Compare commits

..

1 Commits

Author SHA1 Message Date
Caleb Cornett ca3c84d7fb Update template for latest ABI breaks 2022-03-05 09:35:05 -05:00
6 changed files with 425 additions and 547 deletions

View File

@ -8,8 +8,8 @@ option(BUILD_SHARED_LIBS "Build shared library" ON)
# Version # Version
SET(LIB_MAJOR_VERSION "1") SET(LIB_MAJOR_VERSION "1")
SET(LIB_MINOR_VERSION "5") SET(LIB_MINOR_VERSION "2")
SET(LIB_REVISION "0") SET(LIB_REVISION "1")
SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}") SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}")
# Build Type # Build Type

View File

@ -55,8 +55,8 @@ extern "C" {
/* Version API */ /* Version API */
#define REFRESH_MAJOR_VERSION 1 #define REFRESH_MAJOR_VERSION 1
#define REFRESH_MINOR_VERSION 5 #define REFRESH_MINOR_VERSION 2
#define REFRESH_PATCH_VERSION 0 #define REFRESH_PATCH_VERSION 1
#define REFRESH_COMPILED_VERSION ( \ #define REFRESH_COMPILED_VERSION ( \
(REFRESH_MAJOR_VERSION * 100 * 100) + \ (REFRESH_MAJOR_VERSION * 100 * 100) + \
@ -107,6 +107,15 @@ typedef enum Refresh_StoreOp
REFRESH_STOREOP_DONT_CARE REFRESH_STOREOP_DONT_CARE
} Refresh_StoreOp; } Refresh_StoreOp;
typedef enum Refresh_ClearOptionsBits
{
REFRESH_CLEAROPTIONS_COLOR = 0x00000001,
REFRESH_CLEAROPTIONS_DEPTH = 0x00000002,
REFRESH_CLEAROPTIONS_STENCIL = 0x00000004,
} Refresh_ClearOptionsBits;
typedef uint32_t Refresh_ClearOptions;
typedef enum Refresh_IndexElementSize typedef enum Refresh_IndexElementSize
{ {
REFRESH_INDEXELEMENTSIZE_16BIT, REFRESH_INDEXELEMENTSIZE_16BIT,
@ -124,7 +133,6 @@ typedef enum Refresh_TextureFormat
REFRESH_TEXTUREFORMAT_BC1, REFRESH_TEXTUREFORMAT_BC1,
REFRESH_TEXTUREFORMAT_BC2, REFRESH_TEXTUREFORMAT_BC2,
REFRESH_TEXTUREFORMAT_BC3, REFRESH_TEXTUREFORMAT_BC3,
REFRESH_TEXTUREFORMAT_BC7,
REFRESH_TEXTUREFORMAT_R8G8_SNORM, REFRESH_TEXTUREFORMAT_R8G8_SNORM,
REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM, REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM,
REFRESH_TEXTUREFORMAT_A2R10G10B10, REFRESH_TEXTUREFORMAT_A2R10G10B10,
@ -185,8 +193,7 @@ typedef uint32_t Refresh_BufferUsageFlags;
typedef enum Refresh_VertexElementFormat typedef enum Refresh_VertexElementFormat
{ {
REFRESH_VERTEXELEMENTFORMAT_UINT, REFRESH_VERTEXELEMENTFORMAT_SINGLE,
REFRESH_VERTEXELEMENTFORMAT_FLOAT,
REFRESH_VERTEXELEMENTFORMAT_VECTOR2, REFRESH_VERTEXELEMENTFORMAT_VECTOR2,
REFRESH_VERTEXELEMENTFORMAT_VECTOR3, REFRESH_VERTEXELEMENTFORMAT_VECTOR3,
REFRESH_VERTEXELEMENTFORMAT_VECTOR4, REFRESH_VERTEXELEMENTFORMAT_VECTOR4,
@ -488,6 +495,7 @@ typedef struct Refresh_RasterizerState
float depthBiasConstantFactor; float depthBiasConstantFactor;
float depthBiasClamp; float depthBiasClamp;
float depthBiasSlopeFactor; float depthBiasSlopeFactor;
float lineWidth;
} Refresh_RasterizerState; } Refresh_RasterizerState;
typedef struct Refresh_MultisampleState typedef struct Refresh_MultisampleState
@ -599,6 +607,30 @@ REFRESHAPI void Refresh_DestroyDevice(Refresh_Device *device);
/* Drawing */ /* Drawing */
/* Clears the targets of the currently bound framebuffer.
* If fewer colors are passed than the number of color targets in the
* framebuffer, this function will clear the first n color targets.
*
* NOTE:
* It is generally recommended to clear in BeginRenderPass
* rather than by calling this function unless necessary.
*
* clearRect: Area to clear.
* options: Bitflags to specify color/depth/stencil buffers for clearing.
* colors: An array of color values for the cleared color buffers.
* colorCount: The number of colors in the above array.
* depthStencil: Depth and stencil values for the cleared depth stencil buffer.
*/
REFRESHAPI void Refresh_Clear(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Vec4 *colors,
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
);
/* Draws data from vertex/index buffers with instancing enabled. /* Draws data from vertex/index buffers with instancing enabled.
* *
* baseVertex: The starting offset to read from the vertex buffer. * baseVertex: The starting offset to read from the vertex buffer.
@ -956,7 +988,6 @@ REFRESHAPI void Refresh_QueueDestroyGraphicsPipeline(
* The area affected by the render pass. * The area affected by the render pass.
* All load, store and resolve operations are restricted * All load, store and resolve operations are restricted
* to the given rectangle. * to the given rectangle.
* If NULL, a sensible default will be chosen.
* colorAttachmentInfos: * colorAttachmentInfos:
* A pointer to an array of Refresh_ColorAttachmentInfo structures * A pointer to an array of Refresh_ColorAttachmentInfo structures
* that contains render targets and clear values. May be NULL. * that contains render targets and clear values. May be NULL.
@ -1104,22 +1135,17 @@ REFRESHAPI Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
/* Acquires a texture to use for presentation. /* Acquires a texture to use for presentation.
* May return NULL under certain conditions. * May return NULL under certain conditions.
* If NULL, the user must ensure to not use the texture. * If NULL, the user must ensure to not present.
* Once a swapchain texture is acquired, * Once a swapchain texture is acquired,
* it will automatically be presented on command buffer submission. * it will automatically be presented on command buffer submission.
* *
* NOTE: * NOTE:
* It is not recommended to hold a reference to this texture long term. * It is not recommended to hold a reference to this texture long term.
*
* pWidth: A pointer to a uint32 that will be filled with the texture width.
* pHeight: A pointer to a uint32 that will be filled with the texture height.
*/ */
REFRESHAPI Refresh_Texture* Refresh_AcquireSwapchainTexture( REFRESHAPI Refresh_Texture* Refresh_AcquireSwapchainTexture(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
void *windowHandle, void *windowHandle
uint32_t *pWidth,
uint32_t *pHeight
); );
/* Returns the format of the swapchain for the given window. */ /* Returns the format of the swapchain for the given window. */

View File

@ -34,12 +34,7 @@
/* Drivers */ /* Drivers */
static const Refresh_Driver *drivers[] = { static const Refresh_Driver *drivers[] = {
#ifdef REFRESH_DRIVER_VULKAN
&VulkanDriver, &VulkanDriver,
#endif
#ifdef REFRESH_DRIVER_PS5
&PS5Driver,
#endif
NULL NULL
}; };
@ -152,6 +147,27 @@ void Refresh_DestroyDevice(Refresh_Device *device)
device->DestroyDevice(device); device->DestroyDevice(device);
} }
void Refresh_Clear(
Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Vec4 *colors,
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
) {
NULL_RETURN(device);
device->Clear(
device->driverData,
commandBuffer,
clearRect,
options,
colors,
colorCount,
depthStencil
);
}
void Refresh_DrawIndexedPrimitives( void Refresh_DrawIndexedPrimitives(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
@ -713,17 +729,13 @@ Refresh_CommandBuffer* Refresh_AcquireCommandBuffer(
Refresh_Texture* Refresh_AcquireSwapchainTexture( Refresh_Texture* Refresh_AcquireSwapchainTexture(
Refresh_Device *device, Refresh_Device *device,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
void *windowHandle, void *windowHandle
uint32_t *pWidth,
uint32_t *pHeight
) { ) {
NULL_RETURN_NULL(device); NULL_RETURN_NULL(device);
return device->AcquireSwapchainTexture( return device->AcquireSwapchainTexture(
device->driverData, device->driverData,
commandBuffer, commandBuffer,
windowHandle, windowHandle
pWidth,
pHeight
); );
} }

View File

@ -36,15 +36,9 @@
/* Logging */ /* Logging */
#ifdef __cplusplus extern void Refresh_LogInfo(const char *fmt, ...);
extern "C" { extern void Refresh_LogWarn(const char *fmt, ...);
#endif extern void Refresh_LogError(const char *fmt, ...);
void Refresh_LogInfo(const char *fmt, ...);
void Refresh_LogWarn(const char *fmt, ...);
void Refresh_LogError(const char *fmt, ...);
#ifdef __cplusplus
}
#endif
/* Internal Helper Utilities */ /* Internal Helper Utilities */
@ -57,7 +51,6 @@ static inline uint32_t Texture_GetFormatSize(
return 8; return 8;
case REFRESH_TEXTUREFORMAT_BC2: case REFRESH_TEXTUREFORMAT_BC2:
case REFRESH_TEXTUREFORMAT_BC3: case REFRESH_TEXTUREFORMAT_BC3:
case REFRESH_TEXTUREFORMAT_BC7:
return 16; return 16;
case REFRESH_TEXTUREFORMAT_R8: case REFRESH_TEXTUREFORMAT_R8:
return 1; return 1;
@ -124,8 +117,7 @@ static inline uint32_t BytesPerRow(
if ( format == REFRESH_TEXTUREFORMAT_BC1 || if ( format == REFRESH_TEXTUREFORMAT_BC1 ||
format == REFRESH_TEXTUREFORMAT_BC2 || format == REFRESH_TEXTUREFORMAT_BC2 ||
format == REFRESH_TEXTUREFORMAT_BC3 || format == REFRESH_TEXTUREFORMAT_BC3 )
format == REFRESH_TEXTUREFORMAT_BC7 )
{ {
blocksPerRow = (width + 3) / 4; blocksPerRow = (width + 3) / 4;
} }
@ -143,8 +135,7 @@ static inline int32_t BytesPerImage(
if ( format == REFRESH_TEXTUREFORMAT_BC1 || if ( format == REFRESH_TEXTUREFORMAT_BC1 ||
format == REFRESH_TEXTUREFORMAT_BC2 || format == REFRESH_TEXTUREFORMAT_BC2 ||
format == REFRESH_TEXTUREFORMAT_BC3 || format == REFRESH_TEXTUREFORMAT_BC3 )
format == REFRESH_TEXTUREFORMAT_BC7 )
{ {
blocksPerRow = (width + 3) / 4; blocksPerRow = (width + 3) / 4;
blocksPerColumn = (height + 3) / 4; blocksPerColumn = (height + 3) / 4;
@ -177,6 +168,16 @@ struct Refresh_Device
/* Drawing */ /* Drawing */
void (*Clear)(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Vec4 *colors,
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
);
void (*DrawInstancedPrimitives)( void (*DrawInstancedPrimitives)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
@ -450,9 +451,7 @@ struct Refresh_Device
Refresh_Texture* (*AcquireSwapchainTexture)( Refresh_Texture* (*AcquireSwapchainTexture)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
void *windowHandle, void *windowHandle
uint32_t *pWidth,
uint32_t *pHeight
); );
Refresh_TextureFormat (*GetSwapchainFormat)( Refresh_TextureFormat (*GetSwapchainFormat)(
@ -478,6 +477,7 @@ struct Refresh_Device
result->func = name##_##func; result->func = name##_##func;
#define ASSIGN_DRIVER(name) \ #define ASSIGN_DRIVER(name) \
ASSIGN_DRIVER_FUNC(DestroyDevice, name) \ ASSIGN_DRIVER_FUNC(DestroyDevice, name) \
ASSIGN_DRIVER_FUNC(Clear, name) \
ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \
ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \ ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \
@ -531,7 +531,6 @@ typedef struct Refresh_Driver
} Refresh_Driver; } Refresh_Driver;
extern Refresh_Driver VulkanDriver; extern Refresh_Driver VulkanDriver;
extern Refresh_Driver PS5Driver;
#endif /* REFRESH_DRIVER_H */ #endif /* REFRESH_DRIVER_H */

View File

@ -37,7 +37,7 @@
static TEMPLATE_SURFACE_FORMAT_TYPE RefreshToTEMPLATE_SurfaceFormat[] = static TEMPLATE_SURFACE_FORMAT_TYPE RefreshToTEMPLATE_SurfaceFormat[] =
{ {
0, /* R8G8B8A8 */ 0, /* R8G8B8A8 */
0, /* B8G8R8A8 */ 0 /* B8G8R8A8 */
0, /* R5G6B5 */ 0, /* R5G6B5 */
0, /* A1R5G5B5 */ 0, /* A1R5G5B5 */
0, /* B4G4R4A4 */ 0, /* B4G4R4A4 */
@ -97,6 +97,7 @@ static TEMPLATE_POLYGON_MODE_TYPE RefreshToTEMPLATE_PolygonMode[] =
{ {
0, /* FILL */ 0, /* FILL */
0, /* LINE */ 0, /* LINE */
0 /* POINT */
}; };
static TEMPLATE_CULL_MODE_TYPE RefreshToTEMPLATE_CullMode[] = static TEMPLATE_CULL_MODE_TYPE RefreshToTEMPLATE_CullMode[] =
@ -104,6 +105,7 @@ static TEMPLATE_CULL_MODE_TYPE RefreshToTEMPLATE_CullMode[] =
0, /* NONE */ 0, /* NONE */
0, /* FRONT */ 0, /* FRONT */
0, /* BACK */ 0, /* BACK */
0 /* FRONT_AND_BACK */
}; };
static TEMPLATE_FRONT_FACE_TYPE RefreshToTEMPLATE_FrontFace[] = static TEMPLATE_FRONT_FACE_TYPE RefreshToTEMPLATE_FrontFace[] =
@ -126,6 +128,8 @@ static TEMPLATE_BLEND_FACTOR_TYPE RefreshToTEMPLATE_BlendFactor[] =
0, /* ONE_MINUS_DST_ALPHA */ 0, /* ONE_MINUS_DST_ALPHA */
0, /* CONSTANT_COLOR */ 0, /* CONSTANT_COLOR */
0, /* ONE_MINUS_CONSTANT_COLOR */ 0, /* ONE_MINUS_CONSTANT_COLOR */
0, /* CONSTANT_ALPHA */
0, /* ONE_MINUS_CONSTANT_ALPHA */
0, /* SRC_ALPHA_SATURATE */ 0, /* SRC_ALPHA_SATURATE */
0, /* SRC1_COLOR */ 0, /* SRC1_COLOR */
0, /* ONE_MINUS_SRC1_COLOR */ 0, /* ONE_MINUS_SRC1_COLOR */
@ -142,6 +146,26 @@ static TEMPLATE_BLEND_OP_TYPE RefreshToTEMPLATE_BlendOp[] =
0 /* MAX */ 0 /* MAX */
}; };
static TEMPLATE_LOGIC_OP_TYPE RefreshToTEMPLATE_LogicOp[] =
{
0, /* CLEAR */
0, /* AND */
0, /* AND_REVERSE */
0, /* COPY */
0, /* AND_INVERTED */
0, /* NO_OP */
0, /* XOR */
0, /* OR */
0, /* NOR */
0, /* EQUIVALENT */
0, /* INVERT */
0, /* OR_REVERSE */
0, /* COPY_INVERTED */
0, /* OR_INVERTED */
0, /* NAND */
0 /* SET */
};
static TEMPLATE_COMPARE_OP_TYPE RefreshToTEMPLATE_CompareOp[] = static TEMPLATE_COMPARE_OP_TYPE RefreshToTEMPLATE_CompareOp[] =
{ {
0, /* NEVER */ 0, /* NEVER */
@ -200,6 +224,7 @@ static TEMPLATE_FILTER_TYPE RefreshToTEMPLATE_Filter[] =
{ {
0, /* NEAREST */ 0, /* NEAREST */
0, /* LINEAR */ 0, /* LINEAR */
0 /* CUBIC */
}; };
static TEMPLATE_SAMPLER_MIPMAP_MODE_TYPE RefreshToTEMPLATE_SamplerMipmapMode[] = static TEMPLATE_SAMPLER_MIPMAP_MODE_TYPE RefreshToTEMPLATE_SamplerMipmapMode[] =
@ -236,6 +261,18 @@ static void TEMPLATE_DestroyDevice(
/* Drawing */ /* Drawing */
static void TEMPLATE_Clear(
Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer,
Refresh_Rect *clearRect,
Refresh_ClearOptions options,
Refresh_Vec4 *colors,
uint32_t colorCount,
Refresh_DepthStencilValue depthStencil
) {
NOT_IMPLEMENTED
}
static void TEMPLATE_DrawInstancedPrimitives( static void TEMPLATE_DrawInstancedPrimitives(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
@ -586,9 +623,7 @@ static Refresh_CommandBuffer* TEMPLATE_AcquireCommandBuffer(
Refresh_Texture* TEMPLATE_AcquireSwapchainTexture( Refresh_Texture* TEMPLATE_AcquireSwapchainTexture(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_CommandBuffer *commandBuffer, Refresh_CommandBuffer *commandBuffer,
void *windowHandle, void *windowHandle
uint32_t *pWidth,
uint32_t *pHeight
) { ) {
NOT_IMPLEMENTED NOT_IMPLEMENTED
} }

File diff suppressed because it is too large Load Diff