Starting render passes.

This commit is contained in:
Ben Vanik 2016-02-18 18:18:13 -08:00
parent 52a6f795f7
commit 1dcc84a472
2 changed files with 37 additions and 0 deletions

View File

@ -37,6 +37,37 @@ VkRenderPass RenderCache::BeginRenderPass(VkCommandBuffer command_buffer,
// Lookup or construct a render pass compatible with our current state. // Lookup or construct a render pass compatible with our current state.
VkRenderPass render_pass = nullptr; VkRenderPass render_pass = nullptr;
// Begin render pass.
VkRenderPassBeginInfo render_pass_begin_info;
render_pass_begin_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
render_pass_begin_info.pNext = nullptr;
render_pass_begin_info.renderPass = render_pass;
// Target framebuffer.
// render_pass_begin_info.framebuffer = current_buffer.framebuffer;
// Render into the entire buffer (or at least tell the API we are doing
// this). In theory it'd be better to clip this to the scissor region, but
// the docs warn anything but the full framebuffer may be slow.
render_pass_begin_info.renderArea.offset.x = 0;
render_pass_begin_info.renderArea.offset.y = 0;
// render_pass_begin_info.renderArea.extent.width = surface_width_;
// render_pass_begin_info.renderArea.extent.height = surface_height_;
// Configure clear color, if clearing.
VkClearValue color_clear_value;
color_clear_value.color.float32[0] = 238 / 255.0f;
color_clear_value.color.float32[1] = 238 / 255.0f;
color_clear_value.color.float32[2] = 238 / 255.0f;
color_clear_value.color.float32[3] = 1.0f;
VkClearValue clear_values[] = {color_clear_value};
render_pass_begin_info.clearValueCount =
static_cast<uint32_t>(xe::countof(clear_values));
render_pass_begin_info.pClearValues = clear_values;
vkCmdBeginRenderPass(command_buffer, &render_pass_begin_info,
VK_SUBPASS_CONTENTS_INLINE);
return render_pass; return render_pass;
} }
@ -44,6 +75,9 @@ void RenderCache::EndRenderPass() {
assert_not_null(current_command_buffer_); assert_not_null(current_command_buffer_);
auto command_buffer = current_command_buffer_; auto command_buffer = current_command_buffer_;
current_command_buffer_ = nullptr; current_command_buffer_ = nullptr;
// End the render pass.
vkCmdEndRenderPass(command_buffer);
} }
void RenderCache::ClearCache() { void RenderCache::ClearCache() {

View File

@ -52,6 +52,9 @@ class RenderCache {
private: private:
RegisterFile* register_file_ = nullptr; RegisterFile* register_file_ = nullptr;
VkDevice device_ = nullptr; VkDevice device_ = nullptr;
// Only valid during a BeginRenderPass/EndRenderPass block.
VkCommandBuffer current_command_buffer_ = nullptr;
}; };
} // namespace vulkan } // namespace vulkan