shader param buffer stuff

pull/8/head
cosmonaut 2020-12-16 15:15:42 -08:00
parent fddba3a94d
commit 1d152a61bf
1 changed files with 95 additions and 34 deletions

View File

@ -55,16 +55,14 @@ extern "C" {
/* Type Declarations */ /* Type Declarations */
typedef struct REFRESH_Device REFRESH_Device; typedef struct REFRESH_Device REFRESH_Device;
typedef struct REFRESH_Buffer REFRESH_Buffer;
typedef struct REFRESH_Texture REFRESH_Texture; typedef struct REFRESH_Texture REFRESH_Texture;
typedef struct REFRESH_Sampler REFRESH_Sampler; typedef struct REFRESH_Sampler REFRESH_Sampler;
typedef struct REFRESH_ShaderParamBuffer REFRESH_ShaderParamBuffer;
typedef struct REFRESH_Buffer REFRESH_Buffer;
typedef struct REFRESH_ColorTarget REFRESH_ColorTarget; typedef struct REFRESH_ColorTarget REFRESH_ColorTarget;
typedef struct REFRESH_DepthStencilTarget REFRESH_DepthStencilTarget; typedef struct REFRESH_DepthStencilTarget REFRESH_DepthStencilTarget;
typedef struct REFRESH_Framebuffer REFRESH_Framebuffer; typedef struct REFRESH_Framebuffer REFRESH_Framebuffer;
typedef struct REFRESH_ShaderModule REFRESH_ShaderModule; typedef struct REFRESH_ShaderModule REFRESH_ShaderModule;
typedef struct REFRESH_RenderPass REFRESH_RenderPass; typedef struct REFRESH_RenderPass REFRESH_RenderPass;
typedef struct REFRESH_ComputePipeline REFRESH_ComputePipeline;
typedef struct REFRESH_GraphicsPipeline REFRESH_GraphicsPipeline; typedef struct REFRESH_GraphicsPipeline REFRESH_GraphicsPipeline;
typedef enum REFRESH_PrimitiveType typedef enum REFRESH_PrimitiveType
@ -800,6 +798,15 @@ REFRESHAPI REFRESH_Buffer* REFRESH_GenIndexBuffer(
uint32_t sizeInBytes uint32_t sizeInBytes
); );
/* Creates a shader param buffer to be used by shaders.
*
* sizeInBytes: The length of the shader param buffer.
*/
REFRESHAPI REFRESH_Buffer* REFRESH_GenShaderParamBuffer(
REFRESH_Device *device,
uint32_t sizeInBytes
);
/* Setters */ /* Setters */
/* Uploads image data to a 2D texture object. /* Uploads image data to a 2D texture object.
@ -964,23 +971,17 @@ REFRESHAPI void REFRESH_SetFragmentSamplers(
uint32_t count uint32_t count
); );
/* Sets shader params for use with the currently bound vertex shader. /* Pushes shader param data to a buffer.
* *
* TODO: Do we need to give the user this much control over UBOs? * shaderParamBuffer: The buffer to be updated.
* offsetInBytes: The starting offset of the buffer to write into.
* data: The client data to write into the buffer.
* elementCount: The number of elements from the client buffer to write.
* elementSizeInBytes: The size of each element in the client buffer.
*/ */
REFRESHAPI void REFRESH_SetVertexShaderParamData( REFRESHAPI void REFRESH_SetShaderParamData(
REFRESH_Device *device, REFRESH_Device *device,
REFRESH_ShaderParamBuffer *shaderParamBuffer, REFRESH_Buffer *shaderParamBuffer,
uint32_t offsetInBytes,
void *data,
uint32_t elementCount,
uint32_t elementSizeInBytes
);
/* Sets shader params for use with the currently bound fragment shader. */
REFRESHAPI void REFRESH_SetFragmentShaderParamData(
REFRESH_Device *device,
REFRESH_ShaderParamBuffer *shaderParamBuffer,
uint32_t offsetInBytes, uint32_t offsetInBytes,
void *data, void *data,
uint32_t elementCount, uint32_t elementCount,
@ -1056,28 +1057,16 @@ REFRESHAPI void REFRESH_AddDisposeTexture(
REFRESH_Texture *texture REFRESH_Texture *texture
); );
/* Sends a color target to be destroyed by the renderer. Note that we call it /* Sends a sampler to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if * "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector * this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer). * deletes the resource instead of the programmer).
* *
* colorTarget: The REFRESH_ColorTarget to be destroyed. * texture: The REFRESH_Sampler to be destroyed.
*/ */
REFRESHAPI void REFRESH_AddDisposeColorTarget( REFRESHAPI void REFRESH_AddDisposeSampler(
REFRESH_Device *device, REFRESH_Device *device,
REFRESH_ColorTarget *colorTarget REFRESH_Sampler *sampler
);
/* Sends a depth/stencil target to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* depthStencilTarget: The REFRESH_DepthStencilTarget to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeDepthStencilTarget(
REFRESH_Device *device,
REFRESH_DepthStencilTarget *depthStencilTarget
); );
/* Sends a vertex buffer to be destroyed by the renderer. Note that we call it /* Sends a vertex buffer to be destroyed by the renderer. Note that we call it
@ -1104,7 +1093,55 @@ REFRESHAPI void REFRESH_AddDisposeIndexBuffer(
REFRESH_Buffer *buffer REFRESH_Buffer *buffer
); );
/* Sends an shader module to be destroyed by the renderer. Note that we call it /* Sends an shader param buffer to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* buffer: The REFRESH_Buffer to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeShaderParamBuffer(
REFRESH_Device *device,
REFRESH_Buffer *buffer
);
/* Sends a color target to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* colorTarget: The REFRESH_ColorTarget to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeColorTarget(
REFRESH_Device *device,
REFRESH_ColorTarget *colorTarget
);
/* Sends a depth/stencil target to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* depthStencilTarget: The REFRESH_DepthStencilTarget to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeDepthStencilTarget(
REFRESH_Device *device,
REFRESH_DepthStencilTarget *depthStencilTarget
);
/* Sends a framebuffer to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* framebuffer: The REFRESH_Framebuffer to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeFramebuffer(
REFRESH_Device *device,
REFRESH_Framebuffer *frameBuffer
);
/* Sends a shader module to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if * "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector * this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer). * deletes the resource instead of the programmer).
@ -1116,6 +1153,30 @@ REFRESHAPI void REFRESH_AddDisposeShaderModule(
REFRESH_ShaderModule *shaderModule REFRESH_ShaderModule *shaderModule
); );
/* Sends a render pass to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* renderPass: The REFRESH_RenderPass to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeRenderPass(
REFRESH_Device *device,
REFRESH_RenderPass *renderPass
);
/* Sends a graphics pipeline to be destroyed by the renderer. Note that we call it
* "AddDispose" because it may not be immediately destroyed by the renderer if
* this is not called from the main thread (for example, if a garbage collector
* deletes the resource instead of the programmer).
*
* graphicsPipeline: The REFRESH_GraphicsPipeline to be destroyed.
*/
REFRESHAPI void REFRESH_AddDisposeGraphicsPipeline(
REFRESH_Device *device,
REFRESH_GraphicsPipeline *graphicsPipeline
);
/* Graphics State */ /* Graphics State */
/* Begins a render pass. /* Begins a render pass.