aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/arbprogram.c46
-rw-r--r--mesalib/src/mesa/main/clear.c8
-rw-r--r--mesalib/src/mesa/main/condrender.c41
-rw-r--r--mesalib/src/mesa/main/config.h3
-rw-r--r--mesalib/src/mesa/main/context.c46
-rw-r--r--mesalib/src/mesa/main/dd.h20
-rw-r--r--mesalib/src/mesa/main/extensions.c6
-rw-r--r--mesalib/src/mesa/main/fbobject.c50
-rw-r--r--mesalib/src/mesa/main/ff_fragment_shader.cpp2
-rw-r--r--mesalib/src/mesa/main/ffvertex_prog.c2
-rw-r--r--mesalib/src/mesa/main/format_pack.c57
-rw-r--r--mesalib/src/mesa/main/format_unpack.c61
-rw-r--r--mesalib/src/mesa/main/formats.c74
-rw-r--r--mesalib/src/mesa/main/formats.h8
-rw-r--r--mesalib/src/mesa/main/get.c125
-rw-r--r--mesalib/src/mesa/main/get_hash_params.py62
-rw-r--r--mesalib/src/mesa/main/mtypes.h157
-rw-r--r--mesalib/src/mesa/main/scissor.c2
-rw-r--r--mesalib/src/mesa/main/shader_query.cpp2
-rw-r--r--mesalib/src/mesa/main/shaderapi.c18
-rw-r--r--mesalib/src/mesa/main/shaderapi.h2
-rw-r--r--mesalib/src/mesa/main/shaderimage.c488
-rw-r--r--mesalib/src/mesa/main/shaderimage.h51
-rw-r--r--mesalib/src/mesa/main/shaderobj.c5
-rw-r--r--mesalib/src/mesa/main/shaderobj.h6
-rw-r--r--mesalib/src/mesa/main/texcompress.c37
-rw-r--r--mesalib/src/mesa/main/texenv.c8
-rw-r--r--mesalib/src/mesa/main/teximage.c87
-rw-r--r--mesalib/src/mesa/main/teximage.h6
-rw-r--r--mesalib/src/mesa/main/texobj.c26
-rw-r--r--mesalib/src/mesa/main/texparam.c6
-rw-r--r--mesalib/src/mesa/main/texstate.c3
-rw-r--r--mesalib/src/mesa/main/texstore.c107
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp6
-rw-r--r--mesalib/src/mesa/main/uniforms.c4
-rw-r--r--mesalib/src/mesa/main/varray.c24
-rw-r--r--mesalib/src/mesa/main/version.c2
-rw-r--r--mesalib/src/mesa/main/viewport.c4
38 files changed, 1463 insertions, 199 deletions
diff --git a/mesalib/src/mesa/main/arbprogram.c b/mesalib/src/mesa/main/arbprogram.c
index 8bd3f0bd0..247b49253 100644
--- a/mesalib/src/mesa/main/arbprogram.c
+++ b/mesalib/src/mesa/main/arbprogram.c
@@ -247,12 +247,12 @@ get_local_param_pointer(struct gl_context *ctx, const char *func,
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
prog = &(ctx->VertexProgram.Current->Base);
- maxParams = ctx->Const.VertexProgram.MaxLocalParams;
+ maxParams = ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams;
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
prog = &(ctx->FragmentProgram.Current->Base);
- maxParams = ctx->Const.FragmentProgram.MaxLocalParams;
+ maxParams = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams;
}
else {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -282,7 +282,7 @@ get_env_param_pointer(struct gl_context *ctx, const char *func,
{
if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
- if (index >= ctx->Const.FragmentProgram.MaxEnvParams) {
+ if (index >= ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
return GL_FALSE;
}
@@ -291,7 +291,7 @@ get_env_param_pointer(struct gl_context *ctx, const char *func,
}
else if (target == GL_VERTEX_PROGRAM_ARB &&
ctx->Extensions.ARB_vertex_program) {
- if (index >= ctx->Const.VertexProgram.MaxEnvParams) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
return GL_FALSE;
}
@@ -436,7 +436,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
- if ((index + count) > ctx->Const.FragmentProgram.MaxEnvParams) {
+ if ((index + count) > ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(index + count)");
return;
}
@@ -444,7 +444,7 @@ _mesa_ProgramEnvParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
}
else if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
- if ((index + count) > ctx->Const.VertexProgram.MaxEnvParams) {
+ if ((index + count) > ctx->Const.Program[MESA_SHADER_VERTEX].MaxEnvParams) {
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameters4fv(index + count)");
return;
}
@@ -527,28 +527,20 @@ _mesa_ProgramLocalParameters4fvEXT(GLenum target, GLuint index, GLsizei count,
_mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fv(count)");
}
- if (target == GL_FRAGMENT_PROGRAM_ARB
- && ctx->Extensions.ARB_fragment_program) {
- if ((index + count) > ctx->Const.FragmentProgram.MaxLocalParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)");
- return;
- }
- dest = ctx->FragmentProgram.Current->Base.LocalParams[index];
- }
- else if (target == GL_VERTEX_PROGRAM_ARB
- && ctx->Extensions.ARB_vertex_program) {
- if ((index + count) > ctx->Const.VertexProgram.MaxLocalParams) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameters4fvEXT(index + count)");
+ if (get_local_param_pointer(ctx, "glProgramLocalParameters4fvEXT",
+ target, index, &dest)) {
+ GLuint maxParams = target == GL_FRAGMENT_PROGRAM_ARB ?
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams :
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams;
+
+ if ((index + count) > maxParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glProgramLocalParameters4fvEXT(index + count)");
return;
}
- dest = ctx->VertexProgram.Current->Base.LocalParams[index];
- }
- else {
- _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameters4fvEXT(target)");
- return;
- }
- memcpy(dest, params, count * 4 * sizeof(GLfloat));
+ memcpy(dest, params, count * 4 * sizeof(GLfloat));
+ }
}
@@ -610,12 +602,12 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
if (target == GL_VERTEX_PROGRAM_ARB
&& ctx->Extensions.ARB_vertex_program) {
prog = &(ctx->VertexProgram.Current->Base);
- limits = &ctx->Const.VertexProgram;
+ limits = &ctx->Const.Program[MESA_SHADER_VERTEX];
}
else if (target == GL_FRAGMENT_PROGRAM_ARB
&& ctx->Extensions.ARB_fragment_program) {
prog = &(ctx->FragmentProgram.Current->Base);
- limits = &ctx->Const.FragmentProgram;
+ limits = &ctx->Const.Program[MESA_SHADER_FRAGMENT];
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c
index f0b525fa0..077c5fca3 100644
--- a/mesalib/src/mesa/main/clear.c
+++ b/mesalib/src/mesa/main/clear.c
@@ -179,7 +179,11 @@ _mesa_Clear( GLbitfield mask )
if (mask & GL_COLOR_BUFFER_BIT) {
GLuint i;
for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- bufferMask |= (1 << ctx->DrawBuffer->_ColorDrawBufferIndexes[i]);
+ GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[i];
+
+ if (buf >= 0) {
+ bufferMask |= 1 << buf;
+ }
}
}
@@ -274,7 +278,7 @@ make_color_buffer_mask(struct gl_context *ctx, GLint drawbuffer)
break;
default:
{
- GLuint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[drawbuffer];
+ GLint buf = ctx->DrawBuffer->_ColorDrawBufferIndexes[drawbuffer];
if (buf >= 0 && att[buf].Renderbuffer) {
mask |= 1 << buf;
diff --git a/mesalib/src/mesa/main/condrender.c b/mesalib/src/mesa/main/condrender.c
index 2632f7a1a..0ad1e5c2a 100644
--- a/mesalib/src/mesa/main/condrender.c
+++ b/mesalib/src/mesa/main/condrender.c
@@ -40,17 +40,38 @@
void GLAPIENTRY
_mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
{
- struct gl_query_object *q;
+ struct gl_query_object *q = NULL;
GET_CURRENT_CONTEXT(ctx);
- if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery ||
- queryId == 0) {
+ /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says:
+ *
+ * "If BeginConditionalRender is called while conditional rendering is
+ * in progress, or if EndConditionalRender is called while conditional
+ * rendering is not in progress, the error INVALID_OPERATION is
+ * generated."
+ */
+ if (!ctx->Extensions.NV_conditional_render || ctx->Query.CondRenderQuery) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glBeginConditionalRender()");
return;
}
ASSERT(ctx->Query.CondRenderMode == GL_NONE);
+ /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says:
+ *
+ * "The error INVALID_VALUE is generated if <id> is not the name of an
+ * existing query object query."
+ */
+ if (queryId != 0)
+ q = _mesa_lookup_query_object(ctx, queryId);
+
+ if (!q) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glBeginConditionalRender(bad queryId=%u)", queryId);
+ return;
+ }
+ ASSERT(q->Id == queryId);
+
switch (mode) {
case GL_QUERY_WAIT:
case GL_QUERY_NO_WAIT:
@@ -64,14 +85,12 @@ _mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
return;
}
- q = _mesa_lookup_query_object(ctx, queryId);
- if (!q) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glBeginConditionalRender(bad queryId=%u)", queryId);
- return;
- }
- ASSERT(q->Id == queryId);
-
+ /* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says:
+ *
+ * "The error INVALID_OPERATION is generated if <id> is the name of a
+ * query object with a target other than SAMPLES_PASSED, or <id> is the
+ * name of a query currently in progress."
+ */
if ((q->Target != GL_SAMPLES_PASSED &&
q->Target != GL_ANY_SAMPLES_PASSED &&
q->Target != GL_ANY_SAMPLES_PASSED_CONSERVATIVE) || q->Active) {
diff --git a/mesalib/src/mesa/main/config.h b/mesalib/src/mesa/main/config.h
index ebf99c24b..1e1cfb6c5 100644
--- a/mesalib/src/mesa/main/config.h
+++ b/mesalib/src/mesa/main/config.h
@@ -179,6 +179,9 @@
#define MAX_COMBINED_ATOMIC_BUFFERS (MAX_UNIFORM_BUFFERS * 6)
/* Size of an atomic counter in bytes according to ARB_shader_atomic_counters */
#define ATOMIC_COUNTER_SIZE 4
+#define MAX_IMAGE_UNIFORMS 16
+/* 6 is for vertex, hull, domain, geometry, fragment, and compute shader. */
+#define MAX_IMAGE_UNITS (MAX_IMAGE_UNIFORMS * 6)
/*@}*/
/**
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 4db27da9a..4f7bdbdbc 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -461,7 +461,7 @@ _mesa_init_current(struct gl_context *ctx)
* Important: drivers should override these with actual limits.
*/
static void
-init_program_limits(struct gl_context *ctx, GLenum type,
+init_program_limits(struct gl_context *ctx, gl_shader_stage stage,
struct gl_program_constants *prog)
{
prog->MaxInstructions = MAX_PROGRAM_INSTRUCTIONS;
@@ -473,8 +473,8 @@ init_program_limits(struct gl_context *ctx, GLenum type,
prog->MaxLocalParams = MAX_PROGRAM_LOCAL_PARAMS;
prog->MaxAddressOffset = MAX_PROGRAM_LOCAL_PARAMS;
- switch (type) {
- case GL_VERTEX_PROGRAM_ARB:
+ switch (stage) {
+ case MESA_SHADER_VERTEX:
prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
prog->MaxAttribs = MAX_VERTEX_GENERIC_ATTRIBS;
prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
@@ -482,7 +482,7 @@ init_program_limits(struct gl_context *ctx, GLenum type,
prog->MaxInputComponents = 0; /* value not used */
prog->MaxOutputComponents = 16 * 4; /* old limit not to break tnl and swrast */
break;
- case GL_FRAGMENT_PROGRAM_ARB:
+ case MESA_SHADER_FRAGMENT:
prog->MaxParameters = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
prog->MaxAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
prog->MaxAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
@@ -490,7 +490,7 @@ init_program_limits(struct gl_context *ctx, GLenum type,
prog->MaxInputComponents = 16 * 4; /* old limit not to break tnl and swrast */
prog->MaxOutputComponents = 0; /* value not used */
break;
- case MESA_GEOMETRY_PROGRAM:
+ case MESA_SHADER_GEOMETRY:
prog->MaxParameters = MAX_VERTEX_PROGRAM_PARAMS;
prog->MaxAttribs = MAX_VERTEX_GENERIC_ATTRIBS;
prog->MaxAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
@@ -499,7 +499,7 @@ init_program_limits(struct gl_context *ctx, GLenum type,
prog->MaxOutputComponents = 16 * 4; /* old limit not to break tnl and swrast */
break;
default:
- assert(0 && "Bad program type in init_program_limits()");
+ assert(0 && "Bad shader stage in init_program_limits()");
}
/* Set the native limits to zero. This implies that there is no native
@@ -551,6 +551,7 @@ init_program_limits(struct gl_context *ctx, GLenum type,
static void
_mesa_init_constants(struct gl_context *ctx)
{
+ int i;
assert(ctx);
/* Constants, may be overriden (usually only reduced) by device drivers */
@@ -561,9 +562,9 @@ _mesa_init_constants(struct gl_context *ctx)
ctx->Const.MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE;
ctx->Const.MaxArrayTextureLayers = MAX_ARRAY_TEXTURE_LAYERS;
ctx->Const.MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS;
- ctx->Const.FragmentProgram.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureCoordUnits,
- ctx->Const.FragmentProgram.MaxTextureImageUnits);
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits);
ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
ctx->Const.MaxTextureBufferSize = 65536;
@@ -593,9 +594,8 @@ _mesa_init_constants(struct gl_context *ctx)
ctx->Const.MaxUniformBlockSize = 16384;
ctx->Const.UniformBufferOffsetAlignment = 1;
- init_program_limits(ctx, GL_VERTEX_PROGRAM_ARB, &ctx->Const.VertexProgram);
- init_program_limits(ctx, GL_FRAGMENT_PROGRAM_ARB, &ctx->Const.FragmentProgram);
- init_program_limits(ctx, MESA_GEOMETRY_PROGRAM, &ctx->Const.GeometryProgram);
+ for (i = 0; i < MESA_SHADER_STAGES; i++)
+ init_program_limits(ctx, i, &ctx->Const.Program[i]);
ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
@@ -609,10 +609,10 @@ _mesa_init_constants(struct gl_context *ctx)
ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS;
ctx->Const.MaxRenderbufferSize = MAX_RENDERBUFFER_SIZE;
- ctx->Const.VertexProgram.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
ctx->Const.MaxCombinedTextureImageUnits = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
ctx->Const.MaxVarying = 16; /* old limit not to break tnl and swrast */
- ctx->Const.GeometryProgram.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
ctx->Const.MaxGeometryOutputVertices = MAX_GEOMETRY_OUTPUT_VERTICES;
ctx->Const.MaxGeometryTotalOutputComponents = MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS;
@@ -699,24 +699,24 @@ check_context_limits(struct gl_context *ctx)
(8 * sizeof(ctx->FragmentProgram._Current->Base.InputsRead)));
/* shader-related checks */
- assert(ctx->Const.FragmentProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
- assert(ctx->Const.VertexProgram.MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
+ assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
+ assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams <= MAX_PROGRAM_LOCAL_PARAMS);
/* Texture unit checks */
- assert(ctx->Const.FragmentProgram.MaxTextureImageUnits > 0);
- assert(ctx->Const.FragmentProgram.MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS);
+ assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits > 0);
+ assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits <= MAX_TEXTURE_IMAGE_UNITS);
assert(ctx->Const.MaxTextureCoordUnits > 0);
assert(ctx->Const.MaxTextureCoordUnits <= MAX_TEXTURE_COORD_UNITS);
assert(ctx->Const.MaxTextureUnits > 0);
assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_IMAGE_UNITS);
assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_COORD_UNITS);
- assert(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.FragmentProgram.MaxTextureImageUnits,
+ assert(ctx->Const.MaxTextureUnits == MIN2(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits,
ctx->Const.MaxTextureCoordUnits));
assert(ctx->Const.MaxCombinedTextureImageUnits > 0);
assert(ctx->Const.MaxCombinedTextureImageUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS);
assert(ctx->Const.MaxTextureCoordUnits <= MAX_COMBINED_TEXTURE_IMAGE_UNITS);
/* number of coord units cannot be greater than number of image units */
- assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.FragmentProgram.MaxTextureImageUnits);
+ assert(ctx->Const.MaxTextureCoordUnits <= ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits);
/* Texture size checks */
@@ -1851,14 +1851,14 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
#ifdef DEBUG
if (ctx->Shader.Flags & GLSL_LOG) {
- struct gl_shader_program *shProg[MESA_SHADER_TYPES];
- gl_shader_type i;
+ struct gl_shader_program *shProg[MESA_SHADER_STAGES];
+ gl_shader_stage i;
shProg[MESA_SHADER_VERTEX] = ctx->Shader.CurrentVertexProgram;
shProg[MESA_SHADER_GEOMETRY] = ctx->Shader.CurrentGeometryProgram;
shProg[MESA_SHADER_FRAGMENT] = ctx->Shader.CurrentFragmentProgram;
- for (i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
if (shProg[i] == NULL || shProg[i]->_Used
|| shProg[i]->_LinkedShaders[i] == NULL)
continue;
@@ -1875,7 +1875,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
_mesa_append_uniforms_to_file(shProg[i]->_LinkedShaders[i]);
}
- for (i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
if (shProg[i] != NULL)
shProg[i]->_Used = GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 6e73691ea..6c084afa3 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -39,6 +39,7 @@ struct gl_buffer_object;
struct gl_context;
struct gl_display_list;
struct gl_framebuffer;
+struct gl_image_unit;
struct gl_pixelstore_attrib;
struct gl_program;
struct gl_renderbuffer;
@@ -484,7 +485,7 @@ struct dd_function_table {
/** Enable or disable writing into the depth buffer */
void (*DepthMask)(struct gl_context *ctx, GLboolean flag);
/** Specify mapping of depth values from NDC to window coordinates */
- void (*DepthRange)(struct gl_context *ctx, GLclampd nearval, GLclampd farval);
+ void (*DepthRange)(struct gl_context *ctx);
/** Specify the current buffer for writing */
void (*DrawBuffer)( struct gl_context *ctx, GLenum buffer );
/** Specify the buffers for writing for fragment programs*/
@@ -524,7 +525,7 @@ struct dd_function_table {
/** Set rasterization mode */
void (*RenderMode)(struct gl_context *ctx, GLenum mode );
/** Define the scissor box */
- void (*Scissor)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+ void (*Scissor)(struct gl_context *ctx);
/** Select flat or smooth shading */
void (*ShadeModel)(struct gl_context *ctx, GLenum mode);
/** OpenGL 2.0 two-sided StencilFunc */
@@ -546,7 +547,7 @@ struct dd_function_table {
struct gl_texture_object *texObj,
GLenum pname, const GLfloat *params);
/** Set the viewport */
- void (*Viewport)(struct gl_context *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+ void (*Viewport)(struct gl_context *ctx);
/*@}*/
@@ -910,6 +911,19 @@ struct dd_function_table {
* non-zero status should be returned for the duration of the reset.
*/
GLenum (*GetGraphicsResetStatus)(struct gl_context *ctx);
+
+ /**
+ * \name GL_ARB_shader_image_load_store interface.
+ */
+ /** @{ */
+ void (*BindImageTexture)(struct gl_context *ctx,
+ struct gl_image_unit *unit,
+ struct gl_texture_object *texObj,
+ GLint level, GLboolean layered, GLint layer,
+ GLenum access, GLenum format);
+
+ void (*MemoryBarrier)(struct gl_context *ctx, GLbitfield barriers);
+ /** @} */
};
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index f0e1858e4..2e0ccc3b6 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -126,6 +126,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_seamless_cube_map", o(ARB_seamless_cube_map), GL, 2009 },
{ "GL_ARB_shader_atomic_counters", o(ARB_shader_atomic_counters), GL, 2011 },
{ "GL_ARB_shader_bit_encoding", o(ARB_shader_bit_encoding), GL, 2010 },
+ { "GL_ARB_shader_image_load_store", o(ARB_shader_image_load_store), GL, 2011 },
{ "GL_ARB_shader_objects", o(dummy_true), GL, 2002 },
{ "GL_ARB_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 },
{ "GL_ARB_shader_texture_lod", o(ARB_shader_texture_lod), GL, 2009 },
@@ -304,6 +305,7 @@ static const struct extension extension_table[] = {
{ "GL_AMD_performance_monitor", o(AMD_performance_monitor), GL, 2007 },
{ "GL_AMD_seamless_cubemap_per_texture", o(AMD_seamless_cubemap_per_texture), GL, 2009 },
{ "GL_AMD_shader_stencil_export", o(ARB_shader_stencil_export), GL, 2009 },
+ { "GL_AMD_shader_trinary_minmax", o(dummy_true), GL, 2012 },
{ "GL_AMD_vertex_shader_layer", o(AMD_vertex_shader_layer), GLC, 2012 },
{ "GL_APPLE_object_purgeable", o(APPLE_object_purgeable), GL, 2006 },
{ "GL_APPLE_packed_pixels", o(dummy_true), GLL, 2002 },
@@ -396,10 +398,6 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)
ctx->Extensions.ARB_fragment_program_shadow = GL_TRUE;
ctx->Extensions.ARB_fragment_shader = GL_TRUE;
ctx->Extensions.ARB_framebuffer_object = GL_TRUE;
- /* XXX re-enable when GLSL compiler again supports geometry shaders */
-#if 0
- ctx->Extensions.ARB_geometry_shader4 = GL_TRUE;
-#endif
ctx->Extensions.ARB_half_float_pixel = GL_TRUE;
ctx->Extensions.ARB_half_float_vertex = GL_TRUE;
ctx->Extensions.ARB_map_buffer_range = GL_TRUE;
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 2892784f8..dc7184ad4 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -877,8 +877,11 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
GLint fixedSampleLocations = -1;
GLint i;
GLuint j;
- bool layer_count_valid = false;
- GLuint layer_count = 0, att_layer_count;
+ /* Covers max_layer_count, is_layered, and layer_tex_target */
+ bool layer_info_valid = false;
+ GLuint max_layer_count = 0, att_layer_count;
+ bool is_layered;
+ GLenum layer_tex_target = 0;
assert(_mesa_is_user_fbo(fb));
@@ -1062,22 +1065,25 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
} else {
att_layer_count = 0;
}
- if (!layer_count_valid) {
- layer_count = att_layer_count;
- layer_count_valid = true;
- } else if (layer_count != att_layer_count) {
- if (layer_count == 0 || att_layer_count == 0) {
- fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
- fbo_incomplete(ctx, "framebuffer attachment layer mode is inconsistent", i);
- } else {
- fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB;
- fbo_incomplete(ctx, "framebuffer attachment layer count is inconsistent", i);
- }
+ if (!layer_info_valid) {
+ is_layered = att->Layered;
+ max_layer_count = att_layer_count;
+ layer_tex_target = att_tex_target;
+ layer_info_valid = true;
+ } else if (max_layer_count > 0 && layer_tex_target != att_tex_target) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
+ fbo_incomplete(ctx, "layered framebuffer has mismatched targets", i);
+ return;
+ } else if (is_layered != att->Layered) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS;
+ fbo_incomplete(ctx, "framebuffer attachment layer mode is inconsistent", i);
return;
+ } else if (att_layer_count > max_layer_count) {
+ max_layer_count = att_layer_count;
}
}
- fb->NumLayers = layer_count;
+ fb->MaxNumLayers = max_layer_count;
if (_mesa_is_desktop_gl(ctx) && !ctx->Extensions.ARB_ES2_compatibility) {
/* Check that all DrawBuffers are present */
@@ -1504,6 +1510,22 @@ _mesa_base_fbo_format(struct gl_context *ctx, GLenum internalFormat)
return ctx->API == API_OPENGL_COMPAT &&
ctx->Extensions.EXT_texture_snorm &&
ctx->Extensions.ARB_framebuffer_object ? GL_ALPHA : 0;
+ case GL_LUMINANCE_SNORM:
+ case GL_LUMINANCE8_SNORM:
+ case GL_LUMINANCE16_SNORM:
+ return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm
+ ? GL_LUMINANCE : 0;
+ case GL_LUMINANCE_ALPHA_SNORM:
+ case GL_LUMINANCE8_ALPHA8_SNORM:
+ case GL_LUMINANCE16_ALPHA16_SNORM:
+ return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm
+ ? GL_LUMINANCE_ALPHA : 0;
+ case GL_INTENSITY_SNORM:
+ case GL_INTENSITY8_SNORM:
+ case GL_INTENSITY16_SNORM:
+ return _mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_texture_snorm
+ ? GL_INTENSITY : 0;
+
case GL_R16F:
case GL_R32F:
return ((_mesa_is_desktop_gl(ctx) &&
diff --git a/mesalib/src/mesa/main/ff_fragment_shader.cpp b/mesalib/src/mesa/main/ff_fragment_shader.cpp
index ba6258d89..00ca02558 100644
--- a/mesalib/src/mesa/main/ff_fragment_shader.cpp
+++ b/mesalib/src/mesa/main/ff_fragment_shader.cpp
@@ -1296,7 +1296,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
p.mem_ctx = ralloc_context(NULL);
p.shader = ctx->Driver.NewShader(ctx, 0, GL_FRAGMENT_SHADER);
p.shader->ir = new(p.shader) exec_list;
- state = new(p.shader) _mesa_glsl_parse_state(ctx, GL_FRAGMENT_SHADER,
+ state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT,
p.shader);
p.shader->symbols = state->symbols;
p.top_instructions = p.shader->ir;
diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c
index 074fbf9a3..808ea9cbd 100644
--- a/mesalib/src/mesa/main/ffvertex_prog.c
+++ b/mesalib/src/mesa/main/ffvertex_prog.c
@@ -1677,7 +1677,7 @@ _mesa_get_fixed_func_vertex_program(struct gl_context *ctx)
create_new_program( &key, prog,
ctx->ShaderCompilerOptions[MESA_SHADER_VERTEX].PreferDP4,
- ctx->Const.VertexProgram.MaxTemps );
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps );
#if 0
if (ctx->Driver.ProgramStringNotify)
diff --git a/mesalib/src/mesa/main/format_pack.c b/mesalib/src/mesa/main/format_pack.c
index 826fc10a6..41f5f99c1 100644
--- a/mesalib/src/mesa/main/format_pack.c
+++ b/mesalib/src/mesa/main/format_pack.c
@@ -1824,6 +1824,56 @@ pack_float_XBGR32323232_FLOAT(const GLfloat src[4], void *dst)
d[3] = 1.0;
}
+/* MESA_FORMAT_ABGR2101010 */
+
+static void
+pack_ubyte_ABGR2101010(const GLubyte src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r = UBYTE_TO_USHORT(src[RCOMP]);
+ GLushort g = UBYTE_TO_USHORT(src[GCOMP]);
+ GLushort b = UBYTE_TO_USHORT(src[BCOMP]);
+ GLushort a = UBYTE_TO_USHORT(src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
+static void
+pack_float_ABGR2101010(const GLfloat src[4], void *dst)
+{
+ GLuint *d = ((GLuint *) dst);
+ GLushort r, g, b, a;
+ UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+ *d = PACK_COLOR_2101010_US(a, b, g, r);
+}
+
+/*
+ * MESA_FORMAT_SIGNED_RG88
+ */
+
+static void
+pack_float_SIGNED_RG88(const GLfloat src[4], void *dst)
+{
+ GLushort *d = (GLushort *) dst;
+ GLbyte r = FLOAT_TO_BYTE(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLbyte g = FLOAT_TO_BYTE(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ *d = (r << 8) | (g & 0xff);
+}
+
+/*
+ * MESA_FORMAT_SIGNED_RG1616
+ */
+
+static void
+pack_float_SIGNED_RG1616(const GLfloat src[4], void *dst)
+{
+ GLuint *d = (GLuint *) dst;
+ GLshort r = FLOAT_TO_SHORT(CLAMP(src[RCOMP], -1.0f, 1.0f));
+ GLshort g = FLOAT_TO_SHORT(CLAMP(src[GCOMP], -1.0f, 1.0f));
+ *d = (r << 16) | (g & 0xffff);
+}
/**
* Return a function that can pack a GLubyte rgba[4] color.
@@ -1978,6 +2028,8 @@ _mesa_get_pack_ubyte_rgba_function(gl_format format)
table[MESA_FORMAT_XBGR32323232_UINT] = NULL;
table[MESA_FORMAT_XBGR32323232_SINT] = NULL;
+ table[MESA_FORMAT_ABGR2101010] = pack_ubyte_ABGR2101010;
+
initialized = GL_TRUE;
}
@@ -2136,6 +2188,11 @@ _mesa_get_pack_float_rgba_function(gl_format format)
table[MESA_FORMAT_XBGR32323232_UINT] = NULL;
table[MESA_FORMAT_XBGR32323232_SINT] = NULL;
+ table[MESA_FORMAT_ABGR2101010] = pack_float_ABGR2101010;
+
+ table[MESA_FORMAT_SIGNED_RG88] = pack_float_SIGNED_RG88;
+ table[MESA_FORMAT_SIGNED_RG1616] = pack_float_SIGNED_RG1616;
+
initialized = GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/format_unpack.c b/mesalib/src/mesa/main/format_unpack.c
index 0a8b8b183..28a50f31e 100644
--- a/mesalib/src/mesa/main/format_unpack.c
+++ b/mesalib/src/mesa/main/format_unpack.c
@@ -2268,6 +2268,44 @@ unpack_XBGR32323232_SINT(const void *src, GLfloat dst[][4], GLuint n)
}
}
+static void
+unpack_ABGR2101010(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = ((const GLuint *) src);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = ((s[i] >> 0) & 0x3ff) * (1.0F / 1023.0F);
+ dst[i][GCOMP] = ((s[i] >> 10) & 0x3ff) * (1.0F / 1023.0F);
+ dst[i][BCOMP] = ((s[i] >> 20) & 0x3ff) * (1.0F / 1023.0F);
+ dst[i][ACOMP] = ((s[i] >> 30) & 0x03) * (1.0F / 3.0F);
+ }
+}
+
+static void
+unpack_SIGNED_RG88(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLushort *s = ((const GLushort *) src);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] >> 8) );
+ dst[i][GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s[i] & 0xff) );
+ dst[i][BCOMP] = 0.0F;
+ dst[i][ACOMP] = 1.0F;
+ }
+}
+
+static void
+unpack_SIGNED_RG1616(const void *src, GLfloat dst[][4], GLuint n)
+{
+ const GLuint *s = ((const GLuint *) src);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i] >> 16) );
+ dst[i][GCOMP] = SHORT_TO_FLOAT_TEX( (GLshort) (s[i] & 0xffff) );
+ dst[i][BCOMP] = 0.0F;
+ dst[i][ACOMP] = 1.0F;
+ }
+}
/**
* Return the unpacker function for the given format.
@@ -2481,6 +2519,11 @@ get_unpack_rgba_function(gl_format format)
table[MESA_FORMAT_XBGR32323232_UINT] = unpack_XBGR32323232_UINT;
table[MESA_FORMAT_XBGR32323232_SINT] = unpack_XBGR32323232_SINT;
+ table[MESA_FORMAT_ABGR2101010] = unpack_ABGR2101010;
+
+ table[MESA_FORMAT_SIGNED_RG88] = unpack_SIGNED_RG88;
+ table[MESA_FORMAT_SIGNED_RG1616] = unpack_SIGNED_RG1616;
+
initialized = GL_TRUE;
}
@@ -3582,6 +3625,20 @@ unpack_int_rgba_XBGR32323232_UINT(const GLuint *src, GLuint dst[][4], GLuint n)
}
}
+static void
+unpack_int_rgba_ABGR2101010(const GLuint *src, GLuint dst[][4], GLuint n)
+{
+ unsigned int i;
+
+ for (i = 0; i < n; i++) {
+ GLuint tmp = src[i];
+ dst[i][0] = (tmp >> 0) & 0x3ff;
+ dst[i][1] = (tmp >> 10) & 0x3ff;
+ dst[i][2] = (tmp >> 20) & 0x3ff;
+ dst[i][3] = (tmp >> 30) & 0x3;
+ }
+}
+
void
_mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
const void *src, GLuint dst[][4])
@@ -3782,6 +3839,10 @@ _mesa_unpack_uint_rgba_row(gl_format format, GLuint n,
unpack_int_rgba_XBGR32323232_UINT(src, dst, n);
break;
+ case MESA_FORMAT_ABGR2101010:
+ unpack_int_rgba_ABGR2101010(src, dst, n);
+ break;
+
default:
_mesa_problem(NULL, "%s: bad format %s", __FUNCTION__,
_mesa_get_format_name(format));
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 07d2a7240..1246c4d92 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -1763,6 +1763,33 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0,
1, 1, 16
},
+ {
+ MESA_FORMAT_ABGR2101010,
+ "MESA_FORMAT_ABGR2101010",
+ GL_RGBA,
+ GL_UNSIGNED_NORMALIZED,
+ 10, 10, 10, 2,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
+ {
+ MESA_FORMAT_SIGNED_RG88,
+ "MESA_FORMAT_SIGNED_RG88",
+ GL_RG,
+ GL_SIGNED_NORMALIZED,
+ 8, 8, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 2
+ },
+ {
+ MESA_FORMAT_SIGNED_RG1616,
+ "MESA_FORMAT_SIGNED_RG1616",
+ GL_RG,
+ GL_SIGNED_NORMALIZED,
+ 16, 16, 0, 0,
+ 0, 0, 0, 0, 0,
+ 1, 1, 4
+ },
};
@@ -1967,6 +1994,26 @@ _mesa_is_format_unsigned(gl_format format)
/**
+ * Does the given format store signed values?
+ */
+GLboolean
+_mesa_is_format_signed(gl_format format)
+{
+ if (format == MESA_FORMAT_R11_G11_B10_FLOAT ||
+ format == MESA_FORMAT_RGB9_E5_FLOAT) {
+ /* these packed float formats only store unsigned values */
+ return GL_FALSE;
+ }
+ else {
+ const struct gl_format_info *info = _mesa_get_format_info(format);
+ return (info->DataType == GL_SIGNED_NORMALIZED ||
+ info->DataType == GL_INT ||
+ info->DataType == GL_FLOAT);
+ }
+}
+
+
+/**
* Return color encoding for given format.
* \return GL_LINEAR or GL_SRGB
*/
@@ -2821,6 +2868,21 @@ _mesa_format_to_type_and_comps(gl_format format,
*comps = 4;
return;
+ case MESA_FORMAT_ABGR2101010:
+ *datatype = GL_UNSIGNED_INT_2_10_10_10_REV;
+ *comps = 4;
+ return;
+
+ case MESA_FORMAT_SIGNED_RG88:
+ *datatype = GL_BYTE;
+ *comps = 2;
+ return;
+
+ case MESA_FORMAT_SIGNED_RG1616:
+ *datatype = GL_SHORT;
+ *comps = 2;
+ return;
+
case MESA_FORMAT_COUNT:
assert(0);
return;
@@ -3362,6 +3424,18 @@ _mesa_format_matches_format_and_type(gl_format gl_format,
case MESA_FORMAT_XBGR32323232_UINT:
case MESA_FORMAT_XBGR32323232_SINT:
return GL_FALSE;
+
+ case MESA_FORMAT_ABGR2101010:
+ return format == GL_RGBA && type == GL_UNSIGNED_INT_2_10_10_10_REV &&
+ !swapBytes;
+
+ case MESA_FORMAT_SIGNED_RG88:
+ return format == GL_RG && type == GL_BYTE && !littleEndian &&
+ !swapBytes;
+
+ case MESA_FORMAT_SIGNED_RG1616:
+ return format == GL_RG && type == GL_SHORT && !littleEndian &&
+ !swapBytes;
}
return GL_FALSE;
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index 64b4b9a01..a1f0d226a 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -304,6 +304,11 @@ typedef enum
MESA_FORMAT_XBGR32323232_UINT, /* ... */
MESA_FORMAT_XBGR32323232_SINT, /* ... */
+ MESA_FORMAT_ABGR2101010,
+
+ MESA_FORMAT_SIGNED_RG88,
+ MESA_FORMAT_SIGNED_RG1616,
+
MESA_FORMAT_COUNT
} gl_format;
@@ -341,6 +346,9 @@ _mesa_is_format_integer_color(gl_format format);
extern GLboolean
_mesa_is_format_unsigned(gl_format format);
+extern GLboolean
+_mesa_is_format_signed(gl_format format);
+
extern GLenum
_mesa_get_format_color_encoding(gl_format format);
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index 691380898..b13f9a3db 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -145,6 +145,7 @@ enum value_extra {
EXTRA_GLSL_130,
EXTRA_EXT_UBO_GS4,
EXTRA_EXT_ATOMICS_GS4,
+ EXTRA_EXT_SHADER_IMAGE_GS4,
};
#define NO_EXTRA NULL
@@ -327,6 +328,12 @@ static const int extra_EXT_framebuffer_sRGB_and_new_buffers[] = {
EXTRA_END
};
+static const int extra_EXT_packed_float[] = {
+ EXT(EXT_packed_float),
+ EXTRA_NEW_BUFFERS,
+ EXTRA_END
+};
+
static const int extra_EXT_texture_array_es3[] = {
EXT(EXT_texture_array),
EXTRA_API_ES3,
@@ -338,6 +345,11 @@ static const int extra_ARB_shader_atomic_counters_and_geometry_shader[] = {
EXTRA_END
};
+static const int extra_ARB_shader_image_load_store_and_geometry_shader[] = {
+ EXTRA_EXT_SHADER_IMAGE_GS4,
+ EXTRA_END
+};
+
EXTRA_EXT(ARB_texture_cube_map);
EXTRA_EXT(EXT_texture_array);
EXTRA_EXT(NV_fog_distance);
@@ -376,6 +388,7 @@ EXTRA_EXT(ARB_texture_multisample);
EXTRA_EXT(ARB_texture_gather);
EXTRA_EXT(ARB_shader_atomic_counters);
EXTRA_EXT(ARB_draw_indirect);
+EXTRA_EXT(ARB_shader_image_load_store);
static const int
extra_ARB_color_buffer_float_or_glcore[] = {
@@ -757,6 +770,45 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
ctx->Texture.Unit[unit].CurrentTex[d->offset]->Name;
break;
+ /* GL_EXT_packed_float */
+ case GL_RGBA_SIGNED_COMPONENTS_EXT:
+ {
+ /* Note: we only check the 0th color attachment. */
+ const struct gl_renderbuffer *rb =
+ ctx->DrawBuffer->_ColorDrawBuffers[0];
+ if (rb && _mesa_is_format_signed(rb->Format)) {
+ /* Issue 17 of GL_EXT_packed_float: If a component (such as
+ * alpha) has zero bits, the component should not be considered
+ * signed and so the bit for the respective component should be
+ * zeroed.
+ */
+ GLint r_bits =
+ _mesa_get_format_bits(rb->Format, GL_RED_BITS);
+ GLint g_bits =
+ _mesa_get_format_bits(rb->Format, GL_GREEN_BITS);
+ GLint b_bits =
+ _mesa_get_format_bits(rb->Format, GL_BLUE_BITS);
+ GLint a_bits =
+ _mesa_get_format_bits(rb->Format, GL_ALPHA_BITS);
+ GLint l_bits =
+ _mesa_get_format_bits(rb->Format, GL_TEXTURE_LUMINANCE_SIZE);
+ GLint i_bits =
+ _mesa_get_format_bits(rb->Format, GL_TEXTURE_INTENSITY_SIZE);
+
+ v->value_int_4[0] = r_bits + l_bits + i_bits > 0;
+ v->value_int_4[1] = g_bits + l_bits + i_bits > 0;
+ v->value_int_4[2] = b_bits + l_bits + i_bits > 0;
+ v->value_int_4[3] = a_bits + i_bits > 0;
+ }
+ else {
+ v->value_int_4[0] =
+ v->value_int_4[1] =
+ v->value_int_4[2] =
+ v->value_int_4[3] = 0;
+ }
+ }
+ break;
+
/* GL_ARB_vertex_buffer_object */
case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
@@ -849,11 +901,11 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
v->value_float = ctx->Color.AlphaRefUnclamped;
break;
case GL_MAX_VERTEX_UNIFORM_VECTORS:
- v->value_int = ctx->Const.VertexProgram.MaxUniformComponents / 4;
+ v->value_int = ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4;
break;
case GL_MAX_FRAGMENT_UNIFORM_VECTORS:
- v->value_int = ctx->Const.FragmentProgram.MaxUniformComponents / 4;
+ v->value_int = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4;
break;
/* GL_ARB_texture_buffer_object */
@@ -1026,6 +1078,11 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
api_found = (ctx->Extensions.ARB_shader_atomic_counters &&
_mesa_has_geometry_shaders(ctx));
break;
+ case EXTRA_EXT_SHADER_IMAGE_GS4:
+ api_check = GL_TRUE;
+ api_found = (ctx->Extensions.ARB_shader_image_load_store &&
+ _mesa_has_geometry_shaders(ctx));
+ break;
case EXTRA_END:
break;
default: /* *e is a offset into the extension struct */
@@ -1747,7 +1804,7 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
case GL_VERTEX_BINDING_DIVISOR:
if (!_mesa_is_desktop_gl(ctx) || !ctx->Extensions.ARB_instanced_arrays)
goto invalid_enum;
- if (index >= ctx->Const.VertexProgram.MaxAttribs)
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
goto invalid_value;
v->value_int = ctx->Array.ArrayObj->VertexBinding[VERT_ATTRIB_GENERIC(index)].InstanceDivisor;
return TYPE_INT;
@@ -1755,7 +1812,7 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
case GL_VERTEX_BINDING_OFFSET:
if (!_mesa_is_desktop_gl(ctx))
goto invalid_enum;
- if (index >= ctx->Const.VertexProgram.MaxAttribs)
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
goto invalid_value;
v->value_int = ctx->Array.ArrayObj->VertexBinding[VERT_ATTRIB_GENERIC(index)].Offset;
return TYPE_INT;
@@ -1763,9 +1820,67 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
case GL_VERTEX_BINDING_STRIDE:
if (!_mesa_is_desktop_gl(ctx))
goto invalid_enum;
- if (index >= ctx->Const.VertexProgram.MaxAttribs)
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
goto invalid_value;
v->value_int = ctx->Array.ArrayObj->VertexBinding[VERT_ATTRIB_GENERIC(index)].Stride;
+
+ /* ARB_shader_image_load_store */
+ case GL_IMAGE_BINDING_NAME: {
+ struct gl_texture_object *t;
+
+ if (!ctx->Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+ if (index >= ctx->Const.MaxImageUnits)
+ goto invalid_value;
+
+ t = ctx->ImageUnits[index].TexObj;
+ v->value_int = (t ? t->Name : 0);
+ return TYPE_INT;
+ }
+
+ case GL_IMAGE_BINDING_LEVEL:
+ if (!ctx->Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+ if (index >= ctx->Const.MaxImageUnits)
+ goto invalid_value;
+
+ v->value_int = ctx->ImageUnits[index].Level;
+ return TYPE_INT;
+
+ case GL_IMAGE_BINDING_LAYERED:
+ if (!ctx->Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+ if (index >= ctx->Const.MaxImageUnits)
+ goto invalid_value;
+
+ v->value_int = ctx->ImageUnits[index].Layered;
+ return TYPE_INT;
+
+ case GL_IMAGE_BINDING_LAYER:
+ if (!ctx->Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+ if (index >= ctx->Const.MaxImageUnits)
+ goto invalid_value;
+
+ v->value_int = ctx->ImageUnits[index].Layer;
+ return TYPE_INT;
+
+ case GL_IMAGE_BINDING_ACCESS:
+ if (!ctx->Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+ if (index >= ctx->Const.MaxImageUnits)
+ goto invalid_value;
+
+ v->value_int = ctx->ImageUnits[index].Access;
+ return TYPE_INT;
+
+ case GL_IMAGE_BINDING_FORMAT:
+ if (!ctx->Extensions.ARB_shader_image_load_store)
+ goto invalid_enum;
+ if (index >= ctx->Const.MaxImageUnits)
+ goto invalid_value;
+
+ v->value_int = ctx->ImageUnits[index].Format;
return TYPE_INT;
}
diff --git a/mesalib/src/mesa/main/get_hash_params.py b/mesalib/src/mesa/main/get_hash_params.py
index 653bf6256..6195d630d 100644
--- a/mesalib/src/mesa/main/get_hash_params.py
+++ b/mesalib/src/mesa/main/get_hash_params.py
@@ -271,8 +271,8 @@ descriptor=[
# GL_ARB_fragment_program
# == GL_MAX_TEXTURE_IMAGE_UNITS_NV
- [ "MAX_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.FragmentProgram.MaxTextureImageUnits), extra_ARB_fragment_program" ],
- [ "MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.VertexProgram.MaxTextureImageUnits), extra_ARB_vertex_shader" ],
+ [ "MAX_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits), extra_ARB_fragment_program" ],
+ [ "MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits), extra_ARB_vertex_shader" ],
[ "MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.MaxCombinedTextureImageUnits), extra_ARB_vertex_shader" ],
# GL_ARB_shader_objects
@@ -288,7 +288,7 @@ descriptor=[
[ "STENCIL_BACK_FAIL", "CONTEXT_ENUM(Stencil.FailFunc[1]), NO_EXTRA" ],
[ "STENCIL_BACK_PASS_DEPTH_FAIL", "CONTEXT_ENUM(Stencil.ZFailFunc[1]), NO_EXTRA" ],
[ "STENCIL_BACK_PASS_DEPTH_PASS", "CONTEXT_ENUM(Stencil.ZPassFunc[1]), NO_EXTRA" ],
- [ "MAX_VERTEX_ATTRIBS_ARB", "CONTEXT_INT(Const.VertexProgram.MaxAttribs), extra_ARB_vertex_program_api_es2" ],
+ [ "MAX_VERTEX_ATTRIBS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxAttribs), extra_ARB_vertex_program_api_es2" ],
# OES_texture_3D
[ "TEXTURE_BINDING_3D", "LOC_CUSTOM, TYPE_INT, TEXTURE_3D_INDEX, NO_EXTRA" ],
@@ -328,14 +328,14 @@ descriptor=[
[ "MINOR_VERSION", "LOC_CUSTOM, TYPE_INT, 0, extra_gl30_es3" ],
# GL 3.2 / GLES3
- [ "MAX_VERTEX_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.VertexProgram.MaxOutputComponents), extra_gl32_es3" ],
- [ "MAX_FRAGMENT_INPUT_COMPONENTS", "CONTEXT_INT(Const.FragmentProgram.MaxInputComponents), extra_gl32_es3" ],
+ [ "MAX_VERTEX_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents), extra_gl32_es3" ],
+ [ "MAX_FRAGMENT_INPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents), extra_gl32_es3" ],
# GL_ARB_ES3_compatibility
[ "MAX_ELEMENT_INDEX", "CONTEXT_INT64(Const.MaxElementIndex), extra_ARB_ES3_compatibility_api_es3"],
# GL_ARB_fragment_shader
- [ "MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", "CONTEXT_INT(Const.FragmentProgram.MaxUniformComponents), extra_ARB_fragment_shader" ],
+ [ "MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents), extra_ARB_fragment_shader" ],
# GL_ARB_framebuffer_object
[ "MAX_SAMPLES", "CONTEXT_INT(Const.MaxSamples), extra_ARB_framebuffer_object_EXT_framebuffer_multisample" ],
@@ -349,18 +349,18 @@ descriptor=[
[ "TRANSFORM_FEEDBACK_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_transform_feedback2_api_es3" ],
# GL_ARB_uniform_buffer_object
- [ "MAX_VERTEX_UNIFORM_BLOCKS", "CONTEXT_INT(Const.VertexProgram.MaxUniformBlocks), extra_ARB_uniform_buffer_object" ],
- [ "MAX_FRAGMENT_UNIFORM_BLOCKS", "CONTEXT_INT(Const.FragmentProgram.MaxUniformBlocks), extra_ARB_uniform_buffer_object" ],
+ [ "MAX_VERTEX_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxUniformBlocks), extra_ARB_uniform_buffer_object" ],
+ [ "MAX_FRAGMENT_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxUniformBlocks), extra_ARB_uniform_buffer_object" ],
[ "MAX_COMBINED_UNIFORM_BLOCKS", "CONTEXT_INT(Const.MaxCombinedUniformBlocks), extra_ARB_uniform_buffer_object" ],
[ "MAX_UNIFORM_BLOCK_SIZE", "CONTEXT_INT(Const.MaxUniformBlockSize), extra_ARB_uniform_buffer_object" ],
[ "MAX_UNIFORM_BUFFER_BINDINGS", "CONTEXT_INT(Const.MaxUniformBufferBindings), extra_ARB_uniform_buffer_object" ],
- [ "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.VertexProgram.MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object" ],
- [ "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.FragmentProgram.MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object" ],
+ [ "MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object" ],
+ [ "MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object" ],
[ "UNIFORM_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.UniformBufferOffsetAlignment), extra_ARB_uniform_buffer_object" ],
[ "UNIFORM_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_uniform_buffer_object" ],
# GL_ARB_vertex_shader
- [ "MAX_VERTEX_UNIFORM_COMPONENTS_ARB", "CONTEXT_INT(Const.VertexProgram.MaxUniformComponents), extra_ARB_vertex_shader" ],
+ [ "MAX_VERTEX_UNIFORM_COMPONENTS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents), extra_ARB_vertex_shader" ],
[ "MAX_VARYING_FLOATS_ARB", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_vertex_shader" ],
# GL_EXT_framebuffer_blit
@@ -611,6 +611,9 @@ descriptor=[
# GL_ARB_fragment_program
[ "FRAGMENT_PROGRAM_ARB", "CONTEXT_BOOL(FragmentProgram.Enabled), extra_ARB_fragment_program" ],
+# GL_EXT_packed_float
+ [ "RGBA_SIGNED_COMPONENTS_EXT", "LOC_CUSTOM, TYPE_INT_4, 0, extra_EXT_packed_float" ],
+
# GL_EXT_depth_bounds_test
[ "DEPTH_BOUNDS_TEST_EXT", "CONTEXT_BOOL(Depth.BoundsTest), extra_EXT_depth_bounds_test" ],
[ "DEPTH_BOUNDS_EXT", "CONTEXT_FLOAT2(Depth.BoundsMin), extra_EXT_depth_bounds_test" ],
@@ -643,12 +646,12 @@ descriptor=[
[ "MAX_VERTEX_STREAMS", "CONTEXT_INT(Const.MaxVertexStreams), extra_ARB_transform_feedback3" ],
# GL_ARB_geometry_shader4
- [ "MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.GeometryProgram.MaxTextureImageUnits), extra_gl32_ARB_geometry_shader4" ],
+ [ "MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits), extra_gl32_ARB_geometry_shader4" ],
[ "MAX_GEOMETRY_OUTPUT_VERTICES_ARB", "CONTEXT_INT(Const.MaxGeometryOutputVertices), extra_gl32_ARB_geometry_shader4" ],
[ "MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB", "CONTEXT_INT(Const.MaxGeometryTotalOutputComponents), extra_gl32_ARB_geometry_shader4" ],
- [ "MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB", "CONTEXT_INT(Const.GeometryProgram.MaxUniformComponents), extra_gl32_ARB_geometry_shader4" ],
- [ "MAX_GEOMETRY_VARYING_COMPONENTS_ARB", "CONTEXT_INT(Const.GeometryProgram.MaxOutputComponents), extra_ARB_geometry_shader4" ],
- [ "MAX_VERTEX_VARYING_COMPONENTS_ARB", "CONTEXT_INT(Const.VertexProgram.MaxOutputComponents), extra_ARB_geometry_shader4" ],
+ [ "MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformComponents), extra_gl32_ARB_geometry_shader4" ],
+ [ "MAX_GEOMETRY_VARYING_COMPONENTS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents), extra_ARB_geometry_shader4" ],
+ [ "MAX_VERTEX_VARYING_COMPONENTS_ARB", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents), extra_ARB_geometry_shader4" ],
# GL_ARB_color_buffer_float
[ "RGBA_FLOAT_MODE_ARB", "BUFFER_FIELD(Visual.floatMode, TYPE_BOOLEAN), extra_core_ARB_color_buffer_float_and_new_buffers" ],
@@ -688,8 +691,8 @@ descriptor=[
# GL 3.2
[ "CONTEXT_PROFILE_MASK", "CONTEXT_INT(Const.ProfileMask), extra_version_32" ],
- [ "MAX_GEOMETRY_INPUT_COMPONENTS", "CONTEXT_INT(Const.GeometryProgram.MaxInputComponents), extra_version_32" ],
- [ "MAX_GEOMETRY_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.GeometryProgram.MaxOutputComponents), extra_version_32" ],
+ [ "MAX_GEOMETRY_INPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents), extra_version_32" ],
+ [ "MAX_GEOMETRY_OUTPUT_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents), extra_version_32" ],
# GL_ARB_robustness
[ "RESET_NOTIFICATION_STRATEGY_ARB", "CONTEXT_ENUM(Const.ResetStrategy), NO_EXTRA" ],
@@ -706,8 +709,8 @@ descriptor=[
[ "MAX_DUAL_SOURCE_DRAW_BUFFERS", "CONTEXT_INT(Const.MaxDualSourceDrawBuffers), extra_ARB_blend_func_extended" ],
# GL_ARB_uniform_buffer_object
- [ "MAX_GEOMETRY_UNIFORM_BLOCKS", "CONTEXT_INT(Const.GeometryProgram.MaxUniformBlocks), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
- [ "MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.GeometryProgram.MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
+ [ "MAX_GEOMETRY_UNIFORM_BLOCKS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
+ [ "MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxCombinedUniformComponents), extra_ARB_uniform_buffer_object_and_geometry_shader" ],
# GL_ARB_timer_query
[ "TIMESTAMP", "LOC_CUSTOM, TYPE_INT64, 0, extra_ARB_timer_query" ],
@@ -727,18 +730,27 @@ descriptor=[
[ "ATOMIC_COUNTER_BUFFER_BINDING", "LOC_CUSTOM, TYPE_INT, 0, extra_ARB_shader_atomic_counters" ],
[ "MAX_ATOMIC_COUNTER_BUFFER_BINDINGS", "CONTEXT_INT(Const.MaxAtomicBufferBindings), extra_ARB_shader_atomic_counters" ],
[ "MAX_ATOMIC_COUNTER_BUFFER_SIZE", "CONTEXT_INT(Const.MaxAtomicBufferSize), extra_ARB_shader_atomic_counters" ],
- [ "MAX_VERTEX_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.VertexProgram.MaxAtomicBuffers), extra_ARB_shader_atomic_counters" ],
- [ "MAX_VERTEX_ATOMIC_COUNTERS", "CONTEXT_INT(Const.VertexProgram.MaxAtomicCounters), extra_ARB_shader_atomic_counters" ],
- [ "MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.FragmentProgram.MaxAtomicBuffers), extra_ARB_shader_atomic_counters" ],
- [ "MAX_FRAGMENT_ATOMIC_COUNTERS", "CONTEXT_INT(Const.FragmentProgram.MaxAtomicCounters), extra_ARB_shader_atomic_counters" ],
- [ "MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.GeometryProgram.MaxAtomicBuffers), extra_ARB_shader_atomic_counters_and_geometry_shader" ],
- [ "MAX_GEOMETRY_ATOMIC_COUNTERS", "CONTEXT_INT(Const.GeometryProgram.MaxAtomicCounters), extra_ARB_shader_atomic_counters_and_geometry_shader" ],
+ [ "MAX_VERTEX_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxAtomicBuffers), extra_ARB_shader_atomic_counters" ],
+ [ "MAX_VERTEX_ATOMIC_COUNTERS", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxAtomicCounters), extra_ARB_shader_atomic_counters" ],
+ [ "MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers), extra_ARB_shader_atomic_counters" ],
+ [ "MAX_FRAGMENT_ATOMIC_COUNTERS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters), extra_ARB_shader_atomic_counters" ],
+ [ "MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers), extra_ARB_shader_atomic_counters_and_geometry_shader" ],
+ [ "MAX_GEOMETRY_ATOMIC_COUNTERS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters), extra_ARB_shader_atomic_counters_and_geometry_shader" ],
[ "MAX_COMBINED_ATOMIC_COUNTER_BUFFERS", "CONTEXT_INT(Const.MaxCombinedAtomicBuffers), extra_ARB_shader_atomic_counters" ],
[ "MAX_COMBINED_ATOMIC_COUNTERS", "CONTEXT_INT(Const.MaxCombinedAtomicCounters), extra_ARB_shader_atomic_counters" ],
# GL_ARB_vertex_attrib_binding
[ "MAX_VERTEX_ATTRIB_RELATIVE_OFFSET", "CONTEXT_ENUM(Const.MaxVertexAttribRelativeOffset), NO_EXTRA" ],
[ "MAX_VERTEX_ATTRIB_BINDINGS", "CONTEXT_ENUM(Const.MaxVertexAttribBindings), NO_EXTRA" ],
+
+# GL_ARB_shader_image_load_store
+ [ "MAX_IMAGE_UNITS", "CONTEXT_INT(Const.MaxImageUnits), extra_ARB_shader_image_load_store"],
+ [ "MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS", "CONTEXT_INT(Const.MaxCombinedImageUnitsAndFragmentOutputs), extra_ARB_shader_image_load_store"],
+ [ "MAX_IMAGE_SAMPLES", "CONTEXT_INT(Const.MaxImageSamples), extra_ARB_shader_image_load_store"],
+ [ "MAX_VERTEX_IMAGE_UNIFORMS", "CONTEXT_INT(Const.Program[MESA_SHADER_VERTEX].MaxImageUniforms), extra_ARB_shader_image_load_store"],
+ [ "MAX_GEOMETRY_IMAGE_UNIFORMS", "CONTEXT_INT(Const.Program[MESA_SHADER_GEOMETRY].MaxImageUniforms), extra_ARB_shader_image_load_store_and_geometry_shader"],
+ [ "MAX_FRAGMENT_IMAGE_UNIFORMS", "CONTEXT_INT(Const.Program[MESA_SHADER_FRAGMENT].MaxImageUniforms), extra_ARB_shader_image_load_store"],
+ [ "MAX_COMBINED_IMAGE_UNIFORMS", "CONTEXT_INT(Const.MaxCombinedImageUniforms), extra_ARB_shader_image_load_store"],
]},
# Enums restricted to OpenGL Core profile
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index f93bb5641..33df682cf 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -393,6 +393,23 @@ typedef enum
/**
+ * Shader stages. Note that these will become 5 with tessellation.
+ *
+ * The order must match how shaders are ordered in the pipeline.
+ * The GLSL linker assumes that if i<j, then the j-th shader is
+ * executed later than the i-th shader.
+ */
+typedef enum
+{
+ MESA_SHADER_VERTEX = 0,
+ MESA_SHADER_GEOMETRY = 1,
+ MESA_SHADER_FRAGMENT = 2,
+} gl_shader_stage;
+
+#define MESA_SHADER_STAGES (MESA_SHADER_FRAGMENT + 1)
+
+
+/**
* Framebuffer configuration (aka visual / pixelformat)
* Note: some of these fields should be boolean, but it appears that
* code in drivers/dri/common/util.c requires int-sized fields.
@@ -1213,6 +1230,9 @@ struct gl_texture_object
/** GL_OES_EGL_image_external */
GLint RequiredTextureImageUnits;
+
+ /** GL_ARB_shader_image_load_store */
+ GLenum ImageFormatCompatibilityType;
};
@@ -2302,6 +2322,7 @@ struct gl_shader
* Must be the first field.
*/
GLenum Type;
+ gl_shader_stage Stage;
GLuint Name; /**< AKA the handle */
GLchar *Label; /**< GL_KHR_debug */
GLint RefCount; /**< Reference count */
@@ -2384,24 +2405,33 @@ struct gl_shader
*/
GLenum OutputType;
} Geom;
-};
+ /**
+ * Map from image uniform index to image unit (set by glUniform1i())
+ *
+ * An image uniform index is associated with each image uniform by
+ * the linker. The image index associated with each uniform is
+ * stored in the \c gl_uniform_storage::image field.
+ */
+ GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
-/**
- * Shader stages. Note that these will become 5 with tessellation.
- *
- * The order must match how shaders are ordered in the pipeline.
- * The GLSL linker assumes that if i<j, then the j-th shader is
- * executed later than the i-th shader.
- */
-typedef enum
-{
- MESA_SHADER_VERTEX = 0,
- MESA_SHADER_GEOMETRY = 1,
- MESA_SHADER_FRAGMENT = 2,
-} gl_shader_type;
+ /**
+ * Access qualifier specified in the shader for each image uniform
+ * index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY or \c
+ * GL_READ_WRITE.
+ *
+ * It may be different, though only more strict than the value of
+ * \c gl_image_unit::Access for the corresponding image unit.
+ */
+ GLenum ImageAccess[MAX_IMAGE_UNIFORMS];
-#define MESA_SHADER_TYPES (MESA_SHADER_FRAGMENT + 1)
+ /**
+ * Number of image uniforms defined in the shader. It specifies
+ * the number of valid elements in the \c ImageUnits and \c
+ * ImageAccess arrays above.
+ */
+ GLuint NumImages;
+};
struct gl_uniform_buffer_variable
@@ -2482,7 +2512,7 @@ struct gl_active_atomic_buffer
GLuint MinimumSize;
/** Shader stages making use of it. */
- GLboolean StageReferences[MESA_SHADER_TYPES];
+ GLboolean StageReferences[MESA_SHADER_STAGES];
};
/**
@@ -2620,7 +2650,7 @@ struct gl_shader_program
* This is used to maintain the Binding values of the stage's UniformBlocks[]
* and to answer the GL_UNIFORM_BLOCK_REFERENCED_BY_*_SHADER queries.
*/
- int *UniformBlockStageIndex[MESA_SHADER_TYPES];
+ int *UniformBlockStageIndex[MESA_SHADER_STAGES];
/**
* Map of active uniform names to locations
@@ -2650,7 +2680,7 @@ struct gl_shader_program
* \c MESA_SHADER_* defines. Entries for non-existent stages will be
* \c NULL.
*/
- struct gl_shader *_LinkedShaders[MESA_SHADER_TYPES];
+ struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES];
};
@@ -3007,12 +3037,11 @@ struct gl_framebuffer
struct gl_renderbuffer *_ColorReadBuffer;
/**
- * The number of layers in the framebuffer, or 0 if the framebuffer is not
- * layered. For cube maps, this value is 6. For cube map arrays, this
- * value is the "depth" value passed to TexImage3D (always a multiple of
- * 6).
+ * The maximum number of layers in the framebuffer, or 0 if the framebuffer
+ * is not layered. For cube maps and cube map arrays, each cube face
+ * counts as a layer.
*/
- GLuint NumLayers;
+ GLuint MaxNumLayers;
/** Delete this framebuffer */
void (*Delete)(struct gl_framebuffer *fb);
@@ -3089,9 +3118,13 @@ struct gl_program_constants
GLuint MaxUniformBlocks;
GLuint MaxCombinedUniformComponents;
GLuint MaxTextureImageUnits;
+
/* GL_ARB_shader_atomic_counters */
GLuint MaxAtomicBuffers;
GLuint MaxAtomicCounters;
+
+ /* GL_ARB_shader_image_load_store */
+ GLuint MaxImageUniforms;
};
@@ -3134,9 +3167,7 @@ struct gl_constants
GLuint MaxViewportWidth, MaxViewportHeight;
- struct gl_program_constants VertexProgram; /**< GL_ARB_vertex_program */
- struct gl_program_constants FragmentProgram; /**< GL_ARB_fragment_program */
- struct gl_program_constants GeometryProgram; /**< GL_ARB_geometry_shader4 */
+ struct gl_program_constants Program[MESA_SHADER_STAGES];
GLuint MaxProgramMatrices;
GLuint MaxProgramMatrixStackDepth;
@@ -3314,6 +3345,12 @@ struct gl_constants
/** GL_ARB_vertex_attrib_binding */
GLint MaxVertexAttribRelativeOffset;
GLint MaxVertexAttribBindings;
+
+ /* GL_ARB_shader_image_load_store */
+ GLuint MaxImageUnits;
+ GLuint MaxCombinedImageUnitsAndFragmentOutputs;
+ GLuint MaxImageSamples;
+ GLuint MaxCombinedImageUniforms;
};
@@ -3361,6 +3398,7 @@ struct gl_extensions
GLboolean ARB_seamless_cube_map;
GLboolean ARB_shader_atomic_counters;
GLboolean ARB_shader_bit_encoding;
+ GLboolean ARB_shader_image_load_store;
GLboolean ARB_shader_stencil_export;
GLboolean ARB_shader_texture_lod;
GLboolean ARB_shading_language_packing;
@@ -3435,6 +3473,7 @@ struct gl_extensions
/* vendor extensions */
GLboolean AMD_performance_monitor;
GLboolean AMD_seamless_cubemap_per_texture;
+ GLboolean AMD_shader_trinary_minmax;
GLboolean AMD_vertex_shader_layer;
GLboolean APPLE_object_purgeable;
GLboolean ATI_envmap_bumpmap;
@@ -3738,6 +3777,11 @@ struct gl_driver_flags
* gl_context::AtomicBufferBindings
*/
GLbitfield NewAtomicBuffer;
+
+ /**
+ * gl_context::ImageUnits
+ */
+ GLbitfield NewImageUnits;
};
struct gl_uniform_buffer_binding
@@ -3755,6 +3799,60 @@ struct gl_uniform_buffer_binding
};
/**
+ * ARB_shader_image_load_store image unit.
+ */
+struct gl_image_unit
+{
+ /**
+ * Texture object bound to this unit.
+ */
+ struct gl_texture_object *TexObj;
+
+ /**
+ * Level of the texture object bound to this unit.
+ */
+ GLuint Level;
+
+ /**
+ * \c GL_TRUE if the whole level is bound as an array of layers, \c
+ * GL_FALSE if only some specific layer of the texture is bound.
+ * \sa Layer
+ */
+ GLboolean Layered;
+
+ /**
+ * Layer of the texture object bound to this unit, or zero if the
+ * whole level is bound.
+ */
+ GLuint Layer;
+
+ /**
+ * Access allowed to this texture image. Either \c GL_READ_ONLY,
+ * \c GL_WRITE_ONLY or \c GL_READ_WRITE.
+ */
+ GLenum Access;
+
+ /**
+ * GL internal format that determines the interpretation of the
+ * image memory when shader image operations are performed through
+ * this unit.
+ */
+ GLenum Format;
+
+ /**
+ * Mesa format corresponding to \c Format.
+ */
+ gl_format _ActualFormat;
+
+ /**
+ * GL_TRUE if the state of this image unit is valid and access from
+ * the shader is allowed. Otherwise loads from this unit should
+ * return zero and stores should have no effect.
+ */
+ GLboolean _Valid;
+};
+
+/**
* Binding point for an atomic counter buffer object.
*/
struct gl_atomic_buffer_binding
@@ -3906,7 +4004,7 @@ struct gl_context
struct gl_ati_fragment_shader_state ATIFragmentShader;
struct gl_shader_state Shader; /**< GLSL shader object state */
- struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_TYPES];
+ struct gl_shader_compiler_options ShaderCompilerOptions[MESA_SHADER_STAGES];
struct gl_query_state Query; /**< occlusion, timer queries */
@@ -3946,6 +4044,11 @@ struct gl_context
struct gl_atomic_buffer_binding
AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
+ /**
+ * Array of image units for ARB_shader_image_load_store.
+ */
+ struct gl_image_unit ImageUnits[MAX_IMAGE_UNITS];
+
/*@}*/
struct gl_meta_state *Meta; /**< for "meta" operations */
diff --git a/mesalib/src/mesa/main/scissor.c b/mesalib/src/mesa/main/scissor.c
index 0eddaa6c1..ac86bd591 100644
--- a/mesalib/src/mesa/main/scissor.c
+++ b/mesalib/src/mesa/main/scissor.c
@@ -79,7 +79,7 @@ _mesa_set_scissor(struct gl_context *ctx,
ctx->Scissor.Height = height;
if (ctx->Driver.Scissor)
- ctx->Driver.Scissor( ctx, x, y, width, height );
+ ctx->Driver.Scissor(ctx);
}
diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp
index f14e1a562..e1afe5315 100644
--- a/mesalib/src/mesa/main/shader_query.cpp
+++ b/mesalib/src/mesa/main/shader_query.cpp
@@ -59,7 +59,7 @@ _mesa_BindAttribLocation(GLhandleARB program, GLuint index,
return;
}
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBindAttribLocation(index)");
return;
}
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 57511e83e..6042fa896 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -108,7 +108,7 @@ _mesa_init_shader_state(struct gl_context *ctx)
* are generated by the GLSL compiler.
*/
struct gl_shader_compiler_options options;
- gl_shader_type sh;
+ gl_shader_stage sh;
memset(&options, 0, sizeof(options));
options.MaxUnrollIterations = 32;
@@ -117,7 +117,7 @@ _mesa_init_shader_state(struct gl_context *ctx)
/* Default pragma settings */
options.DefaultPragmas.Optimize = GL_TRUE;
- for (sh = 0; sh < MESA_SHADER_TYPES; ++sh)
+ for (sh = 0; sh < MESA_SHADER_STAGES; ++sh)
memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options));
ctx->Shader.Flags = get_shader_flags();
@@ -778,7 +778,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
if (!sh)
return;
- options = &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(sh->Type)];
+ options = &ctx->ShaderCompilerOptions[sh->Stage];
/* set default pragma state for shader */
sh->Pragmas = options->DefaultPragmas;
@@ -791,7 +791,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
} else {
if (ctx->Shader.Flags & GLSL_DUMP) {
printf("GLSL source for %s shader %d:\n",
- _mesa_shader_enum_to_string(sh->Type), sh->Name);
+ _mesa_shader_stage_to_string(sh->Stage), sh->Name);
printf("%s\n", sh->Source);
}
@@ -823,7 +823,7 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
if (!sh->CompileStatus) {
if (ctx->Shader.Flags & GLSL_DUMP_ON_ERROR) {
fprintf(stderr, "GLSL source for %s shader %d:\n",
- _mesa_shader_enum_to_string(sh->Type), sh->Name);
+ _mesa_shader_stage_to_string(sh->Stage), sh->Name);
fprintf(stderr, "%s\n", sh->Source);
fprintf(stderr, "Info Log:\n%s\n", sh->InfoLog);
fflush(stderr);
@@ -898,7 +898,7 @@ print_shader_info(const struct gl_shader_program *shProg)
printf("Mesa: glUseProgram(%u)\n", shProg->Name);
for (i = 0; i < shProg->NumShaders; i++) {
printf(" %s shader %u, checksum %u\n",
- _mesa_shader_enum_to_string(shProg->Shaders[i]->Type),
+ _mesa_shader_stage_to_string(shProg->Shaders[i]->Stage),
shProg->Shaders[i]->Name,
shProg->Shaders[i]->SourceChecksum);
}
@@ -1533,10 +1533,10 @@ _mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype,
switch (shadertype) {
case GL_VERTEX_SHADER:
- limits = &ctx->Const.VertexProgram;
+ limits = &ctx->Const.Program[MESA_SHADER_VERTEX];
break;
case GL_FRAGMENT_SHADER:
- limits = &ctx->Const.FragmentProgram;
+ limits = &ctx->Const.Program[MESA_SHADER_FRAGMENT];
break;
default:
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -1836,7 +1836,7 @@ _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string)
* object to a specific gl_program object.
*/
void
-_mesa_copy_linked_program_data(gl_shader_type type,
+_mesa_copy_linked_program_data(gl_shader_stage type,
const struct gl_shader_program *src,
struct gl_program *dst)
{
diff --git a/mesalib/src/mesa/main/shaderapi.h b/mesalib/src/mesa/main/shaderapi.h
index fe58e7de9..4822e32c2 100644
--- a/mesalib/src/mesa/main/shaderapi.h
+++ b/mesalib/src/mesa/main/shaderapi.h
@@ -211,7 +211,7 @@ extern GLuint GLAPIENTRY
_mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string);
extern void
-_mesa_copy_linked_program_data(gl_shader_type type,
+_mesa_copy_linked_program_data(gl_shader_stage type,
const struct gl_shader_program *src,
struct gl_program *dst);
diff --git a/mesalib/src/mesa/main/shaderimage.c b/mesalib/src/mesa/main/shaderimage.c
new file mode 100644
index 000000000..80c469366
--- /dev/null
+++ b/mesalib/src/mesa/main/shaderimage.c
@@ -0,0 +1,488 @@
+/*
+ * Copyright 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Francisco Jerez <currojerez@riseup.net>
+ */
+
+#include <assert.h>
+
+#include "shaderimage.h"
+#include "mtypes.h"
+#include "formats.h"
+#include "errors.h"
+#include "context.h"
+#include "texobj.h"
+#include "teximage.h"
+
+/*
+ * Define endian-invariant aliases for some mesa formats that are
+ * defined in terms of their channel layout from LSB to MSB in a
+ * 32-bit word. The actual byte offsets matter here because the user
+ * is allowed to bit-cast one format into another and get predictable
+ * results.
+ */
+#ifdef MESA_BIG_ENDIAN
+# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA8888
+# define MESA_FORMAT_RG_16 MESA_FORMAT_RG1616
+# define MESA_FORMAT_RG_8 MESA_FORMAT_RG88
+# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA8888
+# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_RG1616
+# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88
+#else
+# define MESA_FORMAT_RGBA_8 MESA_FORMAT_RGBA8888_REV
+# define MESA_FORMAT_RG_16 MESA_FORMAT_GR1616
+# define MESA_FORMAT_RG_8 MESA_FORMAT_GR88
+# define MESA_FORMAT_SIGNED_RGBA_8 MESA_FORMAT_SIGNED_RGBA8888_REV
+# define MESA_FORMAT_SIGNED_RG_16 MESA_FORMAT_SIGNED_GR1616
+# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_SIGNED_RG88_REV
+#endif
+
+static gl_format
+get_image_format(GLenum format)
+{
+ switch (format) {
+ case GL_RGBA32F:
+ return MESA_FORMAT_RGBA_FLOAT32;
+
+ case GL_RGBA16F:
+ return MESA_FORMAT_RGBA_FLOAT16;
+
+ case GL_RG32F:
+ return MESA_FORMAT_RG_FLOAT32;
+
+ case GL_RG16F:
+ return MESA_FORMAT_RG_FLOAT16;
+
+ case GL_R11F_G11F_B10F:
+ return MESA_FORMAT_R11_G11_B10_FLOAT;
+
+ case GL_R32F:
+ return MESA_FORMAT_R_FLOAT32;
+
+ case GL_R16F:
+ return MESA_FORMAT_R_FLOAT16;
+
+ case GL_RGBA32UI:
+ return MESA_FORMAT_RGBA_UINT32;
+
+ case GL_RGBA16UI:
+ return MESA_FORMAT_RGBA_UINT16;
+
+ case GL_RGB10_A2UI:
+ return MESA_FORMAT_ABGR2101010_UINT;
+
+ case GL_RGBA8UI:
+ return MESA_FORMAT_RGBA_UINT8;
+
+ case GL_RG32UI:
+ return MESA_FORMAT_RG_UINT32;
+
+ case GL_RG16UI:
+ return MESA_FORMAT_RG_UINT16;
+
+ case GL_RG8UI:
+ return MESA_FORMAT_RG_UINT8;
+
+ case GL_R32UI:
+ return MESA_FORMAT_R_UINT32;
+
+ case GL_R16UI:
+ return MESA_FORMAT_R_UINT16;
+
+ case GL_R8UI:
+ return MESA_FORMAT_R_UINT8;
+
+ case GL_RGBA32I:
+ return MESA_FORMAT_RGBA_INT32;
+
+ case GL_RGBA16I:
+ return MESA_FORMAT_RGBA_INT16;
+
+ case GL_RGBA8I:
+ return MESA_FORMAT_RGBA_INT8;
+
+ case GL_RG32I:
+ return MESA_FORMAT_RG_INT32;
+
+ case GL_RG16I:
+ return MESA_FORMAT_RG_INT16;
+
+ case GL_RG8I:
+ return MESA_FORMAT_RG_INT8;
+
+ case GL_R32I:
+ return MESA_FORMAT_R_INT32;
+
+ case GL_R16I:
+ return MESA_FORMAT_R_INT16;
+
+ case GL_R8I:
+ return MESA_FORMAT_R_INT8;
+
+ case GL_RGBA16:
+ return MESA_FORMAT_RGBA_16;
+
+ case GL_RGB10_A2:
+ return MESA_FORMAT_ABGR2101010;
+
+ case GL_RGBA8:
+ return MESA_FORMAT_RGBA_8;
+
+ case GL_RG16:
+ return MESA_FORMAT_RG_16;
+
+ case GL_RG8:
+ return MESA_FORMAT_RG_8;
+
+ case GL_R16:
+ return MESA_FORMAT_R16;
+
+ case GL_R8:
+ return MESA_FORMAT_R8;
+
+ case GL_RGBA16_SNORM:
+ return MESA_FORMAT_SIGNED_RGBA_16;
+
+ case GL_RGBA8_SNORM:
+ return MESA_FORMAT_SIGNED_RGBA_8;
+
+ case GL_RG16_SNORM:
+ return MESA_FORMAT_SIGNED_RG_16;
+
+ case GL_RG8_SNORM:
+ return MESA_FORMAT_SIGNED_RG_8;
+
+ case GL_R16_SNORM:
+ return MESA_FORMAT_SIGNED_R16;
+
+ case GL_R8_SNORM:
+ return MESA_FORMAT_SIGNED_R8;
+
+ default:
+ return MESA_FORMAT_NONE;
+ }
+}
+
+enum image_format_class
+{
+ /** Not a valid image format. */
+ IMAGE_FORMAT_CLASS_NONE = 0,
+
+ /** Classes of image formats you can cast into each other. */
+ /** \{ */
+ IMAGE_FORMAT_CLASS_1X8,
+ IMAGE_FORMAT_CLASS_1X16,
+ IMAGE_FORMAT_CLASS_1X32,
+ IMAGE_FORMAT_CLASS_2X8,
+ IMAGE_FORMAT_CLASS_2X16,
+ IMAGE_FORMAT_CLASS_2X32,
+ IMAGE_FORMAT_CLASS_10_11_11,
+ IMAGE_FORMAT_CLASS_4X8,
+ IMAGE_FORMAT_CLASS_4X16,
+ IMAGE_FORMAT_CLASS_4X32,
+ IMAGE_FORMAT_CLASS_2_10_10_10
+ /** \} */
+};
+
+static enum image_format_class
+get_image_format_class(gl_format format)
+{
+ switch (format) {
+ case MESA_FORMAT_RGBA_FLOAT32:
+ return IMAGE_FORMAT_CLASS_4X32;
+
+ case MESA_FORMAT_RGBA_FLOAT16:
+ return IMAGE_FORMAT_CLASS_4X16;
+
+ case MESA_FORMAT_RG_FLOAT32:
+ return IMAGE_FORMAT_CLASS_2X32;
+
+ case MESA_FORMAT_RG_FLOAT16:
+ return IMAGE_FORMAT_CLASS_2X16;
+
+ case MESA_FORMAT_R11_G11_B10_FLOAT:
+ return IMAGE_FORMAT_CLASS_10_11_11;
+
+ case MESA_FORMAT_R_FLOAT32:
+ return IMAGE_FORMAT_CLASS_1X32;
+
+ case MESA_FORMAT_R_FLOAT16:
+ return IMAGE_FORMAT_CLASS_1X16;
+
+ case MESA_FORMAT_RGBA_UINT32:
+ return IMAGE_FORMAT_CLASS_4X32;
+
+ case MESA_FORMAT_RGBA_UINT16:
+ return IMAGE_FORMAT_CLASS_4X16;
+
+ case MESA_FORMAT_ABGR2101010_UINT:
+ return IMAGE_FORMAT_CLASS_2_10_10_10;
+
+ case MESA_FORMAT_RGBA_UINT8:
+ return IMAGE_FORMAT_CLASS_4X8;
+
+ case MESA_FORMAT_RG_UINT32:
+ return IMAGE_FORMAT_CLASS_2X32;
+
+ case MESA_FORMAT_RG_UINT16:
+ return IMAGE_FORMAT_CLASS_2X16;
+
+ case MESA_FORMAT_RG_UINT8:
+ return IMAGE_FORMAT_CLASS_2X8;
+
+ case MESA_FORMAT_R_UINT32:
+ return IMAGE_FORMAT_CLASS_1X32;
+
+ case MESA_FORMAT_R_UINT16:
+ return IMAGE_FORMAT_CLASS_1X16;
+
+ case MESA_FORMAT_R_UINT8:
+ return IMAGE_FORMAT_CLASS_1X8;
+
+ case MESA_FORMAT_RGBA_INT32:
+ return IMAGE_FORMAT_CLASS_4X32;
+
+ case MESA_FORMAT_RGBA_INT16:
+ return IMAGE_FORMAT_CLASS_4X16;
+
+ case MESA_FORMAT_RGBA_INT8:
+ return IMAGE_FORMAT_CLASS_4X8;
+
+ case MESA_FORMAT_RG_INT32:
+ return IMAGE_FORMAT_CLASS_2X32;
+
+ case MESA_FORMAT_RG_INT16:
+ return IMAGE_FORMAT_CLASS_2X16;
+
+ case MESA_FORMAT_RG_INT8:
+ return IMAGE_FORMAT_CLASS_2X8;
+
+ case MESA_FORMAT_R_INT32:
+ return IMAGE_FORMAT_CLASS_1X32;
+
+ case MESA_FORMAT_R_INT16:
+ return IMAGE_FORMAT_CLASS_1X16;
+
+ case MESA_FORMAT_R_INT8:
+ return IMAGE_FORMAT_CLASS_1X8;
+
+ case MESA_FORMAT_RGBA_16:
+ return IMAGE_FORMAT_CLASS_4X16;
+
+ case MESA_FORMAT_ABGR2101010:
+ return IMAGE_FORMAT_CLASS_2_10_10_10;
+
+ case MESA_FORMAT_RGBA_8:
+ return IMAGE_FORMAT_CLASS_4X8;
+
+ case MESA_FORMAT_RG_16:
+ return IMAGE_FORMAT_CLASS_2X16;
+
+ case MESA_FORMAT_RG_8:
+ return IMAGE_FORMAT_CLASS_2X8;
+
+ case MESA_FORMAT_R16:
+ return IMAGE_FORMAT_CLASS_1X16;
+
+ case MESA_FORMAT_R8:
+ return IMAGE_FORMAT_CLASS_1X8;
+
+ case MESA_FORMAT_SIGNED_RGBA_16:
+ return IMAGE_FORMAT_CLASS_4X16;
+
+ case MESA_FORMAT_SIGNED_RGBA_8:
+ return IMAGE_FORMAT_CLASS_4X8;
+
+ case MESA_FORMAT_SIGNED_RG_16:
+ return IMAGE_FORMAT_CLASS_2X16;
+
+ case MESA_FORMAT_SIGNED_RG_8:
+ return IMAGE_FORMAT_CLASS_2X8;
+
+ case MESA_FORMAT_SIGNED_R16:
+ return IMAGE_FORMAT_CLASS_1X16;
+
+ case MESA_FORMAT_SIGNED_R8:
+ return IMAGE_FORMAT_CLASS_1X8;
+
+ default:
+ return IMAGE_FORMAT_CLASS_NONE;
+ }
+}
+
+static GLboolean
+validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u)
+{
+ struct gl_texture_object *t = u->TexObj;
+ struct gl_texture_image *img;
+
+ if (!t || u->Level < t->BaseLevel ||
+ u->Level > t->_MaxLevel)
+ return GL_FALSE;
+
+ _mesa_test_texobj_completeness(ctx, t);
+
+ if ((u->Level == t->BaseLevel && !t->_BaseComplete) ||
+ (u->Level != t->BaseLevel && !t->_MipmapComplete))
+ return GL_FALSE;
+
+ if (_mesa_tex_target_is_layered(t->Target) &&
+ u->Layer >= _mesa_get_texture_layers(t, u->Level))
+ return GL_FALSE;
+
+ if (t->Target == GL_TEXTURE_CUBE_MAP)
+ img = t->Image[u->Layer][u->Level];
+ else
+ img = t->Image[0][u->Level];
+
+ if (!img || img->Border ||
+ get_image_format_class(img->TexFormat) == IMAGE_FORMAT_CLASS_NONE ||
+ img->NumSamples > ctx->Const.MaxImageSamples)
+ return GL_FALSE;
+
+ switch (t->ImageFormatCompatibilityType) {
+ case GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE:
+ if (_mesa_get_format_bytes(img->TexFormat) !=
+ _mesa_get_format_bytes(u->_ActualFormat))
+ return GL_FALSE;
+ break;
+
+ case GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS:
+ if (get_image_format_class(img->TexFormat) !=
+ get_image_format_class(u->_ActualFormat))
+ return GL_FALSE;
+ break;
+
+ default:
+ assert(!"Unexpected image format compatibility type");
+ }
+
+ return GL_TRUE;
+}
+
+void
+_mesa_validate_image_units(struct gl_context *ctx)
+{
+ int i;
+
+ for (i = 0; i < ctx->Const.MaxImageUnits; ++i) {
+ struct gl_image_unit *u = &ctx->ImageUnits[i];
+ u->_Valid = validate_image_unit(ctx, u);
+ }
+}
+
+static GLboolean
+validate_bind_image_texture(struct gl_context *ctx, GLuint unit,
+ GLuint texture, GLint level, GLboolean layered,
+ GLint layer, GLenum access, GLenum format)
+{
+ assert(ctx->Const.MaxImageUnits <= MAX_IMAGE_UNITS);
+
+ if (unit >= ctx->Const.MaxImageUnits) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(unit)");
+ return GL_FALSE;
+ }
+
+ if (level < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(level)");
+ return GL_FALSE;
+ }
+
+ if (layer < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(layer)");
+ return GL_FALSE;
+ }
+
+ if (access != GL_READ_ONLY &&
+ access != GL_WRITE_ONLY &&
+ access != GL_READ_WRITE) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(access)");
+ return GL_FALSE;
+ }
+
+ if (!get_image_format(format)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(format)");
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+void GLAPIENTRY
+_mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
+ GLboolean layered, GLint layer, GLenum access,
+ GLenum format)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_object *t = NULL;
+ struct gl_image_unit *u;
+
+ if (!validate_bind_image_texture(ctx, unit, texture, level,
+ layered, layer, access, format))
+ return;
+
+ u = &ctx->ImageUnits[unit];
+
+ FLUSH_VERTICES(ctx, 0);
+ ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits;
+
+ if (texture) {
+ t = _mesa_lookup_texture(ctx, texture);
+ if (!t) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(texture)");
+ return;
+ }
+
+ _mesa_reference_texobj(&u->TexObj, t);
+ u->Level = level;
+ u->Access = access;
+ u->Format = format;
+ u->_ActualFormat = get_image_format(format);
+
+ if (_mesa_tex_target_is_layered(t->Target)) {
+ u->Layered = layered;
+ u->Layer = (layered ? 0 : layer);
+ } else {
+ u->Layered = GL_FALSE;
+ u->Layer = 0;
+ }
+
+ } else {
+ _mesa_reference_texobj(&u->TexObj, NULL);
+ }
+
+ u->_Valid = validate_image_unit(ctx, u);
+
+ if (ctx->Driver.BindImageTexture)
+ ctx->Driver.BindImageTexture(ctx, u, t, level, layered,
+ layer, access, format);
+}
+
+void GLAPIENTRY
+_mesa_MemoryBarrier(GLbitfield barriers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->Driver.MemoryBarrier)
+ ctx->Driver.MemoryBarrier(ctx, barriers);
+}
diff --git a/mesalib/src/mesa/main/shaderimage.h b/mesalib/src/mesa/main/shaderimage.h
new file mode 100644
index 000000000..aaecc5d29
--- /dev/null
+++ b/mesalib/src/mesa/main/shaderimage.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Francisco Jerez <currojerez@riseup.net>
+ */
+
+#ifndef SHADERIMAGE_H
+#define SHADERIMAGE_H
+
+#include "glheader.h"
+
+struct gl_context;
+
+/**
+ * Recalculate the \c _Valid flag of a context's shader image units.
+ *
+ * To be called when the state of any texture bound to an image unit
+ * changes.
+ */
+void
+_mesa_validate_image_units(struct gl_context *ctx);
+
+void GLAPIENTRY
+_mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
+ GLboolean layered, GLint layer, GLenum access,
+ GLenum format);
+
+void GLAPIENTRY
+_mesa_MemoryBarrier(GLbitfield barriers);
+
+#endif
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index 0d794ad96..dc81bbc77 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -110,6 +110,7 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
shader = rzalloc(NULL, struct gl_shader);
if (shader) {
shader->Type = type;
+ shader->Stage = _mesa_shader_enum_to_shader_stage(type);
shader->Name = name;
_mesa_init_shader(ctx, shader);
}
@@ -307,7 +308,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
struct gl_shader_program *shProg)
{
GLuint i;
- gl_shader_type sh;
+ gl_shader_stage sh;
assert(shProg->Type == GL_SHADER_PROGRAM_MESA);
@@ -346,7 +347,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
shProg->TransformFeedback.NumVarying = 0;
- for (sh = 0; sh < MESA_SHADER_TYPES; sh++) {
+ for (sh = 0; sh < MESA_SHADER_STAGES; sh++) {
if (shProg->_LinkedShaders[sh] != NULL) {
ctx->Driver.DeleteShader(ctx, shProg->_LinkedShaders[sh]);
shProg->_LinkedShaders[sh] = NULL;
diff --git a/mesalib/src/mesa/main/shaderobj.h b/mesalib/src/mesa/main/shaderobj.h
index 155058d71..517557088 100644
--- a/mesalib/src/mesa/main/shaderobj.h
+++ b/mesalib/src/mesa/main/shaderobj.h
@@ -101,8 +101,8 @@ extern void
_mesa_free_shader_state(struct gl_context *ctx);
-static inline gl_shader_type
-_mesa_shader_type_to_index(GLenum v)
+static inline gl_shader_stage
+_mesa_shader_enum_to_shader_stage(GLenum v)
{
switch (v) {
case GL_VERTEX_SHADER:
@@ -112,7 +112,7 @@ _mesa_shader_type_to_index(GLenum v)
case GL_GEOMETRY_SHADER:
return MESA_SHADER_GEOMETRY;
default:
- ASSERT(0 && "bad value in _mesa_shader_type_to_index()");
+ ASSERT(0 && "bad value in _mesa_shader_enum_to_shader_stage()");
return MESA_SHADER_VERTEX;
}
}
diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c
index e71d0c411..47ad30605 100644
--- a/mesalib/src/mesa/main/texcompress.c
+++ b/mesalib/src/mesa/main/texcompress.c
@@ -263,6 +263,43 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
else {
n += 3;
}
+
+ /* The ES and desktop GL specs diverge here.
+ *
+ * In desktop OpenGL, the driver can perform online compression of
+ * uncompressed texture data. GL_NUM_COMPRESSED_TEXTURE_FORMATS and
+ * GL_COMPRESSED_TEXTURE_FORMATS give the application a list of
+ * formats that it could ask the driver to compress with some
+ * expectation of quality. The GL_ARB_texture_compression spec
+ * calls this "suitable for general-purpose usage." As noted
+ * above, this means GL_COMPRESSED_RGBA_S3TC_DXT1_EXT is not
+ * included in the list.
+ *
+ * In OpenGL ES, the driver never performs compression.
+ * GL_NUM_COMPRESSED_TEXTURE_FORMATS and
+ * GL_COMPRESSED_TEXTURE_FORMATS give the application a list of
+ * formats that the driver can receive from the application. It
+ * is the *complete* list of formats. The
+ * GL_EXT_texture_compression_s3tc spec says:
+ *
+ * "New State for OpenGL ES 2.0.25 and 3.0.2 Specifications
+ *
+ * The queries for NUM_COMPRESSED_TEXTURE_FORMATS and
+ * COMPRESSED_TEXTURE_FORMATS include
+ * COMPRESSED_RGB_S3TC_DXT1_EXT,
+ * COMPRESSED_RGBA_S3TC_DXT1_EXT,
+ * COMPRESSED_RGBA_S3TC_DXT3_EXT, and
+ * COMPRESSED_RGBA_S3TC_DXT5_EXT."
+ *
+ * Note that the addition is only to the OpenGL ES specification!
+ */
+ if (_mesa_is_gles(ctx)) {
+ if (formats) {
+ formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ } else {
+ n += 1;
+ }
+ }
}
/* The GL_OES_compressed_ETC1_RGB8_texture spec says:
diff --git a/mesalib/src/mesa/main/texenv.c b/mesalib/src/mesa/main/texenv.c
index 1aadd7fde..4848208f5 100644
--- a/mesalib/src/mesa/main/texenv.c
+++ b/mesalib/src/mesa/main/texenv.c
@@ -879,7 +879,7 @@ _mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param )
}
else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) {
GLint count = 0;
- for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) {
+ for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) {
if (ctx->Const.SupportedBumpUnits & (1 << i)) {
count++;
}
@@ -887,7 +887,7 @@ _mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param )
*param = count;
}
else if (pname == GL_BUMP_TEX_UNITS_ATI) {
- for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) {
+ for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) {
if (ctx->Const.SupportedBumpUnits & (1 << i)) {
*param++ = i + GL_TEXTURE0;
}
@@ -928,7 +928,7 @@ _mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param )
}
else if (pname == GL_BUMP_NUM_TEX_UNITS_ATI) {
GLint count = 0;
- for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) {
+ for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) {
if (ctx->Const.SupportedBumpUnits & (1 << i)) {
count++;
}
@@ -936,7 +936,7 @@ _mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param )
*param = (GLfloat) count;
}
else if (pname == GL_BUMP_TEX_UNITS_ATI) {
- for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) {
+ for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) {
if (ctx->Const.SupportedBumpUnits & (1 << i)) {
*param++ = (GLfloat) (i + GL_TEXTURE0);
}
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 9c3f1e86e..8aac54e9d 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -1088,6 +1088,93 @@ _mesa_get_texture_dimensions(GLenum target)
/**
+ * Check if a texture target can have more than one layer.
+ */
+GLboolean
+_mesa_tex_target_is_layered(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_PROXY_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_BUFFER:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ case GL_TEXTURE_EXTERNAL_OES:
+ return GL_FALSE;
+
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_PROXY_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_PROXY_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return GL_TRUE;
+
+ default:
+ assert(!"Invalid texture target.");
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Return the number of layers present in the given level of an array,
+ * cubemap or 3D texture. If the texture is not layered return zero.
+ */
+GLuint
+_mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level)
+{
+ assert(level >= 0 && level < MAX_TEXTURE_LEVELS);
+
+ switch (texObj->Target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_BUFFER:
+ case GL_TEXTURE_EXTERNAL_OES:
+ return 0;
+
+ case GL_TEXTURE_CUBE_MAP:
+ return 6;
+
+ case GL_TEXTURE_1D_ARRAY: {
+ struct gl_texture_image *img = texObj->Image[0][level];
+ return img ? img->Height : 0;
+ }
+
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: {
+ struct gl_texture_image *img = texObj->Image[0][level];
+ return img ? img->Depth : 0;
+ }
+
+ default:
+ assert(!"Invalid texture target.");
+ return 0;
+ }
+}
+
+
+/**
* Return the maximum number of mipmap levels for the given target
* and the dimensions.
* The dimensions are expected not to include the border.
diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h
index 0b5786340..80a0a57b5 100644
--- a/mesalib/src/mesa/main/teximage.h
+++ b/mesalib/src/mesa/main/teximage.h
@@ -138,6 +138,12 @@ _mesa_tex_target_to_face(GLenum target);
extern GLint
_mesa_get_texture_dimensions(GLenum target);
+extern GLboolean
+_mesa_tex_target_is_layered(GLenum target);
+
+extern GLuint
+_mesa_get_texture_layers(const struct gl_texture_object *texObj, GLint level);
+
extern GLsizei
_mesa_get_tex_max_num_levels(GLenum target, GLsizei width, GLsizei height,
GLsizei depth);
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index d6510fefd..3c64c4376 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -157,6 +157,7 @@ _mesa_initialize_texture_object( struct gl_context *ctx,
obj->Sampler.sRGBDecode = GL_DECODE_EXT;
obj->BufferObjectFormat = GL_R8;
obj->_BufferObjectFormat = MESA_FORMAT_R8;
+ obj->ImageFormatCompatibilityType = GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE;
}
@@ -1099,6 +1100,25 @@ unbind_texobj_from_texunits(struct gl_context *ctx,
/**
+ * Check if the given texture object is bound to any shader image unit
+ * and unbind it if that's the case.
+ */
+static void
+unbind_texobj_from_imgunits(struct gl_context *ctx,
+ struct gl_texture_object *texObj)
+{
+ int i;
+
+ for (i = 0; i < ctx->Const.MaxImageUnits; i++) {
+ struct gl_image_unit *unit = &ctx->ImageUnits[i];
+
+ if (texObj == unit->TexObj)
+ _mesa_reference_texobj(&unit->TexObj, NULL);
+ }
+}
+
+
+/**
* Delete named textures.
*
* \param n number of textures to be deleted.
@@ -1145,6 +1165,12 @@ _mesa_DeleteTextures( GLsizei n, const GLuint *textures)
*/
unbind_texobj_from_texunits(ctx, delObj);
+ /* Check if this texture is currently bound to any shader
+ * image unit. If so, unbind it.
+ * See section 3.9.X of GL_ARB_shader_image_load_store.
+ */
+ unbind_texobj_from_imgunits(ctx, delObj);
+
_mesa_unlock_texture(ctx, delObj);
ctx->NewState |= _NEW_TEXTURE;
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index 94e498d20..7c59d119f 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -1808,6 +1808,12 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
*params = obj->Sampler.sRGBDecode;
break;
+ case GL_IMAGE_FORMAT_COMPATIBILITY_TYPE:
+ if (!ctx->Extensions.ARB_shader_image_load_store)
+ goto invalid_pname;
+ *params = obj->ImageFormatCompatibilityType;
+ break;
+
default:
goto invalid_pname;
}
diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c
index ad80dcfaa..7720965a8 100644
--- a/mesalib/src/mesa/main/texstate.c
+++ b/mesalib/src/mesa/main/texstate.c
@@ -35,6 +35,7 @@
#include "context.h"
#include "enums.h"
#include "macros.h"
+#include "shaderimage.h"
#include "texobj.h"
#include "teximage.h"
#include "texstate.h"
@@ -674,6 +675,8 @@ update_texture_state( struct gl_context *ctx )
if (!fprog || !vprog)
update_texgen(ctx);
+
+ _mesa_validate_image_units(ctx);
}
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 5adbd5dc9..8eaf43a6a 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -2191,6 +2191,7 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS)
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL88 ||
+ dstFormat == MESA_FORMAT_SIGNED_RG88 ||
dstFormat == MESA_FORMAT_SIGNED_RG88_REV);
ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
@@ -2210,13 +2211,27 @@ _mesa_texstore_snorm88(TEXSTORE_PARAMS)
for (img = 0; img < srcDepth; img++) {
GLbyte *dstRow = (GLbyte *) dstSlices[img];
for (row = 0; row < srcHeight; row++) {
- GLbyte *dst = dstRow;
- for (col = 0; col < srcWidth; col++) {
- dst[0] = FLOAT_TO_BYTE_TEX(src[0]);
- dst[1] = FLOAT_TO_BYTE_TEX(src[1]);
- src += 2;
- dst += 2;
+ GLushort *dst = (GLushort *) dstRow;
+
+ if (dstFormat == MESA_FORMAT_SIGNED_AL88 ||
+ dstFormat == MESA_FORMAT_SIGNED_RG88_REV) {
+ for (col = 0; col < srcWidth; col++) {
+ GLubyte l = FLOAT_TO_BYTE_TEX(src[0]);
+ GLubyte a = FLOAT_TO_BYTE_TEX(src[1]);
+
+ dst[col] = PACK_COLOR_88_REV(l, a);
+ src += 2;
+ }
+ } else {
+ for (col = 0; col < srcWidth; col++) {
+ GLubyte l = FLOAT_TO_BYTE_TEX(src[0]);
+ GLubyte a = FLOAT_TO_BYTE_TEX(src[1]);
+
+ dst[col] = PACK_COLOR_88(l, a);
+ src += 2;
+ }
}
+
dstRow += dstRowStride;
}
}
@@ -2278,6 +2293,7 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS)
const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
ASSERT(dstFormat == MESA_FORMAT_SIGNED_AL1616 ||
+ dstFormat == MESA_FORMAT_SIGNED_RG1616 ||
dstFormat == MESA_FORMAT_SIGNED_GR1616);
ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
@@ -2297,17 +2313,29 @@ _mesa_texstore_snorm1616(TEXSTORE_PARAMS)
for (img = 0; img < srcDepth; img++) {
GLubyte *dstRow = dstSlices[img];
for (row = 0; row < srcHeight; row++) {
- GLshort *dst = (GLshort *) dstRow;
- for (col = 0; col < srcWidth; col++) {
- GLushort l, a;
+ GLuint *dst = (GLuint *) dstRow;
- UNCLAMPED_FLOAT_TO_SHORT(l, src[0]);
- UNCLAMPED_FLOAT_TO_SHORT(a, src[1]);
- dst[0] = l;
- dst[1] = a;
- src += 2;
- dst += 2;
+ if (dstFormat == MESA_FORMAT_SIGNED_AL1616 ||
+ dstFormat == MESA_FORMAT_SIGNED_GR1616) {
+ for (col = 0; col < srcWidth; col++) {
+ GLushort l, a;
+
+ UNCLAMPED_FLOAT_TO_SHORT(l, src[0]);
+ UNCLAMPED_FLOAT_TO_SHORT(a, src[1]);
+ dst[col] = PACK_COLOR_1616_REV(l, a);
+ src += 2;
+ }
+ } else {
+ for (col = 0; col < srcWidth; col++) {
+ GLushort l, a;
+
+ UNCLAMPED_FLOAT_TO_SHORT(l, src[0]);
+ UNCLAMPED_FLOAT_TO_SHORT(a, src[1]);
+ dst[col] = PACK_COLOR_1616_REV(l, a);
+ src += 2;
+ }
}
+
dstRow += dstRowStride;
}
}
@@ -3559,6 +3587,50 @@ _mesa_texstore_abgr2101010_uint(TEXSTORE_PARAMS)
}
static GLboolean
+_mesa_texstore_abgr2101010(TEXSTORE_PARAMS)
+{
+ const GLenum baseFormat = _mesa_get_format_base_format(dstFormat);
+
+ ASSERT(dstFormat == MESA_FORMAT_ABGR2101010);
+ ASSERT(_mesa_get_format_bytes(dstFormat) == 4);
+
+ {
+ /* general path */
+ const GLfloat *tempImage = _mesa_make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ baseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking,
+ ctx->_ImageTransferState);
+ const GLfloat *src = tempImage;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstSlices[img];
+
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ GLushort a,r,g,b;
+
+ UNCLAMPED_FLOAT_TO_USHORT(a, src[ACOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(r, src[RCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(g, src[GCOMP]);
+ UNCLAMPED_FLOAT_TO_USHORT(b, src[BCOMP]);
+ dstUI[col] = PACK_COLOR_2101010_US(a, b, g, r);
+ src += 4;
+ }
+ dstRow += dstRowStride;
+ }
+ }
+ free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+static GLboolean
_mesa_texstore_null(TEXSTORE_PARAMS)
{
(void) ctx; (void) dims;
@@ -3782,6 +3854,11 @@ _mesa_get_texstore_func(gl_format format)
table[MESA_FORMAT_XBGR32323232_UINT] = _mesa_texstore_rgba_uint32;
table[MESA_FORMAT_XBGR32323232_SINT] = _mesa_texstore_rgba_int32;
+ table[MESA_FORMAT_ABGR2101010] = _mesa_texstore_abgr2101010;
+
+ table[MESA_FORMAT_SIGNED_RG88] = _mesa_texstore_snorm88;
+ table[MESA_FORMAT_SIGNED_RG1616] = _mesa_texstore_snorm1616;
+
initialized = GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index 61bcbcb8a..82d7628e8 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -445,14 +445,14 @@ log_uniform(const void *values, enum glsl_base_type basicType,
static void
log_program_parameters(const struct gl_shader_program *shProg)
{
- for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (shProg->_LinkedShaders[i] == NULL)
continue;
const struct gl_program *const prog = shProg->_LinkedShaders[i]->Program;
printf("Program %d %s shader parameters:\n",
- shProg->Name, _mesa_shader_enum_to_string(prog->Target));
+ shProg->Name, _mesa_shader_stage_to_string(i));
for (unsigned j = 0; j < prog->Parameters->NumParameters; j++) {
printf("%s: %p %f %f %f %f\n",
prog->Parameters->Parameters[j].Name,
@@ -784,7 +784,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
int i;
bool flushed = false;
- for (i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_shader *const sh = shProg->_LinkedShaders[i];
int j;
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index 17e24f678..071d668f3 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -68,7 +68,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
{
GLuint s;
struct gl_shader *shader =
- shProg->_LinkedShaders[_mesa_program_target_to_index(prog->Target)];
+ shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)];
assert(shader);
@@ -642,7 +642,7 @@ _mesa_UniformBlockBinding(GLuint program,
shProg->UniformBlocks[uniformBlockIndex].Binding = uniformBlockBinding;
- for (i = 0; i < MESA_SHADER_TYPES; i++) {
+ for (i = 0; i < MESA_SHADER_STAGES; i++) {
int stage_index = shProg->UniformBlockStageIndex[i][uniformBlockIndex];
if (stage_index != -1) {
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index 0f38270d5..b73a396e2 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -621,7 +621,7 @@ _mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
UNSIGNED_INT_10F_11F_11F_REV_BIT);
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
return;
}
@@ -649,7 +649,7 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
const GLboolean integer = GL_TRUE;
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribIPointer(index)");
return;
}
@@ -667,7 +667,7 @@ _mesa_EnableVertexAttribArray(GLuint index)
struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glEnableVertexAttribArrayARB(index)");
return;
@@ -693,7 +693,7 @@ _mesa_DisableVertexAttribArray(GLuint index)
struct gl_array_object *arrayObj;
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glDisableVertexAttribArrayARB(index)");
return;
@@ -725,7 +725,7 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
const struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
const struct gl_vertex_attrib_array *array;
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "%s(index=%u)", caller, index);
return 0;
}
@@ -795,7 +795,7 @@ get_current_attrib(struct gl_context *ctx, GLuint index, const char *function)
return NULL;
}
}
- else if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ else if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"%s(index>=GL_MAX_VERTEX_ATTRIBS)", function);
return NULL;
@@ -913,7 +913,7 @@ _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer)
{
GET_CURRENT_CONTEXT(ctx);
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)");
return;
}
@@ -1308,7 +1308,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
return;
}
- if (index >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribDivisor(index = %u)",
index);
return;
@@ -1479,7 +1479,7 @@ _mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
* "The error INVALID_VALUE is generated if index is greater than or equal
* to the value of MAX_VERTEX_ATTRIBS."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribFormat(attribindex=%u > "
"GL_MAX_VERTEX_ATTRIBS)",
@@ -1526,7 +1526,7 @@ _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
* "The error INVALID_VALUE is generated if index is greater than
* or equal to the value of MAX_VERTEX_ATTRIBS."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribIFormat(attribindex=%u > "
"GL_MAX_VERTEX_ATTRIBS)",
@@ -1574,7 +1574,7 @@ _mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
* "The error INVALID_VALUE is generated if <attribindex> is greater than
* or equal to the value of MAX_VERTEX_ATTRIBS."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribLFormat(attribindex=%u > "
"GL_MAX_VERTEX_ATTRIBS)",
@@ -1616,7 +1616,7 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
* MAX_VERTEX_ATTRIB_BINDINGS, otherwise the error INVALID_VALUE
* is generated."
*/
- if (attribIndex >= ctx->Const.VertexProgram.MaxAttribs) {
+ if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
"glVertexAttribBinding(attribindex=%u >= "
"GL_MAX_VERTEX_ATTRIBS)",
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 119c7dae3..587cb9ad5 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -255,7 +255,7 @@ compute_version(struct gl_context *ctx)
ctx->Extensions.EXT_texture_snorm &&
ctx->Extensions.NV_primitive_restart &&
ctx->Extensions.NV_texture_rectangle &&
- ctx->Const.VertexProgram.MaxTextureImageUnits >= 16);
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits >= 16);
const GLboolean ver_3_2 = (ver_3_1 &&
ctx->Const.GLSLVersion >= 150 &&
ctx->Extensions.ARB_depth_clamp &&
diff --git a/mesalib/src/mesa/main/viewport.c b/mesalib/src/mesa/main/viewport.c
index 91578ba9d..3aaab2d46 100644
--- a/mesalib/src/mesa/main/viewport.c
+++ b/mesalib/src/mesa/main/viewport.c
@@ -99,7 +99,7 @@ _mesa_set_viewport(struct gl_context *ctx, GLint x, GLint y,
/* Many drivers will use this call to check for window size changes
* and reallocate the z/stencil/accum/etc buffers if needed.
*/
- ctx->Driver.Viewport(ctx, x, y, width, height);
+ ctx->Driver.Viewport(ctx);
}
}
@@ -143,7 +143,7 @@ _mesa_DepthRange(GLclampd nearval, GLclampd farval)
#endif
if (ctx->Driver.DepthRange) {
- ctx->Driver.DepthRange(ctx, nearval, farval);
+ ctx->Driver.DepthRange(ctx);
}
}