diff --git a/include/Refresh.h b/include/Refresh.h index 04eb270..8d59dba 100644 --- a/include/Refresh.h +++ b/include/Refresh.h @@ -729,6 +729,19 @@ REFRESHAPI void REFRESH_DrawPrimitives( uint32_t fragmentParamOffset ); +/* Dispatches work compute items. + * + * groupCountX: Number of local workgroups to dispatch in the X dimension. + * groupCountY: Number of local workgroups to dispatch in the Y dimension. + * groupCountZ: Number of local workgroups to dispatch in the Z dimension. + */ +REFRESHAPI void REFRESH_DispatchCompute( + REFRESH_Device *device, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ +); + /* State Creation */ /* Returns an allocated RenderPass* object. */ @@ -1292,7 +1305,7 @@ REFRESHAPI void REFRESH_EndRenderPass( REFRESH_Device *device ); -/* Binds a pipeline to the graphics bind point. */ +/* Binds a graphics pipeline to the graphics bind point. */ REFRESHAPI void REFRESH_BindGraphicsPipeline( REFRESH_Device *device, REFRESH_GraphicsPipeline *graphicsPipeline @@ -1315,6 +1328,34 @@ REFRESHAPI void REFRESH_BindIndexBuffer( REFRESH_IndexElementSize indexElementSize ); +/* Binds a compute pipeline to the compute bind point. */ +REFRESHAPI void REFRESH_BindComputePipeline( + REFRESH_Device *device, + REFRESH_ComputePipeline *computePipeline +); + +/* Binds buffers for use with the currently bound compute pipeline. + * + * pBuffers: An array of buffers to bind. + * Length must be equal to the number of buffers + * specified by the compute pipeline. + */ +REFRESHAPI void REFRESH_BindComputeBuffers( + REFRESH_Device *device, + REFRESH_Buffer **pBuffers +); + +/* Binds textures for use with the currently bound compute pipeline. + * + * pTextures: An array of textures to bind. + * Length must be equal to the number of buffers + * specified by the compute pipeline. + */ +REFRESHAPI void REFRESH_BindComputeTextures( + REFRESH_Device *device, + REFRESH_Texture **pTextures +); + /* Submission/Presentation */ /* Queues an image to be presented to the screen. diff --git a/src/Refresh.c b/src/Refresh.c index 8f9c209..31d0ea4 100644 --- a/src/Refresh.c +++ b/src/Refresh.c @@ -241,6 +241,21 @@ void REFRESH_DrawPrimitives( ); } +void REFRESH_DispatchCompute( + REFRESH_Device *device, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ +) { + NULL_RETURN(device); + device->DispatchCompute( + device->driverData, + groupCountX, + groupCountY, + groupCountZ + ); +} + REFRESH_RenderPass* REFRESH_CreateRenderPass( REFRESH_Device *device, REFRESH_RenderPassCreateInfo *renderPassCreateInfo @@ -850,6 +865,39 @@ void REFRESH_BindIndexBuffer( ); } +void REFRESH_BindComputePipeline( + REFRESH_Device *device, + REFRESH_ComputePipeline *computePipeline +) { + NULL_RETURN(device); + device->BindComputePipeline( + device->driverData, + computePipeline + ); +} + +void REFRESH_BindComputeBuffers( + REFRESH_Device *device, + REFRESH_Buffer **pBuffers +) { + NULL_RETURN(device); + device->BindComputeBuffers( + device->driverData, + pBuffers + ); +} + +void REFRESH_BindComputeTextures( + REFRESH_Device *device, + REFRESH_Texture **pTextures +) { + NULL_RETURN(device); + device->BindComputeTextures( + device->driverData, + pTextures + ); +} + void REFRESH_QueuePresent( REFRESH_Device *device, REFRESH_TextureSlice* textureSlice, diff --git a/src/Refresh_Driver.h b/src/Refresh_Driver.h index 7df2285..6fbe843 100644 --- a/src/Refresh_Driver.h +++ b/src/Refresh_Driver.h @@ -212,6 +212,13 @@ struct REFRESH_Device uint32_t fragmentParamOffset ); + void (*DispatchCompute)( + REFRESH_Renderer *device, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ + ); + /* State Creation */ REFRESH_RenderPass* (*CreateRenderPass)( @@ -507,6 +514,21 @@ struct REFRESH_Device REFRESH_IndexElementSize indexElementSize ); + void(*BindComputePipeline)( + REFRESH_Renderer *driverData, + REFRESH_ComputePipeline *computePipeline + ); + + void(*BindComputeBuffers)( + REFRESH_Renderer *driverData, + REFRESH_Buffer **pBuffers + ); + + void(*BindComputeTextures)( + REFRESH_Renderer *driverData, + REFRESH_Texture **pTextures + ); + void(*QueuePresent)( REFRESH_Renderer *driverData, REFRESH_TextureSlice *textureSlice, @@ -530,6 +552,7 @@ struct REFRESH_Device ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \ + ASSIGN_DRIVER_FUNC(DispatchCompute, name) \ ASSIGN_DRIVER_FUNC(CreateRenderPass, name) \ ASSIGN_DRIVER_FUNC(CreateComputePipeline, name) \ ASSIGN_DRIVER_FUNC(CreateGraphicsPipeline, name) \ @@ -571,6 +594,9 @@ struct REFRESH_Device ASSIGN_DRIVER_FUNC(BindGraphicsPipeline, name) \ ASSIGN_DRIVER_FUNC(BindVertexBuffers, name) \ ASSIGN_DRIVER_FUNC(BindIndexBuffer, name) \ + ASSIGN_DRIVER_FUNC(BindComputePipeline, name) \ + ASSIGN_DRIVER_FUNC(BindComputeBuffers, name) \ + ASSIGN_DRIVER_FUNC(BindComputeTextures, name) \ ASSIGN_DRIVER_FUNC(QueuePresent, name) \ ASSIGN_DRIVER_FUNC(Submit, name) diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index 51ae5f9..c189d1d 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -3641,6 +3641,15 @@ static void VULKAN_DrawPrimitives( )); } +static void VULKAN_DispatchCompute( + REFRESH_Renderer *driverData, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ +) { + SDL_assert(0 && "Function not implemented!"); +} + static REFRESH_RenderPass* VULKAN_CreateRenderPass( REFRESH_Renderer *driverData, REFRESH_RenderPassCreateInfo *renderPassCreateInfo @@ -6938,6 +6947,27 @@ static void VULKAN_BindIndexBuffer( )); } +static void VULKAN_BindComputePipeline( + REFRESH_Renderer *driverData, + REFRESH_ComputePipeline *computePipeline +) { + SDL_assert(0 && "Function not implemented!"); +} + +static void VULKAN_BindComputeBuffers( + REFRESH_Renderer *driverData, + REFRESH_Buffer **pBuffers +) { + SDL_assert(0 && "Function not implemented!"); +} + +static void VULKAN_BindComputeTextures( + REFRESH_Renderer *driverData, + REFRESH_Texture **pTextures +) { + SDL_assert(0 && "Function not implemented!"); +} + static void VULKAN_QueuePresent( REFRESH_Renderer* driverData, REFRESH_TextureSlice* textureSlice,