Add features of depth24unorm-stencil8 and depth32float-stencil8 texture formats

The depth240unorm-stencil8 and depth32float-stencil8 are optional
features. Enable them and add validation tests for texture creation
and texture view creation.

They are unimplmented on backends, skip their end2end tests.

TODO: add validtion for copy commands.

BUG=dawn:690

Change-Id: I980631d2f3fa6397a6125221a76980a15c8cb2f5
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/68220
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Hao Li <hao.x.li@intel.com>
This commit is contained in:
Li Hao 2021-11-25 01:11:57 +00:00 committed by Dawn LUCI CQ
parent 596e07f768
commit a329997e27
16 changed files with 333 additions and 95 deletions

112
dawn.json
View File

@ -1117,6 +1117,8 @@
{"name": "timestamp query", "type": "bool", "default": "false"}, {"name": "timestamp query", "type": "bool", "default": "false"},
{"name": "multi planar formats", "type": "bool", "default": "false"}, {"name": "multi planar formats", "type": "bool", "default": "false"},
{"name": "depth clamping", "type": "bool", "default": "false"}, {"name": "depth clamping", "type": "bool", "default": "false"},
{"name": "depth24 unorm stencil8", "type": "bool", "default": "false"},
{"name": "depth32 float stencil8", "type": "bool", "default": "false"},
{"name": "invalid feature", "type": "bool", "default": "false"}, {"name": "invalid feature", "type": "bool", "default": "false"},
{"name": "dawn internal usages", "type": "bool", "default": "false"}, {"name": "dawn internal usages", "type": "bool", "default": "false"},
{"name": "limits", "type": "supported limits"} {"name": "limits", "type": "supported limits"}
@ -2429,64 +2431,66 @@
{"value": 38, "name": "depth16 unorm"}, {"value": 38, "name": "depth16 unorm"},
{"value": 39, "name": "depth24 plus"}, {"value": 39, "name": "depth24 plus"},
{"value": 40, "name": "depth24 plus stencil8"}, {"value": 40, "name": "depth24 plus stencil8"},
{"value": 41, "name": "depth32 float"}, {"value": 41, "name": "depth24 unorm stencil8"},
{"value": 42, "name": "depth32 float"},
{"value": 43, "name": "depth32 float stencil8"},
{"value": 42, "name": "BC1 RGBA unorm", "jsrepr": "'bc1-rgba-unorm'"}, {"value": 44, "name": "BC1 RGBA unorm", "jsrepr": "'bc1-rgba-unorm'"},
{"value": 43, "name": "BC1 RGBA unorm srgb", "jsrepr": "'bc1-rgba-unorm-srgb'"}, {"value": 45, "name": "BC1 RGBA unorm srgb", "jsrepr": "'bc1-rgba-unorm-srgb'"},
{"value": 44, "name": "BC2 RGBA unorm", "jsrepr": "'bc2-rgba-unorm'"}, {"value": 46, "name": "BC2 RGBA unorm", "jsrepr": "'bc2-rgba-unorm'"},
{"value": 45, "name": "BC2 RGBA unorm srgb", "jsrepr": "'bc2-rgba-unorm-srgb'"}, {"value": 47, "name": "BC2 RGBA unorm srgb", "jsrepr": "'bc2-rgba-unorm-srgb'"},
{"value": 46, "name": "BC3 RGBA unorm", "jsrepr": "'bc3-rgba-unorm'"}, {"value": 48, "name": "BC3 RGBA unorm", "jsrepr": "'bc3-rgba-unorm'"},
{"value": 47, "name": "BC3 RGBA unorm srgb", "jsrepr": "'bc3-rgba-unorm-srgb'"}, {"value": 49, "name": "BC3 RGBA unorm srgb", "jsrepr": "'bc3-rgba-unorm-srgb'"},
{"value": 48, "name": "BC4 R unorm", "jsrepr": "'bc4-r-unorm'"}, {"value": 50, "name": "BC4 R unorm", "jsrepr": "'bc4-r-unorm'"},
{"value": 49, "name": "BC4 R snorm", "jsrepr": "'bc4-r-snorm'"}, {"value": 51, "name": "BC4 R snorm", "jsrepr": "'bc4-r-snorm'"},
{"value": 50, "name": "BC5 RG unorm", "jsrepr": "'bc5-rg-unorm'"}, {"value": 52, "name": "BC5 RG unorm", "jsrepr": "'bc5-rg-unorm'"},
{"value": 51, "name": "BC5 RG snorm", "jsrepr": "'bc5-rg-snorm'"}, {"value": 53, "name": "BC5 RG snorm", "jsrepr": "'bc5-rg-snorm'"},
{"value": 52, "name": "BC6H RGB ufloat", "jsrepr": "'bc6h-rgb-ufloat'"}, {"value": 54, "name": "BC6H RGB ufloat", "jsrepr": "'bc6h-rgb-ufloat'"},
{"value": 53, "name": "BC6H RGB float", "jsrepr": "'bc6h-rgb-float'"}, {"value": 55, "name": "BC6H RGB float", "jsrepr": "'bc6h-rgb-float'"},
{"value": 54, "name": "BC7 RGBA unorm", "jsrepr": "'bc7-rgba-unorm'"}, {"value": 56, "name": "BC7 RGBA unorm", "jsrepr": "'bc7-rgba-unorm'"},
{"value": 55, "name": "BC7 RGBA unorm srgb", "jsrepr": "'bc7-rgba-unorm-srgb'"}, {"value": 57, "name": "BC7 RGBA unorm srgb", "jsrepr": "'bc7-rgba-unorm-srgb'"},
{"value": 56, "name": "ETC2 RGB8 unorm", "jsrepr": "'etc2-rgb8unorm'"}, {"value": 58, "name": "ETC2 RGB8 unorm", "jsrepr": "'etc2-rgb8unorm'"},
{"value": 57, "name": "ETC2 RGB8 unorm srgb", "jsrepr": "'etc2-rgb8unorm-srgb'"}, {"value": 59, "name": "ETC2 RGB8 unorm srgb", "jsrepr": "'etc2-rgb8unorm-srgb'"},
{"value": 58, "name": "ETC2 RGB8A1 unorm", "jsrepr": "'etc2-rgb8a1unorm'"}, {"value": 60, "name": "ETC2 RGB8A1 unorm", "jsrepr": "'etc2-rgb8a1unorm'"},
{"value": 59, "name": "ETC2 RGB8A1 unorm srgb", "jsrepr": "'etc2-rgb8a1unorm-srgb'"}, {"value": 61, "name": "ETC2 RGB8A1 unorm srgb", "jsrepr": "'etc2-rgb8a1unorm-srgb'"},
{"value": 60, "name": "ETC2 RGBA8 unorm", "jsrepr": "'etc2-rgba8unorm'"}, {"value": 62, "name": "ETC2 RGBA8 unorm", "jsrepr": "'etc2-rgba8unorm'"},
{"value": 61, "name": "ETC2 RGBA8 unorm srgb", "jsrepr": "'etc2-rgba8unorm-srgb'"}, {"value": 63, "name": "ETC2 RGBA8 unorm srgb", "jsrepr": "'etc2-rgba8unorm-srgb'"},
{"value": 62, "name": "EAC R11 unorm", "jsrepr": "'eac-r11unorm'"}, {"value": 64, "name": "EAC R11 unorm", "jsrepr": "'eac-r11unorm'"},
{"value": 63, "name": "EAC R11 snorm", "jsrepr": "'eac-r11snorm'"}, {"value": 65, "name": "EAC R11 snorm", "jsrepr": "'eac-r11snorm'"},
{"value": 64, "name": "EAC RG11 unorm", "jsrepr": "'eac-rg11unorm'"}, {"value": 66, "name": "EAC RG11 unorm", "jsrepr": "'eac-rg11unorm'"},
{"value": 65, "name": "EAC RG11 snorm", "jsrepr": "'eac-rg11snorm'"}, {"value": 67, "name": "EAC RG11 snorm", "jsrepr": "'eac-rg11snorm'"},
{"value": 66, "name": "ASTC 4x4 unorm", "jsrepr": "'astc-4x4-unorm'"}, {"value": 68, "name": "ASTC 4x4 unorm", "jsrepr": "'astc-4x4-unorm'"},
{"value": 67, "name": "ASTC 4x4 unorm srgb", "jsrepr": "'astc-4x4-unorm-srgb'"}, {"value": 69, "name": "ASTC 4x4 unorm srgb", "jsrepr": "'astc-4x4-unorm-srgb'"},
{"value": 68, "name": "ASTC 5x4 unorm", "jsrepr": "'astc-5x4-unorm'"}, {"value": 70, "name": "ASTC 5x4 unorm", "jsrepr": "'astc-5x4-unorm'"},
{"value": 69, "name": "ASTC 5x4 unorm srgb", "jsrepr": "'astc-5x4-unorm-srgb'"}, {"value": 71, "name": "ASTC 5x4 unorm srgb", "jsrepr": "'astc-5x4-unorm-srgb'"},
{"value": 70, "name": "ASTC 5x5 unorm", "jsrepr": "'astc-5x5-unorm'"}, {"value": 72, "name": "ASTC 5x5 unorm", "jsrepr": "'astc-5x5-unorm'"},
{"value": 71, "name": "ASTC 5x5 unorm srgb", "jsrepr": "'astc-5x5-unorm-srgb'"}, {"value": 73, "name": "ASTC 5x5 unorm srgb", "jsrepr": "'astc-5x5-unorm-srgb'"},
{"value": 72, "name": "ASTC 6x5 unorm", "jsrepr": "'astc-6x5-unorm'"}, {"value": 74, "name": "ASTC 6x5 unorm", "jsrepr": "'astc-6x5-unorm'"},
{"value": 73, "name": "ASTC 6x5 unorm srgb", "jsrepr": "'astc-6x5-unorm-srgb'"}, {"value": 75, "name": "ASTC 6x5 unorm srgb", "jsrepr": "'astc-6x5-unorm-srgb'"},
{"value": 74, "name": "ASTC 6x6 unorm", "jsrepr": "'astc-6x6-unorm'"}, {"value": 76, "name": "ASTC 6x6 unorm", "jsrepr": "'astc-6x6-unorm'"},
{"value": 75, "name": "ASTC 6x6 unorm srgb", "jsrepr": "'astc-6x6-unorm-srgb'"}, {"value": 77, "name": "ASTC 6x6 unorm srgb", "jsrepr": "'astc-6x6-unorm-srgb'"},
{"value": 76, "name": "ASTC 8x5 unorm", "jsrepr": "'astc-8x5-unorm'"}, {"value": 78, "name": "ASTC 8x5 unorm", "jsrepr": "'astc-8x5-unorm'"},
{"value": 77, "name": "ASTC 8x5 unorm srgb", "jsrepr": "'astc-8x5-unorm-srgb'"}, {"value": 79, "name": "ASTC 8x5 unorm srgb", "jsrepr": "'astc-8x5-unorm-srgb'"},
{"value": 78, "name": "ASTC 8x6 unorm", "jsrepr": "'astc-8x6-unorm'"}, {"value": 80, "name": "ASTC 8x6 unorm", "jsrepr": "'astc-8x6-unorm'"},
{"value": 79, "name": "ASTC 8x6 unorm srgb", "jsrepr": "'astc-8x6-unorm-srgb'"}, {"value": 81, "name": "ASTC 8x6 unorm srgb", "jsrepr": "'astc-8x6-unorm-srgb'"},
{"value": 80, "name": "ASTC 8x8 unorm", "jsrepr": "'astc-8x8-unorm'"}, {"value": 82, "name": "ASTC 8x8 unorm", "jsrepr": "'astc-8x8-unorm'"},
{"value": 81, "name": "ASTC 8x8 unorm srgb", "jsrepr": "'astc-8x8-unorm-srgb'"}, {"value": 83, "name": "ASTC 8x8 unorm srgb", "jsrepr": "'astc-8x8-unorm-srgb'"},
{"value": 82, "name": "ASTC 10x5 unorm", "jsrepr": "'astc-10x5-unorm'"}, {"value": 84, "name": "ASTC 10x5 unorm", "jsrepr": "'astc-10x5-unorm'"},
{"value": 83, "name": "ASTC 10x5 unorm srgb", "jsrepr": "'astc-10x5-unorm-srgb'"}, {"value": 85, "name": "ASTC 10x5 unorm srgb", "jsrepr": "'astc-10x5-unorm-srgb'"},
{"value": 84, "name": "ASTC 10x6 unorm", "jsrepr": "'astc-10x6-unorm'"}, {"value": 86, "name": "ASTC 10x6 unorm", "jsrepr": "'astc-10x6-unorm'"},
{"value": 85, "name": "ASTC 10x6 unorm srgb", "jsrepr": "'astc-10x6-unorm-srgb'"}, {"value": 87, "name": "ASTC 10x6 unorm srgb", "jsrepr": "'astc-10x6-unorm-srgb'"},
{"value": 86, "name": "ASTC 10x8 unorm", "jsrepr": "'astc-10x8-unorm'"}, {"value": 88, "name": "ASTC 10x8 unorm", "jsrepr": "'astc-10x8-unorm'"},
{"value": 87, "name": "ASTC 10x8 unorm srgb", "jsrepr": "'astc-10x8-unorm-srgb'"}, {"value": 89, "name": "ASTC 10x8 unorm srgb", "jsrepr": "'astc-10x8-unorm-srgb'"},
{"value": 88, "name": "ASTC 10x10 unorm", "jsrepr": "'astc-10x10-unorm'"}, {"value": 90, "name": "ASTC 10x10 unorm", "jsrepr": "'astc-10x10-unorm'"},
{"value": 89, "name": "ASTC 10x10 unorm srgb", "jsrepr": "'astc-10x10-unorm-srgb'"}, {"value": 91, "name": "ASTC 10x10 unorm srgb", "jsrepr": "'astc-10x10-unorm-srgb'"},
{"value": 90, "name": "ASTC 12x10 unorm", "jsrepr": "'astc-12x10-unorm'"}, {"value": 92, "name": "ASTC 12x10 unorm", "jsrepr": "'astc-12x10-unorm'"},
{"value": 91, "name": "ASTC 12x10 unorm srgb", "jsrepr": "'astc-12x10-unorm-srgb'"}, {"value": 93, "name": "ASTC 12x10 unorm srgb", "jsrepr": "'astc-12x10-unorm-srgb'"},
{"value": 92, "name": "ASTC 12x12 unorm", "jsrepr": "'astc-12x12-unorm'"}, {"value": 94, "name": "ASTC 12x12 unorm", "jsrepr": "'astc-12x12-unorm'"},
{"value": 93, "name": "ASTC 12x12 unorm srgb", "jsrepr": "'astc-12x12-unorm-srgb'"}, {"value": 95, "name": "ASTC 12x12 unorm srgb", "jsrepr": "'astc-12x12-unorm-srgb'"},
{"value": 94, "name": "R8 BG8 Biplanar 420 unorm", "tags": ["dawn"]} {"value": 96, "name": "R8 BG8 Biplanar 420 unorm", "tags": ["dawn"]}
] ]
}, },
"texture usage": { "texture usage": {

View File

@ -64,6 +64,14 @@ namespace dawn_native {
{"depth-clamping", "Clamp depth to [0, 1] in NDC space instead of clipping", {"depth-clamping", "Clamp depth to [0, 1] in NDC space instead of clipping",
"https://bugs.chromium.org/p/dawn/issues/detail?id=716"}, "https://bugs.chromium.org/p/dawn/issues/detail?id=716"},
&WGPUDeviceProperties::depthClamping}, &WGPUDeviceProperties::depthClamping},
{Feature::Depth24UnormStencil8,
{"depth24unorm-stencil8", "Support depth24unorm-stencil8 texture format",
"https://bugs.chromium.org/p/dawn/issues/detail?id=690"},
&WGPUDeviceProperties::depth24UnormStencil8},
{Feature::Depth32FloatStencil8,
{"depth32float-stencil8", "Support depth32float-stencil8 texture format",
"https://bugs.chromium.org/p/dawn/issues/detail?id=690"},
&WGPUDeviceProperties::depth32FloatStencil8},
{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 "

View File

@ -31,6 +31,8 @@ namespace dawn_native {
PipelineStatisticsQuery, PipelineStatisticsQuery,
TimestampQuery, TimestampQuery,
DepthClamping, DepthClamping,
Depth24UnormStencil8,
Depth32FloatStencil8,
// Dawn-specific // Dawn-specific
DawnInternalUsages, DawnInternalUsages,

View File

@ -335,8 +335,13 @@ namespace dawn_native {
AddDepthFormat(wgpu::TextureFormat::Depth24Plus, 4, true); AddDepthFormat(wgpu::TextureFormat::Depth24Plus, 4, true);
AddMultiAspectFormat(wgpu::TextureFormat::Depth24PlusStencil8, AddMultiAspectFormat(wgpu::TextureFormat::Depth24PlusStencil8,
Aspect::Depth | Aspect::Stencil, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Stencil8, true, true, 2); Aspect::Depth | Aspect::Stencil, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Stencil8, true, true, 2);
bool isD24S8Supported = device->IsFeatureEnabled(Feature::Depth24UnormStencil8);
AddMultiAspectFormat(wgpu::TextureFormat::Depth24UnormStencil8,
Aspect::Depth | Aspect::Stencil, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Stencil8, true, isD24S8Supported, 2);
AddDepthFormat(wgpu::TextureFormat::Depth32Float, 4, true); AddDepthFormat(wgpu::TextureFormat::Depth32Float, 4, true);
// TODO(dawn:690): Implement Depth24UnormStencil8, Depth32FloatStencil8. bool isD32S8Supported = device->IsFeatureEnabled(Feature::Depth32FloatStencil8);
AddMultiAspectFormat(wgpu::TextureFormat::Depth32FloatStencil8,
Aspect::Depth | Aspect::Stencil, wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Stencil8, true, isD32S8Supported, 2);
// BC compressed formats // BC compressed formats
bool isBCFormatSupported = device->IsFeatureEnabled(Feature::TextureCompressionBC); bool isBCFormatSupported = device->IsFeatureEnabled(Feature::TextureCompressionBC);

View File

@ -77,7 +77,7 @@ namespace dawn_native {
// The number of formats Dawn knows about. Asserts in BuildFormatTable ensure that this is the // The number of formats Dawn knows about. Asserts in BuildFormatTable ensure that this is the
// exact number of known format. // exact number of known format.
static constexpr size_t kKnownFormatCount = 94; static constexpr size_t kKnownFormatCount = 96;
struct Format; struct Format;
using FormatTable = std::array<Format, kKnownFormatCount>; using FormatTable = std::array<Format, kKnownFormatCount>;

View File

@ -252,6 +252,10 @@ namespace dawn_native { namespace d3d12 {
case wgpu::TextureFormat::R8BG8Biplanar420Unorm: case wgpu::TextureFormat::R8BG8Biplanar420Unorm:
// TODO(dawn:666): implement stencil8 // TODO(dawn:666): implement stencil8
case wgpu::TextureFormat::Stencil8: case wgpu::TextureFormat::Stencil8:
// TODO(dawn:690): implement depth24unorm-stencil8
case wgpu::TextureFormat::Depth24UnormStencil8:
// TODO(dawn:690): implement depth32float-stencil8
case wgpu::TextureFormat::Depth32FloatStencil8:
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }
@ -421,6 +425,10 @@ namespace dawn_native { namespace d3d12 {
// TODO(dawn:666): implement stencil8 // TODO(dawn:666): implement stencil8
case wgpu::TextureFormat::Stencil8: case wgpu::TextureFormat::Stencil8:
// TODO(dawn:690): implement depth24unorm-stencil8
case wgpu::TextureFormat::Depth24UnormStencil8:
// TODO(dawn:690): implement depth32float-stencil8
case wgpu::TextureFormat::Depth32FloatStencil8:
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }

View File

@ -321,6 +321,10 @@ namespace dawn_native { namespace metal {
// TODO(dawn:666): implement stencil8 // TODO(dawn:666): implement stencil8
case wgpu::TextureFormat::Stencil8: case wgpu::TextureFormat::Stencil8:
// TODO(dawn:690): implement depth24unorm-stencil8
case wgpu::TextureFormat::Depth24UnormStencil8:
// TODO(dawn:690): implement depth32float-stencil8
case wgpu::TextureFormat::Depth32FloatStencil8:
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
UNREACHABLE(); UNREACHABLE();
} }

View File

@ -40,6 +40,16 @@ namespace dawn_native { namespace vulkan {
return mBackend; return mBackend;
} }
bool Adapter::IsDepthStencilFormatSupported(VkFormat format) {
ASSERT(format == VK_FORMAT_D16_UNORM_S8_UINT || format == VK_FORMAT_D24_UNORM_S8_UINT ||
format == VK_FORMAT_D32_SFLOAT_S8_UINT);
VkFormatProperties properties;
GetBackend()->GetFunctions().GetPhysicalDeviceFormatProperties(mPhysicalDevice, format,
&properties);
return properties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
}
MaybeError Adapter::InitializeImpl() { MaybeError Adapter::InitializeImpl() {
DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this)); DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));

View File

@ -36,6 +36,8 @@ namespace dawn_native { namespace vulkan {
VkPhysicalDevice GetPhysicalDevice() const; VkPhysicalDevice GetPhysicalDevice() const;
Backend* GetBackend() const; Backend* GetBackend() const;
bool IsDepthStencilFormatSupported(VkFormat format);
private: private:
MaybeError InitializeImpl() override; MaybeError InitializeImpl() override;
MaybeError InitializeSupportedFeaturesImpl() override; MaybeError InitializeSupportedFeaturesImpl() override;

View File

@ -497,25 +497,10 @@ namespace dawn_native { namespace vulkan {
} }
void Device::ApplyDepth24PlusS8Toggle() { void Device::ApplyDepth24PlusS8Toggle() {
VkPhysicalDevice physicalDevice = ToBackend(GetAdapter())->GetPhysicalDevice(); bool supportsD32s8 =
ToBackend(GetAdapter())->IsDepthStencilFormatSupported(VK_FORMAT_D32_SFLOAT_S8_UINT);
bool supportsD32s8 = false; bool supportsD24s8 =
{ ToBackend(GetAdapter())->IsDepthStencilFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT);
VkFormatProperties properties;
fn.GetPhysicalDeviceFormatProperties(physicalDevice, VK_FORMAT_D32_SFLOAT_S8_UINT,
&properties);
supportsD32s8 =
properties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
}
bool supportsD24s8 = false;
{
VkFormatProperties properties;
fn.GetPhysicalDeviceFormatProperties(physicalDevice, VK_FORMAT_D24_UNORM_S8_UINT,
&properties);
supportsD24s8 =
properties.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
}
ASSERT(supportsD32s8 || supportsD24s8); ASSERT(supportsD32s8 || supportsD24s8);

View File

@ -419,6 +419,10 @@ namespace dawn_native { namespace vulkan {
case wgpu::TextureFormat::R8BG8Biplanar420Unorm: case wgpu::TextureFormat::R8BG8Biplanar420Unorm:
// TODO(dawn:666): implement stencil8 // TODO(dawn:666): implement stencil8
case wgpu::TextureFormat::Stencil8: case wgpu::TextureFormat::Stencil8:
// TODO(dawn:690): implement depth24unorm-stencil8
case wgpu::TextureFormat::Depth24UnormStencil8:
// TODO(dawn:690): implement depth32float-stencil8
case wgpu::TextureFormat::Depth32FloatStencil8:
case wgpu::TextureFormat::Undefined: case wgpu::TextureFormat::Undefined:
break; break;
} }

View File

@ -33,6 +33,33 @@ class ReadOnlyDepthStencilAttachmentTests
uint32_t stencilInitValue; uint32_t stencilInitValue;
uint32_t stencilRefValue; uint32_t stencilRefValue;
}; };
std::vector<const char*> GetRequiredFeatures() override {
switch (GetParam().mTextureFormat) {
case wgpu::TextureFormat::Depth24UnormStencil8:
if (SupportsFeatures({"depth24unorm-stencil8"})) {
mIsFormatSupported = true;
return {"depth24unorm-stencil8"};
}
return {};
case wgpu::TextureFormat::Depth32FloatStencil8:
if (SupportsFeatures({"depth32float-stencil8"})) {
mIsFormatSupported = true;
return {"depth32float-stencil8"};
}
return {};
default:
mIsFormatSupported = true;
return {};
}
}
bool IsFormatSupported() const {
return mIsFormatSupported;
}
wgpu::RenderPipeline CreateRenderPipeline(wgpu::TextureAspect aspect, wgpu::RenderPipeline CreateRenderPipeline(wgpu::TextureAspect aspect,
wgpu::TextureFormat format) { wgpu::TextureFormat format) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor; utils::ComboRenderPipelineDescriptor pipelineDescriptor;
@ -158,9 +185,18 @@ class ReadOnlyDepthStencilAttachmentTests
wgpu::CommandBuffer commands = commandEncoder.Finish(); wgpu::CommandBuffer commands = commandEncoder.Finish();
queue.Submit(1, &commands); queue.Submit(1, &commands);
} }
private:
bool mIsFormatSupported = false;
}; };
class ReadOnlyDepthAttachmentTests : public ReadOnlyDepthStencilAttachmentTests {}; class ReadOnlyDepthAttachmentTests : public ReadOnlyDepthStencilAttachmentTests {
protected:
void SetUp() override {
ReadOnlyDepthStencilAttachmentTests::SetUp();
DAWN_TEST_UNSUPPORTED_IF(!IsFormatSupported());
}
};
TEST_P(ReadOnlyDepthAttachmentTests, Test) { TEST_P(ReadOnlyDepthAttachmentTests, Test) {
wgpu::Texture colorTexture = wgpu::Texture colorTexture =
@ -185,7 +221,13 @@ TEST_P(ReadOnlyDepthAttachmentTests, Test) {
{kSize, kSize / 2}); {kSize, kSize / 2});
} }
class ReadOnlyStencilAttachmentTests : public ReadOnlyDepthStencilAttachmentTests {}; class ReadOnlyStencilAttachmentTests : public ReadOnlyDepthStencilAttachmentTests {
protected:
void SetUp() override {
ReadOnlyDepthStencilAttachmentTests::SetUp();
DAWN_TEST_UNSUPPORTED_IF(!IsFormatSupported());
}
};
TEST_P(ReadOnlyStencilAttachmentTests, Test) { TEST_P(ReadOnlyStencilAttachmentTests, Test) {
wgpu::Texture colorTexture = wgpu::Texture colorTexture =

View File

@ -28,6 +28,11 @@ namespace {
wgpu::TextureFormat::RGBA8Snorm, wgpu::TextureFormat::RGBA8Snorm,
}; };
wgpu::TextureDimension kDimensions[] = {
wgpu::TextureDimension::e1D,
wgpu::TextureDimension::e3D,
};
class TextureValidationTest : public ValidationTest { class TextureValidationTest : public ValidationTest {
protected: protected:
void SetUp() override { void SetUp() override {
@ -426,21 +431,13 @@ namespace {
TEST_F(TextureValidationTest, DepthStencilFormatsFor3D) { TEST_F(TextureValidationTest, DepthStencilFormatsFor3D) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor(); wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
wgpu::TextureDimension dimensions[] = {
wgpu::TextureDimension::e1D,
wgpu::TextureDimension::e3D,
};
// TODO(dawn:690): Uncomment these depth/stencil formats after we implement them in Dawn.
wgpu::TextureFormat depthStencilFormats[] = { wgpu::TextureFormat depthStencilFormats[] = {
wgpu::TextureFormat::Stencil8, wgpu::TextureFormat::Depth16Unorm, wgpu::TextureFormat::Stencil8, wgpu::TextureFormat::Depth16Unorm,
wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth32Float,
// wgpu::TextureFormat::Depth24UnormStencil8,
// wgpu::TextureFormat::Depth32FloatStencil8,
}; };
for (wgpu::TextureDimension dimension : dimensions) { for (wgpu::TextureDimension dimension : kDimensions) {
for (wgpu::TextureFormat format : depthStencilFormats) { for (wgpu::TextureFormat format : depthStencilFormats) {
descriptor.format = format; descriptor.format = format;
descriptor.dimension = dimension; descriptor.dimension = dimension;
@ -551,6 +548,22 @@ namespace {
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
} }
// Test that the creation of a texture with depth24unorm-stencil8 will fail when the feature
// Depth24UnormStencil8 is not enabled.
TEST_F(TextureValidationTest, UseD24S8FormatWithoutEnablingFeature) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = wgpu::TextureFormat::Depth24UnormStencil8;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}
// Test that the creation of a texture with depth32float-stencil8 will fail when the feature
// Depth32FloatStencil8 is not enabled.
TEST_F(TextureValidationTest, UseD32S8FormatWithoutEnablingFeature) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
descriptor.format = wgpu::TextureFormat::Depth32FloatStencil8;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}
// Test that the creation of a texture with BC format will fail when the feature // Test that the creation of a texture with BC format will fail when the feature
// textureCompressionBC is not enabled. // textureCompressionBC is not enabled.
TEST_F(TextureValidationTest, UseBCFormatWithoutEnablingFeature) { TEST_F(TextureValidationTest, UseBCFormatWithoutEnablingFeature) {
@ -581,6 +594,46 @@ namespace {
} }
} }
class D24S8TextureFormatsValidationTests : public TextureValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth24unorm-stencil8"};
return adapter.CreateDevice(&descriptor);
}
};
// Test that depth24unorm-stencil8 format is invalid for 3D texture
TEST_F(D24S8TextureFormatsValidationTests, DepthStencilFormatsFor3D) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
for (wgpu::TextureDimension dimension : kDimensions) {
descriptor.format = wgpu::TextureFormat::Depth24UnormStencil8;
descriptor.dimension = dimension;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}
}
class D32S8TextureFormatsValidationTests : public TextureValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth32float-stencil8"};
return adapter.CreateDevice(&descriptor);
}
};
// Test that depth32float-stencil8 format is invalid for 3D texture
TEST_F(D32S8TextureFormatsValidationTests, DepthStencilFormatsFor3D) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
for (wgpu::TextureDimension dimension : kDimensions) {
descriptor.format = wgpu::TextureFormat::Depth32FloatStencil8;
descriptor.dimension = dimension;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}
}
// TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with // TODO(jiawei.shao@intel.com): add tests to verify we cannot create 1D or 3D textures with
// compressed texture formats. // compressed texture formats.
class CompressedTextureFormatsValidationTests : public TextureValidationTest { class CompressedTextureFormatsValidationTests : public TextureValidationTest {

View File

@ -54,6 +54,16 @@ namespace {
return device.CreateTexture(&descriptor); return device.CreateTexture(&descriptor);
} }
wgpu::Texture CreateDepthStencilTexture(wgpu::Device& device, wgpu::TextureFormat format) {
wgpu::TextureDescriptor descriptor = {};
descriptor.size = {kWidth, kHeight, kDepth};
descriptor.usage =
wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::RenderAttachment;
descriptor.mipLevelCount = kDefaultMipLevels;
descriptor.format = format;
return device.CreateTexture(&descriptor);
}
wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) { wgpu::TextureViewDescriptor CreateDefaultViewDescriptor(wgpu::TextureViewDimension dimension) {
wgpu::TextureViewDescriptor descriptor; wgpu::TextureViewDescriptor descriptor;
descriptor.format = kDefaultTextureFormat; descriptor.format = kDefaultTextureFormat;
@ -639,4 +649,92 @@ namespace {
} }
} }
class D24S8TextureViewValidationTests : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth24unorm-stencil8"};
return adapter.CreateDevice(&descriptor);
}
};
// Test that the selected TextureAspects must exist in the Depth24UnormStencil8 texture format
TEST_F(D24S8TextureViewValidationTests, AspectMustExist) {
wgpu::Texture texture =
CreateDepthStencilTexture(device, wgpu::TextureFormat::Depth24UnormStencil8);
// Can select: All, DepthOnly, and StencilOnly from Depth24UnormStencil8
{
wgpu::TextureViewDescriptor viewDescriptor = {};
viewDescriptor.aspect = wgpu::TextureAspect::All;
texture.CreateView(&viewDescriptor);
viewDescriptor.aspect = wgpu::TextureAspect::DepthOnly;
texture.CreateView(&viewDescriptor);
viewDescriptor.aspect = wgpu::TextureAspect::StencilOnly;
texture.CreateView(&viewDescriptor);
}
}
// Test the format compatibility rules when creating a texture view.
TEST_F(D24S8TextureViewValidationTests, TextureViewFormatCompatibility) {
wgpu::Texture texture =
CreateDepthStencilTexture(device, wgpu::TextureFormat::Depth24UnormStencil8);
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
// It is an error to create a texture view in color format on a depth-stencil texture.
{
wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
}
class D32S8TextureViewValidationTests : public ValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor;
descriptor.requiredFeatures = {"depth32float-stencil8"};
return adapter.CreateDevice(&descriptor);
}
};
// Test that the selected TextureAspects must exist in the Depth32FloatStencil8 texture format
TEST_F(D32S8TextureViewValidationTests, AspectMustExist) {
wgpu::Texture texture =
CreateDepthStencilTexture(device, wgpu::TextureFormat::Depth32FloatStencil8);
// Can select: All, DepthOnly, and StencilOnly from Depth32FloatStencil8
{
wgpu::TextureViewDescriptor viewDescriptor = {};
viewDescriptor.aspect = wgpu::TextureAspect::All;
texture.CreateView(&viewDescriptor);
viewDescriptor.aspect = wgpu::TextureAspect::DepthOnly;
texture.CreateView(&viewDescriptor);
viewDescriptor.aspect = wgpu::TextureAspect::StencilOnly;
texture.CreateView(&viewDescriptor);
}
}
// Test the format compatibility rules when creating a texture view.
TEST_F(D32S8TextureViewValidationTests, TextureViewFormatCompatibility) {
wgpu::Texture texture =
CreateDepthStencilTexture(device, wgpu::TextureFormat::Depth32FloatStencil8);
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
// It is an error to create a texture view in color format on a depth-stencil texture.
{
wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.format = wgpu::TextureFormat::RGBA8Unorm;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
}
} // anonymous namespace } // anonymous namespace

View File

@ -233,6 +233,8 @@ namespace utils {
case wgpu::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24Plus:
case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
case wgpu::TextureFormat::Depth24UnormStencil8:
case wgpu::TextureFormat::Depth32FloatStencil8:
// Block size of a multi-planar format depends on aspect. // Block size of a multi-planar format depends on aspect.
case wgpu::TextureFormat::R8BG8Biplanar420Unorm: case wgpu::TextureFormat::R8BG8Biplanar420Unorm:
@ -287,6 +289,8 @@ namespace utils {
case wgpu::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24Plus:
case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
case wgpu::TextureFormat::Depth16Unorm: case wgpu::TextureFormat::Depth16Unorm:
case wgpu::TextureFormat::Depth24UnormStencil8:
case wgpu::TextureFormat::Depth32FloatStencil8:
return 1u; return 1u;
case wgpu::TextureFormat::BC1RGBAUnorm: case wgpu::TextureFormat::BC1RGBAUnorm:
@ -403,6 +407,8 @@ namespace utils {
case wgpu::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24Plus:
case wgpu::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
case wgpu::TextureFormat::Depth16Unorm: case wgpu::TextureFormat::Depth16Unorm:
case wgpu::TextureFormat::Depth24UnormStencil8:
case wgpu::TextureFormat::Depth32FloatStencil8:
return 1u; return 1u;
case wgpu::TextureFormat::BC1RGBAUnorm: case wgpu::TextureFormat::BC1RGBAUnorm:

View File

@ -22,7 +22,8 @@
#include "common/Assert.h" #include "common/Assert.h"
namespace utils { namespace utils {
static constexpr std::array<wgpu::TextureFormat, 91> kAllTextureFormats = { // TODO(dawn:666, 570): Add Stencil8, Depth16Unorm formats if they are implemented.
static constexpr std::array<wgpu::TextureFormat, 93> kAllTextureFormats = {
wgpu::TextureFormat::R8Unorm, wgpu::TextureFormat::R8Unorm,
wgpu::TextureFormat::R8Snorm, wgpu::TextureFormat::R8Snorm,
wgpu::TextureFormat::R8Uint, wgpu::TextureFormat::R8Uint,
@ -62,6 +63,8 @@ namespace utils {
wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth32Float,
wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24Plus,
wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureFormat::Depth24UnormStencil8,
wgpu::TextureFormat::Depth32FloatStencil8,
wgpu::TextureFormat::BC1RGBAUnorm, wgpu::TextureFormat::BC1RGBAUnorm,
wgpu::TextureFormat::BC1RGBAUnormSrgb, wgpu::TextureFormat::BC1RGBAUnormSrgb,
wgpu::TextureFormat::BC2RGBAUnorm, wgpu::TextureFormat::BC2RGBAUnorm,
@ -179,18 +182,22 @@ namespace utils {
kBCFormats.size() + kETC2Formats.size() + kASTCFormats.size(), kBCFormats.size() + kETC2Formats.size() + kASTCFormats.size(),
"Number of compressed format must equal number of BC, ETC2, and ASTC formats."); "Number of compressed format must equal number of BC, ETC2, and ASTC formats.");
// TODO(dawn:666, 570, 690): Add more depth/stencil formats if Stencil8, Depth16Unorm, // TODO(dawn:666, 570): Add more depth/stencil formats if Stencil8, Depth16Unorm are
// Depth24UnormStencil8, Depth32FloatStencil8 are implemented. // implemented.
static constexpr std::array<wgpu::TextureFormat, 3> kDepthFormats = { static constexpr std::array<wgpu::TextureFormat, 5> kDepthFormats = {
wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth24Plus,
wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth24UnormStencil8,
wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth32FloatStencil8,
}; };
static constexpr std::array<wgpu::TextureFormat, 1> kStencilFormats = { static constexpr std::array<wgpu::TextureFormat, 3> kStencilFormats = {
wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureFormat::Depth24UnormStencil8,
wgpu::TextureFormat::Depth32FloatStencil8,
}; };
static constexpr std::array<wgpu::TextureFormat, 1> kDepthAndStencilFormats = { static constexpr std::array<wgpu::TextureFormat, 3> kDepthAndStencilFormats = {
wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth24PlusStencil8,
wgpu::TextureFormat::Depth24UnormStencil8,
wgpu::TextureFormat::Depth32FloatStencil8,
}; };
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format); bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format);