Compare commits

..

69 Commits

Author SHA1 Message Date
Caleb Cornett 345924f12d Fix infinite while loop in D3D11_INTERNAL_WaitForFence 2024-02-11 00:40:48 -06:00
Caleb Cornett b827713cb0 Compute buffer creation fixes 2024-02-11 00:36:41 -06:00
Caleb Cornett 9ea76e92dc Move uav FIXME's to API FIXME's 2024-02-11 00:08:34 -06:00
Caleb Cornett 19c6c48021 Add shader type to the .refresh shader bytecode format 2024-02-11 00:07:01 -06:00
Caleb Cornett 74bd056adf Fix a few more FIXME's 2024-02-10 23:00:55 -06:00
Caleb Cornett 617ce4edf8 Note which FIXME's require a Refresh API update 2024-02-10 22:21:01 -06:00
Caleb Cornett e81926712e Combine swapchain and window data structs + actually allocate claimedWindows... 2024-02-10 22:18:25 -06:00
Caleb Cornett 506c2e4819 FIXME fixups, mostly for contextLock 2024-02-10 21:49:19 -06:00
Caleb Cornett 54ffdc180d PresentMode fixes 2024-02-10 18:00:12 -06:00
Caleb Cornett 91b389f351 SetSwapchainPresentMode + other swapchain-y features from FNA3D D3D11 2024-02-10 17:07:56 -06:00
Caleb Cornett 01a36b940b Fix non-MSAA cube RTs 2024-02-10 00:19:11 -06:00
Caleb Cornett 81351a1c1b MSAA for color and depth targets 2024-02-09 23:56:36 -06:00
Caleb Cornett 25cec457b4 SetTextureDataYUV 2024-02-09 17:52:47 -06:00
Caleb Cornett e0dcaa222b Two typos in the same malloc... + cube RT fixes 2024-02-09 17:23:48 -06:00
Caleb Cornett c121492e47 Fix copy-paste error from last commit 2024-02-09 16:40:05 -06:00
Caleb Cornett ac5aa0d40c Do some type shenanigans to allow depth textures to be sampled + fix viewport sizing logic 2024-02-09 16:37:08 -06:00
Caleb Cornett 1a87a284c4 DepthStencilView creation + DS state fixes 2024-02-09 16:03:57 -06:00
Caleb Cornett a6f88ec73a RTV overhaul to fix binding an RT with a specific depth/mip level 2024-02-09 15:28:08 -06:00
Caleb Cornett 7093ce0094 First rough pass at color RTs 2024-02-09 12:09:29 -06:00
Caleb Cornett 917896e5f4 Use NO_OVERWRITE on uniform buffers after the initial WRITE_DISCARD + SetBufferData cleanup 2024-02-09 11:19:51 -06:00
Caleb Cornett 9b8dfd8207 Fix repeated buffer writes by using USAGE_DEFAULT/UpdateSubresource instead of DYNAMIC/Map for non-uniform buffers 2024-02-09 11:04:32 -06:00
Caleb Cornett 06d93a55a3 PushComputeShaderUniforms + CreateComputePipeline fix 2024-02-09 02:17:08 -06:00
Caleb Cornett 3f6ecd38a0 Actually compile compute shaders 2024-02-09 02:02:41 -06:00
Caleb Cornett 463c298c96 GetBufferData 2024-02-09 00:57:26 -06:00
Caleb Cornett 17bc9f90eb QueueDestroyComputePipeline + style cleanup for QueueDestroyGraphicsPipeline 2024-02-09 00:35:19 -06:00
Caleb Cornett ecff6f55df Fence API 2024-02-09 00:31:54 -06:00
Caleb Cornett ca7f64eb9a Clean up fence logic 2024-02-08 23:59:13 -06:00
Caleb Cornett 8be21dde9b Uniform buffer binding rework for clarity + minor cleanup 2024-02-08 23:47:25 -06:00
Caleb Cornett 0d6043cfef First pass at fence infrastructure 2024-02-08 22:53:36 -06:00
Caleb Cornett ebf96ff423 First rough draft of Compute functions (untested!) 2024-02-07 21:03:21 -06:00
Caleb Cornett f36abf29de DrawPrimitivesIndirect 2024-02-07 11:53:18 -06:00
Caleb Cornett 597b8dcef3 BindVertexSamplers 2024-02-07 10:18:49 -06:00
Caleb Cornett ce7cca2eba Fix 3D texture SRV creation, use UpdateSubresource1 to avoid bug with non-zero offsets on deferred contexts 2024-02-07 10:08:23 -06:00
Caleb Cornett b0bd383f2e Fix fragment uniform buffer block calculation 2024-02-07 09:35:03 -06:00
Caleb Cornett 10cbac3fc3 Fix device level check, fix ID3D11Device memory leak 2024-02-07 09:09:30 -06:00
Caleb Cornett 7f70318f70 Set up the DXGI Info Queue so we can filter messages without using DirectX Control Panel 2024-02-07 09:09:01 -06:00
Caleb Cornett 30fe868ea2 Add DXGIDebug logic to help track memory leaks, fix SRV leak it discovered 2024-02-07 08:02:49 -06:00
Caleb Cornett 1b63ff8467 Minor style cleanup 2024-02-07 07:34:07 -06:00
Caleb Cornett 69df00398e Fix a couple minor memory leaks 2024-02-07 07:33:23 -06:00
Caleb Cornett 248aa956ac Release DLLs after releasing D3D11/DXGI objects (and release dxgi.dll!) 2024-02-06 22:40:16 -06:00
Caleb Cornett e022faf545 Fix degenerate InputLayout creation when creating graphics pipeline with no vertex attributes 2024-02-06 21:48:16 -06:00
Caleb Cornett 641abe4bb5 Fixed uniform offsets, removed a bunch of code from cdefines.h 2024-02-06 21:13:02 -06:00
Caleb Cornett 53128e0b66 Uniform buffer infrastructure, still missing offset support 2024-02-06 21:13:02 -06:00
Caleb Cornett 991b37c006 Fix texture conversion array 2024-02-06 21:13:02 -06:00
Caleb Cornett 94c2d15895 Fix command buffer memory leak 2024-02-06 21:13:02 -06:00
Caleb Cornett e6402cbb14 CreateTexture, SetTextureData, BindIndexBuffer, BindFragmentSamplers, QueueDestroyTexture, DrawIndexedPrimitives, DrawInstancedPrimitives 2024-02-06 21:13:02 -06:00
Caleb Cornett 4bdfc2293f Fix redundant error code printing 2024-02-06 21:13:02 -06:00
Caleb Cornett d4ac8a1656 QueueDestroySampler 2024-02-06 21:13:02 -06:00
Caleb Cornett 42a9ce28e6 Add a border color conversion function 2024-02-06 21:13:02 -06:00
Caleb Cornett 6b39da7d2d CreateSampler 2024-02-06 21:13:02 -06:00
Caleb Cornett e35efa4061 CreateBuffer, QueueDestroyBuffer, SetBufferData, BindVertexBuffers 2024-02-06 21:13:02 -06:00
Caleb Cornett 741d3ebcff Initial work on DestroyDevice 2024-02-06 21:13:02 -06:00
Caleb Cornett 0f1a2423d0 Implement SetViewport and SetScissor 2024-02-06 21:13:02 -06:00
Caleb Cornett 38d51cf6de Style cleanups + added FIXME note for shader compilation 2024-02-06 21:13:02 -06:00
Caleb Cornett 88ca03f213 shaderc now flips Y values in the vertex shader 2024-02-06 21:12:59 -06:00
Caleb Cornett 9b139cf672 DrawPrimitives, BindGraphicsPipeline, misc cleanup 2024-02-06 21:11:22 -06:00
Caleb Cornett 2cb678d9a1 Implement CreateShaderModule 2024-02-06 21:11:22 -06:00
Caleb Cornett afcfacb305 Pipeline creation copied over from old work + shaderc update 2024-02-06 21:11:22 -06:00
Caleb Cornett e47e7b2c75 Fix for command pool crash, fix for hanging on Wait 2024-02-06 21:11:22 -06:00
Caleb Cornett ce984f58d1 Reworked Wait and Submit logic to use D3D11 Query objects as fences 2024-02-06 21:11:22 -06:00
Caleb Cornett 413095923b Stub out D3D11_Wait, fix crash when unclaiming windows, fix backend order 2024-02-06 21:11:22 -06:00
Caleb Cornett e195e7f222 UnclaimWindow, swapchain destruction, fixed template signature 2024-02-06 21:11:22 -06:00
Caleb Cornett d7d89530de Implemented BeginRenderPass and Submit, ClearScreen works now! 2024-02-06 21:11:22 -06:00
Caleb Cornett f4c332f4e3 More swapchain setup 2024-02-06 21:11:22 -06:00
Caleb Cornett 1637401a8a Apply swapchainDesc fix from FNA3D, add cdefines.h to CMakeLists 2024-02-06 21:11:22 -06:00
Caleb Cornett 49c64a230f Implemented AcquireCommandBuffer (from old D3D11 work) 2024-02-06 21:11:22 -06:00
Caleb Cornett 13ae5dee54 Implement ClaimWindow, mostly copied from Vulkan and FNA3D D3D11 2024-02-06 21:11:22 -06:00
Caleb Cornett 951f124662 Remove old stuff, flesh out PrepareDriver 2024-02-06 21:11:22 -06:00
Caleb Cornett 547ed52305 Groundwork for D3D11. Yoinked most of this from the prior work, but updated the ABI 2024-02-06 21:11:22 -06:00
11 changed files with 4476 additions and 30 deletions

View File

@ -41,6 +41,12 @@ add_definitions(
-DREFRESH_DRIVER_VULKAN -DREFRESH_DRIVER_VULKAN
) )
if (WIN32)
add_definitions(
-DREFRESH_DRIVER_D3D11
)
endif()
# Source lists # Source lists
add_library(Refresh add_library(Refresh
# Public Headers # Public Headers
@ -49,8 +55,10 @@ add_library(Refresh
# Internal Headers # Internal Headers
src/Refresh_Driver.h src/Refresh_Driver.h
src/Refresh_Driver_Vulkan_vkfuncs.h src/Refresh_Driver_Vulkan_vkfuncs.h
Refresh_Driver_D3D11_cdefines.h
# Source Files # Source Files
src/Refresh.c src/Refresh.c
src/Refresh_Driver_D3D11.c
src/Refresh_Driver_Vulkan.c src/Refresh_Driver_Vulkan.c
src/Refresh_Image.c src/Refresh_Image.c
) )

View File

@ -330,6 +330,7 @@ typedef enum Refresh_Backend
{ {
REFRESH_BACKEND_DONTCARE, REFRESH_BACKEND_DONTCARE,
REFRESH_BACKEND_VULKAN, REFRESH_BACKEND_VULKAN,
REFRESH_BACKEND_D3D11,
REFRESH_BACKEND_PS5, REFRESH_BACKEND_PS5,
REFRESH_BACKEND_INVALID REFRESH_BACKEND_INVALID
} Refresh_Backend; } Refresh_Backend;

View File

@ -194,26 +194,37 @@ partial class Program
// Magic // Magic
writer.Write(new char[] { 'R', 'F', 'S', 'H'}); writer.Write(new char[] { 'R', 'F', 'S', 'H'});
// Type
uint shaderTypeIndex;
switch (shaderType)
{
default:
case ".vert": shaderTypeIndex = 0; break;
case ".frag": shaderTypeIndex = 1; break;
case ".comp": shaderTypeIndex = 2; break;
}
writer.Write(shaderTypeIndex);
if (data.vulkan) if (data.vulkan)
{ {
string inputPath = Path.Combine(tempDir, $"{shaderName}.spv"); string inputPath = Path.Combine(tempDir, $"{shaderName}.spv");
WriteShaderBlob(writer, inputPath, 1); WriteShaderBlob(writer, inputPath, 1);
} }
if (data.d3d11)
{
string inputPath = Path.Combine(tempDir, $"{shaderName}.hlsl");
WriteShaderBlob(writer, inputPath, 2);
}
#if PS5 #if PS5
if (data.ps5) if (data.ps5)
{ {
string ext = GetPS5ShaderFileExtension(); string ext = GetPS5ShaderFileExtension();
string inputPath = Path.Combine(tempDir, $"{shaderName}{ext}"); string inputPath = Path.Combine(tempDir, $"{shaderName}{ext}");
WriteShaderBlob(writer, inputPath, 2);
}
#endif
if (data.d3d11)
{
string inputPath = Path.Combine(tempDir, $"{shaderName}.hlsl");
WriteShaderBlob(writer, inputPath, 3); WriteShaderBlob(writer, inputPath, 3);
} }
#endif
} }
} }
@ -254,7 +265,7 @@ partial class Program
{ {
Process spirvcross = Process.Start( Process spirvcross = Process.Start(
"spirv-cross", "spirv-cross",
$"\"{spirvPath}\" --hlsl --shader-model 50 --output \"{outputPath}\"" $"\"{spirvPath}\" --hlsl --flip-vert-y --shader-model 50 --output \"{outputPath}\""
); );
spirvcross.WaitForExit(); spirvcross.WaitForExit();
if (spirvcross.ExitCode != 0) if (spirvcross.ExitCode != 0)

View File

@ -39,6 +39,12 @@
#define VULKAN_DRIVER NULL #define VULKAN_DRIVER NULL
#endif #endif
#ifdef REFRESH_DRIVER_D3D11
#define D3D11_DRIVER &D3D11Driver
#else
#define D3D11_DRIVER NULL
#endif
#ifdef REFRESH_DRIVER_PS5 #ifdef REFRESH_DRIVER_PS5
#define PS5_DRIVER &PS5Driver #define PS5_DRIVER &PS5Driver
#else #else
@ -48,6 +54,7 @@
static const Refresh_Driver *backends[] = { static const Refresh_Driver *backends[] = {
NULL, NULL,
VULKAN_DRIVER, VULKAN_DRIVER,
D3D11_DRIVER,
PS5_DRIVER PS5_DRIVER
}; };
@ -338,7 +345,7 @@ Refresh_ShaderModule* Refresh_CreateShaderModule(
Refresh_Device *device, Refresh_Device *device,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo
) { ) {
Refresh_ShaderModuleCreateInfo driverSpecificCreateInfo = { 0, NULL }; Refresh_Driver_ShaderModuleCreateInfo driverSpecificCreateInfo = { 0, NULL, 0 };
uint8_t *bytes; uint8_t *bytes;
uint32_t i, size; uint32_t i, size;
@ -348,12 +355,24 @@ Refresh_ShaderModule* Refresh_CreateShaderModule(
bytes = (uint8_t*) shaderModuleCreateInfo->byteCode; bytes = (uint8_t*) shaderModuleCreateInfo->byteCode;
if (bytes[0] != 'R' || bytes[1] != 'F' || bytes[2] != 'S' || bytes[3] != 'H') if (bytes[0] != 'R' || bytes[1] != 'F' || bytes[2] != 'S' || bytes[3] != 'H')
{ {
Refresh_LogError("Cannot parse malformed Refresh shader blob!"); Refresh_LogError("Cannot parse malformed Refresh shader blob: Incorrect magic number");
return NULL;
}
/* get the type of shader */
driverSpecificCreateInfo.type = (Refresh_Driver_ShaderType) *((uint32_t*) &bytes[4]);
if ( driverSpecificCreateInfo.type < 0 ||
driverSpecificCreateInfo.type > REFRESH_DRIVER_SHADERTYPE_COMPUTE )
{
Refresh_LogError(
"Cannot parse malformed Refresh shader blob: Unknown shader type (%d)",
driverSpecificCreateInfo.type
);
return NULL; return NULL;
} }
/* find the code for the selected backend */ /* find the code for the selected backend */
i = 4; i = 8;
while (i < shaderModuleCreateInfo->codeSize) while (i < shaderModuleCreateInfo->codeSize)
{ {
size = *((uint32_t*) &bytes[i + 1]); size = *((uint32_t*) &bytes[i + 1]);
@ -940,9 +959,7 @@ int Refresh_QueryFence(
Refresh_Device *device, Refresh_Device *device,
Refresh_Fence *fence Refresh_Fence *fence
) { ) {
if (device == NULL) { if (device == NULL) { return 0; }
return 0;
}
return device->QueryFence( return device->QueryFence(
device->driverData, device->driverData,

View File

@ -48,6 +48,46 @@ void Refresh_LogError(const char *fmt, ...);
/* Internal Helper Utilities */ /* Internal Helper Utilities */
static inline int32_t Texture_GetBlockSize(
Refresh_TextureFormat format
) {
switch (format)
{
case REFRESH_TEXTUREFORMAT_BC1:
case REFRESH_TEXTUREFORMAT_BC2:
case REFRESH_TEXTUREFORMAT_BC3:
case REFRESH_TEXTUREFORMAT_BC7:
return 4;
case REFRESH_TEXTUREFORMAT_R8:
case REFRESH_TEXTUREFORMAT_R8_UINT:
case REFRESH_TEXTUREFORMAT_R5G6B5:
case REFRESH_TEXTUREFORMAT_B4G4R4A4:
case REFRESH_TEXTUREFORMAT_A1R5G5B5:
case REFRESH_TEXTUREFORMAT_R16_SFLOAT:
case REFRESH_TEXTUREFORMAT_R8G8_SNORM:
case REFRESH_TEXTUREFORMAT_R8G8_UINT:
case REFRESH_TEXTUREFORMAT_R16_UINT:
case REFRESH_TEXTUREFORMAT_R8G8B8A8:
case REFRESH_TEXTUREFORMAT_R32_SFLOAT:
case REFRESH_TEXTUREFORMAT_R16G16_SFLOAT:
case REFRESH_TEXTUREFORMAT_R8G8B8A8_SNORM:
case REFRESH_TEXTUREFORMAT_A2R10G10B10:
case REFRESH_TEXTUREFORMAT_R8G8B8A8_UINT:
case REFRESH_TEXTUREFORMAT_R16G16_UINT:
case REFRESH_TEXTUREFORMAT_R16G16B16A16_SFLOAT:
case REFRESH_TEXTUREFORMAT_R16G16B16A16:
case REFRESH_TEXTUREFORMAT_R32G32_SFLOAT:
case REFRESH_TEXTUREFORMAT_R16G16B16A16_UINT:
case REFRESH_TEXTUREFORMAT_R32G32B32A32_SFLOAT:
return 1;
default:
Refresh_LogError(
"Unrecognized TextureFormat!"
);
return 0;
}
}
static inline uint32_t Texture_GetFormatSize( static inline uint32_t Texture_GetFormatSize(
Refresh_TextureFormat format Refresh_TextureFormat format
) { ) {
@ -87,7 +127,7 @@ static inline uint32_t Texture_GetFormatSize(
return 16; return 16;
default: default:
Refresh_LogError( Refresh_LogError(
"Unrecognized SurfaceFormat!" "Unrecognized TextureFormat!"
); );
return 0; return 0;
} }
@ -171,6 +211,22 @@ static inline int32_t BytesPerImage(
#define MAX_COLOR_TARGET_BINDINGS 4 #define MAX_COLOR_TARGET_BINDINGS 4
#define MAX_PRESENT_COUNT 16 #define MAX_PRESENT_COUNT 16
/* Internal Shader Module Create Info */
typedef enum Refresh_Driver_ShaderType
{
REFRESH_DRIVER_SHADERTYPE_VERTEX,
REFRESH_DRIVER_SHADERTYPE_FRAGMENT,
REFRESH_DRIVER_SHADERTYPE_COMPUTE
} Refresh_Driver_ShaderType;
typedef struct Refresh_Driver_ShaderModuleCreateInfo
{
size_t codeSize;
const uint32_t* byteCode;
Refresh_Driver_ShaderType type;
} Refresh_Driver_ShaderModuleCreateInfo;
/* Refresh_Device Definition */ /* Refresh_Device Definition */
typedef struct Refresh_Renderer Refresh_Renderer; typedef struct Refresh_Renderer Refresh_Renderer;
@ -252,7 +308,7 @@ struct Refresh_Device
Refresh_ShaderModule* (*CreateShaderModule)( Refresh_ShaderModule* (*CreateShaderModule)(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo Refresh_Driver_ShaderModuleCreateInfo *shaderModuleCreateInfo
); );
Refresh_Texture* (*CreateTexture)( Refresh_Texture* (*CreateTexture)(
@ -597,6 +653,7 @@ typedef struct Refresh_Driver
} Refresh_Driver; } Refresh_Driver;
extern Refresh_Driver VulkanDriver; extern Refresh_Driver VulkanDriver;
extern Refresh_Driver D3D11Driver;
extern Refresh_Driver PS5Driver; extern Refresh_Driver PS5Driver;
#endif /* REFRESH_DRIVER_H */ #endif /* REFRESH_DRIVER_H */

4292
src/Refresh_Driver_D3D11.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,42 @@
/* 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_FACTORY1)(const GUID* riid, void** ppFactory);
typedef HRESULT(WINAPI* PFN_DXGI_GET_DEBUG_INTERFACE)(const GUID* riid, void** ppDebug);
/* 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_IDXGIFactory4 = { 0x1bc6ea02,0xef36,0x464f,{0xbf,0x0c,0x21,0xca,0x39,0xe5,0x16,0x8a} };
static const IID D3D_IID_IDXGIFactory5 = { 0x7632e1f5,0xee65,0x4dca,{0x87,0xfd,0x84,0xcd,0x75,0xf8,0x83,0x8d} };
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} };
static const IID D3D_IID_ID3D11Device1 = { 0xa04bfb29,0x08ef,0x43d6,{0xa4,0x9c,0xa9,0xbd,0xbd,0xcb,0xe6,0x86} };
static const IID D3D_IID_IDXGIDebug = { 0x119e7452,0xde9e,0x40fe,{0x88,0x06,0x88,0xf9,0x0c,0x12,0xb4,0x41} };
static const IID D3D_IID_IDXGIInfoQueue = { 0xd67441c7,0x672a,0x476f,{0x9e,0x82,0xcd,0x55,0xb4,0x49,0x49,0xce} };
static const GUID D3D_IID_DXGI_DEBUG_ALL = { 0xe48ae283,0xda80,0x490b,{0x87,0xe6,0x43,0xe9,0xa9,0xcf,0xda,0x08} };

View File

@ -318,7 +318,7 @@ static Refresh_Sampler* TEMPLATE_CreateSampler(
static Refresh_ShaderModule* TEMPLATE_CreateShaderModule( static Refresh_ShaderModule* TEMPLATE_CreateShaderModule(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo Refresh_Driver_ShaderModuleCreateInfo *shaderModuleCreateInfo
) { ) {
NOT_IMPLEMENTED NOT_IMPLEMENTED
} }

View File

@ -3003,7 +3003,8 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
else else
{ {
ignoredMemoryPropertyFlags = ignoredMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT; VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
} }
if (preferDeviceLocal) if (preferDeviceLocal)
@ -3043,13 +3044,20 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
} }
/* Bind failed, try again if originally preferred device local */ /* Bind failed, try again if originally preferred device local */
if (bindResult != 1) if (bindResult != 1 && preferDeviceLocal)
{ {
memoryTypeIndex = 0; memoryTypeIndex = 0;
requiredMemoryPropertyFlags = requiredMemoryPropertyFlags = 0;
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; if (requireHostVisible)
{
requiredMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}
ignoredMemoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
/* Follow-up for the warning logged by FindMemoryType */ /* Follow-up for the warning logged by FindMemoryType */
if (!renderer->unifiedMemoryWarning) if (!renderer->unifiedMemoryWarning)
@ -4275,7 +4283,8 @@ static VulkanBufferContainer* VULKAN_INTERNAL_CreateBufferContainer(
VulkanRenderer *renderer, VulkanRenderer *renderer,
uint32_t sizeInBytes, uint32_t sizeInBytes,
VulkanResourceAccessType resourceAccessType, VulkanResourceAccessType resourceAccessType,
VkBufferUsageFlags usageFlags VkBufferUsageFlags usageFlags,
uint8_t dedicated
) { ) {
VulkanBufferContainer* bufferContainer; VulkanBufferContainer* bufferContainer;
VulkanBuffer* buffer; VulkanBuffer* buffer;
@ -4290,7 +4299,7 @@ static VulkanBufferContainer* VULKAN_INTERNAL_CreateBufferContainer(
usageFlags, usageFlags,
0, 0,
1, 1,
0 dedicated
); );
if (buffer == NULL) if (buffer == NULL)
@ -6947,7 +6956,7 @@ static Refresh_Sampler* VULKAN_CreateSampler(
static Refresh_ShaderModule* VULKAN_CreateShaderModule( static Refresh_ShaderModule* VULKAN_CreateShaderModule(
Refresh_Renderer *driverData, Refresh_Renderer *driverData,
Refresh_ShaderModuleCreateInfo *shaderModuleCreateInfo Refresh_Driver_ShaderModuleCreateInfo *shaderModuleCreateInfo
) { ) {
VulkanShaderModule *vulkanShaderModule = SDL_malloc(sizeof(VulkanShaderModule)); VulkanShaderModule *vulkanShaderModule = SDL_malloc(sizeof(VulkanShaderModule));
VkResult vulkanResult; VkResult vulkanResult;
@ -7121,7 +7130,8 @@ static Refresh_Buffer* VULKAN_CreateBuffer(
(VulkanRenderer*) driverData, (VulkanRenderer*) driverData,
sizeInBytes, sizeInBytes,
resourceAccessType, resourceAccessType,
vulkanUsageFlags vulkanUsageFlags,
0
); );
} }
@ -7203,7 +7213,7 @@ static VulkanTransferBuffer* VULKAN_INTERNAL_AcquireTransferBuffer(
RESOURCE_ACCESS_TRANSFER_READ_WRITE, RESOURCE_ACCESS_TRANSFER_READ_WRITE,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
1, 1,
0, 1,
1 1
); );
transferBuffer->fromPool = 0; transferBuffer->fromPool = 0;
@ -12123,7 +12133,7 @@ static Refresh_Device* VULKAN_CreateDevice(
RESOURCE_ACCESS_TRANSFER_READ_WRITE, RESOURCE_ACCESS_TRANSFER_READ_WRITE,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT, VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
1, 1,
0, 1,
1 1
); );

View File

@ -61,7 +61,7 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>REFRESH_DRIVER_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>REFRESH_DRIVER_VULKAN;REFRESH_DRIVER_D3D11;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation> <GenerateDebugInformation>DebugFull</GenerateDebugInformation>
@ -72,7 +72,7 @@
<ClCompile> <ClCompile>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization> <Optimization>MaxSpeed</Optimization>
<PreprocessorDefinitions>REFRESH_DRIVER_VULKAN;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>REFRESH_DRIVER_VULKAN;REFRESH_DRIVER_D3D11;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile> </ClCompile>
@ -84,6 +84,7 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\src\Refresh.c" /> <ClCompile Include="..\src\Refresh.c" />
<ClCompile Include="..\src\Refresh_Driver_D3D11.c" />
<ClCompile Include="..\src\Refresh_Driver_Vulkan.c" /> <ClCompile Include="..\src\Refresh_Driver_Vulkan.c" />
<ClCompile Include="..\src\Refresh_Image.c" /> <ClCompile Include="..\src\Refresh_Image.c" />
</ItemGroup> </ItemGroup>
@ -91,6 +92,7 @@
<ClInclude Include="..\include\Refresh.h" /> <ClInclude Include="..\include\Refresh.h" />
<ClInclude Include="..\include\Refresh_Image.h" /> <ClInclude Include="..\include\Refresh_Image.h" />
<ClInclude Include="..\src\Refresh_Driver.h" /> <ClInclude Include="..\src\Refresh_Driver.h" />
<ClInclude Include="..\src\Refresh_Driver_D3D11_cdefines.h" />
<ClInclude Include="..\src\Refresh_Driver_Vulkan_vkfuncs.h" /> <ClInclude Include="..\src\Refresh_Driver_Vulkan_vkfuncs.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -10,6 +10,9 @@
<ClCompile Include="..\src\Refresh_Image.c"> <ClCompile Include="..\src\Refresh_Image.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\Refresh_Driver_D3D11.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\include\Refresh.h"> <ClInclude Include="..\include\Refresh.h">
@ -24,6 +27,9 @@
<ClInclude Include="..\include\Refresh_Image.h"> <ClInclude Include="..\include\Refresh_Image.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\src\Refresh_Driver_D3D11_cdefines.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Filter Include="Header Files"> <Filter Include="Header Files">