mirror of
https://github.com/libretro/RetroArch
synced 2025-04-24 06:02:36 +00:00
Set parameter uniforms.
This commit is contained in:
parent
5c3e2f9e0a
commit
83b37812b8
@ -132,7 +132,6 @@ struct cg_program
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct cg_program prg[GFX_MAX_SHADERS];
|
static struct cg_program prg[GFX_MAX_SHADERS];
|
||||||
static const char **cg_arguments;
|
|
||||||
static bool cg_active;
|
static bool cg_active;
|
||||||
static CGprofile cgVProf, cgFProf;
|
static CGprofile cgVProf, cgFProf;
|
||||||
static unsigned active_index;
|
static unsigned active_index;
|
||||||
@ -313,6 +312,15 @@ static void gl_cg_set_params(void *data, unsigned width, unsigned height,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// #pragma parameters
|
||||||
|
for (i = 0; i < cg_shader->num_parameters; i++)
|
||||||
|
{
|
||||||
|
CGparameter param_v = cgGetNamedParameter(prg[active_index].vprg, cg_shader->parameters[i].id);
|
||||||
|
CGparameter param_f = cgGetNamedParameter(prg[active_index].fprg, cg_shader->parameters[i].id);
|
||||||
|
set_param_1f(param_v, cg_shader->parameters[i].current);
|
||||||
|
set_param_1f(param_f, cg_shader->parameters[i].current);
|
||||||
|
}
|
||||||
|
|
||||||
// Set state parameters
|
// Set state parameters
|
||||||
if (state_tracker)
|
if (state_tracker)
|
||||||
{
|
{
|
||||||
@ -414,18 +422,23 @@ static bool load_program(unsigned index, const char *prog, bool path_is_file)
|
|||||||
char *listing_f = NULL;
|
char *listing_f = NULL;
|
||||||
char *listing_v = NULL;
|
char *listing_v = NULL;
|
||||||
|
|
||||||
|
static const char *argv[] = {
|
||||||
|
"-DPARAMETER_UNIFORM",
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
if (path_is_file)
|
if (path_is_file)
|
||||||
{
|
{
|
||||||
prg[index].fprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE, prog, cgFProf, "main_fragment", cg_arguments);
|
prg[index].fprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE, prog, cgFProf, "main_fragment", argv);
|
||||||
SET_LISTING(f);
|
SET_LISTING(f);
|
||||||
prg[index].vprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE, prog, cgVProf, "main_vertex", cg_arguments);
|
prg[index].vprg = cgCreateProgramFromFile(cgCtx, CG_SOURCE, prog, cgVProf, "main_vertex", argv);
|
||||||
SET_LISTING(v);
|
SET_LISTING(v);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
prg[index].fprg = cgCreateProgram(cgCtx, CG_SOURCE, prog, cgFProf, "main_fragment", cg_arguments);
|
prg[index].fprg = cgCreateProgram(cgCtx, CG_SOURCE, prog, cgFProf, "main_fragment", argv);
|
||||||
SET_LISTING(f);
|
SET_LISTING(f);
|
||||||
prg[index].vprg = cgCreateProgram(cgCtx, CG_SOURCE, prog, cgVProf, "main_vertex", cg_arguments);
|
prg[index].vprg = cgCreateProgram(cgCtx, CG_SOURCE, prog, cgVProf, "main_vertex", argv);
|
||||||
SET_LISTING(v);
|
SET_LISTING(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,11 +913,6 @@ static bool gl_cg_mipmap_input(unsigned index)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gl_cg_set_compiler_args(const char **argv)
|
|
||||||
{
|
|
||||||
cg_arguments = argv;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gl_cg_invalidate_context(void)
|
void gl_cg_invalidate_context(void)
|
||||||
{
|
{
|
||||||
cgCtx = NULL;
|
cgCtx = NULL;
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
#include "shader_common.h"
|
#include "shader_common.h"
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
void gl_cg_set_compiler_args(const char **argv);
|
|
||||||
void gl_cg_invalidate_context(void); // Call when resetting GL context on PS3.
|
void gl_cg_invalidate_context(void); // Call when resetting GL context on PS3.
|
||||||
extern const gl_shader_backend_t gl_cg_backend;
|
extern const gl_shader_backend_t gl_cg_backend;
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ static GLuint compile_program(const char *vertex, const char *fragment, unsigned
|
|||||||
{
|
{
|
||||||
RARCH_LOG("Found GLSL vertex shader.\n");
|
RARCH_LOG("Found GLSL vertex shader.\n");
|
||||||
vert = glCreateShader(GL_VERTEX_SHADER);
|
vert = glCreateShader(GL_VERTEX_SHADER);
|
||||||
if (!compile_shader(vert, "#define VERTEX\n", vertex))
|
if (!compile_shader(vert, "#define VERTEX\n#define PARAMETER_UNIFORM\n", vertex))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to compile vertex shader #%u\n", i);
|
RARCH_ERR("Failed to compile vertex shader #%u\n", i);
|
||||||
return false;
|
return false;
|
||||||
@ -379,7 +379,7 @@ static GLuint compile_program(const char *vertex, const char *fragment, unsigned
|
|||||||
{
|
{
|
||||||
RARCH_LOG("Found GLSL fragment shader.\n");
|
RARCH_LOG("Found GLSL fragment shader.\n");
|
||||||
frag = glCreateShader(GL_FRAGMENT_SHADER);
|
frag = glCreateShader(GL_FRAGMENT_SHADER);
|
||||||
if (!compile_shader(frag, "#define FRAGMENT\n", fragment))
|
if (!compile_shader(frag, "#define FRAGMENT\n#define PARAMETER_UNIFORM\n", fragment))
|
||||||
{
|
{
|
||||||
RARCH_ERR("Failed to compile fragment shader #%u\n", i);
|
RARCH_ERR("Failed to compile fragment shader #%u\n", i);
|
||||||
return false;
|
return false;
|
||||||
@ -1000,6 +1000,14 @@ static void gl_glsl_set_params(void *data, unsigned width, unsigned height,
|
|||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
|
||||||
|
// #pragma parameters
|
||||||
|
for (i = 0; i < glsl_shader->num_parameters; i++)
|
||||||
|
{
|
||||||
|
int location = glGetUniformLocation(gl_program[active_index], glsl_shader->parameters[i].id);
|
||||||
|
glUniform1f(location, glsl_shader->parameters[i].current);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set state parameters
|
||||||
if (gl_state_tracker)
|
if (gl_state_tracker)
|
||||||
{
|
{
|
||||||
static struct state_tracker_uniform info[GFX_MAX_VARIABLES];
|
static struct state_tracker_uniform info[GFX_MAX_VARIABLES];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user