[Mesa-dev] [PATCH 4/4] st/mesa: use PIPE_BIND_SAMPLER_VIEW_UNNORMALIZED_CLAMP for GL_TEXTURE_RECTANGLE (v2)
Luca Barbieri
luca at luca-barbieri.com
Tue Aug 17 00:09:13 PDT 2010
Changes in v3:
- Rework to use the bind flags
Changes in v2:
- No longer set the flag in compress_with_blit depending on NPOT, let the
driver do that if needed
Allow to pass flags to st_texture_create and take advantage of that
to tell the pipe driver that a texture is going to be used with unnormalized
coordinates.
This is useful for hardware with no mipmapped NPOT support that needs to
allocate texture rectangles in a special way (e.g. nv30).
---
src/mesa/state_tracker/st_cb_texture.c | 22 ++++++++++++++--------
src/mesa/state_tracker/st_format.c | 15 ++++++++++-----
2 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index bc0af17..aa20131 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -209,22 +209,28 @@ do_memcpy(void *dest, const void *src, size_t n)
* Return default texture resource binding bitmask for the given format.
*/
static GLuint
-default_bindings(struct st_context *st, enum pipe_format format)
+default_bindings(struct st_context *st, GLenum target, enum pipe_format format)
{
struct pipe_screen *screen = st->pipe->screen;
- const unsigned target = PIPE_TEXTURE_2D;
const unsigned geom = 0x0;
unsigned bindings;
+ unsigned sampler_view_binding;
if (util_format_is_depth_or_stencil(format))
- bindings = PIPE_BIND_SAMPLER_VIEW_ALL | PIPE_BIND_DEPTH_STENCIL;
+ bindings = PIPE_BIND_DEPTH_STENCIL;
else
- bindings = PIPE_BIND_SAMPLER_VIEW_ALL | PIPE_BIND_RENDER_TARGET;
+ bindings = PIPE_BIND_RENDER_TARGET;
- if (screen->is_format_supported(screen, format, target, 0, bindings, geom))
+ if(target == GL_TEXTURE_RECTANGLE)
+ sampler_view_binding = PIPE_BIND_SAMPLER_VIEW_UNNORMALIZED_CLAMP;
+ else
+ sampler_view_binding = PIPE_BIND_SAMPLER_VIEW_NORMALIZED;
+ bindings |= sampler_view_binding;
+
+ if (screen->is_format_supported(screen, format, PIPE_TEXTURE_2D, 0, bindings, geom))
return bindings;
else
- return PIPE_BIND_SAMPLER_VIEW_ALL;
+ return sampler_view_binding;
}
@@ -341,7 +347,7 @@ guess_and_alloc_texture(struct st_context *st,
fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat);
- bindings = default_bindings(st, fmt);
+ bindings = default_bindings(st, stObj->base.Target, fmt);
stObj->pt = st_texture_create(st,
gl_target_to_pipe(stObj->base.Target),
@@ -1866,7 +1872,7 @@ st_finalize_texture(GLcontext *ctx,
/* May need to create a new gallium texture:
*/
if (!stObj->pt) {
- GLuint bindings = default_bindings(st, firstImageFormat);
+ GLuint bindings = default_bindings(st, stObj->base.Target, firstImageFormat);
stObj->pt = st_texture_create(st,
gl_target_to_pipe(stObj->base.Target),
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index e2ba006..ed53439 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -717,19 +717,24 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
{
struct pipe_screen *screen = st_context(ctx)->pipe->screen;
enum pipe_format pFormat;
- uint bindings;
+ uint bindings, sampler_view_binding;
(void) format;
- (void) type;
/* GL textures may wind up being render targets, but we don't know
* that in advance. Specify potential render target flags now.
*/
if (_mesa_is_depth_format(internalFormat) ||
_mesa_is_depthstencil_format(internalFormat))
- bindings = PIPE_BIND_SAMPLER_VIEW_ALL | PIPE_BIND_DEPTH_STENCIL;
+ bindings = PIPE_BIND_DEPTH_STENCIL;
else
- bindings = PIPE_BIND_SAMPLER_VIEW_ALL | PIPE_BIND_RENDER_TARGET;
+ bindings = PIPE_BIND_RENDER_TARGET;
+
+ if(type == GL_TEXTURE_RECTANGLE)
+ sampler_view_binding = PIPE_BIND_SAMPLER_VIEW_UNNORMALIZED_CLAMP;
+ else
+ sampler_view_binding = PIPE_BIND_SAMPLER_VIEW_NORMALIZED;
+ bindings |= sampler_view_binding;
pFormat = st_choose_format(screen, internalFormat,
PIPE_TEXTURE_2D, 0, bindings);
@@ -737,7 +742,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
if (pFormat == PIPE_FORMAT_NONE) {
/* try choosing format again, this time without render target bindings */
pFormat = st_choose_format(screen, internalFormat,
- PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW_ALL);
+ PIPE_TEXTURE_2D, 0, sampler_view_binding);
}
if (pFormat == PIPE_FORMAT_NONE) {
--
1.7.0.4
More information about the mesa-dev
mailing list