Description
Context
I'm working on a basic compiler for converting Rust functions to SPIR-V using proc macros and rspirv (to achieve similar functionality as CUDA)
Error
When compiling buffers to parameters I'm having an issue where the correlating OpTypeStruct (this: %_struct_5 = OpTypeStruct %_runtimearr_float
) doesn't actually get decorated with Block despite marking aforementioned type with Block
using rspirv.
Code Snippet
This is from withing a struct that uses a handful of hashmaps to store and access variable ids and type ids:
// get word of the type of the elements in the runtime arr
let base_word = self.types.get(arr_ty).ok_or(anyhow!(
"failed to retrieve base type of runtime arr: {:?}",
arr_ty
))?;
// create runtime arr type (pretty simple)
let runtime_ty = self.spirv_builder.type_runtime_array(*base_word);
// create a struct type
let struct_ty = self.spirv_builder.type_struct(vec![runtime_ty]);
self.spirv_builder.decorate(
struct_ty,
rspirv::spirv::Decoration::Block,
vec![],
);
let lit_0 = self.literals
.get(&MimirLit::Int32(0))
.ok_or(anyhow!("Failed to find literal 0 for struct decoration"))?;
self.spirv_builder.member_decorate(
struct_ty,
*lit_0,
rspirv::spirv::Decoration::Offset,
vec![rspirv::dr::Operand::LiteralBit32(0)]
);
SPIR-V
Outputted SPIR-V for my compiler:
saxpy.spirv.txt
Because the SPIR-V contains %_runtimearr_float = OpTypeRuntimeArray %float
and
%_struct_5 = OpTypeStruct %_runtimearr_float
the code for generating buffers is being called but the types are not being decorated properly.
Thank you in advance for any help, thank you!