aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-01-28 07:55:57 +0100
committermarha <marha@users.sourceforge.net>2013-01-28 07:55:57 +0100
commit69c8cec54b01ed522bf10baf20da70304bac701a (patch)
treef37ea158a90ecb99d0780dfdaca14d05394fed3f /mesalib/src/mesa/main
parent06872e284da1c00ce03b234ca24aefeac64990d2 (diff)
downloadvcxsrv-69c8cec54b01ed522bf10baf20da70304bac701a.tar.gz
vcxsrv-69c8cec54b01ed522bf10baf20da70304bac701a.tar.bz2
vcxsrv-69c8cec54b01ed522bf10baf20da70304bac701a.zip
mesa mkfontscale pixman git update 28 jan 2013
mesa: 87592cff57feef29565150b9203e220b50623f30 mkfontscale: b3af8de8d25128f565c2ed2f7c63b6e4099eb84e pixman: 65fc1adb6545737058e938105ae948a3607c277c
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/extensions.c1
-rw-r--r--mesalib/src/mesa/main/getstring.c4
-rw-r--r--mesalib/src/mesa/main/imports.c86
-rw-r--r--mesalib/src/mesa/main/imports.h3
-rw-r--r--mesalib/src/mesa/main/mtypes.h28
-rw-r--r--mesalib/src/mesa/main/remap.c6
-rw-r--r--mesalib/src/mesa/main/shader_query.cpp12
-rw-r--r--mesalib/src/mesa/main/texparam.c8
-rw-r--r--mesalib/src/mesa/main/uniforms.c2
-rw-r--r--mesalib/src/mesa/main/version.c25
10 files changed, 131 insertions, 44 deletions
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 5d01ac8ea..7ae07fb5a 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -125,6 +125,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 },
{ "GL_ARB_shader_texture_lod", o(ARB_shader_texture_lod), GL, 2009 },
{ "GL_ARB_shading_language_100", o(ARB_shading_language_100), GLL, 2003 },
+ { "GL_ARB_shading_language_packing", o(ARB_shading_language_packing), GL, 2011 },
{ "GL_ARB_shadow", o(ARB_shadow), GLL, 2001 },
{ "GL_ARB_sync", o(ARB_sync), GL, 2003 },
{ "GL_ARB_texture_border_clamp", o(ARB_texture_border_clamp), GLL, 2000 },
diff --git a/mesalib/src/mesa/main/getstring.c b/mesalib/src/mesa/main/getstring.c
index 1f23cc0a4..aa3a528fd 100644
--- a/mesalib/src/mesa/main/getstring.c
+++ b/mesalib/src/mesa/main/getstring.c
@@ -74,7 +74,9 @@ shading_language_version(struct gl_context *ctx)
break;
case API_OPENGLES2:
- return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16";
+ return (ctx->Version < 30)
+ ? (const GLubyte *) "OpenGL ES GLSL ES 1.0.16"
+ : (const GLubyte *) "OpenGL ES GLSL ES 3.0";
case API_OPENGLES:
/* fall-through */
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index 76f835e0e..e6f754254 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -314,10 +314,43 @@ _mesa_bitcount_64(uint64_t n)
#endif
+/* Using C99 rounding functions for roundToEven() implementation is
+ * difficult, because round(), rint, and nearbyint() are affected by
+ * fesetenv(), which the application may have done for its own
+ * purposes. Mesa's IROUND macro is close to what we want, but it
+ * rounds away from 0 on n + 0.5.
+ */
+int
+_mesa_round_to_even(float val)
+{
+ int rounded = IROUND(val);
+
+ if (val - floor(val) == 0.5) {
+ if (rounded % 2 != 0)
+ rounded += val > 0 ? -1 : 1;
+ }
+
+ return rounded;
+}
+
+
/**
* Convert a 4-byte float to a 2-byte half float.
- * Based on code from:
- * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
+ *
+ * Not all float32 values can be represented exactly as a float16 value. We
+ * round such intermediate float32 values to the nearest float16. When the
+ * float32 lies exactly between to float16 values, we round to the one with
+ * an even mantissa.
+ *
+ * This rounding behavior has several benefits:
+ * - It has no sign bias.
+ *
+ * - It reproduces the behavior of real hardware: opcode F32TO16 in Intel's
+ * GPU ISA.
+ *
+ * - By reproducing the behavior of the GPU (at least on Intel hardware),
+ * compile-time evaluation of constant packHalf2x16 GLSL expressions will
+ * result in the same value as if the expression were executed on the GPU.
*/
GLhalfARB
_mesa_float_to_half(float val)
@@ -356,32 +389,13 @@ _mesa_float_to_half(float val)
else {
/* regular number */
const int new_exp = flt_e - 127;
- if (new_exp < -24) {
- /* this maps to 0 */
- /* m = 0; - already set */
- e = 0;
- }
- else if (new_exp < -14) {
- /* this maps to a denorm */
- unsigned int exp_val = (unsigned int) (-14 - new_exp); /* 2^-exp_val*/
+ if (new_exp < -14) {
+ /* The float32 lies in the range (0.0, min_normal16) and is rounded
+ * to a nearby float16 value. The result will be either zero, subnormal,
+ * or normal.
+ */
e = 0;
- switch (exp_val) {
- case 0:
- _mesa_warning(NULL,
- "float_to_half: logical error in denorm creation!\n");
- /* m = 0; - already set */
- break;
- case 1: m = 512 + (flt_m >> 14); break;
- case 2: m = 256 + (flt_m >> 15); break;
- case 3: m = 128 + (flt_m >> 16); break;
- case 4: m = 64 + (flt_m >> 17); break;
- case 5: m = 32 + (flt_m >> 18); break;
- case 6: m = 16 + (flt_m >> 19); break;
- case 7: m = 8 + (flt_m >> 20); break;
- case 8: m = 4 + (flt_m >> 21); break;
- case 9: m = 2 + (flt_m >> 22); break;
- case 10: m = 1; break;
- }
+ m = _mesa_round_to_even((1 << 24) * fabsf(fi.f));
}
else if (new_exp > 15) {
/* map this value to infinity */
@@ -389,12 +403,26 @@ _mesa_float_to_half(float val)
e = 31;
}
else {
- /* regular */
+ /* The float32 lies in the range
+ * [min_normal16, max_normal16 + max_step16)
+ * and is rounded to a nearby float16 value. The result will be
+ * either normal or infinite.
+ */
e = new_exp + 15;
- m = flt_m >> 13;
+ m = _mesa_round_to_even(flt_m / (float) (1 << 13));
}
}
+ assert(0 <= m && m <= 1024);
+ if (m == 1024) {
+ /* The float32 was rounded upwards into the range of the next exponent,
+ * so bump the exponent. This correctly handles the case where f32
+ * should be rounded up to float16 infinity.
+ */
+ ++e;
+ m = 0;
+ }
+
result = (s << 15) | (e << 10) | m;
return result;
}
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index 8446ea2a3..4b783818b 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -548,6 +548,9 @@ _mesa_fls(unsigned int n)
#endif
}
+extern int
+_mesa_round_to_even(float val);
+
extern GLhalfARB
_mesa_float_to_half(float f);
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index d37e6c4c0..3369623f7 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2273,11 +2273,30 @@ typedef enum
struct gl_uniform_buffer_variable
{
char *Name;
+
+ /**
+ * Name of the uniform as seen by glGetUniformIndices.
+ *
+ * glGetUniformIndices requires that the block instance index \b not be
+ * present in the name of queried uniforms.
+ *
+ * \note
+ * \c gl_uniform_buffer_variable::IndexName and
+ * \c gl_uniform_buffer_variable::Name may point to identical storage.
+ */
+ char *IndexName;
+
const struct glsl_type *Type;
unsigned int Offset;
GLboolean RowMajor;
};
+enum gl_uniform_block_packing {
+ ubo_packing_std140,
+ ubo_packing_shared,
+ ubo_packing_packed
+};
+
struct gl_uniform_block
{
/** Declared name of the uniform block */
@@ -2299,6 +2318,14 @@ struct gl_uniform_block
* (GL_UNIFORM_BLOCK_DATA_SIZE).
*/
GLuint UniformBufferSize;
+
+ /**
+ * Layout specified in the shader
+ *
+ * This isn't accessible through the API, but it is used while
+ * cross-validating uniform blocks.
+ */
+ enum gl_uniform_block_packing _Packing;
};
/**
@@ -3042,6 +3069,7 @@ struct gl_extensions
GLboolean ARB_shader_stencil_export;
GLboolean ARB_shader_texture_lod;
GLboolean ARB_shading_language_100;
+ GLboolean ARB_shading_language_packing;
GLboolean ARB_shadow;
GLboolean ARB_sync;
GLboolean ARB_texture_border_clamp;
diff --git a/mesalib/src/mesa/main/remap.c b/mesalib/src/mesa/main/remap.c
index c89fba453..a09870561 100644
--- a/mesalib/src/mesa/main/remap.c
+++ b/mesalib/src/mesa/main/remap.c
@@ -208,8 +208,10 @@ _mesa_do_init_remap_table(const char *pool,
offset = _mesa_map_function_spec(spec);
/* store the dispatch offset in the remap table */
driDispatchRemapTable[i] = offset;
- if (offset < 0)
- _mesa_warning(NULL, "failed to remap index %d", i);
+ if (offset < 0) {
+ const char *name = spec + strlen(spec) + 1;
+ _mesa_warning(NULL, "failed to remap %s", name);
+ }
}
}
diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp
index 27b1b8f56..3014a9778 100644
--- a/mesalib/src/mesa/main/shader_query.cpp
+++ b/mesalib/src/mesa/main/shader_query.cpp
@@ -106,7 +106,7 @@ _mesa_GetActiveAttrib(GLhandleARB program, GLuint desired_index,
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1)
continue;
@@ -169,7 +169,7 @@ _mesa_GetAttribLocation(GLhandleARB program, const GLcharARB * name)
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1
|| var->location < VERT_ATTRIB_GENERIC0)
continue;
@@ -197,7 +197,7 @@ _mesa_count_active_attribs(struct gl_shader_program *shProg)
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1)
continue;
@@ -223,7 +223,7 @@ _mesa_longest_attribute_name_length(struct gl_shader_program *shProg)
const ir_variable *const var = ((ir_instruction *) node)->as_variable();
if (var == NULL
- || var->mode != ir_var_in
+ || var->mode != ir_var_shader_in
|| var->location == -1)
continue;
@@ -333,7 +333,7 @@ _mesa_GetFragDataIndex(GLuint program, const GLchar *name)
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_out
+ || var->mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
continue;
@@ -389,7 +389,7 @@ _mesa_GetFragDataLocation(GLuint program, const GLchar *name)
* attribute, or if an error occurs, -1 will be returned."
*/
if (var == NULL
- || var->mode != ir_var_out
+ || var->mode != ir_var_shader_out
|| var->location == -1
|| var->location < FRAG_RESULT_DATA0)
continue;
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 8d0ae16fb..52ede13c0 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -1388,10 +1388,10 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
if (ctx->API != API_OPENGLES || !ctx->Extensions.OES_draw_texture)
goto invalid_pname;
- params[0] = obj->CropRect[0];
- params[1] = obj->CropRect[1];
- params[2] = obj->CropRect[2];
- params[3] = obj->CropRect[3];
+ params[0] = (GLfloat) obj->CropRect[0];
+ params[1] = (GLfloat) obj->CropRect[1];
+ params[2] = (GLfloat) obj->CropRect[2];
+ params[3] = (GLfloat) obj->CropRect[3];
break;
case GL_TEXTURE_SWIZZLE_R_EXT:
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index 62c85b3c0..d902407a0 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -695,7 +695,7 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
for (i = 0; i < block->NumUniforms; i++) {
unsigned offset;
params[i] = _mesa_get_uniform_location(ctx, shProg,
- block->Uniforms[i].Name,
+ block->Uniforms[i].IndexName,
&offset);
}
return;
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 4373d7b91..e944a5518 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -323,7 +323,30 @@ compute_version_es2(struct gl_context *ctx)
ctx->Extensions.ARB_fragment_shader &&
ctx->Extensions.ARB_texture_non_power_of_two &&
ctx->Extensions.EXT_blend_equation_separate);
- if (ver_2_0) {
+ /* FINISHME: This list isn't quite right. */
+ const GLboolean ver_3_0 = (ctx->Extensions.ARB_half_float_vertex &&
+ ctx->Extensions.ARB_internalformat_query &&
+ ctx->Extensions.ARB_map_buffer_range &&
+ ctx->Extensions.ARB_shader_texture_lod &&
+ ctx->Extensions.ARB_texture_float &&
+ ctx->Extensions.ARB_texture_rg &&
+ ctx->Extensions.ARB_texture_compression_rgtc &&
+ ctx->Extensions.EXT_draw_buffers2 &&
+ /* ctx->Extensions.ARB_framebuffer_object && */
+ ctx->Extensions.EXT_framebuffer_sRGB &&
+ ctx->Extensions.EXT_packed_float &&
+ ctx->Extensions.EXT_texture_array &&
+ ctx->Extensions.EXT_texture_shared_exponent &&
+ ctx->Extensions.EXT_transform_feedback &&
+ ctx->Extensions.NV_conditional_render &&
+ ctx->Extensions.ARB_draw_instanced &&
+ ctx->Extensions.ARB_uniform_buffer_object &&
+ ctx->Extensions.EXT_texture_snorm &&
+ ctx->Extensions.NV_primitive_restart &&
+ ctx->Extensions.OES_depth_texture_cube_map);
+ if (ver_3_0) {
+ ctx->Version = 30;
+ } else if (ver_2_0) {
ctx->Version = 20;
} else {
_mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");