Move texture_storage access into type

Instead of having it as a decoration.
The old style is now deprecated and will be removed soon.

See  https://github.com/gpuweb/gpuweb/pull/1735 for the WGSL spec change.

Bug: tint:846
Change-Id: Id2fa681ddf7b97cd3fa41d7b5538029d96db7e28
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/53082
Reviewed-by: Corentin Wallez <cwallez@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-06-03 13:21:36 +00:00 committed by Dawn LUCI CQ
parent b66f630f81
commit b3c371031c
6 changed files with 23 additions and 23 deletions

View File

@ -1205,7 +1205,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
bgEntries.push_back({nullptr, binding, nullptr, 0, 0, nullptr, texture.CreateView()}); bgEntries.push_back({nullptr, binding, nullptr, 0, 0, nullptr, texture.CreateView()});
interface << "[[group(0), binding(" << binding++ << ")]] " interface << "[[group(0), binding(" << binding++ << ")]] "
<< "var image" << i << " : [[access(read)]] texture_storage_2d<r32uint>;\n"; << "var image" << i << " : texture_storage_2d<r32uint, read>;\n";
body << "if (textureLoad(image" << i << ", vec2<i32>(0, 0)).r != " << expectedValue++ body << "if (textureLoad(image" << i << ", vec2<i32>(0, 0)).r != " << expectedValue++
<< "u) {\n"; << "u) {\n";

View File

@ -425,7 +425,7 @@ class BufferZeroInitTest : public DawnTest {
// As long as the comptue shader is executed once, the pixel color of outImage will be set // As long as the comptue shader is executed once, the pixel color of outImage will be set
// to red. // to red.
const char* computeShader = R"( const char* computeShader = R"(
[[group(0), binding(0)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var outImage : texture_storage_2d<rgba8unorm, write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0)); textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
@ -997,7 +997,7 @@ TEST_P(BufferZeroInitTest, BoundAsUniformBuffer) {
value : vec4<u32>; value : vec4<u32>;
}; };
[[group(0), binding(0)]] var<uniform> ubo : UBO; [[group(0), binding(0)]] var<uniform> ubo : UBO;
[[group(0), binding(1)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
if (all(ubo.value == vec4<u32>(0u, 0u, 0u, 0u))) { if (all(ubo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
@ -1036,7 +1036,7 @@ TEST_P(BufferZeroInitTest, BoundAsReadonlyStorageBuffer) {
value : vec4<u32>; value : vec4<u32>;
}; };
[[group(0), binding(0)]] var<storage> ssbo : [[access(read_write)]] SSBO; [[group(0), binding(0)]] var<storage> ssbo : [[access(read_write)]] SSBO;
[[group(0), binding(1)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
if (all(ssbo.value == vec4<u32>(0u, 0u, 0u, 0u))) { if (all(ssbo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
@ -1075,7 +1075,7 @@ TEST_P(BufferZeroInitTest, BoundAsStorageBuffer) {
value : array<vec4<u32>, 2>; value : array<vec4<u32>, 2>;
}; };
[[group(0), binding(0)]] var<storage> ssbo : [[access(read_write)]] SSBO; [[group(0), binding(0)]] var<storage> ssbo : [[access(read_write)]] SSBO;
[[group(0), binding(1)]] var outImage : [[access(write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
if (all(ssbo.value[0] == vec4<u32>(0u, 0u, 0u, 0u)) && if (all(ssbo.value[0] == vec4<u32>(0u, 0u, 0u, 0u)) &&

View File

@ -257,7 +257,7 @@ TEST_P(GpuMemorySyncTests, SampledAndROStorageTextureInComputePass) {
}; };
[[group(0), binding(0)]] var<storage> output : [[access(write)]] Output; [[group(0), binding(0)]] var<storage> output : [[access(write)]] Output;
[[group(0), binding(1)]] var sampledTex : texture_2d<u32>; [[group(0), binding(1)]] var sampledTex : texture_2d<u32>;
[[group(0), binding(2)]] var storageTex : [[access(read)]] texture_storage_2d<r32uint>; [[group(0), binding(2)]] var storageTex : texture_storage_2d<r32uint, read>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
output.sampledOut = textureLoad(sampledTex, vec2<i32>(0, 0), 0).x; output.sampledOut = textureLoad(sampledTex, vec2<i32>(0, 0), 0).x;

View File

@ -982,8 +982,8 @@ TEST_P(StorageTextureTests, ReadonlyAndWriteonlyStorageTexturePingPong) {
kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, 1u, 1u); kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, 1u, 1u);
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var Src : [[access(read)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var Src : texture_storage_2d<r32uint, read>;
[[group(0), binding(1)]] var Dst : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(1)]] var Dst : texture_storage_2d<r32uint, write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0)); var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0));
srcValue.x = srcValue.x + 1u; srcValue.x = srcValue.x + 1u;
@ -1057,7 +1057,7 @@ TEST_P(StorageTextureTests, SampledAndWriteonlyStorageTexturePingPong) {
kTextureFormat, wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Storage, 1u, 1u); kTextureFormat, wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Storage, 1u, 1u);
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"( wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var Src : texture_2d<u32>; [[group(0), binding(0)]] var Src : texture_2d<u32>;
[[group(0), binding(1)]] var Dst : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(1)]] var Dst : texture_storage_2d<r32uint, write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0), 0); var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0), 0);
srcValue.x = srcValue.x + 1u; srcValue.x = srcValue.x + 1u;
@ -1155,13 +1155,13 @@ fn doTest() -> bool {
})"; })";
const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"( const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"(
[[group(0), binding(0)]] var dstImage : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var dstImage : texture_storage_2d<r32uint, write>;
[[stage(fragment)]] fn main() { [[stage(fragment)]] fn main() {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u)); textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
})"; })";
const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"( const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"(
[[group(0), binding(0)]] var dstImage : [[access(write)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var dstImage : texture_storage_2d<r32uint, write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u)); textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
@ -1178,7 +1178,7 @@ TEST_P(StorageTextureZeroInitTests, ReadonlyStorageTextureClearsToZeroInRenderPa
// green as the output color, otherwise uses red instead. // green as the output color, otherwise uses red instead.
const char* kVertexShader = kSimpleVertexShader; const char* kVertexShader = kSimpleVertexShader;
const std::string kFragmentShader = std::string(R"( const std::string kFragmentShader = std::string(R"(
[[group(0), binding(0)]] var srcImage : [[access(read)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var srcImage : texture_storage_2d<r32uint, read>;
)") + kCommonReadOnlyZeroInitTestCode + )") + kCommonReadOnlyZeroInitTestCode +
R"( R"(
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> { [[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
@ -1203,7 +1203,7 @@ TEST_P(StorageTextureZeroInitTests, ReadonlyStorageTextureClearsToZeroInComputeP
result : u32; result : u32;
}; };
[[group(0), binding(0)]] var srcImage : [[access(read)]] texture_storage_2d<r32uint>; [[group(0), binding(0)]] var srcImage : texture_storage_2d<r32uint, read>;
[[group(0), binding(1)]] var<storage> dstBuffer : [[access(read_write)]] DstBuffer; [[group(0), binding(1)]] var<storage> dstBuffer : [[access(read_write)]] DstBuffer;
)") + kCommonReadOnlyZeroInitTestCode + R"( )") + kCommonReadOnlyZeroInitTestCode + R"(
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {

View File

@ -1508,7 +1508,7 @@ namespace {
})"); })");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var tex : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var tex : texture_storage_2d<rgba8unorm, read>;
[[stage(fragment)]] fn main() { [[stage(fragment)]] fn main() {
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor; utils::ComboRenderPipelineDescriptor pipelineDescriptor;

View File

@ -120,7 +120,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Readonly storage texture can be declared in a vertex shader. // Readonly storage texture can be declared in a vertex shader.
{ {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
[[stage(vertex)]] fn main( [[stage(vertex)]] fn main(
[[builtin(vertex_index)]] VertexIndex : u32 [[builtin(vertex_index)]] VertexIndex : u32
) -> [[builtin(position)]] vec4<f32> { ) -> [[builtin(position)]] vec4<f32> {
@ -137,7 +137,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Read-only storage textures can be declared in a fragment shader. // Read-only storage textures can be declared in a fragment shader.
{ {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
[[stage(fragment)]] fn main( [[stage(fragment)]] fn main(
[[builtin(position)]] FragCoord : vec4<f32> [[builtin(position)]] FragCoord : vec4<f32>
) -> [[location(0)]] vec4<f32> { ) -> [[location(0)]] vec4<f32> {
@ -154,7 +154,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Write-only storage textures cannot be declared in a vertex shader. // Write-only storage textures cannot be declared in a vertex shader.
if ((false) /* TODO(https://crbug.com/tint/449) */) { if ((false) /* TODO(https://crbug.com/tint/449) */) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
[[stage(vertex)]] fn main([[builtin(vertex_index)]] vertex_index : u32) { [[stage(vertex)]] fn main([[builtin(vertex_index)]] vertex_index : u32) {
textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0)); textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})"); })");
@ -169,7 +169,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Write-only storage textures can be declared in a fragment shader. // Write-only storage textures can be declared in a fragment shader.
{ {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
[[stage(fragment)]] fn main([[builtin(position)]] position : vec4<f32>) { [[stage(fragment)]] fn main([[builtin(position)]] position : vec4<f32>) {
textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0)); textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})"); })");
@ -188,7 +188,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Read-only storage textures can be declared in a compute shader. // Read-only storage textures can be declared in a compute shader.
{ {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read>;
[[block]] struct Buf { [[block]] struct Buf {
data : f32; data : f32;
@ -210,7 +210,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Write-only storage textures can be declared in a compute shader. // Write-only storage textures can be declared in a compute shader.
{ {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
[[stage(compute)]] fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3<u32>) { [[stage(compute)]] fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3<u32>) {
textureStore(image0, vec2<i32>(LocalInvocationID.xy), vec4<f32>(0.0, 0.0, 0.0, 0.0)); textureStore(image0, vec2<i32>(LocalInvocationID.xy), vec4<f32>(0.0, 0.0, 0.0, 0.0));
@ -230,7 +230,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a vertex shader by default. // Read-write storage textures cannot be declared in a vertex shader by default.
{ {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
[[stage(vertex)]] fn main() { [[stage(vertex)]] fn main() {
textureDimensions(image0); textureDimensions(image0);
})")); })"));
@ -239,7 +239,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a fragment shader by default. // Read-write storage textures cannot be declared in a fragment shader by default.
{ {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
[[stage(fragment)]] fn main() { [[stage(fragment)]] fn main() {
textureDimensions(image0); textureDimensions(image0);
})")); })"));
@ -248,7 +248,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a compute shader by default. // Read-write storage textures cannot be declared in a compute shader by default.
{ {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"( ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>; [[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
[[stage(compute)]] fn main() { [[stage(compute)]] fn main() {
textureDimensions(image0); textureDimensions(image0);
})")); })"));