• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Renderqueue design theory and implementation

5 posts in this topic

I have a rough render queue implementation. However I am struggling with the implementation of spatial meta-data i.e. world-matrices of the command queue but there doesn't seem to be much literature about the subject. My implementation is based on bit-packing the necessary information in as tiny data-structures as possible to achieve narrow command streams/queue. An example of this would be packing a 24-bit fixed-point-math depth-key for including depth-sorting. Prior to rendering the stream(s) are sorted based on the packed data structures allowing for a flexible render system design.

There are several routes i can go with my implementation: 1) Embed the spatial meta-data in the command stream itself, by reserving a portion of the stream in the stride i.e. struct { int sortkey, matrix4x4 worldpos }; 2) Refer to the matrix by id i.e. struct { int sortkey, int matrixId }; 3) Embed the spatial information into a parameter set of the material.

No 1. Is my current implementation since it's straight forward, however this creates quite a wide command stream again, and every shader-pass I apply is added as a separate command. So this solution has possibilities for quite a bit of memory consumption/overhead i.e. 64 bytes extra per call. Deferred rendering in this situation will help somewhat since it minimizes the amount of time the geometry has to be reprocessed and therefor added to the queue, but i estimate you'd have at-least 2 to 3 passes (special effects, shadow mapping etc).

No 2. Seems rather appealing since you have an integer which would makes the command stream narrow again, 60 bytes gained per call. Which would allow for quicker sorting, less memory copying/swapping. However after sorting there is a chance that matrices are accessed in random order i.e. unpredictable fashion and making the algorithm cache hostile in comparison.

No. 3. Seems far from ideal since essentially if we treat the world matrix as another shader parameter the render pipeline has a tendency to be be 'unaware' of it. And my parameter set is optimized for storing their respective parameters for data efficiency rather than lookup efficiency i.e. using homogeneous arrays. Hence forth this solution in my opinion disables interesting instancing concepts with dx11/gl4 hardware i.e. pumping all world matrices into a uniform buffer and unpack them at shader level.

For now solution no. 1 is implemented and suffices for the time being, i also don't anticipate that to change in the foreseeable future, but i would like to orientate/educate myself on what would be considered the 'better' approach to meet the demands for 'scalable, stream-able, massive worlds rendering'. So I would like to know what experience you guys have with various implementations (regarding render queue's, I'm not interested in hearing about visitor patterns for scene-graph traversal) maybe you got something better that I've never considered.

Share this post

Link to post
Share on other sites
maybe someone else understands what you are trying to do --I don't

What exactly are you attempting to do? You never state that in your post. What is your dilemma?

Share this post

Link to post
Share on other sites
[quote name='smasherprog' timestamp='1309210173' post='4828416']
maybe someone else understands what you are trying to do --I don't
What exactly are you attempting to do? You never state that in your post. What is your dilemma?

Well the last paragraph did state what I'm trying do. It however assumes you comprehended the paragraphs above and have some background information on the subject in general. But to summarize: for now I'm not attempting to [i]do[/i] anything; I'm trying to [i]educate [/i]myself with the perspectives / experiences other people might have had on the same subject. The subject I'm interested in is what's considered the 'best' way to organize world-matrices in conjunction with a render queue. They could be adjacent to an individual command as a supplementary argument (making each command say 96 bytes fixed size), or they could be resolved by an indirection ((pointers or index of a well known array) making each command 12 bytes fixed size), or another solution to your liking.

Hope that helps you understand the essence of this post/topic.

Share this post

Link to post
Share on other sites
[quote name='Hodgman' timestamp='1309220049' post='4828468']
Maybe some more details about what stuff goes into your queue would help make it clearer which is the best design for you?

Well the main reason why I'm treating world matrices as a special type is to take advantage of hardware instancing ( i.e. glAttribDivisor ) as introduced in dx11/gl4 hardware. My queue simply exists out { sort_key, mesh, material, matrix4x4 } and only aims to support drawing materials/shaders that are compatible with render-pipeline. The shader-passes that collectively represent a 'material' all have a common structures, mainly this is because the shaders are generated from text-transform-templates this allows me to assume various optimisations: all material based shader can share a 'pipeline based semantic set' (think view-/projection- matrices and viewport settings), all shader-passes and their respective features are implemented in a consistent manner. For instance if the pipeline detected instancing is available for the next sequence of elements, supporting instancing would be as simple as selecting/generating the shader with instancing flag turned on, and generate a cbuffer/bindable uniform buffer with an array of world matrices.

So in short the pipeline is somewhat more restrictive in comparison to your method as it expects a shader-pass to implement a certain contract / behaviour, but it also gains lot of grounds on newly gained heuristics and possible optimizations. Regarding pre-multipled world matrices, i think that could simply be solvable with a boolean to conditionally pre-multiply the matrices. Objects that don't need a world matrix use the identity matrix (but how many of those do really exist?). Skinning similar to instancing could be solved by generating render-pass(es) with skinning support, and uploading the bones into a supplementary cbuffer/bind-able uniform buffer.

Still think reserving the world-matrix as a special purpose semantic is irky? :)

Share this post

Link to post
Share on other sites
OT - How do you deal with other per-mesh-instance states at the moment (besides world transform)? e.g. a per-model colour, or making a particular model fade out, etc... Do you clone it's material and apply the change to the material?[quote name='phr34k9' timestamp='1309232479' post='4828525']Still think reserving the world-matrix as a special purpose semantic is irky? :)[/quote]Yeah, sorry!
You've just added a whole bunch more special cases ([i]pre-multiply flag, skinned flag, etc[/i]) to deal with the fact that there's a special case. I'm sure there's a clean, general system hidden somewhere in that design that just wants to be set free [img]http://public.gamedev.net/public/style_emoticons/default/wink.gif[/img]
As another 'what if' -- what about items that require data other than (or as well as) a world-matrix per instance (e.g. a colour, or a texture offset, etc)?
Regarding identity world-transforms, all static level meshes in the game I'm currently working on have their matrices pre-baked into the vertex data. The static level geo probably makes up over half of the draw-calls.

In my system, I'd perform instance-grouping (and updating of any instance-cbuffers) in the layer above the render queue. E.g. the thing submitting the 'groupable' models would copy all their world matrices into the instance buffer and submit the instanced batch to the queue.
It's also valid to put the instance-grouping on the other side of the queue like you have -- I'd just prefer to do it in a way that doesn't hard-code the type of the per-instance data (i.e. the assumption that instance data == world matrices).

Your pipeline stuff sounds pretty much the same as what I'm working with at the moment -- a state group can bind a "shader", and a shader is a collection of "passes". Each pass is designed to be used by a certain stage of the pipeline. Each pass also has many different permutations (actual shader programs) depending on the currently set options.
e.g. when submitting a model, if you enable the 'instanced' option, then it would select the appropriately generated shader programs like you descirbe.
When submitting a model, it will only be queued up for the pipeline stages that it's shader supports.

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
Sign in to follow this  
Followers 0

  • Similar Content

    • By lonewolff
      Hi Guys,
      I am revisiting an old DX11 framework I was creating a while back and am scratching my head with a small issue.
      I am trying to set the pixel shader resources and am getting the following error on every loop.
      As you can see in the below code, I am clearing out the shader resources as per the documentation. (Even going overboard and doing it both sides of the main PSSet call). But I just can't get rid of the error. Which results in the render target not being drawn.
      ID3D11ShaderResourceView* srv = { 0 }; d3dContext->PSSetShaderResources(0, 1, &srv); for (std::vector<RenderTarget>::iterator it = rtVector.begin(); it != rtVector.end(); ++it) { if (it->szName == name) { //std::cout << it->srv <<"\r\n"; d3dContext->PSSetShaderResources(0, 1, &it->srv); break; } } d3dContext->PSSetShaderResources(0, 1, &srv);  
      I am storing the RT's in a vector and setting them by name. I have tested the it->srv and am retrieving a valid pointer.
      At this stage I am out of ideas.
      Any help would be greatly appreciated
    • By bowerbirdcn
      hi, guys, how to understand the math used in CDXUTDirectionWidget ::UpdateLightDir 
      the  following code snippet is taken from MS DXTU source code
        D3DXMATRIX mInvView;
          D3DXMatrixInverse( &mInvView, NULL, &m_mView );
          mInvView._41 = mInvView._42 = mInvView._43 = 0;
          D3DXMATRIX mLastRotInv;
          D3DXMatrixInverse( &mLastRotInv, NULL, &m_mRotSnapshot );
          D3DXMATRIX mRot = *m_ArcBall.GetRotationMatrix();
          m_mRotSnapshot = mRot;
          // Accumulate the delta of the arcball's rotation in view space.
          // Note that per-frame delta rotations could be problematic over long periods of time.
          m_mRot *= m_mView * mLastRotInv * mRot * mInvView;
          // Since we're accumulating delta rotations, we need to orthonormalize 
          // the matrix to prevent eventual matrix skew
          D3DXVECTOR3* pXBasis = ( D3DXVECTOR3* )&m_mRot._11;
          D3DXVECTOR3* pYBasis = ( D3DXVECTOR3* )&m_mRot._21;
          D3DXVECTOR3* pZBasis = ( D3DXVECTOR3* )&m_mRot._31;
          D3DXVec3Normalize( pXBasis, pXBasis );
          D3DXVec3Cross( pYBasis, pZBasis, pXBasis );
          D3DXVec3Normalize( pYBasis, pYBasis );
          D3DXVec3Cross( pZBasis, pXBasis, pYBasis );
    • By YixunLiu
      I have a surface mesh and I want to use a cone to cut a hole on the surface mesh.
      Anybody know a fast method to calculate the intersected boundary of these two geometries?
    • By hiya83
      Hi, I tried searching for this but either I failed or couldn't find anything. I know there's D11/D12 interop and there are extensions for GL/D11 (though not very efficient). I was wondering if there's any Vulkan/D11 or Vulkan/D12 interop?
    • By lonewolff
      Hi Guys,
      I am just wondering if it is possible to acquire the address of the backbuffer if an API (based on DX11) only exposes the 'device' and 'context' pointers?
      Any advice would be greatly appreciated
  • Popular Now