[Mesa-dev] [PATCHv2] draw: Rewrite primitive decomposer
Chia-I Wu
olvaffe at gmail.com
Thu Aug 5 08:55:22 PDT 2010
On Tue, Aug 3, 2010 at 12:33 AM, Chia-I Wu <olvaffe at gmail.com> wrote:
> While studying the draw module, I noticed that multiple primitive
> decomposers exist: draw_pt_vcache_tmp.h, draw_gs_tmp.h,
> draw_so_emit_tmp.h, and draw_pt_decompose.h. The differences between
> them are small, yet some of them support primitive modes that others
> don't. So I started the work to add a generic draw_decompose_tmp.h
> that can be included by other tmp header files. You may find the
> changes in the attachments, or
>
> http://cgit.freedesktop.org/~olv/mesa/log/?h=draw-decompose
>
> draw_decompose_tmp.h supports all primitive modes. While it is a
> rewrite, it resembles the existing decomposers a lot. There are two
> changes regarding how PIPE_PRIM_POLYGON and
> PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY are decomposed.
>
> When flatshade_first is TRUE, the first triangle of the decomposed
> polygon has edge flags 0 and 1 set; the last triangle has edge flags 1
> and 2 set; the other triangles has edge flags 1 set. This is
> different from the existing decomposers, which seem to set the edge
> flags wrongly(?).
>
> As for PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY, the GS decomposer does not
> seem to follow the vertex ordering of GL_TRIANGLE_STRIP_ADJACENCY. I
> write that part from scratch. I am not 100% sure here as I don't have
> a test case to verify. It would be great if someone can clarify.
>
> I haven't done a thorough (read: piglit) test yet. I would like to
> get early feedback before continuing. Suggestions?
I've pushed v2 of draw_decompose_tmp.h to
http://cgit.freedesktop.org/~olv/mesa/log/?h=draw-decompose-2.1
The main changes are
- Fix decomposition of triangle strip with adjacency (idx[3] was updated
before saved to idx[4])
- Fix several copy-and-paste errors in the comments
- vcache should not decompose, for example, tri_adj to tri
- Return directly for impossible primitive types to help the compiler
generate better code
- Rename the local variable flatfirst to last_vertex_last and invert its
meaning, as the variable is used to control how a bigger primitive is
decomposed. For example, a triangle strip with vertices [0, 1, 2, 3] will
be decomposed to two triangles with vertices [0, 1, 2] and [2, 1, 3]
respectively when last_vertex_last is TRUE (note that the last vertex of
each triangle is emitted last); it will be decomposed to [0, 1, 2] and
[0, 2, 1] when last_vertex_last is FALSE (note that the first vertex of
each triangle is emitted first).
Zack has helped a lot while I am updating the patches (big thanks!). The
patches have been verified with piglit (only those in glean) and manually
verified with a dozen of demos (in demos/src/trivial). If there is no
objection, I'd like to commit the patches tomorrow.
--
olv at LunarG.com
More information about the mesa-dev
mailing list