summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/swr/swr_shader.cpp
diff options
context:
space:
mode:
authorKrzysztof Raszkowski <krzysztof.raszkowski@intel.com>2019-11-08 14:52:16 +0000
committerJan Zielinski <jan.zielinski@intel.com>2019-11-08 14:52:16 +0000
commite5ed9a1b91b6c047a229296908ef461dabac049a (patch)
tree903de40508da91f4c1b0ad2b702378ee96281166 /src/gallium/drivers/swr/swr_shader.cpp
parent911a8261419f48dcd756f78832fa5a5f4c5b8d93 (diff)
gallium/swr: Fix GS invocation issues
- Fixed proper setting gl_InvocationID. - Fixed GS vertices output memory overflow. Reviewed-by: Jan Zielinski <jan.zielinski@intel.com>
Diffstat (limited to 'src/gallium/drivers/swr/swr_shader.cpp')
-rw-r--r--src/gallium/drivers/swr/swr_shader.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gallium/drivers/swr/swr_shader.cpp b/src/gallium/drivers/swr/swr_shader.cpp
index e5e5411fb10..20e855b988d 100644
--- a/src/gallium/drivers/swr/swr_shader.cpp
+++ b/src/gallium/drivers/swr/swr_shader.cpp
@@ -621,7 +621,12 @@ BuilderSWR::CompileGS(struct swr_context *ctx, swr_jit_gs_key &key)
pGS->numInputAttribs = (VERTEX_ATTRIB_START_SLOT - VERTEX_POSITION_SLOT) + info->num_inputs;
pGS->outputTopology =
swr_convert_prim_topology(info->properties[TGSI_PROPERTY_GS_OUTPUT_PRIM]);
- pGS->maxNumVerts = info->properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES];
+
+ /* It's +1 because emit_vertex in swr is always called exactly one time more
+ * than max_vertices passed in Geometry Shader. We need to allocate more memory
+ * to avoid crash/memory overwritten.
+ */
+ pGS->maxNumVerts = info->properties[TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES] + 1;
pGS->instanceCount = info->properties[TGSI_PROPERTY_GS_INVOCATIONS];
// If point primitive then assume to use multiple streams
@@ -699,7 +704,7 @@ BuilderSWR::CompileGS(struct swr_context *ctx, swr_jit_gs_key &key)
struct lp_bld_tgsi_system_values system_values;
memset(&system_values, 0, sizeof(system_values));
system_values.prim_id = wrap(LOAD(pGsCtx, {0, SWR_GS_CONTEXT_PrimitiveID}));
- system_values.instance_id = wrap(LOAD(pGsCtx, {0, SWR_GS_CONTEXT_InstanceID}));
+ system_values.invocation_id = wrap(LOAD(pGsCtx, {0, SWR_GS_CONTEXT_InstanceID}));
std::vector<Constant*> mapConstants;
Value *vtxAttribMap = ALLOCA(ArrayType::get(mInt32Ty, PIPE_MAX_SHADER_INPUTS));