From a7d624825898daffbcbac26a710d9ee2763b3e10 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 11 Oct 2022 11:50:25 +0300 Subject: [PATCH] Add debug names to some things which didn't have them --- demos/forestpond/source/rain.cpp | 3 ++ demos/forestpond/source/water.cpp | 1 + .../backends/vulkan/framebuffer_backend.cpp | 22 +++++++++++++ source/materials/material.h | 2 +- source/materials/splatmaterial.cpp | 31 +++++++++++++++++++ source/materials/splatmaterial.h | 6 ++++ 6 files changed, 64 insertions(+), 1 deletion(-) diff --git a/demos/forestpond/source/rain.cpp b/demos/forestpond/source/rain.cpp index d02e9ef9..0d82086d 100644 --- a/demos/forestpond/source/rain.cpp +++ b/demos/forestpond/source/rain.cpp @@ -8,6 +8,8 @@ Rain::Rain(DataFile::Collection &resources, unsigned count, const LinAl::Vector< tech(resources.get("rain.tech")), mesh((GL::VERTEX3, GL::TEXCOORD1)) { + mesh.set_debug_name("Rain mesh"); + std::minstd_rand rng; std::uniform_real_distribution 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); } diff --git a/demos/forestpond/source/water.cpp b/demos/forestpond/source/water.cpp index d44e7089..85ee4fd7 100644 --- a/demos/forestpond/source/water.cpp +++ b/demos/forestpond/source/water.cpp @@ -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); diff --git a/source/backends/vulkan/framebuffer_backend.cpp b/source/backends/vulkan/framebuffer_backend.cpp index 93956354..c2ab2dfa 100644 --- a/source/backends/vulkan/framebuffer_backend.cpp +++ b/source/backends/vulkan/framebuffer_backend.cpp @@ -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(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(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(view_handles[i]); + name_info.pObjectName = view_name.c_str(); + vk.SetDebugUtilsObjectName(name_info); + } + + ++i; + } #endif } diff --git a/source/materials/material.h b/source/materials/material.h index 3210c966..3586ad38 100644 --- a/source/materials/material.h +++ b/source/materials/material.h @@ -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 static void register_type(const std::string &); diff --git a/source/materials/splatmaterial.cpp b/source/materials/splatmaterial.cpp index 21abe4ca..a7050e64 100644 --- a/source/materials/splatmaterial.cpp +++ b/source/materials/splatmaterial.cpp @@ -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