mirror of
https://github.com/open-goal/jak-project
synced 2026-07-07 14:13:45 -04:00
more fixes
This commit is contained in:
@@ -89,6 +89,10 @@ u32 vsync() {
|
||||
return g_settings.renderer->vsync();
|
||||
}
|
||||
|
||||
u32 sync_path() {
|
||||
return g_settings.renderer->sync_path();
|
||||
}
|
||||
|
||||
void send_chain(const void* data, u32 offset) {
|
||||
if (g_settings.renderer) {
|
||||
g_settings.renderer->send_chain(data, offset);
|
||||
|
||||
@@ -26,6 +26,7 @@ struct GfxRendererModule {
|
||||
std::function<void(GfxDisplay* display)> render_display;
|
||||
std::function<void()> exit;
|
||||
std::function<u32()> vsync;
|
||||
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;
|
||||
@@ -70,6 +71,7 @@ void Loop(std::function<bool()> f);
|
||||
u32 Exit();
|
||||
|
||||
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);
|
||||
|
||||
@@ -8,6 +8,7 @@ DirectRenderer::DirectRenderer(const std::string& name, BucketId my_id, int batc
|
||||
: BucketRenderer(name, my_id), m_prim_buffer(batch_size) {
|
||||
glGenBuffers(1, &m_ogl.vertex_buffer);
|
||||
glGenBuffers(1, &m_ogl.color_buffer);
|
||||
glGenBuffers(1, &m_ogl.st_buffer);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, m_ogl.vertex_buffer);
|
||||
m_ogl.vertex_buffer_bytes = batch_size * 3 * 3 * sizeof(u32);
|
||||
@@ -33,6 +34,7 @@ DirectRenderer::~DirectRenderer() {
|
||||
* Render from a DMA bucket.
|
||||
*/
|
||||
void DirectRenderer::render(DmaFollower& dma, SharedRenderState* render_state) {
|
||||
m_triangles = 0;
|
||||
// fmt::print("direct: {}\n", m_my_id);
|
||||
// if we're rendering from a bucket, we should start off we a totally reset state:
|
||||
reset_state();
|
||||
@@ -127,6 +129,7 @@ void DirectRenderer::flush_pending(SharedRenderState* render_state) {
|
||||
}
|
||||
// assert(false);
|
||||
glDrawArrays(GL_TRIANGLES, 0, m_prim_buffer.vert_count);
|
||||
m_triangles += m_prim_buffer.vert_count / 3;
|
||||
m_prim_buffer.vert_count = 0;
|
||||
}
|
||||
|
||||
@@ -464,7 +467,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_needs_gl_update = true;
|
||||
m_prim_gl_state_needs_gl_update = true;
|
||||
m_texture_state.current_register = reg;
|
||||
}
|
||||
|
||||
@@ -712,7 +715,6 @@ void DirectRenderer::reset_state() {
|
||||
m_prim_gl_state_needs_gl_update = true;
|
||||
m_prim_gl_state = PrimGlState();
|
||||
|
||||
m_texture_state_needs_gl_update = true;
|
||||
m_texture_state = TextureState();
|
||||
|
||||
m_prim_building = PrimBuildState();
|
||||
|
||||
@@ -160,8 +160,9 @@ class DirectRenderer : public BucketRenderer {
|
||||
u32 st_buffer_bytes = 0;
|
||||
} m_ogl;
|
||||
|
||||
int m_triangles = 0;
|
||||
|
||||
bool m_prim_gl_state_needs_gl_update = true;
|
||||
bool m_test_state_needs_gl_update = true;
|
||||
bool m_blend_state_needs_gl_update = true;
|
||||
bool m_texture_state_needs_gl_update = true;
|
||||
};
|
||||
|
||||
@@ -9,6 +9,6 @@ out vec2 tex_coord;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4((position_in.x - 0.5) * 16., -(position_in.y - 0.5) * 32, position_in.z, 1.0);
|
||||
fragment_color = vec4(rgba_in.x, rgba_in.y, rgba_in.z, rgba_in.w + 0.5);
|
||||
fragment_color = vec4(rgba_in.x, rgba_in.y, rgba_in.z, rgba_in.w * 2.);
|
||||
tex_coord = tex_coord_in;
|
||||
}
|
||||
@@ -162,6 +162,7 @@ static void gl_render_display(GfxDisplay* display) {
|
||||
// send_chain again. but let's be safe for now.
|
||||
std::unique_lock<std::mutex> lock(g_gfx_data->dma_mutex);
|
||||
g_gfx_data->has_data_to_render = false;
|
||||
g_gfx_data->sync_cv.notify_all();
|
||||
}
|
||||
|
||||
// actual vsync
|
||||
@@ -199,6 +200,18 @@ u32 gl_vsync() {
|
||||
return g_gfx_data->frame_idx & 1;
|
||||
}
|
||||
|
||||
u32 gl_sync_path() {
|
||||
if (!g_gfx_data) {
|
||||
return 0;
|
||||
}
|
||||
std::unique_lock<std::mutex> lock(g_gfx_data->sync_mutex);
|
||||
if (!g_gfx_data->has_data_to_render) {
|
||||
return 0;
|
||||
}
|
||||
g_gfx_data->sync_cv.wait(lock, [=] { return !g_gfx_data->has_data_to_render; });
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Send DMA to the renderer.
|
||||
* Called from the game thread, on a GOAL stack.
|
||||
@@ -255,6 +268,7 @@ const GfxRendererModule moduleOpenGL = {
|
||||
gl_render_display, // render_display
|
||||
gl_exit, // exit
|
||||
gl_vsync, // vsync
|
||||
gl_sync_path, // sync_path
|
||||
gl_send_chain, // send_chain
|
||||
gl_texture_upload_now, // texture_upload_now
|
||||
gl_texture_relocate, // texture_relocate
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
u32 sceGsSyncPath(u32 mode, u32 timeout) {
|
||||
assert(mode == 0 && timeout == 0);
|
||||
return 0;
|
||||
return Gfx::sync_path();
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
@@ -118,6 +118,7 @@ void TexturePool::handle_upload_now(const u8* tpage, int mode, const u8* memory_
|
||||
u32 size = ((sizes[0] + sizes[1] + sizes[2] + 255) / 256) * 256;
|
||||
m_tex_converter.upload(memory_base + texture_page.segment[0].block_data_ptr,
|
||||
texture_page.segment[0].dest, size);
|
||||
|
||||
} else {
|
||||
// no reason to skip this, other than
|
||||
lg::error("TexturePool skipping upload now with mode {}.", mode);
|
||||
@@ -146,7 +147,6 @@ void TexturePool::handle_upload_now(const u8* tpage, int mode, const u8* memory_
|
||||
m_tex_converter.download_rgba8888(texture_record->data.data(), tex.dest[mip_idx],
|
||||
tex.width[mip_idx], ww, hh, tex.psm, tex.clutpsm,
|
||||
tex.clut_dest, size_bytes);
|
||||
set_texture(tex.dest[mip_idx], std::move(texture_record));
|
||||
|
||||
// Debug output.
|
||||
if (dump_textures_to_file) {
|
||||
@@ -160,6 +160,7 @@ 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);
|
||||
}
|
||||
set_texture(tex.dest[mip_idx], std::move(texture_record));
|
||||
}
|
||||
} else {
|
||||
// texture was #f, skip it.
|
||||
|
||||
@@ -302,6 +302,8 @@ uint32_t FS_BeginRead(LoadStackEntry* fd, void* buffer, int32_t len) {
|
||||
fd->location += (len / SECTOR_SIZE);
|
||||
read_in_progress = true;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return CMD_STATUS_IN_PROGRESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user