Skip to content

Commit

Permalink
Generating Bare Yaml with the --reflection option includes a new unif…
Browse files Browse the repository at this point in the history
…orm_blocks_refl block
  • Loading branch information
Interrupt committed Sep 2, 2024
1 parent ca1d88c commit 4e859bb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/shdc/generators/yaml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ ErrMsg YamlGenerator::generate(const GenInput& gen) {
}
l_close();
}
if (gen.args.reflection) {
if (refl.bindings.uniform_blocks.size() > 0) {
l_open("uniform_blocks_refl:\n");
for (const auto& uniform_block: refl.bindings.uniform_blocks) {
gen_uniform_block_refl(uniform_block);
}
l_close();
}
}
if (refl.bindings.storage_buffers.size() > 0) {
l_open("storage_buffers:\n");
for (const auto& sbuf: refl.bindings.storage_buffers) {
Expand Down Expand Up @@ -149,6 +158,25 @@ void YamlGenerator::gen_uniform_block(const UniformBlock& ub) {
l_close();
}

void YamlGenerator::gen_uniform_block_refl(const UniformBlock& ub) {
l_open("-\n");
l("slot: {}\n", ub.slot);
l("size: {}\n", roundup(ub.struct_info.size, 16));
l("struct_name: {}\n", ub.struct_info.name);
l("inst_name: {}\n", ub.inst_name);
l_open("uniforms:\n");
for (const Type& u: ub.struct_info.struct_items) {
l_open("-\n");
l("name: {}\n", u.name);
l("type: {}\n", uniform_type(u.type));
l("array_count: {}\n", u.array_count);
l("offset: {}\n", u.offset);
l_close();
}
l_close();
l_close();
}

void YamlGenerator::gen_storage_buffer(const StorageBuffer& sbuf) {
const auto& item = sbuf.struct_info.struct_items[0];
l_open("-\n");
Expand Down
1 change: 1 addition & 0 deletions src/shdc/generators/yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class YamlGenerator: public BareGenerator {
private:
void gen_attr(const refl::StageAttr& attr);
void gen_uniform_block(const refl::UniformBlock& ub);
void gen_uniform_block_refl(const refl::UniformBlock& ub);
void gen_storage_buffer(const refl::StorageBuffer& sbuf);
void gen_image(const refl::Image& img);
void gen_sampler(const refl::Sampler& smp);
Expand Down

0 comments on commit 4e859bb

Please sign in to comment.