void VulkanCommands::begin_render_pass(bool clear, const ClearValue *clear_values)
{
- const Framebuffer *target = pipeline_state->get_framebuffer();
- if(!target)
+ framebuffer = pipeline_state->get_framebuffer();
+ if(!framebuffer)
throw invalid_operation("VulkanCommands::begin_render_pass");
const VulkanFunctions &vk = device.get_functions();
device.get_transfer_queue().dispatch_transfers(current_buffer);
bool to_present = false;
- unsigned n_attachments = target->get_format().size();
+ unsigned n_attachments = framebuffer->get_format().size();
for(unsigned i=0; i<n_attachments; ++i)
- if(dynamic_cast<const SwapChainTexture *>(target->VulkanFramebuffer::get_attachment(i)))
+ if(dynamic_cast<const SwapChainTexture *>(framebuffer->VulkanFramebuffer::get_attachment(i)))
to_present = true;
- VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(target->get_format(), clear, !clear_values, to_present);
+ VkRenderPass render_pass = device.get_pipeline_cache().get_render_pass(framebuffer->get_format(), clear, !clear_values, to_present);
- target->refresh();
+ framebuffer->refresh();
VkRenderPassBeginInfo begin_info = { };
begin_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
begin_info.renderPass = handle_cast<::VkRenderPass>(render_pass);
- begin_info.framebuffer = handle_cast<::VkFramebuffer>(target->handle);
+ begin_info.framebuffer = handle_cast<::VkFramebuffer>(framebuffer->handle);
- const Rect *viewport = pipeline_state->get_viewport();
+ viewport = pipeline_state->get_viewport();
if(viewport)
{
begin_info.renderArea.offset.x = viewport->left;
}
else
{
- begin_info.renderArea.extent.width = target->get_width();
- begin_info.renderArea.extent.height = target->get_height();
+ begin_info.renderArea.extent.width = framebuffer->get_width();
+ begin_info.renderArea.extent.height = framebuffer->get_height();
}
VkClearValue vk_clear_values[7];
if(clear_values)
{
unsigned i = 0;
- for(FrameAttachment a: target->get_format())
+ for(FrameAttachment a: framebuffer->get_format())
{
if(get_attach_point(a)==get_attach_point(DEPTH_ATTACHMENT))
vk_clear_values[i].depthStencil.depth = clear_values[i].depth_stencil.depth;
++i;
}
- begin_info.clearValueCount = target->get_format().size();
+ begin_info.clearValueCount = framebuffer->get_format().size();
begin_info.pClearValues = vk_clear_values;
}
const VulkanFunctions &vk = device.get_functions();
vk.CmdEndRenderPass(current_buffer);
- render_pass = 0;
+ framebuffer = 0;
+ viewport = 0;
}
void VulkanCommands::begin_frame(unsigned index)
::VkSemaphore vk_signal_sem = (signal_sem ? handle_cast<::VkSemaphore>(signal_sem->handle) : 0);
VkPipelineStageFlags wait_stages = VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT;
- if(render_pass)
+ if(framebuffer)
end_render_pass();
vk.EndCommandBuffer(current_buffer);
void VulkanCommands::use_pipeline(const PipelineState *ps)
{
- if(!pipeline_state || !ps || ps->get_framebuffer()!=pipeline_state->get_framebuffer() || ps->get_viewport()!=pipeline_state->get_viewport())
- if(render_pass)
+ if(!pipeline_state || !ps || ps->get_framebuffer()!=framebuffer || ps->get_viewport()!=viewport)
+ if(framebuffer)
end_render_pass();
pipeline_state = ps;
void VulkanCommands::clear(const ClearValue *values)
{
- if(render_pass)
+ if(framebuffer)
throw invalid_operation("VulkanCommands::clear");
begin_render_pass(true, values);
const VulkanFunctions &vk = device.get_functions();
- if(!render_pass)
+ if(!framebuffer)
begin_render_pass(false, 0);
pipeline_state->apply(current_buffer);