From e945eb95727042c35995428e69691b808879b344 Mon Sep 17 00:00:00 2001 From: MysterD Date: Thu, 27 Apr 2023 00:54:02 -0700 Subject: [PATCH] Added an optimization back in --- src/pc/gfx/gfx_cc.c | 1 + src/pc/gfx/gfx_opengl.c | 12 +++++++++++- src/pc/gfx/gfx_pc.c | 5 ++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pc/gfx/gfx_cc.c b/src/pc/gfx/gfx_cc.c index 7785e2b4..aae82288 100644 --- a/src/pc/gfx/gfx_cc.c +++ b/src/pc/gfx/gfx_cc.c @@ -1,6 +1,7 @@ #include "gfx_cc.h" void gfx_cc_get_features(uint32_t shader_id, struct CCFeatures *cc_features) { + // DO NOT COMMIT: TODO - need to fix this for (int32_t i = 0; i < 4; i++) { cc_features->c[0][i] = (shader_id >> (i * 3)) & 7; cc_features->c[1][i] = (shader_id >> (12 + i * 3)) & 7; diff --git a/src/pc/gfx/gfx_opengl.c b/src/pc/gfx/gfx_opengl.c index b361fda6..b8dab59e 100644 --- a/src/pc/gfx/gfx_opengl.c +++ b/src/pc/gfx/gfx_opengl.c @@ -263,7 +263,6 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC bool do_single[4] = { 0 }; bool do_multiply[4] = { 0 }; bool do_mix[4] = { 0 }; - bool color_alpha_same[2] = { 0 }; // TODO: gotta compare shader commands for (int i = 0; i < 16 / 4; i++) { u8* c = &cc->shader_commands[i * 4]; do_single[i] = (c[2] == 0); @@ -271,6 +270,17 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC do_mix[i] = (c[1] == c[3]); } + bool color_alpha_same[2] = { 1, 1 }; + for (int i = 0; i < 2; i++) { + u8* cmd = &cc->shader_commands[i * 8]; + for (int j = 0; j < 4; j++) { + if (cmd[j] != cmd[j + 4]) { + color_alpha_same[i] = 0; + break; + } + } + } + char vs_buf[1024]; char fs_buf[2048]; size_t vs_len = 0; diff --git a/src/pc/gfx/gfx_pc.c b/src/pc/gfx/gfx_pc.c index 09fd6c74..8caa8cf2 100644 --- a/src/pc/gfx/gfx_pc.c +++ b/src/pc/gfx/gfx_pc.c @@ -2029,8 +2029,8 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, co gfx_wapi->init(window_title); gfx_rapi->init(); - // DO NOT COMMIT: must update these! /* + // DO NOT COMMIT: TODO must update these! // Used in the 120 star TAS static uint32_t precomp_shaders[] = { 0x01200200, @@ -2062,8 +2062,7 @@ void gfx_init(struct GfxWindowManagerAPI *wapi, struct GfxRenderingAPI *rapi, co }; for (size_t i = 0; i < sizeof(precomp_shaders) / sizeof(uint32_t); i++) - gfx_lookup_or_create_shader_program(precomp_shaders[i]); - */ + gfx_precomp_shaders(precomp_shaders[i]);*/ } #ifdef EXTERNAL_DATA