From bccce00566c3547dfc81a3ec233be40cc5f22c87 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 18 Jun 2024 12:56:59 -0700 Subject: [PATCH] transfer buffers specify upload or download usage --- include/SDL3/SDL_gpu.h | 10 ++++++++-- src/dynapi/SDL_dynapi_procs.h | 2 +- src/gpu/SDL_gpu.c | 4 ++-- src/gpu/SDL_gpu_driver.h | 2 +- src/gpu/vulkan/SDL_gpu_vulkan.c | 2 +- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 89d3711d1671f5..7ed15049887ad8 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -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, @@ -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 * @@ -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 */ diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index eec3d4694e8d6e..d88737bbc3ab6a 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -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),) diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index 73422869be1f6b..110ab1a272e29d 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -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); } diff --git a/src/gpu/SDL_gpu_driver.h b/src/gpu/SDL_gpu_driver.h index 1149604f54630e..b46920f2b10697 100644 --- a/src/gpu/SDL_gpu_driver.h +++ b/src/gpu/SDL_gpu_driver.h @@ -231,7 +231,7 @@ struct SDL_GpuDevice SDL_GpuTransferBuffer *(*CreateTransferBuffer)( SDL_GpuRenderer *driverData, - SDL_bool uploadOnly, + SDL_GpuTransferBufferUsage usage, Uint32 sizeInBytes); /* Debug Naming */ diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index 1078eaf92e9456..11ef92b8514c4b 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -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(