Remove explicit storage class from samplers/textures

Tint automatically infers a storage class of `handle` for these types
of variable, as per the WGSL spec. Explicitly specifying a storage
class for them will soon become an error.

Bug: tint:332
Change-Id: Ib67e44a5afcdd364470488fd4b456a2b42304daa
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/41402
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: James Price <jrprice@google.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
James Price
2021-02-10 20:17:14 +00:00
committed by Commit Bot service account
parent b417919516
commit 7e80cce1a9
21 changed files with 92 additions and 98 deletions

View File

@@ -1787,11 +1787,11 @@ TEST_F(BindGroupLayoutCompatibilityTest, ROStorageInBGLWithRWStorageInShader) {
TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
constexpr char kTexture2DShaderFS[] = R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void {
})";
constexpr char kTexture2DShaderCS[] = R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(compute)]] fn main() -> void {
})";
@@ -1824,11 +1824,11 @@ TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
wgpu::TextureViewDimension::e2DArray}})}));
constexpr char kTexture2DArrayShaderFS[] = R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
[[stage(fragment)]] fn main() -> void {
})";
constexpr char kTexture2DArrayShaderCS[] = R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
[[stage(compute)]] fn main() -> void {
})";
@@ -2077,7 +2077,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() -> void {
})");
}
@@ -2088,7 +2088,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison;
[[group(0), binding(0)]] var mySampler: sampler_comparison;
[[stage(fragment)]] fn main() -> void {
})");
}
@@ -2099,7 +2099,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var<uniform_constant> mySampler: sampler_comparison;
[[group(0), binding(0)]] var mySampler: sampler_comparison;
[[stage(fragment)]] fn main() -> void {
})"));
}
@@ -2110,7 +2110,7 @@ TEST_F(ComparisonSamplerBindingTest, DISABLED_ShaderAndBGLMatches) {
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
[[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() -> void {
})"));
}

View File

@@ -231,7 +231,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::Float;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -241,7 +241,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{
binding.texture.multisampled = true;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_multisampled_2d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -252,7 +252,7 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
{
binding.sampler.type = wgpu::SamplerBindingType::Filtering;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() -> void {
})");
@@ -279,7 +279,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e1D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_1d<f32>;
[[group(0), binding(0)]] var myTexture : texture_1d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -289,7 +289,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e2D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -299,7 +299,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e2DArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d_array<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -309,7 +309,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::e3D;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_3d<f32>;
[[group(0), binding(0)]] var myTexture : texture_3d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -319,7 +319,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::Cube;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_cube<f32>;
[[group(0), binding(0)]] var myTexture : texture_cube<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -329,7 +329,7 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
{
binding.texture.viewDimension = wgpu::TextureViewDimension::CubeArray;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_cube_array<f32>;
[[group(0), binding(0)]] var myTexture : texture_cube_array<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -355,7 +355,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::Float;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -365,7 +365,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::Sint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<i32>;
[[group(0), binding(0)]] var myTexture : texture_2d<i32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -375,7 +375,7 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
{
binding.texture.sampleType = wgpu::TextureSampleType::Uint;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<u32>;
[[group(0), binding(0)]] var myTexture : texture_2d<u32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -567,7 +567,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
})");
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(vertex)]] fn main() -> void {
})");
@@ -576,7 +576,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
})");
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> mySampler: sampler;
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() -> void {
})");
@@ -654,13 +654,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
// Test it is invalid to have conflicting binding texture multisampling in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_multisampled_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_multisampled_2d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -676,13 +676,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
// Test it is invalid to have conflicting binding texture dimension in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_3d<f32>;
[[group(0), binding(0)]] var myTexture : texture_3d<f32>;
[[stage(fragment)]] fn main() -> void {
})");
@@ -698,13 +698,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
// Test it is invalid to have conflicting binding texture component type in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<f32>;
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<i32>;
[[group(0), binding(0)]] var myTexture : texture_2d<i32>;
[[stage(fragment)]] fn main() -> void {
})");

View File

@@ -397,7 +397,7 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
std::ostringstream stream;
stream << R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : texture_2d<)"
[[group(0), binding(0)]] var myTexture : texture_2d<)"
<< kScalarTypes[i] << R"(>;
[[stage(fragment)]] fn main() -> void {
@@ -446,7 +446,7 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
std::ostringstream stream;
stream << R"(
[[group(0), binding(0)]] var<uniform_constant> myTexture : )"
[[group(0), binding(0)]] var myTexture : )"
<< kTextureKeywords[i] << R"(<f32>;
[[stage(fragment)]] fn main() -> void {
})";

View File

@@ -1554,7 +1554,7 @@ namespace {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
@@ -1580,7 +1580,7 @@ namespace {
{
// Create a passthrough compute pipeline with a readonly storage texture
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[stage(compute)]] fn main() -> void {
})");
wgpu::ComputePipelineDescriptor pipelineDescriptor;

View File

@@ -84,7 +84,7 @@ class StorageTextureValidationTests : public ValidationTest {
}
std::ostringstream ostream;
ostream << "[[group(0), binding(0)]] var<uniform_constant> image0 : "
ostream << "[[group(0), binding(0)]] var image0 : "
<< "[[access(" << access << ")]] " << imageTypeDeclaration << "<"
<< imageFormatQualifier
<< ">;\n"
@@ -121,7 +121,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Readonly storage texture can be declared in a vertex shader.
{
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
@@ -138,7 +138,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Read-only storage textures can be declared in a fragment shader.
{
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
@@ -156,7 +156,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
if ((false) /* TODO(https://crbug.com/tint/449) */) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(vertex_index)]] var<in> vertex_index : u32;
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[stage(vertex)]] fn main() -> void {
textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})");
@@ -172,7 +172,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
{
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(frag_coord)]] var<in> frag_coord : vec4<f32>;
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void {
textureStore(image0, vec2<i32>(frag_coord.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})");
@@ -191,7 +191,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Read-only storage textures can be declared in a compute shader.
{
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(local_invocation_id)]] var<in> LocalInvocationID : vec3<u32>;
[[block]] struct Buf {
@@ -214,7 +214,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Write-only storage textures can be declared in a compute shader.
{
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[builtin(local_invocation_id)]] var<in> LocalInvocationID : vec3<u32>;
[[stage(compute)]] fn main() -> void {
@@ -235,7 +235,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a vertex shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[stage(vertex)]] fn main() -> void {
})"));
}
@@ -243,7 +243,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a fragment shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void {
})"));
}
@@ -251,7 +251,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a compute shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var<uniform_constant> image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[stage(compute)]] fn main() -> void {
})"));
}