]> git.tdb.fi Git - libs/gl.git/commitdiff
Print warnings if a required resource is not bound in PipelineState
authorMikko Rasa <tdb@tdb.fi>
Sun, 25 Sep 2022 13:18:01 +0000 (16:18 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sun, 25 Sep 2022 17:21:57 +0000 (20:21 +0300)
source/backends/opengl/pipelinestate_backend.cpp
source/backends/vulkan/pipelinestate_backend.cpp
source/core/pipelinestate.cpp
source/core/pipelinestate.h

index 204e8139f0fc70802aaf3592b68a60779a124bae..da5f495712408926bde3f9445349b383009c819c 100644 (file)
@@ -252,6 +252,11 @@ void OpenGLPipelineState::apply() const
                        glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE);
        }
 
+#ifdef DEBUG
+       if(changes&(PipelineState::SHPROG|PipelineState::RESOURCES))
+               self.check_bound_resources();
+#endif
+
        applied_to = &device;
        dev_state.last_pipeline = this;
        changes = 0;
index f06e2d324a82e9302135b46c49d7401b9c008f4a..5d1139b8762ad8bee543f6aebe2039fce890282a 100644 (file)
@@ -448,6 +448,10 @@ unsigned VulkanPipelineState::fill_descriptor_writes(unsigned index, unsigned fr
                ++write_ptr;
        }
 
+#ifdef DEBUG
+       self.check_bound_resources();
+#endif
+
        return n_writes;
 }
 
index 0769d441a83a3de178f932af44142bf2b81c1f73..6078db5d0aa24d39bfb9fcf0a8ce1187e5215dcf 100644 (file)
@@ -1,7 +1,9 @@
 #include <stdexcept>
 #include <msp/core/algorithm.h>
+#include <msp/io/print.h>
 #include "error.h"
 #include "pipelinestate.h"
+#include "program.h"
 #include "uniformblock.h"
 
 using namespace std;
@@ -137,5 +139,27 @@ void PipelineState::set_blend(const Blend &b)
        set(blend, b, BLEND);
 }
 
+void PipelineState::check_bound_resources() const
+{
+       if(!shprog)
+               return;
+
+       for(const ReflectData::UniformBlockInfo &b: shprog->get_uniform_blocks())
+               if(b.bind_point!=ReflectData::DEFAULT_BLOCK)
+               {
+                       auto i = lower_bound_member(resources, b.bind_point, &PipelineState::BoundResource::binding);
+                       if(i==resources.end() || i->binding!=b.bind_point)
+                               IO::print(IO::cerr, "Warning: No resource present for uniform block binding %d:%d (%s)\n", b.bind_point>>20, b.bind_point&0xFFFFF, b.name);
+               }
+
+       for(const ReflectData::UniformInfo &u: shprog->get_uniforms())
+               if(u.binding>=0 && is_image(u.type))
+               {
+                       auto i = lower_bound_member(resources, u.binding, &PipelineState::BoundResource::binding);
+                       if(i==resources.end() || i->binding!=u.binding)
+                               IO::print(IO::cerr, "Warning: No resource present for texture binding %d:%d (%s)\n", u.binding>>20, u.binding&0xFFFFF, u.name);
+               }
+}
+
 } // namespace GL
 } // namespace Msp
index 5156e0b5e94119826fb1e6cab79fe6b26c9a5b1e..a836c4070b368e4103b80c5ed656cf790d2f15ba 100644 (file)
@@ -120,6 +120,9 @@ public:
        const VertexSetup *get_vertex_setup() const { return vertex_setup; }
        FaceWinding get_front_face() const { return front_face; }
        CullMode get_face_cull() const { return face_cull; }
+
+private:
+       void check_bound_resources() const;
 };
 
 } // namespace GL