mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Start reducing size of video_shader_pass struct to reduce
massive size of video_shader struct
This commit is contained in:
parent
c79b02b1c8
commit
0ab10f73c2
@ -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->feedback)
|
||||
if ((pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
|
||||
{
|
||||
d3d10->pass[i].feedback.desc = d3d10->pass[i].rt.desc;
|
||||
d3d10_release_texture(&d3d10->pass[i].feedback);
|
||||
@ -2302,7 +2302,7 @@ static bool d3d10_gfx_frame(
|
||||
{
|
||||
for (i = 0; i < d3d10->shader_preset->passes; i++)
|
||||
{
|
||||
if (d3d10->shader_preset->pass[i].feedback)
|
||||
if ((d3d10->shader_preset->pass[i].flags & SHDR_PASS_FLG_FEEDBACK) > 0)
|
||||
{
|
||||
d3d10_texture_t tmp = d3d10->pass[i].feedback;
|
||||
d3d10->pass[i].feedback = d3d10->pass[i].rt;
|
||||
|
@ -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->feedback)
|
||||
if ((pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
|
||||
{
|
||||
d3d11->pass[i].feedback.desc = d3d11->pass[i].rt.desc;
|
||||
d3d11_release_texture(&d3d11->pass[i].feedback);
|
||||
@ -3060,7 +3060,7 @@ static bool d3d11_gfx_frame(
|
||||
{
|
||||
for (i = 0; i < d3d11->shader_preset->passes; i++)
|
||||
{
|
||||
if (d3d11->shader_preset->pass[i].feedback)
|
||||
if ((d3d11->shader_preset->pass[i].flags & SHDR_PASS_FLG_FEEDBACK) > 0)
|
||||
{
|
||||
d3d11_texture_t tmp = d3d11->pass[i].feedback;
|
||||
d3d11->pass[i].feedback = d3d11->pass[i].rt;
|
||||
|
@ -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->feedback)
|
||||
if ((pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
|
||||
{
|
||||
d3d12->pass[i].feedback.desc = d3d12->pass[i].rt.desc;
|
||||
d3d12->pass[i].feedback.srv_heap = &d3d12->desc.srv_heap;
|
||||
@ -3566,7 +3566,7 @@ static bool d3d12_gfx_frame(
|
||||
|
||||
for (i = 0; i < d3d12->shader_preset->passes; i++)
|
||||
{
|
||||
if (d3d12->shader_preset->pass[i].feedback)
|
||||
if ((d3d12->shader_preset->pass[i].flags & SHDR_PASS_FLG_FEEDBACK) > 0)
|
||||
{
|
||||
d3d12_texture_t tmp = d3d12->pass[i].feedback;
|
||||
d3d12->pass[i].feedback = d3d12->pass[i].rt;
|
||||
|
@ -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;
|
||||
|
@ -1530,7 +1530,7 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
for (i = 0; i < _shader->passes; i++)
|
||||
{
|
||||
if (_shader->pass[i].feedback)
|
||||
if (_shader->pass[i].flags & SHDR_PASS_FLG_FEEDBACK)
|
||||
{
|
||||
texture_t tmp = _engine.pass[i].feedback;
|
||||
_engine.pass[i].feedback = _engine.pass[i].rt;
|
||||
@ -1733,7 +1733,7 @@ typedef struct MTLALIGN(16)
|
||||
|
||||
[self _initTexture:&_engine.pass[i].rt withDescriptor:td];
|
||||
|
||||
if (shader_pass->feedback)
|
||||
if ((shader_pass->flags & SHDR_PASS_FLG_FEEDBACK) > 0)
|
||||
[self _initTexture:&_engine.pass[i].feedback withDescriptor:td];
|
||||
}
|
||||
else
|
||||
|
@ -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->mipmap)
|
||||
if (next_pass && ((next_pass->flags & SHDR_PASS_FLG_MIPMAP) > 0))
|
||||
pass_info.max_levels = ~0u;
|
||||
|
||||
pass_info.mip_filter = pass->filter != RARCH_FILTER_NEAREST && pass_info.max_levels > 1
|
||||
|
@ -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;
|
||||
@ -1056,14 +1056,11 @@ 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;
|
||||
}
|
||||
|
||||
@ -1114,8 +1111,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)
|
||||
return cg->shader->pass[idx - 1].mipmap;
|
||||
if (cg && idx && ((cg->shader->pass[idx - 1].flags & SHDR_PASS_FLG_MIPMAP) > 0))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
@ -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);
|
||||
@ -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();
|
||||
|
||||
@ -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");
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
@ -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)
|
||||
return glsl->shader->pass[idx - 1].mipmap;
|
||||
if (glsl && idx && (glsl->shader->pass[idx - 1].flags & SHDR_PASS_FLG_MIPMAP) > 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -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->mipmap)
|
||||
if (next_pass && ((next_pass->flags & SHDR_PASS_FLG_MIPMAP) > 0))
|
||||
pass_info.max_levels = ~0u;
|
||||
|
||||
pass_info.mip_filter =
|
||||
|
@ -254,7 +254,9 @@ static bool slang_process_reflection(
|
||||
textures.push_back(texture);
|
||||
|
||||
if (semantic == SLANG_TEXTURE_SEMANTIC_PASS_FEEDBACK)
|
||||
shader_info->pass[index].feedback = true;
|
||||
shader_info->pass[index].flags |= SHDR_PASS_FLG_FEEDBACK;
|
||||
else
|
||||
shader_info->pass[index].flags &= ~SHDR_PASS_FLG_FEEDBACK;
|
||||
|
||||
if (semantic == SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY &&
|
||||
(unsigned)shader_info->history_size < index)
|
||||
|
@ -610,7 +610,12 @@ 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))
|
||||
pass->mipmap = tmp_bool;
|
||||
{
|
||||
if (tmp_bool)
|
||||
pass->flags |= SHDR_PASS_FLG_MIPMAP;
|
||||
else
|
||||
pass->flags &= ~SHDR_PASS_FLG_MIPMAP;
|
||||
}
|
||||
|
||||
_len = strlcpy(shader_var, "alias", sizeof(shader_var));
|
||||
strlcpy(shader_var + _len, formatted_num, sizeof(shader_var) - _len);
|
||||
@ -1152,7 +1157,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->mipmap ? "true" : "false");
|
||||
config_set_string(conf, key, ((pass->flags & SHDR_PASS_FLG_MIPMAP) > 0) ? "true" : "false");
|
||||
|
||||
_len = strlcpy(key, "alias", sizeof(key));
|
||||
strlcpy(key + _len, formatted_num, sizeof(key) - _len);
|
||||
@ -1682,12 +1687,16 @@ 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))
|
||||
|
@ -104,9 +104,8 @@ enum
|
||||
enum video_shader_flags
|
||||
{
|
||||
SHDR_FLAG_MODERN = (1 << 0), /* Only used for XML shaders. */
|
||||
/* Indicative of whether shader was modified -
|
||||
* for instance from the menus */
|
||||
SHDR_FLAG_MODIFIED = (1 << 1),
|
||||
SHDR_FLAG_MODIFIED = (1 << 1), /* Indicative of whether shader was modified -
|
||||
* for instance from the menus */
|
||||
SHDR_FLAG_DISABLED = (1 << 2)
|
||||
};
|
||||
|
||||
@ -160,6 +159,12 @@ 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 */
|
||||
@ -176,8 +181,7 @@ struct video_shader_pass
|
||||
char path[PATH_MAX_LENGTH];
|
||||
} source;
|
||||
char alias[64];
|
||||
bool mipmap;
|
||||
bool feedback;
|
||||
uint8_t flags;
|
||||
};
|
||||
|
||||
struct video_shader_lut
|
||||
|
Loading…
x
Reference in New Issue
Block a user