Skip to content

Commit

Permalink
Revert "Start reducing size of video_shader_pass struct to reduce"
Browse files Browse the repository at this point in the history
This reverts commit 0ab10f7.
  • Loading branch information
LibretroAdmin committed Sep 11, 2024
1 parent 787c1e1 commit 14b1af9
Show file tree
Hide file tree
Showing 12 changed files with 38 additions and 50 deletions.
4 changes: 2 additions & 2 deletions gfx/drivers/d3d10.c
Original file line number Diff line number Diff line change
Expand Up @@ -2127,7 +2127,7 @@ static void d3d10_init_render_targets(d3d10_video_t* d3d10,
d3d10_release_texture(&d3d10->pass[i].rt);
d3d10_init_texture(d3d10->device, &d3d10->pass[i].rt);

if ((pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
if (pass->feedback)
{
d3d10->pass[i].feedback.desc = d3d10->pass[i].rt.desc;
d3d10_release_texture(&d3d10->pass[i].feedback);
Expand Down Expand Up @@ -2302,7 +2302,7 @@ static bool d3d10_gfx_frame(
{
for (i = 0; i < d3d10->shader_preset->passes; i++)
{
if ((d3d10->shader_preset->pass[i].flags & SHDR_PASS_FLG_FEEDBACK) > 0)
if (d3d10->shader_preset->pass[i].feedback)
{
d3d10_texture_t tmp = d3d10->pass[i].feedback;
d3d10->pass[i].feedback = d3d10->pass[i].rt;
Expand Down
4 changes: 2 additions & 2 deletions gfx/drivers/d3d11.c
Original file line number Diff line number Diff line change
Expand Up @@ -2751,7 +2751,7 @@ static void d3d11_init_render_targets(d3d11_video_t* d3d11, unsigned width, unsi
d3d11_release_texture(&d3d11->pass[i].rt);
d3d11_init_texture(d3d11->device, &d3d11->pass[i].rt);

if ((pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
if (pass->feedback)
{
d3d11->pass[i].feedback.desc = d3d11->pass[i].rt.desc;
d3d11_release_texture(&d3d11->pass[i].feedback);
Expand Down Expand Up @@ -3060,7 +3060,7 @@ static bool d3d11_gfx_frame(
{
for (i = 0; i < d3d11->shader_preset->passes; i++)
{
if ((d3d11->shader_preset->pass[i].flags & SHDR_PASS_FLG_FEEDBACK) > 0)
if (d3d11->shader_preset->pass[i].feedback)
{
d3d11_texture_t tmp = d3d11->pass[i].feedback;
d3d11->pass[i].feedback = d3d11->pass[i].rt;
Expand Down
4 changes: 2 additions & 2 deletions gfx/drivers/d3d12.c
Original file line number Diff line number Diff line change
Expand Up @@ -3169,7 +3169,7 @@ static void d3d12_init_render_targets(d3d12_video_t* d3d12, unsigned width, unsi
d3d12_release_texture(&d3d12->pass[i].rt);
d3d12_init_texture(d3d12->device, &d3d12->pass[i].rt);

if ((pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
if (pass->feedback)
{
d3d12->pass[i].feedback.desc = d3d12->pass[i].rt.desc;
d3d12->pass[i].feedback.srv_heap = &d3d12->desc.srv_heap;
Expand Down Expand Up @@ -3566,7 +3566,7 @@ static bool d3d12_gfx_frame(

for (i = 0; i < d3d12->shader_preset->passes; i++)
{
if ((d3d12->shader_preset->pass[i].flags & SHDR_PASS_FLG_FEEDBACK) > 0)
if (d3d12->shader_preset->pass[i].feedback)
{
d3d12_texture_t tmp = d3d12->pass[i].feedback;
d3d12->pass[i].feedback = d3d12->pass[i].rt;
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers/gx2_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ static void gx2_update_uniform_block(wiiu_video_t *wiiu,
continue;
}

/* FEEDBACK not supported yet */
/* feedback not supported yet */
if (!strncmp(id, "PassFeedbackSize", STRLEN_CONST("PassFeedbackSize")))
{
GX2Surface *output;
Expand Down
4 changes: 2 additions & 2 deletions gfx/drivers/metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ - (void)drawWithContext:(Context *)ctx

for (i = 0; i < _shader->passes; i++)
{
if (_shader->pass[i].flags & SHDR_PASS_FLG_FEEDBACK)
if (_shader->pass[i].feedback)
{
texture_t tmp = _engine.pass[i].feedback;
_engine.pass[i].feedback = _engine.pass[i].rt;
Expand Down Expand Up @@ -1733,7 +1733,7 @@ - (void)_updateRenderTargets

[self _initTexture:&_engine.pass[i].rt withDescriptor:td];

if ((shader_pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
if (shader_pass->feedback)
[self _initTexture:&_engine.pass[i].feedback withDescriptor:td];
}
else
Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers_shader/shader_gl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2512,7 +2512,7 @@ gl3_filter_chain_t *gl3_filter_chain_create_from_preset(
* CGP format is a bit awkward in that it uses mipmap_input,
* so we much check if next pass needs the mipmapping.
*/
if (next_pass && ((next_pass->flags & SHDR_PASS_FLG_MIPMAP) > 0))
if (next_pass && next_pass->mipmap)
pass_info.max_levels = ~0u;

pass_info.mip_filter = pass->filter != RARCH_FILTER_NEAREST && pass_info.max_levels > 1
Expand Down
11 changes: 7 additions & 4 deletions gfx/drivers_shader/shader_gl_cg.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ static void gl_cg_set_params(void *dat, void *shader_data)
set_param_2f(cg->prg[cg->active_idx].tex_size_v, tex_width, tex_height);
set_param_2f(cg->prg[cg->active_idx].out_size_v, out_width, out_height);

if ( cg->prg[cg->active_idx].frame_cnt_f ||
if ( cg->prg[cg->active_idx].frame_cnt_f ||
cg->prg[cg->active_idx].frame_cnt_v)
{
unsigned modulo = cg->shader->pass[cg->active_idx - 1].frame_count_mod;
Expand Down Expand Up @@ -1056,11 +1056,14 @@ static unsigned gl_cg_num(void *data)
static bool gl_cg_filter_type(void *data, unsigned idx, bool *smooth)
{
cg_shader_data_t *cg = (cg_shader_data_t*)data;
if (cg && idx && (cg->shader->pass[idx - 1].filter != RARCH_FILTER_UNSPEC))
if (cg && idx &&
(cg->shader->pass[idx - 1].filter != RARCH_FILTER_UNSPEC)
)
{
*smooth = (cg->shader->pass[idx - 1].filter == RARCH_FILTER_LINEAR);
return true;
}

return false;
}

Expand Down Expand Up @@ -1111,8 +1114,8 @@ static bool gl_cg_get_feedback_pass(void *data, unsigned *pass)
static bool gl_cg_mipmap_input(void *data, unsigned idx)
{
cg_shader_data_t *cg = (cg_shader_data_t*)data;
if (cg && idx && ((cg->shader->pass[idx - 1].flags & SHDR_PASS_FLG_MIPMAP) > 0))
return true;
if (cg && idx)
return cg->shader->pass[idx - 1].mipmap;
return false;
}

Expand Down
18 changes: 9 additions & 9 deletions gfx/drivers_shader/shader_glsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ static const XXH64_hash_t gl_glsl_hash_shader(
{
XXH64_update(state, source[n], strlen(source[n]));
}

XXH64_hash_t const hash = XXH64_digest(state);

XXH64_freeState(state);
Expand Down Expand Up @@ -417,10 +417,10 @@ static bool gl_glsl_compile_shader(glsl_shader_data_t *glsl,
source[2] = glsl->alias_define;
source[3] = program;

#if defined(ORBIS)
#if defined(ORBIS)
{
char save_path[250];
XXH64_hash_t const hash =
XXH64_hash_t const hash =
gl_glsl_hash_shader(source, ARRAY_SIZE(source));
snprintf(save_path, sizeof(save_path),
"/data/retroarch/temp/%lx.sb", hash);
Expand Down Expand Up @@ -468,7 +468,7 @@ static bool gl_glsl_compile_program(
struct shader_program_info *program_info)
{
glsl_shader_data_t *glsl = (glsl_shader_data_t*)data;
struct shader_program_glsl_data *program =
struct shader_program_glsl_data *program =
(struct shader_program_glsl_data*)program_data;
GLuint prog = glCreateProgram();

Expand Down Expand Up @@ -1112,7 +1112,7 @@ static void *gl_glsl_init(void *data, const char *path)
goto error;
}
#else
if ( glsl_core
if ( glsl_core
&& (!(glsl->shader->flags & SHDR_FLAG_MODERN)))
{
RARCH_ERR("[GL]: GL core context is used, but shader is not core compatible. Cannot use it.\n");
Expand Down Expand Up @@ -1545,7 +1545,7 @@ static bool gl_glsl_set_mvp(void *shader_data, const void *mat_data)
int loc;
glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data;

if ( !glsl
if ( !glsl
|| (!(glsl->shader->flags & SHDR_FLAG_MODERN)))
return false;

Expand Down Expand Up @@ -1589,7 +1589,7 @@ static bool gl_glsl_set_coords(void *shader_data,
const struct shader_uniforms *uni = glsl
? &glsl->uniforms[glsl->active_idx] : NULL;

if ( !glsl
if ( !glsl
|| (!(glsl->shader->flags & SHDR_FLAG_MODERN))
|| !coords)
{
Expand Down Expand Up @@ -1744,8 +1744,8 @@ static unsigned gl_glsl_get_prev_textures(void *data)
static bool gl_glsl_mipmap_input(void *data, unsigned idx)
{
glsl_shader_data_t *glsl = (glsl_shader_data_t*)data;
if (glsl && idx && (glsl->shader->pass[idx - 1].flags & SHDR_PASS_FLG_MIPMAP) > 0)
return true;
if (glsl && idx)
return glsl->shader->pass[idx - 1].mipmap;
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion gfx/drivers_shader/shader_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2930,7 +2930,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset(
* Preset format is a bit awkward in that it uses mipmap_input,
* so we must check if next pass needs the mipmapping.
*/
if (next_pass && ((next_pass->flags & SHDR_PASS_FLG_MIPMAP) > 0))
if (next_pass && next_pass->mipmap)
pass_info.max_levels = ~0u;

pass_info.mip_filter =
Expand Down
4 changes: 1 addition & 3 deletions gfx/drivers_shader/slang_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ static bool slang_process_reflection(
textures.push_back(texture);

if (semantic == SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK)
shader_info->pass[index].flags |= SHDR_PASS_FLG_FEEDBACK;
else
shader_info->pass[index].flags &= ~SHDR_PASS_FLG_FEEDBACK;
shader_info->pass[index].feedback = true;

if (semantic == SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY &&
(unsigned)shader_info->history_size < index)
Expand Down
19 changes: 5 additions & 14 deletions gfx/video_shader_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,7 @@ static bool video_shader_parse_pass(config_file_t *conf,
_len = strlcpy(shader_var, "mipmap_input", sizeof(shader_var));
strlcpy(shader_var + _len, formatted_num, sizeof(shader_var) - _len);
if (config_get_bool(conf, shader_var, &tmp_bool))
{
if (tmp_bool)
pass->flags |= SHDR_PASS_FLG_MIPMAP;
else
pass->flags &= ~SHDR_PASS_FLG_MIPMAP;
}
pass->mipmap = tmp_bool;

_len = strlcpy(shader_var, "alias", sizeof(shader_var));
strlcpy(shader_var + _len, formatted_num, sizeof(shader_var) - _len);
Expand Down Expand Up @@ -1201,7 +1196,7 @@ static bool video_shader_write_root_preset(const struct video_shader *shader,

_len = strlcpy(key, "mipmap_input", sizeof(key));
strlcpy(key + _len, formatted_num, sizeof(key) - _len);
config_set_string(conf, key, ((pass->flags & SHDR_PASS_FLG_MIPMAP) > 0) ? "true" : "false");
config_set_string(conf, key, pass->mipmap ? "true" : "false");

_len = strlcpy(key, "alias", sizeof(key));
strlcpy(key + _len, formatted_num, sizeof(key) - _len);
Expand Down Expand Up @@ -1729,16 +1724,12 @@ static bool video_shader_write_referenced_preset(
continue_saving_ref = false;
}

if (continue_saving_ref && pass->mipmap != root_pass->mipmap)
{
bool pass_mipmap = (pass->flags & SHDR_PASS_FLG_MIPMAP) > 0;
bool root_pass_mipmap = (root_pass->flags & SHDR_PASS_FLG_MIPMAP) > 0;
if (continue_saving_ref && pass_mipmap != root_pass_mipmap)
{
#ifdef DEBUG
RARCH_WARN("[Shaders]: Pass %u mipmap", i);
RARCH_WARN("[Shaders]: Pass %u mipmap", i);
#endif
continue_saving_ref = false;
}
continue_saving_ref = false;
}

if (continue_saving_ref && !string_is_equal(pass->alias, root_pass->alias))
Expand Down
14 changes: 5 additions & 9 deletions gfx/video_shader_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ enum
enum video_shader_flags
{
SHDR_FLAG_MODERN = (1 << 0), /* Only used for XML shaders. */
SHDR_FLAG_MODIFIED = (1 << 1), /* Indicative of whether shader was modified -
* for instance from the menus */
/* Indicative of whether shader was modified -
* for instance from the menus */
SHDR_FLAG_MODIFIED = (1 << 1),
SHDR_FLAG_DISABLED = (1 << 2)
};

Expand Down Expand Up @@ -140,12 +141,6 @@ struct rarch_dir_shader_list
bool remember_last_preset_dir;
};

enum video_shader_pass_flags
{
SHDR_PASS_FLG_MIPMAP = (1 << 0),
SHDR_PASS_FLG_FEEDBACK = (1 << 1)
};

struct video_shader_pass
{
struct gfx_fbo_scale fbo; /* unsigned alignment */
Expand All @@ -162,7 +157,8 @@ struct video_shader_pass
char path[NAME_MAX_LENGTH*2];
} source;
char alias[64];
uint8_t flags;
bool mipmap;
bool feedback;
};

struct video_shader_lut
Expand Down

0 comments on commit 14b1af9

Please sign in to comment.