27 : render_graph(std::make_unique<render_graph::VKCommandBufferWrapper>(), resources)
30 ghost_context_ = ghost_context;
43 if (surface_texture_) {
47 surface_texture_ =
nullptr;
59 GHOST_VulkanSwapChainData swap_chain_data = {};
60 GHOST_GetVulkanSwapChainFormat((GHOST_WindowHandle)
ghost_window_, &swap_chain_data);
66 resource_pool.
reset();
70 const bool reset_framebuffer = swap_chain_format_ != swap_chain_data.format ||
71 vk_extent_.width != swap_chain_data.extent.width ||
72 vk_extent_.height != swap_chain_data.extent.height;
73 if (reset_framebuffer) {
77 if (surface_texture_) {
79 surface_texture_ =
nullptr;
82 swap_chain_data.extent.width,
83 swap_chain_data.extent.height,
96 swap_chain_format_ = swap_chain_data.format;
97 vk_extent_ = swap_chain_data.extent;
101 else (is_background) {
102 discard all orphaned data
114 thread_data_ = std::reference_wrapper<VKThreadData>(thread_data);
130 thread_data_.reset();
166 return thread_data_.value().get().resource_pool_get().descriptor_pools;
171 return thread_data_.value().get().resource_pool_get().descriptor_set;
261 VkPipeline vk_pipeline,
281 descriptor_set.update_descriptor_set(*
this, access_info_);
288 access_info_.
reset();
302 context->swap_buffers_pre_handler(*swap_chain_data);
309 context->swap_buffers_post_handler();
312void VKContext::swap_buffers_pre_handler(
const GHOST_VulkanSwapChainData &swap_chain_data)
319 blit_image.
dst_image = swap_chain_data.image;
320 blit_image.
filter = VK_FILTER_NEAREST;
322 VkImageBlit ®ion = blit_image.
region;
323 region.srcOffsets[0] = {0, color_attachment->
height_get() - 1, 0};
324 region.srcOffsets[1] = {color_attachment->
width_get(), 0, 1};
325 region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
326 region.srcSubresource.mipLevel = 0;
327 region.srcSubresource.baseArrayLayer = 0;
328 region.srcSubresource.layerCount = 1;
330 region.dstOffsets[0] = {0, 0, 0};
331 region.dstOffsets[1] = {
332 int32_t(swap_chain_data.extent.width),
int32_t(swap_chain_data.extent.height), 1};
333 region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
334 region.dstSubresource.mipLevel = 0;
335 region.dstSubresource.baseArrayLayer = 0;
336 region.dstSubresource.layerCount = 1;
344 VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
353 device.resources.remove_image(swap_chain_data.image);
355 device.debug_print();
359void VKContext::swap_buffers_post_handler()
GHOST C-API function and type declarations.
#define GPU_ATTACHMENT_TEXTURE(_texture)
GPUTexture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, eGPUTextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_texture_free(GPUTexture *texture)
@ GPU_TEXTURE_USAGE_ATTACHMENT
StateManager * state_manager
ShaderCompiler * compiler
void attachment_remove(GPUAttachmentType type)
virtual void bind(bool enabled_srgb)=0
GPUTexture * color_tex(int slot) const
void attachment_set(GPUAttachmentType type, const GPUAttachment &new_attachment)
VKShaderCompiler shader_compiler
void debug_unbind_all_ssbo() override
render_graph::VKResourceAccessInfo & reset_and_get_access_info()
render_graph::VKRenderGraph render_graph
void deactivate_framebuffer()
void deactivate() override
void memory_statistics_get(int *r_total_mem_kb, int *r_free_mem_kb) override
static void swap_buffers_post_callback()
VKFrameBuffer * active_framebuffer_get() const
bool has_active_framebuffer() const
void flush_render_graph()
void debug_unbind_all_ubo() override
static void swap_buffers_pre_callback(const GHOST_VulkanSwapChainData *data)
void activate_framebuffer(VKFrameBuffer &framebuffer)
VKStateManager & state_manager_get() const
VKDescriptorSetTracker & descriptor_set_get()
void update_pipeline_data(render_graph::VKPipelineData &r_pipeline_data)
VKContext(void *ghost_window, void *ghost_context, render_graph::VKResourceStateTracker &resources)
void begin_frame() override
VKDescriptorPools & descriptor_pools_get()
void end_frame() override
void upload_descriptor_sets()
render_graph::VKResourceStateTracker resources
VKDiscardPool orphaned_data
VKThreadData & current_thread_data()
void context_unregister(VKContext &context)
void memory_statistics_get(int *r_total_mem_kb, int *r_free_mem_kb) const
void move_data(VKDiscardPool &src_pool)
void destroy_discarded_resources(VKDevice &device)
bool is_rendering() const
void rendering_end(VKContext &context)
const void * data() const
VKDiscardPool discard_pool
const VKPushConstants::Layout & push_constants_layout_get() const
VKPushConstants push_constants
bool has_descriptor_set() const
VkPipelineLayout vk_pipeline_layout
VkPipeline ensure_and_get_compute_pipeline()
VkPipeline ensure_and_get_graphics_pipeline(GPUPrimType primitive, VKVertexAttributeObject &vao, VKStateManager &state_manager, VKFrameBuffer &framebuffer)
const VKShaderInterface & interface_get() const
void storage_buffer_unbind_all()
void uniform_buffer_unbind_all()
VkImage vk_image_handle() const
uint32_t resource_pool_index
VKResourcePool & resource_pool_get()
void submit_for_present(VkImage vk_swapchain_image)
void add_image(VkImage vk_image, uint32_t layer_count, VkImageLayout vk_image_layout, ResourceOwner owner, const char *name=nullptr)
@ GPU_FB_COLOR_ATTACHMENT0
static Context * unwrap(GPUContext *ctx)
eGPUTextureFormat to_gpu_format(const VkFormat format)
bool assign_if_different(T &old_value, T new_value)
uint32_t size_in_bytes() const
StorageType storage_type_get() const
const void * push_constants_data
VkPipelineLayout vk_pipeline_layout
VkDescriptorSet vk_descriptor_set
uint32_t push_constants_size