[Mesa-dev] [PATCH 6/9] mesa: Add a new GetTransformFeedbackVertexCount() driver hook.

Kenneth Graunke kenneth at whitecape.org
Sat Oct 26 02:16:26 CEST 2013


On 10/25/2013 03:26 PM, Marek Olšák wrote:
[snip]
>> At least for Ivybridge, I think I want this software path 100% of the
>> time.  We may want to remove the stall on Haswell as a later optimization.
> 
> I'd like to have a dedicated flag for this fallback like we have
> Const.PrimitiveRestartInSoftware, in case we need to implement the
> query for something else.

Sure, that seems reasonable.  I'll send out a proposed patch and CC you.

>> It sounds like for Gallium, you already have a decent GPU-only solution.
>>  I tried to follow that code to understand how it works, and got lost
>> after jumping through around 5 files...which is probably just my poor
>> understanding of the Gallium architecture.
> 
> Gallium doesn't do anything, the interface is pretty much the same as
> the vbo one.
> 
> On the hardware side, there are 4 counters containing the number of
> bytes written to each TFB buffer. If TFB is started, the counters are
> set to 0. Everytime TFB is ended or paused, the counters are stored
> for each buffer in memory. When resuming TFB, the counters are simply
> loaded from memory.
> 
> When we have to do DrawTransformFeedback, we copy the value of the
> counter from memory to a special draw register. Since the value is in
> bytes, we also have to set the TFB buffer stride to another special
> draw register. That's all. The hardware then calculates count =
> bytes/stride before drawing.

Oh, interesting!  I would have expected it to count in vertices, but
bytes - that's pretty clever.  If the units were the same on i965, I
would've definitely done it that way...it makes a lot of sense.

[snip]
>> I hadn't thought about non-VBO vertex uploads.  What does Gallium do in
>> that case?  Has it just been broken this whole time?
> 
> Yes, it has, I completely forgot about it. :(
> 
>>
>> I guess I figured drivers would either implement this hook, or do the
>> tfb_vertcount approach, but not both.  Maybe that's a bad assumption.
> 
> For vertex uploads and vertex fetch fallbacks (where we translate and
> align vertex buffers to what a gallium driver supports -
> util/u_vbuf.c), we can use a query like the one you want to add.
> However, gallium drivers should use the tfb_vertcount approach (AKA
> pipe_draw_info::count_from_stream_output) whenever they see it's not
> NULL. Since most Gallium hardware drivers will never see non-VBO
> vertex data or an unsupported vertex format, it's the only approach
> they have to implement.
> 
> Marek


More information about the mesa-dev mailing list