diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 320db4e54b..7ee6c86256 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -606,7 +606,7 @@ typedef struct SDL_GPUFence SDL_GPUFence; * \sa SDL_ReleaseGPUQueryPool * \sa SDL_BeginGPUQuery * \sa SDL_EndGPUQuery - * \sa SDL_CopyGPUQueryResultsToBuffer + * \sa SDL_DownloadGPUQueryResults * \sa SDL_GetGPUTimestampFrequency */ typedef struct SDL_GPUQueryPool SDL_GPUQueryPool; @@ -4088,12 +4088,12 @@ extern SDL_DECLSPEC void SDLCALL SDL_DownloadFromGPUBuffer( * * \since This struct is available since SDL 3.6.0. */ -extern SDL_DECLSPEC void SDLCALL SDL_CopyGPUQueryResultsToBuffer( +extern SDL_DECLSPEC void SDLCALL SDL_DownloadGPUQueryResults( SDL_GPUCopyPass *copy_pass, SDL_GPUQueryPool *pool, Uint32 first_query, Uint32 count, - SDL_GPUBufferLocation *destination); + SDL_GPUTransferBufferLocation *destination); /** * Ends the current copy pass. @@ -4586,7 +4586,7 @@ extern SDL_DECLSPEC float SDLCALL SDL_GetGPUTimestampFrequency(SDL_GPUDevice *de * \sa SDL_GetGPUTimestampFrequency * \sa SDL_BeginGPUQuery * \sa SDL_EndGPUQuery - * \sa SDL_CopyGPUQueryResultsToBuffer + * \sa SDL_DownloadGPUQueryResults * \sa SDL_ReleaseGPUQueryPool */ extern SDL_DECLSPEC SDL_GPUQueryPool * SDLCALL SDL_CreateGPUQueryPool( diff --git a/src/dynapi/SDL_dynapi.exports b/src/dynapi/SDL_dynapi.exports index ff366516af..87e4072ecd 100644 --- a/src/dynapi/SDL_dynapi.exports +++ b/src/dynapi/SDL_dynapi.exports @@ -1290,7 +1290,7 @@ _SDL_LoadJPG _SDL_HasSVE2 _SDL_GamepadHasCapSense _SDL_GetGamepadCapSense -_SDL_CopyGPUQueryResultsToBuffer +_SDL_DownloadGPUQueryResults _SDL_GetGPUTimestampFrequency _SDL_CreateGPUQueryPool _SDL_BeginGPUQuery diff --git a/src/dynapi/SDL_dynapi.sym b/src/dynapi/SDL_dynapi.sym index b3d1c29dec..4871a32753 100644 --- a/src/dynapi/SDL_dynapi.sym +++ b/src/dynapi/SDL_dynapi.sym @@ -1291,7 +1291,7 @@ SDL3_0.0.0 { SDL_HasSVE2; SDL_GamepadHasCapSense; SDL_GetGamepadCapSense; - SDL_CopyGPUQueryResultsToBuffer; + SDL_DownloadGPUQueryResults; SDL_GetGPUTimestampFrequency; SDL_CreateGPUQueryPool; SDL_BeginGPUQuery; diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h index d97e515a12..16435fbe87 100644 --- a/src/dynapi/SDL_dynapi_overrides.h +++ b/src/dynapi/SDL_dynapi_overrides.h @@ -1317,7 +1317,7 @@ #define SDL_HasSVE2 SDL_HasSVE2_REAL #define SDL_GamepadHasCapSense SDL_GamepadHasCapSense_REAL #define SDL_GetGamepadCapSense SDL_GetGamepadCapSense_REAL -#define SDL_CopyGPUQueryResultsToBuffer SDL_CopyGPUQueryResultsToBuffer_REAL +#define SDL_DownloadGPUQueryResults SDL_DownloadGPUQueryResults_REAL #define SDL_GetGPUTimestampFrequency SDL_GetGPUTimestampFrequency_REAL #define SDL_CreateGPUQueryPool SDL_CreateGPUQueryPool_REAL #define SDL_BeginGPUQuery SDL_BeginGPUQuery_REAL diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index b1415eca63..c099b31c77 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -1325,7 +1325,7 @@ SDL_DYNAPI_PROC(SDL_Surface*,SDL_LoadJPG,(const char *a),(a),return) SDL_DYNAPI_PROC(bool,SDL_HasSVE2,(void),(),return) SDL_DYNAPI_PROC(bool,SDL_GamepadHasCapSense,(SDL_Gamepad *a,SDL_GamepadCapSenseType b),(a,b),return) SDL_DYNAPI_PROC(bool,SDL_GetGamepadCapSense,(SDL_Gamepad *a,SDL_GamepadCapSenseType b),(a,b),return) -SDL_DYNAPI_PROC(void,SDL_CopyGPUQueryResultsToBuffer,(SDL_GPUCopyPass *a,SDL_GPUQueryPool *b,Uint32 c,Uint32 d,SDL_GPUBufferLocation *e),(a,b,c,d,e),) +SDL_DYNAPI_PROC(void,SDL_DownloadGPUQueryResults,(SDL_GPUCopyPass *a,SDL_GPUQueryPool *b,Uint32 c,Uint32 d,SDL_GPUTransferBufferLocation *e),(a,b,c,d,e),) SDL_DYNAPI_PROC(float,SDL_GetGPUTimestampFrequency,(SDL_GPUDevice *a),(a),return) SDL_DYNAPI_PROC(SDL_GPUQueryPool*,SDL_CreateGPUQueryPool,(SDL_GPUDevice *a,SDL_GPUQueryPoolCreateInfo *b),(a,b),return) SDL_DYNAPI_PROC(void,SDL_BeginGPUQuery,(SDL_GPUCommandBuffer *a,SDL_GPUQueryPool *b,Uint32 c),(a,b,c),) diff --git a/src/gpu/SDL_gpu.c b/src/gpu/SDL_gpu.c index 914e77c29a..fa57b49d33 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -3020,12 +3020,12 @@ void SDL_DownloadFromGPUBuffer( destination); } -void SDL_CopyGPUQueryResultsToBuffer( +void SDL_DownloadGPUQueryResults( SDL_GPUCopyPass *copy_pass, SDL_GPUQueryPool *pool, Uint32 first_query, Uint32 count, - SDL_GPUBufferLocation *destination) + SDL_GPUTransferBufferLocation *destination) { CHECK_PARAM(copy_pass == NULL) { SDL_InvalidParamError("copy_pass"); @@ -3042,7 +3042,7 @@ void SDL_CopyGPUQueryResultsToBuffer( return; } - COPYPASS_DEVICE->CopyQueryResultsToBuffer( + COPYPASS_DEVICE->DownloadQueryResults( COPYPASS_COMMAND_BUFFER, pool, first_query, diff --git a/src/gpu/SDL_sysgpu.h b/src/gpu/SDL_sysgpu.h index eba51afdb2..d5deb16666 100644 --- a/src/gpu/SDL_sysgpu.h +++ b/src/gpu/SDL_sysgpu.h @@ -995,12 +995,12 @@ struct SDL_GPUDevice Uint32 size, bool cycle); - void (*CopyQueryResultsToBuffer)( + void (*DownloadQueryResults)( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUQueryPool *pool, Uint32 first_query, Uint32 count, - const SDL_GPUBufferLocation *destination); + const SDL_GPUTransferBufferLocation *destination); void (*GenerateMipmaps)( SDL_GPUCommandBuffer *commandBuffer, @@ -1222,7 +1222,7 @@ struct SDL_GPUDevice ASSIGN_DRIVER_FUNC(DownloadFromBuffer, name) \ ASSIGN_DRIVER_FUNC(CopyTextureToTexture, name) \ ASSIGN_DRIVER_FUNC(CopyBufferToBuffer, name) \ - ASSIGN_DRIVER_FUNC(CopyQueryResultsToBuffer, name) \ + ASSIGN_DRIVER_FUNC(DownloadQueryResults, name) \ ASSIGN_DRIVER_FUNC(GenerateMipmaps, name) \ ASSIGN_DRIVER_FUNC(EndCopyPass, name) \ ASSIGN_DRIVER_FUNC(Blit, name) \ diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index a3915c578a..3cfbf2df84 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -9368,46 +9368,34 @@ static void VULKAN_CopyBufferToBuffer( SDL_UnlockRWLock(renderer->defragLock); } -static void VULKAN_CopyQueryResultsToBuffer( +static void VULKAN_DownloadQueryResults( SDL_GPUCommandBuffer *commandBuffer, SDL_GPUQueryPool *pool, Uint32 firstQuery, Uint32 count, - const SDL_GPUBufferLocation *destination) + const SDL_GPUTransferBufferLocation *destination) { VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer *)commandBuffer; VulkanRenderer *renderer = vulkanCommandBuffer->renderer; VulkanQueryPool *vulkanQueryPool = (VulkanQueryPool *)pool; - VulkanBufferContainer *dstContainer = (VulkanBufferContainer *)destination->buffer; + VulkanBufferContainer *dstContainer = (VulkanBufferContainer *)destination->transfer_buffer; SDL_LockRWLockForReading(renderer->defragLock); - VulkanBuffer *dstBuffer = VULKAN_INTERNAL_PrepareBufferForWrite( - renderer, - vulkanCommandBuffer, - dstContainer, - false, // TODO: should this function take a cycle param? - VULKAN_BUFFER_USAGE_MODE_COPY_DESTINATION); + // Note that the transfer buffer does not need a barrier, as it is synced by the client renderer->vkCmdCopyQueryPoolResults( vulkanCommandBuffer->commandBuffer, vulkanQueryPool->pool, firstQuery, count, - dstBuffer->buffer, + dstContainer->activeBuffer->buffer, destination->offset, 8, // Result for timing and occlusion is one 64-bit integer VK_QUERY_RESULT_64_BIT); - VULKAN_INTERNAL_BufferTransitionToDefaultUsage( - renderer, - vulkanCommandBuffer, - VULKAN_BUFFER_USAGE_MODE_COPY_DESTINATION, - dstBuffer); - VULKAN_INTERNAL_TrackQueryPool(vulkanCommandBuffer, vulkanQueryPool); - VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, dstBuffer); - VULKAN_INTERNAL_TrackBufferTransfer(vulkanCommandBuffer, dstBuffer); + VULKAN_INTERNAL_TrackBuffer(vulkanCommandBuffer, dstContainer->activeBuffer); SDL_UnlockRWLock(renderer->defragLock); }