r600: support vertex_array_bgra
authorAndre Maasikas <amaasikas@gmail.com>
Tue, 29 Dec 2009 12:47:01 +0000 (14:47 +0200)
committerAndre Maasikas <amaasikas@gmail.com>
Mon, 4 Jan 2010 10:39:37 +0000 (12:39 +0200)
Use vertex program key mechanism and swizzle during vertex fetch - is there
a better way?

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

index 394fd757d4b718b6e26672ef50446d205e0e9184..94662ab547925e94f114bcb845abbd81e74216ce 100644 (file)
@@ -108,6 +108,7 @@ typedef struct StreamDesc
        GLint   size;   //number of data element
        GLenum  type;  //data element type
        GLsizei stride;
+       GLenum  format; // GL_RGBA,GLBGRA 
 
        struct radeon_bo *bo;
        GLint  bo_offset;
index e464c6191c35a60c35ec97e74619224954146e7f..1ff89e18eaab895664a25be132f28a8a8bd1d57c 100644 (file)
@@ -891,6 +891,7 @@ GLboolean assemble_vfetch_instruction2(r700_AssemblerBase* pAsm,
                                        GLubyte             element,
                                        GLuint              _signed,
                                        GLboolean           normalize,
+                                       GLenum              format,
                                        VTX_FETCH_METHOD  * pFetchMethod)
 {
     GLuint client_size_inbyte;
@@ -939,10 +940,21 @@ GLboolean assemble_vfetch_instruction2(r700_AssemblerBase* pAsm,
        vfetch_instruction_ptr->m_Word0.f.src_sel_x        = SQ_SEL_X;
        vfetch_instruction_ptr->m_Word0.f.mega_fetch_count = mega_fetch_count;
 
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_x        = (size < 1) ? SQ_SEL_0 : SQ_SEL_X;
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_y        = (size < 2) ? SQ_SEL_0 : SQ_SEL_Y;
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_z        = (size < 3) ? SQ_SEL_0 : SQ_SEL_Z;
-       vfetch_instruction_ptr->m_Word1.f.dst_sel_w        = (size < 4) ? SQ_SEL_1 : SQ_SEL_W;
+       if(format == GL_BGRA)
+       {
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_x        = (size < 1) ? SQ_SEL_0 : SQ_SEL_Z;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_y        = (size < 2) ? SQ_SEL_0 : SQ_SEL_Y;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_z        = (size < 3) ? SQ_SEL_0 : SQ_SEL_X;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_w        = (size < 4) ? SQ_SEL_1 : SQ_SEL_W;
+       }
+       else
+       {
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_x        = (size < 1) ? SQ_SEL_0 : SQ_SEL_X;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_y        = (size < 2) ? SQ_SEL_0 : SQ_SEL_Y;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_z        = (size < 3) ? SQ_SEL_0 : SQ_SEL_Z;
+               vfetch_instruction_ptr->m_Word1.f.dst_sel_w        = (size < 4) ? SQ_SEL_1 : SQ_SEL_W;
+
+       }
 
        vfetch_instruction_ptr->m_Word1.f.use_const_fields = 1;
     vfetch_instruction_ptr->m_Word1.f.data_format      = data_format;
index dbd9860f7d0b578dc3486ca4b4909a4aadb1412b..86342b814f338d731ed9d937c7a7703c7136c4a7 100644 (file)
@@ -531,6 +531,7 @@ GLboolean assemble_vfetch_instruction2(r700_AssemblerBase* pAsm,
                                        GLubyte             element,
                                        GLuint              _signed,
                                        GLboolean           normalize,
+                                       GLenum              format,
                                        VTX_FETCH_METHOD  * pFetchMethod);
 GLboolean cleanup_vfetch_instructions(r700_AssemblerBase* pAsm);
 GLuint gethelpr(r700_AssemblerBase* pAsm);
index 90fac078ff0bcae338c8e18e33d047fb28fbf169..782f151f5ac42d3824354d89c3b45a5e348b1aef 100644 (file)
@@ -188,7 +188,8 @@ GLboolean Process_Vertex_Program_Vfetch_Instructions2(
                                       context->stream_desc[i].size,
                                       context->stream_desc[i].element,
                                       context->stream_desc[i]._signed,
-                                      context->stream_desc[i].normalize,                                                           
+                                      context->stream_desc[i].normalize,
+                                      context->stream_desc[i].format,
                                      &vtxFetchMethod);
     }
 
@@ -319,6 +320,7 @@ struct r700_vertex_program* r700TranslateVertexShader(GLcontext *ctx,
                vp->aos_desc[i].size   = context->stream_desc[i].size;
                vp->aos_desc[i].stride = context->stream_desc[i].stride;
                vp->aos_desc[i].type   = context->stream_desc[i].type;
+               vp->aos_desc[i].format = context->stream_desc[i].format;
        }
 
        if (context->radeon.radeonScreen->chip_family < CHIP_FAMILY_RV770)
@@ -395,7 +397,8 @@ void r700SelectVertexShader(GLcontext *ctx)
        match = GL_TRUE;
        for(i=0; i<context->nNumActiveAos; i++)
        {
-               if (vp->aos_desc[i].size != context->stream_desc[i].size)
+               if (vp->aos_desc[i].size != context->stream_desc[i].size ||
+                   vp->aos_desc[i].format != context->stream_desc[i].format)
                {
                        match = GL_FALSE;
                        break;
@@ -498,6 +501,7 @@ static void r700TranslateAttrib(GLcontext *ctx, GLuint unLoc, int count, const s
        pStreamDesc->size = input->Size;
        pStreamDesc->dst_loc = context->nNumActiveAos;
        pStreamDesc->element = unLoc;
+       pStreamDesc->format = input->Format;
 
        switch (pStreamDesc->type) 
        { //GetSurfaceFormat
index 00824c29d3218b11ce6b0859205fb2f6ceeb957b..645c9ac84aae4e7346e4e6f8e53cd3e7d67066ab 100644 (file)
@@ -39,6 +39,7 @@ typedef struct ArrayDesc //TEMP
        GLint size;   //number of data element
        GLenum type;  //data element type
        GLsizei stride;
+       GLenum format; //GL_RGBA or GL_BGRA
 } ArrayDesc;
 
 struct r700_vertex_program