diff options
-rw-r--r-- | src/core/file_sys/patch_manager.cpp | 4 | ||||
-rw-r--r-- | src/core/file_sys/romfs.cpp | 19 | ||||
-rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 2 | ||||
-rw-r--r-- | src/core/loader/nca.cpp | 6 | ||||
-rw-r--r-- | src/shader_recompiler/backend/glsl/glsl_emit_context.cpp | 5 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.cpp | 76 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_buffer_cache.h | 1 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_device.cpp | 1 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_device.h | 5 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 17 | ||||
-rw-r--r-- | src/video_core/renderer_vulkan/vk_rasterizer.cpp | 14 | ||||
-rw-r--r-- | src/yuzu/configuration/qt_config.cpp | 3 | ||||
-rw-r--r-- | src/yuzu/main.cpp | 5 |
13 files changed, 68 insertions, 90 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 0bca055878..cc7af2ea30 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -429,10 +429,6 @@ VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs LOG_DEBUG(Loader, "{}", log_string); } - if (base_romfs == nullptr) { - return base_romfs; - } - auto romfs = base_romfs; // Game Updates diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index 1eb1f439ab..6de2103a0c 100644 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp @@ -3,6 +3,7 @@ #include <memory> +#include "common/assert.h" #include "common/common_types.h" #include "common/string_util.h" #include "common/swap.h" @@ -101,24 +102,30 @@ void ProcessDirectory(const VirtualFile& file, std::size_t dir_offset, std::size } // Anonymous namespace VirtualDir ExtractRomFS(VirtualFile file) { + auto root_container = std::make_shared<VectorVfsDirectory>(); + if (!file) { + return root_container; + } + RomFSHeader header{}; - if (file->ReadObject(&header) != sizeof(RomFSHeader)) - return nullptr; + if (file->ReadObject(&header) != sizeof(RomFSHeader)) { + return root_container; + } - if (header.header_size != sizeof(RomFSHeader)) - return nullptr; + if (header.header_size != sizeof(RomFSHeader)) { + return root_container; + } const u64 file_offset = header.file_meta.offset; const u64 dir_offset = header.directory_meta.offset; - auto root_container = std::make_shared<VectorVfsDirectory>(); - ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container); if (auto root = root_container->GetSubdirectory(""); root) { return std::make_shared<CachedVfsDirectory>(std::move(root)); } + ASSERT(false); return nullptr; } diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 1bc07dae5a..35e1499055 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp @@ -22,7 +22,7 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader, ContentProvider& provi : content_provider{provider}, filesystem_controller{controller} { // Load the RomFS from the app if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) { - LOG_ERROR(Service_FS, "Unable to read RomFS!"); + LOG_WARNING(Service_FS, "Unable to read base RomFS"); } updatable = app_loader.IsRomFSUpdatable(); diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index 4feb6968ae..8144075358 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -74,10 +74,8 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::KProcess& process, Core::S return load_result; } - if (nca->GetRomFS() != nullptr && nca->GetRomFS()->GetSize() > 0) { - system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>( - *this, system.GetContentProvider(), system.GetFileSystemController())); - } + system.GetFileSystemController().RegisterRomFS(std::make_unique<FileSys::RomFSFactory>( + *this, system.GetContentProvider(), system.GetFileSystemController())); is_loaded = true; return load_result; diff --git a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp index fd9a99449d..b2ceeefc45 100644 --- a/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp +++ b/src/shader_recompiler/backend/glsl/glsl_emit_context.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "common/div_ceil.h" #include "shader_recompiler/backend/bindings.h" #include "shader_recompiler/backend/glsl/glsl_emit_context.h" #include "shader_recompiler/frontend/ir/program.h" @@ -431,9 +432,11 @@ void EmitContext::DefineConstantBuffers(Bindings& bindings) { } for (const auto& desc : info.constant_buffer_descriptors) { const auto cbuf_type{profile.has_gl_cbuf_ftou_bug ? "uvec4" : "vec4"}; + const u32 cbuf_used_size{Common::DivCeil(info.constant_buffer_used_sizes[desc.index], 16U)}; + const u32 cbuf_binding_size{info.uses_global_memory ? 0x1000U : cbuf_used_size}; header += fmt::format("layout(std140,binding={}) uniform {}_cbuf_{}{{{} {}_cbuf{}[{}];}};", bindings.uniform_buffer, stage_name, desc.index, cbuf_type, - stage_name, desc.index, 4 * 1024); + stage_name, desc.index, cbuf_binding_size); bindings.uniform_buffer += desc.count; } } diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp index ed188b435b..e6c70fb343 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp @@ -53,13 +53,11 @@ Buffer::Buffer(BufferCacheRuntime& runtime, VideoCore::RasterizerInterface& rast VAddr cpu_addr_, u64 size_bytes_) : VideoCommon::BufferBase<VideoCore::RasterizerInterface>(rasterizer_, cpu_addr_, size_bytes_) { buffer.Create(); - const std::string name = fmt::format("Buffer 0x{:x}", CpuAddr()); - glObjectLabel(GL_BUFFER, buffer.handle, static_cast<GLsizei>(name.size()), name.data()); - glNamedBufferData(buffer.handle, SizeBytes(), nullptr, GL_DYNAMIC_DRAW); - - if (runtime.has_unified_vertex_buffers) { - glGetNamedBufferParameterui64vNV(buffer.handle, GL_BUFFER_GPU_ADDRESS_NV, &address); + if (runtime.device.HasDebuggingToolAttached()) { + const std::string name = fmt::format("Buffer 0x{:x}", CpuAddr()); + glObjectLabel(GL_BUFFER, buffer.handle, static_cast<GLsizei>(name.size()), name.data()); } + glNamedBufferData(buffer.handle, SizeBytes(), nullptr, GL_DYNAMIC_DRAW); } void Buffer::ImmediateUpload(size_t offset, std::span<const u8> data) noexcept { @@ -111,7 +109,6 @@ BufferCacheRuntime::BufferCacheRuntime(const Device& device_, : device{device_}, staging_buffer_pool{staging_buffer_pool_}, has_fast_buffer_sub_data{device.HasFastBufferSubData()}, use_assembly_shaders{device.UseAssemblyShaders()}, - has_unified_vertex_buffers{device.HasVertexBufferUnifiedMemory()}, stream_buffer{has_fast_buffer_sub_data ? std::nullopt : std::make_optional<StreamBuffer>()} { GLint gl_max_attributes; glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &gl_max_attributes); @@ -123,16 +120,18 @@ BufferCacheRuntime::BufferCacheRuntime(const Device& device_, GL_STREAM_DRAW); } } - for (auto& stage_uniforms : copy_uniforms) { - for (OGLBuffer& buffer : stage_uniforms) { + if (use_assembly_shaders) { + for (auto& stage_uniforms : copy_uniforms) { + for (OGLBuffer& buffer : stage_uniforms) { + buffer.Create(); + glNamedBufferData(buffer.handle, 0x10'000, nullptr, GL_STREAM_COPY); + } + } + for (OGLBuffer& buffer : copy_compute_uniforms) { buffer.Create(); glNamedBufferData(buffer.handle, 0x10'000, nullptr, GL_STREAM_COPY); } } - for (OGLBuffer& buffer : copy_compute_uniforms) { - buffer.Create(); - glNamedBufferData(buffer.handle, 0x10'000, nullptr, GL_STREAM_COPY); - } device_access_memory = [this]() -> u64 { if (device.CanReportMemoryUsage()) { @@ -211,14 +210,8 @@ void BufferCacheRuntime::ClearBuffer(Buffer& dest_buffer, u32 offset, size_t siz } void BufferCacheRuntime::BindIndexBuffer(Buffer& buffer, u32 offset, u32 size) { - if (has_unified_vertex_buffers) { - buffer.MakeResident(GL_READ_ONLY); - glBufferAddressRangeNV(GL_ELEMENT_ARRAY_ADDRESS_NV, 0, buffer.HostGpuAddr() + offset, - static_cast<GLsizeiptr>(Common::AlignUp(size, 4))); - } else { - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.Handle()); - index_buffer_offset = offset; - } + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer.Handle()); + index_buffer_offset = offset; } void BufferCacheRuntime::BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, u32 size, @@ -226,24 +219,23 @@ void BufferCacheRuntime::BindVertexBuffer(u32 index, Buffer& buffer, u32 offset, if (index >= max_attributes) { return; } - if (has_unified_vertex_buffers) { - buffer.MakeResident(GL_READ_ONLY); - glBindVertexBuffer(index, 0, 0, static_cast<GLsizei>(stride)); - glBufferAddressRangeNV(GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV, index, - buffer.HostGpuAddr() + offset, static_cast<GLsizeiptr>(size)); - } else { - glBindVertexBuffer(index, buffer.Handle(), static_cast<GLintptr>(offset), - static_cast<GLsizei>(stride)); - } + glBindVertexBuffer(index, buffer.Handle(), static_cast<GLintptr>(offset), + static_cast<GLsizei>(stride)); } void BufferCacheRuntime::BindVertexBuffers(VideoCommon::HostBindings<Buffer>& bindings) { - for (u32 index = 0; index < bindings.buffers.size(); ++index) { - BindVertexBuffer(bindings.min_index + index, *bindings.buffers[index], - static_cast<u32>(bindings.offsets[index]), - static_cast<u32>(bindings.sizes[index]), - static_cast<u32>(bindings.strides[index])); - } + // TODO: Should HostBindings provide the correct runtime types to avoid these transforms? + std::array<GLuint, 32> buffer_handles; + std::array<GLsizei, 32> buffer_strides; + std::ranges::transform(bindings.buffers, buffer_handles.begin(), + [](const Buffer* const buffer) { return buffer->Handle(); }); + std::ranges::transform(bindings.strides, buffer_strides.begin(), + [](u64 stride) { return static_cast<GLsizei>(stride); }); + const u32 count = + std::min(static_cast<u32>(bindings.buffers.size()), max_attributes - bindings.min_index); + glBindVertexBuffers(bindings.min_index, static_cast<GLsizei>(count), buffer_handles.data(), + reinterpret_cast<const GLintptr*>(bindings.offsets.data()), + buffer_strides.data()); } void BufferCacheRuntime::BindUniformBuffer(size_t stage, u32 binding_index, Buffer& buffer, @@ -335,11 +327,13 @@ void BufferCacheRuntime::BindTransformFeedbackBuffer(u32 index, Buffer& buffer, } void BufferCacheRuntime::BindTransformFeedbackBuffers(VideoCommon::HostBindings<Buffer>& bindings) { - for (u32 index = 0; index < bindings.buffers.size(); ++index) { - glBindBufferRange(GL_TRANSFORM_FEEDBACK_BUFFER, index, bindings.buffers[index]->Handle(), - static_cast<GLintptr>(bindings.offsets[index]), - static_cast<GLsizeiptr>(bindings.sizes[index])); - } + std::array<GLuint, 4> buffer_handles; + std::ranges::transform(bindings.buffers, buffer_handles.begin(), + [](const Buffer* const buffer) { return buffer->Handle(); }); + glBindBuffersRange(GL_TRANSFORM_FEEDBACK_BUFFER, 0, + static_cast<GLsizei>(bindings.buffers.size()), buffer_handles.data(), + reinterpret_cast<const GLintptr*>(bindings.offsets.data()), + reinterpret_cast<const GLsizeiptr*>(bindings.strides.data())); } void BufferCacheRuntime::BindTextureBuffer(Buffer& buffer, u32 offset, u32 size, diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h index 1e8708f59e..71cd45d35c 100644 --- a/src/video_core/renderer_opengl/gl_buffer_cache.h +++ b/src/video_core/renderer_opengl/gl_buffer_cache.h @@ -209,7 +209,6 @@ private: bool has_fast_buffer_sub_data = false; bool use_assembly_shaders = false; - bool has_unified_vertex_buffers = false; bool use_storage_buffers = false; diff --git a/src/video_core/renderer_opengl/gl_device.cpp b/src/video_core/renderer_opengl/gl_device.cpp index 993438a27b..a6c93068fc 100644 --- a/src/video_core/renderer_opengl/gl_device.cpp +++ b/src/video_core/renderer_opengl/gl_device.cpp @@ -200,7 +200,6 @@ Device::Device(Core::Frontend::EmuWindow& emu_window) { has_broken_texture_view_formats = is_amd || (!is_linux && is_intel); has_nv_viewport_array2 = GLAD_GL_NV_viewport_array2; has_derivative_control = GLAD_GL_ARB_derivative_control; - has_vertex_buffer_unified_memory = GLAD_GL_NV_vertex_buffer_unified_memory; has_debugging_tool_attached = IsDebugToolAttached(extensions); has_depth_buffer_float = HasExtension(extensions, "GL_NV_depth_buffer_float"); has_geometry_shader_passthrough = GLAD_GL_NV_geometry_shader_passthrough; diff --git a/src/video_core/renderer_opengl/gl_device.h b/src/video_core/renderer_opengl/gl_device.h index a5a6bbbba7..96034ea4a1 100644 --- a/src/video_core/renderer_opengl/gl_device.h +++ b/src/video_core/renderer_opengl/gl_device.h @@ -72,10 +72,6 @@ public: return has_texture_shadow_lod; } - bool HasVertexBufferUnifiedMemory() const { - return has_vertex_buffer_unified_memory; - } - bool HasASTC() const { return has_astc; } @@ -215,7 +211,6 @@ private: bool has_vertex_viewport_layer{}; bool has_image_load_formatted{}; bool has_texture_shadow_lod{}; - bool has_vertex_buffer_unified_memory{}; bool has_astc{}; bool has_variable_aoffi{}; bool has_component_indexing_bug{}; diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 6b8d4e554d..6bfed08a1f 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -168,15 +168,6 @@ RendererOpenGL::RendererOpenGL(Core::TelemetrySession& telemetry_session_, if (!GLAD_GL_ARB_seamless_cubemap_per_texture && !GLAD_GL_AMD_seamless_cubemap_per_texture) { glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS); } - // Enable unified vertex attributes and query vertex buffer address when the driver supports it - if (device.HasVertexBufferUnifiedMemory()) { - glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV); - glEnableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV); - - glMakeNamedBufferResidentNV(vertex_buffer.handle, GL_READ_ONLY); - glGetNamedBufferParameterui64vNV(vertex_buffer.handle, GL_BUFFER_GPU_ADDRESS_NV, - &vertex_buffer_address); - } } RendererOpenGL::~RendererOpenGL() = default; @@ -680,13 +671,7 @@ void RendererOpenGL::DrawScreen(const Layout::FramebufferLayout& layout) { offsetof(ScreenRectVertex, tex_coord)); glVertexAttribBinding(PositionLocation, 0); glVertexAttribBinding(TexCoordLocation, 0); - if (device.HasVertexBufferUnifiedMemory()) { - glBindVertexBuffer(0, 0, 0, sizeof(ScreenRectVertex)); - glBufferAddressRangeNV(GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV, 0, vertex_buffer_address, - sizeof(vertices)); - } else { - glBindVertexBuffer(0, vertex_buffer.handle, 0, sizeof(ScreenRectVertex)); - } + glBindVertexBuffer(0, vertex_buffer.handle, 0, sizeof(ScreenRectVertex)); if (Settings::values.scaling_filter.GetValue() != Settings::ScalingFilter::NearestNeighbor) { glBindSampler(0, present_sampler.handle); diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 07222e603b..b6f52e017f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -75,14 +75,20 @@ VkViewport GetViewportState(const Device& device, const Maxwell& regs, size_t in const float width = conv(src.scale_x * 2.0f); float y = conv(src.translate_y - src.scale_y); float height = conv(src.scale_y * 2.0f); - bool y_negate = regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft; - if (!device.IsNvViewportSwizzleSupported()) { - y_negate = y_negate != (src.swizzle.y == Maxwell::ViewportSwizzle::NegativeY); + const bool lower_left = regs.window_origin.mode != Maxwell::WindowOrigin::Mode::UpperLeft; + const bool y_negate = !device.IsNvViewportSwizzleSupported() && + src.swizzle.y == Maxwell::ViewportSwizzle::NegativeY; + + if (lower_left) { + // Flip by surface clip height + y += conv(static_cast<f32>(regs.surface_clip.height)); + height = -height; } if (y_negate) { - y += conv(static_cast<f32>(regs.surface_clip.height)); + // Flip by viewport height + y += height; height = -height; } diff --git a/src/yuzu/configuration/qt_config.cpp b/src/yuzu/configuration/qt_config.cpp index 5a8e69aa9d..636c5e6400 100644 --- a/src/yuzu/configuration/qt_config.cpp +++ b/src/yuzu/configuration/qt_config.cpp @@ -225,7 +225,8 @@ void QtConfig::ReadPathValues() { UISettings::values.recent_files = QString::fromStdString(ReadStringSetting(std::string("recentFiles"))) .split(QStringLiteral(", "), Qt::SkipEmptyParts, Qt::CaseSensitive); - UISettings::values.language = ReadStringSetting(std::string("language"), std::string("")); + UISettings::values.language = + ReadStringSetting(std::string("language"), std::make_optional(std::string(""))); EndGroup(); } diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 10c7882906..b056c37171 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2713,11 +2713,6 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa } const auto base_romfs = base_nca->GetRomFS(); - if (!base_romfs) { - failed(); - return; - } - const auto dump_dir = target == DumpRomFSTarget::Normal ? Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir) |