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:
Loko Kung 2021-08-25 00:53:42 +00:00 committed by Dawn LUCI CQ
parent 2db24d6bd2
commit c1d395865f
7 changed files with 88 additions and 12 deletions

View File

@ -875,6 +875,8 @@
"extensible": false,
"members": [
{"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": "pipeline statistics query", "type": "bool", "default": "false"},
{"name": "timestamp query", "type": "bool", "default": "false"},

View File

@ -35,6 +35,18 @@ namespace dawn_native {
{"texture_compression_bc", "Support Block Compressed (BC) texture formats",
"https://bugs.chromium.org/p/dawn/issues/detail?id=42"},
&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,
{"shader_float16",
"Support 16bit float arithmetic and declarations in uniform and storage buffers",

View File

@ -25,6 +25,8 @@ namespace dawn_native {
enum class Extension {
TextureCompressionBC,
TextureCompressionETC2,
TextureCompressionASTC,
ShaderFloat16,
PipelineStatisticsQuery,
TimestampQuery,

View File

@ -88,9 +88,12 @@ namespace dawn_native { namespace vulkan {
return DAWN_INTERNAL_ERROR("Vulkan robustBufferAccess feature required.");
}
// TODO(crbug.com/dawn/955): Require BC || (ETC && ASTC) instead.
if (!mDeviceInfo.features.textureCompressionBC) {
return DAWN_INTERNAL_ERROR("Vulkan textureCompressionBC feature required.");
if (!mDeviceInfo.features.textureCompressionBC &&
!(mDeviceInfo.features.textureCompressionETC2 &&
mDeviceInfo.features.textureCompressionASTC_LDR)) {
return DAWN_INTERNAL_ERROR(
"Vulkan textureCompressionBC feature required or both textureCompressionETC2 and "
"textureCompressionASTC required.");
}
// Needed for the respective WebGPU features.
@ -263,6 +266,14 @@ namespace dawn_native { namespace vulkan {
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) {
mSupportedExtensions.EnableExtension(Extension::PipelineStatisticsQuery);
}

View File

@ -348,6 +348,18 @@ namespace dawn_native { namespace vulkan {
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)) {
ASSERT(ToBackend(GetAdapter())->GetDeviceInfo().features.pipelineStatisticsQuery ==
VK_TRUE);

View File

@ -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
// compressed texture formats.
class CompressedTextureFormatsValidationTests : public TextureValidationTest {
protected:
WGPUDevice CreateTestDevice() override {
dawn_native::DeviceDescriptor descriptor;
descriptor.requiredExtensions = {"texture_compression_bc"};
descriptor.requiredExtensions = {"texture_compression_bc", "texture-compression-etc2",
"texture-compression-astc"};
return adapter.CreateDevice(&descriptor);
}
@ -560,9 +581,8 @@ namespace {
}
};
// Test the validation of texture size when creating textures in compressed texture formats.
// It is invalid to use a number that is not a multiple of 4 (the compressed block width and
// height of all BC formats) as the width or height of textures in BC formats.
// Test that it is invalid to use a number that is not a multiple of 4 (the compressed block
// width and height of all BC formats) as the width or height in BC formats.
TEST_F(CompressedTextureFormatsValidationTests, TextureSize) {
for (wgpu::TextureFormat format : utils::kBCFormats) {
{
@ -596,9 +616,7 @@ namespace {
}
}
// Test the validation of texture usages when creating textures in compressed texture formats.
// Only CopySrc, CopyDst and Sampled are accepted as the texture usage of the textures in BC
// formats.
// Test that only CopySrc, CopyDst and Sampled are accepted as usage in compressed formats.
TEST_F(CompressedTextureFormatsValidationTests, TextureUsage) {
wgpu::TextureUsage invalidUsages[] = {
wgpu::TextureUsage::RenderAttachment,
@ -613,6 +631,22 @@ namespace {
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) {
@ -626,8 +660,7 @@ namespace {
}
}
// Test the validation of sample count when creating textures in compressed texture formats.
// It is invalid to specify SampleCount > 1 when we create a texture in BC formats.
// Test that it is invalid to specify SampleCount>1 in BC formats.
TEST_F(CompressedTextureFormatsValidationTests, SampleCount) {
for (wgpu::TextureFormat format : utils::kBCFormats) {
wgpu::TextureDescriptor descriptor = CreateDefaultTextureDescriptor();

View File

@ -87,6 +87,10 @@ namespace utils {
wgpu::TextureFormat::BC6HRGBUfloat, wgpu::TextureFormat::BC6HRGBFloat,
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);
uint32_t GetTexelBlockSizeInBytes(wgpu::TextureFormat textureFormat);