summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/texstate.c107
-rw-r--r--src/mesa/shader/shaderobjects.c99
-rw-r--r--src/mesa/shader/shaderobjects.h5
-rwxr-xr-xsrc/mesa/shader/shaderobjects_3dlabs.c186
-rwxr-xr-xsrc/mesa/shader/slang/library/slang_common_builtin.gc66
-rw-r--r--src/mesa/shader/slang/library/slang_common_builtin_gc.h121
-rwxr-xr-xsrc/mesa/shader/slang/library/slang_fragment_builtin.gc63
-rw-r--r--src/mesa/shader/slang/library/slang_fragment_builtin_gc.h121
-rw-r--r--src/mesa/shader/slang/library/slang_shader.syn18
-rw-r--r--src/mesa/shader/slang/library/slang_shader_syn.h8
-rw-r--r--src/mesa/shader/slang/slang_analyse.c100
-rw-r--r--src/mesa/shader/slang/slang_analyse.h50
-rw-r--r--src/mesa/shader/slang/slang_assemble.c69
-rw-r--r--src/mesa/shader/slang/slang_assemble.h5
-rw-r--r--src/mesa/shader/slang/slang_execute.c80
-rw-r--r--src/mesa/shader/slang/slang_execute_x86.c72
-rw-r--r--src/mesa/shader/slang/slang_library_texsample.c142
-rw-r--r--src/mesa/shader/slang/slang_library_texsample.h44
-rw-r--r--src/mesa/shader/slang/slang_link.c50
-rw-r--r--src/mesa/shader/slang/slang_link.h32
-rw-r--r--windows/VC6/mesa/mesa/mesa.dsp29
21 files changed, 1093 insertions, 374 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 428d0a0d01a..a8cb8a7bcfa 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -39,7 +39,8 @@
#include "texstate.h"
#include "texenvprogram.h"
#include "mtypes.h"
-#include "math/m_xform.h"
+#include "math/m_xform.h"
+#include "shaderobjects.h"
@@ -2765,7 +2766,22 @@ update_texture_matrices( GLcontext *ctx )
}
}
}
-
+
+
+static void
+texture_override( struct gl_texture_object *texObj, GLuint textureBit, GLcontext *ctx,
+ GLbitfield enableBits, struct gl_texture_unit *texUnit )
+{
+ if (!texUnit->_ReallyEnabled && (enableBits & textureBit)) {
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = textureBit;
+ texUnit->_Current = texObj;
+ }
+ }
+}
/**
* \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;
+ struct gl2_program_intf **prog = ctx->ShaderObjects.CurrentProgram;
+ GLbitfield progteximageusage[MAX_TEXTURE_IMAGE_UNITS];
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;
+
+ /*
+ * Grab texture image usage state from shader program. It must be grabbed every time
+ * uniform sampler changes, so maybe there is a better place to perform these rather
+ * expensive computations.
+ */
+ if (prog != NULL) {
+ (**prog).GetTextureImageUsage (prog, progteximageusage);
+ }
/* 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 */
+ if (prog != NULL) {
+ enableBits = progteximageusage[unit];
+ }
+ 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;
- }
- }
+ */
+ texture_override(texUnit->CurrentCubeMap, TEXTURE_CUBE_BIT, ctx, enableBits, texUnit);
+ texture_override(texUnit->Current3D, TEXTURE_3D_BIT, ctx, enableBits, texUnit);
+ texture_override(texUnit->CurrentRect, TEXTURE_RECT_BIT, ctx, enableBits, texUnit);
+ 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.
*/
- if (ctx->ShaderObjects.CurrentProgram != NULL) {
- ctx->Texture._EnabledCoordUnits |= (1 << 8) - 1;
+ if (prog != NULL) {
+ ctx->Texture._EnabledCoordUnits |= (1 << ctx->Const.MaxTextureCoordUnits) - 1;
}
else if (ctx->FragmentProgram._Enabled) {
ctx->Texture._EnabledCoordUnits |=
diff --git a/src/mesa/shader/shaderobjects.c b/src/mesa/shader/shaderobjects.c
index 4c4fdcfe550..ad55b7448c5 100644
--- a/src/mesa/shader/shaderobjects.c
+++ b/src/mesa/shader/shaderobjects.c
@@ -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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ 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");
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
if (pro != NULL)
{
diff --git a/src/mesa/shader/shaderobjects.h b/src/mesa/shader/shaderobjects.h
index 5a4667d090a..830adddec94 100644
--- a/src/mesa/shader/shaderobjects.h
+++ b/src/mesa/shader/shaderobjects.h
@@ -88,9 +88,10 @@ struct gl2_program_intf
GLvoid (* Validate) (struct gl2_program_intf **);
GLvoid (* UpdateFixedUniforms) (struct gl2_program_intf **);
GLvoid (* UpdateFixedAttribute) (struct gl2_program_intf **, GLuint, GLvoid *, GLuint, GLuint,
- GLboolean);
+ GLboolean);
GLvoid (* UpdateFixedVarying) (struct gl2_program_intf **, GLuint, GLvoid *, GLuint, GLuint,
- GLboolean);
+ GLboolean);
+ GLvoid (* GetTextureImageUsage) (struct gl2_program_intf **, GLbitfield *);
};
struct gl2_fragment_shader_intf
diff --git a/src/mesa/shader/shaderobjects_3dlabs.c b/src/mesa/shader/shaderobjects_3dlabs.c
index 96f382437d5..6d03f426487 100755
--- a/src/mesa/shader/shaderobjects_3dlabs.c
+++ b/src/mesa/shader/shaderobjects_3dlabs.c
@@ -841,7 +841,7 @@ write_common_fixed (slang_program *pro, GLuint index, const GLvoid *src, GLuint
{
GLuint i;
- for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
{
GLuint addr;
@@ -965,7 +965,7 @@ _program_UpdateFixedAttribute (struct gl2_program_intf **intf, GLuint index, GLv
{
GLubyte *mem;
- mem = (GLubyte *) pro->machines[SLANG_UNIFORM_BINDING_VERTEX]->mem + addr + offset * size;
+ mem = (GLubyte *) pro->machines[SLANG_SHADER_VERTEX]->mem + addr + offset * size;
if (write)
_mesa_memcpy (mem, data, size);
else
@@ -986,7 +986,7 @@ _program_UpdateFixedVarying (struct gl2_program_intf **intf, GLuint index, GLvoi
{
GLubyte *mem;
- mem = (GLubyte *) pro->machines[SLANG_UNIFORM_BINDING_FRAGMENT]->mem + addr + offset * size;
+ mem = (GLubyte *) pro->machines[SLANG_SHADER_FRAGMENT]->mem + addr + offset * size;
if (write)
_mesa_memcpy (mem, data, size);
else
@@ -994,6 +994,58 @@ _program_UpdateFixedVarying (struct gl2_program_intf **intf, GLuint index, GLvoi
}
}
+static GLvoid
+_program_GetTextureImageUsage (struct gl2_program_intf **intf, GLbitfield *teximageusage)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+ slang_program *pro = &impl->_obj.prog;
+ GLuint i;
+
+ for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++)
+ teximageusage[i] = 0;
+
+ for (i = 0; i < pro->texture_usage.count; i++)
+ {
+ GLuint n, addr, j;
+
+ n = pro->texture_usage.table[i].quant->array_len;
+ if (n == 0)
+ n = 1;
+ addr = pro->texture_usage.table[i].frag_address;
+ for (j = 0; j < n; j++)
+ {
+ GLubyte *mem;
+ GLuint image;
+
+ mem = (GLubyte *) pro->machines[SLANG_SHADER_FRAGMENT]->mem + addr + j * 4;
+ image = (GLuint) *((GLfloat *) mem);
+ if (image >= 0 && image < ctx->Const.MaxTextureImageUnits)
+ {
+ switch (pro->texture_usage.table[i].quant->u.basic_type)
+ {
+ case GL_SAMPLER_1D_ARB:
+ case GL_SAMPLER_1D_SHADOW_ARB:
+ teximageusage[image] |= TEXTURE_1D_BIT;
+ break;
+ case GL_SAMPLER_2D_ARB:
+ case GL_SAMPLER_2D_SHADOW_ARB:
+ teximageusage[image] |= TEXTURE_2D_BIT;
+ break;
+ case GL_SAMPLER_3D_ARB:
+ teximageusage[image] |= TEXTURE_3D_BIT;
+ break;
+ case GL_SAMPLER_CUBE_ARB:
+ teximageusage[image] |= TEXTURE_CUBE_BIT;
+ break;
+ }
+ }
+ }
+ }
+
+ /* TODO: make sure that for 0<=i<=MaxTextureImageUint bitcount(teximageuint[i])<=0 */
+}
+
static struct gl2_program_intf _program_vftbl = {
{
{
@@ -1019,7 +1071,8 @@ static struct gl2_program_intf _program_vftbl = {
_program_Validate,
_program_UpdateFixedUniforms,
_program_UpdateFixedAttribute,
- _program_UpdateFixedVarying
+ _program_UpdateFixedVarying,
+ _program_GetTextureImageUsage
};
static void
@@ -1238,7 +1291,7 @@ int _slang_fetch_discard (struct gl2_program_intf **pro, GLboolean *val)
struct gl2_program_impl *impl;
impl = (struct gl2_program_impl *) pro;
- *val = impl->_obj.prog.machines[SLANG_UNIFORM_BINDING_FRAGMENT]->kill ? GL_TRUE : GL_FALSE;
+ *val = impl->_obj.prog.machines[SLANG_SHADER_FRAGMENT]->kill ? GL_TRUE : GL_FALSE;
return 1;
}
@@ -1251,19 +1304,19 @@ static GLvoid exec_shader (struct gl2_program_intf **pro, GLuint i)
p = &impl->_obj.prog;
slang_machine_init (p->machines[i]);
- p->machines[i]->ip = p->code[i];
+ p->machines[i]->ip = p->code[i][SLANG_COMMON_CODE_MAIN];
_slang_execute2 (p->assemblies[i], p->machines[i]);
}
GLvoid _slang_exec_fragment_shader (struct gl2_program_intf **pro)
{
- exec_shader (pro, SLANG_UNIFORM_BINDING_FRAGMENT);
+ exec_shader (pro, SLANG_SHADER_FRAGMENT);
}
GLvoid _slang_exec_vertex_shader (struct gl2_program_intf **pro)
{
- exec_shader (pro, SLANG_UNIFORM_BINDING_VERTEX);
+ exec_shader (pro, SLANG_SHADER_VERTEX);
}
GLint _slang_get_uniform_location (struct gl2_program_intf **pro, const char *name)
@@ -1287,6 +1340,10 @@ GLboolean _slang_write_uniform (struct gl2_program_intf **pro, GLint loc, GLsize
slang_uniform_bindings *bind;
slang_uniform_binding *b;
GLuint i;
+ GLboolean convert_float_to_bool = GL_FALSE;
+ GLboolean convert_int_to_bool = GL_FALSE;
+ GLboolean convert_int_to_float = GL_FALSE;
+ GLboolean types_match = GL_FALSE;
if (loc == -1)
return GL_TRUE;
@@ -1298,16 +1355,113 @@ GLboolean _slang_write_uniform (struct gl2_program_intf **pro, GLint loc, GLsize
b = &bind->table[loc];
/* TODO: check sizes */
- /* TODO: check if not structure */
- if (b->quant->u.basic_type != type)
+ if (b->quant->structure != NULL)
return GL_FALSE;
- for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)
- if (b->address[i] != ~0)
- {
- _mesa_memcpy (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4], data,
- count * b->quant->size);
- }
+ switch (b->quant->u.basic_type)
+ {
+ case GL_BOOL_ARB:
+ types_match = (type == GL_FLOAT) || (type == GL_INT);
+ if (type == GL_FLOAT)
+ convert_float_to_bool = GL_TRUE;
+ else
+ convert_int_to_bool = GL_TRUE;
+ break;
+ case GL_BOOL_VEC2_ARB:
+ types_match = (type == GL_FLOAT_VEC2_ARB) || (type == GL_INT_VEC2_ARB);
+ if (type == GL_FLOAT_VEC2_ARB)
+ convert_float_to_bool = GL_TRUE;
+ else
+ convert_int_to_bool = GL_TRUE;
+ break;
+ case GL_BOOL_VEC3_ARB:
+ types_match = (type == GL_FLOAT_VEC3_ARB) || (type == GL_INT_VEC3_ARB);
+ if (type == GL_FLOAT_VEC3_ARB)
+ convert_float_to_bool = GL_TRUE;
+ else
+ convert_int_to_bool = GL_TRUE;
+ break;
+ case GL_BOOL_VEC4_ARB:
+ types_match = (type == GL_FLOAT_VEC4_ARB) || (type == GL_INT_VEC4_ARB);
+ if (type == GL_FLOAT_VEC4_ARB)
+ convert_float_to_bool = GL_TRUE;
+ else
+ convert_int_to_bool = GL_TRUE;
+ break;
+ case GL_SAMPLER_1D_ARB:
+ case GL_SAMPLER_2D_ARB:
+ case GL_SAMPLER_3D_ARB:
+ case GL_SAMPLER_CUBE_ARB:
+ case GL_SAMPLER_1D_SHADOW_ARB:
+ case GL_SAMPLER_2D_SHADOW_ARB:
+ types_match = (type == GL_INT);
+ break;
+ default:
+ types_match = (type == b->quant->u.basic_type);
+ break;
+ }
+
+ if (!types_match)
+ return GL_FALSE;
+
+ switch (type)
+ {
+ case GL_INT:
+ case GL_INT_VEC2_ARB:
+ case GL_INT_VEC3_ARB:
+ case GL_INT_VEC4_ARB:
+ convert_int_to_float = GL_TRUE;
+ break;
+ }
+
+ if (convert_float_to_bool)
+ {
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
+ if (b->address[i] != ~0)
+ {
+ const GLfloat *src = (GLfloat *) (data);
+ GLfloat *dst = (GLfloat *) (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4]);
+ GLuint j;
+
+ for (j = 0; j < count * b->quant->size / 4; j++)
+ dst[j] = src[j] != 0.0f ? 1.0f : 0.0f;
+ }
+ }
+ else if (convert_int_to_bool)
+ {
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
+ if (b->address[i] != ~0)
+ {
+ const GLuint *src = (GLuint *) (data);
+ GLfloat *dst = (GLfloat *) (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4]);
+ GLuint j;
+
+ for (j = 0; j < count * b->quant->size / 4; j++)
+ dst[j] = src[j] ? 1.0f : 0.0f;
+ }
+ }
+ else if (convert_int_to_float)
+ {
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
+ if (b->address[i] != ~0)
+ {
+ const GLuint *src = (GLuint *) (data);
+ GLfloat *dst = (GLfloat *) (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4]);
+ GLuint j;
+
+ for (j = 0; j < count * b->quant->size / 4; j++)
+ dst[j] = (GLfloat) src[j];
+ }
+ }
+ else
+ {
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
+ if (b->address[i] != ~0)
+ {
+ _mesa_memcpy (&impl->_obj.prog.machines[i]->mem[b->address[i] / 4], data,
+ count * b->quant->size);
+ }
+ }
return GL_TRUE;
}
diff --git a/src/mesa/shader/slang/library/slang_common_builtin.gc b/src/mesa/shader/slang/library/slang_common_builtin.gc
index 4d82d54c14d..9486f4c8304 100755
--- a/src/mesa/shader/slang/library/slang_common_builtin.gc
+++ b/src/mesa/shader/slang/library/slang_common_builtin.gc
@@ -1,10 +1,27 @@
-
-//
-// TODO:
-// - implement texture1D, texture3D, textureCube,
-// - implement shadow1D, shadow2D,
-//
-
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
//
// From Shader Spec, ver. 1.10, rev. 59
//
@@ -1267,8 +1284,9 @@ bvec4 not (bvec4 v) {
//
vec4 texture1D (sampler1D sampler, float coord) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_tex1d texel, sampler, coord, 0.0;
+ return texel;
}
vec4 texture1DProj (sampler1D sampler, vec2 coord) {
@@ -1281,7 +1299,7 @@ vec4 texture1DProj (sampler1D sampler, vec4 coord) {
vec4 texture2D (sampler2D sampler, vec2 coord) {
vec4 texel;
- __asm vec4_tex2d texel, sampler, coord;
+ __asm vec4_tex2d texel, sampler, coord, 0.0;
return texel;
}
@@ -1294,8 +1312,9 @@ vec4 texture2DProj (sampler2D sampler, vec4 coord) {
}
vec4 texture3D (sampler3D sampler, vec3 coord) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_tex3d texel, sampler, coord, 0.0;
+ return texel;
}
vec4 texture3DProj (sampler3D sampler, vec4 coord) {
@@ -1303,22 +1322,25 @@ vec4 texture3DProj (sampler3D sampler, vec4 coord) {
}
vec4 textureCube (samplerCube sampler, vec3 coord) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_texcube texel, sampler, coord, 0.0;
+ return texel;
}
vec4 shadow1D (sampler1DShadow sampler, vec3 coord) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_shad1d texel, sampler, coord, 0.0;
+ return texel;
}
-vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {
- // XXX:
- return vec4 (0.0);
-}
-
vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord) {
- 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));
+}
+
+vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {
+ vec4 texel;
+ __asm vec4_shad2d texel, sampler, coord, 0.0;
+ return texel;
}
vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord) {
diff --git a/src/mesa/shader/slang/library/slang_common_builtin_gc.h b/src/mesa/shader/slang/library/slang_common_builtin_gc.h
index 7198e5f9478..ad4f78eebf4 100644
--- a/src/mesa/shader/slang/library/slang_common_builtin_gc.h
+++ b/src/mesa/shader/slang/library/slang_common_builtin_gc.h
@@ -548,62 +548,71 @@
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,
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,
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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
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,
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,
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,
diff --git a/src/mesa/shader/slang/library/slang_fragment_builtin.gc b/src/mesa/shader/slang/library/slang_fragment_builtin.gc
index 776c96db9b0..8b619cd8373 100755
--- a/src/mesa/shader/slang/library/slang_fragment_builtin.gc
+++ b/src/mesa/shader/slang/library/slang_fragment_builtin.gc
@@ -1,8 +1,29 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
//
// 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) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_tex1d texel, sampler, coord, bias;
+ return texel;
}
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) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_tex2d texel, sampler, coord, bias;
+ return texel;
}
vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias) {
@@ -52,8 +75,9 @@ vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias) {
}
vec4 texture3D (sampler3D sampler, vec3 coord, float bias) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_tex3d texel, sampler, coord, bias;
+ return texel;
}
vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {
@@ -61,22 +85,25 @@ vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {
}
vec4 textureCube (samplerCube sampler, vec3 coord, float bias) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_texcube texel, sampler, coord, bias;
+ return texel;
}
vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias) {
- // XXX:
- return vec4 (0.0);
-}
-
-vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {
- // XXX:
- return vec4 (0.0);
+ vec4 texel;
+ __asm vec4_shad1d texel, sampler, coord, bias;
+ return texel;
}
vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias) {
- 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);
+}
+
+vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {
+ vec4 texel;
+ __asm vec4_shad2d texel, sampler, coord, bias;
+ return texel;
}
vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias) {
diff --git a/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h b/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h
index d8202a83ca2..89d4736f3eb 100644
--- a/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h
+++ b/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h
@@ -10,58 +10,69 @@
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,
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,
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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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,
-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
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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,
+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
diff --git a/src/mesa/shader/slang/library/slang_shader.syn b/src/mesa/shader/slang/library/slang_shader.syn
index aeb3c6112c2..36d073e88a8 100644
--- a/src/mesa/shader/slang/library/slang_shader.syn
+++ b/src/mesa/shader/slang/library/slang_shader.syn
@@ -1168,16 +1168,26 @@ __asm_statement
"__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
/*
- <asm_arguments> ::= <identifier>
- | <asm_arguments> "," <identifier>
+ <asm_arguments> ::= <asm_argument>
+ | <asm_arguments> "," <asm_argument>
note: this is an extension to the standard language specification - normally slang disallows
__asm statements
*/
asm_arguments
- variable_identifier .and .true .emit OP_END .and .loop asm_arguments_1;
+ asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;
asm_arguments_1
- comma .and variable_identifier .and .true .emit OP_END;
+ comma .and asm_argument .and .true .emit OP_END;
+
+/*
+ <asm_argument> ::= <variable_identifier>
+ | <floatconstant>
+
+note: this is an extension to the standard language specification - normally slang disallows
+ __asm statements
+*/
+asm_argument
+ variable_identifier .or floatconstant;
/*
<translation_unit> ::= <external_declaration>
diff --git a/src/mesa/shader/slang/library/slang_shader_syn.h b/src/mesa/shader/slang/library/slang_shader_syn.h
index 3f13b2583a3..5a94d99d439 100644
--- a/src/mesa/shader/slang/library/slang_shader_syn.h
+++ b/src/mesa/shader/slang/library/slang_shader_syn.h
@@ -560,9 +560,11 @@
"__asm_statement\n"
" \"__asm\" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;\n"
"asm_arguments\n"
-" variable_identifier .and .true .emit OP_END .and .loop asm_arguments_1;\n"
+" asm_argument .and .true .emit OP_END .and .loop asm_arguments_1;\n"
"asm_arguments_1\n"
-" comma .and variable_identifier .and .true .emit OP_END;\n"
+" comma .and asm_argument .and .true .emit OP_END;\n"
+"asm_argument\n"
+" variable_identifier .or floatconstant;\n"
"translation_unit\n"
" optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and\n"
" .loop external_declaration .and optional_space .and\n"
@@ -749,4 +751,4 @@
" '\\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;\n"
"err_identifier\n"
" id_character_first .and .loop id_character_next;\n"
-""
+"" \ 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
index 00000000000..164dbec3503
--- /dev/null
+++ b/src/mesa/shader/slang/slang_analyse.c
@@ -0,0 +1,100 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_analyse.c
+ * slang assembly code analysis
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_analyse.h"
+#include "slang_utility.h"
+
+GLboolean _slang_analyse_texture_usage (slang_program *prog)
+{
+ GLuint i, count = 0;
+
+ slang_texture_usages_dtr (&prog->texture_usage);
+ slang_texture_usages_ctr (&prog->texture_usage);
+
+ /*
+ * We could do a full code analysis to find out which uniforms are actually used.
+ * For now, we are very conservative and extract them from uniform binding table, which
+ * in turn also do not come from code analysis.
+ */
+
+ for (i = 0; i < prog->uniforms.count; i++)
+ {
+ slang_uniform_binding *b = &prog->uniforms.table[i];
+
+ if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && b->quant->structure == NULL)
+ {
+ switch (b->quant->u.basic_type)
+ {
+ case GL_SAMPLER_1D_ARB:
+ case GL_SAMPLER_2D_ARB:
+ case GL_SAMPLER_3D_ARB:
+ case GL_SAMPLER_CUBE_ARB:
+ case GL_SAMPLER_1D_SHADOW_ARB:
+ case GL_SAMPLER_2D_SHADOW_ARB:
+ count++;
+ break;
+ }
+ }
+ }
+
+ if (count == 0)
+ return GL_TRUE;
+ prog->texture_usage.table = (slang_texture_usage *) slang_alloc_malloc (
+ count * sizeof (slang_texture_usage));
+ if (prog->texture_usage.table == NULL)
+ return GL_FALSE;
+ prog->texture_usage.count = count;
+
+ for (count = i = 0; i < prog->uniforms.count; i++)
+ {
+ slang_uniform_binding *b = &prog->uniforms.table[i];
+
+ if (b->address[SLANG_SHADER_FRAGMENT] != ~0 && b->quant->structure == NULL)
+ {
+ switch (b->quant->u.basic_type)
+ {
+ case GL_SAMPLER_1D_ARB:
+ case GL_SAMPLER_2D_ARB:
+ case GL_SAMPLER_3D_ARB:
+ case GL_SAMPLER_CUBE_ARB:
+ case GL_SAMPLER_1D_SHADOW_ARB:
+ case GL_SAMPLER_2D_SHADOW_ARB:
+ prog->texture_usage.table[count].quant = b->quant;
+ prog->texture_usage.table[count].frag_address = b->address[SLANG_SHADER_FRAGMENT];
+ count++;
+ break;
+ }
+ }
+ }
+
+ return GL_TRUE;
+}
+
diff --git a/src/mesa/shader/slang/slang_analyse.h b/src/mesa/shader/slang/slang_analyse.h
new file mode 100644
index 00000000000..89814b3cc3f
--- /dev/null
+++ b/src/mesa/shader/slang/slang_analyse.h
@@ -0,0 +1,50 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_ANALYSE_H
+#define SLANG_ANALYSE_H
+
+#include "slang_link.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Texture usage analysis is a bit more difficult than for fragment programs. While fragment
+ * programs statically link to texture targets and texture units, shaders statically link
+ * only to texture targets. The texture unit linkage is determined just before the execution
+ * of a given primitive by reading active uniform samplers.
+ *
+ * This procedure retrieves a list of uniforms that reach texture sample instructions.
+ */
+
+GLboolean _slang_analyse_texture_usage (slang_program *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/mesa/shader/slang/slang_assemble.c b/src/mesa/shader/slang/slang_assemble.c
index b24d3183841..faa13b33e69 100644
--- a/src/mesa/shader/slang/slang_assemble.c
+++ b/src/mesa/shader/slang/slang_assemble.c
@@ -644,7 +644,12 @@ static const struct
{ "float_noise3", slang_asm_float_noise3, slang_asm_float_copy },
{ "float_noise4", slang_asm_float_noise4, slang_asm_float_copy },
{ "int_to_float", slang_asm_int_to_float, slang_asm_float_copy },
+ { "vec4_tex1d", slang_asm_vec4_tex1d, slang_asm_none },
{ "vec4_tex2d", slang_asm_vec4_tex2d, slang_asm_none },
+ { "vec4_tex3d", slang_asm_vec4_tex3d, slang_asm_none },
+ { "vec4_texcube", slang_asm_vec4_texcube, slang_asm_none },
+ { "vec4_shad1d", slang_asm_vec4_shad1d, slang_asm_none },
+ { "vec4_shad2d", slang_asm_vec4_shad2d, slang_asm_none },
/* mesa-specific extensions */
{ "float_print", slang_asm_float_deref, slang_asm_float_print },
{ "int_print", slang_asm_int_deref, slang_asm_int_print },
@@ -930,7 +935,9 @@ static GLboolean handle_field (slang_assemble_ctx *A, slang_assembly_typeinfo *t
else
{
GLuint i, struct_size = 0, field_offset = 0, field_size = 0;
+ GLboolean relocate, shrink;
+ /* calculate struct size, field offset and field size */
for (i = 0; i < tib->spec._struct->fields->num_variables; i++)
{
slang_variable *field;
@@ -960,28 +967,56 @@ static GLboolean handle_field (slang_assemble_ctx *A, slang_assembly_typeinfo *t
field_offset += size;
}
- if (!PLAB (A->file, slang_asm_addr_push, field_offset))
- return GL_FALSE;
+ /*
+ * OPTIMIZATION: If selecting the last field, no relocation is needed.
+ */
+ relocate = field_offset != struct_size - field_size;
- if (ref == slang_ref_force)
+ /*
+ * OPTIMIZATION: If field and struct sizes are equal, no partial free is needed.
+ */
+ shrink = field_size != struct_size;
+
+ if (relocate)
{
- if (!PUSH (A->file, slang_asm_addr_add))
+ if (!PLAB (A->file, slang_asm_addr_push, field_offset))
return GL_FALSE;
}
+
+ if (ref == slang_ref_force)
+ {
+ if (relocate)
+ {
+ if (!PUSH (A->file, slang_asm_addr_add))
+ return GL_FALSE;
+ }
+ }
else
{
- GLuint i;
+ GLuint free_b = 0;
- /* move the selected element to the beginning of the master expression */
- for (i = 0; i < field_size; i += 4)
- if (!PLAB2 (A->file, slang_asm_float_move, struct_size - field_size + i + 4, i + 4))
- return GL_FALSE;
- if (!PLAB (A->file, slang_asm_local_free, 4))
- return GL_FALSE;
+ if (relocate)
+ {
+ GLuint i;
- /* free the rest of the master expression */
- if (!PLAB (A->file, slang_asm_local_free, struct_size - field_size))
- return GL_FALSE;
+ /* move the selected element to the beginning of the master expression */
+ for (i = 0; i < field_size; i += 4)
+ if (!PLAB2 (A->file, slang_asm_float_move, struct_size - field_size + i + 4, i + 4))
+ return GL_FALSE;
+ free_b += 4;
+ }
+
+ if (shrink)
+ {
+ /* free the rest of the master expression */
+ free_b += struct_size - field_size;
+ }
+
+ if (free_b)
+ {
+ if (!PLAB (A->file, slang_asm_local_free, free_b))
+ return GL_FALSE;
+ }
}
}
@@ -1173,14 +1208,17 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
case slang_oper_addassign:
if (!_slang_assemble_assign (A, op, "+=", ref))
return GL_FALSE;
+ A->ref = ref;
break;
case slang_oper_subassign:
if (!_slang_assemble_assign (A, op, "-=", ref))
return GL_FALSE;
+ A->ref = ref;
break;
case slang_oper_mulassign:
if (!_slang_assemble_assign (A, op, "*=", ref))
return GL_FALSE;
+ A->ref = ref;
break;
/*case slang_oper_modassign:*/
/*case slang_oper_lshassign:*/
@@ -1191,6 +1229,7 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
case slang_oper_divassign:
if (!_slang_assemble_assign (A, op, "/=", ref))
return GL_FALSE;
+ A->ref = ref;
break;
case slang_oper_select:
if (!_slang_assemble_select (A, op))
@@ -1279,10 +1318,12 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
case slang_oper_preincrement:
if (!_slang_assemble_assign (A, op, "++", ref))
return GL_FALSE;
+ A->ref = ref;
break;
case slang_oper_predecrement:
if (!_slang_assemble_assign (A, op, "--", ref))
return GL_FALSE;
+ A->ref = ref;
break;
case slang_oper_plus:
if (!_slang_dereference (A, op))
diff --git a/src/mesa/shader/slang/slang_assemble.h b/src/mesa/shader/slang/slang_assemble.h
index ed1005454f2..0cde845f854 100644
--- a/src/mesa/shader/slang/slang_assemble.h
+++ b/src/mesa/shader/slang/slang_assemble.h
@@ -75,7 +75,12 @@ typedef enum slang_assembly_type_
slang_asm_addr_deref,
slang_asm_addr_add,
slang_asm_addr_multiply,
+ slang_asm_vec4_tex1d,
slang_asm_vec4_tex2d,
+ slang_asm_vec4_tex3d,
+ slang_asm_vec4_texcube,
+ slang_asm_vec4_shad1d,
+ slang_asm_vec4_shad2d,
slang_asm_jump,
slang_asm_jump_if_zero,
slang_asm_enter,
diff --git a/src/mesa/shader/slang/slang_execute.c b/src/mesa/shader/slang/slang_execute.c
index 0714ddff0d9..bed63d1e5b0 100644
--- a/src/mesa/shader/slang/slang_execute.c
+++ b/src/mesa/shader/slang/slang_execute.c
@@ -29,11 +29,9 @@
*/
#include "imports.h"
-#include "context.h"
-#include "swrast/s_context.h"
-#include "colormac.h"
#include "slang_execute.h"
#include "slang_library_noise.h"
+#include "slang_library_texsample.h"
#define DEBUG_SLANG 0
@@ -48,7 +46,8 @@ GLvoid slang_machine_ctr (slang_machine *self)
GLvoid slang_machine_dtr (slang_machine *self)
{
#if defined(USE_X86_ASM) || defined(SLANG_X86)
- /* TODO: free self->x86.compiled_func */
+ if (self->x86.compiled_func != NULL)
+ _mesa_exec_free (self->x86.compiled_func);
#endif
}
@@ -195,9 +194,24 @@ static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
case slang_asm_addr_multiply:
fprintf (f, "addr_multiply");
break;
- case slang_vec4_tex2d:
+ case slang_asm_vec4_tex1d:
+ fprintf (f, "vec4_tex1d");
+ break;
+ case slang_asm_vec4_tex2d:
fprintf (f, "vec4_tex2d");
break;
+ case slang_asm_vec4_tex3d:
+ fprintf (f, "vec4_tex3d");
+ break;
+ case slang_asm_vec4_texcube:
+ fprintf (f, "vec4_texcube");
+ break;
+ case slang_asm_vec4_shad1d:
+ fprintf (f, "vec4_shad1d");
+ break;
+ case slang_asm_vec4_shad2d:
+ fprintf (f, "vec4_shad2d");
+ break;
case slang_asm_jump:
fprintf (f, "jump\t%u", a->param[0]);
break;
@@ -272,21 +286,6 @@ static void dump (const slang_assembly_file *file)
#endif
-static void fetch_texel (GLuint sampler, const GLfloat texcoord[4], GLfloat lambda, GLfloat color[4])
-{
- GET_CURRENT_CONTEXT(ctx);
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLchan rgba[4];
-
- /* XXX: the function pointer is NULL! */
- swrast->TextureSample[sampler] (ctx, ctx->Texture.Unit[sampler]._Current, 1,
- (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
- color[0] = CHAN_TO_FLOAT(rgba[0]);
- color[1] = CHAN_TO_FLOAT(rgba[1]);
- color[2] = CHAN_TO_FLOAT(rgba[2]);
- color[3] = CHAN_TO_FLOAT(rgba[3]);
-}
-
int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)
{
slang_machine_slot *stack;
@@ -465,16 +464,41 @@ int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)
stack[mach->sp + 1]._addr *= stack[mach->sp]._addr;
mach->sp++;
break;
- case slang_asm_vec4_tex2d:
- {
- GLfloat st[4] = { stack[mach->sp]._float, stack[mach->sp + 1]._float, 0.0f, 1.0f };
- GLuint sampler = (GLuint) stack[mach->sp + 2]._float;
- GLfloat *rgba = &mach->mem[stack[mach->sp + 3]._addr / 4]._float;
-
- fetch_texel (sampler, st, 0.0f, rgba);
- }
+ case slang_asm_vec4_tex1d:
+ _slang_library_tex1d (stack[mach->sp]._float, stack[mach->sp + 1]._float,
+ stack[mach->sp + 2]._float, &mach->mem[stack[mach->sp + 3]._addr / 4]._float);
mach->sp += 3;
break;
+ case slang_asm_vec4_tex2d:
+ _slang_library_tex2d (stack[mach->sp]._float, stack[mach->sp + 1]._float,
+ stack[mach->sp + 2]._float, stack[mach->sp + 3]._float,
+ &mach->mem[stack[mach->sp + 4]._addr / 4]._float);
+ mach->sp += 4;
+ break;
+ case slang_asm_vec4_tex3d:
+ _slang_library_tex3d (stack[mach->sp]._float, stack[mach->sp + 1]._float,
+ stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,
+ &mach->mem[stack[mach->sp + 5]._addr / 4]._float);
+ mach->sp += 5;
+ break;
+ case slang_asm_vec4_texcube:
+ _slang_library_texcube (stack[mach->sp]._float, stack[mach->sp + 1]._float,
+ stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,
+ &mach->mem[stack[mach->sp + 5]._addr / 4]._float);
+ mach->sp += 5;
+ break;
+ case slang_asm_vec4_shad1d:
+ _slang_library_shad1d (stack[mach->sp]._float, stack[mach->sp + 1]._float,
+ stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,
+ &mach->mem[stack[mach->sp + 5]._addr / 4]._float);
+ mach->sp += 5;
+ break;
+ case slang_asm_vec4_shad2d:
+ _slang_library_shad2d (stack[mach->sp]._float, stack[mach->sp + 1]._float,
+ stack[mach->sp + 2]._float, stack[mach->sp + 3]._float, stack[mach->sp + 4]._float,
+ &mach->mem[stack[mach->sp + 5]._addr / 4]._float);
+ mach->sp += 5;
+ break;
case slang_asm_jump:
mach->ip = a->param[0];
break;
diff --git a/src/mesa/shader/slang/slang_execute_x86.c b/src/mesa/shader/slang/slang_execute_x86.c
index d6395632390..781aeb97db3 100644
--- a/src/mesa/shader/slang/slang_execute_x86.c
+++ b/src/mesa/shader/slang/slang_execute_x86.c
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.5
*
- * Copyright (C) 2005-2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -29,11 +29,9 @@
*/
#include "imports.h"
-#include "context.h"
-#include "colormac.h"
-#include "swrast/s_context.h"
#include "slang_execute.h"
#include "slang_library_noise.h"
+#include "slang_library_texsample.h"
#if defined(USE_X86_ASM) || defined(SLANG_X86)
@@ -114,28 +112,6 @@ static GLfloat do_ceilf (GLfloat x)
return CEILF (x);
}
-static void fetch_texel (GLuint sampler, const GLfloat texcoord[4], GLfloat lambda, GLfloat color[4])
-{
- GET_CURRENT_CONTEXT(ctx);
- SWcontext *swrast = SWRAST_CONTEXT(ctx);
- GLchan rgba[4];
-
- /* XXX: the function pointer is NULL! */
- swrast->TextureSample[sampler] (ctx, ctx->Texture.Unit[sampler]._Current, 1,
- (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
- color[0] = CHAN_TO_FLOAT(rgba[0]);
- color[1] = CHAN_TO_FLOAT(rgba[1]);
- color[2] = CHAN_TO_FLOAT(rgba[2]);
- color[3] = CHAN_TO_FLOAT(rgba[3]);
-}
-
-static GLvoid do_vec4_tex2d (GLfloat s, GLfloat t, GLuint sampler, GLfloat *rgba)
-{
- GLfloat st[4] = { s, t, 0.0f, 1.0f };
-
- fetch_texel (sampler, st, 0.0f, rgba);
-}
-
static GLvoid do_print_float (GLfloat x)
{
_mesa_printf ("slang print: %f\n", x);
@@ -373,9 +349,29 @@ static GLvoid codegen_assem (codegen_ctx *G, slang_assembly *a)
x86_mul (&G->f, G->r_ecx);
x86_mov (&G->f, x86_deref (G->r_esp), G->r_eax);
break;
+ case slang_asm_vec4_tex1d:
+ x86_call (&G->f, (GLubyte *) _slang_library_tex1d);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 12));
+ break;
case slang_asm_vec4_tex2d:
- x86_call (&G->f, (GLubyte *) do_vec4_tex2d);
- x86_lea (&G->f, G->r_ebp, x86_make_disp (G->r_esp, 12));
+ x86_call (&G->f, (GLubyte *) _slang_library_tex2d);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 16));
+ break;
+ case slang_asm_vec4_tex3d:
+ x86_call (&G->f, (GLubyte *) _slang_library_tex3d);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));
+ break;
+ case slang_asm_vec4_texcube:
+ x86_call (&G->f, (GLubyte *) _slang_library_texcube);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));
+ break;
+ case slang_asm_vec4_shad1d:
+ x86_call (&G->f, (GLubyte *) _slang_library_shad1d);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));
+ break;
+ case slang_asm_vec4_shad2d:
+ x86_call (&G->f, (GLubyte *) _slang_library_shad2d);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 20));
break;
case slang_asm_jump:
add_fixup (G, a->param[0], x86_jmp_forward (&G->f));
@@ -460,7 +456,13 @@ GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GL
GLubyte *j_body, *j_exit;
GLuint i;
- x86_init_func_size (&G.f, 4*1048576);
+ /*
+ * We need as much as 1M because *all* assembly, including built-in library, is
+ * being translated to x86.
+ * The built-in library occupies 450K, so we can be safe for now.
+ * It is going to change in the future, when we get assembly analysis running.
+ */
+ x86_init_func_size (&G.f, 1048576);
G.r_eax = x86_make_reg (file_REG32, reg_AX);
G.r_ecx = x86_make_reg (file_REG32, reg_CX);
G.r_edx = x86_make_reg (file_REG32, reg_DX);
@@ -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);
j_body = x86_jmp_forward (&G.f);
- /* discard keywords go here */
+ /* "discard" instructions jump to this label */
G.l_discard = x86_get_label (&G.f);
x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &G.mach->kill);
x86_mov_reg_imm (&G.f, G.r_ecx, 1);
@@ -503,7 +505,11 @@ GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GL
codegen_assem (&G, &file->code[i]);
}
- /* restore stack and return */
+ /*
+ * Restore stack and return.
+ * This must be handled this way, because "discard" can be invoked from any
+ * place in the code.
+ */
x86_fixup_fwd_jump (&G.f, j_exit);
x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &mach->x86.esp_restore);
x86_mov (&G.f, G.r_esp, x86_deref (G.r_eax));
@@ -526,7 +532,9 @@ GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GL
slang_alloc_free (G.fixups);
slang_alloc_free (G.labels);
- /* TODO: free previous instance, if not NULL */
+ /* install new code */
+ if (mach->x86.compiled_func != NULL)
+ _mesa_exec_free (mach->x86.compiled_func);
mach->x86.compiled_func = (GLvoid (*) (slang_machine *)) x86_get_func (&G.f);
return GL_TRUE;
diff --git a/src/mesa/shader/slang/slang_library_texsample.c b/src/mesa/shader/slang/slang_library_texsample.c
new file mode 100644
index 00000000000..d26b767f88a
--- /dev/null
+++ b/src/mesa/shader/slang/slang_library_texsample.c
@@ -0,0 +1,142 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_library_texsample.c
+ * built-in library functions for texture and shadow sampling
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "context.h"
+#include "colormac.h"
+#include "swrast/s_context.h"
+#include "slang_library_texsample.h"
+
+GLvoid _slang_library_tex1d (GLfloat bias, GLfloat s, GLfloat sampler, GLfloat *color)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint unit = (GLuint) sampler;
+ GLfloat texcoord[4] = { s, 0.0f, 0.0f, 1.0f };
+ GLfloat lambda = bias;
+ GLchan rgba[4];
+
+ swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
+ (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+GLvoid _slang_library_tex2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat sampler, GLfloat *color)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint unit = (GLuint) sampler;
+ GLfloat texcoord[4] = { s, t, 0.0f, 1.0f };
+ GLfloat lambda = bias;
+ GLchan rgba[4];
+
+ swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
+ (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+GLvoid _slang_library_tex3d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
+ GLfloat *color)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint unit = (GLuint) sampler;
+ GLfloat texcoord[4] = { s, t, r, 1.0f };
+ GLfloat lambda = bias;
+ GLchan rgba[4];
+
+ swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
+ (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+GLvoid _slang_library_texcube (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
+ GLfloat *color)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint unit = (GLuint) sampler;
+ GLfloat texcoord[4] = { s, t, r, 1.0f };
+ GLfloat lambda = bias;
+ GLchan rgba[4];
+
+ swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
+ (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+GLvoid _slang_library_shad1d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
+ GLfloat *color)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint unit = (GLuint) sampler;
+ GLfloat texcoord[4] = { s, t, r, 1.0f };
+ GLfloat lambda = bias;
+ GLchan rgba[4];
+
+ swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
+ (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+GLvoid _slang_library_shad2d (GLfloat bias, GLfloat s, GLfloat t, GLfloat r, GLfloat sampler,
+ GLfloat *color)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint unit = (GLuint) sampler;
+ GLfloat texcoord[4] = { s, t, r, 1.0f };
+ GLfloat lambda = bias;
+ GLchan rgba[4];
+
+ swrast->TextureSample[unit] (ctx, ctx->Texture.Unit[unit]._Current, 1,
+ (const GLfloat (*)[4]) texcoord, &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
diff --git a/src/mesa/shader/slang/slang_library_texsample.h b/src/mesa/shader/slang/slang_library_texsample.h
new file mode 100644
index 00000000000..3aea76fd8db
--- /dev/null
+++ b/src/mesa/shader/slang/slang_library_texsample.h
@@ -0,0 +1,44 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2006 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_LIBRARY_TEXSAMPLE_H
+#define SLANG_LIBRARY_TEXSAMPLE_H
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+GLvoid _slang_library_tex1d (GLfloat, GLfloat, GLfloat, GLfloat *);
+GLvoid _slang_library_tex2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
+GLvoid _slang_library_tex3d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
+GLvoid _slang_library_texcube (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
+GLvoid _slang_library_shad1d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
+GLvoid _slang_library_shad2d (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 7216663e3f1..58d17c15580 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -30,6 +30,7 @@
#include "imports.h"
#include "slang_link.h"
+#include "slang_analyse.h"
/*
* slang_uniform_bindings
@@ -69,7 +70,7 @@ static GLboolean slang_uniform_bindings_add (slang_uniform_bindings *self, slang
return GL_FALSE;
self->table[n].quant = q;
self->table[n].name = slang_string_duplicate (name);
- for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
self->table[n].address[i] = ~0;
self->table[n].address[index] = address;
if (self->table[n].name == NULL)
@@ -223,6 +224,21 @@ static GLboolean gather_active_uniforms (slang_active_uniforms *u, slang_export_
}
/*
+ * slang_texture_bindings
+ */
+
+GLvoid slang_texture_usages_ctr (slang_texture_usages *self)
+{
+ self->table = NULL;
+ self->count = 0;
+}
+
+GLvoid slang_texture_usages_dtr (slang_texture_usages *self)
+{
+ slang_alloc_free (self->table);
+}
+
+/*
* slang_program
*/
@@ -232,13 +248,15 @@ GLvoid slang_program_ctr (slang_program *self)
slang_uniform_bindings_ctr (&self->uniforms);
slang_active_uniforms_ctr (&self->active_uniforms);
- for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)
+ slang_texture_usages_ctr (&self->texture_usage);
+ for (i = 0; i < SLANG_SHADER_MAX; i++)
{
GLuint j;
for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)
self->common_fixed_entries[i][j] = ~0;
- self->code[i] = ~0;
+ for (j = 0; j < SLANG_COMMON_CODE_MAX; j++)
+ self->code[i][j] = ~0;
self->machines[i] = NULL;
self->assemblies[i] = NULL;
}
@@ -252,6 +270,7 @@ GLvoid slang_program_dtr (slang_program *self)
{
slang_uniform_bindings_dtr (&self->uniforms);
slang_active_uniforms_dtr (&self->active_uniforms);
+ slang_texture_usages_dtr (&self->texture_usage);
}
/*
@@ -273,7 +292,7 @@ static GLuint gd (slang_export_data_table *tbl, const char *name)
return ~0;
}
-static GLvoid fill_common_fixed_entries (GLuint e[], slang_export_data_table *tbl)
+static GLvoid resolve_common_fixed (GLuint e[], slang_export_data_table *tbl)
{
e[SLANG_COMMON_FIXED_MODELVIEWMATRIX] = gd (tbl, "gl_ModelViewMatrix");
e[SLANG_COMMON_FIXED_PROJECTIONMATRIX] = gd (tbl, "gl_ProjectionMatrix");
@@ -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");
}
-static GLvoid fill_vertex_fixed_entries (GLuint e[], slang_export_data_table *tbl)
+static GLvoid resolve_vertex_fixed (GLuint e[], slang_export_data_table *tbl)
{
e[SLANG_VERTEX_FIXED_POSITION] = gd (tbl, "gl_Position");
e[SLANG_VERTEX_FIXED_POINTSIZE] = gd (tbl, "gl_PointSize");
@@ -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");
}
-static GLvoid fill_fragment_fixed_entries (GLuint e[], slang_export_data_table *tbl)
+static GLvoid resolve_fragment_fixed (GLuint e[], slang_export_data_table *tbl)
{
e[SLANG_FRAGMENT_FIXED_FRAGCOORD] = gd (tbl, "gl_FragCoord");
e[SLANG_FRAGMENT_FIXED_FRONTFACING] = gd (tbl, "gl_FrontFacing");
@@ -376,9 +395,9 @@ static GLuint gc (slang_export_code_table *tbl, const char *name)
return ~0;
}
-static GLvoid resolve_code (GLuint code[], slang_export_code_table *tbl)
+static GLvoid resolve_common_code (GLuint code[], slang_export_code_table *tbl)
{
- code[0] = gc (tbl, "@main");
+ code[SLANG_COMMON_CODE_MAIN] = gc (tbl, "@main");
}
GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLuint count)
@@ -391,25 +410,28 @@ GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLui
if (units[i]->type == slang_unit_fragment_shader)
{
- index = SLANG_UNIFORM_BINDING_FRAGMENT;
- fill_fragment_fixed_entries (prog->fragment_fixed_entries, &units[i]->exp_data);
+ index = SLANG_SHADER_FRAGMENT;
+ resolve_fragment_fixed (prog->fragment_fixed_entries, &units[i]->exp_data);
}
else
{
- index = SLANG_UNIFORM_BINDING_VERTEX;
- fill_vertex_fixed_entries (prog->vertex_fixed_entries, &units[i]->exp_data);
+ index = SLANG_SHADER_VERTEX;
+ resolve_vertex_fixed (prog->vertex_fixed_entries, &units[i]->exp_data);
}
if (!gather_uniform_bindings (&prog->uniforms, &units[i]->exp_data, index))
return GL_FALSE;
if (!gather_active_uniforms (&prog->active_uniforms, &units[i]->exp_data))
return GL_FALSE;
- fill_common_fixed_entries (prog->common_fixed_entries[index], &units[i]->exp_data);
- resolve_code (&prog->code[index], &units[i]->exp_code);
+ resolve_common_fixed (prog->common_fixed_entries[index], &units[i]->exp_data);
+ resolve_common_code (prog->code[index], &units[i]->exp_code);
prog->machines[index] = units[i]->machine;
prog->assemblies[index] = units[i]->assembly;
}
+ if (!_slang_analyse_texture_usage (prog))
+ return GL_FALSE;
+
return GL_TRUE;
}
diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h
index 5f8c4e73351..faebae625ea 100644
--- a/src/mesa/shader/slang/slang_link.h
+++ b/src/mesa/shader/slang/slang_link.h
@@ -42,7 +42,7 @@ typedef struct
{
slang_export_data_quant *quant;
char *name;
- GLuint address[SLANG_UNIFORM_BINDING_MAX];
+ GLuint address[SLANG_SHADER_MAX];
} slang_uniform_binding;
typedef struct
@@ -63,6 +63,21 @@ typedef struct
GLuint count;
} slang_active_uniforms;
+typedef struct
+{
+ slang_export_data_quant *quant;
+ GLuint frag_address;
+} slang_texture_usage;
+
+typedef struct
+{
+ slang_texture_usage *table;
+ GLuint count;
+} slang_texture_usages;
+
+GLvoid slang_texture_usages_ctr (slang_texture_usages *);
+GLvoid slang_texture_usages_dtr (slang_texture_usages *);
+
enum
{
SLANG_COMMON_FIXED_MODELVIEWMATRIX,
@@ -148,16 +163,23 @@ enum
SLANG_FRAGMENT_FIXED_MAX
};
+enum
+{
+ SLANG_COMMON_CODE_MAIN,
+ SLANG_COMMON_CODE_MAX
+};
+
typedef struct
{
slang_uniform_bindings uniforms;
slang_active_uniforms active_uniforms;
- GLuint common_fixed_entries[SLANG_UNIFORM_BINDING_MAX][SLANG_COMMON_FIXED_MAX];
+ slang_texture_usages texture_usage;
+ GLuint common_fixed_entries[SLANG_SHADER_MAX][SLANG_COMMON_FIXED_MAX];
GLuint vertex_fixed_entries[SLANG_VERTEX_FIXED_MAX];
GLuint fragment_fixed_entries[SLANG_FRAGMENT_FIXED_MAX];
- GLuint code[SLANG_UNIFORM_BINDING_MAX];
- slang_machine *machines[SLANG_UNIFORM_BINDING_MAX];
- slang_assembly_file *assemblies[SLANG_UNIFORM_BINDING_MAX];
+ GLuint code[SLANG_SHADER_MAX][SLANG_COMMON_CODE_MAX];
+ slang_machine *machines[SLANG_SHADER_MAX];
+ slang_assembly_file *assemblies[SLANG_SHADER_MAX];
} slang_program;
GLvoid slang_program_ctr (slang_program *);
diff --git a/windows/VC6/mesa/mesa/mesa.dsp b/windows/VC6/mesa/mesa/mesa.dsp
index 4eec5c0c5a6..8d5034076f8 100644
--- a/windows/VC6/mesa/mesa/mesa.dsp
+++ b/windows/VC6/mesa/mesa/mesa.dsp
@@ -329,6 +329,19 @@ SOURCE=..\..\..\..\src\mesa\main\image.c
# Begin Source File
SOURCE=..\..\..\..\src\mesa\main\imports.c
+
+!IF "$(CFG)" == "mesa - Win32 Release"
+
+!ELSEIF "$(CFG)" == "mesa - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "mesa - Win32 Release x86"
+
+# ADD CPP /YX
+
+!ELSEIF "$(CFG)" == "mesa - Win32 Debug x86"
+
+!ENDIF
+
# End Source File
# Begin Source File
@@ -552,6 +565,10 @@ SOURCE=..\..\..\..\src\mesa\shader\shaderobjects_3dlabs.c
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_analyse.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble.c
# End Source File
# Begin Source File
@@ -608,6 +625,10 @@ SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_noise.c
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_texsample.c
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\src\mesa\shader\slang\slang_link.c
# End Source File
# Begin Source File
@@ -1314,6 +1335,10 @@ SOURCE=..\..\..\..\src\mesa\main\simple_list.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_analyse.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble.h
# End Source File
# Begin Source File
@@ -1366,6 +1391,10 @@ SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_noise.h
# End Source File
# Begin Source File
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_library_texsample.h
+# End Source File
+# Begin Source File
+
SOURCE=..\..\..\..\src\mesa\shader\slang\slang_link.h
# End Source File
# Begin Source File