Use WGPU_ARRAY_LAYER_COUNT_UNDEFINED instead of 0

This seperates the undefined 'arrayLayerCount' from 0 to
WGPU_ARRAY_LAYER_COUNT_UNDEFINED. So 0 arrayLayerCount is treated
as a validation error.

Bug: dawn:1026
Change-Id: I7b4ae024b02ac0d2aa260b2a8c64b09bd967db87
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63660
Reviewed-by: Jie A Chen <jie.a.chen@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Jie A Chen <jie.a.chen@intel.com>
This commit is contained in:
jchen10
2021-09-14 02:41:49 +00:00
committed by Dawn LUCI CQ
parent 817ba17d4c
commit 96ac969a33
5 changed files with 43 additions and 9 deletions

View File

@@ -397,7 +397,7 @@ namespace dawn_native {
// TODO(dawn:682): Use GetAspectInfo(aspect).
desc.format = texture->GetFormat().format;
}
if (desc.arrayLayerCount == 0) {
if (desc.arrayLayerCount == wgpu::kArrayLayerCountUndefined) {
switch (desc.dimension) {
case wgpu::TextureViewDimension::e1D:
case wgpu::TextureViewDimension::e2D:

View File

@@ -72,6 +72,13 @@ namespace {
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
// It is an error to create a view with zero 'arrayLayerCount'.
{
wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
descriptor.arrayLayerCount = 0;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
// It is OK to create a 2D texture view on a 2D texture.
{
wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
@@ -144,6 +151,14 @@ namespace {
wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2DArray);
// It is an error to create a view with zero 'arrayLayerCount'.
{
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = wgpu::TextureViewDimension::e2D;
descriptor.arrayLayerCount = 0;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
// It is OK to create a 2D texture view on a 2D array texture.
{
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
@@ -167,10 +182,11 @@ namespace {
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
// baseArrayLayer == k && arrayLayerCount == 0 means to use layers k..end.
// baseArrayLayer == k && arrayLayerCount == wgpu::kArrayLayerCountUndefined means to use
// layers k..end.
{
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.arrayLayerCount = 0;
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
descriptor.baseArrayLayer = 0;
texture.CreateView(&descriptor);
@@ -207,6 +223,13 @@ namespace {
wgpu::TextureViewDescriptor base3DTextureViewDescriptor =
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e3D);
// It is an error to create a view with zero 'arrayLayerCount'.
{
wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
descriptor.arrayLayerCount = 0;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
// It is OK to create a 3D texture view on a 3D texture.
{
wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
@@ -264,11 +287,12 @@ namespace {
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
// baseArrayLayer == k && arrayLayerCount == 0 means to use layers k..end. But
// baseArrayLayer must be 0, and arrayLayerCount must be 1 at most for 3D texture view.
// baseArrayLayer == k && arrayLayerCount == wgpu::kArrayLayerCountUndefined means to use
// layers k..end. But baseArrayLayer must be 0, and arrayLayerCount must be 1 at most for 3D
// texture view.
{
wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
descriptor.arrayLayerCount = 0;
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
descriptor.baseArrayLayer = 0;
texture.CreateView(&descriptor);
descriptor.baseArrayLayer = 1;
@@ -371,7 +395,7 @@ namespace {
}
{
wgpu::TextureViewDescriptor descriptor;
descriptor.arrayLayerCount = 0;
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
texture.CreateView(&descriptor);
descriptor.arrayLayerCount = 1;
texture.CreateView(&descriptor);
@@ -416,7 +440,7 @@ namespace {
}
{
wgpu::TextureViewDescriptor descriptor;
descriptor.arrayLayerCount = 0;
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
texture.CreateView(&descriptor);
descriptor.arrayLayerCount = 1;
texture.CreateView(&descriptor);
@@ -441,6 +465,14 @@ namespace {
wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2DArray);
// It is an error to create a view with zero 'arrayLayerCount'.
{
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
descriptor.dimension = wgpu::TextureViewDimension::Cube;
descriptor.arrayLayerCount = 0;
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
}
// It is OK to create a cube map texture view with arrayLayerCount == 6.
{
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;