Adds placeholders for ETC2/ASTC compression texture format
Compatible Vulkan backends should now enable ETC2/ASTC but no functional changes because no TextureFormat in ETC2 or ASTC have been added yet. Bug: dawn:955 Change-Id: I56e8ff73f931a12253fe6d21f3f4b91e3459ef13 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/62701 Commit-Queue: Loko Kung <lokokung@google.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
2db24d6bd2
commit
c1d395865f
|
@ -875,6 +875,8 @@
|
||||||
"extensible": false,
|
"extensible": false,
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "texture compression BC", "type": "bool", "default": "false"},
|
{"name": "texture compression BC", "type": "bool", "default": "false"},
|
||||||
|
{"name": "texture compression ETC2", "type": "bool", "default": "false"},
|
||||||
|
{"name": "texture compression ASTC", "type": "bool", "default": "false"},
|
||||||
{"name": "shader float16", "type": "bool", "default": "false"},
|
{"name": "shader float16", "type": "bool", "default": "false"},
|
||||||
{"name": "pipeline statistics query", "type": "bool", "default": "false"},
|
{"name": "pipeline statistics query", "type": "bool", "default": "false"},
|
||||||
{"name": "timestamp query", "type": "bool", "default": "false"},
|
{"name": "timestamp query", "type": "bool", "default": "false"},
|
||||||
|
|
|
@ -35,6 +35,18 @@ namespace dawn_native {
|
||||||
{"texture_compression_bc", "Support Block Compressed (BC) texture formats",
|
{"texture_compression_bc", "Support Block Compressed (BC) texture formats",
|
||||||
"https://bugs.chromium.org/p/dawn/issues/detail?id=42"},
|
"https://bugs.chromium.org/p/dawn/issues/detail?id=42"},
|
||||||
&WGPUDeviceProperties::textureCompressionBC},
|
&WGPUDeviceProperties::textureCompressionBC},
|
||||||
|
{Extension::TextureCompressionETC2,
|
||||||
|
{"texture-compression-etc2",
|
||||||
|
"Support Ericsson Texture Compressed (ETC2/EAC) texture "
|
||||||
|
"formats",
|
||||||
|
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"},
|
||||||
|
&WGPUDeviceProperties::textureCompressionETC2},
|
||||||
|
{Extension::TextureCompressionASTC,
|
||||||
|
{"texture-compression-astc",
|
||||||
|
"Support Adaptable Scalable Texture Compressed (ASTC) "
|
||||||
|
"texture formats",
|
||||||
|
"https://bugs.chromium.org/p/dawn/issues/detail?id=955"},
|
||||||
|
&WGPUDeviceProperties::textureCompressionASTC},
|
||||||
{Extension::ShaderFloat16,
|
{Extension::ShaderFloat16,
|
||||||
{"shader_float16",
|
{"shader_float16",
|
||||||
"Support 16bit float arithmetic and declarations in uniform and storage buffers",
|
"Support 16bit float arithmetic and declarations in uniform and storage buffers",
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace dawn_native {
|
||||||
|
|
||||||
enum class Extension {
|
enum class Extension {
|
||||||
TextureCompressionBC,
|
TextureCompressionBC,
|
||||||
|
TextureCompressionETC2,
|
||||||
|
TextureCompressionASTC,
|
||||||
ShaderFloat16,
|
ShaderFloat16,
|
||||||
PipelineStatisticsQuery,
|
PipelineStatisticsQuery,
|
||||||
TimestampQuery,
|
TimestampQuery,
|
||||||
|
|
|
@ -88,9 +88,12 @@ namespace dawn_native { namespace vulkan {
|
||||||
return DAWN_INTERNAL_ERROR("Vulkan robustBufferAccess feature required.");
|
return DAWN_INTERNAL_ERROR("Vulkan robustBufferAccess feature required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(crbug.com/dawn/955): Require BC || (ETC && ASTC) instead.
|
if (!mDeviceInfo.features.textureCompressionBC &&
|
||||||
if (!mDeviceInfo.features.textureCompressionBC) {
|
!(mDeviceInfo.features.textureCompressionETC2 &&
|
||||||
return DAWN_INTERNAL_ERROR("Vulkan textureCompressionBC feature required.");
|
mDeviceInfo.features.textureCompressionASTC_LDR)) {
|
||||||
|
return DAWN_INTERNAL_ERROR(
|
||||||
|
"Vulkan textureCompressionBC feature required or both textureCompressionETC2 and "
|
||||||
|
"textureCompressionASTC required.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for the respective WebGPU features.
|
// Needed for the respective WebGPU features.
|
||||||
|
@ -263,6 +266,14 @@ namespace dawn_native { namespace vulkan {
|
||||||
mSupportedExtensions.EnableExtension(Extension::TextureCompressionBC);
|
mSupportedExtensions.EnableExtension(Extension::TextureCompressionBC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mDeviceInfo.features.textureCompressionETC2 == VK_TRUE) {
|
||||||
|
mSupportedExtensions.EnableExtension(Extension::TextureCompressionETC2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mDeviceInfo.features.textureCompressionASTC_LDR == VK_TRUE) {
|
||||||
|
mSupportedExtensions.EnableExtension(Extension::TextureCompressionASTC);
|
||||||
|
}
|
||||||
|
|
||||||
if (mDeviceInfo.features.pipelineStatisticsQuery == VK_TRUE) {
|
if (mDeviceInfo.features.pipelineStatisticsQuery == VK_TRUE) {
|
||||||
mSupportedExtensions.EnableExtension(Extension::PipelineStatisticsQuery);
|
mSupportedExtensions.EnableExtension(Extension::PipelineStatisticsQuery);
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,6 +348,18 @@ namespace dawn_native { namespace vulkan {
|
||||||
usedKnobs.features.textureCompressionBC = VK_TRUE;
|
usedKnobs.features.textureCompressionBC = VK_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsExtensionEnabled(Extension::TextureCompressionETC2)) {
|
||||||
|
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionETC2 ==
|
||||||
|
VK_TRUE);
|
||||||
|
usedKnobs.features.textureCompressionETC2 = VK_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsExtensionEnabled(Extension::TextureCompressionASTC)) {
|
||||||
|
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.textureCompressionASTC_LDR ==
|
||||||
|
VK_TRUE);
|
||||||
|
usedKnobs.features.textureCompressionASTC_LDR = VK_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsExtensionEnabled(Extension::PipelineStatisticsQuery)) {
|
if (IsExtensionEnabled(Extension::PipelineStatisticsQuery)) {
|
||||||
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.pipelineStatisticsQuery ==
|
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.pipelineStatisticsQuery ==
|
||||||
VK_TRUE);
|
VK_TRUE);
|
||||||
|
|
|
@ -541,13 +541,34 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test that the creation of a texture with ETC2 format will fail when the extension
|
||||||
|
// textureCompressionETC2 is not enabled.
|
||||||
|
TEST_F(TextureValidationTest, UseETC2FormatWithoutEnablingExtension) {
|
||||||
|
for (wgpu::TextureFormat format : utils::kETC2Formats) {
|
||||||
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
descriptor.format = format;
|
||||||
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that the creation of a texture with ASTC format will fail when the extension
|
||||||
|
// textureCompressionASTC is not enabled.
|
||||||
|
TEST_F(TextureValidationTest, UseASTCFormatWithoutEnablingExtension) {
|
||||||
|
for (wgpu::TextureFormat format : utils::kASTCFormats) {
|
||||||
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
descriptor.format = format;
|
||||||
|
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 {
|
||||||
protected:
|
protected:
|
||||||
WGPUDevice CreateTestDevice() override {
|
WGPUDevice CreateTestDevice() override {
|
||||||
dawn_native::DeviceDescriptor descriptor;
|
dawn_native::DeviceDescriptor descriptor;
|
||||||
descriptor.requiredExtensions = {"texture_compression_bc"};
|
descriptor.requiredExtensions = {"texture_compression_bc", "texture-compression-etc2",
|
||||||
|
"texture-compression-astc"};
|
||||||
return adapter.CreateDevice(&descriptor);
|
return adapter.CreateDevice(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,9 +581,8 @@ namespace {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Test the validation of texture size when creating textures in compressed texture formats.
|
// Test that it is invalid to use a number that is not a multiple of 4 (the compressed block
|
||||||
// It is invalid to use a number that is not a multiple of 4 (the compressed block width and
|
// width and height of all BC formats) as the width or height in BC formats.
|
||||||
// height of all BC formats) as the width or height of textures in BC formats.
|
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
|
||||||
for (wgpu::TextureFormat format : utils::kBCFormats) {
|
for (wgpu::TextureFormat format : utils::kBCFormats) {
|
||||||
{
|
{
|
||||||
|
@ -596,9 +616,7 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the validation of texture usages when creating textures in compressed texture formats.
|
// Test that only CopySrc, CopyDst and Sampled are accepted as usage in compressed formats.
|
||||||
// Only CopySrc, CopyDst and Sampled are accepted as the texture usage of the textures in BC
|
|
||||||
// formats.
|
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
|
||||||
wgpu::TextureUsage invalidUsages[] = {
|
wgpu::TextureUsage invalidUsages[] = {
|
||||||
wgpu::TextureUsage::RenderAttachment,
|
wgpu::TextureUsage::RenderAttachment,
|
||||||
|
@ -613,6 +631,22 @@ namespace {
|
||||||
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (wgpu::TextureFormat format : utils::kETC2Formats) {
|
||||||
|
for (wgpu::TextureUsage usage : invalidUsages) {
|
||||||
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
descriptor.format = format;
|
||||||
|
descriptor.usage = usage;
|
||||||
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (wgpu::TextureFormat format : utils::kASTCFormats) {
|
||||||
|
for (wgpu::TextureUsage usage : invalidUsages) {
|
||||||
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
descriptor.format = format;
|
||||||
|
descriptor.usage = usage;
|
||||||
|
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, MipLevelCount) {
|
TEST_F(CompressedTextureFormatsValidationTests, MipLevelCount) {
|
||||||
|
@ -626,8 +660,7 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test the validation of sample count when creating textures in compressed texture formats.
|
// Test that it is invalid to specify SampleCount>1 in BC formats.
|
||||||
// It is invalid to specify SampleCount > 1 when we create a texture in BC formats.
|
|
||||||
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
|
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
|
||||||
for (wgpu::TextureFormat format : utils::kBCFormats) {
|
for (wgpu::TextureFormat format : utils::kBCFormats) {
|
||||||
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();
|
||||||
|
|
|
@ -87,6 +87,10 @@ namespace utils {
|
||||||
wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBFloat,
|
wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBFloat,
|
||||||
wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb};
|
wgpu::TextureFormat::BC7RGBAUnorm, wgpu::TextureFormat::BC7RGBAUnormSrgb};
|
||||||
|
|
||||||
|
// TODO(crbug.com/dawn/955) Add formats once implemented.
|
||||||
|
static constexpr std::array<wgpu::TextureFormat, 0> kETC2Formats = {};
|
||||||
|
static constexpr std::array<wgpu::TextureFormat, 0> kASTCFormats = {};
|
||||||
|
|
||||||
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format);
|
bool TextureFormatSupportsStorageTexture(wgpu::TextureFormat format);
|
||||||
|
|
||||||
uint32_t GetTexelBlockSizeInBytes(wgpu::TextureFormat textureFormat);
|
uint32_t GetTexelBlockSizeInBytes(wgpu::TextureFormat textureFormat);
|
||||||
|
|
Loading…
Reference in New Issue