Compare commits

...

54 Commits

Author SHA1 Message Date
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
cosmonaut c99b4cdfa1 fix incorrect flag bit 2024-01-31 14:47:01 -08:00
cosmonaut 2803e6d94e force ignore device-local property if allocation failed 2024-01-31 14:36:02 -08:00
cosmonaut 30b5f1dd21 user-requested buffers are no longer host-visible 2024-01-31 14:26:40 -08:00
cosmonaut 4ce2d80f80 Intel doesn't like 1 byte buffers 2024-01-19 10:19:23 -08:00
cosmonaut 27e9c741f8 1.15.4 2024-01-15 22:34:31 -08:00
cosmonaut c10ca98ccd Remove some unused variables 2024-01-15 22:25:27 -08:00
cosmonaut d441424b7c Fix ANY_SHADER_READ_SAMPLED_IMAGE sync hazard 2024-01-15 21:41:36 -08:00
cosmonaut 55c77def69 Revert "Fix potential sync hazards (#49)"
This reverts commit 20636ec951.
2024-01-15 21:38:37 -08:00
cosmonaut 2634359b48 Texture size calculation fixes 2024-01-15 16:36:56 -08:00
cosmonaut 56e3eb2af5 1.15.3 2024-01-15 12:47:49 -08:00
cosmonaut 859fc3b9fa fix UBO buffer size 2024-01-13 23:45:07 -08:00
cosmonaut 05350a9332 UBO offsets should respect alignment 2024-01-13 23:39:58 -08:00
cosmonaut 760c29699f 1.15.2 2024-01-12 18:10:11 -08:00
cosmonaut 20636ec951 Fix potential sync hazards (#49)
We now do certain image layout transitions in the render pass instead of a barrier in EndRenderPass.

There is also an additional barrier on buffer uploads to prevent write-after-write hazard. It's a kludge on the fact that we're only tracking the most recent resource access.

Reviewed-on: MoonsideGames/Refresh#49
2024-01-12 18:10:11 -08:00
cosmonaut 7297eba889 Uniform buffers are now slices of dedicated allocs (#48)
This should fix an issue where draw calls could flicker if a defrag was in progress and a uniform buffer was being used.

Uniform buffer "pools" are now just a single dedicated VulkanBuffer, and the uniform buffer objects are offsets into that buffer.

Reviewed-on: MoonsideGames/Refresh#48
2024-01-13 01:41:12 +00:00
cosmonaut b72b0b5fde fix path quotes in shadercompiler 2024-01-11 16:26:08 -08:00
cosmonaut fa92e9e08a change dummy uniform buffer size to 1 2023-12-08 12:49:46 -08:00
cosmonaut 483c07f3a8 Vulkan: fix dummy UBOs becoming invalid after defrag 2023-12-05 12:22:40 -08:00
cosmonaut f01d5d817a Vulkan: fix some missed cleanup in DestroyDevice 2023-12-04 17:28:25 -08:00
cosmonaut 17aae46eae revert OSX deployment target to 10.9 2023-12-04 16:37:22 -08:00
cosmonaut 1b3e954da8 change render pass barriers to read-write 2023-11-09 11:00:19 -08:00
Evan Hemsley 0989e45f88 MoltenVK support 2023-10-14 22:14:00 -07:00
Evan Hemsley 6e6fec5224 bump OSX version to 10.15 2023-10-14 20:46:22 -07:00
cosmonaut 34b2e437de 1.15.1 2023-10-12 11:18:37 -07:00
cosmonaut d69bbbe818 fix Vulkan SDK include on Windows 2023-10-12 11:11:44 -07:00
cosmonaut 54a8ff122c Fix uniform buffers not tracking correctly 2023-10-12 11:11:27 -07:00
10 changed files with 3569 additions and 189 deletions

View File

@ -9,7 +9,7 @@ option(BUILD_SHARED_LIBS "Build shared library" ON)
# Version # Version
SET(LIB_MAJOR_VERSION "1") SET(LIB_MAJOR_VERSION "1")
SET(LIB_MINOR_VERSION "15") SET(LIB_MINOR_VERSION "15")
SET(LIB_REVISION "0") SET(LIB_REVISION "4")
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
@ -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
) )
@ -60,6 +68,11 @@ if(NOT MSVC)
set_property(TARGET Refresh PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall -Wno-strict-aliasing -pedantic") set_property(TARGET Refresh PROPERTY COMPILE_FLAGS "-std=gnu99 -Wall -Wno-strict-aliasing -pedantic")
endif() endif()
# Windows is silly and we need to manually include the Vulkan SDK
if(MSVC)
target_include_directories(Refresh PUBLIC $ENV{VULKAN_SDK}/include)
endif()
# Refresh folders as includes, for other targets to consume # Refresh folders as includes, for other targets to consume
target_include_directories(Refresh PUBLIC target_include_directories(Refresh PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>

View File

@ -56,7 +56,7 @@ extern "C" {
#define REFRESH_MAJOR_VERSION 1 #define REFRESH_MAJOR_VERSION 1
#define REFRESH_MINOR_VERSION 15 #define REFRESH_MINOR_VERSION 15
#define REFRESH_PATCH_VERSION 0 #define REFRESH_PATCH_VERSION 4
#define REFRESH_COMPILED_VERSION ( \ #define REFRESH_COMPILED_VERSION ( \
(REFRESH_MAJOR_VERSION * 100 * 100) + \ (REFRESH_MAJOR_VERSION * 100 * 100) + \
@ -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

@ -200,20 +200,20 @@ partial class Program
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
} }
} }
@ -238,7 +238,7 @@ partial class Program
{ {
Process glslc = Process.Start( Process glslc = Process.Start(
"glslc", "glslc",
$"""{glslPath}"" -o ""{outputPath}""" $"\"{glslPath}\" -o \"{outputPath}\""
); );
glslc.WaitForExit(); glslc.WaitForExit();
if (glslc.ExitCode != 0) if (glslc.ExitCode != 0)
@ -254,7 +254,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
}; };

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;
} }
@ -597,6 +637,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 */

3221
src/Refresh_Driver_D3D11.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
/* 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);
/* 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} };
static const IID D3D_IID_ID3D11Device1 = { 0xa04bfb29,0x08ef,0x43d6,{0xa4,0x9c,0xa9,0xbd,0xbd,0xcb,0xe6,0x86} };

View File

@ -79,7 +79,8 @@ typedef struct VulkanExtensions
#define ALLOCATION_INCREMENT 16000000 /* 16MB */ #define ALLOCATION_INCREMENT 16000000 /* 16MB */
#define TRANSFER_BUFFER_STARTING_SIZE 8000000 /* 8MB */ #define TRANSFER_BUFFER_STARTING_SIZE 8000000 /* 8MB */
#define POOLED_TRANSFER_BUFFER_SIZE 16000000 /* 16MB */ #define POOLED_TRANSFER_BUFFER_SIZE 16000000 /* 16MB */
#define UBO_BUFFER_SIZE 16000 /* 16KB */ #define UBO_BUFFER_SIZE 16777216 /* 16MB */
#define UBO_SECTION_SIZE 4096 /* 4KB */
#define DESCRIPTOR_POOL_STARTING_SIZE 128 #define DESCRIPTOR_POOL_STARTING_SIZE 128
#define DEFRAG_TIME 200 #define DEFRAG_TIME 200
#define WINDOW_DATA "Refresh_VulkanWindowData" #define WINDOW_DATA "Refresh_VulkanWindowData"
@ -560,8 +561,8 @@ static const VulkanResourceAccessInfo AccessMap[RESOURCE_ACCESS_TYPES_COUNT] =
/* RESOURCE_ACCESS_ANY_SHADER_READ_SAMPLED_IMAGE */ /* RESOURCE_ACCESS_ANY_SHADER_READ_SAMPLED_IMAGE */
{ {
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
VK_ACCESS_SHADER_READ_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_INPUT_ATTACHMENT_READ_BIT,
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
}, },
@ -707,6 +708,7 @@ struct VulkanBuffer
VulkanResourceAccessType resourceAccessType; VulkanResourceAccessType resourceAccessType;
VkBufferUsageFlags usage; VkBufferUsageFlags usage;
uint8_t requireHostVisible;
uint8_t preferDeviceLocal; uint8_t preferDeviceLocal;
SDL_atomic_t referenceCount; /* Tracks command buffer usage */ SDL_atomic_t referenceCount; /* Tracks command buffer usage */
@ -719,8 +721,8 @@ typedef struct VulkanUniformBufferPool VulkanUniformBufferPool;
typedef struct VulkanUniformBuffer typedef struct VulkanUniformBuffer
{ {
VulkanUniformBufferPool *pool; VulkanUniformBufferPool *pool;
VulkanBuffer *vulkanBuffer; VkDeviceSize poolOffset; /* memory offset relative to the pool buffer */
VkDeviceSize offset; VkDeviceSize offset; /* based on uniform pushes */
VkDescriptorSet descriptorSet; VkDescriptorSet descriptorSet;
} VulkanUniformBuffer; } VulkanUniformBuffer;
@ -746,10 +748,13 @@ typedef struct VulkanUniformDescriptorPool
uint32_t availableDescriptorSetCount; uint32_t availableDescriptorSetCount;
} VulkanUniformDescriptorPool; } VulkanUniformDescriptorPool;
/* This is actually just one buffer that we carve slices out of. */
struct VulkanUniformBufferPool struct VulkanUniformBufferPool
{ {
VulkanUniformBufferType type; VulkanUniformBufferType type;
VulkanUniformDescriptorPool descriptorPool; VulkanUniformDescriptorPool descriptorPool;
VulkanBuffer *buffer;
VkDeviceSize nextAvailableOffset;
SDL_mutex *lock; SDL_mutex *lock;
VulkanUniformBuffer **availableBuffers; VulkanUniformBuffer **availableBuffers;
@ -1776,6 +1781,8 @@ typedef struct VulkanRenderer
VkDescriptorSetLayout vertexUniformDescriptorSetLayout; VkDescriptorSetLayout vertexUniformDescriptorSetLayout;
VkDescriptorSetLayout fragmentUniformDescriptorSetLayout; VkDescriptorSetLayout fragmentUniformDescriptorSetLayout;
VkDescriptorSetLayout computeUniformDescriptorSetLayout; VkDescriptorSetLayout computeUniformDescriptorSetLayout;
VulkanBuffer *dummyBuffer;
VulkanUniformBuffer *dummyVertexUniformBuffer; VulkanUniformBuffer *dummyVertexUniformBuffer;
VulkanUniformBuffer *dummyFragmentUniformBuffer; VulkanUniformBuffer *dummyFragmentUniformBuffer;
VulkanUniformBuffer *dummyComputeUniformBuffer; VulkanUniformBuffer *dummyComputeUniformBuffer;
@ -1973,59 +1980,51 @@ static inline uint32_t VULKAN_INTERNAL_BytesPerPixel(VkFormat format)
{ {
switch (format) switch (format)
{ {
case VK_FORMAT_R8_UNORM:
case VK_FORMAT_R8_UINT:
return 1;
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
case VK_FORMAT_R16_SFLOAT:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R16_UINT:
case VK_FORMAT_D16_UNORM:
return 2;
case VK_FORMAT_D16_UNORM_S8_UINT:
return 3;
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16_SFLOAT:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_D32_SFLOAT:
return 4;
case VK_FORMAT_D32_SFLOAT_S8_UINT:
return 5;
case VK_FORMAT_R16G16B16A16_SFLOAT:
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R16G16B16A16_UINT:
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
return 8;
case VK_FORMAT_R32G32B32A32_SFLOAT: case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_BC2_UNORM_BLOCK: case VK_FORMAT_BC2_UNORM_BLOCK:
case VK_FORMAT_BC3_UNORM_BLOCK: case VK_FORMAT_BC3_UNORM_BLOCK:
case VK_FORMAT_BC7_UNORM_BLOCK: case VK_FORMAT_BC7_UNORM_BLOCK:
case VK_FORMAT_R16G16B16A16_UINT:
return 16; return 16;
case VK_FORMAT_R8G8B8A8_UNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_B8G8R8A8_UNORM:
case VK_FORMAT_B8G8R8A8_SNORM:
case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16_SFLOAT:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_D32_SFLOAT:
case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R16G16_UINT:
return 4;
case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R16_SFLOAT:
case VK_FORMAT_D16_UNORM:
case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R16_UINT:
return 2;
case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R16G16B16A16_SFLOAT:
case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
case VK_FORMAT_R8_UINT:
return 8;
case VK_FORMAT_R8_UNORM:
return 1;
case VK_FORMAT_D16_UNORM_S8_UINT:
return 3;
case VK_FORMAT_D32_SFLOAT_S8_UINT:
return 5;
default: default:
Refresh_LogError("Invalid texture format!"); Refresh_LogError("Texture format not recognized!");
return 0; return 0;
} }
} }
static inline uint32_t VULKAN_INTERNAL_GetTextureBlockSize( static inline uint32_t VULKAN_INTERNAL_TextureBlockSize(
VkFormat format VkFormat format
) { ) {
switch (format) switch (format)
@ -2040,24 +2039,28 @@ static inline uint32_t VULKAN_INTERNAL_GetTextureBlockSize(
case VK_FORMAT_R5G6B5_UNORM_PACK16: case VK_FORMAT_R5G6B5_UNORM_PACK16:
case VK_FORMAT_A1R5G5B5_UNORM_PACK16: case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
case VK_FORMAT_B4G4R4A4_UNORM_PACK16: case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_A2R10G10B10_UNORM_PACK32: case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
case VK_FORMAT_R16G16_UNORM: case VK_FORMAT_R16G16_UNORM:
case VK_FORMAT_R16G16B16A16_UNORM: case VK_FORMAT_R16G16B16A16_UNORM:
case VK_FORMAT_R8_UNORM: case VK_FORMAT_R8_UNORM:
case VK_FORMAT_R32_SFLOAT: case VK_FORMAT_R8G8_SNORM:
case VK_FORMAT_R32G32_SFLOAT: case VK_FORMAT_R8G8B8A8_SNORM:
case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_R16_SFLOAT: case VK_FORMAT_R16_SFLOAT:
case VK_FORMAT_R16G16_SFLOAT: case VK_FORMAT_R16G16_SFLOAT:
case VK_FORMAT_R16G16B16A16_SFLOAT: case VK_FORMAT_R16G16B16A16_SFLOAT:
case VK_FORMAT_R32_SFLOAT:
case VK_FORMAT_R32G32_SFLOAT:
case VK_FORMAT_R32G32B32A32_SFLOAT:
case VK_FORMAT_R8_UINT: case VK_FORMAT_R8_UINT:
case VK_FORMAT_R8G8_UINT: case VK_FORMAT_R8G8_UINT:
case VK_FORMAT_R8G8B8A8_UINT: case VK_FORMAT_R8G8B8A8_UINT:
case VK_FORMAT_R16_UINT: case VK_FORMAT_R16_UINT:
case VK_FORMAT_R16G16_UINT: case VK_FORMAT_R16G16_UINT:
case VK_FORMAT_R16G16B16A16_UINT: case VK_FORMAT_R16G16B16A16_UINT:
case VK_FORMAT_D16_UNORM:
case VK_FORMAT_D32_SFLOAT:
case VK_FORMAT_D16_UNORM_S8_UINT:
case VK_FORMAT_D32_SFLOAT_S8_UINT:
return 1; return 1;
default: default:
Refresh_LogError("Unrecognized texture format!"); Refresh_LogError("Unrecognized texture format!");
@ -2070,17 +2073,8 @@ static inline VkDeviceSize VULKAN_INTERNAL_BytesPerImage(
uint32_t height, uint32_t height,
VkFormat format VkFormat format
) { ) {
uint32_t blocksPerRow = width; uint32_t blockSize = VULKAN_INTERNAL_TextureBlockSize(format);
uint32_t blocksPerColumn = height; return (width * height * VULKAN_INTERNAL_BytesPerPixel(format)) / (blockSize * blockSize);
uint32_t blockSize = VULKAN_INTERNAL_GetTextureBlockSize(format);
if (blockSize > 1)
{
blocksPerRow = (width + blockSize - 1) / blockSize;
blocksPerColumn = (height + blockSize - 1) / blockSize;
}
return blocksPerRow * blocksPerColumn * VULKAN_INTERNAL_BytesPerPixel(format);
} }
static inline Refresh_SampleCount VULKAN_INTERNAL_GetMaxMultiSampleCount( static inline Refresh_SampleCount VULKAN_INTERNAL_GetMaxMultiSampleCount(
@ -2398,12 +2392,6 @@ static uint8_t VULKAN_INTERNAL_FindMemoryType(
} }
} }
Refresh_LogWarn(
"Failed to find memory type %X, required %X, ignored %X",
typeFilter,
requiredProperties,
ignoredProperties
);
return 0; return 0;
} }
@ -2587,7 +2575,6 @@ static uint8_t VULKAN_INTERNAL_AllocateMemory(
SDL_free(allocation); SDL_free(allocation);
Refresh_LogWarn("vkAllocateMemory: %s", VkErrorMessages(result));
return 0; return 0;
} }
@ -2821,7 +2808,6 @@ static uint8_t VULKAN_INTERNAL_BindResourceMemory(
SDL_UnlockMutex(renderer->allocatorLock); SDL_UnlockMutex(renderer->allocatorLock);
/* Responsibility of the caller to handle being out of memory */ /* Responsibility of the caller to handle being out of memory */
Refresh_LogWarn("Failed to allocate memory!");
return 2; return 2;
} }
@ -2947,7 +2933,7 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForImage(
{ {
memoryTypeIndex = 0; memoryTypeIndex = 0;
requiredMemoryPropertyFlags = 0; requiredMemoryPropertyFlags = 0;
ignoredMemoryPropertyFlags = VK_MEMORY_HEAP_DEVICE_LOCAL_BIT; ignoredMemoryPropertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT;
if (isRenderTarget) if (isRenderTarget)
{ {
@ -2993,23 +2979,33 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
VulkanRenderer* renderer, VulkanRenderer* renderer,
VkBuffer buffer, VkBuffer buffer,
VkDeviceSize size, VkDeviceSize size,
uint8_t requireHostVisible,
uint8_t preferDeviceLocal, uint8_t preferDeviceLocal,
uint8_t isTransferBuffer, uint8_t dedicatedAllocation,
VulkanMemoryUsedRegion** usedRegion VulkanMemoryUsedRegion** usedRegion
) { ) {
uint8_t bindResult = 0; uint8_t bindResult = 0;
uint32_t memoryTypeIndex = 0; uint32_t memoryTypeIndex = 0;
VkMemoryPropertyFlags requiredMemoryPropertyFlags; VkMemoryPropertyFlags requiredMemoryPropertyFlags = 0;
VkMemoryPropertyFlags ignoredMemoryPropertyFlags; VkMemoryPropertyFlags ignoredMemoryPropertyFlags = 0;
VkMemoryRequirements2KHR memoryRequirements = VkMemoryRequirements2KHR memoryRequirements =
{ {
VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR, VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR,
NULL NULL
}; };
requiredMemoryPropertyFlags = if (requireHostVisible)
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | {
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT; requiredMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}
else
{
ignoredMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT;
}
if (preferDeviceLocal) if (preferDeviceLocal)
{ {
@ -3030,7 +3026,7 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
renderer, renderer,
memoryTypeIndex, memoryTypeIndex,
&memoryRequirements, &memoryRequirements,
isTransferBuffer, dedicatedAllocation,
size, size,
buffer, buffer,
VK_NULL_HANDLE, VK_NULL_HANDLE,
@ -3051,9 +3047,17 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
if (bindResult != 1 && preferDeviceLocal) if (bindResult != 1 && preferDeviceLocal)
{ {
memoryTypeIndex = 0; memoryTypeIndex = 0;
requiredMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | requiredMemoryPropertyFlags = 0;
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)
@ -3074,7 +3078,7 @@ static uint8_t VULKAN_INTERNAL_BindMemoryForBuffer(
renderer, renderer,
memoryTypeIndex, memoryTypeIndex,
&memoryRequirements, &memoryRequirements,
isTransferBuffer, dedicatedAllocation,
size, size,
buffer, buffer,
VK_NULL_HANDLE, VK_NULL_HANDLE,
@ -3606,6 +3610,8 @@ static void VULKAN_INTERNAL_DestroyCommandPool(
SDL_free(commandBuffer->transferBuffers); SDL_free(commandBuffer->transferBuffers);
SDL_free(commandBuffer->boundUniformBuffers); SDL_free(commandBuffer->boundUniformBuffers);
SDL_free(commandBuffer->boundDescriptorSetDatas); SDL_free(commandBuffer->boundDescriptorSetDatas);
SDL_free(commandBuffer->boundComputeBuffers);
SDL_free(commandBuffer->boundComputeTextures);
SDL_free(commandBuffer->usedBuffers); SDL_free(commandBuffer->usedBuffers);
SDL_free(commandBuffer->usedTextures); SDL_free(commandBuffer->usedTextures);
SDL_free(commandBuffer->usedSamplers); SDL_free(commandBuffer->usedSamplers);
@ -4109,8 +4115,9 @@ static VulkanBuffer* VULKAN_INTERNAL_CreateBuffer(
VkDeviceSize size, VkDeviceSize size,
VulkanResourceAccessType resourceAccessType, VulkanResourceAccessType resourceAccessType,
VkBufferUsageFlags usage, VkBufferUsageFlags usage,
uint8_t requireHostVisible,
uint8_t preferDeviceLocal, uint8_t preferDeviceLocal,
uint8_t isTransferBuffer uint8_t dedicatedAllocation
) { ) {
VulkanBuffer* buffer; VulkanBuffer* buffer;
VkResult vulkanResult; VkResult vulkanResult;
@ -4122,6 +4129,7 @@ static VulkanBuffer* VULKAN_INTERNAL_CreateBuffer(
buffer->size = size; buffer->size = size;
buffer->resourceAccessType = resourceAccessType; buffer->resourceAccessType = resourceAccessType;
buffer->usage = usage; buffer->usage = usage;
buffer->requireHostVisible = requireHostVisible;
buffer->preferDeviceLocal = preferDeviceLocal; buffer->preferDeviceLocal = preferDeviceLocal;
bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO; bufferCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
@ -4145,8 +4153,9 @@ static VulkanBuffer* VULKAN_INTERNAL_CreateBuffer(
renderer, renderer,
buffer->buffer, buffer->buffer,
buffer->size, buffer->size,
buffer->requireHostVisible,
buffer->preferDeviceLocal, buffer->preferDeviceLocal,
isTransferBuffer, dedicatedAllocation,
&buffer->usedRegion &buffer->usedRegion
); );
@ -4203,6 +4212,37 @@ static VulkanUniformBufferPool* VULKAN_INTERNAL_CreateUniformBufferPool(
VulkanUniformBufferType uniformBufferType VulkanUniformBufferType uniformBufferType
) { ) {
VulkanUniformBufferPool* uniformBufferPool = SDL_malloc(sizeof(VulkanUniformBufferPool)); VulkanUniformBufferPool* uniformBufferPool = SDL_malloc(sizeof(VulkanUniformBufferPool));
VulkanResourceAccessType resourceAccessType;
if (uniformBufferType == UNIFORM_BUFFER_VERTEX)
{
resourceAccessType = RESOURCE_ACCESS_VERTEX_SHADER_READ_UNIFORM_BUFFER;
}
else if (uniformBufferType == UNIFORM_BUFFER_FRAGMENT)
{
resourceAccessType = RESOURCE_ACCESS_FRAGMENT_SHADER_READ_UNIFORM_BUFFER;
}
else if (uniformBufferType == UNIFORM_BUFFER_COMPUTE)
{
resourceAccessType = RESOURCE_ACCESS_COMPUTE_SHADER_READ_UNIFORM_BUFFER;
}
else
{
Refresh_LogError("Unrecognized uniform buffer type!");
return 0;
}
uniformBufferPool->buffer = VULKAN_INTERNAL_CreateBuffer(
renderer,
UBO_BUFFER_SIZE,
resourceAccessType,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
1,
0,
1
);
uniformBufferPool->nextAvailableOffset = 0;
uniformBufferPool->type = uniformBufferType; uniformBufferPool->type = uniformBufferType;
uniformBufferPool->lock = SDL_CreateMutex(); uniformBufferPool->lock = SDL_CreateMutex();
@ -4221,6 +4261,7 @@ static VulkanUniformBufferPool* VULKAN_INTERNAL_CreateUniformBufferPool(
} }
static void VULKAN_INTERNAL_BindUniformBuffer( static void VULKAN_INTERNAL_BindUniformBuffer(
VulkanRenderer *renderer,
VulkanCommandBuffer *commandBuffer, VulkanCommandBuffer *commandBuffer,
VulkanUniformBuffer *uniformBuffer VulkanUniformBuffer *uniformBuffer
) { ) {
@ -4237,26 +4278,59 @@ static void VULKAN_INTERNAL_BindUniformBuffer(
commandBuffer->boundUniformBufferCount += 1; commandBuffer->boundUniformBufferCount += 1;
} }
/* Buffer indirection so we can cleanly defrag */
static VulkanBufferContainer* VULKAN_INTERNAL_CreateBufferContainer(
VulkanRenderer *renderer,
uint32_t sizeInBytes,
VulkanResourceAccessType resourceAccessType,
VkBufferUsageFlags usageFlags,
uint8_t dedicated
) {
VulkanBufferContainer* bufferContainer;
VulkanBuffer* buffer;
/* always set transfer bits so we can defrag */
usageFlags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
buffer = VULKAN_INTERNAL_CreateBuffer(
renderer,
sizeInBytes,
resourceAccessType,
usageFlags,
0,
1,
dedicated
);
if (buffer == NULL)
{
Refresh_LogError("Failed to create buffer!");
return NULL;
}
bufferContainer = SDL_malloc(sizeof(VulkanBufferContainer));
bufferContainer->vulkanBuffer = buffer;
buffer->container = bufferContainer;
return (VulkanBufferContainer*) bufferContainer;
}
static uint8_t VULKAN_INTERNAL_CreateUniformBuffer( static uint8_t VULKAN_INTERNAL_CreateUniformBuffer(
VulkanRenderer *renderer, VulkanRenderer *renderer,
VulkanUniformBufferPool *bufferPool VulkanUniformBufferPool *bufferPool
) { ) {
VulkanResourceAccessType resourceAccessType;
VkDescriptorSetLayout descriptorSetLayout; VkDescriptorSetLayout descriptorSetLayout;
if (bufferPool->type == UNIFORM_BUFFER_VERTEX) if (bufferPool->type == UNIFORM_BUFFER_VERTEX)
{ {
resourceAccessType = RESOURCE_ACCESS_VERTEX_SHADER_READ_UNIFORM_BUFFER;
descriptorSetLayout = renderer->vertexUniformDescriptorSetLayout; descriptorSetLayout = renderer->vertexUniformDescriptorSetLayout;
} }
else if (bufferPool->type == UNIFORM_BUFFER_FRAGMENT) else if (bufferPool->type == UNIFORM_BUFFER_FRAGMENT)
{ {
resourceAccessType = RESOURCE_ACCESS_FRAGMENT_SHADER_READ_UNIFORM_BUFFER;
descriptorSetLayout = renderer->fragmentUniformDescriptorSetLayout; descriptorSetLayout = renderer->fragmentUniformDescriptorSetLayout;
} }
else if (bufferPool->type == UNIFORM_BUFFER_COMPUTE) else if (bufferPool->type == UNIFORM_BUFFER_COMPUTE)
{ {
resourceAccessType = RESOURCE_ACCESS_COMPUTE_SHADER_READ_UNIFORM_BUFFER;
descriptorSetLayout = renderer->computeUniformDescriptorSetLayout; descriptorSetLayout = renderer->computeUniformDescriptorSetLayout;
} }
else else
@ -4265,26 +4339,20 @@ static uint8_t VULKAN_INTERNAL_CreateUniformBuffer(
return 0; return 0;
} }
VulkanUniformBuffer *buffer = SDL_malloc(sizeof(VulkanUniformBuffer)); VulkanUniformBuffer *uniformBuffer = SDL_malloc(sizeof(VulkanUniformBuffer));
buffer->pool = bufferPool; uniformBuffer->pool = bufferPool;
uniformBuffer->poolOffset = bufferPool->nextAvailableOffset;
uniformBuffer->offset = 0;
buffer->vulkanBuffer = VULKAN_INTERNAL_CreateBuffer( bufferPool->nextAvailableOffset += VULKAN_INTERNAL_NextHighestAlignment(UBO_SECTION_SIZE, renderer->minUBOAlignment);
renderer,
UBO_BUFFER_SIZE,
resourceAccessType,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
0,
0
);
if (buffer->vulkanBuffer == NULL) if (bufferPool->nextAvailableOffset >= UBO_BUFFER_SIZE)
{ {
Refresh_LogError("Failed to create buffer for uniform buffer!"); Refresh_LogError("Uniform buffer overflow!");
SDL_free(uniformBuffer);
return 0; return 0;
} }
buffer->offset = 0;
/* Allocate a descriptor set for the uniform buffer */ /* Allocate a descriptor set for the uniform buffer */
if (bufferPool->descriptorPool.availableDescriptorSetCount == 0) if (bufferPool->descriptorPool.availableDescriptorSetCount == 0)
@ -4294,6 +4362,7 @@ static uint8_t VULKAN_INTERNAL_CreateUniformBuffer(
&bufferPool->descriptorPool &bufferPool->descriptorPool
)) { )) {
Refresh_LogError("Failed to add uniform descriptor pool!"); Refresh_LogError("Failed to add uniform descriptor pool!");
SDL_free(uniformBuffer);
return 0; return 0;
} }
} }
@ -4303,7 +4372,7 @@ static uint8_t VULKAN_INTERNAL_CreateUniformBuffer(
bufferPool->descriptorPool.descriptorPools[bufferPool->descriptorPool.descriptorPoolCount - 1], bufferPool->descriptorPool.descriptorPools[bufferPool->descriptorPool.descriptorPoolCount - 1],
descriptorSetLayout, descriptorSetLayout,
1, 1,
&buffer->descriptorSet &uniformBuffer->descriptorSet
)) { )) {
Refresh_LogError("Failed to allocate uniform descriptor set!"); Refresh_LogError("Failed to allocate uniform descriptor set!");
return 0; return 0;
@ -4321,7 +4390,7 @@ static uint8_t VULKAN_INTERNAL_CreateUniformBuffer(
); );
} }
bufferPool->availableBuffers[bufferPool->availableBufferCount] = buffer; bufferPool->availableBuffers[bufferPool->availableBufferCount] = uniformBuffer;
bufferPool->availableBufferCount += 1; bufferPool->availableBufferCount += 1;
return 1; return 1;
@ -4331,24 +4400,20 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_CreateDummyUniformBuffer(
VulkanRenderer *renderer, VulkanRenderer *renderer,
VulkanUniformBufferType uniformBufferType VulkanUniformBufferType uniformBufferType
) { ) {
VulkanResourceAccessType resourceAccessType;
VkDescriptorSetLayout descriptorSetLayout; VkDescriptorSetLayout descriptorSetLayout;
VkWriteDescriptorSet writeDescriptorSet; VkWriteDescriptorSet writeDescriptorSet;
VkDescriptorBufferInfo descriptorBufferInfo; VkDescriptorBufferInfo descriptorBufferInfo;
if (uniformBufferType == UNIFORM_BUFFER_VERTEX) if (uniformBufferType == UNIFORM_BUFFER_VERTEX)
{ {
resourceAccessType = RESOURCE_ACCESS_VERTEX_SHADER_READ_UNIFORM_BUFFER;
descriptorSetLayout = renderer->vertexUniformDescriptorSetLayout; descriptorSetLayout = renderer->vertexUniformDescriptorSetLayout;
} }
else if (uniformBufferType == UNIFORM_BUFFER_FRAGMENT) else if (uniformBufferType == UNIFORM_BUFFER_FRAGMENT)
{ {
resourceAccessType = RESOURCE_ACCESS_FRAGMENT_SHADER_READ_UNIFORM_BUFFER;
descriptorSetLayout = renderer->fragmentUniformDescriptorSetLayout; descriptorSetLayout = renderer->fragmentUniformDescriptorSetLayout;
} }
else if (uniformBufferType == UNIFORM_BUFFER_COMPUTE) else if (uniformBufferType == UNIFORM_BUFFER_COMPUTE)
{ {
resourceAccessType = RESOURCE_ACCESS_COMPUTE_SHADER_READ_UNIFORM_BUFFER;
descriptorSetLayout = renderer->computeUniformDescriptorSetLayout; descriptorSetLayout = renderer->computeUniformDescriptorSetLayout;
} }
else else
@ -4357,17 +4422,9 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_CreateDummyUniformBuffer(
return NULL; return NULL;
} }
VulkanUniformBuffer *buffer = SDL_malloc(sizeof(VulkanUniformBuffer)); VulkanUniformBuffer *uniformBuffer = SDL_malloc(sizeof(VulkanUniformBuffer));
uniformBuffer->poolOffset = 0;
buffer->vulkanBuffer = VULKAN_INTERNAL_CreateBuffer( uniformBuffer->offset = 0;
renderer,
UBO_BUFFER_SIZE,
resourceAccessType,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
0,
0
);
buffer->offset = 0;
/* Allocate a descriptor set for the uniform buffer */ /* Allocate a descriptor set for the uniform buffer */
@ -4376,12 +4433,12 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_CreateDummyUniformBuffer(
renderer->defaultDescriptorPool, renderer->defaultDescriptorPool,
descriptorSetLayout, descriptorSetLayout,
1, 1,
&buffer->descriptorSet &uniformBuffer->descriptorSet
); );
/* Update the descriptor set for the first and last time! */ /* Update the descriptor set for the first and last time! */
descriptorBufferInfo.buffer = buffer->vulkanBuffer->buffer; descriptorBufferInfo.buffer = renderer->dummyBuffer->buffer;
descriptorBufferInfo.offset = 0; descriptorBufferInfo.offset = 0;
descriptorBufferInfo.range = VK_WHOLE_SIZE; descriptorBufferInfo.range = VK_WHOLE_SIZE;
@ -4391,7 +4448,7 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_CreateDummyUniformBuffer(
writeDescriptorSet.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; writeDescriptorSet.descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
writeDescriptorSet.dstArrayElement = 0; writeDescriptorSet.dstArrayElement = 0;
writeDescriptorSet.dstBinding = 0; writeDescriptorSet.dstBinding = 0;
writeDescriptorSet.dstSet = buffer->descriptorSet; writeDescriptorSet.dstSet = uniformBuffer->descriptorSet;
writeDescriptorSet.pBufferInfo = &descriptorBufferInfo; writeDescriptorSet.pBufferInfo = &descriptorBufferInfo;
writeDescriptorSet.pImageInfo = NULL; writeDescriptorSet.pImageInfo = NULL;
writeDescriptorSet.pTexelBufferView = NULL; writeDescriptorSet.pTexelBufferView = NULL;
@ -4404,9 +4461,9 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_CreateDummyUniformBuffer(
NULL NULL
); );
buffer->pool = NULL; /* No pool because this is a dummy */ uniformBuffer->pool = NULL; /* No pool because this is a dummy */
return buffer; return uniformBuffer;
} }
static void VULKAN_INTERNAL_DestroyUniformBufferPool( static void VULKAN_INTERNAL_DestroyUniformBufferPool(
@ -4428,10 +4485,11 @@ static void VULKAN_INTERNAL_DestroyUniformBufferPool(
/* This is always destroyed after submissions, so all buffers are available */ /* This is always destroyed after submissions, so all buffers are available */
for (i = 0; i < uniformBufferPool->availableBufferCount; i += 1) for (i = 0; i < uniformBufferPool->availableBufferCount; i += 1)
{ {
VULKAN_INTERNAL_DestroyBuffer(renderer, uniformBufferPool->availableBuffers[i]->vulkanBuffer);
SDL_free(uniformBufferPool->availableBuffers[i]); SDL_free(uniformBufferPool->availableBuffers[i]);
} }
VULKAN_INTERNAL_DestroyBuffer(renderer, uniformBufferPool->buffer);
SDL_DestroyMutex(uniformBufferPool->lock); SDL_DestroyMutex(uniformBufferPool->lock);
SDL_free(uniformBufferPool->availableBuffers); SDL_free(uniformBufferPool->availableBuffers);
SDL_free(uniformBufferPool); SDL_free(uniformBufferPool);
@ -4466,8 +4524,8 @@ static VulkanUniformBuffer* VULKAN_INTERNAL_AcquireUniformBufferFromPool(
/* Update the descriptor set with the correct range */ /* Update the descriptor set with the correct range */
descriptorBufferInfo.buffer = uniformBuffer->vulkanBuffer->buffer; descriptorBufferInfo.buffer = uniformBuffer->pool->buffer->buffer;
descriptorBufferInfo.offset = 0; descriptorBufferInfo.offset = uniformBuffer->poolOffset;
descriptorBufferInfo.range = blockSize; descriptorBufferInfo.range = blockSize;
writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; writeDescriptorSet.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
@ -5106,6 +5164,7 @@ static void VULKAN_INTERNAL_EndCommandBuffer(
commandBuffer->computeUniformBuffer != NULL commandBuffer->computeUniformBuffer != NULL
) { ) {
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
commandBuffer, commandBuffer,
commandBuffer->computeUniformBuffer commandBuffer->computeUniformBuffer
); );
@ -5146,9 +5205,7 @@ static void VULKAN_DestroyDevice(
SDL_free(renderer->submittedCommandBuffers); SDL_free(renderer->submittedCommandBuffers);
VULKAN_INTERNAL_DestroyBuffer(renderer, renderer->dummyVertexUniformBuffer->vulkanBuffer); VULKAN_INTERNAL_DestroyBuffer(renderer, renderer->dummyBuffer);
VULKAN_INTERNAL_DestroyBuffer(renderer, renderer->dummyFragmentUniformBuffer->vulkanBuffer);
VULKAN_INTERNAL_DestroyBuffer(renderer, renderer->dummyComputeUniformBuffer->vulkanBuffer);
SDL_free(renderer->dummyVertexUniformBuffer); SDL_free(renderer->dummyVertexUniformBuffer);
SDL_free(renderer->dummyFragmentUniformBuffer); SDL_free(renderer->dummyFragmentUniformBuffer);
@ -5371,6 +5428,7 @@ static void VULKAN_DestroyDevice(
SDL_free(renderer->computePipelinesToDestroy); SDL_free(renderer->computePipelinesToDestroy);
SDL_free(renderer->shaderModulesToDestroy); SDL_free(renderer->shaderModulesToDestroy);
SDL_free(renderer->samplersToDestroy); SDL_free(renderer->samplersToDestroy);
SDL_free(renderer->framebuffersToDestroy);
SDL_DestroyMutex(renderer->allocatorLock); SDL_DestroyMutex(renderer->allocatorLock);
SDL_DestroyMutex(renderer->disposeLock); SDL_DestroyMutex(renderer->disposeLock);
@ -7035,8 +7093,6 @@ static Refresh_Buffer* VULKAN_CreateBuffer(
Refresh_BufferUsageFlags usageFlags, Refresh_BufferUsageFlags usageFlags,
uint32_t sizeInBytes uint32_t sizeInBytes
) { ) {
VulkanBufferContainer* bufferContainer;
VulkanBuffer* buffer;
VulkanResourceAccessType resourceAccessType; VulkanResourceAccessType resourceAccessType;
VkBufferUsageFlags vulkanUsageFlags = VkBufferUsageFlags vulkanUsageFlags =
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT;
@ -7070,26 +7126,13 @@ static Refresh_Buffer* VULKAN_CreateBuffer(
resourceAccessType = RESOURCE_ACCESS_INDIRECT_BUFFER; resourceAccessType = RESOURCE_ACCESS_INDIRECT_BUFFER;
} }
buffer = VULKAN_INTERNAL_CreateBuffer( return (Refresh_Buffer*) VULKAN_INTERNAL_CreateBufferContainer(
(VulkanRenderer*)driverData, (VulkanRenderer*) driverData,
sizeInBytes, sizeInBytes,
resourceAccessType, resourceAccessType,
vulkanUsageFlags, vulkanUsageFlags,
1,
0 0
); );
if (buffer == NULL)
{
Refresh_LogError("Failed to create buffer!");
return NULL;
}
bufferContainer = SDL_malloc(sizeof(VulkanBufferContainer));
bufferContainer->vulkanBuffer = buffer;
buffer->container = bufferContainer;
return (Refresh_Buffer*) bufferContainer;
} }
/* Setters */ /* Setters */
@ -7170,6 +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,
1,
1 1
); );
transferBuffer->fromPool = 0; transferBuffer->fromPool = 0;
@ -7209,7 +7253,7 @@ static void VULKAN_SetTextureData(
VulkanTransferBuffer *transferBuffer; VulkanTransferBuffer *transferBuffer;
VkBufferImageCopy imageCopy; VkBufferImageCopy imageCopy;
uint8_t *stagingBufferPointer; uint8_t *stagingBufferPointer;
uint32_t blockSize = VULKAN_INTERNAL_GetTextureBlockSize(vulkanTexture->format); uint32_t blockSize = VULKAN_INTERNAL_TextureBlockSize(vulkanTexture->format);
uint32_t bufferRowLength; uint32_t bufferRowLength;
uint32_t bufferImageHeight; uint32_t bufferImageHeight;
@ -7788,10 +7832,11 @@ static uint32_t VULKAN_PushVertexShaderUniforms(
if ( if (
vulkanCommandBuffer->vertexUniformBuffer->offset + vulkanCommandBuffer->vertexUniformBuffer->offset +
graphicsPipeline->vertexUniformBlockSize >= graphicsPipeline->vertexUniformBlockSize >=
UBO_BUFFER_SIZE UBO_SECTION_SIZE
) { ) {
/* We're out of space in this buffer, bind the old one and acquire a new one */ /* We're out of space in this buffer, bind the old one and acquire a new one */
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->vertexUniformBuffer vulkanCommandBuffer->vertexUniformBuffer
); );
@ -7805,8 +7850,8 @@ static uint32_t VULKAN_PushVertexShaderUniforms(
offset = vulkanCommandBuffer->vertexUniformBuffer->offset; offset = vulkanCommandBuffer->vertexUniformBuffer->offset;
VULKAN_INTERNAL_SetBufferData( VULKAN_INTERNAL_SetBufferData(
vulkanCommandBuffer->vertexUniformBuffer->vulkanBuffer, vulkanCommandBuffer->vertexUniformBuffer->pool->buffer,
vulkanCommandBuffer->vertexUniformBuffer->offset, vulkanCommandBuffer->vertexUniformBuffer->poolOffset + vulkanCommandBuffer->vertexUniformBuffer->offset,
data, data,
dataLengthInBytes dataLengthInBytes
); );
@ -7831,10 +7876,11 @@ static uint32_t VULKAN_PushFragmentShaderUniforms(
if ( if (
vulkanCommandBuffer->fragmentUniformBuffer->offset + vulkanCommandBuffer->fragmentUniformBuffer->offset +
graphicsPipeline->fragmentUniformBlockSize >= graphicsPipeline->fragmentUniformBlockSize >=
UBO_BUFFER_SIZE UBO_SECTION_SIZE
) { ) {
/* We're out of space in this buffer, bind the old one and acquire a new one */ /* We're out of space in this buffer, bind the old one and acquire a new one */
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->fragmentUniformBuffer vulkanCommandBuffer->fragmentUniformBuffer
); );
@ -7848,8 +7894,8 @@ static uint32_t VULKAN_PushFragmentShaderUniforms(
offset = vulkanCommandBuffer->fragmentUniformBuffer->offset; offset = vulkanCommandBuffer->fragmentUniformBuffer->offset;
VULKAN_INTERNAL_SetBufferData( VULKAN_INTERNAL_SetBufferData(
vulkanCommandBuffer->fragmentUniformBuffer->vulkanBuffer, vulkanCommandBuffer->fragmentUniformBuffer->pool->buffer,
vulkanCommandBuffer->fragmentUniformBuffer->offset, vulkanCommandBuffer->fragmentUniformBuffer->poolOffset + vulkanCommandBuffer->fragmentUniformBuffer->offset,
data, data,
dataLengthInBytes dataLengthInBytes
); );
@ -7873,10 +7919,11 @@ static uint32_t VULKAN_PushComputeShaderUniforms(
if ( if (
vulkanCommandBuffer->computeUniformBuffer->offset + vulkanCommandBuffer->computeUniformBuffer->offset +
computePipeline->uniformBlockSize >= computePipeline->uniformBlockSize >=
UBO_BUFFER_SIZE UBO_SECTION_SIZE
) { ) {
/* We're out of space in this buffer, bind the old one and acquire a new one */ /* We're out of space in this buffer, bind the old one and acquire a new one */
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->computeUniformBuffer vulkanCommandBuffer->computeUniformBuffer
); );
@ -7890,8 +7937,8 @@ static uint32_t VULKAN_PushComputeShaderUniforms(
offset = vulkanCommandBuffer->computeUniformBuffer->offset; offset = vulkanCommandBuffer->computeUniformBuffer->offset;
VULKAN_INTERNAL_SetBufferData( VULKAN_INTERNAL_SetBufferData(
vulkanCommandBuffer->computeUniformBuffer->vulkanBuffer, vulkanCommandBuffer->computeUniformBuffer->pool->buffer,
vulkanCommandBuffer->computeUniformBuffer->offset, vulkanCommandBuffer->computeUniformBuffer->poolOffset + vulkanCommandBuffer->computeUniformBuffer->offset,
data, data,
dataLengthInBytes dataLengthInBytes
); );
@ -8816,7 +8863,7 @@ static void VULKAN_BeginRenderPass(
VULKAN_INTERNAL_ImageMemoryBarrier( VULKAN_INTERNAL_ImageMemoryBarrier(
renderer, renderer,
vulkanCommandBuffer->commandBuffer, vulkanCommandBuffer->commandBuffer,
RESOURCE_ACCESS_COLOR_ATTACHMENT_WRITE, RESOURCE_ACCESS_COLOR_ATTACHMENT_READ_WRITE,
VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_ASPECT_COLOR_BIT,
0, 0,
texture->layerCount, texture->layerCount,
@ -8849,7 +8896,7 @@ static void VULKAN_BeginRenderPass(
VULKAN_INTERNAL_ImageMemoryBarrier( VULKAN_INTERNAL_ImageMemoryBarrier(
renderer, renderer,
vulkanCommandBuffer->commandBuffer, vulkanCommandBuffer->commandBuffer,
RESOURCE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE, RESOURCE_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_WRITE,
depthAspectFlags, depthAspectFlags,
0, 0,
texture->layerCount, texture->layerCount,
@ -8971,6 +9018,7 @@ static void VULKAN_EndRenderPass(
vulkanCommandBuffer->vertexUniformBuffer != NULL vulkanCommandBuffer->vertexUniformBuffer != NULL
) { ) {
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->vertexUniformBuffer vulkanCommandBuffer->vertexUniformBuffer
); );
@ -8981,6 +9029,7 @@ static void VULKAN_EndRenderPass(
vulkanCommandBuffer->fragmentUniformBuffer != NULL vulkanCommandBuffer->fragmentUniformBuffer != NULL
) { ) {
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->fragmentUniformBuffer vulkanCommandBuffer->fragmentUniformBuffer
); );
@ -9066,6 +9115,7 @@ static void VULKAN_BindGraphicsPipeline(
vulkanCommandBuffer->vertexUniformBuffer != NULL vulkanCommandBuffer->vertexUniformBuffer != NULL
) { ) {
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->vertexUniformBuffer vulkanCommandBuffer->vertexUniformBuffer
); );
@ -9088,6 +9138,7 @@ static void VULKAN_BindGraphicsPipeline(
vulkanCommandBuffer->fragmentUniformBuffer != NULL vulkanCommandBuffer->fragmentUniformBuffer != NULL
) { ) {
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->fragmentUniformBuffer vulkanCommandBuffer->fragmentUniformBuffer
); );
@ -9219,6 +9270,7 @@ static void VULKAN_BindComputePipeline(
vulkanCommandBuffer->computeUniformBuffer != NULL vulkanCommandBuffer->computeUniformBuffer != NULL
) { ) {
VULKAN_INTERNAL_BindUniformBuffer( VULKAN_INTERNAL_BindUniformBuffer(
renderer,
vulkanCommandBuffer, vulkanCommandBuffer,
vulkanCommandBuffer->computeUniformBuffer vulkanCommandBuffer->computeUniformBuffer
); );
@ -10514,7 +10566,6 @@ static uint8_t VULKAN_INTERNAL_DefragmentMemory(
VkBufferCopy bufferCopy; VkBufferCopy bufferCopy;
VkImageCopy *imageCopyRegions; VkImageCopy *imageCopyRegions;
VulkanCommandBuffer *commandBuffer; VulkanCommandBuffer *commandBuffer;
VkCommandBufferBeginInfo beginInfo;
uint32_t i, level; uint32_t i, level;
VulkanResourceAccessType copyResourceAccessType = RESOURCE_ACCESS_NONE; VulkanResourceAccessType copyResourceAccessType = RESOURCE_ACCESS_NONE;
VulkanResourceAccessType originalResourceAccessType; VulkanResourceAccessType originalResourceAccessType;
@ -10524,11 +10575,6 @@ static uint8_t VULKAN_INTERNAL_DefragmentMemory(
renderer->needDefrag = 0; renderer->needDefrag = 0;
renderer->defragInProgress = 1; renderer->defragInProgress = 1;
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.pNext = NULL;
beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
beginInfo.pInheritanceInfo = NULL;
commandBuffer = (VulkanCommandBuffer*) VULKAN_AcquireCommandBuffer((Refresh_Renderer *) renderer); commandBuffer = (VulkanCommandBuffer*) VULKAN_AcquireCommandBuffer((Refresh_Renderer *) renderer);
if (VULKAN_INTERNAL_FindAllocationToDefragment( if (VULKAN_INTERNAL_FindAllocationToDefragment(
@ -10561,6 +10607,7 @@ static uint8_t VULKAN_INTERNAL_DefragmentMemory(
currentRegion->vulkanBuffer->size, currentRegion->vulkanBuffer->size,
RESOURCE_ACCESS_NONE, RESOURCE_ACCESS_NONE,
currentRegion->vulkanBuffer->usage, currentRegion->vulkanBuffer->usage,
currentRegion->vulkanBuffer->requireHostVisible,
currentRegion->vulkanBuffer->preferDeviceLocal, currentRegion->vulkanBuffer->preferDeviceLocal,
0 0
); );
@ -11533,6 +11580,9 @@ static uint8_t VULKAN_INTERNAL_CreateLogicalDevice(
static void VULKAN_INTERNAL_LoadEntryPoints(void) static void VULKAN_INTERNAL_LoadEntryPoints(void)
{ {
/* Required for MoltenVK support */
SDL_setenv("MVK_CONFIG_FULL_IMAGE_VIEW_SWIZZLE", "1", 1);
/* Load Vulkan entry points */ /* Load Vulkan entry points */
if (SDL_Vulkan_LoadLibrary(NULL) < 0) if (SDL_Vulkan_LoadLibrary(NULL) < 0)
{ {
@ -11705,14 +11755,6 @@ static Refresh_Device* VULKAN_CreateDevice(
renderer->physicalDeviceDriverProperties.conformanceVersion.minor, renderer->physicalDeviceDriverProperties.conformanceVersion.minor,
renderer->physicalDeviceDriverProperties.conformanceVersion.patch renderer->physicalDeviceDriverProperties.conformanceVersion.patch
); );
Refresh_LogWarn(
"\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"
"! Refresh Vulkan is still in development! !\n"
"! The API is unstable and subject to change !\n"
"! You have been warned! !\n"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
);
if (!VULKAN_INTERNAL_CreateLogicalDevice( if (!VULKAN_INTERNAL_CreateLogicalDevice(
renderer renderer
@ -11968,6 +12010,16 @@ static Refresh_Device* VULKAN_CreateDevice(
/* Dummy Uniform Buffers */ /* Dummy Uniform Buffers */
renderer->dummyBuffer = VULKAN_INTERNAL_CreateBuffer(
renderer,
16,
RESOURCE_ACCESS_GENERAL,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
0,
0,
1
);
renderer->dummyVertexUniformBuffer = VULKAN_INTERNAL_CreateDummyUniformBuffer( renderer->dummyVertexUniformBuffer = VULKAN_INTERNAL_CreateDummyUniformBuffer(
renderer, renderer,
UNIFORM_BUFFER_VERTEX UNIFORM_BUFFER_VERTEX
@ -12081,6 +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,
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">