Skip to content

ExecuteIndirect example: Which indirect argument buffer structure for which indirect argument type? #900

@caotrem

Description

@caotrem

Hey there,

maybe I get something fundamentally wrong but the documentation does not say anything about which indirect argument buffer structure needs to be used for which indirect argument type in the IndirectCommand structure: https://learn.microsoft.com/en-us/windows/win32/direct3d12/indirect-drawing

In the ExecuteIndirect example the SceneConstantBuffer argument is defined as INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW. Intuitivly I would think that in the IndirectCommand structure the CBV needs to be of type D3D12_CONSTANT_BUFFER_VIEW_DESC which consists of the BufferLocation and its SizeInBytes.

typedef struct D3D12_CONSTANT_BUFFER_VIEW_DESC {
  D3D12_GPU_VIRTUAL_ADDRESS BufferLocation;
  UINT                      SizeInBytes;
} D3D12_CONSTANT_BUFFER_VIEW_DESC;

But in the example only a D3D12_GPU_VIRTUAL_ADDRESS is used in the IndirectCommand structure to give the buffer location without the size.

struct IndirectCommand
{
    D3D12_GPU_VIRTUAL_ADDRESS cbv;
    D3D12_DRAW_ARGUMENTS drawArguments;
};

So why does it work? And is there any documentation to make clear which indirect argument buffer structure needs to be used for which indirect argument type? My search so far didn't give me any answers.

Also there is no documentation which union fields need to be set in D3D12_INDIRECT_ARGUMENT_DESC for which type.

I would find it helpful to have a table in the docs like this:

D3D12_INDIRECT_ARGUMENT_TYPE                  |      D3D12_INDIRECT_ARGUMENT_DESC       |     Indirect Argument Buffer Structure
**********************************************************************************************************************************
INDIRECT_ARGUMENT_TYPE_DRAW                   |     -                                   |      D3D12_DRAW_ARGUMENTS 
----------------------------------------------------------------------------------------------------------------------------------
...                                           |     ...                                 |      ....
----------------------------------------------------------------------------------------------------------------------------------
INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW   |    ConstantBufferView                   |      CONSTANT_BUFFER_VIEW_DESC ???
----------------------------------------------------------------------------------------------------------------------------------
...

Thanks for looking into it!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions