mirror of
https://github.com/libretro/RetroArch
synced 2025-02-11 15:40:28 +00:00
(gfx/shader) Declare variables at top of functions
This commit is contained in:
parent
94f6889d2d
commit
ffb87e5ab4
@ -38,6 +38,7 @@ static const shader_backend_t *shader_ctx_drivers[] = {
|
|||||||
const shader_backend_t *shader_ctx_find_driver(const char *ident)
|
const shader_backend_t *shader_ctx_find_driver(const char *ident)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; shader_ctx_drivers[i]; i++)
|
for (i = 0; shader_ctx_drivers[i]; i++)
|
||||||
{
|
{
|
||||||
if (strcmp(shader_ctx_drivers[i]->ident, ident) == 0)
|
if (strcmp(shader_ctx_drivers[i]->ident, ident) == 0)
|
||||||
@ -50,6 +51,7 @@ const shader_backend_t *shader_ctx_find_driver(const char *ident)
|
|||||||
const shader_backend_t *shader_ctx_init_first(void)
|
const shader_backend_t *shader_ctx_init_first(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; shader_ctx_drivers[i]; i++)
|
for (i = 0; shader_ctx_drivers[i]; i++)
|
||||||
return shader_ctx_drivers[i];
|
return shader_ctx_drivers[i];
|
||||||
|
|
||||||
|
@ -729,11 +729,12 @@ static void set_program_base_attrib(cg_shader_data_t *cg, unsigned i)
|
|||||||
CGparameter param = cgGetFirstParameter(cg->prg[i].vprg, CG_PROGRAM);
|
CGparameter param = cgGetFirstParameter(cg->prg[i].vprg, CG_PROGRAM);
|
||||||
for (; param; param = cgGetNextParameter(param))
|
for (; param; param = cgGetNextParameter(param))
|
||||||
{
|
{
|
||||||
|
const char *semantic = NULL;
|
||||||
if (cgGetParameterDirection(param) != CG_IN
|
if (cgGetParameterDirection(param) != CG_IN
|
||||||
|| cgGetParameterVariability(param) != CG_VARYING)
|
|| cgGetParameterVariability(param) != CG_VARYING)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const char *semantic = cgGetParameterSemantic(param);
|
semantic = cgGetParameterSemantic(param);
|
||||||
if (!semantic)
|
if (!semantic)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -822,16 +823,15 @@ static void set_program_attributes(cg_shader_data_t *cg, unsigned i)
|
|||||||
if (i > 1)
|
if (i > 1)
|
||||||
{
|
{
|
||||||
char pass_str[64];
|
char pass_str[64];
|
||||||
|
|
||||||
snprintf(pass_str, sizeof(pass_str), "PASSPREV%u", i);
|
snprintf(pass_str, sizeof(pass_str), "PASSPREV%u", i);
|
||||||
set_pass_attrib(&cg->prg[i], &cg->prg[i].orig, pass_str);
|
set_pass_attrib(&cg->prg[i], &cg->prg[i].orig, pass_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = 0; j < PREV_TEXTURES; j++)
|
for (j = 0; j < PREV_TEXTURES; j++)
|
||||||
{
|
{
|
||||||
char attr_buf_tex[64];
|
char attr_buf_tex[64], attr_buf_vid_size[64];
|
||||||
char attr_buf_vid_size[64];
|
char attr_buf_tex_size[64], attr_buf_coord[64];
|
||||||
char attr_buf_tex_size[64];
|
|
||||||
char attr_buf_coord[64];
|
|
||||||
static const char *prev_names[PREV_TEXTURES] = {
|
static const char *prev_names[PREV_TEXTURES] = {
|
||||||
"PREV",
|
"PREV",
|
||||||
"PREV1",
|
"PREV1",
|
||||||
@ -987,9 +987,9 @@ static void gl_cg_use(void *data, unsigned idx)
|
|||||||
static unsigned gl_cg_num(void)
|
static unsigned gl_cg_num(void)
|
||||||
{
|
{
|
||||||
cg_shader_data_t *cg = (cg_shader_data_t*)driver.video_shader_data;
|
cg_shader_data_t *cg = (cg_shader_data_t*)driver.video_shader_data;
|
||||||
if (cg)
|
if (!cg)
|
||||||
return cg->cg_shader->passes;
|
return 0;
|
||||||
return 0;
|
return cg->cg_shader->passes;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool gl_cg_filter_type(unsigned idx, bool *smooth)
|
static bool gl_cg_filter_type(unsigned idx, bool *smooth)
|
||||||
@ -1053,9 +1053,9 @@ static bool gl_cg_mipmap_input(unsigned idx)
|
|||||||
static struct gfx_shader *gl_cg_get_current_shader(void)
|
static struct gfx_shader *gl_cg_get_current_shader(void)
|
||||||
{
|
{
|
||||||
cg_shader_data_t *cg = (cg_shader_data_t*)driver.video_shader_data;
|
cg_shader_data_t *cg = (cg_shader_data_t*)driver.video_shader_data;
|
||||||
if (cg)
|
if (!cg)
|
||||||
return cg->cg_shader;
|
return NULL;
|
||||||
return NULL;
|
return cg->cg_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
const shader_backend_t gl_cg_backend = {
|
const shader_backend_t gl_cg_backend = {
|
||||||
|
@ -227,9 +227,10 @@ static GLint get_uniform(glsl_shader_data_t *glsl,
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
GLint loc;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s%s", glsl->glsl_shader->prefix, base);
|
snprintf(buf, sizeof(buf), "%s%s", glsl->glsl_shader->prefix, base);
|
||||||
GLint loc = glGetUniformLocation(prog, buf);
|
loc = glGetUniformLocation(prog, buf);
|
||||||
if (loc >= 0)
|
if (loc >= 0)
|
||||||
return loc;
|
return loc;
|
||||||
|
|
||||||
@ -249,8 +250,10 @@ static GLint get_attrib(glsl_shader_data_t *glsl,
|
|||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
char buf[64];
|
char buf[64];
|
||||||
|
GLint loc;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s%s", glsl->glsl_shader->prefix, base);
|
snprintf(buf, sizeof(buf), "%s%s", glsl->glsl_shader->prefix, base);
|
||||||
GLint loc = glGetUniformLocation(prog, buf);
|
loc = glGetUniformLocation(prog, buf);
|
||||||
if (loc >= 0)
|
if (loc >= 0)
|
||||||
return loc;
|
return loc;
|
||||||
|
|
||||||
@ -267,15 +270,15 @@ static GLint get_attrib(glsl_shader_data_t *glsl,
|
|||||||
|
|
||||||
static void print_shader_log(GLuint obj)
|
static void print_shader_log(GLuint obj)
|
||||||
{
|
{
|
||||||
GLint info_len = 0;
|
char *info_log;
|
||||||
GLint max_len;
|
GLint max_len, info_len = 0;
|
||||||
|
|
||||||
glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &max_len);
|
glGetShaderiv(obj, GL_INFO_LOG_LENGTH, &max_len);
|
||||||
|
|
||||||
if (max_len == 0)
|
if (max_len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char *info_log = (char*)malloc(max_len);
|
info_log = (char*)malloc(max_len);
|
||||||
if (!info_log)
|
if (!info_log)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -289,15 +292,15 @@ static void print_shader_log(GLuint obj)
|
|||||||
|
|
||||||
static void print_linker_log(GLuint obj)
|
static void print_linker_log(GLuint obj)
|
||||||
{
|
{
|
||||||
GLint info_len = 0;
|
char *info_log;
|
||||||
GLint max_len;
|
GLint max_len, info_len = 0;
|
||||||
|
|
||||||
glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &max_len);
|
glGetProgramiv(obj, GL_INFO_LOG_LENGTH, &max_len);
|
||||||
|
|
||||||
if (max_len == 0)
|
if (max_len == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char *info_log = (char*)malloc(max_len);
|
info_log = (char*)malloc(max_len);
|
||||||
if (!info_log)
|
if (!info_log)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -318,6 +321,7 @@ static bool compile_shader(glsl_shader_data_t *glsl,
|
|||||||
{
|
{
|
||||||
unsigned version_no = 0;
|
unsigned version_no = 0;
|
||||||
unsigned gl_ver = glsl_major * 100 + glsl_minor * 10;
|
unsigned gl_ver = glsl_major * 100 + glsl_minor * 10;
|
||||||
|
|
||||||
switch (gl_ver)
|
switch (gl_ver)
|
||||||
{
|
{
|
||||||
case 300:
|
case 300:
|
||||||
@ -357,25 +361,21 @@ static bool link_program(GLuint prog)
|
|||||||
glGetProgramiv(prog, GL_LINK_STATUS, &status);
|
glGetProgramiv(prog, GL_LINK_STATUS, &status);
|
||||||
print_linker_log(prog);
|
print_linker_log(prog);
|
||||||
|
|
||||||
if (status == GL_TRUE)
|
if (status != GL_TRUE)
|
||||||
{
|
return false;
|
||||||
glUseProgram(prog);
|
|
||||||
return true;
|
glUseProgram(prog);
|
||||||
}
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLuint compile_program(glsl_shader_data_t *glsl,
|
static GLuint compile_program(glsl_shader_data_t *glsl,
|
||||||
const char *vertex,
|
const char *vertex,
|
||||||
const char *fragment, unsigned i)
|
const char *fragment, unsigned i)
|
||||||
{
|
{
|
||||||
GLuint prog = glCreateProgram();
|
GLuint vert = 0, frag = 0, prog = glCreateProgram();
|
||||||
if (!prog)
|
if (!prog)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
GLuint vert = 0;
|
|
||||||
GLuint frag = 0;
|
|
||||||
|
|
||||||
if (vertex)
|
if (vertex)
|
||||||
{
|
{
|
||||||
RARCH_LOG("Found GLSL vertex shader.\n");
|
RARCH_LOG("Found GLSL vertex shader.\n");
|
||||||
@ -444,8 +444,11 @@ static bool load_source_path(struct gfx_shader_pass *pass,
|
|||||||
static bool compile_programs(glsl_shader_data_t *glsl, GLuint *gl_prog)
|
static bool compile_programs(glsl_shader_data_t *glsl, GLuint *gl_prog)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < glsl->glsl_shader->passes; i++)
|
for (i = 0; i < glsl->glsl_shader->passes; i++)
|
||||||
{
|
{
|
||||||
|
const char *vertex = NULL;
|
||||||
|
const char *fragment = NULL;
|
||||||
struct gfx_shader_pass *pass = (struct gfx_shader_pass*)
|
struct gfx_shader_pass *pass = (struct gfx_shader_pass*)
|
||||||
&glsl->glsl_shader->pass[i];
|
&glsl->glsl_shader->pass[i];
|
||||||
|
|
||||||
@ -460,8 +463,8 @@ static bool compile_programs(glsl_shader_data_t *glsl, GLuint *gl_prog)
|
|||||||
}
|
}
|
||||||
*pass->source.path = '\0';
|
*pass->source.path = '\0';
|
||||||
|
|
||||||
const char *vertex = pass->source.string.vertex;
|
vertex = pass->source.string.vertex;
|
||||||
const char *fragment = pass->source.string.fragment;
|
fragment = pass->source.string.fragment;
|
||||||
|
|
||||||
gl_prog[i] = compile_program(glsl, vertex, fragment, i);
|
gl_prog[i] = compile_program(glsl, vertex, fragment, i);
|
||||||
|
|
||||||
@ -478,6 +481,7 @@ static bool compile_programs(glsl_shader_data_t *glsl, GLuint *gl_prog)
|
|||||||
static void gl_glsl_reset_attrib(glsl_shader_data_t *glsl)
|
static void gl_glsl_reset_attrib(glsl_shader_data_t *glsl)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
/* Add sanity check that we did not overflow. */
|
/* Add sanity check that we did not overflow. */
|
||||||
rarch_assert(glsl->gl_attrib_index <= ARRAY_SIZE(glsl->gl_attribs));
|
rarch_assert(glsl->gl_attrib_index <= ARRAY_SIZE(glsl->gl_attribs));
|
||||||
|
|
||||||
@ -514,6 +518,7 @@ static void gl_glsl_set_attribs(glsl_shader_data_t *glsl,
|
|||||||
const struct glsl_attrib *attrs, size_t num_attrs)
|
const struct glsl_attrib *attrs, size_t num_attrs)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||||
|
|
||||||
gl_glsl_set_vbo(buffer, buffer_elems, data, elems);
|
gl_glsl_set_vbo(buffer, buffer_elems, data, elems);
|
||||||
@ -548,10 +553,8 @@ static void find_uniforms_frame(glsl_shader_data_t *glsl,
|
|||||||
GLuint prog,
|
GLuint prog,
|
||||||
struct shader_uniforms_frame *frame, const char *base)
|
struct shader_uniforms_frame *frame, const char *base)
|
||||||
{
|
{
|
||||||
char texture[64];
|
char texture[64], texture_size[64];
|
||||||
char texture_size[64];
|
char input_size[64], tex_coord[64];
|
||||||
char input_size[64];
|
|
||||||
char tex_coord[64];
|
|
||||||
|
|
||||||
snprintf(texture, sizeof(texture), "%s%s", base, "Texture");
|
snprintf(texture, sizeof(texture), "%s%s", base, "Texture");
|
||||||
snprintf(texture_size, sizeof(texture_size), "%s%s", base, "TextureSize");
|
snprintf(texture_size, sizeof(texture_size), "%s%s", base, "TextureSize");
|
||||||
@ -572,7 +575,9 @@ static void find_uniforms(glsl_shader_data_t *glsl,
|
|||||||
unsigned pass, GLuint prog,
|
unsigned pass, GLuint prog,
|
||||||
struct shader_uniforms *uni)
|
struct shader_uniforms *uni)
|
||||||
{
|
{
|
||||||
|
char frame_base[64];
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
glUseProgram(prog);
|
glUseProgram(prog);
|
||||||
|
|
||||||
uni->mvp = get_uniform(glsl, prog, "MVPMatrix");
|
uni->mvp = get_uniform(glsl, prog, "MVPMatrix");
|
||||||
@ -591,7 +596,6 @@ static void find_uniforms(glsl_shader_data_t *glsl,
|
|||||||
for (i = 0; i < glsl->glsl_shader->luts; i++)
|
for (i = 0; i < glsl->glsl_shader->luts; i++)
|
||||||
uni->lut_texture[i] = glGetUniformLocation(prog, glsl->glsl_shader->lut[i].id);
|
uni->lut_texture[i] = glGetUniformLocation(prog, glsl->glsl_shader->lut[i].id);
|
||||||
|
|
||||||
char frame_base[64];
|
|
||||||
clear_uniforms_frame(&uni->orig);
|
clear_uniforms_frame(&uni->orig);
|
||||||
find_uniforms_frame(glsl, prog, &uni->orig, "Orig");
|
find_uniforms_frame(glsl, prog, &uni->orig, "Orig");
|
||||||
if (pass > 1)
|
if (pass > 1)
|
||||||
@ -627,6 +631,7 @@ static void find_uniforms(glsl_shader_data_t *glsl,
|
|||||||
static void gl_glsl_deinit_shader(glsl_shader_data_t *glsl)
|
static void gl_glsl_deinit_shader(glsl_shader_data_t *glsl)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (!glsl || !glsl->glsl_shader)
|
if (!glsl || !glsl->glsl_shader)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -644,6 +649,7 @@ static void gl_glsl_deinit_shader(glsl_shader_data_t *glsl)
|
|||||||
static void gl_glsl_destroy_resources(glsl_shader_data_t *glsl)
|
static void gl_glsl_destroy_resources(glsl_shader_data_t *glsl)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
if (!glsl)
|
if (!glsl)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -701,8 +707,11 @@ static void gl_glsl_deinit(void)
|
|||||||
static bool gl_glsl_init(void *data, const char *path)
|
static bool gl_glsl_init(void *data, const char *path)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
config_file_t *conf = NULL;
|
config_file_t *conf = NULL;
|
||||||
glsl_shader_data_t *glsl = NULL;
|
glsl_shader_data_t *glsl = NULL;
|
||||||
|
const char *stock_vertex = NULL;
|
||||||
|
const char *stock_fragment = NULL;
|
||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
|
|
||||||
glsl = (glsl_shader_data_t*)calloc(1, sizeof(glsl_shader_data_t));
|
glsl = (glsl_shader_data_t*)calloc(1, sizeof(glsl_shader_data_t));
|
||||||
@ -793,9 +802,9 @@ static bool gl_glsl_init(void *data, const char *path)
|
|||||||
conf = NULL;
|
conf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *stock_vertex = glsl->glsl_shader->modern ?
|
stock_vertex = (glsl->glsl_shader->modern) ?
|
||||||
stock_vertex_modern : stock_vertex_legacy;
|
stock_vertex_modern : stock_vertex_legacy;
|
||||||
const char *stock_fragment = glsl->glsl_shader->modern ?
|
stock_fragment = (glsl->glsl_shader->modern) ?
|
||||||
stock_fragment_modern : stock_fragment_legacy;
|
stock_fragment_modern : stock_fragment_legacy;
|
||||||
|
|
||||||
if (glsl_core)
|
if (glsl_core)
|
||||||
@ -858,6 +867,7 @@ static bool gl_glsl_init(void *data, const char *path)
|
|||||||
if (glsl->glsl_shader->variables)
|
if (glsl->glsl_shader->variables)
|
||||||
{
|
{
|
||||||
struct state_tracker_info info = {0};
|
struct state_tracker_info info = {0};
|
||||||
|
|
||||||
info.wram = (uint8_t*)pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
|
info.wram = (uint8_t*)pretro_get_memory_data(RETRO_MEMORY_SYSTEM_RAM);
|
||||||
info.info = glsl->glsl_shader->variable;
|
info.info = glsl->glsl_shader->variable;
|
||||||
info.info_elem = glsl->glsl_shader->variables;
|
info.info_elem = glsl->glsl_shader->variables;
|
||||||
@ -925,7 +935,8 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
|
|||||||
{
|
{
|
||||||
GLfloat buffer[512];
|
GLfloat buffer[512];
|
||||||
struct glsl_attrib attribs[32];
|
struct glsl_attrib attribs[32];
|
||||||
unsigned i;
|
float input_size[2], output_size[2], texture_size[2];
|
||||||
|
unsigned i, texunit = 1;
|
||||||
const struct shader_uniforms *uni = NULL;
|
const struct shader_uniforms *uni = NULL;
|
||||||
size_t size = 0, attribs_size = 0;
|
size_t size = 0, attribs_size = 0;
|
||||||
const struct gl_tex_info *info = (const struct gl_tex_info*)_info;
|
const struct gl_tex_info *info = (const struct gl_tex_info*)_info;
|
||||||
@ -944,9 +955,12 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
|
|||||||
if (glsl->gl_program[glsl->glsl_active_index] == 0)
|
if (glsl->gl_program[glsl->glsl_active_index] == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float input_size[2] = {(float)width, (float)height};
|
input_size [0] = (float)width;
|
||||||
float output_size[2] = {(float)out_width, (float)out_height};
|
input_size [1] = (float)height;
|
||||||
float texture_size[2] = {(float)tex_width, (float)tex_height};
|
output_size[0] = (float)out_width;
|
||||||
|
output_size[1] = (float)out_height;
|
||||||
|
texture_size[0] = (float)tex_width;
|
||||||
|
texture_size[1] = (float)tex_height;
|
||||||
|
|
||||||
if (uni->input_size >= 0)
|
if (uni->input_size >= 0)
|
||||||
glUniform2fv(uni->input_size, 1, input_size);
|
glUniform2fv(uni->input_size, 1, input_size);
|
||||||
@ -960,6 +974,7 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
|
|||||||
if (uni->frame_count >= 0 && glsl->glsl_active_index)
|
if (uni->frame_count >= 0 && glsl->glsl_active_index)
|
||||||
{
|
{
|
||||||
unsigned modulo = glsl->glsl_shader->pass[glsl->glsl_active_index - 1].frame_count_mod;
|
unsigned modulo = glsl->glsl_shader->pass[glsl->glsl_active_index - 1].frame_count_mod;
|
||||||
|
|
||||||
if (modulo)
|
if (modulo)
|
||||||
frame_count %= modulo;
|
frame_count %= modulo;
|
||||||
glUniform1i(uni->frame_count, frame_count);
|
glUniform1i(uni->frame_count, frame_count);
|
||||||
@ -968,7 +983,6 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
|
|||||||
if (uni->frame_direction >= 0)
|
if (uni->frame_direction >= 0)
|
||||||
glUniform1i(uni->frame_direction, g_extern.frame_is_reverse ? -1 : 1);
|
glUniform1i(uni->frame_direction, g_extern.frame_is_reverse ? -1 : 1);
|
||||||
|
|
||||||
unsigned texunit = 1;
|
|
||||||
|
|
||||||
for (i = 0; i < glsl->glsl_shader->luts; i++)
|
for (i = 0; i < glsl->glsl_shader->luts; i++)
|
||||||
{
|
{
|
||||||
@ -1116,6 +1130,7 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
|
|||||||
|
|
||||||
static bool gl_glsl_set_mvp(void *data, const math_matrix_4x4 *mat)
|
static bool gl_glsl_set_mvp(void *data, const math_matrix_4x4 *mat)
|
||||||
{
|
{
|
||||||
|
int loc;
|
||||||
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
@ -1128,7 +1143,7 @@ static bool gl_glsl_set_mvp(void *data, const math_matrix_4x4 *mat)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loc = glsl->gl_uniforms[glsl->glsl_active_index].mvp;
|
loc = glsl->gl_uniforms[glsl->glsl_active_index].mvp;
|
||||||
if (loc >= 0)
|
if (loc >= 0)
|
||||||
glUniformMatrix4fv(loc, 1, GL_FALSE, mat->data);
|
glUniformMatrix4fv(loc, 1, GL_FALSE, mat->data);
|
||||||
|
|
||||||
@ -1137,6 +1152,13 @@ static bool gl_glsl_set_mvp(void *data, const math_matrix_4x4 *mat)
|
|||||||
|
|
||||||
static bool gl_glsl_set_coords(const void *data)
|
static bool gl_glsl_set_coords(const void *data)
|
||||||
{
|
{
|
||||||
|
/* Avoid hitting malloc on every single regular quad draw. */
|
||||||
|
GLfloat short_buffer[4 * (2 + 2 + 4 + 2)];
|
||||||
|
GLfloat *buffer;
|
||||||
|
struct glsl_attrib attribs[4];
|
||||||
|
size_t attribs_size = 0, size = 0;
|
||||||
|
struct glsl_attrib *attr = NULL;
|
||||||
|
const struct shader_uniforms *uni = NULL;
|
||||||
const struct gl_coords *coords = (const struct gl_coords*)data;
|
const struct gl_coords *coords = (const struct gl_coords*)data;
|
||||||
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
||||||
|
|
||||||
@ -1148,9 +1170,7 @@ static bool gl_glsl_set_coords(const void *data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Avoid hitting malloc on every single regular quad draw. */
|
buffer = short_buffer;
|
||||||
GLfloat short_buffer[4 * (2 + 2 + 4 + 2)];
|
|
||||||
GLfloat *buffer = short_buffer;
|
|
||||||
if (coords->vertices > 4)
|
if (coords->vertices > 4)
|
||||||
buffer = (GLfloat*)calloc(coords->vertices *
|
buffer = (GLfloat*)calloc(coords->vertices *
|
||||||
(2 + 2 + 4 + 2), sizeof(*buffer));
|
(2 + 2 + 4 + 2), sizeof(*buffer));
|
||||||
@ -1163,13 +1183,8 @@ static bool gl_glsl_set_coords(const void *data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = 0;
|
attr = attribs;
|
||||||
|
uni = &glsl->gl_uniforms[glsl->glsl_active_index];
|
||||||
struct glsl_attrib attribs[4];
|
|
||||||
size_t attribs_size = 0;
|
|
||||||
struct glsl_attrib *attr = attribs;
|
|
||||||
|
|
||||||
const struct shader_uniforms *uni = &glsl->gl_uniforms[glsl->glsl_active_index];
|
|
||||||
|
|
||||||
if (uni->tex_coord >= 0)
|
if (uni->tex_coord >= 0)
|
||||||
{
|
{
|
||||||
@ -1235,6 +1250,7 @@ static bool gl_glsl_set_coords(const void *data)
|
|||||||
|
|
||||||
if (buffer != short_buffer)
|
if (buffer != short_buffer)
|
||||||
free(buffer);
|
free(buffer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1294,12 +1310,13 @@ static void gl_glsl_shader_scale(unsigned idx, struct gfx_fbo_scale *scale)
|
|||||||
static unsigned gl_glsl_get_prev_textures(void)
|
static unsigned gl_glsl_get_prev_textures(void)
|
||||||
{
|
{
|
||||||
unsigned i, j;
|
unsigned i, j;
|
||||||
|
unsigned max_prev = 0;
|
||||||
|
|
||||||
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
||||||
|
|
||||||
if (!glsl)
|
if (!glsl)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
unsigned max_prev = 0;
|
|
||||||
for (i = 1; i <= glsl->glsl_shader->passes; i++)
|
for (i = 1; i <= glsl->glsl_shader->passes; i++)
|
||||||
for (j = 0; j < PREV_TEXTURES; j++)
|
for (j = 0; j < PREV_TEXTURES; j++)
|
||||||
if (glsl->gl_uniforms[i].prev[j].texture >= 0)
|
if (glsl->gl_uniforms[i].prev[j].texture >= 0)
|
||||||
@ -1319,9 +1336,9 @@ static bool gl_glsl_mipmap_input(unsigned idx)
|
|||||||
static struct gfx_shader *gl_glsl_get_current_shader(void)
|
static struct gfx_shader *gl_glsl_get_current_shader(void)
|
||||||
{
|
{
|
||||||
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
glsl_shader_data_t *glsl = (glsl_shader_data_t*)driver.video_shader_data;
|
||||||
if (glsl)
|
if (!glsl)
|
||||||
return glsl->glsl_shader;
|
return NULL;
|
||||||
return NULL;
|
return glsl->glsl_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_glsl_set_get_proc_address(gfx_ctx_proc_t (*proc)(const char*))
|
void gl_glsl_set_get_proc_address(gfx_ctx_proc_t (*proc)(const char*))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user