summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/CMakeLists.txt2
-rw-r--r--src/common/break_points.cpp90
-rw-r--r--src/common/break_points.h49
-rw-r--r--src/common/misc.cpp2
-rw-r--r--src/common/x64/xbyak_abi.h20
-rw-r--r--src/common/x64/xbyak_util.h6
-rw-r--r--src/core/frontend/emu_window.h6
-rw-r--r--src/core/hle/kernel/svc.cpp7
-rw-r--r--src/core/hle/service/mm/mm_u.cpp83
-rw-r--r--src/core/hle/service/mm/mm_u.h15
-rw-r--r--src/core/loader/deconstructed_rom_directory.cpp1
-rw-r--r--src/core/loader/elf.cpp1
-rw-r--r--src/core/loader/loader.cpp6
-rw-r--r--src/core/loader/loader.h7
-rw-r--r--src/core/loader/nro.cpp1
-rw-r--r--src/core/loader/nso.cpp1
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp14
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h71
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp35
19 files changed, 145 insertions, 272 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index d5d4f6f82..939b8a7d3 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -29,8 +29,6 @@ add_library(common STATIC
29 assert.h 29 assert.h
30 bit_field.h 30 bit_field.h
31 bit_set.h 31 bit_set.h
32 break_points.cpp
33 break_points.h
34 cityhash.cpp 32 cityhash.cpp
35 cityhash.h 33 cityhash.h
36 color.h 34 color.h
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp
deleted file mode 100644
index fa367a4ca..000000000
--- a/src/common/break_points.cpp
+++ /dev/null
@@ -1,90 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <algorithm>
6#include <sstream>
7#include "common/break_points.h"
8
9bool BreakPoints::IsAddressBreakPoint(u32 iAddress) const {
10 auto cond = [&iAddress](const TBreakPoint& bp) { return bp.iAddress == iAddress; };
11 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
12 return it != m_BreakPoints.end();
13}
14
15bool BreakPoints::IsTempBreakPoint(u32 iAddress) const {
16 auto cond = [&iAddress](const TBreakPoint& bp) {
17 return bp.iAddress == iAddress && bp.bTemporary;
18 };
19 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
20 return it != m_BreakPoints.end();
21}
22
23BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const {
24 TBreakPointsStr bps;
25 for (auto breakpoint : m_BreakPoints) {
26 if (!breakpoint.bTemporary) {
27 std::stringstream bp;
28 bp << std::hex << breakpoint.iAddress << " " << (breakpoint.bOn ? "n" : "");
29 bps.push_back(bp.str());
30 }
31 }
32
33 return bps;
34}
35
36void BreakPoints::AddFromStrings(const TBreakPointsStr& bps) {
37 for (auto bps_item : bps) {
38 TBreakPoint bp;
39 std::stringstream bpstr;
40 bpstr << std::hex << bps_item;
41 bpstr >> bp.iAddress;
42 bp.bOn = bps_item.find("n") != bps_item.npos;
43 bp.bTemporary = false;
44 Add(bp);
45 }
46}
47
48void BreakPoints::Add(const TBreakPoint& bp) {
49 if (!IsAddressBreakPoint(bp.iAddress)) {
50 m_BreakPoints.push_back(bp);
51 // if (jit)
52 // jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
53 }
54}
55
56void BreakPoints::Add(u32 em_address, bool temp) {
57 if (!IsAddressBreakPoint(em_address)) // only add new addresses
58 {
59 TBreakPoint pt; // breakpoint settings
60 pt.bOn = true;
61 pt.bTemporary = temp;
62 pt.iAddress = em_address;
63
64 m_BreakPoints.push_back(pt);
65
66 // if (jit)
67 // jit->GetBlockCache()->InvalidateICache(em_address, 4);
68 }
69}
70
71void BreakPoints::Remove(u32 em_address) {
72 auto cond = [&em_address](const TBreakPoint& bp) { return bp.iAddress == em_address; };
73 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
74 if (it != m_BreakPoints.end())
75 m_BreakPoints.erase(it);
76}
77
78void BreakPoints::Clear() {
79 // if (jit)
80 //{
81 // std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(),
82 // [](const TBreakPoint& bp)
83 // {
84 // jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
85 // }
86 // );
87 //}
88
89 m_BreakPoints.clear();
90}
diff --git a/src/common/break_points.h b/src/common/break_points.h
deleted file mode 100644
index e15b9f842..000000000
--- a/src/common/break_points.h
+++ /dev/null
@@ -1,49 +0,0 @@
1// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <string>
8#include <vector>
9#include "common/common_types.h"
10
11class DebugInterface;
12
13struct TBreakPoint {
14 u32 iAddress;
15 bool bOn;
16 bool bTemporary;
17};
18
19// Code breakpoints.
20class BreakPoints {
21public:
22 typedef std::vector<TBreakPoint> TBreakPoints;
23 typedef std::vector<std::string> TBreakPointsStr;
24
25 const TBreakPoints& GetBreakPoints() {
26 return m_BreakPoints;
27 }
28
29 TBreakPointsStr GetStrings() const;
30 void AddFromStrings(const TBreakPointsStr& bps);
31
32 // is address breakpoint
33 bool IsAddressBreakPoint(u32 iAddress) const;
34 bool IsTempBreakPoint(u32 iAddress) const;
35
36 // Add BreakPoint
37 void Add(u32 em_address, bool temp = false);
38 void Add(const TBreakPoint& bp);
39
40 // Remove Breakpoint
41 void Remove(u32 iAddress);
42 void Clear();
43
44 void DeleteByAddress(u32 Address);
45
46private:
47 TBreakPoints m_BreakPoints;
48 u32 m_iBreakOnCount;
49};
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 217a87098..3fa8a3bc4 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -4,7 +4,7 @@
4 4
5#include <cstddef> 5#include <cstddef>
6#ifdef _WIN32 6#ifdef _WIN32
7#include <Windows.h> 7#include <windows.h>
8#else 8#else
9#include <cerrno> 9#include <cerrno>
10#include <cstring> 10#include <cstring>
diff --git a/src/common/x64/xbyak_abi.h b/src/common/x64/xbyak_abi.h
index fd3fbdd4b..927da9187 100644
--- a/src/common/x64/xbyak_abi.h
+++ b/src/common/x64/xbyak_abi.h
@@ -9,10 +9,9 @@
9#include "common/assert.h" 9#include "common/assert.h"
10#include "common/bit_set.h" 10#include "common/bit_set.h"
11 11
12namespace Common { 12namespace Common::X64 {
13namespace X64 {
14 13
15int RegToIndex(const Xbyak::Reg& reg) { 14inline int RegToIndex(const Xbyak::Reg& reg) {
16 using Kind = Xbyak::Reg::Kind; 15 using Kind = Xbyak::Reg::Kind;
17 ASSERT_MSG((reg.getKind() & (Kind::REG | Kind::XMM)) != 0, 16 ASSERT_MSG((reg.getKind() & (Kind::REG | Kind::XMM)) != 0,
18 "RegSet only support GPRs and XMM registers."); 17 "RegSet only support GPRs and XMM registers.");
@@ -152,8 +151,8 @@ constexpr size_t ABI_SHADOW_SPACE = 0;
152 151
153#endif 152#endif
154 153
155void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t needed_frame_size, 154inline void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t needed_frame_size,
156 s32* out_subtraction, s32* out_xmm_offset) { 155 s32* out_subtraction, s32* out_xmm_offset) {
157 int count = (regs & ABI_ALL_GPRS).Count(); 156 int count = (regs & ABI_ALL_GPRS).Count();
158 rsp_alignment -= count * 8; 157 rsp_alignment -= count * 8;
159 size_t subtraction = 0; 158 size_t subtraction = 0;
@@ -174,8 +173,8 @@ void ABI_CalculateFrameSize(BitSet32 regs, size_t rsp_alignment, size_t needed_f
174 *out_xmm_offset = (s32)(subtraction - xmm_base_subtraction); 173 *out_xmm_offset = (s32)(subtraction - xmm_base_subtraction);
175} 174}
176 175
177size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, 176inline size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs,
178 size_t rsp_alignment, size_t needed_frame_size = 0) { 177 size_t rsp_alignment, size_t needed_frame_size = 0) {
179 s32 subtraction, xmm_offset; 178 s32 subtraction, xmm_offset;
180 ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset); 179 ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset);
181 180
@@ -195,8 +194,8 @@ size_t ABI_PushRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs
195 return ABI_SHADOW_SPACE; 194 return ABI_SHADOW_SPACE;
196} 195}
197 196
198void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, size_t rsp_alignment, 197inline void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs,
199 size_t needed_frame_size = 0) { 198 size_t rsp_alignment, size_t needed_frame_size = 0) {
200 s32 subtraction, xmm_offset; 199 s32 subtraction, xmm_offset;
201 ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset); 200 ABI_CalculateFrameSize(regs, rsp_alignment, needed_frame_size, &subtraction, &xmm_offset);
202 201
@@ -217,5 +216,4 @@ void ABI_PopRegistersAndAdjustStack(Xbyak::CodeGenerator& code, BitSet32 regs, s
217 } 216 }
218} 217}
219 218
220} // namespace X64 219} // namespace Common::X64
221} // namespace Common
diff --git a/src/common/x64/xbyak_util.h b/src/common/x64/xbyak_util.h
index ec76e0a47..02323a017 100644
--- a/src/common/x64/xbyak_util.h
+++ b/src/common/x64/xbyak_util.h
@@ -8,8 +8,7 @@
8#include <xbyak.h> 8#include <xbyak.h>
9#include "common/x64/xbyak_abi.h" 9#include "common/x64/xbyak_abi.h"
10 10
11namespace Common { 11namespace Common::X64 {
12namespace X64 {
13 12
14// Constants for use with cmpps/cmpss 13// Constants for use with cmpps/cmpss
15enum { 14enum {
@@ -45,5 +44,4 @@ inline void CallFarFunction(Xbyak::CodeGenerator& code, const T f) {
45 } 44 }
46} 45}
47 46
48} // namespace X64 47} // namespace Common::X64
49} // namespace Common
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index 384dc7822..7006a37b3 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -34,9 +34,9 @@ class EmuWindow {
34public: 34public:
35 /// Data structure to store emuwindow configuration 35 /// Data structure to store emuwindow configuration
36 struct WindowConfig { 36 struct WindowConfig {
37 bool fullscreen; 37 bool fullscreen = false;
38 int res_width; 38 int res_width = 0;
39 int res_height; 39 int res_height = 0;
40 std::pair<unsigned, unsigned> min_client_area_size; 40 std::pair<unsigned, unsigned> min_client_area_size;
41 }; 41 };
42 42
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index b24f409b3..6be5c474e 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -250,8 +250,11 @@ static ResultCode ArbitrateUnlock(VAddr mutex_addr) {
250} 250}
251 251
252/// Break program execution 252/// Break program execution
253static void Break(u64 unk_0, u64 unk_1, u64 unk_2) { 253static void Break(u64 reason, u64 info1, u64 info2) {
254 LOG_CRITICAL(Debug_Emulated, "Emulated program broke execution!"); 254 LOG_CRITICAL(
255 Debug_Emulated,
256 "Emulated program broke execution! reason=0x{:016X}, info1=0x{:016X}, info2=0x{:016X}",
257 reason, info1, info2);
255 ASSERT(false); 258 ASSERT(false);
256} 259}
257 260
diff --git a/src/core/hle/service/mm/mm_u.cpp b/src/core/hle/service/mm/mm_u.cpp
index 08f45b78a..7b91bb258 100644
--- a/src/core/hle/service/mm/mm_u.cpp
+++ b/src/core/hle/service/mm/mm_u.cpp
@@ -9,42 +9,63 @@
9 9
10namespace Service::MM { 10namespace Service::MM {
11 11
12void InstallInterfaces(SM::ServiceManager& service_manager) { 12class MM_U final : public ServiceFramework<MM_U> {
13 std::make_shared<MM_U>()->InstallAsService(service_manager); 13public:
14} 14 explicit MM_U() : ServiceFramework{"mm:u"} {
15 // clang-format off
16 static const FunctionInfo functions[] = {
17 {0, &MM_U::Initialize, "InitializeOld"},
18 {1, &MM_U::Finalize, "FinalizeOld"},
19 {2, &MM_U::SetAndWait, "SetAndWaitOld"},
20 {3, &MM_U::Get, "GetOld"},
21 {4, &MM_U::Initialize, "Initialize"},
22 {5, &MM_U::Finalize, "Finalize"},
23 {6, &MM_U::SetAndWait, "SetAndWait"},
24 {7, &MM_U::Get, "Get"},
25 };
26 // clang-format on
15 27
16void MM_U::Initialize(Kernel::HLERequestContext& ctx) { 28 RegisterHandlers(functions);
17 LOG_WARNING(Service_MM, "(STUBBED) called"); 29 }
18 IPC::ResponseBuilder rb{ctx, 2};
19 rb.Push(RESULT_SUCCESS);
20}
21 30
22void MM_U::SetAndWait(Kernel::HLERequestContext& ctx) { 31private:
23 IPC::RequestParser rp{ctx}; 32 void Initialize(Kernel::HLERequestContext& ctx) {
24 min = rp.Pop<u32>(); 33 LOG_WARNING(Service_MM, "(STUBBED) called");
25 max = rp.Pop<u32>(); 34 IPC::ResponseBuilder rb{ctx, 2};
26 current = min; 35 rb.Push(RESULT_SUCCESS);
36 }
27 37
28 LOG_WARNING(Service_MM, "(STUBBED) called, min=0x{:X}, max=0x{:X}", min, max); 38 void Finalize(Kernel::HLERequestContext& ctx) {
29 IPC::ResponseBuilder rb{ctx, 2}; 39 LOG_WARNING(Service_MM, "(STUBBED) called");
30 rb.Push(RESULT_SUCCESS); 40 IPC::ResponseBuilder rb{ctx, 2};
31} 41 rb.Push(RESULT_SUCCESS);
42 }
32 43
33void MM_U::Get(Kernel::HLERequestContext& ctx) { 44 void SetAndWait(Kernel::HLERequestContext& ctx) {
34 LOG_WARNING(Service_MM, "(STUBBED) called"); 45 IPC::RequestParser rp{ctx};
35 IPC::ResponseBuilder rb{ctx, 3}; 46 min = rp.Pop<u32>();
36 rb.Push(RESULT_SUCCESS); 47 max = rp.Pop<u32>();
37 rb.Push(current); 48 current = min;
38}
39 49
40MM_U::MM_U() : ServiceFramework("mm:u") { 50 LOG_WARNING(Service_MM, "(STUBBED) called, min=0x{:X}, max=0x{:X}", min, max);
41 static const FunctionInfo functions[] = { 51 IPC::ResponseBuilder rb{ctx, 2};
42 {0, nullptr, "InitializeOld"}, {1, nullptr, "FinalizeOld"}, 52 rb.Push(RESULT_SUCCESS);
43 {2, nullptr, "SetAndWaitOld"}, {3, nullptr, "GetOld"}, 53 }
44 {4, &MM_U::Initialize, "Initialize"}, {5, nullptr, "Finalize"}, 54
45 {6, &MM_U::SetAndWait, "SetAndWait"}, {7, &MM_U::Get, "Get"}, 55 void Get(Kernel::HLERequestContext& ctx) {
46 }; 56 LOG_WARNING(Service_MM, "(STUBBED) called");
47 RegisterHandlers(functions); 57 IPC::ResponseBuilder rb{ctx, 3};
58 rb.Push(RESULT_SUCCESS);
59 rb.Push(current);
60 }
61
62 u32 min{0};
63 u32 max{0};
64 u32 current{0};
65};
66
67void InstallInterfaces(SM::ServiceManager& service_manager) {
68 std::make_shared<MM_U>()->InstallAsService(service_manager);
48} 69}
49 70
50} // namespace Service::MM 71} // namespace Service::MM
diff --git a/src/core/hle/service/mm/mm_u.h b/src/core/hle/service/mm/mm_u.h
index 79eeedf9c..5439fa653 100644
--- a/src/core/hle/service/mm/mm_u.h
+++ b/src/core/hle/service/mm/mm_u.h
@@ -8,21 +8,6 @@
8 8
9namespace Service::MM { 9namespace Service::MM {
10 10
11class MM_U final : public ServiceFramework<MM_U> {
12public:
13 MM_U();
14 ~MM_U() = default;
15
16private:
17 void Initialize(Kernel::HLERequestContext& ctx);
18 void SetAndWait(Kernel::HLERequestContext& ctx);
19 void Get(Kernel::HLERequestContext& ctx);
20
21 u32 min{0};
22 u32 max{0};
23 u32 current{0};
24};
25
26/// Registers all MM services with the specified service manager. 11/// Registers all MM services with the specified service manager.
27void InstallInterfaces(SM::ServiceManager& service_manager); 12void InstallInterfaces(SM::ServiceManager& service_manager);
28 13
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp
index de05f21d8..d575a9bea 100644
--- a/src/core/loader/deconstructed_rom_directory.cpp
+++ b/src/core/loader/deconstructed_rom_directory.cpp
@@ -118,7 +118,6 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
118 118
119 process->program_id = metadata.GetTitleID(); 119 process->program_id = metadata.GetTitleID();
120 process->svc_access_mask.set(); 120 process->svc_access_mask.set();
121 process->address_mappings = default_address_mappings;
122 process->resource_limit = 121 process->resource_limit =
123 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 122 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
124 process->Run(Memory::PROCESS_IMAGE_VADDR, metadata.GetMainThreadPriority(), 123 process->Run(Memory::PROCESS_IMAGE_VADDR, metadata.GetMainThreadPriority(),
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index 401cad3ab..6420a7f11 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -398,7 +398,6 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) {
398 398
399 process->LoadModule(codeset, codeset->entrypoint); 399 process->LoadModule(codeset, codeset->entrypoint);
400 process->svc_access_mask.set(); 400 process->svc_access_mask.set();
401 process->address_mappings = default_address_mappings;
402 401
403 // Attach the default resource limit (APPLICATION) to the process 402 // Attach the default resource limit (APPLICATION) to the process
404 process->resource_limit = 403 process->resource_limit =
diff --git a/src/core/loader/loader.cpp b/src/core/loader/loader.cpp
index 1f2f31535..b143f043c 100644
--- a/src/core/loader/loader.cpp
+++ b/src/core/loader/loader.cpp
@@ -17,12 +17,6 @@
17 17
18namespace Loader { 18namespace Loader {
19 19
20const std::initializer_list<Kernel::AddressMapping> default_address_mappings = {
21 {0x1FF50000, 0x8000, true}, // part of DSP RAM
22 {0x1FF70000, 0x8000, true}, // part of DSP RAM
23 {0x1F000000, 0x600000, false}, // entire VRAM
24};
25
26FileType IdentifyFile(FileSys::VirtualFile file) { 20FileType IdentifyFile(FileSys::VirtualFile file) {
27 FileType type; 21 FileType type;
28 22
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 285363549..6dffe451a 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <algorithm> 7#include <algorithm>
8#include <initializer_list>
9#include <memory> 8#include <memory>
10#include <string> 9#include <string>
11#include <utility> 10#include <utility>
@@ -208,12 +207,6 @@ protected:
208}; 207};
209 208
210/** 209/**
211 * Common address mappings found in most games, used for binary formats that don't have this
212 * information.
213 */
214extern const std::initializer_list<Kernel::AddressMapping> default_address_mappings;
215
216/**
217 * Identifies a bootable file and return a suitable loader 210 * Identifies a bootable file and return a suitable loader
218 * @param file The bootable file 211 * @param file The bootable file
219 * @return the best loader for this file 212 * @return the best loader for this file
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index 908d91eab..2179cf2ea 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -186,7 +186,6 @@ ResultStatus AppLoader_NRO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
186 } 186 }
187 187
188 process->svc_access_mask.set(); 188 process->svc_access_mask.set();
189 process->address_mappings = default_address_mappings;
190 process->resource_limit = 189 process->resource_limit =
191 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 190 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
192 process->Run(base_addr, THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE); 191 process->Run(base_addr, THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE);
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index fee7d58c6..a94558ac5 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -152,7 +152,6 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) {
152 LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), Memory::PROCESS_IMAGE_VADDR); 152 LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), Memory::PROCESS_IMAGE_VADDR);
153 153
154 process->svc_access_mask.set(); 154 process->svc_access_mask.set();
155 process->address_mappings = default_address_mappings;
156 process->resource_limit = 155 process->resource_limit =
157 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION); 156 Kernel::ResourceLimit::GetForCategory(Kernel::ResourceLimitCategory::APPLICATION);
158 process->Run(Memory::PROCESS_IMAGE_VADDR, THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE); 157 process->Run(Memory::PROCESS_IMAGE_VADDR, THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 5d58ebd4f..05f153599 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -119,7 +119,8 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
119 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 119 {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
120 true}, // BC7U 120 true}, // BC7U
121 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 121 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
122 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8 122 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // G8R8U
123 {GL_RG8, GL_RG, GL_BYTE, ComponentType::SNorm, false}, // G8R8S
123 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 124 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
124 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F 125 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F
125 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F 126 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F
@@ -260,7 +261,8 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
260 MortonCopy<true, PixelFormat::DXN2SNORM>, 261 MortonCopy<true, PixelFormat::DXN2SNORM>,
261 MortonCopy<true, PixelFormat::BC7U>, 262 MortonCopy<true, PixelFormat::BC7U>,
262 MortonCopy<true, PixelFormat::ASTC_2D_4X4>, 263 MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
263 MortonCopy<true, PixelFormat::G8R8>, 264 MortonCopy<true, PixelFormat::G8R8U>,
265 MortonCopy<true, PixelFormat::G8R8S>,
264 MortonCopy<true, PixelFormat::BGRA8>, 266 MortonCopy<true, PixelFormat::BGRA8>,
265 MortonCopy<true, PixelFormat::RGBA32F>, 267 MortonCopy<true, PixelFormat::RGBA32F>,
266 MortonCopy<true, PixelFormat::RG32F>, 268 MortonCopy<true, PixelFormat::RG32F>,
@@ -315,7 +317,8 @@ static constexpr std::array<void (*)(u32, u32, u32, std::vector<u8>&, Tegra::GPU
315 nullptr, 317 nullptr,
316 nullptr, 318 nullptr,
317 nullptr, 319 nullptr,
318 MortonCopy<false, PixelFormat::G8R8>, 320 MortonCopy<false, PixelFormat::G8R8U>,
321 MortonCopy<false, PixelFormat::G8R8S>,
319 MortonCopy<false, PixelFormat::BGRA8>, 322 MortonCopy<false, PixelFormat::BGRA8>,
320 MortonCopy<false, PixelFormat::RGBA32F>, 323 MortonCopy<false, PixelFormat::RGBA32F>,
321 MortonCopy<false, PixelFormat::RG32F>, 324 MortonCopy<false, PixelFormat::RG32F>,
@@ -461,7 +464,7 @@ static void ConvertS8Z24ToZ24S8(std::vector<u8>& data, u32 width, u32 height) {
461} 464}
462 465
463static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) { 466static void ConvertG8R8ToR8G8(std::vector<u8>& data, u32 width, u32 height) {
464 const auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::G8R8)}; 467 const auto bpp{CachedSurface::GetGLBytesPerPixel(PixelFormat::G8R8U)};
465 for (size_t y = 0; y < height; ++y) { 468 for (size_t y = 0; y < height; ++y) {
466 for (size_t x = 0; x < width; ++x) { 469 for (size_t x = 0; x < width; ++x) {
467 const size_t offset{bpp * (y * width + x)}; 470 const size_t offset{bpp * (y * width + x)};
@@ -493,7 +496,8 @@ static void ConvertFormatAsNeeded_LoadGLBuffer(std::vector<u8>& data, PixelForma
493 ConvertS8Z24ToZ24S8(data, width, height); 496 ConvertS8Z24ToZ24S8(data, width, height);
494 break; 497 break;
495 498
496 case PixelFormat::G8R8: 499 case PixelFormat::G8R8U:
500 case PixelFormat::G8R8S:
497 // Convert the G8R8 color format to R8G8, as OpenGL does not support G8R8. 501 // Convert the G8R8 color format to R8G8, as OpenGL does not support G8R8.
498 ConvertG8R8ToR8G8(data, width, height); 502 ConvertG8R8ToR8G8(data, width, height);
499 break; 503 break;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 36a41522b..37eef5ad0 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -43,36 +43,37 @@ struct SurfaceParams {
43 DXN2SNORM = 17, 43 DXN2SNORM = 17,
44 BC7U = 18, 44 BC7U = 18,
45 ASTC_2D_4X4 = 19, 45 ASTC_2D_4X4 = 19,
46 G8R8 = 20, 46 G8R8U = 20,
47 BGRA8 = 21, 47 G8R8S = 21,
48 RGBA32F = 22, 48 BGRA8 = 22,
49 RG32F = 23, 49 RGBA32F = 23,
50 R32F = 24, 50 RG32F = 24,
51 R16F = 25, 51 R32F = 25,
52 R16UNORM = 26, 52 R16F = 26,
53 R16S = 27, 53 R16UNORM = 27,
54 R16UI = 28, 54 R16S = 28,
55 R16I = 29, 55 R16UI = 29,
56 RG16 = 30, 56 R16I = 30,
57 RG16F = 31, 57 RG16 = 31,
58 RG16UI = 32, 58 RG16F = 32,
59 RG16I = 33, 59 RG16UI = 33,
60 RG16S = 34, 60 RG16I = 34,
61 RGB32F = 35, 61 RG16S = 35,
62 SRGBA8 = 36, 62 RGB32F = 36,
63 RG8U = 37, 63 SRGBA8 = 37,
64 RG8S = 38, 64 RG8U = 38,
65 RG32UI = 39, 65 RG8S = 39,
66 R32UI = 40, 66 RG32UI = 40,
67 R32UI = 41,
67 68
68 MaxColorFormat, 69 MaxColorFormat,
69 70
70 // DepthStencil formats 71 // DepthStencil formats
71 Z24S8 = 41, 72 Z24S8 = 42,
72 S8Z24 = 42, 73 S8Z24 = 43,
73 Z32F = 43, 74 Z32F = 44,
74 Z16 = 44, 75 Z16 = 45,
75 Z32FS8 = 45, 76 Z32FS8 = 46,
76 77
77 MaxDepthStencilFormat, 78 MaxDepthStencilFormat,
78 79
@@ -130,7 +131,8 @@ struct SurfaceParams {
130 4, // DXN2SNORM 131 4, // DXN2SNORM
131 4, // BC7U 132 4, // BC7U
132 4, // ASTC_2D_4X4 133 4, // ASTC_2D_4X4
133 1, // G8R8 134 1, // G8R8U
135 1, // G8R8S
134 1, // BGRA8 136 1, // BGRA8
135 1, // RGBA32F 137 1, // RGBA32F
136 1, // RG32F 138 1, // RG32F
@@ -187,7 +189,8 @@ struct SurfaceParams {
187 128, // DXN2SNORM 189 128, // DXN2SNORM
188 128, // BC7U 190 128, // BC7U
189 32, // ASTC_2D_4X4 191 32, // ASTC_2D_4X4
190 16, // G8R8 192 16, // G8R8U
193 16, // G8R8S
191 32, // BGRA8 194 32, // BGRA8
192 128, // RGBA32F 195 128, // RGBA32F
193 64, // RG32F 196 64, // RG32F
@@ -341,7 +344,15 @@ struct SurfaceParams {
341 static_cast<u32>(component_type)); 344 static_cast<u32>(component_type));
342 UNREACHABLE(); 345 UNREACHABLE();
343 case Tegra::Texture::TextureFormat::G8R8: 346 case Tegra::Texture::TextureFormat::G8R8:
344 return PixelFormat::G8R8; 347 switch (component_type) {
348 case Tegra::Texture::ComponentType::UNORM:
349 return PixelFormat::G8R8U;
350 case Tegra::Texture::ComponentType::SNORM:
351 return PixelFormat::G8R8S;
352 }
353 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
354 static_cast<u32>(component_type));
355 UNREACHABLE();
345 case Tegra::Texture::TextureFormat::R16_G16_B16_A16: 356 case Tegra::Texture::TextureFormat::R16_G16_B16_A16:
346 return PixelFormat::RGBA16F; 357 return PixelFormat::RGBA16F;
347 case Tegra::Texture::TextureFormat::BF10GF11RF11: 358 case Tegra::Texture::TextureFormat::BF10GF11RF11:
@@ -396,6 +407,8 @@ struct SurfaceParams {
396 UNREACHABLE(); 407 UNREACHABLE();
397 case Tegra::Texture::TextureFormat::ZF32: 408 case Tegra::Texture::TextureFormat::ZF32:
398 return PixelFormat::Z32F; 409 return PixelFormat::Z32F;
410 case Tegra::Texture::TextureFormat::Z16:
411 return PixelFormat::Z16;
399 case Tegra::Texture::TextureFormat::Z24S8: 412 case Tegra::Texture::TextureFormat::Z24S8:
400 return PixelFormat::Z24S8; 413 return PixelFormat::Z24S8;
401 case Tegra::Texture::TextureFormat::DXT1: 414 case Tegra::Texture::TextureFormat::DXT1:
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 6834d7085..dabf98b74 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -383,15 +383,13 @@ public:
383 } 383 }
384 } 384 }
385 385
386 std::string GetUniformIndirect(u64 index, s64 offset, const Register& index_reg, 386 std::string GetUniformIndirect(u64 cbuf_index, s64 offset, const std::string& index_str,
387 GLSLRegister::Type type) { 387 GLSLRegister::Type type) {
388 declr_const_buffers[index].MarkAsUsedIndirect(index, stage); 388 declr_const_buffers[cbuf_index].MarkAsUsedIndirect(cbuf_index, stage);
389 389
390 std::string final_offset = "((floatBitsToInt(" + GetRegister(index_reg, 0) + ") + " + 390 std::string final_offset = fmt::format("({} + {})", index_str, offset / 4);
391 std::to_string(offset) + ") / 4)"; 391 std::string value = 'c' + std::to_string(cbuf_index) + '[' + final_offset + " / 4][" +
392 392 final_offset + " % 4]";
393 std::string value =
394 'c' + std::to_string(index) + '[' + final_offset + " / 4][" + final_offset + " % 4]";
395 393
396 if (type == GLSLRegister::Type::Float) { 394 if (type == GLSLRegister::Type::Float) {
397 return value; 395 return value;
@@ -1355,11 +1353,16 @@ private:
1355 case OpCode::Id::LD_C: { 1353 case OpCode::Id::LD_C: {
1356 ASSERT_MSG(instr.ld_c.unknown == 0, "Unimplemented"); 1354 ASSERT_MSG(instr.ld_c.unknown == 0, "Unimplemented");
1357 1355
1356 // Add an extra scope and declare the index register inside to prevent
1357 // overwriting it in case it is used as an output of the LD instruction.
1358 shader.AddLine("{");
1359 ++shader.scope;
1360
1361 shader.AddLine("uint index = (" + regs.GetRegisterAsInteger(instr.gpr8, 0, false) +
1362 " / 4) & (MAX_CONSTBUFFER_ELEMENTS - 1);");
1363
1358 std::string op_a = 1364 std::string op_a =
1359 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 0, instr.gpr8, 1365 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 0, "index",
1360 GLSLRegister::Type::Float);
1361 std::string op_b =
1362 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 4, instr.gpr8,
1363 GLSLRegister::Type::Float); 1366 GLSLRegister::Type::Float);
1364 1367
1365 switch (instr.ld_c.type.Value()) { 1368 switch (instr.ld_c.type.Value()) {
@@ -1367,16 +1370,22 @@ private:
1367 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1); 1370 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1);
1368 break; 1371 break;
1369 1372
1370 case Tegra::Shader::UniformType::Double: 1373 case Tegra::Shader::UniformType::Double: {
1374 std::string op_b =
1375 regs.GetUniformIndirect(instr.cbuf36.index, instr.cbuf36.offset + 4,
1376 "index", GLSLRegister::Type::Float);
1371 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1); 1377 regs.SetRegisterToFloat(instr.gpr0, 0, op_a, 1, 1);
1372 regs.SetRegisterToFloat(instr.gpr0.Value() + 1, 0, op_b, 1, 1); 1378 regs.SetRegisterToFloat(instr.gpr0.Value() + 1, 0, op_b, 1, 1);
1373 break; 1379 break;
1374 1380 }
1375 default: 1381 default:
1376 LOG_CRITICAL(HW_GPU, "Unhandled type: {}", 1382 LOG_CRITICAL(HW_GPU, "Unhandled type: {}",
1377 static_cast<unsigned>(instr.ld_c.type.Value())); 1383 static_cast<unsigned>(instr.ld_c.type.Value()));
1378 UNREACHABLE(); 1384 UNREACHABLE();
1379 } 1385 }
1386
1387 --shader.scope;
1388 shader.AddLine("}");
1380 break; 1389 break;
1381 } 1390 }
1382 case OpCode::Id::ST_A: { 1391 case OpCode::Id::ST_A: {