Skip to content

Commit

Permalink
GPU registers: Fix writes to some registers ignoring the mask (#725)
Browse files Browse the repository at this point in the history
Co-authored-by: henry <23128103+atem2069@users.noreply.github.com>
  • Loading branch information
wheremyfoodat and Atem2069 authored Feb 21, 2025
1 parent 2da7941 commit 0a0ea75
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/PICA/regs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
break;

case VertexShaderOpDescriptorIndex: {
shaderUnit.vs.setOpDescriptorIndex(value);
shaderUnit.vs.setOpDescriptorIndex(newValue);
break;
}

Expand All @@ -301,15 +301,15 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
}

case VertexBoolUniform: {
shaderUnit.vs.uploadBoolUniform(value & 0xffff);
shaderUnit.vs.uploadBoolUniform(newValue & 0xffff);
break;
}

case VertexIntUniform0:
case VertexIntUniform1:
case VertexIntUniform2:
case VertexIntUniform3: {
shaderUnit.vs.uploadIntUniform(index - VertexIntUniform0, value);
shaderUnit.vs.uploadIntUniform(index - VertexIntUniform0, newValue);
break;
}

Expand All @@ -326,7 +326,7 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
}

case VertexShaderEntrypoint: {
shaderUnit.vs.entrypoint = value & 0xffff;
shaderUnit.vs.entrypoint = newValue & 0xffff;
break;
}

Expand All @@ -336,13 +336,13 @@ void GPU::writeInternalReg(u32 index, u32 value, u32 mask) {
break;
*/

case VertexShaderTransferIndex: shaderUnit.vs.setBufferIndex(value); break;
case VertexShaderTransferIndex: shaderUnit.vs.setBufferIndex(newValue); break;

// Command lists can write to the command processor registers and change the command list stream
// Several games are known to do this, including New Super Mario Bros 2 and Super Mario 3D Land
case CmdBufTrigger0:
case CmdBufTrigger1: {
if (value != 0) { // A non-zero value triggers command list processing
if (newValue != 0) { // A non-zero value triggers command list processing
int bufferIndex = index - CmdBufTrigger0; // Index of the command buffer to execute (0 or 1)
u32 addr = (regs[CmdBufAddr0 + bufferIndex] & 0xfffffff) << 3;
u32 size = (regs[CmdBufSize0 + bufferIndex] & 0xfffff) << 3;
Expand Down

0 comments on commit 0a0ea75

Please sign in to comment.