[Vulkan] Replace vulkan-loader with volk
This commit is contained in:
@@ -17,7 +17,7 @@ project("xenia-app")
|
||||
"libavutil",
|
||||
"snappy",
|
||||
"spirv-tools",
|
||||
"vulkan-loader",
|
||||
"volk",
|
||||
"xenia-apu",
|
||||
"xenia-apu-nop",
|
||||
"xenia-base",
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
#include "xenia/base/profiling.h"
|
||||
#include "xenia/gpu/gpu_flags.h"
|
||||
#include "xenia/gpu/vulkan/vulkan_gpu_flags.h"
|
||||
|
||||
#include "third_party/vulkan/vk_mem_alloc.h"
|
||||
#include "xenia/ui/vulkan/vulkan_mem_alloc.h"
|
||||
|
||||
using namespace xe::gpu::xenos;
|
||||
|
||||
@@ -120,9 +119,13 @@ VkResult BufferCache::Initialize() {
|
||||
}
|
||||
|
||||
// Create a memory allocator for textures.
|
||||
VmaVulkanFunctions vulkan_funcs = {};
|
||||
ui::vulkan::FillVMAVulkanFunctions(&vulkan_funcs);
|
||||
|
||||
VmaAllocatorCreateInfo alloc_info = {
|
||||
0, *device_, *device_, 0, 0, nullptr, nullptr,
|
||||
0, *device_, *device_, 0, 0, nullptr, nullptr, 0, nullptr, &vulkan_funcs,
|
||||
};
|
||||
|
||||
status = vmaCreateAllocator(&alloc_info, &mem_allocator_);
|
||||
if (status != VK_SUCCESS) {
|
||||
return status;
|
||||
|
||||
@@ -7,7 +7,7 @@ project("xenia-gpu-vulkan")
|
||||
kind("StaticLib")
|
||||
language("C++")
|
||||
links({
|
||||
"vulkan-loader",
|
||||
"volk",
|
||||
"xenia-base",
|
||||
"xenia-gpu",
|
||||
"xenia-ui",
|
||||
@@ -40,7 +40,7 @@ project("xenia-gpu-vulkan-trace-viewer")
|
||||
"libavutil",
|
||||
"snappy",
|
||||
"spirv-tools",
|
||||
"vulkan-loader",
|
||||
"volk",
|
||||
"xenia-apu",
|
||||
"xenia-apu-nop",
|
||||
"xenia-base",
|
||||
@@ -112,7 +112,7 @@ project("xenia-gpu-vulkan-trace-dump")
|
||||
"libavutil",
|
||||
"snappy",
|
||||
"spirv-tools",
|
||||
"vulkan-loader",
|
||||
"volk",
|
||||
"xenia-apu",
|
||||
"xenia-apu-nop",
|
||||
"xenia-base",
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
#include "xenia/gpu/sampler_info.h"
|
||||
#include "xenia/gpu/texture_info.h"
|
||||
#include "xenia/gpu/vulkan/vulkan_gpu_flags.h"
|
||||
|
||||
#include "third_party/vulkan/vk_mem_alloc.h"
|
||||
#include "xenia/ui/vulkan/vulkan_mem_alloc.h"
|
||||
|
||||
namespace xe {
|
||||
namespace gpu {
|
||||
@@ -198,8 +197,11 @@ VkResult TextureCache::Initialize() {
|
||||
}
|
||||
|
||||
// Create a memory allocator for textures.
|
||||
VmaVulkanFunctions vulkan_funcs = {};
|
||||
ui::vulkan::FillVMAVulkanFunctions(&vulkan_funcs);
|
||||
|
||||
VmaAllocatorCreateInfo alloc_info = {
|
||||
0, *device_, *device_, 0, 0, nullptr, nullptr,
|
||||
0, *device_, *device_, 0, 0, nullptr, nullptr, 0, nullptr, &vulkan_funcs,
|
||||
};
|
||||
status = vmaCreateAllocator(&alloc_info, &mem_allocator_);
|
||||
if (status != VK_SUCCESS) {
|
||||
|
||||
@@ -31,7 +31,7 @@ project("xenia-ui-window-vulkan-demo")
|
||||
links({
|
||||
"gflags",
|
||||
"imgui",
|
||||
"vulkan-loader",
|
||||
"volk",
|
||||
"xenia-base",
|
||||
"xenia-ui",
|
||||
"xenia-ui-spirv",
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#error Platform not yet supported.
|
||||
#endif // XE_PLATFORM_WIN32
|
||||
|
||||
// We are statically linked with the loader, so use function prototypes.
|
||||
#define VK_PROTOTYPES
|
||||
// We use a loader with its own function prototypes.
|
||||
#include "third_party/volk/volk.h"
|
||||
#include "third_party/vulkan/vulkan.h"
|
||||
|
||||
// NOTE: header order matters here, unfortunately:
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "third_party/renderdoc/renderdoc_app.h"
|
||||
#include "third_party/volk/volk.h"
|
||||
|
||||
#include "xenia/base/assert.h"
|
||||
#include "xenia/base/logging.h"
|
||||
@@ -72,6 +73,10 @@ VulkanInstance::~VulkanInstance() { DestroyInstance(); }
|
||||
bool VulkanInstance::Initialize() {
|
||||
auto version = Version::Parse(VK_API_VERSION);
|
||||
XELOGVK("Initializing Vulkan %s...", version.pretty_string.c_str());
|
||||
if (volkInitialize() != VK_SUCCESS) {
|
||||
XELOGE("volkInitialize() failed!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get all of the global layers and extensions provided by the system.
|
||||
if (!QueryGlobals()) {
|
||||
@@ -271,6 +276,9 @@ bool VulkanInstance::CreateInstance() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load Vulkan entrypoints and extensions.
|
||||
volkLoadInstance(handle);
|
||||
|
||||
// Enable debug validation, if needed.
|
||||
EnableDebugValidation();
|
||||
|
||||
|
||||
44
src/xenia/ui/vulkan/vulkan_mem_alloc.h
Normal file
44
src/xenia/ui/vulkan/vulkan_mem_alloc.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2018 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef XENIA_UI_VULKAN_VULKAN_MEM_ALLOC_H_
|
||||
#define XENIA_UI_VULKAN_VULKAN_MEM_ALLOC_H_
|
||||
|
||||
#include "third_party/volk/volk.h"
|
||||
|
||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||
#include "third_party/vulkan/vk_mem_alloc.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
namespace vulkan {
|
||||
|
||||
inline void FillVMAVulkanFunctions(VmaVulkanFunctions* vma_funcs) {
|
||||
vma_funcs->vkGetPhysicalDeviceProperties = vkGetPhysicalDeviceProperties;
|
||||
vma_funcs->vkGetPhysicalDeviceMemoryProperties =
|
||||
vkGetPhysicalDeviceMemoryProperties;
|
||||
vma_funcs->vkAllocateMemory = vkAllocateMemory;
|
||||
vma_funcs->vkFreeMemory = vkFreeMemory;
|
||||
vma_funcs->vkMapMemory = vkMapMemory;
|
||||
vma_funcs->vkUnmapMemory = vkUnmapMemory;
|
||||
vma_funcs->vkBindBufferMemory = vkBindBufferMemory;
|
||||
vma_funcs->vkBindImageMemory = vkBindImageMemory;
|
||||
vma_funcs->vkGetBufferMemoryRequirements = vkGetBufferMemoryRequirements;
|
||||
vma_funcs->vkGetImageMemoryRequirements = vkGetImageMemoryRequirements;
|
||||
vma_funcs->vkCreateBuffer = vkCreateBuffer;
|
||||
vma_funcs->vkDestroyBuffer = vkDestroyBuffer;
|
||||
vma_funcs->vkCreateImage = vkCreateImage;
|
||||
vma_funcs->vkDestroyImage = vkDestroyImage;
|
||||
}
|
||||
|
||||
} // namespace vulkan
|
||||
} // namespace ui
|
||||
} // namespace xe
|
||||
|
||||
#endif // XENIA_UI_VULKAN_VULKAN_MEM_ALLOC_H_
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
// Implement AMD's VMA here.
|
||||
#define VMA_IMPLEMENTATION
|
||||
#include "third_party/vulkan/vk_mem_alloc.h"
|
||||
#include "xenia/ui/vulkan/vulkan_mem_alloc.h"
|
||||
|
||||
namespace xe {
|
||||
namespace ui {
|
||||
|
||||
Reference in New Issue
Block a user