summaryrefslogtreecommitdiff
path: root/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/accum.h2
-rw-r--r--src/mesa/main/attrib.h2
-rw-r--r--src/mesa/main/bufferobj.c22
-rw-r--r--src/mesa/main/colortab.h2
-rw-r--r--src/mesa/main/compiler.h5
-rw-r--r--src/mesa/main/context.c31
-rw-r--r--src/mesa/main/convolve.h2
-rw-r--r--src/mesa/main/core.h66
-rw-r--r--src/mesa/main/dd.h51
-rw-r--r--src/mesa/main/depthstencil.c4
-rw-r--r--src/mesa/main/dlist.c10
-rw-r--r--src/mesa/main/dlist.h2
-rw-r--r--src/mesa/main/es_generator.py10
-rw-r--r--src/mesa/main/extensions.c2
-rw-r--r--src/mesa/main/fbobject.c2
-rw-r--r--src/mesa/main/feedback.h2
-rw-r--r--src/mesa/main/formats.c12
-rw-r--r--src/mesa/main/formats.h3
-rw-r--r--src/mesa/main/framebuffer.c4
-rw-r--r--src/mesa/main/get.c18
-rw-r--r--src/mesa/main/getstring.c4
-rw-r--r--src/mesa/main/imports.h52
-rw-r--r--src/mesa/main/mipmap.c17
-rw-r--r--src/mesa/main/mtypes.h56
-rw-r--r--src/mesa/main/querymatrix.c3
-rw-r--r--src/mesa/main/shaderapi.c12
-rw-r--r--src/mesa/main/shaderobj.c60
-rw-r--r--src/mesa/main/shaderobj.h29
-rw-r--r--src/mesa/main/shared.c4
-rw-r--r--src/mesa/main/texcompress_s3tc.c1
-rw-r--r--src/mesa/main/transformfeedback.c7
-rw-r--r--src/mesa/main/uniforms.c108
-rw-r--r--src/mesa/main/uniforms.h15
33 files changed, 441 insertions, 179 deletions
diff --git a/src/mesa/main/accum.h b/src/mesa/main/accum.h
index 63740f07ed..c2b74b23cb 100644
--- a/src/mesa/main/accum.h
+++ b/src/mesa/main/accum.h
@@ -55,6 +55,8 @@ _mesa_init_accum_dispatch(struct _glapi_table *disp);
#else /* FEATURE_accum */
+#include "main/compiler.h"
+
#define _MESA_INIT_ACCUM_FUNCTIONS(driver, impl) do { } while (0)
static INLINE void
diff --git a/src/mesa/main/attrib.h b/src/mesa/main/attrib.h
index 6b48a17663..83b28a65b7 100644
--- a/src/mesa/main/attrib.h
+++ b/src/mesa/main/attrib.h
@@ -48,6 +48,8 @@ _mesa_init_attrib_dispatch(struct _glapi_table *disp);
#else /* FEATURE_attrib_stack */
+#include "main/compiler.h"
+
static INLINE void
_mesa_PushClientAttrib( GLbitfield mask )
{
diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index 4e232b5731..4797f29b4d 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -590,7 +590,7 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
bindTarget = get_buffer_target(ctx, target);
if (!bindTarget) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindBufferARB(target 0x%x)", target);
return;
}
@@ -1553,27 +1553,27 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget,
if (readOffset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyBuffserSubData(readOffset = %d)", readOffset);
+ "glCopyBuffserSubData(readOffset = %d)", (int) readOffset);
return;
}
if (writeOffset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glCopyBuffserSubData(writeOffset = %d)", writeOffset);
+ "glCopyBuffserSubData(writeOffset = %d)", (int) writeOffset);
return;
}
if (readOffset + size > src->Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCopyBuffserSubData(readOffset + size = %d)",
- readOffset, size);
+ (int) (readOffset + size));
return;
}
if (writeOffset + size > dst->Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glCopyBuffserSubData(writeOffset + size = %d)",
- writeOffset, size);
+ (int) (writeOffset + size));
return;
}
@@ -1617,13 +1617,13 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
if (offset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glMapBufferRange(offset = %ld)", offset);
+ "glMapBufferRange(offset = %ld)", (long)offset);
return NULL;
}
if (length < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glMapBufferRange(length = %ld)", length);
+ "glMapBufferRange(length = %ld)", (long)length);
return NULL;
}
@@ -1708,13 +1708,13 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
if (offset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glMapBufferRange(offset = %ld)", offset);
+ "glMapBufferRange(offset = %ld)", (long)offset);
return;
}
if (length < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glMapBufferRange(length = %ld)", length);
+ "glMapBufferRange(length = %ld)", (long)length);
return;
}
@@ -1746,8 +1746,8 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
if (offset + length > bufObj->Length) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glMapBufferRange(offset %ld + length %ld > mapped length %ld)",
- offset, length, bufObj->Length);
+ "glMapBufferRange(offset %ld + length %ld > mapped length %ld)",
+ (long)offset, (long)length, (long)bufObj->Length);
return;
}
diff --git a/src/mesa/main/colortab.h b/src/mesa/main/colortab.h
index 652fb58246..744f092d93 100644
--- a/src/mesa/main/colortab.h
+++ b/src/mesa/main/colortab.h
@@ -53,6 +53,8 @@ _mesa_init_colortable_dispatch(struct _glapi_table *disp);
#else /* FEATURE_colortable */
+#include "main/compiler.h"
+
#define _MESA_INIT_COLORTABLE_FUNCTIONS(driver, impl) do { } while (0)
static INLINE void GLAPIENTRY
diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
index e0507ccf86..ded69c3106 100644
--- a/src/mesa/main/compiler.h
+++ b/src/mesa/main/compiler.h
@@ -316,6 +316,11 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
#endif
#endif
+#if (__GNUC__ >= 3)
+#define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
+#else
+#define PRINTFLIKE(f, a)
+#endif
#ifndef NULL
#define NULL 0
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index b01fed1781..8e34ec4124 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -140,6 +140,10 @@
#include "sparc/sparc.h"
#endif
+#include "glsl_parser_extras.h"
+
+
+
#ifndef MESA_VERBOSE
int MESA_VERBOSE = 0;
#endif
@@ -339,16 +343,16 @@ _mesa_destroy_visual( GLvisual *vis )
static void
dummy_enum_func(void)
{
- gl_buffer_index bi;
- gl_colortable_index ci;
- gl_face_index fi;
- gl_frag_attrib fa;
- gl_frag_result fr;
- gl_texture_index ti;
- gl_vert_attrib va;
- gl_vert_result vr;
- gl_geom_attrib ga;
- gl_geom_result gr;
+ gl_buffer_index bi = BUFFER_FRONT_LEFT;
+ gl_colortable_index ci = COLORTABLE_PRECONVOLUTION;
+ gl_face_index fi = FACE_POS_X;
+ gl_frag_attrib fa = FRAG_ATTRIB_WPOS;
+ gl_frag_result fr = FRAG_RESULT_DEPTH;
+ gl_texture_index ti = TEXTURE_2D_ARRAY_INDEX;
+ gl_vert_attrib va = VERT_ATTRIB_POS;
+ gl_vert_result vr = VERT_RESULT_HPOS;
+ gl_geom_attrib ga = GEOM_ATTRIB_POSITION;
+ gl_geom_result gr = GEOM_RESULT_POS;
(void) bi;
(void) ci;
@@ -434,6 +438,11 @@ one_time_init( GLcontext *ctx )
}
_glthread_UNLOCK_MUTEX(OneTimeLock);
+ /* Hopefully atexit() is widely available. If not, we may need some
+ * #ifdef tests here.
+ */
+ atexit(_mesa_destroy_shader_compiler);
+
dummy_enum_func();
}
@@ -1695,7 +1704,7 @@ _mesa_valid_to_render(GLcontext *ctx, const char *where)
/* using shaders */
if (!ctx->Shader.CurrentProgram->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "%s(shader not linked), where");
+ "%s(shader not linked)", where);
return GL_FALSE;
}
#if 0 /* not normally enabled */
diff --git a/src/mesa/main/convolve.h b/src/mesa/main/convolve.h
index 59492bc7c5..d1401885df 100644
--- a/src/mesa/main/convolve.h
+++ b/src/mesa/main/convolve.h
@@ -70,6 +70,8 @@ _mesa_init_convolve_dispatch(struct _glapi_table *disp);
#else /* FEATURE_convolve */
+#include "main/compiler.h"
+
#define _MESA_INIT_CONVOLVE_FUNCTIONS(driver, impl) do { } while (0)
static INLINE void GLAPIENTRY
diff --git a/src/mesa/main/core.h b/src/mesa/main/core.h
new file mode 100644
index 0000000000..ea6e6bf118
--- /dev/null
+++ b/src/mesa/main/core.h
@@ -0,0 +1,66 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 7.9
+ *
+ * Copyright (C) 2010 LunarG Inc.
+ *
+ * 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+
+/**
+ * \file core.h
+ * The public header of core mesa.
+ *
+ * This file is the (only) public header of core mesa. It is supposed to be
+ * used by GLX, WGL, and GLSL. It is important that headers directly or
+ * indirectly included here do not perform feature tests (#if FEATURE_xxx).
+ */
+
+
+#ifndef CORE_H
+#define CORE_H
+
+
+#include "main/glheader.h"
+#include "main/compiler.h"
+#include "main/imports.h"
+#include "main/macros.h"
+
+#include "main/version.h" /* for MESA_VERSION_STRING */
+#include "main/context.h" /* for _mesa_share_state */
+#include "main/mtypes.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* for GLSL */
+#include "program/prog_parameter.h"
+#include "program/prog_uniform.h"
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* CORE_H */
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 825073ca88..8a20a66363 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -36,7 +36,7 @@
struct gl_pixelstore_attrib;
struct gl_display_list;
-#if FEATURE_ARB_vertex_buffer_object
+/* GL_ARB_vertex_buffer_object */
/* Modifies GL_MAP_UNSYNCHRONIZED_BIT to allow driver to fail (return
* NULL) if buffer is unavailable for immediate mapping.
*
@@ -49,7 +49,6 @@ struct gl_display_list;
* respect the contents of already referenced data.
*/
#define MESA_MAP_NOWAIT_BIT 0x0040
-#endif
/**
@@ -595,6 +594,27 @@ struct dd_function_table {
/*@}*/
+ /**
+ * \name GLSL shader/program functions.
+ */
+ /*@{*/
+ /**
+ * Called when a shader is compiled.
+ *
+ * Note that not all shader objects get ShaderCompile called on
+ * them. Notably, the shaders containing builtin functions do not
+ * have CompileShader() called, so if lowering passes are done they
+ * need to also be performed in LinkShader().
+ */
+ GLboolean (*CompileShader)(GLcontext *ctx, struct gl_shader *shader);
+ /**
+ * Called when a shader program is linked.
+ *
+ * This gives drivers an opportunity to clone the IR and make their
+ * own transformations on it for the purposes of code generation.
+ */
+ GLboolean (*LinkShader)(GLcontext *ctx, struct gl_shader_program *shader);
+ /*@}*/
/**
* \name State-changing functions.
@@ -709,7 +729,6 @@ struct dd_function_table {
/**
* \name Vertex/pixel buffer object functions
*/
-#if FEATURE_ARB_vertex_buffer_object
/*@{*/
void (*BindBuffer)( GLcontext *ctx, GLenum target,
struct gl_buffer_object *obj );
@@ -753,12 +772,10 @@ struct dd_function_table {
GLboolean (*UnmapBuffer)( GLcontext *ctx, GLenum target,
struct gl_buffer_object *obj );
/*@}*/
-#endif
/**
* \name Functions for GL_APPLE_object_purgeable
*/
-#if FEATURE_APPLE_object_purgeable
/*@{*/
/* variations on ObjectPurgeable */
GLenum (*BufferObjectPurgeable)( GLcontext *ctx, struct gl_buffer_object *obj, GLenum option );
@@ -770,12 +787,10 @@ struct dd_function_table {
GLenum (*RenderObjectUnpurgeable)( GLcontext *ctx, struct gl_renderbuffer *obj, GLenum option );
GLenum (*TextureObjectUnpurgeable)( GLcontext *ctx, struct gl_texture_object *obj, GLenum option );
/*@}*/
-#endif
/**
- * \name Functions for GL_EXT_framebuffer_object
+ * \name Functions for GL_EXT_framebuffer_{object,blit}.
*/
-#if FEATURE_EXT_framebuffer_object
/*@{*/
struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name);
struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name);
@@ -794,13 +809,10 @@ struct dd_function_table {
void (*ValidateFramebuffer)(GLcontext *ctx,
struct gl_framebuffer *fb);
/*@}*/
-#endif
-#if FEATURE_EXT_framebuffer_blit
void (*BlitFramebuffer)(GLcontext *ctx,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
-#endif
/**
* \name Query objects
@@ -955,7 +967,6 @@ struct dd_function_table {
void (*EndCallList)( GLcontext *ctx );
-#if FEATURE_ARB_sync
/**
* \name GL_ARB_sync interfaces
*/
@@ -969,14 +980,12 @@ struct dd_function_table {
void (*ServerWaitSync)(GLcontext *, struct gl_sync_object *,
GLbitfield, GLuint64);
/*@}*/
-#endif
/** GL_NV_conditional_render */
void (*BeginConditionalRender)(GLcontext *ctx, struct gl_query_object *q,
GLenum mode);
void (*EndConditionalRender)(GLcontext *ctx, struct gl_query_object *q);
-#if FEATURE_OES_draw_texture
/**
* \name GL_OES_draw_texture interface
*/
@@ -984,9 +993,10 @@ struct dd_function_table {
void (*DrawTex)(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
GLfloat width, GLfloat height);
/*@}*/
-#endif
-#if FEATURE_OES_EGL_image
+ /**
+ * \name GL_OES_EGL_image interface
+ */
void (*EGLImageTargetTexture2D)(GLcontext *ctx, GLenum target,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage,
@@ -994,9 +1004,10 @@ struct dd_function_table {
void (*EGLImageTargetRenderbufferStorage)(GLcontext *ctx,
struct gl_renderbuffer *rb,
void *image_handle);
-#endif
-#if FEATURE_EXT_transform_feedback
+ /**
+ * \name GL_EXT_transform_feedback interface
+ */
struct gl_transform_feedback_object *
(*NewTransformFeedback)(GLcontext *ctx, GLuint name);
void (*DeleteTransformFeedback)(GLcontext *ctx,
@@ -1011,7 +1022,6 @@ struct dd_function_table {
struct gl_transform_feedback_object *obj);
void (*DrawTransformFeedback)(GLcontext *ctx, GLenum mode,
struct gl_transform_feedback_object *obj);
-#endif
};
@@ -1094,7 +1104,7 @@ typedef struct {
void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v );
void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
-#if FEATURE_ARB_vertex_program
+ /* GL_ARB_vertex_program */
void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x );
void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v );
void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y );
@@ -1103,7 +1113,6 @@ typedef struct {
void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v );
void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v );
-#endif
/*@}*/
void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
diff --git a/src/mesa/main/depthstencil.c b/src/mesa/main/depthstencil.c
index 885e718a76..dbaa841645 100644
--- a/src/mesa/main/depthstencil.c
+++ b/src/mesa/main/depthstencil.c
@@ -359,7 +359,7 @@ _mesa_new_z24_renderbuffer_wrapper(GLcontext *ctx,
dsrb->Format == MESA_FORMAT_X8_Z24);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- z24rb = _mesa_new_renderbuffer(ctx, 0);
+ z24rb = ctx->Driver.NewRenderbuffer(ctx, 0);
if (!z24rb)
return NULL;
@@ -645,7 +645,7 @@ _mesa_new_s8_renderbuffer_wrapper(GLcontext *ctx, struct gl_renderbuffer *dsrb)
dsrb->Format == MESA_FORMAT_S8_Z24);
ASSERT(dsrb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- s8rb = _mesa_new_renderbuffer(ctx, 0);
+ s8rb = ctx->Driver.NewRenderbuffer(ctx, 0);
if (!s8rb)
return NULL;
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 727414d529..5042e14a54 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -6070,8 +6070,15 @@ exec_GetAttribLocationARB(GLuint program, const GLchar *name)
FLUSH_VERTICES(ctx, 0);
return CALL_GetAttribLocationARB(ctx->Exec, (program, name));
}
-/* XXX more shader functions needed here */
+static GLint GLAPIENTRY
+exec_GetUniformLocationARB(GLuint program, const GLchar *name)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ return CALL_GetUniformLocationARB(ctx->Exec, (program, name));
+}
+/* XXX more shader functions needed here */
#if FEATURE_EXT_framebuffer_blit
@@ -9491,6 +9498,7 @@ _mesa_create_save_table(void)
/* ARB 30/31/32. GL_ARB_shader_objects, GL_ARB_vertex/fragment_shader */
SET_BindAttribLocationARB(table, exec_BindAttribLocationARB);
SET_GetAttribLocationARB(table, exec_GetAttribLocationARB);
+ SET_GetUniformLocationARB(table, exec_GetUniformLocationARB);
/* XXX additional functions need to be implemented here! */
/* 299. GL_EXT_blend_equation_separate */
diff --git a/src/mesa/main/dlist.h b/src/mesa/main/dlist.h
index f8255facc5..d3f5c5cb4e 100644
--- a/src/mesa/main/dlist.h
+++ b/src/mesa/main/dlist.h
@@ -81,6 +81,8 @@ extern void _mesa_init_dlist_dispatch(struct _glapi_table *disp);
#else /* FEATURE_dlist */
+#include "main/compiler.h"
+
#define _MESA_INIT_DLIST_FUNCTIONS(driver, impl) do { } while (0)
#define _MESA_INIT_DLIST_VTXFMT(vfmt, impl) do { } while (0)
diff --git a/src/mesa/main/es_generator.py b/src/mesa/main/es_generator.py
index 9a8f5a6f5e..ecb34bb5cd 100644
--- a/src/mesa/main/es_generator.py
+++ b/src/mesa/main/es_generator.py
@@ -215,6 +215,10 @@ extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... );
#ifdef IN_DRI_DRIVER
#define _GLAPI_USE_REMAP_TABLE
#endif
+/* glapi uses GLAPIENTRY while GLES headers define GL_APIENTRY */
+#ifndef GLAPIENTRY
+#define GLAPIENTRY GL_APIENTRY
+#endif
#include "%sapi/glapi/glapitable.h"
#include "%sapi/glapi/glapioffsets.h"
#include "%sapi/glapi/glapidispatch.h"
@@ -603,13 +607,15 @@ for funcName in keys:
# are complete; remove the extra ", " at the front of each.
passthroughDeclarationString = passthroughDeclarationString[2:]
passthroughCallString = passthroughCallString[2:]
+ if not passthroughDeclarationString:
+ passthroughDeclarationString = "void"
# The Mesa functions are scattered across all the Mesa
# header files. The easiest way to manage declarations
# is to create them ourselves.
if funcName in allSpecials:
print "/* this function is special and is defined elsewhere */"
- print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
+ print "extern %s GL_APIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
# A function may be a core function (i.e. it exists in
# the core specification), a core addition (extension
@@ -662,7 +668,7 @@ for funcName in keys:
print
continue
- print "static %s %s(%s)" % (returnType, fullFuncName, declarationString)
+ print "static %s GL_APIENTRY %s(%s)" % (returnType, fullFuncName, declarationString)
print "{"
# Start printing our code pieces. Start with any local
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 19a1eebe6e..c9862ca29e 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -969,7 +969,7 @@ _mesa_get_extension_count(GLcontext *ctx)
if (0)
_mesa_debug(ctx, "%u of %d extensions enabled\n", ctx->Extensions.Count,
- Elements(default_extensions));
+ (int) Elements(default_extensions));
return ctx->Extensions.Count;
}
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 9a84e5a79c..f80dd85993 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -93,6 +93,8 @@ delete_dummy_framebuffer(struct gl_framebuffer *fb)
void
_mesa_init_fbobjects(GLcontext *ctx)
{
+ _glthread_INIT_MUTEX(DummyFramebuffer.Mutex);
+ _glthread_INIT_MUTEX(DummyRenderbuffer.Mutex);
DummyFramebuffer.Delete = delete_dummy_framebuffer;
DummyRenderbuffer.Delete = delete_dummy_renderbuffer;
}
diff --git a/src/mesa/main/feedback.h b/src/mesa/main/feedback.h
index 3e8283ed23..0762930044 100644
--- a/src/mesa/main/feedback.h
+++ b/src/mesa/main/feedback.h
@@ -63,6 +63,8 @@ _mesa_init_feedback_dispatch(struct _glapi_table *disp);
#else /* FEATURE_feedback */
+#include "main/compiler.h"
+
#define _MESA_INIT_FEEDBACK_FUNCTIONS(driver, impl) do { } while (0)
static INLINE void
diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
index 90449cc04f..112d7a0088 100644
--- a/src/mesa/main/formats.c
+++ b/src/mesa/main/formats.c
@@ -940,6 +940,18 @@ _mesa_is_format_compressed(gl_format format)
/**
+ * Determine if the given format represents a packed depth/stencil buffer.
+ */
+GLboolean
+_mesa_is_format_packed_depth_stencil(gl_format format)
+{
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+
+ return info->BaseFormat == GL_DEPTH_STENCIL;
+}
+
+
+/**
* Return color encoding for given format.
* \return GL_LINEAR or GL_SRGB
*/
diff --git a/src/mesa/main/formats.h b/src/mesa/main/formats.h
index ad176caaa0..e9467f486b 100644
--- a/src/mesa/main/formats.h
+++ b/src/mesa/main/formats.h
@@ -190,6 +190,9 @@ _mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh);
extern GLboolean
_mesa_is_format_compressed(gl_format format);
+extern GLboolean
+_mesa_is_format_packed_depth_stencil(gl_format format);
+
extern GLenum
_mesa_get_format_color_encoding(gl_format format);
diff --git a/src/mesa/main/framebuffer.c b/src/mesa/main/framebuffer.c
index e0aac26f62..a98c09cfbf 100644
--- a/src/mesa/main/framebuffer.c
+++ b/src/mesa/main/framebuffer.c
@@ -611,7 +611,7 @@ _mesa_update_depth_buffer(GLcontext *ctx,
depthRb = fb->Attachment[attIndex].Renderbuffer;
- if (depthRb && depthRb->_BaseFormat == GL_DEPTH_STENCIL) {
+ if (depthRb && _mesa_is_format_packed_depth_stencil(depthRb->Format)) {
/* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
if (!fb->_DepthBuffer
|| fb->_DepthBuffer->Wrapped != depthRb
@@ -652,7 +652,7 @@ _mesa_update_stencil_buffer(GLcontext *ctx,
stencilRb = fb->Attachment[attIndex].Renderbuffer;
- if (stencilRb && stencilRb->_BaseFormat == GL_DEPTH_STENCIL) {
+ if (stencilRb && _mesa_is_format_packed_depth_stencil(stencilRb->Format)) {
/* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
if (!fb->_StencilBuffer
|| fb->_StencilBuffer->Wrapped != stencilRb
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 632dadd1a5..a3cb5ec168 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -1661,16 +1661,22 @@ check_extra(GLcontext *ctx, const char *func, const struct value_desc *d)
for (e = d->extra; *e != EXTRA_END; e++)
switch (*e) {
case EXTRA_VERSION_30:
- if (version < 30)
- return GL_FALSE;
+ if (version >= 30) {
+ total++;
+ enabled++;
+ }
break;
case EXTRA_VERSION_31:
- if (version < 31)
- return GL_FALSE;
+ if (version >= 31) {
+ total++;
+ enabled++;
+ }
break;
case EXTRA_VERSION_32:
- if (version < 32)
- return GL_FALSE;
+ if (version >= 32) {
+ total++;
+ enabled++;
+ }
break;
case EXTRA_NEW_BUFFERS:
if (ctx->NewState & _NEW_BUFFERS)
diff --git a/src/mesa/main/getstring.c b/src/mesa/main/getstring.c
index 7961ad7e7d..5e4fcd599c 100644
--- a/src/mesa/main/getstring.c
+++ b/src/mesa/main/getstring.c
@@ -31,7 +31,7 @@
#include "extensions.h"
static const GLubyte *
-shading_laguage_version(GLcontext *ctx)
+shading_language_version(GLcontext *ctx)
{
switch (ctx->API) {
#if FEATURE_ARB_shading_language_100
@@ -98,7 +98,7 @@ _mesa_GetString( GLenum name )
return (const GLubyte *) ctx->Extensions.String;
#if FEATURE_ARB_shading_language_100 || FEATURE_ES2
case GL_SHADING_LANGUAGE_VERSION:
- return shading_laguage_version(ctx);
+ return shading_language_version(ctx);
#endif
#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
index 9c2ffd66d6..751f206501 100644
--- a/src/mesa/main/imports.h
+++ b/src/mesa/main/imports.h
@@ -116,6 +116,42 @@ typedef union { GLfloat f; GLint i; } fi_type;
#endif
+/**
+ * \name Work-arounds for platforms that lack C99 math functions
+ */
+/*@{*/
+#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \
+ && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \
+ && (!defined(_MSC_VER) || (_MSC_VER < 1400))
+#define acosf(f) ((float) acos(f))
+#define asinf(f) ((float) asin(f))
+#define atan2f(x,y) ((float) atan2(x,y))
+#define atanf(f) ((float) atan(f))
+#define cielf(f) ((float) ciel(f))
+#define cosf(f) ((float) cos(f))
+#define coshf(f) ((float) cosh(f))
+#define expf(f) ((float) exp(f))
+#define exp2f(f) ((float) exp2(f))
+#define floorf(f) ((float) floor(f))
+#define logf(f) ((float) log(f))
+#define log2f(f) ((float) log2(f))
+#define powf(x,y) ((float) pow(x,y))
+#define sinf(f) ((float) sin(f))
+#define sinhf(f) ((float) sinh(f))
+#define sqrtf(f) ((float) sqrt(f))
+#define tanf(f) ((float) tan(f))
+#define tanhf(f) ((float) tanh(f))
+#endif
+
+#if defined(_MSC_VER)
+static INLINE float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); }
+static INLINE float exp2f(float x) { return powf(2.0f, x); }
+static INLINE float log2f(float x) { return logf(x) * 1.442695041f; }
+static INLINE int isblank(int ch) { return ch == ' ' || ch == '\t'; }
+#define strtoll(p, e, b) _strtoi64(p, e, b)
+#endif
+/*@}*/
+
/***
*** LOG2: Log base 2 of float
***/
@@ -530,19 +566,25 @@ extern unsigned int
_mesa_str_checksum(const char *str);
extern int
-_mesa_snprintf( char *str, size_t size, const char *fmt, ... );
+_mesa_snprintf( char *str, size_t size, const char *fmt, ... ) PRINTFLIKE(3, 4);
extern void
-_mesa_warning( __GLcontext *gc, const char *fmtString, ... );
+_mesa_warning( __GLcontext *gc, const char *fmtString, ... ) PRINTFLIKE(2, 3);
extern void
-_mesa_problem( const __GLcontext *ctx, const char *fmtString, ... );
+_mesa_problem( const __GLcontext *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
extern void
-_mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
+_mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... ) PRINTFLIKE(3, 4);
extern void
-_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
+_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
+
+
+#if defined(_MSC_VER) && !defined(snprintf)
+#define snprintf _snprintf
+#endif
+
#ifdef __cplusplus
}
diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index c0c29f7889..678d17a2a3 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1005,21 +1005,28 @@ make_2d_mipmap(GLenum datatype, GLuint comps, GLint border,
const GLint dstRowBytes = bpt * dstRowStride;
const GLubyte *srcA, *srcB;
GLubyte *dst;
- GLint row;
+ GLint row, srcRowStep;
/* Compute src and dst pointers, skipping any border */
srcA = srcPtr + border * ((srcWidth + 1) * bpt);
- if (srcHeight > 1)
+ if (srcHeight > 1 && srcHeight > dstHeight) {
+ /* sample from two source rows */
srcB = srcA + srcRowBytes;
- else
+ srcRowStep = 2;
+ }
+ else {
+ /* sample from one source row */
srcB = srcA;
+ srcRowStep = 1;
+ }
+
dst = dstPtr + border * ((dstWidth + 1) * bpt);
for (row = 0; row < dstHeightNB; row++) {
do_row(datatype, comps, srcWidthNB, srcA, srcB,
dstWidthNB, dst);
- srcA += 2 * srcRowBytes;
- srcB += 2 * srcRowBytes;
+ srcA += srcRowStep * srcRowBytes;
+ srcB += srcRowStep * srcRowBytes;
dst += dstRowBytes;
}
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 8d92892ad7..d44eff69cc 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1632,10 +1632,9 @@ struct gl_array_attrib
GLbitfield NewState; /**< mask of _NEW_ARRAY_* values */
-#if FEATURE_ARB_vertex_buffer_object
+ /* GL_ARB_vertex_buffer_object */
struct gl_buffer_object *ArrayBufferObj;
struct gl_buffer_object *ElementArrayBufferObj;
-#endif
};
@@ -2084,6 +2083,15 @@ struct gl_shader
struct gl_program *Program; /**< Post-compile assembly code */
GLchar *InfoLog;
struct gl_sl_pragmas Pragmas;
+
+ unsigned Version; /**< GLSL version used for linking */
+
+ struct exec_list *ir;
+ struct glsl_symbol_table *symbols;
+
+ /** Shaders containing built-in functions that are used for linking. */
+ struct gl_shader *builtins_to_link[16];
+ unsigned num_builtins_to_link;
};
@@ -2129,6 +2137,16 @@ struct gl_shader_program
GLboolean Validated;
GLboolean _Used; /**< Ever used for drawing? */
GLchar *InfoLog;
+
+ unsigned Version; /**< GLSL version used for linking */
+
+ /**
+ * Per-stage shaders resulting from the first stage of linking.
+ */
+ /*@{*/
+ GLuint _NumLinkedShaders;
+ struct gl_shader *_LinkedShaders[2];
+ /*@}*/
};
@@ -2154,6 +2172,11 @@ struct gl_shader_state
GLboolean EmitCondCodes; /**< Use condition codes? */
GLboolean EmitComments; /**< Annotated instructions */
GLboolean EmitNVTempInitialization; /**< 0-fill NV temp registers */
+ /**
+ * Attempts to flatten all ir_if (OPCODE_IF) for GPUs that can't
+ * support control flow.
+ */
+ GLboolean EmitNoIfs;
void *MemPool;
GLbitfield Flags; /**< Mask of GLSL_x flags */
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
@@ -2240,39 +2263,26 @@ struct gl_shared_state
*/
/*@{*/
struct _mesa_HashTable *Programs; /**< All vertex/fragment programs */
-#if FEATURE_ARB_vertex_program
struct gl_vertex_program *DefaultVertexProgram;
-#endif
-#if FEATURE_ARB_fragment_program
struct gl_fragment_program *DefaultFragmentProgram;
-#endif
-#if FEATURE_ARB_geometry_shader4
struct gl_geometry_program *DefaultGeometryProgram;
-#endif
/*@}*/
-#if FEATURE_ATI_fragment_shader
+ /* GL_ATI_fragment_shader */
struct _mesa_HashTable *ATIShaders;
struct ati_fragment_shader *DefaultFragmentShader;
-#endif
-#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
struct _mesa_HashTable *BufferObjects;
-#endif
-#if FEATURE_ARB_shader_objects
/** Table of both gl_shader and gl_shader_program objects */
struct _mesa_HashTable *ShaderObjects;
-#endif
-#if FEATURE_EXT_framebuffer_object
+ /* GL_EXT_framebuffer_object */
struct _mesa_HashTable *RenderBuffers;
struct _mesa_HashTable *FrameBuffers;
-#endif
-#if FEATURE_ARB_sync
+ /* GL_ARB_sync */
struct simple_node SyncObjects;
-#endif
void *DriverData; /**< Device driver shared state */
};
@@ -2507,14 +2517,13 @@ struct gl_program_constants
GLuint MaxNativeParameters;
/* For shaders */
GLuint MaxUniformComponents;
-#if FEATURE_ARB_geometry_shader4
+ /* GL_ARB_geometry_shader4 */
GLuint MaxGeometryTextureImageUnits;
GLuint MaxGeometryVaryingComponents;
GLuint MaxVertexVaryingComponents;
GLuint MaxGeometryUniformComponents;
GLuint MaxGeometryOutputVertices;
GLuint MaxGeometryTotalOutputComponents;
-#endif
};
@@ -2762,12 +2771,8 @@ struct gl_extensions
GLboolean SGIS_texture_lod;
GLboolean TDFX_texture_compression_FXT1;
GLboolean S3_s3tc;
-#if FEATURE_OES_EGL_image
GLboolean OES_EGL_image;
-#endif
-#if FEATURE_OES_draw_texture
GLboolean OES_draw_texture;
-#endif /* FEATURE_OES_draw_texture */
/** The extension string */
const GLubyte *String;
/** Number of supported extensions */
@@ -3208,9 +3213,8 @@ struct __GLcontextRec
struct gl_meta_state *Meta; /**< for "meta" operations */
-#if FEATURE_EXT_framebuffer_object
+ /* GL_EXT_framebuffer_object */
struct gl_renderbuffer *CurrentRenderbuffer;
-#endif
GLenum ErrorValue; /**< Last error code */
diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c
index 32aaa79f7f..36236eb9a7 100644
--- a/src/mesa/main/querymatrix.c
+++ b/src/mesa/main/querymatrix.c
@@ -72,7 +72,8 @@ fpclassify(double x)
#elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
- (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__)
+ (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \
+ (defined(__sun) && defined(__GNUC__))
/* fpclassify is available. */
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 9cb2391035..cc350c93b9 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -46,8 +46,7 @@
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_uniform.h"
-#include "slang/slang_compile.h"
-#include "slang/slang_link.h"
+#include "talloc.h"
/** Define this to enable shader substitution (see below) */
@@ -99,6 +98,7 @@ _mesa_init_shader_state(GLcontext *ctx)
ctx->Shader.EmitContReturn = GL_TRUE;
ctx->Shader.EmitCondCodes = GL_FALSE;
ctx->Shader.EmitComments = GL_FALSE;
+ ctx->Shader.EmitNoIfs = GL_FALSE;
ctx->Shader.Flags = get_shader_flags();
/* Default pragma settings */
@@ -800,7 +800,7 @@ compile_shader(GLcontext *ctx, GLuint shaderObj)
/* this call will set the sh->CompileStatus field to indicate if
* compilation was successful.
*/
- (void) _slang_compile(ctx, sh);
+ _mesa_glsl_compile_shader(ctx, sh);
}
@@ -826,7 +826,7 @@ link_program(GLcontext *ctx, GLuint program)
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
- _slang_link(ctx, program, shProg);
+ _mesa_glsl_link_shader(ctx, shProg);
/* debug code */
if (0) {
@@ -1051,9 +1051,9 @@ validate_program(GLcontext *ctx, GLuint program)
if (!shProg->Validated) {
/* update info log */
if (shProg->InfoLog) {
- free(shProg->InfoLog);
+ talloc_free(shProg->InfoLog);
}
- shProg->InfoLog = _mesa_strdup(errMsg);
+ shProg->InfoLog = talloc_strdup(shProg, errMsg);
}
}
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 14bbb2e4bc..59198d788b 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -36,7 +36,7 @@
#include "program/program.h"
#include "program/prog_parameter.h"
#include "program/prog_uniform.h"
-
+#include "talloc.h"
/**********************************************************************/
/*** Shader object functions ***/
@@ -87,22 +87,27 @@ _mesa_reference_shader(GLcontext *ctx, struct gl_shader **ptr,
}
}
+void
+_mesa_init_shader(GLcontext *ctx, struct gl_shader *shader)
+{
+ shader->RefCount = 1;
+}
/**
* Allocate a new gl_shader object, initialize it.
* Called via ctx->Driver.NewShader()
*/
-static struct gl_shader *
+struct gl_shader *
_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type)
{
struct gl_shader *shader;
assert(type == GL_FRAGMENT_SHADER || type == GL_VERTEX_SHADER ||
type == GL_GEOMETRY_SHADER_ARB);
- shader = CALLOC_STRUCT(gl_shader);
+ shader = talloc_zero(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
shader->Name = name;
- shader->RefCount = 1;
+ _mesa_init_shader(ctx, shader);
}
return shader;
}
@@ -113,14 +118,12 @@ _mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type)
* Called via ctx->Driver.DeleteShader().
*/
static void
-__mesa_delete_shader(GLcontext *ctx, struct gl_shader *sh)
+_mesa_delete_shader(GLcontext *ctx, struct gl_shader *sh)
{
if (sh->Source)
free((void *) sh->Source);
- if (sh->InfoLog)
- free(sh->InfoLog);
_mesa_reference_program(ctx, &sh->Program, NULL);
- free(sh);
+ talloc_free(sh);
}
@@ -226,6 +229,18 @@ _mesa_reference_shader_program(GLcontext *ctx,
}
}
+void
+_mesa_init_shader_program(GLcontext *ctx, struct gl_shader_program *prog)
+{
+ prog->Type = GL_SHADER_PROGRAM_MESA;
+ prog->RefCount = 1;
+ prog->Attributes = _mesa_new_parameter_list();
+#if FEATURE_ARB_geometry_shader4
+ prog->Geom.VerticesOut = 0;
+ prog->Geom.InputType = GL_TRIANGLES;
+ prog->Geom.OutputType = GL_TRIANGLE_STRIP;
+#endif
+}
/**
* Allocate a new gl_shader_program object, initialize it.
@@ -235,17 +250,10 @@ static struct gl_shader_program *
_mesa_new_shader_program(GLcontext *ctx, GLuint name)
{
struct gl_shader_program *shProg;
- shProg = CALLOC_STRUCT(gl_shader_program);
+ shProg = talloc_zero(NULL, struct gl_shader_program);
if (shProg) {
- shProg->Type = GL_SHADER_PROGRAM_MESA;
shProg->Name = name;
- shProg->RefCount = 1;
- shProg->Attributes = _mesa_new_parameter_list();
-#if FEATURE_ARB_geometry_shader4
- shProg->Geom.VerticesOut = 0;
- shProg->Geom.InputType = GL_TRIANGLES;
- shProg->Geom.OutputType = GL_TRIANGLE_STRIP;
-#endif
+ _mesa_init_shader_program(ctx, shProg);
}
return shProg;
}
@@ -305,7 +313,7 @@ _mesa_free_shader_program_data(GLcontext *ctx,
}
if (shProg->InfoLog) {
- free(shProg->InfoLog);
+ talloc_free(shProg->InfoLog);
shProg->InfoLog = NULL;
}
@@ -316,6 +324,12 @@ _mesa_free_shader_program_data(GLcontext *ctx,
free(shProg->TransformFeedback.VaryingNames);
shProg->TransformFeedback.VaryingNames = NULL;
shProg->TransformFeedback.NumVarying = 0;
+
+
+ for (i = 0; i < shProg->_NumLinkedShaders; i++) {
+ ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[i]);
+ }
+ shProg->_NumLinkedShaders = 0;
}
@@ -324,11 +338,11 @@ _mesa_free_shader_program_data(GLcontext *ctx,
* Called via ctx->Driver.DeleteShaderProgram().
*/
static void
-__mesa_delete_shader_program(GLcontext *ctx, struct gl_shader_program *shProg)
+_mesa_delete_shader_program(GLcontext *ctx, struct gl_shader_program *shProg)
{
_mesa_free_shader_program_data(ctx, shProg);
- free(shProg);
+ talloc_free(shProg);
}
@@ -386,7 +400,9 @@ void
_mesa_init_shader_object_functions(struct dd_function_table *driver)
{
driver->NewShader = _mesa_new_shader;
- driver->DeleteShader = __mesa_delete_shader;
+ driver->DeleteShader = _mesa_delete_shader;
driver->NewShaderProgram = _mesa_new_shader_program;
- driver->DeleteShaderProgram = __mesa_delete_shader_program;
+ driver->DeleteShaderProgram = _mesa_delete_shader_program;
+ driver->CompileShader = _mesa_ir_compile_shader;
+ driver->LinkShader = _mesa_ir_link_shader;
}
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index d6b37b4596..4800046375 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -27,8 +27,22 @@
#define SHADEROBJ_H
-#include "glheader.h"
-#include "mtypes.h"
+#include "main/glheader.h"
+#include "main/mtypes.h"
+#include "program/ir_to_mesa.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+/**
+ * Internal functions
+ */
+
+extern void
+_mesa_init_shader_state(GLcontext * ctx);
+
+extern void
+_mesa_free_shader_state(GLcontext *ctx);
extern void
@@ -47,6 +61,14 @@ extern void
_mesa_reference_shader_program(GLcontext *ctx,
struct gl_shader_program **ptr,
struct gl_shader_program *shProg);
+extern void
+_mesa_init_shader(GLcontext *ctx, struct gl_shader *shader);
+
+extern struct gl_shader *
+_mesa_new_shader(GLcontext *ctx, GLuint name, GLenum type);
+
+extern void
+_mesa_init_shader_program(GLcontext *ctx, struct gl_shader_program *prog);
extern struct gl_shader_program *
_mesa_lookup_shader_program(GLcontext *ctx, GLuint name);
@@ -74,5 +96,8 @@ _mesa_init_shader_state(GLcontext *ctx);
extern void
_mesa_free_shader_state(GLcontext *ctx);
+#ifdef __cplusplus
+}
+#endif
#endif /* SHADEROBJ_H */
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c
index cbe004518a..ea7e503cf3 100644
--- a/src/mesa/main/shared.c
+++ b/src/mesa/main/shared.c
@@ -288,6 +288,10 @@ free_shared_state(GLcontext *ctx, struct gl_shared_state *shared)
{
GLuint i;
+ /* Free the dummy/fallback texture object */
+ if (shared->FallbackTex)
+ ctx->Driver.DeleteTexture(ctx, shared->FallbackTex);
+
/*
* Free display lists
*/
diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c
index c70792cab6..8e05980262 100644
--- a/src/mesa/main/texcompress_s3tc.c
+++ b/src/mesa/main/texcompress_s3tc.c
@@ -149,7 +149,6 @@ _mesa_init_texture_s3tc( GLcontext *ctx )
}
if (dxtlibhandle) {
ctx->Mesa_DXTn = GL_TRUE;
- _mesa_warning(ctx, "software DXTn compression/decompression available");
}
#else
(void) ctx;
diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c
index f86f1911d1..5c8c1fd225 100644
--- a/src/mesa/main/transformfeedback.c
+++ b/src/mesa/main/transformfeedback.c
@@ -455,14 +455,14 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
if ((size <= 0) || (size & 0x3)) {
/* must be positive and multiple of four */
- _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", size);
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindBufferRange(size%d)", (int) size);
return;
}
if (offset & 0x3) {
/* must be multiple of four */
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBufferRange(offset=%d)", offset);
+ "glBindBufferRange(offset=%d)", (int) offset);
return;
}
@@ -475,7 +475,8 @@ _mesa_BindBufferRange(GLenum target, GLuint index,
if (offset + size >= bufObj->Size) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindBufferRange(offset + size > buffer size)", size);
+ "glBindBufferRange(offset + size %d > buffer size %d)",
+ (int) (offset + size), (int) (bufObj->Size));
return;
}
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index d68a7768df..a5d7da51f0 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -454,17 +454,12 @@ _mesa_get_uniformiv(GLcontext *ctx, GLuint program, GLint location,
* The return value will encode two values, the uniform location and an
* offset (used for arrays, structs).
*/
-static GLint
-_mesa_get_uniform_location(GLcontext *ctx, GLuint program, const GLchar *name)
+GLint
+_mesa_get_uniform_location(GLcontext *ctx, struct gl_shader_program *shProg,
+ const GLchar *name)
{
GLint offset = 0, location = -1;
- struct gl_shader_program *shProg =
- _mesa_lookup_shader_program_err(ctx, program, "glGetUniformLocation");
-
- if (!shProg)
- return -1;
-
if (shProg->LinkStatus == GL_FALSE) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformfv(program)");
return -1;
@@ -751,11 +746,11 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
/**
* Called via glUniform*() functions.
*/
-static void
-_mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
+void
+_mesa_uniform(GLcontext *ctx, struct gl_shader_program *shProg,
+ GLint location, GLsizei count,
const GLvoid *values, GLenum type)
{
- struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
struct gl_uniform *uniform;
GLint elems, offset;
@@ -923,12 +918,12 @@ set_program_uniform_matrix(GLcontext *ctx, struct gl_program *program,
* Called by glUniformMatrix*() functions.
* Note: cols=2, rows=4 ==> array[2] of vec4
*/
-static void
-_mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
+void
+_mesa_uniform_matrix(GLcontext *ctx, struct gl_shader_program *shProg,
+ GLint cols, GLint rows,
GLint location, GLsizei count,
GLboolean transpose, const GLfloat *values)
{
- struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
struct gl_uniform *uniform;
GLint offset;
@@ -999,7 +994,7 @@ void GLAPIENTRY
_mesa_Uniform1fARB(GLint location, GLfloat v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, 1, &v0, GL_FLOAT);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_FLOAT);
}
void GLAPIENTRY
@@ -1009,7 +1004,7 @@ _mesa_Uniform2fARB(GLint location, GLfloat v0, GLfloat v1)
GLfloat v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, location, 1, v, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC2);
}
void GLAPIENTRY
@@ -1020,7 +1015,7 @@ _mesa_Uniform3fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, location, 1, v, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC3);
}
void GLAPIENTRY
@@ -1033,14 +1028,14 @@ _mesa_Uniform4fARB(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, location, 1, v, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_FLOAT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1iARB(GLint location, GLint v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, 1, &v0, GL_INT);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_INT);
}
void GLAPIENTRY
@@ -1050,7 +1045,7 @@ _mesa_Uniform2iARB(GLint location, GLint v0, GLint v1)
GLint v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, location, 1, v, GL_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC2);
}
void GLAPIENTRY
@@ -1061,7 +1056,7 @@ _mesa_Uniform3iARB(GLint location, GLint v0, GLint v1, GLint v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, location, 1, v, GL_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC3);
}
void GLAPIENTRY
@@ -1073,63 +1068,63 @@ _mesa_Uniform4iARB(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, location, 1, v, GL_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_INT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_FLOAT);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT);
}
void GLAPIENTRY
_mesa_Uniform2fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_FLOAT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC2);
}
void GLAPIENTRY
_mesa_Uniform3fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_FLOAT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC3);
}
void GLAPIENTRY
_mesa_Uniform4fvARB(GLint location, GLsizei count, const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_FLOAT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_FLOAT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_INT);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT);
}
void GLAPIENTRY
_mesa_Uniform2ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC2);
}
void GLAPIENTRY
_mesa_Uniform3ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC3);
}
void GLAPIENTRY
_mesa_Uniform4ivARB(GLint location, GLsizei count, const GLint * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_INT_VEC4);
}
@@ -1138,7 +1133,7 @@ void GLAPIENTRY
_mesa_Uniform1ui(GLint location, GLuint v0)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, 1, &v0, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, &v0, GL_UNSIGNED_INT);
}
void GLAPIENTRY
@@ -1148,7 +1143,7 @@ _mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1)
GLuint v[2];
v[0] = v0;
v[1] = v1;
- _mesa_uniform(ctx, location, 1, v, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC2);
}
void GLAPIENTRY
@@ -1159,7 +1154,7 @@ _mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
v[0] = v0;
v[1] = v1;
v[2] = v2;
- _mesa_uniform(ctx, location, 1, v, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC3);
}
void GLAPIENTRY
@@ -1171,35 +1166,35 @@ _mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
v[1] = v1;
v[2] = v2;
v[3] = v3;
- _mesa_uniform(ctx, location, 1, v, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, 1, v, GL_UNSIGNED_INT_VEC4);
}
void GLAPIENTRY
_mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_UNSIGNED_INT);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT);
}
void GLAPIENTRY
_mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_UNSIGNED_INT_VEC2);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC2);
}
void GLAPIENTRY
_mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_UNSIGNED_INT_VEC3);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC3);
}
void GLAPIENTRY
_mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform(ctx, location, count, value, GL_UNSIGNED_INT_VEC4);
+ _mesa_uniform(ctx, ctx->Shader.CurrentProgram, location, count, value, GL_UNSIGNED_INT_VEC4);
}
@@ -1209,7 +1204,8 @@ _mesa_UniformMatrix2fvARB(GLint location, GLsizei count, GLboolean transpose,
const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 2, 2, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 2, 2, location, count, transpose, value);
}
void GLAPIENTRY
@@ -1217,7 +1213,8 @@ _mesa_UniformMatrix3fvARB(GLint location, GLsizei count, GLboolean transpose,
const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 3, 3, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 3, 3, location, count, transpose, value);
}
void GLAPIENTRY
@@ -1225,7 +1222,8 @@ _mesa_UniformMatrix4fvARB(GLint location, GLsizei count, GLboolean transpose,
const GLfloat * value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 4, 4, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 4, 4, location, count, transpose, value);
}
@@ -1237,7 +1235,8 @@ _mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 2, 3, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 2, 3, location, count, transpose, value);
}
void GLAPIENTRY
@@ -1245,7 +1244,8 @@ _mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 3, 2, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 3, 2, location, count, transpose, value);
}
void GLAPIENTRY
@@ -1253,7 +1253,8 @@ _mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 2, 4, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 2, 4, location, count, transpose, value);
}
void GLAPIENTRY
@@ -1261,7 +1262,8 @@ _mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 4, 2, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 4, 2, location, count, transpose, value);
}
void GLAPIENTRY
@@ -1269,7 +1271,8 @@ _mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 3, 4, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 3, 4, location, count, transpose, value);
}
void GLAPIENTRY
@@ -1277,7 +1280,8 @@ _mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
const GLfloat *value)
{
GET_CURRENT_CONTEXT(ctx);
- _mesa_uniform_matrix(ctx, 4, 3, location, count, transpose, value);
+ _mesa_uniform_matrix(ctx, ctx->Shader.CurrentProgram,
+ 4, 3, location, count, transpose, value);
}
@@ -1300,8 +1304,16 @@ _mesa_GetUniformivARB(GLhandleARB program, GLint location, GLint *params)
GLint GLAPIENTRY
_mesa_GetUniformLocationARB(GLhandleARB programObj, const GLcharARB *name)
{
+ struct gl_shader_program *shProg;
+
GET_CURRENT_CONTEXT(ctx);
- return _mesa_get_uniform_location(ctx, programObj, name);
+
+ shProg = _mesa_lookup_shader_program_err(ctx, programObj,
+ "glGetUniformLocation");
+ if (!shProg)
+ return -1;
+
+ return _mesa_get_uniform_location(ctx, shProg, name);
}
diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h
index ef98fe16bb..f823c61444 100644
--- a/src/mesa/main/uniforms.h
+++ b/src/mesa/main/uniforms.h
@@ -150,7 +150,20 @@ _mesa_GetUniformivARB(GLhandleARB, GLint, GLint *);
extern GLint GLAPIENTRY
_mesa_GetUniformLocationARB(GLhandleARB, const GLcharARB *);
-
+GLint
+_mesa_get_uniform_location(GLcontext *ctx, struct gl_shader_program *shProg,
+ const GLchar *name);
+
+void
+_mesa_uniform(GLcontext *ctx, struct gl_shader_program *shader_program,
+ GLint location, GLsizei count,
+ const GLvoid *values, GLenum type);
+
+void
+_mesa_uniform_matrix(GLcontext *ctx, struct gl_shader_program *shProg,
+ GLint cols, GLint rows,
+ GLint location, GLsizei count,
+ GLboolean transpose, const GLfloat *values);
extern void
_mesa_update_shader_textures_used(struct gl_program *prog);