Compat: Validate out rg32xxx storage textures
GLES 3.1 doesn't support rg32sint, rg32uint, rg32float
Bug: dawn:595
Change-Id: Id3e87bc79c5e84c4ac939c84b032aa5d6a5f5212
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/165524
Commit-Queue: Gregg Tavares <gman@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/Format.cpp b/src/dawn/native/Format.cpp
index 5ec9cc4..e846f06 100644
--- a/src/dawn/native/Format.cpp
+++ b/src/dawn/native/Format.cpp
@@ -467,9 +467,11 @@
AddColorFormat(wgpu::TextureFormat::RGB9E5Ufloat, Cap::None, ByteSize(4), kAnyFloat, ComponentCount(3));
// 8 bytes color formats
- AddColorFormat(wgpu::TextureFormat::RG32Uint, Cap::Renderable | Cap::StorageW, ByteSize(8), SampleTypeBit::Uint, ComponentCount(2), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4));
- AddColorFormat(wgpu::TextureFormat::RG32Sint, Cap::Renderable | Cap::StorageW, ByteSize(8), SampleTypeBit::Sint, ComponentCount(2), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4));
- AddColorFormat(wgpu::TextureFormat::RG32Float, Cap::Renderable | Cap::StorageW, ByteSize(8), sampleTypeFor32BitFloatFormats, ComponentCount(2), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4));
+ auto rg32StorageCaps = device->IsCompatibilityMode() ? Cap::None : Cap::StorageW;
+
+ AddColorFormat(wgpu::TextureFormat::RG32Uint, Cap::Renderable | rg32StorageCaps, ByteSize(8), SampleTypeBit::Uint, ComponentCount(2), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4));
+ AddColorFormat(wgpu::TextureFormat::RG32Sint, Cap::Renderable | rg32StorageCaps, ByteSize(8), SampleTypeBit::Sint, ComponentCount(2), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4));
+ AddColorFormat(wgpu::TextureFormat::RG32Float, Cap::Renderable | rg32StorageCaps, ByteSize(8), sampleTypeFor32BitFloatFormats, ComponentCount(2), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(4));
AddColorFormat(wgpu::TextureFormat::RGBA16Uint, Cap::Renderable | Cap::StorageW | Cap::Multisample, ByteSize(8), SampleTypeBit::Uint, ComponentCount(4), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(2));
AddColorFormat(wgpu::TextureFormat::RGBA16Sint, Cap::Renderable | Cap::StorageW | Cap::Multisample, ByteSize(8), SampleTypeBit::Sint, ComponentCount(4), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(2));
AddColorFormat(wgpu::TextureFormat::RGBA16Float, Cap::Renderable | Cap::StorageW | Cap::Multisample | Cap::Resolve, ByteSize(8), kAnyFloat, ComponentCount(4), RenderTargetPixelByteCost(8), RenderTargetComponentAlignment(2));
diff --git a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp
index 1ec8684..04555f9 100644
--- a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp
@@ -293,6 +293,30 @@
}
}
+TEST_F(CompatValidationTest, CanNotCreateRGxxxStorageTexture) {
+ const wgpu::TextureFormat formats[] = {
+ wgpu::TextureFormat::RGBA8Unorm, // pass check
+ wgpu::TextureFormat::RG32Sint,
+ wgpu::TextureFormat::RG32Uint,
+ wgpu::TextureFormat::RG32Float,
+ };
+ for (auto format : formats) {
+ wgpu::TextureDescriptor descriptor;
+ descriptor.size = {1, 1, 1};
+ descriptor.dimension = wgpu::TextureDimension::e2D;
+ descriptor.format = format;
+ descriptor.usage = wgpu::TextureUsage::StorageBinding;
+ wgpu::Texture texture;
+
+ if (format == wgpu::TextureFormat::RGBA8Unorm) {
+ texture = device.CreateTexture(&descriptor);
+ } else {
+ ASSERT_DEVICE_ERROR(texture = device.CreateTexture(&descriptor));
+ }
+ texture.Destroy();
+ }
+}
+
constexpr const char* kRenderTwoTexturesOneBindgroupWGSL = R"(
@vertex
fn vs(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {