Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Apr 2010
Offline Last Active Jul 22 2016 06:44 AM

#5301698 How To Use Dx Ortho Projection Matrix

Posted by nikitablack on 21 July 2016 - 01:59 AM

You can find a better documentation here: D3DXMatrixOrthoOffCenterLH and D3DXMatrixOrthoLH.

#5296584 [D3D12] How to correctly update constant buffers in different scenarios.

Posted by nikitablack on 15 June 2016 - 02:11 AM

Thanks guys. I understood, the waiting for the queue signal not necessary here. Thought it can be used to make sure that operation completed and release the temporary upload heap.


p.s.: I just realized that @iedoc is an author of amazing directx tutorials and I want to say thank you, I was followed your posts for a long time :).

#5295927 [D3D12] How to correctly update constant buffers in different scenarios.

Posted by nikitablack on 10 June 2016 - 02:34 AM



This topic is super confusing for me and I hope you'll help me to understand it better. Here several usage scenarios:


1. I have n objects and for every object I need to change a constant data before draw. Let's say the constant data ConstData have one integer field and is different for every object. I have a constant buffer consBuffer and I need to update it. In pseudo code:

ConstData cd;

cd.data = 1;

ptr = consBuffer.Map();
memcpy(ptr, cd);


cd.data = 2;

ptr = consBuffer.Map();
memcpy(ptr, cd);



It well known that draw doesn't happen immediately but goes to the gpu queue for later execution. And from the code I wrote I see that when the gpu is ready to actually draw object1 the constant data will be overridden by later calls to memcpy. Does that mean that I need to have a different constant buffer for every object? So if I have 100 objects and 2 back buffers I need 100 * 2 = 200 constant buffers. Is it right?


2. If I want to store a constant data directly in root signature, can I update the root signature before every draw call? Taking my previous example, I will not have calls to Map()/memcpy()/Unmap(), but will write directly to signature. Do I need to wait until previous object or frame finished rendering?


3. If I have rarely changed constant buffer, a projection matrix, for example, do I need to have different constant buffers for every render target? In other words, if projection matrix was changed can I safely update buffer only once and hope that changes will propagate to all frames in the queue?



#5289222 Procedural character animations. What is the state of the art?

Posted by nikitablack on 29 April 2016 - 06:35 AM



I'm a programmer and I'm interested in programmatic character animation - walk, run, bipedal, many-legs creatures etc. What is the state of the art today? I heard about NaturalMotion's Euphoria system. Also I saw Ubisoft's IK Rig system. They look amazing. Where can I find info about similar algorithms?

#5285258 [D3D12] Synchronization on resources creation. Need a fence?

Posted by nikitablack on 05 April 2016 - 08:55 AM



In D3D12HelloTriangle example there's an interesting synchronization in LoadAssets() function. They call WaitForPreviousFrame() function. I understand why we need it during a rendering. But in this particular example I can't get the purpose of a such synchronization. They are not submitting anything to the gpu (or they do???). They're using an upload heap for the single resource here - vertex buffer. As I understand the upload resource exists on the cpu side and the data is transferred every time the gpu needs it. So no need a fence here. They also create a root signature, pso, fence object itself. So maybe for this objects we need a synchronization? Is it somewhere in documentation?

#5272578 [D3D12] Is ExecuteCommandLists asynchronous, does Present stalls, how signall...

Posted by nikitablack on 25 January 2016 - 10:04 AM

Thank you guys. Now it's clear.


Recently I read Intel's article and it helped me a lot to understand swap chains. Highly recommend.

#5263254 Render GUI elements with projection matrix

Posted by nikitablack on 23 November 2015 - 08:08 AM

If you want to preserve depth you still can use ortho matrix. If you turn off depth wright, the triangles will be drawn in the order you submitted them.

#5252881 Does D3D11_BIND_UNORDERED_ACCESS and D3D11_BIND_SHADER_RESOURCE should be alw...

Posted by nikitablack on 18 September 2015 - 08:53 AM

Thank you for the explanation. It's much clearer for me now. But I think you're mistaken (a typo?) in a couple of moments:

"Shader resource" means it can be bound with *SSetShaderResources on the CPU side, and a u# register on the HLSL side (RWBuffer, RWTexture#D, etc).

But in order to write somewhere I have to use UAV, so RWBuffer is not a shader resource but UAV, right?

According to documentation (https://msdn.microsoft.com/en-us/library/windows/desktop/dd607359(v=vs.85).aspx) u# register is used for Unordered Access View and t# for Texture and texture buffer and buffers.

#5252835 Computations with DirectCompute. How to get data back?

Posted by nikitablack on 18 September 2015 - 02:31 AM



I'm trying to use my gpu for computations only (I don't even create a swap chain). But I'm not sure how to retrieve a data after shader do it's job. I want to modify the same data I passed. For this I'm using single structured buffer binded as D3D11_BIND_UNORDERED_ACCESS.


As far as I know I need to use D3D11_CPU_ACCESS_READ together with D3D11_USAGE_STAGING. But in this case I have an error:

A D3D11_USAGE_STAGING Resource cannot be bound to any parts of the graphics pipeline, so therefore cannot have any BindFlags bits set.

My next approach was to create a structured unordered buffer with D3D11_USAGE_DEFAULT usage. I applied calculations on it, next I called 


to copy this buffer to the one with D3D11_CPU_ACCESS_READ and finally read the data. But I'm not sure this is a correct way - I don't like this extra copying between resources.

#5236548 How does games manage different resolutions?

Posted by nikitablack on 24 June 2015 - 06:40 AM

Thank you, guys.


I chose this approach:

  1. Allow the user to select from available gpus with outputs (i.e. if gpu doesn't have an output - ignore it).
  2. After swap chain creation I'm requesting for an output with swapChain->GetContainingOutput()
  3. Request for supported resolutions and refresh rates.
  4. For windowed mode I'm ignoring resolution selection, just resizing as MJP said.

#5235691 How does games manage different resolutions?

Posted by nikitablack on 19 June 2015 - 08:45 AM

@ninnghazad, I see you misunderstood a question. I know how to obtain all the information I need (btw, why are you strongly suggest not do so?). All I want to know how to use this info or how other do it.


One more example - I have a laptop with 2 gpus. Obviously that only one - integrated gpu have an output. The more powerful discrete gpu don't have outputs. Following your words I should ignore it. But of course I shouldn't and in fact I'm using only it for games. But how does system knows where to output a picture in that case. Personally for me EnumOutputs() looks useless for the scenario with more that one gpu.

#5235682 How does games manage different resolutions?

Posted by nikitablack on 19 June 2015 - 07:48 AM

Hi, thank you for the answer.


I know how to setup for basic rendering. My next step in learning is to understand this low level stuff.


Description for GLFW states that it's a library for OpenGL or OpenGL ES. And we're in DirectX section, so this is not very helpful for me. Thought I got an idea, there's still a question - what to do if the user selected an adapter with zero outputs?

#5235667 How does games manage different resolutions?

Posted by nikitablack on 19 June 2015 - 06:16 AM



We all saw that every game allows to select a resolution. It looks simple but some questions doesn't give me to sleep.


  1. How can I obtain available resolutions? Just take the most popular and hardcode?
  2. I can iterate over available outputs and find supported resolutions as well as sync intervals. But what if the user selected an adapter that is not have any output bounded (actually how does this works at all - I have 2 GPUs, I can switch between them, and I always have a picture, even if a card doesn't have an output)?
  3. What if the user have several monitors. How should I choose correct one (and should I at all)?
  4. In Starcraft 2 I noticed that in windowed mode there's no resolution selection at all - I can resize a window and picture scales accordingly. How it is done? Do they have fixed resolution for the windowed mode?

#5219341 Direct3D 12 documentation is now public

Posted by nikitablack on 26 March 2015 - 09:32 AM

Hybrid notebook systems should not be currently supported

That's sad. I hope D3D_DRIVER_TYPE_REFERENCE is implemented.

#5216076 [solved] How to debug compute shader with visual studio?

Posted by nikitablack on 12 March 2015 - 09:42 AM



Debugging vertex/pixel shader works fine, but I have a problem with compute shader debug. After pressing Alt+F5 diagnostic starts, but pressing PrintScreen or CaptureFrame button does nothing.




Upd.: didn't notice this in the beginning:

Programmatic capture is especially useful for debugging compute shaders in programs that never call Present