d3d:d3d12:indirect
差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
| d3d:d3d12:indirect [2015/09/21 15:20] – [CommandSignature] oga | d3d:d3d12:indirect [2015/09/22 20:27] (現在) – [Command (Argument Buffer) で渡せるもの] oga | ||
|---|---|---|---|
| 行 7: | 行 7: | ||
| - | ==== Command (Argument Buffer) で渡せるもの ==== | + | ===== Command (Argument Buffer) で渡せるもの |
| * Draw 命令のパラメータ (Index 数, Vertex数, Instance 数、それぞれの offset 等) | * Draw 命令のパラメータ (Index 数, Vertex数, Instance 数、それぞれの offset 等) | ||
| * Dispatch 命令のパラメータ | * Dispatch 命令のパラメータ | ||
| - | * CBV Buffer の GPU Address | ||
| - | * SRV Buffer の GPU Address | ||
| - | * UAV Buffer の GPU Address | ||
| * VertexBuffer の GPU Address | * VertexBuffer の GPU Address | ||
| - | * RootSignature の Root32bitConstant の値 | + | * RootSignature |
| + | * RootDescriptor CBV の GPU Address | ||
| + | * RootDescriptor SRV (Buffer) の GPU Address | ||
| + | * RootDescriptor UAV (Buffer) の GPU Address | ||
| + | * Root32bitConstant の値 | ||
| どのようなパラメータを渡すのか、予めフォーマットを定義しておく必要があります。 | どのようなパラメータを渡すのか、予めフォーマットを定義しておく必要があります。 | ||
| + | * 2015/09/21 現在判明している問題 | ||
| + | * RADEON GCN 15.8 で Root32bitConstant/ | ||
| + | * GeForce Kepler/ | ||
| + | * Intel HD Graphics では RootSignature に 32bitConstant が複数存在する場合 CommandSignature で最初の constant しか反映されません。 | ||
| + | |||
| + | |||
| + | |||
| + | ^ Type ^ Argument Data ^ | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_DRAW | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW | ||
| + | | D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW | ||
| + | |||
| + | |||
| + | |||
| + | ===== CommandSignature ===== | ||
| - | ==== CommandSignature | + | ==== Root 32bit Constant |
| CommandSignature は Argument Buffer のフォーマットを定義します。 | CommandSignature は Argument Buffer のフォーマットを定義します。 | ||
| + | 下記の例では、ArgumentBuffer に直接 Matrix を埋め込んでいます。 | ||
| + | 描画のたびに RootSignature の Parameter Slot 0 が置き換わるわけです。 | ||
| 行 48: | 行 73: | ||
| </ | </ | ||
| - | バッファ内のパラメータ配置例 | + | バッファ内のパラメータ配置例。CPU で書き込んでいますが、もちろん ComputeShader を用いて動的に作成することも可能。 |
| <code cpp> | <code cpp> | ||
| 行 63: | 行 88: | ||
| } | } | ||
| </ | </ | ||
| + | |||
| + | 実行 | ||
| + | |||
| + | <code cpp> | ||
| + | iCommandList-> | ||
| + | </ | ||
| + | |||
| + | ==== Root Descriptor ==== | ||
| + | |||
| + | RootDescriptor は GPU Address を直接格納します。 | ||
| + | |||
| + | <code cpp> | ||
| + | struct DrawArgument { // 32byte | ||
| + | D3D12_GPU_VIRTUAL_ADDRESS | ||
| + | D3D12_DRAW_INDEXED_ARGUMENTS Draw; // 20byte | ||
| + | unsigned int | ||
| + | }; | ||
| + | |||
| + | D3D12_INDIRECT_ARGUMENT_DESC | ||
| + | memset( arg, 0, sizeof(arg) ); | ||
| + | arg[0].Type= D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW; | ||
| + | arg[0].ConstantBufferView.RootParameterIndex= 0; | ||
| + | arg[1].Type= D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED; | ||
| + | |||
| + | D3D12_COMMAND_SIGNATURE_DESC | ||
| + | memset( &desc, 0, sizeof(desc) ); | ||
| + | desc.ByteStride= sizeof(DrawArugment); | ||
| + | desc.pArgumentDescs= arg; | ||
| + | desc.NumArgumentDescs= 2; | ||
| + | |||
| + | iD3DDevice-> | ||
| + | </ | ||
| + | |||
| + | 参照するバッファの作成 | ||
| + | |||
| + | <code cpp> | ||
| + | D3D12_RESOURCE_DESC | ||
| + | memset( &desc, 0, sizeof(desc) ); | ||
| + | desc.Dimension= D3D12_RESOURCE_DIMENSION_BUFFER; | ||
| + | desc.Width= OBJECT_COUNT * AlignedGeometryBufferSize; | ||
| + | desc.Height= 1; | ||
| + | desc.DepthOrArraySize= 1; | ||
| + | desc.MipLevels= 1; | ||
| + | desc.SamleDesc.Count= 1; | ||
| + | desc.Layout= D3D12_TEXTURE_LAYOUT_ROW_MAJOR; | ||
| + | |||
| + | D3D12_HEAP_PROPERTIES | ||
| + | memset( &heap, 0, sizeof(heap) ); | ||
| + | heap.Type= D3D12_HEAP_TYPE_UPLOAD; | ||
| + | |||
| + | ID3D12Resource* | ||
| + | iD3DDevice-> | ||
| + | </ | ||
| + | |||
| + | Command を作成します。 | ||
| + | |||
| + | <code cpp> | ||
| + | D3D12_GPU_VIRTUAL_ADDRESS | ||
| + | void* ptr= nullptr; | ||
| + | iArgumentBuffer-> | ||
| + | auto arg= reinterpret_cast< | ||
| + | for( int i= 0 ; i< OBJECT_COUNT ; i++, arg++ ){ | ||
| + | arg-> | ||
| + | arg-> | ||
| + | arg-> | ||
| + | arg-> | ||
| + | arg-> | ||
| + | arg-> | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
d3d/d3d12/indirect.1442816407.txt.gz · 最終更新: by oga
