Update majority of tests to use new BindGroupLayoutEntry format

Converts most of the tests to use the new layout, with the exception
of a few that are dependent on additional Dawn changes before the
conversion can happen. The deprecation warning is not enabled yet
due to these remaining changes.

Bug: dawn:527
Change-Id: Idcfd9fc873756f5a9f88de2ce9ab65c66b79bf39
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/35582
Commit-Queue: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Brandon Jones 2020-12-17 00:19:34 +00:00 committed by Commit Bot service account
parent 307ece1630
commit b31cd871ad
17 changed files with 467 additions and 527 deletions

View File

@ -53,7 +53,7 @@ class BindGroupTests : public DawnTest {
})"); })");
} }
wgpu::ShaderModule MakeFSModule(std::vector<wgpu::BindingType> bindingTypes) const { wgpu::ShaderModule MakeFSModule(std::vector<wgpu::BufferBindingType> bindingTypes) const {
ASSERT(bindingTypes.size() <= kMaxBindGroups); ASSERT(bindingTypes.size() <= kMaxBindGroups);
std::ostringstream fs; std::ostringstream fs;
@ -64,14 +64,14 @@ class BindGroupTests : public DawnTest {
for (size_t i = 0; i < bindingTypes.size(); ++i) { for (size_t i = 0; i < bindingTypes.size(); ++i) {
switch (bindingTypes[i]) { switch (bindingTypes[i]) {
case wgpu::BindingType::UniformBuffer: case wgpu::BufferBindingType::Uniform:
fs << "layout (std140, set = " << i << ", binding = 0) uniform UniformBuffer" fs << "layout (std140, set = " << i << ", binding = 0) uniform UniformBuffer"
<< i << R"( { << i << R"( {
vec4 color; vec4 color;
} buffer)" } buffer)"
<< i << ";\n"; << i << ";\n";
break; break;
case wgpu::BindingType::StorageBuffer: case wgpu::BufferBindingType::Storage:
fs << "layout (std430, set = " << i << ", binding = 0) buffer StorageBuffer" fs << "layout (std430, set = " << i << ", binding = 0) buffer StorageBuffer"
<< i << R"( { << i << R"( {
vec4 color; vec4 color;
@ -97,7 +97,7 @@ class BindGroupTests : public DawnTest {
} }
wgpu::RenderPipeline MakeTestPipeline(const utils::BasicRenderPass& renderPass, wgpu::RenderPipeline MakeTestPipeline(const utils::BasicRenderPass& renderPass,
std::vector<wgpu::BindingType> bindingTypes, std::vector<wgpu::BufferBindingType> bindingTypes,
std::vector<wgpu::BindGroupLayout> bindGroupLayouts) { std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
wgpu::ShaderModule vsModule = MakeSimpleVSModule(); wgpu::ShaderModule vsModule = MakeSimpleVSModule();
wgpu::ShaderModule fsModule = MakeFSModule(bindingTypes); wgpu::ShaderModule fsModule = MakeFSModule(bindingTypes);
@ -430,12 +430,12 @@ TEST_P(BindGroupTests, DrawTwiceInSamePipelineWithFourBindGroupSets) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(renderPass, MakeTestPipeline(renderPass,
{wgpu::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer, {wgpu::BufferBindingType::Uniform, wgpu::BufferBindingType::Uniform,
wgpu::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer}, wgpu::BufferBindingType::Uniform, wgpu::BufferBindingType::Uniform},
{layout, layout, layout, layout}); {layout, layout, layout, layout});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -479,11 +479,11 @@ TEST_P(BindGroupTests, SetBindGroupBeforePipeline) {
// Create a bind group layout which uses a single uniform buffer. // Create a bind group layout which uses a single uniform buffer.
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
// Create a pipeline that uses the uniform bind group layout. // Create a pipeline that uses the uniform bind group layout.
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(renderPass, {wgpu::BindingType::UniformBuffer}, {layout}); MakeTestPipeline(renderPass, {wgpu::BufferBindingType::Uniform}, {layout});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
@ -521,11 +521,11 @@ TEST_P(BindGroupTests, SetDynamicBindGroupBeforePipeline) {
// Create a bind group layout which uses a single dynamic uniform buffer. // Create a bind group layout which uses a single dynamic uniform buffer.
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, true}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, true}});
// Create a pipeline that uses the dynamic uniform bind group layout for two bind groups. // Create a pipeline that uses the dynamic uniform bind group layout for two bind groups.
wgpu::RenderPipeline pipeline = MakeTestPipeline( wgpu::RenderPipeline pipeline = MakeTestPipeline(
renderPass, {wgpu::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer}, renderPass, {wgpu::BufferBindingType::Uniform, wgpu::BufferBindingType::Uniform},
{layout, layout}); {layout, layout});
// Prepare data RGBAunorm(1, 0, 0, 0.5) and RGBAunorm(0, 1, 0, 0.5). They will be added in the // Prepare data RGBAunorm(1, 0, 0, 0.5) and RGBAunorm(0, 1, 0, 0.5). They will be added in the
@ -582,20 +582,20 @@ TEST_P(BindGroupTests, BindGroupsPersistAfterPipelineChange) {
// Create a bind group layout which uses a single dynamic uniform buffer. // Create a bind group layout which uses a single dynamic uniform buffer.
wgpu::BindGroupLayout uniformLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout uniformLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, true}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, true}});
// Create a bind group layout which uses a single dynamic storage buffer. // Create a bind group layout which uses a single dynamic storage buffer.
wgpu::BindGroupLayout storageLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout storageLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer, true}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage, true}});
// Create a pipeline which uses the uniform buffer and storage buffer bind groups. // Create a pipeline which uses the uniform buffer and storage buffer bind groups.
wgpu::RenderPipeline pipeline0 = MakeTestPipeline( wgpu::RenderPipeline pipeline0 = MakeTestPipeline(
renderPass, {wgpu::BindingType::UniformBuffer, wgpu::BindingType::StorageBuffer}, renderPass, {wgpu::BufferBindingType::Uniform, wgpu::BufferBindingType::Storage},
{uniformLayout, storageLayout}); {uniformLayout, storageLayout});
// Create a pipeline which uses the uniform buffer bind group twice. // Create a pipeline which uses the uniform buffer bind group twice.
wgpu::RenderPipeline pipeline1 = MakeTestPipeline( wgpu::RenderPipeline pipeline1 = MakeTestPipeline(
renderPass, {wgpu::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer}, renderPass, {wgpu::BufferBindingType::Uniform, wgpu::BufferBindingType::Uniform},
{uniformLayout, uniformLayout}); {uniformLayout, uniformLayout});
// Prepare data RGBAunorm(1, 0, 0, 0.5) and RGBAunorm(0, 1, 0, 0.5). They will be added in the // Prepare data RGBAunorm(1, 0, 0, 0.5) and RGBAunorm(0, 1, 0, 0.5). They will be added in the
@ -660,24 +660,24 @@ TEST_P(BindGroupTests, DrawThenChangePipelineAndBindGroup) {
// Create a bind group layout which uses a single dynamic uniform buffer. // Create a bind group layout which uses a single dynamic uniform buffer.
wgpu::BindGroupLayout uniformLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout uniformLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, true}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, true}});
// Create a bind group layout which uses a single dynamic storage buffer. // Create a bind group layout which uses a single dynamic storage buffer.
wgpu::BindGroupLayout storageLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout storageLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer, true}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage, true}});
// Create a pipeline with pipeline layout (uniform, uniform, storage). // Create a pipeline with pipeline layout (uniform, uniform, storage).
wgpu::RenderPipeline pipeline0 = wgpu::RenderPipeline pipeline0 =
MakeTestPipeline(renderPass, MakeTestPipeline(renderPass,
{wgpu::BindingType::UniformBuffer, wgpu::BindingType::UniformBuffer, {wgpu::BufferBindingType::Uniform, wgpu::BufferBindingType::Uniform,
wgpu::BindingType::StorageBuffer}, wgpu::BufferBindingType::Storage},
{uniformLayout, uniformLayout, storageLayout}); {uniformLayout, uniformLayout, storageLayout});
// Create a pipeline with pipeline layout (uniform, storage, storage). // Create a pipeline with pipeline layout (uniform, storage, storage).
wgpu::RenderPipeline pipeline1 = wgpu::RenderPipeline pipeline1 =
MakeTestPipeline(renderPass, MakeTestPipeline(renderPass,
{wgpu::BindingType::UniformBuffer, wgpu::BindingType::StorageBuffer, {wgpu::BufferBindingType::Uniform, wgpu::BufferBindingType::Storage,
wgpu::BindingType::StorageBuffer}, wgpu::BufferBindingType::Storage},
{uniformLayout, storageLayout, storageLayout}); {uniformLayout, storageLayout, storageLayout});
// Prepare color data. // Prepare color data.
@ -795,10 +795,10 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
// order. // order.
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, { device, {
{3, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer, true}, {3, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage, true},
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage, true},
{2, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, true}, {2, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform, true},
{4, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}, {4, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
}); });
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl,
{ {
@ -1024,7 +1024,7 @@ TEST_P(BindGroupTests, LastReferenceToBindGroupLayout) {
wgpu::BindGroup bg; wgpu::BindGroup bg;
{ {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
bg = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, sizeof(float)}}); bg = utils::MakeBindGroup(device, bgl, {{0, buffer, 0, sizeof(float)}});
} }
} }
@ -1086,7 +1086,7 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat;
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);

View File

@ -211,10 +211,9 @@ class DepthStencilSamplingTest : public DawnTest {
// TODO(dawn:367): Cannot use GetBindGroupLayout for comparison samplers without shader // TODO(dawn:367): Cannot use GetBindGroupLayout for comparison samplers without shader
// reflection data. // reflection data.
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ComparisonSampler}, device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, {1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth},
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison}, {2, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
{2, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}});
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertexStage.module = vsModule;
@ -246,11 +245,10 @@ class DepthStencilSamplingTest : public DawnTest {
// TODO(dawn:367): Cannot use GetBindGroupLayout without shader reflection data. // TODO(dawn:367): Cannot use GetBindGroupLayout without shader reflection data.
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ComparisonSampler}, device, {{0, wgpu::ShaderStage::Compute, wgpu::SamplerBindingType::Comparison},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0, {1, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Depth},
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison}, {2, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform},
{2, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer}, {3, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
{3, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}});
wgpu::ComputePipelineDescriptor pipelineDescriptor; wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);

View File

@ -56,13 +56,13 @@ class DynamicBufferOffsetTests : public DawnTest {
// Default bind group layout // Default bind group layout
mBindGroupLayouts[0] = utils::MakeBindGroupLayout( mBindGroupLayouts[0] = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer}, wgpu::BufferBindingType::Uniform},
{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}, wgpu::BufferBindingType::Storage},
{3, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {3, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer, true}, wgpu::BufferBindingType::Uniform, true},
{4, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {4, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer, true}}); wgpu::BufferBindingType::Storage, true}});
// Default bind group // Default bind group
mBindGroups[0] = utils::MakeBindGroup(device, mBindGroupLayouts[0], mBindGroups[0] = utils::MakeBindGroup(device, mBindGroupLayouts[0],
@ -78,7 +78,7 @@ class DynamicBufferOffsetTests : public DawnTest {
// Bind group layout for inheriting test // Bind group layout for inheriting test
mBindGroupLayouts[1] = utils::MakeBindGroupLayout( mBindGroupLayouts[1] = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer}}); wgpu::BufferBindingType::Uniform}});
// Bind group for inheriting test // Bind group for inheriting test
mBindGroups[1] = utils::MakeBindGroup(device, mBindGroupLayouts[1], mBindGroups[1] = utils::MakeBindGroup(device, mBindGroupLayouts[1],

View File

@ -22,11 +22,11 @@ class ObjectCachingTest : public DawnTest {};
// Test that BindGroupLayouts are correctly deduplicated. // Test that BindGroupLayouts are correctly deduplicated.
TEST_P(ObjectCachingTest, BindGroupLayoutDeduplication) { TEST_P(ObjectCachingTest, BindGroupLayoutDeduplication) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
EXPECT_NE(bgl.Get(), otherBgl.Get()); EXPECT_NE(bgl.Get(), otherBgl.Get());
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire()); EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());
@ -35,11 +35,11 @@ TEST_P(ObjectCachingTest, BindGroupLayoutDeduplication) {
// Test that two similar bind group layouts won't refer to the same one if they differ by dynamic. // Test that two similar bind group layouts won't refer to the same one if they differ by dynamic.
TEST_P(ObjectCachingTest, BindGroupLayoutDynamic) { TEST_P(ObjectCachingTest, BindGroupLayoutDynamic) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, true}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, true}});
wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, true}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, true}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, false}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, false}});
EXPECT_NE(bgl.Get(), otherBgl.Get()); EXPECT_NE(bgl.Get(), otherBgl.Get());
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire()); EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());
@ -49,14 +49,11 @@ TEST_P(ObjectCachingTest, BindGroupLayoutDynamic) {
// textureComponentType // textureComponentType
TEST_P(ObjectCachingTest, BindGroupLayoutTextureComponentType) { TEST_P(ObjectCachingTest, BindGroupLayoutTextureComponentType) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Uint}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Uint}});
EXPECT_NE(bgl.Get(), otherBgl.Get()); EXPECT_NE(bgl.Get(), otherBgl.Get());
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire()); EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());
@ -66,14 +63,12 @@ TEST_P(ObjectCachingTest, BindGroupLayoutTextureComponentType) {
// viewDimension // viewDimension
TEST_P(ObjectCachingTest, BindGroupLayoutViewDimension) { TEST_P(ObjectCachingTest, BindGroupLayoutViewDimension) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout sameBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2DArray, wgpu::TextureComponentType::Float}}); wgpu::TextureViewDimension::e2DArray}});
EXPECT_NE(bgl.Get(), otherBgl.Get()); EXPECT_NE(bgl.Get(), otherBgl.Get());
EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire()); EXPECT_EQ(bgl.Get() == sameBgl.Get(), !UsesWire());
@ -85,16 +80,16 @@ TEST_P(ObjectCachingTest, ErrorObjectDoesntUncache) {
ASSERT_DEVICE_ERROR( ASSERT_DEVICE_ERROR(
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}, device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform},
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}})); {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}}));
} }
// Test that PipelineLayouts are correctly deduplicated. // Test that PipelineLayouts are correctly deduplicated.
TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) { TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
wgpu::PipelineLayout samePl = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout samePl = utils::MakeBasicPipelineLayout(device, &bgl);
@ -169,9 +164,9 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
// Test that ComputePipeline are correctly deduplicated wrt. their layout // Test that ComputePipeline are correctly deduplicated wrt. their layout
TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) { TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
wgpu::PipelineLayout samePl = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout samePl = utils::MakeBasicPipelineLayout(device, &bgl);
@ -204,9 +199,9 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
// Test that RenderPipelines are correctly deduplicated wrt. their layout // Test that RenderPipelines are correctly deduplicated wrt. their layout
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) { TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout otherBgl = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
wgpu::PipelineLayout samePl = utils::MakeBasicPipelineLayout(device, &bgl); wgpu::PipelineLayout samePl = utils::MakeBasicPipelineLayout(device, &bgl);

View File

@ -42,9 +42,9 @@ class OpArrayLengthTest : public DawnTest {
wgpu::ShaderStage kAllStages = wgpu::ShaderStage kAllStages =
wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Compute; wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Compute;
mBindGroupLayout = utils::MakeBindGroupLayout( mBindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, kAllStages, wgpu::BindingType::ReadonlyStorageBuffer}, device, {{0, kAllStages, wgpu::BufferBindingType::ReadOnlyStorage},
{1, kAllStages, wgpu::BindingType::ReadonlyStorageBuffer}, {1, kAllStages, wgpu::BufferBindingType::ReadOnlyStorage},
{2, kAllStages, wgpu::BindingType::ReadonlyStorageBuffer}}); {2, kAllStages, wgpu::BufferBindingType::ReadOnlyStorage}});
mBindGroup = utils::MakeBindGroup(device, mBindGroupLayout, mBindGroup = utils::MakeBindGroup(device, mBindGroupLayout,
{ {
@ -103,7 +103,7 @@ TEST_P(OpArrayLengthTest, Compute) {
wgpu::Buffer resultBuffer = device.CreateBuffer(&bufferDesc); wgpu::Buffer resultBuffer = device.CreateBuffer(&bufferDesc);
wgpu::BindGroupLayout resultLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout resultLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup resultBindGroup = wgpu::BindGroup resultBindGroup =
utils::MakeBindGroup(device, resultLayout, {{0, resultBuffer, 0, wgpu::kWholeSize}}); utils::MakeBindGroup(device, resultLayout, {{0, resultBuffer, 0, wgpu::kWholeSize}});

View File

@ -684,7 +684,7 @@ class StorageTextureTests : public DawnTest {
// valid on all backends. This test is a regression test for chromium:1061156 and passes by not // valid on all backends. This test is a regression test for chromium:1061156 and passes by not
// asserting or crashing. // asserting or crashing.
TEST_P(StorageTextureTests, BindGroupLayoutWithStorageTextureBindingType) { TEST_P(StorageTextureTests, BindGroupLayoutWithStorageTextureBindingType) {
// wgpu::BindingType::ReadonlyStorageTexture is a valid binding type to create a bind group // ReadOnly is a valid storage texture binding type to create a bind group
// layout. // layout.
{ {
wgpu::BindGroupLayoutEntry entry; wgpu::BindGroupLayoutEntry entry;
@ -698,7 +698,7 @@ TEST_P(StorageTextureTests, BindGroupLayoutWithStorageTextureBindingType) {
device.CreateBindGroupLayout(&descriptor); device.CreateBindGroupLayout(&descriptor);
} }
// wgpu::BindingType::WriteonlyStorageTexture is a valid binding type to create a bind group // WriteOnly is a valid storage texture binding type to create a bind group
// layout. // layout.
{ {
wgpu::BindGroupLayoutEntry entry; wgpu::BindGroupLayoutEntry entry;

View File

@ -266,7 +266,7 @@ TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
// Check that view doesn't have extra formats like Sampled. // Check that view doesn't have extra formats like Sampled.
// TODO(cwallez@chromium.org): also check for [Readonly]Storage once that's implemented. // TODO(cwallez@chromium.org): also check for [Readonly]Storage once that's implemented.
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bgl, {{0, view}})); ASSERT_DEVICE_ERROR(utils::MakeBindGroup(device, bgl, {{0, view}}));
} }

View File

@ -330,7 +330,7 @@ void DrawCallPerf::SetUp() {
mUniformBindGroupLayout = utils::MakeBindGroupLayout( mUniformBindGroupLayout = utils::MakeBindGroupLayout(
device, device,
{ {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, false}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, false},
}); });
break; break;
@ -338,7 +338,7 @@ void DrawCallPerf::SetUp() {
mUniformBindGroupLayout = utils::MakeBindGroupLayout( mUniformBindGroupLayout = utils::MakeBindGroupLayout(
device, device,
{ {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, true}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, true},
}); });
break; break;
@ -381,7 +381,7 @@ void DrawCallPerf::SetUp() {
// all draws. // all draws.
mConstantBindGroupLayout = utils::MakeBindGroupLayout( mConstantBindGroupLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, false}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, false},
}); });
// Create the pipeline layout. // Create the pipeline layout.

View File

@ -92,7 +92,7 @@ TEST_F(BindGroupValidationTest, NextInChainNullptr) {
// Check constraints on entryCount // Check constraints on entryCount
TEST_F(BindGroupValidationTest, EntryCountMismatch) { TEST_F(BindGroupValidationTest, EntryCountMismatch) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
// Control case: check that a descriptor with one binding is ok // Control case: check that a descriptor with one binding is ok
utils::MakeBindGroup(device, layout, {{0, mSampler}}); utils::MakeBindGroup(device, layout, {{0, mSampler}});
@ -104,7 +104,7 @@ TEST_F(BindGroupValidationTest, EntryCountMismatch) {
// Check constraints on BindGroupEntry::binding // Check constraints on BindGroupEntry::binding
TEST_F(BindGroupValidationTest, WrongBindings) { TEST_F(BindGroupValidationTest, WrongBindings) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
// Control case: check that a descriptor with a binding matching the layout's is ok // Control case: check that a descriptor with a binding matching the layout's is ok
utils::MakeBindGroup(device, layout, {{0, mSampler}}); utils::MakeBindGroup(device, layout, {{0, mSampler}});
@ -116,8 +116,8 @@ TEST_F(BindGroupValidationTest, WrongBindings) {
// Check that the same binding cannot be set twice // Check that the same binding cannot be set twice
TEST_F(BindGroupValidationTest, BindingSetTwice) { TEST_F(BindGroupValidationTest, BindingSetTwice) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}, device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); {1, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
// Control case: check that different bindings work // Control case: check that different bindings work
utils::MakeBindGroup(device, layout, {{0, mSampler}, {1, mSampler}}); utils::MakeBindGroup(device, layout, {{0, mSampler}, {1, mSampler}});
@ -129,7 +129,7 @@ TEST_F(BindGroupValidationTest, BindingSetTwice) {
// Check that a sampler binding must contain exactly one sampler // Check that a sampler binding must contain exactly one sampler
TEST_F(BindGroupValidationTest, SamplerBindingType) { TEST_F(BindGroupValidationTest, SamplerBindingType) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
wgpu::BindGroupEntry binding; wgpu::BindGroupEntry binding;
binding.binding = 0; binding.binding = 0;
@ -178,7 +178,7 @@ TEST_F(BindGroupValidationTest, SamplerBindingType) {
// Check that a texture binding must contain exactly a texture view // Check that a texture binding must contain exactly a texture view
TEST_F(BindGroupValidationTest, TextureBindingType) { TEST_F(BindGroupValidationTest, TextureBindingType) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::BindGroupEntry binding; wgpu::BindGroupEntry binding;
binding.binding = 0; binding.binding = 0;
@ -232,7 +232,7 @@ TEST_F(BindGroupValidationTest, TextureBindingType) {
// Check that a buffer binding must contain exactly a buffer // Check that a buffer binding must contain exactly a buffer
TEST_F(BindGroupValidationTest, BufferBindingType) { TEST_F(BindGroupValidationTest, BufferBindingType) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupEntry binding; wgpu::BindGroupEntry binding;
binding.binding = 0; binding.binding = 0;
@ -282,7 +282,7 @@ TEST_F(BindGroupValidationTest, BufferBindingType) {
// Check that a texture must have the correct usage // Check that a texture must have the correct usage
TEST_F(BindGroupValidationTest, TextureUsage) { TEST_F(BindGroupValidationTest, TextureUsage) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
// Control case: setting a sampleable texture view works. // Control case: setting a sampleable texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}}); utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
@ -297,8 +297,7 @@ TEST_F(BindGroupValidationTest, TextureUsage) {
// Check that a texture must have the correct component type // Check that a texture must have the correct component type
TEST_F(BindGroupValidationTest, TextureComponentType) { TEST_F(BindGroupValidationTest, TextureComponentType) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
// Control case: setting a Float typed texture view works. // Control case: setting a Float typed texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}}); utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
@ -314,7 +313,7 @@ TEST_F(BindGroupValidationTest, TextureComponentType) {
// Test which depth-stencil formats are allowed to be sampled (all). // Test which depth-stencil formats are allowed to be sampled (all).
TEST_F(BindGroupValidationTest, SamplingDepthStencilTexture) { TEST_F(BindGroupValidationTest, SamplingDepthStencilTexture) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureDescriptor desc; wgpu::TextureDescriptor desc;
desc.size = {1, 1, 1}; desc.size = {1, 1, 1};
@ -356,8 +355,7 @@ TEST_F(BindGroupValidationTest, SamplingDepthStencilTexture) {
// Check that a texture must have a correct format for DepthComparison // Check that a texture must have a correct format for DepthComparison
TEST_F(BindGroupValidationTest, TextureComponentTypeDepthComparison) { TEST_F(BindGroupValidationTest, TextureComponentTypeDepthComparison) {
wgpu::BindGroupLayout depthLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout depthLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison}});
// Control case: setting a depth texture works. // Control case: setting a depth texture works.
wgpu::Texture depthTexture = wgpu::Texture depthTexture =
@ -372,12 +370,10 @@ TEST_F(BindGroupValidationTest, TextureComponentTypeDepthComparison) {
// ::DepthComparison // ::DepthComparison
TEST_F(BindGroupValidationTest, TextureComponentTypeForDepthTexture) { TEST_F(BindGroupValidationTest, TextureComponentTypeForDepthTexture) {
wgpu::BindGroupLayout depthLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout depthLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison}});
wgpu::BindGroupLayout floatLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout floatLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
wgpu::Texture depthTexture = wgpu::Texture depthTexture =
CreateTexture(wgpu::TextureUsage::Sampled, wgpu::TextureFormat::Depth32Float, 1); CreateTexture(wgpu::TextureUsage::Sampled, wgpu::TextureFormat::Depth32Float, 1);
@ -389,8 +385,7 @@ TEST_F(BindGroupValidationTest, TextureComponentTypeForDepthTexture) {
// Check that a texture must have the correct dimension // Check that a texture must have the correct dimension
TEST_F(BindGroupValidationTest, TextureDimension) { TEST_F(BindGroupValidationTest, TextureDimension) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}});
// Control case: setting a 2D texture view works. // Control case: setting a 2D texture view works.
utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}}); utils::MakeBindGroup(device, layout, {{0, mSampledTextureView}});
@ -406,7 +401,7 @@ TEST_F(BindGroupValidationTest, TextureDimension) {
// Check that a UBO must have the correct usage // Check that a UBO must have the correct usage
TEST_F(BindGroupValidationTest, BufferUsageUBO) { TEST_F(BindGroupValidationTest, BufferUsageUBO) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
// Control case: using a buffer with the uniform usage works // Control case: using a buffer with the uniform usage works
utils::MakeBindGroup(device, layout, {{0, mUBO, 0, 256}}); utils::MakeBindGroup(device, layout, {{0, mUBO, 0, 256}});
@ -418,7 +413,7 @@ TEST_F(BindGroupValidationTest, BufferUsageUBO) {
// Check that a SSBO must have the correct usage // Check that a SSBO must have the correct usage
TEST_F(BindGroupValidationTest, BufferUsageSSBO) { TEST_F(BindGroupValidationTest, BufferUsageSSBO) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
// Control case: using a buffer with the storage usage works // Control case: using a buffer with the storage usage works
utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}}); utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}});
@ -430,7 +425,7 @@ TEST_F(BindGroupValidationTest, BufferUsageSSBO) {
// Check that a readonly SSBO must have the correct usage // Check that a readonly SSBO must have the correct usage
TEST_F(BindGroupValidationTest, BufferUsageReadonlySSBO) { TEST_F(BindGroupValidationTest, BufferUsageReadonlySSBO) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage}});
// Control case: using a buffer with the storage usage works // Control case: using a buffer with the storage usage works
utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}}); utils::MakeBindGroup(device, layout, {{0, mSSBO, 0, 256}});
@ -443,7 +438,7 @@ TEST_F(BindGroupValidationTest, BufferUsageReadonlySSBO) {
TEST_F(BindGroupValidationTest, BufferOffsetAlignment) { TEST_F(BindGroupValidationTest, BufferOffsetAlignment) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
}); });
// Check that offset 0 is valid // Check that offset 0 is valid
@ -461,8 +456,8 @@ TEST_F(BindGroupValidationTest, BufferOffsetAlignment) {
// Tests constraints on the texture for MultisampledTexture bindings // Tests constraints on the texture for MultisampledTexture bindings
TEST_F(BindGroupValidationTest, MultisampledTexture) { TEST_F(BindGroupValidationTest, MultisampledTexture) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::MultisampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}}); wgpu::TextureViewDimension::e2D, true}});
wgpu::BindGroupEntry binding; wgpu::BindGroupEntry binding;
binding.binding = 0; binding.binding = 0;
@ -503,7 +498,7 @@ TEST_F(BindGroupValidationTest, MultisampledTexture) {
TEST_F(BindGroupValidationTest, BufferBindingOOB) { TEST_F(BindGroupValidationTest, BufferBindingOOB) {
wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout layout = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
}); });
wgpu::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
@ -549,14 +544,14 @@ TEST_F(BindGroupValidationTest, MaxUniformBufferBindingSize) {
wgpu::Buffer buffer = device.CreateBuffer(&descriptor); wgpu::Buffer buffer = device.CreateBuffer(&descriptor);
wgpu::BindGroupLayout uniformLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout uniformLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
// Success case, this is exactly the limit // Success case, this is exactly the limit
utils::MakeBindGroup(device, uniformLayout, {{0, buffer, 0, kMaxUniformBufferBindingSize}}); utils::MakeBindGroup(device, uniformLayout, {{0, buffer, 0, kMaxUniformBufferBindingSize}});
wgpu::BindGroupLayout doubleUniformLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout doubleUniformLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, device, {{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); {1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
// Success case, individual bindings don't exceed the limit // Success case, individual bindings don't exceed the limit
utils::MakeBindGroup(device, doubleUniformLayout, utils::MakeBindGroup(device, doubleUniformLayout,
@ -569,9 +564,9 @@ TEST_F(BindGroupValidationTest, MaxUniformBufferBindingSize) {
// Making sure the constraint doesn't apply to storage buffers // Making sure the constraint doesn't apply to storage buffers
wgpu::BindGroupLayout readonlyStorageLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readonlyStorageLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroupLayout storageLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout storageLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
// Success case, storage buffer can still be created. // Success case, storage buffer can still be created.
utils::MakeBindGroup(device, readonlyStorageLayout, utils::MakeBindGroup(device, readonlyStorageLayout,
@ -583,15 +578,15 @@ TEST_F(BindGroupValidationTest, MaxUniformBufferBindingSize) {
TEST_F(BindGroupValidationTest, ErrorLayout) { TEST_F(BindGroupValidationTest, ErrorLayout) {
wgpu::BindGroupLayout goodLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout goodLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
}); });
wgpu::BindGroupLayout errorLayout; wgpu::BindGroupLayout errorLayout;
ASSERT_DEVICE_ERROR( ASSERT_DEVICE_ERROR(
errorLayout = utils::MakeBindGroupLayout( errorLayout = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
})); }));
// Control case, creating with the good layout works // Control case, creating with the good layout works
@ -660,7 +655,7 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutEntryNumberLarge) {
// Checks that uint32_t max is valid. // Checks that uint32_t max is valid.
utils::MakeBindGroupLayout(device, utils::MakeBindGroupLayout(device,
{{std::numeric_limits<uint32_t>::max(), wgpu::ShaderStage::Vertex, {{std::numeric_limits<uint32_t>::max(), wgpu::ShaderStage::Vertex,
wgpu::BindingType::UniformBuffer}}); wgpu::BufferBindingType::Uniform}});
} }
// This test verifies that the BindGroupLayout bindings are correctly validated, even if the // This test verifies that the BindGroupLayout bindings are correctly validated, even if the
@ -668,44 +663,34 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutEntryNumberLarge) {
TEST_F(BindGroupLayoutValidationTest, BindGroupEntry) { TEST_F(BindGroupLayoutValidationTest, BindGroupEntry) {
utils::MakeBindGroupLayout(device, utils::MakeBindGroupLayout(device,
{ {
{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
}); });
} }
// Check that dynamic = true is only allowed with buffer bindings. // Check that dynamic = true is only allowed buffer bindings.
TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) { TEST_F(BindGroupLayoutValidationTest, DynamicAndTypeCompatibility) {
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform, true},
}); });
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage, true},
}); });
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage, true},
}); });
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, true},
}));
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::Sampler, true},
}));
} }
// This test verifies that visibility of bindings in BindGroupLayout can be none // This test verifies that visibility of bindings in BindGroupLayout can be none
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) { TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
utils::MakeBindGroupLayout(device, utils::MakeBindGroupLayout(device,
{ {
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
}); });
wgpu::BindGroupLayoutEntry entry; wgpu::BindGroupLayoutEntry entry;
@ -723,8 +708,8 @@ TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNone) {
TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNoneExpectsBindGroupEntry) { TEST_F(BindGroupLayoutValidationTest, BindGroupLayoutVisibilityNoneExpectsBindGroupEntry) {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
{1, wgpu::ShaderStage::None, wgpu::BindingType::UniformBuffer}, {1, wgpu::ShaderStage::None, wgpu::BufferBindingType::Uniform},
}); });
wgpu::BufferDescriptor descriptor; wgpu::BufferDescriptor descriptor;
descriptor.size = 4; descriptor.size = 4;
@ -765,14 +750,41 @@ TEST_F(BindGroupLayoutValidationTest, PerStageLimits) {
auto PopulateEntry = [](utils::BindingLayoutEntryInitializationHelper entry) { auto PopulateEntry = [](utils::BindingLayoutEntryInitializationHelper entry) {
switch (entry.type) { switch (entry.type) {
case wgpu::BindingType::UniformBuffer:
entry.buffer.type = wgpu::BufferBindingType::Uniform;
break;
case wgpu::BindingType::StorageBuffer:
entry.buffer.type = wgpu::BufferBindingType::Storage;
break;
case wgpu::BindingType::ReadonlyStorageBuffer:
entry.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
break;
case wgpu::BindingType::Sampler:
entry.sampler.type = wgpu::SamplerBindingType::Filtering;
break;
case wgpu::BindingType::ComparisonSampler:
entry.sampler.type = wgpu::SamplerBindingType::Comparison;
break;
case wgpu::BindingType::SampledTexture:
entry.texture.sampleType = wgpu::TextureSampleType::Float;
break;
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::BindingType::ReadonlyStorageTexture:
entry.storageTexture.access = wgpu::StorageTextureAccess::ReadOnly;
entry.storageTexture.format = wgpu::TextureFormat::RGBA8Unorm;
break;
case wgpu::BindingType::WriteonlyStorageTexture: case wgpu::BindingType::WriteonlyStorageTexture:
entry.storageTextureFormat = wgpu::TextureFormat::RGBA8Unorm; entry.storageTexture.access = wgpu::StorageTextureAccess::WriteOnly;
entry.storageTexture.format = wgpu::TextureFormat::RGBA8Unorm;
break; break;
default: default:
break; return entry;
} }
entry.type = wgpu::BindingType::Undefined;
return entry; return entry;
}; };
@ -843,17 +855,17 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
for (uint32_t i = 0; i < kMaxDynamicUniformBuffersPerPipelineLayout; ++i) { for (uint32_t i = 0; i < kMaxDynamicUniformBuffersPerPipelineLayout; ++i) {
maxUniformDB.push_back(utils::BindingLayoutEntryInitializationHelper( maxUniformDB.push_back(utils::BindingLayoutEntryInitializationHelper(
i, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, true)); i, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform, true));
} }
for (uint32_t i = 0; i < kMaxDynamicStorageBuffersPerPipelineLayout; ++i) { for (uint32_t i = 0; i < kMaxDynamicStorageBuffersPerPipelineLayout; ++i) {
maxStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper( maxStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper(
i, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer, true)); i, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage, true));
} }
for (uint32_t i = 0; i < kMaxDynamicStorageBuffersPerPipelineLayout; ++i) { for (uint32_t i = 0; i < kMaxDynamicStorageBuffersPerPipelineLayout; ++i) {
maxReadonlyStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper( maxReadonlyStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper(
i, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer, true)); i, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage, true));
} }
// Test creating with the maxes works // Test creating with the maxes works
@ -876,7 +888,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
bgl[0] = MakeBindGroupLayout(maxUniformDB.data(), maxUniformDB.size()); bgl[0] = MakeBindGroupLayout(maxUniformDB.data(), maxUniformDB.size());
bgl[1] = utils::MakeBindGroupLayout( bgl[1] = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer, true}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform, true},
}); });
TestCreatePipelineLayout(bgl, 2, false); TestCreatePipelineLayout(bgl, 2, false);
@ -887,7 +899,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
bgl[0] = MakeBindGroupLayout(maxStorageDB.data(), maxStorageDB.size()); bgl[0] = MakeBindGroupLayout(maxStorageDB.data(), maxStorageDB.size());
bgl[1] = utils::MakeBindGroupLayout( bgl[1] = utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer, true}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage, true},
}); });
TestCreatePipelineLayout(bgl, 2, false); TestCreatePipelineLayout(bgl, 2, false);
@ -899,7 +911,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
bgl[1] = utils::MakeBindGroupLayout( bgl[1] = utils::MakeBindGroupLayout(
device, device,
{ {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer, true}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage, true},
}); });
TestCreatePipelineLayout(bgl, 2, false); TestCreatePipelineLayout(bgl, 2, false);
@ -912,7 +924,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
bgl[1] = utils::MakeBindGroupLayout( bgl[1] = utils::MakeBindGroupLayout(
device, device,
{ {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer, true}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage, true},
}); });
TestCreatePipelineLayout(bgl, 2, false); TestCreatePipelineLayout(bgl, 2, false);
@ -922,7 +934,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
{ {
maxUniformDB.push_back(utils::BindingLayoutEntryInitializationHelper( maxUniformDB.push_back(utils::BindingLayoutEntryInitializationHelper(
kMaxDynamicUniformBuffersPerPipelineLayout, wgpu::ShaderStage::Fragment, kMaxDynamicUniformBuffersPerPipelineLayout, wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer, true)); wgpu::BufferBindingType::Uniform, true));
TestCreateBindGroupLayout(maxUniformDB.data(), maxUniformDB.size(), false); TestCreateBindGroupLayout(maxUniformDB.data(), maxUniformDB.size(), false);
} }
@ -930,7 +942,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
{ {
maxStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper( maxStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper(
kMaxDynamicStorageBuffersPerPipelineLayout, wgpu::ShaderStage::Fragment, kMaxDynamicStorageBuffersPerPipelineLayout, wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer, true)); wgpu::BufferBindingType::Storage, true));
TestCreateBindGroupLayout(maxStorageDB.data(), maxStorageDB.size(), false); TestCreateBindGroupLayout(maxStorageDB.data(), maxStorageDB.size(), false);
} }
@ -938,7 +950,7 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
{ {
maxReadonlyStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper( maxReadonlyStorageDB.push_back(utils::BindingLayoutEntryInitializationHelper(
kMaxDynamicStorageBuffersPerPipelineLayout, wgpu::ShaderStage::Fragment, kMaxDynamicStorageBuffersPerPipelineLayout, wgpu::ShaderStage::Fragment,
wgpu::BindingType::ReadonlyStorageBuffer, true)); wgpu::BufferBindingType::ReadOnlyStorage, true));
TestCreateBindGroupLayout(maxReadonlyStorageDB.data(), maxReadonlyStorageDB.size(), false); TestCreateBindGroupLayout(maxReadonlyStorageDB.data(), maxReadonlyStorageDB.size(), false);
} }
} }
@ -946,92 +958,84 @@ TEST_F(BindGroupLayoutValidationTest, DynamicBufferNumberLimit) {
// Test that multisampled textures must be 2D sampled textures // Test that multisampled textures must be 2D sampled textures
TEST_F(BindGroupLayoutValidationTest, MultisampledTextureViewDimension) { TEST_F(BindGroupLayoutValidationTest, MultisampledTextureViewDimension) {
// Multisampled 2D texture works. // Multisampled 2D texture works.
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(device,
device, { {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::e2D}, wgpu::TextureViewDimension::e2D, true},
}); });
// Multisampled 2D (defaulted) texture works. // Multisampled 2D (defaulted) texture works.
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(device,
device, { {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::Undefined}, wgpu::TextureViewDimension::Undefined, true},
}); });
// Multisampled 2D array texture is invalid. // Multisampled 2D array texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::e2DArray}, wgpu::TextureViewDimension::e2DArray, true},
})); }));
// Multisampled cube texture is invalid. // Multisampled cube texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::Cube}, wgpu::TextureViewDimension::Cube, true},
})); }));
// Multisampled cube array texture is invalid. // Multisampled cube array texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::CubeArray}, wgpu::TextureViewDimension::CubeArray, true},
})); }));
// Multisampled 3D texture is invalid. // Multisampled 3D texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::e3D}, wgpu::TextureViewDimension::e3D, true},
})); }));
// Multisampled 1D texture is invalid. // Multisampled 1D texture is invalid.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::e1D}, wgpu::TextureViewDimension::e1D, true},
})); }));
} }
// Test that multisampled textures cannot be DepthComparison // Test that multisampled textures cannot be DepthComparison
TEST_F(BindGroupLayoutValidationTest, MultisampledTextureComponentType) { TEST_F(BindGroupLayoutValidationTest, MultisampledTextureComponentType) {
// Multisampled float component type works. // Multisampled float component type works.
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(device,
device, { {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
0, wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Float}, wgpu::TextureViewDimension::e2D, true},
}); });
// Multisampled float (defaulted) component type works.
utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false,
0, wgpu::TextureViewDimension::e2D},
});
// Multisampled uint component type works. // Multisampled uint component type works.
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(device,
device, { {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Uint,
0, wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Uint}, wgpu::TextureViewDimension::e2D, true},
}); });
// Multisampled sint component type works. // Multisampled sint component type works.
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(device,
device, { {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Sint,
0, wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::Sint}, wgpu::TextureViewDimension::e2D, true},
}); });
// Multisampled depth comparison component typeworks. // Multisampled depth comparison component typeworks.
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, device, {
{ {0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Depth,
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::MultisampledTexture, false, 0, wgpu::TextureViewDimension::e2D, true},
wgpu::TextureViewDimension::e2D, wgpu::TextureComponentType::DepthComparison}, }));
}));
} }
constexpr uint64_t kBufferSize = 3 * kMinDynamicBufferOffsetAlignment + 8; constexpr uint64_t kBufferSize = 3 * kMinDynamicBufferOffsetAlignment + 8;
@ -1044,13 +1048,13 @@ class SetBindGroupValidationTest : public ValidationTest {
mBindGroupLayout = utils::MakeBindGroupLayout( mBindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer, true}, wgpu::BufferBindingType::Uniform, true},
{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer, false}, wgpu::BufferBindingType::Uniform, false},
{2, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {2, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer, true}, wgpu::BufferBindingType::Storage, true},
{3, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {3, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::ReadonlyStorageBuffer, true}}); wgpu::BufferBindingType::ReadOnlyStorage, true}});
} }
wgpu::Buffer CreateBuffer(uint64_t bufferSize, wgpu::BufferUsage usage) { wgpu::Buffer CreateBuffer(uint64_t bufferSize, wgpu::BufferUsage usage) {
@ -1201,7 +1205,7 @@ TEST_F(SetBindGroupValidationTest, VerifyGroupIfChangedAfterAction) {
// Set up bind group that is incompatible // Set up bind group that is incompatible
wgpu::BindGroupLayout invalidLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout invalidLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
wgpu::BindGroup invalidGroup = wgpu::BindGroup invalidGroup =
utils::MakeBindGroup(device, invalidLayout, {{0, storageBuffer, 0, kBindingSize}}); utils::MakeBindGroup(device, invalidLayout, {{0, storageBuffer, 0, kBindingSize}});
@ -1366,9 +1370,9 @@ TEST_F(SetBindGroupValidationTest, DynamicOffsetOrder) {
// binding number before type. // binding number before type.
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, { device, {
{3, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer, true}, {3, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage, true},
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer, true}, {0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage, true},
{2, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, true}, {2, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform, true},
}); });
// Create buffers which are 3x, 2x, and 1x the size of the minimum buffer offset, plus 4 bytes // Create buffers which are 3x, 2x, and 1x the size of the minimum buffer offset, plus 4 bytes
@ -1482,7 +1486,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
// Generates bind group layouts and a pipeline from a 2D list of binding types. // Generates bind group layouts and a pipeline from a 2D list of binding types.
std::tuple<std::vector<wgpu::BindGroupLayout>, wgpu::RenderPipeline> SetUpLayoutsAndPipeline( std::tuple<std::vector<wgpu::BindGroupLayout>, wgpu::RenderPipeline> SetUpLayoutsAndPipeline(
std::vector<std::vector<wgpu::BindingType>> layouts) { std::vector<std::vector<wgpu::BufferBindingType>> layouts) {
std::vector<wgpu::BindGroupLayout> bindGroupLayouts(layouts.size()); std::vector<wgpu::BindGroupLayout> bindGroupLayouts(layouts.size());
// Iterate through the desired bind group layouts. // Iterate through the desired bind group layouts.
@ -1493,7 +1497,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
// Iterate through binding types and populate a list of BindGroupLayoutEntrys. // Iterate through binding types and populate a list of BindGroupLayoutEntrys.
for (uint32_t b = 0; b < layout.size(); ++b) { for (uint32_t b = 0; b < layout.size(); ++b) {
bindings[b] = utils::BindingLayoutEntryInitializationHelper( bindings[b] = utils::BindingLayoutEntryInitializationHelper(
b, wgpu::ShaderStage::Fragment, layout[b], false); b, wgpu::ShaderStage::Fragment, layout[b]);
} }
// Create the bind group layout. // Create the bind group layout.
@ -1520,14 +1524,14 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
const auto& layout = layouts[l]; const auto& layout = layouts[l];
for (uint32_t b = 0; b < layout.size(); ++b) { for (uint32_t b = 0; b < layout.size(); ++b) {
wgpu::BindingType binding = layout[b]; wgpu::BufferBindingType binding = layout[b];
ss << "[[set(" << l << "), binding(" << b << ")]] "; ss << "[[set(" << l << "), binding(" << b << ")]] ";
switch (binding) { switch (binding) {
case wgpu::BindingType::StorageBuffer: case wgpu::BufferBindingType::Storage:
ss << "var<storage_buffer> set" << l << "_binding" << b ss << "var<storage_buffer> set" << l << "_binding" << b
<< " : [[access(read_write)]] S;"; << " : [[access(read_write)]] S;";
break; break;
case wgpu::BindingType::UniformBuffer: case wgpu::BufferBindingType::Uniform:
ss << "var<uniform> set" << l << "_binding" << b << " : S;"; ss << "var<uniform> set" << l << "_binding" << b << " : S;";
break; break;
default: default:
@ -1559,12 +1563,12 @@ TEST_F(SetBindGroupPersistenceValidationTest, BindGroupBeforePipeline) {
wgpu::RenderPipeline pipeline; wgpu::RenderPipeline pipeline;
std::tie(bindGroupLayouts, pipeline) = SetUpLayoutsAndPipeline({{ std::tie(bindGroupLayouts, pipeline) = SetUpLayoutsAndPipeline({{
{{ {{
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
}}, }},
{{ {{
wgpu::BindingType::StorageBuffer, wgpu::BufferBindingType::Storage,
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
}}, }},
}}); }});
@ -1600,12 +1604,12 @@ TEST_F(SetBindGroupPersistenceValidationTest, NotVulkanInheritance) {
wgpu::RenderPipeline pipelineA; wgpu::RenderPipeline pipelineA;
std::tie(bindGroupLayoutsA, pipelineA) = SetUpLayoutsAndPipeline({{ std::tie(bindGroupLayoutsA, pipelineA) = SetUpLayoutsAndPipeline({{
{{ {{
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
wgpu::BindingType::StorageBuffer, wgpu::BufferBindingType::Storage,
}}, }},
{{ {{
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
}}, }},
}}); }});
@ -1613,12 +1617,12 @@ TEST_F(SetBindGroupPersistenceValidationTest, NotVulkanInheritance) {
wgpu::RenderPipeline pipelineB; wgpu::RenderPipeline pipelineB;
std::tie(bindGroupLayoutsB, pipelineB) = SetUpLayoutsAndPipeline({{ std::tie(bindGroupLayoutsB, pipelineB) = SetUpLayoutsAndPipeline({{
{{ {{
wgpu::BindingType::StorageBuffer, wgpu::BufferBindingType::Storage,
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
}}, }},
{{ {{
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
wgpu::BindingType::UniformBuffer, wgpu::BufferBindingType::Uniform,
}}, }},
}}); }});
@ -1740,10 +1744,10 @@ TEST_F(BindGroupLayoutCompatibilityTest, RWStorageInBGLWithROStorageInShader) {
// Set up the bind group layout. // Set up the bind group layout.
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
CreateRenderPipeline({bgl0, bgl1}); CreateRenderPipeline({bgl0, bgl1});
@ -1756,10 +1760,10 @@ TEST_F(BindGroupLayoutCompatibilityTest, ROStorageInBGLWithRWStorageInShader) {
// Set up the bind group layout. // Set up the bind group layout.
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::ReadonlyStorageBuffer}}); wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::ReadonlyStorageBuffer}}); wgpu::BufferBindingType::ReadOnlyStorage}});
ASSERT_DEVICE_ERROR(CreateRenderPipeline({bgl0, bgl1})); ASSERT_DEVICE_ERROR(CreateRenderPipeline({bgl0, bgl1}));
@ -1780,29 +1784,29 @@ TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
CreateFSRenderPipeline( CreateFSRenderPipeline(
kTexture2DShaderFS, kTexture2DShaderFS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2D}})}); wgpu::TextureViewDimension::e2D}})});
// Render: Test that 2D texture with 2D array view dimension is invalid // Render: Test that 2D texture with 2D array view dimension is invalid
ASSERT_DEVICE_ERROR(CreateFSRenderPipeline( ASSERT_DEVICE_ERROR(CreateFSRenderPipeline(
kTexture2DShaderFS, kTexture2DShaderFS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2DArray}})})); wgpu::TextureViewDimension::e2DArray}})}));
// Compute: Test that 2D texture with 2D view dimension works // Compute: Test that 2D texture with 2D view dimension works
CreateComputePipeline( CreateComputePipeline(
kTexture2DShaderCS, kTexture2DShaderCS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(device,
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0, {{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2D}})}); wgpu::TextureViewDimension::e2D}})});
// Compute: Test that 2D texture with 2D array view dimension is invalid // Compute: Test that 2D texture with 2D array view dimension is invalid
ASSERT_DEVICE_ERROR(CreateComputePipeline( ASSERT_DEVICE_ERROR(CreateComputePipeline(
kTexture2DShaderCS, kTexture2DShaderCS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(device,
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0, {{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2DArray}})})); wgpu::TextureViewDimension::e2DArray}})}));
constexpr char kTexture2DArrayShaderFS[] = R"( constexpr char kTexture2DArrayShaderFS[] = R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d_array<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d_array<f32>;
@ -1817,29 +1821,29 @@ TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
CreateFSRenderPipeline( CreateFSRenderPipeline(
kTexture2DArrayShaderFS, kTexture2DArrayShaderFS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2DArray}})}); wgpu::TextureViewDimension::e2DArray}})});
// Render: Test that 2D texture array with 2D view dimension is invalid // Render: Test that 2D texture array with 2D view dimension is invalid
ASSERT_DEVICE_ERROR(CreateFSRenderPipeline( ASSERT_DEVICE_ERROR(CreateFSRenderPipeline(
kTexture2DArrayShaderFS, kTexture2DArrayShaderFS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2D}})})); wgpu::TextureViewDimension::e2D}})}));
// Compute: Test that 2D texture array with 2D array view dimension works // Compute: Test that 2D texture array with 2D array view dimension works
CreateComputePipeline( CreateComputePipeline(
kTexture2DArrayShaderCS, kTexture2DArrayShaderCS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(device,
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0, {{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2DArray}})}); wgpu::TextureViewDimension::e2DArray}})});
// Compute: Test that 2D texture array with 2D view dimension is invalid // Compute: Test that 2D texture array with 2D view dimension is invalid
ASSERT_DEVICE_ERROR(CreateComputePipeline( ASSERT_DEVICE_ERROR(CreateComputePipeline(
kTexture2DArrayShaderCS, kTexture2DArrayShaderCS,
{utils::MakeBindGroupLayout( {utils::MakeBindGroupLayout(device,
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0, {{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float,
wgpu::TextureViewDimension::e2D}})})); wgpu::TextureViewDimension::e2D}})}));
} }
class BindingsValidationTest : public BindGroupLayoutCompatibilityTest { class BindingsValidationTest : public BindGroupLayoutCompatibilityTest {
@ -1891,15 +1895,15 @@ TEST_F(BindingsValidationTest, PipelineLayoutWithMoreBindingsThanPipeline) {
// Set up bind group layouts. // Set up bind group layouts.
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}, wgpu::BufferBindingType::Storage},
{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer}}); wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::ReadonlyStorageBuffer}}); wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroupLayout bgl2 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl2 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
// pipelineLayout has unused binding set (bgl2) and unused entry in a binding set (bgl0). // pipelineLayout has unused binding set (bgl2) and unused entry in a binding set (bgl0).
CreateRenderPipeline({bgl0, bgl1, bgl2}); CreateRenderPipeline({bgl0, bgl1, bgl2});
@ -1913,7 +1917,7 @@ TEST_F(BindingsValidationTest, PipelineLayoutWithLessBindingsThanPipeline) {
// Set up bind group layout. // Set up bind group layout.
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
// missing a binding set (bgl1) in pipeline layout // missing a binding set (bgl1) in pipeline layout
{ {
@ -1935,7 +1939,7 @@ TEST_F(BindingsValidationTest, PipelineLayoutWithLessBindingsThanPipeline) {
{ {
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer}}); wgpu::BufferBindingType::Uniform}});
ASSERT_DEVICE_ERROR(CreateRenderPipeline({bgl0, bgl1})); ASSERT_DEVICE_ERROR(CreateRenderPipeline({bgl0, bgl1}));
@ -1954,7 +1958,7 @@ TEST_F(BindingsValidationTest, BindGroupsWithMoreBindingsThanPipelineLayout) {
for (uint32_t i = 0; i < kBindingNum + 1; ++i) { for (uint32_t i = 0; i < kBindingNum + 1; ++i) {
bgl[i] = utils::MakeBindGroupLayout( bgl[i] = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
buffer[i] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage); buffer[i] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
bg[i] = utils::MakeBindGroup(device, bgl[i], {{0, buffer[i]}}); bg[i] = utils::MakeBindGroup(device, bgl[i], {{0, buffer[i]}});
} }
@ -1973,9 +1977,9 @@ TEST_F(BindingsValidationTest, BindGroupsWithMoreBindingsThanPipelineLayout) {
// set in pipeline layout. // set in pipeline layout.
bgl[1] = utils::MakeBindGroupLayout( bgl[1] = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::ReadonlyStorageBuffer}, wgpu::BufferBindingType::ReadOnlyStorage},
{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, {1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer}}); wgpu::BufferBindingType::Uniform}});
buffer[1] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform); buffer[1] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform);
bg[1] = utils::MakeBindGroup(device, bgl[1], {{0, buffer[1]}, {1, buffer[1]}}); bg[1] = utils::MakeBindGroup(device, bgl[1], {{0, buffer[1]}, {1, buffer[1]}});
@ -1995,7 +1999,7 @@ TEST_F(BindingsValidationTest, BindGroupsWithLessBindingsThanPipelineLayout) {
for (uint32_t i = 0; i < kBindingNum; ++i) { for (uint32_t i = 0; i < kBindingNum; ++i) {
bgl[i] = utils::MakeBindGroupLayout( bgl[i] = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{0, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
buffer[i] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage); buffer[i] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Storage);
bg[i] = utils::MakeBindGroup(device, bgl[i], {{0, buffer[i]}}); bg[i] = utils::MakeBindGroup(device, bgl[i], {{0, buffer[i]}});
} }
@ -2020,7 +2024,7 @@ TEST_F(BindingsValidationTest, BindGroupsWithLessBindingsThanPipelineLayout) {
// binding // binding
bgl[2] = utils::MakeBindGroupLayout( bgl[2] = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment, device, {{1, wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment,
wgpu::BindingType::UniformBuffer}}); wgpu::BufferBindingType::Uniform}});
buffer[2] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform); buffer[2] = CreateBuffer(kBufferSize, wgpu::BufferUsage::Uniform);
bg[2] = utils::MakeBindGroup(device, bgl[2], {{1, buffer[2]}}); bg[2] = utils::MakeBindGroup(device, bgl[2], {{1, buffer[2]}});
@ -2055,7 +2059,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
// Test that sampler binding works with normal sampler in the shader. // Test that sampler binding works with normal sampler in the shader.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[set(0), binding(0)]] var<uniform_constant> mySampler: sampler;
@ -2066,7 +2070,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
// Test that comparison sampler binding works with shadow sampler in the shader. // Test that comparison sampler binding works with shadow sampler in the shader.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ComparisonSampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
CreateFragmentPipeline(&bindGroupLayout, R"( CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison; [[set(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison;
@ -2077,7 +2081,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
// Test that sampler binding does not work with comparison sampler in the shader. // Test that sampler binding does not work with comparison sampler in the shader.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison; [[set(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison;
@ -2088,7 +2092,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
// Test that comparison sampler binding does not work with normal sampler in the shader. // Test that comparison sampler binding does not work with normal sampler in the shader.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ComparisonSampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"( ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler; [[set(0), binding(0)]] var<uniform_constant> mySampler: sampler;
@ -2101,7 +2105,7 @@ TEST_F(ComparisonSamplerBindingTest, SamplerAndBindGroupMatches) {
// Test that sampler binding works with normal sampler. // Test that sampler binding works with normal sampler.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
wgpu::SamplerDescriptor desc = {}; wgpu::SamplerDescriptor desc = {};
utils::MakeBindGroup(device, bindGroupLayout, {{0, device.CreateSampler(&desc)}}); utils::MakeBindGroup(device, bindGroupLayout, {{0, device.CreateSampler(&desc)}});
@ -2110,7 +2114,7 @@ TEST_F(ComparisonSamplerBindingTest, SamplerAndBindGroupMatches) {
// Test that comparison sampler binding works with sampler w/ compare function. // Test that comparison sampler binding works with sampler w/ compare function.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ComparisonSampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
wgpu::SamplerDescriptor desc = {}; wgpu::SamplerDescriptor desc = {};
desc.compare = wgpu::CompareFunction::Never; desc.compare = wgpu::CompareFunction::Never;
@ -2120,7 +2124,7 @@ TEST_F(ComparisonSamplerBindingTest, SamplerAndBindGroupMatches) {
// Test that sampler binding does not work with sampler w/ compare function. // Test that sampler binding does not work with sampler w/ compare function.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
wgpu::SamplerDescriptor desc; wgpu::SamplerDescriptor desc;
desc.compare = wgpu::CompareFunction::Never; desc.compare = wgpu::CompareFunction::Never;
@ -2131,7 +2135,7 @@ TEST_F(ComparisonSamplerBindingTest, SamplerAndBindGroupMatches) {
// Test that comparison sampler binding does not work with normal sampler. // Test that comparison sampler binding does not work with normal sampler.
{ {
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ComparisonSampler}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
wgpu::SamplerDescriptor desc = {}; wgpu::SamplerDescriptor desc = {};
ASSERT_DEVICE_ERROR( ASSERT_DEVICE_ERROR(

View File

@ -242,16 +242,15 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
TEST_F(GetBindGroupLayoutTests, ViewDimension) { TEST_F(GetBindGroupLayoutTests, ViewDimension) {
wgpu::BindGroupLayoutEntry binding = {}; wgpu::BindGroupLayoutEntry binding = {};
binding.binding = 0; binding.binding = 0;
binding.type = wgpu::BindingType::SampledTexture;
binding.visibility = wgpu::ShaderStage::Fragment; binding.visibility = wgpu::ShaderStage::Fragment;
binding.hasDynamicOffset = false; binding.texture.sampleType = wgpu::TextureSampleType::Float;
wgpu::BindGroupLayoutDescriptor desc = {}; wgpu::BindGroupLayoutDescriptor desc = {};
desc.entryCount = 1; desc.entryCount = 1;
desc.entries = &binding; desc.entries = &binding;
{ {
binding.viewDimension = wgpu::TextureViewDimension::e1D; binding.texture.viewDimension = wgpu::TextureViewDimension::e1D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_1d<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_1d<f32>;
@ -261,7 +260,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
} }
{ {
binding.viewDimension = wgpu::TextureViewDimension::e2D; binding.texture.viewDimension = wgpu::TextureViewDimension::e2D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
@ -271,7 +270,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
} }
{ {
binding.viewDimension = wgpu::TextureViewDimension::e2DArray; binding.texture.viewDimension = wgpu::TextureViewDimension::e2DArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d_array<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d_array<f32>;
@ -281,7 +280,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
} }
{ {
binding.viewDimension = wgpu::TextureViewDimension::e3D; binding.texture.viewDimension = wgpu::TextureViewDimension::e3D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_3d<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_3d<f32>;
@ -291,7 +290,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
} }
{ {
binding.viewDimension = wgpu::TextureViewDimension::Cube; binding.texture.viewDimension = wgpu::TextureViewDimension::Cube;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_cube<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_cube<f32>;
@ -301,7 +300,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
} }
{ {
binding.viewDimension = wgpu::TextureViewDimension::CubeArray; binding.texture.viewDimension = wgpu::TextureViewDimension::CubeArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_cube_array<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_cube_array<f32>;
@ -315,16 +314,14 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
TEST_F(GetBindGroupLayoutTests, TextureComponentType) { TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
wgpu::BindGroupLayoutEntry binding = {}; wgpu::BindGroupLayoutEntry binding = {};
binding.binding = 0; binding.binding = 0;
binding.type = wgpu::BindingType::SampledTexture;
binding.visibility = wgpu::ShaderStage::Fragment; binding.visibility = wgpu::ShaderStage::Fragment;
binding.hasDynamicOffset = false;
wgpu::BindGroupLayoutDescriptor desc = {}; wgpu::BindGroupLayoutDescriptor desc = {};
desc.entryCount = 1; desc.entryCount = 1;
desc.entries = &binding; desc.entries = &binding;
{ {
binding.textureComponentType = wgpu::TextureComponentType::Float; binding.texture.sampleType = wgpu::TextureSampleType::Float;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
@ -334,7 +331,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
} }
{ {
binding.textureComponentType = wgpu::TextureComponentType::Sint; binding.texture.sampleType = wgpu::TextureSampleType::Sint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<i32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<i32>;
@ -344,7 +341,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
} }
{ {
binding.textureComponentType = wgpu::TextureComponentType::Uint; binding.texture.sampleType = wgpu::TextureSampleType::Uint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"( wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<u32>; [[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<u32>;
@ -715,7 +712,7 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
TEST_F(GetBindGroupLayoutTests, Reflection) { TEST_F(GetBindGroupLayoutTests, Reflection) {
wgpu::BindGroupLayoutEntry binding = {}; wgpu::BindGroupLayoutEntry binding = {};
binding.binding = 0; binding.binding = 0;
binding.type = wgpu::BindingType::UniformBuffer; binding.buffer.type = wgpu::BufferBindingType::Uniform;
binding.visibility = wgpu::ShaderStage::Vertex; binding.visibility = wgpu::ShaderStage::Vertex;
wgpu::BindGroupLayoutDescriptor bglDesc = {}; wgpu::BindGroupLayoutDescriptor bglDesc = {};

View File

@ -26,7 +26,7 @@ namespace {
uint32_t binding; uint32_t binding;
std::string text; std::string text;
uint64_t size; uint64_t size;
wgpu::BindingType type = wgpu::BindingType::StorageBuffer; wgpu::BufferBindingType type = wgpu::BufferBindingType::Storage;
wgpu::ShaderStage visibility = wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment; wgpu::ShaderStage visibility = wgpu::ShaderStage::Compute | wgpu::ShaderStage::Fragment;
}; };
@ -67,13 +67,13 @@ namespace {
} }
// Convert binding type to a glsl string // Convert binding type to a glsl string
std::string BindingTypeToStr(wgpu::BindingType type) { std::string BufferBindingTypeToStr(wgpu::BufferBindingType type) {
switch (type) { switch (type) {
case wgpu::BindingType::UniformBuffer: case wgpu::BufferBindingType::Uniform:
return "uniform"; return "uniform";
case wgpu::BindingType::StorageBuffer: case wgpu::BufferBindingType::Storage:
return "buffer"; return "buffer";
case wgpu::BindingType::ReadonlyStorageBuffer: case wgpu::BufferBindingType::ReadOnlyStorage:
return "readonly buffer"; return "readonly buffer";
default: default:
UNREACHABLE(); UNREACHABLE();
@ -88,7 +88,7 @@ namespace {
size_t ctr = 0; size_t ctr = 0;
for (const BindingDescriptor& b : bindings) { for (const BindingDescriptor& b : bindings) {
ostream << "layout(" << layout << ", set = " << b.set << ", binding = " << b.binding ostream << "layout(" << layout << ", set = " << b.set << ", binding = " << b.binding
<< ") " << BindingTypeToStr(b.type) << " b" << ctr++ << "{\n" << ") " << BufferBindingTypeToStr(b.type) << " b" << ctr++ << "{\n"
<< b.text << ";\n};\n"; << b.text << ";\n};\n";
} }
return ostream.str(); return ostream.str();
@ -214,9 +214,9 @@ class MinBufferSizeTestsBase : public ValidationTest {
const BindingDescriptor& b = bindings[i]; const BindingDescriptor& b = bindings[i];
wgpu::BindGroupLayoutEntry e = {}; wgpu::BindGroupLayoutEntry e = {};
e.binding = b.binding; e.binding = b.binding;
e.type = b.type;
e.visibility = b.visibility; e.visibility = b.visibility;
e.minBufferBindingSize = minimumSizes[i]; e.buffer.type = b.type;
e.buffer.minBindingSize = minimumSizes[i];
entries.push_back(e); entries.push_back(e);
} }
@ -393,9 +393,8 @@ TEST_F(MinBufferSizeBindGroupCreationTests, BindingTooSmall) {
TEST_F(MinBufferSizeBindGroupCreationTests, LayoutEquality) { TEST_F(MinBufferSizeBindGroupCreationTests, LayoutEquality) {
auto MakeLayout = [&](uint64_t size) { auto MakeLayout = [&](uint64_t size) {
return utils::MakeBindGroupLayout( return utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer, false, size, device,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform, false, size}});
wgpu::TextureFormat::Undefined}});
}; };
EXPECT_EQ(MakeLayout(0).Get(), MakeLayout(0).Get()); EXPECT_EQ(MakeLayout(0).Get(), MakeLayout(0).Get());
@ -540,16 +539,16 @@ TEST_F(MinBufferSizeDefaultLayoutTests, std430Inferred) {
// Sizes are inferred for all binding types with std140 layout // Sizes are inferred for all binding types with std140 layout
TEST_F(MinBufferSizeDefaultLayoutTests, std140BindingTypes) { TEST_F(MinBufferSizeDefaultLayoutTests, std140BindingTypes) {
CheckShaderBindingSizeReflection( CheckShaderBindingSizeReflection(
"std140", {{{0, 0, "int d; float e[]", 32, wgpu::BindingType::UniformBuffer}, "std140", {{{0, 0, "int d; float e[]", 32, wgpu::BufferBindingType::Uniform},
{0, 1, "ThreeFloats f", 12, wgpu::BindingType::StorageBuffer}, {0, 1, "ThreeFloats f", 12, wgpu::BufferBindingType::Storage},
{0, 2, "ThreeFloats g[]", 16, wgpu::BindingType::ReadonlyStorageBuffer}}}); {0, 2, "ThreeFloats g[]", 16, wgpu::BufferBindingType::ReadOnlyStorage}}});
} }
// Sizes are inferred for all binding types with std430 layout // Sizes are inferred for all binding types with std430 layout
TEST_F(MinBufferSizeDefaultLayoutTests, std430BindingTypes) { TEST_F(MinBufferSizeDefaultLayoutTests, std430BindingTypes) {
CheckShaderBindingSizeReflection( CheckShaderBindingSizeReflection(
"std430", {{{0, 0, "float a", 4, wgpu::BindingType::StorageBuffer}, "std430", {{{0, 0, "float a", 4, wgpu::BufferBindingType::Storage},
{0, 1, "ThreeFloats b[]", 12, wgpu::BindingType::ReadonlyStorageBuffer}}}); {0, 1, "ThreeFloats b[]", 12, wgpu::BufferBindingType::ReadOnlyStorage}}});
} }
// Various bindings have correct size across multiple groups // Various bindings have correct size across multiple groups
@ -575,11 +574,11 @@ TEST_F(MinBufferSizeDefaultLayoutTests, std430MultipleBindGroups) {
// Minimum size should be the max requirement of both vertex and fragment stages // Minimum size should be the max requirement of both vertex and fragment stages
TEST_F(MinBufferSizeDefaultLayoutTests, RenderPassConsidersBothStages) { TEST_F(MinBufferSizeDefaultLayoutTests, RenderPassConsidersBothStages) {
std::string vertexShader = CreateVertexShaderWithBindings( std::string vertexShader = CreateVertexShaderWithBindings(
"std140", {{0, 0, "float a", 4, wgpu::BindingType::UniformBuffer}, "std140", {{0, 0, "float a", 4, wgpu::BufferBindingType::Uniform},
{0, 1, "float b[]", 16, wgpu::BindingType::UniformBuffer}}); {0, 1, "float b[]", 16, wgpu::BufferBindingType::Uniform}});
std::string fragShader = CreateFragmentShaderWithBindings( std::string fragShader = CreateFragmentShaderWithBindings(
"std140", {{0, 0, "float a; float b", 8, wgpu::BindingType::UniformBuffer}, "std140", {{0, 0, "float a; float b", 8, wgpu::BufferBindingType::Uniform},
{0, 1, "float c; float d", 8, wgpu::BindingType::UniformBuffer}}); {0, 1, "float c; float d", 8, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroupLayout renderLayout = GetBGLFromRenderShaders(vertexShader, fragShader, 0); wgpu::BindGroupLayout renderLayout = GetBGLFromRenderShaders(vertexShader, fragShader, 0);

View File

@ -54,11 +54,11 @@ namespace {
wgpu::BindGroupLayout bgls[] = { wgpu::BindGroupLayout bgls[] = {
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}), device, {{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}}),
utils::MakeBindGroupLayout( utils::MakeBindGroupLayout(
device, { device, {
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::UniformBuffer}, {0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}, {1, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage},
})}; })};
wgpu::PipelineLayoutDescriptor pipelineLayoutDesc = {}; wgpu::PipelineLayoutDescriptor pipelineLayoutDesc = {};

View File

@ -393,10 +393,10 @@ TEST_F(RenderPipelineValidationTest, AlphaToCoverageAndSampleCount) {
TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) { TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
constexpr uint32_t kNumTextureComponentType = 3u; constexpr uint32_t kNumTextureComponentType = 3u;
std::array<const char*, kNumTextureComponentType> kScalarTypes = {{"f32", "i32", "u32"}}; std::array<const char*, kNumTextureComponentType> kScalarTypes = {{"f32", "i32", "u32"}};
std::array<wgpu::TextureComponentType, kNumTextureComponentType> kTextureComponentTypes = {{ std::array<wgpu::TextureSampleType, kNumTextureComponentType> kTextureComponentTypes = {{
wgpu::TextureComponentType::Float, wgpu::TextureSampleType::Float,
wgpu::TextureComponentType::Sint, wgpu::TextureSampleType::Sint,
wgpu::TextureComponentType::Uint, wgpu::TextureSampleType::Uint,
}}; }};
for (size_t i = 0; i < kNumTextureComponentType; ++i) { for (size_t i = 0; i < kNumTextureComponentType; ++i) {
@ -415,8 +415,7 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str()); utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, device, {{0, wgpu::ShaderStage::Fragment, kTextureComponentTypes[j]}});
0, wgpu::TextureViewDimension::e2D, kTextureComponentTypes[j]}});
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
if (i == j) { if (i == j) {
@ -464,8 +463,8 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str()); utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
0, kTextureViewDimensions[j], wgpu::TextureComponentType::Float}}); kTextureViewDimensions[j]}});
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
if (i == j) { if (i == j) {
@ -753,11 +752,11 @@ TEST_F(RenderPipelineValidationTest, DISABLED_BindingsFromCorrectEntryPoint) {
)"); )");
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
wgpu::PipelineLayout layout0 = utils::MakeBasicPipelineLayout(device, &bgl0); wgpu::PipelineLayout layout0 = utils::MakeBasicPipelineLayout(device, &bgl0);
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer}}); device, {{1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform}});
wgpu::PipelineLayout layout1 = utils::MakeBasicPipelineLayout(device, &bgl1); wgpu::PipelineLayout layout1 = utils::MakeBasicPipelineLayout(device, &bgl1);
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor descriptor(device);

View File

@ -99,8 +99,8 @@ namespace {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer}, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}}); {1, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}});
// Use the buffer as both uniform and readonly storage buffer in compute pass. // Use the buffer as both uniform and readonly storage buffer in compute pass.
@ -122,7 +122,7 @@ namespace {
CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index); CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index);
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}});
// It is invalid to use the buffer as both index and storage in render pass // It is invalid to use the buffer as both index and storage in render pass
@ -142,8 +142,8 @@ namespace {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}}); {1, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroup bg = wgpu::BindGroup bg =
utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}, {1, buffer, 256, 4}}); utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}, {1, buffer, 256, 4}});
@ -183,9 +183,9 @@ namespace {
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute, device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
wgpu::BindingType::StorageBuffer}, wgpu::BufferBindingType::Storage},
{1, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute, {1, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
wgpu::BindingType::StorageBuffer}}); wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg = wgpu::BindGroup bg =
utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}, {1, buffer, 256, 4}}); utils::MakeBindGroup(device, bgl, {{0, buffer, 0, 4}, {1, buffer, 256, 4}});
@ -243,7 +243,7 @@ namespace {
// Create bind groups to use the buffer as storage // Create bind groups to use the buffer as storage
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, buffer0}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, buffer0}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, buffer1}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, buffer1}});
@ -271,9 +271,9 @@ namespace {
CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform); CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform);
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
@ -297,10 +297,10 @@ namespace {
wgpu::Buffer buffer = CreateBuffer(4, wgpu::BufferUsage::Storage); wgpu::Buffer buffer = CreateBuffer(4, wgpu::BufferUsage::Storage);
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer}}); {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
@ -330,7 +330,7 @@ namespace {
wgpu::Buffer buffer = wgpu::Buffer buffer =
CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index); CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index);
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}});
// Create a no-op render pipeline. // Create a no-op render pipeline.
@ -360,9 +360,9 @@ namespace {
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}}); {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
@ -395,7 +395,7 @@ namespace {
wgpu::Buffer buffer = wgpu::Buffer buffer =
CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index); CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index);
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, buffer}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, buffer}});
// Create a no-op render pipeline. // Create a no-op render pipeline.
@ -423,9 +423,9 @@ namespace {
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}}); {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, buffer}}); wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, buffer}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, buffer}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, buffer}});
@ -459,10 +459,10 @@ namespace {
// Create the bind group to use the buffer as storage // Create the bind group to use the buffer as storage
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, bufferSrc}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, bufferSrc}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, bufferDst}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, bufferDst}});
// Use the buffer as both copy src and storage in render pass // Use the buffer as both copy src and storage in render pass
@ -497,7 +497,7 @@ namespace {
CreateBuffer(4, wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Index); CreateBuffer(4, wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Index);
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer0}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer0}});
DummyRenderPass dummyRenderPass(device); DummyRenderPass dummyRenderPass(device);
@ -566,7 +566,7 @@ namespace {
// Create the bind group to use the buffer as storage // Create the bind group to use the buffer as storage
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, buffer0}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, buffer0}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, buffer1}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, buffer1}});
@ -606,10 +606,10 @@ namespace {
// Create the bind group to use the buffer as storage // Create the bind group to use the buffer as storage
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}}); {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroup writeBG0 = utils::MakeBindGroup(device, writeBGL, {{0, buffer0, 0, 4}}); wgpu::BindGroup writeBG0 = utils::MakeBindGroup(device, writeBGL, {{0, buffer0, 0, 4}});
wgpu::BindGroup readBG0 = utils::MakeBindGroup(device, readBGL, {{0, buffer0, 256, 4}}); wgpu::BindGroup readBG0 = utils::MakeBindGroup(device, readBGL, {{0, buffer0, 256, 4}});
wgpu::BindGroup readBG1 = utils::MakeBindGroup(device, readBGL, {{0, buffer1, 0, 4}}); wgpu::BindGroup readBG1 = utils::MakeBindGroup(device, readBGL, {{0, buffer1, 0, 4}});
@ -662,8 +662,8 @@ namespace {
{ {
// Create a bind group whose bindings are not visible in render pass // Create a bind group whose bindings are not visible in render pass
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}, device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
{1, wgpu::ShaderStage::None, wgpu::BindingType::ReadonlyStorageBuffer}}); {1, wgpu::ShaderStage::None, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}});
// These two bindings are invisible in render pass. But we still track these bindings. // These two bindings are invisible in render pass. But we still track these bindings.
@ -680,8 +680,8 @@ namespace {
{ {
// Create a bind group whose bindings are not visible in compute pass // Create a bind group whose bindings are not visible in compute pass
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer}, device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage},
{1, wgpu::ShaderStage::None, wgpu::BindingType::StorageBuffer}}); {1, wgpu::ShaderStage::None, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}});
// Create a no-op compute pipeline. // Create a no-op compute pipeline.
@ -710,7 +710,7 @@ namespace {
wgpu::Buffer buffer = wgpu::Buffer buffer =
CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index); CreateBuffer(4, wgpu::BufferUsage::Storage | wgpu::BufferUsage::Index);
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}});
// Buffer usage in compute stage in bind group conflicts with index buffer. And binding // Buffer usage in compute stage in bind group conflicts with index buffer. And binding
@ -730,8 +730,8 @@ namespace {
{ {
wgpu::Buffer buffer = CreateBuffer(4, wgpu::BufferUsage::Storage); wgpu::Buffer buffer = CreateBuffer(4, wgpu::BufferUsage::Storage);
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer}, device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); {1, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, buffer}, {1, buffer}});
// Create a no-op compute pipeline. // Create a no-op compute pipeline.
@ -764,9 +764,9 @@ namespace {
// Create bind groups. The bindings are visible for render pass. // Create bind groups. The bindings are visible for render pass.
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageBuffer}}); {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
@ -808,9 +808,9 @@ namespace {
// Create bind groups. The bindings are visible for compute pass. // Create bind groups. The bindings are visible for compute pass.
wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl0 = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageBuffer}}); {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::ReadOnlyStorage}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl0, {{0, buffer}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
@ -853,12 +853,10 @@ namespace {
// Create a bind group to use the texture as sampled and readonly storage bindings // Create a bind group to use the texture as sampled and readonly storage bindings
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
{{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float},
wgpu::BindingType::SampledTexture}, {1, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
{1, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::BindingType::ReadonlyStorageTexture, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
// Test render pass // Test render pass
@ -895,7 +893,7 @@ namespace {
// Create a bind group to use the texture as sampled binding // Create a bind group to use the texture as sampled binding
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::TextureSampleType::Float}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}});
// Create a render pass to use the texture as a render target // Create a render pass to use the texture as a render target
@ -918,10 +916,9 @@ namespace {
// Create a bind group to use the texture as sampled and writeonly bindings // Create a bind group to use the texture as sampled and writeonly bindings
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture}, device,
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, {{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float},
false, 0, wgpu::TextureViewDimension::Undefined, {1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
// Create a no-op compute pipeline // Create a no-op compute pipeline
@ -965,9 +962,7 @@ namespace {
// Create a bind group to use the texture as writeonly storage binding // Create a bind group to use the texture as writeonly storage binding
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, false, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
0, wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float,
kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}});
// It is invalid to use the texture as both writeonly storage and render target in // It is invalid to use the texture as both writeonly storage and render target in
@ -1005,12 +1000,9 @@ namespace {
// Create a bind group to use the texture as sampled and writeonly bindings // Create a bind group to use the texture as sampled and writeonly bindings
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat},
wgpu::TextureComponentType::Float, kFormat}, {1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture,
false, 0, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
// Create a no-op compute pipeline // Create a no-op compute pipeline
@ -1057,7 +1049,7 @@ namespace {
// Create bind groups to use the texture as sampled // Create bind groups to use the texture as sampled
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::TextureSampleType::Float}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, v0}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, v0}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, v1}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, v1}});
@ -1087,13 +1079,11 @@ namespace {
// Create bind groups to use the texture as readonly and writeonly bindings // Create bind groups to use the texture as readonly and writeonly bindings
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}}); wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});
@ -1119,13 +1109,11 @@ namespace {
// Create bind groups to use the texture as readonly and writeonly bindings // Create bind groups to use the texture as readonly and writeonly bindings
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});
wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}}); wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}});
@ -1159,12 +1147,10 @@ namespace {
{ {
// Create bind groups to use the texture as sampled and writeonly storage bindings // Create bind groups to use the texture as sampled and writeonly storage bindings
wgpu::BindGroupLayout sampledBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout sampledBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, false, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
0, wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float,
kFormat}});
wgpu::BindGroup sampledBG = utils::MakeBindGroup(device, sampledBGL, {{0, view}}); wgpu::BindGroup sampledBG = utils::MakeBindGroup(device, sampledBGL, {{0, view}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});
@ -1192,13 +1178,11 @@ namespace {
{ {
// Create bind groups to use the texture as readonly and writeonly storage bindings // Create bind groups to use the texture as readonly and writeonly storage bindings
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}}); wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});
@ -1234,12 +1218,10 @@ namespace {
{ {
// Create the bind group to use the texture as sampled and writeonly storage bindings // Create the bind group to use the texture as sampled and writeonly storage bindings
wgpu::BindGroupLayout sampledBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout sampledBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, device,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, false, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
0, wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float,
kFormat}});
wgpu::BindGroup sampledBG = utils::MakeBindGroup(device, sampledBGL, {{0, view}}); wgpu::BindGroup sampledBG = utils::MakeBindGroup(device, sampledBGL, {{0, view}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});
@ -1265,13 +1247,11 @@ namespace {
{ {
// Create the bind group to use the texture as readonly and writeonly storage bindings // Create the bind group to use the texture as readonly and writeonly storage bindings
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}}); wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});
@ -1324,7 +1304,7 @@ namespace {
{ {
// Create the bind group to use the texture as sampled // Create the bind group to use the texture as sampled
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view1}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view1}});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -1351,7 +1331,7 @@ namespace {
// Create the bind group to use the texture as sampled // Create the bind group to use the texture as sampled
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::TextureSampleType::Float}});
wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, view0}}); wgpu::BindGroup bg0 = utils::MakeBindGroup(device, bgl, {{0, view0}});
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, view1}}); wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl, {{0, view1}});
@ -1392,14 +1372,12 @@ namespace {
// Create the bind group to use the texture as readonly and writeonly bindings // Create the bind group to use the texture as readonly and writeonly bindings
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup writeBG0 = utils::MakeBindGroup(device, writeBGL, {{0, view0}}); wgpu::BindGroup writeBG0 = utils::MakeBindGroup(device, writeBGL, {{0, view0}});
wgpu::BindGroup readBG0 = utils::MakeBindGroup(device, readBGL, {{0, view0}}); wgpu::BindGroup readBG0 = utils::MakeBindGroup(device, readBGL, {{0, view0}});
@ -1455,12 +1433,9 @@ namespace {
{ {
// Create a bind group whose bindings are not visible in render pass // Create a bind group whose bindings are not visible in render pass
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat},
wgpu::TextureComponentType::Float, kFormat}, {1, wgpu::ShaderStage::None, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
{1, wgpu::ShaderStage::None, wgpu::BindingType::WriteonlyStorageTexture,
false, 0, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
// These two bindings are invisible in render pass. But we still track these bindings. // These two bindings are invisible in render pass. But we still track these bindings.
@ -1477,12 +1452,9 @@ namespace {
{ {
// Create a bind group whose bindings are not visible in compute pass // Create a bind group whose bindings are not visible in compute pass
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat},
wgpu::TextureComponentType::Float, kFormat}, {1, wgpu::ShaderStage::None, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
{1, wgpu::ShaderStage::None, wgpu::BindingType::WriteonlyStorageTexture,
false, 0, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
// Create a no-op compute pipeline. // Create a no-op compute pipeline.
@ -1516,9 +1488,8 @@ namespace {
// Create a bind group which use the texture as readonly storage in compute stage // Create a bind group which use the texture as readonly storage in compute stage
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}});
// Texture usage in compute stage in bind group conflicts with render target. And // Texture usage in compute stage in bind group conflicts with render target. And
@ -1535,12 +1506,9 @@ namespace {
{ {
// Create a bind group which contains both fragment and compute stages // Create a bind group which contains both fragment and compute stages
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, device,
false, 0, wgpu::TextureViewDimension::Undefined, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat},
wgpu::TextureComponentType::Float, kFormat}, {1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture,
false, 0, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}}); wgpu::BindGroup bg = utils::MakeBindGroup(device, bgl, {{0, view}, {1, view}});
// Create a no-op compute pipeline. // Create a no-op compute pipeline.
@ -1570,15 +1538,11 @@ namespace {
// Create bind groups. // Create bind groups.
wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout readBGL = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
{{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat}});
wgpu::BindingType::ReadonlyStorageTexture, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout( wgpu::BindGroupLayout writeBGL = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute,
{{0, wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::BindingType::WriteonlyStorageTexture, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}}); wgpu::BindGroup readBG = utils::MakeBindGroup(device, readBGL, {{0, view}});
wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}}); wgpu::BindGroup writeBG = utils::MakeBindGroup(device, writeBGL, {{0, view}});

View File

@ -57,7 +57,7 @@ class StorageTextureValidationTests : public ValidationTest {
} }
static std::string CreateComputeShaderWithStorageTexture( static std::string CreateComputeShaderWithStorageTexture(
wgpu::BindingType storageTextureBindingType, wgpu::StorageTextureAccess storageTextureBindingType,
wgpu::TextureFormat textureFormat, wgpu::TextureFormat textureFormat,
wgpu::TextureViewDimension textureViewDimension = wgpu::TextureViewDimension::e2D) { wgpu::TextureViewDimension textureViewDimension = wgpu::TextureViewDimension::e2D) {
const char* glslImageFormatQualifier = utils::GetGLSLImageFormatQualifier(textureFormat); const char* glslImageFormatQualifier = utils::GetGLSLImageFormatQualifier(textureFormat);
@ -69,16 +69,16 @@ class StorageTextureValidationTests : public ValidationTest {
} }
static std::string CreateComputeShaderWithStorageTexture( static std::string CreateComputeShaderWithStorageTexture(
wgpu::BindingType storageTextureBindingType, wgpu::StorageTextureAccess storageTextureBindingType,
const char* glslImageFormatQualifier, const char* glslImageFormatQualifier,
const char* textureComponentTypePrefix, const char* textureComponentTypePrefix,
const char* glslImageTypeDeclaration = "image2D") { const char* glslImageTypeDeclaration = "image2D") {
const char* memoryQualifier = ""; const char* memoryQualifier = "";
switch (storageTextureBindingType) { switch (storageTextureBindingType) {
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::StorageTextureAccess::ReadOnly:
memoryQualifier = "readonly"; memoryQualifier = "readonly";
break; break;
case wgpu::BindingType::WriteonlyStorageTexture: case wgpu::StorageTextureAccess::WriteOnly:
memoryQualifier = "writeonly"; memoryQualifier = "writeonly";
break; break;
default: default:
@ -115,8 +115,8 @@ class StorageTextureValidationTests : public ValidationTest {
wgpu::ShaderModule mDefaultVSModule; wgpu::ShaderModule mDefaultVSModule;
wgpu::ShaderModule mDefaultFSModule; wgpu::ShaderModule mDefaultFSModule;
const std::array<wgpu::BindingType, 2> kSupportedStorageTextureBindingTypes = { const std::array<wgpu::StorageTextureAccess, 2> kSupportedStorageTextureAccess = {
wgpu::BindingType::ReadonlyStorageTexture, wgpu::BindingType::WriteonlyStorageTexture}; wgpu::StorageTextureAccess::ReadOnly, wgpu::StorageTextureAccess::WriteOnly};
}; };
// Validate read-only storage textures can be declared in vertex and fragment shaders, while // Validate read-only storage textures can be declared in vertex and fragment shaders, while
@ -279,21 +279,20 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
TEST_F(StorageTextureValidationTests, BindGroupLayoutWithStorageTextureBindingType) { TEST_F(StorageTextureValidationTests, BindGroupLayoutWithStorageTextureBindingType) {
struct TestSpec { struct TestSpec {
wgpu::ShaderStage stage; wgpu::ShaderStage stage;
wgpu::BindingType type; wgpu::StorageTextureAccess type;
bool valid; bool valid;
}; };
constexpr std::array<TestSpec, 6> kTestSpecs = { constexpr std::array<TestSpec, 6> kTestSpecs = {
{{wgpu::ShaderStage::Vertex, wgpu::BindingType::ReadonlyStorageTexture, true}, {{wgpu::ShaderStage::Vertex, wgpu::StorageTextureAccess::ReadOnly, true},
{wgpu::ShaderStage::Vertex, wgpu::BindingType::WriteonlyStorageTexture, false}, {wgpu::ShaderStage::Vertex, wgpu::StorageTextureAccess::WriteOnly, false},
{wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, true}, {wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, true},
{wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, true}, {wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly, true},
{wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, true}, {wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, true},
{wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, true}}}; {wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, true}}};
for (const auto& testSpec : kTestSpecs) { for (const auto& testSpec : kTestSpecs) {
wgpu::BindGroupLayoutEntry entry = wgpu::BindGroupLayoutEntry entry = utils::BindingLayoutEntryInitializationHelper(
utils::BindingLayoutEntryInitializationHelper(0, testSpec.stage, testSpec.type); 0, testSpec.stage, testSpec.type, wgpu::TextureFormat::R32Uint);
entry.storageTextureFormat = wgpu::TextureFormat::R32Uint;
wgpu::BindGroupLayoutDescriptor descriptor; wgpu::BindGroupLayoutDescriptor descriptor;
descriptor.entryCount = 1; descriptor.entryCount = 1;
@ -330,7 +329,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInShaders) {
wgpu::TextureFormat::RG16Sint, wgpu::TextureFormat::RG16Float, wgpu::TextureFormat::RG16Sint, wgpu::TextureFormat::RG16Float,
wgpu::TextureFormat::RGB10A2Unorm, wgpu::TextureFormat::RG11B10Ufloat}; wgpu::TextureFormat::RGB10A2Unorm, wgpu::TextureFormat::RG11B10Ufloat};
for (wgpu::BindingType storageTextureBindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageTextureBindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureFormat format : kWGPUTextureFormatSupportedAsSPIRVImageFormats) { for (wgpu::TextureFormat format : kWGPUTextureFormatSupportedAsSPIRVImageFormats) {
std::string computeShader = std::string computeShader =
CreateComputeShaderWithStorageTexture(storageTextureBindingType, format); CreateComputeShaderWithStorageTexture(storageTextureBindingType, format);
@ -361,7 +360,7 @@ TEST_F(StorageTextureValidationTests, UnsupportedSPIRVStorageTextureFormat) {
{"r16_snorm", ""}, {"r16_snorm", ""},
{"rgb10_a2ui", "u"}}}; {"rgb10_a2ui", "u"}}};
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (const TextureFormatInfo& formatInfo : kUnsupportedTextureFormats) { for (const TextureFormatInfo& formatInfo : kUnsupportedTextureFormats) {
std::string computeShader = CreateComputeShaderWithStorageTexture( std::string computeShader = CreateComputeShaderWithStorageTexture(
bindingType, formatInfo.name, formatInfo.componentTypePrefix); bindingType, formatInfo.name, formatInfo.componentTypePrefix);
@ -379,7 +378,7 @@ TEST_F(StorageTextureValidationTests, UnsupportedTextureViewDimensionInShader) {
wgpu::TextureViewDimension::Cube, wgpu::TextureViewDimension::CubeArray}; wgpu::TextureViewDimension::Cube, wgpu::TextureViewDimension::CubeArray};
constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::R32Float; constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::R32Float;
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureViewDimension dimension : kUnsupportedTextureViewDimensions) { for (wgpu::TextureViewDimension dimension : kUnsupportedTextureViewDimensions) {
std::string computeShader = std::string computeShader =
CreateComputeShaderWithStorageTexture(bindingType, kFormat, dimension); CreateComputeShaderWithStorageTexture(bindingType, kFormat, dimension);
@ -403,11 +402,10 @@ TEST_F(StorageTextureValidationTests, UnsupportedTextureViewDimensionInBindGroup
wgpu::TextureViewDimension::Cube, wgpu::TextureViewDimension::CubeArray}; wgpu::TextureViewDimension::Cube, wgpu::TextureViewDimension::CubeArray};
constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::R32Float; constexpr wgpu::TextureFormat kFormat = wgpu::TextureFormat::R32Float;
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureViewDimension dimension : kUnsupportedTextureViewDimensions) { for (wgpu::TextureViewDimension dimension : kUnsupportedTextureViewDimensions) {
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout( ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Compute, bindingType, false, 0, dimension, device, {{0, wgpu::ShaderStage::Compute, bindingType, kFormat, dimension}}));
wgpu::TextureComponentType::Float, kFormat}}));
} }
} }
} }
@ -423,7 +421,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutEntryTypeMatchesShaderDecla
wgpu::BindingType::WriteonlyStorageTexture}; wgpu::BindingType::WriteonlyStorageTexture};
constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float; constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float;
for (wgpu::BindingType bindingTypeInShader : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingTypeInShader : kSupportedStorageTextureAccess) {
// Create the compute shader with the given binding type. // Create the compute shader with the given binding type.
std::string computeShader = std::string computeShader =
CreateComputeShaderWithStorageTexture(bindingTypeInShader, kStorageTextureFormat); CreateComputeShaderWithStorageTexture(bindingTypeInShader, kStorageTextureFormat);
@ -455,7 +453,10 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutEntryTypeMatchesShaderDecla
// The binding type in the bind group layout must the same as the related image object // The binding type in the bind group layout must the same as the related image object
// declared in shader. // declared in shader.
if (bindingTypeInBindgroupLayout == bindingTypeInShader) { if ((bindingTypeInBindgroupLayout == wgpu::BindingType::ReadonlyStorageTexture &&
bindingTypeInShader == wgpu::StorageTextureAccess::ReadOnly) ||
(bindingTypeInBindgroupLayout == wgpu::BindingType::WriteonlyStorageTexture &&
bindingTypeInShader == wgpu::StorageTextureAccess::WriteOnly)) {
device.CreateComputePipeline(&computePipelineDescriptor); device.CreateComputePipeline(&computePipelineDescriptor);
} else { } else {
ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&computePipelineDescriptor)); ASSERT_DEVICE_ERROR(device.CreateComputePipeline(&computePipelineDescriptor));
@ -470,10 +471,10 @@ TEST_F(StorageTextureValidationTests, UndefinedStorageTextureFormatInBindGroupLa
wgpu::BindGroupLayoutEntry errorBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry errorBindGroupLayoutEntry;
errorBindGroupLayoutEntry.binding = 0; errorBindGroupLayoutEntry.binding = 0;
errorBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; errorBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute;
errorBindGroupLayoutEntry.storageTextureFormat = wgpu::TextureFormat::Undefined; errorBindGroupLayoutEntry.storageTexture.format = wgpu::TextureFormat::Undefined;
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
errorBindGroupLayoutEntry.type = bindingType; errorBindGroupLayoutEntry.storageTexture.access = bindingType;
ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(device, {errorBindGroupLayoutEntry})); ASSERT_DEVICE_ERROR(utils::MakeBindGroupLayout(device, {errorBindGroupLayoutEntry}));
} }
} }
@ -485,11 +486,11 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroupLayout) {
defaultBindGroupLayoutEntry.binding = 0; defaultBindGroupLayoutEntry.binding = 0;
defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute;
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureFormat textureFormat : utils::kAllTextureFormats) { for (wgpu::TextureFormat textureFormat : utils::kAllTextureFormats) {
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.type = bindingType; bindGroupLayoutBinding.storageTexture.access = bindingType;
bindGroupLayoutBinding.storageTextureFormat = textureFormat; bindGroupLayoutBinding.storageTexture.format = textureFormat;
if (utils::TextureFormatSupportsStorageTexture(textureFormat)) { if (utils::TextureFormatSupportsStorageTexture(textureFormat)) {
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
} else { } else {
@ -501,7 +502,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroupLayout) {
// Verify the storage texture format in the bind group layout must match the declaration in shader. // Verify the storage texture format in the bind group layout must match the declaration in shader.
TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatchesShaderDeclaration) { TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatchesShaderDeclaration) {
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureFormat storageTextureFormatInShader : utils::kAllTextureFormats) { for (wgpu::TextureFormat storageTextureFormatInShader : utils::kAllTextureFormats) {
if (!utils::TextureFormatSupportsStorageTexture(storageTextureFormatInShader)) { if (!utils::TextureFormatSupportsStorageTexture(storageTextureFormatInShader)) {
continue; continue;
@ -521,7 +522,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatches
// Set common fileds of bind group layout binding. // Set common fileds of bind group layout binding.
utils::BindingLayoutEntryInitializationHelper defaultBindGroupLayoutEntry = { utils::BindingLayoutEntryInitializationHelper defaultBindGroupLayoutEntry = {
0, wgpu::ShaderStage::Compute, bindingType}; 0, wgpu::ShaderStage::Compute, bindingType, utils::kAllTextureFormats[0]};
for (wgpu::TextureFormat storageTextureFormatInBindGroupLayout : for (wgpu::TextureFormat storageTextureFormatInBindGroupLayout :
utils::kAllTextureFormats) { utils::kAllTextureFormats) {
@ -532,7 +533,8 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatches
// Create the bind group layout with the given storage texture format. // Create the bind group layout with the given storage texture format.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.storageTextureFormat = storageTextureFormatInBindGroupLayout; bindGroupLayoutBinding.storageTexture.format =
storageTextureFormatInBindGroupLayout;
wgpu::BindGroupLayout bindGroupLayout = wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
@ -562,7 +564,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutViewDimensionMatchesShaderD
wgpu::TextureViewDimension::e2DArray, wgpu::TextureViewDimension::e3D}; wgpu::TextureViewDimension::e2DArray, wgpu::TextureViewDimension::e3D};
constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float; constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float;
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureViewDimension dimensionInShader : kSupportedDimensions) { for (wgpu::TextureViewDimension dimensionInShader : kSupportedDimensions) {
// Create the compute shader with the given texture view dimension. // Create the compute shader with the given texture view dimension.
std::string computeShader = CreateComputeShaderWithStorageTexture( std::string computeShader = CreateComputeShaderWithStorageTexture(
@ -575,15 +577,14 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutViewDimensionMatchesShaderD
defaultComputePipelineDescriptor.computeStage.module = csModule; defaultComputePipelineDescriptor.computeStage.module = csModule;
defaultComputePipelineDescriptor.computeStage.entryPoint = "main"; defaultComputePipelineDescriptor.computeStage.entryPoint = "main";
// Set common fileds of bind group layout binding. // Set common fields of bind group layout binding.
utils::BindingLayoutEntryInitializationHelper defaultBindGroupLayoutEntry = { utils::BindingLayoutEntryInitializationHelper defaultBindGroupLayoutEntry = {
0, wgpu::ShaderStage::Compute, bindingType}; 0, wgpu::ShaderStage::Compute, bindingType, kStorageTextureFormat};
defaultBindGroupLayoutEntry.storageTextureFormat = kStorageTextureFormat;
for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kSupportedDimensions) { for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kSupportedDimensions) {
// Create the bind group layout with the given texture view dimension. // Create the bind group layout with the given texture view dimension.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.viewDimension = dimensionInBindGroupLayout; bindGroupLayoutBinding.storageTexture.viewDimension = dimensionInBindGroupLayout;
wgpu::BindGroupLayout bindGroupLayout = wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
@ -607,7 +608,10 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutViewDimensionMatchesShaderD
// Verify that in a bind group layout binding neither read-only nor write-only storage textures // Verify that in a bind group layout binding neither read-only nor write-only storage textures
// are allowed to have dynamic offsets. // are allowed to have dynamic offsets.
// TODO(dawn:527): No longer be applicable after changes to BindGroupLayoutEntry are complete.
TEST_F(StorageTextureValidationTests, StorageTextureCannotHaveDynamicOffsets) { TEST_F(StorageTextureValidationTests, StorageTextureCannotHaveDynamicOffsets) {
const std::array<wgpu::BindingType, 2> kSupportedStorageTextureBindingTypes = {
wgpu::BindingType::ReadonlyStorageTexture, wgpu::BindingType::WriteonlyStorageTexture};
for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) {
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding;
bindGroupLayoutBinding.binding = 0; bindGroupLayoutBinding.binding = 0;
@ -624,13 +628,13 @@ TEST_F(StorageTextureValidationTests, StorageTextureCannotHaveDynamicOffsets) {
// bind group. // bind group.
TEST_F(StorageTextureValidationTests, StorageTextureBindingTypeInBindGroup) { TEST_F(StorageTextureValidationTests, StorageTextureBindingTypeInBindGroup) {
constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float; constexpr wgpu::TextureFormat kStorageTextureFormat = wgpu::TextureFormat::R32Float;
for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageBindingType : kSupportedStorageTextureAccess) {
// Create a bind group layout. // Create a bind group layout.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding;
bindGroupLayoutBinding.binding = 0; bindGroupLayoutBinding.binding = 0;
bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute;
bindGroupLayoutBinding.type = storageBindingType; bindGroupLayoutBinding.storageTexture.access = storageBindingType;
bindGroupLayoutBinding.storageTextureFormat = kStorageTextureFormat; bindGroupLayoutBinding.storageTexture.format = kStorageTextureFormat;
wgpu::BindGroupLayout bindGroupLayout = wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
@ -668,13 +672,13 @@ TEST_F(StorageTextureValidationTests, StorageTextureUsageInBindGroup) {
wgpu::TextureUsage::Sampled, wgpu::TextureUsage::Storage, wgpu::TextureUsage::Sampled, wgpu::TextureUsage::Storage,
wgpu::TextureUsage::RenderAttachment, wgpu::TextureUsage::Present}; wgpu::TextureUsage::RenderAttachment, wgpu::TextureUsage::Present};
for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageBindingType : kSupportedStorageTextureAccess) {
// Create a bind group layout. // Create a bind group layout.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding;
bindGroupLayoutBinding.binding = 0; bindGroupLayoutBinding.binding = 0;
bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute; bindGroupLayoutBinding.visibility = wgpu::ShaderStage::Compute;
bindGroupLayoutBinding.type = storageBindingType; bindGroupLayoutBinding.storageTexture.access = storageBindingType;
bindGroupLayoutBinding.storageTextureFormat = wgpu::TextureFormat::R32Float; bindGroupLayoutBinding.storageTexture.format = wgpu::TextureFormat::R32Float;
wgpu::BindGroupLayout bindGroupLayout = wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
@ -698,11 +702,11 @@ TEST_F(StorageTextureValidationTests, StorageTextureUsageInBindGroup) {
// Verify that the format of a texture used as read-only or write-only storage texture in a bind // Verify that the format of a texture used as read-only or write-only storage texture in a bind
// group must match the corresponding bind group binding. // group must match the corresponding bind group binding.
TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroup) { TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroup) {
for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageBindingType : kSupportedStorageTextureAccess) {
wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry;
defaultBindGroupLayoutEntry.binding = 0; defaultBindGroupLayoutEntry.binding = 0;
defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute;
defaultBindGroupLayoutEntry.type = storageBindingType; defaultBindGroupLayoutEntry.storageTexture.access = storageBindingType;
for (wgpu::TextureFormat formatInBindGroupLayout : utils::kAllTextureFormats) { for (wgpu::TextureFormat formatInBindGroupLayout : utils::kAllTextureFormats) {
if (!utils::TextureFormatSupportsStorageTexture(formatInBindGroupLayout)) { if (!utils::TextureFormatSupportsStorageTexture(formatInBindGroupLayout)) {
@ -711,7 +715,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInBindGroup) {
// Create a bind group layout with given storage texture format. // Create a bind group layout with given storage texture format.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.storageTextureFormat = formatInBindGroupLayout; bindGroupLayoutBinding.storageTexture.format = formatInBindGroupLayout;
wgpu::BindGroupLayout bindGroupLayout = wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
@ -759,17 +763,17 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) {
kDefaultTextureViewDescriptor.baseArrayLayer = 0; kDefaultTextureViewDescriptor.baseArrayLayer = 0;
kDefaultTextureViewDescriptor.arrayLayerCount = 1u; kDefaultTextureViewDescriptor.arrayLayerCount = 1u;
for (wgpu::BindingType storageBindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageBindingType : kSupportedStorageTextureAccess) {
wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry defaultBindGroupLayoutEntry;
defaultBindGroupLayoutEntry.binding = 0; defaultBindGroupLayoutEntry.binding = 0;
defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute; defaultBindGroupLayoutEntry.visibility = wgpu::ShaderStage::Compute;
defaultBindGroupLayoutEntry.type = storageBindingType; defaultBindGroupLayoutEntry.storageTexture.access = storageBindingType;
defaultBindGroupLayoutEntry.storageTextureFormat = kStorageTextureFormat; defaultBindGroupLayoutEntry.storageTexture.format = kStorageTextureFormat;
for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kSupportedDimensions) { for (wgpu::TextureViewDimension dimensionInBindGroupLayout : kSupportedDimensions) {
// Create a bind group layout with given texture view dimension. // Create a bind group layout with given texture view dimension.
wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry; wgpu::BindGroupLayoutEntry bindGroupLayoutBinding = defaultBindGroupLayoutEntry;
bindGroupLayoutBinding.viewDimension = dimensionInBindGroupLayout; bindGroupLayoutBinding.storageTexture.viewDimension = dimensionInBindGroupLayout;
wgpu::BindGroupLayout bindGroupLayout = wgpu::BindGroupLayout bindGroupLayout =
utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding}); utils::MakeBindGroupLayout(device, {bindGroupLayoutBinding});
@ -794,7 +798,7 @@ TEST_F(StorageTextureValidationTests, StorageTextureViewDimensionInBindGroup) {
// Verify multisampled storage textures cannot be supported now. // Verify multisampled storage textures cannot be supported now.
TEST_F(StorageTextureValidationTests, MultisampledStorageTexture) { TEST_F(StorageTextureValidationTests, MultisampledStorageTexture) {
for (wgpu::BindingType bindingType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
std::string computeShader = std::string computeShader =
CreateComputeShaderWithStorageTexture(bindingType, "rgba8", "", "image2DMS"); CreateComputeShaderWithStorageTexture(bindingType, "rgba8", "", "image2DMS");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, utils::SingleShaderStage::Compute,
@ -811,12 +815,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureInRenderPass) {
wgpu::Texture outputAttachment = CreateTexture(wgpu::TextureUsage::RenderAttachment, kFormat); wgpu::Texture outputAttachment = CreateTexture(wgpu::TextureUsage::RenderAttachment, kFormat);
utils::ComboRenderPassDescriptor renderPassDescriptor({outputAttachment.CreateView()}); utils::ComboRenderPassDescriptor renderPassDescriptor({outputAttachment.CreateView()});
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
// Create a bind group that contains a storage texture. // Create a bind group that contains a storage texture.
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat}});
{{0, wgpu::ShaderStage::Fragment, storageTextureType, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroupWithStorageTexture = wgpu::BindGroup bindGroupWithStorageTexture =
utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}}); utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}});
@ -843,15 +845,12 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneRender
utils::ComboRenderPassDescriptor renderPassDescriptor({outputAttachment.CreateView()}); utils::ComboRenderPassDescriptor renderPassDescriptor({outputAttachment.CreateView()});
// Create a bind group that contains a storage texture and a sampled texture. // Create a bind group that contains a storage texture and a sampled texture.
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
// Create a bind group that binds the same texture as both storage texture and sampled // Create a bind group that binds the same texture as both storage texture and sampled
// texture. // texture.
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat},
{{0, wgpu::ShaderStage::Fragment, storageTextureType, false, 0, {1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, bindGroupLayout, device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}}); {{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
@ -864,10 +863,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneRender
renderPassEncoder.SetBindGroup(0, bindGroup); renderPassEncoder.SetBindGroup(0, bindGroup);
renderPassEncoder.EndPass(); renderPassEncoder.EndPass();
switch (storageTextureType) { switch (storageTextureType) {
case wgpu::BindingType::ReadonlyStorageTexture: case wgpu::StorageTextureAccess::ReadOnly:
encoder.Finish(); encoder.Finish();
break; break;
case wgpu::BindingType::WriteonlyStorageTexture: case wgpu::StorageTextureAccess::WriteOnly:
ASSERT_DEVICE_ERROR(encoder.Finish()); ASSERT_DEVICE_ERROR(encoder.Finish());
break; break;
default: default:
@ -885,12 +884,10 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndRenderAttachmentInOneRend
CreateTexture(wgpu::TextureUsage::Storage | wgpu::TextureUsage::RenderAttachment, kFormat); CreateTexture(wgpu::TextureUsage::Storage | wgpu::TextureUsage::RenderAttachment, kFormat);
utils::ComboRenderPassDescriptor renderPassDescriptor({storageTexture.CreateView()}); utils::ComboRenderPassDescriptor renderPassDescriptor({storageTexture.CreateView()});
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
// Create a bind group that contains a storage texture. // Create a bind group that contains a storage texture.
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment, storageTextureType, kFormat}});
{{0, wgpu::ShaderStage::Fragment, storageTextureType, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroupWithStorageTexture = wgpu::BindGroup bindGroupWithStorageTexture =
utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}}); utils::MakeBindGroup(device, bindGroupLayout, {{0, storageTexture.CreateView()}});
@ -913,11 +910,8 @@ TEST_F(StorageTextureValidationTests, ReadOnlyAndWriteOnlyStorageTextureInOneRen
// Create a bind group that uses the same texture as both read-only and write-only storage // Create a bind group that uses the same texture as both read-only and write-only storage
// texture. // texture.
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly, kFormat},
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, false, 0, {1, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup = wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, bindGroupLayout, utils::MakeBindGroup(device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}}); {{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
@ -940,15 +934,12 @@ TEST_F(StorageTextureValidationTests, StorageTextureAndSampledTextureInOneComput
wgpu::Texture storageTexture = wgpu::Texture storageTexture =
CreateTexture(wgpu::TextureUsage::Storage | wgpu::TextureUsage::Sampled, kFormat); CreateTexture(wgpu::TextureUsage::Storage | wgpu::TextureUsage::Sampled, kFormat);
for (wgpu::BindingType storageTextureType : kSupportedStorageTextureBindingTypes) { for (wgpu::StorageTextureAccess storageTextureType : kSupportedStorageTextureAccess) {
// Create a bind group that binds the same texture as both storage texture and sampled // Create a bind group that binds the same texture as both storage texture and sampled
// texture. // texture.
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Compute, storageTextureType, kFormat},
{{0, wgpu::ShaderStage::Compute, storageTextureType, false, 0, {1, wgpu::ShaderStage::Compute, wgpu::TextureSampleType::Float}});
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::SampledTexture, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
device, bindGroupLayout, device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}}); {{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});
@ -972,11 +963,8 @@ TEST_F(StorageTextureValidationTests, ReadOnlyAndWriteOnlyStorageTextureInOneCom
// Create a bind group that uses the same texture as both read-only and write-only storage // Create a bind group that uses the same texture as both read-only and write-only storage
// texture. // texture.
wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bindGroupLayout = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::ReadOnly, kFormat},
{{0, wgpu::ShaderStage::Compute, wgpu::BindingType::ReadonlyStorageTexture, false, 0, {1, wgpu::ShaderStage::Compute, wgpu::StorageTextureAccess::WriteOnly, kFormat}});
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::WriteonlyStorageTexture, false, 0,
wgpu::TextureViewDimension::Undefined, wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup = wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, bindGroupLayout, utils::MakeBindGroup(device, bindGroupLayout,
{{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}}); {{0, storageTexture.CreateView()}, {1, storageTexture.CreateView()}});

View File

@ -53,7 +53,7 @@ namespace {
const wgpu::TextureView& samplerView) { const wgpu::TextureView& samplerView) {
// Create bind group // Create bind group
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::SampledTexture}}); device, {{0, wgpu::ShaderStage::Vertex, wgpu::TextureSampleType::Float}});
utils::ComboRenderPassDescriptor renderPassDesc({renderView}); utils::ComboRenderPassDescriptor renderPassDesc({renderView});
@ -73,10 +73,8 @@ namespace {
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, samplerView}}); wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, samplerView}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::ReadOnly,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::ReadonlyStorageTexture, kFormat}});
false, 0, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(device, bgl1, {{0, samplerView}}); wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(device, bgl1, {{0, samplerView}});
@ -104,10 +102,8 @@ namespace {
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, samplerView}}); wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, bgl, {{0, samplerView}});
wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl1 = utils::MakeBindGroupLayout(
device, device, {{0, wgpu::ShaderStage::Fragment, wgpu::StorageTextureAccess::WriteOnly,
{{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::WriteonlyStorageTexture, kFormat}});
false, 0, wgpu::TextureViewDimension::Undefined,
wgpu::TextureComponentType::Float, kFormat}});
wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(device, bgl1, {{0, samplerView}}); wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(device, bgl1, {{0, samplerView}});
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -156,29 +156,29 @@ TEST_F(UnsafeAPIValidationTest, DynamicStorageBuffer) {
// Control case: storage buffer without a dynamic offset is allowed. // Control case: storage buffer without a dynamic offset is allowed.
{ {
entry.type = wgpu::BindingType::StorageBuffer; entry.buffer.type = wgpu::BufferBindingType::Storage;
entry.hasDynamicOffset = false; entry.buffer.hasDynamicOffset = false;
device.CreateBindGroupLayout(&desc); device.CreateBindGroupLayout(&desc);
} }
// Control case: readonly storage buffer without a dynamic offset is allowed. // Control case: readonly storage buffer without a dynamic offset is allowed.
{ {
entry.type = wgpu::BindingType::ReadonlyStorageBuffer; entry.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
entry.hasDynamicOffset = false; entry.buffer.hasDynamicOffset = false;
device.CreateBindGroupLayout(&desc); device.CreateBindGroupLayout(&desc);
} }
// Storage buffer with a dynamic offset is disallowed. // Storage buffer with a dynamic offset is disallowed.
{ {
entry.type = wgpu::BindingType::StorageBuffer; entry.buffer.type = wgpu::BufferBindingType::Storage;
entry.hasDynamicOffset = true; entry.buffer.hasDynamicOffset = true;
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc)); ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc));
} }
// Readonly storage buffer with a dynamic offset is disallowed. // Readonly storage buffer with a dynamic offset is disallowed.
{ {
entry.type = wgpu::BindingType::ReadonlyStorageBuffer; entry.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
entry.hasDynamicOffset = true; entry.buffer.hasDynamicOffset = true;
ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc)); ASSERT_DEVICE_ERROR(device.CreateBindGroupLayout(&desc));
} }
} }