[Mesa-dev] [RFC] [PATCH 0/4] Add frequency declaration for vertex elements

Keith Whitwell keithw at vmware.com
Mon Aug 16 06:50:40 PDT 2010


Luca,

It seems like there is an alternate fix possible -- modify the mesa
fixed-function vertex program generator to put these constant values in
the constant buffer, rather than passing them as vertex data.  That
would remove the need for us to have this unique capability at the
gallium level that none of the other graphics abstractions seem to
consider necessary.

I think we're putting more effort into accommodating the behaviour of
that code than really makes sense...

Keith

On Mon, 2010-08-16 at 04:30 -0700, Luca Barbieri wrote:
> I recently posted a patch that would set instance_divisor to 0xffffffff for
> constant elements, so that the driver could take that knowledge into account
> when creating the vertex elements CSO.
> 
> However, in Direct3D 11, the instance id system value is specified as a 32-bit
> unsigned integers, which can wrap to 0 and thus assume the value 0xffffffff.
> 
> Hence, such a divisor would have a different meaning in Direct3D 11, so my
> approach was the wrong one.
> 
> Here is a new approach, which instead adds a new field to pipe_vertex_element
> called "frequency", which indicates whether the element is per-vertex,
> per-instance or constant.
> 
> Direct3D 11 has a similar feature with the InputSlotClass field in
> D3D11_INPUT_ELEMENT_DESC, but lacks support for constant elements, since
> these are needed only to support "legacy OpenGL style" immediate attribute
> specification.
> 
> Note that currently draw uses translate in a suboptimal way to duplicate
> constant and per-instance elements.
> 
> While translate could be improved to not repeatedly fetch them, the
> real fix should be applied to draw (but this probably doesn't matter
> because draw_llvm doesn't seem to use translate).
> 
> draw_llvm could also perhaps use fetching constant elements only once: this
> patchset only eliminates the stride multiplication and index bounds checking.
> 
> We could theoretically add only a "constant vs non-constant field" instead,
> but this wouldn't reduce the lines of code changed, and deviates needlessly
> from Direct3D 11.
> 
> Luca Barbieri (4):
>   gallium: introduce explicit frequency declaration for vertex elements
>   gallium: set frequency = PIPE_ELEMENT_FREQUENCY_PER_VERTEX explicitly
>   mesa/st: specify constant frequency for elements
>   draw: optimize for vertex element frequency (esp. draw_llvm)
> 
>  src/gallium/auxiliary/draw/draw_llvm.c           |   54 ++++++++++++----------
>  src/gallium/auxiliary/draw/draw_pt.c             |   15 ++++--
>  src/gallium/auxiliary/draw/draw_pt_vcache.c      |    2 +-
>  src/gallium/auxiliary/util/u_blit.c              |    1 +
>  src/gallium/auxiliary/util/u_blitter.c           |    1 +
>  src/gallium/auxiliary/util/u_gen_mipmap.c        |    1 +
>  src/gallium/docs/d3d11ddi.txt                    |    2 +-
>  src/gallium/docs/source/context.rst              |   23 ++++++++--
>  src/gallium/docs/source/cso/velems.rst           |   11 +++-
>  src/gallium/drivers/r300/r300_render_translate.c |    1 +
>  src/gallium/include/pipe/p_defines.h             |    7 +++
>  src/gallium/include/pipe/p_state.h               |   14 ++++--
>  src/gallium/state_trackers/python/p_context.i    |    1 +
>  src/gallium/state_trackers/vega/polygon.c        |    1 +
>  src/gallium/state_trackers/vega/vg_context.c     |    1 +
>  src/gallium/state_trackers/xorg/xorg_renderer.c  |    1 +
>  src/gallium/tests/graw/tri-instanced.c           |    3 +
>  src/gallium/tests/trivial/quad-tex.c             |    2 +
>  src/gallium/tests/trivial/tri.c                  |    2 +
>  src/mesa/state_tracker/st_cb_drawtex.c           |    1 +
>  src/mesa/state_tracker/st_context.c              |    1 +
>  src/mesa/state_tracker/st_draw.c                 |    4 ++
>  src/mesa/state_tracker/st_draw_feedback.c        |    2 +
>  23 files changed, 108 insertions(+), 43 deletions(-)
> 




More information about the mesa-dev mailing list