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/.gitignore4
-rw-r--r--mesalib/src/mesa/main/api_arrayelt.c6
-rw-r--r--mesalib/src/mesa/main/api_exec.h7
-rw-r--r--mesalib/src/mesa/main/api_loopback.h8
-rw-r--r--mesalib/src/mesa/main/arbprogram.c12
-rw-r--r--mesalib/src/mesa/main/arrayobj.c16
-rw-r--r--mesalib/src/mesa/main/atifragshader.c2
-rw-r--r--mesalib/src/mesa/main/atifragshader.h3
-rw-r--r--mesalib/src/mesa/main/attrib.c2
-rw-r--r--mesalib/src/mesa/main/attrib.h1
-rw-r--r--mesalib/src/mesa/main/blend.c4
-rw-r--r--mesalib/src/mesa/main/blit.c5
-rw-r--r--mesalib/src/mesa/main/blit.h1
-rw-r--r--mesalib/src/mesa/main/bufferobj.c58
-rw-r--r--mesalib/src/mesa/main/buffers.c4
-rw-r--r--mesalib/src/mesa/main/clear.c2
-rw-r--r--mesalib/src/mesa/main/colortab.h2
-rw-r--r--mesalib/src/mesa/main/compiler.h192
-rw-r--r--mesalib/src/mesa/main/condrender.c4
-rw-r--r--mesalib/src/mesa/main/context.c11
-rw-r--r--mesalib/src/mesa/main/convolve.h2
-rw-r--r--mesalib/src/mesa/main/cpuinfo.c2
-rw-r--r--mesalib/src/mesa/main/dd.h2
-rw-r--r--mesalib/src/mesa/main/debug.c14
-rw-r--r--mesalib/src/mesa/main/dlist.c21
-rw-r--r--mesalib/src/mesa/main/dlist.h2
-rw-r--r--mesalib/src/mesa/main/drawpix.c6
-rw-r--r--mesalib/src/mesa/main/drawpix.h4
-rw-r--r--mesalib/src/mesa/main/drawtex.c2
-rw-r--r--mesalib/src/mesa/main/enable.c2
-rw-r--r--mesalib/src/mesa/main/errors.c12
-rw-r--r--mesalib/src/mesa/main/es1_conversion.c16
-rw-r--r--mesalib/src/mesa/main/eval.c10
-rw-r--r--mesalib/src/mesa/main/execmem.c1
-rw-r--r--mesalib/src/mesa/main/fbobject.c38
-rw-r--r--mesalib/src/mesa/main/ffvertex_prog.c6
-rw-r--r--mesalib/src/mesa/main/format_unpack.py8
-rw-r--r--mesalib/src/mesa/main/formats.c8
-rw-r--r--mesalib/src/mesa/main/framebuffer.c22
-rw-r--r--mesalib/src/mesa/main/get.c16
-rw-r--r--mesalib/src/mesa/main/hash.c10
-rw-r--r--mesalib/src/mesa/main/histogram.h3
-rw-r--r--mesalib/src/mesa/main/image.c74
-rw-r--r--mesalib/src/mesa/main/imports.c9
-rw-r--r--mesalib/src/mesa/main/imports.h111
-rw-r--r--mesalib/src/mesa/main/light.c23
-rw-r--r--mesalib/src/mesa/main/macros.h40
-rw-r--r--mesalib/src/mesa/main/matrix.c10
-rw-r--r--mesalib/src/mesa/main/mipmap.c20
-rw-r--r--mesalib/src/mesa/main/mtypes.h1
-rw-r--r--mesalib/src/mesa/main/multisample.c7
-rw-r--r--mesalib/src/mesa/main/pack.c23
-rw-r--r--mesalib/src/mesa/main/pbo.c8
-rw-r--r--mesalib/src/mesa/main/pipelineobj.c6
-rw-r--r--mesalib/src/mesa/main/pixel.h2
-rw-r--r--mesalib/src/mesa/main/points.c4
-rw-r--r--mesalib/src/mesa/main/queryobj.c29
-rw-r--r--mesalib/src/mesa/main/rastpos.c4
-rw-r--r--mesalib/src/mesa/main/rastpos.h3
-rw-r--r--mesalib/src/mesa/main/readpix.c13
-rw-r--r--mesalib/src/mesa/main/remap.c4
-rw-r--r--mesalib/src/mesa/main/remap.h2
-rw-r--r--mesalib/src/mesa/main/renderbuffer.c2
-rw-r--r--mesalib/src/mesa/main/samplerobj.c6
-rw-r--r--mesalib/src/mesa/main/shaderapi.c40
-rw-r--r--mesalib/src/mesa/main/shaderobj.c4
-rw-r--r--mesalib/src/mesa/main/shaderobj.h2
-rw-r--r--mesalib/src/mesa/main/shared.c8
-rw-r--r--mesalib/src/mesa/main/state.c2
-rw-r--r--mesalib/src/mesa/main/stencil.h1
-rw-r--r--mesalib/src/mesa/main/texcompress.c4
-rw-r--r--mesalib/src/mesa/main/texcompress_bptc.c4
-rw-r--r--mesalib/src/mesa/main/texcompress_cpal.c3
-rw-r--r--mesalib/src/mesa/main/texcompress_etc.c22
-rw-r--r--mesalib/src/mesa/main/texcompress_fxt1.c14
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.c8
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.c8
-rw-r--r--mesalib/src/mesa/main/texcompress_s3tc.h1
-rw-r--r--mesalib/src/mesa/main/texformat.c8
-rw-r--r--mesalib/src/mesa/main/texgen.h1
-rw-r--r--mesalib/src/mesa/main/texgetimage.c3
-rw-r--r--mesalib/src/mesa/main/teximage.c211
-rw-r--r--mesalib/src/mesa/main/teximage.h3
-rw-r--r--mesalib/src/mesa/main/texobj.c15
-rw-r--r--mesalib/src/mesa/main/texparam.c6
-rw-r--r--mesalib/src/mesa/main/texstate.c32
-rw-r--r--mesalib/src/mesa/main/texstate.h2
-rw-r--r--mesalib/src/mesa/main/texstorage.c2
-rw-r--r--mesalib/src/mesa/main/texstore.c58
-rw-r--r--mesalib/src/mesa/main/transformfeedback.c10
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp2
-rw-r--r--mesalib/src/mesa/main/uniforms.c4
-rw-r--r--mesalib/src/mesa/main/varray.c19
-rw-r--r--mesalib/src/mesa/main/version.c1
-rw-r--r--mesalib/src/mesa/main/vtxfmt.h9
95 files changed, 680 insertions, 779 deletions
diff --git a/mesalib/src/mesa/main/.gitignore b/mesalib/src/mesa/main/.gitignore
index e65472d63..8256ad792 100644
--- a/mesalib/src/mesa/main/.gitignore
+++ b/mesalib/src/mesa/main/.gitignore
@@ -1,13 +1,11 @@
api_exec.c
dispatch.h
enums.c
-get_es1.c
-get_es2.c
git_sha1.h
git_sha1.h.tmp
remap_helper.h
get_hash.h
get_hash.h.tmp
-format_info.c
+format_info.h
format_pack.c
format_unpack.c
diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c
index 536326f6e..ea015fd65 100644
--- a/mesalib/src/mesa/main/api_arrayelt.c
+++ b/mesalib/src/mesa/main/api_arrayelt.c
@@ -1548,7 +1548,7 @@ _ae_update_state(struct gl_context *ctx)
*/
at->array = attribArray;
at->binding = &vao->VertexBinding[attribArray->VertexBinding];
- ASSERT(!at->array->Normalized);
+ assert(!at->array->Normalized);
at->func = AttribFuncsNV[at->array->Normalized]
[at->array->Size-1]
[TYPE_IDX(at->array->Type)];
@@ -1610,8 +1610,8 @@ _ae_update_state(struct gl_context *ctx)
check_vbo(actx, vao->IndexBufferObj);
- ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
- ASSERT(aa - actx->arrays < 32);
+ assert(at - actx->attribs <= VERT_ATTRIB_MAX);
+ assert(aa - actx->arrays < 32);
at->func = NULL; /* terminate the list */
aa->offset = -1; /* terminate the list */
diff --git a/mesalib/src/mesa/main/api_exec.h b/mesalib/src/mesa/main/api_exec.h
index ff35b78bb..1e4a9d61a 100644
--- a/mesalib/src/mesa/main/api_exec.h
+++ b/mesalib/src/mesa/main/api_exec.h
@@ -26,6 +26,9 @@
#ifndef API_EXEC_H
#define API_EXEC_H
+#ifdef __cplusplus
+extern "C" {
+#endif
struct _glapi_table;
struct gl_context;
@@ -39,4 +42,8 @@ _mesa_initialize_exec_table(struct gl_context *ctx);
extern void
_mesa_initialize_dispatch_tables(struct gl_context *ctx);
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif
diff --git a/mesalib/src/mesa/main/api_loopback.h b/mesalib/src/mesa/main/api_loopback.h
index 2195e01e3..44514405b 100644
--- a/mesalib/src/mesa/main/api_loopback.h
+++ b/mesalib/src/mesa/main/api_loopback.h
@@ -27,13 +27,7 @@
#ifndef API_LOOPBACK_H
#define API_LOOPBACK_H
-#include "main/compiler.h"
-#include "main/glheader.h" // ?
-#include "main/macros.h" // ?
-#include "main/mtypes.h" // ?
-#include "glapi/glapi.h" // ?
-#include "main/dispatch.h" // ?
-#include "main/context.h" // ?
+#include "main/glheader.h"
struct _glapi_table;
struct gl_context;
diff --git a/mesalib/src/mesa/main/arbprogram.c b/mesalib/src/mesa/main/arbprogram.c
index fe8cd6bbc..f474951d7 100644
--- a/mesalib/src/mesa/main/arbprogram.c
+++ b/mesalib/src/mesa/main/arbprogram.c
@@ -118,8 +118,8 @@ _mesa_BindProgramARB(GLenum target, GLuint id)
}
/* Never null pointers */
- ASSERT(ctx->VertexProgram.Current);
- ASSERT(ctx->FragmentProgram.Current);
+ assert(ctx->VertexProgram.Current);
+ assert(ctx->FragmentProgram.Current);
if (ctx->Driver.BindProgram)
ctx->Driver.BindProgram(ctx, target, newProg);
@@ -524,7 +524,7 @@ _mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
if (get_local_param_pointer(ctx, "glProgramLocalParameterARB",
target, index, &param)) {
- ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
+ assert(index < MAX_PROGRAM_LOCAL_PARAMS);
ASSIGN_4V(param, x, y, z, w);
}
}
@@ -639,8 +639,8 @@ _mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
return;
}
- ASSERT(prog);
- ASSERT(limits);
+ assert(prog);
+ assert(limits);
/* Queries supported for both vertex and fragment programs */
switch (pname) {
@@ -817,7 +817,7 @@ _mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string)
return;
}
- ASSERT(prog);
+ assert(prog);
if (pname != GL_PROGRAM_STRING_ARB) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(pname)");
diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c
index 6440ea670..3c8ffb5a4 100644
--- a/mesalib/src/mesa/main/arrayobj.c
+++ b/mesalib/src/mesa/main/arrayobj.c
@@ -84,10 +84,10 @@ unbind_array_object_vbos(struct gl_context *ctx, struct gl_vertex_array_object *
{
GLuint i;
- for (i = 0; i < Elements(obj->VertexBinding); i++)
+ for (i = 0; i < ARRAY_SIZE(obj->VertexBinding); i++)
_mesa_reference_buffer_object(ctx, &obj->VertexBinding[i].BufferObj, NULL);
- for (i = 0; i < Elements(obj->_VertexAttrib); i++)
+ for (i = 0; i < ARRAY_SIZE(obj->_VertexAttrib); i++)
_mesa_reference_buffer_object(ctx, &obj->_VertexAttrib[i].BufferObj, NULL);
}
@@ -143,7 +143,7 @@ _mesa_reference_vao_(struct gl_context *ctx,
struct gl_vertex_array_object *oldObj = *ptr;
mtx_lock(&oldObj->Mutex);
- ASSERT(oldObj->RefCount > 0);
+ assert(oldObj->RefCount > 0);
oldObj->RefCount--;
#if 0
printf("ArrayObj %p %d DECR to %d\n",
@@ -153,13 +153,13 @@ _mesa_reference_vao_(struct gl_context *ctx,
mtx_unlock(&oldObj->Mutex);
if (deleteFlag) {
- ASSERT(ctx->Driver.DeleteArrayObject);
+ assert(ctx->Driver.DeleteArrayObject);
ctx->Driver.DeleteArrayObject(ctx, oldObj);
}
*ptr = NULL;
}
- ASSERT(!*ptr);
+ assert(!*ptr);
if (vao) {
/* reference new array object */
@@ -230,7 +230,7 @@ _mesa_initialize_vao(struct gl_context *ctx,
obj->RefCount = 1;
/* Init the individual arrays */
- for (i = 0; i < Elements(obj->VertexAttrib); i++) {
+ for (i = 0; i < ARRAY_SIZE(obj->VertexAttrib); i++) {
switch (i) {
case VERT_ATTRIB_WEIGHT:
init_array(ctx, obj, VERT_ATTRIB_WEIGHT, 1, GL_FLOAT);
@@ -335,7 +335,7 @@ bind_vertex_array(struct gl_context *ctx, GLuint id, GLboolean genRequired)
struct gl_vertex_array_object * const oldObj = ctx->Array.VAO;
struct gl_vertex_array_object *newObj = NULL;
- ASSERT(oldObj != NULL);
+ assert(oldObj != NULL);
if ( oldObj->Name == id )
return; /* rebinding the same array object- no change */
@@ -456,7 +456,7 @@ _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids)
struct gl_vertex_array_object *obj = _mesa_lookup_vao(ctx, ids[i]);
if ( obj != NULL ) {
- ASSERT( obj->Name == ids[i] );
+ assert( obj->Name == ids[i] );
/* If the array object is currently bound, the spec says "the binding
* for that object reverts to zero and the default vertex array
diff --git a/mesalib/src/mesa/main/atifragshader.c b/mesalib/src/mesa/main/atifragshader.c
index 1eab7731a..9d967b9e6 100644
--- a/mesalib/src/mesa/main/atifragshader.c
+++ b/mesalib/src/mesa/main/atifragshader.c
@@ -255,7 +255,7 @@ _mesa_BindFragmentShaderATI(GLuint id)
/* do actual bind */
ctx->ATIFragmentShader.Current = newProg;
- ASSERT(ctx->ATIFragmentShader.Current);
+ assert(ctx->ATIFragmentShader.Current);
if (newProg)
newProg->RefCount++;
diff --git a/mesalib/src/mesa/main/atifragshader.h b/mesalib/src/mesa/main/atifragshader.h
index afaea009d..590113410 100644
--- a/mesalib/src/mesa/main/atifragshader.h
+++ b/mesalib/src/mesa/main/atifragshader.h
@@ -8,10 +8,9 @@
#ifndef ATIFRAGSHADER_H
#define ATIFRAGSHADER_H
-#include "compiler.h"
#include "glheader.h"
-struct _glapi_table;
+
struct gl_context;
#define MAX_NUM_INSTRUCTIONS_PER_PASS_ATI 8
diff --git a/mesalib/src/mesa/main/attrib.c b/mesalib/src/mesa/main/attrib.c
index 07934b9bc..20216a87d 100644
--- a/mesalib/src/mesa/main/attrib.c
+++ b/mesalib/src/mesa/main/attrib.c
@@ -1453,7 +1453,7 @@ copy_array_object(struct gl_context *ctx,
/* In theory must be the same anyway, but on recreate make sure it matches */
dest->ARBsemantics = src->ARBsemantics;
- for (i = 0; i < Elements(src->VertexAttrib); i++) {
+ for (i = 0; i < ARRAY_SIZE(src->VertexAttrib); i++) {
_mesa_copy_client_array(ctx, &dest->_VertexAttrib[i], &src->_VertexAttrib[i]);
_mesa_copy_vertex_attrib_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]);
_mesa_copy_vertex_buffer_binding(ctx, &dest->VertexBinding[i], &src->VertexBinding[i]);
diff --git a/mesalib/src/mesa/main/attrib.h b/mesalib/src/mesa/main/attrib.h
index 44413a6e8..f4fd4929f 100644
--- a/mesalib/src/mesa/main/attrib.h
+++ b/mesalib/src/mesa/main/attrib.h
@@ -26,7 +26,6 @@
#define ATTRIB_H
-#include "compiler.h"
#include "glheader.h"
struct _glapi_table;
diff --git a/mesalib/src/mesa/main/blend.c b/mesalib/src/mesa/main/blend.c
index c37c0fea5..774fc888e 100644
--- a/mesalib/src/mesa/main/blend.c
+++ b/mesalib/src/mesa/main/blend.c
@@ -799,7 +799,7 @@ get_clamp_color(const struct gl_framebuffer *fb, GLenum clamp)
if (clamp == GL_TRUE || clamp == GL_FALSE)
return clamp;
- ASSERT(clamp == GL_FIXED_ONLY);
+ assert(clamp == GL_FIXED_ONLY);
if (!fb)
return GL_TRUE;
@@ -896,7 +896,7 @@ void _mesa_init_color( struct gl_context * ctx )
ctx->Color.AlphaFunc = GL_ALWAYS;
ctx->Color.AlphaRef = 0;
ctx->Color.BlendEnabled = 0x0;
- for (i = 0; i < Elements(ctx->Color.Blend); i++) {
+ for (i = 0; i < ARRAY_SIZE(ctx->Color.Blend); i++) {
ctx->Color.Blend[i].SrcRGB = GL_ONE;
ctx->Color.Blend[i].DstRGB = GL_ZERO;
ctx->Color.Blend[i].SrcA = GL_ONE;
diff --git a/mesalib/src/mesa/main/blit.c b/mesalib/src/mesa/main/blit.c
index b97b56479..0694466eb 100644
--- a/mesalib/src/mesa/main/blit.c
+++ b/mesalib/src/mesa/main/blit.c
@@ -28,6 +28,7 @@
*/
#include <stdbool.h>
+#include <stdio.h>
#include "context.h"
#include "enums.h"
@@ -48,7 +49,7 @@ find_attachment(const struct gl_framebuffer *fb,
const struct gl_renderbuffer *rb)
{
GLuint i;
- for (i = 0; i < Elements(fb->Attachment); i++) {
+ for (i = 0; i < ARRAY_SIZE(fb->Attachment); i++) {
if (fb->Attachment[i].Renderbuffer == rb)
return &fb->Attachment[i];
}
@@ -505,7 +506,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
return;
}
- ASSERT(ctx->Driver.BlitFramebuffer);
+ assert(ctx->Driver.BlitFramebuffer);
ctx->Driver.BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
diff --git a/mesalib/src/mesa/main/blit.h b/mesalib/src/mesa/main/blit.h
index 533d6e5d1..01a958af5 100644
--- a/mesalib/src/mesa/main/blit.h
+++ b/mesalib/src/mesa/main/blit.h
@@ -26,7 +26,6 @@
#ifndef BLIT_H
#define BLIT_H
-#include "compiler.h"
#include "glheader.h"
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index b372c68f2..e1c587779 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -446,7 +446,7 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
struct gl_buffer_object *oldObj = *ptr;
mtx_lock(&oldObj->Mutex);
- ASSERT(oldObj->RefCount > 0);
+ assert(oldObj->RefCount > 0);
oldObj->RefCount--;
#if 0
printf("BufferObj %p %d DECR to %d\n",
@@ -460,18 +460,18 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
/* some sanity checking: don't delete a buffer still in use */
#if 0
/* unfortunately, these tests are invalid during context tear-down */
- ASSERT(ctx->Array.ArrayBufferObj != bufObj);
- ASSERT(ctx->Array.VAO->IndexBufferObj != bufObj);
- ASSERT(ctx->Array.VAO->Vertex.BufferObj != bufObj);
+ assert(ctx->Array.ArrayBufferObj != bufObj);
+ assert(ctx->Array.VAO->IndexBufferObj != bufObj);
+ assert(ctx->Array.VAO->Vertex.BufferObj != bufObj);
#endif
- ASSERT(ctx->Driver.DeleteBuffer);
+ assert(ctx->Driver.DeleteBuffer);
ctx->Driver.DeleteBuffer(ctx, oldObj);
}
*ptr = NULL;
}
- ASSERT(!*ptr);
+ assert(!*ptr);
if (bufObj) {
/* reference new buffer */
@@ -614,7 +614,7 @@ _mesa_buffer_subdata( struct gl_context *ctx, GLintptrARB offset,
(void) ctx;
/* this should have been caught in _mesa_BufferSubData() */
- ASSERT(size + offset <= bufObj->Size);
+ assert(size + offset <= bufObj->Size);
if (bufObj->Data) {
memcpy( (GLubyte *) bufObj->Data + offset, data, size );
@@ -679,7 +679,7 @@ _mesa_buffer_clear_subdata(struct gl_context *ctx,
GLsizeiptr i;
GLubyte *dest;
- ASSERT(ctx->Driver.MapBufferRange);
+ assert(ctx->Driver.MapBufferRange);
dest = ctx->Driver.MapBufferRange(ctx, offset, size,
GL_MAP_WRITE_BIT |
GL_MAP_INVALIDATE_RANGE_BIT,
@@ -908,7 +908,7 @@ _mesa_handle_bind_buffer_gen(struct gl_context *ctx,
/* If this is a new buffer object id, or one which was generated but
* never used before, allocate a buffer object now.
*/
- ASSERT(ctx->Driver.NewBufferObject);
+ assert(ctx->Driver.NewBufferObject);
buf = ctx->Driver.NewBufferObject(ctx, buffer);
if (!buf) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", caller);
@@ -1124,7 +1124,7 @@ _mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
for (i = 0; i < MAP_COUNT; i++) {
if (_mesa_bufferobj_mapped(bufObj, i)) {
ctx->Driver.UnmapBuffer(ctx, bufObj, i);
- ASSERT(bufObj->Mappings[i].Pointer == NULL);
+ assert(bufObj->Mappings[i].Pointer == NULL);
bufObj->Mappings[i].AccessFlags = 0;
}
}
@@ -1174,12 +1174,12 @@ _mesa_DeleteBuffers(GLsizei n, const GLuint *ids)
struct gl_vertex_array_object *vao = ctx->Array.VAO;
GLuint j;
- ASSERT(bufObj->Name == ids[i] || bufObj == &DummyBufferObject);
+ assert(bufObj->Name == ids[i] || bufObj == &DummyBufferObject);
_mesa_buffer_unmap_all_mappings(ctx, bufObj);
/* unbind any vertex pointers bound to this buffer */
- for (j = 0; j < Elements(vao->VertexBinding); j++) {
+ for (j = 0; j < ARRAY_SIZE(vao->VertexBinding); j++) {
unbind(ctx, &vao->VertexBinding[j].BufferObj, bufObj);
}
@@ -1387,7 +1387,7 @@ _mesa_BufferStorage(GLenum target, GLsizeiptr size, const GLvoid *data,
bufObj->Written = GL_TRUE;
bufObj->Immutable = GL_TRUE;
- ASSERT(ctx->Driver.BufferData);
+ assert(ctx->Driver.BufferData);
if (!ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
flags, bufObj)) {
if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
@@ -1477,7 +1477,7 @@ _mesa_BufferData(GLenum target, GLsizeiptrARB size,
size += 100;
#endif
- ASSERT(ctx->Driver.BufferData);
+ assert(ctx->Driver.BufferData);
if (!ctx->Driver.BufferData(ctx, target, size, data, usage,
GL_MAP_READ_BIT |
GL_MAP_WRITE_BIT |
@@ -1525,7 +1525,7 @@ _mesa_BufferSubData(GLenum target, GLintptrARB offset,
bufObj->Written = GL_TRUE;
- ASSERT(ctx->Driver.BufferSubData);
+ assert(ctx->Driver.BufferSubData);
ctx->Driver.BufferSubData( ctx, offset, size, data, bufObj );
}
@@ -1545,7 +1545,7 @@ _mesa_GetBufferSubData(GLenum target, GLintptrARB offset,
return;
}
- ASSERT(ctx->Driver.GetBufferSubData);
+ assert(ctx->Driver.GetBufferSubData);
ctx->Driver.GetBufferSubData( ctx, offset, size, data, bufObj );
}
@@ -1722,7 +1722,7 @@ _mesa_MapBuffer(GLenum target, GLenum access)
return NULL;
}
- ASSERT(ctx->Driver.MapBufferRange);
+ assert(ctx->Driver.MapBufferRange);
map = ctx->Driver.MapBufferRange(ctx, 0, bufObj->Size, accessFlags, bufObj,
MAP_USER);
if (!map) {
@@ -1734,9 +1734,9 @@ _mesa_MapBuffer(GLenum target, GLenum access)
* This is important because other modules (like VBO) might call
* the driver function directly.
*/
- ASSERT(bufObj->Mappings[MAP_USER].Pointer == map);
- ASSERT(bufObj->Mappings[MAP_USER].Length == bufObj->Size);
- ASSERT(bufObj->Mappings[MAP_USER].Offset == 0);
+ assert(bufObj->Mappings[MAP_USER].Pointer == map);
+ assert(bufObj->Mappings[MAP_USER].Length == bufObj->Size);
+ assert(bufObj->Mappings[MAP_USER].Offset == 0);
bufObj->Mappings[MAP_USER].AccessFlags = accessFlags;
}
@@ -1824,9 +1824,9 @@ _mesa_UnmapBuffer(GLenum target)
status = ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_USER);
bufObj->Mappings[MAP_USER].AccessFlags = 0;
- ASSERT(bufObj->Mappings[MAP_USER].Pointer == NULL);
- ASSERT(bufObj->Mappings[MAP_USER].Offset == 0);
- ASSERT(bufObj->Mappings[MAP_USER].Length == 0);
+ assert(bufObj->Mappings[MAP_USER].Pointer == NULL);
+ assert(bufObj->Mappings[MAP_USER].Offset == 0);
+ assert(bufObj->Mappings[MAP_USER].Length == 0);
return status;
}
@@ -2203,7 +2203,7 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
return bufObj->Mappings[MAP_USER].Pointer;
}
- ASSERT(ctx->Driver.MapBufferRange);
+ assert(ctx->Driver.MapBufferRange);
map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj,
MAP_USER);
if (!map) {
@@ -2214,10 +2214,10 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length,
* This is important because other modules (like VBO) might call
* the driver function directly.
*/
- ASSERT(bufObj->Mappings[MAP_USER].Pointer == map);
- ASSERT(bufObj->Mappings[MAP_USER].Length == length);
- ASSERT(bufObj->Mappings[MAP_USER].Offset == offset);
- ASSERT(bufObj->Mappings[MAP_USER].AccessFlags == access);
+ assert(bufObj->Mappings[MAP_USER].Pointer == map);
+ assert(bufObj->Mappings[MAP_USER].Length == length);
+ assert(bufObj->Mappings[MAP_USER].Offset == offset);
+ assert(bufObj->Mappings[MAP_USER].AccessFlags == access);
}
return map;
@@ -2278,7 +2278,7 @@ _mesa_FlushMappedBufferRange(GLenum target, GLintptr offset, GLsizeiptr length)
return;
}
- ASSERT(bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_WRITE_BIT);
+ assert(bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_WRITE_BIT);
if (ctx->Driver.FlushMappedBufferRange)
ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj,
diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c
index e5076e9bb..37a979092 100644
--- a/mesalib/src/mesa/main/buffers.c
+++ b/mesalib/src/mesa/main/buffers.c
@@ -502,7 +502,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
GLuint output;
for (output = 0; output < n; output++) {
mask[output] = draw_buffer_enum_to_bitmask(ctx, buffers[output]);
- ASSERT(mask[output] != BAD_MASK);
+ assert(mask[output] != BAD_MASK);
mask[output] &= supportedMask;
}
destMask = mask;
@@ -533,7 +533,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
if (destMask[buf]) {
GLint bufIndex = ffs(destMask[buf]) - 1;
/* only one bit should be set in the destMask[buf] field */
- ASSERT(_mesa_bitcount(destMask[buf]) == 1);
+ assert(_mesa_bitcount(destMask[buf]) == 1);
if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
updated_drawbuffers(ctx);
fb->_ColorDrawBufferIndexes[buf] = bufIndex;
diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c
index 3c4ced8ed..8d707bc34 100644
--- a/mesalib/src/mesa/main/clear.c
+++ b/mesalib/src/mesa/main/clear.c
@@ -218,7 +218,7 @@ _mesa_Clear( GLbitfield mask )
bufferMask |= BUFFER_BIT_ACCUM;
}
- ASSERT(ctx->Driver.Clear);
+ assert(ctx->Driver.Clear);
ctx->Driver.Clear(ctx, bufferMask);
}
}
diff --git a/mesalib/src/mesa/main/colortab.h b/mesalib/src/mesa/main/colortab.h
index 55c3b59fa..e1165d702 100644
--- a/mesalib/src/mesa/main/colortab.h
+++ b/mesalib/src/mesa/main/colortab.h
@@ -26,8 +26,6 @@
#ifndef COLORTAB_H
#define COLORTAB_H
-
-#include "compiler.h"
#include "glheader.h"
struct _glapi_table;
diff --git a/mesalib/src/mesa/main/compiler.h b/mesalib/src/mesa/main/compiler.h
index cdc843db2..95581fb49 100644
--- a/mesalib/src/mesa/main/compiler.h
+++ b/mesalib/src/mesa/main/compiler.h
@@ -35,14 +35,6 @@
#include <assert.h>
-#include <ctype.h>
-#include <math.h>
-#include <limits.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <float.h>
-#include <stdarg.h>
#include "util/macros.h"
@@ -55,12 +47,6 @@ extern "C" {
/**
- * Get standard integer types
- */
-#include <stdint.h>
-
-
-/**
* Sun compilers define __i386 instead of the gcc-style __i386__
*/
#ifdef __SUNPRO_C
@@ -78,14 +64,6 @@ extern "C" {
/**
- * finite macro.
- */
-#if defined(_MSC_VER)
-# define finite _finite
-#endif
-
-
-/**
* Disable assorted warnings
*/
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -105,33 +83,6 @@ extern "C" {
#endif
-
-/* XXX: Use standard `inline` keyword instead */
-#ifndef INLINE
-# define INLINE inline
-#endif
-
-
-/**
- * PUBLIC/USED macros
- *
- * If we build the library with gcc's -fvisibility=hidden flag, we'll
- * use the PUBLIC macro to mark functions that are to be exported.
- *
- * We also need to define a USED attribute, so the optimizer doesn't
- * inline a static function that we later use in an alias. - ajax
- */
-#ifndef PUBLIC
-# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
-# define PUBLIC __attribute__((visibility("default")))
-# define USED __attribute__((used))
-# else
-# define PUBLIC
-# define USED
-# endif
-#endif
-
-
/* XXX: Use standard `__func__` instead */
#ifndef __FUNCTION__
# define __FUNCTION__ __func__
@@ -174,11 +125,6 @@ static inline GLuint CPU_TO_LE32(GLuint x)
-#if !defined(CAPI) && defined(_WIN32)
-#define CAPI _cdecl
-#endif
-
-
/**
* Create a macro so that asm functions can be linked into compilers other
* than GNU C
@@ -196,41 +142,6 @@ static inline GLuint CPU_TO_LE32(GLuint x)
#endif
#endif
-#ifdef USE_X86_ASM
-#define _NORMAPI _ASMAPI
-#define _NORMAPIP _ASMAPIP
-#else
-#define _NORMAPI
-#define _NORMAPIP *
-#endif
-
-
-/* Turn off macro checking systems used by other libraries */
-#ifdef CHECK
-#undef CHECK
-#endif
-
-
-/**
- * ASSERT macro
- */
-#if defined(DEBUG)
-# define ASSERT(X) assert(X)
-#else
-# define ASSERT(X)
-#endif
-
-
-/*
- * A trick to suppress uninitialized variable warning without generating any
- * code
- */
-#define uninitialized_var(x) x = x
-
-#ifndef NULL
-#define NULL 0
-#endif
-
/**
* LONGSTRING macro
@@ -242,111 +153,8 @@ static inline GLuint CPU_TO_LE32(GLuint x)
# define LONGSTRING __extension__
#endif
-
-#ifndef M_PI
-#define M_PI (3.14159265358979323846)
-#endif
-
-#ifndef M_E
-#define M_E (2.7182818284590452354)
-#endif
-
-#ifndef M_LOG2E
-#define M_LOG2E (1.4426950408889634074)
-#endif
-
-#ifndef ONE_DIV_SQRT_LN2
-#define ONE_DIV_SQRT_LN2 (1.201122408786449815)
-#endif
-
-#ifndef FLT_MAX_EXP
-#define FLT_MAX_EXP 128
-#endif
-
#define IEEE_ONE 0x3f800000
-/**
- * START/END_FAST_MATH macros:
- *
- * START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save
- * original mode to a temporary).
- * END_FAST_MATH: Restore x86 FPU to original mode.
- */
-#if defined(__GNUC__) && defined(__i386__)
-/*
- * Set the x86 FPU control word to guarentee only 32 bits of precision
- * are stored in registers. Allowing the FPU to store more introduces
- * differences between situations where numbers are pulled out of memory
- * vs. situations where the compiler is able to optimize register usage.
- *
- * In the worst case, we force the compiler to use a memory access to
- * truncate the float, by specifying the 'volatile' keyword.
- */
-/* Hardware default: All exceptions masked, extended double precision,
- * round to nearest (IEEE compliant):
- */
-#define DEFAULT_X86_FPU 0x037f
-/* All exceptions masked, single precision, round to nearest:
- */
-#define FAST_X86_FPU 0x003f
-/* The fldcw instruction will cause any pending FP exceptions to be
- * raised prior to entering the block, and we clear any pending
- * exceptions before exiting the block. Hence, asm code has free
- * reign over the FPU while in the fast math block.
- */
-#if defined(NO_FAST_MATH)
-#define START_FAST_MATH(x) \
-do { \
- static GLuint mask = DEFAULT_X86_FPU; \
- __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
- __asm__ ( "fldcw %0" : : "m" (mask) ); \
-} while (0)
-#else
-#define START_FAST_MATH(x) \
-do { \
- static GLuint mask = FAST_X86_FPU; \
- __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
- __asm__ ( "fldcw %0" : : "m" (mask) ); \
-} while (0)
-#endif
-/* Restore original FPU mode, and clear any exceptions that may have
- * occurred in the FAST_MATH block.
- */
-#define END_FAST_MATH(x) \
-do { \
- __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \
-} while (0)
-
-#elif defined(_MSC_VER) && defined(_M_IX86)
-#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */
-#define FAST_X86_FPU 0x003f /* See GCC comments above */
-#if defined(NO_FAST_MATH)
-#define START_FAST_MATH(x) do {\
- static GLuint mask = DEFAULT_X86_FPU;\
- __asm fnstcw word ptr [x]\
- __asm fldcw word ptr [mask]\
-} while(0)
-#else
-#define START_FAST_MATH(x) do {\
- static GLuint mask = FAST_X86_FPU;\
- __asm fnstcw word ptr [x]\
- __asm fldcw word ptr [mask]\
-} while(0)
-#endif
-#define END_FAST_MATH(x) do {\
- __asm fnclex\
- __asm fldcw word ptr [x]\
-} while(0)
-
-#else
-#define START_FAST_MATH(x) x = 0
-#define END_FAST_MATH(x) (void)(x)
-#endif
-
-
-#ifndef Elements
-#define Elements(x) (sizeof(x)/sizeof(*(x)))
-#endif
#ifdef __cplusplus
}
diff --git a/mesalib/src/mesa/main/condrender.c b/mesalib/src/mesa/main/condrender.c
index 75f9d74bc..77e4b95ee 100644
--- a/mesalib/src/mesa/main/condrender.c
+++ b/mesalib/src/mesa/main/condrender.c
@@ -55,7 +55,7 @@ _mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
return;
}
- ASSERT(ctx->Query.CondRenderMode == GL_NONE);
+ assert(ctx->Query.CondRenderMode == GL_NONE);
/* Section 2.14 (Conditional Rendering) of the OpenGL 3.0 spec says:
*
@@ -70,7 +70,7 @@ _mesa_BeginConditionalRender(GLuint queryId, GLenum mode)
"glBeginConditionalRender(bad queryId=%u)", queryId);
return;
}
- ASSERT(q->Id == queryId);
+ assert(q->Id == queryId);
switch (mode) {
case GL_QUERY_WAIT:
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index b186a1fad..22c2341d6 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -134,6 +134,7 @@
#include "math/m_matrix.h"
#include "main/dispatch.h" /* for _gloffset_COUNT */
#include "uniforms.h"
+#include "macros.h"
#ifdef USE_SPARC_ASM
#include "sparc/sparc.h"
@@ -446,7 +447,7 @@ _mesa_init_current(struct gl_context *ctx)
GLuint i;
/* Init all to (0,0,0,1) */
- for (i = 0; i < Elements(ctx->Current.Attrib); i++) {
+ for (i = 0; i < ARRAY_SIZE(ctx->Current.Attrib); i++) {
ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 );
}
@@ -656,7 +657,7 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api)
consts->MaxSamples = 0;
/* GLSL default if NativeIntegers == FALSE */
- consts->UniformBooleanTrue = FLT_AS_UINT(1.0f);
+ consts->UniformBooleanTrue = FLOAT_AS_UNION(1.0f).u;
/* GL_ARB_sync */
consts->MaxServerWaitTimeout = 0x1fff7fffffffULL;
@@ -1644,7 +1645,7 @@ _mesa_make_current( struct gl_context *newCtx,
/* We used to call _glapi_check_multithread() here. Now do it in drivers */
_glapi_set_context((void *) newCtx);
- ASSERT(_mesa_get_current_context() == newCtx);
+ assert(_mesa_get_current_context() == newCtx);
if (!newCtx) {
_glapi_set_dispatch(NULL); /* none current */
@@ -1653,8 +1654,8 @@ _mesa_make_current( struct gl_context *newCtx,
_glapi_set_dispatch(newCtx->CurrentDispatch);
if (drawBuffer && readBuffer) {
- ASSERT(_mesa_is_winsys_fbo(drawBuffer));
- ASSERT(_mesa_is_winsys_fbo(readBuffer));
+ assert(_mesa_is_winsys_fbo(drawBuffer));
+ assert(_mesa_is_winsys_fbo(readBuffer));
_mesa_reference_framebuffer(&newCtx->WinSysDrawBuffer, drawBuffer);
_mesa_reference_framebuffer(&newCtx->WinSysReadBuffer, readBuffer);
diff --git a/mesalib/src/mesa/main/convolve.h b/mesalib/src/mesa/main/convolve.h
index 0c0a9dd5e..e696ce497 100644
--- a/mesalib/src/mesa/main/convolve.h
+++ b/mesalib/src/mesa/main/convolve.h
@@ -28,7 +28,7 @@
#define CONVOLVE_H
-#include "compiler.h"
+#include "glheader.h"
struct _glapi_table;
diff --git a/mesalib/src/mesa/main/cpuinfo.c b/mesalib/src/mesa/main/cpuinfo.c
index 0755d6b21..67f22ab9c 100644
--- a/mesalib/src/mesa/main/cpuinfo.c
+++ b/mesalib/src/mesa/main/cpuinfo.c
@@ -23,7 +23,7 @@
*/
-#include "main/compiler.h"
+#include "main/imports.h"
#include "main/cpuinfo.h"
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index ec8662b30..0c1a13fa4 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -824,7 +824,7 @@ struct dd_function_table {
void (*BeginVertices)( struct gl_context *ctx );
/**
- * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if
+ * If inside glBegin()/glEnd(), it should assert(0). Otherwise, if
* FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered
* vertices, if FLUSH_UPDATE_CURRENT bit is set updates
* __struct gl_contextRec::Current and gl_light_attrib::Material
diff --git a/mesalib/src/mesa/main/debug.c b/mesalib/src/mesa/main/debug.c
index 089ce8987..b50d79e0c 100644
--- a/mesalib/src/mesa/main/debug.c
+++ b/mesalib/src/mesa/main/debug.c
@@ -23,6 +23,7 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
+#include <stdio.h>
#include "mtypes.h"
#include "attrib.h"
#include "colormac.h"
@@ -58,8 +59,8 @@ tex_target_name(GLenum tgt)
{ GL_TEXTURE_EXTERNAL_OES, "GL_TEXTURE_EXTERNAL_OES" }
};
GLuint i;
- STATIC_ASSERT(Elements(tex_targets) == NUM_TEXTURE_TARGETS);
- for (i = 0; i < Elements(tex_targets); i++) {
+ STATIC_ASSERT(ARRAY_SIZE(tex_targets) == NUM_TEXTURE_TARGETS);
+ for (i = 0; i < ARRAY_SIZE(tex_targets); i++) {
if (tex_targets[i].target == tgt)
return tex_targets[i].name;
}
@@ -117,11 +118,6 @@ void _mesa_print_info( struct gl_context *ctx )
*/
_mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n", ctx->Extensions.String);
-#if defined(THREADS)
- _mesa_debug(NULL, "Mesa thread-safe: YES\n");
-#else
- _mesa_debug(NULL, "Mesa thread-safe: NO\n");
-#endif
#if defined(USE_X86_ASM)
_mesa_debug(NULL, "Mesa x86-optimized: YES\n");
#else
@@ -168,7 +164,7 @@ set_verbose_flags(const char *str)
return;
MESA_VERBOSE = 0x0;
- for (i = 0; i < Elements(opts); i++) {
+ for (i = 0; i < ARRAY_SIZE(opts); i++) {
if (strstr(str, opts[i].name) || strcmp(str, "all") == 0)
MESA_VERBOSE |= opts[i].flag;
}
@@ -201,7 +197,7 @@ set_debug_flags(const char *str)
return;
MESA_DEBUG_FLAGS = 0x0;
- for (i = 0; i < Elements(opts); i++) {
+ for (i = 0; i < ARRAY_SIZE(opts); i++) {
if (strstr(str, opts[i].name))
MESA_DEBUG_FLAGS |= opts[i].flag;
}
diff --git a/mesalib/src/mesa/main/dlist.c b/mesalib/src/mesa/main/dlist.c
index 025f6abd2..431c4b48b 100644
--- a/mesalib/src/mesa/main/dlist.c
+++ b/mesalib/src/mesa/main/dlist.c
@@ -29,6 +29,7 @@
* Display lists management functions.
*/
+#include "c99_math.h"
#include "glheader.h"
#include "imports.h"
#include "api_arrayelt.h"
@@ -912,7 +913,7 @@ translate_id(GLsizei n, GLenum type, const GLvoid * list)
return (GLint) uiptr[n];
case GL_FLOAT:
fptr = (GLfloat *) list;
- return (GLint) FLOORF(fptr[n]);
+ return (GLint) floorf(fptr[n]);
case GL_2_BYTES:
ubptr = ((GLubyte *) list) + 2 * n;
return (GLint) ubptr[0] * 256
@@ -1035,7 +1036,7 @@ dlist_alloc(struct gl_context *ctx, OpCode opcode, GLuint bytes, bool align8)
}
else {
/* make sure instruction size agrees */
- ASSERT(numNodes == InstSize[opcode]);
+ assert(numNodes == InstSize[opcode]);
}
}
@@ -5089,7 +5090,7 @@ save_Attr1fNV(GLenum attr, GLfloat x)
n[2].f = x;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 1;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
@@ -5111,7 +5112,7 @@ save_Attr2fNV(GLenum attr, GLfloat x, GLfloat y)
n[3].f = y;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 2;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
@@ -5134,7 +5135,7 @@ save_Attr3fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
n[4].f = z;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 3;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
@@ -5158,7 +5159,7 @@ save_Attr4fNV(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
n[5].f = w;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 4;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
@@ -5180,7 +5181,7 @@ save_Attr1fARB(GLenum attr, GLfloat x)
n[2].f = x;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 1;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
@@ -5202,7 +5203,7 @@ save_Attr2fARB(GLenum attr, GLfloat x, GLfloat y)
n[3].f = y;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 2;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
@@ -5225,7 +5226,7 @@ save_Attr3fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z)
n[4].f = z;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 3;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
@@ -5249,7 +5250,7 @@ save_Attr4fARB(GLenum attr, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
n[5].f = w;
}
- ASSERT(attr < MAX_VERTEX_GENERIC_ATTRIBS);
+ assert(attr < MAX_VERTEX_GENERIC_ATTRIBS);
ctx->ListState.ActiveAttribSize[attr] = 4;
ASSIGN_4V(ctx->ListState.CurrentAttrib[attr], x, y, z, w);
diff --git a/mesalib/src/mesa/main/dlist.h b/mesalib/src/mesa/main/dlist.h
index 6189632d4..a1214674c 100644
--- a/mesalib/src/mesa/main/dlist.h
+++ b/mesalib/src/mesa/main/dlist.h
@@ -32,7 +32,7 @@
#ifndef DLIST_H
#define DLIST_H
-
+#include <stdio.h>
#include "main/mtypes.h"
diff --git a/mesalib/src/mesa/main/drawpix.c b/mesalib/src/mesa/main/drawpix.c
index 1865a66b9..55035f214 100644
--- a/mesalib/src/mesa/main/drawpix.c
+++ b/mesalib/src/mesa/main/drawpix.c
@@ -173,7 +173,7 @@ _mesa_DrawPixels( GLsizei width, GLsizei height,
ctx->Current.RasterTexCoords[0] );
}
else {
- ASSERT(ctx->RenderMode == GL_SELECT);
+ assert(ctx->RenderMode == GL_SELECT);
/* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */
}
@@ -279,7 +279,7 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
ctx->Current.RasterTexCoords[0] );
}
else {
- ASSERT(ctx->RenderMode == GL_SELECT);
+ assert(ctx->RenderMode == GL_SELECT);
/* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */
}
@@ -355,7 +355,7 @@ _mesa_Bitmap( GLsizei width, GLsizei height,
ctx->Current.RasterTexCoords[0] );
}
else {
- ASSERT(ctx->RenderMode == GL_SELECT);
+ assert(ctx->RenderMode == GL_SELECT);
/* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */
}
diff --git a/mesalib/src/mesa/main/drawpix.h b/mesalib/src/mesa/main/drawpix.h
index eb2cb8922..181c05ca5 100644
--- a/mesalib/src/mesa/main/drawpix.h
+++ b/mesalib/src/mesa/main/drawpix.h
@@ -26,9 +26,7 @@
#define DRAWPIX_H
-#include "compiler.h"
-
-struct _glapi_table;
+#include "glheader.h"
void GLAPIENTRY
diff --git a/mesalib/src/mesa/main/drawtex.c b/mesalib/src/mesa/main/drawtex.c
index 7c0ec832b..9c4fdf90e 100644
--- a/mesalib/src/mesa/main/drawtex.c
+++ b/mesalib/src/mesa/main/drawtex.c
@@ -46,7 +46,7 @@ draw_texture(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
if (ctx->NewState)
_mesa_update_state(ctx);
- ASSERT(ctx->Driver.DrawTex);
+ assert(ctx->Driver.DrawTex);
ctx->Driver.DrawTex(ctx, x, y, z, width, height);
_mesa_set_vp_override(ctx, GL_FALSE);
diff --git a/mesalib/src/mesa/main/enable.c b/mesalib/src/mesa/main/enable.c
index 11365ecc4..9008a3863 100644
--- a/mesalib/src/mesa/main/enable.c
+++ b/mesalib/src/mesa/main/enable.c
@@ -1060,7 +1060,7 @@ void
_mesa_set_enablei(struct gl_context *ctx, GLenum cap,
GLuint index, GLboolean state)
{
- ASSERT(state == 0 || state == 1);
+ assert(state == 0 || state == 1);
switch (cap) {
case GL_BLEND:
if (!ctx->Extensions.EXT_draw_buffers2) {
diff --git a/mesalib/src/mesa/main/errors.c b/mesalib/src/mesa/main/errors.c
index 478e4ed33..8ffbf413c 100644
--- a/mesalib/src/mesa/main/errors.c
+++ b/mesalib/src/mesa/main/errors.c
@@ -28,6 +28,8 @@
*/
+#include <stdarg.h>
+#include <stdio.h>
#include "errors.h"
#include "enums.h"
#include "imports.h"
@@ -136,7 +138,7 @@ gl_enum_to_debug_source(GLenum e)
{
unsigned i;
- for (i = 0; i < Elements(debug_source_enums); i++) {
+ for (i = 0; i < ARRAY_SIZE(debug_source_enums); i++) {
if (debug_source_enums[i] == e)
break;
}
@@ -148,7 +150,7 @@ gl_enum_to_debug_type(GLenum e)
{
unsigned i;
- for (i = 0; i < Elements(debug_type_enums); i++) {
+ for (i = 0; i < ARRAY_SIZE(debug_type_enums); i++) {
if (debug_type_enums[i] == e)
break;
}
@@ -160,7 +162,7 @@ gl_enum_to_debug_severity(GLenum e)
{
unsigned i;
- for (i = 0; i < Elements(debug_severity_enums); i++) {
+ for (i = 0; i < ARRAY_SIZE(debug_severity_enums); i++) {
if (debug_severity_enums[i] == e)
break;
}
@@ -1465,7 +1467,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
/* Too long error message. Whoever calls _mesa_error should use
* shorter strings.
*/
- ASSERT(0);
+ assert(0);
return;
}
@@ -1473,7 +1475,7 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
_mesa_lookup_enum_by_nr(error), s);
if (len >= MAX_DEBUG_MESSAGE_LENGTH) {
/* Same as above. */
- ASSERT(0);
+ assert(0);
return;
}
diff --git a/mesalib/src/mesa/main/es1_conversion.c b/mesalib/src/mesa/main/es1_conversion.c
index 60a60e287..b254a6ef1 100644
--- a/mesalib/src/mesa/main/es1_conversion.c
+++ b/mesalib/src/mesa/main/es1_conversion.c
@@ -55,7 +55,7 @@ _mesa_ClipPlanef(GLenum plane, const GLfloat *equation)
unsigned int i;
GLdouble converted_equation[4];
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
converted_equation[i] = (GLdouble) (equation[i]);
}
@@ -68,7 +68,7 @@ _mesa_ClipPlanex(GLenum plane, const GLfixed *equation)
unsigned int i;
GLdouble converted_equation[4];
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
converted_equation[i] = (GLdouble) (equation[i] / 65536.0);
}
@@ -117,7 +117,7 @@ _mesa_DrawTexxvOES(const GLfixed *coords)
unsigned int i;
GLfloat converted_coords[5];
- for (i = 0; i < Elements(converted_coords); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_coords); i++) {
converted_coords[i] = (GLfloat) (coords[i] / 65536.0f);
}
@@ -206,7 +206,7 @@ _mesa_GetClipPlanef(GLenum plane, GLfloat *equation)
GLdouble converted_equation[4];
_mesa_GetClipPlane(plane, converted_equation);
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
equation[i] = (GLfloat) (converted_equation[i]);
}
}
@@ -218,7 +218,7 @@ _mesa_GetClipPlanex(GLenum plane, GLfixed *equation)
GLdouble converted_equation[4];
_mesa_GetClipPlane(plane, converted_equation);
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
equation[i] = (GLfixed) (converted_equation[i] * 65536);
}
}
@@ -549,7 +549,7 @@ _mesa_LoadMatrixx(const GLfixed *m)
unsigned int i;
GLfloat converted_m[16];
- for (i = 0; i < Elements(converted_m); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_m); i++) {
converted_m[i] = (GLfloat) (m[i] / 65536.0f);
}
@@ -617,7 +617,7 @@ _mesa_MultMatrixx(const GLfixed *m)
unsigned int i;
GLfloat converted_m[16];
- for (i = 0; i < Elements(converted_m); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_m); i++) {
converted_m[i] = (GLfloat) (m[i] / 65536.0f);
}
@@ -825,7 +825,7 @@ _mesa_TexEnvxv(GLenum target, GLenum pname, const GLfixed *params)
unsigned int i;
GLfloat converted_params[4];
- for (i = 0; i < Elements(converted_params); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_params); i++) {
converted_params[i] = (GLfloat) (params[i] / 65536.0f);
}
diff --git a/mesalib/src/mesa/main/eval.c b/mesalib/src/mesa/main/eval.c
index 84cd7563b..86c8f75a1 100644
--- a/mesalib/src/mesa/main/eval.c
+++ b/mesalib/src/mesa/main/eval.c
@@ -309,7 +309,7 @@ map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
GLfloat *pnts;
struct gl_1d_map *map = NULL;
- ASSERT(type == GL_FLOAT || type == GL_DOUBLE);
+ assert(type == GL_FLOAT || type == GL_DOUBLE);
if (u1 == u2) {
_mesa_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" );
@@ -391,7 +391,7 @@ map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
GLfloat *pnts;
struct gl_2d_map *map = NULL;
- ASSERT(type == GL_FLOAT || type == GL_DOUBLE);
+ assert(type == GL_FLOAT || type == GL_DOUBLE);
if (u1==u2) {
_mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" );
@@ -505,7 +505,7 @@ _mesa_GetnMapdvARB( GLenum target, GLenum query, GLsizei bufSize, GLdouble *v )
map1d = get_1d_map(ctx, target);
map2d = get_2d_map(ctx, target);
- ASSERT(map1d || map2d);
+ assert(map1d || map2d);
switch (query) {
case GL_COEFF:
@@ -595,7 +595,7 @@ _mesa_GetnMapfvARB( GLenum target, GLenum query, GLsizei bufSize, GLfloat *v )
map1d = get_1d_map(ctx, target);
map2d = get_2d_map(ctx, target);
- ASSERT(map1d || map2d);
+ assert(map1d || map2d);
switch (query) {
case GL_COEFF:
@@ -687,7 +687,7 @@ _mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v )
map1d = get_1d_map(ctx, target);
map2d = get_2d_map(ctx, target);
- ASSERT(map1d || map2d);
+ assert(map1d || map2d);
switch (query) {
case GL_COEFF:
diff --git a/mesalib/src/mesa/main/execmem.c b/mesalib/src/mesa/main/execmem.c
index 7267cf85f..3a1338515 100644
--- a/mesalib/src/mesa/main/execmem.c
+++ b/mesalib/src/mesa/main/execmem.c
@@ -31,6 +31,7 @@
*/
+#include <stdio.h>
#include "imports.h"
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 305362297..f8d0d92bf 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -324,14 +324,14 @@ remove_attachment(struct gl_context *ctx,
ctx->Driver.FinishRenderTexture(ctx, rb);
if (att->Type == GL_TEXTURE) {
- ASSERT(att->Texture);
+ assert(att->Texture);
_mesa_reference_texobj(&att->Texture, NULL); /* unbind */
- ASSERT(!att->Texture);
+ assert(!att->Texture);
}
if (att->Type == GL_TEXTURE || att->Type == GL_RENDERBUFFER_EXT) {
- ASSERT(!att->Texture);
+ assert(!att->Texture);
_mesa_reference_renderbuffer(&att->Renderbuffer, NULL); /* unbind */
- ASSERT(!att->Renderbuffer);
+ assert(!att->Renderbuffer);
}
att->Type = GL_NONE;
att->Complete = GL_TRUE;
@@ -433,7 +433,7 @@ set_texture_attachment(struct gl_context *ctx,
if (att->Texture == texObj) {
/* re-attaching same texture */
- ASSERT(att->Type == GL_TEXTURE);
+ assert(att->Type == GL_TEXTURE);
}
else {
/* new attachment */
@@ -488,7 +488,7 @@ _mesa_framebuffer_renderbuffer(struct gl_context *ctx,
mtx_lock(&fb->Mutex);
att = get_attachment(ctx, fb, attachment);
- ASSERT(att);
+ assert(att);
if (rb) {
set_renderbuffer_attachment(ctx, att, rb);
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
@@ -809,7 +809,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
}
}
else {
- ASSERT(format == GL_STENCIL);
+ assert(format == GL_STENCIL);
if (ctx->Extensions.ARB_depth_texture &&
baseFormat == GL_DEPTH_STENCIL) {
/* OK */
@@ -826,7 +826,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
const GLenum baseFormat =
_mesa_get_format_base_format(att->Renderbuffer->Format);
- ASSERT(att->Renderbuffer);
+ assert(att->Renderbuffer);
if (!att->Renderbuffer->InternalFormat ||
att->Renderbuffer->Width < 1 ||
att->Renderbuffer->Height < 1) {
@@ -868,7 +868,7 @@ test_attachment_completeness(const struct gl_context *ctx, GLenum format,
}
}
else {
- ASSERT(att->Type == GL_NONE);
+ assert(att->Type == GL_NONE);
/* complete */
return;
}
@@ -1239,7 +1239,7 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT");
return;
}
- ASSERT(newRb->AllocStorage);
+ assert(newRb->AllocStorage);
_mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb);
newRb->RefCount = 1; /* referenced by hash table */
}
@@ -1248,7 +1248,7 @@ bind_renderbuffer(GLenum target, GLuint renderbuffer, bool allow_user_names)
newRb = NULL;
}
- ASSERT(newRb != &DummyRenderbuffer);
+ assert(newRb != &DummyRenderbuffer);
_mesa_reference_renderbuffer(&ctx->CurrentRenderbuffer, newRb);
}
@@ -1339,7 +1339,7 @@ _mesa_DeleteRenderbuffers(GLsizei n, const GLuint *renderbuffers)
/* check if deleting currently bound renderbuffer object */
if (rb == ctx->CurrentRenderbuffer) {
/* bind default */
- ASSERT(rb->RefCount >= 2);
+ assert(rb->RefCount >= 2);
_mesa_BindRenderbuffer(GL_RENDERBUFFER_EXT, 0);
}
@@ -1838,7 +1838,7 @@ renderbuffer_storage(GLenum target, GLenum internalFormat,
rb->NumSamples = samples;
/* Now allocate the storage */
- ASSERT(rb->AllocStorage);
+ assert(rb->AllocStorage);
if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
/* No error - check/set fields now */
/* If rb->Format == MESA_FORMAT_NONE, the format is unsupported. */
@@ -2036,7 +2036,7 @@ static void
check_begin_texture_render(struct gl_context *ctx, struct gl_framebuffer *fb)
{
GLuint i;
- ASSERT(ctx->Driver.RenderTexture);
+ assert(ctx->Driver.RenderTexture);
if (_mesa_is_winsys_fbo(fb))
return; /* can't render to texture with winsys framebuffers */
@@ -2134,8 +2134,8 @@ bind_framebuffer(GLenum target, GLuint framebuffer, bool allow_user_names)
newReadFb = ctx->WinSysReadBuffer;
}
- ASSERT(newDrawFb);
- ASSERT(newDrawFb != &DummyFramebuffer);
+ assert(newDrawFb);
+ assert(newDrawFb != &DummyFramebuffer);
/* save pointers to current/old framebuffers */
oldDrawFb = ctx->DrawBuffer;
@@ -2227,17 +2227,17 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
struct gl_framebuffer *fb;
fb = _mesa_lookup_framebuffer(ctx, framebuffers[i]);
if (fb) {
- ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]);
+ assert(fb == &DummyFramebuffer || fb->Name == framebuffers[i]);
/* check if deleting currently bound framebuffer object */
if (fb == ctx->DrawBuffer) {
/* bind default */
- ASSERT(fb->RefCount >= 2);
+ assert(fb->RefCount >= 2);
_mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
if (fb == ctx->ReadBuffer) {
/* bind default */
- ASSERT(fb->RefCount >= 2);
+ assert(fb->RefCount >= 2);
_mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c
index c51c20ddf..395b00e15 100644
--- a/mesalib/src/mesa/main/ffvertex_prog.c
+++ b/mesalib/src/mesa/main/ffvertex_prog.c
@@ -479,7 +479,7 @@ static struct ureg register_const4f( struct tnl_program *p,
values[3].f = s3;
idx = _mesa_add_unnamed_constant( p->program->Base.Parameters, values, 4,
&swizzle );
- ASSERT(swizzle == SWIZZLE_NOOP);
+ assert(swizzle == SWIZZLE_NOOP);
return make_ureg(PROGRAM_CONSTANT, idx);
}
@@ -530,7 +530,7 @@ static void emit_arg( struct prog_src_register *src,
src->Abs = 0;
src->RelAddr = 0;
/* Check that bitfield sizes aren't exceeded */
- ASSERT(src->Index == reg.idx);
+ assert(src->Index == reg.idx);
}
@@ -544,7 +544,7 @@ static void emit_dst( struct prog_dst_register *dst,
dst->CondMask = COND_TR; /* always pass cond test */
dst->CondSwizzle = SWIZZLE_NOOP;
/* Check that bitfield sizes aren't exceeded */
- ASSERT(dst->Index == reg.idx);
+ assert(dst->Index == reg.idx);
}
diff --git a/mesalib/src/mesa/main/format_unpack.py b/mesalib/src/mesa/main/format_unpack.py
index 2276a1063..53bdf641d 100644
--- a/mesalib/src/mesa/main/format_unpack.py
+++ b/mesalib/src/mesa/main/format_unpack.py
@@ -463,8 +463,8 @@ unpack_float_z_X8_UINT_Z24_UNORM(GLuint n, const void *src, GLfloat *dst)
GLuint i;
for (i = 0; i < n; i++) {
dst[i] = (GLfloat) ((s[i] >> 8) * scale);
- ASSERT(dst[i] >= 0.0F);
- ASSERT(dst[i] <= 1.0F);
+ assert(dst[i] >= 0.0F);
+ assert(dst[i] <= 1.0F);
}
}
@@ -477,8 +477,8 @@ unpack_float_z_Z24_UNORM_X8_UINT(GLuint n, const void *src, GLfloat *dst)
GLuint i;
for (i = 0; i < n; i++) {
dst[i] = (GLfloat) ((s[i] & 0x00ffffff) * scale);
- ASSERT(dst[i] >= 0.0F);
- ASSERT(dst[i] <= 1.0F);
+ assert(dst[i] >= 0.0F);
+ assert(dst[i] <= 1.0F);
}
}
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 958d6f245..422c9dc46 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -75,7 +75,7 @@ struct gl_format_info
mesa_array_format ArrayFormat;
};
-#include "format_info.c"
+#include "format_info.h"
static const struct gl_format_info *
_mesa_get_format_info(mesa_format format)
@@ -107,8 +107,8 @@ GLint
_mesa_get_format_bytes(mesa_format format)
{
const struct gl_format_info *info = _mesa_get_format_info(format);
- ASSERT(info->BytesPerBlock);
- ASSERT(info->BytesPerBlock <= MAX_PIXEL_BYTES ||
+ assert(info->BytesPerBlock);
+ assert(info->BytesPerBlock <= MAX_PIXEL_BYTES ||
_mesa_is_format_compressed(format));
return info->BytesPerBlock;
}
@@ -887,7 +887,7 @@ _mesa_test_formats(void)
{
GLuint i;
- STATIC_ASSERT(Elements(format_info) == MESA_FORMAT_COUNT);
+ STATIC_ASSERT(ARRAY_SIZE(format_info) == MESA_FORMAT_COUNT);
for (i = 0; i < MESA_FORMAT_COUNT; i++) {
const struct gl_format_info *info = _mesa_get_format_info(i);
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index dc0386d23..4f7736a64 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -29,7 +29,7 @@
* ushorts, uints, etc.
*/
-
+#include <stdio.h>
#include "glheader.h"
#include "imports.h"
#include "blend.h"
@@ -223,8 +223,8 @@ _mesa_free_framebuffer_data(struct gl_framebuffer *fb)
if (att->Texture) {
_mesa_reference_texobj(&att->Texture, NULL);
}
- ASSERT(!att->Renderbuffer);
- ASSERT(!att->Texture);
+ assert(!att->Renderbuffer);
+ assert(!att->Texture);
att->Type = GL_NONE;
}
}
@@ -245,7 +245,7 @@ _mesa_reference_framebuffer_(struct gl_framebuffer **ptr,
struct gl_framebuffer *oldFb = *ptr;
mtx_lock(&oldFb->Mutex);
- ASSERT(oldFb->RefCount > 0);
+ assert(oldFb->RefCount > 0);
oldFb->RefCount--;
deleteFlag = (oldFb->RefCount == 0);
mtx_unlock(&oldFb->Mutex);
@@ -296,8 +296,8 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
/* only resize if size is changing */
if (rb->Width != width || rb->Height != height) {
if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) {
- ASSERT(rb->Width == width);
- ASSERT(rb->Height == height);
+ assert(rb->Width == width);
+ assert(rb->Height == height);
}
else {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer");
@@ -402,8 +402,8 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
}
}
- ASSERT(bbox[0] <= bbox[1]);
- ASSERT(bbox[2] <= bbox[3]);
+ assert(bbox[0] <= bbox[1]);
+ assert(bbox[2] <= bbox[3]);
}
/**
@@ -621,8 +621,8 @@ update_color_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
fb->_ColorReadBuffer = NULL; /* legal! */
}
else {
- ASSERT(fb->_ColorReadBufferIndex >= 0);
- ASSERT(fb->_ColorReadBufferIndex < BUFFER_COUNT);
+ assert(fb->_ColorReadBufferIndex >= 0);
+ assert(fb->_ColorReadBufferIndex < BUFFER_COUNT);
fb->_ColorReadBuffer
= fb->Attachment[fb->_ColorReadBufferIndex].Renderbuffer;
}
@@ -756,7 +756,7 @@ renderbuffer_exists(struct gl_context *ctx,
if (!readBuf) {
return GL_FALSE;
}
- ASSERT(_mesa_get_format_bits(readBuf->Format, GL_RED_BITS) > 0 ||
+ assert(_mesa_get_format_bits(readBuf->Format, GL_RED_BITS) > 0 ||
_mesa_get_format_bits(readBuf->Format, GL_ALPHA_BITS) > 0 ||
_mesa_get_format_bits(readBuf->Format, GL_TEXTURE_LUMINANCE_SIZE) > 0 ||
_mesa_get_format_bits(readBuf->Format, GL_TEXTURE_INTENSITY_SIZE) > 0 ||
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index 3f9d74516..a881bc589 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -497,12 +497,12 @@ print_table_stats(int api)
};
const char *api_name;
- api_name = api < Elements(api_names) ? api_names[api] : "N/A";
+ api_name = api < ARRAY_SIZE(api_names) ? api_names[api] : "N/A";
count = 0;
- mask = Elements(table(api)) - 1;
+ mask = ARRAY_SIZE(table(api)) - 1;
memset(collisions, 0, sizeof collisions);
- for (i = 0; i < Elements(table(api)); i++) {
+ for (i = 0; i < ARRAY_SIZE(table(api)); i++) {
if (!table(api)[i])
continue;
count++;
@@ -523,8 +523,8 @@ print_table_stats(int api)
}
printf("number of enums for %s: %d (total %ld)\n",
- api_name, count, Elements(values));
- for (i = 0; i < Elements(collisions) - 1; i++)
+ api_name, count, ARRAY_SIZE(values));
+ for (i = 0; i < ARRAY_SIZE(collisions) - 1; i++)
if (collisions[i] > 0)
printf(" %d enums with %d %scollisions\n",
collisions[i], i, i == 10 ? "or more " : "");
@@ -758,7 +758,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
v->value_int_n.n =
_mesa_get_compressed_formats(ctx, v->value_int_n.ints);
- ASSERT(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints));
+ assert(v->value_int_n.n <= (int) ARRAY_SIZE(v->value_int_n.ints));
break;
case GL_MAX_VARYING_FLOATS_ARB:
@@ -1195,11 +1195,11 @@ find_value(const char *func, GLenum pname, void **p, union value *v)
* value since it's compatible with GLES2 its entry in table_set[] is at the
* end.
*/
- STATIC_ASSERT(Elements(table_set) == API_OPENGL_LAST + 2);
+ STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 2);
if (_mesa_is_gles3(ctx)) {
api = API_OPENGL_LAST + 1;
}
- mask = Elements(table(api)) - 1;
+ mask = ARRAY_SIZE(table(api)) - 1;
hash = (pname * prime_factor);
while (1) {
int idx = table(api)[hash & mask];
diff --git a/mesalib/src/mesa/main/hash.c b/mesalib/src/mesa/main/hash.c
index 1a152ec34..d04cccd94 100644
--- a/mesalib/src/mesa/main/hash.c
+++ b/mesalib/src/mesa/main/hash.c
@@ -371,8 +371,8 @@ _mesa_HashDeleteAll(struct _mesa_HashTable *table,
{
struct hash_entry *entry;
- ASSERT(table);
- ASSERT(callback);
+ assert(table);
+ assert(callback);
mtx_lock(&table->Mutex);
table->InDeleteAll = GL_TRUE;
hash_table_foreach(table->ht, entry) {
@@ -401,7 +401,7 @@ _mesa_HashClone(const struct _mesa_HashTable *table)
struct hash_entry *entry;
struct _mesa_HashTable *clonetable;
- ASSERT(table);
+ assert(table);
mtx_lock(&table2->Mutex);
clonetable = _mesa_NewHashTable();
@@ -437,8 +437,8 @@ _mesa_HashWalk(const struct _mesa_HashTable *table,
struct _mesa_HashTable *table2 = (struct _mesa_HashTable *) table;
struct hash_entry *entry;
- ASSERT(table);
- ASSERT(callback);
+ assert(table);
+ assert(callback);
mtx_lock(&table2->WalkMutex);
hash_table_foreach(table->ht, entry) {
callback((uintptr_t)entry->key, entry->data, userData);
diff --git a/mesalib/src/mesa/main/histogram.h b/mesalib/src/mesa/main/histogram.h
index 1d145a03b..47a2bf0e5 100644
--- a/mesalib/src/mesa/main/histogram.h
+++ b/mesalib/src/mesa/main/histogram.h
@@ -36,9 +36,8 @@
#ifndef HISTOGRAM_H
#define HISTOGRAM_H
-#include "compiler.h"
+#include "glheader.h"
-struct _glapi_table;
void GLAPIENTRY
_mesa_GetnMinmaxARB(GLenum target, GLboolean reset, GLenum format,
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index e97b006e0..711a19062 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -118,7 +118,7 @@ _mesa_image_offset( GLuint dimensions,
GLint skipimages; /* for 3-D volume images */
GLintptr offset;
- ASSERT(dimensions >= 1 && dimensions <= 3);
+ assert(dimensions >= 1 && dimensions <= 3);
alignment = packing->Alignment;
if (packing->RowLength > 0) {
@@ -174,7 +174,7 @@ _mesa_image_offset( GLuint dimensions,
if (remainder > 0)
bytes_per_row += (alignment - remainder);
- ASSERT(bytes_per_row % alignment == 0);
+ assert(bytes_per_row % alignment == 0);
bytes_per_image = bytes_per_row * rows_per_image;
@@ -288,7 +288,7 @@ _mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
{
GLint bytesPerRow, remainder;
- ASSERT(packing);
+ assert(packing);
if (type == GL_BITMAP) {
if (packing->RowLength == 0) {
@@ -336,7 +336,7 @@ _mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
{
GLint bytesPerRow, bytesPerImage, remainder;
- ASSERT(packing);
+ assert(packing);
if (type == GL_BITMAP) {
if (packing->RowLength == 0) {
@@ -476,7 +476,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src,
if (!tempBuffer)
return;
- ASSERT(srcType != dstType);
+ assert(srcType != dstType);
switch (srcType) {
case GL_UNSIGNED_BYTE:
@@ -499,7 +499,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src,
const GLubyte (*src1)[4] = (const GLubyte (*)[4]) src;
GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst);
GLuint i;
- ASSERT(dstType == GL_FLOAT);
+ assert(dstType == GL_FLOAT);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
dst4[i][RCOMP] = UBYTE_TO_FLOAT(src1[i][RCOMP]);
@@ -532,7 +532,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src,
const GLushort (*src2)[4] = (const GLushort (*)[4]) src;
GLfloat (*dst4)[4] = (GLfloat (*)[4]) (useTemp ? tempBuffer : dst);
GLuint i;
- ASSERT(dstType == GL_FLOAT);
+ assert(dstType == GL_FLOAT);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
dst4[i][RCOMP] = USHORT_TO_FLOAT(src2[i][RCOMP]);
@@ -561,7 +561,7 @@ _mesa_convert_colors(GLenum srcType, const GLvoid *src,
const GLfloat (*src4)[4] = (const GLfloat (*)[4]) src;
GLushort (*dst2)[4] = (GLushort (*)[4]) (useTemp ? tempBuffer : dst);
GLuint i;
- ASSERT(dstType == GL_UNSIGNED_SHORT);
+ assert(dstType == GL_UNSIGNED_SHORT);
for (i = 0; i < count; i++) {
if (!mask || mask[i]) {
UNCLAMPED_FLOAT_TO_USHORT(dst2[i][RCOMP], src4[i][RCOMP]);
@@ -607,8 +607,8 @@ _mesa_clip_drawpixels(const struct gl_context *ctx,
unpack->RowLength = *width;
}
- ASSERT(ctx->Pixel.ZoomX == 1.0F);
- ASSERT(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F);
+ assert(ctx->Pixel.ZoomX == 1.0F);
+ assert(ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F);
/* left clipping */
if (*destX < buffer->_Xmin) {
@@ -792,20 +792,20 @@ clip_right_or_top(GLint *srcX0, GLint *srcX1,
if (*dstX1 > maxValue) {
/* X1 outside right edge */
- ASSERT(*dstX0 < maxValue); /* X0 should be inside right edge */
+ assert(*dstX0 < maxValue); /* X0 should be inside right edge */
t = (GLfloat) (maxValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
/* chop off [t, 1] part */
- ASSERT(t >= 0.0 && t <= 1.0);
+ assert(t >= 0.0 && t <= 1.0);
*dstX1 = maxValue;
bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
*srcX1 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
}
else if (*dstX0 > maxValue) {
/* X0 outside right edge */
- ASSERT(*dstX1 < maxValue); /* X1 should be inside right edge */
+ assert(*dstX1 < maxValue); /* X1 should be inside right edge */
t = (GLfloat) (maxValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
/* chop off [t, 1] part */
- ASSERT(t >= 0.0 && t <= 1.0);
+ assert(t >= 0.0 && t <= 1.0);
*dstX0 = maxValue;
bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F;
*srcX0 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
@@ -825,20 +825,20 @@ clip_left_or_bottom(GLint *srcX0, GLint *srcX1,
if (*dstX0 < minValue) {
/* X0 outside left edge */
- ASSERT(*dstX1 > minValue); /* X1 should be inside left edge */
+ assert(*dstX1 > minValue); /* X1 should be inside left edge */
t = (GLfloat) (minValue - *dstX0) / (GLfloat) (*dstX1 - *dstX0);
/* chop off [0, t] part */
- ASSERT(t >= 0.0 && t <= 1.0);
+ assert(t >= 0.0 && t <= 1.0);
*dstX0 = minValue;
bias = (*srcX0 < *srcX1) ? 0.5F : -0.5F;
*srcX0 = *srcX0 + (GLint) (t * (*srcX1 - *srcX0) + bias);
}
else if (*dstX1 < minValue) {
/* X1 outside left edge */
- ASSERT(*dstX0 > minValue); /* X0 should be inside left edge */
+ assert(*dstX0 > minValue); /* X0 should be inside left edge */
t = (GLfloat) (minValue - *dstX1) / (GLfloat) (*dstX0 - *dstX1);
/* chop off [0, t] part */
- ASSERT(t >= 0.0 && t <= 1.0);
+ assert(t >= 0.0 && t <= 1.0);
*dstX1 = minValue;
bias = (*srcX0 < *srcX1) ? -0.5F : 0.5F;
*srcX1 = *srcX1 + (GLint) (t * (*srcX0 - *srcX1) + bias);
@@ -936,25 +936,25 @@ _mesa_clip_blit(struct gl_context *ctx,
*srcY0, *srcY1, *dstY0, *dstY1);
*/
- ASSERT(*dstX0 >= dstXmin);
- ASSERT(*dstX0 <= dstXmax);
- ASSERT(*dstX1 >= dstXmin);
- ASSERT(*dstX1 <= dstXmax);
-
- ASSERT(*dstY0 >= dstYmin);
- ASSERT(*dstY0 <= dstYmax);
- ASSERT(*dstY1 >= dstYmin);
- ASSERT(*dstY1 <= dstYmax);
-
- ASSERT(*srcX0 >= srcXmin);
- ASSERT(*srcX0 <= srcXmax);
- ASSERT(*srcX1 >= srcXmin);
- ASSERT(*srcX1 <= srcXmax);
-
- ASSERT(*srcY0 >= srcYmin);
- ASSERT(*srcY0 <= srcYmax);
- ASSERT(*srcY1 >= srcYmin);
- ASSERT(*srcY1 <= srcYmax);
+ assert(*dstX0 >= dstXmin);
+ assert(*dstX0 <= dstXmax);
+ assert(*dstX1 >= dstXmin);
+ assert(*dstX1 <= dstXmax);
+
+ assert(*dstY0 >= dstYmin);
+ assert(*dstY0 <= dstYmax);
+ assert(*dstY1 >= dstYmin);
+ assert(*dstY1 <= dstYmax);
+
+ assert(*srcX0 >= srcXmin);
+ assert(*srcX0 <= srcXmax);
+ assert(*srcX1 >= srcXmin);
+ assert(*srcX1 <= srcXmax);
+
+ assert(*srcY0 >= srcYmin);
+ assert(*srcY0 <= srcYmax);
+ assert(*srcY1 >= srcYmin);
+ assert(*srcY1 <= srcYmax);
return GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/imports.c b/mesalib/src/mesa/main/imports.c
index 4f5a2d11f..a7ffe2296 100644
--- a/mesalib/src/mesa/main/imports.c
+++ b/mesalib/src/mesa/main/imports.c
@@ -42,8 +42,9 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-
-
+#include <stdio.h>
+#include <stdarg.h>
+#include "c99_math.h"
#include "imports.h"
#include "context.h"
#include "mtypes.h"
@@ -92,7 +93,7 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
#else
uintptr_t ptr, buf;
- ASSERT( alignment > 0 );
+ assert( alignment > 0 );
ptr = (uintptr_t)malloc(bytes + alignment + sizeof(void *));
if (!ptr)
@@ -141,7 +142,7 @@ _mesa_align_calloc(size_t bytes, unsigned long alignment)
#else
uintptr_t ptr, buf;
- ASSERT( alignment > 0 );
+ assert( alignment > 0 );
ptr = (uintptr_t)calloc(1, bytes + alignment + sizeof(void *));
if (!ptr)
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index 0fcba4fb9..792100061 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -36,6 +36,9 @@
#define IMPORTS_H
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
#include "compiler.h"
#include "glheader.h"
#include "errors.h"
@@ -79,62 +82,8 @@ typedef union { GLfloat f; GLint i; GLuint u; } fi_type;
-/**********************************************************************
- * Math macros
- */
-
-#define MAX_GLUSHORT 0xffff
-#define MAX_GLUINT 0xffffffff
-
-/* Degrees to radians conversion: */
-#define DEG2RAD (M_PI/180.0)
-
-
-/**
- * \name Work-arounds for platforms that lack C99 math functions
- */
-/*@{*/
-#if (!defined(_XOPEN_SOURCE) || (_XOPEN_SOURCE < 600)) && !defined(_ISOC99_SOURCE) \
- && (!defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)) \
- && (!defined(_MSC_VER) || (_MSC_VER < 1400))
-#define acosf(f) ((float) acos(f))
-#define asinf(f) ((float) asin(f))
-#define atan2f(x,y) ((float) atan2(x,y))
-#define atanf(f) ((float) atan(f))
-#define ceilf(f) ((float) ceil(f))
-#define cosf(f) ((float) cos(f))
-#define coshf(f) ((float) cosh(f))
-#define expf(f) ((float) exp(f))
-#define exp2f(f) ((float) exp2(f))
-#define floorf(f) ((float) floor(f))
-#define logf(f) ((float) log(f))
-
-#ifdef ANDROID
-#define log2f(f) (logf(f) * (float) (1.0 / M_LN2))
-#else
-#define log2f(f) ((float) log2(f))
-#endif
-
-#define powf(x,y) ((float) pow(x,y))
-#define sinf(f) ((float) sin(f))
-#define sinhf(f) ((float) sinh(f))
-#define sqrtf(f) ((float) sqrt(f))
-#define tanf(f) ((float) tan(f))
-#define tanhf(f) ((float) tanh(f))
-#define acoshf(f) ((float) acosh(f))
-#define asinhf(f) ((float) asinh(f))
-#define atanhf(f) ((float) atanh(f))
-#endif
-
#if defined(_MSC_VER)
#if _MSC_VER < 1800 /* Not req'd on VS2013 and above */
-static inline float truncf(float x) { return x < 0.0f ? ceilf(x) : floorf(x); }
-static inline float exp2f(float x) { return powf(2.0f, x); }
-static inline float log2f(float x) { return logf(x) * 1.442695041f; }
-static inline float asinhf(float x) { return logf(x + sqrtf(x * x + 1.0f)); }
-static inline float acoshf(float x) { return logf(x + sqrtf(x * x - 1.0f)); }
-static inline float atanhf(float x) { return (logf(1.0f + x) - logf(1.0f - x)) / 2.0f; }
-static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
#define strtoll(p, e, b) _strtoi64(p, e, b)
#endif /* _MSC_VER < 1800 */
#define strcasecmp(s1, s2) _stricmp(s1, s2)
@@ -142,23 +91,6 @@ static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
/*@}*/
-/*
- * signbit() is a macro on Linux. Not available on Windows.
- */
-#ifndef signbit
-#define signbit(x) ((x) < 0.0f)
-#endif
-
-
-/** single-precision inverse square root */
-static inline float
-INV_SQRTF(float x)
-{
- /* XXX we could try Quake's fast inverse square root function here */
- return 1.0F / sqrtf(x);
-}
-
-
/***
*** LOG2: Log base 2 of float
***/
@@ -189,6 +121,14 @@ static inline GLfloat LOG2(GLfloat x)
+/**
+ * finite macro.
+ */
+#if defined(_MSC_VER)
+# define finite _finite
+#endif
+
+
/***
*** IS_INF_OR_NAN: test if float is infinite or NaN
***/
@@ -203,35 +143,6 @@ static inline GLfloat LOG2(GLfloat x)
#endif
-/***
- *** CEILF: ceiling of float
- *** FLOORF: floor of float
- *** FABSF: absolute value of float
- *** LOGF: the natural logarithm (base e) of the value
- *** EXPF: raise e to the value
- *** LDEXPF: multiply value by an integral power of two
- *** FREXPF: extract mantissa and exponent from value
- ***/
-#if defined(__gnu_linux__)
-/* C99 functions */
-#define CEILF(x) ceilf(x)
-#define FLOORF(x) floorf(x)
-#define FABSF(x) fabsf(x)
-#define LOGF(x) logf(x)
-#define EXPF(x) expf(x)
-#define LDEXPF(x,y) ldexpf(x,y)
-#define FREXPF(x,y) frexpf(x,y)
-#else
-#define CEILF(x) ((GLfloat) ceil(x))
-#define FLOORF(x) ((GLfloat) floor(x))
-#define FABSF(x) ((GLfloat) fabs(x))
-#define LOGF(x) ((GLfloat) log(x))
-#define EXPF(x) ((GLfloat) exp(x))
-#define LDEXPF(x,y) ((GLfloat) ldexp(x,y))
-#define FREXPF(x,y) ((GLfloat) frexp(x,y))
-#endif
-
-
/**
* Convert float to int by rounding to nearest integer, away from zero.
*/
diff --git a/mesalib/src/mesa/main/light.c b/mesalib/src/mesa/main/light.c
index e483b826e..4021dbef9 100644
--- a/mesalib/src/mesa/main/light.c
+++ b/mesalib/src/mesa/main/light.c
@@ -24,6 +24,7 @@
*/
+#include "c99_math.h"
#include "glheader.h"
#include "imports.h"
#include "context.h"
@@ -101,7 +102,7 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa
{
struct gl_light *light;
- ASSERT(lnum < MAX_LIGHTS);
+ assert(lnum < MAX_LIGHTS);
light = &ctx->Light.Light[lnum];
switch (pname) {
@@ -142,20 +143,20 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa
COPY_3V(light->SpotDirection, params);
break;
case GL_SPOT_EXPONENT:
- ASSERT(params[0] >= 0.0);
- ASSERT(params[0] <= ctx->Const.MaxSpotExponent);
+ assert(params[0] >= 0.0);
+ assert(params[0] <= ctx->Const.MaxSpotExponent);
if (light->SpotExponent == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
light->SpotExponent = params[0];
break;
case GL_SPOT_CUTOFF:
- ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0));
+ assert(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0));
if (light->SpotCutoff == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
light->SpotCutoff = params[0];
- light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * DEG2RAD));
+ light->_CosCutoff = (GLfloat) (cos(light->SpotCutoff * M_PI / 180.0));
if (light->_CosCutoff < 0)
light->_CosCutoff = 0;
if (light->SpotCutoff != 180.0F)
@@ -164,21 +165,21 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa
light->_Flags &= ~LIGHT_SPOT;
break;
case GL_CONSTANT_ATTENUATION:
- ASSERT(params[0] >= 0.0);
+ assert(params[0] >= 0.0);
if (light->ConstantAttenuation == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
light->ConstantAttenuation = params[0];
break;
case GL_LINEAR_ATTENUATION:
- ASSERT(params[0] >= 0.0);
+ assert(params[0] >= 0.0);
if (light->LinearAttenuation == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
light->LinearAttenuation = params[0];
break;
case GL_QUADRATIC_ATTENUATION:
- ASSERT(params[0] >= 0.0);
+ assert(params[0] >= 0.0);
if (light->QuadraticAttenuation == params[0])
return;
FLUSH_VERTICES(ctx, _NEW_LIGHT);
@@ -808,7 +809,7 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
GLuint f;
GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
- ASSERT(ctx->API == API_OPENGL_COMPAT);
+ assert(ctx->API == API_OPENGL_COMPAT);
FLUSH_VERTICES(ctx, 0); /* update materials */
FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
@@ -1025,9 +1026,9 @@ update_modelview_scale( struct gl_context *ctx )
GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
if (f < 1e-12) f = 1.0;
if (ctx->_NeedEyeCoords)
- ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f);
+ ctx->_ModelViewInvScale = 1.0f / sqrtf(f);
else
- ctx->_ModelViewInvScale = (GLfloat) sqrtf(f);
+ ctx->_ModelViewInvScale = sqrtf(f);
}
}
diff --git a/mesalib/src/mesa/main/macros.h b/mesalib/src/mesa/main/macros.h
index cf1f0e9c9..2d7a6a107 100644
--- a/mesalib/src/mesa/main/macros.h
+++ b/mesalib/src/mesa/main/macros.h
@@ -171,25 +171,25 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256];
ub = ((GLubyte) F_TO_I((f) * 255.0F))
#endif
-static inline GLfloat INT_AS_FLT(GLint i)
+static fi_type UINT_AS_UNION(GLuint u)
{
fi_type tmp;
- tmp.i = i;
- return tmp.f;
+ tmp.u = u;
+ return tmp;
}
-static inline GLfloat UINT_AS_FLT(GLuint u)
+static inline fi_type INT_AS_UNION(GLint i)
{
fi_type tmp;
- tmp.u = u;
- return tmp.f;
+ tmp.i = i;
+ return tmp;
}
-static inline unsigned FLT_AS_UINT(float f)
+static inline fi_type FLOAT_AS_UNION(GLfloat f)
{
fi_type tmp;
tmp.f = f;
- return tmp.u;
+ return tmp;
}
/**
@@ -604,24 +604,26 @@ do { \
* The default values are chosen based on \p type.
*/
static inline void
-COPY_CLEAN_4V_TYPE_AS_FLOAT(GLfloat dst[4], int sz, const GLfloat src[4],
+COPY_CLEAN_4V_TYPE_AS_UNION(fi_type dst[4], int sz, const fi_type src[4],
GLenum type)
{
switch (type) {
case GL_FLOAT:
- ASSIGN_4V(dst, 0, 0, 0, 1);
+ ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+ FLOAT_AS_UNION(0), FLOAT_AS_UNION(1));
break;
case GL_INT:
- ASSIGN_4V(dst, INT_AS_FLT(0), INT_AS_FLT(0),
- INT_AS_FLT(0), INT_AS_FLT(1));
+ ASSIGN_4V(dst, INT_AS_UNION(0), INT_AS_UNION(0),
+ INT_AS_UNION(0), INT_AS_UNION(1));
break;
case GL_UNSIGNED_INT:
- ASSIGN_4V(dst, UINT_AS_FLT(0), UINT_AS_FLT(0),
- UINT_AS_FLT(0), UINT_AS_FLT(1));
+ ASSIGN_4V(dst, UINT_AS_UNION(0), UINT_AS_UNION(0),
+ UINT_AS_UNION(0), UINT_AS_UNION(1));
break;
default:
- ASSIGN_4V(dst, 0.0f, 0.0f, 0.0f, 1.0f); /* silence warnings */
- ASSERT(!"Unexpected type in COPY_CLEAN_4V_TYPE_AS_FLOAT macro");
+ ASSIGN_4V(dst, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0),
+ FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); /* silence warnings */
+ assert(!"Unexpected type in COPY_CLEAN_4V_TYPE_AS_UNION macro");
}
COPY_SZ_4V(dst, sz, src);
}
@@ -775,7 +777,7 @@ NORMALIZE_3FV(GLfloat v[3])
{
GLfloat len = (GLfloat) LEN_SQUARED_3FV(v);
if (len) {
- len = INV_SQRTF(len);
+ len = 1.0f / sqrtf(len);
v[0] *= len;
v[1] *= len;
v[2] *= len;
@@ -801,10 +803,6 @@ DIFFERENT_SIGNS(GLfloat x, GLfloat y)
#define ENUM_TO_DOUBLE(E) ((GLdouble)(GLint)(E))
#define ENUM_TO_BOOLEAN(E) ((E) ? GL_TRUE : GL_FALSE)
-/* Compute the size of an array */
-#ifndef ARRAY_SIZE
-# define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-#endif
/* Stringify */
#define STRINGIFY(x) #x
diff --git a/mesalib/src/mesa/main/matrix.c b/mesalib/src/mesa/main/matrix.c
index 0539caa47..80c8a248c 100644
--- a/mesalib/src/mesa/main/matrix.c
+++ b/mesalib/src/mesa/main/matrix.c
@@ -176,7 +176,7 @@ _mesa_MatrixMode( GLenum mode )
return;
}
#endif
- ASSERT(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack));
+ assert(ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->TextureMatrixStack));
ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit];
break;
case GL_MATRIX0_ARB:
@@ -697,10 +697,10 @@ void _mesa_init_matrix( struct gl_context * ctx )
_NEW_MODELVIEW);
init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH,
_NEW_PROJECTION);
- for (i = 0; i < Elements(ctx->TextureMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++)
init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH,
_NEW_TEXTURE_MATRIX);
- for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++)
init_matrix_stack(&ctx->ProgramMatrixStack[i],
MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX);
ctx->CurrentStack = &ctx->ModelviewMatrixStack;
@@ -724,9 +724,9 @@ void _mesa_free_matrix_data( struct gl_context *ctx )
free_matrix_stack(&ctx->ModelviewMatrixStack);
free_matrix_stack(&ctx->ProjectionMatrixStack);
- for (i = 0; i < Elements(ctx->TextureMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++)
free_matrix_stack(&ctx->TextureMatrixStack[i]);
- for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++)
free_matrix_stack(&ctx->ProgramMatrixStack[i]);
/* combined Modelview*Projection matrix */
_math_matrix_dtr( &ctx->_ModelProjectMatrix );
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 75a12cd16..7732d09b2 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -153,8 +153,8 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
const GLuint k0 = (srcWidth == dstWidth) ? 0 : 1;
const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2;
- ASSERT(comps >= 1);
- ASSERT(comps <= 4);
+ assert(comps >= 1);
+ assert(comps <= 4);
/* This assertion is no longer valid with non-power-of-2 textures
assert(srcWidth == dstWidth || srcWidth == 2 * dstWidth);
@@ -788,8 +788,8 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2;
GLuint i, j, k;
- ASSERT(comps >= 1);
- ASSERT(comps <= 4);
+ assert(comps >= 1);
+ assert(comps <= 4);
if ((datatype == GL_UNSIGNED_BYTE) && (comps == 4)) {
DECLARE_ROW_POINTERS(GLubyte, 4);
@@ -1650,7 +1650,7 @@ make_3d_mipmap(GLenum datatype, GLuint comps, GLint border,
}
else {
/* average border pixels from adjacent src image pairs */
- ASSERT(srcDepthNB == 2 * dstDepthNB);
+ assert(srcDepthNB == 2 * dstDepthNB);
for (img = 0; img < dstDepthNB; img++) {
const GLubyte *srcA, *srcB;
GLubyte *dst;
@@ -1902,7 +1902,7 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
/* get src image parameters */
srcImage = _mesa_select_tex_image(texObj, target, level);
- ASSERT(srcImage);
+ assert(srcImage);
srcWidth = srcImage->Width;
srcHeight = srcImage->Height;
srcDepth = srcImage->Depth;
@@ -2097,7 +2097,7 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target,
/* get src image parameters */
srcImage = _mesa_select_tex_image(texObj, target, level);
- ASSERT(srcImage);
+ assert(srcImage);
srcWidth = srcImage->Width;
srcHeight = srcImage->Height;
srcDepth = srcImage->Depth;
@@ -2192,12 +2192,12 @@ _mesa_generate_mipmap(struct gl_context *ctx, GLenum target,
struct gl_texture_image *srcImage;
GLint maxLevel;
- ASSERT(texObj);
+ assert(texObj);
srcImage = _mesa_select_tex_image(texObj, target, texObj->BaseLevel);
- ASSERT(srcImage);
+ assert(srcImage);
maxLevel = _mesa_max_texture_levels(ctx, texObj->Target) - 1;
- ASSERT(maxLevel >= 0); /* bad target */
+ assert(maxLevel >= 0); /* bad target */
maxLevel = MIN2(maxLevel, texObj->MaxLevel);
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 6e9977309..efeee8bff 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -36,6 +36,7 @@
#include <stdint.h> /* uint32_t */
#include <stdbool.h>
+#include "c11/threads.h"
#include "main/glheader.h"
#include "main/config.h"
diff --git a/mesalib/src/mesa/main/multisample.c b/mesalib/src/mesa/main/multisample.c
index b696de9f2..0e9207bc1 100644
--- a/mesalib/src/mesa/main/multisample.c
+++ b/mesalib/src/mesa/main/multisample.c
@@ -150,16 +150,17 @@ GLenum
_mesa_check_sample_count(struct gl_context *ctx, GLenum target,
GLenum internalFormat, GLsizei samples)
{
- /* Section 4.4 (Framebuffer objects) of the OpenGL 3.0 specification says:
+ /* Section 4.4 (Framebuffer objects), page 198 of the OpenGL ES 3.0.0
+ * specification says:
*
* "If internalformat is a signed or unsigned integer format and samples
* is greater than zero, then the error INVALID_OPERATION is generated."
*/
- if (_mesa_is_gles3(ctx) && _mesa_is_enum_format_integer(internalFormat)) {
+ if (_mesa_is_gles3(ctx) && _mesa_is_enum_format_integer(internalFormat)
+ && samples > 0) {
return GL_INVALID_OPERATION;
}
-
/* If ARB_internalformat_query is supported, then treat its highest
* returned sample count as the absolute maximum for this format; it is
* allowed to exceed MAX_SAMPLES.
diff --git a/mesalib/src/mesa/main/pack.c b/mesalib/src/mesa/main/pack.c
index 2111a7604..f72360817 100644
--- a/mesalib/src/mesa/main/pack.c
+++ b/mesalib/src/mesa/main/pack.c
@@ -257,9 +257,9 @@ extract_uint_indexes(GLuint n, GLuint indexes[],
GLenum srcFormat, GLenum srcType, const GLvoid *src,
const struct gl_pixelstore_attrib *unpack )
{
- ASSERT(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX);
+ assert(srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX);
- ASSERT(srcType == GL_BITMAP ||
+ assert(srcType == GL_BITMAP ||
srcType == GL_UNSIGNED_BYTE ||
srcType == GL_BYTE ||
srcType == GL_UNSIGNED_SHORT ||
@@ -503,7 +503,7 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
const struct gl_pixelstore_attrib *srcPacking,
GLbitfield transferOps )
{
- ASSERT(srcType == GL_BITMAP ||
+ assert(srcType == GL_BITMAP ||
srcType == GL_UNSIGNED_BYTE ||
srcType == GL_BYTE ||
srcType == GL_UNSIGNED_SHORT ||
@@ -516,7 +516,7 @@ _mesa_unpack_stencil_span( struct gl_context *ctx, GLuint n,
srcType == GL_FLOAT ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
- ASSERT(dstType == GL_UNSIGNED_BYTE ||
+ assert(dstType == GL_UNSIGNED_BYTE ||
dstType == GL_UNSIGNED_SHORT ||
dstType == GL_UNSIGNED_INT ||
dstType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
@@ -988,7 +988,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
else if (dstType == GL_UNSIGNED_SHORT) {
GLushort *zValues = (GLushort *) dest;
GLuint i;
- ASSERT(depthMax <= 0xffff);
+ assert(depthMax <= 0xffff);
for (i = 0; i < n; i++) {
zValues[i] = (GLushort) (depthValues[i] * (GLfloat) depthMax);
}
@@ -1004,7 +1004,7 @@ _mesa_unpack_depth_span( struct gl_context *ctx, GLuint n,
}
}
else {
- ASSERT(0);
+ assert(0);
}
free(depthTemp);
@@ -1487,20 +1487,20 @@ _mesa_pack_luminance_from_rgba_integer(GLuint n,
case GL_UNSIGNED_BYTE: {
GLbyte *dst = (GLbyte *) dstAddr;
dst[i] = lum32;
+ break;
}
- break;
case GL_SHORT:
case GL_UNSIGNED_SHORT: {
GLshort *dst = (GLshort *) dstAddr;
dst[i] = lum32;
+ break;
}
- break;
case GL_INT:
case GL_UNSIGNED_INT: {
GLint *dst = (GLint *) dstAddr;
dst[i] = lum32;
+ break;
}
- break;
}
}
return;
@@ -1525,21 +1525,22 @@ _mesa_pack_luminance_from_rgba_integer(GLuint n,
GLbyte *dst = (GLbyte *) dstAddr;
dst[2*i] = lum32;
dst[2*i+1] = alpha;
+ break;
}
case GL_SHORT:
case GL_UNSIGNED_SHORT: {
GLshort *dst = (GLshort *) dstAddr;
dst[i] = lum32;
dst[2*i+1] = alpha;
+ break;
}
- break;
case GL_INT:
case GL_UNSIGNED_INT: {
GLint *dst = (GLint *) dstAddr;
dst[i] = lum32;
dst[2*i+1] = alpha;
+ break;
}
- break;
}
}
return;
diff --git a/mesalib/src/mesa/main/pbo.c b/mesalib/src/mesa/main/pbo.c
index a0d61a643..5c906ed74 100644
--- a/mesalib/src/mesa/main/pbo.c
+++ b/mesalib/src/mesa/main/pbo.c
@@ -182,7 +182,7 @@ _mesa_map_validate_pbo_source(struct gl_context *ctx,
GLsizei clientMemSize,
const GLvoid *ptr, const char *where)
{
- ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3);
+ assert(dimensions == 1 || dimensions == 2 || dimensions == 3);
if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
format, type, clientMemSize, ptr)) {
@@ -220,7 +220,7 @@ void
_mesa_unmap_pbo_source(struct gl_context *ctx,
const struct gl_pixelstore_attrib *unpack)
{
- ASSERT(unpack != &ctx->Pack); /* catch pack/unpack mismatch */
+ assert(unpack != &ctx->Pack); /* catch pack/unpack mismatch */
if (_mesa_is_bufferobj(unpack->BufferObj)) {
ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
}
@@ -279,7 +279,7 @@ _mesa_map_validate_pbo_dest(struct gl_context *ctx,
GLenum format, GLenum type, GLsizei clientMemSize,
GLvoid *ptr, const char *where)
{
- ASSERT(dimensions == 1 || dimensions == 2 || dimensions == 3);
+ assert(dimensions == 1 || dimensions == 2 || dimensions == 3);
if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
format, type, clientMemSize, ptr)) {
@@ -317,7 +317,7 @@ void
_mesa_unmap_pbo_dest(struct gl_context *ctx,
const struct gl_pixelstore_attrib *pack)
{
- ASSERT(pack != &ctx->Unpack); /* catch pack/unpack mismatch */
+ assert(pack != &ctx->Unpack); /* catch pack/unpack mismatch */
if (_mesa_is_bufferobj(pack->BufferObj)) {
ctx->Driver.UnmapBuffer(ctx, pack->BufferObj, MAP_INTERNAL);
}
diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c
index b713d956f..fb241af1e 100644
--- a/mesalib/src/mesa/main/pipelineobj.c
+++ b/mesalib/src/mesa/main/pipelineobj.c
@@ -187,7 +187,7 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx,
struct gl_pipeline_object *oldObj = *ptr;
mtx_lock(&oldObj->Mutex);
- ASSERT(oldObj->RefCount > 0);
+ assert(oldObj->RefCount > 0);
oldObj->RefCount--;
deleteFlag = (oldObj->RefCount == 0);
mtx_unlock(&oldObj->Mutex);
@@ -198,7 +198,7 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx,
*ptr = NULL;
}
- ASSERT(!*ptr);
+ assert(!*ptr);
if (obj) {
/* reference new pipeline object */
@@ -471,7 +471,7 @@ _mesa_DeleteProgramPipelines(GLsizei n, const GLuint *pipelines)
lookup_pipeline_object(ctx, pipelines[i]);
if (obj) {
- ASSERT(obj->Name == pipelines[i]);
+ assert(obj->Name == pipelines[i]);
/* If the pipeline object is currently bound, the spec says "If an
* object that is currently bound is deleted, the binding for that
diff --git a/mesalib/src/mesa/main/pixel.h b/mesalib/src/mesa/main/pixel.h
index c12ef97b8..fd1782e1b 100644
--- a/mesalib/src/mesa/main/pixel.h
+++ b/mesalib/src/mesa/main/pixel.h
@@ -33,10 +33,8 @@
#define PIXEL_H
-#include "compiler.h"
#include "glheader.h"
-struct _glapi_table;
struct gl_context;
diff --git a/mesalib/src/mesa/main/points.c b/mesalib/src/mesa/main/points.c
index de26bf961..5ad1f38f3 100644
--- a/mesalib/src/mesa/main/points.c
+++ b/mesalib/src/mesa/main/points.c
@@ -103,7 +103,7 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params)
* If point parameters aren't supported, then this function shouldn't even
* exist.
*/
- ASSERT(!(ctx->Extensions.ARB_point_sprite
+ assert(!(ctx->Extensions.ARB_point_sprite
|| ctx->Extensions.NV_point_sprite)
|| ctx->Extensions.EXT_point_parameters);
@@ -253,7 +253,7 @@ _mesa_init_point(struct gl_context *ctx)
ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
- for (i = 0; i < Elements(ctx->Point.CoordReplace); i++) {
+ for (i = 0; i < ARRAY_SIZE(ctx->Point.CoordReplace); i++) {
ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */
}
}
diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c
index 1b19afe4b..0842b540d 100644
--- a/mesalib/src/mesa/main/queryobj.c
+++ b/mesalib/src/mesa/main/queryobj.c
@@ -146,12 +146,13 @@ static struct gl_query_object **
get_pipe_stats_binding_point(struct gl_context *ctx,
GLenum target)
{
+ const int which = target - GL_VERTICES_SUBMITTED_ARB;
+ assert(which < MAX_PIPELINE_STATISTICS);
+
if (!_mesa_is_desktop_gl(ctx) ||
!ctx->Extensions.ARB_pipeline_statistics_query)
return NULL;
- const int which = target - GL_VERTICES_SUBMITTED_ARB;
- assert(which < MAX_PIPELINE_STATISTICS);
return &ctx->Query.pipeline_stats[which];
}
@@ -405,6 +406,22 @@ _mesa_BeginQueryIndexed(GLenum target, GLuint index, GLuint id)
"glBeginQuery{Indexed}(query already active)");
return;
}
+
+ /* Section 2.14 Asynchronous Queries, page 84 of the OpenGL ES 3.0.4
+ * spec states:
+ *
+ * "BeginQuery generates an INVALID_OPERATION error if any of the
+ * following conditions hold: [...] id is the name of an
+ * existing query object whose type does not match target; [...]
+ *
+ * Similar wording exists in the OpenGL 4.5 spec, section 4.2. QUERY
+ * OBJECTS AND ASYNCHRONOUS QUERIES, page 43.
+ */
+ if (q->EverBound && q->Target != target) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBeginQuery{Indexed}(target mismatch)");
+ return;
+ }
}
q->Target = target;
@@ -666,7 +683,7 @@ _mesa_GetQueryObjectiv(GLuint id, GLenum pname, GLint *params)
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectivARB(id=%d is invalid or active)", id);
return;
@@ -717,7 +734,7 @@ _mesa_GetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectuivARB(id=%d is invalid or active)", id);
return;
@@ -771,7 +788,7 @@ _mesa_GetQueryObjecti64v(GLuint id, GLenum pname, GLint64EXT *params)
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectui64vARB(id=%d is invalid or active)", id);
return;
@@ -811,7 +828,7 @@ _mesa_GetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params)
if (id)
q = _mesa_lookup_query_object(ctx, id);
- if (!q || q->Active) {
+ if (!q || q->Active || !q->EverBound) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetQueryObjectuui64vARB(id=%d is invalid or active)", id);
return;
diff --git a/mesalib/src/mesa/main/rastpos.c b/mesalib/src/mesa/main/rastpos.c
index 2027a9bd0..54b2125a8 100644
--- a/mesalib/src/mesa/main/rastpos.c
+++ b/mesalib/src/mesa/main/rastpos.c
@@ -266,7 +266,7 @@ window_pos3f(GLfloat x, GLfloat y, GLfloat z)
{
GLuint texSet;
for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) {
- assert(texSet < Elements(ctx->Current.RasterTexCoords));
+ assert(texSet < ARRAY_SIZE(ctx->Current.RasterTexCoords));
COPY_4FV( ctx->Current.RasterTexCoords[texSet],
ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
}
@@ -496,7 +496,7 @@ void _mesa_init_rastpos( struct gl_context * ctx )
ctx->Current.RasterDistance = 0.0;
ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 );
- for (i = 0; i < Elements(ctx->Current.RasterTexCoords); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->Current.RasterTexCoords); i++)
ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 );
ctx->Current.RasterPosValid = GL_TRUE;
}
diff --git a/mesalib/src/mesa/main/rastpos.h b/mesalib/src/mesa/main/rastpos.h
index 2d36936de..dc28c68d4 100644
--- a/mesalib/src/mesa/main/rastpos.h
+++ b/mesalib/src/mesa/main/rastpos.h
@@ -32,7 +32,8 @@
#define RASTPOS_H
-#include "compiler.h"
+#include "glheader.h"
+
struct _glapi_table;
struct gl_context;
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index ca4b9431b..ed0104c9e 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -127,7 +127,7 @@ _mesa_readpixels_needs_slow_path(const struct gl_context *ctx, GLenum format,
_mesa_get_read_renderbuffer_for_format(ctx, format);
GLenum srcType;
- ASSERT(rb);
+ assert(rb);
/* There are different rules depending on the base format. */
switch (format) {
@@ -180,7 +180,7 @@ readpixels_can_use_memcpy(const struct gl_context *ctx, GLenum format, GLenum ty
struct gl_renderbuffer *rb =
_mesa_get_read_renderbuffer_for_format(ctx, format);
- ASSERT(rb);
+ assert(rb);
if (_mesa_readpixels_needs_slow_path(ctx, format, type, GL_FALSE)) {
return GL_FALSE;
@@ -313,10 +313,10 @@ read_depth_pixels( struct gl_context *ctx,
return;
/* clipping should have been done already */
- ASSERT(x >= 0);
- ASSERT(y >= 0);
- ASSERT(x + width <= (GLint) rb->Width);
- ASSERT(y + height <= (GLint) rb->Height);
+ assert(x >= 0);
+ assert(y >= 0);
+ assert(x + width <= (GLint) rb->Width);
+ assert(y + height <= (GLint) rb->Height);
if (type == GL_UNSIGNED_INT &&
read_uint_depth_pixels(ctx, x, y, width, height, type, pixels, packing)) {
@@ -594,6 +594,7 @@ read_rgba_pixels( struct gl_context *ctx,
_mesa_format_convert(dst, dst_format, dst_stride,
luminance, luminance_format, luminance_stride,
width, height, NULL);
+ free(luminance);
} else {
_mesa_pack_luminance_from_rgba_integer(width * height, src, !src_is_uint,
dst, format, type);
diff --git a/mesalib/src/mesa/main/remap.c b/mesalib/src/mesa/main/remap.c
index 4a881865a..5a9538772 100644
--- a/mesalib/src/mesa/main/remap.c
+++ b/mesalib/src/mesa/main/remap.c
@@ -60,7 +60,7 @@ int driDispatchRemapTable[driDispatchRemapTable_size];
const char *
_mesa_get_function_spec(GLint func_index)
{
- if (func_index < Elements(_mesa_function_pool))
+ if (func_index < ARRAY_SIZE(_mesa_function_pool))
return _mesa_function_pool + func_index;
else
return NULL;
@@ -197,7 +197,7 @@ _mesa_do_init_remap_table(const char *pool,
const char *spec;
/* sanity check */
- ASSERT(i == remap[i].remap_index);
+ assert(i == remap[i].remap_index);
spec = _mesa_function_pool + remap[i].pool_index;
offset = _mesa_map_function_spec(spec);
diff --git a/mesalib/src/mesa/main/remap.h b/mesalib/src/mesa/main/remap.h
index 7199169d3..9d91b83c1 100644
--- a/mesalib/src/mesa/main/remap.h
+++ b/mesalib/src/mesa/main/remap.h
@@ -27,8 +27,6 @@
#define REMAP_H
-#include "main/compiler.h"
-
struct gl_function_pool_remap {
int pool_index;
int remap_index;
diff --git a/mesalib/src/mesa/main/renderbuffer.c b/mesalib/src/mesa/main/renderbuffer.c
index 98f3c13b5..e9d129a1d 100644
--- a/mesalib/src/mesa/main/renderbuffer.c
+++ b/mesalib/src/mesa/main/renderbuffer.c
@@ -172,7 +172,7 @@ _mesa_reference_renderbuffer_(struct gl_renderbuffer **ptr,
struct gl_renderbuffer *oldRb = *ptr;
mtx_lock(&oldRb->Mutex);
- ASSERT(oldRb->RefCount > 0);
+ assert(oldRb->RefCount > 0);
oldRb->RefCount--;
/*printf("RB DECR %p (%d) to %d\n", (void*) oldRb, oldRb->Name, oldRb->RefCount);*/
deleteFlag = (oldRb->RefCount == 0);
diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c
index d62a06bf1..d66b0b5e8 100644
--- a/mesalib/src/mesa/main/samplerobj.c
+++ b/mesalib/src/mesa/main/samplerobj.c
@@ -89,7 +89,7 @@ _mesa_reference_sampler_object_(struct gl_context *ctx,
struct gl_sampler_object *oldSamp = *ptr;
/*mtx_lock(&oldSamp->Mutex);*/
- ASSERT(oldSamp->RefCount > 0);
+ assert(oldSamp->RefCount > 0);
oldSamp->RefCount--;
#if 0
printf("SamplerObj %p %d DECR to %d\n",
@@ -99,13 +99,13 @@ _mesa_reference_sampler_object_(struct gl_context *ctx,
/*mtx_unlock(&oldSamp->Mutex);*/
if (deleteFlag) {
- ASSERT(ctx->Driver.DeleteSamplerObject);
+ assert(ctx->Driver.DeleteSamplerObject);
ctx->Driver.DeleteSamplerObject(ctx, oldSamp);
}
*ptr = NULL;
}
- ASSERT(!*ptr);
+ assert(!*ptr);
if (samp) {
/* reference new sampler */
diff --git a/mesalib/src/mesa/main/shaderapi.c b/mesalib/src/mesa/main/shaderapi.c
index 52eab4655..5731d581a 100644
--- a/mesalib/src/mesa/main/shaderapi.c
+++ b/mesalib/src/mesa/main/shaderapi.c
@@ -523,7 +523,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
GLint *params)
{
struct gl_shader_program *shProg
- = _mesa_lookup_shader_program(ctx, program);
+ = _mesa_lookup_shader_program_err(ctx, program, "glGetProgramiv(program)");
/* Is transform feedback available in this context?
*/
@@ -546,7 +546,6 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
|| _mesa_is_gles3(ctx);
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)");
return;
}
@@ -764,11 +763,25 @@ static void
get_program_info_log(struct gl_context *ctx, GLuint program, GLsizei bufSize,
GLsizei *length, GLchar *infoLog)
{
- struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program);
+ struct gl_shader_program *shProg;
+
+ /* Section 2.5 GL Errors (page 18) of the OpenGL ES 3.0.4 spec and
+ * section 2.3.1 (Errors) of the OpenGL 4.5 spec say:
+ *
+ * "If a negative number is provided where an argument of type sizei or
+ * sizeiptr is specified, an INVALID_VALUE error is generated."
+ */
+ if (bufSize < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(bufSize < 0)");
+ return;
+ }
+
+ shProg = _mesa_lookup_shader_program_err(ctx, program,
+ "glGetProgramInfoLog(program)");
if (!shProg) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramInfoLog(program)");
return;
}
+
_mesa_copy_string(infoLog, bufSize, length, shProg->InfoLog);
}
@@ -777,11 +790,24 @@ static void
get_shader_info_log(struct gl_context *ctx, GLuint shader, GLsizei bufSize,
GLsizei *length, GLchar *infoLog)
{
- struct gl_shader *sh = _mesa_lookup_shader(ctx, shader);
+ struct gl_shader *sh;
+
+ /* Section 2.5 GL Errors (page 18) of the OpenGL ES 3.0.4 spec and
+ * section 2.3.1 (Errors) of the OpenGL 4.5 spec say:
+ *
+ * "If a negative number is provided where an argument of type sizei or
+ * sizeiptr is specified, an INVALID_VALUE error is generated."
+ */
+ if (bufSize < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(bufSize < 0)");
+ return;
+ }
+
+ sh = _mesa_lookup_shader_err(ctx, shader, "glGetShaderInfoLog(shader)");
if (!sh) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGetShaderInfoLog(shader)");
return;
}
+
_mesa_copy_string(infoLog, bufSize, length, sh->InfoLog);
}
@@ -1713,7 +1739,7 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length,
* Ensure that length always points to valid storage to avoid multiple NULL
* pointer checks below.
*/
- if (length != NULL)
+ if (length == NULL)
length = &length_dummy;
diff --git a/mesalib/src/mesa/main/shaderobj.c b/mesalib/src/mesa/main/shaderobj.c
index 02ccf450b..d7620c8ef 100644
--- a/mesalib/src/mesa/main/shaderobj.c
+++ b/mesalib/src/mesa/main/shaderobj.c
@@ -67,7 +67,7 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
GLboolean deleteFlag = GL_FALSE;
struct gl_shader *old = *ptr;
- ASSERT(old->RefCount > 0);
+ assert(old->RefCount > 0);
old->RefCount--;
/*printf("SHADER DECR %p (%d) to %d\n",
(void*) old, old->Name, old->RefCount);*/
@@ -207,7 +207,7 @@ _mesa_reference_shader_program_(struct gl_context *ctx,
GLboolean deleteFlag = GL_FALSE;
struct gl_shader_program *old = *ptr;
- ASSERT(old->RefCount > 0);
+ assert(old->RefCount > 0);
old->RefCount--;
#if 0
printf("ShaderProgram %p ID=%u RefCount-- to %d\n",
diff --git a/mesalib/src/mesa/main/shaderobj.h b/mesalib/src/mesa/main/shaderobj.h
index 92f7a33ee..3d696a188 100644
--- a/mesalib/src/mesa/main/shaderobj.h
+++ b/mesalib/src/mesa/main/shaderobj.h
@@ -114,7 +114,7 @@ _mesa_shader_enum_to_shader_stage(GLenum v)
case GL_COMPUTE_SHADER:
return MESA_SHADER_COMPUTE;
default:
- ASSERT(0 && "bad value in _mesa_shader_enum_to_shader_stage()");
+ assert(0 && "bad value in _mesa_shader_enum_to_shader_stage()");
return MESA_SHADER_VERTEX;
}
}
diff --git a/mesalib/src/mesa/main/shared.c b/mesalib/src/mesa/main/shared.c
index ccf5355f3..0b76cc012 100644
--- a/mesalib/src/mesa/main/shared.c
+++ b/mesalib/src/mesa/main/shared.c
@@ -105,7 +105,7 @@ _mesa_alloc_shared_state(struct gl_context *ctx)
GL_TEXTURE_2D,
GL_TEXTURE_1D
};
- STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS);
+ STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS);
shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]);
}
@@ -159,7 +159,7 @@ delete_program_cb(GLuint id, void *data, void *userData)
struct gl_program *prog = (struct gl_program *) data;
struct gl_context *ctx = (struct gl_context *) userData;
if(prog != &_mesa_DummyProgram) {
- ASSERT(prog->RefCount == 1); /* should only be referenced by hash table */
+ assert(prog->RefCount == 1); /* should only be referenced by hash table */
prog->RefCount = 0; /* now going away */
ctx->Driver.DeleteProgram(ctx, prog);
}
@@ -223,7 +223,7 @@ delete_shader_cb(GLuint id, void *data, void *userData)
}
else {
struct gl_shader_program *shProg = (struct gl_shader_program *) data;
- ASSERT(shProg->Type == GL_SHADER_PROGRAM_MESA);
+ assert(shProg->Type == GL_SHADER_PROGRAM_MESA);
ctx->Driver.DeleteShaderProgram(ctx, shProg);
}
}
@@ -346,7 +346,7 @@ free_shared_state(struct gl_context *ctx, struct gl_shared_state *shared)
* Free texture objects (after FBOs since some textures might have
* been bound to FBOs).
*/
- ASSERT(ctx->Driver.DeleteTexture);
+ assert(ctx->Driver.DeleteTexture);
/* the default textures */
for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
ctx->Driver.DeleteTexture(ctx, shared->DefaultTex[i]);
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index 45bce78fd..dadfb3c8c 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -275,7 +275,7 @@ update_viewport_matrix(struct gl_context *ctx)
const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
unsigned i;
- ASSERT(depthMax > 0);
+ assert(depthMax > 0);
/* Compute scale and bias values. This is really driver-specific
* and should be maintained elsewhere if at all.
diff --git a/mesalib/src/mesa/main/stencil.h b/mesalib/src/mesa/main/stencil.h
index 6480b2adc..3302cb947 100644
--- a/mesalib/src/mesa/main/stencil.h
+++ b/mesalib/src/mesa/main/stencil.h
@@ -33,6 +33,7 @@
#include "glheader.h"
+#include "macros.h"
struct gl_context;
diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c
index b4efeee3b..00234d4cc 100644
--- a/mesalib/src/mesa/main/texcompress.c
+++ b/mesalib/src/mesa/main/texcompress.c
@@ -570,8 +570,8 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
_mesa_get_format_block_size(mesaFormat, &bw, &bh);
- ASSERT(col % bw == 0);
- ASSERT(row % bh == 0);
+ assert(col % bw == 0);
+ assert(row % bh == 0);
offset = ((width + bw - 1) / bw) * (row / bh) + col / bw;
offset *= blockSize;
diff --git a/mesalib/src/mesa/main/texcompress_bptc.c b/mesalib/src/mesa/main/texcompress_bptc.c
index c944ac26f..a600180e2 100644
--- a/mesalib/src/mesa/main/texcompress_bptc.c
+++ b/mesalib/src/mesa/main/texcompress_bptc.c
@@ -1630,7 +1630,7 @@ texstore_bptc_rgb_float(TEXSTORE_PARAMS,
GLboolean
_mesa_texstore_bptc_rgb_signed_float(TEXSTORE_PARAMS)
{
- ASSERT(dstFormat == MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT);
+ assert(dstFormat == MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT);
return texstore_bptc_rgb_float(ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
@@ -1643,7 +1643,7 @@ _mesa_texstore_bptc_rgb_signed_float(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_bptc_rgb_unsigned_float(TEXSTORE_PARAMS)
{
- ASSERT(dstFormat == MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT);
+ assert(dstFormat == MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT);
return texstore_bptc_rgb_float(ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
diff --git a/mesalib/src/mesa/main/texcompress_cpal.c b/mesalib/src/mesa/main/texcompress_cpal.c
index 54e9af41d..c46ef8c53 100644
--- a/mesalib/src/mesa/main/texcompress_cpal.c
+++ b/mesalib/src/mesa/main/texcompress_cpal.c
@@ -32,7 +32,6 @@
#include "glheader.h"
-#include "compiler.h" /* for ASSERT */
#include "context.h"
#include "mtypes.h"
#include "imports.h"
@@ -120,7 +119,7 @@ _mesa_cpal_compressed_size(int level, GLenum internalFormat,
}
info = &formats[internalFormat - GL_PALETTE4_RGB8_OES];
- ASSERT(info->cpal_format == internalFormat);
+ assert(info->cpal_format == internalFormat);
expect_size = info->palette_size * info->size;
for (lvl = 0; lvl < num_levels; lvl++) {
diff --git a/mesalib/src/mesa/main/texcompress_etc.c b/mesalib/src/mesa/main/texcompress_etc.c
index 98b4fe201..f29561cc6 100644
--- a/mesalib/src/mesa/main/texcompress_etc.c
+++ b/mesalib/src/mesa/main/texcompress_etc.c
@@ -108,7 +108,7 @@ GLboolean
_mesa_texstore_etc1_rgb8(TEXSTORE_PARAMS)
{
/* GL_ETC1_RGB8_OES is only valid in glCompressedTexImage2D */
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1099,7 +1099,7 @@ etc2_unpack_srgb8_punchthrough_alpha1(uint8_t *dst_row,
GLboolean
_mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1107,7 +1107,7 @@ _mesa_texstore_etc2_rgb8(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1115,7 +1115,7 @@ _mesa_texstore_etc2_srgb8(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1123,7 +1123,7 @@ _mesa_texstore_etc2_rgba8_eac(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1131,7 +1131,7 @@ _mesa_texstore_etc2_srgb8_alpha8_eac(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1139,7 +1139,7 @@ _mesa_texstore_etc2_r11_eac(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1147,7 +1147,7 @@ _mesa_texstore_etc2_signed_r11_eac(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1155,7 +1155,7 @@ _mesa_texstore_etc2_rg11_eac(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1163,7 +1163,7 @@ _mesa_texstore_etc2_signed_rg11_eac(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
@@ -1171,7 +1171,7 @@ _mesa_texstore_etc2_rgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
GLboolean
_mesa_texstore_etc2_srgb8_punchthrough_alpha1(TEXSTORE_PARAMS)
{
- ASSERT(0);
+ assert(0);
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/main/texcompress_fxt1.c b/mesalib/src/mesa/main/texcompress_fxt1.c
index 7b25e1039..562359410 100644
--- a/mesalib/src/mesa/main/texcompress_fxt1.c
+++ b/mesalib/src/mesa/main/texcompress_fxt1.c
@@ -61,7 +61,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
GLubyte *dst;
const GLubyte *tempImage = NULL;
- ASSERT(dstFormat == MESA_FORMAT_RGB_FXT1);
+ assert(dstFormat == MESA_FORMAT_RGB_FXT1);
if (srcFormat != GL_RGB ||
srcType != GL_UNSIGNED_BYTE ||
@@ -116,7 +116,7 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
GLubyte *dst;
const GLubyte *tempImage = NULL;
- ASSERT(dstFormat == MESA_FORMAT_RGBA_FXT1);
+ assert(dstFormat == MESA_FORMAT_RGBA_FXT1);
if (srcFormat != GL_RGBA ||
srcType != GL_UNSIGNED_BYTE ||
@@ -1264,12 +1264,12 @@ upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,
{
GLint i, j, k;
- ASSERT(outWidth >= inWidth);
- ASSERT(outHeight >= inHeight);
+ assert(outWidth >= inWidth);
+ assert(outHeight >= inHeight);
#if 0
- ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2);
- ASSERT((outWidth & 3) == 0);
- ASSERT((outHeight & 3) == 0);
+ assert(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2);
+ assert((outWidth & 3) == 0);
+ assert((outHeight & 3) == 0);
#endif
for (i = 0; i < outHeight; i++) {
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c
index e3042011a..f40e4e6c0 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.c
+++ b/mesalib/src/mesa/main/texcompress_rgtc.c
@@ -86,7 +86,7 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
GLint dstRowDiff, redRowStride;
GLubyte *tempImageSlices[1];
- ASSERT(dstFormat == MESA_FORMAT_R_RGTC1_UNORM ||
+ assert(dstFormat == MESA_FORMAT_R_RGTC1_UNORM ||
dstFormat == MESA_FORMAT_L_LATC1_UNORM);
tempImage = malloc(srcWidth * srcHeight * 1 * sizeof(GLubyte));
@@ -139,7 +139,7 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
GLint dstRowDiff, redRowStride;
GLfloat *tempImageSlices[1];
- ASSERT(dstFormat == MESA_FORMAT_R_RGTC1_SNORM ||
+ assert(dstFormat == MESA_FORMAT_R_RGTC1_SNORM ||
dstFormat == MESA_FORMAT_L_LATC1_SNORM);
redRowStride = 1 * srcWidth * sizeof(GLfloat);
@@ -193,7 +193,7 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
mesa_format tempFormat;
GLubyte *tempImageSlices[1];
- ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2_UNORM ||
+ assert(dstFormat == MESA_FORMAT_RG_RGTC2_UNORM ||
dstFormat == MESA_FORMAT_LA_LATC2_UNORM);
if (baseInternalFormat == GL_RG)
@@ -258,7 +258,7 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
mesa_format tempFormat;
GLfloat *tempImageSlices[1];
- ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2_SNORM ||
+ assert(dstFormat == MESA_FORMAT_RG_RGTC2_SNORM ||
dstFormat == MESA_FORMAT_LA_LATC2_SNORM);
if (baseInternalFormat == GL_RG)
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.c b/mesalib/src/mesa/main/texcompress_s3tc.c
index bfb53dce4..41d00d4e9 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.c
+++ b/mesalib/src/mesa/main/texcompress_s3tc.c
@@ -133,7 +133,7 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
GLubyte *dst;
const GLubyte *tempImage = NULL;
- ASSERT(dstFormat == MESA_FORMAT_RGB_DXT1 ||
+ assert(dstFormat == MESA_FORMAT_RGB_DXT1 ||
dstFormat == MESA_FORMAT_SRGB_DXT1);
if (srcFormat != GL_RGB ||
@@ -190,7 +190,7 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
GLubyte *dst;
const GLubyte *tempImage = NULL;
- ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
+ assert(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
dstFormat == MESA_FORMAT_SRGBA_DXT1);
if (srcFormat != GL_RGBA ||
@@ -247,7 +247,7 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
GLubyte *dst;
const GLubyte *tempImage = NULL;
- ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
+ assert(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
dstFormat == MESA_FORMAT_SRGBA_DXT3);
if (srcFormat != GL_RGBA ||
@@ -303,7 +303,7 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
GLubyte *dst;
const GLubyte *tempImage = NULL;
- ASSERT(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
+ assert(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
dstFormat == MESA_FORMAT_SRGBA_DXT5);
if (srcFormat != GL_RGBA ||
diff --git a/mesalib/src/mesa/main/texcompress_s3tc.h b/mesalib/src/mesa/main/texcompress_s3tc.h
index 2734210a5..438b71fe3 100644
--- a/mesalib/src/mesa/main/texcompress_s3tc.h
+++ b/mesalib/src/mesa/main/texcompress_s3tc.h
@@ -25,7 +25,6 @@
#ifndef TEXCOMPRESS_S3TC_H
#define TEXCOMPRESS_S3TC_H
-#include "compiler.h"
#include "glheader.h"
#include "texstore.h"
#include "texcompress.h"
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index ec16af9d2..3c4baca70 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -430,12 +430,12 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
case GL_RGB9_E5:
/* GL_EXT_texture_shared_exponent -- just one format to support */
- ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_R9G9B9E5_FLOAT]);
+ assert(ctx->TextureFormatSupported[MESA_FORMAT_R9G9B9E5_FLOAT]);
return MESA_FORMAT_R9G9B9E5_FLOAT;
case GL_R11F_G11F_B10F:
/* GL_EXT_texture_packed_float -- just one format to support */
- ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_R11G11B10_FLOAT]);
+ assert(ctx->TextureFormatSupported[MESA_FORMAT_R11G11B10_FLOAT]);
return MESA_FORMAT_R11G11B10_FLOAT;
case GL_DEPTH_STENCIL_EXT:
@@ -445,10 +445,10 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target,
break;
case GL_DEPTH_COMPONENT32F:
- ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z_FLOAT32]);
+ assert(ctx->TextureFormatSupported[MESA_FORMAT_Z_FLOAT32]);
return MESA_FORMAT_Z_FLOAT32;
case GL_DEPTH32F_STENCIL8:
- ASSERT(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_S8X24_UINT]);
+ assert(ctx->TextureFormatSupported[MESA_FORMAT_Z32_FLOAT_S8X24_UINT]);
return MESA_FORMAT_Z32_FLOAT_S8X24_UINT;
case GL_RED_SNORM:
diff --git a/mesalib/src/mesa/main/texgen.h b/mesalib/src/mesa/main/texgen.h
index aad5d2ecf..84adfc061 100644
--- a/mesalib/src/mesa/main/texgen.h
+++ b/mesalib/src/mesa/main/texgen.h
@@ -27,7 +27,6 @@
#define TEXGEN_H
-#include "compiler.h"
#include "glheader.h"
struct _glapi_table;
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 24df5b6f8..f975c160e 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -375,7 +375,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
GLuint height = texImage->Height;
GLuint depth = texImage->Depth;
GLuint img;
- GLboolean dst_is_integer = _mesa_is_enum_format_integer(format);
+ GLboolean dst_is_integer;
uint32_t dst_format;
int dst_stride;
uint8_t rebaseSwizzle[4];
@@ -423,6 +423,7 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions,
* integer then transferOps do not apply.
*/
assert(!transferOps || (transferOps && !dst_is_integer));
+ (void) dst_is_integer; /* silence unused var warning */
for (img = 0; img < depth; img++) {
GLubyte *srcMap;
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 29c325bf2..611d664b6 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -224,7 +224,10 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
if (ctx->Extensions.ARB_stencil_texturing) {
switch (internalFormat) {
case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1:
+ case GL_STENCIL_INDEX4:
case GL_STENCIL_INDEX8:
+ case GL_STENCIL_INDEX16:
return GL_STENCIL_INDEX;
default:
; /* fallthrough */
@@ -650,8 +653,8 @@ set_tex_image(struct gl_texture_object *tObj,
{
const GLuint face = _mesa_tex_target_to_face(target);
- ASSERT(tObj);
- ASSERT(texImage);
+ assert(tObj);
+ assert(texImage);
if (target == GL_TEXTURE_RECTANGLE_NV || target == GL_TEXTURE_EXTERNAL_OES)
assert(level == 0);
@@ -696,7 +699,7 @@ _mesa_delete_texture_image(struct gl_context *ctx,
/* Free texImage->Data and/or any other driver-specific texture
* image storage.
*/
- ASSERT(ctx->Driver.FreeTextureImageBuffer);
+ assert(ctx->Driver.FreeTextureImageBuffer);
ctx->Driver.FreeTextureImageBuffer( ctx, texImage );
free(texImage);
}
@@ -729,9 +732,9 @@ _mesa_is_proxy_texture(GLenum target)
* NUM_TEXTURE_TARGETS should match number of terms above, except there's no
* proxy for GL_TEXTURE_BUFFER and GL_TEXTURE_EXTERNAL_OES.
*/
- STATIC_ASSERT(NUM_TEXTURE_TARGETS == Elements(targets) + 2);
+ STATIC_ASSERT(NUM_TEXTURE_TARGETS == ARRAY_SIZE(targets) + 2);
- for (i = 0; i < Elements(targets); ++i)
+ for (i = 0; i < ARRAY_SIZE(targets); ++i)
if (target == targets[i])
return GL_TRUE;
return GL_FALSE;
@@ -739,6 +742,28 @@ _mesa_is_proxy_texture(GLenum target)
/**
+ * Test if a target is an array target.
+ *
+ * \param target texture target.
+ *
+ * \return true if the target is an array target, false otherwise.
+ */
+bool
+_mesa_is_array_texture(GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return true;
+ default:
+ return false;
+ };
+}
+
+
+/**
* Return the proxy target which corresponds to the given texture target
*/
static GLenum
@@ -807,9 +832,9 @@ _mesa_select_tex_image(const struct gl_texture_object *texObj,
{
const GLuint face = _mesa_tex_target_to_face(target);
- ASSERT(texObj);
- ASSERT(level >= 0);
- ASSERT(level < MAX_TEXTURE_LEVELS);
+ assert(texObj);
+ assert(level >= 0);
+ assert(level < MAX_TEXTURE_LEVELS);
return texObj->Image[face][level];
}
@@ -1239,7 +1264,7 @@ make_null_texture(GLint width, GLint height, GLint depth, GLenum format)
static void
clear_teximage_fields(struct gl_texture_image *img)
{
- ASSERT(img);
+ assert(img);
img->_BaseFormat = 0;
img->InternalFormat = 0;
img->Border = 0;
@@ -1284,14 +1309,14 @@ init_teximage_fields_ms(struct gl_context *ctx,
GLuint numSamples, GLboolean fixedSampleLocations)
{
GLenum target;
- ASSERT(img);
- ASSERT(width >= 0);
- ASSERT(height >= 0);
- ASSERT(depth >= 0);
+ assert(img);
+ assert(width >= 0);
+ assert(height >= 0);
+ assert(depth >= 0);
target = img->TexObject->Target;
img->_BaseFormat = _mesa_base_tex_format( ctx, internalFormat );
- ASSERT(img->_BaseFormat != -1);
+ assert(img->_BaseFormat != -1);
img->InternalFormat = internalFormat;
img->Border = border;
img->Width = width;
@@ -2184,7 +2209,7 @@ texture_error_check( struct gl_context *ctx,
/* additional checks for ycbcr textures */
if (internalFormat == GL_YCBCR_MESA) {
- ASSERT(ctx->Extensions.MESA_ycbcr_texture);
+ assert(ctx->Extensions.MESA_ycbcr_texture);
if (type != GL_UNSIGNED_SHORT_8_8_MESA &&
type != GL_UNSIGNED_SHORT_8_8_REV_MESA) {
char message[100];
@@ -2491,8 +2516,8 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
}
if (error_check_subtexture_dimensions(ctx, dimensions,
- texImage, xoffset, yoffset, 0,
- width, height, 1,
+ texImage, xoffset, yoffset, zoffset,
+ width, height, depth,
dsa ? "glTextureSubImage" :
"glTexSubImage")) {
return GL_TRUE;
@@ -2815,14 +2840,6 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
}
}
- /* check target (proxies not allowed) */
- if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTex%sSubImage%uD(target=%s)",
- suffix, dimensions,
- _mesa_lookup_enum_by_nr(target));
- return GL_TRUE;
- }
-
/* Check level */
if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -2933,7 +2950,7 @@ check_rtt_cb(GLuint key, void *data, void *userData)
att->TextureLevel == level &&
att->CubeMapFace == face) {
_mesa_update_texture_renderbuffer(ctx, ctx->DrawBuffer, att);
- ASSERT(att->Renderbuffer->TexImage);
+ assert(att->Renderbuffer->TexImage);
/* Mark fb status as indeterminate to force re-validation */
fb->_Status = 0;
}
@@ -2977,7 +2994,7 @@ check_gen_mipmap(struct gl_context *ctx, GLenum target,
if (texObj->GenerateMipmap &&
level == texObj->BaseLevel &&
level < texObj->MaxLevel) {
- ASSERT(ctx->Driver.GenerateMipmap);
+ assert(ctx->Driver.GenerateMipmap);
ctx->Driver.GenerateMipmap(ctx, target, texObj);
}
}
@@ -3054,7 +3071,7 @@ _mesa_choose_texture_format(struct gl_context *ctx,
prevImage->Width > 0 &&
prevImage->InternalFormat == internalFormat) {
/* use the same format */
- ASSERT(prevImage->TexFormat != MESA_FORMAT_NONE);
+ assert(prevImage->TexFormat != MESA_FORMAT_NONE);
return prevImage->TexFormat;
}
}
@@ -3093,7 +3110,7 @@ _mesa_choose_texture_format(struct gl_context *ctx,
/* choose format from scratch */
f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat,
format, type);
- ASSERT(f != MESA_FORMAT_NONE);
+ assert(f != MESA_FORMAT_NONE);
return f;
}
@@ -4088,6 +4105,16 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
struct gl_texture_object* texObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Check target (proxies not allowed). Target must be checked prior to
+ * calling _mesa_get_current_tex_object.
+ */
+ if (!legal_texsubimage_target(ctx, 1, target, false)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage1D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4106,6 +4133,16 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
struct gl_texture_object* texObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Check target (proxies not allowed). Target must be checked prior to
+ * calling _mesa_get_current_tex_object.
+ */
+ if (!legal_texsubimage_target(ctx, 2, target, false)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage2D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4125,6 +4162,16 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
struct gl_texture_object* texObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Check target (proxies not allowed). Target must be checked prior to
+ * calling _mesa_get_current_tex_object.
+ */
+ if (!legal_texsubimage_target(ctx, 3, target, false)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage3D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4145,6 +4192,14 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
if (!texObj)
return;
+ /* Check target (proxies not allowed). */
+ if (!legal_texsubimage_target(ctx, 1, texObj->Target, true)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTextureSubImage1D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(texObj->Target));
+ return;
+ }
+
_mesa_copy_texture_sub_image(ctx, 1, texObj, texObj->Target, level,
xoffset, 0, 0, x, y, width, 1, true);
}
@@ -4161,6 +4216,14 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
if (!texObj)
return;
+ /* Check target (proxies not allowed). */
+ if (!legal_texsubimage_target(ctx, 2, texObj->Target, true)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTextureSubImage2D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(texObj->Target));
+ return;
+ }
+
_mesa_copy_texture_sub_image(ctx, 2, texObj, texObj->Target, level,
xoffset, yoffset, 0,
x, y, width, height, true);
@@ -4180,6 +4243,14 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
if (!texObj)
return;
+ /* Check target (proxies not allowed). */
+ if (!legal_texsubimage_target(ctx, 3, texObj->Target, true)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTextureSubImage3D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(texObj->Target));
+ return;
+ }
+
_mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level,
xoffset, yoffset, zoffset,
x, y, width, height, true);
@@ -4454,25 +4525,21 @@ out:
/**
- * Error checking for glCompressedTexSubImage[123]D().
+ * Target checking for glCompressedTexSubImage[123]D().
* \return GL_TRUE if error, GL_FALSE if no error
+ * Must come before other error checking so that the texture object can
+ * be correctly retrieved using _mesa_get_current_tex_object.
*/
static GLboolean
-compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
- const struct gl_texture_object *texObj,
- GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLsizei imageSize, bool dsa)
+compressed_subtexture_target_check(struct gl_context *ctx, GLenum target,
+ GLint dims, GLenum format, bool dsa,
+ const char *caller)
{
- struct gl_texture_image *texImage;
- GLint expectedSize;
GLboolean targetOK;
- const char *suffix = dsa ? "ture" : "";
if (dsa && target == GL_TEXTURE_RECTANGLE) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glCompressedSubTexture%dD(target)", dims);
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
return GL_TRUE;
}
@@ -4535,7 +4602,9 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
}
if (invalidformat) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glCompressedTex%sSubImage%uD(target)", suffix, dims);
+ "%s(invalid target %s for format %s)", caller,
+ _mesa_lookup_enum_by_nr(target),
+ _mesa_lookup_enum_by_nr(format));
return GL_TRUE;
}
}
@@ -4549,11 +4618,30 @@ compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
}
if (!targetOK) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glCompressedTex%sSubImage%uD(target)", suffix, dims);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
return GL_TRUE;
}
+ return GL_FALSE;
+}
+
+/**
+ * Error checking for glCompressedTexSubImage[123]D().
+ * \return GL_TRUE if error, GL_FALSE if no error
+ */
+static GLboolean
+compressed_subtexture_error_check(struct gl_context *ctx, GLint dims,
+ const struct gl_texture_object *texObj,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLsizei imageSize, bool dsa)
+{
+ struct gl_texture_image *texImage;
+ GLint expectedSize;
+ const char *suffix = dsa ? "ture" : "";
+
/* this will catch any invalid compressed format token */
if (!_mesa_is_compressed_format(ctx, format)) {
_mesa_error(ctx, GL_INVALID_ENUM,
@@ -4709,6 +4797,11 @@ _mesa_CompressedTexSubImage1D(GLenum target, GLint level, GLint xoffset,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (compressed_subtexture_target_check(ctx, target, 1, format, false,
+ "glCompressedTexSubImage1D")) {
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4731,6 +4824,12 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
if (!texObj)
return;
+ if (compressed_subtexture_target_check(ctx, texObj->Target, 1, format,
+ true,
+ "glCompressedTextureSubImage1D")) {
+ return;
+ }
+
_mesa_compressed_texture_sub_image(ctx, 1, texObj, texObj->Target, level,
xoffset, 0, 0, width, 1, 1,
format, imageSize, data, true);
@@ -4746,6 +4845,11 @@ _mesa_CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (compressed_subtexture_target_check(ctx, target, 2, format, false,
+ "glCompressedTexSubImage2D")) {
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4770,6 +4874,12 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
if (!texObj)
return;
+ if (compressed_subtexture_target_check(ctx, texObj->Target, 2, format,
+ true,
+ "glCompressedTextureSubImage2D")) {
+ return;
+ }
+
_mesa_compressed_texture_sub_image(ctx, 2, texObj, texObj->Target, level,
xoffset, yoffset, 0, width, height, 1,
format, imageSize, data, true);
@@ -4784,6 +4894,11 @@ _mesa_CompressedTexSubImage3D(GLenum target, GLint level, GLint xoffset,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (compressed_subtexture_target_check(ctx, target, 3, format, false,
+ "glCompressedTexSubImage3D")) {
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4809,6 +4924,12 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
if (!texObj)
return;
+ if (compressed_subtexture_target_check(ctx, texObj->Target, 3, format,
+ true,
+ "glCompressedTextureSubImage3D")) {
+ return;
+ }
+
_mesa_compressed_texture_sub_image(ctx, 3, texObj, texObj->Target, level,
xoffset, yoffset, zoffset,
width, height, depth,
@@ -5031,7 +5152,7 @@ _mesa_validate_texbuffer_format(const struct gl_context *ctx,
void
_mesa_texture_buffer_range(struct gl_context *ctx,
- struct gl_texture_object *texObj, GLenum target,
+ struct gl_texture_object *texObj, GLenum target,
GLenum internalFormat,
struct gl_buffer_object *bufObj,
GLintptr offset, GLsizeiptr size, bool range,
diff --git a/mesalib/src/mesa/main/teximage.h b/mesalib/src/mesa/main/teximage.h
index 02b0eda38..b7336bc6c 100644
--- a/mesalib/src/mesa/main/teximage.h
+++ b/mesalib/src/mesa/main/teximage.h
@@ -66,6 +66,9 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat );
extern GLboolean
_mesa_is_proxy_texture(GLenum target);
+extern bool
+_mesa_is_array_texture(GLenum target);
+
extern struct gl_texture_image *
_mesa_new_texture_image( struct gl_context *ctx );
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index 59090db4e..e018ab910 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -28,6 +28,7 @@
*/
+#include <stdio.h>
#include "bufferobj.h"
#include "colortab.h"
#include "context.h"
@@ -265,7 +266,7 @@ _mesa_initialize_texture_object( struct gl_context *ctx,
struct gl_texture_object *obj,
GLuint name, GLenum target )
{
- ASSERT(target == 0 ||
+ assert(target == 0 ||
target == GL_TEXTURE_1D ||
target == GL_TEXTURE_2D ||
target == GL_TEXTURE_3D ||
@@ -541,11 +542,11 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr,
GLboolean deleteFlag = GL_FALSE;
struct gl_texture_object *oldTex = *ptr;
- ASSERT(valid_texture_object(oldTex));
+ assert(valid_texture_object(oldTex));
(void) valid_texture_object; /* silence warning in release builds */
mtx_lock(&oldTex->Mutex);
- ASSERT(oldTex->RefCount > 0);
+ assert(oldTex->RefCount > 0);
oldTex->RefCount--;
deleteFlag = (oldTex->RefCount == 0);
@@ -568,7 +569,7 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr,
if (tex) {
/* reference new texture */
- ASSERT(valid_texture_object(tex));
+ assert(valid_texture_object(tex));
mtx_lock(&tex->Mutex);
if (tex->RefCount == 0) {
/* this texture's being deleted (look just above) */
@@ -730,7 +731,7 @@ _mesa_test_texobj_completeness( const struct gl_context *ctx,
return;
}
- ASSERT(maxLevels > 0);
+ assert(maxLevels > 0);
t->_MaxLevel = MIN3(t->MaxLevel,
/* 'p' in the GL spec */
@@ -1724,7 +1725,7 @@ _mesa_BindTexture( GLenum target, GLuint texName )
_mesa_reference_texobj(&texUnit->CurrentTex[targetIndex], newTexObj);
ctx->Texture.NumCurrentTexUsed = MAX2(ctx->Texture.NumCurrentTexUsed,
ctx->Texture.CurrentUnit + 1);
- ASSERT(texUnit->CurrentTex[targetIndex]);
+ assert(texUnit->CurrentTex[targetIndex]);
if (texName != 0)
texUnit->_BoundTextures |= (1 << targetIndex);
@@ -1773,7 +1774,7 @@ _mesa_bind_texture_unit(struct gl_context *ctx,
_mesa_reference_texobj(&texUnit->CurrentTex[texObj->TargetIndex],
texObj);
- ASSERT(texUnit->CurrentTex[texObj->TargetIndex]);
+ assert(texUnit->CurrentTex[texObj->TargetIndex]);
ctx->Texture.NumCurrentTexUsed = MAX2(ctx->Texture.NumCurrentTexUsed,
unit + 1);
texUnit->_BoundTextures |= (1 << texObj->TargetIndex);
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index c4a5841c5..1ef728660 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -217,8 +217,8 @@ comp_to_swizzle(GLenum comp)
static void
set_swizzle_component(GLuint *swizzle, GLuint comp, GLuint swz)
{
- ASSERT(comp < 4);
- ASSERT(swz <= SWIZZLE_NIL);
+ assert(comp < 4);
+ assert(swz <= SWIZZLE_NIL);
{
GLuint mask = 0x7 << (3 * comp);
GLuint s = (*swizzle & ~mask) | (swz << (3 * comp));
@@ -537,7 +537,7 @@ set_tex_parameteri(struct gl_context *ctx,
"glTex%sParameter(swizzle 0x%x)", suffix, params[0]);
return GL_FALSE;
}
- ASSERT(comp < 4);
+ assert(comp < 4);
flush(ctx);
texObj->Swizzle[comp] = params[0];
diff --git a/mesalib/src/mesa/main/texstate.c b/mesalib/src/mesa/main/texstate.c
index 99c7c8178..0a7f983fb 100644
--- a/mesalib/src/mesa/main/texstate.c
+++ b/mesalib/src/mesa/main/texstate.c
@@ -28,6 +28,7 @@
* Texture state handling.
*/
+#include <stdio.h>
#include "glheader.h"
#include "bufferobj.h"
#include "colormac.h"
@@ -68,8 +69,8 @@ _mesa_copy_texture_state( const struct gl_context *src, struct gl_context *dst )
{
GLuint u, tex;
- ASSERT(src);
- ASSERT(dst);
+ assert(src);
+ assert(dst);
dst->Texture.CurrentUnit = src->Texture.CurrentUnit;
dst->Texture._GenFlags = src->Texture._GenFlags;
@@ -292,7 +293,7 @@ _mesa_ActiveTexture(GLenum texture)
k = _mesa_max_tex_unit(ctx);
- ASSERT(k <= Elements(ctx->Texture.Unit));
+ assert(k <= ARRAY_SIZE(ctx->Texture.Unit));
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
_mesa_debug(ctx, "glActiveTexture %s\n",
@@ -363,7 +364,7 @@ update_texture_matrices( struct gl_context *ctx )
ctx->Texture._TexMatEnabled = 0x0;
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
- ASSERT(u < Elements(ctx->TextureMatrixStack));
+ assert(u < ARRAY_SIZE(ctx->TextureMatrixStack));
if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) {
_math_matrix_analyse( ctx->TextureMatrixStack[u].Top );
@@ -501,7 +502,7 @@ update_texgen(struct gl_context *ctx)
ctx->Texture._GenFlags |= texUnit->_GenFlags;
}
- ASSERT(unit < Elements(ctx->TextureMatrixStack));
+ assert(unit < ARRAY_SIZE(ctx->TextureMatrixStack));
if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
}
@@ -797,7 +798,7 @@ alloc_proxy_textures( struct gl_context *ctx )
};
GLint tgt;
- STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS);
+ STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS);
assert(targets[TEXTURE_2D_INDEX] == GL_TEXTURE_2D);
assert(targets[TEXTURE_CUBE_INDEX] == GL_TEXTURE_CUBE_MAP);
@@ -882,10 +883,19 @@ _mesa_init_texture(struct gl_context *ctx)
* "OpenGL ES 3.0 requires that all cube map filtering be
* seamless. OpenGL ES 2.0 specified that a single cube map face be
* selected and used for filtering."
+ *
+ * Unfortunatley, a call to _mesa_is_gles3 below will only work if
+ * the driver has already computed and set ctx->Version, however drivers
+ * seem to call _mesa_initialize_context (which calls this) early
+ * in the CreateContext hook and _mesa_compute_version much later (since
+ * it needs information about available extensions). So, we will
+ * enable seamless cubemaps by default since GLES2. This should work
+ * for most implementations and drivers that don't support seamless
+ * cubemaps for GLES2 can still disable it.
*/
- ctx->Texture.CubeMapSeamless = _mesa_is_gles3(ctx);
+ ctx->Texture.CubeMapSeamless = ctx->API == API_OPENGLES2;
- for (u = 0; u < Elements(ctx->Texture.Unit); u++)
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++)
init_texture_unit(ctx, u);
/* After we're done initializing the context's texture state the default
@@ -918,7 +928,7 @@ _mesa_free_texture_data(struct gl_context *ctx)
GLuint u, tgt;
/* unreference current textures */
- for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
/* The _Current texture could account for another reference */
_mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL);
@@ -934,7 +944,7 @@ _mesa_free_texture_data(struct gl_context *ctx)
/* GL_ARB_texture_buffer_object */
_mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
- for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
_mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL);
}
}
@@ -950,7 +960,7 @@ _mesa_update_default_objects_texture(struct gl_context *ctx)
{
GLuint u, tex;
- for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
_mesa_reference_texobj(&texUnit->CurrentTex[tex],
diff --git a/mesalib/src/mesa/main/texstate.h b/mesalib/src/mesa/main/texstate.h
index abc07eafb..662435b47 100644
--- a/mesalib/src/mesa/main/texstate.h
+++ b/mesalib/src/mesa/main/texstate.h
@@ -41,7 +41,7 @@
static inline struct gl_texture_unit *
_mesa_get_tex_unit(struct gl_context *ctx, GLuint unit)
{
- ASSERT(unit < Elements(ctx->Texture.Unit));
+ assert(unit < ARRAY_SIZE(ctx->Texture.Unit));
return &(ctx->Texture.Unit[unit]);
}
diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c
index 3ace5e8bb..53cb2c091 100644
--- a/mesalib/src/mesa/main/texstorage.c
+++ b/mesalib/src/mesa/main/texstorage.c
@@ -171,7 +171,7 @@ clear_texture_fields(struct gl_context *ctx,
GLint level;
GLuint face;
- for (level = 0; level < Elements(texObj->Image[0]); level++) {
+ for (level = 0; level < ARRAY_SIZE(texObj->Image[0]); level++) {
for (face = 0; face < numFaces; face++) {
struct gl_texture_image *texImage =
get_tex_image(ctx, texObj, face, level);
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index 7039cdf81..7ad9d2b68 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -154,9 +154,9 @@ _mesa_texstore_z32(TEXSTORE_PARAMS)
const GLuint depthScale = 0xffffffff;
GLenum dstType;
(void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z_UNORM32 ||
+ assert(dstFormat == MESA_FORMAT_Z_UNORM32 ||
dstFormat == MESA_FORMAT_Z_FLOAT32);
- ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint));
+ assert(_mesa_get_format_bytes(dstFormat) == sizeof(GLuint));
if (dstFormat == MESA_FORMAT_Z_UNORM32)
dstType = GL_UNSIGNED_INT;
@@ -191,7 +191,7 @@ _mesa_texstore_x8_z24(TEXSTORE_PARAMS)
const GLuint depthScale = 0xffffff;
(void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z24_UNORM_X8_UINT);
+ assert(dstFormat == MESA_FORMAT_Z24_UNORM_X8_UINT);
{
/* general path */
@@ -221,7 +221,7 @@ _mesa_texstore_z24_x8(TEXSTORE_PARAMS)
const GLuint depthScale = 0xffffff;
(void) dims;
- ASSERT(dstFormat == MESA_FORMAT_X8_UINT_Z24_UNORM);
+ assert(dstFormat == MESA_FORMAT_X8_UINT_Z24_UNORM);
{
/* general path */
@@ -254,8 +254,8 @@ _mesa_texstore_z16(TEXSTORE_PARAMS)
{
const GLuint depthScale = 0xffff;
(void) dims;
- ASSERT(dstFormat == MESA_FORMAT_Z_UNORM16);
- ASSERT(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort));
+ assert(dstFormat == MESA_FORMAT_Z_UNORM16);
+ assert(_mesa_get_format_bytes(dstFormat) == sizeof(GLushort));
{
/* general path */
@@ -287,14 +287,14 @@ _mesa_texstore_ycbcr(TEXSTORE_PARAMS)
(void) ctx; (void) dims; (void) baseInternalFormat;
- ASSERT((dstFormat == MESA_FORMAT_YCBCR) ||
+ assert((dstFormat == MESA_FORMAT_YCBCR) ||
(dstFormat == MESA_FORMAT_YCBCR_REV));
- ASSERT(_mesa_get_format_bytes(dstFormat) == 2);
- ASSERT(ctx->Extensions.MESA_ycbcr_texture);
- ASSERT(srcFormat == GL_YCBCR_MESA);
- ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
+ assert(_mesa_get_format_bytes(dstFormat) == 2);
+ assert(ctx->Extensions.MESA_ycbcr_texture);
+ assert(srcFormat == GL_YCBCR_MESA);
+ assert((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
(srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA));
- ASSERT(baseInternalFormat == GL_YCBCR_MESA);
+ assert(baseInternalFormat == GL_YCBCR_MESA);
/* always just memcpy since no pixel transfer ops apply */
memcpy_texture(ctx, dims,
@@ -335,11 +335,11 @@ _mesa_texstore_z24_s8(TEXSTORE_PARAMS)
GLuint *depth = malloc(srcWidth * sizeof(GLuint));
GLubyte *stencil = malloc(srcWidth * sizeof(GLubyte));
- ASSERT(dstFormat == MESA_FORMAT_S8_UINT_Z24_UNORM);
- ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT ||
+ assert(dstFormat == MESA_FORMAT_S8_UINT_Z24_UNORM);
+ assert(srcFormat == GL_DEPTH_STENCIL_EXT ||
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
- ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT ||
+ assert(srcFormat != GL_DEPTH_STENCIL_EXT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
@@ -414,11 +414,11 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
GLuint *depth;
GLubyte *stencil;
- ASSERT(dstFormat == MESA_FORMAT_Z24_UNORM_S8_UINT);
- ASSERT(srcFormat == GL_DEPTH_STENCIL_EXT ||
+ assert(dstFormat == MESA_FORMAT_Z24_UNORM_S8_UINT);
+ assert(srcFormat == GL_DEPTH_STENCIL_EXT ||
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
- ASSERT(srcFormat != GL_DEPTH_STENCIL_EXT ||
+ assert(srcFormat != GL_DEPTH_STENCIL_EXT ||
srcType == GL_UNSIGNED_INT_24_8_EXT ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
@@ -491,8 +491,8 @@ _mesa_texstore_s8_z24(TEXSTORE_PARAMS)
static GLboolean
_mesa_texstore_s8(TEXSTORE_PARAMS)
{
- ASSERT(dstFormat == MESA_FORMAT_S_UINT8);
- ASSERT(srcFormat == GL_STENCIL_INDEX);
+ assert(dstFormat == MESA_FORMAT_S_UINT8);
+ assert(srcFormat == GL_STENCIL_INDEX);
{
const GLint srcRowStride
@@ -543,11 +543,11 @@ _mesa_texstore_z32f_x24s8(TEXSTORE_PARAMS)
= _mesa_image_row_stride(srcPacking, srcWidth, srcFormat, srcType)
/ sizeof(uint64_t);
- ASSERT(dstFormat == MESA_FORMAT_Z32_FLOAT_S8X24_UINT);
- ASSERT(srcFormat == GL_DEPTH_STENCIL ||
+ assert(dstFormat == MESA_FORMAT_Z32_FLOAT_S8X24_UINT);
+ assert(srcFormat == GL_DEPTH_STENCIL ||
srcFormat == GL_DEPTH_COMPONENT ||
srcFormat == GL_STENCIL_INDEX);
- ASSERT(srcFormat != GL_DEPTH_STENCIL ||
+ assert(srcFormat != GL_DEPTH_STENCIL ||
srcType == GL_UNSIGNED_INT_24_8 ||
srcType == GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
@@ -606,7 +606,7 @@ texstore_depth_stencil(TEXSTORE_PARAMS)
initialized = GL_TRUE;
}
- ASSERT(table[dstFormat]);
+ assert(table[dstFormat]);
return table[dstFormat](ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
@@ -666,7 +666,7 @@ texstore_compressed(TEXSTORE_PARAMS)
initialized = GL_TRUE;
}
- ASSERT(table[dstFormat]);
+ assert(table[dstFormat]);
return table[dstFormat](ctx, dims, baseInternalFormat,
dstFormat, dstRowStride, dstSlices,
srcWidth, srcHeight, srcDepth,
@@ -1225,10 +1225,10 @@ _mesa_store_compressed_teximage(struct gl_context *ctx, GLuint dims,
* have to worry about the usual image unpacking or image transfer
* operations.
*/
- ASSERT(texImage);
- ASSERT(texImage->Width > 0);
- ASSERT(texImage->Height > 0);
- ASSERT(texImage->Depth > 0);
+ assert(texImage);
+ assert(texImage->Width > 0);
+ assert(texImage->Height > 0);
+ assert(texImage->Depth > 0);
/* allocate storage for texture data */
if (!ctx->Driver.AllocTextureImageBuffer(ctx, texImage)) {
diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c
index a73746335..a3e23ced5 100644
--- a/mesalib/src/mesa/main/transformfeedback.c
+++ b/mesalib/src/mesa/main/transformfeedback.c
@@ -93,7 +93,7 @@ reference_transform_feedback_object(struct gl_transform_feedback_object **ptr,
/* Unreference the old object */
struct gl_transform_feedback_object *oldObj = *ptr;
- ASSERT(oldObj->RefCount > 0);
+ assert(oldObj->RefCount > 0);
oldObj->RefCount--;
if (oldObj->RefCount == 0) {
@@ -104,7 +104,7 @@ reference_transform_feedback_object(struct gl_transform_feedback_object **ptr,
*ptr = NULL;
}
- ASSERT(!*ptr);
+ assert(!*ptr);
if (obj) {
/* reference new object */
@@ -143,7 +143,7 @@ void
_mesa_init_transform_feedback(struct gl_context *ctx)
{
/* core mesa expects this, even a dummy one, to be available */
- ASSERT(ctx->Driver.NewTransformFeedback);
+ assert(ctx->Driver.NewTransformFeedback);
ctx->TransformFeedback.DefaultObject =
ctx->Driver.NewTransformFeedback(ctx, 0);
@@ -185,7 +185,7 @@ void
_mesa_free_transform_feedback(struct gl_context *ctx)
{
/* core mesa expects this, even a dummy one, to be available */
- ASSERT(ctx->Driver.NewTransformFeedback);
+ assert(ctx->Driver.NewTransformFeedback);
_mesa_reference_buffer_object(ctx,
&ctx->TransformFeedback.CurrentBuffer,
@@ -235,7 +235,7 @@ delete_transform_feedback(struct gl_context *ctx,
{
GLuint i;
- for (i = 0; i < Elements(obj->Buffers); i++) {
+ for (i = 0; i < ARRAY_SIZE(obj->Buffers); i++) {
_mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL);
}
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index 40327fba4..9f82de952 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -762,7 +762,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
* been modified.
*/
bool changed = false;
- for (unsigned j = 0; j < Elements(prog->SamplerUnits); j++) {
+ for (unsigned j = 0; j < ARRAY_SIZE(prog->SamplerUnits); j++) {
if ((sh->active_samplers & (1U << j)) != 0
&& (prog->SamplerUnits[j] != sh->SamplerUnits[j])) {
changed = true;
diff --git a/mesalib/src/mesa/main/uniforms.c b/mesalib/src/mesa/main/uniforms.c
index e471b878c..fb1482f9c 100644
--- a/mesalib/src/mesa/main/uniforms.c
+++ b/mesalib/src/mesa/main/uniforms.c
@@ -81,7 +81,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
if (prog->SamplersUsed & (1 << s)) {
GLuint unit = shader->SamplerUnits[s];
GLuint tgt = shader->SamplerTargets[s];
- assert(unit < Elements(prog->TexturesUsed));
+ assert(unit < ARRAY_SIZE(prog->TexturesUsed));
assert(tgt < NUM_TEXTURE_TARGETS);
/* The types of the samplers associated with a particular texture
@@ -1142,6 +1142,8 @@ _mesa_GetActiveUniformBlockiv(GLuint program,
return;
case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
+ if (!_mesa_has_geometry_shaders(ctx))
+ break;
params[0] = shProg->UniformBlockStageIndex[MESA_SHADER_GEOMETRY][uniformBlockIndex] != -1;
return;
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index 978ec7b53..42e7f89b2 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -24,6 +24,7 @@
*/
+#include <stdio.h>
#include <inttypes.h> /* for PRId64 macro */
#include "glheader.h"
@@ -356,7 +357,7 @@ update_array_format(struct gl_context *ctx,
return false;
}
- ASSERT(size <= 4);
+ assert(size <= 4);
elementSize = _mesa_bytes_per_vertex_attrib(size, type);
assert(elementSize != -1);
@@ -714,7 +715,7 @@ _mesa_EnableVertexAttribArray(GLuint index)
vao = ctx->Array.VAO;
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
if (!vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
/* was disabled, now being enabled */
@@ -740,7 +741,7 @@ _mesa_DisableVertexAttribArray(GLuint index)
vao = ctx->Array.VAO;
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
if (vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
/* was enabled, now being disabled */
@@ -769,7 +770,7 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
return 0;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
array = &vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
@@ -834,7 +835,7 @@ get_current_attrib(struct gl_context *ctx, GLuint index, const char *function)
return NULL;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
FLUSH_CURRENT(ctx, 0);
return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)];
@@ -956,7 +957,7 @@ _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer)
return;
}
- ASSERT(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
*pointer = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr;
}
@@ -1348,7 +1349,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
return;
}
- ASSERT(genericIndex < Elements(ctx->Array.VAO->VertexAttrib));
+ assert(genericIndex < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
/* The ARB_vertex_attrib_binding spec says:
*
@@ -1802,8 +1803,8 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
return;
}
- ASSERT(VERT_ATTRIB_GENERIC(attribIndex) <
- Elements(ctx->Array.VAO->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(attribIndex) <
+ ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
vertex_attrib_binding(ctx, VERT_ATTRIB_GENERIC(attribIndex),
VERT_ATTRIB_GENERIC(bindingIndex));
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 4951891cb..8e0c3ef5b 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -23,6 +23,7 @@
*/
+#include <stdio.h>
#include "imports.h"
#include "mtypes.h"
#include "version.h"
diff --git a/mesalib/src/mesa/main/vtxfmt.h b/mesalib/src/mesa/main/vtxfmt.h
index 34ade8905..4f8bc9cdf 100644
--- a/mesalib/src/mesa/main/vtxfmt.h
+++ b/mesalib/src/mesa/main/vtxfmt.h
@@ -33,11 +33,18 @@
#ifndef _VTXFMT_H_
#define _VTXFMT_H_
-#include "compiler.h"
#include "mtypes.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern void _mesa_install_exec_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt );
extern void _mesa_install_save_vtxfmt( struct gl_context *ctx, const GLvertexformat *vfmt );
extern void _mesa_initialize_vbo_vtxfmt(struct gl_context *ctx);
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
#endif /* _VTXFMT_H_ */