mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 16:37:08 +00:00
Implement Pointers and References
This change implements pointers and references as described by the WGSL specification change in https://github.com/gpuweb/gpuweb/pull/1569. reader/spirv: * Now emits address-of `&expr` and indirection `*expr` operators as needed. * As an identifier may now resolve to a pointer or reference type depending on whether the declaration is a `var`, `let` or parameter, `Function::identifier_values_` has been changed from an ID set to an ID -> Type* map. resolver: * Now correctly resolves all expressions to either a value type, reference type or pointer type. * Validates pointer / reference rules on assignment, `var` and `let` construction, and usage. * Handles the address-of and indirection operators. * No longer does any implicit loads of pointer types. * Storage class validation is still TODO (crbug.com/tint/809) writer/spirv: * Correctly handles variables and expressions of pointer and reference types, emitting OpLoads where necessary. test: * Lots of new test cases Fixed: tint:727 Change-Id: I77d3281590e35e5a3122f5b74cdeb71a6fe51f74 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/50740 Commit-Queue: Ben Clayton <bclayton@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
committed by
Commit Bot service account
parent
d1232670ae
commit
9b54a2e53c
@@ -227,7 +227,7 @@ std::vector<EntryPoint> Inspector::GetEntryPoints() {
|
||||
stage_variable.name = name;
|
||||
|
||||
stage_variable.component_type = ComponentType::kUnknown;
|
||||
auto* type = var->Type()->UnwrapAll();
|
||||
auto* type = var->Type()->UnwrapRef();
|
||||
if (type->is_float_scalar_or_vector() || type->is_float_matrix()) {
|
||||
stage_variable.component_type = ComponentType::kFloat;
|
||||
} else if (type->is_unsigned_scalar_or_vector()) {
|
||||
@@ -400,7 +400,7 @@ std::vector<ResourceBinding> Inspector::GetUniformBufferResourceBindings(
|
||||
auto* var = ruv.first;
|
||||
auto binding_info = ruv.second;
|
||||
|
||||
auto* unwrapped_type = var->Type()->UnwrapAccess();
|
||||
auto* unwrapped_type = var->Type()->UnwrapRef();
|
||||
auto* str = unwrapped_type->As<sem::Struct>();
|
||||
if (str == nullptr) {
|
||||
continue;
|
||||
@@ -522,7 +522,7 @@ std::vector<ResourceBinding> Inspector::GetDepthTextureResourceBindings(
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
auto* texture_type = var->Type()->UnwrapAccess()->As<sem::Texture>();
|
||||
auto* texture_type = var->Type()->UnwrapRef()->As<sem::Texture>();
|
||||
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
|
||||
texture_type->dim());
|
||||
|
||||
@@ -550,7 +550,7 @@ std::vector<ResourceBinding> Inspector::GetExternalTextureResourceBindings(
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
auto* texture_type = var->Type()->UnwrapAccess()->As<sem::Texture>();
|
||||
auto* texture_type = var->Type()->UnwrapRef()->As<sem::Texture>();
|
||||
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
|
||||
texture_type->dim());
|
||||
|
||||
@@ -584,7 +584,7 @@ void Inspector::AddEntryPointInOutVariables(
|
||||
return;
|
||||
}
|
||||
|
||||
auto* unwrapped_type = type->UnwrapAll();
|
||||
auto* unwrapped_type = type->UnwrapRef();
|
||||
|
||||
if (auto* struct_ty = unwrapped_type->As<sem::Struct>()) {
|
||||
// Recurse into members.
|
||||
@@ -641,7 +641,7 @@ std::vector<ResourceBinding> Inspector::GetStorageBufferResourceBindingsImpl(
|
||||
continue;
|
||||
}
|
||||
|
||||
auto* str = var->Type()->UnwrapAccess()->As<sem::Struct>();
|
||||
auto* str = var->Type()->UnwrapRef()->As<sem::Struct>();
|
||||
if (!str) {
|
||||
continue;
|
||||
}
|
||||
@@ -685,7 +685,7 @@ std::vector<ResourceBinding> Inspector::GetSampledTextureResourceBindingsImpl(
|
||||
entry.bind_group = binding_info.group->value();
|
||||
entry.binding = binding_info.binding->value();
|
||||
|
||||
auto* texture_type = var->Type()->UnwrapAccess()->As<sem::Texture>();
|
||||
auto* texture_type = var->Type()->UnwrapRef()->As<sem::Texture>();
|
||||
entry.dim = TypeTextureDimensionToResourceBindingTextureDimension(
|
||||
texture_type->dim());
|
||||
|
||||
@@ -717,7 +717,7 @@ std::vector<ResourceBinding> Inspector::GetStorageTextureResourceBindingsImpl(
|
||||
auto* var = ref.first;
|
||||
auto binding_info = ref.second;
|
||||
|
||||
auto* texture_type = var->Type()->As<sem::StorageTexture>();
|
||||
auto* texture_type = var->Type()->UnwrapRef()->As<sem::StorageTexture>();
|
||||
|
||||
if (read_only !=
|
||||
(texture_type->access_control() == ast::AccessControl::kReadOnly)) {
|
||||
|
||||
Reference in New Issue
Block a user