Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[spirv] Add names to buffer struct types and pointers #4092

Merged
merged 2 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions taichi/codegen/spirv/spirv_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,9 +1597,8 @@ class TaskCodegen : public IRVisitor {
return it->second;
}

spirv::Value buffer_value =
ir_->buffer_argument(type, 0, buffer_binding_map_[buffer]);
ir_->debug(spv::OpName, buffer_value, buffer_instance_name(buffer));
spirv::Value buffer_value = ir_->buffer_argument(
type, 0, buffer_binding_map_[buffer], buffer_instance_name(buffer));
buffer_value_map_[key] = buffer_value;
TI_TRACE("buffer name = {}, value = {}", buffer_instance_name(buffer),
buffer_value.id);
Expand All @@ -1616,9 +1615,8 @@ class TaskCodegen : public IRVisitor {
return it->second;
}

spirv::Value buffer_value =
ir_->buffer_argument(type, 0, buffer_binding_map_[buffer]);
ir_->debug(spv::OpName, buffer_value, buffer_instance_name(buffer));
spirv::Value buffer_value = ir_->buffer_argument(
type, 0, buffer_binding_map_[buffer], buffer_instance_name(buffer));
buffer_value_map_[key] = buffer_value;
TI_TRACE("buffer name = {}, value = {}", buffer_instance_name(buffer),
buffer_value.id);
Expand Down
9 changes: 8 additions & 1 deletion taichi/codegen/spirv/spirv_ir_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ SType IRBuilder::get_struct_array_type(const SType &value_type,

Value IRBuilder::buffer_argument(const SType &value_type,
uint32_t descriptor_set,
uint32_t binding) {
uint32_t binding,
const std::string &name) {
// NOTE: BufferBlock was deprecated in SPIRV 1.3
// use StorageClassStorageBuffer instead.
spv::StorageClass storage_class;
Expand All @@ -365,7 +366,13 @@ Value IRBuilder::buffer_argument(const SType &value_type,
}

SType sarr_type = get_struct_array_type(value_type, 0);

this->debug(spv::OpName, sarr_type, name + "_struct_array");

SType ptr_type = get_pointer_type(sarr_type, storage_class);

this->debug(spv::OpName, sarr_type, name + "_ptr");

Value val = new_value(ptr_type, ValueKind::kStructArrayPtr);
ib_.begin(spv::OpVariable)
.add_seq(ptr_type, val, storage_class)
Expand Down
3 changes: 2 additions & 1 deletion taichi/codegen/spirv/spirv_ir_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,8 @@ class IRBuilder {
// Declare buffer argument of function
Value buffer_argument(const SType &value_type,
uint32_t descriptor_set,
uint32_t binding);
uint32_t binding,
const std::string &name);
Value struct_array_access(const SType &res_type, Value buffer, Value index);

// Declare a new function
Expand Down