forked from MoonsideGames/Refresh
				
			Compare commits
	
		
			1 Commits 
		
	
	
		
			main
			...
			ca3c84d7fb
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | ca3c84d7fb | 
|  | @ -8,8 +8,8 @@ option(BUILD_SHARED_LIBS "Build shared library" ON) | |||
| 
 | ||||
| # Version | ||||
| SET(LIB_MAJOR_VERSION "1") | ||||
| SET(LIB_MINOR_VERSION "5") | ||||
| SET(LIB_REVISION "0") | ||||
| SET(LIB_MINOR_VERSION "2") | ||||
| SET(LIB_REVISION "1") | ||||
| SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}") | ||||
| 
 | ||||
| # Build Type | ||||
|  |  | |||
|  | @ -55,8 +55,8 @@ extern "C" { | |||
| /* Version API */ | ||||
| 
 | ||||
| #define REFRESH_MAJOR_VERSION   1 | ||||
| #define REFRESH_MINOR_VERSION	5 | ||||
| #define REFRESH_PATCH_VERSION	0 | ||||
| #define REFRESH_MINOR_VERSION	2 | ||||
| #define REFRESH_PATCH_VERSION	1 | ||||
| 
 | ||||
| #define REFRESH_COMPILED_VERSION ( \ | ||||
| 	(REFRESH_MAJOR_VERSION * 100 * 100) + \ | ||||
|  | @ -107,6 +107,15 @@ typedef enum Refresh_StoreOp | |||
| 	REFRESH_STOREOP_DONT_CARE | ||||
| } 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 | ||||
| { | ||||
| 	REFRESH_INDEXELEMENTSIZE_16BIT, | ||||
|  | @ -124,7 +133,6 @@ typedef enum Refresh_TextureFormat | |||
| 	REFRESH_TEXTUREFORMAT_BC1, | ||||
| 	REFRESH_TEXTUREFORMAT_BC2, | ||||
| 	REFRESH_TEXTUREFORMAT_BC3, | ||||
| 	REFRESH_TEXTUREFORMAT_BC7, | ||||
| 	REFRESH_TEXTUREFORMAT_R8G8_SNORM, | ||||
| 	REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM, | ||||
| 	REFRESH_TEXTUREFORMAT_A2R10G10B10, | ||||
|  | @ -185,8 +193,7 @@ typedef uint32_t Refresh_BufferUsageFlags; | |||
| 
 | ||||
| typedef enum Refresh_VertexElementFormat | ||||
| { | ||||
| 	REFRESH_VERTEXELEMENTFORMAT_UINT, | ||||
| 	REFRESH_VERTEXELEMENTFORMAT_FLOAT, | ||||
| 	REFRESH_VERTEXELEMENTFORMAT_SINGLE, | ||||
| 	REFRESH_VERTEXELEMENTFORMAT_VECTOR2, | ||||
| 	REFRESH_VERTEXELEMENTFORMAT_VECTOR3, | ||||
| 	REFRESH_VERTEXELEMENTFORMAT_VECTOR4, | ||||
|  | @ -488,6 +495,7 @@ typedef struct Refresh_RasterizerState | |||
| 	float depthBiasConstantFactor; | ||||
| 	float depthBiasClamp; | ||||
| 	float depthBiasSlopeFactor; | ||||
| 	float lineWidth; | ||||
| } Refresh_RasterizerState; | ||||
| 
 | ||||
| typedef struct Refresh_MultisampleState | ||||
|  | @ -599,6 +607,30 @@ REFRESHAPI void Refresh_DestroyDevice(Refresh_Device *device); | |||
| 
 | ||||
| /* 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.
 | ||||
|  * | ||||
|  * 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. | ||||
|  * 		All load, store and resolve operations are restricted | ||||
|  * 		to the given rectangle. | ||||
|  * 		If NULL, a sensible default will be chosen. | ||||
|  * colorAttachmentInfos: | ||||
|  * 		A pointer to an array of Refresh_ColorAttachmentInfo structures | ||||
|  * 		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.
 | ||||
|  * 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, | ||||
|  * it will automatically be presented on command buffer submission. | ||||
|  * | ||||
|  * NOTE: | ||||
|  * 	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( | ||||
| 	Refresh_Device *device, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
| 	void *windowHandle, | ||||
| 	uint32_t *pWidth, | ||||
| 	uint32_t *pHeight | ||||
| 	void *windowHandle | ||||
| ); | ||||
| 
 | ||||
| /* Returns the format of the swapchain for the given window. */ | ||||
|  |  | |||
|  | @ -34,12 +34,7 @@ | |||
| /* Drivers */ | ||||
| 
 | ||||
| static const Refresh_Driver *drivers[] = { | ||||
| #ifdef REFRESH_DRIVER_VULKAN | ||||
| 	&VulkanDriver, | ||||
| #endif | ||||
| #ifdef REFRESH_DRIVER_PS5 | ||||
| 	&PS5Driver, | ||||
| #endif | ||||
| 	NULL | ||||
| }; | ||||
| 
 | ||||
|  | @ -152,6 +147,27 @@ void Refresh_DestroyDevice(Refresh_Device *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( | ||||
| 	Refresh_Device *device, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
|  | @ -713,17 +729,13 @@ Refresh_CommandBuffer* Refresh_AcquireCommandBuffer( | |||
| Refresh_Texture* Refresh_AcquireSwapchainTexture( | ||||
| 	Refresh_Device *device, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
| 	void *windowHandle, | ||||
| 	uint32_t *pWidth, | ||||
| 	uint32_t *pHeight | ||||
| 	void *windowHandle | ||||
| ) { | ||||
| 	NULL_RETURN_NULL(device); | ||||
| 	return device->AcquireSwapchainTexture( | ||||
| 		device->driverData, | ||||
| 		commandBuffer, | ||||
| 		windowHandle, | ||||
| 		pWidth, | ||||
| 		pHeight | ||||
| 		windowHandle | ||||
| 	); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -36,15 +36,9 @@ | |||
| 
 | ||||
| /* Logging */ | ||||
| 
 | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
| void Refresh_LogInfo(const char *fmt, ...); | ||||
| void Refresh_LogWarn(const char *fmt, ...); | ||||
| void Refresh_LogError(const char *fmt, ...); | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
| extern void Refresh_LogInfo(const char *fmt, ...); | ||||
| extern void Refresh_LogWarn(const char *fmt, ...); | ||||
| extern void Refresh_LogError(const char *fmt, ...); | ||||
| 
 | ||||
| /* Internal Helper Utilities */ | ||||
| 
 | ||||
|  | @ -57,7 +51,6 @@ static inline uint32_t Texture_GetFormatSize( | |||
| 			return 8; | ||||
| 		case REFRESH_TEXTUREFORMAT_BC2: | ||||
| 		case REFRESH_TEXTUREFORMAT_BC3: | ||||
| 		case REFRESH_TEXTUREFORMAT_BC7: | ||||
| 			return 16; | ||||
| 		case REFRESH_TEXTUREFORMAT_R8: | ||||
| 			return 1; | ||||
|  | @ -124,8 +117,7 @@ static inline uint32_t BytesPerRow( | |||
| 
 | ||||
| 	if (	format == REFRESH_TEXTUREFORMAT_BC1 || | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC2 || | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC3 || | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC7	) | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC3	) | ||||
| 	{ | ||||
| 		blocksPerRow = (width + 3) / 4; | ||||
| 	} | ||||
|  | @ -143,8 +135,7 @@ static inline int32_t BytesPerImage( | |||
| 
 | ||||
| 	if (	format == REFRESH_TEXTUREFORMAT_BC1 || | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC2 || | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC3 || | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC7	) | ||||
| 		format == REFRESH_TEXTUREFORMAT_BC3	) | ||||
| 	{ | ||||
| 		blocksPerRow = (width + 3) / 4; | ||||
| 		blocksPerColumn = (height + 3) / 4; | ||||
|  | @ -177,6 +168,16 @@ struct Refresh_Device | |||
| 
 | ||||
| 	/* 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)( | ||||
| 		Refresh_Renderer *driverData, | ||||
| 		Refresh_CommandBuffer *commandBuffer, | ||||
|  | @ -450,9 +451,7 @@ struct Refresh_Device | |||
| 	Refresh_Texture* (*AcquireSwapchainTexture)( | ||||
| 		Refresh_Renderer *driverData, | ||||
| 		Refresh_CommandBuffer *commandBuffer, | ||||
| 		void *windowHandle, | ||||
| 		uint32_t *pWidth, | ||||
| 		uint32_t *pHeight | ||||
| 		void *windowHandle | ||||
| 	); | ||||
| 
 | ||||
| 	Refresh_TextureFormat (*GetSwapchainFormat)( | ||||
|  | @ -478,6 +477,7 @@ struct Refresh_Device | |||
| 	result->func = name##_##func; | ||||
| #define ASSIGN_DRIVER(name) \ | ||||
| 	ASSIGN_DRIVER_FUNC(DestroyDevice, name) \ | ||||
| 	ASSIGN_DRIVER_FUNC(Clear, name) \ | ||||
| 	ASSIGN_DRIVER_FUNC(DrawIndexedPrimitives, name) \ | ||||
| 	ASSIGN_DRIVER_FUNC(DrawInstancedPrimitives, name) \ | ||||
| 	ASSIGN_DRIVER_FUNC(DrawPrimitives, name) \ | ||||
|  | @ -531,7 +531,6 @@ typedef struct Refresh_Driver | |||
| } Refresh_Driver; | ||||
| 
 | ||||
| extern Refresh_Driver VulkanDriver; | ||||
| extern Refresh_Driver PS5Driver; | ||||
| 
 | ||||
| #endif /* REFRESH_DRIVER_H */ | ||||
| 
 | ||||
|  |  | |||
|  | @ -37,7 +37,7 @@ | |||
| static TEMPLATE_SURFACE_FORMAT_TYPE RefreshToTEMPLATE_SurfaceFormat[] = | ||||
| { | ||||
| 	0,	/* R8G8B8A8 */ | ||||
| 	0,	/* B8G8R8A8 */ | ||||
| 	0	/* B8G8R8A8 */ | ||||
| 	0,	/* R5G6B5 */ | ||||
| 	0,	/* A1R5G5B5 */ | ||||
| 	0,	/* B4G4R4A4 */ | ||||
|  | @ -97,6 +97,7 @@ static TEMPLATE_POLYGON_MODE_TYPE RefreshToTEMPLATE_PolygonMode[] = | |||
| { | ||||
| 	0,	/* FILL */ | ||||
| 	0,	/* LINE */ | ||||
| 	0	/* POINT */ | ||||
| }; | ||||
| 
 | ||||
| static TEMPLATE_CULL_MODE_TYPE RefreshToTEMPLATE_CullMode[] = | ||||
|  | @ -104,6 +105,7 @@ static TEMPLATE_CULL_MODE_TYPE RefreshToTEMPLATE_CullMode[] = | |||
| 	0,	/* NONE */ | ||||
| 	0,	/* FRONT */ | ||||
| 	0,	/* BACK */ | ||||
| 	0	/* FRONT_AND_BACK */ | ||||
| }; | ||||
| 
 | ||||
| static TEMPLATE_FRONT_FACE_TYPE RefreshToTEMPLATE_FrontFace[] = | ||||
|  | @ -126,6 +128,8 @@ static TEMPLATE_BLEND_FACTOR_TYPE RefreshToTEMPLATE_BlendFactor[] = | |||
| 	0,	/* ONE_MINUS_DST_ALPHA */ | ||||
| 	0,	/* CONSTANT_COLOR */ | ||||
| 	0,	/* ONE_MINUS_CONSTANT_COLOR */ | ||||
| 	0,	/* CONSTANT_ALPHA */ | ||||
| 	0,	/* ONE_MINUS_CONSTANT_ALPHA */ | ||||
| 	0,	/* SRC_ALPHA_SATURATE */ | ||||
| 	0,	/* SRC1_COLOR */ | ||||
| 	0,	/* ONE_MINUS_SRC1_COLOR */ | ||||
|  | @ -142,6 +146,26 @@ static TEMPLATE_BLEND_OP_TYPE RefreshToTEMPLATE_BlendOp[] = | |||
| 	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[] = | ||||
| { | ||||
| 	0,	/* NEVER */ | ||||
|  | @ -200,6 +224,7 @@ static TEMPLATE_FILTER_TYPE RefreshToTEMPLATE_Filter[] = | |||
| { | ||||
| 	0,	/* NEAREST */ | ||||
| 	0,	/* LINEAR */ | ||||
| 	0	/* CUBIC */ | ||||
| }; | ||||
| 
 | ||||
| static TEMPLATE_SAMPLER_MIPMAP_MODE_TYPE RefreshToTEMPLATE_SamplerMipmapMode[] = | ||||
|  | @ -236,6 +261,18 @@ static void TEMPLATE_DestroyDevice( | |||
| 
 | ||||
| /* 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( | ||||
| 	Refresh_Renderer *driverData, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
|  | @ -586,9 +623,7 @@ static Refresh_CommandBuffer* TEMPLATE_AcquireCommandBuffer( | |||
| Refresh_Texture* TEMPLATE_AcquireSwapchainTexture( | ||||
| 	Refresh_Renderer *driverData, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
| 	void *windowHandle, | ||||
| 	uint32_t *pWidth, | ||||
| 	uint32_t *pHeight | ||||
| 	void *windowHandle | ||||
| ) { | ||||
| 	NOT_IMPLEMENTED | ||||
| } | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
		Reference in New Issue