mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 00:17:03 +00:00
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:
@@ -64,6 +64,14 @@ namespace dawn_native {
|
||||
{"depth-clamping", "Clamp depth to [0, 1] in NDC space instead of clipping",
|
||||
"https://bugs.chromium.org/p/dawn/issues/detail?id=716"},
|
||||
&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,
|
||||
{"dawn-internal-usages",
|
||||
"Add internal usages to resources to affect how the texture is allocated, but not "
|
||||
|
||||
@@ -31,6 +31,8 @@ namespace dawn_native {
|
||||
PipelineStatisticsQuery,
|
||||
TimestampQuery,
|
||||
DepthClamping,
|
||||
Depth24UnormStencil8,
|
||||
Depth32FloatStencil8,
|
||||
|
||||
// Dawn-specific
|
||||
DawnInternalUsages,
|
||||
|
||||
@@ -335,8 +335,13 @@ namespace dawn_native {
|
||||
AddDepthFormat(wgpu::TextureFormat::Depth24Plus, 4, true);
|
||||
AddMultiAspectFormat(wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
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);
|
||||
// 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
|
||||
bool isBCFormatSupported = device->IsFeatureEnabled(Feature::TextureCompressionBC);
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace dawn_native {
|
||||
|
||||
// The number of formats Dawn knows about. Asserts in BuildFormatTable ensure that this is the
|
||||
// exact number of known format.
|
||||
static constexpr size_t kKnownFormatCount = 94;
|
||||
static constexpr size_t kKnownFormatCount = 96;
|
||||
|
||||
struct Format;
|
||||
using FormatTable = std::array<Format, kKnownFormatCount>;
|
||||
|
||||
@@ -252,6 +252,10 @@ namespace dawn_native { namespace d3d12 {
|
||||
case wgpu::TextureFormat::R8BG8Biplanar420Unorm:
|
||||
// TODO(dawn:666): implement 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:
|
||||
UNREACHABLE();
|
||||
}
|
||||
@@ -421,6 +425,10 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
// TODO(dawn:666): implement 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:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -321,6 +321,10 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
// TODO(dawn:666): implement 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:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
@@ -40,6 +40,16 @@ namespace dawn_native { namespace vulkan {
|
||||
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() {
|
||||
DAWN_TRY_ASSIGN(mDeviceInfo, GatherDeviceInfo(*this));
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ namespace dawn_native { namespace vulkan {
|
||||
VkPhysicalDevice GetPhysicalDevice() const;
|
||||
Backend* GetBackend() const;
|
||||
|
||||
bool IsDepthStencilFormatSupported(VkFormat format);
|
||||
|
||||
private:
|
||||
MaybeError InitializeImpl() override;
|
||||
MaybeError InitializeSupportedFeaturesImpl() override;
|
||||
|
||||
@@ -497,25 +497,10 @@ namespace dawn_native { namespace vulkan {
|
||||
}
|
||||
|
||||
void Device::ApplyDepth24PlusS8Toggle() {
|
||||
VkPhysicalDevice physicalDevice = ToBackend(GetAdapter())->GetPhysicalDevice();
|
||||
|
||||
bool supportsD32s8 = false;
|
||||
{
|
||||
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;
|
||||
}
|
||||
bool supportsD32s8 =
|
||||
ToBackend(GetAdapter())->IsDepthStencilFormatSupported(VK_FORMAT_D32_SFLOAT_S8_UINT);
|
||||
bool supportsD24s8 =
|
||||
ToBackend(GetAdapter())->IsDepthStencilFormatSupported(VK_FORMAT_D24_UNORM_S8_UINT);
|
||||
|
||||
ASSERT(supportsD32s8 || supportsD24s8);
|
||||
|
||||
|
||||
@@ -419,6 +419,10 @@ namespace dawn_native { namespace vulkan {
|
||||
case wgpu::TextureFormat::R8BG8Biplanar420Unorm:
|
||||
// TODO(dawn:666): implement 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:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,33 @@ class ReadOnlyDepthStencilAttachmentTests
|
||||
uint32_t stencilInitValue;
|
||||
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::TextureFormat format) {
|
||||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
@@ -158,9 +185,18 @@ class ReadOnlyDepthStencilAttachmentTests
|
||||
wgpu::CommandBuffer commands = commandEncoder.Finish();
|
||||
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) {
|
||||
wgpu::Texture colorTexture =
|
||||
@@ -185,7 +221,13 @@ TEST_P(ReadOnlyDepthAttachmentTests, Test) {
|
||||
{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) {
|
||||
wgpu::Texture colorTexture =
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace {
|
||||
wgpu::TextureFormat::RGBA8Snorm,
|
||||
};
|
||||
|
||||
wgpu::TextureDimension kDimensions[] = {
|
||||
wgpu::TextureDimension::e1D,
|
||||
wgpu::TextureDimension::e3D,
|
||||
};
|
||||
|
||||
class TextureValidationTest : public ValidationTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
@@ -426,21 +431,13 @@ namespace {
|
||||
TEST_F(TextureValidationTest, DepthStencilFormatsFor3D) {
|
||||
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::Stencil8, wgpu::TextureFormat::Depth16Unorm,
|
||||
wgpu::TextureFormat::Depth24Plus, wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
wgpu::TextureFormat::Depth32Float,
|
||||
// wgpu::TextureFormat::Depth24UnormStencil8,
|
||||
// wgpu::TextureFormat::Depth32FloatStencil8,
|
||||
};
|
||||
|
||||
for (wgpu::TextureDimension dimension : dimensions) {
|
||||
for (wgpu::TextureDimension dimension : kDimensions) {
|
||||
for (wgpu::TextureFormat format : depthStencilFormats) {
|
||||
descriptor.format = format;
|
||||
descriptor.dimension = dimension;
|
||||
@@ -551,6 +548,22 @@ namespace {
|
||||
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
|
||||
// textureCompressionBC is not enabled.
|
||||
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
|
||||
// compressed texture formats.
|
||||
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
|
||||
|
||||
@@ -54,6 +54,16 @@ namespace {
|
||||
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 descriptor;
|
||||
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
|
||||
|
||||
@@ -233,6 +233,8 @@ namespace utils {
|
||||
|
||||
case wgpu::TextureFormat::Depth24Plus:
|
||||
case wgpu::TextureFormat::Depth24PlusStencil8:
|
||||
case wgpu::TextureFormat::Depth24UnormStencil8:
|
||||
case wgpu::TextureFormat::Depth32FloatStencil8:
|
||||
|
||||
// Block size of a multi-planar format depends on aspect.
|
||||
case wgpu::TextureFormat::R8BG8Biplanar420Unorm:
|
||||
@@ -287,6 +289,8 @@ namespace utils {
|
||||
case wgpu::TextureFormat::Depth24Plus:
|
||||
case wgpu::TextureFormat::Depth24PlusStencil8:
|
||||
case wgpu::TextureFormat::Depth16Unorm:
|
||||
case wgpu::TextureFormat::Depth24UnormStencil8:
|
||||
case wgpu::TextureFormat::Depth32FloatStencil8:
|
||||
return 1u;
|
||||
|
||||
case wgpu::TextureFormat::BC1RGBAUnorm:
|
||||
@@ -403,6 +407,8 @@ namespace utils {
|
||||
case wgpu::TextureFormat::Depth24Plus:
|
||||
case wgpu::TextureFormat::Depth24PlusStencil8:
|
||||
case wgpu::TextureFormat::Depth16Unorm:
|
||||
case wgpu::TextureFormat::Depth24UnormStencil8:
|
||||
case wgpu::TextureFormat::Depth32FloatStencil8:
|
||||
return 1u;
|
||||
|
||||
case wgpu::TextureFormat::BC1RGBAUnorm:
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
#include "common/Assert.h"
|
||||
|
||||
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::R8Snorm,
|
||||
wgpu::TextureFormat::R8Uint,
|
||||
@@ -62,6 +63,8 @@ namespace utils {
|
||||
wgpu::TextureFormat::Depth32Float,
|
||||
wgpu::TextureFormat::Depth24Plus,
|
||||
wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
wgpu::TextureFormat::Depth24UnormStencil8,
|
||||
wgpu::TextureFormat::Depth32FloatStencil8,
|
||||
wgpu::TextureFormat::BC1RGBAUnorm,
|
||||
wgpu::TextureFormat::BC1RGBAUnormSrgb,
|
||||
wgpu::TextureFormat::BC2RGBAUnorm,
|
||||
@@ -179,18 +182,22 @@ namespace utils {
|
||||
kBCFormats.size() + kETC2Formats.size() + kASTCFormats.size(),
|
||||
"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,
|
||||
// Depth24UnormStencil8, Depth32FloatStencil8 are implemented.
|
||||
static constexpr std::array<wgpu::TextureFormat, 3> kDepthFormats = {
|
||||
wgpu::TextureFormat::Depth32Float,
|
||||
wgpu::TextureFormat::Depth24Plus,
|
||||
wgpu::TextureFormat::Depth24PlusStencil8,
|
||||
// TODO(dawn:666, 570): Add more depth/stencil formats if Stencil8, Depth16Unorm are
|
||||
// implemented.
|
||||
static constexpr std::array<wgpu::TextureFormat, 5> kDepthFormats = {
|
||||
wgpu::TextureFormat::Depth32Float, wgpu::TextureFormat::Depth24Plus,
|
||||
wgpu::TextureFormat::Depth24PlusStencil8, wgpu::TextureFormat::Depth24UnormStencil8,
|
||||
wgpu::TextureFormat::Depth32FloatStencil8,
|
||||
};
|
||||
static constexpr std::array<wgpu::TextureFormat, 1> kStencilFormats = {
|
||||
static constexpr std::array<wgpu::TextureFormat, 3> kStencilFormats = {
|
||||
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::Depth24UnormStencil8,
|
||||
wgpu::TextureFormat::Depth32FloatStencil8,
|
||||
};
|
||||
|
||||
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format);
|
||||
|
||||
Reference in New Issue
Block a user