mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
Avoid memory access functions that can cause memory exceptions in ImDebugger. Minor opt.
This commit is contained in:
@@ -1141,7 +1141,6 @@ void DrawEngineCommon::FlushQueuedDepth() {
|
||||
|
||||
const bool collectStats = coreCollectDebugStats;
|
||||
const bool lowQ = g_Config.iDepthRasterMode == (int)DepthRasterMode::LOW_QUALITY;
|
||||
|
||||
for (const auto &draw : depthDraws_) {
|
||||
int *tx = depthScreenVerts_;
|
||||
int *ty = depthScreenVerts_ + DEPTH_SCREENVERTS_COMPONENT_COUNT;
|
||||
@@ -1168,9 +1167,13 @@ void DrawEngineCommon::FlushQueuedDepth() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
if (outVertCount > 0) {
|
||||
TimeCollector collectStat(&gpuStats.msRasterizeDepth, collectStats);
|
||||
DepthRasterScreenVerts((uint16_t *)Memory::GetPointerWrite(draw.depthAddr), draw.depthStride, tx, ty, tz, outVertCount, draw, tileScissor, lowQ);
|
||||
if (!Memory::IsValid4AlignedAddress(draw.depthAddr)) {
|
||||
continue;
|
||||
}
|
||||
u16 *depthPtr = (uint16_t *)Memory::GetPointerWriteUnchecked(draw.depthAddr);
|
||||
DepthRasterScreenVerts(depthPtr, draw.depthStride, tx, ty, tz, outVertCount, draw, tileScissor, lowQ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1344,6 +1344,9 @@ void DrawMediaDecodersView(ImConfig &cfg, ImControl &control) {
|
||||
if (ctx->BufferState() == ATRAC_STATUS_ALL_DATA_LOADED) {
|
||||
if (ImGui::Button("Save to disk...")) {
|
||||
System_BrowseForFileSave(cfg.requesterToken, "Save AT3 file", "song.at3", BrowseFileType::ATRAC3, [=](const std::string &filename, int) {
|
||||
if (!Memory::IsValidRange(info.buffer, info.bufferByte)) {
|
||||
return;
|
||||
}
|
||||
const u8 *data = Memory::GetPointerRange(info.buffer, info.bufferByte);
|
||||
if (!data) {
|
||||
return;
|
||||
|
||||
+12
-8
@@ -426,31 +426,34 @@ bool ImGePixelViewer::FormatValueAt(char *buf, size_t bufSize, int x, int y) con
|
||||
// Go look directly in RAM.
|
||||
int bpp = BufferFormatBytesPerPixel(format);
|
||||
u32 pixelAddr = addr + (y * stride + x) * bpp;
|
||||
if (!Memory::IsValidAddress(pixelAddr)) {
|
||||
return false;
|
||||
}
|
||||
switch (format) {
|
||||
case GE_FORMAT_8888:
|
||||
snprintf(buf, bufSize, "%08x", Memory::Read_U32(pixelAddr));
|
||||
snprintf(buf, bufSize, "%08x", Memory::ReadUnchecked_U32(pixelAddr));
|
||||
break;
|
||||
case GE_FORMAT_4444:
|
||||
{
|
||||
u16 raw = Memory::Read_U16(pixelAddr);
|
||||
u16 raw = Memory::ReadUnchecked_U16(pixelAddr);
|
||||
snprintf(buf, bufSize, "%08x (raw: %04x)", RGBA4444ToRGBA8888(raw), raw);
|
||||
break;
|
||||
}
|
||||
case GE_FORMAT_565:
|
||||
{
|
||||
u16 raw = Memory::Read_U16(pixelAddr);
|
||||
u16 raw = Memory::ReadUnchecked_U16(pixelAddr);
|
||||
snprintf(buf, bufSize, "%08x (raw: %04x)", RGB565ToRGBA8888(raw), raw);
|
||||
break;
|
||||
}
|
||||
case GE_FORMAT_5551:
|
||||
{
|
||||
u16 raw = Memory::Read_U16(pixelAddr);
|
||||
u16 raw = Memory::ReadUnchecked_U16(pixelAddr);
|
||||
snprintf(buf, bufSize, "%08x (raw: %04x)", RGBA5551ToRGBA8888(raw), raw);
|
||||
break;
|
||||
}
|
||||
case GE_FORMAT_DEPTH16:
|
||||
{
|
||||
u16 raw = Memory::Read_U16(pixelAddr);
|
||||
u16 raw = Memory::ReadUnchecked_U16(pixelAddr);
|
||||
snprintf(buf, bufSize, "%0.4f (raw: %04x / %d)", (float)raw / 65535.0f, raw, raw);
|
||||
break;
|
||||
}
|
||||
@@ -779,7 +782,7 @@ void ImGeDisasmView::Draw(GPUDebugInterface *gpuDebug) {
|
||||
if (Memory::IsValid4AlignedAddress(addr)) {
|
||||
draw_list->AddText(lineStart, 0xFFC0C0C0, addrBuffer);
|
||||
|
||||
u32 opcode = Memory::Read_U32(addr);
|
||||
u32 opcode = Memory::ReadUnchecked_U32(addr);
|
||||
GPUDebugOp op = gpuDebug->DisassembleOp(addr, opcode);
|
||||
u32 color = 0xFFFFFFFF;
|
||||
char temp[16];
|
||||
@@ -842,7 +845,7 @@ void ImGeDisasmView::Draw(GPUDebugInterface *gpuDebug) {
|
||||
}
|
||||
} else if (Memory::IsValid4AlignedAddress(dragAddr_)) {
|
||||
char buffer[64];
|
||||
u32 opcode = Memory::Read_U32(dragAddr_);
|
||||
u32 opcode = Memory::ReadUnchecked_U32(dragAddr_);
|
||||
GPUDebugOp op = gpuDebug->DisassembleOp(dragAddr_, opcode);
|
||||
// affect dragAddr_?
|
||||
if (ImGui::MenuItem("Copy Address", NULL, false)) {
|
||||
@@ -1182,7 +1185,8 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
|
||||
DisplayList list;
|
||||
bool isOnBlockTransfer = false;
|
||||
if (gpuDebug->GetCurrentDisplayList(list)) {
|
||||
op = Memory::Read_U32(list.pc);
|
||||
_dbg_assert_(Memory::IsValid4AlignedAddress(list.pc));
|
||||
op = Memory::ReadUnchecked_U32(list.pc);
|
||||
|
||||
// TODO: Also add support for block transfer previews!
|
||||
|
||||
|
||||
@@ -998,7 +998,7 @@ void ImMemDumpWindow::Draw(ImConfig &cfg, MIPSDebugInterface *debug) {
|
||||
errorMsg_ = "Couldn't open file for writing";
|
||||
} else {
|
||||
if (mode_ == MemDumpMode::Raw) {
|
||||
const uint8_t *ptr = Memory::GetPointer(address_);
|
||||
const uint8_t *ptr = Memory::GetPointerUnchecked(address_);
|
||||
fwrite(ptr, 1, size_, file);
|
||||
} else {
|
||||
std::string disassembly = DisassembleRange(address_, size_, true, debug);
|
||||
|
||||
Reference in New Issue
Block a user