diff options
author | marha <marha@users.sourceforge.net> | 2011-11-14 09:42:43 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2011-11-14 09:42:43 +0100 |
commit | 93795f7d8ca73dd428a926901cbc632015ac0cf5 (patch) | |
tree | 3fdcae64c6a51d6512aa32387846a2f282439855 /mesalib | |
parent | 00ea126522f5bbf5c4600ddb93a45b260475c8c1 (diff) | |
parent | 156e37d3879b316329e3e05579414031da2647e2 (diff) | |
download | vcxsrv-93795f7d8ca73dd428a926901cbc632015ac0cf5.tar.gz vcxsrv-93795f7d8ca73dd428a926901cbc632015ac0cf5.tar.bz2 vcxsrv-93795f7d8ca73dd428a926901cbc632015ac0cf5.zip |
Merge remote-tracking branch 'origin/released'
Conflicts:
libX11/src/util/makekeys.c
Diffstat (limited to 'mesalib')
27 files changed, 1093 insertions, 1344 deletions
diff --git a/mesalib/bin/mklib b/mesalib/bin/mklib index fd87aad42..70bd1a27a 100644 --- a/mesalib/bin/mklib +++ b/mesalib/bin/mklib @@ -260,7 +260,7 @@ if [ $STATIC = 1 ]; then NEWOBJECTS="" for OBJ in $OBJECTS ; do case $OBJ in - -Wl,*) + -Wl,*|-L*|-l*) echo "mklib: warning: ignoring $OBJ for static library" ;; *) diff --git a/mesalib/docs/viewperf.html b/mesalib/docs/viewperf.html index cef584fd8..bb3852734 100644 --- a/mesalib/docs/viewperf.html +++ b/mesalib/docs/viewperf.html @@ -34,6 +34,19 @@ they'll be fixed in the future. +<h2>Catia-03 test 2</h2> + +<p> +This test creates over 38000 vertex buffer objects. On some systems +this can exceed the maximum number of buffer allocations. Mesa +generates GL_OUT_OF_MEMORY errors in this situation, but Viewperf +does no error checking and continues. When this happens, some drawing +commands become no-ops. This can also eventually lead to a segfault +either in Viewperf or the Mesa driver. +</p> + + + <h2>Catia-03 tests 3, 4, 8</h2> <p> diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c index 6a4324bc2..3a0d7d424 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blit.c +++ b/mesalib/src/gallium/auxiliary/util/u_blit.c @@ -286,8 +286,10 @@ setup_vertex_data_tex(struct blit_state *ctx, offset = get_next_slot( ctx ); - pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf, - offset, sizeof(ctx->vertices), ctx->vertices); + if (ctx->vbuf) { + pipe_buffer_write_nooverlap(ctx->pipe, ctx->vbuf, + offset, sizeof(ctx->vertices), ctx->vertices); + } return offset; } @@ -599,10 +601,12 @@ util_blit_pixels_writemask(struct blit_state *ctx, s1, t1, z); - util_draw_vertex_buffer(ctx->pipe, ctx->cso, ctx->vbuf, offset, - PIPE_PRIM_TRIANGLE_FAN, - 4, /* verts */ - 2); /* attribs/vert */ + if (ctx->vbuf) { + util_draw_vertex_buffer(ctx->pipe, ctx->cso, ctx->vbuf, offset, + PIPE_PRIM_TRIANGLE_FAN, + 4, /* verts */ + 2); /* attribs/vert */ + } /* restore state we changed */ cso_restore_blend(ctx->cso); diff --git a/mesalib/src/gallium/auxiliary/util/u_format_pack.py b/mesalib/src/gallium/auxiliary/util/u_format_pack.py index 5cfbe323d..14a504944 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_pack.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_pack.py @@ -150,6 +150,11 @@ def is_format_pure_signed(format): def native_type(format): '''Get the native appropriate for a format.''' + if format.name == 'PIPE_FORMAT_R11G11B10_FLOAT': + return 'uint32_t' + if format.name == 'PIPE_FORMAT_R9G9B9E5_FLOAT': + return 'uint32_t' + if format.layout == PLAIN: if not format.is_array(): # For arithmetic pixel formats return the integer type that matches the whole pixel diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources index b4bfff09c..c65bfe4ff 100644 --- a/mesalib/src/glsl/Makefile.sources +++ b/mesalib/src/glsl/Makefile.sources @@ -20,6 +20,7 @@ LIBGLSL_CXX_SOURCES := \ ast_function.cpp \ ast_to_hir.cpp \ ast_type.cpp \ + builtin_variables.cpp \ glsl_parser_extras.cpp \ glsl_types.cpp \ glsl_symbol_table.cpp \ @@ -40,7 +41,6 @@ LIBGLSL_CXX_SOURCES := \ ir_rvalue_visitor.cpp \ ir_set_program_inouts.cpp \ ir_validate.cpp \ - ir_variable.cpp \ ir_variable_refcount.cpp \ linker.cpp \ link_functions.cpp \ diff --git a/mesalib/src/glsl/ir_variable.cpp b/mesalib/src/glsl/builtin_variables.cpp index 3092507bc..ed6b922ca 100644 --- a/mesalib/src/glsl/ir_variable.cpp +++ b/mesalib/src/glsl/builtin_variables.cpp @@ -24,7 +24,7 @@ #include "ir.h" #include "glsl_parser_extras.h" #include "glsl_symbol_table.h" -#include "builtin_variables.h" +#include "main/core.h" #include "main/uniforms.h" #include "program/prog_parameter.h" #include "program/prog_statevars.h" @@ -39,6 +39,91 @@ generate_ARB_draw_instanced_variables(exec_list *, struct _mesa_glsl_parse_state *, bool, _mesa_glsl_parser_targets); +struct builtin_variable { + enum ir_variable_mode mode; + int slot; + const char *type; + const char *name; +}; + +static const builtin_variable builtin_core_vs_variables[] = { + { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" }, + { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" }, +}; + +static const builtin_variable builtin_core_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" }, + { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" }, + { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, +}; + +static const builtin_variable builtin_100ES_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, +}; + +static const builtin_variable builtin_110_fs_variables[] = { + { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, +}; + +static const builtin_variable builtin_110_deprecated_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" }, + { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" }, +}; + +static const builtin_variable builtin_110_deprecated_vs_variables[] = { + { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, + { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, + { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, + { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, + { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, + { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, + { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, + { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, + { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, + { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, + { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, + { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, + { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, + { ir_var_out, VERT_RESULT_CLIP_VERTEX, "vec4", "gl_ClipVertex" }, + { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" }, + { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" }, + { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" }, + { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" }, + { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, +}; + +static const builtin_variable builtin_120_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, +}; + +static const builtin_variable builtin_130_vs_variables[] = { + { ir_var_system_value, SYSTEM_VALUE_VERTEX_ID, "int", "gl_VertexID" }, +}; + +static const builtin_variable builtin_110_deprecated_uniforms[] = { + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, + { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, + { ir_var_uniform, -1, "float", "gl_NormalScale" }, + { ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"}, + + /* Mesa-internal ATI_envmap_bumpmap state. */ + { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix0MESA"}, + { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix1MESA"}, + { ir_var_uniform, -1, "vec4", "gl_FogParamsOptimizedMESA"}, +}; + static struct gl_builtin_uniform_element gl_DepthRange_elements[] = { {"near", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_XXXX}, {"far", {STATE_DEPTH_RANGE, 0, 0}, SWIZZLE_YYYY}, diff --git a/mesalib/src/glsl/builtin_variables.h b/mesalib/src/glsl/builtin_variables.h deleted file mode 100644 index 237b361d8..000000000 --- a/mesalib/src/glsl/builtin_variables.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright © 2010 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - */ - -#include "main/core.h" /* for slot numbers */ - -struct builtin_variable { - enum ir_variable_mode mode; - int slot; - const char *type; - const char *name; -}; - -static const builtin_variable builtin_core_vs_variables[] = { - { ir_var_out, VERT_RESULT_HPOS, "vec4", "gl_Position" }, - { ir_var_out, VERT_RESULT_PSIZ, "float", "gl_PointSize" }, -}; - -static const builtin_variable builtin_core_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_WPOS, "vec4", "gl_FragCoord" }, - { ir_var_in, FRAG_ATTRIB_FACE, "bool", "gl_FrontFacing" }, - { ir_var_out, FRAG_RESULT_COLOR, "vec4", "gl_FragColor" }, -}; - -static const builtin_variable builtin_100ES_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, -}; - -static const builtin_variable builtin_110_fs_variables[] = { - { ir_var_out, FRAG_RESULT_DEPTH, "float", "gl_FragDepth" }, -}; - -static const builtin_variable builtin_110_deprecated_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_COL0, "vec4", "gl_Color" }, - { ir_var_in, FRAG_ATTRIB_COL1, "vec4", "gl_SecondaryColor" }, - { ir_var_in, FRAG_ATTRIB_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_110_deprecated_vs_variables[] = { - { ir_var_in, VERT_ATTRIB_POS, "vec4", "gl_Vertex" }, - { ir_var_in, VERT_ATTRIB_NORMAL, "vec3", "gl_Normal" }, - { ir_var_in, VERT_ATTRIB_COLOR0, "vec4", "gl_Color" }, - { ir_var_in, VERT_ATTRIB_COLOR1, "vec4", "gl_SecondaryColor" }, - { ir_var_in, VERT_ATTRIB_TEX0, "vec4", "gl_MultiTexCoord0" }, - { ir_var_in, VERT_ATTRIB_TEX1, "vec4", "gl_MultiTexCoord1" }, - { ir_var_in, VERT_ATTRIB_TEX2, "vec4", "gl_MultiTexCoord2" }, - { ir_var_in, VERT_ATTRIB_TEX3, "vec4", "gl_MultiTexCoord3" }, - { ir_var_in, VERT_ATTRIB_TEX4, "vec4", "gl_MultiTexCoord4" }, - { ir_var_in, VERT_ATTRIB_TEX5, "vec4", "gl_MultiTexCoord5" }, - { ir_var_in, VERT_ATTRIB_TEX6, "vec4", "gl_MultiTexCoord6" }, - { ir_var_in, VERT_ATTRIB_TEX7, "vec4", "gl_MultiTexCoord7" }, - { ir_var_in, VERT_ATTRIB_FOG, "float", "gl_FogCoord" }, - { ir_var_out, VERT_RESULT_CLIP_VERTEX, "vec4", "gl_ClipVertex" }, - { ir_var_out, VERT_RESULT_COL0, "vec4", "gl_FrontColor" }, - { ir_var_out, VERT_RESULT_BFC0, "vec4", "gl_BackColor" }, - { ir_var_out, VERT_RESULT_COL1, "vec4", "gl_FrontSecondaryColor" }, - { ir_var_out, VERT_RESULT_BFC1, "vec4", "gl_BackSecondaryColor" }, - { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, -}; - -static const builtin_variable builtin_120_fs_variables[] = { - { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, -}; - -static const builtin_variable builtin_130_vs_variables[] = { - { ir_var_in, -1, "int", "gl_VertexID" }, -}; - -static const builtin_variable builtin_110_deprecated_uniforms[] = { - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrix" }, - { ir_var_uniform, -1, "mat3", "gl_NormalMatrix" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverse" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "mat4", "gl_ModelViewProjectionMatrixInverseTranspose" }, - { ir_var_uniform, -1, "float", "gl_NormalScale" }, - { ir_var_uniform, -1, "gl_LightModelParameters", "gl_LightModel"}, - - /* Mesa-internal ATI_envmap_bumpmap state. */ - { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix0MESA"}, - { ir_var_uniform, -1, "vec2", "gl_BumpRotMatrix1MESA"}, - { ir_var_uniform, -1, "vec4", "gl_FogParamsOptimizedMESA"}, -}; - diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y index 1b17ff43a..c0457b057 100644 --- a/mesalib/src/glsl/glcpp/glcpp-parse.y +++ b/mesalib/src/glsl/glcpp/glcpp-parse.y @@ -1132,6 +1132,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) if (extensions->ARB_shader_texture_lod) add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1); + if (extensions->ARB_draw_instanced) + add_builtin_define(parser, "GL_ARB_draw_instanced", 1); + if (extensions->AMD_conservative_depth) { add_builtin_define(parser, "GL_AMD_conservative_depth", 1); add_builtin_define(parser, "GL_ARB_conservative_depth", 1); diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp index 492be325f..adca62e8d 100644 --- a/mesalib/src/glsl/ir_constant_expression.cpp +++ b/mesalib/src/glsl/ir_constant_expression.cpp @@ -713,6 +713,9 @@ ir_expression::constant_expression_value() case GLSL_TYPE_FLOAT: data.b[c] = op[0]->value.f[c] == op[1]->value.f[c]; break; + case GLSL_TYPE_BOOL: + data.b[c] = op[0]->value.b[c] == op[1]->value.b[c]; + break; default: assert(0); } @@ -731,6 +734,9 @@ ir_expression::constant_expression_value() case GLSL_TYPE_FLOAT: data.b[c] = op[0]->value.f[c] != op[1]->value.f[c]; break; + case GLSL_TYPE_BOOL: + data.b[c] = op[0]->value.b[c] != op[1]->value.b[c]; + break; default: assert(0); } diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index 8f978097c..3e42bfd8b 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -40,7 +40,6 @@ main_sources = [ 'main/api_arrayelt.c', 'main/api_exec.c', 'main/api_loopback.c', - 'main/api_noop.c', 'main/api_validate.c', 'main/accum.c', 'main/arbprogram.c', @@ -214,6 +213,7 @@ vbo_sources = [ 'vbo/vbo_exec_array.c', 'vbo/vbo_exec_draw.c', 'vbo/vbo_exec_eval.c', + 'vbo/vbo_noop.c', 'vbo/vbo_rebase.c', 'vbo/vbo_split.c', 'vbo/vbo_split_copy.c', diff --git a/mesalib/src/mesa/main/api_noop.c b/mesalib/src/mesa/main/api_noop.c deleted file mode 100644 index c4ac95c98..000000000 --- a/mesalib/src/mesa/main/api_noop.c +++ /dev/null @@ -1,1089 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.1 - * - * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#include "glheader.h" -#include "api_noop.h" -#include "api_validate.h" -#include "api_arrayelt.h" -#include "context.h" -#include "light.h" -#include "macros.h" -#include "mfeatures.h" -#include "dlist.h" -#include "eval.h" -#include "main/dispatch.h" - - -/** - * \file - * Just update the ctx->Current vertex attributes. - * These functions are used when outside glBegin/glEnd or outside display - * lists. - */ - - -#if FEATURE_beginend - - -static void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b ) -{ - GET_CURRENT_CONTEXT(ctx); - ctx->Current.Attrib[VERT_ATTRIB_EDGEFLAG][0] = (GLfloat)b; -} - -static void GLAPIENTRY _mesa_noop_Indexf( GLfloat f ) -{ - GET_CURRENT_CONTEXT(ctx); - ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = f; -} - -static void GLAPIENTRY _mesa_noop_Indexfv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - ctx->Current.Attrib[VERT_ATTRIB_COLOR_INDEX][0] = *v; -} - -static void GLAPIENTRY _mesa_noop_FogCoordfEXT( GLfloat a ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG]; - dest[0] = a; - dest[1] = 0.0; - dest[2] = 0.0; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_FogCoordfvEXT( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG]; - dest[0] = v[0]; - dest[1] = 0.0; - dest[2] = 0.0; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Normal3fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = a; - color[1] = b; - color[2] = c; - color[3] = d; -} - -static void GLAPIENTRY _mesa_noop_Color4fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = v[0]; - color[1] = v[1]; - color[2] = v[2]; - color[3] = v[3]; -} - -static void GLAPIENTRY _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = a; - color[1] = b; - color[2] = c; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_Color3fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; - color[0] = v[0]; - color[1] = v[1]; - color[2] = v[2]; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = b; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = 0; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = 1; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b, - GLfloat c, GLfloat d ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = d; - } -} - -static void GLAPIENTRY _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLuint unit = target - GL_TEXTURE0_ARB; - - /* unit is unsigned -- cannot be less than zero. - */ - if (unit < MAX_TEXTURE_COORD_UNITS) - { - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = v[3]; - } -} - -static void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - color[0] = a; - color[1] = b; - color[2] = c; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1]; - color[0] = v[0]; - color[1] = v[1]; - color[2] = v[2]; - color[3] = 1.0; -} - -static void GLAPIENTRY _mesa_noop_TexCoord1f( GLfloat a ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord1fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = 0; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord2f( GLfloat a, GLfloat b ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = b; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord2fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = 0; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord3fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = 1; -} - -static void GLAPIENTRY _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = a; - dest[1] = b; - dest[2] = c; - dest[3] = d; -} - -static void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - dest[0] = v[0]; - dest[1] = v[1]; - dest[2] = v[2]; - dest[3] = v[3]; -} - - -/** - * GL_NV_vertex_program attributes. - * Note that these attributes alias the conventional vertex attributes. - */ - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x, - GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, - GLfloat y, GLfloat z, GLfloat w ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fNV(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_NV_VERTEX_PROGRAM_INPUTS) { - ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvNV(index)" ); -} - - - -/** - * GL_ARB_vertex_program attributes. - * Note that these attributes DO NOT alias the conventional vertex attributes. - */ - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], 0, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib1fvARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], 0, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib2fvARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, - GLfloat y, GLfloat z ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], 1); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib3fvARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, - GLfloat y, GLfloat z, GLfloat w ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], x, y, z, w); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fARB(index)" ); -} - -static void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v ) -{ - GET_CURRENT_CONTEXT(ctx); - if (index < MAX_VERTEX_GENERIC_ATTRIBS) { - ASSIGN_4V(ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index], v[0], v[1], v[2], v[3]); - } - else - _mesa_error( ctx, GL_INVALID_VALUE, "glVertexAttrib4fvARB(index)" ); -} - - - -/** - * Called by glMaterial*() - */ -void GLAPIENTRY -_mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i, nr; - struct gl_material *mat = &ctx->Light.Material; - GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, - "_mesa_noop_Materialfv" ); - - if (ctx->Light.ColorMaterialEnabled) - bitmask &= ~ctx->Light.ColorMaterialBitmask; - - if (bitmask == 0) - return; - - switch (pname) { - case GL_SHININESS: nr = 1; break; - case GL_COLOR_INDEXES: nr = 3; break; - default: nr = 4 ; break; - } - - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (bitmask & (1<<i)) - COPY_SZ_4V( mat->Attrib[i], nr, params ); - - _mesa_update_material( ctx, bitmask ); -} - - -/** - * These really are noops outside begin/end: - */ -static void GLAPIENTRY _mesa_noop_Vertex2fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_Vertex3fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_Vertex4fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_Vertex2f( GLfloat a, GLfloat b ) -{ - (void) a; (void) b; -} - -static void GLAPIENTRY _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c ) -{ - (void) a; (void) b; (void) c; -} - -static void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d ) -{ - (void) a; (void) b; (void) c; (void) d; -} - - -#if FEATURE_evaluators -/* Similarly, these have no effect outside begin/end: - */ -static void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a ) -{ - (void) a; -} - -static void GLAPIENTRY _mesa_noop_EvalCoord1fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_EvalCoord2f( GLfloat a, GLfloat b ) -{ - (void) a; (void) b; -} - -static void GLAPIENTRY _mesa_noop_EvalCoord2fv( const GLfloat *v ) -{ - (void) v; -} - -static void GLAPIENTRY _mesa_noop_EvalPoint1( GLint a ) -{ - (void) a; -} - -static void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b ) -{ - (void) a; (void) b; -} -#endif /* FEATURE_evaluators */ - - -/* Begin -- call into driver, should result in the vtxfmt being - * swapped out: - */ -static void GLAPIENTRY _mesa_noop_Begin( GLenum mode ) -{ - (void) mode; -} - - -/* End -- just raise an error - */ -static void GLAPIENTRY _mesa_noop_End( void ) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd(no glBegin)" ); -} - - -/*** - * PrimitiveRestart called outside glBegin()/End(): raise an error - */ -static void GLAPIENTRY _mesa_noop_PrimitiveRestartNV( void ) -{ - GET_CURRENT_CONTEXT(ctx); - _mesa_error(ctx, GL_INVALID_OPERATION, "glPrimitiveRestartNV(no glBegin)"); -} - - -/** - * Execute a glRectf() function. This is not suitable for GL_COMPILE - * modes (as the test for outside begin/end is not compiled), - * but may be useful for drivers in circumstances which exclude - * display list interactions. - * - * (None of the functions in this file are suitable for GL_COMPILE - * modes). - */ -void GLAPIENTRY -_mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) -{ - { - GET_CURRENT_CONTEXT(ctx); - ASSERT_OUTSIDE_BEGIN_END(ctx); - } - - CALL_Begin(GET_DISPATCH(), (GL_QUADS)); - CALL_Vertex2f(GET_DISPATCH(), (x1, y1)); - CALL_Vertex2f(GET_DISPATCH(), (x2, y1)); - CALL_Vertex2f(GET_DISPATCH(), (x2, y2)); - CALL_Vertex2f(GET_DISPATCH(), (x1, y2)); - CALL_End(GET_DISPATCH(), ()); -} - - -/** - * Some very basic support for arrays. Drivers without explicit array - * support can hook these in, but still need to supply an array-elt - * implementation. - */ -static void GLAPIENTRY -_mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawArrays( ctx, mode, start, count )) - return; - - CALL_Begin(GET_DISPATCH(), (mode)); - for (i = 0; i < count; i++) - CALL_ArrayElement(GET_DISPATCH(), (start + i)); - CALL_End(GET_DISPATCH(), ()); -} - - -static void GLAPIENTRY -_mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, 0 )) - return; - - CALL_Begin(GET_DISPATCH(), (mode)); - - switch (type) { - case GL_UNSIGNED_BYTE: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] )); - break; - case GL_UNSIGNED_SHORT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] )); - break; - case GL_UNSIGNED_INT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] )); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" ); - break; - } - - CALL_End(GET_DISPATCH(), ()); -} - -static void GLAPIENTRY -_mesa_noop_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - - if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices, - basevertex )) - return; - - CALL_Begin(GET_DISPATCH(), (mode)); - - switch (type) { - case GL_UNSIGNED_BYTE: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] + - basevertex)); - break; - case GL_UNSIGNED_SHORT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] + - basevertex )); - break; - case GL_UNSIGNED_INT: - for (i = 0 ; i < count ; i++) - CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] + - basevertex )); - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElementsBaseVertex(type)" ); - break; - } - - CALL_End(GET_DISPATCH(), ()); -} - - -static void GLAPIENTRY -_mesa_noop_DrawRangeElements(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices) -{ - GET_CURRENT_CONTEXT(ctx); - - if (_mesa_validate_DrawRangeElements( ctx, mode, - start, end, - count, type, indices, 0 )) - CALL_DrawElements(GET_DISPATCH(), (mode, count, type, indices)); -} - -/* GL_EXT_multi_draw_arrays */ -void GLAPIENTRY -_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, - const GLvoid **indices, GLsizei primcount) -{ - GLsizei i; - - for (i = 0; i < primcount; i++) { - if (count[i] > 0) { - CALL_DrawElements(GET_DISPATCH(), (mode, count[i], type, indices[i])); - } - } -} - -static void GLAPIENTRY -_mesa_noop_DrawRangeElementsBaseVertex(GLenum mode, - GLuint start, GLuint end, - GLsizei count, GLenum type, - const GLvoid *indices, GLint basevertex) -{ - GET_CURRENT_CONTEXT(ctx); - - if (_mesa_validate_DrawRangeElements( ctx, mode, - start, end, - count, type, indices, basevertex )) - CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count, type, indices, - basevertex)); -} - -/* GL_EXT_multi_draw_arrays */ -void GLAPIENTRY -_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, - GLenum type, - const GLvoid **indices, - GLsizei primcount, - const GLint *basevertex) -{ - GLsizei i; - - for (i = 0; i < primcount; i++) { - if (count[i] > 0) { - CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count[i], type, - indices[i], - basevertex[i])); - } - } -} - -/* - * Eval Mesh - */ - -/** - * KW: - * If are compiling, we don't know whether eval will produce a - * vertex when it is run in the future. If this is pure immediate - * mode, eval is a noop if neither vertex map is enabled. - * - * Thus we need to have a check in the display list code or elsewhere - * for eval(1,2) vertices in the case where map(1,2)_vertex is - * disabled, and to purge those vertices from the vb. - */ -void GLAPIENTRY -_mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 ) -{ - GET_CURRENT_CONTEXT(ctx); - GLint i; - GLfloat u, du; - GLenum prim; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (mode) { - case GL_POINT: - prim = GL_POINTS; - break; - case GL_LINE: - prim = GL_LINE_STRIP; - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" ); - return; - } - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map1Vertex4 && - !ctx->Eval.Map1Vertex3 && - !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) - return; - - du = ctx->Eval.MapGrid1du; - u = ctx->Eval.MapGrid1u1 + i1 * du; - - CALL_Begin(GET_DISPATCH(), (prim)); - for (i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord1f(GET_DISPATCH(), (u)); - } - CALL_End(GET_DISPATCH(), ()); -} - - - -void GLAPIENTRY -_mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) -{ - GET_CURRENT_CONTEXT(ctx); - GLfloat u, du, v, dv, v1, u1; - GLint i, j; - - ASSERT_OUTSIDE_BEGIN_END(ctx); - - switch (mode) { - case GL_POINT: - case GL_LINE: - case GL_FILL: - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); - return; - } - - /* No effect if vertex maps disabled. - */ - if (!ctx->Eval.Map2Vertex4 && - !ctx->Eval.Map2Vertex3 && - !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) - return; - - du = ctx->Eval.MapGrid2du; - dv = ctx->Eval.MapGrid2dv; - v1 = ctx->Eval.MapGrid2v1 + j1 * dv; - u1 = ctx->Eval.MapGrid2u1 + i1 * du; - - switch (mode) { - case GL_POINT: - CALL_Begin(GET_DISPATCH(), (GL_POINTS)); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - } - CALL_End(GET_DISPATCH(), ()); - break; - case GL_LINE: - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - CALL_End(GET_DISPATCH(), ()); - } - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); - for (v=v1,j=j1;j<=j2;j++,v+=dv) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - } - CALL_End(GET_DISPATCH(), ()); - } - break; - case GL_FILL: - for (v=v1,j=j1;j<j2;j++,v+=dv) { - CALL_Begin(GET_DISPATCH(), (GL_TRIANGLE_STRIP)); - for (u=u1,i=i1;i<=i2;i++,u+=du) { - CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); - CALL_EvalCoord2f(GET_DISPATCH(), (u, v+dv)); - } - CALL_End(GET_DISPATCH(), ()); - } - break; - default: - _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); - return; - } -} - - - -/** - * Build a vertexformat of functions to use outside begin/end pairs. - * - * TODO -- build a whole dispatch table for this purpose, and likewise - * for inside begin/end. - */ -void -_mesa_noop_vtxfmt_init( GLvertexformat *vfmt ) -{ - _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); - - vfmt->Begin = _mesa_noop_Begin; - - _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); - - vfmt->Color3f = _mesa_noop_Color3f; - vfmt->Color3fv = _mesa_noop_Color3fv; - vfmt->Color4f = _mesa_noop_Color4f; - vfmt->Color4fv = _mesa_noop_Color4fv; - vfmt->EdgeFlag = _mesa_noop_EdgeFlag; - vfmt->End = _mesa_noop_End; - - vfmt->PrimitiveRestartNV = _mesa_noop_PrimitiveRestartNV; - - _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_); - - vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; - vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT; - vfmt->Indexf = _mesa_noop_Indexf; - vfmt->Indexfv = _mesa_noop_Indexfv; - vfmt->Materialfv = _mesa_noop_Materialfv; - vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB; - vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB; - vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB; - vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB; - vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB; - vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB; - vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB; - vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB; - vfmt->Normal3f = _mesa_noop_Normal3f; - vfmt->Normal3fv = _mesa_noop_Normal3fv; - vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT; - vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT; - vfmt->TexCoord1f = _mesa_noop_TexCoord1f; - vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv; - vfmt->TexCoord2f = _mesa_noop_TexCoord2f; - vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv; - vfmt->TexCoord3f = _mesa_noop_TexCoord3f; - vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv; - vfmt->TexCoord4f = _mesa_noop_TexCoord4f; - vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv; - vfmt->Vertex2f = _mesa_noop_Vertex2f; - vfmt->Vertex2fv = _mesa_noop_Vertex2fv; - vfmt->Vertex3f = _mesa_noop_Vertex3f; - vfmt->Vertex3fv = _mesa_noop_Vertex3fv; - vfmt->Vertex4f = _mesa_noop_Vertex4f; - vfmt->Vertex4fv = _mesa_noop_Vertex4fv; - vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV; - vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV; - vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV; - vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV; - vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV; - vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV; - vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV; - vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV; - vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB; - vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB; - vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB; - vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB; - vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB; - vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB; - vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB; - vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB; - - vfmt->Rectf = _mesa_noop_Rectf; - - vfmt->DrawArrays = _mesa_noop_DrawArrays; - vfmt->DrawElements = _mesa_noop_DrawElements; - vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; - vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements; - vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex; - vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex; - vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex; -} - - -#endif /* FEATURE_beginend */ diff --git a/mesalib/src/mesa/main/eval.h b/mesalib/src/mesa/main/eval.h index 5a4203138..c07d4d532 100644 --- a/mesalib/src/mesa/main/eval.h +++ b/mesalib/src/mesa/main/eval.h @@ -58,10 +58,6 @@ extern GLuint _mesa_evaluator_components( GLenum target ); -extern void gl_free_control_points( struct gl_context *ctx, - GLenum target, GLfloat *data ); - - extern GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder, const GLfloat *points ); diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c index bcebf1240..f8b148cee 100644 --- a/mesalib/src/mesa/main/fbobject.c +++ b/mesalib/src/mesa/main/fbobject.c @@ -1939,7 +1939,29 @@ _mesa_CheckFramebufferStatusEXT(GLenum target) return buffer->_Status; } - +/** + * Replicate the src attachment point. Used by framebuffer_texture() when + * the same texture is attached at GL_DEPTH_ATTACHMENT and + * GL_STENCIL_ATTACHMENT. + */ +static void +reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb, + gl_buffer_index dst, + gl_buffer_index src) +{ + struct gl_renderbuffer_attachment *dst_att = &fb->Attachment[dst]; + struct gl_renderbuffer_attachment *src_att = &fb->Attachment[src]; + + assert(src_att->Texture != NULL); + assert (src_att->Renderbuffer != NULL); + + _mesa_reference_texobj(&dst_att->Texture, src_att->Texture); + _mesa_reference_renderbuffer(&dst_att->Renderbuffer, src_att->Renderbuffer); + dst_att->Type = src_att->Type; + dst_att->Complete = src_att->Complete; + dst_att->TextureLevel = src_att->TextureLevel; + dst_att->Zoffset = src_att->Zoffset; +} /** * Common code called by glFramebufferTexture1D/2D/3DEXT(). @@ -2041,8 +2063,34 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, _glthread_LOCK_MUTEX(fb->Mutex); if (texObj) { - _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, - level, zoffset); + if (attachment == GL_DEPTH_ATTACHMENT && + texObj == fb->Attachment[BUFFER_STENCIL].Texture) { + /* The texture object is already attached to the stencil attachment + * point. Don't create a new renderbuffer; just reuse the stencil + * attachment's. This is required to prevent a GL error in + * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL). + */ + reuse_framebuffer_texture_attachment(fb, BUFFER_DEPTH, + BUFFER_STENCIL); + } else if (attachment == GL_STENCIL_ATTACHMENT && + texObj== fb->Attachment[BUFFER_DEPTH].Texture) { + /* As above, but with depth and stencil juxtasposed. */ + reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL, + BUFFER_DEPTH); + } else { + _mesa_set_texture_attachment(ctx, fb, att, texObj, textarget, + level, zoffset); + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + /* Above we created a new renderbuffer and attached it to the + * depth attachment point. Now attach it to the stencil attachment + * point too. + */ + assert(att == &fb->Attachment[BUFFER_DEPTH]); + reuse_framebuffer_texture_attachment(fb,BUFFER_STENCIL, + BUFFER_DEPTH); + } + } + /* Set the render-to-texture flag. We'll check this flag in * glTexImage() and friends to determine if we need to revalidate * any FBOs that might be rendering into this texture. @@ -2055,6 +2103,10 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target, } else { _mesa_remove_attachment(ctx, att); + if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) { + assert(att == &fb->Attachment[BUFFER_DEPTH]); + _mesa_remove_attachment(ctx, &fb->Attachment[BUFFER_STENCIL]); + } } invalidate_framebuffer(fb); diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index adcbaeb19..deab97d3e 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -1798,6 +1798,7 @@ typedef enum typedef enum { SYSTEM_VALUE_FRONT_FACE, /**< Fragment shader only (not done yet) */ + SYSTEM_VALUE_VERTEX_ID, /**< Vertex shader only */ SYSTEM_VALUE_INSTANCE_ID, /**< Vertex shader only */ SYSTEM_VALUE_MAX /**< Number of values */ } gl_system_value; diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp index 39aa5570e..5371d6a17 100644 --- a/mesalib/src/mesa/main/uniform_query.cpp +++ b/mesalib/src/mesa/main/uniform_query.cpp @@ -894,7 +894,7 @@ _mesa_get_uniform_location(struct gl_context *ctx, array_lookup = false; } - unsigned location; + unsigned location = 0; const bool found = shProg->UniformHash->get(location, name_copy); assert(!found diff --git a/mesalib/src/mesa/sources.mak b/mesalib/src/mesa/sources.mak index b804a95cc..102562ace 100644 --- a/mesalib/src/mesa/sources.mak +++ b/mesalib/src/mesa/sources.mak @@ -9,7 +9,6 @@ MAIN_SOURCES = \ main/api_arrayelt.c \ main/api_exec.c \ main/api_loopback.c \ - main/api_noop.c \ main/api_validate.c \ main/accum.c \ main/arbprogram.c \ @@ -183,6 +182,7 @@ VBO_SOURCES = \ vbo/vbo_exec_array.c \ vbo/vbo_exec_draw.c \ vbo/vbo_exec_eval.c \ + vbo/vbo_noop.c \ vbo/vbo_rebase.c \ vbo/vbo_split.c \ vbo/vbo_split_copy.c \ diff --git a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c index 1a8854b9b..fa37be0b6 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_bitmap.c +++ b/mesalib/src/mesa/state_tracker/st_cb_bitmap.c @@ -376,6 +376,10 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized, PIPE_USAGE_STREAM, max_slots * sizeof(st->bitmap.vertices)); + if (!st->bitmap.vbuf) { + /* out of memory */ + return 0; + } } /* Positions are in clip coords since we need to do clipping in case @@ -547,11 +551,12 @@ draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z, sv->texture->target != PIPE_TEXTURE_RECT, x, y, width, height, z, color); - util_draw_vertex_buffer(pipe, st->cso_context, st->bitmap.vbuf, offset, - PIPE_PRIM_TRIANGLE_FAN, - 4, /* verts */ - 3); /* attribs/vert */ - + if (st->bitmap.vbuf) { + util_draw_vertex_buffer(pipe, st->cso_context, st->bitmap.vbuf, offset, + PIPE_PRIM_TRIANGLE_FAN, + 4, /* verts */ + 3); /* attribs/vert */ + } /* restore state */ cso_restore_rasterizer(cso); diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c index eff195068..332b0d1b6 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_drawtex.c +++ b/mesalib/src/mesa/state_tracker/st_cb_drawtex.c @@ -114,7 +114,6 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, uint semantic_names[2 + MAX_TEXTURE_UNITS]; uint semantic_indexes[2 + MAX_TEXTURE_UNITS]; struct pipe_vertex_element velements[2 + MAX_TEXTURE_UNITS]; - GLbitfield inputs = VERT_BIT_POS; st_validate_state(st); @@ -128,7 +127,6 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, numTexCoords = 0; for (i = 0; i < ctx->Const.MaxTextureUnits; i++) { if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_2D_BIT) { - inputs |= VERT_BIT_TEX(i); numTexCoords++; } } diff --git a/mesalib/src/mesa/swrast/s_readpix.c b/mesalib/src/mesa/swrast/s_readpix.c index b5618e884..500686798 100644 --- a/mesalib/src/mesa/swrast/s_readpix.c +++ b/mesalib/src/mesa/swrast/s_readpix.c @@ -236,6 +236,7 @@ slow_read_rgba_pixels( struct gl_context *ctx, GLbitfield transferOps ) { struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer; + const gl_format rbFormat = _mesa_get_srgb_format_linear(rb->Format); union { float f[MAX_WIDTH][4]; unsigned int i[MAX_WIDTH][4]; @@ -252,11 +253,10 @@ slow_read_rgba_pixels( struct gl_context *ctx, for (j = 0; j < height; j++) { if (_mesa_is_integer_format(format)) { - _mesa_unpack_int_rgba_row(rb->Format, width, map, rgba.i); + _mesa_unpack_int_rgba_row(rbFormat, width, map, rgba.i); _mesa_pack_rgba_span_int(ctx, width, rgba.i, format, type, dst); } else { - _mesa_unpack_rgba_row(_mesa_get_srgb_format_linear(rb->Format), - width, map, rgba.f); + _mesa_unpack_rgba_row(rbFormat, width, map, rgba.f); _mesa_pack_rgba_span_float(ctx, width, rgba.f, format, type, dst, packing, transferOps); } diff --git a/mesalib/src/mesa/swrast/s_texture.c b/mesalib/src/mesa/swrast/s_texture.c index ba67c6fa4..76a31eeae 100644 --- a/mesalib/src/mesa/swrast/s_texture.c +++ b/mesalib/src/mesa/swrast/s_texture.c @@ -241,7 +241,6 @@ _swrast_map_texture(struct gl_context *ctx, struct gl_texture_object *texObj) /* XXX we'll eventually call _swrast_map_teximage() here */ swImage->Data = swImage->Buffer; - assert(swImage->Buffer); } } } diff --git a/mesalib/src/mesa/vbo/vbo_exec.h b/mesalib/src/mesa/vbo/vbo_exec.h index 0b72579a8..8d6b8f95a 100644 --- a/mesalib/src/mesa/vbo/vbo_exec.h +++ b/mesalib/src/mesa/vbo/vbo_exec.h @@ -82,6 +82,7 @@ struct vbo_exec_context { struct gl_context *ctx; GLvertexformat vtxfmt; + GLvertexformat vtxfmt_noop; struct { struct gl_buffer_object *bufferobj; diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c index 5f3ed9d5d..62e7d03f3 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_api.c +++ b/mesalib/src/mesa/vbo/vbo_exec_api.c @@ -41,11 +41,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/state.h" #include "main/light.h" #include "main/api_arrayelt.h" -#include "main/api_noop.h" #include "main/api_validate.h" #include "main/dispatch.h" #include "vbo_context.h" +#include "vbo_noop.h" + #ifdef ERROR #undef ERROR @@ -546,13 +547,146 @@ static void GLAPIENTRY vbo_exec_EvalPoint2( GLint i, GLint j ) vbo_exec_EvalCoord2f( u, v ); } -/* use noop eval mesh */ -#define vbo_exec_EvalMesh1 _mesa_noop_EvalMesh1 -#define vbo_exec_EvalMesh2 _mesa_noop_EvalMesh2 + +static void GLAPIENTRY +vbo_exec_EvalMesh1(GLenum mode, GLint i1, GLint i2) +{ + GET_CURRENT_CONTEXT(ctx); + GLint i; + GLfloat u, du; + GLenum prim; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (mode) { + case GL_POINT: + prim = GL_POINTS; + break; + case GL_LINE: + prim = GL_LINE_STRIP; + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" ); + return; + } + + /* No effect if vertex maps disabled. + */ + if (!ctx->Eval.Map1Vertex4 && + !ctx->Eval.Map1Vertex3 && + !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS])) + return; + + du = ctx->Eval.MapGrid1du; + u = ctx->Eval.MapGrid1u1 + i1 * du; + + CALL_Begin(GET_DISPATCH(), (prim)); + for (i=i1;i<=i2;i++,u+=du) { + CALL_EvalCoord1f(GET_DISPATCH(), (u)); + } + CALL_End(GET_DISPATCH(), ()); +} + + +static void GLAPIENTRY +vbo_exec_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) +{ + GET_CURRENT_CONTEXT(ctx); + GLfloat u, du, v, dv, v1, u1; + GLint i, j; + + ASSERT_OUTSIDE_BEGIN_END(ctx); + + switch (mode) { + case GL_POINT: + case GL_LINE: + case GL_FILL: + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); + return; + } + + /* No effect if vertex maps disabled. + */ + if (!ctx->Eval.Map2Vertex4 && + !ctx->Eval.Map2Vertex3 && + !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS])) + return; + + du = ctx->Eval.MapGrid2du; + dv = ctx->Eval.MapGrid2dv; + v1 = ctx->Eval.MapGrid2v1 + j1 * dv; + u1 = ctx->Eval.MapGrid2u1 + i1 * du; + + switch (mode) { + case GL_POINT: + CALL_Begin(GET_DISPATCH(), (GL_POINTS)); + for (v=v1,j=j1;j<=j2;j++,v+=dv) { + for (u=u1,i=i1;i<=i2;i++,u+=du) { + CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); + } + } + CALL_End(GET_DISPATCH(), ()); + break; + case GL_LINE: + for (v=v1,j=j1;j<=j2;j++,v+=dv) { + CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); + for (u=u1,i=i1;i<=i2;i++,u+=du) { + CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); + } + CALL_End(GET_DISPATCH(), ()); + } + for (u=u1,i=i1;i<=i2;i++,u+=du) { + CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP)); + for (v=v1,j=j1;j<=j2;j++,v+=dv) { + CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); + } + CALL_End(GET_DISPATCH(), ()); + } + break; + case GL_FILL: + for (v=v1,j=j1;j<j2;j++,v+=dv) { + CALL_Begin(GET_DISPATCH(), (GL_TRIANGLE_STRIP)); + for (u=u1,i=i1;i<=i2;i++,u+=du) { + CALL_EvalCoord2f(GET_DISPATCH(), (u, v)); + CALL_EvalCoord2f(GET_DISPATCH(), (u, v+dv)); + } + CALL_End(GET_DISPATCH(), ()); + } + break; + default: + _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" ); + return; + } +} #endif /* FEATURE_evaluators */ +/** + * Execute a glRectf() function. This is not suitable for GL_COMPILE + * modes (as the test for outside begin/end is not compiled), + * but may be useful for drivers in circumstances which exclude + * display list interactions. + * + * (None of the functions in this file are suitable for GL_COMPILE + * modes). + */ +static void GLAPIENTRY +vbo_exec_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx); + + CALL_Begin(GET_DISPATCH(), (GL_QUADS)); + CALL_Vertex2f(GET_DISPATCH(), (x1, y1)); + CALL_Vertex2f(GET_DISPATCH(), (x2, y1)); + CALL_Vertex2f(GET_DISPATCH(), (x2, y2)); + CALL_Vertex2f(GET_DISPATCH(), (x1, y2)); + CALL_End(GET_DISPATCH(), ()); +} + /** * Called via glBegin. @@ -673,7 +807,7 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec ) _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); _MESA_INIT_EVAL_VTXFMT(vfmt, vbo_exec_); - vfmt->Rectf = _mesa_noop_Rectf; + vfmt->Rectf = vbo_exec_Rectf; /* from attrib_tmp.h: */ @@ -896,7 +1030,9 @@ void vbo_use_buffer_objects(struct gl_context *ctx) /* Allocate a real buffer object now */ _mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL); exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, bufName, target); - ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj); + if (!ctx->Driver.BufferData(ctx, target, size, NULL, usage, exec->vtx.bufferobj)) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "VBO allocation"); + } } @@ -933,6 +1069,7 @@ void vbo_exec_vtx_init( struct vbo_exec_context *exec ) exec->vtx.buffer_ptr = exec->vtx.buffer_map; vbo_exec_vtxfmt_init( exec ); + _mesa_noop_vtxfmt_init(&exec->vtxfmt_noop); /* Hook our functions into the dispatch table. */ diff --git a/mesalib/src/mesa/vbo/vbo_exec_draw.c b/mesalib/src/mesa/vbo/vbo_exec_draw.c index 8ffaaaa48..efb6dd10a 100644 --- a/mesalib/src/mesa/vbo/vbo_exec_draw.c +++ b/mesalib/src/mesa/vbo/vbo_exec_draw.c @@ -28,11 +28,14 @@ #include "main/glheader.h" #include "main/bufferobj.h" #include "main/compiler.h" +#include "main/context.h" #include "main/enums.h" #include "main/mfeatures.h" #include "main/state.h" +#include "main/vtxfmt.h" #include "vbo_context.h" +#include "vbo_noop.h" #if FEATURE_beginend @@ -308,32 +311,55 @@ vbo_exec_vtx_map( struct vbo_exec_context *exec ) if (VBO_VERT_BUFFER_SIZE > exec->vtx.buffer_used + 1024) { /* The VBO exists and there's room for more */ - exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, - exec->vtx.buffer_used, - (VBO_VERT_BUFFER_SIZE - - exec->vtx.buffer_used), - accessRange, - exec->vtx.bufferobj); - exec->vtx.buffer_ptr = exec->vtx.buffer_map; + if (exec->vtx.bufferobj->Size > 0) { + exec->vtx.buffer_map = + (GLfloat *)ctx->Driver.MapBufferRange(ctx, + exec->vtx.buffer_used, + (VBO_VERT_BUFFER_SIZE - + exec->vtx.buffer_used), + accessRange, + exec->vtx.bufferobj); + exec->vtx.buffer_ptr = exec->vtx.buffer_map; + } + else { + exec->vtx.buffer_ptr = exec->vtx.buffer_map = NULL; + } } if (!exec->vtx.buffer_map) { /* Need to allocate a new VBO */ exec->vtx.buffer_used = 0; - ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER_ARB, - VBO_VERT_BUFFER_SIZE, - NULL, usage, exec->vtx.bufferobj); + if (ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER_ARB, + VBO_VERT_BUFFER_SIZE, + NULL, usage, exec->vtx.bufferobj)) { + /* buffer allocation worked, now map the buffer */ + exec->vtx.buffer_map = + (GLfloat *)ctx->Driver.MapBufferRange(ctx, + 0, VBO_VERT_BUFFER_SIZE, + accessRange, + exec->vtx.bufferobj); + } + else { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "VBO allocation"); + exec->vtx.buffer_map = NULL; + } + } + exec->vtx.buffer_ptr = exec->vtx.buffer_map; - exec->vtx.buffer_map = - (GLfloat *)ctx->Driver.MapBufferRange(ctx, - 0, VBO_VERT_BUFFER_SIZE, - accessRange, - exec->vtx.bufferobj); - assert(exec->vtx.buffer_map); - exec->vtx.buffer_ptr = exec->vtx.buffer_map; + if (!exec->vtx.buffer_map) { + /* out of memory */ + _mesa_install_exec_vtxfmt( ctx, &exec->vtxfmt_noop ); + } + else { + if (_mesa_using_noop_vtxfmt(ctx->Exec)) { + /* The no-op functions are installed so switch back to regular + * functions. We do this test just to avoid frequent and needless + * calls to _mesa_install_exec_vtxfmt(). + */ + _mesa_install_exec_vtxfmt(ctx, &exec->vtxfmt); + } } if (0) diff --git a/mesalib/src/mesa/vbo/vbo_noop.c b/mesalib/src/mesa/vbo/vbo_noop.c new file mode 100644 index 000000000..430011207 --- /dev/null +++ b/mesalib/src/mesa/vbo/vbo_noop.c @@ -0,0 +1,519 @@ +/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2011 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +/** + * GLvertexformat no-op functions. Used in out-of-memory situations. + */ + + +#include "main/glheader.h" +#include "main/api_arrayelt.h" +#include "main/context.h" +#include "main/dispatch.h" +#include "main/dlist.h" +#include "main/eval.h" +#include "main/mfeatures.h" +#include "vbo/vbo_noop.h" + +#if FEATURE_beginend + + +static void GLAPIENTRY +_mesa_noop_EdgeFlag(GLboolean b) +{ +} + +static void GLAPIENTRY +_mesa_noop_Indexf(GLfloat f) +{ +} + +static void GLAPIENTRY +_mesa_noop_Indexfv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_FogCoordfEXT(GLfloat a) +{ +} + +static void GLAPIENTRY +_mesa_noop_FogCoordfvEXT(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_Normal3f(GLfloat a, GLfloat b, GLfloat c) +{ +} + +static void GLAPIENTRY +_mesa_noop_Normal3fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_Color4f(GLfloat a, GLfloat b, GLfloat c, GLfloat d) +{ +} + +static void GLAPIENTRY +_mesa_noop_Color4fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_Color3f(GLfloat a, GLfloat b, GLfloat c) +{ +} + +static void GLAPIENTRY +_mesa_noop_Color3fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord1fARB(GLenum target, GLfloat a) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord1fvARB(GLenum target, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord2fARB(GLenum target, GLfloat a, GLfloat b) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord2fvARB(GLenum target, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord3fARB(GLenum target, GLfloat a, GLfloat b, GLfloat c) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord3fvARB(GLenum target, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord4fARB(GLenum target, GLfloat a, GLfloat b, + GLfloat c, GLfloat d) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiTexCoord4fvARB(GLenum target, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_SecondaryColor3fEXT(GLfloat a, GLfloat b, GLfloat c) +{ +} + +static void GLAPIENTRY +_mesa_noop_SecondaryColor3fvEXT(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord1f(GLfloat a) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord1fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord2f(GLfloat a, GLfloat b) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord2fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord3f(GLfloat a, GLfloat b, GLfloat c) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord3fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord4f(GLfloat a, GLfloat b, GLfloat c, GLfloat d) +{ +} + +static void GLAPIENTRY +_mesa_noop_TexCoord4fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib1fNV(GLuint index, GLfloat x) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib1fvNV(GLuint index, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib2fvNV(GLuint index, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib3fvNV(GLuint index, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib4fNV(GLuint index, GLfloat x, + GLfloat y, GLfloat z, GLfloat w) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib4fvNV(GLuint index, const GLfloat * v) +{ +} + + +static void GLAPIENTRY +_mesa_noop_VertexAttrib1fARB(GLuint index, GLfloat x) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib1fvARB(GLuint index, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib2fvARB(GLuint index, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib3fvARB(GLuint index, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib4fARB(GLuint index, GLfloat x, + GLfloat y, GLfloat z, GLfloat w) +{ +} + +static void GLAPIENTRY +_mesa_noop_VertexAttrib4fvARB(GLuint index, const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_Materialfv(GLenum face, GLenum pname, const GLfloat * params) +{ +} + +static void GLAPIENTRY +_mesa_noop_Vertex2fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_Vertex3fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_Vertex4fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_Vertex2f(GLfloat a, GLfloat b) +{ +} + +static void GLAPIENTRY +_mesa_noop_Vertex3f(GLfloat a, GLfloat b, GLfloat c) +{ +} + +static void GLAPIENTRY +_mesa_noop_Vertex4f(GLfloat a, GLfloat b, GLfloat c, GLfloat d) +{ +} + + +#if FEATURE_evaluators +static void GLAPIENTRY +_mesa_noop_EvalCoord1f(GLfloat a) +{ +} + +static void GLAPIENTRY +_mesa_noop_EvalCoord1fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_EvalCoord2f(GLfloat a, GLfloat b) +{ +} + +static void GLAPIENTRY +_mesa_noop_EvalCoord2fv(const GLfloat * v) +{ +} + +static void GLAPIENTRY +_mesa_noop_EvalPoint1(GLint a) +{ +} + +static void GLAPIENTRY +_mesa_noop_EvalPoint2(GLint a, GLint b) +{ +} +#endif /* FEATURE_evaluators */ + + +static void GLAPIENTRY +_mesa_noop_Begin(GLenum mode) +{ +} + +static void GLAPIENTRY +_mesa_noop_End(void) +{ +} + +static void GLAPIENTRY +_mesa_noop_PrimitiveRestartNV(void) +{ +} + + +static void GLAPIENTRY +_mesa_noop_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) +{ +} + + +static void GLAPIENTRY +_mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count) +{ +} + +static void GLAPIENTRY +_mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices) +{ +} + +static void GLAPIENTRY +_mesa_noop_DrawElementsBaseVertex(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices, GLint basevertex) +{ +} + + +static void GLAPIENTRY +_mesa_noop_DrawRangeElements(GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid * indices) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei * count, GLenum type, + const GLvoid ** indices, GLsizei primcount) +{ +} + +static void GLAPIENTRY +_mesa_noop_DrawRangeElementsBaseVertex(GLenum mode, + GLuint start, GLuint end, + GLsizei count, GLenum type, + const GLvoid * indices, + GLint basevertex) +{ +} + +static void GLAPIENTRY +_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei * count, + GLenum type, + const GLvoid ** indices, + GLsizei primcount, + const GLint * basevertex) +{ +} + +static void GLAPIENTRY +_mesa_noop_EvalMesh1(GLenum mode, GLint i1, GLint i2) +{ +} + +static void GLAPIENTRY +_mesa_noop_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) +{ +} + + +/** + * Build a vertexformat of functions that are no-ops. + * These are used in out-of-memory situations when we have no VBO + * to put the vertex data into. + */ +void +_mesa_noop_vtxfmt_init(GLvertexformat * vfmt) +{ + _MESA_INIT_ARRAYELT_VTXFMT(vfmt, _ae_); + + vfmt->Begin = _mesa_noop_Begin; + + _MESA_INIT_DLIST_VTXFMT(vfmt, _mesa_); + + vfmt->Color3f = _mesa_noop_Color3f; + vfmt->Color3fv = _mesa_noop_Color3fv; + vfmt->Color4f = _mesa_noop_Color4f; + vfmt->Color4fv = _mesa_noop_Color4fv; + vfmt->EdgeFlag = _mesa_noop_EdgeFlag; + vfmt->End = _mesa_noop_End; + + vfmt->PrimitiveRestartNV = _mesa_noop_PrimitiveRestartNV; + + _MESA_INIT_EVAL_VTXFMT(vfmt, _mesa_noop_); + + vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT; + vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT; + vfmt->Indexf = _mesa_noop_Indexf; + vfmt->Indexfv = _mesa_noop_Indexfv; + vfmt->Materialfv = _mesa_noop_Materialfv; + vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB; + vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB; + vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB; + vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB; + vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB; + vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB; + vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB; + vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB; + vfmt->Normal3f = _mesa_noop_Normal3f; + vfmt->Normal3fv = _mesa_noop_Normal3fv; + vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT; + vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT; + vfmt->TexCoord1f = _mesa_noop_TexCoord1f; + vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv; + vfmt->TexCoord2f = _mesa_noop_TexCoord2f; + vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv; + vfmt->TexCoord3f = _mesa_noop_TexCoord3f; + vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv; + vfmt->TexCoord4f = _mesa_noop_TexCoord4f; + vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv; + vfmt->Vertex2f = _mesa_noop_Vertex2f; + vfmt->Vertex2fv = _mesa_noop_Vertex2fv; + vfmt->Vertex3f = _mesa_noop_Vertex3f; + vfmt->Vertex3fv = _mesa_noop_Vertex3fv; + vfmt->Vertex4f = _mesa_noop_Vertex4f; + vfmt->Vertex4fv = _mesa_noop_Vertex4fv; + vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV; + vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV; + vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV; + vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV; + vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV; + vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV; + vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV; + vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV; + vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB; + vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB; + vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB; + vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB; + vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB; + vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB; + vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB; + vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB; + + vfmt->Rectf = _mesa_noop_Rectf; + + vfmt->DrawArrays = _mesa_noop_DrawArrays; + vfmt->DrawElements = _mesa_noop_DrawElements; + vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; + vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements; + vfmt->DrawElementsBaseVertex = _mesa_noop_DrawElementsBaseVertex; + vfmt->DrawRangeElementsBaseVertex = _mesa_noop_DrawRangeElementsBaseVertex; + vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex; +} + + +/** + * Is the given dispatch table using the no-op functions? + */ +GLboolean +_mesa_using_noop_vtxfmt(const struct _glapi_table *dispatch) +{ + return GET_Begin((struct _glapi_table *) dispatch) == _mesa_noop_Begin; +} + + +#endif /* FEATURE_beginend */ diff --git a/mesalib/src/mesa/main/api_noop.h b/mesalib/src/mesa/vbo/vbo_noop.h index 4af2cde6b..f9180374f 100644 --- a/mesalib/src/mesa/main/api_noop.h +++ b/mesalib/src/mesa/vbo/vbo_noop.h @@ -1,61 +1,45 @@ -/*
- * Mesa 3-D graphics library
- * Version: 6.5.1
- *
- * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _API_NOOP_H
-#define _API_NOOP_H
-
-#include "main/mfeatures.h"
-#include "main/mtypes.h"
-
-#if FEATURE_beginend
-
-extern void GLAPIENTRY
-_mesa_noop_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
-
-extern void GLAPIENTRY
-_mesa_noop_EvalMesh1(GLenum mode, GLint i1, GLint i2);
-
-extern void GLAPIENTRY
-_mesa_noop_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
-
-extern void GLAPIENTRY
-_mesa_noop_Materialfv(GLenum face, GLenum pname, const GLfloat *param);
-
-extern void GLAPIENTRY
-_mesa_noop_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type,
- const GLvoid **indices, GLsizei primcount);
-
-extern void GLAPIENTRY
-_mesa_noop_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count,
- GLenum type,
- const GLvoid **indices,
- GLsizei primcount,
- const GLint *basevertex);
-
-extern void
-_mesa_noop_vtxfmt_init(GLvertexformat *vfmt);
-
-#endif /* FEATURE_beginend */
-
-#endif /* _API_NOOP_H */
+/* + * Mesa 3-D graphics library + * + * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. + * Copyright (C) 2011 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _API_NOOP_H +#define _API_NOOP_H + + +#include "main/mfeatures.h" +#include "main/mtypes.h" + + +#if FEATURE_beginend + +extern void +_mesa_noop_vtxfmt_init(GLvertexformat *vfmt); + +extern GLboolean +_mesa_using_noop_vtxfmt(const struct _glapi_table *dispatch); + + +#endif /* FEATURE_beginend */ + + +#endif /* _API_NOOP_H */ diff --git a/mesalib/src/mesa/vbo/vbo_save.h b/mesalib/src/mesa/vbo/vbo_save.h index a85a7cbf6..4d4a5bf17 100644 --- a/mesalib/src/mesa/vbo/vbo_save.h +++ b/mesalib/src/mesa/vbo/vbo_save.h @@ -122,6 +122,7 @@ struct vbo_save_primitive_store { struct vbo_save_context { struct gl_context *ctx; GLvertexformat vtxfmt; + GLvertexformat vtxfmt_noop; /**< Used if out_of_memory is true */ struct gl_client_array arrays[VBO_ATTRIB_MAX]; const struct gl_client_array *inputs[VBO_ATTRIB_MAX]; @@ -129,6 +130,8 @@ struct vbo_save_context { GLubyte active_sz[VBO_ATTRIB_MAX]; GLuint vertex_size; + GLboolean out_of_memory; /**< True if last VBO allocation failed */ + GLfloat *buffer; GLuint count; GLuint wrap_count; diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c index 87a52e81f..64da7ac49 100644 --- a/mesalib/src/mesa/vbo/vbo_save_api.c +++ b/mesalib/src/mesa/vbo/vbo_save_api.c @@ -75,13 +75,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/eval.h" #include "main/macros.h" #include "main/mfeatures.h" -#include "main/api_noop.h" #include "main/api_validate.h" #include "main/api_arrayelt.h" #include "main/vtxfmt.h" #include "main/dispatch.h" #include "vbo_context.h" +#include "vbo_noop.h" #if FEATURE_dlist @@ -185,6 +185,7 @@ _save_copy_vertices(struct gl_context *ctx, static struct vbo_save_vertex_store * alloc_vertex_store(struct gl_context *ctx) { + struct vbo_save_context *save = &vbo_context(ctx)->save; struct vbo_save_vertex_store *vertex_store = CALLOC_STRUCT(vbo_save_vertex_store); @@ -197,11 +198,22 @@ alloc_vertex_store(struct gl_context *ctx) vertex_store->bufferobj = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID, GL_ARRAY_BUFFER_ARB); + if (vertex_store->bufferobj) { + save->out_of_memory = + !ctx->Driver.BufferData(ctx, + GL_ARRAY_BUFFER_ARB, + VBO_SAVE_BUFFER_SIZE * sizeof(GLfloat), + NULL, GL_STATIC_DRAW_ARB, + vertex_store->bufferobj); + } + else { + save->out_of_memory = GL_TRUE; + } - ctx->Driver.BufferData(ctx, - GL_ARRAY_BUFFER_ARB, - VBO_SAVE_BUFFER_SIZE * sizeof(GLfloat), - NULL, GL_STATIC_DRAW_ARB, vertex_store->bufferobj); + if (save->out_of_memory) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "internal VBO allocation"); + _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); + } vertex_store->buffer = NULL; vertex_store->used = 0; @@ -231,14 +243,19 @@ map_vertex_store(struct gl_context *ctx, { assert(vertex_store->bufferobj); assert(!vertex_store->buffer); - vertex_store->buffer = - (GLfloat *) ctx->Driver.MapBufferRange(ctx, 0, - vertex_store->bufferobj->Size, - GL_MAP_WRITE_BIT, /* not used */ - vertex_store->bufferobj); - - assert(vertex_store->buffer); - return vertex_store->buffer + vertex_store->used; + if (vertex_store->bufferobj->Size > 0) { + vertex_store->buffer = + (GLfloat *) ctx->Driver.MapBufferRange(ctx, 0, + vertex_store->bufferobj->Size, + GL_MAP_WRITE_BIT, /* not used */ + vertex_store->bufferobj); + assert(vertex_store->buffer); + return vertex_store->buffer + vertex_store->used; + } + else { + /* probably ran out of memory for buffers */ + return NULL; + } } @@ -246,7 +263,9 @@ static void unmap_vertex_store(struct gl_context *ctx, struct vbo_save_vertex_store *vertex_store) { - ctx->Driver.UnmapBuffer(ctx, vertex_store->bufferobj); + if (vertex_store->bufferobj->Size > 0) { + ctx->Driver.UnmapBuffer(ctx, vertex_store->bufferobj); + } vertex_store->buffer = NULL; } @@ -400,6 +419,7 @@ _save_compile_vertex_list(struct gl_context *ctx) */ save->vertex_store = alloc_vertex_store(ctx); save->buffer_ptr = map_vertex_store(ctx, save->vertex_store); + save->out_of_memory = save->buffer_ptr == NULL; } if (save->prim_store->used > VBO_SAVE_PRIM_SIZE - 6) { @@ -733,7 +753,12 @@ dlist_fallback(struct gl_context *ctx) _save_copy_to_current(ctx); _save_reset_vertex(ctx); _save_reset_counters(ctx); - _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); + if (save->out_of_memory) { + _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); + } + else { + _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); + } ctx->Driver.SaveNeedFlush = 0; } @@ -826,7 +851,12 @@ vbo_save_NotifyBegin(struct gl_context *ctx, GLenum mode) save->prim[i].count = 0; save->prim[i].num_instances = 1; - _mesa_install_save_vtxfmt(ctx, &save->vtxfmt); + if (save->out_of_memory) { + _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); + } + else { + _mesa_install_save_vtxfmt(ctx, &save->vtxfmt); + } ctx->Driver.SaveNeedFlush = 1; return GL_TRUE; } @@ -852,7 +882,12 @@ _save_End(void) * etc. received between here and the next begin will be compiled * as opcodes. */ - _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); + if (save->out_of_memory) { + _mesa_install_save_vtxfmt(ctx, &save->vtxfmt_noop); + } + else { + _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); + } } @@ -933,6 +968,37 @@ _save_DrawArrays(GLenum mode, GLint start, GLsizei count) static void GLAPIENTRY +_save_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount) +{ + GET_CURRENT_CONTEXT(ctx); + (void) mode; + (void) count; + (void) type; + (void) indices; + (void) primcount; + _mesa_compile_error(ctx, GL_INVALID_OPERATION, "glMultiDrawElements"); +} + + +static void GLAPIENTRY +_save_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, + GLenum type, const GLvoid **indices, + GLsizei primcount, const GLint *basevertex) +{ + GET_CURRENT_CONTEXT(ctx); + (void) mode; + (void) count; + (void) type; + (void) indices; + (void) primcount; + (void) basevertex; + _mesa_compile_error(ctx, GL_INVALID_OPERATION, + "glMultiDrawElementsBaseVertex"); +} + + +static void GLAPIENTRY _save_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { GET_CURRENT_CONTEXT(ctx); @@ -993,6 +1059,7 @@ _save_PrimitiveRestartNV(void) /* Unlike the functions above, these are to be hooked into the vtxfmt * maintained in ctx->ListState, active when the list is known or * suspected to be outside any begin/end primitive. + * Note: OBE = Outside Begin/End */ static void GLAPIENTRY _save_OBE_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) @@ -1011,11 +1078,15 @@ static void GLAPIENTRY _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei count) { GET_CURRENT_CONTEXT(ctx); + struct vbo_save_context *save = &vbo_context(ctx)->save; GLint i; if (!_mesa_validate_DrawArrays(ctx, mode, start, count)) return; + if (save->out_of_memory) + return; + _ae_map_vbos(ctx); vbo_save_NotifyBegin(ctx, (mode | VBO_SAVE_PRIM_WEAK @@ -1037,11 +1108,15 @@ _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices) { GET_CURRENT_CONTEXT(ctx); + struct vbo_save_context *save = &vbo_context(ctx)->save; GLint i; if (!_mesa_validate_DrawElements(ctx, mode, count, type, indices, 0)) return; + if (save->out_of_memory) + return; + _ae_map_vbos(ctx); if (_mesa_is_bufferobj(ctx->Array.ElementArrayBufferObj)) @@ -1081,9 +1156,48 @@ _save_OBE_DrawRangeElements(GLenum mode, GLuint start, GLuint end, const GLvoid * indices) { GET_CURRENT_CONTEXT(ctx); - if (_mesa_validate_DrawRangeElements(ctx, mode, - start, end, count, type, indices, 0)) { - _save_OBE_DrawElements(mode, count, type, indices); + struct vbo_save_context *save = &vbo_context(ctx)->save; + + if (!_mesa_validate_DrawRangeElements(ctx, mode, + start, end, count, type, indices, 0)) + return; + + if (save->out_of_memory) + return; + + _save_OBE_DrawElements(mode, count, type, indices); +} + + +static void GLAPIENTRY +_save_OBE_MultiDrawElements(GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount) +{ + GLsizei i; + + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + CALL_DrawElements(GET_DISPATCH(), (mode, count[i], type, indices[i])); + } + } +} + + +static void GLAPIENTRY +_save_OBE_MultiDrawElementsBaseVertex(GLenum mode, const GLsizei *count, + GLenum type, + const GLvoid **indices, + GLsizei primcount, + const GLint *basevertex) +{ + GLsizei i; + + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + CALL_DrawElementsBaseVertex(GET_DISPATCH(), (mode, count[i], type, + indices[i], + basevertex[i])); + } } } @@ -1223,8 +1337,8 @@ _save_vtxfmt_init(struct gl_context *ctx) _MESA_INIT_EVAL_VTXFMT(vfmt, _save_); - /* These are all errors as we at least know we are in some sort of - * begin/end pair: + /* These calls all generate GL_INVALID_OPERATION since this vtxfmt is + * only used when we're inside a glBegin/End pair. */ vfmt->Begin = _save_Begin; vfmt->Rectf = _save_Rectf; @@ -1233,9 +1347,8 @@ _save_vtxfmt_init(struct gl_context *ctx) vfmt->DrawRangeElements = _save_DrawRangeElements; vfmt->DrawElementsBaseVertex = _save_DrawElementsBaseVertex; vfmt->DrawRangeElementsBaseVertex = _save_DrawRangeElementsBaseVertex; - /* Loops back into vfmt->DrawElements */ - vfmt->MultiDrawElementsEXT = _mesa_noop_MultiDrawElements; - vfmt->MultiDrawElementsBaseVertex = _mesa_noop_MultiDrawElementsBaseVertex; + vfmt->MultiDrawElementsEXT = _save_MultiDrawElements; + vfmt->MultiDrawElementsBaseVertex = _save_MultiDrawElementsBaseVertex; } @@ -1424,6 +1537,7 @@ vbo_save_api_init(struct vbo_save_context *save) _save_vtxfmt_init(ctx); _save_current_init(ctx); + _mesa_noop_vtxfmt_init(&save->vtxfmt_noop); /* These will actually get set again when binding/drawing */ for (i = 0; i < VBO_ATTRIB_MAX; i++) @@ -1436,11 +1550,8 @@ vbo_save_api_init(struct vbo_save_context *save) ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays; ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements; ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements; - /* loops back into _save_OBE_DrawElements */ - ctx->ListState.ListVtxfmt.MultiDrawElementsEXT = - _mesa_noop_MultiDrawElements; - ctx->ListState.ListVtxfmt.MultiDrawElementsBaseVertex = - _mesa_noop_MultiDrawElementsBaseVertex; + ctx->ListState.ListVtxfmt.MultiDrawElementsEXT = _save_OBE_MultiDrawElements; + ctx->ListState.ListVtxfmt.MultiDrawElementsBaseVertex = _save_OBE_MultiDrawElementsBaseVertex; _mesa_install_save_vtxfmt(ctx, &ctx->ListState.ListVtxfmt); } |