Update ComputeStorageBufferBarrierTests to use WGSL
Bug: dawn:572 Change-Id: I42e971b843807602ba91f5df0aa692569ec31521 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/32511 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
d10774c42f
commit
64c5d601f8
|
@ -31,13 +31,17 @@ TEST_P(ComputeStorageBufferBarrierTests, AddIncrement) {
|
|||
wgpu::Buffer buffer = utils::CreateBufferFromData(
|
||||
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
|
||||
|
||||
wgpu::ShaderModule module =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
||||
#version 450
|
||||
#define kNumValues 100
|
||||
layout(std430, set = 0, binding = 0) buffer Buf { uint buf[kNumValues]; };
|
||||
void main() {
|
||||
buf[gl_GlobalInvocationID.x] += 0x1234;
|
||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||
[[block]] struct Buf {
|
||||
[[offset(0)]] data : [[stride(4)]] array<u32, 100>;
|
||||
};
|
||||
|
||||
[[set(0), binding(0)]] var<storage_buffer> buf : [[access(read_write)]] Buf;
|
||||
|
||||
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
|
||||
|
||||
[[stage(compute)]] fn main() -> void {
|
||||
buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234;
|
||||
}
|
||||
)");
|
||||
|
||||
|
@ -78,15 +82,22 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
|
|||
wgpu::Buffer bufferB = utils::CreateBufferFromData(
|
||||
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
|
||||
|
||||
wgpu::ShaderModule module =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
||||
#version 450
|
||||
#define kNumValues 100
|
||||
layout(std430, set = 0, binding = 0) buffer Src { uint src[kNumValues]; };
|
||||
layout(std430, set = 0, binding = 1) buffer Dst { uint dst[kNumValues]; };
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
dst[index] = src[index] + 0x1234;
|
||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||
# TODO(crbug.com/tint/386): Use the same struct.
|
||||
[[block]] struct Src {
|
||||
[[offset(0)]] data : [[stride(4)]] array<u32, 100>;
|
||||
};
|
||||
|
||||
[[block]] struct Dst {
|
||||
[[offset(0)]] data : [[stride(4)]] array<u32, 100>;
|
||||
};
|
||||
|
||||
[[set(0), binding(0)]] var<storage_buffer> src : [[access(read_write)]] Src;
|
||||
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Dst;
|
||||
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
|
||||
|
||||
[[stage(compute)]] fn main() -> void {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234;
|
||||
}
|
||||
)");
|
||||
|
||||
|
@ -142,15 +153,23 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
|
|||
wgpu::Buffer bufferB = utils::CreateBufferFromData(
|
||||
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
|
||||
|
||||
wgpu::ShaderModule module =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
||||
#version 450
|
||||
#define kNumValues 100
|
||||
layout(std430, set = 0, binding = 0) readonly buffer Src { uint src[kNumValues]; };
|
||||
layout(std430, set = 0, binding = 1) buffer Dst { uint dst[kNumValues]; };
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
dst[index] = src[index] + 0x1234;
|
||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||
# TODO(crbug.com/tint/386): Use the same struct.
|
||||
[[block]] struct Src {
|
||||
[[offset(0)]] data : [[stride(4)]] array<u32, 100>;
|
||||
};
|
||||
|
||||
[[block]] struct Dst {
|
||||
[[offset(0)]] data : [[stride(4)]] array<u32, 100>;
|
||||
};
|
||||
|
||||
[[set(0), binding(0)]] var<storage_buffer> src : [[access(read)]] Src;
|
||||
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Dst;
|
||||
|
||||
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
|
||||
|
||||
[[stage(compute)]] fn main() -> void {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234;
|
||||
}
|
||||
)");
|
||||
|
||||
|
@ -208,15 +227,18 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPong) {
|
|||
device, data.data(), bufferSize,
|
||||
wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopySrc);
|
||||
|
||||
wgpu::ShaderModule module =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
||||
#version 450
|
||||
#define kNumValues 100
|
||||
layout(std140, set = 0, binding = 0) uniform Src { uvec4 src[kNumValues / 4]; };
|
||||
layout(std430, set = 0, binding = 1) buffer Dst { uvec4 dst[kNumValues / 4]; };
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
dst[index] = src[index] + 0x1234;
|
||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||
[[block]] struct Buf {
|
||||
[[offset(0)]] data : [[stride(16)]] array<vec4<u32>, 25>;
|
||||
};
|
||||
|
||||
[[set(0), binding(0)]] var<uniform> src : Buf;
|
||||
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Buf;
|
||||
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
|
||||
|
||||
[[stage(compute)]] fn main() -> void {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
|
||||
vec4<u32>(0x1234, 0x1234, 0x1234, 0x1234);
|
||||
}
|
||||
)");
|
||||
|
||||
|
@ -273,15 +295,18 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPongInOnePass) {
|
|||
device, data.data(), bufferSize,
|
||||
wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopySrc);
|
||||
|
||||
wgpu::ShaderModule module =
|
||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
||||
#version 450
|
||||
#define kNumValues 100
|
||||
layout(std140, set = 0, binding = 0) uniform Src { uvec4 src[kNumValues / 4]; };
|
||||
layout(std430, set = 0, binding = 1) buffer Dst { uvec4 dst[kNumValues / 4]; };
|
||||
void main() {
|
||||
uint index = gl_GlobalInvocationID.x;
|
||||
dst[index] = src[index] + 0x1234;
|
||||
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||
[[block]] struct Buf {
|
||||
[[offset(0)]] data : [[stride(16)]] array<vec4<u32>, 25>;
|
||||
};
|
||||
|
||||
[[set(0), binding(0)]] var<uniform> src : Buf;
|
||||
[[set(0), binding(1)]] var<storage_buffer> dst : [[access(read_write)]] Buf;
|
||||
[[builtin(global_invocation_id)]] var<in> GlobalInvocationID : vec3<u32>;
|
||||
|
||||
[[stage(compute)]] fn main() -> void {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
|
||||
vec4<u32>(0x1234, 0x1234, 0x1234, 0x1234);
|
||||
}
|
||||
)");
|
||||
|
||||
|
|
Loading…
Reference in New Issue