|
@@ -34,7 +34,6 @@
|
|
#include <vector>
|
|
#include <vector>
|
|
#include <cstring>
|
|
#include <cstring>
|
|
#include <set>
|
|
#include <set>
|
|
-#include <fstream>
|
|
|
|
#include <sstream>
|
|
#include <sstream>
|
|
#include <array>
|
|
#include <array>
|
|
|
|
|
|
@@ -83,7 +82,7 @@ Graphics::Graphics()
|
|
|
|
|
|
volkInitializeCustom((PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr());
|
|
volkInitializeCustom((PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr());
|
|
|
|
|
|
- vulkanApiVersion = Vulkan::getSupportedVulkanApiVersion(volkGetInstanceVersion());
|
|
|
|
|
|
+ instanceVersion = volkGetInstanceVersion();
|
|
}
|
|
}
|
|
|
|
|
|
Graphics::~Graphics()
|
|
Graphics::~Graphics()
|
|
@@ -92,13 +91,6 @@ Graphics::~Graphics()
|
|
defaultTexture.set(nullptr);
|
|
defaultTexture.set(nullptr);
|
|
|
|
|
|
SDL_Vulkan_UnloadLibrary();
|
|
SDL_Vulkan_UnloadLibrary();
|
|
-
|
|
|
|
- // We already cleaned those up by clearing out batchedDrawBuffers.
|
|
|
|
- // We set them to nullptr here so the base class doesn't crash
|
|
|
|
- // when it tries to free this.
|
|
|
|
- batchedDrawState.vb[0] = nullptr;
|
|
|
|
- batchedDrawState.vb[1] = nullptr;
|
|
|
|
- batchedDrawState.indexBuffer = nullptr;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// START OVERRIDEN FUNCTIONS
|
|
// START OVERRIDEN FUNCTIONS
|
|
@@ -293,17 +285,6 @@ void Graphics::submitGpuCommands(bool present, void *screenshotCallbackData)
|
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
|
|
|
|
|
- VkImageCopy imageCopy{};
|
|
|
|
- imageCopy.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
|
|
- imageCopy.srcSubresource.layerCount = 1;
|
|
|
|
- imageCopy.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
|
|
- imageCopy.dstSubresource.layerCount = 1;
|
|
|
|
- imageCopy.extent = {
|
|
|
|
- swapChainExtent.width,
|
|
|
|
- swapChainExtent.height,
|
|
|
|
- 1
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
VkImageBlit blit{};
|
|
VkImageBlit blit{};
|
|
blit.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
blit.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
|
|
blit.srcSubresource.layerCount = 1;
|
|
blit.srcSubresource.layerCount = 1;
|
|
@@ -652,12 +633,10 @@ void Graphics::setFrontFaceWinding(Winding winding)
|
|
|
|
|
|
states.back().winding = winding;
|
|
states.back().winding = winding;
|
|
|
|
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
vkCmdSetFrontFaceEXT(
|
|
vkCmdSetFrontFaceEXT(
|
|
commandBuffers.at(currentFrame),
|
|
commandBuffers.at(currentFrame),
|
|
Vulkan::getFrontFace(winding));
|
|
Vulkan::getFrontFace(winding));
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void Graphics::setColorMask(ColorChannelMask mask)
|
|
void Graphics::setColorMask(ColorChannelMask mask)
|
|
@@ -895,14 +874,12 @@ void Graphics::setStencilMode(StencilAction action, CompareMode compare, int val
|
|
vkCmdSetStencilCompareMask(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, readmask);
|
|
vkCmdSetStencilCompareMask(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, readmask);
|
|
vkCmdSetStencilReference(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, value);
|
|
vkCmdSetStencilReference(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, value);
|
|
|
|
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
vkCmdSetStencilOpEXT(
|
|
vkCmdSetStencilOpEXT(
|
|
commandBuffers.at(currentFrame),
|
|
commandBuffers.at(currentFrame),
|
|
VK_STENCIL_FRONT_AND_BACK,
|
|
VK_STENCIL_FRONT_AND_BACK,
|
|
VK_STENCIL_OP_KEEP, Vulkan::getStencilOp(action),
|
|
VK_STENCIL_OP_KEEP, Vulkan::getStencilOp(action),
|
|
VK_STENCIL_OP_KEEP, Vulkan::getCompareOp(getReversedCompareMode(compare)));
|
|
VK_STENCIL_OP_KEEP, Vulkan::getCompareOp(getReversedCompareMode(compare)));
|
|
-#endif
|
|
|
|
|
|
|
|
states.back().stencil.action = action;
|
|
states.back().stencil.action = action;
|
|
states.back().stencil.compare = compare;
|
|
states.back().stencil.compare = compare;
|
|
@@ -915,7 +892,6 @@ void Graphics::setDepthMode(CompareMode compare, bool write)
|
|
{
|
|
{
|
|
flushBatchedDraws();
|
|
flushBatchedDraws();
|
|
|
|
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
{
|
|
{
|
|
vkCmdSetDepthCompareOpEXT(
|
|
vkCmdSetDepthCompareOpEXT(
|
|
@@ -924,7 +900,6 @@ void Graphics::setDepthMode(CompareMode compare, bool write)
|
|
vkCmdSetDepthWriteEnableEXT(
|
|
vkCmdSetDepthWriteEnableEXT(
|
|
commandBuffers.at(currentFrame), Vulkan::getBool(write));
|
|
commandBuffers.at(currentFrame), Vulkan::getBool(write));
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
|
|
|
|
states.back().depthTest = compare;
|
|
states.back().depthTest = compare;
|
|
states.back().depthWrite = write;
|
|
states.back().depthWrite = write;
|
|
@@ -1102,7 +1077,6 @@ void Graphics::initDynamicState()
|
|
vkCmdSetStencilCompareMask(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, states.back().stencil.readMask);
|
|
vkCmdSetStencilCompareMask(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, states.back().stencil.readMask);
|
|
vkCmdSetStencilReference(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, states.back().stencil.value);
|
|
vkCmdSetStencilReference(commandBuffers.at(currentFrame), VK_STENCIL_FRONT_AND_BACK, states.back().stencil.value);
|
|
|
|
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
{
|
|
{
|
|
vkCmdSetStencilOpEXT(
|
|
vkCmdSetStencilOpEXT(
|
|
@@ -1120,7 +1094,6 @@ void Graphics::initDynamicState()
|
|
vkCmdSetFrontFaceEXT(
|
|
vkCmdSetFrontFaceEXT(
|
|
commandBuffers.at(currentFrame), Vulkan::getFrontFace(states.back().winding));
|
|
commandBuffers.at(currentFrame), Vulkan::getFrontFace(states.back().winding));
|
|
}
|
|
}
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void Graphics::beginFrame()
|
|
void Graphics::beginFrame()
|
|
@@ -1306,10 +1279,8 @@ static void checkOptionalInstanceExtensions(OptionalInstanceExtensions &ext)
|
|
|
|
|
|
for (const auto &extension : extensions)
|
|
for (const auto &extension : extensions)
|
|
{
|
|
{
|
|
-#ifdef VK_KHR_get_physical_device_properties2
|
|
|
|
if (strcmp(extension.extensionName, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME) == 0)
|
|
ext.physicalDeviceProperties2 = true;
|
|
ext.physicalDeviceProperties2 = true;
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1324,7 +1295,7 @@ void Graphics::createVulkanInstance()
|
|
appInfo.applicationVersion = VK_MAKE_API_VERSION(0, 1, 0, 0); // get this version from somewhere else?
|
|
appInfo.applicationVersion = VK_MAKE_API_VERSION(0, 1, 0, 0); // get this version from somewhere else?
|
|
appInfo.pEngineName = "LOVE Game Framework";
|
|
appInfo.pEngineName = "LOVE Game Framework";
|
|
appInfo.engineVersion = VK_MAKE_API_VERSION(0, VERSION_MAJOR, VERSION_MINOR, VERSION_REV);
|
|
appInfo.engineVersion = VK_MAKE_API_VERSION(0, VERSION_MAJOR, VERSION_MINOR, VERSION_REV);
|
|
- appInfo.apiVersion = vulkanApiVersion;
|
|
|
|
|
|
+ appInfo.apiVersion = instanceVersion;
|
|
|
|
|
|
VkInstanceCreateInfo createInfo{};
|
|
VkInstanceCreateInfo createInfo{};
|
|
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
|
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
|
@@ -1342,10 +1313,8 @@ void Graphics::createVulkanInstance()
|
|
|
|
|
|
checkOptionalInstanceExtensions(optionalInstanceExtensions);
|
|
checkOptionalInstanceExtensions(optionalInstanceExtensions);
|
|
|
|
|
|
-#ifdef VK_KHR_get_physical_device_properties2
|
|
|
|
if (optionalInstanceExtensions.physicalDeviceProperties2)
|
|
if (optionalInstanceExtensions.physicalDeviceProperties2)
|
|
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
|
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
|
|
|
|
size_t additional_extension_count = extensions.size();
|
|
size_t additional_extension_count = extensions.size();
|
|
extensions.resize(additional_extension_count + count);
|
|
extensions.resize(additional_extension_count + count);
|
|
@@ -1361,11 +1330,6 @@ void Graphics::createVulkanInstance()
|
|
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
|
|
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
|
|
createInfo.ppEnabledLayerNames = validationLayers.data();
|
|
createInfo.ppEnabledLayerNames = validationLayers.data();
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- createInfo.enabledLayerCount = 0;
|
|
|
|
- createInfo.ppEnabledLayerNames = nullptr;
|
|
|
|
- }
|
|
|
|
|
|
|
|
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS)
|
|
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS)
|
|
throw love::Exception("couldn't create vulkan instance");
|
|
throw love::Exception("couldn't create vulkan instance");
|
|
@@ -1385,12 +1349,14 @@ bool Graphics::checkValidationSupport()
|
|
{
|
|
{
|
|
bool layerFound = false;
|
|
bool layerFound = false;
|
|
|
|
|
|
- for (const auto &layerProperties : availableLayers)
|
|
|
|
|
|
+ for (const auto& layerProperties : availableLayers)
|
|
|
|
+ {
|
|
if (strcmp(layerName, layerProperties.layerName) == 0)
|
|
if (strcmp(layerName, layerProperties.layerName) == 0)
|
|
{
|
|
{
|
|
layerFound = true;
|
|
layerFound = true;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
if (!layerFound)
|
|
if (!layerFound)
|
|
return false;
|
|
return false;
|
|
@@ -1426,6 +1392,7 @@ void Graphics::pickPhysicalDevice()
|
|
VkPhysicalDeviceProperties properties;
|
|
VkPhysicalDeviceProperties properties;
|
|
vkGetPhysicalDeviceProperties(physicalDevice, &properties);
|
|
vkGetPhysicalDeviceProperties(physicalDevice, &properties);
|
|
minUniformBufferOffsetAlignment = properties.limits.minUniformBufferOffsetAlignment;
|
|
minUniformBufferOffsetAlignment = properties.limits.minUniformBufferOffsetAlignment;
|
|
|
|
+ deviceApiVersion = properties.apiVersion;
|
|
|
|
|
|
msaaSamples = getMsaaCount(requestedMsaa);
|
|
msaaSamples = getMsaaCount(requestedMsaa);
|
|
}
|
|
}
|
|
@@ -1535,34 +1502,20 @@ static void findOptionalDeviceExtensions(VkPhysicalDevice physicalDevice, Option
|
|
|
|
|
|
for (const auto &extension : availableExtensions)
|
|
for (const auto &extension : availableExtensions)
|
|
{
|
|
{
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (strcmp(extension.extensionName, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME) == 0)
|
|
optionalDeviceFeatures.extendedDynamicState = true;
|
|
optionalDeviceFeatures.extendedDynamicState = true;
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_get_memory_requirements2
|
|
|
|
if (strcmp(extension.extensionName, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME) == 0)
|
|
optionalDeviceFeatures.memoryRequirements2 = true;
|
|
optionalDeviceFeatures.memoryRequirements2 = true;
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_dedicated_allocation
|
|
|
|
if (strcmp(extension.extensionName, VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME) == 0)
|
|
optionalDeviceFeatures.dedicatedAllocation = true;
|
|
optionalDeviceFeatures.dedicatedAllocation = true;
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_buffer_device_address
|
|
|
|
if (strcmp(extension.extensionName, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME) == 0)
|
|
optionalDeviceFeatures.bufferDeviceAddress = true;
|
|
optionalDeviceFeatures.bufferDeviceAddress = true;
|
|
-#endif
|
|
|
|
-#ifdef VK_EXT_memory_budget
|
|
|
|
if (strcmp(extension.extensionName, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_EXT_MEMORY_BUDGET_EXTENSION_NAME) == 0)
|
|
optionalDeviceFeatures.memoryBudget = true;
|
|
optionalDeviceFeatures.memoryBudget = true;
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_shader_float_controls
|
|
|
|
if (strcmp(extension.extensionName, VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME) == 0)
|
|
optionalDeviceFeatures.shaderFloatControls = true;
|
|
optionalDeviceFeatures.shaderFloatControls = true;
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_spirv_1_4
|
|
|
|
if (strcmp(extension.extensionName, VK_KHR_SPIRV_1_4_EXTENSION_NAME) == 0)
|
|
if (strcmp(extension.extensionName, VK_KHR_SPIRV_1_4_EXTENSION_NAME) == 0)
|
|
optionalDeviceFeatures.spirv14 = true;
|
|
optionalDeviceFeatures.spirv14 = true;
|
|
-#endif
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1601,7 +1554,7 @@ void Graphics::createLogicalDevice()
|
|
optionalDeviceFeatures.memoryBudget = false;
|
|
optionalDeviceFeatures.memoryBudget = false;
|
|
if (optionalDeviceFeatures.spirv14 && !optionalDeviceFeatures.shaderFloatControls)
|
|
if (optionalDeviceFeatures.spirv14 && !optionalDeviceFeatures.shaderFloatControls)
|
|
optionalDeviceFeatures.spirv14 = false;
|
|
optionalDeviceFeatures.spirv14 = false;
|
|
- if (optionalDeviceFeatures.spirv14 && vulkanApiVersion < VK_MAKE_API_VERSION(0, 1, 1, 0))
|
|
|
|
|
|
+ if (optionalDeviceFeatures.spirv14 && deviceApiVersion < VK_API_VERSION_1_1)
|
|
optionalDeviceFeatures.spirv14 = false;
|
|
optionalDeviceFeatures.spirv14 = false;
|
|
|
|
|
|
VkPhysicalDeviceFeatures deviceFeatures{};
|
|
VkPhysicalDeviceFeatures deviceFeatures{};
|
|
@@ -1615,38 +1568,22 @@ void Graphics::createLogicalDevice()
|
|
createInfo.pEnabledFeatures = &deviceFeatures;
|
|
createInfo.pEnabledFeatures = &deviceFeatures;
|
|
|
|
|
|
std::vector<const char*> enabledExtensions(deviceExtensions.begin(), deviceExtensions.end());
|
|
std::vector<const char*> enabledExtensions(deviceExtensions.begin(), deviceExtensions.end());
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
enabledExtensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_get_memory_requirements2
|
|
|
|
if (optionalDeviceFeatures.memoryRequirements2)
|
|
if (optionalDeviceFeatures.memoryRequirements2)
|
|
enabledExtensions.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_dedicated_allocation
|
|
|
|
if (optionalDeviceFeatures.dedicatedAllocation)
|
|
if (optionalDeviceFeatures.dedicatedAllocation)
|
|
enabledExtensions.push_back(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_buffer_device_address
|
|
|
|
if (optionalDeviceFeatures.bufferDeviceAddress)
|
|
if (optionalDeviceFeatures.bufferDeviceAddress)
|
|
enabledExtensions.push_back(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
-#ifdef VK_EXT_memory_budget
|
|
|
|
if (optionalDeviceFeatures.memoryBudget)
|
|
if (optionalDeviceFeatures.memoryBudget)
|
|
enabledExtensions.push_back(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_EXT_MEMORY_BUDGET_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_shader_float_controls
|
|
|
|
if (optionalDeviceFeatures.shaderFloatControls)
|
|
if (optionalDeviceFeatures.shaderFloatControls)
|
|
enabledExtensions.push_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_spirv_1_4
|
|
|
|
if (optionalDeviceFeatures.spirv14)
|
|
if (optionalDeviceFeatures.spirv14)
|
|
enabledExtensions.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_KHR_SPIRV_1_4_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_bind_memory2
|
|
|
|
- if (vulkanApiVersion >= VK_API_VERSION_1_1)
|
|
|
|
|
|
+ if (deviceApiVersion >= VK_API_VERSION_1_1)
|
|
enabledExtensions.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
|
|
enabledExtensions.push_back(VK_KHR_BIND_MEMORY_2_EXTENSION_NAME);
|
|
-#endif
|
|
|
|
|
|
|
|
createInfo.enabledExtensionCount = static_cast<uint32_t>(enabledExtensions.size());
|
|
createInfo.enabledExtensionCount = static_cast<uint32_t>(enabledExtensions.size());
|
|
createInfo.ppEnabledExtensionNames = enabledExtensions.data();
|
|
createInfo.ppEnabledExtensionNames = enabledExtensions.data();
|
|
@@ -1656,17 +1593,13 @@ void Graphics::createLogicalDevice()
|
|
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
|
|
createInfo.enabledLayerCount = static_cast<uint32_t>(validationLayers.size());
|
|
createInfo.ppEnabledLayerNames = validationLayers.data();
|
|
createInfo.ppEnabledLayerNames = validationLayers.data();
|
|
}
|
|
}
|
|
- else
|
|
|
|
- createInfo.enabledLayerCount = 0;
|
|
|
|
|
|
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extendedDynamicStateFeatures{};
|
|
VkPhysicalDeviceExtendedDynamicStateFeaturesEXT extendedDynamicStateFeatures{};
|
|
extendedDynamicStateFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT;
|
|
extendedDynamicStateFeatures.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT;
|
|
extendedDynamicStateFeatures.extendedDynamicState = Vulkan::getBool(optionalDeviceFeatures.extendedDynamicState);
|
|
extendedDynamicStateFeatures.extendedDynamicState = Vulkan::getBool(optionalDeviceFeatures.extendedDynamicState);
|
|
extendedDynamicStateFeatures.pNext = nullptr;
|
|
extendedDynamicStateFeatures.pNext = nullptr;
|
|
|
|
|
|
createInfo.pNext = &extendedDynamicStateFeatures;
|
|
createInfo.pNext = &extendedDynamicStateFeatures;
|
|
-#endif
|
|
|
|
|
|
|
|
if (vkCreateDevice(physicalDevice, &createInfo, nullptr, &device) != VK_SUCCESS)
|
|
if (vkCreateDevice(physicalDevice, &createInfo, nullptr, &device) != VK_SUCCESS)
|
|
throw love::Exception("failed to create logical device");
|
|
throw love::Exception("failed to create logical device");
|
|
@@ -1680,7 +1613,7 @@ void Graphics::createLogicalDevice()
|
|
void Graphics::initVMA()
|
|
void Graphics::initVMA()
|
|
{
|
|
{
|
|
VmaAllocatorCreateInfo allocatorCreateInfo = {};
|
|
VmaAllocatorCreateInfo allocatorCreateInfo = {};
|
|
- allocatorCreateInfo.vulkanApiVersion = vulkanApiVersion;
|
|
|
|
|
|
+ allocatorCreateInfo.vulkanApiVersion = deviceApiVersion;
|
|
allocatorCreateInfo.physicalDevice = physicalDevice;
|
|
allocatorCreateInfo.physicalDevice = physicalDevice;
|
|
allocatorCreateInfo.device = device;
|
|
allocatorCreateInfo.device = device;
|
|
allocatorCreateInfo.instance = instance;
|
|
allocatorCreateInfo.instance = instance;
|
|
@@ -1707,22 +1640,13 @@ void Graphics::initVMA()
|
|
vulkanFunctions.vkDestroyImage = vkDestroyImage;
|
|
vulkanFunctions.vkDestroyImage = vkDestroyImage;
|
|
vulkanFunctions.vkCmdCopyBuffer = vkCmdCopyBuffer;
|
|
vulkanFunctions.vkCmdCopyBuffer = vkCmdCopyBuffer;
|
|
|
|
|
|
-#ifdef VK_KHR_get_memory_requirements2
|
|
|
|
vulkanFunctions.vkGetBufferMemoryRequirements2KHR = vkGetBufferMemoryRequirements2KHR;
|
|
vulkanFunctions.vkGetBufferMemoryRequirements2KHR = vkGetBufferMemoryRequirements2KHR;
|
|
vulkanFunctions.vkGetImageMemoryRequirements2KHR = vkGetImageMemoryRequirements2KHR;
|
|
vulkanFunctions.vkGetImageMemoryRequirements2KHR = vkGetImageMemoryRequirements2KHR;
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_bind_memory2
|
|
|
|
vulkanFunctions.vkBindBufferMemory2KHR = vkBindBufferMemory2KHR;
|
|
vulkanFunctions.vkBindBufferMemory2KHR = vkBindBufferMemory2KHR;
|
|
vulkanFunctions.vkBindImageMemory2KHR = vkBindImageMemory2KHR;
|
|
vulkanFunctions.vkBindImageMemory2KHR = vkBindImageMemory2KHR;
|
|
-#endif
|
|
|
|
-#ifdef VK_KHR_get_physical_device_properties2
|
|
|
|
vulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR = vkGetPhysicalDeviceMemoryProperties2KHR;
|
|
vulkanFunctions.vkGetPhysicalDeviceMemoryProperties2KHR = vkGetPhysicalDeviceMemoryProperties2KHR;
|
|
-#endif
|
|
|
|
-
|
|
|
|
-#ifdef VK_KHR_maintenance4
|
|
|
|
vulkanFunctions.vkGetDeviceBufferMemoryRequirements = vkGetDeviceBufferMemoryRequirements;
|
|
vulkanFunctions.vkGetDeviceBufferMemoryRequirements = vkGetDeviceBufferMemoryRequirements;
|
|
vulkanFunctions.vkGetDeviceImageMemoryRequirements = vkGetDeviceImageMemoryRequirements;
|
|
vulkanFunctions.vkGetDeviceImageMemoryRequirements = vkGetDeviceImageMemoryRequirements;
|
|
-#endif
|
|
|
|
|
|
|
|
allocatorCreateInfo.pVulkanFunctions = &vulkanFunctions;
|
|
allocatorCreateInfo.pVulkanFunctions = &vulkanFunctions;
|
|
|
|
|
|
@@ -2260,17 +2184,18 @@ void Graphics::createVulkanVertexFormat(
|
|
{
|
|
{
|
|
std::set<uint32_t> usedBuffers;
|
|
std::set<uint32_t> usedBuffers;
|
|
|
|
|
|
- auto allBits = vertexAttributes.enableBits;
|
|
|
|
|
|
+ auto enableBits = vertexAttributes.enableBits;
|
|
|
|
+ auto allBits = enableBits;
|
|
|
|
|
|
bool usesColor = false;
|
|
bool usesColor = false;
|
|
|
|
|
|
uint8_t highestBufferBinding = 0;
|
|
uint8_t highestBufferBinding = 0;
|
|
|
|
|
|
- // fixme: change to loop like in opengl implementation ?
|
|
|
|
- for (uint32_t i = 0; i < VertexAttributes::MAX; i++)
|
|
|
|
|
|
+ uint32_t i = 0;
|
|
|
|
+ while (allBits)
|
|
{
|
|
{
|
|
uint32 bit = 1u << i;
|
|
uint32 bit = 1u << i;
|
|
- if (allBits & bit)
|
|
|
|
|
|
+ if (enableBits & bit)
|
|
{
|
|
{
|
|
if (i == ATTRIB_COLOR)
|
|
if (i == ATTRIB_COLOR)
|
|
usesColor = true;
|
|
usesColor = true;
|
|
@@ -2301,6 +2226,9 @@ void Graphics::createVulkanVertexFormat(
|
|
|
|
|
|
attributeDescriptions.push_back(attributeDescription);
|
|
attributeDescriptions.push_back(attributeDescription);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ i++;
|
|
|
|
+ allBits >>= 1;
|
|
}
|
|
}
|
|
|
|
|
|
if (!usesColor)
|
|
if (!usesColor)
|
|
@@ -2343,11 +2271,9 @@ void Graphics::prepareDraw(const VertexAttributes &attributes, const BufferBindi
|
|
configuration.numColorAttachments = renderPassState.numColorAttachments;
|
|
configuration.numColorAttachments = renderPassState.numColorAttachments;
|
|
configuration.primitiveType = primitiveType;
|
|
configuration.primitiveType = primitiveType;
|
|
|
|
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
vkCmdSetCullModeEXT(commandBuffers.at(currentFrame), Vulkan::getCullMode(cullmode));
|
|
vkCmdSetCullModeEXT(commandBuffers.at(currentFrame), Vulkan::getCullMode(cullmode));
|
|
else
|
|
else
|
|
-#endif
|
|
|
|
{
|
|
{
|
|
configuration.dynamicState.winding = states.back().winding;
|
|
configuration.dynamicState.winding = states.back().winding;
|
|
configuration.dynamicState.depthState.compare = states.back().depthTest;
|
|
configuration.dynamicState.depthState.compare = states.back().depthTest;
|
|
@@ -2721,7 +2647,6 @@ VkPipeline Graphics::createGraphicsPipeline(GraphicsPipelineConfiguration &confi
|
|
|
|
|
|
std::vector<VkDynamicState> dynamicStates;
|
|
std::vector<VkDynamicState> dynamicStates;
|
|
|
|
|
|
-#ifdef VK_EXT_extended_dynamic_state
|
|
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
if (optionalDeviceFeatures.extendedDynamicState)
|
|
dynamicStates = {
|
|
dynamicStates = {
|
|
VK_DYNAMIC_STATE_SCISSOR,
|
|
VK_DYNAMIC_STATE_SCISSOR,
|
|
@@ -2737,7 +2662,6 @@ VkPipeline Graphics::createGraphicsPipeline(GraphicsPipelineConfiguration &confi
|
|
VK_DYNAMIC_STATE_STENCIL_OP_EXT,
|
|
VK_DYNAMIC_STATE_STENCIL_OP_EXT,
|
|
};
|
|
};
|
|
else
|
|
else
|
|
-#endif
|
|
|
|
dynamicStates = {
|
|
dynamicStates = {
|
|
VK_DYNAMIC_STATE_SCISSOR,
|
|
VK_DYNAMIC_STATE_SCISSOR,
|
|
VK_DYNAMIC_STATE_VIEWPORT,
|
|
VK_DYNAMIC_STATE_VIEWPORT,
|