-
Given a shader parameter of type I got this far: Slang::ComPtr<slang::IComponentType> program;
compile_request->getProgram(program.writeRef());
auto program_layout = program->getLayout();
auto parameter_count = program_layout->getParameterCount();
for (auto i : std::ranges::views::iota(0u, parameter_count)) {
auto parameter = program_layout->getParameterByIndex(i);
std::cout
<< parameter->getName() << ' '
<< parameter->getCategory() << ' '
<< parameter->getBindingIndex() << '\n';
auto element_type = parameter->getType()->getElementType();
if (element_type->getKind() == slang::TypeReflection::Kind::Struct) {
auto field_count = element_type->getFieldCount();
for (auto j : std::ranges::views::iota(0u, field_count)) {
auto field = element_type->getFieldByIndex(j);
std::cout
<< " "
<< field->getName() << ' '
<< field->getType()->getName() << '\n';
}
}
} This prints the name and type of each field of each struct used in a structured buffer parameter. However, |
Beta Was this translation helpful? Give feedback.
Answered by
zopsicle
Jan 24, 2024
Replies: 1 comment
-
Ah, I found it! Simply use auto element_type = parameter->getTypeLayout()->getElementTypeLayout(); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zopsicle
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah, I found it! Simply use
getTypeLayout
instead ofgetType
onparameter
: