/// hash lookup data
struct r_glsl_permutation_s *hashnext;
unsigned int mode;
- dpuint64 permutation;
+ uint64_t permutation;
/// indicates if we have tried compiling this permutation already
qboolean compiled;
shaderstaticparmstrings_list[shaderstaticparms_count++] = "#define " n "\n"; \
else \
shaderstaticparmstrings_list[shaderstaticparms_count++] = "\n"
-static void R_CompileShader_AddStaticParms(unsigned int mode, dpuint64 permutation)
+static void R_CompileShader_AddStaticParms(unsigned int mode, uint64_t permutation)
{
shaderstaticparms_count = 0;
/// storage for permutations linked in the hash table
memexpandablearray_t r_glsl_permutationarray;
-static r_glsl_permutation_t *R_GLSL_FindPermutation(unsigned int mode, dpuint64 permutation)
+static r_glsl_permutation_t *R_GLSL_FindPermutation(unsigned int mode, uint64_t permutation)
{
//unsigned int hashdepth = 0;
unsigned int hashindex = (permutation * 0x1021) & (SHADERPERMUTATION_HASHSIZE - 1);
return Mem_strdup(r_main_mempool, modeinfo->builtinstring);
}
-static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode, dpuint64 permutation)
+static void R_GLSL_CompilePermutation(r_glsl_permutation_t *p, unsigned int mode, uint64_t permutation)
{
int i;
int ubibind;
Mem_Free(sourcestring);
}
-static void R_SetupShader_SetPermutationGLSL(unsigned int mode, dpuint64 permutation)
+static void R_SetupShader_SetPermutationGLSL(unsigned int mode, uint64_t permutation)
{
r_glsl_permutation_t *perm = R_GLSL_FindPermutation(mode, permutation);
if (r_glsl_permutation != perm)
{
if (!r_glsl_permutation->compiled)
{
- Con_DPrintf("Compiling shader mode %u permutation %llx\n", mode, permutation);
+ Con_DPrintf("Compiling shader mode %u permutation %"PRIx64"\n", mode, permutation);
R_GLSL_CompilePermutation(perm, mode, permutation);
}
if (!r_glsl_permutation->program)
for (i = 0;i < SHADERPERMUTATION_COUNT;i++)
{
// reduce i more quickly whenever it would not remove any bits
- dpuint64 j = 1ll<<(SHADERPERMUTATION_COUNT-1-i);
+ uint64_t j = 1ll<<(SHADERPERMUTATION_COUNT-1-i);
if (!(permutation & j))
continue;
permutation -= j;
void R_SetupShader_Generic(rtexture_t *t, qboolean usegamma, qboolean notrippy, qboolean suppresstexalpha)
{
- dpuint64 permutation = 0;
+ uint64_t permutation = 0;
if (r_trippy.integer && !notrippy)
permutation |= SHADERPERMUTATION_TRIPPY;
permutation |= SHADERPERMUTATION_VIEWTINT;
void R_SetupShader_DepthOrShadow(qboolean notrippy, qboolean depthrgb, qboolean skeletal)
{
- dpuint64 permutation = 0;
+ uint64_t permutation = 0;
if (r_trippy.integer && !notrippy)
permutation |= SHADERPERMUTATION_TRIPPY;
if (depthrgb)
// combination of texture, entity, light source, and fogging, only use the
// minimum features necessary to avoid wasting rendering time in the
// fragment shader on features that are not being used
- dpuint64 permutation = 0;
+ uint64_t permutation = 0;
unsigned int mode = 0;
int blendfuncflags;
texture_t *t = rsurface.texture;
}
if(!(blendfuncflags & BLENDFUNC_ALLOWS_ANYFOG))
permutation &= ~(SHADERPERMUTATION_FOGHEIGHTTEXTURE | SHADERPERMUTATION_FOGOUTSIDE | SHADERPERMUTATION_FOGINSIDE);
- if(blendfuncflags & BLENDFUNC_ALLOWS_FOG_HACKALPHA)
+ if(blendfuncflags & BLENDFUNC_ALLOWS_FOG_HACKALPHA && !notrippy)
permutation |= SHADERPERMUTATION_FOGALPHAHACK;
switch(vid.renderpath)
{
if (r_glsl_permutation->loc_DeferredMod_Specular >= 0) qglUniform3f(r_glsl_permutation->loc_DeferredMod_Specular, t->render_rtlight_specular[0], t->render_rtlight_specular[1], t->render_rtlight_specular[2]);
}
// additive passes are only darkened by fog, not tinted
- if (r_glsl_permutation->loc_FogColor >= 0)
+ if (r_glsl_permutation->loc_FogColor >= 0 && !notrippy)
{
if(blendfuncflags & BLENDFUNC_ALLOWS_FOG_HACK0)
qglUniform3f(r_glsl_permutation->loc_FogColor, 0, 0, 0);
// combination of texture, entity, light source, and fogging, only use the
// minimum features necessary to avoid wasting rendering time in the
// fragment shader on features that are not being used
- dpuint64 permutation = 0;
+ uint64_t permutation = 0;
unsigned int mode = 0;
const float *lightcolorbase = rtlight->currentcolor;
float ambientscale = rtlight->ambientscale;
static rtexture_t *R_LoadCubemap(const char *basename)
{
- int i, j, cubemapsize;
+ int i, j, cubemapsize, forcefilter;
unsigned char *cubemappixels, *image_buffer;
rtexture_t *cubemaptexture;
char name[256];
+
+ // HACK: if the cubemap name starts with a !, the cubemap is nearest-filtered
+ forcefilter = TEXF_FORCELINEAR;
+ if (basename && basename[0] == '!')
+ {
+ basename++;
+ forcefilter = TEXF_FORCENEAREST;
+ }
// must start 0 so the first loadimagepixels has no requested width/height
cubemapsize = 0;
cubemappixels = NULL;
if (developer_loading.integer)
Con_Printf("loading cubemap \"%s\"\n", basename);
- cubemaptexture = R_LoadTextureCubeMap(r_main_texturepool, basename, cubemapsize, cubemappixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, (gl_texturecompression_lightcubemaps.integer && gl_texturecompression.integer ? TEXF_COMPRESS : 0) | TEXF_FORCELINEAR | TEXF_CLAMP, -1, NULL);
+ cubemaptexture = R_LoadTextureCubeMap(r_main_texturepool, basename, cubemapsize, cubemappixels, vid.sRGB3D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, (gl_texturecompression_lightcubemaps.integer && gl_texturecompression.integer ? TEXF_COMPRESS : 0) | forcefilter | TEXF_CLAMP, -1, NULL);
Mem_Free(cubemappixels);
}
else
r_main_mempool = Mem_AllocPool("Renderer", 0, NULL);
R_InitShaderModeInfo();
- Cmd_AddCommand(&cmd_client, "r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
- Cmd_AddCommand(&cmd_client, "r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
+ Cmd_AddCommand(CMD_CLIENT, "r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
+ Cmd_AddCommand(CMD_CLIENT, "r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
// FIXME: the client should set up r_refdef.fog stuff including the fogmasktable
if (gamemode == GAME_NEHAHRA)
{
{
samples = ent->last_trace_visibility == 0 ? r_cullentities_trace_tempentitysamples.integer : r_cullentities_trace_samples.integer;
if (R_CanSeeBox(samples, r_cullentities_trace_eyejitter.value, r_cullentities_trace_enlarge.value, r_cullentities_trace_expand.value, r_cullentities_trace_pad.value, r_refdef.view.origin, ent->mins, ent->maxs))
- ent->last_trace_visibility = realtime;
- if (ent->last_trace_visibility < realtime - r_cullentities_trace_delay.value)
+ ent->last_trace_visibility = host.realtime;
+ if (ent->last_trace_visibility < host.realtime - r_cullentities_trace_delay.value)
r_refdef.viewcache.entityvisible[i] = 0;
}
}
// free resources for rendertargets that have not been used for a while
// (note: this check is run after the frame render, so any targets used
// this frame will not be affected even at low framerates)
- if (r && (realtime - r->lastusetime > 0.2 || force))
+ if (r && (host.realtime - r->lastusetime > 0.2 || force))
{
if (r->fbo)
R_Mesh_DestroyFramebufferObject(r->fbo);
for (i = 0; i < end; i++)
{
r = (r_rendertarget_t *)Mem_ExpandableArray_RecordAtIndex(&r_fb.rendertargets, i);
- if (r && r->lastusetime != realtime && r->texturewidth == texturewidth && r->textureheight == textureheight && r->depthtextype == depthtextype && r->colortextype[0] == colortextype0 && r->colortextype[1] == colortextype1 && r->colortextype[2] == colortextype2 && r->colortextype[3] == colortextype3)
+ if (r && r->lastusetime != host.realtime && r->texturewidth == texturewidth && r->textureheight == textureheight && r->depthtextype == depthtextype && r->colortextype[0] == colortextype0 && r->colortextype[1] == colortextype1 && r->colortextype[2] == colortextype2 && r->colortextype[3] == colortextype3)
break;
}
if (i == end)
}
r_refdef.stats[r_stat_rendertargets_used]++;
r_refdef.stats[r_stat_rendertargets_pixels] += r->texturewidth * r->textureheight;
- r->lastusetime = realtime;
+ r->lastusetime = host.realtime;
R_CalcTexCoordsForView(0, 0, r->texturewidth, r->textureheight, r->texturewidth, r->textureheight, r->texcoord2f);
return r;
}
static void R_BlendView(int viewfbo, rtexture_t *viewdepthtexture, rtexture_t *viewcolortexture, int viewx, int viewy, int viewwidth, int viewheight)
{
- dpuint64 permutation;
+ uint64_t permutation;
float uservecs[4][4];
rtexture_t *viewtexture;
rtexture_t *bloomtexture;
static void R_DrawTextureSurfaceList_Sky(int texturenumsurfaces, const msurface_t **texturesurfacelist)
{
int j;
+ const float *v;
+ float p[3], mins[3], maxs[3];
+ int scissor[4];
// transparent sky would be ridiculous
if (rsurface.texture->currentmaterialflags & MATERIALFLAGMASK_DEPTHSORTED)
return;
if (r_sky_scissor.integer)
{
RSurf_PrepareVerticesForBatch(BATCHNEED_ARRAY_VERTEX | BATCHNEED_NOGAPS, texturenumsurfaces, texturesurfacelist);
- const float *v;
- float p[3];
- float mins[3], maxs[3];
- int scissor[4];
for (j = 0, v = rsurface.batchvertex3f + 3 * rsurface.batchfirstvertex; j < rsurface.batchnumvertices; j++, v += 3)
{
Matrix4x4_Transform(&rsurface.matrix, v, p);