OSDN Git Service

gallivm: fix improper clamping of vertex index when fetching gs inputs
authorRoland Scheidegger <sroland@vmware.com>
Thu, 8 Nov 2018 01:52:47 +0000 (02:52 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 8 Nov 2018 23:53:03 +0000 (00:53 +0100)
commita3c898dc97ec5f0e0b93b2ee180bdf8ca3bab14c
tree498a49052e2de6e82ac2590dc12e14070e591abe
parenta5c39ed974402c6a40d51c6189547d1f29581fbe
gallivm: fix improper clamping of vertex index when fetching gs inputs

Because we only have one file_max for the (2d) gs input file, the value
actually represents the max of attrib and vertex index (although I'm
not entirely sure if we really want the max, since the max valid value
of the vertex dimension can be easily deduced from the input primitive).

Thus in cases where the number of inputs is higher than the number of
vertices per prim, we did not properly clamp the vertex index, which
would result in out-of-bound fetches, potentially causing segfaults
(the segfaults seemed actually difficult to trigger, but valgrind
certainly wasn't happy). This might have happened even if the shader
did not actually try to fetch bogus vertices, if the fetching happened
in non-active conditional clauses.

To fix simply use the correct max vertex index value (derived from
the input prim type) instead when clamping for this case.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c