[Mesa-dev] [PATCH v4 6/6] i965: gl_BaseVertex must be zero for non-indexed draw calls
Ian Romanick
idr at freedesktop.org
Tue Apr 17 17:31:05 UTC 2018
On 04/10/2018 09:26 AM, Jason Ekstrand wrote:
> On Tue, Apr 10, 2018 at 1:28 AM, Antia Puentes <apuentes at igalia.com
> <mailto:apuentes at igalia.com>> wrote:
>
> On 07/04/18 08:21, Jason Ekstrand wrote:
>
>> Oh, boy, this is tricky... First of all, it's a bit of a bummer
>> that we can't just load the indirect buffer again for this. Not
>> too much to do about it, I guess.
>>
>> Second, there be very scary dragons here. It turns out that, at
>> least on Haswell (and possibly other platforms), reading from
>> state registers while rendering is in-flight can lead to GPU
>> hangs. Yes, I said "reading". We found this out the hard way
>> while working on Vulkan indirect clear colors. The better thing
>> to do here would be to use GPRs when available (I think they're
>> safe but I'm not sure) or to do a MI_COPY_MEM_MEM which, of
>> course, is only available on gen8+. On Ivy Bridge (and haswell if
>> we're going to do a store_register_mem from a state register), we
>> need to do a mi_flush *before* the store as well.
>>
>
> I see that this is complicated, I have thought in a different way to
> implement this.
> Instead of moving gl_BaseVertex to a VE2 and reading its value from
> state registers:
>
> - VE1 remains as: <firstvertex, BaseInstance, VertexID, InstanceID>
> -> Patches 1-5 are still valid (I think) and we can still calculate
> the VertexID as FirstVertex + VertexIDZeroBased.
>
> - VE2 contains: <Draw ID, IsIndexedDraw, 0, 0>,
> ->when asked for glBaseVertex (nir_instrinsic_load_base_vertex), we
> would return the value stored in FirstVertex is the draw call is
> indexed, zero if it is not.
>
> How does it sound?.
>
> That sounds fine to me. It's one extra instruciton in the shader (it
Unless there are objections, I'm going to push patches 1 through 5 (with
the extra comment Jason suggested in patch 4) in the morning.
> could be an AND if IsIndexedDraw is 0/~0) and lets us avoid trying to do
> command-stream copying of data. If I understand correcctly, Vulkan will
> never hit this path because it will always use FIRST_VERETX and not
> BASE_VERTEX. Is that correct?
More information about the mesa-dev
mailing list