aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
committermarha <marha@users.sourceforge.net>2012-03-26 14:23:28 +0200
commit76bcc36ed305418a3ddc5752d287ede894243e1b (patch)
treebacb320c825768471ce56f058f17ce863d592376 /mesalib/src/glsl
parent7d894e32566b710952c44cbc71939ad1d9e2fa8d (diff)
parent0f834b91a4768673833ab4917e87d86c237bb1a6 (diff)
downloadvcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.gz
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.tar.bz2
vcxsrv-76bcc36ed305418a3ddc5752d287ede894243e1b.zip
Merge remote-tracking branch 'origin/released'
Conflicts: pixman/pixman/pixman-mmx.c xorg-server/Xext/shm.c xorg-server/Xext/syncsrv.h xorg-server/Xext/xvmain.c xorg-server/Xi/exevents.c xorg-server/Xi/opendev.c xorg-server/composite/compalloc.c xorg-server/composite/compoverlay.c xorg-server/dix/colormap.c xorg-server/dix/devices.c xorg-server/dix/dispatch.c xorg-server/dix/dixfonts.c xorg-server/dix/eventconvert.c xorg-server/dix/events.c xorg-server/dix/gc.c xorg-server/dix/getevents.c xorg-server/dix/main.c xorg-server/dix/privates.c xorg-server/dix/registry.c xorg-server/dix/resource.c xorg-server/exa/exa_accel.c xorg-server/exa/exa_migration_classic.c xorg-server/exa/exa_unaccel.c xorg-server/fb/fb.h xorg-server/fb/fbcopy.c xorg-server/fb/fbpixmap.c xorg-server/glx/dispatch.h xorg-server/glx/glapi.h xorg-server/glx/glapi_gentable.c xorg-server/glx/glapitable.h xorg-server/glx/glprocs.h xorg-server/glx/glxcmds.c xorg-server/glx/glxcmdsswap.c xorg-server/glx/glxdricommon.c xorg-server/glx/glxdriswrast.c xorg-server/glx/glxext.c xorg-server/glx/indirect_dispatch.c xorg-server/glx/indirect_dispatch.h xorg-server/glx/indirect_dispatch_swap.c xorg-server/glx/indirect_size.h xorg-server/glx/indirect_size_get.h xorg-server/glx/indirect_table.c xorg-server/glx/indirect_util.c xorg-server/glx/rensize.c xorg-server/glx/single2swap.c xorg-server/glx/singlepix.c xorg-server/glx/singlepixswap.c xorg-server/glx/singlesize.c xorg-server/hw/dmx/dmxinit.c xorg-server/hw/kdrive/ephyr/ephyr.c xorg-server/hw/kdrive/ephyr/hostx.c xorg-server/hw/kdrive/ephyr/hostx.h xorg-server/hw/kdrive/src/kinput.c xorg-server/hw/xfree86/common/compiler.h xorg-server/hw/xwin/InitInput.c xorg-server/hw/xwin/InitOutput.c xorg-server/hw/xwin/ddraw.h xorg-server/hw/xwin/glx/glwrap.c xorg-server/hw/xwin/glx/indirect.c xorg-server/hw/xwin/glx/wgl_ext_api.h xorg-server/hw/xwin/glx/winpriv.c xorg-server/hw/xwin/win.h xorg-server/hw/xwin/winallpriv.c xorg-server/hw/xwin/winauth.c xorg-server/hw/xwin/winclipboard.h xorg-server/hw/xwin/winclipboardinit.c xorg-server/hw/xwin/winclipboardthread.c xorg-server/hw/xwin/winclipboardunicode.c xorg-server/hw/xwin/winclipboardwndproc.c xorg-server/hw/xwin/winclipboardwrappers.c xorg-server/hw/xwin/winclipboardxevents.c xorg-server/hw/xwin/wincmap.c xorg-server/hw/xwin/winconfig.c xorg-server/hw/xwin/wincreatewnd.c xorg-server/hw/xwin/wincursor.c xorg-server/hw/xwin/windialogs.c xorg-server/hw/xwin/winengine.c xorg-server/hw/xwin/winerror.c xorg-server/hw/xwin/wingc.c xorg-server/hw/xwin/wingetsp.c xorg-server/hw/xwin/winkeybd.c xorg-server/hw/xwin/winkeybd.h xorg-server/hw/xwin/winlayouts.h xorg-server/hw/xwin/winmisc.c xorg-server/hw/xwin/winmonitors.c xorg-server/hw/xwin/winmouse.c xorg-server/hw/xwin/winmsg.c xorg-server/hw/xwin/winmsg.h xorg-server/hw/xwin/winmultiwindowclass.c xorg-server/hw/xwin/winmultiwindowicons.c xorg-server/hw/xwin/winmultiwindowshape.c xorg-server/hw/xwin/winmultiwindowwindow.c xorg-server/hw/xwin/winmultiwindowwm.c xorg-server/hw/xwin/winmultiwindowwndproc.c xorg-server/hw/xwin/winnativegdi.c xorg-server/hw/xwin/winpfbdd.c xorg-server/hw/xwin/winpixmap.c xorg-server/hw/xwin/winpolyline.c xorg-server/hw/xwin/winprefs.c xorg-server/hw/xwin/winprocarg.c xorg-server/hw/xwin/winregistry.c xorg-server/hw/xwin/winscrinit.c xorg-server/hw/xwin/winsetsp.c xorg-server/hw/xwin/winshaddd.c xorg-server/hw/xwin/winshadddnl.c xorg-server/hw/xwin/winshadgdi.c xorg-server/hw/xwin/wintrayicon.c xorg-server/hw/xwin/winwin32rootless.c xorg-server/hw/xwin/winwin32rootlesswindow.c xorg-server/hw/xwin/winwin32rootlesswndproc.c xorg-server/hw/xwin/winwindow.c xorg-server/hw/xwin/winwindow.h xorg-server/hw/xwin/winwindowswm.c xorg-server/hw/xwin/winwndproc.c xorg-server/include/callback.h xorg-server/include/dixstruct.h xorg-server/include/misc.h xorg-server/include/os.h xorg-server/include/scrnintstr.h xorg-server/mi/micmap.c xorg-server/mi/miinitext.c xorg-server/mi/mioverlay.c xorg-server/mi/misprite.c xorg-server/mi/mivaltree.c xorg-server/mi/miwindow.c xorg-server/miext/damage/damage.c xorg-server/miext/rootless/rootlessGC.c xorg-server/miext/rootless/rootlessWindow.c xorg-server/os/WaitFor.c xorg-server/os/access.c xorg-server/os/connection.c xorg-server/os/io.c xorg-server/os/log.c xorg-server/os/osinit.c xorg-server/os/utils.c xorg-server/os/xdmcp.c xorg-server/os/xprintf.c xorg-server/os/xstrans.c xorg-server/render/mipict.c xorg-server/xkb/xkbActions.c xorg-server/xkb/xkbInit.c xorg-server/xkeyboard-config/compat/default.in
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp23
-rw-r--r--mesalib/src/glsl/builtin_types.h12
-rw-r--r--mesalib/src/glsl/builtin_variables.cpp261
-rw-r--r--mesalib/src/glsl/glsl_parser.yy3
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp2
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h1
-rw-r--r--mesalib/src/glsl/glsl_types.cpp40
-rw-r--r--mesalib/src/glsl/glsl_types.h8
-rw-r--r--mesalib/src/glsl/linker.cpp41
-rw-r--r--mesalib/src/glsl/main.cpp6
10 files changed, 248 insertions, 149 deletions
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index c580359fd..75d7e9d57 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -1199,15 +1199,9 @@ ast_expression::hir(exec_list *instructions,
op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1,
"RHS", &error_emitted);
- ir_constant *op0_const = op[0]->constant_expression_value();
- if (op0_const) {
- if (op0_const->value.b[0]) {
- instructions->append_list(&rhs_instructions);
- result = op[1];
- } else {
- result = op0_const;
- }
- type = glsl_type::bool_type;
+ if (rhs_instructions.is_empty()) {
+ result = new(ctx) ir_expression(ir_binop_logic_and, op[0], op[1]);
+ type = result->type;
} else {
ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type,
"and_tmp",
@@ -1241,14 +1235,9 @@ ast_expression::hir(exec_list *instructions,
op[1] = get_scalar_boolean_operand(&rhs_instructions, state, this, 1,
"RHS", &error_emitted);
- ir_constant *op0_const = op[0]->constant_expression_value();
- if (op0_const) {
- if (op0_const->value.b[0]) {
- result = op0_const;
- } else {
- result = op[1];
- }
- type = glsl_type::bool_type;
+ if (rhs_instructions.is_empty()) {
+ result = new(ctx) ir_expression(ir_binop_logic_or, op[0], op[1]);
+ type = result->type;
} else {
ir_variable *const tmp = new(ctx) ir_variable(glsl_type::bool_type,
"or_tmp",
diff --git a/mesalib/src/glsl/builtin_types.h b/mesalib/src/glsl/builtin_types.h
index cc99b1bde..890c1213f 100644
--- a/mesalib/src/glsl/builtin_types.h
+++ b/mesalib/src/glsl/builtin_types.h
@@ -259,6 +259,18 @@ const glsl_type *const glsl_type::uvec3_type = & builtin_130_types[2];
const glsl_type *const glsl_type::uvec4_type = & builtin_130_types[3];
/*@}*/
+
+/** \name Types added in GLSL 1.30
+ */
+/*@{*/
+const glsl_type glsl_type::builtin_140_types[] = {
+ glsl_type(GL_INT_SAMPLER_2D_RECT,
+ GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_INT, "isampler2DRect"),
+ glsl_type(GL_UNSIGNED_INT_SAMPLER_2D_RECT,
+ GLSL_SAMPLER_DIM_RECT, 0, 0, GLSL_TYPE_UINT, "usampler2DRect"),
+};
+/*@}*/
+
/** \name Sampler types added by GL_ARB_texture_rectangle
*/
/*@{*/
diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp
index 66b3abdd8..516a69caf 100644
--- a/mesalib/src/glsl/builtin_variables.cpp
+++ b/mesalib/src/glsl/builtin_variables.cpp
@@ -528,25 +528,30 @@ generate_100ES_uniforms(exec_list *instructions,
static void
generate_110_uniforms(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+ struct _mesa_glsl_parse_state *state,
+ bool add_deprecated)
{
glsl_symbol_table *const symtab = state->symbols;
- for (unsigned i = 0
- ; i < Elements(builtin_110_deprecated_uniforms)
- ; i++) {
- add_builtin_variable(instructions, symtab,
- & builtin_110_deprecated_uniforms[i]);
+ if (add_deprecated) {
+ for (unsigned i = 0
+ ; i < Elements(builtin_110_deprecated_uniforms)
+ ; i++) {
+ add_builtin_variable(instructions, symtab,
+ & builtin_110_deprecated_uniforms[i]);
+ }
}
- 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);
+ 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",
@@ -562,65 +567,69 @@ generate_110_uniforms(exec_list *instructions,
add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformComponents",
state->Const.MaxFragmentUniformComponents);
- const glsl_type *const mat4_array_type =
- glsl_type::get_array_instance(glsl_type::mat4_type,
- state->Const.MaxTextureCoords);
+ 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_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"));
- 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"));
+ 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"));
+ }
/* Mesa-internal current attrib state */
const glsl_type *const vert_attribs =
@@ -650,20 +659,23 @@ generate_100ES_vs_variables(exec_list *instructions,
static void
generate_110_vs_variables(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+ 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]);
}
- for (unsigned i = 0
- ; i < Elements(builtin_110_deprecated_vs_variables)
- ; i++) {
- add_builtin_variable(instructions, state->symbols,
- & builtin_110_deprecated_vs_variables[i]);
+ 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]);
+ }
}
- generate_110_uniforms(instructions, state);
+ generate_110_uniforms(instructions, state, add_deprecated);
/* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
*
@@ -686,12 +698,13 @@ generate_110_vs_variables(exec_list *instructions,
static void
generate_120_vs_variables(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+ 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);
+ generate_110_vs_variables(instructions, state, add_deprecated);
}
@@ -710,9 +723,10 @@ generate_130_uniforms(exec_list *instructions,
static void
generate_130_vs_variables(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+ struct _mesa_glsl_parse_state *state,
+ bool add_deprecated)
{
- generate_120_vs_variables(instructions, state);
+ 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,
@@ -751,19 +765,21 @@ initialize_vs_variables(exec_list *instructions,
generate_100ES_vs_variables(instructions, state);
break;
case 110:
- generate_110_vs_variables(instructions, state);
+ generate_110_vs_variables(instructions, state, true);
break;
case 120:
- generate_120_vs_variables(instructions, state);
+ generate_120_vs_variables(instructions, state, true);
break;
case 130:
- generate_130_vs_variables(instructions, state);
+ generate_130_vs_variables(instructions, state, true);
+ break;
+ case 140:
+ generate_130_vs_variables(instructions, state, false);
break;
}
- if (state->ARB_draw_instanced_enable)
- generate_ARB_draw_instanced_variables(instructions, state, false,
- vertex_shader);
+ generate_ARB_draw_instanced_variables(instructions, state, false,
+ vertex_shader);
}
@@ -790,7 +806,8 @@ generate_100ES_fs_variables(exec_list *instructions,
static void
generate_110_fs_variables(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+ struct _mesa_glsl_parse_state *state,
+ bool add_deprecated)
{
for (unsigned i = 0; i < Elements(builtin_core_fs_variables); i++) {
add_builtin_variable(instructions, state->symbols,
@@ -802,13 +819,16 @@ generate_110_fs_variables(exec_list *instructions,
& builtin_110_fs_variables[i]);
}
- for (unsigned i = 0
- ; i < Elements(builtin_110_deprecated_fs_variables)
- ; i++) {
- add_builtin_variable(instructions, state->symbols,
- & builtin_110_deprecated_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]);
+ }
}
- generate_110_uniforms(instructions, state);
+
+ generate_110_uniforms(instructions, state, add_deprecated);
/* From page 54 (page 60 of the PDF) of the GLSL 1.20 spec:
*
@@ -869,7 +889,10 @@ generate_ARB_draw_instanced_variables(exec_list *instructions,
{
/* gl_InstanceIDARB is only available in the vertex shader.
*/
- if (target == vertex_shader) {
+ 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,
@@ -877,17 +900,20 @@ generate_ARB_draw_instanced_variables(exec_list *instructions,
if (warn)
inst->warn_extension = "GL_ARB_draw_instanced";
+ }
+ if (state->ARB_draw_instanced_enable || state->language_version >= 140) {
/* 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.
*/
- inst = add_variable(instructions, state->symbols,
- "gl_InstanceID", glsl_type::int_type,
- ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);
+ ir_variable *inst =
+ add_variable(instructions, state->symbols,
+ "gl_InstanceID", glsl_type::int_type,
+ ir_var_system_value, SYSTEM_VALUE_INSTANCE_ID);
- if (warn)
+ if (state->language_version < 140 && warn)
inst->warn_extension = "GL_ARB_draw_instanced";
}
}
@@ -927,9 +953,10 @@ generate_AMD_shader_stencil_export_variables(exec_list *instructions,
static void
generate_120_fs_variables(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+ struct _mesa_glsl_parse_state *state,
+ bool add_deprecated)
{
- generate_110_fs_variables(instructions, state);
+ generate_110_fs_variables(instructions, state, add_deprecated);
for (unsigned i = 0
; i < Elements(builtin_120_fs_variables)
@@ -940,13 +967,9 @@ generate_120_fs_variables(exec_list *instructions,
}
static void
-generate_130_fs_variables(exec_list *instructions,
- struct _mesa_glsl_parse_state *state)
+generate_fs_clipdistance(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
{
- generate_120_fs_variables(instructions, state);
-
- generate_130_uniforms(instructions, state);
-
/* From the GLSL 1.30 spec, section 7.2 (Fragment Shader Special
* Variables):
*
@@ -968,6 +991,27 @@ generate_130_fs_variables(exec_list *instructions,
}
static void
+generate_130_fs_variables(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ generate_120_fs_variables(instructions, state, true);
+
+ generate_130_uniforms(instructions, state);
+ generate_fs_clipdistance(instructions, state);
+}
+
+
+static void
+generate_140_fs_variables(exec_list *instructions,
+ struct _mesa_glsl_parse_state *state)
+{
+ generate_120_fs_variables(instructions, state, false);
+
+ generate_130_uniforms(instructions, state);
+ generate_fs_clipdistance(instructions, state);
+}
+
+static void
initialize_fs_variables(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
{
@@ -977,14 +1021,17 @@ initialize_fs_variables(exec_list *instructions,
generate_100ES_fs_variables(instructions, state);
break;
case 110:
- generate_110_fs_variables(instructions, state);
+ generate_110_fs_variables(instructions, state, true);
break;
case 120:
- generate_120_fs_variables(instructions, state);
+ generate_120_fs_variables(instructions, state, true);
break;
case 130:
generate_130_fs_variables(instructions, state);
break;
+ case 140:
+ generate_140_fs_variables(instructions, state);
+ break;
}
if (state->ARB_shader_stencil_export_enable)
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index d5e85abc0..64506b635 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -264,6 +264,9 @@ version_statement:
case 130:
supported = state->Const.GLSL_130;
break;
+ case 140:
+ supported = state->Const.GLSL_140;
+ break;
default:
supported = false;
break;
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 2a72ba1f6..21c3c6ec2 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -94,6 +94,8 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
&& (ctx->Const.GLSLVersion >= 120);
this->Const.GLSL_130 = (ctx->API == API_OPENGL)
&& (ctx->Const.GLSLVersion >= 130);
+ this->Const.GLSL_140 = (ctx->API == API_OPENGL)
+ && (ctx->Const.GLSLVersion >= 140);
const unsigned lowest_version =
(ctx->API == API_OPENGLES2) || ctx->Extensions.ARB_ES2_compatibility
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index ce207ecda..1d9409056 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -136,6 +136,7 @@ struct _mesa_glsl_parse_state {
unsigned GLSL_110:1;
unsigned GLSL_120:1;
unsigned GLSL_130:1;
+ unsigned GLSL_140:1;
/*@}*/
} Const;
diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp
index 1489aae6d..069ebd10d 100644
--- a/mesalib/src/glsl/glsl_types.cpp
+++ b/mesalib/src/glsl/glsl_types.cpp
@@ -169,7 +169,7 @@ glsl_type::generate_100ES_types(glsl_symbol_table *symtab)
}
void
-glsl_type::generate_110_types(glsl_symbol_table *symtab)
+glsl_type::generate_110_types(glsl_symbol_table *symtab, bool add_deprecated)
{
generate_100ES_types(symtab);
@@ -177,16 +177,18 @@ glsl_type::generate_110_types(glsl_symbol_table *symtab)
Elements(builtin_110_types),
false);
add_types_to_symbol_table(symtab, &_sampler3D_type, 1, false);
- add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,
- Elements(builtin_110_deprecated_structure_types),
- false);
+ if (add_deprecated) {
+ add_types_to_symbol_table(symtab, builtin_110_deprecated_structure_types,
+ Elements(builtin_110_deprecated_structure_types),
+ false);
+ }
}
void
-glsl_type::generate_120_types(glsl_symbol_table *symtab)
+glsl_type::generate_120_types(glsl_symbol_table *symtab, bool add_deprecated)
{
- generate_110_types(symtab);
+ generate_110_types(symtab, add_deprecated);
add_types_to_symbol_table(symtab, builtin_120_types,
Elements(builtin_120_types), false);
@@ -194,9 +196,9 @@ glsl_type::generate_120_types(glsl_symbol_table *symtab)
void
-glsl_type::generate_130_types(glsl_symbol_table *symtab)
+glsl_type::generate_130_types(glsl_symbol_table *symtab, bool add_deprecated)
{
- generate_120_types(symtab);
+ generate_120_types(symtab, add_deprecated);
add_types_to_symbol_table(symtab, builtin_130_types,
Elements(builtin_130_types), false);
@@ -205,6 +207,16 @@ glsl_type::generate_130_types(glsl_symbol_table *symtab)
void
+glsl_type::generate_140_types(glsl_symbol_table *symtab)
+{
+ generate_130_types(symtab, false);
+
+ add_types_to_symbol_table(symtab, builtin_140_types,
+ Elements(builtin_140_types), false);
+}
+
+
+void
glsl_type::generate_ARB_texture_rectangle_types(glsl_symbol_table *symtab,
bool warn)
{
@@ -249,20 +261,24 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
glsl_type::generate_100ES_types(state->symbols);
break;
case 110:
- glsl_type::generate_110_types(state->symbols);
+ glsl_type::generate_110_types(state->symbols, true);
break;
case 120:
- glsl_type::generate_120_types(state->symbols);
+ glsl_type::generate_120_types(state->symbols, true);
break;
case 130:
- glsl_type::generate_130_types(state->symbols);
+ glsl_type::generate_130_types(state->symbols, true);
+ break;
+ case 140:
+ glsl_type::generate_140_types(state->symbols);
break;
default:
/* error */
break;
}
- if (state->ARB_texture_rectangle_enable) {
+ if (state->ARB_texture_rectangle_enable ||
+ state->language_version >= 140) {
glsl_type::generate_ARB_texture_rectangle_types(state->symbols,
state->ARB_texture_rectangle_warn);
}
diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h
index 2997c9311..48d41d7f8 100644
--- a/mesalib/src/glsl/glsl_types.h
+++ b/mesalib/src/glsl/glsl_types.h
@@ -498,6 +498,7 @@ private:
static const glsl_type builtin_110_types[];
static const glsl_type builtin_120_types[];
static const glsl_type builtin_130_types[];
+ static const glsl_type builtin_140_types[];
static const glsl_type builtin_ARB_texture_rectangle_types[];
static const glsl_type builtin_EXT_texture_array_types[];
static const glsl_type builtin_EXT_texture_buffer_object_types[];
@@ -514,9 +515,10 @@ private:
*/
/*@{*/
static void generate_100ES_types(glsl_symbol_table *);
- static void generate_110_types(glsl_symbol_table *);
- static void generate_120_types(glsl_symbol_table *);
- static void generate_130_types(glsl_symbol_table *);
+ static void generate_110_types(glsl_symbol_table *, bool add_deprecated);
+ static void generate_120_types(glsl_symbol_table *, bool add_deprecated);
+ static void generate_130_types(glsl_symbol_table *, bool add_deprecated);
+ static void generate_140_types(glsl_symbol_table *);
static void generate_ARB_texture_rectangle_types(glsl_symbol_table *, bool);
static void generate_EXT_texture_array_types(glsl_symbol_table *, bool);
static void generate_OES_texture_3D_types(glsl_symbol_table *, bool);
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 82bddb003..8278e43ad 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -258,11 +258,36 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
if (shader == NULL)
return true;
- find_assignment_visitor find("gl_Position");
- find.run(shader->ir);
- if (!find.variable_found()) {
- linker_error(prog, "vertex shader does not write to `gl_Position'\n");
- return false;
+ /* From the GLSL 1.10 spec, page 48:
+ *
+ * "The variable gl_Position is available only in the vertex
+ * language and is intended for writing the homogeneous vertex
+ * position. All executions of a well-formed vertex shader
+ * executable must write a value into this variable. [...] The
+ * variable gl_Position is available only in the vertex
+ * language and is intended for writing the homogeneous vertex
+ * position. All executions of a well-formed vertex shader
+ * executable must write a value into this variable."
+ *
+ * while in GLSL 1.40 this text is changed to:
+ *
+ * "The variable gl_Position is available only in the vertex
+ * language and is intended for writing the homogeneous vertex
+ * position. It can be written at any time during shader
+ * execution. It may also be read back by a vertex shader
+ * after being written. This value will be used by primitive
+ * assembly, clipping, culling, and other fixed functionality
+ * operations, if present, that operate on primitives after
+ * vertex processing has occurred. Its value is undefined if
+ * the vertex shader executable does not write gl_Position."
+ */
+ if (prog->Version < 140) {
+ find_assignment_visitor find("gl_Position");
+ find.run(shader->ir);
+ if (!find.variable_found()) {
+ linker_error(prog, "vertex shader does not write to `gl_Position'\n");
+ return false;
+ }
}
prog->Vert.ClipDistanceArraySize = 0;
@@ -2175,7 +2200,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
* of all shaders must match.
*/
assert(min_version >= 100);
- assert(max_version <= 130);
+ assert(max_version <= 140);
if ((max_version >= 130 || min_version == 100)
&& min_version != max_version) {
linker_error(prog, "all shaders must use same shading "
@@ -2269,7 +2294,9 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
if (ctx->ShaderCompilerOptions[i].LowerClipDistance)
lower_clip_distance(prog->_LinkedShaders[i]->ir);
- while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false, 32))
+ unsigned max_unroll = ctx->ShaderCompilerOptions[i].MaxUnrollIterations;
+
+ while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false, max_unroll))
;
}
diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp
index 519abb5b5..f04a146e8 100644
--- a/mesalib/src/glsl/main.cpp
+++ b/mesalib/src/glsl/main.cpp
@@ -46,10 +46,10 @@ initialize_context(struct gl_context *ctx, gl_api api)
{
initialize_context_to_defaults(ctx, api);
- /* GLSL 1.30 isn't fully supported, but we need to advertise 1.30 so that
- * the built-in functions for 1.30 can be built.
+ /* The standalone compiler needs to claim support for almost
+ * everything in order to compile the built-in functions.
*/
- ctx->Const.GLSLVersion = 130;
+ ctx->Const.GLSLVersion = 140;
ctx->Const.MaxClipPlanes = 8;
ctx->Const.MaxDrawBuffers = 2;