31 VKBuffer &buffer = ensure_space(bytes_needed, offset_alignment);
35 buffer_offset_ += offset_alignment - 1;
36 buffer_offset_ &= ~(offset_alignment - 1);
37 BLI_assert((buffer_offset_ & (offset_alignment - 1)) == 0);
39 current_subbuffer_len_ = bytes_needed;
41 return data + buffer_offset_;
52 uchar *first_vertex_ptr =
static_cast<uchar *
>(active_buffer_->mapped_memory_get()) +
54 size_t vertex_stride = current_subbuffer_len_ / (
vertex_len + 1);
56 memcpy(last_vertex_ptr, first_vertex_ptr, vertex_stride);
66 VKBuffer &buffer = active_buffer_.value();
84 vertex_attributes_.update_bindings(*
this);
85 context.active_framebuffer_get()->rendering_ensure(context);
89 draw.node_data.instance_count = 1;
90 draw.node_data.first_vertex = 0;
91 draw.node_data.first_instance = 0;
93 context.active_framebuffer_get()->vk_viewports_append(
draw.node_data.viewport_data.viewports);
94 context.active_framebuffer_get()->vk_render_areas_append(
95 draw.node_data.viewport_data.scissors);
97 vertex_attributes_.bind(
draw.node_data.vertex_buffers);
98 context.update_pipeline_data(
prim_type, vertex_attributes_,
draw.node_data.pipeline_data);
100 context.render_graph().add_node(
draw);
103 buffer_offset_ += current_subbuffer_len_;
104 current_subbuffer_len_ = 0;
113VkDeviceSize VKImmediate::buffer_bytes_free()
115 return active_buffer_->size_in_bytes() - buffer_offset_;
123VKBuffer &VKImmediate::ensure_space(VkDeviceSize bytes_needed, VkDeviceSize offset_alignment)
125 VkDeviceSize bytes_required = bytes_needed + offset_alignment;
128 if (active_buffer_.has_value() && buffer_bytes_free() >= bytes_required) {
129 return active_buffer_.value();
136 "Immediate buffer cannot hold another %d bytes, it contains %d bytes. A new "
137 "buffer will be allocated (size=%d)",
142 VKBuffer &
result = active_buffer_.emplace();
144 VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT |
145 VK_BUFFER_USAGE_TRANSFER_DST_BIT,
146 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
147 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
148 VMA_ALLOCATION_CREATE_MAPPED_BIT |
149 VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT,
#define BLI_assert_msg(a, msg)
#define CLOG_INFO(clg_ref, level,...)
size_t GPU_storage_buffer_alignment()
void GPU_matrix_bind(GPUShader *shader)
BMesh const char void * data
void * mapped_memory_get() const
void storage_buffer_bind(BindSpaceStorageBuffers::Type resource_type, void *resource, int binding)
VKDrawCreateInfo CreateInfo
#define GPU_SSBO_POLYLINE_POS_BUF_SLOT
#define GPU_SSBO_POLYLINE_COL_BUF_SLOT
#define GPU_SSBO_INDEX_BUF_SLOT
MINLINE unsigned long long max_ulul(unsigned long long a, unsigned long long b)
void object_label(GLenum type, GLuint object, const char *name)
static Context * unwrap(GPUContext *ctx)
constexpr size_t DEFAULT_INTERNAL_BUFFER_SIZE
static GPUContext * wrap(Context *ctx)
static VkDeviceSize new_buffer_size(VkDeviceSize sub_buffer_size)