Skip to content

Commit 5d3c16f

Browse files
beaufortfrancoisDawn LUCI CQ
authored andcommitted
Enable texture view usage for externalTexture binding by default
This CL enables using a texture view for an external binding behind a toggle disabled by default. Bug: 398752857 Change-Id: I0c9046203331cd6e049abfc94b858ec8e2bbb452 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/234014 Reviewed-by: Loko Kung <[email protected]> Reviewed-by: Corentin Wallez <[email protected]> Commit-Queue: Fr <[email protected]>
1 parent e6ef9ef commit 5d3c16f

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

src/dawn/native/BindGroup.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,7 @@ MaybeError ValidateBindGroupDescriptor(DeviceBase* device,
510510
layout->GetExternalTextureBindingExpansionMap()));
511511
continue;
512512
}
513-
// TODO(crbug.com/398752857): Make this controlled by a toggle before shipping.
514-
if (device->IsToggleEnabled(Toggle::AllowUnsafeAPIs)) {
513+
if (!device->IsToggleEnabled(Toggle::DisableTextureViewBindingUsedAsExternalTexture)) {
515514
DAWN_TRY_CONTEXT(ValidateTextureViewBindingUsedAsExternalTexture(device, entry),
516515
"validating entries[%u] as a TextureView."
517516
"\nExpected entry layout: %s",

src/dawn/native/Toggles.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,10 @@ static constexpr ToggleEnumAndInfoList kToggleNameAndInfoList = {{
169169
{Toggle::MetalEnableVertexPulling,
170170
{"metal_enable_vertex_pulling", "Uses vertex pulling to protect out-of-bounds reads on Metal",
171171
"https://crbug.com/dawn/480", ToggleStage::Device}},
172+
{Toggle::DisableTextureViewBindingUsedAsExternalTexture,
173+
{"disable_texture_view_binding_used_as_external_texture",
174+
"Disable using a texture view for an externalTexture binding.", "http://crbug.com/398752857",
175+
ToggleStage::Device}},
172176
{Toggle::AllowUnsafeAPIs,
173177
{"allow_unsafe_apis",
174178
"Suppresses validation errors on API entry points or parameter combinations that aren't "

src/dawn/native/Toggles.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ enum class Toggle {
6565
UseDXC,
6666
DisableRobustness,
6767
MetalEnableVertexPulling,
68+
DisableTextureViewBindingUsedAsExternalTexture,
6869
AllowUnsafeAPIs,
6970
FlushBeforeClientWaitSync,
7071
UseTempBufferInSmallFormatTextureToTextureCopyFromGreaterToLessMipLevel,

src/dawn/tests/unittests/validation/ExternalTextureTests.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -617,16 +617,26 @@ TEST_F(ExternalTextureTest, BindGroupDoesNotMatchLayout) {
617617
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
618618
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bgl, {{0, externalTexture}}));
619619
}
620+
621+
// Bind group creation should fail when a sampler is present in the
622+
// corresponding slot of the bind group layout.
623+
{
624+
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
625+
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
626+
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bgl, {{0, device.CreateSampler()}}));
627+
}
620628
}
621629

622-
class ExternalTextureTestSafe : public ExternalTextureTest {
630+
class ExternalTextureTestEnabledToggle : public ExternalTextureTest {
623631
protected:
624-
bool AllowUnsafeAPIs() override { return false; }
632+
std::vector<const char*> GetEnabledToggles() override {
633+
return {"disable_texture_view_binding_used_as_external_texture"};
634+
}
625635
};
626636

627637
// Regression test for crbug.com/1343099 where BindGroup validation let other binding types be used
628638
// for external texture bindings.
629-
TEST_F(ExternalTextureTestSafe, TextureViewBindingDoesntMatch) {
639+
TEST_F(ExternalTextureTestEnabledToggle, TextureViewBindingDoesntMatch) {
630640
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
631641
device, {{0, wgpu::ShaderStage::Fragment, &utils::kExternalTextureBindingLayout}});
632642

0 commit comments

Comments
 (0)