[Mesa-dev] [RFC] [PATCH 0/2] Allow mesa/st to inform driver of GL_TEXTURE_RECTANGLE

Luca Barbieri luca at luca-barbieri.com
Thu Apr 15 00:36:52 PDT 2010


See also the RFC-gallium-unnormalized-coords-hint branch.

Currently the Gallium driver has no way of telling that a texture was created
with GL_TEXTURE_RECTANGLE as opposed to GL_TEXTURE_2D.

Unfortunately, some hardware like nv30 has two texture layouts, and the
first only works with unnormalized coordinates (and has no mipmap support),
and the second only works with normalized coordinates (and requires POT sizes).

Thus, it is beneficial to know which kind of coordinates are going to be used at
texture creation time.

Fortunately, with OpenGL, whether normalized or unnormalized coordinates can
be used is decided at creation time, but we don't currently pass this to
the driver.

This branch adds a new resource flag that is used by the state trackers to
tell the driver whether it is going to typically use sampler states with
normalized_coords = 0.

In practice, the OpenGL state tracker sets it if and only if GL_TEXTURE_RECTANGLE
is being used as the texture target.

Note that this patch series does *not* make this a mandatory flag, but rather an
hint: the driver is theoretically supposed to either change the texture layout
or alter the fragment shader if a normalization mismatch happens.

The general idea is that the weird pre-DirectX 10 restrictions for texture sizes
should be hidden by the driver, and not exposed to the state tracker.

Currently the NPOT cap exposes them a bit, but r300g just lifted all restrictions
and hopefully nv30 will too (nv40 also has the minor restriction of not supporting
unnormalized coordinates with mipmaps).

However, this flag is still likely to be useful to avoid unnecessary overhead.

Right now, it's required to correctly support ARB_texture_rectangle on nv30.

The impact on Gallium is quite minimal.

Luca Barbieri (2):
  gallium: add PIPE_RESOURCE_FLAG_UNNORMALIZED_COORDS_HINT
  st/mesa: set PIPE_RESOURCE_FLAG_UNNORMALIZED_COORDS_HINT for
    GL_TEXTURE_RECTANGLE

 src/gallium/include/pipe/p_defines.h           |    6 ++++++
 src/mesa/state_tracker/st_atom_pixeltransfer.c |    2 +-
 src/mesa/state_tracker/st_cb_bitmap.c          |    4 ++--
 src/mesa/state_tracker/st_cb_drawpixels.c      |    2 +-
 src/mesa/state_tracker/st_cb_texture.c         |   16 ++++++++++++++--
 src/mesa/state_tracker/st_gen_mipmap.c         |    8 ++++++--
 src/mesa/state_tracker/st_texture.c            |    5 +++--
 src/mesa/state_tracker/st_texture.h            |    3 ++-
 8 files changed, 35 insertions(+), 11 deletions(-)



More information about the mesa-dev mailing list