i965: Add support for GL_ARB_seamless_cube_map
authorIan Romanick <ian.d.romanick@intel.com>
Fri, 14 Aug 2009 23:27:33 +0000 (16:27 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 14 Aug 2009 23:28:51 +0000 (16:28 -0700)
src/mesa/drivers/dri/i965/brw_wm_sampler_state.c
src/mesa/drivers/dri/intel/intel_extensions.c

index 3fc18ff1f3a3cfbc2de60736a96bb59c90d52839..dff466587a8df8c36640bffe132f1d644ff3148f 100644 (file)
@@ -103,6 +103,10 @@ struct wm_sampler_key {
       GLenum minfilter, magfilter;
       GLenum comparemode, comparefunc;
       dri_bo *sdc_bo;
+
+      /** If target is cubemap, take context setting.
+       */
+      GLboolean seamless_cube_map;
    } sampler[BRW_MAX_TEX_UNIT];
 };
 
@@ -169,30 +173,33 @@ static void brw_update_sampler_state(struct wm_sampler_entry *key,
       }  
    }
 
-   if (key->tex_target == GL_TEXTURE_CUBE_MAP &&
-       (key->minfilter != GL_NEAREST || key->magfilter != GL_NEAREST)) {
-      /* If we're using anything but nearest sampling for a cube map, we
-       * need to set this wrap mode to avoid GPU lock-ups.
-       */
-      sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CUBE;
-      sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;
-      sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;
-   }
-   else if (key->tex_target == GL_TEXTURE_1D) {
+   sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);
+   sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s);
+   sampler->ss1.t_wrap_mode = translate_wrap_mode(key->wrap_t);
+
+   /* Cube-maps on 965 and later must use the same wrap mode for all 3
+    * coordinate dimensions.  Futher, only CUBE and CLAMP are valid.
+    */
+   if (key->tex_target == GL_TEXTURE_CUBE_MAP) {
+      if (key->seamless_cube_map &&
+         (key->minfilter != GL_NEAREST || key->magfilter != GL_NEAREST)) {
+        sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CUBE;
+        sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CUBE;
+        sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CUBE;
+      } else {
+        sampler->ss1.r_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
+        sampler->ss1.s_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
+        sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_CLAMP;
+      }
+   } else if (key->tex_target == GL_TEXTURE_1D) {
       /* There's a bug in 1D texture sampling - it actually pays
        * attention to the wrap_t value, though it should not.
        * Override the wrap_t value here to GL_REPEAT to keep
        * any nonexistent border pixels from floating in.
        */
-      sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);
-      sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s);
       sampler->ss1.t_wrap_mode = BRW_TEXCOORDMODE_WRAP;
    }
-   else {
-      sampler->ss1.r_wrap_mode = translate_wrap_mode(key->wrap_r);
-      sampler->ss1.s_wrap_mode = translate_wrap_mode(key->wrap_s);
-      sampler->ss1.t_wrap_mode = translate_wrap_mode(key->wrap_t);
-   }
+
 
    /* Set shadow function: 
     */
@@ -249,6 +256,9 @@ brw_wm_sampler_populate_key(struct brw_context *brw,
 
          entry->tex_target = texObj->Target;
 
+        entry->seamless_cube_map = (texObj->Target == GL_TEXTURE_CUBE_MAP)
+           ? ctx->Texture.CubeMapSeamless : GL_FALSE;
+
         entry->wrap_r = texObj->WrapR;
         entry->wrap_s = texObj->WrapS;
         entry->wrap_t = texObj->WrapT;
index aa3d704f2995e1562860efc196bbe5321aea6970..9f90ef0a6973ca399e75b4b3b871de652f0b7fee 100644 (file)
@@ -140,6 +140,7 @@ static const struct dri_extension brw_extensions[] = {
    { "GL_ARB_framebuffer_object",         GL_ARB_framebuffer_object_functions},
    { "GL_ARB_occlusion_query",            GL_ARB_occlusion_query_functions },
    { "GL_ARB_point_sprite",              NULL },
+   { "GL_ARB_seamless_cube_map",          NULL },
    { "GL_ARB_shader_objects",             GL_ARB_shader_objects_functions },
    { "GL_ARB_shading_language_100",       GL_VERSION_2_0_functions },
    { "GL_ARB_shading_language_120",       GL_VERSION_2_1_functions },