early-access version 3281
This commit is contained in:
parent
ece2622a91
commit
c22147eb61
26 changed files with 589 additions and 71 deletions
|
@ -1,7 +1,7 @@
|
||||||
yuzu emulator early access
|
yuzu emulator early access
|
||||||
=============
|
=============
|
||||||
|
|
||||||
This is the source code for early-access 3280.
|
This is the source code for early-access 3281.
|
||||||
|
|
||||||
## Legal Notice
|
## Legal Notice
|
||||||
|
|
||||||
|
|
|
@ -185,6 +185,7 @@ void RestoreGlobalState(bool is_powered_on) {
|
||||||
// Renderer
|
// Renderer
|
||||||
values.fsr_sharpening_slider.SetGlobal(true);
|
values.fsr_sharpening_slider.SetGlobal(true);
|
||||||
values.renderer_backend.SetGlobal(true);
|
values.renderer_backend.SetGlobal(true);
|
||||||
|
values.renderer_force_max_clock.SetGlobal(true);
|
||||||
values.vulkan_device.SetGlobal(true);
|
values.vulkan_device.SetGlobal(true);
|
||||||
values.aspect_ratio.SetGlobal(true);
|
values.aspect_ratio.SetGlobal(true);
|
||||||
values.max_anisotropy.SetGlobal(true);
|
values.max_anisotropy.SetGlobal(true);
|
||||||
|
@ -200,6 +201,7 @@ void RestoreGlobalState(bool is_powered_on) {
|
||||||
values.use_asynchronous_shaders.SetGlobal(true);
|
values.use_asynchronous_shaders.SetGlobal(true);
|
||||||
values.use_fast_gpu_time.SetGlobal(true);
|
values.use_fast_gpu_time.SetGlobal(true);
|
||||||
values.use_pessimistic_flushes.SetGlobal(true);
|
values.use_pessimistic_flushes.SetGlobal(true);
|
||||||
|
values.use_vulkan_driver_pipeline_cache.SetGlobal(true);
|
||||||
values.bg_red.SetGlobal(true);
|
values.bg_red.SetGlobal(true);
|
||||||
values.bg_green.SetGlobal(true);
|
values.bg_green.SetGlobal(true);
|
||||||
values.bg_blue.SetGlobal(true);
|
values.bg_blue.SetGlobal(true);
|
||||||
|
|
|
@ -415,6 +415,7 @@ struct Values {
|
||||||
// Renderer
|
// Renderer
|
||||||
SwitchableSetting<RendererBackend, true> renderer_backend{
|
SwitchableSetting<RendererBackend, true> renderer_backend{
|
||||||
RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend"};
|
RendererBackend::Vulkan, RendererBackend::OpenGL, RendererBackend::Null, "backend"};
|
||||||
|
SwitchableSetting<bool> renderer_force_max_clock{true, "force_max_clock"};
|
||||||
Setting<bool> renderer_debug{false, "debug"};
|
Setting<bool> renderer_debug{false, "debug"};
|
||||||
Setting<bool> renderer_shader_feedback{false, "shader_feedback"};
|
Setting<bool> renderer_shader_feedback{false, "shader_feedback"};
|
||||||
Setting<bool> enable_nsight_aftermath{false, "nsight_aftermath"};
|
Setting<bool> enable_nsight_aftermath{false, "nsight_aftermath"};
|
||||||
|
@ -451,6 +452,8 @@ struct Values {
|
||||||
SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"};
|
SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"};
|
||||||
SwitchableSetting<bool> use_fast_gpu_time{true, "use_fast_gpu_time"};
|
SwitchableSetting<bool> use_fast_gpu_time{true, "use_fast_gpu_time"};
|
||||||
SwitchableSetting<bool> use_pessimistic_flushes{false, "use_pessimistic_flushes"};
|
SwitchableSetting<bool> use_pessimistic_flushes{false, "use_pessimistic_flushes"};
|
||||||
|
SwitchableSetting<bool> use_vulkan_driver_pipeline_cache{true,
|
||||||
|
"use_vulkan_driver_pipeline_cache"};
|
||||||
|
|
||||||
SwitchableSetting<u8> bg_red{0, "bg_red"};
|
SwitchableSetting<u8> bg_red{0, "bg_red"};
|
||||||
SwitchableSetting<u8> bg_green{0, "bg_green"};
|
SwitchableSetting<u8> bg_green{0, "bg_green"};
|
||||||
|
|
|
@ -190,6 +190,8 @@ add_library(video_core STATIC
|
||||||
renderer_vulkan/vk_texture_cache.cpp
|
renderer_vulkan/vk_texture_cache.cpp
|
||||||
renderer_vulkan/vk_texture_cache.h
|
renderer_vulkan/vk_texture_cache.h
|
||||||
renderer_vulkan/vk_texture_cache_base.cpp
|
renderer_vulkan/vk_texture_cache_base.cpp
|
||||||
|
renderer_vulkan/vk_turbo_mode.cpp
|
||||||
|
renderer_vulkan/vk_turbo_mode.h
|
||||||
renderer_vulkan/vk_update_descriptor.cpp
|
renderer_vulkan/vk_update_descriptor.cpp
|
||||||
renderer_vulkan/vk_update_descriptor.h
|
renderer_vulkan/vk_update_descriptor.h
|
||||||
shader_cache.cpp
|
shader_cache.cpp
|
||||||
|
|
|
@ -47,6 +47,7 @@ set(SHADER_FILES
|
||||||
vulkan_present_scaleforce_fp16.frag
|
vulkan_present_scaleforce_fp16.frag
|
||||||
vulkan_present_scaleforce_fp32.frag
|
vulkan_present_scaleforce_fp32.frag
|
||||||
vulkan_quad_indexed.comp
|
vulkan_quad_indexed.comp
|
||||||
|
vulkan_turbo_mode.comp
|
||||||
vulkan_uint8.comp
|
vulkan_uint8.comp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
29
src/video_core/host_shaders/vulkan_turbo_mode.comp
Executable file
29
src/video_core/host_shaders/vulkan_turbo_mode.comp
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#version 460 core
|
||||||
|
|
||||||
|
layout (local_size_x = 16, local_size_y = 8, local_size_z = 1) in;
|
||||||
|
|
||||||
|
layout (binding = 0) buffer ThreadData {
|
||||||
|
uint data[];
|
||||||
|
};
|
||||||
|
|
||||||
|
uint xorshift32(uint x) {
|
||||||
|
x ^= x << 13;
|
||||||
|
x ^= x >> 17;
|
||||||
|
x ^= x << 5;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint getGlobalIndex() {
|
||||||
|
return gl_GlobalInvocationID.x + gl_GlobalInvocationID.y * gl_WorkGroupSize.y * gl_NumWorkGroups.y;
|
||||||
|
}
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
uint myIndex = xorshift32(getGlobalIndex());
|
||||||
|
uint otherIndex = xorshift32(myIndex);
|
||||||
|
|
||||||
|
uint otherValue = atomicAdd(data[otherIndex % data.length()], 0) + 1;
|
||||||
|
atomicAdd(data[myIndex % data.length()], otherValue);
|
||||||
|
}
|
|
@ -78,6 +78,8 @@ std::string BuildCommaSeparatedExtensions(std::vector<std::string> available_ext
|
||||||
return separated_extensions;
|
return separated_extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Anonymous namespace
|
||||||
|
|
||||||
Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld,
|
Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld,
|
||||||
VkSurfaceKHR surface) {
|
VkSurfaceKHR surface) {
|
||||||
const std::vector<VkPhysicalDevice> devices = instance.EnumeratePhysicalDevices();
|
const std::vector<VkPhysicalDevice> devices = instance.EnumeratePhysicalDevices();
|
||||||
|
@ -89,7 +91,6 @@ Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dl
|
||||||
const vk::PhysicalDevice physical_device(devices[device_index], dld);
|
const vk::PhysicalDevice physical_device(devices[device_index], dld);
|
||||||
return Device(*instance, physical_device, surface, dld);
|
return Device(*instance, physical_device, surface, dld);
|
||||||
}
|
}
|
||||||
} // Anonymous namespace
|
|
||||||
|
|
||||||
RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
|
RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
|
||||||
Core::Frontend::EmuWindow& emu_window,
|
Core::Frontend::EmuWindow& emu_window,
|
||||||
|
@ -109,6 +110,9 @@ RendererVulkan::RendererVulkan(Core::TelemetrySession& telemetry_session_,
|
||||||
screen_info),
|
screen_info),
|
||||||
rasterizer(render_window, gpu, cpu_memory, screen_info, device, memory_allocator,
|
rasterizer(render_window, gpu, cpu_memory, screen_info, device, memory_allocator,
|
||||||
state_tracker, scheduler) {
|
state_tracker, scheduler) {
|
||||||
|
if (Settings::values.renderer_force_max_clock.GetValue()) {
|
||||||
|
turbo_mode.emplace(instance, dld);
|
||||||
|
}
|
||||||
Report();
|
Report();
|
||||||
} catch (const vk::Exception& exception) {
|
} catch (const vk::Exception& exception) {
|
||||||
LOG_ERROR(Render_Vulkan, "Vulkan initialization failed with error: {}", exception.what());
|
LOG_ERROR(Render_Vulkan, "Vulkan initialization failed with error: {}", exception.what());
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
#include "video_core/renderer_vulkan/vk_scheduler.h"
|
||||||
#include "video_core/renderer_vulkan/vk_state_tracker.h"
|
#include "video_core/renderer_vulkan/vk_state_tracker.h"
|
||||||
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
#include "video_core/renderer_vulkan/vk_swapchain.h"
|
||||||
|
#include "video_core/renderer_vulkan/vk_turbo_mode.h"
|
||||||
#include "video_core/vulkan_common/vulkan_device.h"
|
#include "video_core/vulkan_common/vulkan_device.h"
|
||||||
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
||||||
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||||
|
@ -31,6 +32,9 @@ class GPU;
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
|
|
||||||
|
Device CreateDevice(const vk::Instance& instance, const vk::InstanceDispatch& dld,
|
||||||
|
VkSurfaceKHR surface);
|
||||||
|
|
||||||
class RendererVulkan final : public VideoCore::RendererBase {
|
class RendererVulkan final : public VideoCore::RendererBase {
|
||||||
public:
|
public:
|
||||||
explicit RendererVulkan(Core::TelemetrySession& telemtry_session,
|
explicit RendererVulkan(Core::TelemetrySession& telemtry_session,
|
||||||
|
@ -74,6 +78,7 @@ private:
|
||||||
Swapchain swapchain;
|
Swapchain swapchain;
|
||||||
BlitScreen blit_screen;
|
BlitScreen blit_screen;
|
||||||
RasterizerVulkan rasterizer;
|
RasterizerVulkan rasterizer;
|
||||||
|
std::optional<TurboMode> turbo_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -24,13 +24,15 @@ using Shader::ImageBufferDescriptor;
|
||||||
using Shader::Backend::SPIRV::RESCALING_LAYOUT_WORDS_OFFSET;
|
using Shader::Backend::SPIRV::RESCALING_LAYOUT_WORDS_OFFSET;
|
||||||
using Tegra::Texture::TexturePair;
|
using Tegra::Texture::TexturePair;
|
||||||
|
|
||||||
ComputePipeline::ComputePipeline(const Device& device_, DescriptorPool& descriptor_pool,
|
ComputePipeline::ComputePipeline(const Device& device_, vk::PipelineCache& pipeline_cache_,
|
||||||
|
DescriptorPool& descriptor_pool,
|
||||||
UpdateDescriptorQueue& update_descriptor_queue_,
|
UpdateDescriptorQueue& update_descriptor_queue_,
|
||||||
Common::ThreadWorker* thread_worker,
|
Common::ThreadWorker* thread_worker,
|
||||||
PipelineStatistics* pipeline_statistics,
|
PipelineStatistics* pipeline_statistics,
|
||||||
VideoCore::ShaderNotify* shader_notify, const Shader::Info& info_,
|
VideoCore::ShaderNotify* shader_notify, const Shader::Info& info_,
|
||||||
vk::ShaderModule spv_module_)
|
vk::ShaderModule spv_module_)
|
||||||
: device{device_}, update_descriptor_queue{update_descriptor_queue_}, info{info_},
|
: device{device_}, pipeline_cache(pipeline_cache_),
|
||||||
|
update_descriptor_queue{update_descriptor_queue_}, info{info_},
|
||||||
spv_module(std::move(spv_module_)) {
|
spv_module(std::move(spv_module_)) {
|
||||||
if (shader_notify) {
|
if (shader_notify) {
|
||||||
shader_notify->MarkShaderBuilding();
|
shader_notify->MarkShaderBuilding();
|
||||||
|
@ -56,23 +58,27 @@ ComputePipeline::ComputePipeline(const Device& device_, DescriptorPool& descript
|
||||||
if (device.IsKhrPipelineExecutablePropertiesEnabled()) {
|
if (device.IsKhrPipelineExecutablePropertiesEnabled()) {
|
||||||
flags |= VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR;
|
flags |= VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR;
|
||||||
}
|
}
|
||||||
pipeline = device.GetLogical().CreateComputePipeline({
|
pipeline = device.GetLogical().CreateComputePipeline(
|
||||||
.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
|
{
|
||||||
.pNext = nullptr,
|
.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
|
||||||
.flags = flags,
|
.pNext = nullptr,
|
||||||
.stage{
|
.flags = flags,
|
||||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
.stage{
|
||||||
.pNext = device.IsExtSubgroupSizeControlSupported() ? &subgroup_size_ci : nullptr,
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||||
.flags = 0,
|
.pNext =
|
||||||
.stage = VK_SHADER_STAGE_COMPUTE_BIT,
|
device.IsExtSubgroupSizeControlSupported() ? &subgroup_size_ci : nullptr,
|
||||||
.module = *spv_module,
|
.flags = 0,
|
||||||
.pName = "main",
|
.stage = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
.pSpecializationInfo = nullptr,
|
.module = *spv_module,
|
||||||
|
.pName = "main",
|
||||||
|
.pSpecializationInfo = nullptr,
|
||||||
|
},
|
||||||
|
.layout = *pipeline_layout,
|
||||||
|
.basePipelineHandle = 0,
|
||||||
|
.basePipelineIndex = 0,
|
||||||
},
|
},
|
||||||
.layout = *pipeline_layout,
|
*pipeline_cache);
|
||||||
.basePipelineHandle = 0,
|
|
||||||
.basePipelineIndex = 0,
|
|
||||||
});
|
|
||||||
if (pipeline_statistics) {
|
if (pipeline_statistics) {
|
||||||
pipeline_statistics->Collect(*pipeline);
|
pipeline_statistics->Collect(*pipeline);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,8 @@ class Scheduler;
|
||||||
|
|
||||||
class ComputePipeline {
|
class ComputePipeline {
|
||||||
public:
|
public:
|
||||||
explicit ComputePipeline(const Device& device, DescriptorPool& descriptor_pool,
|
explicit ComputePipeline(const Device& device, vk::PipelineCache& pipeline_cache,
|
||||||
|
DescriptorPool& descriptor_pool,
|
||||||
UpdateDescriptorQueue& update_descriptor_queue,
|
UpdateDescriptorQueue& update_descriptor_queue,
|
||||||
Common::ThreadWorker* thread_worker,
|
Common::ThreadWorker* thread_worker,
|
||||||
PipelineStatistics* pipeline_statistics,
|
PipelineStatistics* pipeline_statistics,
|
||||||
|
@ -46,6 +47,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Device& device;
|
const Device& device;
|
||||||
|
vk::PipelineCache& pipeline_cache;
|
||||||
UpdateDescriptorQueue& update_descriptor_queue;
|
UpdateDescriptorQueue& update_descriptor_queue;
|
||||||
Shader::Info info;
|
Shader::Info info;
|
||||||
|
|
||||||
|
|
|
@ -234,13 +234,14 @@ ConfigureFuncPtr ConfigureFunc(const std::array<vk::ShaderModule, NUM_STAGES>& m
|
||||||
|
|
||||||
GraphicsPipeline::GraphicsPipeline(
|
GraphicsPipeline::GraphicsPipeline(
|
||||||
Scheduler& scheduler_, BufferCache& buffer_cache_, TextureCache& texture_cache_,
|
Scheduler& scheduler_, BufferCache& buffer_cache_, TextureCache& texture_cache_,
|
||||||
VideoCore::ShaderNotify* shader_notify, const Device& device_, DescriptorPool& descriptor_pool,
|
vk::PipelineCache& pipeline_cache_, VideoCore::ShaderNotify* shader_notify,
|
||||||
|
const Device& device_, DescriptorPool& descriptor_pool,
|
||||||
UpdateDescriptorQueue& update_descriptor_queue_, Common::ThreadWorker* worker_thread,
|
UpdateDescriptorQueue& update_descriptor_queue_, Common::ThreadWorker* worker_thread,
|
||||||
PipelineStatistics* pipeline_statistics, RenderPassCache& render_pass_cache,
|
PipelineStatistics* pipeline_statistics, RenderPassCache& render_pass_cache,
|
||||||
const GraphicsPipelineCacheKey& key_, std::array<vk::ShaderModule, NUM_STAGES> stages,
|
const GraphicsPipelineCacheKey& key_, std::array<vk::ShaderModule, NUM_STAGES> stages,
|
||||||
const std::array<const Shader::Info*, NUM_STAGES>& infos)
|
const std::array<const Shader::Info*, NUM_STAGES>& infos)
|
||||||
: key{key_}, device{device_}, texture_cache{texture_cache_},
|
: key{key_}, device{device_}, texture_cache{texture_cache_}, buffer_cache{buffer_cache_},
|
||||||
buffer_cache{buffer_cache_}, scheduler{scheduler_},
|
pipeline_cache(pipeline_cache_), scheduler{scheduler_},
|
||||||
update_descriptor_queue{update_descriptor_queue_}, spv_modules{std::move(stages)} {
|
update_descriptor_queue{update_descriptor_queue_}, spv_modules{std::move(stages)} {
|
||||||
if (shader_notify) {
|
if (shader_notify) {
|
||||||
shader_notify->MarkShaderBuilding();
|
shader_notify->MarkShaderBuilding();
|
||||||
|
@ -894,27 +895,29 @@ void GraphicsPipeline::MakePipeline(VkRenderPass render_pass) {
|
||||||
if (device.IsKhrPipelineExecutablePropertiesEnabled()) {
|
if (device.IsKhrPipelineExecutablePropertiesEnabled()) {
|
||||||
flags |= VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR;
|
flags |= VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR;
|
||||||
}
|
}
|
||||||
pipeline = device.GetLogical().CreateGraphicsPipeline({
|
pipeline = device.GetLogical().CreateGraphicsPipeline(
|
||||||
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
{
|
||||||
.pNext = nullptr,
|
.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
|
||||||
.flags = flags,
|
.pNext = nullptr,
|
||||||
.stageCount = static_cast<u32>(shader_stages.size()),
|
.flags = flags,
|
||||||
.pStages = shader_stages.data(),
|
.stageCount = static_cast<u32>(shader_stages.size()),
|
||||||
.pVertexInputState = &vertex_input_ci,
|
.pStages = shader_stages.data(),
|
||||||
.pInputAssemblyState = &input_assembly_ci,
|
.pVertexInputState = &vertex_input_ci,
|
||||||
.pTessellationState = &tessellation_ci,
|
.pInputAssemblyState = &input_assembly_ci,
|
||||||
.pViewportState = &viewport_ci,
|
.pTessellationState = &tessellation_ci,
|
||||||
.pRasterizationState = &rasterization_ci,
|
.pViewportState = &viewport_ci,
|
||||||
.pMultisampleState = &multisample_ci,
|
.pRasterizationState = &rasterization_ci,
|
||||||
.pDepthStencilState = &depth_stencil_ci,
|
.pMultisampleState = &multisample_ci,
|
||||||
.pColorBlendState = &color_blend_ci,
|
.pDepthStencilState = &depth_stencil_ci,
|
||||||
.pDynamicState = &dynamic_state_ci,
|
.pColorBlendState = &color_blend_ci,
|
||||||
.layout = *pipeline_layout,
|
.pDynamicState = &dynamic_state_ci,
|
||||||
.renderPass = render_pass,
|
.layout = *pipeline_layout,
|
||||||
.subpass = 0,
|
.renderPass = render_pass,
|
||||||
.basePipelineHandle = nullptr,
|
.subpass = 0,
|
||||||
.basePipelineIndex = 0,
|
.basePipelineHandle = nullptr,
|
||||||
});
|
.basePipelineIndex = 0,
|
||||||
|
},
|
||||||
|
*pipeline_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsPipeline::Validate() {
|
void GraphicsPipeline::Validate() {
|
||||||
|
|
|
@ -70,16 +70,14 @@ class GraphicsPipeline {
|
||||||
static constexpr size_t NUM_STAGES = Tegra::Engines::Maxwell3D::Regs::MaxShaderStage;
|
static constexpr size_t NUM_STAGES = Tegra::Engines::Maxwell3D::Regs::MaxShaderStage;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GraphicsPipeline(Scheduler& scheduler, BufferCache& buffer_cache,
|
explicit GraphicsPipeline(
|
||||||
TextureCache& texture_cache, VideoCore::ShaderNotify* shader_notify,
|
Scheduler& scheduler, BufferCache& buffer_cache, TextureCache& texture_cache,
|
||||||
const Device& device, DescriptorPool& descriptor_pool,
|
vk::PipelineCache& pipeline_cache, VideoCore::ShaderNotify* shader_notify,
|
||||||
UpdateDescriptorQueue& update_descriptor_queue,
|
const Device& device, DescriptorPool& descriptor_pool,
|
||||||
Common::ThreadWorker* worker_thread,
|
UpdateDescriptorQueue& update_descriptor_queue, Common::ThreadWorker* worker_thread,
|
||||||
PipelineStatistics* pipeline_statistics,
|
PipelineStatistics* pipeline_statistics, RenderPassCache& render_pass_cache,
|
||||||
RenderPassCache& render_pass_cache,
|
const GraphicsPipelineCacheKey& key, std::array<vk::ShaderModule, NUM_STAGES> stages,
|
||||||
const GraphicsPipelineCacheKey& key,
|
const std::array<const Shader::Info*, NUM_STAGES>& infos);
|
||||||
std::array<vk::ShaderModule, NUM_STAGES> stages,
|
|
||||||
const std::array<const Shader::Info*, NUM_STAGES>& infos);
|
|
||||||
|
|
||||||
GraphicsPipeline& operator=(GraphicsPipeline&&) noexcept = delete;
|
GraphicsPipeline& operator=(GraphicsPipeline&&) noexcept = delete;
|
||||||
GraphicsPipeline(GraphicsPipeline&&) noexcept = delete;
|
GraphicsPipeline(GraphicsPipeline&&) noexcept = delete;
|
||||||
|
@ -133,6 +131,7 @@ private:
|
||||||
const Device& device;
|
const Device& device;
|
||||||
TextureCache& texture_cache;
|
TextureCache& texture_cache;
|
||||||
BufferCache& buffer_cache;
|
BufferCache& buffer_cache;
|
||||||
|
vk::PipelineCache& pipeline_cache;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
UpdateDescriptorQueue& update_descriptor_queue;
|
UpdateDescriptorQueue& update_descriptor_queue;
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ using VideoCommon::GenericEnvironment;
|
||||||
using VideoCommon::GraphicsEnvironment;
|
using VideoCommon::GraphicsEnvironment;
|
||||||
|
|
||||||
constexpr u32 CACHE_VERSION = 10;
|
constexpr u32 CACHE_VERSION = 10;
|
||||||
|
constexpr std::array<char, 8> VULKAN_CACHE_MAGIC_NUMBER{'y', 'u', 'z', 'u', 'v', 'k', 'c', 'h'};
|
||||||
|
|
||||||
template <typename Container>
|
template <typename Container>
|
||||||
auto MakeSpan(Container& container) {
|
auto MakeSpan(Container& container) {
|
||||||
|
@ -284,6 +285,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device
|
||||||
render_pass_cache{render_pass_cache_}, buffer_cache{buffer_cache_},
|
render_pass_cache{render_pass_cache_}, buffer_cache{buffer_cache_},
|
||||||
texture_cache{texture_cache_}, shader_notify{shader_notify_},
|
texture_cache{texture_cache_}, shader_notify{shader_notify_},
|
||||||
use_asynchronous_shaders{Settings::values.use_asynchronous_shaders.GetValue()},
|
use_asynchronous_shaders{Settings::values.use_asynchronous_shaders.GetValue()},
|
||||||
|
use_vulkan_pipeline_cache{Settings::values.use_vulkan_driver_pipeline_cache.GetValue()},
|
||||||
workers(std::max(std::thread::hardware_concurrency(), 2U) - 1, "VkPipelineBuilder"),
|
workers(std::max(std::thread::hardware_concurrency(), 2U) - 1, "VkPipelineBuilder"),
|
||||||
serialization_thread(1, "VkPipelineSerialization") {
|
serialization_thread(1, "VkPipelineSerialization") {
|
||||||
const auto& float_control{device.FloatControlProperties()};
|
const auto& float_control{device.FloatControlProperties()};
|
||||||
|
@ -362,7 +364,12 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
PipelineCache::~PipelineCache() = default;
|
PipelineCache::~PipelineCache() {
|
||||||
|
if (use_vulkan_pipeline_cache && !vulkan_pipeline_cache_filename.empty()) {
|
||||||
|
SerializeVulkanPipelineCache(vulkan_pipeline_cache_filename, vulkan_pipeline_cache,
|
||||||
|
CACHE_VERSION);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GraphicsPipeline* PipelineCache::CurrentGraphicsPipeline() {
|
GraphicsPipeline* PipelineCache::CurrentGraphicsPipeline() {
|
||||||
MICROPROFILE_SCOPE(Vulkan_PipelineCache);
|
MICROPROFILE_SCOPE(Vulkan_PipelineCache);
|
||||||
|
@ -418,6 +425,12 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
|
||||||
}
|
}
|
||||||
pipeline_cache_filename = base_dir / "vulkan.bin";
|
pipeline_cache_filename = base_dir / "vulkan.bin";
|
||||||
|
|
||||||
|
if (use_vulkan_pipeline_cache) {
|
||||||
|
vulkan_pipeline_cache_filename = base_dir / "vulkan_pipelines.bin";
|
||||||
|
vulkan_pipeline_cache =
|
||||||
|
LoadVulkanPipelineCache(vulkan_pipeline_cache_filename, CACHE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
std::mutex mutex;
|
std::mutex mutex;
|
||||||
size_t total{};
|
size_t total{};
|
||||||
|
@ -496,6 +509,11 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading
|
||||||
|
|
||||||
workers.WaitForRequests(stop_loading);
|
workers.WaitForRequests(stop_loading);
|
||||||
|
|
||||||
|
if (use_vulkan_pipeline_cache) {
|
||||||
|
SerializeVulkanPipelineCache(vulkan_pipeline_cache_filename, vulkan_pipeline_cache,
|
||||||
|
CACHE_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
if (state.statistics) {
|
if (state.statistics) {
|
||||||
state.statistics->Report();
|
state.statistics->Report();
|
||||||
}
|
}
|
||||||
|
@ -616,10 +634,10 @@ std::unique_ptr<GraphicsPipeline> PipelineCache::CreateGraphicsPipeline(
|
||||||
previous_stage = &program;
|
previous_stage = &program;
|
||||||
}
|
}
|
||||||
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
|
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
|
||||||
return std::make_unique<GraphicsPipeline>(scheduler, buffer_cache, texture_cache,
|
return std::make_unique<GraphicsPipeline>(
|
||||||
&shader_notify, device, descriptor_pool,
|
scheduler, buffer_cache, texture_cache, vulkan_pipeline_cache, &shader_notify, device,
|
||||||
update_descriptor_queue, thread_worker, statistics,
|
descriptor_pool, update_descriptor_queue, thread_worker, statistics, render_pass_cache, key,
|
||||||
render_pass_cache, key, std::move(modules), infos);
|
std::move(modules), infos);
|
||||||
|
|
||||||
} catch (const Shader::Exception& exception) {
|
} catch (const Shader::Exception& exception) {
|
||||||
LOG_ERROR(Render_Vulkan, "{}", exception.what());
|
LOG_ERROR(Render_Vulkan, "{}", exception.what());
|
||||||
|
@ -689,13 +707,107 @@ std::unique_ptr<ComputePipeline> PipelineCache::CreateComputePipeline(
|
||||||
spv_module.SetObjectNameEXT(name.c_str());
|
spv_module.SetObjectNameEXT(name.c_str());
|
||||||
}
|
}
|
||||||
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
|
Common::ThreadWorker* const thread_worker{build_in_parallel ? &workers : nullptr};
|
||||||
return std::make_unique<ComputePipeline>(device, descriptor_pool, update_descriptor_queue,
|
return std::make_unique<ComputePipeline>(device, vulkan_pipeline_cache, descriptor_pool,
|
||||||
thread_worker, statistics, &shader_notify,
|
update_descriptor_queue, thread_worker, statistics,
|
||||||
program.info, std::move(spv_module));
|
&shader_notify, program.info, std::move(spv_module));
|
||||||
|
|
||||||
} catch (const Shader::Exception& exception) {
|
} catch (const Shader::Exception& exception) {
|
||||||
LOG_ERROR(Render_Vulkan, "{}", exception.what());
|
LOG_ERROR(Render_Vulkan, "{}", exception.what());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PipelineCache::SerializeVulkanPipelineCache(const std::filesystem::path& filename,
|
||||||
|
const vk::PipelineCache& pipeline_cache,
|
||||||
|
u32 cache_version) try {
|
||||||
|
std::ofstream file(filename, std::ios::binary);
|
||||||
|
file.exceptions(std::ifstream::failbit);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
LOG_ERROR(Common_Filesystem, "Failed to open Vulkan driver pipeline cache file {}",
|
||||||
|
Common::FS::PathToUTF8String(filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
file.write(VULKAN_CACHE_MAGIC_NUMBER.data(), VULKAN_CACHE_MAGIC_NUMBER.size())
|
||||||
|
.write(reinterpret_cast<const char*>(&cache_version), sizeof(cache_version));
|
||||||
|
|
||||||
|
size_t cache_size = 0;
|
||||||
|
std::vector<char> cache_data;
|
||||||
|
if (pipeline_cache) {
|
||||||
|
pipeline_cache.Read(&cache_size, nullptr);
|
||||||
|
cache_data.resize(cache_size);
|
||||||
|
pipeline_cache.Read(&cache_size, cache_data.data());
|
||||||
|
}
|
||||||
|
file.write(cache_data.data(), cache_size);
|
||||||
|
|
||||||
|
LOG_INFO(Render_Vulkan, "Vulkan driver pipelines cached at: {}",
|
||||||
|
Common::FS::PathToUTF8String(filename));
|
||||||
|
|
||||||
|
} catch (const std::ios_base::failure& e) {
|
||||||
|
LOG_ERROR(Common_Filesystem, "{}", e.what());
|
||||||
|
if (!Common::FS::RemoveFile(filename)) {
|
||||||
|
LOG_ERROR(Common_Filesystem, "Failed to delete Vulkan driver pipeline cache file {}",
|
||||||
|
Common::FS::PathToUTF8String(filename));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vk::PipelineCache PipelineCache::LoadVulkanPipelineCache(const std::filesystem::path& filename,
|
||||||
|
u32 expected_cache_version) {
|
||||||
|
const auto create_pipeline_cache = [this](size_t data_size, const void* data) {
|
||||||
|
VkPipelineCacheCreateInfo pipeline_cache_ci = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
.initialDataSize = data_size,
|
||||||
|
.pInitialData = data};
|
||||||
|
return device.GetLogical().CreatePipelineCache(pipeline_cache_ci);
|
||||||
|
};
|
||||||
|
try {
|
||||||
|
std::ifstream file(filename, std::ios::binary | std::ios::ate);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
return create_pipeline_cache(0, nullptr);
|
||||||
|
}
|
||||||
|
file.exceptions(std::ifstream::failbit);
|
||||||
|
const auto end{file.tellg()};
|
||||||
|
file.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
|
std::array<char, 8> magic_number;
|
||||||
|
u32 cache_version;
|
||||||
|
file.read(magic_number.data(), magic_number.size())
|
||||||
|
.read(reinterpret_cast<char*>(&cache_version), sizeof(cache_version));
|
||||||
|
if (magic_number != VULKAN_CACHE_MAGIC_NUMBER || cache_version != expected_cache_version) {
|
||||||
|
file.close();
|
||||||
|
if (Common::FS::RemoveFile(filename)) {
|
||||||
|
if (magic_number != VULKAN_CACHE_MAGIC_NUMBER) {
|
||||||
|
LOG_ERROR(Common_Filesystem, "Invalid Vulkan driver pipeline cache file");
|
||||||
|
}
|
||||||
|
if (cache_version != expected_cache_version) {
|
||||||
|
LOG_INFO(Common_Filesystem, "Deleting old Vulkan driver pipeline cache");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(Common_Filesystem,
|
||||||
|
"Invalid Vulkan pipeline cache file and failed to delete it in \"{}\"",
|
||||||
|
Common::FS::PathToUTF8String(filename));
|
||||||
|
}
|
||||||
|
return create_pipeline_cache(0, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
const size_t cache_size = static_cast<size_t>(end) - magic_number.size();
|
||||||
|
std::vector<char> cache_data(cache_size);
|
||||||
|
file.read(cache_data.data(), cache_size);
|
||||||
|
|
||||||
|
LOG_INFO(Render_Vulkan,
|
||||||
|
"Loaded Vulkan driver pipeline cache: ", Common::FS::PathToUTF8String(filename));
|
||||||
|
|
||||||
|
return create_pipeline_cache(cache_size, cache_data.data());
|
||||||
|
|
||||||
|
} catch (const std::ios_base::failure& e) {
|
||||||
|
LOG_ERROR(Common_Filesystem, "{}", e.what());
|
||||||
|
if (!Common::FS::RemoveFile(filename)) {
|
||||||
|
LOG_ERROR(Common_Filesystem, "Failed to delete Vulkan driver pipeline cache file {}",
|
||||||
|
Common::FS::PathToUTF8String(filename));
|
||||||
|
}
|
||||||
|
|
||||||
|
return create_pipeline_cache(0, nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Vulkan
|
} // namespace Vulkan
|
||||||
|
|
|
@ -135,6 +135,12 @@ private:
|
||||||
PipelineStatistics* statistics,
|
PipelineStatistics* statistics,
|
||||||
bool build_in_parallel);
|
bool build_in_parallel);
|
||||||
|
|
||||||
|
void SerializeVulkanPipelineCache(const std::filesystem::path& filename,
|
||||||
|
const vk::PipelineCache& pipeline_cache, u32 cache_version);
|
||||||
|
|
||||||
|
vk::PipelineCache LoadVulkanPipelineCache(const std::filesystem::path& filename,
|
||||||
|
u32 expected_cache_version);
|
||||||
|
|
||||||
const Device& device;
|
const Device& device;
|
||||||
Scheduler& scheduler;
|
Scheduler& scheduler;
|
||||||
DescriptorPool& descriptor_pool;
|
DescriptorPool& descriptor_pool;
|
||||||
|
@ -144,6 +150,7 @@ private:
|
||||||
TextureCache& texture_cache;
|
TextureCache& texture_cache;
|
||||||
VideoCore::ShaderNotify& shader_notify;
|
VideoCore::ShaderNotify& shader_notify;
|
||||||
bool use_asynchronous_shaders{};
|
bool use_asynchronous_shaders{};
|
||||||
|
bool use_vulkan_pipeline_cache{};
|
||||||
|
|
||||||
GraphicsPipelineCacheKey graphics_key{};
|
GraphicsPipelineCacheKey graphics_key{};
|
||||||
GraphicsPipeline* current_pipeline{};
|
GraphicsPipeline* current_pipeline{};
|
||||||
|
@ -158,6 +165,9 @@ private:
|
||||||
|
|
||||||
std::filesystem::path pipeline_cache_filename;
|
std::filesystem::path pipeline_cache_filename;
|
||||||
|
|
||||||
|
std::filesystem::path vulkan_pipeline_cache_filename;
|
||||||
|
vk::PipelineCache vulkan_pipeline_cache;
|
||||||
|
|
||||||
Common::ThreadWorker workers;
|
Common::ThreadWorker workers;
|
||||||
Common::ThreadWorker serialization_thread;
|
Common::ThreadWorker serialization_thread;
|
||||||
DynamicFeatures dynamic_features;
|
DynamicFeatures dynamic_features;
|
||||||
|
|
205
src/video_core/renderer_vulkan/vk_turbo_mode.cpp
Executable file
205
src/video_core/renderer_vulkan/vk_turbo_mode.cpp
Executable file
|
@ -0,0 +1,205 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "common/literals.h"
|
||||||
|
#include "video_core/host_shaders/vulkan_turbo_mode_comp_spv.h"
|
||||||
|
#include "video_core/renderer_vulkan/renderer_vulkan.h"
|
||||||
|
#include "video_core/renderer_vulkan/vk_shader_util.h"
|
||||||
|
#include "video_core/renderer_vulkan/vk_turbo_mode.h"
|
||||||
|
#include "video_core/vulkan_common/vulkan_device.h"
|
||||||
|
|
||||||
|
namespace Vulkan {
|
||||||
|
|
||||||
|
using namespace Common::Literals;
|
||||||
|
|
||||||
|
TurboMode::TurboMode(const vk::Instance& instance, const vk::InstanceDispatch& dld)
|
||||||
|
: m_device{CreateDevice(instance, dld, VK_NULL_HANDLE)}, m_allocator{m_device, false} {
|
||||||
|
m_thread = std::jthread([&](auto stop_token) { Run(stop_token); });
|
||||||
|
}
|
||||||
|
|
||||||
|
TurboMode::~TurboMode() = default;
|
||||||
|
|
||||||
|
void TurboMode::Run(std::stop_token stop_token) {
|
||||||
|
auto& dld = m_device.GetLogical();
|
||||||
|
|
||||||
|
// Allocate buffer. 2MiB should be sufficient.
|
||||||
|
auto buffer = dld.CreateBuffer(VkBufferCreateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
.size = 2_MiB,
|
||||||
|
.usage = VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT,
|
||||||
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||||
|
.queueFamilyIndexCount = 0,
|
||||||
|
.pQueueFamilyIndices = nullptr,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Commit some device local memory for the buffer.
|
||||||
|
auto commit = m_allocator.Commit(buffer, MemoryUsage::DeviceLocal);
|
||||||
|
|
||||||
|
// Create the descriptor pool to contain our descriptor.
|
||||||
|
constexpr VkDescriptorPoolSize pool_size{
|
||||||
|
.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
auto descriptor_pool = dld.CreateDescriptorPool(VkDescriptorPoolCreateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT,
|
||||||
|
.maxSets = 1,
|
||||||
|
.poolSizeCount = 1,
|
||||||
|
.pPoolSizes = &pool_size,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the descriptor set layout from the pool.
|
||||||
|
constexpr VkDescriptorSetLayoutBinding layout_binding{
|
||||||
|
.binding = 0,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
.pImmutableSamplers = nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
auto descriptor_set_layout = dld.CreateDescriptorSetLayout(VkDescriptorSetLayoutCreateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
.bindingCount = 1,
|
||||||
|
.pBindings = &layout_binding,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Actually create the descriptor set.
|
||||||
|
auto descriptor_set = descriptor_pool.Allocate(VkDescriptorSetAllocateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.descriptorPool = *descriptor_pool,
|
||||||
|
.descriptorSetCount = 1,
|
||||||
|
.pSetLayouts = descriptor_set_layout.address(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create the shader.
|
||||||
|
auto shader = BuildShader(m_device, VULKAN_TURBO_MODE_COMP_SPV);
|
||||||
|
|
||||||
|
// Create the pipeline layout.
|
||||||
|
auto pipeline_layout = dld.CreatePipelineLayout(VkPipelineLayoutCreateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
.setLayoutCount = 1,
|
||||||
|
.pSetLayouts = descriptor_set_layout.address(),
|
||||||
|
.pushConstantRangeCount = 0,
|
||||||
|
.pPushConstantRanges = nullptr,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Actually create the pipeline.
|
||||||
|
const VkPipelineShaderStageCreateInfo shader_stage{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
.stage = VK_SHADER_STAGE_COMPUTE_BIT,
|
||||||
|
.module = *shader,
|
||||||
|
.pName = "main",
|
||||||
|
.pSpecializationInfo = nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
auto pipeline = dld.CreateComputePipeline(VkComputePipelineCreateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
.stage = shader_stage,
|
||||||
|
.layout = *pipeline_layout,
|
||||||
|
.basePipelineHandle = VK_NULL_HANDLE,
|
||||||
|
.basePipelineIndex = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a fence to wait on.
|
||||||
|
auto fence = dld.CreateFence(VkFenceCreateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a command pool to allocate a command buffer from.
|
||||||
|
auto command_pool = dld.CreateCommandPool(VkCommandPoolCreateInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags =
|
||||||
|
VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT,
|
||||||
|
.queueFamilyIndex = m_device.GetGraphicsFamily(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a single command buffer.
|
||||||
|
auto cmdbufs = command_pool.Allocate(1, VK_COMMAND_BUFFER_LEVEL_PRIMARY);
|
||||||
|
auto cmdbuf = vk::CommandBuffer{cmdbufs[0], m_device.GetDispatchLoader()};
|
||||||
|
|
||||||
|
while (!stop_token.stop_requested()) {
|
||||||
|
// Reset the fence.
|
||||||
|
fence.Reset();
|
||||||
|
|
||||||
|
// Update descriptor set.
|
||||||
|
const VkDescriptorBufferInfo buffer_info{
|
||||||
|
.buffer = *buffer,
|
||||||
|
.offset = 0,
|
||||||
|
.range = VK_WHOLE_SIZE,
|
||||||
|
};
|
||||||
|
|
||||||
|
const VkWriteDescriptorSet buffer_write{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.dstSet = descriptor_set[0],
|
||||||
|
.dstBinding = 0,
|
||||||
|
.dstArrayElement = 0,
|
||||||
|
.descriptorCount = 1,
|
||||||
|
.descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
|
.pImageInfo = nullptr,
|
||||||
|
.pBufferInfo = &buffer_info,
|
||||||
|
.pTexelBufferView = nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
dld.UpdateDescriptorSets(std::array{buffer_write}, {});
|
||||||
|
|
||||||
|
// Set up the command buffer.
|
||||||
|
cmdbuf.Begin(VkCommandBufferBeginInfo{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
|
||||||
|
.pInheritanceInfo = nullptr,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clear the buffer.
|
||||||
|
cmdbuf.FillBuffer(*buffer, 0, VK_WHOLE_SIZE, 0);
|
||||||
|
|
||||||
|
// Bind descriptor set.
|
||||||
|
cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline_layout, 0,
|
||||||
|
descriptor_set, {});
|
||||||
|
|
||||||
|
// Bind the pipeline.
|
||||||
|
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_COMPUTE, *pipeline);
|
||||||
|
|
||||||
|
// Dispatch.
|
||||||
|
cmdbuf.Dispatch(64, 64, 1);
|
||||||
|
|
||||||
|
// Finish.
|
||||||
|
cmdbuf.End();
|
||||||
|
|
||||||
|
const VkSubmitInfo submit_info{
|
||||||
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
||||||
|
.pNext = nullptr,
|
||||||
|
.waitSemaphoreCount = 0,
|
||||||
|
.pWaitSemaphores = nullptr,
|
||||||
|
.pWaitDstStageMask = nullptr,
|
||||||
|
.commandBufferCount = 1,
|
||||||
|
.pCommandBuffers = cmdbuf.address(),
|
||||||
|
.signalSemaphoreCount = 0,
|
||||||
|
.pSignalSemaphores = nullptr,
|
||||||
|
};
|
||||||
|
|
||||||
|
m_device.GetGraphicsQueue().Submit(std::array{submit_info}, *fence);
|
||||||
|
|
||||||
|
// Wait for completion.
|
||||||
|
fence.Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Vulkan
|
26
src/video_core/renderer_vulkan/vk_turbo_mode.h
Executable file
26
src/video_core/renderer_vulkan/vk_turbo_mode.h
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "common/polyfill_thread.h"
|
||||||
|
#include "video_core/vulkan_common/vulkan_device.h"
|
||||||
|
#include "video_core/vulkan_common/vulkan_memory_allocator.h"
|
||||||
|
#include "video_core/vulkan_common/vulkan_wrapper.h"
|
||||||
|
|
||||||
|
namespace Vulkan {
|
||||||
|
|
||||||
|
class TurboMode {
|
||||||
|
public:
|
||||||
|
explicit TurboMode(const vk::Instance& instance, const vk::InstanceDispatch& dld);
|
||||||
|
~TurboMode();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Run(std::stop_token stop_token);
|
||||||
|
|
||||||
|
Device m_device;
|
||||||
|
MemoryAllocator m_allocator;
|
||||||
|
std::jthread m_thread;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Vulkan
|
|
@ -1472,7 +1472,7 @@ std::vector<const char*> Device::LoadExtensions(bool requires_surface) {
|
||||||
is_patch_list_restart_supported =
|
is_patch_list_restart_supported =
|
||||||
primitive_topology_list_restart.primitiveTopologyPatchListRestart;
|
primitive_topology_list_restart.primitiveTopologyPatchListRestart;
|
||||||
}
|
}
|
||||||
if (has_khr_image_format_list && has_khr_swapchain_mutable_format) {
|
if (requires_surface && has_khr_image_format_list && has_khr_swapchain_mutable_format) {
|
||||||
extensions.push_back(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
|
extensions.push_back(VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME);
|
||||||
extensions.push_back(VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME);
|
extensions.push_back(VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME);
|
||||||
khr_swapchain_mutable_format = true;
|
khr_swapchain_mutable_format = true;
|
||||||
|
|
|
@ -152,6 +152,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
|
||||||
X(vkCreateGraphicsPipelines);
|
X(vkCreateGraphicsPipelines);
|
||||||
X(vkCreateImage);
|
X(vkCreateImage);
|
||||||
X(vkCreateImageView);
|
X(vkCreateImageView);
|
||||||
|
X(vkCreatePipelineCache);
|
||||||
X(vkCreatePipelineLayout);
|
X(vkCreatePipelineLayout);
|
||||||
X(vkCreateQueryPool);
|
X(vkCreateQueryPool);
|
||||||
X(vkCreateRenderPass);
|
X(vkCreateRenderPass);
|
||||||
|
@ -171,6 +172,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
|
||||||
X(vkDestroyImage);
|
X(vkDestroyImage);
|
||||||
X(vkDestroyImageView);
|
X(vkDestroyImageView);
|
||||||
X(vkDestroyPipeline);
|
X(vkDestroyPipeline);
|
||||||
|
X(vkDestroyPipelineCache);
|
||||||
X(vkDestroyPipelineLayout);
|
X(vkDestroyPipelineLayout);
|
||||||
X(vkDestroyQueryPool);
|
X(vkDestroyQueryPool);
|
||||||
X(vkDestroyRenderPass);
|
X(vkDestroyRenderPass);
|
||||||
|
@ -188,6 +190,7 @@ void Load(VkDevice device, DeviceDispatch& dld) noexcept {
|
||||||
X(vkGetEventStatus);
|
X(vkGetEventStatus);
|
||||||
X(vkGetFenceStatus);
|
X(vkGetFenceStatus);
|
||||||
X(vkGetImageMemoryRequirements);
|
X(vkGetImageMemoryRequirements);
|
||||||
|
X(vkGetPipelineCacheData);
|
||||||
X(vkGetMemoryFdKHR);
|
X(vkGetMemoryFdKHR);
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
X(vkGetMemoryWin32HandleKHR);
|
X(vkGetMemoryWin32HandleKHR);
|
||||||
|
@ -431,6 +434,10 @@ void Destroy(VkDevice device, VkPipeline handle, const DeviceDispatch& dld) noex
|
||||||
dld.vkDestroyPipeline(device, handle, nullptr);
|
dld.vkDestroyPipeline(device, handle, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Destroy(VkDevice device, VkPipelineCache handle, const DeviceDispatch& dld) noexcept {
|
||||||
|
dld.vkDestroyPipelineCache(device, handle, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
void Destroy(VkDevice device, VkPipelineLayout handle, const DeviceDispatch& dld) noexcept {
|
void Destroy(VkDevice device, VkPipelineLayout handle, const DeviceDispatch& dld) noexcept {
|
||||||
dld.vkDestroyPipelineLayout(device, handle, nullptr);
|
dld.vkDestroyPipelineLayout(device, handle, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -651,6 +658,10 @@ void ShaderModule::SetObjectNameEXT(const char* name) const {
|
||||||
SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_SHADER_MODULE, name);
|
SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_SHADER_MODULE, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PipelineCache::SetObjectNameEXT(const char* name) const {
|
||||||
|
SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_PIPELINE_CACHE, name);
|
||||||
|
}
|
||||||
|
|
||||||
void Semaphore::SetObjectNameEXT(const char* name) const {
|
void Semaphore::SetObjectNameEXT(const char* name) const {
|
||||||
SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_SEMAPHORE, name);
|
SetObjectName(dld, owner, handle, VK_OBJECT_TYPE_SEMAPHORE, name);
|
||||||
}
|
}
|
||||||
|
@ -746,21 +757,29 @@ DescriptorSetLayout Device::CreateDescriptorSetLayout(
|
||||||
return DescriptorSetLayout(object, handle, *dld);
|
return DescriptorSetLayout(object, handle, *dld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PipelineCache Device::CreatePipelineCache(const VkPipelineCacheCreateInfo& ci) const {
|
||||||
|
VkPipelineCache cache;
|
||||||
|
Check(dld->vkCreatePipelineCache(handle, &ci, nullptr, &cache));
|
||||||
|
return PipelineCache(cache, handle, *dld);
|
||||||
|
}
|
||||||
|
|
||||||
PipelineLayout Device::CreatePipelineLayout(const VkPipelineLayoutCreateInfo& ci) const {
|
PipelineLayout Device::CreatePipelineLayout(const VkPipelineLayoutCreateInfo& ci) const {
|
||||||
VkPipelineLayout object;
|
VkPipelineLayout object;
|
||||||
Check(dld->vkCreatePipelineLayout(handle, &ci, nullptr, &object));
|
Check(dld->vkCreatePipelineLayout(handle, &ci, nullptr, &object));
|
||||||
return PipelineLayout(object, handle, *dld);
|
return PipelineLayout(object, handle, *dld);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pipeline Device::CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo& ci) const {
|
Pipeline Device::CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo& ci,
|
||||||
|
VkPipelineCache cache) const {
|
||||||
VkPipeline object;
|
VkPipeline object;
|
||||||
Check(dld->vkCreateGraphicsPipelines(handle, nullptr, 1, &ci, nullptr, &object));
|
Check(dld->vkCreateGraphicsPipelines(handle, cache, 1, &ci, nullptr, &object));
|
||||||
return Pipeline(object, handle, *dld);
|
return Pipeline(object, handle, *dld);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pipeline Device::CreateComputePipeline(const VkComputePipelineCreateInfo& ci) const {
|
Pipeline Device::CreateComputePipeline(const VkComputePipelineCreateInfo& ci,
|
||||||
|
VkPipelineCache cache) const {
|
||||||
VkPipeline object;
|
VkPipeline object;
|
||||||
Check(dld->vkCreateComputePipelines(handle, nullptr, 1, &ci, nullptr, &object));
|
Check(dld->vkCreateComputePipelines(handle, cache, 1, &ci, nullptr, &object));
|
||||||
return Pipeline(object, handle, *dld);
|
return Pipeline(object, handle, *dld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -270,6 +270,7 @@ struct DeviceDispatch : InstanceDispatch {
|
||||||
PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines{};
|
PFN_vkCreateGraphicsPipelines vkCreateGraphicsPipelines{};
|
||||||
PFN_vkCreateImage vkCreateImage{};
|
PFN_vkCreateImage vkCreateImage{};
|
||||||
PFN_vkCreateImageView vkCreateImageView{};
|
PFN_vkCreateImageView vkCreateImageView{};
|
||||||
|
PFN_vkCreatePipelineCache vkCreatePipelineCache{};
|
||||||
PFN_vkCreatePipelineLayout vkCreatePipelineLayout{};
|
PFN_vkCreatePipelineLayout vkCreatePipelineLayout{};
|
||||||
PFN_vkCreateQueryPool vkCreateQueryPool{};
|
PFN_vkCreateQueryPool vkCreateQueryPool{};
|
||||||
PFN_vkCreateRenderPass vkCreateRenderPass{};
|
PFN_vkCreateRenderPass vkCreateRenderPass{};
|
||||||
|
@ -289,6 +290,7 @@ struct DeviceDispatch : InstanceDispatch {
|
||||||
PFN_vkDestroyImage vkDestroyImage{};
|
PFN_vkDestroyImage vkDestroyImage{};
|
||||||
PFN_vkDestroyImageView vkDestroyImageView{};
|
PFN_vkDestroyImageView vkDestroyImageView{};
|
||||||
PFN_vkDestroyPipeline vkDestroyPipeline{};
|
PFN_vkDestroyPipeline vkDestroyPipeline{};
|
||||||
|
PFN_vkDestroyPipelineCache vkDestroyPipelineCache{};
|
||||||
PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout{};
|
PFN_vkDestroyPipelineLayout vkDestroyPipelineLayout{};
|
||||||
PFN_vkDestroyQueryPool vkDestroyQueryPool{};
|
PFN_vkDestroyQueryPool vkDestroyQueryPool{};
|
||||||
PFN_vkDestroyRenderPass vkDestroyRenderPass{};
|
PFN_vkDestroyRenderPass vkDestroyRenderPass{};
|
||||||
|
@ -306,6 +308,7 @@ struct DeviceDispatch : InstanceDispatch {
|
||||||
PFN_vkGetEventStatus vkGetEventStatus{};
|
PFN_vkGetEventStatus vkGetEventStatus{};
|
||||||
PFN_vkGetFenceStatus vkGetFenceStatus{};
|
PFN_vkGetFenceStatus vkGetFenceStatus{};
|
||||||
PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements{};
|
PFN_vkGetImageMemoryRequirements vkGetImageMemoryRequirements{};
|
||||||
|
PFN_vkGetPipelineCacheData vkGetPipelineCacheData{};
|
||||||
PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR{};
|
PFN_vkGetMemoryFdKHR vkGetMemoryFdKHR{};
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR{};
|
PFN_vkGetMemoryWin32HandleKHR vkGetMemoryWin32HandleKHR{};
|
||||||
|
@ -351,6 +354,7 @@ void Destroy(VkDevice, VkFramebuffer, const DeviceDispatch&) noexcept;
|
||||||
void Destroy(VkDevice, VkImage, const DeviceDispatch&) noexcept;
|
void Destroy(VkDevice, VkImage, const DeviceDispatch&) noexcept;
|
||||||
void Destroy(VkDevice, VkImageView, const DeviceDispatch&) noexcept;
|
void Destroy(VkDevice, VkImageView, const DeviceDispatch&) noexcept;
|
||||||
void Destroy(VkDevice, VkPipeline, const DeviceDispatch&) noexcept;
|
void Destroy(VkDevice, VkPipeline, const DeviceDispatch&) noexcept;
|
||||||
|
void Destroy(VkDevice, VkPipelineCache, const DeviceDispatch&) noexcept;
|
||||||
void Destroy(VkDevice, VkPipelineLayout, const DeviceDispatch&) noexcept;
|
void Destroy(VkDevice, VkPipelineLayout, const DeviceDispatch&) noexcept;
|
||||||
void Destroy(VkDevice, VkQueryPool, const DeviceDispatch&) noexcept;
|
void Destroy(VkDevice, VkQueryPool, const DeviceDispatch&) noexcept;
|
||||||
void Destroy(VkDevice, VkRenderPass, const DeviceDispatch&) noexcept;
|
void Destroy(VkDevice, VkRenderPass, const DeviceDispatch&) noexcept;
|
||||||
|
@ -773,6 +777,18 @@ public:
|
||||||
void SetObjectNameEXT(const char* name) const;
|
void SetObjectNameEXT(const char* name) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class PipelineCache : public Handle<VkPipelineCache, VkDevice, DeviceDispatch> {
|
||||||
|
using Handle<VkPipelineCache, VkDevice, DeviceDispatch>::Handle;
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Set object name.
|
||||||
|
void SetObjectNameEXT(const char* name) const;
|
||||||
|
|
||||||
|
VkResult Read(size_t* size, void* data) const noexcept {
|
||||||
|
return dld->vkGetPipelineCacheData(owner, handle, size, data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class Semaphore : public Handle<VkSemaphore, VkDevice, DeviceDispatch> {
|
class Semaphore : public Handle<VkSemaphore, VkDevice, DeviceDispatch> {
|
||||||
using Handle<VkSemaphore, VkDevice, DeviceDispatch>::Handle;
|
using Handle<VkSemaphore, VkDevice, DeviceDispatch>::Handle;
|
||||||
|
|
||||||
|
@ -844,11 +860,15 @@ public:
|
||||||
|
|
||||||
DescriptorSetLayout CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo& ci) const;
|
DescriptorSetLayout CreateDescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo& ci) const;
|
||||||
|
|
||||||
|
PipelineCache CreatePipelineCache(const VkPipelineCacheCreateInfo& ci) const;
|
||||||
|
|
||||||
PipelineLayout CreatePipelineLayout(const VkPipelineLayoutCreateInfo& ci) const;
|
PipelineLayout CreatePipelineLayout(const VkPipelineLayoutCreateInfo& ci) const;
|
||||||
|
|
||||||
Pipeline CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo& ci) const;
|
Pipeline CreateGraphicsPipeline(const VkGraphicsPipelineCreateInfo& ci,
|
||||||
|
VkPipelineCache cache = nullptr) const;
|
||||||
|
|
||||||
Pipeline CreateComputePipeline(const VkComputePipelineCreateInfo& ci) const;
|
Pipeline CreateComputePipeline(const VkComputePipelineCreateInfo& ci,
|
||||||
|
VkPipelineCache cache = nullptr) const;
|
||||||
|
|
||||||
Sampler CreateSampler(const VkSamplerCreateInfo& ci) const;
|
Sampler CreateSampler(const VkSamplerCreateInfo& ci) const;
|
||||||
|
|
||||||
|
|
|
@ -691,6 +691,7 @@ void Config::ReadRendererValues() {
|
||||||
qt_config->beginGroup(QStringLiteral("Renderer"));
|
qt_config->beginGroup(QStringLiteral("Renderer"));
|
||||||
|
|
||||||
ReadGlobalSetting(Settings::values.renderer_backend);
|
ReadGlobalSetting(Settings::values.renderer_backend);
|
||||||
|
ReadGlobalSetting(Settings::values.renderer_force_max_clock);
|
||||||
ReadGlobalSetting(Settings::values.vulkan_device);
|
ReadGlobalSetting(Settings::values.vulkan_device);
|
||||||
ReadGlobalSetting(Settings::values.fullscreen_mode);
|
ReadGlobalSetting(Settings::values.fullscreen_mode);
|
||||||
ReadGlobalSetting(Settings::values.aspect_ratio);
|
ReadGlobalSetting(Settings::values.aspect_ratio);
|
||||||
|
@ -710,6 +711,7 @@ void Config::ReadRendererValues() {
|
||||||
ReadGlobalSetting(Settings::values.use_asynchronous_shaders);
|
ReadGlobalSetting(Settings::values.use_asynchronous_shaders);
|
||||||
ReadGlobalSetting(Settings::values.use_fast_gpu_time);
|
ReadGlobalSetting(Settings::values.use_fast_gpu_time);
|
||||||
ReadGlobalSetting(Settings::values.use_pessimistic_flushes);
|
ReadGlobalSetting(Settings::values.use_pessimistic_flushes);
|
||||||
|
ReadGlobalSetting(Settings::values.use_vulkan_driver_pipeline_cache);
|
||||||
ReadGlobalSetting(Settings::values.bg_red);
|
ReadGlobalSetting(Settings::values.bg_red);
|
||||||
ReadGlobalSetting(Settings::values.bg_green);
|
ReadGlobalSetting(Settings::values.bg_green);
|
||||||
ReadGlobalSetting(Settings::values.bg_blue);
|
ReadGlobalSetting(Settings::values.bg_blue);
|
||||||
|
@ -1307,6 +1309,9 @@ void Config::SaveRendererValues() {
|
||||||
static_cast<u32>(Settings::values.renderer_backend.GetValue(global)),
|
static_cast<u32>(Settings::values.renderer_backend.GetValue(global)),
|
||||||
static_cast<u32>(Settings::values.renderer_backend.GetDefault()),
|
static_cast<u32>(Settings::values.renderer_backend.GetDefault()),
|
||||||
Settings::values.renderer_backend.UsingGlobal());
|
Settings::values.renderer_backend.UsingGlobal());
|
||||||
|
WriteSetting(QString::fromStdString(Settings::values.renderer_force_max_clock.GetLabel()),
|
||||||
|
static_cast<u32>(Settings::values.renderer_force_max_clock.GetValue(global)),
|
||||||
|
static_cast<u32>(Settings::values.renderer_force_max_clock.GetDefault()));
|
||||||
WriteGlobalSetting(Settings::values.vulkan_device);
|
WriteGlobalSetting(Settings::values.vulkan_device);
|
||||||
WriteSetting(QString::fromStdString(Settings::values.fullscreen_mode.GetLabel()),
|
WriteSetting(QString::fromStdString(Settings::values.fullscreen_mode.GetLabel()),
|
||||||
static_cast<u32>(Settings::values.fullscreen_mode.GetValue(global)),
|
static_cast<u32>(Settings::values.fullscreen_mode.GetValue(global)),
|
||||||
|
@ -1350,6 +1355,7 @@ void Config::SaveRendererValues() {
|
||||||
WriteGlobalSetting(Settings::values.use_asynchronous_shaders);
|
WriteGlobalSetting(Settings::values.use_asynchronous_shaders);
|
||||||
WriteGlobalSetting(Settings::values.use_fast_gpu_time);
|
WriteGlobalSetting(Settings::values.use_fast_gpu_time);
|
||||||
WriteGlobalSetting(Settings::values.use_pessimistic_flushes);
|
WriteGlobalSetting(Settings::values.use_pessimistic_flushes);
|
||||||
|
WriteGlobalSetting(Settings::values.use_vulkan_driver_pipeline_cache);
|
||||||
WriteGlobalSetting(Settings::values.bg_red);
|
WriteGlobalSetting(Settings::values.bg_red);
|
||||||
WriteGlobalSetting(Settings::values.bg_green);
|
WriteGlobalSetting(Settings::values.bg_green);
|
||||||
WriteGlobalSetting(Settings::values.bg_blue);
|
WriteGlobalSetting(Settings::values.bg_blue);
|
||||||
|
|
|
@ -25,10 +25,13 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||||
ui->use_asynchronous_shaders->setEnabled(runtime_lock);
|
ui->use_asynchronous_shaders->setEnabled(runtime_lock);
|
||||||
ui->anisotropic_filtering_combobox->setEnabled(runtime_lock);
|
ui->anisotropic_filtering_combobox->setEnabled(runtime_lock);
|
||||||
|
|
||||||
|
ui->renderer_force_max_clock->setChecked(Settings::values.renderer_force_max_clock.GetValue());
|
||||||
ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue());
|
ui->use_vsync->setChecked(Settings::values.use_vsync.GetValue());
|
||||||
ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue());
|
ui->use_asynchronous_shaders->setChecked(Settings::values.use_asynchronous_shaders.GetValue());
|
||||||
ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue());
|
ui->use_fast_gpu_time->setChecked(Settings::values.use_fast_gpu_time.GetValue());
|
||||||
ui->use_pessimistic_flushes->setChecked(Settings::values.use_pessimistic_flushes.GetValue());
|
ui->use_pessimistic_flushes->setChecked(Settings::values.use_pessimistic_flushes.GetValue());
|
||||||
|
ui->use_vulkan_driver_pipeline_cache->setChecked(
|
||||||
|
Settings::values.use_vulkan_driver_pipeline_cache.GetValue());
|
||||||
|
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
ui->gpu_accuracy->setCurrentIndex(
|
ui->gpu_accuracy->setCurrentIndex(
|
||||||
|
@ -37,6 +40,8 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||||
Settings::values.max_anisotropy.GetValue());
|
Settings::values.max_anisotropy.GetValue());
|
||||||
} else {
|
} else {
|
||||||
ConfigurationShared::SetPerGameSetting(ui->gpu_accuracy, &Settings::values.gpu_accuracy);
|
ConfigurationShared::SetPerGameSetting(ui->gpu_accuracy, &Settings::values.gpu_accuracy);
|
||||||
|
ConfigurationShared::SetPerGameSetting(ui->renderer_force_max_clock,
|
||||||
|
&Settings::values.renderer_force_max_clock);
|
||||||
ConfigurationShared::SetPerGameSetting(ui->anisotropic_filtering_combobox,
|
ConfigurationShared::SetPerGameSetting(ui->anisotropic_filtering_combobox,
|
||||||
&Settings::values.max_anisotropy);
|
&Settings::values.max_anisotropy);
|
||||||
ConfigurationShared::SetHighlight(ui->label_gpu_accuracy,
|
ConfigurationShared::SetHighlight(ui->label_gpu_accuracy,
|
||||||
|
@ -48,6 +53,9 @@ void ConfigureGraphicsAdvanced::SetConfiguration() {
|
||||||
|
|
||||||
void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.gpu_accuracy, ui->gpu_accuracy);
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.gpu_accuracy, ui->gpu_accuracy);
|
||||||
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.renderer_force_max_clock,
|
||||||
|
ui->renderer_force_max_clock,
|
||||||
|
renderer_force_max_clock);
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.max_anisotropy,
|
||||||
ui->anisotropic_filtering_combobox);
|
ui->anisotropic_filtering_combobox);
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync);
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vsync, ui->use_vsync, use_vsync);
|
||||||
|
@ -58,6 +66,9 @@ void ConfigureGraphicsAdvanced::ApplyConfiguration() {
|
||||||
ui->use_fast_gpu_time, use_fast_gpu_time);
|
ui->use_fast_gpu_time, use_fast_gpu_time);
|
||||||
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_pessimistic_flushes,
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_pessimistic_flushes,
|
||||||
ui->use_pessimistic_flushes, use_pessimistic_flushes);
|
ui->use_pessimistic_flushes, use_pessimistic_flushes);
|
||||||
|
ConfigurationShared::ApplyPerGameSetting(&Settings::values.use_vulkan_driver_pipeline_cache,
|
||||||
|
ui->use_vulkan_driver_pipeline_cache,
|
||||||
|
use_vulkan_driver_pipeline_cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) {
|
void ConfigureGraphicsAdvanced::changeEvent(QEvent* event) {
|
||||||
|
@ -76,18 +87,25 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||||
// Disable if not global (only happens during game)
|
// Disable if not global (only happens during game)
|
||||||
if (Settings::IsConfiguringGlobal()) {
|
if (Settings::IsConfiguringGlobal()) {
|
||||||
ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal());
|
ui->gpu_accuracy->setEnabled(Settings::values.gpu_accuracy.UsingGlobal());
|
||||||
|
ui->renderer_force_max_clock->setEnabled(
|
||||||
|
Settings::values.renderer_force_max_clock.UsingGlobal());
|
||||||
ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal());
|
ui->use_vsync->setEnabled(Settings::values.use_vsync.UsingGlobal());
|
||||||
ui->use_asynchronous_shaders->setEnabled(
|
ui->use_asynchronous_shaders->setEnabled(
|
||||||
Settings::values.use_asynchronous_shaders.UsingGlobal());
|
Settings::values.use_asynchronous_shaders.UsingGlobal());
|
||||||
ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal());
|
ui->use_fast_gpu_time->setEnabled(Settings::values.use_fast_gpu_time.UsingGlobal());
|
||||||
ui->use_pessimistic_flushes->setEnabled(
|
ui->use_pessimistic_flushes->setEnabled(
|
||||||
Settings::values.use_pessimistic_flushes.UsingGlobal());
|
Settings::values.use_pessimistic_flushes.UsingGlobal());
|
||||||
|
ui->use_vulkan_driver_pipeline_cache->setEnabled(
|
||||||
|
Settings::values.use_vulkan_driver_pipeline_cache.UsingGlobal());
|
||||||
ui->anisotropic_filtering_combobox->setEnabled(
|
ui->anisotropic_filtering_combobox->setEnabled(
|
||||||
Settings::values.max_anisotropy.UsingGlobal());
|
Settings::values.max_anisotropy.UsingGlobal());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfigurationShared::SetColoredTristate(ui->renderer_force_max_clock,
|
||||||
|
Settings::values.renderer_force_max_clock,
|
||||||
|
renderer_force_max_clock);
|
||||||
ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync);
|
ConfigurationShared::SetColoredTristate(ui->use_vsync, Settings::values.use_vsync, use_vsync);
|
||||||
ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders,
|
ConfigurationShared::SetColoredTristate(ui->use_asynchronous_shaders,
|
||||||
Settings::values.use_asynchronous_shaders,
|
Settings::values.use_asynchronous_shaders,
|
||||||
|
@ -97,6 +115,9 @@ void ConfigureGraphicsAdvanced::SetupPerGameUI() {
|
||||||
ConfigurationShared::SetColoredTristate(ui->use_pessimistic_flushes,
|
ConfigurationShared::SetColoredTristate(ui->use_pessimistic_flushes,
|
||||||
Settings::values.use_pessimistic_flushes,
|
Settings::values.use_pessimistic_flushes,
|
||||||
use_pessimistic_flushes);
|
use_pessimistic_flushes);
|
||||||
|
ConfigurationShared::SetColoredTristate(ui->use_vulkan_driver_pipeline_cache,
|
||||||
|
Settings::values.use_vulkan_driver_pipeline_cache,
|
||||||
|
use_vulkan_driver_pipeline_cache);
|
||||||
ConfigurationShared::SetColoredComboBox(
|
ConfigurationShared::SetColoredComboBox(
|
||||||
ui->gpu_accuracy, ui->label_gpu_accuracy,
|
ui->gpu_accuracy, ui->label_gpu_accuracy,
|
||||||
static_cast<int>(Settings::values.gpu_accuracy.GetValue(true)));
|
static_cast<int>(Settings::values.gpu_accuracy.GetValue(true)));
|
||||||
|
|
|
@ -36,10 +36,12 @@ private:
|
||||||
|
|
||||||
std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui;
|
std::unique_ptr<Ui::ConfigureGraphicsAdvanced> ui;
|
||||||
|
|
||||||
|
ConfigurationShared::CheckState renderer_force_max_clock;
|
||||||
ConfigurationShared::CheckState use_vsync;
|
ConfigurationShared::CheckState use_vsync;
|
||||||
ConfigurationShared::CheckState use_asynchronous_shaders;
|
ConfigurationShared::CheckState use_asynchronous_shaders;
|
||||||
ConfigurationShared::CheckState use_fast_gpu_time;
|
ConfigurationShared::CheckState use_fast_gpu_time;
|
||||||
ConfigurationShared::CheckState use_pessimistic_flushes;
|
ConfigurationShared::CheckState use_pessimistic_flushes;
|
||||||
|
ConfigurationShared::CheckState use_vulkan_driver_pipeline_cache;
|
||||||
|
|
||||||
const Core::System& system;
|
const Core::System& system;
|
||||||
};
|
};
|
||||||
|
|
|
@ -69,6 +69,16 @@
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="renderer_force_max_clock">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Runs work in the background while waiting for graphics commands to keep the GPU from lowering its clock speed.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Force maximum clocks (Vulkan only)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="use_vsync">
|
<widget class="QCheckBox" name="use_vsync">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
|
@ -109,6 +119,16 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="use_vulkan_driver_pipeline_cache">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Enables GPU vendor-specific pipeline cache. This option can improve shader loading time significantly in cases where the Vulkan driver does not store pipeline cache files internally.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use Vulkan pipeline cache</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="af_layout" native="true">
|
<widget class="QWidget" name="af_layout" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_1">
|
<layout class="QHBoxLayout" name="horizontalLayout_1">
|
||||||
|
|
|
@ -2228,8 +2228,10 @@ void GMainWindow::OnGameListRemoveFile(u64 program_id, GameListRemoveTarget targ
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (target) {
|
switch (target) {
|
||||||
case GameListRemoveTarget::GlShaderCache:
|
|
||||||
case GameListRemoveTarget::VkShaderCache:
|
case GameListRemoveTarget::VkShaderCache:
|
||||||
|
RemoveVulkanDriverPipelineCache(program_id);
|
||||||
|
[[fallthrough]];
|
||||||
|
case GameListRemoveTarget::GlShaderCache:
|
||||||
RemoveTransferableShaderCache(program_id, target);
|
RemoveTransferableShaderCache(program_id, target);
|
||||||
break;
|
break;
|
||||||
case GameListRemoveTarget::AllShaderCache:
|
case GameListRemoveTarget::AllShaderCache:
|
||||||
|
@ -2270,6 +2272,22 @@ void GMainWindow::RemoveTransferableShaderCache(u64 program_id, GameListRemoveTa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GMainWindow::RemoveVulkanDriverPipelineCache(u64 program_id) {
|
||||||
|
static constexpr std::string_view target_file_name = "vulkan_pipelines.bin";
|
||||||
|
|
||||||
|
const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir);
|
||||||
|
const auto shader_cache_folder_path = shader_cache_dir / fmt::format("{:016x}", program_id);
|
||||||
|
const auto target_file = shader_cache_folder_path / target_file_name;
|
||||||
|
|
||||||
|
if (!Common::FS::Exists(target_file)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!Common::FS::RemoveFile(target_file)) {
|
||||||
|
QMessageBox::warning(this, tr("Error Removing Vulkan Driver Pipeline Cache"),
|
||||||
|
tr("Failed to remove the driver pipeline cache."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GMainWindow::RemoveAllTransferableShaderCaches(u64 program_id) {
|
void GMainWindow::RemoveAllTransferableShaderCaches(u64 program_id) {
|
||||||
const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir);
|
const auto shader_cache_dir = Common::FS::GetYuzuPath(Common::FS::YuzuPath::ShaderDir);
|
||||||
const auto program_shader_cache_dir = shader_cache_dir / fmt::format("{:016x}", program_id);
|
const auto program_shader_cache_dir = shader_cache_dir / fmt::format("{:016x}", program_id);
|
||||||
|
|
|
@ -347,6 +347,7 @@ private:
|
||||||
void RemoveUpdateContent(u64 program_id, InstalledEntryType type);
|
void RemoveUpdateContent(u64 program_id, InstalledEntryType type);
|
||||||
void RemoveAddOnContent(u64 program_id, InstalledEntryType type);
|
void RemoveAddOnContent(u64 program_id, InstalledEntryType type);
|
||||||
void RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target);
|
void RemoveTransferableShaderCache(u64 program_id, GameListRemoveTarget target);
|
||||||
|
void RemoveVulkanDriverPipelineCache(u64 program_id);
|
||||||
void RemoveAllTransferableShaderCaches(u64 program_id);
|
void RemoveAllTransferableShaderCaches(u64 program_id);
|
||||||
void RemoveCustomConfiguration(u64 program_id, const std::string& game_path);
|
void RemoveCustomConfiguration(u64 program_id, const std::string& game_path);
|
||||||
std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
|
std::optional<u64> SelectRomFSDumpTarget(const FileSys::ContentProvider&, u64 program_id);
|
||||||
|
|
|
@ -296,6 +296,7 @@ void Config::ReadValues() {
|
||||||
|
|
||||||
// Renderer
|
// Renderer
|
||||||
ReadSetting("Renderer", Settings::values.renderer_backend);
|
ReadSetting("Renderer", Settings::values.renderer_backend);
|
||||||
|
ReadSetting("Renderer", Settings::values.renderer_force_max_clock);
|
||||||
ReadSetting("Renderer", Settings::values.renderer_debug);
|
ReadSetting("Renderer", Settings::values.renderer_debug);
|
||||||
ReadSetting("Renderer", Settings::values.renderer_shader_feedback);
|
ReadSetting("Renderer", Settings::values.renderer_shader_feedback);
|
||||||
ReadSetting("Renderer", Settings::values.enable_nsight_aftermath);
|
ReadSetting("Renderer", Settings::values.enable_nsight_aftermath);
|
||||||
|
@ -321,6 +322,7 @@ void Config::ReadValues() {
|
||||||
ReadSetting("Renderer", Settings::values.accelerate_astc);
|
ReadSetting("Renderer", Settings::values.accelerate_astc);
|
||||||
ReadSetting("Renderer", Settings::values.use_fast_gpu_time);
|
ReadSetting("Renderer", Settings::values.use_fast_gpu_time);
|
||||||
ReadSetting("Renderer", Settings::values.use_pessimistic_flushes);
|
ReadSetting("Renderer", Settings::values.use_pessimistic_flushes);
|
||||||
|
ReadSetting("Renderer", Settings::values.use_vulkan_driver_pipeline_cache);
|
||||||
|
|
||||||
ReadSetting("Renderer", Settings::values.bg_red);
|
ReadSetting("Renderer", Settings::values.bg_red);
|
||||||
ReadSetting("Renderer", Settings::values.bg_green);
|
ReadSetting("Renderer", Settings::values.bg_green);
|
||||||
|
|
Loading…
Reference in a new issue