• Advertisement
  • Popular Tags

  • Popular Now

  • Advertisement
  • Similar Content

    • By isu diss
      How do I fill the gap between sky and terrain? Scaling the terrain or procedural terrain rendering?

    • By Jiraya
      For a 2D game, does using a float2 for position increases performance in any way?
      I know that in the end the vertex shader will have to return a float4 anyway, but does using a float2 decreases the amount of data that will have to be sent from the CPU to the GPU?
       
    • By ThunderTwonk
      Hello everyone, I am working on a game idea and since I am still in the process of learning C# and the features available in unity I was hoping some of you might be able to offer me a little insight on things in general for getting started.
      I guess the basic components of what I'm wanting to create would be a Multi-levels management/city builder/rpg.
      The goal is to provide a framework for players to interact with, build in and affect the world both from a 3rd person action RPG as well as a zoomed out 4x style view (This would be something unlocked through gameplay)
       
      As for my questions go I was wondering if anyone had resources that could help me learn.  I've been on youtube as well as enrolled in an online course for basic unity and C# and will continue those but if anyone has any words of advice, a place that has good information and tutorials etc.
       
      Thanks for your time.
    • By INFRA
      SCAN. DRILL. SURVIVE.   ISOLATED Release in May 1st 2018   https://store.steampowered.com/app/805950/Isolated/   A game by Jérémie Bertrand Music & Sound Design by Pierrick Querolle *** Our solar system has been invaded by strangers. For the purpose of a possible negotiation, a team of astronauts is sent to the moon. Alas, they are shot before even arriving on the scene. Only one astronaut survives the crash and his only goal will be to go home...   GAMEPLAY   Shoot enemy ships to avoid being invaded. Be precise in your movements, because it's better to lose a bit of life at the top than to lose it all at the bottom. Take out your drill to destroy the stones in your path. Validate your identity to cross the different laboratories. Reach the flag before losing your three lives.   And all that... at the same time! Will you be able to go home? If the answer is yes, how long will it take?
    • By ucfchuck
      I am feeding in 16 bit unsigned integer data to process in a compute shader and i need to get a standard deviation.
      So I read in a series of samples and push them into float arrays
      float vals1[9], vals2[9], vals3[9], vals4[9]; int x = 0,y=0; for ( x = 0; x < 3; x++) { for (y = 0; y < 3; y++) { vals1[3 * x + y] = (float) (asuint(Input1[threadID.xy + int2(x - 1, y - 1)].x)); vals2[3 * x + y] = (float) (asuint(Input2[threadID.xy + int2(x - 1, y - 1)].x)); vals3[3 * x + y] = (float) (asuint(Input3[threadID.xy + int2(x - 1, y - 1)].x)); vals4[3 * x + y] = (float) (asuint(Input4[threadID.xy + int2(x - 1, y - 1)].x)); } } I can send these values out directly and the data is as expected

                             
      Output1[threadID.xy] = (uint) (vals1[4] ); Output2[threadID.xy] = (uint) (vals2[4] ); Output3[threadID.xy] = (uint) (vals3[4] ); Output4[threadID.xy] = (uint) (vals4[4] ); however if i do anything to that data it is destroyed.
      If i add a
      vals1[4] = vals1[4]/2; 
      or a
      vals1[4] = vals[1]-vals[4];
      the data is gone and everything comes back 0.
       
       
      How does one go about converting a uint to a float and performing operations on it and then converting back to a rounded uint?
  • Advertisement
  • Advertisement

DX11 Rendering Thread Architecture

Recommended Posts

So I wanted to ask a question pertaining to rendering thread architecture. I currently know of two main designs.

One approach is where visibility , drawcall logic, and gpu submission are all done on the rendering thread and render related game data is sent to the rendering thread at the end of the frame. 

The second approach is where the sole responsibility of the rendering thread is to send gpu commands to the api. Engine abstacted Command Buffers will be generated in parallel or on the game thread, and sent to the rendering thread to be translated into gpu commands.

I know that Engines such as Unreal Engine use the first approach, while Unity / Source use the second approach , and Cryengine uses a hybrid of both. I wanted to see if anyone could give some advice, I know some of the benefits of both approaches , but wanted to get more incite on the architecture.

Share this post


Link to post
Share on other sites
Advertisement

My current architecture is one game thread , one rendering thread, and two worker threads. Both the rendering thread and the game thread can access the workers, i.e the rendering thread does visibility culling on up to three threads (including the rendering thread).  I have "scene proxy" objects that contain all data for rendering , and are synced at the end of the game frame. My issue with this architecture is that it doesn't fully utilize the strengths of DX12 and Vulkan. I would not need a dedicated thread , I guess to solve this, I could check the API that the user has and scale accordingly? I.e if the user is using DX11 or OpenGL I use the dedicated thread approach , and if the use is using vulkan , I will not have a dedicated rendering thread and just use all four cores for API command buffer generation. I've seen that some engines still use the dedicated rendering thread , but also use their job systems to create the command lists, and then call ExecuteCommandList on the dedicated thread, but that doesn't seem like an optimal approach.

Share this post


Link to post
Share on other sites

I use a similar arch, but the gameplay / render threads are also part of the pool and will attempt to execute jobs when idle. This means that rendering work can run on all 4 threads.

The rendering thread can kick off draw-call submission to the job system if you've got a lot of draws. Yeah, I expose a caps variable describing whether threaded command buffers are supported (D3D11) and whether they're actually recording HW commands (D3D12/Vulkan) or not.

On D11, I use a deferred context to record my GUI commands on another thread, just because GUI traversal is expensive and it's intertwined with draw submission. 

For the main scene, I cull and collect drawables in a platform independent manner. Then on D11/GL, one thread records them to the immediate context.

On D12/Vulkan, they're broken into batches that are thrown into the job queue for recording to many command buffers. These jobs could submit those command buffers to the GPU, but that would result in non-deterministic draw ordering. To preserve ordering, one thread submits all of the command buffers in a single call after those jobs have completed. 

Share this post


Link to post
Share on other sites

Ah , I see . Do you cull and collect drawables on the rendering thread ( i.e the rendering thread + worker threads ) ? Or do you cull / collect drawables on the game thread (game thread+ worker threads) and then send "drawitems" to the rendering thread to be translated into dx11 calls?

Share this post


Link to post
Share on other sites

Yeah, I take a snapshot of the gameplay state and pass it from the game thread to the render thread, which includes object transforms, etc...

The render thread then culls and extracts draw-items. Generally there's many draw-items for a single model, which the game doesn't care about. It just wants to place a model in the world, not care that it's made up of 100 sub-meshes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement