diff --git a/game/graphics/opengl_renderer/EyeRenderer.cpp b/game/graphics/opengl_renderer/EyeRenderer.cpp index c87a9bbcdf..d1f2089443 100644 --- a/game/graphics/opengl_renderer/EyeRenderer.cpp +++ b/game/graphics/opengl_renderer/EyeRenderer.cpp @@ -11,20 +11,30 @@ ///////////////////////// EyeRenderer::EyeRenderer(const std::string& name, int id) : BucketRenderer(name, id) {} -void EyeRenderer::init_textures(TexturePool& texture_pool, GameVersion) { +void EyeRenderer::init_textures(TexturePool& texture_pool, GameVersion version) { // set up eyes for (int pair_idx = 0; pair_idx < NUM_EYE_PAIRS; pair_idx++) { for (int lr = 0; lr < 2; lr++) { u32 tidx = pair_idx * 2 + lr; - u32 tbp = EYE_BASE_BLOCK + pair_idx * 2 + lr; + u32 tbp = pair_idx * 2 + lr; + switch (version) { + case GameVersion::Jak1: + tbp += EYE_BASE_BLOCK_JAK1; + break; + case GameVersion::Jak2: + tbp += EYE_BASE_BLOCK_JAK2; + break; + default: + ASSERT_NOT_REACHED(); + } TextureInput in; in.gpu_texture = m_gpu_eye_textures[tidx].fb.texture(); in.w = 32; in.h = 32; in.debug_page_name = "PC-EYES"; in.debug_name = fmt::format("{}-eye-gpu-{}", lr ? "left" : "right", pair_idx); - in.id = texture_pool.allocate_pc_port_texture(); + in.id = texture_pool.allocate_pc_port_texture(version); m_gpu_eye_textures[tidx].gpu_tex = texture_pool.give_texture_and_load_to_vram(in, tbp); m_gpu_eye_textures[tidx].tbp = tbp; } diff --git a/game/graphics/opengl_renderer/EyeRenderer.h b/game/graphics/opengl_renderer/EyeRenderer.h index fe4f4d48ce..67d070df81 100644 --- a/game/graphics/opengl_renderer/EyeRenderer.h +++ b/game/graphics/opengl_renderer/EyeRenderer.h @@ -6,7 +6,8 @@ #include "game/graphics/opengl_renderer/opengl_utils.h" #include "game/graphics/pipelines/opengl.h" -constexpr int EYE_BASE_BLOCK = 8160; +constexpr int EYE_BASE_BLOCK_JAK1 = 8160; +constexpr int EYE_BASE_BLOCK_JAK2 = 3968; constexpr int NUM_EYE_PAIRS = 20; constexpr int SINGLE_EYE_SIZE = 32; diff --git a/game/graphics/opengl_renderer/OpenGLRenderer.cpp b/game/graphics/opengl_renderer/OpenGLRenderer.cpp index 0a49ec6990..9b85168d32 100644 --- a/game/graphics/opengl_renderer/OpenGLRenderer.cpp +++ b/game/graphics/opengl_renderer/OpenGLRenderer.cpp @@ -469,8 +469,8 @@ void OpenGLRenderer::init_bucket_renderers_jak1() { m_bucket_renderers[i]->init_shaders(m_render_state.shaders); m_bucket_renderers[i]->init_textures(*m_render_state.texture_pool, GameVersion::Jak1); } - sky_cpu_blender->init_textures(*m_render_state.texture_pool); - sky_gpu_blender->init_textures(*m_render_state.texture_pool); + sky_cpu_blender->init_textures(*m_render_state.texture_pool, m_version); + sky_gpu_blender->init_textures(*m_render_state.texture_pool, m_version); m_render_state.loader->load_common(*m_render_state.texture_pool, "GAME"); } diff --git a/game/graphics/opengl_renderer/ProgressRenderer.cpp b/game/graphics/opengl_renderer/ProgressRenderer.cpp index f8f6add8c2..1db82092f0 100644 --- a/game/graphics/opengl_renderer/ProgressRenderer.cpp +++ b/game/graphics/opengl_renderer/ProgressRenderer.cpp @@ -13,14 +13,14 @@ void ProgressRenderer::post_render() { m_offscreen_mode = false; } -void ProgressRenderer::init_textures(TexturePool& texture_pool, GameVersion) { +void ProgressRenderer::init_textures(TexturePool& texture_pool, GameVersion version) { TextureInput in; in.gpu_texture = m_minimap_fb.texture(); in.w = kMinimapWidth; in.h = kMinimapHeight; in.debug_page_name = "PC-MAP"; in.debug_name = "map"; - in.id = texture_pool.allocate_pc_port_texture(); + in.id = texture_pool.allocate_pc_port_texture(version); m_minimap_gpu_tex = texture_pool.give_texture_and_load_to_vram(in, kMinimapVramAddr); } diff --git a/game/graphics/opengl_renderer/SkyBlendCPU.cpp b/game/graphics/opengl_renderer/SkyBlendCPU.cpp index 0fc81fa979..3b3a6a25cb 100644 --- a/game/graphics/opengl_renderer/SkyBlendCPU.cpp +++ b/game/graphics/opengl_renderer/SkyBlendCPU.cpp @@ -188,7 +188,7 @@ SkyBlendStats SkyBlendCPU::do_sky_blends(DmaFollower& dma, return stats; } -void SkyBlendCPU::init_textures(TexturePool& tex_pool) { +void SkyBlendCPU::init_textures(TexturePool& tex_pool, GameVersion version) { for (int i = 0; i < 2; i++) { // update it glBindTexture(GL_TEXTURE_2D, m_textures[i].gl); @@ -200,7 +200,7 @@ void SkyBlendCPU::init_textures(TexturePool& tex_pool) { in.w = m_sizes[i]; in.h = m_sizes[i]; in.debug_name = fmt::format("PC-SKY-CPU-{}", i); - in.id = tex_pool.allocate_pc_port_texture(); + in.id = tex_pool.allocate_pc_port_texture(version); u32 tbp = SKY_TEXTURE_VRAM_ADDRS[i]; m_textures[i].tex = tex_pool.give_texture_and_load_to_vram(in, tbp); m_textures[i].tbp = tbp; diff --git a/game/graphics/opengl_renderer/SkyBlendCPU.h b/game/graphics/opengl_renderer/SkyBlendCPU.h index 116755c4f0..b2e83df03d 100644 --- a/game/graphics/opengl_renderer/SkyBlendCPU.h +++ b/game/graphics/opengl_renderer/SkyBlendCPU.h @@ -14,7 +14,7 @@ class SkyBlendCPU { SkyBlendStats do_sky_blends(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof); - void init_textures(TexturePool& tex_pool); + void init_textures(TexturePool& tex_pool, GameVersion version); private: static constexpr int m_sizes[2] = {32, 64}; diff --git a/game/graphics/opengl_renderer/SkyBlendGPU.cpp b/game/graphics/opengl_renderer/SkyBlendGPU.cpp index 5c0715fdbb..f81ca18a3c 100644 --- a/game/graphics/opengl_renderer/SkyBlendGPU.cpp +++ b/game/graphics/opengl_renderer/SkyBlendGPU.cpp @@ -60,14 +60,14 @@ SkyBlendGPU::~SkyBlendGPU() { glDeleteTextures(2, m_textures); } -void SkyBlendGPU::init_textures(TexturePool& tex_pool) { +void SkyBlendGPU::init_textures(TexturePool& tex_pool, GameVersion version) { for (int i = 0; i < 2; i++) { TextureInput in; in.gpu_texture = m_textures[i]; in.w = m_sizes[i]; in.h = in.w; in.debug_name = fmt::format("PC-SKY-GPU-{}", i); - in.id = tex_pool.allocate_pc_port_texture(); + in.id = tex_pool.allocate_pc_port_texture(version); u32 tbp = SKY_TEXTURE_VRAM_ADDRS[i]; m_tex_info[i] = {tex_pool.give_texture_and_load_to_vram(in, tbp), tbp}; } diff --git a/game/graphics/opengl_renderer/SkyBlendGPU.h b/game/graphics/opengl_renderer/SkyBlendGPU.h index ddce74a7ac..70a103908c 100644 --- a/game/graphics/opengl_renderer/SkyBlendGPU.h +++ b/game/graphics/opengl_renderer/SkyBlendGPU.h @@ -9,7 +9,7 @@ class SkyBlendGPU { public: SkyBlendGPU(); ~SkyBlendGPU(); - void init_textures(TexturePool& tex_pool); + void init_textures(TexturePool& tex_pool, GameVersion version); SkyBlendStats do_sky_blends(DmaFollower& dma, SharedRenderState* render_state, ScopedProfilerNode& prof); diff --git a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp index 986eccaaf9..efcffb177c 100644 --- a/game/graphics/opengl_renderer/ocean/OceanTexture.cpp +++ b/game/graphics/opengl_renderer/ocean/OceanTexture.cpp @@ -62,7 +62,7 @@ void OceanTexture::init_textures(TexturePool& pool, GameVersion version) { in.h = TEX0_SIZE; in.debug_page_name = "PC-OCEAN"; in.debug_name = fmt::format("pc-ocean-mip-{}", m_generate_mipmaps); - in.id = pool.allocate_pc_port_texture(); + in.id = pool.allocate_pc_port_texture(version); switch (version) { case GameVersion::Jak1: m_tex0_gpu = pool.give_texture_and_load_to_vram(in, OCEAN_TEX_TBP_JAK1); diff --git a/game/graphics/texture/TexturePool.cpp b/game/graphics/texture/TexturePool.cpp index f978b344a7..69216b50c2 100644 --- a/game/graphics/texture/TexturePool.cpp +++ b/game/graphics/texture/TexturePool.cpp @@ -364,9 +364,16 @@ void TexturePool::draw_debug_for_tex(const std::string& name, GpuTexture* tex, u ImGui::PopStyleColor(); } -PcTextureId TexturePool::allocate_pc_port_texture() { +PcTextureId TexturePool::allocate_pc_port_texture(GameVersion version) { ASSERT(m_next_pc_texture_to_allocate < EXTRA_PC_PORT_TEXTURE_COUNT); - return PcTextureId(get_jak1_tpage_dir().size() - 1, m_next_pc_texture_to_allocate++); + switch (version) { + case GameVersion::Jak1: + return PcTextureId(get_jak1_tpage_dir().size() - 1, m_next_pc_texture_to_allocate++); + case GameVersion::Jak2: + return PcTextureId(get_jak2_tpage_dir().size() - 1, m_next_pc_texture_to_allocate++); + default: + ASSERT_NOT_REACHED(); + } } std::string TexturePool::get_debug_texture_name(PcTextureId id) { diff --git a/game/graphics/texture/TexturePool.h b/game/graphics/texture/TexturePool.h index 3a4beaf317..bcd3cb6abc 100644 --- a/game/graphics/texture/TexturePool.h +++ b/game/graphics/texture/TexturePool.h @@ -353,7 +353,7 @@ class TexturePool { void move_existing_to_vram(GpuTexture* tex, u32 slot_addr); std::mutex& mutex() { return m_mutex; } - PcTextureId allocate_pc_port_texture(); + PcTextureId allocate_pc_port_texture(GameVersion version); std::string get_debug_texture_name(PcTextureId id);