Normalize case X : {} break; to case X : { break;}

Dawn was using a very uncommon way to do breaks from case statements
when a block was introduced for that case statement. Fix it by running
the following commands:

  git grep -l "} break;" | xargs sed -i "" -e "s/} break;/break;}/"
  git cl format

Some -Wunreachable-code-break become very apparent in this CL but and are
fixed in a follow-up to keep mechanical and manual changes separate.

Bug: None
Change-Id: I558eda92bb1c9d938cc7cf07b091b733b57d3aca
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/18660
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Corentin Wallez 2020-04-02 16:45:17 +00:00 committed by Commit Bot service account
parent 5b29904d76
commit e8316538e3
18 changed files with 522 additions and 249 deletions

View File

@ -86,12 +86,14 @@ namespace dawn_native {
if (!texture->GetFormat().HasComponentType(bindingInfo.textureComponentType)) { if (!texture->GetFormat().HasComponentType(bindingInfo.textureComponentType)) {
return DAWN_VALIDATION_ERROR("texture component type usage mismatch"); return DAWN_VALIDATION_ERROR("texture component type usage mismatch");
} }
} break; break;
}
case wgpu::TextureUsage::Storage: { case wgpu::TextureUsage::Storage: {
if (texture->GetFormat().format != bindingInfo.storageTextureFormat) { if (texture->GetFormat().format != bindingInfo.storageTextureFormat) {
return DAWN_VALIDATION_ERROR("storage texture format mismatch"); return DAWN_VALIDATION_ERROR("storage texture format mismatch");
} }
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
break; break;

View File

@ -34,7 +34,8 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"storage buffer binding is not supported in vertex shader"); "storage buffer binding is not supported in vertex shader");
} }
} break; break;
}
case wgpu::BindingType::WriteonlyStorageTexture: { case wgpu::BindingType::WriteonlyStorageTexture: {
if ((shaderStageVisibility & if ((shaderStageVisibility &
@ -42,11 +43,13 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"write-only storage texture binding is only supported in compute shader"); "write-only storage texture binding is only supported in compute shader");
} }
} break; break;
}
case wgpu::BindingType::StorageTexture: { case wgpu::BindingType::StorageTexture: {
return DAWN_VALIDATION_ERROR("Read-write storage texture binding is not supported"); return DAWN_VALIDATION_ERROR("Read-write storage texture binding is not supported");
} break; break;
}
case wgpu::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case wgpu::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
@ -73,7 +76,8 @@ namespace dawn_native {
if (!format->supportsStorageUsage) { if (!format->supportsStorageUsage) {
return DAWN_VALIDATION_ERROR("The storage texture format is not supported"); return DAWN_VALIDATION_ERROR("The storage texture format is not supported");
} }
} break; break;
}
case wgpu::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
case wgpu::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:

View File

@ -793,12 +793,14 @@ namespace dawn_native {
case Command::BeginComputePass: { case Command::BeginComputePass: {
commands->NextCommand<BeginComputePassCmd>(); commands->NextCommand<BeginComputePassCmd>();
DAWN_TRY(ValidateComputePass(commands)); DAWN_TRY(ValidateComputePass(commands));
} break; break;
}
case Command::BeginRenderPass: { case Command::BeginRenderPass: {
const BeginRenderPassCmd* cmd = commands->NextCommand<BeginRenderPassCmd>(); const BeginRenderPassCmd* cmd = commands->NextCommand<BeginRenderPassCmd>();
DAWN_TRY(ValidateRenderPass(commands, cmd)); DAWN_TRY(ValidateRenderPass(commands, cmd));
} break; break;
}
case Command::CopyBufferToBuffer: { case Command::CopyBufferToBuffer: {
const CopyBufferToBufferCmd* copy = const CopyBufferToBufferCmd* copy =
@ -813,7 +815,8 @@ namespace dawn_native {
DAWN_TRY(ValidateCanUseAs(copy->source.Get(), wgpu::BufferUsage::CopySrc)); DAWN_TRY(ValidateCanUseAs(copy->source.Get(), wgpu::BufferUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.Get(), wgpu::BufferUsage::CopyDst)); DAWN_TRY(ValidateCanUseAs(copy->destination.Get(), wgpu::BufferUsage::CopyDst));
} break; break;
}
case Command::CopyBufferToTexture: { case Command::CopyBufferToTexture: {
const CopyBufferToTextureCmd* copy = const CopyBufferToTextureCmd* copy =
@ -846,7 +849,8 @@ namespace dawn_native {
ValidateCanUseAs(copy->source.buffer.Get(), wgpu::BufferUsage::CopySrc)); ValidateCanUseAs(copy->source.buffer.Get(), wgpu::BufferUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(), DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
wgpu::TextureUsage::CopyDst)); wgpu::TextureUsage::CopyDst));
} break; break;
}
case Command::CopyTextureToBuffer: { case Command::CopyTextureToBuffer: {
const CopyTextureToBufferCmd* copy = const CopyTextureToBufferCmd* copy =
@ -879,7 +883,8 @@ namespace dawn_native {
ValidateCanUseAs(copy->source.texture.Get(), wgpu::TextureUsage::CopySrc)); ValidateCanUseAs(copy->source.texture.Get(), wgpu::TextureUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(), DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
wgpu::BufferUsage::CopyDst)); wgpu::BufferUsage::CopyDst));
} break; break;
}
case Command::CopyTextureToTexture: { case Command::CopyTextureToTexture: {
const CopyTextureToTextureCmd* copy = const CopyTextureToTextureCmd* copy =
@ -904,24 +909,28 @@ namespace dawn_native {
ValidateCanUseAs(copy->source.texture.Get(), wgpu::TextureUsage::CopySrc)); ValidateCanUseAs(copy->source.texture.Get(), wgpu::TextureUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(), DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
wgpu::TextureUsage::CopyDst)); wgpu::TextureUsage::CopyDst));
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
const InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>(); const InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
commands->NextCommand<PopDebugGroupCmd>(); commands->NextCommand<PopDebugGroupCmd>();
DAWN_TRY(ValidateCanPopDebugGroup(debugGroupStackSize)); DAWN_TRY(ValidateCanPopDebugGroup(debugGroupStackSize));
debugGroupStackSize--; debugGroupStackSize--;
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
const PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>(); const PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
debugGroupStackSize++; debugGroupStackSize++;
} break; break;
}
default: default:
return DAWN_VALIDATION_ERROR("Command disallowed outside of a pass"); return DAWN_VALIDATION_ERROR("Command disallowed outside of a pass");
} }

View File

@ -37,39 +37,46 @@ namespace dawn_native {
case Command::Draw: { case Command::Draw: {
commands->NextCommand<DrawCmd>(); commands->NextCommand<DrawCmd>();
DAWN_TRY(commandBufferState->ValidateCanDraw()); DAWN_TRY(commandBufferState->ValidateCanDraw());
} break; break;
}
case Command::DrawIndexed: { case Command::DrawIndexed: {
commands->NextCommand<DrawIndexedCmd>(); commands->NextCommand<DrawIndexedCmd>();
DAWN_TRY(commandBufferState->ValidateCanDrawIndexed()); DAWN_TRY(commandBufferState->ValidateCanDrawIndexed());
} break; break;
}
case Command::DrawIndirect: { case Command::DrawIndirect: {
commands->NextCommand<DrawIndirectCmd>(); commands->NextCommand<DrawIndirectCmd>();
DAWN_TRY(commandBufferState->ValidateCanDraw()); DAWN_TRY(commandBufferState->ValidateCanDraw());
} break; break;
}
case Command::DrawIndexedIndirect: { case Command::DrawIndexedIndirect: {
commands->NextCommand<DrawIndexedIndirectCmd>(); commands->NextCommand<DrawIndexedIndirectCmd>();
DAWN_TRY(commandBufferState->ValidateCanDrawIndexed()); DAWN_TRY(commandBufferState->ValidateCanDrawIndexed());
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
commands->NextCommand<PopDebugGroupCmd>(); commands->NextCommand<PopDebugGroupCmd>();
DAWN_TRY(ValidateCanPopDebugGroup(*debugGroupStackSize)); DAWN_TRY(ValidateCanPopDebugGroup(*debugGroupStackSize));
*debugGroupStackSize -= 1; *debugGroupStackSize -= 1;
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
*debugGroupStackSize += 1; *debugGroupStackSize += 1;
} break; break;
}
case Command::SetRenderPipeline: { case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = commands->NextCommand<SetRenderPipelineCmd>(); SetRenderPipelineCmd* cmd = commands->NextCommand<SetRenderPipelineCmd>();
@ -79,7 +86,8 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Pipeline attachment state is not compatible"); return DAWN_VALIDATION_ERROR("Pipeline attachment state is not compatible");
} }
commandBufferState->SetRenderPipeline(pipeline); commandBufferState->SetRenderPipeline(pipeline);
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>();
@ -88,17 +96,20 @@ namespace dawn_native {
} }
commandBufferState->SetBindGroup(cmd->index, cmd->group.Get()); commandBufferState->SetBindGroup(cmd->index, cmd->group.Get());
} break; break;
}
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
commands->NextCommand<SetIndexBufferCmd>(); commands->NextCommand<SetIndexBufferCmd>();
commandBufferState->SetIndexBuffer(); commandBufferState->SetIndexBuffer();
} break; break;
}
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>(); SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>();
commandBufferState->SetVertexBuffer(cmd->slot); commandBufferState->SetVertexBuffer(cmd->slot);
} break; break;
}
default: default:
return DAWN_VALIDATION_ERROR(disallowedMessage); return DAWN_VALIDATION_ERROR(disallowedMessage);
@ -150,7 +161,8 @@ namespace dawn_native {
commands->NextCommand<EndRenderPassCmd>(); commands->NextCommand<EndRenderPassCmd>();
DAWN_TRY(ValidateFinalDebugGroupStackSize(debugGroupStackSize)); DAWN_TRY(ValidateFinalDebugGroupStackSize(debugGroupStackSize));
return {}; return {};
} break; break;
}
case Command::ExecuteBundles: { case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = commands->NextCommand<ExecuteBundlesCmd>(); ExecuteBundlesCmd* cmd = commands->NextCommand<ExecuteBundlesCmd>();
@ -168,23 +180,28 @@ namespace dawn_native {
commandBufferState = CommandBufferStateTracker{}; commandBufferState = CommandBufferStateTracker{};
} }
} break; break;
}
case Command::SetStencilReference: { case Command::SetStencilReference: {
commands->NextCommand<SetStencilReferenceCmd>(); commands->NextCommand<SetStencilReferenceCmd>();
} break; break;
}
case Command::SetBlendColor: { case Command::SetBlendColor: {
commands->NextCommand<SetBlendColorCmd>(); commands->NextCommand<SetBlendColorCmd>();
} break; break;
}
case Command::SetViewport: { case Command::SetViewport: {
commands->NextCommand<SetViewportCmd>(); commands->NextCommand<SetViewportCmd>();
} break; break;
}
case Command::SetScissorRect: { case Command::SetScissorRect: {
commands->NextCommand<SetScissorRectCmd>(); commands->NextCommand<SetScissorRectCmd>();
} break; break;
}
default: default:
DAWN_TRY(ValidateRenderBundleCommand( DAWN_TRY(ValidateRenderBundleCommand(
@ -208,40 +225,47 @@ namespace dawn_native {
commands->NextCommand<EndComputePassCmd>(); commands->NextCommand<EndComputePassCmd>();
DAWN_TRY(ValidateFinalDebugGroupStackSize(debugGroupStackSize)); DAWN_TRY(ValidateFinalDebugGroupStackSize(debugGroupStackSize));
return {}; return {};
} break; break;
}
case Command::Dispatch: { case Command::Dispatch: {
commands->NextCommand<DispatchCmd>(); commands->NextCommand<DispatchCmd>();
DAWN_TRY(commandBufferState.ValidateCanDispatch()); DAWN_TRY(commandBufferState.ValidateCanDispatch());
} break; break;
}
case Command::DispatchIndirect: { case Command::DispatchIndirect: {
commands->NextCommand<DispatchIndirectCmd>(); commands->NextCommand<DispatchIndirectCmd>();
DAWN_TRY(commandBufferState.ValidateCanDispatch()); DAWN_TRY(commandBufferState.ValidateCanDispatch());
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
commands->NextCommand<PopDebugGroupCmd>(); commands->NextCommand<PopDebugGroupCmd>();
DAWN_TRY(ValidateCanPopDebugGroup(debugGroupStackSize)); DAWN_TRY(ValidateCanPopDebugGroup(debugGroupStackSize));
debugGroupStackSize--; debugGroupStackSize--;
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
debugGroupStackSize++; debugGroupStackSize++;
} break; break;
}
case Command::SetComputePipeline: { case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = commands->NextCommand<SetComputePipelineCmd>(); SetComputePipelineCmd* cmd = commands->NextCommand<SetComputePipelineCmd>();
ComputePipelineBase* pipeline = cmd->pipeline.Get(); ComputePipelineBase* pipeline = cmd->pipeline.Get();
commandBufferState.SetComputePipeline(pipeline); commandBufferState.SetComputePipeline(pipeline);
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>();
@ -249,7 +273,8 @@ namespace dawn_native {
commands->NextData<uint32_t>(cmd->dynamicOffsetCount); commands->NextData<uint32_t>(cmd->dynamicOffsetCount);
} }
commandBufferState.SetBindGroup(cmd->index, cmd->group.Get()); commandBufferState.SetBindGroup(cmd->index, cmd->group.Get());
} break; break;
}
default: default:
return DAWN_VALIDATION_ERROR("Command disallowed inside a compute pass"); return DAWN_VALIDATION_ERROR("Command disallowed inside a compute pass");

View File

@ -33,60 +33,74 @@ namespace dawn_native {
case Command::BeginComputePass: { case Command::BeginComputePass: {
BeginComputePassCmd* begin = commands->NextCommand<BeginComputePassCmd>(); BeginComputePassCmd* begin = commands->NextCommand<BeginComputePassCmd>();
begin->~BeginComputePassCmd(); begin->~BeginComputePassCmd();
} break; break;
}
case Command::BeginRenderPass: { case Command::BeginRenderPass: {
BeginRenderPassCmd* begin = commands->NextCommand<BeginRenderPassCmd>(); BeginRenderPassCmd* begin = commands->NextCommand<BeginRenderPassCmd>();
begin->~BeginRenderPassCmd(); begin->~BeginRenderPassCmd();
} break; break;
}
case Command::CopyBufferToBuffer: { case Command::CopyBufferToBuffer: {
CopyBufferToBufferCmd* copy = commands->NextCommand<CopyBufferToBufferCmd>(); CopyBufferToBufferCmd* copy = commands->NextCommand<CopyBufferToBufferCmd>();
copy->~CopyBufferToBufferCmd(); copy->~CopyBufferToBufferCmd();
} break; break;
}
case Command::CopyBufferToTexture: { case Command::CopyBufferToTexture: {
CopyBufferToTextureCmd* copy = commands->NextCommand<CopyBufferToTextureCmd>(); CopyBufferToTextureCmd* copy = commands->NextCommand<CopyBufferToTextureCmd>();
copy->~CopyBufferToTextureCmd(); copy->~CopyBufferToTextureCmd();
} break; break;
}
case Command::CopyTextureToBuffer: { case Command::CopyTextureToBuffer: {
CopyTextureToBufferCmd* copy = commands->NextCommand<CopyTextureToBufferCmd>(); CopyTextureToBufferCmd* copy = commands->NextCommand<CopyTextureToBufferCmd>();
copy->~CopyTextureToBufferCmd(); copy->~CopyTextureToBufferCmd();
} break; break;
}
case Command::CopyTextureToTexture: { case Command::CopyTextureToTexture: {
CopyTextureToTextureCmd* copy = CopyTextureToTextureCmd* copy =
commands->NextCommand<CopyTextureToTextureCmd>(); commands->NextCommand<CopyTextureToTextureCmd>();
copy->~CopyTextureToTextureCmd(); copy->~CopyTextureToTextureCmd();
} break; break;
}
case Command::Dispatch: { case Command::Dispatch: {
DispatchCmd* dispatch = commands->NextCommand<DispatchCmd>(); DispatchCmd* dispatch = commands->NextCommand<DispatchCmd>();
dispatch->~DispatchCmd(); dispatch->~DispatchCmd();
} break; break;
}
case Command::DispatchIndirect: { case Command::DispatchIndirect: {
DispatchIndirectCmd* dispatch = commands->NextCommand<DispatchIndirectCmd>(); DispatchIndirectCmd* dispatch = commands->NextCommand<DispatchIndirectCmd>();
dispatch->~DispatchIndirectCmd(); dispatch->~DispatchIndirectCmd();
} break; break;
}
case Command::Draw: { case Command::Draw: {
DrawCmd* draw = commands->NextCommand<DrawCmd>(); DrawCmd* draw = commands->NextCommand<DrawCmd>();
draw->~DrawCmd(); draw->~DrawCmd();
} break; break;
}
case Command::DrawIndexed: { case Command::DrawIndexed: {
DrawIndexedCmd* draw = commands->NextCommand<DrawIndexedCmd>(); DrawIndexedCmd* draw = commands->NextCommand<DrawIndexedCmd>();
draw->~DrawIndexedCmd(); draw->~DrawIndexedCmd();
} break; break;
}
case Command::DrawIndirect: { case Command::DrawIndirect: {
DrawIndirectCmd* draw = commands->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* draw = commands->NextCommand<DrawIndirectCmd>();
draw->~DrawIndirectCmd(); draw->~DrawIndirectCmd();
} break; break;
}
case Command::DrawIndexedIndirect: { case Command::DrawIndexedIndirect: {
DrawIndexedIndirectCmd* draw = commands->NextCommand<DrawIndexedIndirectCmd>(); DrawIndexedIndirectCmd* draw = commands->NextCommand<DrawIndexedIndirectCmd>();
draw->~DrawIndexedIndirectCmd(); draw->~DrawIndexedIndirectCmd();
} break; break;
}
case Command::EndComputePass: { case Command::EndComputePass: {
EndComputePassCmd* cmd = commands->NextCommand<EndComputePassCmd>(); EndComputePassCmd* cmd = commands->NextCommand<EndComputePassCmd>();
cmd->~EndComputePassCmd(); cmd->~EndComputePassCmd();
} break; break;
}
case Command::EndRenderPass: { case Command::EndRenderPass: {
EndRenderPassCmd* cmd = commands->NextCommand<EndRenderPassCmd>(); EndRenderPassCmd* cmd = commands->NextCommand<EndRenderPassCmd>();
cmd->~EndRenderPassCmd(); cmd->~EndRenderPassCmd();
} break; break;
}
case Command::ExecuteBundles: { case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = commands->NextCommand<ExecuteBundlesCmd>(); ExecuteBundlesCmd* cmd = commands->NextCommand<ExecuteBundlesCmd>();
auto bundles = commands->NextData<Ref<RenderBundleBase>>(cmd->count); auto bundles = commands->NextData<Ref<RenderBundleBase>>(cmd->count);
@ -94,60 +108,73 @@ namespace dawn_native {
(&bundles[i])->~Ref<RenderBundleBase>(); (&bundles[i])->~Ref<RenderBundleBase>();
} }
cmd->~ExecuteBundlesCmd(); cmd->~ExecuteBundlesCmd();
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
cmd->~InsertDebugMarkerCmd(); cmd->~InsertDebugMarkerCmd();
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
PopDebugGroupCmd* cmd = commands->NextCommand<PopDebugGroupCmd>(); PopDebugGroupCmd* cmd = commands->NextCommand<PopDebugGroupCmd>();
cmd->~PopDebugGroupCmd(); cmd->~PopDebugGroupCmd();
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
cmd->~PushDebugGroupCmd(); cmd->~PushDebugGroupCmd();
} break; break;
}
case Command::SetComputePipeline: { case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = commands->NextCommand<SetComputePipelineCmd>(); SetComputePipelineCmd* cmd = commands->NextCommand<SetComputePipelineCmd>();
cmd->~SetComputePipelineCmd(); cmd->~SetComputePipelineCmd();
} break; break;
}
case Command::SetRenderPipeline: { case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = commands->NextCommand<SetRenderPipelineCmd>(); SetRenderPipelineCmd* cmd = commands->NextCommand<SetRenderPipelineCmd>();
cmd->~SetRenderPipelineCmd(); cmd->~SetRenderPipelineCmd();
} break; break;
}
case Command::SetStencilReference: { case Command::SetStencilReference: {
SetStencilReferenceCmd* cmd = commands->NextCommand<SetStencilReferenceCmd>(); SetStencilReferenceCmd* cmd = commands->NextCommand<SetStencilReferenceCmd>();
cmd->~SetStencilReferenceCmd(); cmd->~SetStencilReferenceCmd();
} break; break;
}
case Command::SetViewport: { case Command::SetViewport: {
SetViewportCmd* cmd = commands->NextCommand<SetViewportCmd>(); SetViewportCmd* cmd = commands->NextCommand<SetViewportCmd>();
cmd->~SetViewportCmd(); cmd->~SetViewportCmd();
} break; break;
}
case Command::SetScissorRect: { case Command::SetScissorRect: {
SetScissorRectCmd* cmd = commands->NextCommand<SetScissorRectCmd>(); SetScissorRectCmd* cmd = commands->NextCommand<SetScissorRectCmd>();
cmd->~SetScissorRectCmd(); cmd->~SetScissorRectCmd();
} break; break;
}
case Command::SetBlendColor: { case Command::SetBlendColor: {
SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>(); SetBlendColorCmd* cmd = commands->NextCommand<SetBlendColorCmd>();
cmd->~SetBlendColorCmd(); cmd->~SetBlendColorCmd();
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = commands->NextCommand<SetBindGroupCmd>();
if (cmd->dynamicOffsetCount > 0) { if (cmd->dynamicOffsetCount > 0) {
commands->NextData<uint32_t>(cmd->dynamicOffsetCount); commands->NextData<uint32_t>(cmd->dynamicOffsetCount);
} }
cmd->~SetBindGroupCmd(); cmd->~SetBindGroupCmd();
} break; break;
}
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>();
cmd->~SetIndexBufferCmd(); cmd->~SetIndexBufferCmd();
} break; break;
}
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>(); SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>();
cmd->~SetVertexBufferCmd(); cmd->~SetVertexBufferCmd();
} break; break;
}
} }
} }
commands->DataWasDestroyed(); commands->DataWasDestroyed();
@ -214,12 +241,14 @@ namespace dawn_native {
case Command::ExecuteBundles: { case Command::ExecuteBundles: {
auto* cmd = commands->NextCommand<ExecuteBundlesCmd>(); auto* cmd = commands->NextCommand<ExecuteBundlesCmd>();
commands->NextData<Ref<RenderBundleBase>>(cmd->count); commands->NextData<Ref<RenderBundleBase>>(cmd->count);
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = commands->NextCommand<InsertDebugMarkerCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
} break; break;
}
case Command::PopDebugGroup: case Command::PopDebugGroup:
commands->NextCommand<PopDebugGroupCmd>(); commands->NextCommand<PopDebugGroupCmd>();
@ -228,7 +257,8 @@ namespace dawn_native {
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = commands->NextCommand<PushDebugGroupCmd>();
commands->NextData<char>(cmd->length + 1); commands->NextData<char>(cmd->length + 1);
} break; break;
}
case Command::SetComputePipeline: case Command::SetComputePipeline:
commands->NextCommand<SetComputePipelineCmd>(); commands->NextCommand<SetComputePipelineCmd>();
@ -259,7 +289,8 @@ namespace dawn_native {
if (cmd->dynamicOffsetCount > 0) { if (cmd->dynamicOffsetCount > 0) {
commands->NextData<uint32_t>(cmd->dynamicOffsetCount); commands->NextData<uint32_t>(cmd->dynamicOffsetCount);
} }
} break; break;
}
case Command::SetIndexBuffer: case Command::SetIndexBuffer:
commands->NextCommand<SetIndexBufferCmd>(); commands->NextCommand<SetIndexBufferCmd>();
@ -267,7 +298,8 @@ namespace dawn_native {
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
commands->NextCommand<SetVertexBufferCmd>(); commands->NextCommand<SetVertexBufferCmd>();
} break; break;
}
} }
} }

View File

@ -37,23 +37,27 @@ namespace dawn_native {
case wgpu::BindingType::UniformBuffer: { case wgpu::BindingType::UniformBuffer: {
BufferBase* buffer = group->GetBindingAsBufferBinding(bindingIndex).buffer; BufferBase* buffer = group->GetBindingAsBufferBinding(bindingIndex).buffer;
usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Uniform); usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Uniform);
} break; break;
}
case wgpu::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
BufferBase* buffer = group->GetBindingAsBufferBinding(bindingIndex).buffer; BufferBase* buffer = group->GetBindingAsBufferBinding(bindingIndex).buffer;
usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Storage); usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Storage);
} break; break;
}
case wgpu::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
TextureBase* texture = TextureBase* texture =
group->GetBindingAsTextureView(bindingIndex)->GetTexture(); group->GetBindingAsTextureView(bindingIndex)->GetTexture();
usageTracker->TextureUsedAs(texture, wgpu::TextureUsage::Sampled); usageTracker->TextureUsedAs(texture, wgpu::TextureUsage::Sampled);
} break; break;
}
case wgpu::BindingType::ReadonlyStorageBuffer: { case wgpu::BindingType::ReadonlyStorageBuffer: {
BufferBase* buffer = group->GetBindingAsBufferBinding(bindingIndex).buffer; BufferBase* buffer = group->GetBindingAsBufferBinding(bindingIndex).buffer;
usageTracker->BufferUsedAs(buffer, kReadOnlyStorage); usageTracker->BufferUsedAs(buffer, kReadOnlyStorage);
} break; break;
}
case wgpu::BindingType::Sampler: case wgpu::BindingType::Sampler:
break; break;

View File

@ -396,7 +396,8 @@ namespace dawn_native {
ToWGPUTextureViewDimension(binding.texture_dimension); ToWGPUTextureViewDimension(binding.texture_dimension);
info->textureComponentType = info->textureComponentType =
ToDawnFormatType(binding.texture_component_type); ToDawnFormatType(binding.texture_component_type);
} break; break;
}
case wgpu::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:
case wgpu::BindingType::WriteonlyStorageTexture: { case wgpu::BindingType::WriteonlyStorageTexture: {
@ -416,7 +417,8 @@ namespace dawn_native {
info->storageTextureFormat = storageTextureFormat; info->storageTextureFormat = storageTextureFormat;
info->textureDimension = info->textureDimension =
ToWGPUTextureViewDimension(binding.texture_dimension); ToWGPUTextureViewDimension(binding.texture_dimension);
} break; break;
}
default: default:
break; break;
} }
@ -580,7 +582,8 @@ namespace dawn_native {
info->textureComponentType = info->textureComponentType =
SpirvCrossBaseTypeToFormatType(textureComponentType); SpirvCrossBaseTypeToFormatType(textureComponentType);
info->type = bindingType; info->type = bindingType;
} break; break;
}
case wgpu::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
// Differentiate between readonly storage bindings and writable ones // Differentiate between readonly storage bindings and writable ones
// based on the NonWritable decoration // based on the NonWritable decoration
@ -590,7 +593,8 @@ namespace dawn_native {
} else { } else {
info->type = wgpu::BindingType::StorageBuffer; info->type = wgpu::BindingType::StorageBuffer;
} }
} break; break;
}
case wgpu::BindingType::StorageTexture: { case wgpu::BindingType::StorageTexture: {
spirv_cross::Bitset flags = compiler.get_decoration_bitset(resource.id); spirv_cross::Bitset flags = compiler.get_decoration_bitset(resource.id);
if (flags.get(spv::DecorationNonReadable)) { if (flags.get(spv::DecorationNonReadable)) {
@ -619,7 +623,8 @@ namespace dawn_native {
info->storageTextureFormat = storageTextureFormat; info->storageTextureFormat = storageTextureFormat;
info->textureDimension = info->textureDimension =
SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed); SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed);
} break; break;
}
default: default:
info->type = bindingType; info->type = bindingType;
} }
@ -784,7 +789,8 @@ namespace dawn_native {
if (bindingInfo.textureDimension != moduleInfo.textureDimension) { if (bindingInfo.textureDimension != moduleInfo.textureDimension) {
return false; return false;
} }
} break; break;
}
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:
case wgpu::BindingType::WriteonlyStorageTexture: { case wgpu::BindingType::WriteonlyStorageTexture: {
@ -796,7 +802,8 @@ namespace dawn_native {
if (bindingInfo.textureDimension != moduleInfo.textureDimension) { if (bindingInfo.textureDimension != moduleInfo.textureDimension) {
return false; return false;
} }
} break; break;
}
case wgpu::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case wgpu::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:

View File

@ -55,7 +55,8 @@ namespace dawn_native {
if (!InheritsFromCAMetalLayer(metalDesc->layer)) { if (!InheritsFromCAMetalLayer(metalDesc->layer)) {
return DAWN_VALIDATION_ERROR("layer must be a CAMetalLayer"); return DAWN_VALIDATION_ERROR("layer must be a CAMetalLayer");
} }
} break; break;
}
#endif // defined(DAWN_ENABLE_BACKEND_METAL) #endif // defined(DAWN_ENABLE_BACKEND_METAL)
#if defined(DAWN_PLATFORM_WINDOWS) #if defined(DAWN_PLATFORM_WINDOWS)
@ -69,7 +70,8 @@ namespace dawn_native {
if (IsWindow(static_cast<HWND>(hwndDesc->hwnd)) == 0) { if (IsWindow(static_cast<HWND>(hwndDesc->hwnd)) == 0) {
return DAWN_VALIDATION_ERROR("Invalid HWND"); return DAWN_VALIDATION_ERROR("Invalid HWND");
} }
} break; break;
}
#endif // defined(DAWN_PLATFORM_WINDOWS) #endif // defined(DAWN_PLATFORM_WINDOWS)
#if defined(DAWN_USE_X11) #if defined(DAWN_USE_X11)
@ -93,7 +95,8 @@ namespace dawn_native {
if (status == 0) { if (status == 0) {
return DAWN_VALIDATION_ERROR("Invalid X Window"); return DAWN_VALIDATION_ERROR("Invalid X Window");
} }
} break; break;
}
#endif // defined(DAWN_USE_X11) #endif // defined(DAWN_USE_X11)
case wgpu::SType::SurfaceDescriptorFromHTMLCanvasId: case wgpu::SType::SurfaceDescriptorFromHTMLCanvasId:
@ -115,7 +118,8 @@ namespace dawn_native {
static_cast<const SurfaceDescriptorFromMetalLayer*>(chainedDescriptor); static_cast<const SurfaceDescriptorFromMetalLayer*>(chainedDescriptor);
mType = Type::MetalLayer; mType = Type::MetalLayer;
mMetalLayer = metalDesc->layer; mMetalLayer = metalDesc->layer;
} break; break;
}
case wgpu::SType::SurfaceDescriptorFromWindowsHWND: { case wgpu::SType::SurfaceDescriptorFromWindowsHWND: {
const SurfaceDescriptorFromWindowsHWND* hwndDesc = const SurfaceDescriptorFromWindowsHWND* hwndDesc =
@ -123,7 +127,8 @@ namespace dawn_native {
mType = Type::WindowsHWND; mType = Type::WindowsHWND;
mHInstance = hwndDesc->hinstance; mHInstance = hwndDesc->hinstance;
mHWND = hwndDesc->hwnd; mHWND = hwndDesc->hwnd;
} break; break;
}
case wgpu::SType::SurfaceDescriptorFromXlib: { case wgpu::SType::SurfaceDescriptorFromXlib: {
const SurfaceDescriptorFromXlib* xDesc = const SurfaceDescriptorFromXlib* xDesc =
@ -131,7 +136,8 @@ namespace dawn_native {
mType = Type::Xlib; mType = Type::Xlib;
mXDisplay = xDesc->display; mXDisplay = xDesc->display;
mXWindow = xDesc->window; mXWindow = xDesc->window;
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();

View File

@ -108,7 +108,8 @@ namespace dawn_native { namespace d3d12 {
d3d12Device->CreateConstantBufferView( d3d12Device->CreateConstantBufferView(
&desc, cbvSrvUavDescriptorHeapAllocation.GetCPUHandle( &desc, cbvSrvUavDescriptorHeapAllocation.GetCPUHandle(
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; break;
}
case wgpu::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex); BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
@ -132,7 +133,8 @@ namespace dawn_native { namespace d3d12 {
ToBackend(binding.buffer)->GetD3D12Resource().Get(), nullptr, &desc, ToBackend(binding.buffer)->GetD3D12Resource().Get(), nullptr, &desc,
cbvSrvUavDescriptorHeapAllocation.GetCPUHandle( cbvSrvUavDescriptorHeapAllocation.GetCPUHandle(
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; break;
}
case wgpu::BindingType::ReadonlyStorageBuffer: { case wgpu::BindingType::ReadonlyStorageBuffer: {
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex); BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
@ -152,7 +154,8 @@ namespace dawn_native { namespace d3d12 {
ToBackend(binding.buffer)->GetD3D12Resource().Get(), &desc, ToBackend(binding.buffer)->GetD3D12Resource().Get(), &desc,
cbvSrvUavDescriptorHeapAllocation.GetCPUHandle( cbvSrvUavDescriptorHeapAllocation.GetCPUHandle(
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; break;
}
case wgpu::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
auto* view = ToBackend(GetBindingAsTextureView(bindingIndex)); auto* view = ToBackend(GetBindingAsTextureView(bindingIndex));
auto& srv = view->GetSRVDescriptor(); auto& srv = view->GetSRVDescriptor();
@ -160,14 +163,16 @@ namespace dawn_native { namespace d3d12 {
ToBackend(view->GetTexture())->GetD3D12Resource(), &srv, ToBackend(view->GetTexture())->GetD3D12Resource(), &srv,
cbvSrvUavDescriptorHeapAllocation.GetCPUHandle( cbvSrvUavDescriptorHeapAllocation.GetCPUHandle(
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; break;
}
case wgpu::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
auto* sampler = ToBackend(GetBindingAsSampler(bindingIndex)); auto* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
auto& samplerDesc = sampler->GetSamplerDescriptor(); auto& samplerDesc = sampler->GetSamplerDescriptor();
d3d12Device->CreateSampler( d3d12Device->CreateSampler(
&samplerDesc, &samplerDesc,
samplerDescriptorHeapAllocation.GetCPUHandle(bindingOffsets[bindingIndex])); samplerDescriptorHeapAllocation.GetCPUHandle(bindingOffsets[bindingIndex]));
} break; break;
}
case wgpu::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:

View File

@ -553,7 +553,8 @@ namespace dawn_native { namespace d3d12 {
DAWN_TRY(RecordComputePass(commandContext, &bindingTracker)); DAWN_TRY(RecordComputePass(commandContext, &bindingTracker));
nextPassNumber++; nextPassNumber++;
} break; break;
}
case Command::BeginRenderPass: { case Command::BeginRenderPass: {
BeginRenderPassCmd* beginRenderPassCmd = BeginRenderPassCmd* beginRenderPassCmd =
@ -568,7 +569,8 @@ namespace dawn_native { namespace d3d12 {
passHasUAV)); passHasUAV));
nextPassNumber++; nextPassNumber++;
} break; break;
}
case Command::CopyBufferToBuffer: { case Command::CopyBufferToBuffer: {
CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>(); CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
@ -583,7 +585,8 @@ namespace dawn_native { namespace d3d12 {
commandList->CopyBufferRegion( commandList->CopyBufferRegion(
dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset, dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset,
srcBuffer->GetD3D12Resource().Get(), copy->sourceOffset, copy->size); srcBuffer->GetD3D12Resource().Get(), copy->sourceOffset, copy->size);
} break; break;
}
case Command::CopyBufferToTexture: { case Command::CopyBufferToTexture: {
CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>(); CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
@ -626,7 +629,8 @@ namespace dawn_native { namespace d3d12 {
info.textureOffset.y, info.textureOffset.z, info.textureOffset.y, info.textureOffset.z,
&bufferLocation, &sourceRegion); &bufferLocation, &sourceRegion);
} }
} break; break;
}
case Command::CopyTextureToBuffer: { case Command::CopyTextureToBuffer: {
CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>(); CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
@ -664,7 +668,8 @@ namespace dawn_native { namespace d3d12 {
info.bufferOffset.y, info.bufferOffset.z, info.bufferOffset.y, info.bufferOffset.z,
&textureLocation, &sourceRegion); &textureLocation, &sourceRegion);
} }
} break; break;
}
case Command::CopyTextureToTexture: { case Command::CopyTextureToTexture: {
CopyTextureToTextureCmd* copy = CopyTextureToTextureCmd* copy =
@ -708,9 +713,13 @@ namespace dawn_native { namespace d3d12 {
&dstLocation, copy->destination.origin.x, copy->destination.origin.y, &dstLocation, copy->destination.origin.x, copy->destination.origin.y,
copy->destination.origin.z, &srcLocation, &sourceRegion); copy->destination.origin.z, &srcLocation, &sourceRegion);
} }
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
@ -730,7 +739,8 @@ namespace dawn_native { namespace d3d12 {
DAWN_TRY(bindingTracker->Apply(commandContext)); DAWN_TRY(bindingTracker->Apply(commandContext));
commandList->Dispatch(dispatch->x, dispatch->y, dispatch->z); commandList->Dispatch(dispatch->x, dispatch->y, dispatch->z);
} break; break;
}
case Command::DispatchIndirect: { case Command::DispatchIndirect: {
DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>(); DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>();
@ -742,12 +752,14 @@ namespace dawn_native { namespace d3d12 {
commandList->ExecuteIndirect(signature.Get(), 1, commandList->ExecuteIndirect(signature.Get(), 1,
buffer->GetD3D12Resource().Get(), buffer->GetD3D12Resource().Get(),
dispatch->indirectOffset, nullptr, 0); dispatch->indirectOffset, nullptr, 0);
} break; break;
}
case Command::EndComputePass: { case Command::EndComputePass: {
mCommands.NextCommand<EndComputePassCmd>(); mCommands.NextCommand<EndComputePassCmd>();
return {}; return {};
} break; break;
}
case Command::SetComputePipeline: { case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>(); SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
@ -760,7 +772,8 @@ namespace dawn_native { namespace d3d12 {
bindingTracker->OnSetPipeline(pipeline); bindingTracker->OnSetPipeline(pipeline);
lastLayout = layout; lastLayout = layout;
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
@ -773,7 +786,8 @@ namespace dawn_native { namespace d3d12 {
bindingTracker->OnSetBindGroup(cmd->index, group, cmd->dynamicOffsetCount, bindingTracker->OnSetBindGroup(cmd->index, group, cmd->dynamicOffsetCount,
dynamicOffsets); dynamicOffsets);
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = mCommands.NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = mCommands.NextCommand<InsertDebugMarkerCmd>();
@ -786,7 +800,8 @@ namespace dawn_native { namespace d3d12 {
->GetFunctions() ->GetFunctions()
->pixSetMarkerOnCommandList(commandList, kPIXBlackColor, label); ->pixSetMarkerOnCommandList(commandList, kPIXBlackColor, label);
} }
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
mCommands.NextCommand<PopDebugGroupCmd>(); mCommands.NextCommand<PopDebugGroupCmd>();
@ -796,7 +811,8 @@ namespace dawn_native { namespace d3d12 {
->GetFunctions() ->GetFunctions()
->pixEndEventOnCommandList(commandList); ->pixEndEventOnCommandList(commandList);
} }
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>();
@ -809,9 +825,13 @@ namespace dawn_native { namespace d3d12 {
->GetFunctions() ->GetFunctions()
->pixBeginEventOnCommandList(commandList, kPIXBlackColor, label); ->pixBeginEventOnCommandList(commandList, kPIXBlackColor, label);
} }
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
@ -993,7 +1013,8 @@ namespace dawn_native { namespace d3d12 {
vertexBufferTracker.Apply(commandList, lastPipeline); vertexBufferTracker.Apply(commandList, lastPipeline);
commandList->DrawInstanced(draw->vertexCount, draw->instanceCount, commandList->DrawInstanced(draw->vertexCount, draw->instanceCount,
draw->firstVertex, draw->firstInstance); draw->firstVertex, draw->firstInstance);
} break; break;
}
case Command::DrawIndexed: { case Command::DrawIndexed: {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>(); DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
@ -1004,7 +1025,8 @@ namespace dawn_native { namespace d3d12 {
commandList->DrawIndexedInstanced(draw->indexCount, draw->instanceCount, commandList->DrawIndexedInstanced(draw->indexCount, draw->instanceCount,
draw->firstIndex, draw->baseVertex, draw->firstIndex, draw->baseVertex,
draw->firstInstance); draw->firstInstance);
} break; break;
}
case Command::DrawIndirect: { case Command::DrawIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -1017,7 +1039,8 @@ namespace dawn_native { namespace d3d12 {
commandList->ExecuteIndirect(signature.Get(), 1, commandList->ExecuteIndirect(signature.Get(), 1,
buffer->GetD3D12Resource().Get(), buffer->GetD3D12Resource().Get(),
draw->indirectOffset, nullptr, 0); draw->indirectOffset, nullptr, 0);
} break; break;
}
case Command::DrawIndexedIndirect: { case Command::DrawIndexedIndirect: {
DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>(); DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>();
@ -1031,7 +1054,8 @@ namespace dawn_native { namespace d3d12 {
commandList->ExecuteIndirect(signature.Get(), 1, commandList->ExecuteIndirect(signature.Get(), 1,
buffer->GetD3D12Resource().Get(), buffer->GetD3D12Resource().Get(),
draw->indirectOffset, nullptr, 0); draw->indirectOffset, nullptr, 0);
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = iter->NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = iter->NextCommand<InsertDebugMarkerCmd>();
@ -1044,7 +1068,8 @@ namespace dawn_native { namespace d3d12 {
->GetFunctions() ->GetFunctions()
->pixSetMarkerOnCommandList(commandList, kPIXBlackColor, label); ->pixSetMarkerOnCommandList(commandList, kPIXBlackColor, label);
} }
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
iter->NextCommand<PopDebugGroupCmd>(); iter->NextCommand<PopDebugGroupCmd>();
@ -1054,7 +1079,8 @@ namespace dawn_native { namespace d3d12 {
->GetFunctions() ->GetFunctions()
->pixEndEventOnCommandList(commandList); ->pixEndEventOnCommandList(commandList);
} }
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = iter->NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = iter->NextCommand<PushDebugGroupCmd>();
@ -1067,7 +1093,8 @@ namespace dawn_native { namespace d3d12 {
->GetFunctions() ->GetFunctions()
->pixBeginEventOnCommandList(commandList, kPIXBlackColor, label); ->pixBeginEventOnCommandList(commandList, kPIXBlackColor, label);
} }
} break; break;
}
case Command::SetRenderPipeline: { case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>(); SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>();
@ -1083,7 +1110,8 @@ namespace dawn_native { namespace d3d12 {
lastPipeline = pipeline; lastPipeline = pipeline;
lastLayout = layout; lastLayout = layout;
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>();
@ -1096,20 +1124,23 @@ namespace dawn_native { namespace d3d12 {
bindingTracker->OnSetBindGroup(cmd->index, group, cmd->dynamicOffsetCount, bindingTracker->OnSetBindGroup(cmd->index, group, cmd->dynamicOffsetCount,
dynamicOffsets); dynamicOffsets);
} break; break;
}
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
indexBufferTracker.OnSetIndexBuffer(ToBackend(cmd->buffer.Get()), cmd->offset); indexBufferTracker.OnSetIndexBuffer(ToBackend(cmd->buffer.Get()), cmd->offset);
} break; break;
}
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>(); SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
vertexBufferTracker.OnSetVertexBuffer(cmd->slot, ToBackend(cmd->buffer.Get()), vertexBufferTracker.OnSetVertexBuffer(cmd->slot, ToBackend(cmd->buffer.Get()),
cmd->offset); cmd->offset);
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
@ -1129,13 +1160,15 @@ namespace dawn_native { namespace d3d12 {
ResolveMultisampledRenderPass(commandContext, renderPass); ResolveMultisampledRenderPass(commandContext, renderPass);
} }
return {}; return {};
} break; break;
}
case Command::SetStencilReference: { case Command::SetStencilReference: {
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>(); SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
commandList->OMSetStencilRef(cmd->reference); commandList->OMSetStencilRef(cmd->reference);
} break; break;
}
case Command::SetViewport: { case Command::SetViewport: {
SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>(); SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
@ -1148,7 +1181,8 @@ namespace dawn_native { namespace d3d12 {
viewport.MaxDepth = cmd->maxDepth; viewport.MaxDepth = cmd->maxDepth;
commandList->RSSetViewports(1, &viewport); commandList->RSSetViewports(1, &viewport);
} break; break;
}
case Command::SetScissorRect: { case Command::SetScissorRect: {
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>(); SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
@ -1159,12 +1193,14 @@ namespace dawn_native { namespace d3d12 {
rect.bottom = cmd->y + cmd->height; rect.bottom = cmd->y + cmd->height;
commandList->RSSetScissorRects(1, &rect); commandList->RSSetScissorRects(1, &rect);
} break; break;
}
case Command::SetBlendColor: { case Command::SetBlendColor: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->color.r)); commandList->OMSetBlendFactor(static_cast<const FLOAT*>(&cmd->color.r));
} break; break;
}
case Command::ExecuteBundles: { case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>(); ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>();
@ -1177,9 +1213,13 @@ namespace dawn_native { namespace d3d12 {
DAWN_TRY(EncodeRenderBundleCommand(iter, type)); DAWN_TRY(EncodeRenderBundleCommand(iter, type));
} }
} }
} break; break;
}
default: { DAWN_TRY(EncodeRenderBundleCommand(&mCommands, type)); } break; default: {
DAWN_TRY(EncodeRenderBundleCommand(&mCommands, type));
break;
}
} }
} }
return {}; return {};

View File

@ -88,7 +88,8 @@ namespace dawn_native { namespace d3d12 {
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} break; break;
}
case D3D12_RESOURCE_DIMENSION_TEXTURE1D: case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
case D3D12_RESOURCE_DIMENSION_TEXTURE2D: case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
case D3D12_RESOURCE_DIMENSION_TEXTURE3D: { case D3D12_RESOURCE_DIMENSION_TEXTURE3D: {
@ -100,11 +101,13 @@ namespace dawn_native { namespace d3d12 {
} else { } else {
return Default_OnlyNonRenderableOrDepthTextures; return Default_OnlyNonRenderableOrDepthTextures;
} }
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }

View File

@ -568,7 +568,8 @@ namespace dawn_native { namespace metal {
withRange:NSMakeRange(computeIndex, 1)]; withRange:NSMakeRange(computeIndex, 1)];
} }
} break; break;
}
case wgpu::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
auto sampler = ToBackend(group->GetBindingAsSampler(bindingIndex)); auto sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
@ -584,7 +585,8 @@ namespace dawn_native { namespace metal {
[compute setSamplerState:sampler->GetMTLSamplerState() [compute setSamplerState:sampler->GetMTLSamplerState()
atIndex:computeIndex]; atIndex:computeIndex];
} }
} break; break;
}
case wgpu::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
auto textureView = auto textureView =
@ -601,7 +603,8 @@ namespace dawn_native { namespace metal {
[compute setTexture:textureView->GetMTLTexture() [compute setTexture:textureView->GetMTLTexture()
atIndex:computeIndex]; atIndex:computeIndex];
} }
} break; break;
}
case wgpu::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:
@ -706,7 +709,8 @@ namespace dawn_native { namespace metal {
EncodeComputePass(commandContext); EncodeComputePass(commandContext);
nextPassNumber++; nextPassNumber++;
} break; break;
}
case Command::BeginRenderPass: { case Command::BeginRenderPass: {
BeginRenderPassCmd* cmd = mCommands.NextCommand<BeginRenderPassCmd>(); BeginRenderPassCmd* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
@ -719,7 +723,8 @@ namespace dawn_native { namespace metal {
EncodeRenderPass(commandContext, descriptor, cmd->width, cmd->height); EncodeRenderPass(commandContext, descriptor, cmd->width, cmd->height);
nextPassNumber++; nextPassNumber++;
} break; break;
}
case Command::CopyBufferToBuffer: { case Command::CopyBufferToBuffer: {
CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>(); CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
@ -730,7 +735,8 @@ namespace dawn_native { namespace metal {
toBuffer:ToBackend(copy->destination)->GetMTLBuffer() toBuffer:ToBackend(copy->destination)->GetMTLBuffer()
destinationOffset:copy->destinationOffset destinationOffset:copy->destinationOffset
size:copy->size]; size:copy->size];
} break; break;
}
case Command::CopyBufferToTexture: { case Command::CopyBufferToTexture: {
CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>(); CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
@ -759,7 +765,8 @@ namespace dawn_native { namespace metal {
destinationLevel:dst.mipLevel destinationLevel:dst.mipLevel
destinationOrigin:copyInfo.textureOrigin]; destinationOrigin:copyInfo.textureOrigin];
} }
} break; break;
}
case Command::CopyTextureToBuffer: { case Command::CopyTextureToBuffer: {
CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>(); CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
@ -788,7 +795,8 @@ namespace dawn_native { namespace metal {
destinationBytesPerRow:copyInfo.bytesPerRow destinationBytesPerRow:copyInfo.bytesPerRow
destinationBytesPerImage:copyInfo.bytesPerImage]; destinationBytesPerImage:copyInfo.bytesPerImage];
} }
} break; break;
}
case Command::CopyTextureToTexture: { case Command::CopyTextureToTexture: {
CopyTextureToTextureCmd* copy = CopyTextureToTextureCmd* copy =
@ -810,9 +818,13 @@ namespace dawn_native { namespace metal {
destinationSlice:copy->destination.arrayLayer destinationSlice:copy->destination.arrayLayer
destinationLevel:copy->destination.mipLevel destinationLevel:copy->destination.mipLevel
destinationOrigin:MakeMTLOrigin(copy->destination.origin)]; destinationOrigin:MakeMTLOrigin(copy->destination.origin)];
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
@ -833,7 +845,8 @@ namespace dawn_native { namespace metal {
mCommands.NextCommand<EndComputePassCmd>(); mCommands.NextCommand<EndComputePassCmd>();
commandContext->EndCompute(); commandContext->EndCompute();
return; return;
} break; break;
}
case Command::Dispatch: { case Command::Dispatch: {
DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>(); DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
@ -843,7 +856,8 @@ namespace dawn_native { namespace metal {
[encoder dispatchThreadgroups:MTLSizeMake(dispatch->x, dispatch->y, dispatch->z) [encoder dispatchThreadgroups:MTLSizeMake(dispatch->x, dispatch->y, dispatch->z)
threadsPerThreadgroup:lastPipeline->GetLocalWorkGroupSize()]; threadsPerThreadgroup:lastPipeline->GetLocalWorkGroupSize()];
} break; break;
}
case Command::DispatchIndirect: { case Command::DispatchIndirect: {
DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>(); DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>();
@ -857,7 +871,8 @@ namespace dawn_native { namespace metal {
indirectBufferOffset:dispatch->indirectOffset indirectBufferOffset:dispatch->indirectOffset
threadsPerThreadgroup:lastPipeline threadsPerThreadgroup:lastPipeline
->GetLocalWorkGroupSize()]; ->GetLocalWorkGroupSize()];
} break; break;
}
case Command::SetComputePipeline: { case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>(); SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
@ -866,7 +881,8 @@ namespace dawn_native { namespace metal {
bindGroups.OnSetPipeline(lastPipeline); bindGroups.OnSetPipeline(lastPipeline);
lastPipeline->Encode(encoder); lastPipeline->Encode(encoder);
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
@ -877,7 +893,8 @@ namespace dawn_native { namespace metal {
bindGroups.OnSetBindGroup(cmd->index, ToBackend(cmd->group.Get()), bindGroups.OnSetBindGroup(cmd->index, ToBackend(cmd->group.Get()),
cmd->dynamicOffsetCount, dynamicOffsets); cmd->dynamicOffsetCount, dynamicOffsets);
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = mCommands.NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = mCommands.NextCommand<InsertDebugMarkerCmd>();
@ -886,13 +903,15 @@ namespace dawn_native { namespace metal {
[encoder insertDebugSignpost:mtlLabel]; [encoder insertDebugSignpost:mtlLabel];
[mtlLabel release]; [mtlLabel release];
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
mCommands.NextCommand<PopDebugGroupCmd>(); mCommands.NextCommand<PopDebugGroupCmd>();
[encoder popDebugGroup]; [encoder popDebugGroup];
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>();
@ -901,9 +920,13 @@ namespace dawn_native { namespace metal {
[encoder pushDebugGroup:mtlLabel]; [encoder pushDebugGroup:mtlLabel];
[mtlLabel release]; [mtlLabel release];
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
@ -1039,7 +1062,8 @@ namespace dawn_native { namespace metal {
baseInstance:draw->firstInstance]; baseInstance:draw->firstInstance];
} }
} }
} break; break;
}
case Command::DrawIndexed: { case Command::DrawIndexed: {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>(); DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
@ -1074,7 +1098,8 @@ namespace dawn_native { namespace metal {
baseInstance:draw->firstInstance]; baseInstance:draw->firstInstance];
} }
} }
} break; break;
}
case Command::DrawIndirect: { case Command::DrawIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -1088,7 +1113,8 @@ namespace dawn_native { namespace metal {
[encoder drawPrimitives:lastPipeline->GetMTLPrimitiveTopology() [encoder drawPrimitives:lastPipeline->GetMTLPrimitiveTopology()
indirectBuffer:indirectBuffer indirectBuffer:indirectBuffer
indirectBufferOffset:draw->indirectOffset]; indirectBufferOffset:draw->indirectOffset];
} break; break;
}
case Command::DrawIndexedIndirect: { case Command::DrawIndexedIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -1105,7 +1131,8 @@ namespace dawn_native { namespace metal {
indexBufferOffset:indexBufferBaseOffset indexBufferOffset:indexBufferBaseOffset
indirectBuffer:indirectBuffer indirectBuffer:indirectBuffer
indirectBufferOffset:draw->indirectOffset]; indirectBufferOffset:draw->indirectOffset];
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = iter->NextCommand<InsertDebugMarkerCmd>(); InsertDebugMarkerCmd* cmd = iter->NextCommand<InsertDebugMarkerCmd>();
@ -1114,13 +1141,15 @@ namespace dawn_native { namespace metal {
[encoder insertDebugSignpost:mtlLabel]; [encoder insertDebugSignpost:mtlLabel];
[mtlLabel release]; [mtlLabel release];
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
iter->NextCommand<PopDebugGroupCmd>(); iter->NextCommand<PopDebugGroupCmd>();
[encoder popDebugGroup]; [encoder popDebugGroup];
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = iter->NextCommand<PushDebugGroupCmd>(); PushDebugGroupCmd* cmd = iter->NextCommand<PushDebugGroupCmd>();
@ -1129,7 +1158,8 @@ namespace dawn_native { namespace metal {
[encoder pushDebugGroup:mtlLabel]; [encoder pushDebugGroup:mtlLabel];
[mtlLabel release]; [mtlLabel release];
} break; break;
}
case Command::SetRenderPipeline: { case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>(); SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>();
@ -1144,7 +1174,8 @@ namespace dawn_native { namespace metal {
newPipeline->Encode(encoder); newPipeline->Encode(encoder);
lastPipeline = newPipeline; lastPipeline = newPipeline;
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>();
@ -1155,21 +1186,24 @@ namespace dawn_native { namespace metal {
bindGroups.OnSetBindGroup(cmd->index, ToBackend(cmd->group.Get()), bindGroups.OnSetBindGroup(cmd->index, ToBackend(cmd->group.Get()),
cmd->dynamicOffsetCount, dynamicOffsets); cmd->dynamicOffsetCount, dynamicOffsets);
} break; break;
}
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
auto b = ToBackend(cmd->buffer.Get()); auto b = ToBackend(cmd->buffer.Get());
indexBuffer = b->GetMTLBuffer(); indexBuffer = b->GetMTLBuffer();
indexBufferBaseOffset = cmd->offset; indexBufferBaseOffset = cmd->offset;
} break; break;
}
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>(); SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
vertexBuffers.OnSetVertexBuffer(cmd->slot, ToBackend(cmd->buffer.Get()), vertexBuffers.OnSetVertexBuffer(cmd->slot, ToBackend(cmd->buffer.Get()),
cmd->offset); cmd->offset);
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
@ -1184,12 +1218,14 @@ namespace dawn_native { namespace metal {
mCommands.NextCommand<EndRenderPassCmd>(); mCommands.NextCommand<EndRenderPassCmd>();
commandContext->EndRender(); commandContext->EndRender();
return; return;
} break; break;
}
case Command::SetStencilReference: { case Command::SetStencilReference: {
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>(); SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
[encoder setStencilReferenceValue:cmd->reference]; [encoder setStencilReferenceValue:cmd->reference];
} break; break;
}
case Command::SetViewport: { case Command::SetViewport: {
SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>(); SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
@ -1202,7 +1238,8 @@ namespace dawn_native { namespace metal {
viewport.zfar = cmd->maxDepth; viewport.zfar = cmd->maxDepth;
[encoder setViewport:viewport]; [encoder setViewport:viewport];
} break; break;
}
case Command::SetScissorRect: { case Command::SetScissorRect: {
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>(); SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
@ -1222,7 +1259,8 @@ namespace dawn_native { namespace metal {
} }
[encoder setScissorRect:rect]; [encoder setScissorRect:rect];
} break; break;
}
case Command::SetBlendColor: { case Command::SetBlendColor: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
@ -1230,7 +1268,8 @@ namespace dawn_native { namespace metal {
green:cmd->color.g green:cmd->color.g
blue:cmd->color.b blue:cmd->color.b
alpha:cmd->color.a]; alpha:cmd->color.a];
} break; break;
}
case Command::ExecuteBundles: { case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>(); ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>();
@ -1243,9 +1282,13 @@ namespace dawn_native { namespace metal {
EncodeRenderBundleCommand(iter, type); EncodeRenderBundleCommand(iter, type);
} }
} }
} break; break;
}
default: { EncodeRenderBundleCommand(&mCommands, type); } break; default: {
EncodeRenderBundleCommand(&mCommands, type);
break;
}
} }
} }

View File

@ -260,7 +260,8 @@ namespace dawn_native { namespace opengl {
gl.BindBufferRange(GL_UNIFORM_BUFFER, uboIndex, buffer, offset, gl.BindBufferRange(GL_UNIFORM_BUFFER, uboIndex, buffer, offset,
binding.size); binding.size);
} break; break;
}
case wgpu::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
case wgpu::BindingType::ReadonlyStorageBuffer: { case wgpu::BindingType::ReadonlyStorageBuffer: {
@ -276,7 +277,8 @@ namespace dawn_native { namespace opengl {
gl.BindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer, offset, gl.BindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer, offset,
binding.size); binding.size);
} break; break;
}
case wgpu::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex)); Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
@ -292,7 +294,8 @@ namespace dawn_native { namespace opengl {
gl.BindSampler(unit.unit, sampler->GetNonFilteringHandle()); gl.BindSampler(unit.unit, sampler->GetNonFilteringHandle());
} }
} }
} break; break;
}
case wgpu::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
TextureView* view = TextureView* view =
@ -305,7 +308,8 @@ namespace dawn_native { namespace opengl {
gl.ActiveTexture(GL_TEXTURE0 + unit); gl.ActiveTexture(GL_TEXTURE0 + unit);
gl.BindTexture(target, handle); gl.BindTexture(target, handle);
} }
} break; break;
}
case wgpu::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:
@ -435,7 +439,8 @@ namespace dawn_native { namespace opengl {
ExecuteComputePass(); ExecuteComputePass();
nextPassNumber++; nextPassNumber++;
} break; break;
}
case Command::BeginRenderPass: { case Command::BeginRenderPass: {
auto* cmd = mCommands.NextCommand<BeginRenderPassCmd>(); auto* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
@ -445,7 +450,8 @@ namespace dawn_native { namespace opengl {
ExecuteRenderPass(cmd); ExecuteRenderPass(cmd);
nextPassNumber++; nextPassNumber++;
} break; break;
}
case Command::CopyBufferToBuffer: { case Command::CopyBufferToBuffer: {
CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>(); CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
@ -458,7 +464,8 @@ namespace dawn_native { namespace opengl {
gl.BindBuffer(GL_PIXEL_PACK_BUFFER, 0); gl.BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
gl.BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); gl.BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
} break; break;
}
case Command::CopyBufferToTexture: { case Command::CopyBufferToTexture: {
CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>(); CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
@ -537,7 +544,8 @@ namespace dawn_native { namespace opengl {
gl.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); gl.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
gl.BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); gl.BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
} break; break;
}
case Command::CopyTextureToBuffer: { case Command::CopyTextureToBuffer: {
CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>(); CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
@ -594,7 +602,8 @@ namespace dawn_native { namespace opengl {
gl.BindBuffer(GL_PIXEL_PACK_BUFFER, 0); gl.BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
gl.DeleteFramebuffers(1, &readFBO); gl.DeleteFramebuffers(1, &readFBO);
} break; break;
}
case Command::CopyTextureToTexture: { case Command::CopyTextureToTexture: {
CopyTextureToTextureCmd* copy = CopyTextureToTextureCmd* copy =
@ -623,9 +632,13 @@ namespace dawn_native { namespace opengl {
dstTexture->GetHandle(), dstTexture->GetGLTarget(), dstTexture->GetHandle(), dstTexture->GetGLTarget(),
dst.mipLevel, dst.origin.x, dst.origin.y, dst.arrayLayer, dst.mipLevel, dst.origin.x, dst.origin.y, dst.arrayLayer,
copySize.width, copySize.height, 1); copySize.width, copySize.height, 1);
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
} }
@ -641,7 +654,8 @@ namespace dawn_native { namespace opengl {
case Command::EndComputePass: { case Command::EndComputePass: {
mCommands.NextCommand<EndComputePassCmd>(); mCommands.NextCommand<EndComputePassCmd>();
return; return;
} break; break;
}
case Command::Dispatch: { case Command::Dispatch: {
DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>(); DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
@ -650,7 +664,8 @@ namespace dawn_native { namespace opengl {
gl.DispatchCompute(dispatch->x, dispatch->y, dispatch->z); gl.DispatchCompute(dispatch->x, dispatch->y, dispatch->z);
// TODO(cwallez@chromium.org): add barriers to the API // TODO(cwallez@chromium.org): add barriers to the API
gl.MemoryBarrier(GL_ALL_BARRIER_BITS); gl.MemoryBarrier(GL_ALL_BARRIER_BITS);
} break; break;
}
case Command::DispatchIndirect: { case Command::DispatchIndirect: {
DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>(); DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>();
@ -663,7 +678,8 @@ namespace dawn_native { namespace opengl {
gl.DispatchComputeIndirect(static_cast<GLintptr>(indirectBufferOffset)); gl.DispatchComputeIndirect(static_cast<GLintptr>(indirectBufferOffset));
// TODO(cwallez@chromium.org): add barriers to the API // TODO(cwallez@chromium.org): add barriers to the API
gl.MemoryBarrier(GL_ALL_BARRIER_BITS); gl.MemoryBarrier(GL_ALL_BARRIER_BITS);
} break; break;
}
case Command::SetComputePipeline: { case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>(); SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
@ -671,7 +687,8 @@ namespace dawn_native { namespace opengl {
lastPipeline->ApplyNow(); lastPipeline->ApplyNow();
bindGroupTracker.OnSetPipeline(lastPipeline); bindGroupTracker.OnSetPipeline(lastPipeline);
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
@ -681,7 +698,8 @@ namespace dawn_native { namespace opengl {
} }
bindGroupTracker.OnSetBindGroup(cmd->index, cmd->group.Get(), bindGroupTracker.OnSetBindGroup(cmd->index, cmd->group.Get(),
cmd->dynamicOffsetCount, dynamicOffsets); cmd->dynamicOffsetCount, dynamicOffsets);
} break; break;
}
case Command::InsertDebugMarker: case Command::InsertDebugMarker:
case Command::PopDebugGroup: case Command::PopDebugGroup:
@ -689,9 +707,13 @@ namespace dawn_native { namespace opengl {
// Due to lack of linux driver support for GL_EXT_debug_marker // Due to lack of linux driver support for GL_EXT_debug_marker
// extension these functions are skipped. // extension these functions are skipped.
SkipCommand(&mCommands, type); SkipCommand(&mCommands, type);
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
@ -855,7 +877,8 @@ namespace dawn_native { namespace opengl {
draw->firstVertex, draw->vertexCount, draw->firstVertex, draw->vertexCount,
draw->instanceCount); draw->instanceCount);
} }
} break; break;
}
case Command::DrawIndexed: { case Command::DrawIndexed: {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>(); DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
@ -892,7 +915,8 @@ namespace dawn_native { namespace opengl {
draw->instanceCount); draw->instanceCount);
} }
} }
} break; break;
}
case Command::DrawIndirect: { case Command::DrawIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -906,7 +930,8 @@ namespace dawn_native { namespace opengl {
gl.DrawArraysIndirect( gl.DrawArraysIndirect(
lastPipeline->GetGLPrimitiveTopology(), lastPipeline->GetGLPrimitiveTopology(),
reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset))); reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset)));
} break; break;
}
case Command::DrawIndexedIndirect: { case Command::DrawIndexedIndirect: {
DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>(); DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>();
@ -924,7 +949,8 @@ namespace dawn_native { namespace opengl {
gl.DrawElementsIndirect( gl.DrawElementsIndirect(
lastPipeline->GetGLPrimitiveTopology(), formatType, lastPipeline->GetGLPrimitiveTopology(), formatType,
reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset))); reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset)));
} break; break;
}
case Command::InsertDebugMarker: case Command::InsertDebugMarker:
case Command::PopDebugGroup: case Command::PopDebugGroup:
@ -932,7 +958,8 @@ namespace dawn_native { namespace opengl {
// Due to lack of linux driver support for GL_EXT_debug_marker // Due to lack of linux driver support for GL_EXT_debug_marker
// extension these functions are skipped. // extension these functions are skipped.
SkipCommand(iter, type); SkipCommand(iter, type);
} break; break;
}
case Command::SetRenderPipeline: { case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>(); SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>();
@ -941,7 +968,8 @@ namespace dawn_native { namespace opengl {
vertexStateBufferBindingTracker.OnSetPipeline(lastPipeline); vertexStateBufferBindingTracker.OnSetPipeline(lastPipeline);
bindGroupTracker.OnSetPipeline(lastPipeline); bindGroupTracker.OnSetPipeline(lastPipeline);
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>();
@ -951,19 +979,22 @@ namespace dawn_native { namespace opengl {
} }
bindGroupTracker.OnSetBindGroup(cmd->index, cmd->group.Get(), bindGroupTracker.OnSetBindGroup(cmd->index, cmd->group.Get(),
cmd->dynamicOffsetCount, dynamicOffsets); cmd->dynamicOffsetCount, dynamicOffsets);
} break; break;
}
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
indexBufferBaseOffset = cmd->offset; indexBufferBaseOffset = cmd->offset;
vertexStateBufferBindingTracker.OnSetIndexBuffer(cmd->buffer.Get()); vertexStateBufferBindingTracker.OnSetIndexBuffer(cmd->buffer.Get());
} break; break;
}
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>(); SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
vertexStateBufferBindingTracker.OnSetVertexBuffer(cmd->slot, cmd->buffer.Get(), vertexStateBufferBindingTracker.OnSetVertexBuffer(cmd->slot, cmd->buffer.Get(),
cmd->offset); cmd->offset);
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
@ -982,28 +1013,33 @@ namespace dawn_native { namespace opengl {
} }
gl.DeleteFramebuffers(1, &fbo); gl.DeleteFramebuffers(1, &fbo);
return; return;
} break; break;
}
case Command::SetStencilReference: { case Command::SetStencilReference: {
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>(); SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
persistentPipelineState.SetStencilReference(gl, cmd->reference); persistentPipelineState.SetStencilReference(gl, cmd->reference);
} break; break;
}
case Command::SetViewport: { case Command::SetViewport: {
SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>(); SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
gl.ViewportIndexedf(0, cmd->x, cmd->y, cmd->width, cmd->height); gl.ViewportIndexedf(0, cmd->x, cmd->y, cmd->width, cmd->height);
gl.DepthRangef(cmd->minDepth, cmd->maxDepth); gl.DepthRangef(cmd->minDepth, cmd->maxDepth);
} break; break;
}
case Command::SetScissorRect: { case Command::SetScissorRect: {
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>(); SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
gl.Scissor(cmd->x, cmd->y, cmd->width, cmd->height); gl.Scissor(cmd->x, cmd->y, cmd->width, cmd->height);
} break; break;
}
case Command::SetBlendColor: { case Command::SetBlendColor: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
gl.BlendColor(cmd->color.r, cmd->color.g, cmd->color.b, cmd->color.a); gl.BlendColor(cmd->color.r, cmd->color.g, cmd->color.b, cmd->color.a);
} break; break;
}
case Command::ExecuteBundles: { case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>(); ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>();
@ -1016,9 +1052,13 @@ namespace dawn_native { namespace opengl {
DoRenderBundleCommand(iter, type); DoRenderBundleCommand(iter, type);
} }
} }
} break; break;
}
default: { DoRenderBundleCommand(&mCommands, type); } break; default: {
DoRenderBundleCommand(&mCommands, type);
break;
}
} }
} }

View File

@ -121,7 +121,8 @@ namespace dawn_native { namespace opengl {
gl.UniformBlockBinding(mProgram, location, gl.UniformBlockBinding(mProgram, location,
indices[group][bindingIndex]); indices[group][bindingIndex]);
} }
} break; break;
}
case wgpu::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
case wgpu::BindingType::ReadonlyStorageBuffer: { case wgpu::BindingType::ReadonlyStorageBuffer: {
@ -131,7 +132,8 @@ namespace dawn_native { namespace opengl {
gl.ShaderStorageBlockBinding(mProgram, location, gl.ShaderStorageBlockBinding(mProgram, location,
indices[group][bindingIndex]); indices[group][bindingIndex]);
} }
} break; break;
}
case wgpu::BindingType::Sampler: case wgpu::BindingType::Sampler:
case wgpu::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:

View File

@ -68,13 +68,15 @@ namespace dawn_native { namespace vulkan {
writeBufferInfo[numWrites].offset = binding.offset; writeBufferInfo[numWrites].offset = binding.offset;
writeBufferInfo[numWrites].range = binding.size; writeBufferInfo[numWrites].range = binding.size;
write.pBufferInfo = &writeBufferInfo[numWrites]; write.pBufferInfo = &writeBufferInfo[numWrites];
} break; break;
}
case wgpu::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
Sampler* sampler = ToBackend(GetBindingAsSampler(bindingIndex)); Sampler* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
writeImageInfo[numWrites].sampler = sampler->GetHandle(); writeImageInfo[numWrites].sampler = sampler->GetHandle();
write.pImageInfo = &writeImageInfo[numWrites]; write.pImageInfo = &writeImageInfo[numWrites];
} break; break;
}
case wgpu::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex)); TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
@ -86,7 +88,8 @@ namespace dawn_native { namespace vulkan {
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
write.pImageInfo = &writeImageInfo[numWrites]; write.pImageInfo = &writeImageInfo[numWrites];
} break; break;
}
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:
case wgpu::BindingType::WriteonlyStorageTexture: { case wgpu::BindingType::WriteonlyStorageTexture: {
@ -96,7 +99,8 @@ namespace dawn_native { namespace vulkan {
writeImageInfo[numWrites].imageLayout = VK_IMAGE_LAYOUT_GENERAL; writeImageInfo[numWrites].imageLayout = VK_IMAGE_LAYOUT_GENERAL;
write.pImageInfo = &writeImageInfo[numWrites]; write.pImageInfo = &writeImageInfo[numWrites];
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
} }

View File

@ -403,7 +403,8 @@ namespace dawn_native { namespace vulkan {
VkBuffer srcHandle = srcBuffer->GetHandle(); VkBuffer srcHandle = srcBuffer->GetHandle();
VkBuffer dstHandle = dstBuffer->GetHandle(); VkBuffer dstHandle = dstBuffer->GetHandle();
device->fn.CmdCopyBuffer(commands, srcHandle, dstHandle, 1, &region); device->fn.CmdCopyBuffer(commands, srcHandle, dstHandle, 1, &region);
} break; break;
}
case Command::CopyBufferToTexture: { case Command::CopyBufferToTexture: {
CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>(); CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
@ -437,7 +438,8 @@ namespace dawn_native { namespace vulkan {
device->fn.CmdCopyBufferToImage(commands, srcBuffer, dstImage, device->fn.CmdCopyBufferToImage(commands, srcBuffer, dstImage,
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1,
&region); &region);
} break; break;
}
case Command::CopyTextureToBuffer: { case Command::CopyTextureToBuffer: {
CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>(); CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
@ -463,7 +465,8 @@ namespace dawn_native { namespace vulkan {
// The Dawn CopySrc usage is always mapped to GENERAL // The Dawn CopySrc usage is always mapped to GENERAL
device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL, device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL,
dstBuffer, 1, &region); dstBuffer, 1, &region);
} break; break;
}
case Command::CopyTextureToTexture: { case Command::CopyTextureToTexture: {
CopyTextureToTextureCmd* copy = CopyTextureToTextureCmd* copy =
@ -522,7 +525,8 @@ namespace dawn_native { namespace vulkan {
copy->copySize); copy->copySize);
} }
} break; break;
}
case Command::BeginRenderPass: { case Command::BeginRenderPass: {
BeginRenderPassCmd* cmd = mCommands.NextCommand<BeginRenderPassCmd>(); BeginRenderPassCmd* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
@ -533,7 +537,8 @@ namespace dawn_native { namespace vulkan {
DAWN_TRY(RecordRenderPass(recordingContext, cmd)); DAWN_TRY(RecordRenderPass(recordingContext, cmd));
nextPassNumber++; nextPassNumber++;
} break; break;
}
case Command::BeginComputePass: { case Command::BeginComputePass: {
mCommands.NextCommand<BeginComputePassCmd>(); mCommands.NextCommand<BeginComputePassCmd>();
@ -542,9 +547,13 @@ namespace dawn_native { namespace vulkan {
RecordComputePass(recordingContext); RecordComputePass(recordingContext);
nextPassNumber++; nextPassNumber++;
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
@ -563,14 +572,16 @@ namespace dawn_native { namespace vulkan {
case Command::EndComputePass: { case Command::EndComputePass: {
mCommands.NextCommand<EndComputePassCmd>(); mCommands.NextCommand<EndComputePassCmd>();
return; return;
} break; break;
}
case Command::Dispatch: { case Command::Dispatch: {
DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>(); DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_COMPUTE); descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_COMPUTE);
device->fn.CmdDispatch(commands, dispatch->x, dispatch->y, dispatch->z); device->fn.CmdDispatch(commands, dispatch->x, dispatch->y, dispatch->z);
} break; break;
}
case Command::DispatchIndirect: { case Command::DispatchIndirect: {
DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>(); DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>();
@ -580,7 +591,8 @@ namespace dawn_native { namespace vulkan {
device->fn.CmdDispatchIndirect( device->fn.CmdDispatchIndirect(
commands, indirectBuffer, commands, indirectBuffer,
static_cast<VkDeviceSize>(dispatch->indirectOffset)); static_cast<VkDeviceSize>(dispatch->indirectOffset));
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
@ -593,7 +605,8 @@ namespace dawn_native { namespace vulkan {
descriptorSets.OnSetBindGroup(cmd->index, bindGroup, cmd->dynamicOffsetCount, descriptorSets.OnSetBindGroup(cmd->index, bindGroup, cmd->dynamicOffsetCount,
dynamicOffsets); dynamicOffsets);
} break; break;
}
case Command::SetComputePipeline: { case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>(); SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
@ -602,7 +615,8 @@ namespace dawn_native { namespace vulkan {
device->fn.CmdBindPipeline(commands, VK_PIPELINE_BIND_POINT_COMPUTE, device->fn.CmdBindPipeline(commands, VK_PIPELINE_BIND_POINT_COMPUTE,
pipeline->GetHandle()); pipeline->GetHandle());
descriptorSets.OnSetPipeline(pipeline); descriptorSets.OnSetPipeline(pipeline);
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
if (device->GetDeviceInfo().debugMarker) { if (device->GetDeviceInfo().debugMarker) {
@ -621,7 +635,8 @@ namespace dawn_native { namespace vulkan {
} else { } else {
SkipCommand(&mCommands, Command::InsertDebugMarker); SkipCommand(&mCommands, Command::InsertDebugMarker);
} }
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
if (device->GetDeviceInfo().debugMarker) { if (device->GetDeviceInfo().debugMarker) {
@ -630,7 +645,8 @@ namespace dawn_native { namespace vulkan {
} else { } else {
SkipCommand(&mCommands, Command::PopDebugGroup); SkipCommand(&mCommands, Command::PopDebugGroup);
} }
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
if (device->GetDeviceInfo().debugMarker) { if (device->GetDeviceInfo().debugMarker) {
@ -649,9 +665,13 @@ namespace dawn_native { namespace vulkan {
} else { } else {
SkipCommand(&mCommands, Command::PushDebugGroup); SkipCommand(&mCommands, Command::PushDebugGroup);
} }
} break; break;
}
default: { UNREACHABLE(); } break; default: {
UNREACHABLE();
break;
}
} }
} }
@ -710,7 +730,8 @@ namespace dawn_native { namespace vulkan {
descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS); descriptorSets.Apply(device, recordingContext, VK_PIPELINE_BIND_POINT_GRAPHICS);
device->fn.CmdDraw(commands, draw->vertexCount, draw->instanceCount, device->fn.CmdDraw(commands, draw->vertexCount, draw->instanceCount,
draw->firstVertex, draw->firstInstance); draw->firstVertex, draw->firstInstance);
} break; break;
}
case Command::DrawIndexed: { case Command::DrawIndexed: {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>(); DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
@ -719,7 +740,8 @@ namespace dawn_native { namespace vulkan {
device->fn.CmdDrawIndexed(commands, draw->indexCount, draw->instanceCount, device->fn.CmdDrawIndexed(commands, draw->indexCount, draw->instanceCount,
draw->firstIndex, draw->baseVertex, draw->firstIndex, draw->baseVertex,
draw->firstInstance); draw->firstInstance);
} break; break;
}
case Command::DrawIndirect: { case Command::DrawIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -729,7 +751,8 @@ namespace dawn_native { namespace vulkan {
device->fn.CmdDrawIndirect(commands, indirectBuffer, device->fn.CmdDrawIndirect(commands, indirectBuffer,
static_cast<VkDeviceSize>(draw->indirectOffset), 1, static_cast<VkDeviceSize>(draw->indirectOffset), 1,
0); 0);
} break; break;
}
case Command::DrawIndexedIndirect: { case Command::DrawIndexedIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -739,7 +762,8 @@ namespace dawn_native { namespace vulkan {
device->fn.CmdDrawIndexedIndirect( device->fn.CmdDrawIndexedIndirect(
commands, indirectBuffer, static_cast<VkDeviceSize>(draw->indirectOffset), commands, indirectBuffer, static_cast<VkDeviceSize>(draw->indirectOffset),
1, 0); 1, 0);
} break; break;
}
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
if (device->GetDeviceInfo().debugMarker) { if (device->GetDeviceInfo().debugMarker) {
@ -758,7 +782,8 @@ namespace dawn_native { namespace vulkan {
} else { } else {
SkipCommand(iter, Command::InsertDebugMarker); SkipCommand(iter, Command::InsertDebugMarker);
} }
} break; break;
}
case Command::PopDebugGroup: { case Command::PopDebugGroup: {
if (device->GetDeviceInfo().debugMarker) { if (device->GetDeviceInfo().debugMarker) {
@ -767,7 +792,8 @@ namespace dawn_native { namespace vulkan {
} else { } else {
SkipCommand(iter, Command::PopDebugGroup); SkipCommand(iter, Command::PopDebugGroup);
} }
} break; break;
}
case Command::PushDebugGroup: { case Command::PushDebugGroup: {
if (device->GetDeviceInfo().debugMarker) { if (device->GetDeviceInfo().debugMarker) {
@ -786,7 +812,8 @@ namespace dawn_native { namespace vulkan {
} else { } else {
SkipCommand(iter, Command::PushDebugGroup); SkipCommand(iter, Command::PushDebugGroup);
} }
} break; break;
}
case Command::SetBindGroup: { case Command::SetBindGroup: {
SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>(); SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>();
@ -798,7 +825,8 @@ namespace dawn_native { namespace vulkan {
descriptorSets.OnSetBindGroup(cmd->index, bindGroup, cmd->dynamicOffsetCount, descriptorSets.OnSetBindGroup(cmd->index, bindGroup, cmd->dynamicOffsetCount,
dynamicOffsets); dynamicOffsets);
} break; break;
}
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
@ -811,7 +839,8 @@ namespace dawn_native { namespace vulkan {
VulkanIndexType(lastPipeline->GetVertexStateDescriptor()->indexFormat); VulkanIndexType(lastPipeline->GetVertexStateDescriptor()->indexFormat);
device->fn.CmdBindIndexBuffer( device->fn.CmdBindIndexBuffer(
commands, indexBuffer, static_cast<VkDeviceSize>(cmd->offset), indexType); commands, indexBuffer, static_cast<VkDeviceSize>(cmd->offset), indexType);
} break; break;
}
case Command::SetRenderPipeline: { case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>(); SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>();
@ -822,7 +851,8 @@ namespace dawn_native { namespace vulkan {
lastPipeline = pipeline; lastPipeline = pipeline;
descriptorSets.OnSetPipeline(pipeline); descriptorSets.OnSetPipeline(pipeline);
} break; break;
}
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>(); SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
@ -830,7 +860,8 @@ namespace dawn_native { namespace vulkan {
VkDeviceSize offset = static_cast<VkDeviceSize>(cmd->offset); VkDeviceSize offset = static_cast<VkDeviceSize>(cmd->offset);
device->fn.CmdBindVertexBuffers(commands, cmd->slot, 1, &*buffer, &offset); device->fn.CmdBindVertexBuffers(commands, cmd->slot, 1, &*buffer, &offset);
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();
@ -845,7 +876,8 @@ namespace dawn_native { namespace vulkan {
mCommands.NextCommand<EndRenderPassCmd>(); mCommands.NextCommand<EndRenderPassCmd>();
device->fn.CmdEndRenderPass(commands); device->fn.CmdEndRenderPass(commands);
return {}; return {};
} break; break;
}
case Command::SetBlendColor: { case Command::SetBlendColor: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>(); SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
@ -856,13 +888,15 @@ namespace dawn_native { namespace vulkan {
cmd->color.a, cmd->color.a,
}; };
device->fn.CmdSetBlendConstants(commands, blendConstants); device->fn.CmdSetBlendConstants(commands, blendConstants);
} break; break;
}
case Command::SetStencilReference: { case Command::SetStencilReference: {
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>(); SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
device->fn.CmdSetStencilReference(commands, VK_STENCIL_FRONT_AND_BACK, device->fn.CmdSetStencilReference(commands, VK_STENCIL_FRONT_AND_BACK,
cmd->reference); cmd->reference);
} break; break;
}
case Command::SetViewport: { case Command::SetViewport: {
SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>(); SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
@ -875,7 +909,8 @@ namespace dawn_native { namespace vulkan {
viewport.maxDepth = cmd->maxDepth; viewport.maxDepth = cmd->maxDepth;
device->fn.CmdSetViewport(commands, 0, 1, &viewport); device->fn.CmdSetViewport(commands, 0, 1, &viewport);
} break; break;
}
case Command::SetScissorRect: { case Command::SetScissorRect: {
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>(); SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
@ -886,7 +921,8 @@ namespace dawn_native { namespace vulkan {
rect.extent.height = cmd->height; rect.extent.height = cmd->height;
device->fn.CmdSetScissor(commands, 0, 1, &rect); device->fn.CmdSetScissor(commands, 0, 1, &rect);
} break; break;
}
case Command::ExecuteBundles: { case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>(); ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>();
@ -899,9 +935,13 @@ namespace dawn_native { namespace vulkan {
EncodeRenderBundleCommand(iter, type); EncodeRenderBundleCommand(iter, type);
} }
} }
} break; break;
}
default: { EncodeRenderBundleCommand(&mCommands, type); } break; default: {
EncodeRenderBundleCommand(&mCommands, type);
break;
}
} }
} }

View File

@ -119,7 +119,8 @@ void BufferUploadPerf::Step() {
} }
// Make sure all SetSubData's are flushed. // Make sure all SetSubData's are flushed.
queue.Submit(0, nullptr); queue.Submit(0, nullptr);
} break; break;
}
case UploadMethod::CreateBufferMapped: { case UploadMethod::CreateBufferMapped: {
wgpu::BufferDescriptor desc = {}; wgpu::BufferDescriptor desc = {};
@ -137,7 +138,8 @@ void BufferUploadPerf::Step() {
wgpu::CommandBuffer commands = encoder.Finish(); wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands); queue.Submit(1, &commands);
} break; break;
}
} }
} }

View File

@ -306,7 +306,8 @@ void DrawCallPerf::TestSetUp() {
mVertexBuffers[i] = utils::CreateBufferFromData( mVertexBuffers[i] = utils::CreateBufferFromData(
device, kVertexData, sizeof(kVertexData), wgpu::BufferUsage::Vertex); device, kVertexData, sizeof(kVertexData), wgpu::BufferUsage::Vertex);
} }
} break; break;
}
case VertexBuffer::Dynamic: { case VertexBuffer::Dynamic: {
std::vector<char> data(mAlignedVertexDataSize * kNumDraws); std::vector<char> data(mAlignedVertexDataSize * kNumDraws);
@ -316,7 +317,8 @@ void DrawCallPerf::TestSetUp() {
mVertexBuffers[0] = utils::CreateBufferFromData(device, data.data(), data.size(), mVertexBuffers[0] = utils::CreateBufferFromData(device, data.data(), data.size(),
wgpu::BufferUsage::Vertex); wgpu::BufferUsage::Vertex);
} break; break;
}
} }
// Create the bind group layout. // Create the bind group layout.
@ -505,7 +507,8 @@ void DrawCallPerf::RecordRenderCommands(Encoder pass) {
// Because of the pipeline layout change, we need to rebind bind group index 0. // Because of the pipeline layout change, we need to rebind bind group index 0.
pass.SetBindGroup(0, mConstantBindGroup); pass.SetBindGroup(0, mConstantBindGroup);
} }
} break; break;
}
} }
// Set the vertex buffer, if it changes. // Set the vertex buffer, if it changes.
@ -535,7 +538,8 @@ void DrawCallPerf::RecordRenderCommands(Encoder pass) {
wgpu::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, mUniformBindGroupLayout, {{0, mUniformBuffers[i], 0, kUniformSize}}); device, mUniformBindGroupLayout, {{0, mUniformBuffers[i], 0, kUniformSize}});
pass.SetBindGroup(uniformBindGroupIndex, bindGroup); pass.SetBindGroup(uniformBindGroupIndex, bindGroup);
} break; break;
}
case BindGroup::Multiple: case BindGroup::Multiple:
pass.SetBindGroup(uniformBindGroupIndex, mUniformBindGroups[i]); pass.SetBindGroup(uniformBindGroupIndex, mUniformBindGroups[i]);
@ -544,7 +548,8 @@ void DrawCallPerf::RecordRenderCommands(Encoder pass) {
case BindGroup::Dynamic: { case BindGroup::Dynamic: {
uint32_t dynamicOffset = static_cast<uint32_t>(i * mAlignedUniformSize); uint32_t dynamicOffset = static_cast<uint32_t>(i * mAlignedUniformSize);
pass.SetBindGroup(uniformBindGroupIndex, mUniformBindGroups[0], 1, &dynamicOffset); pass.SetBindGroup(uniformBindGroupIndex, mUniformBindGroups[0], 1, &dynamicOffset);
} break; break;
}
default: default:
UNREACHABLE(); UNREACHABLE();