Implements float32-filterable feature.

- Adds the feature and the major backend supports.
- Adds initial validation testing.

Bug: dawn:1664
Change-Id: I9918c3de8cce379319d3d1877e45c51acb388961
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/133281
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Brandon Jones <bajones@google.com>
Commit-Queue: Loko Kung <lokokung@google.com>
This commit is contained in:
Loko Kung 2023-05-18 07:21:11 +00:00 committed by Dawn LUCI CQ
parent 8f57f3b2e8
commit 9fb0eed227
9 changed files with 198 additions and 108 deletions

View File

@ -1441,6 +1441,7 @@
{"value": 9, "name": "shader f16"}, {"value": 9, "name": "shader f16"},
{"value": 10, "name": "RG11B10 ufloat renderable"}, {"value": 10, "name": "RG11B10 ufloat renderable"},
{"value": 11, "name": "BGRA8 unorm storage"}, {"value": 11, "name": "BGRA8 unorm storage"},
{"value": 12, "name": "float32 filterable"},
{"value": 1001, "name": "dawn shader float 16", "tags": ["dawn"]}, {"value": 1001, "name": "dawn shader float 16", "tags": ["dawn"]},
{"value": 1002, "name": "dawn internal usages", "tags": ["dawn"]}, {"value": 1002, "name": "dawn internal usages", "tags": ["dawn"]},
{"value": 1003, "name": "dawn multi planar formats", "tags": ["dawn"]}, {"value": 1003, "name": "dawn multi planar formats", "tags": ["dawn"]},

View File

@ -82,6 +82,11 @@ static constexpr FeatureEnumAndInfoList kFeatureNameAndInfoList = {{
{Feature::BGRA8UnormStorage, {Feature::BGRA8UnormStorage,
{"bgra8unorm-storage", "Allows the STORAGE usage on textures with format \"bgra8unorm\".", {"bgra8unorm-storage", "Allows the STORAGE usage on textures with format \"bgra8unorm\".",
"https://bugs.chromium.org/p/dawn/issues/detail?id=1591", FeatureInfo::FeatureState::Stable}}, "https://bugs.chromium.org/p/dawn/issues/detail?id=1591", FeatureInfo::FeatureState::Stable}},
{Feature::Float32Filterable,
{"float32-filterable",
"Allows textures with formats \"r32float\" \"rg32float\" and \"rgba32float\" to be filtered.",
"https://bugs.chromium.org/p/dawn/issues/detail?id=1664",
FeatureInfo::FeatureState::Experimental}},
{Feature::DawnInternalUsages, {Feature::DawnInternalUsages,
{"dawn-internal-usages", {"dawn-internal-usages",
"Add internal usages to resources to affect how the texture is allocated, but not " "Add internal usages to resources to affect how the texture is allocated, but not "
@ -160,6 +165,8 @@ Feature FromAPIFeature(wgpu::FeatureName feature) {
return Feature::SurfaceCapabilities; return Feature::SurfaceCapabilities;
case wgpu::FeatureName::TransientAttachments: case wgpu::FeatureName::TransientAttachments:
return Feature::TransientAttachments; return Feature::TransientAttachments;
case wgpu::FeatureName::Float32Filterable:
return Feature::Float32Filterable;
} }
return Feature::InvalidEnum; return Feature::InvalidEnum;
} }
@ -204,6 +211,8 @@ wgpu::FeatureName ToAPIFeature(Feature feature) {
return wgpu::FeatureName::SurfaceCapabilities; return wgpu::FeatureName::SurfaceCapabilities;
case Feature::TransientAttachments: case Feature::TransientAttachments:
return wgpu::FeatureName::TransientAttachments; return wgpu::FeatureName::TransientAttachments;
case Feature::Float32Filterable:
return wgpu::FeatureName::Float32Filterable;
case Feature::EnumCount: case Feature::EnumCount:
break; break;

View File

@ -40,6 +40,7 @@ enum class Feature {
ShaderF16, ShaderF16,
RG11B10UfloatRenderable, RG11B10UfloatRenderable,
BGRA8UnormStorage, BGRA8UnormStorage,
Float32Filterable,
// Dawn-specific // Dawn-specific
DawnInternalUsages, DawnInternalUsages,

View File

@ -362,9 +362,10 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
AddColorFormat(wgpu::TextureFormat::RG8Sint, true, false, true, false, 2, SampleTypeBit::Sint, 2, 2, 1); AddColorFormat(wgpu::TextureFormat::RG8Sint, true, false, true, false, 2, SampleTypeBit::Sint, 2, 2, 1);
// 4 bytes color formats // 4 bytes color formats
SampleTypeBit sampleTypeFor32BitFloatFormats = device->HasFeature(Feature::Float32Filterable) ? kAnyFloat : SampleTypeBit::UnfilterableFloat;
AddColorFormat(wgpu::TextureFormat::R32Uint, true, true, false, false, 4, SampleTypeBit::Uint, 1, 4, 4); AddColorFormat(wgpu::TextureFormat::R32Uint, true, true, false, false, 4, SampleTypeBit::Uint, 1, 4, 4);
AddColorFormat(wgpu::TextureFormat::R32Sint, true, true, false, false, 4, SampleTypeBit::Sint, 1, 4, 4); AddColorFormat(wgpu::TextureFormat::R32Sint, true, true, false, false, 4, SampleTypeBit::Sint, 1, 4, 4);
AddColorFormat(wgpu::TextureFormat::R32Float, true, true, true, false, 4, SampleTypeBit::UnfilterableFloat, 1, 4, 4); AddColorFormat(wgpu::TextureFormat::R32Float, true, true, true, false, 4, sampleTypeFor32BitFloatFormats, 1, 4, 4);
AddColorFormat(wgpu::TextureFormat::RG16Uint, true, false, true, false, 4, SampleTypeBit::Uint, 2, 4, 2); AddColorFormat(wgpu::TextureFormat::RG16Uint, true, false, true, false, 4, SampleTypeBit::Uint, 2, 4, 2);
AddColorFormat(wgpu::TextureFormat::RG16Sint, true, false, true, false, 4, SampleTypeBit::Sint, 2, 4, 2); AddColorFormat(wgpu::TextureFormat::RG16Sint, true, false, true, false, 4, SampleTypeBit::Sint, 2, 4, 2);
AddColorFormat(wgpu::TextureFormat::RG16Float, true, false, true, true, 4, kAnyFloat, 2, 4, 2); AddColorFormat(wgpu::TextureFormat::RG16Float, true, false, true, true, 4, kAnyFloat, 2, 4, 2);
@ -386,7 +387,7 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
// 8 bytes color formats // 8 bytes color formats
AddColorFormat(wgpu::TextureFormat::RG32Uint, true, true, false, false, 8, SampleTypeBit::Uint, 2, 8, 4); AddColorFormat(wgpu::TextureFormat::RG32Uint, true, true, false, false, 8, SampleTypeBit::Uint, 2, 8, 4);
AddColorFormat(wgpu::TextureFormat::RG32Sint, true, true, false, false, 8, SampleTypeBit::Sint, 2, 8, 4); AddColorFormat(wgpu::TextureFormat::RG32Sint, true, true, false, false, 8, SampleTypeBit::Sint, 2, 8, 4);
AddColorFormat(wgpu::TextureFormat::RG32Float, true, true, false, false, 8, SampleTypeBit::UnfilterableFloat, 2, 8, 4); AddColorFormat(wgpu::TextureFormat::RG32Float, true, true, false, false, 8, sampleTypeFor32BitFloatFormats, 2, 8, 4);
AddColorFormat(wgpu::TextureFormat::RGBA16Uint, true, true, true, false, 8, SampleTypeBit::Uint, 4, 8, 2); AddColorFormat(wgpu::TextureFormat::RGBA16Uint, true, true, true, false, 8, SampleTypeBit::Uint, 4, 8, 2);
AddColorFormat(wgpu::TextureFormat::RGBA16Sint, true, true, true, false, 8, SampleTypeBit::Sint, 4, 8, 2); AddColorFormat(wgpu::TextureFormat::RGBA16Sint, true, true, true, false, 8, SampleTypeBit::Sint, 4, 8, 2);
AddColorFormat(wgpu::TextureFormat::RGBA16Float, true, true, true, true, 8, kAnyFloat, 4, 8, 2); AddColorFormat(wgpu::TextureFormat::RGBA16Float, true, true, true, true, 8, kAnyFloat, 4, 8, 2);
@ -394,7 +395,7 @@ FormatTable BuildFormatTable(const DeviceBase* device) {
// 16 bytes color formats // 16 bytes color formats
AddColorFormat(wgpu::TextureFormat::RGBA32Uint, true, true, false, false, 16, SampleTypeBit::Uint, 4, 16, 4); AddColorFormat(wgpu::TextureFormat::RGBA32Uint, true, true, false, false, 16, SampleTypeBit::Uint, 4, 16, 4);
AddColorFormat(wgpu::TextureFormat::RGBA32Sint, true, true, false, false, 16, SampleTypeBit::Sint, 4, 16, 4); AddColorFormat(wgpu::TextureFormat::RGBA32Sint, true, true, false, false, 16, SampleTypeBit::Sint, 4, 16, 4);
AddColorFormat(wgpu::TextureFormat::RGBA32Float, true, true, false, false, 16, SampleTypeBit::UnfilterableFloat, 4, 16, 4); AddColorFormat(wgpu::TextureFormat::RGBA32Float, true, true, false, false, 16, sampleTypeFor32BitFloatFormats, 4, 16, 4);
// Depth-stencil formats // Depth-stencil formats
AddStencilFormat(wgpu::TextureFormat::Stencil8, true); AddStencilFormat(wgpu::TextureFormat::Stencil8, true);

View File

@ -124,6 +124,7 @@ void PhysicalDevice::InitializeSupportedFeaturesImpl() {
EnableFeature(Feature::RG11B10UfloatRenderable); EnableFeature(Feature::RG11B10UfloatRenderable);
EnableFeature(Feature::DepthClipControl); EnableFeature(Feature::DepthClipControl);
EnableFeature(Feature::SurfaceCapabilities); EnableFeature(Feature::SurfaceCapabilities);
EnableFeature(Feature::Float32Filterable);
if (AreTimestampQueriesSupported()) { if (AreTimestampQueriesSupported()) {
EnableFeature(Feature::TimestampQuery); EnableFeature(Feature::TimestampQuery);

View File

@ -435,11 +435,16 @@ class PhysicalDevice : public PhysicalDeviceBase {
MaybeError InitializeImpl() override { return {}; } MaybeError InitializeImpl() override { return {}; }
void InitializeSupportedFeaturesImpl() override { void InitializeSupportedFeaturesImpl() override {
// Check compressed texture format with deprecated MTLFeatureSet way. // Check texture formats with deprecated MTLFeatureSet way.
#if DAWN_PLATFORM_IS(MACOS) #if DAWN_PLATFORM_IS(MACOS)
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
} }
if (@available(macOS 10.14, *)) {
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1]) {
EnableFeature(Feature::Float32Filterable);
}
}
#endif #endif
#if DAWN_PLATFORM_IS(IOS) #if DAWN_PLATFORM_IS(IOS)
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily1_v1]) {
@ -450,11 +455,14 @@ class PhysicalDevice : public PhysicalDeviceBase {
} }
#endif #endif
// Check compressed texture format with MTLGPUFamily // Check texture formats with MTLGPUFamily
if (@available(macOS 10.15, iOS 13.0, *)) { if (@available(macOS 10.15, iOS 13.0, *)) {
if ([*mDevice supportsFamily:MTLGPUFamilyMac1]) { if ([*mDevice supportsFamily:MTLGPUFamilyMac1]) {
EnableFeature(Feature::TextureCompressionBC); EnableFeature(Feature::TextureCompressionBC);
} }
if ([*mDevice supportsFamily:MTLGPUFamilyMac2]) {
EnableFeature(Feature::Float32Filterable);
}
if ([*mDevice supportsFamily:MTLGPUFamilyApple2]) { if ([*mDevice supportsFamily:MTLGPUFamilyApple2]) {
EnableFeature(Feature::TextureCompressionETC2); EnableFeature(Feature::TextureCompressionETC2);
} }
@ -625,7 +633,7 @@ class PhysicalDevice : public PhysicalDeviceBase {
} }
} }
#if TARGET_OS_OSX #if DAWN_PLATFORM_IS(MACOS)
if (@available(macOS 10.14, *)) { if (@available(macOS 10.14, *)) {
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily2_v1]) {
return MTLGPUFamily::Mac2; return MTLGPUFamily::Mac2;
@ -634,7 +642,7 @@ class PhysicalDevice : public PhysicalDeviceBase {
if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_macOS_GPUFamily1_v1]) {
return MTLGPUFamily::Mac1; return MTLGPUFamily::Mac1;
} }
#elif TARGET_OS_IOS #elif DAWN_PLATFORM_IS(IOS)
if (@available(iOS 10.11, *)) { if (@available(iOS 10.11, *)) {
if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) { if ([*mDevice supportsFeatureSet:MTLFeatureSet_iOS_GPUFamily4_v1]) {
return MTLGPUFamily::Apple4; return MTLGPUFamily::Apple4;

View File

@ -255,6 +255,24 @@ void PhysicalDevice::InitializeSupportedFeaturesImpl() {
EnableFeature(Feature::BGRA8UnormStorage); EnableFeature(Feature::BGRA8UnormStorage);
} }
// 32 bit float channel formats.
VkFormatProperties r32Properties;
VkFormatProperties rg32Properties;
VkFormatProperties rgba32Properties;
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(
mVkPhysicalDevice, VK_FORMAT_R32_SFLOAT, &r32Properties);
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(
mVkPhysicalDevice, VK_FORMAT_R32G32_SFLOAT, &rg32Properties);
mVulkanInstance->GetFunctions().GetPhysicalDeviceFormatProperties(
mVkPhysicalDevice, VK_FORMAT_R32G32B32A32_SFLOAT, &rgba32Properties);
if ((r32Properties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) &&
(rg32Properties.optimalTilingFeatures &
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) &&
(rgba32Properties.optimalTilingFeatures &
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT)) {
EnableFeature(Feature::Float32Filterable);
}
#if DAWN_PLATFORM_IS(ANDROID) || DAWN_PLATFORM_IS(CHROMEOS) #if DAWN_PLATFORM_IS(ANDROID) || DAWN_PLATFORM_IS(CHROMEOS)
// TODO(chromium:1258986): Precisely enable the feature by querying the device's format // TODO(chromium:1258986): Precisely enable the feature by querying the device's format
// features. // features.

View File

@ -90,6 +90,29 @@ class BindGroupValidationTest : public ValidationTest {
return dawnAdapter.CreateDevice(&descriptor); return dawnAdapter.CreateDevice(&descriptor);
} }
void DoTextureSampleTypeTest(bool success,
wgpu::TextureFormat format,
wgpu::TextureSampleType sampleType,
wgpu::TextureAspect aspect = wgpu::TextureAspect::All) {
wgpu::BindGroupLayout layout =
utils::MakeBindGroupLayout(device, {{0, wgpu::ShaderStage::Fragment, sampleType}});
wgpu::TextureDescriptor descriptor;
descriptor.size = {4, 4, 1};
descriptor.usage = wgpu::TextureUsage::TextureBinding;
descriptor.format = format;
wgpu::TextureViewDescriptor viewDescriptor;
viewDescriptor.aspect = aspect;
wgpu::TextureView view = device.CreateTexture(&descriptor).CreateView(&viewDescriptor);
if (success) {
utils::MakeBindGroup(device, layout, {{0, view}});
} else {
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, view}}));
}
}
wgpu::Buffer mUBO; wgpu::Buffer mUBO;
wgpu::Buffer mSSBO; wgpu::Buffer mSSBO;
wgpu::Sampler mSampler; wgpu::Sampler mSampler;
@ -468,126 +491,153 @@ TEST_F(BindGroupValidationTest, StorageTextureUsage) {
// Check that a texture must have the correct sample type // Check that a texture must have the correct sample type
TEST_F(BindGroupValidationTest, TextureSampleType) { TEST_F(BindGroupValidationTest, TextureSampleType) {
auto DoTest = [this](bool success, wgpu::TextureFormat format, // Test that RGBA8Unorm is only compatible with float/unfilterable-float.
wgpu::TextureSampleType sampleType, DoTextureSampleTypeTest(true, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Float);
wgpu::TextureAspect aspect = wgpu::TextureAspect::All) { DoTextureSampleTypeTest(true, wgpu::TextureFormat::RGBA8Unorm,
wgpu::BindGroupLayout layout = wgpu::TextureSampleType::UnfilterableFloat);
utils::MakeBindGroupLayout(device, {{0, wgpu::ShaderStage::Fragment, sampleType}}); DoTextureSampleTypeTest(false, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Depth);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Sint);
wgpu::TextureDescriptor descriptor; // Test that float32 formats are only compatible with unfilterable-float (without the
descriptor.size = {4, 4, 1}; // float32-filterable feature enabled).
descriptor.usage = wgpu::TextureUsage::TextureBinding; for (const auto f32Format : {wgpu::TextureFormat::R32Float, wgpu::TextureFormat::RG32Float,
descriptor.format = format; wgpu::TextureFormat::RGBA32Float}) {
DoTextureSampleTypeTest(false, f32Format, wgpu::TextureSampleType::Float);
wgpu::TextureViewDescriptor viewDescriptor; DoTextureSampleTypeTest(true, f32Format, wgpu::TextureSampleType::UnfilterableFloat);
viewDescriptor.aspect = aspect; DoTextureSampleTypeTest(false, f32Format, wgpu::TextureSampleType::Depth);
wgpu::TextureView view = device.CreateTexture(&descriptor).CreateView(&viewDescriptor); DoTextureSampleTypeTest(false, f32Format, wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(false, f32Format, wgpu::TextureSampleType::Sint);
if (success) { }
utils::MakeBindGroup(device, layout, {{0, view}});
} else {
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, view}}));
}
};
// Test that RGBA8Unorm is only compatible with float/unfilterable-float
DoTest(true, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Float);
DoTest(true, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::UnfilterableFloat);
DoTest(false, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Depth);
DoTest(false, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Uint);
DoTest(false, wgpu::TextureFormat::RGBA8Unorm, wgpu::TextureSampleType::Sint);
// Test that R32Float is only compatible with unfilterable-float
DoTest(false, wgpu::TextureFormat::R32Float, wgpu::TextureSampleType::Float);
DoTest(true, wgpu::TextureFormat::R32Float, wgpu::TextureSampleType::UnfilterableFloat);
DoTest(false, wgpu::TextureFormat::R32Float, wgpu::TextureSampleType::Depth);
DoTest(false, wgpu::TextureFormat::R32Float, wgpu::TextureSampleType::Uint);
DoTest(false, wgpu::TextureFormat::R32Float, wgpu::TextureSampleType::Sint);
// Test that Depth16Unorm is only compatible with depth/unfilterable-float. // Test that Depth16Unorm is only compatible with depth/unfilterable-float.
DoTest(false, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureSampleType::Float); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth16Unorm,
DoTest(true, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureSampleType::UnfilterableFloat); wgpu::TextureSampleType::Float);
DoTest(true, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureSampleType::Depth); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth16Unorm,
DoTest(false, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureSampleType::Uint); wgpu::TextureSampleType::UnfilterableFloat);
DoTest(false, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureSampleType::Sint); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth16Unorm,
wgpu::TextureSampleType::Depth);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth16Unorm,
wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth16Unorm,
wgpu::TextureSampleType::Sint);
// Test that Depth24Plus is only compatible with depth/unfilterable-float. // Test that Depth24Plus is only compatible with depth/unfilterable-float.
DoTest(false, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::Float); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24Plus,
DoTest(true, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::UnfilterableFloat); wgpu::TextureSampleType::Float);
DoTest(true, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::Depth); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth24Plus,
DoTest(false, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::Uint); wgpu::TextureSampleType::UnfilterableFloat);
DoTest(false, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::Sint); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::Depth);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24Plus, wgpu::TextureSampleType::Sint);
// Test that Depth24PlusStencil8 with depth aspect is only compatible with // Test that Depth24PlusStencil8 with depth aspect is only compatible with
// depth/unfilterable-float. // depth/unfilterable-float.
DoTest(false, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Float, DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureAspect::DepthOnly); wgpu::TextureSampleType::Float, wgpu::TextureAspect::DepthOnly);
DoTest(true, wgpu::TextureFormat::Depth24PlusStencil8, DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureSampleType::UnfilterableFloat, wgpu::TextureAspect::DepthOnly); wgpu::TextureSampleType::UnfilterableFloat,
DoTest(true, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::DepthOnly);
wgpu::TextureAspect::DepthOnly); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth24PlusStencil8,
DoTest(false, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Uint, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::DepthOnly);
wgpu::TextureAspect::DepthOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24PlusStencil8,
DoTest(false, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Sint, wgpu::TextureSampleType::Uint, wgpu::TextureAspect::DepthOnly);
wgpu::TextureAspect::DepthOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureSampleType::Sint, wgpu::TextureAspect::DepthOnly);
// Test that Depth24PlusStencil8 with stencil aspect is only compatible with uint. // Test that Depth24PlusStencil8 with stencil aspect is only compatible with uint.
DoTest(false, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Float, DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureAspect::StencilOnly); wgpu::TextureSampleType::Float, wgpu::TextureAspect::StencilOnly);
DoTest(false, wgpu::TextureFormat::Depth24PlusStencil8, DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureSampleType::UnfilterableFloat, wgpu::TextureAspect::StencilOnly); wgpu::TextureSampleType::UnfilterableFloat,
DoTest(false, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::StencilOnly);
wgpu::TextureAspect::StencilOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24PlusStencil8,
DoTest(true, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Uint, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::StencilOnly);
wgpu::TextureAspect::StencilOnly); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth24PlusStencil8,
DoTest(false, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureSampleType::Sint, wgpu::TextureSampleType::Uint, wgpu::TextureAspect::StencilOnly);
wgpu::TextureAspect::StencilOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureSampleType::Sint, wgpu::TextureAspect::StencilOnly);
// Test that Depth32Float is only compatible with depth/unfilterable-float. // Test that Depth32Float is only compatible with depth/unfilterable-float.
DoTest(false, wgpu::TextureFormat::Depth32Float, wgpu::TextureSampleType::Float); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32Float,
DoTest(true, wgpu::TextureFormat::Depth32Float, wgpu::TextureSampleType::UnfilterableFloat); wgpu::TextureSampleType::Float);
DoTest(true, wgpu::TextureFormat::Depth32Float, wgpu::TextureSampleType::Depth); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth32Float,
DoTest(false, wgpu::TextureFormat::Depth32Float, wgpu::TextureSampleType::Uint); wgpu::TextureSampleType::UnfilterableFloat);
DoTest(false, wgpu::TextureFormat::Depth32Float, wgpu::TextureSampleType::Sint); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth32Float,
wgpu::TextureSampleType::Depth);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32Float,
wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32Float,
wgpu::TextureSampleType::Sint);
// Test that Depth32FloatStencil8 with depth aspect is only compatible with // Test that Depth32FloatStencil8 with depth aspect is only compatible with
// depth/unfilterable-float. // depth/unfilterable-float.
DoTest(false, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Float, DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureAspect::DepthOnly); wgpu::TextureSampleType::Float, wgpu::TextureAspect::DepthOnly);
DoTest(true, wgpu::TextureFormat::Depth32FloatStencil8, DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureSampleType::UnfilterableFloat, wgpu::TextureAspect::DepthOnly); wgpu::TextureSampleType::UnfilterableFloat,
DoTest(true, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::DepthOnly);
wgpu::TextureAspect::DepthOnly); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth32FloatStencil8,
DoTest(false, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Uint, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::DepthOnly);
wgpu::TextureAspect::DepthOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32FloatStencil8,
DoTest(false, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Sint, wgpu::TextureSampleType::Uint, wgpu::TextureAspect::DepthOnly);
wgpu::TextureAspect::DepthOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureSampleType::Sint, wgpu::TextureAspect::DepthOnly);
// Test that Depth32FloatStencil8 with stencil aspect is only compatible with uint. // Test that Depth32FloatStencil8 with stencil aspect is only compatible with uint.
DoTest(false, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Float, DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureAspect::StencilOnly); wgpu::TextureSampleType::Float, wgpu::TextureAspect::StencilOnly);
DoTest(false, wgpu::TextureFormat::Depth32FloatStencil8, DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureSampleType::UnfilterableFloat, wgpu::TextureAspect::StencilOnly); wgpu::TextureSampleType::UnfilterableFloat,
DoTest(false, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::StencilOnly);
wgpu::TextureAspect::StencilOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32FloatStencil8,
DoTest(true, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Uint, wgpu::TextureSampleType::Depth, wgpu::TextureAspect::StencilOnly);
wgpu::TextureAspect::StencilOnly); DoTextureSampleTypeTest(true, wgpu::TextureFormat::Depth32FloatStencil8,
DoTest(false, wgpu::TextureFormat::Depth32FloatStencil8, wgpu::TextureSampleType::Sint, wgpu::TextureSampleType::Uint, wgpu::TextureAspect::StencilOnly);
wgpu::TextureAspect::StencilOnly); DoTextureSampleTypeTest(false, wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureSampleType::Sint, wgpu::TextureAspect::StencilOnly);
// Test that RG8Uint is only compatible with uint // Test that RG8Uint is only compatible with uint.
DoTest(false, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Float); DoTextureSampleTypeTest(false, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Float);
DoTest(false, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::UnfilterableFloat); DoTextureSampleTypeTest(false, wgpu::TextureFormat::RG8Uint,
DoTest(false, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Depth); wgpu::TextureSampleType::UnfilterableFloat);
DoTest(true, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Uint); DoTextureSampleTypeTest(false, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Depth);
DoTest(false, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Sint); DoTextureSampleTypeTest(true, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(false, wgpu::TextureFormat::RG8Uint, wgpu::TextureSampleType::Sint);
// Test that R16Sint is only compatible with sint // Test that R16Sint is only compatible with sint.
DoTest(false, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Float); DoTextureSampleTypeTest(false, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Float);
DoTest(false, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::UnfilterableFloat); DoTextureSampleTypeTest(false, wgpu::TextureFormat::R16Sint,
DoTest(false, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Depth); wgpu::TextureSampleType::UnfilterableFloat);
DoTest(false, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Uint); DoTextureSampleTypeTest(false, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Depth);
DoTest(true, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Sint); DoTextureSampleTypeTest(false, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(true, wgpu::TextureFormat::R16Sint, wgpu::TextureSampleType::Sint);
}
class BindGroupValidationTest_Float32Filterable : public BindGroupValidationTest {
protected:
WGPUDevice CreateTestDevice(dawn::native::Adapter dawnAdapter,
wgpu::DeviceDescriptor descriptor) override {
wgpu::FeatureName requiredFeatures[1] = {wgpu::FeatureName::Float32Filterable};
descriptor.requiredFeatures = requiredFeatures;
descriptor.requiredFeaturesCount = 1;
return dawnAdapter.CreateDevice(&descriptor);
}
};
// Checks that float32 texture formats have the correct sample type when float32-filterable feature
// enabled.
TEST_F(BindGroupValidationTest_Float32Filterable, TextureSampleType) {
// With the feature enabled, float32 formats should be compatible with both float and
// unfilterable-float.
for (const auto f32Format : {wgpu::TextureFormat::R32Float, wgpu::TextureFormat::RG32Float,
wgpu::TextureFormat::RGBA32Float}) {
DoTextureSampleTypeTest(true, f32Format, wgpu::TextureSampleType::Float);
DoTextureSampleTypeTest(true, f32Format, wgpu::TextureSampleType::UnfilterableFloat);
DoTextureSampleTypeTest(false, f32Format, wgpu::TextureSampleType::Depth);
DoTextureSampleTypeTest(false, f32Format, wgpu::TextureSampleType::Uint);
DoTextureSampleTypeTest(false, f32Format, wgpu::TextureSampleType::Sint);
}
} }
// Test which depth-stencil formats are allowed to be sampled (all). // Test which depth-stencil formats are allowed to be sampled (all).

View File

@ -43,6 +43,7 @@ bool IsFeatureSupported(WGPUFeatureName feature) {
case WGPUFeatureName_RG11B10UfloatRenderable: case WGPUFeatureName_RG11B10UfloatRenderable:
case WGPUFeatureName_BGRA8UnormStorage: case WGPUFeatureName_BGRA8UnormStorage:
case WGPUFeatureName_TransientAttachments: case WGPUFeatureName_TransientAttachments:
case WGPUFeatureName_Float32Filterable:
return true; return true;
} }