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:
parent
817ba17d4c
commit
96ac969a33
|
@ -2093,7 +2093,7 @@
|
||||||
{"name": "base mip level", "type": "uint32_t", "default": "0"},
|
{"name": "base mip level", "type": "uint32_t", "default": "0"},
|
||||||
{"name": "mip level count", "type": "uint32_t", "default": "0"},
|
{"name": "mip level count", "type": "uint32_t", "default": "0"},
|
||||||
{"name": "base array layer", "type": "uint32_t", "default": "0"},
|
{"name": "base array layer", "type": "uint32_t", "default": "0"},
|
||||||
{"name": "array layer count", "type": "uint32_t", "default": "0"},
|
{"name": "array layer count", "type": "uint32_t", "default": "WGPU_ARRAY_LAYER_COUNT_UNDEFINED"},
|
||||||
{"name": "aspect", "type": "texture aspect", "default": "all"}
|
{"name": "aspect", "type": "texture aspect", "default": "all"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -79,6 +79,7 @@
|
||||||
#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL)
|
#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL)
|
||||||
#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL)
|
#define WGPU_LIMIT_U32_UNDEFINED (0xffffffffUL)
|
||||||
#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL)
|
#define WGPU_LIMIT_U64_UNDEFINED (0xffffffffffffffffULL)
|
||||||
|
#define WGPU_ARRAY_LAYER_COUNT_UNDEFINED (0xffffffffUL)
|
||||||
|
|
||||||
typedef uint32_t WGPUFlags;
|
typedef uint32_t WGPUFlags;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ namespace wgpu {
|
||||||
static constexpr uint32_t kCopyStrideUndefined = WGPU_COPY_STRIDE_UNDEFINED;
|
static constexpr uint32_t kCopyStrideUndefined = WGPU_COPY_STRIDE_UNDEFINED;
|
||||||
static constexpr uint32_t kLimitU32Undefined = WGPU_LIMIT_U32_UNDEFINED;
|
static constexpr uint32_t kLimitU32Undefined = WGPU_LIMIT_U32_UNDEFINED;
|
||||||
static constexpr uint64_t kLimitU64Undefined = WGPU_LIMIT_U64_UNDEFINED;
|
static constexpr uint64_t kLimitU64Undefined = WGPU_LIMIT_U64_UNDEFINED;
|
||||||
|
static constexpr uint32_t kArrayLayerCountUndefined = WGPU_ARRAY_LAYER_COUNT_UNDEFINED;
|
||||||
|
|
||||||
{% for type in by_category["enum"] %}
|
{% for type in by_category["enum"] %}
|
||||||
enum class {{as_cppType(type.name)}} : uint32_t {
|
enum class {{as_cppType(type.name)}} : uint32_t {
|
||||||
|
|
|
@ -397,7 +397,7 @@ namespace dawn_native {
|
||||||
// TODO(dawn:682): Use GetAspectInfo(aspect).
|
// TODO(dawn:682): Use GetAspectInfo(aspect).
|
||||||
desc.format = texture->GetFormat().format;
|
desc.format = texture->GetFormat().format;
|
||||||
}
|
}
|
||||||
if (desc.arrayLayerCount == 0) {
|
if (desc.arrayLayerCount == wgpu::kArrayLayerCountUndefined) {
|
||||||
switch (desc.dimension) {
|
switch (desc.dimension) {
|
||||||
case wgpu::TextureViewDimension::e1D:
|
case wgpu::TextureViewDimension::e1D:
|
||||||
case wgpu::TextureViewDimension::e2D:
|
case wgpu::TextureViewDimension::e2D:
|
||||||
|
|
|
@ -72,6 +72,13 @@ namespace {
|
||||||
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
wgpu::TextureViewDescriptor base2DTextureViewDescriptor =
|
||||||
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2D);
|
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.
|
// It is OK to create a 2D texture view on a 2D texture.
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
|
wgpu::TextureViewDescriptor descriptor = base2DTextureViewDescriptor;
|
||||||
|
@ -144,6 +151,14 @@ namespace {
|
||||||
wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
|
wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
|
||||||
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2DArray);
|
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.
|
// It is OK to create a 2D texture view on a 2D array texture.
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||||
|
@ -167,10 +182,11 @@ namespace {
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
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;
|
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||||
descriptor.arrayLayerCount = 0;
|
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
|
||||||
|
|
||||||
descriptor.baseArrayLayer = 0;
|
descriptor.baseArrayLayer = 0;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
|
@ -207,6 +223,13 @@ namespace {
|
||||||
wgpu::TextureViewDescriptor base3DTextureViewDescriptor =
|
wgpu::TextureViewDescriptor base3DTextureViewDescriptor =
|
||||||
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e3D);
|
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.
|
// It is OK to create a 3D texture view on a 3D texture.
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
|
wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
|
||||||
|
@ -264,11 +287,12 @@ namespace {
|
||||||
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
ASSERT_DEVICE_ERROR(texture.CreateView(&descriptor));
|
||||||
}
|
}
|
||||||
|
|
||||||
// baseArrayLayer == k && arrayLayerCount == 0 means to use layers k..end. But
|
// baseArrayLayer == k && arrayLayerCount == wgpu::kArrayLayerCountUndefined means to use
|
||||||
// baseArrayLayer must be 0, and arrayLayerCount must be 1 at most for 3D texture view.
|
// layers k..end. But baseArrayLayer must be 0, and arrayLayerCount must be 1 at most for 3D
|
||||||
|
// texture view.
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
|
wgpu::TextureViewDescriptor descriptor = base3DTextureViewDescriptor;
|
||||||
descriptor.arrayLayerCount = 0;
|
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
|
||||||
descriptor.baseArrayLayer = 0;
|
descriptor.baseArrayLayer = 0;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
descriptor.baseArrayLayer = 1;
|
descriptor.baseArrayLayer = 1;
|
||||||
|
@ -371,7 +395,7 @@ namespace {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor;
|
wgpu::TextureViewDescriptor descriptor;
|
||||||
descriptor.arrayLayerCount = 0;
|
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
|
@ -416,7 +440,7 @@ namespace {
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor;
|
wgpu::TextureViewDescriptor descriptor;
|
||||||
descriptor.arrayLayerCount = 0;
|
descriptor.arrayLayerCount = wgpu::kArrayLayerCountUndefined;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
descriptor.arrayLayerCount = 1;
|
descriptor.arrayLayerCount = 1;
|
||||||
texture.CreateView(&descriptor);
|
texture.CreateView(&descriptor);
|
||||||
|
@ -441,6 +465,14 @@ namespace {
|
||||||
wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
|
wgpu::TextureViewDescriptor base2DArrayTextureViewDescriptor =
|
||||||
CreateDefaultViewDescriptor(wgpu::TextureViewDimension::e2DArray);
|
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.
|
// It is OK to create a cube map texture view with arrayLayerCount == 6.
|
||||||
{
|
{
|
||||||
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
wgpu::TextureViewDescriptor descriptor = base2DArrayTextureViewDescriptor;
|
||||||
|
|
Loading…
Reference in New Issue