diff --git a/docs/dawn/features/flexible_texture_views.md b/docs/dawn/features/flexible_texture_views.md new file mode 100644 index 0000000000..262f965575 --- /dev/null +++ b/docs/dawn/features/flexible_texture_views.md @@ -0,0 +1,7 @@ +# Flexible Texture Views +In Compat Mode, a texture by default: +- Must be created with texture view dimension specified. +- Cannot use different views in the same draw call. +- Cannot create a 2D view of a 2DArray texture. + +The `FlexibleTextureViews` feature removes the above restrictions. diff --git a/src/dawn/dawn.json b/src/dawn/dawn.json index c22573073f..0a6428b8d8 100644 --- a/src/dawn/dawn.json +++ b/src/dawn/dawn.json @@ -2523,7 +2523,8 @@ {"value": 52, "name": "dawn partial load resolve texture", "tags": ["dawn"]}, {"value": 53, "name": "multi draw indirect", "tags": ["dawn"]}, {"value": 54, "name": "clip distances", "tags": ["dawn"]}, - {"value": 55, "name": "dawn texel copy buffer row alignment", "tags": ["dawn"]} + {"value": 55, "name": "dawn texel copy buffer row alignment", "tags": ["dawn"]}, + {"value": 56, "name": "flexible texture views", "tags": ["dawn"]} ] }, "filter mode": { diff --git a/src/dawn/native/BindGroup.cpp b/src/dawn/native/BindGroup.cpp index 9a0eade0a0..c7af938245 100644 --- a/src/dawn/native/BindGroup.cpp +++ b/src/dawn/native/BindGroup.cpp @@ -223,7 +223,7 @@ MaybeError ValidateSampledTextureBinding(DeviceBase* device, "Dimension (%s) of %s doesn't match the expected dimension (%s).", entry.textureView->GetDimension(), entry.textureView, layout.viewDimension); - if (device->IsCompatibilityMode()) { + if (!device->HasFlexibleTextureViews()) { DAWN_INVALID_IF( view->GetDimension() != texture->GetCompatibilityTextureBindingViewDimension(), "Dimension (%s) of %s must match textureBindingViewDimension (%s) of " @@ -261,7 +261,7 @@ MaybeError ValidateStorageTextureBinding(DeviceBase* device, DAWN_INVALID_IF(view->GetLevelCount() != 1, "mipLevelCount (%u) of %s expected to be 1.", view->GetLevelCount(), view); - if (device->IsCompatibilityMode()) { + if (!device->HasFlexibleTextureViews()) { DAWN_TRY(ValidateCompatibilityModeTextureViewArrayLayer(device, view, texture)); } diff --git a/src/dawn/native/BlitBufferToDepthStencil.cpp b/src/dawn/native/BlitBufferToDepthStencil.cpp index 62924a012c..c676c26384 100644 --- a/src/dawn/native/BlitBufferToDepthStencil.cpp +++ b/src/dawn/native/BlitBufferToDepthStencil.cpp @@ -370,7 +370,7 @@ MaybeError BlitR8ToStencil(DeviceBase* device, // In compat mode view dimension needs to match texture binding view dimension. wgpu::TextureViewDimension textureViewDimension; - if (device->IsCompatibilityMode()) { + if (!device->HasFlexibleTextureViews()) { textureViewDimension = dataTexture->GetCompatibilityTextureBindingViewDimension(); } else { textureViewDimension = wgpu::TextureViewDimension::e2DArray; diff --git a/src/dawn/native/BlitTextureToBuffer.cpp b/src/dawn/native/BlitTextureToBuffer.cpp index a29cd2b513..cdc7dde8b3 100644 --- a/src/dawn/native/BlitTextureToBuffer.cpp +++ b/src/dawn/native/BlitTextureToBuffer.cpp @@ -962,7 +962,7 @@ MaybeError BlitTextureToBuffer(DeviceBase* device, const Extent3D& copyExtent) { wgpu::TextureViewDimension textureViewDimension; { - if (device->IsCompatibilityMode()) { + if (!device->HasFlexibleTextureViews()) { textureViewDimension = src.texture->GetCompatibilityTextureBindingViewDimension(); } else { wgpu::TextureDimension dimension = src.texture->GetDimension(); diff --git a/src/dawn/native/ComputePassEncoder.cpp b/src/dawn/native/ComputePassEncoder.cpp index 8f5e8541e6..1e023fc8d3 100644 --- a/src/dawn/native/ComputePassEncoder.cpp +++ b/src/dawn/native/ComputePassEncoder.cpp @@ -240,7 +240,7 @@ void ComputePassEncoder::APIDispatchWorkgroups(uint32_t workgroupCountX, DAWN_INCREASE_LIMIT_MESSAGE(GetDevice()->GetAdapter(), maxComputeWorkgroupsPerDimension, workgroupCountZ)); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } } @@ -374,7 +374,7 @@ void ComputePassEncoder::APIDispatchWorkgroupsIndirect(BufferBase* indirectBuffe "size (%u).", indirectOffset, kDispatchIndirectSize, indirectBuffer->GetSize()); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } } diff --git a/src/dawn/native/Device.cpp b/src/dawn/native/Device.cpp index eb1089b02f..316b6b1c71 100644 --- a/src/dawn/native/Device.cpp +++ b/src/dawn/native/Device.cpp @@ -1788,6 +1788,8 @@ void DeviceBase::ApplyFeatures(const UnpackedPtr& deviceDescri for (uint32_t i = 0; i < deviceDescriptor->requiredFeatureCount; ++i) { mEnabledFeatures.EnableFeature(deviceDescriptor->requiredFeatures[i]); } + + // TODO(384921944): Enable Compat's optional features by default in Core Mode. } bool DeviceBase::HasFeature(Feature feature) const { @@ -2592,6 +2594,12 @@ ResultOrError> DeviceBase::GetOrCreateTemporaryUniformBuffer(siz return mTemporaryUniformBuffer; } +bool DeviceBase::HasFlexibleTextureViews() const { + // TODO(384921944): Once FlexibleTextureViews is enabled by default in Core Mode, we only need + // to check HasFeature(FlexibleTextureViews). + return !IsCompatibilityMode() || HasFeature(Feature::FlexibleTextureViews); +} + IgnoreLazyClearCountScope::IgnoreLazyClearCountScope(DeviceBase* device) : mDevice(device), mLazyClearCountForTesting(device->mLazyClearCountForTesting) {} diff --git a/src/dawn/native/Device.h b/src/dawn/native/Device.h index d5fbb4f18d..f0275b1eab 100644 --- a/src/dawn/native/Device.h +++ b/src/dawn/native/Device.h @@ -442,6 +442,8 @@ class DeviceBase : public ErrorSink, public RefCountedWithExternalCount> GetOrCreateTemporaryUniformBuffer(size_t size); + bool HasFlexibleTextureViews() const; + protected: // Constructor used only for mocking and testing. DeviceBase(); diff --git a/src/dawn/native/Features.cpp b/src/dawn/native/Features.cpp index 68249529ff..286a6f981c 100644 --- a/src/dawn/native/Features.cpp +++ b/src/dawn/native/Features.cpp @@ -92,7 +92,8 @@ static constexpr FeatureEnumAndInfo kFeatureInfo[] = { {"Allows the STORAGE usage on textures with format \"bgra8unorm\".", "https://gpuweb.github.io/gpuweb/#bgra8unorm-storage", FeatureInfo::FeatureState::Stable}}, {Feature::Float32Filterable, - {"Allows textures with formats \"r32float\" \"rg32float\" and \"rgba32float\" to be filtered.", + {"Allows textures with formats \"r32float\" \"rg32float\" and \"rgba32float\" to be " + "filtered.", "https://gpuweb.github.io/gpuweb/#float32-filterable", FeatureInfo::FeatureState::Stable}}, {Feature::Float32Blendable, {"Allows textures with formats \"r32float\" \"rg32float\" and \"rgba32float\" to be " @@ -389,6 +390,11 @@ static constexpr FeatureEnumAndInfo kFeatureInfo[] = { {"Expose the min row alignment in buffer for texel copy operations.", "https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/" "dawn_texel_copy_buffer_row_alignment.md", + FeatureInfo::FeatureState::Stable}}, + {Feature::FlexibleTextureViews, + {"Remove the texture view restrictions in Compat Mode.", + "https://dawn.googlesource.com/dawn/+/refs/heads/main/docs/dawn/features/" + "flexible_texture_views.md", FeatureInfo::FeatureState::Stable}}}; } // anonymous namespace diff --git a/src/dawn/native/RenderEncoderBase.cpp b/src/dawn/native/RenderEncoderBase.cpp index f6f8c38ebf..3148872dd8 100644 --- a/src/dawn/native/RenderEncoderBase.cpp +++ b/src/dawn/native/RenderEncoderBase.cpp @@ -117,7 +117,7 @@ void RenderEncoderBase::APIDraw(uint32_t vertexCount, DAWN_TRY(mCommandBufferState.ValidateCanDraw()); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } @@ -164,7 +164,7 @@ void RenderEncoderBase::APIDrawIndexed(uint32_t indexCount, DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed()); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } @@ -204,7 +204,7 @@ void RenderEncoderBase::APIDrawIndirect(BufferBase* indirectBuffer, uint64_t ind DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer)); DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect)); DAWN_TRY(mCommandBufferState.ValidateCanDraw()); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } @@ -263,7 +263,7 @@ void RenderEncoderBase::APIDrawIndexedIndirect(BufferBase* indirectBuffer, DAWN_TRY(GetDevice()->ValidateObject(indirectBuffer)); DAWN_TRY(ValidateCanUseAs(indirectBuffer, wgpu::BufferUsage::Indirect)); DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed()); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } @@ -375,7 +375,7 @@ void RenderEncoderBase::APIMultiDrawIndirect(BufferBase* indirectBuffer, DAWN_TRY(mCommandBufferState.ValidateCanDraw()); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } } @@ -481,7 +481,7 @@ void RenderEncoderBase::APIMultiDrawIndexedIndirect(BufferBase* indirectBuffer, DAWN_TRY(mCommandBufferState.ValidateCanDrawIndexed()); - if (GetDevice()->IsCompatibilityMode()) { + if (!GetDevice()->HasFlexibleTextureViews()) { DAWN_TRY(mCommandBufferState.ValidateNoDifferentTextureViewsOnSameTexture()); } } diff --git a/src/dawn/native/Texture.cpp b/src/dawn/native/Texture.cpp index 9383ec595a..8c65bc5670 100644 --- a/src/dawn/native/Texture.cpp +++ b/src/dawn/native/Texture.cpp @@ -572,7 +572,7 @@ wgpu::TextureViewDimension ResolveDefaultCompatiblityTextureBindingViewDimension const UnpackedPtr& descriptor) { // In non-compatibility mode this value is not used so return undefined so that it is not // used by mistake. - if (!device->IsCompatibilityMode()) { + if (device->HasFlexibleTextureViews()) { return wgpu::TextureViewDimension::Undefined; } @@ -691,7 +691,7 @@ MaybeError ValidateTextureDescriptor( DAWN_TRY(ValidateTextureUsage(device, descriptor->dimension, usage, format, std::move(allowedSharedTextureMemoryUsage))); DAWN_TRY(ValidateTextureDimension(descriptor->dimension)); - if (device->IsCompatibilityMode()) { + if (!device->HasFlexibleTextureViews()) { const auto textureBindingViewDimension = ResolveDefaultCompatiblityTextureBindingViewDimension(device, descriptor); DAWN_TRY_CONTEXT(ValidateTextureViewDimension(textureBindingViewDimension), diff --git a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp index 67a5733465..2292e92ebe 100644 --- a/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp +++ b/src/dawn/native/d3d11/PhysicalDeviceD3D11.cpp @@ -190,6 +190,7 @@ void PhysicalDevice::InitializeSupportedFeaturesImpl() { } EnableFeature(Feature::DawnTexelCopyBufferRowAlignment); + EnableFeature(Feature::FlexibleTextureViews); } MaybeError PhysicalDevice::InitializeSupportedLimitsImpl(CombinedLimits* limits) { diff --git a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp index 2335340db4..18228c486a 100644 --- a/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp +++ b/src/dawn/native/d3d12/PhysicalDeviceD3D12.cpp @@ -148,6 +148,7 @@ void PhysicalDevice::InitializeSupportedFeaturesImpl() { EnableFeature(Feature::StaticSamplers); EnableFeature(Feature::MultiDrawIndirect); EnableFeature(Feature::ClipDistances); + EnableFeature(Feature::FlexibleTextureViews); if (AreTimestampQueriesSupported()) { EnableFeature(Feature::TimestampQuery); diff --git a/src/dawn/native/metal/PhysicalDeviceMTL.mm b/src/dawn/native/metal/PhysicalDeviceMTL.mm index 0e96769092..7d970a4fc9 100644 --- a/src/dawn/native/metal/PhysicalDeviceMTL.mm +++ b/src/dawn/native/metal/PhysicalDeviceMTL.mm @@ -740,6 +740,7 @@ bool IsGPUCounterSupported(id device, EnableFeature(Feature::DawnLoadResolveTexture); EnableFeature(Feature::ClipDistances); EnableFeature(Feature::Float32Blendable); + EnableFeature(Feature::FlexibleTextureViews); // SIMD-scoped permute operations is supported by GPU family Metal3, Apple6, Apple7, Apple8, // and Mac2. diff --git a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp index 972df71f4e..274678eff8 100644 --- a/src/dawn/native/vulkan/PhysicalDeviceVk.cpp +++ b/src/dawn/native/vulkan/PhysicalDeviceVk.cpp @@ -213,6 +213,7 @@ MaybeError PhysicalDevice::InitializeImpl() { void PhysicalDevice::InitializeSupportedFeaturesImpl() { EnableFeature(Feature::AdapterPropertiesMemoryHeaps); EnableFeature(Feature::StaticSamplers); + EnableFeature(Feature::FlexibleTextureViews); // Initialize supported extensions if (mDeviceInfo.features.textureCompressionBC == VK_TRUE) { diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp index 56189d22da..2eb80daac1 100644 --- a/src/dawn/node/binding/Converter.cpp +++ b/src/dawn/node/binding/Converter.cpp @@ -1618,6 +1618,7 @@ bool Converter::Convert(interop::GPUFeatureName& out, wgpu::FeatureName in) { case wgpu::FeatureName::DawnLoadResolveTexture: case wgpu::FeatureName::DawnPartialLoadResolveTexture: case wgpu::FeatureName::DawnTexelCopyBufferRowAlignment: + case wgpu::FeatureName::FlexibleTextureViews: return false; } return false; diff --git a/src/dawn/tests/end2end/CopyTests.cpp b/src/dawn/tests/end2end/CopyTests.cpp index 7f4e1cd104..e4e822a8c1 100644 --- a/src/dawn/tests/end2end/CopyTests.cpp +++ b/src/dawn/tests/end2end/CopyTests.cpp @@ -268,10 +268,14 @@ class CopyTests_T2B : public CopyTests, public DawnTestWithParams GetRequiredFeatures() override { - if (!SupportsFeatures({wgpu::FeatureName::DawnTexelCopyBufferRowAlignment})) { - return {}; + std::vector requiredFeatures = {}; + if (SupportsFeatures({wgpu::FeatureName::FlexibleTextureViews})) { + requiredFeatures.push_back(wgpu::FeatureName::FlexibleTextureViews); } - return {wgpu::FeatureName::DawnTexelCopyBufferRowAlignment}; + if (SupportsFeatures({wgpu::FeatureName::DawnTexelCopyBufferRowAlignment})) { + requiredFeatures.push_back(wgpu::FeatureName::DawnTexelCopyBufferRowAlignment); + } + return requiredFeatures; } void SetUp() override { @@ -1930,6 +1934,7 @@ TEST_P(CopyTests_T2B_Compat, TextureCubeRegionNonzeroRowsPerImage) { DAWN_INSTANTIATE_TEST_P(CopyTests_T2B_Compat, { + D3D11Backend(), OpenGLBackend(), OpenGLESBackend(), }, diff --git a/src/dawn/tests/end2end/DepthBiasTests.cpp b/src/dawn/tests/end2end/DepthBiasTests.cpp index 8bbe56ce00..519e27c56b 100644 --- a/src/dawn/tests/end2end/DepthBiasTests.cpp +++ b/src/dawn/tests/end2end/DepthBiasTests.cpp @@ -183,10 +183,6 @@ TEST_P(DepthBiasTests, PositiveBiasOnFloat) { // Test adding positive bias to output with a clamp TEST_P(DepthBiasTests, PositiveBiasOnFloatWithClamp) { - // Clamping support in OpenGL is spotty - DAWN_TEST_UNSUPPORTED_IF(IsOpenGL()); - DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES()); - // Depth bias clamp is not supported in compat mode. // https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md#9-depth-bias-clamp-must-be-zero DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); @@ -225,10 +221,6 @@ TEST_P(DepthBiasTests, NegativeBiasOnFloat) { // Test adding negative bias to output with a clamp TEST_P(DepthBiasTests, NegativeBiasOnFloatWithClamp) { - // Clamping support in OpenGL is spotty - DAWN_TEST_UNSUPPORTED_IF(IsOpenGL()); - DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES()); - // Depth bias clamp is not supported in compat mode. // https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md#9-depth-bias-clamp-must-be-zero DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); @@ -348,10 +340,6 @@ TEST_P(DepthBiasTests, PositiveBiasOn24bit) { // Test adding positive bias to output with a clamp TEST_P(DepthBiasTests, PositiveBiasOn24bitWithClamp) { - // Clamping support in OpenGL is spotty - DAWN_TEST_UNSUPPORTED_IF(IsOpenGL()); - DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES()); - // Depth bias clamp is not supported in compat mode. // https://github.com/gpuweb/gpuweb/blob/main/proposals/compatibility-mode.md#9-depth-bias-clamp-must-be-zero DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); diff --git a/src/dawn/tests/end2end/TextureViewTests.cpp b/src/dawn/tests/end2end/TextureViewTests.cpp index 7b3878a9b8..178a3cf155 100644 --- a/src/dawn/tests/end2end/TextureViewTests.cpp +++ b/src/dawn/tests/end2end/TextureViewTests.cpp @@ -47,6 +47,19 @@ constexpr uint32_t kBytesPerTexel = 4; class TextureViewTestBase : public DawnTest { protected: + std::vector GetRequiredFeatures() override { + std::vector requiredFeatures = {}; + if (SupportsFeatures({wgpu::FeatureName::FlexibleTextureViews})) { + requiredFeatures.push_back(wgpu::FeatureName::FlexibleTextureViews); + } + return requiredFeatures; + } + + bool HasFlexibleTextureViews() { + return !IsCompatibilityMode() || + SupportsFeatures({wgpu::FeatureName::FlexibleTextureViews}); + } + wgpu::Texture Create2DTexture(uint32_t width, uint32_t height, uint32_t arrayLayerCount, @@ -67,7 +80,7 @@ class TextureViewTestBase : public DawnTest { // Only set the textureBindingViewDimension in compat mode. It's not needed // nor used in non-compat. wgpu::TextureBindingViewDimensionDescriptor textureBindingViewDimensionDesc; - if (IsCompatibilityMode()) { + if (!HasFlexibleTextureViews()) { textureBindingViewDimensionDesc.textureBindingViewDimension = textureBindingViewDimension; descriptor.nextInChain = &textureBindingViewDimensionDesc; @@ -485,13 +498,13 @@ TEST_P(TextureViewSamplingTest, CubeArrayTextureSignedNegativeIndex) { // Test sampling from a 2D texture view created on a 2D array texture. TEST_P(TextureViewSamplingTest, Texture2DViewOn2DArrayTexture) { - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); + DAWN_TEST_UNSUPPORTED_IF(!HasFlexibleTextureViews()); Texture2DViewTest(6, 1, 4, 0); } // Test sampling from a 2D array texture view created on a 2D array texture. TEST_P(TextureViewSamplingTest, Texture2DArrayViewOn2DArrayTexture) { - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); + DAWN_TEST_UNSUPPORTED_IF(!HasFlexibleTextureViews()); Texture2DArrayViewTest(6, 1, 2, 0); } @@ -531,13 +544,13 @@ TEST_P(TextureViewSamplingTest, Texture2DViewOnOneLevelOf2DTexture) { // Test sampling from a 2D texture view created on a mipmap level of a 2D array texture layer. TEST_P(TextureViewSamplingTest, Texture2DViewOnOneLevelOf2DArrayTexture) { - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); + DAWN_TEST_UNSUPPORTED_IF(!HasFlexibleTextureViews()); Texture2DViewTest(6, 6, 3, 4); } // Test sampling from a 2D array texture view created on a mipmap level of a 2D array texture. TEST_P(TextureViewSamplingTest, Texture2DArrayViewOnOneLevelOf2DArrayTexture) { - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); + DAWN_TEST_UNSUPPORTED_IF(!HasFlexibleTextureViews()); Texture2DArrayViewTest(6, 6, 2, 4); } @@ -641,7 +654,7 @@ TEST_P(TextureViewSamplingTest, TextureCubeMapOnWholeTexture) { // Test sampling from a cube map texture view that covers a sub part of a 2D array texture. TEST_P(TextureViewSamplingTest, TextureCubeMapViewOnPartOfTexture) { - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); + DAWN_TEST_UNSUPPORTED_IF(!HasFlexibleTextureViews()); // TODO(dawn:1935): Total layers have to be at least 12 on Intel D3D11 Gen12. DAWN_SUPPRESS_TEST_IF(IsD3D11() && IsIntelGen12()); @@ -650,7 +663,7 @@ TEST_P(TextureViewSamplingTest, TextureCubeMapViewOnPartOfTexture) { // Test sampling from a cube map texture view that covers the last layer of a 2D array texture. TEST_P(TextureViewSamplingTest, TextureCubeMapViewCoveringLastLayer) { - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); + DAWN_TEST_UNSUPPORTED_IF(!HasFlexibleTextureViews()); // TODO(dawn:1812): the test fails with DXGI_ERROR_DEVICE_HUNG on Intel D3D11 driver. DAWN_SUPPRESS_TEST_IF(IsD3D11() && IsIntel()); diff --git a/src/dawn/tests/end2end/VideoViewsTests.cpp b/src/dawn/tests/end2end/VideoViewsTests.cpp index e3bd954339..27bdcf1008 100644 --- a/src/dawn/tests/end2end/VideoViewsTests.cpp +++ b/src/dawn/tests/end2end/VideoViewsTests.cpp @@ -58,6 +58,12 @@ void VideoViewsTestsBase::SetUp() { DAWN_TEST_UNSUPPORTED_IF(!IsMultiPlanarFormatsSupported()); // TODO(crbug.com/342213634): Crashes on ChromeOS volteer devices. DAWN_SUPPRESS_TEST_IF(IsChromeOS() && IsVulkan() && IsIntel() && IsBackendValidationEnabled()); + + // compat mode doesn't allow different texture views to be used in a draw call unless + // FlexibleTextureViews feature is enabled. The tests need texture views to sample and render to + // separate planes of a multiplanar texture. + DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode() && + !SupportsFeatures({wgpu::FeatureName::FlexibleTextureViews})); } std::vector VideoViewsTestsBase::GetRequiredFeatures() { @@ -128,6 +134,10 @@ std::vector VideoViewsTestsBase::GetRequiredFeatures() { if (mIsSnorm16TextureFormatsSupported) { requiredFeatures.push_back(wgpu::FeatureName::Snorm16TextureFormats); } + if (SupportsFeatures({wgpu::FeatureName::FlexibleTextureViews})) { + requiredFeatures.push_back(wgpu::FeatureName::FlexibleTextureViews); + } + requiredFeatures.push_back(wgpu::FeatureName::DawnInternalUsages); return requiredFeatures; } @@ -524,10 +534,6 @@ class VideoViewsTests : public VideoViewsTestsBase { DAWN_TEST_UNSUPPORTED_IF(UsesWire()); DAWN_TEST_UNSUPPORTED_IF(!IsMultiPlanarFormatsSupported()); DAWN_TEST_UNSUPPORTED_IF(!IsFormatSupported()); - // TODO(382071071): compat mode doesn't allow different texture views to be used in - // a draw call. But the tests need texture views to sample and render to separate planes of - // a multiplanar texture. - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode()); mBackend = VideoViewsTestBackend::Create(); mBackend->OnSetUp(device); diff --git a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp index 72085f1cbc..bad5ffdf3b 100644 --- a/src/dawn/tests/unittests/validation/CompatValidationTests.cpp +++ b/src/dawn/tests/unittests/validation/CompatValidationTests.cpp @@ -27,6 +27,7 @@ #include #include +#include #include #include @@ -758,9 +759,54 @@ void TestMultipleTextureViewValidationInRenderPass( texture.Destroy(); } +enum FlexibleTextureViewsFeature { + Enabled, + Disabled, +}; + +class CompatTextureViewValidationTests + : public CompatValidationTest, + public ::testing::WithParamInterface { + public: + static std::string PrintToStringParamName( + const testing::TestParamInfo& info) { + std::ostringstream ss; + ss << "WithFlexibleTextureViews"; + if (info.param == FlexibleTextureViewsFeature::Enabled) { + ss << "Enabled"; + } else { + ss << "Disabled"; + } + + return ss.str(); + } + + protected: + std::vector GetRequiredFeatures() override { + if (HasFlexibleTextureViews()) { + return {wgpu::FeatureName::FlexibleTextureViews}; + } + + return {}; + } + + bool HasFlexibleTextureViews() const { + return GetParam() == FlexibleTextureViewsFeature::Enabled; + } +}; + +#define ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(statement, matcher) \ + do { \ + if (HasFlexibleTextureViews()) { \ + statement; \ + } else { \ + ASSERT_DEVICE_ERROR(statement, matcher); \ + } \ + } while (0) + // Test we get a validation error if we have 2 different views of a texture -// in the same bind group. -TEST_F(CompatValidationTest, CanNotDrawDifferentMipsSameTextureSameBindGroup) { +// in the same bind group. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewValidationTests, CanNotDrawDifferentMipsSameTextureSameBindGroup) { TestMultipleTextureViewValidationInRenderPass( device, kRenderTwoTexturesOneBindgroupWGSL, [this](wgpu::Device device, wgpu::Texture texture, wgpu::RenderPipeline pipeline, @@ -788,13 +834,14 @@ TEST_F(CompatValidationTest, CanNotDrawDifferentMipsSameTextureSameBindGroup) { drawFn(pass); pass.End(); - ASSERT_DEVICE_ERROR(encoder.Finish(), testing::HasSubstr("different views")); + ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(encoder.Finish(), + testing::HasSubstr("different views")); }); } // Test we get a validation error if we have 2 different views of a texture spanning -// different bind groups. -TEST_F(CompatValidationTest, CanNotDrawDifferentMipsSameTextureDifferentBindGroups) { +// different bind groups. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewValidationTests, CanNotDrawDifferentMipsSameTextureDifferentBindGroups) { TestMultipleTextureViewValidationInRenderPass( device, kRenderTwoTexturesTwoBindgroupsWGSL, [this](wgpu::Device device, wgpu::Texture texture, wgpu::RenderPipeline pipeline, @@ -825,7 +872,8 @@ TEST_F(CompatValidationTest, CanNotDrawDifferentMipsSameTextureDifferentBindGrou drawFn(pass); pass.End(); - ASSERT_DEVICE_ERROR(encoder.Finish(), testing::HasSubstr("different views")); + ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(encoder.Finish(), + testing::HasSubstr("different views")); }); } @@ -833,7 +881,8 @@ TEST_F(CompatValidationTest, CanNotDrawDifferentMipsSameTextureDifferentBindGrou // which would be an error if you issued a draw command but, you then fix the issue by replacing // the bindgroup with one that does not have multiple views. We're trying to test // that the implementation does the validation at draw command time and not before. -TEST_F(CompatValidationTest, CanBindDifferentMipsSameTextureSameBindGroupAndFixWithoutError) { +TEST_P(CompatTextureViewValidationTests, + CanBindDifferentMipsSameTextureSameBindGroupAndFixWithoutError) { TestMultipleTextureViewValidationInRenderPass( device, kRenderTwoTexturesOneBindgroupWGSL, [](wgpu::Device device, wgpu::Texture texture, wgpu::RenderPipeline pipeline, @@ -875,7 +924,7 @@ TEST_F(CompatValidationTest, CanBindDifferentMipsSameTextureSameBindGroupAndFixW // Test that having 2 texture views that have the same settings, in 2 different // bindgroups, does not generate a validation error. -TEST_F(CompatValidationTest, CanBindSameViewIn2BindGroups) { +TEST_P(CompatTextureViewValidationTests, CanBindSameViewIn2BindGroups) { TestMultipleTextureViewValidationInRenderPass( device, kRenderTwoTexturesTwoBindgroupsWGSL, [](wgpu::Device device, wgpu::Texture texture, wgpu::RenderPipeline pipeline, @@ -910,7 +959,7 @@ TEST_F(CompatValidationTest, CanBindSameViewIn2BindGroups) { // Test that no validation error happens if we have multiple views of a texture // but don't draw. -TEST_F(CompatValidationTest, NoErrorIfMultipleDifferentViewsOfTextureAreNotUsed) { +TEST_P(CompatTextureViewValidationTests, NoErrorIfMultipleDifferentViewsOfTextureAreNotUsed) { TestMultipleTextureViewValidationInRenderPass( device, kRenderTwoTexturesTwoBindgroupsWGSL, [](wgpu::Device device, wgpu::Texture texture, wgpu::RenderPipeline pipeline, @@ -1006,8 +1055,8 @@ void TestMultipleTextureViewValidationInComputePass( } // Test we get a validation error if we have 2 different views of a texture -// in the same bind group. -TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameTextureSameBindGroup) { +// in the same bind group. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewValidationTests, CanNotComputeWithDifferentMipsSameTextureSameBindGroup) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoTexturesOneBindgroupWGSL, wgpu::TextureUsage::TextureBinding, [this](wgpu::Device device, wgpu::Texture texture, wgpu::ComputePipeline pipeline, @@ -1034,13 +1083,15 @@ TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameTextureSameBindGr dispatchFn(pass); pass.End(); - ASSERT_DEVICE_ERROR(encoder.Finish(), testing::HasSubstr("different views")); + ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(encoder.Finish(), + testing::HasSubstr("different views")); }); } // Test we get a validation error if we have 2 different views of a texture spanning -// different bind groups. -TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameTextureDifferentBindGroups) { +// different bind groups. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewValidationTests, + CanNotComputeWithDifferentMipsSameTextureDifferentBindGroups) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoTexturesTwoBindgroupsWGSL, wgpu::TextureUsage::TextureBinding, [this](wgpu::Device device, wgpu::Texture texture, wgpu::ComputePipeline pipeline, @@ -1070,7 +1121,8 @@ TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameTextureDifferentB dispatchFn(pass); pass.End(); - ASSERT_DEVICE_ERROR(encoder.Finish(), testing::HasSubstr("different views")); + ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(encoder.Finish(), + testing::HasSubstr("different views")); }); } @@ -1078,7 +1130,7 @@ TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameTextureDifferentB // which would be an error if you issued a draw command but, you then fix the issue by replacing // the bindgroup with one that does not have multiple views. We're trying to test // that the implementation does the validation at draw command time and not before. -TEST_F(CompatValidationTest, +TEST_P(CompatTextureViewValidationTests, CanBindDifferentMipsSameTextureSameBindGroupAndFixWithoutErrorInComputePass) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoTexturesOneBindgroupWGSL, wgpu::TextureUsage::TextureBinding, @@ -1120,7 +1172,7 @@ TEST_F(CompatValidationTest, // Test that having 2 texture views that have the same settings, in 2 different // bindgroups, does not generate a validation error. -TEST_F(CompatValidationTest, CanBindSameViewIn2BindGroupsInComputePass) { +TEST_P(CompatTextureViewValidationTests, CanBindSameViewIn2BindGroupsInComputePass) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoTexturesTwoBindgroupsWGSL, wgpu::TextureUsage::TextureBinding, [](wgpu::Device device, wgpu::Texture texture, wgpu::ComputePipeline pipeline, @@ -1154,7 +1206,8 @@ TEST_F(CompatValidationTest, CanBindSameViewIn2BindGroupsInComputePass) { // Test that no validation error happens if we have multiple views of a texture // but don't draw. -TEST_F(CompatValidationTest, NoErrorIfMultipleDifferentViewsOfTextureAreNotUsedInComputePass) { +TEST_P(CompatTextureViewValidationTests, + NoErrorIfMultipleDifferentViewsOfTextureAreNotUsedInComputePass) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoTexturesTwoBindgroupsWGSL, wgpu::TextureUsage::TextureBinding, [](wgpu::Device device, wgpu::Texture texture, wgpu::ComputePipeline pipeline, @@ -1211,8 +1264,9 @@ constexpr const char* kComputeTwoStorageTexturesTwoBindgroupsWGSL = R"( )"; // Test we get a validation error if we have 2 different views of a storage texture -// in the same bind group. -TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameStorageTextureSameBindGroup) { +// in the same bind group. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewValidationTests, + CanNotComputeWithDifferentMipsSameStorageTextureSameBindGroup) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoStorageTexturesOneBindgroupWGSL, wgpu::TextureUsage::StorageBinding, [this](wgpu::Device device, wgpu::Texture texture, wgpu::ComputePipeline pipeline, @@ -1239,13 +1293,15 @@ TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameStorageTextureSam dispatchFn(pass); pass.End(); - ASSERT_DEVICE_ERROR(encoder.Finish(), testing::HasSubstr("different views")); + ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(encoder.Finish(), + testing::HasSubstr("different views")); }); } // Test we get a validation error if we have 2 different views of a texture spanning -// different bind groups. -TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameStorageTextureDifferentBindGroups) { +// different bind groups. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewValidationTests, + CanNotComputeWithDifferentMipsSameStorageTextureDifferentBindGroups) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoStorageTexturesTwoBindgroupsWGSL, wgpu::TextureUsage::StorageBinding, [this](wgpu::Device device, wgpu::Texture texture, wgpu::ComputePipeline pipeline, @@ -1275,7 +1331,8 @@ TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameStorageTextureDif dispatchFn(pass); pass.End(); - ASSERT_DEVICE_ERROR(encoder.Finish(), testing::HasSubstr("different views")); + ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(encoder.Finish(), + testing::HasSubstr("different views")); }); } @@ -1283,7 +1340,7 @@ TEST_F(CompatValidationTest, CanNotComputeWithDifferentMipsSameStorageTextureDif // which would be an error if you issued a draw command but, you then fix the issue by replacing // the bindgroup with one that does not have multiple views. We're trying to test // that the implementation does the validation at draw command time and not before. -TEST_F(CompatValidationTest, +TEST_P(CompatTextureViewValidationTests, CanBindDifferentMipsSameStorageTextureSameBindGroupAndFixWithoutErrorInComputePass) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoStorageTexturesOneBindgroupWGSL, wgpu::TextureUsage::StorageBinding, @@ -1333,7 +1390,7 @@ TEST_F(CompatValidationTest, // Test that no validation error happens if we have multiple views of a texture // but don't draw. -TEST_F(CompatValidationTest, +TEST_P(CompatTextureViewValidationTests, NoErrorIfMultipleDifferentViewsOfStorageTextureAreNotUsedInComputePass) { TestMultipleTextureViewValidationInComputePass( device, kComputeTwoStorageTexturesTwoBindgroupsWGSL, wgpu::TextureUsage::StorageBinding, @@ -1424,7 +1481,8 @@ TEST_F(CompatValidationTest, CanNotCopyMultisampleTextureToTexture) { // Regression test for crbug.com/339704108 // Error texture should not resolve mCompatibilityTextureBindingViewDimension, // as dimension could be in bad form. -TEST_F(CompatValidationTest, DoNotResolveDefaultTextureBindingViewDimensionOnErrorTexture) { +TEST_P(CompatTextureViewValidationTests, + DoNotResolveDefaultTextureBindingViewDimensionOnErrorTexture) { // Set incompatible texture format and view format. // This validation happens before texture dimension validation and binding view dimension // resolving and shall return an error texture. @@ -1445,7 +1503,7 @@ TEST_F(CompatValidationTest, DoNotResolveDefaultTextureBindingViewDimensionOnErr // Regression test for crbug.com/341167195 // Resolved default compatibility textureBindingViewDimension should be validated as it may come // from the TextureBindingViewDimensionDescriptor -TEST_F(CompatValidationTest, InvalidTextureBindingViewDimensionDescriptorDescriptor) { +TEST_P(CompatTextureViewValidationTests, InvalidTextureBindingViewDimensionDescriptorDescriptor) { wgpu::TextureDescriptor descriptor; descriptor.size = {1, 1, 1}; descriptor.dimension = wgpu::TextureDimension::Undefined; @@ -1458,10 +1516,10 @@ TEST_F(CompatValidationTest, InvalidTextureBindingViewDimensionDescriptorDescrip textureBindingViewDimensionDesc.textureBindingViewDimension = static_cast(99); - ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); + ASSERT_TEXTURE_VIEW_ERROR_IF_NO_FLEXIBLE_FEATURE(device.CreateTexture(&descriptor), testing::_); } -class CompatTextureViewDimensionValidationTests : public CompatValidationTest { +class CompatTextureViewDimensionValidationTests : public CompatTextureViewValidationTests { protected: void TestBindingTextureViewDimensions( const uint32_t depth, @@ -1559,85 +1617,89 @@ const wgpu::TextureViewDimension kViewDimensions[] = { wgpu::TextureViewDimension::Cube, }; -// Test creating 1d textures with each view dimension. -TEST_F(CompatTextureViewDimensionValidationTests, E1D) { +// Test creating 1d textures with each view dimension. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, E1D) { for (auto viewDimension : kViewDimensions) { TestCreateTextureIsCompatibleWithViewDimension( 1, wgpu::TextureDimension::e1D, viewDimension, - viewDimension == wgpu::TextureViewDimension::e1D); + HasFlexibleTextureViews() || viewDimension == wgpu::TextureViewDimension::e1D); } } -// Test creating 2d textures with each view dimension. -TEST_F(CompatTextureViewDimensionValidationTests, E2D) { +// Test creating 2d textures with each view dimension. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, E2D) { for (auto viewDimension : kViewDimensions) { TestCreateTextureIsCompatibleWithViewDimension( viewDimension == wgpu::TextureViewDimension::e2D ? 1 : 6, wgpu::TextureDimension::e2D, viewDimension, - viewDimension != wgpu::TextureViewDimension::e1D && - viewDimension != wgpu::TextureViewDimension::e3D); + HasFlexibleTextureViews() || (viewDimension != wgpu::TextureViewDimension::e1D && + viewDimension != wgpu::TextureViewDimension::e3D)); } } -// Test creating 1d textures with each view dimension. -TEST_F(CompatTextureViewDimensionValidationTests, E3D) { +// Test creating 1d textures with each view dimension. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, E3D) { for (auto viewDimension : kViewDimensions) { TestCreateTextureIsCompatibleWithViewDimension( 1, wgpu::TextureDimension::e3D, viewDimension, - viewDimension == wgpu::TextureViewDimension::e3D); + HasFlexibleTextureViews() || viewDimension == wgpu::TextureViewDimension::e3D); } } -// Test creating a 2d texture with a 2d view and depthOrArrayLayers > 1 fails -TEST_F(CompatTextureViewDimensionValidationTests, E2DViewMoreThan1Layer) { - TestCreateTextureLayersIsCompatibleWithViewDimension(2, wgpu::TextureDimension::e2D, - wgpu::TextureViewDimension::e2D, false); +// Test creating a 2d texture with a 2d view and depthOrArrayLayers > 1 fails. Unless +// FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, E2DViewMoreThan1Layer) { + TestCreateTextureLayersIsCompatibleWithViewDimension( + 2, wgpu::TextureDimension::e2D, wgpu::TextureViewDimension::e2D, HasFlexibleTextureViews()); } -// Test creating a 2d texture with a cube view with depthOrArrayLayers != 6 fails -TEST_F(CompatTextureViewDimensionValidationTests, CubeViewMoreWhereLayersIsNot6) { +// Test creating a 2d texture with a cube view with depthOrArrayLayers != 6 fails. Unless +// FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, CubeViewMoreWhereLayersIsNot6) { uint32_t layers[] = {1, 5, 6, 7, 12}; for (auto numLayers : layers) { - TestCreateTextureLayersIsCompatibleWithViewDimension(numLayers, wgpu::TextureDimension::e2D, - wgpu::TextureViewDimension::Cube, - numLayers == 6); + TestCreateTextureLayersIsCompatibleWithViewDimension( + numLayers, wgpu::TextureDimension::e2D, wgpu::TextureViewDimension::Cube, + HasFlexibleTextureViews() || numLayers == 6); } } -TEST_F(CompatTextureViewDimensionValidationTests, OneLayerIs2DView) { +TEST_P(CompatTextureViewDimensionValidationTests, OneLayerIs2DView) { TestBindingTextureViewDimensions(1, wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::e2D, true); } // Test 2 layer texture gets a 2d-array viewDimension -TEST_F(CompatTextureViewDimensionValidationTests, TwoLayersIs2DArrayView) { +TEST_P(CompatTextureViewDimensionValidationTests, TwoLayersIs2DArrayView) { TestBindingTextureViewDimensions(2, wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::e2DArray, true); } // Test 6 layer texture gets a 2d-array viewDimension -TEST_F(CompatTextureViewDimensionValidationTests, SixLayersIs2DArrayView) { +TEST_P(CompatTextureViewDimensionValidationTests, SixLayersIs2DArrayView) { TestBindingTextureViewDimensions(6, wgpu::TextureViewDimension::Undefined, wgpu::TextureViewDimension::e2DArray, true); } -// Test 2d texture can not be viewed as 2D array -TEST_F(CompatTextureViewDimensionValidationTests, TwoDTextureViewDimensionCanNotBeViewedAs2DArray) { +// Test 2d texture can not be viewed as 2D array. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, TwoDTextureViewDimensionCanNotBeViewedAs2DArray) { TestBindingTextureViewDimensions(1, wgpu::TextureViewDimension::e2D, - wgpu::TextureViewDimension::e2DArray, false); + wgpu::TextureViewDimension::e2DArray, + HasFlexibleTextureViews()); } -// Test 2d-array texture can not be viewed as cube -TEST_F(CompatTextureViewDimensionValidationTests, +// Test 2d-array texture can not be viewed as cube. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, TwoDArrayTextureViewDimensionCanNotBeViewedAsCube) { TestBindingTextureViewDimensions(6, wgpu::TextureViewDimension::e2DArray, - wgpu::TextureViewDimension::Cube, false); + wgpu::TextureViewDimension::Cube, HasFlexibleTextureViews()); } -// Test cube texture can not be viewed as 2d-array -TEST_F(CompatTextureViewDimensionValidationTests, CubeTextureViewDimensionCanNotBeViewedAs2DArray) { +// Test cube texture can not be viewed as 2d-array. Unless FlexibleTextureViews is enabled. +TEST_P(CompatTextureViewDimensionValidationTests, CubeTextureViewDimensionCanNotBeViewedAs2DArray) { TestBindingTextureViewDimensions(6, wgpu::TextureViewDimension::Cube, - wgpu::TextureViewDimension::e2DArray, false); + wgpu::TextureViewDimension::e2DArray, + HasFlexibleTextureViews()); } // Test 2Darray != 2d @@ -1815,5 +1877,17 @@ TEST_F(CompatMaxVertexAttributesTest, VertexAndInstanceIndexEachTakeAnAttribute) TestMaxVertexAttributes(true, true); } +INSTANTIATE_TEST_SUITE_P(, + CompatTextureViewValidationTests, + ::testing::Values(FlexibleTextureViewsFeature::Disabled, + FlexibleTextureViewsFeature::Enabled), + CompatTextureViewValidationTests::PrintToStringParamName); + +INSTANTIATE_TEST_SUITE_P(, + CompatTextureViewDimensionValidationTests, + ::testing::Values(FlexibleTextureViewsFeature::Disabled, + FlexibleTextureViewsFeature::Enabled), + CompatTextureViewValidationTests::PrintToStringParamName); + } // anonymous namespace } // namespace dawn diff --git a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp index 070f4472dd..bd017dcc90 100644 --- a/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp +++ b/src/dawn/tests/white_box/SharedTextureMemoryTests.cpp @@ -105,6 +105,7 @@ std::vector SharedTextureMemoryTests::GetRequiredFeatures() { wgpu::FeatureName::TransientAttachments, wgpu::FeatureName::Unorm16TextureFormats, wgpu::FeatureName::BGRA8UnormStorage, + wgpu::FeatureName::FlexibleTextureViews, }; for (auto feature : kOptionalFeatures) { if (SupportsFeatures({feature})) { @@ -113,7 +114,7 @@ std::vector SharedTextureMemoryTests::GetRequiredFeatures() { } return features; -} +} // namespace dawn void SharedTextureMemoryTests::SetUp() { DAWN_TEST_UNSUPPORTED_IF(UsesWire()); @@ -124,7 +125,9 @@ void SharedTextureMemoryTests::SetUp() { DAWN_SUPPRESS_TEST_IF(IsChromeOS() && IsVulkan() && IsIntel() && IsBackendValidationEnabled()); // Compat cannot create 2D texture view from a 2D array texture. - DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode() && GetParam().mLayerCount > 1); + DAWN_TEST_UNSUPPORTED_IF(IsCompatibilityMode() && + !SupportsFeatures({wgpu::FeatureName::FlexibleTextureViews}) && + GetParam().mLayerCount > 1); GetParam().mBackend->SetUp(); } diff --git a/src/dawn/wire/SupportedFeatures.cpp b/src/dawn/wire/SupportedFeatures.cpp index 985e49747a..d7127ada7a 100644 --- a/src/dawn/wire/SupportedFeatures.cpp +++ b/src/dawn/wire/SupportedFeatures.cpp @@ -113,6 +113,7 @@ bool IsFeatureSupported(WGPUFeatureName feature) { case WGPUFeatureName_ClipDistances: case WGPUFeatureName_ChromiumExperimentalImmediateData: case WGPUFeatureName_DawnTexelCopyBufferRowAlignment: + case WGPUFeatureName_FlexibleTextureViews: return true; }