From 06f4de23ace4de1fd628c37891214f0a4ecb77db Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 16 Jul 2013 08:53:23 +0200 Subject: libxcb xcb-proto mesa xkbcomp git update 16 Jul 2013 libxcb commit 45619dc71e9411a526d7c69595cf615b1b1206cf libxcb/xcb-proto commit 56a82005ac388fcb7a4d1c82e07c7e72eaf69a32 xkbcomp commit 1cd5c50c54b06de2238d6d7675d0a3c65a21414d mesa commit e4fdf1b008ce29c5b5a52985c586b61f35d31e4c --- mesalib/configure.ac | 53 +- mesalib/include/GL/glext.h | 30 +- mesalib/src/gallium/auxiliary/Makefile.sources | 2 + mesalib/src/gallium/auxiliary/hud/hud_context.c | 16 +- mesalib/src/gallium/auxiliary/util/u_blit.c | 28 +- .../src/gallium/auxiliary/util/u_format_tests.c | 5 + mesalib/src/gallium/auxiliary/util/u_pstipple.c | 10 +- mesalib/src/glsl/ast.h | 3 +- mesalib/src/glsl/ast_function.cpp | 5 + mesalib/src/glsl/ast_to_hir.cpp | 2 +- mesalib/src/glsl/builtin_variables.cpp | 1119 +++++++------------- mesalib/src/glsl/glsl_symbol_table.cpp | 21 +- mesalib/src/glsl/lower_named_interface_blocks.cpp | 2 + mesalib/src/mapi/glapi/gen/ARB_debug_output.xml | 2 +- .../src/mapi/glapi/gen/EXT_transform_feedback.xml | 2 +- mesalib/src/mesa/main/enable.c | 21 +- mesalib/src/mesa/main/errors.c | 2 +- mesalib/src/mesa/main/errors.h | 2 +- mesalib/src/mesa/main/getstring.c | 2 +- mesalib/src/mesa/main/hash_table.c | 4 +- mesalib/src/mesa/main/mipmap.c | 4 +- mesalib/src/mesa/main/mtypes.h | 32 +- mesalib/src/mesa/main/multisample.c | 5 +- mesalib/src/mesa/main/set.c | 4 +- mesalib/src/mesa/main/texparam.c | 2 +- mesalib/src/mesa/main/texstore.c | 2 +- mesalib/src/mesa/main/uniforms.c | 2 +- mesalib/src/mesa/program/prog_parameter.c | 16 +- mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 +- mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c | 11 +- 30 files changed, 544 insertions(+), 872 deletions(-) (limited to 'mesalib') diff --git a/mesalib/configure.ac b/mesalib/configure.ac index 2265e854a..0026613cc 100644 --- a/mesalib/configure.ac +++ b/mesalib/configure.ac @@ -1584,8 +1584,26 @@ if test "x$enable_gallium_llvm" = xyes; then fi if test "x$LLVM_CONFIG" != xno; then - LLVM_VERSION=`$LLVM_CONFIG --version | sed 's/svn.*//g'` - LLVM_VERSION_INT=`echo $LLVM_VERSION | sed -e 's/\([[0-9]]\)\.\([[0-9]]\)/\10\2/g'` + LLVM_VERSION=`$LLVM_CONFIG --version | sed 's/svn.*//g'` + LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` + LLVM_BINDIR=`$LLVM_CONFIG --bindir` + LLVM_CPPFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cppflags"` + LLVM_CFLAGS=$LLVM_CPPFLAGS # CPPFLAGS seem to be sufficient + LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"` + LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir` + LLVM_LIBDIR=`$LLVM_CONFIG --libdir` + + AC_COMPUTE_INT([LLVM_VERSION_MAJOR], [LLVM_VERSION_MAJOR], + [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"]) + AC_COMPUTE_INT([LLVM_VERSION_MINOR], [LLVM_VERSION_MINOR], + [#include "${LLVM_INCLUDEDIR}/llvm/Config/llvm-config.h"]) + + if test "x${LLVM_VERSION_MAJOR}" != x; then + LLVM_VERSION_INT="${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" + else + LLVM_VERSION_INT=`echo $LLVM_VERSION | sed -e 's/\([[0-9]]\)\.\([[0-9]]\)/\10\2/g'` + fi + LLVM_COMPONENTS="engine bitwriter" if $LLVM_CONFIG --components | grep -q '\'; then LLVM_COMPONENTS="${LLVM_COMPONENTS} mcjit" @@ -1598,28 +1616,21 @@ if test "x$enable_gallium_llvm" = xyes; then LLVM_COMPONENTS="${LLVM_COMPONENTS} irreader" fi fi - LLVM_LDFLAGS=`$LLVM_CONFIG --ldflags` - LLVM_BINDIR=`$LLVM_CONFIG --bindir` - LLVM_CPPFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cppflags"` - LLVM_CFLAGS=$LLVM_CPPFLAGS # CPPFLAGS seem to be sufficient - LLVM_CXXFLAGS=`strip_unwanted_llvm_flags "$LLVM_CONFIG --cxxflags"` - LLVM_INCLUDEDIR=`$LLVM_CONFIG --includedir` - LLVM_LIBDIR=`$LLVM_CONFIG --libdir` - DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT" - MESA_LLVM=1 - - dnl Check for Clang interanl headers + DEFINES="${DEFINES} -DHAVE_LLVM=0x0$LLVM_VERSION_INT" + MESA_LLVM=1 + + dnl Check for Clang internal headers if test "x$enable_opencl" = xyes; then if test "x$CLANG_LIBDIR" = x; then CLANG_LIBDIR=${LLVM_LIBDIR} fi CLANG_RESOURCE_DIR=$CLANG_LIBDIR/clang/${LLVM_VERSION} - AC_CHECK_FILE("$CLANG_RESOURCE_DIR/include/stddef.h",, - AC_MSG_ERROR([Could not find clang internal header stddef.h in $CLANG_RESOURCE_DIR Use --with-clang-libdir to specify the correct path to the clang libraries.])) + AS_IF([test ! -f "$CLANG_RESOURCE_DIR/include/stddef.h"], + [AC_MSG_ERROR([Could not find clang internal header stddef.h in $CLANG_RESOURCE_DIR Use --with-clang-libdir to specify the correct path to the clang libraries.])]) fi else - MESA_LLVM=0 - LLVM_VERSION_INT=0 + MESA_LLVM=0 + LLVM_VERSION_INT=0 fi else MESA_LLVM=0 @@ -1853,7 +1864,7 @@ if test "x$MESA_LLVM" != x0; then if test "x$with_llvm_shared_libs" = xyes; then dnl We can't use $LLVM_VERSION because it has 'svn' stripped out, LLVM_SO_NAME=LLVM-`$LLVM_CONFIG --version` - AC_CHECK_FILE("$LLVM_LIBDIR/lib$LLVM_SO_NAME.so", llvm_have_one_so=yes,) + AS_IF([test -f "$LLVM_LIBDIR/lib$LLVM_SO_NAME.so"], [llvm_have_one_so=yes]) if test "x$llvm_have_one_so" = xyes; then dnl LLVM was built using auto*, so there is only one shared object. @@ -1861,8 +1872,8 @@ if test "x$MESA_LLVM" != x0; then else dnl If LLVM was built with CMake, there will be one shared object per dnl component. - AC_CHECK_FILE("$LLVM_LIBDIR/libLLVMTarget.so",, - AC_MSG_ERROR([Could not find llvm shared libraries: + AS_IF([test ! -f "$LLVM_LIBDIR/libLLVMTarget.so"], + [AC_MSG_ERROR([Could not find llvm shared libraries: Please make sure you have built llvm with the --enable-shared option and that your llvm libraries are installed in $LLVM_LIBDIR If you have installed your llvm libraries to a different directory you @@ -1873,7 +1884,7 @@ if test "x$MESA_LLVM" != x0; then --enable-opencl If you do not want to build with llvm shared libraries and instead want to use llvm static libraries then remove these options from your configure - invocation and reconfigure.])) + invocation and reconfigure.])]) dnl We don't need to update LLVM_LIBS in this case because the LLVM dnl install uses a shared object for each compoenent and we have diff --git a/mesalib/include/GL/glext.h b/mesalib/include/GL/glext.h index c14219e8c..0c2c94680 100644 --- a/mesalib/include/GL/glext.h +++ b/mesalib/include/GL/glext.h @@ -37,7 +37,9 @@ extern "C" { */ #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN 1 +#endif #include #endif @@ -51,7 +53,7 @@ extern "C" { #define GLAPI extern #endif -#define GL_GLEXT_VERSION 20130624 +#define GL_GLEXT_VERSION 20130708 /* Generated C header for: * API: gl @@ -2598,7 +2600,7 @@ GLAPI void APIENTRY glClampColorARB (GLenum target, GLenum clamp); #ifndef GL_ARB_debug_output #define GL_ARB_debug_output 1 -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,void *userParam); +typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); #define GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB 0x8242 #define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_ARB 0x8243 #define GL_DEBUG_CALLBACK_FUNCTION_ARB 0x8244 @@ -2623,12 +2625,12 @@ typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLe #define GL_DEBUG_SEVERITY_LOW_ARB 0x9148 typedef void (APIENTRYP PFNGLDEBUGMESSAGECONTROLARBPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); typedef void (APIENTRYP PFNGLDEBUGMESSAGEINSERTARBPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, void *userParam); +typedef void (APIENTRYP PFNGLDEBUGMESSAGECALLBACKARBPROC) (GLDEBUGPROCARB callback, const void *userParam); typedef GLuint (APIENTRYP PFNGLGETDEBUGMESSAGELOGARBPROC) (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glDebugMessageControlARB (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); GLAPI void APIENTRY glDebugMessageInsertARB (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); -GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, void *userParam); +GLAPI void APIENTRY glDebugMessageCallbackARB (GLDEBUGPROCARB callback, const void *userParam); GLAPI GLuint APIENTRY glGetDebugMessageLogARB (GLuint count, GLsizei bufsize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); #endif #endif /* GL_ARB_debug_output */ @@ -3625,14 +3627,14 @@ GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GL #define GL_NAMED_STRING_TYPE_ARB 0x8DEA typedef void (APIENTRYP PFNGLNAMEDSTRINGARBPROC) (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); typedef void (APIENTRYP PFNGLDELETENAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); -typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERINCLUDEARBPROC) (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); typedef GLboolean (APIENTRYP PFNGLISNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name); typedef void (APIENTRYP PFNGLGETNAMEDSTRINGARBPROC) (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); typedef void (APIENTRYP PFNGLGETNAMEDSTRINGIVARBPROC) (GLint namelen, const GLchar *name, GLenum pname, GLint *params); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glNamedStringARB (GLenum type, GLint namelen, const GLchar *name, GLint stringlen, const GLchar *string); GLAPI void APIENTRY glDeleteNamedStringARB (GLint namelen, const GLchar *name); -GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar **path, const GLint *length); +GLAPI void APIENTRY glCompileShaderIncludeARB (GLuint shader, GLsizei count, const GLchar *const*path, const GLint *length); GLAPI GLboolean APIENTRY glIsNamedStringARB (GLint namelen, const GLchar *name); GLAPI void APIENTRY glGetNamedStringARB (GLint namelen, const GLchar *name, GLsizei bufSize, GLint *stringlen, GLchar *string); GLAPI void APIENTRY glGetNamedStringivARB (GLint namelen, const GLchar *name, GLenum pname, GLint *params); @@ -7318,14 +7320,12 @@ GLAPI void APIENTRY glTextureNormalEXT (GLenum mode); #ifndef GL_EXT_timer_query #define GL_EXT_timer_query 1 -typedef int64_t GLint64EXT; -typedef uint64_t GLuint64EXT; #define GL_TIME_ELAPSED_EXT 0x88BF -typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); -typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); #ifdef GL_GLEXT_PROTOTYPES -GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64EXT *params); -GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64EXT *params); +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); #endif #endif /* GL_EXT_timer_query */ @@ -7351,7 +7351,7 @@ typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void); typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer); -typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar **varyings, GLenum bufferMode); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); #ifdef GL_GLEXT_PROTOTYPES GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum primitiveMode); @@ -7359,7 +7359,7 @@ GLAPI void APIENTRY glEndTransformFeedbackEXT (void); GLAPI void APIENTRY glBindBufferRangeEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum target, GLuint index, GLuint buffer, GLintptr offset); GLAPI void APIENTRY glBindBufferBaseEXT (GLenum target, GLuint index, GLuint buffer); -GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar **varyings, GLenum bufferMode); +GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); #endif #endif /* GL_EXT_transform_feedback */ @@ -8359,6 +8359,8 @@ GLAPI void APIENTRY glGetProgramSubroutineParameteruivNV (GLenum target, GLuint #ifndef GL_NV_gpu_shader5 #define GL_NV_gpu_shader5 1 +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; #define GL_INT64_NV 0x140E #define GL_UNSIGNED_INT64_NV 0x140F #define GL_INT8_NV 0x8FE0 diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources index 47517626d..acbcef7e2 100644 --- a/mesalib/src/gallium/auxiliary/Makefile.sources +++ b/mesalib/src/gallium/auxiliary/Makefile.sources @@ -44,6 +44,7 @@ C_SOURCES := \ hud/hud_fps.c \ hud/hud_driver_query.c \ os/os_misc.c \ + os/os_process.c \ os/os_time.c \ pipebuffer/pb_buffer_fenced.c \ pipebuffer/pb_buffer_malloc.c \ @@ -172,6 +173,7 @@ GALLIVM_SOURCES := \ gallivm/lp_bld_format_aos.c \ gallivm/lp_bld_format_aos_array.c \ gallivm/lp_bld_format_float.c \ + gallivm/lp_bld_format_srgb.c \ gallivm/lp_bld_format_soa.c \ gallivm/lp_bld_format_yuv.c \ gallivm/lp_bld_gather.c \ diff --git a/mesalib/src/gallium/auxiliary/hud/hud_context.c b/mesalib/src/gallium/auxiliary/hud/hud_context.c index 47566d816..c4a4f1877 100644 --- a/mesalib/src/gallium/auxiliary/hud/hud_context.c +++ b/mesalib/src/gallium/auxiliary/hud/hud_context.c @@ -407,8 +407,8 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) hud->fb_width = tex->width0; hud->fb_height = tex->height0; - hud->constants.two_div_fb_width = 2.0 / hud->fb_width; - hud->constants.two_div_fb_height = 2.0 / hud->fb_height; + hud->constants.two_div_fb_width = 2.0f / hud->fb_width; + hud->constants.two_div_fb_height = 2.0f / hud->fb_height; cso_save_framebuffer(cso); cso_save_sample_mask(cso); @@ -488,7 +488,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) hud->constants.color[0] = 0; hud->constants.color[1] = 0; hud->constants.color[2] = 0; - hud->constants.color[3] = 0.666; + hud->constants.color[3] = 0.666f; hud->constants.translate[0] = 0; hud->constants.translate[1] = 0; hud->constants.scale[0] = 1; @@ -564,7 +564,7 @@ void hud_pane_set_max_value(struct hud_pane *pane, uint64_t value) { pane->max_value = value; - pane->yscale = -(int)pane->inner_height / (double)pane->max_value; + pane->yscale = -(int)pane->inner_height / (float)pane->max_value; } static struct hud_pane * @@ -636,8 +636,8 @@ hud_graph_add_value(struct hud_graph *gr, uint64_t value) gr->vertices[1] = gr->vertices[(gr->index-1)*2+1]; gr->index = 1; } - gr->vertices[(gr->index)*2+0] = gr->index*2; - gr->vertices[(gr->index)*2+1] = value; + gr->vertices[(gr->index)*2+0] = (float) (gr->index * 2); + gr->vertices[(gr->index)*2+1] = (float) value; gr->index++; if (gr->num_vertices < gr->pane->max_num_vertices) { @@ -717,8 +717,8 @@ hud_parse_env_var(struct hud_context *hud, const char *env) */ period_env = getenv("GALLIUM_HUD_PERIOD"); if (period_env) { - float p = atof(period_env); - if (p >= 0.0) { + float p = (float) atof(period_env); + if (p >= 0.0f) { period = (unsigned) (p * 1000 * 1000); } } diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c index 07418be45..8cc080cc9 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blit.c +++ b/mesalib/src/gallium/auxiliary/util/u_blit.c @@ -596,10 +596,10 @@ util_blit_pixels(struct blit_state *ctx, t1 = 1.0f; } else { - s0 = 0; - s1 = srcW; - t0 = 0; - t1 = srcH; + s0 = 0.0f; + s1 = (float) srcW; + t0 = 0.0f; + t1 = (float) srcH; } u_sampler_view_default_template(&sv_templ, tex, tex->format); @@ -630,10 +630,10 @@ util_blit_pixels(struct blit_state *ctx, return; } - s0 = srcX0; - s1 = srcX1; - t0 = srcY0; - t1 = srcY1; + s0 = (float) srcX0; + s1 = (float) srcX1; + t0 = (float) srcY0; + t1 = (float) srcY1; normalized = sampler_view->texture->target != PIPE_TEXTURE_RECT; if(normalized) { @@ -685,8 +685,8 @@ util_blit_pixels(struct blit_state *ctx, ctx->sampler.normalized_coords = normalized; ctx->sampler.min_img_filter = filter; ctx->sampler.mag_img_filter = filter; - ctx->sampler.min_lod = src_level; - ctx->sampler.max_lod = src_level; + ctx->sampler.min_lod = (float) src_level; + ctx->sampler.max_lod = (float) src_level; /* Depth stencil state, fragment shader and sampler setup depending on what * we blit. @@ -839,10 +839,10 @@ util_blit_pixels_tex(struct blit_state *ctx, assert(tex->width0 != 0); assert(tex->height0 != 0); - s0 = srcX0; - s1 = srcX1; - t0 = srcY0; - t1 = srcY1; + s0 = (float) srcX0; + s1 = (float) srcX1; + t0 = (float) srcY0; + t1 = (float) srcY1; if(normalized) { diff --git a/mesalib/src/gallium/auxiliary/util/u_format_tests.c b/mesalib/src/gallium/auxiliary/util/u_format_tests.c index 26e7acb62..64224cd2e 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_tests.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_tests.c @@ -883,8 +883,13 @@ util_format_test_cases[] = /* Minimum positive normal */ {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x0400), UNPACKED_1x1( 6.10352E-5, 0.0, 0.0, 1.0)}, + /* XXX: Now that we disable denormals this test cases fails, except on + * IvyBridge processors which have intrinsics dedicated to half-float + * packing/unpacking. */ +#if 0 /* Max denormal */ {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x03FF), UNPACKED_1x1( 6.09756E-5, 0.0, 0.0, 1.0)}, +#endif /* Minimum positive denormal */ {PIPE_FORMAT_R16_FLOAT, PACKED_1x16(0xffff), PACKED_1x16(0x0001), UNPACKED_1x1( 5.96046E-8, 0.0, 0.0, 1.0)}, diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.c b/mesalib/src/gallium/auxiliary/util/u_pstipple.c index 68804ae98..640305f9e 100644 --- a/mesalib/src/gallium/auxiliary/util/u_pstipple.c +++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.c @@ -75,7 +75,7 @@ util_pstipple_update_stipple_texture(struct pipe_context *pipe, /* * Load alpha texture. * Note: 0 means keep the fragment, 255 means kill it. - * We'll negate the texel value and use KILP which kills if value + * We'll negate the texel value and use KILL_IF which kills if value * is negative. */ for (i = 0; i < 32; i++) { @@ -252,7 +252,7 @@ free_bit(uint bitfield) * declare new registers * MUL texTemp, INPUT[wincoord], 1/32; * TEX texTemp, texTemp, sampler; - * KIL -texTemp; # if -texTemp < 0, KILL fragment + * KILL_IF -texTemp; # if -texTemp < 0, kill fragment * [...original code...] */ static void @@ -340,7 +340,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx, /* - * Insert new MUL/TEX/KILP instructions at start of program + * Insert new MUL/TEX/KILL_IF instructions at start of program * Take gl_FragCoord, divide by 32 (stipple size), sample the * texture and kill fragment if needed. * @@ -379,9 +379,9 @@ pstip_transform_inst(struct tgsi_transform_context *ctx, newInst.Src[1].Register.Index = pctx->freeSampler; ctx->emit_instruction(ctx, &newInst); - /* KIL -texTemp; # if -texTemp < 0, KILL fragment */ + /* KILL_IF -texTemp; # if -texTemp < 0, kill fragment */ newInst = tgsi_default_full_instruction(); - newInst.Instruction.Opcode = TGSI_OPCODE_KIL; + newInst.Instruction.Opcode = TGSI_OPCODE_KILL_IF; newInst.Instruction.NumDstRegs = 0; newInst.Instruction.NumSrcRegs = 1; newInst.Src[0].Register.File = TGSI_FILE_TEMPORARY; diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h index 9b119edbb..c0350e735 100644 --- a/mesalib/src/glsl/ast.h +++ b/mesalib/src/glsl/ast.h @@ -307,7 +307,8 @@ private: class ast_aggregate_initializer : public ast_expression { public: ast_aggregate_initializer() - : ast_expression(ast_aggregate, NULL, NULL, NULL) + : ast_expression(ast_aggregate, NULL, NULL, NULL), + constructor_type(NULL) { /* empty */ } diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp index 39182639f..e34c1ddba 100644 --- a/mesalib/src/glsl/ast_function.cpp +++ b/mesalib/src/glsl/ast_function.cpp @@ -1707,6 +1707,11 @@ ast_aggregate_initializer::hir(exec_list *instructions, void *ctx = state; YYLTYPE loc = this->get_location(); const char *name; + + if (!this->constructor_type) { + _mesa_glsl_error(&loc, state, "type of C-style initializer unknown"); + return ir_rvalue::error_value(ctx); + } const glsl_type *const constructor_type = this->constructor_type->glsl_type(&name, state); diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index 01203134d..28ccf7288 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -2707,7 +2707,7 @@ ast_declarator_list::hir(exec_list *instructions, } if (!error_emitted && var->type->is_array() && - !state->check_version(140, 0, &loc, + !state->check_version(150, 0, &loc, "vertex shader input / attribute " "cannot have array type")) { error_emitted = true; diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp index f4ac20543..1e88b6a73 100644 --- a/mesalib/src/glsl/builtin_variables.cpp +++ b/mesalib/src/glsl/builtin_variables.cpp @@ -30,116 +30,6 @@ #include "program/prog_statevars.h" #include "program/prog_instruction.h" -static void generate_ARB_draw_buffers_variables(exec_list *, - struct _mesa_glsl_parse_state *, - bool, _mesa_glsl_parser_targets); - -static void -generate_ARB_draw_instanced_variables(exec_list *, - struct _mesa_glsl_parse_state *, - bool, _mesa_glsl_parser_targets); - -static void -generate_AMD_vertex_shader_layer_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn, - _mesa_glsl_parser_targets target); - -struct builtin_variable { - enum ir_variable_mode mode; - int slot; - const char *type; - const char *name; -}; - -static const builtin_variable builtin_core_vs_variables[] = { - { ir_var_shader_out, VARYING_SLOT_POS, "vec4", "gl_Position" }, - { ir_var_shader_out, VARYING_SLOT_PSIZ, "float", "gl_PointSize" }, -}; - -static const builtin_variable builtin_core_fs_variables[] = { - { ir_var_shader_in, VARYING_SLOT_POS, "vec4", "gl_FragCoord" }, - { ir_var_shader_in, VARYING_SLOT_FACE, "bool", "gl_FrontFacing" }, - { ir_var_shader_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, -}; - -static const builtin_variable builtin_100ES_fs_variables[] = { - { ir_var_shader_in, VARYING_SLOT_PNTC, "vec2", "gl_PointCoord" }, -}; - -static const builtin_variable builtin_300ES_vs_variables[] = { - { ir_var_system_value, SYSTEM_VALUE_VERTEX_ID, "int", "gl_VertexID" }, -}; - -static const builtin_variable builtin_300ES_fs_variables[] = { - { ir_var_shader_in, VARYING_SLOT_POS, "vec4", "gl_FragCoord" }, - { ir_var_shader_in, VARYING_SLOT_FACE, "bool", "gl_FrontFacing" }, - { ir_var_shader_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, - { ir_var_shader_in, VARYING_SLOT_PNTC, "vec2", "gl_PointCoord" }, -}; - -static const builtin_variable builtin_110_fs_variables[] = { - { ir_var_shader_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, -}; - -static const builtin_variable builtin_110_deprecated_fs_variables[] = { - { ir_var_shader_in, VARYING_SLOT_COL0, "vec4", "gl_Color" }, - { ir_var_shader_in, VARYING_SLOT_COL1, "vec4", "gl_SecondaryColor" }, - { ir_var_shader_in, VARYING_SLOT_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_110_deprecated_vs_variables[] = { - { ir_var_shader_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, - { ir_var_shader_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, - { ir_var_shader_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, - { ir_var_shader_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, - { ir_var_shader_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, - { ir_var_shader_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, - { ir_var_shader_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, - { ir_var_shader_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, - { ir_var_shader_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, - { ir_var_shader_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, - { ir_var_shader_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, - { ir_var_shader_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, - { ir_var_shader_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, - { ir_var_shader_out, VARYING_SLOT_CLIP_VERTEX, "vec4", "gl_ClipVertex" }, - { ir_var_shader_out, VARYING_SLOT_COL0, "vec4", "gl_FrontColor" }, - { ir_var_shader_out, VARYING_SLOT_BFC0, "vec4", "gl_BackColor" }, - { ir_var_shader_out, VARYING_SLOT_COL1, "vec4", "gl_FrontSecondaryColor" }, - { ir_var_shader_out, VARYING_SLOT_BFC1, "vec4", "gl_BackSecondaryColor" }, - { ir_var_shader_out, VARYING_SLOT_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_120_fs_variables[] = { - { ir_var_shader_in, VARYING_SLOT_PNTC, "vec2", "gl_PointCoord" }, -}; - -static const builtin_variable builtin_130_vs_variables[] = { - { ir_var_system_value, SYSTEM_VALUE_VERTEX_ID, "int", "gl_VertexID" }, -}; - -static const builtin_variable builtin_110_deprecated_uniforms[] = { - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, - { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "float", "gl_NormalScale" }, - { ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"}, - - /* Mesa-internal ATI_envmap_bumpmap state. */ - { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix0MESA"}, - { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix1MESA"}, - { ir_var_uniform, -1, "vec4", "gl_FogParamsOptimizedMESA"}, -}; static struct gl_builtin_uniform_element gl_DepthRange_elements[] = { {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, @@ -400,10 +290,93 @@ static const struct gl_builtin_uniform_desc _mesa_builtin_uniform_desc[] = { {NULL, NULL, 0} }; -static ir_variable * -add_variable(exec_list *instructions, glsl_symbol_table *symtab, - const char *name, const glsl_type *type, - enum ir_variable_mode mode, int slot) + +namespace { + +class builtin_variable_generator +{ +public: + builtin_variable_generator(exec_list *instructions, + struct _mesa_glsl_parse_state *state); + void generate_constants(); + void generate_uniforms(); + void generate_vs_special_vars(); + void generate_gs_special_vars(); + void generate_fs_special_vars(); + void generate_varyings(); + +private: + const glsl_type *array(const glsl_type *base, unsigned elements) + { + return glsl_type::get_array_instance(base, elements); + } + + const glsl_type *type(const char *name) + { + return symtab->get_type(name); + } + + ir_variable *add_input(int slot, const glsl_type *type, const char *name) + { + return add_variable(name, type, ir_var_shader_in, slot); + } + + ir_variable *add_output(int slot, const glsl_type *type, const char *name) + { + return add_variable(name, type, ir_var_shader_out, slot); + } + + ir_variable *add_system_value(int slot, const glsl_type *type, + const char *name) + { + return add_variable(name, type, ir_var_system_value, slot); + } + + ir_variable *add_variable(const char *name, const glsl_type *type, + enum ir_variable_mode mode, int slot); + ir_variable *add_uniform(const glsl_type *type, const char *name); + ir_variable *add_const(const char *name, int value); + void add_varying(int slot, const glsl_type *type, const char *name, + const char *name_as_gs_input); + + exec_list * const instructions; + struct _mesa_glsl_parse_state * const state; + glsl_symbol_table * const symtab; + + /** + * True if compatibility-profile-only variables should be included. (In + * desktop GL, these are always included when the GLSL version is 1.30 and + * or below). + */ + const bool compatibility; + + const glsl_type * const bool_t; + const glsl_type * const int_t; + const glsl_type * const float_t; + const glsl_type * const vec2_t; + const glsl_type * const vec3_t; + const glsl_type * const vec4_t; + const glsl_type * const mat3_t; + const glsl_type * const mat4_t; +}; + + +builtin_variable_generator::builtin_variable_generator( + exec_list *instructions, struct _mesa_glsl_parse_state *state) + : instructions(instructions), state(state), symtab(state->symbols), + compatibility(!state->is_version(140, 100)), + bool_t(glsl_type::bool_type), int_t(glsl_type::int_type), + float_t(glsl_type::float_type), vec2_t(glsl_type::vec2_type), + vec3_t(glsl_type::vec3_type), vec4_t(glsl_type::vec4_type), + mat3_t(glsl_type::mat3_type), mat4_t(glsl_type::mat4_type) +{ +} + + +ir_variable * +builtin_variable_generator::add_variable(const char *name, + const glsl_type *type, + enum ir_variable_mode mode, int slot) { ir_variable *var = new(symtab) ir_variable(type, name, mode); @@ -438,12 +411,12 @@ add_variable(exec_list *instructions, glsl_symbol_table *symtab, return var; } -static ir_variable * -add_uniform(exec_list *instructions, glsl_symbol_table *symtab, - const char *name, const glsl_type *type) + +ir_variable * +builtin_variable_generator::add_uniform(const glsl_type *type, + const char *name) { - ir_variable *const uni = - add_variable(instructions, symtab, name, type, ir_var_uniform, -1); + ir_variable *const uni = add_variable(name, type, ir_var_uniform, -1); unsigned i; for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) { @@ -486,31 +459,11 @@ add_uniform(exec_list *instructions, glsl_symbol_table *symtab, return uni; } -static void -add_builtin_variable(exec_list *instructions, glsl_symbol_table *symtab, - const builtin_variable *proto) -{ - /* Create a new variable declaration from the description supplied by - * the caller. - */ - const glsl_type *const type = symtab->get_type(proto->type); - - assert(type != NULL); - if (proto->mode == ir_var_uniform) { - add_uniform(instructions, symtab, proto->name, type); - } else { - add_variable(instructions, symtab, proto->name, type, proto->mode, - proto->slot); - } -} - -static ir_variable * -add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab, - const char *name, int value) +ir_variable * +builtin_variable_generator::add_const(const char *name, int value) { - ir_variable *const var = add_variable(instructions, symtab, - name, glsl_type::int_type, + ir_variable *const var = add_variable(name, glsl_type::int_type, ir_var_auto, -1); var->constant_value = new(var) ir_constant(value); var->constant_initializer = new(var) ir_constant(value); @@ -518,697 +471,355 @@ add_builtin_constant(exec_list *instructions, glsl_symbol_table *symtab, return var; } -/** - * Uniforms that are common to all GLSL ES implementations. - * - * Several constants in GLSL ES have different names than normal desktop GLSL. - * Therefore, this function should only be called on the ES path. - */ -static void -generate_common_ES_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - glsl_symbol_table *const symtab = state->symbols; - - add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs", - state->Const.MaxVertexAttribs); - add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformVectors", - state->Const.MaxVertexUniformComponents); - add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits", - state->Const.MaxVertexTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits", - state->Const.MaxCombinedTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", - state->Const.MaxTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformVectors", - state->Const.MaxFragmentUniformComponents / 4); - - add_uniform(instructions, symtab, "gl_DepthRange", - state->symbols->get_type("gl_DepthRangeParameters")); -} - -static void -generate_100ES_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - generate_common_ES_uniforms(instructions, state); - - glsl_symbol_table *const symtab = state->symbols; - add_builtin_constant(instructions, symtab, "gl_MaxVaryingVectors", - state->Const.MaxVaryingFloats / 4); -} - -static void -generate_300ES_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +void +builtin_variable_generator::generate_constants() { - generate_common_ES_uniforms(instructions, state); - - glsl_symbol_table *const symtab = state->symbols; - - add_builtin_constant(instructions, symtab, "gl_MaxVertexOutputVectors", - state->Const.MaxVaryingFloats / 4); - add_builtin_constant(instructions, symtab, "gl_MaxFragmentInputVectors", - state->Const.MaxVaryingFloats / 4); - add_builtin_constant(instructions, symtab, "gl_MinProgramTexelOffset", - state->Const.MinProgramTexelOffset); - add_builtin_constant(instructions, symtab, "gl_MaxProgramTexelOffset", - state->Const.MaxProgramTexelOffset); -} + add_const("gl_MaxVertexAttribs", state->Const.MaxVertexAttribs); + add_const("gl_MaxVertexTextureImageUnits", + state->Const.MaxVertexTextureImageUnits); + add_const("gl_MaxCombinedTextureImageUnits", + state->Const.MaxCombinedTextureImageUnits); + add_const("gl_MaxTextureImageUnits", state->Const.MaxTextureImageUnits); + add_const("gl_MaxDrawBuffers", state->Const.MaxDrawBuffers); + + /* Max uniforms/varyings: GLSL ES counts these in units of vectors; desktop + * GL counts them in units of "components" or "floats". + */ + if (state->es_shader) { + add_const("gl_MaxVertexUniformVectors", + state->Const.MaxVertexUniformComponents / 4); + add_const("gl_MaxFragmentUniformVectors", + state->Const.MaxFragmentUniformComponents / 4); -static void -generate_110_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool add_deprecated) -{ - glsl_symbol_table *const symtab = state->symbols; - - if (add_deprecated) { - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_uniforms) - ; i++) { - add_builtin_variable(instructions, symtab, - & builtin_110_deprecated_uniforms[i]); + /* In GLSL ES 3.00, gl_MaxVaryingVectors was split out to separate + * vertex and fragment shader constants. + */ + if (state->is_version(0, 300)) { + add_const("gl_MaxVertexOutputVectors", + state->Const.MaxVaryingFloats / 4); + add_const("gl_MaxFragmentInputVectors", + state->Const.MaxVaryingFloats / 4); + } else { + add_const("gl_MaxVaryingVectors", state->Const.MaxVaryingFloats / 4); } - } - - if (add_deprecated) { - add_builtin_constant(instructions, symtab, "gl_MaxLights", - state->Const.MaxLights); - add_builtin_constant(instructions, symtab, "gl_MaxClipPlanes", - state->Const.MaxClipPlanes); - add_builtin_constant(instructions, symtab, "gl_MaxTextureUnits", - state->Const.MaxTextureUnits); - add_builtin_constant(instructions, symtab, "gl_MaxTextureCoords", - state->Const.MaxTextureCoords); - } - add_builtin_constant(instructions, symtab, "gl_MaxVertexAttribs", - state->Const.MaxVertexAttribs); - add_builtin_constant(instructions, symtab, "gl_MaxVertexUniformComponents", - state->Const.MaxVertexUniformComponents); - add_builtin_constant(instructions, symtab, "gl_MaxVaryingFloats", - state->Const.MaxVaryingFloats); - add_builtin_constant(instructions, symtab, "gl_MaxVertexTextureImageUnits", - state->Const.MaxVertexTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxCombinedTextureImageUnits", - state->Const.MaxCombinedTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", - state->Const.MaxTextureImageUnits); - add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformComponents", - state->Const.MaxFragmentUniformComponents); - - if (add_deprecated) { - const glsl_type *const mat4_array_type = - glsl_type::get_array_instance(glsl_type::mat4_type, - state->Const.MaxTextureCoords); - - add_uniform(instructions, symtab, "gl_TextureMatrix", mat4_array_type); - add_uniform(instructions, symtab, "gl_TextureMatrixInverse", mat4_array_type); - add_uniform(instructions, symtab, "gl_TextureMatrixTranspose", mat4_array_type); - add_uniform(instructions, symtab, "gl_TextureMatrixInverseTranspose", mat4_array_type); - } - - add_uniform(instructions, symtab, "gl_DepthRange", - symtab->get_type("gl_DepthRangeParameters")); - - if (add_deprecated) { - add_uniform(instructions, symtab, "gl_ClipPlane", - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxClipPlanes)); - add_uniform(instructions, symtab, "gl_Point", - symtab->get_type("gl_PointParameters")); - - const glsl_type *const material_parameters_type = - symtab->get_type("gl_MaterialParameters"); - add_uniform(instructions, symtab, "gl_FrontMaterial", material_parameters_type); - add_uniform(instructions, symtab, "gl_BackMaterial", material_parameters_type); - - const glsl_type *const light_source_array_type = - glsl_type::get_array_instance(symtab->get_type("gl_LightSourceParameters"), state->Const.MaxLights); - - add_uniform(instructions, symtab, "gl_LightSource", light_source_array_type); - - const glsl_type *const light_model_products_type = - symtab->get_type("gl_LightModelProducts"); - add_uniform(instructions, symtab, "gl_FrontLightModelProduct", - light_model_products_type); - add_uniform(instructions, symtab, "gl_BackLightModelProduct", - light_model_products_type); - - const glsl_type *const light_products_type = - glsl_type::get_array_instance(symtab->get_type("gl_LightProducts"), - state->Const.MaxLights); - add_uniform(instructions, symtab, "gl_FrontLightProduct", light_products_type); - add_uniform(instructions, symtab, "gl_BackLightProduct", light_products_type); - - add_uniform(instructions, symtab, "gl_TextureEnvColor", - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxTextureUnits)); - - const glsl_type *const texcoords_vec4 = - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxTextureCoords); - add_uniform(instructions, symtab, "gl_EyePlaneS", texcoords_vec4); - add_uniform(instructions, symtab, "gl_EyePlaneT", texcoords_vec4); - add_uniform(instructions, symtab, "gl_EyePlaneR", texcoords_vec4); - add_uniform(instructions, symtab, "gl_EyePlaneQ", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneS", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneT", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneR", texcoords_vec4); - add_uniform(instructions, symtab, "gl_ObjectPlaneQ", texcoords_vec4); - - add_uniform(instructions, symtab, "gl_Fog", - symtab->get_type("gl_FogParameters")); - } + } else { + add_const("gl_MaxVertexUniformComponents", + state->Const.MaxVertexUniformComponents); - /* Mesa-internal current attrib state */ - const glsl_type *const vert_attribs = - glsl_type::get_array_instance(glsl_type::vec4_type, VERT_ATTRIB_MAX); - add_uniform(instructions, symtab, "gl_CurrentAttribVertMESA", vert_attribs); - const glsl_type *const frag_attribs = - glsl_type::get_array_instance(glsl_type::vec4_type, VARYING_SLOT_MAX); - add_uniform(instructions, symtab, "gl_CurrentAttribFragMESA", frag_attribs); -} + /* Note: gl_MaxVaryingFloats was deprecated in GLSL 1.30+, but not + * removed + */ + add_const("gl_MaxVaryingFloats", state->Const.MaxVaryingFloats); -/* This function should only be called for ES, not desktop GL. */ -static void -generate_100ES_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_vs_variables[i]); + add_const("gl_MaxFragmentUniformComponents", + state->Const.MaxFragmentUniformComponents); } - generate_100ES_uniforms(instructions, state); - - generate_ARB_draw_buffers_variables(instructions, state, false, - vertex_shader); -} - -static void -generate_300ES_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_vs_variables[i]); + /* Texel offsets were introduced in ARB_shading_language_420pack (which + * requires desktop GLSL version 130), and adopted into desktop GLSL + * version 4.20 and GLSL ES version 3.00. + */ + if ((state->is_version(130, 0) && + state->ARB_shading_language_420pack_enable) || + state->is_version(420, 300)) { + add_const("gl_MinProgramTexelOffset", + state->Const.MinProgramTexelOffset); + add_const("gl_MaxProgramTexelOffset", + state->Const.MaxProgramTexelOffset); } - for (unsigned i = 0; i < Elements(builtin_300ES_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_300ES_vs_variables[i]); + if (state->is_version(130, 0)) { + add_const("gl_MaxClipDistances", state->Const.MaxClipPlanes); + add_const("gl_MaxVaryingComponents", state->Const.MaxVaryingFloats); } - generate_300ES_uniforms(instructions, state); - - generate_ARB_draw_buffers_variables(instructions, state, false, - vertex_shader); -} + if (compatibility) { + /* Note: gl_MaxLights stopped being listed as an explicit constant in + * GLSL 1.30, however it continues to be referred to (as a minimum size + * for compatibility-mode uniforms) all the way up through GLSL 4.30, so + * this seems like it was probably an oversight. + */ + add_const("gl_MaxLights", state->Const.MaxLights); + add_const("gl_MaxClipPlanes", state->Const.MaxClipPlanes); -static void -generate_110_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool add_deprecated) -{ - for (unsigned i = 0; i < Elements(builtin_core_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_vs_variables[i]); - } + /* Note: gl_MaxTextureUnits wasn't made compatibility-only until GLSL + * 1.50, however this seems like it was probably an oversight. + */ + add_const("gl_MaxTextureUnits", state->Const.MaxTextureUnits); - if (add_deprecated) { - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_vs_variables) - ; i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_110_deprecated_vs_variables[i]); - } + /* Note: gl_MaxTextureCoords was left out of GLSL 1.40, but it was + * re-introduced in GLSL 1.50, so this seems like it was probably an + * oversight. + */ + add_const("gl_MaxTextureCoords", state->Const.MaxTextureCoords); } - generate_110_uniforms(instructions, state, add_deprecated); - - /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: - * - * "As with all arrays, indices used to subscript gl_TexCoord must - * either be an integral constant expressions, or this array must be - * re-declared by the shader with a size. The size can be at most - * gl_MaxTextureCoords. Using indexes close to 0 may aid the - * implementation in preserving varying resources." - */ - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 0); - - add_variable(instructions, state->symbols, - "gl_TexCoord", vec4_array_type, ir_var_shader_out, - VARYING_SLOT_TEX0); - - generate_ARB_draw_buffers_variables(instructions, state, false, - vertex_shader); } -static void -generate_120_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool add_deprecated) -{ - /* GLSL version 1.20 did not add any built-in variables in the vertex - * shader. - */ - generate_110_vs_variables(instructions, state, add_deprecated); -} - - -static void -generate_130_uniforms(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +/** + * Generate uniform variables (which exist in all types of shaders). + */ +void +builtin_variable_generator::generate_uniforms() { - glsl_symbol_table *const symtab = state->symbols; - - add_builtin_constant(instructions, symtab, "gl_MaxClipDistances", - state->Const.MaxClipPlanes); - add_builtin_constant(instructions, symtab, "gl_MaxVaryingComponents", - state->Const.MaxVaryingFloats); - - if (state->ARB_shading_language_420pack_enable) { - add_builtin_constant(instructions, symtab, "gl_MinProgramTexelOffset", - state->Const.MinProgramTexelOffset); - add_builtin_constant(instructions, symtab, "gl_MaxProgramTexelOffset", - state->Const.MaxProgramTexelOffset); - } -} + add_uniform(type("gl_DepthRangeParameters"), "gl_DepthRange"); + add_uniform(array(vec4_t, VERT_ATTRIB_MAX), "gl_CurrentAttribVertMESA"); + add_uniform(array(vec4_t, VARYING_SLOT_MAX), "gl_CurrentAttribFragMESA"); + + if (compatibility) { + add_uniform(mat4_t, "gl_ModelViewMatrix"); + add_uniform(mat4_t, "gl_ProjectionMatrix"); + add_uniform(mat4_t, "gl_ModelViewProjectionMatrix"); + add_uniform(mat3_t, "gl_NormalMatrix"); + add_uniform(mat4_t, "gl_ModelViewMatrixInverse"); + add_uniform(mat4_t, "gl_ProjectionMatrixInverse"); + add_uniform(mat4_t, "gl_ModelViewProjectionMatrixInverse"); + add_uniform(mat4_t, "gl_ModelViewMatrixTranspose"); + add_uniform(mat4_t, "gl_ProjectionMatrixTranspose"); + add_uniform(mat4_t, "gl_ModelViewProjectionMatrixTranspose"); + add_uniform(mat4_t, "gl_ModelViewMatrixInverseTranspose"); + add_uniform(mat4_t, "gl_ProjectionMatrixInverseTranspose"); + add_uniform(mat4_t, "gl_ModelViewProjectionMatrixInverseTranspose"); + add_uniform(float_t, "gl_NormalScale"); + add_uniform(type("gl_LightModelParameters"), "gl_LightModel"); + add_uniform(vec2_t, "gl_BumpRotMatrix0MESA"); + add_uniform(vec2_t, "gl_BumpRotMatrix1MESA"); + add_uniform(vec4_t, "gl_FogParamsOptimizedMESA"); + const glsl_type *const mat4_array_type = + array(mat4_t, state->Const.MaxTextureCoords); + add_uniform(mat4_array_type, "gl_TextureMatrix"); + add_uniform(mat4_array_type, "gl_TextureMatrixInverse"); + add_uniform(mat4_array_type, "gl_TextureMatrixTranspose"); + add_uniform(mat4_array_type, "gl_TextureMatrixInverseTranspose"); -static void -generate_130_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool add_deprecated) -{ - generate_120_vs_variables(instructions, state, add_deprecated); - - for (unsigned i = 0; i < Elements(builtin_130_vs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_130_vs_variables[i]); - } + add_uniform(array(vec4_t, state->Const.MaxClipPlanes), "gl_ClipPlane"); + add_uniform(type("gl_PointParameters"), "gl_Point"); - generate_130_uniforms(instructions, state); + const glsl_type *const material_parameters_type = + type("gl_MaterialParameters"); + add_uniform(material_parameters_type, "gl_FrontMaterial"); + add_uniform(material_parameters_type, "gl_BackMaterial"); - /* From the GLSL 1.30 spec, section 7.1 (Vertex Shader Special - * Variables): - * - * The gl_ClipDistance array is predeclared as unsized and must - * be sized by the shader either redeclaring it with a size or - * indexing it only with integral constant expressions. - * - * We represent this in Mesa by initially declaring the array as - * size 0. - */ - const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 0); + add_uniform(array(type("gl_LightSourceParameters"), + state->Const.MaxLights), + "gl_LightSource"); - add_variable(instructions, state->symbols, - "gl_ClipDistance", clip_distance_array_type, ir_var_shader_out, - VARYING_SLOT_CLIP_DIST0); + const glsl_type *const light_model_products_type = + type("gl_LightModelProducts"); + add_uniform(light_model_products_type, "gl_FrontLightModelProduct"); + add_uniform(light_model_products_type, "gl_BackLightModelProduct"); - generate_AMD_vertex_shader_layer_variables(instructions, state, false, - vertex_shader); -} + const glsl_type *const light_products_type = + array(type("gl_LightProducts"), state->Const.MaxLights); + add_uniform(light_products_type, "gl_FrontLightProduct"); + add_uniform(light_products_type, "gl_BackLightProduct"); + add_uniform(array(vec4_t, state->Const.MaxTextureUnits), + "gl_TextureEnvColor"); -static void -initialize_vs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (state->es_shader) { - switch (state->language_version) { - case 100: - generate_100ES_vs_variables(instructions, state); - break; - case 300: - generate_300ES_vs_variables(instructions, state); - break; - default: - assert(!"Unexpected language version"); - break; - } - } else { - switch (state->language_version) { - case 110: - generate_110_vs_variables(instructions, state, true); - break; - case 120: - generate_120_vs_variables(instructions, state, true); - break; - case 130: - generate_130_vs_variables(instructions, state, true); - break; - case 140: - case 150: - generate_130_vs_variables(instructions, state, false); - break; - default: - assert(!"Unexpected language version"); - break; - } + const glsl_type *const texcoords_vec4 = + array(vec4_t, state->Const.MaxTextureCoords); + add_uniform(texcoords_vec4, "gl_EyePlaneS"); + add_uniform(texcoords_vec4, "gl_EyePlaneT"); + add_uniform(texcoords_vec4, "gl_EyePlaneR"); + add_uniform(texcoords_vec4, "gl_EyePlaneQ"); + add_uniform(texcoords_vec4, "gl_ObjectPlaneS"); + add_uniform(texcoords_vec4, "gl_ObjectPlaneT"); + add_uniform(texcoords_vec4, "gl_ObjectPlaneR"); + add_uniform(texcoords_vec4, "gl_ObjectPlaneQ"); + + add_uniform(type("gl_FogParameters"), "gl_Fog"); } - - generate_ARB_draw_instanced_variables(instructions, state, false, - vertex_shader); } -/* This function should only be called for ES, not desktop GL. */ -static void -generate_100ES_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +/** + * Generate variables which only exist in vertex shaders. + */ +void +builtin_variable_generator::generate_vs_special_vars() { - for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_fs_variables[i]); + if (state->is_version(130, 300)) + add_system_value(SYSTEM_VALUE_VERTEX_ID, int_t, "gl_VertexID"); + if (state->ARB_draw_instanced_enable) + add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceIDARB"); + if (state->ARB_draw_instanced_enable || state->is_version(140, 300)) + add_system_value(SYSTEM_VALUE_INSTANCE_ID, int_t, "gl_InstanceID"); + if (state->AMD_vertex_shader_layer_enable) + add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer"); + if (compatibility) { + add_input(VERT_ATTRIB_POS, vec4_t, "gl_Vertex"); + add_input(VERT_ATTRIB_NORMAL, vec3_t, "gl_Normal"); + add_input(VERT_ATTRIB_COLOR0, vec4_t, "gl_Color"); + add_input(VERT_ATTRIB_COLOR1, vec4_t, "gl_SecondaryColor"); + add_input(VERT_ATTRIB_TEX0, vec4_t, "gl_MultiTexCoord0"); + add_input(VERT_ATTRIB_TEX1, vec4_t, "gl_MultiTexCoord1"); + add_input(VERT_ATTRIB_TEX2, vec4_t, "gl_MultiTexCoord2"); + add_input(VERT_ATTRIB_TEX3, vec4_t, "gl_MultiTexCoord3"); + add_input(VERT_ATTRIB_TEX4, vec4_t, "gl_MultiTexCoord4"); + add_input(VERT_ATTRIB_TEX5, vec4_t, "gl_MultiTexCoord5"); + add_input(VERT_ATTRIB_TEX6, vec4_t, "gl_MultiTexCoord6"); + add_input(VERT_ATTRIB_TEX7, vec4_t, "gl_MultiTexCoord7"); + add_input(VERT_ATTRIB_FOG, float_t, "gl_FogCoord"); } - - for (unsigned i = 0; i < Elements(builtin_100ES_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_100ES_fs_variables[i]); - } - - generate_100ES_uniforms(instructions, state); - - generate_ARB_draw_buffers_variables(instructions, state, false, - fragment_shader); } -static void -generate_300ES_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - /* Note: we don't add builtin_core_fs_variables, because it contains - * gl_FragColor, which is not in GLSL 3.00 ES. - */ - - for (unsigned i = 0; i < Elements(builtin_300ES_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_300ES_fs_variables[i]); - } - - generate_300ES_uniforms(instructions, state); - - generate_ARB_draw_buffers_variables(instructions, state, false, - fragment_shader); -} -static void -generate_110_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool add_deprecated) +/** + * Generate variables which only exist in geometry shaders. + */ +void +builtin_variable_generator::generate_gs_special_vars() { - for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_core_fs_variables[i]); - } - - for (unsigned i = 0; i < Elements(builtin_110_fs_variables); i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_110_fs_variables[i]); - } - - if (add_deprecated) { - for (unsigned i = 0 - ; i < Elements(builtin_110_deprecated_fs_variables) - ; i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_110_deprecated_fs_variables[i]); - } - } + add_output(VARYING_SLOT_LAYER, int_t, "gl_Layer"); - generate_110_uniforms(instructions, state, add_deprecated); - - /* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec: + /* Although gl_PrimitiveID appears in tessellation control and tessellation + * evaluation shaders, it has a different function there than it has in + * geometry shaders, so we treat it (and its counterpart gl_PrimitiveIDIn) + * as special geometry shader variables. * - * "As with all arrays, indices used to subscript gl_TexCoord must - * either be an integral constant expressions, or this array must be - * re-declared by the shader with a size. The size can be at most - * gl_MaxTextureCoords. Using indexes close to 0 may aid the - * implementation in preserving varying resources." + * Note that although the general convention of suffixing geometry shader + * input varyings with "In" was not adopted into GLSL 1.50, it is used in + * the specific case of gl_PrimitiveIDIn. So we don't need to treat + * gl_PrimitiveIDIn as an {ARB,EXT}_geometry_shader4-only variable. */ - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, 0); - - add_variable(instructions, state->symbols, - "gl_TexCoord", vec4_array_type, ir_var_shader_in, - VARYING_SLOT_TEX0); - - generate_ARB_draw_buffers_variables(instructions, state, false, - fragment_shader); + add_input(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveIDIn"); + add_output(VARYING_SLOT_PRIMITIVE_ID, int_t, "gl_PrimitiveID"); } -static void -generate_ARB_draw_buffers_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn, _mesa_glsl_parser_targets target) +/** + * Generate variables which only exist in fragment shaders. + */ +void +builtin_variable_generator::generate_fs_special_vars() { - /* gl_MaxDrawBuffers is available in all shader stages. - */ - ir_variable *const mdb = - add_builtin_constant(instructions, state->symbols, "gl_MaxDrawBuffers", - state->Const.MaxDrawBuffers); - - if (warn) - mdb->warn_extension = "GL_ARB_draw_buffers"; - - /* gl_FragData is only available in the fragment shader. - * It is not present in GLSL 3.00 ES. + add_input(VARYING_SLOT_POS, vec4_t, "gl_FragCoord"); + add_input(VARYING_SLOT_FACE, bool_t, "gl_FrontFacing"); + if (state->is_version(120, 100)) + add_input(VARYING_SLOT_PNTC, vec2_t, "gl_PointCoord"); + + /* gl_FragColor and gl_FragData were deprecated starting in desktop GLSL + * 1.30, and were relegated to the compatibility profile in GLSL 4.20. + * They were removed from GLSL ES 3.00. */ - if (target == fragment_shader && !state->is_version(0, 300)) { - const glsl_type *const vec4_array_type = - glsl_type::get_array_instance(glsl_type::vec4_type, - state->Const.MaxDrawBuffers); - - ir_variable *const fd = - add_variable(instructions, state->symbols, - "gl_FragData", vec4_array_type, - ir_var_shader_out, FRAG_RESULT_DATA0); - - if (warn) - fd->warn_extension = "GL_ARB_draw_buffers"; + if (compatibility || !state->is_version(420, 300)) { + add_output(FRAG_RESULT_COLOR, vec4_t, "gl_FragColor"); + add_output(FRAG_RESULT_DATA0, + array(vec4_t, state->Const.MaxDrawBuffers), "gl_FragData"); } -} - -static void -generate_ARB_draw_instanced_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn, - _mesa_glsl_parser_targets target) -{ - /* gl_InstanceIDARB is only available in the vertex shader. + /* gl_FragDepth has always been in desktop GLSL, but did not appear in GLSL + * ES 1.00. */ - if (target != vertex_shader) - return; - - if (state->ARB_draw_instanced_enable) { - ir_variable *inst = - add_variable(instructions, state->symbols, - "gl_InstanceIDARB", glsl_type::int_type, - ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID); - - if (warn) - inst->warn_extension = "GL_ARB_draw_instanced"; + if (state->is_version(110, 300)) + add_output(FRAG_RESULT_DEPTH, float_t, "gl_FragDepth"); + + if (state->ARB_shader_stencil_export_enable) { + ir_variable *const var = + add_output(FRAG_RESULT_STENCIL, int_t, "gl_FragStencilRefARB"); + if (state->ARB_shader_stencil_export_warn) + var->warn_extension = "GL_ARB_shader_stencil_export"; } - bool available_in_core = state->is_version(140, 300); - if (state->ARB_draw_instanced_enable || available_in_core) { - /* Originally ARB_draw_instanced only specified that ARB decorated name. - * Since no vendor actually implemented that behavior and some apps use - * the undecorated name, the extension now specifies that both names are - * available. - */ - ir_variable *inst = - add_variable(instructions, state->symbols, - "gl_InstanceID", glsl_type::int_type, - ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID); - - if (!available_in_core && warn) - inst->warn_extension = "GL_ARB_draw_instanced"; - } -} - -static void -generate_AMD_vertex_shader_layer_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn, - _mesa_glsl_parser_targets target) -{ - /* gl_Layer is only available in the vertex shader for the - * AMD_vertex_shader_layer extension. It will also be available in the - * geometry shader when GLSL 1.50 is supported. - */ - if (target != vertex_shader) - return; - - if (state->AMD_vertex_shader_layer_enable) { - ir_variable *inst = - add_variable(instructions, state->symbols, - "gl_Layer", glsl_type::int_type, - ir_var_shader_out, VARYING_SLOT_LAYER); - - if (warn) - inst->warn_extension = "GL_AMD_vertex_shader_layer"; + if (state->AMD_shader_stencil_export_enable) { + ir_variable *const var = + add_output(FRAG_RESULT_STENCIL, int_t, "gl_FragStencilRefAMD"); + if (state->AMD_shader_stencil_export_warn) + var->warn_extension = "GL_AMD_shader_stencil_export"; } } -static void -generate_ARB_shader_stencil_export_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn) -{ - /* gl_FragStencilRefARB is only available in the fragment shader. - */ - ir_variable *const fd = - add_variable(instructions, state->symbols, - "gl_FragStencilRefARB", glsl_type::int_type, - ir_var_shader_out, FRAG_RESULT_STENCIL); - - if (warn) - fd->warn_extension = "GL_ARB_shader_stencil_export"; -} - -static void -generate_AMD_shader_stencil_export_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool warn) -{ - /* gl_FragStencilRefAMD is only available in the fragment shader. - */ - ir_variable *const fd = - add_variable(instructions, state->symbols, - "gl_FragStencilRefAMD", glsl_type::int_type, - ir_var_shader_out, FRAG_RESULT_STENCIL); - if (warn) - fd->warn_extension = "GL_AMD_shader_stencil_export"; -} - -static void -generate_120_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state, - bool add_deprecated) +/** + * Add a single "varying" variable. The variable's type and direction (input + * or output) are adjusted as appropriate for the type of shader being + * compiled. For geometry shaders using {ARB,EXT}_geometry_shader4, + * name_as_gs_input is used for the input (to avoid ambiguity). + */ +void +builtin_variable_generator::add_varying(int slot, const glsl_type *type, + const char *name, + const char *name_as_gs_input) { - generate_110_fs_variables(instructions, state, add_deprecated); - - for (unsigned i = 0 - ; i < Elements(builtin_120_fs_variables) - ; i++) { - add_builtin_variable(instructions, state->symbols, - & builtin_120_fs_variables[i]); + switch (state->target) { + case geometry_shader: + add_input(slot, array(type, 0), name_as_gs_input); + /* FALLTHROUGH */ + case vertex_shader: + add_output(slot, type, name); + break; + case fragment_shader: + add_input(slot, type, name); + break; } } -static void -generate_fs_clipdistance(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - /* From the GLSL 1.30 spec, section 7.2 (Fragment Shader Special - * Variables): - * - * The built-in input variable gl_ClipDistance array contains linearly - * interpolated values for the vertex values written by the vertex shader - * to the gl_ClipDistance vertex output variable. This array must be - * sized in the fragment shader either implicitly or explicitly to be the - * same size as it was sized in the vertex shader. - * - * In other words, the array must be pre-declared as implicitly sized. We - * represent this in Mesa by initially declaring the array as size 0. - */ - const glsl_type *const clip_distance_array_type = - glsl_type::get_array_instance(glsl_type::float_type, 0); - - add_variable(instructions, state->symbols, - "gl_ClipDistance", clip_distance_array_type, ir_var_shader_in, - VARYING_SLOT_CLIP_DIST0); -} -static void -generate_130_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +/** + * Generate variables that are used to communicate data from one shader stage + * to the next ("varyings"). + */ +void +builtin_variable_generator::generate_varyings() { - generate_120_fs_variables(instructions, state, true); - - generate_130_uniforms(instructions, state); - generate_fs_clipdistance(instructions, state); -} - +#define ADD_VARYING(loc, type, name) \ + add_varying(loc, type, name, name "In") -static void -generate_140_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - generate_120_fs_variables(instructions, state, false); + /* gl_Position and gl_PointSize are not visible from fragment shaders. */ + if (state->target != fragment_shader) { + ADD_VARYING(VARYING_SLOT_POS, vec4_t, "gl_Position"); + ADD_VARYING(VARYING_SLOT_PSIZ, float_t, "gl_PointSize"); + } - generate_130_uniforms(instructions, state); - generate_fs_clipdistance(instructions, state); -} + if (state->is_version(130, 0)) { + ADD_VARYING(VARYING_SLOT_CLIP_DIST0, array(float_t, 0), + "gl_ClipDistance"); + } -static void -initialize_fs_variables(exec_list *instructions, - struct _mesa_glsl_parse_state *state) -{ - if (state->es_shader) { - switch (state->language_version) { - case 100: - generate_100ES_fs_variables(instructions, state); - break; - case 300: - generate_300ES_fs_variables(instructions, state); - break; - default: - assert(!"Unexpected language version"); - break; - } - } else { - switch (state->language_version) { - case 110: - generate_110_fs_variables(instructions, state, true); - break; - case 120: - generate_120_fs_variables(instructions, state, true); - break; - case 130: - generate_130_fs_variables(instructions, state); - break; - case 140: - case 150: - generate_140_fs_variables(instructions, state); - break; - default: - assert(!"Unexpected language version"); - break; + if (compatibility) { + ADD_VARYING(VARYING_SLOT_TEX0, array(vec4_t, 0), "gl_TexCoord"); + ADD_VARYING(VARYING_SLOT_FOGC, float_t, "gl_FogFragCoord"); + if (state->target == fragment_shader) { + ADD_VARYING(VARYING_SLOT_COL0, vec4_t, "gl_Color"); + ADD_VARYING(VARYING_SLOT_COL1, vec4_t, "gl_SecondaryColor"); + } else { + ADD_VARYING(VARYING_SLOT_CLIP_VERTEX, vec4_t, "gl_ClipVertex"); + ADD_VARYING(VARYING_SLOT_COL0, vec4_t, "gl_FrontColor"); + ADD_VARYING(VARYING_SLOT_BFC0, vec4_t, "gl_BackColor"); + ADD_VARYING(VARYING_SLOT_COL1, vec4_t, "gl_FrontSecondaryColor"); + ADD_VARYING(VARYING_SLOT_BFC1, vec4_t, "gl_BackSecondaryColor"); } } +} - if (state->ARB_shader_stencil_export_enable) - generate_ARB_shader_stencil_export_variables(instructions, state, - state->ARB_shader_stencil_export_warn); - if (state->AMD_shader_stencil_export_enable) - generate_AMD_shader_stencil_export_variables(instructions, state, - state->AMD_shader_stencil_export_warn); -} +}; /* Anonymous namespace */ + void _mesa_glsl_initialize_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { + builtin_variable_generator gen(instructions, state); + + gen.generate_constants(); + gen.generate_uniforms(); + + gen.generate_varyings(); + switch (state->target) { case vertex_shader: - initialize_vs_variables(instructions, state); + gen.generate_vs_special_vars(); break; case geometry_shader: + gen.generate_gs_special_vars(); break; case fragment_shader: - initialize_fs_variables(instructions, state); + gen.generate_fs_special_vars(); break; } } diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp index 0bea5364e..4c96620bf 100644 --- a/mesalib/src/glsl/glsl_symbol_table.cpp +++ b/mesalib/src/glsl/glsl_symbol_table.cpp @@ -175,13 +175,21 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t) return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0; } -bool glsl_symbol_table::add_type_ast(const char *name, const class ast_type_specifier *a) +static char *make_ast_name(const char *name) { - symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(a); - char ast_name[strlen("#ast.") + strlen(name) + 1]; + char *ast_name = new char[strlen("#ast.") + strlen(name) + 1]; strcpy(ast_name, "#ast."); strcat(ast_name + strlen("#ast."), name); - return _mesa_symbol_table_add_symbol(table, -1, ast_name, entry) == 0; + return ast_name; +} + +bool glsl_symbol_table::add_type_ast(const char *name, const class ast_type_specifier *a) +{ + symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(a); + char *ast_name = make_ast_name(name); + bool ret = _mesa_symbol_table_add_symbol(table, -1, ast_name, entry) == 0; + delete [] ast_name; + return ret; } bool glsl_symbol_table::add_interface(const char *name, const glsl_type *i, @@ -237,10 +245,9 @@ const glsl_type *glsl_symbol_table::get_type(const char *name) const class ast_type_specifier *glsl_symbol_table::get_type_ast(const char *name) { - char ast_name[strlen("#ast.") + strlen(name) + 1]; - strcpy(ast_name, "#ast."); - strcat(ast_name + strlen("#ast."), name); + char *ast_name = make_ast_name(name); symbol_table_entry *entry = get_entry(ast_name); + delete [] ast_name; return entry != NULL ? entry->a : NULL; } diff --git a/mesalib/src/glsl/lower_named_interface_blocks.cpp b/mesalib/src/glsl/lower_named_interface_blocks.cpp index 922cc024f..d0d491d3d 100644 --- a/mesalib/src/glsl/lower_named_interface_blocks.cpp +++ b/mesalib/src/glsl/lower_named_interface_blocks.cpp @@ -194,6 +194,8 @@ flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue) return; ir_variable *var = ir->variable_referenced(); + if (var == NULL) + return; if (!var->is_interface_instance()) return; diff --git a/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml b/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml index f2877a4f7..11f268dc6 100644 --- a/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml +++ b/mesalib/src/mapi/glapi/gen/ARB_debug_output.xml @@ -72,7 +72,7 @@ - + diff --git a/mesalib/src/mapi/glapi/gen/EXT_transform_feedback.xml b/mesalib/src/mapi/glapi/gen/EXT_transform_feedback.xml index e4b310ec3..65259fc1f 100644 --- a/mesalib/src/mapi/glapi/gen/EXT_transform_feedback.xml +++ b/mesalib/src/mapi/glapi/gen/EXT_transform_feedback.xml @@ -55,7 +55,7 @@ - + diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c index 5c72b3cd7..21e593117 100644 --- a/mesalib/src/mesa/main/enable.c +++ b/mesalib/src/mesa/main/enable.c @@ -1395,40 +1395,41 @@ _mesa_IsEnabled( GLenum cap ) case GL_VERTEX_ARRAY: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled != 0); + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POS].Enabled; case GL_NORMAL_ARRAY: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled != 0); + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_NORMAL].Enabled; case GL_COLOR_ARRAY: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled != 0); + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR0].Enabled; case GL_INDEX_ARRAY: if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled != 0); + return ctx->Array.ArrayObj-> + VertexAttrib[VERT_ATTRIB_COLOR_INDEX].Enabled; case GL_TEXTURE_COORD_ARRAY: if (ctx->API != API_OPENGL_COMPAT && ctx->API != API_OPENGLES) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)] - .Enabled != 0); + return ctx->Array.ArrayObj-> + VertexAttrib[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].Enabled; case GL_EDGE_FLAG_ARRAY: if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled != 0); + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_EDGEFLAG].Enabled; case GL_FOG_COORDINATE_ARRAY_EXT: if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled != 0); + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_FOG].Enabled; case GL_SECONDARY_COLOR_ARRAY_EXT: if (ctx->API != API_OPENGL_COMPAT) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled != 0); + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_COLOR1].Enabled; case GL_POINT_SIZE_ARRAY_OES: if (ctx->API != API_OPENGLES) goto invalid_enum_error; - return (ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled != 0); + return ctx->Array.ArrayObj->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled; /* GL_ARB_texture_cube_map */ case GL_TEXTURE_CUBE_MAP_ARB: diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c index 465420766..5a0758d0b 100644 --- a/mesalib/src/mesa/main/errors.c +++ b/mesalib/src/mesa/main/errors.c @@ -659,7 +659,7 @@ _mesa_DebugMessageControlARB(GLenum gl_source, GLenum gl_type, } void GLAPIENTRY -_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, GLvoid *userParam) +_mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, const void *userParam) { GET_CURRENT_CONTEXT(ctx); ctx->Debug.Callback = callback; diff --git a/mesalib/src/mesa/main/errors.h b/mesalib/src/mesa/main/errors.h index 4b376fb60..5b4f36f55 100644 --- a/mesalib/src/mesa/main/errors.h +++ b/mesalib/src/mesa/main/errors.h @@ -101,7 +101,7 @@ _mesa_DebugMessageControlARB(GLenum source, GLenum type, GLenum severity, GLboolean enabled); void GLAPIENTRY _mesa_DebugMessageCallbackARB(GLDEBUGPROCARB callback, - GLvoid *userParam); + const void *userParam); #ifdef __cplusplus } diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c index 39fd260dc..0e075427f 100644 --- a/mesalib/src/mesa/main/getstring.c +++ b/mesalib/src/mesa/main/getstring.c @@ -262,7 +262,7 @@ _mesa_GetPointerv( GLenum pname, GLvoid **params ) case GL_DEBUG_CALLBACK_USER_PARAM_ARB: if (!_mesa_is_desktop_gl(ctx)) goto invalid_pname; - *params = ctx->Debug.CallbackData; + *params = (GLvoid *) ctx->Debug.CallbackData; break; default: goto invalid_pname; diff --git a/mesalib/src/mesa/main/hash_table.c b/mesalib/src/mesa/main/hash_table.c index af0510da1..008b4cdbc 100644 --- a/mesalib/src/mesa/main/hash_table.c +++ b/mesalib/src/mesa/main/hash_table.c @@ -110,8 +110,8 @@ entry_is_present(const struct hash_table *ht, struct hash_entry *entry) struct hash_table * _mesa_hash_table_create(void *mem_ctx, - bool key_equals_function(const void *a, - const void *b)) + bool (*key_equals_function)(const void *a, + const void *b)) { struct hash_table *ht; diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c index f1e12e8cf..edf725721 100644 --- a/mesalib/src/mesa/main/mipmap.c +++ b/mesalib/src/mesa/main/mipmap.c @@ -1885,7 +1885,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target, const struct gl_texture_image *srcImage, GLuint maxLevel) { - GLint level; + GLuint level; GLenum datatype; GLuint comps; @@ -2017,7 +2017,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, struct gl_texture_image *srcImage, GLuint maxLevel) { - GLint level; + GLuint level; gl_format temp_format; GLint components; GLuint temp_src_stride; /* in bytes */ diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index 2f7cce7ba..ea139ea58 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -272,8 +272,6 @@ typedef enum /*@}*/ -/*********************************************/ - /** * Determine if the given gl_varying_slot appears in the fragment shader. */ @@ -673,7 +671,7 @@ struct gl_colorbuffer_attrib GLboolean _ClampFragmentColor; /** < with GL_FIXED_ONLY_ARB resolved */ GLenum ClampReadColor; /**< GL_TRUE, GL_FALSE or GL_FIXED_ONLY_ARB */ - GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ + GLboolean sRGBEnabled; /**< Framebuffer sRGB blending/updating requested */ }; @@ -874,9 +872,8 @@ struct gl_multisample_attrib /* ARB_texture_multisample / GL3.2 additions */ GLboolean SampleMask; - GLbitfield SampleMaskValue; /* GL spec defines this as an array but >32x MSAA is - * madness - */ + /** The GL spec defines this as an array but >32x MSAA is madness */ + GLbitfield SampleMaskValue; }; @@ -1103,8 +1100,8 @@ struct gl_texture_image GLuint Face; /** GL_ARB_texture_multisample */ - GLuint NumSamples; /**< Sample count, or 0 for non-multisample */ - GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */ + GLuint NumSamples; /**< Sample count, or 0 for non-multisample */ + GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */ }; @@ -1546,7 +1543,8 @@ struct gl_array_attrib /** * Vertex arrays as consumed by a driver. - * The array pointer is set up only by the VBO module. */ + * The array pointer is set up only by the VBO module. + */ const struct gl_client_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */ }; @@ -2102,7 +2100,10 @@ struct gl_sl_pragmas */ struct gl_shader { - GLenum Type; /**< GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB (first field!) */ + /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB. + * Must be the first field. + */ + GLenum Type; GLuint Name; /**< AKA the handle */ GLint RefCount; /**< Reference count */ GLboolean DeletePending; @@ -2186,6 +2187,7 @@ typedef enum MESA_SHADER_TYPES = 3 } gl_shader_type; + struct gl_uniform_buffer_variable { char *Name; @@ -2207,12 +2209,15 @@ struct gl_uniform_buffer_variable GLboolean RowMajor; }; -enum gl_uniform_block_packing { + +enum gl_uniform_block_packing +{ ubo_packing_std140, ubo_packing_shared, ubo_packing_packed }; + struct gl_uniform_block { /** Declared name of the uniform block */ @@ -2244,6 +2249,7 @@ struct gl_uniform_block enum gl_uniform_block_packing _Packing; }; + /** * A GLSL program object. * Basically a linked collection of vertex and fragment shaders. @@ -2793,7 +2799,7 @@ struct gl_constants GLuint MaxTextureRectSize; /**< Max rectangle texture size, in pixes */ GLuint MaxTextureCoordUnits; GLuint MaxCombinedTextureImageUnits; - GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */ + GLuint MaxTextureUnits; /**< = MIN(CoordUnits, FragmentProgram.ImageUnits) */ GLfloat MaxTextureMaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */ GLfloat MaxTextureLodBias; /**< GL_EXT_texture_lod_bias */ GLuint MaxTextureBufferSize; /**< GL_ARB_texture_buffer_object */ @@ -3324,7 +3330,7 @@ struct gl_debug_namespace struct gl_debug_state { GLDEBUGPROCARB Callback; - GLvoid *CallbackData; + const void *CallbackData; GLboolean SyncOutput; GLboolean Defaults[MESA_DEBUG_SEVERITY_COUNT][MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT]; struct gl_debug_namespace Namespaces[MESA_DEBUG_SOURCE_COUNT][MESA_DEBUG_TYPE_COUNT]; diff --git a/mesalib/src/mesa/main/multisample.c b/mesalib/src/mesa/main/multisample.c index 8b974c1b7..bd97c5096 100644 --- a/mesalib/src/mesa/main/multisample.c +++ b/mesalib/src/mesa/main/multisample.c @@ -80,7 +80,7 @@ _mesa_GetMultisamplefv(GLenum pname, GLuint index, GLfloat * val) switch (pname) { case GL_SAMPLE_POSITION: { - if (index >= ctx->DrawBuffer->Visual.samples) { + if ((int) index >= ctx->DrawBuffer->Visual.samples) { _mesa_error( ctx, GL_INVALID_VALUE, "glGetMultisamplefv(index)" ); return; } @@ -197,5 +197,6 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum target, * "... or if samples is greater than MAX_SAMPLES, then the error * INVALID_VALUE is generated" */ - return samples > ctx->Const.MaxSamples ? GL_INVALID_VALUE : GL_NO_ERROR; + return (GLuint) samples > ctx->Const.MaxSamples + ? GL_INVALID_VALUE : GL_NO_ERROR; } diff --git a/mesalib/src/mesa/main/set.c b/mesalib/src/mesa/main/set.c index 2519b9694..dc3550c76 100644 --- a/mesalib/src/mesa/main/set.c +++ b/mesalib/src/mesa/main/set.c @@ -103,8 +103,8 @@ entry_is_present(struct set_entry *entry) struct set * _mesa_set_create(void *mem_ctx, - bool key_equals_function(const void *a, - const void *b)) + bool (*key_equals_function)(const void *a, + const void *b)) { struct set *ht; diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c index cf9a3014c..141cbe3ab 100644 --- a/mesalib/src/mesa/main/texparam.c +++ b/mesalib/src/mesa/main/texparam.c @@ -1547,7 +1547,7 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) case GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES: if (!_mesa_is_gles(ctx) || !ctx->Extensions.OES_EGL_image_external) goto invalid_pname; - *params = obj->RequiredTextureImageUnits; + *params = (GLfloat) obj->RequiredTextureImageUnits; break; case GL_TEXTURE_SRGB_DECODE_EXT: diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c index 9b66ad50b..04385e1e9 100644 --- a/mesalib/src/mesa/main/texstore.c +++ b/mesalib/src/mesa/main/texstore.c @@ -4143,7 +4143,7 @@ _mesa_store_compressed_texsubimage(struct gl_context *ctx, GLuint dims, const GLubyte *src; const gl_format texFormat = texImage->TexFormat; GLuint bw, bh; - GLuint slice; + GLint slice; if (dims == 1) { _mesa_problem(ctx, "Unexpected 1D compressed texsubimage call"); diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c index 17e62403d..1e6f7f483 100644 --- a/mesalib/src/mesa/main/uniforms.c +++ b/mesalib/src/mesa/main/uniforms.c @@ -832,7 +832,7 @@ _mesa_get_uniform_name(const struct gl_uniform_storage *uni, * harm in always appending "[0]" to uniform array names. */ if (uni->array_elements != 0) { - unsigned i; + int i; /* The comparison is strange because *length does *NOT* include the * terminating NUL, but maxLength does. diff --git a/mesalib/src/mesa/program/prog_parameter.c b/mesalib/src/mesa/program/prog_parameter.c index 95b153e16..4d9cf08d2 100644 --- a/mesalib/src/mesa/program/prog_parameter.c +++ b/mesalib/src/mesa/program/prog_parameter.c @@ -155,7 +155,21 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList, p->Size = size; p->DataType = datatype; if (values) { - COPY_4V(paramList->ParameterValues[oldNum + i], values); + if (size >= 4) { + COPY_4V(paramList->ParameterValues[oldNum + i], values); + } + else { + /* copy 1, 2 or 3 values */ + GLuint remaining = size % 4; + assert(remaining < 4); + for (j = 0; j < remaining; j++) { + paramList->ParameterValues[oldNum + i][j].f = values[j].f; + } + /* fill in remaining positions with zeros */ + for (; j < 4; j++) { + paramList->ParameterValues[oldNum + i][j].f = 0.0f; + } + } values += 4; p->Initialized = GL_TRUE; } diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 64e0a8a46..69c1b412b 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -2976,9 +2976,10 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir) if (ir->condition) { ir->condition->accept(this); this->result.negate = ~this->result.negate; - emit(ir, TGSI_OPCODE_KIL, undef_dst, this->result); + emit(ir, TGSI_OPCODE_KILL_IF, undef_dst, this->result); } else { - emit(ir, TGSI_OPCODE_KILP); + /* unconditional kil */ + emit(ir, TGSI_OPCODE_KILL); } } @@ -4009,7 +4010,7 @@ get_bitmap_visitor(struct st_fragment_program *fp, src0.negate = NEGATE_XYZW; if (st->bitmap.tex_format == PIPE_FORMAT_L8_UNORM) src0.swizzle = SWIZZLE_XXXX; - inst = v->emit(NULL, TGSI_OPCODE_KIL, undef_dst, src0); + inst = v->emit(NULL, TGSI_OPCODE_KILL_IF, undef_dst, src0); /* Now copy the instructions from the original glsl_to_tgsi_visitor into the * new visitor. */ diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c index dd9f4fc53..67c6f53f6 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -585,9 +585,10 @@ translate_opcode( unsigned op ) case OPCODE_TRUNC: return TGSI_OPCODE_TRUNC; case OPCODE_KIL: - return TGSI_OPCODE_KIL; + return TGSI_OPCODE_KILL_IF; case OPCODE_KIL_NV: - return TGSI_OPCODE_KILP; + /* XXX we don't support condition codes in TGSI */ + return TGSI_OPCODE_KILL; case OPCODE_LG2: return TGSI_OPCODE_LG2; case OPCODE_LOG: @@ -614,8 +615,6 @@ translate_opcode( unsigned op ) return TGSI_OPCODE_RCP; case OPCODE_RET: return TGSI_OPCODE_RET; - case OPCODE_RSQ: - return TGSI_OPCODE_RSQ; case OPCODE_SCS: return TGSI_OPCODE_SCS; case OPCODE_SEQ: @@ -755,6 +754,10 @@ compile_instruction( emit_ddy( t, dst[0], &inst->SrcReg[0] ); break; + case OPCODE_RSQ: + ureg_RSQ( ureg, dst[0], ureg_abs(src[0]) ); + break; + default: ureg_insn( ureg, translate_opcode( inst->Opcode ), -- cgit v1.2.3