[iortcw] 237/497: All: Rend2: Bit of multidraw optimization
Simon McVittie
smcv at debian.org
Fri Sep 8 10:36:58 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to annotated tag 1.42d
in repository iortcw.
commit 788c5365e195522e4894b3b01dda835e1a273a71
Author: M4N4T4RMS at gmail.com <M4N4T4RMS at gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date: Thu Oct 16 15:06:22 2014 +0000
All: Rend2: Bit of multidraw optimization
---
MP/code/rend2/tr_local.h | 3 +--
MP/code/rend2/tr_shade.c | 2 +-
MP/code/rend2/tr_surface.c | 7 +------
SP/code/rend2/tr_local.h | 3 +--
SP/code/rend2/tr_shade.c | 2 +-
SP/code/rend2/tr_surface.c | 7 +------
6 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index f2902b8..f5cf755 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -2240,7 +2240,7 @@ typedef struct stageVars
vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES];
} stageVars_t;
-#define MAX_MULTIDRAW_PRIMITIVES 16384
+#define MAX_MULTIDRAW_PRIMITIVES 256
typedef struct shaderCommands_s
{
@@ -2281,7 +2281,6 @@ typedef struct shaderCommands_s
int multiDrawPrimitives;
GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t *multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
- glIndex_t *multiDrawLastIndex[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t multiDrawMinIndex[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t multiDrawMaxIndex[MAX_MULTIDRAW_PRIMITIVES];
diff --git a/MP/code/rend2/tr_shade.c b/MP/code/rend2/tr_shade.c
index 35b6db0..20f8cac 100644
--- a/MP/code/rend2/tr_shade.c
+++ b/MP/code/rend2/tr_shade.c
@@ -60,7 +60,7 @@ void R_DrawElementsVao( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex
static void R_DrawMultiElementsVao( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex,
GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex)
{
- if (glRefConfig.multiDrawArrays)
+ if (glRefConfig.multiDrawArrays && multiDrawPrimitives > 1)
{
qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives);
}
diff --git a/MP/code/rend2/tr_surface.c b/MP/code/rend2/tr_surface.c
index a166f89..fab37a4 100644
--- a/MP/code/rend2/tr_surface.c
+++ b/MP/code/rend2/tr_surface.c
@@ -469,7 +469,7 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
for (; i < tess.multiDrawPrimitives; i++)
{
- if (tess.multiDrawLastIndex[i] == firstIndexOffset)
+ if (firstIndexOffset == tess.multiDrawFirstIndex[i] + tess.multiDrawNumIndexes[i])
{
mergeBack = i;
@@ -490,7 +490,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
if (mergeBack != -1 && mergeForward == -1)
{
tess.multiDrawNumIndexes[mergeBack] += numIndexes;
- tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack];
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex);
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex);
backEnd.pc.c_multidrawsMerged++;
@@ -499,7 +498,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[mergeForward] += numIndexes;
tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset;
- tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward];
tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex);
tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex);
backEnd.pc.c_multidrawsMerged++;
@@ -507,7 +505,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
else if (mergeBack != -1 && mergeForward != -1)
{
tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward];
- tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward];
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex));
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex));
tess.multiDrawPrimitives--;
@@ -516,7 +513,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives];
tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives];
- tess.multiDrawLastIndex[mergeForward] = tess.multiDrawLastIndex[tess.multiDrawPrimitives];
tess.multiDrawMinIndex[mergeForward] = tess.multiDrawMinIndex[tess.multiDrawPrimitives];
tess.multiDrawMaxIndex[mergeForward] = tess.multiDrawMaxIndex[tess.multiDrawPrimitives];
}
@@ -526,7 +522,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes;
tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset;
- tess.multiDrawLastIndex[tess.multiDrawPrimitives] = lastIndexOffset;
tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex;
tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex;
tess.multiDrawPrimitives++;
diff --git a/SP/code/rend2/tr_local.h b/SP/code/rend2/tr_local.h
index 77fc028..bb7e721 100644
--- a/SP/code/rend2/tr_local.h
+++ b/SP/code/rend2/tr_local.h
@@ -2267,7 +2267,7 @@ typedef struct stageVars
vec2_t texcoords[NUM_TEXTURE_BUNDLES][SHADER_MAX_VERTEXES];
} stageVars_t;
-#define MAX_MULTIDRAW_PRIMITIVES 16384
+#define MAX_MULTIDRAW_PRIMITIVES 256
typedef struct shaderCommands_s
{
@@ -2308,7 +2308,6 @@ typedef struct shaderCommands_s
int multiDrawPrimitives;
GLsizei multiDrawNumIndexes[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t *multiDrawFirstIndex[MAX_MULTIDRAW_PRIMITIVES];
- glIndex_t *multiDrawLastIndex[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t multiDrawMinIndex[MAX_MULTIDRAW_PRIMITIVES];
glIndex_t multiDrawMaxIndex[MAX_MULTIDRAW_PRIMITIVES];
diff --git a/SP/code/rend2/tr_shade.c b/SP/code/rend2/tr_shade.c
index 15fd2a7..3dcad5b 100644
--- a/SP/code/rend2/tr_shade.c
+++ b/SP/code/rend2/tr_shade.c
@@ -53,7 +53,7 @@ void R_DrawElementsVao( int numIndexes, glIndex_t firstIndex, glIndex_t minIndex
static void R_DrawMultiElementsVao( int multiDrawPrimitives, glIndex_t *multiDrawMinIndex, glIndex_t *multiDrawMaxIndex,
GLsizei *multiDrawNumIndexes, glIndex_t **multiDrawFirstIndex)
{
- if (glRefConfig.multiDrawArrays)
+ if (glRefConfig.multiDrawArrays && multiDrawPrimitives > 1)
{
qglMultiDrawElementsEXT(GL_TRIANGLES, multiDrawNumIndexes, GL_INDEX_TYPE, (const GLvoid **)multiDrawFirstIndex, multiDrawPrimitives);
}
diff --git a/SP/code/rend2/tr_surface.c b/SP/code/rend2/tr_surface.c
index 12ceecc..429fb89 100644
--- a/SP/code/rend2/tr_surface.c
+++ b/SP/code/rend2/tr_surface.c
@@ -469,7 +469,7 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
for (; i < tess.multiDrawPrimitives; i++)
{
- if (tess.multiDrawLastIndex[i] == firstIndexOffset)
+ if (firstIndexOffset == tess.multiDrawFirstIndex[i] + tess.multiDrawNumIndexes[i])
{
mergeBack = i;
@@ -490,7 +490,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
if (mergeBack != -1 && mergeForward == -1)
{
tess.multiDrawNumIndexes[mergeBack] += numIndexes;
- tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeBack] + tess.multiDrawNumIndexes[mergeBack];
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], minIndex);
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], maxIndex);
backEnd.pc.c_multidrawsMerged++;
@@ -499,7 +498,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[mergeForward] += numIndexes;
tess.multiDrawFirstIndex[mergeForward] = firstIndexOffset;
- tess.multiDrawLastIndex[mergeForward] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward];
tess.multiDrawMinIndex[mergeForward] = MIN(tess.multiDrawMinIndex[mergeForward], minIndex);
tess.multiDrawMaxIndex[mergeForward] = MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex);
backEnd.pc.c_multidrawsMerged++;
@@ -507,7 +505,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
else if (mergeBack != -1 && mergeForward != -1)
{
tess.multiDrawNumIndexes[mergeBack] += numIndexes + tess.multiDrawNumIndexes[mergeForward];
- tess.multiDrawLastIndex[mergeBack] = tess.multiDrawFirstIndex[mergeForward] + tess.multiDrawNumIndexes[mergeForward];
tess.multiDrawMinIndex[mergeBack] = MIN(tess.multiDrawMinIndex[mergeBack], MIN(tess.multiDrawMinIndex[mergeForward], minIndex));
tess.multiDrawMaxIndex[mergeBack] = MAX(tess.multiDrawMaxIndex[mergeBack], MAX(tess.multiDrawMaxIndex[mergeForward], maxIndex));
tess.multiDrawPrimitives--;
@@ -516,7 +513,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[mergeForward] = tess.multiDrawNumIndexes[tess.multiDrawPrimitives];
tess.multiDrawFirstIndex[mergeForward] = tess.multiDrawFirstIndex[tess.multiDrawPrimitives];
- tess.multiDrawLastIndex[mergeForward] = tess.multiDrawLastIndex[tess.multiDrawPrimitives];
tess.multiDrawMinIndex[mergeForward] = tess.multiDrawMinIndex[tess.multiDrawPrimitives];
tess.multiDrawMaxIndex[mergeForward] = tess.multiDrawMaxIndex[tess.multiDrawPrimitives];
}
@@ -526,7 +522,6 @@ static qboolean RB_SurfaceVao(vao_t *vao, int numVerts, int numIndexes, int firs
{
tess.multiDrawNumIndexes[tess.multiDrawPrimitives] = numIndexes;
tess.multiDrawFirstIndex[tess.multiDrawPrimitives] = firstIndexOffset;
- tess.multiDrawLastIndex[tess.multiDrawPrimitives] = lastIndexOffset;
tess.multiDrawMinIndex[tess.multiDrawPrimitives] = minIndex;
tess.multiDrawMaxIndex[tess.multiDrawPrimitives] = maxIndex;
tess.multiDrawPrimitives++;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list