Fix missing validations and Vulkan flags on cube map texture views
This patch adds checks that we can only create cube map and cube map array texture views on textures with width == height as is required in Vulkan. This patch enables the imageCubeArray feature on Vulkan back-ends to ensure we can create cube map array image views on all Vulkan back-ends. This patch also adds a missing VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT flag when creating Vulkan images with arrayLayer >= 6. Without this flag we cannot create cube map or cube map array views. This patch fixes all the cube map end2end tests on Linux using Vulkan back-ends. BUG=dawn:16 TEST=dawn_end2end_tests Change-Id: Id9386b9ee509d18a5ba8ae1ca085134486b242d7 Reviewed-on: https://dawn-review.googlesource.com/c/2522 Commit-Queue: Jiawei Shao <jiawei.shao@intel.com> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
63997221d7
commit
ad3d9bafbc
|
@ -66,19 +66,43 @@ namespace dawn_native {
|
|||
}
|
||||
}
|
||||
|
||||
bool IsTextureSizeValidForTextureViewDimension(
|
||||
dawn::TextureViewDimension textureViewDimension,
|
||||
const Extent3D& textureSize) {
|
||||
switch (textureViewDimension) {
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
return textureSize.width == textureSize.height;
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
return true;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
MaybeError ValidateTextureViewDimensionCompatibility(
|
||||
const TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor) {
|
||||
if (!IsArrayLayerValidForTextureViewDimension(descriptor->dimension,
|
||||
descriptor->layerCount)) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"The dimension of the texture view is not compatible to the layer count");
|
||||
"The dimension of the texture view is not compatible with the layer count");
|
||||
}
|
||||
|
||||
if (!IsTextureViewDimensionCompatibleWithTextureDimension(descriptor->dimension,
|
||||
texture->GetDimension())) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"The dimension of texture view is not compatible to the original texture");
|
||||
"The dimension of the texture view is not compatible with the dimension of the"
|
||||
"original texture");
|
||||
}
|
||||
|
||||
if (!IsTextureSizeValidForTextureViewDimension(descriptor->dimension,
|
||||
texture->GetSize())) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"The dimension of the texture view is not compatible with the size of the"
|
||||
"original texture");
|
||||
}
|
||||
|
||||
return {};
|
||||
|
|
|
@ -497,8 +497,10 @@ namespace dawn_native { namespace vulkan {
|
|||
usedKnobs->swapchain = true;
|
||||
}
|
||||
|
||||
// Always require independentBlend because it is a core Dawn feature,
|
||||
// Always require independentBlend because it is a core Dawn feature
|
||||
usedKnobs->features.independentBlend = VK_TRUE;
|
||||
// Always require imageCubeArray because it is a core Dawn feature
|
||||
usedKnobs->features.imageCubeArray = VK_TRUE;
|
||||
|
||||
// Find a universal queue family
|
||||
{
|
||||
|
|
|
@ -267,6 +267,10 @@ namespace dawn_native { namespace vulkan {
|
|||
createInfo.pQueueFamilyIndices = nullptr;
|
||||
createInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
||||
|
||||
if (GetArrayLayers() >= 6 && GetSize().width == GetSize().height) {
|
||||
createInfo.flags |= VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
|
||||
}
|
||||
|
||||
if (device->fn.CreateImage(device->GetVkDevice(), &createInfo, nullptr, &mHandle) !=
|
||||
VK_SUCCESS) {
|
||||
ASSERT(false);
|
||||
|
|
|
@ -27,14 +27,15 @@ constexpr dawn::TextureFormat kDefaultTextureFormat = dawn::TextureFormat::R8G8B
|
|||
|
||||
dawn::Texture Create2DArrayTexture(dawn::Device& device,
|
||||
uint32_t arrayLayers,
|
||||
dawn::TextureFormat format = kDefaultTextureFormat) {
|
||||
uint32_t width = kWidth,
|
||||
uint32_t height = kHeight) {
|
||||
dawn::TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.size.width = kWidth;
|
||||
descriptor.size.height = kHeight;
|
||||
descriptor.size.width = width;
|
||||
descriptor.size.height = height;
|
||||
descriptor.size.depth = 1;
|
||||
descriptor.arrayLayer = arrayLayers;
|
||||
descriptor.format = format;
|
||||
descriptor.format = kDefaultTextureFormat;
|
||||
descriptor.levelCount = kDefaultMipLevels;
|
||||
descriptor.usage = dawn::TextureUsageBit::Sampled;
|
||||
return device.CreateTexture(&descriptor);
|
||||
|
@ -169,13 +170,33 @@ TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
|||
texture.CreateTextureView(&descriptor);
|
||||
}
|
||||
|
||||
// It is an error create a cube map array texture view with layerCount % 6 != 0.
|
||||
// It is an error to create a cube map array texture view with layerCount % 6 != 0.
|
||||
{
|
||||
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||
descriptor.dimension = dawn::TextureViewDimension::CubeArray;
|
||||
descriptor.layerCount = 11;
|
||||
ASSERT_DEVICE_ERROR(texture.CreateTextureView(&descriptor));
|
||||
}
|
||||
|
||||
// It is an error to create a cube map texture view with width != height.
|
||||
{
|
||||
dawn::Texture nonSquareTexture = Create2DArrayTexture(device, 18, 32, 16);
|
||||
|
||||
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||
descriptor.dimension = dawn::TextureViewDimension::Cube;
|
||||
descriptor.layerCount = 6;
|
||||
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateTextureView(&descriptor));
|
||||
}
|
||||
|
||||
// It is an error to create a cube map array texture view with width != height.
|
||||
{
|
||||
dawn::Texture nonSquareTexture = Create2DArrayTexture(device, 18, 32, 16);
|
||||
|
||||
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||
descriptor.dimension = dawn::TextureViewDimension::CubeArray;
|
||||
descriptor.layerCount = 12;
|
||||
ASSERT_DEVICE_ERROR(nonSquareTexture.CreateTextureView(&descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
// Test the format compatibility rules when creating a texture view.
|
||||
|
|
Loading…
Reference in New Issue