Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 12 Apr 2010
Offline Last Active Nov 24 2015 02:58 AM

#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



#5214156 How to initialize Texture2DArray?

Posted by nikitablack on 03 March 2015 - 03:52 AM

Update. Everything is much more simple. It turned out that dds format supports several textures in one file. And CreateDDSTextureFromMemory() do all the job. All we need to do is just create dds with texassemble tool (https://directxtex.codeplex.com/wikipage?title=Texassemble) and supply to texture creation function.

#5209966 Clip (mask out) child by parent bounds.

Posted by nikitablack on 11 February 2015 - 03:48 AM

Nevertheless, you could implement this in a shader, just discard the pixels which are not inside the bounding rect of the parent element.


If you have only axis-aligned rectangles you can simply clip them when filling up your vertex buffer.



As I wrote in PS, I have rotating quads. Also quads can have round corners (and maybe holes) so it will be difficult to calculate it analytically. It was my mistake that I wrote about quads. I probably have to write arbitrary geometry. 


For non-rectangular regions, you could use a second texture as a mask and do manual blending (so to speak) in the pixel shader. This can of course be combined with the above approach.



This sounds interesting. Can you give more insights please?

#5209762 Does gpu guaranties order of execution?

Posted by nikitablack on 10 February 2015 - 02:39 AM

Thank you.

#5209056 int attribute interpolation from vertex shader to pixel shader.

Posted by nikitablack on 06 February 2015 - 08:19 AM

Oh, thank you. No, there's no errors/warnings even if I specify interpolation (linear) explicitly.

#5208656 How to read and write to texture in place in pixel shader?

Posted by nikitablack on 04 February 2015 - 10:48 AM

Oops, the problem was in this line:

context->OMSetRenderTargetsAndUnorderedAccessViews(D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL, NULL, NULL, 1, 1, uavStencilView.GetAddressOf(), 0);

And very confusiong documentation (https://msdn.microsoft.com/en-us/library/windows/desktop/ff476465%28v=vs.85%29.aspx):


RTVs, DSV, and UAVs cannot be set independently; they all need to be set at the same time.






In this situation, OMSetRenderTargetsAndUnorderedAccessViews binds only UAVs.



In my case using D3D11_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL doesn't work. Specifying render target and depth/stencil buffer do the job. It would be cool to hear why this works so.

#5194409 Creating a game launcher.

Posted by nikitablack on 24 November 2014 - 08:02 AM

Greetings dear community.


Although my question is not 100% game related, I didn't find the better place to put my topic.


I need to create a launcher for our game. This will be online game and I need a way to easily update it. Also launcher itself should be easily updateable. I mostly interested in high level architecture, i.e. how thing works at all. Our game will be cross platform, but for now I'm trying to do it for Windows (Win7). There's very little info in the web, so I don't know what is the "industry standard". I investigated how major launcher/programs work, and here's a quick description:


1. Launching Battle.net launches 2 exes - Battle.net.exe and Agent.exe. I suppose that Battle.net.exe is user interface exe and Agent.exe always runs in background. This Agent.exe can be found in C:\ProgramData\Battle.net\Agent\... folder. But what is this Agent.exe for? Why it's in ProgramData folder? Who starts who - agent starts launcher or other way? What I like about Blizzard's work - I don't have any system dialogs while run a program, like dialog asking to run as administrator.


2. Steam is seems only one process in task manager. When it's time to update, who updates exe? As far as I know the program can't update itself (at least on windows - you can't replace running exe).


Thank you.