This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 97068322694c6fa144e4214de54347751dd1d212
Author: m4n4t4...@gmail.com 
<m4n4t4...@gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Sun Nov 2 14:39:08 2014 +0000

    All: Rend2: Change normal/tangent vertex encoding
---
 MP/code/rend2/glsl/dlight_vp.glsl     |   2 +-
 MP/code/rend2/glsl/fogpass_vp.glsl    |   3 +-
 MP/code/rend2/glsl/generic_vp.glsl    |   3 +-
 MP/code/rend2/glsl/lightall_vp.glsl   |   9 +--
 MP/code/rend2/glsl/pshadow_vp.glsl    |   2 +-
 MP/code/rend2/glsl/shadowfill_vp.glsl |   1 -
 MP/code/rend2/tr_extensions.c         |   4 +-
 MP/code/rend2/tr_vbo.c                | 136 ++++++++++++++++++++++++----------
 SP/code/rend2/glsl/dlight_vp.glsl     |   2 +-
 SP/code/rend2/glsl/fogpass_vp.glsl    |   3 +-
 SP/code/rend2/glsl/generic_vp.glsl    |   3 +-
 SP/code/rend2/glsl/lightall_vp.glsl   |   9 +--
 SP/code/rend2/glsl/pshadow_vp.glsl    |   2 +-
 SP/code/rend2/glsl/shadowfill_vp.glsl |   1 -
 SP/code/rend2/tr_extensions.c         |   4 +-
 SP/code/rend2/tr_vbo.c                | 136 ++++++++++++++++++++++++----------
 16 files changed, 212 insertions(+), 108 deletions(-)

diff --git a/MP/code/rend2/glsl/dlight_vp.glsl 
b/MP/code/rend2/glsl/dlight_vp.glsl
index 9566a04..c326bd7 100644
--- a/MP/code/rend2/glsl/dlight_vp.glsl
+++ b/MP/code/rend2/glsl/dlight_vp.glsl
@@ -74,7 +74,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const 
vec2 st)
 void main()
 {
        vec3 position = attr_Position;
-       vec3 normal = attr_Normal * 2.0 - vec3(1.0);
+       vec3 normal = attr_Normal;
 
 #if defined(USE_DEFORM_VERTEXES)
        position = DeformPosition(position, normal, attr_TexCoord0.st);
diff --git a/MP/code/rend2/glsl/fogpass_vp.glsl 
b/MP/code/rend2/glsl/fogpass_vp.glsl
index 6afc364..eec99de 100644
--- a/MP/code/rend2/glsl/fogpass_vp.glsl
+++ b/MP/code/rend2/glsl/fogpass_vp.glsl
@@ -108,10 +108,9 @@ void main()
 #if defined(USE_VERTEX_ANIMATION)
        vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);
        vec3 normal   = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
-       normal = normalize(normal - vec3(0.5));
 #else
        vec3 position = attr_Position;
-       vec3 normal   = attr_Normal * 2.0 - vec3(1.0);
+       vec3 normal   = attr_Normal;
 #endif
 
 #if defined(USE_DEFORM_VERTEXES)
diff --git a/MP/code/rend2/glsl/generic_vp.glsl 
b/MP/code/rend2/glsl/generic_vp.glsl
index 60f6c99..8dc86d7 100644
--- a/MP/code/rend2/glsl/generic_vp.glsl
+++ b/MP/code/rend2/glsl/generic_vp.glsl
@@ -213,10 +213,9 @@ void main()
 #if defined(USE_VERTEX_ANIMATION)
        vec3 position  = mix(attr_Position, attr_Position2, u_VertexLerp);
        vec3 normal    = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
-       normal = normalize(normal - vec3(0.5));
 #else
        vec3 position  = attr_Position;
-       vec3 normal    = attr_Normal * 2.0 - vec3(1.0);
+       vec3 normal    = attr_Normal;
 #endif
 
 #if defined(USE_DEFORM_VERTEXES)
diff --git a/MP/code/rend2/glsl/lightall_vp.glsl 
b/MP/code/rend2/glsl/lightall_vp.glsl
index b9e839d..59051d7 100644
--- a/MP/code/rend2/glsl/lightall_vp.glsl
+++ b/MP/code/rend2/glsl/lightall_vp.glsl
@@ -167,11 +167,6 @@ void main()
   #endif
 #endif
 
-       normal  = normal  * 2.0 - vec3(1.0);
-#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && 
!defined(USE_FAST_LIGHT)
-       tangent = tangent * 2.0 - vec3(1.0);
-#endif
-
 #if defined(USE_TCGEN)
        vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, 
u_TCGen0Vector0, u_TCGen0Vector1);
 #else
@@ -195,13 +190,13 @@ void main()
 #endif
 
 #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && 
!defined(USE_FAST_LIGHT)
-       vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0);
+       vec3 bitangent = cross(normal, tangent) * attr_Tangent.w;
 #endif
 
 #if defined(USE_LIGHT_VECTOR)
        vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);
 #elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
-       vec3 L = attr_LightDirection * 2.0 - vec3(1.0);
+       vec3 L = attr_LightDirection;
   #if defined(USE_MODELMATRIX)
        L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
   #endif
diff --git a/MP/code/rend2/glsl/pshadow_vp.glsl 
b/MP/code/rend2/glsl/pshadow_vp.glsl
index 0f9940c..07a4985 100644
--- a/MP/code/rend2/glsl/pshadow_vp.glsl
+++ b/MP/code/rend2/glsl/pshadow_vp.glsl
@@ -11,5 +11,5 @@ void main()
        gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
 
        var_Position  = attr_Position;
-       var_Normal    = attr_Normal * 2.0 - vec3(1.0);
+       var_Normal    = attr_Normal;
 }
diff --git a/MP/code/rend2/glsl/shadowfill_vp.glsl 
b/MP/code/rend2/glsl/shadowfill_vp.glsl
index 7a5cc57..7de901b 100644
--- a/MP/code/rend2/glsl/shadowfill_vp.glsl
+++ b/MP/code/rend2/glsl/shadowfill_vp.glsl
@@ -80,7 +80,6 @@ void main()
 {
        vec3 position  = mix(attr_Position, attr_Position2, u_VertexLerp);
        vec3 normal    = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
-       normal = normalize(normal - vec3(0.5));
 
        position = DeformPosition(position, normal, attr_TexCoord0.st);
 
diff --git a/MP/code/rend2/tr_extensions.c b/MP/code/rend2/tr_extensions.c
index 6ac8f83..b770e6c 100644
--- a/MP/code/rend2/tr_extensions.c
+++ b/MP/code/rend2/tr_extensions.c
@@ -673,11 +673,11 @@ void GLimp_InitExtraExtensions()
 
        // GL_ARB_vertex_type_2_10_10_10_rev
        extension = "GL_ARB_vertex_type_2_10_10_10_rev";
-       glRefConfig.packedNormalDataType = GL_UNSIGNED_BYTE;
+       glRefConfig.packedNormalDataType = GL_BYTE;
        if( GLimp_HaveExtension( extension ) )
        {
                if (r_arb_vertex_type_2_10_10_10_rev->integer)
-                       glRefConfig.packedNormalDataType = 
GL_UNSIGNED_INT_2_10_10_10_REV;
+                       glRefConfig.packedNormalDataType = 
GL_INT_2_10_10_10_REV;
 
                ri.Printf(PRINT_ALL, 
result[r_arb_vertex_type_2_10_10_10_rev->integer ? 1 : 0], extension);
        }
diff --git a/MP/code/rend2/tr_vbo.c b/MP/code/rend2/tr_vbo.c
index 9734c5a..981741f 100644
--- a/MP/code/rend2/tr_vbo.c
+++ b/MP/code/rend2/tr_vbo.c
@@ -23,71 +23,126 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
 #include "tr_local.h"
 
 
+union pack10_u {
+       struct {
+               signed int x:10;
+               signed int y:10;
+               signed int z:10;
+               signed int w:2;
+       } pack;
+       uint32_t i;
+};
+
+union pack8_u {
+       struct {
+               signed int x:8;
+               signed int y:8;
+               signed int z:8;
+               signed int w:8;
+       } pack;
+       uint32_t i;
+};
+
+
 uint32_t R_VaoPackTangent(vec4_t v)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               return (((uint32_t)(v[3] * 1.5f   + 2.0f  )) << 30)
-                    | (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20)
-                    | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10)
-                    | (((uint32_t)(v[0] * 511.5f + 512.0f)));
+               union pack10_u num;
+
+               num.pack.x = v[0] * 511.0f;
+               num.pack.y = v[1] * 511.0f;
+               num.pack.z = v[2] * 511.0f;
+               num.pack.w = v[3];
+
+               return num.i;
        }
        else
        {
-               return (((uint32_t)(v[3] * 127.5f + 128.0f)) << 24)
-                    | (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16)
-                    | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8)
-                    | (((uint32_t)(v[0] * 127.5f + 128.0f)));
+               union pack8_u num;
+
+               num.pack.x = v[0] * 127.0f;
+               num.pack.y = v[1] * 127.0f;
+               num.pack.z = v[2] * 127.0f;
+               num.pack.w = v[3] * 127.0f;
+
+               return num.i;
        }
 }
 
 uint32_t R_VaoPackNormal(vec3_t v)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               return (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20)
-                    | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10)
-                    | (((uint32_t)(v[0] * 511.5f + 512.0f)));
+               union pack10_u num;
+
+               num.pack.x = v[0] * 511.0f;
+               num.pack.y = v[1] * 511.0f;
+               num.pack.z = v[2] * 511.0f;
+               num.pack.w = 0;
+
+               return num.i;
        }
        else
        {
-               return (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16)
-                    | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8)
-                    | (((uint32_t)(v[0] * 127.5f + 128.0f)));
+               union pack8_u num;
+
+               num.pack.x = v[0] * 127.0f;
+               num.pack.y = v[1] * 127.0f;
+               num.pack.z = v[2] * 127.0f;
+               num.pack.w = 0;
+
+               return num.i;
        }
 }
 
 void R_VaoUnpackTangent(vec4_t v, uint32_t b)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               v[0] = ((b)       & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[3] = ((b >> 30) & 0x3)   * 1.0f/1.5f   - 1.0f;
+               union pack10_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 511.0f;
+               v[1] = num.pack.y / 511.0f;
+               v[2] = num.pack.z / 511.0f;
+               v[3] = num.pack.w; 
        }
        else
        {
-               v[0] = ((b)       & 0xff) * 1.0f/127.5f - 1.0f;
-               v[1] = ((b >> 8)  & 0xff) * 1.0f/127.5f - 1.0f;
-               v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f;
-               v[3] = ((b >> 24) & 0xff) * 1.0f/127.5f - 1.0f;
+               union pack8_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 127.0f;
+               v[1] = num.pack.y / 127.0f;
+               v[2] = num.pack.z / 127.0f;
+               v[3] = num.pack.w / 127.0f; 
        }
 }
 
 void R_VaoUnpackNormal(vec3_t v, uint32_t b)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               v[0] = ((b)       & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f;
+               union pack10_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 511.0f;
+               v[1] = num.pack.y / 511.0f;
+               v[2] = num.pack.z / 511.0f;
        }
        else
        {
-               v[0] = ((b)       & 0xff) * 1.0f/127.5f - 1.0f;
-               v[1] = ((b >> 8)  & 0xff) * 1.0f/127.5f - 1.0f;
-               v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f;
+               union pack8_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 127.0f;
+               v[1] = num.pack.y / 127.0f;
+               v[2] = num.pack.z / 127.0f;
        }
 }
 
@@ -651,6 +706,7 @@ void RB_UpdateTessVao(unsigned int attribBits)
        if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES && 
tess.numIndexes > 0 && tess.numIndexes <= SHADER_MAX_INDEXES)
        {
                int attribIndex;
+               int attribUpload;
 
                R_BindVao(tess.vao);
 
@@ -661,25 +717,29 @@ void RB_UpdateTessVao(unsigned int attribBits)
                if(!(attribBits & ATTR_BITS))
                        attribBits = ATTR_BITS;
 
-               if(attribBits & ATTR_TEXCOORD || attribBits & ATTR_LIGHTCOORD)
+               attribUpload = attribBits;
+
+               if((attribUpload & ATTR_TEXCOORD) || (attribUpload & 
ATTR_LIGHTCOORD))
                {
                        // these are interleaved, so we update both if either 
need it
                        // this translates to updating ATTR_TEXCOORD twice as 
large as it needs
-                       attribBits &= ~ATTR_LIGHTCOORD;
-                       attribBits |= ATTR_TEXCOORD;
+                       attribUpload &= ~ATTR_LIGHTCOORD;
+                       attribUpload |= ATTR_TEXCOORD;
                }
 
                for (attribIndex = 0; attribIndex < ATTR_INDEX_COUNT; 
attribIndex++)
                {
                        uint32_t attribBit = 1 << attribIndex;
+                       vaoAttrib_t *vAtb = &tess.vao->attribs[attribIndex];
 
-                       if (attribBits & attribBit)
+                       if (attribUpload & attribBit)
                        {
-                               vaoAttrib_t *vAtb = 
&tess.vao->attribs[attribIndex];
-
                                // note: tess has a VBO where stride == size
                                qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 
vAtb->offset, tess.numVertexes * vAtb->stride, 
tess.attribPointers[attribIndex]);
+                       }
 
+                       if (attribBits & attribBit)
+                       {
                                if (!glRefConfig.vertexArrayObject)
                                        qglVertexAttribPointerARB(attribIndex, 
vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, 
BUFFER_OFFSET(vAtb->offset));
 
diff --git a/SP/code/rend2/glsl/dlight_vp.glsl 
b/SP/code/rend2/glsl/dlight_vp.glsl
index 9566a04..c326bd7 100644
--- a/SP/code/rend2/glsl/dlight_vp.glsl
+++ b/SP/code/rend2/glsl/dlight_vp.glsl
@@ -74,7 +74,7 @@ vec3 DeformPosition(const vec3 pos, const vec3 normal, const 
vec2 st)
 void main()
 {
        vec3 position = attr_Position;
-       vec3 normal = attr_Normal * 2.0 - vec3(1.0);
+       vec3 normal = attr_Normal;
 
 #if defined(USE_DEFORM_VERTEXES)
        position = DeformPosition(position, normal, attr_TexCoord0.st);
diff --git a/SP/code/rend2/glsl/fogpass_vp.glsl 
b/SP/code/rend2/glsl/fogpass_vp.glsl
index 6afc364..eec99de 100644
--- a/SP/code/rend2/glsl/fogpass_vp.glsl
+++ b/SP/code/rend2/glsl/fogpass_vp.glsl
@@ -108,10 +108,9 @@ void main()
 #if defined(USE_VERTEX_ANIMATION)
        vec3 position = mix(attr_Position, attr_Position2, u_VertexLerp);
        vec3 normal   = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
-       normal = normalize(normal - vec3(0.5));
 #else
        vec3 position = attr_Position;
-       vec3 normal   = attr_Normal * 2.0 - vec3(1.0);
+       vec3 normal   = attr_Normal;
 #endif
 
 #if defined(USE_DEFORM_VERTEXES)
diff --git a/SP/code/rend2/glsl/generic_vp.glsl 
b/SP/code/rend2/glsl/generic_vp.glsl
index 60f6c99..8dc86d7 100644
--- a/SP/code/rend2/glsl/generic_vp.glsl
+++ b/SP/code/rend2/glsl/generic_vp.glsl
@@ -213,10 +213,9 @@ void main()
 #if defined(USE_VERTEX_ANIMATION)
        vec3 position  = mix(attr_Position, attr_Position2, u_VertexLerp);
        vec3 normal    = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
-       normal = normalize(normal - vec3(0.5));
 #else
        vec3 position  = attr_Position;
-       vec3 normal    = attr_Normal * 2.0 - vec3(1.0);
+       vec3 normal    = attr_Normal;
 #endif
 
 #if defined(USE_DEFORM_VERTEXES)
diff --git a/SP/code/rend2/glsl/lightall_vp.glsl 
b/SP/code/rend2/glsl/lightall_vp.glsl
index b9e839d..59051d7 100644
--- a/SP/code/rend2/glsl/lightall_vp.glsl
+++ b/SP/code/rend2/glsl/lightall_vp.glsl
@@ -167,11 +167,6 @@ void main()
   #endif
 #endif
 
-       normal  = normal  * 2.0 - vec3(1.0);
-#if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && 
!defined(USE_FAST_LIGHT)
-       tangent = tangent * 2.0 - vec3(1.0);
-#endif
-
 #if defined(USE_TCGEN)
        vec2 texCoords = GenTexCoords(u_TCGen0, position, normal, 
u_TCGen0Vector0, u_TCGen0Vector1);
 #else
@@ -195,13 +190,13 @@ void main()
 #endif
 
 #if defined(USE_VERT_TANGENT_SPACE) && defined(USE_LIGHT) && 
!defined(USE_FAST_LIGHT)
-       vec3 bitangent = cross(normal, tangent) * (attr_Tangent.w * 2.0 - 1.0);
+       vec3 bitangent = cross(normal, tangent) * attr_Tangent.w;
 #endif
 
 #if defined(USE_LIGHT_VECTOR)
        vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);
 #elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
-       vec3 L = attr_LightDirection * 2.0 - vec3(1.0);
+       vec3 L = attr_LightDirection;
   #if defined(USE_MODELMATRIX)
        L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
   #endif
diff --git a/SP/code/rend2/glsl/pshadow_vp.glsl 
b/SP/code/rend2/glsl/pshadow_vp.glsl
index 0f9940c..07a4985 100644
--- a/SP/code/rend2/glsl/pshadow_vp.glsl
+++ b/SP/code/rend2/glsl/pshadow_vp.glsl
@@ -11,5 +11,5 @@ void main()
        gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
 
        var_Position  = attr_Position;
-       var_Normal    = attr_Normal * 2.0 - vec3(1.0);
+       var_Normal    = attr_Normal;
 }
diff --git a/SP/code/rend2/glsl/shadowfill_vp.glsl 
b/SP/code/rend2/glsl/shadowfill_vp.glsl
index 7a5cc57..7de901b 100644
--- a/SP/code/rend2/glsl/shadowfill_vp.glsl
+++ b/SP/code/rend2/glsl/shadowfill_vp.glsl
@@ -80,7 +80,6 @@ void main()
 {
        vec3 position  = mix(attr_Position, attr_Position2, u_VertexLerp);
        vec3 normal    = mix(attr_Normal,   attr_Normal2,   u_VertexLerp);
-       normal = normalize(normal - vec3(0.5));
 
        position = DeformPosition(position, normal, attr_TexCoord0.st);
 
diff --git a/SP/code/rend2/tr_extensions.c b/SP/code/rend2/tr_extensions.c
index 6ac8f83..b770e6c 100644
--- a/SP/code/rend2/tr_extensions.c
+++ b/SP/code/rend2/tr_extensions.c
@@ -673,11 +673,11 @@ void GLimp_InitExtraExtensions()
 
        // GL_ARB_vertex_type_2_10_10_10_rev
        extension = "GL_ARB_vertex_type_2_10_10_10_rev";
-       glRefConfig.packedNormalDataType = GL_UNSIGNED_BYTE;
+       glRefConfig.packedNormalDataType = GL_BYTE;
        if( GLimp_HaveExtension( extension ) )
        {
                if (r_arb_vertex_type_2_10_10_10_rev->integer)
-                       glRefConfig.packedNormalDataType = 
GL_UNSIGNED_INT_2_10_10_10_REV;
+                       glRefConfig.packedNormalDataType = 
GL_INT_2_10_10_10_REV;
 
                ri.Printf(PRINT_ALL, 
result[r_arb_vertex_type_2_10_10_10_rev->integer ? 1 : 0], extension);
        }
diff --git a/SP/code/rend2/tr_vbo.c b/SP/code/rend2/tr_vbo.c
index 9734c5a..981741f 100644
--- a/SP/code/rend2/tr_vbo.c
+++ b/SP/code/rend2/tr_vbo.c
@@ -23,71 +23,126 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
02110-1301  USA
 #include "tr_local.h"
 
 
+union pack10_u {
+       struct {
+               signed int x:10;
+               signed int y:10;
+               signed int z:10;
+               signed int w:2;
+       } pack;
+       uint32_t i;
+};
+
+union pack8_u {
+       struct {
+               signed int x:8;
+               signed int y:8;
+               signed int z:8;
+               signed int w:8;
+       } pack;
+       uint32_t i;
+};
+
+
 uint32_t R_VaoPackTangent(vec4_t v)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               return (((uint32_t)(v[3] * 1.5f   + 2.0f  )) << 30)
-                    | (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20)
-                    | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10)
-                    | (((uint32_t)(v[0] * 511.5f + 512.0f)));
+               union pack10_u num;
+
+               num.pack.x = v[0] * 511.0f;
+               num.pack.y = v[1] * 511.0f;
+               num.pack.z = v[2] * 511.0f;
+               num.pack.w = v[3];
+
+               return num.i;
        }
        else
        {
-               return (((uint32_t)(v[3] * 127.5f + 128.0f)) << 24)
-                    | (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16)
-                    | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8)
-                    | (((uint32_t)(v[0] * 127.5f + 128.0f)));
+               union pack8_u num;
+
+               num.pack.x = v[0] * 127.0f;
+               num.pack.y = v[1] * 127.0f;
+               num.pack.z = v[2] * 127.0f;
+               num.pack.w = v[3] * 127.0f;
+
+               return num.i;
        }
 }
 
 uint32_t R_VaoPackNormal(vec3_t v)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               return (((uint32_t)(v[2] * 511.5f + 512.0f)) << 20)
-                    | (((uint32_t)(v[1] * 511.5f + 512.0f)) << 10)
-                    | (((uint32_t)(v[0] * 511.5f + 512.0f)));
+               union pack10_u num;
+
+               num.pack.x = v[0] * 511.0f;
+               num.pack.y = v[1] * 511.0f;
+               num.pack.z = v[2] * 511.0f;
+               num.pack.w = 0;
+
+               return num.i;
        }
        else
        {
-               return (((uint32_t)(v[2] * 127.5f + 128.0f)) << 16)
-                    | (((uint32_t)(v[1] * 127.5f + 128.0f)) << 8)
-                    | (((uint32_t)(v[0] * 127.5f + 128.0f)));
+               union pack8_u num;
+
+               num.pack.x = v[0] * 127.0f;
+               num.pack.y = v[1] * 127.0f;
+               num.pack.z = v[2] * 127.0f;
+               num.pack.w = 0;
+
+               return num.i;
        }
 }
 
 void R_VaoUnpackTangent(vec4_t v, uint32_t b)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               v[0] = ((b)       & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[3] = ((b >> 30) & 0x3)   * 1.0f/1.5f   - 1.0f;
+               union pack10_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 511.0f;
+               v[1] = num.pack.y / 511.0f;
+               v[2] = num.pack.z / 511.0f;
+               v[3] = num.pack.w; 
        }
        else
        {
-               v[0] = ((b)       & 0xff) * 1.0f/127.5f - 1.0f;
-               v[1] = ((b >> 8)  & 0xff) * 1.0f/127.5f - 1.0f;
-               v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f;
-               v[3] = ((b >> 24) & 0xff) * 1.0f/127.5f - 1.0f;
+               union pack8_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 127.0f;
+               v[1] = num.pack.y / 127.0f;
+               v[2] = num.pack.z / 127.0f;
+               v[3] = num.pack.w / 127.0f; 
        }
 }
 
 void R_VaoUnpackNormal(vec3_t v, uint32_t b)
 {
-       if (glRefConfig.packedNormalDataType == GL_UNSIGNED_INT_2_10_10_10_REV)
+       if (glRefConfig.packedNormalDataType == GL_INT_2_10_10_10_REV)
        {
-               v[0] = ((b)       & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[1] = ((b >> 10) & 0x3ff) * 1.0f/511.5f - 1.0f;
-               v[2] = ((b >> 20) & 0x3ff) * 1.0f/511.5f - 1.0f;
+               union pack10_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 511.0f;
+               v[1] = num.pack.y / 511.0f;
+               v[2] = num.pack.z / 511.0f;
        }
        else
        {
-               v[0] = ((b)       & 0xff) * 1.0f/127.5f - 1.0f;
-               v[1] = ((b >> 8)  & 0xff) * 1.0f/127.5f - 1.0f;
-               v[2] = ((b >> 16) & 0xff) * 1.0f/127.5f - 1.0f;
+               union pack8_u num;
+
+               num.i = b;
+
+               v[0] = num.pack.x / 127.0f;
+               v[1] = num.pack.y / 127.0f;
+               v[2] = num.pack.z / 127.0f;
        }
 }
 
@@ -651,6 +706,7 @@ void RB_UpdateTessVao(unsigned int attribBits)
        if(tess.numVertexes > 0 && tess.numVertexes <= SHADER_MAX_VERTEXES && 
tess.numIndexes > 0 && tess.numIndexes <= SHADER_MAX_INDEXES)
        {
                int attribIndex;
+               int attribUpload;
 
                R_BindVao(tess.vao);
 
@@ -661,25 +717,29 @@ void RB_UpdateTessVao(unsigned int attribBits)
                if(!(attribBits & ATTR_BITS))
                        attribBits = ATTR_BITS;
 
-               if(attribBits & ATTR_TEXCOORD || attribBits & ATTR_LIGHTCOORD)
+               attribUpload = attribBits;
+
+               if((attribUpload & ATTR_TEXCOORD) || (attribUpload & 
ATTR_LIGHTCOORD))
                {
                        // these are interleaved, so we update both if either 
need it
                        // this translates to updating ATTR_TEXCOORD twice as 
large as it needs
-                       attribBits &= ~ATTR_LIGHTCOORD;
-                       attribBits |= ATTR_TEXCOORD;
+                       attribUpload &= ~ATTR_LIGHTCOORD;
+                       attribUpload |= ATTR_TEXCOORD;
                }
 
                for (attribIndex = 0; attribIndex < ATTR_INDEX_COUNT; 
attribIndex++)
                {
                        uint32_t attribBit = 1 << attribIndex;
+                       vaoAttrib_t *vAtb = &tess.vao->attribs[attribIndex];
 
-                       if (attribBits & attribBit)
+                       if (attribUpload & attribBit)
                        {
-                               vaoAttrib_t *vAtb = 
&tess.vao->attribs[attribIndex];
-
                                // note: tess has a VBO where stride == size
                                qglBufferSubDataARB(GL_ARRAY_BUFFER_ARB, 
vAtb->offset, tess.numVertexes * vAtb->stride, 
tess.attribPointers[attribIndex]);
+                       }
 
+                       if (attribBits & attribBit)
+                       {
                                if (!glRefConfig.vertexArrayObject)
                                        qglVertexAttribPointerARB(attribIndex, 
vAtb->count, vAtb->type, vAtb->normalized, vAtb->stride, 
BUFFER_OFFSET(vAtb->offset));
 

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/iortcw.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to