From 2c98063e76a229f1c7e59cbf3540dfc91e9966d7 Mon Sep 17 00:00:00 2001 From: IndecisiveTurtle <47210458+raphaelthegreat@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:13:30 +0300 Subject: [PATCH] oops forgot optimize off --- src/core/libraries/kernel/thread_management.cpp | 9 --------- .../backend/spirv/emit_spirv_context_get_set.cpp | 8 ++++---- .../backend/spirv/spirv_emit_context.cpp | 2 +- src/shader_recompiler/backend/spirv/spirv_emit_context.h | 1 - src/video_core/buffer_cache/buffer_cache.cpp | 2 +- src/video_core/page_manager.cpp | 8 +++++++- src/video_core/renderer_vulkan/vk_compute_pipeline.cpp | 5 +++-- src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp | 5 +++-- 8 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/core/libraries/kernel/thread_management.cpp b/src/core/libraries/kernel/thread_management.cpp index 19ce1bdd..48347ea5 100644 --- a/src/core/libraries/kernel/thread_management.cpp +++ b/src/core/libraries/kernel/thread_management.cpp @@ -1056,16 +1056,7 @@ ScePthread PThreadPool::Create() { } } -#ifdef _WIN64 auto* ret = new PthreadInternal{}; -#else - // TODO: Linux specific hack - static u8* hint_address = reinterpret_cast(0x7FFFFC000ULL); - auto* ret = reinterpret_cast( - mmap(hint_address, sizeof(PthreadInternal), PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0)); - hint_address += Common::AlignUp(sizeof(PthreadInternal), 4_KB); -#endif ret->is_free = false; ret->is_detached = false; ret->is_almost_done = false; diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index e85272e9..40d6cdb7 100644 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -129,7 +129,7 @@ Id EmitReadConst(EmitContext& ctx) { Id EmitReadConstBuffer(EmitContext& ctx, u32 handle, Id index) { auto& buffer = ctx.buffers[handle]; if (!Sirit::ValidId(buffer.offset)) { - buffer.offset = ctx.GetBufferOffset(buffer.global_binding); + buffer.offset = ctx.GetBufferOffset(handle); } const Id offset_dwords{ctx.OpShiftRightLogical(ctx.U32[1], buffer.offset, ctx.ConstU32(2U))}; index = ctx.OpIAdd(ctx.U32[1], index, offset_dwords); @@ -230,7 +230,7 @@ template static Id EmitLoadBufferF32xN(EmitContext& ctx, u32 handle, Id address) { auto& buffer = ctx.buffers[handle]; if (!Sirit::ValidId(buffer.offset)) { - buffer.offset = ctx.GetBufferOffset(buffer.global_binding); + buffer.offset = ctx.GetBufferOffset(handle); } address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset); const Id index = ctx.OpShiftRightLogical(ctx.U32[1], address, ctx.ConstU32(2u)); @@ -412,7 +412,7 @@ template static Id EmitLoadBufferFormatF32xN(EmitContext& ctx, IR::Inst* inst, u32 handle, Id address) { auto& buffer = ctx.buffers[handle]; if (!Sirit::ValidId(buffer.offset)) { - buffer.offset = ctx.GetBufferOffset(buffer.global_binding); + buffer.offset = ctx.GetBufferOffset(handle); } address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset); if constexpr (N == 1) { @@ -446,7 +446,7 @@ template static void EmitStoreBufferF32xN(EmitContext& ctx, u32 handle, Id address, Id value) { auto& buffer = ctx.buffers[handle]; if (!Sirit::ValidId(buffer.offset)) { - buffer.offset = ctx.GetBufferOffset(buffer.global_binding); + buffer.offset = ctx.GetBufferOffset(handle); } address = ctx.OpIAdd(ctx.U32[1], address, buffer.offset); const Id index = ctx.OpShiftRightLogical(ctx.U32[1], address, ctx.ConstU32(2u)); diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index 61b55437..cdf417fc 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -352,9 +352,9 @@ void EmitContext::DefineBuffers() { Decorate(id, spv::Decoration::DescriptorSet, 0U); Name(id, fmt::format("{}_{}", buffer.is_storage ? "ssbo" : "cbuf", buffer.sgpr_base)); + binding++; buffers.push_back({ .id = id, - .global_binding = binding++, .data_types = data_types, .pointer_type = pointer_type, .buffer = buffer.GetVsharp(info), diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.h b/src/shader_recompiler/backend/spirv/spirv_emit_context.h index 0d090eb3..ff9ec4b7 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.h +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.h @@ -203,7 +203,6 @@ public: struct BufferDefinition { Id id; Id offset; - u32 global_binding; const VectorIds* data_types; Id pointer_type; AmdGpu::Buffer buffer; diff --git a/src/video_core/buffer_cache/buffer_cache.cpp b/src/video_core/buffer_cache/buffer_cache.cpp index a89107ba..7ab0d817 100644 --- a/src/video_core/buffer_cache/buffer_cache.cpp +++ b/src/video_core/buffer_cache/buffer_cache.cpp @@ -1,6 +1,6 @@ // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#pragma clang optimize off + #include #include "common/alignment.h" #include "common/scope_exit.h" diff --git a/src/video_core/page_manager.cpp b/src/video_core/page_manager.cpp index a7fcaab4..6225f11b 100644 --- a/src/video_core/page_manager.cpp +++ b/src/video_core/page_manager.cpp @@ -10,11 +10,13 @@ #ifndef _WIN64 #include -#include #include #include #include #include +#ifdef ENABLE_USERFAULTFD +#include +#endif #else #include #endif @@ -191,7 +193,11 @@ struct PageManager::Impl { static void GuestFaultSignalHandler(int sig, siginfo_t* info, void* raw_context) { ucontext_t* ctx = reinterpret_cast(raw_context); const VAddr address = reinterpret_cast(info->si_addr); +#ifdef __APPLE__ + const u32 err = ctx->uc_mcontext->__es.__err; +#else const greg_t err = ctx->uc_mcontext.gregs[REG_ERR]; +#endif if (err & 0x2) { rasterizer->InvalidateMemory(address, sizeof(u64)); } else { diff --git a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp index 3345deb8..8a98e968 100644 --- a/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_compute_pipeline.cpp @@ -96,7 +96,7 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache, Shader::PushData push_data{}; u32 binding{}; - for (const auto& buffer : info.buffers) { + for (u32 i = 0; const auto& buffer : info.buffers) { const auto vsharp = buffer.GetVsharp(info); const VAddr address = vsharp.base_address; // Most of the time when a metadata is updated with a shader it gets cleared. It means we @@ -125,7 +125,7 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache, const u32 adjust = offset - offset_aligned; if (adjust != 0) { ASSERT(adjust % 4 == 0); - push_data.AddOffset(binding, adjust); + push_data.AddOffset(i, adjust); } buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust); set_writes.push_back({ @@ -137,6 +137,7 @@ bool ComputePipeline::BindResources(VideoCore::BufferCache& buffer_cache, : vk::DescriptorType::eUniformBuffer, .pBufferInfo = &buffer_infos.back(), }); + i++; } for (const auto& image_desc : info.images) { diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 5d87a1ca..91ff999e 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -343,7 +343,7 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs, push_data.step0 = regs.vgt_instance_step_rate_0; push_data.step1 = regs.vgt_instance_step_rate_1; } - for (const auto& buffer : stage.buffers) { + for (u32 i = 0; const auto& buffer : stage.buffers) { const auto vsharp = buffer.GetVsharp(stage); if (vsharp) { const VAddr address = vsharp.base_address; @@ -359,7 +359,7 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs, const u32 adjust = offset - offset_aligned; if (adjust != 0) { ASSERT(adjust % 4 == 0); - push_data.AddOffset(binding, adjust); + push_data.AddOffset(i, adjust); } buffer_infos.emplace_back(vk_buffer->Handle(), offset_aligned, size + adjust); } else { @@ -374,6 +374,7 @@ void GraphicsPipeline::BindResources(const Liverpool::Regs& regs, : vk::DescriptorType::eUniformBuffer, .pBufferInfo = &buffer_infos.back(), }); + i++; } boost::container::static_vector tsharps;