On 16 November 2011 11:07, Paul Berry <span dir="ltr">&lt;<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>&gt;</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;">
In order to implement transform feedback on Gen6, we need to create a<br>
geometry shader program that will stream out the transformed vertices.<br>
It makes sense to re-use parts of the vec4_visitor infrastructure to<br>
do this, because (a) VS and GS handle data very similarly, (b) it<br>
allows us to take advantage of the optimization and register<br>
allocation code in vec4_visitor, and (c) in the long run when we add<br>
support for GLSL geometry shaders, we are going to need to use the<br>
vec4_visitor infrastructure to compile them.<br>
<br>
This patch series gets us ready for re-using parts of vec4_visitor, by<br>
breaking it into a base class containing the parts we are likely to<br>
re-use, and a derived class containing the parts we aren&#39;t.  The base<br>
class, vec4_generator, is responsible for code generation, register<br>
allocation, and optimization; it is independent of GLSL IR (with one<br>
trivial exception), and mostly independent of the type of shader being<br>
compiled.  The derived class, vec4_visitor, is responsible for<br>
visiting the GLSL IR and performing vertex-shader-specific actions.<br>
<br>
This split was already implicitly present in the code; this patch<br>
series merely makes it more explicit.<br>
<br>
The idea is that for now, we can make a class that derives from<br>
vec4_generator to do transform feedback, and we won&#39;t have to worry<br>
too much about interactions with the GLSL IR visiting code in<br>
vec4_visitor.  Later, when we add support for GLSL geometry shaders,<br>
we&#39;ll have to do further work on vec4_visitor, but we won&#39;t have to<br>
touch vec4_generator very much.<br>
<br>
Patches 01-11 are all preparatory refactoring: they make small<br>
adjustments to the functioning of vec4_visitor so that the separation<br>
between its IR visiting parts and its code generation parts is a<br>
little more strict.  Patch 12 splits the classes up, and then patch 13<br>
reformats the class declarations to clarify the relationship between<br>
the two classes.<br>
<br>
The split isn&#39;t perfect yet; there are a few places where<br>
vec4_generator still makes implicit assumptions that are vertex-shader<br>
specific (particularly in register allocation), and there are a few<br>
places where vec4_visitor still does things that arguably should be<br>
part of code generation (such as setting up scratch registers).  But I<br>
think this is close enough that we can clean those up with later<br>
patches on an as-needed basis.<br>
<br>
Note: To ease reading the diffs, I didn&#39;t make any effort to move code<br>
between .cpp files.  As a result, vec4_visitor and vec4_generator code<br>
are intermingled in brw_vec4_visitor.cpp, brw_vec4_emit.cpp,<br>
brw_vec4.cpp, brw_vec4_copy_propagation.cpp, and<br>
brw_vec4_reg_allocate.cpp.  Once this patch is reviewed and we&#39;ve<br>
settled on how we want the classes to be split up, I&#39;ll make a<br>
follow-up patch that rearranges the .cpp files to match the changes to<br>
the class structure.<br>
<br>
[PATCH 01/13] i965 vs: Remove dead code from the vec4_visitor class.<br>
[PATCH 02/13] i965 vs: Make reg_allocate() return total_grf.<br>
[PATCH 03/13] i965 vs: Return last_scratch from move_grf_array_access_to_scratch()<br>
[PATCH 04/13] i965 vs: Make first_non_payload_grf an explicit function arguments.<br>
[PATCH 05/13] i965 vs: Move brw_set_access_mode() call into generate_code().<br>
[PATCH 06/13] i965 vs: Move the call to reg_allocate() inside of generate_code().<br>
[PATCH 07/13] i965 vs: Streamline the way fail is tracked.<br>
[PATCH 08/13] i965 vs: Add get_debug_flag()<br>
[PATCH 09/13] i965 vs: Add get_debug_name().<br>
[PATCH 10/13] i965 vs: Make a separate optimize() method.<br>
[PATCH 11/13] i965 vs: Make get_assignment_lhs() a method<br>
[PATCH 12/13] i965 vs: Separate IR visiting from code generation in vec4_visitor;<br>
[PATCH 13/13] i965 vs: Rearrange class declarations.<br>
</blockquote></div><br>I should also mention: if you&#39;d like to look at these patches in context, you can pull them from my github repo (git://<a href="http://github.com/stereotype441/mesa.git">github.com/stereotype441/mesa.git</a>).  The branch is called &quot;vec4-split&quot;.<br>
<br>If you&#39;d like to see what the final vec4_generator and vec4_visitor classes look like, you can view them here: <a href="https://github.com/stereotype441/mesa/blob/vec4-split/src/mesa/drivers/dri/i965/brw_vec4.h">https://github.com/stereotype441/mesa/blob/vec4-split/src/mesa/drivers/dri/i965/brw_vec4.h</a><br>