msl: Handle buffer variables in transform

This removes a lot of awkward logic from the MSL writer, and means
that we now handle all module-scope variables with the same transform.

Change-Id: I782e36a4b88dafbc3f8364f7caa7f95c6ae3f5f1
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/67643
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
James Price
2021-10-28 15:00:39 +00:00
parent c6ce5785d0
commit e548db90f6
141 changed files with 1681 additions and 1546 deletions

View File

@@ -808,7 +808,7 @@ struct TestParams {
struct TestWithParams : resolver::ResolverTestWithParam<TestParams> {};
using ResolverFunctionParameterValidationTest = TestWithParams;
TEST_P(ResolverFunctionParameterValidationTest, SotrageClass) {
TEST_P(ResolverFunctionParameterValidationTest, StorageClass) {
auto& param = GetParam();
auto* ptr_type = ty.pointer(Source{{12, 34}}, ty.i32(), param.storage_class);
auto* arg = Param(Source{{12, 34}}, "p", ptr_type);

View File

@@ -1235,7 +1235,9 @@ bool Resolver::ValidateFunctionParameter(const ast::Function* func,
auto sc = ref->StorageClass();
if (!(sc == ast::StorageClass::kFunction ||
sc == ast::StorageClass::kPrivate ||
sc == ast::StorageClass::kWorkgroup)) {
sc == ast::StorageClass::kWorkgroup) &&
IsValidationEnabled(info->declaration->decorations,
ast::DisabledValidation::kIgnoreStorageClass)) {
std::stringstream ss;
ss << "function parameter of pointer type cannot be in '" << sc
<< "' storage class";
@@ -1806,6 +1808,18 @@ bool Resolver::Function(const ast::Function* func) {
param->source);
return false;
}
if (auto* ptr = param_info->type->As<sem::Pointer>()) {
// For MSL, we push module-scope variables into the entry point as pointer
// parameters, so we also need to handle their store type.
if (!ApplyStorageClassUsageToType(
ptr->StorageClass(), const_cast<sem::Type*>(ptr->StoreType()),
param->source)) {
AddNote("while instantiating parameter " +
builder_->Symbols().NameFor(param->symbol),
param->source);
return false;
}
}
if (auto* str = param_info->type->As<sem::Struct>()) {
switch (func->PipelineStage()) {