summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/imports.c11
-rw-r--r--src/mesa/main/imports.h29
-rw-r--r--src/mesa/shader/shaderobjects.c1275
-rw-r--r--src/mesa/shader/shaderobjects.h9
-rwxr-xr-xsrc/mesa/shader/shaderobjects_3dlabs.c409
-rwxr-xr-xsrc/mesa/shader/shaderobjects_3dlabs.h32
-rw-r--r--src/mesa/shader/slang/slang_assemble.c8
-rw-r--r--src/mesa/shader/slang/slang_assemble.h27
-rw-r--r--src/mesa/shader/slang/slang_assemble_assignment.c5
-rw-r--r--src/mesa/shader/slang/slang_assemble_assignment.h6
-rw-r--r--src/mesa/shader/slang/slang_assemble_conditional.c4
-rw-r--r--src/mesa/shader/slang/slang_assemble_conditional.h16
-rw-r--r--src/mesa/shader/slang/slang_assemble_constructor.c4
-rw-r--r--src/mesa/shader/slang/slang_assemble_constructor.h5
-rw-r--r--src/mesa/shader/slang/slang_assemble_typeinfo.c91
-rw-r--r--src/mesa/shader/slang/slang_assemble_typeinfo.h53
-rw-r--r--src/mesa/shader/slang/slang_compile.c70
-rw-r--r--src/mesa/shader/slang/slang_compile.h12
-rw-r--r--src/mesa/shader/slang/slang_compile_function.c50
-rw-r--r--src/mesa/shader/slang/slang_compile_function.h3
-rw-r--r--src/mesa/shader/slang/slang_compile_operation.c4
-rw-r--r--src/mesa/shader/slang/slang_compile_struct.c4
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.c194
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.h61
-rw-r--r--src/mesa/shader/slang/slang_execute.c32
-rw-r--r--src/mesa/shader/slang/slang_execute.h18
-rw-r--r--src/mesa/shader/slang/slang_execute_x86.c536
-rw-r--r--src/mesa/shader/slang/slang_export.c51
-rw-r--r--src/mesa/shader/slang/slang_export.h29
-rw-r--r--src/mesa/shader/slang/slang_library_noise.c20
-rw-r--r--src/mesa/shader/slang/slang_link.c243
-rw-r--r--src/mesa/shader/slang/slang_link.h115
-rw-r--r--src/mesa/shader/slang/slang_preprocess.c2
-rw-r--r--src/mesa/shader/slang/slang_preprocess.h6
-rw-r--r--src/mesa/shader/slang/slang_storage.c3
-rw-r--r--src/mesa/shader/slang/slang_storage.h2
-rw-r--r--src/mesa/shader/slang/slang_utility.h4
-rw-r--r--src/mesa/sources3
-rw-r--r--src/mesa/swrast/s_arbshader.c70
-rw-r--r--src/mesa/tnl/t_vb_arbshader.c201
-rw-r--r--src/mesa/x86/rtasm/x86sse.c83
-rw-r--r--src/mesa/x86/rtasm/x86sse.h32
42 files changed, 2308 insertions, 1524 deletions
diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
index a49c711a25c..96b89dd9601 100644
--- a/src/mesa/main/imports.c
+++ b/src/mesa/main/imports.c
@@ -295,6 +295,17 @@ _mesa_sin(double a)
#else
return sin(a);
#endif
+}
+
+/** Single precision wrapper around either sin() or xf86sin() */
+float
+_mesa_sinf(float a)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return (float) xf86sin((double) a);
+#else
+ return (float) sin((double) a);
+#endif
}
/** Wrapper around either cos() or xf86cos() */
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index c6983129446..425ef825d1c 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -572,7 +572,29 @@ do { \
_watcom_start_fast_math(&x,&mask); \
} while (0)
#endif
-#define END_FAST_MATH(x) _watcom_end_fast_math(&x)
+#define END_FAST_MATH(x) _watcom_end_fast_math(&x)
+
+#elif defined(_MSC_VER) && defined(_M_IX86)
+#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */
+#define FAST_X86_FPU 0x003f /* See GCC comments above */
+#if defined(NO_FAST_MATH)
+#define START_FAST_MATH(x) do {\
+ static GLuint mask = DEFAULT_X86_FPU;\
+ __asm fnstcw word ptr [x]\
+ __asm fldcw word ptr [mask]\
+} while(0)
+#else
+#define START_FAST_MATH(x) do {\
+ static GLuint mask = FAST_X86_FPU;\
+ __asm fnstcw word ptr [x]\
+ __asm fldcw word ptr [mask]\
+} while(0)
+#endif
+#define END_FAST_MATH(x) do {\
+ __asm fnclex\
+ __asm fldcw word ptr [x]\
+} while(0)
+
#else
#define START_FAST_MATH(x) x = 0
#define END_FAST_MATH(x) (void)(x)
@@ -627,7 +649,10 @@ extern int
_mesa_memcmp( const void *s1, const void *s2, size_t n );
extern double
-_mesa_sin(double a);
+_mesa_sin(double a);
+
+extern float
+_mesa_sinf(float a);
extern double
_mesa_cos(double a);
diff --git a/src/mesa/shader/shaderobjects.c b/src/mesa/shader/shaderobjects.c
index 7b18e10d8c7..4c4fdcfe550 100644
--- a/src/mesa/shader/shaderobjects.c
+++ b/src/mesa/shader/shaderobjects.c
@@ -30,39 +30,116 @@
#include "glheader.h"
-#include "shaderobjects.h"
-#include "shaderobjects_3dlabs.h"
#include "context.h"
-#include "macros.h"
#include "hash.h"
+#include "shaderobjects.h"
+#include "shaderobjects_3dlabs.h"
-void GLAPIENTRY
+#define I_UNKNOWN struct gl2_unknown_intf **
+#define I_GENERIC struct gl2_generic_intf **
+#define I_CONTAINER struct gl2_container_intf **
+#define I_PROGRAM struct gl2_program_intf **
+#define I_SHADER struct gl2_shader_intf **
+
+#define RELEASE_GENERIC(x)\
+ (**x)._unknown.Release ((I_UNKNOWN) x)
+
+#define RELEASE_CONTAINER(x)\
+ (**x)._generic._unknown.Release ((I_UNKNOWN) x)
+
+#define RELEASE_PROGRAM(x)\
+ (**x)._container._generic._unknown.Release ((I_UNKNOWN) x)
+
+#define RELEASE_SHADER(x)\
+ (**x)._generic._unknown.Release ((I_UNKNOWN) x);
+
+#define _LOOKUP_HANDLE(handle, function)\
+ I_UNKNOWN unk;\
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\
+ unk = (I_UNKNOWN) _mesa_HashLookup (ctx->Shared->GL2Objects, handle);\
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\
+ if (unk == NULL) {\
+ _mesa_error (ctx, GL_INVALID_VALUE, function);\
+ break;\
+ }
+
+#define _QUERY_INTERFACE(x, type, uuid, function)\
+ x = (type) (**unk).QueryInterface (unk, uuid);\
+ if (x == NULL) {\
+ _mesa_error (ctx, GL_INVALID_OPERATION, function);\
+ break;\
+ }
+
+#define GET_GENERIC(x, handle, function)\
+ I_GENERIC x = NULL;\
+ do {\
+ _LOOKUP_HANDLE(handle, function);\
+ _QUERY_INTERFACE(x, I_GENERIC, UIID_GENERIC, function);\
+ } while (0)
+
+#define GET_CONTAINER(x, handle, function)\
+ I_CONTAINER x = NULL;\
+ do {\
+ _LOOKUP_HANDLE(handle, function);\
+ _QUERY_INTERFACE(x, I_CONTAINER, UIID_CONTAINER, function);\
+ } while (0)
+
+#define GET_PROGRAM(x, handle, function)\
+ I_PROGRAM x = NULL;\
+ do {\
+ _LOOKUP_HANDLE(handle, function);\
+ _QUERY_INTERFACE(x, I_PROGRAM, UIID_PROGRAM, function);\
+ } while (0)
+
+#define GET_SHADER(x, handle, function)\
+ I_SHADER x = NULL;\
+ do {\
+ _LOOKUP_HANDLE(handle, function);\
+ _QUERY_INTERFACE(x, I_SHADER, UIID_SHADER, function);\
+ } while (0)
+
+#define _LINKED_PROGRAM(x, function)\
+ if ((**x).GetLinkStatus (x) == GL_FALSE) {\
+ RELEASE_PROGRAM(x);\
+ _mesa_error (ctx, GL_INVALID_OPERATION, function);\
+ break;\
+ }
+
+#define GET_LINKED_PROGRAM(x, handle, function)\
+ I_PROGRAM x = NULL;\
+ do {\
+ _LOOKUP_HANDLE(handle, function);\
+ _QUERY_INTERFACE(x, I_PROGRAM, UIID_PROGRAM, function);\
+ _LINKED_PROGRAM(x, function);\
+ } while (0)
+
+#define _CURRENT_PROGRAM(x, function)\
+ if (ctx->ShaderObjects.CurrentProgram == NULL) {\
+ _mesa_error (ctx, GL_INVALID_OPERATION, function);\
+ break;\
+ }\
+ x = ctx->ShaderObjects.CurrentProgram;
+
+#define GET_CURRENT_LINKED_PROGRAM(x, function)\
+ I_PROGRAM x = NULL;\
+ do {\
+ _CURRENT_PROGRAM(x, function);\
+ _LINKED_PROGRAM(x, function);\
+ } while (0)
+
+
+GLvoid GLAPIENTRY
_mesa_DeleteObjectARB (GLhandleARB obj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_generic_intf **gen;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+ GET_GENERIC(gen, obj, "glDeleteObjectARB");
- if (unk == NULL)
+ if (gen != NULL)
{
- _mesa_error (ctx, GL_INVALID_VALUE, "glDeleteObjectARB");
- return;
+ (**gen).Delete (gen);
+ RELEASE_GENERIC(gen);
}
-
- gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);
- if (gen == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glDeleteObjectARB");
- return;
- }
-
- (**gen).Delete (gen);
- (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);
}
GLhandleARB GLAPIENTRY
@@ -73,58 +150,37 @@ _mesa_GetHandleARB (GLenum pname)
switch (pname)
{
case GL_PROGRAM_OBJECT_ARB:
- if (ctx->ShaderObjects.CurrentProgram != NULL)
- return (**ctx->ShaderObjects.CurrentProgram)._container._generic.GetName (
- (struct gl2_generic_intf **) ctx->ShaderObjects.CurrentProgram);
+ {
+ I_PROGRAM pro = ctx->ShaderObjects.CurrentProgram;
+
+ if (pro != NULL)
+ return (**pro)._container._generic.GetName ((I_GENERIC) pro);
+ }
break;
+ default:
+ _mesa_error (ctx, GL_INVALID_ENUM, "glGetHandleARB");
}
return 0;
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_DetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unkc, **unka;
- struct gl2_container_intf **con;
- struct gl2_generic_intf **att;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unkc = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);
- unka = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, attachedObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+ GET_CONTAINER(con, containerObj, "glDetachObjectARB");
- if (unkc == NULL || unka == NULL)
+ if (con != NULL)
{
- _mesa_error (ctx, GL_INVALID_VALUE, "glDetachObjectARB");
- return;
- }
+ GET_GENERIC(att, attachedObj, "glDetachObjectARB");
- con = (struct gl2_container_intf **) (**unkc).QueryInterface (unkc, UIID_CONTAINER);
- if (con == NULL)
- {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glDetachObjectARB");
- return;
- }
-
- att = (struct gl2_generic_intf **) (**unka).QueryInterface (unka, UIID_GENERIC);
- if (att == NULL)
- {
- (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
- _mesa_error (ctx, GL_INVALID_VALUE, "glDetachObjectARB");
- return;
- }
-
- if ((**con).Detach (con, att) == GL_FALSE)
- {
- (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
- (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
- return;
+ if (att != NULL)
+ {
+ (**con).Detach (con, att);
+ RELEASE_GENERIC(att);
+ }
+ RELEASE_CONTAINER(con);
}
-
- (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
- (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
}
GLhandleARB GLAPIENTRY
@@ -133,40 +189,27 @@ _mesa_CreateShaderObjectARB (GLenum shaderType)
return _mesa_3dlabs_create_shader_object (shaderType);
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string,
const GLint *length)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_shader_intf **sha;
GLint *offsets;
GLsizei i;
GLcharARB *source;
+ GET_SHADER(sha, shaderObj, "glShaderSourceARB");
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, shaderObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glShaderSourceARB");
- return;
- }
-
- sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
if (sha == NULL)
- {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glShaderSourceARB");
return;
- }
- /* this array holds offsets of where the appropriate string ends, thus the last
- element will be set to the total length of the source code */
+ /*
+ * This array holds offsets of where the appropriate string ends, thus the last
+ * element will be set to the total length of the source code.
+ */
offsets = (GLint *) _mesa_malloc (count * sizeof (GLint));
if (offsets == NULL)
{
- (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+ RELEASE_SHADER(sha);
_mesa_error (ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
return;
}
@@ -185,8 +228,8 @@ _mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **s
source = (GLcharARB *) _mesa_malloc ((offsets[count - 1] + 1) * sizeof (GLcharARB));
if (source == NULL)
{
- _mesa_free ((void *) offsets);
- (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+ _mesa_free ((GLvoid *) offsets);
+ RELEASE_SHADER(sha);
_mesa_error (ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
return;
}
@@ -199,197 +242,105 @@ _mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **s
source[offsets[count - 1]] = '\0';
(**sha).SetSource (sha, source, offsets, count);
- (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+ RELEASE_SHADER(sha);
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_CompileShaderARB (GLhandleARB shaderObj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_shader_intf **sha;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, shaderObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glCompileShaderARB");
- return;
- }
+ GET_SHADER(sha, shaderObj, "glCompileShaderARB");
- sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
- if (sha == NULL)
+ if (sha != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glCompileShaderARB");
- return;
+ (**sha).Compile (sha);
+ RELEASE_SHADER(sha);
}
-
- (**sha).Compile (sha);
- (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
}
GLhandleARB GLAPIENTRY
-_mesa_CreateProgramObjectARB (void)
+_mesa_CreateProgramObjectARB (GLvoid)
{
return _mesa_3dlabs_create_program_object ();
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_AttachObjectARB (GLhandleARB containerObj, GLhandleARB obj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unkc, **unka;
- struct gl2_container_intf **con;
- struct gl2_generic_intf **att;
+ GET_CONTAINER(con, containerObj, "glAttachObjectARB");
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unkc = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);
- unka = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unkc == NULL || unka == NULL)
+ if (con != NULL)
{
- _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");
- return;
- }
+ GET_GENERIC(att, obj, "glAttachObjectARB");
- con = (struct gl2_container_intf **) (**unkc).QueryInterface (unkc, UIID_CONTAINER);
- if (con == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");
- return;
- }
-
- att = (struct gl2_generic_intf **) (**unka).QueryInterface (unka, UIID_GENERIC);
- if (att == NULL)
- {
- (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
- _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");
- return;
- }
-
- if (!(**con).Attach (con, att))
- {
- (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
- (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
- return;
+ if (att != NULL)
+ {
+ (**con).Attach (con, att);
+ RELEASE_GENERIC(att);
+ }
+ RELEASE_CONTAINER(con);
}
-
- (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
- (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_LinkProgramARB (GLhandleARB programObj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glLinkProgramARB");
- return;
- }
-
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
- {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glLinkProgramARB");
- return;
- }
+ GET_PROGRAM(pro, programObj, "glLinkProgramARB");
- if (pro == ctx->ShaderObjects.CurrentProgram)
+ if (pro != NULL)
{
- /* TODO re-install executable program */
+ if (pro == ctx->ShaderObjects.CurrentProgram)
+ {
+ /* TODO re-install executable program */
+ }
+ (**pro).Link (pro);
+ RELEASE_PROGRAM(pro);
}
-
- (**pro).Link (pro);
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_UseProgramObjectARB (GLhandleARB programObj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_program_intf **pro;
-
+ I_PROGRAM program = NULL;
+
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
- if (programObj == 0)
+ if (programObj != 0)
{
- pro = NULL;
- }
- else
- {
- struct gl2_unknown_intf **unk;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glUseProgramObjectARB");
- return;
- }
+ GET_PROGRAM(pro, programObj, "glUseProgramObjectARB");
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
if (pro == NULL)
- {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUseProgramObjectARB");
return;
- }
if ((**pro).GetLinkStatus (pro) == GL_FALSE)
{
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ RELEASE_PROGRAM(pro);
_mesa_error (ctx, GL_INVALID_OPERATION, "glUseProgramObjectARB");
return;
}
- }
- if (ctx->ShaderObjects.CurrentProgram != NULL)
- {
- (**ctx->ShaderObjects.CurrentProgram)._container._generic._unknown.Release (
- (struct gl2_unknown_intf **) ctx->ShaderObjects.CurrentProgram);
+ program = pro;
}
- ctx->ShaderObjects.CurrentProgram = pro;
+ if (ctx->ShaderObjects.CurrentProgram != NULL)
+ RELEASE_PROGRAM(ctx->ShaderObjects.CurrentProgram);
+ ctx->ShaderObjects.CurrentProgram = program;
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_ValidateProgramARB (GLhandleARB programObj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
+ GET_PROGRAM(pro, programObj, "glValidateProgramARB");
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glValidateProgramARB");
- return;
- }
-
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glValidateProgramARB");
- return;
+ (**pro).Validate (pro);
+ RELEASE_PROGRAM(pro);
}
-
- (**pro).Validate (pro);
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
/*
@@ -413,284 +364,341 @@ Errors TODO
Uniform1i{v}ARB is used to load a sampler value.
-*/
-
-#define _RELEASE_PROGRAM(obj)\
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro)
-
-#define _LOOKUP_PROGRAM(obj, function)\
- struct gl2_unknown_intf **unk;\
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);\
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);\
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);\
- if (unk == NULL) {\
- _mesa_error (ctx, GL_INVALID_VALUE, function);\
- break;\
- }\
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);\
- if (pro == NULL) {\
- _mesa_error (ctx, GL_INVALID_OPERATION, function);\
- break;\
- }
-
-#define _CURRENT_PROGRAM(function)\
- if (ctx->ShaderObjects.CurrentProgram == NULL) {\
- _mesa_error (ctx, GL_INVALID_OPERATION, function);\
- break;\
- }\
- pro = ctx->ShaderObjects.CurrentProgram;
-
-#define _IS_LINKED(function)\
- if ((**pro).GetLinkStatus (pro) == GL_FALSE) {\
- _mesa_error (ctx, GL_INVALID_OPERATION, function);\
- _RELEASE_PROGRAM(obj);\
- break;\
- }
-
-#define GET_PROGRAM(obj, function)\
- struct gl2_program_intf **pro = NULL;\
- do {\
- _LOOKUP_PROGRAM(obj, function);\
- } while (0)
-
-#define GET_LINKED_PROGRAM(obj, function)\
- struct gl2_program_intf **pro = NULL;\
- do {\
- _LOOKUP_PROGRAM(obj, function);\
- _IS_LINKED(function);\
- } while (0)
-
-#define CURRENT_LINKED_PROGRAM(function)\
- struct gl2_program_intf **pro = NULL;\
- do {\
- _CURRENT_PROGRAM(function);\
- _IS_LINKED(function);\
- } while (0)
-
-/* XXX */
-GLboolean _slang_write_uniform (struct gl2_program_intf **, GLint, GLsizei, const GLvoid *, GLenum);
-
-void GLAPIENTRY
+*/
+
+GLvoid GLAPIENTRY
_mesa_Uniform1fARB (GLint location, GLfloat v0)
-{
- GET_CURRENT_CONTEXT(ctx);
- CURRENT_LINKED_PROGRAM("glUniform1fARB");
-
- if (!_slang_write_uniform (pro, location, 1, &v0, GL_FLOAT))
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fARB");
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fARB");
+
+ if (pro != NULL)
+ {
+ if (!_slang_write_uniform (pro, location, 1, &v0, GL_FLOAT))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fARB");
+ }
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform2fARB (GLint location, GLfloat v0, GLfloat v1)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fARB");
- return;
+ GLfloat v[2] = { v0, v1 };
+
+ if (!_slang_write_uniform (pro, location, 1, v, GL_FLOAT_VEC2))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fARB");
- return;
+ GLfloat v[3] = { v0, v1, v2 };
+
+ if (!_slang_write_uniform (pro, location, 1, v, GL_FLOAT_VEC3))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fARB");
- return;
+ GLfloat v[4] = { v0, v1, v2, v3 };
+
+ if (!_slang_write_uniform (pro, location, 1, v, GL_FLOAT_VEC4))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform1iARB (GLint location, GLint v0)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1iARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1iARB");
- return;
+ if (!_slang_write_uniform (pro, location, 1, &v0, GL_INT))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1iARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform2iARB (GLint location, GLint v0, GLint v1)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2iARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2iARB");
- return;
+ GLint v[2] = { v0, v1 };
+
+ if (!_slang_write_uniform (pro, location, 1, v, GL_INT_VEC2))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2iARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform3iARB (GLint location, GLint v0, GLint v1, GLint v2)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3iARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3iARB");
- return;
+ GLint v[3] = { v0, v1, v2 };
+
+ if (!_slang_write_uniform (pro, location, 1, v, GL_INT_VEC3))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3iARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4iARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4iARB");
- return;
+ GLint v[4] = { v0, v1, v2, v3 };
+
+ if (!_slang_write_uniform (pro, location, 1, v, GL_INT_VEC4))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4iARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform1fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1fvARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fvARB");
- return;
+ if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fvARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform2fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2fvARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fvARB");
- return;
+ if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT_VEC2))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fvARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform3fvARB (GLint location, GLsizei count, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3fvARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fvARB");
- return;
+ if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT_VEC3))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fvARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform4fvARB (GLint location, GLsizei count, const GLfloat *value)
{
- GET_CURRENT_CONTEXT(ctx);
- CURRENT_LINKED_PROGRAM("glUniform4fvARB");
+ GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4fvARB");
- if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT_VEC4_ARB))
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fvARB");
+ if (pro != NULL)
+ {
+ if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT_VEC4))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fvARB");
+ }
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform1ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform1ivARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1ivARB");
- return;
+ if (!_slang_write_uniform (pro, location, count, value, GL_INT))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1ivARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform2ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform2ivARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2ivARB");
- return;
+ if (!_slang_write_uniform (pro, location, count, value, GL_INT_VEC2))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2ivARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform3ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform3ivARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3ivARB");
- return;
+ if (!_slang_write_uniform (pro, location, count, value, GL_INT_VEC3))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3ivARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_Uniform4ivARB (GLint location, GLsizei count, const GLint *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniform4ivARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4ivARB");
- return;
+ if (!_slang_write_uniform (pro, location, count, value, GL_INT_VEC4))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4ivARB");
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_UniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix2fvARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix2fvARB");
- return;
+ if (transpose)
+ {
+ GLfloat *trans, *pt;
+ const GLfloat *pv;
+
+ trans = (GLfloat *) _mesa_malloc (count * 4 * sizeof (GLfloat));
+ if (trans == NULL)
+ {
+ _mesa_error (ctx, GL_OUT_OF_MEMORY, "glUniformMatrix2fvARB");
+ return;
+ }
+ for (pt = trans, pv = value; pt != trans + count * 4; pt += 4, pv += 4)
+ {
+ pt[0] = pv[0];
+ pt[1] = pv[2];
+ pt[2] = pv[1];
+ pt[3] = pv[3];
+ }
+ if (!_slang_write_uniform (pro, location, count, trans, GL_FLOAT_MAT2))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix2fvARB");
+ _mesa_free (trans);
+ }
+ else
+ {
+ if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT_MAT2))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix2fvARB");
+ }
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_UniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix3fvARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix3fvARB");
- return;
+ if (transpose)
+ {
+ GLfloat *trans, *pt;
+ const GLfloat *pv;
+
+ trans = (GLfloat *) _mesa_malloc (count * 9 * sizeof (GLfloat));
+ if (trans == NULL)
+ {
+ _mesa_error (ctx, GL_OUT_OF_MEMORY, "glUniformMatrix3fvARB");
+ return;
+ }
+ for (pt = trans, pv = value; pt != trans + count * 9; pt += 9, pv += 9)
+ {
+ pt[0] = pv[0];
+ pt[1] = pv[3];
+ pt[2] = pv[6];
+ pt[3] = pv[1];
+ pt[4] = pv[4];
+ pt[5] = pv[7];
+ pt[6] = pv[2];
+ pt[7] = pv[5];
+ pt[8] = pv[8];
+ }
+ if (!_slang_write_uniform (pro, location, count, trans, GL_FLOAT_MAT3))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix3fvARB");
+ _mesa_free (trans);
+ }
+ else
+ {
+ if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT_MAT3))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix3fvARB");
+ }
}
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_UniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_LINKED_PROGRAM(pro, "glUniformMatrix4fvARB");
- if (ctx->ShaderObjects.CurrentProgram == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix4fvARB");
- return;
+ if (transpose)
+ {
+ GLfloat *trans, *pt;
+ const GLfloat *pv;
+
+ trans = (GLfloat *) _mesa_malloc (count * 16 * sizeof (GLfloat));
+ if (trans == NULL)
+ {
+ _mesa_error (ctx, GL_OUT_OF_MEMORY, "glUniformMatrix4fvARB");
+ return;
+ }
+ for (pt = trans, pv = value; pt != trans + count * 16; pt += 16, pv += 16)
+ {
+ _math_transposef (pt, pv);
+ }
+ if (!_slang_write_uniform (pro, location, count, trans, GL_FLOAT_MAT4))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix4fvARB");
+ _mesa_free (trans);
+ }
+ else
+ {
+ if (!_slang_write_uniform (pro, location, count, value, GL_FLOAT_MAT4))
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix4fvARB");
+ }
}
}
@@ -699,513 +707,342 @@ _mesa_get_object_parameter (GLhandleARB obj, GLenum pname, GLvoid *params, GLboo
GLint *size)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_generic_intf **gen;
- struct gl2_shader_intf **sha;
- struct gl2_program_intf **pro;
GLint *ipar = (GLint *) params;
- /*GLfloat *fpar = (GLfloat *) params;*/
- GLboolean success = GL_TRUE;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB");
- return GL_FALSE;
- }
-
- gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);
- if (gen == NULL)
- {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- return GL_FALSE;
- }
-
- sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
/* set default values */
*integral = GL_TRUE; /* indicates param type, TRUE: GLint, FALSE: GLfloat */
- *size = 1; /* param array size */
+ *size = 1; /* param array size */
switch (pname)
{
case GL_OBJECT_TYPE_ARB:
- *ipar = (**gen).GetType (gen);
- break;
- case GL_OBJECT_SUBTYPE_ARB:
- if (sha != NULL)
- *ipar = (**sha).GetSubType (sha);
- else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
- }
- break;
case GL_OBJECT_DELETE_STATUS_ARB:
- *ipar = (**gen).GetDeleteStatus (gen);
+ case GL_OBJECT_INFO_LOG_LENGTH_ARB:
+ {
+ GET_GENERIC(gen, obj, "glGetObjectParameterivARB");
+
+ if (gen == NULL)
+ return GL_FALSE;
+
+ switch (pname)
+ {
+ case GL_OBJECT_TYPE_ARB:
+ *ipar = (**gen).GetType (gen);
+ break;
+ case GL_OBJECT_DELETE_STATUS_ARB:
+ *ipar = (**gen).GetDeleteStatus (gen);
+ break;
+ case GL_OBJECT_INFO_LOG_LENGTH_ARB:
+ {
+ const GLcharARB *info = (**gen).GetInfoLog (gen);
+
+ if (info == NULL)
+ *ipar = 0;
+ else
+ *ipar = _mesa_strlen (info) + 1;
+ }
+ break;
+ }
+
+ RELEASE_GENERIC(gen);
+ }
break;
+ case GL_OBJECT_SUBTYPE_ARB:
case GL_OBJECT_COMPILE_STATUS_ARB:
- if (sha != NULL)
- *ipar = (**sha).GetCompileStatus (sha);
- else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
+ case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB:
+ {
+ GET_SHADER(sha, obj, "glGetObjectParameterivARB");
+
+ if (sha == NULL)
+ return GL_FALSE;
+
+ switch (pname)
+ {
+ case GL_OBJECT_SUBTYPE_ARB:
+ *ipar = (**sha).GetSubType (sha);
+ break;
+ case GL_OBJECT_COMPILE_STATUS_ARB:
+ *ipar = (**sha).GetCompileStatus (sha);
+ break;
+ case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB:
+ {
+ const GLcharARB *src = (**sha).GetSource (sha);
+
+ if (src == NULL)
+ *ipar = 0;
+ else
+ *ipar = _mesa_strlen (src) + 1;
+ }
+ break;
+ }
+
+ RELEASE_SHADER(sha);
}
break;
case GL_OBJECT_LINK_STATUS_ARB:
- if (pro != NULL)
- *ipar = (**pro).GetLinkStatus (pro);
- else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
- }
- break;
case GL_OBJECT_VALIDATE_STATUS_ARB:
- if (pro != NULL)
- *ipar = (**pro).GetValidateStatus (pro);
- else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
- }
- break;
- case GL_OBJECT_INFO_LOG_LENGTH_ARB:
- {
- const GLcharARB *info = (**gen).GetInfoLog (gen);
- if (info == NULL)
- *ipar = 0;
- else
- *ipar = _mesa_strlen (info) + 1;
- }
- break;
case GL_OBJECT_ATTACHED_OBJECTS_ARB:
- if (pro != NULL)
- *ipar = (**pro)._container.GetAttachedCount ((struct gl2_container_intf **) pro);
- else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
- }
- break;
case GL_OBJECT_ACTIVE_UNIFORMS_ARB:
- if (pro != NULL)
- *ipar = 0; /* TODO */
- else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
- }
- break;
case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB:
- if (pro != NULL)
- *ipar = 0; /* TODO */
- else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
- }
- break;
- case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB:
- if (sha != NULL) {
- const GLcharARB *src = (**sha).GetSource (sha);
- if (src == NULL)
- *ipar = 0;
- else
- *ipar = _mesa_strlen (src) + 1;
- } else {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
- success = GL_FALSE;
+ {
+ GET_PROGRAM(pro, obj, "glGetObjectParameterivARB");
+
+ if (pro == NULL)
+ return GL_FALSE;
+
+ switch (pname)
+ {
+ case GL_OBJECT_LINK_STATUS_ARB:
+ *ipar = (**pro).GetLinkStatus (pro);
+ break;
+ case GL_OBJECT_VALIDATE_STATUS_ARB:
+ *ipar = (**pro).GetValidateStatus (pro);
+ break;
+ case GL_OBJECT_ATTACHED_OBJECTS_ARB:
+ *ipar = (**pro)._container.GetAttachedCount ((I_CONTAINER) pro);
+ break;
+ case GL_OBJECT_ACTIVE_UNIFORMS_ARB:
+ *ipar = _slang_get_active_uniform_count (pro);
+ break;
+ case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB:
+ *ipar = _slang_get_active_uniform_max_length (pro);
+ break;
+ }
+
+ RELEASE_PROGRAM(pro);
}
break;
default:
_mesa_error (ctx, GL_INVALID_ENUM, "glGetObjectParameterivARB");
- success = GL_FALSE;
- break;
+ return GL_FALSE;
}
- (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);
- if (sha != NULL)
- (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
- if (pro != NULL)
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
-
- return success;
+ return GL_TRUE;
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_GetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params)
{
GLboolean integral;
- GLint size, i;
+ GLint size;
assert (sizeof (GLfloat) == sizeof (GLint));
- if (_mesa_get_object_parameter (obj, pname, (GLvoid *) params, &integral, &size) != GL_FALSE)
- if (integral != GL_FALSE)
+ if (_mesa_get_object_parameter (obj, pname, (GLvoid *) params, &integral, &size))
+ if (integral)
+ {
+ GLint i;
+
for (i = 0; i < size; i++)
params[i] = (GLfloat) ((GLint *) params)[i];
+ }
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_GetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params)
{
GLboolean integral;
- GLint size, i;
+ GLint size;
assert (sizeof (GLfloat) == sizeof (GLint));
- if (_mesa_get_object_parameter (obj, pname, (GLvoid *) params, &integral, &size) != GL_FALSE)
- if (integral == GL_FALSE)
+ if (_mesa_get_object_parameter (obj, pname, (GLvoid *) params, &integral, &size))
+ if (!integral)
+ {
+ GLint i;
+
for (i = 0; i < size; i++)
params[i] = (GLint) ((GLfloat *) params)[i];
+ }
}
-static void
+static GLvoid
_mesa_get_string (const GLcharARB *src, GLsizei maxLength, GLsizei *length, GLcharARB *str)
{
GLsizei len;
+ if (maxLength == 0)
+ {
+ if (length != NULL)
+ *length = 0;
+ return;
+ }
+
if (src == NULL)
src = "";
len = _mesa_strlen (src);
- if (len > maxLength)
- {
- len = maxLength;
- /* allocate space for null termination */
- if (len > 0)
- len--;
- }
+ if (len >= maxLength)
+ len = maxLength - 1;
_mesa_memcpy (str, src, len * sizeof (GLcharARB));
- if (maxLength > 0)
- str[len] = '\0';
-
+ str[len] = '\0';
if (length != NULL)
*length = len;
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_GetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_generic_intf **gen;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetInfoLogARB");
- return;
- }
+ GET_GENERIC(gen, obj, "glGetInfoLogARB");
- gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);
- if (gen == NULL)
+ if (gen != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetInfoLogARB");
- return;
+ _mesa_get_string ((**gen).GetInfoLog (gen), maxLength, length, infoLog);
+ RELEASE_GENERIC(gen);
}
-
- _mesa_get_string ((**gen).GetInfoLog (gen), maxLength, length, infoLog);
-
- (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);
}
-void GLAPIENTRY
-_mesa_GetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj)
+GLvoid GLAPIENTRY
+_mesa_GetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count,
+ GLhandleARB *obj)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_container_intf **con;
GLsizei cnt, i;
+ GET_CONTAINER(con, containerObj, "glGetAttachedObjectsARB");
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttachedObjectsARB");
- return;
- }
-
- con = (struct gl2_container_intf **) (**unk).QueryInterface (unk, UIID_CONTAINER);
- if (con == NULL)
+ if (con != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetAttachedObjectsARB");
- return;
- }
+ cnt = (**con).GetAttachedCount (con);
+ if (cnt > maxCount)
+ cnt = maxCount;
+ if (count != NULL)
+ *count = cnt;
- cnt = (**con).GetAttachedCount (con);
- if (cnt > maxCount)
- cnt = maxCount;
-
- for (i = 0; i < cnt; i++)
- {
- struct gl2_generic_intf **x = (**con).GetAttached (con, i);
- obj[i] = (**x).GetName (x);
- (**x)._unknown.Release ((struct gl2_unknown_intf **) x);
+ for (i = 0; i < cnt; i++)
+ {
+ I_GENERIC x = (**con).GetAttached (con, i);
+ obj[i] = (**x).GetName (x);
+ RELEASE_GENERIC(x);
+ }
+ RELEASE_CONTAINER(con);
}
-
- (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
-
- if (count != NULL)
- *count = cnt;
-}
-
-/* XXX */
-GLint _slang_get_uniform_location (struct gl2_program_intf **, const char *);
+}
GLint GLAPIENTRY
_mesa_GetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name)
{
- GET_CURRENT_CONTEXT(ctx);
+ GET_CURRENT_CONTEXT(ctx);
GLint loc = -1;
- GET_LINKED_PROGRAM(programObj, "glGetUniformLocationARB");
-
- if (pro == NULL)
- return -1;
+ GET_LINKED_PROGRAM(pro, programObj, "glGetUniformLocationARB");
- loc = _slang_get_uniform_location (pro, name);
- _RELEASE_PROGRAM(pro);
+ if (pro != NULL)
+ {
+ if (name != NULL && (name[0] != 'g' || name[1] != 'l' || name[2] != '_'))
+ loc = _slang_get_uniform_location (pro, name);
+ RELEASE_PROGRAM(pro);
+ }
return loc;
}
-void GLAPIENTRY
-_mesa_GetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name)
+GLvoid GLAPIENTRY
+_mesa_GetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length,
+ GLint *size, GLenum *type, GLcharARB *name)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
+ GET_PROGRAM(pro, programObj, "glGetActiveUniformARB");
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");
- return;
- }
-
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetActiveUniformARB");
- return;
+ if (index < _slang_get_active_uniform_count (pro))
+ _slang_get_active_uniform (pro, index, maxLength, length, size, type, name);
+ else
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");
+ RELEASE_PROGRAM(pro);
}
-
-/* if (index >= val (OBJECT_ACTIVE_ATTRIBUTES_ARB))
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
- return;
- }*/
-
- /* TODO */
-
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_GetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformfvARB");
- return;
- }
+ GET_LINKED_PROGRAM(pro, programObj, "glGetUniformfvARB");
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
- {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformfvARB");
- return;
- }
-
- if ((**pro).GetLinkStatus (pro) == GL_FALSE)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformfvARB");
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
- return;
+ /* TODO */
+ RELEASE_PROGRAM(pro);
}
-
- /* TODO validate location (OPERATION) */
-
- /* TODO */
-
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_GetUniformivARB (GLhandleARB programObj, GLint location, GLint *params)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformivARB");
- return;
- }
-
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
- {
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformivARB");
- return;
- }
+ GET_LINKED_PROGRAM(pro, programObj, "glGetUniformivARB");
- if ((**pro).GetLinkStatus (pro) == GL_FALSE)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformivARB");
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
- return;
+ /* TODO */
+ RELEASE_PROGRAM(pro);
}
-
- /* TODO validate location (GL_INVALID_OPERATION) */
-
- /* TODO */
-
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_GetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_shader_intf **sha;
+ GET_SHADER(sha, obj, "glGetShaderSourceARB");
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetShaderSourceARB");
- return;
- }
-
- sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
- if (sha == NULL)
+ if (sha != NULL)
{
- _mesa_error (ctx, GL_INVALID_OPERATION, "glGetShaderSourceARB");
- return;
+ _mesa_get_string ((**sha).GetSource (sha), maxLength, length, source);
+ RELEASE_SHADER(sha);
}
-
- _mesa_get_string ((**sha).GetSource (sha), maxLength, length, source);
-
- (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
}
/* GL_ARB_vertex_shader */
-void GLAPIENTRY
+GLvoid GLAPIENTRY
_mesa_BindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
+ GET_PROGRAM(pro, programObj, "glBindAttribLocationARB");
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glBindAttribLocationARB");
- return;
- }
-
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_VALUE, "glBindAttribLocationARB");
- return;
+ if (name != NULL && (name[0] != 'g' || name[1] != 'l' || name[2] != '_'))
+ {
+ /* TODO */
+ }
+ RELEASE_PROGRAM(pro);
}
-
- /* TODO */
-
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
-void GLAPIENTRY
-_mesa_GetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name)
+GLvoid GLAPIENTRY
+_mesa_GetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length,
+ GLint *size, GLenum *type, GLcharARB *name)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveAttribARB");
- return;
- }
+ GET_PROGRAM(pro, programObj, "glGetActiveAttribARB");
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveAttribARB");
- return;
+ /* TODO */
+ RELEASE_PROGRAM(pro);
}
-
- /* TODO */
-
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
}
GLint GLAPIENTRY
_mesa_GetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl2_unknown_intf **unk;
- struct gl2_program_intf **pro;
- GLint loc = 0;
-
- _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
- unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
- _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
-
- if (unk == NULL)
- {
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttribLocationARB");
- return 0;
- }
+ GLint loc = -1;
+ GET_PROGRAM(pro, programObj, "glGetAttribLocationARB");
- pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
- if (pro == NULL)
+ if (pro != NULL)
{
- _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttribLocationARB");
- return 0;
+ if (name != NULL && (name[0] != 'g' || name[1] != 'l' || name[2] != '_'))
+ {
+ /* TODO */
+ }
+ RELEASE_PROGRAM(pro);
}
-
- /* TODO */
-
- (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
return loc;
}
-void
+GLvoid
_mesa_init_shaderobjects (GLcontext *ctx)
{
ctx->ShaderObjects.CurrentProgram = NULL;
diff --git a/src/mesa/shader/shaderobjects.h b/src/mesa/shader/shaderobjects.h
index 7cea462aeed..5a4667d090a 100644
--- a/src/mesa/shader/shaderobjects.h
+++ b/src/mesa/shader/shaderobjects.h
@@ -25,7 +25,7 @@
#ifndef SHADEROBJECTS_H
#define SHADEROBJECTS_H
-#include "mtypes.h"
+#include "context.h"
/**
* gl2 unique interface identifier.
@@ -85,7 +85,12 @@ struct gl2_program_intf
GLboolean (* GetLinkStatus) (struct gl2_program_intf **);
GLboolean (* GetValidateStatus) (struct gl2_program_intf **);
GLvoid (* Link) (struct gl2_program_intf **);
- GLvoid (* Validate) (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);
+ GLvoid (* UpdateFixedVarying) (struct gl2_program_intf **, GLuint, GLvoid *, GLuint, GLuint,
+ GLboolean);
};
struct gl2_fragment_shader_intf
diff --git a/src/mesa/shader/shaderobjects_3dlabs.c b/src/mesa/shader/shaderobjects_3dlabs.c
index 0cfe2756335..6faed114aa3 100755
--- a/src/mesa/shader/shaderobjects_3dlabs.c
+++ b/src/mesa/shader/shaderobjects_3dlabs.c
@@ -31,19 +31,14 @@
/* Set this to 1 when we are ready to use 3dlabs' front-end */
#define USE_3DLABS_FRONTEND 0
-#include "glheader.h"
-#include "shaderobjects.h"
-#include "shaderobjects_3dlabs.h"
-#include "context.h"
-#include "macros.h"
+#include "imports.h"
#include "hash.h"
+#include "shaderobjects.h"
#if USE_3DLABS_FRONTEND
#include "slang_mesa.h"
#include "Public/ShaderLang.h"
#else
-#include "slang_utility.h"
-#include "slang_compile.h"
#include "slang_link.h"
#endif
@@ -840,6 +835,164 @@ _program_Validate (struct gl2_program_intf **intf)
/* TODO validate */
}
+static GLvoid
+write_common_fixed (slang_program *pro, GLuint index, const GLvoid *src, GLuint off, GLuint size)
+{
+ GLuint i;
+
+ for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)
+ {
+ GLuint addr;
+
+ addr = pro->common_fixed_entries[i][index];
+ if (addr != ~0)
+ {
+ GLubyte *dst;
+
+ dst = (GLubyte *) pro->machines[i]->mem + addr + off * size;
+ _mesa_memcpy (dst, src, size);
+ }
+ }
+}
+
+static GLvoid
+write_common_fixed_mat4 (slang_program *pro, GLmatrix *matrix, GLuint off, GLuint i, GLuint ii,
+ GLuint it, GLuint iit)
+{
+ GLfloat mat[16];
+
+ /* we want inverse matrix */
+ if (!matrix->inv)
+ {
+ /* allocate inverse matrix and make it dirty */
+ _math_matrix_alloc_inv (matrix);
+ _math_matrix_loadf (matrix, matrix->m);
+ }
+ _math_matrix_analyse (matrix);
+
+ write_common_fixed (pro, i, matrix->m, off, 16 * sizeof (GLfloat));
+
+ /* inverse */
+ write_common_fixed (pro, ii, matrix->inv, off, 16 * sizeof (GLfloat));
+
+ /* transpose */
+ _math_transposef (mat, matrix->m);
+ write_common_fixed (pro, it, mat, off, 16 * sizeof (GLfloat));
+
+ /* inverse transpose */
+ _math_transposef (mat, matrix->inv);
+ write_common_fixed (pro, iit, mat, off, 16 * sizeof (GLfloat));
+}
+
+static GLvoid
+_program_UpdateFixedUniforms (struct gl2_program_intf **intf)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+ slang_program *pro = &impl->_obj.prog;
+ GLuint i;
+ GLfloat v[9];
+ GLfloat *p;
+
+ /* MODELVIEW matrix */
+ write_common_fixed_mat4 (pro, ctx->ModelviewMatrixStack.Top, 0,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIX,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE);
+
+ /* PROJECTION matrix */
+ write_common_fixed_mat4 (pro, ctx->ProjectionMatrixStack.Top, 0,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIX,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE);
+
+ /* MVP matrix */
+ write_common_fixed_mat4 (pro, &ctx->_ModelProjectMatrix, 0,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE);
+
+ /* TEXTURE matrix */
+ for (i = 0; i < 8; i++)
+ {
+ write_common_fixed_mat4 (pro, ctx->TextureMatrixStack[i].Top, i,
+ SLANG_COMMON_FIXED_TEXTUREMATRIX,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE);
+ }
+
+ /* NORMAL matrix - upper 3x3 inverse transpose of MODELVIEW matrix */
+ p = ctx->ModelviewMatrixStack.Top->inv;
+ v[0] = p[0];
+ v[1] = p[4];
+ v[2] = p[8];
+ v[3] = p[1];
+ v[4] = p[5];
+ v[5] = p[9];
+ v[6] = p[2];
+ v[7] = p[6];
+ v[8] = p[10];
+ write_common_fixed (pro, SLANG_COMMON_FIXED_NORMALMATRIX, v, 0, 9 * sizeof (GLfloat));
+
+ /* XXX: fetch uniform float gl_NormalScale */
+ /* XXX: fetch uniform mat4 gl_ClipPlane */
+ /* XXX: fetch uniform mat4 gl_TextureEnvColor */
+ /* XXX: fetch uniform mat4 gl_EyePlaneS */
+ /* XXX: fetch uniform mat4 gl_EyePlaneT */
+ /* XXX: fetch uniform mat4 gl_EyePlaneR */
+ /* XXX: fetch uniform mat4 gl_EyePlaneQ */
+ /* XXX: fetch uniform mat4 gl_ObjectPlaneS */
+ /* XXX: fetch uniform mat4 gl_ObjectPlaneT */
+ /* XXX: fetch uniform mat4 gl_ObjectPlaneR */
+ /* XXX: fetch uniform mat4 gl_ObjectPlaneQ */
+}
+
+static GLvoid
+_program_UpdateFixedAttribute (struct gl2_program_intf **intf, GLuint index, GLvoid *data,
+ GLuint offset, GLuint size, GLboolean write)
+{
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+ slang_program *pro = &impl->_obj.prog;
+ GLuint addr;
+
+ addr = pro->vertex_fixed_entries[index];
+ if (addr != ~0)
+ {
+ GLubyte *mem;
+
+ mem = (GLubyte *) pro->machines[SLANG_UNIFORM_BINDING_VERTEX]->mem + addr + offset * size;
+ if (write)
+ _mesa_memcpy (mem, data, size);
+ else
+ _mesa_memcpy (data, mem, size);
+ }
+}
+
+static GLvoid
+_program_UpdateFixedVarying (struct gl2_program_intf **intf, GLuint index, GLvoid *data,
+ GLuint offset, GLuint size, GLboolean write)
+{
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+ slang_program *pro = &impl->_obj.prog;
+ GLuint addr;
+
+ addr = pro->fragment_fixed_entries[index];
+ if (addr != ~0)
+ {
+ GLubyte *mem;
+
+ mem = (GLubyte *) pro->machines[SLANG_UNIFORM_BINDING_FRAGMENT]->mem + addr + offset * size;
+ if (write)
+ _mesa_memcpy (mem, data, size);
+ else
+ _mesa_memcpy (data, mem, size);
+ }
+}
+
static struct gl2_program_intf _program_vftbl = {
{
{
@@ -862,7 +1015,10 @@ static struct gl2_program_intf _program_vftbl = {
_program_GetLinkStatus,
_program_GetValidateStatus,
_program_Link,
- _program_Validate
+ _program_Validate,
+ _program_UpdateFixedUniforms,
+ _program_UpdateFixedAttribute,
+ _program_UpdateFixedVarying
};
static void
@@ -1076,195 +1232,37 @@ _mesa_3dlabs_create_program_object (void)
#include "slang_assemble.h"
#include "slang_execute.h"
-static GLubyte *get_address_of (struct gl2_vertex_shader_intf **vs, const char *name)
-{
- struct gl2_vertex_shader_impl *impl;
- slang_translation_unit *unit;
- slang_atom atom;
- slang_variable *var;
-
- impl = (struct gl2_vertex_shader_impl *) vs;
- unit = &impl->_obj._shader.unit;
- atom = slang_atom_pool_atom (unit->atom_pool, name);
- var = _slang_locate_variable (&unit->globals, atom, 1);
- if (var == NULL || var->address == ~0)
- return NULL;
- return (GLubyte *) unit->machine->mem + var->address;
-}
-
-static GLubyte *get_address_of_f (struct gl2_fragment_shader_intf **fs, const char *name)
+int _slang_fetch_discard (struct gl2_program_intf **pro, GLboolean *val)
{
- struct gl2_fragment_shader_impl *impl;
- slang_translation_unit *unit;
- slang_atom atom;
- slang_variable *var;
-
- impl = (struct gl2_fragment_shader_impl *) fs;
- unit = &impl->_obj._shader.unit;
- atom = slang_atom_pool_atom (unit->atom_pool, name);
- var = _slang_locate_variable (&unit->globals, atom, 1);
- if (var == NULL || var->address == ~0)
- return NULL;
- return (GLubyte *) unit->machine->mem + var->address;
-}
-
-static int fetch_mem (struct gl2_vertex_shader_intf **vs, const char *name, GLvoid *val,
- GLuint size, GLuint index, int write)
-{
- GLubyte *data;
-
- data = get_address_of (vs, name);
- if (data == NULL)
- return 0;
- if (write)
- _mesa_memcpy (data + index * size, val, size);
- else
- _mesa_memcpy (val, data + index * size, size);
- return 1;
-}
-
-static int fetch_mem_f (struct gl2_fragment_shader_intf **fs, const char *name, GLvoid *val,
- GLuint size, GLuint index, int write)
-{
- GLubyte *data;
+ struct gl2_program_impl *impl;
- data = get_address_of_f (fs, name);
- if (data == NULL)
- return 0;
- if (write)
- _mesa_memcpy (data + index * size, val, size);
- else
- _mesa_memcpy (val, data + index * size, size);
+ impl = (struct gl2_program_impl *) pro;
+ *val = impl->_obj.prog.machines[SLANG_UNIFORM_BINDING_FRAGMENT]->kill ? GL_TRUE : GL_FALSE;
return 1;
}
-int _slang_fetch_float (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write)
-{
- return fetch_mem (vs, name, val, 4, 0, write);
-}
-
-int _slang_fetch_vec3 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write)
+static GLvoid exec_shader (struct gl2_program_intf **pro, GLuint i)
{
- return fetch_mem (vs, name, val, 12, 0, write);
-}
+ struct gl2_program_impl *impl;
+ slang_program *p;
-int _slang_fetch_vec4 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,
- GLuint index, int write)
-{
- return fetch_mem (vs, name, val, 16, index, write);
-}
+ impl = (struct gl2_program_impl *) pro;
+ p = &impl->_obj.prog;
-int _slang_fetch_vec4_f (struct gl2_fragment_shader_intf **fs, const char *name, GLfloat *val,
- GLuint index, int write)
-{
- return fetch_mem_f (fs, name, val, 16, index, write);
-}
+ slang_machine_init (p->machines[i]);
+ p->machines[i]->ip = p->code[i];
-int _slang_fetch_mat3 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,
- GLuint index, int write)
-{
- return fetch_mem (vs, name, val, 36, index, write);
+ _slang_execute2 (p->assemblies[i], p->machines[i]);
}
-int _slang_fetch_mat4 (struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val,
- GLuint index, int write)
+GLvoid _slang_exec_fragment_shader (struct gl2_program_intf **pro)
{
- return fetch_mem (vs, name, val, 64, index, write);
+ exec_shader (pro, SLANG_UNIFORM_BINDING_FRAGMENT);
}
-int _slang_fetch_discard (struct gl2_fragment_shader_intf **fs, GLboolean *val)
+GLvoid _slang_exec_vertex_shader (struct gl2_program_intf **pro)
{
- struct gl2_fragment_shader_impl *impl;
- slang_translation_unit *unit;
-
- impl = (struct gl2_fragment_shader_impl *) fs;
- unit = &impl->_obj._shader.unit;
- *val = unit->machine->kill ? GL_TRUE : GL_FALSE;
- return 1;
-}
-
-void _slang_exec_vertex_shader (struct gl2_vertex_shader_intf **vs)
-{
- struct gl2_vertex_shader_impl *impl;
- slang_translation_unit *unit;
- slang_atom atom;
- unsigned int i;
-
- impl = (struct gl2_vertex_shader_impl *) vs;
- unit = &impl->_obj._shader.unit;
- atom = slang_atom_pool_atom (unit->atom_pool, "main");
- for (i = 0; i < unit->functions.num_functions; i++)
- if (atom == unit->functions.functions[i].header.a_name)
- break;
- if (i < unit->functions.num_functions)
- {
- slang_function *f;
- slang_assembly_file_restore_point point;
- slang_assemble_ctx A;
-
- f = &unit->functions.functions[i];
- slang_assembly_file_restore_point_save (unit->assembly, &point);
-
- slang_machine_init (unit->machine);
- unit->machine->ip = unit->assembly->count;
-
- A.file = unit->assembly;
- A.mach = unit->machine;
- A.atoms = unit->atom_pool;
- A.space.funcs = &unit->functions;
- A.space.structs = &unit->structs;
- A.space.vars = &unit->globals;
- slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
- slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
- _slang_assemble_function_call (&A, f, NULL, 0, GL_FALSE);
- slang_assembly_file_push (unit->assembly, slang_asm_exit);
-
- _slang_execute2 (unit->assembly, unit->machine);
-
- slang_assembly_file_restore_point_load (unit->assembly, &point);
- }
-}
-
-void _slang_exec_fragment_shader (struct gl2_fragment_shader_intf **fs)
-{
- struct gl2_fragment_shader_impl *impl;
- slang_translation_unit *unit;
- slang_atom atom;
- unsigned int i;
-
- impl = (struct gl2_fragment_shader_impl *) fs;
- unit = &impl->_obj._shader.unit;
- atom = slang_atom_pool_atom (unit->atom_pool, "main");
- for (i = 0; i < unit->functions.num_functions; i++)
- if (atom == unit->functions.functions[i].header.a_name)
- break;
- if (i < unit->functions.num_functions)
- {
- slang_function *f;
- slang_assembly_file_restore_point point;
- slang_assemble_ctx A;
-
- f = &unit->functions.functions[i];
- slang_assembly_file_restore_point_save (unit->assembly, &point);
-
- slang_machine_init (unit->machine);
- unit->machine->ip = unit->assembly->count;
-
- A.file = unit->assembly;
- A.mach = unit->machine;
- A.atoms = unit->atom_pool;
- A.space.funcs = &unit->functions;
- A.space.structs = &unit->structs;
- A.space.vars = &unit->globals;
- slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
- slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
- _slang_assemble_function_call (&A, f, NULL, 0, GL_FALSE);
- slang_assembly_file_push (unit->assembly, slang_asm_exit);
-
- _slang_execute2 (unit->assembly, unit->machine);
-
- slang_assembly_file_restore_point_load (unit->assembly, &point);
- }
+ exec_shader (pro, SLANG_UNIFORM_BINDING_VERTEX);
}
GLint _slang_get_uniform_location (struct gl2_program_intf **pro, const char *name)
@@ -1312,6 +1310,53 @@ GLboolean _slang_write_uniform (struct gl2_program_intf **pro, GLint loc, GLsize
return GL_TRUE;
}
+GLuint _slang_get_active_uniform_count (struct gl2_program_intf **pro)
+{
+ struct gl2_program_impl *impl;
+
+ impl = (struct gl2_program_impl *) pro;
+ return impl->_obj.prog.active_uniforms.count;
+}
+
+GLuint _slang_get_active_uniform_max_length (struct gl2_program_intf **pro)
+{
+ struct gl2_program_impl *impl;
+ GLuint i, len = 0;
+
+ impl = (struct gl2_program_impl *) pro;
+ for (i = 0; i < impl->_obj.prog.active_uniforms.count; i++)
+ {
+ GLuint n = _mesa_strlen (impl->_obj.prog.active_uniforms.table[i].name);
+ if (n > len)
+ len = n;
+ }
+ return len;
+}
+
+GLvoid _slang_get_active_uniform (struct gl2_program_intf **pro, GLuint index, GLsizei maxLength,
+ GLsizei *length, GLint *size, GLenum *type, char *name)
+{
+ struct gl2_program_impl *impl;
+ slang_active_uniform *u;
+ GLsizei len;
+
+ impl = (struct gl2_program_impl *) pro;
+ u = &impl->_obj.prog.active_uniforms.table[index];
+
+ len = _mesa_strlen (u->name);
+ if (len >= maxLength)
+ len = maxLength - 1;
+ _mesa_memcpy (name, u->name, len);
+ name[len] = '\0';
+ if (length != NULL)
+ *length = len;
+ *type = u->quant->u.basic_type;
+ if (u->quant->array_len == 0)
+ *size = 1;
+ else
+ *size = u->quant->array_len;
+}
+
void
_mesa_init_shaderobjects_3dlabs (GLcontext *ctx)
{
diff --git a/src/mesa/shader/shaderobjects_3dlabs.h b/src/mesa/shader/shaderobjects_3dlabs.h
index c18c7ffe943..d82079d8f31 100755
--- a/src/mesa/shader/shaderobjects_3dlabs.h
+++ b/src/mesa/shader/shaderobjects_3dlabs.h
@@ -2,7 +2,7 @@
* Mesa 3-D graphics library
* Version: 6.5
*
- * Copyright (C) 2006 Brian Paul All Rights Reserved.
+ * Copyright (C) 2005-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"),
@@ -25,37 +25,29 @@
#ifndef SHADEROBJECTS_3DLABS_H
#define SHADEROBJECTS_3DLABS_H
-#include "mtypes.h"
+extern int _slang_fetch_discard (struct gl2_program_intf **pro, GLboolean *val);
+extern GLvoid _slang_exec_fragment_shader (struct gl2_program_intf **pro);
-extern int _slang_fetch_float(struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write);
+extern GLvoid _slang_exec_vertex_shader (struct gl2_program_intf **pro);
-extern int _slang_fetch_vec3(struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, int write);
+extern GLint _slang_get_uniform_location (struct gl2_program_intf **pro, const char *name);
-extern int _slang_fetch_vec4(struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, GLuint index, int write);
+extern GLboolean _slang_write_uniform (struct gl2_program_intf **pro, GLint loc, GLsizei count,
+ const GLvoid *data, GLenum type);
-extern int _slang_fetch_vec4_f(struct gl2_fragment_shader_intf **fs, const char *name, GLfloat *val, GLuint index, int write);
+extern GLuint _slang_get_active_uniform_count (struct gl2_program_intf **pro);
-extern int _slang_fetch_mat3(struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, GLuint index, int write);
-
-extern int _slang_fetch_mat4(struct gl2_vertex_shader_intf **vs, const char *name, GLfloat *val, GLuint index, int write);
-
-extern int _slang_fetch_discard(struct gl2_fragment_shader_intf **fs, GLboolean *val);
-
-extern GLint _slang_get_uniform_location(struct gl2_program_intf **pro, const char *name);
-
-extern GLboolean _slang_write_uniform(struct gl2_program_intf **pro, GLint loc, GLsizei count, const GLvoid *data, GLenum type);
-
-extern void _slang_exec_vertex_shader(struct gl2_vertex_shader_intf **vs);
-
-extern void _slang_exec_fragment_shader(struct gl2_fragment_shader_intf **fs);
+extern GLuint _slang_get_active_uniform_max_length (struct gl2_program_intf **pro);
+extern GLvoid _slang_get_active_uniform (struct gl2_program_intf **pro, GLuint index, GLsizei maxLength,
+ GLsizei *length, GLint *size, GLenum *type, char *name);
extern GLhandleARB
_mesa_3dlabs_create_shader_object (GLenum);
extern GLhandleARB
-_mesa_3dlabs_create_program_object (void);
+_mesa_3dlabs_create_program_object (GLvoid);
extern void
_mesa_init_shaderobjects_3dlabs (GLcontext *ctx);
diff --git a/src/mesa/shader/slang/slang_assemble.c b/src/mesa/shader/slang/slang_assemble.c
index 2e1e13d1f5d..b24d3183841 100644
--- a/src/mesa/shader/slang/slang_assemble.c
+++ b/src/mesa/shader/slang/slang_assemble.c
@@ -29,13 +29,9 @@
*/
#include "imports.h"
-#include "slang_utility.h"
#include "slang_assemble.h"
+#include "slang_compile.h"
#include "slang_storage.h"
-#include "slang_assemble_typeinfo.h"
-#include "slang_assemble_conditional.h"
-#include "slang_assemble_assignment.h"
-#include "slang_execute.h"
/* slang_assembly */
@@ -1138,7 +1134,7 @@ GLboolean _slang_assemble_operation (slang_assemble_ctx *A, slang_operation *op,
/* push the variable's address */
if (var->global)
{
- if (!PLAB (A->file, slang_asm_addr_push, var->address))
+ if (!PLAB (A->file, slang_asm_global_addr, var->address))
return GL_FALSE;
}
else
diff --git a/src/mesa/shader/slang/slang_assemble.h b/src/mesa/shader/slang/slang_assemble.h
index 99c407d75ae..ddb59f83a1e 100644
--- a/src/mesa/shader/slang/slang_assemble.h
+++ b/src/mesa/shader/slang/slang_assemble.h
@@ -25,7 +25,7 @@
#if !defined SLANG_ASSEMBLE_H
#define SLANG_ASSEMBLE_H
-#include "slang_compile.h"
+#include "slang_utility.h"
#if defined __cplusplus
extern "C" {
@@ -81,6 +81,7 @@ typedef enum slang_assembly_type_
slang_asm_local_alloc,
slang_asm_local_free,
slang_asm_local_addr,
+ slang_asm_global_addr,
slang_asm_call,
slang_asm_return,
slang_asm_discard,
@@ -174,27 +175,33 @@ typedef struct slang_assemble_ctx_
slang_swizzle swz;
} slang_assemble_ctx;
-slang_function *_slang_locate_function (slang_function_scope *funcs, slang_atom a_name,
- slang_operation *params, GLuint num_params, slang_assembly_name_space *space,
+struct slang_function_ *_slang_locate_function (struct slang_function_scope_ *funcs, slang_atom name,
+ struct slang_operation_ *params, GLuint num_params, slang_assembly_name_space *space,
slang_atom_pool *);
GLboolean _slang_assemble_function (slang_assemble_ctx *, struct slang_function_ *);
-GLboolean _slang_cleanup_stack (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_cleanup_stack (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_dereference (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_dereference (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_function_call (slang_assemble_ctx *, slang_function *, slang_operation *,
- GLuint, GLboolean);
+GLboolean _slang_assemble_function_call (slang_assemble_ctx *, struct slang_function_ *,
+ struct slang_operation_ *, GLuint, GLboolean);
-GLboolean _slang_assemble_function_call_name (slang_assemble_ctx *, const char *, slang_operation *,
- GLuint, GLboolean);
+GLboolean _slang_assemble_function_call_name (slang_assemble_ctx *, const char *,
+ struct slang_operation_ *, GLuint, GLboolean);
-GLboolean _slang_assemble_operation (slang_assemble_ctx *, struct slang_operation_ *, slang_ref_type);
+GLboolean _slang_assemble_operation (slang_assemble_ctx *, struct slang_operation_ *,
+ slang_ref_type);
#ifdef __cplusplus
}
#endif
+#include "slang_assemble_assignment.h"
+#include "slang_assemble_typeinfo.h"
+#include "slang_assemble_constructor.h"
+#include "slang_assemble_conditional.h"
+
#endif
diff --git a/src/mesa/shader/slang/slang_assemble_assignment.c b/src/mesa/shader/slang/slang_assemble_assignment.c
index d4799b05be1..868724ed3e5 100644
--- a/src/mesa/shader/slang/slang_assemble_assignment.c
+++ b/src/mesa/shader/slang/slang_assemble_assignment.c
@@ -29,11 +29,8 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_assignment.h"
-#include "slang_assemble_typeinfo.h"
+#include "slang_assemble.h"
#include "slang_storage.h"
-#include "slang_execute.h"
/*
* _slang_assemble_assignment()
diff --git a/src/mesa/shader/slang/slang_assemble_assignment.h b/src/mesa/shader/slang/slang_assemble_assignment.h
index ef05ebd71d4..111459be920 100644
--- a/src/mesa/shader/slang/slang_assemble_assignment.h
+++ b/src/mesa/shader/slang/slang_assemble_assignment.h
@@ -25,15 +25,13 @@
#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H
#define SLANG_ASSEMBLE_ASSIGNMENT_H
-#include "slang_assemble.h"
-
#if defined __cplusplus
extern "C" {
#endif
-GLboolean _slang_assemble_assignment (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_assignment (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_assign (slang_assemble_ctx *, slang_operation *, const char *,
+GLboolean _slang_assemble_assign (slang_assemble_ctx *, struct slang_operation_ *, const char *,
slang_ref_type);
#ifdef __cplusplus
diff --git a/src/mesa/shader/slang/slang_assemble_conditional.c b/src/mesa/shader/slang/slang_assemble_conditional.c
index 115e292609e..b29d0cf30c5 100644
--- a/src/mesa/shader/slang/slang_assemble_conditional.c
+++ b/src/mesa/shader/slang/slang_assemble_conditional.c
@@ -29,10 +29,8 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_conditional.h"
#include "slang_assemble.h"
-#include "slang_execute.h"
+#include "slang_compile.h"
/*
* _slang_assemble_logicaland()
diff --git a/src/mesa/shader/slang/slang_assemble_conditional.h b/src/mesa/shader/slang/slang_assemble_conditional.h
index 9ea1ed265ea..ef0c2172c93 100644
--- a/src/mesa/shader/slang/slang_assemble_conditional.h
+++ b/src/mesa/shader/slang/slang_assemble_conditional.h
@@ -25,25 +25,23 @@
#if !defined SLANG_ASSEMBLE_CONDITIONAL_H
#define SLANG_ASSEMBLE_CONDITIONAL_H
-#include "slang_assemble.h"
-
#if defined __cplusplus
extern "C" {
#endif
-GLboolean _slang_assemble_logicaland (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_logicaland (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_logicalor (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_logicalor (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_select (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_select (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_for (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_for (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_do (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_do (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_while (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_while (slang_assemble_ctx *, struct slang_operation_ *);
-GLboolean _slang_assemble_if (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_if (slang_assemble_ctx *, struct slang_operation_ *);
#ifdef __cplusplus
}
diff --git a/src/mesa/shader/slang/slang_assemble_constructor.c b/src/mesa/shader/slang/slang_assemble_constructor.c
index 278d490d9d2..5a8addeae0f 100644
--- a/src/mesa/shader/slang/slang_assemble_constructor.c
+++ b/src/mesa/shader/slang/slang_assemble_constructor.c
@@ -29,9 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_constructor.h"
-#include "slang_assemble_typeinfo.h"
+#include "slang_assemble.h"
#include "slang_storage.h"
/* _slang_is_swizzle() */
diff --git a/src/mesa/shader/slang/slang_assemble_constructor.h b/src/mesa/shader/slang/slang_assemble_constructor.h
index 3b556379978..4bd120c4a81 100644
--- a/src/mesa/shader/slang/slang_assemble_constructor.h
+++ b/src/mesa/shader/slang/slang_assemble_constructor.h
@@ -25,9 +25,6 @@
#if !defined SLANG_ASSEMBLE_CONSTRUCTOR_H
#define SLANG_ASSEMBLE_CONSTRUCTOR_H
-#include "slang_assemble.h"
-#include "slang_compile.h"
-
#if defined __cplusplus
extern "C" {
#endif
@@ -54,7 +51,7 @@ GLboolean _slang_is_swizzle_mask (const slang_swizzle *swz, GLuint rows);
*/
GLvoid _slang_multiply_swizzles (slang_swizzle *, const slang_swizzle *, const slang_swizzle *);
-GLboolean _slang_assemble_constructor (slang_assemble_ctx *, slang_operation *);
+GLboolean _slang_assemble_constructor (slang_assemble_ctx *, struct slang_operation_ *);
GLboolean _slang_assemble_constructor_from_swizzle (slang_assemble_ctx *, const slang_swizzle *,
slang_type_specifier *, slang_type_specifier *);
diff --git a/src/mesa/shader/slang/slang_assemble_typeinfo.c b/src/mesa/shader/slang/slang_assemble_typeinfo.c
index 48fba8ff612..8c5275f7d5b 100644
--- a/src/mesa/shader/slang/slang_assemble_typeinfo.c
+++ b/src/mesa/shader/slang/slang_assemble_typeinfo.c
@@ -29,22 +29,103 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_assemble_typeinfo.h"
+#include "slang_assemble.h"
+#include "slang_compile.h"
+
+/*
+ * slang_type_specifier
+ */
+
+GLvoid slang_type_specifier_ctr (slang_type_specifier *self)
+{
+ self->type = slang_spec_void;
+ self->_struct = NULL;
+ self->_array = NULL;
+}
+
+GLvoid slang_type_specifier_dtr (slang_type_specifier *self)
+{
+ if (self->_struct != NULL)
+ {
+ slang_struct_destruct (self->_struct);
+ slang_alloc_free (self->_struct);
+ }
+ if (self->_array != NULL)
+ {
+ slang_type_specifier_dtr (self->_array);
+ slang_alloc_free (self->_array);
+ }
+}
+
+GLboolean slang_type_specifier_copy (slang_type_specifier *x, const slang_type_specifier *y)
+{
+ slang_type_specifier z;
+
+ slang_type_specifier_ctr (&z);
+ z.type = y->type;
+ if (z.type == slang_spec_struct)
+ {
+ z._struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
+ if (z._struct == NULL)
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ if (!slang_struct_construct (z._struct))
+ {
+ slang_alloc_free (z._struct);
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ if (!slang_struct_copy (z._struct, y->_struct))
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ }
+ else if (z.type == slang_spec_array)
+ {
+ z._array = (slang_type_specifier *) slang_alloc_malloc (sizeof (slang_type_specifier));
+ if (z._array == NULL)
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ slang_type_specifier_ctr (z._array);
+ if (!slang_type_specifier_copy (z._array, y->_array))
+ {
+ slang_type_specifier_dtr (&z);
+ return GL_FALSE;
+ }
+ }
+ slang_type_specifier_dtr (x);
+ *x = z;
+ return GL_TRUE;
+}
+
+GLboolean slang_type_specifier_equal (const slang_type_specifier *x, const slang_type_specifier *y)
+{
+ if (x->type != y->type)
+ return 0;
+ if (x->type == slang_spec_struct)
+ return slang_struct_equal (x->_struct, y->_struct);
+ if (x->type == slang_spec_array)
+ return slang_type_specifier_equal (x->_array, y->_array);
+ return 1;
+}
/* slang_assembly_typeinfo */
GLboolean slang_assembly_typeinfo_construct (slang_assembly_typeinfo *ti)
{
- if (!slang_type_specifier_construct (&ti->spec))
- return GL_FALSE;
+ slang_type_specifier_ctr (&ti->spec);
ti->array_len = 0;
return GL_TRUE;
}
GLvoid slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *ti)
{
- slang_type_specifier_destruct (&ti->spec);
+ slang_type_specifier_dtr (&ti->spec);
}
/* _slang_typeof_operation() */
diff --git a/src/mesa/shader/slang/slang_assemble_typeinfo.h b/src/mesa/shader/slang/slang_assemble_typeinfo.h
index b189dbed734..257793990b9 100644
--- a/src/mesa/shader/slang/slang_assemble_typeinfo.h
+++ b/src/mesa/shader/slang/slang_assemble_typeinfo.h
@@ -25,13 +25,50 @@
#if !defined SLANG_ASSEMBLE_TYPEINFO_H
#define SLANG_ASSEMBLE_TYPEINFO_H
-#include "slang_assemble_constructor.h"
-#include "slang_compile.h"
-
#if defined __cplusplus
extern "C" {
#endif
+typedef enum slang_type_specifier_type_
+{
+ slang_spec_void,
+ slang_spec_bool,
+ slang_spec_bvec2,
+ slang_spec_bvec3,
+ slang_spec_bvec4,
+ slang_spec_int,
+ slang_spec_ivec2,
+ slang_spec_ivec3,
+ slang_spec_ivec4,
+ slang_spec_float,
+ slang_spec_vec2,
+ slang_spec_vec3,
+ slang_spec_vec4,
+ slang_spec_mat2,
+ slang_spec_mat3,
+ slang_spec_mat4,
+ slang_spec_sampler1D,
+ slang_spec_sampler2D,
+ slang_spec_sampler3D,
+ slang_spec_samplerCube,
+ slang_spec_sampler1DShadow,
+ slang_spec_sampler2DShadow,
+ slang_spec_struct,
+ slang_spec_array
+} slang_type_specifier_type;
+
+typedef struct slang_type_specifier_
+{
+ slang_type_specifier_type type;
+ struct slang_struct_ *_struct; /* type: spec_struct */
+ struct slang_type_specifier_ *_array; /* type: spec_array */
+} slang_type_specifier;
+
+GLvoid slang_type_specifier_ctr (slang_type_specifier *);
+GLvoid slang_type_specifier_dtr (slang_type_specifier *);
+GLboolean slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
+GLboolean slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
+
typedef struct slang_assembly_typeinfo_
{
GLboolean can_be_referenced;
@@ -49,8 +86,9 @@ GLvoid slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
* Returns GL_TRUE on success.
* Returns GL_FALSE otherwise.
*/
-GLboolean _slang_typeof_operation (slang_assemble_ctx *, slang_operation *, slang_assembly_typeinfo *);
-GLboolean _slang_typeof_operation_ (slang_operation *, slang_assembly_name_space *,
+GLboolean _slang_typeof_operation (slang_assemble_ctx *, struct slang_operation_ *,
+ slang_assembly_typeinfo *);
+GLboolean _slang_typeof_operation_ (struct slang_operation_ *, slang_assembly_name_space *,
slang_assembly_typeinfo *, slang_atom_pool *);
/*
@@ -58,8 +96,9 @@ GLboolean _slang_typeof_operation_ (slang_operation *, slang_assembly_name_space
* Returns GL_TRUE on success, even if the function was not found.
* Returns GL_FALSE otherwise.
*/
-GLboolean _slang_typeof_function (slang_atom a_name, slang_operation *params, GLuint num_params,
- slang_assembly_name_space *, slang_type_specifier *spec, GLboolean *exists, slang_atom_pool *);
+GLboolean _slang_typeof_function (slang_atom a_name, struct slang_operation_ *params,
+ GLuint num_params, slang_assembly_name_space *, slang_type_specifier *spec, GLboolean *exists,
+ slang_atom_pool *);
GLboolean _slang_type_is_matrix (slang_type_specifier_type);
diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c
index 54aca6dd79d..5576821411f 100644
--- a/src/mesa/shader/slang/slang_compile.c
+++ b/src/mesa/shader/slang/slang_compile.c
@@ -29,13 +29,10 @@
*/
#include "imports.h"
-#include "grammar_mesa.h"
-#include "slang_utility.h"
-#include "slang_compile.h"
-#include "slang_preprocess.h"
-#include "slang_storage.h"
-#include "slang_assemble.h"
-#include "slang_execute.h"
+#include "grammar_mesa.h"
+#include "slang_compile.h"
+#include "slang_preprocess.h"
+#include "slang_storage.h"
/*
* This is a straightforward implementation of the slang front-end compiler.
@@ -83,7 +80,7 @@ int slang_translation_unit_construct (slang_translation_unit *unit)
slang_alloc_free (unit->assembly);
return 0;
}
- slang_machine_init (unit->machine);
+ slang_machine_ctr (unit->machine);
unit->atom_pool = (slang_atom_pool *) slang_alloc_malloc (sizeof (slang_atom_pool));
if (unit->atom_pool == NULL)
{
@@ -136,7 +133,7 @@ int slang_translation_unit_construct2 (slang_translation_unit *unit, slang_assem
unit->atom_pool = atoms;
unit->free_atom_pool = 0;
slang_export_data_table_ctr (&unit->exp_data);
- slang_active_uniforms_ctr (&unit->uniforms);
+ slang_export_code_table_ctr (&unit->exp_code);
return 1;
}
@@ -152,15 +149,18 @@ void slang_translation_unit_destruct (slang_translation_unit *unit)
}
if (unit->free_global_pool)
slang_alloc_free (unit->global_pool);
- if (unit->free_machine)
- slang_alloc_free (unit->machine);
+ if (unit->free_machine)
+ {
+ slang_machine_dtr (unit->machine);
+ slang_alloc_free (unit->machine);
+ }
if (unit->free_atom_pool)
{
slang_atom_pool_destruct (unit->atom_pool);
slang_alloc_free (unit->atom_pool);
}
- slang_active_uniforms_dtr (&unit->uniforms);
- slang_export_data_table_dtr (&unit->exp_data);
+ slang_export_data_table_dtr (&unit->exp_data);
+ slang_export_code_table_ctr (&unit->exp_code);
}
/* slang_info_log */
@@ -407,13 +407,7 @@ static GLboolean convert_to_array (slang_parse_ctx *C, slang_variable *var,
slang_info_log_memory (C->L);
return GL_FALSE;
}
- if (!slang_type_specifier_construct (var->type.specifier._array))
- {
- slang_alloc_free (var->type.specifier._array);
- var->type.specifier._array = NULL;
- slang_info_log_memory (C->L);
- return GL_FALSE;
- }
+ slang_type_specifier_ctr (var->type.specifier._array);
return slang_type_specifier_copy (var->type.specifier._array, sp);
}
@@ -518,14 +512,13 @@ static int parse_struct (slang_parse_ctx *C, slang_output_ctx *O, slang_struct *
{
slang_type_specifier sp;
- if (!slang_type_specifier_construct (&sp))
- return 0;
+ slang_type_specifier_ctr (&sp);
if (!parse_struct_field (C, O, *st, &sp))
{
- slang_type_specifier_destruct (&sp);
+ slang_type_specifier_dtr (&sp);
return 0;
}
- slang_type_specifier_destruct (&sp);
+ slang_type_specifier_dtr (&sp);
}
while (*C->I++ != FIELD_NONE);
@@ -1320,19 +1313,18 @@ static int parse_parameter_declaration (slang_parse_ctx *C, slang_output_ctx *O,
{
slang_type_specifier p;
- if (!slang_type_specifier_construct (&p))
- return GL_FALSE;
+ slang_type_specifier_ctr (&p);
if (!slang_type_specifier_copy (&p, &param->type.specifier))
{
- slang_type_specifier_destruct (&p);
+ slang_type_specifier_dtr (&p);
return GL_FALSE;
}
if (!convert_to_array (C, param, &p))
{
- slang_type_specifier_destruct (&p);
+ slang_type_specifier_dtr (&p);
return GL_FALSE;
}
- slang_type_specifier_destruct (&p);
+ slang_type_specifier_dtr (&p);
if (!parse_array_len (C, O, &param->array_len))
return GL_FALSE;
}
@@ -2102,7 +2094,12 @@ static int compile (grammar *id, slang_translation_unit *builtin_units, int *com
return 0;
return 1;
-}
+}
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+/* XXX */
+GLboolean _slang_x86_codegen (slang_machine *, slang_assembly_file *, GLuint);
+#endif
int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit_type type,
slang_info_log *log)
@@ -2136,11 +2133,20 @@ int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit
if (!success)
return 0;
+
unit->exp_data.atoms = unit->atom_pool;
if (!_slang_build_export_data_table (&unit->exp_data, &unit->globals))
return 0;
- if (!_slang_gather_active_uniforms (&unit->uniforms, &unit->exp_data))
- return 0;
+
+ unit->exp_code.atoms = unit->atom_pool;
+ if (!_slang_build_export_code_table (&unit->exp_code, &unit->functions, unit))
+ return 0;
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ /* XXX: lookup the @main label */
+ if (!_slang_x86_codegen (unit->machine, unit->assembly, unit->exp_code.entries[0].address))
+ return 0;
+#endif
return 1;
}
diff --git a/src/mesa/shader/slang/slang_compile.h b/src/mesa/shader/slang/slang_compile.h
index 7695235c21c..cbf0bf907a1 100644
--- a/src/mesa/shader/slang/slang_compile.h
+++ b/src/mesa/shader/slang/slang_compile.h
@@ -25,6 +25,8 @@
#if !defined SLANG_COMPILE_H
#define SLANG_COMPILE_H
+#include "slang_export.h"
+#include "slang_execute.h"
#include "slang_compile_variable.h"
#include "slang_compile_struct.h"
#include "slang_compile_operation.h"
@@ -53,21 +55,21 @@ typedef struct slang_translation_unit_
slang_function_scope functions;
slang_struct_scope structs;
slang_unit_type type;
- struct slang_assembly_file_ *assembly;
+ slang_assembly_file *assembly;
int free_assembly;
slang_var_pool *global_pool;
int free_global_pool;
- struct slang_machine_ *machine;
+ slang_machine *machine;
int free_machine;
slang_atom_pool *atom_pool;
int free_atom_pool;
slang_export_data_table exp_data;
- slang_active_uniforms uniforms;
+ slang_export_code_table exp_code;
} slang_translation_unit;
int slang_translation_unit_construct (slang_translation_unit *);
-int slang_translation_unit_construct2 (slang_translation_unit *, struct slang_assembly_file_ *,
- slang_var_pool *, struct slang_machine_ *, slang_atom_pool *);
+int slang_translation_unit_construct2 (slang_translation_unit *, slang_assembly_file *,
+ slang_var_pool *, slang_machine *, slang_atom_pool *);
void slang_translation_unit_destruct (slang_translation_unit *);
typedef struct slang_info_log_
diff --git a/src/mesa/shader/slang/slang_compile_function.c b/src/mesa/shader/slang/slang_compile_function.c
index 5edba72cf77..50828d0b076 100644
--- a/src/mesa/shader/slang/slang_compile_function.c
+++ b/src/mesa/shader/slang/slang_compile_function.c
@@ -29,10 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_operation.h"
-#include "slang_compile_function.h"
+#include "slang_compile.h"
/* slang_fixup_table */
@@ -146,3 +143,48 @@ slang_function *slang_function_scope_find (slang_function_scope *funcs, slang_fu
return NULL;
}
+/*
+ * _slang_build_export_code_table()
+ */
+
+GLboolean _slang_build_export_code_table (slang_export_code_table *tbl, slang_function_scope *funs,
+ slang_translation_unit *unit)
+{
+ slang_atom main;
+ GLuint i;
+
+ main = slang_atom_pool_atom (tbl->atoms, "main");
+ if (main == SLANG_ATOM_NULL)
+ return GL_FALSE;
+
+ for (i = 0; i < funs->num_functions; i++)
+ {
+ if (funs->functions[i].header.a_name == main)
+ {
+ slang_function *fun = &funs->functions[i];
+ slang_export_code_entry *e;
+ slang_assemble_ctx A;
+
+ e = slang_export_code_table_add (tbl);
+ if (e == NULL)
+ return GL_FALSE;
+ e->address = unit->assembly->count;
+ e->name = slang_atom_pool_atom (tbl->atoms, "@main");
+ if (e->name == SLANG_ATOM_NULL)
+ return GL_FALSE;
+
+ A.file = unit->assembly;
+ A.mach = unit->machine;
+ A.atoms = unit->atom_pool;
+ A.space.funcs = &unit->functions;
+ A.space.structs = &unit->structs;
+ A.space.vars = &unit->globals;
+ slang_assembly_file_push_label (unit->assembly, slang_asm_local_alloc, 20);
+ slang_assembly_file_push_label (unit->assembly, slang_asm_enter, 20);
+ _slang_assemble_function_call (&A, fun, NULL, 0, GL_FALSE);
+ slang_assembly_file_push (unit->assembly, slang_asm_exit);
+ }
+ }
+ return GL_TRUE;
+}
+
diff --git a/src/mesa/shader/slang/slang_compile_function.h b/src/mesa/shader/slang/slang_compile_function.h
index d1208817cfa..2ad1d053b01 100644
--- a/src/mesa/shader/slang/slang_compile_function.h
+++ b/src/mesa/shader/slang/slang_compile_function.h
@@ -71,6 +71,9 @@ void slang_function_scope_destruct (slang_function_scope *);
int slang_function_scope_find_by_name (slang_function_scope *, slang_atom, int);
slang_function *slang_function_scope_find (slang_function_scope *, slang_function *, int);
+GLboolean _slang_build_export_code_table (slang_export_code_table *, slang_function_scope *,
+ struct slang_translation_unit_ *);
+
#ifdef __cplusplus
}
#endif
diff --git a/src/mesa/shader/slang/slang_compile_operation.c b/src/mesa/shader/slang/slang_compile_operation.c
index 6783f1dc78d..8af8d1f82be 100644
--- a/src/mesa/shader/slang/slang_compile_operation.c
+++ b/src/mesa/shader/slang/slang_compile_operation.c
@@ -29,9 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_operation.h"
+#include "slang_compile.h"
/* slang_operation */
diff --git a/src/mesa/shader/slang/slang_compile_struct.c b/src/mesa/shader/slang/slang_compile_struct.c
index 30c15ffd5d8..627f0597e1c 100644
--- a/src/mesa/shader/slang/slang_compile_struct.c
+++ b/src/mesa/shader/slang/slang_compile_struct.c
@@ -29,9 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_struct.h"
+#include "slang_compile.h"
/* slang_struct_scope */
diff --git a/src/mesa/shader/slang/slang_compile_variable.c b/src/mesa/shader/slang/slang_compile_variable.c
index 6f56872b593..0c8f6c57276 100644
--- a/src/mesa/shader/slang/slang_compile_variable.c
+++ b/src/mesa/shader/slang/slang_compile_variable.c
@@ -29,10 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile_variable.h"
-#include "slang_compile_struct.h"
-#include "slang_compile_operation.h"
+#include "slang_compile.h"
/* slang_type_specifier_type */
@@ -92,106 +89,18 @@ const char *slang_type_specifier_type_to_string (slang_type_specifier_type type)
return p->name;
}
-/* slang_type_specifier */
-
-int slang_type_specifier_construct (slang_type_specifier *spec)
-{
- spec->type = slang_spec_void;
- spec->_struct = NULL;
- spec->_array = NULL;
- return 1;
-}
-
-void slang_type_specifier_destruct (slang_type_specifier *spec)
-{
- if (spec->_struct != NULL)
- {
- slang_struct_destruct (spec->_struct);
- slang_alloc_free (spec->_struct);
- }
- if (spec->_array != NULL)
- {
- slang_type_specifier_destruct (spec->_array);
- slang_alloc_free (spec->_array);
- }
-}
-
-int slang_type_specifier_copy (slang_type_specifier *x, const slang_type_specifier *y)
-{
- slang_type_specifier z;
-
- if (!slang_type_specifier_construct (&z))
- return 0;
- z.type = y->type;
- if (z.type == slang_spec_struct)
- {
- z._struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
- if (z._struct == NULL)
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_struct_construct (z._struct))
- {
- slang_alloc_free (z._struct);
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_struct_copy (z._struct, y->_struct))
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- }
- else if (z.type == slang_spec_array)
- {
- z._array = (slang_type_specifier *) slang_alloc_malloc (sizeof (slang_type_specifier));
- if (z._array == NULL)
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_type_specifier_construct (z._array))
- {
- slang_alloc_free (z._array);
- slang_type_specifier_destruct (&z);
- return 0;
- }
- if (!slang_type_specifier_copy (z._array, y->_array))
- {
- slang_type_specifier_destruct (&z);
- return 0;
- }
- }
- slang_type_specifier_destruct (x);
- *x = z;
- return 1;
-}
-
-int slang_type_specifier_equal (const slang_type_specifier *x, const slang_type_specifier *y)
-{
- if (x->type != y->type)
- return 0;
- if (x->type == slang_spec_struct)
- return slang_struct_equal (x->_struct, y->_struct);
- if (x->type == slang_spec_array)
- return slang_type_specifier_equal (x->_array, y->_array);
- return 1;
-}
-
/* slang_fully_specified_type */
int slang_fully_specified_type_construct (slang_fully_specified_type *type)
{
type->qualifier = slang_qual_none;
- if (!slang_type_specifier_construct (&type->specifier))
- return 0;
+ slang_type_specifier_ctr (&type->specifier);
return 1;
}
void slang_fully_specified_type_destruct (slang_fully_specified_type *type)
{
- slang_type_specifier_destruct (&type->specifier);
+ slang_type_specifier_dtr (&type->specifier);
}
int slang_fully_specified_type_copy (slang_fully_specified_type *x, const slang_fully_specified_type *y)
@@ -341,41 +250,9 @@ slang_variable *_slang_locate_variable (slang_variable_scope *scope, slang_atom
}
/*
- * slang_active_uniforms
+ * _slang_build_export_data_table()
*/
-GLvoid slang_active_uniforms_ctr (slang_active_uniforms *self)
-{
- self->table = NULL;
- self->count = 0;
-}
-
-GLvoid slang_active_uniforms_dtr (slang_active_uniforms *self)
-{
- GLuint i;
-
- for (i = 0; i < self->count; i++)
- slang_alloc_free (self->table[i].name);
- slang_alloc_free (self->table);
-}
-
-GLboolean slang_active_uniforms_add (slang_active_uniforms *self, slang_export_data_quant *q,
- const char *name)
-{
- const GLuint n = self->count;
-
- self->table = (slang_active_uniform *) slang_alloc_realloc (self->table,
- n * sizeof (slang_active_uniform), (n + 1) * sizeof (slang_active_uniform));
- if (self->table == NULL)
- return GL_FALSE;
- self->table[n].quant = q;
- self->table[n].name = slang_string_duplicate (name);
- if (self->table[n].name == NULL)
- return GL_FALSE;
- self->count++;
- return GL_TRUE;
-}
-
static GLenum gl_type_from_specifier (const slang_type_specifier *type)
{
switch (type->type)
@@ -469,17 +346,20 @@ GLboolean _slang_build_export_data_table (slang_export_data_table *tbl, slang_va
for (i = 0; i < vars->num_variables; i++)
{
slang_variable *var = &vars->variables[i];
-
+ slang_export_data_entry *e;
+
+ e = slang_export_data_table_add (tbl);
+ if (e == NULL)
+ return GL_FALSE;
+ if (!build_quant (&e->quant, var))
+ return GL_FALSE;
if (var->type.qualifier == slang_qual_uniform)
- {
- slang_export_data_entry *e = slang_export_data_table_add (tbl);
- if (e == NULL)
- return GL_FALSE;
- if (!build_quant (&e->quant, var))
- return GL_FALSE;
e->access = slang_exp_uniform;
- e->address = var->address;
- }
+ else if (var->type.qualifier == slang_qual_attribute)
+ e->access = slang_exp_attribute;
+ else
+ e->access = slang_exp_varying;
+ e->address = var->address;
}
if (vars->outer_scope != NULL)
@@ -487,45 +367,3 @@ GLboolean _slang_build_export_data_table (slang_export_data_table *tbl, slang_va
return GL_TRUE;
}
-static GLboolean insert_uniform (slang_active_uniforms *u, slang_export_data_quant *q, char *name,
- slang_atom_pool *atoms)
-{
- slang_string_concat (name, slang_atom_pool_id (atoms, q->name));
- if (q->array_len != 0)
- slang_string_concat (name, "[0]");
-
- if (q->structure != NULL)
- {
- GLuint save, i;
-
- slang_string_concat (name, ".");
- save = slang_string_length (name);
-
- for (i = 0; i < q->u.field_count; i++)
- {
- if (!insert_uniform (u, &q->structure[i], name, atoms))
- return GL_FALSE;
- name[save] = '\0';
- }
-
- return GL_TRUE;
- }
-
- return slang_active_uniforms_add (u, q, name);
-}
-
-GLboolean _slang_gather_active_uniforms (slang_active_uniforms *u, slang_export_data_table *tbl)
-{
- GLuint i;
-
- for (i = 0; i < tbl->count; i++)
- {
- char name[1024] = "";
-
- if (!insert_uniform (u, &tbl->entries[i].quant, name, tbl->atoms))
- return GL_FALSE;
- }
-
- return GL_TRUE;
-}
-
diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h
index 4261dd16896..6d2e23702f5 100644
--- a/src/mesa/shader/slang/slang_compile_variable.h
+++ b/src/mesa/shader/slang/slang_compile_variable.h
@@ -25,8 +25,6 @@
#if !defined SLANG_COMPILE_VARIABLE_H
#define SLANG_COMPILE_VARIABLE_H
-#include "slang_export.h"
-
#if defined __cplusplus
extern "C" {
#endif
@@ -44,49 +42,9 @@ typedef enum slang_type_qualifier_
slang_qual_fixedinput /* internal */
} slang_type_qualifier;
-typedef enum slang_type_specifier_type_
-{
- slang_spec_void,
- slang_spec_bool,
- slang_spec_bvec2,
- slang_spec_bvec3,
- slang_spec_bvec4,
- slang_spec_int,
- slang_spec_ivec2,
- slang_spec_ivec3,
- slang_spec_ivec4,
- slang_spec_float,
- slang_spec_vec2,
- slang_spec_vec3,
- slang_spec_vec4,
- slang_spec_mat2,
- slang_spec_mat3,
- slang_spec_mat4,
- slang_spec_sampler1D,
- slang_spec_sampler2D,
- slang_spec_sampler3D,
- slang_spec_samplerCube,
- slang_spec_sampler1DShadow,
- slang_spec_sampler2DShadow,
- slang_spec_struct,
- slang_spec_array
-} slang_type_specifier_type;
-
slang_type_specifier_type slang_type_specifier_type_from_string (const char *);
const char *slang_type_specifier_type_to_string (slang_type_specifier_type);
-typedef struct slang_type_specifier_
-{
- slang_type_specifier_type type;
- struct slang_struct_ *_struct; /* type: spec_struct */
- struct slang_type_specifier_ *_array; /* type: spec_array */
-} slang_type_specifier;
-
-int slang_type_specifier_construct (slang_type_specifier *);
-void slang_type_specifier_destruct (slang_type_specifier *);
-int slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
-int slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
-
typedef struct slang_fully_specified_type_
{
slang_type_qualifier qualifier;
@@ -125,27 +83,8 @@ int slang_variable_copy (slang_variable *, const slang_variable *);
slang_variable *_slang_locate_variable (slang_variable_scope *, slang_atom a_name, GLboolean all);
-typedef struct
-{
- slang_export_data_quant *quant;
- char *name;
-} slang_active_uniform;
-
-typedef struct
-{
- slang_active_uniform *table;
- GLuint count;
-} slang_active_uniforms;
-
-GLvoid slang_active_uniforms_ctr (slang_active_uniforms *);
-GLvoid slang_active_uniforms_dtr (slang_active_uniforms *);
-GLboolean slang_active_uniforms_add (slang_active_uniforms *, slang_export_data_quant *,
- const char *);
-
GLboolean _slang_build_export_data_table (slang_export_data_table *, slang_variable_scope *);
-GLboolean _slang_gather_active_uniforms (slang_active_uniforms *, slang_export_data_table *);
-
#ifdef __cplusplus
}
#endif
diff --git a/src/mesa/shader/slang/slang_execute.c b/src/mesa/shader/slang/slang_execute.c
index 06f0eefdf60..0714ddff0d9 100644
--- a/src/mesa/shader/slang/slang_execute.c
+++ b/src/mesa/shader/slang/slang_execute.c
@@ -32,14 +32,26 @@
#include "context.h"
#include "swrast/s_context.h"
#include "colormac.h"
-#include "slang_utility.h"
-#include "slang_assemble.h"
-#include "slang_storage.h"
#include "slang_execute.h"
#include "slang_library_noise.h"
#define DEBUG_SLANG 0
+GLvoid slang_machine_ctr (slang_machine *self)
+{
+ slang_machine_init (self);
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ self->x86.compiled_func = NULL;
+#endif
+}
+
+GLvoid slang_machine_dtr (slang_machine *self)
+{
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ /* TODO: free self->x86.compiled_func */
+#endif
+}
+
void slang_machine_init (slang_machine *mach)
{
mach->ip = 0;
@@ -53,7 +65,7 @@ int _slang_execute (const slang_assembly_file *file)
{
slang_machine mach;
- slang_machine_init (&mach);
+ slang_machine_ctr (&mach);
return _slang_execute2 (file, &mach);
}
@@ -207,6 +219,9 @@ static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
case slang_asm_local_addr:
fprintf (f, "local_addr\t%u, %u", a->param[0], a->param[1]);
break;
+ case slang_asm_global_addr:
+ fprintf (f, "global_addr\t%u", a->param[0]);
+ break;
case slang_asm_call:
fprintf (f, "call\t%u", a->param[0]);
break;
@@ -293,6 +308,14 @@ int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)
f = fopen (filename, "w");
#endif
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ if (mach->x86.compiled_func != NULL)
+ {
+ mach->x86.compiled_func (mach);
+ return 1;
+ }
+#endif
+
stack = mach->mem + SLANG_MACHINE_GLOBAL_SIZE;
while (!mach->exit)
@@ -427,6 +450,7 @@ int _slang_execute2 (const slang_assembly_file *file, slang_machine *mach)
mach->sp++;
break;
case slang_asm_addr_push:
+ case slang_asm_global_addr:
mach->sp--;
stack[mach->sp]._addr = a->param[0];
break;
diff --git a/src/mesa/shader/slang/slang_execute.h b/src/mesa/shader/slang/slang_execute.h
index a3b326f3155..588b0cac3fe 100644
--- a/src/mesa/shader/slang/slang_execute.h
+++ b/src/mesa/shader/slang/slang_execute.h
@@ -25,6 +25,8 @@
#if !defined SLANG_EXECUTE_H
#define SLANG_EXECUTE_H
+#include "slang_assemble.h"
+
#if defined __cplusplus
extern "C" {
#endif
@@ -39,6 +41,16 @@ typedef union slang_machine_slot_
#define SLANG_MACHINE_STACK_SIZE 1024
#define SLANG_MACHINE_MEMORY_SIZE (SLANG_MACHINE_GLOBAL_SIZE + SLANG_MACHINE_STACK_SIZE)
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+typedef struct
+{
+ GLvoid (* compiled_func) (struct slang_machine_ *);
+ GLuint esp_restore;
+ GLshort fpucntl_rnd_neg;
+ GLshort fpucntl_restore;
+} slang_machine_x86;
+#endif
+
typedef struct slang_machine_
{
GLuint ip; /* instruction pointer, for flow control */
@@ -47,8 +59,14 @@ typedef struct slang_machine_
GLuint kill; /* discard the fragment */
GLuint exit; /* terminate the shader */
slang_machine_slot mem[SLANG_MACHINE_MEMORY_SIZE];
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ slang_machine_x86 x86;
+#endif
} slang_machine;
+GLvoid slang_machine_ctr (slang_machine *);
+GLvoid slang_machine_dtr (slang_machine *);
+
void slang_machine_init (slang_machine *);
int _slang_execute (const slang_assembly_file *);
diff --git a/src/mesa/shader/slang/slang_execute_x86.c b/src/mesa/shader/slang/slang_execute_x86.c
new file mode 100644
index 00000000000..d6395632390
--- /dev/null
+++ b/src/mesa/shader/slang/slang_execute_x86.c
@@ -0,0 +1,536 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 2005-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_execute_x86.c
+ * x86 back end compiler
+ * \author Michal Krol, Keith Whitwell
+ */
+
+#include "imports.h"
+#include "context.h"
+#include "colormac.h"
+#include "swrast/s_context.h"
+#include "slang_execute.h"
+#include "slang_library_noise.h"
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+
+#include "x86/rtasm/x86sse.h"
+
+typedef struct
+{
+ GLuint index;
+ GLubyte *csr;
+} fixup;
+
+typedef struct
+{
+ struct x86_function f;
+ struct x86_reg r_eax;
+ struct x86_reg r_ecx;
+ struct x86_reg r_edx;
+ struct x86_reg r_esp;
+ struct x86_reg r_ebp;
+ struct x86_reg r_st0;
+ struct x86_reg r_st1;
+ struct x86_reg r_st2;
+ struct x86_reg r_st3;
+ fixup *fixups;
+ GLuint fixup_count;
+ GLubyte **labels;
+ slang_machine *mach;
+ GLubyte *l_discard;
+ GLubyte *l_exit;
+ GLshort fpucntl;
+} codegen_ctx;
+
+static GLvoid add_fixup (codegen_ctx *G, GLuint index, GLubyte *csr)
+{
+ G->fixups = (fixup *) slang_alloc_realloc (G->fixups, G->fixup_count * sizeof (fixup),
+ (G->fixup_count + 1) * sizeof (fixup));
+ G->fixups[G->fixup_count].index = index;
+ G->fixups[G->fixup_count].csr = csr;
+ G->fixup_count++;
+}
+
+#ifdef NO_FAST_MATH
+#define RESTORE_FPU (DEFAULT_X86_FPU)
+#define RND_NEG_FPU (DEFAULT_X86_FPU | 0x400)
+#else
+#define RESTORE_FPU (FAST_X86_FPU)
+#define RND_NEG_FPU (FAST_X86_FPU | 0x400)
+#endif
+
+static void set_fpu_round_neg_inf (codegen_ctx *G)
+{
+ if (G->fpucntl != RND_NEG_FPU)
+ {
+ G->fpucntl = RND_NEG_FPU;
+ x87_fnclex (&G->f);
+ x86_mov_reg_imm (&G->f, G->r_eax, (GLint) &G->mach->x86.fpucntl_rnd_neg);
+ x87_fldcw (&G->f, x86_deref (G->r_eax));
+ }
+}
+
+static void emit_x87_ex2 (codegen_ctx *G)
+{
+ set_fpu_round_neg_inf (G);
+
+ x87_fld (&G->f, G->r_st0); /* a a */
+ x87_fprndint (&G->f); /* int(a) a */
+ x87_fld (&G->f, G->r_st0); /* int(a) int(a) a */
+ x87_fstp (&G->f, G->r_st3); /* int(a) a int(a)*/
+ x87_fsubp (&G->f, G->r_st1);/* frac(a) int(a) */
+ x87_f2xm1 (&G->f); /* (2^frac(a))-1 int(a)*/
+ x87_fld1 (&G->f); /* 1 (2^frac(a))-1 int(a)*/
+ x87_faddp (&G->f, G->r_st1);/* 2^frac(a) int(a) */
+ x87_fscale (&G->f); /* 2^a */
+}
+
+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);
+}
+
+static GLvoid do_print_int (GLfloat x)
+{
+ _mesa_printf ("slang print: %d\n", (GLint) x);
+}
+
+static GLvoid do_print_bool (GLfloat x)
+{
+ _mesa_printf ("slang print: %s\n", (GLint) x ? "true" : "false");
+}
+
+static GLvoid codegen_assem (codegen_ctx *G, slang_assembly *a)
+{
+ GLint disp;
+
+ switch (a->type)
+ {
+ case slang_asm_none:
+ break;
+ case slang_asm_float_copy:
+ case slang_asm_int_copy:
+ case slang_asm_bool_copy:
+ x86_mov (&G->f, G->r_eax, x86_make_disp (G->r_esp, a->param[0]));
+ x86_pop (&G->f, G->r_ecx);
+ x86_mov (&G->f, x86_make_disp (G->r_eax, a->param[1]), G->r_ecx);
+ break;
+ case slang_asm_float_move:
+ case slang_asm_int_move:
+ case slang_asm_bool_move:
+ x86_lea (&G->f, G->r_eax, x86_make_disp (G->r_esp, a->param[1]));
+ x86_add (&G->f, G->r_eax, x86_deref (G->r_esp));
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_eax));
+ x86_mov (&G->f, x86_make_disp (G->r_esp, a->param[0]), G->r_eax);
+ break;
+ case slang_asm_float_push:
+ case slang_asm_int_push:
+ case slang_asm_bool_push:
+ /* TODO: use push imm32 */
+ x86_mov_reg_imm (&G->f, G->r_eax, *((GLint *) &a->literal));
+ x86_push (&G->f, G->r_eax);
+ break;
+ case slang_asm_float_deref:
+ case slang_asm_int_deref:
+ case slang_asm_bool_deref:
+ case slang_asm_addr_deref:
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_esp));
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_eax));
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_eax);
+ break;
+ case slang_asm_float_add:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_faddp (&G->f, G->r_st1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_multiply:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fmulp (&G->f, G->r_st1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_divide:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fdivp (&G->f, G->r_st1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_negate:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fchs (&G->f);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_less:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fcomp (&G->f, x86_deref (G->r_esp));
+ x87_fnstsw (&G->f, G->r_eax);
+ /* TODO: use test r8,imm8 */
+ x86_mov_reg_imm (&G->f, G->r_ecx, 0x100);
+ x86_test (&G->f, G->r_eax, G->r_ecx);
+ {
+ GLfloat one = 1.0f, zero = 0.0f;
+ GLubyte *lab0, *lab1;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_E);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &one));
+ /* TODO: use jmp rel8 */
+ lab1 = x86_jmp_forward (&G->f);
+ x86_fixup_fwd_jump (&G->f, lab0);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &zero));
+ x86_fixup_fwd_jump (&G->f, lab1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_ecx);
+ }
+ break;
+ case slang_asm_float_equal_exp:
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fcomp (&G->f, x86_deref (G->r_esp));
+ x87_fnstsw (&G->f, G->r_eax);
+ /* TODO: use test r8,imm8 */
+ x86_mov_reg_imm (&G->f, G->r_ecx, 0x4000);
+ x86_test (&G->f, G->r_eax, G->r_ecx);
+ {
+ GLfloat one = 1.0f, zero = 0.0f;
+ GLubyte *lab0, *lab1;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_E);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &one));
+ /* TODO: use jmp rel8 */
+ lab1 = x86_jmp_forward (&G->f);
+ x86_fixup_fwd_jump (&G->f, lab0);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &zero));
+ x86_fixup_fwd_jump (&G->f, lab1);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_ecx);
+ }
+ break;
+ case slang_asm_float_equal_int:
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, -4));
+ x87_fld (&G->f, x86_make_disp (G->r_esp, a->param[0] + 4));
+ x87_fcomp (&G->f, x86_make_disp (G->r_esp, a->param[1] + 4));
+ x87_fnstsw (&G->f, G->r_eax);
+ /* TODO: use test r8,imm8 */
+ x86_mov_reg_imm (&G->f, G->r_ecx, 0x4000);
+ x86_test (&G->f, G->r_eax, G->r_ecx);
+ {
+ GLfloat one = 1.0f, zero = 0.0f;
+ GLubyte *lab0, *lab1;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_E);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &one));
+ /* TODO: use jmp rel8 */
+ lab1 = x86_jmp_forward (&G->f);
+ x86_fixup_fwd_jump (&G->f, lab0);
+ x86_mov_reg_imm (&G->f, G->r_ecx, *((GLint *) &zero));
+ x86_fixup_fwd_jump (&G->f, lab1);
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_ecx);
+ }
+ break;
+ case slang_asm_float_to_int:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fistp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_sine:
+ /* TODO: use fsin */
+ x86_call (&G->f, (GLubyte *) _mesa_sinf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_arcsine:
+ /* TODO: use fpatan (?) */
+ x86_call (&G->f, (GLubyte *) _mesa_asinf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_arctan:
+ /* TODO: use fpatan */
+ x86_call (&G->f, (GLubyte *) _mesa_atanf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_power:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fld (&G->f, x86_make_disp (G->r_esp, 4));
+ x87_fyl2x (&G->f);
+ emit_x87_ex2 (G);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_log2:
+ x87_fld1 (&G->f);
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fyl2x (&G->f);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_floor:
+ set_fpu_round_neg_inf (G);
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fprndint (&G->f);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_ceil:
+ /* TODO: use frndint */
+ x86_call (&G->f, (GLubyte *) do_ceilf);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise1:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise1);
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise2:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise2);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise3:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise4);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 8));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_float_noise4:
+ x86_call (&G->f, (GLubyte *) _slang_library_noise4);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 12));
+ x87_fstp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_int_to_float:
+ break;
+ case slang_asm_int_to_addr:
+ x87_fld (&G->f, x86_deref (G->r_esp));
+ x87_fistp (&G->f, x86_deref (G->r_esp));
+ break;
+ case slang_asm_addr_copy:
+ x86_pop (&G->f, G->r_eax);
+ x86_mov (&G->f, G->r_ecx, x86_deref (G->r_esp));
+ x86_mov (&G->f, x86_deref (G->r_ecx), G->r_eax);
+ break;
+ case slang_asm_addr_push:
+ /* TODO: use push imm32 */
+ x86_mov_reg_imm (&G->f, G->r_eax, (GLint) a->param[0]);
+ x86_push (&G->f, G->r_eax);
+ break;
+ case slang_asm_addr_add:
+ x86_pop (&G->f, G->r_eax);
+ x86_add (&G->f, x86_deref (G->r_esp), G->r_eax);
+ break;
+ case slang_asm_addr_multiply:
+ x86_pop (&G->f, G->r_ecx);
+ x86_mov (&G->f, G->r_eax, x86_deref (G->r_esp));
+ x86_mul (&G->f, G->r_ecx);
+ x86_mov (&G->f, x86_deref (G->r_esp), G->r_eax);
+ 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));
+ break;
+ case slang_asm_jump:
+ add_fixup (G, a->param[0], x86_jmp_forward (&G->f));
+ break;
+ case slang_asm_jump_if_zero:
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, 4));
+ x86_xor (&G->f, G->r_eax, G->r_eax);
+ x86_cmp (&G->f, G->r_eax, x86_make_disp (G->r_esp, -4));
+ {
+ GLubyte *lab0;
+
+ /* TODO: use jcc rel8 */
+ lab0 = x86_jcc_forward (&G->f, cc_NE);
+ add_fixup (G, a->param[0], x86_jmp_forward (&G->f));
+ x86_fixup_fwd_jump (&G->f, lab0);
+ }
+ break;
+ case slang_asm_enter:
+ /* FIXME: x86_make_disp(esp, 0) + x86_lea() generates bogus code */
+ assert (a->param[0] != 0);
+ x86_push (&G->f, G->r_ebp);
+ x86_lea (&G->f, G->r_ebp, x86_make_disp (G->r_esp, (GLint) a->param[0]));
+ break;
+ case slang_asm_leave:
+ x86_pop (&G->f, G->r_ebp);
+ break;
+ case slang_asm_local_alloc:
+ /* FIXME: x86_make_disp(esp, 0) + x86_lea() generates bogus code */
+ assert (a->param[0] != 0);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, -(GLint) a->param[0]));
+ break;
+ case slang_asm_local_free:
+ /* FIXME: x86_make_disp(esp, 0) + x86_lea() generates bogus code */
+ assert (a->param[0] != 0);
+ x86_lea (&G->f, G->r_esp, x86_make_disp (G->r_esp, (GLint) a->param[0]));
+ break;
+ case slang_asm_local_addr:
+ disp = -(GLint) (a->param[0] + a->param[1]) + 4;
+ if (disp != 0)
+ {
+ x86_lea (&G->f, G->r_eax, x86_make_disp (G->r_ebp, disp));
+ x86_push (&G->f, G->r_eax);
+ }
+ else
+ x86_push (&G->f, G->r_ebp);
+ break;
+ case slang_asm_global_addr:
+ /* TODO: use push imm32 */
+ x86_mov_reg_imm (&G->f, G->r_eax, (GLint) &G->mach->mem + a->param[0]);
+ x86_push (&G->f, G->r_eax);
+ break;
+ case slang_asm_call:
+ add_fixup (G, a->param[0], x86_call_forward (&G->f));
+ break;
+ case slang_asm_return:
+ x86_ret (&G->f);
+ break;
+ case slang_asm_discard:
+ x86_jmp (&G->f, G->l_discard);
+ break;
+ case slang_asm_exit:
+ x86_jmp (&G->f, G->l_exit);
+ break;
+ /* mesa-specific extensions */
+ case slang_asm_float_print:
+ x86_call (&G->f, (GLubyte *) do_print_float);
+ break;
+ case slang_asm_int_print:
+ x86_call (&G->f, (GLubyte *) do_print_int);
+ break;
+ case slang_asm_bool_print:
+ x86_call (&G->f, (GLubyte *) do_print_bool);
+ break;
+ default:
+ assert (0);
+ }
+}
+
+GLboolean _slang_x86_codegen (slang_machine *mach, slang_assembly_file *file, GLuint start)
+{
+ codegen_ctx G;
+ GLubyte *j_body, *j_exit;
+ GLuint i;
+
+ x86_init_func_size (&G.f, 4*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);
+ G.r_esp = x86_make_reg (file_REG32, reg_SP);
+ G.r_ebp = x86_make_reg (file_REG32, reg_BP);
+ G.r_st0 = x86_make_reg (file_x87, 0);
+ G.r_st1 = x86_make_reg (file_x87, 1);
+ G.r_st2 = x86_make_reg (file_x87, 2);
+ G.r_st3 = x86_make_reg (file_x87, 3);
+ G.fixups = NULL;
+ G.fixup_count = 0;
+ G.labels = (GLubyte **) slang_alloc_malloc (file->count * sizeof (GLubyte *));
+ G.mach = mach;
+ G.fpucntl = RESTORE_FPU;
+
+ mach->x86.fpucntl_rnd_neg = RND_NEG_FPU;
+ mach->x86.fpucntl_restore = RESTORE_FPU;
+
+ /* prepare stack and jump to start */
+ x86_push (&G.f, G.r_ebp);
+ x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &mach->x86.esp_restore);
+ x86_push (&G.f, G.r_esp);
+ x86_pop (&G.f, G.r_ecx);
+ x86_mov (&G.f, x86_deref (G.r_eax), G.r_ecx);
+ j_body = x86_jmp_forward (&G.f);
+
+ /* discard keywords go here */
+ 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);
+ x86_mov (&G.f, x86_deref (G.r_eax), G.r_ecx);
+ G.l_exit = x86_get_label (&G.f);
+ j_exit = x86_jmp_forward (&G.f);
+
+ for (i = 0; i < file->count; i++)
+ {
+ G.labels[i] = x86_get_label (&G.f);
+ if (i == start)
+ x86_fixup_fwd_jump (&G.f, j_body);
+ codegen_assem (&G, &file->code[i]);
+ }
+
+ /* restore stack and return */
+ 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));
+ x86_pop (&G.f, G.r_ebp);
+ if (G.fpucntl != RESTORE_FPU)
+ {
+ x87_fnclex (&G.f);
+ x86_mov_reg_imm (&G.f, G.r_eax, (GLint) &G.mach->x86.fpucntl_restore);
+ x87_fldcw (&G.f, x86_deref (G.r_eax));
+ }
+ x86_ret (&G.f);
+
+ /* fixup forward labels */
+ for (i = 0; i < G.fixup_count; i++)
+ {
+ G.f.csr = G.labels[G.fixups[i].index];
+ x86_fixup_fwd_jump (&G.f, G.fixups[i].csr);
+ }
+
+ slang_alloc_free (G.fixups);
+ slang_alloc_free (G.labels);
+
+ /* TODO: free previous instance, if not NULL */
+ mach->x86.compiled_func = (GLvoid (*) (slang_machine *)) x86_get_func (&G.f);
+
+ return GL_TRUE;
+}
+
+#endif
+
diff --git a/src/mesa/shader/slang/slang_export.c b/src/mesa/shader/slang/slang_export.c
index 8103994336c..ffc2ec975ea 100644
--- a/src/mesa/shader/slang/slang_export.c
+++ b/src/mesa/shader/slang/slang_export.c
@@ -29,7 +29,6 @@
*/
#include "imports.h"
-#include "slang_utility.h"
#include "slang_export.h"
/*
@@ -123,6 +122,56 @@ slang_export_data_entry *slang_export_data_table_add (slang_export_data_table *s
}
/*
+ * slang_export_code_entry
+ */
+
+GLvoid slang_export_code_entry_ctr (slang_export_code_entry *self)
+{
+ self->name = SLANG_ATOM_NULL;
+ self->address = ~0;
+}
+
+GLvoid slang_export_code_entry_dtr (slang_export_code_entry *self)
+{
+}
+
+/*
+ * slang_export_code_table
+ */
+
+GLvoid slang_export_code_table_ctr (slang_export_code_table *self)
+{
+ self->entries = NULL;
+ self->count = 0;
+ self->atoms = NULL;
+}
+
+GLvoid slang_export_code_table_dtr (slang_export_code_table *self)
+{
+ if (self->entries != NULL)
+ {
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_export_code_entry_dtr (&self->entries[i]);
+ slang_alloc_free (self->entries);
+ }
+}
+
+slang_export_code_entry *slang_export_code_table_add (slang_export_code_table *self)
+{
+ const GLuint n = self->count;
+
+ self->entries = (slang_export_code_entry *) slang_alloc_realloc (self->entries,
+ n * sizeof (slang_export_code_entry), (n + 1) * sizeof (slang_export_code_entry));
+ if (self->entries == NULL)
+ return NULL;
+ slang_export_code_entry_ctr (&self->entries[n]);
+ self->count++;
+ return &self->entries[n];
+}
+
+/*
* _slang_find_exported_data()
*/
diff --git a/src/mesa/shader/slang/slang_export.h b/src/mesa/shader/slang/slang_export.h
index 57e7d51279e..88a74fe26b0 100644
--- a/src/mesa/shader/slang/slang_export.h
+++ b/src/mesa/shader/slang/slang_export.h
@@ -25,6 +25,8 @@
#if !defined SLANG_EXPORT_H
#define SLANG_EXPORT_H
+#include "slang_utility.h"
+
#if defined __cplusplus
extern "C" {
#endif
@@ -82,7 +84,7 @@ GLvoid slang_export_data_entry_ctr (slang_export_data_entry *);
GLvoid slang_export_data_entry_dtr (slang_export_data_entry *);
/*
- * Data export table. Holds <count> elements in <entries> array.
+ * Data export table.
*/
typedef struct
@@ -97,6 +99,31 @@ GLvoid slang_export_data_table_dtr (slang_export_data_table *);
slang_export_data_entry *slang_export_data_table_add (slang_export_data_table *);
/*
+ * Code export entry. Contains label name and its entry point (label, address).
+ */
+
+typedef struct
+{
+ slang_atom name;
+ GLuint address;
+} slang_export_code_entry;
+
+/*
+ * Code export table.
+ */
+
+typedef struct
+{
+ slang_export_code_entry *entries;
+ GLuint count;
+ slang_atom_pool *atoms;
+} slang_export_code_table;
+
+GLvoid slang_export_code_table_ctr (slang_export_code_table *);
+GLvoid slang_export_code_table_dtr (slang_export_code_table *);
+slang_export_code_entry *slang_export_code_table_add (slang_export_code_table *);
+
+/*
* _slang_find_exported_data()
*
* Parses the name string and returns corresponding data entry, data quantity and offset.
diff --git a/src/mesa/shader/slang/slang_library_noise.c b/src/mesa/shader/slang/slang_library_noise.c
index 4dddf33e724..d0081c542a9 100644
--- a/src/mesa/shader/slang/slang_library_noise.c
+++ b/src/mesa/shader/slang/slang_library_noise.c
@@ -22,28 +22,11 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#include "imports.h"
-#include "slang_library_noise.h"
-
/*
* SimplexNoise1234
* Copyright � 2003-2005, Stefan Gustavson
*
* Contact: [email protected]
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** \file
@@ -66,6 +49,9 @@
*/
+#include "imports.h"
+#include "slang_library_noise.h"
+
#define FASTFLOOR(x) ( ((x)>0) ? ((int)x) : (((int)x)-1) )
/*
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index c4303ac020d..7216663e3f1 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -29,9 +29,6 @@
*/
#include "imports.h"
-#include "slang_utility.h"
-#include "slang_compile.h"
-#include "slang_export.h"
#include "slang_link.h"
/*
@@ -134,14 +131,94 @@ static GLboolean gather_uniform_bindings (slang_uniform_bindings *bind, slang_ex
GLuint i;
for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_uniform)
+ {
+ char name[1024] = "";
+
+ if (!insert_binding (bind, &tbl->entries[i].quant, name, tbl->atoms, index,
+ tbl->entries[i].address))
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+/*
+ * slang_active_uniforms
+ */
+
+static GLvoid slang_active_uniforms_ctr (slang_active_uniforms *self)
+{
+ self->table = NULL;
+ self->count = 0;
+}
+
+static GLvoid slang_active_uniforms_dtr (slang_active_uniforms *self)
+{
+ GLuint i;
+
+ for (i = 0; i < self->count; i++)
+ slang_alloc_free (self->table[i].name);
+ slang_alloc_free (self->table);
+}
+
+static GLboolean slang_active_uniforms_add (slang_active_uniforms *self, slang_export_data_quant *q,
+ const char *name)
+{
+ const GLuint n = self->count;
+
+ self->table = (slang_active_uniform *) slang_alloc_realloc (self->table,
+ n * sizeof (slang_active_uniform), (n + 1) * sizeof (slang_active_uniform));
+ if (self->table == NULL)
+ return GL_FALSE;
+ self->table[n].quant = q;
+ self->table[n].name = slang_string_duplicate (name);
+ if (self->table[n].name == NULL)
+ return GL_FALSE;
+ self->count++;
+ return GL_TRUE;
+}
+
+static GLboolean insert_uniform (slang_active_uniforms *u, slang_export_data_quant *q, char *name,
+ slang_atom_pool *atoms)
+{
+ slang_string_concat (name, slang_atom_pool_id (atoms, q->name));
+ if (q->array_len != 0)
+ slang_string_concat (name, "[0]");
+
+ if (q->structure != NULL)
{
- char name[1024] = "";
+ GLuint save, i;
- if (!insert_binding (bind, &tbl->entries[i].quant, name, tbl->atoms, index,
- tbl->entries[i].address))
- return GL_FALSE;
+ slang_string_concat (name, ".");
+ save = slang_string_length (name);
+
+ for (i = 0; i < q->u.field_count; i++)
+ {
+ if (!insert_uniform (u, &q->structure[i], name, atoms))
+ return GL_FALSE;
+ name[save] = '\0';
+ }
+
+ return GL_TRUE;
}
+ return slang_active_uniforms_add (u, q, name);
+}
+
+static GLboolean gather_active_uniforms (slang_active_uniforms *u, slang_export_data_table *tbl)
+{
+ GLuint i;
+
+ for (i = 0; i < tbl->count; i++)
+ if (tbl->entries[i].access == slang_exp_uniform)
+ {
+ char name[1024] = "";
+
+ if (!insert_uniform (u, &tbl->entries[i].quant, name, tbl->atoms))
+ return GL_FALSE;
+ }
+
return GL_TRUE;
}
@@ -151,18 +228,159 @@ static GLboolean gather_uniform_bindings (slang_uniform_bindings *bind, slang_ex
GLvoid slang_program_ctr (slang_program *self)
{
+ GLuint i;
+
slang_uniform_bindings_ctr (&self->uniforms);
+ slang_active_uniforms_ctr (&self->active_uniforms);
+ for (i = 0; i < SLANG_UNIFORM_BINDING_MAX; i++)
+ {
+ GLuint j;
+
+ for (j = 0; j < SLANG_COMMON_FIXED_MAX; j++)
+ self->common_fixed_entries[i][j] = ~0;
+ self->code[i] = ~0;
+ self->machines[i] = NULL;
+ self->assemblies[i] = NULL;
+ }
+ for (i = 0; i < SLANG_VERTEX_FIXED_MAX; i++)
+ self->vertex_fixed_entries[i] = ~0;
+ for (i = 0; i < SLANG_FRAGMENT_FIXED_MAX; i++)
+ self->fragment_fixed_entries[i] = ~0;
}
GLvoid slang_program_dtr (slang_program *self)
{
slang_uniform_bindings_dtr (&self->uniforms);
+ slang_active_uniforms_dtr (&self->active_uniforms);
}
/*
* _slang_link()
*/
+static GLuint gd (slang_export_data_table *tbl, const char *name)
+{
+ slang_atom atom;
+ GLuint i;
+
+ atom = slang_atom_pool_atom (tbl->atoms, name);
+ if (atom == SLANG_ATOM_NULL)
+ return ~0;
+
+ for (i = 0; i < tbl->count; i++)
+ if (atom == tbl->entries[i].quant.name)
+ return tbl->entries[i].address;
+ return ~0;
+}
+
+static GLvoid fill_common_fixed_entries (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");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX] = gd (tbl, "gl_ModelViewProjectionMatrix");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIX] = gd (tbl, "gl_TextureMatrix");
+ e[SLANG_COMMON_FIXED_NORMALMATRIX] = gd (tbl, "gl_NormalMatrix");
+ e[SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE] = gd (tbl, "gl_ModelViewMatrixInverse");
+ e[SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE] = gd (tbl, "gl_ProjectionMatrixInverse");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE] =
+ gd (tbl, "gl_ModelViewProjectionMatrixInverse");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE] = gd (tbl, "gl_TextureMatrixInverse");
+ e[SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE] = gd (tbl, "gl_ModelViewMatrixTranspose");
+ e[SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE] = gd (tbl, "gl_ProjectionMatrixTranspose");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE] =
+ gd (tbl, "gl_ModelViewProjectionMatrixTranspose");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE] = gd (tbl, "gl_TextureMatrixTranspose");
+ e[SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_ModelViewMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_ProjectionMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_ModelViewProjectionMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE] =
+ gd (tbl, "gl_TextureMatrixInverseTranspose");
+ e[SLANG_COMMON_FIXED_NORMALSCALE] = gd (tbl, "gl_NormalScale");
+ e[SLANG_COMMON_FIXED_DEPTHRANGE] = gd (tbl, "gl_DepthRange");
+ e[SLANG_COMMON_FIXED_CLIPPLANE] = gd (tbl, "gl_ClipPlane");
+ e[SLANG_COMMON_FIXED_POINT] = gd (tbl, "gl_Point");
+ e[SLANG_COMMON_FIXED_FRONTMATERIAL] = gd (tbl, "gl_FrontMaterial");
+ e[SLANG_COMMON_FIXED_BACKMATERIAL] = gd (tbl, "gl_BackMaterial");
+ e[SLANG_COMMON_FIXED_LIGHTSOURCE] = gd (tbl, "gl_LightSource");
+ e[SLANG_COMMON_FIXED_LIGHTMODEL] = gd (tbl, "gl_LightModel");
+ e[SLANG_COMMON_FIXED_FRONTLIGHTMODELPRODUCT] = gd (tbl, "gl_FrontLightModelProduct");
+ e[SLANG_COMMON_FIXED_BACKLIGHTMODELPRODUCT] = gd (tbl, "gl_BackLightModelProduct");
+ e[SLANG_COMMON_FIXED_FRONTLIGHTPRODUCT] = gd (tbl, "gl_FrontLightProduct");
+ e[SLANG_COMMON_FIXED_BACKLIGHTPRODUCT] = gd (tbl, "gl_BackLightProduct");
+ e[SLANG_COMMON_FIXED_TEXTUREENVCOLOR] = gd (tbl, "gl_TextureEnvColor");
+ e[SLANG_COMMON_FIXED_EYEPLANES] = gd (tbl, "gl_EyePlaneS");
+ e[SLANG_COMMON_FIXED_EYEPLANET] = gd (tbl, "gl_EyePlaneT");
+ e[SLANG_COMMON_FIXED_EYEPLANER] = gd (tbl, "gl_EyePlaneR");
+ e[SLANG_COMMON_FIXED_EYEPLANEQ] = gd (tbl, "gl_EyePlaneQ");
+ e[SLANG_COMMON_FIXED_OBJECTPLANES] = gd (tbl, "gl_ObjectPlaneS");
+ e[SLANG_COMMON_FIXED_OBJECTPLANET] = gd (tbl, "gl_ObjectPlaneT");
+ e[SLANG_COMMON_FIXED_OBJECTPLANER] = gd (tbl, "gl_ObjectPlaneR");
+ e[SLANG_COMMON_FIXED_OBJECTPLANEQ] = gd (tbl, "gl_ObjectPlaneQ");
+ e[SLANG_COMMON_FIXED_FOG] = gd (tbl, "gl_Fog");
+}
+
+static GLvoid fill_vertex_fixed_entries (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");
+ e[SLANG_VERTEX_FIXED_CLIPVERTEX] = gd (tbl, "gl_ClipVertex");
+ e[SLANG_VERTEX_FIXED_COLOR] = gd (tbl, "gl_Color");
+ e[SLANG_VERTEX_FIXED_SECONDARYCOLOR] = gd (tbl, "gl_SecondaryColor");
+ e[SLANG_VERTEX_FIXED_NORMAL] = gd (tbl, "gl_Normal");
+ e[SLANG_VERTEX_FIXED_VERTEX] = gd (tbl, "gl_Vertex");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD0] = gd (tbl, "gl_MultiTexCoord0");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD1] = gd (tbl, "gl_MultiTexCoord1");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD2] = gd (tbl, "gl_MultiTexCoord2");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD3] = gd (tbl, "gl_MultiTexCoord3");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD4] = gd (tbl, "gl_MultiTexCoord4");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD5] = gd (tbl, "gl_MultiTexCoord5");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD6] = gd (tbl, "gl_MultiTexCoord6");
+ e[SLANG_VERTEX_FIXED_MULTITEXCOORD7] = gd (tbl, "gl_MultiTexCoord7");
+ e[SLANG_VERTEX_FIXED_FOGCOORD] = gd (tbl, "gl_FogCoord");
+ e[SLANG_VERTEX_FIXED_FRONTCOLOR] = gd (tbl, "gl_FrontColor");
+ e[SLANG_VERTEX_FIXED_BACKCOLOR] = gd (tbl, "gl_BackColor");
+ e[SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR] = gd (tbl, "gl_FrontSecondaryColor");
+ e[SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR] = gd (tbl, "gl_BackSecondaryColor");
+ e[SLANG_VERTEX_FIXED_TEXCOORD] = gd (tbl, "gl_TexCoord");
+ e[SLANG_VERTEX_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");
+}
+
+static GLvoid fill_fragment_fixed_entries (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");
+ e[SLANG_FRAGMENT_FIXED_FRAGCOLOR] = gd (tbl, "gl_FragColor");
+ e[SLANG_FRAGMENT_FIXED_FRAGDATA] = gd (tbl, "gl_FragData");
+ e[SLANG_FRAGMENT_FIXED_FRAGDEPTH] = gd (tbl, "gl_FragDepth");
+ e[SLANG_FRAGMENT_FIXED_COLOR] = gd (tbl, "gl_Color");
+ e[SLANG_FRAGMENT_FIXED_SECONDARYCOLOR] = gd (tbl, "gl_SecondaryColor");
+ e[SLANG_FRAGMENT_FIXED_TEXCOORD] = gd (tbl, "gl_TexCoord");
+ e[SLANG_FRAGMENT_FIXED_FOGFRAGCOORD] = gd (tbl, "gl_FogFragCoord");
+}
+
+static GLuint gc (slang_export_code_table *tbl, const char *name)
+{
+ slang_atom atom;
+ GLuint i;
+
+ atom = slang_atom_pool_atom (tbl->atoms, name);
+ if (atom == SLANG_ATOM_NULL)
+ return ~0;
+
+ for (i = 0; i < tbl->count; i++)
+ if (atom == tbl->entries[i].name)
+ return tbl->entries[i].address;
+ return ~0;
+}
+
+static GLvoid resolve_code (GLuint code[], slang_export_code_table *tbl)
+{
+ code[0] = gc (tbl, "@main");
+}
+
GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLuint count)
{
GLuint i;
@@ -172,13 +390,24 @@ GLboolean _slang_link (slang_program *prog, slang_translation_unit **units, GLui
GLuint index;
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);
+ }
else
+ {
index = SLANG_UNIFORM_BINDING_VERTEX;
+ fill_vertex_fixed_entries (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);
prog->machines[index] = units[i]->machine;
+ prog->assemblies[index] = units[i]->assembly;
}
return GL_TRUE;
diff --git a/src/mesa/shader/slang/slang_link.h b/src/mesa/shader/slang/slang_link.h
index 7395c77c5df..2f4fd254cec 100644
--- a/src/mesa/shader/slang/slang_link.h
+++ b/src/mesa/shader/slang/slang_link.h
@@ -25,16 +25,18 @@
#if !defined SLANG_LINK_H
#define SLANG_LINK_H
-#include "slang_assemble.h"
-#include "slang_execute.h"
+#include "slang_compile.h"
#if defined __cplusplus
extern "C" {
#endif
-#define SLANG_UNIFORM_BINDING_VERTEX 0
-#define SLANG_UNIFORM_BINDING_FRAGMENT 1
-#define SLANG_UNIFORM_BINDING_MAX 2
+typedef enum
+{
+ SLANG_UNIFORM_BINDING_VERTEX,
+ SLANG_UNIFORM_BINDING_FRAGMENT,
+ SLANG_UNIFORM_BINDING_MAX
+};
typedef struct
{
@@ -51,8 +53,111 @@ typedef struct
typedef struct
{
+ slang_export_data_quant *quant;
+ char *name;
+} slang_active_uniform;
+
+typedef struct
+{
+ slang_active_uniform *table;
+ GLuint count;
+} slang_active_uniforms;
+
+typedef enum
+{
+ SLANG_COMMON_FIXED_MODELVIEWMATRIX,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIX,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIX,
+ SLANG_COMMON_FIXED_TEXTUREMATRIX,
+ SLANG_COMMON_FIXED_NORMALMATRIX,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSE,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXTRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_PROJECTIONMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_MODELVIEWPROJECTIONMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_TEXTUREMATRIXINVERSETRANSPOSE,
+ SLANG_COMMON_FIXED_NORMALSCALE,
+ SLANG_COMMON_FIXED_DEPTHRANGE,
+ SLANG_COMMON_FIXED_CLIPPLANE,
+ SLANG_COMMON_FIXED_POINT,
+ SLANG_COMMON_FIXED_FRONTMATERIAL,
+ SLANG_COMMON_FIXED_BACKMATERIAL,
+ SLANG_COMMON_FIXED_LIGHTSOURCE,
+ SLANG_COMMON_FIXED_LIGHTMODEL,
+ SLANG_COMMON_FIXED_FRONTLIGHTMODELPRODUCT,
+ SLANG_COMMON_FIXED_BACKLIGHTMODELPRODUCT,
+ SLANG_COMMON_FIXED_FRONTLIGHTPRODUCT,
+ SLANG_COMMON_FIXED_BACKLIGHTPRODUCT,
+ SLANG_COMMON_FIXED_TEXTUREENVCOLOR,
+ SLANG_COMMON_FIXED_EYEPLANES,
+ SLANG_COMMON_FIXED_EYEPLANET,
+ SLANG_COMMON_FIXED_EYEPLANER,
+ SLANG_COMMON_FIXED_EYEPLANEQ,
+ SLANG_COMMON_FIXED_OBJECTPLANES,
+ SLANG_COMMON_FIXED_OBJECTPLANET,
+ SLANG_COMMON_FIXED_OBJECTPLANER,
+ SLANG_COMMON_FIXED_OBJECTPLANEQ,
+ SLANG_COMMON_FIXED_FOG,
+ SLANG_COMMON_FIXED_MAX
+};
+
+typedef enum
+{
+ SLANG_VERTEX_FIXED_POSITION,
+ SLANG_VERTEX_FIXED_POINTSIZE,
+ SLANG_VERTEX_FIXED_CLIPVERTEX,
+ SLANG_VERTEX_FIXED_COLOR,
+ SLANG_VERTEX_FIXED_SECONDARYCOLOR,
+ SLANG_VERTEX_FIXED_NORMAL,
+ SLANG_VERTEX_FIXED_VERTEX,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD0,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD1,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD2,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD3,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD4,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD5,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD6,
+ SLANG_VERTEX_FIXED_MULTITEXCOORD7,
+ SLANG_VERTEX_FIXED_FOGCOORD,
+ SLANG_VERTEX_FIXED_FRONTCOLOR,
+ SLANG_VERTEX_FIXED_BACKCOLOR,
+ SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR,
+ SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR,
+ SLANG_VERTEX_FIXED_TEXCOORD,
+ SLANG_VERTEX_FIXED_FOGFRAGCOORD,
+ SLANG_VERTEX_FIXED_MAX
+};
+
+typedef enum
+{
+ SLANG_FRAGMENT_FIXED_FRAGCOORD,
+ SLANG_FRAGMENT_FIXED_FRONTFACING,
+ SLANG_FRAGMENT_FIXED_FRAGCOLOR,
+ SLANG_FRAGMENT_FIXED_FRAGDATA,
+ SLANG_FRAGMENT_FIXED_FRAGDEPTH,
+ SLANG_FRAGMENT_FIXED_COLOR,
+ SLANG_FRAGMENT_FIXED_SECONDARYCOLOR,
+ SLANG_FRAGMENT_FIXED_TEXCOORD,
+ SLANG_FRAGMENT_FIXED_FOGFRAGCOORD,
+ SLANG_FRAGMENT_FIXED_MAX
+};
+
+typedef struct
+{
slang_uniform_bindings uniforms;
+ slang_active_uniforms active_uniforms;
+ GLuint common_fixed_entries[SLANG_UNIFORM_BINDING_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];
} slang_program;
GLvoid slang_program_ctr (slang_program *);
diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c
index 3601a384f7a..0be167e2ed9 100644
--- a/src/mesa/shader/slang/slang_preprocess.c
+++ b/src/mesa/shader/slang/slang_preprocess.c
@@ -30,8 +30,6 @@
#include "imports.h"
#include "grammar_mesa.h"
-#include "slang_utility.h"
-#include "slang_compile.h"
#include "slang_preprocess.h"
static const char *slang_version_syn =
diff --git a/src/mesa/shader/slang/slang_preprocess.h b/src/mesa/shader/slang/slang_preprocess.h
index 7901e78580c..c27556d67ea 100644
--- a/src/mesa/shader/slang/slang_preprocess.h
+++ b/src/mesa/shader/slang/slang_preprocess.h
@@ -1,8 +1,8 @@
/*
* Mesa 3-D graphics library
- * Version: 6.3
+ * Version: 6.5
*
- * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ * Copyright (C) 2005-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"),
@@ -25,6 +25,8 @@
#if !defined SLANG_PREPROCESS_H
#define SLANG_PREPROCESS_H
+#include "slang_compile.h"
+
#if defined __cplusplus
extern "C" {
#endif
diff --git a/src/mesa/shader/slang/slang_storage.c b/src/mesa/shader/slang/slang_storage.c
index 4afee2ccc79..946dc2e6fc8 100644
--- a/src/mesa/shader/slang/slang_storage.c
+++ b/src/mesa/shader/slang/slang_storage.c
@@ -29,10 +29,7 @@
*/
#include "imports.h"
-#include "slang_utility.h"
#include "slang_storage.h"
-#include "slang_assemble.h"
-#include "slang_execute.h"
/* slang_storage_array */
diff --git a/src/mesa/shader/slang/slang_storage.h b/src/mesa/shader/slang/slang_storage.h
index 4537223d81b..532ea638ee7 100644
--- a/src/mesa/shader/slang/slang_storage.h
+++ b/src/mesa/shader/slang/slang_storage.h
@@ -56,7 +56,7 @@ typedef enum slang_storage_type_
* elements. They are also required to support indirect addressing. That is, if B references
* first data slot in the array, S is the size of the data slot and I is the integral index that
* is not known at compile time, B+I*S references I-th data slot.
- *
+ *
* This structure is also used to break down built-in data types that are not supported directly.
* Vectors, like vec3, are constructed from arrays of their basic types. Matrices are formed of
* an array of column vectors, which are in turn processed as other vectors.
diff --git a/src/mesa/shader/slang/slang_utility.h b/src/mesa/shader/slang/slang_utility.h
index 2d2ac8e42e4..b4bde3d5388 100644
--- a/src/mesa/shader/slang/slang_utility.h
+++ b/src/mesa/shader/slang/slang_utility.h
@@ -61,8 +61,8 @@ typedef struct slang_atom_pool_
slang_atom_entry *entries[SLANG_ATOM_POOL_SIZE];
} slang_atom_pool;
-void slang_atom_pool_construct (slang_atom_pool *);
-void slang_atom_pool_destruct (slang_atom_pool *);
+GLvoid slang_atom_pool_construct (slang_atom_pool *);
+GLvoid slang_atom_pool_destruct (slang_atom_pool *);
slang_atom slang_atom_pool_atom (slang_atom_pool *, const char *);
const char *slang_atom_pool_id (slang_atom_pool *, slang_atom);
diff --git a/src/mesa/sources b/src/mesa/sources
index dfef696d2dd..80f7e250155 100644
--- a/src/mesa/sources
+++ b/src/mesa/sources
@@ -215,7 +215,8 @@ ASM_C_SOURCES = \
x86/rtasm/x86sse.c \
sparc/sparc.c \
ppc/common_ppc.c \
- x86-64/x86-64.c
+ x86-64/x86-64.c \
+ shader/slang/slang_execute_x86.c
X86_SOURCES = \
x86/common_x86_asm.S \
diff --git a/src/mesa/swrast/s_arbshader.c b/src/mesa/swrast/s_arbshader.c
index 1d489d90e54..e17e799100e 100644
--- a/src/mesa/swrast/s_arbshader.c
+++ b/src/mesa/swrast/s_arbshader.c
@@ -32,83 +32,63 @@
#include "s_context.h"
#include "shaderobjects.h"
#include "shaderobjects_3dlabs.h"
-
-
-static void fetch_input_vec4 (const char *name, GLfloat *vec, GLuint index,
- struct gl2_fragment_shader_intf **fs)
-{
- _slang_fetch_vec4_f (fs, name, vec, index, 1);
-}
-
-static void fetch_output_vec4 (const char *name, GLfloat *vec, GLuint index,
- struct gl2_fragment_shader_intf **fs)
-{
- _slang_fetch_vec4_f (fs, name, vec, index, 0);
-}
+#include "slang_utility.h"
+#include "slang_link.h"
void _swrast_exec_arbshader (GLcontext *ctx, struct sw_span *span)
{
- struct gl2_program_intf **prog;
- struct gl2_fragment_shader_intf **fs = NULL;
- GLuint count, i;
+ struct gl2_program_intf **pro;
+ GLuint i;
- prog = ctx->ShaderObjects.CurrentProgram;
- count = (**prog)._container.GetAttachedCount ((struct gl2_container_intf **) prog);
- for (i = 0; i < count; i++)
- {
- struct gl2_generic_intf **obj;
- struct gl2_unknown_intf **unk;
-
- obj = (**prog)._container.GetAttached ((struct gl2_container_intf **) prog, i);
- unk = (**obj)._unknown.QueryInterface ((struct gl2_unknown_intf **) obj, UIID_FRAGMENT_SHADER);
- (**obj)._unknown.Release ((struct gl2_unknown_intf **) obj);
- if (unk != NULL)
- {
- fs = (struct gl2_fragment_shader_intf **) unk;
- break;
- }
- }
- if (fs == NULL)
+ pro = ctx->ShaderObjects.CurrentProgram;
+ if (pro == NULL)
return;
for (i = span->start; i < span->end; i++)
{
GLfloat vec[4];
GLuint j;
- GLboolean kill;
+ GLboolean discard;
vec[0] = (GLfloat) span->x + i;
vec[1] = (GLfloat) span->y;
vec[2] = (GLfloat) span->array->z[i] / ctx->DrawBuffer->_DepthMaxF;
vec[3] = span->w + span->dwdx * i;
- fetch_input_vec4 ("gl_FragCoord", vec, 0, fs);
+ (**pro).UpdateFixedVarying (pro, SLANG_FRAGMENT_FIXED_FRAGCOORD, vec, 0,
+ 4 * sizeof (GLfloat), GL_TRUE);
vec[0] = CHAN_TO_FLOAT(span->array->rgba[i][RCOMP]);
vec[1] = CHAN_TO_FLOAT(span->array->rgba[i][GCOMP]);
vec[2] = CHAN_TO_FLOAT(span->array->rgba[i][BCOMP]);
vec[3] = CHAN_TO_FLOAT(span->array->rgba[i][ACOMP]);
- fetch_input_vec4 ("gl_Color", vec, 0, fs);
+ (**pro).UpdateFixedVarying (pro, SLANG_FRAGMENT_FIXED_COLOR, vec, 0, 4 * sizeof (GLfloat),
+ GL_TRUE);
for (j = 0; j < ctx->Const.MaxTextureCoordUnits; j++)
{
vec[0] = span->array->texcoords[j][i][0];
vec[1] = span->array->texcoords[j][i][1];
vec[2] = span->array->texcoords[j][i][2];
vec[3] = span->array->texcoords[j][i][3];
- fetch_input_vec4 ("gl_TexCoord", vec, j, fs);
+ (**pro).UpdateFixedVarying (pro, SLANG_FRAGMENT_FIXED_TEXCOORD, vec, j,
+ 4 * sizeof (GLfloat), GL_TRUE);
}
- _slang_exec_fragment_shader (fs);
+ _slang_exec_fragment_shader (pro);
- _slang_fetch_discard (fs, &kill);
- if (kill)
+ _slang_fetch_discard (pro, &discard);
+ if (discard)
{
span->array->mask[i] = GL_FALSE;
span->writeAll = GL_FALSE;
}
- fetch_output_vec4 ("gl_FragColor", vec, 0, fs);
- UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][RCOMP], vec[0]);
- UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][GCOMP], vec[1]);
- UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][BCOMP], vec[2]);
- UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][ACOMP], vec[3]);
+ else
+ {
+ (**pro).UpdateFixedVarying (pro, SLANG_FRAGMENT_FIXED_FRAGCOLOR, vec, 0,
+ 4 * sizeof (GLfloat), GL_FALSE);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][RCOMP], vec[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][GCOMP], vec[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][BCOMP], vec[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][ACOMP], vec[3]);
+ }
}
}
diff --git a/src/mesa/tnl/t_vb_arbshader.c b/src/mesa/tnl/t_vb_arbshader.c
index c8f826571ad..65304372ddf 100644
--- a/src/mesa/tnl/t_vb_arbshader.c
+++ b/src/mesa/tnl/t_vb_arbshader.c
@@ -32,6 +32,7 @@
#include "shaderobjects_3dlabs.h"
#include "t_pipeline.h"
#include "slang_utility.h"
+#include "slang_link.h"
typedef struct
{
@@ -90,42 +91,40 @@ static void validate_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stag
{
}
-static void fetch_input_float (const char *name, GLuint attr, GLuint i, struct vertex_buffer *vb,
- struct gl2_vertex_shader_intf **vs)
+static GLvoid fetch_input_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ struct vertex_buffer *vb)
{
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
- /*const GLuint size = vb->AttribPtr[attr]->size;*/
const GLuint stride = vb->AttribPtr[attr]->stride;
const GLfloat *data = (const GLfloat *) (ptr + stride * i);
- float vec[1];
+ GLfloat vec[1];
vec[0] = data[0];
- _slang_fetch_float (vs, name, vec, 1);
+ (**pro).UpdateFixedAttribute (pro, index, vec, 0, sizeof (GLfloat), GL_TRUE);
}
-static void fetch_input_vec3 (const char *name, GLuint attr, GLuint i, struct vertex_buffer *vb,
- struct gl2_vertex_shader_intf **vs)
+static GLvoid fetch_input_vec3 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ struct vertex_buffer *vb)
{
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
- /*const GLuint size = vb->AttribPtr[attr]->size;*/
const GLuint stride = vb->AttribPtr[attr]->stride;
const GLfloat *data = (const GLfloat *) (ptr + stride * i);
- float vec[3];
+ GLfloat vec[3];
vec[0] = data[0];
vec[1] = data[1];
vec[2] = data[2];
- _slang_fetch_vec3 (vs, name, vec, 1);
+ (**pro).UpdateFixedAttribute (pro, index, vec, 0, 3 * sizeof (GLfloat), GL_TRUE);
}
-static void fetch_input_vec4 (const char *name, GLuint attr, GLuint i, struct vertex_buffer *vb,
- struct gl2_vertex_shader_intf **vs)
+static void fetch_input_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ struct vertex_buffer *vb)
{
const GLubyte *ptr = (const GLubyte *) vb->AttribPtr[attr]->data;
const GLuint size = vb->AttribPtr[attr]->size;
const GLuint stride = vb->AttribPtr[attr]->stride;
const GLfloat *data = (const GLfloat *) (ptr + stride * i);
- float vec[4];
+ GLfloat vec[4];
switch (size)
{
@@ -148,82 +147,21 @@ static void fetch_input_vec4 (const char *name, GLuint attr, GLuint i, struct ve
vec[3] = data[3];
break;
}
- _slang_fetch_vec4 (vs, name, vec, 0, 1);
+ (**pro).UpdateFixedAttribute (pro, index, vec, 0, 4 * sizeof (GLfloat), GL_TRUE);
}
-static void fetch_output_float (const char *name, GLuint attr, GLuint i, arbvs_stage_data *store,
- struct gl2_vertex_shader_intf **vs)
+static GLvoid fetch_output_float (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ arbvs_stage_data *store)
{
- float vec[1];
-
- _slang_fetch_float (vs, name, vec, 0);
- _mesa_memcpy (&store->outputs[attr].data[i], vec, 4);
+ (**pro).UpdateFixedAttribute (pro, index, &store->outputs[attr].data[i], 0, sizeof (GLfloat),
+ GL_FALSE);
}
-static void fetch_output_vec4 (const char *name, GLuint attr, GLuint i, GLuint index,
- arbvs_stage_data *store, struct gl2_vertex_shader_intf **vs)
+static void fetch_output_vec4 (struct gl2_program_intf **pro, GLuint index, GLuint attr, GLuint i,
+ GLuint offset, arbvs_stage_data *store)
{
- float vec[4];
-
- _slang_fetch_vec4 (vs, name, vec, index, 0);
- _mesa_memcpy (&store->outputs[attr].data[i], vec, 16);
-}
-
-static void fetch_uniform_mat4 (const char *name, GLmatrix *matrix, GLuint index,
- struct gl2_vertex_shader_intf **vs)
-{
- GLuint len;
- GLfloat mat[16];
- char buffer[64];
-
- _mesa_strcpy (buffer, name);
- len = _mesa_strlen (name);
-
- /* we want inverse matrix */
- if (!matrix->inv)
- {
- /* allocate inverse matrix and make it dirty */
- _math_matrix_alloc_inv (matrix);
- _math_matrix_loadf (matrix, matrix->m);
- }
- _math_matrix_analyse (matrix);
-
- /* identity */
- _slang_fetch_mat4 (vs, name, matrix->m, index, 1);
-
- /* transpose */
- _mesa_strcpy (buffer + len, "Transpose");
- _math_transposef (mat, matrix->m);
- _slang_fetch_mat4 (vs, buffer, mat, index, 1);
-
- /* inverse */
- _mesa_strcpy (buffer + len, "Inverse");
- _slang_fetch_mat4 (vs, buffer, matrix->inv, index, 1);
-
- /* inverse transpose */
- _mesa_strcpy (buffer + len, "InverseTranspose");
- _math_transposef (mat, matrix->inv);
- _slang_fetch_mat4 (vs, buffer, mat, index, 1);
-}
-
-static void fetch_normal_matrix (const char *name, GLmatrix *matrix,
- struct gl2_vertex_shader_intf **vs)
-{
- GLfloat mat[9];
-
- _math_matrix_analyse (matrix);
-
- /* inverse transpose */
- mat[0] = matrix->inv[0];
- mat[1] = matrix->inv[4];
- mat[2] = matrix->inv[8];
- mat[3] = matrix->inv[1];
- mat[4] = matrix->inv[5];
- mat[5] = matrix->inv[9];
- mat[6] = matrix->inv[2];
- mat[7] = matrix->inv[6];
- mat[8] = matrix->inv[10];
- _slang_fetch_mat3 (vs, name, mat, 0, 1);
+ (**pro).UpdateFixedAttribute (pro, index, &store->outputs[attr].data[i], offset,
+ 4 * sizeof (GLfloat), GL_FALSE);
}
static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stage *stage)
@@ -231,82 +169,45 @@ static GLboolean run_arb_vertex_shader (GLcontext *ctx, struct tnl_pipeline_stag
TNLcontext *tnl = TNL_CONTEXT(ctx);
struct vertex_buffer *vb = &tnl->vb;
arbvs_stage_data *store = ARBVS_STAGE_DATA(stage);
- struct gl2_program_intf **prog;
- struct gl2_vertex_shader_intf **vs = NULL;
- GLsizei count, i, j;
+ struct gl2_program_intf **pro;
+ GLsizei i, j;
- prog = ctx->ShaderObjects.CurrentProgram;
- if (prog == NULL)
+ pro = ctx->ShaderObjects.CurrentProgram;
+ if (pro == NULL)
return GL_TRUE;
- count = (**prog)._container.GetAttachedCount ((struct gl2_container_intf **) prog);
- for (i = 0; i < count; i++)
- {
- struct gl2_generic_intf **obj;
- struct gl2_unknown_intf **unk;
-
- obj = (**prog)._container.GetAttached ((struct gl2_container_intf **) prog, i);
- unk = (**obj)._unknown.QueryInterface ((struct gl2_unknown_intf **) obj, UIID_VERTEX_SHADER);
- (**obj)._unknown.Release ((struct gl2_unknown_intf **) obj);
- if (unk != NULL)
- {
- vs = (struct gl2_vertex_shader_intf **) unk;
- break;
- }
- }
- if (vs == NULL)
- return GL_TRUE;
-
- fetch_uniform_mat4 ("gl_ModelViewMatrix", ctx->ModelviewMatrixStack.Top, 0, vs);
- fetch_uniform_mat4 ("gl_ProjectionMatrix", ctx->ProjectionMatrixStack.Top, 0, vs);
- fetch_uniform_mat4 ("gl_ModelViewProjectionMatrix", &ctx->_ModelProjectMatrix, 0, vs);
- for (j = 0; j < 8; j++)
- fetch_uniform_mat4 ("gl_TextureMatrix", ctx->TextureMatrixStack[j].Top, j, vs);
- fetch_normal_matrix ("gl_NormalMatrix", ctx->ModelviewMatrixStack.Top, vs);
- /* XXX: fetch uniform float gl_NormalScale */
- /* XXX: fetch uniform mat4 gl_ClipPlane */
- /* XXX: fetch uniform mat4 gl_TextureEnvColor */
- /* XXX: fetch uniform mat4 gl_EyePlaneS */
- /* XXX: fetch uniform mat4 gl_EyePlaneT */
- /* XXX: fetch uniform mat4 gl_EyePlaneR */
- /* XXX: fetch uniform mat4 gl_EyePlaneQ */
- /* XXX: fetch uniform mat4 gl_ObjectPlaneS */
- /* XXX: fetch uniform mat4 gl_ObjectPlaneT */
- /* XXX: fetch uniform mat4 gl_ObjectPlaneR */
- /* XXX: fetch uniform mat4 gl_ObjectPlaneQ */
+ (**pro).UpdateFixedUniforms (pro);
for (i = 0; i < vb->Count; i++)
{
- fetch_input_vec4 ("gl_Vertex", _TNL_ATTRIB_POS, i, vb, vs);
- fetch_input_vec3 ("gl_Normal", _TNL_ATTRIB_NORMAL, i, vb, vs);
- fetch_input_vec4 ("gl_Color", _TNL_ATTRIB_COLOR0, i, vb, vs);
- fetch_input_vec4 ("gl_SecondaryColor", _TNL_ATTRIB_COLOR1, i, vb, vs);
- fetch_input_float ("gl_FogCoord", _TNL_ATTRIB_FOG, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord0", _TNL_ATTRIB_TEX0, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord1", _TNL_ATTRIB_TEX1, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord2", _TNL_ATTRIB_TEX2, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord3", _TNL_ATTRIB_TEX3, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord4", _TNL_ATTRIB_TEX4, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord5", _TNL_ATTRIB_TEX5, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord6", _TNL_ATTRIB_TEX6, i, vb, vs);
- fetch_input_vec4 ("gl_MultiTexCoord7", _TNL_ATTRIB_TEX7, i, vb, vs);
-
- _slang_exec_vertex_shader (vs);
-
- fetch_output_vec4 ("gl_Position", VERT_RESULT_HPOS, i, 0, store, vs);
- fetch_output_vec4 ("gl_FrontColor", VERT_RESULT_COL0, i, 0, store, vs);
- fetch_output_vec4 ("gl_FrontSecondaryColor", VERT_RESULT_COL1, i, 0, store, vs);
- fetch_output_float ("gl_FogFragCoord", VERT_RESULT_FOGC, i, store, vs);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_VERTEX, _TNL_ATTRIB_POS, i, vb);
+ fetch_input_vec3 (pro, SLANG_VERTEX_FIXED_NORMAL, _TNL_ATTRIB_NORMAL, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_COLOR, _TNL_ATTRIB_COLOR0, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_SECONDARYCOLOR, _TNL_ATTRIB_COLOR1, i, vb);
+ fetch_input_float (pro, SLANG_VERTEX_FIXED_FOGCOORD, _TNL_ATTRIB_FOG, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD0, _TNL_ATTRIB_TEX0, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD1, _TNL_ATTRIB_TEX1, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD2, _TNL_ATTRIB_TEX2, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD3, _TNL_ATTRIB_TEX3, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD4, _TNL_ATTRIB_TEX4, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD5, _TNL_ATTRIB_TEX5, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD6, _TNL_ATTRIB_TEX6, i, vb);
+ fetch_input_vec4 (pro, SLANG_VERTEX_FIXED_MULTITEXCOORD7, _TNL_ATTRIB_TEX7, i, vb);
+
+ _slang_exec_vertex_shader (pro);
+
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_POSITION, VERT_RESULT_HPOS, i, 0, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTCOLOR, VERT_RESULT_COL0, i, 0, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_FRONTSECONDARYCOLOR, VERT_RESULT_COL1, i, 0, store);
+ fetch_output_float (pro, SLANG_VERTEX_FIXED_FOGFRAGCOORD, VERT_RESULT_FOGC, i, store);
for (j = 0; j < 8; j++)
- fetch_output_vec4 ("gl_TexCoord", VERT_RESULT_TEX0 + j, i, j, store, vs);
- fetch_output_float ("gl_PointSize", VERT_RESULT_PSIZ, i, store, vs);
- fetch_output_vec4 ("gl_BackColor", VERT_RESULT_BFC0, i, 0, store, vs);
- fetch_output_vec4 ("gl_BackSecondaryColor", VERT_RESULT_BFC1, i, 0, store, vs);
- /* XXX: fetch output gl_ClipVertex */
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_TEXCOORD, VERT_RESULT_TEX0 + j, i, j, store);
+ fetch_output_float (pro, SLANG_VERTEX_FIXED_POINTSIZE, VERT_RESULT_PSIZ, i, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKCOLOR, VERT_RESULT_BFC0, i, 0, store);
+ fetch_output_vec4 (pro, SLANG_VERTEX_FIXED_BACKSECONDARYCOLOR, VERT_RESULT_BFC1, i, 0, store);
+ /* XXX: fetch output SLANG_VERTEX_FIXED_CLIPVERTEX */
}
- (**vs)._shader._generic._unknown.Release ((struct gl2_unknown_intf **) vs);
-
vb->ClipPtr = &store->outputs[VERT_RESULT_HPOS];
vb->ClipPtr->count = vb->Count;
vb->ColorPtr[0] = &store->outputs[VERT_RESULT_COL0];
diff --git a/src/mesa/x86/rtasm/x86sse.c b/src/mesa/x86/rtasm/x86sse.c
index 0c9ffe25fa2..82a18f012a1 100644
--- a/src/mesa/x86/rtasm/x86sse.c
+++ b/src/mesa/x86/rtasm/x86sse.c
@@ -1,4 +1,4 @@
-#if defined(USE_X86_ASM)
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
#include "imports.h"
#include "x86sse.h"
@@ -85,10 +85,10 @@ static void emit_modrm( struct x86_function *p,
case mod_INDIRECT:
break;
case mod_DISP8:
- emit_1b(p, regmem.disp);
+ emit_1b(p, regmem.disp);
break;
case mod_DISP32:
- emit_1i(p, regmem.disp);
+ emit_1i(p, regmem.disp);
break;
default:
assert(0);
@@ -142,8 +142,8 @@ static void emit_op_modrm( struct x86_function *p,
/* Create and manipulate registers and regmem values:
*/
-struct x86_reg x86_make_reg( GLuint file,
- GLuint idx )
+struct x86_reg x86_make_reg( enum x86_reg_file file,
+ enum x86_reg_name idx )
{
struct x86_reg reg;
@@ -198,7 +198,7 @@ GLubyte *x86_get_label( struct x86_function *p )
void x86_jcc( struct x86_function *p,
- GLuint cc,
+ enum x86_cc cc,
GLubyte *label )
{
GLint offset = label - (x86_get_label(p) + 2);
@@ -217,11 +217,25 @@ void x86_jcc( struct x86_function *p,
/* Always use a 32bit offset for forward jumps:
*/
GLubyte *x86_jcc_forward( struct x86_function *p,
- GLuint cc )
+ enum x86_cc cc )
{
emit_2ub(p, 0x0f, 0x80 + cc);
emit_1i(p, 0);
return x86_get_label(p);
+}
+
+GLubyte *x86_jmp_forward( struct x86_function *p)
+{
+ emit_1ub(p, 0xe9);
+ emit_1i(p, 0);
+ return x86_get_label(p);
+}
+
+GLubyte *x86_call_forward( struct x86_function *p)
+{
+ emit_1ub(p, 0xe8);
+ emit_1i(p, 0);
+ return x86_get_label(p);
}
/* Fixup offset from forward jump:
@@ -230,6 +244,29 @@ void x86_fixup_fwd_jump( struct x86_function *p,
GLubyte *fixup )
{
*(int *)(fixup - 4) = x86_get_label(p) - fixup;
+}
+
+void x86_jmp( struct x86_function *p, GLubyte *label)
+{
+ emit_1ub(p, 0xe9);
+ emit_1i(p, label - x86_get_label(p) - 4);
+}
+
+void x86_call( struct x86_function *p, GLubyte *label)
+{
+ emit_1ub(p, 0xe8);
+ emit_1i(p, label - x86_get_label(p) - 4);
+}
+
+/* michal:
+ * Temporary. As I need immediate operands, and dont want to mess with the codegen,
+ * I load the immediate into general purpose register and use it.
+ */
+void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm )
+{
+ assert(dst.mod == mod_REG);
+ emit_1ub(p, 0xb8 + dst.idx);
+ emit_1i(p, imm);
}
void x86_push( struct x86_function *p,
@@ -307,6 +344,27 @@ void x86_test( struct x86_function *p,
{
emit_1ub(p, 0x85);
emit_modrm( p, dst, src );
+}
+
+void x86_add( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_op_modrm(p, 0x03, 0x01, dst, src );
+}
+
+void x86_mul( struct x86_function *p,
+ struct x86_reg src )
+{
+ assert (src.file == file_REG32 && src.mod == mod_REG);
+ emit_op_modrm(p, 0xf7, 0, x86_make_reg (file_REG32, reg_SP), src );
+}
+
+void x86_sub( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_op_modrm(p, 0x2b, 0x29, dst, src );
}
@@ -971,8 +1029,13 @@ struct x86_reg x86_fn_arg( struct x86_function *p,
void x86_init_func( struct x86_function *p )
{
- p->store = _mesa_exec_malloc(1024);
- p->csr = p->store;
+ x86_init_func_size(p, 1024);
+}
+
+void x86_init_func_size( struct x86_function *p, GLuint code_size )
+{
+ p->store = _mesa_exec_malloc(code_size);
+ p->csr = p->store;
}
void x86_release_func( struct x86_function *p )
@@ -985,7 +1048,7 @@ void (*x86_get_func( struct x86_function *p ))(void)
{
if (DISASSEM)
_mesa_printf("disassemble %p %p\n", p->store, p->csr);
- return (void (*)())p->store;
+ return (void (*)(void))p->store;
}
#else
diff --git a/src/mesa/x86/rtasm/x86sse.h b/src/mesa/x86/rtasm/x86sse.h
index 611d01e1cb3..55a98564afb 100644
--- a/src/mesa/x86/rtasm/x86sse.h
+++ b/src/mesa/x86/rtasm/x86sse.h
@@ -2,7 +2,7 @@
#ifndef _X86SSE_H_
#define _X86SSE_H_
-#if defined(USE_X86_ASM)
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
#include "glheader.h"
@@ -80,7 +80,8 @@ enum sse_cc {
*/
-void x86_init_func( struct x86_function *p );
+void x86_init_func( struct x86_function *p );
+void x86_init_func_size( struct x86_function *p, GLuint code_size );
void x86_release_func( struct x86_function *p );
void (*x86_get_func( struct x86_function *p ))( void );
@@ -108,10 +109,24 @@ void x86_jcc( struct x86_function *p,
GLubyte *label );
GLubyte *x86_jcc_forward( struct x86_function *p,
- enum x86_cc cc );
+ enum x86_cc cc );
+
+GLubyte *x86_jmp_forward( struct x86_function *p);
+
+GLubyte *x86_call_forward( struct x86_function *p);
void x86_fixup_fwd_jump( struct x86_function *p,
- GLubyte *fixup );
+ GLubyte *fixup );
+
+void x86_jmp( struct x86_function *p, GLubyte *label );
+
+void x86_call( struct x86_function *p, GLubyte *label );
+
+/* michal:
+ * Temporary. As I need immediate operands, and dont want to mess with the codegen,
+ * I load the immediate into general purpose register and use it.
+ */
+void x86_mov_reg_imm( struct x86_function *p, struct x86_reg dst, GLint imm );
/* Macro for sse_shufps() and sse2_pshufd():
@@ -153,15 +168,18 @@ void sse_mulps( struct x86_function *p, struct x86_reg dst, struct x86_reg src )
void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf );
-
+
+void x86_add( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_cmp( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_dec( struct x86_function *p, struct x86_reg reg );
void x86_inc( struct x86_function *p, struct x86_reg reg );
void x86_lea( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
-void x86_mov( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void x86_mov( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void x86_mul( struct x86_function *p, struct x86_reg src );
void x86_pop( struct x86_function *p, struct x86_reg reg );
void x86_push( struct x86_function *p, struct x86_reg reg );
-void x86_ret( struct x86_function *p );
+void x86_ret( struct x86_function *p );
+void x86_sub( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_test( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_xor( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
void x86_sahf( struct x86_function *p );