Port GetBindGroupLayoutValidationTests to WGSL
Bug: dawn:572 Change-Id: I132644a2dc9efecaacf7a7a23818d5eba8bc4ded Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33927 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
b92c375560
commit
218a3d71c3
|
@ -20,13 +20,11 @@
|
||||||
class GetBindGroupLayoutTests : public ValidationTest {
|
class GetBindGroupLayoutTests : public ValidationTest {
|
||||||
protected:
|
protected:
|
||||||
wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) {
|
wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[stage(vertex)]] fn main() -> void {
|
||||||
#version 450
|
})");
|
||||||
void main() {
|
|
||||||
})");
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, shader);
|
||||||
wgpu::ShaderModule fsModule =
|
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, shader);
|
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = nullptr;
|
descriptor.layout = nullptr;
|
||||||
|
@ -40,32 +38,28 @@ class GetBindGroupLayoutTests : public ValidationTest {
|
||||||
// Test that GetBindGroupLayout returns the same object for the same index
|
// Test that GetBindGroupLayout returns the same object for the same index
|
||||||
// and for matching layouts.
|
// and for matching layouts.
|
||||||
TEST_F(GetBindGroupLayoutTests, SameObject) {
|
TEST_F(GetBindGroupLayoutTests, SameObject) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer1 {
|
|
||||||
vec4 pos1;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> uniform0 : S;
|
||||||
|
[[set(1), binding(0)]] var<uniform> uniform1 : S;
|
||||||
|
|
||||||
layout(set = 1, binding = 0) uniform UniformBuffer2 {
|
[[stage(vertex)]] fn main() -> void {
|
||||||
vec4 pos2;
|
|
||||||
};
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
})");
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[block]] struct S2 {
|
||||||
#version 450
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
layout(set = 2, binding = 0) uniform UniformBuffer3 {
|
|
||||||
vec4 pos3;
|
|
||||||
};
|
};
|
||||||
|
[[set(2), binding(0)]] var<uniform> uniform2 : S2;
|
||||||
|
|
||||||
layout(set = 3, binding = 0) buffer StorageBuffer {
|
[[block]] struct S3 {
|
||||||
mat4 pos4;
|
[[offset(0)]] pos : mat4x4<f32>;
|
||||||
};
|
};
|
||||||
|
[[set(3), binding(0)]] var<storage_buffer> storage3 : S3;
|
||||||
|
|
||||||
void main() {
|
[[stage(fragment)]] fn main() -> void {
|
||||||
})");
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
|
@ -93,12 +87,12 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
|
||||||
// - dynamic offsets is false
|
// - dynamic offsets is false
|
||||||
TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
|
TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {
|
[[stage(fragment)]] fn main() -> void {
|
||||||
})");
|
})");
|
||||||
|
|
||||||
wgpu::BindGroupLayoutEntry binding = {};
|
wgpu::BindGroupLayoutEntry binding = {};
|
||||||
|
@ -130,13 +124,13 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
|
||||||
|
|
||||||
// Test GetBindGroupLayout works with a compute pipeline
|
// Test GetBindGroupLayout works with a compute pipeline
|
||||||
TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
|
TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
|
||||||
wgpu::ShaderModule csModule =
|
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer {
|
|
||||||
vec4 pos;
|
|
||||||
};
|
};
|
||||||
void main() {
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
|
[[stage(compute)]] fn main() -> void {
|
||||||
})");
|
})");
|
||||||
|
|
||||||
wgpu::ComputePipelineDescriptor descriptor;
|
wgpu::ComputePipelineDescriptor descriptor;
|
||||||
|
@ -177,35 +171,38 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
||||||
binding.visibility = wgpu::ShaderStage::Fragment;
|
binding.visibility = wgpu::ShaderStage::Fragment;
|
||||||
binding.type = wgpu::BindingType::StorageBuffer;
|
binding.type = wgpu::BindingType::StorageBuffer;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 0) buffer Storage {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos;
|
};
|
||||||
};
|
[[set(0), binding(0)]] var<storage_buffer> ssbo : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
binding.type = wgpu::BindingType::UniformBuffer;
|
binding.type = wgpu::BindingType::UniformBuffer;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 0) uniform Buffer {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos;
|
};
|
||||||
};
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.type = wgpu::BindingType::ReadonlyStorageBuffer;
|
binding.type = wgpu::BindingType::ReadonlyStorageBuffer;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 0) readonly buffer Storage {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos;
|
};
|
||||||
};
|
[[set(0), binding(0)]] var<storage_buffer> ssbo : [[access(read)]] S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,30 +210,30 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
||||||
{
|
{
|
||||||
binding.type = wgpu::BindingType::SampledTexture;
|
binding.type = wgpu::BindingType::SampledTexture;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
|
||||||
layout(set = 0, binding = 0) uniform texture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.type = wgpu::BindingType::MultisampledTexture;
|
binding.type = wgpu::BindingType::MultisampledTexture;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>;
|
||||||
layout(set = 0, binding = 0) uniform texture2DMS tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.type = wgpu::BindingType::Sampler;
|
binding.type = wgpu::BindingType::Sampler;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler;
|
||||||
layout(set = 0, binding = 0) uniform sampler samp;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,60 +253,60 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
||||||
{
|
{
|
||||||
binding.viewDimension = wgpu::TextureViewDimension::e1D;
|
binding.viewDimension = wgpu::TextureViewDimension::e1D;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_1d<f32>;
|
||||||
layout(set = 0, binding = 0) uniform texture1D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.viewDimension = wgpu::TextureViewDimension::e2D;
|
binding.viewDimension = wgpu::TextureViewDimension::e2D;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
|
||||||
layout(set = 0, binding = 0) uniform texture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.viewDimension = wgpu::TextureViewDimension::e2DArray;
|
binding.viewDimension = wgpu::TextureViewDimension::e2DArray;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d_array<f32>;
|
||||||
layout(set = 0, binding = 0) uniform texture2DArray tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.viewDimension = wgpu::TextureViewDimension::e3D;
|
binding.viewDimension = wgpu::TextureViewDimension::e3D;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_3d<f32>;
|
||||||
layout(set = 0, binding = 0) uniform texture3D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.viewDimension = wgpu::TextureViewDimension::Cube;
|
binding.viewDimension = wgpu::TextureViewDimension::Cube;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_cube<f32>;
|
||||||
layout(set = 0, binding = 0) uniform textureCube tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.viewDimension = wgpu::TextureViewDimension::CubeArray;
|
binding.viewDimension = wgpu::TextureViewDimension::CubeArray;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_cube_array<f32>;
|
||||||
layout(set = 0, binding = 0) uniform textureCubeArray tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,30 +326,30 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
|
||||||
{
|
{
|
||||||
binding.textureComponentType = wgpu::TextureComponentType::Float;
|
binding.textureComponentType = wgpu::TextureComponentType::Float;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
|
||||||
layout(set = 0, binding = 0) uniform texture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.textureComponentType = wgpu::TextureComponentType::Sint;
|
binding.textureComponentType = wgpu::TextureComponentType::Sint;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<i32>;
|
||||||
layout(set = 0, binding = 0) uniform itexture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.textureComponentType = wgpu::TextureComponentType::Uint;
|
binding.textureComponentType = wgpu::TextureComponentType::Uint;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<u32>;
|
||||||
layout(set = 0, binding = 0) uniform utexture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,63 +369,63 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
|
||||||
{
|
{
|
||||||
binding.binding = 0;
|
binding.binding = 0;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 0) uniform Buffer {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos;
|
};
|
||||||
};
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.binding = 1;
|
binding.binding = 1;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 1) uniform Buffer {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos;
|
};
|
||||||
};
|
[[set(0), binding(1)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_EQ(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
binding.binding = 2;
|
binding.binding = 2;
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 1) uniform Buffer {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos;
|
};
|
||||||
};
|
[[set(0), binding(1)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
EXPECT_NE(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
EXPECT_NE(device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test it is valid to have duplicate bindings in the shaders.
|
// Test it is valid to have duplicate bindings in the shaders.
|
||||||
TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
|
TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer1 {
|
|
||||||
vec4 pos1;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> uniform0 : S;
|
||||||
|
[[set(1), binding(0)]] var<uniform> uniform1 : S;
|
||||||
|
|
||||||
layout(set = 1, binding = 0) uniform UniformBuffer2 {
|
[[stage(vertex)]] fn main() -> void {
|
||||||
vec4 pos2;
|
})");
|
||||||
|
|
||||||
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
|
[[block]] struct S {
|
||||||
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
};
|
};
|
||||||
|
[[set(1), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
wgpu::ShaderModule fsModule =
|
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
|
||||||
#version 450
|
|
||||||
layout(set = 1, binding = 0) uniform UniformBuffer3 {
|
|
||||||
vec4 pos3;
|
|
||||||
};
|
|
||||||
|
|
||||||
void main() {})");
|
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = nullptr;
|
descriptor.layout = nullptr;
|
||||||
|
@ -440,39 +437,41 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
|
||||||
|
|
||||||
// Test that minBufferSize is set on the BGL and that the max of the min buffer sizes is used.
|
// Test that minBufferSize is set on the BGL and that the max of the min buffer sizes is used.
|
||||||
TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
|
TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
|
||||||
wgpu::ShaderModule vsModule4 =
|
wgpu::ShaderModule vsModule4 = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : f32;
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer {
|
|
||||||
float pos;
|
|
||||||
};
|
};
|
||||||
void main() {})");
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
wgpu::ShaderModule vsModule64 =
|
[[stage(vertex)]] fn main() -> void {
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
})");
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer1 {
|
wgpu::ShaderModule vsModule64 = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
mat4 pos;
|
[[block]] struct S {
|
||||||
|
[[offset(0)]] pos : mat4x4<f32>;
|
||||||
};
|
};
|
||||||
void main() {})");
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule4 =
|
[[stage(vertex)]] fn main() -> void {
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
})");
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer {
|
wgpu::ShaderModule fsModule4 = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
float pos;
|
[[block]] struct S {
|
||||||
|
[[offset(0)]] pos : f32;
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule64 =
|
wgpu::ShaderModule fsModule64 = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : mat4x4<f32>;
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer {
|
|
||||||
mat4 pos;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
// Create BGLs with minBufferBindingSize 4 and 64.
|
// Create BGLs with minBufferBindingSize 4 and 64.
|
||||||
wgpu::BindGroupLayoutEntry binding = {};
|
wgpu::BindGroupLayoutEntry binding = {};
|
||||||
|
@ -519,27 +518,23 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
|
||||||
|
|
||||||
// Test that the visibility is correctly aggregated if two stages have the exact same binding.
|
// Test that the visibility is correctly aggregated if two stages have the exact same binding.
|
||||||
TEST_F(GetBindGroupLayoutTests, StageAggregation) {
|
TEST_F(GetBindGroupLayoutTests, StageAggregation) {
|
||||||
wgpu::ShaderModule vsModuleNoSampler =
|
wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[stage(vertex)]] fn main() -> void {
|
||||||
#version 450
|
})");
|
||||||
void main() {})");
|
|
||||||
|
|
||||||
wgpu::ShaderModule vsModuleSampler =
|
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler;
|
||||||
#version 450
|
[[stage(vertex)]] fn main() -> void {
|
||||||
layout(set = 0, binding = 0) uniform sampler mySampler;
|
})");
|
||||||
void main() {})");
|
|
||||||
|
|
||||||
wgpu::ShaderModule fsModuleNoSampler =
|
wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[stage(fragment)]] fn main() -> void {
|
||||||
#version 450
|
})");
|
||||||
void main() {})");
|
|
||||||
|
|
||||||
wgpu::ShaderModule fsModuleSampler =
|
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[set(0), binding(0)]] var<uniform_constant> mySampler: sampler;
|
||||||
#version 450
|
[[stage(fragment)]] fn main() -> void {
|
||||||
layout(set = 0, binding = 0) uniform sampler mySampler;
|
})");
|
||||||
void main() {})");
|
|
||||||
|
|
||||||
// Create BGLs with minBufferBindingSize 4 and 64.
|
// Create BGLs with minBufferBindingSize 4 and 64.
|
||||||
wgpu::BindGroupLayoutEntry binding = {};
|
wgpu::BindGroupLayoutEntry binding = {};
|
||||||
|
@ -586,23 +581,23 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
|
||||||
|
|
||||||
// Test it is invalid to have conflicting binding types in the shaders.
|
// Test it is invalid to have conflicting binding types in the shaders.
|
||||||
TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
|
TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
layout(set = 0, binding = 0) uniform UniformBuffer {
|
|
||||||
vec4 pos;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> ubo : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(vertex)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
layout(set = 0, binding = 0) buffer StorageBuffer {
|
|
||||||
vec4 pos;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<storage_buffer> ssbo : S;
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = nullptr;
|
descriptor.layout = nullptr;
|
||||||
|
@ -614,19 +609,17 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
|
||||||
|
|
||||||
// Test it is invalid to have conflicting binding texture multisampling in the shaders.
|
// Test it is invalid to have conflicting binding texture multisampling in the shaders.
|
||||||
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
|
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform texture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(vertex)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>;
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform texture2DMS tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = nullptr;
|
descriptor.layout = nullptr;
|
||||||
|
@ -638,19 +631,17 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
|
||||||
|
|
||||||
// Test it is invalid to have conflicting binding texture dimension in the shaders.
|
// Test it is invalid to have conflicting binding texture dimension in the shaders.
|
||||||
TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
|
TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform texture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(vertex)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_3d<f32>;
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform texture3D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = nullptr;
|
descriptor.layout = nullptr;
|
||||||
|
@ -662,19 +653,17 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
|
||||||
|
|
||||||
// Test it is invalid to have conflicting binding texture component type in the shaders.
|
// Test it is invalid to have conflicting binding texture component type in the shaders.
|
||||||
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
|
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<f32>;
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform texture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(vertex)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[set(0), binding(0)]] var<uniform_constant> myTexture : texture_sampled_2d<i32>;
|
||||||
#version 450
|
|
||||||
layout(set = 0, binding = 0) uniform utexture2D tex;
|
|
||||||
|
|
||||||
void main() {})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor descriptor(device);
|
||||||
descriptor.layout = nullptr;
|
descriptor.layout = nullptr;
|
||||||
|
@ -687,35 +676,27 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
|
||||||
// Test it is an error to query an out of range bind group layout.
|
// Test it is an error to query an out of range bind group layout.
|
||||||
TEST_F(GetBindGroupLayoutTests, OutOfRangeIndex) {
|
TEST_F(GetBindGroupLayoutTests, OutOfRangeIndex) {
|
||||||
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
|
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[stage(fragment)]] fn main() -> void {
|
||||||
layout(set = 0, binding = 0) uniform Buffer1 {
|
})")
|
||||||
vec4 pos1;
|
|
||||||
};
|
|
||||||
void main() {})")
|
|
||||||
.GetBindGroupLayout(kMaxBindGroups));
|
.GetBindGroupLayout(kMaxBindGroups));
|
||||||
|
|
||||||
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
|
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[stage(fragment)]] fn main() -> void {
|
||||||
layout(set = 0, binding = 0) uniform Buffer1 {
|
})")
|
||||||
vec4 pos1;
|
|
||||||
};
|
|
||||||
void main() {})")
|
|
||||||
.GetBindGroupLayout(kMaxBindGroups + 1));
|
.GetBindGroupLayout(kMaxBindGroups + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that unused indices return the empty bind group layout.
|
// Test that unused indices return the empty bind group layout.
|
||||||
TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
|
TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
|
||||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||||
#version 450
|
[[block]] struct S {
|
||||||
layout(set = 0, binding = 0) uniform Buffer1 {
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
vec4 pos1;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> uniforms0 : S;
|
||||||
|
[[set(2), binding(0)]] var<uniform> uniforms2 : S;
|
||||||
|
|
||||||
layout(set = 2, binding = 0) uniform Buffer2 {
|
[[stage(fragment)]] fn main() -> void {
|
||||||
vec4 pos2;
|
})");
|
||||||
};
|
|
||||||
|
|
||||||
void main() {})");
|
|
||||||
|
|
||||||
wgpu::BindGroupLayoutDescriptor desc = {};
|
wgpu::BindGroupLayoutDescriptor desc = {};
|
||||||
desc.entryCount = 0;
|
desc.entryCount = 0;
|
||||||
|
@ -749,20 +730,17 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
|
||||||
|
|
||||||
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&pipelineLayoutDesc);
|
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&pipelineLayoutDesc);
|
||||||
|
|
||||||
wgpu::ShaderModule vsModule =
|
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[block]] struct S {
|
||||||
#version 450
|
[[offset(0)]] pos : vec4<f32>;
|
||||||
layout(set = 0, binding = 0) uniform Buffer1 {
|
|
||||||
vec4 pos1;
|
|
||||||
};
|
};
|
||||||
|
[[set(0), binding(0)]] var<uniform> uniforms : S;
|
||||||
|
|
||||||
void main() {
|
[[stage(vertex)]] fn main() -> void {
|
||||||
})");
|
})");
|
||||||
|
|
||||||
wgpu::ShaderModule fsModule =
|
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[stage(fragment)]] fn main() -> void {
|
||||||
#version 450
|
|
||||||
void main() {
|
|
||||||
})");
|
})");
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor pipelineDesc(device);
|
utils::ComboRenderPipelineDescriptor pipelineDesc(device);
|
||||||
|
|
Loading…
Reference in New Issue