Download results to transfer buffer

This commit is contained in:
Evan Hemsley 2026-05-18 17:47:48 -07:00
parent 100e3d8c5a
commit 3441b18aa5
8 changed files with 20 additions and 32 deletions

View file

@ -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(

View file

@ -1290,7 +1290,7 @@ _SDL_LoadJPG
_SDL_HasSVE2
_SDL_GamepadHasCapSense
_SDL_GetGamepadCapSense
_SDL_CopyGPUQueryResultsToBuffer
_SDL_DownloadGPUQueryResults
_SDL_GetGPUTimestampFrequency
_SDL_CreateGPUQueryPool
_SDL_BeginGPUQuery

View file

@ -1291,7 +1291,7 @@ SDL3_0.0.0 {
SDL_HasSVE2;
SDL_GamepadHasCapSense;
SDL_GetGamepadCapSense;
SDL_CopyGPUQueryResultsToBuffer;
SDL_DownloadGPUQueryResults;
SDL_GetGPUTimestampFrequency;
SDL_CreateGPUQueryPool;
SDL_BeginGPUQuery;

View file

@ -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

View file

@ -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),)

View file

@ -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,

View file

@ -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) \

View file

@ -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);
}