mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-15 01:26:06 +00:00
Add compute to D3D12 backend
This commit is contained in:
parent
dc6bb4a16c
commit
37d11539a4
@ -25,6 +25,16 @@ namespace backend {
|
|||||||
namespace d3d12 {
|
namespace d3d12 {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(nxt::BufferUsageBit usage) {
|
||||||
|
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
|
||||||
|
|
||||||
|
if (usage & nxt::BufferUsageBit::Storage) {
|
||||||
|
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
D3D12_RESOURCE_STATES D3D12BufferUsage(nxt::BufferUsageBit usage) {
|
D3D12_RESOURCE_STATES D3D12BufferUsage(nxt::BufferUsageBit usage) {
|
||||||
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
|
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
|
||||||
|
|
||||||
@ -72,7 +82,7 @@ namespace d3d12 {
|
|||||||
resourceDescriptor.SampleDesc.Count = 1;
|
resourceDescriptor.SampleDesc.Count = 1;
|
||||||
resourceDescriptor.SampleDesc.Quality = 0;
|
resourceDescriptor.SampleDesc.Quality = 0;
|
||||||
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||||
resourceDescriptor.Flags = D3D12_RESOURCE_FLAG_NONE;
|
resourceDescriptor.Flags = D3D12ResourceFlags(GetAllowedUsage());
|
||||||
|
|
||||||
auto heapType = D3D12HeapType(GetAllowedUsage());
|
auto heapType = D3D12HeapType(GetAllowedUsage());
|
||||||
auto bufferUsage = D3D12BufferUsage(GetUsage());
|
auto bufferUsage = D3D12BufferUsage(GetUsage());
|
||||||
|
@ -488,6 +488,9 @@ namespace d3d12 {
|
|||||||
ComputePipeline* pipeline = ToBackend(cmd->pipeline).Get();
|
ComputePipeline* pipeline = ToBackend(cmd->pipeline).Get();
|
||||||
PipelineLayout* layout = ToBackend(pipeline->GetLayout());
|
PipelineLayout* layout = ToBackend(pipeline->GetLayout());
|
||||||
|
|
||||||
|
commandList->SetComputeRootSignature(layout->GetRootSignature().Get());
|
||||||
|
commandList->SetPipelineState(pipeline->GetPipelineState().Get());
|
||||||
|
|
||||||
// TODO(enga@google.com): Implement compute pipelines
|
// TODO(enga@google.com): Implement compute pipelines
|
||||||
bindingTracker.SetInheritedBindGroups(commandList, lastLayout, layout);
|
bindingTracker.SetInheritedBindGroups(commandList, lastLayout, layout);
|
||||||
lastLayout = layout;
|
lastLayout = layout;
|
||||||
|
@ -48,7 +48,7 @@ namespace d3d12 {
|
|||||||
{ nullptr },
|
{ nullptr },
|
||||||
nullptr,
|
nullptr,
|
||||||
entryPoint.c_str(),
|
entryPoint.c_str(),
|
||||||
"cs_5_0",
|
"cs_5_1",
|
||||||
compileFlags,
|
compileFlags,
|
||||||
0,
|
0,
|
||||||
&compiledShader,
|
&compiledShader,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user