CopyBufferToImageDesc

sg_copy_buffer_to_image_desc

Describes a buffer-to-image copy operation via sg_copy_buffer_to_image():

.src .buffer the source buffer .offset offset into the buffer .bytes_per_row row pitch in bytes of the source data (default: see below) .bytes_per_slice slice pitch in bytes of the source data (default: see below) .dst .image the destination image .mip_level the mip level to copy to .x, .y destination [x,y] coordinate .slice destination array or 3d slice .size .width copy region width in pixels .height copy region height in pixels .num_slices number of array or 3d slices to copy

Note on default values:

The default values are the same as sg_write_image_desc, which may be a bit unintuitive for a copy operation. TL;DR: the defaults are for copying a whole, tightly packed mip level into the destination image:

.src.bytes_per_row Default is the row pitch of the selected destination image miplevel (e.g. *not* computed from the copy-width) .src.bytes_per_slice Likewise, the default is the slice pitch of the destination image mip level (e.g. *not* computed from the copy width and height) .size The size default is the 'rest after offset' for the destination mip level, e.g.: .size.width = mip_width - .dst.x .size.height = mip_height - .dst.y .size.num_slices = mip_depth_or_slices - .dst.slice

Caveats (all checked by the validation layer or via logged errors and warnings): - sg_copy_buffer_to_image() must be called outside a pass - for compressed image formats, .size.width and .size.height must be a multiple of the compression block size or fall on the mip level width / height - the source buffer must have been created with .usage.copy_src - the destination image must have been created with .usage.copy_dst - the source buffer type cannot be .usage.staging_index_buffer - the source buffer type cannot be .usage.index_buffer when sg_query_features().separate_buffer_types is true (this is a WebGL2 restriction) - only .usage.staging_buffer sources are allowed when sg_query_features().copy_buffer_to_image_relaxed_buffer_type is false (this is a D3D11 restriction) - when copying from a *non-staging buffer*, .src.bytes_per_row must be a multiple of 256 when sg_query_features().copy_buffer_to_image_relaxed_bytes_per_row is false (this is a WebGPU restriction) - 'fuzzy' GL restriction (this is not currently enforced by the validation layer): when copying into compressed textures, the source data must be tightly packed (e.g. .src.bytes_per_row and .src.bytes_per_slice will be ignored) - On the Apple GL/GLES3 backends, when calling sg_copy_buffer_to_image() from a non-staging buffer, the source buffer offset is ignored because of a GL driver bug (which is unlikely to be fixed because GL on macOS is long deprecated), sokol_gfx.h will log a one-time message when the bug would be triggered. For copying from staging buffers, the offset works because of a special workaround in the sokol-gfx GL backend (staging buffers are actually heap memory allocations).

extern (C)
struct CopyBufferToImageDesc {}

Members

Variables

dst
ImageLocation dst;
Undocumented in source.
size
ImageExtent size;
Undocumented in source.
src
BufferImageLocation src;
Undocumented in source.

Meta