Support ARB_texture_rectangle.
authorKeith Whitwell <keith@tungstengraphics.com>
Wed, 20 Sep 2006 14:54:49 +0000 (14:54 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Wed, 20 Sep 2006 14:54:49 +0000 (14:54 +0000)
src/mesa/drivers/dri/i965/brw_tex.c
src/mesa/drivers/dri/i965/brw_tex_layout.c
src/mesa/drivers/dri/i965/brw_util.c
src/mesa/drivers/dri/i965/brw_wm_fp.c
src/mesa/drivers/dri/i965/intel_context.c

index d70b2ea87a5dff16bf44c392e307de2f88fd98be..78d351407de50895c2c06578bd2609d1a434df89 100644 (file)
@@ -75,7 +75,9 @@ brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_RGB5:
    case GL_RGB4:
    case GL_R3_G3_B2:
-/*       return &_mesa_texformat_rgb888; */
+      /* Broadwater doesn't support RGB textures, so these must be
+       * stored as ARGB.
+       */
       return &_mesa_texformat_argb8888;
 
    case GL_ALPHA:
index f8aa068241b2678f11e9a16bb68b58469c455cd0..1353325afff7c5ce3050419f64abf3d197172002 100644 (file)
@@ -138,13 +138,16 @@ GLboolean brw_miptree_layout( struct intel_mipmap_tree *mt )
         
         /* Layout_below: step right after second mipmap.
          */
-        if (level == mt->first_level + 1) 
+        if (level == mt->first_level + 1) {
            x += mt->pitch / 2;
+           x = (x + 3) & ~ 3;
+        }
         else {
            y += img_height;
+           y += align_h - 1;
+           y &= ~(align_h - 1);
         }
 
-
         width  = minify(width);
         height = minify(height);
       }
index 5957b717218525023fb4a49edaa19e522be3b3c8..9d12c26486d4595e18b5b4ad70561c5efaf040db 100644 (file)
@@ -98,6 +98,8 @@ static GLuint brw_parameter_state_flags(const enum state_index state[])
       switch (state[1]) {
       case STATE_NORMAL_SCALE:
         return _NEW_MODELVIEW;
+      case STATE_TEXRECT_SCALE:
+        return _NEW_TEXTURE;
       default:
         assert(0);
         return 0;
index 2f5968486632404aa7d4e50213ff0cf1e5ba7d19..8bf55790bfac3a9f2b69c33c95830c1acf6f7d5e 100644 (file)
@@ -520,6 +520,35 @@ static void precalc_lit( struct brw_wm_compile *c,
 static void precalc_tex( struct brw_wm_compile *c,
                         const struct prog_instruction *inst )
 {
+   struct prog_src_register coord;
+   struct prog_dst_register tmpcoord;
+
+   if (inst->TexSrcTarget == TEXTURE_RECT_INDEX) {
+      struct prog_src_register scale = 
+        search_or_add_param6( c, 
+                              STATE_INTERNAL, 
+                              STATE_TEXRECT_SCALE,
+                              inst->TexSrcUnit,
+                              0,0,0 );
+
+      tmpcoord = get_temp(c);
+
+      /* coord.xy   = MUL inst->SrcReg[0], { 1/width, 1/height }
+       */
+      emit_op(c,
+             OPCODE_MUL,
+             tmpcoord,
+             0, 0, 0,
+             inst->SrcReg[0],
+             scale,
+             src_undef());
+
+      coord = src_reg_from_dst(tmpcoord);
+   }
+   else {
+      coord = inst->SrcReg[0];
+   }
+
    /* Need to emit YUV texture conversions by hand.  Probably need to
     * do this here - the alternative is in brw_wm_emit.c, but the
     * conversion requires allocating a temporary variable which we
@@ -532,7 +561,7 @@ static void precalc_tex( struct brw_wm_compile *c,
              inst->SaturateMode,
              inst->TexSrcUnit,
              inst->TexSrcTarget,
-             inst->SrcReg[0],
+             coord,
              src_undef(),
              src_undef());
    }
@@ -604,7 +633,12 @@ static void precalc_tex( struct brw_wm_compile *c,
              src_swizzle1(tmpsrc, Z),
              src_swizzle1(C1, W),
              src_swizzle1(src_reg_from_dst(dst), Y));
+
+      release_temp(c, tmp);
    }
+
+   if (inst->TexSrcTarget == GL_TEXTURE_RECTANGLE_NV) 
+      release_temp(c, tmpcoord);
 }
 
 
index 47c8510ad39ecea049fe7a22a4282ba20a1e4580..c8ba26c425f5dc2f56456d8ce14f5267794ed43b 100644 (file)
@@ -149,6 +149,10 @@ const struct dri_extension card_extensions[] =
     { "GL_ARB_texture_env_combine",        NULL },
     { "GL_ARB_texture_env_dot3",           NULL },
     { "GL_ARB_texture_mirrored_repeat",    NULL },
+    { "GL_ARB_texture_non_power_of_two",   NULL },
+    { "GL_ARB_texture_rectangle",          NULL },
+    { "GL_NV_texture_rectangle",           NULL },
+    { "GL_EXT_texture_rectangle",          NULL },
     { "GL_ARB_texture_rectangle",          NULL },
     { "GL_ARB_vertex_buffer_object",       GL_ARB_vertex_buffer_object_functions },
     { "GL_ARB_vertex_program",             GL_ARB_vertex_program_functions },