// license:BSD-3-Clause // copyright-holders:Sven Gothel #include /* snprintf */ #include /* malloc */ #include "osdcomm.h" #include "osd_opengl.h" #include "gl_shader_mgr.h" #include "gl_shader_tool.h" #define GLSL_VERTEX_SHADER_INT_NUMBER 1 // general #define GLSL_VERTEX_SHADER_MAX_NUMBER 2 // general + custom #define GLSL_VERTEX_SHADER_CUSTOM 1 // custom idx #ifdef GLSL_SOURCE_ON_DISK static char const *const glsl_mamebm_vsh_files [GLSL_VERTEX_SHADER_INT_NUMBER] = { "/tmp/glsl_general.vsh" // general }; static char const *const glsl_mamebm_fsh_files [GLSL_SHADER_FEAT_INT_NUMBER] = { "/tmp/glsl_plain_rgb32_dir.fsh", // rgb32 dir plain "/tmp/glsl_bilinear_rgb32_dir.fsh", // rgb32 dir bilinear "/tmp/glsl_bicubic_rgb32_dir.fsh", // rgb32 dir bicubic }; #else // GLSL_SOURCE_ON_DISK #include "shader/glsl_general.vsh.c" #include "shader/glsl_plain_rgb32_dir.fsh.c" #include "shader/glsl_bilinear_rgb32_dir.fsh.c" #include "shader/glsl_bicubic_rgb32_dir.fsh.c" static char const *const glsl_mamebm_vsh_sources [GLSL_VERTEX_SHADER_INT_NUMBER] = { glsl_general_vsh_src // general }; static char const *const glsl_mamebm_fsh_sources [GLSL_SHADER_FEAT_INT_NUMBER] = { glsl_plain_rgb32_dir_fsh_src, // rgb32 dir plain glsl_bilinear_rgb32_dir_fsh_src, // rgb32 dir bilinear glsl_bicubic_rgb32_dir_fsh_src, // rgb32 dir bicubic }; #endif // GLSL_SOURCE_ON_DISK static char const *const glsl_mamebm_filter_names [GLSL_SHADER_FEAT_MAX_NUMBER] = { "plain", "bilinear", "bicubic", "custom" }; static GLhandleARB glsl_mamebm_programs [GLSL_SHADER_FEAT_MAX_NUMBER+9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* rgb32 dir: plain, bilinear, bicubic, custom0-9, .. */ }; /** * fragment shader -> vertex shader mapping */ static int glsl_mamebm_fsh2vsh[GLSL_SHADER_FEAT_MAX_NUMBER] = { 0, // plain -> general 0, // bilinear -> general 0, // bicubic -> general 1, // custom -> custom }; static GLhandleARB glsl_mamebm_vsh_shader[GLSL_VERTEX_SHADER_MAX_NUMBER+9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* general, custom0-9 */ static GLhandleARB glsl_mamebm_fsh_shader [GLSL_SHADER_FEAT_MAX_NUMBER+9] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* rgb32 dir: plain, bilinear, bicubic, custom0-9 */ }; static GLhandleARB glsl_scrn_programs [10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* rgb32: custom0-9, .. */ }; static GLhandleARB glsl_scrn_vsh_shader[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* custom0-9 */ static GLhandleARB glsl_scrn_fsh_shader [10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; /* rgb32: custom0-9 */ const char * glsl_shader_get_filter_name_mamebm(int glslShaderFeature) { if ( !(0 <= glslShaderFeature && glslShaderFeature < GLSL_SHADER_FEAT_MAX_NUMBER) ) return "illegal shader feature"; return glsl_mamebm_filter_names[glslShaderFeature]; } GLhandleARB glsl_shader_get_program_mamebm(int glslShaderFeature, int idx) { if ( !(0 <= glslShaderFeature && glslShaderFeature < GLSL_SHADER_FEAT_MAX_NUMBER) ) return 0; return glsl_mamebm_programs[glslShaderFeature+idx]; } GLhandleARB glsl_shader_get_program_scrn(int idx) { if ( !(0 <= idx && idx < 10) ) return 0; return glsl_scrn_programs[idx]; } glsl_shader_info *glsl_shader_init(osd_gl_context *gl_ctx) { int i,j, err; err = gl_shader_loadExtention(gl_ctx); if(err) return nullptr; for (i=0; !err && i