Skip to content

Commit

Permalink
transfer buffers specify upload or download usage
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcosmonaut committed Jun 18, 2024
1 parent 2d02455 commit bccce00
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions include/SDL3/SDL_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ typedef enum SDL_GpuBufferUsageFlagBits

typedef Uint32 SDL_GpuBufferUsageFlags;

typedef enum SDL_GpuTransferBufferUsage
{
SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD,
SDL_GPU_TRANSFERBUFFERUSAGE_DOWNLOAD
} SDL_GpuTransferBufferUsage;

typedef enum SDL_GpuShaderStage
{
SDL_GPU_SHADERSTAGE_VERTEX,
Expand Down Expand Up @@ -936,7 +942,7 @@ extern SDL_DECLSPEC SDL_GpuBuffer *SDLCALL SDL_GpuCreateBuffer(
* Creates a transfer buffer to be used when uploading to or downloading from graphics resources.
*
* \param device a GPU Context
* \param uploadOnly specifies that the transfer buffer will only be used for uploads, allows optimizations on certain backends
* \param usage whether the transfer buffer will be used for uploads or downloads
* \param sizeInBytes the size of the transfer buffer
* \returns a transfer buffer on success, or NULL on failure
*
Expand All @@ -950,7 +956,7 @@ extern SDL_DECLSPEC SDL_GpuBuffer *SDLCALL SDL_GpuCreateBuffer(
*/
extern SDL_DECLSPEC SDL_GpuTransferBuffer *SDLCALL SDL_GpuCreateTransferBuffer(
SDL_GpuDevice *device,
SDL_bool uploadOnly,
SDL_GpuTransferBufferUsage usage,
Uint32 sizeInBytes);

/* Debug Naming */
Expand Down
2 changes: 1 addition & 1 deletion src/dynapi/SDL_dynapi_procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ SDL_DYNAPI_PROC(SDL_GpuSampler*,SDL_GpuCreateSampler,(SDL_GpuDevice *a, SDL_GpuS
SDL_DYNAPI_PROC(SDL_GpuShader*,SDL_GpuCreateShader,(SDL_GpuDevice *a, SDL_GpuShaderCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuTexture*,SDL_GpuCreateTexture,(SDL_GpuDevice *a, SDL_GpuTextureCreateInfo *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_GpuBuffer*,SDL_GpuCreateBuffer,(SDL_GpuDevice *a, SDL_GpuBufferUsageFlags b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_GpuTransferBuffer*,SDL_GpuCreateTransferBuffer,(SDL_GpuDevice *a, SDL_bool b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_GpuTransferBuffer*,SDL_GpuCreateTransferBuffer,(SDL_GpuDevice *a, SDL_GpuTransferBufferUsage b, Uint32 c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_GpuSetBufferName,(SDL_GpuDevice *a, SDL_GpuBuffer *b, const char *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_GpuSetTextureName,(SDL_GpuDevice *a, SDL_GpuTexture *b, const char *c),(a,b,c),)
SDL_DYNAPI_PROC(void,SDL_GpuSetStringMarker,(SDL_GpuCommandBuffer *a, const char *b),(a,b),)
Expand Down
4 changes: 2 additions & 2 deletions src/gpu/SDL_gpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,13 +444,13 @@ SDL_GpuBuffer *SDL_GpuCreateBuffer(

SDL_GpuTransferBuffer *SDL_GpuCreateTransferBuffer(
SDL_GpuDevice *device,
SDL_bool uploadOnly,
SDL_GpuTransferBufferUsage usage,
Uint32 sizeInBytes)
{
NULL_ASSERT(device)
return device->CreateTransferBuffer(
device->driverData,
uploadOnly,
usage,
sizeInBytes);
}

Expand Down
2 changes: 1 addition & 1 deletion src/gpu/SDL_gpu_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct SDL_GpuDevice

SDL_GpuTransferBuffer *(*CreateTransferBuffer)(
SDL_GpuRenderer *driverData,
SDL_bool uploadOnly,
SDL_GpuTransferBufferUsage usage,
Uint32 sizeInBytes);

/* Debug Naming */
Expand Down
2 changes: 1 addition & 1 deletion src/gpu/vulkan/SDL_gpu_vulkan.c
Original file line number Diff line number Diff line change
Expand Up @@ -6765,7 +6765,7 @@ static VulkanUniformBuffer *VULKAN_INTERNAL_CreateUniformBuffer(

static SDL_GpuTransferBuffer *VULKAN_CreateTransferBuffer(
SDL_GpuRenderer *driverData,
SDL_bool uploadOnly, /* ignored on Vulkan */
SDL_GpuTransferBufferUsage usage, /* ignored on Vulkan */
Uint32 sizeInBytes)
{
return (SDL_GpuTransferBuffer *)VULKAN_INTERNAL_CreateBufferContainer(
Expand Down

0 comments on commit bccce00

Please sign in to comment.