Skip to content

Commit

Permalink
Merge pull request #1554 from grumpycoders/gpu-parser-fixes
Browse files Browse the repository at this point in the history
Fixing parsing of sizes in GPU
  • Loading branch information
nicolasnoble authored Jan 24, 2024
2 parents 41c5d3a + e9cc0d7 commit de48a69
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/core/gpu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ void GPU::Rect<size, textured, blend, modulation>::processWrite(Buffer & buf, Lo
value = buf.get();
[[fallthrough]];
case READ_HW:
w = GPU::signExtend<int, 11>(value & 0xffff);
h = GPU::signExtend<int, 11>(value >> 16);
w = value & 0xffff;
h = value >> 16;
}
}
m_state = READ_COLOR;
Expand Down Expand Up @@ -824,8 +824,8 @@ void PCSX::GPU::BlitVramVram::processWrite(Buffer &buf, Logged::Origin origin, u
[[fallthrough]];
case READ_HW:
value = buf.get();
w = signExtend<int, 11>(value & 0xffff);
h = signExtend<int, 11>(value >> 16);
w = value & 0xffff;
h = value >> 16;
raw.sX = sX;
raw.sY = sY;
raw.dX = dX;
Expand All @@ -844,7 +844,7 @@ void PCSX::GPU::BlitVramVram::processWrite(Buffer &buf, Logged::Origin origin, u

void PCSX::GPU::BlitRamVram::processWrite(Buffer &buf, Logged::Origin origin, uint32_t origvalue, uint32_t length) {
uint32_t value;
size_t size;
size_t size = (w * h + 1) / 2;
bool done = false;
switch (m_state) {
case READ_COMMAND:
Expand All @@ -860,25 +860,23 @@ void PCSX::GPU::BlitRamVram::processWrite(Buffer &buf, Logged::Origin origin, ui
[[fallthrough]];
case READ_HW:
value = buf.get();
w = signExtend<int, 11>(value & 0xffff);
h = signExtend<int, 11>(value >> 16);
w = value & 0xffff;
h = value >> 16;
size = (w * h + 1) / 2;
size *= 4;
m_data.clear();
m_data.reserve(size * 4);
m_state = READ_PIXELS;
if (buf.isEmpty()) return;
[[fallthrough]];
case READ_PIXELS:
size = (w * h + 1) / 2;
if ((buf.size() >= size) && (m_data.empty())) {
data.borrow(buf.data(), size * 4);
buf.consume(size);
done = true;
} else {
size_t toConsume = std::min(buf.size(), size - (m_data.size() / 4));
size_t toConsume = std::min(buf.size(), size - m_data.size() / 4);
m_data.append(reinterpret_cast<const char *>(buf.data()), toConsume * 4);
done = m_data.size() == (size * 4);
done = m_data.size() == size * 4;
buf.consume(toConsume);
if (done) {
data.acquire(std::move(m_data));
Expand Down Expand Up @@ -919,8 +917,8 @@ void PCSX::GPU::BlitVramRam::processWrite(Buffer &buf, Logged::Origin origin, ui
[[fallthrough]];
case READ_HW:
value = buf.get();
w = signExtend<int, 11>(value & 0xffff);
h = signExtend<int, 11>(value >> 16);
w = value & 0xffff;
h = value >> 16;
raw.x = x;
raw.y = y;
raw.w = w;
Expand Down

0 comments on commit de48a69

Please sign in to comment.