mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-06-06 06:34:35 +00:00
Download results to transfer buffer
This commit is contained in:
parent
100e3d8c5a
commit
3441b18aa5
8 changed files with 20 additions and 32 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -1290,7 +1290,7 @@ _SDL_LoadJPG
|
|||
_SDL_HasSVE2
|
||||
_SDL_GamepadHasCapSense
|
||||
_SDL_GetGamepadCapSense
|
||||
_SDL_CopyGPUQueryResultsToBuffer
|
||||
_SDL_DownloadGPUQueryResults
|
||||
_SDL_GetGPUTimestampFrequency
|
||||
_SDL_CreateGPUQueryPool
|
||||
_SDL_BeginGPUQuery
|
||||
|
|
|
|||
|
|
@ -1291,7 +1291,7 @@ SDL3_0.0.0 {
|
|||
SDL_HasSVE2;
|
||||
SDL_GamepadHasCapSense;
|
||||
SDL_GetGamepadCapSense;
|
||||
SDL_CopyGPUQueryResultsToBuffer;
|
||||
SDL_DownloadGPUQueryResults;
|
||||
SDL_GetGPUTimestampFrequency;
|
||||
SDL_CreateGPUQueryPool;
|
||||
SDL_BeginGPUQuery;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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),)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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) \
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue