Disallow creating multisampled 2D array textures

Currently we decide not to support multisampled 2D array textures
because on Metal they are only available on macOS version greater than
10.14.

This patch also removes the compatibility check between cube map texture
views and sample counts because currently the sample count of 2D array
textures is always equal to 1.

BUG=dawn:56
TEST=dawn_unittests

Change-Id: I9736c977192409c79572f061fa1b7681b5b3e6c8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6000
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao 2019-03-28 00:14:50 +00:00 committed by Commit Bot service account
parent cae68ff846
commit 5f4bcbb946
3 changed files with 20 additions and 50 deletions

View File

@ -47,22 +47,6 @@ namespace dawn_native {
}
}
bool IsTextureViewDimensionCompatibleWithTextureSampleCount(
dawn::TextureViewDimension textureViewDimension,
const uint32_t sampleCount) {
switch (textureViewDimension) {
case dawn::TextureViewDimension::Cube:
case dawn::TextureViewDimension::CubeArray:
return sampleCount == 1;
case dawn::TextureViewDimension::e2D:
case dawn::TextureViewDimension::e2DArray:
return true;
default:
UNREACHABLE();
return false;
}
}
// TODO(jiawei.shao@intel.com): support validation on all texture view dimensions
bool IsArrayLayerValidForTextureViewDimension(
dawn::TextureViewDimension textureViewDimension,
@ -104,9 +88,17 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("The sample count of the texture is not supported.");
}
if (descriptor->sampleCount > 1 && descriptor->mipLevelCount > 1) {
return DAWN_VALIDATION_ERROR(
"The mipmap level count of a multisampled texture must be 1.");
if (descriptor->sampleCount > 1) {
if (descriptor->mipLevelCount > 1) {
return DAWN_VALIDATION_ERROR(
"The mipmap level count of a multisampled texture must be 1.");
}
// Multisampled 2D array texture is not supported because on Metal it requires the
// version of macOS be greater than 10.14.
if (descriptor->arrayLayerCount > 1) {
return DAWN_VALIDATION_ERROR("Multisampled 2D array texture is not supported.");
}
}
return {};
@ -128,13 +120,6 @@ namespace dawn_native {
"original texture");
}
if (!IsTextureViewDimensionCompatibleWithTextureSampleCount(
descriptor->dimension, texture->GetSampleCount())) {
return DAWN_VALIDATION_ERROR(
"The dimension of the texture view is not compatible with the sample count of "
"the original texture");
}
if (!IsTextureSizeValidForTextureViewDimension(descriptor->dimension,
texture->GetSize())) {
return DAWN_VALIDATION_ERROR(

View File

@ -84,6 +84,15 @@ TEST_F(TextureValidationTest, SampleCount) {
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}
// Currently we do not support multisampled 2D array textures.
{
dawn::TextureDescriptor descriptor = defaultDescriptor;
descriptor.sampleCount = 4;
descriptor.arrayLayerCount = 2;
ASSERT_DEVICE_ERROR(device.CreateTexture(&descriptor));
}
}
// Test that it is valid to destroy a texture

View File

@ -200,30 +200,6 @@ TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
descriptor.arrayLayerCount = 12;
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateTextureView(&descriptor));
}
// It is an error to create a cube map texture view on a multisampled texture.
{
constexpr uint32_t kSampleCount = 4;
dawn::Texture multisampledTexture = Create2DArrayTexture(device, kDefaultArrayLayers,
kWidth, kHeight, 1, kSampleCount);
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::Cube;
descriptor.arrayLayerCount = 6;
descriptor.mipLevelCount = 1;
ASSERT_DEVICE_ERROR(multisampledTexture.CreateTextureView(&descriptor));
}
// It is an error to create a cube map array texture view on a multisampled texture.
{
constexpr uint32_t kSampleCount = 4;
dawn::Texture multisampledTexture = Create2DArrayTexture(device, kDefaultArrayLayers,
kWidth, kHeight, 1, kSampleCount);
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = dawn::TextureViewDimension::CubeArray;
descriptor.arrayLayerCount = 12;
descriptor.mipLevelCount = 1;
ASSERT_DEVICE_ERROR(multisampledTexture.CreateTextureView(&descriptor));
}
}
// Test the format compatibility rules when creating a texture view.