Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize data transfer structs and parameters #51

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 50 additions & 55 deletions include/SDL3/SDL_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,19 +438,24 @@ typedef struct SDL_GpuTextureRegion
Uint32 d;
} SDL_GpuTextureRegion;

typedef struct SDL_GpuBufferImageCopy
typedef struct SDL_GpuTransferBufferWithOffset
{
Uint32 bufferOffset;
SDL_GpuTransferBuffer *transferBuffer;
Uint32 offset;
} SDL_GpuTransferBufferWithOffset;

typedef struct SDL_GpuImageTransfer
{
SDL_GpuTransferBufferWithOffset transferBufferWithOffset;
Uint32 bufferStride; /* number of pixels from one row to the next */
Uint32 bufferImageHeight; /* number of rows from one layer/depth-slice to the next */
} SDL_GpuBufferImageCopy;
} SDL_GpuImageTransfer;

typedef struct SDL_GpuBufferCopy
typedef struct SDL_GpuBufferWithOffset
{
Uint32 srcOffset;
Uint32 dstOffset;
Uint32 size;
} SDL_GpuBufferCopy;
SDL_GpuBuffer *buffer;
Uint32 offset;
} SDL_GpuBufferWithOffset;

typedef struct SDL_GpuIndirectDrawCommand
{
Expand Down Expand Up @@ -738,12 +743,6 @@ typedef struct SDL_GpuDepthStencilAttachmentInfo

/* Binding structs */

typedef struct SDL_GpuBufferBinding
{
SDL_GpuBuffer *buffer;
Uint32 offset;
} SDL_GpuBufferBinding;

typedef struct SDL_GpuTextureSamplerBinding
{
SDL_GpuTexture *texture;
Expand Down Expand Up @@ -1236,15 +1235,15 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuSetScissor(
*
* \param renderPass a render pass handle
* \param firstBinding the starting bind point for the vertex buffers
* \param pBindings an array of SDL_GpuBufferBinding structs containing vertex buffers and offset values
* \param pBindings an array of SDL_GpuBufferWithOffset structs containing vertex buffers and offset values
* \param bindingCount the number of bindings in the pBindings array
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuBindVertexBuffers(
SDL_GpuRenderPass *renderPass,
Uint32 firstBinding,
SDL_GpuBufferBinding *pBindings,
SDL_GpuBufferWithOffset *pBindings,
Uint32 bindingCount);

/**
Expand All @@ -1258,7 +1257,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuBindVertexBuffers(
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuBindIndexBuffer(
SDL_GpuRenderPass *renderPass,
SDL_GpuBufferBinding *pBinding,
SDL_GpuBufferWithOffset *pBinding,
SDL_GpuIndexElementSize indexElementSize);

/**
Expand Down Expand Up @@ -1650,35 +1649,35 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuUnmapTransferBuffer(
* Immediately copies data from a pointer to a transfer buffer.
*
* \param device a GPU context
* \param data a pointer to data to copy into the transfer buffer
* \param transferBuffer a transfer buffer
* \param copyParams a struct containing parameters specifying copy offsets and size
* \param source a pointer to data to copy into the transfer buffer
* \param destination a transfer buffer and offset
* \param size the amount of bytes to copy
* \param cycle if SDL_TRUE, cycles the transfer buffer if it is bound, otherwise overwrites the data.
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuSetTransferData(
SDL_GpuDevice *device,
const void *data,
SDL_GpuTransferBuffer *transferBuffer,
SDL_GpuBufferCopy *copyParams,
const void *source,
SDL_GpuTransferBufferWithOffset *destination,
Uint32 size,
SDL_bool cycle);

/**
* Immediately copies data from a transfer buffer to a pointer.
*
* \param device a GPU context
* \param transferBuffer a transfer buffer
* \param data a data pointer
* \param copyParams a struct containing parameters specifying copy offsets and size
* \param source a transfer buffer and offset
* \param destination a data pointer to be copied into
* \param size the amount of bytes to copy
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuGetTransferData(
SDL_GpuDevice *device,
SDL_GpuTransferBuffer *transferBuffer,
void *data,
SDL_GpuBufferCopy *copyParams);
SDL_GpuTransferBufferWithOffset *source,
void *destination,
Uint32 size);

/* Copy Pass */

Expand All @@ -1705,18 +1704,16 @@ extern SDL_DECLSPEC SDL_GpuCopyPass *SDLCALL SDL_GpuBeginCopyPass(
* the texel size of the texture format.
*
* \param copyPass a copy pass handle
* \param source the source transfer buffer
* \param source the source transfer buffer and copy params
* \param destination the destination texture region
* \param copyParams buffer offset, stride, and height
* \param cycle if SDL_TRUE, cycles the texture if the texture slice is bound, otherwise overwrites the data.
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuUploadToTexture(
SDL_GpuCopyPass *copyPass,
SDL_GpuTransferBuffer *source,
SDL_GpuImageTransfer *source,
SDL_GpuTextureRegion *destination,
SDL_GpuBufferImageCopy *copyParams,
SDL_bool cycle);

/* Uploads data from a TransferBuffer to a Buffer. */
Expand All @@ -1729,16 +1726,16 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuUploadToTexture(
* \param copyPass a copy pass handle
* \param source the source transfer buffer
* \param destination the destination buffer
* \param copyParams buffer offsets and length
* \param size the amount of bytes to copy
* \param cycle if SDL_TRUE, cycles the buffer if it is bound, otherwise overwrites the data.
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuUploadToBuffer(
SDL_GpuCopyPass *copyPass,
SDL_GpuTransferBuffer *source,
SDL_GpuBuffer *destination,
SDL_GpuBufferCopy *copyParams,
SDL_GpuTransferBufferWithOffset *source,
SDL_GpuBufferWithOffset *destination,
Uint32 size,
SDL_bool cycle);

/**
Expand All @@ -1747,8 +1744,8 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuUploadToBuffer(
* You may assume the copy has finished in subsequent commands.
*
* \param copyPass a copy pass handle
* \param source a source texture region
* \param destination must be the same dimensions as the source region
* \param source the source texture region
* \param destination the destination texture region, must have the same dimensions as the source region
* \param cycle if SDL_TRUE, cycles the destination texture if the destination texture slice is bound, otherwise overwrites the data.
*
* \since This function is available since SDL 3.x.x
Expand All @@ -1767,18 +1764,18 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuCopyTextureToTexture(
* You may assume the copy has finished in subsequent commands.
*
* \param copyPass a copy pass handle
* \param source the buffer to copy from
* \param destination the buffer to copy to
* \param copyParams a struct containing offset and length data
* \param source the buffer and offset to copy from
* \param destination the buffer and offset to copy to
* \param size the amount of bytes to copy
* \param cycle if SDL_TRUE, cycles the destination buffer if it is bound, otherwise overwrites the data.
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuCopyBufferToBuffer(
SDL_GpuCopyPass *copyPass,
SDL_GpuBuffer *source,
SDL_GpuBuffer *destination,
SDL_GpuBufferCopy *copyParams,
SDL_GpuBufferWithOffset *source,
SDL_GpuBufferWithOffset *destination,
Uint32 size,
SDL_bool cycle);

/**
Expand All @@ -1799,33 +1796,31 @@ extern SDL_DECLSPEC void SDLCALL SDL_GpuGenerateMipmaps(
*
* \param copyPass a copy pass handle
* \param source the source texture region
* \param destination the destination transfer buffer
* \param copyParams a struct containing parameters specifying buffer offset, stride, and height
* \param destination the destination transfer buffer and copy params
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuDownloadFromTexture(
SDL_GpuCopyPass *copyPass,
SDL_GpuTextureRegion *source,
SDL_GpuTransferBuffer *destination,
SDL_GpuBufferImageCopy *copyParams);
SDL_GpuImageTransfer *destination);

/**
* Copies data from a buffer to a transfer buffer on the GPU timeline.
* This data is not guaranteed to be copied until the command buffer fence is signaled.
*
* \param copyPass a copy pass handle
* \param source the source buffer
* \param destination the destination transfer buffer
* \param copyParams a struct containing offsets and length
* \param source the source buffer and offset
* \param destination the destination transfer buffer and offset
* \param size the amount of bytes to copy
*
* \since This function is available since SDL 3.x.x
*/
extern SDL_DECLSPEC void SDLCALL SDL_GpuDownloadFromBuffer(
SDL_GpuCopyPass *copyPass,
SDL_GpuBuffer *source,
SDL_GpuTransferBuffer *destination,
SDL_GpuBufferCopy *copyParams);
SDL_GpuBufferWithOffset *source,
SDL_GpuTransferBufferWithOffset *destination,
Uint32 size);

/**
* Ends the current copy pass.
Expand Down
18 changes: 9 additions & 9 deletions src/dynapi/SDL_dynapi_procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1077,8 +1077,8 @@ SDL_DYNAPI_PROC(SDL_GpuRenderPass*,SDL_GpuBeginRenderPass,(SDL_GpuCommandBuffer
SDL_DYNAPI_PROC(void,SDL_GpuBindGraphicsPipeline,(SDL_GpuRenderPass *a, SDL_GpuGraphicsPipeline *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_GpuSetViewport,(SDL_GpuRenderPass *a, SDL_GpuViewport *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_GpuSetScissor,(SDL_GpuRenderPass *a, SDL_GpuRect *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_GpuBindVertexBuffers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuBufferBinding *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuBindIndexBuffer,(SDL_GpuRenderPass *a, SDL_GpuBufferBinding *b, SDL_GpuIndexElementSize c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_GpuBindVertexBuffers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuBufferWithOffset *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuBindIndexBuffer,(SDL_GpuRenderPass *a, SDL_GpuBufferWithOffset *b, SDL_GpuIndexElementSize c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_GpuBindVertexSamplers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuTextureSamplerBinding *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuBindVertexStorageTextures,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuTextureSlice *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuBindVertexStorageBuffers,(SDL_GpuRenderPass *a, Uint32 b, SDL_GpuBuffer **c, Uint32 d),(a,b,c,d),)
Expand All @@ -1101,16 +1101,16 @@ SDL_DYNAPI_PROC(void,SDL_GpuDispatchCompute,(SDL_GpuComputePass *a, Uint32 b, Ui
SDL_DYNAPI_PROC(void,SDL_GpuEndComputePass,(SDL_GpuComputePass *a),(a),)
SDL_DYNAPI_PROC(void,SDL_GpuMapTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBuffer *b, SDL_bool c, void **d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuUnmapTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBuffer *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_GpuSetTransferData,(SDL_GpuDevice *a, const void *b, SDL_GpuTransferBuffer *c, SDL_GpuBufferCopy *d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GpuGetTransferData,(SDL_GpuDevice *a, SDL_GpuTransferBuffer *b, void *c, SDL_GpuBufferCopy *d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuSetTransferData,(SDL_GpuDevice *a, const void *b, SDL_GpuTransferBufferWithOffset *c, Uint32 d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GpuGetTransferData,(SDL_GpuDevice *a, SDL_GpuTransferBufferWithOffset *b, void *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(SDL_GpuCopyPass*,SDL_GpuBeginCopyPass,(SDL_GpuCommandBuffer *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GpuUploadToTexture,(SDL_GpuCopyPass *a, SDL_GpuTransferBuffer *b, SDL_GpuTextureRegion *c, SDL_GpuBufferImageCopy *d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GpuUploadToBuffer,(SDL_GpuCopyPass *a, SDL_GpuTransferBuffer *b, SDL_GpuBuffer *c, SDL_GpuBufferCopy *d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GpuUploadToTexture,(SDL_GpuCopyPass *a, SDL_GpuImageTransfer *b, SDL_GpuTextureRegion *c, SDL_bool d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuUploadToBuffer,(SDL_GpuCopyPass *a, SDL_GpuTransferBufferWithOffset *b, SDL_GpuBufferWithOffset *c, Uint32 d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GpuCopyTextureToTexture,(SDL_GpuCopyPass *a, SDL_GpuTextureRegion *b, SDL_GpuTextureRegion *c, SDL_bool d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuCopyBufferToBuffer,(SDL_GpuCopyPass *a, SDL_GpuBuffer *b, SDL_GpuBuffer *c, SDL_GpuBufferCopy *d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GpuCopyBufferToBuffer,(SDL_GpuCopyPass *a, SDL_GpuBufferWithOffset *b, SDL_GpuBufferWithOffset *c, Uint32 d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(void,SDL_GpuGenerateMipmaps,(SDL_GpuCopyPass *a, SDL_GpuTexture *b),(a,b),)
SDL_DYNAPI_PROC(void,SDL_GpuDownloadFromTexture,(SDL_GpuCopyPass *a, SDL_GpuTextureRegion *b, SDL_GpuTransferBuffer *c, SDL_GpuBufferImageCopy *d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuDownloadFromBuffer,(SDL_GpuCopyPass *a, SDL_GpuBuffer *b, SDL_GpuTransferBuffer *c, SDL_GpuBufferCopy *d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuDownloadFromTexture,(SDL_GpuCopyPass *a, SDL_GpuTextureRegion *b, SDL_GpuImageTransfer *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_GpuDownloadFromBuffer,(SDL_GpuCopyPass *a, SDL_GpuBufferWithOffset *b, SDL_GpuTransferBufferWithOffset *c, Uint32 d),(a,b,c,d),)
SDL_DYNAPI_PROC(void,SDL_GpuEndCopyPass,(SDL_GpuCopyPass *a),(a),)
SDL_DYNAPI_PROC(void,SDL_GpuBlit,(SDL_GpuCommandBuffer *a, SDL_GpuTextureRegion *b, SDL_GpuTextureRegion *c, SDL_GpuFilter d, SDL_bool e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(SDL_bool,SDL_GpuSupportsSwapchainComposition,(SDL_GpuDevice *a, SDL_Window *b, SDL_GpuSwapchainComposition c),(a,b,c),return)
Expand Down
Loading
Loading