Skip to content

Commit

Permalink
Reland "webgpu.h: Update BindingNotUsed enum values | Part 1"
Browse files Browse the repository at this point in the history
This is a reland of commit bcfc294

Original change's description:
> webgpu.h: Update BindingNotUsed enum values | Part 1
>
> This CL renames current Undefined values to BindingNotUsed=0 (still the
> default) for the following four enums:
>
> - WGPUBufferBindingType
> - WGPUSamplerBindingType
> - WGPUTextureSampleType
> - WGPUStorageTextureAccess
>
> webgpu-native/webgpu-headers#364
>
> Bug: 377820810
> Change-Id: Id75bd9f05a78e8f08a319ef70050f45423f37e3d
> Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/215114
> Commit-Queue: Kai Ninomiya <[email protected]>
> Reviewed-by: Kai Ninomiya <[email protected]>

Bug: 377820810
Change-Id: I095a88650a181d96fb6930d3eb606cb26c029147
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/217976
Auto-Submit: Loko Kung <[email protected]>
Commit-Queue: Shrek Shao <[email protected]>
Commit-Queue: Loko Kung <[email protected]>
Reviewed-by: Shrek Shao <[email protected]>
  • Loading branch information
beaufortfrancois authored and Dawn LUCI CQ committed Dec 5, 2024
1 parent 2d08f94 commit 2906936
Show file tree
Hide file tree
Showing 27 changed files with 68 additions and 67 deletions.
16 changes: 8 additions & 8 deletions src/dawn/dawn.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@
"buffer binding type": {
"category": "enum",
"values": [
{"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false},
{"value": 0, "name": "binding not used"},
{"value": 1, "name": "uniform"},
{"value": 2, "name": "storage"},
{"value": 3, "name": "read only storage"}
Expand All @@ -387,7 +387,7 @@
"category": "structure",
"extensible": "in",
"members": [
{"name": "type", "type": "buffer binding type", "default": "undefined"},
{"name": "type", "type": "buffer binding type", "default": "binding not used"},
{"name": "has dynamic offset", "type": "bool", "default": "false"},
{"name": "min binding size", "type": "uint64_t", "default": "0"}
]
Expand All @@ -396,7 +396,7 @@
"sampler binding type": {
"category": "enum",
"values": [
{"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false},
{"value": 0, "name": "binding not used"},
{"value": 1, "name": "filtering"},
{"value": 2, "name": "non filtering"},
{"value": 3, "name": "comparison"}
Expand All @@ -406,7 +406,7 @@
"category": "structure",
"extensible": "in",
"members": [
{"name": "type", "type": "sampler binding type", "default": "undefined"}
{"name": "type", "type": "sampler binding type", "default": "binding not used"}
]
},
"static sampler binding layout": {
Expand All @@ -422,7 +422,7 @@
"texture sample type": {
"category": "enum",
"values": [
{"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false},
{"value": 0, "name": "binding not used"},
{"value": 1, "name": "float"},
{"value": 2, "name": "unfilterable float"},
{"value": 3, "name": "depth"},
Expand All @@ -434,7 +434,7 @@
"category": "structure",
"extensible": "in",
"members": [
{"name": "sample type", "type": "texture sample type", "default": "undefined"},
{"name": "sample type", "type": "texture sample type", "default": "binding not used"},
{"name": "view dimension", "type": "texture view dimension", "default": "2D"},
{"name": "multisampled", "type": "bool", "default": "false"}
]
Expand Down Expand Up @@ -495,7 +495,7 @@
"storage texture access": {
"category": "enum",
"values": [
{"value": 0, "name": "undefined", "jsrepr": "undefined", "valid": false},
{"value": 0, "name": "binding not used"},
{"value": 1, "name": "write only"},
{"value": 2, "name": "read only"},
{"value": 3, "name": "read write"}
Expand All @@ -505,7 +505,7 @@
"category": "structure",
"extensible": "in",
"members": [
{"name": "access", "type": "storage texture access", "default": "undefined"},
{"name": "access", "type": "storage texture access", "default": "binding not used"},
{"name": "format", "type": "texture format", "default": "undefined"},
{"name": "view dimension", "type": "texture view dimension", "default": "2D"}
]
Expand Down
2 changes: 1 addition & 1 deletion src/dawn/native/BindGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ MaybeError ValidateBufferBinding(const DeviceBase* device,
maxBindingSize = device->GetLimits().v1.maxStorageBufferBindingSize;
requiredBindingAlignment = device->GetLimits().v1.minStorageBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}

Expand Down
24 changes: 12 additions & 12 deletions src/dawn/native/BindGroupLayoutInternal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ MaybeError ValidateBindGroupLayoutEntry(DeviceBase* device,

int bindingMemberCount = 0;

if (entry->buffer.type != wgpu::BufferBindingType::Undefined) {
if (entry->buffer.type != wgpu::BufferBindingType::BindingNotUsed) {
bindingMemberCount++;
const BufferBindingLayout& buffer = entry->buffer;

Expand All @@ -119,12 +119,12 @@ MaybeError ValidateBindGroupLayoutEntry(DeviceBase* device,
}
}

if (entry->sampler.type != wgpu::SamplerBindingType::Undefined) {
if (entry->sampler.type != wgpu::SamplerBindingType::BindingNotUsed) {
bindingMemberCount++;
DAWN_TRY(ValidateSamplerBindingType(entry->sampler.type));
}

if (entry->texture.sampleType != wgpu::TextureSampleType::Undefined) {
if (entry->texture.sampleType != wgpu::TextureSampleType::BindingNotUsed) {
bindingMemberCount++;
const TextureBindingLayout& texture = entry->texture;
// The kInternalResolveAttachmentSampleType is used internally and not a value
Expand Down Expand Up @@ -166,7 +166,7 @@ MaybeError ValidateBindGroupLayoutEntry(DeviceBase* device,
"Sample type for multisampled texture binding was %s.", wgpu::TextureSampleType::Float);
}

if (entry->storageTexture.access != wgpu::StorageTextureAccess::Undefined) {
if (entry->storageTexture.access != wgpu::StorageTextureAccess::BindingNotUsed) {
bindingMemberCount++;
const StorageTextureBindingLayout& storageTexture = entry->storageTexture;
DAWN_TRY(ValidateStorageTextureAccess(storageTexture.access));
Expand Down Expand Up @@ -257,7 +257,7 @@ MaybeError ValidateStaticSamplersWithTextureBindings(
samplerBinding, sampledTextureBinding);

auto& textureEntry = descriptor->entries[bindingNumberToIndexMap.at(sampledTextureBinding)];
DAWN_INVALID_IF(textureEntry.texture.sampleType == wgpu::TextureSampleType::Undefined,
DAWN_INVALID_IF(textureEntry.texture.sampleType == wgpu::TextureSampleType::BindingNotUsed,
"For static sampler binding (%u) the sampled texture binding (%u) is not a "
"texture binding.",
samplerBinding, sampledTextureBinding);
Expand Down Expand Up @@ -443,11 +443,11 @@ bool operator!=(const BindingInfo& a, const BindingInfo& b) {
}

bool IsBufferBinding(const UnpackedPtr<BindGroupLayoutEntry>& binding) {
return binding->buffer.type != wgpu::BufferBindingType::Undefined;
return binding->buffer.type != wgpu::BufferBindingType::BindingNotUsed;
}

bool BindingHasDynamicOffset(const UnpackedPtr<BindGroupLayoutEntry>& binding) {
if (binding->buffer.type != wgpu::BufferBindingType::Undefined) {
if (binding->buffer.type != wgpu::BufferBindingType::BindingNotUsed) {
return binding->buffer.hasDynamicOffset;
}
return false;
Expand All @@ -458,18 +458,18 @@ BindingInfo CreateBindGroupLayoutInfo(const UnpackedPtr<BindGroupLayoutEntry>& b
bindingInfo.binding = BindingNumber(binding->binding);
bindingInfo.visibility = binding->visibility;

if (binding->buffer.type != wgpu::BufferBindingType::Undefined) {
if (binding->buffer.type != wgpu::BufferBindingType::BindingNotUsed) {
bindingInfo.bindingLayout = BufferBindingInfo(binding->buffer);
} else if (binding->sampler.type != wgpu::SamplerBindingType::Undefined) {
} else if (binding->sampler.type != wgpu::SamplerBindingType::BindingNotUsed) {
bindingInfo.bindingLayout = SamplerBindingInfo(binding->sampler);
} else if (binding->texture.sampleType != wgpu::TextureSampleType::Undefined) {
} else if (binding->texture.sampleType != wgpu::TextureSampleType::BindingNotUsed) {
if (binding->texture.viewDimension == kInternalInputAttachmentDim) {
bindingInfo.bindingLayout = InputAttachmentBindingInfo(binding->texture.sampleType);
} else {
bindingInfo.bindingLayout =
TextureBindingInfo(binding->texture.WithTrivialFrontendDefaults());
}
} else if (binding->storageTexture.access != wgpu::StorageTextureAccess::Undefined) {
} else if (binding->storageTexture.access != wgpu::StorageTextureAccess::BindingNotUsed) {
bindingInfo.bindingLayout =
StorageTextureBindingInfo(binding->storageTexture.WithTrivialFrontendDefaults());
} else if (auto* staticSamplerBindingLayout = binding.Get<StaticSamplerBindingLayout>()) {
Expand Down Expand Up @@ -825,7 +825,7 @@ bool BindGroupLayoutInternalBase::IsStorageBufferBinding(BindingIndex bindingInd
case wgpu::BufferBindingType::Storage:
case wgpu::BufferBindingType::ReadOnlyStorage:
return true;
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
break;
}
DAWN_UNREACHABLE();
Expand Down
10 changes: 5 additions & 5 deletions src/dawn/native/BindingInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void IncrementBindingCounts(BindingCounts* bindingCounts,

uint32_t PerStageBindingCounts::*perStageBindingCountMember = nullptr;

if (entry->buffer.type != wgpu::BufferBindingType::Undefined) {
if (entry->buffer.type != wgpu::BufferBindingType::BindingNotUsed) {
++bindingCounts->bufferCount;
const BufferBindingLayout& buffer = entry->buffer;

Expand All @@ -82,21 +82,21 @@ void IncrementBindingCounts(BindingCounts* bindingCounts,
perStageBindingCountMember = &PerStageBindingCounts::storageBufferCount;
break;

case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
// Can't get here due to the enclosing if statement.
DAWN_UNREACHABLE();
break;
}
} else if (entry->sampler.type != wgpu::SamplerBindingType::Undefined) {
} else if (entry->sampler.type != wgpu::SamplerBindingType::BindingNotUsed) {
perStageBindingCountMember = &PerStageBindingCounts::samplerCount;
} else if (entry->texture.sampleType != wgpu::TextureSampleType::Undefined) {
} else if (entry->texture.sampleType != wgpu::TextureSampleType::BindingNotUsed) {
if (entry->texture.viewDimension == kInternalInputAttachmentDim) {
// Internal use only.
return;
} else {
perStageBindingCountMember = &PerStageBindingCounts::sampledTextureCount;
}
} else if (entry->storageTexture.access != wgpu::StorageTextureAccess::Undefined) {
} else if (entry->storageTexture.access != wgpu::StorageTextureAccess::BindingNotUsed) {
perStageBindingCountMember = &PerStageBindingCounts::storageTextureCount;
} else if (entry.Get<ExternalTextureBindingLayout>()) {
perStageBindingCountMember = &PerStageBindingCounts::externalTextureCount;
Expand Down
2 changes: 1 addition & 1 deletion src/dawn/native/CommandBufferStateTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ Return FindStorageBufferBindingAliasing(const PipelineLayoutBase* pipelineLayout
break;
case wgpu::StorageTextureAccess::ReadOnly:
continue;
case wgpu::StorageTextureAccess::Undefined:
case wgpu::StorageTextureAccess::BindingNotUsed:
default:
DAWN_UNREACHABLE();
}
Expand Down
6 changes: 3 additions & 3 deletions src/dawn/native/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ SampleTypeBit SampleTypeToSampleTypeBit(wgpu::TextureSampleType sampleType) {
case wgpu::TextureSampleType::Sint:
case wgpu::TextureSampleType::Uint:
case wgpu::TextureSampleType::Depth:
case wgpu::TextureSampleType::Undefined:
case wgpu::TextureSampleType::BindingNotUsed:
// When the compiler complains that you need to add a case statement here, please
// also add a corresponding static assert below!
break;
}

static_assert(static_cast<uint32_t>(wgpu::TextureSampleType::Undefined) == 0);
if (sampleType == wgpu::TextureSampleType::Undefined) {
static_assert(static_cast<uint32_t>(wgpu::TextureSampleType::BindingNotUsed) == 0);
if (sampleType == wgpu::TextureSampleType::BindingNotUsed) {
return SampleTypeBit::None;
}

Expand Down
4 changes: 2 additions & 2 deletions src/dawn/native/PassResourceUsageTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void SyncScopeUsageTracker::AddBindGroup(BindGroupBase* group) {
case wgpu::BufferBindingType::ReadOnlyStorage:
BufferUsedAs(buffer, kReadOnlyStorageBuffer, bindingInfo.visibility);
break;
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}
},
Expand Down Expand Up @@ -156,7 +156,7 @@ void SyncScopeUsageTracker::AddBindGroup(BindGroupBase* group) {
case wgpu::StorageTextureAccess::ReadOnly:
TextureViewUsedAs(view, kReadOnlyStorageTexture, bindingInfo.visibility);
break;
case wgpu::StorageTextureAccess::Undefined:
case wgpu::StorageTextureAccess::BindingNotUsed:
DAWN_UNREACHABLE();
}
},
Expand Down
10 changes: 5 additions & 5 deletions src/dawn/native/PipelineLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,17 @@ ResultOrError<Ref<PipelineLayoutBase>> PipelineLayoutBase::CreateDefault(
modifiedEntry->buffer.type == mergedEntry.buffer.type &&
modifiedEntry->sampler.type == mergedEntry.sampler.type &&
// Compatibility between these sample types is checked below.
(modifiedEntry->texture.sampleType != wgpu::TextureSampleType::Undefined) ==
(mergedEntry.texture.sampleType != wgpu::TextureSampleType::Undefined) &&
(modifiedEntry->texture.sampleType != wgpu::TextureSampleType::BindingNotUsed) ==
(mergedEntry.texture.sampleType != wgpu::TextureSampleType::BindingNotUsed) &&
modifiedEntry->storageTexture.access == mergedEntry.storageTexture.access;

// Minimum buffer binding size excluded because we take the maximum seen across stages.
if (modifiedEntry->buffer.type != wgpu::BufferBindingType::Undefined) {
if (modifiedEntry->buffer.type != wgpu::BufferBindingType::BindingNotUsed) {
compatible = compatible && modifiedEntry->buffer.hasDynamicOffset ==
mergedEntry.buffer.hasDynamicOffset;
}

if (modifiedEntry->texture.sampleType != wgpu::TextureSampleType::Undefined) {
if (modifiedEntry->texture.sampleType != wgpu::TextureSampleType::BindingNotUsed) {
// Sample types are compatible if they are exactly equal,
// or if the |modifiedEntry| is Float and the |mergedEntry| is UnfilterableFloat.
// Note that the |mergedEntry| never has type Float. Texture bindings all start
Expand All @@ -229,7 +229,7 @@ ResultOrError<Ref<PipelineLayoutBase>> PipelineLayoutBase::CreateDefault(
modifiedEntry->texture.multisampled == mergedEntry.texture.multisampled;
}

if (modifiedEntry->storageTexture.access != wgpu::StorageTextureAccess::Undefined) {
if (modifiedEntry->storageTexture.access != wgpu::StorageTextureAccess::BindingNotUsed) {
compatible =
compatible &&
modifiedEntry->storageTexture.format == mergedEntry.storageTexture.format &&
Expand Down
2 changes: 1 addition & 1 deletion src/dawn/native/ProgrammableEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ MaybeError ProgrammableEncoder::ValidateSetBindGroup(BindGroupIndex index,
case kInternalStorageBufferBinding:
requiredAlignment = GetDevice()->GetLimits().v1.minStorageBufferOffsetAlignment;
break;
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}

Expand Down
2 changes: 1 addition & 1 deletion src/dawn/native/ShaderModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ wgpu::TextureSampleType TintSampledKindToSampleType(
// Note that Float is compatible with both Float and UnfilterableFloat.
return wgpu::TextureSampleType::Float;
case tint::inspector::ResourceBinding::SampledKind::kUnknown:
return wgpu::TextureSampleType::Undefined;
return wgpu::TextureSampleType::BindingNotUsed;
}
DAWN_UNREACHABLE();
}
Expand Down
9 changes: 5 additions & 4 deletions src/dawn/native/d3d11/BindGroupTrackerD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ MaybeError BindGroupTracker::ApplyBindGroup(BindGroupIndex index) {
}
break;
}
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}
return {};
Expand Down Expand Up @@ -370,7 +370,7 @@ void ComputePassBindGroupTracker::UnapplyComputeBindings(BindGroupIndex index) {
deviceContext->CSSetShaderResources(bindingSlot, 1, &nullSRV);
break;
}
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}
},
Expand Down Expand Up @@ -494,10 +494,11 @@ MaybeError RenderPassBindGroupTracker::Apply() {
break;
}
case wgpu::BufferBindingType::Uniform:
case wgpu::BufferBindingType::ReadOnlyStorage:
case wgpu::BufferBindingType::Undefined: {
case wgpu::BufferBindingType::ReadOnlyStorage: {
break;
}
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}
return {};
},
Expand Down
4 changes: 2 additions & 2 deletions src/dawn/native/d3d11/PipelineLayoutD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ MaybeError PipelineLayout::Initialize(Device* device) {
case wgpu::BufferBindingType::ReadOnlyStorage:
mIndexInfo[group][bindingIndex] = shaderResourceViewIndex++;
break;
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}
},
Expand All @@ -102,7 +102,7 @@ MaybeError PipelineLayout::Initialize(Device* device) {
case wgpu::StorageTextureAccess::ReadOnly:
mIndexInfo[group][bindingIndex] = shaderResourceViewIndex++;
break;
case wgpu::StorageTextureAccess::Undefined:
case wgpu::StorageTextureAccess::BindingNotUsed:
DAWN_UNREACHABLE();
}
},
Expand Down
2 changes: 1 addition & 1 deletion src/dawn/native/d3d11/ShaderModuleD3D11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ ResultOrError<d3d::CompiledShader> ShaderModule::Compile(
srcBindingPoint, tint::hlsl::writer::binding::Storage{
dstBindingPoint.group, dstBindingPoint.binding});
break;
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/dawn/native/d3d12/BindGroupD3D12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ BindGroup::BindGroup(Device* device,
descriptorHeapOffsets[bindingIndex]));
break;
}
case wgpu::BufferBindingType::Undefined:
case wgpu::BufferBindingType::BindingNotUsed:
DAWN_UNREACHABLE();
}
},
Expand Down Expand Up @@ -190,7 +190,7 @@ BindGroup::BindGroup(Device* device,
descriptorHeapOffsets[bindingIndex]));
break;
}
case wgpu::StorageTextureAccess::Undefined:
case wgpu::StorageTextureAccess::BindingNotUsed:
DAWN_UNREACHABLE();
}
},
Expand Down
Loading

0 comments on commit 2906936

Please sign in to comment.