presentation loop

submit_rewrite
cosmonaut 2020-12-21 15:44:43 -08:00
parent 6827eea6d3
commit 06b805cf93
4 changed files with 887 additions and 396 deletions

View File

@ -932,8 +932,8 @@ REFRESHAPI void REFRESH_SetTextureDataYUV(
* *
* NOTE: * NOTE:
* Calling this function on a buffer after the buffer * Calling this function on a buffer after the buffer
* has been bound by BindVertexBuffers but before * has been bound by BindVertexBuffers without calling
* Present has been called is an error. * Submit first is an error.
* *
* buffer: The vertex buffer to be updated. * buffer: The vertex buffer to be updated.
* offsetInBytes: The starting offset of the buffer to write into. * offsetInBytes: The starting offset of the buffer to write into.
@ -954,8 +954,8 @@ REFRESHAPI void REFRESH_SetVertexBufferData(
* *
* NOTE: * NOTE:
* Calling this function on a buffer after the buffer * Calling this function on a buffer after the buffer
* has been bound by BindIndexBuffer but before * has been bound by BindIndexBuffer without calling
* Present has been called is an error. * Submit first is an error.
* *
* buffer: The index buffer to be updated. * buffer: The index buffer to be updated.
* offsetInBytes: The starting offset of the buffer to write into. * offsetInBytes: The starting offset of the buffer to write into.
@ -1249,6 +1249,7 @@ REFRESHAPI void REFRESH_BindGraphicsPipeline(
REFRESH_GraphicsPipeline *graphicsPipeline REFRESH_GraphicsPipeline *graphicsPipeline
); );
/* Binds vertex buffers for use with subsequent draw calls. */
REFRESHAPI void REFRESH_BindVertexBuffers( REFRESHAPI void REFRESH_BindVertexBuffers(
REFRESH_Device *device, REFRESH_Device *device,
uint32_t firstBinding, uint32_t firstBinding,
@ -1257,6 +1258,7 @@ REFRESHAPI void REFRESH_BindVertexBuffers(
uint64_t *pOffsets uint64_t *pOffsets
); );
/* Binds an index buffer for use with subsequent draw calls. */
REFRESHAPI void REFRESH_BindIndexBuffer( REFRESHAPI void REFRESH_BindIndexBuffer(
REFRESH_Device *device, REFRESH_Device *device,
REFRESH_Buffer *buffer, REFRESH_Buffer *buffer,
@ -1264,14 +1266,30 @@ REFRESHAPI void REFRESH_BindIndexBuffer(
REFRESH_IndexElementSize indexElementSize REFRESH_IndexElementSize indexElementSize
); );
/* Presentation */ /* Submission/Presentation */
REFRESHAPI void REFRESH_Present( /* Prepares for an image to be presented to the screen.
* The image will be presented upon the next REFRESH_Submit call.
*
* NOTE:
* It is an error to call this function in headless mode.
*
* texture: The image to present.
* sourceRectangle: The region of the image to present (or NULL).
* destinationRectangle: The region of the window to update (or NULL).
*/
REFRESHAPI void REFRESH_PreparePresent(
REFRESH_Device *device, REFRESH_Device *device,
REFRESH_Texture* texture,
REFRESH_Rect *sourceRectangle, REFRESH_Rect *sourceRectangle,
REFRESH_Rect *destinationRectangle REFRESH_Rect *destinationRectangle
); );
/* Submits all of the enqueued commands. */
REFRESHAPI void REFRESH_Submit(
REFRESH_Device* device
);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */

View File

@ -346,7 +346,7 @@ REFRESH_Texture* REFRESH_CreateTextureCube(
REFRESH_ColorTarget* REFRESH_GenColorTarget( REFRESH_ColorTarget* REFRESH_GenColorTarget(
REFRESH_Device *device, REFRESH_Device *device,
uint32_t multisampleCount, REFRESH_SampleCount multisampleCount,
REFRESH_TextureSlice textureSlice REFRESH_TextureSlice textureSlice
) { ) {
NULL_RETURN_NULL(device); NULL_RETURN_NULL(device);
@ -835,17 +835,28 @@ void REFRESH_BindIndexBuffer(
); );
} }
void REFRESH_Present( void REFRESH_PreparePresent(
REFRESH_Device *device, REFRESH_Device *device,
REFRESH_Texture *texture,
REFRESH_Rect *sourceRectangle, REFRESH_Rect *sourceRectangle,
REFRESH_Rect *destinationRectangle REFRESH_Rect *destinationRectangle
) { ) {
NULL_RETURN(device); NULL_RETURN(device);
device->Present( device->PreparePresent(
device->driverData, device->driverData,
texture,
sourceRectangle, sourceRectangle,
destinationRectangle destinationRectangle
); );
} }
void REFRESH_Submit(
REFRESH_Device *device
) {
NULL_RETURN(device);
device->Submit(
device->driverData
);
}
/* vim: set noexpandtab shiftwidth=8 tabstop=8: */ /* vim: set noexpandtab shiftwidth=8 tabstop=8: */

View File

@ -268,7 +268,7 @@ struct REFRESH_Device
REFRESH_ColorTarget* (*GenColorTarget)( REFRESH_ColorTarget* (*GenColorTarget)(
REFRESH_Renderer *driverData, REFRESH_Renderer *driverData,
uint32_t multisampleCount, REFRESH_SampleCount multisampleCount,
REFRESH_TextureSlice textureSlice REFRESH_TextureSlice textureSlice
); );
@ -505,12 +505,17 @@ struct REFRESH_Device
REFRESH_IndexElementSize indexElementSize REFRESH_IndexElementSize indexElementSize
); );
void(*Present)( void(*PreparePresent)(
REFRESH_Renderer *driverData, REFRESH_Renderer *driverData,
REFRESH_Texture *texture,
REFRESH_Rect *sourceRectangle, REFRESH_Rect *sourceRectangle,
REFRESH_Rect *destinationRectangle REFRESH_Rect *destinationRectangle
); );
void(*Submit)(
REFRESH_Renderer *driverData
);
/* Opaque pointer for the Driver */ /* Opaque pointer for the Driver */
REFRESH_Renderer *driverData; REFRESH_Renderer *driverData;
}; };
@ -562,7 +567,8 @@ struct REFRESH_Device
ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \ ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \
ASSIGN_DRIVER_FUNC(BindVertexBuffers, name) \ ASSIGN_DRIVER_FUNC(BindVertexBuffers, name) \
ASSIGN_DRIVER_FUNC(BindIndexBuffer, name) \ ASSIGN_DRIVER_FUNC(BindIndexBuffer, name) \
ASSIGN_DRIVER_FUNC(Present, name) ASSIGN_DRIVER_FUNC(PreparePresent, name) \
ASSIGN_DRIVER_FUNC(Submit, name)
typedef struct REFRESH_Driver typedef struct REFRESH_Driver
{ {

File diff suppressed because it is too large Load Diff