tweaked the draw surface sort key for better performance

it minimizes depth fade <-> generic pipeline transitions
This commit is contained in:
myT 2020-10-08 04:08:38 +02:00
parent 78cf275a62
commit 633c5bd13c
2 changed files with 9 additions and 8 deletions

View file

@ -797,15 +797,16 @@ compared quickly during the qsorting process
the bits are allocated as follows:
18-31 : sorted shader index (14 bits)
16-17 : cull type (2 bits)
15-15 : polygon offset (1 bit)
31-31 : unused (1 bit)
30-30 : depth fade (1 bit)
29-29 : polygon offset (1 bit)
15-28 : sorted shader index (14 bits)
5-14 : entity index (10 bits)
0- 4 : fog index (5 bits)
*/
#define QSORT_SHADERNUM_SHIFT 18
#define QSORT_CULLTYPE_SHIFT 16
#define QSORT_POLYOFF_SHIFT 15
#define QSORT_DEPTHFADE_SHIFT 30
#define QSORT_POLYOFF_SHIFT 29
#define QSORT_SHADERNUM_SHIFT 15
#define QSORT_ENTITYNUM_SHIFT 5
#define QSORT_FOGNUM_SHIFT 0

View file

@ -1073,7 +1073,7 @@ void R_AddDrawSurf( const surfaceType_t* surface, const shader_t* shader, int fo
// compared quickly during the qsorting process
tr.refdef.drawSurfs[index].sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT)
| tr.shiftedEntityNum | (fogIndex << QSORT_FOGNUM_SHIFT)
| (shader->cullType << QSORT_CULLTYPE_SHIFT)
| ((shader->dfType != DFT_NONE) << QSORT_DEPTHFADE_SHIFT)
| (shader->polygonOffset << QSORT_POLYOFF_SHIFT);
tr.refdef.drawSurfs[index].surface = surface;
tr.refdef.drawSurfs[index].model = tr.currentModel != NULL ? tr.currentModel->index : 0;
@ -1089,7 +1089,7 @@ void R_AddLitSurf( const surfaceType_t* surface, const shader_t* shader, int fog
litsurf->sort = (shader->sortedIndex << QSORT_SHADERNUM_SHIFT)
| tr.shiftedEntityNum | (fogIndex << QSORT_FOGNUM_SHIFT)
| (shader->cullType << QSORT_CULLTYPE_SHIFT)
| ((shader->dfType != DFT_NONE) << QSORT_DEPTHFADE_SHIFT)
| (shader->polygonOffset << QSORT_POLYOFF_SHIFT);
litsurf->surface = surface;