MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / buffer_copy

Method buffer_copy

servers/rendering/rendering_device.cpp:420–459  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

418}
419
420Error RenderingDevice::buffer_copy(RID p_src_buffer, RID p_dst_buffer, uint32_t p_src_offset, uint32_t p_dst_offset, uint32_t p_size) {
421 ERR_RENDER_THREAD_GUARD_V(ERR_UNAVAILABLE);
422
423 ERR_FAIL_COND_V_MSG(draw_list.active, ERR_INVALID_PARAMETER,
424 "Copying buffers is forbidden during creation of a draw list");
425 ERR_FAIL_COND_V_MSG(compute_list.active, ERR_INVALID_PARAMETER,
426 "Copying buffers is forbidden during creation of a compute list");
427
428 Buffer *src_buffer = _get_buffer_from_owner(p_src_buffer);
429 if (!src_buffer) {
430 ERR_FAIL_V_MSG(ERR_INVALID_PARAMETER, "Source buffer argument is not a valid buffer of any type.");
431 }
432
433 Buffer *dst_buffer = _get_buffer_from_owner(p_dst_buffer);
434 if (!dst_buffer) {
435 ERR_FAIL_V_MSG(ERR_INVALID_PARAMETER, "Destination buffer argument is not a valid buffer of any type.");
436 }
437
438 // Validate the copy's dimensions for both buffers.
439 ERR_FAIL_COND_V_MSG((p_size + p_src_offset) > src_buffer->size, ERR_INVALID_PARAMETER, "Size is larger than the source buffer.");
440 ERR_FAIL_COND_V_MSG((p_size + p_dst_offset) > dst_buffer->size, ERR_INVALID_PARAMETER, "Size is larger than the destination buffer.");
441
442 _check_transfer_worker_buffer(src_buffer);
443 _check_transfer_worker_buffer(dst_buffer);
444
445 // Perform the copy.
446 RDD::BufferCopyRegion region;
447 region.src_offset = p_src_offset;
448 region.dst_offset = p_dst_offset;
449 region.size = p_size;
450
451 if (_buffer_make_mutable(dst_buffer, p_dst_buffer)) {
452 // The destination buffer must be mutable to be used as a copy destination.
453 draw_graph.add_synchronization();
454 }
455
456 draw_graph.add_buffer_copy(src_buffer->driver_id, src_buffer->draw_tracker, dst_buffer->driver_id, dst_buffer->draw_tracker, region);
457
458 return OK;
459}
460
461Error RenderingDevice::buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data) {
462 ERR_RENDER_THREAD_GUARD_V(ERR_UNAVAILABLE);

Callers 4

update_lightMethod · 0.80
render_regionMethod · 0.80
render_static_lightsMethod · 0.80

Calls 2

add_synchronizationMethod · 0.80
add_buffer_copyMethod · 0.80

Tested by

no test coverage detected