From 53192e17e55aa9ed3e3721bf4fdcb2b01a595202 Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 31 Aug 2012 15:18:29 +0200 Subject: randrproto xwininfo fontconfig libxcb mesa xkeyboard-config pixman xserver git update 31 Aug 2012 --- mesalib/src/gallium/auxiliary/util/u_blitter.c | 24 +- mesalib/src/gallium/auxiliary/util/u_blitter.h | 10 + mesalib/src/gallium/auxiliary/util/u_vbuf.c | 4 +- mesalib/src/glsl/glsl_parser_extras.h | 2 +- mesalib/src/mapi/glapi/gen/es_EXT.xml | 26 + mesalib/src/mapi/glapi/gen/gles_api.py | 5 + mesalib/src/mesa/Android.gen.mk | 8 +- mesalib/src/mesa/Makefile.am | 15 - mesalib/src/mesa/SConscript | 19 +- mesalib/src/mesa/drivers/common/meta.c | 423 +++++++++--- mesalib/src/mesa/drivers/dri/common/dri_util.c | 10 +- mesalib/src/mesa/main/.gitignore | 3 - mesalib/src/mesa/main/APIspec.xml | 903 ------------------------- mesalib/src/mesa/main/api_exec.c | 300 +++++--- mesalib/src/mesa/main/api_validate.c | 35 +- mesalib/src/mesa/main/arrayobj.c | 2 +- mesalib/src/mesa/main/attrib.c | 3 +- mesalib/src/mesa/main/blend.c | 15 +- mesalib/src/mesa/main/bufferobj.c | 4 + mesalib/src/mesa/main/clear.c | 11 +- mesalib/src/mesa/main/compiler.h | 3 + mesalib/src/mesa/main/context.c | 12 +- mesalib/src/mesa/main/enable.c | 303 ++++++++- mesalib/src/mesa/main/es1_conversion.c | 430 +----------- mesalib/src/mesa/main/extensions.c | 7 +- mesalib/src/mesa/main/fbobject.c | 276 +++++--- mesalib/src/mesa/main/fog.c | 15 +- mesalib/src/mesa/main/get.c | 44 +- mesalib/src/mesa/main/getstring.c | 58 +- mesalib/src/mesa/main/hint.c | 31 +- mesalib/src/mesa/main/light.c | 19 +- mesalib/src/mesa/main/lines.c | 17 + mesalib/src/mesa/main/macros.h | 194 +++--- mesalib/src/mesa/main/matrix.c | 7 +- mesalib/src/mesa/main/mtypes.h | 2 - mesalib/src/mesa/main/pixelstore.c | 39 +- mesalib/src/mesa/main/points.c | 131 ++-- mesalib/src/mesa/main/polygon.c | 8 + mesalib/src/mesa/main/readpix.c | 33 + mesalib/src/mesa/main/texenv.c | 41 +- mesalib/src/mesa/main/texgen.c | 63 +- mesalib/src/mesa/main/texgen.h | 3 + mesalib/src/mesa/main/teximage.c | 53 +- mesalib/src/mesa/main/texobj.c | 5 + mesalib/src/mesa/main/varray.c | 49 +- mesalib/src/mesa/main/version.c | 1 - mesalib/src/mesa/main/version.h | 6 +- mesalib/src/mesa/main/vtxfmt.c | 14 +- mesalib/src/mesa/sources.mak | 1 - mesalib/src/mesa/state_tracker/st_extensions.c | 3 - mesalib/src/mesa/swrast/s_lines.c | 4 +- mesalib/src/mesa/tnl/t_vertex_generic.c | 5 +- mesalib/src/mesa/vbo/vbo_exec_api.c | 36 +- 53 files changed, 1757 insertions(+), 1978 deletions(-) (limited to 'mesalib/src') diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index ad4ccd9eb..44295c136 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -123,13 +123,6 @@ struct blitter_context_priv boolean has_stencil_export; }; -static void blitter_draw_rectangle(struct blitter_context *blitter, - unsigned x, unsigned y, - unsigned width, unsigned height, - float depth, - enum blitter_attrib_type type, - const union pipe_color_union *attrib); - struct blitter_context *util_blitter_create(struct pipe_context *pipe) { @@ -146,7 +139,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) return NULL; ctx->base.pipe = pipe; - ctx->base.draw_rectangle = blitter_draw_rectangle; + ctx->base.draw_rectangle = util_blitter_draw_rectangle; /* init state objects for them to be considered invalid */ ctx->base.saved_blend_state = INVALID_PTR; @@ -862,12 +855,12 @@ static void blitter_draw(struct blitter_context_priv *ctx, pipe_resource_reference(&buf, NULL); } -static void blitter_draw_rectangle(struct blitter_context *blitter, - unsigned x1, unsigned y1, - unsigned x2, unsigned y2, - float depth, - enum blitter_attrib_type type, - const union pipe_color_union *attrib) +void util_blitter_draw_rectangle(struct blitter_context *blitter, + unsigned x1, unsigned y1, + unsigned x2, unsigned y2, + float depth, + enum blitter_attrib_type type, + const union pipe_color_union *attrib) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; @@ -1499,6 +1492,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, unsigned dst_layer, struct pipe_resource *src, unsigned src_layer, + unsigned sample_mask, void *custom_blend) { struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; @@ -1515,7 +1509,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, pipe->bind_depth_stencil_alpha_state(pipe, ctx->dsa_keep_depth_stencil); pipe->bind_vertex_elements_state(pipe, ctx->velem_state); pipe->bind_fs_state(pipe, blitter_get_fs_col(ctx, 1, FALSE)); - pipe->set_sample_mask(pipe, (1ull << MAX2(1, src->nr_samples)) - 1); + pipe->set_sample_mask(pipe, sample_mask); memset(&surf_tmpl, 0, sizeof(surf_tmpl)); surf_tmpl.format = dst->format; diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h index e06e8b12d..680407381 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.h +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h @@ -129,6 +129,15 @@ struct pipe_context *util_blitter_get_pipe(struct blitter_context *blitter) return blitter->pipe; } +/* The default function to draw a rectangle. This can only be used + * inside of the draw_rectangle callback if the driver overrides it. */ +void util_blitter_draw_rectangle(struct blitter_context *blitter, + unsigned x1, unsigned y1, + unsigned x2, unsigned y2, + float depth, + enum blitter_attrib_type type, + const union pipe_color_union *attrib); + /* * These states must be saved before any of the following functions are called: * - vertex buffers @@ -320,6 +329,7 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter, unsigned dst_layer, struct pipe_resource *src, unsigned src_layer, + unsigned sampled_mask, void *custom_blend); /* The functions below should be used to save currently bound constant state diff --git a/mesalib/src/gallium/auxiliary/util/u_vbuf.c b/mesalib/src/gallium/auxiliary/util/u_vbuf.c index 4141ba536..52db294cb 100644 --- a/mesalib/src/gallium/auxiliary/util/u_vbuf.c +++ b/mesalib/src/gallium/auxiliary/util/u_vbuf.c @@ -225,7 +225,9 @@ u_vbuf_set_vertex_elements_internal(struct u_vbuf *mgr, unsigned count, } assert(ve); - pipe->bind_vertex_elements_state(pipe, ve->driver_cso); + + if (ve != mgr->ve) + pipe->bind_vertex_elements_state(pipe, ve->driver_cso); return ve; } diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h index 66463c5b6..fc08ee273 100644 --- a/mesalib/src/glsl/glsl_parser_extras.h +++ b/mesalib/src/glsl/glsl_parser_extras.h @@ -96,7 +96,7 @@ struct _mesa_glsl_parse_state { * Currently affects uniform blocks and uniform buffer variables in * those blocks. */ - class ast_type_qualifier *default_uniform_qualifier; + struct ast_type_qualifier *default_uniform_qualifier; /** * Printable list of GLSL versions supported by the current context diff --git a/mesalib/src/mapi/glapi/gen/es_EXT.xml b/mesalib/src/mapi/glapi/gen/es_EXT.xml index d012ccd5b..fc2ec621e 100644 --- a/mesalib/src/mapi/glapi/gen/es_EXT.xml +++ b/mesalib/src/mapi/glapi/gen/es_EXT.xml @@ -619,6 +619,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mesalib/src/mapi/glapi/gen/gles_api.py b/mesalib/src/mapi/glapi/gen/gles_api.py index 70ae2e300..8dfef655a 100644 --- a/mesalib/src/mapi/glapi/gen/gles_api.py +++ b/mesalib/src/mapi/glapi/gen/gles_api.py @@ -449,6 +449,11 @@ es2_api = es2_core + ( # GL_OES_get_program_binary 'GetProgramBinaryOES', 'ProgramBinaryOES', + # GL_OES_vertex_array_object + 'BindVertexArrayOES', + 'DeleteVertexArraysOES', + 'GenVertexArraysOES', + 'IsVertexArrayOES', # GL_NV_draw_buffers 'DrawBuffersNV', # GL_NV_read_buffer diff --git a/mesalib/src/mesa/Android.gen.mk b/mesalib/src/mesa/Android.gen.mk index 5443bb99f..f5e63234a 100644 --- a/mesalib/src/mesa/Android.gen.mk +++ b/mesalib/src/mesa/Android.gen.mk @@ -35,13 +35,10 @@ sources := \ main/api_exec_es1.c \ main/api_exec_es1_dispatch.h \ main/api_exec_es1_remap_helper.h \ - main/api_exec_es2.c \ - main/api_exec_es2_dispatch.h \ program/program_parse.tab.c \ program/lex.yy.c \ main/dispatch.h \ - main/remap_helper.h \ - main/api_exec_es2_remap_helper.h + main/remap_helper.h LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES)) @@ -100,9 +97,6 @@ $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_a $(intermediates)/main/api_exec_es1.c: $(es_src_deps) $(call es-gen, -V GLES1.1) -$(intermediates)/main/api_exec_es2.c: $(es_src_deps) - $(call es-gen, -V GLES2.0) - $(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps) $(call es-gen, -c $* -m remap_table) diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am index 6964c8a68..57325afab 100644 --- a/mesalib/src/mesa/Makefile.am +++ b/mesalib/src/mesa/Makefile.am @@ -51,10 +51,7 @@ BUILT_SOURCES = \ main/git_sha1.h \ main/api_exec_es1_dispatch.h \ main/api_exec_es1_remap_helper.h \ - main/api_exec_es2_dispatch.h \ - main/api_exec_es2_remap_helper.h \ main/api_exec_es1.c \ - main/api_exec_es2.c \ program/program_parse.tab.c \ program/program_parse.tab.h \ program/lex.yy.c @@ -70,22 +67,10 @@ main/api_exec_es1_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_d main/api_exec_es1.o: main/api_exec_es1_dispatch.h main/api_exec_es1_remap_helper.h -main/api_exec_es2_dispatch.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_dispatch_deps) - $(call glapi_gen_dispatch,$<,es2) - -main/api_exec_es2_remap_helper.h: $(GLAPI)/gl_and_es_API.xml $(glapi_gen_remap_deps) - $(call glapi_gen_remap,$<,es2) - -main/api_exec_es2.o: main/api_exec_es2_dispatch.h main/api_exec_es2_remap_helper.h - main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/es_generator.py \ -S $(srcdir)/main/APIspec.xml -V GLES1.1 > $@ -main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py - $(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/main/es_generator.py \ - -S $(srcdir)/main/APIspec.xml -V GLES2.0 > $@ - program/program_parse.tab.c program/program_parse.tab.h: program/program_parse.y $(MKDIR_P) program $(AM_V_GEN) $(YACC) -v -d --output=program/program_parse.tab.c $< diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index e2064ce73..920b545a8 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -31,6 +31,7 @@ if env['platform'] == 'windows': else: env.Append(CPPDEFINES = [ 'IN_DRI_DRIVER', # enable the remap table (for DRI drivers) + ('HAVE_DLOPEN', '1'), ]) # @@ -344,12 +345,6 @@ if env['gles']: source = 'main/APIspec.xml', command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES1.1 > $TARGET' ) - gles_sources += env.CodeGenerate( - target = 'main/api_exec_es2.c', - script = 'main/es_generator.py', - source = 'main/APIspec.xml', - command = python_cmd + ' $SCRIPT -S $SOURCE -V GLES2.0 > $TARGET' - ) # generate GLES headers gles_headers = [] @@ -365,18 +360,6 @@ if env['gles']: source = GLAPI + 'gen/gl_and_es_API.xml', command = python_cmd + ' $SCRIPT -c es1 -f $SOURCE > $TARGET', ) - gles_headers += env.CodeGenerate( - target = 'main/api_exec_es2_dispatch.h', - script = GLAPI + 'gen/gl_table.py', - source = GLAPI + 'gen/gl_and_es_API.xml', - command = python_cmd + ' $SCRIPT -c es2 -m remap_table -f $SOURCE > $TARGET', - ) - gles_headers += env.CodeGenerate( - target = 'main/api_exec_es2_remap_helper.h', - script = GLAPI + 'gen/remap_helper.py', - source = GLAPI + 'gen/gl_and_es_API.xml', - command = python_cmd + ' $SCRIPT -c es2 -f $SOURCE > $TARGET', - ) env.Depends(gles_sources, gles_headers) diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 7d7113c56..4b448fed5 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -282,6 +282,8 @@ struct gen_mipmap_state GLuint VBO; GLuint FBO; GLuint Sampler; + GLuint ShaderProg; + GLuint IntegerShaderProg; }; @@ -330,6 +332,8 @@ struct gl_meta_state static void meta_glsl_blit_cleanup(struct gl_context *ctx, struct blit_state *blit); static void cleanup_temp_texture(struct gl_context *ctx, struct temp_texture *tex); static void meta_glsl_clear_cleanup(struct gl_context *ctx, struct clear_state *clear); +static void meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx, + struct gen_mipmap_state *mipmap); static GLuint compile_shader_with_debug(struct gl_context *ctx, GLenum target, const GLcharARB *source) @@ -422,6 +426,7 @@ _mesa_meta_free(struct gl_context *ctx) _mesa_make_current(ctx, NULL, NULL); meta_glsl_blit_cleanup(ctx, &ctx->Meta->Blit); meta_glsl_clear_cleanup(ctx, &ctx->Meta->Clear); + meta_glsl_generate_mipmap_cleanup(ctx, &ctx->Meta->Mipmap); cleanup_temp_texture(ctx, &ctx->Meta->TempTex); if (old_context) _mesa_make_current(old_context, old_context->WinSysDrawBuffer, old_context->WinSysReadBuffer); @@ -432,6 +437,35 @@ _mesa_meta_free(struct gl_context *ctx) } +/** + * This is an alternative to _mesa_set_enable() to handle some special cases. + * See comments inside. + */ +static void +meta_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) +{ + switch (cap) { + case GL_MULTISAMPLE: + /* We need to enable/disable multisample when using GLES but this enum + * is not supported there. + */ + if (ctx->Multisample.Enabled == state) + return; + FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE); + ctx->Multisample.Enabled = state; + break; + default: + _mesa_problem(ctx, "Unexpected cap in _meta_set_enable()"); + return; + } + + if (ctx->Driver.Enable) { + ctx->Driver.Enable(ctx, cap, state); + } +} + + + /** * Enter meta state. This is like a light-weight version of glPushAttrib * but it also resets most GL state back to default values. @@ -549,8 +583,10 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) save->PolygonCull = ctx->Polygon.CullFlag; _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL); _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, GL_FALSE); - _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE); - _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE); + if (ctx->API == API_OPENGL) { + _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, GL_FALSE); + _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, GL_FALSE); + } _mesa_set_enable(ctx, GL_CULL_FACE, GL_FALSE); } @@ -560,14 +596,14 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) } if (state & MESA_META_SHADER) { - if (ctx->Extensions.ARB_vertex_program) { + if (ctx->API == API_OPENGL && ctx->Extensions.ARB_vertex_program) { save->VertexProgramEnabled = ctx->VertexProgram.Enabled; _mesa_reference_vertprog(ctx, &save->VertexProgram, ctx->VertexProgram.Current); _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE); } - if (ctx->Extensions.ARB_fragment_program) { + if (ctx->API == API_OPENGL && ctx->Extensions.ARB_fragment_program) { save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled; _mesa_reference_fragprog(ctx, &save->FragmentProgram, ctx->FragmentProgram.Current); @@ -603,25 +639,27 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) save->EnvMode = ctx->Texture.Unit[0].EnvMode; /* Disable all texture units */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled; - save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled; - if (ctx->Texture.Unit[u].Enabled || - ctx->Texture.Unit[u].TexGenEnabled) { - _mesa_ActiveTextureARB(GL_TEXTURE0 + u); - _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE); - if (ctx->Extensions.ARB_texture_cube_map) - _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE); - if (ctx->Extensions.NV_texture_rectangle) - _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE); - if (ctx->Extensions.OES_EGL_image_external) - _mesa_set_enable(ctx, GL_TEXTURE_EXTERNAL_OES, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE); - _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE); + if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + save->TexEnabled[u] = ctx->Texture.Unit[u].Enabled; + save->TexGenEnabled[u] = ctx->Texture.Unit[u].TexGenEnabled; + if (ctx->Texture.Unit[u].Enabled || + ctx->Texture.Unit[u].TexGenEnabled) { + _mesa_ActiveTextureARB(GL_TEXTURE0 + u); + _mesa_set_enable(ctx, GL_TEXTURE_1D, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_2D, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_3D, GL_FALSE); + if (ctx->Extensions.ARB_texture_cube_map) + _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE); + if (ctx->Extensions.NV_texture_rectangle) + _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE, GL_FALSE); + if (ctx->Extensions.OES_EGL_image_external) + _mesa_set_enable(ctx, GL_TEXTURE_EXTERNAL_OES, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_S, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_T, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_R, GL_FALSE); + _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q, GL_FALSE); + } } } @@ -634,7 +672,9 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) /* set defaults for unit[0] */ _mesa_ActiveTextureARB(GL_TEXTURE0); _mesa_ClientActiveTextureARB(GL_TEXTURE0); - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + } } if (state & MESA_META_TRANSFORM) { @@ -744,7 +784,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) if (state & MESA_META_MULTISAMPLE) { save->MultisampleEnabled = ctx->Multisample.Enabled; if (ctx->Multisample.Enabled) - _mesa_set_enable(ctx, GL_MULTISAMPLE, GL_FALSE); + meta_set_enable(ctx, GL_MULTISAMPLE, GL_FALSE); } /* misc */ @@ -765,7 +805,7 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state) void _mesa_meta_end(struct gl_context *ctx) { - struct save_state *save = &ctx->Meta->Save[--ctx->Meta->SaveStackDepth]; + struct save_state *save = &ctx->Meta->Save[ctx->Meta->SaveStackDepth - 1]; const GLbitfield state = save->SavedState; if (state & MESA_META_ALPHA_TEST) { @@ -840,11 +880,19 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_RASTERIZATION) { - _mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode); - _mesa_PolygonMode(GL_BACK, save->BackPolygonMode); - _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple); + /* Core context requires that front and back mode be the same. + */ + if (ctx->API == API_OPENGL_CORE) { + _mesa_PolygonMode(GL_FRONT_AND_BACK, save->FrontPolygonMode); + } else { + _mesa_PolygonMode(GL_FRONT, save->FrontPolygonMode); + _mesa_PolygonMode(GL_BACK, save->BackPolygonMode); + } + if (ctx->API == API_OPENGL) { + _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, save->PolygonStipple); + _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth); + } _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL, save->PolygonOffset); - _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, save->PolygonSmooth); _mesa_set_enable(ctx, GL_CULL_FACE, save->PolygonCull); } @@ -855,7 +903,7 @@ _mesa_meta_end(struct gl_context *ctx) } if (state & MESA_META_SHADER) { - if (ctx->Extensions.ARB_vertex_program) { + if (ctx->API == API_OPENGL && ctx->Extensions.ARB_vertex_program) { _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, save->VertexProgramEnabled); _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, @@ -863,7 +911,7 @@ _mesa_meta_end(struct gl_context *ctx) _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL); } - if (ctx->Extensions.ARB_fragment_program) { + if (ctx->API == API_OPENGL && ctx->Extensions.ARB_fragment_program) { _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, save->FragmentProgramEnabled); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, @@ -896,7 +944,7 @@ _mesa_meta_end(struct gl_context *ctx) _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled); _mesa_ClearStencil(stencil->Clear); - if (ctx->Extensions.EXT_stencil_two_side) { + if (ctx->API == API_OPENGL && ctx->Extensions.EXT_stencil_two_side) { _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, stencil->TestTwoSide); _mesa_ActiveStencilFaceEXT(stencil->ActiveFace @@ -928,7 +976,9 @@ _mesa_meta_end(struct gl_context *ctx) ASSERT(ctx->Texture.CurrentUnit == 0); /* restore texenv for unit[0] */ - _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); + if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, save->EnvMode); + } /* restore texture objects for unit[0] only */ for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { @@ -941,16 +991,18 @@ _mesa_meta_end(struct gl_context *ctx) } /* Restore fixed function texture enables, texgen */ - for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { - if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.Unit[u].Enabled = save->TexEnabled[u]; - } + if (ctx->API == API_OPENGL || ctx->API == API_OPENGLES) { + for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { + if (ctx->Texture.Unit[u].Enabled != save->TexEnabled[u]) { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + ctx->Texture.Unit[u].Enabled = save->TexEnabled[u]; + } - if (ctx->Texture.Unit[u].TexGenEnabled != save->TexGenEnabled[u]) { - FLUSH_VERTICES(ctx, _NEW_TEXTURE); - ctx->Texture.Unit[u].TexGenEnabled = save->TexGenEnabled[u]; - } + if (ctx->Texture.Unit[u].TexGenEnabled != save->TexGenEnabled[u]) { + FLUSH_VERTICES(ctx, _NEW_TEXTURE); + ctx->Texture.Unit[u].TexGenEnabled = save->TexGenEnabled[u]; + } + } } /* restore current unit state */ @@ -1034,7 +1086,7 @@ _mesa_meta_end(struct gl_context *ctx) if (state & MESA_META_MULTISAMPLE) { if (ctx->Multisample.Enabled != save->MultisampleEnabled) - _mesa_set_enable(ctx, GL_MULTISAMPLE, save->MultisampleEnabled); + meta_set_enable(ctx, GL_MULTISAMPLE, save->MultisampleEnabled); } /* misc */ @@ -1048,6 +1100,8 @@ _mesa_meta_end(struct gl_context *ctx) if (save->TransformFeedbackNeedsResume) _mesa_ResumeTransformFeedback(); #endif + + ctx->Meta->SaveStackDepth--; } @@ -1400,7 +1454,8 @@ blitframebuffer_texture(struct gl_context *ctx, _mesa_SamplerParameteri(sampler, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); } - if (ctx->Extensions.EXT_framebuffer_sRGB) { + if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_framebuffer_sRGB) + || _mesa_is_gles3(ctx)) { _mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE); } @@ -1799,7 +1854,7 @@ meta_glsl_clear_init(struct gl_context *ctx, struct clear_state *clear) "}\n"; const char *vs_int_source = "#version 130\n" - "attribute vec4 position;\n" + "in vec4 position;\n" "void main()\n" "{\n" " gl_Position = position;\n" @@ -2913,6 +2968,157 @@ setup_texture_coords(GLenum faceTarget, } +static void +setup_ff_generate_mipmap(struct gl_context *ctx, + struct gen_mipmap_state *mipmap) +{ + struct vertex { + GLfloat x, y, tex[3]; + }; + + if (mipmap->ArrayObj == 0) { + /* one-time setup */ + /* create vertex array object */ + _mesa_GenVertexArraysAPPLE(1, &mipmap->ArrayObj); + _mesa_BindVertexArrayAPPLE(mipmap->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, &mipmap->VBO); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO); + /* setup vertex arrays */ + _mesa_VertexPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); + _mesa_TexCoordPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(tex)); + _mesa_EnableClientState(GL_VERTEX_ARRAY); + _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + } + + /* setup projection matrix */ + _mesa_MatrixMode(GL_PROJECTION); + _mesa_LoadIdentity(); + _mesa_Ortho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0); +} + + +static void +setup_glsl_generate_mipmap(struct gl_context *ctx, + struct gen_mipmap_state *mipmap) +{ + struct vertex { + GLfloat x, y, tex[3]; + }; + + static const char *vs_source = + "attribute vec2 position;\n" + "attribute vec3 textureCoords;\n" + "varying vec3 texCoords;\n" + "void main()\n" + "{\n" + " texCoords = textureCoords;\n" + " gl_Position = vec4(position, 0.0, 1.0);\n" + "}\n"; + static const char *fs_source = + "uniform sampler2D tex2d;\n" + "varying vec3 texCoords;\n" + "void main()\n" + "{\n" + " gl_FragColor = texture2D(tex2d, texCoords.xy);\n" + "}\n"; + + static const char *vs_int_source = + "#version 130\n" + "in vec2 position;\n" + "in vec3 textureCoords;\n" + "out vec3 texCoords;\n" + "void main()\n" + "{\n" + " texCoords = textureCoords;\n" + " gl_Position = gl_Vertex;\n" + "}\n"; + static const char *fs_int_source = + "#version 130\n" + "uniform isampler2D tex2d;\n" + "in vec3 texCoords;\n" + "out ivec4 out_color;\n" + "\n" + "void main()\n" + "{\n" + " out_color = texture(tex2d, texCoords.xy);\n" + "}\n"; + GLuint vs, fs; + + /* Check if already initialized */ + if (mipmap->ArrayObj != 0) + return; + /* create vertex array object */ + _mesa_GenVertexArrays(1, &mipmap->ArrayObj); + _mesa_BindVertexArray(mipmap->ArrayObj); + + /* create vertex array buffer */ + _mesa_GenBuffersARB(1, &mipmap->VBO); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO); + + /* setup vertex arrays */ + _mesa_VertexAttribPointerARB(0, 2, GL_FLOAT, GL_FALSE, + sizeof(struct vertex), OFFSET(x)); + _mesa_VertexAttribPointerARB(1, 3, GL_FLOAT, GL_FALSE, + sizeof(struct vertex), OFFSET(tex)); + + vs = compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_source); + fs = compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_source); + + mipmap->ShaderProg = _mesa_CreateProgramObjectARB(); + _mesa_AttachShader(mipmap->ShaderProg, fs); + _mesa_DeleteObjectARB(fs); + _mesa_AttachShader(mipmap->ShaderProg, vs); + _mesa_DeleteObjectARB(vs); + _mesa_BindAttribLocationARB(mipmap->ShaderProg, 0, "position"); + _mesa_BindAttribLocationARB(mipmap->ShaderProg, 1, "texcoords"); + _mesa_EnableVertexAttribArrayARB(0); + _mesa_EnableVertexAttribArrayARB(1); + link_program_with_debug(ctx, mipmap->ShaderProg); + + if ((_mesa_is_desktop_gl(ctx) && ctx->Const.GLSLVersion >= 130) || + _mesa_is_gles3(ctx)){ + vs = compile_shader_with_debug(ctx, GL_VERTEX_SHADER, vs_int_source); + fs = compile_shader_with_debug(ctx, GL_FRAGMENT_SHADER, fs_int_source); + + mipmap->IntegerShaderProg = _mesa_CreateProgramObjectARB(); + _mesa_AttachShader(mipmap->IntegerShaderProg, fs); + _mesa_DeleteObjectARB(fs); + _mesa_AttachShader(mipmap->IntegerShaderProg, vs); + _mesa_DeleteObjectARB(vs); + _mesa_BindAttribLocationARB(mipmap->IntegerShaderProg, 0, "position"); + _mesa_BindAttribLocationARB(mipmap->IntegerShaderProg, 1, "texcoords"); + + /* Note that user-defined out attributes get automatically assigned + * locations starting from 0, so we don't need to explicitly + * BindFragDataLocation to 0. + */ + link_program_with_debug(ctx, mipmap->IntegerShaderProg); + } +} + + +static void +meta_glsl_generate_mipmap_cleanup(struct gl_context *ctx, + struct gen_mipmap_state *mipmap) +{ + if (mipmap->ArrayObj == 0) + return; + _mesa_DeleteVertexArraysAPPLE(1, &mipmap->ArrayObj); + mipmap->ArrayObj = 0; + _mesa_DeleteBuffersARB(1, &mipmap->VBO); + mipmap->VBO = 0; + _mesa_DeleteObjectARB(mipmap->ShaderProg); + mipmap->ShaderProg = 0; + + if (mipmap->IntegerShaderProg) { + _mesa_DeleteObjectARB(mipmap->IntegerShaderProg); + mipmap->IntegerShaderProg = 0; + } +} + + /** * Called via ctx->Driver.GenerateMipmap() * Note: We don't yet support 3D textures, 1D/2D array textures or texture @@ -2933,10 +3139,12 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, const GLboolean genMipmapSave = texObj->GenerateMipmap; const GLenum srgbBufferSave = ctx->Color.sRGBEnabled; const GLuint fboSave = ctx->DrawBuffer->Name; - const GLuint original_active_unit = ctx->Texture.CurrentUnit; + const GLuint currentTexUnitSave = ctx->Texture.CurrentUnit; + const GLboolean use_glsl_version = ctx->Extensions.ARB_vertex_shader && + ctx->Extensions.ARB_fragment_shader && + (ctx->API != API_OPENGLES); GLenum faceTarget; GLuint dstLevel; - const GLuint border = 0; const GLint slice = 0; GLuint samplerSave; @@ -2956,36 +3164,31 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, _mesa_meta_begin(ctx, MESA_META_ALL); - samplerSave = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ? - ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0; - - if (original_active_unit != 0) - _mesa_BindTexture(target, texObj->Name); - - if (mipmap->ArrayObj == 0) { - /* one-time setup */ - - /* create vertex array object */ - _mesa_GenVertexArraysAPPLE(1, &mipmap->ArrayObj); - _mesa_BindVertexArrayAPPLE(mipmap->ArrayObj); - - /* create vertex array buffer */ - _mesa_GenBuffersARB(1, &mipmap->VBO); - _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO); - _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), - NULL, GL_DYNAMIC_DRAW_ARB); + /* Choose between glsl version and fixed function version of + * GenerateMipmap function. + */ + if (use_glsl_version) { + setup_glsl_generate_mipmap(ctx, mipmap); - /* setup vertex arrays */ - _mesa_VertexPointer(2, GL_FLOAT, sizeof(struct vertex), OFFSET(x)); - _mesa_TexCoordPointer(3, GL_FLOAT, sizeof(struct vertex), OFFSET(tex)); - _mesa_EnableClientState(GL_VERTEX_ARRAY); - _mesa_EnableClientState(GL_TEXTURE_COORD_ARRAY); + if (texObj->_IsIntegerFormat) + _mesa_UseProgramObjectARB(mipmap->IntegerShaderProg); + else + _mesa_UseProgramObjectARB(mipmap->ShaderProg); } else { - _mesa_BindVertexArray(mipmap->ArrayObj); - _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO); + setup_ff_generate_mipmap(ctx, mipmap); + _mesa_set_enable(ctx, target, GL_TRUE); } + _mesa_BindVertexArray(mipmap->ArrayObj); + _mesa_BindBufferARB(GL_ARRAY_BUFFER_ARB, mipmap->VBO); + + samplerSave = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler ? + ctx->Texture.Unit[ctx->Texture.CurrentUnit].Sampler->Name : 0; + + if (currentTexUnitSave != 0) + _mesa_BindTexture(target, texObj->Name); + if (!mipmap->FBO) { _mesa_GenFramebuffersEXT(1, &mipmap->FBO); } @@ -2993,12 +3196,25 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, if (!mipmap->Sampler) { _mesa_GenSamplers(1, &mipmap->Sampler); _mesa_BindSampler(ctx->Texture.CurrentUnit, mipmap->Sampler); - _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); + + if (use_glsl_version && texObj->_IsIntegerFormat) + _mesa_SamplerParameteri(mipmap->Sampler, + GL_TEXTURE_MIN_FILTER, + GL_NEAREST_MIPMAP_NEAREST); + else + _mesa_SamplerParameteri(mipmap->Sampler, + GL_TEXTURE_MIN_FILTER, + GL_LINEAR_MIPMAP_LINEAR); + _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR); _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); - /* We don't want to encode or decode sRGB values; treat them as linear */ + + /* We don't want to encode or decode sRGB values; treat them as linear. + * This is not technically correct for GLES3 but we don't get any API + * error at the moment. + */ if (ctx->Extensions.EXT_texture_sRGB_decode) { _mesa_SamplerParameteri(mipmap->Sampler, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT); @@ -3015,13 +3231,13 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, else assert(!genMipmapSave); - if (ctx->Extensions.EXT_framebuffer_sRGB) { + if ((ctx->Extensions.EXT_framebuffer_sRGB && + _mesa_is_desktop_gl(ctx)) || + _mesa_is_gles3(ctx)) { _mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE); } - _mesa_set_enable(ctx, target, GL_TRUE); - - /* setup texcoords (XXX what about border?) */ + /* Setup texture coordinates */ setup_texture_coords(faceTarget, slice, 0, 0, /* width, height never used here */ @@ -3031,22 +3247,18 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, verts[3].tex); /* setup vertex positions */ - verts[0].x = 0.0F; - verts[0].y = 0.0F; - verts[1].x = 1.0F; - verts[1].y = 0.0F; - verts[2].x = 1.0F; - verts[2].y = 1.0F; - verts[3].x = 0.0F; - verts[3].y = 1.0F; - - /* upload new vertex data */ - _mesa_BufferSubDataARB(GL_ARRAY_BUFFER_ARB, 0, sizeof(verts), verts); - - /* setup projection matrix */ - _mesa_MatrixMode(GL_PROJECTION); - _mesa_LoadIdentity(); - _mesa_Ortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); + verts[0].x = -1.0F; + verts[0].y = -1.0F; + verts[1].x = 1.0F; + verts[1].y = -1.0F; + verts[2].x = 1.0F; + verts[2].y = 1.0F; + verts[3].x = -1.0F; + verts[3].y = 1.0F; + + /* upload vertex data */ + _mesa_BufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), + verts, GL_DYNAMIC_DRAW_ARB); /* texture is already locked, unlock now */ _mesa_unlock_texture(ctx, texObj); @@ -3059,17 +3271,17 @@ _mesa_meta_GenerateMipmap(struct gl_context *ctx, GLenum target, GLenum status; srcImage = _mesa_select_tex_image(ctx, texObj, faceTarget, srcLevel); - assert(srcImage->Border == 0); /* XXX we can fix this */ + assert(srcImage->Border == 0); - /* src size w/out border */ - srcWidth = srcImage->Width - 2 * border; - srcHeight = srcImage->Height - 2 * border; - srcDepth = srcImage->Depth - 2 * border; + /* src size */ + srcWidth = srcImage->Width; + srcHeight = srcImage->Height; + srcDepth = srcImage->Depth; - /* new dst size w/ border */ - dstWidth = MAX2(1, srcWidth / 2) + 2 * border; - dstHeight = MAX2(1, srcHeight / 2) + 2 * border; - dstDepth = MAX2(1, srcDepth / 2) + 2 * border; + /* new dst size */ + dstWidth = MAX2(1, srcWidth / 2); + dstHeight = MAX2(1, srcHeight / 2); + dstDepth = MAX2(1, srcDepth / 2); if (dstWidth == srcImage->Width && dstHeight == srcImage->Height && @@ -3424,7 +3636,8 @@ decompress_texture_image(struct gl_context *ctx, } /* No sRGB decode or encode.*/ - if (ctx->Extensions.EXT_framebuffer_sRGB) { + if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.EXT_framebuffer_sRGB) + || _mesa_is_gles3(ctx)) { _mesa_set_enable(ctx, GL_FRAMEBUFFER_SRGB_EXT, GL_FALSE); } diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index 86409dd06..4276ad981 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -257,17 +257,17 @@ dri2CreateContextAttribs(__DRIscreen *screen, int api, * "Forward-compatible contexts are defined only for OpenGL versions * 3.0 and later." * - * Moreover, Mesa can't fulfill the requirements of a forward-looking - * context. Return failure if a forward-looking context is requested. + * Forward-looking contexts are supported by silently converting the + * requested API to API_OPENGL_CORE. * * In Mesa, a debug context is the same as a regular context. */ if ((flags & __DRI_CTX_FLAG_FORWARD_COMPATIBLE) != 0) { - *error = __DRI_CTX_ERROR_BAD_FLAG; - return NULL; + mesa_api = API_OPENGL_CORE; } - if ((flags & ~__DRI_CTX_FLAG_DEBUG) != 0) { + if ((flags & ~(__DRI_CTX_FLAG_DEBUG | __DRI_CTX_FLAG_FORWARD_COMPATIBLE)) + != 0) { *error = __DRI_CTX_ERROR_UNKNOWN_FLAG; return NULL; } diff --git a/mesalib/src/mesa/main/.gitignore b/mesalib/src/mesa/main/.gitignore index caed74f40..b26be227f 100644 --- a/mesalib/src/mesa/main/.gitignore +++ b/mesalib/src/mesa/main/.gitignore @@ -1,5 +1,4 @@ api_exec_es1.c -api_exec_es2.c dispatch.h enums.c get_es1.c @@ -8,6 +7,4 @@ git_sha1.h git_sha1.h.tmp api_exec_es1_dispatch.h api_exec_es1_remap_helper.h -api_exec_es2_dispatch.h -api_exec_es2_remap_helper.h remap_helper.h diff --git a/mesalib/src/mesa/main/APIspec.xml b/mesalib/src/mesa/main/APIspec.xml index 3121226ca..a65c5c529 100644 --- a/mesalib/src/mesa/main/APIspec.xml +++ b/mesalib/src/mesa/main/APIspec.xml @@ -58,29 +58,6 @@ - - - - - - - - - - - - - - - - - - - - - - - @@ -564,56 +271,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -