mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-09 14:45:58 +00:00
Add entry points for creating a cube map/cube map array texture view
This patch adds the entry points for creating cube map and cube map array texture views. This patch also adds validations that the array layer in the texture view descriptor must be 6 when the texture view dimension is cube map, and a multiple of 6 when the texture view dimension is cube map array. BUG=dawn:16 TEST=dawn_unittests Change-Id: I86a66c3753a7678351f65b43f6cd54b96d1b762c Reviewed-on: https://dawn-review.googlesource.com/c/2200 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
parent
6686fc8245
commit
db3b893675
@ -1111,10 +1111,12 @@
|
||||
"category": "enum",
|
||||
"values": [
|
||||
{"value": 0, "name": "2D"},
|
||||
{"value": 1, "name": "2D array"}
|
||||
{"value": 1, "name": "2D array"},
|
||||
{"value": 2, "name": "cube"},
|
||||
{"value": 3, "name": "cube array"}
|
||||
],
|
||||
"TODO": [
|
||||
"jiawei.shao@intel.com: support 1D, 3D, cube and cube array texture views"
|
||||
"jiawei.shao@intel.com: support 1D and 3D texture views"
|
||||
]
|
||||
},
|
||||
"vertex format": {
|
||||
|
@ -37,8 +37,9 @@ namespace dawn_native {
|
||||
dawn::TextureDimension textureDimension) {
|
||||
switch (textureViewDimension) {
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
return textureDimension == dawn::TextureDimension::e2D;
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
return textureDimension == dawn::TextureDimension::e2D;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -55,6 +56,10 @@ namespace dawn_native {
|
||||
return textureViewArrayLayer == 1u;
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
return true;
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
return textureViewArrayLayer == 6u;
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
return textureViewArrayLayer % 6 == 0;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
|
@ -136,6 +136,48 @@ TEST_F(TextureViewValidationTest, CreateTextureViewOnTexture2DArray) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test creating cube map texture view
|
||||
TEST_F(TextureViewValidationTest, CreateCubeMapTextureView) {
|
||||
constexpr uint32_t kDefaultArrayLayers = 16;
|
||||
|
||||
dawn::Texture texture = Create2DArrayTexture(device, kDefaultArrayLayers);
|
||||
|
||||
dawn::TextureViewDescriptor base2DArrayTextureViewDescriptor =
|
||||
CreateDefaultTextureViewDescriptor(dawn::TextureViewDimension::e2DArray);
|
||||
|
||||
// It is OK to create a cube map texture view with layerCount == 6.
|
||||
{
|
||||
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||
descriptor.dimension = dawn::TextureViewDimension::Cube;
|
||||
descriptor.layerCount = 6;
|
||||
texture.CreateTextureView(&descriptor);
|
||||
}
|
||||
|
||||
// It is an error to create a cube map texture view with layerCount != 6.
|
||||
{
|
||||
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||
descriptor.dimension = dawn::TextureViewDimension::Cube;
|
||||
descriptor.layerCount = 3;
|
||||
ASSERT_DEVICE_ERROR(texture.CreateTextureView(&descriptor));
|
||||
}
|
||||
|
||||
// It is OK to create a cube map array texture view with layerCount % 6 == 0.
|
||||
{
|
||||
dawn::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||
descriptor.dimension = dawn::TextureViewDimension::CubeArray;
|
||||
descriptor.layerCount = 12;
|
||||
texture.CreateTextureView(&descriptor);
|
||||
}
|
||||
|
||||
// It is an error 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));
|
||||
}
|
||||
}
|
||||
|
||||
// Test the format compatibility rules when creating a texture view.
|
||||
// TODO(jiawei.shao@intel.com): add more tests when the rules are fully implemented.
|
||||
TEST_F(TextureViewValidationTest, TextureViewFormatCompatibility) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user