jpvanoosten / learningdirectx12 Goto Github PK
View Code? Open in Web Editor NEWThis repository is intended to be used as a code repository for learning DirectX 12.
Home Page: https://www.3dgep.com
License: MIT License
This repository is intended to be used as a code repository for learning DirectX 12.
Home Page: https://www.3dgep.com
License: MIT License
Currently only the functions exist for binding them through a descriptor heap.
I have come across two .png images which cause a crash when it is being loaded with CommandList::LoadTextureFromFile. It seems to be an issue where the formats are mismatched when generating mips.
This is with the latest revision of master (at the time of writing).
STEPS TO REPRODUCE
Download the images from below, and put them in Assets/Textures/[image_name].png
Load the texture like normal. For example in Tutorial4.cpp at line 193, insert:
Texture tempTex;
commandList->LoadTextureFromFile(tempTex, L"Assets/Textures/AlKharidWarrior.png");
Error message
D3D12 ERROR: ID3D12Device::CreateShaderResourceView: The Format (0x57, B8G8R8A8_UNORM) is invalid when creating a View; it is not a fully qualified format within the same family as the Format of the Resource (0x1c, R8G8B8A8_UNORM). [ STATE_CREATION ERROR #28: CREATESHADERRESOURCEVIEW_INVALIDFORMAT]
D3D12: **BREAK** enabled for the previous message, which was: [ ERROR STATE_CREATION #28: CREATESHADERRESOURCEVIEW_INVALIDFORMAT ]
Exception thrown at 0x00007FFE8608A388 (KernelBase.dll) in Tutorial4.exe: 0x0000087A (parameters: 0x0000000000000001, 0x0000000429168810, 0x000000042916A710).
Unhandled exception at 0x00007FFE8608A388 (KernelBase.dll) in Tutorial4.exe: 0x0000087A (parameters: 0x0000000000000001, 0x0000000429168810, 0x000000042916A710).
Stacktrace
Tutorial4.exe!Texture::CreateShaderResourceView(const D3D12_SHADER_RESOURCE_VIEW_DESC * srvDesc) Line 189
Tutorial4.exe!Texture::GetShaderResourceView(const D3D12_SHADER_RESOURCE_VIEW_DESC * srvDesc) Line 217
Tutorial4.exe!CommandList::SetShaderResourceView(unsigned int rootParameterIndex, unsigned int descriptorOffset, const Resource & resource, D3D12_RESOURCE_STATES stateAfter, unsigned int firstSubresource, unsigned int numSubresources, const D3D12_SHADER_RESOURCE_VIEW_DESC * srv) Line 892
Tutorial4.exe!CommandList::GenerateMips_UAV(Texture & texture, DXGI_FORMAT format) Line 550
Tutorial4.exe!CommandList::GenerateMips(Texture & texture) Line 472
Tutorial4.exe!CommandList::GenerateMips(Texture & texture) Line 359
Tutorial4.exe!CommandList::LoadTextureFromFile(Texture & texture, const std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> > & fileName, TextureUsage textureUsage) Line 346
Tutorial4.exe!Tutorial4::LoadContent() Line 195
On Monday we were tracking a bug where loading the textures for a mesh would randomly cause the DirectX error: D3D12_RESOURCE_STATES has bits that mismatch support required from D3D12_RESOURCE_FLAGS
.
I found a minimal way to reproduce this error. Firstly, write a simple loop (I put this in Tutorial3::LoadContent()
):
auto commandQueue = Application::Get().GetCommandQueue(D3D12_COMMAND_LIST_TYPE_COPY);
Texture dummyTextures[20];
for (int i = 0; i < 20; ++i)
{
auto commandList = commandQueue->GetCommandList();
commandList->LoadTextureFromFile(dummyTextures[i], L"Assets/Textures/Directx9.png");
auto fenceVal = commandQueue->ExecuteCommandList(commandList);
commandQueue->WaitForFenceValue(fenceVal);
}
THEN you need to disable the cache check in CommandList::LoadTextureFromFile()
so you are actually emulating loading a lot of different textures after each other. Otherwise the command doesn't do anything on the gpu.
...
auto iter = ms_TextureCache.find( fileName );
if ( false /*iter != ms_TextureCache.end()*/ )
{
texture.SetTextureUsage(textureUsage);
texture.SetD3D12Resource(iter->second);
texture.CreateViews();
texture.SetName(fileName);
}
else
{
TexMetadata metadata;
....
Then after usually ~5 iterations you will get the same error we know and love:
D3D12 ERROR: ID3D12CommandList::ResourceBarrier: D3D12_RESOURCE_STATES has bits that mismatch support required from D3D12_RESOURCE_FLAGS. [ RESOURCE_MANIPULATION ERROR #524: RESOURCE_BARRIER_MISMATCHING_MISC_FLAGS]
D3D12: **BREAK** enabled for the previous message, which was: [ ERROR RESOURCE_MANIPULATION #524: RESOURCE_BARRIER_MISMATCHING_MISC_FLAGS ]
Exception thrown at 0x00007FFF3DDAA388 (KernelBase.dll) in EngineLyra.exe: 0x0000087A (parameters: 0x0000000000000001, 0x000000B3B31F5470, 0x000000B3B31F7370).
Unhandled exception at 0x00007FFF3DDAA388 (KernelBase.dll) in EngineLyra.exe: 0x0000087A (parameters: 0x0000000000000001, 0x000000B3B31F5470, 0x000000B3B31F7370).
This makes me suspect that there is some unsafe deletions being made. You mentioned that the cleanup for staging resources and other temporary resources happens on a seperate thread. Perhaps something is not fully thread safe. I will do more debugging tomorrow to find out more.
This was noticed when creating a DebugRenderer which uploads a vertex buffer of lines every frame and then renders it.
perhaps memory will leak here
It should be "copy", not "other".
When minimizing the window, the width and height are set to zero and then it tries to resize the RTV to zero which causes an issue on resizing the textures. Making sure that the width and height will not get below 1 in the resize event args will resolve this problem.
Currently StructuredBuffer::CreateViews() attempts to create a SRV and UAV. Even though sometimes a UAV cannot be created (the resource flag ALLOW_UNORDERED_ACCESS is not set for example).
For example in Indexbuffer.h
size_t GetNumIndicies() const
{
return m_NumIndicies;
}
LearningDirectX12/DX12Lib/src/Application.cpp
Lines 288 to 289 in 01b71e7
...a "break" around line 400.
Please provide m_BufferSize
default value in ByteAddressBuffer
constructors...
We should redesign the for(...) loop to avoid a crash when m_AvailableHeaps.erase(iter)
returns iter.end()
and then is pre-incremented in the current version of for(...) loop.
Let's just move ++iter;
to the end of the current scope and add continue();
after the mentioned line.
When I set g_UseWarp = false
and build and run the program it will crash if I push "alt + enter" many times to go in the borderless state and back but it works perfectly when I set g_UseWarp = true
do you know exactly why?
Missing flushBarriers
argument on:
LearningDirectX12/DX12Lib/src/CommandList.cpp
Line 100 in dc7c1d9
I got the following error message and not sure how to resolve it:
Severity Code Description Project File Line Suppression State
Error CMake Error:
Running
'C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe' '-C' 'C:/Users/mt_la/source/repos/LearningDirectX12/out/build/x64-Debug' '-t' 'recompact'
failed with:
ninja: error: build.ninja:3588: bad $-escape (literal $ must be written as $$) C:\Users\mt_la\source\repos\LearningDirectX12\ ninja
I added the following but still not working:
IF %VS_VERSION% == 17 (
SET CMAKE_GENERATOR="Visual Studio 17 2022"
SET CMAKE_BINARY_DIR=build_vs2022
) ELSE IF %VS_VERSION% == 16 (
SET CMAKE_GENERATOR="Visua ...
Hi,
I am getting a read access violation when I reach this line;
`void Window::RegisterCallbacks(std::shared_ptr arg_pGame)
{
m_pGame = arg_pGame; //Read Access violation here
return;
}
`
I am new to this, but my hunch is that since we are passing it "shared_from_this", it may not be move assignable. I could be completely wrong too.
How would I fix it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.