Change to double buffering and SPRT_16
This commit is contained in:
parent
5dc3b78393
commit
3c73cc88e7
|
@ -37,6 +37,14 @@ namespace JabyEngine {
|
|||
static void set_offset(uint16_t x, uint16_t y);
|
||||
};
|
||||
|
||||
static uint32_t update_id() {
|
||||
return Display::current_id;
|
||||
}
|
||||
|
||||
static uint32_t render_id() {
|
||||
return Display::current_id ^ 1;
|
||||
}
|
||||
|
||||
namespace internal {
|
||||
void render(const uint32_t* data, size_t words);
|
||||
void render_dma(const uint32_t* data);
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#include <PSX/GPU/make_gpu_primitives.hpp>
|
||||
|
||||
namespace JabyEngine {
|
||||
using FontPrimitive = GPU::SPRT::Linked;
|
||||
using FontPrimitive = GPU::SPRT_16::Linked;
|
||||
|
||||
struct FontInfo {
|
||||
GPU::SizeU16 texture_size;
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace JabyEngine {
|
|||
FontWriter::write(state, str, color, wiggle, list); \
|
||||
va_end(list)
|
||||
|
||||
GPU::TexPage::Linked tex_page;
|
||||
GPU::TexPage::Linked tex_page[2];
|
||||
GPU::SizeI16 font_size;
|
||||
GPU::PageClut clut;
|
||||
GPU::Link* last_primitive;
|
||||
|
@ -22,7 +22,8 @@ namespace JabyEngine {
|
|||
static constexpr FontWriter empty() {
|
||||
FontWriter instance;
|
||||
|
||||
instance.tex_page = {0};
|
||||
instance.tex_page[0] = {0};
|
||||
instance.tex_page[1] = {0};
|
||||
instance.font_size = Make::SizeI16();
|
||||
instance.clut = Make::PageClut();
|
||||
instance.last_primitive = nullptr;
|
||||
|
|
|
@ -48,10 +48,12 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
void FontWriter :: setup(const SimpleTIM& vram_dst, const GPU::SizeI16& font_size) {
|
||||
this->tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked();
|
||||
for(auto& tex_page : this->tex_page) {
|
||||
tex_page = Make::TexPage(vram_dst.get_texture_position(), GPU::TexturePageColor::$4bit).linked();
|
||||
}
|
||||
this->font_size = font_size;
|
||||
this->clut = Make::PageClut(vram_dst.get_clut_position());
|
||||
this->last_primitive = &this->tex_page;
|
||||
this->last_primitive = nullptr;
|
||||
}
|
||||
|
||||
void FontWriter :: write(State& state, const char* str, GPU::Color24 color, Wiggle* wiggle, va_list list) {
|
||||
|
@ -59,13 +61,15 @@ namespace JabyEngine {
|
|||
return {str + 1, new_str};
|
||||
};
|
||||
|
||||
if(!this->last_primitive) {
|
||||
this->last_primitive = &this->tex_page[GPU::update_id()];
|
||||
}
|
||||
|
||||
const auto row_count = 256/font_size.width;
|
||||
const auto push_char = [&](State& state, char cur_char) -> bool {
|
||||
auto& primitive = GlobalPrimitiveFactory.new_primitive();
|
||||
|
||||
primitive->position = state.pos;
|
||||
primitive->size = this->font_size;
|
||||
|
||||
if(wiggle) {
|
||||
const auto [off_x, off_y] = (*wiggle)[(state.wiggle_count++)&0x7];
|
||||
primitive->position.move(off_x, off_y);
|
||||
|
@ -131,12 +135,9 @@ namespace JabyEngine {
|
|||
}
|
||||
|
||||
void FontWriter :: render() {
|
||||
const auto update_id = GPU::Display::current_id;
|
||||
const auto render_id = update_id ^ 1;
|
||||
|
||||
this->last_primitive->terminate();
|
||||
this->last_primitive = &this->tex_page;
|
||||
this->last_primitive = nullptr;
|
||||
|
||||
GPU::render(this->tex_page);
|
||||
GPU::render(this->tex_page[GPU::render_id()]);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace JabyEngine {
|
|||
const auto*const buffer_end = start + length;
|
||||
|
||||
for(auto* cur_prim = start; cur_prim < buffer_end; cur_prim++) {
|
||||
*cur_prim = FontPrimitive::create(GPU::SPRT::create(Make::AreaI16(), Make::OffsetPageWithClut()));
|
||||
*cur_prim = FontPrimitive::create(Make::SPRT_16(Make::Vertex(), Make::OffsetPageWithClut()));
|
||||
}
|
||||
|
||||
GlobalPrimitiveFactory = PrimitiveFactory::create(start, length);
|
||||
|
|
Loading…
Reference in New Issue