From 60a944e783c3a78bffaf41b2364beeb8c8a36516 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 9 Jan 2019 22:39:36 +0100 Subject: [PATCH] glgsg: fix shader inputs not being updated in esoteric case Specifically, this happens if you have a custom ShaderGenerator that assigns shader inputs via the ShaderAttrib. If two objects then both have the auto-shader turned on, and the shader generator generates ShaderAttribs with the same shaders but different inputs, the inputs will not be updated properly for one of the objects. --- panda/src/glstuff/glShaderContext_src.cxx | 9 +++++---- panda/src/glstuff/glShaderContext_src.h | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index ae7a845efc..a2ac21cbc4 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -2042,10 +2042,6 @@ set_state_and_transform(const RenderState *target_rs, target_rs->get_attrib(MaterialAttrib::get_class_slot())) { altered |= Shader::SSD_material; } - if (state_rs->get_attrib(ShaderAttrib::get_class_slot()) != - target_rs->get_attrib(ShaderAttrib::get_class_slot())) { - altered |= Shader::SSD_shaderinputs; - } if (state_rs->get_attrib(FogAttrib::get_class_slot()) != target_rs->get_attrib(FogAttrib::get_class_slot())) { altered |= Shader::SSD_fog; @@ -2069,6 +2065,11 @@ set_state_and_transform(const RenderState *target_rs, _state_rs = target_rs; } + if (_shader_attrib.get_orig() != _glgsg->_target_shader || _shader_attrib.was_deleted()) { + altered |= Shader::SSD_shaderinputs; + _shader_attrib = _glgsg->_target_shader; + } + // Is this the first time this shader is used this frame? int frame_number = ClockObject::get_global_clock()->get_frame_count(); if (frame_number != _frame_number) { diff --git a/panda/src/glstuff/glShaderContext_src.h b/panda/src/glstuff/glShaderContext_src.h index 91130e9224..0ccb99fe90 100644 --- a/panda/src/glstuff/glShaderContext_src.h +++ b/panda/src/glstuff/glShaderContext_src.h @@ -76,6 +76,7 @@ private: CPT(TransformState) _camera_transform; CPT(TransformState) _projection_transform; CPT(ColorAttrib) _color_attrib; + WCPT(ShaderAttrib) _shader_attrib; /* * struct ParamContext { CPT(InternalName) _name; GLint _location; GLsizei