This took me a while to figure as a D3D12 newbie and I did not find anything searching the web. Shaders compiled fine, all resources acquired but the output kept being black. After setting debug level to max and enabled GPU validation I got the error message, followed by some kind of assembler trace and operand dump.
D3D12 ERROR: GPU-BASED VALIDATION: Draw, Uninitialized root argument accessed. Shader Stage: PIXEL, Root Parameter Index: [1]
720 views Asked by JKrahmann At
1
This error is raised if you have set root parameters in your RootSignature and not SetGraphicsRootDescritporTable() or SetGraphicsRootConstantBufferView() or similar for each slot in your render loop. I accidentally wrote only
which was copied from D3D12HelloTexture example and turned wrong in many ways for my program.
I use a volatile constant buffer, a couple of static textures and a volatile render texture for a post processing shader. So root signature's resource part looks like this:
All my SRVs fit to same descriptor table but have different access flags. So we need 2 ranges. Note: The last parameter for the descriptor range (table) is the offset in your DescriptorHeap. You need to make sure, every descriptor gets it's own index. This corresponds to a slot of GetDescriptorHandleIncrementSize in your DescriptorHeap on GPU. Make sure to use these values, when CreateShaderResourceView later:
CBV goes directly to root descriptor to save one indirection, thus it dosn't live in the DescriptorHeap so we need to set the it in render loop:
Note: first parameter corresponds to rootParameter[] slot from above.
Solved and running fine now.