예제 #1
0
def create_pipeline():
    global pipeline, pipeline_cache

    width, height = window.dimensions()

    viewport = hvk.viewport(width=width, height=height)
    render_area = hvk.rect_2d(0, 0, width, height)
    pipeline_info = hvk.graphics_pipeline_create_info(
        stages=stage_infos,
        vertex_input_state=hvk.pipeline_vertex_input_state_create_info(
            vertex_binding_descriptions=vertex_bindings,
            vertex_attribute_descriptions=vertex_attributes),
        input_assembly_state=hvk.pipeline_input_assembly_state_create_info(),
        viewport_state=hvk.pipeline_viewport_state_create_info(
            viewports=(viewport, ), scissors=(render_area, )),
        rasterization_state=hvk.pipeline_rasterization_state_create_info(),
        multisample_state=hvk.pipeline_multisample_state_create_info(),
        depth_stencil_state=hvk.pipeline_depth_stencil_state_create_info(
            depth_test_enable=vk.TRUE,
            depth_write_enable=vk.TRUE,
            depth_compare_op=vk.COMPARE_OP_LESS_OR_EQUAL,
        ),
        color_blend_state=hvk.pipeline_color_blend_state_create_info(
            attachments=(hvk.pipeline_color_blend_attachment_state(), )),
        layout=pipeline_layout,
        render_pass=render_pass)

    pipeline_cache = hvk.create_pipeline_cache(
        api, device, hvk.pipeline_cache_create_info())
    pipeline = hvk.create_graphics_pipelines(api, device, (pipeline_info, ),
                                             pipeline_cache)[0]
예제 #2
0
    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