Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psyqo GPU tweaks #1678

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/mips/psyqo/gpu.hh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,14 @@ namespace timer_literals {
* `gpu().armPeriodicTimer(1_s, callback)` will create a timer that
* fires every second.
*/
constexpr uint32_t operator""_ns(unsigned long long int value) { return value / 1'000; }
constexpr uint32_t operator""_us(unsigned long long int value) { return value; }
constexpr uint32_t operator""_ms(unsigned long long int value) { return value * 1'000; }
constexpr uint32_t operator""_s(unsigned long long int value) { return value * 1'000'000; }
consteval uint32_t operator""_ns(unsigned long long int value) { return value / 1'000; }
consteval uint32_t operator""_us(unsigned long long int value) { return value; }
consteval uint32_t operator""_ms(unsigned long long int value) { return value * 1'000; }
consteval uint32_t operator""_s(unsigned long long int value) { return value * 1'000'000; }
consteval uint32_t operator""_ns(long double value) { return value / 1'000; }
consteval uint32_t operator""_us(long double value) { return value; }
consteval uint32_t operator""_ms(long double value) { return value * 1'000; }
consteval uint32_t operator""_s(long double value) { return value * 1'000'000; }

} // namespace timer_literals

Expand All @@ -85,6 +89,7 @@ class GPU {
enum class VideoMode { AUTO, NTSC, PAL };
enum class ColorMode { C15BITS, C24BITS };
enum class Interlace { PROGRESSIVE, INTERLACED };
enum class MiscSetting { CLEAR_VRAM, KEEP_VRAM };
void initialize(const Configuration &config);

static constexpr uint32_t US_PER_HBLANK = 64;
Expand Down
13 changes: 13 additions & 0 deletions src/mips/psyqo/internal/gpu/configuration.hh
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ struct psyqo::GPU::Configuration {
config.vResolution = interlace == Interlace::INTERLACED ? VR_480 : VR_240;
return *this;
}
Configuration &set(MiscSetting setting) {
switch (setting) {
case MiscSetting::CLEAR_VRAM:
clearVRAM = true;
break;
case MiscSetting::KEEP_VRAM:
clearVRAM = false;
break;
}
return *this;
}

private:
enum HResolution {
Expand Down Expand Up @@ -125,5 +136,7 @@ struct psyqo::GPU::Configuration {
};

DisplayModeConfig config = {};
bool clearVRAM = true;

friend class GPU;
};
8 changes: 5 additions & 3 deletions src/mips/psyqo/src/gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@
syscall_enableEvent(event);
syscall_enableTimerIRQ(3);
syscall_setTimerAutoAck(3, 1);
Prim::FastFill ff;
ff.rect = Rect{0, 0, 1024, 512};
sendPrimitive(ff);
if (config.clearVRAM) {
Prim::FastFill ff;
ff.rect = Rect{0, 0, 1024, 512};
sendPrimitive(ff);
}

Check warning on line 124 in src/mips/psyqo/src/gpu.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Complex Method

psyqo::GPU::initialize increases in cyclomatic complexity from 17 to 18, threshold = 9. This function has many conditional statements (e.g. if, for, while), leading to lower code health. Avoid adding more conditionals and code to it without refactoring.
// Enable Display
Hardware::GPU::Ctrl = 0x03000000;
Kernel::enableDma(Kernel::DMA::GPU);
Expand Down
Loading