Skip to content

Commit 3a04186

Browse files
authored
Merge branch 'hrydgard:master' into master
2 parents 1325653 + b608257 commit 3a04186

File tree

163 files changed

+17874
-4812
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

163 files changed

+17874
-4812
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,8 @@ list(APPEND NativeAppSource
15281528
UI/ImDebugger/ImGe.h
15291529
UI/ImDebugger/ImDisasmView.cpp
15301530
UI/ImDebugger/ImDisasmView.h
1531+
UI/ImDebugger/ImMemView.cpp
1532+
UI/ImDebugger/ImMemView.h
15311533
UI/ImDebugger/ImStructViewer.cpp
15321534
UI/ImDebugger/ImStructViewer.h
15331535
UI/DiscordIntegration.cpp

Common/GPU/D3D11/thin3d_d3d11.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class D3D11Framebuffer : public Framebuffer {
7575
colorSRView->Release();
7676
if (depthSRView)
7777
depthSRView->Release();
78+
if (stencilSRView)
79+
stencilSRView->Release();
7880
if (depthStencilTex)
7981
depthStencilTex->Release();
8082
if (depthStencilRTView)
@@ -85,6 +87,7 @@ class D3D11Framebuffer : public Framebuffer {
8587
ID3D11RenderTargetView *colorRTView = nullptr;
8688
ID3D11ShaderResourceView *colorSRView = nullptr;
8789
ID3D11ShaderResourceView *depthSRView = nullptr;
90+
ID3D11ShaderResourceView *stencilSRView = nullptr;
8891
DXGI_FORMAT colorFormat = DXGI_FORMAT_UNKNOWN;
8992

9093
ID3D11Texture2D *depthStencilTex = nullptr;
@@ -1438,6 +1441,16 @@ void D3D11DrawContext::DrawIndexedClippedBatchUP(const void *vdata, int vertexCo
14381441
context_->PSSetShaderResources(0, 1, &view);
14391442
} else {
14401443
ID3D11ShaderResourceView *view = ((D3D11Framebuffer *)draws[i].bindFramebufferAsTex)->colorSRView;
1444+
switch (draws[i].aspect) {
1445+
case FB_DEPTH_BIT:
1446+
view = ((D3D11Framebuffer *)draws[i].bindFramebufferAsTex)->depthSRView;
1447+
break;
1448+
case FB_STENCIL_BIT:
1449+
view = ((D3D11Framebuffer *)draws[i].bindFramebufferAsTex)->stencilSRView;
1450+
break;
1451+
default:
1452+
break;
1453+
}
14411454
context_->PSSetShaderResources(0, 1, &view);
14421455
}
14431456
ID3D11SamplerState *sstate = ((D3D11SamplerState *)draws[i].samplerState)->ss;
@@ -1550,6 +1563,18 @@ Framebuffer *D3D11DrawContext::CreateFramebuffer(const FramebufferDesc &desc) {
15501563
WARN_LOG(Log::G3D, "Failed to create SRV for depth buffer.");
15511564
fb->depthSRView = nullptr;
15521565
}
1566+
1567+
1568+
D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilViewDesc{};
1569+
depthStencilViewDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
1570+
depthStencilViewDesc.Texture2D.MostDetailedMip = 0;
1571+
depthStencilViewDesc.Texture2D.MipLevels = 1;
1572+
depthStencilViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
1573+
hr = device_->CreateShaderResourceView(fb->depthStencilTex, &depthViewDesc, &fb->stencilSRView);
1574+
if (FAILED(hr)) {
1575+
WARN_LOG(Log::G3D, "Failed to create SRV for depth+stencil buffer.");
1576+
fb->depthSRView = nullptr;
1577+
}
15531578
}
15541579

15551580
return fb;

Common/GPU/Vulkan/thin3d_vulkan.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ void VKContext::DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, co
15991599
if (draw.bindTexture) {
16001600
BindTexture(0, draw.bindTexture);
16011601
} else if (draw.bindFramebufferAsTex) {
1602-
BindFramebufferAsTexture(draw.bindFramebufferAsTex, 0, FBChannel::FB_COLOR_BIT, 0);
1602+
BindFramebufferAsTexture(draw.bindFramebufferAsTex, 0, draw.aspect, 0);
16031603
} else if (draw.bindNativeTexture) {
16041604
BindNativeTexture(0, draw.bindNativeTexture);
16051605
}
@@ -1834,6 +1834,7 @@ void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChanne
18341834
aspect = VK_IMAGE_ASPECT_DEPTH_BIT;
18351835
break;
18361836
default:
1837+
// Hm, can we texture from stencil?
18371838
_assert_(false);
18381839
break;
18391840
}

Common/GPU/thin3d.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ struct ClippedDraw {
708708
void *bindNativeTexture;
709709
Draw::SamplerState *samplerState;
710710
Draw::Pipeline *pipeline;
711+
Draw::FBChannel aspect;
711712
};
712713

713714
class DrawContext {

Common/Render/Text/draw_text.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ void TextDrawer::MeasureStringRect(std::string_view str, const Bounds &bounds, f
167167
}
168168

169169
void TextDrawer::DrawStringRect(DrawBuffer &target, std::string_view str, const Bounds &bounds, uint32_t color, int align) {
170+
if (bounds.w < 0.0f || bounds.h < 0.0f) {
171+
return;
172+
}
170173
float x = bounds.x;
171174
float y = bounds.y;
172175
if (align & ALIGN_HCENTER) {

Common/TimeUtil.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,19 @@ class Instant {
4545
int64_t nsecs_;
4646
#endif
4747
};
48+
49+
class TimeCollector {
50+
public:
51+
TimeCollector(double *target, bool enable) : target_(enable ? target : nullptr) {
52+
if (enable)
53+
startTime_ = time_now_d();
54+
}
55+
~TimeCollector() {
56+
if (target_) {
57+
*target_ += time_now_d() - startTime_;
58+
}
59+
}
60+
private:
61+
double startTime_;
62+
double *target_;
63+
};

Core/Compatibility.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919

2020
#include "Common/Log.h"
2121
#include "Common/Data/Format/IniFile.h"
22+
#include "Common/Data/Text/I18n.h"
2223
#include "Common/File/VFS/VFS.h"
2324
#include "Common/StringUtils.h"
25+
#include "Common/System/OSD.h"
2426
#include "Core/Compatibility.h"
2527
#include "Core/Config.h"
2628
#include "Core/System.h"
@@ -41,6 +43,10 @@ void Compatibility::Load(const std::string &gameID) {
4143
// This loads from assets.
4244
if (compat.LoadFromVFS(g_VFS, "compat.ini")) {
4345
CheckSettings(compat, gameID);
46+
} else {
47+
auto e = GetI18NCategory(I18NCat::ERRORS);
48+
std::string msg = ApplySafeSubstitutions(e->T("File not found: %1"), "compat.ini");
49+
g_OSD.Show(OSDType::MESSAGE_ERROR, msg, 3.0f);
4450
}
4551
}
4652

Core/Core.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,24 +186,22 @@ void Core_RunLoopUntil(u64 globalticks) {
186186
break; // Will loop around to go to RUNNING_GE or NEXTFRAME, which will exit.
187187
case CORE_RUNNING_GE:
188188
switch (gpu->ProcessDLQueue()) {
189-
case DLResult::Break:
190-
GPUStepping::EnterStepping();
189+
case DLResult::DebugBreak:
190+
GPUStepping::EnterStepping(coreState);
191191
break;
192192
case DLResult::Error:
193-
// We should elegantly report the error, or I guess ignore it.
193+
// We should elegantly report the error somehow, or I guess ignore it.
194194
hleFinishSyscallAfterGe();
195195
coreState = preGeCoreState;
196196
break;
197-
case DLResult::Stall:
198197
case DLResult::Done:
199198
// Done executing for now
200199
hleFinishSyscallAfterGe();
201200
coreState = preGeCoreState;
202201
break;
203202
default:
203+
// Not a valid return value.
204204
_dbg_assert_(false);
205-
hleFinishSyscallAfterGe();
206-
coreState = preGeCoreState;
207205
break;
208206
}
209207
break;
@@ -395,8 +393,8 @@ void Core_Break(const char *reason, u32 relatedAddress) {
395393
return;
396394
}
397395

398-
// Stop the tracer
399396
{
397+
// Stop the tracer
400398
std::lock_guard<std::mutex> lock(g_stepMutex);
401399
if (!g_cpuStepCommand.empty() && Core_IsStepping()) {
402400
// If we're in a failed step that uses a temp breakpoint, we need to be able to override it here.

Core/Debugger/Breakpoints.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,12 @@ void BreakpointManager::Update(u32 addr) {
647647
System_Notify(SystemNotification::DISASSEMBLY);
648648
}
649649

650-
bool BreakpointManager::ValidateLogFormat(DebugInterface *cpu, const std::string &fmt) {
650+
bool BreakpointManager::ValidateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt) {
651651
std::string ignore;
652652
return EvaluateLogFormat(cpu, fmt, ignore);
653653
}
654654

655-
bool BreakpointManager::EvaluateLogFormat(DebugInterface *cpu, const std::string &fmt, std::string &result) {
655+
bool BreakpointManager::EvaluateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt, std::string &result) {
656656
PostfixExpression exp;
657657
result.clear();
658658

@@ -697,7 +697,7 @@ bool BreakpointManager::EvaluateLogFormat(DebugInterface *cpu, const std::string
697697
}
698698
}
699699

700-
if (!cpu->initExpression(expression.c_str(), exp)) {
700+
if (!initExpression(cpu, expression.c_str(), exp)) {
701701
return false;
702702
}
703703

@@ -707,7 +707,7 @@ bool BreakpointManager::EvaluateLogFormat(DebugInterface *cpu, const std::string
707707
float f;
708708
} expResult;
709709
char resultString[256];
710-
if (!cpu->parseExpression(exp, expResult.u)) {
710+
if (!parseExpression(cpu, exp, expResult.u)) {
711711
return false;
712712
}
713713

Core/Debugger/Breakpoints.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <atomic>
2222
#include <mutex>
2323

24-
#include "Core/Debugger/DebugInterface.h"
24+
#include "Core/MIPS/MIPSDebugInterface.h"
2525

2626
enum BreakAction : u32 {
2727
BREAK_ACTION_IGNORE = 0x00,
@@ -45,7 +45,7 @@ struct BreakPointCond {
4545

4646
u32 Evaluate() {
4747
u32 result;
48-
if (debug->parseExpression(expression, result) == false)
48+
if (parseExpression(debug, expression, result) == false)
4949
return 0;
5050
return result;
5151
}
@@ -185,8 +185,8 @@ class BreakpointManager {
185185

186186
void Update(u32 addr = 0);
187187

188-
bool ValidateLogFormat(DebugInterface *cpu, const std::string &fmt);
189-
bool EvaluateLogFormat(DebugInterface *cpu, const std::string &fmt, std::string &result);
188+
bool ValidateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt);
189+
bool EvaluateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt, std::string &result);
190190

191191
private:
192192
size_t FindBreakpoint(u32 addr, bool matchTemp = false, bool temp = false);

0 commit comments

Comments
 (0)