Goal is to reduce the number of command buffer flushes by tracking what is happening in the different command queues. This is an initial step towards advanced queue-ing strategies. The new (intermediate) strategy records commands to different command buffers based on what they do. There is a command buffer for data transfers, compute pipelines and graphics pipelines. When a compute command is recorded it ensures that all graphic commands are finished. When a graphic command is recorded it ensures all compute commands are finished. When a graphic or compute command is scheduled all recorded data transfer commands are scheduled as well. Some improvements are expected as multiple compute and data transfers commands can now be scheduled at the same time and don't need to unbind and rebind render passes. Especially when using EEVEE-Next which is compute centric the performance change is visible for the user. Pull Request: https://projects.blender.org/blender/blender/pulls/114104
93 lines
2.3 KiB
C++
93 lines
2.3 KiB
C++
/* SPDX-FileCopyrightText: 2022 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
/** \file
|
|
* \ingroup gpu
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "gpu_context_private.hh"
|
|
|
|
#include "GHOST_Types.h"
|
|
|
|
#include "vk_command_buffers.hh"
|
|
#include "vk_common.hh"
|
|
#include "vk_debug.hh"
|
|
#include "vk_descriptor_pools.hh"
|
|
|
|
namespace blender::gpu {
|
|
class VKFrameBuffer;
|
|
class VKVertexAttributeObject;
|
|
class VKBatch;
|
|
class VKStateManager;
|
|
|
|
class VKContext : public Context, NonCopyable {
|
|
private:
|
|
VKCommandBuffers command_buffers_;
|
|
|
|
VkExtent2D vk_extent_ = {};
|
|
VkFormat swap_chain_format_ = {};
|
|
GPUTexture *surface_texture_ = nullptr;
|
|
void *ghost_context_;
|
|
|
|
public:
|
|
VKContext(void *ghost_window, void *ghost_context);
|
|
virtual ~VKContext();
|
|
|
|
void activate() override;
|
|
void deactivate() override;
|
|
void begin_frame() override;
|
|
void end_frame() override;
|
|
|
|
void flush() override;
|
|
void finish() override;
|
|
|
|
void memory_statistics_get(int *total_mem, int *free_mem) override;
|
|
|
|
void debug_group_begin(const char *, int) override;
|
|
void debug_group_end() override;
|
|
bool debug_capture_begin() override;
|
|
void debug_capture_end() override;
|
|
void *debug_capture_scope_create(const char *name) override;
|
|
bool debug_capture_scope_begin(void *scope) override;
|
|
void debug_capture_scope_end(void *scope) override;
|
|
|
|
bool has_active_framebuffer() const;
|
|
void activate_framebuffer(VKFrameBuffer &framebuffer);
|
|
void deactivate_framebuffer();
|
|
VKFrameBuffer *active_framebuffer_get() const;
|
|
|
|
void bind_compute_pipeline();
|
|
void bind_graphics_pipeline(const GPUPrimType prim_type,
|
|
const VKVertexAttributeObject &vertex_attribute_object);
|
|
void sync_backbuffer();
|
|
|
|
static VKContext *get()
|
|
{
|
|
return static_cast<VKContext *>(Context::get());
|
|
}
|
|
|
|
VKCommandBuffers &command_buffers_get()
|
|
{
|
|
return command_buffers_;
|
|
}
|
|
|
|
VKStateManager &state_manager_get() const;
|
|
|
|
static void swap_buffers_pre_callback(const GHOST_VulkanSwapChainData *data);
|
|
static void swap_buffers_post_callback();
|
|
|
|
private:
|
|
void swap_buffers_pre_handler(const GHOST_VulkanSwapChainData &data);
|
|
void swap_buffers_post_handler();
|
|
};
|
|
|
|
BLI_INLINE bool operator==(const VKContext &a, const VKContext &b)
|
|
{
|
|
return static_cast<const void *>(&a) == static_cast<const void *>(&b);
|
|
}
|
|
|
|
} // namespace blender::gpu
|