Skip to content

Commit

Permalink
Added Allow Texture Disable test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Dec 3, 2019
1 parent 99ef16c commit 42352ae
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 11 deletions.
68 changes: 57 additions & 11 deletions gpu/gp0-e1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,31 @@ void drawTexturedPolygon(uint16_t texpage) {
DrawPrim(&p);
}

// Allow setting E1.11 bit
void allowTextureDisable(bool allow) {
writeGP1(0x09, allow);
}

// Check if writing zeroes to GP0_E1 == what GPSTAT read
void testWriteZerosToE1() {
writeGP1(0x09, 0); // Disable E1.11 bit
writeGP0(0xe1,0x000);
allowTextureDisable(false); // Disable E1.11 bit
writeGP0(0xe1, 0x000);

assertEquals((ReadGPUstat() & E1_MASK), 0b00000000'00000000);
}

// Check if writing ones to GP0_E1 == what GPSTAT read (no "Texture Disable")
void testWriteOnesToE1() {
writeGP1(0x09, 0); // Disable E1.11 bit
allowTextureDisable(false);
writeGP0(0xe1, 0xfff);

assertEquals((ReadGPUstat() & E1_MASK), 0b00000111'11111111);
}

// Check if writing ones to GP0_E1 == what GPSTAT read (with "Texture Disable")
void testWriteOnesToE1WithTextureDisable() {
writeGP1(0x09, 1); // Enable E1.11 bit
writeGP0(0xe1,0xfff);
allowTextureDisable(true);
writeGP0(0xe1, 0xfff);

assertEquals((ReadGPUstat() & E1_MASK), 0b10000111'11111111);
}
Expand All @@ -48,38 +53,79 @@ void testWriteOnesToE1WithTextureDisable() {
// vv - These two bits can be set via GP0_E1, but not via draw command
// 0b10000111'11111111
void testTexturedPolygons() {
writeGP1(0x09, 0); // Disable E1.11 bit
writeGP0(0xe1,0x000);
allowTextureDisable(false);
writeGP0(0xe1, 0x000);
drawTexturedPolygon(0xffff);

assertEquals((ReadGPUstat() & E1_MASK), 0b0000001'11111111);
}

// Check which bits in GP0_E1 are changed by Textured Polygon draw commands (Texture Disable allowed)
void testTexturedPolygonsTextureDisable() {
writeGP1(0x09, 1); // Enable E1.11 bit
writeGP0(0xe1,0x000);
allowTextureDisable(true);
writeGP0(0xe1, 0x000);
drawTexturedPolygon(0xffff);

assertEquals((ReadGPUstat() & E1_MASK), 0b10000001'11111111);
}

// Check if drawing textured polygons doesn't change other bits in E1 register
void testTexturedPolygonsDoesNotChangeOtherBits() {
writeGP1(0x09, 1); // Enable E1.11 bit
allowTextureDisable(true);
writeGP0(0xe1,0xfff);
drawTexturedPolygon(0x0000);

assertEquals((ReadGPUstat() & E1_MASK), 0b00000110'00000000);
}

// Check if write to "Texture disabled" bit in e1 is ignored when "Allow Texture Disable" is unset
void testTextureDisableBitIsIgnoredWhenNotAllowed() {
allowTextureDisable(false);
writeGP0(0xe1, 1<<11); // Write Texture disabled bit

assertEquals(ReadGPUstat() & 0b10000000'00000000, 0 << 15);
}

// Check if write to "Texture disabled" bit in e1 is allowed when "Allow Texture Disable" is set
void testTextureDisableBitIsWrittenWhenAllowed() {
allowTextureDisable(true);
writeGP0(0xe1, 1<<11);

assertEquals(ReadGPUstat() & 0b10000000'00000000, 1 << 15);
}

// Check if "Texture disabled" bit is preserved when disabling "Allow Texture Disable"
// Conclusion - "Allow Texture Disable" Bit only prevents write to this bit, read is unaffected
void testUnsetAllowTextureDisablePreservesBit() {
allowTextureDisable(true);
writeGP0(0xe1, 1<<11);
allowTextureDisable(false);

assertEquals(ReadGPUstat() & 0b10000000'00000000, 1 << 15);
}

// Check if "Texture disabled" bit is cleared after write if "Allow Texture Disable" is unset
// Note - you cannot preserve this bit in e1 after write
void testUnsetAllowTextureDisableClearsBitAfterWrite() {
allowTextureDisable(true);
writeGP0(0xe1, 1<<11);
allowTextureDisable(false);
writeGP0(0xe1, 0); // Clear Texture disabled bit

assertEquals(ReadGPUstat() & 0b10000000'00000000, 0);
}

void runTests() {
testWriteZerosToE1();
testWriteOnesToE1();
testWriteOnesToE1WithTextureDisable();
testTexturedPolygons();
testTexturedPolygonsTextureDisable();
testTexturedPolygonsDoesNotChangeOtherBits();
testTextureDisableBitIsIgnoredWhenNotAllowed();
testTextureDisableBitIsWrittenWhenAllowed();
testUnsetAllowTextureDisablePreservesBit();
testUnsetAllowTextureDisableClearsBitAfterWrite();

printf("Done.\n");
}
Expand All @@ -94,7 +140,7 @@ int main() {
runTests();

for (;;) {
VSync(0);
VSync(false);
}
return 0;
}
4 changes: 4 additions & 0 deletions gpu/gp0-e1/psx.log
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ pass - testWriteOnesToE1WithTextureDisable
pass - testTexturedPolygons
pass - testTexturedPolygonsTextureDisable
pass - testTexturedPolygonsDoesNotChangeOtherBits
pass - testTextureDisableBitIsIgnoredWhenNotAllowed
pass - testTextureDisableBitIsWrittenWhenAllowed
pass - testUnsetAllowTextureDisablePreservesBit
pass - testUnsetAllowTextureDisableClearsBitAfterWrite
Done.

0 comments on commit 42352ae

Please sign in to comment.