From 88266ba0ee28d36204e3e99b304e9f3651846654 Mon Sep 17 00:00:00 2001 From: Jaby Date: Wed, 14 Jun 2023 21:39:48 +0200 Subject: [PATCH] Move GPU tests into an Overlay --- examples/PoolBox/application/Makefile | 2 +- examples/PoolBox/application/Overlays.json | 3 + .../application/src/GPUTests/gpu_tests.cpp | 193 ++++++++++++++++++ examples/PoolBox/application/src/main.cpp | 192 +---------------- examples/PoolBox/iso/Config.xml | 2 +- 5 files changed, 200 insertions(+), 192 deletions(-) create mode 100644 examples/PoolBox/application/src/GPUTests/gpu_tests.cpp diff --git a/examples/PoolBox/application/Makefile b/examples/PoolBox/application/Makefile index 71f4711e..efce152f 100644 --- a/examples/PoolBox/application/Makefile +++ b/examples/PoolBox/application/Makefile @@ -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 diff --git a/examples/PoolBox/application/Overlays.json b/examples/PoolBox/application/Overlays.json index 0e5d7be0..9a450a0e 100644 --- a/examples/PoolBox/application/Overlays.json +++ b/examples/PoolBox/application/Overlays.json @@ -2,6 +2,9 @@ "slot_0": { "timer_tests": { "pattern": "bin/*/src/TimerTests/*.o" + }, + "gpu_tests": { + "pattern": "bin/*/src/GPUTests/*.o" } } } \ No newline at end of file diff --git a/examples/PoolBox/application/src/GPUTests/gpu_tests.cpp b/examples/PoolBox/application/src/GPUTests/gpu_tests.cpp new file mode 100644 index 00000000..0d4966b3 --- /dev/null +++ b/examples/PoolBox/application/src/GPUTests/gpu_tests.cpp @@ -0,0 +1,193 @@ +#include +#include +#include +#include +#include + +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); \ No newline at end of file diff --git a/examples/PoolBox/application/src/main.cpp b/examples/PoolBox/application/src/main.cpp index ca776915..ef5c08a2 100644 --- a/examples/PoolBox/application/src/main.cpp +++ b/examples/PoolBox/application/src/main.cpp @@ -1,193 +1,5 @@ -#include -#include -#include -#include #include -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); \ No newline at end of file + printf("Planschbecken c:\n"); +} \ No newline at end of file diff --git a/examples/PoolBox/iso/Config.xml b/examples/PoolBox/iso/Config.xml index c2ef9bf9..cad8f163 100644 --- a/examples/PoolBox/iso/Config.xml +++ b/examples/PoolBox/iso/Config.xml @@ -5,7 +5,7 @@ iso/System.cnf -
application/bin/PSX-release/PoolBox.psexe
+
application/bin/PSX-release/PoolBox.psexe
assets/bin/TexturePage.bin assets/bin/IconTexture.bin