More GLSL code:
authorMichal Krol <mjkrol@gmail.org>
Tue, 14 Mar 2006 11:23:16 +0000 (11:23 +0000)
committerMichal Krol <mjkrol@gmail.org>
Tue, 14 Mar 2006 11:23:16 +0000 (11:23 +0000)
- add texture sampling support;
- fix assembly codegen bugs;

21 files changed:
src/mesa/main/texstate.c
src/mesa/shader/shaderobjects.c
src/mesa/shader/shaderobjects.h
src/mesa/shader/shaderobjects_3dlabs.c
src/mesa/shader/slang/library/slang_common_builtin.gc
src/mesa/shader/slang/library/slang_common_builtin_gc.h
src/mesa/shader/slang/library/slang_fragment_builtin.gc
src/mesa/shader/slang/library/slang_fragment_builtin_gc.h
src/mesa/shader/slang/library/slang_shader.syn
src/mesa/shader/slang/library/slang_shader_syn.h
src/mesa/shader/slang/slang_analyse.c [new file with mode: 0644]
src/mesa/shader/slang/slang_analyse.h [new file with mode: 0644]
src/mesa/shader/slang/slang_assemble.c
src/mesa/shader/slang/slang_assemble.h
src/mesa/shader/slang/slang_execute.c
src/mesa/shader/slang/slang_execute_x86.c
src/mesa/shader/slang/slang_library_texsample.c [new file with mode: 0644]
src/mesa/shader/slang/slang_library_texsample.h [new file with mode: 0644]
src/mesa/shader/slang/slang_link.c
src/mesa/shader/slang/slang_link.h
windows/VC6/mesa/mesa/mesa.dsp

index 428d0a0d01adae1abb23e8da7d4a859d0c73e709..a8cb8a7bcfa57dcf9900b98ddc10e7bab60e9739 100644 (file)
@@ -39,7 +39,8 @@
 #include "texstate.h"
 #include "texenvprogram.h"
 #include "mtypes.h"
-#include "math/m_xform.h"
+#include "math/m_xform.h"\r
+#include "shaderobjects.h"
 
 
 
@@ -2765,7 +2766,22 @@ update_texture_matrices( GLcontext *ctx )
       }
    }
 }
-
+\r
+\r
+static void\r
+texture_override( struct gl_texture_object *texObj, GLuint textureBit, GLcontext *ctx,\r
+                GLbitfield enableBits, struct gl_texture_unit *texUnit )\r
+{\r
+   if (!texUnit->_ReallyEnabled && (enableBits & textureBit)) {\r
+      if (!texObj->Complete) {\r
+         _mesa_test_texobj_completeness(ctx, texObj);\r
+      }\r
+      if (texObj->Complete) {\r
+         texUnit->_ReallyEnabled = textureBit;\r
+         texUnit->_Current = texObj;\r
+      }\r
+   }\r
+}
 
 /**
  * \note This routine refers to derived texture matrix values to
@@ -2778,7 +2794,9 @@ update_texture_matrices( GLcontext *ctx )
 static void
 update_texture_state( GLcontext *ctx )
 {
-   GLuint unit;
+   GLuint unit;\r
+   struct gl2_program_intf **prog = ctx->ShaderObjects.CurrentProgram;\r
+   GLbitfield progteximageusage[MAX_TEXTURE_IMAGE_UNITS];\r
 
    ctx->NewState |= _NEW_TEXTURE; /* TODO: only set this if there are 
                                   * actual changes. 
@@ -2787,7 +2805,16 @@ update_texture_state( GLcontext *ctx )
    ctx->Texture._EnabledUnits = 0;
    ctx->Texture._GenFlags = 0;
    ctx->Texture._TexMatEnabled = 0;
-   ctx->Texture._TexGenEnabled = 0;
+   ctx->Texture._TexGenEnabled = 0;\r
+\r
+   /*\r
+    * Grab texture image usage state from shader program. It must be grabbed every time\r
+    * uniform sampler changes, so maybe there is a better place to perform these rather\r
+    * expensive computations.\r
+    */\r
+   if (prog != NULL) {\r
+      (**prog).GetTextureImageUsage (prog, progteximageusage);\r
+   }
 
    /* Update texture unit state.
     * XXX this loop should probably be broken into separate loops for
@@ -2801,8 +2828,11 @@ update_texture_state( GLcontext *ctx )
       texUnit->_ReallyEnabled = 0;
       texUnit->_GenFlags = 0;
 
-      /* Get the bitmask of texture enables */
-      if (ctx->FragmentProgram._Enabled) {
+      /* Get the bitmask of texture enables */\r
+      if (prog != NULL) {\r
+         enableBits = progteximageusage[unit];
+      }\r
+      else if (ctx->FragmentProgram._Enabled) {
          enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit];
       }
       else {
@@ -2814,61 +2844,12 @@ update_texture_state( GLcontext *ctx )
       /* Look for the highest-priority texture target that's enabled and
        * complete.  That's the one we'll use for texturing.  If we're using
        * a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
-       */
-      if (enableBits & TEXTURE_CUBE_BIT) {
-         struct gl_texture_object *texObj = texUnit->CurrentCubeMap;
-         if (!texObj->Complete) {
-            _mesa_test_texobj_completeness(ctx, texObj);
-         }
-         if (texObj->Complete) {
-            texUnit->_ReallyEnabled = TEXTURE_CUBE_BIT;
-            texUnit->_Current = texObj;
-         }
-      }
-
-      if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_3D_BIT)) {
-         struct gl_texture_object *texObj = texUnit->Current3D;
-         if (!texObj->Complete) {
-            _mesa_test_texobj_completeness(ctx, texObj);
-         }
-         if (texObj->Complete) {
-            texUnit->_ReallyEnabled = TEXTURE_3D_BIT;
-            texUnit->_Current = texObj;
-         }
-      }
-
-      if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_RECT_BIT)) {
-         struct gl_texture_object *texObj = texUnit->CurrentRect;
-         if (!texObj->Complete) {
-            _mesa_test_texobj_completeness(ctx, texObj);
-         }
-         if (texObj->Complete) {
-            texUnit->_ReallyEnabled = TEXTURE_RECT_BIT;
-            texUnit->_Current = texObj;
-         }
-      }
-
-      if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_2D_BIT)) {
-         struct gl_texture_object *texObj = texUnit->Current2D;
-         if (!texObj->Complete) {
-            _mesa_test_texobj_completeness(ctx, texObj);
-         }
-         if (texObj->Complete) {
-            texUnit->_ReallyEnabled = TEXTURE_2D_BIT;
-            texUnit->_Current = texObj;
-         }
-      }
-
-      if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_1D_BIT)) {
-         struct gl_texture_object *texObj = texUnit->Current1D;
-         if (!texObj->Complete) {
-            _mesa_test_texobj_completeness(ctx, texObj);
-         }
-         if (texObj->Complete) {
-            texUnit->_ReallyEnabled = TEXTURE_1D_BIT;
-            texUnit->_Current = texObj;
-         }
-      }
+       */\r
+      texture_override(texUnit->CurrentCubeMap, TEXTURE_CUBE_BIT, ctx, enableBits, texUnit);\r
+      texture_override(texUnit->Current3D, TEXTURE_3D_BIT, ctx, enableBits, texUnit);
+      texture_override(texUnit->CurrentRect, TEXTURE_RECT_BIT, ctx, enableBits, texUnit);\r
+      texture_override(texUnit->Current2D, TEXTURE_2D_BIT, ctx, enableBits, texUnit);
+      texture_override(texUnit->Current1D, TEXTURE_1D_BIT, ctx, enableBits, texUnit);
 
       if (!texUnit->_ReallyEnabled) {
          continue;
@@ -2967,8 +2948,8 @@ update_texture_state( GLcontext *ctx )
    /* Fragment programs may need texture coordinates but not the
     * corresponding texture images.
     */\r
-   if (ctx->ShaderObjects.CurrentProgram != NULL) {\r
-      ctx->Texture._EnabledCoordUnits |= (1 << 8) - 1;\r
+   if (prog != NULL) {\r
+      ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1;\r
    }
    else if (ctx->FragmentProgram._Enabled) {
       ctx->Texture._EnabledCoordUnits |=
index 4c4fdcfe550705d07f3f5909b45c63d20e155945..ad55b7448c54e55167fdcb72129ee7b310a5c3ed 100644 (file)
@@ -343,34 +343,13 @@ _mesa_ValidateProgramARB (GLhandleARB programObj)
        }
 }
 
-/*
-Errors TODO
-
-    The error INVALID_OPERATION is generated by the Uniform*ARB if the
-    number of values loaded results in exceeding the declared extent of a
-    uniform.
-
-    The error INVALID_OPERATION is generated by the Uniform*ARB commands if
-    the size does not match the size of the uniform declared in the shader.
-
-    The error INVALID_OPERATION is generated by the Uniform*ARB commands if
-    the type does not match the type of the uniform declared in the shader,
-    if the uniform is not of type Boolean.
-
-    The error INVALID_OPERATION is generated by the Uniform*ARB commands if
-    <location> does not exist for the program object currently in use.
-
-    The error INVALID_OPERATION is generated if a uniform command other than
-    Uniform1i{v}ARB is used to load a sampler value.
-
-
-*/
-
 GLvoid GLAPIENTRY
 _mesa_Uniform1fARB (GLint location, GLfloat v0)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -383,7 +362,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform2fARB (GLint location, GLfloat v0, GLfloat v1)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -398,7 +379,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -413,7 +396,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -428,7 +413,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform1iARB (GLint location, GLint v0)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1iARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1iARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -441,7 +428,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform2iARB (GLint location, GLint v0, GLint v1)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2iARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2iARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -456,7 +445,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform3iARB (GLint location, GLint v0, GLint v1, GLint v2)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3iARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3iARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -471,7 +462,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4iARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4iARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -486,7 +479,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform1fvARB (GLint location, GLsizei count, const GLfloat *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fvARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fvARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -499,7 +494,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform2fvARB (GLint location, GLsizei count, const GLfloat *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fvARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fvARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -512,7 +509,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform3fvARB (GLint location, GLsizei count, const GLfloat *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fvARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fvARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -525,7 +524,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform4fvARB (GLint location, GLsizei count, const GLfloat *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fvARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fvARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -538,7 +539,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform1ivARB (GLint location, GLsizei count, const GLint *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1ivARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1ivARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -551,7 +554,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform2ivARB (GLint location, GLsizei count, const GLint *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2ivARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2ivARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -564,7 +569,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform3ivARB (GLint location, GLsizei count, const GLint *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3ivARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3ivARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -577,7 +584,9 @@ GLvoid GLAPIENTRY
 _mesa_Uniform4ivARB (GLint location, GLsizei count, const GLint *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4ivARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4ivARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -590,7 +599,9 @@ GLvoid GLAPIENTRY
 _mesa_UniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix2fvARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix2fvARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -628,7 +639,9 @@ GLvoid GLAPIENTRY
 _mesa_UniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix3fvARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix3fvARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
@@ -671,7 +684,9 @@ GLvoid GLAPIENTRY
 _mesa_UniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
 {
        GET_CURRENT_CONTEXT(ctx);
-       GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix4fvARB");
+       GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix4fvARB");\r
+\r
+       FLUSH_VERTICES(ctx, _NEW_PROGRAM);
 
        if (pro != NULL)
        {
index 5a4667d090a947bcac0833f9d25faf3bc9b3665d..830adddec94066a8fbce2296ab07bf217e7e2720 100644 (file)
@@ -88,9 +88,10 @@ struct gl2_program_intf
    GLvoid (* Validate) (struct gl2_program_intf **);\r
    GLvoid (* UpdateFixedUniforms) (struct gl2_program_intf **);\r
    GLvoid (* UpdateFixedAttribute) (struct gl2_program_intf **, GLuint, GLvoid *, GLuint, GLuint,\r
-          GLboolean);\r
+      GLboolean);\r
    GLvoid (* UpdateFixedVarying) (struct gl2_program_intf **, GLuint, GLvoid *, GLuint, GLuint,\r
-          GLboolean);
+      GLboolean);\r
+   GLvoid (* GetTextureImageUsage) (struct gl2_program_intf **, GLbitfield *);
 };
 
 struct gl2_fragment_shader_intf
index 96f382437d56d0d546799eda051e36a3cb780a93..6d03f426487b320c0e882a417acc7d891b8cc9f6 100755 (executable)
@@ -841,7 +841,7 @@ write_common_fixed (slang_program *pro, GLuint index, const GLvoid *src, GLuint
 {\r
        GLuint i;\r
 \r
-       for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)\r
+       for (i = 0; i < SLANG_SHADER_MAX; i++)\r
        {\r
                GLuint addr;\r
 \r
@@ -965,7 +965,7 @@ _program_UpdateFixedAttribute (struct gl2_program_intf **intf, GLuint index, GLv
        {\r
                GLubyte *mem;\r
 \r
-               mem = (GLubyte *) pro->machines[SLANG_UNIFORM_BINDING_VERTEX]->mem + addr + offset * size;\r
+               mem = (GLubyte *) pro->machines[SLANG_SHADER_VERTEX]->mem + addr + offset * size;\r
                if (write)\r
                        _mesa_memcpy (mem, data, size);\r
                else\r
@@ -986,7 +986,7 @@ _program_UpdateFixedVarying (struct gl2_program_intf **intf, GLuint index, GLvoi
        {\r
                GLubyte *mem;\r
 \r
-               mem = (GLubyte *) pro->machines[SLANG_UNIFORM_BINDING_FRAGMENT]->mem + addr + offset * size;\r
+               mem = (GLubyte *) pro->machines[SLANG_SHADER_FRAGMENT]->mem + addr + offset * size;\r
                if (write)\r
                        _mesa_memcpy (mem, data, size);\r
                else\r
@@ -994,6 +994,58 @@ _program_UpdateFixedVarying (struct gl2_program_intf **intf, GLuint index, GLvoi
        }\r
 }\r
 \r
+static GLvoid\r
+_program_GetTextureImageUsage (struct gl2_program_intf **intf, GLbitfield *teximageusage)\r
+{\r
+       GET_CURRENT_CONTEXT(ctx);\r
+       struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;\r
+       slang_program *pro = &impl->_obj.prog;\r
+       GLuint i;\r
+\r
+       for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++)\r
+               teximageusage[i] = 0;\r
+\r
+       for (i = 0; i < pro->texture_usage.count; i++)\r
+       {\r
+               GLuint n, addr, j;\r
+\r
+               n = pro->texture_usage.table[i].quant->array_len;\r
+               if (n == 0)\r
+                       n = 1;\r
+               addr = pro->texture_usage.table[i].frag_address;\r
+               for (j = 0; j < n; j++)\r
+               {\r
+                       GLubyte *mem;\r
+                       GLuint image;\r
+\r
+                       mem = (GLubyte *) pro->machines[SLANG_SHADER_FRAGMENT]->mem + addr + j * 4;\r
+                       image = (GLuint) *((GLfloat *) mem);\r
+                       if (image >= 0 && image < ctx->Const.MaxTextureImageUnits)\r
+                       {\r
+                               switch (pro->texture_usage.table[i].quant->u.basic_type)\r
+                               {\r
+                               case GL_SAMPLER_1D_ARB:\r
+                               case GL_SAMPLER_1D_SHADOW_ARB:\r
+                                       teximageusage[image] |= TEXTURE_1D_BIT;\r
+                                       break;\r
+                               case GL_SAMPLER_2D_ARB:\r
+                               case GL_SAMPLER_2D_SHADOW_ARB:\r
+                                       teximageusage[image] |= TEXTURE_2D_BIT;\r
+                                       break;\r
+                               case GL_SAMPLER_3D_ARB:\r
+                                       teximageusage[image] |= TEXTURE_3D_BIT;\r
+                                       break;\r
+                               case GL_SAMPLER_CUBE_ARB:\r
+                                       teximageusage[image] |= TEXTURE_CUBE_BIT;\r
+                                       break;\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
+       /* TODO: make sure that for 0<=i<=MaxTextureImageUint bitcount(teximageuint[i])<=0 */\r
+}\r
+\r
 static struct gl2_program_intf _program_vftbl = {\r
        {\r
                {\r
@@ -1019,7 +1071,8 @@ static struct gl2_program_intf _program_vftbl = {
        _program_Validate,\r
        _program_UpdateFixedUniforms,\r
        _program_UpdateFixedAttribute,\r
-       _program_UpdateFixedVarying\r
+       _program_UpdateFixedVarying,\r
+       _program_GetTextureImageUsage\r
 };\r
 \r
 static void\r
@@ -1238,7 +1291,7 @@ int _slang_fetch_discard (struct gl2_program_intf **pro, GLboolean *val)
        struct gl2_program_impl *impl;\r
 \r
        impl = (struct gl2_program_impl *) pro;\r
-       *val = impl->_obj.prog.machines[SLANG_UNIFORM_BINDING_FRAGMENT]->kill ? GL_TRUE : GL_FALSE;\r
+       *val = impl->_obj.prog.machines[SLANG_SHADER_FRAGMENT]->kill ? GL_TRUE : GL_FALSE;\r
        return 1;\r
 }\r
 \r
@@ -1251,19 +1304,19 @@ static GLvoid exec_shader (struct gl2_program_intf **pro, GLuint i)
        p = &impl->_obj.prog;\r
 \r
        slang_machine_init (p->machines[i]);\r
-       p->machines[i]->ip = p->code[i];\r
+       p->machines[i]->ip = p->code[i][SLANG_COMMON_CODE_MAIN];\r
 \r
        _slang_execute2 (p->assemblies[i], p->machines[i]);\r
 }\r
 \r
 GLvoid _slang_exec_fragment_shader (struct gl2_program_intf **pro)\r
 {\r
-       exec_shader (pro, SLANG_UNIFORM_BINDING_FRAGMENT);\r
+       exec_shader (pro, SLANG_SHADER_FRAGMENT);\r
 }\r
 \r
 GLvoid _slang_exec_vertex_shader (struct gl2_program_intf **pro)\r
 {\r
-       exec_shader (pro, SLANG_UNIFORM_BINDING_VERTEX);\r
+       exec_shader (pro, SLANG_SHADER_VERTEX);\r
 }\r
 \r
 GLint _slang_get_uniform_location (struct gl2_program_intf **pro, const char *name)\r
@@ -1287,6 +1340,10 @@ GLboolean _slang_write_uniform (struct gl2_program_intf **pro, GLint loc, GLsize
        slang_uniform_bindings *bind;\r
        slang_uniform_binding *b;\r
        GLuint i;\r
+       GLboolean convert_float_to_bool = GL_FALSE;\r
+       GLboolean convert_int_to_bool = GL_FALSE;\r
+       GLboolean convert_int_to_float = GL_FALSE;\r
+       GLboolean types_match = GL_FALSE;\r
 \r
        if (loc == -1)\r
                return GL_TRUE;\r
@@ -1298,16 +1355,113 @@ GLboolean _slang_write_uniform (struct gl2_program_intf **pro, GLint loc, GLsize
 \r
        b = &bind->table[loc];\r
        /* TODO: check sizes */\r
-       /* TODO: check if not structure */\r
-       if (b->quant->u.basic_type != type)\r
+       if (b->quant->structure != NULL)\r
                return GL_FALSE;\r
 \r
-       for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)\r
-               if (b->address[i] != ~0)\r
-               {\r
-                       _mesa_memcpy (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4], data,\r
-                               count * b->quant->size);\r
-               }\r
+       switch (b->quant->u.basic_type)\r
+       {\r
+       case GL_BOOL_ARB:\r
+               types_match = (type == GL_FLOAT) || (type == GL_INT);\r
+               if (type == GL_FLOAT)\r
+                       convert_float_to_bool = GL_TRUE;\r
+               else\r
+                       convert_int_to_bool = GL_TRUE;\r
+               break;\r
+       case GL_BOOL_VEC2_ARB:\r
+               types_match = (type == GL_FLOAT_VEC2_ARB) || (type == GL_INT_VEC2_ARB);\r
+               if (type == GL_FLOAT_VEC2_ARB)\r
+                       convert_float_to_bool = GL_TRUE;\r
+               else\r
+                       convert_int_to_bool = GL_TRUE;\r
+               break;\r
+       case GL_BOOL_VEC3_ARB:\r
+               types_match = (type == GL_FLOAT_VEC3_ARB) || (type == GL_INT_VEC3_ARB);\r
+               if (type == GL_FLOAT_VEC3_ARB)\r
+                       convert_float_to_bool = GL_TRUE;\r
+               else\r
+                       convert_int_to_bool = GL_TRUE;\r
+               break;\r
+       case GL_BOOL_VEC4_ARB:\r
+               types_match = (type == GL_FLOAT_VEC4_ARB) || (type == GL_INT_VEC4_ARB);\r
+               if (type == GL_FLOAT_VEC4_ARB)\r
+                       convert_float_to_bool = GL_TRUE;\r
+               else\r
+                       convert_int_to_bool = GL_TRUE;\r
+               break;\r
+       case GL_SAMPLER_1D_ARB:\r
+       case GL_SAMPLER_2D_ARB:\r
+       case GL_SAMPLER_3D_ARB:\r
+       case GL_SAMPLER_CUBE_ARB:\r
+       case GL_SAMPLER_1D_SHADOW_ARB:\r
+       case GL_SAMPLER_2D_SHADOW_ARB:\r
+               types_match = (type == GL_INT);\r
+               break;\r
+       default:\r
+               types_match = (type == b->quant->u.basic_type);\r
+               break;\r
+       }\r
+\r
+       if (!types_match)\r
+               return GL_FALSE;\r
+\r
+       switch (type)\r
+       {\r
+       case GL_INT:\r
+       case GL_INT_VEC2_ARB:\r
+       case GL_INT_VEC3_ARB:\r
+       case GL_INT_VEC4_ARB:\r
+               convert_int_to_float = GL_TRUE;\r
+               break;\r
+       }\r
+\r
+       if (convert_float_to_bool)\r
+       {\r
+               for (i = 0; i < SLANG_SHADER_MAX; i++)\r
+                       if (b->address[i] != ~0)\r
+                       {\r
+                               const GLfloat *src = (GLfloat *) (data);\r
+                               GLfloat *dst = (GLfloat *) (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4]);\r
+                               GLuint j;\r
+\r
+                               for (j = 0; j < count * b->quant->size / 4; j++)\r
+                                       dst[j] = src[j] != 0.0f ? 1.0f : 0.0f;\r
+                       }\r
+       }\r
+       else if (convert_int_to_bool)\r
+       {\r
+               for (i = 0; i < SLANG_SHADER_MAX; i++)\r
+                       if (b->address[i] != ~0)\r
+                       {\r
+                               const GLuint *src = (GLuint *) (data);\r
+                               GLfloat *dst = (GLfloat *) (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4]);\r
+                               GLuint j;\r
+\r
+                               for (j = 0; j < count * b->quant->size / 4; j++)\r
+                                       dst[j] = src[j] ? 1.0f : 0.0f;\r
+                       }\r
+       }\r
+       else if (convert_int_to_float)\r
+       {\r
+               for (i = 0; i < SLANG_SHADER_MAX; i++)\r
+                       if (b->address[i] != ~0)\r
+                       {\r
+                               const GLuint *src = (GLuint *) (data);\r
+                               GLfloat *dst = (GLfloat *) (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4]);\r
+                               GLuint j;\r
+\r
+                               for (j = 0; j < count * b->quant->size / 4; j++)\r
+                                       dst[j] = (GLfloat) src[j];\r
+                       }\r
+       }\r
+       else\r
+       {\r
+               for (i = 0; i < SLANG_SHADER_MAX; i++)\r
+                       if (b->address[i] != ~0)\r
+                       {\r
+                               _mesa_memcpy (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4], data,\r
+                                       count * b->quant->size);\r
+                       }\r
+       }\r
        return GL_TRUE;\r
 }\r
 \r
index 4d82d54c14da28b144498630de1647647bc7cfa6..9486f4c83049a0f3cabca41a126e3c3be14b6f44 100755 (executable)
@@ -1,10 +1,27 @@
-
-//
-// TODO:
-// - implement texture1D, texture3D, textureCube,
-// - implement shadow1D, shadow2D,
-//
-
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.5\r
+ *\r
+ * Copyright (C) 2006  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
 //
 // From Shader Spec, ver. 1.10, rev. 59
 //
@@ -1267,8 +1284,9 @@ bvec4 not (bvec4 v) {
 //
 
 vec4 texture1D (sampler1D sampler, float coord) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_tex1d texel, sampler, coord, 0.0;\r
+    return texel;
 }\r
 
 vec4 texture1DProj (sampler1D sampler, vec2 coord) {
@@ -1281,7 +1299,7 @@ vec4 texture1DProj (sampler1D sampler, vec4 coord) {
 
 vec4 texture2D (sampler2D sampler, vec2 coord) {\r
     vec4 texel;\r
-    __asm vec4_tex2d texel, sampler, coord;\r
+    __asm vec4_tex2d texel, sampler, coord, 0.0;\r
     return texel;
 }\r
 
@@ -1294,8 +1312,9 @@ vec4 texture2DProj (sampler2D sampler, vec4 coord) {
 }
 
 vec4 texture3D (sampler3D sampler, vec3 coord) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_tex3d texel, sampler, coord, 0.0;\r
+    return texel;
 }\r
 
 vec4 texture3DProj (sampler3D sampler, vec4 coord) {\r
@@ -1303,22 +1322,25 @@ vec4 texture3DProj (sampler3D sampler, vec4 coord) {
 }
 
 vec4 textureCube (samplerCube sampler, vec3 coord) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_texcube texel, sampler, coord, 0.0;\r
+    return texel;
 }
 
 vec4 shadow1D (sampler1DShadow sampler, vec3 coord) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_shad1d texel, sampler, coord, 0.0;\r
+    return texel;
 }
 
-vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {\r
-    // XXX:
-    return vec4 (0.0);
-}\r
-
 vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord) {\r
-    return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q));
+    return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q));\r
+}\r
+\r
+vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {\r
+    vec4 texel;\r
+    __asm vec4_shad2d texel, sampler, coord, 0.0;\r
+    return texel;
 }\r
 
 vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord) {\r
index 7198e5f94784a53e02c85afdfd9ba21599a58dff..ad4f78eebf4f7d8b07a23eae45958279dc4c3d4a 100644 (file)
 0,56,0,18,118,0,59,121,0,56,0,18,118,0,59,122,0,56,0,0,0,0,1,0,4,0,110,111,116,0,1,0,0,4,118,0,0,0,\r
 1,8,58,98,118,101,99,52,0,18,118,0,59,120,0,56,0,18,118,0,59,121,0,56,0,18,118,0,59,122,0,56,0,18,\r
 118,0,59,119,0,56,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,0,1,0,0,16,115,97,109,112,108,\r
-101,114,0,0,1,0,0,9,99,111,111,114,100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,\r
-0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,\r
-10,99,111,111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,\r
-114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,116,0,49,0,0,0,0,1,0,12,0,116,\r
-101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,\r
-111,111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,\r
-18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,1,0,12,0,116,101,120,\r
-116,117,114,101,50,68,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,0,0,\r
-1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,50,100,0,18,116,101,120,101,\r
-108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,0,8,18,116,101,120,101,108,0,0,\r
-0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,\r
-0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,\r
-108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,112,\r
-0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,0,0,0,1,0,12,0,\r
-116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,\r
-12,99,111,111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,\r
-114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,\r
-18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,12,0,116,101,\r
-120,116,117,114,101,51,68,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,\r
-0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,\r
-114,111,106,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,116,\r
-101,120,116,117,114,101,51,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,\r
-114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,\r
-111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,\r
-49,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,67,117,98,101,0,1,0,0,19,115,97,109,112,108,\r
-101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,\r
-0,115,104,97,100,111,119,49,68,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,\r
-100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,0,1,\r
-0,0,21,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,8,58,118,101,99,52,0,17,\r
-48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,80,114,111,106,0,1,0,0,20,115,97,109,112,\r
-108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,115,104,97,100,111,119,49,68,0,18,115,97,\r
-109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,\r
-0,59,113,0,49,0,17,48,0,48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,\r
-49,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,0,0,21,115,97,109,112,108,\r
-101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,115,104,97,100,111,119,50,68,0,18,115,97,109,\r
-112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,\r
-113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,\r
-114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,9,0,110,111,105,115,101,49,\r
-0,1,0,0,9,120,0,0,0,1,3,2,0,9,1,97,0,0,0,4,102,108,111,97,116,95,110,111,105,115,101,49,0,18,97,0,\r
-0,18,120,0,0,0,8,18,97,0,0,0,1,0,9,0,110,111,105,115,101,49,0,1,0,0,10,120,0,0,0,1,3,2,0,9,1,97,0,\r
-0,0,4,102,108,111,97,116,95,110,111,105,115,101,50,0,18,97,0,0,18,120,0,0,0,8,18,97,0,0,0,1,0,9,0,\r
-110,111,105,115,101,49,0,1,0,0,11,120,0,0,0,1,3,2,0,9,1,97,0,0,0,4,102,108,111,97,116,95,110,111,\r
-105,115,101,51,0,18,97,0,0,18,120,0,0,0,8,18,97,0,0,0,1,0,9,0,110,111,105,115,101,49,0,1,0,0,12,\r
-120,0,0,0,1,3,2,0,9,1,97,0,0,0,4,102,108,111,97,116,95,110,111,105,115,101,52,0,18,97,0,0,18,120,0,\r
-0,0,8,18,97,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,9,120,0,0,0,1,8,58,118,101,99,50,0,58,\r
-110,111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,17,49,57,0,51,52,0,0,\r
-46,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,110,\r
-111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,49,\r
-57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,11,\r
-120,0,0,0,1,8,58,118,101,99,50,0,58,110,111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,\r
-49,0,18,120,0,58,118,101,99,51,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,0,\r
-46,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,50,0,58,110,\r
-111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,49,\r
-57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,0,0,0,0,1,0,\r
-11,0,110,111,105,115,101,51,0,1,0,0,9,120,0,0,0,1,8,58,118,101,99,51,0,58,110,111,105,115,101,49,0,\r
-18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,17,49,57,0,51,52,0,0,46,0,0,0,58,110,111,105,\r
+101,114,0,0,1,0,0,9,99,111,111,114,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,\r
+52,95,116,101,120,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,\r
+111,114,100,0,0,17,48,0,48,0,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,\r
+101,49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,0,\r
+0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,\r
+100,0,59,115,0,18,99,111,111,114,100,0,59,116,0,49,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,\r
+68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,\r
+58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,\r
+59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,0,\r
+1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,0,0,1,3,2,0,12,1,116,101,120,\r
+101,108,0,0,0,4,118,101,99,52,95,116,101,120,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,\r
+108,101,114,0,0,18,99,111,111,114,100,0,0,17,48,0,48,0,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,\r
+0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,\r
+11,99,111,111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,\r
+114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,112,0,49,0,\r
+18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,0,0,0,1,0,12,0,116,101,\r
+120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,\r
+111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,0,58,\r
+118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,\r
+111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,12,0,116,101,120,116,\r
+117,114,101,51,68,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,3,\r
+2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,51,100,0,18,116,101,120,101,108,\r
+0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,17,48,0,48,0,0,0,0,8,18,116,101,\r
+120,101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,0,1,0,0,18,115,97,109,\r
+112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,51,68,0,\r
+18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,\r
+111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,\r
+18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,12,0,116,101,\r
+120,116,117,114,101,67,117,98,101,0,1,0,0,19,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,\r
+114,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,99,117,98,101,\r
+0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,17,48,0,\r
+48,0,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,0,1,0,0,20,115,97,\r
+109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,\r
+118,101,99,52,95,115,104,97,100,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,\r
+0,0,18,99,111,111,114,100,0,0,17,48,0,48,0,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,115,104,\r
+97,100,111,119,49,68,80,114,111,106,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,\r
+114,100,0,0,0,1,8,58,115,104,97,100,111,119,49,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,\r
+99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,17,48,0,48,0,0,0,18,\r
+99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,12,0,115,104,97,\r
+100,111,119,50,68,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,3,\r
+2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,115,104,97,100,50,100,0,18,116,101,120,101,\r
+108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,17,48,0,48,0,0,0,0,8,18,116,\r
+101,120,101,108,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,0,0,21,115,97,109,\r
+112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,115,104,97,100,111,119,50,68,0,18,115,\r
+97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,\r
+100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,\r
+111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,9,0,110,111,105,115,\r
+101,49,0,1,0,0,9,120,0,0,0,1,3,2,0,9,1,97,0,0,0,4,102,108,111,97,116,95,110,111,105,115,101,49,0,\r
+18,97,0,0,18,120,0,0,0,8,18,97,0,0,0,1,0,9,0,110,111,105,115,101,49,0,1,0,0,10,120,0,0,0,1,3,2,0,9,\r
+1,97,0,0,0,4,102,108,111,97,116,95,110,111,105,115,101,50,0,18,97,0,0,18,120,0,0,0,8,18,97,0,0,0,1,\r
+0,9,0,110,111,105,115,101,49,0,1,0,0,11,120,0,0,0,1,3,2,0,9,1,97,0,0,0,4,102,108,111,97,116,95,110,\r
+111,105,115,101,51,0,18,97,0,0,18,120,0,0,0,8,18,97,0,0,0,1,0,9,0,110,111,105,115,101,49,0,1,0,0,\r
+12,120,0,0,0,1,3,2,0,9,1,97,0,0,0,4,102,108,111,97,116,95,110,111,105,115,101,52,0,18,97,0,0,18,\r
+120,0,0,0,8,18,97,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,9,120,0,0,0,1,8,58,118,101,99,50,0,\r
+58,110,111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,17,49,57,0,51,52,0,\r
+0,46,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,\r
+110,111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,50,0,17,\r
+49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,\r
+11,120,0,0,0,1,8,58,118,101,99,50,0,58,110,111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,\r
+101,49,0,18,120,0,58,118,101,99,51,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,\r
+0,0,46,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,50,0,58,\r
+110,111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,58,118,101,99,52,0,17,\r
+49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,17,51,0,50,51,0,0,0,17,50,0,55,55,0,0,0,0,46,0,0,0,0,0,0,1,\r
+0,11,0,110,111,105,115,101,51,0,1,0,0,9,120,0,0,0,1,8,58,118,101,99,51,0,58,110,111,105,115,101,49,\r
+0,18,120,0,0,0,0,58,110,111,105,115,101,49,0,18,120,0,17,49,57,0,51,52,0,0,46,0,0,0,58,110,111,105,\r
 115,101,49,0,18,120,0,17,53,0,52,55,0,0,46,0,0,0,0,0,0,1,0,11,0,110,111,105,115,101,51,0,1,0,0,10,\r
 120,0,0,0,1,8,58,118,101,99,51,0,58,110,111,105,115,101,49,0,18,120,0,0,0,0,58,110,111,105,115,101,\r
 49,0,18,120,0,58,118,101,99,50,0,17,49,57,0,51,52,0,0,0,17,55,0,54,54,0,0,0,0,46,0,0,0,58,110,111,\r
index 776c96db9b0ba3ec683cb5e439616beb279523dc..8b619cd837389918210f0ef0f45199ef7369b372 100755 (executable)
@@ -1,8 +1,29 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.5\r
+ *\r
+ * Copyright (C) 2006  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
 
 //
 // TODO:
-// - implement texture1D, texture2D, texture3D, textureCube,
-// - implement shadow1D, shadow2D,
 // - implement dFdx, dFdy,
 //
 
@@ -26,8 +47,9 @@ varying float gl_FogFragCoord;
 //
 
 vec4 texture1D (sampler1D sampler, float coord, float bias) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_tex1d texel, sampler, coord, bias;\r
+    return texel;
 }\r
 
 vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias) {
@@ -39,8 +61,9 @@ vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias) {
 }
 
 vec4 texture2D (sampler2D sampler, vec2 coord, float bias) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_tex2d texel, sampler, coord, bias;\r
+    return texel;
 }\r
 
 vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias) {\r
@@ -52,8 +75,9 @@ vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias) {
 }
 
 vec4 texture3D (sampler3D sampler, vec3 coord, float bias) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_tex3d texel, sampler, coord, bias;\r
+    return texel;
 }\r
 
 vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {\r
@@ -61,22 +85,25 @@ vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {
 }
 
 vec4 textureCube (samplerCube sampler, vec3 coord, float bias) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_texcube texel, sampler, coord, bias;\r
+    return texel;
 }
 
 vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias) {\r
-    // XXX:
-    return vec4 (0.0);
-}\r
-
-vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {\r
-    // XXX:
-    return vec4 (0.0);
+    vec4 texel;\r
+    __asm vec4_shad1d texel, sampler, coord, bias;\r
+    return texel;
 }\r
 
 vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias) {\r
-    return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), bias);
+    return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), bias);\r
+}\r
+\r
+vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {\r
+    vec4 texel;\r
+    __asm vec4_shad2d texel, sampler, coord, bias;\r
+    return texel;
 }\r
 
 vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias) {\r
index d8202a83ca2f25b6af33ca6e3bd32c910104375a..89d4736f3ebed58fac626b11d3c528fba7653b8a 100644 (file)
 111,114,0,0,0,2,2,3,12,1,103,108,95,84,101,120,67,111,111,114,100,0,3,18,103,108,95,77,97,120,84,\r
 101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,3,9,1,103,108,95,70,111,103,70,114,97,103,\r
 67,111,111,114,100,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,0,1,0,0,16,115,97,109,112,108,\r
-101,114,0,0,1,0,0,9,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,\r
-48,0,48,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,115,97,\r
-109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,\r
-120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,\r
-99,111,111,114,100,0,59,116,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,\r
-49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,\r
-0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,\r
-0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,98,105,97,115,0,0,0,0,\r
-0,1,0,12,0,116,101,120,116,117,114,101,50,68,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,\r
-111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,\r
-12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,\r
-0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,\r
-0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,\r
-111,114,100,0,59,112,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,\r
-0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,\r
-17,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,\r
-58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,\r
-111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,\r
-18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,\r
-114,101,51,68,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,\r
-105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,\r
-101,51,68,80,114,111,106,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,\r
-1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,51,68,0,18,115,97,109,112,108,101,\r
-114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,\r
-18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,\r
-112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,\r
-116,117,114,101,67,117,98,101,0,1,0,0,19,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,\r
-100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,\r
-97,100,111,119,49,68,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,\r
-0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,\r
-119,50,68,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,\r
-97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,\r
-80,114,111,106,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,\r
-98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,49,68,0,18,115,97,109,112,108,101,114,0,0,58,118,\r
-101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,17,48,0,48,0,0,\r
-0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,0,\r
-0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,0,0,21,115,97,109,112,108,101,114,0,\r
-0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,50,68,\r
-0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,\r
-111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,\r
-18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,0,0,\r
-0,0,1,0,9,0,100,70,100,120,0,1,0,0,9,112,0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,100,70,100,120,0,1,\r
-0,0,10,112,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,0,0,0,0,0,0,1,0,11,0,100,70,100,120,0,1,0,0,11,\r
-112,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,100,70,100,120,0,1,0,0,12,112,0,0,\r
-0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,9,0,100,70,100,121,0,1,0,0,9,112,0,0,0,1,8,17,\r
-48,0,48,0,0,0,0,1,0,10,0,100,70,100,121,0,1,0,0,10,112,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,0,0,\r
-0,0,0,0,1,0,11,0,100,70,100,121,0,1,0,0,11,112,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,0,0,\r
-1,0,12,0,100,70,100,121,0,1,0,0,12,112,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,9,0,\r
-102,119,105,100,116,104,0,1,0,0,9,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,\r
-0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,10,0,102,119,105,100,116,104,0,1,\r
-0,0,10,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,\r
-100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,11,0,102,119,105,100,116,104,0,1,0,0,11,112,0,0,0,1,8,58,97,\r
-98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,\r
-46,0,0,1,0,12,0,102,119,105,100,116,104,0,1,0,0,12,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,\r
-0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,0\r
+101,114,0,0,1,0,0,9,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,\r
+101,108,0,0,0,4,118,101,99,52,95,116,101,120,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,\r
+108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,\r
+0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,\r
+1,0,0,10,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,49,\r
+68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,\r
+116,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,\r
+1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,\r
+0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,\r
+100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,\r
+120,116,117,114,101,50,68,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,\r
+0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,\r
+120,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,\r
+0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,\r
+80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,\r
+98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,0,\r
+58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,112,0,49,0,18,99,\r
+111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,\r
+0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,101,114,0,0,\r
+1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,\r
+68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,\r
+111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,\r
+49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,0,1,0,0,18,115,97,\r
+109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,\r
+116,101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,51,100,0,18,116,101,120,101,108,0,0,18,\r
+115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,\r
+101,108,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,0,1,0,0,18,115,97,109,112,\r
+108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,\r
+117,114,101,51,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,\r
+59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,\r
+100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,\r
+98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,67,117,98,101,0,1,0,0,19,115,97,109,\r
+112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,\r
+101,120,101,108,0,0,0,4,118,101,99,52,95,116,101,120,99,117,98,101,0,18,116,101,120,101,108,0,0,18,\r
+115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,\r
+101,108,0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,\r
+0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,101,108,0,0,0,4,\r
+118,101,99,52,95,115,104,97,100,49,100,0,18,116,101,120,101,108,0,0,18,115,97,109,112,108,101,114,\r
+0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,0,1,0,12,0,115,\r
+104,97,100,111,119,49,68,80,114,111,106,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,\r
+111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,49,68,0,18,115,97,109,\r
+112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,\r
+113,0,49,0,17,48,0,48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,\r
+0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,0,1,0,0,21,115,97,109,112,108,\r
+101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,3,2,0,12,1,116,101,120,\r
+101,108,0,0,0,4,118,101,99,52,95,115,104,97,100,50,100,0,18,116,101,120,101,108,0,0,18,115,97,109,\r
+112,108,101,114,0,0,18,99,111,111,114,100,0,0,18,98,105,97,115,0,0,0,8,18,116,101,120,101,108,0,0,\r
+0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,\r
+0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,100,111,119,50,68,0,18,\r
+115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,\r
+114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,\r
+99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,\r
+1,0,9,0,100,70,100,120,0,1,0,0,9,112,0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,100,70,100,120,0,1,0,0,\r
+10,112,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,0,0,0,0,0,0,1,0,11,0,100,70,100,120,0,1,0,0,11,112,\r
+0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,100,70,100,120,0,1,0,0,12,112,0,0,0,1,\r
+8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,9,0,100,70,100,121,0,1,0,0,9,112,0,0,0,1,8,17,48,0,\r
+48,0,0,0,0,1,0,10,0,100,70,100,121,0,1,0,0,10,112,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,0,0,0,0,\r
+0,0,1,0,11,0,100,70,100,121,0,1,0,0,11,112,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,0,0,1,0,\r
+12,0,100,70,100,121,0,1,0,0,12,112,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,9,0,102,\r
+119,105,100,116,104,0,1,0,0,9,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,\r
+97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,10,0,102,119,105,100,116,104,0,1,0,0,\r
+10,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,\r
+121,0,18,112,0,0,0,0,0,46,0,0,1,0,11,0,102,119,105,100,116,104,0,1,0,0,11,112,0,0,0,1,8,58,97,98,\r
+115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,\r
+0,0,1,0,12,0,102,119,105,100,116,104,0,1,0,0,12,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,\r
+18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,0\r
index aeb3c6112c2a7bd0e77c7a20817e34921e1c7988..36d073e88a83a8e13505c85187bb644af2f9d0ac 100644 (file)
@@ -1168,16 +1168,26 @@ __asm_statement
     "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;\r
 \r
 /*\r
-    <asm_arguments>                     ::= <identifier>\r
-                                          | <asm_arguments> "," <identifier>\r
+    <asm_arguments>                     ::= <asm_argument>\r
+                                          | <asm_arguments> "," <asm_argument>\r
 \r
 note: this is an extension to the standard language specification - normally slang disallows\r
       __asm statements\r
 */\r
 asm_arguments\r
-    variable_identifier .and .true .emit OP_END .and .loop asm_arguments_1;\r
+    asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;\r
 asm_arguments_1\r
-    comma .and variable_identifier .and .true .emit OP_END;\r
+    comma .and asm_argument .and .true .emit OP_END;\r
+\r
+/*\r
+    <asm_argument>                      ::= <variable_identifier>\r
+                                          | <floatconstant>\r
+\r
+note: this is an extension to the standard language specification - normally slang disallows\r
+      __asm statements\r
+*/\r
+asm_argument\r
+    variable_identifier .or floatconstant;\r
 \r
 /*\r
     <translation_unit>                  ::= <external_declaration>\r
index 3f13b2583a3caa48e7ba38a3b344f4b13b08cba9..5a94d99d439977f6601610403066ee262a13753e 100644 (file)
 "__asm_statement\n"\r
 " \"__asm\" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;\n"\r
 "asm_arguments\n"\r
-" variable_identifier .and .true .emit OP_END .and .loop asm_arguments_1;\n"\r
+" asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;\n"\r
 "asm_arguments_1\n"\r
-" comma .and variable_identifier .and .true .emit OP_END;\n"\r
+" comma .and asm_argument .and .true .emit OP_END;\n"\r
+"asm_argument\n"\r
+" variable_identifier .or floatconstant;\n"\r
 "translation_unit\n"\r
 " optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and\n"\r
 " .loop external_declaration .and optional_space .and\n"\r
 " '\\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;\n"\r
 "err_identifier\n"\r
 " id_character_first .and .loop id_character_next;\n"\r
-""\r
+""
\ No newline at end of file
diff --git a/src/mesa/shader/slang/slang_analyse.c b/src/mesa/shader/slang/slang_analyse.c
new file mode 100644 (file)
index 0000000..164dbec
--- /dev/null
@@ -0,0 +1,100 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.5\r
+ *\r
+ * Copyright (C) 2006  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/**\r
+ * \file slang_analyse.c\r
+ * slang assembly code analysis\r
+ * \author Michal Krol\r
+ */\r
+\r
+#include "imports.h"\r
+#include "slang_analyse.h"\r
+#include "slang_utility.h"\r
+\r
+GLboolean _slang_analyse_texture_usage (slang_program *prog)\r
+{\r
+       GLuint i, count = 0;\r
+\r
+       slang_texture_usages_dtr (&prog->texture_usage);\r
+       slang_texture_usages_ctr (&prog->texture_usage);\r
+\r
+       /*\r
+        * We could do a full code analysis to find out which uniforms are actually used.\r
+        * For now, we are very conservative and extract them from uniform binding table, which\r
+        * in turn also do not come from code analysis.\r
+        */\r
+\r
+       for (i = 0; i < prog->uniforms.count; i++)\r
+       {\r
+               slang_uniform_binding *b = &prog->uniforms.table[i];\r
+\r
+               if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && b->quant->structure == NULL)\r
+               {\r
+                       switch (b->quant->u.basic_type)\r
+                       {\r
+                       case GL_SAMPLER_1D_ARB:\r
+                       case GL_SAMPLER_2D_ARB:\r
+                       case GL_SAMPLER_3D_ARB:\r
+                       case GL_SAMPLER_CUBE_ARB:\r
+                       case GL_SAMPLER_1D_SHADOW_ARB:\r
+                       case GL_SAMPLER_2D_SHADOW_ARB:\r
+                               count++;\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
+\r
+       if (count == 0)\r
+               return GL_TRUE;\r
+       prog->texture_usage.table = (slang_texture_usage *) slang_alloc_malloc (\r
+               count * sizeof (slang_texture_usage));\r
+       if (prog->texture_usage.table == NULL)\r
+               return GL_FALSE;\r
+       prog->texture_usage.count = count;\r
+\r
+       for (count = i = 0; i < prog->uniforms.count; i++)\r
+       {\r
+               slang_uniform_binding *b = &prog->uniforms.table[i];\r
+\r
+               if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && b->quant->structure == NULL)\r
+               {\r
+                       switch (b->quant->u.basic_type)\r
+                       {\r
+                       case GL_SAMPLER_1D_ARB:\r
+                       case GL_SAMPLER_2D_ARB:\r
+                       case GL_SAMPLER_3D_ARB:\r
+                       case GL_SAMPLER_CUBE_ARB:\r
+                       case GL_SAMPLER_1D_SHADOW_ARB:\r
+                       case GL_SAMPLER_2D_SHADOW_ARB:\r
+                               prog->texture_usage.table[count].quant = b->quant;\r
+                               prog->texture_usage.table[count].frag_address = b->address[SLANG_SHADER_FRAGMENT];\r
+                               count++;\r
+                               break;\r
+                       }\r
+               }\r
+       }\r
+\r
+       return GL_TRUE;\r
+}\r
+\r
diff --git a/src/mesa/shader/slang/slang_analyse.h b/src/mesa/shader/slang/slang_analyse.h
new file mode 100644 (file)
index 0000000..89814b3
--- /dev/null
@@ -0,0 +1,50 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.5\r
+ *\r
+ * Copyright (C) 2006  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+#if !defined SLANG_ANALYSE_H\r
+#define SLANG_ANALYSE_H\r
+\r
+#include "slang_link.h"\r
+\r
+#if defined __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/*\r
+ * Texture usage analysis is a bit more difficult than for fragment programs. While fragment\r
+ * programs statically link to texture targets and texture units, shaders statically link\r
+ * only to texture targets. The texture unit linkage is determined just before the execution\r
+ * of a given primitive by reading active uniform samplers.\r
+ *\r
+ * This procedure retrieves a list of uniforms that reach texture sample instructions.\r
+ */\r
+\r
+GLboolean _slang_analyse_texture_usage (slang_program *);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
index b24d3183841042c11ec2fc1ab6519259104b8ce3..faa13b33e69336bd0ac60b37686fce2cc6c27a59 100644 (file)
@@ -644,7 +644,12 @@ static const struct
        { "float_noise3",   slang_asm_float_noise3,   slang_asm_float_copy },\r
        { "float_noise4",   slang_asm_float_noise4,   slang_asm_float_copy },\r
        { "int_to_float",   slang_asm_int_to_float,   slang_asm_float_copy },\r
+       { "vec4_tex1d",     slang_asm_vec4_tex1d,     slang_asm_none },\r
        { "vec4_tex2d",     slang_asm_vec4_tex2d,     slang_asm_none },\r
+       { "vec4_tex3d",     slang_asm_vec4_tex3d,     slang_asm_none },\r
+       { "vec4_texcube",   slang_asm_vec4_texcube,   slang_asm_none },\r
+       { "vec4_shad1d",    slang_asm_vec4_shad1d,    slang_asm_none },\r
+       { "vec4_shad2d",    slang_asm_vec4_shad2d,    slang_asm_none },\r
        /* mesa-specific extensions */\r
        { "float_print",    slang_asm_float_deref,    slang_asm_float_print },\r
        { "int_print",      slang_asm_int_deref,      slang_asm_int_print },\r
@@ -930,7 +935,9 @@ static GLboolean handle_field (slang_assemble_ctx *A, slang_assembly_typeinfo *t
        else\r
        {\r
                GLuint i, struct_size = 0, field_offset = 0, field_size = 0;\r
+               GLboolean relocate, shrink;\r
 \r
+               /* calculate struct size, field offset and field size */\r
                for (i = 0; i < tib->spec._struct->fields->num_variables; i++)\r
                {\r
                        slang_variable *field;\r
@@ -960,28 +967,56 @@ static GLboolean handle_field (slang_assemble_ctx *A, slang_assembly_typeinfo *t
                                field_offset += size;\r
                }\r
 \r
-               if (!PLAB (A->file, slang_asm_addr_push, field_offset))\r
-                       return GL_FALSE;\r
+               /*\r
+                * OPTIMIZATION: If selecting the last field, no relocation is needed.\r
+                */\r
+               relocate = field_offset != struct_size - field_size;\r
 \r
-               if (ref == slang_ref_force)\r
+               /*\r
+                * OPTIMIZATION: If field and struct sizes are equal, no partial free is needed.\r
+                */\r
+               shrink = field_size != struct_size;\r
+\r
+               if (relocate)\r
                {\r
-                       if (!PUSH (A->file, slang_asm_addr_add))\r
+                       if (!PLAB (A->file, slang_asm_addr_push, field_offset))\r
                                return GL_FALSE;\r
                }\r
+\r
+               if (ref == slang_ref_force)\r
+               {\r
+                       if (relocate)\r
+                       {\r
+                               if (!PUSH (A->file, slang_asm_addr_add))\r
+                                       return GL_FALSE;\r
+                       }\r
+               }\r
                else\r
                {\r
-                       GLuint i;\r
+                       GLuint free_b = 0;\r
 \r
-                       /* move the selected element to the beginning of the master expression */\r
-                       for (i = 0; i < field_size; i += 4)\r
-                               if (!PLAB2 (A->file, slang_asm_float_move, struct_size - field_size + i + 4, i + 4))\r
-                                       return GL_FALSE;\r
-                       if (!PLAB (A->file, slang_asm_local_free, 4))\r
-                               return GL_FALSE;\r
+                       if (relocate)\r
+                       {\r
+                               GLuint i;\r
 \r
-                       /* free the rest of the master expression */\r
-                       if (!PLAB (A->file, slang_asm_local_free, struct_size - field_size))\r
-                               return GL_FALSE;\r
+                               /* move the selected element to the beginning of the master expression */\r
+                               for (i = 0; i < field_size; i += 4)\r
+                                       if (!PLAB2 (A->file, slang_asm_float_move, struct_size - field_size + i + 4, i + 4))\r
+                                               return GL_FALSE;\r
+                               free_b += 4;\r
+                       }\r
+\r
+                       if (shrink)\r
+                       {\r
+                               /* free the rest of the master expression */\r
+                               free_b += struct_size - field_size;\r
+                       }\r
+\r
+                       if (free_b)\r
+                       {\r
+                               if (!PLAB (A->file, slang_asm_local_free, free_b))\r
+                                       return GL_FALSE;\r
+                       }\r
                }\r
        }\r
 \r
@@ -1173,14 +1208,17 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
        case slang_oper_addassign:\r
                if (!_slang_assemble_assign (A, op, "+=", ref))\r
                        return GL_FALSE;\r
+               A->ref = ref;\r
                break;\r
        case slang_oper_subassign:\r
                if (!_slang_assemble_assign (A, op, "-=", ref))\r
                        return GL_FALSE;\r
+               A->ref = ref;\r
                break;\r
        case slang_oper_mulassign:\r
                if (!_slang_assemble_assign (A, op, "*=", ref))\r
                        return GL_FALSE;\r
+               A->ref = ref;\r
                break;\r
        /*case slang_oper_modassign:*/\r
        /*case slang_oper_lshassign:*/\r
@@ -1191,6 +1229,7 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
        case slang_oper_divassign:\r
                if (!_slang_assemble_assign (A, op, "/=", ref))\r
                        return GL_FALSE;\r
+               A->ref = ref;\r
                break;\r
        case slang_oper_select:\r
                if (!_slang_assemble_select (A, op))\r
@@ -1279,10 +1318,12 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
        case slang_oper_preincrement:\r
                if (!_slang_assemble_assign (A, op, "++", ref))\r
                        return GL_FALSE;\r
+               A->ref = ref;\r
                break;\r
        case slang_oper_predecrement:\r
                if (!_slang_assemble_assign (A, op, "--", ref))\r
                        return GL_FALSE;\r
+               A->ref = ref;\r
                break;\r
        case slang_oper_plus:\r
                if (!_slang_dereference (A, op))\r
index ed1005454f2efc6cab1f12ea60ea722840c78bb5..0cde845f854c2fd51c1a519a62b71179ed431749 100644 (file)
@@ -75,7 +75,12 @@ typedef enum slang_assembly_type_
        slang_asm_addr_deref,\r
        slang_asm_addr_add,\r
        slang_asm_addr_multiply,\r
+       slang_asm_vec4_tex1d,\r
        slang_asm_vec4_tex2d,\r
+       slang_asm_vec4_tex3d,\r
+       slang_asm_vec4_texcube,\r
+       slang_asm_vec4_shad1d,\r
+       slang_asm_vec4_shad2d,\r
        slang_asm_jump,\r
        slang_asm_jump_if_zero,\r
        slang_asm_enter,\r
index 0714ddff0d99ef8540839f06de4929b2b043b201..bed63d1e5b0667ae6c7246ccdd9377f9075a6a05 100644 (file)
  */\r
 \r
 #include "imports.h"\r
-#include "context.h"\r
-#include "swrast/s_context.h"\r
-#include "colormac.h"\r
 #include "slang_execute.h"\r
 #include "slang_library_noise.h"\r
+#include "slang_library_texsample.h"\r
 \r
 #define DEBUG_SLANG 0\r
 \r
@@ -48,7 +46,8 @@ GLvoid slang_machine_ctr (slang_machine *self)
 GLvoid slang_machine_dtr (slang_machine *self)\r
 {\r
 #if defined(USE_X86_ASM) || defined(SLANG_X86)\r
-       /* TODO: free self->x86.compiled_func */\r
+       if (self->x86.compiled_func != NULL)\r
+               _mesa_exec_free (self->x86.compiled_func);\r
 #endif\r
 }\r
 \r
@@ -195,9 +194,24 @@ static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
        case slang_asm_addr_multiply:\r
                fprintf (f, "addr_multiply");\r
                break;\r
-       case slang_vec4_tex2d:\r
+       case slang_asm_vec4_tex1d:\r
+               fprintf (f, "vec4_tex1d");\r
+               break;\r
+       case slang_asm_vec4_tex2d:\r
                fprintf (f, "vec4_tex2d");\r
                break;\r
+       case slang_asm_vec4_tex3d:\r
+               fprintf (f, "vec4_tex3d");\r
+               break;\r
+       case slang_asm_vec4_texcube:\r
+               fprintf (f, "vec4_texcube");\r
+               break;\r
+       case slang_asm_vec4_shad1d:\r
+               fprintf (f, "vec4_shad1d");\r
+               break;\r
+       case slang_asm_vec4_shad2d:\r
+               fprintf (f, "vec4_shad2d");\r
+               break;\r
        case slang_asm_jump:\r
                fprintf (f, "jump\t%u", a->param[0]);\r
                break;\r
@@ -272,21 +286,6 @@ static void dump (const slang_assembly_file *file)
 \r
 #endif\r
 \r
-static void fetch_texel (GLuint sampler, const GLfloat texcoord[4], GLfloat lambda, GLfloat color[4])\r
-{\r
-       GET_CURRENT_CONTEXT(ctx);\r
-       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
-       GLchan rgba[4];\r
-\r
-       /* XXX: the function pointer is NULL! */\r
-       swrast->TextureSample[sampler] (ctx, ctx->Texture.Unit[sampler]._Current, 1,\r
-               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
-       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
-       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
-       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
-       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
-}\r
-\r
 int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)\r
 {\r
        slang_machine_slot *stack;\r
@@ -465,16 +464,41 @@ int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)
                        stack[mach->sp + 1]._addr *= stack[mach->sp]._addr;\r
                        mach->sp++;\r
                        break;\r
-               case slang_asm_vec4_tex2d:\r
-                       {\r
-                               GLfloat st[4] = { stack[mach->sp]._float, stack[mach->sp + 1]._float, 0.0f, 1.0f };\r
-                               GLuint sampler = (GLuint) stack[mach->sp + 2]._float;\r
-                               GLfloat *rgba = &mach->mem[stack[mach->sp + 3]._addr / 4]._float;\r
-\r
-                               fetch_texel (sampler, st, 0.0f, rgba);\r
-                       }\r
+               case slang_asm_vec4_tex1d:\r
+                       _slang_library_tex1d (stack[mach->sp]._float, stack[mach->sp + 1]._float,\r
+                               stack[mach->sp + 2]._float, &mach->mem[stack[mach->sp + 3]._addr / 4]._float);\r
                        mach->sp += 3;\r
                        break;\r
+               case slang_asm_vec4_tex2d:\r
+                       _slang_library_tex2d (stack[mach->sp]._float, stack[mach->sp + 1]._float,\r
+                               stack[mach->sp + 2]._float, stack[mach->sp + 3]._float,\r
+                               &mach->mem[stack[mach->sp + 4]._addr / 4]._float);\r
+                       mach->sp += 4;\r
+                       break;\r
+               case slang_asm_vec4_tex3d:\r
+                       _slang_library_tex3d (stack[mach->sp]._float, stack[mach->sp + 1]._float,\r
+                               stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,\r
+                               &mach->mem[stack[mach->sp + 5]._addr / 4]._float);\r
+                       mach->sp += 5;\r
+                       break;\r
+               case slang_asm_vec4_texcube:\r
+                       _slang_library_texcube (stack[mach->sp]._float, stack[mach->sp + 1]._float,\r
+                               stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,\r
+                               &mach->mem[stack[mach->sp + 5]._addr / 4]._float);\r
+                       mach->sp += 5;\r
+                       break;\r
+               case slang_asm_vec4_shad1d:\r
+                       _slang_library_shad1d (stack[mach->sp]._float, stack[mach->sp + 1]._float,\r
+                               stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,\r
+                               &mach->mem[stack[mach->sp + 5]._addr / 4]._float);\r
+                       mach->sp += 5;\r
+                       break;\r
+               case slang_asm_vec4_shad2d:\r
+                       _slang_library_shad2d (stack[mach->sp]._float, stack[mach->sp + 1]._float,\r
+                               stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,\r
+                               &mach->mem[stack[mach->sp + 5]._addr / 4]._float);\r
+                       mach->sp += 5;\r
+                       break;\r
                case slang_asm_jump:\r
                        mach->ip = a->param[0];\r
                        break;\r
index d639563239019039e0070fffb4a7fcbc4c5e47a0..781aeb97db305b5856030cb3a6a4ba7c24a329f3 100644 (file)
@@ -2,7 +2,7 @@
  * Mesa 3-D graphics library\r
  * Version:  6.5\r
  *\r
- * Copyright (C) 2005-2006  Brian Paul   All Rights Reserved.\r
+ * Copyright (C) 2006  Brian Paul   All Rights Reserved.\r
  *\r
  * Permission is hereby granted, free of charge, to any person obtaining a\r
  * copy of this software and associated documentation files (the "Software"),\r
  */\r
 \r
 #include "imports.h"\r
-#include "context.h"\r
-#include "colormac.h"\r
-#include "swrast/s_context.h"\r
 #include "slang_execute.h"\r
 #include "slang_library_noise.h"\r
+#include "slang_library_texsample.h"\r
 \r
 #if defined(USE_X86_ASM) || defined(SLANG_X86)\r
 \r
@@ -114,28 +112,6 @@ static GLfloat do_ceilf (GLfloat x)
        return CEILF (x);\r
 }\r
 \r
-static void fetch_texel (GLuint sampler, const GLfloat texcoord[4], GLfloat lambda, GLfloat color[4])\r
-{\r
-       GET_CURRENT_CONTEXT(ctx);\r
-       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
-       GLchan rgba[4];\r
-\r
-       /* XXX: the function pointer is NULL! */\r
-       swrast->TextureSample[sampler] (ctx, ctx->Texture.Unit[sampler]._Current, 1,\r
-               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
-       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
-       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
-       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
-       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
-}\r
-\r
-static GLvoid do_vec4_tex2d (GLfloat s, GLfloat t, GLuint sampler, GLfloat *rgba)\r
-{\r
-       GLfloat st[4] = { s, t, 0.0f, 1.0f };\r
-\r
-       fetch_texel (sampler, st, 0.0f, rgba);\r
-}\r
-\r
 static GLvoid do_print_float (GLfloat x)\r
 {\r
        _mesa_printf ("slang print: %f\n", x);\r
@@ -373,9 +349,29 @@ static GLvoid codegen_assem (codegen_ctx *G, slang_assembly *a)
                x86_mul (&G->f, G->r_ecx);\r
                x86_mov (&G->f, x86_deref (G->r_esp), G->r_eax);\r
                break;\r
+       case slang_asm_vec4_tex1d:\r
+               x86_call (&G->f, (GLubyte *) _slang_library_tex1d);\r
+               x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 12));\r
+               break;\r
        case slang_asm_vec4_tex2d:\r
-               x86_call (&G->f, (GLubyte *) do_vec4_tex2d);\r
-               x86_lea (&G->f, G->r_ebp, x86_make_disp (G->r_esp, 12));\r
+               x86_call (&G->f, (GLubyte *) _slang_library_tex2d);\r
+               x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 16));\r
+               break;\r
+       case slang_asm_vec4_tex3d:\r
+               x86_call (&G->f, (GLubyte *) _slang_library_tex3d);\r
+               x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));\r
+               break;\r
+       case slang_asm_vec4_texcube:\r
+               x86_call (&G->f, (GLubyte *) _slang_library_texcube);\r
+               x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));\r
+               break;\r
+       case slang_asm_vec4_shad1d:\r
+               x86_call (&G->f, (GLubyte *) _slang_library_shad1d);\r
+               x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));\r
+               break;\r
+       case slang_asm_vec4_shad2d:\r
+               x86_call (&G->f, (GLubyte *) _slang_library_shad2d);\r
+               x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));\r
                break;\r
        case slang_asm_jump:\r
                add_fixup (G, a->param[0], x86_jmp_forward (&G->f));\r
@@ -460,7 +456,13 @@ GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GL
        GLubyte *j_body, *j_exit;\r
        GLuint i;\r
 \r
-       x86_init_func_size (&G.f, 4*1048576);\r
+       /*\r
+        * We need as much as 1M because *all* assembly, including built-in library, is\r
+        * being translated to x86.\r
+        * The built-in library occupies 450K, so we can be safe for now.\r
+        * It is going to change in the future, when we get assembly analysis running.\r
+        */\r
+       x86_init_func_size (&G.f, 1048576);\r
        G.r_eax = x86_make_reg (file_REG32, reg_AX);\r
        G.r_ecx = x86_make_reg (file_REG32, reg_CX);\r
        G.r_edx = x86_make_reg (file_REG32, reg_DX);\r
@@ -487,7 +489,7 @@ GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GL
        x86_mov (&G.f, x86_deref (G.r_eax), G.r_ecx);\r
        j_body = x86_jmp_forward (&G.f);\r
 \r
-       /* discard keywords go here */\r
+       /* "discard" instructions jump to this label */\r
        G.l_discard = x86_get_label (&G.f);\r
        x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &G.mach->kill);\r
        x86_mov_reg_imm (&G.f, G.r_ecx, 1);\r
@@ -503,7 +505,11 @@ GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GL
                codegen_assem (&G, &file->code[i]);\r
        }\r
 \r
-       /* restore stack and return */\r
+       /*\r
+        * Restore stack and return.\r
+        * This must be handled this way, because "discard" can be invoked from any\r
+        * place in the code.\r
+        */\r
        x86_fixup_fwd_jump (&G.f, j_exit);\r
        x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &mach->x86.esp_restore);\r
        x86_mov (&G.f, G.r_esp, x86_deref (G.r_eax));\r
@@ -526,7 +532,9 @@ GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GL
        slang_alloc_free (G.fixups);\r
        slang_alloc_free (G.labels);\r
 \r
-       /* TODO: free previous instance, if not NULL */\r
+       /* install new code */\r
+       if (mach->x86.compiled_func != NULL)\r
+               _mesa_exec_free (mach->x86.compiled_func);\r
        mach->x86.compiled_func = (GLvoid (*) (slang_machine *)) x86_get_func (&G.f);\r
 \r
        return GL_TRUE;\r
diff --git a/src/mesa/shader/slang/slang_library_texsample.c b/src/mesa/shader/slang/slang_library_texsample.c
new file mode 100644 (file)
index 0000000..d26b767
--- /dev/null
@@ -0,0 +1,142 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.5\r
+ *\r
+ * Copyright (C) 2006  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+/**\r
+ * \file slang_library_texsample.c\r
+ * built-in library functions for texture and shadow sampling\r
+ * \author Michal Krol\r
+ */\r
+\r
+#include "imports.h"\r
+#include "context.h"\r
+#include "colormac.h"\r
+#include "swrast/s_context.h"\r
+#include "slang_library_texsample.h"\r
+\r
+GLvoid _slang_library_tex1d (GLfloat bias, GLfloat s, GLfloat sampler, GLfloat *color)\r
+{\r
+       GET_CURRENT_CONTEXT(ctx);\r
+       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+       GLuint unit = (GLuint) sampler;\r
+       GLfloat texcoord[4] = { s, 0.0f, 0.0f, 1.0f };\r
+       GLfloat lambda = bias;\r
+       GLchan rgba[4];\r
+\r
+       swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,\r
+               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
+       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
+       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
+       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
+       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
+}\r
+\r
+GLvoid _slang_library_tex2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat sampler, GLfloat *color)\r
+{\r
+       GET_CURRENT_CONTEXT(ctx);\r
+       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+       GLuint unit = (GLuint) sampler;\r
+       GLfloat texcoord[4] = { s, t, 0.0f, 1.0f };\r
+       GLfloat lambda = bias;\r
+       GLchan rgba[4];\r
+\r
+       swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,\r
+               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
+       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
+       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
+       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
+       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
+}\r
+\r
+GLvoid _slang_library_tex3d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,\r
+       GLfloat *color)\r
+{\r
+       GET_CURRENT_CONTEXT(ctx);\r
+       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+       GLuint unit = (GLuint) sampler;\r
+       GLfloat texcoord[4] = { s, t, r, 1.0f };\r
+       GLfloat lambda = bias;\r
+       GLchan rgba[4];\r
+\r
+       swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,\r
+               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
+       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
+       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
+       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
+       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
+}\r
+\r
+GLvoid _slang_library_texcube (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,\r
+       GLfloat *color)\r
+{\r
+       GET_CURRENT_CONTEXT(ctx);\r
+       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+       GLuint unit = (GLuint) sampler;\r
+       GLfloat texcoord[4] = { s, t, r, 1.0f };\r
+       GLfloat lambda = bias;\r
+       GLchan rgba[4];\r
+\r
+       swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,\r
+               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
+       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
+       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
+       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
+       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
+}\r
+\r
+GLvoid _slang_library_shad1d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,\r
+       GLfloat *color)\r
+{\r
+       GET_CURRENT_CONTEXT(ctx);\r
+       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+       GLuint unit = (GLuint) sampler;\r
+       GLfloat texcoord[4] = { s, t, r, 1.0f };\r
+       GLfloat lambda = bias;\r
+       GLchan rgba[4];\r
+\r
+       swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,\r
+               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
+       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
+       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
+       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
+       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
+}\r
+\r
+GLvoid _slang_library_shad2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,\r
+       GLfloat *color)\r
+{\r
+       GET_CURRENT_CONTEXT(ctx);\r
+       SWcontext *swrast = SWRAST_CONTEXT(ctx);\r
+       GLuint unit = (GLuint) sampler;\r
+       GLfloat texcoord[4] = { s, t, r, 1.0f };\r
+       GLfloat lambda = bias;\r
+       GLchan rgba[4];\r
+\r
+       swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,\r
+               (const GLfloat (*)[4]) texcoord, &lambda, &rgba);\r
+       color[0] = CHAN_TO_FLOAT(rgba[0]);\r
+       color[1] = CHAN_TO_FLOAT(rgba[1]);\r
+       color[2] = CHAN_TO_FLOAT(rgba[2]);\r
+       color[3] = CHAN_TO_FLOAT(rgba[3]);\r
+}\r
+\r
diff --git a/src/mesa/shader/slang/slang_library_texsample.h b/src/mesa/shader/slang/slang_library_texsample.h
new file mode 100644 (file)
index 0000000..3aea76f
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ * Mesa 3-D graphics library\r
+ * Version:  6.5\r
+ *\r
+ * Copyright (C) 2006  Brian Paul   All Rights Reserved.\r
+ *\r
+ * Permission is hereby granted, free of charge, to any person obtaining a\r
+ * copy of this software and associated documentation files (the "Software"),\r
+ * to deal in the Software without restriction, including without limitation\r
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
+ * and/or sell copies of the Software, and to permit persons to whom the\r
+ * Software is furnished to do so, subject to the following conditions:\r
+ *\r
+ * The above copyright notice and this permission notice shall be included\r
+ * in all copies or substantial portions of the Software.\r
+ *\r
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\r
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN\r
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\r
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+ */\r
+\r
+#if !defined SLANG_LIBRARY_TEXSAMPLE_H\r
+#define SLANG_LIBRARY_TEXSAMPLE_H\r
+\r
+#if defined __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+GLvoid _slang_library_tex1d (GLfloat, GLfloat, GLfloat, GLfloat *);\r
+GLvoid _slang_library_tex2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);\r
+GLvoid _slang_library_tex3d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);\r
+GLvoid _slang_library_texcube (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);\r
+GLvoid _slang_library_shad1d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);\r
+GLvoid _slang_library_shad2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif\r
+\r
index 7216663e3f1c5deff1f363dfb8c0223f85d35f21..58d17c15580739fc5d46876c82ad90abcf8897bc 100644 (file)
@@ -30,6 +30,7 @@
 \r
 #include "imports.h"\r
 #include "slang_link.h"\r
+#include "slang_analyse.h"\r
 \r
 /*\r
  * slang_uniform_bindings\r
@@ -69,7 +70,7 @@ static GLboolean slang_uniform_bindings_add (slang_uniform_bindings *self, slang
                return GL_FALSE;\r
        self->table[n].quant = q;\r
        self->table[n].name = slang_string_duplicate (name);\r
-       for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)\r
+       for (i = 0; i < SLANG_SHADER_MAX; i++)\r
                self->table[n].address[i] = ~0;\r
        self->table[n].address[index] = address;\r
        if (self->table[n].name == NULL)\r
@@ -222,6 +223,21 @@ static GLboolean gather_active_uniforms (slang_active_uniforms *u, slang_export_
        return GL_TRUE;\r
 }\r
 \r
+/*\r
+ * slang_texture_bindings\r
+ */\r
+\r
+GLvoid slang_texture_usages_ctr (slang_texture_usages *self)\r
+{\r
+       self->table = NULL;\r
+       self->count = 0;\r
+}\r
+\r
+GLvoid slang_texture_usages_dtr (slang_texture_usages *self)\r
+{\r
+       slang_alloc_free (self->table);\r
+}\r
+\r
 /*\r
  * slang_program\r
  */\r
@@ -232,13 +248,15 @@ GLvoid slang_program_ctr (slang_program *self)
 \r
        slang_uniform_bindings_ctr (&self->uniforms);\r
        slang_active_uniforms_ctr (&self->active_uniforms);\r
-       for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)\r
+       slang_texture_usages_ctr (&self->texture_usage);\r
+       for (i = 0; i < SLANG_SHADER_MAX; i++)\r
        {\r
                GLuint j;\r
 \r
                for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)\r
                        self->common_fixed_entries[i][j] = ~0;\r
-               self->code[i] = ~0;\r
+               for (j = 0; j < SLANG_COMMON_CODE_MAX; j++)\r
+                       self->code[i][j] = ~0;\r
                self->machines[i] = NULL;\r
                self->assemblies[i] = NULL;\r
        }\r
@@ -252,6 +270,7 @@ GLvoid slang_program_dtr (slang_program *self)
 {\r
        slang_uniform_bindings_dtr (&self->uniforms);\r
        slang_active_uniforms_dtr (&self->active_uniforms);\r
+       slang_texture_usages_dtr (&self->texture_usage);\r
 }\r
 \r
 /*\r
@@ -273,7 +292,7 @@ static GLuint gd (slang_export_data_table *tbl, const char *name)
        return ~0;\r
 }\r
 \r
-static GLvoid fill_common_fixed_entries (GLuint e[], slang_export_data_table *tbl)\r
+static GLvoid resolve_common_fixed (GLuint e[], slang_export_data_table *tbl)\r
 {\r
        e[SLANG_COMMON_FIXED_MODELVIEWMATRIX] = gd (tbl, "gl_ModelViewMatrix");\r
        e[SLANG_COMMON_FIXED_PROJECTIONMATRIX] = gd (tbl, "gl_ProjectionMatrix");\r
@@ -322,7 +341,7 @@ static GLvoid fill_common_fixed_entries (GLuint e[], slang_export_data_table *tb
        e[SLANG_COMMON_FIXED_FOG] = gd (tbl, "gl_Fog");\r
 }\r
 \r
-static GLvoid fill_vertex_fixed_entries (GLuint e[], slang_export_data_table *tbl)\r
+static GLvoid resolve_vertex_fixed (GLuint e[], slang_export_data_table *tbl)\r
 {\r
        e[SLANG_VERTEX_FIXED_POSITION] = gd (tbl, "gl_Position");\r
        e[SLANG_VERTEX_FIXED_POINTSIZE] = gd (tbl,  "gl_PointSize");\r
@@ -348,7 +367,7 @@ static GLvoid fill_vertex_fixed_entries (GLuint e[], slang_export_data_table *tb
        e[SLANG_VERTEX_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");\r
 }\r
 \r
-static GLvoid fill_fragment_fixed_entries (GLuint e[], slang_export_data_table *tbl)\r
+static GLvoid resolve_fragment_fixed (GLuint e[], slang_export_data_table *tbl)\r
 {\r
        e[SLANG_FRAGMENT_FIXED_FRAGCOORD] = gd (tbl, "gl_FragCoord");\r
        e[SLANG_FRAGMENT_FIXED_FRONTFACING] = gd (tbl, "gl_FrontFacing");\r
@@ -376,9 +395,9 @@ static GLuint gc (slang_export_code_table *tbl, const char *name)
        return ~0;\r
 }\r
 \r
-static GLvoid resolve_code (GLuint code[], slang_export_code_table *tbl)\r
+static GLvoid resolve_common_code (GLuint code[], slang_export_code_table *tbl)\r
 {\r
-       code[0] = gc (tbl, "@main");\r
+       code[SLANG_COMMON_CODE_MAIN] = gc (tbl, "@main");\r
 }\r
 \r
 GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLuint count)\r
@@ -391,25 +410,28 @@ GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLui
 \r
                if (units[i]->type == slang_unit_fragment_shader)\r
                {\r
-                       index = SLANG_UNIFORM_BINDING_FRAGMENT;\r
-                       fill_fragment_fixed_entries (prog->fragment_fixed_entries, &units[i]->exp_data);\r
+                       index = SLANG_SHADER_FRAGMENT;\r
+                       resolve_fragment_fixed (prog->fragment_fixed_entries, &units[i]->exp_data);\r
                }\r
                else\r
                {\r
-                       index = SLANG_UNIFORM_BINDING_VERTEX;\r
-                       fill_vertex_fixed_entries (prog->vertex_fixed_entries, &units[i]->exp_data);\r
+                       index = SLANG_SHADER_VERTEX;\r
+                       resolve_vertex_fixed (prog->vertex_fixed_entries, &units[i]->exp_data);\r
                }\r
 \r
                if (!gather_uniform_bindings (&prog->uniforms, &units[i]->exp_data, index))\r
                        return GL_FALSE;\r
                if (!gather_active_uniforms (&prog->active_uniforms, &units[i]->exp_data))\r
                        return GL_FALSE;\r
-               fill_common_fixed_entries (prog->common_fixed_entries[index], &units[i]->exp_data);\r
-               resolve_code (&prog->code[index], &units[i]->exp_code);\r
+               resolve_common_fixed (prog->common_fixed_entries[index], &units[i]->exp_data);\r
+               resolve_common_code (prog->code[index], &units[i]->exp_code);\r
                prog->machines[index] = units[i]->machine;\r
                prog->assemblies[index] = units[i]->assembly;\r
        }\r
 \r
+       if (!_slang_analyse_texture_usage (prog))\r
+               return GL_FALSE;\r
+\r
        return GL_TRUE;\r
 }\r
 \r
index 5f8c4e7335113c2f505461194720e45ce6840aa3..faebae625eaa576e7b56f93800412fbafc28aa9d 100644 (file)
@@ -42,7 +42,7 @@ typedef struct
 {\r
        slang_export_data_quant *quant;\r
        char *name;\r
-       GLuint address[SLANG_UNIFORM_BINDING_MAX];\r
+       GLuint address[SLANG_SHADER_MAX];\r
 } slang_uniform_binding;\r
 \r
 typedef struct\r
@@ -63,6 +63,21 @@ typedef struct
        GLuint count;\r
 } slang_active_uniforms;\r
 \r
+typedef struct\r
+{\r
+       slang_export_data_quant *quant;\r
+       GLuint frag_address;\r
+} slang_texture_usage;\r
+\r
+typedef struct\r
+{\r
+       slang_texture_usage *table;\r
+       GLuint count;\r
+} slang_texture_usages;\r
+\r
+GLvoid slang_texture_usages_ctr (slang_texture_usages *);\r
+GLvoid slang_texture_usages_dtr (slang_texture_usages *);\r
+\r
 enum\r
 {\r
        SLANG_COMMON_FIXED_MODELVIEWMATRIX,\r
@@ -148,16 +163,23 @@ enum
        SLANG_FRAGMENT_FIXED_MAX\r
 };\r
 \r
+enum\r
+{\r
+       SLANG_COMMON_CODE_MAIN,\r
+       SLANG_COMMON_CODE_MAX\r
+};\r
+\r
 typedef struct\r
 {\r
        slang_uniform_bindings uniforms;\r
        slang_active_uniforms active_uniforms;\r
-       GLuint common_fixed_entries[SLANG_UNIFORM_BINDING_MAX][SLANG_COMMON_FIXED_MAX];\r
+       slang_texture_usages texture_usage;\r
+       GLuint common_fixed_entries[SLANG_SHADER_MAX][SLANG_COMMON_FIXED_MAX];\r
        GLuint vertex_fixed_entries[SLANG_VERTEX_FIXED_MAX];\r
        GLuint fragment_fixed_entries[SLANG_FRAGMENT_FIXED_MAX];\r
-       GLuint code[SLANG_UNIFORM_BINDING_MAX];\r
-       slang_machine *machines[SLANG_UNIFORM_BINDING_MAX];\r
-       slang_assembly_file *assemblies[SLANG_UNIFORM_BINDING_MAX];\r
+       GLuint code[SLANG_SHADER_MAX][SLANG_COMMON_CODE_MAX];\r
+       slang_machine *machines[SLANG_SHADER_MAX];\r
+       slang_assembly_file *assemblies[SLANG_SHADER_MAX];\r
 } slang_program;\r
 \r
 GLvoid slang_program_ctr (slang_program *);\r
index 4eec5c0c5a6a1f52faef54d1ab47c31bca546e28..8d5034076f876e24989c42148382540f6953bf31 100644 (file)
@@ -329,6 +329,19 @@ SOURCE=..\..\..\..\src\mesa\main\image.c
 # Begin Source File\r
 \r
 SOURCE=..\..\..\..\src\mesa\main\imports.c\r
+\r
+!IF  "$(CFG)" == "mesa - Win32 Release"\r
+\r
+!ELSEIF  "$(CFG)" == "mesa - Win32 Debug"\r
+\r
+!ELSEIF  "$(CFG)" == "mesa - Win32 Release x86"\r
+\r
+# ADD CPP /YX\r
+\r
+!ELSEIF  "$(CFG)" == "mesa - Win32 Debug x86"\r
+\r
+!ENDIF \r
+\r
 # End Source File\r
 # Begin Source File\r
 \r
@@ -552,6 +565,10 @@ SOURCE=..\..\..\..\src\mesa\shader\shaderobjects_3dlabs.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_analyse.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble.c\r
 # End Source File\r
 # Begin Source File\r
@@ -608,6 +625,10 @@ SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_noise.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_texsample.c\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\..\..\src\mesa\shader\slang\slang_link.c\r
 # End Source File\r
 # Begin Source File\r
@@ -1314,6 +1335,10 @@ SOURCE=..\..\..\..\src\mesa\main\simple_list.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_analyse.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble.h\r
 # End Source File\r
 # Begin Source File\r
@@ -1366,6 +1391,10 @@ SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_noise.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_texsample.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\..\..\..\src\mesa\shader\slang\slang_link.h\r
 # End Source File\r
 # Begin Source File\r