def clean_resources():
    window.hide()
    hvk.device_wait_idle(api, device)

    hvk.destroy_fence(api, device, staging_fence)
    hvk.destroy_command_pool(api, device, staging_pool)

    hvk.destroy_command_pool(api, device, drawing_pool)

    hvk.destroy_buffer(api, device, mesh_buffer)
    hvk.free_memory(api, device, mesh_memory)

    hvk.destroy_sampler(api, device, texture_sampler)
    hvk.destroy_image_view(api, device, texture_view)
    hvk.destroy_image(api, device, texture_image)
    hvk.free_memory(api, device, texture_image_memory)

    hvk.destroy_descriptor_pool(api, device, descriptor_pool)
    hvk.destroy_buffer(api, device, uniforms_buffer)
    hvk.free_memory(api, device, uniforms_mem)

    hvk.destroy_pipeline(api, device, pipeline)
    hvk.destroy_pipeline_cache(api, device, pipeline_cache)
    hvk.destroy_pipeline_layout(api, device, pipeline_layout)

    for m in shader_modules:
        hvk.destroy_shader_module(api, device, m)

    hvk.destroy_descriptor_set_layout(api, device, descriptor_set_layout)

    for fb in framebuffers:
        hvk.destroy_framebuffer(api, device, fb)

    hvk.destroy_render_pass(api, device, render_pass)

    hvk.destroy_semaphore(api, device, image_ready)
    hvk.destroy_semaphore(api, device, rendering_done)
    for f in render_fences:
        hvk.destroy_fence(api, device, f)

    hvk.destroy_image(api, device, depth_stencil)
    hvk.destroy_image_view(api, device, depth_view)
    hvk.free_memory(api, device, depth_alloc)

    for v in swapchain_image_views:
        hvk.destroy_image_view(api, device, v)

    hvk.destroy_swapchain(api, device, swapchain)
    hvk.destroy_device(api, device)
    hvk.destroy_surface(api, instance, surface)

    debugger.stop()
    hvk.destroy_instance(api, instance)

    window.destroy()
예제 #2
0
    def free(self):
        ctx, api, device = self.ctx
        memory_manager = ctx.memory_manager

        hvk.destroy_image_view(api, device, self.depth_stencil.view)
        hvk.destroy_image(api, device, self.depth_stencil.image)
        memory_manager.free_alloc(self.depth_stencil_alloc)

        for fb in self.framebuffers:
            hvk.destroy_framebuffer(api, device, fb)

        for (_, view) in self.swapchain_images:
            hvk.destroy_image_view(api, device, view)

        hvk.destroy_render_pass(api, device, self.render_pass)
        del self.engine
def create_framebuffers(recreate=False):
    global framebuffers

    if recreate:
        for fb in framebuffers:
            hvk.destroy_framebuffer(api, device, fb)

    width, height = window.dimensions()

    framebuffers = []
    for img in swapchain_image_views:
        framebuffer = hvk.create_framebuffer(
            api, device,
            hvk.framebuffer_create_info(render_pass=render_pass,
                                        width=width,
                                        height=height,
                                        attachments=(img, depth_view)))

        framebuffers.append(framebuffer)
예제 #4
0
    def _setup_framebuffers(self):
        ctx, api, device = self.ctx
        render_pass = self.render_pass
        width, height = ctx.info["swapchain_extent"].values()

        if self.framebuffers is not None:
            for fb in self.framebuffers:
                hvk.destroy_framebuffer(api, device, fb)

        depth_view = self.depth_stencil.view
        framebuffers = []

        for _, color_view in self.swapchain_images:
            framebuffer = hvk.create_framebuffer(
                api, device,
                hvk.framebuffer_create_info(render_pass=render_pass,
                                            width=width,
                                            height=height,
                                            attachments=(color_view,
                                                         depth_view)))

            framebuffers.append(framebuffer)

        self.framebuffers = framebuffers