From 0dc948ffc9f7b03e29ff969f3edf1a2b6ba7f3fb Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 17 Jul 2023 13:31:31 +0300 Subject: [PATCH] Rename uniform blocks to just blocks in ReflectData --- source/backends/opengl/program_backend.cpp | 24 +++++++++---------- .../backends/vulkan/pipelinestate_backend.cpp | 2 +- source/backends/vulkan/program_backend.cpp | 6 ++--- source/core/pipelinestate.cpp | 2 +- source/core/program.cpp | 22 ++++++++--------- source/core/program.h | 6 ++--- source/core/reflectdata.cpp | 12 +++++----- source/core/reflectdata.h | 10 ++++---- source/core/uniformblock.cpp | 2 +- source/core/uniformblock.h | 2 +- source/materials/programdata.cpp | 14 +++++------ source/materials/programdata.h | 4 ++-- 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/source/backends/opengl/program_backend.cpp b/source/backends/opengl/program_backend.cpp index 6f7e41cc..7183cce4 100644 --- a/source/backends/opengl/program_backend.cpp +++ b/source/backends/opengl/program_backend.cpp @@ -170,13 +170,13 @@ void OpenGLProgram::add_glsl_stages(const GlslModule &mod, const map &block_bindings = compiler.get_uniform_block_bindings(); if(!block_bindings.empty()) { - for(unsigned i=0; isecond); - rd.uniform_blocks[i].bind_point = j->second; + rd.blocks[i].bind_point = j->second; } } } @@ -200,8 +200,8 @@ void OpenGLProgram::add_glsl_stages(const GlslModule &mod, const map(u)->block = &b; @@ -349,8 +349,8 @@ void OpenGLProgram::query_uniforms() query_uniform_blocks(uniforms_by_index); } - rd.uniform_blocks.emplace_back(); - ReflectData::UniformBlockInfo &default_block = rd.uniform_blocks.back(); + rd.blocks.emplace_back(); + ReflectData::BlockInfo &default_block = rd.blocks.back(); for(ReflectData::UniformInfo &u: rd.uniforms) if(!u.block) @@ -377,14 +377,14 @@ void OpenGLProgram::query_uniform_blocks(const vector(&count)); // Reserve an extra index for the default block - rd.uniform_blocks.reserve(count+1); + rd.blocks.reserve(count+1); for(unsigned i=0; i(this)->reflect_data; - auto i = find_member(rd.uniform_blocks, static_cast(ReflectData::DEFAULT_BLOCK), &ReflectData::UniformBlockInfo::bind_point); - if(i!=rd.uniform_blocks.end() && !i->uniforms.empty()) + auto i = find_member(rd.blocks, static_cast(ReflectData::DEFAULT_BLOCK), &ReflectData::BlockInfo::bind_point); + if(i!=rd.blocks.end() && !i->uniforms.empty()) { for(const ReflectData::UniformInfo *u: i->uniforms) if(u->location>=0) diff --git a/source/backends/vulkan/pipelinestate_backend.cpp b/source/backends/vulkan/pipelinestate_backend.cpp index 612c65e3..1cd7d2d3 100644 --- a/source/backends/vulkan/pipelinestate_backend.cpp +++ b/source/backends/vulkan/pipelinestate_backend.cpp @@ -67,7 +67,7 @@ void VulkanPipelineState::update() const if(r.changed || changed_sets==~0U) { if(r.type==PipelineState::UNIFORM_BLOCK) - r.used = self.shprog->uses_uniform_block_binding(r.binding); + r.used = self.shprog->uses_block_binding(r.binding); else if(r.type==PipelineState::SAMPLED_TEXTURE || r.type==PipelineState::STORAGE_TEXTURE) { r.used = self.shprog->uses_texture_binding(r.binding); diff --git a/source/backends/vulkan/program_backend.cpp b/source/backends/vulkan/program_backend.cpp index 52f49c49..8ad2205d 100644 --- a/source/backends/vulkan/program_backend.cpp +++ b/source/backends/vulkan/program_backend.cpp @@ -113,14 +113,14 @@ void VulkanProgram::finalize_uniforms() const VulkanFunctions &vk = device.get_functions(); const ReflectData &rd = static_cast(this)->reflect_data; - auto i = find_member(rd.uniform_blocks, static_cast(ReflectData::PUSH_CONSTANT), &ReflectData::UniformBlockInfo::bind_point); - const ReflectData::UniformBlockInfo *push_const_block = (i!=rd.uniform_blocks.end() ? &*i : 0); + auto i = find_member(rd.blocks, static_cast(ReflectData::PUSH_CONSTANT), &ReflectData::BlockInfo::bind_point); + const ReflectData::BlockInfo *push_const_block = (i!=rd.blocks.end() ? &*i : 0); desc_set_layout_handles.resize(rd.n_descriptor_sets); for(unsigned j=0; j bindings; - for(const ReflectData::UniformBlockInfo &b: rd.uniform_blocks) + for(const ReflectData::BlockInfo &b: rd.blocks) if(b.bind_point>=0 && static_cast(b.bind_point>>20)==j) { bindings.emplace_back(); diff --git a/source/core/pipelinestate.cpp b/source/core/pipelinestate.cpp index 374f8926..dd5b51a3 100644 --- a/source/core/pipelinestate.cpp +++ b/source/core/pipelinestate.cpp @@ -168,7 +168,7 @@ void PipelineState::check_bound_resources() const if(!shprog) return; - for(const ReflectData::UniformBlockInfo &b: shprog->get_uniform_blocks()) + for(const ReflectData::BlockInfo &b: shprog->get_blocks()) if(b.bind_point!=ReflectData::DEFAULT_BLOCK) { auto i = lower_bound_member(resources, b.bind_point, &PipelineState::BoundResource::binding); diff --git a/source/core/program.cpp b/source/core/program.cpp index fe55fc28..e946a847 100644 --- a/source/core/program.cpp +++ b/source/core/program.cpp @@ -75,15 +75,15 @@ void Program::add_stages(const Module &mod, const map &spec_values) void Program::collect_uniforms(const SpirVModule &mod) { // Prepare the default block - reflect_data.uniform_blocks.emplace_back(); + reflect_data.blocks.emplace_back(); vector > block_uniform_names(1); for(const SpirVModule::Variable &v: mod.get_variables()) { if((v.storage==SpirVModule::UNIFORM || v.storage==SpirVModule::PUSH_CONSTANT) && v.struct_type) { - reflect_data.uniform_blocks.emplace_back(); - ReflectData::UniformBlockInfo &info = reflect_data.uniform_blocks.back(); + reflect_data.blocks.emplace_back(); + ReflectData::BlockInfo &info = reflect_data.blocks.back(); info.tag = info.name = v.struct_type->name; info.data_size = v.struct_type->size; if(v.storage==SpirVModule::PUSH_CONSTANT) @@ -126,13 +126,13 @@ void Program::collect_uniforms(const SpirVModule &mod) if(block_uniform_names.front().empty()) { - reflect_data.uniform_blocks.erase(reflect_data.uniform_blocks.begin()); + reflect_data.blocks.erase(reflect_data.blocks.begin()); block_uniform_names.erase(block_uniform_names.begin()); } - for(unsigned i=0; i(u)->block = &b; @@ -217,10 +217,10 @@ void Program::collect_builtins(const SpirVModule::Structure &strct) reflect_data.n_clip_distances = m.array_size; } -int Program::get_uniform_block_binding(Tag tag) const +int Program::get_block_binding(Tag tag) const { - auto i = lower_bound_member(reflect_data.uniform_blocks, tag, &ReflectData::UniformBlockInfo::tag); - return i!=reflect_data.uniform_blocks.end() && i->tag==tag ? i->bind_point : -1; + auto i = lower_bound_member(reflect_data.blocks, tag, &ReflectData::BlockInfo::tag); + return i!=reflect_data.blocks.end() && i->tag==tag ? i->bind_point : -1; } const ReflectData::UniformInfo &Program::get_uniform_info(Tag tag) const diff --git a/source/core/program.h b/source/core/program.h index 3bc72a78..0f47cb4b 100644 --- a/source/core/program.h +++ b/source/core/program.h @@ -78,14 +78,14 @@ public: ReflectData::LayoutHash get_uniform_layout_hash() const { return reflect_data.layout_hash; } unsigned get_n_descriptor_sets() const { return reflect_data.n_descriptor_sets; } unsigned get_push_constants_size() const { return reflect_data.push_constants_size; } - const std::vector &get_uniform_blocks() const { return reflect_data.uniform_blocks; } - int get_uniform_block_binding(Tag) const; + const std::vector &get_blocks() const { return reflect_data.blocks; } + int get_block_binding(Tag) const; const std::vector &get_uniforms() const { return reflect_data.uniforms; } const ReflectData::UniformInfo &get_uniform_info(Tag) const; int get_uniform_location(const std::string &) const; int get_uniform_location(Tag) const; int get_uniform_binding(Tag) const; - bool uses_uniform_block_binding(int b) const { return uses_binding(b|ReflectData::UNIFORM_BLOCK_BINDING); } + bool uses_block_binding(int b) const { return uses_binding(b|ReflectData::BLOCK_BINDING); } bool uses_texture_binding(unsigned b) const { return uses_binding(b|ReflectData::TEXTURE_BINDING); } private: bool uses_binding(int) const; diff --git a/source/core/reflectdata.cpp b/source/core/reflectdata.cpp index c4c24f7b..db583bf7 100644 --- a/source/core/reflectdata.cpp +++ b/source/core/reflectdata.cpp @@ -10,8 +10,8 @@ namespace GL { void ReflectData::update_layout_hash() { - layout_hash = hash<32>(uniform_blocks.size()); - for(const UniformBlockInfo &b: uniform_blocks) + layout_hash = hash<32>(blocks.size()); + for(const BlockInfo &b: blocks) { layout_hash = hash_update<32>(layout_hash, b.bind_point); layout_hash = hash_update<32>(layout_hash, b.layout_hash); @@ -23,18 +23,18 @@ void ReflectData::update_used_bindings() for(const UniformInfo &u: uniforms) if(u.binding>=0 && is_image(u.type)) used_bindings.push_back(u.binding|TEXTURE_BINDING); - for(const UniformBlockInfo &b: uniform_blocks) - used_bindings.push_back(b.bind_point|UNIFORM_BLOCK_BINDING); + for(const BlockInfo &b: blocks) + used_bindings.push_back(b.bind_point|BLOCK_BINDING); sort(used_bindings); } -void ReflectData::UniformBlockInfo::sort_uniforms() +void ReflectData::BlockInfo::sort_uniforms() { sort(uniforms, [](const UniformInfo *u1, const UniformInfo *u2){ return u1->locationlocation; }); } -void ReflectData::UniformBlockInfo::update_layout_hash() +void ReflectData::BlockInfo::update_layout_hash() { layout_hash = hash<32>(uniforms.size()); for(const UniformInfo *u: uniforms) diff --git a/source/core/reflectdata.h b/source/core/reflectdata.h index 215b01e9..a48dda6d 100644 --- a/source/core/reflectdata.h +++ b/source/core/reflectdata.h @@ -18,17 +18,17 @@ struct ReflectData { DEFAULT_BLOCK = -1, PUSH_CONSTANT = -2, - UNIFORM_BLOCK_BINDING = 0, + BLOCK_BINDING = 0, TEXTURE_BINDING = 0x1000000 }; typedef unsigned LayoutHash; - struct UniformBlockInfo; + struct BlockInfo; struct UniformInfo { std::string name; - const UniformBlockInfo *block = 0; + const BlockInfo *block = 0; union { int location = -1; @@ -42,7 +42,7 @@ struct ReflectData int binding = -1; }; - struct UniformBlockInfo + struct BlockInfo { std::string name; unsigned data_size = 0; @@ -63,7 +63,7 @@ struct ReflectData DataType type = VOID; }; - std::vector uniform_blocks; + std::vector blocks; std::vector uniforms; LayoutHash layout_hash = 0; std::vector attributes; diff --git a/source/core/uniformblock.cpp b/source/core/uniformblock.cpp index 952fd2fd..b4af61a2 100644 --- a/source/core/uniformblock.cpp +++ b/source/core/uniformblock.cpp @@ -7,7 +7,7 @@ using namespace std; namespace Msp { namespace GL { -UniformBlock::UniformBlock(const ReflectData::UniformBlockInfo &info): +UniformBlock::UniformBlock(const ReflectData::BlockInfo &info): UniformBlockBackend(info.bind_point>=0), data(info.data_size) { } diff --git a/source/core/uniformblock.h b/source/core/uniformblock.h index b543049e..c759d852 100644 --- a/source/core/uniformblock.h +++ b/source/core/uniformblock.h @@ -27,7 +27,7 @@ private: std::vector data; public: - UniformBlock(const ReflectData::UniformBlockInfo &); + UniformBlock(const ReflectData::BlockInfo &); virtual std::size_t get_data_size() const { return data.size(); } virtual const void *get_data_pointer() const { return &data[0]; } diff --git a/source/materials/programdata.cpp b/source/materials/programdata.cpp index c641a7df..6be31552 100644 --- a/source/materials/programdata.cpp +++ b/source/materials/programdata.cpp @@ -469,7 +469,7 @@ vector::iterator ProgramData::get_program(const Progr if(i!=programs.end() && i->prog_hash==prog_hash) return i; - const vector &block_infos = prog.get_uniform_blocks(); + const vector &block_infos = prog.get_blocks(); unsigned index = i-programs.begin(); programs.insert(i, 1+block_infos.size(), ProgramBlock(prog_hash)); @@ -482,7 +482,7 @@ vector::iterator ProgramData::get_program(const Progr for(unsigned j=0; j16) @@ -582,7 +582,7 @@ void ProgramData::update_block_uniform_indices(SharedBlock &block, const Reflect } } -void ProgramData::update_block(SharedBlock &block, const ReflectData::UniformBlockInfo &info) const +void ProgramData::update_block(SharedBlock &block, const ReflectData::BlockInfo &info) const { const uint8_t *indices = block.get_uniform_indices(); for(unsigned i=0; i::const_iterator ProgramData::prepare_program(c dirty = 0; } - const vector &block_infos = prog.get_uniform_blocks(); + const vector &block_infos = prog.get_blocks(); if(prog_begin->masks.dirty==ALL_ONES) { @@ -628,7 +628,7 @@ vector::const_iterator ProgramData::prepare_program(c Refresh uniform indices within the program's blocks. */ prog_begin->masks.used = 0; auto j = prog_begin+1; - for(const ReflectData::UniformBlockInfo &b: block_infos) + for(const ReflectData::BlockInfo &b: block_infos) { SharedBlock &shared = blocks[j->block_index]; if(shared.dirty==ALL_ONES) @@ -642,7 +642,7 @@ vector::const_iterator ProgramData::prepare_program(c // Update the contents of all dirty blocks. bool buffered_blocks_updated = false; auto j = prog_begin+1; - for(const ReflectData::UniformBlockInfo &b: block_infos) + for(const ReflectData::BlockInfo &b: block_infos) { SharedBlock &shared = blocks[j->block_index]; if(shared.dirty) diff --git a/source/materials/programdata.h b/source/materials/programdata.h index 6b168efb..f60f712e 100644 --- a/source/materials/programdata.h +++ b/source/materials/programdata.h @@ -253,8 +253,8 @@ private: int find_uniform_index(Tag) const; std::vector::iterator get_program(const Program &) const; void recreate_buffer() const; - void update_block_uniform_indices(SharedBlock &, const ReflectData::UniformBlockInfo &) const; - void update_block(SharedBlock &, const ReflectData::UniformBlockInfo &) const; + void update_block_uniform_indices(SharedBlock &, const ReflectData::BlockInfo &) const; + void update_block(SharedBlock &, const ReflectData::BlockInfo &) const; std::vector::const_iterator prepare_program(const Program &) const; public: -- 2.45.2