[Mesa-dev] [PATCH 1/1] mesa : OpenGL ES 3 support improvement regarding seamless cubemap state

Maxence Le Doré maxence.ledore at gmail.com
Thu Nov 8 17:54:34 PST 2012


Hi everyone,

I took a look at OpenGl ES 3.0 this summer and noticed a little something
than seems to still lack to the current implementation in mesa. It's about
the support of seamless cube maps. The spec seems to suggest that linearly
flltered cube maps should always be seamless, regarless of any state change

At Appendix F.2 (page 318 - page 330 of the PDF of OpenGL ES 3.0.0
specifications) you can read this :

"OpenGL ES 3.0 requires that all cube map filtering be seamless. OpenGL ES
2.0 specified that a single cube map face be selected and used for
filtering."

So, i've made this little patch as an attempt to get a more conforming
behavior. It involves a modification of interface for
_mesa_initialize_texture_object and _mesa_init_sampler_object functions to
give access to gl_context properties to make some needed GL API checks.



Here is the patch :



>From a0abd6e488aca5dca3d96868aea68bdffe25e339 Mon Sep 17 00:00:00 2001
From: Maxence Le Dore <maxence.ledore at gmail.com>
Date: Wed, 7 Nov 2012 20:34:10 +0100
Subject: [PATCH] es3_seamless_cube_map

---
 src/mesa/drivers/dri/intel/intel_tex.c         |    2 +-
 src/mesa/drivers/dri/nouveau/nouveau_texture.c |    2 +-
 src/mesa/drivers/dri/r200/r200_tex.c           |    2 +-
 src/mesa/drivers/dri/radeon/radeon_tex.c       |    2 +-
 src/mesa/main/enable.c                         |    4 +++-
 src/mesa/main/samplerobj.c                     |   10 +++++++---
 src/mesa/main/samplerobj.h                     |    3 ++-
 src/mesa/main/texobj.c                         |    8 +++++---
 src/mesa/main/texobj.h                         |    3 ++-
 src/mesa/state_tracker/st_cb_texture.c         |    2 +-
 10 files changed, 24 insertions(+), 14 deletions(-)

diff --git a/src/mesa/drivers/dri/intel/intel_tex.c
b/src/mesa/drivers/dri/intel/intel_tex.c
index 6820f98..b927440 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -34,7 +34,7 @@ intelNewTextureObject(struct gl_context * ctx, GLuint
name, GLenum target)
    (void) ctx;

    DBG("%s\n", __FUNCTION__);
-   _mesa_initialize_texture_object(&obj->base, name, target);
+   _mesa_initialize_texture_object(ctx, &obj->base, name, target);

    return &obj->base;
 }
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
index 37f7577..7a4ab60 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c
@@ -46,7 +46,7 @@ nouveau_texture_new(struct gl_context *ctx, GLuint name,
GLenum target)
 {
     struct nouveau_texture *nt = CALLOC_STRUCT(nouveau_texture);

-    _mesa_initialize_texture_object(&nt->base, name, target);
+    _mesa_initialize_texture_object(ctx, &nt->base, name, target);

     return &nt->base;
 }
diff --git a/src/mesa/drivers/dri/r200/r200_tex.c
b/src/mesa/drivers/dri/r200/r200_tex.c
index a4347c6..a74a2e9 100644
--- a/src/mesa/drivers/dri/r200/r200_tex.c
+++ b/src/mesa/drivers/dri/r200/r200_tex.c
@@ -477,7 +477,7 @@ static struct gl_texture_object
*r200NewTextureObject(struct gl_context * ctx,
        __FUNCTION__, ctx,
        _mesa_lookup_enum_by_nr(target), t);

-   _mesa_initialize_texture_object(&t->base, name, target);
+   _mesa_initialize_texture_object(ctx, &t->base, name, target);
    t->base.Sampler.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;

    /* Initialize hardware state */
diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.c
b/src/mesa/drivers/dri/radeon/radeon_tex.c
index 5ca07e0..56efb8c 100644
--- a/src/mesa/drivers/dri/radeon/radeon_tex.c
+++ b/src/mesa/drivers/dri/radeon/radeon_tex.c
@@ -411,7 +411,7 @@ radeonNewTextureObject( struct gl_context *ctx, GLuint
name, GLenum target )
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj);

-   _mesa_initialize_texture_object(&t->base, name, target);
+   _mesa_initialize_texture_object(ctx, &t->base, name, target);
    t->base.Sampler.MaxAnisotropy = rmesa->radeon.initialMaxAnisotropy;

    t->border_fallback = GL_FALSE;
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index e704f2f..4197e9d 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -938,6 +938,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap,
GLboolean state)
          break;

       case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+     if (_mesa_is_gles3(ctx))
+        return;
          if (!_mesa_is_desktop_gl(ctx))
             goto invalid_enum_error;
      CHECK_EXTENSION(ARB_seamless_cube_map, cap);
@@ -1517,7 +1519,7 @@ _mesa_IsEnabled( GLenum cap )
      return ctx->ATIFragmentShader.Enabled;

       case GL_TEXTURE_CUBE_MAP_SEAMLESS:
-         if (!_mesa_is_desktop_gl(ctx))
+         if (!_mesa_is_desktop_gl(ctx) && !_mesa_is_gles3(ctx))
             goto invalid_enum_error;
      CHECK_EXTENSION(ARB_seamless_cube_map);
      return ctx->Texture.CubeMapSeamless;
diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c
index 3c3bfff..4dacb7f 100644
--- a/src/mesa/main/samplerobj.c
+++ b/src/mesa/main/samplerobj.c
@@ -111,7 +111,8 @@ _mesa_reference_sampler_object_(struct gl_context *ctx,
  * Initialize the fields of the given sampler object.
  */
 void
-_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name)
+_mesa_init_sampler_object(struct gl_context *ctx,
+                          struct gl_sampler_object *sampObj, GLuint name)
 {
    sampObj->Name = name;
    sampObj->RefCount = 1;
@@ -131,7 +132,7 @@ _mesa_init_sampler_object(struct gl_sampler_object
*sampObj, GLuint name)
    sampObj->CompareMode = GL_NONE;
    sampObj->CompareFunc = GL_LEQUAL;
    sampObj->sRGBDecode = GL_DECODE_EXT;
-   sampObj->CubeMapSeamless = GL_FALSE;
+   sampObj->CubeMapSeamless = _mesa_is_gles3(ctx) ? GL_TRUE : GL_FALSE;
 }

 /**
@@ -142,7 +143,7 @@ _mesa_new_sampler_object(struct gl_context *ctx, GLuint
name)
 {
    struct gl_sampler_object *sampObj = CALLOC_STRUCT(gl_sampler_object);
    if (sampObj) {
-      _mesa_init_sampler_object(sampObj, name);
+      _mesa_init_sampler_object(ctx, sampObj, name);
    }
    return sampObj;
 }
@@ -576,6 +577,9 @@ set_sampler_cube_map_seamless(struct gl_context *ctx,
    if (param != GL_TRUE && param != GL_FALSE)
       return INVALID_VALUE;

+   if (_mesa_is_gles3(ctx))
+      return GL_FALSE;
+
    flush(ctx);
    samp->CubeMapSeamless = param;
    return GL_TRUE;
diff --git a/src/mesa/main/samplerobj.h b/src/mesa/main/samplerobj.h
index ecff032..a758c7f 100644
--- a/src/mesa/main/samplerobj.h
+++ b/src/mesa/main/samplerobj.h
@@ -64,7 +64,8 @@ _mesa_reference_sampler_object(struct gl_context *ctx,


 extern void
-_mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name);
+_mesa_init_sampler_object(struct gl_context *ctx,
+                          struct gl_sampler_object *sampObj, GLuint name);

 extern struct gl_sampler_object *
 _mesa_new_sampler_object(struct gl_context *ctx, GLuint name);
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index c083c72..2e6bab3 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -84,19 +84,21 @@ _mesa_new_texture_object( struct gl_context *ctx,
GLuint name, GLenum target )
    struct gl_texture_object *obj;
    (void) ctx;
    obj = MALLOC_STRUCT(gl_texture_object);
-   _mesa_initialize_texture_object(obj, name, target);
+   _mesa_initialize_texture_object(ctx, obj, name, target);
    return obj;
 }


 /**
  * Initialize a new texture object to default values.
+ * \param ctx the GL context
  * \param obj  the texture object
  * \param name  the texture name
  * \param target  the texture target
  */
 void
-_mesa_initialize_texture_object( struct gl_texture_object *obj,
+_mesa_initialize_texture_object( struct gl_context *ctx,
+                                 struct gl_texture_object *obj,
                                  GLuint name, GLenum target )
 {
    ASSERT(target == 0 ||
@@ -146,7 +148,7 @@ _mesa_initialize_texture_object( struct
gl_texture_object *obj,
    obj->Sampler.CompareMode = GL_NONE;         /* ARB_shadow */
    obj->Sampler.CompareFunc = GL_LEQUAL;       /* ARB_shadow */
    obj->DepthMode = GL_LUMINANCE;
-   obj->Sampler.CubeMapSeamless = GL_FALSE;
+   obj->Sampler.CubeMapSeamless = _mesa_is_gles3(ctx) ? GL_TRUE : GL_FALSE;
    obj->Swizzle[0] = GL_RED;
    obj->Swizzle[1] = GL_GREEN;
    obj->Swizzle[2] = GL_BLUE;
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index f86b4eb..368927a 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -50,7 +50,8 @@ extern struct gl_texture_object *
 _mesa_new_texture_object( struct gl_context *ctx, GLuint name, GLenum
target );

 extern void
-_mesa_initialize_texture_object( struct gl_texture_object *obj,
+_mesa_initialize_texture_object( struct gl_context *ctx,
+                                 struct gl_texture_object *obj,
                                  GLuint name, GLenum target );

 extern void
diff --git a/src/mesa/state_tracker/st_cb_texture.c
b/src/mesa/state_tracker/st_cb_texture.c
index b2711c3..6702e4d 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -138,7 +138,7 @@ st_NewTextureObject(struct gl_context * ctx, GLuint
name, GLenum target)
    struct st_texture_object *obj = ST_CALLOC_STRUCT(st_texture_object);

    DBG("%s\n", __FUNCTION__);
-   _mesa_initialize_texture_object(&obj->base, name, target);
+   _mesa_initialize_texture_object(ctx, &obj->base, name, target);

    return &obj->base;
 }
-- 
1.7.9.5
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20121109/97e8d3ef/attachment-0001.html>


More information about the mesa-dev mailing list