Force 16 Word limit for Linked List GPU

This commit is contained in:
2024-02-07 22:04:28 -05:00
parent 507615df97
commit 77c0dd28db
5 changed files with 99 additions and 46 deletions

View File

@@ -1,51 +1,103 @@
#pragma once
#include <PSX/GPU/gpu.hpp>
#include <PSX/GPU/make_gpu_primitives.hpp>
#include <PSX/System/IOPorts/dma_io.hpp>
namespace ScreenCenter {
using namespace JabyEngine;
// TODO: Fit these pieces into 16Word buffers (sizeof(T) >> 2 == words)
// TODO: Can we DMA all of this?
class Frame : public GPU::internal::LinkedElementCreator<Frame> {
class Frame {
private:
GPU::TILE top_left[2];
GPU::TILE top_right[2];
GPU::TILE bottom_left[2];
GPU::TILE bottom_right[2];
GPU::LINE_G_MULTI<5> border;
GPU::LINE_G_SINGLE cross[2];
struct TopBorder : public GPU::internal::LinkedElementCreator<TopBorder> {
GPU::TILE top_left[2];
GPU::TILE top_right[2];
static constexpr TopBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) {
TopBorder frame;
frame.top_left[0] = Make::TILE(Make::AreaI16(0, 0, Size.width, Size.height), BaseColor);
frame.top_left[1] = Make::TILE(Make::AreaI16(0, 0, Size.height, Size.width), BaseColor);
frame.top_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, 0, Size.width, Size.height), BaseColor);
frame.top_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, 0, Size.height, Size.width), BaseColor);
return frame.linked();
}
};
struct BottomBorder : GPU::internal::LinkedElementCreator<BottomBorder> {
GPU::TILE bottom_left[2];
GPU::TILE bottom_right[2];
static constexpr BottomBorder::Linked create(GPU::Color24 BaseColor, GPU::SizeI16 Size) {
BottomBorder frame;
frame.bottom_left[0] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
frame.bottom_left[1] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
frame.bottom_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
frame.bottom_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
return frame.linked();
}
};
struct LineBorder : GPU::internal::LinkedElementCreator<LineBorder> {
GPU::LINE_G_MULTI<5> border;
static constexpr LineBorder::Linked create() {
LineBorder frame;
frame.border = Make::LINE_G(
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)},
GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, GPU::Display::Height - 1)},
GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(GPU::Display::Width - 1, GPU::Display::Height - 1)},
GPU::ColorVertex{GPU::Color24::Yellow(), Make::Vertex(GPU::Display::Width - 1, 0)},
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)}
);
return frame.linked();
}
};
struct LineCross : GPU::internal::LinkedElementCreator<LineCross> {
GPU::LINE_G_SINGLE cross[2];
static constexpr LineCross::Linked create(const decltype(LineBorder::border)& border) {
LineCross frame;
frame.cross[0] = Make::LINE_G(border[0], border[2]);
frame.cross[1] = Make::LINE_G(border[3], border[1]);
return frame.linked();
}
};
TopBorder::Linked top_border;
BottomBorder::Linked bottom_border;
LineBorder::Linked line_border;
LineCross::Linked line_cross;
public:
static constexpr Frame::Linked create() {
static constexpr Frame create() {
constexpr auto BaseColor = GPU::Color24::from_rgb(0x1D, 0xA0, 0xA3);
constexpr auto Size = Make::SizeI16(64, 16);
Frame frame;
frame.top_left[0] = Make::TILE(Make::AreaI16(0, 0, Size.width, Size.height), BaseColor);
frame.top_left[1] = Make::TILE(Make::AreaI16(0, 0, Size.height, Size.width), BaseColor);
frame.top_border = TopBorder::create(BaseColor, Size);
frame.bottom_border = BottomBorder::create(BaseColor, Size);
frame.line_border = LineBorder::create();
frame.line_cross = LineCross::create(frame.line_border->border);
return frame;
}
frame.top_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, 0, Size.width, Size.height), BaseColor);
frame.top_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, 0, Size.height, Size.width), BaseColor);
void setup() {
// TODO: I want this in one line
this->top_border.concat(this->bottom_border);
this->bottom_border.concat(this->line_border);
this->line_border.concat(this->line_cross);
}
frame.bottom_left[0] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
frame.bottom_left[1] = Make::TILE(Make::AreaI16(0, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
frame.bottom_right[0] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.height, GPU::Display::Height - Size.width, Size.height, Size.width), BaseColor);
frame.bottom_right[1] = Make::TILE(Make::AreaI16(GPU::Display::Width - Size.width, GPU::Display::Height - Size.height, Size.width, Size.height), BaseColor);
frame.border = Make::LINE_G(
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)},
GPU::ColorVertex{GPU::Color24::Green(), Make::Vertex(0, GPU::Display::Height - 1)},
GPU::ColorVertex{GPU::Color24::Blue(), Make::Vertex(GPU::Display::Width - 1, GPU::Display::Height - 1)},
GPU::ColorVertex{GPU::Color24::Yellow(), Make::Vertex(GPU::Display::Width - 1, 0)},
GPU::ColorVertex{GPU::Color24::Red(), Make::Vertex(0, 0)}
);
frame.cross[0] = Make::LINE_G(frame.border[0], frame.border[2]);
frame.cross[1] = Make::LINE_G(frame.border[3], frame.border[1]);
return frame.linked();
void render() const {
GPU::render(this->top_border);
}
};
}

View File

@@ -77,7 +77,7 @@ namespace ScreenCenter {
Formular{.name = PSYQ::Name, .function = PSYQ::set_offset}
};
static const auto frame = Frame::create();
static auto frame = Frame::create();
static ButtonPulser button_pulse[4];
static void (*update)() = nullptr;
@@ -160,6 +160,7 @@ namespace ScreenCenter {
static void setup() {
Shared::back_menu.reset();
frame.setup();
for(auto& pulse : button_pulse) {
pulse.setup();
@@ -182,7 +183,7 @@ namespace ScreenCenter {
}
static void render() {
GPU::render(frame);
frame.render();
Shared::back_menu.render();
}