Fixes up re-present issue

This commit is contained in:
2024-01-25 04:41:55 -05:00
parent 04d795d845
commit 8b5b5cb082
13 changed files with 149 additions and 108 deletions

View File

@@ -86,15 +86,31 @@ namespace fgl::engine
{
for ( std::uint16_t i = 0; i < count; ++i )
{
auto& images = m_attachment_resources.m_images;
auto& image_views = m_attachment_resources.m_image_views;
images.emplace_back( std::make_shared< Image >(
auto& images { m_attachment_resources.m_images };
auto& image_views { m_attachment_resources.m_image_views };
auto& itter { images.emplace_back( std::make_shared< Image >(
extent,
description.format,
usage | vk::ImageUsageFlagBits::eInputAttachment,
inital_layout,
final_layout ) );
image_views.emplace_back( images.back()->getView() );
final_layout ) ) };
image_views.emplace_back( itter->getView() );
}
}
//! Creates a resource that is used across all frames
void createResourceSpread( const std::uint32_t count, vk::Extent2D extent )
{
auto image { std::make_shared< Image >(
extent,
description.format,
usage | vk::ImageUsageFlagBits::eInputAttachment,
inital_layout,
final_layout ) };
for ( std::uint32_t i = 0; i < count; ++i )
{
m_attachment_resources.m_images.emplace_back( image );
m_attachment_resources.m_image_views.emplace_back( image->getView() );
}
}

View File

@@ -26,8 +26,8 @@ target_include_directories(FGLEngine PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/..)
set_target_properties(FGLEngine PROPERTIES COMPILE_FLAGS ${FGL_FLAGS})
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_UPPER_BUILD_TYPE)
if (CMAKE_UPPER_BUILD_TYPE STREQUAL "DEBUG")
target_compile_definitions(FGLEngine PRIVATE ENABLE_IMGUI=1)
else ()
#if (CMAKE_UPPER_BUILD_TYPE STREQUAL "DEBUG")
# target_compile_definitions(FGLEngine PRIVATE ENABLE_IMGUI=1)
#else ()
target_compile_definitions(FGLEngine PRIVATE ENABLE_IMGUI=0)
endif ()
#endif ()

View File

@@ -62,28 +62,26 @@ namespace fgl::engine
constexpr std::uint32_t matrix_default_size { 16_MiB };
constexpr std::uint32_t draw_parameter_default_size { 16_MiB };
std::array< Buffer, SwapChain::MAX_FRAMES_IN_FLIGHT > matrix_info_buffers {
{ { matrix_default_size,
vk::BufferUsageFlagBits::eVertexBuffer,
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible },
{ matrix_default_size,
vk::BufferUsageFlagBits::eVertexBuffer,
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible } }
// Should be in the BAR area
};
std::vector< Buffer > matrix_info_buffers {};
std::array< Buffer, SwapChain::MAX_FRAMES_IN_FLIGHT > draw_parameter_buffers {
{ { draw_parameter_default_size,
vk::BufferUsageFlagBits::eIndirectBuffer,
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible },
{ draw_parameter_default_size,
vk::BufferUsageFlagBits::eIndirectBuffer,
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible } }
};
std::vector< Buffer > draw_parameter_buffers {};
std::array< DescriptorSet, SwapChain::MAX_FRAMES_IN_FLIGHT > global_descriptor_sets {
{ { GlobalDescriptorSet::createLayout() }, { GlobalDescriptorSet::createLayout() } }
};
std::vector< DescriptorSet > global_descriptor_sets {};
for ( int i = 0; i < SwapChain::MAX_FRAMES_IN_FLIGHT; ++i )
{
matrix_info_buffers.emplace_back(
matrix_default_size,
vk::BufferUsageFlagBits::eVertexBuffer,
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible );
draw_parameter_buffers.emplace_back(
draw_parameter_default_size,
vk::BufferUsageFlagBits::eIndirectBuffer,
vk::MemoryPropertyFlagBits::eDeviceLocal | vk::MemoryPropertyFlagBits::eHostVisible );
global_descriptor_sets.emplace_back( GlobalDescriptorSet::createLayout() );
}
for ( std::uint8_t i = 0; i < SwapChain::MAX_FRAMES_IN_FLIGHT; ++i )
{
@@ -125,7 +123,7 @@ namespace fgl::engine
{
ZoneScopedN( "Render" );
//Update
const std::uint8_t frame_index { m_renderer.getFrameIndex() };
const std::uint16_t frame_index { m_renderer.getFrameIndex() };
FrameInfo frame_info { frame_index,
delta_time,
@@ -166,6 +164,10 @@ namespace fgl::engine
ImGui::SameLine();
ImGui::Text( "%.3f ms", 1000.0f / ImGui::GetIO().Framerate );
ImGui::Text( "Frame: " );
ImGui::SameLine();
ImGui::Text( "%i", frame_info.frame_idx );
if ( ImGui::CollapsingHeader( "Camera" ) )
{
ImGui::PushItemWidth( 80 );
@@ -347,8 +349,12 @@ namespace fgl::engine
FrameMark;
}
using namespace std::chrono_literals;
//std::this_thread::sleep_until( new_time + 12ms );
{
ZoneScopedN( "Sleep for sustained fps" );
using namespace std::chrono_literals;
// std::this_thread::sleep_until( new_time + 16.66ms );
std::this_thread::sleep_until( new_time + 16.66ms );
}
}
Device::getInstance().device().waitIdle();

View File

@@ -66,7 +66,7 @@ namespace fgl::engine
struct FrameInfo
{
int frame_idx;
std::uint16_t frame_idx;
float frame_time;
vk::CommandBuffer command_buffer;
Camera& camera;

View File

@@ -103,7 +103,7 @@ namespace fgl::engine
if ( glfwGetKey( window, key_mappings.move_down ) == GLFW_PRESS ) move_dir -= up_dir;
if ( glm::dot( move_dir, move_dir ) > std::numeric_limits< float >::epsilon() )
target.transform.translation += move_speed * dt * glm::normalize( move_dir );
target.transform.translation += ( move_speed * dt ) * glm::normalize( move_dir );
}
} // namespace fgl::engine

View File

@@ -92,9 +92,9 @@ namespace fgl::engine
assert(
attachment.m_image_views.size() == frame_count
&& "Attachment image views must be equal to frame count" );
for ( std::uint16_t i = 0; i < attachment.m_image_views.size(); ++i )
for ( std::uint16_t frame_idx = 0; frame_idx < attachment.m_image_views.size(); ++frame_idx )
{
views[ i ].emplace_back( attachment.m_image_views[ i ] );
views[ frame_idx ].emplace_back( attachment.m_image_views[ frame_idx ] );
}
}

View File

@@ -66,6 +66,7 @@ namespace fgl::engine
void Renderer::recreateSwapchain()
{
ZoneScoped;
std::cout << "Rebuilding swap chain" << std::endl;
auto extent { m_window.getExtent() };
@@ -102,7 +103,10 @@ namespace fgl::engine
vk::CommandBuffer Renderer::beginFrame()
{
assert( !is_frame_started && "Cannot begin frame while frame is already in progress" );
vk::Result result { m_swapchain->acquireNextImage( &current_image_idx ) };
auto [ result, image_idx ] = m_swapchain->acquireNextImage();
current_image_idx = image_idx;
std::cout << "Acquired next image at index: " << current_image_idx << " for frame " << current_frame_idx
<< std::endl;
if ( result == vk::Result::eErrorOutOfDateKHR )
{
@@ -114,11 +118,11 @@ namespace fgl::engine
throw std::runtime_error( "Failed to acquire swap chain image" );
is_frame_started = true;
auto command_buffer { getCurrentCommandbuffer() };
auto& command_buffer { getCurrentCommandbuffer() };
vk::CommandBufferBeginInfo begin_info {};
begin_info.pNext = VK_NULL_HANDLE;
begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
//begin_info.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
begin_info.pInheritanceInfo = VK_NULL_HANDLE;
command_buffer.begin( begin_info );
@@ -128,6 +132,7 @@ namespace fgl::engine
void Renderer::endFrame()
{
ZoneScopedN( "Ending frame" );
assert( is_frame_started && "Cannot call end frame while frame is not in progress" );
auto command_buffer { getCurrentCommandbuffer() };
@@ -135,7 +140,7 @@ namespace fgl::engine
if ( vkEndCommandBuffer( command_buffer ) != VK_SUCCESS )
throw std::runtime_error( "Failed to end recording command buffer" );
const auto result { m_swapchain->submitCommandBuffers( &command_buffer, &current_image_idx ) };
const auto result { m_swapchain->submitCommandBuffers( &command_buffer, current_image_idx ) };
if ( result == vk::Result::eErrorOutOfDateKHR || result == vk::Result::eSuboptimalKHR
|| m_window.wasWindowResized() )
@@ -147,7 +152,7 @@ namespace fgl::engine
throw std::runtime_error( "Failed to submit commmand buffer" );
is_frame_started = false;
current_frame_idx = static_cast< std::uint8_t >( ( current_frame_idx + 1 ) % SwapChain::MAX_FRAMES_IN_FLIGHT );
current_frame_idx = ( current_frame_idx + 1 ) % SwapChain::MAX_FRAMES_IN_FLIGHT;
}
void Renderer::beginSwapchainRendererPass( vk::CommandBuffer buffer )
@@ -185,24 +190,6 @@ namespace fgl::engine
buffer.setScissor( 0, 1, &scissor );
}
void Renderer::nextPass()
{
vk::Viewport viewport {};
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = static_cast< float >( m_swapchain->getSwapChainExtent().width );
viewport.height = static_cast< float >( m_swapchain->getSwapChainExtent().height );
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
vk::Rect2D scissor { { 0, 0 }, m_swapchain->getSwapChainExtent() };
auto buffer = getCurrentCommandbuffer();
buffer.nextSubpass( vk::SubpassContents::eInline );
buffer.setViewport( 0, 1, &viewport );
buffer.setScissor( 0, 1, &scissor );
}
void Renderer::endSwapchainRendererPass( vk::CommandBuffer buffer )
{
assert( is_frame_started && "Cannot call endSwapChainRenderPass if frame is not in progress" );

View File

@@ -16,6 +16,7 @@
//clang-format: off
#include <tracy/TracyVulkan.hpp>
//clang-format: on
namespace fgl::engine
@@ -34,18 +35,18 @@ namespace fgl::engine
void freeCommandBuffers();
void recreateSwapchain();
uint32_t current_image_idx {};
std::uint8_t current_frame_idx { 0 };
uint32_t current_image_idx { std::numeric_limits< std::uint32_t >::max() };
std::uint16_t current_frame_idx { 0 };
bool is_frame_started { false };
public:
DescriptorSet& getGBufferDescriptor( std::uint8_t frame_idx ) const
DescriptorSet& getGBufferDescriptor( std::uint16_t frame_idx ) const
{
return m_swapchain->getGBufferDescriptor( frame_idx );
}
std::uint8_t getFrameIndex() const
std::uint16_t getFrameIndex() const
{
assert( is_frame_started && "Cannot get frame index while frame not in progress" );
return current_frame_idx;
@@ -53,7 +54,7 @@ namespace fgl::engine
bool isFrameInProgress() const { return is_frame_started; }
vk::CommandBuffer getCurrentCommandbuffer() const
vk::CommandBuffer& getCurrentCommandbuffer()
{
assert( is_frame_started && "Cannot get command buffer while frame not in progress" );
return m_command_buffer[ current_frame_idx ];
@@ -82,7 +83,6 @@ namespace fgl::engine
Renderer( Renderer&& other ) = delete;
Renderer( const Renderer& other ) = delete;
Renderer& operator=( const Renderer& other ) = delete;
void nextPass();
};
} // namespace fgl::engine

View File

@@ -39,6 +39,7 @@ namespace fgl::engine
SwapChain::~SwapChain()
{
ZoneScoped;
if ( swapChain != nullptr )
{
vkDestroySwapchainKHR( Device::getInstance().device(), swapChain, nullptr );
@@ -61,34 +62,39 @@ namespace fgl::engine
}
}
vk::Result SwapChain::acquireNextImage( uint32_t* imageIndex )
std::pair< vk::Result, std::uint32_t > SwapChain::acquireNextImage()
{
ZoneScoped;
if ( Device::getInstance()
.device()
.waitForFences( 1, &inFlightFences[ currentFrame ], VK_TRUE, std::numeric_limits< uint64_t >::max() )
!= vk::Result::eSuccess )
throw std::runtime_error( "failed to wait for fences!" );
std::uint32_t image_idx { 0 };
vk::Result result { Device::getInstance().device().acquireNextImageKHR(
swapChain,
std::numeric_limits< uint64_t >::max(),
imageAvailableSemaphores[ currentFrame ], // must be a not signaled semaphore
VK_NULL_HANDLE,
imageIndex ) };
&image_idx ) };
return result;
return { result, image_idx };
}
vk::Result SwapChain::submitCommandBuffers( const vk::CommandBuffer* buffers, uint32_t* imageIndex )
vk::Result SwapChain::submitCommandBuffers( const vk::CommandBuffer* buffers, std::uint32_t imageIndex )
{
if ( imagesInFlight[ *imageIndex ] != VK_NULL_HANDLE )
ZoneScoped;
if ( imagesInFlight[ imageIndex ] != VK_NULL_HANDLE )
{
if ( Device::getInstance().device().waitForFences(
1, &imagesInFlight[ *imageIndex ], VK_TRUE, std::numeric_limits< uint64_t >::max() )
if ( Device::getInstance()
.device()
.waitForFences( 1, &imagesInFlight[ imageIndex ], VK_TRUE, std::numeric_limits< uint64_t >::max() )
!= vk::Result::eSuccess )
throw std::runtime_error( "failed to wait for fences!" );
}
imagesInFlight[ *imageIndex ] = inFlightFences[ currentFrame ];
imagesInFlight[ imageIndex ] = inFlightFences[ currentFrame ];
vk::SubmitInfo submitInfo {};
@@ -135,7 +141,8 @@ namespace fgl::engine
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = swapChains;
presentInfo.pImageIndices = imageIndex;
std::array< std::uint32_t, 1 > indicies { imageIndex };
presentInfo.setImageIndices( indicies );
if ( auto present_result = Device::getInstance().presentQueue().presentKHR( &presentInfo );
present_result != vk::Result::eSuccess )
@@ -152,6 +159,7 @@ namespace fgl::engine
void SwapChain::createSwapChain()
{
ZoneScoped;
SwapChainSupportDetails swapChainSupport { Device::getInstance().getSwapChainSupport() };
vk::SurfaceFormatKHR surfaceFormat { chooseSwapSurfaceFormat( swapChainSupport.formats ) };
@@ -221,6 +229,7 @@ namespace fgl::engine
void SwapChain::createRenderPass()
{
ZoneScoped;
//Present attachment
ColoredPresentAttachment colorAttachment { getSwapChainImageFormat() };
@@ -236,28 +245,17 @@ namespace fgl::engine
ColorAttachment g_buffer_normal { vk::Format::eR16G16B16A16Sfloat };
ColorAttachment g_buffer_albedo { vk::Format::eR8G8B8A8Unorm };
g_buffer_position.createResources( imageCount(), getSwapChainExtent() );
g_buffer_normal.createResources( imageCount(), getSwapChainExtent() );
g_buffer_albedo.createResources( imageCount(), getSwapChainExtent() );
g_buffer_position.createResourceSpread( imageCount(), getSwapChainExtent() );
g_buffer_normal.createResourceSpread( imageCount(), getSwapChainExtent() );
g_buffer_albedo.createResourceSpread( imageCount(), getSwapChainExtent() );
g_buffer_position.setClear( vk::ClearColorValue( std::array< float, 4 > { 0.0f, 0.0f, 0.0f, 0.0f } ) );
g_buffer_normal.setClear( vk::ClearColorValue( std::array< float, 4 > { 0.0f, 0.0f, 0.0f, 0.0f } ) );
g_buffer_albedo.setClear( vk::ClearColorValue( std::array< float, 4 > { 0.0f, 0.0f, 0.0f, 0.0f } ) );
for ( int i = 0; i < imageCount(); ++i )
{
g_buffer_position.m_attachment_resources.m_images[ i ]
->setName( "GBufferPosition: " + std::to_string( i ) );
}
for ( int i = 0; i < imageCount(); ++i )
{
g_buffer_normal.m_attachment_resources.m_images[ i ]->setName( "GBufferNormal: " + std::to_string( i ) );
}
for ( int i = 0; i < imageCount(); ++i )
{
g_buffer_albedo.m_attachment_resources.m_images[ i ]->setName( "GBufferAlbedo: " + std::to_string( i ) );
}
g_buffer_position.m_attachment_resources.m_images[ 0 ]->setName( "GBufferPosition" );
g_buffer_normal.m_attachment_resources.m_images[ 0 ]->setName( "GBufferNormal" );
g_buffer_albedo.m_attachment_resources.m_images[ 0 ]->setName( "GBufferAlbedo" );
RenderPass render_pass {};
@@ -360,15 +358,15 @@ namespace fgl::engine
void SwapChain::createFramebuffers()
{
ZoneScoped;
m_swap_chain_buffers.resize( imageCount() );
for ( uint8_t i = 0; i < imageCount(); i++ )
{
//TODO: Fix image shit. It's dying because the image is being nuked
std::vector< vk::ImageView > attachments { m_render_pass_resources->forFrame( i ) };
//Fill attachments for this frame
const vk::Extent2D swapChainExtent { getSwapChainExtent() };
vk::FramebufferCreateInfo framebufferInfo = {};
vk::FramebufferCreateInfo framebufferInfo {};
framebufferInfo.renderPass = m_render_pass;
framebufferInfo.attachmentCount = static_cast< uint32_t >( attachments.size() );
framebufferInfo.pAttachments = attachments.data();
@@ -388,6 +386,7 @@ namespace fgl::engine
void SwapChain::createSyncObjects()
{
ZoneScoped;
imageAvailableSemaphores.resize( MAX_FRAMES_IN_FLIGHT );
renderFinishedSemaphores.resize( MAX_FRAMES_IN_FLIGHT );
inFlightFences.resize( MAX_FRAMES_IN_FLIGHT );
@@ -415,6 +414,7 @@ namespace fgl::engine
vk::SurfaceFormatKHR SwapChain::chooseSwapSurfaceFormat( const std::vector< vk::SurfaceFormatKHR >&
availableFormats )
{
ZoneScoped;
for ( const auto& availableFormat : availableFormats )
{
if ( availableFormat.format == vk::Format::eB8G8R8A8Srgb
@@ -430,6 +430,7 @@ namespace fgl::engine
vk::PresentModeKHR SwapChain::chooseSwapPresentMode( const std::vector< vk::PresentModeKHR >&
availablePresentModes )
{
ZoneScoped;
for ( const auto& availablePresentMode : availablePresentModes )
{
switch ( availablePresentMode )
@@ -477,6 +478,7 @@ namespace fgl::engine
vk::Extent2D SwapChain::chooseSwapExtent( const vk::SurfaceCapabilitiesKHR& capabilities )
{
ZoneScoped;
if ( capabilities.currentExtent.width != std::numeric_limits< uint32_t >::max() )
{
return capabilities.currentExtent;
@@ -497,6 +499,7 @@ namespace fgl::engine
vk::Format SwapChain::findDepthFormat()
{
ZoneScoped;
return Device::getInstance().findSupportedFormat(
{ vk::Format::eD32Sfloat, vk::Format::eD32SfloatS8Uint, vk::Format::eD24UnormS8Uint },
vk::ImageTiling::eOptimal,

View File

@@ -18,6 +18,12 @@ namespace fgl::engine
class SwapChain
{
public:
static constexpr std::uint16_t MAX_FRAMES_IN_FLIGHT = 2;
private:
vk::Format m_swap_chain_format { vk::Format::eUndefined };
vk::Format m_swap_chain_depth_format { findDepthFormat() };
vk::Extent2D m_swap_chain_extent { 0, 0 };
@@ -52,22 +58,21 @@ namespace fgl::engine
vk::PresentModeKHR chooseSwapPresentMode( const std::vector< vk::PresentModeKHR >& availablePresentModes );
vk::Extent2D chooseSwapExtent( const vk::SurfaceCapabilitiesKHR& capabilities );
std::array< std::unique_ptr< DescriptorSet >, SwapChain::MAX_FRAMES_IN_FLIGHT > m_gbuffer_descriptor_set {};
public:
std::vector< vk::ClearValue > getClearValues() const { return m_clear_values; }
DescriptorSet& getGBufferDescriptor( std::uint8_t frame_idx ) const
DescriptorSet& getGBufferDescriptor( std::uint16_t frame_idx ) const
{
assert( frame_idx < MAX_FRAMES_IN_FLIGHT && "Frame index out of range" );
assert( frame_idx < SwapChain::MAX_FRAMES_IN_FLIGHT && "Frame index out of range" );
assert(
m_gbuffer_descriptor_set.size() == MAX_FRAMES_IN_FLIGHT && "GBuffer descriptor set not initialized" );
m_gbuffer_descriptor_set.size() == SwapChain::MAX_FRAMES_IN_FLIGHT
&& "GBuffer descriptor set not initialized" );
return *m_gbuffer_descriptor_set[ frame_idx ];
}
static constexpr std::uint8_t MAX_FRAMES_IN_FLIGHT = 2;
std::array< std::unique_ptr< DescriptorSet >, MAX_FRAMES_IN_FLIGHT > m_gbuffer_descriptor_set {};
SwapChain( vk::Extent2D windowExtent );
SwapChain( vk::Extent2D windowExtent, std::shared_ptr< SwapChain > previous );
~SwapChain();
@@ -75,14 +80,14 @@ namespace fgl::engine
SwapChain( const SwapChain& ) = delete;
SwapChain& operator=( const SwapChain& ) = delete;
vk::Framebuffer getFrameBuffer( int index ) const
vk::Framebuffer getFrameBuffer( std::uint32_t index ) const
{
return m_swap_chain_buffers[ static_cast< std::size_t >( index ) ];
}
vk::RenderPass getRenderPass() const { return m_render_pass; }
std::uint8_t imageCount() const { return static_cast< std::uint8_t >( m_swap_chain_images.size() ); }
std::uint16_t imageCount() const { return static_cast< std::uint16_t >( m_swap_chain_images.size() ); }
vk::Format getSwapChainImageFormat() const { return m_swap_chain_format; }
@@ -106,8 +111,8 @@ namespace fgl::engine
vk::Format findDepthFormat();
[[nodiscard]] vk::Result acquireNextImage( uint32_t* imageIndex );
[[nodiscard]] vk::Result submitCommandBuffers( const vk::CommandBuffer* buffers, uint32_t* imageIndex );
[[nodiscard]] std::pair< vk::Result, std::uint32_t > acquireNextImage();
[[nodiscard]] vk::Result submitCommandBuffers( const vk::CommandBuffer* buffers, std::uint32_t imageIndex );
};
} // namespace fgl::engine

View File

@@ -105,8 +105,9 @@ namespace fgl::engine
Buffer( vk::DeviceSize memory_size, vk::BufferUsageFlags usage, vk::MemoryPropertyFlags memory_properties );
Buffer( const Buffer& other ) = delete;
Buffer( Buffer&& other ) = delete;
Buffer& operator=( const Buffer& other ) = delete;
Buffer( Buffer&& other ) = default;
Buffer& operator=( Buffer&& other ) = default;
private:

View File

@@ -21,7 +21,30 @@ namespace fgl::engine
DescriptorSet::~DescriptorSet()
{
DescriptorPool::getInstance().deallocSet( m_set );
if ( m_set != VK_NULL_HANDLE ) DescriptorPool::getInstance().deallocSet( m_set );
}
DescriptorSet::DescriptorSet( DescriptorSet&& other ) :
m_infos( std::move( other.m_infos ) ),
descriptor_writes( std::move( other.descriptor_writes ) ),
m_resources( std::move( other.m_resources ) ),
m_layout( std::move( other.m_layout ) ),
m_set( std::move( other.m_set ) ),
m_max_idx( other.m_max_idx )
{
other.m_set = VK_NULL_HANDLE;
}
DescriptorSet& DescriptorSet::operator=( DescriptorSet&& other )
{
m_infos = std::move( other.m_infos );
descriptor_writes = std::move( other.descriptor_writes );
m_resources = std::move( other.m_resources );
m_layout = std::move( other.m_layout );
m_set = std::move( other.m_set );
other.m_set = VK_NULL_HANDLE;
m_max_idx = other.m_max_idx;
return *this;
}
void DescriptorSet::bindUniformBuffer( std::uint32_t binding_idx, BufferSuballocation& buffer )

View File

@@ -49,8 +49,8 @@ namespace fgl::engine
DescriptorSet& operator=( const DescriptorSet& other ) = delete;
//Move
DescriptorSet( DescriptorSet&& other ) = delete;
DescriptorSet& operator=( DescriptorSet&& other ) = delete;
DescriptorSet( DescriptorSet&& other );
DescriptorSet& operator=( DescriptorSet&& other );
void bindImage(
std::uint32_t binding_idx, ImageView& view, vk::ImageLayout layout, vk::Sampler sampler = VK_NULL_HANDLE );