DirectX 12 Root Constant Buffer Problem

Started by
14 comments, last by karnaltaB 5 years, 8 months ago

Hi,

I am trying to learn D3D12 programming by programming a small engine but I have a strange behavior that I cannot understand.

Basically, I am drawing 200 cubes each frame and between each draw call I use a root 32 bits constant to determine the cube color in my shader. It work fine for a couple of seconds then the root constant seem to stop to be updated and so my shader can't determine color anymore. I don't know why it work and suddenly stop without any debug error.

Here is the pseudo code of what I am doing :


Init()
{
	...
	- Define a float value
	- Create a pointer to this float value
	- Add a root constant to my root signature parameters.
	...
}

RenderLoop()
{
	...
	For 0 to 200
	{
		- Update my float value
		- CommandList->SetGraphicsRoot32BitConstants(floatPtr)
		- Draw cube
	}
}

Thank for help.

Advertisement

Have you tried using PIX For Windows to debug this?

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

27 minutes ago, ajmiles said:

Have you tried using PIX For Windows to debug this?

No yet. The shader is really minimalist. When my cube turns black it’s because the root constant has not an expected value. So I know the problem come from that constant. Can I see root constant life with PIX ? 

You can see the value of a root constant and how it changes with each draw, yes.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

ajmiles is right, you can use the visual studio graphic debugger to have a better idea on what happened with your root parameter. Here's a screenshot of where to look at. I'd suggest playing around with that debugger a bit and get used to all it's features, especially if you're learning DX12. It will save you a lot of time in the future. Otherwise we will need much more than the pseudo-code to help you figure what went wrong.

image.thumb.png.fccb414f32541badc00729ce830a461f.png

The Visual Studio Graphics Debugger (VSGD) should work fine for simple applications, but that particular feature is no longer under active development and is likely to become less useful to DX12 developers as time goes on. "PIX For Windows" is a separate standalone graphics profiler and debugger and is in constant development. I would recommend installing PIX For Windows and using this for any investigations you might want to do in the future.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

Thank all. I have installed PIX it will probably save me a lot of time later.

But in my specific case (really simple app), thing happen as I thought, the constant switch between value 5 and 6 (which is intended) while my app is working and fall down to 0 when all my cubes goes to black.

So, as I expected the root constant stop being updated in the middle of my rendering loop after a few second.

Does that mean you still haven't figured out what's wrong?

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

7 hours ago, ajmiles said:

Does that mean you still haven't figured out what's wrong?

Yes, I haven't figured yet.

I keep learning other aspect, maybe I will find what's wrong when I get a better understanding of D3D12. I understand that it's quite hard for you too help me with that bug, but pasting code is impossible even my small learning engine has dozen of classes.

Sharing a PIX capture with us would probably also solve the problem.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

This topic is closed to new replies.

Advertisement