Skip to content

Commit

Permalink
Merge branch 'hrydgard:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanaobrien authored Dec 15, 2024
2 parents 1325653 + b608257 commit 3a04186
Show file tree
Hide file tree
Showing 163 changed files with 17,874 additions and 4,812 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1528,6 +1528,8 @@ list(APPEND NativeAppSource
UI/ImDebugger/ImGe.h
UI/ImDebugger/ImDisasmView.cpp
UI/ImDebugger/ImDisasmView.h
UI/ImDebugger/ImMemView.cpp
UI/ImDebugger/ImMemView.h
UI/ImDebugger/ImStructViewer.cpp
UI/ImDebugger/ImStructViewer.h
UI/DiscordIntegration.cpp
Expand Down
25 changes: 25 additions & 0 deletions Common/GPU/D3D11/thin3d_d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ class D3D11Framebuffer : public Framebuffer {
colorSRView->Release();
if (depthSRView)
depthSRView->Release();
if (stencilSRView)
stencilSRView->Release();
if (depthStencilTex)
depthStencilTex->Release();
if (depthStencilRTView)
Expand All @@ -85,6 +87,7 @@ class D3D11Framebuffer : public Framebuffer {
ID3D11RenderTargetView *colorRTView = nullptr;
ID3D11ShaderResourceView *colorSRView = nullptr;
ID3D11ShaderResourceView *depthSRView = nullptr;
ID3D11ShaderResourceView *stencilSRView = nullptr;
DXGI_FORMAT colorFormat = DXGI_FORMAT_UNKNOWN;

ID3D11Texture2D *depthStencilTex = nullptr;
Expand Down Expand Up @@ -1438,6 +1441,16 @@ void D3D11DrawContext::DrawIndexedClippedBatchUP(const void *vdata, int vertexCo
context_->PSSetShaderResources(0, 1, &view);
} else {
ID3D11ShaderResourceView *view = ((D3D11Framebuffer *)draws[i].bindFramebufferAsTex)->colorSRView;
switch (draws[i].aspect) {
case FB_DEPTH_BIT:
view = ((D3D11Framebuffer *)draws[i].bindFramebufferAsTex)->depthSRView;
break;
case FB_STENCIL_BIT:
view = ((D3D11Framebuffer *)draws[i].bindFramebufferAsTex)->stencilSRView;
break;
default:
break;
}
context_->PSSetShaderResources(0, 1, &view);
}
ID3D11SamplerState *sstate = ((D3D11SamplerState *)draws[i].samplerState)->ss;
Expand Down Expand Up @@ -1550,6 +1563,18 @@ Framebuffer *D3D11DrawContext::CreateFramebuffer(const FramebufferDesc &desc) {
WARN_LOG(Log::G3D, "Failed to create SRV for depth buffer.");
fb->depthSRView = nullptr;
}


D3D11_SHADER_RESOURCE_VIEW_DESC depthStencilViewDesc{};
depthStencilViewDesc.Format = DXGI_FORMAT_R24G8_TYPELESS;
depthStencilViewDesc.Texture2D.MostDetailedMip = 0;
depthStencilViewDesc.Texture2D.MipLevels = 1;
depthStencilViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
hr = device_->CreateShaderResourceView(fb->depthStencilTex, &depthViewDesc, &fb->stencilSRView);
if (FAILED(hr)) {
WARN_LOG(Log::G3D, "Failed to create SRV for depth+stencil buffer.");
fb->depthSRView = nullptr;
}
}

return fb;
Expand Down
3 changes: 2 additions & 1 deletion Common/GPU/Vulkan/thin3d_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1599,7 +1599,7 @@ void VKContext::DrawIndexedClippedBatchUP(const void *vdata, int vertexCount, co
if (draw.bindTexture) {
BindTexture(0, draw.bindTexture);
} else if (draw.bindFramebufferAsTex) {
BindFramebufferAsTexture(draw.bindFramebufferAsTex, 0, FBChannel::FB_COLOR_BIT, 0);
BindFramebufferAsTexture(draw.bindFramebufferAsTex, 0, draw.aspect, 0);
} else if (draw.bindNativeTexture) {
BindNativeTexture(0, draw.bindNativeTexture);
}
Expand Down Expand Up @@ -1834,6 +1834,7 @@ void VKContext::BindFramebufferAsTexture(Framebuffer *fbo, int binding, FBChanne
aspect = VK_IMAGE_ASPECT_DEPTH_BIT;
break;
default:
// Hm, can we texture from stencil?
_assert_(false);
break;
}
Expand Down
1 change: 1 addition & 0 deletions Common/GPU/thin3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ struct ClippedDraw {
void *bindNativeTexture;
Draw::SamplerState *samplerState;
Draw::Pipeline *pipeline;
Draw::FBChannel aspect;
};

class DrawContext {
Expand Down
3 changes: 3 additions & 0 deletions Common/Render/Text/draw_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ void TextDrawer::MeasureStringRect(std::string_view str, const Bounds &bounds, f
}

void TextDrawer::DrawStringRect(DrawBuffer &target, std::string_view str, const Bounds &bounds, uint32_t color, int align) {
if (bounds.w < 0.0f || bounds.h < 0.0f) {
return;
}
float x = bounds.x;
float y = bounds.y;
if (align & ALIGN_HCENTER) {
Expand Down
16 changes: 16 additions & 0 deletions Common/TimeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,19 @@ class Instant {
int64_t nsecs_;
#endif
};

class TimeCollector {
public:
TimeCollector(double *target, bool enable) : target_(enable ? target : nullptr) {
if (enable)
startTime_ = time_now_d();
}
~TimeCollector() {
if (target_) {
*target_ += time_now_d() - startTime_;
}
}
private:
double startTime_;
double *target_;
};
6 changes: 6 additions & 0 deletions Core/Compatibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

#include "Common/Log.h"
#include "Common/Data/Format/IniFile.h"
#include "Common/Data/Text/I18n.h"
#include "Common/File/VFS/VFS.h"
#include "Common/StringUtils.h"
#include "Common/System/OSD.h"
#include "Core/Compatibility.h"
#include "Core/Config.h"
#include "Core/System.h"
Expand All @@ -41,6 +43,10 @@ void Compatibility::Load(const std::string &gameID) {
// This loads from assets.
if (compat.LoadFromVFS(g_VFS, "compat.ini")) {
CheckSettings(compat, gameID);
} else {
auto e = GetI18NCategory(I18NCat::ERRORS);
std::string msg = ApplySafeSubstitutions(e->T("File not found: %1"), "compat.ini");
g_OSD.Show(OSDType::MESSAGE_ERROR, msg, 3.0f);
}
}

Expand Down
12 changes: 5 additions & 7 deletions Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,22 @@ void Core_RunLoopUntil(u64 globalticks) {
break; // Will loop around to go to RUNNING_GE or NEXTFRAME, which will exit.
case CORE_RUNNING_GE:
switch (gpu->ProcessDLQueue()) {
case DLResult::Break:
GPUStepping::EnterStepping();
case DLResult::DebugBreak:
GPUStepping::EnterStepping(coreState);
break;
case DLResult::Error:
// We should elegantly report the error, or I guess ignore it.
// We should elegantly report the error somehow, or I guess ignore it.
hleFinishSyscallAfterGe();
coreState = preGeCoreState;
break;
case DLResult::Stall:
case DLResult::Done:
// Done executing for now
hleFinishSyscallAfterGe();
coreState = preGeCoreState;
break;
default:
// Not a valid return value.
_dbg_assert_(false);
hleFinishSyscallAfterGe();
coreState = preGeCoreState;
break;
}
break;
Expand Down Expand Up @@ -395,8 +393,8 @@ void Core_Break(const char *reason, u32 relatedAddress) {
return;
}

// Stop the tracer
{
// Stop the tracer
std::lock_guard<std::mutex> lock(g_stepMutex);
if (!g_cpuStepCommand.empty() && Core_IsStepping()) {
// If we're in a failed step that uses a temp breakpoint, we need to be able to override it here.
Expand Down
8 changes: 4 additions & 4 deletions Core/Debugger/Breakpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,12 @@ void BreakpointManager::Update(u32 addr) {
System_Notify(SystemNotification::DISASSEMBLY);
}

bool BreakpointManager::ValidateLogFormat(DebugInterface *cpu, const std::string &fmt) {
bool BreakpointManager::ValidateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt) {
std::string ignore;
return EvaluateLogFormat(cpu, fmt, ignore);
}

bool BreakpointManager::EvaluateLogFormat(DebugInterface *cpu, const std::string &fmt, std::string &result) {
bool BreakpointManager::EvaluateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt, std::string &result) {
PostfixExpression exp;
result.clear();

Expand Down Expand Up @@ -697,7 +697,7 @@ bool BreakpointManager::EvaluateLogFormat(DebugInterface *cpu, const std::string
}
}

if (!cpu->initExpression(expression.c_str(), exp)) {
if (!initExpression(cpu, expression.c_str(), exp)) {
return false;
}

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

Expand Down
8 changes: 4 additions & 4 deletions Core/Debugger/Breakpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <atomic>
#include <mutex>

#include "Core/Debugger/DebugInterface.h"
#include "Core/MIPS/MIPSDebugInterface.h"

enum BreakAction : u32 {
BREAK_ACTION_IGNORE = 0x00,
Expand All @@ -45,7 +45,7 @@ struct BreakPointCond {

u32 Evaluate() {
u32 result;
if (debug->parseExpression(expression, result) == false)
if (parseExpression(debug, expression, result) == false)
return 0;
return result;
}
Expand Down Expand Up @@ -185,8 +185,8 @@ class BreakpointManager {

void Update(u32 addr = 0);

bool ValidateLogFormat(DebugInterface *cpu, const std::string &fmt);
bool EvaluateLogFormat(DebugInterface *cpu, const std::string &fmt, std::string &result);
bool ValidateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt);
bool EvaluateLogFormat(MIPSDebugInterface *cpu, const std::string &fmt, std::string &result);

private:
size_t FindBreakpoint(u32 addr, bool matchTemp = false, bool temp = false);
Expand Down
54 changes: 11 additions & 43 deletions Core/Debugger/DebugInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,51 +26,19 @@ struct MemMap;

class DebugInterface {
public:
virtual int getInstructionSize(int instruction) = 0;
virtual u32 GetPC() const = 0;
virtual u32 GetRA() const = 0;
virtual u32 GetHi() const = 0;
virtual u32 GetLo() const = 0;
virtual u32 GetLLBit() const = 0;
virtual u32 GetFPCond() const = 0;
virtual u32 GetGPR32Value(int reg) const = 0;

virtual bool isAlive() = 0;
virtual bool isBreakpoint(unsigned int address) = 0;
virtual void setBreakpoint(unsigned int address) = 0;
virtual void clearBreakpoint(unsigned int address) = 0;
virtual void clearAllBreakpoints() = 0;
virtual void toggleBreakpoint(unsigned int address) = 0;
virtual unsigned int readMemory(unsigned int address) {return 0;}
virtual unsigned int getPC() = 0;
virtual void setPC(unsigned int address) {}
virtual void step() {}
virtual void runToBreakpoint() {}
virtual int getColor(unsigned int address, bool darkMode) const {return darkMode ? 0xFF101010 : 0xFFFFFFFF;}
virtual std::string getDescription(unsigned int address) {return "";}
virtual bool initExpression(const char* exp, PostfixExpression& dest) { return false; };
virtual bool parseExpression(PostfixExpression& exp, u32& dest) { return false; };

virtual u32 GetHi() = 0;
virtual u32 GetLo() = 0;
virtual u32 GetLLBit() = 0;
virtual u32 GetFPCond() = 0;

virtual void SetHi(u32 val) { };
virtual void SetLo(u32 val) { };
virtual const char *GetName() = 0;
virtual u32 GetGPR32Value(int reg) = 0;
virtual void SetGPR32Value(int reg, u32 value) = 0;
virtual float GetFPR32Value(int reg) { return -1.0f; }
virtual float GetVPR32Value(int reg) { return -1.0f; }

virtual u32 GetPC() = 0;
virtual void SetPC(u32 _pc) = 0;
virtual u32 GetLR() = 0;

virtual void DisAsm(u32 pc, char *out, size_t outSize) = 0;
virtual void SetHi(u32 val) = 0;
virtual void SetLo(u32 val) = 0;

// More stuff for debugger
virtual int GetNumCategories() = 0;
virtual int GetNumRegsInCategory(int cat) = 0;
virtual const char *GetCategoryName(int cat) = 0;
virtual std::string GetRegName(int cat, int index) = 0;
virtual void PrintRegValue(int cat, int index, char *out, size_t outSize) {
snprintf(out, outSize, "%08X", GetGPR32Value(index));
}
virtual u32 GetRegValue(int cat, int index) = 0;
virtual u32 GetRegValue(int cat, int index) const = 0;
virtual void PrintRegValue(int cat, int index, char *out, size_t outSize) const = 0;
virtual void SetRegValue(int cat, int index, u32 value) {}
};
Loading

0 comments on commit 3a04186

Please sign in to comment.