From 100e3d8c5af92710b84d3299d6c89aa31176df83 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Mon, 18 May 2026 16:55:31 -0700 Subject: [PATCH] Change GetTimestampFrequency to return float --- include/SDL3/SDL_gpu.h | 2 +- src/dynapi/SDL_dynapi_procs.h | 2 +- src/gpu/SDL_gpu.c | 7 +++++++ src/gpu/SDL_sysgpu.h | 5 +++++ src/gpu/vulkan/SDL_gpu_vulkan.c | 6 ++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/include/SDL3/SDL_gpu.h b/include/SDL3/SDL_gpu.h index 040b476675..320db4e54b 100644 --- a/include/SDL3/SDL_gpu.h +++ b/include/SDL3/SDL_gpu.h @@ -4571,7 +4571,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_ReleaseGPUFence( * * \sa SDL_CreateGPUQueryPool */ -extern SDL_DECLSPEC Uint64 SDLCALL SDL_GetGPUTimestampFrequency(SDL_GPUDevice *device); +extern SDL_DECLSPEC float SDLCALL SDL_GetGPUTimestampFrequency(SDL_GPUDevice *device); /** * Creates a query pool object to be used in queries. diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h index 1da1797a95..b1415eca63 100644 --- a/src/dynapi/SDL_dynapi_procs.h +++ b/src/dynapi/SDL_dynapi_procs.h @@ -1326,7 +1326,7 @@ 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(Uint64,SDL_GetGPUTimestampFrequency,(SDL_GPUDevice *a),(a),return) +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),) SDL_DYNAPI_PROC(void,SDL_EndGPUQuery,(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 bc7c106ef3..914e77c29a 100644 --- a/src/gpu/SDL_gpu.c +++ b/src/gpu/SDL_gpu.c @@ -3541,6 +3541,13 @@ void SDL_ReleaseGPUFence( fence); } +float SDL_GetGPUTimestampFrequency(SDL_GPUDevice *device) +{ + CHECK_DEVICE_MAGIC(device, 0); + + return device->GetTimestampFrequency(device->driverData); +} + SDL_GPUQueryPool *SDL_CreateGPUQueryPool( SDL_GPUDevice *device, SDL_GPUQueryPoolCreateInfo *createinfo) diff --git a/src/gpu/SDL_sysgpu.h b/src/gpu/SDL_sysgpu.h index 91f78b537b..eba51afdb2 100644 --- a/src/gpu/SDL_sysgpu.h +++ b/src/gpu/SDL_sysgpu.h @@ -1104,6 +1104,10 @@ struct SDL_GPUDevice SDL_GPURenderer *driverData, SDL_GPUFence *fence); + float (*GetTimestampFrequency)( + SDL_GPURenderer *device + ); + SDL_GPUQueryPool *(*CreateQueryPool)( SDL_GPURenderer *driverData, SDL_GPUQueryPoolCreateInfo *createinfo); @@ -1240,6 +1244,7 @@ struct SDL_GPUDevice ASSIGN_DRIVER_FUNC(WaitForFences, name) \ ASSIGN_DRIVER_FUNC(QueryFence, name) \ ASSIGN_DRIVER_FUNC(ReleaseFence, name) \ + ASSIGN_DRIVER_FUNC(GetTimestampFrequency, name) \ ASSIGN_DRIVER_FUNC(CreateQueryPool, name) \ ASSIGN_DRIVER_FUNC(BeginQuery, name) \ ASSIGN_DRIVER_FUNC(EndQuery, name) \ diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c index a2c00b8b57..a3915c578a 100644 --- a/src/gpu/vulkan/SDL_gpu_vulkan.c +++ b/src/gpu/vulkan/SDL_gpu_vulkan.c @@ -7123,6 +7123,12 @@ static SDL_GPUTransferBuffer *VULKAN_CreateTransferBuffer( debugName); } +static float VULKAN_GetTimestampFrequency(SDL_GPURenderer *driverData) +{ + VulkanRenderer *renderer = (VulkanRenderer *)driverData; + return renderer->physicalDeviceProperties.properties.limits.timestampPeriod; +} + static SDL_GPUQueryPool *VULKAN_CreateQueryPool( SDL_GPURenderer *driverData, SDL_GPUQueryPoolCreateInfo *createinfo)