On 14 December 2011 15:00, Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5">On Wed, Dec 14, 2011 at 11:25 PM, Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>> wrote:<br>
> On 14 December 2011 13:42, Marek Olšák <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br>
>><br>
>> I think RASTERIZER_DISCARD has nothing to do with transform feedback.<br>
>> I think it's part of the same spec because it's not useful without it.<br>
>> As I understand it, _NEW_TRANSFORM_FEEDBACK is dirty when transform<br>
>> feedback buffer bindings are changed or just enabled/disabled. On the<br>
>> other hand, RASTERIZER_DISCARD enables or disables the rasterizer, so<br>
>> it should fall into the same category as face culling for example. (I<br>
>> even implemented it using face culling on r600)<br>
>><br>
>> Also there would be no way to know whether _NEW_TRANSFORM_FEEDBACK<br>
>> changes just TFB buffer bindings, or just RASTERIZER_DISCARD, or both.<br>
>><br>
>> Marek<br>
><br>
><br>
> I see where you are coming from--I could have implemented rasterizer discard<br>
> on i965 gen6 in the same way.<br>
><br>
> However, I think there are three compelling reasons to consider rasterizer<br>
> discard to be related to transform feedback:<br>
><br>
> (1) from a user perspective, it really only makes sense to use rasterizer<br>
> discard when transform feedback is active. Thus, it's highly likely that<br>
> when the rasterizer discard state is changed, transform feedback settings<br>
> will be changed too.<br>
><br>
> (2) rasterizer discard functionality is described by the same set of<br>
> extensions that enable transform feedback (e.g. EXT_transform_feedback), so<br>
> presumably the inventors of these two features thought they were closely<br>
> related.<br>
><br>
> (3) the enable bit that Mesa uses to keep track of the state of rasterizer<br>
> discard is in gl_context::TransformFeedback, not gl_context::Transform.<br>
><br>
> Item (3) is the most important to me. One of the scarier things about i965<br>
> driver development is that we have to manually keep track of which hardware<br>
> configuration commands correspond to which dirty bits. If we miss a<br>
> dependency, that causes a subtle bug in which a state change might not cause<br>
> the hardware state to be updated properly. These kinds of bugs are not well<br>
> exposed by Piglit tests, because most Piglit tests make a large number of<br>
> state changes followed by a draw operation, so a missing dependency might<br>
> easily go undetected. The thing that allows me to sleep at night is that<br>
> there is a nice one-to-one correspondence between almost all of the dirty<br>
> bits and corresponding substructures of gl_context. For example, the<br>
> _NEW_MODELVIEW dirty bit corresponds to gl_context::ModelView,<br>
> _NEW_PROJECTION corresponds to gl_context::Projection, and so on. That<br>
> means any time I am worried that I'm not handling dirty bits correctly, I<br>
> can visually inspect the code and make sure that the dirty bits I'm<br>
> consulting match up with which elements of gl_context I'm accessing. If we<br>
> leave the code as is, then there's a big undocumented exception to that<br>
> one-to-one correspondence, wherein<br>
> gl_context::TransformFeedback.RasterDiscard is covered by _NEW_TRANSFORM,<br>
> not _NEW_TRANSFORM_FEEDBACK, as one would logically guess based on where<br>
> it's located within gl_context. I'm not confident that I (or other<br>
> developers) will remember this exception once we're no longer in the thick<br>
> of implementing transform feedback and rasterizer discard.<br>
><br>
> It seems to me that we have three possible approaches to choose from here:<br>
><br>
> (a) Go ahead with this patch, and modify r600 code to recompute the face<br>
> culling mode when the _NEW_TRANSFORM_FEEDBACK dirty bit is set.<br>
><br>
> (b) Don't apply this patch, and instead move RasterDiscard from<br>
> gl_context::TransformFeedback to gl_context::Transform, so that we restore<br>
> the one-to-one correspondence between dirty bits and substructures of<br>
> gl_context.<br>
><br>
> (c) Do nothing, and rely on programmers to remember that RasterDiscard is an<br>
> exception to the usual correspondence between dirty bits and substructures<br>
> of gl_context.<br>
><br>
> I'm really not comfortable with (c) because of the risk of future bugs. I<br>
> suppose I could be talked into (b) if there's popular support for it, but<br>
> it's not my favourite, because as I said earlier, I think there are actually<br>
> a lot of good reasons to think of rasterizer discard as related to transform<br>
> feedback. My preference is to do (a).<br>
<br>
</div></div>(d) Rework the _NEW_* flags such that they roughly match hardware<br>
state groups, not OpenGL state groups. Direct3D 11 and Gallium are two<br>
examples of how it could be done.<br>
<br>
I am for (b) or (d). I would have nothing against (a) if TFB buffer<br>
bindings were not covered by the same flag. It's mainly about the<br>
overhead of state changes, although I admitted there are r600-related<br>
reasons too. Also, Gallium will have rasterizer_discard in the rasterizer<br>
state (once the patches hit master) - that can be changed though.<br>
<span class="HOEnZb"><font color="#888888"><br>
Marek<br>
</font></span></blockquote></div><br>I would be happy to review patches to do (d) if someone wants to take that on. Sadly, I do not have time to work on it myself right now, since I am under deadline pressure to finish OpenGL 3.0 support.<br>
<br>As for your concerns about the overhead of state changes caused by putting TFB buffer bindings under the same flag as rasterizer discard, would those concerns be addressed by removing the FLUSH_VERTICES(ctx, _NEW_TRANSFORM_FEEDBACK) call from bind_buffer_range()? As you pointed out in another email, I was wrong to add that in the first place, since the user isn't allowed to change transform feedback buffer bindings while transform feedback is active. I'm planning to send out a patch to fix that ASAP.<br>