aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r--mesalib/src/mesa/SConscript43
-rw-r--r--mesalib/src/mesa/main/context.c1
-rw-r--r--mesalib/src/mesa/main/shaderapi.c1
-rw-r--r--mesalib/src/mesa/main/version.c26
-rw-r--r--mesalib/src/mesa/main/version.h2
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp12
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_draw.c8
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c2
9 files changed, 84 insertions, 13 deletions
diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript
index ff1ffe008..abcce4133 100644
--- a/mesalib/src/mesa/SConscript
+++ b/mesalib/src/mesa/SConscript
@@ -3,6 +3,9 @@
Import('*')
+import filecmp
+import os
+import subprocess
env = env.Clone()
@@ -458,13 +461,41 @@ if env['gcc'] and env['platform'] != 'windows':
env.Append(CPPPATH = [matypes[0].dir])
-# Create the git_sha1.h file if it doesn't exist already
-try:
- f = open('main/git_sha1.h', 'r')
- f.close()
-except IOError:
- f = open('main/git_sha1.h', 'w')
+
+
+def write_git_sha1_h_file(filename):
+ """Mesa looks for a git_sha1.h file at compile time in order to display
+ the current git hash id in the GL_VERSION string. This function tries
+ to retrieve the git hashid and write the header file. An empty file
+ will be created if anything goes wrong."""
+
+ args = [ 'git', 'log', '-n', '1', '--oneline' ]
+ try:
+ (commit, foo) = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
+ except:
+ # git log command didn't work
+ if not os.path.exists(filename):
+ # create an empty file if none already exists
+ f = open(filename, "w")
+ f.close()
+ return
+
+ commit = '#define MESA_GIT_SHA1 "git-%s"\n' % commit[0:7]
+ tempfile = "git_sha1.h.tmp"
+ f = open(tempfile, "w")
+ f.write(commit)
f.close()
+ if not os.path.exists(filename) or not filecmp.cmp(tempfile, filename):
+ # The filename does not exist or it's different from the new file,
+ # so replace old file with new.
+ if os.path.exists(filename):
+ os.remove(filename)
+ os.rename(tempfile, filename)
+ return
+
+
+# Create the git_sha1.h header file
+write_git_sha1_h_file("main/git_sha1.h")
# and update CPPPATH so the git_sha1.h header can be found
env.Append(CPPPATH = ["#" + env['build_dir'] + "/mesa/main"])
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index b20063c33..2532c47de 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -627,6 +627,7 @@ _mesa_init_constants(struct gl_context *ctx)
/* Shading language version */
if (ctx->API == API_OPENGL) {
ctx->Const.GLSLVersion = 120;
+ _mesa_override_glsl_version(ctx);
}
else if (ctx->API == API_OPENGLES2) {
ctx->Const.GLSLVersion = 100;
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 74997eaaa..3ce14d154 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -137,6 +137,7 @@ _mesa_sizeof_glsl_type(GLenum type)
switch (type) {
case GL_FLOAT:
case GL_INT:
+ case GL_UNSIGNED_INT:
case GL_BOOL:
case GL_SAMPLER_1D:
case GL_SAMPLER_2D:
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index a5deeabd2..c49731747 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -44,7 +44,7 @@ override_version(struct gl_context *ctx, GLuint *major, GLuint *minor)
return;
}
- n = sscanf(version, "%d.%d", major, minor);
+ n = sscanf(version, "%u.%u", major, minor);
if (n != 2) {
fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
return;
@@ -52,6 +52,30 @@ override_version(struct gl_context *ctx, GLuint *major, GLuint *minor)
}
/**
+ * Override the context's GLSL version if the environment variable
+ * MESA_GLSL_VERSION_OVERRIDE is set. Valid values for
+ * MESA_GLSL_VERSION_OVERRIDE are integers, such as "130".
+ */
+void
+_mesa_override_glsl_version(struct gl_context *ctx)
+{
+ const char *env_var = "MESA_GLSL_VERSION_OVERRIDE";
+ const char *version;
+ int n;
+
+ version = getenv(env_var);
+ if (!version) {
+ return;
+ }
+
+ n = sscanf(version, "%u", &ctx->Const.GLSLVersion);
+ if (n != 1) {
+ fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version);
+ return;
+ }
+}
+
+/**
* Examine enabled GL extensions to determine GL version.
* Return major and minor version numbers.
*/
diff --git a/mesalib/src/mesa/main/version.h b/mesalib/src/mesa/main/version.h
index 0a0512c33..32e141f0e 100644
--- a/mesalib/src/mesa/main/version.h
+++ b/mesalib/src/mesa/main/version.h
@@ -56,5 +56,7 @@ struct gl_context;
extern void
_mesa_compute_version(struct gl_context *ctx);
+extern void
+_mesa_override_glsl_version(struct gl_context *ctx);
#endif /* VERSION_H */
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index 7b2c69fdb..c5b71b3f0 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -1456,14 +1456,22 @@ ir_to_mesa_visitor::visit(ir_expression *ir)
emit_scalar(ir, OPCODE_POW, result_dst, op[0], op[1]);
break;
- case ir_unop_bit_not:
+ /* GLSL 1.30 integer ops are unsupported in Mesa IR, but since
+ * hardware backends have no way to avoid Mesa IR generation
+ * even if they don't use it, we need to emit "something" and
+ * continue.
+ */
case ir_binop_lshift:
case ir_binop_rshift:
case ir_binop_bit_and:
case ir_binop_bit_xor:
case ir_binop_bit_or:
+ emit(ir, OPCODE_ADD, result_dst, op[0], op[1]);
+ break;
+
+ case ir_unop_bit_not:
case ir_unop_round_even:
- assert(!"GLSL 1.30 features unsupported");
+ emit(ir, OPCODE_MOV, result_dst, op[0]);
break;
case ir_quadop_vector:
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index 354e58de9..8df753f7c 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -1707,7 +1707,7 @@ st_finalize_texture(struct gl_context *ctx,
firstImage->base.Width2,
firstImage->base.Height2,
firstImage->base.Depth2,
- stObj->base.BaseLevel,
+ firstImage->base.Level,
&width, &height, &depth)) {
width = stObj->width0;
height = stObj->height0;
diff --git a/mesalib/src/mesa/state_tracker/st_draw.c b/mesalib/src/mesa/state_tracker/st_draw.c
index 39a947df7..574802084 100644
--- a/mesalib/src/mesa/state_tracker/st_draw.c
+++ b/mesalib/src/mesa/state_tracker/st_draw.c
@@ -267,8 +267,8 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
/**
- * This is very similar to vbo_all_varyings_in_vbos() but we test
- * the stride. See bug 38626.
+ * This is very similar to vbo_all_varyings_in_vbos() but we are
+ * only interested in per-vertex data. See bug 38626.
*/
static GLboolean
all_varyings_in_vbos(const struct gl_client_array *arrays[])
@@ -276,7 +276,9 @@ all_varyings_in_vbos(const struct gl_client_array *arrays[])
GLuint i;
for (i = 0; i < VERT_ATTRIB_MAX; i++)
- if (arrays[i]->StrideB && !_mesa_is_bufferobj(arrays[i]->BufferObj))
+ if (arrays[i]->StrideB &&
+ !arrays[i]->InstanceDivisor &&
+ !_mesa_is_bufferobj(arrays[i]->BufferObj))
return GL_FALSE;
return GL_TRUE;
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index ef284ad70..e6572c85a 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -30,6 +30,7 @@
#include "main/context.h"
#include "main/macros.h"
#include "main/mfeatures.h"
+#include "main/version.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
@@ -216,6 +217,7 @@ void st_init_limits(struct st_context *st)
c->MaxProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MAX_TEXEL_OFFSET);
c->GLSLVersion = 120;
+ _mesa_override_glsl_version(st->ctx);
c->UniformBooleanTrue = ~0;
}
}