diff options
30 files changed, 201 insertions, 35 deletions
diff --git a/src/common/string_util.cpp b/src/common/string_util.cpp index feab1653d..4c7aba3f5 100644 --- a/src/common/string_util.cpp +++ b/src/common/string_util.cpp | |||
| @@ -135,6 +135,11 @@ std::u16string UTF8ToUTF16(std::string_view input) { | |||
| 135 | return convert.from_bytes(input.data(), input.data() + input.size()); | 135 | return convert.from_bytes(input.data(), input.data() + input.size()); |
| 136 | } | 136 | } |
| 137 | 137 | ||
| 138 | std::u32string UTF8ToUTF32(std::string_view input) { | ||
| 139 | std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> convert; | ||
| 140 | return convert.from_bytes(input.data(), input.data() + input.size()); | ||
| 141 | } | ||
| 142 | |||
| 138 | #ifdef _WIN32 | 143 | #ifdef _WIN32 |
| 139 | static std::wstring CPToUTF16(u32 code_page, std::string_view input) { | 144 | static std::wstring CPToUTF16(u32 code_page, std::string_view input) { |
| 140 | const auto size = | 145 | const auto size = |
diff --git a/src/common/string_util.h b/src/common/string_util.h index c351f1a0c..9da1ca4e9 100644 --- a/src/common/string_util.h +++ b/src/common/string_util.h | |||
| @@ -38,6 +38,7 @@ bool SplitPath(const std::string& full_path, std::string* _pPath, std::string* _ | |||
| 38 | 38 | ||
| 39 | [[nodiscard]] std::string UTF16ToUTF8(std::u16string_view input); | 39 | [[nodiscard]] std::string UTF16ToUTF8(std::u16string_view input); |
| 40 | [[nodiscard]] std::u16string UTF8ToUTF16(std::string_view input); | 40 | [[nodiscard]] std::u16string UTF8ToUTF16(std::string_view input); |
| 41 | [[nodiscard]] std::u32string UTF8ToUTF32(std::string_view input); | ||
| 41 | 42 | ||
| 42 | #ifdef _WIN32 | 43 | #ifdef _WIN32 |
| 43 | [[nodiscard]] std::string UTF16ToUTF8(std::wstring_view input); | 44 | [[nodiscard]] std::string UTF16ToUTF8(std::wstring_view input); |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 08cbb8978..0ab2e3b76 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -1078,6 +1078,10 @@ void System::ApplySettings() { | |||
| 1078 | impl->RefreshTime(); | 1078 | impl->RefreshTime(); |
| 1079 | 1079 | ||
| 1080 | if (IsPoweredOn()) { | 1080 | if (IsPoweredOn()) { |
| 1081 | if (Settings::values.custom_rtc_enabled) { | ||
| 1082 | const s64 posix_time{Settings::values.custom_rtc.GetValue()}; | ||
| 1083 | GetTimeManager().UpdateLocalSystemClockTime(posix_time); | ||
| 1084 | } | ||
| 1081 | Renderer().RefreshBaseSettings(); | 1085 | Renderer().RefreshBaseSettings(); |
| 1082 | } | 1086 | } |
| 1083 | } | 1087 | } |
diff --git a/src/core/debugger/gdbstub.cpp b/src/core/debugger/gdbstub.cpp index e55831f27..82964f0a1 100644 --- a/src/core/debugger/gdbstub.cpp +++ b/src/core/debugger/gdbstub.cpp | |||
| @@ -2,6 +2,8 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <atomic> | 4 | #include <atomic> |
| 5 | #include <codecvt> | ||
| 6 | #include <locale> | ||
| 5 | #include <numeric> | 7 | #include <numeric> |
| 6 | #include <optional> | 8 | #include <optional> |
| 7 | #include <thread> | 9 | #include <thread> |
| @@ -12,6 +14,7 @@ | |||
| 12 | #include "common/logging/log.h" | 14 | #include "common/logging/log.h" |
| 13 | #include "common/scope_exit.h" | 15 | #include "common/scope_exit.h" |
| 14 | #include "common/settings.h" | 16 | #include "common/settings.h" |
| 17 | #include "common/string_util.h" | ||
| 15 | #include "core/arm/arm_interface.h" | 18 | #include "core/arm/arm_interface.h" |
| 16 | #include "core/core.h" | 19 | #include "core/core.h" |
| 17 | #include "core/debugger/gdbstub.h" | 20 | #include "core/debugger/gdbstub.h" |
| @@ -68,10 +71,16 @@ static std::string EscapeGDB(std::string_view data) { | |||
| 68 | } | 71 | } |
| 69 | 72 | ||
| 70 | static std::string EscapeXML(std::string_view data) { | 73 | static std::string EscapeXML(std::string_view data) { |
| 74 | std::u32string converted = U"[Encoding error]"; | ||
| 75 | try { | ||
| 76 | converted = Common::UTF8ToUTF32(data); | ||
| 77 | } catch (std::range_error&) { | ||
| 78 | } | ||
| 79 | |||
| 71 | std::string escaped; | 80 | std::string escaped; |
| 72 | escaped.reserve(data.size()); | 81 | escaped.reserve(data.size()); |
| 73 | 82 | ||
| 74 | for (char c : data) { | 83 | for (char32_t c : converted) { |
| 75 | switch (c) { | 84 | switch (c) { |
| 76 | case '&': | 85 | case '&': |
| 77 | escaped += "&"; | 86 | escaped += "&"; |
| @@ -86,7 +95,11 @@ static std::string EscapeXML(std::string_view data) { | |||
| 86 | escaped += ">"; | 95 | escaped += ">"; |
| 87 | break; | 96 | break; |
| 88 | default: | 97 | default: |
| 89 | escaped += c; | 98 | if (c > 0x7f) { |
| 99 | escaped += fmt::format("&#{};", static_cast<u32>(c)); | ||
| 100 | } else { | ||
| 101 | escaped += static_cast<char>(c); | ||
| 102 | } | ||
| 90 | break; | 103 | break; |
| 91 | } | 104 | } |
| 92 | } | 105 | } |
diff --git a/src/core/file_sys/program_metadata.cpp b/src/core/file_sys/program_metadata.cpp index f00479bd3..8e291ff67 100644 --- a/src/core/file_sys/program_metadata.cpp +++ b/src/core/file_sys/program_metadata.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <vector> | 5 | #include <vector> |
| 6 | 6 | ||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "common/scope_exit.h" | ||
| 8 | #include "core/file_sys/program_metadata.h" | 9 | #include "core/file_sys/program_metadata.h" |
| 9 | #include "core/file_sys/vfs.h" | 10 | #include "core/file_sys/vfs.h" |
| 10 | #include "core/loader/loader.h" | 11 | #include "core/loader/loader.h" |
| @@ -95,6 +96,13 @@ Loader::ResultStatus ProgramMetadata::Load(VirtualFile file) { | |||
| 95 | return Loader::ResultStatus::Success; | 96 | return Loader::ResultStatus::Success; |
| 96 | } | 97 | } |
| 97 | 98 | ||
| 99 | Loader::ResultStatus ProgramMetadata::Reload(VirtualFile file) { | ||
| 100 | const u64 original_program_id = aci_header.title_id; | ||
| 101 | SCOPE_EXIT({ aci_header.title_id = original_program_id; }); | ||
| 102 | |||
| 103 | return this->Load(file); | ||
| 104 | } | ||
| 105 | |||
| 98 | /*static*/ ProgramMetadata ProgramMetadata::GetDefault() { | 106 | /*static*/ ProgramMetadata ProgramMetadata::GetDefault() { |
| 99 | // Allow use of cores 0~3 and thread priorities 1~63. | 107 | // Allow use of cores 0~3 and thread priorities 1~63. |
| 100 | constexpr u32 default_thread_info_capability = 0x30007F7; | 108 | constexpr u32 default_thread_info_capability = 0x30007F7; |
diff --git a/src/core/file_sys/program_metadata.h b/src/core/file_sys/program_metadata.h index 2e8960b07..9f8e74b13 100644 --- a/src/core/file_sys/program_metadata.h +++ b/src/core/file_sys/program_metadata.h | |||
| @@ -56,6 +56,7 @@ public: | |||
| 56 | static ProgramMetadata GetDefault(); | 56 | static ProgramMetadata GetDefault(); |
| 57 | 57 | ||
| 58 | Loader::ResultStatus Load(VirtualFile file); | 58 | Loader::ResultStatus Load(VirtualFile file); |
| 59 | Loader::ResultStatus Reload(VirtualFile file); | ||
| 59 | 60 | ||
| 60 | /// Load from parameters instead of NPDM file, used for KIP | 61 | /// Load from parameters instead of NPDM file, used for KIP |
| 61 | void LoadManual(bool is_64_bit, ProgramAddressSpaceType address_space, s32 main_thread_prio, | 62 | void LoadManual(bool is_64_bit, ProgramAddressSpaceType address_space, s32 main_thread_prio, |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 5a42dea48..5c36b71e5 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -118,7 +118,7 @@ AppLoader_DeconstructedRomDirectory::LoadResult AppLoader_DeconstructedRomDirect | |||
| 118 | return {ResultStatus::ErrorMissingNPDM, {}}; | 118 | return {ResultStatus::ErrorMissingNPDM, {}}; |
| 119 | } | 119 | } |
| 120 | 120 | ||
| 121 | const ResultStatus result2 = metadata.Load(npdm); | 121 | const ResultStatus result2 = metadata.Reload(npdm); |
| 122 | if (result2 != ResultStatus::Success) { | 122 | if (result2 != ResultStatus::Success) { |
| 123 | return {result2, {}}; | 123 | return {result2, {}}; |
| 124 | } | 124 | } |
diff --git a/src/video_core/host_shaders/CMakeLists.txt b/src/video_core/host_shaders/CMakeLists.txt index 6b912027f..8bb429578 100644 --- a/src/video_core/host_shaders/CMakeLists.txt +++ b/src/video_core/host_shaders/CMakeLists.txt | |||
| @@ -19,6 +19,7 @@ set(SHADER_FILES | |||
| 19 | block_linear_unswizzle_2d.comp | 19 | block_linear_unswizzle_2d.comp |
| 20 | block_linear_unswizzle_3d.comp | 20 | block_linear_unswizzle_3d.comp |
| 21 | convert_abgr8_to_d24s8.frag | 21 | convert_abgr8_to_d24s8.frag |
| 22 | convert_d32f_to_abgr8.frag | ||
| 22 | convert_d24s8_to_abgr8.frag | 23 | convert_d24s8_to_abgr8.frag |
| 23 | convert_depth_to_float.frag | 24 | convert_depth_to_float.frag |
| 24 | convert_float_to_depth.frag | 25 | convert_float_to_depth.frag |
diff --git a/src/video_core/host_shaders/convert_d32f_to_abgr8.frag b/src/video_core/host_shaders/convert_d32f_to_abgr8.frag new file mode 100644 index 000000000..04cfef8b5 --- /dev/null +++ b/src/video_core/host_shaders/convert_d32f_to_abgr8.frag | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #version 450 | ||
| 5 | |||
| 6 | layout(binding = 0) uniform sampler2D depth_tex; | ||
| 7 | |||
| 8 | layout(location = 0) out vec4 color; | ||
| 9 | |||
| 10 | void main() { | ||
| 11 | ivec2 coord = ivec2(gl_FragCoord.xy); | ||
| 12 | float depth = textureLod(depth_tex, coord, 0).r; | ||
| 13 | color = vec4(depth, depth, depth, 1.0); | ||
| 14 | } | ||
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h index c7dc7e0a1..5ea9e2378 100644 --- a/src/video_core/renderer_opengl/maxwell_to_gl.h +++ b/src/video_core/renderer_opengl/maxwell_to_gl.h | |||
| @@ -116,6 +116,7 @@ constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> FORMAT_TAB | |||
| 116 | {GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV}, // E5B9G9R9_FLOAT | 116 | {GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV}, // E5B9G9R9_FLOAT |
| 117 | {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT}, // D32_FLOAT | 117 | {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT}, // D32_FLOAT |
| 118 | {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}, // D16_UNORM | 118 | {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT}, // D16_UNORM |
| 119 | {GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT_24_8}, // X8_D24_UNORM | ||
| 119 | {GL_STENCIL_INDEX8, GL_STENCIL, GL_UNSIGNED_BYTE}, // S8_UINT | 120 | {GL_STENCIL_INDEX8, GL_STENCIL, GL_UNSIGNED_BYTE}, // S8_UINT |
| 120 | {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}, // D24_UNORM_S8_UINT | 121 | {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}, // D24_UNORM_S8_UINT |
| 121 | {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}, // S8_UINT_D24_UNORM | 122 | {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8}, // S8_UINT_D24_UNORM |
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index 1032c9d12..f01d2394e 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "video_core/host_shaders/blit_color_float_frag_spv.h" | 9 | #include "video_core/host_shaders/blit_color_float_frag_spv.h" |
| 10 | #include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" | 10 | #include "video_core/host_shaders/convert_abgr8_to_d24s8_frag_spv.h" |
| 11 | #include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" | 11 | #include "video_core/host_shaders/convert_d24s8_to_abgr8_frag_spv.h" |
| 12 | #include "video_core/host_shaders/convert_d32f_to_abgr8_frag_spv.h" | ||
| 12 | #include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" | 13 | #include "video_core/host_shaders/convert_depth_to_float_frag_spv.h" |
| 13 | #include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" | 14 | #include "video_core/host_shaders/convert_float_to_depth_frag_spv.h" |
| 14 | #include "video_core/host_shaders/convert_s8d24_to_abgr8_frag_spv.h" | 15 | #include "video_core/host_shaders/convert_s8d24_to_abgr8_frag_spv.h" |
| @@ -433,6 +434,7 @@ BlitImageHelper::BlitImageHelper(const Device& device_, Scheduler& scheduler_, | |||
| 433 | convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)), | 434 | convert_depth_to_float_frag(BuildShader(device, CONVERT_DEPTH_TO_FLOAT_FRAG_SPV)), |
| 434 | convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), | 435 | convert_float_to_depth_frag(BuildShader(device, CONVERT_FLOAT_TO_DEPTH_FRAG_SPV)), |
| 435 | convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), | 436 | convert_abgr8_to_d24s8_frag(BuildShader(device, CONVERT_ABGR8_TO_D24S8_FRAG_SPV)), |
| 437 | convert_d32f_to_abgr8_frag(BuildShader(device, CONVERT_D32F_TO_ABGR8_FRAG_SPV)), | ||
| 436 | convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), | 438 | convert_d24s8_to_abgr8_frag(BuildShader(device, CONVERT_D24S8_TO_ABGR8_FRAG_SPV)), |
| 437 | convert_s8d24_to_abgr8_frag(BuildShader(device, CONVERT_S8D24_TO_ABGR8_FRAG_SPV)), | 439 | convert_s8d24_to_abgr8_frag(BuildShader(device, CONVERT_S8D24_TO_ABGR8_FRAG_SPV)), |
| 438 | linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)), | 440 | linear_sampler(device.GetLogical().CreateSampler(SAMPLER_CREATE_INFO<VK_FILTER_LINEAR>)), |
| @@ -557,6 +559,13 @@ void BlitImageHelper::ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, | |||
| 557 | Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view); | 559 | Convert(*convert_abgr8_to_d24s8_pipeline, dst_framebuffer, src_image_view); |
| 558 | } | 560 | } |
| 559 | 561 | ||
| 562 | void BlitImageHelper::ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, | ||
| 563 | ImageView& src_image_view) { | ||
| 564 | ConvertPipelineColorTargetEx(convert_d32f_to_abgr8_pipeline, dst_framebuffer->RenderPass(), | ||
| 565 | convert_d32f_to_abgr8_frag); | ||
| 566 | ConvertDepthStencil(*convert_d32f_to_abgr8_pipeline, dst_framebuffer, src_image_view); | ||
| 567 | } | ||
| 568 | |||
| 560 | void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, | 569 | void BlitImageHelper::ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, |
| 561 | ImageView& src_image_view) { | 570 | ImageView& src_image_view) { |
| 562 | ConvertPipelineColorTargetEx(convert_d24s8_to_abgr8_pipeline, dst_framebuffer->RenderPass(), | 571 | ConvertPipelineColorTargetEx(convert_d24s8_to_abgr8_pipeline, dst_framebuffer->RenderPass(), |
| @@ -609,6 +618,8 @@ void BlitImageHelper::ClearDepthStencil(const Framebuffer* dst_framebuffer, bool | |||
| 609 | const VkPipelineLayout layout = *clear_color_pipeline_layout; | 618 | const VkPipelineLayout layout = *clear_color_pipeline_layout; |
| 610 | scheduler.RequestRenderpass(dst_framebuffer); | 619 | scheduler.RequestRenderpass(dst_framebuffer); |
| 611 | scheduler.Record([pipeline, layout, clear_depth, dst_region](vk::CommandBuffer cmdbuf) { | 620 | scheduler.Record([pipeline, layout, clear_depth, dst_region](vk::CommandBuffer cmdbuf) { |
| 621 | constexpr std::array blend_constants{0.0f, 0.0f, 0.0f, 0.0f}; | ||
| 622 | cmdbuf.SetBlendConstants(blend_constants.data()); | ||
| 612 | cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | 623 | cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); |
| 613 | BindBlitState(cmdbuf, dst_region); | 624 | BindBlitState(cmdbuf, dst_region); |
| 614 | cmdbuf.PushConstants(layout, VK_SHADER_STAGE_FRAGMENT_BIT, clear_depth); | 625 | cmdbuf.PushConstants(layout, VK_SHADER_STAGE_FRAGMENT_BIT, clear_depth); |
| @@ -865,7 +876,7 @@ VkPipeline BlitImageHelper::FindOrEmplaceClearStencilPipeline( | |||
| 865 | .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, | 876 | .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO, |
| 866 | .pNext = nullptr, | 877 | .pNext = nullptr, |
| 867 | .flags = 0, | 878 | .flags = 0, |
| 868 | .depthTestEnable = VK_FALSE, | 879 | .depthTestEnable = key.depth_clear, |
| 869 | .depthWriteEnable = key.depth_clear, | 880 | .depthWriteEnable = key.depth_clear, |
| 870 | .depthCompareOp = VK_COMPARE_OP_ALWAYS, | 881 | .depthCompareOp = VK_COMPARE_OP_ALWAYS, |
| 871 | .depthBoundsTestEnable = VK_FALSE, | 882 | .depthBoundsTestEnable = VK_FALSE, |
diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index dcfe217aa..a032c71fb 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h | |||
| @@ -67,6 +67,8 @@ public: | |||
| 67 | 67 | ||
| 68 | void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); | 68 | void ConvertABGR8ToD24S8(const Framebuffer* dst_framebuffer, const ImageView& src_image_view); |
| 69 | 69 | ||
| 70 | void ConvertD32FToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); | ||
| 71 | |||
| 70 | void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); | 72 | void ConvertD24S8ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); |
| 71 | 73 | ||
| 72 | void ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); | 74 | void ConvertS8D24ToABGR8(const Framebuffer* dst_framebuffer, ImageView& src_image_view); |
| @@ -128,6 +130,7 @@ private: | |||
| 128 | vk::ShaderModule convert_depth_to_float_frag; | 130 | vk::ShaderModule convert_depth_to_float_frag; |
| 129 | vk::ShaderModule convert_float_to_depth_frag; | 131 | vk::ShaderModule convert_float_to_depth_frag; |
| 130 | vk::ShaderModule convert_abgr8_to_d24s8_frag; | 132 | vk::ShaderModule convert_abgr8_to_d24s8_frag; |
| 133 | vk::ShaderModule convert_d32f_to_abgr8_frag; | ||
| 131 | vk::ShaderModule convert_d24s8_to_abgr8_frag; | 134 | vk::ShaderModule convert_d24s8_to_abgr8_frag; |
| 132 | vk::ShaderModule convert_s8d24_to_abgr8_frag; | 135 | vk::ShaderModule convert_s8d24_to_abgr8_frag; |
| 133 | vk::Sampler linear_sampler; | 136 | vk::Sampler linear_sampler; |
| @@ -146,6 +149,7 @@ private: | |||
| 146 | vk::Pipeline convert_d16_to_r16_pipeline; | 149 | vk::Pipeline convert_d16_to_r16_pipeline; |
| 147 | vk::Pipeline convert_r16_to_d16_pipeline; | 150 | vk::Pipeline convert_r16_to_d16_pipeline; |
| 148 | vk::Pipeline convert_abgr8_to_d24s8_pipeline; | 151 | vk::Pipeline convert_abgr8_to_d24s8_pipeline; |
| 152 | vk::Pipeline convert_d32f_to_abgr8_pipeline; | ||
| 149 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; | 153 | vk::Pipeline convert_d24s8_to_abgr8_pipeline; |
| 150 | vk::Pipeline convert_s8d24_to_abgr8_pipeline; | 154 | vk::Pipeline convert_s8d24_to_abgr8_pipeline; |
| 151 | }; | 155 | }; |
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp index 208e88533..a08f2f67f 100644 --- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp +++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp | |||
| @@ -214,8 +214,9 @@ struct FormatTuple { | |||
| 214 | {VK_FORMAT_E5B9G9R9_UFLOAT_PACK32}, // E5B9G9R9_FLOAT | 214 | {VK_FORMAT_E5B9G9R9_UFLOAT_PACK32}, // E5B9G9R9_FLOAT |
| 215 | 215 | ||
| 216 | // Depth formats | 216 | // Depth formats |
| 217 | {VK_FORMAT_D32_SFLOAT, Attachable}, // D32_FLOAT | 217 | {VK_FORMAT_D32_SFLOAT, Attachable}, // D32_FLOAT |
| 218 | {VK_FORMAT_D16_UNORM, Attachable}, // D16_UNORM | 218 | {VK_FORMAT_D16_UNORM, Attachable}, // D16_UNORM |
| 219 | {VK_FORMAT_X8_D24_UNORM_PACK32, Attachable}, // X8_D24_UNORM | ||
| 219 | 220 | ||
| 220 | // Stencil formats | 221 | // Stencil formats |
| 221 | {VK_FORMAT_S8_UINT, Attachable}, // S8_UINT | 222 | {VK_FORMAT_S8_UINT, Attachable}, // S8_UINT |
diff --git a/src/video_core/renderer_vulkan/vk_blit_screen.cpp b/src/video_core/renderer_vulkan/vk_blit_screen.cpp index 31928bb94..52fc142d1 100644 --- a/src/video_core/renderer_vulkan/vk_blit_screen.cpp +++ b/src/video_core/renderer_vulkan/vk_blit_screen.cpp | |||
| @@ -96,6 +96,7 @@ std::size_t GetSizeInBytes(const Tegra::FramebufferConfig& framebuffer) { | |||
| 96 | VkFormat GetFormat(const Tegra::FramebufferConfig& framebuffer) { | 96 | VkFormat GetFormat(const Tegra::FramebufferConfig& framebuffer) { |
| 97 | switch (framebuffer.pixel_format) { | 97 | switch (framebuffer.pixel_format) { |
| 98 | case Service::android::PixelFormat::Rgba8888: | 98 | case Service::android::PixelFormat::Rgba8888: |
| 99 | case Service::android::PixelFormat::Rgbx8888: | ||
| 99 | return VK_FORMAT_A8B8G8R8_UNORM_PACK32; | 100 | return VK_FORMAT_A8B8G8R8_UNORM_PACK32; |
| 100 | case Service::android::PixelFormat::Rgb565: | 101 | case Service::android::PixelFormat::Rgb565: |
| 101 | return VK_FORMAT_R5G6B5_UNORM_PACK16; | 102 | return VK_FORMAT_R5G6B5_UNORM_PACK16; |
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 1628d76d6..83f2b6045 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp | |||
| @@ -422,7 +422,8 @@ void RasterizerVulkan::Clear(u32 layer_count) { | |||
| 422 | return; | 422 | return; |
| 423 | } | 423 | } |
| 424 | 424 | ||
| 425 | if (use_stencil && regs.stencil_front_mask != 0xFF && regs.stencil_front_mask != 0) { | 425 | if (use_stencil && framebuffer->HasAspectStencilBit() && regs.stencil_front_mask != 0xFF && |
| 426 | regs.stencil_front_mask != 0) { | ||
| 426 | Region2D dst_region = { | 427 | Region2D dst_region = { |
| 427 | Offset2D{.x = clear_rect.rect.offset.x, .y = clear_rect.rect.offset.y}, | 428 | Offset2D{.x = clear_rect.rect.offset.x, .y = clear_rect.rect.offset.y}, |
| 428 | Offset2D{.x = clear_rect.rect.offset.x + static_cast<s32>(clear_rect.rect.extent.width), | 429 | Offset2D{.x = clear_rect.rect.offset.x + static_cast<s32>(clear_rect.rect.extent.width), |
diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp index ce92f66ab..b278614e6 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.cpp | |||
| @@ -24,25 +24,38 @@ using namespace Common::Literals; | |||
| 24 | 24 | ||
| 25 | // Maximum potential alignment of a Vulkan buffer | 25 | // Maximum potential alignment of a Vulkan buffer |
| 26 | constexpr VkDeviceSize MAX_ALIGNMENT = 256; | 26 | constexpr VkDeviceSize MAX_ALIGNMENT = 256; |
| 27 | // Maximum size to put elements in the stream buffer | ||
| 28 | constexpr VkDeviceSize MAX_STREAM_BUFFER_REQUEST_SIZE = 8_MiB; | ||
| 29 | // Stream buffer size in bytes | 27 | // Stream buffer size in bytes |
| 30 | constexpr VkDeviceSize STREAM_BUFFER_SIZE = 128_MiB; | 28 | constexpr VkDeviceSize MAX_STREAM_BUFFER_SIZE = 128_MiB; |
| 31 | constexpr VkDeviceSize REGION_SIZE = STREAM_BUFFER_SIZE / StagingBufferPool::NUM_SYNCS; | ||
| 32 | 29 | ||
| 33 | size_t Region(size_t iterator) noexcept { | 30 | size_t GetStreamBufferSize(const Device& device) { |
| 34 | return iterator / REGION_SIZE; | 31 | VkDeviceSize size{0}; |
| 32 | if (device.HasDebuggingToolAttached()) { | ||
| 33 | ForEachDeviceLocalHostVisibleHeap(device, [&size](size_t index, VkMemoryHeap& heap) { | ||
| 34 | size = std::max(size, heap.size); | ||
| 35 | }); | ||
| 36 | // If rebar is not supported, cut the max heap size to 40%. This will allow 2 captures to be | ||
| 37 | // loaded at the same time in RenderDoc. If rebar is supported, this shouldn't be an issue | ||
| 38 | // as the heap will be much larger. | ||
| 39 | if (size <= 256_MiB) { | ||
| 40 | size = size * 40 / 100; | ||
| 41 | } | ||
| 42 | } else { | ||
| 43 | size = MAX_STREAM_BUFFER_SIZE; | ||
| 44 | } | ||
| 45 | return std::min(Common::AlignUp(size, MAX_ALIGNMENT), MAX_STREAM_BUFFER_SIZE); | ||
| 35 | } | 46 | } |
| 36 | } // Anonymous namespace | 47 | } // Anonymous namespace |
| 37 | 48 | ||
| 38 | StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& memory_allocator_, | 49 | StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& memory_allocator_, |
| 39 | Scheduler& scheduler_) | 50 | Scheduler& scheduler_) |
| 40 | : device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_} { | 51 | : device{device_}, memory_allocator{memory_allocator_}, scheduler{scheduler_}, |
| 52 | stream_buffer_size{GetStreamBufferSize(device)}, region_size{stream_buffer_size / | ||
| 53 | StagingBufferPool::NUM_SYNCS} { | ||
| 41 | VkBufferCreateInfo stream_ci = { | 54 | VkBufferCreateInfo stream_ci = { |
| 42 | .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, | 55 | .sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, |
| 43 | .pNext = nullptr, | 56 | .pNext = nullptr, |
| 44 | .flags = 0, | 57 | .flags = 0, |
| 45 | .size = STREAM_BUFFER_SIZE, | 58 | .size = stream_buffer_size, |
| 46 | .usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | | 59 | .usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | |
| 47 | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, | 60 | VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, |
| 48 | .sharingMode = VK_SHARING_MODE_EXCLUSIVE, | 61 | .sharingMode = VK_SHARING_MODE_EXCLUSIVE, |
| @@ -63,7 +76,7 @@ StagingBufferPool::StagingBufferPool(const Device& device_, MemoryAllocator& mem | |||
| 63 | StagingBufferPool::~StagingBufferPool() = default; | 76 | StagingBufferPool::~StagingBufferPool() = default; |
| 64 | 77 | ||
| 65 | StagingBufferRef StagingBufferPool::Request(size_t size, MemoryUsage usage, bool deferred) { | 78 | StagingBufferRef StagingBufferPool::Request(size_t size, MemoryUsage usage, bool deferred) { |
| 66 | if (!deferred && usage == MemoryUsage::Upload && size <= MAX_STREAM_BUFFER_REQUEST_SIZE) { | 79 | if (!deferred && usage == MemoryUsage::Upload && size <= region_size) { |
| 67 | return GetStreamBuffer(size); | 80 | return GetStreamBuffer(size); |
| 68 | } | 81 | } |
| 69 | return GetStagingBuffer(size, usage, deferred); | 82 | return GetStagingBuffer(size, usage, deferred); |
| @@ -101,7 +114,7 @@ StagingBufferRef StagingBufferPool::GetStreamBuffer(size_t size) { | |||
| 101 | used_iterator = iterator; | 114 | used_iterator = iterator; |
| 102 | free_iterator = std::max(free_iterator, iterator + size); | 115 | free_iterator = std::max(free_iterator, iterator + size); |
| 103 | 116 | ||
| 104 | if (iterator + size >= STREAM_BUFFER_SIZE) { | 117 | if (iterator + size >= stream_buffer_size) { |
| 105 | std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + NUM_SYNCS, | 118 | std::fill(sync_ticks.begin() + Region(used_iterator), sync_ticks.begin() + NUM_SYNCS, |
| 106 | current_tick); | 119 | current_tick); |
| 107 | used_iterator = 0; | 120 | used_iterator = 0; |
diff --git a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h index 5f69f08b1..d3deb9072 100644 --- a/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h +++ b/src/video_core/renderer_vulkan/vk_staging_buffer_pool.h | |||
| @@ -90,6 +90,9 @@ private: | |||
| 90 | void ReleaseCache(MemoryUsage usage); | 90 | void ReleaseCache(MemoryUsage usage); |
| 91 | 91 | ||
| 92 | void ReleaseLevel(StagingBuffersCache& cache, size_t log2); | 92 | void ReleaseLevel(StagingBuffersCache& cache, size_t log2); |
| 93 | size_t Region(size_t iter) const noexcept { | ||
| 94 | return iter / region_size; | ||
| 95 | } | ||
| 93 | 96 | ||
| 94 | const Device& device; | 97 | const Device& device; |
| 95 | MemoryAllocator& memory_allocator; | 98 | MemoryAllocator& memory_allocator; |
| @@ -97,6 +100,8 @@ private: | |||
| 97 | 100 | ||
| 98 | vk::Buffer stream_buffer; | 101 | vk::Buffer stream_buffer; |
| 99 | std::span<u8> stream_pointer; | 102 | std::span<u8> stream_pointer; |
| 103 | VkDeviceSize stream_buffer_size; | ||
| 104 | VkDeviceSize region_size; | ||
| 100 | 105 | ||
| 101 | size_t iterator = 0; | 106 | size_t iterator = 0; |
| 102 | size_t used_iterator = 0; | 107 | size_t used_iterator = 0; |
diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 71fdec809..00ab47268 100644 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp | |||
| @@ -238,6 +238,7 @@ constexpr VkBorderColor ConvertBorderColor(const std::array<float, 4>& color) { | |||
| 238 | return any_r ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; | 238 | return any_r ? VK_IMAGE_ASPECT_STENCIL_BIT : VK_IMAGE_ASPECT_DEPTH_BIT; |
| 239 | case PixelFormat::D16_UNORM: | 239 | case PixelFormat::D16_UNORM: |
| 240 | case PixelFormat::D32_FLOAT: | 240 | case PixelFormat::D32_FLOAT: |
| 241 | case PixelFormat::X8_D24_UNORM: | ||
| 241 | return VK_IMAGE_ASPECT_DEPTH_BIT; | 242 | return VK_IMAGE_ASPECT_DEPTH_BIT; |
| 242 | case PixelFormat::S8_UINT: | 243 | case PixelFormat::S8_UINT: |
| 243 | return VK_IMAGE_ASPECT_STENCIL_BIT; | 244 | return VK_IMAGE_ASPECT_STENCIL_BIT; |
| @@ -1200,6 +1201,9 @@ void TextureCacheRuntime::ConvertImage(Framebuffer* dst, ImageView& dst_view, Im | |||
| 1200 | if (src_view.format == PixelFormat::D24_UNORM_S8_UINT) { | 1201 | if (src_view.format == PixelFormat::D24_UNORM_S8_UINT) { |
| 1201 | return blit_image_helper.ConvertS8D24ToABGR8(dst, src_view); | 1202 | return blit_image_helper.ConvertS8D24ToABGR8(dst, src_view); |
| 1202 | } | 1203 | } |
| 1204 | if (src_view.format == PixelFormat::D32_FLOAT) { | ||
| 1205 | return blit_image_helper.ConvertD32FToABGR8(dst, src_view); | ||
| 1206 | } | ||
| 1203 | break; | 1207 | break; |
| 1204 | case PixelFormat::R32_FLOAT: | 1208 | case PixelFormat::R32_FLOAT: |
| 1205 | if (src_view.format == PixelFormat::D32_FLOAT) { | 1209 | if (src_view.format == PixelFormat::D32_FLOAT) { |
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index e16cd5e73..5b3c7aa5a 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp | |||
| @@ -85,6 +85,8 @@ PixelFormat PixelFormatFromDepthFormat(Tegra::DepthFormat format) { | |||
| 85 | return PixelFormat::S8_UINT; | 85 | return PixelFormat::S8_UINT; |
| 86 | case Tegra::DepthFormat::Z32_FLOAT_X24S8_UINT: | 86 | case Tegra::DepthFormat::Z32_FLOAT_X24S8_UINT: |
| 87 | return PixelFormat::D32_FLOAT_S8_UINT; | 87 | return PixelFormat::D32_FLOAT_S8_UINT; |
| 88 | case Tegra::DepthFormat::X8Z24_UNORM: | ||
| 89 | return PixelFormat::X8_D24_UNORM; | ||
| 88 | default: | 90 | default: |
| 89 | UNIMPLEMENTED_MSG("Unimplemented format={}", format); | 91 | UNIMPLEMENTED_MSG("Unimplemented format={}", format); |
| 90 | return PixelFormat::S8_UINT_D24_UNORM; | 92 | return PixelFormat::S8_UINT_D24_UNORM; |
| @@ -202,6 +204,7 @@ PixelFormat PixelFormatFromRenderTargetFormat(Tegra::RenderTargetFormat format) | |||
| 202 | PixelFormat PixelFormatFromGPUPixelFormat(Service::android::PixelFormat format) { | 204 | PixelFormat PixelFormatFromGPUPixelFormat(Service::android::PixelFormat format) { |
| 203 | switch (format) { | 205 | switch (format) { |
| 204 | case Service::android::PixelFormat::Rgba8888: | 206 | case Service::android::PixelFormat::Rgba8888: |
| 207 | case Service::android::PixelFormat::Rgbx8888: | ||
| 205 | return PixelFormat::A8B8G8R8_UNORM; | 208 | return PixelFormat::A8B8G8R8_UNORM; |
| 206 | case Service::android::PixelFormat::Rgb565: | 209 | case Service::android::PixelFormat::Rgb565: |
| 207 | return PixelFormat::R5G6B5_UNORM; | 210 | return PixelFormat::R5G6B5_UNORM; |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index 9b9c4d9bc..a5e8e2f62 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -115,6 +115,7 @@ enum class PixelFormat { | |||
| 115 | // Depth formats | 115 | // Depth formats |
| 116 | D32_FLOAT = MaxColorFormat, | 116 | D32_FLOAT = MaxColorFormat, |
| 117 | D16_UNORM, | 117 | D16_UNORM, |
| 118 | X8_D24_UNORM, | ||
| 118 | 119 | ||
| 119 | MaxDepthFormat, | 120 | MaxDepthFormat, |
| 120 | 121 | ||
| @@ -251,6 +252,7 @@ constexpr std::array<u8, MaxPixelFormat> BLOCK_WIDTH_TABLE = {{ | |||
| 251 | 1, // E5B9G9R9_FLOAT | 252 | 1, // E5B9G9R9_FLOAT |
| 252 | 1, // D32_FLOAT | 253 | 1, // D32_FLOAT |
| 253 | 1, // D16_UNORM | 254 | 1, // D16_UNORM |
| 255 | 1, // X8_D24_UNORM | ||
| 254 | 1, // S8_UINT | 256 | 1, // S8_UINT |
| 255 | 1, // D24_UNORM_S8_UINT | 257 | 1, // D24_UNORM_S8_UINT |
| 256 | 1, // S8_UINT_D24_UNORM | 258 | 1, // S8_UINT_D24_UNORM |
| @@ -360,6 +362,7 @@ constexpr std::array<u8, MaxPixelFormat> BLOCK_HEIGHT_TABLE = {{ | |||
| 360 | 1, // E5B9G9R9_FLOAT | 362 | 1, // E5B9G9R9_FLOAT |
| 361 | 1, // D32_FLOAT | 363 | 1, // D32_FLOAT |
| 362 | 1, // D16_UNORM | 364 | 1, // D16_UNORM |
| 365 | 1, // X8_D24_UNORM | ||
| 363 | 1, // S8_UINT | 366 | 1, // S8_UINT |
| 364 | 1, // D24_UNORM_S8_UINT | 367 | 1, // D24_UNORM_S8_UINT |
| 365 | 1, // S8_UINT_D24_UNORM | 368 | 1, // S8_UINT_D24_UNORM |
| @@ -469,6 +472,7 @@ constexpr std::array<u8, MaxPixelFormat> BITS_PER_BLOCK_TABLE = {{ | |||
| 469 | 32, // E5B9G9R9_FLOAT | 472 | 32, // E5B9G9R9_FLOAT |
| 470 | 32, // D32_FLOAT | 473 | 32, // D32_FLOAT |
| 471 | 16, // D16_UNORM | 474 | 16, // D16_UNORM |
| 475 | 32, // X8_D24_UNORM | ||
| 472 | 8, // S8_UINT | 476 | 8, // S8_UINT |
| 473 | 32, // D24_UNORM_S8_UINT | 477 | 32, // D24_UNORM_S8_UINT |
| 474 | 32, // S8_UINT_D24_UNORM | 478 | 32, // S8_UINT_D24_UNORM |
diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp index 56307d030..3162c8f5e 100644 --- a/src/video_core/texture_cache/format_lookup_table.cpp +++ b/src/video_core/texture_cache/format_lookup_table.cpp | |||
| @@ -142,6 +142,10 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red, | |||
| 142 | return PixelFormat::D16_UNORM; | 142 | return PixelFormat::D16_UNORM; |
| 143 | case Hash(TextureFormat::Z16, UNORM, UINT, UINT, UINT, LINEAR): | 143 | case Hash(TextureFormat::Z16, UNORM, UINT, UINT, UINT, LINEAR): |
| 144 | return PixelFormat::D16_UNORM; | 144 | return PixelFormat::D16_UNORM; |
| 145 | case Hash(TextureFormat::X8Z24, UNORM): | ||
| 146 | return PixelFormat::X8_D24_UNORM; | ||
| 147 | case Hash(TextureFormat::X8Z24, UNORM, UINT, UINT, UINT, LINEAR): | ||
| 148 | return PixelFormat::X8_D24_UNORM; | ||
| 145 | case Hash(TextureFormat::Z24S8, UINT, UNORM, UNORM, UNORM, LINEAR): | 149 | case Hash(TextureFormat::Z24S8, UINT, UNORM, UNORM, UNORM, LINEAR): |
| 146 | return PixelFormat::S8_UINT_D24_UNORM; | 150 | return PixelFormat::S8_UINT_D24_UNORM; |
| 147 | case Hash(TextureFormat::Z24S8, UINT, UNORM, UINT, UINT, LINEAR): | 151 | case Hash(TextureFormat::Z24S8, UINT, UNORM, UINT, UINT, LINEAR): |
diff --git a/src/video_core/texture_cache/formatter.h b/src/video_core/texture_cache/formatter.h index 9ee57a076..cabbfcb2d 100644 --- a/src/video_core/texture_cache/formatter.h +++ b/src/video_core/texture_cache/formatter.h | |||
| @@ -211,6 +211,8 @@ struct fmt::formatter<VideoCore::Surface::PixelFormat> : fmt::formatter<fmt::str | |||
| 211 | return "D32_FLOAT"; | 211 | return "D32_FLOAT"; |
| 212 | case PixelFormat::D16_UNORM: | 212 | case PixelFormat::D16_UNORM: |
| 213 | return "D16_UNORM"; | 213 | return "D16_UNORM"; |
| 214 | case PixelFormat::X8_D24_UNORM: | ||
| 215 | return "X8_D24_UNORM"; | ||
| 214 | case PixelFormat::S8_UINT: | 216 | case PixelFormat::S8_UINT: |
| 215 | return "S8_UINT"; | 217 | return "S8_UINT"; |
| 216 | case PixelFormat::D24_UNORM_S8_UINT: | 218 | case PixelFormat::D24_UNORM_S8_UINT: |
diff --git a/src/video_core/texture_cache/image_view_base.cpp b/src/video_core/texture_cache/image_view_base.cpp index 0c5f4450d..18b9250f9 100644 --- a/src/video_core/texture_cache/image_view_base.cpp +++ b/src/video_core/texture_cache/image_view_base.cpp | |||
| @@ -85,6 +85,7 @@ bool ImageViewBase::SupportsAnisotropy() const noexcept { | |||
| 85 | // Depth formats | 85 | // Depth formats |
| 86 | case PixelFormat::D32_FLOAT: | 86 | case PixelFormat::D32_FLOAT: |
| 87 | case PixelFormat::D16_UNORM: | 87 | case PixelFormat::D16_UNORM: |
| 88 | case PixelFormat::X8_D24_UNORM: | ||
| 88 | // Stencil formats | 89 | // Stencil formats |
| 89 | case PixelFormat::S8_UINT: | 90 | case PixelFormat::S8_UINT: |
| 90 | // DepthStencil formats | 91 | // DepthStencil formats |
diff --git a/src/video_core/vulkan_common/vulkan_device.cpp b/src/video_core/vulkan_common/vulkan_device.cpp index 3960b135a..876cec2e8 100644 --- a/src/video_core/vulkan_common/vulkan_device.cpp +++ b/src/video_core/vulkan_common/vulkan_device.cpp | |||
| @@ -84,9 +84,12 @@ constexpr std::array VK_FORMAT_A4B4G4R4_UNORM_PACK16{ | |||
| 84 | } // namespace Alternatives | 84 | } // namespace Alternatives |
| 85 | 85 | ||
| 86 | enum class NvidiaArchitecture { | 86 | enum class NvidiaArchitecture { |
| 87 | AmpereOrNewer, | 87 | KeplerOrOlder, |
| 88 | Maxwell, | ||
| 89 | Pascal, | ||
| 90 | Volta, | ||
| 88 | Turing, | 91 | Turing, |
| 89 | VoltaOrOlder, | 92 | AmpereOrNewer, |
| 90 | }; | 93 | }; |
| 91 | 94 | ||
| 92 | template <typename T> | 95 | template <typename T> |
| @@ -200,6 +203,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::Physica | |||
| 200 | VK_FORMAT_BC7_UNORM_BLOCK, | 203 | VK_FORMAT_BC7_UNORM_BLOCK, |
| 201 | VK_FORMAT_D16_UNORM, | 204 | VK_FORMAT_D16_UNORM, |
| 202 | VK_FORMAT_D16_UNORM_S8_UINT, | 205 | VK_FORMAT_D16_UNORM_S8_UINT, |
| 206 | VK_FORMAT_X8_D24_UNORM_PACK32, | ||
| 203 | VK_FORMAT_D24_UNORM_S8_UINT, | 207 | VK_FORMAT_D24_UNORM_S8_UINT, |
| 204 | VK_FORMAT_D32_SFLOAT, | 208 | VK_FORMAT_D32_SFLOAT, |
| 205 | VK_FORMAT_D32_SFLOAT_S8_UINT, | 209 | VK_FORMAT_D32_SFLOAT_S8_UINT, |
| @@ -321,13 +325,38 @@ NvidiaArchitecture GetNvidiaArchitecture(vk::PhysicalDevice physical, | |||
| 321 | physical.GetProperties2(physical_properties); | 325 | physical.GetProperties2(physical_properties); |
| 322 | if (shading_rate_props.primitiveFragmentShadingRateWithMultipleViewports) { | 326 | if (shading_rate_props.primitiveFragmentShadingRateWithMultipleViewports) { |
| 323 | // Only Ampere and newer support this feature | 327 | // Only Ampere and newer support this feature |
| 328 | // TODO: Find a way to differentiate Ampere and Ada | ||
| 324 | return NvidiaArchitecture::AmpereOrNewer; | 329 | return NvidiaArchitecture::AmpereOrNewer; |
| 325 | } | 330 | } |
| 326 | } | ||
| 327 | if (exts.contains(VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME)) { | ||
| 328 | return NvidiaArchitecture::Turing; | 331 | return NvidiaArchitecture::Turing; |
| 329 | } | 332 | } |
| 330 | return NvidiaArchitecture::VoltaOrOlder; | 333 | |
| 334 | if (exts.contains(VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME)) { | ||
| 335 | VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT advanced_blending_props{}; | ||
| 336 | advanced_blending_props.sType = | ||
| 337 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT; | ||
| 338 | VkPhysicalDeviceProperties2 physical_properties{}; | ||
| 339 | physical_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; | ||
| 340 | physical_properties.pNext = &advanced_blending_props; | ||
| 341 | physical.GetProperties2(physical_properties); | ||
| 342 | if (advanced_blending_props.advancedBlendMaxColorAttachments == 1) { | ||
| 343 | return NvidiaArchitecture::Maxwell; | ||
| 344 | } | ||
| 345 | |||
| 346 | if (exts.contains(VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME)) { | ||
| 347 | VkPhysicalDeviceConservativeRasterizationPropertiesEXT conservative_raster_props{}; | ||
| 348 | conservative_raster_props.sType = | ||
| 349 | VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT; | ||
| 350 | physical_properties.pNext = &conservative_raster_props; | ||
| 351 | physical.GetProperties2(physical_properties); | ||
| 352 | if (conservative_raster_props.degenerateLinesRasterized) { | ||
| 353 | return NvidiaArchitecture::Volta; | ||
| 354 | } | ||
| 355 | return NvidiaArchitecture::Pascal; | ||
| 356 | } | ||
| 357 | } | ||
| 358 | |||
| 359 | return NvidiaArchitecture::KeplerOrOlder; | ||
| 331 | } | 360 | } |
| 332 | 361 | ||
| 333 | std::vector<const char*> ExtensionListForVulkan( | 362 | std::vector<const char*> ExtensionListForVulkan( |
| @@ -504,19 +533,14 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 504 | if (is_nvidia) { | 533 | if (is_nvidia) { |
| 505 | const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff; | 534 | const u32 nv_major_version = (properties.properties.driverVersion >> 22) & 0x3ff; |
| 506 | const auto arch = GetNvidiaArchitecture(physical, supported_extensions); | 535 | const auto arch = GetNvidiaArchitecture(physical, supported_extensions); |
| 507 | switch (arch) { | 536 | if (arch >= NvidiaArchitecture::AmpereOrNewer) { |
| 508 | case NvidiaArchitecture::AmpereOrNewer: | ||
| 509 | LOG_WARNING(Render_Vulkan, "Ampere and newer have broken float16 math"); | 537 | LOG_WARNING(Render_Vulkan, "Ampere and newer have broken float16 math"); |
| 510 | features.shader_float16_int8.shaderFloat16 = false; | 538 | features.shader_float16_int8.shaderFloat16 = false; |
| 511 | break; | 539 | } else if (arch <= NvidiaArchitecture::Volta) { |
| 512 | case NvidiaArchitecture::Turing: | ||
| 513 | break; | ||
| 514 | case NvidiaArchitecture::VoltaOrOlder: | ||
| 515 | if (nv_major_version < 527) { | 540 | if (nv_major_version < 527) { |
| 516 | LOG_WARNING(Render_Vulkan, "Volta and older have broken VK_KHR_push_descriptor"); | 541 | LOG_WARNING(Render_Vulkan, "Volta and older have broken VK_KHR_push_descriptor"); |
| 517 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | 542 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
| 518 | } | 543 | } |
| 519 | break; | ||
| 520 | } | 544 | } |
| 521 | if (nv_major_version >= 510) { | 545 | if (nv_major_version >= 510) { |
| 522 | LOG_WARNING(Render_Vulkan, "NVIDIA Drivers >= 510 do not support MSAA image blits"); | 546 | LOG_WARNING(Render_Vulkan, "NVIDIA Drivers >= 510 do not support MSAA image blits"); |
| @@ -661,7 +685,15 @@ Device::Device(VkInstance instance_, vk::PhysicalDevice physical_, VkSurfaceKHR | |||
| 661 | "ANV drivers 22.3.0 to 23.1.0 have broken VK_KHR_push_descriptor"); | 685 | "ANV drivers 22.3.0 to 23.1.0 have broken VK_KHR_push_descriptor"); |
| 662 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | 686 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); |
| 663 | } | 687 | } |
| 688 | } else if (extensions.push_descriptor && is_nvidia) { | ||
| 689 | const auto arch = GetNvidiaArchitecture(physical, supported_extensions); | ||
| 690 | if (arch <= NvidiaArchitecture::Pascal) { | ||
| 691 | LOG_WARNING(Render_Vulkan, | ||
| 692 | "Pascal and older architectures have broken VK_KHR_push_descriptor"); | ||
| 693 | RemoveExtension(extensions.push_descriptor, VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME); | ||
| 694 | } | ||
| 664 | } | 695 | } |
| 696 | |||
| 665 | if (is_mvk) { | 697 | if (is_mvk) { |
| 666 | LOG_WARNING(Render_Vulkan, | 698 | LOG_WARNING(Render_Vulkan, |
| 667 | "MVK driver breaks when using more than 16 vertex attributes/bindings"); | 699 | "MVK driver breaks when using more than 16 vertex attributes/bindings"); |
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp index 3ef381a38..82767fdf0 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.cpp +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/alignment.h" | 9 | #include "common/alignment.h" |
| 10 | #include "common/assert.h" | 10 | #include "common/assert.h" |
| 11 | #include "common/common_types.h" | 11 | #include "common/common_types.h" |
| 12 | #include "common/literals.h" | ||
| 12 | #include "common/logging/log.h" | 13 | #include "common/logging/log.h" |
| 13 | #include "common/polyfill_ranges.h" | 14 | #include "common/polyfill_ranges.h" |
| 14 | #include "video_core/vulkan_common/vma.h" | 15 | #include "video_core/vulkan_common/vma.h" |
| @@ -69,8 +70,7 @@ struct Range { | |||
| 69 | case MemoryUsage::Download: | 70 | case MemoryUsage::Download: |
| 70 | return VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT; | 71 | return VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT; |
| 71 | case MemoryUsage::DeviceLocal: | 72 | case MemoryUsage::DeviceLocal: |
| 72 | return VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT | | 73 | return {}; |
| 73 | VMA_ALLOCATION_CREATE_HOST_ACCESS_ALLOW_TRANSFER_INSTEAD_BIT; | ||
| 74 | } | 74 | } |
| 75 | return {}; | 75 | return {}; |
| 76 | } | 76 | } |
| @@ -212,7 +212,20 @@ MemoryAllocator::MemoryAllocator(const Device& device_) | |||
| 212 | : device{device_}, allocator{device.GetAllocator()}, | 212 | : device{device_}, allocator{device.GetAllocator()}, |
| 213 | properties{device_.GetPhysical().GetMemoryProperties().memoryProperties}, | 213 | properties{device_.GetPhysical().GetMemoryProperties().memoryProperties}, |
| 214 | buffer_image_granularity{ | 214 | buffer_image_granularity{ |
| 215 | device_.GetPhysical().GetProperties().limits.bufferImageGranularity} {} | 215 | device_.GetPhysical().GetProperties().limits.bufferImageGranularity} { |
| 216 | // GPUs not supporting rebar may only have a region with less than 256MB host visible/device | ||
| 217 | // local memory. In that case, opening 2 RenderDoc captures side-by-side is not possible due to | ||
| 218 | // the heap running out of memory. With RenderDoc attached and only a small host/device region, | ||
| 219 | // only allow the stream buffer in this memory heap. | ||
| 220 | if (device.HasDebuggingToolAttached()) { | ||
| 221 | using namespace Common::Literals; | ||
| 222 | ForEachDeviceLocalHostVisibleHeap(device, [this](size_t index, VkMemoryHeap& heap) { | ||
| 223 | if (heap.size <= 256_MiB) { | ||
| 224 | valid_memory_types &= ~(1u << index); | ||
| 225 | } | ||
| 226 | }); | ||
| 227 | } | ||
| 228 | } | ||
| 216 | 229 | ||
| 217 | MemoryAllocator::~MemoryAllocator() = default; | 230 | MemoryAllocator::~MemoryAllocator() = default; |
| 218 | 231 | ||
| @@ -244,7 +257,7 @@ vk::Buffer MemoryAllocator::CreateBuffer(const VkBufferCreateInfo& ci, MemoryUsa | |||
| 244 | .usage = MemoryUsageVma(usage), | 257 | .usage = MemoryUsageVma(usage), |
| 245 | .requiredFlags = 0, | 258 | .requiredFlags = 0, |
| 246 | .preferredFlags = MemoryUsagePreferedVmaFlags(usage), | 259 | .preferredFlags = MemoryUsagePreferedVmaFlags(usage), |
| 247 | .memoryTypeBits = 0, | 260 | .memoryTypeBits = usage == MemoryUsage::Stream ? 0u : valid_memory_types, |
| 248 | .pool = VK_NULL_HANDLE, | 261 | .pool = VK_NULL_HANDLE, |
| 249 | .pUserData = nullptr, | 262 | .pUserData = nullptr, |
| 250 | .priority = 0.f, | 263 | .priority = 0.f, |
diff --git a/src/video_core/vulkan_common/vulkan_memory_allocator.h b/src/video_core/vulkan_common/vulkan_memory_allocator.h index f449bc8d0..38a182bcb 100644 --- a/src/video_core/vulkan_common/vulkan_memory_allocator.h +++ b/src/video_core/vulkan_common/vulkan_memory_allocator.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <span> | 7 | #include <span> |
| 8 | #include <vector> | 8 | #include <vector> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "video_core/vulkan_common/vulkan_device.h" | ||
| 10 | #include "video_core/vulkan_common/vulkan_wrapper.h" | 11 | #include "video_core/vulkan_common/vulkan_wrapper.h" |
| 11 | 12 | ||
| 12 | VK_DEFINE_HANDLE(VmaAllocator) | 13 | VK_DEFINE_HANDLE(VmaAllocator) |
| @@ -26,6 +27,18 @@ enum class MemoryUsage { | |||
| 26 | Stream, ///< Requests device local host visible buffer, falling back host memory. | 27 | Stream, ///< Requests device local host visible buffer, falling back host memory. |
| 27 | }; | 28 | }; |
| 28 | 29 | ||
| 30 | template <typename F> | ||
| 31 | void ForEachDeviceLocalHostVisibleHeap(const Device& device, F&& f) { | ||
| 32 | auto memory_props = device.GetPhysical().GetMemoryProperties().memoryProperties; | ||
| 33 | for (size_t i = 0; i < memory_props.memoryTypeCount; i++) { | ||
| 34 | auto& memory_type = memory_props.memoryTypes[i]; | ||
| 35 | if ((memory_type.propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) && | ||
| 36 | (memory_type.propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) { | ||
| 37 | f(memory_type.heapIndex, memory_props.memoryHeaps[memory_type.heapIndex]); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 29 | /// Ownership handle of a memory commitment. | 42 | /// Ownership handle of a memory commitment. |
| 30 | /// Points to a subregion of a memory allocation. | 43 | /// Points to a subregion of a memory allocation. |
| 31 | class MemoryCommit { | 44 | class MemoryCommit { |
| @@ -124,6 +137,7 @@ private: | |||
| 124 | std::vector<std::unique_ptr<MemoryAllocation>> allocations; ///< Current allocations. | 137 | std::vector<std::unique_ptr<MemoryAllocation>> allocations; ///< Current allocations. |
| 125 | VkDeviceSize buffer_image_granularity; // The granularity for adjacent offsets between buffers | 138 | VkDeviceSize buffer_image_granularity; // The granularity for adjacent offsets between buffers |
| 126 | // and optimal images | 139 | // and optimal images |
| 140 | u32 valid_memory_types{~0u}; | ||
| 127 | }; | 141 | }; |
| 128 | 142 | ||
| 129 | } // namespace Vulkan | 143 | } // namespace Vulkan |
diff --git a/src/yuzu/configuration/configure_audio.cpp b/src/yuzu/configuration/configure_audio.cpp index 9ccfb2435..81dd51ad3 100644 --- a/src/yuzu/configuration/configure_audio.cpp +++ b/src/yuzu/configuration/configure_audio.cpp | |||
| @@ -42,6 +42,9 @@ void ConfigureAudio::Setup(const ConfigurationShared::Builder& builder) { | |||
| 42 | for (auto* setting : Settings::values.linkage.by_category[category]) { | 42 | for (auto* setting : Settings::values.linkage.by_category[category]) { |
| 43 | settings.push_back(setting); | 43 | settings.push_back(setting); |
| 44 | } | 44 | } |
| 45 | for (auto* setting : UISettings::values.linkage.by_category[category]) { | ||
| 46 | settings.push_back(setting); | ||
| 47 | } | ||
| 45 | }; | 48 | }; |
| 46 | 49 | ||
| 47 | push(Settings::Category::Audio); | 50 | push(Settings::Category::Audio); |
diff --git a/src/yuzu/configuration/shared_translation.cpp b/src/yuzu/configuration/shared_translation.cpp index 276bdbaba..a4e8af1b4 100644 --- a/src/yuzu/configuration/shared_translation.cpp +++ b/src/yuzu/configuration/shared_translation.cpp | |||
| @@ -29,9 +29,10 @@ std::unique_ptr<TranslationMap> InitializeTranslations(QWidget* parent) { | |||
| 29 | INSERT(Settings, sink_id, "Output Engine:", ""); | 29 | INSERT(Settings, sink_id, "Output Engine:", ""); |
| 30 | INSERT(Settings, audio_output_device_id, "Output Device:", ""); | 30 | INSERT(Settings, audio_output_device_id, "Output Device:", ""); |
| 31 | INSERT(Settings, audio_input_device_id, "Input Device:", ""); | 31 | INSERT(Settings, audio_input_device_id, "Input Device:", ""); |
| 32 | INSERT(Settings, audio_muted, "Mute audio when in background", ""); | 32 | INSERT(Settings, audio_muted, "Mute audio", ""); |
| 33 | INSERT(Settings, volume, "Volume:", ""); | 33 | INSERT(Settings, volume, "Volume:", ""); |
| 34 | INSERT(Settings, dump_audio_commands, "", ""); | 34 | INSERT(Settings, dump_audio_commands, "", ""); |
| 35 | INSERT(UISettings, mute_when_in_background, "Mute audio when in background", ""); | ||
| 35 | 36 | ||
| 36 | // Core | 37 | // Core |
| 37 | INSERT(Settings, use_multi_core, "Multicore CPU Emulation", ""); | 38 | INSERT(Settings, use_multi_core, "Multicore CPU Emulation", ""); |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 16fa92e2c..1753fec12 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1447,6 +1447,7 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { | |||
| 1447 | Settings::values.audio_muted = false; | 1447 | Settings::values.audio_muted = false; |
| 1448 | auto_muted = false; | 1448 | auto_muted = false; |
| 1449 | } | 1449 | } |
| 1450 | UpdateVolumeUI(); | ||
| 1450 | } | 1451 | } |
| 1451 | } | 1452 | } |
| 1452 | 1453 | ||
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 8efd63f31..8a2caa9dd 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -103,7 +103,7 @@ struct Values { | |||
| 103 | true, | 103 | true, |
| 104 | true}; | 104 | true}; |
| 105 | Setting<bool> mute_when_in_background{ | 105 | Setting<bool> mute_when_in_background{ |
| 106 | linkage, false, "muteWhenInBackground", Category::Ui, Settings::Specialization::Default, | 106 | linkage, false, "muteWhenInBackground", Category::Audio, Settings::Specialization::Default, |
| 107 | true, true}; | 107 | true, true}; |
| 108 | Setting<bool> hide_mouse{ | 108 | Setting<bool> hide_mouse{ |
| 109 | linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default, | 109 | linkage, true, "hideInactiveMouse", Category::UiGeneral, Settings::Specialization::Default, |