Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

TiagoCosta

Member Since 26 Nov 2008
Online Last Active Today, 05:44 AM
-----

Posts I've Made

In Topic: DX11 InstanceDataStepRate

06 May 2013 - 09:53 AM

It can be useful in some effects.

 

Example:

 

Drawing a model multiple times at different positions in pairs (each pair with a different tint).

struct VS_IN
{
    float3 position;
    ...
    float4x4 instanceWorld : mTransform ;
    float4 tint : mTint;
};
 

 

Since 2 instances should be draw with the same tint the instance step rate is 2

const D3D11_INPUT_ELEMENT_DESC instlayout[] =
{
    ...
    { L"mTransform", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTransform", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTransform", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTransform", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
    { L"mTint", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0, D3D11_INPUT_PER_INSTANCE_DATA, 2 },
};

 

Most common instancing effects use step rate = 1 though.


In Topic: Simplifying renderer architecture

05 May 2013 - 08:55 AM

You don't need to "predict" it. You have been given this information explicitly by the assets when the draw calls were built.
Shaders don't change after the assets have been loaded. At worse, the value contained in their uniform buffers do, or perhaps in the textures. But the code permutation, vertex buffer layout and such is constant. No need to "predict" anything.

Shaders might change. Example: In a forward renderer I might have multiple shader permutations each used to draw an actor affected by n lights, so the shader used by each actor depends of the actor and lights positions.

In Topic: Render queue texture clearing

16 April 2013 - 01:05 PM

Do I need a seperate command for submitting a state group only for my render queue (because now I only support render instance submitting), or do you mean "submit" here more like explicitely set those states here?

 

Can't you simply submit the state group in a RenderItem with the draw call as null?
Or you could explicitely set those states... Anyway should work fine.


In Topic: Render queue texture clearing

16 April 2013 - 05:48 AM

IMO, you should create a new class, let's call it Stage along with a new StateGroup, and move the render target binding/clearing to it (now the Effects state group will only bind the hardware shaders and set default shader values).

 

In my renderer, models can have more than one RenderItem (draw call/state groups pair) each one is assigned to a Stage. Example: the RenderItem assigned to the Shadow Mapping stage doesn't need the material state group to be executed)

 

As you can read in this topic, the renderer has multiple buckets (lists of RenderItems) each bucket is associated with a Stage. Before rendering the renderer goes through the Scene (a list of model instances, etc) finds all the model instances and puts its RenderItems in the appropriate bucket.

 

Then Stages are executed according to the order defined in the renderer_config file: the bucket associated with each stage is sorted (if needed), the state group of that stage (containing the render target clearing/binding commands) is submitted and only then the RenderItems inside the bucket are submitted.


In Topic: Render queue texture clearing

15 April 2013 - 12:08 PM

I do also have stage groups, probably a lot like yours. As in one of Hodgmans posts, my model, material and effect all holds their own state group, which the model puts together and submits to the queue.

 

In my implementation the models don't have access to the render queue, (in my opinion the model class should be independent on the Renderer), instead the model class has a method getStateGroups() an array containing the effect, material, mesh, model state groups.

 

for(Model model : models)
{
    queue.submit(model.getStageGroups(), model.getNumStateGroups();
}

 

 

Now that you say "models, materials and effects should not have anything to do" with clearing render targets - how do you set the stage group anyway? Since each of those entities have their own stage groups, command injection has to go through them, at some point, right? E.g. my model has a "SetVertexConstant"-method that adds a VertexConstantX-command to the stage. How do you handle this? Thats a question I was going to ask anyway at some point, because I was really unsure how this is normally done.

 

The Stage group is submitted individually before the models. How do you bind render targets/depth stencil buffers?

 

I don't have commands to set individual constants, instead I work with constant buffers, the model "SetVertexConstant"-method will change the value of the constant in a POD buffer then the model uses two commands, UpdateCBuffer (that fills a D3D buffer with the contents of the POD buffer containing the constants) and VSBindCBuffer0 (that binds the D3D buffer to the constant buffer slot 0 of the vertex stage)


PARTNERS