[Vulkan] Refactoring and fixes for VulkanProvider and related areas

Enable portability subset physical device enumeration.

Don't use Vulkan 1.1+ logical devices on Vulkan 1.0 instances due to the
VkApplicationInfo::apiVersion specification.

Make sure all extension dependencies are enabled when creating a device.

Prefer exposing feature support over extension support via the device
interface to avoid causing confusion with regard to promoted extensions
(especially those that required some features as extensions, but had those
features made optional when they were promoted).

Allow creating presentation-only devices, not demanding any optional
features beyond the basic Vulkan 1.0, for use cases such as internal tools
or CPU rendering.

Require the independentBlend feature for GPU emulation as working around is
complicated, while support is almost ubiquitous.

Move the graphics system initialization fatal error message to xenia_main
after attempting to initialize all implementations, for automatic fallback
to other implementations in the future.

Log Vulkan driver info.

Improve Vulkan debug message logging, enabled by default.

Refactor code, with simplified logic for enabling extensions and layers.
This commit is contained in:
Triang3l
2025-08-12 23:21:59 +03:00
parent a06be03f1b
commit b5432ab83f
70 changed files with 3238 additions and 2757 deletions

View File

@@ -11,6 +11,7 @@
#include <cstdint>
#include "xenia/base/assert.h"
#include "xenia/base/logging.h"
#include "xenia/ui/vulkan/vulkan_provider.h"
@@ -20,10 +21,10 @@ namespace vulkan {
VulkanShader::VulkanTranslation::~VulkanTranslation() {
if (shader_module_) {
const ui::vulkan::VulkanProvider& provider =
static_cast<const VulkanShader&>(shader()).provider_;
provider.dfn().vkDestroyShaderModule(provider.device(), shader_module_,
nullptr);
const ui::vulkan::VulkanDevice* const vulkan_device =
static_cast<const VulkanShader&>(shader()).vulkan_device_;
vulkan_device->functions().vkDestroyShaderModule(vulkan_device->device(),
shader_module_, nullptr);
}
}
@@ -34,8 +35,8 @@ VkShaderModule VulkanShader::VulkanTranslation::GetOrCreateShaderModule() {
if (shader_module_ != VK_NULL_HANDLE) {
return shader_module_;
}
const ui::vulkan::VulkanProvider& provider =
static_cast<const VulkanShader&>(shader()).provider_;
const ui::vulkan::VulkanDevice* const vulkan_device =
static_cast<const VulkanShader&>(shader()).vulkan_device_;
VkShaderModuleCreateInfo shader_module_create_info;
shader_module_create_info.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
shader_module_create_info.pNext = nullptr;
@@ -43,9 +44,9 @@ VkShaderModule VulkanShader::VulkanTranslation::GetOrCreateShaderModule() {
shader_module_create_info.codeSize = translated_binary().size();
shader_module_create_info.pCode =
reinterpret_cast<const uint32_t*>(translated_binary().data());
if (provider.dfn().vkCreateShaderModule(provider.device(),
&shader_module_create_info, nullptr,
&shader_module_) != VK_SUCCESS) {
if (vulkan_device->functions().vkCreateShaderModule(
vulkan_device->device(), &shader_module_create_info, nullptr,
&shader_module_) != VK_SUCCESS) {
XELOGE(
"VulkanShader::VulkanTranslation: Failed to create a Vulkan shader "
"module for shader {:016X} modification {:016X}",
@@ -56,15 +57,17 @@ VkShaderModule VulkanShader::VulkanTranslation::GetOrCreateShaderModule() {
return shader_module_;
}
VulkanShader::VulkanShader(const ui::vulkan::VulkanProvider& provider,
xenos::ShaderType shader_type,
uint64_t ucode_data_hash,
const uint32_t* ucode_dwords,
size_t ucode_dword_count,
std::endian ucode_source_endian)
VulkanShader::VulkanShader(const ui::vulkan::VulkanDevice* const vulkan_device,
const xenos::ShaderType shader_type,
const uint64_t ucode_data_hash,
const uint32_t* const ucode_dwords,
const size_t ucode_dword_count,
const std::endian ucode_source_endian)
: SpirvShader(shader_type, ucode_data_hash, ucode_dwords, ucode_dword_count,
ucode_source_endian),
provider_(provider) {}
vulkan_device_(vulkan_device) {
assert_not_null(vulkan_device);
}
Shader::Translation* VulkanShader::CreateTranslationInstance(
uint64_t modification) {