Skip to content

Commit

Permalink
[msl] Key PackedVec3 helpers on pointer type
Browse files Browse the repository at this point in the history
Using the same composite type from multiple address spaces was causing
collisions in the helper functions that meant they were being reused
across different address spaces.

Fixed: 366037039
Change-Id: I72927b90febd26fa23cb7acd4153b70af1c69fbe
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/206375
Reviewed-by: Antonio Maiorano <[email protected]>
  • Loading branch information
jrprice committed Sep 12, 2024
1 parent 2744a22 commit 59c9377
Show file tree
Hide file tree
Showing 13 changed files with 1,222 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/tint/lang/msl/writer/raise/packed_vec3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ struct State {
/// when inside an array.
Hashmap<const core::type::Type*, const core::type::Struct*, 4> packed_array_element_types{};

// A map from an unpacked type to a helper function that will load it from a packed pointer.
Hashmap<const core::type::Type*, core::ir::Function*, 4> packed_load_helpers{};
// A map from a packed pointer type to a helper function that will load it to an unpacked type.
Hashmap<const core::type::Pointer*, core::ir::Function*, 4> packed_load_helpers{};

// A map from an unpacked type to a helper function that will store it to a packed pointer.
Hashmap<const core::type::Type*, core::ir::Function*, 4> packed_store_helpers{};
// A map from a packed pointer type to a helper function that will store an unpacked type to it.
Hashmap<const core::type::Pointer*, core::ir::Function*, 4> packed_store_helpers{};

/// Process the module.
void Process() {
Expand Down Expand Up @@ -410,7 +410,7 @@ struct State {
/// @returns the helper function
core::ir::Function* LoadPackedArrayHelper(const core::type::Array* unpacked_arr,
const core::type::Pointer* packed_ptr_type) {
return packed_load_helpers.GetOrAdd(unpacked_arr, [&] {
return packed_load_helpers.GetOrAdd(packed_ptr_type, [&] {
auto* func = b.Function(sym.New("tint_load_array_packed_vec3").Name(), unpacked_arr);
auto* from = b.FunctionParam("from", packed_ptr_type);
func->SetParams({from});
Expand Down Expand Up @@ -472,7 +472,7 @@ struct State {
/// @returns the helper function
core::ir::Function* LoadPackedStructHelper(const core::type::Struct* unpacked_str,
const core::type::Pointer* packed_ptr_type) {
return packed_load_helpers.GetOrAdd(unpacked_str, [&] {
return packed_load_helpers.GetOrAdd(packed_ptr_type, [&] {
auto* func = b.Function(sym.New("tint_load_struct_packed_vec3").Name(), unpacked_str);
auto* from = b.FunctionParam("from", packed_ptr_type);
func->SetParams({from});
Expand Down Expand Up @@ -547,7 +547,7 @@ struct State {
/// @returns the helper function
core::ir::Function* StorePackedArrayHelper(const core::type::Array* unpacked_arr,
const core::type::Pointer* packed_ptr_type) {
return packed_store_helpers.GetOrAdd(unpacked_arr, [&] {
return packed_store_helpers.GetOrAdd(packed_ptr_type, [&] {
auto* func = b.Function(sym.New("tint_store_array_packed_vec3").Name(), ty.void_());
auto* to = b.FunctionParam("to", packed_ptr_type);
auto* value = b.FunctionParam("value", unpacked_arr);
Expand Down Expand Up @@ -603,7 +603,7 @@ struct State {
/// @returns the helper function
core::ir::Function* StorePackedStructHelper(const core::type::Struct* unpacked_str,
const core::type::Pointer* packed_ptr_type) {
return packed_store_helpers.GetOrAdd(unpacked_str, [&] {
return packed_store_helpers.GetOrAdd(packed_ptr_type, [&] {
auto* func = b.Function(sym.New("tint_store_array_packed_vec3").Name(), ty.void_());
auto* to = b.FunctionParam("to", packed_ptr_type);
auto* value = b.FunctionParam("value", unpacked_str);
Expand Down
Loading

0 comments on commit 59c9377

Please sign in to comment.