Buffer and Submission Rework (#1)

We used to have monolithic uniform buffers on the VulkanRenderer object, but this was inefficient in the case of threaded usage.

Now, we have a pool of uniform buffers. A uniform buffer is selected from the pool when a pipeline is bound. The uniform buffers are rotated upon presentation.

Now pushing uniforms is now a concern of the command buffer instead of the pipeline. The pipeline should just always have been a static object anyway.

Additionally, we now do extra buffer record-keeping so that buffer data can be updated after a bind/draw.

Fence submission has also been restructured so that submissions don't cause unnecessary blocks. Now we assign one fence per submission, and we don't wait for fences until it's time to present.

Reviewed-on: MoonsideGames/Refresh#1
Co-authored-by: cosmonaut <evan@moonside.games>
Co-committed-by: cosmonaut <evan@moonside.games>
submit_rewrite
cosmonaut 2022-01-12 22:41:10 +00:00
parent c51b4e95d2
commit 0e05ed6b34
4 changed files with 1747 additions and 1332 deletions

View File

@ -983,7 +983,7 @@ REFRESHAPI void Refresh_SetBufferData(
*/ */
REFRESHAPI uint32_t Refresh_PushVertexShaderUniforms( REFRESHAPI uint32_t Refresh_PushVertexShaderUniforms(
Refresh_Device *device, Refresh_Device *device,
Refresh_GraphicsPipeline *pipeline, Refresh_CommandBuffer * commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
); );
@ -1000,7 +1000,7 @@ REFRESHAPI uint32_t Refresh_PushVertexShaderUniforms(
*/ */
REFRESHAPI uint32_t Refresh_PushFragmentShaderUniforms( REFRESHAPI uint32_t Refresh_PushFragmentShaderUniforms(
Refresh_Device *device, Refresh_Device *device,
Refresh_GraphicsPipeline *pipeline, Refresh_CommandBuffer *commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
); );
@ -1017,7 +1017,7 @@ REFRESHAPI uint32_t Refresh_PushFragmentShaderUniforms(
*/ */
REFRESHAPI uint32_t Refresh_PushComputeShaderUniforms( REFRESHAPI uint32_t Refresh_PushComputeShaderUniforms(
Refresh_Device *device, Refresh_Device *device,
Refresh_ComputePipeline *pipeline, Refresh_CommandBuffer * commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
); );

View File

@ -470,14 +470,14 @@ void Refresh_SetBufferData(
uint32_t Refresh_PushVertexShaderUniforms( uint32_t Refresh_PushVertexShaderUniforms(
Refresh_Device *device, Refresh_Device *device,
Refresh_GraphicsPipeline *pipeline, Refresh_CommandBuffer *commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
) { ) {
if (device == NULL) { return 0; } if (device == NULL) { return 0; }
return device->PushVertexShaderUniforms( return device->PushVertexShaderUniforms(
device->driverData, device->driverData,
pipeline, commandBuffer,
data, data,
dataLengthInBytes dataLengthInBytes
); );
@ -485,14 +485,14 @@ uint32_t Refresh_PushVertexShaderUniforms(
uint32_t Refresh_PushFragmentShaderUniforms( uint32_t Refresh_PushFragmentShaderUniforms(
Refresh_Device *device, Refresh_Device *device,
Refresh_GraphicsPipeline * pipeline, Refresh_CommandBuffer *commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
) { ) {
if (device == NULL) { return 0; } if (device == NULL) { return 0; }
return device->PushFragmentShaderUniforms( return device->PushFragmentShaderUniforms(
device->driverData, device->driverData,
pipeline, commandBuffer,
data, data,
dataLengthInBytes dataLengthInBytes
); );
@ -500,14 +500,14 @@ uint32_t Refresh_PushFragmentShaderUniforms(
uint32_t Refresh_PushComputeShaderUniforms( uint32_t Refresh_PushComputeShaderUniforms(
Refresh_Device *device, Refresh_Device *device,
Refresh_ComputePipeline *pipeline, Refresh_CommandBuffer *commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
) { ) {
if (device == NULL) { return 0; } if (device == NULL) { return 0; }
return device->PushComputeShaderUniforms( return device->PushComputeShaderUniforms(
device->driverData, device->driverData,
pipeline, commandBuffer,
data, data,
dataLengthInBytes dataLengthInBytes
); );

View File

@ -314,21 +314,21 @@ struct Refresh_Device
uint32_t(*PushVertexShaderUniforms)( uint32_t(*PushVertexShaderUniforms)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_GraphicsPipeline* pipeline, Refresh_CommandBuffer *commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
); );
uint32_t(*PushFragmentShaderUniforms)( uint32_t(*PushFragmentShaderUniforms)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_GraphicsPipeline *pipeline, Refresh_CommandBuffer *commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
); );
uint32_t (*PushComputeShaderUniforms)( uint32_t (*PushComputeShaderUniforms)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_ComputePipeline *pipeline, Refresh_CommandBuffer *commandBuffer,
void *data, void *data,
uint32_t dataLengthInBytes uint32_t dataLengthInBytes
); );

File diff suppressed because it is too large Load Diff