def record_render_commands(): # Render commands recording begin_info = hvk.command_buffer_begin_info() width, height = window.dimensions() render_pass_begin = hvk.render_pass_begin_info( render_pass=render_pass, framebuffer=0, render_area=hvk.rect_2d(0, 0, width, height), clear_values=(hvk.clear_value(color=(0.0, 0.0, 0.0, 1.0)), hvk.clear_value(depth=1.0, stencil=0))) for framebuffer, cmd in zip(framebuffers, cmd_draw): render_pass_begin.framebuffer = framebuffer hvk.begin_command_buffer(api, cmd, begin_info) hvk.begin_render_pass(api, cmd, render_pass_begin, vk.SUBPASS_CONTENTS_INLINE) hvk.bind_pipeline(api, cmd, pipeline, vk.PIPELINE_BIND_POINT_GRAPHICS) hvk.bind_index_buffer(api, cmd, mesh_buffer, mesh_indices['offset'], vk.INDEX_TYPE_UINT16) hvk.bind_vertex_buffers(api, cmd, (mesh_buffer, ), (mesh_positions['offset'], )) hvk.draw_indexed(api, cmd, mesh_indices['count']) hvk.end_render_pass(api, cmd) hvk.end_command_buffer(api, cmd)
def _setup_render_cache(self): rc = self.render_cache width, height = self.engine.info["swapchain_extent"].values() viewport = hvk.viewport(width=width, height=height) scissor = hvk.rect_2d(0, 0, width, height) render_pass_begin = hvk.render_pass_begin_info( render_pass=self.engine.render_target.render_pass, framebuffer=0, render_area=hvk.rect_2d(0, 0, 0, 0), clear_values=(hvk.clear_value(color=(0.15, 0.15, 0.15, 1.0)), hvk.clear_value(depth=1.0, stencil=0))) rc["begin_info"] = hvk.command_buffer_begin_info() rc["viewports"] = (viewport, ) rc["scissors"] = (scissor, ) rc["render_pass_begin_info"] = render_pass_begin rc["render_area_extent"] = render_pass_begin.render_area.extent