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 d70b2ea..78d3514 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 f8aa068..1353325 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 5957b71..9d12c26 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 2f59684..8bf5579 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 47c8510..c8ba26c 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 },