forked from MoonsideGames/Refresh
				
			Compare commits
	
		
			9 Commits 
		
	
	
		
			3b0774579f
			...
			4a1e4a49a8
		
	
	| Author | SHA1 | Date | 
|---|---|---|
|  | 4a1e4a49a8 | |
|  | e44aee7101 | |
|  | f638e05ed1 | |
|  | 56ebde7567 | |
|  | 40b6ec0e91 | |
|  | 93848a79ec | |
|  | 77acc3c47a | |
|  | acefc530fd | |
|  | 3820d458fe | 
|  | @ -8,8 +8,8 @@ option(BUILD_SHARED_LIBS "Build shared library" ON) | |||
| 
 | ||||
| # Version | ||||
| SET(LIB_MAJOR_VERSION "1") | ||||
| SET(LIB_MINOR_VERSION "2") | ||||
| SET(LIB_REVISION "1") | ||||
| SET(LIB_MINOR_VERSION "3") | ||||
| SET(LIB_REVISION "0") | ||||
| SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_REVISION}") | ||||
| 
 | ||||
| # Build Type | ||||
|  | @ -40,6 +40,11 @@ endif() | |||
| add_definitions( | ||||
| 	-DREFRESH_DRIVER_VULKAN | ||||
| ) | ||||
| if (WIN32) | ||||
| 	add_definitions( | ||||
| 		-DREFRESH_DRIVER_D3D11 | ||||
| 	) | ||||
| endif() | ||||
| 
 | ||||
| # Source lists | ||||
| add_library(Refresh | ||||
|  | @ -49,8 +54,10 @@ add_library(Refresh | |||
| 	# Internal Headers | ||||
| 	src/Refresh_Driver.h | ||||
| 	src/Refresh_Driver_Vulkan_vkfuncs.h | ||||
| 	src/Refresh_Driver_D3D11_cdefines.h | ||||
| 	# Source Files | ||||
| 	src/Refresh.c | ||||
| 	src/Refresh_Driver_D3D11.c | ||||
| 	src/Refresh_Driver_Vulkan.c | ||||
| 	src/Refresh_Image.c | ||||
| ) | ||||
|  |  | |||
|  | @ -55,8 +55,8 @@ extern "C" { | |||
| /* Version API */ | ||||
| 
 | ||||
| #define REFRESH_MAJOR_VERSION   1 | ||||
| #define REFRESH_MINOR_VERSION	2 | ||||
| #define REFRESH_PATCH_VERSION	1 | ||||
| #define REFRESH_MINOR_VERSION	3 | ||||
| #define REFRESH_PATCH_VERSION	0 | ||||
| 
 | ||||
| #define REFRESH_COMPILED_VERSION ( \ | ||||
| 	(REFRESH_MAJOR_VERSION * 100 * 100) + \ | ||||
|  | @ -107,15 +107,6 @@ 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, | ||||
|  | @ -607,30 +598,6 @@ 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. | ||||
|  | @ -1136,17 +1103,22 @@ 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 present. | ||||
|  * If NULL, the user must ensure to not use the texture. | ||||
|  * 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 | ||||
| 	void *windowHandle, | ||||
| 	uint32_t *pWidth, | ||||
| 	uint32_t *pHeight | ||||
| ); | ||||
| 
 | ||||
| /* Returns the format of the swapchain for the given window. */ | ||||
|  |  | |||
|  | @ -34,7 +34,12 @@ | |||
| /* Drivers */ | ||||
| 
 | ||||
| static const Refresh_Driver *drivers[] = { | ||||
| #if REFRESH_DRIVER_VULKAN | ||||
| 	&VulkanDriver, | ||||
| #endif | ||||
| #if REFRESH_DRIVER_D3D11 | ||||
| 	&D3D11Driver, | ||||
| #endif | ||||
| 	NULL | ||||
| }; | ||||
| 
 | ||||
|  | @ -124,21 +129,42 @@ uint32_t Refresh_LinkedVersion(void) | |||
| 
 | ||||
| /* Driver Functions */ | ||||
| 
 | ||||
| static int32_t selectedDriver = 0; | ||||
| static int32_t selectedDriver = -1; | ||||
| 
 | ||||
| Refresh_Device* Refresh_CreateDevice( | ||||
| 	Refresh_PresentationParameters *presentationParameters, | ||||
| 	uint8_t debugMode | ||||
| ) { | ||||
| 	if (selectedDriver < 0) | ||||
| 	uint32_t result = 0; | ||||
| 	uint32_t i; | ||||
| 	const char *hint = SDL_GetHint("REFRESH_FORCE_DRIVER"); | ||||
| 	for (i = 0; drivers[i] != NULL; i += 1) | ||||
| 	{ | ||||
| 		return NULL; | ||||
| 		if (hint != NULL) | ||||
| 		{ | ||||
| 			if (SDL_strcmp(hint, drivers[i]->Name) != 0) | ||||
| 			{ | ||||
| 				continue; | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		/* FIXME: add fallback driver handling */ | ||||
| 		break; | ||||
| 	} | ||||
| 
 | ||||
| 	return drivers[selectedDriver]->CreateDevice( | ||||
| 		presentationParameters, | ||||
| 		debugMode | ||||
| 	); | ||||
| 	if (drivers[i] == NULL) | ||||
| 	{ | ||||
| 		Refresh_LogError("No supported Refresh driver found!"); | ||||
| 		return NULL; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		selectedDriver = i; | ||||
| 		return drivers[selectedDriver]->CreateDevice( | ||||
| 			presentationParameters, | ||||
| 			debugMode | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| void Refresh_DestroyDevice(Refresh_Device *device) | ||||
|  | @ -147,27 +173,6 @@ 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, | ||||
|  | @ -729,13 +734,17 @@ Refresh_CommandBuffer* Refresh_AcquireCommandBuffer( | |||
| Refresh_Texture* Refresh_AcquireSwapchainTexture( | ||||
| 	Refresh_Device *device, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
| 	void *windowHandle | ||||
| 	void *windowHandle, | ||||
| 	uint32_t *pWidth, | ||||
| 	uint32_t *pHeight | ||||
| ) { | ||||
| 	NULL_RETURN_NULL(device); | ||||
| 	return device->AcquireSwapchainTexture( | ||||
| 		device->driverData, | ||||
| 		commandBuffer, | ||||
| 		windowHandle | ||||
| 		windowHandle, | ||||
| 		pWidth, | ||||
| 		pHeight | ||||
| 	); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -168,16 +168,6 @@ 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, | ||||
|  | @ -451,7 +441,9 @@ struct Refresh_Device | |||
| 	Refresh_Texture* (*AcquireSwapchainTexture)( | ||||
| 		Refresh_Renderer *driverData, | ||||
| 		Refresh_CommandBuffer *commandBuffer, | ||||
| 		void *windowHandle | ||||
| 		void *windowHandle, | ||||
| 		uint32_t *pWidth, | ||||
| 		uint32_t *pHeight | ||||
| 	); | ||||
| 
 | ||||
| 	Refresh_TextureFormat (*GetSwapchainFormat)( | ||||
|  | @ -477,7 +469,6 @@ 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,6 +522,7 @@ typedef struct Refresh_Driver | |||
| } Refresh_Driver; | ||||
| 
 | ||||
| extern Refresh_Driver VulkanDriver; | ||||
| extern Refresh_Driver D3D11Driver; | ||||
| 
 | ||||
| #endif /* REFRESH_DRIVER_H */ | ||||
| 
 | ||||
|  |  | |||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							|  | @ -0,0 +1,215 @@ | |||
| /* Refresh - XNA-inspired 3D Graphics Library with modern capabilities
 | ||||
|  * | ||||
|  * Copyright (c) 2020 Evan Hemsley | ||||
|  * | ||||
|  * This software is provided 'as-is', without any express or implied warranty. | ||||
|  * In no event will the authors be held liable for any damages arising from | ||||
|  * the use of this software. | ||||
|  * | ||||
|  * Permission is granted to anyone to use this software for any purpose, | ||||
|  * including commercial applications, and to alter it and redistribute it | ||||
|  * freely, subject to the following restrictions: | ||||
|  * | ||||
|  * 1. The origin of this software must not be misrepresented; you must not | ||||
|  * claim that you wrote the original software. If you use this software in a | ||||
|  * product, an acknowledgment in the product documentation would be | ||||
|  * appreciated but is not required. | ||||
|  * | ||||
|  * 2. Altered source versions must be plainly marked as such, and must not be | ||||
|  * misrepresented as being the original software. | ||||
|  * | ||||
|  * 3. This notice may not be removed or altered from any source distribution. | ||||
|  * | ||||
|  * Evan "cosmonaut" Hemsley <evan@moonside.games> | ||||
|  * | ||||
|  */ | ||||
| 
 | ||||
| /* Function Pointer Signatures */ | ||||
| typedef HRESULT(WINAPI* PFN_CREATE_DXGI_FACTORY)(const GUID* riid, void** ppFactory); | ||||
| 
 | ||||
|  /* IIDs (from https://magnumdb.com) */ | ||||
| 
 | ||||
| static const IID D3D_IID_IDXGIFactory1 = { 0x770aae78,0xf26f,0x4dba,{0xa8,0x29,0x25,0x3c,0x83,0xd1,0xb3,0x87} }; | ||||
| static const IID D3D_IID_IDXGIFactory6 = { 0xc1b6694f,0xff09,0x44a9,{0xb0,0x3c,0x77,0x90,0x0a,0x0a,0x1d,0x17} }; | ||||
| static const IID D3D_IID_IDXGIAdapter1 = { 0x29038f61,0x3839,0x4626,{0x91,0xfd,0x08,0x68,0x79,0x01,0x1a,0x05} }; | ||||
| static const IID D3D_IID_ID3D11Texture2D = { 0x6f15aaf2,0xd208,0x4e89,{0x9a,0xb4,0x48,0x95,0x35,0xd3,0x4f,0x9c} }; | ||||
| 
 | ||||
| /* IDXGIFactory6 (taken from dxgi1_6.h, cleaned up a bit) */ | ||||
| typedef enum | ||||
| { | ||||
| 	DXGI_FEATURE_PRESENT_ALLOW_TEARING = 0 | ||||
| } DXGI_FEATURE; | ||||
| 
 | ||||
| typedef enum | ||||
| { | ||||
| 	DXGI_GPU_PREFERENCE_UNSPECIFIED = 0, | ||||
| 	DXGI_GPU_PREFERENCE_MINIMUM_POWER = (DXGI_GPU_PREFERENCE_UNSPECIFIED + 1), | ||||
| 	DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE = (DXGI_GPU_PREFERENCE_MINIMUM_POWER + 1) | ||||
| } DXGI_GPU_PREFERENCE; | ||||
| 
 | ||||
| typedef struct IDXGIFactory6 IDXGIFactory6; | ||||
| typedef struct IDXGIFactory6Vtbl | ||||
| { | ||||
| 	HRESULT(STDMETHODCALLTYPE* QueryInterface)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		REFIID riid, | ||||
| 		void** ppvObject); | ||||
| 
 | ||||
| 	ULONG(STDMETHODCALLTYPE* AddRef)( | ||||
| 		IDXGIFactory6* This); | ||||
| 
 | ||||
| 	ULONG(STDMETHODCALLTYPE* Release)( | ||||
| 		IDXGIFactory6* This); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* SetPrivateData)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		REFGUID Name, | ||||
| 		UINT DataSize, | ||||
| 		const void* pData); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* SetPrivateDataInterface)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		REFGUID Name, | ||||
| 		const IUnknown* pUnknown); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* GetPrivateData)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		REFGUID Name, | ||||
| 		UINT* pDataSize, | ||||
| 		void* pData); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* GetParent)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		REFIID riid, | ||||
| 		void** ppParent); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* EnumAdapters)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		UINT Adapter, | ||||
| 		IDXGIAdapter** ppAdapter); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* MakeWindowAssociation)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HWND WindowHandle, | ||||
| 		UINT Flags); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* GetWindowAssociation)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HWND* pWindowHandle); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* CreateSwapChain)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		IUnknown* pDevice, | ||||
| 		DXGI_SWAP_CHAIN_DESC* pDesc, | ||||
| 		IDXGISwapChain** ppSwapChain); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* CreateSoftwareAdapter)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HMODULE Module, | ||||
| 		IDXGIAdapter** ppAdapter); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* EnumAdapters1)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		UINT Adapter, | ||||
| 		IDXGIAdapter1** ppAdapter); | ||||
| 
 | ||||
| 	BOOL(STDMETHODCALLTYPE* IsCurrent)( | ||||
| 		IDXGIFactory6* This); | ||||
| 
 | ||||
| 	BOOL(STDMETHODCALLTYPE* IsWindowedStereoEnabled)( | ||||
| 		IDXGIFactory6* This); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* CreateSwapChainForHwnd)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		IUnknown* pDevice, | ||||
| 		HWND hWnd, | ||||
| 		void* pDesc, | ||||
| 		void* pFullscreenDesc, | ||||
| 		void* pRestrictToOutput, | ||||
| 		void** ppSwapChain); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* CreateSwapChainForCoreWindow)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		IUnknown* pDevice, | ||||
| 		IUnknown* pWindow, | ||||
| 		void* pDesc, | ||||
| 		void* pRestrictToOutput, | ||||
| 		void** ppSwapChain); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* GetSharedResourceAdapterLuid)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HANDLE hResource, | ||||
| 		LUID* pLuid); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* RegisterStereoStatusWindow)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HWND WindowHandle, | ||||
| 		UINT wMsg, | ||||
| 		DWORD* pdwCookie); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* RegisterStereoStatusEvent)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HANDLE hEvent, | ||||
| 		DWORD* pdwCookie); | ||||
| 
 | ||||
| 	void (STDMETHODCALLTYPE* UnregisterStereoStatus)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		DWORD dwCookie); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* RegisterOcclusionStatusWindow)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HWND WindowHandle, | ||||
| 		UINT wMsg, | ||||
| 		DWORD* pdwCookie); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* RegisterOcclusionStatusEvent)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		HANDLE hEvent, | ||||
| 		DWORD* pdwCookie); | ||||
| 
 | ||||
| 	void (STDMETHODCALLTYPE* UnregisterOcclusionStatus)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		DWORD dwCookie); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* CreateSwapChainForComposition)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		IUnknown* pDevice, | ||||
| 		void* pDesc, | ||||
| 		void* pRestrictToOutput, | ||||
| 		void** ppSwapChain); | ||||
| 
 | ||||
| 	UINT(STDMETHODCALLTYPE* GetCreationFlags)( | ||||
| 		IDXGIFactory6* This); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* EnumAdapterByLuid)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		LUID AdapterLuid, | ||||
| 		REFIID riid, | ||||
| 		void** ppvAdapter); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* EnumWarpAdapter)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		REFIID riid, | ||||
| 		void** ppvAdapter); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* CheckFeatureSupport)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		DXGI_FEATURE Feature, | ||||
| 		void* pFeatureSupportData, | ||||
| 		UINT FeatureSupportDataSize); | ||||
| 
 | ||||
| 	HRESULT(STDMETHODCALLTYPE* EnumAdapterByGpuPreference)( | ||||
| 		IDXGIFactory6* This, | ||||
| 		UINT Adapter, | ||||
| 		DXGI_GPU_PREFERENCE GpuPreference, | ||||
| 		REFIID riid, | ||||
| 		void** ppvAdapter); | ||||
| } IDXGIFactory6Vtbl; | ||||
| 
 | ||||
| struct IDXGIFactory6 | ||||
| { | ||||
| 	struct IDXGIFactory6Vtbl* lpVtbl; | ||||
| }; | ||||
| 
 | ||||
| #define IDXGIFactory6_EnumAdapterByGpuPreference(This,Adapter,GpuPreference,riid,ppvAdapter)	\ | ||||
| 	( (This)->lpVtbl -> EnumAdapterByGpuPreference(This,Adapter,GpuPreference,riid,ppvAdapter) )  | ||||
|  | @ -236,18 +236,6 @@ 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, | ||||
|  | @ -598,7 +586,9 @@ static Refresh_CommandBuffer* TEMPLATE_AcquireCommandBuffer( | |||
| Refresh_Texture* TEMPLATE_AcquireSwapchainTexture( | ||||
| 	Refresh_Renderer *driverData, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
| 	void *windowHandle | ||||
| 	void *windowHandle, | ||||
| 	uint32_t *pWidth, | ||||
| 	uint32_t *pHeight | ||||
| ) { | ||||
| 	NOT_IMPLEMENTED | ||||
| } | ||||
|  |  | |||
|  | @ -4798,117 +4798,6 @@ static void VULKAN_DestroyDevice( | |||
| 	SDL_free(device); | ||||
| } | ||||
| 
 | ||||
| static void VULKAN_Clear( | ||||
| 	Refresh_Renderer *driverData, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
| 	Refresh_Rect *clearRect, | ||||
| 	Refresh_ClearOptions options, | ||||
| 	Refresh_Vec4 *colors, | ||||
| 	uint32_t colorCount, | ||||
| 	Refresh_DepthStencilValue depthStencil | ||||
| ) { | ||||
| 	VulkanRenderer* renderer = (VulkanRenderer*) driverData; | ||||
| 	VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer; | ||||
| 
 | ||||
| 	uint32_t attachmentCount, i; | ||||
| 	VkClearAttachment clearAttachments[MAX_COLOR_TARGET_BINDINGS + 1]; | ||||
| 	VkClearRect vulkanClearRect; | ||||
| 	VkClearValue clearValues[4]; | ||||
| 
 | ||||
| 	uint8_t shouldClearColor = options & REFRESH_CLEAROPTIONS_COLOR; | ||||
| 	uint8_t shouldClearDepth = options & REFRESH_CLEAROPTIONS_DEPTH; | ||||
| 	uint8_t shouldClearStencil = options & REFRESH_CLEAROPTIONS_STENCIL; | ||||
| 
 | ||||
| 	uint8_t shouldClearDepthStencil = ( | ||||
| 		(shouldClearDepth || shouldClearStencil) | ||||
| 	); | ||||
| 
 | ||||
| 	if (!shouldClearColor && !shouldClearDepthStencil) | ||||
| 	{ | ||||
| 		return; | ||||
| 	} | ||||
| 
 | ||||
| 	vulkanClearRect.baseArrayLayer = 0; | ||||
| 	vulkanClearRect.layerCount = 1; | ||||
| 	vulkanClearRect.rect.offset.x = clearRect->x; | ||||
| 	vulkanClearRect.rect.offset.y = clearRect->y; | ||||
| 	vulkanClearRect.rect.extent.width = clearRect->w; | ||||
| 	vulkanClearRect.rect.extent.height = clearRect->h; | ||||
| 
 | ||||
| 	attachmentCount = 0; | ||||
| 
 | ||||
| 	if (shouldClearColor) | ||||
| 	{ | ||||
| 		for (i = 0; i < colorCount; i += 1) | ||||
| 		{ | ||||
| 			clearValues[i].color.float32[0] = colors[i].x; | ||||
| 			clearValues[i].color.float32[1] = colors[i].y; | ||||
| 			clearValues[i].color.float32[2] = colors[i].z; | ||||
| 			clearValues[i].color.float32[3] = colors[i].w; | ||||
| 		} | ||||
| 
 | ||||
| 		for (i = 0; i < colorCount; i += 1) | ||||
| 		{ | ||||
| 			clearAttachments[attachmentCount].aspectMask = | ||||
| 				VK_IMAGE_ASPECT_COLOR_BIT; | ||||
| 			clearAttachments[attachmentCount].colorAttachment = | ||||
| 				attachmentCount; | ||||
| 			clearAttachments[attachmentCount].clearValue = | ||||
| 				clearValues[attachmentCount]; | ||||
| 			attachmentCount += 1; | ||||
| 
 | ||||
| 			/* Do NOT clear the multisample image here!
 | ||||
| 			 * Vulkan treats them both as the same color attachment. | ||||
| 			 * Vulkan is a very good and not confusing at all API. | ||||
| 			 */ | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	if (shouldClearDepthStencil) | ||||
| 	{ | ||||
| 		clearAttachments[attachmentCount].aspectMask = 0; | ||||
| 		clearAttachments[attachmentCount].colorAttachment = 0; | ||||
| 
 | ||||
| 		if (shouldClearDepth) | ||||
| 		{ | ||||
| 			if (depthStencil.depth < 0.0f) | ||||
| 			{ | ||||
| 				depthStencil.depth = 0.0f; | ||||
| 			} | ||||
| 			else if (depthStencil.depth > 1.0f) | ||||
| 			{ | ||||
| 				depthStencil.depth = 1.0f; | ||||
| 			} | ||||
| 			clearAttachments[attachmentCount].aspectMask |= VK_IMAGE_ASPECT_DEPTH_BIT; | ||||
| 			clearAttachments[attachmentCount].clearValue.depthStencil.depth = depthStencil.depth; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			clearAttachments[attachmentCount].clearValue.depthStencil.depth = 0.0f; | ||||
| 		} | ||||
| 
 | ||||
| 		if (shouldClearStencil) | ||||
| 		{ | ||||
| 			clearAttachments[attachmentCount].aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT; | ||||
| 			clearAttachments[attachmentCount].clearValue.depthStencil.stencil = depthStencil.stencil; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			clearAttachments[attachmentCount].clearValue.depthStencil.stencil = 0; | ||||
| 		} | ||||
| 
 | ||||
| 		attachmentCount += 1; | ||||
| 	} | ||||
| 
 | ||||
| 	renderer->vkCmdClearAttachments( | ||||
| 		vulkanCommandBuffer->commandBuffer, | ||||
| 		attachmentCount, | ||||
| 		clearAttachments, | ||||
| 		1, | ||||
| 		&vulkanClearRect | ||||
| 	); | ||||
| } | ||||
| 
 | ||||
| static void VULKAN_DrawInstancedPrimitives( | ||||
| 	Refresh_Renderer *driverData, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
|  | @ -8954,7 +8843,9 @@ static VulkanSwapchainData* VULKAN_INTERNAL_FetchSwapchainData( | |||
| static Refresh_Texture* VULKAN_AcquireSwapchainTexture( | ||||
| 	Refresh_Renderer *driverData, | ||||
| 	Refresh_CommandBuffer *commandBuffer, | ||||
| 	void *windowHandle | ||||
| 	void *windowHandle, | ||||
| 	uint32_t *pWidth, | ||||
| 	uint32_t *pHeight | ||||
| ) { | ||||
| 	VulkanRenderer *renderer = (VulkanRenderer*) driverData; | ||||
| 	VulkanCommandBuffer *vulkanCommandBuffer = (VulkanCommandBuffer*) commandBuffer; | ||||
|  | @ -9066,6 +8957,9 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture( | |||
| 	vulkanCommandBuffer->signalSemaphores[vulkanCommandBuffer->signalSemaphoreCount] = swapchainData->renderFinishedSemaphore; | ||||
| 	vulkanCommandBuffer->signalSemaphoreCount += 1; | ||||
| 
 | ||||
| 	*pWidth = swapchainData->extent.width; | ||||
| 	*pHeight = swapchainData->extent.height; | ||||
| 
 | ||||
| 	return (Refresh_Texture*) swapchainTexture; | ||||
| } | ||||
| 
 | ||||
|  |  | |||
|  | @ -61,7 +61,7 @@ | |||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>Disabled</Optimization> | ||||
|       <PreprocessorDefinitions>REFRESH_DRIVER_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <PreprocessorDefinitions>REFRESH_DRIVER_D3D11;REFRESH_DRIVER_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|     </ClCompile> | ||||
|     <Link> | ||||
|       <GenerateDebugInformation>DebugFull</GenerateDebugInformation> | ||||
|  | @ -72,7 +72,7 @@ | |||
|     <ClCompile> | ||||
|       <WarningLevel>Level3</WarningLevel> | ||||
|       <Optimization>MaxSpeed</Optimization> | ||||
|       <PreprocessorDefinitions>REFRESH_DRIVER_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <PreprocessorDefinitions>REFRESH_DRIVER_D3D11;REFRESH_DRIVER_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||
|       <FunctionLevelLinking>true</FunctionLevelLinking> | ||||
|       <IntrinsicFunctions>true</IntrinsicFunctions> | ||||
|     </ClCompile> | ||||
|  | @ -84,6 +84,7 @@ | |||
|   </ItemDefinitionGroup> | ||||
|   <ItemGroup> | ||||
|     <ClCompile Include="..\src\Refresh.c" /> | ||||
|     <ClCompile Include="..\src\Refresh_Driver_D3D11.c" /> | ||||
|     <ClCompile Include="..\src\Refresh_Driver_Vulkan.c" /> | ||||
|     <ClCompile Include="..\src\Refresh_Image.c" /> | ||||
|   </ItemGroup> | ||||
|  | @ -91,6 +92,7 @@ | |||
|     <ClInclude Include="..\include\Refresh.h" /> | ||||
|     <ClInclude Include="..\include\Refresh_Image.h" /> | ||||
|     <ClInclude Include="..\src\Refresh_Driver.h" /> | ||||
|     <ClInclude Include="..\src\Refresh_Driver_D3D11_cdefines.h" /> | ||||
|     <ClInclude Include="..\src\Refresh_Driver_Vulkan_vkfuncs.h" /> | ||||
|   </ItemGroup> | ||||
|   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||||
|  |  | |||
|  | @ -10,6 +10,9 @@ | |||
|     <ClCompile Include="..\src\Refresh_Image.c"> | ||||
|       <Filter>Source Files</Filter> | ||||
|     </ClCompile> | ||||
|     <ClCompile Include="..\src\Refresh_Driver_D3D11.c"> | ||||
|       <Filter>Source Files</Filter> | ||||
|     </ClCompile> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <ClInclude Include="..\include\Refresh.h"> | ||||
|  | @ -24,6 +27,9 @@ | |||
|     <ClInclude Include="..\include\Refresh_Image.h"> | ||||
|       <Filter>Header Files</Filter> | ||||
|     </ClInclude> | ||||
|     <ClInclude Include="..\src\Refresh_Driver_D3D11_cdefines.h"> | ||||
|       <Filter>Header Files</Filter> | ||||
|     </ClInclude> | ||||
|   </ItemGroup> | ||||
|   <ItemGroup> | ||||
|     <Filter Include="Header Files"> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue