mirror of
https://github.com/open-goal/jak-project
synced 2026-09-01 01:52:03 -04:00
[jak2] Fix texture page dir offset for jak 2 (#2412)
Accidentally used Jak 1's tpage dir size...
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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};
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user