d3d11: Enable StorageTextureTests
Bug: dawn:1705
Change-Id: I7bcac2c5ee57c8030a592766edd992485ce54175
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/135120
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/dawn/native/d3d11/TextureD3D11.cpp b/src/dawn/native/d3d11/TextureD3D11.cpp
index ed6c981..ffcacc9 100644
--- a/src/dawn/native/d3d11/TextureD3D11.cpp
+++ b/src/dawn/native/d3d11/TextureD3D11.cpp
@@ -337,7 +337,8 @@
rtvDesc.Texture3D.WSize = singleLevelRange.layerCount;
break;
case wgpu::TextureDimension::e1D:
- UNREACHABLE();
+ rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE1D;
+ rtvDesc.Texture1D.MipSlice = singleLevelRange.baseMipLevel;
break;
}
return rtvDesc;
@@ -711,6 +712,7 @@
srcBox.top = src.origin.y;
srcBox.bottom = src.origin.y + copy->copySize.height;
switch (src.texture->GetDimension()) {
+ case wgpu::TextureDimension::e1D:
case wgpu::TextureDimension::e2D:
srcBox.front = 0;
srcBox.back = 1;
@@ -720,7 +722,6 @@
srcBox.back = src.origin.z + copy->copySize.depthOrArrayLayers;
break;
default:
- // TODO(dawn:1705): support 1d texture.
UNREACHABLE();
}
diff --git a/src/dawn/tests/end2end/StorageTextureTests.cpp b/src/dawn/tests/end2end/StorageTextureTests.cpp
index 589e539..d6bab6c 100644
--- a/src/dawn/tests/end2end/StorageTextureTests.cpp
+++ b/src/dawn/tests/end2end/StorageTextureTests.cpp
@@ -27,10 +27,9 @@
namespace dawn {
namespace {
-bool OpenGLESSupportsStorageTexture(wgpu::TextureFormat format) {
- // TODO(crbug.com/dawn/595): 32-bit RG* formats are unsupported on OpenGL ES.
- return format != wgpu::TextureFormat::RG32Float && format != wgpu::TextureFormat::RG32Sint &&
- format != wgpu::TextureFormat::RG32Uint;
+bool D3D11SupportsStorageTexture(wgpu::TextureFormat format) {
+ // TODO(dawn:1802): Support clearing non-renderable textures on D3D11.
+ return format != wgpu::TextureFormat::RGBA8Snorm;
}
class StorageTextureTests : public DawnTest {
@@ -668,10 +667,10 @@
// Test that write-only storage textures are supported in compute shader.
TEST_P(StorageTextureTests, WriteonlyStorageTextureInComputeShader) {
for (wgpu::TextureFormat format : utils::kAllTextureFormats) {
- if (!utils::TextureFormatSupportsStorageTexture(format)) {
+ if (!utils::TextureFormatSupportsStorageTexture(format, IsCompatibilityMode())) {
continue;
}
- if (IsOpenGLES() && !OpenGLESSupportsStorageTexture(format)) {
+ if (IsD3D11() && !D3D11SupportsStorageTexture(format)) {
continue;
}
@@ -708,10 +707,10 @@
DAWN_SUPPRESS_TEST_IF(IsNvidia() && IsLinux() && IsOpenGLES());
for (wgpu::TextureFormat format : utils::kAllTextureFormats) {
- if (!utils::TextureFormatSupportsStorageTexture(format)) {
+ if (!utils::TextureFormatSupportsStorageTexture(format, IsCompatibilityMode())) {
continue;
}
- if (IsOpenGLES() && !OpenGLESSupportsStorageTexture(format)) {
+ if (IsD3D11() && !D3D11SupportsStorageTexture(format)) {
continue;
}
@@ -870,6 +869,7 @@
}
DAWN_INSTANTIATE_TEST(StorageTextureTests,
+ D3D11Backend(),
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
@@ -934,6 +934,7 @@
}
DAWN_INSTANTIATE_TEST(BGRA8UnormStorageTextureTests,
+ D3D11Backend(),
D3D12Backend(),
MetalBackend(),
OpenGLBackend(),
@@ -1012,6 +1013,7 @@
}
DAWN_INSTANTIATE_TEST(StorageTextureZeroInitTests,
+ D3D11Backend({"nonzero_clear_resources_on_creation_for_testing"}),
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"}),
OpenGLESBackend({"nonzero_clear_resources_on_creation_for_testing"}),
diff --git a/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp b/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp
index b95129f..1e2136a 100644
--- a/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/StorageTextureValidationTests.cpp
@@ -261,7 +261,7 @@
for (wgpu::TextureFormat format : kWGPUTextureFormatSupportedAsSPIRVImageFormats) {
std::string computeShader =
CreateComputeShaderWithStorageTexture(storageTextureBindingType, format);
- if (utils::TextureFormatSupportsStorageTexture(format)) {
+ if (utils::TextureFormatSupportsStorageTexture(format, UseCompatibilityMode())) {
utils::CreateShaderModule(device, computeShader.c_str());
} else {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, computeShader.c_str()));
@@ -419,7 +419,7 @@
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.storageTexture.access = bindingType;
bindGroupLayoutBinding.storageTexture.format = textureFormat;
- if (utils::TextureFormatSupportsStorageTexture(textureFormat)) {
+ if (utils::TextureFormatSupportsStorageTexture(textureFormat, UseCompatibilityMode())) {
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
} else {
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}));
@@ -458,7 +458,8 @@
TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatchesShaderDeclaration) {
for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureFormat storageTextureFormatInShader : utils::kAllTextureFormats) {
- if (!utils::TextureFormatSupportsStorageTexture(storageTextureFormatInShader)) {
+ if (!utils::TextureFormatSupportsStorageTexture(storageTextureFormatInShader,
+ UseCompatibilityMode())) {
continue;
}
@@ -480,7 +481,7 @@
for (wgpu::TextureFormat storageTextureFormatInBindGroupLayout :
utils::kAllTextureFormats) {
if (!utils::TextureFormatSupportsStorageTexture(
- storageTextureFormatInBindGroupLayout)) {
+ storageTextureFormatInBindGroupLayout, UseCompatibilityMode())) {
continue;
}
@@ -643,7 +644,8 @@
defaultBindGroupLayoutEntry.storageTexture.access = storageBindingType;
for (wgpu::TextureFormat formatInBindGroupLayout : utils::kAllTextureFormats) {
- if (!utils::TextureFormatSupportsStorageTexture(formatInBindGroupLayout)) {
+ if (!utils::TextureFormatSupportsStorageTexture(formatInBindGroupLayout,
+ UseCompatibilityMode())) {
continue;
}
@@ -654,7 +656,8 @@
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
for (wgpu::TextureFormat textureViewFormat : utils::kAllTextureFormats) {
- if (!utils::TextureFormatSupportsStorageTexture(textureViewFormat)) {
+ if (!utils::TextureFormatSupportsStorageTexture(textureViewFormat,
+ UseCompatibilityMode())) {
continue;
}
diff --git a/src/dawn/tests/unittests/validation/TextureValidationTests.cpp b/src/dawn/tests/unittests/validation/TextureValidationTests.cpp
index e48d4a9..1397677 100644
--- a/src/dawn/tests/unittests/validation/TextureValidationTests.cpp
+++ b/src/dawn/tests/unittests/validation/TextureValidationTests.cpp
@@ -625,7 +625,7 @@
for (wgpu::TextureFormat format : utils::kAllTextureFormats) {
descriptor.format = format;
- if (utils::TextureFormatSupportsStorageTexture(format)) {
+ if (utils::TextureFormatSupportsStorageTexture(format, UseCompatibilityMode())) {
device.CreateTexture(&descriptor);
} else {
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
diff --git a/src/dawn/utils/TextureUtils.cpp b/src/dawn/utils/TextureUtils.cpp
index 0a30394..86844e1 100644
--- a/src/dawn/utils/TextureUtils.cpp
+++ b/src/dawn/utils/TextureUtils.cpp
@@ -15,7 +15,7 @@
#include "dawn/utils/TextureUtils.h"
namespace dawn::utils {
-bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format) {
+bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format, bool isCompatibilityMode) {
switch (format) {
case wgpu::TextureFormat::R32Uint:
case wgpu::TextureFormat::R32Sint:
@@ -24,9 +24,6 @@
case wgpu::TextureFormat::RGBA8Snorm:
case wgpu::TextureFormat::RGBA8Uint:
case wgpu::TextureFormat::RGBA8Sint:
- case wgpu::TextureFormat::RG32Uint:
- case wgpu::TextureFormat::RG32Sint:
- case wgpu::TextureFormat::RG32Float:
case wgpu::TextureFormat::RGBA16Uint:
case wgpu::TextureFormat::RGBA16Sint:
case wgpu::TextureFormat::RGBA16Float:
@@ -34,6 +31,11 @@
case wgpu::TextureFormat::RGBA32Sint:
case wgpu::TextureFormat::RGBA32Float:
return true;
+ // TODO(crbug.com/dawn/595): 32-bit RG* formats are unsupported on OpenGL ES.
+ case wgpu::TextureFormat::RG32Uint:
+ case wgpu::TextureFormat::RG32Sint:
+ case wgpu::TextureFormat::RG32Float:
+ return !isCompatibilityMode;
default:
return false;
diff --git a/src/dawn/utils/TextureUtils.h b/src/dawn/utils/TextureUtils.h
index 79cce30..a009050 100644
--- a/src/dawn/utils/TextureUtils.h
+++ b/src/dawn/utils/TextureUtils.h
@@ -220,7 +220,7 @@
wgpu::TextureFormat::Depth32FloatStencil8,
};
-bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format);
+bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format, bool isCompatibilityMode);
bool IsBCTextureFormat(wgpu::TextureFormat textureFormat);
bool IsETC2TextureFormat(wgpu::TextureFormat textureFormat);