r600: fix rectangle textures
authorAlex Deucher <alexdeucher@gmail.com>
Sun, 2 Aug 2009 00:55:43 +0000 (20:55 -0400)
committerAlex Deucher <alexdeucher@gmail.com>
Sun, 2 Aug 2009 00:55:43 +0000 (20:55 -0400)
It might be better to add an instruction to normalize the
coordinates for rectanglular textures as there are some limitations
to wrap modes on unnormalized tex coords.

fixes texrect

src/mesa/drivers/dri/r600/r700_assembler.c
src/mesa/drivers/dri/r600/r700_assembler.h

index ebd5ff106befb0248c5677e7ca103344adabac5c..0abf112b55f031785dabe1be8f8e30fa29499079 100644 (file)
@@ -1205,7 +1205,7 @@ GLboolean tex_src(r700_AssemblerBase *pAsm)
     return GL_TRUE;
 }
 
-GLboolean assemble_tex_instruction(r700_AssemblerBase *pAsm)
+GLboolean assemble_tex_instruction(r700_AssemblerBase *pAsm, GLboolean normalized)
 {
     PVSSRC *   texture_coordinate_source;
     PVSSRC *   texture_unit_source;
@@ -1227,10 +1227,18 @@ GLboolean assemble_tex_instruction(r700_AssemblerBase *pAsm)
     tex_instruction_ptr->m_Word0.f.resource_id      = texture_unit_source->reg;
 
     tex_instruction_ptr->m_Word1.f.lod_bias     = 0x0;
-    tex_instruction_ptr->m_Word1.f.coord_type_x = SQ_TEX_NORMALIZED;
-    tex_instruction_ptr->m_Word1.f.coord_type_y = SQ_TEX_NORMALIZED;
-    tex_instruction_ptr->m_Word1.f.coord_type_z = SQ_TEX_NORMALIZED;
-    tex_instruction_ptr->m_Word1.f.coord_type_w = SQ_TEX_NORMALIZED;
+    if (normalized) {
+           tex_instruction_ptr->m_Word1.f.coord_type_x = SQ_TEX_NORMALIZED;
+           tex_instruction_ptr->m_Word1.f.coord_type_y = SQ_TEX_NORMALIZED;
+           tex_instruction_ptr->m_Word1.f.coord_type_z = SQ_TEX_NORMALIZED;
+           tex_instruction_ptr->m_Word1.f.coord_type_w = SQ_TEX_NORMALIZED;
+    } else {
+           /* XXX: UNNORMALIZED tex coords have limited wrap modes */
+           tex_instruction_ptr->m_Word1.f.coord_type_x = SQ_TEX_UNNORMALIZED;
+           tex_instruction_ptr->m_Word1.f.coord_type_y = SQ_TEX_UNNORMALIZED;
+           tex_instruction_ptr->m_Word1.f.coord_type_z = SQ_TEX_UNNORMALIZED;
+           tex_instruction_ptr->m_Word1.f.coord_type_w = SQ_TEX_UNNORMALIZED;
+    }
 
     tex_instruction_ptr->m_Word2.f.offset_x   = 0x0;
     tex_instruction_ptr->m_Word2.f.offset_y   = 0x0;
@@ -2196,11 +2204,19 @@ GLboolean next_ins(r700_AssemblerBase *pAsm)
 
     if( GL_TRUE == IsTex(pILInst->Opcode) )
     {
-        if( GL_FALSE == assemble_tex_instruction(pAsm) ) 
-        {
-            r700_error(ERROR_ASM_TEXINSTRUCTION, "Error assembling TEX instruction");
-            return GL_FALSE;
-        }
+           if (pILInst->TexSrcTarget == TEXTURE_RECT_INDEX) {
+                   if( GL_FALSE == assemble_tex_instruction(pAsm, GL_FALSE) ) 
+                   {
+                           r700_error(ERROR_ASM_TEXINSTRUCTION, "Error assembling TEX instruction");
+                           return GL_FALSE;
+                   }
+           } else {
+                   if( GL_FALSE == assemble_tex_instruction(pAsm, GL_TRUE) ) 
+                   {
+                           r700_error(ERROR_ASM_TEXINSTRUCTION, "Error assembling TEX instruction");
+                           return GL_FALSE;
+                   }
+           }
     }
     else 
     {   //ALU      
index e9b21b802ec0a7bb57a0fbad4e0054f3a0cdc189..f9c4d849c65a24e95329fcc82ddf27fa3aaf95bb 100644 (file)
@@ -424,7 +424,7 @@ GLboolean assemble_src(r700_AssemblerBase *pAsm,
 GLboolean assemble_dst(r700_AssemblerBase *pAsm);
 GLboolean tex_dst(r700_AssemblerBase *pAsm);
 GLboolean tex_src(r700_AssemblerBase *pAsm);
-GLboolean assemble_tex_instruction(r700_AssemblerBase *pAsm);
+GLboolean assemble_tex_instruction(r700_AssemblerBase *pAsm, GLboolean normalized);
 void initialize(r700_AssemblerBase *pAsm);
 GLboolean assemble_alu_src(R700ALUInstruction*  alu_instruction_ptr,
                            int                  source_index,