UFO: Alien Invasion
|
Shader (GLSL) backend functions. More...
#include "r_local.h"
#include "r_error.h"
#include "r_program.h"
#include "../../shared/parse.h"
#include "../../shared/shared.h"
Go to the source code of this file.
Macros | |
#define | SHADER_BUF_SIZE 16384 |
#define | FILTER_SIZE 3 |
width of convolution filter (for blur/bloom effects) More... | |
Enumerations | |
enum | shaderQualityLevel_t { SHQ_LOW, SHQ_MID, SHQ_HIGH, SHQ_NUM } |
Functions | |
void | R_UseProgram (r_program_t *prog) |
static r_progvar_t * | R_ProgramVariable (int type, const char *name) |
void | R_ProgramParameter1i (const char *name, GLint value) |
void | R_ProgramParameter1f (const char *name, GLfloat value) |
void | R_ProgramParameter1fvs (const char *name, GLint size, GLfloat *value) |
void | R_ProgramParameter2fv (const char *name, GLfloat *value) |
void | R_ProgramParameter2fvs (const char *name, GLint size, GLfloat *value) |
void | R_ProgramParameter3fv (const char *name, GLfloat *value) |
void | R_ProgramParameter3fvs (const char *name, GLint size, GLfloat *value) |
void | R_ProgramParameter4fv (const char *name, GLfloat *value) |
void | R_ProgramParameter4fvs (const char *name, GLint size, GLfloat *value) |
void | R_ProgramParameterMatrix4fv (const char *name, GLfloat *value) |
void | R_AttributePointer (const char *name, GLuint size, const GLvoid *array) |
void | R_EnableAttribute (const char *name) |
void | R_DisableAttribute (const char *name) |
static void | R_ShutdownShader (r_shader_t *sh) |
static void | R_ShutdownProgram (r_program_t *prog) |
void | R_ShutdownPrograms (void) |
static size_t | R_PreprocessShaderAddToShaderBuf (const char *name, const char *in, char **out, size_t *len) |
Prefixes shader string (out) with in. More... | |
static size_t | R_InitializeShader (const GLenum type, const char *name, char *out, size_t len) |
Prefixes the shader string with user settings and the video hardware manufacturer. More... | |
static size_t | R_PreprocessShaderR (const char *name, const char **inPtr, char *out, long *remainingOutChars, bool nested, bool inElse) |
Do our own preprocessing to the shader file, before the GLSL implementation calls it's preprocessor. More... | |
static size_t | R_PreprocessShader (const char *name, const char *in, char *out, size_t *remainingOutChars) |
Do our own preprocessing to the shader file, before the GLSL implementation calls it's preprocessor. More... | |
static r_shader_t * | R_LoadShader (const GLenum type, const char *name) |
Reads/Preprocesses/Compiles the specified shader into a program. More... | |
r_program_t * | R_LoadProgram (const char *name, programInitFunc_t init, programUseFunc_t use) |
static void | R_InitWorldProgram (r_program_t *prog) |
static void | R_UseWorldProgram (r_program_t *prog) |
static void | R_InitModelProgram (r_program_t *prog) |
static void | R_UseModelProgram (r_program_t *prog) |
static void | R_InitWarpProgram (r_program_t *prog) |
static void | R_UseWarpProgram (r_program_t *prog) |
static void | R_InitGeoscapeProgram (r_program_t *prog) |
static int | R_PascalTriangle (int row, int col) |
static void | R_InitConvolveProgram (r_program_t *prog) |
static void | R_UseConvolveProgram (r_program_t *prog) |
Use the filter convolution glsl program. More... | |
static void | R_InitCombine2Program (r_program_t *prog) |
static void | R_InitAtmosphereProgram (r_program_t *prog) |
static void | R_InitSimpleGlowProgram (r_program_t *prog) |
void | R_InitParticleProgram (r_program_t *prog) |
void | R_UseParticleProgram (r_program_t *prog) |
void | R_InitPrograms (void) |
void | R_RestartPrograms_f (void) |
Reloads the glsl shaders. More... | |
Variables | |
const char * | shaderQualityLevelNames [SHQ_NUM][2] |
vec2_t | fogRange |
Shader (GLSL) backend functions.
Definition in file r_program.cpp.
#define FILTER_SIZE 3 |
width of convolution filter (for blur/bloom effects)
Definition at line 941 of file r_program.cpp.
Referenced by R_InitConvolveProgram(), R_InitPrograms(), and R_UseConvolveProgram().
#define SHADER_BUF_SIZE 16384 |
Definition at line 33 of file r_program.cpp.
Referenced by R_LoadShader(), and R_PreprocessShaderR().
enum shaderQualityLevel_t |
Enumerator | |
---|---|
SHQ_LOW | |
SHQ_MID | |
SHQ_HIGH | |
SHQ_NUM |
Definition at line 35 of file r_program.cpp.
Definition at line 211 of file r_program.cpp.
References GL_ATTRIBUTE, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_BindArray().
void R_DisableAttribute | ( | const char * | name | ) |
Definition at line 231 of file r_program.cpp.
References GL_ATTRIBUTE, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableAnimation(), and R_EnableModelLights().
void R_EnableAttribute | ( | const char * | name | ) |
Definition at line 221 of file r_program.cpp.
References GL_ATTRIBUTE, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableAnimation(), R_EnableModelLights(), and R_EnableWorldLights().
|
static |
Definition at line 993 of file r_program.cpp.
References R_ProgramParameter1i(), R_ProgramParameter2fv(), and R_ProgramParameter4fv().
Referenced by R_InitPrograms().
|
static |
Definition at line 983 of file r_program.cpp.
References R_ProgramParameter1i(), and R_ProgramParameter4fv().
Referenced by R_InitPrograms().
|
static |
Definition at line 943 of file r_program.cpp.
References FILTER_SIZE, i, lengthof, R_PascalTriangle(), R_ProgramParameter1fvs(), and R_ProgramParameter1i().
Referenced by R_InitPrograms().
|
static |
Definition at line 914 of file r_program.cpp.
References R_ProgramParameter1i(), R_ProgramParameter2fv(), and R_ProgramParameter4fv().
Referenced by R_InitPrograms().
|
static |
Prefixes the shader string with user settings and the video hardware manufacturer.
The shader needs to know the rendered width & height, the glsl version, and the hardware manufacturer.
[in] | type | The type of shader, currently either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER. |
[in] | name | The name of the shader. |
[in,out] | out | |
[in,out] | len | The amount of space left in the buffer pointed to by *out. |
Definition at line 309 of file r_program.cpp.
References Com_Error(), viddef_t::context, ERR_FATAL, GL_FRAGMENT_SHADER, GL_VERTEX_SHADER, GLHW_ATI, GLHW_GENERIC, GLHW_INTEL, GLHW_MESA, GLHW_NVIDIA, rconfig_t::hardwareType, viddefContext_t::height, int(), r_config, r_glsl_version, R_PreprocessShaderAddToShaderBuf(), va(), cvar_s::value, viddef, and viddefContext_t::width.
Referenced by R_LoadShader().
|
static |
Definition at line 810 of file r_program.cpp.
References material_s::bump, defaultMaterial, f, rstate_s::fog_enabled, rendererData_t::fogColor, fogRange, material_s::glowscale, GLVectorTransform(), material_s::hardness, cvar_s::integer, rendererData_t::modelAmbientColor, material_s::parallax, r_fog, r_locals, R_ProgramParameter1f(), R_ProgramParameter1i(), R_ProgramParameter2fv(), R_ProgramParameter3fv(), r_programs, r_state, refdef, material_s::specular, rendererData_t::sunDiffuseColor, rendererData_t::sunVector, and rlocals_s::world_matrix.
Referenced by R_InitPrograms().
void R_InitParticleProgram | ( | r_program_t * | prog | ) |
Definition at line 1012 of file r_program.cpp.
References R_ProgramParameter1i().
Referenced by CL_ParseMapParticle(), and CL_ParticleFunction().
Definition at line 1022 of file r_program.cpp.
References rstate_s::atmosphere_program, Com_Printf(), rstate_s::combine2_program, rstate_s::convolve_program, Cvar_Set(), DOUBLEQUOTE, FILTER_SIZE, rstate_s::geoscape_program, cvar_s::integer, rstate_s::model_program, cvar_s::modified, OBJZERO, rstate_s::programs, R_InitAtmosphereProgram(), R_InitCombine2Program(), R_InitConvolveProgram(), R_InitGeoscapeProgram(), R_InitModelProgram(), R_InitSimpleGlowProgram(), R_InitWarpProgram(), R_InitWorldProgram(), R_LoadProgram(), r_programs, r_state, R_UseConvolveProgram(), R_UseModelProgram(), R_UseWarpProgram(), R_UseWorldProgram(), shaderQualityLevelNames, rstate_s::shaders, rstate_s::simple_glow_program, rstate_s::warp_program, and rstate_s::world_program.
Referenced by R_Init(), R_ReinitOpenglContext(), and R_RestartPrograms_f().
|
static |
Definition at line 1005 of file r_program.cpp.
References R_ProgramParameter1f(), and R_ProgramParameter1i().
Referenced by R_InitPrograms().
|
static |
Definition at line 877 of file r_program.cpp.
References f, rstate_s::fog_enabled, rendererData_t::fogColor, fogRange, cvar_s::integer, r_fog, R_ProgramParameter1f(), R_ProgramParameter1i(), R_ProgramParameter2fv(), R_ProgramParameter3fv(), R_ProgramParameter4fv(), r_state, and refdef.
Referenced by R_InitPrograms().
|
static |
Definition at line 758 of file r_program.cpp.
References rendererData_t::ambientColor, material_s::bump, defaultMaterial, f, rstate_s::fog_enabled, rendererData_t::fogColor, fogRange, material_s::glowscale, material_s::hardness, cvar_s::integer, material_s::parallax, r_fog, R_ProgramParameter1f(), R_ProgramParameter1i(), R_ProgramParameter2fv(), R_ProgramParameter3fv(), r_programs, r_state, refdef, and material_s::specular.
Referenced by R_InitPrograms().
r_program_t* R_LoadProgram | ( | const char * | name, |
programInitFunc_t | init, | ||
programUseFunc_t | use | ||
) |
Definition at line 684 of file r_program.cpp.
References Com_Printf(), r_program_s::f, GL_FRAGMENT_SHADER, GL_LINK_STATUS, GL_VERTEX_SHADER, i, r_shader_s::id, r_program_s::id, r_program_s::init, cvar_s::integer, MAX_PROGRAMS, MAX_STRING_CHARS, r_program_s::name, rstate_s::programs, Q_streq, Q_strncpyz(), R_LoadShader(), r_programs, R_ShutdownProgram(), r_state, R_UseProgram(), r_program_s::use, r_program_s::v, and va().
Referenced by CL_ParseMapParticle(), CL_ParticleFunction(), and R_InitPrograms().
|
static |
Reads/Preprocesses/Compiles the specified shader into a program.
[in] | type | The type of shader, currently either GL_VERTEX_SHADER or GL_FRAGMENT_SHADER. |
[in] | name | The file name of the shader to load from ./base/shaders/ (e.g. "world_fs.glsl"). |
Definition at line 595 of file r_program.cpp.
References Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, FS_FreeFile(), FS_LoadFile(), GL_COMPILE_STATUS, i, r_shader_s::id, length, MAX_QPATH, MAX_SHADERS, MAX_STRING_CHARS, Mem_Free, Mem_PoolAllocTypeN, r_shader_s::name, OBJZERO, Q_strncpyz(), R_InitializeShader(), R_PreprocessShader(), r_state, SHADER_BUF_SIZE, rstate_s::shaders, r_shader_s::type, type, and vid_imagePool.
Referenced by R_LoadProgram().
Definition at line 933 of file r_program.cpp.
Referenced by R_InitConvolveProgram().
|
static |
Do our own preprocessing to the shader file, before the GLSL implementation calls it's preprocessor.
"#if/#endif" pairs, "#unroll", "#endunroll", "#include", "#replace" are handled by our preprocessor, not the GLSL implementation's preprocessor (except "#include" which may also be handled by the implementation's preprocessor). "#if" operates off of the value of a cvar interpreted as a bool. Note the GLSL implementation preprocessor handles "#ifdef" and "#ifndef", not "#if".
[in] | name | The file name of the shader (e.g. "world_fs.glsl"). |
[in] | in | The non-preprocessed shader string. |
[in,out] | out | The preprocessed shader string, nullptr if we don't want to write to it. |
[in,out] | remainingOutChars | The number of characters left in the out buffer. |
Definition at line 581 of file r_program.cpp.
References R_PreprocessShaderR().
Referenced by R_LoadShader().
|
static |
Prefixes shader string (out) with in.
[in] | name | The name of the shader. |
[in] | in | The string to prefix onto the shader string (out). |
[in,out] | out | The shader string (initially was the whole shader file). |
[in,out] | len | The amount of space left in the buffer pointed to by *out. |
Definition at line 289 of file r_program.cpp.
Referenced by R_InitializeShader().
|
static |
Do our own preprocessing to the shader file, before the GLSL implementation calls it's preprocessor.
"#if/#endif" pairs, "#unroll", "#endunroll", "#include", "#replace" are handled by our preprocessor, not the GLSL implementation's preprocessor (except "#include" which may also be handled by the implementation's preprocessor). "#if" operates off of the value of a cvar interpreted as a bool. Note the GLSL implementation preprocessor handles "#ifdef" and "#ifndef", not "#if".
[in] | name | The file name of the shader (e.g. "world_fs.glsl"). |
[in] | inPtr | The non-preprocessed shader string. |
[in,out] | out | The preprocessed shader string, nullptr if we don't want to write to it. |
[in,out] | remainingOutChars | The number of characters left in the out buffer. |
[in] | nested | If true, parsing a part of "#if" clause, so "#else" and "#endif" tokens are allowed |
[in] | inElse | If true, parsing an "#else" clause and shouldn't expect another "#else" |
Definition at line 392 of file r_program.cpp.
References Com_Error(), Com_Parse(), Com_Printf(), Com_sprintf(), Cvar_GetValue(), ERR_DROP, ERR_FATAL, f, FS_FreeFile(), FS_LoadFile(), MAX_QPATH, Mem_Free, Mem_PoolAllocTypeN, SHADER_BUF_SIZE, and vid_imagePool.
Referenced by R_PreprocessShader().
void R_ProgramParameter1f | ( | const char * | name, |
GLfloat | value | ||
) |
Definition at line 121 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableAnimation(), R_EnableFog(), R_EnableShell(), R_InitModelProgram(), R_InitSimpleGlowProgram(), R_InitWarpProgram(), R_InitWorldProgram(), R_SphereShadeGLSL(), R_StageGlow(), R_UpdateGlowBufferBinding(), R_UseMaterial(), R_UseModelProgram(), R_UseWarpProgram(), and R_UseWorldProgram().
Definition at line 131 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_InitConvolveProgram().
Definition at line 111 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableAnimation(), R_EnableBumpmap(), R_EnableRoughnessMap(), R_EnableSpecularMap(), R_InitAtmosphereProgram(), R_InitCombine2Program(), R_InitConvolveProgram(), R_InitGeoscapeProgram(), R_InitModelProgram(), R_InitParticleProgram(), R_InitSimpleGlowProgram(), R_InitWarpProgram(), and R_InitWorldProgram().
void R_ProgramParameter2fv | ( | const char * | name, |
GLfloat * | value | ||
) |
Definition at line 141 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableFog(), R_InitAtmosphereProgram(), R_InitGeoscapeProgram(), R_InitModelProgram(), R_InitWarpProgram(), R_InitWorldProgram(), R_UseModelProgram(), R_UseWarpProgram(), and R_UseWorldProgram().
Definition at line 151 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_UseConvolveProgram().
void R_ProgramParameter3fv | ( | const char * | name, |
GLfloat * | value | ||
) |
Definition at line 161 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableFog(), R_EnableModelLights(), R_InitModelProgram(), R_InitWarpProgram(), R_InitWorldProgram(), R_UseModelProgram(), R_UseWarpProgram(), and R_UseWorldProgram().
Definition at line 171 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableModelLights(), and R_EnableWorldLights().
void R_ProgramParameter4fv | ( | const char * | name, |
GLfloat * | value | ||
) |
Definition at line 181 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_InitAtmosphereProgram(), R_InitCombine2Program(), R_InitGeoscapeProgram(), R_InitWarpProgram(), and R_UseWarpProgram().
Definition at line 191 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
Referenced by R_EnableModelLights(), and R_EnableWorldLights().
void R_ProgramParameterMatrix4fv | ( | const char * | name, |
GLfloat * | value | ||
) |
Definition at line 201 of file r_program.cpp.
References GL_UNIFORM, r_progvar_s::location, R_ProgramVariable(), and v.
|
static |
Definition at line 67 of file r_program.cpp.
References rstate_s::active_program, Com_DPrintf(), Com_Printf(), DEBUG_RENDERER, GL_UNIFORM, i, r_program_s::id, r_progvar_s::location, MAX_PROGRAM_VARS, r_progvar_s::name, r_program_s::name, Q_streq, Q_strncpyz(), r_state, r_progvar_s::type, type, v, and r_program_s::vars.
Referenced by R_AttributePointer(), R_DisableAttribute(), R_EnableAttribute(), R_ProgramParameter1f(), R_ProgramParameter1fvs(), R_ProgramParameter1i(), R_ProgramParameter2fv(), R_ProgramParameter2fvs(), R_ProgramParameter3fv(), R_ProgramParameter3fvs(), R_ProgramParameter4fv(), R_ProgramParameter4fvs(), and R_ProgramParameterMatrix4fv().
Reloads the glsl shaders.
Definition at line 1058 of file r_program.cpp.
References Com_Printf(), Cvar_Get(), cvar_s::integer, R_InitFBObjects(), R_InitPrograms(), r_programs, and R_ShutdownPrograms().
Referenced by R_BeginFrame().
|
static |
Definition at line 247 of file r_program.cpp.
References r_program_s::f, r_shader_s::id, r_program_s::id, OBJZERO, R_CheckError, R_ShutdownShader(), and r_program_s::v.
Referenced by R_LoadProgram(), and R_ShutdownPrograms().
Definition at line 265 of file r_program.cpp.
References i, r_program_s::id, cvar_s::integer, MAX_PROGRAMS, rstate_s::programs, r_programs, R_ShutdownProgram(), and r_state.
Referenced by R_ReinitOpenglContext(), R_RestartPrograms_f(), and R_Shutdown().
|
static |
Definition at line 241 of file r_program.cpp.
References r_shader_s::id, and OBJZERO.
Referenced by R_ShutdownProgram().
|
static |
Use the filter convolution glsl program.
Definition at line 966 of file r_program.cpp.
References FILTER_SIZE, i, R_ProgramParameter2fvs(), and r_program_s::userdata.
Referenced by R_InitPrograms().
|
static |
Definition at line 854 of file r_program.cpp.
References f, rstate_s::fog_enabled, rendererData_t::fogColor, fogRange, GLVectorTransform(), cvar_s::integer, rendererData_t::modelAmbientColor, r_fog, r_locals, R_ProgramParameter1f(), R_ProgramParameter2fv(), R_ProgramParameter3fv(), r_state, refdef, rendererData_t::sunDiffuseColor, rendererData_t::sunVector, and rlocals_s::world_matrix.
Referenced by R_InitPrograms().
void R_UseParticleProgram | ( | r_program_t * | prog | ) |
Definition at line 1017 of file r_program.cpp.
Referenced by CL_ParseMapParticle(), and CL_ParticleFunction().
void R_UseProgram | ( | r_program_t * | prog | ) |
Definition at line 43 of file r_program.cpp.
References rstate_s::active_program, rendererData_t::FFPToShaderCount, r_program_s::id, r_state, refdef, rendererData_t::shaderToFFPCount, rendererData_t::shaderToShaderCount, and r_program_s::use.
Referenced by R_BlurStack(), R_DrawBloom(), R_DrawParticles(), R_EnableBlur(), R_EnableGlowMap(), R_EnableLighting(), R_EnableWarp(), and R_LoadProgram().
|
static |
Definition at line 897 of file r_program.cpp.
References f, rstate_s::fog_enabled, rendererData_t::fogColor, fogRange, cvar_s::integer, r_fog, R_ProgramParameter1f(), R_ProgramParameter2fv(), R_ProgramParameter3fv(), R_ProgramParameter4fv(), r_state, refdef, and rendererData_t::time.
Referenced by R_InitPrograms().
|
static |
Definition at line 793 of file r_program.cpp.
References rendererData_t::ambientColor, f, rstate_s::fog_enabled, rendererData_t::fogColor, fogRange, cvar_s::integer, r_fog, R_ProgramParameter1f(), R_ProgramParameter2fv(), R_ProgramParameter3fv(), r_programs, r_state, and refdef.
Referenced by R_InitPrograms().
vec2_t fogRange |
Definition at line 584 of file r_state.cpp.
Referenced by R_EnableFog(), R_InitModelProgram(), R_InitWarpProgram(), R_InitWorldProgram(), R_UseModelProgram(), R_UseWarpProgram(), and R_UseWorldProgram().
const char* shaderQualityLevelNames[SHQ_NUM][2] |
Definition at line 37 of file r_program.cpp.
Referenced by R_InitPrograms().