Move storage_class validation from wgsl to resolver

We don't want the WGSL parser to have to maintain type lookups.
If the WGSL language is updated to allow module-scope variables to be declared in any order, then the single-pass approach is going to fail horribly.

Instead do the check in the Resovler.
With this change, the AST nodes actually contain the correctly declared storage class.

Fix up the SPIR-V reader to generate StorageClass::kNone for handle types.
Fix all tests.

Bug: tint:724
Change-Id: I102e30c9bbef32de40e123c2676ea9a281dee74d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50306
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
This commit is contained in:
Ben Clayton
2021-05-10 18:01:51 +00:00
committed by Commit Bot service account
parent a34fa0ecb7
commit fcda15ef67
26 changed files with 154 additions and 142 deletions

View File

@@ -316,8 +316,7 @@ class InspectorHelper : public ProgramBuilder {
/// @param group the binding/group to use for the storage buffer
/// @param binding the binding number to use for the storage buffer
void AddSampler(const std::string& name, uint32_t group, uint32_t binding) {
AddBinding(name, sampler_type(), ast::StorageClass::kUniformConstant, group,
binding);
AddBinding(name, sampler_type(), ast::StorageClass::kNone, group, binding);
}
/// Adds a comparison sampler variable to the program
@@ -327,8 +326,8 @@ class InspectorHelper : public ProgramBuilder {
void AddComparisonSampler(const std::string& name,
uint32_t group,
uint32_t binding) {
AddBinding(name, comparison_sampler_type(),
ast::StorageClass::kUniformConstant, group, binding);
AddBinding(name, comparison_sampler_type(), ast::StorageClass::kNone, group,
binding);
}
/// Generates a SampledTexture appropriate for the params
@@ -366,7 +365,7 @@ class InspectorHelper : public ProgramBuilder {
ast::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
AddBinding(name, type, ast::StorageClass::kNone, group, binding);
}
/// Adds a multi-sampled texture variable to the program
@@ -378,7 +377,7 @@ class InspectorHelper : public ProgramBuilder {
ast::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
AddBinding(name, type, ast::StorageClass::kNone, group, binding);
}
void AddGlobalVariable(const std::string& name, ast::Type* type) {
@@ -394,7 +393,7 @@ class InspectorHelper : public ProgramBuilder {
ast::Type* type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
AddBinding(name, type, ast::StorageClass::kNone, group, binding);
}
/// Generates a function that references a specific sampler variable
@@ -566,7 +565,7 @@ class InspectorHelper : public ProgramBuilder {
typ::Type type,
uint32_t group,
uint32_t binding) {
AddBinding(name, type, ast::StorageClass::kUniformConstant, group, binding);
AddBinding(name, type, ast::StorageClass::kNone, group, binding);
}
/// Generates a function that references a storage texture variable.