mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
(XMB/Shaders) Reimplement menu shader loading for GLSL/Cg/HLSL backends - if
XMB is selected, it will compile the shader pipelines in advance
This commit is contained in:
parent
74a3677eb5
commit
97cf6613da
@ -201,8 +201,7 @@ static void vulkan_init_pipeline_layout(
|
||||
&layout_info, NULL, &vk->pipelines.layout);
|
||||
}
|
||||
|
||||
static void vulkan_init_pipelines(
|
||||
vk_t *vk)
|
||||
static void vulkan_init_pipelines(vk_t *vk)
|
||||
{
|
||||
static const uint32_t alpha_blend_vert[] =
|
||||
#include "vulkan_shaders/alpha_blend.vert.inc"
|
||||
@ -834,7 +833,11 @@ static bool vulkan_init_filter_chain(vk_t *vk)
|
||||
|
||||
static void vulkan_init_resources(vk_t *vk)
|
||||
{
|
||||
if (!vk)
|
||||
return;
|
||||
|
||||
vk->num_swapchain_images = vk->context->num_swapchain_images;
|
||||
|
||||
vulkan_init_framebuffers(vk);
|
||||
vulkan_init_pipelines(vk);
|
||||
vulkan_init_descriptor_pool(vk);
|
||||
|
@ -1053,10 +1053,50 @@ static void gl_cg_set_program_attributes(void *data, unsigned i)
|
||||
}
|
||||
}
|
||||
|
||||
static void gl_cg_init_menu_shaders(void *data)
|
||||
{
|
||||
struct shader_program_info shader_prog_info;
|
||||
cg_shader_data_t *cg = (cg_shader_data_t*)data;
|
||||
|
||||
if (!cg)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_SHADERPIPELINE
|
||||
shader_prog_info.combined = stock_xmb_ribbon_simple;
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_cg_compile_program(
|
||||
cg,
|
||||
VIDEO_SHADER_MENU,
|
||||
&cg->prg[VIDEO_SHADER_MENU],
|
||||
&shader_prog_info);
|
||||
gl_cg_set_program_base_attrib(cg, VIDEO_SHADER_MENU);
|
||||
|
||||
shader_prog_info.combined = stock_xmb_ribbon_simple;
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_cg_compile_program(
|
||||
cg,
|
||||
VIDEO_SHADER_MENU_2,
|
||||
&cg->prg[VIDEO_SHADER_MENU_2],
|
||||
&shader_prog_info);
|
||||
gl_cg_set_program_base_attrib(cg, VIDEO_SHADER_MENU_2);
|
||||
|
||||
shader_prog_info.combined = stock_xmb_snow;
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_cg_compile_program(
|
||||
cg,
|
||||
VIDEO_SHADER_MENU_3,
|
||||
&cg->prg[VIDEO_SHADER_MENU_3],
|
||||
&shader_prog_info);
|
||||
gl_cg_set_program_base_attrib(cg, VIDEO_SHADER_MENU_3);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *gl_cg_init(void *data, const char *path)
|
||||
{
|
||||
unsigned i;
|
||||
struct shader_program_info shader_prog_info;
|
||||
cg_shader_data_t *cg = (cg_shader_data_t*)
|
||||
calloc(1, sizeof(cg_shader_data_t));
|
||||
|
||||
@ -1129,37 +1169,6 @@ static void *gl_cg_init(void *data, const char *path)
|
||||
|
||||
gl_cg_set_shaders(cg->prg[1].fprg, cg->prg[1].vprg);
|
||||
|
||||
#ifdef HAVE_SHADERPIPELINE
|
||||
shader_prog_info.combined = stock_xmb_ribbon_simple;
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_cg_compile_program(
|
||||
cg,
|
||||
VIDEO_SHADER_MENU,
|
||||
&cg->prg[VIDEO_SHADER_MENU],
|
||||
&shader_prog_info);
|
||||
gl_cg_set_program_base_attrib(cg, VIDEO_SHADER_MENU);
|
||||
|
||||
shader_prog_info.combined = stock_xmb_ribbon_simple;
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_cg_compile_program(
|
||||
cg,
|
||||
VIDEO_SHADER_MENU_2,
|
||||
&cg->prg[VIDEO_SHADER_MENU_2],
|
||||
&shader_prog_info);
|
||||
gl_cg_set_program_base_attrib(cg, VIDEO_SHADER_MENU_2);
|
||||
|
||||
shader_prog_info.combined = stock_xmb_snow;
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_cg_compile_program(
|
||||
cg,
|
||||
VIDEO_SHADER_MENU_3,
|
||||
&cg->prg[VIDEO_SHADER_MENU_3],
|
||||
&shader_prog_info);
|
||||
gl_cg_set_program_base_attrib(cg, VIDEO_SHADER_MENU_3);
|
||||
#endif
|
||||
|
||||
gl_cg_reset_attrib(cg);
|
||||
|
||||
@ -1271,6 +1280,7 @@ static struct video_shader *gl_cg_get_current_shader(void *data)
|
||||
|
||||
const shader_backend_t gl_cg_backend = {
|
||||
gl_cg_init,
|
||||
gl_cg_init_menu_shaders,
|
||||
gl_cg_deinit,
|
||||
gl_cg_set_params,
|
||||
gl_cg_set_uniform_parameter,
|
||||
|
@ -790,6 +790,113 @@ static void gl_glsl_deinit(void *data)
|
||||
free(glsl);
|
||||
}
|
||||
|
||||
static void gl_glsl_init_menu_shaders(void *data)
|
||||
{
|
||||
#ifdef HAVE_SHADERPIPELINE
|
||||
struct shader_program_info shader_prog_info;
|
||||
glsl_shader_data_t *glsl = (glsl_shader_data_t*)data;
|
||||
|
||||
if (!glsl)
|
||||
return;
|
||||
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gl_query_extension("GL_OES_standard_derivatives"))
|
||||
{
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_ribbon_modern : stock_vertex_xmb_ribbon_legacy;
|
||||
shader_prog_info.fragment = glsl_core ? core_stock_fragment_xmb : stock_fragment_xmb;
|
||||
}
|
||||
else
|
||||
{
|
||||
shader_prog_info.vertex = stock_vertex_xmb_ribbon_simple_legacy;
|
||||
shader_prog_info.fragment = stock_fragment_xmb_ribbon_simple;
|
||||
}
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_ribbon_modern : stock_vertex_xmb_ribbon_legacy;
|
||||
shader_prog_info.fragment = glsl_core ? core_stock_fragment_xmb : stock_fragment_xmb;
|
||||
#endif
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU,
|
||||
&glsl->prg[VIDEO_SHADER_MENU],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU]);
|
||||
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_simple_modern : stock_vertex_xmb_ribbon_simple_legacy;
|
||||
shader_prog_info.fragment = stock_fragment_xmb_ribbon_simple;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_2,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_2],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_2].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_2]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_simple_snow;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_3,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_3],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_3].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_3]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_snow;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_4,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_4],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_4].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_4]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_bokeh;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_5,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_5],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_5].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_5]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_snowflake;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_6,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_6],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_6].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_6]);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void *gl_glsl_init(void *data, const char *path)
|
||||
{
|
||||
unsigned i;
|
||||
@ -1015,104 +1122,6 @@ static void *gl_glsl_init(void *data, const char *path)
|
||||
glsl->uniforms[VIDEO_SHADER_STOCK_BLEND] = glsl->uniforms[0];
|
||||
}
|
||||
|
||||
#ifdef HAVE_SHADERPIPELINE
|
||||
#ifdef HAVE_OPENGLES
|
||||
if (gl_query_extension("GL_OES_standard_derivatives"))
|
||||
{
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_ribbon_modern : stock_vertex_xmb_ribbon_legacy;
|
||||
shader_prog_info.fragment = glsl_core ? core_stock_fragment_xmb : stock_fragment_xmb;
|
||||
}
|
||||
else
|
||||
{
|
||||
shader_prog_info.vertex = stock_vertex_xmb_ribbon_simple_legacy;
|
||||
shader_prog_info.fragment = stock_fragment_xmb_ribbon_simple;
|
||||
}
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_ribbon_modern : stock_vertex_xmb_ribbon_legacy;
|
||||
shader_prog_info.fragment = glsl_core ? core_stock_fragment_xmb : stock_fragment_xmb;
|
||||
#endif
|
||||
shader_prog_info.is_file = false;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU,
|
||||
&glsl->prg[VIDEO_SHADER_MENU],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU]);
|
||||
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_simple_modern : stock_vertex_xmb_ribbon_simple_legacy;
|
||||
shader_prog_info.fragment = stock_fragment_xmb_ribbon_simple;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_2,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_2],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_2].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_2]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_simple_snow;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_3,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_3],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_3].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_3]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_snow;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_4,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_4],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_4].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_4]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_bokeh;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_5,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_5],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_5].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_5]);
|
||||
|
||||
#if defined(HAVE_OPENGLES)
|
||||
shader_prog_info.vertex = stock_vertex_xmb_snow_modern;
|
||||
#else
|
||||
shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy;
|
||||
#endif
|
||||
shader_prog_info.fragment = stock_fragment_xmb_snowflake;
|
||||
|
||||
gl_glsl_compile_program(
|
||||
glsl,
|
||||
VIDEO_SHADER_MENU_6,
|
||||
&glsl->prg[VIDEO_SHADER_MENU_6],
|
||||
&shader_prog_info);
|
||||
gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_6].id,
|
||||
&glsl->uniforms[VIDEO_SHADER_MENU_6]);
|
||||
#endif
|
||||
|
||||
gl_glsl_reset_attrib(glsl);
|
||||
|
||||
for (i = 0; i < GFX_MAX_SHADERS; i++)
|
||||
@ -1688,6 +1697,7 @@ void gl_glsl_set_context_type(bool core_profile,
|
||||
|
||||
const shader_backend_t gl_glsl_backend = {
|
||||
gl_glsl_init,
|
||||
gl_glsl_init_menu_shaders,
|
||||
gl_glsl_deinit,
|
||||
gl_glsl_set_params,
|
||||
gl_glsl_set_uniform_parameter,
|
||||
|
@ -592,6 +592,7 @@ static struct video_shader *hlsl_get_current_shader(void *data)
|
||||
|
||||
const shader_backend_t hlsl_backend = {
|
||||
hlsl_init,
|
||||
NULL, /* hlsl_init_menu_shaders */
|
||||
hlsl_deinit,
|
||||
hlsl_set_params,
|
||||
hlsl_set_uniform_parameter,
|
||||
|
@ -77,6 +77,7 @@ static bool shader_null_compile_program(
|
||||
|
||||
const shader_backend_t shader_null_backend = {
|
||||
shader_null_init,
|
||||
NULL,
|
||||
shader_null_deinit,
|
||||
NULL,
|
||||
shader_null_set_uniform_parameter,
|
||||
|
@ -3545,7 +3545,8 @@ bool video_shader_driver_init_first(void)
|
||||
|
||||
bool video_shader_driver_init(video_shader_ctx_init_t *init)
|
||||
{
|
||||
void *tmp = NULL;
|
||||
void *tmp = NULL;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!init->shader || !init->shader->init)
|
||||
{
|
||||
@ -3560,6 +3561,10 @@ bool video_shader_driver_init(video_shader_ctx_init_t *init)
|
||||
if (!tmp)
|
||||
return false;
|
||||
|
||||
if (string_is_equal(settings->arrays.menu_driver, "xmb")
|
||||
&& init->shader->init_menu_shaders)
|
||||
init->shader->init_menu_shaders(tmp);
|
||||
|
||||
current_shader_data = tmp;
|
||||
current_shader = (shader_backend_t*)init->shader;
|
||||
video_shader_driver_reset_to_defaults();
|
||||
|
@ -200,6 +200,7 @@ struct uniform_info
|
||||
typedef struct shader_backend
|
||||
{
|
||||
void *(*init)(void *data, const char *path);
|
||||
void (*init_menu_shaders)(void *data);
|
||||
void (*deinit)(void *data);
|
||||
|
||||
/* Set shader parameters. */
|
||||
|
Loading…
x
Reference in New Issue
Block a user