summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2014-06-11 11:38:19 +1000
committerDave Airlie <airlied@redhat.com>2014-06-11 12:19:37 +1000
commita4670de0a00fad11a2b2a5c458a89302b552df64 (patch)
tree10f4131316954ee12e4b9ecb3f1d9a9da42d9110 /src
parent10e8d557993140cd5df85e38738c26bfce3a4761 (diff)
downloadexternal_mesa3d-a4670de0a00fad11a2b2a5c458a89302b552df64.zip
external_mesa3d-a4670de0a00fad11a2b2a5c458a89302b552df64.tar.gz
external_mesa3d-a4670de0a00fad11a2b2a5c458a89302b552df64.tar.bz2
tgsi/gs: bound max output vertices in shader
This limits the number of emitted vertices to the shaders max output vertices, and avoids us writing things into memory that isn't big enough for it. Reviewed-by: Zack Rusin <zackr@vmware.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.c8
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_exec.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c
index 9be1d13..19412af 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c
@@ -789,6 +789,11 @@ tgsi_exec_machine_bind_shader(
break;
case TGSI_TOKEN_TYPE_PROPERTY:
+ if (mach->Processor == TGSI_PROCESSOR_GEOMETRY) {
+ if (parse.FullToken.FullProperty.Property.PropertyName == TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES) {
+ mach->MaxOutputVertices = parse.FullToken.FullProperty.u[0].Data;
+ }
+ }
break;
default:
@@ -1621,6 +1626,9 @@ emit_vertex(struct tgsi_exec_machine *mach)
if ((mach->ExecMask & (1 << i)))
*/
if (mach->ExecMask) {
+ if (mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]] >= mach->MaxOutputVertices)
+ return;
+
mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += mach->NumOutputs;
mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]]++;
}
diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h
index bb56934..a5369ae 100644
--- a/src/gallium/auxiliary/tgsi/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h
@@ -297,6 +297,7 @@ struct tgsi_exec_machine
unsigned *Primitives;
unsigned NumOutputs;
unsigned MaxGeometryShaderOutputs;
+ unsigned MaxOutputVertices;
/* FRAGMENT processor only. */
const struct tgsi_interp_coef *InterpCoefs;