mesa: implement AMD_seamless_cubemap_per_texture
authorMarek Olšák <maraeo@gmail.com>
Tue, 3 May 2011 09:37:25 +0000 (11:37 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 6 May 2011 18:06:30 +0000 (20:06 +0200)
src/mesa/main/extensions.c
src/mesa/main/mtypes.h
src/mesa/main/samplerobj.c
src/mesa/main/texobj.c
src/mesa/main/texparam.c

index 1062cde..a9ef8fa 100644 (file)
@@ -260,6 +260,7 @@ static const struct extension extension_table[] = {
    { "GL_3DFX_texture_compression_FXT1",           o(TDFX_texture_compression_FXT1),           GL,             1999 },
    { "GL_AMD_conservative_depth",                  o(AMD_conservative_depth),                  GL,             2009 },
    { "GL_AMD_draw_buffers_blend",                  o(ARB_draw_buffers_blend),                  GL,             2009 },
+   { "GL_AMD_seamless_cubemap_per_texture",        o(AMD_seamless_cubemap_per_texture),        GL,             2009 },
    { "GL_AMD_shader_stencil_export",               o(ARB_shader_stencil_export),               GL,             2009 },
    { "GL_APPLE_client_storage",                    o(APPLE_client_storage),                    GL,             2002 },
    { "GL_APPLE_object_purgeable",                  o(APPLE_object_purgeable),                  GL,             2006 },
index fba65e8..29c8cfd 100644 (file)
@@ -1339,6 +1339,7 @@ struct gl_sampler_object
    GLenum CompareFunc;         /**< GL_ARB_shadow */
    GLfloat CompareFailValue;    /**< GL_ARB_shadow_ambient */
    GLenum sRGBDecode;           /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
+   GLboolean CubeMapSeamless;   /**< GL_AMD_seamless_cubemap_per_texture */
 
    /* deprecated sampler state */
    GLenum DepthMode;           /**< GL_ARB_depth_texture */
@@ -2885,6 +2886,7 @@ struct gl_extensions
    GLboolean OES_standard_derivatives;
    /* vendor extensions */
    GLboolean AMD_conservative_depth;
+   GLboolean AMD_seamless_cubemap_per_texture;
    GLboolean APPLE_client_storage;
    GLboolean APPLE_packed_pixels;
    GLboolean APPLE_vertex_array_object;
index 4a28c91..6e53f64 100644 (file)
@@ -133,6 +133,7 @@ _mesa_init_sampler_object(struct gl_sampler_object *sampObj, GLuint name)
    sampObj->CompareFunc = GL_LEQUAL;
    sampObj->CompareFailValue = 0.0;
    sampObj->sRGBDecode = GL_FALSE;
+   sampObj->CubeMapSeamless = GL_FALSE;
    sampObj->DepthMode = 0;
 }
 
@@ -1110,6 +1111,11 @@ _mesa_GetSamplerParameteriv(GLuint sampler, GLenum pname, GLint *params)
       params[2] = FLOAT_TO_INT(sampObj->BorderColor.f[2]);
       params[3] = FLOAT_TO_INT(sampObj->BorderColor.f[3]);
       break;
+   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+      if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+         goto invalid_pname;
+      *params = sampObj->CubeMapSeamless;
+      break;
    default:
       goto invalid_pname;
    }
@@ -1178,6 +1184,11 @@ _mesa_GetSamplerParameterfv(GLuint sampler, GLenum pname, GLfloat *params)
       params[2] = sampObj->BorderColor.f[2];
       params[3] = sampObj->BorderColor.f[3];
       break;
+   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+      if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+         goto invalid_pname;
+      *params = (GLfloat) sampObj->CubeMapSeamless;
+      break;
    default:
       goto invalid_pname;
    }
@@ -1247,6 +1258,11 @@ _mesa_GetSamplerParameterIiv(GLuint sampler, GLenum pname, GLint *params)
       params[2] = sampObj->BorderColor.i[2];
       params[3] = sampObj->BorderColor.i[3];
       break;
+   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+      if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+         goto invalid_pname;
+      *params = sampObj->CubeMapSeamless;
+      break;
    default:
       goto invalid_pname;
    }
@@ -1316,6 +1332,11 @@ _mesa_GetSamplerParameterIuiv(GLuint sampler, GLenum pname, GLuint *params)
       params[2] = sampObj->BorderColor.ui[2];
       params[3] = sampObj->BorderColor.ui[3];
       break;
+   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+      if (!ctx->Extensions.AMD_seamless_cubemap_per_texture)
+         goto invalid_pname;
+      *params = sampObj->CubeMapSeamless;
+      break;
    default:
       goto invalid_pname;
    }
index 43d6e52..f2d214f 100644 (file)
@@ -141,6 +141,7 @@ _mesa_initialize_texture_object( struct gl_texture_object *obj,
    obj->Sampler.CompareFunc = GL_LEQUAL;       /* ARB_shadow */
    obj->Sampler.CompareFailValue = 0.0F;       /* ARB_shadow_ambient */
    obj->Sampler.DepthMode = GL_LUMINANCE;      /* ARB_depth_texture */
+   obj->Sampler.CubeMapSeamless = GL_FALSE;
    obj->Swizzle[0] = GL_RED;
    obj->Swizzle[1] = GL_GREEN;
    obj->Swizzle[2] = GL_BLUE;
@@ -251,6 +252,7 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
    dest->Sampler.CompareMode = src->Sampler.CompareMode;
    dest->Sampler.CompareFunc = src->Sampler.CompareFunc;
    dest->Sampler.CompareFailValue = src->Sampler.CompareFailValue;
+   dest->Sampler.CubeMapSeamless = src->Sampler.CubeMapSeamless;
    dest->Sampler.DepthMode = src->Sampler.DepthMode;
    dest->_MaxLevel = src->_MaxLevel;
    dest->_MaxLambda = src->_MaxLambda;
index f86a8cf..4b9dcb5 100644 (file)
@@ -439,6 +439,20 @@ set_tex_parameteri(struct gl_context *ctx,
       }
       goto invalid_pname;
 
+   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+      if (ctx->Extensions.AMD_seamless_cubemap_per_texture) {
+         GLenum param = params[0];
+         if (param != GL_TRUE && param != GL_FALSE) {
+            goto invalid_param;
+         }
+         if (param != texObj->Sampler.CubeMapSeamless) {
+            flush(ctx);
+            texObj->Sampler.CubeMapSeamless = param;
+         }
+         return GL_TRUE;
+      }
+      goto invalid_pname;
+
    default:
       goto invalid_pname;
    }
@@ -580,6 +594,7 @@ _mesa_TexParameterf(GLenum target, GLenum pname, GLfloat param)
    case GL_TEXTURE_COMPARE_FUNC_ARB:
    case GL_DEPTH_TEXTURE_MODE_ARB:
    case GL_TEXTURE_SRGB_DECODE_EXT:
+   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
       {
          /* convert float param to int */
          GLint p[4];
@@ -629,6 +644,7 @@ _mesa_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    case GL_TEXTURE_COMPARE_FUNC_ARB:
    case GL_DEPTH_TEXTURE_MODE_ARB:
    case GL_TEXTURE_SRGB_DECODE_EXT:
+   case GL_TEXTURE_CUBE_MAP_SEAMLESS:
       {
          /* convert float param to int */
          GLint p[4];
@@ -1235,6 +1251,14 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
          }
          break;
 
+      case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+      if (ctx->Extensions.AMD_seamless_cubemap_per_texture) {
+         *params = (GLfloat) obj->Sampler.CubeMapSeamless;
+      }
+      else {
+         error = GL_TRUE;
+      }
+
       default:
         error = GL_TRUE;
         break;
@@ -1396,6 +1420,14 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
          }
          break;
 
+      case GL_TEXTURE_CUBE_MAP_SEAMLESS:
+         if (ctx->Extensions.AMD_seamless_cubemap_per_texture) {
+            *params = (GLint) obj->Sampler.CubeMapSeamless;
+         }
+         else {
+            error = GL_TRUE;
+         }
+
       default:
          ; /* silence warnings */
    }