Exemple #1
0
def create_render_resources(recreate=False):
    global drawing_pool, cmd_draw, image_ready, rendering_done, render_fences

    if recreate:
        hvk.destroy_command_pool(api, device, drawing_pool)
        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)

    # Render commands setup
    drawing_pool = hvk.create_command_pool(
        api, device,
        hvk.command_pool_create_info(
            queue_family_index=render_queue.family.index,
            flags=vk.COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT))

    cmd_draw = hvk.allocate_command_buffers(
        api, device,
        hvk.command_buffer_allocate_info(
            command_pool=drawing_pool,
            command_buffer_count=len(swapchain_images)))

    # Render commands synchronisation resources
    info = hvk.semaphore_create_info()
    image_ready = hvk.create_semaphore(api, device, info)
    rendering_done = hvk.create_semaphore(api, device, info)

    info = hvk.fence_create_info(flags=vk.FENCE_CREATE_SIGNALED_BIT)
    render_fences = tuple(
        hvk.create_fence(api, device, info)
        for _ in range(len(swapchain_images)))
Exemple #2
0
    def free(self):
        api, i, d = self.api, self.instance, self.device

        hvk.device_wait_idle(api, d)

        hvk.destroy_command_pool(api, d, self.command_pool)
        hvk.destroy_fence(api, d, self.setup_fence)

        for scene in self.graph:
            scene.free()

        self.compute_runner.free()
        self.renderer.free()
        self.render_target.free()
        self.memory_manager.free()

        hvk.destroy_swapchain(api, d, self.swapchain)
        hvk.destroy_device(api, d)

        hvk.destroy_surface(api, i, self.surface)

        if self.debugger is not None:
            self.debugger.stop()

        if self.debug_ui is not None:
            self.debug_ui.close()

        hvk.destroy_instance(api, i)

        self.window.destroy()
Exemple #3
0
    def free(self):
        engine, api, device = self.ctx
        hvk.destroy_semaphore(api, device, self.image_ready)
        hvk.destroy_semaphore(api, device, self.rendering_done)

        for f in self.render_fences:
            hvk.destroy_fence(api, device, f)

        del self.engine
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()
Exemple #5
0
    def free(self):
        engine, api, device = self.ctx

        for dset_layout in self.descriptor_set_layouts:
            hvk.destroy_descriptor_set_layout(api, device, dset_layout.set_layout)

        hvk.destroy_pipeline_layout(api, device, self.pipeline_layout)
        hvk.destroy_shader_module(api, device, self.module)
        hvk.destroy_fence(api, device, self.fence)

        del self.engine