CpuBuffer Set/Get API
continuous-integration/drone/push Build is failing Details

abi_break
cosmonaut 2024-02-17 20:21:52 -08:00
parent c44a095bca
commit 94f181787b
3 changed files with 91 additions and 6 deletions

View File

@ -327,6 +327,12 @@ typedef enum Refresh_BorderColor
REFRESH_BORDERCOLOR_INT_OPAQUE_WHITE
} Refresh_BorderColor;
typedef enum Refresh_SetDataOptions
{
REFRESH_SETDATAOPTIONS_DISCARD,
REFRESH_SETDATAOPTIONS_OVERWRITE
} Refresh_SetDataOptions;
typedef enum Refresh_Backend
{
REFRESH_BACKEND_DONTCARE,
@ -685,12 +691,10 @@ REFRESHAPI Refresh_GpuBuffer* Refresh_CreateGpuBuffer(
/* Creates a CpuBuffer.
*
* sizeInBytes: The length of the buffer.
* pDataPtr: On success, contains a pointer that can be used to copy to/from the buffer.
*/
REFRESHAPI Refresh_CpuBuffer* Refresh_CreateCpuBuffer(
Refresh_Device *device,
uint32_t sizeInBytes,
void **pDataPtr
uint32_t sizeInBytes
);
/* Disposal */
@ -1045,6 +1049,37 @@ REFRESHAPI void Refresh_EndComputePass(
Refresh_CommandBuffer *commandBuffer
);
/* CpuBuffer Set/Get */
/* Immediately copies data from a pointer into a CpuBuffer.
*
* option:
* DISCARD:
* If this CpuBuffer has been used in a copy command that has not completed,
* preserves the data in the issued copy commands at the cost of increased memory usage.
* Otherwise it simply overwrites.
* It is not recommended to use this option with large CpuBuffers.
*
* OVERWRITE:
* Overwrites the data regardless of whether a copy has been issued.
* Use this option with great care, as it can cause data races to occur!
*/
REFRESHAPI void Refresh_SetData(
Refresh_Device *device,
void* data,
Refresh_CpuBuffer *cpuBuffer,
Refresh_BufferCopy *copyParams,
Refresh_SetDataOptions option
);
/* Immediately copies data from a CpuBuffer into a pointer. */
REFRESHAPI void Refresh_GetData(
Refresh_Device *device,
Refresh_CpuBuffer *cpuBuffer,
void* data,
Refresh_BufferCopy *copyParams
);
/* Copy Pass */
/* Begins a copy pass. */
@ -1054,9 +1089,6 @@ REFRESHAPI void Refresh_BeginCopyPass(
);
/* CPU-to-GPU copies occur on the GPU timeline.
*
* You MUST NOT alter the data in the CpuBuffer
* until the command buffer has finished execution.
*
* You MAY assume that the copy has finished for subsequent commands.
*/

View File

@ -732,6 +732,40 @@ void Refresh_EndComputePass(
);
}
/* CpuBuffer Set/Get */
void Refresh_SetData(
Refresh_Device *device,
void* data,
Refresh_CpuBuffer *cpuBuffer,
Refresh_BufferCopy *copyParams,
Refresh_SetDataOptions option
) {
NULL_RETURN(device);
device->SetData(
device->driverData,
data,
cpuBuffer,
copyParams,
option
);
}
void Refresh_GetData(
Refresh_Device *device,
Refresh_CpuBuffer *cpuBuffer,
void* data,
Refresh_BufferCopy *copyParams
) {
NULL_RETURN(device);
device->GetData(
device->driverData,
cpuBuffer,
data,
copyParams
);
}
/* Copy Pass */
void Refresh_BeginCopyPass(

View File

@ -414,6 +414,23 @@ struct Refresh_Device
Refresh_CommandBuffer *commandBuffer
);
/* CpuBuffer Set/Get */
void (*SetData)(
Refresh_Renderer *driverData,
void* data,
Refresh_CpuBuffer *cpuBuffer,
Refresh_BufferCopy *copyParams,
Refresh_SetDataOptions option
);
void (*GetData)(
Refresh_Renderer *driverData,
Refresh_CpuBuffer *cpuBuffer,
void* data,
Refresh_BufferCopy *copyParams
);
/* Copy Pass */
void (*BeginCopyPass)(
@ -606,6 +623,8 @@ struct Refresh_Device
ASSIGN_DRIVER_FUNC(PushComputeShaderUniforms, name) \
ASSIGN_DRIVER_FUNC(DispatchCompute, name) \
ASSIGN_DRIVER_FUNC(EndComputePass, name) \
ASSIGN_DRIVER_FUNC(SetData, name) \
ASSIGN_DRIVER_FUNC(GetData, name) \
ASSIGN_DRIVER_FUNC(BeginCopyPass, name) \
ASSIGN_DRIVER_FUNC(UploadToTexture, name) \
ASSIGN_DRIVER_FUNC(UploadToBuffer, name) \