diff options
author | marha <marha@users.sourceforge.net> | 2015-03-05 22:17:40 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-03-05 22:17:40 +0100 |
commit | 8574eba804031f6b19713f0b02952280730bf62e (patch) | |
tree | 9afa4d6fe299d43ab7e580dc08a5547120274561 /mesalib/src/mesa | |
parent | eef70231353a6103f47fcae88a6e89e765e5cd47 (diff) | |
download | vcxsrv-8574eba804031f6b19713f0b02952280730bf62e.tar.gz vcxsrv-8574eba804031f6b19713f0b02952280730bf62e.tar.bz2 vcxsrv-8574eba804031f6b19713f0b02952280730bf62e.zip |
fontconfig mesa git update 5 Mar 2015
Diffstat (limited to 'mesalib/src/mesa')
229 files changed, 1721 insertions, 3751 deletions
diff --git a/mesalib/src/mesa/Android.gen.mk b/mesalib/src/mesa/Android.gen.mk index c7b7f7edf..caae2c107 100644 --- a/mesalib/src/mesa/Android.gen.mk +++ b/mesalib/src/mesa/Android.gen.mk @@ -122,5 +122,5 @@ format_info_deps := \ $(LOCAL_PATH)/main/format_parser.py \ $(FORMAT_INFO) -$(intermediates)/main/format_info.c: $(format_info_deps) +$(intermediates)/main/format_info.h: $(format_info_deps) @$(MESA_PYTHON2) $(FORMAT_INFO) $< > $@ diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am index b6cb8f111..3dab8f03f 100644 --- a/mesalib/src/mesa/Makefile.am +++ b/mesalib/src/mesa/Makefile.am @@ -62,7 +62,6 @@ include Makefile.sources EXTRA_DIST = \ drivers/haiku \ drivers/SConscript \ - drivers/windows \ main/format_info.py \ main/format_pack.py \ main/format_parser.py \ @@ -80,7 +79,7 @@ EXTRA_DIST = \ BUILT_SOURCES = \ main/get_hash.h \ - main/format_info.c \ + main/format_info.h \ main/git_sha1.h \ main/format_pack.c \ main/format_unpack.c \ @@ -94,13 +93,13 @@ CLEANFILES = \ GET_HASH_GEN = main/get_hash_generator.py main/get_hash.h: ../mapi/glapi/gen/gl_and_es_API.xml main/get_hash_params.py \ - $(GET_HASH_GEN) Makefile + $(GET_HASH_GEN) $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/$(GET_HASH_GEN) \ -f $< > $@.tmp; \ mv $@.tmp $@; -main/format_info.c: main/formats.csv \ +main/format_info.h: main/formats.csv \ main/format_parser.py main/format_info.py $(AM_V_GEN)set -e; \ $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/format_info.py \ @@ -123,7 +122,7 @@ main/format_unpack.c: main/format_unpack.py main/formats.csv \ $(srcdir)/main/formats.csv \ | $(INDENT) $(INDENT_FLAGS) > $@; -main/formats.c: main/format_info.c +main/formats.c: main/format_info.h noinst_LTLIBRARIES = $(ARCH_LIBS) if NEED_LIBMESA @@ -136,8 +135,14 @@ noinst_LTLIBRARIES += libmesagallium.la endif AM_CPPFLAGS = $(DEFINES) $(INCLUDE_DIRS) -AM_CFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CFLAGS) -AM_CXXFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CXXFLAGS) +AM_CFLAGS = \ + $(LLVM_CFLAGS) \ + $(VISIBILITY_CFLAGS) \ + $(MSVC2013_COMPAT_CFLAGS) +AM_CXXFLAGS = \ + $(LLVM_CFLAGS) \ + $(VISIBILITY_CXXFLAGS) \ + $(MSVC2013_COMPAT_CXXFLAGS) ARCH_LIBS = diff --git a/mesalib/src/mesa/Makefile.sources b/mesalib/src/mesa/Makefile.sources index 5b4e71253..217be9ab3 100644 --- a/mesalib/src/mesa/Makefile.sources +++ b/mesalib/src/mesa/Makefile.sources @@ -86,6 +86,7 @@ MAIN_FILES = \ main/ffvertex_prog.h \ main/fog.c \ main/fog.h \ + main/format_info.h \ main/format_pack.h \ main/format_pack.c \ main/format_unpack.h \ @@ -100,6 +101,7 @@ MAIN_FILES = \ main/framebuffer.h \ main/get.c \ main/get.h \ + main/get_hash.h \ main/genmipmap.c \ main/genmipmap.h \ main/getstring.c \ diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index 62e81ced1..81939f981 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -10,6 +10,8 @@ from sys import executable as python_cmd env = env.Clone() +env.MSVC2013Compat() + env.Append(CPPPATH = [ '#/src', '#/src/mapi', @@ -62,7 +64,7 @@ get_hash_header = env.CodeGenerate( ) format_info = env.CodeGenerate( - target = 'main/format_info.c', + target = 'main/format_info.h', script = 'main/format_info.py', source = 'main/formats.csv', command = python_cmd + ' $SCRIPT ' + ' $SOURCE > $TARGET' diff --git a/mesalib/src/mesa/drivers/SConscript b/mesalib/src/mesa/drivers/SConscript index 9888e3306..17813da96 100644 --- a/mesalib/src/mesa/drivers/SConscript +++ b/mesalib/src/mesa/drivers/SConscript @@ -11,8 +11,5 @@ if env['dri']: 'dri/common/SConscript', ]) -if env['platform'] == 'windows': - SConscript('windows/gdi/SConscript') - if env['platform'] == 'haiku': SConscript('haiku/swrast/SConscript') diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.h b/mesalib/src/mesa/drivers/common/driverfuncs.h index 6b9a90074..385ccb8dd 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.h +++ b/mesalib/src/mesa/drivers/common/driverfuncs.h @@ -26,6 +26,10 @@ #ifndef DRIVERFUNCS_H #define DRIVERFUNCS_H +#ifdef __cplusplus +extern "C" { +#endif + extern void _mesa_init_driver_functions(struct dd_function_table *driver); @@ -33,5 +37,8 @@ _mesa_init_driver_functions(struct dd_function_table *driver); extern void _mesa_init_driver_state(struct gl_context *ctx); +#ifdef __cplusplus +} // extern "C" +#endif #endif diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 3636ee83b..fdc4cf1e9 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -393,7 +393,7 @@ _mesa_meta_setup_vertex_objects(GLuint *VAO, GLuint *VBO, void _mesa_meta_init(struct gl_context *ctx) { - ASSERT(!ctx->Meta); + assert(!ctx->Meta); ctx->Meta = CALLOC_STRUCT(gl_meta_state); } @@ -823,6 +823,8 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) void _mesa_meta_end(struct gl_context *ctx) { + assert(ctx->Meta->SaveStackDepth > 0); + struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1]; const GLbitfield state = save->SavedState; int i; @@ -1045,7 +1047,7 @@ _mesa_meta_end(struct gl_context *ctx) if (state & MESA_META_TEXTURE) { GLuint u, tgt; - ASSERT(ctx->Texture.CurrentUnit == 0); + assert(ctx->Texture.CurrentUnit == 0); /* restore texenv for unit[0] */ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); @@ -1332,8 +1334,8 @@ _mesa_meta_alloc_texture(struct temp_texture *tex, { GLboolean newTex = GL_FALSE; - ASSERT(width <= tex->MaxSize); - ASSERT(height <= tex->MaxSize); + assert(width <= tex->MaxSize); + assert(height <= tex->MaxSize); if (width > tex->Width || height > tex->Height || @@ -1747,7 +1749,7 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl) _mesa_ClampColor(GL_CLAMP_FRAGMENT_COLOR, GL_FALSE); } else { - ASSERT(metaSave & MESA_META_COLOR_MASK); + assert(metaSave & MESA_META_COLOR_MASK); _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); } diff --git a/mesalib/src/mesa/drivers/common/meta_blit.c b/mesalib/src/mesa/drivers/common/meta_blit.c index 3406be1ed..bb2164276 100644 --- a/mesalib/src/mesa/drivers/common/meta_blit.c +++ b/mesalib/src/mesa/drivers/common/meta_blit.c @@ -82,7 +82,7 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, y_scale = samples * 0.5; /* We expect only power of 2 samples in source multisample buffer. */ - assert((samples & (samples - 1)) == 0); + assert(samples > 0 && (samples & (samples - 1)) == 0); while (samples >> (shader_offset + 1)) { shader_offset++; } @@ -133,6 +133,8 @@ setup_glsl_msaa_blit_scaled_shader(struct gl_context *ctx, sample_map = ctx->Const.SampleMap8x; break; default: + sample_number = NULL; + sample_map = NULL; _mesa_problem(ctx, "Unsupported sample count %d\n", samples); unreachable("Unsupported sample count"); } @@ -261,7 +263,7 @@ setup_glsl_msaa_blit_shader(struct gl_context *ctx, } /* We expect only power of 2 samples in source multisample buffer. */ - assert((samples & (samples - 1)) == 0); + assert(samples > 0 && (samples & (samples - 1)) == 0); while (samples >> (shader_offset + 1)) { shader_offset++; } diff --git a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c index 68c8273fe..e29addb73 100644 --- a/mesalib/src/mesa/drivers/common/meta_tex_subimage.c +++ b/mesalib/src/mesa/drivers/common/meta_tex_subimage.c @@ -44,7 +44,7 @@ static struct gl_texture_image * create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, - GLenum pbo_target, int width, int height, int depth, + GLenum pbo_target, int width, int height, GLenum format, GLenum type, const void *pixels, const struct gl_pixelstore_attrib *packing, GLuint *tmp_pbo, GLuint *tmp_tex) @@ -57,8 +57,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, struct gl_texture_image *tex_image; bool read_only; - if ((packing->ImageHeight != 0 && packing->ImageHeight != height) || - packing->SwapBytes || + if (packing->SwapBytes || packing->LsbFirst || packing->Invert) return NULL; @@ -79,6 +78,8 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, *tmp_pbo = 0; buffer_obj = packing->BufferObj; } else { + bool is_pixel_pack = pbo_target == GL_PIXEL_PACK_BUFFER; + assert(create_pbo); _mesa_GenBuffers(1, tmp_pbo); @@ -89,9 +90,17 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, */ _mesa_BindBuffer(pbo_target, *tmp_pbo); - _mesa_BufferData(pbo_target, row_stride * height, pixels, GL_STREAM_DRAW); + /* In case of GL_PIXEL_PACK_BUFFER, pass null pointer for the pixel + * data to avoid unnecessary data copying in _mesa_BufferData(). + */ + if (is_pixel_pack) + _mesa_BufferData(pbo_target, row_stride * height, NULL, + GL_STREAM_READ); + else + _mesa_BufferData(pbo_target, row_stride * height, pixels, + GL_STREAM_DRAW); - buffer_obj = ctx->Unpack.BufferObj; + buffer_obj = packing->BufferObj; pixels = NULL; _mesa_BindBuffer(pbo_target, 0); @@ -99,14 +108,16 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo, _mesa_GenTextures(1, tmp_tex); tex_obj = _mesa_lookup_texture(ctx, *tmp_tex); - tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D; - tex_obj->Immutable = GL_TRUE; _mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex, GL_TEXTURE_2D); + /* This must be set after _mesa_initialize_texture_object, not before. */ + tex_obj->Immutable = GL_TRUE; + /* This is required for interactions with ARB_texture_view. */ + tex_obj->NumLayers = 1; internal_format = _mesa_get_format_base_format(pbo_format); tex_image = _mesa_get_tex_image(ctx, tex_obj, tex_obj->Target, 0); - _mesa_init_teximage_fields(ctx, tex_image, width, height, depth, + _mesa_init_teximage_fields(ctx, tex_image, width, height, 1, 0, internal_format, pbo_format); read_only = pbo_target == GL_PIXEL_UNPACK_BUFFER; @@ -133,6 +144,7 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -166,9 +178,16 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, return true; } + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; + pbo_tex_image = create_texture_for_pbo(ctx, create_pbo, GL_PIXEL_UNPACK_BUFFER, - width, height, depth, + width, full_height, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) @@ -177,8 +196,8 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (allocate_storage) ctx->Driver.AllocTextureImageBuffer(ctx, tex_image); - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); _mesa_BindFramebuffer(GL_READ_FRAMEBUFFER, fbos[0]); @@ -186,8 +205,12 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, if (tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, @@ -214,15 +237,14 @@ _mesa_meta_pbo_TexSubImage(struct gl_context *ctx, GLuint dims, goto fail; for (z = 1; z < depth; z++) { - _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - pbo_tex_image, z); _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); _mesa_update_state(ctx); _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, - 0, 0, width, height, + 0, z * image_height, + width, z * image_height + height, xoffset, yoffset, xoffset + width, yoffset + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); @@ -249,6 +271,7 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, const struct gl_pixelstore_attrib *packing) { GLuint pbo = 0, pbo_tex = 0, fbos[2] = { 0, 0 }; + int full_height, image_height; struct gl_texture_image *pbo_tex_image; GLenum status; bool success = false; @@ -282,22 +305,33 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, return true; } + /* For arrays, use a tall (height * depth) 2D texture but taking into + * account the inter-image padding specified with the image height packing + * property. + */ + image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight; + full_height = image_height * (depth - 1) + height; + pbo_tex_image = create_texture_for_pbo(ctx, false, GL_PIXEL_PACK_BUFFER, - width, height, depth, + width, full_height * depth, format, type, pixels, packing, &pbo, &pbo_tex); if (!pbo_tex_image) return false; - /* Only stash the current FBO */ - _mesa_meta_begin(ctx, 0); + _mesa_meta_begin(ctx, ~(MESA_META_PIXEL_TRANSFER | + MESA_META_PIXEL_STORE)); _mesa_GenFramebuffers(2, fbos); if (tex_image && tex_image->TexObject->Target == GL_TEXTURE_1D_ARRAY) { assert(depth == 1); + assert(zoffset == 0); depth = height; height = 1; + image_height = 1; + zoffset = yoffset; + yoffset = 0; } /* If we were given a texture, bind it to the read framebuffer. If not, @@ -336,15 +370,14 @@ _mesa_meta_pbo_GetTexSubImage(struct gl_context *ctx, GLuint dims, for (z = 1; z < depth; z++) { _mesa_meta_bind_fbo_image(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex_image, zoffset + z); - _mesa_meta_bind_fbo_image(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - pbo_tex_image, z); _mesa_update_state(ctx); _mesa_meta_BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer, xoffset, yoffset, xoffset + width, yoffset + height, - 0, 0, width, height, + 0, z * image_height, + width, z * image_height + height, GL_COLOR_BUFFER_BIT, GL_NEAREST); } diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c index f2e63c0b9..bb22107e9 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.c +++ b/mesalib/src/mesa/drivers/dri/common/utils.c @@ -30,6 +30,7 @@ */ #include <string.h> +#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <stdint.h> @@ -485,6 +486,7 @@ driIndexConfigAttrib(const __DRIconfig *config, int index, * Currently only the following queries are supported by this function: * * - \c __DRI2_RENDERER_VERSION + * - \c __DRI2_RENDERER_PREFERRED_PROFILE * - \c __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION * - \c __DRI2_RENDERER_OPENGL_COMPATIBLITY_PROFILE_VERSION * - \c __DRI2_RENDERER_ES_PROFILE_VERSION diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c index d69eb0196..2b284ccf2 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c +++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c @@ -27,10 +27,13 @@ * \author Felix Kuehling */ +#include <stdarg.h> +#include <stdio.h> #include <string.h> #include <assert.h> #include <expat.h> #include <fcntl.h> +#include <math.h> #include <unistd.h> #include <errno.h> #include "main/imports.h" diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am index da7d03480..555771685 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/Makefile.am @@ -52,7 +52,7 @@ POT=xmlpool.pot .PHONY: all clean pot po mo -EXTRA_DIST = gen_xmlpool.py t_options.h $(POS) SConscript +EXTRA_DIST = gen_xmlpool.py options.h t_options.h $(POS) SConscript BUILT_SOURCES = options.h CLEANFILES = $(MOS) options.h diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po index 23e9f4211..03bf29613 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/ca.po @@ -25,15 +25,15 @@ msgid "" msgstr "" "Project-Id-Version: Mesa 10.1.0-devel\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-09-25 22:29-0600\n" -"PO-Revision-Date: 2014-09-26 14:43-0700\n" +"POT-Creation-Date: 2015-02-07 02:08-0700\n" +"PO-Revision-Date: 2015-02-23 14:28-0700\n" "Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n" "Language-Team: Catalan <ca@li.org>\n" "Language: ca\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.6.9\n" +"X-Generator: Poedit 1.7.4\n" #: t_options.h:56 msgid "Debugging" @@ -83,8 +83,8 @@ msgstr "Deshabilita el GL_ARB_shader_bit_encoding" msgid "" "Force a default GLSL version for shaders that lack an explicit #version line" msgstr "" -"Força una versió GLSL per defecte en els shaders als quals falta una lÃnia " -"#version explÃcita" +"Força una versió GLSL per defecte en els shaders als quals lis manca una " +"lÃnia #version explÃcita" #: t_options.h:110 msgid "Allow GLSL #extension directives in the middle of shaders" @@ -92,7 +92,7 @@ msgstr "Permet les directives #extension GLSL en el mitjà dels shaders" #: t_options.h:120 msgid "Image Quality" -msgstr "Qualitat d'Imatge" +msgstr "Qualitat d'imatge" #: t_options.h:133 msgid "Texture color depth" @@ -149,11 +149,11 @@ msgstr "Mètode d'arrodoniment de color" #: t_options.h:171 msgid "Round color components downward" -msgstr "Arrondeix els components de color a baix" +msgstr "Arrodoneix els components de color a baix" #: t_options.h:172 msgid "Round to nearest color" -msgstr "Arrondeix al color més proper" +msgstr "Arrodoneix al color més proper" #: t_options.h:181 msgid "Color dithering method" @@ -181,15 +181,15 @@ msgstr "Un filtre de postprocessament per a aplicar cel shading a la sortida" #: t_options.h:200 msgid "A post-processing filter to remove the red channel" -msgstr "Un filtre de postprocessament per a treure el canal vermell" +msgstr "Un filtre de postprocessament per a eliminar el canal vermell" #: t_options.h:205 msgid "A post-processing filter to remove the green channel" -msgstr "Un filtre de postprocessament per a treure el canal verd" +msgstr "Un filtre de postprocessament per a eliminar el canal verd" #: t_options.h:210 msgid "A post-processing filter to remove the blue channel" -msgstr "Un filtre de postprocessament per a treure el canal blau" +msgstr "Un filtre de postprocessament per a eliminar el canal blau" #: t_options.h:215 msgid "" @@ -222,17 +222,17 @@ msgstr "Utilitza la canonada TCL de programari" #: t_options.h:240 msgid "Use hardware TCL as first TCL pipeline stage" -msgstr "Utilitza el TCL maquinà ri com la primera fase de la canonada TCL" +msgstr "Utilitza el TCL de maquinari com a la primera fase de la canonada TCL" #: t_options.h:241 msgid "Bypass the TCL pipeline" -msgstr "Passar per alt la canonada TCL" +msgstr "Passa per alt la canonada TCL" #: t_options.h:242 msgid "" "Bypass the TCL pipeline with state-based machine code generated on-the-fly" msgstr "" -"Passar per alt la canonada TCL amb codi mà quina basat en estats, generat " +"Passa per alt la canonada TCL amb codi de mà quina basat en estats, generat " "sobre la marxa" #: t_options.h:251 @@ -245,7 +245,7 @@ msgstr "Espera activa pel maquinari de grà fics" #: t_options.h:253 msgid "Sleep for brief intervals while waiting for the graphics hardware" -msgstr "Dormi per intervals breus mentre s'espera al maquinari de grà fics" +msgstr "Dorm per intervals breus mentre s'espera al maquinari de grà fics" #: t_options.h:254 msgid "Let the graphics hardware emit a software interrupt and sleep" @@ -259,7 +259,7 @@ msgstr "Sincronització amb refresc vertical (intervals d'intercanvi)" #: t_options.h:265 msgid "Never synchronize with vertical refresh, ignore application's choice" msgstr "" -"Mai sincronitzis amb el refresc vertial, ignora l'elecció de l'aplicació" +"Mai sincronitzis amb el refresc vertical, ignora l'elecció de l'aplicació" #: t_options.h:266 msgid "Initial swap interval 0, obey application's choice" @@ -301,7 +301,7 @@ msgstr "Tota la memòria disponible" #: t_options.h:296 msgid "Only card memory (if available)" -msgstr "Només memòria de tarjeta (si està disponible)" +msgstr "Només memòria de targeta (si està disponible)" #: t_options.h:297 msgid "Only GART (AGP/PCIE) memory (if available)" @@ -329,4 +329,20 @@ msgstr "Inicialització" #: t_options.h:341 msgid "Define the graphic device to use if possible" -msgstr "Defineix el dispositiu de grà fics que usar si és possible" +msgstr "Defineix el dispositiu de grà fics que utilitzar si és possible" + +#: t_options.h:350 +msgid "Gallium Nine" +msgstr "Gallium Nine" + +#: t_options.h:354 +msgid "" +"Define the throttling value. -1 for no throttling, -2 for default (usually " +"2), 0 for glfinish behaviour" +msgstr "" +"Defineix el valor de regulació. -1 per a no regular, -2 per al predeterminat " +"(generalment 2), 0 per al comportament de glfinish" + +#: t_options.h:359 +msgid "Use an additional thread to submit buffers." +msgstr "Utilitza un fil addicional per a entregar els buffers." diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po index a68c329a5..f9d950ac1 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool/es.po @@ -9,8 +9,8 @@ msgid "" msgstr "" "Project-Id-Version: es\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-09-25 22:29-0600\n" -"PO-Revision-Date: 2014-09-26 14:22-0700\n" +"POT-Creation-Date: 2015-02-07 02:08-0700\n" +"PO-Revision-Date: 2015-02-23 14:54-0700\n" "Last-Translator: Alex Henrie <alexhenrie24@gmail.com>\n" "Language-Team: Spanish <es@li.org>\n" "Language: es\n" @@ -18,7 +18,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Generator: Poedit 1.6.9\n" +"X-Generator: Poedit 1.7.4\n" #: t_options.h:56 msgid "Debugging" @@ -301,11 +301,11 @@ msgstr "Habilitar la extensión GL_ARB_vertex_program" #: t_options.h:323 msgid "Miscellaneous" -msgstr "Misceláneo" +msgstr "Misceláneos" #: t_options.h:327 msgid "Create all visuals with a depth buffer" -msgstr "Crear todos los visuales con buffer de profundidad" +msgstr "Crear todos los visuales con búfer de profundidad" #: t_options.h:337 msgid "Initialization" @@ -314,3 +314,19 @@ msgstr "Inicialización" #: t_options.h:341 msgid "Define the graphic device to use if possible" msgstr "Define el dispositivo de gráficos que usar si es posible" + +#: t_options.h:350 +msgid "Gallium Nine" +msgstr "Gallium Nine" + +#: t_options.h:354 +msgid "" +"Define the throttling value. -1 for no throttling, -2 for default (usually " +"2), 0 for glfinish behaviour" +msgstr "" +"Define el valor de regulación. -1 para no regular, -2 para el por defecto " +"(generalmente 2), 0 para el comportamiento de glfinish" + +#: t_options.h:359 +msgid "Use an additional thread to submit buffers." +msgstr "Usar un hilo adicional para entregar los búfer." diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index 8005f7d69..fb29078b6 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -32,6 +32,7 @@ * The back-buffer is allocated by the driver and is private. */ +#include <stdio.h> #include "main/api_exec.h" #include "main/context.h" #include "main/extensions.h" @@ -341,7 +342,7 @@ swrast_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) } /* see bytes_per_line in libGL */ -static INLINE int +static inline int bytes_per_line(unsigned pitch_bits, unsigned mul) { unsigned mask = mul - 1; @@ -481,7 +482,7 @@ swrast_map_renderbuffer(struct gl_context *ctx, return; } - ASSERT(xrb->Base.Buffer); + assert(xrb->Base.Buffer); if (rb->AllocStorage == swrast_alloc_back_storage) { map += (rb->Height - 1) * stride; diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h index 535f6fe59..1f3a48f38 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -65,13 +65,13 @@ struct dri_context __DRIcontext *cPriv; }; -static INLINE struct dri_context * +static inline struct dri_context * dri_context(__DRIcontext * driContextPriv) { return (struct dri_context *)driContextPriv->driverPrivate; } -static INLINE struct dri_context * +static inline struct dri_context * swrast_context(struct gl_context *ctx) { return (struct dri_context *) ctx; @@ -89,13 +89,13 @@ struct dri_drawable char *row; }; -static INLINE struct dri_drawable * +static inline struct dri_drawable * dri_drawable(__DRIdrawable * driDrawPriv) { return (struct dri_drawable *)driDrawPriv->driverPrivate; } -static INLINE struct dri_drawable * +static inline struct dri_drawable * swrast_drawable(struct gl_framebuffer *fb) { return (struct dri_drawable *) fb; @@ -115,7 +115,7 @@ struct dri_swrast_renderbuffer { GLuint bpp; }; -static INLINE struct dri_swrast_renderbuffer * +static inline struct dri_swrast_renderbuffer * dri_swrast_renderbuffer(struct gl_renderbuffer *rb) { return (struct dri_swrast_renderbuffer *) rb; diff --git a/mesalib/src/mesa/drivers/windows/gdi/SConscript b/mesalib/src/mesa/drivers/windows/gdi/SConscript deleted file mode 100644 index 1f4d7e1fa..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/SConscript +++ /dev/null @@ -1,40 +0,0 @@ -Import('*') - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '#src', - '#src/mapi', - '#src/mesa', -]) - -env.AppendUnique(CPPDEFINES = [ - '_GDI32_', # prevent wgl* being declared __declspec(dllimport) - 'BUILD_GL32', # declare gl* as __declspec(dllexport) in Mesa headers -]) -if not env['gles']: - # prevent _glapi_* from being declared __declspec(dllimport) - env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) - -env.Prepend(LIBS = [ - mesautil, - glapi, - mesa, - glsl, - 'gdi32', - 'user32', - 'kernel32', -]) - -sources = [ - 'mesa.def', - 'wgl.c', - 'wmesa.c', -] - -mesagdi = env.SharedLibrary( - target = 'opengl32', - source = sources, -) - -env.Alias('mesagdi', mesagdi) diff --git a/mesalib/src/mesa/drivers/windows/gdi/colors.h b/mesalib/src/mesa/drivers/windows/gdi/colors.h deleted file mode 100644 index 03e512c1f..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/colors.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Values for wmesa->pixelformat: */ - -#define PF_8A8B8G8R 3 /* 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */ -#define PF_8R8G8B 4 /* 32-bit TrueColor: 8-R, 8-G, 8-B */ -#define PF_5R6G5B 5 /* 16-bit TrueColor: 5-R, 6-G, 5-B bits */ -#define PF_DITHER8 6 /* Dithered RGB using a lookup table */ -#define PF_LOOKUP 7 /* Undithered RGB using a lookup table */ -#define PF_GRAYSCALE 10 /* Grayscale or StaticGray */ -#define PF_BADFORMAT 11 -#define PF_INDEX8 12 - - -#define BGR8(r,g,b) (unsigned)(((BYTE)((b & 0xc0) | ((g & 0xe0)>>2) | \ - ((r & 0xe0)>>5)))) - -/* Windows uses 5,5,5 for 16-bit */ -#define BGR16(r,g,b) ( (((unsigned short)b ) >> 3) | \ - (((unsigned short)g & 0xf8) << 2) | \ - (((unsigned short)r & 0xf8) << 7) ) - -#define BGR24(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \ - ((WORD)((BYTE)(g))<<8))| \ - (((DWORD)(BYTE)(r))<<16))) - -#define BGR32(r,g,b) (unsigned long)((DWORD)(((BYTE)(b)| \ - ((WORD)((BYTE)(g))<<8))| \ - (((DWORD)(BYTE)(r))<<16))) - - diff --git a/mesalib/src/mesa/drivers/windows/gdi/mesa.def b/mesalib/src/mesa/drivers/windows/gdi/mesa.def deleted file mode 100644 index a52207b63..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/mesa.def +++ /dev/null @@ -1,385 +0,0 @@ -; -; Module definition file for Mesa (OPENGL32.DLL) -; -; Note: The OpenGL functions use the STDCALL -; function calling convention. Microsoft's -; OPENGL32 uses this convention and so must the -; Mesa OPENGL32 so that the Mesa DLL can be used -; as a drop-in replacement. -; -; The linker exports STDCALL entry points with -; 'decorated' names; e.g., _glBegin@0, where the -; trailing number is the number of bytes of -; parameter data pushed onto the stack. The -; callee is responsible for popping this data -; off the stack, usually via a RETF n instruction. -; -; However, the Microsoft OPENGL32.DLL does not export -; the decorated names, even though the calling convention -; is STDCALL. So, this module definition file is -; needed to force the Mesa OPENGL32.DLL to export the -; symbols in the same manner as the Microsoft DLL. -; Were it not for this problem, this file would not -; be needed (for the gl* functions) since the entry -; points are compiled with dllexport declspec. -; -EXPORTS - glAccum - glAlphaFunc - glAreTexturesResident - glArrayElement - glBegin - glBindTexture - glBitmap - glBlendFunc - glCallList - glCallLists - glClear - glClearAccum - glClearColor - glClearDepth - glClearIndex - glClearStencil - glClipPlane - glColor3b - glColor3bv - glColor3d - glColor3dv - glColor3f - glColor3fv - glColor3i - glColor3iv - glColor3s - glColor3sv - glColor3ub - glColor3ubv - glColor3ui - glColor3uiv - glColor3us - glColor3usv - glColor4b - glColor4bv - glColor4d - glColor4dv - glColor4f - glColor4fv - glColor4i - glColor4iv - glColor4s - glColor4sv - glColor4ub - glColor4ubv - glColor4ui - glColor4uiv - glColor4us - glColor4usv - glColorMask - glColorMaterial - glColorPointer - glCopyPixels - glCopyTexImage1D - glCopyTexImage2D - glCopyTexSubImage1D - glCopyTexSubImage2D - glCullFace - glDeleteLists - glDeleteTextures - glDepthFunc - glDepthMask - glDepthRange - glDisable - glDisableClientState - glDrawArrays - glDrawBuffer - glDrawElements - glDrawPixels - glEdgeFlag - glEdgeFlagPointer - glEdgeFlagv - glEnable - glEnableClientState - glEnd - glEndList - glEvalCoord1d - glEvalCoord1dv - glEvalCoord1f - glEvalCoord1fv - glEvalCoord2d - glEvalCoord2dv - glEvalCoord2f - glEvalCoord2fv - glEvalMesh1 - glEvalMesh2 - glEvalPoint1 - glEvalPoint2 - glFeedbackBuffer - glFinish - glFlush - glFogf - glFogfv - glFogi - glFogiv - glFrontFace - glFrustum - glGenLists - glGenTextures - glGetBooleanv - glGetClipPlane - glGetDoublev - glGetError - glGetFloatv - glGetIntegerv - glGetLightfv - glGetLightiv - glGetMapdv - glGetMapfv - glGetMapiv - glGetMaterialfv - glGetMaterialiv - glGetPixelMapfv - glGetPixelMapuiv - glGetPixelMapusv - glGetPointerv - glGetPolygonStipple - glGetString - glGetTexEnvfv - glGetTexEnviv - glGetTexGendv - glGetTexGenfv - glGetTexGeniv - glGetTexImage - glGetTexLevelParameterfv - glGetTexLevelParameteriv - glGetTexParameterfv - glGetTexParameteriv - glHint - glIndexMask - glIndexPointer - glIndexd - glIndexdv - glIndexf - glIndexfv - glIndexi - glIndexiv - glIndexs - glIndexsv - glIndexub - glIndexubv - glInitNames - glInterleavedArrays - glIsEnabled - glIsList - glIsTexture - glLightModelf - glLightModelfv - glLightModeli - glLightModeliv - glLightf - glLightfv - glLighti - glLightiv - glLineStipple - glLineWidth - glListBase - glLoadIdentity - glLoadMatrixd - glLoadMatrixf - glLoadName - glLogicOp - glMap1d - glMap1f - glMap2d - glMap2f - glMapGrid1d - glMapGrid1f - glMapGrid2d - glMapGrid2f - glMaterialf - glMaterialfv - glMateriali - glMaterialiv - glMatrixMode - glMultMatrixd - glMultMatrixf - glNewList - glNormal3b - glNormal3bv - glNormal3d - glNormal3dv - glNormal3f - glNormal3fv - glNormal3i - glNormal3iv - glNormal3s - glNormal3sv - glNormalPointer - glOrtho - glPassThrough - glPixelMapfv - glPixelMapuiv - glPixelMapusv - glPixelStoref - glPixelStorei - glPixelTransferf - glPixelTransferi - glPixelZoom - glPointSize - glPolygonMode - glPolygonOffset - glPolygonStipple - glPopAttrib - glPopClientAttrib - glPopMatrix - glPopName - glPrioritizeTextures - glPushAttrib - glPushClientAttrib - glPushMatrix - glPushName - glRasterPos2d - glRasterPos2dv - glRasterPos2f - glRasterPos2fv - glRasterPos2i - glRasterPos2iv - glRasterPos2s - glRasterPos2sv - glRasterPos3d - glRasterPos3dv - glRasterPos3f - glRasterPos3fv - glRasterPos3i - glRasterPos3iv - glRasterPos3s - glRasterPos3sv - glRasterPos4d - glRasterPos4dv - glRasterPos4f - glRasterPos4fv - glRasterPos4i - glRasterPos4iv - glRasterPos4s - glRasterPos4sv - glReadBuffer - glReadPixels - glRectd - glRectdv - glRectf - glRectfv - glRecti - glRectiv - glRects - glRectsv - glRenderMode - glRotated - glRotatef - glScaled - glScalef - glScissor - glSelectBuffer - glShadeModel - glStencilFunc - glStencilMask - glStencilOp - glTexCoord1d - glTexCoord1dv - glTexCoord1f - glTexCoord1fv - glTexCoord1i - glTexCoord1iv - glTexCoord1s - glTexCoord1sv - glTexCoord2d - glTexCoord2dv - glTexCoord2f - glTexCoord2fv - glTexCoord2i - glTexCoord2iv - glTexCoord2s - glTexCoord2sv - glTexCoord3d - glTexCoord3dv - glTexCoord3f - glTexCoord3fv - glTexCoord3i - glTexCoord3iv - glTexCoord3s - glTexCoord3sv - glTexCoord4d - glTexCoord4dv - glTexCoord4f - glTexCoord4fv - glTexCoord4i - glTexCoord4iv - glTexCoord4s - glTexCoord4sv - glTexCoordPointer - glTexEnvf - glTexEnvfv - glTexEnvi - glTexEnviv - glTexGend - glTexGendv - glTexGenf - glTexGenfv - glTexGeni - glTexGeniv - glTexImage1D - glTexImage2D - glTexParameterf - glTexParameterfv - glTexParameteri - glTexParameteriv - glTexSubImage1D - glTexSubImage2D - glTranslated - glTranslatef - glVertex2d - glVertex2dv - glVertex2f - glVertex2fv - glVertex2i - glVertex2iv - glVertex2s - glVertex2sv - glVertex3d - glVertex3dv - glVertex3f - glVertex3fv - glVertex3i - glVertex3iv - glVertex3s - glVertex3sv - glVertex4d - glVertex4dv - glVertex4f - glVertex4fv - glVertex4i - glVertex4iv - glVertex4s - glVertex4sv - glVertexPointer - glViewport - wglChoosePixelFormat - wglCopyContext - wglCreateContext - wglCreateLayerContext - wglDeleteContext - wglDescribeLayerPlane - wglDescribePixelFormat - wglGetCurrentContext - wglGetCurrentDC - wglGetLayerPaletteEntries - wglGetPixelFormat - wglGetProcAddress - wglMakeCurrent - wglRealizeLayerPalette - wglSetLayerPaletteEntries - wglSetPixelFormat - wglShareLists - wglSwapBuffers - wglSwapLayerBuffers - wglUseFontBitmapsA - wglUseFontBitmapsW - wglUseFontOutlinesA - wglUseFontOutlinesW diff --git a/mesalib/src/mesa/drivers/windows/gdi/wgl.c b/mesalib/src/mesa/drivers/windows/gdi/wgl.c deleted file mode 100644 index 3458cc9f3..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wgl.c +++ /dev/null @@ -1,689 +0,0 @@ - -/* - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* - * File name : wgl.c - * WGL stuff. Added by Oleg Letsinsky, ajl@ultersys.ru - * Some things originated from the 3Dfx WGL functions - */ - -/* - * This file contains the implementation of the wgl* functions for - * Mesa on Windows. Since these functions are provided by Windows in - * GDI/OpenGL, we must supply our versions that work with Mesa here. - */ - - -#include <windows.h> - -#include "main/config.h" -#include "glapi/glapi.h" -#include "swrast/swrast.h" -#include "GL/wmesa.h" /* protos for wmesa* functions */ - -/* - * Pixel Format Descriptors - */ - -/* Extend the PFD to include DB flag */ -struct __pixelformat__ -{ - PIXELFORMATDESCRIPTOR pfd; - GLboolean doubleBuffered; -}; - - - -/* These are the PFD's supported by this driver. */ -struct __pixelformat__ pfd[] = -{ -#if 0 - /* Double Buffer, alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 8, 24, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_TRUE - }, - /* Single Buffer, alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 8, 24, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_FALSE - }, -#endif - /* Double Buffer, no alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT|PFD_DOUBLEBUFFER|PFD_SWAP_COPY, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 0, 0, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_TRUE - }, - /* Single Buffer, no alpha */ - { - { - sizeof(PIXELFORMATDESCRIPTOR), 1, - PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL| - PFD_GENERIC_FORMAT, - PFD_TYPE_RGBA, - 24, - 8, 0, - 8, 8, - 8, 16, - 0, 0, - 0, 0, 0, 0, 0, - DEFAULT_SOFTWARE_DEPTH_BITS, 8, - 0, 0, 0, - 0, 0, 0 - }, - GL_FALSE - }, -}; - -int npfd = sizeof(pfd) / sizeof(pfd[0]); - - -/* - * Contexts - */ - -typedef struct { - WMesaContext ctx; -} MesaWglCtx; - -#define MESAWGL_CTX_MAX_COUNT 20 - -static MesaWglCtx wgl_ctx[MESAWGL_CTX_MAX_COUNT]; - -static unsigned ctx_count = 0; -static int ctx_current = -1; -static unsigned curPFD = 0; - -static HDC CurrentHDC = 0; - - -WINGDIAPI HGLRC GLAPIENTRY wglCreateContext(HDC hdc) -{ - int i = 0; - if (!ctx_count) { - for(i=0;i<MESAWGL_CTX_MAX_COUNT;i++) { - wgl_ctx[i].ctx = NULL; - } - } - for( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == NULL ) { - wgl_ctx[i].ctx = - WMesaCreateContext(hdc, NULL, (GLboolean)GL_TRUE, - (GLboolean) (pfd[curPFD-1].doubleBuffered ? - GL_TRUE : GL_FALSE), - (GLboolean)(pfd[curPFD-1].pfd.cAlphaBits ? - GL_TRUE : GL_FALSE) ); - if (wgl_ctx[i].ctx == NULL) - break; - ctx_count++; - return ((HGLRC)wgl_ctx[i].ctx); - } - } - SetLastError(0); - return(NULL); -} - -WINGDIAPI BOOL GLAPIENTRY wglDeleteContext(HGLRC hglrc) -{ - int i; - for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ){ - WMesaMakeCurrent((WMesaContext) hglrc, NULL); - WMesaDestroyContext(wgl_ctx[i].ctx); - wgl_ctx[i].ctx = NULL; - ctx_count--; - return(TRUE); - } - } - SetLastError(0); - return(FALSE); -} - -WINGDIAPI HGLRC GLAPIENTRY wglGetCurrentContext(VOID) -{ - if (ctx_current < 0) - return 0; - else - return (HGLRC) wgl_ctx[ctx_current].ctx; -} - -WINGDIAPI HDC GLAPIENTRY wglGetCurrentDC(VOID) -{ - return CurrentHDC; -} - -WINGDIAPI BOOL GLAPIENTRY wglMakeCurrent(HDC hdc, HGLRC hglrc) -{ - int i; - - CurrentHDC = hdc; - - if (!hdc || !hglrc) { - WMesaMakeCurrent(NULL, NULL); - ctx_current = -1; - return TRUE; - } - - for ( i = 0; i < MESAWGL_CTX_MAX_COUNT; i++ ) { - if ( wgl_ctx[i].ctx == (WMesaContext) hglrc ) { - WMesaMakeCurrent( (WMesaContext) hglrc, hdc ); - ctx_current = i; - return TRUE; - } - } - return FALSE; -} - - -WINGDIAPI int GLAPIENTRY wglChoosePixelFormat(HDC hdc, - CONST - PIXELFORMATDESCRIPTOR *ppfd) -{ - int i,best = -1,bestdelta = 0x7FFFFFFF,delta; - (void) hdc; - - if(ppfd->nSize != sizeof(PIXELFORMATDESCRIPTOR) || ppfd->nVersion != 1) - { - SetLastError(0); - return(0); - } - for(i = 0; i < npfd;i++) - { - delta = 0; - if( - (ppfd->dwFlags & PFD_DRAW_TO_WINDOW) && - !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_WINDOW)) - continue; - if( - (ppfd->dwFlags & PFD_DRAW_TO_BITMAP) && - !(pfd[i].pfd.dwFlags & PFD_DRAW_TO_BITMAP)) - continue; - if( - (ppfd->dwFlags & PFD_SUPPORT_GDI) && - !(pfd[i].pfd.dwFlags & PFD_SUPPORT_GDI)) - continue; - if( - (ppfd->dwFlags & PFD_SUPPORT_OPENGL) && - !(pfd[i].pfd.dwFlags & PFD_SUPPORT_OPENGL)) - continue; - if( - !(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) && - ((ppfd->dwFlags & PFD_DOUBLEBUFFER) != - (pfd[i].pfd.dwFlags & PFD_DOUBLEBUFFER))) - continue; - if( - !(ppfd->dwFlags & PFD_STEREO_DONTCARE) && - ((ppfd->dwFlags & PFD_STEREO) != - (pfd[i].pfd.dwFlags & PFD_STEREO))) - continue; - if(ppfd->iPixelType != pfd[i].pfd.iPixelType) - delta++; - if(ppfd->cAlphaBits != pfd[i].pfd.cAlphaBits) - delta++; - if(delta < bestdelta) - { - best = i + 1; - bestdelta = delta; - if(bestdelta == 0) - break; - } - } - if(best == -1) - { - SetLastError(0); - return(0); - } - return(best); -} - -WINGDIAPI int GLAPIENTRY wglDescribePixelFormat(HDC hdc, - int iPixelFormat, - UINT nBytes, - LPPIXELFORMATDESCRIPTOR ppfd) -{ - (void) hdc; - - if(ppfd == NULL) - return(npfd); - if(iPixelFormat < 1 || iPixelFormat > npfd || - nBytes != sizeof(PIXELFORMATDESCRIPTOR)) - { - SetLastError(0); - return(0); - } - *ppfd = pfd[iPixelFormat - 1].pfd; - return(npfd); -} - -WINGDIAPI PROC GLAPIENTRY wglGetProcAddress(LPCSTR lpszProc) -{ - PROC p = (PROC) _glapi_get_proc_address((const char *) lpszProc); - if (p) - return p; - - SetLastError(0); - return(NULL); -} - -WINGDIAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc) -{ - (void) hdc; - if(curPFD == 0) { - SetLastError(0); - return(0); - } - return(curPFD); -} - -WINGDIAPI BOOL GLAPIENTRY wglSetPixelFormat(HDC hdc,int iPixelFormat, - const PIXELFORMATDESCRIPTOR *ppfd) -{ - (void) hdc; - - /* SetPixelFormat (hence wglSetPixelFormat) must not touch ppfd, per - * http://msdn.microsoft.com/en-us/library/dd369049(v=vs.85).aspx - */ - (void) ppfd; - - if(iPixelFormat < 1 || iPixelFormat > npfd) { - SetLastError(0); - return(FALSE); - } - curPFD = iPixelFormat; - return(TRUE); -} - -WINGDIAPI BOOL GLAPIENTRY wglSwapBuffers(HDC hdc) -{ - WMesaSwapBuffers(hdc); - return TRUE; -} - -static FIXED FixedFromDouble(double d) -{ - long l = (long) (d * 65536L); - return *(FIXED *) (void *) &l; -} - - -/* -** This is cribbed from FX/fxwgl.c, and seems to implement support -** for bitmap fonts where the wglUseFontBitmapsA() code implements -** support for outline fonts. In combination they hopefully give -** fairly generic support for fonts. -*/ -static BOOL wglUseFontBitmaps_FX(HDC fontDevice, DWORD firstChar, - DWORD numChars, DWORD listBase) -{ -#define VERIFY(a) (void)(a) - - TEXTMETRIC metric; - BITMAPINFO *dibInfo; - HDC bitDevice; - COLORREF tempColor; - int i; - - VERIFY(GetTextMetrics(fontDevice, &metric)); - - dibInfo = calloc(sizeof(BITMAPINFO) + sizeof(RGBQUAD), 1); - dibInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - dibInfo->bmiHeader.biPlanes = 1; - dibInfo->bmiHeader.biBitCount = 1; - dibInfo->bmiHeader.biCompression = BI_RGB; - - bitDevice = CreateCompatibleDC(fontDevice); - - /* Swap fore and back colors so the bitmap has the right polarity */ - tempColor = GetBkColor(bitDevice); - SetBkColor(bitDevice, GetTextColor(bitDevice)); - SetTextColor(bitDevice, tempColor); - - /* Place chars based on base line */ - VERIFY(SetTextAlign(bitDevice, TA_BASELINE) != GDI_ERROR ? 1 : 0); - - for(i = 0; i < (int)numChars; i++) { - SIZE size; - char curChar; - int charWidth,charHeight,bmapWidth,bmapHeight,numBytes,res; - HBITMAP bitObject; - HGDIOBJ origBmap; - unsigned char *bmap; - - curChar = (char)(i + firstChar); - - /* Find how high/wide this character is */ - VERIFY(GetTextExtentPoint32(bitDevice, &curChar, 1, &size)); - - /* Create the output bitmap */ - charWidth = size.cx; - charHeight = size.cy; - /* Round up to the next multiple of 32 bits */ - bmapWidth = ((charWidth + 31) / 32) * 32; - bmapHeight = charHeight; - bitObject = CreateCompatibleBitmap(bitDevice, - bmapWidth, - bmapHeight); - /* VERIFY(bitObject); */ - - /* Assign the output bitmap to the device */ - origBmap = SelectObject(bitDevice, bitObject); - (void) VERIFY(origBmap); - - VERIFY( PatBlt( bitDevice, 0, 0, bmapWidth, bmapHeight,BLACKNESS ) ); - - /* Use our source font on the device */ - VERIFY(SelectObject(bitDevice, GetCurrentObject(fontDevice,OBJ_FONT))); - - /* Draw the character */ - VERIFY(TextOut(bitDevice, 0, metric.tmAscent, &curChar, 1)); - - /* Unselect our bmap object */ - VERIFY(SelectObject(bitDevice, origBmap)); - - /* Convert the display dependant representation to a 1 bit deep DIB */ - numBytes = (bmapWidth * bmapHeight) / 8; - bmap = malloc(numBytes); - dibInfo->bmiHeader.biWidth = bmapWidth; - dibInfo->bmiHeader.biHeight = bmapHeight; - res = GetDIBits(bitDevice, bitObject, 0, bmapHeight, bmap, - dibInfo, - DIB_RGB_COLORS); - /* VERIFY(res); */ - - /* Create the GL object */ - glNewList(i + listBase, GL_COMPILE); - glBitmap(bmapWidth, bmapHeight, 0.0, (GLfloat)metric.tmDescent, - (GLfloat)charWidth, 0.0, - bmap); - glEndList(); - /* CheckGL(); */ - - /* Destroy the bmap object */ - DeleteObject(bitObject); - - /* Deallocate the bitmap data */ - free(bmap); - } - - /* Destroy the DC */ - VERIFY(DeleteDC(bitDevice)); - - free(dibInfo); - - return TRUE; -#undef VERIFY -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsA(HDC hdc, DWORD first, - DWORD count, DWORD listBase) -{ - int i; - GLuint font_list; - DWORD size; - GLYPHMETRICS gm; - HANDLE hBits; - LPSTR lpBits; - MAT2 mat; - int success = TRUE; - - if (count == 0) - return FALSE; - - font_list = listBase; - - mat.eM11 = FixedFromDouble(1); - mat.eM12 = FixedFromDouble(0); - mat.eM21 = FixedFromDouble(0); - mat.eM22 = FixedFromDouble(-1); - - memset(&gm,0,sizeof(gm)); - - /* - ** If we can't get the glyph outline, it may be because this is a fixed - ** font. Try processing it that way. - */ - if( GetGlyphOutline(hdc, first, GGO_BITMAP, &gm, 0, NULL, &mat) - == GDI_ERROR ) { - return wglUseFontBitmaps_FX( hdc, first, count, listBase ); - } - - /* - ** Otherwise process all desired characters. - */ - for (i = 0; i < (int)count; i++) { - DWORD err; - - glNewList( font_list+i, GL_COMPILE ); - - /* allocate space for the bitmap/outline */ - size = GetGlyphOutline(hdc, first + i, GGO_BITMAP, - &gm, 0, NULL, &mat); - if (size == GDI_ERROR) { - glEndList( ); - err = GetLastError(); - success = FALSE; - continue; - } - - hBits = GlobalAlloc(GHND, size+1); - lpBits = GlobalLock(hBits); - - err = - GetGlyphOutline(hdc, /* handle to device context */ - first + i, /* character to query */ - GGO_BITMAP, /* format of data to return */ - &gm, /* ptr to structure for metrics*/ - size, /* size of buffer for data */ - lpBits, /* pointer to buffer for data */ - &mat /* pointer to transformation */ - /* matrix structure */ - ); - - if (err == GDI_ERROR) { - GlobalUnlock(hBits); - GlobalFree(hBits); - - glEndList( ); - err = GetLastError(); - success = FALSE; - continue; - } - - glBitmap(gm.gmBlackBoxX,gm.gmBlackBoxY, - (GLfloat)-gm.gmptGlyphOrigin.x, - (GLfloat)gm.gmptGlyphOrigin.y, - (GLfloat)gm.gmCellIncX, - (GLfloat)gm.gmCellIncY, - (const GLubyte * )lpBits); - - GlobalUnlock(hBits); - GlobalFree(hBits); - - glEndList( ); - } - - return success; -} - -WINGDIAPI BOOL GLAPIENTRY wglShareLists(HGLRC hglrc1, - HGLRC hglrc2) -{ - WMesaShareLists((WMesaContext)hglrc1, (WMesaContext)hglrc2); - return(TRUE); -} - - - -/* NOT IMPLEMENTED YET */ -WINGDIAPI BOOL GLAPIENTRY wglCopyContext(HGLRC hglrcSrc, - HGLRC hglrcDst, - UINT mask) -{ - (void) hglrcSrc; (void) hglrcDst; (void) mask; - return(FALSE); -} - -WINGDIAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC hdc, - int iLayerPlane) -{ - SetLastError(0); - if (iLayerPlane == 0) - return wglCreateContext( hdc ); - return(NULL); -} - - -WINGDIAPI BOOL GLAPIENTRY wglUseFontBitmapsW(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase) -{ - (void) hdc; (void) first; (void) count; (void) listBase; - return FALSE; -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesA(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase, - FLOAT deviation, - FLOAT extrusion, - int format, - LPGLYPHMETRICSFLOAT lpgmf) -{ - (void) hdc; (void) first; (void) count; - (void) listBase; (void) deviation; (void) extrusion; (void) format; - (void) lpgmf; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglUseFontOutlinesW(HDC hdc, - DWORD first, - DWORD count, - DWORD listBase, - FLOAT deviation, - FLOAT extrusion, - int format, - LPGLYPHMETRICSFLOAT lpgmf) -{ - (void) hdc; (void) first; (void) count; - (void) listBase; (void) deviation; (void) extrusion; (void) format; - (void) lpgmf; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglDescribeLayerPlane(HDC hdc, - int iPixelFormat, - int iLayerPlane, - UINT nBytes, - LPLAYERPLANEDESCRIPTOR plpd) -{ - (void) hdc; (void) iPixelFormat; (void) iLayerPlane; - (void) nBytes; (void) plpd; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC hdc, - int iLayerPlane, - int iStart, - int cEntries, - CONST COLORREF *pcr) -{ - (void) hdc; (void) iLayerPlane; (void) iStart; - (void) cEntries; (void) pcr; - SetLastError(0); - return(0); -} - -WINGDIAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC hdc, - int iLayerPlane, - int iStart, - int cEntries, - COLORREF *pcr) -{ - (void) hdc; (void) iLayerPlane; (void) iStart; (void) cEntries; (void) pcr; - SetLastError(0); - return(0); -} - -WINGDIAPI BOOL GLAPIENTRY wglRealizeLayerPalette(HDC hdc, - int iLayerPlane, - BOOL bRealize) -{ - (void) hdc; (void) iLayerPlane; (void) bRealize; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI BOOL GLAPIENTRY wglSwapLayerBuffers(HDC hdc, - UINT fuPlanes) -{ - (void) hdc; (void) fuPlanes; - SetLastError(0); - return(FALSE); -} - -WINGDIAPI const char * GLAPIENTRY wglGetExtensionsStringARB(HDC hdc) -{ - return "WGL_ARB_extensions_string"; -} diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c b/mesalib/src/mesa/drivers/windows/gdi/wmesa.c deleted file mode 100644 index c1a9c28b1..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesa.c +++ /dev/null @@ -1,791 +0,0 @@ -/* - * Windows (Win32/Win64) device driver for Mesa - * - */ - -#include "wmesadef.h" -#include "colors.h" -#include "GL/wmesa.h" -#include <winuser.h> -#include "main/context.h" -#include "main/api_exec.h" -#include "main/extensions.h" -#include "main/framebuffer.h" -#include "main/renderbuffer.h" -#include "main/macros.h" -#include "main/version.h" -#include "main/vtxfmt.h" -#include "drivers/common/driverfuncs.h" -#include "drivers/common/meta.h" -#include "vbo/vbo.h" -#include "swrast/swrast.h" -#include "swrast/s_renderbuffer.h" -#include "swrast_setup/swrast_setup.h" -#include "tnl/tnl.h" -#include "tnl/t_context.h" -#include "tnl/t_pipeline.h" - - -/* linked list of our Framebuffers (windows) */ -static WMesaFramebuffer FirstFramebuffer = NULL; - - -/** - * Create a new WMesaFramebuffer object which will correspond to the - * given HDC (Window handle). - */ -static WMesaFramebuffer -wmesa_new_framebuffer(HDC hdc, struct gl_config *visual) -{ - WMesaFramebuffer pwfb - = malloc(sizeof(struct wmesa_framebuffer)); - if (pwfb) { - _mesa_initialize_window_framebuffer(&pwfb->Base, visual); - pwfb->hDC = hdc; - /* insert at head of list */ - pwfb->next = FirstFramebuffer; - FirstFramebuffer = pwfb; - } - return pwfb; -} - -/** - * Given an hdc, free the corresponding WMesaFramebuffer - */ -static void -wmesa_free_framebuffer(HDC hdc) -{ - WMesaFramebuffer pwfb, prev; - for (pwfb = FirstFramebuffer; pwfb; pwfb = pwfb->next) { - if (pwfb->hDC == hdc) - break; - prev = pwfb; - } - if (pwfb) { - struct gl_framebuffer *fb; - if (pwfb == FirstFramebuffer) - FirstFramebuffer = pwfb->next; - else - prev->next = pwfb->next; - fb = &pwfb->Base; - _mesa_reference_framebuffer(&fb, NULL); - } -} - -/** - * Given an hdc, return the corresponding WMesaFramebuffer - */ -static WMesaFramebuffer -wmesa_lookup_framebuffer(HDC hdc) -{ - WMesaFramebuffer pwfb; - for (pwfb = FirstFramebuffer; pwfb; pwfb = pwfb->next) { - if (pwfb->hDC == hdc) - return pwfb; - } - return NULL; -} - - -/** - * Given a struct gl_framebuffer, return the corresponding WMesaFramebuffer. - */ -static WMesaFramebuffer wmesa_framebuffer(struct gl_framebuffer *fb) -{ - return (WMesaFramebuffer) fb; -} - - -/** - * Given a struct gl_context, return the corresponding WMesaContext. - */ -static WMesaContext wmesa_context(const struct gl_context *ctx) -{ - return (WMesaContext) ctx; -} - - -/* - * Every driver should implement a GetString function in order to - * return a meaningful GL_RENDERER string. - */ -static const GLubyte *wmesa_get_string(struct gl_context *ctx, GLenum name) -{ - return (name == GL_RENDERER) ? - (GLubyte *) "Mesa Windows GDI Driver" : NULL; -} - - -/* - * Determine the pixel format based on the pixel size. - */ -static void wmSetPixelFormat(WMesaFramebuffer pwfb, HDC hDC) -{ - pwfb->cColorBits = GetDeviceCaps(hDC, BITSPIXEL); - - /* Only 16 and 32 bit targets are supported now */ - assert(pwfb->cColorBits == 0 || - pwfb->cColorBits == 16 || - pwfb->cColorBits == 24 || - pwfb->cColorBits == 32); - - switch(pwfb->cColorBits){ - case 8: - pwfb->pixelformat = PF_INDEX8; - break; - case 16: - pwfb->pixelformat = PF_5R6G5B; - break; - case 24: - case 32: - pwfb->pixelformat = PF_8R8G8B; - break; - default: - pwfb->pixelformat = PF_BADFORMAT; - } -} - - -/** - * Create DIB for back buffer. - * We write into this memory with the span routines and then blit it - * to the window on a buffer swap. - */ -static BOOL wmCreateBackingStore(WMesaFramebuffer pwfb, long lxSize, long lySize) -{ - LPBITMAPINFO pbmi = &(pwfb->bmi); - HDC hic; - - pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - pbmi->bmiHeader.biWidth = lxSize; - pbmi->bmiHeader.biHeight= -lySize; - pbmi->bmiHeader.biPlanes = 1; - pbmi->bmiHeader.biBitCount = GetDeviceCaps(pwfb->hDC, BITSPIXEL); - pbmi->bmiHeader.biCompression = BI_RGB; - pbmi->bmiHeader.biSizeImage = 0; - pbmi->bmiHeader.biXPelsPerMeter = 0; - pbmi->bmiHeader.biYPelsPerMeter = 0; - pbmi->bmiHeader.biClrUsed = 0; - pbmi->bmiHeader.biClrImportant = 0; - - pwfb->cColorBits = pbmi->bmiHeader.biBitCount; - pwfb->ScanWidth = (lxSize * (pwfb->cColorBits / 8) + 3) & ~3; - - hic = CreateIC("display", NULL, NULL, NULL); - pwfb->dib_hDC = CreateCompatibleDC(hic); - - pwfb->hbmDIB = CreateDIBSection(hic, - &pwfb->bmi, - DIB_RGB_COLORS, - (void **)&(pwfb->pbPixels), - 0, - 0); - pwfb->hOldBitmap = SelectObject(pwfb->dib_hDC, pwfb->hbmDIB); - - DeleteDC(hic); - - wmSetPixelFormat(pwfb, pwfb->hDC); - return TRUE; -} - - -static void wmDeleteBackingStore(WMesaFramebuffer pwfb) -{ - if (pwfb->hbmDIB) { - SelectObject(pwfb->dib_hDC, pwfb->hOldBitmap); - DeleteDC(pwfb->dib_hDC); - DeleteObject(pwfb->hbmDIB); - } -} - - -/** - * Find the width and height of the window named by hdc. - */ -static void -get_window_size(HDC hdc, GLuint *width, GLuint *height) -{ - if (WindowFromDC(hdc)) { - RECT rect; - GetClientRect(WindowFromDC(hdc), &rect); - *width = rect.right - rect.left; - *height = rect.bottom - rect.top; - } - else { /* Memory context */ - /* From contributed code - use the size of the desktop - * for the size of a memory context (?) */ - *width = GetDeviceCaps(hdc, HORZRES); - *height = GetDeviceCaps(hdc, VERTRES); - } -} - - -static void -wmesa_get_buffer_size(struct gl_framebuffer *buffer, GLuint *width, GLuint *height) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(buffer); - get_window_size(pwfb->hDC, width, height); -} - - -static void wmesa_flush(struct gl_context *ctx) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->WinSysDrawBuffer); - - if (ctx->Visual.doubleBufferMode == 1) { - BitBlt(pwfb->hDC, 0, 0, pwfb->Base.Width, pwfb->Base.Height, - pwfb->dib_hDC, 0, 0, SRCCOPY); - } - else { - /* Do nothing for single buffer */ - } -} - - -/**********************************************************************/ -/***** CLEAR Functions *****/ -/**********************************************************************/ - -/* - * Clear the color/depth/stencil buffers. - */ -static void clear(struct gl_context *ctx, GLbitfield mask) -{ -#define FLIP(Y) (ctx->DrawBuffer->Height - (Y) - 1) - const GLint x = ctx->DrawBuffer->_Xmin; - const GLint y = ctx->DrawBuffer->_Ymin; - const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin; - - WMesaContext pwc = wmesa_context(ctx); - WMesaFramebuffer pwfb = wmesa_framebuffer(ctx->DrawBuffer); - int done = 0; - - /* Let swrast do all the work if the masks are not set to - * clear all channels. */ - if (!ctx->Color.ColorMask[0][0] || - !ctx->Color.ColorMask[0][1] || - !ctx->Color.ColorMask[0][2] || - !ctx->Color.ColorMask[0][3]) { - _swrast_Clear(ctx, mask); - return; - } - - if (mask & BUFFER_BITS_COLOR) { - /* setup the clearing color */ - const union gl_color_union color = ctx->Color.ClearColor; - GLubyte col[3]; - UNCLAMPED_FLOAT_TO_UBYTE(col[0], color.f[0]); - UNCLAMPED_FLOAT_TO_UBYTE(col[1], color.f[1]); - UNCLAMPED_FLOAT_TO_UBYTE(col[2], color.f[2]); - pwc->clearColorRef = RGB(col[0], col[1], col[2]); - DeleteObject(pwc->clearPen); - DeleteObject(pwc->clearBrush); - pwc->clearPen = CreatePen(PS_SOLID, 1, pwc->clearColorRef); - pwc->clearBrush = CreateSolidBrush(pwc->clearColorRef); - } - - /* Back buffer */ - if (mask & BUFFER_BIT_BACK_LEFT) { - - int i, rowSize; - UINT bytesPerPixel = pwfb->cColorBits / 8; - LPBYTE lpb, clearRow; - LPWORD lpw; - BYTE bColor; - WORD wColor; - BYTE r, g, b; - DWORD dwColor; - LPDWORD lpdw; - - /* Try for a fast clear - clearing entire buffer with a single - * byte value. */ - if (width == ctx->DrawBuffer->Width && - height == ctx->DrawBuffer->Height) { /* entire buffer */ - /* Now check for an easy clear value */ - switch (bytesPerPixel) { - case 1: - bColor = BGR8(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - memset(pwfb->pbPixels, bColor, - pwfb->ScanWidth * height); - done = 1; - break; - case 2: - wColor = BGR16(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - if (((wColor >> 8) & 0xff) == (wColor & 0xff)) { - memset(pwfb->pbPixels, wColor & 0xff, - pwfb->ScanWidth * height); - done = 1; - } - break; - case 3: - /* fall through */ - case 4: - if (GetRValue(pwc->clearColorRef) == - GetGValue(pwc->clearColorRef) && - GetRValue(pwc->clearColorRef) == - GetBValue(pwc->clearColorRef)) { - memset(pwfb->pbPixels, - GetRValue(pwc->clearColorRef), - pwfb->ScanWidth * height); - done = 1; - } - break; - default: - break; - } - } /* all */ - - if (!done) { - /* Need to clear a row at a time. Begin by setting the first - * row in the area to be cleared to the clear color. */ - - clearRow = pwfb->pbPixels + - pwfb->ScanWidth * FLIP(y) + - bytesPerPixel * x; - switch (bytesPerPixel) { - case 1: - lpb = clearRow; - bColor = BGR8(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - memset(lpb, bColor, width); - break; - case 2: - lpw = (LPWORD)clearRow; - wColor = BGR16(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - for (i=0; i<width; i++) - *lpw++ = wColor; - break; - case 3: - lpb = clearRow; - r = GetRValue(pwc->clearColorRef); - g = GetGValue(pwc->clearColorRef); - b = GetBValue(pwc->clearColorRef); - for (i=0; i<width; i++) { - *lpb++ = b; - *lpb++ = g; - *lpb++ = r; - } - break; - case 4: - lpdw = (LPDWORD)clearRow; - dwColor = BGR32(GetRValue(pwc->clearColorRef), - GetGValue(pwc->clearColorRef), - GetBValue(pwc->clearColorRef)); - for (i=0; i<width; i++) - *lpdw++ = dwColor; - break; - default: - break; - } /* switch */ - - /* copy cleared row to other rows in buffer */ - lpb = clearRow - pwfb->ScanWidth; - rowSize = width * bytesPerPixel; - for (i=1; i<height; i++) { - memcpy(lpb, clearRow, rowSize); - lpb -= pwfb->ScanWidth; - } - } /* not done */ - mask &= ~BUFFER_BIT_BACK_LEFT; - } /* back buffer */ - - /* front buffer */ - if (mask & BUFFER_BIT_FRONT_LEFT) { - HDC DC = pwc->hDC; - HPEN Old_Pen = SelectObject(DC, pwc->clearPen); - HBRUSH Old_Brush = SelectObject(DC, pwc->clearBrush); - Rectangle(DC, - x, - FLIP(y) + 1, - x + width + 1, - FLIP(y) - height + 1); - SelectObject(DC, Old_Pen); - SelectObject(DC, Old_Brush); - mask &= ~BUFFER_BIT_FRONT_LEFT; - } /* front buffer */ - - /* Call swrast if there is anything left to clear (like DEPTH) */ - if (mask) - _swrast_Clear(ctx, mask); - -#undef FLIP -} - - - -/**********************************************************************/ -/***** BUFFER Functions *****/ -/**********************************************************************/ - - - - -static void -wmesa_delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb) -{ - _mesa_delete_renderbuffer(ctx, rb); -} - - -/** - * This is called by Mesa whenever it determines that the window size - * has changed. Do whatever's needed to cope with that. - */ -static GLboolean -wmesa_renderbuffer_storage(struct gl_context *ctx, - struct gl_renderbuffer *rb, - GLenum internalFormat, - GLuint width, - GLuint height) -{ - rb->Width = width; - rb->Height = height; - return GL_TRUE; -} - - -/** - * Called by ctx->Driver.ResizeBuffers() - * Resize the front/back colorbuffers to match the latest window size. - */ -static void -wmesa_resize_buffers(struct gl_context *ctx, struct gl_framebuffer *buffer, - GLuint width, GLuint height) -{ - WMesaFramebuffer pwfb = wmesa_framebuffer(buffer); - - if (pwfb->Base.Width != width || pwfb->Base.Height != height) { - /* Realloc back buffer */ - if (ctx->Visual.doubleBufferMode == 1) { - wmDeleteBackingStore(pwfb); - wmCreateBackingStore(pwfb, width, height); - } - } - _mesa_resize_framebuffer(ctx, buffer, width, height); -} - - -/** - * Called by glViewport. - * This is a good time for us to poll the current window size and adjust - * our renderbuffers to match the current window size. - * Remember, we have no opportunity to respond to conventional - * resize events since the driver has no event loop. - * Thus, we poll. - * MakeCurrent also ends up making a call here, so that ensures - * we get the viewport set correctly, even if the app does not call - * glViewport and relies on the defaults. - */ -static void wmesa_viewport(struct gl_context *ctx) -{ - GLuint new_width, new_height; - - wmesa_get_buffer_size(ctx->WinSysDrawBuffer, &new_width, &new_height); - - /** - * Resize buffers if the window size changed. - */ - wmesa_resize_buffers(ctx, ctx->WinSysDrawBuffer, new_width, new_height); - ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */ -} - - - - -/** - * Called when the driver should update it's state, based on the new_state - * flags. - */ -static void wmesa_update_state(struct gl_context *ctx, GLuint new_state) -{ - _swrast_InvalidateState(ctx, new_state); - _swsetup_InvalidateState(ctx, new_state); - _vbo_InvalidateState(ctx, new_state); - _tnl_InvalidateState(ctx, new_state); - - /* TODO - This code is not complete yet because I - * don't know what to do for all state updates. - */ - - if (new_state & _NEW_BUFFERS) { - } -} - - - - - -/**********************************************************************/ -/***** WMESA Functions *****/ -/**********************************************************************/ - -WMesaContext WMesaCreateContext(HDC hDC, - HPALETTE* Pal, - GLboolean rgb_flag, - GLboolean db_flag, - GLboolean alpha_flag) -{ - WMesaContext c; - struct dd_function_table functions; - GLint red_bits, green_bits, blue_bits, alpha_bits; - struct gl_context *ctx; - struct gl_config *visual; - - (void) Pal; - - /* Indexed mode not supported */ - if (!rgb_flag) - return NULL; - - /* Allocate wmesa context */ - c = CALLOC_STRUCT(wmesa_context); - if (!c) - return NULL; - -#if 0 - /* I do not understand this contributed code */ - /* Support memory and device contexts */ - if(WindowFromDC(hDC) != NULL) { - c->hDC = GetDC(WindowFromDC(hDC)); /* huh ???? */ - } - else { - c->hDC = hDC; - } -#else - c->hDC = hDC; -#endif - - /* Get data for visual */ - /* Dealing with this is actually a bit of overkill because Mesa will end - * up treating all color component size requests less than 8 by using - * a single byte per channel. In addition, the interface to the span - * routines passes colors as an entire byte per channel anyway, so there - * is nothing to be saved by telling the visual to be 16 bits if the device - * is 16 bits. That is, Mesa is going to compute colors down to 8 bits per - * channel anyway. - * But we go through the motions here anyway. - */ - switch (GetDeviceCaps(c->hDC, BITSPIXEL)) { - case 16: - red_bits = green_bits = blue_bits = 5; - alpha_bits = 0; - break; - default: - red_bits = green_bits = blue_bits = 8; - alpha_bits = 8; - break; - } - /* Create visual based on flags */ - visual = _mesa_create_visual(db_flag, /* db_flag */ - GL_FALSE, /* stereo */ - red_bits, green_bits, blue_bits, /* color RGB */ - alpha_flag ? alpha_bits : 0, /* color A */ - DEFAULT_SOFTWARE_DEPTH_BITS, /* depth_bits */ - 8, /* stencil_bits */ - 16,16,16, /* accum RGB */ - alpha_flag ? 16 : 0, /* accum A */ - 1); /* num samples */ - - if (!visual) { - free(c); - return NULL; - } - - /* Set up driver functions */ - _mesa_init_driver_functions(&functions); - functions.GetString = wmesa_get_string; - functions.UpdateState = wmesa_update_state; - functions.Flush = wmesa_flush; - functions.Clear = clear; - functions.ResizeBuffers = wmesa_resize_buffers; - functions.Viewport = wmesa_viewport; - - /* initialize the Mesa context data */ - ctx = &c->gl_ctx; - _mesa_initialize_context(ctx, API_OPENGL_COMPAT, visual, - NULL, &functions); - - /* visual no longer needed - it was copied by _mesa_initialize_context() */ - _mesa_destroy_visual(visual); - - _mesa_enable_sw_extensions(ctx); - - _mesa_meta_init(ctx); - - /* Initialize the software rasterizer and helper modules. */ - if (!_swrast_CreateContext(ctx) || - !_vbo_CreateContext(ctx) || - !_tnl_CreateContext(ctx) || - !_swsetup_CreateContext(ctx)) { - _mesa_free_context_data(ctx); - free(c); - return NULL; - } - _swsetup_Wakeup(ctx); - TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline; - - _mesa_compute_version(ctx); - - /* Exec table initialization requires the version to be computed */ - _mesa_initialize_dispatch_tables(ctx); - _mesa_initialize_vbo_vtxfmt(ctx); - - return c; -} - - -void WMesaDestroyContext( WMesaContext pwc ) -{ - struct gl_context *ctx = &pwc->gl_ctx; - WMesaFramebuffer pwfb; - GET_CURRENT_CONTEXT(cur_ctx); - - if (cur_ctx == ctx) { - /* unbind current if deleting current context */ - WMesaMakeCurrent(NULL, NULL); - } - - /* clean up frame buffer resources */ - pwfb = wmesa_lookup_framebuffer(pwc->hDC); - if (pwfb) { - if (ctx->Visual.doubleBufferMode == 1) - wmDeleteBackingStore(pwfb); - wmesa_free_framebuffer(pwc->hDC); - } - - /* Release for device, not memory contexts */ - if (WindowFromDC(pwc->hDC) != NULL) - { - ReleaseDC(WindowFromDC(pwc->hDC), pwc->hDC); - } - DeleteObject(pwc->clearPen); - DeleteObject(pwc->clearBrush); - - _mesa_meta_free(ctx); - - _swsetup_DestroyContext(ctx); - _tnl_DestroyContext(ctx); - _vbo_DestroyContext(ctx); - _swrast_DestroyContext(ctx); - - _mesa_free_context_data(ctx); - free(pwc); -} - - -/** - * Create a new color renderbuffer. - */ -static struct gl_renderbuffer * -wmesa_new_renderbuffer(void) -{ - struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer); - if (!rb) - return NULL; - - _mesa_init_renderbuffer(rb, (GLuint)0); - - rb->_BaseFormat = GL_RGBA; - rb->InternalFormat = GL_RGBA; - rb->Delete = wmesa_delete_renderbuffer; - rb->AllocStorage = wmesa_renderbuffer_storage; - return rb; -} - - -void WMesaMakeCurrent(WMesaContext c, HDC hdc) -{ - WMesaFramebuffer pwfb; - - { - /* return if already current */ - GET_CURRENT_CONTEXT(ctx); - WMesaContext pwc = wmesa_context(ctx); - if (pwc && c == pwc && pwc->hDC == hdc) - return; - } - - pwfb = wmesa_lookup_framebuffer(hdc); - - /* Lazy creation of framebuffers */ - if (c && !pwfb && hdc) { - struct gl_renderbuffer *rb; - struct gl_config *visual = &c->gl_ctx.Visual; - GLuint width, height; - - get_window_size(hdc, &width, &height); - - c->clearPen = CreatePen(PS_SOLID, 1, 0); - c->clearBrush = CreateSolidBrush(0); - - pwfb = wmesa_new_framebuffer(hdc, visual); - - /* Create back buffer if double buffered */ - if (visual->doubleBufferMode == 1) { - wmCreateBackingStore(pwfb, width, height); - } - - /* make render buffers */ - if (visual->doubleBufferMode == 1) { - rb = wmesa_new_renderbuffer(); - _mesa_add_renderbuffer(&pwfb->Base, BUFFER_BACK_LEFT, rb); - } - rb = wmesa_new_renderbuffer(); - _mesa_add_renderbuffer(&pwfb->Base, BUFFER_FRONT_LEFT, rb); - - /* Let Mesa own the Depth, Stencil, and Accum buffers */ - _swrast_add_soft_renderbuffers(&pwfb->Base, - GL_FALSE, /* color */ - visual->depthBits > 0, - visual->stencilBits > 0, - visual->accumRedBits > 0, - visual->alphaBits >0, - GL_FALSE); - } - - if (c && pwfb) - _mesa_make_current(&c->gl_ctx, &pwfb->Base, &pwfb->Base); - else - _mesa_make_current(NULL, NULL, NULL); -} - - -void WMesaSwapBuffers( HDC hdc ) -{ - GET_CURRENT_CONTEXT(ctx); - WMesaContext pwc = wmesa_context(ctx); - WMesaFramebuffer pwfb = wmesa_lookup_framebuffer(hdc); - - if (!pwfb) { - _mesa_problem(NULL, "wmesa: swapbuffers on unknown hdc"); - return; - } - - /* If we're swapping the buffer associated with the current context - * we have to flush any pending rendering commands first. - */ - if (pwc->hDC == hdc) { - _mesa_notifySwapBuffers(ctx); - - BitBlt(pwfb->hDC, 0, 0, pwfb->Base.Width, pwfb->Base.Height, - pwfb->dib_hDC, 0, 0, SRCCOPY); - } - else { - /* XXX for now only allow swapping current window */ - _mesa_problem(NULL, "wmesa: can't swap non-current window"); - } -} - -void WMesaShareLists(WMesaContext ctx_to_share, WMesaContext ctx) -{ - _mesa_share_state(&ctx->gl_ctx, &ctx_to_share->gl_ctx); -} - diff --git a/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h b/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h deleted file mode 100644 index 9fda88390..000000000 --- a/mesalib/src/mesa/drivers/windows/gdi/wmesadef.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef WMESADEF_H -#define WMESADEF_H - -#include <windows.h> - -#include "main/context.h" - - -/** - * The Windows Mesa rendering context, derived from struct gl_context. - */ -struct wmesa_context { - struct gl_context gl_ctx; /* The core GL/Mesa context */ - HDC hDC; - COLORREF clearColorRef; - HPEN clearPen; - HBRUSH clearBrush; -}; - - -/** - * Windows framebuffer, derived from gl_framebuffer - */ -struct wmesa_framebuffer -{ - struct gl_framebuffer Base; - HDC hDC; - int pixelformat; - GLuint ScanWidth; - int cColorBits; - /* back buffer DIB fields */ - HDC dib_hDC; - BITMAPINFO bmi; - HBITMAP hbmDIB; - HBITMAP hOldBitmap; - PBYTE pbPixels; - struct wmesa_framebuffer *next; -}; - -typedef struct wmesa_framebuffer *WMesaFramebuffer; - - -#endif /* WMESADEF_H */ 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, ¶m)) { - 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_ */ diff --git a/mesalib/src/mesa/math/m_debug_norm.c b/mesalib/src/mesa/math/m_debug_norm.c index 00e72be54..197b43cf2 100644 --- a/mesalib/src/mesa/math/m_debug_norm.c +++ b/mesalib/src/mesa/math/m_debug_norm.c @@ -26,6 +26,7 @@ * Gareth Hughes */ +#include "c99_math.h" #include "main/glheader.h" #include "main/context.h" #include "main/macros.h" @@ -165,7 +166,7 @@ static void ref_norm_transform_normalize( const GLmatrix *mat, /* Hmmm, don't know how we could test the precalculated * length case... */ - scale = INV_SQRTF( len ); + scale = 1.0f / sqrtf(len); SCALE_SCALAR_3V( out[i], scale, t ); } else { out[i][0] = out[i][1] = out[i][2] = 0; @@ -241,7 +242,7 @@ static int test_norm_function( normal_func func, int mtype, long *cycles ) ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 ); for ( j = 0 ; j < 3 ; j++ ) s[i][j] = rnd(); - length[i] = INV_SQRTF( LEN_SQUARED_3FV( s[i] ) ); + length[i] = 1.0f / sqrtf( LEN_SQUARED_3FV( s[i] ) ); } source->data = (GLfloat(*)[4]) s; diff --git a/mesalib/src/mesa/math/m_debug_util.h b/mesalib/src/mesa/math/m_debug_util.h index d05da8994..25ee029ce 100644 --- a/mesalib/src/mesa/math/m_debug_util.h +++ b/mesalib/src/mesa/math/m_debug_util.h @@ -32,6 +32,9 @@ #ifdef DEBUG_MATH /* This code only used for debugging */ +#include "c99_math.h" + + /* Comment this out to deactivate the cycle counter. * NOTE: it works only on CPUs which know the 'rdtsc' command (586 or higher) * (hope, you don't try to debug Mesa on a 386 ;) @@ -286,9 +289,9 @@ static int significand_match( GLfloat a, GLfloat b ) return 0; } - FREXPF( a, &a_ex ); - FREXPF( b, &b_ex ); - FREXPF( d, &d_ex ); + frexpf( a, &a_ex ); + frexpf( b, &b_ex ); + frexpf( d, &d_ex ); if ( a_ex < b_ex ) { return a_ex - d_ex; diff --git a/mesalib/src/mesa/math/m_debug_xform.c b/mesalib/src/mesa/math/m_debug_xform.c index f56b4cfc7..632c82ea2 100644 --- a/mesalib/src/mesa/math/m_debug_xform.c +++ b/mesalib/src/mesa/math/m_debug_xform.c @@ -187,7 +187,7 @@ static int test_transform_function( transform_func func, int psize, mat->type = mtypes[mtype]; m = mat->m; - ASSERT( ((long)m & 15) == 0 ); + assert( ((long)m & 15) == 0 ); init_matrix( m ); @@ -206,7 +206,7 @@ static int test_transform_function( transform_func func, int psize, case VAR: break; default: - ASSERT(0); + assert(0); return 0; } } diff --git a/mesalib/src/mesa/math/m_matrix.c b/mesalib/src/mesa/math/m_matrix.c index 9c9310d93..0475a7ab2 100644 --- a/mesalib/src/mesa/math/m_matrix.c +++ b/mesalib/src/mesa/math/m_matrix.c @@ -34,6 +34,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/imports.h" #include "main/macros.h" @@ -376,9 +377,9 @@ static GLboolean invert_matrix_general( GLmatrix *mat ) r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0; /* choose pivot - or die */ - if (FABSF(r3[0])>FABSF(r2[0])) SWAP_ROWS(r3, r2); - if (FABSF(r2[0])>FABSF(r1[0])) SWAP_ROWS(r2, r1); - if (FABSF(r1[0])>FABSF(r0[0])) SWAP_ROWS(r1, r0); + if (fabsf(r3[0])>fabsf(r2[0])) SWAP_ROWS(r3, r2); + if (fabsf(r2[0])>fabsf(r1[0])) SWAP_ROWS(r2, r1); + if (fabsf(r1[0])>fabsf(r0[0])) SWAP_ROWS(r1, r0); if (0.0 == r0[0]) return GL_FALSE; /* eliminate first variable */ @@ -396,8 +397,8 @@ static GLboolean invert_matrix_general( GLmatrix *mat ) if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ - if (FABSF(r3[1])>FABSF(r2[1])) SWAP_ROWS(r3, r2); - if (FABSF(r2[1])>FABSF(r1[1])) SWAP_ROWS(r2, r1); + if (fabsf(r3[1])>fabsf(r2[1])) SWAP_ROWS(r3, r2); + if (fabsf(r2[1])>fabsf(r1[1])) SWAP_ROWS(r2, r1); if (0.0 == r1[1]) return GL_FALSE; /* eliminate second variable */ @@ -410,7 +411,7 @@ static GLboolean invert_matrix_general( GLmatrix *mat ) s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; } /* choose pivot - or die */ - if (FABSF(r3[2])>FABSF(r2[2])) SWAP_ROWS(r3, r2); + if (fabsf(r3[2])>fabsf(r2[2])) SWAP_ROWS(r3, r2); if (0.0 == r2[2]) return GL_FALSE; /* eliminate third variable */ @@ -508,7 +509,7 @@ static GLboolean invert_matrix_3d_general( GLmatrix *mat ) det = pos + neg; - if (FABSF(det) < 1e-25) + if (fabsf(det) < 1e-25) return GL_FALSE; det = 1.0F / det; @@ -798,8 +799,8 @@ _math_matrix_rotate( GLmatrix *mat, GLfloat m[16]; GLboolean optimized; - s = (GLfloat) sin( angle * DEG2RAD ); - c = (GLfloat) cos( angle * DEG2RAD ); + s = (GLfloat) sin( angle * M_PI / 180.0 ); + c = (GLfloat) cos( angle * M_PI / 180.0 ); memcpy(m, Identity, sizeof(GLfloat)*16); optimized = GL_FALSE; @@ -1069,7 +1070,7 @@ _math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z ) m[2] *= x; m[6] *= y; m[10] *= z; m[3] *= x; m[7] *= y; m[11] *= z; - if (FABSF(x - y) < 1e-8 && FABSF(x - z) < 1e-8) + if (fabsf(x - y) < 1e-8 && fabsf(x - z) < 1e-8) mat->flags |= MAT_FLAG_UNIFORM_SCALE; else mat->flags |= MAT_FLAG_GENERAL_SCALE; diff --git a/mesalib/src/mesa/math/m_norm_tmp.h b/mesalib/src/mesa/math/m_norm_tmp.h index 339c03ff8..c8fab0ed3 100644 --- a/mesalib/src/mesa/math/m_norm_tmp.h +++ b/mesalib/src/mesa/math/m_norm_tmp.h @@ -68,7 +68,7 @@ TAG(transform_normalize_normals)( const GLmatrix *mat, { GLdouble len = tx*tx + ty*ty + tz*tz; if (len > 1e-20) { - GLfloat scale = INV_SQRTF(len); + GLfloat scale = 1.0f / sqrtf(len); out[i][0] = tx * scale; out[i][1] = ty * scale; out[i][2] = tz * scale; @@ -135,7 +135,7 @@ TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat, { GLdouble len = tx*tx + ty*ty + tz*tz; if (len > 1e-20) { - GLfloat scale = INV_SQRTF(len); + GLfloat scale = 1.0f / sqrtf(len); out[i][0] = tx * scale; out[i][1] = ty * scale; out[i][2] = tz * scale; @@ -322,7 +322,7 @@ TAG(normalize_normals)( const GLmatrix *mat, const GLfloat x = from[0], y = from[1], z = from[2]; GLdouble len = x * x + y * y + z * z; if (len > 1e-50) { - len = INV_SQRTF(len); + len = 1.0f / sqrtf(len); out[i][0] = (GLfloat)(x * len); out[i][1] = (GLfloat)(y * len); out[i][2] = (GLfloat)(z * len); diff --git a/mesalib/src/mesa/math/m_trans_tmp.h b/mesalib/src/mesa/math/m_trans_tmp.h index f39a3c83a..0a8bfc538 100644 --- a/mesalib/src/mesa/math/m_trans_tmp.h +++ b/mesalib/src/mesa/math/m_trans_tmp.h @@ -40,13 +40,11 @@ static void DEST_4F( GLfloat (*t)[4], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4F(f, 0); - if (SZ >= 2) t[i][1] = TRX_4F(f, 1); - if (SZ >= 3) t[i][2] = TRX_4F(f, 2); - if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; - } + NEXT_F2; + if (SZ >= 1) t[i][0] = TRX_4F(f, 0); + if (SZ >= 2) t[i][1] = TRX_4F(f, 1); + if (SZ >= 3) t[i][2] = TRX_4F(f, 2); + if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0; } } #endif @@ -66,13 +64,11 @@ static void DEST_4FN( GLfloat (*t)[4], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); - if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); - if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); - if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; - } + NEXT_F2; + if (SZ >= 1) t[i][0] = TRX_4FN(f, 0); + if (SZ >= 2) t[i][1] = TRX_4FN(f, 1); + if (SZ >= 3) t[i][2] = TRX_4FN(f, 2); + if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0; } } #endif @@ -90,12 +86,10 @@ static void DEST_3FN( GLfloat (*t)[3], (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i][0] = TRX_3FN(f, 0); - t[i][1] = TRX_3FN(f, 1); - t[i][2] = TRX_3FN(f, 2); - } + NEXT_F2; + t[i][0] = TRX_3FN(f, 0); + t[i][1] = TRX_3FN(f, 1); + t[i][2] = TRX_3FN(f, 2); } } #endif @@ -112,10 +106,8 @@ static void DEST_1F( GLfloat *t, (void) first; (void) start; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_1F(f, 0); - } + NEXT_F2; + t[i] = TRX_1F(f, 0); } } #endif @@ -132,13 +124,11 @@ static void DEST_4UB( GLubyte (*t)[4], (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_UB(t[i][0], f, 0); - if (SZ >= 2) TRX_UB(t[i][1], f, 1); - if (SZ >= 3) TRX_UB(t[i][2], f, 2); - if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; - } + NEXT_F2; + if (SZ >= 1) TRX_UB(t[i][0], f, 0); + if (SZ >= 2) TRX_UB(t[i][1], f, 1); + if (SZ >= 3) TRX_UB(t[i][2], f, 2); + if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255; } } #endif @@ -156,13 +146,11 @@ static void DEST_4US( GLushort (*t)[4], (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - if (SZ >= 1) TRX_US(t[i][0], f, 0); - if (SZ >= 2) TRX_US(t[i][1], f, 1); - if (SZ >= 3) TRX_US(t[i][2], f, 2); - if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; - } + NEXT_F2; + if (SZ >= 1) TRX_US(t[i][0], f, 0); + if (SZ >= 2) TRX_US(t[i][1], f, 1); + if (SZ >= 3) TRX_US(t[i][2], f, 2); + if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535; } } #endif @@ -180,10 +168,8 @@ static void DEST_1UB( GLubyte *t, (void) start; (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - TRX_UB(t[i], f, 0); - } + NEXT_F2; + TRX_UB(t[i], f, 0); } } #endif @@ -202,10 +188,8 @@ static void DEST_1UI( GLuint *t, (void) first; for (i = DST_START ; i < n ; i++, NEXT_F) { - CHECK { - NEXT_F2; - t[i] = TRX_UI(f, 0); - } + NEXT_F2; + t[i] = TRX_UI(f, 0); } } #endif @@ -214,19 +198,19 @@ static void DEST_1UI( GLuint *t, static void INIT(void) { #ifdef DEST_1UI - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1ui)[SRC_IDX] = DEST_1UI; #endif #ifdef DEST_1UB - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1ub)[SRC_IDX] = DEST_1UB; #endif #ifdef DEST_1F - ASSERT(SZ == 1); + assert(SZ == 1); TAB(_1f)[SRC_IDX] = DEST_1F; #endif #ifdef DEST_3FN - ASSERT(SZ == 3); + assert(SZ == 3); TAB(_3fn)[SRC_IDX] = DEST_3FN; #endif #ifdef DEST_4UB diff --git a/mesalib/src/mesa/math/m_translate.c b/mesalib/src/mesa/math/m_translate.c index 3a8ca74f6..a5bf5d76f 100644 --- a/mesalib/src/mesa/math/m_translate.c +++ b/mesalib/src/mesa/math/m_translate.c @@ -84,10 +84,6 @@ typedef void (*trans_3fn_func)(GLfloat (*to)[3], #define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */ -/* This macro is used on other systems, so undefine it for this module */ - -#undef CHECK - static trans_1f_func _math_trans_1f_tab[MAX_TYPES]; static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES]; static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES]; @@ -108,7 +104,6 @@ static trans_4f_func _math_trans_4fn_tab[5][MAX_TYPES]; #define STRIDE stride #define NEXT_F f += stride #define NEXT_F2 -#define CHECK @@ -604,7 +599,6 @@ static void init_translate_raw(void) #undef CLASS #endif #undef ARGS -#undef CHECK #undef SRC_START #undef DST_START #undef NEXT_F diff --git a/mesalib/src/mesa/math/m_translate.h b/mesalib/src/mesa/math/m_translate.h index bdfa4c770..62f676ca6 100644 --- a/mesalib/src/mesa/math/m_translate.h +++ b/mesalib/src/mesa/math/m_translate.h @@ -26,7 +26,6 @@ #ifndef _M_TRANSLATE_H_ #define _M_TRANSLATE_H_ -#include "main/compiler.h" #include "main/glheader.h" /** diff --git a/mesalib/src/mesa/math/m_vector.c b/mesalib/src/mesa/math/m_vector.c index ff42396b7..831f953d6 100644 --- a/mesalib/src/mesa/math/m_vector.c +++ b/mesalib/src/mesa/math/m_vector.c @@ -26,6 +26,7 @@ * New (3.1) transformation code written by Keith Whitwell. */ +#include <stdio.h> #include "main/glheader.h" #include "main/imports.h" diff --git a/mesalib/src/mesa/math/m_xform.c b/mesalib/src/mesa/math/m_xform.c index 14d1c6453..718ad4993 100644 --- a/mesalib/src/mesa/math/m_xform.c +++ b/mesalib/src/mesa/math/m_xform.c @@ -33,6 +33,7 @@ * 3. Transformation of a point p by a matrix M is: p' = M * p */ +#include "c99_math.h" #include "main/glheader.h" #include "main/macros.h" diff --git a/mesalib/src/mesa/math/m_xform.h b/mesalib/src/mesa/math/m_xform.h index e45880322..2ed62e711 100644 --- a/mesalib/src/mesa/math/m_xform.h +++ b/mesalib/src/mesa/math/m_xform.h @@ -119,7 +119,7 @@ typedef void (*vec_copy_func)( GLvector4f *to, /* * Functions for transformation of normals in the VB. */ -typedef void (_NORMAPIP normal_func)( const GLmatrix *mat, +typedef void (_XFORMAPIP normal_func)( const GLmatrix *mat, GLfloat scale, const GLvector4f *in, const GLfloat lengths[], diff --git a/mesalib/src/mesa/program/arbprogparse.c b/mesalib/src/mesa/program/arbprogparse.c index 53a6f37cb..3ddaeca8a 100644 --- a/mesalib/src/mesa/program/arbprogparse.c +++ b/mesalib/src/mesa/program/arbprogparse.c @@ -73,7 +73,7 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target, struct asm_parser_state state; GLuint i; - ASSERT(target == GL_FRAGMENT_PROGRAM_ARB); + assert(target == GL_FRAGMENT_PROGRAM_ARB); memset(&prog, 0, sizeof(prog)); memset(&state, 0, sizeof(state)); @@ -166,7 +166,7 @@ _mesa_parse_arb_vertex_program(struct gl_context *ctx, GLenum target, struct gl_program prog; struct asm_parser_state state; - ASSERT(target == GL_VERTEX_PROGRAM_ARB); + assert(target == GL_VERTEX_PROGRAM_ARB); memset(&prog, 0, sizeof(prog)); memset(&state, 0, sizeof(state)); diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index b2776da45..39790ec8e 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -1018,7 +1018,7 @@ void ir_to_mesa_visitor::visit(ir_expression *ir) { unsigned int operand; - src_reg op[Elements(ir->operands)]; + src_reg op[ARRAY_SIZE(ir->operands)]; src_reg result_src; dst_reg result_dst; diff --git a/mesalib/src/mesa/program/prog_execute.c b/mesalib/src/mesa/program/prog_execute.c index b2fbc808a..dc4919ae8 100644 --- a/mesalib/src/mesa/program/prog_execute.c +++ b/mesalib/src/mesa/program/prog_execute.c @@ -35,6 +35,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" @@ -123,7 +124,7 @@ get_src_register_pointer(const struct prog_src_register *source, return (GLfloat *) prog->Parameters->ParameterValues[reg]; case PROGRAM_SYSTEM_VALUE: - assert(reg < (GLint) Elements(machine->SystemValues)); + assert(reg < (GLint) ARRAY_SIZE(machine->SystemValues)); return machine->SystemValues[reg]; default: @@ -190,10 +191,10 @@ fetch_vector4(const struct prog_src_register *source, COPY_4V(result, src); } else { - ASSERT(GET_SWZ(source->Swizzle, 0) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 1) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 2) <= 3); - ASSERT(GET_SWZ(source->Swizzle, 3) <= 3); + assert(GET_SWZ(source->Swizzle, 0) <= 3); + assert(GET_SWZ(source->Swizzle, 1) <= 3); + assert(GET_SWZ(source->Swizzle, 2) <= 3); + assert(GET_SWZ(source->Swizzle, 3) <= 3); result[0] = src[GET_SWZ(source->Swizzle, 0)]; result[1] = src[GET_SWZ(source->Swizzle, 1)]; result[2] = src[GET_SWZ(source->Swizzle, 2)]; @@ -201,13 +202,13 @@ fetch_vector4(const struct prog_src_register *source, } if (source->Abs) { - result[0] = FABSF(result[0]); - result[1] = FABSF(result[1]); - result[2] = FABSF(result[2]); - result[3] = FABSF(result[3]); + result[0] = fabsf(result[0]); + result[1] = fabsf(result[1]); + result[2] = fabsf(result[2]); + result[3] = fabsf(result[3]); } if (source->Negate) { - ASSERT(source->Negate == NEGATE_XYZW); + assert(source->Negate == NEGATE_XYZW); result[0] = -result[0]; result[1] = -result[1]; result[2] = -result[2]; @@ -259,13 +260,13 @@ fetch_vector4_deriv(struct gl_context * ctx, result[3] = deriv[GET_SWZ(source->Swizzle, 3)]; if (source->Abs) { - result[0] = FABSF(result[0]); - result[1] = FABSF(result[1]); - result[2] = FABSF(result[2]); - result[3] = FABSF(result[3]); + result[0] = fabsf(result[0]); + result[1] = fabsf(result[1]); + result[2] = fabsf(result[2]); + result[3] = fabsf(result[3]); } if (source->Negate) { - ASSERT(source->Negate == NEGATE_XYZW); + assert(source->Negate == NEGATE_XYZW); result[0] = -result[0]; result[1] = -result[1]; result[2] = -result[2]; @@ -290,7 +291,7 @@ fetch_vector1(const struct prog_src_register *source, result[0] = src[GET_SWZ(source->Swizzle, 0)]; if (source->Abs) { - result[0] = FABSF(result[0]); + result[0] = fabsf(result[0]); } if (source->Negate) { result[0] = -result[0]; @@ -520,10 +521,10 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = FABSF(a[0]); - result[1] = FABSF(a[1]); - result[2] = FABSF(a[2]); - result[3] = FABSF(a[3]); + result[0] = fabsf(a[0]); + result[1] = fabsf(a[1]); + result[2] = fabsf(a[2]); + result[3] = fabsf(a[3]); store_vector4(inst, machine, result); } break; @@ -556,12 +557,12 @@ _mesa_execute_program(struct gl_context * ctx, break; case OPCODE_BGNLOOP: /* no-op */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDLOOP); break; case OPCODE_ENDLOOP: /* subtract 1 here since pc is incremented by for(pc) loop */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_BGNLOOP); pc = inst->BranchTarget - 1; /* go to matching BNGLOOP */ break; @@ -570,7 +571,7 @@ _mesa_execute_program(struct gl_context * ctx, case OPCODE_ENDSUB: /* end subroutine */ break; case OPCODE_BRK: /* break out of loop (conditional) */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDLOOP); if (eval_condition(machine, inst)) { /* break out of loop */ @@ -579,7 +580,7 @@ _mesa_execute_program(struct gl_context * ctx, } break; case OPCODE_CONT: /* continue loop (conditional) */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDLOOP); if (eval_condition(machine, inst)) { /* continue at ENDLOOP */ @@ -708,7 +709,7 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat t[4], q[4], floor_t0; fetch_vector1(&inst->SrcReg[0], machine, t); - floor_t0 = FLOORF(t[0]); + floor_t0 = floorf(t[0]); if (floor_t0 > FLT_MAX_EXP) { SET_POS_INFINITY(q[0]); SET_POS_INFINITY(q[2]); @@ -718,7 +719,7 @@ _mesa_execute_program(struct gl_context * ctx, q[2] = 0.0F; } else { - q[0] = LDEXPF(1.0, (int) floor_t0); + q[0] = ldexpf(1.0, (int) floor_t0); /* Note: GL_NV_vertex_program expects * result.z = result.x * APPX(result.y) * We do what the ARB extension says. @@ -747,10 +748,10 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = FLOORF(a[0]); - result[1] = FLOORF(a[1]); - result[2] = FLOORF(a[2]); - result[3] = FLOORF(a[3]); + result[0] = floorf(a[0]); + result[1] = floorf(a[1]); + result[2] = floorf(a[2]); + result[3] = floorf(a[3]); store_vector4(inst, machine, result); } break; @@ -758,17 +759,17 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector4(&inst->SrcReg[0], machine, a); - result[0] = a[0] - FLOORF(a[0]); - result[1] = a[1] - FLOORF(a[1]); - result[2] = a[2] - FLOORF(a[2]); - result[3] = a[3] - FLOORF(a[3]); + result[0] = a[0] - floorf(a[0]); + result[1] = a[1] - floorf(a[1]); + result[2] = a[2] - floorf(a[2]); + result[3] = a[3] - floorf(a[3]); store_vector4(inst, machine, result); } break; case OPCODE_IF: { GLboolean cond; - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ELSE || program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDIF); @@ -797,7 +798,7 @@ _mesa_execute_program(struct gl_context * ctx, break; case OPCODE_ELSE: /* goto ENDIF */ - ASSERT(program->Instructions[inst->BranchTarget].Opcode + assert(program->Instructions[inst->BranchTarget].Opcode == OPCODE_ENDIF); assert(inst->BranchTarget >= 0); pc = inst->BranchTarget; @@ -874,7 +875,7 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat t[4], q[4], abs_t0; fetch_vector1(&inst->SrcReg[0], machine, t); - abs_t0 = FABSF(t[0]); + abs_t0 = fabsf(t[0]); if (abs_t0 != 0.0F) { if (IS_INF_OR_NAN(abs_t0)) { @@ -884,7 +885,7 @@ _mesa_execute_program(struct gl_context * ctx, } else { int exponent; - GLfloat mantissa = FREXPF(t[0], &exponent); + GLfloat mantissa = frexpf(t[0], &exponent); q[0] = (GLfloat) (exponent - 1); q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */ @@ -1083,8 +1084,8 @@ _mesa_execute_program(struct gl_context * ctx, { GLfloat a[4], result[4]; fetch_vector1(&inst->SrcReg[0], machine, a); - a[0] = FABSF(a[0]); - result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]); + a[0] = fabsf(a[0]); + result[0] = result[1] = result[2] = result[3] = 1.0f / sqrtf(a[0]); store_vector4(inst, machine, result); if (DEBUG_PROG) { printf("RSQ %g = 1/sqrt(|%g|)\n", result[0], a[0]); @@ -1260,7 +1261,7 @@ _mesa_execute_program(struct gl_context * ctx, else if (swz == SWIZZLE_ONE) result[i] = 1.0; else { - ASSERT(swz <= 3); + assert(swz <= 3); result[i] = src[swz]; } if (source->Negate & (1 << i)) @@ -1357,7 +1358,7 @@ _mesa_execute_program(struct gl_context * ctx, fetch_vector4(&inst->SrcReg[0], machine, texcoord); /* Not so sure about this test - if texcoord[3] is - * zero, we'd probably be fine except for an ASSERT in + * zero, we'd probably be fine except for an assert in * IROUND_POS() which gets triggered by the inf values created. */ if (texcoord[3] != 0.0) { diff --git a/mesalib/src/mesa/program/prog_instruction.c b/mesalib/src/mesa/program/prog_instruction.c index 254c0128f..6a9bcb7b5 100644 --- a/mesalib/src/mesa/program/prog_instruction.c +++ b/mesalib/src/mesa/program/prog_instruction.c @@ -200,9 +200,9 @@ static const struct instruction_info InstInfo[MAX_OPCODE] = { GLuint _mesa_num_inst_src_regs(gl_inst_opcode opcode) { - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + assert(opcode < MAX_OPCODE); + assert(opcode == InstInfo[opcode].Opcode); + assert(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); return InstInfo[opcode].NumSrcRegs; } @@ -213,9 +213,9 @@ _mesa_num_inst_src_regs(gl_inst_opcode opcode) GLuint _mesa_num_inst_dst_regs(gl_inst_opcode opcode) { - ASSERT(opcode < MAX_OPCODE); - ASSERT(opcode == InstInfo[opcode].Opcode); - ASSERT(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); + assert(opcode < MAX_OPCODE); + assert(opcode == InstInfo[opcode].Opcode); + assert(OPCODE_XPD == InstInfo[OPCODE_XPD].Opcode); return InstInfo[opcode].NumDstRegs; } diff --git a/mesalib/src/mesa/program/prog_optimize.c b/mesalib/src/mesa/program/prog_optimize.c index 65d427cb4..6d4485acb 100644 --- a/mesalib/src/mesa/program/prog_optimize.c +++ b/mesalib/src/mesa/program/prog_optimize.c @@ -57,7 +57,7 @@ get_src_arg_mask(const struct prog_instruction *inst, GLuint read_mask, channel_mask; GLuint comp; - ASSERT(arg < _mesa_num_inst_src_regs(inst->Opcode)); + assert(arg < _mesa_num_inst_src_regs(inst->Opcode)); /* Form the dst register, find the written channels */ if (inst->CondUpdate) { @@ -133,7 +133,7 @@ get_dst_mask_for_mov(const struct prog_instruction *mov, GLuint src_mask) GLuint comp; GLuint updated_mask = 0x0; - ASSERT(mov->Opcode == OPCODE_MOV); + assert(mov->Opcode == OPCODE_MOV); for (comp = 0; comp < 4; ++comp) { GLuint src_comp; @@ -225,13 +225,13 @@ replace_regs(struct gl_program *prog, gl_register_file file, const GLint map[]) for (j = 0; j < numSrc; j++) { if (inst->SrcReg[j].File == file) { GLuint index = inst->SrcReg[j].Index; - ASSERT(map[index] >= 0); + assert(map[index] >= 0); inst->SrcReg[j].Index = map[index]; } } if (inst->DstReg.File == file) { const GLuint index = inst->DstReg.Index; - ASSERT(map[index] >= 0); + assert(map[index] >= 0); inst->DstReg.Index = map[index]; } } @@ -272,7 +272,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog) if (inst->SrcReg[j].File == PROGRAM_TEMPORARY) { const GLuint index = inst->SrcReg[j].Index; GLuint read_mask; - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); + assert(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); read_mask = get_src_arg_mask(inst, j, NO_MASK); if (inst->SrcReg[j].RelAddr) { @@ -295,7 +295,7 @@ _mesa_remove_dead_code_global(struct gl_program *prog) /* check dst reg */ if (inst->DstReg.File == PROGRAM_TEMPORARY) { const GLuint index = inst->DstReg.Index; - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); + assert(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); if (inst->DstReg.RelAddr) { if (dbg) @@ -676,7 +676,7 @@ _mesa_merge_mov_into_inst(struct prog_instruction *inst, for (dst_comp = 0; dst_comp < 4; ++dst_comp) { if (mov->DstReg.WriteMask & (1 << dst_comp)) { const GLuint src_comp = GET_SWZ(mov->SrcReg[0].Swizzle, dst_comp); - ASSERT(src_comp < 4); + assert(src_comp < 4); dst_to_src_comp[dst_comp] = src_comp; } } @@ -692,9 +692,9 @@ _mesa_merge_mov_into_inst(struct prog_instruction *inst, if ((mov->DstReg.WriteMask & (1 << dst_comp)) == 0) continue; src_comp = dst_to_src_comp[dst_comp]; - ASSERT(src_comp < 4); + assert(src_comp < 4); arg_comp = GET_SWZ(arg_swz, src_comp); - ASSERT(arg_comp < 4); + assert(arg_comp < 4); inst->SrcReg[arg].Swizzle |= arg_comp << (3*dst_comp); } } @@ -871,7 +871,7 @@ insert_interval_by_end(struct interval_list *list, const struct interval *inv) { GLuint i; for (i = 0; i + 1 < list->Num; i++) { - ASSERT(list->Intervals[i].End <= list->Intervals[i + 1].End); + assert(list->Intervals[i].End <= list->Intervals[i + 1].End); } } #endif @@ -887,8 +887,8 @@ remove_interval(struct interval_list *list, const struct interval *inv) for (k = 0; k < list->Num; k++) { if (list->Intervals[k].Reg == inv->Reg) { /* found, remove it */ - ASSERT(list->Intervals[k].Start == inv->Start); - ASSERT(list->Intervals[k].End == inv->End); + assert(list->Intervals[k].Start == inv->Start); + assert(list->Intervals[k].End == inv->End); while (k < list->Num - 1) { list->Intervals[k] = list->Intervals[k + 1]; k++; @@ -924,7 +924,7 @@ sort_interval_list_by_start(struct interval_list *list) { GLuint i; for (i = 0; i + 1 < list->Num; i++) { - ASSERT(list->Intervals[i].Start <= list->Intervals[i + 1].Start); + assert(list->Intervals[i].Start <= list->Intervals[i + 1].Start); } } #endif @@ -966,9 +966,9 @@ update_interval(GLint intBegin[], GLint intEnd[], begin = loopStack[0].Start; } - ASSERT(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); + assert(index < REG_ALLOCATE_MAX_PROGRAM_TEMPS); if (intBegin[index] == -1) { - ASSERT(intEnd[index] == -1); + assert(intEnd[index] == -1); intBegin[index] = begin; intEnd[index] = end; } @@ -1176,7 +1176,7 @@ _mesa_reallocate_registers(struct gl_program *prog) else { /* Interval 'inv' has expired */ const GLint regNew = registerMap[inv->Reg]; - ASSERT(regNew >= 0); + assert(regNew >= 0); if (dbg) printf(" expire interval for reg %u\n", inv->Reg); @@ -1188,7 +1188,7 @@ _mesa_reallocate_registers(struct gl_program *prog) /* return register regNew to the free pool */ if (dbg) printf(" free reg %d\n", regNew); - ASSERT(usedRegs[regNew] == GL_TRUE); + assert(usedRegs[regNew] == GL_TRUE); usedRegs[regNew] = GL_FALSE; } } diff --git a/mesalib/src/mesa/program/prog_parameter.c b/mesalib/src/mesa/program/prog_parameter.c index 0ef46415d..5939f6f72 100644 --- a/mesalib/src/mesa/program/prog_parameter.c +++ b/mesalib/src/mesa/program/prog_parameter.c @@ -241,8 +241,8 @@ _mesa_add_typed_unnamed_constant(struct gl_program_parameter_list *paramList, GLenum datatype, GLuint *swizzleOut) { GLint pos; - ASSERT(size >= 1); - ASSERT(size <= 4); + assert(size >= 1); + assert(size <= 4); if (swizzleOut && _mesa_lookup_parameter_constant(paramList, values, @@ -528,7 +528,7 @@ _mesa_clone_parameter_list(const struct gl_program_parameter_list *list) GLuint size = MIN2(p->Size, 4); GLint j = _mesa_add_parameter(clone, p->Type, p->Name, size, p->DataType, list->ParameterValues[i], NULL); - ASSERT(j >= 0); + assert(j >= 0); pCopy = clone->Parameters + j; /* copy state indexes */ if (p->Type == PROGRAM_STATE_VAR) { diff --git a/mesalib/src/mesa/program/prog_parameter_layout.c b/mesalib/src/mesa/program/prog_parameter_layout.c index e83469059..282a367ad 100644 --- a/mesalib/src/mesa/program/prog_parameter_layout.c +++ b/mesalib/src/mesa/program/prog_parameter_layout.c @@ -28,7 +28,7 @@ * \author Ian Romanick <ian.d.romanick@intel.com> */ -#include "main/compiler.h" +#include "main/imports.h" #include "main/mtypes.h" #include "prog_parameter.h" #include "prog_parameter_layout.h" diff --git a/mesalib/src/mesa/program/prog_print.c b/mesalib/src/mesa/program/prog_print.c index 3f499749a..d588d07ff 100644 --- a/mesalib/src/mesa/program/prog_print.c +++ b/mesalib/src/mesa/program/prog_print.c @@ -182,20 +182,20 @@ arb_input_attrib_string(GLuint index, GLenum progType) }; /* sanity checks */ - STATIC_ASSERT(Elements(vertAttribs) == VERT_ATTRIB_MAX); - STATIC_ASSERT(Elements(fragAttribs) == VARYING_SLOT_MAX); + STATIC_ASSERT(ARRAY_SIZE(vertAttribs) == VERT_ATTRIB_MAX); + STATIC_ASSERT(ARRAY_SIZE(fragAttribs) == VARYING_SLOT_MAX); assert(strcmp(vertAttribs[VERT_ATTRIB_TEX0], "vertex.texcoord[0]") == 0); assert(strcmp(vertAttribs[VERT_ATTRIB_GENERIC15], "vertex.attrib[15]") == 0); assert(strcmp(fragAttribs[VARYING_SLOT_TEX0], "fragment.texcoord[0]") == 0); assert(strcmp(fragAttribs[VARYING_SLOT_VAR0+15], "fragment.varying[15]") == 0); if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertAttribs)); + assert(index < ARRAY_SIZE(vertAttribs)); return vertAttribs[index]; } else { assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragAttribs)); + assert(index < ARRAY_SIZE(fragAttribs)); return fragAttribs[index]; } } @@ -321,19 +321,19 @@ arb_output_attrib_string(GLuint index, GLenum progType) }; /* sanity checks */ - STATIC_ASSERT(Elements(vertResults) == VARYING_SLOT_MAX); - STATIC_ASSERT(Elements(fragResults) == FRAG_RESULT_MAX); + STATIC_ASSERT(ARRAY_SIZE(vertResults) == VARYING_SLOT_MAX); + STATIC_ASSERT(ARRAY_SIZE(fragResults) == FRAG_RESULT_MAX); assert(strcmp(vertResults[VARYING_SLOT_POS], "result.position") == 0); assert(strcmp(vertResults[VARYING_SLOT_VAR0], "result.varying[0]") == 0); assert(strcmp(fragResults[FRAG_RESULT_DATA0], "result.color[0]") == 0); if (progType == GL_VERTEX_PROGRAM_ARB) { - assert(index < Elements(vertResults)); + assert(index < ARRAY_SIZE(vertResults)); return vertResults[index]; } else { assert(progType == GL_FRAGMENT_PROGRAM_ARB); - assert(index < Elements(fragResults)); + assert(index < ARRAY_SIZE(fragResults)); return fragResults[index]; } } diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c index 7f5daf8c6..57b25a7e3 100644 --- a/mesalib/src/mesa/program/prog_statevars.c +++ b/mesalib/src/mesa/program/prog_statevars.c @@ -29,6 +29,7 @@ */ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/blend.h" @@ -41,6 +42,9 @@ #include "main/samplerobj.h" +#define ONE_DIV_SQRT_LN2 (1.201122408786449815) + + /** * Use the list of tokens in the state[] array to find global GL state * and return it in <value>. Usually, four values are returned in <value> @@ -58,9 +62,9 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], /* state[1] is either 0=front or 1=back side */ const GLuint face = (GLuint) state[1]; const struct gl_material *mat = &ctx->Light.Material; - ASSERT(face == 0 || face == 1); + assert(face == 0 || face == 1); /* we rely on tokens numbered so that _BACK_ == _FRONT_+ 1 */ - ASSERT(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT); + assert(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT); /* XXX we could get rid of this switch entirely with a little * work in arbprogparse.c's parse_state_single_item(). */ @@ -170,7 +174,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], const GLuint ln = (GLuint) state[1]; const GLuint face = (GLuint) state[2]; GLint i; - ASSERT(face == 0 || face == 1); + assert(face == 0 || face == 1); switch (state[3]) { case STATE_AMBIENT: for (i = 0; i < 3; i++) { @@ -295,8 +299,8 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], const gl_state_index modifier = state[4]; const GLfloat *m; GLuint row, i; - ASSERT(firstRow < 4); - ASSERT(lastRow < 4); + assert(firstRow < 4); + assert(lastRow < 4); if (mat == STATE_MODELVIEW_MATRIX) { matrix = ctx->ModelviewMatrixStack.Top; } @@ -307,11 +311,11 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], matrix = &ctx->_ModelProjectMatrix; } else if (mat == STATE_TEXTURE_MATRIX) { - ASSERT(index < Elements(ctx->TextureMatrixStack)); + assert(index < ARRAY_SIZE(ctx->TextureMatrixStack)); matrix = ctx->TextureMatrixStack[index].Top; } else if (mat == STATE_PROGRAM_MATRIX) { - ASSERT(index < Elements(ctx->ProgramMatrixStack)); + assert(index < ARRAY_SIZE(ctx->ProgramMatrixStack)); matrix = ctx->ProgramMatrixStack[index].Top; } else { diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c index 6e17fe65f..61a9e97c9 100644 --- a/mesalib/src/mesa/program/program.c +++ b/mesalib/src/mesa/program/program.c @@ -56,21 +56,21 @@ _mesa_init_program(struct gl_context *ctx) * If this assertion fails, we need to increase the field * size for register indexes (see INST_INDEX_BITS). */ - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4 + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents / 4 <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4 + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents / 4 <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTemps <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxLocalParams <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTemps <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxLocalParams <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents <= 4 * MAX_UNIFORMS); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents <= 4 * MAX_UNIFORMS); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents <= 4 * MAX_UNIFORMS); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents <= 4 * MAX_UNIFORMS); - ASSERT(ctx->Const.Program[MESA_SHADER_VERTEX].MaxAddressOffset <= (1 << INST_INDEX_BITS)); - ASSERT(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAddressOffset <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_VERTEX].MaxAddressOffset <= (1 << INST_INDEX_BITS)); + assert(ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAddressOffset <= (1 << INST_INDEX_BITS)); /* If this fails, increase prog_instruction::TexSrcUnit size */ STATIC_ASSERT(MAX_TEXTURE_UNITS <= (1 << 5)); @@ -364,8 +364,8 @@ void _mesa_delete_program(struct gl_context *ctx, struct gl_program *prog) { (void) ctx; - ASSERT(prog); - ASSERT(prog->RefCount==0); + assert(prog); + assert(prog->RefCount==0); if (prog == &_mesa_DummyProgram) return; @@ -414,12 +414,12 @@ _mesa_reference_program_(struct gl_context *ctx, if (*ptr && prog) { /* sanity check */ if ((*ptr)->Target == GL_VERTEX_PROGRAM_ARB) - ASSERT(prog->Target == GL_VERTEX_PROGRAM_ARB); + assert(prog->Target == GL_VERTEX_PROGRAM_ARB); else if ((*ptr)->Target == GL_FRAGMENT_PROGRAM_ARB) - ASSERT(prog->Target == GL_FRAGMENT_PROGRAM_ARB || + assert(prog->Target == GL_FRAGMENT_PROGRAM_ARB || prog->Target == GL_FRAGMENT_PROGRAM_NV); else if ((*ptr)->Target == MESA_GEOMETRY_PROGRAM) - ASSERT(prog->Target == MESA_GEOMETRY_PROGRAM); + assert(prog->Target == MESA_GEOMETRY_PROGRAM); } #endif @@ -434,14 +434,14 @@ _mesa_reference_program_(struct gl_context *ctx, ((*ptr)->Target == MESA_GEOMETRY_PROGRAM ? "GP" : "FP")), (*ptr)->RefCount - 1); #endif - ASSERT((*ptr)->RefCount > 0); + assert((*ptr)->RefCount > 0); (*ptr)->RefCount--; deleteFlag = ((*ptr)->RefCount == 0); /*mtx_lock(&(*ptr)->Mutex);*/ if (deleteFlag) { - ASSERT(ctx); + assert(ctx); ctx->Driver.DeleteProgram(ctx, *ptr); } @@ -733,7 +733,7 @@ _mesa_combine_programs(struct gl_context *ctx, GLbitfield64 inputsB; GLuint i; - ASSERT(progA->Target == progB->Target); + assert(progA->Target == progB->Target); newInst = _mesa_alloc_instructions(newLength); if (!newInst) @@ -867,14 +867,14 @@ _mesa_find_used_registers(const struct gl_program *prog, const GLuint n = _mesa_num_inst_src_regs(inst->Opcode); if (inst->DstReg.File == file) { - ASSERT(inst->DstReg.Index < usedSize); + assert(inst->DstReg.Index < usedSize); if(inst->DstReg.Index < usedSize) used[inst->DstReg.Index] = GL_TRUE; } for (j = 0; j < n; j++) { if (inst->SrcReg[j].File == file) { - ASSERT(inst->SrcReg[j].Index < (GLint) usedSize); + assert(inst->SrcReg[j].Index < (GLint) usedSize); if (inst->SrcReg[j].Index < (GLint) usedSize) used[inst->SrcReg[j].Index] = GL_TRUE; } diff --git a/mesalib/src/mesa/program/program.h b/mesalib/src/mesa/program/program.h index ef698242f..0b0d1ac6f 100644 --- a/mesalib/src/mesa/program/program.h +++ b/mesalib/src/mesa/program/program.h @@ -210,7 +210,7 @@ _mesa_program_enum_to_shader_stage(GLenum v) case GL_COMPUTE_PROGRAM_NV: return MESA_SHADER_COMPUTE; default: - ASSERT(0); + assert(0); return ~0; } } diff --git a/mesalib/src/mesa/program/program_parse.y b/mesalib/src/mesa/program/program_parse.y index 1664740b4..716b83d2d 100644 --- a/mesalib/src/mesa/program/program_parse.y +++ b/mesalib/src/mesa/program/program_parse.y @@ -21,6 +21,8 @@ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ + +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -2333,11 +2335,11 @@ set_dst_reg(struct prog_dst_register *r, gl_register_file file, GLint index) { const GLint maxIndex = 1 << INST_INDEX_BITS; const GLint minIndex = 0; - ASSERT(index >= minIndex); + assert(index >= minIndex); (void) minIndex; - ASSERT(index <= maxIndex); + assert(index <= maxIndex); (void) maxIndex; - ASSERT(file == PROGRAM_TEMPORARY || + assert(file == PROGRAM_TEMPORARY || file == PROGRAM_ADDRESS || file == PROGRAM_OUTPUT); memset(r, 0, sizeof(*r)); @@ -2375,10 +2377,10 @@ set_src_reg_swz(struct asm_src_register *r, gl_register_file file, GLint index, { const GLint maxIndex = (1 << INST_INDEX_BITS) - 1; const GLint minIndex = -(1 << INST_INDEX_BITS); - ASSERT(file < PROGRAM_FILE_MAX); - ASSERT(index >= minIndex); + assert(file < PROGRAM_FILE_MAX); + assert(index >= minIndex); (void) minIndex; - ASSERT(index <= maxIndex); + assert(index <= maxIndex); (void) maxIndex; memset(r, 0, sizeof(*r)); r->Base.File = file; diff --git a/mesalib/src/mesa/program/programopt.c b/mesalib/src/mesa/program/programopt.c index fdaa4a465..e82c68a53 100644 --- a/mesalib/src/mesa/program/programopt.c +++ b/mesalib/src/mesa/program/programopt.c @@ -335,7 +335,7 @@ _mesa_append_fog_code(struct gl_context *ctx, inst++; } else { - ASSERT(fog_mode == GL_EXP || fog_mode == GL_EXP2); + assert(fog_mode == GL_EXP || fog_mode == GL_EXP2); /* fogPRefOpt.z = d/ln(2), fogPRefOpt.w = d/sqrt(ln(2) */ /* EXP: MUL fogFactorTemp.x, fogPRefOpt.z, fragment.fogcoord.x; */ /* EXP2: MUL fogFactorTemp.x, fogPRefOpt.w, fragment.fogcoord.x; */ diff --git a/mesalib/src/mesa/program/sampler.cpp b/mesalib/src/mesa/program/sampler.cpp index f8584c968..ea3024d51 100644 --- a/mesalib/src/mesa/program/sampler.cpp +++ b/mesalib/src/mesa/program/sampler.cpp @@ -29,7 +29,6 @@ #include "../glsl/program.h" #include "ir_uniform.h" -#include "main/compiler.h" #include "main/mtypes.h" #include "program/hash_table.h" #include "program/prog_parameter.h" diff --git a/mesalib/src/mesa/state_tracker/st_atom.c b/mesalib/src/mesa/state_tracker/st_atom.c index 625ea2965..f0fe11ffa 100644 --- a/mesalib/src/mesa/state_tracker/st_atom.c +++ b/mesalib/src/mesa/state_tracker/st_atom.c @@ -26,6 +26,7 @@ **************************************************************************/ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" @@ -197,7 +198,7 @@ void st_validate_state( struct st_context *st ) memset(&examined, 0, sizeof(examined)); prev = *state; - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { const struct st_tracked_state *atom = atoms[i]; struct st_state_flags generated; @@ -228,7 +229,7 @@ void st_validate_state( struct st_context *st ) } else { - for (i = 0; i < Elements(atoms); i++) { + for (i = 0; i < ARRAY_SIZE(atoms); i++) { if (check_state(state, &atoms[i]->dirty)) atoms[i]->update( st ); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c index f24805cf5..1dbc4b905 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -104,9 +104,9 @@ st_bufferobj_subdata(struct gl_context *ctx, struct st_buffer_object *st_obj = st_buffer_object(obj); /* we may be called from VBO code, so double-check params here */ - ASSERT(offset >= 0); - ASSERT(size >= 0); - ASSERT(offset + size <= obj->Size); + assert(offset >= 0); + assert(size >= 0); + assert(offset + size <= obj->Size); if (!size) return; @@ -148,9 +148,9 @@ st_bufferobj_get_subdata(struct gl_context *ctx, struct st_buffer_object *st_obj = st_buffer_object(obj); /* we may be called from VBO code, so double-check params here */ - ASSERT(offset >= 0); - ASSERT(size >= 0); - ASSERT(offset + size <= obj->Size); + assert(offset >= 0); + assert(size >= 0); + assert(offset + size <= obj->Size); if (!size) return; diff --git a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h index a5ab12219..647efe4cc 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h +++ b/mesalib/src/mesa/state_tracker/st_cb_bufferobjects.h @@ -48,7 +48,7 @@ struct st_buffer_object /** cast wrapper */ -static INLINE struct st_buffer_object * +static inline struct st_buffer_object * st_buffer_object(struct gl_buffer_object *obj) { return (struct st_buffer_object *) obj; diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c index 45dea594e..dd81a6273 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_clear.c +++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c @@ -102,7 +102,7 @@ st_destroy_clear(struct st_context *st) /** * Helper function to set the fragment shaders. */ -static INLINE void +static inline void set_fragment_shader(struct st_context *st) { if (!st->clear.fs) @@ -118,7 +118,7 @@ set_fragment_shader(struct st_context *st) /** * Helper function to set the vertex shader. */ -static INLINE void +static inline void set_vertex_shader(struct st_context *st) { /* vertex shader - still required to provide the linkage between @@ -381,7 +381,7 @@ clear_with_quad(struct gl_context *ctx, unsigned clear_buffers) /** * Return if the scissor must be enabled during the clear. */ -static INLINE GLboolean +static inline GLboolean is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb) { return (ctx->Scissor.EnableFlags & 1) && @@ -395,7 +395,7 @@ is_scissor_enabled(struct gl_context *ctx, struct gl_renderbuffer *rb) /** * Return if all of the color channels are masked. */ -static INLINE GLboolean +static inline GLboolean is_color_disabled(struct gl_context *ctx, int i) { return !ctx->Color.ColorMask[i][0] && @@ -408,7 +408,7 @@ is_color_disabled(struct gl_context *ctx, int i) /** * Return if any of the color channels are masked. */ -static INLINE GLboolean +static inline GLboolean is_color_masked(struct gl_context *ctx, int i) { return !ctx->Color.ColorMask[i][0] || @@ -421,7 +421,7 @@ is_color_masked(struct gl_context *ctx, int i) /** * Return if all of the stencil bits are masked. */ -static INLINE GLboolean +static inline GLboolean is_stencil_disabled(struct gl_context *ctx, struct gl_renderbuffer *rb) { const GLuint stencilMax = 0xff; @@ -434,7 +434,7 @@ is_stencil_disabled(struct gl_context *ctx, struct gl_renderbuffer *rb) /** * Return if any of the stencil bits are masked. */ -static INLINE GLboolean +static inline GLboolean is_stencil_masked(struct gl_context *ctx, struct gl_renderbuffer *rb) { const GLuint stencilMax = 0xff; diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c index 14fc13952..3edf31bad 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c @@ -201,7 +201,7 @@ st_make_drawpix_z_stencil_program(struct st_context *st, GLuint ic = 0; const GLuint shaderIndex = write_depth * 2 + write_stencil; - assert(shaderIndex < Elements(st->drawpix.shaders)); + assert(shaderIndex < ARRAY_SIZE(st->drawpix.shaders)); if (st->drawpix.shaders[shaderIndex]) { /* already have the proper shader */ @@ -1684,7 +1684,7 @@ st_destroy_drawpix(struct st_context *st) { GLuint i; - for (i = 0; i < Elements(st->drawpix.shaders); i++) { + for (i = 0; i < ARRAY_SIZE(st->drawpix.shaders); i++) { if (st->drawpix.shaders[i]) _mesa_reference_fragprog(st->ctx, &st->drawpix.shaders[i], NULL); } diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.h b/mesalib/src/mesa/state_tracker/st_cb_fbo.h index ae13aa677..f3b310b07 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_fbo.h +++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.h @@ -65,7 +65,7 @@ struct st_renderbuffer }; -static INLINE struct st_renderbuffer * +static inline struct st_renderbuffer * st_renderbuffer(struct gl_renderbuffer *rb) { return (struct st_renderbuffer *) rb; diff --git a/mesalib/src/mesa/state_tracker/st_cb_feedback.c b/mesalib/src/mesa/state_tracker/st_cb_feedback.c index 6b504b8ab..c5410886a 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_feedback.c +++ b/mesalib/src/mesa/state_tracker/st_cb_feedback.c @@ -69,7 +69,7 @@ struct feedback_stage * GL Feedback functions **********************************************************************/ -static INLINE struct feedback_stage * +static inline struct feedback_stage * feedback_stage( struct draw_stage *stage ) { return (struct feedback_stage *)stage; diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c index 5544c6644..6df430049 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_flush.c +++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c @@ -47,7 +47,7 @@ /** Check if we have a front color buffer and if it's been drawn to. */ -static INLINE GLboolean +static inline GLboolean is_front_buffer_dirty(struct st_context *st) { struct gl_framebuffer *fb = st->ctx->DrawBuffer; diff --git a/mesalib/src/mesa/state_tracker/st_cb_program.c b/mesalib/src/mesa/state_tracker/st_cb_program.c index faff9c4bd..aa301d830 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_program.c +++ b/mesalib/src/mesa/state_tracker/st_cb_program.c @@ -143,11 +143,6 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog) if (stgp->glsl_to_tgsi) free_glsl_to_tgsi_visitor(stgp->glsl_to_tgsi); - - if (stgp->tgsi.tokens) { - st_free_tokens((void *) stgp->tgsi.tokens); - stgp->tgsi.tokens = NULL; - } } break; case GL_FRAGMENT_PROGRAM_ARB: @@ -207,11 +202,6 @@ st_program_string_notify( struct gl_context *ctx, st_release_gp_variants(st, stgp); - if (stgp->tgsi.tokens) { - st_free_tokens((void *) stgp->tgsi.tokens); - stgp->tgsi.tokens = NULL; - } - if (st->gp == stgp) st->dirty.st |= ST_NEW_GEOMETRY_PROGRAM; } diff --git a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h index e4c6c8643..24063211b 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_queryobj.h +++ b/mesalib/src/mesa/state_tracker/st_cb_queryobj.h @@ -49,7 +49,7 @@ struct st_query_object /** * Cast wrapper */ -static INLINE struct st_query_object * +static inline struct st_query_object * st_query_object(struct gl_query_object *q) { return (struct st_query_object *) q; diff --git a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c index 370746536..272cbb91d 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/mesalib/src/mesa/state_tracker/st_cb_rasterpos.c @@ -64,7 +64,7 @@ struct rastpos_stage }; -static INLINE struct rastpos_stage * +static inline struct rastpos_stage * rastpos_stage( struct draw_stage *stage ) { return (struct rastpos_stage *) stage; @@ -191,7 +191,7 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw) rs->stage.destroy = rastpos_destroy; rs->ctx = ctx; - for (i = 0; i < Elements(rs->array); i++) { + for (i = 0; i < ARRAY_SIZE(rs->array); i++) { rs->array[i].Size = 4; rs->array[i].Type = GL_FLOAT; rs->array[i].Format = GL_RGBA; diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c index 0525e879f..a8b19a1f3 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_texture.c +++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include <stdio.h> #include "main/bufferobj.h" #include "main/enums.h" #include "main/fbobject.h" diff --git a/mesalib/src/mesa/state_tracker/st_cb_viewport.c b/mesalib/src/mesa/state_tracker/st_cb_viewport.c index 2bd55f6d2..d7a34125e 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_viewport.c +++ b/mesalib/src/mesa/state_tracker/st_cb_viewport.c @@ -39,7 +39,7 @@ * We'll only return non-null for window system framebuffers. * Note that this function may fail. */ -static INLINE struct st_framebuffer * +static inline struct st_framebuffer * st_ws_framebuffer(struct gl_framebuffer *fb) { /* FBO cannot be casted. See st_new_framebuffer */ diff --git a/mesalib/src/mesa/state_tracker/st_cb_xformfb.c b/mesalib/src/mesa/state_tracker/st_cb_xformfb.c index a2bd86aff..07c118e22 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_xformfb.c +++ b/mesalib/src/mesa/state_tracker/st_cb_xformfb.c @@ -59,7 +59,7 @@ struct st_transform_feedback_object { struct pipe_stream_output_target *draw_count; }; -static INLINE struct st_transform_feedback_object * +static inline struct st_transform_feedback_object * st_transform_feedback_object(struct gl_transform_feedback_object *obj) { return (struct st_transform_feedback_object *) obj; @@ -95,7 +95,7 @@ st_delete_transform_feedback(struct gl_context *ctx, pipe_so_target_reference(&sobj->targets[i], NULL); } - for (i = 0; i < Elements(sobj->base.Buffers); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->base.Buffers); i++) { _mesa_reference_buffer_object(ctx, &sobj->base.Buffers[i], NULL); } @@ -115,8 +115,8 @@ st_begin_transform_feedback(struct gl_context *ctx, GLenum mode, unsigned i, max_num_targets; unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0}; - max_num_targets = MIN2(Elements(sobj->base.Buffers), - Elements(sobj->targets)); + max_num_targets = MIN2(ARRAY_SIZE(sobj->base.Buffers), + ARRAY_SIZE(sobj->targets)); /* Convert the transform feedback state into the gallium representation. */ for (i = 0; i < max_num_targets; i++) { @@ -185,7 +185,7 @@ st_transform_feedback_get_draw_target(struct gl_transform_feedback_object *obj) st_transform_feedback_object(obj); unsigned i; - for (i = 0; i < Elements(sobj->targets); i++) { + for (i = 0; i < ARRAY_SIZE(sobj->targets); i++) { if (sobj->targets[i]) { return sobj->targets[i]; } diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c index 5834ebad3..5fe132ac2 100644 --- a/mesalib/src/mesa/state_tracker/st_context.c +++ b/mesalib/src/mesa/state_tracker/st_context.c @@ -117,8 +117,8 @@ st_destroy_context_priv(struct st_context *st) st_destroy_drawpix(st); st_destroy_drawtex(st); - for (shader = 0; shader < Elements(st->state.sampler_views); shader++) { - for (i = 0; i < Elements(st->state.sampler_views[0]); i++) { + for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) { + for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) { pipe_sampler_view_release(st->pipe, &st->state.sampler_views[shader][i]); } @@ -200,7 +200,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, /* Vertex element objects used for drawing rectangles for glBitmap, * glDrawPixels, glClear, etc. */ - for (i = 0; i < Elements(st->velems_util_draw); i++) { + for (i = 0; i < ARRAY_SIZE(st->velems_util_draw); i++) { memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element)); st->velems_util_draw[i].src_offset = i * 4 * sizeof(float); st->velems_util_draw[i].instance_divisor = 0; diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index b091a8856..8a9504bb7 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -214,7 +214,7 @@ struct st_context /* Need this so that we can implement Mesa callbacks in this module. */ -static INLINE struct st_context *st_context(struct gl_context *ctx) +static inline struct st_context *st_context(struct gl_context *ctx) { return ctx->st; } @@ -246,7 +246,7 @@ void st_invalidate_state(struct gl_context * ctx, GLuint new_state); #define Y_0_TOP 1 #define Y_0_BOTTOM 2 -static INLINE GLuint +static inline GLuint st_fb_orientation(const struct gl_framebuffer *fb) { if (fb && _mesa_is_winsys_fbo(fb)) { diff --git a/mesalib/src/mesa/state_tracker/st_debug.h b/mesalib/src/mesa/state_tracker/st_debug.h index 49b916fb3..cc8197836 100644 --- a/mesalib/src/mesa/state_tracker/st_debug.h +++ b/mesalib/src/mesa/state_tracker/st_debug.h @@ -58,7 +58,7 @@ extern int ST_DEBUG; void st_debug_init( void ); -static INLINE void +static inline void ST_DBG( unsigned flag, const char *fmt, ... ) { if (ST_DEBUG & flag) diff --git a/mesalib/src/mesa/state_tracker/st_draw.h b/mesalib/src/mesa/state_tracker/st_draw.h index 361fe7f91..780d4bde7 100644 --- a/mesalib/src/mesa/state_tracker/st_draw.h +++ b/mesalib/src/mesa/state_tracker/st_draw.h @@ -76,7 +76,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, * This function is basically a cast wrapper to avoid warnings when building * in 64-bit mode. */ -static INLINE unsigned +static inline unsigned pointer_to_offset(const void *ptr) { return (unsigned) (((GLsizeiptr) ptr) & 0xffffffffUL); diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c index ce29d076c..bc20f7323 100644 --- a/mesalib/src/mesa/state_tracker/st_extensions.c +++ b/mesalib/src/mesa/state_tracker/st_extensions.c @@ -347,8 +347,8 @@ init_format_extensions(struct pipe_screen *screen, GLboolean *extension_table = (GLboolean *) extensions; unsigned i; int j; - int num_formats = Elements(mapping->format); - int num_ext = Elements(mapping->extension_offset); + int num_formats = ARRAY_SIZE(mapping->format); + int num_ext = ARRAY_SIZE(mapping->extension_offset); for (i = 0; i < num_mappings; i++) { int num_supported = 0; @@ -630,7 +630,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->OES_draw_texture = GL_TRUE; /* Expose the extensions which directly correspond to gallium caps. */ - for (i = 0; i < Elements(cap_mapping); i++) { + for (i = 0; i < ARRAY_SIZE(cap_mapping); i++) { if (screen->get_param(screen, cap_mapping[i].cap)) { extension_table[cap_mapping[i].extension_offset] = GL_TRUE; } @@ -638,16 +638,16 @@ void st_init_extensions(struct pipe_screen *screen, /* Expose the extensions which directly correspond to gallium formats. */ init_format_extensions(screen, extensions, rendertarget_mapping, - Elements(rendertarget_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D, PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, depthstencil_mapping, - Elements(depthstencil_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(depthstencil_mapping), PIPE_TEXTURE_2D, PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, texture_mapping, - Elements(texture_mapping), PIPE_TEXTURE_2D, + ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D, PIPE_BIND_SAMPLER_VIEW); init_format_extensions(screen, extensions, vertex_mapping, - Elements(vertex_mapping), PIPE_BUFFER, + ARRAY_SIZE(vertex_mapping), PIPE_BUFFER, PIPE_BIND_VERTEX_BUFFER); /* Figure out GLSL support. */ @@ -758,22 +758,22 @@ void st_init_extensions(struct pipe_screen *screen, }; consts->MaxSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, 16, PIPE_BIND_RENDER_TARGET); consts->MaxColorTextureSamples = - get_max_samples_for_formats(screen, Elements(color_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats), color_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxDepthTextureSamples = - get_max_samples_for_formats(screen, Elements(depth_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(depth_formats), depth_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); consts->MaxIntegerSamples = - get_max_samples_for_formats(screen, Elements(int_formats), + get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats), int_formats, consts->MaxSamples, PIPE_BIND_SAMPLER_VIEW); } @@ -831,7 +831,7 @@ void st_init_extensions(struct pipe_screen *screen, extensions->ARB_texture_buffer_range = GL_TRUE; init_format_extensions(screen, extensions, tbo_rgb32, - Elements(tbo_rgb32), PIPE_BUFFER, + ARRAY_SIZE(tbo_rgb32), PIPE_BUFFER, PIPE_BIND_SAMPLER_VIEW); } diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 7868bb501..72dbf3bd4 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -1855,7 +1855,7 @@ st_choose_format(struct st_context *st, GLenum internalFormat, return pf; /* search table for internalFormat */ - for (i = 0; i < Elements(format_map); i++) { + for (i = 0; i < ARRAY_SIZE(format_map); i++) { const struct format_mapping *mapping = &format_map[i]; for (j = 0; mapping->glFormats[j]; j++) { if (mapping->glFormats[j] == internalFormat) { diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 0b3477161..bd191d864 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -1497,7 +1497,7 @@ void glsl_to_tgsi_visitor::visit(ir_expression *ir) { unsigned int operand; - st_src_reg op[Elements(ir->operands)]; + st_src_reg op[ARRAY_SIZE(ir->operands)]; st_src_reg result_src; st_dst_reg result_dst; @@ -3515,7 +3515,7 @@ get_src_arg_mask(st_dst_reg dst, st_src_reg src) */ for (comp = 0; comp < 4; ++comp) { const unsigned coord = GET_SWZ(src.swizzle, comp); - ASSERT(coord < 4); + assert(coord < 4); if (dst.writemask & (1 << comp) && coord <= SWIZZLE_W) read_mask |= 1 << coord; } @@ -4022,7 +4022,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) /* Continuing the block, clear any channels from the write array that * are read by this instruction. */ - for (unsigned i = 0; i < Elements(inst->src); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->src); i++) { if (inst->src[i].file == PROGRAM_TEMPORARY && inst->src[i].reladdr){ /* Any temporary might be read, so no dead code elimination * across this instruction. @@ -4067,7 +4067,7 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) * If there is already an instruction in the write array for one or more * of the channels, flag that channel write as dead. */ - for (unsigned i = 0; i < Elements(inst->dst); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(inst->dst); i++) { if (inst->dst[i].file == PROGRAM_TEMPORARY && !inst->dst[i].reladdr && !inst->saturate) { @@ -4625,7 +4625,7 @@ dst_register(struct st_translate *t, case PROGRAM_ARRAY: array = index >> 16; - assert(array < Elements(t->arrays)); + assert(array < ARRAY_SIZE(t->arrays)); if (ureg_dst_is_undef(t->arrays[array])) t->arrays[array] = ureg_DECL_array_temporary( @@ -4642,7 +4642,7 @@ dst_register(struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -4659,7 +4659,7 @@ dst_register(struct st_translate *t, * Map a glsl_to_tgsi src register to a TGSI ureg_src register. */ static struct ureg_src -src_register(struct st_translate *t, const struct st_src_reg *reg) +src_register(struct st_translate *t, const st_src_reg *reg) { switch(reg->file) { case PROGRAM_UNDEFINED: @@ -4685,18 +4685,18 @@ src_register(struct st_translate *t, const struct st_src_reg *reg) return t->immediates[reg->index]; case PROGRAM_INPUT: - assert(t->inputMapping[reg->index] < Elements(t->inputs)); + assert(t->inputMapping[reg->index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[reg->index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[reg->index] < Elements(t->outputs)); + assert(t->outputMapping[reg->index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[reg->index]); case PROGRAM_SYSTEM_VALUE: - assert(reg->index < (int) Elements(t->systemValues)); + assert(reg->index < (int) ARRAY_SIZE(t->systemValues)); return t->systemValues[reg->index]; default: @@ -4824,7 +4824,7 @@ translate_tex_offset(struct st_translate *t, array = in_offset->index >> 16; assert(array >= 0); - assert(array < (int) Elements(t->arrays)); + assert(array < (int) ARRAY_SIZE(t->arrays)); dst = t->arrays[array]; offset.File = dst.File; @@ -5200,8 +5200,8 @@ st_translate_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_FRONT_FACE] == TGSI_SEMANTIC_FACE); diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c index 5411d84b0..840f76a13 100644 --- a/mesalib/src/mesa/state_tracker/st_manager.c +++ b/mesalib/src/mesa/state_tracker/st_manager.c @@ -61,7 +61,7 @@ * We'll only return non-null for window system framebuffers. * Note that this function may fail. */ -static INLINE struct st_framebuffer * +static inline struct st_framebuffer * st_ws_framebuffer(struct gl_framebuffer *fb) { /* FBO cannot be casted. See st_new_framebuffer */ @@ -73,7 +73,7 @@ st_ws_framebuffer(struct gl_framebuffer *fb) /** * Map an attachment to a buffer index. */ -static INLINE gl_buffer_index +static inline gl_buffer_index attachment_to_buffer_index(enum st_attachment_type statt) { gl_buffer_index index; @@ -109,7 +109,7 @@ attachment_to_buffer_index(enum st_attachment_type statt) /** * Map a buffer index to an attachment. */ -static INLINE enum st_attachment_type +static inline enum st_attachment_type buffer_index_to_attachment(gl_buffer_index index) { enum st_attachment_type statt; diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c index 3dd8a14b6..2f1016110 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -172,7 +172,7 @@ dst_register( struct st_translate *t, else assert(index < VARYING_SLOT_MAX); - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return t->outputs[t->outputMapping[index]]; @@ -200,7 +200,7 @@ src_register( struct st_translate *t, case PROGRAM_TEMPORARY: assert(index >= 0); - assert(index < Elements(t->temps)); + assert(index < ARRAY_SIZE(t->temps)); if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_temporary( t->ureg ); return ureg_src(t->temps[index]); @@ -216,18 +216,18 @@ src_register( struct st_translate *t, return t->constants[index]; case PROGRAM_INPUT: - assert(t->inputMapping[index] < Elements(t->inputs)); + assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs)); return t->inputs[t->inputMapping[index]]; case PROGRAM_OUTPUT: - assert(t->outputMapping[index] < Elements(t->outputs)); + assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs)); return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */ case PROGRAM_ADDRESS: return ureg_src(t->address[index]); case PROGRAM_SYSTEM_VALUE: - assert(index < Elements(t->systemValues)); + assert(index < ARRAY_SIZE(t->systemValues)); return t->systemValues[index]; default: @@ -1027,8 +1027,8 @@ st_translate_mesa_program( unsigned i; enum pipe_error ret = PIPE_OK; - assert(numInputs <= Elements(t->inputs)); - assert(numOutputs <= Elements(t->outputs)); + assert(numInputs <= ARRAY_SIZE(t->inputs)); + assert(numOutputs <= ARRAY_SIZE(t->outputs)); t = &translate; memset(t, 0, sizeof *t); @@ -1254,14 +1254,3 @@ out: return ret; } - - -/** - * Tokens cannot be free with free otherwise the builtin gallium - * malloc debugging will get confused. - */ -void -st_free_tokens(const struct tgsi_token *tokens) -{ - ureg_free_tokens(tokens); -} diff --git a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h index 1aa797a32..62bb654e9 100644 --- a/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h +++ b/mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.h @@ -62,9 +62,6 @@ st_translate_mesa_program( boolean passthrough_edgeflags, boolean clamp_color); -void -st_free_tokens(const struct tgsi_token *tokens); - unsigned st_translate_texture_target(GLuint textarget, GLboolean shadow); diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index 10a5f2900..4cfd817ce 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -69,7 +69,7 @@ delete_vp_variant(struct st_context *st, struct st_vp_variant *vpv) draw_delete_vertex_shader( st->draw, vpv->draw_shader ); if (vpv->tgsi.tokens) - st_free_tokens(vpv->tgsi.tokens); + ureg_free_tokens(vpv->tgsi.tokens); free( vpv ); } @@ -108,7 +108,7 @@ delete_fp_variant(struct st_context *st, struct st_fp_variant *fpv) if (fpv->parameters) _mesa_free_parameter_list(fpv->parameters); if (fpv->tgsi.tokens) - st_free_tokens(fpv->tgsi.tokens); + ureg_free_tokens(fpv->tgsi.tokens); free(fpv); } @@ -869,106 +869,79 @@ st_translate_geometry_program(struct st_context *st, GLuint outputMapping[VARYING_SLOT_MAX]; struct pipe_context *pipe = st->pipe; GLuint attr; - GLbitfield64 inputsRead; - GLuint vslot = 0; uint gs_num_inputs = 0; - uint gs_builtin_inputs = 0; - uint gs_array_offset = 0; + + ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; + ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; ubyte gs_output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; ubyte gs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; uint gs_num_outputs = 0; GLint i; - GLuint maxSlot = 0; struct ureg_program *ureg; - + struct pipe_shader_state state = {0}; struct st_gp_variant *gpv; gpv = CALLOC_STRUCT(st_gp_variant); if (!gpv) return NULL; - if (!stgp->glsl_to_tgsi) { - _mesa_remove_output_reads(&stgp->Base.Base, PROGRAM_OUTPUT); - } - - ureg = ureg_create( TGSI_PROCESSOR_GEOMETRY ); + ureg = ureg_create(TGSI_PROCESSOR_GEOMETRY); if (ureg == NULL) { free(gpv); return NULL; } - /* which vertex output goes to the first geometry input */ - vslot = 0; - memset(inputMapping, 0, sizeof(inputMapping)); memset(outputMapping, 0, sizeof(outputMapping)); /* * Convert Mesa program inputs to TGSI input register semantics. */ - inputsRead = stgp->Base.Base.InputsRead; for (attr = 0; attr < VARYING_SLOT_MAX; attr++) { - if ((inputsRead & BITFIELD64_BIT(attr)) != 0) { - const GLuint slot = gs_num_inputs; - - gs_num_inputs++; + if ((stgp->Base.Base.InputsRead & BITFIELD64_BIT(attr)) != 0) { + const GLuint slot = gs_num_inputs++; inputMapping[attr] = slot; - stgp->input_map[slot + gs_array_offset] = vslot - gs_builtin_inputs; - stgp->input_to_index[attr] = vslot; - stgp->index_to_input[vslot] = attr; - ++vslot; - - if (attr != VARYING_SLOT_PRIMITIVE_ID) { - gs_array_offset += 2; - } else - ++gs_builtin_inputs; - -#if 0 - debug_printf("input map at %d = %d\n", - slot + gs_array_offset, stgp->input_map[slot + gs_array_offset]); -#endif - switch (attr) { case VARYING_SLOT_PRIMITIVE_ID: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_POS: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_POSITION; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_COL0: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_COL1: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; - stgp->input_semantic_index[slot] = 1; + input_semantic_name[slot] = TGSI_SEMANTIC_COLOR; + input_semantic_index[slot] = 1; break; case VARYING_SLOT_FOGC: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_FOG; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_CLIP_VERTEX: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_CLIP_DIST0: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_CLIP_DIST1: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; - stgp->input_semantic_index[slot] = 1; + input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST; + input_semantic_index[slot] = 1; break; case VARYING_SLOT_PSIZ: - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; - stgp->input_semantic_index[slot] = 0; + input_semantic_name[slot] = TGSI_SEMANTIC_PSIZE; + input_semantic_index[slot] = 0; break; case VARYING_SLOT_TEX0: case VARYING_SLOT_TEX1: @@ -979,16 +952,16 @@ st_translate_geometry_program(struct st_context *st, case VARYING_SLOT_TEX6: case VARYING_SLOT_TEX7: if (st->needs_texcoord_semantic) { - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD; - stgp->input_semantic_index[slot] = attr - VARYING_SLOT_TEX0; + input_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD; + input_semantic_index[slot] = attr - VARYING_SLOT_TEX0; break; } /* fall through */ case VARYING_SLOT_VAR0: default: assert(attr >= VARYING_SLOT_VAR0 && attr < VARYING_SLOT_MAX); - stgp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; - stgp->input_semantic_index[slot] = + input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; + input_semantic_index[slot] = st_get_generic_varying_index(st, attr); break; } @@ -1007,10 +980,8 @@ st_translate_geometry_program(struct st_context *st, */ for (attr = 0; attr < VARYING_SLOT_MAX; attr++) { if (stgp->Base.Base.OutputsWritten & BITFIELD64_BIT(attr)) { - GLuint slot; + GLuint slot = gs_num_outputs++; - slot = gs_num_outputs; - gs_num_outputs++; outputMapping[attr] = slot; switch (attr) { @@ -1083,7 +1054,7 @@ st_translate_geometry_program(struct st_context *st, /* fall through */ case VARYING_SLOT_VAR0: default: - assert(slot < Elements(gs_output_semantic_name)); + assert(slot < ARRAY_SIZE(gs_output_semantic_name)); assert(attr >= VARYING_SLOT_VAR0); gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; gs_output_semantic_index[slot] = @@ -1093,93 +1064,38 @@ st_translate_geometry_program(struct st_context *st, } } - /* find max output slot referenced to compute gs_num_outputs */ - for (attr = 0; attr < VARYING_SLOT_MAX; attr++) { - if (outputMapping[attr] != ~0U && outputMapping[attr] > maxSlot) - maxSlot = outputMapping[attr]; - } - gs_num_outputs = maxSlot + 1; - -#if 0 /* debug */ - { - GLuint i; - printf("outputMapping? %d\n", outputMapping ? 1 : 0); - if (outputMapping) { - printf("attr -> slot\n"); - for (i = 0; i < 16; i++) { - printf(" %2d %3d\n", i, outputMapping[i]); - } - } - printf("slot sem_name sem_index\n"); - for (i = 0; i < gs_num_outputs; i++) { - printf(" %2d %d %d\n", - i, - gs_output_semantic_name[i], - gs_output_semantic_index[i]); - } - } -#endif - - /* free old shader state, if any */ - if (stgp->tgsi.tokens) { - st_free_tokens(stgp->tgsi.tokens); - stgp->tgsi.tokens = NULL; - } - ureg_property(ureg, TGSI_PROPERTY_GS_INPUT_PRIM, stgp->Base.InputType); ureg_property(ureg, TGSI_PROPERTY_GS_OUTPUT_PRIM, stgp->Base.OutputType); ureg_property(ureg, TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES, stgp->Base.VerticesOut); ureg_property(ureg, TGSI_PROPERTY_GS_INVOCATIONS, stgp->Base.Invocations); - if (stgp->glsl_to_tgsi) - st_translate_program(st->ctx, - TGSI_PROCESSOR_GEOMETRY, - ureg, - stgp->glsl_to_tgsi, - &stgp->Base.Base, - /* inputs */ - gs_num_inputs, - inputMapping, - stgp->input_semantic_name, - stgp->input_semantic_index, - NULL, - NULL, - /* outputs */ - gs_num_outputs, - outputMapping, - gs_output_semantic_name, - gs_output_semantic_index, - FALSE, - FALSE); - else - st_translate_mesa_program(st->ctx, - TGSI_PROCESSOR_GEOMETRY, - ureg, - &stgp->Base.Base, - /* inputs */ - gs_num_inputs, - inputMapping, - stgp->input_semantic_name, - stgp->input_semantic_index, - NULL, - /* outputs */ - gs_num_outputs, - outputMapping, - gs_output_semantic_name, - gs_output_semantic_index, - FALSE, - FALSE); - - stgp->num_inputs = gs_num_inputs; - stgp->tgsi.tokens = ureg_get_tokens( ureg, NULL ); - ureg_destroy( ureg ); - - if (stgp->glsl_to_tgsi) { - st_translate_stream_output_info(stgp->glsl_to_tgsi, - outputMapping, - &stgp->tgsi.stream_output); - } + st_translate_program(st->ctx, + TGSI_PROCESSOR_GEOMETRY, + ureg, + stgp->glsl_to_tgsi, + &stgp->Base.Base, + /* inputs */ + gs_num_inputs, + inputMapping, + input_semantic_name, + input_semantic_index, + NULL, + NULL, + /* outputs */ + gs_num_outputs, + outputMapping, + gs_output_semantic_name, + gs_output_semantic_index, + FALSE, + FALSE); + + state.tokens = ureg_get_tokens(ureg, NULL); + ureg_destroy(ureg); + + st_translate_stream_output_info(stgp->glsl_to_tgsi, + outputMapping, + &state.stream_output); if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { _mesa_print_program(&stgp->Base.Base); @@ -1187,13 +1103,15 @@ st_translate_geometry_program(struct st_context *st, } if (ST_DEBUG & DEBUG_TGSI) { - tgsi_dump(stgp->tgsi.tokens, 0); + tgsi_dump(state.tokens, 0); debug_printf("\n"); } /* fill in new variant */ - gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi); + gpv->driver_shader = pipe->create_gs_state(pipe, &state); gpv->key = *key; + + ureg_free_tokens(state.tokens); return gpv; } @@ -1229,51 +1147,6 @@ st_get_gp_variant(struct st_context *st, } - - -/** - * Debug- print current shader text - */ -void -st_print_shaders(struct gl_context *ctx) -{ - struct gl_shader_program **shProg = ctx->_Shader->CurrentProgram; - unsigned j; - - for (j = 0; j < 3; j++) { - unsigned i; - - if (shProg[j] == NULL) - continue; - - for (i = 0; i < shProg[j]->NumShaders; i++) { - struct gl_shader *sh; - - switch (shProg[j]->Shaders[i]->Type) { - case GL_VERTEX_SHADER: - sh = (i != 0) ? NULL : shProg[j]->Shaders[i]; - break; - case GL_GEOMETRY_SHADER_ARB: - sh = (i != 1) ? NULL : shProg[j]->Shaders[i]; - break; - case GL_FRAGMENT_SHADER: - sh = (i != 2) ? NULL : shProg[j]->Shaders[i]; - break; - default: - assert(0); - sh = NULL; - break; - } - - if (sh != NULL) { - printf("GLSL shader %u of %u:\n", i, shProg[j]->NumShaders); - printf("%s\n", sh->Source); - } - } - } -} - - /** * Vert/Geom/Frag programs have per-context variants. Free all the * variants attached to the given program which match the given context. @@ -1374,7 +1247,7 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData) destroy_program_variants(st, shProg->Shaders[i]->Program); } - for (i = 0; i < Elements(shProg->_LinkedShaders); i++) { + for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) { if (shProg->_LinkedShaders[i]) destroy_program_variants(st, shProg->_LinkedShaders[i]->Program); } diff --git a/mesalib/src/mesa/state_tracker/st_program.h b/mesalib/src/mesa/state_tracker/st_program.h index 870d0d57a..451d7bb6a 100644 --- a/mesalib/src/mesa/state_tracker/st_program.h +++ b/mesalib/src/mesa/state_tracker/st_program.h @@ -203,49 +203,31 @@ struct st_geometry_program struct gl_geometry_program Base; /**< The Mesa geometry program */ struct glsl_to_tgsi_visitor* glsl_to_tgsi; - /** map GP input back to VP output */ - GLuint input_map[PIPE_MAX_SHADER_INPUTS]; - - /** maps a Mesa VARYING_SLOT_x to a packed TGSI input index */ - GLuint input_to_index[VARYING_SLOT_MAX]; - /** maps a TGSI input index back to a Mesa VARYING_SLOT_x */ - GLuint index_to_input[PIPE_MAX_SHADER_INPUTS]; - - GLuint num_inputs; - - GLuint input_to_slot[VARYING_SLOT_MAX]; /**< Maps VARYING_SLOT_x to slot */ - GLuint num_input_slots; - - ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; - ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; - - struct pipe_shader_state tgsi; - struct st_gp_variant *variants; }; -static INLINE struct st_fragment_program * +static inline struct st_fragment_program * st_fragment_program( struct gl_fragment_program *fp ) { return (struct st_fragment_program *)fp; } -static INLINE struct st_vertex_program * +static inline struct st_vertex_program * st_vertex_program( struct gl_vertex_program *vp ) { return (struct st_vertex_program *)vp; } -static INLINE struct st_geometry_program * +static inline struct st_geometry_program * st_geometry_program( struct gl_geometry_program *gp ) { return (struct st_geometry_program *)gp; } -static INLINE void +static inline void st_reference_vertprog(struct st_context *st, struct st_vertex_program **ptr, struct st_vertex_program *prog) @@ -255,7 +237,7 @@ st_reference_vertprog(struct st_context *st, (struct gl_program *) prog); } -static INLINE void +static inline void st_reference_geomprog(struct st_context *st, struct st_geometry_program **ptr, struct st_geometry_program *prog) @@ -265,7 +247,7 @@ st_reference_geomprog(struct st_context *st, (struct gl_program *) prog); } -static INLINE void +static inline void st_reference_fragprog(struct st_context *st, struct st_fragment_program **ptr, struct st_fragment_program *prog) @@ -278,7 +260,7 @@ st_reference_fragprog(struct st_context *st, /** * This defines mapping from Mesa VARYING_SLOTs to TGSI GENERIC slots. */ -static INLINE unsigned +static inline unsigned st_get_generic_varying_index(struct st_context *st, GLuint attr) { if (attr >= VARYING_SLOT_VAR0) { @@ -340,10 +322,6 @@ extern void st_release_gp_variants(struct st_context *st, struct st_geometry_program *stgp); - -extern void -st_print_shaders(struct gl_context *ctx); - extern void st_destroy_program_variants(struct st_context *st); diff --git a/mesalib/src/mesa/state_tracker/st_texture.h b/mesalib/src/mesa/state_tracker/st_texture.h index 2f540295f..6b7f8c750 100644 --- a/mesalib/src/mesa/state_tracker/st_texture.h +++ b/mesalib/src/mesa/state_tracker/st_texture.h @@ -117,32 +117,32 @@ struct st_texture_object }; -static INLINE struct st_texture_image * +static inline struct st_texture_image * st_texture_image(struct gl_texture_image *img) { return (struct st_texture_image *) img; } -static INLINE const struct st_texture_image * +static inline const struct st_texture_image * st_texture_image_const(const struct gl_texture_image *img) { return (const struct st_texture_image *) img; } -static INLINE struct st_texture_object * +static inline struct st_texture_object * st_texture_object(struct gl_texture_object *obj) { return (struct st_texture_object *) obj; } -static INLINE const struct st_texture_object * +static inline const struct st_texture_object * st_texture_object_const(const struct gl_texture_object *obj) { return (const struct st_texture_object *) obj; } -static INLINE struct pipe_resource * +static inline struct pipe_resource * st_get_texobj_resource(struct gl_texture_object *texObj) { struct st_texture_object *stObj = st_texture_object(texObj); @@ -150,14 +150,14 @@ st_get_texobj_resource(struct gl_texture_object *texObj) } -static INLINE struct pipe_resource * +static inline struct pipe_resource * st_get_stobj_resource(struct st_texture_object *stObj) { return stObj ? stObj->pt : NULL; } -static INLINE struct pipe_sampler_view * +static inline struct pipe_sampler_view * st_create_texture_sampler_view_format(struct pipe_context *pipe, struct pipe_resource *texture, enum pipe_format format) @@ -169,7 +169,7 @@ st_create_texture_sampler_view_format(struct pipe_context *pipe, return pipe->create_sampler_view(pipe, texture, &templ); } -static INLINE struct pipe_sampler_view * +static inline struct pipe_sampler_view * st_create_texture_sampler_view(struct pipe_context *pipe, struct pipe_resource *texture) { diff --git a/mesalib/src/mesa/swrast/s_aaline.c b/mesalib/src/mesa/swrast/s_aaline.c index 6aea9d545..f3258e813 100644 --- a/mesalib/src/mesa/swrast/s_aaline.c +++ b/mesalib/src/mesa/swrast/s_aaline.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/imports.h" #include "main/macros.h" @@ -203,7 +204,7 @@ compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4], if (rho2 == 0.0F) return 0.0; else - return (GLfloat) (LOGF(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */ + return logf(rho2) * 1.442695f * 0.5f;/* 1.442695 = 1/log(2) */ } @@ -477,7 +478,7 @@ _swrast_choose_aa_line_function(struct gl_context *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - ASSERT(ctx->Line.SmoothFlag); + assert(ctx->Line.SmoothFlag); if (ctx->Texture._EnabledCoordUnits != 0 || _swrast_use_fragment_program(ctx) diff --git a/mesalib/src/mesa/swrast/s_aatriangle.c b/mesalib/src/mesa/swrast/s_aatriangle.c index 219282748..1d076cc7d 100644 --- a/mesalib/src/mesa/swrast/s_aatriangle.c +++ b/mesalib/src/mesa/swrast/s_aatriangle.c @@ -102,7 +102,7 @@ do { \ static inline GLfloat solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4]) { - ASSERT(plane[2] != 0.0F); + assert(plane[2] != 0.0F); return (plane[3] + plane[0] * x + plane[1] * y) / -plane[2]; } @@ -201,7 +201,7 @@ compute_coveragef(const GLfloat v0[3], const GLfloat v1[3], GLint stop = 4, i; GLfloat insideCount = 16.0F; - ASSERT(dx0 * dy1 - dx1 * dy0 >= 0.0); /* area >= 0.0 */ + assert(dx0 * dy1 - dx1 * dy0 >= 0.0); /* area >= 0.0 */ for (i = 0; i < stop; i++) { const GLfloat sx = x + samples[i][0]; @@ -282,7 +282,7 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx) { SWcontext *swrast = SWRAST_CONTEXT(ctx); - ASSERT(ctx->Polygon.SmoothFlag); + assert(ctx->Polygon.SmoothFlag); if (ctx->Texture._EnabledCoordUnits != 0 || _swrast_use_fragment_program(ctx) @@ -294,5 +294,5 @@ _swrast_set_aa_triangle_function(struct gl_context *ctx) SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri; } - ASSERT(SWRAST_CONTEXT(ctx)->Triangle); + assert(SWRAST_CONTEXT(ctx)->Triangle); } diff --git a/mesalib/src/mesa/swrast/s_aatritemp.h b/mesalib/src/mesa/swrast/s_aatritemp.h index fd374a524..230dab816 100644 --- a/mesalib/src/mesa/swrast/s_aatritemp.h +++ b/mesalib/src/mesa/swrast/s_aatritemp.h @@ -284,7 +284,7 @@ /* (cx,cy) = center of fragment */ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F; SWspanarrays *array = span.array; - ASSERT(ix >= 0); + assert(ix >= 0); array->coverage[ix] = coverage; #ifdef DO_Z array->z[ix] = (GLuint) solve_plane(cx, cy, zPlane); diff --git a/mesalib/src/mesa/swrast/s_alpha.c b/mesalib/src/mesa/swrast/s_alpha.c index fba143a52..b1a7ff132 100644 --- a/mesalib/src/mesa/swrast/s_alpha.c +++ b/mesalib/src/mesa/swrast/s_alpha.c @@ -130,7 +130,7 @@ _swrast_alpha_test(const struct gl_context *ctx, SWspan *span) } else { /* Interpolate alpha values */ - ASSERT(span->interpMask & SPAN_RGBA); + assert(span->interpMask & SPAN_RGBA); if (span->array->ChanType == GL_UNSIGNED_BYTE) { const GLfixed alphaStep = span->alphaStep; GLfixed alpha = span->alpha; diff --git a/mesalib/src/mesa/swrast/s_atifragshader.c b/mesalib/src/mesa/swrast/s_atifragshader.c index 1e91e2bee..0bf03771f 100644 --- a/mesalib/src/mesa/swrast/s_atifragshader.c +++ b/mesalib/src/mesa/swrast/s_atifragshader.c @@ -571,7 +571,7 @@ _swrast_exec_fragment_shader(struct gl_context * ctx, SWspan *span) GLuint i; /* incoming colors should be floats */ - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); for (i = 0; i < span->end; i++) { if (span->array->mask[i]) { diff --git a/mesalib/src/mesa/swrast/s_bitmap.c b/mesalib/src/mesa/swrast/s_bitmap.c index e364ec129..324daea36 100644 --- a/mesalib/src/mesa/swrast/s_bitmap.c +++ b/mesalib/src/mesa/swrast/s_bitmap.c @@ -55,7 +55,7 @@ _swrast_Bitmap( struct gl_context *ctx, GLint px, GLint py, GLuint count = 0; SWspan span; - ASSERT(ctx->RenderMode == GL_RENDER); + assert(ctx->RenderMode == GL_RENDER); if (!_mesa_check_conditional_render(ctx)) return; /* don't draw */ @@ -154,8 +154,8 @@ _swrast_Bitmap( struct gl_context *ctx, GLint px, GLint py, GLint row, col; SWspan span; - ASSERT(ctx->RenderMode == GL_RENDER); - ASSERT(bitmap); + assert(ctx->RenderMode == GL_RENDER); + assert(bitmap); swrast_render_start(ctx); diff --git a/mesalib/src/mesa/swrast/s_blend.c b/mesalib/src/mesa/swrast/s_blend.c index 1037b6236..7cb119407 100644 --- a/mesalib/src/mesa/swrast/s_blend.c +++ b/mesalib/src/mesa/swrast/s_blend.c @@ -75,10 +75,10 @@ blend_noop(struct gl_context *ctx, GLuint n, const GLubyte mask[], { GLint bytes; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ZERO); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_ZERO); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE); (void) ctx; /* just memcpy */ @@ -101,10 +101,10 @@ static void _BLENDAPI blend_replace(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ONE); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ZERO); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_ONE); + assert(ctx->Color.Blend[0].DstRGB == GL_ZERO); (void) ctx; (void) n; (void) mask; @@ -125,13 +125,13 @@ blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[], const GLubyte (*dest)[4] = (const GLubyte (*)[4]) dst; GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_UNSIGNED_BYTE); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); + assert(chanType == GL_UNSIGNED_BYTE); (void) ctx; @@ -148,10 +148,10 @@ blend_transparency_ubyte(struct gl_context *ctx, GLuint n, const GLubyte mask[], const GLint g = DIV255((rgba[i][GCOMP] - dest[i][GCOMP]) * t) + dest[i][GCOMP]; const GLint b = DIV255((rgba[i][BCOMP] - dest[i][BCOMP]) * t) + dest[i][BCOMP]; const GLint a = DIV255((rgba[i][ACOMP] - dest[i][ACOMP]) * t) + dest[i][ACOMP]; - ASSERT(r <= 255); - ASSERT(g <= 255); - ASSERT(b <= 255); - ASSERT(a <= 255); + assert(r <= 255); + assert(g <= 255); + assert(b <= 255); + assert(a <= 255); rgba[i][RCOMP] = (GLubyte) r; rgba[i][GCOMP] = (GLubyte) g; rgba[i][BCOMP] = (GLubyte) b; @@ -170,13 +170,13 @@ blend_transparency_ushort(struct gl_context *ctx, GLuint n, const GLubyte mask[] const GLushort (*dest)[4] = (const GLushort (*)[4]) dst; GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_UNSIGNED_SHORT); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); + assert(chanType == GL_UNSIGNED_SHORT); (void) ctx; @@ -208,13 +208,13 @@ blend_transparency_float(struct gl_context *ctx, GLuint n, const GLubyte mask[], const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); - ASSERT(chanType == GL_FLOAT); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].SrcA == GL_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE_MINUS_SRC_ALPHA); + assert(ctx->Color.Blend[0].DstA == GL_ONE_MINUS_SRC_ALPHA); + assert(chanType == GL_FLOAT); (void) ctx; @@ -248,10 +248,10 @@ blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[], { GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); - ASSERT(ctx->Color.Blend[0].SrcRGB == GL_ONE); - ASSERT(ctx->Color.Blend[0].DstRGB == GL_ONE); + assert(ctx->Color.Blend[0].EquationRGB == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].EquationA == GL_FUNC_ADD); + assert(ctx->Color.Blend[0].SrcRGB == GL_ONE); + assert(ctx->Color.Blend[0].DstRGB == GL_ONE); (void) ctx; if (chanType == GL_UNSIGNED_BYTE) { @@ -289,7 +289,7 @@ blend_add(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { /* don't RGB clamp to max */ @@ -313,8 +313,8 @@ blend_min(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_MIN); - ASSERT(ctx->Color.Blend[0].EquationA == GL_MIN); + assert(ctx->Color.Blend[0].EquationRGB == GL_MIN); + assert(ctx->Color.Blend[0].EquationA == GL_MIN); (void) ctx; if (chanType == GL_UNSIGNED_BYTE) { @@ -344,7 +344,7 @@ blend_min(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { rgba[i][RCOMP] = MIN2( rgba[i][RCOMP], dest[i][RCOMP] ); @@ -366,8 +366,8 @@ blend_max(struct gl_context *ctx, GLuint n, const GLubyte mask[], GLvoid *src, const GLvoid *dst, GLenum chanType) { GLuint i; - ASSERT(ctx->Color.Blend[0].EquationRGB == GL_MAX); - ASSERT(ctx->Color.Blend[0].EquationA == GL_MAX); + assert(ctx->Color.Blend[0].EquationRGB == GL_MAX); + assert(ctx->Color.Blend[0].EquationA == GL_MAX); (void) ctx; if (chanType == GL_UNSIGNED_BYTE) { @@ -397,7 +397,7 @@ blend_max(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { rgba[i][RCOMP] = MAX2( rgba[i][RCOMP], dest[i][RCOMP] ); @@ -450,7 +450,7 @@ blend_modulate(struct gl_context *ctx, GLuint n, const GLubyte mask[], else { GLfloat (*rgba)[4] = (GLfloat (*)[4]) src; const GLfloat (*dest)[4] = (const GLfloat (*)[4]) dst; - ASSERT(chanType == GL_FLOAT); + assert(chanType == GL_FLOAT); for (i=0;i<n;i++) { if (mask[i]) { rgba[i][RCOMP] = rgba[i][RCOMP] * dest[i][RCOMP]; @@ -998,9 +998,9 @@ _swrast_blend_span(struct gl_context *ctx, struct gl_renderbuffer *rb, SWspan *s SWcontext *swrast = SWRAST_CONTEXT(ctx); void *rbPixels; - ASSERT(span->end <= SWRAST_MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); - ASSERT(!ctx->Color.ColorLogicOpEnabled); + assert(span->end <= SWRAST_MAX_WIDTH); + assert(span->arrayMask & SPAN_RGBA); + assert(!ctx->Color.ColorLogicOpEnabled); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_blit.c b/mesalib/src/mesa/swrast/s_blit.c index 16e5b8c1c..3e838a41d 100644 --- a/mesalib/src/mesa/swrast/s_blit.c +++ b/mesalib/src/mesa/swrast/s_blit.c @@ -52,8 +52,8 @@ NAME(GLint srcWidth, GLint dstWidth, \ if (flip) { \ for (dstCol = 0; dstCol < dstWidth; dstCol++) { \ GLint srcCol = (dstCol * srcWidth) / dstWidth; \ - ASSERT(srcCol >= 0); \ - ASSERT(srcCol < srcWidth); \ + assert(srcCol >= 0); \ + assert(srcCol < srcWidth); \ srcCol = srcWidth - 1 - srcCol; /* flip */ \ if (SIZE == 1) { \ dst[dstCol] = src[srcCol]; \ @@ -73,8 +73,8 @@ NAME(GLint srcWidth, GLint dstWidth, \ else { \ for (dstCol = 0; dstCol < dstWidth; dstCol++) { \ GLint srcCol = (dstCol * srcWidth) / dstWidth; \ - ASSERT(srcCol >= 0); \ - ASSERT(srcCol < srcWidth); \ + assert(srcCol >= 0); \ + assert(srcCol < srcWidth); \ if (SIZE == 1) { \ dst[dstCol] = src[srcCol]; \ } \ @@ -299,8 +299,8 @@ blit_nearest(struct gl_context *ctx, GLint srcRow = IROUND(srcRowF); GLubyte *dstRowStart = dstMap + dstRowStride * dstRow; - ASSERT(srcRow >= 0); - ASSERT(srcRow < srcHeight); + assert(srcRow >= 0); + assert(srcRow < srcHeight); if (invertY) { srcRow = srcHeight - 1 - srcRow; @@ -412,8 +412,8 @@ resample_linear_row_ub(GLint srcWidth, GLint dstWidth, GLfloat colWeight = srcCol - srcCol0; /* fractional part of srcCol */ GLfloat red, green, blue, alpha; - ASSERT(srcCol0 < srcWidth); - ASSERT(srcCol1 <= srcWidth); + assert(srcCol0 < srcWidth); + assert(srcCol1 <= srcWidth); if (srcCol1 == srcWidth) { /* last column fudge */ @@ -467,8 +467,8 @@ resample_linear_row_float(GLint srcWidth, GLint dstWidth, GLfloat colWeight = srcCol - srcCol0; /* fractional part of srcCol */ GLfloat red, green, blue, alpha; - ASSERT(srcCol0 < srcWidth); - ASSERT(srcCol1 <= srcWidth); + assert(srcCol0 < srcWidth); + assert(srcCol1 <= srcWidth); if (srcCol1 == srcWidth) { /* last column fudge */ @@ -801,7 +801,7 @@ _swrast_BlitFramebuffer(struct gl_context *ctx, } } else { - ASSERT(filter == GL_LINEAR); + assert(filter == GL_LINEAR); if (mask & GL_COLOR_BUFFER_BIT) { /* depth/stencil not allowed */ blit_linear(ctx, readFb, drawFb, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1); diff --git a/mesalib/src/mesa/swrast/s_context.c b/mesalib/src/mesa/swrast/s_context.c index ad11aa2c1..51cc22760 100644 --- a/mesalib/src/mesa/swrast/s_context.c +++ b/mesalib/src/mesa/swrast/s_context.c @@ -251,6 +251,7 @@ _swrast_update_fog_state( struct gl_context *ctx ) const struct gl_fragment_program *fp = ctx->FragmentProgram._Current; assert(fp == NULL || fp->Base.Target == GL_FRAGMENT_PROGRAM_ARB); + (void) fp; /* silence unused var warning */ /* determine if fog is needed, and if so, which fog mode */ swrast->_FogEnabled = (!_swrast_use_fragment_program(ctx) && @@ -351,7 +352,7 @@ _swrast_validate_triangle( struct gl_context *ctx, _swrast_validate_derived( ctx ); swrast->choose_triangle( ctx ); - ASSERT(swrast->Triangle); + assert(swrast->Triangle); if (swrast->SpecularVertexAdd) { /* separate specular color, but no texture */ @@ -373,7 +374,7 @@ _swrast_validate_line( struct gl_context *ctx, const SWvertex *v0, const SWverte _swrast_validate_derived( ctx ); swrast->choose_line( ctx ); - ASSERT(swrast->Line); + assert(swrast->Line); if (swrast->SpecularVertexAdd) { swrast->SpecLine = swrast->Line; diff --git a/mesalib/src/mesa/swrast/s_copypix.c b/mesalib/src/mesa/swrast/s_copypix.c index e21c69dbc..17140ad2d 100644 --- a/mesalib/src/mesa/swrast/s_copypix.c +++ b/mesalib/src/mesa/swrast/s_copypix.c @@ -158,7 +158,7 @@ copy_rgba_pixels(struct gl_context *ctx, GLint srcx, GLint srcy, p = NULL; } - ASSERT(width < SWRAST_MAX_WIDTH); + assert(width < SWRAST_MAX_WIDTH); for (row = 0; row < height; row++, sy += stepy, dy += stepy) { GLvoid *rgba = span.array->attribs[VARYING_SLOT_COL0]; @@ -468,7 +468,7 @@ swrast_fast_copy_pixels(struct gl_context *ctx, dstRb = dstFb->Attachment[BUFFER_DEPTH].Renderbuffer; } else { - ASSERT(type == GL_DEPTH_STENCIL_EXT); + assert(type == GL_DEPTH_STENCIL_EXT); /* XXX correct? */ srcRb = srcFb->Attachment[BUFFER_DEPTH].Renderbuffer; dstRb = dstFb->Attachment[BUFFER_DEPTH].Renderbuffer; diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c index c99251904..bf427266c 100644 --- a/mesalib/src/mesa/swrast/s_drawpix.c +++ b/mesalib/src/mesa/swrast/s_drawpix.c @@ -373,7 +373,7 @@ draw_depth_pixels( struct gl_context *ctx, GLint x, GLint y, while (skipPixels < width) { const GLint spanWidth = MIN2(width - skipPixels, SWRAST_MAX_WIDTH); GLint row; - ASSERT(span.end <= SWRAST_MAX_WIDTH); + assert(span.end <= SWRAST_MAX_WIDTH); for (row = 0; row < height; row++) { const GLvoid *zSrc = _mesa_image_address2d(unpack, pixels, width, height, @@ -595,8 +595,8 @@ draw_depth_stencil_pixels(struct gl_context *ctx, GLint x, GLint y, depthRb = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; stencilRb = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer; - ASSERT(depthRb); - ASSERT(stencilRb); + assert(depthRb); + assert(stencilRb); if (depthRb == stencilRb && (depthRb->Format == MESA_FORMAT_S8_UINT_Z24_UNORM || diff --git a/mesalib/src/mesa/swrast/s_fog.c b/mesalib/src/mesa/swrast/s_fog.c index 34b7c2d28..e270b7e24 100644 --- a/mesalib/src/mesa/swrast/s_fog.c +++ b/mesalib/src/mesa/swrast/s_fog.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" @@ -49,12 +50,12 @@ _swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z) return CLAMP(f, 0.0F, 1.0F); case GL_EXP: d = ctx->Fog.Density; - f = EXPF(-d * z); + f = expf(-d * z); f = CLAMP(f, 0.0F, 1.0F); return f; case GL_EXP2: d = ctx->Fog.Density; - f = EXPF(-(d * d * z * z)); + f = expf(-(d * d * z * z)); f = CLAMP(f, 0.0F, 1.0F); return f; default: @@ -66,14 +67,14 @@ _swrast_z_to_fogfactor(struct gl_context *ctx, GLfloat z) #define LINEAR_FOG(f, coord) f = (fogEnd - coord) * fogScale -#define EXP_FOG(f, coord) f = EXPF(density * coord) +#define EXP_FOG(f, coord) f = expf(density * coord) #define EXP2_FOG(f, coord) \ do { \ GLfloat tmp = negDensitySquared * coord * coord; \ if (tmp < FLT_MIN_10_EXP) \ tmp = FLT_MIN_10_EXP; \ - f = EXPF(tmp); \ + f = expf(tmp); \ } while(0) @@ -91,7 +92,7 @@ if (span->arrayAttribs & VARYING_BIT_FOGC) { \ GLuint i; \ for (i = 0; i < span->end; i++) { \ const GLfloat fogCoord = span->array->attribs[VARYING_SLOT_FOGC][i][0]; \ - const GLfloat c = FABSF(fogCoord); \ + const GLfloat c = fabsf(fogCoord); \ GLfloat f, oneMinusF; \ FOG_FUNC(f, c); \ f = CLAMP(f, 0.0F, 1.0F); \ @@ -108,7 +109,7 @@ else { \ GLfloat w = span->attrStart[VARYING_SLOT_POS][3]; \ GLuint i; \ for (i = 0; i < span->end; i++) { \ - const GLfloat c = FABSF(fogCoord) / w; \ + const GLfloat c = fabsf(fogCoord) / w; \ GLfloat f, oneMinusF; \ FOG_FUNC(f, c); \ f = CLAMP(f, 0.0F, 1.0F); \ @@ -134,8 +135,8 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) const SWcontext *swrast = CONST_SWRAST_CONTEXT(ctx); GLfloat rFog, gFog, bFog; - ASSERT(swrast->_FogEnabled); - ASSERT(span->arrayMask & SPAN_RGBA); + assert(swrast->_FogEnabled); + assert(span->arrayMask & SPAN_RGBA); /* compute (scaled) fog color */ if (span->array->ChanType == GL_UNSIGNED_BYTE) { @@ -174,7 +175,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, LINEAR_FOG); } } @@ -193,7 +194,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, EXP_FOG); } } @@ -212,7 +213,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, EXP2_FOG); } } @@ -237,7 +238,7 @@ _swrast_fog_rgba_span( const struct gl_context *ctx, SWspan *span ) } else { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); FOG_LOOP(GLfloat, BLEND_FOG); } } diff --git a/mesalib/src/mesa/swrast/s_fragprog.c b/mesalib/src/mesa/swrast/s_fragprog.c index 1d7c33619..12bcda311 100644 --- a/mesalib/src/mesa/swrast/s_fragprog.c +++ b/mesalib/src/mesa/swrast/s_fragprog.c @@ -273,7 +273,7 @@ _swrast_exec_fragment_program( struct gl_context *ctx, SWspan *span ) /* incoming colors should be floats */ if (program->Base.InputsRead & VARYING_BIT_COL0) { - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); } run_program(ctx, span, 0, span->end); diff --git a/mesalib/src/mesa/swrast/s_lines.c b/mesalib/src/mesa/swrast/s_lines.c index b63296aa4..3e626b9e0 100644 --- a/mesalib/src/mesa/swrast/s_lines.c +++ b/mesalib/src/mesa/swrast/s_lines.c @@ -67,7 +67,7 @@ draw_wide_line( struct gl_context *ctx, SWspan *span, GLboolean xMajor ) ctx->Const.MaxLineWidth); GLint start; - ASSERT(span->end < SWRAST_MAX_WIDTH); + assert(span->end < SWRAST_MAX_WIDTH); if (width & 1) start = width / 2; @@ -233,7 +233,7 @@ _swrast_choose_line( struct gl_context *ctx ) if (ctx->Line.SmoothFlag) { /* antialiased lines */ _swrast_choose_aa_line_function(ctx); - ASSERT(swrast->Line); + assert(swrast->Line); } else if (ctx->Texture._EnabledCoordUnits || _swrast_use_fragment_program(ctx) @@ -252,8 +252,8 @@ _swrast_choose_line( struct gl_context *ctx ) #endif } else { - ASSERT(!ctx->Depth.Test); - ASSERT(ctx->Line.Width == 1.0); + assert(!ctx->Depth.Test); + assert(ctx->Line.Width == 1.0); /* simple lines */ USE(simple_no_z_rgba_line); } @@ -262,7 +262,7 @@ _swrast_choose_line( struct gl_context *ctx ) USE(_swrast_feedback_line); } else { - ASSERT(ctx->RenderMode == GL_SELECT); + assert(ctx->RenderMode == GL_SELECT); USE(_swrast_select_line); } } diff --git a/mesalib/src/mesa/swrast/s_linetemp.h b/mesalib/src/mesa/swrast/s_linetemp.h index 7b1eac36a..352c88428 100644 --- a/mesalib/src/mesa/swrast/s_linetemp.h +++ b/mesalib/src/mesa/swrast/s_linetemp.h @@ -212,8 +212,8 @@ NAME( struct gl_context *ctx, const SWvertex *vert0, const SWvertex *vert1 ) #endif } - ASSERT(dx >= 0); - ASSERT(dy >= 0); + assert(dx >= 0); + assert(dy >= 0); numPixels = MAX2(dx, dy); diff --git a/mesalib/src/mesa/swrast/s_logic.c b/mesalib/src/mesa/swrast/s_logic.c index f68273fd2..c7cac2e40 100644 --- a/mesalib/src/mesa/swrast/s_logic.c +++ b/mesalib/src/mesa/swrast/s_logic.c @@ -193,8 +193,8 @@ _swrast_logicop_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, { void *rbPixels; - ASSERT(span->end < SWRAST_MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->end < SWRAST_MAX_WIDTH); + assert(span->arrayMask & SPAN_RGBA); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_masking.c b/mesalib/src/mesa/swrast/s_masking.c index c3aa41891..c95587b20 100644 --- a/mesalib/src/mesa/swrast/s_masking.c +++ b/mesalib/src/mesa/swrast/s_masking.c @@ -46,8 +46,8 @@ _swrast_mask_rgba_span(struct gl_context *ctx, struct gl_renderbuffer *rb, const GLuint n = span->end; void *rbPixels; - ASSERT(n < SWRAST_MAX_WIDTH); - ASSERT(span->arrayMask & SPAN_RGBA); + assert(n < SWRAST_MAX_WIDTH); + assert(span->arrayMask & SPAN_RGBA); rbPixels = _swrast_get_dest_rgba(ctx, rb, span); diff --git a/mesalib/src/mesa/swrast/s_points.c b/mesalib/src/mesa/swrast/s_points.c index b9bec237e..8180483ba 100644 --- a/mesalib/src/mesa/swrast/s_points.c +++ b/mesalib/src/mesa/swrast/s_points.c @@ -140,7 +140,7 @@ sprite_point(struct gl_context *ctx, const SWvertex *vert) if (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7) { /* a texcoord attribute */ const GLuint u = attr - VARYING_SLOT_TEX0; - ASSERT(u < Elements(ctx->Point.CoordReplace)); + assert(u < ARRAY_SIZE(ctx->Point.CoordReplace)); if (ctx->Point.CoordReplace[u]) { tCoords[numTcoords++] = attr; @@ -504,7 +504,7 @@ pixel_point(struct gl_context *ctx, const SWvertex *vert) span->array->z[count] = (GLint) (vert->attrib[VARYING_SLOT_POS][2] + 0.5F); span->end = count + 1; - ASSERT(span->end <= SWRAST_MAX_WIDTH); + assert(span->end <= SWRAST_MAX_WIDTH); } diff --git a/mesalib/src/mesa/swrast/s_renderbuffer.c b/mesalib/src/mesa/swrast/s_renderbuffer.c index dfd3a6057..d8c4ed386 100644 --- a/mesalib/src/mesa/swrast/s_renderbuffer.c +++ b/mesalib/src/mesa/swrast/s_renderbuffer.c @@ -153,7 +153,7 @@ soft_renderbuffer_storage(struct gl_context *ctx, struct gl_renderbuffer *rb, } else { /* the internalFormat should have been error checked long ago */ - ASSERT(rb->_BaseFormat); + assert(rb->_BaseFormat); } return GL_TRUE; diff --git a/mesalib/src/mesa/swrast/s_span.c b/mesalib/src/mesa/swrast/s_span.c index 321959df9..5d618f048 100644 --- a/mesalib/src/mesa/swrast/s_span.c +++ b/mesalib/src/mesa/swrast/s_span.c @@ -31,6 +31,7 @@ * \author Brian Paul */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/format_pack.h" @@ -205,7 +206,7 @@ interpolate_active_attribs(struct gl_context *ctx, SWspan *span, v3 += dv3dx; w += dwdx; } - ASSERT((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0); + assert((span->arrayAttribs & BITFIELD64_BIT(attr)) == 0); span->arrayAttribs |= BITFIELD64_BIT(attr); } ATTRIB_LOOP_END @@ -223,7 +224,7 @@ interpolate_int_colors(struct gl_context *ctx, SWspan *span) const GLuint n = span->end; GLuint i; - ASSERT(!(span->arrayMask & SPAN_RGBA)); + assert(!(span->arrayMask & SPAN_RGBA)); #endif switch (span->array->ChanType) { @@ -336,7 +337,7 @@ interpolate_float_colors(SWspan *span) } else { /* interpolate red/green/blue/alpha to get float colors */ - ASSERT(span->interpMask & SPAN_RGBA); + assert(span->interpMask & SPAN_RGBA); if (span->interpMask & SPAN_FLAT) { GLfloat r = FixedToFloat(span->red); GLfloat g = FixedToFloat(span->green); @@ -383,7 +384,7 @@ _swrast_span_interpolate_z( const struct gl_context *ctx, SWspan *span ) const GLuint n = span->end; GLuint i; - ASSERT(!(span->arrayMask & SPAN_Z)); + assert(!(span->arrayMask & SPAN_Z)); if (ctx->DrawBuffer->Visual.depthBits <= 16) { GLfixed zval = span->z; @@ -443,10 +444,10 @@ _swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy, GLfloat dsdy2 = (s + dsdy) / (q + dqdy) - s * invQ; GLfloat dtdy2 = (t + dtdy) / (q + dqdy) - t * invQ; GLfloat maxU, maxV, rho, lambda; - dsdx2 = FABSF(dsdx2); - dsdy2 = FABSF(dsdy2); - dtdx2 = FABSF(dtdx2); - dtdy2 = FABSF(dtdy2); + dsdx2 = fabsf(dsdx2); + dsdy2 = fabsf(dsdy2); + dtdx2 = fabsf(dtdx2); + dtdy2 = fabsf(dtdy2); maxU = MAX2(dsdx2, dsdy2) * texW; maxV = MAX2(dtdx2, dtdy2) * texH; rho = MAX2(maxU, maxV); @@ -658,7 +659,7 @@ stipple_polygon_span(struct gl_context *ctx, SWspan *span) { GLubyte *mask = span->array->mask; - ASSERT(ctx->Polygon.StippleFlag); + assert(ctx->Polygon.StippleFlag); if (span->arrayMask & SPAN_XY) { /* arrays of x/y pixel coords */ @@ -748,7 +749,7 @@ clip_span( struct gl_context *ctx, SWspan *span ) /* Clip to right */ if (x + n > xmax) { - ASSERT(x < xmax); + assert(x < xmax); n = span->end = xmax - x; } @@ -757,8 +758,8 @@ clip_span( struct gl_context *ctx, SWspan *span ) const GLint leftClip = xmin - x; GLuint i; - ASSERT(leftClip > 0); - ASSERT(x + n > xmin); + assert(leftClip > 0); + assert(x + n > xmin); /* Clip 'leftClip' pixels from the left side. * The span->leftClip field will be applied when we interpolate @@ -813,10 +814,10 @@ clip_span( struct gl_context *ctx, SWspan *span ) span->writeAll = GL_FALSE; } - ASSERT(span->x >= xmin); - ASSERT(span->x + span->end <= xmax); - ASSERT(span->y >= ymin); - ASSERT(span->y < ymax); + assert(span->x >= xmin); + assert(span->x + span->end <= xmax); + assert(span->y >= ymin); + assert(span->y < ymax); return GL_TRUE; /* some pixels visible */ } @@ -837,9 +838,9 @@ add_specular(struct gl_context *ctx, SWspan *span) GLfloat (*col1)[4] = span->array->attribs[VARYING_SLOT_COL1]; GLuint i; - ASSERT(!_swrast_use_fragment_program(ctx)); - ASSERT(span->arrayMask & SPAN_RGBA); - ASSERT(swrast->_ActiveAttribMask & VARYING_BIT_COL1); + assert(!_swrast_use_fragment_program(ctx)); + assert(span->arrayMask & SPAN_RGBA); + assert(swrast->_ActiveAttribMask & VARYING_BIT_COL1); (void) swrast; /* silence warning */ if (span->array->ChanType == GL_FLOAT) { @@ -859,8 +860,8 @@ add_specular(struct gl_context *ctx, SWspan *span) interpolate_active_attribs(ctx, span, VARYING_BIT_COL1); } - ASSERT(span->arrayAttribs & VARYING_BIT_COL0); - ASSERT(span->arrayAttribs & VARYING_BIT_COL1); + assert(span->arrayAttribs & VARYING_BIT_COL0); + assert(span->arrayAttribs & VARYING_BIT_COL1); for (i = 0; i < span->end; i++) { if (mask[i]) { @@ -887,8 +888,8 @@ apply_aa_coverage(SWspan *span) for (i = 0; i < span->end; i++) { const GLfloat a = rgba[i][ACOMP] * coverage[i]; rgba[i][ACOMP] = (GLubyte) CLAMP(a, 0.0, 255.0); - ASSERT(coverage[i] >= 0.0); - ASSERT(coverage[i] <= 1.0); + assert(coverage[i] >= 0.0); + assert(coverage[i] <= 1.0); } } else if (span->array->ChanType == GL_UNSIGNED_SHORT) { @@ -916,7 +917,7 @@ clamp_colors(SWspan *span) { GLfloat (*rgba)[4] = span->array->attribs[VARYING_SLOT_COL0]; GLuint i; - ASSERT(span->array->ChanType == GL_FLOAT); + assert(span->array->ChanType == GL_FLOAT); for (i = 0; i < span->end; i++) { rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); @@ -945,7 +946,7 @@ convert_color_type(SWspan *span, GLenum srcType, GLenum newType, GLuint output) src = span->array->rgba8; } else { - ASSERT(srcType == GL_UNSIGNED_SHORT); + assert(srcType == GL_UNSIGNED_SHORT); src = span->array->rgba16; } @@ -1008,7 +1009,7 @@ shade_texture_span(struct gl_context *ctx, SWspan *span) _swrast_exec_fragment_program(ctx, span); } else { - ASSERT(ctx->ATIFragmentShader._Enabled); + assert(ctx->ATIFragmentShader._Enabled); _swrast_exec_fragment_shader(ctx, span); } } @@ -1147,7 +1148,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) span->interpMask, span->arrayMask); */ - ASSERT(span->primitive == GL_POINT || + assert(span->primitive == GL_POINT || span->primitive == GL_LINE || span->primitive == GL_POLYGON || span->primitive == GL_BITMAP); @@ -1167,7 +1168,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) return; } - ASSERT(span->end <= SWRAST_MAX_WIDTH); + assert(span->end <= SWRAST_MAX_WIDTH); /* Depth bounds test */ if (ctx->Depth.BoundsTest && fb->Visual.depthBits > 0) { @@ -1229,8 +1230,8 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) } else if (fb->Visual.depthBits > 0) { /* Just regular depth testing */ - ASSERT(ctx->Depth.Test); - ASSERT(span->arrayMask & SPAN_Z); + assert(ctx->Depth.Test); + assert(span->arrayMask & SPAN_Z); if (!_swrast_depth_test_span(ctx, span)) { /* all fragments failed test */ goto end; @@ -1272,7 +1273,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) } #endif - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); if (span->primitive == GL_BITMAP || !swrast->SpecularVertexAdd) { /* Add primary and specular (diffuse + specular) colors */ @@ -1353,7 +1354,7 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span) 4 * span->end * sizeof(GLchan)); } - ASSERT(rb->_BaseFormat == GL_RGBA || + assert(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RED || rb->_BaseFormat == GL_RG || @@ -1457,8 +1458,8 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, length = (GLint) n; } - ASSERT(rb); - ASSERT(rb->_BaseFormat == GL_RGBA || + assert(rb); + assert(rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RG || rb->_BaseFormat == GL_RED || @@ -1468,6 +1469,7 @@ _swrast_read_rgba_span( struct gl_context *ctx, struct gl_renderbuffer *rb, rb->_BaseFormat == GL_ALPHA); assert(srb->Map); + (void) srb; /* silence unused var warning */ src = _swrast_pixel_address(rb, x + skip, y); diff --git a/mesalib/src/mesa/swrast/s_stencil.c b/mesalib/src/mesa/swrast/s_stencil.c index eba9da863..294b593a2 100644 --- a/mesalib/src/mesa/swrast/s_stencil.c +++ b/mesalib/src/mesa/swrast/s_stencil.c @@ -280,7 +280,7 @@ compute_pass_fail_masks(GLuint n, const GLubyte origMask[], { GLuint i; for (i = 0; i < n; i++) { - ASSERT(newMask[i] == 0 || newMask[i] == 1); + assert(newMask[i] == 0 || newMask[i] == 1); passMask[i] = origMask[i] & newMask[i]; failMask[i] = origMask[i] & (newMask[i] ^ 1); } diff --git a/mesalib/src/mesa/swrast/s_texcombine.c b/mesalib/src/mesa/swrast/s_texcombine.c index def5eb19e..58ff16465 100644 --- a/mesalib/src/mesa/swrast/s_texcombine.c +++ b/mesalib/src/mesa/swrast/s_texcombine.c @@ -188,7 +188,7 @@ texture_combine( struct gl_context *ctx, GLuint unit, /* ARB_texture_env_crossbar source */ { const GLuint srcUnit = srcRGB - GL_TEXTURE0; - ASSERT(srcUnit < ctx->Const.MaxTextureUnits); + assert(srcUnit < ctx->Const.MaxTextureUnits); if (!ctx->Texture.Unit[srcUnit]._Current) goto end; argRGB[term] = get_texel_array(swrast, srcUnit); @@ -278,7 +278,7 @@ texture_combine( struct gl_context *ctx, GLuint unit, /* ARB_texture_env_crossbar source */ { const GLuint srcUnit = srcA - GL_TEXTURE0; - ASSERT(srcUnit < ctx->Const.MaxTextureUnits); + assert(srcUnit < ctx->Const.MaxTextureUnits); if (!ctx->Texture.Unit[srcUnit]._Current) goto end; argA[term] = get_texel_array(swrast, srcUnit); @@ -628,7 +628,7 @@ _swrast_texture_span( struct gl_context *ctx, SWspan *span ) return; } - ASSERT(span->end <= SWRAST_MAX_WIDTH); + assert(span->end <= SWRAST_MAX_WIDTH); /* * Save copy of the incoming fragment colors (the GL_PRIMARY_COLOR) diff --git a/mesalib/src/mesa/swrast/s_texfetch.c b/mesalib/src/mesa/swrast/s_texfetch.c index 9629024b9..3c4ee15ba 100644 --- a/mesalib/src/mesa/swrast/s_texfetch.c +++ b/mesalib/src/mesa/swrast/s_texfetch.c @@ -573,7 +573,7 @@ set_fetch_functions(const struct gl_sampler_object *samp, } #endif - STATIC_ASSERT(Elements(texfetch_funcs) == MESA_FORMAT_COUNT); + STATIC_ASSERT(ARRAY_SIZE(texfetch_funcs) == MESA_FORMAT_COUNT); if (samp->sRGBDecode == GL_SKIP_DECODE_EXT && _mesa_get_format_color_encoding(format) == GL_SRGB) { @@ -598,7 +598,7 @@ set_fetch_functions(const struct gl_sampler_object *samp, texImage->FetchCompressedTexel = _mesa_get_compressed_fetch_func(format); - ASSERT(texImage->FetchTexel); + assert(texImage->FetchTexel); } void diff --git a/mesalib/src/mesa/swrast/s_texfilter.c b/mesalib/src/mesa/swrast/s_texfilter.c index fa79fdc5b..3ade99519 100644 --- a/mesalib/src/mesa/swrast/s_texfilter.c +++ b/mesalib/src/mesa/swrast/s_texfilter.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" @@ -223,7 +224,7 @@ linear_texel_locations(GLenum wrapMode, } break; case GL_MIRROR_CLAMP_EXT: - u = FABSF(s); + u = fabsf(s); if (u >= 1.0F) u = (GLfloat) size; else @@ -233,7 +234,7 @@ linear_texel_locations(GLenum wrapMode, *i1 = *i0 + 1; break; case GL_MIRROR_CLAMP_TO_EDGE_EXT: - u = FABSF(s); + u = fabsf(s); if (u >= 1.0F) u = (GLfloat) size; else @@ -250,7 +251,7 @@ linear_texel_locations(GLenum wrapMode, { const GLfloat min = -1.0F / (2.0F * size); const GLfloat max = 1.0F - min; - u = FABSF(s); + u = fabsf(s); if (u <= min) u = min * size; else if (u >= max) @@ -354,7 +355,7 @@ nearest_texel_location(GLenum wrapMode, { /* s limited to [0,1] */ /* i limited to [0,size-1] */ - const GLfloat u = FABSF(s); + const GLfloat u = fabsf(s); if (u <= 0.0F) i = 0; else if (u >= 1.0F) @@ -369,7 +370,7 @@ nearest_texel_location(GLenum wrapMode, /* i limited to [0, size-1] */ const GLfloat min = 1.0F / (2.0F * size); const GLfloat max = 1.0F - min; - const GLfloat u = FABSF(s); + const GLfloat u = fabsf(s); if (u < min) i = 0; else if (u > max) @@ -384,7 +385,7 @@ nearest_texel_location(GLenum wrapMode, /* i limited to [0, size-1] */ const GLfloat min = -1.0F / (2.0F * size); const GLfloat max = 1.0F - min; - const GLfloat u = FABSF(s); + const GLfloat u = fabsf(s); if (u < min) i = -1; else if (u > max) @@ -668,7 +669,7 @@ compute_min_mag_ranges(const struct gl_sampler_object *samp, GLfloat minMagThresh; /* we shouldn't be here if minfilter == magfilter */ - ASSERT(samp->MinFilter != samp->MagFilter); + assert(samp->MinFilter != samp->MagFilter); /* This bit comes from the OpenGL spec: */ if (samp->MagFilter == GL_LINEAR @@ -690,12 +691,12 @@ compute_min_mag_ranges(const struct gl_sampler_object *samp, printf("lambda delta = %g\n", lambda[0] - lambda[n-1]); if (lambda[0] >= lambda[n-1]) { /* decreasing */ for (i = 0; i < n - 1; i++) { - ASSERT((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10)); + assert((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10)); } } else { /* increasing */ for (i = 0; i < n - 1; i++) { - ASSERT((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10)); + assert((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10)); } } } @@ -749,13 +750,13 @@ compute_min_mag_ranges(const struct gl_sampler_object *samp, for (i = 0; i < n; i++) { if (lambda[i] > minMagThresh) { /* minification */ - ASSERT(i >= *minStart); - ASSERT(i < *minEnd); + assert(i >= *minStart); + assert(i < *minEnd); } else { /* magnification */ - ASSERT(i >= *magStart); - ASSERT(i < *magEnd); + assert(i >= *magStart); + assert(i < *magEnd); } } } @@ -920,7 +921,7 @@ sample_1d_nearest_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_1d_nearest(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -936,7 +937,7 @@ sample_1d_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_1d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -952,7 +953,7 @@ sample_1d_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -978,7 +979,7 @@ sample_1d_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1042,7 +1043,7 @@ sample_lambda_1d( struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -1226,10 +1227,10 @@ sample_2d_linear_repeat(struct gl_context *ctx, (void) ctx; - ASSERT(samp->WrapS == GL_REPEAT); - ASSERT(samp->WrapT == GL_REPEAT); - ASSERT(img->Border == 0); - ASSERT(swImg->_IsPowerOfTwo); + assert(samp->WrapS == GL_REPEAT); + assert(samp->WrapT == GL_REPEAT); + assert(img->Border == 0); + assert(swImg->_IsPowerOfTwo); linear_repeat_texel_location(width, texcoord[0], &i0, &i1, &wi); linear_repeat_texel_location(height, texcoord[1], &j0, &j1, &wj); @@ -1266,7 +1267,7 @@ sample_2d_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_2d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -1282,7 +1283,7 @@ sample_2d_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1308,7 +1309,7 @@ sample_2d_linear_mipmap_linear( struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4] ) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1334,9 +1335,9 @@ sample_2d_linear_mipmap_linear_repeat(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); - ASSERT(samp->WrapS == GL_REPEAT); - ASSERT(samp->WrapT == GL_REPEAT); + assert(lambda != NULL); + assert(samp->WrapS == GL_REPEAT); + assert(samp->WrapT == GL_REPEAT); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -1426,11 +1427,11 @@ opt_sample_rgb_2d(struct gl_context *ctx, GLuint k; (void) ctx; (void) lambda; - ASSERT(samp->WrapS==GL_REPEAT); - ASSERT(samp->WrapT==GL_REPEAT); - ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_BGR_UNORM8); - ASSERT(swImg->_IsPowerOfTwo); + assert(samp->WrapS==GL_REPEAT); + assert(samp->WrapT==GL_REPEAT); + assert(img->Border==0); + assert(img->TexFormat == MESA_FORMAT_BGR_UNORM8); + assert(swImg->_IsPowerOfTwo); (void) swImg; for (k=0; k<n; k++) { @@ -1471,11 +1472,11 @@ opt_sample_rgba_2d(struct gl_context *ctx, GLuint i; (void) ctx; (void) lambda; - ASSERT(samp->WrapS==GL_REPEAT); - ASSERT(samp->WrapT==GL_REPEAT); - ASSERT(img->Border==0); - ASSERT(img->TexFormat == MESA_FORMAT_A8B8G8R8_UNORM); - ASSERT(swImg->_IsPowerOfTwo); + assert(samp->WrapS==GL_REPEAT); + assert(samp->WrapT==GL_REPEAT); + assert(img->Border==0); + assert(img->TexFormat == MESA_FORMAT_A8B8G8R8_UNORM); + assert(swImg->_IsPowerOfTwo); (void) swImg; for (i = 0; i < n; i++) { @@ -1511,7 +1512,7 @@ sample_lambda_2d(struct gl_context *ctx, swImg->RowStride) && swImg->_IsPowerOfTwo; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -1674,7 +1675,7 @@ sample_2d_ewa(struct gl_context *ctx, GLfloat F = A*C-B*B/4.0f; /* check if it is an ellipse */ - /* ASSERT(F > 0.0); */ + /* assert(F > 0.0); */ /* Compute the ellipse's (u,v) bounding box in texture space */ GLfloat d = -B*B+4.0f*C*A; @@ -2164,7 +2165,7 @@ sample_3d_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_3d_linear(ctx, samp, tObj->Image[0][level], texcoord[i], rgba[i]); @@ -2180,7 +2181,7 @@ sample_3d_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -2206,7 +2207,7 @@ sample_3d_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -2270,7 +2271,7 @@ sample_lambda_3d(struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -2358,7 +2359,7 @@ choose_cube_face(const struct gl_texture_object *texObj, const GLfloat rx = texcoord[0]; const GLfloat ry = texcoord[1]; const GLfloat rz = texcoord[2]; - const GLfloat arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz); + const GLfloat arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz); GLuint face; GLfloat sc, tc, ma; @@ -2471,7 +2472,7 @@ sample_cube_nearest_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2506,7 +2507,7 @@ sample_cube_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2531,7 +2532,7 @@ sample_cube_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2566,7 +2567,7 @@ sample_cube_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { const struct gl_texture_image **images; GLfloat newCoord[4]; @@ -2604,7 +2605,7 @@ sample_lambda_cube(struct gl_context *ctx, GLuint minStart, minEnd; /* texels with minification */ GLuint magStart, magEnd; /* texels with magnification */ - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -2687,10 +2688,10 @@ sample_nearest_rect(struct gl_context *ctx, (void) ctx; (void) lambda; - ASSERT(samp->WrapS == GL_CLAMP || + assert(samp->WrapS == GL_CLAMP || samp->WrapS == GL_CLAMP_TO_EDGE || samp->WrapS == GL_CLAMP_TO_BORDER); - ASSERT(samp->WrapT == GL_CLAMP || + assert(samp->WrapT == GL_CLAMP || samp->WrapT == GL_CLAMP_TO_EDGE || samp->WrapT == GL_CLAMP_TO_BORDER); @@ -2722,10 +2723,10 @@ sample_linear_rect(struct gl_context *ctx, (void) ctx; (void) lambda; - ASSERT(samp->WrapS == GL_CLAMP || + assert(samp->WrapS == GL_CLAMP || samp->WrapS == GL_CLAMP_TO_EDGE || samp->WrapS == GL_CLAMP_TO_BORDER); - ASSERT(samp->WrapT == GL_CLAMP || + assert(samp->WrapT == GL_CLAMP || samp->WrapT == GL_CLAMP_TO_EDGE || samp->WrapT == GL_CLAMP_TO_BORDER); @@ -2947,7 +2948,7 @@ sample_2d_array_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_2d_array_linear(ctx, samp, tObj->Image[0][level], @@ -2964,7 +2965,7 @@ sample_2d_array_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -2992,7 +2993,7 @@ sample_2d_array_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -3059,7 +3060,7 @@ sample_lambda_2d_array(struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -3242,7 +3243,7 @@ sample_1d_array_linear_mipmap_nearest(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = nearest_mipmap_level(tObj, lambda[i]); sample_1d_array_linear(ctx, samp, tObj->Image[0][level], @@ -3259,7 +3260,7 @@ sample_1d_array_nearest_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -3285,7 +3286,7 @@ sample_1d_array_linear_mipmap_linear(struct gl_context *ctx, const GLfloat lambda[], GLfloat rgba[][4]) { GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); for (i = 0; i < n; i++) { GLint level = linear_mipmap_level(tObj, lambda[i]); if (level >= tObj->_MaxLevel) { @@ -3349,7 +3350,7 @@ sample_lambda_1d_array(struct gl_context *ctx, GLuint magStart, magEnd; /* texels with magnification */ GLuint i; - ASSERT(lambda != NULL); + assert(lambda != NULL); compute_min_mag_ranges(samp, n, lambda, &minStart, &minEnd, &magStart, &magEnd); @@ -3555,10 +3556,10 @@ sample_depth_texture( struct gl_context *ctx, GLenum function; GLfloat result; - ASSERT(img->_BaseFormat == GL_DEPTH_COMPONENT || + assert(img->_BaseFormat == GL_DEPTH_COMPONENT || img->_BaseFormat == GL_DEPTH_STENCIL_EXT); - ASSERT(tObj->Target == GL_TEXTURE_1D || + assert(tObj->Target == GL_TEXTURE_1D || tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_RECTANGLE_NV || tObj->Target == GL_TEXTURE_1D_ARRAY_EXT || @@ -3595,7 +3596,7 @@ sample_depth_texture( struct gl_context *ctx, } else { GLuint i; - ASSERT(samp->MagFilter == GL_LINEAR); + assert(samp->MagFilter == GL_LINEAR); for (i = 0; i < n; i++) { GLfloat depth00, depth01, depth10, depth11, depthRef; GLint i0, i1, j0, j1; @@ -3730,7 +3731,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_1d; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_1d; } case GL_TEXTURE_2D: @@ -3755,7 +3756,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, swrast_texture_image_const(img); texture_sample_func func; - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); func = &sample_nearest_2d; if (sampler->WrapS == GL_REPEAT && sampler->WrapT == GL_REPEAT && @@ -3777,7 +3778,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_3d; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_3d; } case GL_TEXTURE_CUBE_MAP: @@ -3788,7 +3789,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_cube; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_cube; } case GL_TEXTURE_RECTANGLE_NV: @@ -3802,7 +3803,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_rect; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_rect; } case GL_TEXTURE_1D_ARRAY_EXT: @@ -3816,7 +3817,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_1d_array; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_1d_array; } case GL_TEXTURE_2D_ARRAY_EXT: @@ -3830,7 +3831,7 @@ _swrast_choose_texture_sample_func( struct gl_context *ctx, return &sample_linear_2d_array; } else { - ASSERT(sampler->MinFilter == GL_NEAREST); + assert(sampler->MinFilter == GL_NEAREST); return &sample_nearest_2d_array; } default: diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c index d67e48ad3..29bb270d6 100644 --- a/mesalib/src/mesa/swrast/s_texrender.c +++ b/mesalib/src/mesa/swrast/s_texrender.c @@ -18,7 +18,7 @@ static void delete_texture_wrapper(struct gl_context *ctx, struct gl_renderbuffer *rb) { - ASSERT(rb->RefCount == 0); + assert(rb->RefCount == 0); free(rb); } diff --git a/mesalib/src/mesa/swrast/s_triangle.c b/mesalib/src/mesa/swrast/s_triangle.c index 1d8e31c2e..af039c359 100644 --- a/mesalib/src/mesa/swrast/s_triangle.c +++ b/mesalib/src/mesa/swrast/s_triangle.c @@ -78,8 +78,8 @@ _swrast_culltriangle( struct gl_context *ctx, #define NAME flat_rgba_triangle #define INTERP_Z 1 #define SETUP_CODE \ - ASSERT(ctx->Texture._EnabledCoordUnits == 0);\ - ASSERT(ctx->Light.ShadeModel==GL_FLAT); \ + assert(ctx->Texture._EnabledCoordUnits == 0);\ + assert(ctx->Light.ShadeModel==GL_FLAT); \ span.interpMask |= SPAN_RGBA; \ span.red = ChanToFixed(v2->color[0]); \ span.green = ChanToFixed(v2->color[1]); \ @@ -104,8 +104,8 @@ _swrast_culltriangle( struct gl_context *ctx, #define SETUP_CODE \ { \ /* texturing must be off */ \ - ASSERT(ctx->Texture._EnabledCoordUnits == 0); \ - ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \ + assert(ctx->Texture._EnabledCoordUnits == 0); \ + assert(ctx->Light.ShadeModel==GL_SMOOTH); \ } #define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span); #include "s_tritemp.h" @@ -137,7 +137,7 @@ _swrast_culltriangle( struct gl_context *ctx, const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0]; \ const GLint smask = texImg->Width - 1; \ const GLint tmask = texImg->Height - 1; \ - ASSERT(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ + assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ if (!rb || !texture) { \ return; \ } @@ -195,7 +195,7 @@ _swrast_culltriangle( struct gl_context *ctx, const GLubyte *texture = (const GLubyte *) swImg->ImageSlices[0]; \ const GLint smask = texImg->Width - 1; \ const GLint tmask = texImg->Height - 1; \ - ASSERT(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ + assert(texImg->TexFormat == MESA_FORMAT_BGR_UNORM8); \ if (!rb || !texture) { \ return; \ } @@ -513,7 +513,7 @@ affine_span(struct gl_context *ctx, SWspan *span, break; } span->interpMask &= ~SPAN_RGBA; - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); _swrast_write_rgba_span(ctx, span); @@ -783,7 +783,7 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, break; } - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); _swrast_write_rgba_span(ctx, span); #undef SPAN_NEAREST @@ -885,9 +885,9 @@ fast_persp_span(struct gl_context *ctx, SWspan *span, struct gl_renderbuffer *rb = \ ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; \ struct gl_query_object *q = ctx->Query.CurrentOcclusionObject; \ - ASSERT(ctx->Depth.Test); \ - ASSERT(!ctx->Depth.Mask); \ - ASSERT(ctx->Depth.Func == GL_LESS); \ + assert(ctx->Depth.Test); \ + assert(!ctx->Depth.Mask); \ + assert(ctx->Depth.Func == GL_LESS); \ assert(rb->Format == MESA_FORMAT_Z_UNORM16); \ if (!q) { \ return; \ @@ -1015,7 +1015,7 @@ _swrast_choose_triangle( struct gl_context *ctx ) if (ctx->Polygon.SmoothFlag) { _swrast_set_aa_triangle_function(ctx); - ASSERT(swrast->Triangle); + assert(swrast->Triangle); return; } @@ -1134,8 +1134,8 @@ _swrast_choose_triangle( struct gl_context *ctx ) } } else { - ASSERT(!swrast->_FogEnabled); - ASSERT(!_mesa_need_secondary_color(ctx)); + assert(!swrast->_FogEnabled); + assert(!_mesa_need_secondary_color(ctx)); if (ctx->Light.ShadeModel==GL_SMOOTH) { /* smooth shaded, no texturing, stippled or some raster ops */ #if CHAN_BITS != 8 diff --git a/mesalib/src/mesa/swrast/s_tritemp.h b/mesalib/src/mesa/swrast/s_tritemp.h index 8a278dff6..fb73b2d59 100644 --- a/mesalib/src/mesa/swrast/s_tritemp.h +++ b/mesalib/src/mesa/swrast/s_tritemp.h @@ -91,6 +91,11 @@ */ +#ifndef MAX_GLUINT +#define MAX_GLUINT 0xffffffff +#endif + + /* * Some code we unfortunately need to prevent negative interpolated colors. */ @@ -380,7 +385,7 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0, # endif /* INTERP_ALPHA */ } else { - ASSERT(ctx->Light.ShadeModel == GL_FLAT); + assert(ctx->Light.ShadeModel == GL_FLAT); span.interpMask |= SPAN_FLAT; span.attrStepX[VARYING_SLOT_COL0][0] = span.attrStepY[VARYING_SLOT_COL0][0] = 0.0F; span.attrStepX[VARYING_SLOT_COL0][1] = span.attrStepY[VARYING_SLOT_COL0][1] = 0.0F; @@ -662,7 +667,7 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0, # endif } else { - ASSERT(ctx->Light.ShadeModel == GL_FLAT); + assert(ctx->Light.ShadeModel == GL_FLAT); rLeft = ChanToFixed(v2->color[RCOMP]); gLeft = ChanToFixed(v2->color[GCOMP]); bLeft = ChanToFixed(v2->color[BCOMP]); diff --git a/mesalib/src/mesa/swrast/s_zoom.c b/mesalib/src/mesa/swrast/s_zoom.c index 352c61ad2..ab22652c7 100644 --- a/mesalib/src/mesa/swrast/s_zoom.c +++ b/mesalib/src/mesa/swrast/s_zoom.c @@ -53,8 +53,8 @@ compute_zoomed_bounds(struct gl_context *ctx, GLint imageX, GLint imageY, const struct gl_framebuffer *fb = ctx->DrawBuffer; GLint c0, c1, r0, r1; - ASSERT(spanX >= imageX); - ASSERT(spanY >= imageY); + assert(spanX >= imageX); + assert(spanY >= imageY); /* * Compute destination columns: [c0, c1) @@ -149,12 +149,12 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, } zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + assert(zoomedWidth > 0); + assert(zoomedWidth <= SWRAST_MAX_WIDTH); /* no pixel arrays! must be horizontal spans. */ - ASSERT((span->arrayMask & SPAN_XY) == 0); - ASSERT(span->primitive == GL_BITMAP); + assert((span->arrayMask & SPAN_XY) == 0); + assert(span->primitive == GL_BITMAP); INIT_SPAN(zoomed, GL_BITMAP); zoomed.x = x0; @@ -184,7 +184,7 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, zoomed.interpMask = span->interpMask & ~SPAN_RGBA; zoomed.arrayMask |= SPAN_RGBA; zoomed.arrayAttribs |= VARYING_BIT_COL0; /* we'll produce these values */ - ASSERT(span->arrayMask & SPAN_RGBA); + assert(span->arrayMask & SPAN_RGBA); } else if (format == GL_DEPTH_COMPONENT) { /* Copy color info */ @@ -199,7 +199,7 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, /* we'll generate an array of depth values */ zoomed.interpMask = span->interpMask & ~SPAN_Z; zoomed.arrayMask |= SPAN_Z; - ASSERT(span->arrayMask & SPAN_Z); + assert(span->arrayMask & SPAN_Z); } else { _mesa_problem(ctx, "Bad format in zoom_span"); @@ -213,8 +213,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); COPY_4UBV(zoomed.array->rgba8[i], rgba[j]); } } @@ -223,8 +223,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); COPY_4V(zoomed.array->rgba16[i], rgba[j]); } } @@ -233,8 +233,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); COPY_4V(zoomed.array->attribs[VARYING_SLOT_COL0][i], rgba[j]); } } @@ -245,8 +245,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->rgba8[i][0] = rgb[j][0]; zoomed.array->rgba8[i][1] = rgb[j][1]; zoomed.array->rgba8[i][2] = rgb[j][2]; @@ -258,8 +258,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->rgba16[i][0] = rgb[j][0]; zoomed.array->rgba16[i][1] = rgb[j][1]; zoomed.array->rgba16[i][2] = rgb[j][2]; @@ -271,8 +271,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->attribs[VARYING_SLOT_COL0][i][0] = rgb[j][0]; zoomed.array->attribs[VARYING_SLOT_COL0][i][1] = rgb[j][1]; zoomed.array->attribs[VARYING_SLOT_COL0][i][2] = rgb[j][2]; @@ -285,8 +285,8 @@ zoom_span( struct gl_context *ctx, GLint imgX, GLint imgY, const SWspan *span, GLint i; for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - span->x; - ASSERT(j >= 0); - ASSERT(j < (GLint) span->end); + assert(j >= 0); + assert(j < (GLint) span->end); zoomed.array->z[i] = zValues[j]; } /* Now, fall into the RGB path below */ @@ -372,8 +372,8 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY } zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + assert(zoomedWidth > 0); + assert(zoomedWidth <= SWRAST_MAX_WIDTH); zoomedVals = malloc(zoomedWidth * sizeof(GLubyte)); if (!zoomedVals) @@ -382,8 +382,8 @@ _swrast_write_zoomed_stencil_span(struct gl_context *ctx, GLint imgX, GLint imgY /* zoom the span horizontally */ for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - spanX; - ASSERT(j >= 0); - ASSERT(j < width); + assert(j >= 0); + assert(j < width); zoomedVals[i] = stencil[j]; } @@ -417,8 +417,8 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, } zoomedWidth = x1 - x0; - ASSERT(zoomedWidth > 0); - ASSERT(zoomedWidth <= SWRAST_MAX_WIDTH); + assert(zoomedWidth > 0); + assert(zoomedWidth <= SWRAST_MAX_WIDTH); zoomedVals = malloc(zoomedWidth * sizeof(GLuint)); if (!zoomedVals) @@ -427,8 +427,8 @@ _swrast_write_zoomed_z_span(struct gl_context *ctx, GLint imgX, GLint imgY, /* zoom the span horizontally */ for (i = 0; i < zoomedWidth; i++) { GLint j = unzoom_x(ctx->Pixel.ZoomX, imgX, x0 + i) - spanX; - ASSERT(j >= 0); - ASSERT(j < width); + assert(j >= 0); + assert(j < width); zoomedVals[i] = zVals[j]; } diff --git a/mesalib/src/mesa/swrast_setup/ss_triangle.c b/mesalib/src/mesa/swrast_setup/ss_triangle.c index 42ba891ab..483c41592 100644 --- a/mesalib/src/mesa/swrast_setup/ss_triangle.c +++ b/mesalib/src/mesa/swrast_setup/ss_triangle.c @@ -25,6 +25,7 @@ * Keith Whitwell <keithw@vmware.com> */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" diff --git a/mesalib/src/mesa/swrast_setup/ss_tritmp.h b/mesalib/src/mesa/swrast_setup/ss_tritmp.h index d4513c9ac..c38c76a4a 100644 --- a/mesalib/src/mesa/swrast_setup/ss_tritmp.h +++ b/mesalib/src/mesa/swrast_setup/ss_tritmp.h @@ -142,8 +142,8 @@ static void TAG(triangle)(struct gl_context *ctx, GLuint e0, GLuint e1, GLuint e const GLfloat ez = z[0] - z[2]; const GLfloat fz = z[1] - z[2]; const GLfloat oneOverArea = 1.0F / cc; - const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea); - const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea); + const GLfloat dzdx = fabsf((ey * fz - ez * fy) * oneOverArea); + const GLfloat dzdy = fabsf((ez * fx - ex * fz) * oneOverArea); offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor; } /* new Z values */ diff --git a/mesalib/src/mesa/tnl/t_context.c b/mesalib/src/mesa/tnl/t_context.c index eb5bae41d..bc705d7a3 100644 --- a/mesalib/src/mesa/tnl/t_context.c +++ b/mesalib/src/mesa/tnl/t_context.c @@ -130,7 +130,7 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) GLuint i; if (new_state & (_NEW_HINT | _NEW_PROGRAM)) { - ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog); + assert(tnl->AllowVertexFog || tnl->AllowPixelFog); tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST)) || !tnl->AllowPixelFog) && !fp; } diff --git a/mesalib/src/mesa/tnl/t_draw.c b/mesalib/src/mesa/tnl/t_draw.c index be3f059bb..60265d60b 100644 --- a/mesalib/src/mesa/tnl/t_draw.c +++ b/mesalib/src/mesa/tnl/t_draw.c @@ -25,6 +25,8 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> + #include "main/glheader.h" #include "main/bufferobj.h" #include "main/condrender.h" diff --git a/mesalib/src/mesa/tnl/t_pipeline.c b/mesalib/src/mesa/tnl/t_pipeline.c index 78508aecf..0adbef012 100644 --- a/mesalib/src/mesa/tnl/t_pipeline.c +++ b/mesalib/src/mesa/tnl/t_pipeline.c @@ -112,6 +112,84 @@ static GLuint check_output_changes( struct gl_context *ctx ) #endif } +/** + * 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 + void _tnl_run_pipeline( struct gl_context *ctx ) { diff --git a/mesalib/src/mesa/tnl/t_rasterpos.c b/mesalib/src/mesa/tnl/t_rasterpos.c index 2f52bb306..9ecf947df 100644 --- a/mesalib/src/mesa/tnl/t_rasterpos.c +++ b/mesalib/src/mesa/tnl/t_rasterpos.c @@ -23,6 +23,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/feedback.h" @@ -271,7 +272,7 @@ compute_texgen(struct gl_context *ctx, const GLfloat vObj[4], const GLfloat vEye rz = u[2] - normal[2] * two_nu; m = rx * rx + ry * ry + (rz + 1.0F) * (rz + 1.0F); if (m > 0.0F) - mInv = 0.5F * INV_SQRTF(m); + mInv = 0.5F * (1.0f / sqrtf(m)); else mInv = 0.0F; diff --git a/mesalib/src/mesa/tnl/t_vb_cliptmp.h b/mesalib/src/mesa/tnl/t_vb_cliptmp.h index 7dafb83cf..12181f085 100644 --- a/mesalib/src/mesa/tnl/t_vb_cliptmp.h +++ b/mesalib/src/mesa/tnl/t_vb_cliptmp.h @@ -155,7 +155,7 @@ TAG(clip_line)( struct gl_context *ctx, GLuint v0, GLuint v1, GLubyte mask ) newvert++; } else { - ASSERT(t0 == 0.0); + assert(t0 == 0.0); } /* Note: we need to use vertex v0_orig when computing the new @@ -174,7 +174,7 @@ TAG(clip_line)( struct gl_context *ctx, GLuint v0, GLuint v1, GLubyte mask ) newvert++; } else { - ASSERT(t1 == 0.0); + assert(t1 == 0.0); } tnl->Driver.Render.ClippedLine( ctx, v0, v1 ); @@ -239,7 +239,7 @@ TAG(clip_tri)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte if (ctx->Light.ShadeModel == GL_FLAT) { if (pv != inlist[0]) { - ASSERT( inlist[0] >= VB->Count ); + assert( inlist[0] >= VB->Count ); tnl->Driver.Render.CopyPV( ctx, inlist[0], pv ); } } @@ -302,7 +302,7 @@ TAG(clip_quad)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint if (ctx->Light.ShadeModel == GL_FLAT) { if (pv != inlist[0]) { - ASSERT( inlist[0] >= VB->Count ); + assert( inlist[0] >= VB->Count ); tnl->Driver.Render.CopyPV( ctx, inlist[0], pv ); } } diff --git a/mesalib/src/mesa/tnl/t_vb_fog.c b/mesalib/src/mesa/tnl/t_vb_fog.c index ab7901edb..3626f1da3 100644 --- a/mesalib/src/mesa/tnl/t_vb_fog.c +++ b/mesalib/src/mesa/tnl/t_vb_fog.c @@ -26,6 +26,7 @@ */ +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/macros.h" @@ -78,7 +79,7 @@ init_static_data( void ) GLfloat f = 0.0F; GLint i = 0; for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) { - exp_table[i] = EXPF(-f); + exp_table[i] = expf(-f); } inited = 1; } @@ -186,7 +187,7 @@ run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) NOTE should avoid going through array twice */ coord = input->start; for (i = 0; i < input->count; i++) { - *coord = FABSF(*coord); + *coord = fabsf(*coord); STRIDE_F(coord, input->stride); } } @@ -201,7 +202,7 @@ run_fog_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) input->count = VB->EyePtr->count; coord = VB->EyePtr->start; for (i = 0 ; i < VB->EyePtr->count; i++) { - input->data[i][0] = FABSF(coord[2]); + input->data[i][0] = fabsf(coord[2]); STRIDE_F(coord, VB->EyePtr->stride); } } diff --git a/mesalib/src/mesa/tnl/t_vb_light.c b/mesalib/src/mesa/tnl/t_vb_light.c index f6884a464..7781b6a6c 100644 --- a/mesalib/src/mesa/tnl/t_vb_light.c +++ b/mesalib/src/mesa/tnl/t_vb_light.c @@ -23,7 +23,7 @@ */ - +#include "c99_math.h" #include "main/glheader.h" #include "main/colormac.h" #include "main/light.h" @@ -123,7 +123,7 @@ validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess ) struct tnl_shine_tab *list = tnl->_ShineTabList; struct tnl_shine_tab *s; - ASSERT(side < 2); + assert(side < 2); foreach(s, list) if ( s->shininess == shininess ) diff --git a/mesalib/src/mesa/tnl/t_vb_points.c b/mesalib/src/mesa/tnl/t_vb_points.c index 5f6c25857..0f8578daa 100644 --- a/mesalib/src/mesa/tnl/t_vb_points.c +++ b/mesalib/src/mesa/tnl/t_vb_points.c @@ -25,6 +25,7 @@ * Brian Paul */ +#include "c99_math.h" #include "main/glheader.h" #include "main/mtypes.h" #include "main/dd.h" @@ -62,9 +63,9 @@ run_point_stage(struct gl_context *ctx, struct tnl_pipeline_stage *stage) GLuint i; for (i = 0; i < VB->Count; i++) { - const GLfloat dist = FABSF(*eyeCoord); + const GLfloat dist = fabsf(*eyeCoord); const GLfloat q = p0 + dist * (p1 + dist * p2); - const GLfloat atten = (q != 0.0F) ? INV_SQRTF(q) : 1.0F; + const GLfloat atten = (q != 0.0F) ? (1.0f / sqrtf(q)) : 1.0F; size[i][0] = pointSize * atten; /* clamping done in rasterization */ eyeCoord += eyeCoordStride; } diff --git a/mesalib/src/mesa/tnl/t_vb_program.c b/mesalib/src/mesa/tnl/t_vb_program.c index d08abe7c2..464a4cddd 100644 --- a/mesalib/src/mesa/tnl/t_vb_program.c +++ b/mesalib/src/mesa/tnl/t_vb_program.c @@ -392,7 +392,7 @@ run_vp( struct gl_context *ctx, struct tnl_pipeline_stage *stage ) store->results[VARYING_SLOT_FOGC].data[i][3] = 1.0; } #ifdef NAN_CHECK - ASSERT(machine->Outputs[0][3] != 0.0F); + assert(machine->Outputs[0][3] != 0.0F); #endif #if 0 printf("HPOS: %f %f %f %f\n", diff --git a/mesalib/src/mesa/tnl/t_vb_render.c b/mesalib/src/mesa/tnl/t_vb_render.c index aff5b9a68..4960ac096 100644 --- a/mesalib/src/mesa/tnl/t_vb_render.c +++ b/mesalib/src/mesa/tnl/t_vb_render.c @@ -38,6 +38,7 @@ */ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/enums.h" @@ -271,22 +272,22 @@ static GLboolean run_render( struct gl_context *ctx, * that window coordinates are guarenteed not to change before * rendering. */ - ASSERT(tnl->Driver.Render.Start); + assert(tnl->Driver.Render.Start); tnl->Driver.Render.Start( ctx ); - ASSERT(tnl->Driver.Render.BuildVertices); - ASSERT(tnl->Driver.Render.PrimitiveNotify); - ASSERT(tnl->Driver.Render.Points); - ASSERT(tnl->Driver.Render.Line); - ASSERT(tnl->Driver.Render.Triangle); - ASSERT(tnl->Driver.Render.Quad); - ASSERT(tnl->Driver.Render.ResetLineStipple); - ASSERT(tnl->Driver.Render.Interp); - ASSERT(tnl->Driver.Render.CopyPV); - ASSERT(tnl->Driver.Render.ClippedLine); - ASSERT(tnl->Driver.Render.ClippedPolygon); - ASSERT(tnl->Driver.Render.Finish); + assert(tnl->Driver.Render.BuildVertices); + assert(tnl->Driver.Render.PrimitiveNotify); + assert(tnl->Driver.Render.Points); + assert(tnl->Driver.Render.Line); + assert(tnl->Driver.Render.Triangle); + assert(tnl->Driver.Render.Quad); + assert(tnl->Driver.Render.ResetLineStipple); + assert(tnl->Driver.Render.Interp); + assert(tnl->Driver.Render.CopyPV); + assert(tnl->Driver.Render.ClippedLine); + assert(tnl->Driver.Render.ClippedPolygon); + assert(tnl->Driver.Render.Finish); tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 ); diff --git a/mesalib/src/mesa/tnl/t_vb_texgen.c b/mesalib/src/mesa/tnl/t_vb_texgen.c index 8f527e343..9a61ef2fe 100644 --- a/mesalib/src/mesa/tnl/t_vb_texgen.c +++ b/mesalib/src/mesa/tnl/t_vb_texgen.c @@ -116,7 +116,7 @@ static void build_m3( GLfloat f[][3], GLfloat m[], fz = f[i][2] = u[2] - norm[2] * two_nu; m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); if (m[i] != 0.0F) { - m[i] = 0.5F * INV_SQRTF(m[i]); + m[i] = 0.5F * (1.0f / sqrtf(m[i])); } } } @@ -145,7 +145,7 @@ static void build_m2( GLfloat f[][3], GLfloat m[], fz = f[i][2] = u[2] - norm[2] * two_nu; m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F); if (m[i] != 0.0F) { - m[i] = 0.5F * INV_SQRTF(m[i]); + m[i] = 0.5F * (1.0f / sqrtf(m[i])); } } } diff --git a/mesalib/src/mesa/tnl/t_vertex.c b/mesalib/src/mesa/tnl/t_vertex.c index 90b97a092..369d6d945 100644 --- a/mesalib/src/mesa/tnl/t_vertex.c +++ b/mesalib/src/mesa/tnl/t_vertex.c @@ -25,6 +25,7 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" diff --git a/mesalib/src/mesa/tnl/t_vertex_sse.c b/mesalib/src/mesa/tnl/t_vertex_sse.c index 93128fbe6..963432c48 100644 --- a/mesalib/src/mesa/tnl/t_vertex_sse.c +++ b/mesalib/src/mesa/tnl/t_vertex_sse.c @@ -25,6 +25,8 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> + #include "main/glheader.h" #include "main/context.h" #include "main/colormac.h" diff --git a/mesalib/src/mesa/vbo/vbo.h b/mesalib/src/mesa/vbo/vbo.h index 6e1a4aa1a..54dee6c46 100644 --- a/mesalib/src/mesa/vbo/vbo.h +++ b/mesalib/src/mesa/vbo/vbo.h @@ -35,6 +35,10 @@ #include <stdbool.h> #include "main/glheader.h" +#ifdef __cplusplus +extern "C" { +#endif + struct gl_client_array; struct gl_context; struct gl_transform_feedback_object; @@ -228,4 +232,8 @@ _es_VertexAttrib3fv(GLuint indx, const GLfloat* values); void GLAPIENTRY _es_VertexAttrib4fv(GLuint indx, const GLfloat* values); +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/mesalib/src/mesa/vbo/vbo_attrib_tmp.h b/mesalib/src/mesa/vbo/vbo_attrib_tmp.h index 0c44540fc..b1c3d9842 100644 --- a/mesalib/src/mesa/vbo/vbo_attrib_tmp.h +++ b/mesalib/src/mesa/vbo/vbo_attrib_tmp.h @@ -28,6 +28,22 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "util/u_format_r11g11b10f.h" #include "main/varray.h" + +/* ATTR */ +#define ATTR( A, N, T, V0, V1, V2, V3 ) \ + ATTR_##T((A), (N), (T), (V0), (V1), (V2), (V3)) + +#define ATTR_GL_UNSIGNED_INT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \ + UINT_AS_UNION(V2), UINT_AS_UNION(V3)) +#define ATTR_GL_INT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, INT_AS_UNION(V0), INT_AS_UNION(V1), \ + INT_AS_UNION(V2), INT_AS_UNION(V3)) +#define ATTR_GL_FLOAT( A, N, T, V0, V1, V2, V3 ) \ + ATTR_UNION(A, N, T, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\ + FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3)) + + /* float */ #define ATTR1FV( A, V ) ATTR( A, 1, GL_FLOAT, (V)[0], 0, 0, 1 ) #define ATTR2FV( A, V ) ATTR( A, 2, GL_FLOAT, (V)[0], (V)[1], 0, 1 ) @@ -41,8 +57,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* int */ #define ATTRI( A, N, X, Y, Z, W) ATTR( A, N, GL_INT, \ - INT_AS_FLT(X), INT_AS_FLT(Y), \ - INT_AS_FLT(Z), INT_AS_FLT(W) ) + X, Y, Z, W ) #define ATTR2IV( A, V ) ATTRI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3IV( A, V ) ATTRI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) @@ -56,8 +71,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* uint */ #define ATTRUI( A, N, X, Y, Z, W) ATTR( A, N, GL_UNSIGNED_INT, \ - UINT_AS_FLT(X), UINT_AS_FLT(Y), \ - UINT_AS_FLT(Z), UINT_AS_FLT(W) ) + X, Y, Z, W ) #define ATTR2UIV( A, V ) ATTRUI( A, 2, (V)[0], (V)[1], 0, 1 ) #define ATTR3UIV( A, V ) ATTRUI( A, 3, (V)[0], (V)[1], (V)[2], 1 ) diff --git a/mesalib/src/mesa/vbo/vbo_context.c b/mesalib/src/mesa/vbo/vbo_context.c index 19712aa58..fd1ffe2f7 100644 --- a/mesalib/src/mesa/vbo/vbo_context.c +++ b/mesalib/src/mesa/vbo/vbo_context.c @@ -108,7 +108,7 @@ static void init_mat_currval(struct gl_context *ctx) &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT]; GLuint i; - ASSERT(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX); + assert(NR_MAT_ATTRIBS == MAT_ATTRIB_MAX); memset(arrays, 0, sizeof(*arrays) * NR_MAT_ATTRIBS); @@ -172,14 +172,14 @@ GLboolean _vbo_CreateContext( struct gl_context *ctx ) GLuint i; /* identity mapping */ - for (i = 0; i < Elements(vbo->map_vp_none); i++) + for (i = 0; i < ARRAY_SIZE(vbo->map_vp_none); i++) vbo->map_vp_none[i] = i; /* map material attribs to generic slots */ for (i = 0; i < NR_MAT_ATTRIBS; i++) vbo->map_vp_none[VERT_ATTRIB_GENERIC(i)] = VBO_ATTRIB_MAT_FRONT_AMBIENT + i; - for (i = 0; i < Elements(vbo->map_vp_arb); i++) + for (i = 0; i < ARRAY_SIZE(vbo->map_vp_arb); i++) vbo->map_vp_arb[i] = i; } diff --git a/mesalib/src/mesa/vbo/vbo_context.h b/mesalib/src/mesa/vbo/vbo_context.h index e22451305..6099b56e6 100644 --- a/mesalib/src/mesa/vbo/vbo_context.h +++ b/mesalib/src/mesa/vbo/vbo_context.h @@ -56,6 +56,11 @@ #include "vbo_exec.h" #include "vbo_save.h" +#include "main/macros.h" + +#ifdef __cplusplus +extern "C" { +#endif struct vbo_context { struct gl_client_array currval[VBO_ATTRIB_MAX]; @@ -124,7 +129,7 @@ vbo_draw_method(struct vbo_context *vbo, gl_draw_method method) ctx->Array._DrawArrays = vbo->save.inputs; break; default: - ASSERT(0); + assert(0); } ctx->NewDriverState |= ctx->DriverFlags.NewArray; @@ -146,33 +151,36 @@ vbo_attrtype_to_integer_flag(GLenum format) case GL_UNSIGNED_INT: return GL_TRUE; default: - ASSERT(0); + assert(0); return GL_FALSE; } } - /** * Return default component values for the given format. - * The return type is an array of floats, because that's how we declare - * the vertex storage despite the fact we sometimes store integers in there. + * The return type is an array of fi_types, because that's how we declare + * the vertex storage : floats , integers or unsigned integers. */ -static inline const GLfloat * -vbo_get_default_vals_as_float(GLenum format) +static inline const fi_type * +vbo_get_default_vals_as_union(GLenum format) { static const GLfloat default_float[4] = { 0, 0, 0, 1 }; static const GLint default_int[4] = { 0, 0, 0, 1 }; switch (format) { case GL_FLOAT: - return default_float; + return (fi_type *)default_float; case GL_INT: case GL_UNSIGNED_INT: - return (const GLfloat*)default_int; + return (fi_type *)default_int; default: - ASSERT(0); + assert(0); return NULL; } } +#ifdef __cplusplus +} // extern "C" +#endif + #endif diff --git a/mesalib/src/mesa/vbo/vbo_exec.h b/mesalib/src/mesa/vbo/vbo_exec.h index bb265def8..f17fe684c 100644 --- a/mesalib/src/mesa/vbo/vbo_exec.h +++ b/mesalib/src/mesa/vbo/vbo_exec.h @@ -38,6 +38,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "vbo.h" #include "vbo_attrib.h" +#include "main/imports.h" /** * Max number of primitives (number of glBegin/End pairs) per VBO. @@ -71,7 +72,7 @@ struct vbo_exec_eval2_map { struct vbo_exec_copied_vtx { - GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; + fi_type buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; GLuint nr; }; @@ -91,10 +92,10 @@ struct vbo_exec_context struct _mesa_prim prim[VBO_MAX_PRIM]; GLuint prim_count; - GLfloat *buffer_map; - GLfloat *buffer_ptr; /* cursor, points into buffer */ + fi_type *buffer_map; + fi_type *buffer_ptr; /* cursor, points into buffer */ GLuint buffer_used; /* in bytes */ - GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current vertex */ + fi_type vertex[VBO_ATTRIB_MAX*4]; /* current vertex */ GLuint vert_count; GLuint max_vert; @@ -104,7 +105,7 @@ struct vbo_exec_context GLenum attrtype[VBO_ATTRIB_MAX]; GLubyte active_sz[VBO_ATTRIB_MAX]; - GLfloat *attrptr[VBO_ATTRIB_MAX]; + fi_type *attrptr[VBO_ATTRIB_MAX]; struct gl_client_array arrays[VERT_ATTRIB_MAX]; /* According to program mode, the values above plus current diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index 5f8250e78..9669abe7d 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -115,7 +115,7 @@ static void vbo_exec_wrap_buffers( struct vbo_exec_context *exec ) */ void vbo_exec_vtx_wrap( struct vbo_exec_context *exec ) { - GLfloat *data = exec->vtx.copied.buffer; + fi_type *data = exec->vtx.copied.buffer; GLuint i; /* Run pipeline on current vertices, copy wrapped vertices @@ -159,9 +159,9 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec ) * ctx->Current.Attrib and ctx->Light.Material.Attrib arrays. */ GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; + fi_type tmp[4]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, + COPY_CLEAN_4V_TYPE_AS_UNION(tmp, exec->vtx.attrsz[i], exec->vtx.attrptr[i], exec->vtx.attrtype[i]); @@ -214,7 +214,7 @@ vbo_exec_copy_from_current(struct vbo_exec_context *exec) GLint i; for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { - const GLfloat *current = (GLfloat *) vbo->currval[i].Ptr; + const fi_type *current = (fi_type *) vbo->currval[i].Ptr; switch (exec->vtx.attrsz[i]) { case 4: exec->vtx.attrptr[i][3] = current[3]; case 3: exec->vtx.attrptr[i][2] = current[2]; @@ -240,7 +240,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, struct gl_context *ctx = exec->ctx; struct vbo_context *vbo = vbo_context(ctx); const GLint lastcount = exec->vtx.vert_count; - GLfloat *old_attrptr[VBO_ATTRIB_MAX]; + fi_type *old_attrptr[VBO_ATTRIB_MAX]; const GLuint old_vtx_size = exec->vtx.vertex_size; /* floats per vertex */ const GLuint oldSize = exec->vtx.attrsz[attr]; GLuint i; @@ -287,7 +287,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, if (unlikely(oldSize)) { /* Size changed, recalculate all the attrptr[] values */ - GLfloat *tmp = exec->vtx.vertex; + fi_type *tmp = exec->vtx.vertex; for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { if (exec->vtx.attrsz[i]) { @@ -306,7 +306,7 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, else { /* Just have to append the new attribute at the end */ exec->vtx.attrptr[attr] = exec->vtx.vertex + - exec->vtx.vertex_size - newSize; + exec->vtx.vertex_size - newSize; } /* Replay stored vertices to translate them @@ -315,8 +315,8 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, * -- No need to replay - just copy piecewise */ if (unlikely(exec->vtx.copied.nr)) { - GLfloat *data = exec->vtx.copied.buffer; - GLfloat *dest = exec->vtx.buffer_ptr; + fi_type *data = exec->vtx.copied.buffer; + fi_type *dest = exec->vtx.buffer_ptr; GLuint j; assert(exec->vtx.buffer_ptr == exec->vtx.buffer_map); @@ -331,13 +331,13 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec, if (j == attr) { if (oldSize) { - GLfloat tmp[4]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, oldSize, + fi_type tmp[4]; + COPY_CLEAN_4V_TYPE_AS_UNION(tmp, oldSize, data + old_offset, exec->vtx.attrtype[j]); COPY_SZ_4V(dest + new_offset, newSize, tmp); } else { - GLfloat *current = (GLfloat *)vbo->currval[j].Ptr; + fi_type *current = (fi_type *)vbo->currval[j].Ptr; COPY_SZ_4V(dest + new_offset, sz, current); } } @@ -376,14 +376,14 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) } else if (newSize < exec->vtx.active_sz[attr]) { GLuint i; - const GLfloat *id = - vbo_get_default_vals_as_float(exec->vtx.attrtype[attr]); + const fi_type *id = + vbo_get_default_vals_as_union(exec->vtx.attrtype[attr]); /* New size is smaller - just need to fill in some * zeros. Don't need to flush or wrap. */ for (i = newSize; i <= exec->vtx.attrsz[attr]; i++) - exec->vtx.attrptr[attr][i-1] = id[i-1]; + exec->vtx.attrptr[attr][i-1] = id[i-1]; } exec->vtx.active_sz[attr] = newSize; @@ -401,7 +401,7 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize) * This macro is used to implement all the glVertex, glColor, glTexCoord, * glVertexAttrib, etc functions. */ -#define ATTR( A, N, T, V0, V1, V2, V3 ) \ +#define ATTR_UNION( A, N, T, V0, V1, V2, V3 ) \ do { \ struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \ \ @@ -412,12 +412,12 @@ do { \ vbo_exec_fixup_vertex(ctx, A, N); \ \ { \ - GLfloat *dest = exec->vtx.attrptr[A]; \ + fi_type *dest = exec->vtx.attrptr[A]; \ if (N>0) dest[0] = V0; \ if (N>1) dest[1] = V1; \ if (N>2) dest[2] = V2; \ if (N>3) dest[3] = V3; \ - exec->vtx.attrtype[A] = T; \ + exec->vtx.attrtype[A] = T; \ } \ \ if ((A) == 0) { \ @@ -1036,7 +1036,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) &exec->vtx.bufferobj, ctx->Shared->NullBufferObj); - ASSERT(!exec->vtx.buffer_map); + assert(!exec->vtx.buffer_map); exec->vtx.buffer_map = _mesa_align_malloc(VBO_VERT_BUFFER_SIZE, 64); exec->vtx.buffer_ptr = exec->vtx.buffer_map; @@ -1044,16 +1044,16 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) _mesa_noop_vtxfmt_init(&exec->vtxfmt_noop); for (i = 0 ; i < VBO_ATTRIB_MAX ; i++) { - ASSERT(i < Elements(exec->vtx.attrsz)); + assert(i < ARRAY_SIZE(exec->vtx.attrsz)); exec->vtx.attrsz[i] = 0; - ASSERT(i < Elements(exec->vtx.attrtype)); + assert(i < ARRAY_SIZE(exec->vtx.attrtype)); exec->vtx.attrtype[i] = GL_FLOAT; - ASSERT(i < Elements(exec->vtx.active_sz)); + assert(i < ARRAY_SIZE(exec->vtx.active_sz)); exec->vtx.active_sz[i] = 0; } for (i = 0 ; i < VERT_ATTRIB_MAX; i++) { - ASSERT(i < Elements(exec->vtx.inputs)); - ASSERT(i < Elements(exec->vtx.arrays)); + assert(i < ARRAY_SIZE(exec->vtx.inputs)); + assert(i < ARRAY_SIZE(exec->vtx.arrays)); exec->vtx.inputs[i] = &exec->vtx.arrays[i]; } @@ -1099,7 +1099,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) /* True VBOs should already be unmapped */ if (exec->vtx.buffer_map) { - ASSERT(exec->vtx.bufferobj->Name == 0 || + assert(exec->vtx.bufferobj->Name == 0 || exec->vtx.bufferobj->Name == IMM_BUFFER_NAME); if (exec->vtx.bufferobj->Name == 0) { _mesa_align_free(exec->vtx.buffer_map); @@ -1110,7 +1110,7 @@ void vbo_exec_vtx_destroy( struct vbo_exec_context *exec ) /* Drop any outstanding reference to the vertex buffer */ - for (i = 0; i < Elements(exec->vtx.arrays); i++) { + for (i = 0; i < ARRAY_SIZE(exec->vtx.arrays); i++) { _mesa_reference_buffer_object(ctx, &exec->vtx.arrays[i].BufferObj, NULL); diff --git a/mesalib/src/mesa/vbo/vbo_exec_array.c b/mesalib/src/mesa/vbo/vbo_exec_array.c index c16fe77ee..3ea775c0e 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_array.c +++ b/mesalib/src/mesa/vbo/vbo_exec_array.c @@ -26,6 +26,7 @@ * **************************************************************************/ +#include <stdio.h> #include "main/glheader.h" #include "main/context.h" #include "main/state.h" @@ -181,8 +182,7 @@ vbo_get_minmax_index(struct gl_context *ctx, break; } default: - assert(0); - break; + unreachable("not reached"); } if (_mesa_is_bufferobj(ib->obj)) { @@ -331,7 +331,7 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, } /* check element j of each enabled array */ - for (k = 0; k < Elements(vao->_VertexAttrib); k++) { + for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) { check_array_data(ctx, &vao->_VertexAttrib[k], k, j); } } @@ -341,7 +341,7 @@ check_draw_elements_data(struct gl_context *ctx, GLsizei count, GLenum elemType, MAP_INTERNAL); } - for (k = 0; k < Elements(vao->_VertexAttrib); k++) { + for (k = 0; k < ARRAY_SIZE(vao->_VertexAttrib); k++) { unmap_array_buffer(ctx, &vao->_VertexAttrib[k]); } } diff --git a/mesalib/src/mesa/vbo/vbo_exec_draw.c b/mesalib/src/mesa/vbo/vbo_exec_draw.c index 362cc1040..91f2ca43a 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_draw.c +++ b/mesalib/src/mesa/vbo/vbo_exec_draw.c @@ -25,6 +25,7 @@ * Keith Whitwell <keithw@vmware.com> */ +#include <stdio.h> #include "main/glheader.h" #include "main/bufferobj.h" #include "main/compiler.h" @@ -73,8 +74,8 @@ vbo_copy_vertices( struct vbo_exec_context *exec ) GLuint nr = exec->vtx.prim[exec->vtx.prim_count-1].count; GLuint ovf, i; GLuint sz = exec->vtx.vertex_size; - GLfloat *dst = exec->vtx.copied.buffer; - const GLfloat *src = (exec->vtx.buffer_map + + fi_type *dst = exec->vtx.copied.buffer; + const fi_type *src = (exec->vtx.buffer_map + exec->vtx.prim[exec->vtx.prim_count-1].start * exec->vtx.vertex_size); @@ -172,7 +173,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; } for (attr = 0; attr < MAT_ATTRIB_MAX; attr++) { - ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); + assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->currval[VBO_ATTRIB_MAT_FRONT_AMBIENT+attr]; } @@ -183,7 +184,7 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) exec->vtx.inputs[attr] = &vbo->currval[VBO_ATTRIB_POS+attr]; } for (attr = 0; attr < VERT_ATTRIB_GENERIC_MAX; attr++) { - ASSERT(VERT_ATTRIB_GENERIC(attr) < Elements(exec->vtx.inputs)); + assert(VERT_ATTRIB_GENERIC(attr) < ARRAY_SIZE(exec->vtx.inputs)); exec->vtx.inputs[VERT_ATTRIB_GENERIC(attr)] = &vbo->currval[VBO_ATTRIB_GENERIC0+attr]; } @@ -213,8 +214,8 @@ vbo_exec_bind_arrays( struct gl_context *ctx ) (GLbyte *)exec->vtx.vertex; /* override the default array set above */ - ASSERT(attr < Elements(exec->vtx.inputs)); - ASSERT(attr < Elements(exec->vtx.arrays)); /* arrays[] */ + assert(attr < ARRAY_SIZE(exec->vtx.inputs)); + assert(attr < ARRAY_SIZE(exec->vtx.arrays)); /* arrays[] */ exec->vtx.inputs[attr] = &arrays[attr]; if (_mesa_is_bufferobj(exec->vtx.bufferobj)) { @@ -309,7 +310,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec ) /* The VBO exists and there's room for more */ if (exec->vtx.bufferobj->Size > 0) { exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, + (fi_type *)ctx->Driver.MapBufferRange(ctx, exec->vtx.buffer_used, (VBO_VERT_BUFFER_SIZE - exec->vtx.buffer_used), @@ -336,7 +337,7 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec ) exec->vtx.bufferobj)) { /* buffer allocation worked, now map the buffer */ exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, + (fi_type *)ctx->Driver.MapBufferRange(ctx, 0, VBO_VERT_BUFFER_SIZE, accessRange, exec->vtx.bufferobj, diff --git a/mesalib/src/mesa/vbo/vbo_exec_eval.c b/mesalib/src/mesa/vbo/vbo_exec_eval.c index 82f89b95f..b26655bd5 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_eval.c +++ b/mesalib/src/mesa/vbo/vbo_exec_eval.c @@ -35,20 +35,20 @@ static void clear_active_eval1( struct vbo_exec_context *exec, GLuint attr ) { - assert(attr < Elements(exec->eval.map1)); + assert(attr < ARRAY_SIZE(exec->eval.map1)); exec->eval.map1[attr].map = NULL; } static void clear_active_eval2( struct vbo_exec_context *exec, GLuint attr ) { - assert(attr < Elements(exec->eval.map2)); + assert(attr < ARRAY_SIZE(exec->eval.map2)); exec->eval.map2[attr].map = NULL; } static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint dim, struct gl_1d_map *map ) { - assert(attr < Elements(exec->eval.map1)); + assert(attr < ARRAY_SIZE(exec->eval.map1)); if (!exec->eval.map1[attr].map) { exec->eval.map1[attr].map = map; exec->eval.map1[attr].sz = dim; @@ -58,7 +58,7 @@ static void set_active_eval1( struct vbo_exec_context *exec, GLuint attr, GLuint static void set_active_eval2( struct vbo_exec_context *exec, GLuint attr, GLuint dim, struct gl_2d_map *map ) { - assert(attr < Elements(exec->eval.map2)); + assert(attr < ARRAY_SIZE(exec->eval.map2)); if (!exec->eval.map2[attr].map) { exec->eval.map2[attr].map = map; exec->eval.map2[attr].sz = dim; @@ -130,11 +130,12 @@ void vbo_exec_do_EvalCoord1f(struct vbo_exec_context *exec, GLfloat u) struct gl_1d_map *map = exec->eval.map1[attr].map; if (map) { GLfloat uu = (u - map->u1) * map->du; - GLfloat data[4]; + fi_type data[4]; - ASSIGN_4V(data, 0, 0, 0, 1); + ASSIGN_4V(data, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0), + FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); - _math_horner_bezier_curve(map->Points, data, uu, + _math_horner_bezier_curve(map->Points, &data[0].f, uu, exec->eval.map1[attr].sz, map->Order); @@ -176,12 +177,13 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, if (map) { GLfloat uu = (u - map->u1) * map->du; GLfloat vv = (v - map->v1) * map->dv; - GLfloat data[4]; + fi_type data[4]; - ASSIGN_4V(data, 0, 0, 0, 1); + ASSIGN_4V(data, FLOAT_AS_UNION(0), FLOAT_AS_UNION(0), + FLOAT_AS_UNION(0), FLOAT_AS_UNION(1)); _math_horner_bezier_surf(map->Points, - data, + &data[0].f, uu, vv, exec->eval.map2[attr].sz, map->Uorder, map->Vorder); @@ -203,7 +205,7 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, ASSIGN_4V(vertex, 0, 0, 0, 1); if (exec->ctx->Eval.AutoNormal) { - GLfloat normal[4]; + fi_type normal[4]; GLfloat du[4], dv[4]; _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv, @@ -221,11 +223,11 @@ void vbo_exec_do_EvalCoord2f( struct vbo_exec_context *exec, } - CROSS3(normal, du, dv); - NORMALIZE_3FV(normal); - normal[3] = 1.0; + CROSS3(&normal[0].f, du, dv); + NORMALIZE_3FV(&normal[0].f); + normal[3] = FLOAT_AS_UNION(1.0); - COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL], + COPY_SZ_4V( exec->vtx.attrptr[VBO_ATTRIB_NORMAL], exec->vtx.attrsz[VBO_ATTRIB_NORMAL], normal ); diff --git a/mesalib/src/mesa/vbo/vbo_rebase.c b/mesalib/src/mesa/vbo/vbo_rebase.c index 82a0b8e2b..b06df4ab2 100644 --- a/mesalib/src/mesa/vbo/vbo_rebase.c +++ b/mesalib/src/mesa/vbo/vbo_rebase.c @@ -46,6 +46,7 @@ * of zero. */ +#include <stdio.h> #include "main/glheader.h" #include "main/imports.h" #include "main/mtypes.h" diff --git a/mesalib/src/mesa/vbo/vbo_save.h b/mesalib/src/mesa/vbo/vbo_save.h index fd26b5f61..5b1ac8177 100644 --- a/mesalib/src/mesa/vbo/vbo_save.h +++ b/mesalib/src/mesa/vbo/vbo_save.h @@ -40,7 +40,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. struct vbo_save_copied_vtx { - GLfloat buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; + fi_type buffer[VBO_ATTRIB_MAX * 4 * VBO_MAX_COPIED_VERTS]; GLuint nr; }; @@ -69,7 +69,7 @@ struct vbo_save_vertex_list { * Keep this in regular (non-VBO) memory to avoid repeated * map/unmap of the VBO when updating GL current data. */ - GLfloat *current_data; + fi_type *current_data; GLuint current_size; GLuint buffer_offset; @@ -107,7 +107,7 @@ struct vbo_save_vertex_list { */ struct vbo_save_vertex_store { struct gl_buffer_object *bufferobj; - GLfloat *buffer; + fi_type *buffer; GLuint used; GLuint refcount; }; @@ -133,7 +133,7 @@ struct vbo_save_context { GLboolean out_of_memory; /**< True if last VBO allocation failed */ - GLfloat *buffer; + fi_type *buffer; GLuint count; GLuint wrap_count; GLuint replay_flags; @@ -144,9 +144,9 @@ struct vbo_save_context { struct vbo_save_vertex_store *vertex_store; struct vbo_save_primitive_store *prim_store; - GLfloat *buffer_ptr; /* cursor, points into buffer */ - GLfloat vertex[VBO_ATTRIB_MAX*4]; /* current values */ - GLfloat *attrptr[VBO_ATTRIB_MAX]; + fi_type *buffer_ptr; /* cursor, points into buffer */ + fi_type vertex[VBO_ATTRIB_MAX*4]; /* current values */ + fi_type *attrptr[VBO_ATTRIB_MAX]; GLuint vert_count; GLuint max_vert; GLboolean dangling_attr_ref; @@ -155,7 +155,7 @@ struct vbo_save_context { struct vbo_save_copied_vtx copied; - GLfloat *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ + fi_type *current[VBO_ATTRIB_MAX]; /* points into ctx->ListState */ GLubyte *currentsz[VBO_ATTRIB_MAX]; }; @@ -186,7 +186,7 @@ void vbo_save_playback_vertex_list( struct gl_context *ctx, void *data ); void vbo_save_api_init( struct vbo_save_context *save ); -GLfloat * +fi_type * vbo_save_map_vertex_store(struct gl_context *ctx, struct vbo_save_vertex_store *vertex_store); diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c index beef342be..fd9a5de3d 100644 --- a/mesalib/src/mesa/vbo/vbo_save_api.c +++ b/mesalib/src/mesa/vbo/vbo_save_api.c @@ -99,14 +99,14 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. static GLuint _save_copy_vertices(struct gl_context *ctx, const struct vbo_save_vertex_list *node, - const GLfloat * src_buffer) + const fi_type * src_buffer) { struct vbo_save_context *save = &vbo_context(ctx)->save; const struct _mesa_prim *prim = &node->prim[node->prim_count - 1]; GLuint nr = prim->count; GLuint sz = save->vertex_size; - const GLfloat *src = src_buffer + prim->start * sz; - GLfloat *dst = save->copied.buffer; + const fi_type *src = src_buffer + prim->start * sz; + fi_type *dst = save->copied.buffer; GLuint ovf, i; if (prim->end) @@ -233,7 +233,7 @@ free_vertex_store(struct gl_context *ctx, } -GLfloat * +fi_type * vbo_save_map_vertex_store(struct gl_context *ctx, struct vbo_save_vertex_store *vertex_store) { @@ -249,7 +249,7 @@ vbo_save_map_vertex_store(struct gl_context *ctx, /* Map the remaining free space in the VBO */ GLintptr offset = vertex_store->used * sizeof(GLfloat); GLsizeiptr size = vertex_store->bufferobj->Size - offset; - GLfloat *range = (GLfloat *) + fi_type *range = (fi_type *) ctx->Driver.MapBufferRange(ctx, offset, size, access, vertex_store->bufferobj, MAP_INTERNAL); @@ -549,7 +549,7 @@ static void _save_wrap_filled_vertex(struct gl_context *ctx) { struct vbo_save_context *save = &vbo_context(ctx)->save; - GLfloat *data = save->copied.buffer; + fi_type *data = save->copied.buffer; GLuint i; /* Emit a glEnd to close off the last vertex list. @@ -578,7 +578,7 @@ _save_copy_to_current(struct gl_context *ctx) for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) { if (save->attrsz[i]) { save->currentsz[i][0] = save->attrsz[i]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(save->current[i], save->attrsz[i], + COPY_CLEAN_4V_TYPE_AS_UNION(save->current[i], save->attrsz[i], save->attrptr[i], save->attrtype[i]); } } @@ -620,7 +620,7 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) struct vbo_save_context *save = &vbo_context(ctx)->save; GLuint oldsz; GLuint i; - GLfloat *tmp; + fi_type *tmp; /* Store the current run of vertices, and emit a GL_END. Emit a * BEGIN in the new buffer. @@ -669,8 +669,8 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) * and will need fixup at runtime. */ if (save->copied.nr) { - const GLfloat *data = save->copied.buffer; - GLfloat *dest = save->buffer; + const fi_type *data = save->copied.buffer; + fi_type *dest = save->buffer; GLuint j; /* Need to note this and fix up at runtime (or loopback): @@ -685,7 +685,7 @@ _save_upgrade_vertex(struct gl_context *ctx, GLuint attr, GLuint newsz) if (save->attrsz[j]) { if (j == attr) { if (oldsz) { - COPY_CLEAN_4V_TYPE_AS_FLOAT(dest, oldsz, data, + COPY_CLEAN_4V_TYPE_AS_UNION(dest, oldsz, data, save->attrtype[j]); data += oldsz; dest += newsz; @@ -729,7 +729,7 @@ save_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint sz) } else if (sz < save->active_sz[attr]) { GLuint i; - const GLfloat *id = vbo_get_default_vals_as_float(save->attrtype[attr]); + const fi_type *id = vbo_get_default_vals_as_union(save->attrtype[attr]); /* New size is equal or smaller - just need to fill in some * zeros. @@ -772,7 +772,7 @@ _save_reset_vertex(struct gl_context *ctx) * 3f version won't otherwise set color[3] to 1.0 -- this is the job * of the chooser function when switching between Color4f and Color3f. */ -#define ATTR(A, N, T, V0, V1, V2, V3) \ +#define ATTR_UNION(A, N, T, V0, V1, V2, V3) \ do { \ struct vbo_save_context *save = &vbo_context(ctx)->save; \ \ @@ -780,12 +780,12 @@ do { \ save_fixup_vertex(ctx, A, N); \ \ { \ - GLfloat *dest = save->attrptr[A]; \ + fi_type *dest = save->attrptr[A]; \ if (N>0) dest[0] = V0; \ if (N>1) dest[1] = V1; \ if (N>2) dest[2] = V2; \ if (N>3) dest[3] = V3; \ - save->attrtype[A] = T; \ + save->attrtype[A] = T; \ } \ \ if ((A) == 0) { \ @@ -1564,16 +1564,16 @@ _save_current_init(struct gl_context *ctx) for (i = VBO_ATTRIB_POS; i <= VBO_ATTRIB_GENERIC15; i++) { const GLuint j = i - VBO_ATTRIB_POS; - ASSERT(j < VERT_ATTRIB_MAX); + assert(j < VERT_ATTRIB_MAX); save->currentsz[i] = &ctx->ListState.ActiveAttribSize[j]; - save->current[i] = ctx->ListState.CurrentAttrib[j]; + save->current[i] = (fi_type *) ctx->ListState.CurrentAttrib[j]; } for (i = VBO_ATTRIB_FIRST_MATERIAL; i <= VBO_ATTRIB_LAST_MATERIAL; i++) { const GLuint j = i - VBO_ATTRIB_FIRST_MATERIAL; - ASSERT(j < MAT_ATTRIB_MAX); + assert(j < MAT_ATTRIB_MAX); save->currentsz[i] = &ctx->ListState.ActiveMaterialSize[j]; - save->current[i] = ctx->ListState.CurrentMaterial[j]; + save->current[i] = (fi_type *) ctx->ListState.CurrentMaterial[j]; } } diff --git a/mesalib/src/mesa/vbo/vbo_save_draw.c b/mesalib/src/mesa/vbo/vbo_save_draw.c index d0521d794..74e266d19 100644 --- a/mesalib/src/mesa/vbo/vbo_save_draw.c +++ b/mesalib/src/mesa/vbo/vbo_save_draw.c @@ -47,8 +47,8 @@ _playback_copy_to_current(struct gl_context *ctx, const struct vbo_save_vertex_list *node) { struct vbo_context *vbo = vbo_context(ctx); - GLfloat vertex[VBO_ATTRIB_MAX * 4]; - GLfloat *data; + fi_type vertex[VBO_ATTRIB_MAX * 4]; + fi_type *data; GLuint i, offset; if (node->current_size == 0) @@ -75,10 +75,10 @@ _playback_copy_to_current(struct gl_context *ctx, for (i = VBO_ATTRIB_POS+1 ; i < VBO_ATTRIB_MAX ; i++) { if (node->attrsz[i]) { - GLfloat *current = (GLfloat *)vbo->currval[i].Ptr; - GLfloat tmp[4]; + fi_type *current = (fi_type *)vbo->currval[i].Ptr; + fi_type tmp[4]; - COPY_CLEAN_4V_TYPE_AS_FLOAT(tmp, + COPY_CLEAN_4V_TYPE_AS_UNION(tmp, node->attrsz[i], data, node->attrtype[i]); diff --git a/mesalib/src/mesa/vbo/vbo_save_loopback.c b/mesalib/src/mesa/vbo/vbo_save_loopback.c index 8c93ae86a..7410f1875 100644 --- a/mesalib/src/mesa/vbo/vbo_save_loopback.c +++ b/mesalib/src/mesa/vbo/vbo_save_loopback.c @@ -25,6 +25,7 @@ * **************************************************************************/ +#include <stdio.h> #include "main/context.h" #include "main/glheader.h" #include "main/enums.h" diff --git a/mesalib/src/mesa/vbo/vbo_split_copy.c b/mesalib/src/mesa/vbo/vbo_split_copy.c index ca752e810..d1107dd84 100644 --- a/mesalib/src/mesa/vbo/vbo_split_copy.c +++ b/mesalib/src/mesa/vbo/vbo_split_copy.c @@ -29,6 +29,8 @@ /* Split indexed primitives with per-vertex copying. */ +#include <stdio.h> + #include "main/glheader.h" #include "main/bufferobj.h" #include "main/imports.h" diff --git a/mesalib/src/mesa/x86/common_x86.c b/mesalib/src/mesa/x86/common_x86.c index 25f5c40e2..14b497d06 100644 --- a/mesalib/src/mesa/x86/common_x86.c +++ b/mesalib/src/mesa/x86/common_x86.c @@ -344,13 +344,13 @@ _mesa_get_x86_features(void) #elif defined(USE_X86_64_ASM) { - unsigned int uninitialized_var(eax), uninitialized_var(ebx), - uninitialized_var(ecx), uninitialized_var(edx); + unsigned int eax, ebx, ecx, edx; /* Always available on x86-64. */ _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2; - __get_cpuid(1, &eax, &ebx, &ecx, &edx); + if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) + return; if (ecx & bit_SSE4_1) _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1; diff --git a/mesalib/src/mesa/x86/gen_matypes.c b/mesalib/src/mesa/x86/gen_matypes.c index 1e904aa0b..18ffb728a 100644 --- a/mesalib/src/mesa/x86/gen_matypes.c +++ b/mesalib/src/mesa/x86/gen_matypes.c @@ -35,6 +35,8 @@ #ifndef __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS #endif + +#include <stdio.h> #include <inttypes.h> #include "main/glheader.h" |