From: Mikko Rasa Date: Tue, 28 Sep 2021 13:47:58 +0000 (+0300) Subject: Remove the deprecated texunit-based texture assignments from RenderPass X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=ad3d915bcba61059a9e371dda780670da8dd249b Remove the deprecated texunit-based texture assignments from RenderPass --- diff --git a/source/materials/renderpass.cpp b/source/materials/renderpass.cpp index 43d5803e..63ba695b 100644 --- a/source/materials/renderpass.cpp +++ b/source/materials/renderpass.cpp @@ -93,36 +93,6 @@ Tag RenderPass::get_texture_tag(const string &slot) const return (i!=textures.end() ? i->tag : Tag()); } -void RenderPass::set_texture(unsigned index, const Texture *tex, const Sampler *samp) -{ - if(!shprog) - throw invalid_operation("RenderPass::set_texture"); - - const vector &uniforms = shprog->get_uniforms(); - for(const ReflectData::UniformInfo &u: uniforms) - if(is_image(u.type) && u.binding==static_cast(index)) - return set_texture(u.tag, tex, samp); - - if(shdata) - { - for(Tag t: shdata->get_uniform_tags()) - { - auto j = find_member(uniforms, t, &ReflectData::UniformInfo::tag); - if(j==uniforms.end() || !is_image(j->type)) - continue; - if(const Uniform1i *uni1i = dynamic_cast(shdata->find_uniform(t))) - if(uni1i->get()==static_cast(index)) - return set_texture(t, tex, samp); - } - } -} - -int RenderPass::get_texture_index(const string &n) const -{ - auto i = find_member(textures, n, &TextureSlot::slot_name); - return (shprog && i!=textures.end() ? shprog->get_uniform_binding(i->tag) : -1); -} - void RenderPass::set_face_cull(CullMode fc) { face_cull = fc; @@ -181,11 +151,6 @@ void RenderPass::Loader::init_actions() add("uniforms", &Loader::uniforms); add("uniform_slot", &Loader::uniform_slot); add("uniform_slot", &Loader::uniform_slot2); - - // Deprecated - add("texunit", &Loader::texunit); - add("texunit", &Loader::texture); - add("texunit", &Loader::texunit_named); } void RenderPass::Loader::set_inline_base_name(const string &n) @@ -246,35 +211,6 @@ void RenderPass::Loader::texture(const string &n) load_sub_with(ldr); } -void RenderPass::Loader::texunit(unsigned) -{ - IO::print(IO::cerr, "Warning: specifying textures by unit number is deprecated and may not produce expected results"); - string name; - if(obj.shprog) - { - for(const ReflectData::UniformInfo &u: obj.shprog->get_uniforms()) - if(is_image(u.type) && u.binding>=0) - { - if(!name.empty()) - { - name.clear(); - break; - } - name = u.name; - } - } - - if(name.empty()) - throw runtime_error("Could not determine name for texture"); - - texture(name); -} - -void RenderPass::Loader::texunit_named(unsigned, const string &n) -{ - texture(n); -} - void RenderPass::Loader::uniforms() { if(!obj.shprog || obj.shprog_from_material) diff --git a/source/materials/renderpass.h b/source/materials/renderpass.h index 94cc2ed9..c810e2c7 100644 --- a/source/materials/renderpass.h +++ b/source/materials/renderpass.h @@ -47,8 +47,6 @@ public: void material(const std::string &); void shader(const std::string &); void texture(const std::string &); - void texunit(unsigned); - void texunit_named(unsigned, const std::string &); void uniforms(); void uniform_slot(const std::string &); void uniform_slot2(const std::string &, const std::string &); @@ -105,8 +103,6 @@ public: const std::string &get_material_slot_name() const { return material_slot; } void set_texture(Tag, const Texture *, const Sampler * = 0); Tag get_texture_tag(const std::string &) const; - DEPRECATED void set_texture(unsigned, const Texture *, const Sampler * = 0); - DEPRECATED int get_texture_index(const std::string &) const; void set_face_cull(CullMode); CullMode get_face_cull() const { return face_cull; } void set_receive_shadows(bool);