add compute related functions to API

pull/8/head
cosmonaut 2020-12-29 17:31:39 -08:00 committed by thatcosmonaut
parent 602e669970
commit 5bddb9faab
4 changed files with 146 additions and 1 deletions

View File

@ -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.

View File

@ -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,

View File

@ -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)

View File

@ -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,