Blender V5.3
vk_context.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "DNA_userdef_types.h"
10
11#include "GPU_debug.hh"
12
14
15#include "vk_backend.hh"
16#include "vk_context.hh"
17#include "vk_debug.hh"
18#include "vk_framebuffer.hh"
19#include "vk_immediate.hh"
20#include "vk_shader.hh"
22#include "vk_state_manager.hh"
23#include "vk_texture.hh"
25
26namespace blender::gpu {
27
29 : push_constants_pool(VKBufferPool("PushConstants",
30 64 * 1024,
31 VKBackend::get()
32 .device.physical_device_properties_get()
33 .limits.minUniformBufferOffsetAlignment,
34 VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
35 VMA_MEMORY_USAGE_AUTO_PREFER_HOST,
36 VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
37 0.8f))
38{
39 ghost_window_ = ghost_window;
40 ghost_context_ = ghost_context;
41
43 imm = new VKImmediate();
44
45 back_left = new VKFrameBuffer("back_left");
46 front_left = new VKFrameBuffer("front_left");
48}
49
51{
52 if (surface_texture_) {
55 GPU_texture_free(surface_texture_);
56 surface_texture_ = nullptr;
57 }
59 delete imm;
60 imm = nullptr;
61 VKDevice &device = VKBackend::get().device;
62 device.context_unregister(*this);
63
64 this->process_frame_timings();
65}
66
68{
69 if (ghost_window_) {
70 GHOST_VulkanSwapChainData swap_chain_data = {};
71 ghost_window_->getVulkanSwapChainFormat(&swap_chain_data);
72
73 const bool reset_framebuffer = swap_chain_format_.format !=
74 swap_chain_data.surface_format.format ||
75 swap_chain_format_.colorSpace !=
76 swap_chain_data.surface_format.colorSpace ||
77 vk_extent_.width != swap_chain_data.extent.width ||
78 vk_extent_.height != swap_chain_data.extent.height;
79 if (reset_framebuffer) {
82 }
83 if (surface_texture_) {
84 GPU_texture_free(surface_texture_);
85 surface_texture_ = nullptr;
86 }
87 vk_extent_ = swap_chain_data.extent;
88 vk_extent_.width = max_uu(vk_extent_.width, 1u);
89 vk_extent_.height = max_uu(vk_extent_.height, 1u);
90 surface_texture_ = GPU_texture_create_2d(
91 "back-left",
92 vk_extent_.width,
93 vk_extent_.height,
94 1,
95 to_gpu_format(swap_chain_data.surface_format.format),
97 nullptr);
98
100 GPU_ATTACHMENT_TEXTURE(surface_texture_));
102 GPU_ATTACHMENT_TEXTURE(surface_texture_));
103
104 back_left->bind(false);
105
106 swap_chain_format_ = swap_chain_data.surface_format;
107 GCaps.hdr_viewport_support = (swap_chain_format_.format == VK_FORMAT_R16G16B16A16_SFLOAT) &&
108 ELEM(swap_chain_format_.colorSpace,
109 VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT,
110 VK_COLOR_SPACE_PASS_THROUGH_EXT);
111 }
112 }
113}
114
116{
117 /* Make sure no other context is already bound to this thread. */
118 BLI_assert(is_active_ == false);
119 /* Make sure the active GHOST context matches the one this GPU Context was created for. */
121
122 VKDevice &device = VKBackend::get().device;
123 VKThreadData &thread_data = device.current_thread_data();
124 thread_data_ = std::reference_wrapper<VKThreadData>(thread_data);
125
126 if (!render_graph_.has_value()) {
127 render_graph_ = std::reference_wrapper<render_graph::VKRenderGraph>(
128 *device.render_graph_new());
129 /* Recreate the debug group stack for the new graph.
130 * Note: there is no associated `debug_group_end` as the graph groups
131 * are implicitly closed on submission. */
132 for (const StringRef &group : debug_stack) {
133 std::string str_group = group;
134 render_graph_.value().get().debug_group_begin(str_group.c_str(),
135 debug::get_debug_group_color(str_group));
136 }
137 }
138
139 is_active_ = true;
140
142
143 immActivate();
144}
145
147{
150 thread_data_.reset();
151
152 is_active_ = false;
153}
154
156
158{
159 this->process_frame_timings();
160}
161
163{
164 /* Submit when flushing to avoid out-of-memory errors and TDRs when more and more commands are
165 * added in background mode without ever submitting work to the GPU. */
167}
168
170 VkPipelineStageFlags wait_dst_stage_mask,
171 VkSemaphore wait_semaphore,
172 VkSemaphore signal_semaphore,
173 VkFence signal_fence)
174{
176 VKFrameBuffer &framebuffer = *active_framebuffer_get();
177 if (framebuffer.is_rendering()) {
178 framebuffer.rendering_end(*this);
179 }
180 }
181 VKDevice &device = VKBackend::get().device;
185 TimelineValue timeline = device.render_graph_submit(
186 &render_graph_.value().get(),
188 bool(flags & RenderGraphFlushFlags::SUBMIT),
191 wait_dst_stage_mask,
192 wait_semaphore,
193 signal_semaphore,
194 signal_fence);
195 render_graph_.reset();
196 streaming_buffers_.clear();
198 render_graph_ = std::reference_wrapper<render_graph::VKRenderGraph>(
199 *device.render_graph_new());
200 /* Recreate the debug group stack for the new graph.
201 * Note: there is no associated `debug_group_end` as the graph groups
202 * are implicitly closed on submission. */
203 for (const StringRef &group : debug_stack) {
204 std::string str_group = group;
205 render_graph_.value().get().debug_group_begin(str_group.c_str(),
206 debug::get_debug_group_color(str_group));
207 }
208 }
209 return timeline;
210}
211
217
218void VKContext::memory_statistics_get(int *r_total_mem_kb, int *r_free_mem_kb)
219{
220 const VKDevice &device = VKBackend::get().device;
221 device.memory_statistics_get(r_total_mem_kb, r_free_mem_kb);
222}
223
224/* -------------------------------------------------------------------- */
227
229{
230 return thread_data_.value().get().descriptor_pools;
231}
232
234{
235 return thread_data_.value().get().descriptor_set;
236}
237
239{
240 return *static_cast<VKStateManager *>(state_manager);
241}
242
247
252
254
255/* -------------------------------------------------------------------- */
258
260{
263 }
264
265 BLI_assert(active_fb == nullptr);
266 active_fb = &framebuffer;
267 framebuffer.update_size();
268 framebuffer.update_srgb();
269 framebuffer.rendering_reset();
270}
271
276
278{
279 return active_framebuffer_get() != nullptr;
280}
281
283{
284 VKFrameBuffer *framebuffer = active_framebuffer_get();
285 BLI_assert(framebuffer != nullptr);
286 if (framebuffer->is_rendering()) {
287 framebuffer->rendering_end(*this);
288 }
289 active_fb = nullptr;
290}
291
293{
294 VKFrameBuffer *framebuffer = active_framebuffer_get();
295 if (framebuffer) {
296 framebuffer->rendering_end(*this);
297 }
298}
299
301
302/* -------------------------------------------------------------------- */
305
307 GPUPrimType primitive,
308 VKVertexInputDescriptionPool::Key vertex_input_key,
310{
311 VKShader &vk_shader = unwrap(*shader);
313
314 /* Disable non-vulkan state flags to reduce unneeded pipeline compilation. */
315 state_manager.state.clip_control = 0;
316
317 framebuffer.vk_viewports_append(r_pipeline_data.viewport.viewports);
318 framebuffer.vk_render_areas_append(r_pipeline_data.viewport.scissors);
319
320 /* Override size of point shader when GPU_point size < 0 */
321 const float point_size = state_manager.mutable_state.point_size;
322 if (primitive == GPU_PRIM_POINTS && point_size < 0.0) {
324 }
325
326 VKDevice &device = VKBackend::get().device;
327 const VKExtensions &extensions = device.extensions_get();
328
329 /* Dynamic state line width */
330 const bool is_line_primitive = ELEM(primitive,
336 if (is_line_primitive) {
337 r_pipeline_data.line_width = extensions.wide_lines ? state_manager.mutable_state.line_width :
338 1.0f;
339 }
340 else {
341 r_pipeline_data.line_width.reset();
342 }
343
344 /* Dynamic state stencil state */
345 if (framebuffer.stencil_attachment_format_get() != VK_FORMAT_UNDEFINED &&
346 state_manager.state.stencil_test != GPU_STENCIL_NONE)
347 {
348 r_pipeline_data.stencil_state = {state_manager.mutable_state.stencil_compare_mask,
349 state_manager.mutable_state.stencil_reference,
350 state_manager.mutable_state.stencil_write_mask};
351 }
352 else {
353 r_pipeline_data.stencil_state.reset();
354 }
355
356 /* VK_EXT_extended_dynamic_state */
357 if (extensions.extended_dynamic_state) {
358 r_pipeline_data.front_face = state_manager.state.invert_facing ?
359 VK_FRONT_FACE_COUNTER_CLOCKWISE :
360 VK_FRONT_FACE_CLOCKWISE;
361 }
362
363 if (extensions.vertex_input_dynamic_state) {
364 r_pipeline_data.vertex_input_description = vertex_input_key;
365 }
366
368 vk_shader,
370 primitive, vertex_input_key, state_manager, framebuffer, constants_state_),
371 r_pipeline_data.pipeline_data);
372}
373
375{
376 VKShader &vk_shader = unwrap(*shader);
378 vk_shader, vk_shader.ensure_and_get_compute_pipeline(constants_state_), r_pipeline_data);
379}
380
382 VkPipeline vk_pipeline,
383 render_graph::VKPipelineData &r_pipeline_data)
384{
385 r_pipeline_data.vk_pipeline_layout = vk_shader.vk_pipeline_layout;
386 r_pipeline_data.vk_pipeline = vk_pipeline;
387
388 /* Update push constants. */
390 const VKPushConstants::Layout &push_constants_layout =
392 if (push_constants_layout.storage_type_get() == VKPushConstants::StorageType::PUSH_CONSTANTS) {
393 r_pipeline_data.push_constants_range = render_graph().copy_push_constants(
394 Span<uint8_t>(static_cast<const uint8_t *>(vk_shader.push_constants.data()),
395 push_constants_layout.size_in_bytes()));
396 }
397
398 /* Update descriptor set. */
399 r_pipeline_data.vk_descriptor_set = VK_NULL_HANDLE;
400 if (vk_shader.has_descriptor_set()) {
401 VKDescriptorSetTracker &descriptor_set = descriptor_set_get();
402 descriptor_set.update_descriptor_set(*this, access_info_, r_pipeline_data);
403 }
404}
405
407{
408 access_info_.reset();
409 return access_info_;
410}
411
413
414/* -------------------------------------------------------------------- */
417
419{
420 VKContext *context = VKContext::get();
421 BLI_assert(context);
422 context->swap_buffer_acquired_handler();
423}
424
425void VKContext::swap_buffer_draw_callback(const GHOST_VulkanSwapChainData *swap_chain_data,
426 bool wait_for_submission)
427{
428 VKContext *context = VKContext::get();
429 BLI_assert(context);
430 context->swap_buffer_draw_handler(*swap_chain_data, wait_for_submission);
431}
432
433void VKContext::swap_buffer_acquired_handler()
434{
436}
437
438void VKContext::swap_buffer_draw_handler(const GHOST_VulkanSwapChainData &swap_chain_data,
439 bool wait_for_submission)
440{
441 const bool do_blit_to_swapchain = swap_chain_data.image != VK_NULL_HANDLE;
442 const bool use_shader = ELEM(swap_chain_data.surface_format.colorSpace,
443 VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT,
444 VK_COLOR_SPACE_PASS_THROUGH_EXT);
445
446 /* When swapchain is invalid/minimized we only flush the render graph to free GPU resources. */
447 if (!do_blit_to_swapchain) {
449 return;
450 }
451
452 VKDevice &device = VKBackend::get().device;
453 render_graph::VKRenderGraph &render_graph = this->render_graph();
454 VKFrameBuffer &framebuffer = *unwrap(active_fb);
455 framebuffer.rendering_end(*this);
456 VKTexture *color_attachment = unwrap(unwrap(framebuffer.color_tex(0)));
457 ResourceHandle resource_handle = device.resources.add_swapchain_image(swap_chain_data.image,
458 "SwapchainImage");
459
460 GPU_debug_group_begin("BackBuffer.Blit");
461 if (use_shader) {
462 VKTexture swap_chain_texture("swap_chain_texture");
463 swap_chain_texture.init_swapchain(swap_chain_data.image,
464 resource_handle,
465 to_gpu_format(swap_chain_data.surface_format.format));
466 Shader *shader = device.vk_backbuffer_blit_sh_get();
468 GPU_shader_uniform_1f(shader, "sdr_scale", swap_chain_data.sdr_scale);
469 VKStateManager &state_manager = state_manager_get();
470 state_manager.image_bind(color_attachment, 0);
471 state_manager.image_bind(&swap_chain_texture, 1);
472 int2 dispatch_size = math::divide_ceil(
473 int2(swap_chain_data.extent.width, swap_chain_data.extent.height), int2(16));
474 VKBackend::get().compute_dispatch(UNPACK2(dispatch_size), 1);
475 }
476 else {
478 blit_image.src_image = color_attachment->vk_image_handle();
479 blit_image.dst_image = swap_chain_data.image;
480 blit_image.filter = VK_FILTER_LINEAR;
481
482 VkImageBlit &region = blit_image.region;
483 region.srcOffsets[0] = {0, 0, 0};
484 region.srcOffsets[1] = {color_attachment->width_get(), color_attachment->height_get(), 1};
485 region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
486 region.srcSubresource.mipLevel = 0;
487 region.srcSubresource.baseArrayLayer = 0;
488 region.srcSubresource.layerCount = 1;
489
490 region.dstOffsets[0] = {0, int32_t(swap_chain_data.extent.height), 0};
491 region.dstOffsets[1] = {int32_t(swap_chain_data.extent.width), 0, 1};
492 region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
493 region.dstSubresource.mipLevel = 0;
494 region.dstSubresource.baseArrayLayer = 0;
495 region.dstSubresource.layerCount = 1;
496
497 render_graph.add_node(blit_image);
498 }
499
501 synchronization.vk_image = swap_chain_data.image;
502 synchronization.vk_image_layout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
503 synchronization.vk_image_aspect = VK_IMAGE_ASPECT_COLOR_BIT;
504 synchronization.vk_access_flags = VK_ACCESS_NONE;
505 render_graph.add_node(synchronization);
507
508 wait_for_submission |= swap_chain_data.submission_fence != VK_NULL_HANDLE;
510 (wait_for_submission ? RenderGraphFlushFlags::WAIT_FOR_SUBMISSION :
512 VK_PIPELINE_STAGE_TRANSFER_BIT,
513 swap_chain_data.acquire_semaphore,
514 swap_chain_data.present_semaphore,
515 swap_chain_data.submission_fence);
516 /* Discard/remove not owning swapchain handlers.
517 * During a regular swapchain update, NVIDIA can use the same image multiple times in a row.
518 * Placing these images in the discard pool results in incorrect state, best to remove them
519 * directly. */
520 if (wait_for_submission) {
521 /* The image is removed directly, but its views are still referenced by the submitted
522 * commands; discard them timeline-safely. */
523 for (const std::variant<VkImageView, VkBufferView> &view :
524 device.resources.take_views(resource_handle))
525 {
526 discard_pool.discard_image_view(std::get<VkImageView>(view));
527 }
528 device.resources.remove_swapchain_image(resource_handle);
529 }
530 else {
531 discard_pool.discard_swapchain_image(resource_handle);
532 }
533#if 0
534 device.debug_print();
535#endif
536}
537
539 const shader::SpecializationConstants *constants_state)
540{
541 constants_state_ = (constants_state != nullptr) ? *constants_state :
543}
544
545std::unique_ptr<VKStreamingBuffer> &VKContext::get_or_create_streaming_buffer(
546 VKBuffer &buffer, VkDeviceSize min_offset_alignment)
547{
548 for (std::unique_ptr<VKStreamingBuffer> &streaming_buffer : streaming_buffers_) {
549 if (streaming_buffer->vk_buffer_dst() == buffer.vk_handle()) {
550 return streaming_buffer;
551 }
552 }
553
554 streaming_buffers_.append(std::make_unique<VKStreamingBuffer>(buffer, min_offset_alignment));
555 return streaming_buffers_.last();
556}
557
559
560/* -------------------------------------------------------------------- */
563
564void VKContext::openxr_acquire_framebuffer_image_callback(GHOST_VulkanOpenXRData *openxr_data)
565{
566 VKContext *context = VKContext::get();
567 BLI_assert(context);
568 context->openxr_acquire_framebuffer_image_handler(*openxr_data);
569}
570
571void VKContext::openxr_release_framebuffer_image_callback(GHOST_VulkanOpenXRData *openxr_data)
572{
573 VKContext *context = VKContext::get();
574 BLI_assert(context);
575 context->openxr_release_framebuffer_image_handler(*openxr_data);
576}
577
578void VKContext::openxr_acquire_framebuffer_image_handler(GHOST_VulkanOpenXRData &openxr_data)
579{
580 VKFrameBuffer &framebuffer = *unwrap(active_fb);
581 VKTexture *color_attachment = unwrap(unwrap(framebuffer.color_tex(0)));
582 openxr_data.extent.width = color_attachment->width_get();
583 openxr_data.extent.height = color_attachment->height_get();
584
585 /* Determine the data format for data transfer. */
586 const TextureFormat device_format = color_attachment->device_format_get();
588 if (ELEM(device_format, TextureFormat::UNORM_8_8_8_8)) {
589 data_format = GPU_DATA_UBYTE;
590 }
591
592 switch (openxr_data.data_transfer_mode) {
593 case GHOST_kVulkanXRModeCPU:
594 openxr_data.cpu.image_data = MEM_new_uninitialized(
595 color_attachment->read_size_get(0, data_format), __func__);
596 color_attachment->read(0, data_format, openxr_data.cpu.image_data);
597 break;
598
599 case GHOST_kVulkanXRModeFD: {
603 if (openxr_data.gpu.vk_image_blender != color_attachment->vk_image_handle()) {
604 VKMemoryExport exported_memory = color_attachment->export_memory(
605 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT);
606 openxr_data.gpu.image_handle = exported_memory.handle;
607 openxr_data.gpu.new_handle = true;
608 openxr_data.gpu.image_format = to_vk_format(color_attachment->device_format_get());
609 openxr_data.gpu.memory_size = exported_memory.memory_size;
610 openxr_data.gpu.memory_offset = exported_memory.memory_offset;
611 openxr_data.gpu.vk_image_blender = color_attachment->vk_image_handle();
612 }
613 break;
614 }
615
616 case GHOST_kVulkanXRModeWin32: {
620 if (openxr_data.gpu.vk_image_blender != color_attachment->vk_image_handle()) {
621 VKMemoryExport exported_memory = color_attachment->export_memory(
622 VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT);
623 openxr_data.gpu.image_handle = exported_memory.handle;
624 openxr_data.gpu.new_handle = true;
625 openxr_data.gpu.image_format = to_vk_format(color_attachment->device_format_get());
626 openxr_data.gpu.memory_size = exported_memory.memory_size;
627 openxr_data.gpu.memory_offset = exported_memory.memory_offset;
628 openxr_data.gpu.vk_image_blender = color_attachment->vk_image_handle();
629 }
630 break;
631 }
632
633 case GHOST_kVulkanXRModeRenderGraph:
634 break;
635 }
636}
637
638void VKContext::openxr_release_framebuffer_image_handler(GHOST_VulkanOpenXRData &openxr_data)
639{
640 switch (openxr_data.data_transfer_mode) {
641 case GHOST_kVulkanXRModeCPU:
642 MEM_delete_void(openxr_data.cpu.image_data);
643 openxr_data.cpu.image_data = nullptr;
644 break;
645
646 case GHOST_kVulkanXRModeFD:
647 /* Nothing to do as import of the handle by the XrInstance removes the ownership of the
648 * handle. Ref
649 * https://registry.khronos.org/vulkan/specs/latest/man/html/VK_KHR_external_memory_fd.html#_issues
650 */
651 break;
652
653 case GHOST_kVulkanXRModeWin32:
654#ifdef _WIN32
655 if (openxr_data.gpu.new_handle) {
656 /* Exported handle isn't consumed during import and should be freed after use. */
657 CloseHandle(HANDLE(openxr_data.gpu.image_handle));
658 openxr_data.gpu.image_handle = 0;
659 }
660#endif
661 break;
662
663 case GHOST_kVulkanXRModeRenderGraph:
664 break;
665 }
666}
667
669
670} // namespace blender::gpu
#define GPU_ATTACHMENT_TEXTURE(_texture)
#define UNPACK2(a)
#define ELEM(...)
static GHOST_IContext * getActiveDrawingContext()
static constexpr IndexRange from_begin_size(const int64_t begin, const int64_t size)
void attachment_remove(GPUAttachmentType type)
gpu::Texture * color_tex(int slot) const
virtual void bind(bool enabled_srgb)=0
void attachment_set(GPUAttachmentType type, const GPUAttachment &new_attachment)
virtual void image_bind(Texture *tex, int unit)=0
size_t read_size_get(int mip, eGPUDataFormat format) const
static VKBackend & get()
void compute_dispatch(int groups_x_len, int groups_y_len, int groups_z_len) override
A pool of VkBuffers.
void discard()
Discard the current buffers to the discard pool.
void ensure_uploaded()
Ensure that all the data is uploaded.
VkBuffer vk_handle() const
Definition vk_buffer.hh:108
static void swap_buffer_draw_callback(const GHOST_VulkanSwapChainData *data, bool wait_for_submission)
VKContext(GHOST_IWindow *ghost_window, GHOST_IContext *ghost_context)
Definition vk_context.cc:28
void debug_unbind_all_ssbo() override
render_graph::VKResourceAccessInfo & reset_and_get_access_info()
VKBufferPool push_constants_pool
Definition vk_context.hh:79
void finish() override
static void openxr_acquire_framebuffer_image_callback(GHOST_VulkanOpenXRData *data)
void specialization_constants_set(const shader::SpecializationConstants *constants_state)
void deactivate() override
void memory_statistics_get(int *r_total_mem_kb, int *r_free_mem_kb) override
VKDiscardPool discard_pool
Definition vk_context.hh:78
static void swap_buffer_acquired_callback()
static void openxr_release_framebuffer_image_callback(GHOST_VulkanOpenXRData *data)
void flush() override
VKFrameBuffer * active_framebuffer_get() const
void activate() override
const render_graph::VKRenderGraph & render_graph() const
Definition vk_context.hh:81
bool has_active_framebuffer() const
void debug_unbind_all_ubo() override
void activate_framebuffer(VKFrameBuffer &framebuffer)
VKStateManager & state_manager_get() const
VKDescriptorSetTracker & descriptor_set_get()
std::unique_ptr< VKStreamingBuffer > & get_or_create_streaming_buffer(VKBuffer &buffer, VkDeviceSize min_offset_alignment)
void update_pipeline_data(render_graph::VKPipelineData &r_pipeline_data)
static VKContext * get()
void begin_frame() override
VKDescriptorPools & descriptor_pools_get()
void end_frame() override
TimelineValue flush_render_graph(RenderGraphFlushFlags flags, VkPipelineStageFlags wait_dst_stage_mask=VK_PIPELINE_STAGE_NONE, VkSemaphore wait_semaphore=VK_NULL_HANDLE, VkSemaphore signal_semaphore=VK_NULL_HANDLE, VkFence signal_fence=VK_NULL_HANDLE)
void update_descriptor_set(VKContext &context, render_graph::VKResourceAccessInfo &resource_access_info, render_graph::VKPipelineData &r_pipeline_data)
const VKExtensions & extensions_get() const
Definition vk_device.hh:398
render_graph::VKRenderGraph * render_graph_new()
VKThreadData & current_thread_data()
Definition vk_device.cc:488
void context_unregister(VKContext &context)
Definition vk_device.cc:509
void memory_statistics_get(int *r_total_mem_kb, int *r_free_mem_kb) const
Definition vk_device.cc:532
TimelineValue render_graph_submit(render_graph::VKRenderGraph *render_graph, VKDiscardPool &context_discard_pool, bool submit_to_device, bool wait_for_submission, bool wait_for_completion, VkPipelineStageFlags wait_dst_stage_mask, VkSemaphore wait_semaphore, VkSemaphore signal_semaphore, VkFence signal_fence)
void discard_swapchain_image(ResourceHandle image_handle)
void discard_image_view(VkImageView vk_image_view)
VKFrameBuffer(const char *name)
VkFormat stencil_attachment_format_get() const
void rendering_end(VKContext &context)
void vk_viewports_append(Vector< VkViewport, GPU_MAX_VIEWPORTS > &r_viewports) const
void vk_render_areas_append(Vector< VkRect2D, GPU_MAX_VIEWPORTS > &r_render_areas) const
const VKPushConstants::Layout & push_constants_layout_get() const
VkPipeline ensure_and_get_compute_pipeline(const shader::SpecializationConstants &constants_state)
VKPushConstants push_constants
Definition vk_shader.hh:70
bool has_descriptor_set() const
Definition vk_shader.hh:126
VkPipelineLayout vk_pipeline_layout
Definition vk_shader.hh:69
const VKShaderInterface & interface_get() const
VkPipeline ensure_and_get_graphics_pipeline(GPUPrimType primitive, VKVertexInputDescriptionPool::Key vertex_input_description_key, VKStateManager &state_manager, const VKFrameBuffer &framebuffer, shader::SpecializationConstants &constants_state)
VKMemoryExport export_memory(VkExternalMemoryHandleTypeFlagBits handle_type)
TextureFormat device_format_get() const
VkImage vk_image_handle() const
void read(int mip, eGPUDataFormat format, void *data) override
#define point_size
uint64_t TimelineValue
Definition vk_common.hh:39
static Context * unwrap(GPUContext *ctx)
VkFormat to_vk_format(const TextureFormat format)
Definition vk_common.cc:157
BLI_INLINE MTLTexture * unwrap(Texture *tex)
GPUCapabilities GCaps
TextureFormat to_gpu_format(const VkFormat format)
Definition vk_common.cc:122
uint64_t ResourceHandle
Definition vk_common.hh:68
VecBase< T, Size > divide_ceil(const VecBase< T, Size > &a, const VecBase< T, Size > &b)
void * MEM_new_uninitialized(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
@ GPU_DATA_HALF_FLOAT
@ GPU_PRIM_LINES_ADJ
@ GPU_PRIM_LINE_STRIP_ADJ
@ GPU_PRIM_LINE_STRIP
@ GPU_PRIM_LINE_LOOP
MINLINE uint max_uu(uint a, uint b)
void MEM_delete_void(void *vmemh)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_ATTACHMENT
unsigned char uint8_t
Definition BKE_text.h:79
void GPU_shader_bind(gpu::Shader *shader, const gpu::shader::SpecializationConstants *constants_state=nullptr)
@ GPU_STENCIL_NONE
Definition GPU_state.hh:142
void GPU_debug_group_end()
Definition gpu_debug.cc:34
void GPU_shader_uniform_1f(gpu::Shader *sh, const char *name, float value)
void GPU_texture_free(gpu::Texture *texture)
signed int int32_t
Definition BKE_text.h:78
void immDeactivate()
void immActivate()
gpu::Texture * GPU_texture_create_2d(const char *name, int width, int height, int mip_len, gpu::TextureFormat format, eGPUTextureUsage usage, const float *data)
void GPU_debug_group_begin(const char *name)
Definition gpu_debug.cc:23
std::optional< VKVertexInputDescriptionPool::Key > vertex_input_description
Vector< VkViewport, GPU_MAX_VIEWPORTS > viewports
Vector< VkRect2D, GPU_MAX_VIEWPORTS > scissors