From 150771e7aabf4c864b0b970c5b8d773634793abe Mon Sep 17 00:00:00 2001 From: marha Date: Tue, 4 Jun 2013 09:07:26 +0200 Subject: xwininfo fontconfig libX11 libXau libXdmcp libXext mesa libXinerama libxcb libxcb/xcb-proto libfontenc pixman xkbcomp mkfontscale xkeyboard-config git update 4 Jun 2013 xserver commit c21344add2fc589df83b29be5831c36a372201bd libxcb commit 9ae84ad187e2ba440c40f44b8eb21c82c2fdbf12 libxcb/xcb-proto commit bdfedfa57a13ff805580cfacafc70f9cc55df363 xkeyboard-config commit dad9ade4e83d1ef5a517fcc4cc9ad3a79b47acce libX11 commit 8496122eb00ce6cd5d2308ee54f64b68c378e455 libXdmcp commit 0b443c1b769b9c9a3b45b4252afe07e18b709ff4 libXext commit d8366afbb0d2e4fbb1e419b1187f490522270bea libfontenc commit 3acba630d8b57084f7e92c15732408711ed5137a libXinerama commit 6e1d1dc328ba8162bba2f4694e7f3c706a1491ff libXau commit 899790011304c4029e15abf410e49ce7cec17e0a xkbcomp commit ed582f4fccd4e23abcfba8b3b03649fea6414f44 pixman commit 2acfac5f8e097ee2ae225d986f981b55d65dd152 mkfontscale commit 19e2cb7c6a3ec2c5b1bc0d24866fa685eef0ee13 xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 fontconfig commit cd9b1033a68816a7acfbba1718ba0aa5888f6ec7 mesa commit 7bafd88c153e395274b632e7eae4bc9fc3aec1d2 --- mesalib/src/Makefile.am | 55 +- mesalib/src/gallium/Android.mk | 5 + mesalib/src/gallium/Makefile.am | 22 - mesalib/src/gallium/SConscript | 49 +- mesalib/src/gallium/auxiliary/Makefile.sources | 1 + mesalib/src/gallium/auxiliary/SConscript | 4 - mesalib/src/gallium/auxiliary/hud/hud_context.c | 67 +- mesalib/src/gallium/auxiliary/hud/hud_fps.c | 3 +- mesalib/src/gallium/auxiliary/util/u_blit.c | 3 +- mesalib/src/gallium/auxiliary/util/u_blitter.c | 98 +- mesalib/src/gallium/auxiliary/util/u_blitter.h | 18 +- .../src/gallium/auxiliary/util/u_debug_symbol.c | 6 +- mesalib/src/gallium/auxiliary/util/u_dump_state.c | 3 +- mesalib/src/gallium/auxiliary/util/u_format.c | 34 + mesalib/src/gallium/auxiliary/util/u_format.h | 12 + mesalib/src/gallium/auxiliary/util/u_format_latc.c | 7 +- mesalib/src/gallium/auxiliary/util/u_format_rgtc.c | 7 +- mesalib/src/gallium/auxiliary/util/u_format_s3tc.c | 7 +- mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c | 3 +- mesalib/src/gallium/auxiliary/util/u_inlines.h | 3 +- mesalib/src/gallium/auxiliary/util/u_prim.h | 227 +-- mesalib/src/gallium/auxiliary/util/u_simple_list.h | 7 +- mesalib/src/gallium/auxiliary/util/u_sse.h | 7 +- mesalib/src/glsl/Makefile.am | 3 +- mesalib/src/glsl/Makefile.sources | 5 + mesalib/src/glsl/ast.h | 14 +- mesalib/src/glsl/ast_array_index.cpp | 190 +++ mesalib/src/glsl/ast_function.cpp | 149 +- mesalib/src/glsl/ast_to_hir.cpp | 274 ++-- mesalib/src/glsl/builtin_variables.cpp | 33 +- mesalib/src/glsl/glcpp/glcpp-parse.y | 6 + mesalib/src/glsl/glcpp/pp.c | 4 +- mesalib/src/glsl/glsl_parser.yy | 188 ++- mesalib/src/glsl/glsl_parser_extras.cpp | 15 +- mesalib/src/glsl/glsl_parser_extras.h | 4 + mesalib/src/glsl/glsl_symbol_table.cpp | 84 +- mesalib/src/glsl/glsl_symbol_table.h | 4 + mesalib/src/glsl/glsl_types.cpp | 4 + mesalib/src/glsl/glsl_types.h | 3 +- mesalib/src/glsl/ir.cpp | 16 +- mesalib/src/glsl/ir.h | 68 +- mesalib/src/glsl/ir_basic_block.cpp | 2 +- mesalib/src/glsl/ir_constant_expression.cpp | 185 ++- mesalib/src/glsl/ir_optimization.h | 7 +- mesalib/src/glsl/ir_print_visitor.cpp | 5 +- mesalib/src/glsl/ir_reader.cpp | 10 +- mesalib/src/glsl/ir_uniform.h | 27 +- mesalib/src/glsl/ir_validate.cpp | 82 ++ mesalib/src/glsl/link_interface_blocks.cpp | 110 ++ mesalib/src/glsl/link_uniform_initializers.cpp | 25 +- mesalib/src/glsl/link_uniforms.cpp | 126 +- mesalib/src/glsl/link_varyings.cpp | 69 +- mesalib/src/glsl/linker.cpp | 28 +- mesalib/src/glsl/linker.h | 8 + mesalib/src/glsl/lower_clip_distance.cpp | 124 +- mesalib/src/glsl/lower_instructions.cpp | 39 + mesalib/src/glsl/lower_named_interface_blocks.cpp | 238 ++++ mesalib/src/glsl/lower_packed_varyings.cpp | 8 + .../src/glsl/lower_vec_index_to_cond_assign.cpp | 149 +- mesalib/src/glsl/lower_vec_index_to_swizzle.cpp | 37 +- mesalib/src/glsl/lower_vector_insert.cpp | 139 ++ mesalib/src/glsl/main.cpp | 4 +- mesalib/src/glsl/opt_algebraic.cpp | 6 +- mesalib/src/glsl/opt_flip_matrices.cpp | 122 ++ mesalib/src/glsl/opt_if_simplification.cpp | 27 +- mesalib/src/glsl/program.h | 7 +- mesalib/src/glsl/ralloc.c | 8 +- mesalib/src/glsl/standalone_scaffolding.cpp | 17 +- mesalib/src/glsl/standalone_scaffolding.h | 17 + mesalib/src/glsl/test_optpass.cpp | 14 +- mesalib/src/mapi/Android.mk | 16 +- mesalib/src/mapi/Makefile.am | 42 + mesalib/src/mapi/Makefile.sources | 36 + mesalib/src/mapi/entry.c | 98 ++ mesalib/src/mapi/entry.h | 48 + mesalib/src/mapi/entry_x86-64_tls.h | 113 ++ mesalib/src/mapi/entry_x86_tls.h | 133 ++ mesalib/src/mapi/entry_x86_tsd.h | 104 ++ mesalib/src/mapi/glapi/Makefile.am | 4 +- mesalib/src/mapi/glapi/Makefile.sources | 19 + mesalib/src/mapi/glapi/SConscript | 10 +- mesalib/src/mapi/glapi/gen/GL3x.xml | 18 +- mesalib/src/mapi/glapi/gen/Makefile.am | 2 +- mesalib/src/mapi/glapi/gen/es_EXT.xml | 23 +- mesalib/src/mapi/glapi/gen/gl_API.xml | 72 +- mesalib/src/mapi/glapi/gen/gl_XML.py | 2 + mesalib/src/mapi/glapi/gen/gl_enums.py | 8 +- mesalib/src/mapi/glapi/gen/gl_genexec.py | 4 +- mesalib/src/mapi/glapi/gen/gl_table.py | 21 - mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py | 13 - mesalib/src/mapi/glapi/gen/gl_x86_asm.py | 13 - mesalib/src/mapi/glapi/gen/glapi_gen.mk | 2 +- mesalib/src/mapi/glapi/gen/mesadef.py | 7 +- mesalib/src/mapi/glapi/glapi.c | 2 +- mesalib/src/mapi/glapi/glapi.h | 7 +- mesalib/src/mapi/glapi/glapi_dispatch.c | 7 +- mesalib/src/mapi/glapi/glapi_entrypoint.c | 9 +- mesalib/src/mapi/glapi/glapi_getproc.c | 7 +- mesalib/src/mapi/glapi/glapi_nop.c | 7 +- mesalib/src/mapi/glapi/glapi_priv.h | 7 +- mesalib/src/mapi/glapi/glthread.h | 2 +- mesalib/src/mapi/glapi/sources.mak | 19 - mesalib/src/mapi/mapi.c | 191 +++ mesalib/src/mapi/mapi.h | 66 + mesalib/src/mapi/mapi/entry.c | 98 -- mesalib/src/mapi/mapi/entry.h | 48 - mesalib/src/mapi/mapi/entry_x86-64_tls.h | 126 -- mesalib/src/mapi/mapi/entry_x86_tls.h | 146 -- mesalib/src/mapi/mapi/entry_x86_tsd.h | 104 -- mesalib/src/mapi/mapi/mapi.c | 191 --- mesalib/src/mapi/mapi/mapi.h | 66 - mesalib/src/mapi/mapi/mapi_abi.py | 873 ------------ mesalib/src/mapi/mapi/mapi_glapi.c | 240 ---- mesalib/src/mapi/mapi/mapi_tmp.h | 48 - mesalib/src/mapi/mapi/sources.mak | 36 - mesalib/src/mapi/mapi/stub.c | 229 --- mesalib/src/mapi/mapi/stub.h | 60 - mesalib/src/mapi/mapi/table.c | 56 - mesalib/src/mapi/mapi/table.h | 72 - mesalib/src/mapi/mapi/u_compiler.h | 33 - mesalib/src/mapi/mapi/u_current.c | 266 ---- mesalib/src/mapi/mapi/u_current.h | 87 -- mesalib/src/mapi/mapi/u_execmem.c | 145 -- mesalib/src/mapi/mapi/u_execmem.h | 7 - mesalib/src/mapi/mapi/u_macros.h | 12 - mesalib/src/mapi/mapi/u_thread.h | 287 ---- mesalib/src/mapi/mapi_abi.py | 873 ++++++++++++ mesalib/src/mapi/mapi_glapi.c | 240 ++++ mesalib/src/mapi/mapi_tmp.h | 48 + mesalib/src/mapi/stub.c | 229 +++ mesalib/src/mapi/stub.h | 60 + mesalib/src/mapi/table.c | 56 + mesalib/src/mapi/table.h | 72 + mesalib/src/mapi/u_compiler.h | 33 + mesalib/src/mapi/u_current.c | 267 ++++ mesalib/src/mapi/u_current.h | 87 ++ mesalib/src/mapi/u_execmem.c | 146 ++ mesalib/src/mapi/u_execmem.h | 7 + mesalib/src/mapi/u_macros.h | 12 + mesalib/src/mapi/u_thread.h | 288 ++++ mesalib/src/mesa/Android.gen.mk | 3 +- mesalib/src/mesa/Android.libmesa_dricore.mk | 2 +- mesalib/src/mesa/Android.libmesa_st_mesa.mk | 2 +- mesalib/src/mesa/Makefile.am | 24 +- mesalib/src/mesa/Makefile.sources | 350 +++++ mesalib/src/mesa/SConscript | 12 +- mesalib/src/mesa/drivers/Makefile.am | 22 - mesalib/src/mesa/drivers/common/driverfuncs.c | 10 +- mesalib/src/mesa/drivers/common/driverfuncs.h | 7 +- mesalib/src/mesa/drivers/common/meta.c | 57 +- mesalib/src/mesa/drivers/common/meta.h | 7 +- mesalib/src/mesa/drivers/dri/common/Makefile.am | 1 - mesalib/src/mesa/drivers/dri/common/drisw_util.c | 7 +- mesalib/src/mesa/drivers/dri/common/xmlpool.h | 7 + .../mesa/drivers/dri/common/xmlpool/t_options.h | 30 +- mesalib/src/mesa/drivers/dri/swrast/Makefile.am | 1 - mesalib/src/mesa/drivers/dri/swrast/swrast.c | 7 +- mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h | 7 +- mesalib/src/mesa/main/accum.c | 8 +- mesalib/src/mesa/main/accum.h | 8 +- mesalib/src/mesa/main/api_arrayelt.c | 110 +- mesalib/src/mesa/main/api_arrayelt.h | 12 +- mesalib/src/mesa/main/api_exec.h | 7 +- mesalib/src/mesa/main/api_loopback.c | 8 +- mesalib/src/mesa/main/api_loopback.h | 9 +- mesalib/src/mesa/main/api_validate.c | 41 +- mesalib/src/mesa/main/api_validate.h | 13 +- mesalib/src/mesa/main/arbprogram.c | 7 +- mesalib/src/mesa/main/arbprogram.h | 7 +- mesalib/src/mesa/main/arrayobj.c | 9 +- mesalib/src/mesa/main/arrayobj.h | 8 +- mesalib/src/mesa/main/atifragshader.c | 1 - mesalib/src/mesa/main/atifragshader.h | 1 - mesalib/src/mesa/main/attrib.c | 11 +- mesalib/src/mesa/main/attrib.h | 8 +- mesalib/src/mesa/main/bitset.h | 11 +- mesalib/src/mesa/main/blend.c | 25 +- mesalib/src/mesa/main/blend.h | 11 +- mesalib/src/mesa/main/bufferobj.c | 21 +- mesalib/src/mesa/main/bufferobj.h | 8 +- mesalib/src/mesa/main/buffers.c | 12 +- mesalib/src/mesa/main/buffers.h | 7 +- mesalib/src/mesa/main/clear.c | 56 +- mesalib/src/mesa/main/clear.h | 7 +- mesalib/src/mesa/main/clip.c | 7 +- mesalib/src/mesa/main/clip.h | 7 +- mesalib/src/mesa/main/colormac.h | 7 +- mesalib/src/mesa/main/colortab.c | 8 +- mesalib/src/mesa/main/colortab.h | 8 +- mesalib/src/mesa/main/compiler.h | 7 +- mesalib/src/mesa/main/config.h | 21 +- mesalib/src/mesa/main/context.c | 44 +- mesalib/src/mesa/main/context.h | 38 +- mesalib/src/mesa/main/convolve.c | 8 +- mesalib/src/mesa/main/convolve.h | 8 +- mesalib/src/mesa/main/cpuinfo.c | 7 +- mesalib/src/mesa/main/cpuinfo.h | 7 +- mesalib/src/mesa/main/dd.h | 132 +- mesalib/src/mesa/main/debug.c | 31 +- mesalib/src/mesa/main/debug.h | 9 +- mesalib/src/mesa/main/depth.c | 15 +- mesalib/src/mesa/main/depth.h | 8 +- mesalib/src/mesa/main/dlist.c | 146 +- mesalib/src/mesa/main/dlist.h | 16 +- mesalib/src/mesa/main/dlopen.h | 7 +- mesalib/src/mesa/main/drawpix.c | 8 +- mesalib/src/mesa/main/drawpix.h | 8 +- mesalib/src/mesa/main/drawtex.c | 1 - mesalib/src/mesa/main/drawtex.h | 1 - mesalib/src/mesa/main/enable.c | 27 +- mesalib/src/mesa/main/enable.h | 7 +- mesalib/src/mesa/main/enums.h | 8 +- mesalib/src/mesa/main/errors.c | 7 +- mesalib/src/mesa/main/errors.h | 17 +- mesalib/src/mesa/main/es1_conversion.c | 1 - mesalib/src/mesa/main/eval.c | 18 +- mesalib/src/mesa/main/eval.h | 23 +- mesalib/src/mesa/main/execmem.c | 9 +- mesalib/src/mesa/main/extensions.c | 17 +- mesalib/src/mesa/main/extensions.h | 8 +- mesalib/src/mesa/main/fbobject.c | 187 ++- mesalib/src/mesa/main/fbobject.h | 38 +- mesalib/src/mesa/main/feedback.c | 8 +- mesalib/src/mesa/main/feedback.h | 8 +- mesalib/src/mesa/main/ff_fragment_shader.cpp | 5 +- mesalib/src/mesa/main/ffvertex_prog.c | 9 +- mesalib/src/mesa/main/fog.c | 7 +- mesalib/src/mesa/main/fog.h | 8 +- mesalib/src/mesa/main/format_pack.c | 7 +- mesalib/src/mesa/main/format_pack.h | 7 +- mesalib/src/mesa/main/format_unpack.c | 604 +++++++- mesalib/src/mesa/main/format_unpack.h | 7 +- mesalib/src/mesa/main/formatquery.c | 1 - mesalib/src/mesa/main/formats.c | 8 +- mesalib/src/mesa/main/formats.h | 37 +- mesalib/src/mesa/main/framebuffer.c | 88 +- mesalib/src/mesa/main/framebuffer.h | 7 +- mesalib/src/mesa/main/get.c | 123 +- mesalib/src/mesa/main/get.h | 7 +- mesalib/src/mesa/main/get_hash_generator.py | 26 +- mesalib/src/mesa/main/get_hash_params.py | 26 +- mesalib/src/mesa/main/getstring.c | 8 +- mesalib/src/mesa/main/glformats.c | 7 +- mesalib/src/mesa/main/glformats.h | 7 +- mesalib/src/mesa/main/glheader.h | 7 +- mesalib/src/mesa/main/hash.c | 11 +- mesalib/src/mesa/main/hash.h | 7 +- mesalib/src/mesa/main/hint.c | 7 +- mesalib/src/mesa/main/hint.h | 8 +- mesalib/src/mesa/main/histogram.c | 8 +- mesalib/src/mesa/main/histogram.h | 8 +- mesalib/src/mesa/main/image.c | 8 +- mesalib/src/mesa/main/image.h | 7 +- mesalib/src/mesa/main/imports.c | 7 +- mesalib/src/mesa/main/imports.h | 7 +- mesalib/src/mesa/main/light.c | 11 +- mesalib/src/mesa/main/light.h | 8 +- mesalib/src/mesa/main/lines.c | 7 +- mesalib/src/mesa/main/lines.h | 7 +- mesalib/src/mesa/main/macros.h | 13 +- mesalib/src/mesa/main/matrix.c | 8 +- mesalib/src/mesa/main/matrix.h | 7 +- mesalib/src/mesa/main/mfeatures.h | 53 - mesalib/src/mesa/main/mipmap.c | 7 +- mesalib/src/mesa/main/mipmap.h | 7 +- mesalib/src/mesa/main/mtypes.h | 149 +- mesalib/src/mesa/main/multisample.c | 12 +- mesalib/src/mesa/main/multisample.h | 7 +- mesalib/src/mesa/main/pack.h | 7 +- mesalib/src/mesa/main/pbo.c | 7 +- mesalib/src/mesa/main/pbo.h | 7 +- mesalib/src/mesa/main/pixel.c | 8 +- mesalib/src/mesa/main/pixel.h | 8 +- mesalib/src/mesa/main/pixelstore.c | 25 +- mesalib/src/mesa/main/pixelstore.h | 7 +- mesalib/src/mesa/main/pixeltransfer.c | 7 +- mesalib/src/mesa/main/pixeltransfer.h | 7 +- mesalib/src/mesa/main/points.c | 12 +- mesalib/src/mesa/main/points.h | 7 +- mesalib/src/mesa/main/polygon.c | 12 +- mesalib/src/mesa/main/polygon.h | 7 +- mesalib/src/mesa/main/querymatrix.h | 1 - mesalib/src/mesa/main/queryobj.c | 15 +- mesalib/src/mesa/main/queryobj.h | 8 +- mesalib/src/mesa/main/rastpos.c | 8 +- mesalib/src/mesa/main/rastpos.h | 8 +- mesalib/src/mesa/main/readpix.c | 7 +- mesalib/src/mesa/main/readpix.h | 7 +- mesalib/src/mesa/main/remap.c | 7 - mesalib/src/mesa/main/remap.h | 35 - mesalib/src/mesa/main/renderbuffer.c | 8 +- mesalib/src/mesa/main/renderbuffer.h | 7 +- mesalib/src/mesa/main/samplerobj.c | 8 +- mesalib/src/mesa/main/samplerobj.h | 7 +- mesalib/src/mesa/main/scissor.c | 7 +- mesalib/src/mesa/main/scissor.h | 7 +- mesalib/src/mesa/main/shaderapi.c | 19 +- mesalib/src/mesa/main/shaderapi.h | 7 +- mesalib/src/mesa/main/shaderobj.c | 8 +- mesalib/src/mesa/main/shaderobj.h | 7 +- mesalib/src/mesa/main/shared.c | 8 +- mesalib/src/mesa/main/shared.h | 7 +- mesalib/src/mesa/main/simple_list.h | 7 +- mesalib/src/mesa/main/state.c | 110 +- mesalib/src/mesa/main/state.h | 7 +- mesalib/src/mesa/main/stencil.c | 21 +- mesalib/src/mesa/main/stencil.h | 21 +- mesalib/src/mesa/main/syncobj.c | 1 - mesalib/src/mesa/main/syncobj.h | 1 - mesalib/src/mesa/main/texcompress.c | 10 +- mesalib/src/mesa/main/texcompress.h | 11 +- mesalib/src/mesa/main/texcompress_cpal.c | 8 +- mesalib/src/mesa/main/texcompress_cpal.h | 7 +- mesalib/src/mesa/main/texcompress_etc.c | 52 +- mesalib/src/mesa/main/texcompress_etc.h | 1 - mesalib/src/mesa/main/texcompress_fxt1.c | 16 +- mesalib/src/mesa/main/texcompress_fxt1.h | 8 +- mesalib/src/mesa/main/texcompress_rgtc.c | 71 +- mesalib/src/mesa/main/texcompress_rgtc.h | 1 - mesalib/src/mesa/main/texcompress_s3tc.c | 64 +- mesalib/src/mesa/main/texcompress_s3tc.h | 8 +- mesalib/src/mesa/main/texenv.c | 15 +- mesalib/src/mesa/main/texenv.h | 7 +- mesalib/src/mesa/main/texenvprogram.h | 7 +- mesalib/src/mesa/main/texformat.c | 1475 +++++++++----------- mesalib/src/mesa/main/texformat.h | 9 +- mesalib/src/mesa/main/texgen.c | 8 +- mesalib/src/mesa/main/texgen.h | 8 +- mesalib/src/mesa/main/texgetimage.c | 8 +- mesalib/src/mesa/main/texgetimage.h | 7 +- mesalib/src/mesa/main/teximage.c | 108 +- mesalib/src/mesa/main/teximage.h | 7 +- mesalib/src/mesa/main/texobj.c | 8 +- mesalib/src/mesa/main/texobj.h | 7 +- mesalib/src/mesa/main/texparam.c | 8 +- mesalib/src/mesa/main/texparam.h | 7 +- mesalib/src/mesa/main/texstate.c | 8 +- mesalib/src/mesa/main/texstate.h | 7 +- mesalib/src/mesa/main/texstorage.c | 38 +- mesalib/src/mesa/main/texstorage.h | 12 +- mesalib/src/mesa/main/texstore.c | 8 +- mesalib/src/mesa/main/texstore.h | 7 +- mesalib/src/mesa/main/transformfeedback.c | 28 +- mesalib/src/mesa/main/transformfeedback.h | 8 +- mesalib/src/mesa/main/uniform_query.cpp | 31 +- mesalib/src/mesa/main/uniforms.c | 22 +- mesalib/src/mesa/main/uniforms.h | 7 +- mesalib/src/mesa/main/varray.c | 41 +- mesalib/src/mesa/main/varray.h | 10 +- mesalib/src/mesa/main/version.c | 9 +- mesalib/src/mesa/main/version.h | 7 +- mesalib/src/mesa/main/viewport.c | 7 +- mesalib/src/mesa/main/viewport.h | 7 +- mesalib/src/mesa/main/vtxfmt.c | 59 +- mesalib/src/mesa/main/vtxfmt.h | 8 +- mesalib/src/mesa/math/m_clip_tmp.h | 7 +- mesalib/src/mesa/math/m_copy_tmp.h | 7 +- mesalib/src/mesa/math/m_debug.h | 7 +- mesalib/src/mesa/math/m_debug_clip.c | 7 +- mesalib/src/mesa/math/m_debug_norm.c | 7 +- mesalib/src/mesa/math/m_debug_util.h | 7 +- mesalib/src/mesa/math/m_debug_xform.c | 7 +- mesalib/src/mesa/math/m_dotprod_tmp.h | 7 +- mesalib/src/mesa/math/m_eval.c | 7 +- mesalib/src/mesa/math/m_eval.h | 7 +- mesalib/src/mesa/math/m_matrix.c | 7 +- mesalib/src/mesa/math/m_matrix.h | 7 +- mesalib/src/mesa/math/m_norm_tmp.h | 7 +- mesalib/src/mesa/math/m_trans_tmp.h | 7 +- mesalib/src/mesa/math/m_translate.c | 7 +- mesalib/src/mesa/math/m_translate.h | 7 +- mesalib/src/mesa/math/m_vector.c | 7 +- mesalib/src/mesa/math/m_vector.h | 7 +- mesalib/src/mesa/math/m_xform.c | 7 +- mesalib/src/mesa/math/m_xform.h | 7 +- mesalib/src/mesa/math/m_xform_tmp.h | 7 +- mesalib/src/mesa/program/Android.mk | 4 +- mesalib/src/mesa/program/Makefile.am | 4 +- mesalib/src/mesa/program/arbprogparse.c | 7 +- mesalib/src/mesa/program/arbprogparse.h | 7 +- mesalib/src/mesa/program/ir_to_mesa.cpp | 38 +- mesalib/src/mesa/program/prog_execute.c | 142 +- mesalib/src/mesa/program/prog_execute.h | 7 +- mesalib/src/mesa/program/prog_instruction.c | 16 +- mesalib/src/mesa/program/prog_instruction.h | 18 +- mesalib/src/mesa/program/prog_noise.c | 7 +- mesalib/src/mesa/program/prog_noise.h | 7 +- mesalib/src/mesa/program/prog_opt_constant_fold.c | 4 - mesalib/src/mesa/program/prog_parameter.c | 7 +- mesalib/src/mesa/program/prog_parameter.h | 7 +- mesalib/src/mesa/program/prog_print.c | 21 +- mesalib/src/mesa/program/prog_print.h | 7 +- mesalib/src/mesa/program/prog_statevars.c | 7 +- mesalib/src/mesa/program/prog_statevars.h | 7 +- mesalib/src/mesa/program/program.c | 8 +- mesalib/src/mesa/program/program.h | 7 +- mesalib/src/mesa/program/program_parse.y | 7 +- mesalib/src/mesa/program/program_parse_extra.c | 24 +- mesalib/src/mesa/program/programopt.c | 9 +- mesalib/src/mesa/program/programopt.h | 7 +- mesalib/src/mesa/program/register_allocate.c | 6 +- mesalib/src/mesa/program/sampler.cpp | 20 +- mesalib/src/mesa/sources.mak | 349 ----- mesalib/src/mesa/state_tracker/st_atom.c | 8 +- mesalib/src/mesa/state_tracker/st_atom_array.c | 2 +- mesalib/src/mesa/state_tracker/st_atom_constbuf.c | 28 +- mesalib/src/mesa/state_tracker/st_atom_depth.c | 9 +- .../src/mesa/state_tracker/st_atom_framebuffer.c | 1 + mesalib/src/mesa/state_tracker/st_atom_msaa.c | 3 +- .../src/mesa/state_tracker/st_atom_rasterizer.c | 11 +- mesalib/src/mesa/state_tracker/st_atom_sampler.c | 33 +- mesalib/src/mesa/state_tracker/st_atom_scissor.c | 2 +- mesalib/src/mesa/state_tracker/st_atom_texture.c | 11 +- mesalib/src/mesa/state_tracker/st_cb_bitmap.c | 8 +- mesalib/src/mesa/state_tracker/st_cb_bitmap.h | 1 - mesalib/src/mesa/state_tracker/st_cb_blit.c | 1 - mesalib/src/mesa/state_tracker/st_cb_blit.h | 1 - .../src/mesa/state_tracker/st_cb_bufferobjects.c | 19 +- mesalib/src/mesa/state_tracker/st_cb_clear.c | 3 +- mesalib/src/mesa/state_tracker/st_cb_drawpixels.c | 6 +- mesalib/src/mesa/state_tracker/st_cb_drawpixels.h | 1 - mesalib/src/mesa/state_tracker/st_cb_drawtex.c | 1 - mesalib/src/mesa/state_tracker/st_cb_drawtex.h | 1 - mesalib/src/mesa/state_tracker/st_cb_eglimage.c | 2 +- mesalib/src/mesa/state_tracker/st_cb_eglimage.h | 1 - mesalib/src/mesa/state_tracker/st_cb_fbo.c | 39 +- mesalib/src/mesa/state_tracker/st_cb_feedback.c | 1 - mesalib/src/mesa/state_tracker/st_cb_feedback.h | 1 - mesalib/src/mesa/state_tracker/st_cb_flush.c | 2 +- mesalib/src/mesa/state_tracker/st_cb_flush.h | 2 +- mesalib/src/mesa/state_tracker/st_cb_msaa.c | 59 + mesalib/src/mesa/state_tracker/st_cb_msaa.h | 39 + mesalib/src/mesa/state_tracker/st_cb_queryobj.c | 1 - mesalib/src/mesa/state_tracker/st_cb_queryobj.h | 1 - mesalib/src/mesa/state_tracker/st_cb_rasterpos.c | 1 - mesalib/src/mesa/state_tracker/st_cb_rasterpos.h | 1 - mesalib/src/mesa/state_tracker/st_cb_texture.c | 51 +- mesalib/src/mesa/state_tracker/st_cb_xformfb.c | 1 - mesalib/src/mesa/state_tracker/st_cb_xformfb.h | 1 - mesalib/src/mesa/state_tracker/st_context.c | 10 +- mesalib/src/mesa/state_tracker/st_context.h | 3 + mesalib/src/mesa/state_tracker/st_draw.c | 5 +- mesalib/src/mesa/state_tracker/st_draw_feedback.c | 15 +- mesalib/src/mesa/state_tracker/st_extensions.c | 148 +- mesalib/src/mesa/state_tracker/st_format.c | 36 - mesalib/src/mesa/state_tracker/st_format.h | 4 - mesalib/src/mesa/state_tracker/st_gen_mipmap.c | 1 + mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 48 +- mesalib/src/mesa/state_tracker/st_manager.c | 34 +- mesalib/src/mesa/state_tracker/st_mesa_to_tgsi.c | 22 +- mesalib/src/mesa/state_tracker/st_program.c | 1 - mesalib/src/mesa/state_tracker/st_texture.c | 8 +- mesalib/src/mesa/state_tracker/st_texture.h | 11 +- mesalib/src/mesa/swrast/s_aaline.c | 7 +- mesalib/src/mesa/swrast/s_aaline.h | 7 +- mesalib/src/mesa/swrast/s_aalinetemp.h | 7 +- mesalib/src/mesa/swrast/s_aatriangle.c | 7 +- mesalib/src/mesa/swrast/s_aatriangle.h | 7 +- mesalib/src/mesa/swrast/s_aatritemp.h | 7 +- mesalib/src/mesa/swrast/s_alpha.c | 7 +- mesalib/src/mesa/swrast/s_alpha.h | 7 +- mesalib/src/mesa/swrast/s_bitmap.c | 7 +- mesalib/src/mesa/swrast/s_blend.c | 7 +- mesalib/src/mesa/swrast/s_blend.h | 7 +- mesalib/src/mesa/swrast/s_blit.c | 99 +- mesalib/src/mesa/swrast/s_chan.h | 7 +- mesalib/src/mesa/swrast/s_clear.c | 7 +- mesalib/src/mesa/swrast/s_context.c | 16 +- mesalib/src/mesa/swrast/s_context.h | 35 +- mesalib/src/mesa/swrast/s_copypix.c | 7 +- mesalib/src/mesa/swrast/s_depth.c | 7 +- mesalib/src/mesa/swrast/s_depth.h | 7 +- mesalib/src/mesa/swrast/s_drawpix.c | 7 +- mesalib/src/mesa/swrast/s_feedback.c | 7 +- mesalib/src/mesa/swrast/s_feedback.h | 7 +- mesalib/src/mesa/swrast/s_fog.c | 7 +- mesalib/src/mesa/swrast/s_fog.h | 7 +- mesalib/src/mesa/swrast/s_fragprog.c | 7 +- mesalib/src/mesa/swrast/s_fragprog.h | 7 +- mesalib/src/mesa/swrast/s_lines.c | 7 +- mesalib/src/mesa/swrast/s_lines.h | 7 +- mesalib/src/mesa/swrast/s_linetemp.h | 7 +- mesalib/src/mesa/swrast/s_logic.c | 7 +- mesalib/src/mesa/swrast/s_logic.h | 7 +- mesalib/src/mesa/swrast/s_masking.c | 7 +- mesalib/src/mesa/swrast/s_masking.h | 7 +- mesalib/src/mesa/swrast/s_points.c | 7 +- mesalib/src/mesa/swrast/s_points.h | 7 +- mesalib/src/mesa/swrast/s_renderbuffer.c | 7 +- mesalib/src/mesa/swrast/s_renderbuffer.h | 7 +- mesalib/src/mesa/swrast/s_span.c | 7 +- mesalib/src/mesa/swrast/s_span.h | 7 +- mesalib/src/mesa/swrast/s_stencil.c | 13 +- mesalib/src/mesa/swrast/s_stencil.h | 7 +- mesalib/src/mesa/swrast/s_texcombine.c | 9 +- mesalib/src/mesa/swrast/s_texcombine.h | 7 +- mesalib/src/mesa/swrast/s_texfetch.c | 22 +- mesalib/src/mesa/swrast/s_texfetch.h | 7 +- mesalib/src/mesa/swrast/s_texfetch_tmp.h | 18 +- mesalib/src/mesa/swrast/s_texfilter.c | 15 +- mesalib/src/mesa/swrast/s_texfilter.h | 7 +- mesalib/src/mesa/swrast/s_texrender.c | 63 +- mesalib/src/mesa/swrast/s_texture.c | 186 +-- mesalib/src/mesa/swrast/s_triangle.c | 18 +- mesalib/src/mesa/swrast/s_triangle.h | 7 +- mesalib/src/mesa/swrast/s_tritemp.h | 7 +- mesalib/src/mesa/swrast/s_zoom.c | 7 +- mesalib/src/mesa/swrast/s_zoom.h | 7 +- mesalib/src/mesa/swrast/swrast.h | 19 +- mesalib/src/mesa/swrast_setup/ss_context.c | 7 +- mesalib/src/mesa/swrast_setup/ss_context.h | 7 +- mesalib/src/mesa/swrast_setup/ss_triangle.c | 7 +- mesalib/src/mesa/swrast_setup/ss_triangle.h | 7 +- mesalib/src/mesa/swrast_setup/ss_tritmp.h | 7 +- mesalib/src/mesa/swrast_setup/ss_vb.h | 7 +- mesalib/src/mesa/swrast_setup/swrast_setup.h | 7 +- mesalib/src/mesa/tnl/t_context.c | 7 +- mesalib/src/mesa/tnl/t_context.h | 7 +- mesalib/src/mesa/tnl/t_draw.c | 7 +- mesalib/src/mesa/tnl/t_pipeline.c | 7 +- mesalib/src/mesa/tnl/t_pipeline.h | 7 +- mesalib/src/mesa/tnl/t_rasterpos.c | 7 +- mesalib/src/mesa/tnl/t_vb_cliptmp.h | 7 +- mesalib/src/mesa/tnl/t_vb_fog.c | 7 +- mesalib/src/mesa/tnl/t_vb_light.c | 7 +- mesalib/src/mesa/tnl/t_vb_lighttmp.h | 10 +- mesalib/src/mesa/tnl/t_vb_normals.c | 7 +- mesalib/src/mesa/tnl/t_vb_points.c | 7 +- mesalib/src/mesa/tnl/t_vb_program.c | 11 +- mesalib/src/mesa/tnl/t_vb_render.c | 7 +- mesalib/src/mesa/tnl/t_vb_rendertmp.h | 7 +- mesalib/src/mesa/tnl/t_vb_texgen.c | 10 +- mesalib/src/mesa/tnl/t_vb_texmat.c | 7 +- mesalib/src/mesa/tnl/t_vb_vertex.c | 7 +- mesalib/src/mesa/tnl/t_vertex.c | 13 +- mesalib/src/mesa/tnl/tnl.h | 7 +- mesalib/src/mesa/vbo/vbo.h | 26 +- mesalib/src/mesa/vbo/vbo_context.c | 7 +- mesalib/src/mesa/vbo/vbo_context.h | 8 +- mesalib/src/mesa/vbo/vbo_exec.c | 128 +- mesalib/src/mesa/vbo/vbo_exec.h | 5 +- mesalib/src/mesa/vbo/vbo_exec_api.c | 182 +-- mesalib/src/mesa/vbo/vbo_exec_array.c | 235 +++- mesalib/src/mesa/vbo/vbo_exec_draw.c | 8 +- mesalib/src/mesa/vbo/vbo_exec_eval.c | 7 +- mesalib/src/mesa/vbo/vbo_noop.c | 100 +- mesalib/src/mesa/vbo/vbo_noop.h | 8 +- mesalib/src/mesa/vbo/vbo_primitive_restart.c | 3 +- mesalib/src/mesa/vbo/vbo_rebase.c | 7 +- mesalib/src/mesa/vbo/vbo_save.c | 10 +- mesalib/src/mesa/vbo/vbo_save.h | 9 +- mesalib/src/mesa/vbo/vbo_save_api.c | 364 ++--- mesalib/src/mesa/vbo/vbo_save_draw.c | 25 +- mesalib/src/mesa/vbo/vbo_save_loopback.c | 3 +- mesalib/src/mesa/vbo/vbo_split.c | 7 +- mesalib/src/mesa/vbo/vbo_split.h | 7 +- mesalib/src/mesa/vbo/vbo_split_copy.c | 7 +- mesalib/src/mesa/vbo/vbo_split_inplace.c | 7 +- mesalib/src/mesa/x86/3dnow.c | 7 +- mesalib/src/mesa/x86/3dnow.h | 7 +- mesalib/src/mesa/x86/3dnow_normal.S | 7 +- mesalib/src/mesa/x86/3dnow_xform1.S | 7 +- mesalib/src/mesa/x86/3dnow_xform2.S | 7 +- mesalib/src/mesa/x86/3dnow_xform3.S | 7 +- mesalib/src/mesa/x86/3dnow_xform4.S | 7 +- mesalib/src/mesa/x86/Makefile.am | 1 - mesalib/src/mesa/x86/clip_args.h | 7 +- mesalib/src/mesa/x86/common_x86.c | 7 +- mesalib/src/mesa/x86/common_x86_asm.S | 7 +- mesalib/src/mesa/x86/common_x86_asm.h | 7 +- mesalib/src/mesa/x86/common_x86_features.h | 7 +- mesalib/src/mesa/x86/gen_matypes.c | 7 +- mesalib/src/mesa/x86/mmx.h | 7 +- mesalib/src/mesa/x86/norm_args.h | 7 +- mesalib/src/mesa/x86/sse.c | 7 +- mesalib/src/mesa/x86/sse.h | 7 +- mesalib/src/mesa/x86/sse_normal.S | 7 +- mesalib/src/mesa/x86/sse_xform1.S | 7 +- mesalib/src/mesa/x86/sse_xform2.S | 7 +- mesalib/src/mesa/x86/sse_xform3.S | 7 +- mesalib/src/mesa/x86/sse_xform4.S | 7 +- mesalib/src/mesa/x86/x86_cliptest.S | 7 +- mesalib/src/mesa/x86/x86_xform.c | 7 +- mesalib/src/mesa/x86/x86_xform.h | 7 +- mesalib/src/mesa/x86/x86_xform2.S | 7 +- mesalib/src/mesa/x86/x86_xform3.S | 7 +- mesalib/src/mesa/x86/x86_xform4.S | 7 +- mesalib/src/mesa/x86/xform_args.h | 7 +- 588 files changed, 11261 insertions(+), 8923 deletions(-) delete mode 100644 mesalib/src/gallium/Makefile.am create mode 100644 mesalib/src/glsl/ast_array_index.cpp create mode 100644 mesalib/src/glsl/link_interface_blocks.cpp create mode 100644 mesalib/src/glsl/lower_named_interface_blocks.cpp create mode 100644 mesalib/src/glsl/lower_vector_insert.cpp create mode 100644 mesalib/src/glsl/opt_flip_matrices.cpp create mode 100644 mesalib/src/mapi/Makefile.am create mode 100644 mesalib/src/mapi/Makefile.sources create mode 100644 mesalib/src/mapi/entry.c create mode 100644 mesalib/src/mapi/entry.h create mode 100644 mesalib/src/mapi/entry_x86-64_tls.h create mode 100644 mesalib/src/mapi/entry_x86_tls.h create mode 100644 mesalib/src/mapi/entry_x86_tsd.h create mode 100644 mesalib/src/mapi/glapi/Makefile.sources delete mode 100644 mesalib/src/mapi/glapi/sources.mak create mode 100644 mesalib/src/mapi/mapi.c create mode 100644 mesalib/src/mapi/mapi.h delete mode 100644 mesalib/src/mapi/mapi/entry.c delete mode 100644 mesalib/src/mapi/mapi/entry.h delete mode 100644 mesalib/src/mapi/mapi/entry_x86-64_tls.h delete mode 100644 mesalib/src/mapi/mapi/entry_x86_tls.h delete mode 100644 mesalib/src/mapi/mapi/entry_x86_tsd.h delete mode 100644 mesalib/src/mapi/mapi/mapi.c delete mode 100644 mesalib/src/mapi/mapi/mapi.h delete mode 100644 mesalib/src/mapi/mapi/mapi_abi.py delete mode 100644 mesalib/src/mapi/mapi/mapi_glapi.c delete mode 100644 mesalib/src/mapi/mapi/mapi_tmp.h delete mode 100644 mesalib/src/mapi/mapi/sources.mak delete mode 100644 mesalib/src/mapi/mapi/stub.c delete mode 100644 mesalib/src/mapi/mapi/stub.h delete mode 100644 mesalib/src/mapi/mapi/table.c delete mode 100644 mesalib/src/mapi/mapi/table.h delete mode 100644 mesalib/src/mapi/mapi/u_compiler.h delete mode 100644 mesalib/src/mapi/mapi/u_current.c delete mode 100644 mesalib/src/mapi/mapi/u_current.h delete mode 100644 mesalib/src/mapi/mapi/u_execmem.c delete mode 100644 mesalib/src/mapi/mapi/u_execmem.h delete mode 100644 mesalib/src/mapi/mapi/u_macros.h delete mode 100644 mesalib/src/mapi/mapi/u_thread.h create mode 100644 mesalib/src/mapi/mapi_abi.py create mode 100644 mesalib/src/mapi/mapi_glapi.c create mode 100644 mesalib/src/mapi/mapi_tmp.h create mode 100644 mesalib/src/mapi/stub.c create mode 100644 mesalib/src/mapi/stub.h create mode 100644 mesalib/src/mapi/table.c create mode 100644 mesalib/src/mapi/table.h create mode 100644 mesalib/src/mapi/u_compiler.h create mode 100644 mesalib/src/mapi/u_current.c create mode 100644 mesalib/src/mapi/u_current.h create mode 100644 mesalib/src/mapi/u_execmem.c create mode 100644 mesalib/src/mapi/u_execmem.h create mode 100644 mesalib/src/mapi/u_macros.h create mode 100644 mesalib/src/mapi/u_thread.h create mode 100644 mesalib/src/mesa/Makefile.sources delete mode 100644 mesalib/src/mesa/drivers/Makefile.am delete mode 100644 mesalib/src/mesa/main/mfeatures.h delete mode 100644 mesalib/src/mesa/sources.mak create mode 100644 mesalib/src/mesa/state_tracker/st_cb_msaa.c create mode 100644 mesalib/src/mesa/state_tracker/st_cb_msaa.h (limited to 'mesalib/src') diff --git a/mesalib/src/Makefile.am b/mesalib/src/Makefile.am index d6a7946ef..b3dc44d6f 100644 --- a/mesalib/src/Makefile.am +++ b/mesalib/src/Makefile.am @@ -1,4 +1,53 @@ -SUBDIRS=$(SRC_DIRS) +# Copyright © 2013 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. -all-local: - $(MKDIR_P) $(top_builddir)/$(LIB_DIR) +SUBDIRS = gtest mapi + +if NEED_OPENGL_COMMON +SUBDIRS += glsl mesa +endif + +if HAVE_DRI_GLX +SUBDIRS += glx +endif + +if HAVE_GBM +SUBDIRS += gbm +endif + +if HAVE_EGL +SUBDIRS += egl +endif + +if HAVE_GALLIUM +SUBDIRS += \ + gallium/auxiliary \ + gallium/drivers \ + gallium/state_trackers \ + gallium/winsys \ + gallium/targets + +if HAVE_GALLIUM_TESTS +SUBDIRS += \ + gallium/tests/trivial \ + gallium/tests/unit +endif +endif diff --git a/mesalib/src/gallium/Android.mk b/mesalib/src/gallium/Android.mk index 1d002d053..4e5acc86f 100644 --- a/mesalib/src/gallium/Android.mk +++ b/mesalib/src/gallium/Android.mk @@ -39,6 +39,11 @@ ifneq ($(filter i915g, $(MESA_GPU_DRIVERS)),) SUBDIRS += winsys/i915/drm drivers/i915 endif +# ilo +ifneq ($(filter ilo, $(MESA_GPU_DRIVERS)),) +SUBDIRS += winsys/intel/drm drivers/ilo +endif + # nouveau ifneq ($(filter nouveau, $(MESA_GPU_DRIVERS)),) SUBDIRS += \ diff --git a/mesalib/src/gallium/Makefile.am b/mesalib/src/gallium/Makefile.am deleted file mode 100644 index e7cff8920..000000000 --- a/mesalib/src/gallium/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright © 2012 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. - -SUBDIRS = $(GALLIUM_DIRS) diff --git a/mesalib/src/gallium/SConscript b/mesalib/src/gallium/SConscript index f281f4c65..ca75f37f9 100644 --- a/mesalib/src/gallium/SConscript +++ b/mesalib/src/gallium/SConscript @@ -27,28 +27,6 @@ if not env['msvc']: 'drivers/i915/SConscript', ]) -if env['drm']: - # These drivers depend on drm headers - if env['drm_radeon']: - SConscript([ - 'drivers/r300/SConscript', - 'drivers/r600/SConscript', - ]) - if env['llvm']: - SConscript([ - 'drivers/radeonsi/SConscript', - ]) - # XXX: nouveau drivers have a tight dependency on libdrm, so to enable - # we need some version logic before we enable them. Also, ATM there is - # no nouveau target in scons - # if env['drm_nouveau']: - # SConscript([ - # 'drivers/nouveau/SConscript', - # 'drivers/nv50/SConscript', - # 'drivers/nvc0/SConscript', - # 'drivers/nvfx/SConscript', - # ]) - # # State trackers # @@ -96,6 +74,11 @@ if not env['msvc']: 'winsys/i915/sw/SConscript', ]) +if env['platform'] == 'haiku': + SConscript([ + 'winsys/sw/hgl/SConscript', + ]) + if env['dri']: SConscript([ 'winsys/sw/dri/SConscript', @@ -110,11 +93,6 @@ if env['dri']: 'winsys/i915/drm/SConscript', ]) - if env['drm_radeon']: - SConscript([ - 'winsys/radeon/drm/SConscript', - ]) - # # Targets # @@ -141,32 +119,25 @@ if not env['embedded']: 'targets/libgl-gdi/SConscript', ]) + if env['platform'] == 'haiku': + SConscript([ + 'targets/haiku-softpipe/SConscript', + ]) + if env['dri']: SConscript([ 'targets/SConscript.dri', 'targets/dri-swrast/SConscript', 'targets/dri-vmwgfx/SConscript', - #'targets/dri-nouveau/SConscript', ]) if env['drm_intel']: SConscript([ 'targets/dri-i915/SConscript', ]) - if env['drm_radeon']: - SConscript([ - 'targets/dri-r300/SConscript', - 'targets/dri-r600/SConscript', - ]) - if env['llvm']: - SConscript([ - 'targets/dri-radeonsi/SConscript', - ]) if env['xorg'] and env['drm']: SConscript([ #'targets/xorg-i915/SConscript', - #'targets/xorg-nouveau/SConscript', - #'targets/xorg-radeon/SConscript', ]) diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources index 79def2177..20ff5ba73 100644 --- a/mesalib/src/gallium/auxiliary/Makefile.sources +++ b/mesalib/src/gallium/auxiliary/Makefile.sources @@ -23,6 +23,7 @@ C_SOURCES := \ draw/draw_pipe_vbuf.c \ draw/draw_pipe_wide_line.c \ draw/draw_pipe_wide_point.c \ + draw/draw_prim_assembler.c \ draw/draw_pt.c \ draw/draw_pt_emit.c \ draw/draw_pt_fetch.c \ diff --git a/mesalib/src/gallium/auxiliary/SConscript b/mesalib/src/gallium/auxiliary/SConscript index bfd5ec34c..31dfed316 100644 --- a/mesalib/src/gallium/auxiliary/SConscript +++ b/mesalib/src/gallium/auxiliary/SConscript @@ -51,10 +51,6 @@ if env['llvm']: 'GALLIVM_CPP_SOURCES' ]) - if env['toolchain'] == 'crossmingw': - # compile lp_bld_misc.cpp without -gstabs option - source = env.compile_without_gstabs(source, "gallivm/lp_bld_misc.cpp") - gallium = env.ConvenienceLibrary( target = 'gallium', source = source, diff --git a/mesalib/src/gallium/auxiliary/hud/hud_context.c b/mesalib/src/gallium/auxiliary/hud/hud_context.c index 983f05756..de032b6ba 100644 --- a/mesalib/src/gallium/auxiliary/hud/hud_context.c +++ b/mesalib/src/gallium/auxiliary/hud/hud_context.c @@ -90,10 +90,6 @@ struct hud_context { unsigned max_num_vertices; unsigned num_vertices; } text, bg, whitelines; - - struct { - boolean query_pipeline_statistics; - } cap; }; @@ -467,7 +463,7 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex) cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf); /* prepare vertex buffers */ - hud_alloc_vertices(hud, &hud->bg, 4 * 64, 2 * sizeof(float)); + hud_alloc_vertices(hud, &hud->bg, 4 * 128, 2 * sizeof(float)); hud_alloc_vertices(hud, &hud->whitelines, 4 * 256, 2 * sizeof(float)); hud_alloc_vertices(hud, &hud->text, 4 * 512, 4 * sizeof(float)); @@ -695,6 +691,12 @@ has_streamout(struct pipe_screen *screen) return screen->get_param(screen, PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS) != 0; } +static boolean +has_pipeline_stats_query(struct pipe_screen *screen) +{ + return screen->get_param(screen, PIPE_CAP_QUERY_PIPELINE_STATISTICS) != 0; +} + static void hud_parse_env_var(struct hud_context *hud, const char *env) { @@ -728,7 +730,8 @@ hud_parse_env_var(struct hud_context *hud, const char *env) return; } - /* add a graph */ + /* Add a graph. */ + /* IF YOU CHANGE THIS, UPDATE print_help! */ if (strcmp(name, "fps") == 0) { hud_fps_graph_install(pane); } @@ -748,8 +751,11 @@ hud_parse_env_var(struct hud_context *hud, const char *env) hud_pipe_query_install(pane, hud->pipe, "primitives-generated", PIPE_QUERY_PRIMITIVES_GENERATED, 0, 0, FALSE); } - else if (strncmp(name, "pipeline-statistics-", 20) == 0) { - if (hud->cap.query_pipeline_statistics) { + else { + boolean processed = FALSE; + + /* pipeline statistics queries */ + if (has_pipeline_stats_query(hud->pipe->screen)) { static const char *pipeline_statistics_names[] = { "ia-vertices", @@ -765,22 +771,21 @@ hud_parse_env_var(struct hud_context *hud, const char *env) "cs-invocations" }; for (i = 0; i < Elements(pipeline_statistics_names); ++i) - if (strcmp(&name[20], pipeline_statistics_names[i]) == 0) + if (strcmp(name, pipeline_statistics_names[i]) == 0) break; - if (i < Elements(pipeline_statistics_names)) - hud_pipe_query_install(pane, hud->pipe, &name[20], + if (i < Elements(pipeline_statistics_names)) { + hud_pipe_query_install(pane, hud->pipe, name, PIPE_QUERY_PIPELINE_STATISTICS, i, 0, FALSE); - else - fprintf(stderr, "gallium_hud: invalid pipeline-statistics-*\n"); - } else { - fprintf(stderr, "gallium_hud: PIPE_QUERY_PIPELINE_STATISTICS " - "not supported by the driver\n"); + processed = TRUE; + } } - } - else { - if (!hud_driver_query_install(pane, hud->pipe, name)){ - fprintf(stderr, "gallium_hud: unknown driver query '%s'\n", name); + + /* driver queries */ + if (!processed) { + if (!hud_driver_query_install(pane, hud->pipe, name)){ + fprintf(stderr, "gallium_hud: unknown driver query '%s'\n", name); + } } } @@ -877,10 +882,24 @@ print_help(struct pipe_screen *screen) printf(" cpu%i\n", i); if (has_occlusion_query(screen)) - puts(" pixels-rendered"); + puts(" samples-passed"); if (has_streamout(screen)) puts(" primitives-generated"); + if (has_pipeline_stats_query(screen)) { + puts(" ia-vertices"); + puts(" ia-primitives"); + puts(" vs-invocations"); + puts(" gs-invocations"); + puts(" gs-primitives"); + puts(" clipper-invocations"); + puts(" clipper-primitives-generated"); + puts(" ps-invocations"); + puts(" hs-invocations"); + puts(" ds-invocations"); + puts(" cs-invocations"); + } + if (screen->get_driver_query_info){ struct pipe_driver_query_info info; num_queries = screen->get_driver_query_info(screen, 0, NULL); @@ -971,7 +990,8 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso) } /* rasterizer */ - hud->rasterizer.gl_rasterization_rules = 1; + hud->rasterizer.half_pixel_center = 1; + hud->rasterizer.bottom_edge_rule = 1; hud->rasterizer.depth_clip = 1; hud->rasterizer.line_width = 1; hud->rasterizer.line_last_pixel = 1; @@ -1045,9 +1065,6 @@ hud_create(struct pipe_context *pipe, struct cso_context *cso) LIST_INITHEAD(&hud->pane_list); - hud->cap.query_pipeline_statistics = - pipe->screen->get_param(pipe->screen, PIPE_CAP_QUERY_PIPELINE_STATISTICS); - hud_parse_env_var(hud, env); return hud; } diff --git a/mesalib/src/gallium/auxiliary/hud/hud_fps.c b/mesalib/src/gallium/auxiliary/hud/hud_fps.c index 71cdfd04e..80381f547 100644 --- a/mesalib/src/gallium/auxiliary/hud/hud_fps.c +++ b/mesalib/src/gallium/auxiliary/hud/hud_fps.c @@ -47,7 +47,8 @@ query_fps(struct hud_graph *gr) if (info->last_time) { if (info->last_time + gr->pane->period <= now) { - double fps = info->frames * 1000000 / (double)(now - info->last_time); + double fps = (uint64_t)info->frames * 1000000 / + (double)(now - info->last_time); info->frames = 0; info->last_time = now; diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c index 9fe15b810..cda66d157 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blit.c +++ b/mesalib/src/gallium/auxiliary/util/u_blit.c @@ -118,7 +118,8 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) /* rasterizer */ ctx->rasterizer.cull_face = PIPE_FACE_NONE; - ctx->rasterizer.gl_rasterization_rules = 1; + ctx->rasterizer.half_pixel_center = 1; + ctx->rasterizer.bottom_edge_rule = 1; ctx->rasterizer.depth_clip = 1; /* samplers */ diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c index 2a4a13e9f..8c871fdf9 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.c +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c @@ -100,7 +100,7 @@ struct blitter_context_priv void *velem_state; void *velem_uint_state; void *velem_sint_state; - void *velem_state_readbuf; + void *velem_state_readbuf[4]; /**< X, XY, XYZ, XYZW */ /* Sampler state. */ void *sampler_state; @@ -239,7 +239,8 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) /* rasterizer state */ memset(&rs_state, 0, sizeof(rs_state)); rs_state.cull_face = PIPE_FACE_NONE; - rs_state.gl_rasterization_rules = 1; + rs_state.half_pixel_center = 1; + rs_state.bottom_edge_rule = 1; rs_state.flatshade = 1; rs_state.depth_clip = 1; ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state); @@ -285,9 +286,19 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe) } if (ctx->has_stream_out) { - velem[0].src_format = PIPE_FORMAT_R32_UINT; - velem[0].vertex_buffer_index = ctx->base.vb_slot; - ctx->velem_state_readbuf = pipe->create_vertex_elements_state(pipe, 1, &velem[0]); + static enum pipe_format formats[4] = { + PIPE_FORMAT_R32_UINT, + PIPE_FORMAT_R32G32_UINT, + PIPE_FORMAT_R32G32B32_UINT, + PIPE_FORMAT_R32G32B32A32_UINT + }; + + for (i = 0; i < 4; i++) { + velem[0].src_format = formats[i]; + velem[0].vertex_buffer_index = ctx->base.vb_slot; + ctx->velem_state_readbuf[i] = + pipe->create_vertex_elements_state(pipe, 1, &velem[0]); + } } /* fragment shaders are created on-demand */ @@ -352,8 +363,11 @@ void util_blitter_destroy(struct blitter_context *blitter) pipe->delete_vertex_elements_state(pipe, ctx->velem_sint_state); pipe->delete_vertex_elements_state(pipe, ctx->velem_uint_state); } - if (ctx->velem_state_readbuf) - pipe->delete_vertex_elements_state(pipe, ctx->velem_state_readbuf); + for (i = 0; i < 4; i++) { + if (ctx->velem_state_readbuf[i]) { + pipe->delete_vertex_elements_state(pipe, ctx->velem_state_readbuf[i]); + } + } for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) { if (ctx->fs_texfetch_col[i]) @@ -490,7 +504,7 @@ static void blitter_restore_fragment_states(struct blitter_context_priv *ctx) /* XXX check whether these are saved and whether they need to be restored * (depending on the operation) */ pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref); - pipe->set_viewport_state(pipe, &ctx->base.saved_viewport); + pipe->set_viewport_states(pipe, 0, 1, &ctx->base.saved_viewport); } static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx) @@ -585,7 +599,7 @@ static void blitter_set_rectangle(struct blitter_context_priv *ctx, ctx->viewport.translate[1] = 0.5f * ctx->dst_height; ctx->viewport.translate[2] = 0.0f; ctx->viewport.translate[3] = 0.0f; - ctx->base.pipe->set_viewport_state(ctx->base.pipe, &ctx->viewport); + ctx->base.pipe->set_viewport_states(ctx->base.pipe, 0, 1, &ctx->viewport); } static void blitter_set_clear_color(struct blitter_context_priv *ctx, @@ -1387,7 +1401,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter, pipe->bind_vertex_elements_state(pipe, ctx->velem_state); if (scissor) { - pipe->set_scissor_state(pipe, scissor); + pipe->set_scissor_states(pipe, 0, 1, scissor); } blitter_set_common_draw_rect_state(ctx, scissor != NULL); @@ -1482,7 +1496,7 @@ void util_blitter_blit_generic(struct blitter_context *blitter, blitter_restore_textures(ctx); blitter_restore_fb_state(ctx); if (scissor) { - pipe->set_scissor_state(pipe, &ctx->base.saved_scissor); + pipe->set_scissor_states(pipe, 0, 1, &ctx->base.saved_scissor); } blitter_restore_render_cond(ctx); blitter_unset_running_flag(ctx); @@ -1739,7 +1753,7 @@ void util_blitter_copy_buffer(struct blitter_context *blitter, vb.stride = 4; pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &vb); - pipe->bind_vertex_elements_state(pipe, ctx->velem_state_readbuf); + pipe->bind_vertex_elements_state(pipe, ctx->velem_state_readbuf[0]); pipe->bind_vs_state(pipe, ctx->vs_pos_only); if (ctx->has_geometry_shader) pipe->bind_gs_state(pipe, NULL); @@ -1756,6 +1770,66 @@ void util_blitter_copy_buffer(struct blitter_context *blitter, pipe_so_target_reference(&so_target, NULL); } +void util_blitter_clear_buffer(struct blitter_context *blitter, + struct pipe_resource *dst, + unsigned offset, unsigned size, + unsigned num_channels, + const union pipe_color_union *clear_value) +{ + struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter; + struct pipe_context *pipe = ctx->base.pipe; + struct pipe_vertex_buffer vb = {0}; + struct pipe_stream_output_target *so_target; + + assert(num_channels >= 1); + assert(num_channels <= 4); + + /* IMPORTANT: DON'T DO ANY BOUNDS CHECKING HERE! + * + * R600 uses this to initialize texture resources, so width0 might not be + * what you think it is. + */ + + /* Streamout is required. */ + if (!ctx->has_stream_out) { + assert(!"Streamout unsupported in util_blitter_clear_buffer()"); + return; + } + + /* Some alignment is required. */ + if (offset % 4 != 0 || size % 4 != 0) { + assert(!"Bad alignment in util_blitter_clear_buffer()"); + return; + } + + u_upload_data(ctx->upload, 0, num_channels*4, clear_value, + &vb.buffer_offset, &vb.buffer); + vb.stride = 0; + + blitter_set_running_flag(ctx); + blitter_check_saved_vertex_states(ctx); + blitter_disable_render_cond(ctx); + + pipe->set_vertex_buffers(pipe, ctx->base.vb_slot, 1, &vb); + pipe->bind_vertex_elements_state(pipe, + ctx->velem_state_readbuf[num_channels-1]); + pipe->bind_vs_state(pipe, ctx->vs_pos_only); + if (ctx->has_geometry_shader) + pipe->bind_gs_state(pipe, NULL); + pipe->bind_rasterizer_state(pipe, ctx->rs_discard_state); + + so_target = pipe->create_stream_output_target(pipe, dst, offset, size); + pipe->set_stream_output_targets(pipe, 1, &so_target, 0); + + util_draw_arrays(pipe, PIPE_PRIM_POINTS, 0, size / 4); + + blitter_restore_vertex_states(ctx); + blitter_restore_render_cond(ctx); + blitter_unset_running_flag(ctx); + pipe_so_target_reference(&so_target, NULL); + pipe_resource_reference(&vb.buffer, NULL); +} + /* probably radeon specific */ void util_blitter_custom_resolve_color(struct blitter_context *blitter, struct pipe_resource *dst, diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h index 20e69ed5b..19015844e 100644 --- a/mesalib/src/gallium/auxiliary/util/u_blitter.h +++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h @@ -276,7 +276,7 @@ void util_blitter_default_src_texture(struct pipe_sampler_view *src_templ, /** * Copy data from one buffer to another using the Stream Output functionality. - * Some alignment is required, otherwise software fallback is used. + * 4-byte alignment is required, otherwise software fallback is used. */ void util_blitter_copy_buffer(struct blitter_context *blitter, struct pipe_resource *dst, @@ -285,6 +285,22 @@ void util_blitter_copy_buffer(struct blitter_context *blitter, unsigned srcx, unsigned size); +/** + * Clear the contents of a buffer using the Stream Output functionality. + * 4-byte alignment is required. + * + * "num_channels" can be 1, 2, 3, or 4, and specifies if the clear value is + * R, RG, RGB, or RGBA. + * + * For each element, only "num_channels" components of "clear_value" are + * copied to the buffer, then the offset is incremented by num_channels*4. + */ +void util_blitter_clear_buffer(struct blitter_context *blitter, + struct pipe_resource *dst, + unsigned offset, unsigned size, + unsigned num_channels, + const union pipe_color_union *clear_value); + /** * Clear a region of a (color) surface to a constant value. * diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c index 3d2f8ebc3..0ef111c3b 100644 --- a/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c +++ b/mesalib/src/gallium/auxiliary/util/u_debug_symbol.c @@ -151,10 +151,8 @@ debug_symbol_name_dbghelp(const void *addr, char* buf, unsigned size) } #endif -#ifdef __GLIBC__ -#ifndef __UCLIBC__ +#if defined(__GLIBC__) && !defined(__UCLIBC__) #include -#endif /* This can only provide dynamic symbols, or binary offsets into a file. * @@ -179,7 +177,7 @@ debug_symbol_name(const void *addr, char* buf, unsigned size) return; #endif -#ifdef __GLIBC__ +#if defined(__GLIBC__) && !defined(__UCLIBC__) debug_symbol_name_glibc(addr, buf, size); if(buf[0]) return; diff --git a/mesalib/src/gallium/auxiliary/util/u_dump_state.c b/mesalib/src/gallium/auxiliary/util/u_dump_state.c index 2f28f3c84..12f1d2d6e 100644 --- a/mesalib/src/gallium/auxiliary/util/u_dump_state.c +++ b/mesalib/src/gallium/auxiliary/util/u_dump_state.c @@ -327,7 +327,8 @@ util_dump_rasterizer_state(FILE *stream, const struct pipe_rasterizer_state *sta util_dump_member(stream, uint, state, line_stipple_pattern); util_dump_member(stream, bool, state, line_last_pixel); util_dump_member(stream, bool, state, flatshade_first); - util_dump_member(stream, bool, state, gl_rasterization_rules); + util_dump_member(stream, bool, state, half_pixel_center); + util_dump_member(stream, bool, state, bottom_edge_rule); util_dump_member(stream, bool, state, rasterizer_discard); util_dump_member(stream, bool, state, depth_clip); util_dump_member(stream, uint, state, clip_plane_enable); diff --git a/mesalib/src/gallium/auxiliary/util/u_format.c b/mesalib/src/gallium/auxiliary/util/u_format.c index 18456371c..9bdc2eabf 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.c +++ b/mesalib/src/gallium/auxiliary/util/u_format.c @@ -632,6 +632,40 @@ void util_format_compose_swizzles(const unsigned char swz1[4], } } +void util_format_apply_color_swizzle(union pipe_color_union *dst, + const union pipe_color_union *src, + const unsigned char swz[4], + const boolean is_integer) +{ + unsigned c; + + if (is_integer) { + for (c = 0; c < 4; ++c) { + switch (swz[c]) { + case PIPE_SWIZZLE_RED: dst->ui[c] = src->ui[0]; break; + case PIPE_SWIZZLE_GREEN: dst->ui[c] = src->ui[1]; break; + case PIPE_SWIZZLE_BLUE: dst->ui[c] = src->ui[2]; break; + case PIPE_SWIZZLE_ALPHA: dst->ui[c] = src->ui[3]; break; + default: + dst->ui[c] = (swz[c] == PIPE_SWIZZLE_ONE) ? 1 : 0; + break; + } + } + } else { + for (c = 0; c < 4; ++c) { + switch (swz[c]) { + case PIPE_SWIZZLE_RED: dst->f[c] = src->f[0]; break; + case PIPE_SWIZZLE_GREEN: dst->f[c] = src->f[1]; break; + case PIPE_SWIZZLE_BLUE: dst->f[c] = src->f[2]; break; + case PIPE_SWIZZLE_ALPHA: dst->f[c] = src->f[3]; break; + default: + dst->f[c] = (swz[c] == PIPE_SWIZZLE_ONE) ? 1.0f : 0.0f; + break; + } + } + } +} + void util_format_swizzle_4f(float *dst, const float *src, const unsigned char swz[4]) { diff --git a/mesalib/src/gallium/auxiliary/util/u_format.h b/mesalib/src/gallium/auxiliary/util/u_format.h index ed942fb16..e4b9c365c 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.h +++ b/mesalib/src/gallium/auxiliary/util/u_format.h @@ -33,6 +33,9 @@ #include "pipe/p_format.h" #include "util/u_debug.h" +union pipe_color_union; + + #ifdef __cplusplus extern "C" { #endif @@ -1117,6 +1120,15 @@ void util_format_compose_swizzles(const unsigned char swz1[4], const unsigned char swz2[4], unsigned char dst[4]); +/* Apply the swizzle provided in \param swz (which is one of PIPE_SWIZZLE_x) + * to \param src and store the result in \param dst. + * \param is_integer determines the value written for PIPE_SWIZZLE_ONE. + */ +void util_format_apply_color_swizzle(union pipe_color_union *dst, + const union pipe_color_union *src, + const unsigned char swz[4], + const boolean is_integer); + void util_format_swizzle_4f(float *dst, const float *src, const unsigned char swz[4]); diff --git a/mesalib/src/gallium/auxiliary/util/u_format_latc.c b/mesalib/src/gallium/auxiliary/util/u_format_latc.c index 20feb241e..caab7e87a 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_latc.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_latc.c @@ -15,9 +15,10 @@ * 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. + * 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. * **************************************************************************/ diff --git a/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c b/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c index ff04e37b5..758e33774 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_rgtc.c @@ -15,9 +15,10 @@ * 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. + * 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. * **************************************************************************/ diff --git a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c index 4a9dc2237..35e3d3445 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_s3tc.c @@ -16,9 +16,10 @@ * 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. + * 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. * **************************************************************************/ diff --git a/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c b/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c index e1f18f39c..7974b1d76 100644 --- a/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/mesalib/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1271,7 +1271,8 @@ util_create_gen_mipmap(struct pipe_context *pipe, /* rasterizer */ memset(&ctx->rasterizer, 0, sizeof(ctx->rasterizer)); ctx->rasterizer.cull_face = PIPE_FACE_NONE; - ctx->rasterizer.gl_rasterization_rules = 1; + ctx->rasterizer.half_pixel_center = 1; + ctx->rasterizer.bottom_edge_rule = 1; ctx->rasterizer.depth_clip = 1; /* sampler state */ diff --git a/mesalib/src/gallium/auxiliary/util/u_inlines.h b/mesalib/src/gallium/auxiliary/util/u_inlines.h index 7770cd514..6e65ee6c9 100644 --- a/mesalib/src/gallium/auxiliary/util/u_inlines.h +++ b/mesalib/src/gallium/auxiliary/util/u_inlines.h @@ -485,8 +485,7 @@ util_get_min_point_size(const struct pipe_rasterizer_state *state) { /* The point size should be clamped to this value at the rasterizer stage. */ - return state->gl_rasterization_rules && - !state->point_quad_rasterization && + return !state->point_quad_rasterization && !state->point_smooth && !state->multisample ? 1.0f : 0.0f; } diff --git a/mesalib/src/gallium/auxiliary/util/u_prim.h b/mesalib/src/gallium/auxiliary/util/u_prim.h index d62c636f2..8f444a305 100644 --- a/mesalib/src/gallium/auxiliary/util/u_prim.h +++ b/mesalib/src/gallium/auxiliary/util/u_prim.h @@ -26,8 +26,8 @@ **************************************************************************/ -#ifndef U_BLIT_H -#define U_BLIT_H +#ifndef U_PRIM_H +#define U_PRIM_H #include "pipe/p_defines.h" @@ -37,95 +37,125 @@ extern "C" { #endif -static INLINE boolean u_validate_pipe_prim( unsigned pipe_prim, unsigned nr ) -{ - boolean ok = TRUE; +struct u_prim_vertex_count { + int min; + int incr; +}; - switch (pipe_prim) { - case PIPE_PRIM_POINTS: - ok = (nr >= 1); - break; - case PIPE_PRIM_LINES: - ok = (nr >= 2); - break; - case PIPE_PRIM_LINE_STRIP: +/** + * Decompose a primitive that is a loop, a strip, or a fan. Return the + * original primitive if it is already decomposed. + */ +static INLINE unsigned +u_decomposed_prim(unsigned prim) +{ + switch (prim) { case PIPE_PRIM_LINE_LOOP: - ok = (nr >= 2); - break; - case PIPE_PRIM_TRIANGLES: - ok = (nr >= 3); - break; + case PIPE_PRIM_LINE_STRIP: + return PIPE_PRIM_LINES; case PIPE_PRIM_TRIANGLE_STRIP: case PIPE_PRIM_TRIANGLE_FAN: - case PIPE_PRIM_POLYGON: - ok = (nr >= 3); - break; - case PIPE_PRIM_QUADS: - ok = (nr >= 4); - break; + return PIPE_PRIM_TRIANGLES; case PIPE_PRIM_QUAD_STRIP: - ok = (nr >= 4); - break; + return PIPE_PRIM_QUADS; + case PIPE_PRIM_LINE_STRIP_ADJACENCY: + return PIPE_PRIM_LINES_ADJACENCY; + case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: + return PIPE_PRIM_TRIANGLES_ADJACENCY; default: - ok = 0; - break; + return prim; } +} - return ok; +/** + * Reduce a primitive to one of PIPE_PRIM_POINTS, PIPE_PRIM_LINES, and + * PIPE_PRIM_TRIANGLES. + */ +static INLINE unsigned +u_reduced_prim(unsigned prim) +{ + switch (prim) { + case PIPE_PRIM_POINTS: + return PIPE_PRIM_POINTS; + case PIPE_PRIM_LINES: + case PIPE_PRIM_LINE_LOOP: + case PIPE_PRIM_LINE_STRIP: + case PIPE_PRIM_LINES_ADJACENCY: + case PIPE_PRIM_LINE_STRIP_ADJACENCY: + return PIPE_PRIM_LINES; + default: + return PIPE_PRIM_TRIANGLES; + } } +/** + * Re-assemble a primitive to remove its adjacency. + */ +static INLINE unsigned +u_assembled_prim(unsigned prim) +{ + switch (prim) { + case PIPE_PRIM_LINES_ADJACENCY: + case PIPE_PRIM_LINE_STRIP_ADJACENCY: + return PIPE_PRIM_LINES; + case PIPE_PRIM_TRIANGLES_ADJACENCY: + case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: + return PIPE_PRIM_TRIANGLES; + default: + return prim; + } +} -static INLINE boolean u_trim_pipe_prim( unsigned pipe_prim, unsigned *nr ) +/** + * Return the vertex count information for a primitive. + * + * Note that if this function is called directly or indirectly anywhere in a + * source file, it will increase the size of the binary slightly more than + * expected because of the use of a table. + */ +static INLINE const struct u_prim_vertex_count * +u_prim_vertex_count(unsigned prim) { - boolean ok = TRUE; - const static unsigned values[][2] = { - { 1, 0 }, /* PIPE_PRIM_POINTS */ + static const struct u_prim_vertex_count prim_table[PIPE_PRIM_MAX] = { + { 1, 1 }, /* PIPE_PRIM_POINTS */ { 2, 2 }, /* PIPE_PRIM_LINES */ - { 2, 0 }, /* PIPE_PRIM_LINE_LOOP */ - { 2, 0 }, /* PIPE_PRIM_LINE_STRIP */ + { 2, 1 }, /* PIPE_PRIM_LINE_LOOP */ + { 2, 1 }, /* PIPE_PRIM_LINE_STRIP */ { 3, 3 }, /* PIPE_PRIM_TRIANGLES */ - { 3, 0 }, /* PIPE_PRIM_TRIANGLE_STRIP */ - { 3, 0 }, /* PIPE_PRIM_TRIANGLE_FAN */ - { 4, 4 }, /* PIPE_PRIM_TRIANGLE_QUADS */ - { 4, 2 }, /* PIPE_PRIM_TRIANGLE_QUAD_STRIP */ - { 3, 0 }, /* PIPE_PRIM_TRIANGLE_POLYGON */ + { 3, 1 }, /* PIPE_PRIM_TRIANGLE_STRIP */ + { 3, 1 }, /* PIPE_PRIM_TRIANGLE_FAN */ + { 4, 4 }, /* PIPE_PRIM_QUADS */ + { 4, 2 }, /* PIPE_PRIM_QUAD_STRIP */ + { 3, 1 }, /* PIPE_PRIM_POLYGON */ { 4, 4 }, /* PIPE_PRIM_LINES_ADJACENCY */ - { 4, 0 }, /* PIPE_PRIM_LINE_STRIP_ADJACENCY */ - { 6, 5 }, /* PIPE_PRIM_TRIANGLES_ADJACENCY */ - { 4, 0 }, /* PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY */ + { 4, 1 }, /* PIPE_PRIM_LINE_STRIP_ADJACENCY */ + { 6, 6 }, /* PIPE_PRIM_TRIANGLES_ADJACENCY */ + { 6, 2 }, /* PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY */ }; - if (unlikely(pipe_prim >= PIPE_PRIM_MAX)) { - *nr = 0; - return FALSE; - } - - ok = (*nr >= values[pipe_prim][0]); - if (values[pipe_prim][1]) - *nr -= (*nr % values[pipe_prim][1]); + return (likely(prim < PIPE_PRIM_MAX)) ? &prim_table[prim] : NULL; +} - if (!ok) - *nr = 0; +static INLINE boolean u_validate_pipe_prim( unsigned pipe_prim, unsigned nr ) +{ + const struct u_prim_vertex_count *count = u_prim_vertex_count(pipe_prim); - return ok; + return (count && nr >= count->min); } -static INLINE unsigned u_reduced_prim( unsigned pipe_prim ) +static INLINE boolean u_trim_pipe_prim( unsigned pipe_prim, unsigned *nr ) { - switch (pipe_prim) { - case PIPE_PRIM_POINTS: - return PIPE_PRIM_POINTS; + const struct u_prim_vertex_count *count = u_prim_vertex_count(pipe_prim); - case PIPE_PRIM_LINES: - case PIPE_PRIM_LINES_ADJACENCY: - case PIPE_PRIM_LINE_STRIP: - case PIPE_PRIM_LINE_STRIP_ADJACENCY: - case PIPE_PRIM_LINE_LOOP: - return PIPE_PRIM_LINES; - - default: - return PIPE_PRIM_TRIANGLES; + if (count && *nr >= count->min) { + if (count->incr > 1) + *nr -= (*nr % count->incr); + return TRUE; + } + else { + *nr = 0; + return FALSE; } } @@ -165,46 +195,71 @@ u_vertices_per_prim(int primitive) /** * Returns the number of decomposed primitives for the given * vertex count. - * Geometry shader is invoked once for each triangle in + * Parts of the pipline are invoked once for each triangle in * triangle strip, triangle fans and triangles and once - * for each line in line strip, line loop, lines. + * for each line in line strip, line loop, lines. Also + * statistics depend on knowing the exact number of decomposed + * primitives for a set of vertices. */ static INLINE unsigned -u_gs_prims_for_vertices(int primitive, int vertices) +u_decomposed_prims_for_vertices(int primitive, int vertices) { - switch(primitive) { + switch (primitive) { case PIPE_PRIM_POINTS: return vertices; case PIPE_PRIM_LINES: return vertices / 2; case PIPE_PRIM_LINE_LOOP: - return vertices; + return (vertices >= 2) ? vertices : 0; case PIPE_PRIM_LINE_STRIP: - return vertices - 1; + return (vertices >= 2) ? vertices - 1 : 0; case PIPE_PRIM_TRIANGLES: - return vertices / 3; + return vertices / 3; case PIPE_PRIM_TRIANGLE_STRIP: - return vertices - 2; + return (vertices >= 3) ? vertices - 2 : 0; case PIPE_PRIM_TRIANGLE_FAN: - return vertices - 2; + return (vertices >= 3) ? vertices - 2 : 0; case PIPE_PRIM_LINES_ADJACENCY: - return vertices / 2; + return vertices / 4; case PIPE_PRIM_LINE_STRIP_ADJACENCY: - return vertices - 1; + return (vertices >= 4) ? vertices - 3 : 0; case PIPE_PRIM_TRIANGLES_ADJACENCY: - return vertices / 3; + return vertices / 6; case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: - return vertices - 2; - - /* following primitives should never be used - * with geometry shaders abd their size is - * undefined */ + return (vertices >= 6) ? 1 + (vertices - 6) / 2 : 0; + case PIPE_PRIM_QUADS: + return vertices / 4; + case PIPE_PRIM_QUAD_STRIP: + return (vertices >= 4) ? (vertices - 2) / 2 : 0; + /* Polygons can't be decomposed + * because the number of their vertices isn't known so + * for them and whatever else we don't recognize just + * return 1 if the number of vertices is greater than + * or equal to 3 and zero otherwise */ case PIPE_PRIM_POLYGON: + default: + debug_printf("Invalid decomposition primitive!\n"); + return (vertices >= 3) ? 1 : 0; + } +} + +/** + * Returns the number of reduced/tessellated primitives for the given vertex + * count. Each quad is treated as two triangles. Polygons are treated as + * triangle fans. + */ +static INLINE unsigned +u_reduced_prims_for_vertices(int primitive, int vertices) +{ + switch (primitive) { case PIPE_PRIM_QUADS: case PIPE_PRIM_QUAD_STRIP: + return u_decomposed_prims_for_vertices(primitive, vertices) * 2; + case PIPE_PRIM_POLYGON: + primitive = PIPE_PRIM_TRIANGLE_FAN; + /* fall through */ default: - debug_printf("Unrecognized geometry shader primitive"); - return 3; + return u_decomposed_prims_for_vertices(primitive, vertices); } } diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_list.h b/mesalib/src/gallium/auxiliary/util/u_simple_list.h index fe5977137..7a47c1a78 100644 --- a/mesalib/src/gallium/auxiliary/util/u_simple_list.h +++ b/mesalib/src/gallium/auxiliary/util/u_simple_list.h @@ -28,9 +28,10 @@ * 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. + * 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. */ diff --git a/mesalib/src/gallium/auxiliary/util/u_sse.h b/mesalib/src/gallium/auxiliary/util/u_sse.h index 1df6c8726..d100c4706 100644 --- a/mesalib/src/gallium/auxiliary/util/u_sse.h +++ b/mesalib/src/gallium/auxiliary/util/u_sse.h @@ -175,7 +175,12 @@ static INLINE void u_print_ps(const char *name, __m128 r) * MSVC will never get in here as its intrinsics support do not rely on * compiler command line options. */ -static __inline __m128i __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +static __inline __m128i +#ifdef __clang__ + __attribute__((__always_inline__, __nodebug__)) +#else + __attribute__((__gnu_inline__, __always_inline__, __artificial__)) +#endif _mm_shuffle_epi8(__m128i a, __m128i mask) { __m128i result; diff --git a/mesalib/src/glsl/Makefile.am b/mesalib/src/glsl/Makefile.am index d0e5cd1d0..2bbad3d65 100644 --- a/mesalib/src/glsl/Makefile.am +++ b/mesalib/src/glsl/Makefile.am @@ -27,8 +27,7 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/src/mesa/ \ -I$(top_srcdir)/src/glsl/glcpp \ -I$(top_srcdir)/src/gtest/include \ - $(DEFINES) \ - $(API_DEFINES) + $(DEFINES) AM_CFLAGS = $(VISIBILITY_CFLAGS) AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS) diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources index b5282a604..50bad85ad 100644 --- a/mesalib/src/glsl/Makefile.sources +++ b/mesalib/src/glsl/Makefile.sources @@ -16,6 +16,7 @@ LIBGLCPP_GENERATED_FILES = \ # libglsl LIBGLSL_FILES = \ + $(GLSL_SRCDIR)/ast_array_index.cpp \ $(GLSL_SRCDIR)/ast_expr.cpp \ $(GLSL_SRCDIR)/ast_function.cpp \ $(GLSL_SRCDIR)/ast_to_hir.cpp \ @@ -45,6 +46,7 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/ir_variable_refcount.cpp \ $(GLSL_SRCDIR)/linker.cpp \ $(GLSL_SRCDIR)/link_functions.cpp \ + $(GLSL_SRCDIR)/link_interface_blocks.cpp \ $(GLSL_SRCDIR)/link_uniforms.cpp \ $(GLSL_SRCDIR)/link_uniform_initializers.cpp \ $(GLSL_SRCDIR)/link_uniform_block_active_visitor.cpp \ @@ -62,12 +64,14 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/lower_mat_op_to_vec.cpp \ $(GLSL_SRCDIR)/lower_noise.cpp \ $(GLSL_SRCDIR)/lower_packed_varyings.cpp \ + $(GLSL_SRCDIR)/lower_named_interface_blocks.cpp \ $(GLSL_SRCDIR)/lower_packing_builtins.cpp \ $(GLSL_SRCDIR)/lower_texture_projection.cpp \ $(GLSL_SRCDIR)/lower_variable_index_to_cond_assign.cpp \ $(GLSL_SRCDIR)/lower_vec_index_to_cond_assign.cpp \ $(GLSL_SRCDIR)/lower_vec_index_to_swizzle.cpp \ $(GLSL_SRCDIR)/lower_vector.cpp \ + $(GLSL_SRCDIR)/lower_vector_insert.cpp \ $(GLSL_SRCDIR)/lower_output_reads.cpp \ $(GLSL_SRCDIR)/lower_ubo_reference.cpp \ $(GLSL_SRCDIR)/opt_algebraic.cpp \ @@ -81,6 +85,7 @@ LIBGLSL_FILES = \ $(GLSL_SRCDIR)/opt_dead_code_local.cpp \ $(GLSL_SRCDIR)/opt_dead_functions.cpp \ $(GLSL_SRCDIR)/opt_flatten_nested_if_blocks.cpp \ + $(GLSL_SRCDIR)/opt_flip_matrices.cpp \ $(GLSL_SRCDIR)/opt_function_inlining.cpp \ $(GLSL_SRCDIR)/opt_if_simplification.cpp \ $(GLSL_SRCDIR)/opt_noop_swizzle.cpp \ diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h index fcc6b4566..df2a21f79 100644 --- a/mesalib/src/glsl/ast.h +++ b/mesalib/src/glsl/ast.h @@ -805,9 +805,9 @@ public: ast_compound_statement *body; }; -class ast_uniform_block : public ast_node { +class ast_interface_block : public ast_node { public: - ast_uniform_block(ast_type_qualifier layout, + ast_interface_block(ast_type_qualifier layout, const char *instance_name, ast_expression *array_size) : layout(layout), block_name(NULL), instance_name(instance_name), @@ -854,7 +854,17 @@ _mesa_ast_field_selection_to_hir(const ast_expression *expr, exec_list *instructions, struct _mesa_glsl_parse_state *state); +extern ir_rvalue * +_mesa_ast_array_index_to_hir(void *mem_ctx, + struct _mesa_glsl_parse_state *state, + ir_rvalue *array, ir_rvalue *idx, + YYLTYPE &loc, YYLTYPE &idx_loc); + void emit_function(_mesa_glsl_parse_state *state, ir_function *f); +extern void +check_builtin_array_max_size(const char *name, unsigned size, + YYLTYPE loc, struct _mesa_glsl_parse_state *state); + #endif /* AST_H */ diff --git a/mesalib/src/glsl/ast_array_index.cpp b/mesalib/src/glsl/ast_array_index.cpp new file mode 100644 index 000000000..4baeb6f9d --- /dev/null +++ b/mesalib/src/glsl/ast_array_index.cpp @@ -0,0 +1,190 @@ +/* + * 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 "ast.h" +#include "glsl_types.h" +#include "ir.h" + +ir_rvalue * +_mesa_ast_array_index_to_hir(void *mem_ctx, + struct _mesa_glsl_parse_state *state, + ir_rvalue *array, ir_rvalue *idx, + YYLTYPE &loc, YYLTYPE &idx_loc) +{ + if (!array->type->is_error() + && !array->type->is_array() + && !array->type->is_matrix() + && !array->type->is_vector()) { + _mesa_glsl_error(& idx_loc, state, + "cannot dereference non-array / non-matrix / " + "non-vector"); + } + + if (!idx->type->is_error()) { + if (!idx->type->is_integer()) { + _mesa_glsl_error(& idx_loc, state, "array index must be integer type"); + } else if (!idx->type->is_scalar()) { + _mesa_glsl_error(& idx_loc, state, "array index must be scalar"); + } + } + + /* If the array index is a constant expression and the array has a + * declared size, ensure that the access is in-bounds. If the array + * index is not a constant expression, ensure that the array has a + * declared size. + */ + ir_constant *const const_index = idx->constant_expression_value(); + if (const_index != NULL && idx->type->is_integer()) { + const int idx = const_index->value.i[0]; + const char *type_name = "error"; + unsigned bound = 0; + + /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: + * + * "It is illegal to declare an array with a size, and then + * later (in the same shader) index the same array with an + * integral constant expression greater than or equal to the + * declared size. It is also illegal to index an array with a + * negative constant expression." + */ + if (array->type->is_matrix()) { + if (array->type->row_type()->vector_elements <= idx) { + type_name = "matrix"; + bound = array->type->row_type()->vector_elements; + } + } else if (array->type->is_vector()) { + if (array->type->vector_elements <= idx) { + type_name = "vector"; + bound = array->type->vector_elements; + } + } else { + /* glsl_type::array_size() returns 0 for non-array types. This means + * that we don't need to verify that the type is an array before + * doing the bounds checking. + */ + if ((array->type->array_size() > 0) + && (array->type->array_size() <= idx)) { + type_name = "array"; + bound = array->type->array_size(); + } + } + + if (bound > 0) { + _mesa_glsl_error(& loc, state, "%s index must be < %u", + type_name, bound); + } else if (idx < 0) { + _mesa_glsl_error(& loc, state, "%s index must be >= 0", + type_name); + } + + if (array->type->is_array()) { + /* If the array is a variable dereference, it dereferences the + * whole array, by definition. Use this to get the variable. + * + * FINISHME: Should some methods for getting / setting / testing + * FINISHME: array access limits be added to ir_dereference? + */ + ir_variable *const v = array->whole_variable_referenced(); + if ((v != NULL) && (unsigned(idx) > v->max_array_access)) { + v->max_array_access = idx; + + /* Check whether this access will, as a side effect, implicitly + * cause the size of a built-in array to be too large. + */ + check_builtin_array_max_size(v->name, idx+1, loc, state); + } + } + } else if (const_index == NULL && array->type->is_array()) { + if (array->type->array_size() == 0) { + _mesa_glsl_error(&loc, state, "unsized array index must be constant"); + } else if (array->type->fields.array->is_interface()) { + /* Page 46 in section 4.3.7 of the OpenGL ES 3.00 spec says: + * + * "All indexes used to index a uniform block array must be + * constant integral expressions." + */ + _mesa_glsl_error(&loc, state, + "uniform block array index must be constant"); + } else { + /* whole_variable_referenced can return NULL if the array is a + * member of a structure. In this case it is safe to not update + * the max_array_access field because it is never used for fields + * of structures. + */ + ir_variable *v = array->whole_variable_referenced(); + if (v != NULL) + v->max_array_access = array->type->array_size() - 1; + } + + /* From page 23 (29 of the PDF) of the GLSL 1.30 spec: + * + * "Samplers aggregated into arrays within a shader (using square + * brackets [ ]) can only be indexed with integral constant + * expressions [...]." + * + * This restriction was added in GLSL 1.30. Shaders using earlier + * version of the language should not be rejected by the compiler + * front-end for using this construct. This allows useful things such + * as using a loop counter as the index to an array of samplers. If the + * loop in unrolled, the code should compile correctly. Instead, emit a + * warning. + */ + if (array->type->element_type()->is_sampler()) { + if (!state->is_version(130, 100)) { + if (state->es_shader) { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is optional in %s", + state->get_version_string()); + } else { + _mesa_glsl_warning(&loc, state, + "sampler arrays indexed with non-constant " + "expressions will be forbidden in GLSL 1.30 " + "and later"); + } + } else { + _mesa_glsl_error(&loc, state, + "sampler arrays indexed with non-constant " + "expressions is forbidden in GLSL 1.30 and " + "later"); + } + } + } + + /* After performing all of the error checking, generate the IR for the + * expression. + */ + if (array->type->is_array() + || array->type->is_matrix()) { + return new(mem_ctx) ir_dereference_array(array, idx); + } else if (array->type->is_vector()) { + return new(mem_ctx) ir_expression(ir_binop_vector_extract, array, idx); + } else if (array->type->is_error()) { + return array; + } else { + ir_rvalue *result = new(mem_ctx) ir_dereference_array(array, idx); + result->type = glsl_type::error_type; + + return result; + } +} diff --git a/mesalib/src/glsl/ast_function.cpp b/mesalib/src/glsl/ast_function.cpp index 26f72cf8e..00e0c05dd 100644 --- a/mesalib/src/glsl/ast_function.cpp +++ b/mesalib/src/glsl/ast_function.cpp @@ -165,10 +165,18 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, actual->variable_referenced()->name); return false; } else if (!actual->is_lvalue()) { - _mesa_glsl_error(&loc, state, - "function parameter '%s %s' is not an lvalue", - mode, formal->name); - return false; + /* Even though ir_binop_vector_extract is not an l-value, let it + * slop through. generate_call will handle it correctly. + */ + ir_expression *const expr = ((ir_rvalue *) actual)->as_expression(); + if (expr == NULL + || expr->operation != ir_binop_vector_extract + || !expr->operands[0]->is_lvalue()) { + _mesa_glsl_error(&loc, state, + "function parameter '%s %s' is not an lvalue", + mode, formal->name); + return false; + } } } @@ -178,6 +186,93 @@ verify_parameter_modes(_mesa_glsl_parse_state *state, return true; } +static void +fix_parameter(void *mem_ctx, ir_rvalue *actual, const glsl_type *formal_type, + exec_list *before_instructions, exec_list *after_instructions, + bool parameter_is_inout) +{ + ir_expression *const expr = actual->as_expression(); + + /* If the types match exactly and the parameter is not a vector-extract, + * nothing needs to be done to fix the parameter. + */ + if (formal_type == actual->type + && (expr == NULL || expr->operation != ir_binop_vector_extract)) + return; + + /* To convert an out parameter, we need to create a temporary variable to + * hold the value before conversion, and then perform the conversion after + * the function call returns. + * + * This has the effect of transforming code like this: + * + * void f(out int x); + * float value; + * f(value); + * + * Into IR that's equivalent to this: + * + * void f(out int x); + * float value; + * int out_parameter_conversion; + * f(out_parameter_conversion); + * value = float(out_parameter_conversion); + * + * If the parameter is an ir_expression of ir_binop_vector_extract, + * additional conversion is needed in the post-call re-write. + */ + ir_variable *tmp = + new(mem_ctx) ir_variable(formal_type, "inout_tmp", ir_var_temporary); + + before_instructions->push_tail(tmp); + + /* If the parameter is an inout parameter, copy the value of the actual + * parameter to the new temporary. Note that no type conversion is allowed + * here because inout parameters must match types exactly. + */ + if (parameter_is_inout) { + /* Inout parameters should never require conversion, since that would + * require an implicit conversion to exist both to and from the formal + * parameter type, and there are no bidirectional implicit conversions. + */ + assert (actual->type == formal_type); + + ir_dereference_variable *const deref_tmp_1 = + new(mem_ctx) ir_dereference_variable(tmp); + ir_assignment *const assignment = + new(mem_ctx) ir_assignment(deref_tmp_1, actual); + before_instructions->push_tail(assignment); + } + + /* Replace the parameter in the call with a dereference of the new + * temporary. + */ + ir_dereference_variable *const deref_tmp_2 = + new(mem_ctx) ir_dereference_variable(tmp); + actual->replace_with(deref_tmp_2); + + + /* Copy the temporary variable to the actual parameter with optional + * type conversion applied. + */ + ir_rvalue *rhs = new(mem_ctx) ir_dereference_variable(tmp); + if (actual->type != formal_type) + rhs = convert_component(rhs, actual->type); + + ir_rvalue *lhs = actual; + if (expr != NULL && expr->operation == ir_binop_vector_extract) { + rhs = new(mem_ctx) ir_expression(ir_triop_vector_insert, + expr->operands[0]->type, + expr->operands[0]->clone(mem_ctx, NULL), + rhs, + expr->operands[1]->clone(mem_ctx, NULL)); + lhs = expr->operands[0]->clone(mem_ctx, NULL); + } + + ir_assignment *const assignment_2 = new(mem_ctx) ir_assignment(lhs, rhs); + after_instructions->push_tail(assignment_2); +} + /** * If a function call is generated, \c call_ir will point to it on exit. * Otherwise \c call_ir will be set to \c NULL. @@ -218,50 +313,10 @@ generate_call(exec_list *instructions, ir_function_signature *sig, break; } case ir_var_function_out: - if (actual->type != formal->type) { - /* To convert an out parameter, we need to create a - * temporary variable to hold the value before conversion, - * and then perform the conversion after the function call - * returns. - * - * This has the effect of transforming code like this: - * - * void f(out int x); - * float value; - * f(value); - * - * Into IR that's equivalent to this: - * - * void f(out int x); - * float value; - * int out_parameter_conversion; - * f(out_parameter_conversion); - * value = float(out_parameter_conversion); - */ - ir_variable *tmp = - new(ctx) ir_variable(formal->type, - "out_parameter_conversion", - ir_var_temporary); - instructions->push_tail(tmp); - ir_dereference_variable *deref_tmp_1 - = new(ctx) ir_dereference_variable(tmp); - ir_dereference_variable *deref_tmp_2 - = new(ctx) ir_dereference_variable(tmp); - ir_rvalue *converted_tmp - = convert_component(deref_tmp_1, actual->type); - ir_assignment *assignment - = new(ctx) ir_assignment(actual, converted_tmp); - post_call_conversions.push_tail(assignment); - actual->replace_with(deref_tmp_2); - } - break; case ir_var_function_inout: - /* Inout parameters should never require conversion, since that - * would require an implicit conversion to exist both to and - * from the formal parameter type, and there are no - * bidirectional implicit conversions. - */ - assert (actual->type == formal->type); + fix_parameter(ctx, actual, formal->type, + instructions, &post_call_conversions, + formal->mode == ir_var_function_inout); break; default: assert (!"Illegal formal parameter mode"); diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp index 92065f5b7..e918adeef 100644 --- a/mesalib/src/glsl/ast_to_hir.cpp +++ b/mesalib/src/glsl/ast_to_hir.cpp @@ -672,6 +672,30 @@ do_assignment(exec_list *instructions, struct _mesa_glsl_parse_state *state, void *ctx = state; bool error_emitted = (lhs->type->is_error() || rhs->type->is_error()); + /* If the assignment LHS comes back as an ir_binop_vector_extract + * expression, move it to the RHS as an ir_triop_vector_insert. + */ + if (lhs->ir_type == ir_type_expression) { + ir_expression *const expr = lhs->as_expression(); + + if (unlikely(expr->operation == ir_binop_vector_extract)) { + ir_rvalue *new_rhs = + validate_assignment(state, lhs->type, rhs, is_initializer); + + if (new_rhs == NULL) { + _mesa_glsl_error(& lhs_loc, state, "type mismatch"); + return lhs; + } else { + rhs = new(ctx) ir_expression(ir_triop_vector_insert, + expr->operands[0]->type, + expr->operands[0], + new_rhs, + expr->operands[1]); + lhs = expr->operands[0]->clone(ctx, NULL); + } + } + } + ir_variable *lhs_var = lhs->variable_referenced(); if (lhs_var) lhs_var->assigned = true; @@ -904,7 +928,7 @@ get_scalar_boolean_operand(exec_list *instructions, * If name refers to a builtin array whose maximum allowed size is less than * size, report an error and return true. Otherwise return false. */ -static bool +void check_builtin_array_max_size(const char *name, unsigned size, YYLTYPE loc, struct _mesa_glsl_parse_state *state) { @@ -918,7 +942,6 @@ check_builtin_array_max_size(const char *name, unsigned size, _mesa_glsl_error(&loc, state, "`gl_TexCoord' array size cannot " "be larger than gl_MaxTextureCoords (%u)\n", state->Const.MaxTextureCoords); - return true; } else if (strcmp("gl_ClipDistance", name) == 0 && size > state->Const.MaxClipPlanes) { /* From section 7.1 (Vertex Shader Special Variables) of the @@ -933,9 +956,7 @@ check_builtin_array_max_size(const char *name, unsigned size, _mesa_glsl_error(&loc, state, "`gl_ClipDistance' array size cannot " "be larger than gl_MaxClipDistances (%u)\n", state->Const.MaxClipPlanes); - return true; } - return false; } /** @@ -1517,172 +1538,11 @@ ast_expression::hir(exec_list *instructions, op[0] = subexpressions[0]->hir(instructions, state); op[1] = subexpressions[1]->hir(instructions, state); - error_emitted = op[0]->type->is_error() || op[1]->type->is_error(); - - ir_rvalue *const array = op[0]; - - result = new(ctx) ir_dereference_array(op[0], op[1]); - - /* Do not use op[0] after this point. Use array. - */ - op[0] = NULL; - + result = _mesa_ast_array_index_to_hir(ctx, state, op[0], op[1], + loc, index_loc); - if (error_emitted) - break; - - if (!array->type->is_array() - && !array->type->is_matrix() - && !array->type->is_vector()) { - _mesa_glsl_error(& index_loc, state, - "cannot dereference non-array / non-matrix / " - "non-vector"); + if (result->type->is_error()) error_emitted = true; - } - - if (!op[1]->type->is_integer()) { - _mesa_glsl_error(& index_loc, state, - "array index must be integer type"); - error_emitted = true; - } else if (!op[1]->type->is_scalar()) { - _mesa_glsl_error(& index_loc, state, - "array index must be scalar"); - error_emitted = true; - } - - /* If the array index is a constant expression and the array has a - * declared size, ensure that the access is in-bounds. If the array - * index is not a constant expression, ensure that the array has a - * declared size. - */ - ir_constant *const const_index = op[1]->constant_expression_value(); - if (const_index != NULL) { - const int idx = const_index->value.i[0]; - const char *type_name; - unsigned bound = 0; - - if (array->type->is_matrix()) { - type_name = "matrix"; - } else if (array->type->is_vector()) { - type_name = "vector"; - } else { - type_name = "array"; - } - - /* From page 24 (page 30 of the PDF) of the GLSL 1.50 spec: - * - * "It is illegal to declare an array with a size, and then - * later (in the same shader) index the same array with an - * integral constant expression greater than or equal to the - * declared size. It is also illegal to index an array with a - * negative constant expression." - */ - if (array->type->is_matrix()) { - if (array->type->row_type()->vector_elements <= idx) { - bound = array->type->row_type()->vector_elements; - } - } else if (array->type->is_vector()) { - if (array->type->vector_elements <= idx) { - bound = array->type->vector_elements; - } - } else { - if ((array->type->array_size() > 0) - && (array->type->array_size() <= idx)) { - bound = array->type->array_size(); - } - } - - if (bound > 0) { - _mesa_glsl_error(& loc, state, "%s index must be < %u", - type_name, bound); - error_emitted = true; - } else if (idx < 0) { - _mesa_glsl_error(& loc, state, "%s index must be >= 0", - type_name); - error_emitted = true; - } - - if (array->type->is_array()) { - /* If the array is a variable dereference, it dereferences the - * whole array, by definition. Use this to get the variable. - * - * FINISHME: Should some methods for getting / setting / testing - * FINISHME: array access limits be added to ir_dereference? - */ - ir_variable *const v = array->whole_variable_referenced(); - if ((v != NULL) && (unsigned(idx) > v->max_array_access)) { - v->max_array_access = idx; - - /* Check whether this access will, as a side effect, implicitly - * cause the size of a built-in array to be too large. - */ - if (check_builtin_array_max_size(v->name, idx+1, loc, state)) - error_emitted = true; - } - } - } else if (array->type->array_size() == 0) { - _mesa_glsl_error(&loc, state, "unsized array index must be constant"); - } else if (array->type->is_array() - && array->type->fields.array->is_interface()) { - /* Page 46 in section 4.3.7 of the OpenGL ES 3.00 spec says: - * - * "All indexes used to index a uniform block array must be - * constant integral expressions." - */ - _mesa_glsl_error(&loc, state, - "uniform block array index must be constant"); - } else { - if (array->type->is_array()) { - /* whole_variable_referenced can return NULL if the array is a - * member of a structure. In this case it is safe to not update - * the max_array_access field because it is never used for fields - * of structures. - */ - ir_variable *v = array->whole_variable_referenced(); - if (v != NULL) - v->max_array_access = array->type->array_size() - 1; - } - } - - /* From page 23 (29 of the PDF) of the GLSL 1.30 spec: - * - * "Samplers aggregated into arrays within a shader (using square - * brackets [ ]) can only be indexed with integral constant - * expressions [...]." - * - * This restriction was added in GLSL 1.30. Shaders using earlier version - * of the language should not be rejected by the compiler front-end for - * using this construct. This allows useful things such as using a loop - * counter as the index to an array of samplers. If the loop in unrolled, - * the code should compile correctly. Instead, emit a warning. - */ - if (array->type->is_array() && - array->type->element_type()->is_sampler() && - const_index == NULL) { - - if (!state->is_version(130, 100)) { - if (state->es_shader) { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is optional in %s", - state->get_version_string()); - } else { - _mesa_glsl_warning(&loc, state, - "sampler arrays indexed with non-constant " - "expressions will be forbidden in GLSL 1.30 and " - "later"); - } - } else { - _mesa_glsl_error(&loc, state, - "sampler arrays indexed with non-constant " - "expressions is forbidden in GLSL 1.30 and " - "later"); - error_emitted = true; - } - } - - if (error_emitted) - result->type = glsl_type::error_type; break; } @@ -1842,6 +1702,9 @@ process_array_type(YYLTYPE *loc, const glsl_type *base, ast_node *array_size, { unsigned length = 0; + if (base == NULL) + return glsl_type::error_type; + /* From page 19 (page 25) of the GLSL 1.20 spec: * * "Only one-dimensional arrays may be declared." @@ -1894,7 +1757,8 @@ process_array_type(YYLTYPE *loc, const glsl_type *base, ast_node *array_size, "allowed in GLSL ES 1.00."); } - return glsl_type::get_array_instance(base, length); + const glsl_type *array_type = glsl_type::get_array_instance(base, length); + return array_type != NULL ? array_type : glsl_type::error_type; } @@ -3365,10 +3229,17 @@ ast_function::hir(exec_list *instructions, "match prototype", name); } - if (is_definition && sig->is_defined) { - YYLTYPE loc = this->get_location(); - - _mesa_glsl_error(& loc, state, "function `%s' redefined", name); + if (sig->is_defined) { + if (is_definition) { + YYLTYPE loc = this->get_location(); + _mesa_glsl_error(& loc, state, "function `%s' redefined", name); + } else { + /* We just encountered a prototype that exactly matches a + * function that's already been defined. This is redundant, + * and we should ignore it. + */ + return NULL; + } } } } else { @@ -4149,8 +4020,14 @@ ast_process_structure_or_interface_block(exec_list *instructions, * blocks. All other types, arrays, and structures * allowed for uniforms are allowed within a uniform * block." + * + * It should be impossible for decl_type to be NULL here. Cases that + * might naturally lead to decl_type being NULL, especially for the + * is_interface case, will have resulted in compilation having + * already halted due to a syntax error. */ - const struct glsl_type *field_type = decl_type; + const struct glsl_type *field_type = + decl_type != NULL ? decl_type : glsl_type::error_type; if (is_interface && field_type->contains_sampler()) { YYLTYPE loc = decl_list->get_location(); @@ -4173,12 +4050,15 @@ ast_process_structure_or_interface_block(exec_list *instructions, field_type = process_array_type(&loc, decl_type, decl->array_size, state); } - fields[i].type = (field_type != NULL) - ? field_type : glsl_type::error_type; + fields[i].type = field_type; fields[i].name = decl->identifier; if (qual->flags.q.row_major || qual->flags.q.column_major) { - if (!field_type->is_matrix() && !field_type->is_record()) { + if (!qual->flags.q.uniform) { + _mesa_glsl_error(&loc, state, + "row_major and column_major can only be " + "applied to uniform interface blocks."); + } else if (!field_type->is_matrix() && !field_type->is_record()) { _mesa_glsl_error(&loc, state, "uniform block layout qualifiers row_major and " "column_major can only be applied to matrix and " @@ -4187,6 +4067,12 @@ ast_process_structure_or_interface_block(exec_list *instructions, validate_matrix_layout_for_type(state, &loc, field_type); } + if (qual->flags.q.uniform && qual->has_interpolation()) { + _mesa_glsl_error(&loc, state, + "interpolation qualifiers cannot be used " + "with uniform interface blocks"); + } + if (field_type->is_matrix() || (field_type->is_array() && field_type->fields.array->is_matrix())) { fields[i].row_major = block_row_major; @@ -4244,12 +4130,12 @@ ast_struct_specifier::hir(exec_list *instructions, } ir_rvalue * -ast_uniform_block::hir(exec_list *instructions, - struct _mesa_glsl_parse_state *state) +ast_interface_block::hir(exec_list *instructions, + struct _mesa_glsl_parse_state *state) { YYLTYPE loc = this->get_location(); - /* The ast_uniform_block has a list of ast_declarator_lists. We + /* The ast_interface_block has a list of ast_declarator_lists. We * need to turn those into ir_variables with an association * with this uniform block. */ @@ -4276,16 +4162,32 @@ ast_uniform_block::hir(exec_list *instructions, true, block_row_major); + ir_variable_mode var_mode; + const char *iface_type_name; + if (this->layout.flags.q.in) { + var_mode = ir_var_shader_in; + iface_type_name = "in"; + } else if (this->layout.flags.q.out) { + var_mode = ir_var_shader_out; + iface_type_name = "out"; + } else if (this->layout.flags.q.uniform) { + var_mode = ir_var_uniform; + iface_type_name = "uniform"; + } else { + assert(!"interface block layout qualifier not found!"); + } + const glsl_type *block_type = glsl_type::get_interface_instance(fields, num_variables, packing, this->block_name); - if (!state->symbols->add_type(block_type->name, block_type)) { + if (!state->symbols->add_interface(block_type->name, block_type, var_mode)) { YYLTYPE loc = this->get_location(); - _mesa_glsl_error(&loc, state, "Uniform block name `%s' already taken in " - "the current scope.\n", this->block_name); + _mesa_glsl_error(&loc, state, "Interface block `%s' with type `%s' " + "already taken in the current scope.\n", + this->block_name, iface_type_name); } /* Since interface blocks cannot contain statements, it should be @@ -4309,11 +4211,11 @@ ast_uniform_block::hir(exec_list *instructions, var = new(state) ir_variable(block_array_type, this->instance_name, - ir_var_uniform); + var_mode); } else { var = new(state) ir_variable(block_type, this->instance_name, - ir_var_uniform); + var_mode); } var->interface_type = block_type; @@ -4329,7 +4231,7 @@ ast_uniform_block::hir(exec_list *instructions, ir_variable *var = new(state) ir_variable(fields[i].type, ralloc_strdup(state, fields[i].name), - ir_var_uniform); + var_mode); var->interface_type = block_type; state->symbols->add_variable(var); diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp index b0c7a2035..4bb361c2e 100644 --- a/mesalib/src/glsl/builtin_variables.cpp +++ b/mesalib/src/glsl/builtin_variables.cpp @@ -39,6 +39,12 @@ generate_ARB_draw_instanced_variables(exec_list *, struct _mesa_glsl_parse_state *, bool, _mesa_glsl_parser_targets); +static void +generate_AMD_vertex_shader_layer_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn, + _mesa_glsl_parser_targets target); + struct builtin_variable { enum ir_variable_mode mode; int slot; @@ -535,7 +541,7 @@ generate_common_ES_uniforms(exec_list *instructions, add_builtin_constant(instructions, symtab, "gl_MaxTextureImageUnits", state->Const.MaxTextureImageUnits); add_builtin_constant(instructions, symtab, "gl_MaxFragmentUniformVectors", - state->Const.MaxFragmentUniformComponents); + state->Const.MaxFragmentUniformComponents / 4); add_uniform(instructions, symtab, "gl_DepthRange", state->symbols->get_type("gl_DepthRangeParameters")); @@ -818,6 +824,8 @@ generate_130_vs_variables(exec_list *instructions, "gl_ClipDistance", clip_distance_array_type, ir_var_shader_out, VARYING_SLOT_CLIP_DIST0); + generate_AMD_vertex_shader_layer_variables(instructions, state, false, + vertex_shader); } @@ -1020,6 +1028,29 @@ generate_ARB_draw_instanced_variables(exec_list *instructions, } } +static void +generate_AMD_vertex_shader_layer_variables(exec_list *instructions, + struct _mesa_glsl_parse_state *state, + bool warn, + _mesa_glsl_parser_targets target) +{ + /* gl_Layer is only available in the vertex shader for the + * AMD_vertex_shader_layer extension. It will also be available in the + * geometry shader when GLSL 1.50 is supported. + */ + if (target != vertex_shader) + return; + + if (state->AMD_vertex_shader_layer_enable) { + ir_variable *inst = + add_variable(instructions, state->symbols, + "gl_Layer", glsl_type::int_type, + ir_var_shader_out, VARYING_SLOT_LAYER); + + if (warn) + inst->warn_extension = "GL_AMD_vertex_shader_layer"; + } +} static void generate_ARB_shader_stencil_export_variables(exec_list *instructions, diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y index 00edbbfbd..81ba04bcc 100644 --- a/mesalib/src/glsl/glcpp/glcpp-parse.y +++ b/mesalib/src/glsl/glcpp/glcpp-parse.y @@ -1236,6 +1236,12 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api) if (extensions->ARB_texture_query_lod) add_builtin_define(parser, "GL_ARB_texture_query_lod", 1); + + if (extensions->ARB_gpu_shader5) + add_builtin_define(parser, "GL_ARB_gpu_shader5", 1); + + if (extensions->AMD_vertex_shader_layer) + add_builtin_define(parser, "GL_AMD_vertex_shader_layer", 1); } } diff --git a/mesalib/src/glsl/glcpp/pp.c b/mesalib/src/glsl/glcpp/pp.c index 789f7f941..7e1b6c689 100644 --- a/mesalib/src/glsl/glcpp/pp.c +++ b/mesalib/src/glsl/glcpp/pp.c @@ -97,8 +97,10 @@ remove_line_continuations(glcpp_parser_t *ctx, const char *shader) { ralloc_strncat(&clean, shader, newline - shader + 1); - while (collapsed_newlines--) + while (collapsed_newlines) { ralloc_strcat(&clean, "\n"); + collapsed_newlines--; + } shader = newline + 1; search_start = shader; } diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy index f52ed9b0a..6e92c2651 100644 --- a/mesalib/src/glsl/glsl_parser.yy +++ b/mesalib/src/glsl/glsl_parser.yy @@ -79,7 +79,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) ast_case_label_list *case_label_list; ast_case_statement *case_statement; ast_case_statement_list *case_statement_list; - ast_uniform_block *uniform_block; + ast_interface_block *interface_block; struct { ast_node *cond; @@ -115,7 +115,7 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %token STRUCT VOID_TOK WHILE %token IDENTIFIER TYPE_IDENTIFIER NEW_IDENTIFIER %type any_identifier -%type instance_name_opt +%type instance_name_opt %token FLOATCONSTANT %token INTCONSTANT UINTCONSTANT BOOLCONSTANT %token FIELD_SELECTION @@ -164,7 +164,8 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %type interpolation_qualifier %type layout_qualifier %type layout_qualifier_id_list layout_qualifier_id -%type uniform_block_layout_qualifier +%type interface_block_layout_qualifier +%type interface_qualifier %type type_specifier %type type_specifier_no_prec %type type_specifier_nonarray @@ -223,8 +224,8 @@ static void yyerror(YYLTYPE *loc, _mesa_glsl_parse_state *st, const char *msg) %type declaration %type declaration_statement %type jump_statement -%type uniform_block -%type basic_uniform_block +%type interface_block +%type basic_interface_block %type struct_specifier %type struct_declaration_list %type struct_declaration @@ -784,7 +785,7 @@ declaration: $3->is_precision_statement = true; $$ = $3; } - | uniform_block + | interface_block { $$ = $1; } @@ -1140,7 +1141,7 @@ layout_qualifier_id: } } - /* See also uniform_block_layout_qualifier. */ + /* See also interface_block_layout_qualifier. */ if (!$$.flags.i && state->ARB_uniform_buffer_object_enable) { if (strcmp($1, "std140") == 0) { $$.flags.q.std140 = 1; @@ -1211,15 +1212,15 @@ layout_qualifier_id: "identifier `%s' used\n", $1); } } - | uniform_block_layout_qualifier + | interface_block_layout_qualifier { $$ = $1; /* Layout qualifiers for ARB_uniform_buffer_object. */ - if (!state->ARB_uniform_buffer_object_enable) { + if ($$.flags.q.uniform && !state->ARB_uniform_buffer_object_enable) { _mesa_glsl_error(& @1, state, "#version 140 / GL_ARB_uniform_buffer_object " "layout qualifier `%s' is used\n", $1); - } else if (state->ARB_uniform_buffer_object_warn) { + } else if ($$.flags.q.uniform && state->ARB_uniform_buffer_object_warn) { _mesa_glsl_warning(& @1, state, "#version 140 / GL_ARB_uniform_buffer_object " "layout qualifier `%s' is used\n", $1); @@ -1232,7 +1233,7 @@ layout_qualifier_id: * most qualifiers. See the any_identifier path of * layout_qualifier_id for the others. */ -uniform_block_layout_qualifier: +interface_block_layout_qualifier: ROW_MAJOR { memset(& $$, 0, sizeof($$)); @@ -1893,14 +1894,14 @@ function_definition: ; /* layout_qualifieropt is packed into this rule */ -uniform_block: - basic_uniform_block +interface_block: + basic_interface_block { $$ = $1; } - | layout_qualifier basic_uniform_block + | layout_qualifier basic_interface_block { - ast_uniform_block *block = $2; + ast_interface_block *block = $2; if (!block->layout.merge_qualifier(& @1, state, $1)) { YYERROR; } @@ -1908,55 +1909,137 @@ uniform_block: } ; -basic_uniform_block: - UNIFORM NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';' +basic_interface_block: + interface_qualifier NEW_IDENTIFIER '{' member_list '}' instance_name_opt ';' { - ast_uniform_block *const block = $6; + ast_interface_block *const block = $6; block->block_name = $2; block->declarations.push_degenerate_list_at_head(& $4->link); - if (!state->ARB_uniform_buffer_object_enable) { + if ($1.flags.q.uniform) { + if (!state->ARB_uniform_buffer_object_enable) { + _mesa_glsl_error(& @1, state, + "#version 140 / GL_ARB_uniform_buffer_object " + "required for defining uniform blocks\n"); + } else if (state->ARB_uniform_buffer_object_warn) { + _mesa_glsl_warning(& @1, state, + "#version 140 / GL_ARB_uniform_buffer_object " + "required for defining uniform blocks\n"); + } + } else { + if (state->es_shader || state->language_version < 150) { + _mesa_glsl_error(& @1, state, + "#version 150 required for using " + "interface blocks.\n"); + } + } + + /* From the GLSL 1.50.11 spec, section 4.3.7 ("Interface Blocks"): + * "It is illegal to have an input block in a vertex shader + * or an output block in a fragment shader" + */ + if ((state->target == vertex_shader) && $1.flags.q.in) { _mesa_glsl_error(& @1, state, - "#version 140 / GL_ARB_uniform_buffer_object " - "required for defining uniform blocks\n"); - } else if (state->ARB_uniform_buffer_object_warn) { - _mesa_glsl_warning(& @1, state, - "#version 140 / GL_ARB_uniform_buffer_object " - "required for defining uniform blocks\n"); + "`in' interface block is not allowed for " + "a vertex shader\n"); + } else if ((state->target == fragment_shader) && $1.flags.q.out) { + _mesa_glsl_error(& @1, state, + "`out' interface block is not allowed for " + "a fragment shader\n"); } /* Since block arrays require names, and both features are added in * the same language versions, we don't have to explicitly * version-check both things. */ - if (block->instance_name != NULL - && !(state->language_version == 300 && state->es_shader)) { - _mesa_glsl_error(& @1, state, - "#version 300 es required for using uniform " - "blocks with an instance name\n"); + if (block->instance_name != NULL) { + state->check_version(150, 300, & @1, "interface blocks with " + "an instance name are not allowed"); + } + + unsigned interface_type_mask; + struct ast_type_qualifier temp_type_qualifier; + + /* Get a bitmask containing only the in/out/uniform flags, allowing us + * to ignore other irrelevant flags like interpolation qualifiers. + */ + temp_type_qualifier.flags.i = 0; + temp_type_qualifier.flags.q.uniform = true; + temp_type_qualifier.flags.q.in = true; + temp_type_qualifier.flags.q.out = true; + interface_type_mask = temp_type_qualifier.flags.i; + + /* Get the block's interface qualifier. The interface_qualifier + * production rule guarantees that only one bit will be set (and + * it will be in/out/uniform). + */ + unsigned block_interface_qualifier = $1.flags.i; + + block->layout.flags.i |= block_interface_qualifier; + + foreach_list_typed (ast_declarator_list, member, link, &block->declarations) { + ast_type_qualifier& qualifier = member->type->qualifier; + if ((qualifier.flags.i & interface_type_mask) == 0) { + /* GLSLangSpec.1.50.11, 4.3.7 (Interface Blocks): + * "If no optional qualifier is used in a member declaration, the + * qualifier of the variable is just in, out, or uniform as declared + * by interface-qualifier." + */ + qualifier.flags.i |= block_interface_qualifier; + } else if ((qualifier.flags.i & interface_type_mask) != + block_interface_qualifier) { + /* GLSLangSpec.1.50.11, 4.3.7 (Interface Blocks): + * "If optional qualifiers are used, they can include interpolation + * and storage qualifiers and they must declare an input, output, + * or uniform variable consistent with the interface qualifier of + * the block." + */ + _mesa_glsl_error(& @1, state, + "uniform/in/out qualifier on " + "interface block member does not match " + "the interface block\n"); + } } $$ = block; } ; +interface_qualifier: + IN_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.in = 1; + } + | OUT_TOK + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.out = 1; + } + | UNIFORM + { + memset(& $$, 0, sizeof($$)); + $$.flags.q.uniform = 1; + } + ; + instance_name_opt: /* empty */ { - $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier, + $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, NULL, NULL); } | NEW_IDENTIFIER { - $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier, + $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, $1, NULL); } | NEW_IDENTIFIER '[' constant_expression ']' { - $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier, + $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, $1, $3); } @@ -1965,7 +2048,7 @@ instance_name_opt: _mesa_glsl_error(& @1, state, "instance block arrays must be explicitly sized\n"); - $$ = new(state) ast_uniform_block(*state->default_uniform_qualifier, + $$ = new(state) ast_interface_block(*state->default_uniform_qualifier, $1, NULL); } @@ -1984,41 +2067,28 @@ member_list: } ; -/* Specifying "uniform" inside of a uniform block is redundant. */ -uniformopt: - /* nothing */ - | UNIFORM - ; - member_declaration: - layout_qualifier uniformopt type_specifier struct_declarator_list ';' + fully_specified_type struct_declarator_list ';' { void *ctx = state; - ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); + ast_fully_specified_type *type = $1; type->set_location(yylloc); - type->qualifier = $1; - type->qualifier.flags.q.uniform = true; - type->specifier = $3; - $$ = new(ctx) ast_declarator_list(type); - $$->set_location(yylloc); - $$->ubo_qualifiers_valid = true; - - $$->declarations.push_degenerate_list_at_head(& $4->link); - } - | uniformopt type_specifier struct_declarator_list ';' - { - void *ctx = state; - ast_fully_specified_type *type = new(ctx) ast_fully_specified_type(); - type->set_location(yylloc); + if (type->qualifier.flags.q.attribute) { + _mesa_glsl_error(& @1, state, + "keyword 'attribute' cannot be used with " + "interface block member\n"); + } else if (type->qualifier.flags.q.varying) { + _mesa_glsl_error(& @1, state, + "keyword 'varying' cannot be used with " + "interface block member\n"); + } - type->qualifier.flags.q.uniform = true; - type->specifier = $2; $$ = new(ctx) ast_declarator_list(type); $$->set_location(yylloc); $$->ubo_qualifiers_valid = true; - $$->declarations.push_degenerate_list_at_head(& $3->link); + $$->declarations.push_degenerate_list_at_head(& $2->link); } ; diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp index 099229410..c0dd71370 100644 --- a/mesalib/src/glsl/glsl_parser_extras.cpp +++ b/mesalib/src/glsl/glsl_parser_extras.cpp @@ -93,9 +93,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx, this->Const.MaxVertexAttribs = ctx->Const.VertexProgram.MaxAttribs; this->Const.MaxVertexUniformComponents = ctx->Const.VertexProgram.MaxUniformComponents; this->Const.MaxVaryingFloats = ctx->Const.MaxVarying * 4; - this->Const.MaxVertexTextureImageUnits = ctx->Const.MaxVertexTextureImageUnits; + this->Const.MaxVertexTextureImageUnits = ctx->Const.VertexProgram.MaxTextureImageUnits; this->Const.MaxCombinedTextureImageUnits = ctx->Const.MaxCombinedTextureImageUnits; - this->Const.MaxTextureImageUnits = ctx->Const.MaxTextureImageUnits; + this->Const.MaxTextureImageUnits = ctx->Const.FragmentProgram.MaxTextureImageUnits; this->Const.MaxFragmentUniformComponents = ctx->Const.FragmentProgram.MaxUniformComponents; this->Const.MinProgramTexelOffset = ctx->Const.MinProgramTexelOffset; this->Const.MaxProgramTexelOffset = ctx->Const.MaxProgramTexelOffset; @@ -468,6 +468,8 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = { EXT(ARB_shading_language_packing, true, false, true, true, false, ARB_shading_language_packing), EXT(ARB_texture_multisample, true, false, true, true, false, ARB_texture_multisample), EXT(ARB_texture_query_lod, false, false, true, true, false, ARB_texture_query_lod), + EXT(ARB_gpu_shader5, true, true, true, true, false, ARB_gpu_shader5), + EXT(AMD_vertex_shader_layer, true, false, false, true, false, AMD_vertex_shader_layer), }; #undef EXT @@ -1202,11 +1204,13 @@ ast_struct_specifier::ast_struct_specifier(const char *identifier, * \param max_unroll_iterations Maximum number of loop iterations to be * unrolled. Setting to 0 disables loop * unrolling. + * \param options The driver's preferred shader options. */ bool do_common_optimization(exec_list *ir, bool linked, bool uniform_locations_assigned, - unsigned max_unroll_iterations) + unsigned max_unroll_iterations, + const struct gl_shader_compiler_options *options) { GLboolean progress = GL_FALSE; @@ -1221,6 +1225,10 @@ do_common_optimization(exec_list *ir, bool linked, progress = opt_flatten_nested_if_blocks(ir) || progress; progress = do_copy_propagation(ir) || progress; progress = do_copy_propagation_elements(ir) || progress; + + if (options->PreferDP4 && !linked) + progress = opt_flip_matrices(ir) || progress; + if (linked) progress = do_dead_code(ir, uniform_locations_assigned) || progress; else @@ -1236,6 +1244,7 @@ do_common_optimization(exec_list *ir, bool linked, progress = do_algebraic(ir) || progress; progress = do_lower_jumps(ir) || progress; progress = do_vec_index_to_swizzle(ir) || progress; + progress = lower_vector_insert(ir, false) || progress; progress = do_swizzle_swizzle(ir) || progress; progress = do_noop_swizzle(ir) || progress; diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h index 95891b595..16e180d3e 100644 --- a/mesalib/src/glsl/glsl_parser_extras.h +++ b/mesalib/src/glsl/glsl_parser_extras.h @@ -284,6 +284,10 @@ struct _mesa_glsl_parse_state { bool ARB_texture_multisample_warn; bool ARB_texture_query_lod_enable; bool ARB_texture_query_lod_warn; + bool ARB_gpu_shader5_enable; + bool ARB_gpu_shader5_warn; + bool AMD_vertex_shader_layer_enable; + bool AMD_vertex_shader_layer_warn; /*@}*/ /** Extensions supported by the OpenGL implementation. */ diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp index 8d34547c6..50bf11302 100644 --- a/mesalib/src/glsl/glsl_symbol_table.cpp +++ b/mesalib/src/glsl/glsl_symbol_table.cpp @@ -41,13 +41,67 @@ public: ralloc_free(entry); } - symbol_table_entry(ir_variable *v) : v(v), f(0), t(0) {} - symbol_table_entry(ir_function *f) : v(0), f(f), t(0) {} - symbol_table_entry(const glsl_type *t) : v(0), f(0), t(t) {} + bool add_interface(const glsl_type *i, enum ir_variable_mode mode) + { + const glsl_type **dest; + + switch (mode) { + case ir_var_uniform: + dest = &ibu; + break; + case ir_var_shader_in: + dest = &ibi; + break; + case ir_var_shader_out: + dest = &ibo; + break; + default: + assert(!"Unsupported interface variable mode!"); + return false; + } + + if (*dest != NULL) { + return false; + } else { + *dest = i; + return true; + } + } + + const glsl_type *get_interface(enum ir_variable_mode mode) + { + switch (mode) { + case ir_var_uniform: + return ibu; + case ir_var_shader_in: + return ibi; + case ir_var_shader_out: + return ibo; + default: + assert(!"Unsupported interface variable mode!"); + return NULL; + } + } + + symbol_table_entry(ir_variable *v) : + v(v), f(0), t(0), ibu(0), ibi(0), ibo(0) {} + symbol_table_entry(ir_function *f) : + v(0), f(f), t(0), ibu(0), ibi(0), ibo(0) {} + symbol_table_entry(const glsl_type *t) : + v(0), f(0), t(t), ibu(0), ibi(0), ibo(0) {} + symbol_table_entry(const glsl_type *t, enum ir_variable_mode mode) : + v(0), f(0), t(0), ibu(0), ibi(0), ibo(0) + { + assert(t->is_interface()); + add_interface(t, mode); + } ir_variable *v; ir_function *f; const glsl_type *t; + const glsl_type *ibu; + const glsl_type *ibi; + const glsl_type *ibo; }; glsl_symbol_table::glsl_symbol_table() @@ -118,6 +172,23 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t) return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0; } +bool glsl_symbol_table::add_interface(const char *name, const glsl_type *i, + enum ir_variable_mode mode) +{ + assert(i->is_interface()); + symbol_table_entry *entry = get_entry(name); + if (entry == NULL) { + symbol_table_entry *entry = + new(mem_ctx) symbol_table_entry(i, mode); + bool add_interface_symbol_result = + _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0; + assert(add_interface_symbol_result); + return add_interface_symbol_result; + } else { + return entry->add_interface(i, mode); + } +} + bool glsl_symbol_table::add_function(ir_function *f) { if (this->separate_function_namespace && name_declared_this_scope(f->name)) { @@ -152,6 +223,13 @@ const glsl_type *glsl_symbol_table::get_type(const char *name) return entry != NULL ? entry->t : NULL; } +const glsl_type *glsl_symbol_table::get_interface(const char *name, + enum ir_variable_mode mode) +{ + symbol_table_entry *entry = get_entry(name); + return entry != NULL ? entry->get_interface(mode) : NULL; +} + ir_function *glsl_symbol_table::get_function(const char *name) { symbol_table_entry *entry = get_entry(name); diff --git a/mesalib/src/glsl/glsl_symbol_table.h b/mesalib/src/glsl/glsl_symbol_table.h index 9f5602787..2753bdf31 100644 --- a/mesalib/src/glsl/glsl_symbol_table.h +++ b/mesalib/src/glsl/glsl_symbol_table.h @@ -99,6 +99,8 @@ public: bool add_variable(ir_variable *v); bool add_type(const char *name, const glsl_type *t); bool add_function(ir_function *f); + bool add_interface(const char *name, const glsl_type *i, + enum ir_variable_mode mode); /*@}*/ /** @@ -113,6 +115,8 @@ public: ir_variable *get_variable(const char *name); const glsl_type *get_type(const char *name); ir_function *get_function(const char *name); + const glsl_type *get_interface(const char *name, + enum ir_variable_mode mode); /*@}*/ private: diff --git a/mesalib/src/glsl/glsl_types.cpp b/mesalib/src/glsl/glsl_types.cpp index 419761a7d..df9c5d36f 100644 --- a/mesalib/src/glsl/glsl_types.cpp +++ b/mesalib/src/glsl/glsl_types.cpp @@ -57,6 +57,7 @@ glsl_type::glsl_type(GLenum gl_type, length(0) { init_ralloc_type_ctx(); + assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); /* Neither dimension is zero or both dimensions are zero. */ @@ -75,6 +76,7 @@ glsl_type::glsl_type(GLenum gl_type, length(0) { init_ralloc_type_ctx(); + assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); memset(& fields, 0, sizeof(fields)); } @@ -91,6 +93,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, unsigned int i; init_ralloc_type_ctx(); + assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); this->fields.structure = ralloc_array(this->mem_ctx, glsl_struct_field, length); @@ -114,6 +117,7 @@ glsl_type::glsl_type(const glsl_struct_field *fields, unsigned num_fields, unsigned int i; init_ralloc_type_ctx(); + assert(name != NULL); this->name = ralloc_strdup(this->mem_ctx, name); this->fields.structure = ralloc_array(this->mem_ctx, glsl_struct_field, length); diff --git a/mesalib/src/glsl/glsl_types.h b/mesalib/src/glsl/glsl_types.h index 2f3b19f51..31e3dd253 100644 --- a/mesalib/src/glsl/glsl_types.h +++ b/mesalib/src/glsl/glsl_types.h @@ -132,8 +132,7 @@ struct glsl_type { /** * Name of the data type * - * This may be \c NULL for anonymous structures, for arrays, or for - * function types. + * Will never be \c NULL. */ const char *name; diff --git a/mesalib/src/glsl/ir.cpp b/mesalib/src/glsl/ir.cpp index 05b77da2c..dad58deeb 100644 --- a/mesalib/src/glsl/ir.cpp +++ b/mesalib/src/glsl/ir.cpp @@ -399,6 +399,10 @@ ir_expression::ir_expression(int op, ir_rvalue *op0, ir_rvalue *op1) this->type = op0->type; break; + case ir_binop_vector_extract: + this->type = op0->type->get_scalar_type(); + break; + default: assert(!"not reached: missing automatic type setup for ir_expression"); this->type = glsl_type::float_type; @@ -419,7 +423,7 @@ ir_expression::get_num_operands(ir_expression_operation op) if (op <= ir_last_triop) return 3; - if (op == ir_quadop_vector) + if (op <= ir_last_quadop) return 4; assert(false); @@ -477,6 +481,10 @@ static const char *const operator_strs[] = { "unpackHalf2x16", "unpackHalf2x16_split_x", "unpackHalf2x16_split_y", + "bitfield_reverse", + "bit_count", + "find_msb", + "find_lsb", "noise", "+", "-", @@ -504,8 +512,14 @@ static const char *const operator_strs[] = { "max", "pow", "packHalf2x16_split", + "bfm", "ubo_load", + "vector_extract", "lrp", + "bfi", + "bitfield_extract", + "vector_insert", + "bitfield_insert", "vector", }; diff --git a/mesalib/src/glsl/ir.h b/mesalib/src/glsl/ir.h index 0c3e39979..6d4150136 100644 --- a/mesalib/src/glsl/ir.h +++ b/mesalib/src/glsl/ir.h @@ -131,6 +131,7 @@ public: virtual class ir_swizzle * as_swizzle() { return NULL; } virtual class ir_constant * as_constant() { return NULL; } virtual class ir_discard * as_discard() { return NULL; } + virtual class ir_jump * as_jump() { return NULL; } /*@}*/ protected: @@ -273,7 +274,8 @@ enum ir_variable_mode { ir_var_function_inout, ir_var_const_in, /**< "in" param that must be a constant expression */ ir_var_system_value, /**< Ex: front-face, instance-id, etc. */ - ir_var_temporary /**< Temporary variable generated during compilation. */ + ir_var_temporary, /**< Temporary variable generated during compilation. */ + ir_var_mode_count /**< Number of variable modes */ }; /** @@ -1031,6 +1033,16 @@ enum ir_expression_operation { ir_unop_unpack_half_2x16_split_y, /*@}*/ + /** + * \name Bit operations, part of ARB_gpu_shader5. + */ + /*@{*/ + ir_unop_bitfield_reverse, + ir_unop_bit_count, + ir_unop_find_msb, + ir_unop_find_lsb, + /*@}*/ + ir_unop_noise, /** @@ -1106,6 +1118,15 @@ enum ir_expression_operation { ir_binop_pack_half_2x16_split, /*@}*/ + /** + * \name First half of a lowered bitfieldInsert() operation. + * + * \see lower_instructions::bitfield_insert_to_bfm_bfi + */ + /*@{*/ + ir_binop_bfm, + /*@}*/ + /** * Load a value the size of a given GLSL type from a uniform block. * @@ -1114,20 +1135,55 @@ enum ir_expression_operation { */ ir_binop_ubo_load, + /** + * Extract a scalar from a vector + * + * operand0 is the vector + * operand1 is the index of the field to read from operand0 + */ + ir_binop_vector_extract, + /** * A sentinel marking the last of the binary operations. */ - ir_last_binop = ir_binop_ubo_load, + ir_last_binop = ir_binop_vector_extract, ir_triop_lrp, + /** + * \name Second half of a lowered bitfieldInsert() operation. + * + * \see lower_instructions::bitfield_insert_to_bfm_bfi + */ + /*@{*/ + ir_triop_bfi, + /*@}*/ + + ir_triop_bitfield_extract, + + /** + * Generate a value with one field of a vector changed + * + * operand0 is the vector + * operand1 is the value to write into the vector result + * operand2 is the index in operand0 to be modified + */ + ir_triop_vector_insert, + /** * A sentinel marking the last of the ternary operations. */ - ir_last_triop = ir_triop_lrp, + ir_last_triop = ir_triop_vector_insert, + + ir_quadop_bitfield_insert, ir_quadop_vector, + /** + * A sentinel marking the last of the ternary operations. + */ + ir_last_quadop = ir_quadop_vector, + /** * A sentinel marking the last of all operations. */ @@ -1297,6 +1353,12 @@ protected: { ir_type = ir_type_unset; } + +public: + virtual ir_jump *as_jump() + { + return this; + } }; class ir_return : public ir_jump { diff --git a/mesalib/src/glsl/ir_basic_block.cpp b/mesalib/src/glsl/ir_basic_block.cpp index 86e0cf795..2cbc682d4 100644 --- a/mesalib/src/glsl/ir_basic_block.cpp +++ b/mesalib/src/glsl/ir_basic_block.cpp @@ -77,7 +77,7 @@ void call_for_basic_blocks(exec_list *instructions, callback(leader, ir, data); leader = NULL; call_for_basic_blocks(&ir_loop->body_instructions, callback, data); - } else if (ir->as_return() || ir->as_call()) { + } else if (ir->as_jump() || ir->as_call()) { callback(leader, ir, data); leader = NULL; } else if ((ir_function = ir->as_function())) { diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp index c09e56a3d..0a725b45b 100644 --- a/mesalib/src/glsl/ir_constant_expression.cpp +++ b/mesalib/src/glsl/ir_constant_expression.cpp @@ -391,9 +391,17 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) } if (op[1] != NULL) - assert(op[0]->type->base_type == op[1]->type->base_type || - this->operation == ir_binop_lshift || - this->operation == ir_binop_rshift); + switch (this->operation) { + case ir_binop_lshift: + case ir_binop_rshift: + case ir_binop_vector_extract: + case ir_triop_bitfield_extract: + break; + + default: + assert(op[0]->type->base_type == op[1]->type->base_type); + break; + } bool op0_scalar = op[0]->type->is_scalar(); bool op1_scalar = op[1] != NULL && op[1]->type->is_scalar(); @@ -1230,6 +1238,29 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) } break; + case ir_binop_vector_extract: { + const int c = CLAMP(op[1]->value.i[0], 0, + (int) op[0]->type->vector_elements - 1); + + switch (op[0]->type->base_type) { + case GLSL_TYPE_UINT: + data.u[0] = op[0]->value.u[c]; + break; + case GLSL_TYPE_INT: + data.i[0] = op[0]->value.i[c]; + break; + case GLSL_TYPE_FLOAT: + data.f[0] = op[0]->value.f[c]; + break; + case GLSL_TYPE_BOOL: + data.b[0] = op[0]->value.b[c]; + break; + default: + assert(0); + } + break; + } + case ir_binop_bit_xor: for (unsigned c = 0, c0 = 0, c1 = 0; c < components; @@ -1248,6 +1279,102 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) } break; + case ir_unop_bitfield_reverse: + /* http://graphics.stanford.edu/~seander/bithacks.html#BitReverseObvious */ + for (unsigned c = 0; c < components; c++) { + unsigned int v = op[0]->value.u[c]; // input bits to be reversed + unsigned int r = v; // r will be reversed bits of v; first get LSB of v + int s = sizeof(v) * CHAR_BIT - 1; // extra shift needed at end + + for (v >>= 1; v; v >>= 1) { + r <<= 1; + r |= v & 1; + s--; + } + r <<= s; // shift when v's highest bits are zero + + data.u[c] = r; + } + break; + + case ir_unop_bit_count: + for (unsigned c = 0; c < components; c++) { + unsigned count = 0; + unsigned v = op[0]->value.u[c]; + + for (; v; count++) { + v &= v - 1; + } + data.u[c] = count; + } + break; + + case ir_unop_find_msb: + for (unsigned c = 0; c < components; c++) { + int v = op[0]->value.i[c]; + + if (v == 0 || (op[0]->type->base_type == GLSL_TYPE_INT && v == -1)) + data.i[c] = -1; + else { + int count = 0; + int top_bit = op[0]->type->base_type == GLSL_TYPE_UINT + ? 0 : v & (1 << 31); + + while (((v & (1 << 31)) == top_bit) && count != 32) { + count++; + v <<= 1; + } + + data.i[c] = 31 - count; + } + } + break; + + case ir_unop_find_lsb: + for (unsigned c = 0; c < components; c++) { + if (op[0]->value.i[c] == 0) + data.i[c] = -1; + else { + unsigned pos = 0; + unsigned v = op[0]->value.u[c]; + + for (; !(v & 1); v >>= 1) { + pos++; + } + data.u[c] = pos; + } + } + break; + + case ir_triop_bitfield_extract: { + int offset = op[1]->value.i[0]; + int bits = op[2]->value.i[0]; + + for (unsigned c = 0; c < components; c++) { + if (bits == 0) + data.u[c] = 0; + else if (offset < 0 || bits < 0) + data.u[c] = 0; /* Undefined, per spec. */ + else if (offset + bits > 32) + data.u[c] = 0; /* Undefined, per spec. */ + else { + if (op[0]->type->base_type == GLSL_TYPE_INT) { + /* int so that the right shift will sign-extend. */ + int value = op[0]->value.i[c]; + value <<= 32 - bits - offset; + value >>= 32 - bits; + data.i[c] = value; + } else { + unsigned value = op[0]->value.u[c]; + value <<= 32 - bits - offset; + value >>= 32 - bits; + data.u[c] = value; + } + } + } + break; + } + case ir_triop_lrp: { assert(op[0]->type->base_type == GLSL_TYPE_FLOAT); assert(op[1]->type->base_type == GLSL_TYPE_FLOAT); @@ -1261,6 +1388,58 @@ ir_expression::constant_expression_value(struct hash_table *variable_context) break; } + case ir_triop_vector_insert: { + const unsigned idx = op[2]->value.u[0]; + + memcpy(&data, &op[0]->value, sizeof(data)); + + switch (this->type->base_type) { + case GLSL_TYPE_INT: + data.i[idx] = op[1]->value.i[0]; + break; + case GLSL_TYPE_UINT: + data.u[idx] = op[1]->value.u[0]; + break; + case GLSL_TYPE_FLOAT: + data.f[idx] = op[1]->value.f[0]; + break; + case GLSL_TYPE_BOOL: + data.b[idx] = op[1]->value.b[0]; + break; + default: + assert(!"Should not get here."); + break; + } + break; + } + + case ir_quadop_bitfield_insert: { + int offset = op[2]->value.i[0]; + int bits = op[3]->value.i[0]; + + for (unsigned c = 0; c < components; c++) { + if (bits == 0) + data.u[c] = op[0]->value.u[c]; + else if (offset < 0 || bits < 0) + data.u[c] = 0; /* Undefined, per spec. */ + else if (offset + bits > 32) + data.u[c] = 0; /* Undefined, per spec. */ + else { + unsigned insert_mask = ((1 << bits) - 1) << offset; + + unsigned insert = op[1]->value.u[c]; + insert <<= offset; + insert &= insert_mask; + + unsigned base = op[0]->value.u[c]; + base &= ~insert_mask; + + data.u[c] = base | insert; + } + } + break; + } + case ir_quadop_vector: for (unsigned c = 0; c < this->type->vector_elements; c++) { switch (this->type->base_type) { diff --git a/mesalib/src/glsl/ir_optimization.h b/mesalib/src/glsl/ir_optimization.h index a8885d722..d38d5e303 100644 --- a/mesalib/src/glsl/ir_optimization.h +++ b/mesalib/src/glsl/ir_optimization.h @@ -37,6 +37,7 @@ #define MOD_TO_FRACT 0x20 #define INT_DIV_TO_MUL_RCP 0x40 #define LRP_TO_ARITH 0x80 +#define BITFIELD_INSERT_TO_BFM_BFI 0x100 /** * \see class lower_packing_builtins_visitor @@ -65,7 +66,8 @@ enum lower_packing_builtins_op { bool do_common_optimization(exec_list *ir, bool linked, bool uniform_locations_assigned, - unsigned max_unroll_iterations); + unsigned max_unroll_iterations, + const struct gl_shader_compiler_options *options); bool do_algebraic(exec_list *instructions); bool do_constant_folding(exec_list *instructions); @@ -78,6 +80,7 @@ bool do_dead_code(exec_list *instructions, bool uniform_locations_assigned); bool do_dead_code_local(exec_list *instructions); bool do_dead_code_unlinked(exec_list *instructions); bool do_dead_functions(exec_list *instructions); +bool opt_flip_matrices(exec_list *instructions); bool do_function_inlining(exec_list *instructions); bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_sub_return = true, bool lower_main_return = false, bool lower_continue = false, bool lower_break = false); bool do_lower_texture_projection(exec_list *instructions); @@ -106,6 +109,8 @@ void lower_ubo_reference(struct gl_shader *shader, exec_list *instructions); void lower_packed_varyings(void *mem_ctx, unsigned location_base, unsigned locations_used, ir_variable_mode mode, gl_shader *shader); +bool lower_vector_insert(exec_list *instructions, bool lower_nonconstant_index); +void lower_named_interface_blocks(void *mem_ctx, gl_shader *shader); bool optimize_redundant_jumps(exec_list *instructions); bool optimize_split_arrays(exec_list *instructions, bool linked); diff --git a/mesalib/src/glsl/ir_print_visitor.cpp b/mesalib/src/glsl/ir_print_visitor.cpp index 597d2813f..f01019c98 100644 --- a/mesalib/src/glsl/ir_print_visitor.cpp +++ b/mesalib/src/glsl/ir_print_visitor.cpp @@ -24,6 +24,7 @@ #include "ir_print_visitor.h" #include "glsl_types.h" #include "glsl_parser_extras.h" +#include "main/macros.h" #include "program/hash_table.h" static void print_type(const glsl_type *t); @@ -149,7 +150,9 @@ void ir_print_visitor::visit(ir_variable *ir) const char *const mode[] = { "", "uniform ", "shader_in ", "shader_out ", "in ", "out ", "inout ", "const_in ", "sys ", "temporary " }; - const char *const interp[] = { "", "flat", "noperspective" }; + STATIC_ASSERT(ARRAY_SIZE(mode) == ir_var_mode_count); + const char *const interp[] = { "", "smooth", "flat", "noperspective" }; + STATIC_ASSERT(ARRAY_SIZE(interp) == INTERP_QUALIFIER_COUNT); printf("(%s%s%s%s) ", cent, inv, mode[ir->mode], interp[ir->interpolation]); diff --git a/mesalib/src/glsl/ir_reader.cpp b/mesalib/src/glsl/ir_reader.cpp index 16fdc41b4..b3667124f 100644 --- a/mesalib/src/glsl/ir_reader.cpp +++ b/mesalib/src/glsl/ir_reader.cpp @@ -676,16 +676,18 @@ ir_reader::read_expression(s_expression *expr) { s_expression *s_type; s_symbol *s_op; - s_expression *s_arg[3]; + s_expression *s_arg[4] = {NULL}; s_pattern pat[] = { "expression", s_type, s_op, s_arg[0] }; if (!PARTIAL_MATCH(expr, pat)) { ir_read_error(expr, "expected (expression " - " [])"); + " [] [] [])"); return NULL; } s_arg[1] = (s_expression *) s_arg[0]->next; // may be tail sentinel s_arg[2] = (s_expression *) s_arg[1]->next; // may be tail sentinel or NULL + if (s_arg[2]) + s_arg[3] = (s_expression *) s_arg[2]->next; // may be tail sentinel or NULL const glsl_type *type = read_type(s_type); if (type == NULL) @@ -709,7 +711,7 @@ ir_reader::read_expression(s_expression *expr) return NULL; } - ir_rvalue *arg[3] = {NULL, NULL, NULL}; + ir_rvalue *arg[4] = {NULL}; for (int i = 0; i < num_operands; i++) { arg[i] = read_rvalue(s_arg[i]); if (arg[i] == NULL) { @@ -718,7 +720,7 @@ ir_reader::read_expression(s_expression *expr) } } - return new(mem_ctx) ir_expression(op, type, arg[0], arg[1], arg[2]); + return new(mem_ctx) ir_expression(op, type, arg[0], arg[1], arg[2], arg[3]); } ir_swizzle * diff --git a/mesalib/src/glsl/ir_uniform.h b/mesalib/src/glsl/ir_uniform.h index 30e6f260d..8198c4819 100644 --- a/mesalib/src/glsl/ir_uniform.h +++ b/mesalib/src/glsl/ir_uniform.h @@ -99,15 +99,24 @@ struct gl_uniform_storage { */ bool initialized; - /** - * Base sampler index - * - * If \c ::base_type is \c GLSL_TYPE_SAMPLER, this represents the index of - * this sampler. If \c ::array_elements is not zero, the array will use - * sampler indexes \c ::sampler through \c ::sampler + \c ::array_elements - * - 1, inclusive. - */ - uint8_t sampler; + struct { + /** + * Base sampler index + * + * If \c ::base_type is \c GLSL_TYPE_SAMPLER, this represents the index + * of this sampler. If \c ::array_elements is not zero, the array will + * use sampler indices \c ::sampler through \c ::sampler + + * \c ::array_elements - 1, inclusive. + * + * Note that the index may be different in each shader stage. + */ + uint8_t index; + + /** + * Whether this sampler is used in this shader stage. + */ + bool active; + } sampler[MESA_SHADER_TYPES]; /** * Storage used by the driver for the uniform diff --git a/mesalib/src/glsl/ir_validate.cpp b/mesalib/src/glsl/ir_validate.cpp index 699c192cd..ce96f6855 100644 --- a/mesalib/src/glsl/ir_validate.cpp +++ b/mesalib/src/glsl/ir_validate.cpp @@ -69,6 +69,8 @@ public: virtual ir_visitor_status visit_leave(ir_expression *ir); virtual ir_visitor_status visit_leave(ir_swizzle *ir); + virtual ir_visitor_status visit_enter(class ir_dereference_array *); + virtual ir_visitor_status visit_enter(ir_assignment *ir); virtual ir_visitor_status visit_enter(ir_call *ir); @@ -101,6 +103,33 @@ ir_validate::visit(ir_dereference_variable *ir) return visit_continue; } +ir_visitor_status +ir_validate::visit_enter(class ir_dereference_array *ir) +{ + if (!ir->array->type->is_array() && !ir->array->type->is_matrix()) { + printf("ir_dereference_array @ %p does not specify an array or a " + "matrix\n", + (void *) ir); + ir->print(); + printf("\n"); + abort(); + } + + if (!ir->array_index->type->is_scalar()) { + printf("ir_dereference_array @ %p does not have scalar index: %s\n", + (void *) ir, ir->array_index->type->name); + abort(); + } + + if (!ir->array_index->type->is_integer()) { + printf("ir_dereference_array @ %p does not have integer index: %s\n", + (void *) ir, ir->array_index->type->name); + abort(); + } + + return visit_continue; +} + ir_visitor_status ir_validate::visit_enter(ir_if *ir) { @@ -361,6 +390,19 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->operands[0]->type == glsl_type::uint_type); break; + case ir_unop_bitfield_reverse: + assert(ir->operands[0]->type == ir->type); + assert(ir->type->is_integer()); + break; + + case ir_unop_bit_count: + case ir_unop_find_msb: + case ir_unop_find_lsb: + assert(ir->operands[0]->type->vector_elements == ir->type->vector_elements); + assert(ir->operands[0]->type->is_integer()); + assert(ir->type->base_type == GLSL_TYPE_INT); + break; + case ir_unop_noise: /* XXX what can we assert here? */ break; @@ -461,6 +503,12 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->operands[1]->type == glsl_type::float_type); break; + case ir_binop_bfm: + assert(ir->type->is_integer()); + assert(ir->operands[0]->type->is_integer()); + assert(ir->operands[1]->type->is_integer()); + break; + case ir_binop_ubo_load: assert(ir->operands[0]->as_constant()); assert(ir->operands[0]->type == glsl_type::uint_type); @@ -468,12 +516,46 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->operands[1]->type == glsl_type::uint_type); break; + case ir_binop_vector_extract: + assert(ir->operands[0]->type->is_vector()); + assert(ir->operands[1]->type->is_scalar() + && ir->operands[1]->type->is_integer()); + break; + case ir_triop_lrp: assert(ir->operands[0]->type->base_type == GLSL_TYPE_FLOAT); assert(ir->operands[0]->type == ir->operands[1]->type); assert(ir->operands[2]->type == ir->operands[0]->type || ir->operands[2]->type == glsl_type::float_type); break; + case ir_triop_bfi: + assert(ir->operands[0]->type->is_integer()); + assert(ir->operands[1]->type == ir->operands[2]->type); + assert(ir->operands[1]->type == ir->type); + break; + + case ir_triop_bitfield_extract: + assert(ir->operands[0]->type == ir->type); + assert(ir->operands[1]->type == glsl_type::int_type); + assert(ir->operands[2]->type == glsl_type::int_type); + break; + + case ir_triop_vector_insert: + assert(ir->operands[0]->type->is_vector()); + assert(ir->operands[1]->type->is_scalar()); + assert(ir->operands[0]->type->base_type == ir->operands[1]->type->base_type); + assert(ir->operands[2]->type->is_scalar() + && ir->operands[2]->type->is_integer()); + assert(ir->type == ir->operands[0]->type); + break; + + case ir_quadop_bitfield_insert: + assert(ir->operands[0]->type == ir->type); + assert(ir->operands[1]->type == ir->type); + assert(ir->operands[2]->type == glsl_type::int_type); + assert(ir->operands[3]->type == glsl_type::int_type); + break; + case ir_quadop_vector: /* The vector operator collects some number of scalars and generates a * vector from them. diff --git a/mesalib/src/glsl/link_interface_blocks.cpp b/mesalib/src/glsl/link_interface_blocks.cpp new file mode 100644 index 000000000..b91860d03 --- /dev/null +++ b/mesalib/src/glsl/link_interface_blocks.cpp @@ -0,0 +1,110 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file link_interface_blocks.cpp + * Linker support for GLSL's interface blocks. + */ + +#include "ir.h" +#include "glsl_symbol_table.h" +#include "linker.h" +#include "main/macros.h" + +bool +validate_intrastage_interface_blocks(const gl_shader **shader_list, + unsigned num_shaders) +{ + glsl_symbol_table interfaces; + + for (unsigned int i = 0; i < num_shaders; i++) { + if (shader_list[i] == NULL) + continue; + + foreach_list(node, shader_list[i]->ir) { + ir_variable *var = ((ir_instruction *) node)->as_variable(); + if (!var) + continue; + + const glsl_type *iface_type = var->interface_type; + + if (iface_type == NULL) + continue; + + const glsl_type *old_iface_type = + interfaces.get_interface(iface_type->name, + (enum ir_variable_mode) var->mode); + + if (old_iface_type == NULL) { + /* This is the first time we've seen the interface, so save + * it into our symbol table. + */ + interfaces.add_interface(iface_type->name, iface_type, + (enum ir_variable_mode) var->mode); + } else if (old_iface_type != iface_type) { + return false; + } + } + } + + return true; +} + +bool +validate_interstage_interface_blocks(const gl_shader *producer, + const gl_shader *consumer) +{ + glsl_symbol_table interfaces; + + /* Add non-output interfaces from the consumer to the symbol table. */ + foreach_list(node, consumer->ir) { + ir_variable *var = ((ir_instruction *) node)->as_variable(); + if (!var || !var->interface_type || var->mode == ir_var_shader_out) + continue; + + interfaces.add_interface(var->interface_type->name, + var->interface_type, + (enum ir_variable_mode) var->mode); + } + + /* Verify that the producer's interfaces match. */ + foreach_list(node, producer->ir) { + ir_variable *var = ((ir_instruction *) node)->as_variable(); + if (!var || !var->interface_type || var->mode == ir_var_shader_in) + continue; + + enum ir_variable_mode consumer_mode = + var->mode == ir_var_uniform ? ir_var_uniform : ir_var_shader_in; + const glsl_type *expected_type = + interfaces.get_interface(var->interface_type->name, consumer_mode); + + /* The consumer doesn't use this output block. Ignore it. */ + if (expected_type == NULL) + continue; + + if (var->interface_type != expected_type) + return false; + } + + return true; +} diff --git a/mesalib/src/glsl/link_uniform_initializers.cpp b/mesalib/src/glsl/link_uniform_initializers.cpp index 836a360fa..54d9bf1f5 100644 --- a/mesalib/src/glsl/link_uniform_initializers.cpp +++ b/mesalib/src/glsl/link_uniform_initializers.cpp @@ -138,8 +138,16 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog, } if (base_type == GLSL_TYPE_SAMPLER) { - for (unsigned int i = 0; i < storage->array_elements; i++) { - prog->SamplerUnits[storage->sampler + i] = storage->storage[i].i; + for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + gl_shader *shader = prog->_LinkedShaders[sh]; + + if (shader && storage->sampler[sh].active) { + for (unsigned i = 0; i < storage->array_elements; i++) { + unsigned index = storage->sampler[sh].index + i; + + shader->SamplerUnits[index] = storage->storage[i].i; + } + } } } } else { @@ -148,8 +156,17 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog, val->type->base_type, val->type->components()); - if (storage->type->is_sampler()) - prog->SamplerUnits[storage->sampler] = storage->storage[0].i; + if (storage->type->is_sampler()) { + for (int sh = 0; sh < MESA_SHADER_TYPES; sh++) { + gl_shader *shader = prog->_LinkedShaders[sh]; + + if (shader && storage->sampler[sh].active) { + unsigned index = storage->sampler[sh].index; + + shader->SamplerUnits[index] = storage->storage[0].i; + } + } + } } storage->initialized = true; diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp index d457e4d0c..ad636681f 100644 --- a/mesalib/src/glsl/link_uniforms.cpp +++ b/mesalib/src/glsl/link_uniforms.cpp @@ -263,15 +263,19 @@ public: parcel_out_uniform_storage(struct string_to_uint_map *map, struct gl_uniform_storage *uniforms, union gl_constant_value *values) - : map(map), uniforms(uniforms), next_sampler(0), values(values) + : map(map), uniforms(uniforms), values(values) { - memset(this->targets, 0, sizeof(this->targets)); } - void start_shader() + void start_shader(gl_shader_type shader_type) { + assert(shader_type < MESA_SHADER_TYPES); + this->shader_type = shader_type; + this->shader_samplers_used = 0; this->shader_shadow_samplers = 0; + this->next_sampler = 0; + memset(this->targets, 0, sizeof(this->targets)); } void set_and_process(struct gl_shader_program *prog, @@ -335,8 +339,37 @@ public: int ubo_block_index; int ubo_byte_offset; bool ubo_row_major; + gl_shader_type shader_type; private: + void handle_samplers(const glsl_type *base_type, + struct gl_uniform_storage *uniform) + { + if (base_type->is_sampler()) { + uniform->sampler[shader_type].index = this->next_sampler; + uniform->sampler[shader_type].active = true; + + /* Increment the sampler by 1 for non-arrays and by the number of + * array elements for arrays. + */ + this->next_sampler += + MAX2(1, uniform->array_elements); + + const gl_texture_index target = base_type->sampler_index(); + const unsigned shadow = base_type->sampler_shadow; + for (unsigned i = uniform->sampler[shader_type].index; + i < MIN2(this->next_sampler, MAX_SAMPLERS); + i++) { + this->targets[i] = target; + this->shader_samplers_used |= 1U << i; + this->shader_shadow_samplers |= shadow << i; + } + } else { + uniform->sampler[shader_type].index = ~0; + uniform->sampler[shader_type].active = false; + } + } + virtual void visit_field(const glsl_type *type, const char *name, bool row_major) { @@ -354,31 +387,6 @@ private: if (!found) return; - /* If there is already storage associated with this uniform, it means - * that it was set while processing an earlier shader stage. For - * example, we may be processing the uniform in the fragment shader, but - * the uniform was already processed in the vertex shader. - */ - if (this->uniforms[id].storage != NULL) { - /* If the uniform already has storage set from another shader stage, - * mark the samplers used for this shader stage. - */ - if (type->contains_sampler()) { - const unsigned count = MAX2(1, this->uniforms[id].array_elements); - const unsigned shadow = (type->is_array()) - ? type->fields.array->sampler_shadow : type->sampler_shadow; - - for (unsigned i = 0; i < count; i++) { - const unsigned s = this->uniforms[id].sampler + i; - - this->shader_samplers_used |= 1U << s; - this->shader_shadow_samplers |= shadow << s; - } - } - - return; - } - const glsl_type *base_type; if (type->is_array()) { this->uniforms[id].array_elements = type->length; @@ -388,26 +396,16 @@ private: base_type = type; } - if (base_type->is_sampler()) { - this->uniforms[id].sampler = this->next_sampler; + /* This assigns sampler uniforms to sampler units. */ + handle_samplers(base_type, &this->uniforms[id]); - /* Increment the sampler by 1 for non-arrays and by the number of - * array elements for arrays. - */ - this->next_sampler += MAX2(1, this->uniforms[id].array_elements); - - const gl_texture_index target = base_type->sampler_index(); - const unsigned shadow = base_type->sampler_shadow; - for (unsigned i = this->uniforms[id].sampler - ; i < MIN2(this->next_sampler, MAX_SAMPLERS) - ; i++) { - this->targets[i] = target; - this->shader_samplers_used |= 1U << i; - this->shader_shadow_samplers |= shadow << i; - } - - } else { - this->uniforms[id].sampler = ~0; + /* If there is already storage associated with this uniform, it means + * that it was set while processing an earlier shader stage. For + * example, we may be processing the uniform in the fragment shader, but + * the uniform was already processed in the vertex shader. + */ + if (this->uniforms[id].storage != NULL) { + return; } this->uniforms[id].name = ralloc_strdup(this->uniforms, name); @@ -633,17 +631,6 @@ link_assign_uniform_locations(struct gl_shader_program *prog) prog->UniformHash = new string_to_uint_map; } - /* Uniforms that lack an initializer in the shader code have an initial - * value of zero. This includes sampler uniforms. - * - * Page 24 (page 30 of the PDF) of the GLSL 1.20 spec says: - * - * "The link time initial value is either the value of the variable's - * initializer, if present, or 0 if no initializer is present. Sampler - * types cannot have initializers." - */ - memset(prog->SamplerUnits, 0, sizeof(prog->SamplerUnits)); - /* First pass: Count the uniform resources used by the user-defined * uniforms. While this happens, each active uniform will have an index * assigned to it. @@ -656,6 +643,18 @@ link_assign_uniform_locations(struct gl_shader_program *prog) if (prog->_LinkedShaders[i] == NULL) continue; + /* Uniforms that lack an initializer in the shader code have an initial + * value of zero. This includes sampler uniforms. + * + * Page 24 (page 30 of the PDF) of the GLSL 1.20 spec says: + * + * "The link time initial value is either the value of the variable's + * initializer, if present, or 0 if no initializer is present. Sampler + * types cannot have initializers." + */ + memset(prog->_LinkedShaders[i]->SamplerUnits, 0, + sizeof(prog->_LinkedShaders[i]->SamplerUnits)); + link_update_uniform_buffer_variables(prog->_LinkedShaders[i]); /* Reset various per-shader target counts. @@ -706,9 +705,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog) if (prog->_LinkedShaders[i] == NULL) continue; - /* Reset various per-shader target counts. - */ - parcel.start_shader(); + parcel.start_shader((gl_shader_type)i); foreach_list(node, prog->_LinkedShaders[i]->ir) { ir_variable *const var = ((ir_instruction *) node)->as_variable(); @@ -726,10 +723,11 @@ link_assign_uniform_locations(struct gl_shader_program *prog) prog->_LinkedShaders[i]->active_samplers = parcel.shader_samplers_used; prog->_LinkedShaders[i]->shadow_samplers = parcel.shader_shadow_samplers; - } - assert(sizeof(prog->SamplerTargets) == sizeof(parcel.targets)); - memcpy(prog->SamplerTargets, parcel.targets, sizeof(prog->SamplerTargets)); + STATIC_ASSERT(sizeof(prog->_LinkedShaders[i]->SamplerTargets) == sizeof(parcel.targets)); + memcpy(prog->_LinkedShaders[i]->SamplerTargets, parcel.targets, + sizeof(prog->_LinkedShaders[i]->SamplerTargets)); + } #ifndef NDEBUG for (unsigned i = 0; i < num_user_uniforms; i++) { diff --git a/mesalib/src/glsl/link_varyings.cpp b/mesalib/src/glsl/link_varyings.cpp index 04c9fdd7c..34e3440d6 100644 --- a/mesalib/src/glsl/link_varyings.cpp +++ b/mesalib/src/glsl/link_varyings.cpp @@ -541,7 +541,7 @@ store_tfeedback_info(struct gl_context *ctx, struct gl_shader_program *prog, class varying_matches { public: - varying_matches(bool disable_varying_packing); + varying_matches(bool disable_varying_packing, bool consumer_is_fs); ~varying_matches(); void record(ir_variable *producer_var, ir_variable *consumer_var); unsigned assign_locations(); @@ -621,11 +621,15 @@ private: * it was allocated. */ unsigned matches_capacity; + + const bool consumer_is_fs; }; -varying_matches::varying_matches(bool disable_varying_packing) - : disable_varying_packing(disable_varying_packing) +varying_matches::varying_matches(bool disable_varying_packing, + bool consumer_is_fs) + : disable_varying_packing(disable_varying_packing), + consumer_is_fs(consumer_is_fs) { /* Note: this initial capacity is rather arbitrarily chosen to be large * enough for many cases without wasting an unreasonable amount of space. @@ -656,6 +660,10 @@ varying_matches::~varying_matches() * If \c producer_var has already been paired up with a consumer_var, or * producer_var is part of fixed pipeline functionality (and hence already has * a location assigned), this function has no effect. + * + * Note: as a side effect this function may change the interpolation type of + * \c producer_var, but only when the change couldn't possibly affect + * rendering. */ void varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var) @@ -668,6 +676,25 @@ varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var) return; } + if ((consumer_var == NULL && producer_var->type->contains_integer()) || + !consumer_is_fs) { + /* Since this varying is not being consumed by the fragment shader, its + * interpolation type varying cannot possibly affect rendering. Also, + * this variable is non-flat and is (or contains) an integer. + * + * lower_packed_varyings requires all integer varyings to flat, + * regardless of where they appear. We can trivially satisfy that + * requirement by changing the interpolation type to flat here. + */ + producer_var->centroid = false; + producer_var->interpolation = INTERP_QUALIFIER_FLAT; + + if (consumer_var) { + consumer_var->centroid = false; + consumer_var->interpolation = INTERP_QUALIFIER_FLAT; + } + } + if (this->num_matches == this->matches_capacity) { this->matches_capacity *= 2; this->matches = (match *) @@ -960,11 +987,14 @@ assign_varying_locations(struct gl_context *ctx, { const unsigned producer_base = VARYING_SLOT_VAR0; const unsigned consumer_base = VARYING_SLOT_VAR0; - varying_matches matches(ctx->Const.DisableVaryingPacking); + varying_matches matches(ctx->Const.DisableVaryingPacking, + consumer && consumer->Type == GL_FRAGMENT_SHADER); hash_table *tfeedback_candidates = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); hash_table *consumer_inputs = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); + hash_table *consumer_interface_inputs + = hash_table_ctor(0, hash_table_string_hash, hash_table_string_compare); /* Operate in a total of three passes. * @@ -983,8 +1013,17 @@ assign_varying_locations(struct gl_context *ctx, ((ir_instruction *) node)->as_variable(); if ((input_var != NULL) && (input_var->mode == ir_var_shader_in)) { - hash_table_insert(consumer_inputs, input_var, - ralloc_strdup(mem_ctx, input_var->name)); + if (input_var->interface_type != NULL) { + char *const iface_field_name = + ralloc_asprintf(mem_ctx, "%s.%s", + input_var->interface_type->name, + input_var->name); + hash_table_insert(consumer_interface_inputs, input_var, + iface_field_name); + } else { + hash_table_insert(consumer_inputs, input_var, + ralloc_strdup(mem_ctx, input_var->name)); + } } } } @@ -998,8 +1037,19 @@ assign_varying_locations(struct gl_context *ctx, tfeedback_candidate_generator g(mem_ctx, tfeedback_candidates); g.process(output_var); - ir_variable *input_var = - (ir_variable *) hash_table_find(consumer_inputs, output_var->name); + ir_variable *input_var; + if (output_var->interface_type != NULL) { + char *const iface_field_name = + ralloc_asprintf(mem_ctx, "%s.%s", + output_var->interface_type->name, + output_var->name); + input_var = + (ir_variable *) hash_table_find(consumer_interface_inputs, + iface_field_name); + } else { + input_var = + (ir_variable *) hash_table_find(consumer_inputs, output_var->name); + } if (input_var && input_var->mode != ir_var_shader_in) input_var = NULL; @@ -1019,6 +1069,7 @@ assign_varying_locations(struct gl_context *ctx, if (matched_candidate == NULL) { hash_table_dtor(tfeedback_candidates); hash_table_dtor(consumer_inputs); + hash_table_dtor(consumer_interface_inputs); return false; } @@ -1036,12 +1087,14 @@ assign_varying_locations(struct gl_context *ctx, if (!tfeedback_decls[i].assign_location(ctx, prog)) { hash_table_dtor(tfeedback_candidates); hash_table_dtor(consumer_inputs); + hash_table_dtor(consumer_interface_inputs); return false; } } hash_table_dtor(tfeedback_candidates); hash_table_dtor(consumer_inputs); + hash_table_dtor(consumer_interface_inputs); if (ctx->Const.DisableVaryingPacking) { /* Transform feedback code assumes varyings are packed, so if the driver diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp index 2b30d2b65..982fe46bd 100644 --- a/mesalib/src/glsl/linker.cpp +++ b/mesalib/src/glsl/linker.cpp @@ -938,6 +938,12 @@ link_intrastage_shaders(void *mem_ctx, if (!cross_validate_globals(prog, shader_list, num_shaders, false)) return NULL; + /* Check that interface blocks defined in multiple shaders are consistent. + */ + if (!validate_intrastage_interface_blocks((const gl_shader **)shader_list, + num_shaders)) + return NULL; + /* Check that uniform blocks between shaders for a stage agree. */ const int num_uniform_blocks = link_uniform_blocks(mem_ctx, prog, shader_list, num_shaders, @@ -1512,15 +1518,15 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog) }; const unsigned max_samplers[MESA_SHADER_TYPES] = { - ctx->Const.MaxVertexTextureImageUnits, - ctx->Const.MaxTextureImageUnits, - ctx->Const.MaxGeometryTextureImageUnits + ctx->Const.VertexProgram.MaxTextureImageUnits, + ctx->Const.FragmentProgram.MaxTextureImageUnits, + ctx->Const.GeometryProgram.MaxTextureImageUnits }; const unsigned max_uniform_components[MESA_SHADER_TYPES] = { ctx->Const.VertexProgram.MaxUniformComponents, ctx->Const.FragmentProgram.MaxUniformComponents, - 0 /* FINISHME: Geometry shaders. */ + ctx->Const.GeometryProgram.MaxUniformComponents }; const unsigned max_uniform_blocks[MESA_SHADER_TYPES] = { @@ -1722,6 +1728,12 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) if (prog->_LinkedShaders[i] == NULL) continue; + if (!validate_interstage_interface_blocks(prog->_LinkedShaders[prev], + prog->_LinkedShaders[i])) { + linker_error(prog, "interface block mismatch between shader stages\n"); + goto done; + } + if (!cross_validate_outputs_to_inputs(prog, prog->_LinkedShaders[prev], prog->_LinkedShaders[i])) @@ -1733,6 +1745,12 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) prog->LinkStatus = true; } + + for (unsigned int i = 0; i < MESA_SHADER_TYPES; i++) { + if (prog->_LinkedShaders[i] != NULL) + lower_named_interface_blocks(mem_ctx, prog->_LinkedShaders[i]); + } + /* Implement the GLSL 1.30+ rule for discard vs infinite loops Do * it before optimization because we want most of the checks to get * dropped thanks to constant propagation. @@ -1767,7 +1785,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog) unsigned max_unroll = ctx->ShaderCompilerOptions[i].MaxUnrollIterations; - while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false, max_unroll)) + while (do_common_optimization(prog->_LinkedShaders[i]->ir, true, false, max_unroll, &ctx->ShaderCompilerOptions[i])) ; } diff --git a/mesalib/src/glsl/linker.h b/mesalib/src/glsl/linker.h index f1ce50ace..2fe2410c2 100644 --- a/mesalib/src/glsl/linker.h +++ b/mesalib/src/glsl/linker.h @@ -60,6 +60,14 @@ link_uniform_blocks(void *mem_ctx, unsigned num_shaders, struct gl_uniform_block **blocks_ret); +bool +validate_intrastage_interface_blocks(const gl_shader **shader_list, + unsigned num_shaders); + +bool +validate_interstage_interface_blocks(const gl_shader *producer, + const gl_shader *consumer); + /** * Class for processing all of the leaf fields of a variable that corresponds * to a program resource. diff --git a/mesalib/src/glsl/lower_clip_distance.cpp b/mesalib/src/glsl/lower_clip_distance.cpp index 643807de8..d6cf94438 100644 --- a/mesalib/src/glsl/lower_clip_distance.cpp +++ b/mesalib/src/glsl/lower_clip_distance.cpp @@ -46,10 +46,11 @@ */ #include "glsl_symbol_table.h" -#include "ir_hierarchical_visitor.h" +#include "ir_rvalue_visitor.h" #include "ir.h" +#include "program/prog_instruction.h" /* For WRITEMASK_* */ -class lower_clip_distance_visitor : public ir_hierarchical_visitor { +class lower_clip_distance_visitor : public ir_rvalue_visitor { public: lower_clip_distance_visitor() : progress(false), old_clip_distance_var(NULL), @@ -59,11 +60,14 @@ public: virtual ir_visitor_status visit(ir_variable *); void create_indices(ir_rvalue*, ir_rvalue *&, ir_rvalue *&); - virtual ir_visitor_status visit_leave(ir_dereference_array *); virtual ir_visitor_status visit_leave(ir_assignment *); void visit_new_assignment(ir_assignment *ir); virtual ir_visitor_status visit_leave(ir_call *); + virtual void handle_rvalue(ir_rvalue **rvalue); + + void fix_lhs(ir_assignment *); + bool progress; /** @@ -173,35 +177,70 @@ lower_clip_distance_visitor::create_indices(ir_rvalue *old_index, } -/** - * Replace any expression that indexes into the gl_ClipDistance array with an - * expression that indexes into one of the vec4's in gl_ClipDistanceMESA and - * accesses the appropriate component. - */ -ir_visitor_status -lower_clip_distance_visitor::visit_leave(ir_dereference_array *ir) +void +lower_clip_distance_visitor::handle_rvalue(ir_rvalue **rv) { /* If the gl_ClipDistance var hasn't been declared yet, then * there's no way this deref can refer to it. */ - if (!this->old_clip_distance_var) - return visit_continue; + if (!this->old_clip_distance_var || *rv == NULL) + return; + + ir_dereference_array *const array_deref = (*rv)->as_dereference_array(); + if (array_deref == NULL) + return; - ir_dereference_variable *old_var_ref = ir->array->as_dereference_variable(); + /* Replace any expression that indexes into the gl_ClipDistance array + * with an expression that indexes into one of the vec4's in + * gl_ClipDistanceMESA and accesses the appropriate component. + */ + ir_dereference_variable *old_var_ref = + array_deref->array->as_dereference_variable(); if (old_var_ref && old_var_ref->var == this->old_clip_distance_var) { this->progress = true; ir_rvalue *array_index; ir_rvalue *swizzle_index; - this->create_indices(ir->array_index, array_index, swizzle_index); - void *mem_ctx = ralloc_parent(ir); - ir->array = new(mem_ctx) ir_dereference_array( - this->new_clip_distance_var, array_index); - ir->array_index = swizzle_index; - } + this->create_indices(array_deref->array_index, array_index, swizzle_index); + void *mem_ctx = ralloc_parent(array_deref); - return visit_continue; + ir_dereference_array *const ClipDistanceMESA_deref = + new(mem_ctx) ir_dereference_array(this->new_clip_distance_var, + array_index); + + ir_expression *const expr = + new(mem_ctx) ir_expression(ir_binop_vector_extract, + ClipDistanceMESA_deref, + swizzle_index); + + *rv = expr; + } } +void +lower_clip_distance_visitor::fix_lhs(ir_assignment *ir) +{ + if (ir->lhs->ir_type == ir_type_expression) { + void *mem_ctx = ralloc_parent(ir); + ir_expression *const expr = (ir_expression *) ir->lhs; + + /* The expression must be of the form: + * + * (vector_extract gl_ClipDistanceMESA[i], j). + */ + assert(expr->operation == ir_binop_vector_extract); + assert(expr->operands[0]->ir_type == ir_type_dereference_array); + assert(expr->operands[0]->type == glsl_type::vec4_type); + + ir_dereference *const new_lhs = (ir_dereference *) expr->operands[0]; + ir->rhs = new(mem_ctx) ir_expression(ir_triop_vector_insert, + glsl_type::vec4_type, + new_lhs->clone(mem_ctx, NULL), + ir->rhs, + expr->operands[1]); + ir->set_lhs(new_lhs); + ir->write_mask = WRITEMASK_XYZW; + } +} /** * Replace any assignment having gl_ClipDistance (undereferenced) as its LHS @@ -223,29 +262,50 @@ lower_clip_distance_visitor::visit_leave(ir_assignment *ir) * each of them. * * Note: to unroll into element-by-element assignments, we need to make - * clones of the LHS and RHS. This is only safe if the LHS and RHS are - * side-effect free. Fortunately, we know that they are, because the - * only kind of rvalue that can have side effects is an ir_call, and - * ir_calls only appear (a) as a statement on their own, or (b) as the - * RHS of an assignment that stores the result of the call in a - * temporary variable. + * clones of the LHS and RHS. This is safe because expressions and + * l-values are side-effect free. */ void *ctx = ralloc_parent(ir); int array_size = this->old_clip_distance_var->type->array_size(); for (int i = 0; i < array_size; ++i) { ir_dereference_array *new_lhs = new(ctx) ir_dereference_array( ir->lhs->clone(ctx, NULL), new(ctx) ir_constant(i)); - new_lhs->accept(this); ir_dereference_array *new_rhs = new(ctx) ir_dereference_array( ir->rhs->clone(ctx, NULL), new(ctx) ir_constant(i)); - new_rhs->accept(this); - this->base_ir->insert_before( - new(ctx) ir_assignment(new_lhs, new_rhs)); + this->handle_rvalue((ir_rvalue **) &new_rhs); + + /* Handle the LHS after creating the new assignment. This must + * happen in this order because handle_rvalue may replace the old LHS + * with an ir_expression of ir_binop_vector_extract. Since this is + * not a valide l-value, this will cause an assertion in the + * ir_assignment constructor to fail. + * + * If this occurs, replace the mangled LHS with a dereference of the + * vector, and replace the RHS with an ir_triop_vector_insert. + */ + ir_assignment *const assign = new(ctx) ir_assignment(new_lhs, new_rhs); + this->handle_rvalue((ir_rvalue **) &assign->lhs); + this->fix_lhs(assign); + + this->base_ir->insert_before(assign); } ir->remove(); + + return visit_continue; } - return visit_continue; + /* Handle the LHS as if it were an r-value. Normally + * rvalue_visit(ir_assignment *) only visits the RHS, but we need to lower + * expressions in the LHS as well. + * + * This may cause the LHS to get replaced with an ir_expression of + * ir_binop_vector_extract. If this occurs, replace it with a dereference + * of the vector, and replace the RHS with an ir_triop_vector_insert. + */ + handle_rvalue((ir_rvalue **)&ir->lhs); + this->fix_lhs(ir); + + return rvalue_visit(ir); } @@ -330,7 +390,7 @@ lower_clip_distance_visitor::visit_leave(ir_call *ir) } } - return visit_continue; + return rvalue_visit(ir); } diff --git a/mesalib/src/glsl/lower_instructions.cpp b/mesalib/src/glsl/lower_instructions.cpp index 1ce7b7c9d..d32ec80d6 100644 --- a/mesalib/src/glsl/lower_instructions.cpp +++ b/mesalib/src/glsl/lower_instructions.cpp @@ -38,6 +38,7 @@ * - LOG_TO_LOG2 * - MOD_TO_FRACT * - LRP_TO_ARITH + * - BITFIELD_INSERT_TO_BFM_BFI * * SUB_TO_ADD_NEG: * --------------- @@ -84,6 +85,15 @@ * LRP_TO_ARITH: * ------------- * Converts ir_triop_lrp to (op0 * (1.0f - op2)) + (op1 * op2). + * + * BITFIELD_INSERT_TO_BFM_BFI: + * --------------------------- + * Breaks ir_quadop_bitfield_insert into ir_binop_bfm (bitfield mask) and + * ir_triop_bfi (bitfield insert). + * + * Many GPUs implement the bitfieldInsert() built-in from ARB_gpu_shader_5 + * with a pair of instructions. + * */ #include "main/core.h" /* for M_LOG2E */ @@ -114,6 +124,7 @@ private: void pow_to_exp2(ir_expression *); void log_to_log2(ir_expression *); void lrp_to_arith(ir_expression *); + void bitfield_insert_to_bfm_bfi(ir_expression *); }; /** @@ -298,6 +309,29 @@ lower_instructions_visitor::lrp_to_arith(ir_expression *ir) this->progress = true; } +void +lower_instructions_visitor::bitfield_insert_to_bfm_bfi(ir_expression *ir) +{ + /* Translates + * ir_quadop_bitfield_insert base insert offset bits + * into + * ir_triop_bfi (ir_binop_bfm bits offset) insert base + */ + + ir_rvalue *base_expr = ir->operands[0]; + + ir->operation = ir_triop_bfi; + ir->operands[0] = new(ir) ir_expression(ir_binop_bfm, + ir->type->get_base_type(), + ir->operands[3], + ir->operands[2]); + /* ir->operands[1] is still the value to insert. */ + ir->operands[2] = base_expr; + ir->operands[3] = NULL; + + this->progress = true; +} + ir_visitor_status lower_instructions_visitor::visit_leave(ir_expression *ir) { @@ -339,6 +373,11 @@ lower_instructions_visitor::visit_leave(ir_expression *ir) lrp_to_arith(ir); break; + case ir_quadop_bitfield_insert: + if (lowering(BITFIELD_INSERT_TO_BFM_BFI)) + bitfield_insert_to_bfm_bfi(ir); + break; + default: return visit_continue; } diff --git a/mesalib/src/glsl/lower_named_interface_blocks.cpp b/mesalib/src/glsl/lower_named_interface_blocks.cpp new file mode 100644 index 000000000..eba667a8b --- /dev/null +++ b/mesalib/src/glsl/lower_named_interface_blocks.cpp @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file lower_named_interface_blocks.cpp + * + * This lowering pass converts all interface blocks with instance names + * into interface blocks without an instance name. + * + * For example, the following shader: + * + * out block { + * float block_var; + * } inst_name; + * + * main() + * { + * inst_name.block_var = 0.0; + * } + * + * Is rewritten to: + * + * out block { + * float block_var; + * }; + * + * main() + * { + * block_var = 0.0; + * } + * + * This takes place after the shader code has already been verified with + * the interface name in place. + * + * The linking phase will use the interface block name rather than the + * interface's instance name when linking interfaces. + * + * This modification to the ir allows our currently existing dead code + * elimination to work with interface blocks without changes. + */ + +#include "glsl_symbol_table.h" +#include "ir.h" +#include "ir_optimization.h" +#include "ir_rvalue_visitor.h" +#include "program/hash_table.h" + +class flatten_named_interface_blocks_declarations : public ir_rvalue_visitor +{ +public: + void * const mem_ctx; + hash_table *interface_namespace; + + flatten_named_interface_blocks_declarations(void *mem_ctx) + : mem_ctx(mem_ctx) + { + } + + void run(exec_list *instructions); + + virtual ir_visitor_status visit_leave(ir_assignment *); + virtual void handle_rvalue(ir_rvalue **rvalue); +}; + +void +flatten_named_interface_blocks_declarations::run(exec_list *instructions) +{ + interface_namespace = hash_table_ctor(0, hash_table_string_hash, + hash_table_string_compare); + + /* First pass: adjust instance block variables with an instance name + * to not have an instance name. + * + * The interface block variables are stored in the interface_namespace + * hash table so they can be used in the second pass. + */ + foreach_list_safe(node, instructions) { + ir_variable *var = ((ir_instruction *) node)->as_variable(); + if (!var || !var->is_interface_instance()) + continue; + + /* It should be possible to handle uniforms during this pass, + * but, this will require changes to the other uniform block + * support code. + */ + if (var->mode == ir_var_uniform) + continue; + + const glsl_type * iface_t = var->type; + const glsl_type * array_t = NULL; + exec_node *insert_pos = var; + + if (iface_t->is_array()) { + array_t = iface_t; + iface_t = array_t->fields.array; + } + + assert (iface_t->is_interface()); + + for (unsigned i = 0; i < iface_t->length; i++) { + const char * field_name = iface_t->fields.structure[i].name; + char *iface_field_name = + ralloc_asprintf(mem_ctx, "%s.%s", + iface_t->name, field_name); + + ir_variable *found_var = + (ir_variable *) hash_table_find(interface_namespace, + iface_field_name); + if (!found_var) { + ir_variable *new_var; + if (array_t == NULL) { + char *var_name = + ralloc_strdup(mem_ctx, iface_t->fields.structure[i].name); + new_var = + new(mem_ctx) ir_variable(iface_t->fields.structure[i].type, + var_name, + (ir_variable_mode) var->mode); + } else { + const glsl_type *new_array_type = + glsl_type::get_array_instance( + iface_t->fields.structure[i].type, + array_t->length); + char *var_name = + ralloc_asprintf(mem_ctx, "%s[%d]", + iface_t->fields.structure[i].name, + array_t->length); + new_var = + new(mem_ctx) ir_variable(new_array_type, + var_name, + (ir_variable_mode) var->mode); + } + + new_var->interface_type = iface_t; + hash_table_insert(interface_namespace, new_var, + iface_field_name); + insert_pos->insert_after(new_var); + insert_pos = new_var; + } + } + var->remove(); + } + + /* Second pass: visit all ir_dereference_record instances, and if they + * reference an interface block, then flatten the refererence out. + */ + visit_list_elements(this, instructions); + hash_table_dtor(interface_namespace); + interface_namespace = NULL; +} + +ir_visitor_status +flatten_named_interface_blocks_declarations::visit_leave(ir_assignment *ir) +{ + ir_dereference_record *lhs_rec = ir->lhs->as_dereference_record(); + if (lhs_rec) { + ir_rvalue *lhs_rec_tmp = lhs_rec; + handle_rvalue(&lhs_rec_tmp); + if (lhs_rec_tmp != lhs_rec) { + ir->set_lhs(lhs_rec_tmp); + } + } + return rvalue_visit(ir); +} + +void +flatten_named_interface_blocks_declarations::handle_rvalue(ir_rvalue **rvalue) +{ + if (*rvalue == NULL) + return; + + ir_dereference_record *ir = (*rvalue)->as_dereference_record(); + if (ir == NULL) + return; + + ir_variable *var = ir->variable_referenced(); + + if (!var->is_interface_instance()) + return; + + /* It should be possible to handle uniforms during this pass, + * but, this will require changes to the other uniform block + * support code. + */ + if (var->mode == ir_var_uniform) + return; + + if (var->interface_type != NULL) { + char *iface_field_name = + ralloc_asprintf(mem_ctx, "%s.%s", var->interface_type->name, + ir->field); + /* Find the variable in the set of flattened interface blocks */ + ir_variable *found_var = + (ir_variable *) hash_table_find(interface_namespace, + iface_field_name); + assert(found_var); + + ir_dereference_variable *deref_var = + new(mem_ctx) ir_dereference_variable(found_var); + + ir_dereference_array *deref_array = + ir->record->as_dereference_array(); + if (deref_array != NULL) { + *rvalue = + new(mem_ctx) ir_dereference_array(deref_var, + deref_array->array_index); + } else { + *rvalue = deref_var; + } + } +} + +void +lower_named_interface_blocks(void *mem_ctx, gl_shader *shader) +{ + flatten_named_interface_blocks_declarations v_decl(mem_ctx); + v_decl.run(shader->ir); +} + diff --git a/mesalib/src/glsl/lower_packed_varyings.cpp b/mesalib/src/glsl/lower_packed_varyings.cpp index b4cc5cd0d..cdf2289b4 100644 --- a/mesalib/src/glsl/lower_packed_varyings.cpp +++ b/mesalib/src/glsl/lower_packed_varyings.cpp @@ -178,6 +178,14 @@ lower_packed_varyings_visitor::run(exec_list *instructions) !this->needs_lowering(var)) continue; + /* This lowering pass is only capable of packing floats and ints + * together when their interpolation mode is "flat". Therefore, to be + * safe, caller should ensure that integral varyings always use flat + * interpolation, even when this is not required by GLSL. + */ + assert(var->interpolation == INTERP_QUALIFIER_FLAT || + !var->type->contains_integer()); + /* Change the old varying into an ordinary global. */ var->mode = ir_var_auto; diff --git a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp index f85875f49..880859688 100644 --- a/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp +++ b/mesalib/src/glsl/lower_vec_index_to_cond_assign.cpp @@ -52,7 +52,12 @@ public: progress = false; } - ir_rvalue *convert_vec_index_to_cond_assign(ir_rvalue *val); + ir_rvalue *convert_vec_index_to_cond_assign(void *mem_ctx, + ir_rvalue *orig_vector, + ir_rvalue *orig_index, + const glsl_type *type); + + ir_rvalue *convert_vector_extract_to_cond_assign(ir_rvalue *ir); virtual ir_visitor_status visit_enter(ir_expression *); virtual ir_visitor_status visit_enter(ir_swizzle *); @@ -65,24 +70,16 @@ public: }; ir_rvalue * -ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue *ir) +ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(void *mem_ctx, + ir_rvalue *orig_vector, + ir_rvalue *orig_index, + const glsl_type *type) { - ir_dereference_array *orig_deref = ir->as_dereference_array(); ir_assignment *assign, *value_assign; ir_variable *index, *var, *value; ir_dereference *deref, *deref_value; unsigned i; - if (!orig_deref) - return ir; - - if (orig_deref->array->type->is_matrix() || - orig_deref->array->type->is_array()) - return ir; - - void *mem_ctx = ralloc_parent(ir); - - assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); exec_list list; @@ -92,19 +89,19 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue ir_var_temporary); list.push_tail(index); deref = new(base_ir) ir_dereference_variable(index); - assign = new(base_ir) ir_assignment(deref, orig_deref->array_index, NULL); + assign = new(base_ir) ir_assignment(deref, orig_index, NULL); list.push_tail(assign); /* Store the value inside a temp, thus avoiding matrixes duplication */ - value = new(base_ir) ir_variable(orig_deref->array->type, "vec_value_tmp", - ir_var_temporary); + value = new(base_ir) ir_variable(orig_vector->type, "vec_value_tmp", + ir_var_temporary); list.push_tail(value); deref_value = new(base_ir) ir_dereference_variable(value); - value_assign = new(base_ir) ir_assignment(deref_value, orig_deref->array); + value_assign = new(base_ir) ir_assignment(deref_value, orig_vector); list.push_tail(value_assign); /* Temporary where we store whichever value we swizzle out. */ - var = new(base_ir) ir_variable(ir->type, "vec_index_tmp_v", + var = new(base_ir) ir_variable(type, "vec_index_tmp_v", ir_var_temporary); list.push_tail(var); @@ -113,13 +110,14 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue */ ir_rvalue *const cond_deref = compare_index_block(&list, index, 0, - orig_deref->array->type->vector_elements, + orig_vector->type->vector_elements, mem_ctx); /* Generate a conditional move of each vector element to the temp. */ - for (i = 0; i < orig_deref->array->type->vector_elements; i++) { + for (i = 0; i < orig_vector->type->vector_elements; i++) { ir_rvalue *condition_swizzle = - new(base_ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1); + new(base_ir) ir_swizzle(cond_deref->clone(mem_ctx, NULL), + i, 0, 0, 0, 1); /* Just clone the rest of the deref chain when trying to get at the * underlying variable. @@ -142,13 +140,27 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue return new(base_ir) ir_dereference_variable(var); } +ir_rvalue * +ir_vec_index_to_cond_assign_visitor::convert_vector_extract_to_cond_assign(ir_rvalue *ir) +{ + ir_expression *const expr = ir->as_expression(); + + if (expr == NULL || expr->operation != ir_binop_vector_extract) + return ir; + + return convert_vec_index_to_cond_assign(ralloc_parent(ir), + expr->operands[0], + expr->operands[1], + ir->type); +} + ir_visitor_status ir_vec_index_to_cond_assign_visitor::visit_enter(ir_expression *ir) { unsigned int i; for (i = 0; i < ir->get_num_operands(); i++) { - ir->operands[i] = convert_vec_index_to_cond_assign(ir->operands[i]); + ir->operands[i] = convert_vector_extract_to_cond_assign(ir->operands[i]); } return visit_continue; @@ -161,7 +173,7 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_swizzle *ir) * the result of indexing a vector is. But maybe at some point we'll end up * using swizzling of scalars for vector construction. */ - ir->val = convert_vec_index_to_cond_assign(ir->val); + ir->val = convert_vector_extract_to_cond_assign(ir->val); return visit_continue; } @@ -169,91 +181,12 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_swizzle *ir) ir_visitor_status ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir) { - ir_variable *index, *var; - ir_dereference_variable *deref; - ir_assignment *assign; - unsigned i; - - ir->rhs = convert_vec_index_to_cond_assign(ir->rhs); - if (ir->condition) - ir->condition = convert_vec_index_to_cond_assign(ir->condition); - - /* Last, handle the LHS */ - ir_dereference_array *orig_deref = ir->lhs->as_dereference_array(); - - if (!orig_deref || - orig_deref->array->type->is_matrix() || - orig_deref->array->type->is_array()) - return visit_continue; - - void *mem_ctx = ralloc_parent(ir); - - assert(orig_deref->array_index->type->base_type == GLSL_TYPE_INT); - - exec_list list; - - /* Store the index to a temporary to avoid reusing its tree. */ - index = new(ir) ir_variable(glsl_type::int_type, "vec_index_tmp_i", - ir_var_temporary); - list.push_tail(index); - deref = new(ir) ir_dereference_variable(index); - assign = new(ir) ir_assignment(deref, orig_deref->array_index, NULL); - list.push_tail(assign); - - /* Store the RHS to a temporary to avoid reusing its tree. */ - var = new(ir) ir_variable(ir->rhs->type, "vec_index_tmp_v", - ir_var_temporary); - list.push_tail(var); - deref = new(ir) ir_dereference_variable(var); - assign = new(ir) ir_assignment(deref, ir->rhs, NULL); - list.push_tail(assign); - - /* Generate a single comparison condition "mask" for all of the components - * in the vector. - */ - ir_rvalue *const cond_deref = - compare_index_block(&list, index, 0, - orig_deref->array->type->vector_elements, - mem_ctx); + ir->rhs = convert_vector_extract_to_cond_assign(ir->rhs); - /* Generate a conditional move of each vector element to the temp. */ - for (i = 0; i < orig_deref->array->type->vector_elements; i++) { - ir_rvalue *condition_swizzle = - new(ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1); - - - /* Just clone the rest of the deref chain when trying to get at the - * underlying variable. - */ - ir_rvalue *swizzle = - new(ir) ir_swizzle(orig_deref->array->clone(mem_ctx, NULL), - i, 0, 0, 0, 1); - - deref = new(ir) ir_dereference_variable(var); - assign = new(ir) ir_assignment(swizzle, deref, condition_swizzle); - list.push_tail(assign); + if (ir->condition) { + ir->condition = convert_vector_extract_to_cond_assign(ir->condition); } - /* If the original assignment has a condition, respect that original - * condition! This is acomplished by wrapping the new conditional - * assignments in an if-statement that uses the original condition. - */ - if (ir->condition != NULL) { - /* No need to clone the condition because the IR that it hangs on is - * going to be removed from the instruction sequence. - */ - ir_if *if_stmt = new(mem_ctx) ir_if(ir->condition); - - list.move_nodes_to(&if_stmt->then_instructions); - ir->insert_before(if_stmt); - } else { - ir->insert_before(&list); - } - - ir->remove(); - - this->progress = true; - return visit_continue; } @@ -262,7 +195,7 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_call *ir) { foreach_iter(exec_list_iterator, iter, *ir) { ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = convert_vec_index_to_cond_assign(param); + ir_rvalue *new_param = convert_vector_extract_to_cond_assign(param); if (new_param != param) { param->replace_with(new_param); @@ -276,7 +209,7 @@ ir_visitor_status ir_vec_index_to_cond_assign_visitor::visit_enter(ir_return *ir) { if (ir->value) { - ir->value = convert_vec_index_to_cond_assign(ir->value); + ir->value = convert_vector_extract_to_cond_assign(ir->value); } return visit_continue; @@ -285,7 +218,7 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_return *ir) ir_visitor_status ir_vec_index_to_cond_assign_visitor::visit_enter(ir_if *ir) { - ir->condition = convert_vec_index_to_cond_assign(ir->condition); + ir->condition = convert_vector_extract_to_cond_assign(ir->condition); return visit_continue; } diff --git a/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp b/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp index 264d6dc07..d5ad692c2 100644 --- a/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp +++ b/mesalib/src/glsl/lower_vec_index_to_swizzle.cpp @@ -46,7 +46,7 @@ public: progress = false; } - ir_rvalue *convert_vec_index_to_swizzle(ir_rvalue *val); + ir_rvalue *convert_vector_extract_to_swizzle(ir_rvalue *val); virtual ir_visitor_status visit_enter(ir_expression *); virtual ir_visitor_status visit_enter(ir_swizzle *); @@ -59,20 +59,14 @@ public: }; ir_rvalue * -ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) +ir_vec_index_to_swizzle_visitor::convert_vector_extract_to_swizzle(ir_rvalue *ir) { - ir_dereference_array *deref = ir->as_dereference_array(); - ir_constant *ir_constant; - - if (!deref) - return ir; - - if (deref->array->type->is_matrix() || deref->array->type->is_array()) + ir_expression *const expr = ir->as_expression(); + if (expr == NULL || expr->operation != ir_binop_vector_extract) return ir; - assert(deref->array_index->type->base_type == GLSL_TYPE_INT); - ir_constant = deref->array_index->constant_expression_value(); - if (!ir_constant) + ir_constant *const idx = expr->operands[1]->constant_expression_value(); + if (idx == NULL) return ir; void *ctx = ralloc_parent(ir); @@ -92,10 +86,10 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir) * The ir_swizzle constructor gets angry if the index is negative or too * large. For simplicity sake, just clamp the index to [0, size-1]. */ - const int i = MIN2(MAX2(ir_constant->value.i[0], 0), - ((int) deref->array->type->vector_elements - 1)); + const int i = CLAMP(idx->value.i[0], 0, + (int) expr->operands[0]->type->vector_elements - 1); - return new(ctx) ir_swizzle(deref->array, i, 0, 0, 0, 1); + return new(ctx) ir_swizzle(expr->operands[0], i, 0, 0, 0, 1); } ir_visitor_status @@ -104,7 +98,7 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_expression *ir) unsigned int i; for (i = 0; i < ir->get_num_operands(); i++) { - ir->operands[i] = convert_vec_index_to_swizzle(ir->operands[i]); + ir->operands[i] = convert_vector_extract_to_swizzle(ir->operands[i]); } return visit_continue; @@ -117,7 +111,7 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) * the result of indexing a vector is. But maybe at some point we'll end up * using swizzling of scalars for vector construction. */ - ir->val = convert_vec_index_to_swizzle(ir->val); + ir->val = convert_vector_extract_to_swizzle(ir->val); return visit_continue; } @@ -125,8 +119,7 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_swizzle *ir) ir_visitor_status ir_vec_index_to_swizzle_visitor::visit_enter(ir_assignment *ir) { - ir->set_lhs(convert_vec_index_to_swizzle(ir->lhs)); - ir->rhs = convert_vec_index_to_swizzle(ir->rhs); + ir->rhs = convert_vector_extract_to_swizzle(ir->rhs); return visit_continue; } @@ -136,7 +129,7 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_call *ir) { foreach_iter(exec_list_iterator, iter, *ir) { ir_rvalue *param = (ir_rvalue *)iter.get(); - ir_rvalue *new_param = convert_vec_index_to_swizzle(param); + ir_rvalue *new_param = convert_vector_extract_to_swizzle(param); if (new_param != param) { param->replace_with(new_param); @@ -150,7 +143,7 @@ ir_visitor_status ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir) { if (ir->value) { - ir->value = convert_vec_index_to_swizzle(ir->value); + ir->value = convert_vector_extract_to_swizzle(ir->value); } return visit_continue; @@ -159,7 +152,7 @@ ir_vec_index_to_swizzle_visitor::visit_enter(ir_return *ir) ir_visitor_status ir_vec_index_to_swizzle_visitor::visit_enter(ir_if *ir) { - ir->condition = convert_vec_index_to_swizzle(ir->condition); + ir->condition = convert_vector_extract_to_swizzle(ir->condition); return visit_continue; } diff --git a/mesalib/src/glsl/lower_vector_insert.cpp b/mesalib/src/glsl/lower_vector_insert.cpp new file mode 100644 index 000000000..0e640cc32 --- /dev/null +++ b/mesalib/src/glsl/lower_vector_insert.cpp @@ -0,0 +1,139 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ +#include "ir.h" +#include "ir_builder.h" +#include "ir_rvalue_visitor.h" +#include "ir_optimization.h" + +using namespace ir_builder; + +class vector_insert_visitor : public ir_rvalue_visitor { +public: + vector_insert_visitor(bool lower_nonconstant_index) + : progress(false), lower_nonconstant_index(lower_nonconstant_index) + { + factory.instructions = &factory_instructions; + } + + virtual ~vector_insert_visitor() + { + assert(factory_instructions.is_empty()); + } + + virtual void handle_rvalue(ir_rvalue **rv); + + ir_factory factory; + exec_list factory_instructions; + bool progress; + bool lower_nonconstant_index; +}; + + +void +vector_insert_visitor::handle_rvalue(ir_rvalue **rv) +{ + if (*rv == NULL || (*rv)->ir_type != ir_type_expression) + return; + + ir_expression *const expr = (ir_expression *) *rv; + + if (likely(expr->operation != ir_triop_vector_insert)) + return; + + factory.mem_ctx = ralloc_parent(expr); + + ir_constant *const idx = expr->operands[2]->constant_expression_value(); + if (idx != NULL) { + /* Replace (vector_insert (vec) (scalar) (index)) with a dereference of + * a new temporary. The new temporary gets assigned as + * + * t = vec + * t.mask = scalar + * + * where mask is the component selected by index. + */ + ir_variable *const temp = + factory.make_temp(expr->operands[0]->type, "vec_tmp"); + + const int mask = 1 << idx->value.i[0]; + + factory.emit(assign(temp, expr->operands[0])); + factory.emit(assign(temp, expr->operands[1], mask)); + + this->progress = true; + *rv = new(factory.mem_ctx) ir_dereference_variable(temp); + } else if (this->lower_nonconstant_index) { + /* Replace (vector_insert (vec) (scalar) (index)) with a dereference of + * a new temporary. The new temporary gets assigned as + * + * t = vec + * if (index == 0) + * t.x = scalar + * if (index == 1) + * t.y = scalar + * if (index == 2) + * t.z = scalar + * if (index == 3) + * t.w = scalar + */ + ir_variable *const temp = + factory.make_temp(expr->operands[0]->type, "vec_tmp"); + + ir_variable *const src_temp = + factory.make_temp(expr->operands[1]->type, "src_temp"); + + factory.emit(assign(temp, expr->operands[0])); + factory.emit(assign(src_temp, expr->operands[1])); + + for (unsigned i = 0; i < expr->type->vector_elements; i++) { + ir_constant *const cmp_index = + new(factory.mem_ctx) ir_constant(int(i)); + + ir_variable *const cmp_result = + factory.make_temp(glsl_type::bool_type, "index_condition"); + + factory.emit(assign(cmp_result, + equal(expr->operands[2]->clone(factory.mem_ctx, + NULL), + cmp_index))); + + factory.emit(if_tree(cmp_result, + assign(temp, src_temp, WRITEMASK_X << i))); + } + + this->progress = true; + *rv = new(factory.mem_ctx) ir_dereference_variable(temp); + } + + base_ir->insert_before(factory.instructions); +} + +bool +lower_vector_insert(exec_list *instructions, bool lower_nonconstant_index) +{ + vector_insert_visitor v(lower_nonconstant_index); + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/mesalib/src/glsl/main.cpp b/mesalib/src/glsl/main.cpp index ce084b4d7..d7e35bcb3 100644 --- a/mesalib/src/glsl/main.cpp +++ b/mesalib/src/glsl/main.cpp @@ -174,9 +174,11 @@ compile_shader(struct gl_context *ctx, struct gl_shader *shader) /* Optimization passes */ if (!state->error && !shader->ir->is_empty()) { + const struct gl_shader_compiler_options *opts = + &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; bool progress; do { - progress = do_common_optimization(shader->ir, false, false, 32); + progress = do_common_optimization(shader->ir, false, false, 32, opts); } while (progress); validate_ir_tree(shader->ir); diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp index 70e016d22..d706a6ad1 100644 --- a/mesalib/src/glsl/opt_algebraic.cpp +++ b/mesalib/src/glsl/opt_algebraic.cpp @@ -186,12 +186,12 @@ ir_algebraic_visitor::swizzle_if_required(ir_expression *expr, ir_rvalue * ir_algebraic_visitor::handle_expression(ir_expression *ir) { - ir_constant *op_const[3] = {NULL, NULL, NULL}; - ir_expression *op_expr[3] = {NULL, NULL, NULL}; + ir_constant *op_const[4] = {NULL, NULL, NULL, NULL}; + ir_expression *op_expr[4] = {NULL, NULL, NULL, NULL}; ir_expression *temp; unsigned int i; - assert(ir->get_num_operands() <= 3); + assert(ir->get_num_operands() <= 4); for (i = 0; i < ir->get_num_operands(); i++) { if (ir->operands[i]->type->is_matrix()) return ir; diff --git a/mesalib/src/glsl/opt_flip_matrices.cpp b/mesalib/src/glsl/opt_flip_matrices.cpp new file mode 100644 index 000000000..497513fe8 --- /dev/null +++ b/mesalib/src/glsl/opt_flip_matrices.cpp @@ -0,0 +1,122 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file opt_flip_matrices.cpp + * + * Convert (matrix * vector) operations to (vector * matrixTranspose), + * which can be done using dot products rather than multiplies and adds. + * On some hardware, this is more efficient. + * + * This currently only does the conversion for built-in matrices which + * already have transposed equivalents. Namely, gl_ModelViewProjectionMatrix + * and gl_TextureMatrix. + */ +#include "ir.h" +#include "ir_optimization.h" +#include "main/macros.h" + +namespace { +class matrix_flipper : public ir_hierarchical_visitor { +public: + matrix_flipper(exec_list *instructions) + { + progress = false; + mvp_transpose = NULL; + texmat_transpose = NULL; + + foreach_list(n, instructions) { + ir_instruction *ir = (ir_instruction *) n; + ir_variable *var = ir->as_variable(); + if (!var) + continue; + if (strcmp(var->name, "gl_ModelViewProjectionMatrixTranspose") == 0) + mvp_transpose = var; + if (strcmp(var->name, "gl_TextureMatrixTranspose") == 0) + texmat_transpose = var; + } + } + + ir_visitor_status visit_enter(ir_expression *ir); + + bool progress; + +private: + ir_variable *mvp_transpose; + ir_variable *texmat_transpose; +}; +} + +ir_visitor_status +matrix_flipper::visit_enter(ir_expression *ir) +{ + if (ir->operation != ir_binop_mul || + !ir->operands[0]->type->is_matrix() || + !ir->operands[1]->type->is_vector()) + return visit_continue; + + ir_variable *mat_var = ir->operands[0]->variable_referenced(); + if (!mat_var) + return visit_continue; + + if (mvp_transpose && + strcmp(mat_var->name, "gl_ModelViewProjectionMatrix") == 0) { + ir_dereference_variable *deref = ir->operands[0]->as_dereference_variable(); + assert(deref && deref->var == mat_var); + + void *mem_ctx = ralloc_parent(ir); + + ir->operands[0] = ir->operands[1]; + ir->operands[1] = new(mem_ctx) ir_dereference_variable(mvp_transpose); + + progress = true; + } else if (texmat_transpose && + strcmp(mat_var->name, "gl_TextureMatrix") == 0) { + ir_dereference_array *array_ref = ir->operands[0]->as_dereference_array(); + assert(array_ref != NULL); + ir_dereference_variable *var_ref = array_ref->array->as_dereference_variable(); + assert(var_ref && var_ref->var == mat_var); + + ir->operands[0] = ir->operands[1]; + ir->operands[1] = array_ref; + + var_ref->var = texmat_transpose; + + texmat_transpose->max_array_access = + MAX2(texmat_transpose->max_array_access, mat_var->max_array_access); + + progress = true; + } + + return visit_continue; +} + +bool +opt_flip_matrices(struct exec_list *instructions) +{ + matrix_flipper v(instructions); + + visit_list_elements(&v, instructions); + + return v.progress; +} diff --git a/mesalib/src/glsl/opt_if_simplification.cpp b/mesalib/src/glsl/opt_if_simplification.cpp index e1a23d94a..db59b131d 100644 --- a/mesalib/src/glsl/opt_if_simplification.cpp +++ b/mesalib/src/glsl/opt_if_simplification.cpp @@ -25,7 +25,8 @@ * \file opt_if_simplification.cpp * * Moves constant branches of if statements out to the surrounding - * instruction stream. + * instruction stream, and inverts if conditionals to avoid empty + * "then" blocks. */ #include "ir.h" @@ -101,6 +102,30 @@ ir_if_simplification_visitor::visit_leave(ir_if *ir) } ir->remove(); this->made_progress = true; + return visit_continue; + } + + /* Turn: + * + * if (cond) { + * } else { + * do_work(); + * } + * + * into : + * + * if (!cond) + * do_work(); + * + * which avoids control flow for "else" (which is usually more + * expensive than normal operations), and the "not" can usually be + * folded into the generation of "cond" anyway. + */ + if (ir->then_instructions.is_empty()) { + ir->condition = new(ralloc_parent(ir->condition)) + ir_expression(ir_unop_logic_not, ir->condition); + ir->else_instructions.move_nodes_to(&ir->then_instructions); + this->made_progress = true; } return visit_continue; diff --git a/mesalib/src/glsl/program.h b/mesalib/src/glsl/program.h index 46ce9dccc..6a76d4d54 100644 --- a/mesalib/src/glsl/program.h +++ b/mesalib/src/glsl/program.h @@ -16,9 +16,10 @@ * 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. + * 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" diff --git a/mesalib/src/glsl/ralloc.c b/mesalib/src/glsl/ralloc.c index 59e71c48b..e79dad764 100644 --- a/mesalib/src/glsl/ralloc.c +++ b/mesalib/src/glsl/ralloc.c @@ -107,9 +107,13 @@ void * ralloc_size(const void *ctx, size_t size) { void *block = calloc(1, size + sizeof(ralloc_header)); + ralloc_header *info; + ralloc_header *parent; - ralloc_header *info = (ralloc_header *) block; - ralloc_header *parent = ctx != NULL ? get_header(ctx) : NULL; + if (unlikely(block == NULL)) + return NULL; + info = (ralloc_header *) block; + parent = ctx != NULL ? get_header(ctx) : NULL; add_child(parent, info); diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp index 0c1f52f48..11cd6cdc0 100644 --- a/mesalib/src/glsl/standalone_scaffolding.cpp +++ b/mesalib/src/glsl/standalone_scaffolding.cpp @@ -104,6 +104,7 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Extensions.ARB_texture_cube_map_array = true; ctx->Extensions.ARB_texture_multisample = true; ctx->Extensions.ARB_texture_query_lod = true; + ctx->Extensions.ARB_gpu_shader5 = true; ctx->Const.GLSLVersion = 120; @@ -116,10 +117,22 @@ void initialize_context_to_defaults(struct gl_context *ctx, gl_api api) ctx->Const.VertexProgram.MaxUniformComponents = 512; ctx->Const.MaxVarying = 8; /* == gl_MaxVaryingFloats / 4 */ - ctx->Const.MaxVertexTextureImageUnits = 0; + ctx->Const.VertexProgram.MaxTextureImageUnits = 0; ctx->Const.MaxCombinedTextureImageUnits = 2; - ctx->Const.MaxTextureImageUnits = 2; + ctx->Const.FragmentProgram.MaxTextureImageUnits = 2; ctx->Const.FragmentProgram.MaxUniformComponents = 64; ctx->Const.MaxDrawBuffers = 1; + + /* Set up default shader compiler options. */ + struct gl_shader_compiler_options options; + memset(&options, 0, sizeof(options)); + options.MaxUnrollIterations = 32; + options.MaxIfDepth = UINT_MAX; + + /* Default pragma settings */ + options.DefaultPragmas.Optimize = true; + + for (int sh = 0; sh < MESA_SHADER_TYPES; ++sh) + memcpy(&ctx->ShaderCompilerOptions[sh], &options, sizeof(options)); } diff --git a/mesalib/src/glsl/standalone_scaffolding.h b/mesalib/src/glsl/standalone_scaffolding.h index 0a2cde8a3..7afb1c313 100644 --- a/mesalib/src/glsl/standalone_scaffolding.h +++ b/mesalib/src/glsl/standalone_scaffolding.h @@ -31,6 +31,7 @@ #ifndef STANDALONE_SCAFFOLDING_H #define STANDALONE_SCAFFOLDING_H +#include #include "main/mtypes.h" extern "C" void @@ -47,6 +48,22 @@ extern "C" void _mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint *id, const char *msg, int len); +static inline gl_shader_type +_mesa_shader_type_to_index(GLenum v) +{ + switch (v) { + case GL_VERTEX_SHADER: + return MESA_SHADER_VERTEX; + case GL_FRAGMENT_SHADER: + return MESA_SHADER_FRAGMENT; + case GL_GEOMETRY_SHADER: + return MESA_SHADER_GEOMETRY; + default: + assert(!"bad value in _mesa_shader_type_to_index()"); + return MESA_SHADER_TYPES; + } +} + /** * Initialize the given gl_context structure to a reasonable set of * defaults representing the minimum capabilities required by the diff --git a/mesalib/src/glsl/test_optpass.cpp b/mesalib/src/glsl/test_optpass.cpp index 117b0b006..fc10cbbde 100644 --- a/mesalib/src/glsl/test_optpass.cpp +++ b/mesalib/src/glsl/test_optpass.cpp @@ -54,7 +54,8 @@ static string read_stdin_to_eof() } static GLboolean -do_optimization(struct exec_list *ir, const char *optimization) +do_optimization(struct exec_list *ir, const char *optimization, + const struct gl_shader_compiler_options *options) { int int_0; int int_1; @@ -64,7 +65,7 @@ do_optimization(struct exec_list *ir, const char *optimization) if (sscanf(optimization, "do_common_optimization ( %d , %d ) ", &int_0, &int_1) == 2) { - return do_common_optimization(ir, int_0 != 0, false, int_1); + return do_common_optimization(ir, int_0 != 0, false, int_1, options); } else if (strcmp(optimization, "do_algebraic") == 0) { return do_algebraic(ir); } else if (strcmp(optimization, "do_constant_folding") == 0) { @@ -141,7 +142,8 @@ do_optimization(struct exec_list *ir, const char *optimization) static GLboolean do_optimization_passes(struct exec_list *ir, char **optimizations, - int num_optimizations, bool quiet) + int num_optimizations, bool quiet, + const struct gl_shader_compiler_options *options) { GLboolean overall_progress = false; @@ -150,7 +152,7 @@ do_optimization_passes(struct exec_list *ir, char **optimizations, if (!quiet) { printf("*** Running optimization %s...", optimization); } - GLboolean progress = do_optimization(ir, optimization); + GLboolean progress = do_optimization(ir, optimization, options); if (!quiet) { printf("%s\n", progress ? "progress" : "no progress"); } @@ -240,9 +242,11 @@ int test_optpass(int argc, char **argv) /* Optimization passes */ if (!state->error) { GLboolean progress; + const struct gl_shader_compiler_options *options = + &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader_type)]; do { progress = do_optimization_passes(shader->ir, &argv[optind], - argc - optind, quiet != 0); + argc - optind, quiet != 0, options); } while (loop && progress); } diff --git a/mesalib/src/mapi/Android.mk b/mesalib/src/mapi/Android.mk index d1749a262..f10437874 100644 --- a/mesalib/src/mapi/Android.mk +++ b/mesalib/src/mapi/Android.mk @@ -36,12 +36,12 @@ include $(CLEAR_VARS) abi_header := shared-glapi/glapi_mapi_tmp.h LOCAL_SRC_FILES := \ - mapi/entry.c \ - mapi/mapi_glapi.c \ - mapi/stub.c \ - mapi/table.c \ - mapi/u_current.c \ - mapi/u_execmem.c + entry.c \ + mapi_glapi.c \ + stub.c \ + table.c \ + u_current.c \ + u_execmem.c LOCAL_CFLAGS := \ -DMAPI_MODE_GLAPI \ @@ -68,9 +68,9 @@ include $(BUILD_SHARED_LIBRARY) mapi_abi_deps := \ $(wildcard $(LOCAL_PATH)/glapi/gen/*.py) \ $(wildcard $(LOCAL_PATH)/glapi/gen/*.xml) \ - $(LOCAL_PATH)/mapi/mapi_abi.py + $(LOCAL_PATH)/mapi_abi.py -$(mapi_abi_headers): PRIVATE_SCRIPT := $(MESA_PYTHON2) $(LOCAL_PATH)/mapi/mapi_abi.py +$(mapi_abi_headers): PRIVATE_SCRIPT := $(MESA_PYTHON2) $(LOCAL_PATH)/mapi_abi.py $(mapi_abi_headers): PRIVATE_APIXML := $(LOCAL_PATH)/glapi/gen/gl_and_es_API.xml $(mapi_abi_headers): $(mapi_abi_deps) @mkdir -p $(dir $@) diff --git a/mesalib/src/mapi/Makefile.am b/mesalib/src/mapi/Makefile.am new file mode 100644 index 000000000..ef538039b --- /dev/null +++ b/mesalib/src/mapi/Makefile.am @@ -0,0 +1,42 @@ +# Copyright © 2013 Intel Corporation +# +# Permission is hereby granted, free of charge, to any person obtaining a +# copy of this software and associated documentation files (the "Software"), +# to deal in the Software without restriction, including without limitation +# the rights to use, copy, modify, merge, publish, distribute, sublicense, +# and/or sell copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice (including the next +# paragraph) shall be included in all copies or substantial portions of the +# Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. + +SUBDIRS = glapi/gen + +if HAVE_SHARED_GLAPI +SUBDIRS += shared-glapi +endif + +if HAVE_OPENGL +SUBDIRS += glapi +endif + +if HAVE_OPENGL_ES1 +SUBDIRS += es1api +endif + +if HAVE_OPENGL_ES2 +SUBDIRS += es2api +endif + +if HAVE_OPENVG +SUBDIRS += vgapi +endif diff --git a/mesalib/src/mapi/Makefile.sources b/mesalib/src/mapi/Makefile.sources new file mode 100644 index 000000000..aff465a60 --- /dev/null +++ b/mesalib/src/mapi/Makefile.sources @@ -0,0 +1,36 @@ +# src/mapi/Makefile.sources +# +# mapi may be used in several ways +# +# - In default mode, mapi implements the interface defined by mapi.h. To use +# this mode, compile MAPI_FILES. +# +# - In util mode, mapi provides utility functions for use with glapi. To use +# this mode, compile MAPI_UTIL_FILES with MAPI_MODE_UTIL defined. +# +# - In glapi mode, mapi implements the interface defined by glapi.h. To use +# this mode, compile MAPI_GLAPI_FILES with MAPI_MODE_GLAPI defined. +# +# - In bridge mode, mapi provides entry points calling into glapi. To use +# this mode, compile MAPI_BRIDGE_FILES with MAPI_MODE_BRIDGE defined. + +MAPI_UTIL_FILES = \ + $(TOP)/src/mapi/u_current.c \ + $(TOP)/src/mapi/u_execmem.c + +MAPI_FILES = \ + $(TOP)/src/mapi/entry.c \ + $(TOP)/src/mapi/mapi.c \ + $(TOP)/src/mapi/stub.c \ + $(TOP)/src/mapi/table.c \ + $(MAPI_UTIL_FILES) + +MAPI_GLAPI_FILES = \ + $(TOP)/src/mapi/entry.c \ + $(TOP)/src/mapi/mapi_glapi.c \ + $(TOP)/src/mapi/stub.c \ + $(TOP)/src/mapi/table.c \ + $(MAPI_UTIL_FILES) + +MAPI_BRIDGE_FILES = \ + $(TOP)/src/mapi/entry.c diff --git a/mesalib/src/mapi/entry.c b/mesalib/src/mapi/entry.c new file mode 100644 index 000000000..3d9168a72 --- /dev/null +++ b/mesalib/src/mapi/entry.c @@ -0,0 +1,98 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include "entry.h" +#include "u_current.h" +#include "u_macros.h" + +/* define macros for use by assembly dispatchers */ +#define ENTRY_CURRENT_TABLE U_STRINGIFY(u_current_table) + +/* in bridge mode, mapi is a user of glapi */ +#ifdef MAPI_MODE_BRIDGE +#define ENTRY_CURRENT_TABLE_GET "_glapi_get_dispatch" +#else +#define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_internal) +#endif + +#if defined(USE_X86_ASM) && defined(__GNUC__) +# ifdef GLX_USE_TLS +# include "entry_x86_tls.h" +# else +# include "entry_x86_tsd.h" +# endif +#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(GLX_USE_TLS) +# include "entry_x86-64_tls.h" +#else + +#include + +static INLINE const struct mapi_table * +entry_current_get(void) +{ +#ifdef MAPI_MODE_BRIDGE + return GET_DISPATCH(); +#else + return u_current_get(); +#endif +} + +/* C version of the public entries */ +#define MAPI_TMP_DEFINES +#define MAPI_TMP_PUBLIC_DECLARES +#define MAPI_TMP_PUBLIC_ENTRIES +#include "mapi_tmp.h" + +#ifndef MAPI_MODE_BRIDGE + +void +entry_patch_public(void) +{ +} + +mapi_func +entry_get_public(int slot) +{ + /* pubic_entries are defined by MAPI_TMP_PUBLIC_ENTRIES */ + return public_entries[slot]; +} + +mapi_func +entry_generate(int slot) +{ + return NULL; +} + +void +entry_patch(mapi_func entry, int slot) +{ +} + +#endif /* MAPI_MODE_BRIDGE */ + +#endif /* asm */ diff --git a/mesalib/src/mapi/entry.h b/mesalib/src/mapi/entry.h new file mode 100644 index 000000000..9df810004 --- /dev/null +++ b/mesalib/src/mapi/entry.h @@ -0,0 +1,48 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _ENTRY_H_ +#define _ENTRY_H_ + +#include "u_compiler.h" + +typedef void (*mapi_func)(void); + +void +entry_patch_public(void); + +mapi_func +entry_get_public(int slot); + +mapi_func +entry_generate(int slot); + +void +entry_patch(mapi_func entry, int slot); + +#endif /* _ENTRY_H_ */ diff --git a/mesalib/src/mapi/entry_x86-64_tls.h b/mesalib/src/mapi/entry_x86-64_tls.h new file mode 100644 index 000000000..36cad00c2 --- /dev/null +++ b/mesalib/src/mapi/entry_x86-64_tls.h @@ -0,0 +1,113 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include "u_macros.h" + +__asm__(".text\n" + ".balign 32\n" + "x86_64_entry_start:"); + +#define STUB_ASM_ENTRY(func) \ + ".globl " func "\n" \ + ".type " func ", @function\n" \ + ".balign 32\n" \ + func ":" + +#define STUB_ASM_CODE(slot) \ + "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t" \ + "movq %fs:(%rax), %r11\n\t" \ + "jmp *(8 * " slot ")(%r11)" + +#define MAPI_TMP_STUB_ASM_GCC +#include "mapi_tmp.h" + +#ifndef MAPI_MODE_BRIDGE + +__asm__("x86_64_current_tls:\n\t" + "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t" + "ret"); + +extern unsigned long +x86_64_current_tls(); + +#include +#include "u_execmem.h" + +void +entry_patch_public(void) +{ +} + +static char +x86_64_entry_start[]; + +mapi_func +entry_get_public(int slot) +{ + return (mapi_func) (x86_64_entry_start + slot * 32); +} + +void +entry_patch(mapi_func entry, int slot) +{ + char *code = (char *) entry; + *((unsigned int *) (code + 12)) = slot * sizeof(mapi_func); +} + +mapi_func +entry_generate(int slot) +{ + const char code_templ[16] = { + /* movq %fs:0, %r11 */ + 0x64, 0x4c, 0x8b, 0x1c, 0x25, 0x00, 0x00, 0x00, 0x00, + /* jmp *0x1234(%r11) */ + 0x41, 0xff, 0xa3, 0x34, 0x12, 0x00, 0x00, + }; + unsigned long addr; + void *code; + mapi_func entry; + + addr = x86_64_current_tls(); + if ((addr >> 32) != 0xffffffff) + return NULL; + addr &= 0xffffffff; + + code = u_execmem_alloc(sizeof(code_templ)); + if (!code) + return NULL; + + memcpy(code, code_templ, sizeof(code_templ)); + + *((unsigned int *) (code + 5)) = addr; + entry = (mapi_func) code; + entry_patch(entry, slot); + + return entry; +} + +#endif /* MAPI_MODE_BRIDGE */ diff --git a/mesalib/src/mapi/entry_x86_tls.h b/mesalib/src/mapi/entry_x86_tls.h new file mode 100644 index 000000000..58d09caa6 --- /dev/null +++ b/mesalib/src/mapi/entry_x86_tls.h @@ -0,0 +1,133 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include +#include "u_macros.h" + +__asm__(".text"); + +__asm__("x86_current_tls:\n\t" + "call 1f\n" + "1:\n\t" + "popl %eax\n\t" + "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" + "movl " ENTRY_CURRENT_TABLE "@GOTNTPOFF(%eax), %eax\n\t" + "ret"); + +#ifndef GLX_X86_READONLY_TEXT +__asm__(".section wtext, \"awx\", @progbits"); +#endif /* GLX_X86_READONLY_TEXT */ + +__asm__(".balign 16\n" + "x86_entry_start:"); + +#define STUB_ASM_ENTRY(func) \ + ".globl " func "\n" \ + ".type " func ", @function\n" \ + ".balign 16\n" \ + func ":" + +#define STUB_ASM_CODE(slot) \ + "call x86_current_tls\n\t" \ + "movl %gs:(%eax), %eax\n\t" \ + "jmp *(4 * " slot ")(%eax)" + +#define MAPI_TMP_STUB_ASM_GCC +#include "mapi_tmp.h" + +#ifndef GLX_X86_READONLY_TEXT +__asm__(".balign 16\n" + "x86_entry_end:"); +__asm__(".text"); +#endif /* GLX_X86_READONLY_TEXT */ + +#ifndef MAPI_MODE_BRIDGE + +#include "u_execmem.h" + +extern unsigned long +x86_current_tls(); + +static char x86_entry_start[]; +static char x86_entry_end[]; + +void +entry_patch_public(void) +{ +#ifndef GLX_X86_READONLY_TEXT + char patch[8] = { + 0x65, 0xa1, 0x00, 0x00, 0x00, 0x00, /* movl %gs:0x0, %eax */ + 0x90, 0x90 /* nop's */ + }; + char *entry; + + *((unsigned long *) (patch + 2)) = x86_current_tls(); + + for (entry = x86_entry_start; entry < x86_entry_end; entry += 16) + memcpy(entry, patch, sizeof(patch)); +#endif +} + +mapi_func +entry_get_public(int slot) +{ + return (mapi_func) (x86_entry_start + slot * 16); +} + +void +entry_patch(mapi_func entry, int slot) +{ + char *code = (char *) entry; + *((unsigned long *) (code + 8)) = slot * sizeof(mapi_func); +} + +mapi_func +entry_generate(int slot) +{ + const char code_templ[16] = { + 0x65, 0xa1, 0x00, 0x00, 0x00, 0x00, /* movl %gs:0x0, %eax */ + 0xff, 0xa0, 0x34, 0x12, 0x00, 0x00, /* jmp *0x1234(%eax) */ + 0x90, 0x90, 0x90, 0x90 /* nop's */ + }; + void *code; + mapi_func entry; + + code = u_execmem_alloc(sizeof(code_templ)); + if (!code) + return NULL; + + memcpy(code, code_templ, sizeof(code_templ)); + + *((unsigned long *) (code + 2)) = x86_current_tls(); + entry = (mapi_func) code; + entry_patch(entry, slot); + + return entry; +} + +#endif /* MAPI_MODE_BRIDGE */ diff --git a/mesalib/src/mapi/entry_x86_tsd.h b/mesalib/src/mapi/entry_x86_tsd.h new file mode 100644 index 000000000..c479c199e --- /dev/null +++ b/mesalib/src/mapi/entry_x86_tsd.h @@ -0,0 +1,104 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include "u_macros.h" + +#define X86_ENTRY_SIZE 32 + +__asm__(".text\n" + ".balign 32\n" + "x86_entry_start:"); + +#define STUB_ASM_ENTRY(func) \ + ".globl " func "\n" \ + ".type " func ", @function\n" \ + ".balign 32\n" \ + func ":" + +#define STUB_ASM_CODE(slot) \ + "movl " ENTRY_CURRENT_TABLE ", %eax\n\t" \ + "testl %eax, %eax\n\t" \ + "je 1f\n\t" \ + "jmp *(4 * " slot ")(%eax)\n" \ + "1:\n\t" \ + "call " ENTRY_CURRENT_TABLE_GET "\n\t" \ + "jmp *(4 * " slot ")(%eax)" + +#define MAPI_TMP_STUB_ASM_GCC +#include "mapi_tmp.h" + +#ifndef MAPI_MODE_BRIDGE + +__asm__(".balign 32\n" + "x86_entry_end:"); + +#include +#include "u_execmem.h" + +static const char x86_entry_start[]; +static const char x86_entry_end[]; + +void +entry_patch_public(void) +{ +} + +mapi_func +entry_get_public(int slot) +{ + return (mapi_func) (x86_entry_start + slot * X86_ENTRY_SIZE); +} + +void +entry_patch(mapi_func entry, int slot) +{ + char *code = (char *) entry; + + *((unsigned long *) (code + 11)) = slot * sizeof(mapi_func); + *((unsigned long *) (code + 22)) = slot * sizeof(mapi_func); +} + +mapi_func +entry_generate(int slot) +{ + const char *code_templ = x86_entry_end - X86_ENTRY_SIZE; + void *code; + mapi_func entry; + + code = u_execmem_alloc(X86_ENTRY_SIZE); + if (!code) + return NULL; + + memcpy(code, code_templ, X86_ENTRY_SIZE); + entry = (mapi_func) code; + entry_patch(entry, slot); + + return entry; +} + +#endif /* MAPI_MODE_BRIDGE */ diff --git a/mesalib/src/mapi/glapi/Makefile.am b/mesalib/src/mapi/glapi/Makefile.am index bdb527d5c..1698d1474 100644 --- a/mesalib/src/mapi/glapi/Makefile.am +++ b/mesalib/src/mapi/glapi/Makefile.am @@ -20,8 +20,8 @@ # IN THE SOFTWARE. TOP = $(top_srcdir) -include sources.mak -include ../mapi/sources.mak +include Makefile.sources +include ../Makefile.sources AM_CPPFLAGS = \ $(DEFINES) \ diff --git a/mesalib/src/mapi/glapi/Makefile.sources b/mesalib/src/mapi/glapi/Makefile.sources new file mode 100644 index 000000000..58d28c52c --- /dev/null +++ b/mesalib/src/mapi/glapi/Makefile.sources @@ -0,0 +1,19 @@ +# src/mapi/glapi/Makefile.sources + +GLAPI_SOURCES = \ + glapi_dispatch.c \ + glapi_entrypoint.c \ + glapi_gentable.c \ + glapi_getproc.c \ + glapi_nop.c \ + glthread.c \ + glapi.c + +X86_API = \ + glapi_x86.S + +X86_64_API = \ + glapi_x86-64.S + +SPARC_API = \ + glapi_sparc.S diff --git a/mesalib/src/mapi/glapi/SConscript b/mesalib/src/mapi/glapi/SConscript index 00cce3e7f..c4ac080aa 100644 --- a/mesalib/src/mapi/glapi/SConscript +++ b/mesalib/src/mapi/glapi/SConscript @@ -43,13 +43,14 @@ mapi_sources = [ 'u_execmem.c', ] for s in mapi_sources: - o = env.SharedObject(s[:-2], '../mapi/' + s) + o = env.SharedObject(s[:-2], '../' + s) glapi_sources.append(o) # # Assembly sources # -if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows'): +if (env['gcc'] or env['clang']) and \ + env['platform'] not in ('cygwin', 'darwin', 'windows'): GLAPI = '#src/mapi/glapi/' if env['machine'] == 'x86': @@ -94,11 +95,6 @@ if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows'): else: pass -if env['toolchain'] == 'crossmingw': - # compile these files without -gstabs option - glapi_sources = env.compile_without_gstabs(glapi_sources, "glapi_dispatch.c") - glapi_sources = env.compile_without_gstabs(glapi_sources, "glapi_getproc.c") - glapi = env.ConvenienceLibrary( target = 'glapi', source = glapi_sources, diff --git a/mesalib/src/mapi/glapi/gen/GL3x.xml b/mesalib/src/mapi/glapi/gen/GL3x.xml index c17a64402..5078f7b6d 100644 --- a/mesalib/src/mapi/glapi/gen/GL3x.xml +++ b/mesalib/src/mapi/glapi/gen/GL3x.xml @@ -424,26 +424,26 @@ - - + + - - + + - - + + - - + + @@ -607,7 +607,7 @@ - + diff --git a/mesalib/src/mapi/glapi/gen/Makefile.am b/mesalib/src/mapi/glapi/gen/Makefile.am index 36e47e21e..97200598e 100644 --- a/mesalib/src/mapi/glapi/gen/Makefile.am +++ b/mesalib/src/mapi/glapi/gen/Makefile.am @@ -20,7 +20,7 @@ XORG_INDENT_FLAGS = -linux -bad -bap -blf -bli0 -cbi0 -cdw -nce -cs -i4 -lc80 -p MESA_DIR = $(top_srcdir)/src/mesa MESA_GLAPI_DIR = $(top_srcdir)/src/mapi/glapi -MESA_MAPI_DIR = $(top_srcdir)/src/mapi/mapi +MESA_MAPI_DIR = $(top_srcdir)/src/mapi MESA_GLX_DIR = $(top_srcdir)/src/glx MESA_GLAPI_OUTPUTS = \ diff --git a/mesalib/src/mapi/glapi/gen/es_EXT.xml b/mesalib/src/mapi/glapi/gen/es_EXT.xml index ff378acf1..f412333df 100644 --- a/mesalib/src/mapi/glapi/gen/es_EXT.xml +++ b/mesalib/src/mapi/glapi/gen/es_EXT.xml @@ -689,22 +689,25 @@ - + + static_dispatch="false" es2="2.0"> - + - + @@ -779,7 +782,8 @@ - + @@ -787,7 +791,8 @@ - + @@ -815,8 +820,8 @@ - + @@ -825,7 +830,7 @@ + static_dispatch="false" es1="1.0" es2="2.0"> diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml index df9592477..f7257978f 100644 --- a/mesalib/src/mapi/glapi/gen/gl_API.xml +++ b/mesalib/src/mapi/glapi/gen/gl_API.xml @@ -5685,83 +5685,83 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + - + - + @@ -6004,44 +6004,44 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -7656,8 +7656,8 @@ - - + + diff --git a/mesalib/src/mapi/glapi/gen/gl_XML.py b/mesalib/src/mapi/glapi/gen/gl_XML.py index 227e9fcd9..3bbc79439 100644 --- a/mesalib/src/mapi/glapi/gen/gl_XML.py +++ b/mesalib/src/mapi/glapi/gen/gl_XML.py @@ -802,6 +802,8 @@ class gl_function( gl_item ): comma = "" for p in self.parameterIterator(): + if p.is_padding: + continue p_string = p_string + comma + p.name comma = ", " diff --git a/mesalib/src/mapi/glapi/gen/gl_enums.py b/mesalib/src/mapi/glapi/gen/gl_enums.py index 0bf8b0a9c..806d38445 100644 --- a/mesalib/src/mapi/glapi/gen/gl_enums.py +++ b/mesalib/src/mapi/glapi/gen/gl_enums.py @@ -43,7 +43,6 @@ class PrintGlEnums(gl_XML.gl_print_base): def printRealHeader(self): print '#include "main/glheader.h"' - print '#include "main/mfeatures.h"' print '#include "main/enums.h"' print '#include "main/imports.h"' print '#include "main/mtypes.h"' @@ -115,7 +114,7 @@ const char *_mesa_lookup_enum_by_nr( int nr ) /** * Primitive names */ -static const char *prim_names[PRIM_UNKNOWN + 1] = { +static const char *prim_names[PRIM_MAX+3] = { "GL_POINTS", "GL_LINES", "GL_LINE_LOOP", @@ -126,8 +125,11 @@ static const char *prim_names[PRIM_UNKNOWN + 1] = { "GL_QUADS", "GL_QUAD_STRIP", "GL_POLYGON", + "GL_LINES_ADJACENCY", + "GL_LINE_STRIP_ADJACENCY", + "GL_TRIANGLES_ADJACENCY", + "GL_TRIANGLE_STRIP_ADJACENCY", "outside begin/end", - "inside unknown primitive", "unknown state" }; diff --git a/mesalib/src/mapi/glapi/gen/gl_genexec.py b/mesalib/src/mapi/glapi/gen/gl_genexec.py index a85b4471a..e91d4e9ac 100644 --- a/mesalib/src/mapi/glapi/gen/gl_genexec.py +++ b/mesalib/src/mapi/glapi/gen/gl_genexec.py @@ -44,7 +44,6 @@ header = """/** */ -#include "main/mfeatures.h" #include "main/accum.h" #include "main/api_loopback.h" #include "main/api_exec.h" @@ -110,6 +109,7 @@ header = """/** #include "main/syncobj.h" #include "main/formatquery.h" #include "main/dispatch.h" +#include "vbo/vbo.h" /** @@ -129,6 +129,8 @@ _mesa_initialize_exec_table(struct gl_context *ctx) assert(exec != NULL); assert(ctx->Version > 0); + + vbo_initialize_exec_dispatch(ctx, exec); """ diff --git a/mesalib/src/mapi/glapi/gen/gl_table.py b/mesalib/src/mapi/glapi/gen/gl_table.py index 382eaafd9..fd384689f 100644 --- a/mesalib/src/mapi/glapi/gen/gl_table.py +++ b/mesalib/src/mapi/glapi/gen/gl_table.py @@ -97,12 +97,6 @@ class PrintRemapTable(gl_XML.gl_print_base): * can SET_FuncName, are used to get and set the dispatch pointer for the * named function in the specified dispatch table. */ - -/* GLXEXT is defined when building the GLX extension in the xserver. - */ -#if !defined(GLXEXT) -#include "main/mfeatures.h" -#endif """ return @@ -147,17 +141,6 @@ class PrintRemapTable(gl_XML.gl_print_base): for f, index in abi_functions: print '#define _gloffset_%s %d' % (f.name, f.offset) - print '' - print '#if !FEATURE_remap_table' - print '' - - for f, index in functions: - print '#define _gloffset_%s %d' % (f.name, f.offset) - - print '' - print '#else /* !FEATURE_remap_table */' - print '' - if self.es: remap_table = "esLocalRemapTable" @@ -180,8 +163,6 @@ class PrintRemapTable(gl_XML.gl_print_base): print '#define _gloffset_%s %s[%s_remap_index]' % (f.name, remap_table, f.name) print '' - print '#endif /* !FEATURE_remap_table */' - print '' for f, index in abi_functions + functions: arg_string = gl_XML.create_parameter_string( f.parameters, 0 ) @@ -209,12 +190,10 @@ class PrintRemapTable(gl_XML.gl_print_base): print '#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name) print '' - print '#if FEATURE_remap_table' for f in alias_functions: for name in f.entry_points: if name != f.name: print '#define %s_remap_index %s_remap_index' % (name, f.name) - print '#endif /* FEATURE_remap_table */' print '' return diff --git a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py index a3548c295..19e0e15b0 100644 --- a/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py +++ b/mesalib/src/mapi/glapi/gen/gl_x86-64_asm.py @@ -180,19 +180,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): def printRealFooter(self): - print '' - print '#if defined(GLX_USE_TLS) && defined(__linux__)' - print ' .section ".note.ABI-tag", "a"' - print ' .p2align 2' - print ' .long 1f - 0f /* name length */' - print ' .long 3f - 2f /* data length */' - print ' .long 1 /* note length */' - print '0: .asciz "GNU" /* vendor name */' - print '1: .p2align 2' - print '2: .long 0 /* note data: the ABI tag */' - print ' .long 2,4,20 /* Minimum kernel version w/TLS */' - print '3: .p2align 2 /* pad out section */' - print '#endif /* GLX_USE_TLS */' print '' print '#if defined (__ELF__) && defined (__linux__)' print ' .section .note.GNU-stack,"",%progbits' diff --git a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py index 8b0f6ee24..919bbc032 100644 --- a/mesalib/src/mapi/glapi/gen/gl_x86_asm.py +++ b/mesalib/src/mapi/glapi/gen/gl_x86_asm.py @@ -189,19 +189,6 @@ class PrintGenericStubs(gl_XML.gl_print_base): print '\t\tALIGNTEXT16' print 'GLNAME(gl_dispatch_functions_end):' print '' - print '#if defined(GLX_USE_TLS) && defined(__linux__)' - print ' .section ".note.ABI-tag", "a"' - print ' .p2align 2' - print ' .long 1f - 0f /* name length */' - print ' .long 3f - 2f /* data length */' - print ' .long 1 /* note length */' - print '0: .asciz "GNU" /* vendor name */' - print '1: .p2align 2' - print '2: .long 0 /* note data: the ABI tag */' - print ' .long 2,4,20 /* Minimum kernel version w/TLS */' - print '3: .p2align 2 /* pad out section */' - print '#endif /* GLX_USE_TLS */' - print '' print '#if defined (__ELF__) && defined (__linux__)' print ' .section .note.GNU-stack,"",%progbits' print '#endif' diff --git a/mesalib/src/mapi/glapi/gen/glapi_gen.mk b/mesalib/src/mapi/glapi/gen/glapi_gen.mk index f65286fbd..242ae5fd9 100644 --- a/mesalib/src/mapi/glapi/gen/glapi_gen.mk +++ b/mesalib/src/mapi/glapi/gen/glapi_gen.mk @@ -4,7 +4,7 @@ glapi_gen_common_deps := \ $(wildcard $(top_srcdir)/src/mapi/glapi/gen/*.xml) \ $(wildcard $(top_srcdir)/src/mapi/glapi/gen/*.py) -glapi_gen_mapi_script := $(top_srcdir)/src/mapi/mapi/mapi_abi.py +glapi_gen_mapi_script := $(top_srcdir)/src/mapi/mapi_abi.py glapi_gen_mapi_deps := \ $(glapi_gen_mapi_script) \ $(glapi_gen_common_deps) diff --git a/mesalib/src/mapi/glapi/gen/mesadef.py b/mesalib/src/mapi/glapi/gen/mesadef.py index 473baaee5..eefda7643 100644 --- a/mesalib/src/mapi/glapi/gen/mesadef.py +++ b/mesalib/src/mapi/glapi/gen/mesadef.py @@ -19,9 +19,10 @@ # 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. +# 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. # Generate the mesa.def file for Windows. diff --git a/mesalib/src/mapi/glapi/glapi.c b/mesalib/src/mapi/glapi/glapi.c index f7655c558..18a7d31a7 100644 --- a/mesalib/src/mapi/glapi/glapi.c +++ b/mesalib/src/mapi/glapi/glapi.c @@ -27,7 +27,7 @@ */ #include "glapi/glapi.h" -#include "mapi/u_current.h" +#include "u_current.h" /* * Global variables, _glapi_get_context, and _glapi_get_dispatch are defined in diff --git a/mesalib/src/mapi/glapi/glapi.h b/mesalib/src/mapi/glapi/glapi.h index f6854754b..bacc4c5f6 100644 --- a/mesalib/src/mapi/glapi/glapi.h +++ b/mesalib/src/mapi/glapi/glapi.h @@ -17,9 +17,10 @@ * 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. + * 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. */ diff --git a/mesalib/src/mapi/glapi/glapi_dispatch.c b/mesalib/src/mapi/glapi/glapi_dispatch.c index be65ebedd..7f8056242 100644 --- a/mesalib/src/mapi/glapi/glapi_dispatch.c +++ b/mesalib/src/mapi/glapi/glapi_dispatch.c @@ -17,9 +17,10 @@ * 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. + * 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. */ diff --git a/mesalib/src/mapi/glapi/glapi_entrypoint.c b/mesalib/src/mapi/glapi/glapi_entrypoint.c index 7a0eb3537..6b03548fe 100644 --- a/mesalib/src/mapi/glapi/glapi_entrypoint.c +++ b/mesalib/src/mapi/glapi/glapi_entrypoint.c @@ -17,9 +17,10 @@ * 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. + * 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. */ /** @@ -30,7 +31,7 @@ #include "glapi/glapi_priv.h" -#include "mapi/u_execmem.h" +#include "u_execmem.h" #ifdef USE_X86_ASM diff --git a/mesalib/src/mapi/glapi/glapi_getproc.c b/mesalib/src/mapi/glapi/glapi_getproc.c index f976d5808..3cbd68fda 100644 --- a/mesalib/src/mapi/glapi/glapi_getproc.c +++ b/mesalib/src/mapi/glapi/glapi_getproc.c @@ -17,9 +17,10 @@ * 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. + * 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. */ /** diff --git a/mesalib/src/mapi/glapi/glapi_nop.c b/mesalib/src/mapi/glapi/glapi_nop.c index 69b1ae6dd..bdd1786fe 100644 --- a/mesalib/src/mapi/glapi/glapi_nop.c +++ b/mesalib/src/mapi/glapi/glapi_nop.c @@ -18,9 +18,10 @@ * 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. + * 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. */ diff --git a/mesalib/src/mapi/glapi/glapi_priv.h b/mesalib/src/mapi/glapi/glapi_priv.h index 3ab553a2b..ea32f302f 100644 --- a/mesalib/src/mapi/glapi/glapi_priv.h +++ b/mesalib/src/mapi/glapi/glapi_priv.h @@ -17,9 +17,10 @@ * 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. + * 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. */ diff --git a/mesalib/src/mapi/glapi/glthread.h b/mesalib/src/mapi/glapi/glthread.h index 1c3f4e2bf..2399abb2b 100644 --- a/mesalib/src/mapi/glapi/glthread.h +++ b/mesalib/src/mapi/glapi/glthread.h @@ -1,7 +1,7 @@ #ifndef GLTHREAD_H #define GLTHREAD_H -#include "mapi/u_thread.h" +#include "u_thread.h" #ifdef __cplusplus extern "C" { diff --git a/mesalib/src/mapi/glapi/sources.mak b/mesalib/src/mapi/glapi/sources.mak deleted file mode 100644 index aa8a4d40a..000000000 --- a/mesalib/src/mapi/glapi/sources.mak +++ /dev/null @@ -1,19 +0,0 @@ -# src/mapi/glapi/sources.mak - -GLAPI_SOURCES = \ - glapi_dispatch.c \ - glapi_entrypoint.c \ - glapi_gentable.c \ - glapi_getproc.c \ - glapi_nop.c \ - glthread.c \ - glapi.c - -X86_API = \ - glapi_x86.S - -X86_64_API = \ - glapi_x86-64.S - -SPARC_API = \ - glapi_sparc.S diff --git a/mesalib/src/mapi/mapi.c b/mesalib/src/mapi/mapi.c new file mode 100644 index 000000000..b471c40b1 --- /dev/null +++ b/mesalib/src/mapi/mapi.c @@ -0,0 +1,191 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include +#include + +#include "u_current.h" +#include "u_thread.h" +#include "mapi.h" +#include "stub.h" +#include "table.h" + +/* dynamic stubs will run out before this array */ +static const struct mapi_stub *mapi_stub_map[MAPI_TABLE_NUM_SLOTS]; +static int mapi_num_stubs; + +static const struct mapi_stub * +get_stub(const char *name, const struct mapi_stub *alias) +{ + const struct mapi_stub *stub; + + stub = stub_find_public(name); + if (!stub) { + struct mapi_stub *dyn = stub_find_dynamic(name, 1); + if (dyn) { + stub_fix_dynamic(dyn, alias); + stub = dyn; + } + } + + return stub; +} + +/** + * Initialize mapi. spec consists of NULL-separated strings. The first string + * denotes the version. It is followed by variable numbers of entries. Each + * entry can have multiple names. An empty name terminates an entry. An empty + * entry terminates the spec. A spec of two entries, Foo and Bar, is as + * follows + * + * "1\0" + * "Foo\0" + * "FooEXT\0" + * "\0" + * "Bar\0" + * "\0" + */ +void +mapi_init(const char *spec) +{ + u_mutex_declare_static(mutex); + const char *p; + int ver, count; + + u_mutex_lock(mutex); + + /* already initialized */ + if (mapi_num_stubs) { + u_mutex_unlock(mutex); + return; + } + + count = 0; + p = spec; + + /* parse version string */ + ver = atoi(p); + if (ver != 1) { + u_mutex_unlock(mutex); + return; + } + p += strlen(p) + 1; + + while (*p) { + const struct mapi_stub *stub; + + stub = get_stub(p, NULL); + /* out of dynamic entries */ + if (!stub) + break; + p += strlen(p) + 1; + + while (*p) { + get_stub(p, stub); + p += strlen(p) + 1; + } + + mapi_stub_map[count++] = stub; + p++; + } + + mapi_num_stubs = count; + + u_mutex_unlock(mutex); +} + +/** + * Return the address of an entry. Optionally generate the entry if it does + * not exist. + */ +mapi_proc +mapi_get_proc_address(const char *name) +{ + const struct mapi_stub *stub; + + stub = stub_find_public(name); + if (!stub) + stub = stub_find_dynamic(name, 0); + + return (stub) ? (mapi_proc) stub_get_addr(stub) : NULL; +} + +/** + * Create a dispatch table. + */ +struct mapi_table * +mapi_table_create(void) +{ + const struct mapi_table *noop = table_get_noop(); + struct mapi_table *tbl; + + tbl = malloc(MAPI_TABLE_SIZE); + if (tbl) + memcpy(tbl, noop, MAPI_TABLE_SIZE); + + return tbl; +} + +/** + * Destroy a dispatch table. + */ +void +mapi_table_destroy(struct mapi_table *tbl) +{ + free(tbl); +} + +/** + * Fill a dispatch table. The order of the procs is determined when mapi_init + * is called. + */ +void +mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs) +{ + const struct mapi_table *noop = table_get_noop(); + int i; + + for (i = 0; i < mapi_num_stubs; i++) { + const struct mapi_stub *stub = mapi_stub_map[i]; + int slot = stub_get_slot(stub); + mapi_func func = (mapi_func) procs[i]; + + if (!func) + func = table_get_func(noop, slot); + table_set_func(tbl, slot, func); + } +} + +/** + * Make a dispatch table current. + */ +void +mapi_table_make_current(const struct mapi_table *tbl) +{ + u_current_set(tbl); +} diff --git a/mesalib/src/mapi/mapi.h b/mesalib/src/mapi/mapi.h new file mode 100644 index 000000000..c7e43e22e --- /dev/null +++ b/mesalib/src/mapi/mapi.h @@ -0,0 +1,66 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _MAPI_H_ +#define _MAPI_H_ + +#include "u_compiler.h" + +#ifdef _WIN32 +#ifdef MAPI_DLL_EXPORTS +#define MAPI_EXPORT __declspec(dllexport) +#else +#define MAPI_EXPORT __declspec(dllimport) +#endif +#else /* _WIN32 */ +#define MAPI_EXPORT PUBLIC +#endif + +typedef void (*mapi_proc)(void); + +struct mapi_table; + +MAPI_EXPORT void +mapi_init(const char *spec); + +MAPI_EXPORT mapi_proc +mapi_get_proc_address(const char *name); + +MAPI_EXPORT struct mapi_table * +mapi_table_create(void); + +MAPI_EXPORT void +mapi_table_destroy(struct mapi_table *tbl); + +MAPI_EXPORT void +mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs); + +MAPI_EXPORT void +mapi_table_make_current(const struct mapi_table *tbl); + +#endif /* _MAPI_H_ */ diff --git a/mesalib/src/mapi/mapi/entry.c b/mesalib/src/mapi/mapi/entry.c deleted file mode 100644 index 3d9168a72..000000000 --- a/mesalib/src/mapi/mapi/entry.c +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include "entry.h" -#include "u_current.h" -#include "u_macros.h" - -/* define macros for use by assembly dispatchers */ -#define ENTRY_CURRENT_TABLE U_STRINGIFY(u_current_table) - -/* in bridge mode, mapi is a user of glapi */ -#ifdef MAPI_MODE_BRIDGE -#define ENTRY_CURRENT_TABLE_GET "_glapi_get_dispatch" -#else -#define ENTRY_CURRENT_TABLE_GET U_STRINGIFY(u_current_get_internal) -#endif - -#if defined(USE_X86_ASM) && defined(__GNUC__) -# ifdef GLX_USE_TLS -# include "entry_x86_tls.h" -# else -# include "entry_x86_tsd.h" -# endif -#elif defined(USE_X86_64_ASM) && defined(__GNUC__) && defined(GLX_USE_TLS) -# include "entry_x86-64_tls.h" -#else - -#include - -static INLINE const struct mapi_table * -entry_current_get(void) -{ -#ifdef MAPI_MODE_BRIDGE - return GET_DISPATCH(); -#else - return u_current_get(); -#endif -} - -/* C version of the public entries */ -#define MAPI_TMP_DEFINES -#define MAPI_TMP_PUBLIC_DECLARES -#define MAPI_TMP_PUBLIC_ENTRIES -#include "mapi_tmp.h" - -#ifndef MAPI_MODE_BRIDGE - -void -entry_patch_public(void) -{ -} - -mapi_func -entry_get_public(int slot) -{ - /* pubic_entries are defined by MAPI_TMP_PUBLIC_ENTRIES */ - return public_entries[slot]; -} - -mapi_func -entry_generate(int slot) -{ - return NULL; -} - -void -entry_patch(mapi_func entry, int slot) -{ -} - -#endif /* MAPI_MODE_BRIDGE */ - -#endif /* asm */ diff --git a/mesalib/src/mapi/mapi/entry.h b/mesalib/src/mapi/mapi/entry.h deleted file mode 100644 index 9df810004..000000000 --- a/mesalib/src/mapi/mapi/entry.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#ifndef _ENTRY_H_ -#define _ENTRY_H_ - -#include "u_compiler.h" - -typedef void (*mapi_func)(void); - -void -entry_patch_public(void); - -mapi_func -entry_get_public(int slot); - -mapi_func -entry_generate(int slot); - -void -entry_patch(mapi_func entry, int slot); - -#endif /* _ENTRY_H_ */ diff --git a/mesalib/src/mapi/mapi/entry_x86-64_tls.h b/mesalib/src/mapi/mapi/entry_x86-64_tls.h deleted file mode 100644 index 72d4125a6..000000000 --- a/mesalib/src/mapi/mapi/entry_x86-64_tls.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include "u_macros.h" - -#ifdef __linux__ -__asm__(".section .note.ABI-tag, \"a\"\n\t" - ".p2align 2\n\t" - ".long 1f - 0f\n\t" /* name length */ - ".long 3f - 2f\n\t" /* data length */ - ".long 1\n\t" /* note length */ - "0: .asciz \"GNU\"\n\t" /* vendor name */ - "1: .p2align 2\n\t" - "2: .long 0\n\t" /* note data: the ABI tag */ - ".long 2,4,20\n\t" /* Minimum kernel version w/TLS */ - "3: .p2align 2\n\t"); /* pad out section */ -#endif /* __linux__ */ - -__asm__(".text\n" - ".balign 32\n" - "x86_64_entry_start:"); - -#define STUB_ASM_ENTRY(func) \ - ".globl " func "\n" \ - ".type " func ", @function\n" \ - ".balign 32\n" \ - func ":" - -#define STUB_ASM_CODE(slot) \ - "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t" \ - "movq %fs:(%rax), %r11\n\t" \ - "jmp *(8 * " slot ")(%r11)" - -#define MAPI_TMP_STUB_ASM_GCC -#include "mapi_tmp.h" - -#ifndef MAPI_MODE_BRIDGE - -__asm__("x86_64_current_tls:\n\t" - "movq " ENTRY_CURRENT_TABLE "@GOTTPOFF(%rip), %rax\n\t" - "ret"); - -extern unsigned long -x86_64_current_tls(); - -#include -#include "u_execmem.h" - -void -entry_patch_public(void) -{ -} - -static char -x86_64_entry_start[]; - -mapi_func -entry_get_public(int slot) -{ - return (mapi_func) (x86_64_entry_start + slot * 32); -} - -void -entry_patch(mapi_func entry, int slot) -{ - char *code = (char *) entry; - *((unsigned int *) (code + 12)) = slot * sizeof(mapi_func); -} - -mapi_func -entry_generate(int slot) -{ - const char code_templ[16] = { - /* movq %fs:0, %r11 */ - 0x64, 0x4c, 0x8b, 0x1c, 0x25, 0x00, 0x00, 0x00, 0x00, - /* jmp *0x1234(%r11) */ - 0x41, 0xff, 0xa3, 0x34, 0x12, 0x00, 0x00, - }; - unsigned long addr; - void *code; - mapi_func entry; - - addr = x86_64_current_tls(); - if ((addr >> 32) != 0xffffffff) - return NULL; - addr &= 0xffffffff; - - code = u_execmem_alloc(sizeof(code_templ)); - if (!code) - return NULL; - - memcpy(code, code_templ, sizeof(code_templ)); - - *((unsigned int *) (code + 5)) = addr; - entry = (mapi_func) code; - entry_patch(entry, slot); - - return entry; -} - -#endif /* MAPI_MODE_BRIDGE */ diff --git a/mesalib/src/mapi/mapi/entry_x86_tls.h b/mesalib/src/mapi/mapi/entry_x86_tls.h deleted file mode 100644 index de918128e..000000000 --- a/mesalib/src/mapi/mapi/entry_x86_tls.h +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include -#include "u_macros.h" - -#ifdef __linux__ -__asm__(".section .note.ABI-tag, \"a\"\n\t" - ".p2align 2\n\t" - ".long 1f - 0f\n\t" /* name length */ - ".long 3f - 2f\n\t" /* data length */ - ".long 1\n\t" /* note length */ - "0: .asciz \"GNU\"\n\t" /* vendor name */ - "1: .p2align 2\n\t" - "2: .long 0\n\t" /* note data: the ABI tag */ - ".long 2,4,20\n\t" /* Minimum kernel version w/TLS */ - "3: .p2align 2\n\t"); /* pad out section */ -#endif /* __linux__ */ - -__asm__(".text"); - -__asm__("x86_current_tls:\n\t" - "call 1f\n" - "1:\n\t" - "popl %eax\n\t" - "addl $_GLOBAL_OFFSET_TABLE_+[.-1b], %eax\n\t" - "movl " ENTRY_CURRENT_TABLE "@GOTNTPOFF(%eax), %eax\n\t" - "ret"); - -#ifndef GLX_X86_READONLY_TEXT -__asm__(".section wtext, \"awx\", @progbits"); -#endif /* GLX_X86_READONLY_TEXT */ - -__asm__(".balign 16\n" - "x86_entry_start:"); - -#define STUB_ASM_ENTRY(func) \ - ".globl " func "\n" \ - ".type " func ", @function\n" \ - ".balign 16\n" \ - func ":" - -#define STUB_ASM_CODE(slot) \ - "call x86_current_tls\n\t" \ - "movl %gs:(%eax), %eax\n\t" \ - "jmp *(4 * " slot ")(%eax)" - -#define MAPI_TMP_STUB_ASM_GCC -#include "mapi_tmp.h" - -#ifndef GLX_X86_READONLY_TEXT -__asm__(".balign 16\n" - "x86_entry_end:"); -__asm__(".text"); -#endif /* GLX_X86_READONLY_TEXT */ - -#ifndef MAPI_MODE_BRIDGE - -#include "u_execmem.h" - -extern unsigned long -x86_current_tls(); - -static char x86_entry_start[]; -static char x86_entry_end[]; - -void -entry_patch_public(void) -{ -#ifndef GLX_X86_READONLY_TEXT - char patch[8] = { - 0x65, 0xa1, 0x00, 0x00, 0x00, 0x00, /* movl %gs:0x0, %eax */ - 0x90, 0x90 /* nop's */ - }; - char *entry; - - *((unsigned long *) (patch + 2)) = x86_current_tls(); - - for (entry = x86_entry_start; entry < x86_entry_end; entry += 16) - memcpy(entry, patch, sizeof(patch)); -#endif -} - -mapi_func -entry_get_public(int slot) -{ - return (mapi_func) (x86_entry_start + slot * 16); -} - -void -entry_patch(mapi_func entry, int slot) -{ - char *code = (char *) entry; - *((unsigned long *) (code + 8)) = slot * sizeof(mapi_func); -} - -mapi_func -entry_generate(int slot) -{ - const char code_templ[16] = { - 0x65, 0xa1, 0x00, 0x00, 0x00, 0x00, /* movl %gs:0x0, %eax */ - 0xff, 0xa0, 0x34, 0x12, 0x00, 0x00, /* jmp *0x1234(%eax) */ - 0x90, 0x90, 0x90, 0x90 /* nop's */ - }; - void *code; - mapi_func entry; - - code = u_execmem_alloc(sizeof(code_templ)); - if (!code) - return NULL; - - memcpy(code, code_templ, sizeof(code_templ)); - - *((unsigned long *) (code + 2)) = x86_current_tls(); - entry = (mapi_func) code; - entry_patch(entry, slot); - - return entry; -} - -#endif /* MAPI_MODE_BRIDGE */ diff --git a/mesalib/src/mapi/mapi/entry_x86_tsd.h b/mesalib/src/mapi/mapi/entry_x86_tsd.h deleted file mode 100644 index c479c199e..000000000 --- a/mesalib/src/mapi/mapi/entry_x86_tsd.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include "u_macros.h" - -#define X86_ENTRY_SIZE 32 - -__asm__(".text\n" - ".balign 32\n" - "x86_entry_start:"); - -#define STUB_ASM_ENTRY(func) \ - ".globl " func "\n" \ - ".type " func ", @function\n" \ - ".balign 32\n" \ - func ":" - -#define STUB_ASM_CODE(slot) \ - "movl " ENTRY_CURRENT_TABLE ", %eax\n\t" \ - "testl %eax, %eax\n\t" \ - "je 1f\n\t" \ - "jmp *(4 * " slot ")(%eax)\n" \ - "1:\n\t" \ - "call " ENTRY_CURRENT_TABLE_GET "\n\t" \ - "jmp *(4 * " slot ")(%eax)" - -#define MAPI_TMP_STUB_ASM_GCC -#include "mapi_tmp.h" - -#ifndef MAPI_MODE_BRIDGE - -__asm__(".balign 32\n" - "x86_entry_end:"); - -#include -#include "u_execmem.h" - -static const char x86_entry_start[]; -static const char x86_entry_end[]; - -void -entry_patch_public(void) -{ -} - -mapi_func -entry_get_public(int slot) -{ - return (mapi_func) (x86_entry_start + slot * X86_ENTRY_SIZE); -} - -void -entry_patch(mapi_func entry, int slot) -{ - char *code = (char *) entry; - - *((unsigned long *) (code + 11)) = slot * sizeof(mapi_func); - *((unsigned long *) (code + 22)) = slot * sizeof(mapi_func); -} - -mapi_func -entry_generate(int slot) -{ - const char *code_templ = x86_entry_end - X86_ENTRY_SIZE; - void *code; - mapi_func entry; - - code = u_execmem_alloc(X86_ENTRY_SIZE); - if (!code) - return NULL; - - memcpy(code, code_templ, X86_ENTRY_SIZE); - entry = (mapi_func) code; - entry_patch(entry, slot); - - return entry; -} - -#endif /* MAPI_MODE_BRIDGE */ diff --git a/mesalib/src/mapi/mapi/mapi.c b/mesalib/src/mapi/mapi/mapi.c deleted file mode 100644 index b471c40b1..000000000 --- a/mesalib/src/mapi/mapi/mapi.c +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include -#include - -#include "u_current.h" -#include "u_thread.h" -#include "mapi.h" -#include "stub.h" -#include "table.h" - -/* dynamic stubs will run out before this array */ -static const struct mapi_stub *mapi_stub_map[MAPI_TABLE_NUM_SLOTS]; -static int mapi_num_stubs; - -static const struct mapi_stub * -get_stub(const char *name, const struct mapi_stub *alias) -{ - const struct mapi_stub *stub; - - stub = stub_find_public(name); - if (!stub) { - struct mapi_stub *dyn = stub_find_dynamic(name, 1); - if (dyn) { - stub_fix_dynamic(dyn, alias); - stub = dyn; - } - } - - return stub; -} - -/** - * Initialize mapi. spec consists of NULL-separated strings. The first string - * denotes the version. It is followed by variable numbers of entries. Each - * entry can have multiple names. An empty name terminates an entry. An empty - * entry terminates the spec. A spec of two entries, Foo and Bar, is as - * follows - * - * "1\0" - * "Foo\0" - * "FooEXT\0" - * "\0" - * "Bar\0" - * "\0" - */ -void -mapi_init(const char *spec) -{ - u_mutex_declare_static(mutex); - const char *p; - int ver, count; - - u_mutex_lock(mutex); - - /* already initialized */ - if (mapi_num_stubs) { - u_mutex_unlock(mutex); - return; - } - - count = 0; - p = spec; - - /* parse version string */ - ver = atoi(p); - if (ver != 1) { - u_mutex_unlock(mutex); - return; - } - p += strlen(p) + 1; - - while (*p) { - const struct mapi_stub *stub; - - stub = get_stub(p, NULL); - /* out of dynamic entries */ - if (!stub) - break; - p += strlen(p) + 1; - - while (*p) { - get_stub(p, stub); - p += strlen(p) + 1; - } - - mapi_stub_map[count++] = stub; - p++; - } - - mapi_num_stubs = count; - - u_mutex_unlock(mutex); -} - -/** - * Return the address of an entry. Optionally generate the entry if it does - * not exist. - */ -mapi_proc -mapi_get_proc_address(const char *name) -{ - const struct mapi_stub *stub; - - stub = stub_find_public(name); - if (!stub) - stub = stub_find_dynamic(name, 0); - - return (stub) ? (mapi_proc) stub_get_addr(stub) : NULL; -} - -/** - * Create a dispatch table. - */ -struct mapi_table * -mapi_table_create(void) -{ - const struct mapi_table *noop = table_get_noop(); - struct mapi_table *tbl; - - tbl = malloc(MAPI_TABLE_SIZE); - if (tbl) - memcpy(tbl, noop, MAPI_TABLE_SIZE); - - return tbl; -} - -/** - * Destroy a dispatch table. - */ -void -mapi_table_destroy(struct mapi_table *tbl) -{ - free(tbl); -} - -/** - * Fill a dispatch table. The order of the procs is determined when mapi_init - * is called. - */ -void -mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs) -{ - const struct mapi_table *noop = table_get_noop(); - int i; - - for (i = 0; i < mapi_num_stubs; i++) { - const struct mapi_stub *stub = mapi_stub_map[i]; - int slot = stub_get_slot(stub); - mapi_func func = (mapi_func) procs[i]; - - if (!func) - func = table_get_func(noop, slot); - table_set_func(tbl, slot, func); - } -} - -/** - * Make a dispatch table current. - */ -void -mapi_table_make_current(const struct mapi_table *tbl) -{ - u_current_set(tbl); -} diff --git a/mesalib/src/mapi/mapi/mapi.h b/mesalib/src/mapi/mapi/mapi.h deleted file mode 100644 index c7e43e22e..000000000 --- a/mesalib/src/mapi/mapi/mapi.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#ifndef _MAPI_H_ -#define _MAPI_H_ - -#include "u_compiler.h" - -#ifdef _WIN32 -#ifdef MAPI_DLL_EXPORTS -#define MAPI_EXPORT __declspec(dllexport) -#else -#define MAPI_EXPORT __declspec(dllimport) -#endif -#else /* _WIN32 */ -#define MAPI_EXPORT PUBLIC -#endif - -typedef void (*mapi_proc)(void); - -struct mapi_table; - -MAPI_EXPORT void -mapi_init(const char *spec); - -MAPI_EXPORT mapi_proc -mapi_get_proc_address(const char *name); - -MAPI_EXPORT struct mapi_table * -mapi_table_create(void); - -MAPI_EXPORT void -mapi_table_destroy(struct mapi_table *tbl); - -MAPI_EXPORT void -mapi_table_fill(struct mapi_table *tbl, const mapi_proc *procs); - -MAPI_EXPORT void -mapi_table_make_current(const struct mapi_table *tbl); - -#endif /* _MAPI_H_ */ diff --git a/mesalib/src/mapi/mapi/mapi_abi.py b/mesalib/src/mapi/mapi/mapi_abi.py deleted file mode 100644 index c645c02f9..000000000 --- a/mesalib/src/mapi/mapi/mapi_abi.py +++ /dev/null @@ -1,873 +0,0 @@ -#!/usr/bin/env python - -# Mesa 3-D graphics library -# Version: 7.9 -# -# Copyright (C) 2010 LunarG Inc. -# -# 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -# DEALINGS IN THE SOFTWARE. -# -# Authors: -# Chia-I Wu - -import sys -# make it possible to import glapi -import os -GLAPI = os.path.join(".", os.path.dirname(sys.argv[0]), "../glapi/gen") -sys.path.append(GLAPI) - -import re -from optparse import OptionParser -import gl_XML -import glX_XML - - -# number of dynamic entries -ABI_NUM_DYNAMIC_ENTRIES = 256 - -class ABIEntry(object): - """Represent an ABI entry.""" - - _match_c_param = re.compile( - '^(?P[\w\s*]+?)(?P\w+)(\[(?P\d+)\])?$') - - def __init__(self, cols, attrs, xml_data = None): - self._parse(cols) - - self.slot = attrs['slot'] - self.hidden = attrs['hidden'] - self.alias = attrs['alias'] - self.handcode = attrs['handcode'] - self.xml_data = xml_data - - def c_prototype(self): - return '%s %s(%s)' % (self.c_return(), self.name, self.c_params()) - - def c_return(self): - ret = self.ret - if not ret: - ret = 'void' - - return ret - - def c_params(self): - """Return the parameter list used in the entry prototype.""" - c_params = [] - for t, n, a in self.params: - sep = '' if t.endswith('*') else ' ' - arr = '[%d]' % a if a else '' - c_params.append(t + sep + n + arr) - if not c_params: - c_params.append('void') - - return ", ".join(c_params) - - def c_args(self): - """Return the argument list used in the entry invocation.""" - c_args = [] - for t, n, a in self.params: - c_args.append(n) - - return ", ".join(c_args) - - def _parse(self, cols): - ret = cols.pop(0) - if ret == 'void': - ret = None - - name = cols.pop(0) - - params = [] - if not cols: - raise Exception(cols) - elif len(cols) == 1 and cols[0] == 'void': - pass - else: - for val in cols: - params.append(self._parse_param(val)) - - self.ret = ret - self.name = name - self.params = params - - def _parse_param(self, c_param): - m = self._match_c_param.match(c_param) - if not m: - raise Exception('unrecognized param ' + c_param) - - c_type = m.group('type').strip() - c_name = m.group('name') - c_array = m.group('array') - c_array = int(c_array) if c_array else 0 - - return (c_type, c_name, c_array) - - def __str__(self): - return self.c_prototype() - - def __cmp__(self, other): - # compare slot, alias, and then name - res = cmp(self.slot, other.slot) - if not res: - if not self.alias: - res = -1 - elif not other.alias: - res = 1 - - if not res: - res = cmp(self.name, other.name) - - return res - -def abi_parse_xml(xml): - """Parse a GLAPI XML file for ABI entries.""" - api = gl_XML.parse_GL_API(xml, glX_XML.glx_item_factory()) - - entry_dict = {} - for func in api.functionIterateByOffset(): - # make sure func.name appear first - entry_points = func.entry_points[:] - entry_points.remove(func.name) - entry_points.insert(0, func.name) - - for name in entry_points: - attrs = { - 'slot': func.offset, - 'hidden': not func.is_static_entry_point(name), - 'alias': None if name == func.name else func.name, - 'handcode': bool(func.has_different_protocol(name)), - } - - # post-process attrs - if attrs['alias']: - try: - alias = entry_dict[attrs['alias']] - except KeyError: - raise Exception('failed to alias %s' % attrs['alias']) - if alias.alias: - raise Exception('recursive alias %s' % ent.name) - attrs['alias'] = alias - if attrs['handcode']: - attrs['handcode'] = func.static_glx_name(name) - else: - attrs['handcode'] = None - - if entry_dict.has_key(name): - raise Exception('%s is duplicated' % (name)) - - cols = [] - cols.append(func.return_type) - cols.append(name) - params = func.get_parameter_string(name) - cols.extend([p.strip() for p in params.split(',')]) - - ent = ABIEntry(cols, attrs, func) - entry_dict[ent.name] = ent - - entries = entry_dict.values() - entries.sort() - - return entries - -def abi_parse_line(line): - cols = [col.strip() for col in line.split(',')] - - attrs = { - 'slot': -1, - 'hidden': False, - 'alias': None, - 'handcode': None, - } - - # extract attributes from the first column - vals = cols[0].split(':') - while len(vals) > 1: - val = vals.pop(0) - if val.startswith('slot='): - attrs['slot'] = int(val[5:]) - elif val == 'hidden': - attrs['hidden'] = True - elif val.startswith('alias='): - attrs['alias'] = val[6:] - elif val.startswith('handcode='): - attrs['handcode'] = val[9:] - elif not val: - pass - else: - raise Exception('unknown attribute %s' % val) - cols[0] = vals[0] - - return (attrs, cols) - -def abi_parse(filename): - """Parse a CSV file for ABI entries.""" - fp = open(filename) if filename != '-' else sys.stdin - lines = [line.strip() for line in fp.readlines() - if not line.startswith('#') and line.strip()] - - entry_dict = {} - next_slot = 0 - for line in lines: - attrs, cols = abi_parse_line(line) - - # post-process attributes - if attrs['alias']: - try: - alias = entry_dict[attrs['alias']] - except KeyError: - raise Exception('failed to alias %s' % attrs['alias']) - if alias.alias: - raise Exception('recursive alias %s' % ent.name) - slot = alias.slot - attrs['alias'] = alias - else: - slot = next_slot - next_slot += 1 - - if attrs['slot'] < 0: - attrs['slot'] = slot - elif attrs['slot'] != slot: - raise Exception('invalid slot in %s' % (line)) - - ent = ABIEntry(cols, attrs) - if entry_dict.has_key(ent.name): - raise Exception('%s is duplicated' % (ent.name)) - entry_dict[ent.name] = ent - - entries = entry_dict.values() - entries.sort() - - return entries - -def abi_sanity_check(entries): - if not entries: - return - - all_names = [] - last_slot = entries[-1].slot - i = 0 - for slot in xrange(last_slot + 1): - if entries[i].slot != slot: - raise Exception('entries are not ordered by slots') - if entries[i].alias: - raise Exception('first entry of slot %d aliases %s' - % (slot, entries[i].alias.name)) - handcode = None - while i < len(entries) and entries[i].slot == slot: - ent = entries[i] - if not handcode and ent.handcode: - handcode = ent.handcode - elif ent.handcode != handcode: - raise Exception('two aliases with handcode %s != %s', - ent.handcode, handcode) - - if ent.name in all_names: - raise Exception('%s is duplicated' % (ent.name)) - if ent.alias and ent.alias.name not in all_names: - raise Exception('failed to alias %s' % (ent.alias.name)) - all_names.append(ent.name) - i += 1 - if i < len(entries): - raise Exception('there are %d invalid entries' % (len(entries) - 1)) - -class ABIPrinter(object): - """MAPI Printer""" - - def __init__(self, entries): - self.entries = entries - - # sort entries by their names - self.entries_sorted_by_names = self.entries[:] - self.entries_sorted_by_names.sort(lambda x, y: cmp(x.name, y.name)) - - self.indent = ' ' * 3 - self.noop_warn = 'noop_warn' - self.noop_generic = 'noop_generic' - self.current_get = 'entry_current_get' - - self.api_defines = [] - self.api_headers = ['"KHR/khrplatform.h"'] - self.api_call = 'KHRONOS_APICALL' - self.api_entry = 'KHRONOS_APIENTRY' - self.api_attrs = 'KHRONOS_APIATTRIBUTES' - - self.c_header = '' - - self.lib_need_table_size = True - self.lib_need_noop_array = True - self.lib_need_stubs = True - self.lib_need_all_entries = True - self.lib_need_non_hidden_entries = False - - def c_notice(self): - return '/* This file is automatically generated by mapi_abi.py. Do not modify. */' - - def c_public_includes(self): - """Return includes of the client API headers.""" - defines = ['#define ' + d for d in self.api_defines] - includes = ['#include ' + h for h in self.api_headers] - return "\n".join(defines + includes) - - def need_entry_point(self, ent): - """Return True if an entry point is needed for the entry.""" - # non-handcode hidden aliases may share the entry they alias - use_alias = (ent.hidden and ent.alias and not ent.handcode) - return not use_alias - - def c_public_declarations(self, prefix): - """Return the declarations of public entry points.""" - decls = [] - for ent in self.entries: - if not self.need_entry_point(ent): - continue - export = self.api_call if not ent.hidden else '' - decls.append(self._c_decl(ent, prefix, True, export) + ';') - - return "\n".join(decls) - - def c_mapi_table(self): - """Return defines of the dispatch table size.""" - num_static_entries = self.entries[-1].slot + 1 - return ('#define MAPI_TABLE_NUM_STATIC %d\n' + \ - '#define MAPI_TABLE_NUM_DYNAMIC %d') % ( - num_static_entries, ABI_NUM_DYNAMIC_ENTRIES) - - def c_mapi_table_initializer(self, prefix): - """Return the array initializer for mapi_table_fill.""" - entries = [self._c_function(ent, prefix) - for ent in self.entries if not ent.alias] - pre = self.indent + '(mapi_proc) ' - return pre + (',\n' + pre).join(entries) - - def c_mapi_table_spec(self): - """Return the spec for mapi_init.""" - specv1 = [] - line = '"1' - for ent in self.entries: - if not ent.alias: - line += '\\0"\n' - specv1.append(line) - line = '"' - line += '%s\\0' % ent.name - line += '";' - specv1.append(line) - - return self.indent + self.indent.join(specv1) - - def _c_function(self, ent, prefix, mangle=False, stringify=False): - """Return the function name of an entry.""" - formats = { - True: { True: '%s_STR(%s)', False: '%s(%s)' }, - False: { True: '"%s%s"', False: '%s%s' }, - } - fmt = formats[prefix.isupper()][stringify] - name = ent.name - if mangle and ent.hidden: - name = '_dispatch_stub_' + str(ent.slot) - return fmt % (prefix, name) - - def _c_function_call(self, ent, prefix): - """Return the function name used for calling.""" - if ent.handcode: - # _c_function does not handle this case - formats = { True: '%s(%s)', False: '%s%s' } - fmt = formats[prefix.isupper()] - name = fmt % (prefix, ent.handcode) - elif self.need_entry_point(ent): - name = self._c_function(ent, prefix, True) - else: - name = self._c_function(ent.alias, prefix, True) - return name - - def _c_decl(self, ent, prefix, mangle=False, export=''): - """Return the C declaration for the entry.""" - decl = '%s %s %s(%s)' % (ent.c_return(), self.api_entry, - self._c_function(ent, prefix, mangle), ent.c_params()) - if export: - decl = export + ' ' + decl - if self.api_attrs: - decl += ' ' + self.api_attrs - - return decl - - def _c_cast(self, ent): - """Return the C cast for the entry.""" - cast = '%s (%s *)(%s)' % ( - ent.c_return(), self.api_entry, ent.c_params()) - - return cast - - def c_private_declarations(self, prefix): - """Return the declarations of private functions.""" - decls = [self._c_decl(ent, prefix) + ';' - for ent in self.entries if not ent.alias] - - return "\n".join(decls) - - def c_public_dispatches(self, prefix, no_hidden): - """Return the public dispatch functions.""" - dispatches = [] - for ent in self.entries: - if ent.hidden and no_hidden: - continue - - if not self.need_entry_point(ent): - continue - - export = self.api_call if not ent.hidden else '' - - proto = self._c_decl(ent, prefix, True, export) - cast = self._c_cast(ent) - - ret = '' - if ent.ret: - ret = 'return ' - stmt1 = self.indent - stmt1 += 'const struct mapi_table *_tbl = %s();' % ( - self.current_get) - stmt2 = self.indent - stmt2 += 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % ( - ent.slot) - stmt3 = self.indent - stmt3 += '%s((%s) _func)(%s);' % (ret, cast, ent.c_args()) - - disp = '%s\n{\n%s\n%s\n%s\n}' % (proto, stmt1, stmt2, stmt3) - - if ent.handcode: - disp = '#if 0\n' + disp + '\n#endif' - - dispatches.append(disp) - - return '\n\n'.join(dispatches) - - def c_public_initializer(self, prefix): - """Return the initializer for public dispatch functions.""" - names = [] - for ent in self.entries: - if ent.alias: - continue - - name = '%s(mapi_func) %s' % (self.indent, - self._c_function_call(ent, prefix)) - names.append(name) - - return ',\n'.join(names) - - def c_stub_string_pool(self): - """Return the string pool for use by stubs.""" - # sort entries by their names - sorted_entries = self.entries[:] - sorted_entries.sort(lambda x, y: cmp(x.name, y.name)) - - pool = [] - offsets = {} - count = 0 - for ent in sorted_entries: - offsets[ent] = count - pool.append('%s' % (ent.name)) - count += len(ent.name) + 1 - - pool_str = self.indent + '"' + \ - ('\\0"\n' + self.indent + '"').join(pool) + '";' - return (pool_str, offsets) - - def c_stub_initializer(self, prefix, pool_offsets): - """Return the initializer for struct mapi_stub array.""" - stubs = [] - for ent in self.entries_sorted_by_names: - stubs.append('%s{ (void *) %d, %d, NULL }' % ( - self.indent, pool_offsets[ent], ent.slot)) - - return ',\n'.join(stubs) - - def c_noop_functions(self, prefix, warn_prefix): - """Return the noop functions.""" - noops = [] - for ent in self.entries: - if ent.alias: - continue - - proto = self._c_decl(ent, prefix, False, 'static') - - stmt1 = self.indent; - space = '' - for t, n, a in ent.params: - stmt1 += "%s(void) %s;" % (space, n) - space = ' ' - - if ent.params: - stmt1 += '\n'; - - stmt1 += self.indent + '%s(%s);' % (self.noop_warn, - self._c_function(ent, warn_prefix, False, True)) - - if ent.ret: - stmt2 = self.indent + 'return (%s) 0;' % (ent.ret) - noop = '%s\n{\n%s\n%s\n}' % (proto, stmt1, stmt2) - else: - noop = '%s\n{\n%s\n}' % (proto, stmt1) - - noops.append(noop) - - return '\n\n'.join(noops) - - def c_noop_initializer(self, prefix, use_generic): - """Return an initializer for the noop dispatch table.""" - entries = [self._c_function(ent, prefix) - for ent in self.entries if not ent.alias] - if use_generic: - entries = [self.noop_generic] * len(entries) - - entries.extend([self.noop_generic] * ABI_NUM_DYNAMIC_ENTRIES) - - pre = self.indent + '(mapi_func) ' - return pre + (',\n' + pre).join(entries) - - def c_asm_gcc(self, prefix, no_hidden): - asm = [] - - for ent in self.entries: - if ent.hidden and no_hidden: - continue - - if not self.need_entry_point(ent): - continue - - name = self._c_function(ent, prefix, True, True) - - if ent.handcode: - asm.append('#if 0') - - if ent.hidden: - asm.append('".hidden "%s"\\n"' % (name)) - - if ent.alias and not (ent.alias.hidden and no_hidden): - asm.append('".globl "%s"\\n"' % (name)) - asm.append('".set "%s", "%s"\\n"' % (name, - self._c_function(ent.alias, prefix, True, True))) - else: - asm.append('STUB_ASM_ENTRY(%s)"\\n"' % (name)) - asm.append('"\\t"STUB_ASM_CODE("%d")"\\n"' % (ent.slot)) - - if ent.handcode: - asm.append('#endif') - asm.append('') - - return "\n".join(asm) - - def output_for_lib(self): - print self.c_notice() - - if self.c_header: - print - print self.c_header - - print - print '#ifdef MAPI_TMP_DEFINES' - print self.c_public_includes() - print - print self.c_public_declarations(self.prefix_lib) - print '#undef MAPI_TMP_DEFINES' - print '#endif /* MAPI_TMP_DEFINES */' - - if self.lib_need_table_size: - print - print '#ifdef MAPI_TMP_TABLE' - print self.c_mapi_table() - print '#undef MAPI_TMP_TABLE' - print '#endif /* MAPI_TMP_TABLE */' - - if self.lib_need_noop_array: - print - print '#ifdef MAPI_TMP_NOOP_ARRAY' - print '#ifdef DEBUG' - print - print self.c_noop_functions(self.prefix_noop, self.prefix_warn) - print - print 'const mapi_func table_%s_array[] = {' % (self.prefix_noop) - print self.c_noop_initializer(self.prefix_noop, False) - print '};' - print - print '#else /* DEBUG */' - print - print 'const mapi_func table_%s_array[] = {' % (self.prefix_noop) - print self.c_noop_initializer(self.prefix_noop, True) - print '};' - print - print '#endif /* DEBUG */' - print '#undef MAPI_TMP_NOOP_ARRAY' - print '#endif /* MAPI_TMP_NOOP_ARRAY */' - - if self.lib_need_stubs: - pool, pool_offsets = self.c_stub_string_pool() - print - print '#ifdef MAPI_TMP_PUBLIC_STUBS' - print 'static const char public_string_pool[] =' - print pool - print - print 'static const struct mapi_stub public_stubs[] = {' - print self.c_stub_initializer(self.prefix_lib, pool_offsets) - print '};' - print '#undef MAPI_TMP_PUBLIC_STUBS' - print '#endif /* MAPI_TMP_PUBLIC_STUBS */' - - if self.lib_need_all_entries: - print - print '#ifdef MAPI_TMP_PUBLIC_ENTRIES' - print self.c_public_dispatches(self.prefix_lib, False) - print - print 'static const mapi_func public_entries[] = {' - print self.c_public_initializer(self.prefix_lib) - print '};' - print '#undef MAPI_TMP_PUBLIC_ENTRIES' - print '#endif /* MAPI_TMP_PUBLIC_ENTRIES */' - - print - print '#ifdef MAPI_TMP_STUB_ASM_GCC' - print '__asm__(' - print self.c_asm_gcc(self.prefix_lib, False) - print ');' - print '#undef MAPI_TMP_STUB_ASM_GCC' - print '#endif /* MAPI_TMP_STUB_ASM_GCC */' - - if self.lib_need_non_hidden_entries: - all_hidden = True - for ent in self.entries: - if not ent.hidden: - all_hidden = False - break - if not all_hidden: - print - print '#ifdef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN' - print self.c_public_dispatches(self.prefix_lib, True) - print - print '/* does not need public_entries */' - print '#undef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN' - print '#endif /* MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN */' - - print - print '#ifdef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN' - print '__asm__(' - print self.c_asm_gcc(self.prefix_lib, True) - print ');' - print '#undef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN' - print '#endif /* MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN */' - - def output_for_app(self): - print self.c_notice() - print - print self.c_private_declarations(self.prefix_app) - print - print '#ifdef API_TMP_DEFINE_SPEC' - print - print 'static const char %s_spec[] =' % (self.prefix_app) - print self.c_mapi_table_spec() - print - print 'static const mapi_proc %s_procs[] = {' % (self.prefix_app) - print self.c_mapi_table_initializer(self.prefix_app) - print '};' - print - print '#endif /* API_TMP_DEFINE_SPEC */' - -class GLAPIPrinter(ABIPrinter): - """OpenGL API Printer""" - - def __init__(self, entries): - for ent in entries: - self._override_for_api(ent) - super(GLAPIPrinter, self).__init__(entries) - - self.api_defines = ['GL_GLEXT_PROTOTYPES'] - self.api_headers = ['"GL/gl.h"', '"GL/glext.h"'] - self.api_call = 'GLAPI' - self.api_entry = 'APIENTRY' - self.api_attrs = '' - - self.lib_need_table_size = False - self.lib_need_noop_array = False - self.lib_need_stubs = False - self.lib_need_all_entries = False - self.lib_need_non_hidden_entries = True - - self.prefix_lib = 'GLAPI_PREFIX' - self.prefix_app = '_mesa_' - self.prefix_noop = 'noop' - self.prefix_warn = self.prefix_lib - - self.c_header = self._get_c_header() - - def _override_for_api(self, ent): - """Override attributes of an entry if necessary for this - printer.""" - # By default, no override is necessary. - pass - - def _get_c_header(self): - header = """#ifndef _GLAPI_TMP_H_ -#define _GLAPI_TMP_H_ -#ifdef USE_MGL_NAMESPACE -#define GLAPI_PREFIX(func) mgl##func -#define GLAPI_PREFIX_STR(func) "mgl"#func -#else -#define GLAPI_PREFIX(func) gl##func -#define GLAPI_PREFIX_STR(func) "gl"#func -#endif /* USE_MGL_NAMESPACE */ - -typedef int GLfixed; -typedef int GLclampx; -#endif /* _GLAPI_TMP_H_ */""" - - return header - -class ES1APIPrinter(GLAPIPrinter): - """OpenGL ES 1.x API Printer""" - - def __init__(self, entries): - super(ES1APIPrinter, self).__init__(entries) - self.prefix_lib = 'gl' - self.prefix_warn = 'gl' - - def _override_for_api(self, ent): - if ent.xml_data is None: - raise Exception('ES2 API printer requires XML input') - ent.hidden = ent.name not in \ - ent.xml_data.entry_points_for_api_version('es1') - ent.handcode = False - - def _get_c_header(self): - header = """#ifndef _GLAPI_TMP_H_ -#define _GLAPI_TMP_H_ -typedef int GLfixed; -typedef int GLclampx; -#endif /* _GLAPI_TMP_H_ */""" - - return header - -class ES2APIPrinter(GLAPIPrinter): - """OpenGL ES 2.x API Printer""" - - def __init__(self, entries): - super(ES2APIPrinter, self).__init__(entries) - self.prefix_lib = 'gl' - self.prefix_warn = 'gl' - - def _override_for_api(self, ent): - if ent.xml_data is None: - raise Exception('ES2 API printer requires XML input') - ent.hidden = ent.name not in \ - ent.xml_data.entry_points_for_api_version('es2') - ent.handcode = False - - def _get_c_header(self): - header = """#ifndef _GLAPI_TMP_H_ -#define _GLAPI_TMP_H_ -typedef int GLfixed; -typedef int GLclampx; -#endif /* _GLAPI_TMP_H_ */""" - - return header - -class SharedGLAPIPrinter(GLAPIPrinter): - """Shared GLAPI API Printer""" - - def __init__(self, entries): - super(SharedGLAPIPrinter, self).__init__(entries) - - self.lib_need_table_size = True - self.lib_need_noop_array = True - self.lib_need_stubs = True - self.lib_need_all_entries = True - self.lib_need_non_hidden_entries = False - - self.prefix_lib = 'shared' - self.prefix_warn = 'gl' - - def _override_for_api(self, ent): - ent.hidden = True - ent.handcode = False - - def _get_c_header(self): - header = """#ifndef _GLAPI_TMP_H_ -#define _GLAPI_TMP_H_ -typedef int GLfixed; -typedef int GLclampx; -#endif /* _GLAPI_TMP_H_ */""" - - return header - -class VGAPIPrinter(ABIPrinter): - """OpenVG API Printer""" - - def __init__(self, entries): - super(VGAPIPrinter, self).__init__(entries) - - self.api_defines = ['VG_VGEXT_PROTOTYPES'] - self.api_headers = ['"VG/openvg.h"', '"VG/vgext.h"'] - self.api_call = 'VG_API_CALL' - self.api_entry = 'VG_API_ENTRY' - self.api_attrs = 'VG_API_EXIT' - - self.prefix_lib = 'vg' - self.prefix_app = 'vega' - self.prefix_noop = 'noop' - self.prefix_warn = 'vg' - -def parse_args(): - printers = ['vgapi', 'glapi', 'es1api', 'es2api', 'shared-glapi'] - modes = ['lib', 'app'] - - parser = OptionParser(usage='usage: %prog [options] ') - parser.add_option('-p', '--printer', dest='printer', - help='printer to use: %s' % (", ".join(printers))) - parser.add_option('-m', '--mode', dest='mode', - help='target user: %s' % (", ".join(modes))) - - options, args = parser.parse_args() - if not args or options.printer not in printers or \ - options.mode not in modes: - parser.print_help() - sys.exit(1) - - return (args[0], options) - -def main(): - printers = { - 'vgapi': VGAPIPrinter, - 'glapi': GLAPIPrinter, - 'es1api': ES1APIPrinter, - 'es2api': ES2APIPrinter, - 'shared-glapi': SharedGLAPIPrinter, - } - - filename, options = parse_args() - - if filename.endswith('.xml'): - entries = abi_parse_xml(filename) - else: - entries = abi_parse(filename) - abi_sanity_check(entries) - - printer = printers[options.printer](entries) - if options.mode == 'lib': - printer.output_for_lib() - else: - printer.output_for_app() - -if __name__ == '__main__': - main() diff --git a/mesalib/src/mapi/mapi/mapi_glapi.c b/mesalib/src/mapi/mapi/mapi_glapi.c deleted file mode 100644 index 4627c4de0..000000000 --- a/mesalib/src/mapi/mapi/mapi_glapi.c +++ /dev/null @@ -1,240 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include -#include "glapi/glapi.h" -#include "mapi/u_current.h" -#include "mapi/table.h" /* for MAPI_TABLE_NUM_SLOTS */ -#include "mapi/stub.h" - -/* - * Global variables, _glapi_get_context, and _glapi_get_dispatch are defined in - * u_current.c. - */ - -#ifdef GLX_USE_TLS -/* not used, but defined for compatibility */ -const struct _glapi_table *_glapi_Dispatch; -const void *_glapi_Context; -#endif /* GLX_USE_TLS */ - -void -_glapi_destroy_multithread(void) -{ - u_current_destroy(); -} - -void -_glapi_check_multithread(void) -{ - u_current_init(); -} - -void -_glapi_set_context(void *context) -{ - u_current_set_user((const void *) context); -} - -void -_glapi_set_dispatch(struct _glapi_table *dispatch) -{ - u_current_set((const struct mapi_table *) dispatch); -} - -/** - * Return size of dispatch table struct as number of functions (or - * slots). - */ -unsigned int -_glapi_get_dispatch_table_size(void) -{ - return MAPI_TABLE_NUM_SLOTS; -} - -/** - * Fill-in the dispatch stub for the named function. - * - * This function is intended to be called by a hardware driver. When called, - * a dispatch stub may be created created for the function. A pointer to this - * dispatch function will be returned by glXGetProcAddress. - * - * \param function_names Array of pointers to function names that should - * share a common dispatch offset. - * \param parameter_signature String representing the types of the parameters - * passed to the named function. Parameter types - * are converted to characters using the following - * rules: - * - 'i' for \c GLint, \c GLuint, and \c GLenum - * - 'p' for any pointer type - * - 'f' for \c GLfloat and \c GLclampf - * - 'd' for \c GLdouble and \c GLclampd - * - * \returns - * The offset in the dispatch table of the named function. A pointer to the - * driver's implementation of the named function should be stored at - * \c dispatch_table[\c offset]. Return -1 if error/problem. - * - * \sa glXGetProcAddress - * - * \warning - * This function can only handle up to 8 names at a time. As far as I know, - * the maximum number of names ever associated with an existing GL function is - * 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT, - * \c glPointParameterfARB, and \c glPointParameterf), so this should not be - * too painful of a limitation. - * - * \todo - * Check parameter_signature. - */ -int -_glapi_add_dispatch( const char * const * function_names, - const char * parameter_signature ) -{ - const struct mapi_stub *function_stubs[8]; - const struct mapi_stub *alias = NULL; - unsigned i; - - (void) memset(function_stubs, 0, sizeof(function_stubs)); - - /* find the missing stubs, and decide the alias */ - for (i = 0; function_names[i] != NULL && i < 8; i++) { - const char * funcName = function_names[i]; - const struct mapi_stub *stub; - int slot; - - if (!funcName || funcName[0] != 'g' || funcName[1] != 'l') - return -1; - funcName += 2; - - stub = stub_find_public(funcName); - if (!stub) - stub = stub_find_dynamic(funcName, 0); - - slot = (stub) ? stub_get_slot(stub) : -1; - if (slot >= 0) { - if (alias && stub_get_slot(alias) != slot) - return -1; - /* use the first existing stub as the alias */ - if (!alias) - alias = stub; - - function_stubs[i] = stub; - } - } - - /* generate missing stubs */ - for (i = 0; function_names[i] != NULL && i < 8; i++) { - const char * funcName = function_names[i] + 2; - struct mapi_stub *stub; - - if (function_stubs[i]) - continue; - - stub = stub_find_dynamic(funcName, 1); - if (!stub) - return -1; - - stub_fix_dynamic(stub, alias); - if (!alias) - alias = stub; - } - - return (alias) ? stub_get_slot(alias) : -1; -} - -static const struct mapi_stub * -_glapi_get_stub(const char *name, int generate) -{ - const struct mapi_stub *stub; - -#ifdef USE_MGL_NAMESPACE - if (name) - name++; -#endif - - if (!name || name[0] != 'g' || name[1] != 'l') - return NULL; - name += 2; - - stub = stub_find_public(name); - if (!stub) - stub = stub_find_dynamic(name, generate); - - return stub; -} - -/** - * Return offset of entrypoint for named function within dispatch table. - */ -int -_glapi_get_proc_offset(const char *funcName) -{ - const struct mapi_stub *stub = _glapi_get_stub(funcName, 0); - return (stub) ? stub_get_slot(stub) : -1; -} - -/** - * Return pointer to the named function. If the function name isn't found - * in the name of static functions, try generating a new API entrypoint on - * the fly with assembly language. - */ -_glapi_proc -_glapi_get_proc_address(const char *funcName) -{ - const struct mapi_stub *stub = _glapi_get_stub(funcName, 1); - return (stub) ? (_glapi_proc) stub_get_addr(stub) : NULL; -} - -/** - * Return the name of the function at the given dispatch offset. - * This is only intended for debugging. - */ -const char * -_glapi_get_proc_name(unsigned int offset) -{ - const struct mapi_stub *stub = stub_find_by_slot(offset); - return stub ? stub_get_name(stub) : NULL; -} - -unsigned long -_glthread_GetID(void) -{ - return u_thread_self(); -} - -void -_glapi_noop_enable_warnings(unsigned char enable) -{ -} - -void -_glapi_set_warning_func(_glapi_proc func) -{ -} diff --git a/mesalib/src/mapi/mapi/mapi_tmp.h b/mesalib/src/mapi/mapi/mapi_tmp.h deleted file mode 100644 index f326b4a4e..000000000 --- a/mesalib/src/mapi/mapi/mapi_tmp.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#ifndef MAPI_ABI_HEADER -#error "MAPI_ABI_HEADER must be defined" -#endif - -/* does not need hidden entries in bridge mode */ -#ifdef MAPI_MODE_BRIDGE - -#ifdef MAPI_TMP_PUBLIC_ENTRIES -#undef MAPI_TMP_PUBLIC_ENTRIES -#define MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN -#endif - -#ifdef MAPI_TMP_STUB_ASM_GCC -#undef MAPI_TMP_STUB_ASM_GCC -#define MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN -#endif - -#endif /* MAPI_MODE_BRIDGE */ - -#include MAPI_ABI_HEADER diff --git a/mesalib/src/mapi/mapi/sources.mak b/mesalib/src/mapi/mapi/sources.mak deleted file mode 100644 index 56f4afd3e..000000000 --- a/mesalib/src/mapi/mapi/sources.mak +++ /dev/null @@ -1,36 +0,0 @@ -# src/mapi/mapi/sources.mak -# -# mapi may be used in several ways -# -# - In default mode, mapi implements the interface defined by mapi.h. To use -# this mode, compile MAPI_FILES. -# -# - In util mode, mapi provides utility functions for use with glapi. To use -# this mode, compile MAPI_UTIL_FILES with MAPI_MODE_UTIL defined. -# -# - In glapi mode, mapi implements the interface defined by glapi.h. To use -# this mode, compile MAPI_GLAPI_FILES with MAPI_MODE_GLAPI defined. -# -# - In bridge mode, mapi provides entry points calling into glapi. To use -# this mode, compile MAPI_BRIDGE_FILES with MAPI_MODE_BRIDGE defined. - -MAPI_UTIL_FILES = \ - $(TOP)/src/mapi/mapi/u_current.c \ - $(TOP)/src/mapi/mapi/u_execmem.c - -MAPI_FILES = \ - $(TOP)/src/mapi/mapi/entry.c \ - $(TOP)/src/mapi/mapi/mapi.c \ - $(TOP)/src/mapi/mapi/stub.c \ - $(TOP)/src/mapi/mapi/table.c \ - $(MAPI_UTIL_FILES) - -MAPI_GLAPI_FILES = \ - $(TOP)/src/mapi/mapi/entry.c \ - $(TOP)/src/mapi/mapi/mapi_glapi.c \ - $(TOP)/src/mapi/mapi/stub.c \ - $(TOP)/src/mapi/mapi/table.c \ - $(MAPI_UTIL_FILES) - -MAPI_BRIDGE_FILES = \ - $(TOP)/src/mapi/mapi/entry.c diff --git a/mesalib/src/mapi/mapi/stub.c b/mesalib/src/mapi/mapi/stub.c deleted file mode 100644 index 688dc8143..000000000 --- a/mesalib/src/mapi/mapi/stub.c +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include -#include -#include - -#include "u_current.h" -#include "u_thread.h" -#include "entry.h" -#include "stub.h" -#include "table.h" - -#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) - -struct mapi_stub { - const void *name; - int slot; - mapi_func addr; -}; - -/* define public_string_pool and public_stubs */ -#define MAPI_TMP_PUBLIC_STUBS -#include "mapi_tmp.h" - -static struct mapi_stub dynamic_stubs[MAPI_TABLE_NUM_DYNAMIC]; -static int num_dynamic_stubs; -static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC; - -void -stub_init_once(void) -{ -#ifdef HAVE_PTHREAD - static pthread_once_t once = PTHREAD_ONCE_INIT; - pthread_once(&once, entry_patch_public); -#else - static int first = 1; - if (first) { - first = 0; - entry_patch_public(); - } -#endif -} - -static int -stub_compare(const void *key, const void *elem) -{ - const char *name = (const char *) key; - const struct mapi_stub *stub = (const struct mapi_stub *) elem; - const char *stub_name; - - stub_name = &public_string_pool[(unsigned long) stub->name]; - - return strcmp(name, stub_name); -} - -/** - * Return the public stub with the given name. - */ -const struct mapi_stub * -stub_find_public(const char *name) -{ - return (const struct mapi_stub *) bsearch(name, public_stubs, - ARRAY_SIZE(public_stubs), sizeof(public_stubs[0]), stub_compare); -} - -/** - * Add a dynamic stub. - */ -static struct mapi_stub * -stub_add_dynamic(const char *name) -{ - struct mapi_stub *stub; - int idx; - - idx = num_dynamic_stubs; - /* minus 1 to make sure we can never reach the last slot */ - if (idx >= MAPI_TABLE_NUM_DYNAMIC - 1) - return NULL; - - stub = &dynamic_stubs[idx]; - - /* dispatch to the last slot, which is reserved for no-op */ - stub->addr = entry_generate( - MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC - 1); - if (!stub->addr) - return NULL; - - stub->name = (const void *) name; - /* to be fixed later */ - stub->slot = -1; - - num_dynamic_stubs = idx + 1; - - return stub; -} - -/** - * Return the dynamic stub with the given name. If no such stub exists and - * generate is true, a new stub is generated. - */ -struct mapi_stub * -stub_find_dynamic(const char *name, int generate) -{ - u_mutex_declare_static(dynamic_mutex); - struct mapi_stub *stub = NULL; - int count, i; - - u_mutex_lock(dynamic_mutex); - - if (generate) - assert(!stub_find_public(name)); - - count = num_dynamic_stubs; - for (i = 0; i < count; i++) { - if (strcmp(name, (const char *) dynamic_stubs[i].name) == 0) { - stub = &dynamic_stubs[i]; - break; - } - } - - /* generate a dynamic stub */ - if (generate && !stub) - stub = stub_add_dynamic(name); - - u_mutex_unlock(dynamic_mutex); - - return stub; -} - -static const struct mapi_stub * -search_table_by_slot(const struct mapi_stub *table, size_t num_entries, - int slot) -{ - size_t i; - for (i = 0; i < num_entries; ++i) { - if (table[i].slot == slot) - return &table[i]; - } - return NULL; -} - -const struct mapi_stub * -stub_find_by_slot(int slot) -{ - const struct mapi_stub *stub = - search_table_by_slot(public_stubs, ARRAY_SIZE(public_stubs), slot); - if (stub) - return stub; - return search_table_by_slot(dynamic_stubs, num_dynamic_stubs, slot); -} - -void -stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias) -{ - int slot; - - if (stub->slot >= 0) - return; - - if (alias) - slot = alias->slot; - else - slot = next_dynamic_slot++; - - entry_patch(stub->addr, slot); - stub->slot = slot; -} - -/** - * Return the name of a stub. - */ -const char * -stub_get_name(const struct mapi_stub *stub) -{ - const char *name; - - if (stub >= public_stubs && - stub < public_stubs + ARRAY_SIZE(public_stubs)) - name = &public_string_pool[(unsigned long) stub->name]; - else - name = (const char *) stub->name; - - return name; -} - -/** - * Return the slot of a stub. - */ -int -stub_get_slot(const struct mapi_stub *stub) -{ - return stub->slot; -} - -/** - * Return the address of a stub. - */ -mapi_func -stub_get_addr(const struct mapi_stub *stub) -{ - assert(stub->addr || (unsigned int) stub->slot < MAPI_TABLE_NUM_STATIC); - return (stub->addr) ? stub->addr : entry_get_public(stub->slot); -} diff --git a/mesalib/src/mapi/mapi/stub.h b/mesalib/src/mapi/mapi/stub.h deleted file mode 100644 index 98e2553ec..000000000 --- a/mesalib/src/mapi/mapi/stub.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#ifndef _STUB_H_ -#define _STUB_H_ - -#include "entry.h" - -struct mapi_stub; - -void -stub_init_once(void); - -const struct mapi_stub * -stub_find_public(const char *name); - -struct mapi_stub * -stub_find_dynamic(const char *name, int generate); - -const struct mapi_stub * -stub_find_by_slot(int slot); - -void -stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias); - -const char * -stub_get_name(const struct mapi_stub *stub); - -int -stub_get_slot(const struct mapi_stub *stub); - -mapi_func -stub_get_addr(const struct mapi_stub *stub); - -#endif /* _STUB_H_ */ diff --git a/mesalib/src/mapi/mapi/table.c b/mesalib/src/mapi/mapi/table.c deleted file mode 100644 index 9bb9f654a..000000000 --- a/mesalib/src/mapi/mapi/table.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#include -#include - -#include "table.h" - -static void -noop_warn(const char *name) -{ - static int debug = -1; - - if (debug < 0) - debug = (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")); - - if (debug) - fprintf(stderr, "%s is no-op\n", name); -} - -static int -noop_generic(void) -{ - noop_warn("function"); - return 0; -} - -/* define noop_array */ -#define MAPI_TMP_DEFINES -#define MAPI_TMP_NOOP_ARRAY -#include "mapi_tmp.h" diff --git a/mesalib/src/mapi/mapi/table.h b/mesalib/src/mapi/mapi/table.h deleted file mode 100644 index d84523f77..000000000 --- a/mesalib/src/mapi/mapi/table.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.9 - * - * Copyright (C) 2010 LunarG Inc. - * - * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - * Authors: - * Chia-I Wu - */ - -#ifndef _TABLE_H_ -#define _TABLE_H_ - -#include "u_compiler.h" -#include "entry.h" - -#define MAPI_TMP_TABLE -#include "mapi_tmp.h" - -#define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC) -#define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func)) - -extern const mapi_func table_noop_array[]; - -/** - * Get the no-op dispatch table. - */ -static INLINE const struct mapi_table * -table_get_noop(void) -{ - return (const struct mapi_table *) table_noop_array; -} - -/** - * Set the function of a slot. - */ -static INLINE void -table_set_func(struct mapi_table *tbl, int slot, mapi_func func) -{ - mapi_func *funcs = (mapi_func *) tbl; - funcs[slot] = func; -} - -/** - * Return the function of a slot. - */ -static INLINE mapi_func -table_get_func(const struct mapi_table *tbl, int slot) -{ - const mapi_func *funcs = (const mapi_func *) tbl; - return funcs[slot]; -} - -#endif /* _TABLE_H_ */ diff --git a/mesalib/src/mapi/mapi/u_compiler.h b/mesalib/src/mapi/mapi/u_compiler.h deleted file mode 100644 index f376e97a0..000000000 --- a/mesalib/src/mapi/mapi/u_compiler.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _U_COMPILER_H_ -#define _U_COMPILER_H_ - -#include "c99_compat.h" /* inline, __func__, etc. */ - - -/* XXX: Use standard `inline` keyword instead */ -#ifndef INLINE -# define INLINE inline -#endif - -/* Function visibility */ -#ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) -# define PUBLIC __attribute__((visibility("default"))) -# elif defined(_MSC_VER) -# define PUBLIC __declspec(dllexport) -# else -# define PUBLIC -# endif -#endif - -#ifndef likely -# if defined(__GNUC__) -# define likely(x) __builtin_expect(!!(x), 1) -# define unlikely(x) __builtin_expect(!!(x), 0) -# else -# define likely(x) (x) -# define unlikely(x) (x) -# endif -#endif - -#endif /* _U_COMPILER_H_ */ diff --git a/mesalib/src/mapi/mapi/u_current.c b/mesalib/src/mapi/mapi/u_current.c deleted file mode 100644 index d902375f8..000000000 --- a/mesalib/src/mapi/mapi/u_current.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 7.1 - * - * Copyright (C) 1999-2008 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. - */ - - -/* - * This file manages the OpenGL API dispatch layer. - * The dispatch table (struct _glapi_table) is basically just a list - * of function pointers. - * There are functions to set/get the current dispatch table for the - * current thread and to manage registration/dispatch of dynamically - * added extension functions. - * - * It's intended that this file and the other glapi*.[ch] files are - * flexible enough to be reused in several places: XFree86, DRI- - * based libGL.so, and perhaps the SGI SI. - * - * NOTE: There are no dependencies on Mesa in this code. - * - * Versions (API changes): - * 2000/02/23 - original version for Mesa 3.3 and XFree86 4.0 - * 2001/01/16 - added dispatch override feature for Mesa 3.5 - * 2002/06/28 - added _glapi_set_warning_func(), Mesa 4.1. - * 2002/10/01 - _glapi_get_proc_address() will now generate new entrypoints - * itself (using offset ~0). _glapi_add_entrypoint() can be - * called afterward and it'll fill in the correct dispatch - * offset. This allows DRI libGL to avoid probing for DRI - * drivers! No changes to the public glapi interface. - */ - -#include "u_current.h" -#include "u_thread.h" - -#ifndef MAPI_MODE_UTIL - -#include "table.h" -#include "stub.h" - -#else - -extern void init_glapi_relocs_once(void); -extern void (*__glapi_noop_table[])(void); - -#define table_noop_array __glapi_noop_table -#define stub_init_once() init_glapi_relocs_once() - -#endif - -/** - * \name Current dispatch and current context control variables - * - * Depending on whether or not multithreading is support, and the type of - * support available, several variables are used to store the current context - * pointer and the current dispatch table pointer. In the non-threaded case, - * the variables \c _glapi_Dispatch and \c _glapi_Context are used for this - * purpose. - * - * In the "normal" threaded case, the variables \c _glapi_Dispatch and - * \c _glapi_Context will be \c NULL if an application is detected as being - * multithreaded. Single-threaded applications will use \c _glapi_Dispatch - * and \c _glapi_Context just like the case without any threading support. - * When \c _glapi_Dispatch and \c _glapi_Context are \c NULL, the thread state - * data \c _gl_DispatchTSD and \c ContextTSD are used. Drivers and the - * static dispatch functions access these variables via \c _glapi_get_dispatch - * and \c _glapi_get_context. - * - * There is a race condition in setting \c _glapi_Dispatch to \c NULL. It is - * possible for the original thread to be setting it at the same instant a new - * thread, perhaps running on a different processor, is clearing it. Because - * of that, \c ThreadSafe, which can only ever be changed to \c GL_TRUE, is - * used to determine whether or not the application is multithreaded. - * - * In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context are - * hardcoded to \c NULL. Instead the TLS variables \c _glapi_tls_Dispatch and - * \c _glapi_tls_Context are used. Having \c _glapi_Dispatch and - * \c _glapi_Context be hardcoded to \c NULL maintains binary compatability - * between TLS enabled loaders and non-TLS DRI drivers. - */ -/*@{*/ -#if defined(GLX_USE_TLS) - -__thread struct mapi_table *u_current_table - __attribute__((tls_model("initial-exec"))) - = (struct mapi_table *) table_noop_array; - -__thread void *u_current_user - __attribute__((tls_model("initial-exec"))); - -#else - -struct mapi_table *u_current_table = - (struct mapi_table *) table_noop_array; -void *u_current_user; - -#ifdef THREADS -struct u_tsd u_current_table_tsd; -static struct u_tsd u_current_user_tsd; -static int ThreadSafe; -#endif /* THREADS */ - -#endif /* defined(GLX_USE_TLS) */ -/*@}*/ - - -void -u_current_destroy(void) -{ -#if defined(THREADS) && defined(_WIN32) - u_tsd_destroy(&u_current_table_tsd); - u_tsd_destroy(&u_current_user_tsd); -#endif -} - - -#if defined(THREADS) && !defined(GLX_USE_TLS) - -static void -u_current_init_tsd(void) -{ - u_tsd_init(&u_current_table_tsd); - u_tsd_init(&u_current_user_tsd); -} - -/** - * Mutex for multithread check. - */ -u_mutex_declare_static(ThreadCheckMutex); - -/** - * We should call this periodically from a function such as glXMakeCurrent - * in order to test if multiple threads are being used. - */ -void -u_current_init(void) -{ - static unsigned long knownID; - static int firstCall = 1; - - if (ThreadSafe) - return; - - u_mutex_lock(ThreadCheckMutex); - if (firstCall) { - u_current_init_tsd(); - - knownID = u_thread_self(); - firstCall = 0; - } - else if (knownID != u_thread_self()) { - ThreadSafe = 1; - u_current_set(NULL); - u_current_set_user(NULL); - } - u_mutex_unlock(ThreadCheckMutex); -} - -#else - -void -u_current_init(void) -{ -} - -#endif - - - -/** - * Set the current context pointer for this thread. - * The context pointer is an opaque type which should be cast to - * void from the real context pointer type. - */ -void -u_current_set_user(const void *ptr) -{ - u_current_init(); - -#if defined(GLX_USE_TLS) - u_current_user = (void *) ptr; -#elif defined(THREADS) - u_tsd_set(&u_current_user_tsd, (void *) ptr); - u_current_user = (ThreadSafe) ? NULL : (void *) ptr; -#else - u_current_user = (void *) ptr; -#endif -} - -/** - * Get the current context pointer for this thread. - * The context pointer is an opaque type which should be cast from - * void to the real context pointer type. - */ -void * -u_current_get_user_internal(void) -{ -#if defined(GLX_USE_TLS) - return u_current_user; -#elif defined(THREADS) - return (ThreadSafe) - ? u_tsd_get(&u_current_user_tsd) - : u_current_user; -#else - return u_current_user; -#endif -} - -/** - * Set the global or per-thread dispatch table pointer. - * If the dispatch parameter is NULL we'll plug in the no-op dispatch - * table (__glapi_noop_table). - */ -void -u_current_set(const struct mapi_table *tbl) -{ - u_current_init(); - - stub_init_once(); - - if (!tbl) - tbl = (const struct mapi_table *) table_noop_array; - -#if defined(GLX_USE_TLS) - u_current_table = (struct mapi_table *) tbl; -#elif defined(THREADS) - u_tsd_set(&u_current_table_tsd, (void *) tbl); - u_current_table = (ThreadSafe) ? NULL : (void *) tbl; -#else - u_current_table = (struct mapi_table *) tbl; -#endif -} - -/** - * Return pointer to current dispatch table for calling thread. - */ -struct mapi_table * -u_current_get_internal(void) -{ -#if defined(GLX_USE_TLS) - return u_current_table; -#elif defined(THREADS) - return (struct mapi_table *) ((ThreadSafe) ? - u_tsd_get(&u_current_table_tsd) : (void *) u_current_table); -#else - return u_current_table; -#endif -} diff --git a/mesalib/src/mapi/mapi/u_current.h b/mesalib/src/mapi/mapi/u_current.h deleted file mode 100644 index f9cffd8c3..000000000 --- a/mesalib/src/mapi/mapi/u_current.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef _U_CURRENT_H_ -#define _U_CURRENT_H_ - -#if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \ - defined(MAPI_MODE_BRIDGE) - -#include "glapi/glapi.h" - -/* ugly renames to match glapi.h */ -#define mapi_table _glapi_table - -#ifdef GLX_USE_TLS -#define u_current_table _glapi_tls_Dispatch -#define u_current_user _glapi_tls_Context -#else -#define u_current_table _glapi_Dispatch -#define u_current_user _glapi_Context -#endif - -#define u_current_get_internal _glapi_get_dispatch -#define u_current_get_user_internal _glapi_get_context - -#define u_current_table_tsd _gl_DispatchTSD - -#else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ - -#include "u_compiler.h" - -struct mapi_table; - -#ifdef GLX_USE_TLS - -extern __thread struct mapi_table *u_current_table - __attribute__((tls_model("initial-exec"))); - -extern __thread void *u_current_user - __attribute__((tls_model("initial-exec"))); - -#else /* GLX_USE_TLS */ - -extern struct mapi_table *u_current_table; -extern void *u_current_user; - -#endif /* GLX_USE_TLS */ - -#endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ - -void -u_current_init(void); - -void -u_current_destroy(void); - -void -u_current_set(const struct mapi_table *tbl); - -struct mapi_table * -u_current_get_internal(void); - -void -u_current_set_user(const void *ptr); - -void * -u_current_get_user_internal(void); - -static INLINE const struct mapi_table * -u_current_get(void) -{ -#ifdef GLX_USE_TLS - return u_current_table; -#else - return (likely(u_current_table) ? - u_current_table : u_current_get_internal()); -#endif -} - -static INLINE const void * -u_current_get_user(void) -{ -#ifdef GLX_USE_TLS - return u_current_user; -#else - return likely(u_current_user) ? u_current_user : u_current_get_user_internal(); -#endif -} - -#endif /* _U_CURRENT_H_ */ diff --git a/mesalib/src/mapi/mapi/u_execmem.c b/mesalib/src/mapi/mapi/u_execmem.c deleted file mode 100644 index e5072e06e..000000000 --- a/mesalib/src/mapi/mapi/u_execmem.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5 - * - * Copyright (C) 1999-2005 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. - */ - - -/** - * \file glapi_execmem.c - * - * Function for allocating executable memory for dispatch stubs. - * - * Copied from main/execmem.c and simplified for dispatch stubs. - */ - - -#include "u_compiler.h" -#include "u_thread.h" -#include "u_execmem.h" - - -#define EXEC_MAP_SIZE (4*1024) - -u_mutex_declare_static(exec_mutex); - -static unsigned int head = 0; - -static unsigned char *exec_mem = (unsigned char *)0; - - -#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) - -#include -#include - -#ifdef MESA_SELINUX -#include -#endif - - -#ifndef MAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON -#endif - - -/* - * Dispatch stubs are of fixed size and never freed. Thus, we do not need to - * overlay a heap, we just mmap a page and manage through an index. - */ - -static int -init_map(void) -{ -#ifdef MESA_SELINUX - if (is_selinux_enabled()) { - if (!security_get_boolean_active("allow_execmem") || - !security_get_boolean_pending("allow_execmem")) - return 0; - } -#endif - - if (!exec_mem) - exec_mem = mmap(NULL, EXEC_MAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - - return (exec_mem != MAP_FAILED); -} - - -#elif defined(_WIN32) - -#include - - -/* - * Avoid Data Execution Prevention. - */ - -static int -init_map(void) -{ - exec_mem = VirtualAlloc(NULL, EXEC_MAP_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); - - return (exec_mem != NULL); -} - - -#else - -#include - -static int -init_map(void) -{ - exec_mem = malloc(EXEC_MAP_SIZE); - - return (exec_mem != NULL); -} - - -#endif - -void * -u_execmem_alloc(unsigned int size) -{ - void *addr = NULL; - - u_mutex_lock(exec_mutex); - - if (!init_map()) - goto bail; - - /* free space check, assumes no integer overflow */ - if (head + size > EXEC_MAP_SIZE) - goto bail; - - /* allocation, assumes proper addr and size alignement */ - addr = exec_mem + head; - head += size; - -bail: - u_mutex_unlock(exec_mutex); - - return addr; -} - - diff --git a/mesalib/src/mapi/mapi/u_execmem.h b/mesalib/src/mapi/mapi/u_execmem.h deleted file mode 100644 index 13fff8df2..000000000 --- a/mesalib/src/mapi/mapi/u_execmem.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef _U_EXECMEM_H_ -#define _U_EXECMEM_H_ - -void * -u_execmem_alloc(unsigned int size); - -#endif /* _U_EXECMEM_H_ */ diff --git a/mesalib/src/mapi/mapi/u_macros.h b/mesalib/src/mapi/mapi/u_macros.h deleted file mode 100644 index 72345b5f1..000000000 --- a/mesalib/src/mapi/mapi/u_macros.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _U_MACROS_ -#define _U_MACROS_ - -#define _U_STRINGIFY(x) #x -#define _U_CONCAT(x, y) x ## y -#define _U_CONCAT_STR(x, y) #x#y - -#define U_STRINGIFY(x) _U_STRINGIFY(x) -#define U_CONCAT(x, y) _U_CONCAT(x, y) -#define U_CONCAT_STR(x, y) _U_CONCAT_STR(x, y) - -#endif /* _U_MACROS_ */ diff --git a/mesalib/src/mapi/mapi/u_thread.h b/mesalib/src/mapi/mapi/u_thread.h deleted file mode 100644 index a5e504370..000000000 --- a/mesalib/src/mapi/mapi/u_thread.h +++ /dev/null @@ -1,287 +0,0 @@ -/* - * Mesa 3-D graphics library - * Version: 6.5.2 - * - * 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. - */ - - -/* - * Thread support for gl dispatch. - * - * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu) - * and Christoph Poliwoda (poliwoda@volumegraphics.com) - * Revised by Keith Whitwell - * Adapted for new gl dispatcher by Brian Paul - * Modified for use in mapi by Chia-I Wu - */ - -/* - * If this file is accidentally included by a non-threaded build, - * it should not cause the build to fail, or otherwise cause problems. - * In general, it should only be included when needed however. - */ - -#ifndef _U_THREAD_H_ -#define _U_THREAD_H_ - -#include -#include -#include "u_compiler.h" - -#if defined(HAVE_PTHREAD) -#include /* POSIX threads headers */ -#endif -#ifdef _WIN32 -#include -#endif - -#if defined(HAVE_PTHREAD) || defined(_WIN32) -#ifndef THREADS -#define THREADS -#endif -#endif - -/* - * Error messages - */ -#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data" -#define GET_TSD_ERROR "_glthread_: failed to get thread specific data" -#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data" - - -/* - * Magic number to determine if a TSD object has been initialized. - * Kind of a hack but there doesn't appear to be a better cross-platform - * solution. - */ -#define INIT_MAGIC 0xff8adc98 - -#ifdef __cplusplus -extern "C" { -#endif - - -/* - * POSIX threads. This should be your choice in the Unix world - * whenever possible. When building with POSIX threads, be sure - * to enable any compiler flags which will cause the MT-safe - * libc (if one exists) to be used when linking, as well as any - * header macros for MT-safe errno, etc. For Solaris, this is the -mt - * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable - * proper compiling for MT-safe libc etc. - */ -#if defined(HAVE_PTHREAD) - -struct u_tsd { - pthread_key_t key; - unsigned initMagic; -}; - -typedef pthread_mutex_t u_mutex; - -#define u_mutex_declare_static(name) \ - static u_mutex name = PTHREAD_MUTEX_INITIALIZER - -#define u_mutex_init(name) pthread_mutex_init(&(name), NULL) -#define u_mutex_destroy(name) pthread_mutex_destroy(&(name)) -#define u_mutex_lock(name) (void) pthread_mutex_lock(&(name)) -#define u_mutex_unlock(name) (void) pthread_mutex_unlock(&(name)) - -static INLINE unsigned long -u_thread_self(void) -{ - return (unsigned long) pthread_self(); -} - - -static INLINE void -u_tsd_init(struct u_tsd *tsd) -{ - if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -static INLINE void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - return pthread_getspecific(tsd->key); -} - - -static INLINE void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - if (pthread_setspecific(tsd->key, ptr) != 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - -#endif /* HAVE_PTHREAD */ - - -/* - * Windows threads. Should work with Windows NT and 95. - * IMPORTANT: Link with multithreaded runtime library when THREADS are - * used! - */ -#ifdef _WIN32 - -struct u_tsd { - DWORD key; - unsigned initMagic; -}; - -typedef CRITICAL_SECTION u_mutex; - -/* http://locklessinc.com/articles/pthreads_on_windows/ */ -#define u_mutex_declare_static(name) \ - static u_mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} - -#define u_mutex_init(name) InitializeCriticalSection(&name) -#define u_mutex_destroy(name) DeleteCriticalSection(&name) -#define u_mutex_lock(name) EnterCriticalSection(&name) -#define u_mutex_unlock(name) LeaveCriticalSection(&name) - -static INLINE unsigned long -u_thread_self(void) -{ - return GetCurrentThreadId(); -} - - -static INLINE void -u_tsd_init(struct u_tsd *tsd) -{ - tsd->key = TlsAlloc(); - if (tsd->key == TLS_OUT_OF_INDEXES) { - perror(INIT_TSD_ERROR); - exit(-1); - } - tsd->initMagic = INIT_MAGIC; -} - - -static INLINE void -u_tsd_destroy(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - return; - } - TlsFree(tsd->key); - tsd->initMagic = 0x0; -} - - -static INLINE void * -u_tsd_get(struct u_tsd *tsd) -{ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - return TlsGetValue(tsd->key); -} - - -static INLINE void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - /* the following code assumes that the struct u_tsd has been initialized - to zero at creation */ - if (tsd->initMagic != INIT_MAGIC) { - u_tsd_init(tsd); - } - if (TlsSetValue(tsd->key, ptr) == 0) { - perror(SET_TSD_ERROR); - exit(-1); - } -} - -#endif /* _WIN32 */ - - -/* - * THREADS not defined - */ -#ifndef THREADS - -struct u_tsd { - unsigned initMagic; -}; - -typedef unsigned u_mutex; - -#define u_mutex_declare_static(name) static u_mutex name = 0 -#define u_mutex_init(name) (void) name -#define u_mutex_destroy(name) (void) name -#define u_mutex_lock(name) (void) name -#define u_mutex_unlock(name) (void) name - -/* - * no-op functions - */ - -static INLINE unsigned long -u_thread_self(void) -{ - return 0; -} - - -static INLINE void -u_tsd_init(struct u_tsd *tsd) -{ - (void) tsd; -} - - -static INLINE void * -u_tsd_get(struct u_tsd *tsd) -{ - (void) tsd; - return NULL; -} - - -static INLINE void -u_tsd_set(struct u_tsd *tsd, void *ptr) -{ - (void) tsd; - (void) ptr; -} -#endif /* THREADS */ - - -#ifdef __cplusplus -} -#endif - -#endif /* _U_THREAD_H_ */ diff --git a/mesalib/src/mapi/mapi_abi.py b/mesalib/src/mapi/mapi_abi.py new file mode 100644 index 000000000..6bfcfa9af --- /dev/null +++ b/mesalib/src/mapi/mapi_abi.py @@ -0,0 +1,873 @@ +#!/usr/bin/env python + +# Mesa 3-D graphics library +# Version: 7.9 +# +# Copyright (C) 2010 LunarG Inc. +# +# 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +# DEALINGS IN THE SOFTWARE. +# +# Authors: +# Chia-I Wu + +import sys +# make it possible to import glapi +import os +GLAPI = os.path.join(".", os.path.dirname(sys.argv[0]), "glapi/gen") +sys.path.append(GLAPI) + +import re +from optparse import OptionParser +import gl_XML +import glX_XML + + +# number of dynamic entries +ABI_NUM_DYNAMIC_ENTRIES = 256 + +class ABIEntry(object): + """Represent an ABI entry.""" + + _match_c_param = re.compile( + '^(?P[\w\s*]+?)(?P\w+)(\[(?P\d+)\])?$') + + def __init__(self, cols, attrs, xml_data = None): + self._parse(cols) + + self.slot = attrs['slot'] + self.hidden = attrs['hidden'] + self.alias = attrs['alias'] + self.handcode = attrs['handcode'] + self.xml_data = xml_data + + def c_prototype(self): + return '%s %s(%s)' % (self.c_return(), self.name, self.c_params()) + + def c_return(self): + ret = self.ret + if not ret: + ret = 'void' + + return ret + + def c_params(self): + """Return the parameter list used in the entry prototype.""" + c_params = [] + for t, n, a in self.params: + sep = '' if t.endswith('*') else ' ' + arr = '[%d]' % a if a else '' + c_params.append(t + sep + n + arr) + if not c_params: + c_params.append('void') + + return ", ".join(c_params) + + def c_args(self): + """Return the argument list used in the entry invocation.""" + c_args = [] + for t, n, a in self.params: + c_args.append(n) + + return ", ".join(c_args) + + def _parse(self, cols): + ret = cols.pop(0) + if ret == 'void': + ret = None + + name = cols.pop(0) + + params = [] + if not cols: + raise Exception(cols) + elif len(cols) == 1 and cols[0] == 'void': + pass + else: + for val in cols: + params.append(self._parse_param(val)) + + self.ret = ret + self.name = name + self.params = params + + def _parse_param(self, c_param): + m = self._match_c_param.match(c_param) + if not m: + raise Exception('unrecognized param ' + c_param) + + c_type = m.group('type').strip() + c_name = m.group('name') + c_array = m.group('array') + c_array = int(c_array) if c_array else 0 + + return (c_type, c_name, c_array) + + def __str__(self): + return self.c_prototype() + + def __cmp__(self, other): + # compare slot, alias, and then name + res = cmp(self.slot, other.slot) + if not res: + if not self.alias: + res = -1 + elif not other.alias: + res = 1 + + if not res: + res = cmp(self.name, other.name) + + return res + +def abi_parse_xml(xml): + """Parse a GLAPI XML file for ABI entries.""" + api = gl_XML.parse_GL_API(xml, glX_XML.glx_item_factory()) + + entry_dict = {} + for func in api.functionIterateByOffset(): + # make sure func.name appear first + entry_points = func.entry_points[:] + entry_points.remove(func.name) + entry_points.insert(0, func.name) + + for name in entry_points: + attrs = { + 'slot': func.offset, + 'hidden': not func.is_static_entry_point(name), + 'alias': None if name == func.name else func.name, + 'handcode': bool(func.has_different_protocol(name)), + } + + # post-process attrs + if attrs['alias']: + try: + alias = entry_dict[attrs['alias']] + except KeyError: + raise Exception('failed to alias %s' % attrs['alias']) + if alias.alias: + raise Exception('recursive alias %s' % ent.name) + attrs['alias'] = alias + if attrs['handcode']: + attrs['handcode'] = func.static_glx_name(name) + else: + attrs['handcode'] = None + + if entry_dict.has_key(name): + raise Exception('%s is duplicated' % (name)) + + cols = [] + cols.append(func.return_type) + cols.append(name) + params = func.get_parameter_string(name) + cols.extend([p.strip() for p in params.split(',')]) + + ent = ABIEntry(cols, attrs, func) + entry_dict[ent.name] = ent + + entries = entry_dict.values() + entries.sort() + + return entries + +def abi_parse_line(line): + cols = [col.strip() for col in line.split(',')] + + attrs = { + 'slot': -1, + 'hidden': False, + 'alias': None, + 'handcode': None, + } + + # extract attributes from the first column + vals = cols[0].split(':') + while len(vals) > 1: + val = vals.pop(0) + if val.startswith('slot='): + attrs['slot'] = int(val[5:]) + elif val == 'hidden': + attrs['hidden'] = True + elif val.startswith('alias='): + attrs['alias'] = val[6:] + elif val.startswith('handcode='): + attrs['handcode'] = val[9:] + elif not val: + pass + else: + raise Exception('unknown attribute %s' % val) + cols[0] = vals[0] + + return (attrs, cols) + +def abi_parse(filename): + """Parse a CSV file for ABI entries.""" + fp = open(filename) if filename != '-' else sys.stdin + lines = [line.strip() for line in fp.readlines() + if not line.startswith('#') and line.strip()] + + entry_dict = {} + next_slot = 0 + for line in lines: + attrs, cols = abi_parse_line(line) + + # post-process attributes + if attrs['alias']: + try: + alias = entry_dict[attrs['alias']] + except KeyError: + raise Exception('failed to alias %s' % attrs['alias']) + if alias.alias: + raise Exception('recursive alias %s' % ent.name) + slot = alias.slot + attrs['alias'] = alias + else: + slot = next_slot + next_slot += 1 + + if attrs['slot'] < 0: + attrs['slot'] = slot + elif attrs['slot'] != slot: + raise Exception('invalid slot in %s' % (line)) + + ent = ABIEntry(cols, attrs) + if entry_dict.has_key(ent.name): + raise Exception('%s is duplicated' % (ent.name)) + entry_dict[ent.name] = ent + + entries = entry_dict.values() + entries.sort() + + return entries + +def abi_sanity_check(entries): + if not entries: + return + + all_names = [] + last_slot = entries[-1].slot + i = 0 + for slot in xrange(last_slot + 1): + if entries[i].slot != slot: + raise Exception('entries are not ordered by slots') + if entries[i].alias: + raise Exception('first entry of slot %d aliases %s' + % (slot, entries[i].alias.name)) + handcode = None + while i < len(entries) and entries[i].slot == slot: + ent = entries[i] + if not handcode and ent.handcode: + handcode = ent.handcode + elif ent.handcode != handcode: + raise Exception('two aliases with handcode %s != %s', + ent.handcode, handcode) + + if ent.name in all_names: + raise Exception('%s is duplicated' % (ent.name)) + if ent.alias and ent.alias.name not in all_names: + raise Exception('failed to alias %s' % (ent.alias.name)) + all_names.append(ent.name) + i += 1 + if i < len(entries): + raise Exception('there are %d invalid entries' % (len(entries) - 1)) + +class ABIPrinter(object): + """MAPI Printer""" + + def __init__(self, entries): + self.entries = entries + + # sort entries by their names + self.entries_sorted_by_names = self.entries[:] + self.entries_sorted_by_names.sort(lambda x, y: cmp(x.name, y.name)) + + self.indent = ' ' * 3 + self.noop_warn = 'noop_warn' + self.noop_generic = 'noop_generic' + self.current_get = 'entry_current_get' + + self.api_defines = [] + self.api_headers = ['"KHR/khrplatform.h"'] + self.api_call = 'KHRONOS_APICALL' + self.api_entry = 'KHRONOS_APIENTRY' + self.api_attrs = 'KHRONOS_APIATTRIBUTES' + + self.c_header = '' + + self.lib_need_table_size = True + self.lib_need_noop_array = True + self.lib_need_stubs = True + self.lib_need_all_entries = True + self.lib_need_non_hidden_entries = False + + def c_notice(self): + return '/* This file is automatically generated by mapi_abi.py. Do not modify. */' + + def c_public_includes(self): + """Return includes of the client API headers.""" + defines = ['#define ' + d for d in self.api_defines] + includes = ['#include ' + h for h in self.api_headers] + return "\n".join(defines + includes) + + def need_entry_point(self, ent): + """Return True if an entry point is needed for the entry.""" + # non-handcode hidden aliases may share the entry they alias + use_alias = (ent.hidden and ent.alias and not ent.handcode) + return not use_alias + + def c_public_declarations(self, prefix): + """Return the declarations of public entry points.""" + decls = [] + for ent in self.entries: + if not self.need_entry_point(ent): + continue + export = self.api_call if not ent.hidden else '' + decls.append(self._c_decl(ent, prefix, True, export) + ';') + + return "\n".join(decls) + + def c_mapi_table(self): + """Return defines of the dispatch table size.""" + num_static_entries = self.entries[-1].slot + 1 + return ('#define MAPI_TABLE_NUM_STATIC %d\n' + \ + '#define MAPI_TABLE_NUM_DYNAMIC %d') % ( + num_static_entries, ABI_NUM_DYNAMIC_ENTRIES) + + def c_mapi_table_initializer(self, prefix): + """Return the array initializer for mapi_table_fill.""" + entries = [self._c_function(ent, prefix) + for ent in self.entries if not ent.alias] + pre = self.indent + '(mapi_proc) ' + return pre + (',\n' + pre).join(entries) + + def c_mapi_table_spec(self): + """Return the spec for mapi_init.""" + specv1 = [] + line = '"1' + for ent in self.entries: + if not ent.alias: + line += '\\0"\n' + specv1.append(line) + line = '"' + line += '%s\\0' % ent.name + line += '";' + specv1.append(line) + + return self.indent + self.indent.join(specv1) + + def _c_function(self, ent, prefix, mangle=False, stringify=False): + """Return the function name of an entry.""" + formats = { + True: { True: '%s_STR(%s)', False: '%s(%s)' }, + False: { True: '"%s%s"', False: '%s%s' }, + } + fmt = formats[prefix.isupper()][stringify] + name = ent.name + if mangle and ent.hidden: + name = '_dispatch_stub_' + str(ent.slot) + return fmt % (prefix, name) + + def _c_function_call(self, ent, prefix): + """Return the function name used for calling.""" + if ent.handcode: + # _c_function does not handle this case + formats = { True: '%s(%s)', False: '%s%s' } + fmt = formats[prefix.isupper()] + name = fmt % (prefix, ent.handcode) + elif self.need_entry_point(ent): + name = self._c_function(ent, prefix, True) + else: + name = self._c_function(ent.alias, prefix, True) + return name + + def _c_decl(self, ent, prefix, mangle=False, export=''): + """Return the C declaration for the entry.""" + decl = '%s %s %s(%s)' % (ent.c_return(), self.api_entry, + self._c_function(ent, prefix, mangle), ent.c_params()) + if export: + decl = export + ' ' + decl + if self.api_attrs: + decl += ' ' + self.api_attrs + + return decl + + def _c_cast(self, ent): + """Return the C cast for the entry.""" + cast = '%s (%s *)(%s)' % ( + ent.c_return(), self.api_entry, ent.c_params()) + + return cast + + def c_private_declarations(self, prefix): + """Return the declarations of private functions.""" + decls = [self._c_decl(ent, prefix) + ';' + for ent in self.entries if not ent.alias] + + return "\n".join(decls) + + def c_public_dispatches(self, prefix, no_hidden): + """Return the public dispatch functions.""" + dispatches = [] + for ent in self.entries: + if ent.hidden and no_hidden: + continue + + if not self.need_entry_point(ent): + continue + + export = self.api_call if not ent.hidden else '' + + proto = self._c_decl(ent, prefix, True, export) + cast = self._c_cast(ent) + + ret = '' + if ent.ret: + ret = 'return ' + stmt1 = self.indent + stmt1 += 'const struct mapi_table *_tbl = %s();' % ( + self.current_get) + stmt2 = self.indent + stmt2 += 'mapi_func _func = ((const mapi_func *) _tbl)[%d];' % ( + ent.slot) + stmt3 = self.indent + stmt3 += '%s((%s) _func)(%s);' % (ret, cast, ent.c_args()) + + disp = '%s\n{\n%s\n%s\n%s\n}' % (proto, stmt1, stmt2, stmt3) + + if ent.handcode: + disp = '#if 0\n' + disp + '\n#endif' + + dispatches.append(disp) + + return '\n\n'.join(dispatches) + + def c_public_initializer(self, prefix): + """Return the initializer for public dispatch functions.""" + names = [] + for ent in self.entries: + if ent.alias: + continue + + name = '%s(mapi_func) %s' % (self.indent, + self._c_function_call(ent, prefix)) + names.append(name) + + return ',\n'.join(names) + + def c_stub_string_pool(self): + """Return the string pool for use by stubs.""" + # sort entries by their names + sorted_entries = self.entries[:] + sorted_entries.sort(lambda x, y: cmp(x.name, y.name)) + + pool = [] + offsets = {} + count = 0 + for ent in sorted_entries: + offsets[ent] = count + pool.append('%s' % (ent.name)) + count += len(ent.name) + 1 + + pool_str = self.indent + '"' + \ + ('\\0"\n' + self.indent + '"').join(pool) + '";' + return (pool_str, offsets) + + def c_stub_initializer(self, prefix, pool_offsets): + """Return the initializer for struct mapi_stub array.""" + stubs = [] + for ent in self.entries_sorted_by_names: + stubs.append('%s{ (void *) %d, %d, NULL }' % ( + self.indent, pool_offsets[ent], ent.slot)) + + return ',\n'.join(stubs) + + def c_noop_functions(self, prefix, warn_prefix): + """Return the noop functions.""" + noops = [] + for ent in self.entries: + if ent.alias: + continue + + proto = self._c_decl(ent, prefix, False, 'static') + + stmt1 = self.indent; + space = '' + for t, n, a in ent.params: + stmt1 += "%s(void) %s;" % (space, n) + space = ' ' + + if ent.params: + stmt1 += '\n'; + + stmt1 += self.indent + '%s(%s);' % (self.noop_warn, + self._c_function(ent, warn_prefix, False, True)) + + if ent.ret: + stmt2 = self.indent + 'return (%s) 0;' % (ent.ret) + noop = '%s\n{\n%s\n%s\n}' % (proto, stmt1, stmt2) + else: + noop = '%s\n{\n%s\n}' % (proto, stmt1) + + noops.append(noop) + + return '\n\n'.join(noops) + + def c_noop_initializer(self, prefix, use_generic): + """Return an initializer for the noop dispatch table.""" + entries = [self._c_function(ent, prefix) + for ent in self.entries if not ent.alias] + if use_generic: + entries = [self.noop_generic] * len(entries) + + entries.extend([self.noop_generic] * ABI_NUM_DYNAMIC_ENTRIES) + + pre = self.indent + '(mapi_func) ' + return pre + (',\n' + pre).join(entries) + + def c_asm_gcc(self, prefix, no_hidden): + asm = [] + + for ent in self.entries: + if ent.hidden and no_hidden: + continue + + if not self.need_entry_point(ent): + continue + + name = self._c_function(ent, prefix, True, True) + + if ent.handcode: + asm.append('#if 0') + + if ent.hidden: + asm.append('".hidden "%s"\\n"' % (name)) + + if ent.alias and not (ent.alias.hidden and no_hidden): + asm.append('".globl "%s"\\n"' % (name)) + asm.append('".set "%s", "%s"\\n"' % (name, + self._c_function(ent.alias, prefix, True, True))) + else: + asm.append('STUB_ASM_ENTRY(%s)"\\n"' % (name)) + asm.append('"\\t"STUB_ASM_CODE("%d")"\\n"' % (ent.slot)) + + if ent.handcode: + asm.append('#endif') + asm.append('') + + return "\n".join(asm) + + def output_for_lib(self): + print self.c_notice() + + if self.c_header: + print + print self.c_header + + print + print '#ifdef MAPI_TMP_DEFINES' + print self.c_public_includes() + print + print self.c_public_declarations(self.prefix_lib) + print '#undef MAPI_TMP_DEFINES' + print '#endif /* MAPI_TMP_DEFINES */' + + if self.lib_need_table_size: + print + print '#ifdef MAPI_TMP_TABLE' + print self.c_mapi_table() + print '#undef MAPI_TMP_TABLE' + print '#endif /* MAPI_TMP_TABLE */' + + if self.lib_need_noop_array: + print + print '#ifdef MAPI_TMP_NOOP_ARRAY' + print '#ifdef DEBUG' + print + print self.c_noop_functions(self.prefix_noop, self.prefix_warn) + print + print 'const mapi_func table_%s_array[] = {' % (self.prefix_noop) + print self.c_noop_initializer(self.prefix_noop, False) + print '};' + print + print '#else /* DEBUG */' + print + print 'const mapi_func table_%s_array[] = {' % (self.prefix_noop) + print self.c_noop_initializer(self.prefix_noop, True) + print '};' + print + print '#endif /* DEBUG */' + print '#undef MAPI_TMP_NOOP_ARRAY' + print '#endif /* MAPI_TMP_NOOP_ARRAY */' + + if self.lib_need_stubs: + pool, pool_offsets = self.c_stub_string_pool() + print + print '#ifdef MAPI_TMP_PUBLIC_STUBS' + print 'static const char public_string_pool[] =' + print pool + print + print 'static const struct mapi_stub public_stubs[] = {' + print self.c_stub_initializer(self.prefix_lib, pool_offsets) + print '};' + print '#undef MAPI_TMP_PUBLIC_STUBS' + print '#endif /* MAPI_TMP_PUBLIC_STUBS */' + + if self.lib_need_all_entries: + print + print '#ifdef MAPI_TMP_PUBLIC_ENTRIES' + print self.c_public_dispatches(self.prefix_lib, False) + print + print 'static const mapi_func public_entries[] = {' + print self.c_public_initializer(self.prefix_lib) + print '};' + print '#undef MAPI_TMP_PUBLIC_ENTRIES' + print '#endif /* MAPI_TMP_PUBLIC_ENTRIES */' + + print + print '#ifdef MAPI_TMP_STUB_ASM_GCC' + print '__asm__(' + print self.c_asm_gcc(self.prefix_lib, False) + print ');' + print '#undef MAPI_TMP_STUB_ASM_GCC' + print '#endif /* MAPI_TMP_STUB_ASM_GCC */' + + if self.lib_need_non_hidden_entries: + all_hidden = True + for ent in self.entries: + if not ent.hidden: + all_hidden = False + break + if not all_hidden: + print + print '#ifdef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN' + print self.c_public_dispatches(self.prefix_lib, True) + print + print '/* does not need public_entries */' + print '#undef MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN' + print '#endif /* MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN */' + + print + print '#ifdef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN' + print '__asm__(' + print self.c_asm_gcc(self.prefix_lib, True) + print ');' + print '#undef MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN' + print '#endif /* MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN */' + + def output_for_app(self): + print self.c_notice() + print + print self.c_private_declarations(self.prefix_app) + print + print '#ifdef API_TMP_DEFINE_SPEC' + print + print 'static const char %s_spec[] =' % (self.prefix_app) + print self.c_mapi_table_spec() + print + print 'static const mapi_proc %s_procs[] = {' % (self.prefix_app) + print self.c_mapi_table_initializer(self.prefix_app) + print '};' + print + print '#endif /* API_TMP_DEFINE_SPEC */' + +class GLAPIPrinter(ABIPrinter): + """OpenGL API Printer""" + + def __init__(self, entries): + for ent in entries: + self._override_for_api(ent) + super(GLAPIPrinter, self).__init__(entries) + + self.api_defines = ['GL_GLEXT_PROTOTYPES'] + self.api_headers = ['"GL/gl.h"', '"GL/glext.h"'] + self.api_call = 'GLAPI' + self.api_entry = 'APIENTRY' + self.api_attrs = '' + + self.lib_need_table_size = False + self.lib_need_noop_array = False + self.lib_need_stubs = False + self.lib_need_all_entries = False + self.lib_need_non_hidden_entries = True + + self.prefix_lib = 'GLAPI_PREFIX' + self.prefix_app = '_mesa_' + self.prefix_noop = 'noop' + self.prefix_warn = self.prefix_lib + + self.c_header = self._get_c_header() + + def _override_for_api(self, ent): + """Override attributes of an entry if necessary for this + printer.""" + # By default, no override is necessary. + pass + + def _get_c_header(self): + header = """#ifndef _GLAPI_TMP_H_ +#define _GLAPI_TMP_H_ +#ifdef USE_MGL_NAMESPACE +#define GLAPI_PREFIX(func) mgl##func +#define GLAPI_PREFIX_STR(func) "mgl"#func +#else +#define GLAPI_PREFIX(func) gl##func +#define GLAPI_PREFIX_STR(func) "gl"#func +#endif /* USE_MGL_NAMESPACE */ + +typedef int GLfixed; +typedef int GLclampx; +#endif /* _GLAPI_TMP_H_ */""" + + return header + +class ES1APIPrinter(GLAPIPrinter): + """OpenGL ES 1.x API Printer""" + + def __init__(self, entries): + super(ES1APIPrinter, self).__init__(entries) + self.prefix_lib = 'gl' + self.prefix_warn = 'gl' + + def _override_for_api(self, ent): + if ent.xml_data is None: + raise Exception('ES2 API printer requires XML input') + ent.hidden = ent.name not in \ + ent.xml_data.entry_points_for_api_version('es1') + ent.handcode = False + + def _get_c_header(self): + header = """#ifndef _GLAPI_TMP_H_ +#define _GLAPI_TMP_H_ +typedef int GLfixed; +typedef int GLclampx; +#endif /* _GLAPI_TMP_H_ */""" + + return header + +class ES2APIPrinter(GLAPIPrinter): + """OpenGL ES 2.x API Printer""" + + def __init__(self, entries): + super(ES2APIPrinter, self).__init__(entries) + self.prefix_lib = 'gl' + self.prefix_warn = 'gl' + + def _override_for_api(self, ent): + if ent.xml_data is None: + raise Exception('ES2 API printer requires XML input') + ent.hidden = ent.name not in \ + ent.xml_data.entry_points_for_api_version('es2') + ent.handcode = False + + def _get_c_header(self): + header = """#ifndef _GLAPI_TMP_H_ +#define _GLAPI_TMP_H_ +typedef int GLfixed; +typedef int GLclampx; +#endif /* _GLAPI_TMP_H_ */""" + + return header + +class SharedGLAPIPrinter(GLAPIPrinter): + """Shared GLAPI API Printer""" + + def __init__(self, entries): + super(SharedGLAPIPrinter, self).__init__(entries) + + self.lib_need_table_size = True + self.lib_need_noop_array = True + self.lib_need_stubs = True + self.lib_need_all_entries = True + self.lib_need_non_hidden_entries = False + + self.prefix_lib = 'shared' + self.prefix_warn = 'gl' + + def _override_for_api(self, ent): + ent.hidden = True + ent.handcode = False + + def _get_c_header(self): + header = """#ifndef _GLAPI_TMP_H_ +#define _GLAPI_TMP_H_ +typedef int GLfixed; +typedef int GLclampx; +#endif /* _GLAPI_TMP_H_ */""" + + return header + +class VGAPIPrinter(ABIPrinter): + """OpenVG API Printer""" + + def __init__(self, entries): + super(VGAPIPrinter, self).__init__(entries) + + self.api_defines = ['VG_VGEXT_PROTOTYPES'] + self.api_headers = ['"VG/openvg.h"', '"VG/vgext.h"'] + self.api_call = 'VG_API_CALL' + self.api_entry = 'VG_API_ENTRY' + self.api_attrs = 'VG_API_EXIT' + + self.prefix_lib = 'vg' + self.prefix_app = 'vega' + self.prefix_noop = 'noop' + self.prefix_warn = 'vg' + +def parse_args(): + printers = ['vgapi', 'glapi', 'es1api', 'es2api', 'shared-glapi'] + modes = ['lib', 'app'] + + parser = OptionParser(usage='usage: %prog [options] ') + parser.add_option('-p', '--printer', dest='printer', + help='printer to use: %s' % (", ".join(printers))) + parser.add_option('-m', '--mode', dest='mode', + help='target user: %s' % (", ".join(modes))) + + options, args = parser.parse_args() + if not args or options.printer not in printers or \ + options.mode not in modes: + parser.print_help() + sys.exit(1) + + return (args[0], options) + +def main(): + printers = { + 'vgapi': VGAPIPrinter, + 'glapi': GLAPIPrinter, + 'es1api': ES1APIPrinter, + 'es2api': ES2APIPrinter, + 'shared-glapi': SharedGLAPIPrinter, + } + + filename, options = parse_args() + + if filename.endswith('.xml'): + entries = abi_parse_xml(filename) + else: + entries = abi_parse(filename) + abi_sanity_check(entries) + + printer = printers[options.printer](entries) + if options.mode == 'lib': + printer.output_for_lib() + else: + printer.output_for_app() + +if __name__ == '__main__': + main() diff --git a/mesalib/src/mapi/mapi_glapi.c b/mesalib/src/mapi/mapi_glapi.c new file mode 100644 index 000000000..a6838ce61 --- /dev/null +++ b/mesalib/src/mapi/mapi_glapi.c @@ -0,0 +1,240 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include +#include "glapi/glapi.h" +#include "u_current.h" +#include "table.h" /* for MAPI_TABLE_NUM_SLOTS */ +#include "stub.h" + +/* + * Global variables, _glapi_get_context, and _glapi_get_dispatch are defined in + * u_current.c. + */ + +#ifdef GLX_USE_TLS +/* not used, but defined for compatibility */ +const struct _glapi_table *_glapi_Dispatch; +const void *_glapi_Context; +#endif /* GLX_USE_TLS */ + +void +_glapi_destroy_multithread(void) +{ + u_current_destroy(); +} + +void +_glapi_check_multithread(void) +{ + u_current_init(); +} + +void +_glapi_set_context(void *context) +{ + u_current_set_user((const void *) context); +} + +void +_glapi_set_dispatch(struct _glapi_table *dispatch) +{ + u_current_set((const struct mapi_table *) dispatch); +} + +/** + * Return size of dispatch table struct as number of functions (or + * slots). + */ +unsigned int +_glapi_get_dispatch_table_size(void) +{ + return MAPI_TABLE_NUM_SLOTS; +} + +/** + * Fill-in the dispatch stub for the named function. + * + * This function is intended to be called by a hardware driver. When called, + * a dispatch stub may be created created for the function. A pointer to this + * dispatch function will be returned by glXGetProcAddress. + * + * \param function_names Array of pointers to function names that should + * share a common dispatch offset. + * \param parameter_signature String representing the types of the parameters + * passed to the named function. Parameter types + * are converted to characters using the following + * rules: + * - 'i' for \c GLint, \c GLuint, and \c GLenum + * - 'p' for any pointer type + * - 'f' for \c GLfloat and \c GLclampf + * - 'd' for \c GLdouble and \c GLclampd + * + * \returns + * The offset in the dispatch table of the named function. A pointer to the + * driver's implementation of the named function should be stored at + * \c dispatch_table[\c offset]. Return -1 if error/problem. + * + * \sa glXGetProcAddress + * + * \warning + * This function can only handle up to 8 names at a time. As far as I know, + * the maximum number of names ever associated with an existing GL function is + * 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT, + * \c glPointParameterfARB, and \c glPointParameterf), so this should not be + * too painful of a limitation. + * + * \todo + * Check parameter_signature. + */ +int +_glapi_add_dispatch( const char * const * function_names, + const char * parameter_signature ) +{ + const struct mapi_stub *function_stubs[8]; + const struct mapi_stub *alias = NULL; + unsigned i; + + (void) memset(function_stubs, 0, sizeof(function_stubs)); + + /* find the missing stubs, and decide the alias */ + for (i = 0; function_names[i] != NULL && i < 8; i++) { + const char * funcName = function_names[i]; + const struct mapi_stub *stub; + int slot; + + if (!funcName || funcName[0] != 'g' || funcName[1] != 'l') + return -1; + funcName += 2; + + stub = stub_find_public(funcName); + if (!stub) + stub = stub_find_dynamic(funcName, 0); + + slot = (stub) ? stub_get_slot(stub) : -1; + if (slot >= 0) { + if (alias && stub_get_slot(alias) != slot) + return -1; + /* use the first existing stub as the alias */ + if (!alias) + alias = stub; + + function_stubs[i] = stub; + } + } + + /* generate missing stubs */ + for (i = 0; function_names[i] != NULL && i < 8; i++) { + const char * funcName = function_names[i] + 2; + struct mapi_stub *stub; + + if (function_stubs[i]) + continue; + + stub = stub_find_dynamic(funcName, 1); + if (!stub) + return -1; + + stub_fix_dynamic(stub, alias); + if (!alias) + alias = stub; + } + + return (alias) ? stub_get_slot(alias) : -1; +} + +static const struct mapi_stub * +_glapi_get_stub(const char *name, int generate) +{ + const struct mapi_stub *stub; + +#ifdef USE_MGL_NAMESPACE + if (name) + name++; +#endif + + if (!name || name[0] != 'g' || name[1] != 'l') + return NULL; + name += 2; + + stub = stub_find_public(name); + if (!stub) + stub = stub_find_dynamic(name, generate); + + return stub; +} + +/** + * Return offset of entrypoint for named function within dispatch table. + */ +int +_glapi_get_proc_offset(const char *funcName) +{ + const struct mapi_stub *stub = _glapi_get_stub(funcName, 0); + return (stub) ? stub_get_slot(stub) : -1; +} + +/** + * Return pointer to the named function. If the function name isn't found + * in the name of static functions, try generating a new API entrypoint on + * the fly with assembly language. + */ +_glapi_proc +_glapi_get_proc_address(const char *funcName) +{ + const struct mapi_stub *stub = _glapi_get_stub(funcName, 1); + return (stub) ? (_glapi_proc) stub_get_addr(stub) : NULL; +} + +/** + * Return the name of the function at the given dispatch offset. + * This is only intended for debugging. + */ +const char * +_glapi_get_proc_name(unsigned int offset) +{ + const struct mapi_stub *stub = stub_find_by_slot(offset); + return stub ? stub_get_name(stub) : NULL; +} + +unsigned long +_glthread_GetID(void) +{ + return u_thread_self(); +} + +void +_glapi_noop_enable_warnings(unsigned char enable) +{ +} + +void +_glapi_set_warning_func(_glapi_proc func) +{ +} diff --git a/mesalib/src/mapi/mapi_tmp.h b/mesalib/src/mapi/mapi_tmp.h new file mode 100644 index 000000000..f326b4a4e --- /dev/null +++ b/mesalib/src/mapi/mapi_tmp.h @@ -0,0 +1,48 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef MAPI_ABI_HEADER +#error "MAPI_ABI_HEADER must be defined" +#endif + +/* does not need hidden entries in bridge mode */ +#ifdef MAPI_MODE_BRIDGE + +#ifdef MAPI_TMP_PUBLIC_ENTRIES +#undef MAPI_TMP_PUBLIC_ENTRIES +#define MAPI_TMP_PUBLIC_ENTRIES_NO_HIDDEN +#endif + +#ifdef MAPI_TMP_STUB_ASM_GCC +#undef MAPI_TMP_STUB_ASM_GCC +#define MAPI_TMP_STUB_ASM_GCC_NO_HIDDEN +#endif + +#endif /* MAPI_MODE_BRIDGE */ + +#include MAPI_ABI_HEADER diff --git a/mesalib/src/mapi/stub.c b/mesalib/src/mapi/stub.c new file mode 100644 index 000000000..688dc8143 --- /dev/null +++ b/mesalib/src/mapi/stub.c @@ -0,0 +1,229 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include +#include +#include + +#include "u_current.h" +#include "u_thread.h" +#include "entry.h" +#include "stub.h" +#include "table.h" + +#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) + +struct mapi_stub { + const void *name; + int slot; + mapi_func addr; +}; + +/* define public_string_pool and public_stubs */ +#define MAPI_TMP_PUBLIC_STUBS +#include "mapi_tmp.h" + +static struct mapi_stub dynamic_stubs[MAPI_TABLE_NUM_DYNAMIC]; +static int num_dynamic_stubs; +static int next_dynamic_slot = MAPI_TABLE_NUM_STATIC; + +void +stub_init_once(void) +{ +#ifdef HAVE_PTHREAD + static pthread_once_t once = PTHREAD_ONCE_INIT; + pthread_once(&once, entry_patch_public); +#else + static int first = 1; + if (first) { + first = 0; + entry_patch_public(); + } +#endif +} + +static int +stub_compare(const void *key, const void *elem) +{ + const char *name = (const char *) key; + const struct mapi_stub *stub = (const struct mapi_stub *) elem; + const char *stub_name; + + stub_name = &public_string_pool[(unsigned long) stub->name]; + + return strcmp(name, stub_name); +} + +/** + * Return the public stub with the given name. + */ +const struct mapi_stub * +stub_find_public(const char *name) +{ + return (const struct mapi_stub *) bsearch(name, public_stubs, + ARRAY_SIZE(public_stubs), sizeof(public_stubs[0]), stub_compare); +} + +/** + * Add a dynamic stub. + */ +static struct mapi_stub * +stub_add_dynamic(const char *name) +{ + struct mapi_stub *stub; + int idx; + + idx = num_dynamic_stubs; + /* minus 1 to make sure we can never reach the last slot */ + if (idx >= MAPI_TABLE_NUM_DYNAMIC - 1) + return NULL; + + stub = &dynamic_stubs[idx]; + + /* dispatch to the last slot, which is reserved for no-op */ + stub->addr = entry_generate( + MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC - 1); + if (!stub->addr) + return NULL; + + stub->name = (const void *) name; + /* to be fixed later */ + stub->slot = -1; + + num_dynamic_stubs = idx + 1; + + return stub; +} + +/** + * Return the dynamic stub with the given name. If no such stub exists and + * generate is true, a new stub is generated. + */ +struct mapi_stub * +stub_find_dynamic(const char *name, int generate) +{ + u_mutex_declare_static(dynamic_mutex); + struct mapi_stub *stub = NULL; + int count, i; + + u_mutex_lock(dynamic_mutex); + + if (generate) + assert(!stub_find_public(name)); + + count = num_dynamic_stubs; + for (i = 0; i < count; i++) { + if (strcmp(name, (const char *) dynamic_stubs[i].name) == 0) { + stub = &dynamic_stubs[i]; + break; + } + } + + /* generate a dynamic stub */ + if (generate && !stub) + stub = stub_add_dynamic(name); + + u_mutex_unlock(dynamic_mutex); + + return stub; +} + +static const struct mapi_stub * +search_table_by_slot(const struct mapi_stub *table, size_t num_entries, + int slot) +{ + size_t i; + for (i = 0; i < num_entries; ++i) { + if (table[i].slot == slot) + return &table[i]; + } + return NULL; +} + +const struct mapi_stub * +stub_find_by_slot(int slot) +{ + const struct mapi_stub *stub = + search_table_by_slot(public_stubs, ARRAY_SIZE(public_stubs), slot); + if (stub) + return stub; + return search_table_by_slot(dynamic_stubs, num_dynamic_stubs, slot); +} + +void +stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias) +{ + int slot; + + if (stub->slot >= 0) + return; + + if (alias) + slot = alias->slot; + else + slot = next_dynamic_slot++; + + entry_patch(stub->addr, slot); + stub->slot = slot; +} + +/** + * Return the name of a stub. + */ +const char * +stub_get_name(const struct mapi_stub *stub) +{ + const char *name; + + if (stub >= public_stubs && + stub < public_stubs + ARRAY_SIZE(public_stubs)) + name = &public_string_pool[(unsigned long) stub->name]; + else + name = (const char *) stub->name; + + return name; +} + +/** + * Return the slot of a stub. + */ +int +stub_get_slot(const struct mapi_stub *stub) +{ + return stub->slot; +} + +/** + * Return the address of a stub. + */ +mapi_func +stub_get_addr(const struct mapi_stub *stub) +{ + assert(stub->addr || (unsigned int) stub->slot < MAPI_TABLE_NUM_STATIC); + return (stub->addr) ? stub->addr : entry_get_public(stub->slot); +} diff --git a/mesalib/src/mapi/stub.h b/mesalib/src/mapi/stub.h new file mode 100644 index 000000000..98e2553ec --- /dev/null +++ b/mesalib/src/mapi/stub.h @@ -0,0 +1,60 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _STUB_H_ +#define _STUB_H_ + +#include "entry.h" + +struct mapi_stub; + +void +stub_init_once(void); + +const struct mapi_stub * +stub_find_public(const char *name); + +struct mapi_stub * +stub_find_dynamic(const char *name, int generate); + +const struct mapi_stub * +stub_find_by_slot(int slot); + +void +stub_fix_dynamic(struct mapi_stub *stub, const struct mapi_stub *alias); + +const char * +stub_get_name(const struct mapi_stub *stub); + +int +stub_get_slot(const struct mapi_stub *stub); + +mapi_func +stub_get_addr(const struct mapi_stub *stub); + +#endif /* _STUB_H_ */ diff --git a/mesalib/src/mapi/table.c b/mesalib/src/mapi/table.c new file mode 100644 index 000000000..9bb9f654a --- /dev/null +++ b/mesalib/src/mapi/table.c @@ -0,0 +1,56 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#include +#include + +#include "table.h" + +static void +noop_warn(const char *name) +{ + static int debug = -1; + + if (debug < 0) + debug = (getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG")); + + if (debug) + fprintf(stderr, "%s is no-op\n", name); +} + +static int +noop_generic(void) +{ + noop_warn("function"); + return 0; +} + +/* define noop_array */ +#define MAPI_TMP_DEFINES +#define MAPI_TMP_NOOP_ARRAY +#include "mapi_tmp.h" diff --git a/mesalib/src/mapi/table.h b/mesalib/src/mapi/table.h new file mode 100644 index 000000000..d84523f77 --- /dev/null +++ b/mesalib/src/mapi/table.h @@ -0,0 +1,72 @@ +/* + * Mesa 3-D graphics library + * Version: 7.9 + * + * Copyright (C) 2010 LunarG Inc. + * + * 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 OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Authors: + * Chia-I Wu + */ + +#ifndef _TABLE_H_ +#define _TABLE_H_ + +#include "u_compiler.h" +#include "entry.h" + +#define MAPI_TMP_TABLE +#include "mapi_tmp.h" + +#define MAPI_TABLE_NUM_SLOTS (MAPI_TABLE_NUM_STATIC + MAPI_TABLE_NUM_DYNAMIC) +#define MAPI_TABLE_SIZE (MAPI_TABLE_NUM_SLOTS * sizeof(mapi_func)) + +extern const mapi_func table_noop_array[]; + +/** + * Get the no-op dispatch table. + */ +static INLINE const struct mapi_table * +table_get_noop(void) +{ + return (const struct mapi_table *) table_noop_array; +} + +/** + * Set the function of a slot. + */ +static INLINE void +table_set_func(struct mapi_table *tbl, int slot, mapi_func func) +{ + mapi_func *funcs = (mapi_func *) tbl; + funcs[slot] = func; +} + +/** + * Return the function of a slot. + */ +static INLINE mapi_func +table_get_func(const struct mapi_table *tbl, int slot) +{ + const mapi_func *funcs = (const mapi_func *) tbl; + return funcs[slot]; +} + +#endif /* _TABLE_H_ */ diff --git a/mesalib/src/mapi/u_compiler.h b/mesalib/src/mapi/u_compiler.h new file mode 100644 index 000000000..f376e97a0 --- /dev/null +++ b/mesalib/src/mapi/u_compiler.h @@ -0,0 +1,33 @@ +#ifndef _U_COMPILER_H_ +#define _U_COMPILER_H_ + +#include "c99_compat.h" /* inline, __func__, etc. */ + + +/* XXX: Use standard `inline` keyword instead */ +#ifndef INLINE +# define INLINE inline +#endif + +/* Function visibility */ +#ifndef PUBLIC +# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# define PUBLIC __attribute__((visibility("default"))) +# elif defined(_MSC_VER) +# define PUBLIC __declspec(dllexport) +# else +# define PUBLIC +# endif +#endif + +#ifndef likely +# if defined(__GNUC__) +# define likely(x) __builtin_expect(!!(x), 1) +# define unlikely(x) __builtin_expect(!!(x), 0) +# else +# define likely(x) (x) +# define unlikely(x) (x) +# endif +#endif + +#endif /* _U_COMPILER_H_ */ diff --git a/mesalib/src/mapi/u_current.c b/mesalib/src/mapi/u_current.c new file mode 100644 index 000000000..344344939 --- /dev/null +++ b/mesalib/src/mapi/u_current.c @@ -0,0 +1,267 @@ +/* + * Mesa 3-D graphics library + * Version: 7.1 + * + * Copyright (C) 1999-2008 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 + * 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. + */ + + +/* + * This file manages the OpenGL API dispatch layer. + * The dispatch table (struct _glapi_table) is basically just a list + * of function pointers. + * There are functions to set/get the current dispatch table for the + * current thread and to manage registration/dispatch of dynamically + * added extension functions. + * + * It's intended that this file and the other glapi*.[ch] files are + * flexible enough to be reused in several places: XFree86, DRI- + * based libGL.so, and perhaps the SGI SI. + * + * NOTE: There are no dependencies on Mesa in this code. + * + * Versions (API changes): + * 2000/02/23 - original version for Mesa 3.3 and XFree86 4.0 + * 2001/01/16 - added dispatch override feature for Mesa 3.5 + * 2002/06/28 - added _glapi_set_warning_func(), Mesa 4.1. + * 2002/10/01 - _glapi_get_proc_address() will now generate new entrypoints + * itself (using offset ~0). _glapi_add_entrypoint() can be + * called afterward and it'll fill in the correct dispatch + * offset. This allows DRI libGL to avoid probing for DRI + * drivers! No changes to the public glapi interface. + */ + +#include "u_current.h" +#include "u_thread.h" + +#ifndef MAPI_MODE_UTIL + +#include "table.h" +#include "stub.h" + +#else + +extern void init_glapi_relocs_once(void); +extern void (*__glapi_noop_table[])(void); + +#define table_noop_array __glapi_noop_table +#define stub_init_once() init_glapi_relocs_once() + +#endif + +/** + * \name Current dispatch and current context control variables + * + * Depending on whether or not multithreading is support, and the type of + * support available, several variables are used to store the current context + * pointer and the current dispatch table pointer. In the non-threaded case, + * the variables \c _glapi_Dispatch and \c _glapi_Context are used for this + * purpose. + * + * In the "normal" threaded case, the variables \c _glapi_Dispatch and + * \c _glapi_Context will be \c NULL if an application is detected as being + * multithreaded. Single-threaded applications will use \c _glapi_Dispatch + * and \c _glapi_Context just like the case without any threading support. + * When \c _glapi_Dispatch and \c _glapi_Context are \c NULL, the thread state + * data \c _gl_DispatchTSD and \c ContextTSD are used. Drivers and the + * static dispatch functions access these variables via \c _glapi_get_dispatch + * and \c _glapi_get_context. + * + * There is a race condition in setting \c _glapi_Dispatch to \c NULL. It is + * possible for the original thread to be setting it at the same instant a new + * thread, perhaps running on a different processor, is clearing it. Because + * of that, \c ThreadSafe, which can only ever be changed to \c GL_TRUE, is + * used to determine whether or not the application is multithreaded. + * + * In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context are + * hardcoded to \c NULL. Instead the TLS variables \c _glapi_tls_Dispatch and + * \c _glapi_tls_Context are used. Having \c _glapi_Dispatch and + * \c _glapi_Context be hardcoded to \c NULL maintains binary compatability + * between TLS enabled loaders and non-TLS DRI drivers. + */ +/*@{*/ +#if defined(GLX_USE_TLS) + +__thread struct mapi_table *u_current_table + __attribute__((tls_model("initial-exec"))) + = (struct mapi_table *) table_noop_array; + +__thread void *u_current_user + __attribute__((tls_model("initial-exec"))); + +#else + +struct mapi_table *u_current_table = + (struct mapi_table *) table_noop_array; +void *u_current_user; + +#ifdef THREADS +struct u_tsd u_current_table_tsd; +static struct u_tsd u_current_user_tsd; +static int ThreadSafe; +#endif /* THREADS */ + +#endif /* defined(GLX_USE_TLS) */ +/*@}*/ + + +void +u_current_destroy(void) +{ +#if defined(THREADS) && defined(_WIN32) + u_tsd_destroy(&u_current_table_tsd); + u_tsd_destroy(&u_current_user_tsd); +#endif +} + + +#if defined(THREADS) && !defined(GLX_USE_TLS) + +static void +u_current_init_tsd(void) +{ + u_tsd_init(&u_current_table_tsd); + u_tsd_init(&u_current_user_tsd); +} + +/** + * Mutex for multithread check. + */ +u_mutex_declare_static(ThreadCheckMutex); + +/** + * We should call this periodically from a function such as glXMakeCurrent + * in order to test if multiple threads are being used. + */ +void +u_current_init(void) +{ + static unsigned long knownID; + static int firstCall = 1; + + if (ThreadSafe) + return; + + u_mutex_lock(ThreadCheckMutex); + if (firstCall) { + u_current_init_tsd(); + + knownID = u_thread_self(); + firstCall = 0; + } + else if (knownID != u_thread_self()) { + ThreadSafe = 1; + u_current_set(NULL); + u_current_set_user(NULL); + } + u_mutex_unlock(ThreadCheckMutex); +} + +#else + +void +u_current_init(void) +{ +} + +#endif + + + +/** + * Set the current context pointer for this thread. + * The context pointer is an opaque type which should be cast to + * void from the real context pointer type. + */ +void +u_current_set_user(const void *ptr) +{ + u_current_init(); + +#if defined(GLX_USE_TLS) + u_current_user = (void *) ptr; +#elif defined(THREADS) + u_tsd_set(&u_current_user_tsd, (void *) ptr); + u_current_user = (ThreadSafe) ? NULL : (void *) ptr; +#else + u_current_user = (void *) ptr; +#endif +} + +/** + * Get the current context pointer for this thread. + * The context pointer is an opaque type which should be cast from + * void to the real context pointer type. + */ +void * +u_current_get_user_internal(void) +{ +#if defined(GLX_USE_TLS) + return u_current_user; +#elif defined(THREADS) + return (ThreadSafe) + ? u_tsd_get(&u_current_user_tsd) + : u_current_user; +#else + return u_current_user; +#endif +} + +/** + * Set the global or per-thread dispatch table pointer. + * If the dispatch parameter is NULL we'll plug in the no-op dispatch + * table (__glapi_noop_table). + */ +void +u_current_set(const struct mapi_table *tbl) +{ + u_current_init(); + + stub_init_once(); + + if (!tbl) + tbl = (const struct mapi_table *) table_noop_array; + +#if defined(GLX_USE_TLS) + u_current_table = (struct mapi_table *) tbl; +#elif defined(THREADS) + u_tsd_set(&u_current_table_tsd, (void *) tbl); + u_current_table = (ThreadSafe) ? NULL : (void *) tbl; +#else + u_current_table = (struct mapi_table *) tbl; +#endif +} + +/** + * Return pointer to current dispatch table for calling thread. + */ +struct mapi_table * +u_current_get_internal(void) +{ +#if defined(GLX_USE_TLS) + return u_current_table; +#elif defined(THREADS) + return (struct mapi_table *) ((ThreadSafe) ? + u_tsd_get(&u_current_table_tsd) : (void *) u_current_table); +#else + return u_current_table; +#endif +} diff --git a/mesalib/src/mapi/u_current.h b/mesalib/src/mapi/u_current.h new file mode 100644 index 000000000..f9cffd8c3 --- /dev/null +++ b/mesalib/src/mapi/u_current.h @@ -0,0 +1,87 @@ +#ifndef _U_CURRENT_H_ +#define _U_CURRENT_H_ + +#if defined(MAPI_MODE_UTIL) || defined(MAPI_MODE_GLAPI) || \ + defined(MAPI_MODE_BRIDGE) + +#include "glapi/glapi.h" + +/* ugly renames to match glapi.h */ +#define mapi_table _glapi_table + +#ifdef GLX_USE_TLS +#define u_current_table _glapi_tls_Dispatch +#define u_current_user _glapi_tls_Context +#else +#define u_current_table _glapi_Dispatch +#define u_current_user _glapi_Context +#endif + +#define u_current_get_internal _glapi_get_dispatch +#define u_current_get_user_internal _glapi_get_context + +#define u_current_table_tsd _gl_DispatchTSD + +#else /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ + +#include "u_compiler.h" + +struct mapi_table; + +#ifdef GLX_USE_TLS + +extern __thread struct mapi_table *u_current_table + __attribute__((tls_model("initial-exec"))); + +extern __thread void *u_current_user + __attribute__((tls_model("initial-exec"))); + +#else /* GLX_USE_TLS */ + +extern struct mapi_table *u_current_table; +extern void *u_current_user; + +#endif /* GLX_USE_TLS */ + +#endif /* MAPI_MODE_UTIL || MAPI_MODE_GLAPI || MAPI_MODE_BRIDGE */ + +void +u_current_init(void); + +void +u_current_destroy(void); + +void +u_current_set(const struct mapi_table *tbl); + +struct mapi_table * +u_current_get_internal(void); + +void +u_current_set_user(const void *ptr); + +void * +u_current_get_user_internal(void); + +static INLINE const struct mapi_table * +u_current_get(void) +{ +#ifdef GLX_USE_TLS + return u_current_table; +#else + return (likely(u_current_table) ? + u_current_table : u_current_get_internal()); +#endif +} + +static INLINE const void * +u_current_get_user(void) +{ +#ifdef GLX_USE_TLS + return u_current_user; +#else + return likely(u_current_user) ? u_current_user : u_current_get_user_internal(); +#endif +} + +#endif /* _U_CURRENT_H_ */ diff --git a/mesalib/src/mapi/u_execmem.c b/mesalib/src/mapi/u_execmem.c new file mode 100644 index 000000000..b6751edb5 --- /dev/null +++ b/mesalib/src/mapi/u_execmem.c @@ -0,0 +1,146 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5 + * + * Copyright (C) 1999-2005 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 + * 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. + */ + + +/** + * \file glapi_execmem.c + * + * Function for allocating executable memory for dispatch stubs. + * + * Copied from main/execmem.c and simplified for dispatch stubs. + */ + + +#include "u_compiler.h" +#include "u_thread.h" +#include "u_execmem.h" + + +#define EXEC_MAP_SIZE (4*1024) + +u_mutex_declare_static(exec_mutex); + +static unsigned int head = 0; + +static unsigned char *exec_mem = (unsigned char *)0; + + +#if defined(__linux__) || defined(__OpenBSD__) || defined(_NetBSD__) || defined(__sun) || defined(__HAIKU__) + +#include +#include + +#ifdef MESA_SELINUX +#include +#endif + + +#ifndef MAP_ANONYMOUS +#define MAP_ANONYMOUS MAP_ANON +#endif + + +/* + * Dispatch stubs are of fixed size and never freed. Thus, we do not need to + * overlay a heap, we just mmap a page and manage through an index. + */ + +static int +init_map(void) +{ +#ifdef MESA_SELINUX + if (is_selinux_enabled()) { + if (!security_get_boolean_active("allow_execmem") || + !security_get_boolean_pending("allow_execmem")) + return 0; + } +#endif + + if (!exec_mem) + exec_mem = mmap(NULL, EXEC_MAP_SIZE, PROT_EXEC | PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + + return (exec_mem != MAP_FAILED); +} + + +#elif defined(_WIN32) + +#include + + +/* + * Avoid Data Execution Prevention. + */ + +static int +init_map(void) +{ + exec_mem = VirtualAlloc(NULL, EXEC_MAP_SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + + return (exec_mem != NULL); +} + + +#else + +#include + +static int +init_map(void) +{ + exec_mem = malloc(EXEC_MAP_SIZE); + + return (exec_mem != NULL); +} + + +#endif + +void * +u_execmem_alloc(unsigned int size) +{ + void *addr = NULL; + + u_mutex_lock(exec_mutex); + + if (!init_map()) + goto bail; + + /* free space check, assumes no integer overflow */ + if (head + size > EXEC_MAP_SIZE) + goto bail; + + /* allocation, assumes proper addr and size alignement */ + addr = exec_mem + head; + head += size; + +bail: + u_mutex_unlock(exec_mutex); + + return addr; +} + + diff --git a/mesalib/src/mapi/u_execmem.h b/mesalib/src/mapi/u_execmem.h new file mode 100644 index 000000000..13fff8df2 --- /dev/null +++ b/mesalib/src/mapi/u_execmem.h @@ -0,0 +1,7 @@ +#ifndef _U_EXECMEM_H_ +#define _U_EXECMEM_H_ + +void * +u_execmem_alloc(unsigned int size); + +#endif /* _U_EXECMEM_H_ */ diff --git a/mesalib/src/mapi/u_macros.h b/mesalib/src/mapi/u_macros.h new file mode 100644 index 000000000..72345b5f1 --- /dev/null +++ b/mesalib/src/mapi/u_macros.h @@ -0,0 +1,12 @@ +#ifndef _U_MACROS_ +#define _U_MACROS_ + +#define _U_STRINGIFY(x) #x +#define _U_CONCAT(x, y) x ## y +#define _U_CONCAT_STR(x, y) #x#y + +#define U_STRINGIFY(x) _U_STRINGIFY(x) +#define U_CONCAT(x, y) _U_CONCAT(x, y) +#define U_CONCAT_STR(x, y) _U_CONCAT_STR(x, y) + +#endif /* _U_MACROS_ */ diff --git a/mesalib/src/mapi/u_thread.h b/mesalib/src/mapi/u_thread.h new file mode 100644 index 000000000..2f8154373 --- /dev/null +++ b/mesalib/src/mapi/u_thread.h @@ -0,0 +1,288 @@ +/* + * Mesa 3-D graphics library + * Version: 6.5.2 + * + * 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 + * 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. + */ + + +/* + * Thread support for gl dispatch. + * + * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu) + * and Christoph Poliwoda (poliwoda@volumegraphics.com) + * Revised by Keith Whitwell + * Adapted for new gl dispatcher by Brian Paul + * Modified for use in mapi by Chia-I Wu + */ + +/* + * If this file is accidentally included by a non-threaded build, + * it should not cause the build to fail, or otherwise cause problems. + * In general, it should only be included when needed however. + */ + +#ifndef _U_THREAD_H_ +#define _U_THREAD_H_ + +#include +#include +#include "u_compiler.h" + +#if defined(HAVE_PTHREAD) +#include /* POSIX threads headers */ +#endif +#ifdef _WIN32 +#include +#endif + +#if defined(HAVE_PTHREAD) || defined(_WIN32) +#ifndef THREADS +#define THREADS +#endif +#endif + +/* + * Error messages + */ +#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data" +#define GET_TSD_ERROR "_glthread_: failed to get thread specific data" +#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data" + + +/* + * Magic number to determine if a TSD object has been initialized. + * Kind of a hack but there doesn't appear to be a better cross-platform + * solution. + */ +#define INIT_MAGIC 0xff8adc98 + +#ifdef __cplusplus +extern "C" { +#endif + + +/* + * POSIX threads. This should be your choice in the Unix world + * whenever possible. When building with POSIX threads, be sure + * to enable any compiler flags which will cause the MT-safe + * libc (if one exists) to be used when linking, as well as any + * header macros for MT-safe errno, etc. For Solaris, this is the -mt + * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable + * proper compiling for MT-safe libc etc. + */ +#if defined(HAVE_PTHREAD) + +struct u_tsd { + pthread_key_t key; + unsigned initMagic; +}; + +typedef pthread_mutex_t u_mutex; + +#define u_mutex_declare_static(name) \ + static u_mutex name = PTHREAD_MUTEX_INITIALIZER + +#define u_mutex_init(name) pthread_mutex_init(&(name), NULL) +#define u_mutex_destroy(name) pthread_mutex_destroy(&(name)) +#define u_mutex_lock(name) (void) pthread_mutex_lock(&(name)) +#define u_mutex_unlock(name) (void) pthread_mutex_unlock(&(name)) + +static INLINE unsigned long +u_thread_self(void) +{ + return (unsigned long) pthread_self(); +} + + +static INLINE void +u_tsd_init(struct u_tsd *tsd) +{ + if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) { + perror(INIT_TSD_ERROR); + exit(-1); + } + tsd->initMagic = INIT_MAGIC; +} + + +static INLINE void * +u_tsd_get(struct u_tsd *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + return pthread_getspecific(tsd->key); +} + + +static INLINE void +u_tsd_set(struct u_tsd *tsd, void *ptr) +{ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + if (pthread_setspecific(tsd->key, ptr) != 0) { + perror(SET_TSD_ERROR); + exit(-1); + } +} + +#endif /* HAVE_PTHREAD */ + + +/* + * Windows threads. Should work with Windows NT and 95. + * IMPORTANT: Link with multithreaded runtime library when THREADS are + * used! + */ +#ifdef _WIN32 + +struct u_tsd { + DWORD key; + unsigned initMagic; +}; + +typedef CRITICAL_SECTION u_mutex; + +/* http://locklessinc.com/articles/pthreads_on_windows/ */ +#define u_mutex_declare_static(name) \ + static u_mutex name = {(PCRITICAL_SECTION_DEBUG)-1, -1, 0, 0, 0, 0} + +#define u_mutex_init(name) InitializeCriticalSection(&name) +#define u_mutex_destroy(name) DeleteCriticalSection(&name) +#define u_mutex_lock(name) EnterCriticalSection(&name) +#define u_mutex_unlock(name) LeaveCriticalSection(&name) + +static INLINE unsigned long +u_thread_self(void) +{ + return GetCurrentThreadId(); +} + + +static INLINE void +u_tsd_init(struct u_tsd *tsd) +{ + tsd->key = TlsAlloc(); + if (tsd->key == TLS_OUT_OF_INDEXES) { + perror(INIT_TSD_ERROR); + exit(-1); + } + tsd->initMagic = INIT_MAGIC; +} + + +static INLINE void +u_tsd_destroy(struct u_tsd *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + return; + } + TlsFree(tsd->key); + tsd->initMagic = 0x0; +} + + +static INLINE void * +u_tsd_get(struct u_tsd *tsd) +{ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + return TlsGetValue(tsd->key); +} + + +static INLINE void +u_tsd_set(struct u_tsd *tsd, void *ptr) +{ + /* the following code assumes that the struct u_tsd has been initialized + to zero at creation */ + if (tsd->initMagic != INIT_MAGIC) { + u_tsd_init(tsd); + } + if (TlsSetValue(tsd->key, ptr) == 0) { + perror(SET_TSD_ERROR); + exit(-1); + } +} + +#endif /* _WIN32 */ + + +/* + * THREADS not defined + */ +#ifndef THREADS + +struct u_tsd { + unsigned initMagic; +}; + +typedef unsigned u_mutex; + +#define u_mutex_declare_static(name) static u_mutex name = 0 +#define u_mutex_init(name) (void) name +#define u_mutex_destroy(name) (void) name +#define u_mutex_lock(name) (void) name +#define u_mutex_unlock(name) (void) name + +/* + * no-op functions + */ + +static INLINE unsigned long +u_thread_self(void) +{ + return 0; +} + + +static INLINE void +u_tsd_init(struct u_tsd *tsd) +{ + (void) tsd; +} + + +static INLINE void * +u_tsd_get(struct u_tsd *tsd) +{ + (void) tsd; + return NULL; +} + + +static INLINE void +u_tsd_set(struct u_tsd *tsd, void *ptr) +{ + (void) tsd; + (void) ptr; +} +#endif /* THREADS */ + + +#ifdef __cplusplus +} +#endif + +#endif /* _U_THREAD_H_ */ diff --git a/mesalib/src/mesa/Android.gen.mk b/mesalib/src/mesa/Android.gen.mk index 35f00da09..c6280f5cb 100644 --- a/mesalib/src/mesa/Android.gen.mk +++ b/mesalib/src/mesa/Android.gen.mk @@ -111,8 +111,7 @@ $(intermediates)/main/api_exec.c: $(dispatch_deps) $(call es-gen) GET_HASH_GEN := $(LOCAL_PATH)/main/get_hash_generator.py -GET_HASH_GEN_FLAGS := $(patsubst %,-a %,$(MESA_ENABLED_APIS)) $(intermediates)/main/get_hash.h: $(glapi)/gl_and_es_API.xml \ $(LOCAL_PATH)/main/get_hash_params.py $(GET_HASH_GEN) - @$(MESA_PYTHON2) $(GET_HASH_GEN) $(GET_HASH_GEN_FLAGS) -f $< > $@ + @$(MESA_PYTHON2) $(GET_HASH_GEN) -f $< > $@ diff --git a/mesalib/src/mesa/Android.libmesa_dricore.mk b/mesalib/src/mesa/Android.libmesa_dricore.mk index 093d7a189..00c06943c 100644 --- a/mesalib/src/mesa/Android.libmesa_dricore.mk +++ b/mesalib/src/mesa/Android.libmesa_dricore.mk @@ -31,7 +31,7 @@ LOCAL_PATH := $(call my-dir) # Import the following variables: # MESA_FILES # X86_FILES -include $(LOCAL_PATH)/sources.mak +include $(LOCAL_PATH)/Makefile.sources include $(CLEAR_VARS) diff --git a/mesalib/src/mesa/Android.libmesa_st_mesa.mk b/mesalib/src/mesa/Android.libmesa_st_mesa.mk index 79914caf1..e7203c41d 100644 --- a/mesalib/src/mesa/Android.libmesa_st_mesa.mk +++ b/mesalib/src/mesa/Android.libmesa_st_mesa.mk @@ -31,7 +31,7 @@ LOCAL_PATH := $(call my-dir) # Import variables: # MESA_GALLIUM_FILES. # X86_FILES -include $(LOCAL_PATH)/sources.mak +include $(LOCAL_PATH)/Makefile.sources include $(CLEAR_VARS) diff --git a/mesalib/src/mesa/Makefile.am b/mesalib/src/mesa/Makefile.am index c341c48e7..d5f5f5b86 100644 --- a/mesalib/src/mesa/Makefile.am +++ b/mesalib/src/mesa/Makefile.am @@ -23,7 +23,19 @@ if NEED_LIBDRICORE DRICORE_SUBDIR = libdricore endif -SUBDIRS = program x86 x86-64 . $(DRICORE_SUBDIR) drivers +SUBDIRS = program x86 x86-64 . $(DRICORE_SUBDIR) + +if HAVE_X11_DRIVER +SUBDIRS += drivers/x11 +endif + +if HAVE_DRI +SUBDIRS += drivers/dri +endif + +if HAVE_OSMESA +SUBDIRS += drivers/osmesa +endif gldir = $(includedir)/GL gl_HEADERS = $(top_srcdir)/include/GL/*.h @@ -59,14 +71,12 @@ CLEANFILES = \ git_sha1.h.tmp GET_HASH_GEN = main/get_hash_generator.py -GET_HASH_GEN_FLAGS := $(patsubst -DFEATURE_%=1,-a %, \ - $(patsubst -DFEATURE_%=0,,$(API_DEFINES))) main/get_hash.h: $(GLAPI)/gl_and_es_API.xml main/get_hash_params.py \ $(GET_HASH_GEN) Makefile $(AM_V_GEN)set -e; \ - $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/$(GET_HASH_GEN) \ - $(GET_HASH_GEN_FLAGS) -f $< > $@.tmp; \ + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/$(GET_HASH_GEN) \ + -f $< > $@.tmp; \ mv $@.tmp $@; noinst_LTLIBRARIES = @@ -81,9 +91,9 @@ endif SRCDIR = $(top_srcdir)/src/mesa/ BUILDDIR = $(top_builddir)/src/mesa/ -include sources.mak +include Makefile.sources -AM_CPPFLAGS = $(API_DEFINES) $(DEFINES) $(INCLUDE_DIRS) +AM_CPPFLAGS = $(DEFINES) $(INCLUDE_DIRS) AM_CFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CFLAGS) AM_CXXFLAGS = $(LLVM_CFLAGS) $(VISIBILITY_CXXFLAGS) diff --git a/mesalib/src/mesa/Makefile.sources b/mesalib/src/mesa/Makefile.sources new file mode 100644 index 000000000..a5c1f5dea --- /dev/null +++ b/mesalib/src/mesa/Makefile.sources @@ -0,0 +1,350 @@ +### Lists of source files, included by Makefiles + +# This file is among different build systems. SRCDIR must be defined with +# a trailing slash because the Android build system leaves it undefined. + +# this is part of MAIN_FILES +MAIN_ES_FILES = \ + $(SRCDIR)main/es1_conversion.c + +MAIN_FILES = \ + $(SRCDIR)main/api_arrayelt.c \ + $(BUILDDIR)main/api_exec.c \ + $(SRCDIR)main/api_loopback.c \ + $(SRCDIR)main/api_validate.c \ + $(SRCDIR)main/accum.c \ + $(SRCDIR)main/arbprogram.c \ + $(SRCDIR)main/atifragshader.c \ + $(SRCDIR)main/attrib.c \ + $(SRCDIR)main/arrayobj.c \ + $(SRCDIR)main/blend.c \ + $(SRCDIR)main/bufferobj.c \ + $(SRCDIR)main/buffers.c \ + $(SRCDIR)main/clear.c \ + $(SRCDIR)main/clip.c \ + $(SRCDIR)main/colortab.c \ + $(SRCDIR)main/condrender.c \ + $(SRCDIR)main/context.c \ + $(SRCDIR)main/convolve.c \ + $(SRCDIR)main/cpuinfo.c \ + $(SRCDIR)main/debug.c \ + $(SRCDIR)main/depth.c \ + $(SRCDIR)main/dlist.c \ + $(SRCDIR)main/drawpix.c \ + $(SRCDIR)main/drawtex.c \ + $(SRCDIR)main/enable.c \ + $(SRCDIR)main/errors.c \ + $(SRCDIR)main/eval.c \ + $(SRCDIR)main/execmem.c \ + $(SRCDIR)main/extensions.c \ + $(SRCDIR)main/fbobject.c \ + $(SRCDIR)main/feedback.c \ + $(SRCDIR)main/ffvertex_prog.c \ + $(SRCDIR)main/ff_fragment_shader.cpp \ + $(SRCDIR)main/fog.c \ + $(SRCDIR)main/formatquery.c \ + $(SRCDIR)main/formats.c \ + $(SRCDIR)main/format_pack.c \ + $(SRCDIR)main/format_unpack.c \ + $(SRCDIR)main/framebuffer.c \ + $(SRCDIR)main/get.c \ + $(SRCDIR)main/getstring.c \ + $(SRCDIR)main/glformats.c \ + $(SRCDIR)main/hash.c \ + $(SRCDIR)main/hash_table.c \ + $(SRCDIR)main/hint.c \ + $(SRCDIR)main/histogram.c \ + $(SRCDIR)main/image.c \ + $(SRCDIR)main/imports.c \ + $(SRCDIR)main/light.c \ + $(SRCDIR)main/lines.c \ + $(SRCDIR)main/matrix.c \ + $(SRCDIR)main/mipmap.c \ + $(SRCDIR)main/mm.c \ + $(SRCDIR)main/multisample.c \ + $(SRCDIR)main/pack.c \ + $(SRCDIR)main/pbo.c \ + $(SRCDIR)main/pixel.c \ + $(SRCDIR)main/pixelstore.c \ + $(SRCDIR)main/pixeltransfer.c \ + $(SRCDIR)main/points.c \ + $(SRCDIR)main/polygon.c \ + $(SRCDIR)main/queryobj.c \ + $(SRCDIR)main/querymatrix.c \ + $(SRCDIR)main/rastpos.c \ + $(SRCDIR)main/readpix.c \ + $(SRCDIR)main/remap.c \ + $(SRCDIR)main/renderbuffer.c \ + $(SRCDIR)main/samplerobj.c \ + $(SRCDIR)main/scissor.c \ + $(SRCDIR)main/set.c \ + $(SRCDIR)main/shaderapi.c \ + $(SRCDIR)main/shaderobj.c \ + $(SRCDIR)main/shader_query.cpp \ + $(SRCDIR)main/shared.c \ + $(SRCDIR)main/state.c \ + $(SRCDIR)main/stencil.c \ + $(SRCDIR)main/syncobj.c \ + $(SRCDIR)main/texcompress.c \ + $(SRCDIR)main/texcompress_cpal.c \ + $(SRCDIR)main/texcompress_rgtc.c \ + $(SRCDIR)main/texcompress_s3tc.c \ + $(SRCDIR)main/texcompress_fxt1.c \ + $(SRCDIR)main/texcompress_etc.c \ + $(SRCDIR)main/texenv.c \ + $(SRCDIR)main/texformat.c \ + $(SRCDIR)main/texgen.c \ + $(SRCDIR)main/texgetimage.c \ + $(SRCDIR)main/teximage.c \ + $(SRCDIR)main/texobj.c \ + $(SRCDIR)main/texparam.c \ + $(SRCDIR)main/texstate.c \ + $(SRCDIR)main/texstorage.c \ + $(SRCDIR)main/texstore.c \ + $(SRCDIR)main/texturebarrier.c \ + $(SRCDIR)main/transformfeedback.c \ + $(SRCDIR)main/uniforms.c \ + $(SRCDIR)main/uniform_query.cpp \ + $(SRCDIR)main/varray.c \ + $(SRCDIR)main/version.c \ + $(SRCDIR)main/viewport.c \ + $(SRCDIR)main/vtxfmt.c \ + $(BUILDDIR)main/enums.c \ + $(MAIN_ES_FILES) + +MATH_FILES = \ + $(SRCDIR)math/m_debug_clip.c \ + $(SRCDIR)math/m_debug_norm.c \ + $(SRCDIR)math/m_debug_xform.c \ + $(SRCDIR)math/m_eval.c \ + $(SRCDIR)math/m_matrix.c \ + $(SRCDIR)math/m_translate.c \ + $(SRCDIR)math/m_vector.c + +MATH_XFORM_FILES = \ + $(SRCDIR)math/m_xform.c + +SWRAST_FILES = \ + $(SRCDIR)swrast/s_aaline.c \ + $(SRCDIR)swrast/s_aatriangle.c \ + $(SRCDIR)swrast/s_alpha.c \ + $(SRCDIR)swrast/s_atifragshader.c \ + $(SRCDIR)swrast/s_bitmap.c \ + $(SRCDIR)swrast/s_blend.c \ + $(SRCDIR)swrast/s_blit.c \ + $(SRCDIR)swrast/s_clear.c \ + $(SRCDIR)swrast/s_copypix.c \ + $(SRCDIR)swrast/s_context.c \ + $(SRCDIR)swrast/s_depth.c \ + $(SRCDIR)swrast/s_drawpix.c \ + $(SRCDIR)swrast/s_feedback.c \ + $(SRCDIR)swrast/s_fog.c \ + $(SRCDIR)swrast/s_fragprog.c \ + $(SRCDIR)swrast/s_lines.c \ + $(SRCDIR)swrast/s_logic.c \ + $(SRCDIR)swrast/s_masking.c \ + $(SRCDIR)swrast/s_points.c \ + $(SRCDIR)swrast/s_renderbuffer.c \ + $(SRCDIR)swrast/s_span.c \ + $(SRCDIR)swrast/s_stencil.c \ + $(SRCDIR)swrast/s_texcombine.c \ + $(SRCDIR)swrast/s_texfetch.c \ + $(SRCDIR)swrast/s_texfilter.c \ + $(SRCDIR)swrast/s_texrender.c \ + $(SRCDIR)swrast/s_texture.c \ + $(SRCDIR)swrast/s_triangle.c \ + $(SRCDIR)swrast/s_zoom.c + +SWRAST_SETUP_FILES = \ + $(SRCDIR)swrast_setup/ss_context.c \ + $(SRCDIR)swrast_setup/ss_triangle.c + +TNL_FILES = \ + $(SRCDIR)tnl/t_context.c \ + $(SRCDIR)tnl/t_pipeline.c \ + $(SRCDIR)tnl/t_draw.c \ + $(SRCDIR)tnl/t_rasterpos.c \ + $(SRCDIR)tnl/t_vb_program.c \ + $(SRCDIR)tnl/t_vb_render.c \ + $(SRCDIR)tnl/t_vb_texgen.c \ + $(SRCDIR)tnl/t_vb_texmat.c \ + $(SRCDIR)tnl/t_vb_vertex.c \ + $(SRCDIR)tnl/t_vb_fog.c \ + $(SRCDIR)tnl/t_vb_light.c \ + $(SRCDIR)tnl/t_vb_normals.c \ + $(SRCDIR)tnl/t_vb_points.c \ + $(SRCDIR)tnl/t_vp_build.c \ + $(SRCDIR)tnl/t_vertex.c \ + $(SRCDIR)tnl/t_vertex_sse.c \ + $(SRCDIR)tnl/t_vertex_generic.c + +VBO_FILES = \ + $(SRCDIR)vbo/vbo_context.c \ + $(SRCDIR)vbo/vbo_exec.c \ + $(SRCDIR)vbo/vbo_exec_api.c \ + $(SRCDIR)vbo/vbo_exec_array.c \ + $(SRCDIR)vbo/vbo_exec_draw.c \ + $(SRCDIR)vbo/vbo_exec_eval.c \ + $(SRCDIR)vbo/vbo_noop.c \ + $(SRCDIR)vbo/vbo_primitive_restart.c \ + $(SRCDIR)vbo/vbo_rebase.c \ + $(SRCDIR)vbo/vbo_split.c \ + $(SRCDIR)vbo/vbo_split_copy.c \ + $(SRCDIR)vbo/vbo_split_inplace.c \ + $(SRCDIR)vbo/vbo_save.c \ + $(SRCDIR)vbo/vbo_save_api.c \ + $(SRCDIR)vbo/vbo_save_draw.c \ + $(SRCDIR)vbo/vbo_save_loopback.c + +STATETRACKER_FILES = \ + $(SRCDIR)state_tracker/st_atom.c \ + $(SRCDIR)state_tracker/st_atom_array.c \ + $(SRCDIR)state_tracker/st_atom_blend.c \ + $(SRCDIR)state_tracker/st_atom_clip.c \ + $(SRCDIR)state_tracker/st_atom_constbuf.c \ + $(SRCDIR)state_tracker/st_atom_depth.c \ + $(SRCDIR)state_tracker/st_atom_framebuffer.c \ + $(SRCDIR)state_tracker/st_atom_msaa.c \ + $(SRCDIR)state_tracker/st_atom_pixeltransfer.c \ + $(SRCDIR)state_tracker/st_atom_sampler.c \ + $(SRCDIR)state_tracker/st_atom_scissor.c \ + $(SRCDIR)state_tracker/st_atom_shader.c \ + $(SRCDIR)state_tracker/st_atom_rasterizer.c \ + $(SRCDIR)state_tracker/st_atom_stipple.c \ + $(SRCDIR)state_tracker/st_atom_texture.c \ + $(SRCDIR)state_tracker/st_atom_viewport.c \ + $(SRCDIR)state_tracker/st_cb_bitmap.c \ + $(SRCDIR)state_tracker/st_cb_blit.c \ + $(SRCDIR)state_tracker/st_cb_bufferobjects.c \ + $(SRCDIR)state_tracker/st_cb_clear.c \ + $(SRCDIR)state_tracker/st_cb_condrender.c \ + $(SRCDIR)state_tracker/st_cb_flush.c \ + $(SRCDIR)state_tracker/st_cb_drawpixels.c \ + $(SRCDIR)state_tracker/st_cb_drawtex.c \ + $(SRCDIR)state_tracker/st_cb_eglimage.c \ + $(SRCDIR)state_tracker/st_cb_fbo.c \ + $(SRCDIR)state_tracker/st_cb_feedback.c \ + $(SRCDIR)state_tracker/st_cb_msaa.c \ + $(SRCDIR)state_tracker/st_cb_program.c \ + $(SRCDIR)state_tracker/st_cb_queryobj.c \ + $(SRCDIR)state_tracker/st_cb_rasterpos.c \ + $(SRCDIR)state_tracker/st_cb_readpixels.c \ + $(SRCDIR)state_tracker/st_cb_syncobj.c \ + $(SRCDIR)state_tracker/st_cb_strings.c \ + $(SRCDIR)state_tracker/st_cb_texture.c \ + $(SRCDIR)state_tracker/st_cb_texturebarrier.c \ + $(SRCDIR)state_tracker/st_cb_viewport.c \ + $(SRCDIR)state_tracker/st_cb_xformfb.c \ + $(SRCDIR)state_tracker/st_context.c \ + $(SRCDIR)state_tracker/st_debug.c \ + $(SRCDIR)state_tracker/st_draw.c \ + $(SRCDIR)state_tracker/st_draw_feedback.c \ + $(SRCDIR)state_tracker/st_extensions.c \ + $(SRCDIR)state_tracker/st_format.c \ + $(SRCDIR)state_tracker/st_gen_mipmap.c \ + $(SRCDIR)state_tracker/st_glsl_to_tgsi.cpp \ + $(SRCDIR)state_tracker/st_manager.c \ + $(SRCDIR)state_tracker/st_mesa_to_tgsi.c \ + $(SRCDIR)state_tracker/st_program.c \ + $(SRCDIR)state_tracker/st_texture.c + +PROGRAM_FILES = \ + $(SRCDIR)program/arbprogparse.c \ + $(SRCDIR)program/prog_hash_table.c \ + $(SRCDIR)program/ir_to_mesa.cpp \ + $(SRCDIR)program/program.c \ + $(SRCDIR)program/program_parse_extra.c \ + $(SRCDIR)program/prog_cache.c \ + $(SRCDIR)program/prog_execute.c \ + $(SRCDIR)program/prog_instruction.c \ + $(SRCDIR)program/prog_noise.c \ + $(SRCDIR)program/prog_optimize.c \ + $(SRCDIR)program/prog_opt_constant_fold.c \ + $(SRCDIR)program/prog_parameter.c \ + $(SRCDIR)program/prog_parameter_layout.c \ + $(SRCDIR)program/prog_print.c \ + $(SRCDIR)program/prog_statevars.c \ + $(SRCDIR)program/programopt.c \ + $(SRCDIR)program/register_allocate.c \ + $(SRCDIR)program/sampler.cpp \ + $(SRCDIR)program/string_to_uint_map.cpp \ + $(SRCDIR)program/symbol_table.c \ + $(BUILDDIR)program/lex.yy.c \ + $(BUILDDIR)program/program_parse.tab.c + +ASM_C_FILES = \ + $(SRCDIR)x86/common_x86.c \ + $(SRCDIR)x86/x86_xform.c \ + $(SRCDIR)x86/3dnow.c \ + $(SRCDIR)x86/sse.c \ + $(SRCDIR)x86/rtasm/x86sse.c \ + $(SRCDIR)sparc/sparc.c \ + $(SRCDIR)x86-64/x86-64.c + +X86_FILES = \ + $(SRCDIR)x86/common_x86_asm.S \ + $(SRCDIR)x86/x86_xform2.S \ + $(SRCDIR)x86/x86_xform3.S \ + $(SRCDIR)x86/x86_xform4.S \ + $(SRCDIR)x86/x86_cliptest.S \ + $(SRCDIR)x86/mmx_blend.S \ + $(SRCDIR)x86/3dnow_xform1.S \ + $(SRCDIR)x86/3dnow_xform2.S \ + $(SRCDIR)x86/3dnow_xform3.S \ + $(SRCDIR)x86/3dnow_xform4.S \ + $(SRCDIR)x86/3dnow_normal.S \ + $(SRCDIR)x86/sse_xform1.S \ + $(SRCDIR)x86/sse_xform2.S \ + $(SRCDIR)x86/sse_xform3.S \ + $(SRCDIR)x86/sse_xform4.S \ + $(SRCDIR)x86/sse_normal.S \ + $(SRCDIR)x86/read_rgba_span_x86.S + +X86_64_FILES = \ + $(SRCDIR)x86-64/xform4.S + +SPARC_FILES = \ + $(SRCDIR)sparc/sparc_clip.S \ + $(SRCDIR)sparc/norm.S \ + $(SRCDIR)sparc/xform.S + +COMMON_DRIVER_FILES = \ + $(SRCDIR)drivers/common/driverfuncs.c \ + $(SRCDIR)drivers/common/meta.c + + +# Sources for building non-Gallium drivers +MESA_FILES = \ + $(MAIN_FILES) \ + $(MATH_FILES) \ + $(MATH_XFORM_FILES) \ + $(VBO_FILES) \ + $(TNL_FILES) \ + $(SWRAST_FILES) \ + $(SWRAST_SETUP_FILES) \ + $(COMMON_DRIVER_FILES)\ + $(ASM_C_FILES) + +# Sources for building Gallium drivers +MESA_GALLIUM_FILES = \ + $(MAIN_FILES) \ + $(MATH_FILES) \ + $(VBO_FILES) \ + $(STATETRACKER_FILES) \ + $(SRCDIR)x86/common_x86.c + +### Include directories + +INCLUDE_DIRS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/src/glsl \ + -I$(top_builddir)/src/glsl \ + -I$(top_srcdir)/src/glsl/glcpp \ + -I$(top_srcdir)/src/mesa \ + -I$(top_builddir)/src/mesa \ + -I$(top_srcdir)/src/mesa/main \ + -I$(top_builddir)/src/mesa/main \ + -I$(top_srcdir)/src/mapi \ + -I$(top_builddir)/src/mapi \ + -I$(top_srcdir)/src/gallium/include \ + -I$(top_srcdir)/src/gallium/auxiliary diff --git a/mesalib/src/mesa/SConscript b/mesalib/src/mesa/SConscript index ca9b70bad..0f1543802 100644 --- a/mesalib/src/mesa/SConscript +++ b/mesalib/src/mesa/SConscript @@ -31,7 +31,6 @@ if env['platform'] == 'windows': env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) else: env.Append(CPPDEFINES = [ - 'IN_DRI_DRIVER', # enable the remap table (for DRI drivers) ('HAVE_DLOPEN', '1'), ]) @@ -263,6 +262,7 @@ statetracker_sources = [ 'state_tracker/st_cb_eglimage.c', 'state_tracker/st_cb_fbo.c', 'state_tracker/st_cb_feedback.c', + 'state_tracker/st_cb_msaa.c', 'state_tracker/st_cb_program.c', 'state_tracker/st_cb_queryobj.c', 'state_tracker/st_cb_rasterpos.c', @@ -340,22 +340,18 @@ if env['gles']: enabled_apis += ['ES1', 'ES2'] -env.Append(CPPDEFINES = ["FEATURE_%s=1" % api for api in enabled_apis]) - -get_hash_gen_opts = ' '.join(["-a %s" % api for api in enabled_apis]) - get_hash_header = env.CodeGenerate( target = 'main/get_hash.h', script = 'main/get_hash_generator.py', source = GLAPI + 'gen/gl_and_es_API.xml', - command = python_cmd + ' $SCRIPT ' + get_hash_gen_opts + - ' -f $SOURCE > $TARGET' + command = python_cmd + ' $SCRIPT ' + ' -f $SOURCE > $TARGET' ) # # Assembly sources # -if env['gcc'] and env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'): +if (env['gcc'] or env['clang']) and \ + env['platform'] not in ('cygwin', 'darwin', 'windows', 'haiku'): if env['machine'] == 'x86': env.Append(CPPDEFINES = [ 'USE_X86_ASM', diff --git a/mesalib/src/mesa/drivers/Makefile.am b/mesalib/src/mesa/drivers/Makefile.am deleted file mode 100644 index 1bc74eadf..000000000 --- a/mesalib/src/mesa/drivers/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright © 2012 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. - -SUBDIRS = $(DRIVER_DIRS) diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c index a98dfc607..4f7696c4c 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.c +++ b/mesalib/src/mesa/drivers/common/driverfuncs.c @@ -17,9 +17,10 @@ * 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. + * 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. */ @@ -40,6 +41,7 @@ #include "main/texgetimage.h" #include "main/teximage.h" #include "main/texobj.h" +#include "main/texstorage.h" #include "main/texstore.h" #include "main/bufferobj.h" #include "main/fbobject.h" @@ -209,7 +211,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->EndCallList = NULL; /* GL_ARB_texture_storage */ - driver->AllocTextureStorage = _swrast_AllocTextureStorage; + driver->AllocTextureStorage = _mesa_alloc_texture_storage; /* GL_ARB_texture_multisample */ driver->GetSamplePosition = NULL; diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.h b/mesalib/src/mesa/drivers/common/driverfuncs.h index 212f30742..806c8b0af 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.h +++ b/mesalib/src/mesa/drivers/common/driverfuncs.h @@ -17,9 +17,10 @@ * 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. + * 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. */ diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index e3ab82bfe..1250bd35c 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -17,9 +17,10 @@ * 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. + * 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. */ /** @@ -3048,16 +3049,33 @@ _mesa_meta_check_generate_mipmap_fallback(struct gl_context *ctx, GLenum target, GLenum status; /* check for fallbacks */ - if (!ctx->Extensions.EXT_framebuffer_object || - target == GL_TEXTURE_3D || + if (!ctx->Extensions.EXT_framebuffer_object) { + _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, + "glGenerateMipmap() without FBOs\n"); + return GL_TRUE; + } + + if (target == GL_TEXTURE_3D || target == GL_TEXTURE_1D_ARRAY || target == GL_TEXTURE_2D_ARRAY) { + _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, + "glGenerateMipmap() to %s target\n", + _mesa_lookup_enum_by_nr(target)); return GL_TRUE; } srcLevel = texObj->BaseLevel; baseImage = _mesa_select_tex_image(ctx, texObj, target, srcLevel); - if (!baseImage || _mesa_is_format_compressed(baseImage->TexFormat)) { + if (!baseImage) { + _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, + "glGenerateMipmap() couldn't find base teximage\n"); + return GL_TRUE; + } + + if (_mesa_is_format_compressed(baseImage->TexFormat)) { + _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, + "glGenerateMipmap() with %s format\n", + _mesa_get_format_name(baseImage->TexFormat)); return GL_TRUE; } @@ -3067,6 +3085,9 @@ _mesa_meta_check_generate_mipmap_fallback(struct gl_context *ctx, GLenum target, * texture sample conversion. So we won't be able to generate the * right colors when rendering. Need to use a fallback. */ + _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, + "glGenerateMipmap() of sRGB texture without " + "sRGB decode\n"); return GL_TRUE; } @@ -3103,6 +3124,8 @@ _mesa_meta_check_generate_mipmap_fallback(struct gl_context *ctx, GLenum target, _mesa_BindFramebuffer(GL_FRAMEBUFFER_EXT, fboSave); if (status != GL_FRAMEBUFFER_COMPLETE_EXT) { + _mesa_perf_debug(ctx, MESA_DEBUG_SEVERITY_HIGH, + "glGenerateMipmap() got incomplete FBO\n"); return GL_TRUE; } @@ -3374,6 +3397,8 @@ setup_glsl_generate_mipmap(struct gl_context *ctx, sizeof(struct vertex), OFFSET(x)); _mesa_VertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(struct vertex), OFFSET(tex)); + _mesa_EnableVertexAttribArray(0); + _mesa_EnableVertexAttribArray(1); } /* Generate a fragment shader program appropriate for the texture target */ @@ -3445,8 +3470,6 @@ setup_glsl_generate_mipmap(struct gl_context *ctx, _mesa_DeleteObjectARB(vs); _mesa_BindAttribLocation(mipmap->ShaderProg, 0, "position"); _mesa_BindAttribLocation(mipmap->ShaderProg, 1, "texcoords"); - _mesa_EnableVertexAttribArray(0); - _mesa_EnableVertexAttribArray(1); link_program_with_debug(ctx, mipmap->ShaderProg); sampler->shader_prog = mipmap->ShaderProg; ralloc_free(mem_ctx); @@ -3741,10 +3764,20 @@ get_temp_image_type(struct gl_context *ctx, gl_format format) return datatype; return GL_FLOAT; } - case GL_DEPTH_COMPONENT: - return GL_UNSIGNED_INT; - case GL_DEPTH_STENCIL: - return GL_UNSIGNED_INT_24_8; + case GL_DEPTH_COMPONENT: { + GLenum datatype = _mesa_get_format_datatype(format); + if (datatype == GL_FLOAT) + return GL_FLOAT; + else + return GL_UNSIGNED_INT; + } + case GL_DEPTH_STENCIL: { + GLenum datatype = _mesa_get_format_datatype(format); + if (datatype == GL_FLOAT) + return GL_FLOAT_32_UNSIGNED_INT_24_8_REV; + else + return GL_UNSIGNED_INT_24_8; + } default: _mesa_problem(ctx, "Unexpected format %d in get_temp_image_type()", baseFormat); diff --git a/mesalib/src/mesa/drivers/common/meta.h b/mesalib/src/mesa/drivers/common/meta.h index a6bdd3947..823be14c7 100644 --- a/mesalib/src/mesa/drivers/common/meta.h +++ b/mesalib/src/mesa/drivers/common/meta.h @@ -17,9 +17,10 @@ * 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. + * 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. */ diff --git a/mesalib/src/mesa/drivers/dri/common/Makefile.am b/mesalib/src/mesa/drivers/dri/common/Makefile.am index dfc8f3b7a..ce4119d0f 100644 --- a/mesalib/src/mesa/drivers/dri/common/Makefile.am +++ b/mesalib/src/mesa/drivers/dri/common/Makefile.am @@ -27,7 +27,6 @@ AM_CFLAGS = \ -I$(top_srcdir)/src/mapi \ -I$(top_srcdir)/src/mesa/ \ $(DEFINES) \ - $(API_DEFINES) \ $(LIBDRM_CFLAGS) \ $(VISIBILITY_CFLAGS) diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c index 6af101c31..89f03c310 100644 --- a/mesalib/src/mesa/drivers/dri/common/drisw_util.c +++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.c @@ -16,9 +16,10 @@ * 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. + * 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. */ /** diff --git a/mesalib/src/mesa/drivers/dri/common/xmlpool.h b/mesalib/src/mesa/drivers/dri/common/xmlpool.h index ffea43002..ebd4e7c86 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlpool.h +++ b/mesalib/src/mesa/drivers/dri/common/xmlpool.h @@ -60,6 +60,13 @@ #define DRI_CONF_OPT_BEGIN(name,type,def) \ "