depth-prepass #1

Merged
KJ16609 merged 22 commits from depth-prepass into master 2025-12-15 19:59:49 -05:00
2 changed files with 24 additions and 11 deletions
Showing only changes of commit e6371069fb - Show all commits

View File

@@ -76,7 +76,7 @@ namespace fgl::engine
const ImVec2 imgui_size { static_cast< float >( extent.width ), static_cast< float >( extent.height ) };
ImGui::Image( getImGuiDescriptorSet(), imgui_size );
ImGui::Image( getImGuiTexture(), imgui_size );
}
bool Texture::drawImGuiButton( vk::Extent2D extent )
@@ -98,7 +98,7 @@ namespace fgl::engine
const ImVec2 imgui_size { static_cast< float >( extent.width ), static_cast< float >( extent.height ) };
return ImGui::ImageButton( m_name.c_str(), getImGuiDescriptorSet(), imgui_size );
return ImGui::ImageButton( m_name.c_str(), getImGuiTexture(), imgui_size );
}
Texture::Texture( std::tuple< std::vector< std::byte >, int, int, vk::Format, Sampler > tuple ) :
@@ -176,6 +176,23 @@ namespace fgl::engine
return m_image_view->descriptorInfo( vk::ImageLayout::eGeneral );
}
ImTextureRef Texture::createImGuiTexture() const
{
const ImTextureRef ref { m_imgui_set };
return ref;
}
ImTextureRef Texture::getImGuiTexture() const
{
if ( !m_imgui_texture.has_value() )
{
m_imgui_texture = createImGuiTexture();
}
return m_imgui_texture.value();
}
vk::Extent2D Texture::getExtent() const
{
return m_image_view->getExtent();
@@ -208,13 +225,6 @@ namespace fgl::engine
m_imgui_set = ImGui_ImplVulkan_AddTexture( vk_sampler, vk_view, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL );
}
vk::DescriptorSet& Texture::getImGuiDescriptorSet()
{
assert( ready() );
assert( m_imgui_set != VK_NULL_HANDLE );
return m_imgui_set;
}
Texture::Texture( const std::shared_ptr< Image >& image, Sampler&& sampler ) :
m_texture_id( texture_id_pool.getID() ),
m_image( image ),

View File

@@ -61,7 +61,8 @@ namespace fgl::engine
vk::Extent2D m_extent;
//! Descriptor set used for displaying the texture in ImGui
vk::DescriptorSet m_imgui_set { VK_NULL_HANDLE };
mutable vk::DescriptorSet m_imgui_set { VK_NULL_HANDLE };
mutable std::optional< ImTextureRef > m_imgui_texture { std::nullopt };
std::string m_name;
@@ -111,7 +112,9 @@ namespace fgl::engine
const std::string& getName() const { return m_name; }
[[nodiscard]] vk::DescriptorImageInfo getDescriptor() const;
[[nodiscard]] vk::DescriptorSet& getImGuiDescriptorSet();
[[nodiscard]] ImTextureRef createImGuiTexture() const;
// [[nodiscard]] vk::DescriptorSet& getImGuiDescriptorSet();
[[nodiscard]] ImTextureRef getImGuiTexture() const;
[[nodiscard]] vk::Extent2D getExtent() const;