Deprecate BGLEntry::textureDimension in favor of viewDimension

Bug: dawn:22
Change-Id: Ibc58be789e3d3322fcd9cef92b1942c0e0b79090
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/19861
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2020-04-20 08:10:10 +00:00 committed by Commit Bot service account
parent 99655bcf85
commit 98334dfdf7
13 changed files with 272 additions and 74 deletions

View File

@ -94,6 +94,7 @@
{"name": "has dynamic offset", "type": "bool", "default": "false"},
{"name": "multisampled", "type": "bool", "default": "false"},
{"name": "texture dimension", "type": "texture view dimension", "default": "undefined"},
{"name": "view dimension", "type": "texture view dimension", "default": "undefined"},
{"name": "texture component type", "type": "texture component type", "default": "float"},
{"name": "storage texture format", "type": "texture format", "default": "undefined"}
]

View File

@ -110,7 +110,7 @@ namespace dawn_native {
break;
}
if (binding.textureView->GetDimension() != bindingInfo.textureDimension) {
if (binding.textureView->GetDimension() != bindingInfo.viewDimension) {
return DAWN_VALIDATION_ERROR("texture view dimension mismatch");
}

View File

@ -111,8 +111,22 @@ namespace dawn_native {
DAWN_TRY(ValidateBindingType(binding.type));
DAWN_TRY(ValidateTextureComponentType(binding.textureComponentType));
if (binding.viewDimension != wgpu::TextureViewDimension::Undefined) {
DAWN_TRY(ValidateTextureViewDimension(binding.viewDimension));
// TODO(dawn:22): Remove this once users use viewDimension
if (binding.textureDimension != wgpu::TextureViewDimension::Undefined) {
return DAWN_VALIDATION_ERROR(
"Cannot use both viewDimension and textureDimension");
}
} else {
// TODO(dawn:22): Remove this once users use viewDimension
if (binding.textureDimension != wgpu::TextureViewDimension::Undefined) {
DAWN_TRY(ValidateTextureViewDimension(binding.textureDimension));
device->EmitDeprecationWarning(
"BindGroupLayoutEntry::textureDimension is deprecated, use viewDimension "
"instead");
}
}
if (bindingsSet.count(bindingNumber) != 0) {
@ -179,8 +193,7 @@ namespace dawn_native {
void HashCombineBindingInfo(size_t* hash, const BindingInfo& info) {
HashCombine(hash, info.hasDynamicOffset, info.multisampled, info.visibility, info.type,
info.textureComponentType, info.textureDimension,
info.storageTextureFormat);
info.textureComponentType, info.viewDimension, info.storageTextureFormat);
}
bool operator!=(const BindingInfo& a, const BindingInfo& b) {
@ -189,7 +202,7 @@ namespace dawn_native {
a.visibility != b.visibility || //
a.type != b.type || //
a.textureComponentType != b.textureComponentType || //
a.textureDimension != b.textureDimension || //
a.viewDimension != b.viewDimension || //
a.storageTextureFormat != b.storageTextureFormat;
}
@ -210,8 +223,8 @@ namespace dawn_native {
if (a.multisampled != b.multisampled) {
return a.multisampled < b.multisampled;
}
if (a.textureDimension != b.textureDimension) {
return a.textureDimension < b.textureDimension;
if (a.viewDimension != b.viewDimension) {
return a.viewDimension < b.viewDimension;
}
if (a.textureComponentType != b.textureComponentType) {
return a.textureComponentType < b.textureComponentType;
@ -287,10 +300,15 @@ namespace dawn_native {
break;
}
if (binding.textureDimension == wgpu::TextureViewDimension::Undefined) {
mBindingInfo[i].textureDimension = wgpu::TextureViewDimension::e2D;
if (binding.viewDimension == wgpu::TextureViewDimension::Undefined) {
// TODO(dawn:22): Remove this once users use viewDimension
if (binding.textureDimension != wgpu::TextureViewDimension::Undefined) {
mBindingInfo[i].viewDimension = binding.textureDimension;
} else {
mBindingInfo[i].textureDimension = binding.textureDimension;
mBindingInfo[i].viewDimension = wgpu::TextureViewDimension::e2D;
}
} else {
mBindingInfo[i].viewDimension = binding.viewDimension;
}
mBindingInfo[i].multisampled = binding.multisampled;

View File

@ -35,7 +35,7 @@ namespace dawn_native {
wgpu::ShaderStage visibility;
wgpu::BindingType type;
Format::Type textureComponentType = Format::Type::Float;
wgpu::TextureViewDimension textureDimension = wgpu::TextureViewDimension::Undefined;
wgpu::TextureViewDimension viewDimension = wgpu::TextureViewDimension::Undefined;
wgpu::TextureFormat storageTextureFormat = wgpu::TextureFormat::Undefined;
bool hasDynamicOffset = false;
bool multisampled = false;

View File

@ -28,8 +28,7 @@ namespace dawn_native {
bool operator==(const BindGroupLayoutEntry& lhs, const BindGroupLayoutEntry& rhs) {
return lhs.binding == rhs.binding && lhs.visibility == rhs.visibility &&
lhs.type == rhs.type && lhs.hasDynamicOffset == rhs.hasDynamicOffset &&
lhs.multisampled == rhs.multisampled &&
lhs.textureDimension == rhs.textureDimension &&
lhs.multisampled == rhs.multisampled && lhs.viewDimension == rhs.viewDimension &&
lhs.textureComponentType == rhs.textureComponentType;
}
@ -165,7 +164,7 @@ namespace dawn_native {
bindingSlot.type = bindingInfo.type;
bindingSlot.hasDynamicOffset = false;
bindingSlot.multisampled = bindingInfo.multisampled;
bindingSlot.textureDimension = bindingInfo.textureDimension;
bindingSlot.viewDimension = bindingInfo.viewDimension;
bindingSlot.textureComponentType =
Format::FormatTypeToTextureComponentType(bindingInfo.textureComponentType);
bindingSlot.storageTextureFormat = bindingInfo.storageTextureFormat;

View File

@ -395,8 +395,7 @@ namespace dawn_native {
switch (info->type) {
case wgpu::BindingType::SampledTexture: {
info->multisampled = binding.multisampled;
info->textureDimension =
ToWGPUTextureViewDimension(binding.texture_dimension);
info->viewDimension = ToWGPUTextureViewDimension(binding.texture_dimension);
info->textureComponentType =
ToDawnFormatType(binding.texture_component_type);
break;
@ -418,8 +417,7 @@ namespace dawn_native {
}
info->multisampled = binding.multisampled;
info->storageTextureFormat = storageTextureFormat;
info->textureDimension =
ToWGPUTextureViewDimension(binding.texture_dimension);
info->viewDimension = ToWGPUTextureViewDimension(binding.texture_dimension);
break;
}
default:
@ -580,7 +578,7 @@ namespace dawn_native {
compiler.get_type(imageType.type).basetype;
info->multisampled = imageType.ms;
info->textureDimension =
info->viewDimension =
SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed);
info->textureComponentType =
SpirvCrossBaseTypeToFormatType(textureComponentType);
@ -624,7 +622,7 @@ namespace dawn_native {
}
info->multisampled = imageType.ms;
info->storageTextureFormat = storageTextureFormat;
info->textureDimension =
info->viewDimension =
SpirvDimToTextureViewDimension(imageType.dim, imageType.arrayed);
break;
}
@ -799,7 +797,7 @@ namespace dawn_native {
return false;
}
if (bindingInfo.textureDimension != moduleInfo.textureDimension) {
if (bindingInfo.viewDimension != moduleInfo.viewDimension) {
return false;
}
break;
@ -812,7 +810,7 @@ namespace dawn_native {
if (bindingInfo.storageTextureFormat != moduleInfo.storageTextureFormat) {
return false;
}
if (bindingInfo.textureDimension != moduleInfo.textureDimension) {
if (bindingInfo.viewDimension != moduleInfo.viewDimension) {
return false;
}
break;

View File

@ -19,7 +19,24 @@
#include "tests/DawnTest.h"
class DeprecationTests : public DawnTest {};
#include "utils/WGPUHelpers.h"
class DeprecationTests : public DawnTest {
protected:
void TestSetUp() override {
// Skip when validation is off because warnings might be emitted during validation calls
DAWN_SKIP_TEST_IF(IsDawnValidationSkipped());
}
void TearDown() override {
if (!UsesWire()) {
EXPECT_EQ(mLastWarningCount,
dawn_native::GetDeprecationWarningCountForTesting(device.Get()));
}
}
size_t mLastWarningCount = 0;
};
#define EXPECT_DEPRECATION_WARNING(statement) \
do { \
@ -31,7 +48,9 @@ class DeprecationTests : public DawnTest {};
statement; \
size_t warningsAfter = \
dawn_native::GetDeprecationWarningCountForTesting(device.Get()); \
EXPECT_EQ(mLastWarningCount, warningsBefore); \
EXPECT_EQ(warningsAfter, warningsBefore + 1); \
mLastWarningCount = warningsAfter; \
} \
} while (0)
@ -50,6 +69,89 @@ TEST_P(DeprecationTests, CreateQueueReturnsFunctionalQueue) {
q.Submit(0, nullptr);
}
// Tests for BindGroupLayoutEntry::textureDimension -> viewDimension
// Test that creating a BGL with textureDimension produces a deprecation warning.
TEST_P(DeprecationTests, BGLEntryTextureDimensionIsDeprecated) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::SampledTexture,
.textureDimension = wgpu::TextureViewDimension::e2D,
};
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 1,
.bindings = &entryDesc,
};
EXPECT_DEPRECATION_WARNING(device.CreateBindGroupLayout(&bglDesc));
}
// Test that creating a BGL with default viewDimension and textureDimension doesn't emit a warning
TEST_P(DeprecationTests, BGLEntryTextureDimensionAndViewUndefinedEmitsNoWarning) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::Sampler,
};
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 1,
.bindings = &entryDesc,
};
device.CreateBindGroupLayout(&bglDesc);
}
// Test that creating a BGL with both textureDimension and viewDimension is an error
TEST_P(DeprecationTests, BGLEntryTextureAndViewDimensionIsInvalid) {
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::SampledTexture,
.textureDimension = wgpu::TextureViewDimension::e2D,
.viewDimension = wgpu::TextureViewDimension::e2D,
};
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 1,
.bindings = &entryDesc,
};
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&bglDesc));
}
// Test that creating a BGL with both textureDimension still does correct state tracking
TEST_P(DeprecationTests, BGLEntryTextureDimensionStateTracking) {
// Create a BGL that expects a cube map
wgpu::BindGroupLayoutEntry entryDesc = {
.type = wgpu::BindingType::SampledTexture,
.textureDimension = wgpu::TextureViewDimension::Cube,
};
wgpu::BindGroupLayoutDescriptor bglDesc = {
.bindingCount = 1,
.bindings = &entryDesc,
};
wgpu::BindGroupLayout layout;
EXPECT_DEPRECATION_WARNING(layout = device.CreateBindGroupLayout(&bglDesc));
// Create a 2D array view and a cube view
wgpu::TextureDescriptor textureDesc = {
.usage = wgpu::TextureUsage::Sampled,
.size = {1, 1, 1},
.arrayLayerCount = 6,
.format = wgpu::TextureFormat::RGBA8Unorm,
};
wgpu::Texture texture = device.CreateTexture(&textureDesc);
wgpu::TextureViewDescriptor viewDesc = {
.dimension = wgpu::TextureViewDimension::e2DArray,
.baseArrayLayer = 0,
.arrayLayerCount = 6,
};
wgpu::TextureView arrayView = texture.CreateView(&viewDesc);
viewDesc.dimension = wgpu::TextureViewDimension::Cube;
wgpu::TextureView cubeView = texture.CreateView(&viewDesc);
// textureDimension is correctly taken into account and only the BindGroup with the Cube view is
// valid.
utils::MakeBindGroup(device, layout, {{0, cubeView}});
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, layout, {{0, arrayView}}));
}
DAWN_INSTANTIATE_TEST(DeprecationTests,
D3D12Backend(),
MetalBackend(),

View File

@ -48,32 +48,68 @@ TEST_P(ObjectCachingTest, BindGroupLayoutDynamic) {
// Test that two similar bind group layouts won't refer to the same one if they differ by
// textureComponentType
TEST_P(ObjectCachingTest, BindGroupLayoutTextureComponentType) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Uint}});
wgpu::BindGroupLayout bgl =
utils::MakeBindGroupLayout(device, {{1,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout sameBgl =
utils::MakeBindGroupLayout(device, {{1,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout otherBgl =
utils::MakeBindGroupLayout(device, {{1,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
wgpu::TextureComponentType::Uint}});
EXPECT_NE(bgl.Get(), otherBgl.Get());
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());
}
// Test that two similar bind group layouts won't refer to the same one if they differ by
// textureDimension
TEST_P(ObjectCachingTest, BindGroupLayoutTextureDimension) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2DArray, wgpu::TextureComponentType::Float}});
// viewDimension
TEST_P(ObjectCachingTest, BindGroupLayoutViewDimension) {
wgpu::BindGroupLayout bgl =
utils::MakeBindGroupLayout(device, {{1,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout sameBgl =
utils::MakeBindGroupLayout(device, {{1,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout otherBgl =
utils::MakeBindGroupLayout(device, {{1,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2DArray,
wgpu::TextureComponentType::Float}});
EXPECT_NE(bgl.Get(), otherBgl.Get());
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());

View File

@ -304,9 +304,15 @@ TEST_F(BindGroupValidationTest, TextureUsage) {
// Check that a texture must have the correct component type
TEST_F(BindGroupValidationTest, TextureComponentType) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout layout =
utils::MakeBindGroupLayout(device, {{0,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
wgpu::TextureComponentType::Float}});
// Control case: setting a Float typed texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
@ -321,9 +327,15 @@ TEST_F(BindGroupValidationTest, TextureComponentType) {
// Check that a texture must have the correct dimension
TEST_F(BindGroupValidationTest, TextureDimension) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, false,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout layout =
utils::MakeBindGroupLayout(device, {{0,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
wgpu::TextureComponentType::Float}});
// Control case: setting a 2D texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});

View File

@ -272,7 +272,7 @@ TEST_F(GetBindGroupLayoutTests, Multisampled) {
}
// Test that texture view dimension matches the shader.
TEST_F(GetBindGroupLayoutTests, TextureDimension) {
TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::BindGroupLayoutEntry binding = {};
binding.binding = 0;
binding.type = wgpu::BindingType::SampledTexture;
@ -285,7 +285,7 @@ TEST_F(GetBindGroupLayoutTests, TextureDimension) {
desc.bindings = &binding;
{
binding.textureDimension = wgpu::TextureViewDimension::e1D;
binding.viewDimension = wgpu::TextureViewDimension::e1D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform texture1D tex;
@ -295,7 +295,7 @@ TEST_F(GetBindGroupLayoutTests, TextureDimension) {
}
{
binding.textureDimension = wgpu::TextureViewDimension::e2D;
binding.viewDimension = wgpu::TextureViewDimension::e2D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform texture2D tex;
@ -305,7 +305,7 @@ TEST_F(GetBindGroupLayoutTests, TextureDimension) {
}
{
binding.textureDimension = wgpu::TextureViewDimension::e2DArray;
binding.viewDimension = wgpu::TextureViewDimension::e2DArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform texture2DArray tex;
@ -315,7 +315,7 @@ TEST_F(GetBindGroupLayoutTests, TextureDimension) {
}
{
binding.textureDimension = wgpu::TextureViewDimension::e3D;
binding.viewDimension = wgpu::TextureViewDimension::e3D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform texture3D tex;
@ -325,7 +325,7 @@ TEST_F(GetBindGroupLayoutTests, TextureDimension) {
}
{
binding.textureDimension = wgpu::TextureViewDimension::Cube;
binding.viewDimension = wgpu::TextureViewDimension::Cube;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform textureCube tex;
@ -335,7 +335,7 @@ TEST_F(GetBindGroupLayoutTests, TextureDimension) {
}
{
binding.textureDimension = wgpu::TextureViewDimension::CubeArray;
binding.viewDimension = wgpu::TextureViewDimension::CubeArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
#version 450
layout(set = 0, binding = 0) uniform textureCubeArray tex;
@ -524,7 +524,7 @@ TEST_F(GetBindGroupLayoutTests, DISABLED_ConflictingBindingTextureMultisampling)
}
// Test it is invalid to have conflicting binding texture dimension in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureDimension) {
TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule vsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
#version 450

View File

@ -393,9 +393,15 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
descriptor.cFragmentStage.module = utils::CreateShaderModule(
device, utils::SingleShaderStage::Fragment, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false,
false, wgpu::TextureViewDimension::e2D, kTextureComponentTypes[j]}});
wgpu::BindGroupLayout bgl =
utils::MakeBindGroupLayout(device, {{0,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
wgpu::TextureViewDimension::e2D,
kTextureComponentTypes[j]}});
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
if (i == j) {
@ -443,9 +449,15 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
descriptor.cFragmentStage.module = utils::CreateShaderModule(
device, utils::SingleShaderStage::Fragment, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false,
false, kTextureViewDimensions[j], wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout bgl =
utils::MakeBindGroupLayout(device, {{0,
wgpu::ShaderStage::Fragment,
wgpu::BindingType::SampledTexture,
false,
false,
{},
kTextureViewDimensions[j],
wgpu::TextureComponentType::Float}});
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
if (i == j) {

View File

@ -603,7 +603,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatches
// Verify the dimension of the bind group layout with storage textures must match the one declared
// in shader.
TEST_F(StorageTextureValidationTests, BindGroupLayoutTextureDimensionMatchesShaderDeclaration) {
TEST_F(StorageTextureValidationTests, BindGroupLayoutViewDimensionMatchesShaderDeclaration) {
constexpr std::array<wgpu::TextureViewDimension, 6> kAllDimensions = {
wgpu::TextureViewDimension::e1D, wgpu::TextureViewDimension::e2D,
wgpu::TextureViewDimension::e2DArray, wgpu::TextureViewDimension::Cube,
@ -631,7 +631,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutTextureDimensionMatchesShad
for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kAllDimensions) {
// Create the bind group layout with the given texture view dimension.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.textureDimension = dimensionInBindGroupLayout;
bindGroupLayoutBinding.viewDimension = dimensionInBindGroupLayout;
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
@ -817,7 +817,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) {
for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kSupportedDimensions) {
// Create a bind group layout with given texture view dimension.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.textureDimension = dimensionInBindGroupLayout;
bindGroupLayoutBinding.viewDimension = dimensionInBindGroupLayout;
wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});

View File

@ -309,13 +309,33 @@ TEST_F(WireArgumentTests, StructureOfObjectArrayArgument) {
TEST_F(WireArgumentTests, StructureOfStructureArrayArgument) {
static constexpr int NUM_BINDINGS = 3;
WGPUBindGroupLayoutEntry bindings[NUM_BINDINGS]{
{0, WGPUShaderStage_Vertex, WGPUBindingType_Sampler, false, false,
WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
{1, WGPUShaderStage_Vertex, WGPUBindingType_SampledTexture, false, false,
WGPUTextureViewDimension_2D, WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
{2, static_cast<WGPUShaderStage>(WGPUShaderStage_Vertex | WGPUShaderStage_Fragment),
WGPUBindingType_UniformBuffer, false, false, WGPUTextureViewDimension_2D,
WGPUTextureComponentType_Float, WGPUTextureFormat_RGBA8Unorm},
{0,
WGPUShaderStage_Vertex,
WGPUBindingType_Sampler,
false,
false,
{},
WGPUTextureViewDimension_2D,
WGPUTextureComponentType_Float,
WGPUTextureFormat_RGBA8Unorm},
{1,
WGPUShaderStage_Vertex,
WGPUBindingType_SampledTexture,
false,
false,
{},
WGPUTextureViewDimension_2D,
WGPUTextureComponentType_Float,
WGPUTextureFormat_RGBA8Unorm},
{2,
static_cast<WGPUShaderStage>(WGPUShaderStage_Vertex | WGPUShaderStage_Fragment),
WGPUBindingType_UniformBuffer,
false,
false,
{},
WGPUTextureViewDimension_2D,
WGPUTextureComponentType_Float,
WGPUTextureFormat_RGBA8Unorm},
};
WGPUBindGroupLayoutDescriptor bglDescriptor = {};
bglDescriptor.bindingCount = NUM_BINDINGS;