renderer_vulkan: Fix warnings and cleanup
This commit is contained in:
@ -191,7 +191,11 @@ endif()
|
|||||||
|
|
||||||
create_target_directory_groups(video_core)
|
create_target_directory_groups(video_core)
|
||||||
|
|
||||||
# Include Vulkan headers
|
if (NOT MSVC)
|
||||||
|
# Ignore nullability warnings generated from VMA
|
||||||
|
target_compile_options(vma INTERFACE -Wno-unused-variable -Wno-nullability-completeness)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(video_core PUBLIC common core)
|
target_link_libraries(video_core PUBLIC common core)
|
||||||
target_link_libraries(video_core PRIVATE glad vma vulkan-headers glm::glm SPIRV glslang nihstro-headers Boost::serialization)
|
target_link_libraries(video_core PRIVATE glad vma vulkan-headers glm::glm SPIRV glslang nihstro-headers Boost::serialization)
|
||||||
set_target_properties(video_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
|
set_target_properties(video_core PROPERTIES INTERPROCEDURAL_OPTIMIZATION ${ENABLE_LTO})
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <array>
|
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
#include "video_core/regs.h"
|
#include "video_core/regs.h"
|
||||||
@ -13,20 +13,6 @@ namespace PicaToVK {
|
|||||||
|
|
||||||
using TextureFilter = Pica::TexturingRegs::TextureConfig::TextureFilter;
|
using TextureFilter = Pica::TexturingRegs::TextureConfig::TextureFilter;
|
||||||
|
|
||||||
struct FilterInfo {
|
|
||||||
vk::Filter mag_filter, min_filter;
|
|
||||||
vk::SamplerMipmapMode mip_mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline FilterInfo TextureFilterMode(TextureFilter mag, TextureFilter min, TextureFilter mip) {
|
|
||||||
constexpr std::array filter_table = {vk::Filter::eNearest, vk::Filter::eLinear};
|
|
||||||
|
|
||||||
constexpr std::array mipmap_table = {vk::SamplerMipmapMode::eNearest,
|
|
||||||
vk::SamplerMipmapMode::eLinear};
|
|
||||||
|
|
||||||
return FilterInfo{filter_table.at(mag), filter_table.at(min), mipmap_table.at(mip)};
|
|
||||||
}
|
|
||||||
|
|
||||||
inline vk::Filter TextureFilterMode(TextureFilter mode) {
|
inline vk::Filter TextureFilterMode(TextureFilter mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case TextureFilter::Linear:
|
case TextureFilter::Linear:
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
#include <glm/gtc/matrix_transform.hpp>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
@ -942,7 +941,7 @@ void RendererVulkan::SwapBuffers() {
|
|||||||
|
|
||||||
// Create swapchain if needed
|
// Create swapchain if needed
|
||||||
if (swapchain.NeedsRecreation()) {
|
if (swapchain.NeedsRecreation()) {
|
||||||
swapchain.Create(layout.width, layout.height, false);
|
swapchain.Create(layout.width, layout.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calling Submit will change the slot so get the required semaphores now
|
// Calling Submit will change the slot so get the required semaphores now
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VMA_IMPLEMENTATION
|
|
||||||
#include "video_core/renderer_vulkan/vk_common.h"
|
#include "video_core/renderer_vulkan/vk_common.h"
|
||||||
|
|
||||||
|
// Implement vma functions
|
||||||
|
#define VMA_IMPLEMENTATION
|
||||||
|
#include <vk_mem_alloc.h>
|
||||||
|
|
||||||
// Store the dispatch loader here
|
// Store the dispatch loader here
|
||||||
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
|
||||||
|
@ -9,13 +9,11 @@
|
|||||||
// Include vulkan-hpp header
|
// Include vulkan-hpp header
|
||||||
#define VK_NO_PROTOTYPES 1
|
#define VK_NO_PROTOTYPES 1
|
||||||
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1
|
||||||
|
#define VULKAN_HPP_NO_CONSTRUCTORS
|
||||||
#include <vulkan/vulkan.hpp>
|
#include <vulkan/vulkan.hpp>
|
||||||
|
|
||||||
// Include Vulkan memory allocator
|
|
||||||
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
#define VMA_STATIC_VULKAN_FUNCTIONS 0
|
||||||
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
|
||||||
#define VMA_VULKAN_VERSION 1001000 // Vulkan 1.1
|
|
||||||
#include <vk_mem_alloc.h>
|
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include "video_core/renderer_vulkan/vk_format_reinterpreter.h"
|
#include "video_core/renderer_vulkan/vk_format_reinterpreter.h"
|
||||||
#include "video_core/renderer_vulkan/vk_shader.h"
|
#include "video_core/renderer_vulkan/vk_shader.h"
|
||||||
#include "video_core/renderer_vulkan/vk_texture_runtime.h"
|
#include "video_core/renderer_vulkan/vk_texture_runtime.h"
|
||||||
|
@ -2,13 +2,14 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include <span>
|
#include <span>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "core/frontend/emu_window.h"
|
#include "core/frontend/emu_window.h"
|
||||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
#include "video_core/renderer_vulkan/vk_platform.h"
|
#include "video_core/renderer_vulkan/vk_platform.h"
|
||||||
|
|
||||||
|
#include <vk_mem_alloc.h>
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
vk::Format ToVkFormat(VideoCore::PixelFormat format) {
|
vk::Format ToVkFormat(VideoCore::PixelFormat format) {
|
||||||
|
@ -14,6 +14,8 @@ namespace Frontend {
|
|||||||
class EmuWindow;
|
class EmuWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VK_DEFINE_HANDLE(VmaAllocator)
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
struct FormatTraits {
|
struct FormatTraits {
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
namespace Frontend {
|
namespace Frontend {
|
||||||
class EmuWindow;
|
class EmuWindow;
|
||||||
enum class WindowSystemType : u8;
|
enum class WindowSystemType : u8;
|
||||||
} // namespace Frontend
|
}
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include "common/alignment.h"
|
#include "common/alignment.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/math_util.h"
|
#include "common/math_util.h"
|
||||||
@ -175,7 +174,6 @@ RasterizerVulkan::~RasterizerVulkan() {
|
|||||||
renderpass_cache.ExitRenderpass();
|
renderpass_cache.ExitRenderpass();
|
||||||
scheduler.Submit(SubmitMode::Flush | SubmitMode::Shutdown);
|
scheduler.Submit(SubmitMode::Flush | SubmitMode::Shutdown);
|
||||||
|
|
||||||
VmaAllocator allocator = instance.GetAllocator();
|
|
||||||
vk::Device device = instance.GetDevice();
|
vk::Device device = instance.GetDevice();
|
||||||
|
|
||||||
for (auto& [key, sampler] : samplers) {
|
for (auto& [key, sampler] : samplers) {
|
||||||
@ -186,9 +184,13 @@ RasterizerVulkan::~RasterizerVulkan() {
|
|||||||
device.destroyFramebuffer(framebuffer);
|
device.destroyFramebuffer(framebuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
vmaDestroyImage(allocator, default_texture.image, default_texture.allocation);
|
const VideoCore::HostTextureTag tag = {
|
||||||
device.destroyImageView(default_texture.image_view);
|
.format = VideoCore::PixelFormat::RGBA8,
|
||||||
device.destroyImageView(default_texture.base_view);
|
.width = 1,
|
||||||
|
.height = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
runtime.Recycle(tag, std::move(default_texture));
|
||||||
device.destroySampler(default_sampler);
|
device.destroySampler(default_sampler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
|
#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include <SPIRV/GlslangToSpv.h>
|
#include <SPIRV/GlslangToSpv.h>
|
||||||
#include <glslang/Include/ResourceLimits.h>
|
#include <glslang/Include/ResourceLimits.h>
|
||||||
#include <glslang/Public/ShaderLang.h>
|
#include <glslang/Public/ShaderLang.h>
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include "common/hash.h"
|
#include "common/hash.h"
|
||||||
|
@ -2,15 +2,15 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "common/alignment.h"
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
#include "video_core/renderer_vulkan/vk_stream_buffer.h"
|
#include "video_core/renderer_vulkan/vk_stream_buffer.h"
|
||||||
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
#include "video_core/renderer_vulkan/vk_task_scheduler.h"
|
||||||
|
|
||||||
|
#include <vk_mem_alloc.h>
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
inline auto ToVkAccessStageFlags(vk::BufferUsageFlagBits usage) {
|
inline auto ToVkAccessStageFlags(vk::BufferUsageFlagBits usage) {
|
||||||
|
@ -3,12 +3,15 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "video_core/renderer_vulkan/vk_common.h"
|
#include "video_core/renderer_vulkan/vk_common.h"
|
||||||
|
|
||||||
|
VK_DEFINE_HANDLE(VmaAllocation)
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
class Instance;
|
class Instance;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
#include "core/settings.h"
|
||||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
|
#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
|
||||||
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
||||||
@ -29,7 +29,7 @@ Swapchain::~Swapchain() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Swapchain::Create(u32 width, u32 height, bool vsync_enabled) {
|
void Swapchain::Create(u32 width, u32 height) {
|
||||||
is_outdated = false;
|
is_outdated = false;
|
||||||
is_suboptimal = false;
|
is_suboptimal = false;
|
||||||
|
|
||||||
@ -184,12 +184,14 @@ void Swapchain::Configure(u32 width, u32 height) {
|
|||||||
|
|
||||||
// FIFO is guaranteed by the Vulkan standard to be available
|
// FIFO is guaranteed by the Vulkan standard to be available
|
||||||
present_mode = vk::PresentModeKHR::eFifo;
|
present_mode = vk::PresentModeKHR::eFifo;
|
||||||
auto iter = std::ranges::find_if(
|
if (!Settings::values.use_vsync_new) {
|
||||||
modes, [](vk::PresentModeKHR mode) { return vk::PresentModeKHR::eMailbox == mode; });
|
auto iter = std::ranges::find_if(
|
||||||
|
modes, [](vk::PresentModeKHR mode) { return vk::PresentModeKHR::eMailbox == mode; });
|
||||||
|
|
||||||
// Prefer Mailbox if present for lowest latency
|
// Prefer Mailbox when vsync is disabled for lowest latency
|
||||||
if (iter != modes.end()) {
|
if (iter != modes.end()) {
|
||||||
present_mode = vk::PresentModeKHR::eMailbox;
|
present_mode = vk::PresentModeKHR::eMailbox;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Query surface extent
|
// Query surface extent
|
||||||
|
@ -19,7 +19,7 @@ public:
|
|||||||
~Swapchain();
|
~Swapchain();
|
||||||
|
|
||||||
/// Creates (or recreates) the swapchain with a given size.
|
/// Creates (or recreates) the swapchain with a given size.
|
||||||
void Create(u32 width, u32 height, bool vsync_enabled);
|
void Create(u32 width, u32 height);
|
||||||
|
|
||||||
/// Acquires the next image in the swapchain.
|
/// Acquires the next image in the swapchain.
|
||||||
void AcquireNextImage(vk::Semaphore signal_acquired);
|
void AcquireNextImage(vk::Semaphore signal_acquired);
|
||||||
@ -83,7 +83,6 @@ private:
|
|||||||
std::vector<Image> swapchain_images;
|
std::vector<Image> swapchain_images;
|
||||||
u32 current_image = 0;
|
u32 current_image = 0;
|
||||||
u32 current_frame = 0;
|
u32 current_frame = 0;
|
||||||
bool vsync_enabled = false;
|
|
||||||
bool is_outdated = true;
|
bool is_outdated = true;
|
||||||
bool is_suboptimal = true;
|
bool is_suboptimal = true;
|
||||||
};
|
};
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#define VULKAN_HPP_NO_CONSTRUCTORS
|
|
||||||
#include "video_core/rasterizer_cache/utils.h"
|
#include "video_core/rasterizer_cache/utils.h"
|
||||||
#include "video_core/renderer_vulkan/vk_instance.h"
|
#include "video_core/renderer_vulkan/vk_instance.h"
|
||||||
#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
|
#include "video_core/renderer_vulkan/vk_renderpass_cache.h"
|
||||||
@ -10,6 +9,7 @@
|
|||||||
#include "video_core/renderer_vulkan/vk_texture_runtime.h"
|
#include "video_core/renderer_vulkan/vk_texture_runtime.h"
|
||||||
|
|
||||||
#include <vulkan/vulkan_format_traits.hpp>
|
#include <vulkan/vulkan_format_traits.hpp>
|
||||||
|
#include <vk_mem_alloc.h>
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <span>
|
#include <span>
|
||||||
#include <vulkan/vulkan_hash.hpp>
|
#include <vulkan/vulkan_hash.hpp>
|
||||||
@ -114,7 +115,6 @@ private:
|
|||||||
std::array<u32, SCHEDULER_COMMAND_COUNT> staging_offsets{};
|
std::array<u32, SCHEDULER_COMMAND_COUNT> staging_offsets{};
|
||||||
std::unordered_multimap<VideoCore::HostTextureTag, ImageAlloc> texture_recycler;
|
std::unordered_multimap<VideoCore::HostTextureTag, ImageAlloc> texture_recycler;
|
||||||
std::unordered_map<vk::ImageView, vk::Framebuffer> clear_framebuffers;
|
std::unordered_map<vk::ImageView, vk::Framebuffer> clear_framebuffers;
|
||||||
ReinterpreterList list;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Surface : public VideoCore::SurfaceBase<Surface> {
|
class Surface : public VideoCore::SurfaceBase<Surface> {
|
||||||
|
Reference in New Issue
Block a user