Move GPU tests into an Overlay

This commit is contained in:
jaby 2023-06-14 21:39:48 +02:00
parent 50a2fc3128
commit 4b02b9a7d2
5 changed files with 200 additions and 192 deletions

View File

@ -7,7 +7,7 @@ include $(JABY_ENGINE_DIR)/lib/Wildcard.mk
SRCS = $(call rwildcard, src, c cpp)
INCLUDES += -I$(JABY_ENGINE_DIR)/include
CCFLAGS += -save-temps=obj
#CCFLAGS += -save-temps=obj
include $(JABY_ENGINE_DIR)/lib/Makefile
include $(JABY_ENGINE_DIR)/lib/PSEXETarget.mk

View File

@ -2,6 +2,9 @@
"slot_0": {
"timer_tests": {
"pattern": "bin/*/src/TimerTests/*.o"
},
"gpu_tests": {
"pattern": "bin/*/src/GPUTests/*.o"
}
}
}

View File

@ -0,0 +1,193 @@
#include <PSX/File/Processor/cd_file_processor.hpp>
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
#include <PSX/GPU/gpu.hpp>
#include <PSX/GPU/gpu_primitives.hpp>
#include <stdio.h>
enum LBA {
__jabyengine_start_lba_request
__jabyengine_request_lba_for(FONT, "ASSETS/FONT.BIN"),
__jabyengine_request_lba_for(ICON, "ASSETS/ICON.BIN"),
__jabyengine_end_lba_request
};
using namespace JabyEngine;
// Some default values for the objects
static constexpr auto TriangleColor = GPU::Color24(0x0, 0xFF, 0xFF);
static constexpr auto TriangleArea = GPU::AreaI16({0, 0}, {64, 64});
static constexpr auto TriangleTPage = GPU::TPage(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
static constexpr auto TriangleClut = GPU::PageClut(320, 511);
static constexpr auto RectangleColor = GPU::Color24(0x80, 0x80, 0xFF);
static constexpr auto RectangleArea = GPU::AreaI16({0, TriangleArea.size.height}, {80, 80});
static constexpr auto RectangleTPage = GPU::TPage(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
static constexpr auto RectangleClut = GPU::PageClut(320, 510);
static constexpr auto LineColor = GPU::Color24(0xFF, 0x0, 0x0);
static constexpr const auto triangle1 = GPU::POLY_F3({
{TriangleArea.position.x, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.size.height},
{TriangleArea.position.x, TriangleArea.size.height}},
TriangleColor
);
static constexpr const auto triangle2 = GPU::POLY_FT3({
{TriangleArea.position.x, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.size.height}},{
// Texture
{TriangleArea.position.x, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.size.height}},
TriangleTPage,
TriangleClut,
GPU::Color24::Grey()
);
static constexpr const auto triangle3 = GPU::POLY_G3({
{triangle1.vertex0.move(TriangleArea.size.width, 0), GPU::Color24::Red()},
{triangle1.vertex1.move(TriangleArea.size.width, 0), GPU::Color24::Green()},
{triangle1.vertex2.move(TriangleArea.size.width, 0), GPU::Color24::Blue()}}
);
static constexpr const auto triangle4 = GPU::POLY_GT3({
{triangle2.vertex0.move(TriangleArea.size.width, 0), triangle2.page0, GPU::Color24::Red()},
{triangle2.vertex1.move(TriangleArea.size.width, 0), triangle2.page1, GPU::Color24::Blue()},
{triangle2.vertex2.move(TriangleArea.size.width, 0), triangle2.page2, GPU::Color24::Green()}},
TriangleTPage,
TriangleClut
);
static constexpr const auto rectangle1 = GPU::POLY_F4(RectangleArea, RectangleColor);
static constexpr const auto rectangle2 = GPU::POLY_FT4({
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size}, {0, 0},
RectangleTPage,
RectangleClut,
GPU::Color24::Grey()
);
static constexpr const auto rectangle3 = GPU::POLY_G4(
{RectangleArea.position.move(RectangleArea.size.width*2, 0), RectangleArea.size}, {
GPU::Color24::Red(),
GPU::Color24::Blue(),
GPU::Color24::Green(),
GPU::Color24::White()});
static constexpr const auto rectangle4 = GPU::POLY_GT4(
{RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size}, {0, 0},
RectangleTPage,
RectangleClut, {
GPU::Color24::Red(),
GPU::Color24::Blue(),
GPU::Color24::Green(),
GPU::Color24::White()}
);
static constexpr const auto rectangle5 = GPU::POLY_GT4(
{RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size}, {0, 0},
RectangleTPage,
RectangleClut, {
GPU::Color24::Red(),
GPU::Color24::Blue(),
GPU::Color24::Green(),
GPU::Color24::White()}
).set_semi_transparent(true);
static constexpr const auto line1 = GPU::LINE_F::create(LineColor,
{0, 0},
{GPU::Display::Width, GPU::Display::Height}
);
static constexpr const auto line2 = GPU::LINE_F::create(LineColor.invert(),
GPU::Vertex(0, 0),
GPU::Vertex(16, 0),
GPU::Vertex(16, 16),
GPU::Vertex(0, 0)
);
static constexpr const auto line3 = GPU::LINE_G::create(
{LineColor, {GPU::Display::Width, 0}},
{LineColor.invert(), {0, GPU::Display::Height}}
);
static constexpr const auto line4 = GPU::LINE_G::create(
GPU::ColorVertex{GPU::Color24::Red(), {0, 0}},
GPU::ColorVertex{GPU::Color24::Green(), {0, 16}},
GPU::ColorVertex{GPU::Color24::Blue(), {16, 16}},
GPU::ColorVertex{GPU::Color24::White(), {0, 0}}
);
static constexpr const auto rect1 = GPU::TILE(GPU::AreaI16({GPU::Display::Width - 32, GPU::Display::Height - 32}, {32, 32}), GPU::Color24::Green());
static constexpr const auto rect2 = GPU::TILE_16({GPU::Display::Width - 16, GPU::Display::Height - 16}, GPU::Color24::Blue());
static constexpr const auto rect3 = GPU::TILE_8({GPU::Display::Width - 8, GPU::Display::Height - 8}, GPU::Color24::Yellow());
static constexpr const auto rect4 = GPU::TILE_1({GPU::Display::Width - 1, GPU::Display::Height - 1}, GPU::Color24::Red());
static constexpr const auto texpage = GPU::TexPage({320, 0}, GPU::TexturePageColor::$4bit);
static constexpr const auto rect5 = GPU::SPRT(GPU::AreaI16({0, GPU::Display::Height - 32}, {32, 32}), {{0, 0}, TriangleClut}, GPU::Color24::Green());
static constexpr const auto rect6 = GPU::SPRT_16({0, GPU::Display::Height - 16}, {{0, 0}, TriangleClut}, GPU::Color24::Blue());
static constexpr const auto rect7 = GPU::SPRT_8({0, GPU::Display::Height - 8}, {{0, 0}, TriangleClut}, GPU::Color24::Yellow());
static constexpr const auto rect8 = GPU::SPRT_1({0, GPU::Display::Height - 1}, {{0, 0}, TriangleClut}, GPU::Color24::Red());
static auto rect9 = GPU::SPRT(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked();
static auto rect10 = GPU::SPRT(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2 - 32}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked();
static void load_assets() {
static const CDFile Assets[] = {
CDFileBuilder::simple_tim(LBA::FONT, SimpleTIM(320, 0, 320, 511)),
CDFileBuilder::simple_tim(LBA::ICON, SimpleTIM(320, 256, 320, 510)),
};
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
CDFileProcessor file_processor;
file_processor.setup(lba, Assets, buffer_cfg);
while(true) {
switch(file_processor.process()) {
case Progress::InProgress:
break;
case Progress::Done:
if(!file_processor.next(lba, buffer_cfg)) {
return;
}
break;
case Progress::Error:
printf("Error detected! Aborting load\n");
return;
}
}
printf("Done loading assets!\n");
}
void test_gpu() {
load_assets();
rect9.concat(rect10);
while(true) {
GPU::render(triangle1);
GPU::render(triangle2);
GPU::render(triangle3);
GPU::render(triangle4);
GPU::render(rectangle1);
GPU::render(rectangle2);
GPU::render(rectangle3);
GPU::render(rectangle4);
GPU::render(rectangle5);
GPU::render(rect1);
GPU::render(rect2);
GPU::render(rect3);
GPU::render(rect4);
GPU::render(texpage);
GPU::render(rect5);
GPU::render(rect6);
GPU::render(rect7);
GPU::render(rect8);
GPU::render(line1);
GPU::render(line2);
GPU::render(line3);
GPU::render(line4);
GPU::render(rect9);
GPU::swap_buffers_vsync(2);
}
}
__declare_lba_header(LBA);

View File

@ -1,193 +1,5 @@
#include <PSX/File/Processor/cd_file_processor.hpp>
#include <PSX/AutoLBA/auto_lba_declaration.hpp>
#include <PSX/GPU/gpu.hpp>
#include <PSX/GPU/gpu_primitives.hpp>
#include <stdio.h>
enum LBA {
__jabyengine_start_lba_request
__jabyengine_request_lba_for(FONT, "ASSETS/FONT.BIN"),
__jabyengine_request_lba_for(ICON, "ASSETS/ICON.BIN"),
__jabyengine_end_lba_request
};
using namespace JabyEngine;
// Some default values for the objects
static constexpr auto TriangleColor = GPU::Color24(0x0, 0xFF, 0xFF);
static constexpr auto TriangleArea = GPU::AreaI16({0, 0}, {64, 64});
static constexpr auto TriangleTPage = GPU::TPage(320, 0, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
static constexpr auto TriangleClut = GPU::PageClut(320, 511);
static constexpr auto RectangleColor = GPU::Color24(0x80, 0x80, 0xFF);
static constexpr auto RectangleArea = GPU::AreaI16({0, TriangleArea.size.height}, {80, 80});
static constexpr auto RectangleTPage = GPU::TPage(320, 256, GPU::SemiTransparency::B_Half_add_F_Half, GPU::TexturePageColor::$4bit);
static constexpr auto RectangleClut = GPU::PageClut(320, 510);
static constexpr auto LineColor = GPU::Color24(0xFF, 0x0, 0x0);
static constexpr const auto triangle1 = GPU::POLY_F3({
{TriangleArea.position.x, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.size.height},
{TriangleArea.position.x, TriangleArea.size.height}},
TriangleColor
);
static constexpr const auto triangle2 = GPU::POLY_FT3({
{TriangleArea.position.x, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.size.height}},{
// Texture
{TriangleArea.position.x, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.position.y},
{TriangleArea.size.width, TriangleArea.size.height}},
TriangleTPage,
TriangleClut,
GPU::Color24::Grey()
);
static constexpr const auto triangle3 = GPU::POLY_G3({
{triangle1.vertex0.move(TriangleArea.size.width, 0), GPU::Color24::Red()},
{triangle1.vertex1.move(TriangleArea.size.width, 0), GPU::Color24::Green()},
{triangle1.vertex2.move(TriangleArea.size.width, 0), GPU::Color24::Blue()}}
);
static constexpr const auto triangle4 = GPU::POLY_GT3({
{triangle2.vertex0.move(TriangleArea.size.width, 0), triangle2.page0, GPU::Color24::Red()},
{triangle2.vertex1.move(TriangleArea.size.width, 0), triangle2.page1, GPU::Color24::Blue()},
{triangle2.vertex2.move(TriangleArea.size.width, 0), triangle2.page2, GPU::Color24::Green()}},
TriangleTPage,
TriangleClut
);
static constexpr const auto rectangle1 = GPU::POLY_F4(RectangleArea, RectangleColor);
static constexpr const auto rectangle2 = GPU::POLY_FT4({
RectangleArea.position.move(RectangleArea.size.width, 0), RectangleArea.size}, {0, 0},
RectangleTPage,
RectangleClut,
GPU::Color24::Grey()
);
static constexpr const auto rectangle3 = GPU::POLY_G4(
{RectangleArea.position.move(RectangleArea.size.width*2, 0), RectangleArea.size}, {
GPU::Color24::Red(),
GPU::Color24::Blue(),
GPU::Color24::Green(),
GPU::Color24::White()});
static constexpr const auto rectangle4 = GPU::POLY_GT4(
{RectangleArea.position.move(RectangleArea.size.width*3, 0), RectangleArea.size}, {0, 0},
RectangleTPage,
RectangleClut, {
GPU::Color24::Red(),
GPU::Color24::Blue(),
GPU::Color24::Green(),
GPU::Color24::White()}
);
static constexpr const auto rectangle5 = GPU::POLY_GT4(
{RectangleArea.position.move(0, RectangleArea.size.height), RectangleArea.size}, {0, 0},
RectangleTPage,
RectangleClut, {
GPU::Color24::Red(),
GPU::Color24::Blue(),
GPU::Color24::Green(),
GPU::Color24::White()}
).set_semi_transparent(true);
static constexpr const auto line1 = GPU::LINE_F::create(LineColor,
{0, 0},
{GPU::Display::Width, GPU::Display::Height}
);
static constexpr const auto line2 = GPU::LINE_F::create(LineColor.invert(),
GPU::Vertex(0, 0),
GPU::Vertex(16, 0),
GPU::Vertex(16, 16),
GPU::Vertex(0, 0)
);
static constexpr const auto line3 = GPU::LINE_G::create(
{LineColor, {GPU::Display::Width, 0}},
{LineColor.invert(), {0, GPU::Display::Height}}
);
static constexpr const auto line4 = GPU::LINE_G::create(
GPU::ColorVertex{GPU::Color24::Red(), {0, 0}},
GPU::ColorVertex{GPU::Color24::Green(), {0, 16}},
GPU::ColorVertex{GPU::Color24::Blue(), {16, 16}},
GPU::ColorVertex{GPU::Color24::White(), {0, 0}}
);
static constexpr const auto rect1 = GPU::TILE(GPU::AreaI16({GPU::Display::Width - 32, GPU::Display::Height - 32}, {32, 32}), GPU::Color24::Green());
static constexpr const auto rect2 = GPU::TILE_16({GPU::Display::Width - 16, GPU::Display::Height - 16}, GPU::Color24::Blue());
static constexpr const auto rect3 = GPU::TILE_8({GPU::Display::Width - 8, GPU::Display::Height - 8}, GPU::Color24::Yellow());
static constexpr const auto rect4 = GPU::TILE_1({GPU::Display::Width - 1, GPU::Display::Height - 1}, GPU::Color24::Red());
static constexpr const auto texpage = GPU::TexPage({320, 0}, GPU::TexturePageColor::$4bit);
static constexpr const auto rect5 = GPU::SPRT(GPU::AreaI16({0, GPU::Display::Height - 32}, {32, 32}), {{0, 0}, TriangleClut}, GPU::Color24::Green());
static constexpr const auto rect6 = GPU::SPRT_16({0, GPU::Display::Height - 16}, {{0, 0}, TriangleClut}, GPU::Color24::Blue());
static constexpr const auto rect7 = GPU::SPRT_8({0, GPU::Display::Height - 8}, {{0, 0}, TriangleClut}, GPU::Color24::Yellow());
static constexpr const auto rect8 = GPU::SPRT_1({0, GPU::Display::Height - 1}, {{0, 0}, TriangleClut}, GPU::Color24::Red());
static auto rect9 = GPU::SPRT(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked();
static auto rect10 = GPU::SPRT(GPU::AreaI16({GPU::Display::Width/2, GPU::Display::Height/2 - 32}, {32, 32}).centered(), {{0, 0}, TriangleClut}, GPU::Color24::Grey()).linked();
static void load_assets() {
static const CDFile Assets[] = {
CDFileBuilder::simple_tim(LBA::FONT, SimpleTIM(320, 0, 320, 511)),
CDFileBuilder::simple_tim(LBA::ICON, SimpleTIM(320, 256, 320, 510)),
};
const auto buffer_cfg = CDFileProcessor::BufferConfiguration::new_default();
CDFileProcessor file_processor;
file_processor.setup(lba, Assets, buffer_cfg);
while(true) {
switch(file_processor.process()) {
case Progress::InProgress:
break;
case Progress::Done:
if(!file_processor.next(lba, buffer_cfg)) {
return;
}
break;
case Progress::Error:
printf("Error detected! Aborting load\n");
return;
}
}
printf("Done loading assets!\n");
}
void main() {
load_assets();
rect9.concat(rect10);
while(true) {
GPU::render(triangle1);
GPU::render(triangle2);
GPU::render(triangle3);
GPU::render(triangle4);
GPU::render(rectangle1);
GPU::render(rectangle2);
GPU::render(rectangle3);
GPU::render(rectangle4);
GPU::render(rectangle5);
GPU::render(rect1);
GPU::render(rect2);
GPU::render(rect3);
GPU::render(rect4);
GPU::render(texpage);
GPU::render(rect5);
GPU::render(rect6);
GPU::render(rect7);
GPU::render(rect8);
GPU::render(line1);
GPU::render(line2);
GPU::render(line3);
GPU::render(line4);
GPU::render(rect9);
GPU::swap_buffers_vsync(2);
}
}
__declare_lba_header(LBA);
printf("Planschbecken c:\n");
}

View File

@ -5,7 +5,7 @@
</Description>
<Track>
<File name = "SYSTEM.CNF">iso/System.cnf</File>
<Main name = "XXXX_AAA.AA" lba_source = "application/src/main.cpp">application/bin/PSX-release/PoolBox.psexe</Main>
<Main name = "XXXX_AAA.AA">application/bin/PSX-release/PoolBox.psexe</Main>
<Directory name="ASSETS">
<File name = "FONT.BIN" lz4 = "already">assets/bin/TexturePage.bin</File>
<File name = "ICON.BIN" lz4 = "already">assets/bin/IconTexture.bin</File>