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)) {
return DAWN_VALIDATION_ERROR("texture component type usage mismatch");
}
} break;
break;
}
case wgpu::TextureUsage::Storage: {
if (texture->GetFormat().format != bindingInfo.storageTextureFormat) {
return DAWN_VALIDATION_ERROR("storage texture format mismatch");
}
} break;
break;
}
default:
UNREACHABLE();
break;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -568,7 +568,8 @@ namespace dawn_native { namespace metal {
withRange:NSMakeRange(computeIndex, 1)];
}
} break;
break;
}
case wgpu::BindingType::Sampler: {
auto sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
@ -584,7 +585,8 @@ namespace dawn_native { namespace metal {
[compute setSamplerState:sampler->GetMTLSamplerState()
atIndex:computeIndex];
}
} break;
break;
}
case wgpu::BindingType::SampledTexture: {
auto textureView =
@ -601,7 +603,8 @@ namespace dawn_native { namespace metal {
[compute setTexture:textureView->GetMTLTexture()
atIndex:computeIndex];
}
} break;
break;
}
case wgpu::BindingType::StorageTexture:
case wgpu::BindingType::ReadonlyStorageTexture:
@ -706,7 +709,8 @@ namespace dawn_native { namespace metal {
EncodeComputePass(commandContext);
nextPassNumber++;
} break;
break;
}
case Command::BeginRenderPass: {
BeginRenderPassCmd* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
@ -719,7 +723,8 @@ namespace dawn_native { namespace metal {
EncodeRenderPass(commandContext, descriptor, cmd->width, cmd->height);
nextPassNumber++;
} break;
break;
}
case Command::CopyBufferToBuffer: {
CopyBufferToBufferCmd* copy = mCommands.NextCommand<CopyBufferToBufferCmd>();
@ -730,7 +735,8 @@ namespace dawn_native { namespace metal {
toBuffer:ToBackend(copy->destination)->GetMTLBuffer()
destinationOffset:copy->destinationOffset
size:copy->size];
} break;
break;
}
case Command::CopyBufferToTexture: {
CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
@ -759,7 +765,8 @@ namespace dawn_native { namespace metal {
destinationLevel:dst.mipLevel
destinationOrigin:copyInfo.textureOrigin];
}
} break;
break;
}
case Command::CopyTextureToBuffer: {
CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
@ -788,7 +795,8 @@ namespace dawn_native { namespace metal {
destinationBytesPerRow:copyInfo.bytesPerRow
destinationBytesPerImage:copyInfo.bytesPerImage];
}
} break;
break;
}
case Command::CopyTextureToTexture: {
CopyTextureToTextureCmd* copy =
@ -810,9 +818,13 @@ namespace dawn_native { namespace metal {
destinationSlice:copy->destination.arrayLayer
destinationLevel:copy->destination.mipLevel
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>();
commandContext->EndCompute();
return;
} break;
break;
}
case Command::Dispatch: {
DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
@ -843,7 +856,8 @@ namespace dawn_native { namespace metal {
[encoder dispatchThreadgroups:MTLSizeMake(dispatch->x, dispatch->y, dispatch->z)
threadsPerThreadgroup:lastPipeline->GetLocalWorkGroupSize()];
} break;
break;
}
case Command::DispatchIndirect: {
DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>();
@ -857,7 +871,8 @@ namespace dawn_native { namespace metal {
indirectBufferOffset:dispatch->indirectOffset
threadsPerThreadgroup:lastPipeline
->GetLocalWorkGroupSize()];
} break;
break;
}
case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
@ -866,7 +881,8 @@ namespace dawn_native { namespace metal {
bindGroups.OnSetPipeline(lastPipeline);
lastPipeline->Encode(encoder);
} break;
break;
}
case Command::SetBindGroup: {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
@ -877,7 +893,8 @@ namespace dawn_native { namespace metal {
bindGroups.OnSetBindGroup(cmd->index, ToBackend(cmd->group.Get()),
cmd->dynamicOffsetCount, dynamicOffsets);
} break;
break;
}
case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = mCommands.NextCommand<InsertDebugMarkerCmd>();
@ -886,13 +903,15 @@ namespace dawn_native { namespace metal {
[encoder insertDebugSignpost:mtlLabel];
[mtlLabel release];
} break;
break;
}
case Command::PopDebugGroup: {
mCommands.NextCommand<PopDebugGroupCmd>();
[encoder popDebugGroup];
} break;
break;
}
case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = mCommands.NextCommand<PushDebugGroupCmd>();
@ -901,9 +920,13 @@ namespace dawn_native { namespace metal {
[encoder pushDebugGroup:mtlLabel];
[mtlLabel release];
} break;
break;
}
default: { UNREACHABLE(); } break;
default: {
UNREACHABLE();
break;
}
}
}
@ -1039,7 +1062,8 @@ namespace dawn_native { namespace metal {
baseInstance:draw->firstInstance];
}
}
} break;
break;
}
case Command::DrawIndexed: {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
@ -1074,7 +1098,8 @@ namespace dawn_native { namespace metal {
baseInstance:draw->firstInstance];
}
}
} break;
break;
}
case Command::DrawIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -1088,7 +1113,8 @@ namespace dawn_native { namespace metal {
[encoder drawPrimitives:lastPipeline->GetMTLPrimitiveTopology()
indirectBuffer:indirectBuffer
indirectBufferOffset:draw->indirectOffset];
} break;
break;
}
case Command::DrawIndexedIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -1105,7 +1131,8 @@ namespace dawn_native { namespace metal {
indexBufferOffset:indexBufferBaseOffset
indirectBuffer:indirectBuffer
indirectBufferOffset:draw->indirectOffset];
} break;
break;
}
case Command::InsertDebugMarker: {
InsertDebugMarkerCmd* cmd = iter->NextCommand<InsertDebugMarkerCmd>();
@ -1114,13 +1141,15 @@ namespace dawn_native { namespace metal {
[encoder insertDebugSignpost:mtlLabel];
[mtlLabel release];
} break;
break;
}
case Command::PopDebugGroup: {
iter->NextCommand<PopDebugGroupCmd>();
[encoder popDebugGroup];
} break;
break;
}
case Command::PushDebugGroup: {
PushDebugGroupCmd* cmd = iter->NextCommand<PushDebugGroupCmd>();
@ -1129,7 +1158,8 @@ namespace dawn_native { namespace metal {
[encoder pushDebugGroup:mtlLabel];
[mtlLabel release];
} break;
break;
}
case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>();
@ -1144,7 +1174,8 @@ namespace dawn_native { namespace metal {
newPipeline->Encode(encoder);
lastPipeline = newPipeline;
} break;
break;
}
case Command::SetBindGroup: {
SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>();
@ -1155,21 +1186,24 @@ namespace dawn_native { namespace metal {
bindGroups.OnSetBindGroup(cmd->index, ToBackend(cmd->group.Get()),
cmd->dynamicOffsetCount, dynamicOffsets);
} break;
break;
}
case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
auto b = ToBackend(cmd->buffer.Get());
indexBuffer = b->GetMTLBuffer();
indexBufferBaseOffset = cmd->offset;
} break;
break;
}
case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
vertexBuffers.OnSetVertexBuffer(cmd->slot, ToBackend(cmd->buffer.Get()),
cmd->offset);
} break;
break;
}
default:
UNREACHABLE();
@ -1184,12 +1218,14 @@ namespace dawn_native { namespace metal {
mCommands.NextCommand<EndRenderPassCmd>();
commandContext->EndRender();
return;
} break;
break;
}
case Command::SetStencilReference: {
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
[encoder setStencilReferenceValue:cmd->reference];
} break;
break;
}
case Command::SetViewport: {
SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
@ -1202,7 +1238,8 @@ namespace dawn_native { namespace metal {
viewport.zfar = cmd->maxDepth;
[encoder setViewport:viewport];
} break;
break;
}
case Command::SetScissorRect: {
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
@ -1222,7 +1259,8 @@ namespace dawn_native { namespace metal {
}
[encoder setScissorRect:rect];
} break;
break;
}
case Command::SetBlendColor: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
@ -1230,7 +1268,8 @@ namespace dawn_native { namespace metal {
green:cmd->color.g
blue:cmd->color.b
alpha:cmd->color.a];
} break;
break;
}
case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>();
@ -1243,9 +1282,13 @@ namespace dawn_native { namespace metal {
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,
binding.size);
} break;
break;
}
case wgpu::BindingType::StorageBuffer:
case wgpu::BindingType::ReadonlyStorageBuffer: {
@ -276,7 +277,8 @@ namespace dawn_native { namespace opengl {
gl.BindBufferRange(GL_SHADER_STORAGE_BUFFER, ssboIndex, buffer, offset,
binding.size);
} break;
break;
}
case wgpu::BindingType::Sampler: {
Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
@ -292,7 +294,8 @@ namespace dawn_native { namespace opengl {
gl.BindSampler(unit.unit, sampler->GetNonFilteringHandle());
}
}
} break;
break;
}
case wgpu::BindingType::SampledTexture: {
TextureView* view =
@ -305,7 +308,8 @@ namespace dawn_native { namespace opengl {
gl.ActiveTexture(GL_TEXTURE0 + unit);
gl.BindTexture(target, handle);
}
} break;
break;
}
case wgpu::BindingType::StorageTexture:
case wgpu::BindingType::ReadonlyStorageTexture:
@ -435,7 +439,8 @@ namespace dawn_native { namespace opengl {
ExecuteComputePass();
nextPassNumber++;
} break;
break;
}
case Command::BeginRenderPass: {
auto* cmd = mCommands.NextCommand<BeginRenderPassCmd>();
@ -445,7 +450,8 @@ namespace dawn_native { namespace opengl {
ExecuteRenderPass(cmd);
nextPassNumber++;
} break;
break;
}
case Command::CopyBufferToBuffer: {
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_UNPACK_BUFFER, 0);
} break;
break;
}
case Command::CopyBufferToTexture: {
CopyBufferToTextureCmd* copy = mCommands.NextCommand<CopyBufferToTextureCmd>();
@ -537,7 +544,8 @@ namespace dawn_native { namespace opengl {
gl.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0);
gl.BindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
} break;
break;
}
case Command::CopyTextureToBuffer: {
CopyTextureToBufferCmd* copy = mCommands.NextCommand<CopyTextureToBufferCmd>();
@ -594,7 +602,8 @@ namespace dawn_native { namespace opengl {
gl.BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
gl.DeleteFramebuffers(1, &readFBO);
} break;
break;
}
case Command::CopyTextureToTexture: {
CopyTextureToTextureCmd* copy =
@ -623,9 +632,13 @@ namespace dawn_native { namespace opengl {
dstTexture->GetHandle(), dstTexture->GetGLTarget(),
dst.mipLevel, dst.origin.x, dst.origin.y, dst.arrayLayer,
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: {
mCommands.NextCommand<EndComputePassCmd>();
return;
} break;
break;
}
case Command::Dispatch: {
DispatchCmd* dispatch = mCommands.NextCommand<DispatchCmd>();
@ -650,7 +664,8 @@ namespace dawn_native { namespace opengl {
gl.DispatchCompute(dispatch->x, dispatch->y, dispatch->z);
// TODO(cwallez@chromium.org): add barriers to the API
gl.MemoryBarrier(GL_ALL_BARRIER_BITS);
} break;
break;
}
case Command::DispatchIndirect: {
DispatchIndirectCmd* dispatch = mCommands.NextCommand<DispatchIndirectCmd>();
@ -663,7 +678,8 @@ namespace dawn_native { namespace opengl {
gl.DispatchComputeIndirect(static_cast<GLintptr>(indirectBufferOffset));
// TODO(cwallez@chromium.org): add barriers to the API
gl.MemoryBarrier(GL_ALL_BARRIER_BITS);
} break;
break;
}
case Command::SetComputePipeline: {
SetComputePipelineCmd* cmd = mCommands.NextCommand<SetComputePipelineCmd>();
@ -671,7 +687,8 @@ namespace dawn_native { namespace opengl {
lastPipeline->ApplyNow();
bindGroupTracker.OnSetPipeline(lastPipeline);
} break;
break;
}
case Command::SetBindGroup: {
SetBindGroupCmd* cmd = mCommands.NextCommand<SetBindGroupCmd>();
@ -681,7 +698,8 @@ namespace dawn_native { namespace opengl {
}
bindGroupTracker.OnSetBindGroup(cmd->index, cmd->group.Get(),
cmd->dynamicOffsetCount, dynamicOffsets);
} break;
break;
}
case Command::InsertDebugMarker:
case Command::PopDebugGroup:
@ -689,9 +707,13 @@ namespace dawn_native { namespace opengl {
// Due to lack of linux driver support for GL_EXT_debug_marker
// extension these functions are skipped.
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->instanceCount);
}
} break;
break;
}
case Command::DrawIndexed: {
DrawIndexedCmd* draw = iter->NextCommand<DrawIndexedCmd>();
@ -892,7 +915,8 @@ namespace dawn_native { namespace opengl {
draw->instanceCount);
}
}
} break;
break;
}
case Command::DrawIndirect: {
DrawIndirectCmd* draw = iter->NextCommand<DrawIndirectCmd>();
@ -906,7 +930,8 @@ namespace dawn_native { namespace opengl {
gl.DrawArraysIndirect(
lastPipeline->GetGLPrimitiveTopology(),
reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset)));
} break;
break;
}
case Command::DrawIndexedIndirect: {
DrawIndexedIndirectCmd* draw = iter->NextCommand<DrawIndexedIndirectCmd>();
@ -924,7 +949,8 @@ namespace dawn_native { namespace opengl {
gl.DrawElementsIndirect(
lastPipeline->GetGLPrimitiveTopology(), formatType,
reinterpret_cast<void*>(static_cast<intptr_t>(indirectBufferOffset)));
} break;
break;
}
case Command::InsertDebugMarker:
case Command::PopDebugGroup:
@ -932,7 +958,8 @@ namespace dawn_native { namespace opengl {
// Due to lack of linux driver support for GL_EXT_debug_marker
// extension these functions are skipped.
SkipCommand(iter, type);
} break;
break;
}
case Command::SetRenderPipeline: {
SetRenderPipelineCmd* cmd = iter->NextCommand<SetRenderPipelineCmd>();
@ -941,7 +968,8 @@ namespace dawn_native { namespace opengl {
vertexStateBufferBindingTracker.OnSetPipeline(lastPipeline);
bindGroupTracker.OnSetPipeline(lastPipeline);
} break;
break;
}
case Command::SetBindGroup: {
SetBindGroupCmd* cmd = iter->NextCommand<SetBindGroupCmd>();
@ -951,19 +979,22 @@ namespace dawn_native { namespace opengl {
}
bindGroupTracker.OnSetBindGroup(cmd->index, cmd->group.Get(),
cmd->dynamicOffsetCount, dynamicOffsets);
} break;
break;
}
case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = iter->NextCommand<SetIndexBufferCmd>();
indexBufferBaseOffset = cmd->offset;
vertexStateBufferBindingTracker.OnSetIndexBuffer(cmd->buffer.Get());
} break;
break;
}
case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = iter->NextCommand<SetVertexBufferCmd>();
vertexStateBufferBindingTracker.OnSetVertexBuffer(cmd->slot, cmd->buffer.Get(),
cmd->offset);
} break;
break;
}
default:
UNREACHABLE();
@ -982,28 +1013,33 @@ namespace dawn_native { namespace opengl {
}
gl.DeleteFramebuffers(1, &fbo);
return;
} break;
break;
}
case Command::SetStencilReference: {
SetStencilReferenceCmd* cmd = mCommands.NextCommand<SetStencilReferenceCmd>();
persistentPipelineState.SetStencilReference(gl, cmd->reference);
} break;
break;
}
case Command::SetViewport: {
SetViewportCmd* cmd = mCommands.NextCommand<SetViewportCmd>();
gl.ViewportIndexedf(0, cmd->x, cmd->y, cmd->width, cmd->height);
gl.DepthRangef(cmd->minDepth, cmd->maxDepth);
} break;
break;
}
case Command::SetScissorRect: {
SetScissorRectCmd* cmd = mCommands.NextCommand<SetScissorRectCmd>();
gl.Scissor(cmd->x, cmd->y, cmd->width, cmd->height);
} break;
break;
}
case Command::SetBlendColor: {
SetBlendColorCmd* cmd = mCommands.NextCommand<SetBlendColorCmd>();
gl.BlendColor(cmd->color.r, cmd->color.g, cmd->color.b, cmd->color.a);
} break;
break;
}
case Command::ExecuteBundles: {
ExecuteBundlesCmd* cmd = mCommands.NextCommand<ExecuteBundlesCmd>();
@ -1016,9 +1052,13 @@ namespace dawn_native { namespace opengl {
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,
indices[group][bindingIndex]);
}
} break;
break;
}
case wgpu::BindingType::StorageBuffer:
case wgpu::BindingType::ReadonlyStorageBuffer: {
@ -131,7 +132,8 @@ namespace dawn_native { namespace opengl {
gl.ShaderStorageBlockBinding(mProgram, location,
indices[group][bindingIndex]);
}
} break;
break;
}
case wgpu::BindingType::Sampler:
case wgpu::BindingType::SampledTexture:

View File

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

View File

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

View File

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