]> git.tdb.fi Git - libs/gl.git/commitdiff
Add debug names to some things which didn't have them
authorMikko Rasa <tdb@tdb.fi>
Tue, 11 Oct 2022 08:50:25 +0000 (11:50 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 11 Oct 2022 08:51:18 +0000 (11:51 +0300)
demos/forestpond/source/rain.cpp
demos/forestpond/source/water.cpp
source/backends/vulkan/framebuffer_backend.cpp
source/materials/material.h
source/materials/splatmaterial.cpp
source/materials/splatmaterial.h

index d02e9ef9ecba8f4ab1ba49b7e435335525c7802c..0d82086d6a7bbc3f6b4ede9a2e791830c570bbcb 100644 (file)
@@ -8,6 +8,8 @@ Rain::Rain(DataFile::Collection &resources, unsigned count, const LinAl::Vector<
        tech(resources.get<GL::Technique>("rain.tech")),
        mesh((GL::VERTEX3, GL::TEXCOORD1))
 {
+       mesh.set_debug_name("Rain mesh");
+
        std::minstd_rand rng;
        std::uniform_real_distribution<float> dist(0.0f, 1.0f);
        GL::MeshBuilder bld(mesh);
@@ -24,6 +26,7 @@ Rain::Rain(DataFile::Collection &resources, unsigned count, const LinAl::Vector<
        }
        bld.end();
 
+       shdata.set_debug_name("Rain params");
        shdata.uniform("time", 0.0f);
 }
 
index d44e70891a0f42c8c58a93889d366a26f1314d81..85ee4fd7fe7187ed99bd1ba3a3e38ffcb664371f 100644 (file)
@@ -28,6 +28,7 @@ Water::Water(const GL::Object &o, DataFile::Collection &resources, const Region
        sim_shdata.uniform("max_flow_fraction", 0.9999f);
        sim_shdata.uniform("residual_depth", 0.01f);
 
+       shdata.set_debug_name("Water params");
        shdata.uniform("Region.scale", 1.0f/(region.right-region.left), 1.0f/(region.top-region.bottom));
        shdata.uniform("Region.offset", -region.left/(region.right-region.left), -region.bottom/(region.top-region.bottom));
        shdata.uniform("Region.amplitude", 0.01f);
index 9395635476025473e182653becb57316737006ed..c2ab2dfafa3ba0de3f5c838c52aebf0631ff01c8 100644 (file)
@@ -172,6 +172,7 @@ void VulkanFramebuffer::set_debug_name(const string &name)
 void VulkanFramebuffer::set_vulkan_object_name() const
 {
 #ifdef DEBUG
+       const Framebuffer &self = *static_cast<const Framebuffer *>(this);
        const VulkanFunctions &vk = device.get_functions();
 
        VkDebugUtilsObjectNameInfoEXT name_info = { };
@@ -180,6 +181,27 @@ void VulkanFramebuffer::set_vulkan_object_name() const
        name_info.objectHandle = reinterpret_cast<uint64_t>(handle);
        name_info.pObjectName = debug_name.c_str();
        vk.SetDebugUtilsObjectName(name_info);
+
+       name_info.objectType = VK_OBJECT_TYPE_IMAGE_VIEW;
+       unsigned i=0;
+       for(FrameAttachment a: self.format)
+       {
+               if(view_handles[i])
+               {
+                       string view_name;
+                       if(get_attach_point(a)==get_attach_point(DEPTH_ATTACHMENT))
+                               view_name = debug_name+": depth.view";
+                       else if(get_attach_point(a)==get_attach_point(STENCIL_ATTACHMENT))
+                               view_name = debug_name+": stencil.view";
+                       else
+                               view_name = format("%s: color%d.view", debug_name, i);
+                       name_info.objectHandle = reinterpret_cast<uint64_t>(view_handles[i]);
+                       name_info.pObjectName = view_name.c_str();
+                       vk.SetDebugUtilsObjectName(name_info);
+               }
+
+               ++i;
+       }
 #endif
 }
 
index 3210c96612fcfc2739d7fb99134f086c0c3761f9..3586ad38208ec03222add65aa9af0e612d36f8bc 100644 (file)
@@ -105,7 +105,7 @@ public:
        float get_alpha_cutoff() const { return alpha_cutoff; }
        float get_alpha_feather() const { return alpha_feather; }
 
-       void set_debug_name(const std::string &);
+       virtual void set_debug_name(const std::string &);
 
        template<typename T>
        static void register_type(const std::string &);
index 21abe4cab1e5c85d3c128226e3467a425e141a4e..a7050e64df3df8d7eb1965db5e1a1da694111349 100644 (file)
@@ -144,6 +144,33 @@ void SplatMaterial::upload_sub_map(DataFile::Collection &coll, unsigned index, S
        shdata.uniform(format("splat_materials[%d].%s_layer", index, name), sub.layer);
 }
 
+void SplatMaterial::set_debug_name(const string &name)
+{
+       Material::set_debug_name(name);
+#ifdef DEBUG
+       debug_name = name;
+       set_array_debug_names();
+#endif
+}
+
+void SplatMaterial::set_array_debug_names()
+{
+#ifdef DEBUG
+       if(base_color_array.texture)
+               base_color_array.texture->set_debug_name(debug_name+": base_color.tex");
+       if(normal_array.texture)
+               normal_array.texture->set_debug_name(debug_name+": normal.tex");
+       if(metalness_array.texture)
+               metalness_array.texture->set_debug_name(debug_name+": metalness.tex");
+       if(roughness_array.texture)
+               roughness_array.texture->set_debug_name(debug_name+": roughness.tex");
+       if(occlusion_array.texture)
+               occlusion_array.texture->set_debug_name(debug_name+": occlusion.tex");
+       if(emission_array.texture)
+               emission_array.texture->set_debug_name(debug_name+": emission.tex");
+#endif
+}
+
 
 void SplatMaterial::MapArray::create()
 {
@@ -183,6 +210,10 @@ void SplatMaterial::Loader::finish()
        obj.roughness_array.create();
        obj.occlusion_array.create();
        obj.emission_array.create();
+#ifdef DEBUG
+       if(!obj.debug_name.empty())
+               obj.set_array_debug_names();
+#endif
 
        DataFile::Collection &c = get_collection();
        for(unsigned i=0; i<obj.sub_materials.size(); ++i)
index a9dafdbf702627d8315454909240ccf40db3c6c1..e929dac27a07ffea85fc20d07528f1a4f6de94d3 100644 (file)
@@ -90,6 +90,7 @@ private:
        MapArray emission_array;
        const Texture2D &fresnel_lookup;
        const Sampler &fresnel_sampler;
+       std::string debug_name;
 
        static const Tag texture_tags[];
 
@@ -109,6 +110,11 @@ private:
        void set_sub_uniforms(unsigned);
        void upload_sub(DataFile::Collection &, unsigned);
        void upload_sub_map(DataFile::Collection &, unsigned, SubMap SubMaterial::*, MapArray &, const char *);
+
+public:
+       virtual void set_debug_name(const std::string &);
+private:
+       void set_array_debug_names();
 };
 
 } // namespace GL