mirror of
https://github.com/open-goal/jak-project.git
synced 2024-10-20 11:26:18 -04:00
support mt4hh texture for japanese fonts
This commit is contained in:
parent
452aaf55b4
commit
3bba86ce18
|
@ -10,5 +10,6 @@ TWEAKVAL.MUS resources/TWEAKVAL.MUS
|
|||
VAGDIR.AYB resources/VAGDIR.AYB
|
||||
SCREEN1.USA resources/SCREEN1.USA
|
||||
0COMMON.TXT out/iso/0COMMON.TXT
|
||||
5COMMON.TXT out/iso/5COMMON.TXT
|
||||
0TEST.TXT out/iso/0TEST.TXT
|
||||
VI1.DGO out/iso/VI1.DGO
|
|
@ -250,7 +250,22 @@ struct GsTex0 {
|
|||
|
||||
u32 tbp0() const { return data & 0b11'1111'1111'1111; }
|
||||
u32 tbw() const { return (data >> 14) & 0b111111; }
|
||||
u32 psm() const { return (data >> 20) & 0b111111; }
|
||||
enum class PSM {
|
||||
PSMCT32 = 0,
|
||||
PSMCT24 = 1,
|
||||
PSMCT16 = 2,
|
||||
PSMCT16S = 0b1010,
|
||||
PSMT8 = 0b10011,
|
||||
PSMT4 = 0b10100,
|
||||
PSMT8H = 0b011011,
|
||||
PSMT4HL = 0b100100,
|
||||
PSMT4HH = 0b101100,
|
||||
PSMZ32 = 0b110000,
|
||||
PSMZ24 = 0b110001,
|
||||
PSMZ16 = 0b110010,
|
||||
PSMZ16S = 0b111010
|
||||
};
|
||||
PSM psm() const { return (PSM)((data >> 20) & 0b111111); }
|
||||
u32 tw() const { return (data >> 26) & 0b1111; }
|
||||
u32 th() const { return (data >> 30) & 0b1111; }
|
||||
enum class TextureFunction : u8 {
|
||||
|
|
|
@ -105,9 +105,9 @@ void texture_upload_now(const u8* tpage, int mode, u32 s7_ptr) {
|
|||
}
|
||||
}
|
||||
|
||||
void texture_relocate(u32 destination, u32 source) {
|
||||
void texture_relocate(u32 destination, u32 source, u32 format) {
|
||||
if (g_settings.renderer) {
|
||||
g_settings.renderer->texture_relocate(destination, source);
|
||||
g_settings.renderer->texture_relocate(destination, source, format);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ struct GfxRendererModule {
|
|||
std::function<u32()> sync_path;
|
||||
std::function<void(const void*, u32)> send_chain;
|
||||
std::function<void(const u8*, int, u32)> texture_upload_now;
|
||||
std::function<void(u32, u32)> texture_relocate;
|
||||
std::function<void(u32, u32, u32)> texture_relocate;
|
||||
|
||||
GfxPipeline pipeline;
|
||||
const char* name;
|
||||
|
@ -74,6 +74,6 @@ u32 vsync();
|
|||
u32 sync_path();
|
||||
void send_chain(const void* data, u32 offset);
|
||||
void texture_upload_now(const u8* tpage, int mode, u32 s7_ptr);
|
||||
void texture_relocate(u32 destination, u32 source);
|
||||
void texture_relocate(u32 destination, u32 source, u32 format);
|
||||
|
||||
} // namespace Gfx
|
||||
|
|
|
@ -180,7 +180,12 @@ void DirectRenderer::upload_texture(TextureRecord* tex) {
|
|||
}
|
||||
|
||||
void DirectRenderer::update_gl_texture(SharedRenderState* render_state) {
|
||||
auto tex = render_state->texture_pool->lookup(m_texture_state.texture_base_ptr);
|
||||
TextureRecord* tex = nullptr;
|
||||
if (m_texture_state.using_mt4hh) {
|
||||
tex = render_state->texture_pool->lookup_mt4hh(m_texture_state.texture_base_ptr);
|
||||
} else {
|
||||
tex = render_state->texture_pool->lookup(m_texture_state.texture_base_ptr);
|
||||
}
|
||||
assert(tex);
|
||||
// fmt::print("Successful texture lookup! {} {}\n", tex->page_name, tex->name);
|
||||
|
||||
|
@ -475,6 +480,7 @@ void DirectRenderer::handle_tex0_1(u64 val, SharedRenderState* render_state) {
|
|||
if (m_texture_state.current_register != reg) {
|
||||
flush_pending(render_state);
|
||||
m_texture_state.texture_base_ptr = reg.tbp0();
|
||||
m_texture_state.using_mt4hh = reg.psm() == GsTex0::PSM::PSMT4HH;
|
||||
m_prim_gl_state_needs_gl_update = true;
|
||||
m_texture_state.current_register = reg;
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ class DirectRenderer : public BucketRenderer {
|
|||
struct TextureState {
|
||||
GsTex0 current_register;
|
||||
u32 texture_base_ptr = 0;
|
||||
bool using_mt4hh = false;
|
||||
} m_texture_state;
|
||||
|
||||
// state set through the prim/rgbaq register that doesn't require changing GL stuff
|
||||
|
|
|
@ -257,9 +257,9 @@ void gl_texture_upload_now(const u8* tpage, int mode, u32 s7_ptr) {
|
|||
}
|
||||
}
|
||||
|
||||
void gl_texture_relocate(u32 destination, u32 source) {
|
||||
void gl_texture_relocate(u32 destination, u32 source, u32 format) {
|
||||
if (g_gfx_data) {
|
||||
g_gfx_data->texture_pool->relocate(destination, source);
|
||||
g_gfx_data->texture_pool->relocate(destination, source, format);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -160,8 +160,12 @@ void TexturePool::handle_upload_now(const u8* tpage, int mode, const u8* memory_
|
|||
tex_idx, tex_name, mip_idx),
|
||||
texture_record->data.data(), ww, hh);
|
||||
}
|
||||
if (tex.psm == 44) {
|
||||
set_mt4hh_texture(tex.dest[mip_idx], std::move(texture_record));
|
||||
} else {
|
||||
set_texture(tex.dest[mip_idx], std::move(texture_record));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// texture was #f, skip it.
|
||||
}
|
||||
|
@ -174,23 +178,28 @@ void TexturePool::handle_upload_now(const u8* tpage, int mode, const u8* memory_
|
|||
* Store a texture in the pool. Location is specified like TBP.
|
||||
*/
|
||||
void TexturePool::set_texture(u32 location, std::unique_ptr<TextureRecord>&& record) {
|
||||
if (m_textures.at(location)) {
|
||||
m_garbage_textures.push_back(std::move(m_textures[location]));
|
||||
if (m_textures.at(location).normal_texture) {
|
||||
m_garbage_textures.push_back(std::move(m_textures[location].normal_texture));
|
||||
}
|
||||
m_textures[location] = std::move(record);
|
||||
m_textures[location].normal_texture = std::move(record);
|
||||
}
|
||||
|
||||
void TexturePool::set_mt4hh_texture(u32 location, std::unique_ptr<TextureRecord>&& record) {
|
||||
if (m_textures.at(location).mt4hh_texture) {
|
||||
m_garbage_textures.push_back(std::move(m_textures[location].mt4hh_texture));
|
||||
}
|
||||
m_textures[location].mt4hh_texture = std::move(record);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Move a texture.
|
||||
*/
|
||||
void TexturePool::relocate(u32 destination, u32 source) {
|
||||
if (m_textures.at(source)) {
|
||||
if (m_textures.at(destination)) {
|
||||
return; // HACK
|
||||
}
|
||||
m_textures.at(destination) = std::move(m_textures.at(source));
|
||||
fmt::print("Relocated a texture: {}\n", m_textures[destination]->name);
|
||||
void TexturePool::relocate(u32 destination, u32 source, u32 format) {
|
||||
auto& src = m_textures.at(source).normal_texture;
|
||||
assert(src);
|
||||
if (format == 44) {
|
||||
m_textures.at(destination).mt4hh_texture = std::move(src);
|
||||
} else {
|
||||
assert(false);
|
||||
m_textures.at(destination).normal_texture = std::move(src);
|
||||
}
|
||||
}
|
|
@ -17,25 +17,39 @@ struct TextureRecord {
|
|||
bool on_gpu = false;
|
||||
};
|
||||
|
||||
struct TextureData {
|
||||
std::unique_ptr<TextureRecord> normal_texture;
|
||||
std::unique_ptr<TextureRecord> mt4hh_texture;
|
||||
};
|
||||
|
||||
class TexturePool {
|
||||
public:
|
||||
void handle_upload_now(const u8* tpage, int mode, const u8* memory_base, u32 s7_ptr);
|
||||
void set_texture(u32 location, std::unique_ptr<TextureRecord>&& record);
|
||||
void set_mt4hh_texture(u32 location, std::unique_ptr<TextureRecord>&& record);
|
||||
TextureRecord* lookup(u32 location) {
|
||||
if (m_textures.at(location)) {
|
||||
return m_textures[location].get();
|
||||
if (m_textures.at(location).normal_texture) {
|
||||
return m_textures[location].normal_texture.get();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void relocate(u32 destination, u32 source);
|
||||
TextureRecord* lookup_mt4hh(u32 location) {
|
||||
if (m_textures.at(location).mt4hh_texture) {
|
||||
return m_textures[location].mt4hh_texture.get();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void relocate(u32 destination, u32 source, u32 format);
|
||||
|
||||
private:
|
||||
TextureConverter m_tex_converter;
|
||||
|
||||
// uses tex.dest[mip] indexing. (bytes / 256). Currently only sets the base of a texture.
|
||||
std::array<std::unique_ptr<TextureRecord>, 1024 * 1024 * 4 / 256> m_textures;
|
||||
std::array<TextureData, 1024 * 1024 * 4 / 256> m_textures;
|
||||
|
||||
// textures that the game overwrote, but may be still allocated on the GPU.
|
||||
// TODO: free these periodically.
|
||||
|
|
|
@ -105,6 +105,9 @@ s32 goal_main(int argc, const char* const* argv) {
|
|||
masterConfig.language = (u16)Language::German;
|
||||
} else if (masterConfig.language == SCE_ITALIAN_LANGUAGE) {
|
||||
masterConfig.language = (u16)Language::Italian;
|
||||
} else if (masterConfig.language == SCE_JAPANESE_LANGUAGE) {
|
||||
// Note: this case was added so it is easier to test Japanese fonts.
|
||||
masterConfig.language = (u16)Language::Japanese;
|
||||
} else {
|
||||
// pick english by default, if language is not supported.
|
||||
masterConfig.language = (u16)Language::English;
|
||||
|
|
|
@ -449,8 +449,8 @@ void pc_texture_upload_now(u32 page, u32 mode) {
|
|||
Gfx::texture_upload_now(Ptr<u8>(page).c(), mode, s7.offset);
|
||||
}
|
||||
|
||||
void pc_texture_relocate(u32 dst, u32 src) {
|
||||
Gfx::texture_relocate(dst, src);
|
||||
void pc_texture_relocate(u32 dst, u32 src, u32 format) {
|
||||
Gfx::texture_relocate(dst, src, format);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -1809,7 +1809,7 @@
|
|||
|
||||
(#when PC_PORT
|
||||
;; as far as I know this is only used for fonts which have 1 mip level.
|
||||
(__pc-texture-relocate (/ dest-loc 64) (-> tex dest 0))
|
||||
(__pc-texture-relocate (/ dest-loc 64) (-> tex dest 0) dest-fmt)
|
||||
)
|
||||
|
||||
;; loop over mips
|
||||
|
|
|
@ -183,7 +183,7 @@
|
|||
(define-extern __mem-move (function pointer pointer uint none))
|
||||
(define-extern __send-gfx-dma-chain (function object object none))
|
||||
(define-extern __pc-texture-upload-now (function object object none))
|
||||
(define-extern __pc-texture-relocate (function object object none))
|
||||
(define-extern __pc-texture-relocate (function object object object none))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;;; ksound - InitSoundScheme
|
||||
|
|
Loading…
Reference in a new issue