From 85ef9930f56bf15181f9a0b238f03d55303cf411 Mon Sep 17 00:00:00 2001 From: marha Date: Mon, 22 Nov 2010 19:42:40 +0000 Subject: Updated to mesalib 7.9 --- mesalib/src/mesa/Makefile | 154 +- mesalib/src/mesa/Makefile.mgw | 4 +- mesalib/src/mesa/drivers/common/driverfuncs.c | 33 +- mesalib/src/mesa/drivers/common/meta.c | 33 +- mesalib/src/mesa/drivers/dri/Makefile.template | 14 +- mesalib/src/mesa/drivers/dri/common/dri_metaops.c | 5 +- mesalib/src/mesa/drivers/dri/common/dri_test.c | 89 + mesalib/src/mesa/drivers/dri/common/dri_util.c | 236 +- mesalib/src/mesa/drivers/dri/common/dri_util.h | 45 +- mesalib/src/mesa/drivers/dri/common/drisw_util.c | 273 + mesalib/src/mesa/drivers/dri/common/drisw_util.h | 135 + mesalib/src/mesa/drivers/dri/common/spantmp2.h | 32 + mesalib/src/mesa/drivers/dri/common/utils.c | 28 +- mesalib/src/mesa/drivers/dri/common/utils.h | 3 + mesalib/src/mesa/drivers/dri/common/xmlconfig.c | 2 +- mesalib/src/mesa/drivers/dri/swrast/Makefile | 5 +- mesalib/src/mesa/drivers/dri/swrast/swrast.c | 365 +- mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h | 75 +- mesalib/src/mesa/drivers/dri/swrast/swrast_span.c | 6 +- .../src/mesa/drivers/dri/swrast/swrast_spantemp.h | 16 +- mesalib/src/mesa/main/APIspec.dtd | 52 + mesalib/src/mesa/main/APIspec.py | 617 ++ mesalib/src/mesa/main/APIspec.xml | 4332 +++++++++ mesalib/src/mesa/main/APIspecutil.py | 272 + mesalib/src/mesa/main/accum.h | 7 +- mesalib/src/mesa/main/api_exec.c | 184 +- mesalib/src/mesa/main/api_exec.h | 12 +- mesalib/src/mesa/main/api_loopback.c | 174 + mesalib/src/mesa/main/api_validate.c | 147 +- mesalib/src/mesa/main/api_validate.h | 10 + mesalib/src/mesa/main/arbprogram.c | 940 ++ mesalib/src/mesa/main/arbprogram.h | 131 + mesalib/src/mesa/main/arrayobj.h | 2 +- mesalib/src/mesa/main/atifragshader.c | 794 ++ mesalib/src/mesa/main/atifragshader.h | 149 + mesalib/src/mesa/main/attrib.c | 2 +- mesalib/src/mesa/main/attrib.h | 2 + mesalib/src/mesa/main/bufferobj.c | 108 +- mesalib/src/mesa/main/bufferobj.h | 2 +- mesalib/src/mesa/main/clear.c | 1 + mesalib/src/mesa/main/clear.h | 2 +- mesalib/src/mesa/main/clip.h | 2 +- mesalib/src/mesa/main/colormac.h | 2 +- mesalib/src/mesa/main/colortab.h | 9 +- mesalib/src/mesa/main/compiler.h | 28 +- mesalib/src/mesa/main/config.h | 18 +- mesalib/src/mesa/main/context.c | 272 +- mesalib/src/mesa/main/context.h | 18 +- mesalib/src/mesa/main/convolve.c | 1 + mesalib/src/mesa/main/convolve.h | 8 +- mesalib/src/mesa/main/core.h | 66 + mesalib/src/mesa/main/dd.h | 165 +- mesalib/src/mesa/main/debug.c | 7 +- mesalib/src/mesa/main/debug.h | 3 + mesalib/src/mesa/main/depthstencil.c | 26 +- mesalib/src/mesa/main/depthstencil.h | 1 + mesalib/src/mesa/main/dlist.c | 293 +- mesalib/src/mesa/main/dlist.h | 15 +- mesalib/src/mesa/main/dlopen.c | 15 +- mesalib/src/mesa/main/drawpix.h | 9 - mesalib/src/mesa/main/drawtex.c | 131 + mesalib/src/mesa/main/drawtex.h | 60 + mesalib/src/mesa/main/enable.c | 115 +- mesalib/src/mesa/main/enums.c | 6651 +++++++------ mesalib/src/mesa/main/es_generator.py | 743 ++ mesalib/src/mesa/main/extensions.c | 253 +- mesalib/src/mesa/main/fbobject.c | 196 +- mesalib/src/mesa/main/fbobject.h | 16 + mesalib/src/mesa/main/feedback.h | 7 +- mesalib/src/mesa/main/ffvertex_prog.c | 20 +- mesalib/src/mesa/main/fog.c | 1 + mesalib/src/mesa/main/formats.c | 186 +- mesalib/src/mesa/main/formats.h | 38 +- mesalib/src/mesa/main/framebuffer.c | 58 +- mesalib/src/mesa/main/framebuffer.h | 4 + mesalib/src/mesa/main/get.c | 9932 +++++--------------- mesalib/src/mesa/main/get.h | 5 +- mesalib/src/mesa/main/getstring.c | 59 +- mesalib/src/mesa/main/glheader.h | 58 +- mesalib/src/mesa/main/histogram.c | 1 + mesalib/src/mesa/main/image.c | 512 +- mesalib/src/mesa/main/image.h | 8 + mesalib/src/mesa/main/imports.c | 46 +- mesalib/src/mesa/main/imports.h | 106 +- mesalib/src/mesa/main/light.c | 12 +- mesalib/src/mesa/main/light.h | 2 +- mesalib/src/mesa/main/macros.h | 38 + mesalib/src/mesa/main/mfeatures.h | 128 +- mesalib/src/mesa/main/mipmap.c | 48 +- mesalib/src/mesa/main/mm.c | 5 + mesalib/src/mesa/main/mm.h | 3 - mesalib/src/mesa/main/mtypes.h | 365 +- mesalib/src/mesa/main/multisample.h | 1 + mesalib/src/mesa/main/nvprogram.c | 919 ++ mesalib/src/mesa/main/nvprogram.h | 115 + mesalib/src/mesa/main/pixelstore.h | 1 + mesalib/src/mesa/main/querymatrix.c | 216 + mesalib/src/mesa/main/queryobj.c | 130 +- mesalib/src/mesa/main/queryobj.h | 17 +- mesalib/src/mesa/main/rastpos.h | 7 - mesalib/src/mesa/main/rbadaptors.c | 565 -- mesalib/src/mesa/main/rbadaptors.h | 40 - mesalib/src/mesa/main/readpix.c | 6 + mesalib/src/mesa/main/remap.c | 64 +- mesalib/src/mesa/main/remap.h | 77 +- mesalib/src/mesa/main/remap_helper.h | 3288 ++++--- mesalib/src/mesa/main/renderbuffer.c | 46 +- mesalib/src/mesa/main/renderbuffer.h | 5 + mesalib/src/mesa/main/restart.c | 68 + mesalib/src/mesa/main/restart.h | 41 + mesalib/src/mesa/main/shaderapi.c | 1642 ++++ mesalib/src/mesa/main/shaderapi.h | 169 + mesalib/src/mesa/main/shaderobj.c | 408 + mesalib/src/mesa/main/shaderobj.h | 134 + mesalib/src/mesa/main/shaders.c | 741 -- mesalib/src/mesa/main/shaders.h | 236 - mesalib/src/mesa/main/shared.c | 25 +- mesalib/src/mesa/main/shared.h | 1 + mesalib/src/mesa/main/state.c | 36 +- mesalib/src/mesa/main/syncobj.c | 15 + mesalib/src/mesa/main/syncobj.h | 47 +- mesalib/src/mesa/main/texcompress.c | 19 +- mesalib/src/mesa/main/texcompress_fxt1.c | 2 +- mesalib/src/mesa/main/texcompress_fxt1.h | 4 +- mesalib/src/mesa/main/texcompress_s3tc.c | 19 +- mesalib/src/mesa/main/texenv.c | 119 +- mesalib/src/mesa/main/texenvprogram.c | 33 +- mesalib/src/mesa/main/texfetch.c | 607 +- mesalib/src/mesa/main/texfetch_tmp.h | 374 + mesalib/src/mesa/main/texformat.c | 95 +- mesalib/src/mesa/main/texgen.c | 32 + mesalib/src/mesa/main/texgen.h | 23 +- mesalib/src/mesa/main/texgetimage.c | 2 +- mesalib/src/mesa/main/texgetimage.h | 1 + mesalib/src/mesa/main/teximage.c | 349 +- mesalib/src/mesa/main/teximage.h | 8 + mesalib/src/mesa/main/texobj.c | 6 +- mesalib/src/mesa/main/texpal.c | 204 + mesalib/src/mesa/main/texpal.h | 38 + mesalib/src/mesa/main/texparam.c | 22 +- mesalib/src/mesa/main/texrender.c | 1 + mesalib/src/mesa/main/texrender.h | 1 + mesalib/src/mesa/main/texstate.c | 2 +- mesalib/src/mesa/main/texstate.h | 1 + mesalib/src/mesa/main/texstore.c | 727 +- mesalib/src/mesa/main/transformfeedback.c | 944 ++ mesalib/src/mesa/main/transformfeedback.h | 132 + mesalib/src/mesa/main/uniforms.c | 1382 +++ mesalib/src/mesa/main/uniforms.h | 175 + mesalib/src/mesa/main/varray.c | 290 +- mesalib/src/mesa/main/varray.h | 44 +- mesalib/src/mesa/main/version.c | 200 +- mesalib/src/mesa/main/version.h | 8 +- mesalib/src/mesa/main/viewport.h | 2 + mesalib/src/mesa/main/vtxfmt.c | 2 + mesalib/src/mesa/main/vtxfmt.h | 3 + mesalib/src/mesa/main/vtxfmt_tmp.h | 21 + mesalib/src/mesa/math/m_matrix.c | 4 +- mesalib/src/mesa/math/m_matrix.h | 2 + mesalib/src/mesa/math/m_translate.c | 2 +- mesalib/src/mesa/math/m_translate.h | 3 +- mesalib/src/mesa/math/m_xform.h | 4 +- mesalib/src/mesa/shader/Makefile | 7 - mesalib/src/mesa/shader/arbprogparse.c | 217 - mesalib/src/mesa/shader/arbprogparse.h | 41 - mesalib/src/mesa/shader/arbprogram.c | 1097 --- mesalib/src/mesa/shader/arbprogram.h | 152 - mesalib/src/mesa/shader/atifragshader.c | 769 -- mesalib/src/mesa/shader/atifragshader.h | 123 - mesalib/src/mesa/shader/descrip.mms | 93 - mesalib/src/mesa/shader/hash_table.c | 159 - mesalib/src/mesa/shader/hash_table.h | 117 - mesalib/src/mesa/shader/lex.yy.c | 3655 ------- mesalib/src/mesa/shader/nvfragparse.c | 1588 ---- mesalib/src/mesa/shader/nvfragparse.h | 43 - mesalib/src/mesa/shader/nvprogram.c | 917 -- mesalib/src/mesa/shader/nvprogram.h | 113 - mesalib/src/mesa/shader/nvvertparse.c | 1454 --- mesalib/src/mesa/shader/nvvertparse.h | 45 - mesalib/src/mesa/shader/prog_cache.c | 206 - mesalib/src/mesa/shader/prog_cache.h | 55 - mesalib/src/mesa/shader/prog_execute.c | 1798 ---- mesalib/src/mesa/shader/prog_execute.h | 85 - mesalib/src/mesa/shader/prog_instruction.c | 352 - mesalib/src/mesa/shader/prog_instruction.h | 437 - mesalib/src/mesa/shader/prog_noise.c | 638 -- mesalib/src/mesa/shader/prog_noise.h | 34 - mesalib/src/mesa/shader/prog_optimize.c | 1035 -- mesalib/src/mesa/shader/prog_optimize.h | 45 - mesalib/src/mesa/shader/prog_parameter.c | 750 -- mesalib/src/mesa/shader/prog_parameter.h | 181 - mesalib/src/mesa/shader/prog_parameter_layout.c | 213 - mesalib/src/mesa/shader/prog_parameter_layout.h | 42 - mesalib/src/mesa/shader/prog_print.c | 1065 --- mesalib/src/mesa/shader/prog_print.h | 100 - mesalib/src/mesa/shader/prog_statevars.c | 1187 --- mesalib/src/mesa/shader/prog_statevars.h | 147 - mesalib/src/mesa/shader/prog_uniform.c | 165 - mesalib/src/mesa/shader/prog_uniform.h | 92 - mesalib/src/mesa/shader/program.c | 912 -- mesalib/src/mesa/shader/program.h | 151 - mesalib/src/mesa/shader/program_lexer.l | 495 - mesalib/src/mesa/shader/program_parse.tab.c | 5728 ----------- mesalib/src/mesa/shader/program_parse.tab.h | 209 - mesalib/src/mesa/shader/program_parse.y | 2766 ------ mesalib/src/mesa/shader/program_parse_extra.c | 255 - mesalib/src/mesa/shader/program_parser.h | 302 - mesalib/src/mesa/shader/programopt.c | 669 -- mesalib/src/mesa/shader/programopt.h | 52 - mesalib/src/mesa/shader/shader_api.c | 2233 ----- mesalib/src/mesa/shader/shader_api.h | 100 - mesalib/src/mesa/shader/slang/descrip.mms | 67 - mesalib/src/mesa/shader/slang/library/Makefile | 51 - .../mesa/shader/slang/library/slang_120_core.gc | 1978 ---- .../slang/library/slang_builtin_120_common.gc | 200 - .../slang/library/slang_builtin_120_fragment.gc | 30 - .../shader/slang/library/slang_common_builtin.gc | 1893 ---- .../src/mesa/shader/slang/library/slang_core.gc | 2619 ------ .../shader/slang/library/slang_fragment_builtin.gc | 299 - .../shader/slang/library/slang_vertex_builtin.gc | 210 - mesalib/src/mesa/shader/slang/slang_builtin.c | 897 -- mesalib/src/mesa/shader/slang/slang_builtin.h | 54 - mesalib/src/mesa/shader/slang/slang_codegen.c | 5354 ----------- mesalib/src/mesa/shader/slang/slang_codegen.h | 73 - mesalib/src/mesa/shader/slang/slang_compile.c | 3032 ------ mesalib/src/mesa/shader/slang/slang_compile.h | 100 - .../src/mesa/shader/slang/slang_compile_function.c | 262 - .../src/mesa/shader/slang/slang_compile_function.h | 92 - .../mesa/shader/slang/slang_compile_operation.c | 334 - .../mesa/shader/slang/slang_compile_operation.h | 225 - .../src/mesa/shader/slang/slang_compile_struct.c | 174 - .../src/mesa/shader/slang/slang_compile_struct.h | 66 - .../src/mesa/shader/slang/slang_compile_variable.c | 247 - .../src/mesa/shader/slang/slang_compile_variable.h | 90 - mesalib/src/mesa/shader/slang/slang_emit.c | 2667 ------ mesalib/src/mesa/shader/slang/slang_emit.h | 51 - mesalib/src/mesa/shader/slang/slang_ir.c | 498 - mesalib/src/mesa/shader/slang/slang_ir.h | 280 - mesalib/src/mesa/shader/slang/slang_label.c | 104 - mesalib/src/mesa/shader/slang/slang_label.h | 45 - mesalib/src/mesa/shader/slang/slang_link.c | 933 -- mesalib/src/mesa/shader/slang/slang_link.h | 37 - mesalib/src/mesa/shader/slang/slang_log.c | 133 - mesalib/src/mesa/shader/slang/slang_log.h | 57 - mesalib/src/mesa/shader/slang/slang_mem.c | 243 - mesalib/src/mesa/shader/slang/slang_mem.h | 55 - mesalib/src/mesa/shader/slang/slang_print.c | 883 -- mesalib/src/mesa/shader/slang/slang_print.h | 29 - mesalib/src/mesa/shader/slang/slang_simplify.c | 527 -- mesalib/src/mesa/shader/slang/slang_simplify.h | 50 - mesalib/src/mesa/shader/slang/slang_storage.c | 321 - mesalib/src/mesa/shader/slang/slang_storage.h | 139 - mesalib/src/mesa/shader/slang/slang_typeinfo.c | 1177 --- mesalib/src/mesa/shader/slang/slang_typeinfo.h | 259 - mesalib/src/mesa/shader/slang/slang_utility.c | 228 - mesalib/src/mesa/shader/slang/slang_utility.h | 100 - mesalib/src/mesa/shader/slang/slang_vartable.c | 362 - mesalib/src/mesa/shader/slang/slang_vartable.h | 42 - mesalib/src/mesa/shader/symbol_table.c | 362 - mesalib/src/mesa/shader/symbol_table.h | 55 - mesalib/src/mesa/sources.mak | 142 +- mesalib/src/mesa/swrast/s_aaline.h | 2 +- mesalib/src/mesa/swrast/s_aatriangle.h | 2 +- mesalib/src/mesa/swrast/s_alpha.h | 3 +- mesalib/src/mesa/swrast/s_atifragshader.c | 4 +- mesalib/src/mesa/swrast/s_atifragshader.h | 3 +- mesalib/src/mesa/swrast/s_blend.h | 3 +- mesalib/src/mesa/swrast/s_clear.c | 1 - mesalib/src/mesa/swrast/s_context.c | 7 +- mesalib/src/mesa/swrast/s_context.h | 3 +- mesalib/src/mesa/swrast/s_depth.c | 1 - mesalib/src/mesa/swrast/s_depth.h | 3 +- mesalib/src/mesa/swrast/s_feedback.c | 1 - mesalib/src/mesa/swrast/s_fog.c | 1 - mesalib/src/mesa/swrast/s_fog.h | 3 +- mesalib/src/mesa/swrast/s_fragprog.c | 4 +- mesalib/src/mesa/swrast/s_fragprog.h | 3 +- mesalib/src/mesa/swrast/s_logic.h | 3 +- mesalib/src/mesa/swrast/s_masking.h | 3 +- mesalib/src/mesa/swrast/s_points.c | 1 - mesalib/src/mesa/swrast/s_readpix.c | 18 +- mesalib/src/mesa/swrast/s_span.c | 24 +- mesalib/src/mesa/swrast/s_stencil.h | 3 +- mesalib/src/mesa/swrast/s_texcombine.c | 2 +- mesalib/src/mesa/swrast/s_texcombine.h | 3 +- mesalib/src/mesa/swrast/s_texfilter.c | 41 +- mesalib/src/mesa/swrast/s_texfilter.h | 3 +- mesalib/src/mesa/swrast/s_triangle.c | 2 +- mesalib/src/mesa/swrast/s_zoom.h | 3 +- mesalib/src/mesa/swrast_setup/ss_context.c | 2 +- mesalib/src/mesa/swrast_setup/ss_context.h | 3 +- mesalib/src/mesa/swrast_setup/ss_triangle.c | 2 +- mesalib/src/mesa/swrast_setup/ss_triangle.h | 2 +- mesalib/src/mesa/swrast_setup/ss_vb.h | 1 - mesalib/src/mesa/tnl/t_context.h | 2 - mesalib/src/mesa/tnl/t_rasterpos.c | 1 - mesalib/src/mesa/tnl/t_vb_cull.c | 1 - mesalib/src/mesa/tnl/t_vb_fog.c | 1 - mesalib/src/mesa/tnl/t_vb_normals.c | 1 - mesalib/src/mesa/tnl/t_vb_program.c | 8 +- mesalib/src/mesa/tnl/t_vb_render.c | 1 + mesalib/src/mesa/tnl/t_vb_texgen.c | 1 - mesalib/src/mesa/tnl/t_vb_texmat.c | 1 - mesalib/src/mesa/tnl/t_vb_vertex.c | 1 - mesalib/src/mesa/vbo/vbo.h | 25 + mesalib/src/mesa/vbo/vbo_context.c | 10 +- mesalib/src/mesa/vbo/vbo_context.h | 2 - mesalib/src/mesa/vbo/vbo_exec.c | 12 +- mesalib/src/mesa/vbo/vbo_exec.h | 3 - mesalib/src/mesa/vbo/vbo_exec_api.c | 66 +- mesalib/src/mesa/vbo/vbo_exec_array.c | 193 +- mesalib/src/mesa/vbo/vbo_exec_draw.c | 2 +- mesalib/src/mesa/vbo/vbo_save.c | 3 + mesalib/src/mesa/vbo/vbo_save.h | 17 +- mesalib/src/mesa/vbo/vbo_save_api.c | 7 + mesalib/src/mesa/vbo/vbo_save_draw.c | 71 +- mesalib/src/mesa/vbo/vbo_save_loopback.c | 5 + 317 files changed, 29837 insertions(+), 77197 deletions(-) create mode 100644 mesalib/src/mesa/drivers/dri/common/dri_test.c create mode 100644 mesalib/src/mesa/drivers/dri/common/drisw_util.c create mode 100644 mesalib/src/mesa/drivers/dri/common/drisw_util.h create mode 100644 mesalib/src/mesa/main/APIspec.dtd create mode 100644 mesalib/src/mesa/main/APIspec.py create mode 100644 mesalib/src/mesa/main/APIspec.xml create mode 100644 mesalib/src/mesa/main/APIspecutil.py create mode 100644 mesalib/src/mesa/main/arbprogram.c create mode 100644 mesalib/src/mesa/main/arbprogram.h create mode 100644 mesalib/src/mesa/main/atifragshader.c create mode 100644 mesalib/src/mesa/main/atifragshader.h create mode 100644 mesalib/src/mesa/main/core.h create mode 100644 mesalib/src/mesa/main/drawtex.c create mode 100644 mesalib/src/mesa/main/drawtex.h create mode 100644 mesalib/src/mesa/main/es_generator.py create mode 100644 mesalib/src/mesa/main/nvprogram.c create mode 100644 mesalib/src/mesa/main/nvprogram.h create mode 100644 mesalib/src/mesa/main/querymatrix.c delete mode 100644 mesalib/src/mesa/main/rbadaptors.c delete mode 100644 mesalib/src/mesa/main/rbadaptors.h create mode 100644 mesalib/src/mesa/main/restart.c create mode 100644 mesalib/src/mesa/main/restart.h create mode 100644 mesalib/src/mesa/main/shaderapi.c create mode 100644 mesalib/src/mesa/main/shaderapi.h create mode 100644 mesalib/src/mesa/main/shaderobj.c create mode 100644 mesalib/src/mesa/main/shaderobj.h delete mode 100644 mesalib/src/mesa/main/shaders.c delete mode 100644 mesalib/src/mesa/main/shaders.h create mode 100644 mesalib/src/mesa/main/texpal.c create mode 100644 mesalib/src/mesa/main/texpal.h create mode 100644 mesalib/src/mesa/main/transformfeedback.c create mode 100644 mesalib/src/mesa/main/transformfeedback.h create mode 100644 mesalib/src/mesa/main/uniforms.c create mode 100644 mesalib/src/mesa/main/uniforms.h delete mode 100644 mesalib/src/mesa/shader/Makefile delete mode 100644 mesalib/src/mesa/shader/arbprogparse.c delete mode 100644 mesalib/src/mesa/shader/arbprogparse.h delete mode 100644 mesalib/src/mesa/shader/arbprogram.c delete mode 100644 mesalib/src/mesa/shader/arbprogram.h delete mode 100644 mesalib/src/mesa/shader/atifragshader.c delete mode 100644 mesalib/src/mesa/shader/atifragshader.h delete mode 100644 mesalib/src/mesa/shader/descrip.mms delete mode 100644 mesalib/src/mesa/shader/hash_table.c delete mode 100644 mesalib/src/mesa/shader/hash_table.h delete mode 100644 mesalib/src/mesa/shader/lex.yy.c delete mode 100644 mesalib/src/mesa/shader/nvfragparse.c delete mode 100644 mesalib/src/mesa/shader/nvfragparse.h delete mode 100644 mesalib/src/mesa/shader/nvprogram.c delete mode 100644 mesalib/src/mesa/shader/nvprogram.h delete mode 100644 mesalib/src/mesa/shader/nvvertparse.c delete mode 100644 mesalib/src/mesa/shader/nvvertparse.h delete mode 100644 mesalib/src/mesa/shader/prog_cache.c delete mode 100644 mesalib/src/mesa/shader/prog_cache.h delete mode 100644 mesalib/src/mesa/shader/prog_execute.c delete mode 100644 mesalib/src/mesa/shader/prog_execute.h delete mode 100644 mesalib/src/mesa/shader/prog_instruction.c delete mode 100644 mesalib/src/mesa/shader/prog_instruction.h delete mode 100644 mesalib/src/mesa/shader/prog_noise.c delete mode 100644 mesalib/src/mesa/shader/prog_noise.h delete mode 100644 mesalib/src/mesa/shader/prog_optimize.c delete mode 100644 mesalib/src/mesa/shader/prog_optimize.h delete mode 100644 mesalib/src/mesa/shader/prog_parameter.c delete mode 100644 mesalib/src/mesa/shader/prog_parameter.h delete mode 100644 mesalib/src/mesa/shader/prog_parameter_layout.c delete mode 100644 mesalib/src/mesa/shader/prog_parameter_layout.h delete mode 100644 mesalib/src/mesa/shader/prog_print.c delete mode 100644 mesalib/src/mesa/shader/prog_print.h delete mode 100644 mesalib/src/mesa/shader/prog_statevars.c delete mode 100644 mesalib/src/mesa/shader/prog_statevars.h delete mode 100644 mesalib/src/mesa/shader/prog_uniform.c delete mode 100644 mesalib/src/mesa/shader/prog_uniform.h delete mode 100644 mesalib/src/mesa/shader/program.c delete mode 100644 mesalib/src/mesa/shader/program.h delete mode 100644 mesalib/src/mesa/shader/program_lexer.l delete mode 100644 mesalib/src/mesa/shader/program_parse.tab.c delete mode 100644 mesalib/src/mesa/shader/program_parse.tab.h delete mode 100644 mesalib/src/mesa/shader/program_parse.y delete mode 100644 mesalib/src/mesa/shader/program_parse_extra.c delete mode 100644 mesalib/src/mesa/shader/program_parser.h delete mode 100644 mesalib/src/mesa/shader/programopt.c delete mode 100644 mesalib/src/mesa/shader/programopt.h delete mode 100644 mesalib/src/mesa/shader/shader_api.c delete mode 100644 mesalib/src/mesa/shader/shader_api.h delete mode 100644 mesalib/src/mesa/shader/slang/descrip.mms delete mode 100644 mesalib/src/mesa/shader/slang/library/Makefile delete mode 100644 mesalib/src/mesa/shader/slang/library/slang_120_core.gc delete mode 100644 mesalib/src/mesa/shader/slang/library/slang_builtin_120_common.gc delete mode 100644 mesalib/src/mesa/shader/slang/library/slang_builtin_120_fragment.gc delete mode 100644 mesalib/src/mesa/shader/slang/library/slang_common_builtin.gc delete mode 100644 mesalib/src/mesa/shader/slang/library/slang_core.gc delete mode 100644 mesalib/src/mesa/shader/slang/library/slang_fragment_builtin.gc delete mode 100644 mesalib/src/mesa/shader/slang/library/slang_vertex_builtin.gc delete mode 100644 mesalib/src/mesa/shader/slang/slang_builtin.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_builtin.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_codegen.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_codegen.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_function.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_function.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_operation.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_operation.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_struct.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_struct.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_variable.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_compile_variable.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_emit.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_emit.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_ir.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_ir.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_label.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_label.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_link.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_link.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_log.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_log.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_mem.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_mem.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_print.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_print.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_simplify.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_simplify.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_storage.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_storage.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_typeinfo.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_typeinfo.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_utility.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_utility.h delete mode 100644 mesalib/src/mesa/shader/slang/slang_vartable.c delete mode 100644 mesalib/src/mesa/shader/slang/slang_vartable.h delete mode 100644 mesalib/src/mesa/shader/symbol_table.c delete mode 100644 mesalib/src/mesa/shader/symbol_table.h (limited to 'mesalib/src/mesa') diff --git a/mesalib/src/mesa/Makefile b/mesalib/src/mesa/Makefile index 8c0ebf84c..c41c38cba 100644 --- a/mesalib/src/mesa/Makefile +++ b/mesalib/src/mesa/Makefile @@ -3,27 +3,98 @@ TOP = ../.. include $(TOP)/configs/current +MESA_LIBS := libmesa.a libmesagallium.a +DEPENDS := depend + +ifeq ($(GLES_OVERLAY),1) +ES1_LIBS := libes1gallium.a +ES2_LIBS := libes2gallium.a +DEPENDS += depend.es1 depend.es2 +endif + +MESA_OBJ_DIR := . +ES1_OBJ_DIR := objs-es1 +ES2_OBJ_DIR := objs-es2 + + include sources.mak -.SUFFIXES : .cpp +# adjust object dirs +ES1_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(MESA_OBJECTS)) +ES2_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(MESA_OBJECTS)) +MESA_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_OBJECTS)) + +ES1_GALLIUM_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS)) +ES2_GALLIUM_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS)) +MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS)) + +# define preprocessor flags +MESA_CPPFLAGS := $(API_DEFINES) $(DEFINES) +ES1_CPPFLAGS := -DFEATURE_ES1=1 $(DEFINES) +ES2_CPPFLAGS := -DFEATURE_ES2=1 $(DEFINES) + +# append include dirs +MESA_CPPFLAGS += $(INCLUDE_DIRS) +ES1_CPPFLAGS += -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS) +ES2_CPPFLAGS += -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS) + +# tidy compiler flags +CFLAGS := $(filter-out $(DEFINES), $(CFLAGS)) +CXXFLAGS := $(filter-out $(DEFINES), $(CXXFLAGS)) + +# LLVM is needed for the state tracker +MESA_CFLAGS := $(LLVM_CFLAGS) +ES1_CFLAGS := $(LLVM_CFLAGS) +ES2_CFLAGS := $(LLVM_CFLAGS) -.c.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ +define mesa-cc-c + @mkdir -p $(dir $@) + $(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_CFLAGS) $(CFLAGS) +endef -.cpp.o: - $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@ +define mesa-cxx-c + @mkdir -p $(dir $@) + $(CXX) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_CFLAGS) $(CXXFLAGS) +endef -.S.o: - $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@ +$(MESA_OBJ_DIR)/%.o: %.c + $(call mesa-cc-c,MESA) +$(MESA_OBJ_DIR)/%.o: %.cpp + $(call mesa-cxx-c,MESA) + +$(MESA_OBJ_DIR)/%.o: %.S + $(call mesa-cc-c,MESA) + +$(ES1_OBJ_DIR)/%.o: %.c + $(call mesa-cc-c,ES1) + +$(ES1_OBJ_DIR)/%.o: %.cpp + $(call mesa-cxx-c,ES1) + +$(ES1_OBJ_DIR)/%.o: %.S + $(call mesa-cc-c,ES1) + +$(ES2_OBJ_DIR)/%.o: %.c + $(call mesa-cc-c,ES2) + +$(ES2_OBJ_DIR)/%.o: %.cpp + $(call mesa-cxx-c,ES2) + +$(ES2_OBJ_DIR)/%.o: %.S + $(call mesa-cc-c,ES2) # Default: build dependencies, then asm_subdirs, GLSL built-in lib, # then convenience libs (.a) and finally the device drivers: -default: depend asm_subdirs glsl_builtin libmesa.a libmesagallium.a \ - libglapi.a driver_subdirs +default: $(DEPENDS) asm_subdirs \ + $(MESA_LIBS) $(ES1_LIBS) $(ES2_LIBS) driver_subdirs +main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py + $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES1.1 > $@ +main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py + $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES2.0 > $@ ###################################################################### # Helper libraries used by many drivers: @@ -32,17 +103,25 @@ default: depend asm_subdirs glsl_builtin libmesa.a libmesagallium.a \ libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS) @ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS) +libes1.a: $(ES1_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es1 -static $(ES1_OBJECTS) $(GLSL_LIBS) + +libes2.a: $(ES2_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es2 -static $(ES2_OBJECTS) $(GLSL_LIBS) + # Make archive of subset of core mesa object files for gallium libmesagallium.a: $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS) @ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS) -# Make archive of gl* API dispatcher functions only -libglapi.a: $(GLAPI_OBJECTS) - @ $(MKLIB) -o glapi -static $(GLAPI_OBJECTS) +libes1gallium.a: $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es1gallium -static $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS) + +libes2gallium.a: $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) + @$(MKLIB) -o es2gallium -static $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS) ###################################################################### # Device drivers -driver_subdirs: libmesa.a libglapi.a libmesagallium.a +driver_subdirs: $(MESA_LIBS) @ (cd drivers && $(MAKE)) @@ -58,21 +137,26 @@ asm_subdirs: fi -###################################################################### -# GLSL built-in library -glsl_builtin: - (cd shader/slang/library && $(MAKE)) || exit 1 ; - - ###################################################################### # Dependency generation depend: $(ALL_SOURCES) @ echo "running $(MKDEP)" @ touch depend - @$(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \ - > /dev/null 2>/dev/null + @$(MKDEP) $(MKDEP_OPTIONS) -p$(MESA_OBJ_DIR)/ $(MESA_CPPFLAGS) \ + $(ALL_SOURCES) > /dev/null 2>/dev/null + +depend.es1: $(ALL_SOURCES) + @echo "running $(MKDEP) for ES1" + @touch $@ + @$(MKDEP) $(MKDEP_OPTIONS) -f$@ -p$(ES1_OBJ_DIR)/ $(ES1_CPPFLAGS) \ + $(ALL_SOURCES) > /dev/null 2>/dev/null +depend.es2: $(ALL_SOURCES) + @echo "running $(MKDEP) for ES2" + @touch $@ + @$(MKDEP) $(MKDEP_OPTIONS) -f$@ -p$(ES2_OBJ_DIR)/ $(ES2_CPPFLAGS) \ + $(ALL_SOURCES) > /dev/null 2>/dev/null ###################################################################### # Installation rules @@ -96,12 +180,15 @@ install: default esac ; \ done - -gl_pcedit = sed \ +pcedit = \ -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \ -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \ -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \ + + +gl_pcedit = sed \ + $(pcedit) \ -e 's,@GL_PC_REQ_PRIV@,$(GL_PC_REQ_PRIV),' \ -e 's,@GL_PC_LIB_PRIV@,$(GL_PC_LIB_PRIV),' \ -e 's,@GL_PC_CFLAGS@,$(GL_PC_CFLAGS),' \ @@ -111,10 +198,7 @@ gl.pc: gl.pc.in $(gl_pcedit) $< > $@ osmesa_pcedit = sed \ - -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \ - -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \ - -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \ - -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \ + $(pcedit) \ -e 's,@OSMESA_LIB@,$(OSMESA_LIB),' \ -e 's,@OSMESA_PC_REQ@,$(OSMESA_PC_REQ),' \ -e 's,@OSMESA_PC_LIB_PRIV@,$(OSMESA_PC_LIB_PRIV),' @@ -150,14 +234,22 @@ install-dri: default tags: etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h +clean-es1: + -rm -f $(ES1_LIBS) + -rm -rf $(ES1_OBJ_DIR) + -rm -f depend.es1 depend.es1.bak + +clean-es2: + -rm -f $(ES2_LIBS) + -rm -rf $(ES2_OBJ_DIR) + -rm -f depend.es2 depend.es2.bak -clean: +clean: clean-es1 clean-es2 -rm -f */*.o -rm -f */*/*.o - -rm -f depend depend.bak libmesa.a libglapi.a libmesagallium.a + -rm -f depend depend.bak libmesa.a libmesagallium.a -rm -f drivers/*/*.o -rm -f *.pc - -rm -f shader/slang/library/*_gc.h -@cd drivers/dri && $(MAKE) clean -@cd drivers/x11 && $(MAKE) clean -@cd drivers/osmesa && $(MAKE) clean @@ -165,4 +257,4 @@ clean: -@cd x86-64 && $(MAKE) clean --include depend +-include $(DEPENDS) diff --git a/mesalib/src/mesa/Makefile.mgw b/mesalib/src/mesa/Makefile.mgw index b90384d04..fc0ff28d6 100644 --- a/mesalib/src/mesa/Makefile.mgw +++ b/mesalib/src/mesa/Makefile.mgw @@ -216,8 +216,8 @@ clean: -$(call UNLINK,main/*.o) -$(call UNLINK,math/*.o) -$(call UNLINK,vbo/*.o) - -$(call UNLINK,shader/*.o) - -$(call UNLINK,shader/slang/*.o) + -$(call UNLINK,program/*.o) + -$(call UNLINK,slang/*.o) -$(call UNLINK,sparc/*.o) -$(call UNLINK,ppc/*.o) -$(call UNLINK,swrast/*.o) diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c index ebfaa2f07..f92cdc5a7 100644 --- a/mesalib/src/mesa/drivers/common/driverfuncs.c +++ b/mesalib/src/mesa/drivers/common/driverfuncs.c @@ -31,25 +31,20 @@ #include "main/mipmap.h" #include "main/queryobj.h" #include "main/renderbuffer.h" +#include "main/shaderobj.h" #include "main/texcompress.h" #include "main/texformat.h" #include "main/texgetimage.h" #include "main/teximage.h" #include "main/texobj.h" #include "main/texstore.h" -#if FEATURE_ARB_vertex_buffer_object #include "main/bufferobj.h" -#endif -#if FEATURE_EXT_framebuffer_object #include "main/fbobject.h" #include "main/texrender.h" -#endif -#if FEATURE_ARB_sync #include "main/syncobj.h" -#endif +#include "main/transformfeedback.h" -#include "shader/program.h" -#include "shader/shader_api.h" +#include "program/program.h" #include "tnl/tnl.h" #include "swrast/swrast.h" @@ -178,41 +173,31 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->TexParameter = NULL; driver->Viewport = NULL; - /* state queries */ - driver->GetBooleanv = NULL; - driver->GetDoublev = NULL; - driver->GetFloatv = NULL; - driver->GetIntegerv = NULL; - driver->GetInteger64v = NULL; - driver->GetPointerv = NULL; - /* buffer objects */ _mesa_init_buffer_object_functions(driver); /* query objects */ _mesa_init_query_object_functions(driver); -#if FEATURE_ARB_sync _mesa_init_sync_object_functions(driver); -#endif -#if FEATURE_EXT_framebuffer_object driver->NewFramebuffer = _mesa_new_framebuffer; driver->NewRenderbuffer = _mesa_new_soft_renderbuffer; driver->RenderTexture = _mesa_render_texture; driver->FinishRenderTexture = _mesa_finish_render_texture; driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer; -#endif -#if FEATURE_EXT_framebuffer_blit driver->BlitFramebuffer = _swrast_BlitFramebuffer; -#endif /* APPLE_vertex_array_object */ driver->NewArrayObject = _mesa_new_array_object; driver->DeleteArrayObject = _mesa_delete_array_object; driver->BindArrayObject = NULL; + _mesa_init_shader_object_functions(driver); + + _mesa_init_transform_feedback_functions(driver); + /* T&L stuff */ driver->NeedValidate = GL_FALSE; driver->ValidateTnlModule = NULL; @@ -232,10 +217,6 @@ _mesa_init_driver_functions(struct dd_function_table *driver) driver->EndList = NULL; driver->BeginCallList = NULL; driver->EndCallList = NULL; - - - /* XXX temporary here */ - _mesa_init_glsl_driver_functions(driver); } diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c index 89ca476f9..a03cb68ec 100644 --- a/mesalib/src/mesa/drivers/common/meta.c +++ b/mesalib/src/mesa/drivers/common/meta.c @@ -34,6 +34,7 @@ #include "main/glheader.h" #include "main/mtypes.h" #include "main/imports.h" +#include "main/arbprogram.h" #include "main/arrayobj.h" #include "main/blend.h" #include "main/bufferobj.h" @@ -51,7 +52,7 @@ #include "main/polygon.h" #include "main/readpix.h" #include "main/scissor.h" -#include "main/shaders.h" +#include "main/shaderapi.h" #include "main/state.h" #include "main/stencil.h" #include "main/texobj.h" @@ -61,8 +62,7 @@ #include "main/texstate.h" #include "main/varray.h" #include "main/viewport.h" -#include "shader/program.h" -#include "shader/arbprogram.h" +#include "program/program.h" #include "swrast/swrast.h" #include "drivers/common/meta.h" @@ -430,13 +430,15 @@ _mesa_meta_begin(GLcontext *ctx, GLbitfield state) if (state & META_SHADER) { if (ctx->Extensions.ARB_vertex_program) { save->VertexProgramEnabled = ctx->VertexProgram.Enabled; - save->VertexProgram = ctx->VertexProgram.Current; + _mesa_reference_vertprog(ctx, &save->VertexProgram, + ctx->VertexProgram.Current); _mesa_set_enable(ctx, GL_VERTEX_PROGRAM_ARB, GL_FALSE); } if (ctx->Extensions.ARB_fragment_program) { save->FragmentProgramEnabled = ctx->FragmentProgram.Enabled; - save->FragmentProgram = ctx->FragmentProgram.Current; + _mesa_reference_fragprog(ctx, &save->FragmentProgram, + ctx->FragmentProgram.Current); _mesa_set_enable(ctx, GL_FRAGMENT_PROGRAM_ARB, GL_FALSE); } @@ -664,6 +666,7 @@ _mesa_meta_end(GLcontext *ctx) save->VertexProgramEnabled); _mesa_reference_vertprog(ctx, &ctx->VertexProgram.Current, save->VertexProgram); + _mesa_reference_vertprog(ctx, &save->VertexProgram, NULL); } if (ctx->Extensions.ARB_fragment_program) { @@ -671,6 +674,7 @@ _mesa_meta_end(GLcontext *ctx) save->FragmentProgramEnabled); _mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, save->FragmentProgram); + _mesa_reference_fragprog(ctx, &save->FragmentProgram, NULL); } if (ctx->Extensions.ARB_shader_objects) { @@ -721,6 +725,7 @@ _mesa_meta_end(GLcontext *ctx) for (tgt = 0; tgt < NUM_TEXTURE_TARGETS; tgt++) { _mesa_reference_texobj(&ctx->Texture.Unit[0].CurrentTex[tgt], save->CurrentTexture[tgt]); + _mesa_reference_texobj(&save->CurrentTexture[tgt], NULL); } /* Re-enable textures, texgen */ @@ -2082,8 +2087,10 @@ _mesa_meta_Bitmap(GLcontext *ctx, } bitmap1 = _mesa_map_pbo_source(ctx, &unpackSave, bitmap1); - if (!bitmap1) + if (!bitmap1) { + _mesa_meta_end(ctx); return; + } bitmap8 = (GLubyte *) calloc(1, width * height); if (bitmap8) { @@ -2393,6 +2400,9 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target, break; } + /* Set MaxLevel large enough to hold the new level when we allocate it */ + _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel); + /* Create empty dest image */ if (target == GL_TEXTURE_1D) { _mesa_TexImage1D(target, dstLevel, srcImage->InternalFormat, @@ -2560,12 +2570,6 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, return; } - if (texImage->TexFormat == MESA_FORMAT_NONE) - texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, - internalFormat, - format, - type); - _mesa_unlock_texture(ctx, texObj); /* need to unlock first */ /* @@ -2579,12 +2583,10 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, /* * Prepare for new texture image size/data */ -#if FEATURE_convolve if (_mesa_is_color_format(internalFormat)) { _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight); } -#endif if (texImage->Data) { ctx->Driver.FreeTexImageData(ctx, texImage); @@ -2594,6 +2596,9 @@ copy_tex_image(GLcontext *ctx, GLuint dims, GLenum target, GLint level, postConvWidth, postConvHeight, 1, border, internalFormat); + _mesa_choose_texture_format(ctx, texObj, texImage, target, level, + internalFormat, GL_NONE, GL_NONE); + /* * Store texture data (with pixel transfer ops) */ diff --git a/mesalib/src/mesa/drivers/dri/Makefile.template b/mesalib/src/mesa/drivers/dri/Makefile.template index a0c25d26c..a00018caf 100644 --- a/mesalib/src/mesa/drivers/dri/Makefile.template +++ b/mesalib/src/mesa/drivers/dri/Makefile.template @@ -17,6 +17,7 @@ COMMON_SOURCES = $(COMMON_GALLIUM_SOURCES) \ INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES) OBJECTS = $(C_SOURCES:.c=.o) \ + $(CXX_SOURCES:.cpp=.o) \ $(ASM_SOURCES:.S=.o) @@ -26,17 +27,23 @@ SHARED_INCLUDES = \ -I$(TOP)/src/mesa/drivers/dri/common \ -Iserver \ -I$(TOP)/include \ + -I$(TOP)/src/mapi \ -I$(TOP)/src/mesa \ -I$(TOP)/src/egl/main \ -I$(TOP)/src/egl/drivers/dri \ $(LIBDRM_CFLAGS) +CFLAGS += $(API_DEFINES) +CXXFLAGS += $(API_DEFINES) ##### RULES ##### .c.o: $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ +.cpp.o: + $(CC) -c $(INCLUDES) $(CXXFLAGS) $(DRIVER_DEFINES) $< -o $@ + .S.o: $(CC) -c $(INCLUDES) $(CFLAGS) $(DRIVER_DEFINES) $< -o $@ @@ -51,9 +58,12 @@ lib: symlinks subdirs depend @$(MAKE) $(LIBNAME) $(TOP)/$(LIB_DIR)/$(LIBNAME) $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) Makefile \ - $(TOP)/src/mesa/drivers/dri/Makefile.template - $(MKLIB) -o $@ -noprefix -linker '$(CC)' -ldflags '$(LDFLAGS)' \ + $(TOP)/src/mesa/drivers/dri/Makefile.template $(TOP)/src/mesa/drivers/dri/common/dri_test.o + $(MKLIB) -o $@.tmp -noprefix -linker '$(CXX)' -ldflags '$(LDFLAGS)' \ $(OBJECTS) $(MESA_MODULES) $(EXTRA_MODULES) $(DRI_LIB_DEPS) + $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) + @rm -f $@.test + mv -f $@.tmp $@ $(TOP)/$(LIB_DIR)/$(LIBNAME): $(LIBNAME) diff --git a/mesalib/src/mesa/drivers/dri/common/dri_metaops.c b/mesalib/src/mesa/drivers/dri/common/dri_metaops.c index dfb7d6404..a2f404b61 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_metaops.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_metaops.c @@ -26,15 +26,16 @@ * **************************************************************************/ +#include "main/arbprogram.h" #include "main/arrayobj.h" #include "main/bufferobj.h" +#include "main/context.h" #include "main/enable.h" #include "main/matrix.h" #include "main/texstate.h" #include "main/varray.h" #include "main/viewport.h" -#include "shader/arbprogram.h" -#include "shader/program.h" +#include "program/program.h" #include "dri_metaops.h" void diff --git a/mesalib/src/mesa/drivers/dri/common/dri_test.c b/mesalib/src/mesa/drivers/dri/common/dri_test.c new file mode 100644 index 000000000..793f0c37d --- /dev/null +++ b/mesalib/src/mesa/drivers/dri/common/dri_test.c @@ -0,0 +1,89 @@ +#include "main/glheader.h" +#include "main/compiler.h" +#include "glapi/glapi.h" + +/* This is just supposed to make sure we get a reference to + the driver entry symbol that the compiler doesn't optimize away */ + +extern char __driDriverExtensions[]; + +/* provide glapi symbols */ + +#if defined(GLX_USE_TLS) + +PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch + __attribute__((tls_model("initial-exec"))); + +PUBLIC __thread void * _glapi_tls_Context + __attribute__((tls_model("initial-exec"))); + +PUBLIC const struct _glapi_table *_glapi_Dispatch; +PUBLIC const void *_glapi_Context; + +#else + +PUBLIC struct _glapi_table *_glapi_Dispatch; +PUBLIC void *_glapi_Context; + +#endif + +PUBLIC void +_glapi_check_multithread(void) +{} + +PUBLIC void +_glapi_set_context(void *context) +{} + +PUBLIC void * +_glapi_get_context(void) +{ + return 0; +} + +PUBLIC void +_glapi_set_dispatch(struct _glapi_table *dispatch) +{} + +PUBLIC struct _glapi_table * +_glapi_get_dispatch(void) +{ + return 0; +} + +PUBLIC int +_glapi_add_dispatch( const char * const * function_names, + const char * parameter_signature ) +{ + return 0; +} + +PUBLIC GLint +_glapi_get_proc_offset(const char *funcName) +{ + return 0; +} + +PUBLIC _glapi_proc +_glapi_get_proc_address(const char *funcName) +{ + return 0; +} + +PUBLIC GLuint +_glapi_get_dispatch_table_size(void) +{ + return 0; +} + +PUBLIC unsigned long +_glthread_GetID(void) +{ + return 0; +} + +int main(int argc, char** argv) +{ + void* p = __driDriverExtensions; + return (int)(unsigned long)p; +} diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.c b/mesalib/src/mesa/drivers/dri/common/dri_util.c index 75c98825b..d46f622d5 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.c +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.c @@ -31,6 +31,17 @@ #include "dri_util.h" #include "drm_sarea.h" #include "utils.h" +#include "xmlpool.h" +#include "../glsl/glsl_parser_extras.h" + +PUBLIC const char __dri2ConfigOptions[] = + DRI_CONF_BEGIN + DRI_CONF_SECTION_PERFORMANCE + DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1) + DRI_CONF_SECTION_END + DRI_CONF_END; + +static const uint __dri2NConfigOptions = 1; #ifndef GLX_OML_sync_control typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRIdrawable *drawable, int32_t *numerator, int32_t *denominator); @@ -47,28 +58,6 @@ const __DRIextension driReadDrawableExtension = { __DRI_READ_DRAWABLE, __DRI_READ_DRAWABLE_VERSION }; -/** - * Print message to \c stderr if the \c LIBGL_DEBUG environment variable - * is set. - * - * Is called from the drivers. - * - * \param f \c printf like format string. - */ -void -__driUtilMessage(const char *f, ...) -{ - va_list args; - - if (getenv("LIBGL_DEBUG")) { - fprintf(stderr, "libGL: "); - va_start(args, f); - vfprintf(stderr, f, args); - va_end(args); - fprintf(stderr, "\n"); - } -} - GLint driIntersectArea( drm_clip_rect_t rect1, drm_clip_rect_t rect2 ) { @@ -151,11 +140,6 @@ static int driUnbindContext(__DRIcontext *pcp) */ pcp->driDrawablePriv = pcp->driReadablePriv = NULL; -#if 0 - /* Unbind the drawable */ - pdp->driContextPriv = &psp->dummyContextPriv; -#endif - return GL_TRUE; } @@ -170,19 +154,24 @@ static int driBindContext(__DRIcontext *pcp, { __DRIscreen *psp = NULL; - /* Bind the drawable to the context */ + /* + ** Assume error checking is done properly in glXMakeCurrent before + ** calling driUnbindContext. + */ - if (pcp) { - psp = pcp->driScreenPriv; - pcp->driDrawablePriv = pdp; - pcp->driReadablePriv = prp; - if (pdp) { - pdp->driContextPriv = pcp; - dri_get_drawable(pdp); - } - if ( prp && pdp != prp ) { - dri_get_drawable(prp); - } + if (!pcp) + return GL_FALSE; + + /* Bind the drawable to the context */ + psp = pcp->driScreenPriv; + pcp->driDrawablePriv = pdp; + pcp->driReadablePriv = prp; + if (pdp) { + pdp->driContextPriv = pcp; + dri_get_drawable(pdp); + } + if (prp && pdp != prp) { + dri_get_drawable(prp); } /* @@ -190,7 +179,6 @@ static int driBindContext(__DRIcontext *pcp, ** initialize the drawable information if has not been done before. */ - assert(psp); if (!psp->dri2.enabled) { if (pdp && !pdp->pStamp) { DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); @@ -205,7 +193,6 @@ static int driBindContext(__DRIcontext *pcp, } /* Call device-specific MakeCurrent */ - return (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp); } @@ -437,6 +424,7 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, return NULL; } + pdp->driContextPriv = NULL; pdp->loaderPrivate = data; pdp->hHWDrawable = hwDrawable; pdp->refcount = 1; @@ -455,7 +443,6 @@ driCreateNewDrawable(__DRIscreen *psp, const __DRIconfig *config, pdp->vblFlags = 0; pdp->driScreenPriv = psp; - pdp->driContextPriv = &psp->dummyContextPriv; if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, &config->modes, renderType == GLX_PIXMAP_BIT)) { @@ -495,6 +482,41 @@ dri2CreateNewDrawable(__DRIscreen *screen, return pdraw; } +static int +dri2ConfigQueryb(__DRIscreen *screen, const char *var, GLboolean *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_BOOL)) + return -1; + + *val = driQueryOptionb(&screen->optionCache, var); + + return 0; +} + +static int +dri2ConfigQueryi(__DRIscreen *screen, const char *var, GLint *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_INT) && + !driCheckOption(&screen->optionCache, var, DRI_ENUM)) + return -1; + + *val = driQueryOptioni(&screen->optionCache, var); + + return 0; +} + +static int +dri2ConfigQueryf(__DRIscreen *screen, const char *var, GLfloat *val) +{ + if (!driCheckOption(&screen->optionCache, var, DRI_FLOAT)) + return -1; + + *val = driQueryOptionf(&screen->optionCache, var); + + return 0; +} + + static void dri_get_drawable(__DRIdrawable *pdp) { pdp->refcount++; @@ -589,21 +611,11 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, pcp->dri2.draw_stamp = 0; pcp->dri2.read_stamp = 0; - /* When the first context is created for a screen, initialize a "dummy" - * context. - */ - - if (!psp->dri2.enabled && !psp->dummyContextPriv.driScreenPriv) { - psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context; - psp->dummyContextPriv.driScreenPriv = psp; - psp->dummyContextPriv.driDrawablePriv = NULL; - psp->dummyContextPriv.driverPrivate = NULL; - /* No other fields should be used! */ - } pcp->hHWContext = hwContext; - if ( !(*psp->DriverAPI.CreateContext)(&config->modes, pcp, shareCtx) ) { + if ( !(*psp->DriverAPI.CreateContext)(API_OPENGL, + &config->modes, pcp, shareCtx) ) { free(pcp); return NULL; } @@ -611,15 +623,65 @@ driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, return pcp; } +static unsigned int +dri2GetAPIMask(__DRIscreen *screen) +{ + return screen->api_mask; +} + +static __DRIcontext * +dri2CreateNewContextForAPI(__DRIscreen *screen, int api, + const __DRIconfig *config, + __DRIcontext *shared, void *data) +{ + __DRIcontext *context; + const __GLcontextModes *modes = (config != NULL) ? &config->modes : NULL; + void *shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; + gl_api mesa_api; + + if (!(screen->api_mask & (1 << api))) + return NULL; + + switch (api) { + case __DRI_API_OPENGL: + mesa_api = API_OPENGL; + break; + case __DRI_API_GLES: + mesa_api = API_OPENGLES; + break; + case __DRI_API_GLES2: + mesa_api = API_OPENGLES2; + break; + default: + return NULL; + } + + context = malloc(sizeof *context); + if (!context) + return NULL; + + context->driScreenPriv = screen; + context->driDrawablePriv = NULL; + context->loaderPrivate = data; + + if (!(*screen->DriverAPI.CreateContext)(mesa_api, modes, + context, shareCtx) ) { + free(context); + return NULL; + } + + return context; +} + static __DRIcontext * dri2CreateNewContext(__DRIscreen *screen, const __DRIconfig *config, __DRIcontext *shared, void *data) { - return driCreateNewContext(screen, config, 0, shared, 0, data); + return dri2CreateNewContextForAPI(screen, __DRI_API_OPENGL, + config, shared, data); } - static int driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask) { @@ -649,6 +711,8 @@ static void driDestroyScreen(__DRIscreen *psp) * stream open to the X-server anymore. */ + _mesa_destroy_shader_compiler(); + if (psp->DriverAPI.DestroyScreen) (*psp->DriverAPI.DestroyScreen)(psp); @@ -656,6 +720,9 @@ static void driDestroyScreen(__DRIscreen *psp) (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize); (void)drmCloseOnce(psp->fd); + } else { + driDestroyOptionCache(&psp->optionCache); + driDestroyOptionInfo(&psp->optionInfo); } free(psp); @@ -679,6 +746,8 @@ setupLoaderExtensions(__DRIscreen *psp, psp->dri2.loader = (__DRIdri2LoaderExtension *) extensions[i]; if (strcmp(extensions[i]->name, __DRI_IMAGE_LOOKUP) == 0) psp->dri2.image = (__DRIimageLookupExtension *) extensions[i]; + if (strcmp(extensions[i]->name, __DRI_USE_INVALIDATE) == 0) + psp->dri2.useInvalidate = (__DRIuseInvalidateExtension *) extensions[i]; } } @@ -756,14 +825,8 @@ driCreateNewScreen(int scrn, psp->myNum = scrn; psp->dri2.enabled = GL_FALSE; - /* - ** Do not init dummy context here; actual initialization will be - ** done when the first DRI context is created. Init screen priv ptr - ** to NULL to let CreateContext routine that it needs to be inited. - */ - psp->dummyContextPriv.driScreenPriv = NULL; - psp->DriverAPI = driDriverAPI; + psp->api_mask = (1 << __DRI_API_OPENGL); *driver_modes = driDriverAPI.InitScreen(psp); if (*driver_modes == NULL) { @@ -809,6 +872,7 @@ dri2CreateNewScreen(int scrn, int fd, psp->dri2.enabled = GL_TRUE; psp->DriverAPI = driDriverAPI; + psp->api_mask = (1 << __DRI_API_OPENGL); *driver_configs = driDriverAPI.InitScreen2(psp); if (*driver_configs == NULL) { free(psp); @@ -816,6 +880,12 @@ dri2CreateNewScreen(int scrn, int fd, } psp->DriverAPI = driDriverAPI; + psp->loaderPrivate = data; + + driParseOptionInfo(&psp->optionInfo, __dri2ConfigOptions, + __dri2NConfigOptions); + driParseConfigFiles(&psp->optionCache, &psp->optionInfo, psp->myNum, + "dri2"); return psp; } @@ -857,41 +927,15 @@ const __DRIdri2Extension driDRI2Extension = { dri2CreateNewScreen, dri2CreateNewDrawable, dri2CreateNewContext, + dri2GetAPIMask, + dri2CreateNewContextForAPI }; -static int -driFrameTracking(__DRIdrawable *drawable, GLboolean enable) -{ - return GLX_BAD_CONTEXT; -} - -static int -driQueryFrameTracking(__DRIdrawable *dpriv, - int64_t * sbc, int64_t * missedFrames, - float * lastMissedUsage, float * usage) -{ - __DRIswapInfo sInfo; - int status; - int64_t ust; - __DRIscreen *psp = dpriv->driScreenPriv; - - status = dpriv->driScreenPriv->DriverAPI.GetSwapInfo( dpriv, & sInfo ); - if ( status == 0 ) { - *sbc = sInfo.swap_count; - *missedFrames = sInfo.swap_missed_count; - *lastMissedUsage = sInfo.swap_missed_usage; - - (*psp->systemTime->getUST)( & ust ); - *usage = driCalculateSwapUsage( dpriv, sInfo.swap_ust, ust ); - } - - return status; -} - -const __DRIframeTrackingExtension driFrameTrackingExtension = { - { __DRI_FRAME_TRACKING, __DRI_FRAME_TRACKING_VERSION }, - driFrameTracking, - driQueryFrameTracking +const __DRI2configQueryExtension dri2ConfigQueryExtension = { + { __DRI2_CONFIG_QUERY, __DRI2_CONFIG_QUERY_VERSION }, + dri2ConfigQueryb, + dri2ConfigQueryi, + dri2ConfigQueryf, }; /** diff --git a/mesalib/src/mesa/drivers/dri/common/dri_util.h b/mesalib/src/mesa/drivers/dri/common/dri_util.h index 99c0f1e44..785beacd8 100644 --- a/mesalib/src/mesa/drivers/dri/common/dri_util.h +++ b/mesalib/src/mesa/drivers/dri/common/dri_util.h @@ -51,7 +51,9 @@ #include #include #include +#include "xmlconfig.h" #include "main/glheader.h" +#include "main/mtypes.h" #include "GL/internal/glcore.h" #include "GL/internal/dri_interface.h" @@ -68,8 +70,8 @@ extern const __DRIdri2Extension driDRI2Extension; extern const __DRIextension driReadDrawableExtension; extern const __DRIcopySubBufferExtension driCopySubBufferExtension; extern const __DRIswapControlExtension driSwapControlExtension; -extern const __DRIframeTrackingExtension driFrameTrackingExtension; extern const __DRImediaStreamCounterExtension driMediaStreamCounterExtension; +extern const __DRI2configQueryExtension dri2ConfigQueryExtension; /** * Used by DRI_VALIDATE_DRAWABLE_INFO @@ -146,8 +148,9 @@ struct __DriverAPIRec { /** * Context creation callback */ - GLboolean (*CreateContext)(const __GLcontextModes *glVis, - __DRIcontext *driContextPriv, + GLboolean (*CreateContext)(gl_api api, + const __GLcontextModes *glVis, + __DRIcontext *driContextPriv, void *sharedContextPrivate); /** @@ -398,11 +401,6 @@ struct __DRIcontextRec { */ void *driverPrivate; - /** - * Pointer back to the \c __DRIcontext that contains this structure. - */ - __DRIcontext *pctx; - /** * Pointer to drawable currently bound to this context for drawing. */ @@ -510,29 +508,16 @@ struct __DRIscreenRec { int devPrivSize; /*@}*/ - /** - * Dummy context to which drawables are bound when not bound to any - * other context. - * - * A dummy hHWContext is created for this context, and is used by the GL - * core when a hardware lock is required but the drawable is not currently - * bound (e.g., potentially during a SwapBuffers request). The dummy - * context is created when the first "real" context is created on this - * screen. - */ - __DRIcontext dummyContextPriv; - /** * Device-dependent private information (not stored in the SAREA). * * This pointer is never touched by the DRI layer. */ +#ifdef __cplusplus + void *priv; +#else void *private; - - /** - * Pointer back to the \c __DRIscreen that contains this structure. - */ - __DRIscreen *psc; +#endif /* Extensions provided by the loader. */ const __DRIgetDrawableInfoExtension *getDrawableInfo; @@ -545,15 +530,17 @@ struct __DRIscreenRec { int enabled; __DRIdri2LoaderExtension *loader; __DRIimageLookupExtension *image; + __DRIuseInvalidateExtension *useInvalidate; } dri2; /* The lock actually in use, old sarea or DRI2 */ drmLock *lock; -}; - -extern void -__driUtilMessage(const char *f, ...); + driOptionCache optionInfo; + driOptionCache optionCache; + unsigned int api_mask; + void *loaderPrivate; +}; extern void __driUtilUpdateDrawableInfo(__DRIdrawable *pdp); diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.c b/mesalib/src/mesa/drivers/dri/common/drisw_util.c new file mode 100644 index 000000000..1529c23b1 --- /dev/null +++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.c @@ -0,0 +1,273 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * 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 drisw_util.c + * + * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits. + */ + +#include "drisw_util.h" +#include "utils.h" + + +/** + * Screen functions + */ + +static void +setupLoaderExtensions(__DRIscreen *psp, + const __DRIextension **extensions) +{ + int i; + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0) + psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i]; + } +} + +static __DRIscreen * +driCreateNewScreen(int scrn, const __DRIextension **extensions, + const __DRIconfig ***driver_configs, void *data) +{ + static const __DRIextension *emptyExtensionList[] = { NULL }; + __DRIscreen *psp; + + (void) data; + + psp = CALLOC_STRUCT(__DRIscreenRec); + if (!psp) + return NULL; + + setupLoaderExtensions(psp, extensions); + + psp->extensions = emptyExtensionList; + psp->fd = -1; + psp->myNum = scrn; + + *driver_configs = driDriverAPI.InitScreen(psp); + + if (*driver_configs == NULL) { + FREE(psp); + return NULL; + } + + return psp; +} + +static void driDestroyScreen(__DRIscreen *psp) +{ + if (psp) { + driDriverAPI.DestroyScreen(psp); + + FREE(psp); + } +} + +static const __DRIextension **driGetExtensions(__DRIscreen *psp) +{ + return psp->extensions; +} + + +/** + * Context functions + */ + +static __DRIcontext * +driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, + __DRIcontext *shared, void *data) +{ + __DRIcontext *pcp; + void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; + + pcp = CALLOC_STRUCT(__DRIcontextRec); + if (!pcp) + return NULL; + + pcp->loaderPrivate = data; + + pcp->driScreenPriv = psp; + pcp->driDrawablePriv = NULL; + pcp->driReadablePriv = NULL; + + if (!driDriverAPI.CreateContext(API_OPENGL, + &config->modes, pcp, shareCtx)) { + FREE(pcp); + return NULL; + } + + return pcp; +} + +static void +driDestroyContext(__DRIcontext *pcp) +{ + if (pcp) { + driDriverAPI.DestroyContext(pcp); + FREE(pcp); + } +} + +static int +driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask) +{ + return GL_FALSE; +} + +static void dri_get_drawable(__DRIdrawable *pdp); +static void dri_put_drawable(__DRIdrawable *pdp); + +static int driBindContext(__DRIcontext *pcp, + __DRIdrawable *pdp, + __DRIdrawable *prp) +{ + /* Bind the drawable to the context */ + if (pcp) { + pcp->driDrawablePriv = pdp; + pcp->driReadablePriv = prp; + if (pdp) { + pdp->driContextPriv = pcp; + dri_get_drawable(pdp); + } + if ( prp && pdp != prp ) { + dri_get_drawable(prp); + } + } + + return driDriverAPI.MakeCurrent(pcp, pdp, prp); +} + +static int driUnbindContext(__DRIcontext *pcp) +{ + __DRIdrawable *pdp; + __DRIdrawable *prp; + + if (pcp == NULL) + return GL_FALSE; + + pdp = pcp->driDrawablePriv; + prp = pcp->driReadablePriv; + + /* already unbound */ + if (!pdp && !prp) + return GL_TRUE; + + driDriverAPI.UnbindContext(pcp); + + dri_put_drawable(pdp); + + if (prp != pdp) { + dri_put_drawable(prp); + } + + pcp->driDrawablePriv = NULL; + pcp->driReadablePriv = NULL; + + return GL_TRUE; +} + + +/** + * Drawable functions + */ + +static void dri_get_drawable(__DRIdrawable *pdp) +{ + pdp->refcount++; +} + +static void dri_put_drawable(__DRIdrawable *pdp) +{ + if (pdp) { + pdp->refcount--; + if (pdp->refcount) + return; + + driDriverAPI.DestroyBuffer(pdp); + + FREE(pdp); + } +} + +static __DRIdrawable * +driCreateNewDrawable(__DRIscreen *psp, + const __DRIconfig *config, void *data) +{ + __DRIdrawable *pdp; + + pdp = CALLOC_STRUCT(__DRIdrawableRec); + if (!pdp) + return NULL; + + pdp->loaderPrivate = data; + + pdp->driScreenPriv = psp; + pdp->driContextPriv = NULL; + + dri_get_drawable(pdp); + + if (!driDriverAPI.CreateBuffer(psp, pdp, &config->modes, GL_FALSE)) { + FREE(pdp); + return NULL; + } + + pdp->lastStamp = 1; /* const */ + + return pdp; +} + +static void +driDestroyDrawable(__DRIdrawable *pdp) +{ + dri_put_drawable(pdp); +} + +static void driSwapBuffers(__DRIdrawable *pdp) +{ + driDriverAPI.SwapBuffers(pdp); +} + +const __DRIcoreExtension driCoreExtension = { + { __DRI_CORE, __DRI_CORE_VERSION }, + NULL, /* driCreateNewScreen */ + driDestroyScreen, + driGetExtensions, + driGetConfigAttrib, + driIndexConfigAttrib, + NULL, /* driCreateNewDrawable */ + driDestroyDrawable, + driSwapBuffers, + driCreateNewContext, + driCopyContext, + driDestroyContext, + driBindContext, + driUnbindContext +}; + +const __DRIswrastExtension driSWRastExtension = { + { __DRI_SWRAST, __DRI_SWRAST_VERSION }, + driCreateNewScreen, + driCreateNewDrawable +}; diff --git a/mesalib/src/mesa/drivers/dri/common/drisw_util.h b/mesalib/src/mesa/drivers/dri/common/drisw_util.h new file mode 100644 index 000000000..9c3d01c99 --- /dev/null +++ b/mesalib/src/mesa/drivers/dri/common/drisw_util.h @@ -0,0 +1,135 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * 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 + * Binding of the DRI interface (dri_interface.h) for DRISW. + * + * The DRISW structs are 'base classes' of the corresponding DRI1 / DRI2 (DRM) + * structs. The bindings for SW and DRM can be unified by making the DRM structs + * 'sub-classes' of the SW structs, either proper or with field re-ordering. + * + * The code can also be unified but that requires cluttering the common code + * with ifdef's and guarding with (__DRIscreen::fd >= 0) for DRM. + */ + +#ifndef _DRISW_UTIL_H +#define _DRISW_UTIL_H + +#include "main/mtypes.h" + +#include +#include +#include +typedef struct _drmLock drmLock; + + +/** + * Extensions + */ +extern const __DRIcoreExtension driCoreExtension; +extern const __DRIswrastExtension driSWRastExtension; + + +/** + * Driver callback functions + */ +struct __DriverAPIRec { + const __DRIconfig **(*InitScreen) (__DRIscreen * priv); + + void (*DestroyScreen)(__DRIscreen *driScrnPriv); + + GLboolean (*CreateContext)(gl_api glapi, + const __GLcontextModes *glVis, + __DRIcontext *driContextPriv, + void *sharedContextPrivate); + + void (*DestroyContext)(__DRIcontext *driContextPriv); + + GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, + __DRIdrawable *driDrawPriv, + const __GLcontextModes *glVis, + GLboolean pixmapBuffer); + + void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); + + void (*SwapBuffers)(__DRIdrawable *driDrawPriv); + + GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, + __DRIdrawable *driDrawPriv, + __DRIdrawable *driReadPriv); + + GLboolean (*UnbindContext)(__DRIcontext *driContextPriv); +}; + +extern const struct __DriverAPIRec driDriverAPI; + + +/** + * Data types + */ +struct __DRIscreenRec { + int myNum; + + int fd; + + void *private; + + const __DRIextension **extensions; + + const __DRIswrastLoaderExtension *swrast_loader; +}; + +struct __DRIcontextRec { + + void *driverPrivate; + + void *loaderPrivate; + + __DRIdrawable *driDrawablePriv; + + __DRIdrawable *driReadablePriv; + + __DRIscreen *driScreenPriv; +}; + +struct __DRIdrawableRec { + + void *driverPrivate; + + void *loaderPrivate; + + __DRIcontext *driContextPriv; + + __DRIscreen *driScreenPriv; + + int refcount; + + /* gallium */ + unsigned int lastStamp; + + int w; + int h; +}; + +#endif /* _DRISW_UTIL_H */ diff --git a/mesalib/src/mesa/drivers/dri/common/spantmp2.h b/mesalib/src/mesa/drivers/dri/common/spantmp2.h index 98422a856..1dab7336b 100644 --- a/mesalib/src/mesa/drivers/dri/common/spantmp2.h +++ b/mesalib/src/mesa/drivers/dri/common/spantmp2.h @@ -413,6 +413,38 @@ } while (0) # endif +#elif (SPANTMP_PIXEL_FMT == GL_ALPHA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_BYTE) + +/** + ** GL_ALPHA, GL_UNSIGNED_BYTE + **/ + +#ifndef GET_VALUE +#ifndef GET_PTR +#define GET_PTR(_x, _y) ( buf + (_x) + (_y) * pitch) +#endif + +#define GET_VALUE(_x, _y) *(volatile GLubyte *)(GET_PTR(_x, _y)) +#define PUT_VALUE(_x, _y, _v) *(volatile GLubyte *)(GET_PTR(_x, _y)) = (_v) +#endif /* GET_VALUE */ + +# define INIT_MONO_PIXEL(p, color) \ + p = color[3] + +# define WRITE_RGBA(_x, _y, r, g, b, a) \ + PUT_VALUE(_x, _y, a | (r & 0 /* quiet warnings */)) + +#define WRITE_PIXEL(_x, _y, p) PUT_VALUE(_x, _y, p) + +#define READ_RGBA( rgba, _x, _y ) \ + do { \ + GLubyte p = GET_VALUE(_x, _y); \ + rgba[0] = 0; \ + rgba[1] = 0; \ + rgba[2] = 0; \ + rgba[3] = p; \ + } while (0) + #else #error SPANTMP_PIXEL_FMT must be set to a valid value! #endif diff --git a/mesalib/src/mesa/drivers/dri/common/utils.c b/mesalib/src/mesa/drivers/dri/common/utils.c index b85b364c5..0dd879abc 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.c +++ b/mesalib/src/mesa/drivers/dri/common/utils.c @@ -37,6 +37,29 @@ #include "utils.h" +/** + * Print message to \c stderr if the \c LIBGL_DEBUG environment variable + * is set. + * + * Is called from the drivers. + * + * \param f \c printf like format string. + */ +void +__driUtilMessage(const char *f, ...) +{ + va_list args; + + if (getenv("LIBGL_DEBUG")) { + fprintf(stderr, "libGL: "); + va_start(args, f); + vfprintf(stderr, f, args); + va_end(args); + fprintf(stderr, "\n"); + } +} + + unsigned driParseDebugString( const char * debug, const struct dri_debug_control * control ) @@ -230,9 +253,6 @@ void driInitSingleExtension( GLcontext * ctx, /** * Utility function used by drivers to test the verions of other components. * - * If one of the version requirements is not met, a message is logged using - * \c __driUtilMessage. - * * \param driver_name Name of the driver. Used in error messages. * \param driActual Actual DRI version supplied __driCreateNewScreen. * \param driExpected Minimum DRI version required by the driver. @@ -244,7 +264,7 @@ void driInitSingleExtension( GLcontext * ctx, * \returns \c GL_TRUE if all version requirements are met. Otherwise, * \c GL_FALSE is returned. * - * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2, __driUtilMessage + * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2 * * \todo * Now that the old \c driCheckDriDdxDrmVersions function is gone, this diff --git a/mesalib/src/mesa/drivers/dri/common/utils.h b/mesalib/src/mesa/drivers/dri/common/utils.h index 02ca3feb7..de6070c39 100644 --- a/mesalib/src/mesa/drivers/dri/common/utils.h +++ b/mesalib/src/mesa/drivers/dri/common/utils.h @@ -69,6 +69,9 @@ struct __DRIutilversionRec2 { int patch; /**< Patch-level. */ }; +extern void +__driUtilMessage(const char *f, ...); + extern unsigned driParseDebugString( const char * debug, const struct dri_debug_control * control ); diff --git a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c index a6d6c999a..738b1ae97 100644 --- a/mesalib/src/mesa/drivers/dri/common/xmlconfig.c +++ b/mesalib/src/mesa/drivers/dri/common/xmlconfig.c @@ -36,7 +36,7 @@ #include #include #include "main/imports.h" -#include "dri_util.h" +#include "utils.h" #include "xmlconfig.h" #undef GET_PROGRAM_NAME diff --git a/mesalib/src/mesa/drivers/dri/swrast/Makefile b/mesalib/src/mesa/drivers/dri/swrast/Makefile index 771169c1f..d2cf6dbc5 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/Makefile +++ b/mesalib/src/mesa/drivers/dri/swrast/Makefile @@ -5,6 +5,8 @@ include $(TOP)/configs/current LIBNAME = swrast_dri.so +DRIVER_DEFINES = -D__NOT_HAVE_DRM_H + DRIVER_SOURCES = \ swrast.c \ swrast_span.c @@ -17,7 +19,8 @@ ASM_SOURCES = SWRAST_COMMON_SOURCES = \ ../../common/driverfuncs.c \ - ../common/utils.c + ../common/utils.c \ + ../common/drisw_util.c include ../Makefile.template diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c index 03c672ecf..ff53ffd0d 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 George Sapountzis + * Copyright 2008, 2010 George Sapountzis * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -47,6 +47,11 @@ #include "drivers/common/meta.h" #include "utils.h" +#include "main/teximage.h" +#include "main/texfetch.h" +#include "main/texformat.h" +#include "main/texstate.h" + #include "swrast_priv.h" @@ -54,18 +59,62 @@ * Screen and config-related functions */ -static void -setupLoaderExtensions(__DRIscreen *psp, - const __DRIextension **extensions) +static void swrastSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, + GLint texture_format, __DRIdrawable *dPriv) { - int i; + struct dri_context *dri_ctx; + int x, y, w, h; + __DRIscreen *sPriv = dPriv->driScreenPriv; + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + uint32_t internalFormat; - for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0) - psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i]; - } + dri_ctx = pDRICtx->driverPrivate; + + internalFormat = (texture_format == __DRI_TEXTURE_FORMAT_RGB ? 3 : 4); + + texUnit = _mesa_get_current_tex_unit(&dri_ctx->Base); + texObj = _mesa_select_tex_object(&dri_ctx->Base, texUnit, target); + texImage = _mesa_get_tex_image(&dri_ctx->Base, texObj, target, 0); + + _mesa_lock_texture(&dri_ctx->Base, texObj); + + sPriv->swrast_loader->getDrawableInfo(dPriv, &x, &y, &w, &h, dPriv->loaderPrivate); + + _mesa_init_teximage_fields(&dri_ctx->Base, target, texImage, + w, h, 1, 0, internalFormat); + + if (texture_format == __DRI_TEXTURE_FORMAT_RGB) + texImage->TexFormat = MESA_FORMAT_XRGB8888; + else + texImage->TexFormat = MESA_FORMAT_ARGB8888; + + _mesa_set_fetch_functions(texImage, 2); + + sPriv->swrast_loader->getImage(dPriv, x, y, w, h, (char *)texImage->Data, + dPriv->loaderPrivate); + + _mesa_unlock_texture(&dri_ctx->Base, texObj); } +static void swrastSetTexBuffer(__DRIcontext *pDRICtx, GLint target, + __DRIdrawable *dPriv) +{ + swrastSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv); +} + +static const __DRItexBufferExtension swrastTexBufferExtension = { + { __DRI_TEX_BUFFER, __DRI_TEX_BUFFER_VERSION }, + swrastSetTexBuffer, + swrastSetTexBuffer2, +}; + +static const __DRIextension *dri_screen_extensions[] = { + &swrastTexBufferExtension.base, + NULL +}; + static __DRIconfig ** swrastFillInModes(__DRIscreen *psp, unsigned pixel_bits, unsigned depth_bits, @@ -143,26 +192,14 @@ swrastFillInModes(__DRIscreen *psp, return configs; } -static __DRIscreen * -driCreateNewScreen(int scrn, const __DRIextension **extensions, - const __DRIconfig ***driver_configs, void *data) +static const __DRIconfig ** +dri_init_screen(__DRIscreen * psp) { - static const __DRIextension *emptyExtensionList[] = { NULL }; - __DRIscreen *psp; __DRIconfig **configs8, **configs16, **configs24, **configs32; - (void) data; - TRACE; - psp = calloc(1, sizeof(*psp)); - if (!psp) - return NULL; - - setupLoaderExtensions(psp, extensions); - - psp->num = scrn; - psp->extensions = emptyExtensionList; + psp->extensions = dri_screen_extensions; configs8 = swrastFillInModes(psp, 8, 8, 0, 1); configs16 = swrastFillInModes(psp, 16, 16, 0, 1); @@ -171,28 +208,15 @@ driCreateNewScreen(int scrn, const __DRIextension **extensions, configs16 = driConcatConfigs(configs8, configs16); configs24 = driConcatConfigs(configs16, configs24); - *driver_configs = (const __DRIconfig **) - driConcatConfigs(configs24, configs32); - - driInitExtensions( NULL, NULL, GL_FALSE ); - - return psp; -} + configs32 = driConcatConfigs(configs24, configs32); -static void driDestroyScreen(__DRIscreen *psp) -{ - TRACE; - - if (psp) { - free(psp); - } + return (const __DRIconfig **)configs32; } -static const __DRIextension **driGetExtensions(__DRIscreen *psp) +static void +dri_destroy_screen(__DRIscreen * sPriv) { TRACE; - - return psp->extensions; } @@ -239,12 +263,20 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb) free(rb); } +/* see bytes_per_line in libGL */ +static INLINE int +bytes_per_line(unsigned pitch_bits, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((pitch_bits + mask) & ~mask) / 8; +} + static GLboolean swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); - unsigned mask = PITCH_ALIGN_BITS - 1; TRACE; @@ -252,8 +284,7 @@ swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; - /* always pad to PITCH_ALIGN_BITS */ - xrb->pitch = ((width * xrb->bpp + mask) & ~mask) / 8; + xrb->pitch = bytes_per_line(width * xrb->bpp, 32); return GL_TRUE; } @@ -336,94 +367,118 @@ swrast_new_renderbuffer(const GLvisual *visual, GLboolean front) return xrb; } -static __DRIdrawable * -driCreateNewDrawable(__DRIscreen *screen, - const __DRIconfig *config, void *data) +static GLboolean +dri_create_buffer(__DRIscreen * sPriv, + __DRIdrawable * dPriv, + const __GLcontextModes * visual, GLboolean isPixmap) { - __DRIdrawable *buf; + struct dri_drawable *drawable = NULL; + GLframebuffer *fb; struct swrast_renderbuffer *frontrb, *backrb; TRACE; - buf = calloc(1, sizeof *buf); - if (!buf) - return NULL; + drawable = CALLOC_STRUCT(dri_drawable); + if (drawable == NULL) + goto drawable_fail; - buf->loaderPrivate = data; + dPriv->driverPrivate = drawable; + drawable->dPriv = dPriv; - buf->driScreenPriv = screen; + drawable->row = malloc(MAX_WIDTH * 4); + if (drawable->row == NULL) + goto drawable_fail; - buf->row = malloc(MAX_WIDTH * 4); + fb = &drawable->Base; /* basic framebuffer setup */ - _mesa_initialize_window_framebuffer(&buf->Base, &config->modes); + _mesa_initialize_window_framebuffer(fb, visual); /* add front renderbuffer */ - frontrb = swrast_new_renderbuffer(&config->modes, GL_TRUE); - _mesa_add_renderbuffer(&buf->Base, BUFFER_FRONT_LEFT, &frontrb->Base); + frontrb = swrast_new_renderbuffer(visual, GL_TRUE); + _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontrb->Base); /* add back renderbuffer */ - if (config->modes.doubleBufferMode) { - backrb = swrast_new_renderbuffer(&config->modes, GL_FALSE); - _mesa_add_renderbuffer(&buf->Base, BUFFER_BACK_LEFT, &backrb->Base); + if (visual->doubleBufferMode) { + backrb = swrast_new_renderbuffer(visual, GL_FALSE); + _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backrb->Base); } /* add software renderbuffers */ - _mesa_add_soft_renderbuffers(&buf->Base, + _mesa_add_soft_renderbuffers(fb, GL_FALSE, /* color */ - config->modes.haveDepthBuffer, - config->modes.haveStencilBuffer, - config->modes.haveAccumBuffer, + visual->haveDepthBuffer, + visual->haveStencilBuffer, + visual->haveAccumBuffer, GL_FALSE, /* alpha */ GL_FALSE /* aux bufs */); - return buf; + return GL_TRUE; + +drawable_fail: + + if (drawable) + free(drawable->row); + + FREE(drawable); + + return GL_FALSE; } static void -driDestroyDrawable(__DRIdrawable *buf) +dri_destroy_buffer(__DRIdrawable * dPriv) { TRACE; - if (buf) { - struct gl_framebuffer *fb = &buf->Base; + if (dPriv) { + struct dri_drawable *drawable = dri_drawable(dPriv); + GLframebuffer *fb; - free(buf->row); + free(drawable->row); + + fb = &drawable->Base; fb->DeletePending = GL_TRUE; _mesa_reference_framebuffer(&fb, NULL); } } -static void driSwapBuffers(__DRIdrawable *buf) +static void +dri_swap_buffers(__DRIdrawable * dPriv) { - GET_CURRENT_CONTEXT(ctx); + __DRIscreen *sPriv = dPriv->driScreenPriv; - struct swrast_renderbuffer *frontrb = - swrast_renderbuffer(buf->Base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer); - struct swrast_renderbuffer *backrb = - swrast_renderbuffer(buf->Base.Attachment[BUFFER_BACK_LEFT].Renderbuffer); + GET_CURRENT_CONTEXT(ctx); - __DRIscreen *screen = buf->driScreenPriv; + struct dri_drawable *drawable = dri_drawable(dPriv); + GLframebuffer *fb; + struct swrast_renderbuffer *frontrb, *backrb; TRACE; + fb = &drawable->Base; + + frontrb = + swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + backrb = + swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + /* check for signle-buffered */ if (backrb == NULL) return; /* check if swapping currently bound buffer */ - if (ctx && ctx->DrawBuffer == &(buf->Base)) { + if (ctx && ctx->DrawBuffer == fb) { /* flush pending rendering */ _mesa_notifySwapBuffers(ctx); } - screen->swrast_loader->putImage(buf, __DRI_SWRAST_IMAGE_OP_SWAP, - 0, 0, - frontrb->Base.Width, - frontrb->Base.Height, - backrb->Base.Data, - buf->loaderPrivate); + sPriv->swrast_loader->putImage(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, + 0, 0, + frontrb->Base.Width, + frontrb->Base.Height, + backrb->Base.Data, + dPriv->loaderPrivate); } @@ -434,13 +489,13 @@ static void driSwapBuffers(__DRIdrawable *buf) static void get_window_size( GLframebuffer *fb, GLsizei *w, GLsizei *h ) { - __DRIdrawable *buf = swrast_drawable(fb); - __DRIscreen *screen = buf->driScreenPriv; + __DRIdrawable *dPriv = swrast_drawable(fb)->dPriv; + __DRIscreen *sPriv = dPriv->driScreenPriv; int x, y; - screen->swrast_loader->getDrawableInfo(buf, - &x, &y, w, h, - buf->loaderPrivate); + sPriv->swrast_loader->getDrawableInfo(dPriv, + &x, &y, w, h, + dPriv->loaderPrivate); } static void @@ -488,6 +543,16 @@ viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h) swrast_check_and_update_window_size(ctx, read); } +static gl_format swrastChooseTextureFormat(GLcontext * ctx, + GLint internalFormat, + GLenum format, + GLenum type) +{ + if (internalFormat == GL_RGB) + return MESA_FORMAT_XRGB8888; + return _mesa_choose_tex_format(ctx, internalFormat, format, type); +} + static void swrast_init_driver_functions(struct dd_function_table *driver) { @@ -495,6 +560,7 @@ swrast_init_driver_functions(struct dd_function_table *driver) driver->UpdateState = update_state; driver->GetBufferSize = NULL; driver->Viewport = viewport; + driver->ChooseTextureFormat = swrastChooseTextureFormat; } @@ -502,37 +568,41 @@ swrast_init_driver_functions(struct dd_function_table *driver) * Context-related functions. */ -static __DRIcontext * -driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config, - __DRIcontext *shared, void *data) +static GLboolean +dri_create_context(gl_api api, + const __GLcontextModes * visual, + __DRIcontext * cPriv, void *sharedContextPrivate) { - __DRIcontext *ctx; - GLcontext *mesaCtx; + struct dri_context *ctx = NULL; + struct dri_context *share = (struct dri_context *)sharedContextPrivate; + GLcontext *mesaCtx = NULL; + GLcontext *sharedCtx = NULL; struct dd_function_table functions; TRACE; - ctx = calloc(1, sizeof *ctx); - if (!ctx) - return NULL; - - ctx->loaderPrivate = data; + ctx = CALLOC_STRUCT(dri_context); + if (ctx == NULL) + goto context_fail; - ctx->driScreenPriv = screen; + cPriv->driverPrivate = ctx; + ctx->cPriv = cPriv; /* build table of device driver functions */ _mesa_init_driver_functions(&functions); swrast_init_driver_functions(&functions); - if (!_mesa_initialize_context(&ctx->Base, &config->modes, - shared ? &shared->Base : NULL, - &functions, (void *) ctx)) { - free(ctx); - return NULL; + if (share) { + sharedCtx = &share->Base; } mesaCtx = &ctx->Base; + /* basic context setup */ + if (!_mesa_initialize_context(mesaCtx, visual, sharedCtx, &functions, (void *) cPriv)) { + goto context_fail; + } + /* do bounds checking to prevent segfaults and server crashes! */ mesaCtx->Const.CheckArrayBounds = GL_TRUE; @@ -558,17 +628,28 @@ driCreateNewContext(__DRIscreen *screen, const __DRIconfig *config, _mesa_meta_init(mesaCtx); - return ctx; + driInitExtensions( mesaCtx, NULL, GL_FALSE ); + + return GL_TRUE; + +context_fail: + + FREE(ctx); + + return GL_FALSE; } static void -driDestroyContext(__DRIcontext *ctx) +dri_destroy_context(__DRIcontext * cPriv) { - GLcontext *mesaCtx; TRACE; - if (ctx) { + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + GLcontext *mesaCtx; + mesaCtx = &ctx->Base; + _mesa_meta_free(mesaCtx); _swsetup_DestroyContext( mesaCtx ); _swrast_DestroyContext( mesaCtx ); @@ -578,28 +659,26 @@ driDestroyContext(__DRIcontext *ctx) } } -static int -driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask) -{ - TRACE; - - _mesa_copy_context(&src->Base, &dst->Base, mask); - return GL_TRUE; -} - -static int driBindContext(__DRIcontext *ctx, - __DRIdrawable *draw, - __DRIdrawable *read) +static GLboolean +dri_make_current(__DRIcontext * cPriv, + __DRIdrawable * driDrawPriv, + __DRIdrawable * driReadPriv) { GLcontext *mesaCtx; GLframebuffer *mesaDraw; GLframebuffer *mesaRead; TRACE; - if (ctx) { - if (!draw || !read) + if (cPriv) { + struct dri_context *ctx = dri_context(cPriv); + struct dri_drawable *draw; + struct dri_drawable *read; + + if (!driDrawPriv || !driReadPriv) return GL_FALSE; + draw = dri_drawable(driDrawPriv); + read = dri_drawable(driReadPriv); mesaCtx = &ctx->Base; mesaDraw = &draw->Base; mesaRead = &read->Base; @@ -614,7 +693,7 @@ static int driBindContext(__DRIcontext *ctx, _glapi_check_multithread(); swrast_check_and_update_window_size(mesaCtx, mesaDraw); - if (read != draw) + if (mesaRead != mesaDraw) swrast_check_and_update_window_size(mesaCtx, mesaRead); _mesa_make_current( mesaCtx, @@ -629,35 +708,29 @@ static int driBindContext(__DRIcontext *ctx, return GL_TRUE; } -static int driUnbindContext(__DRIcontext *ctx) +static GLboolean +dri_unbind_context(__DRIcontext * cPriv) { TRACE; - (void) ctx; + (void) cPriv; + + /* Unset current context and dispath table */ + _mesa_make_current(NULL, NULL, NULL); + return GL_TRUE; } -static const __DRIcoreExtension driCoreExtension = { - { __DRI_CORE, __DRI_CORE_VERSION }, - NULL, /* driCreateNewScreen */ - driDestroyScreen, - driGetExtensions, - driGetConfigAttrib, - driIndexConfigAttrib, - NULL, /* driCreateNewDrawable */ - driDestroyDrawable, - driSwapBuffers, - driCreateNewContext, - driCopyContext, - driDestroyContext, - driBindContext, - driUnbindContext -}; - -static const __DRIswrastExtension driSWRastExtension = { - { __DRI_SWRAST, __DRI_SWRAST_VERSION }, - driCreateNewScreen, - driCreateNewDrawable +const struct __DriverAPIRec driDriverAPI = { + .InitScreen = dri_init_screen, + .DestroyScreen = dri_destroy_screen, + .CreateContext = dri_create_context, + .DestroyContext = dri_destroy_context, + .CreateBuffer = dri_create_buffer, + .DestroyBuffer = dri_destroy_buffer, + .SwapBuffers = dri_swap_buffers, + .MakeCurrent = dri_make_current, + .UnbindContext = dri_unbind_context, }; /* This is the table of extensions that the loader will dlsym() for. */ diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h index 4722007f9..6679061a9 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -3,6 +3,7 @@ * Version: 7.1 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright 2008, 2010 George Sapountzis * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,11 +23,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Authors: - * George Sapountzis - */ - #ifndef _SWRAST_PRIV_H #define _SWRAST_PRIV_H @@ -34,6 +30,7 @@ #include #include #include "main/mtypes.h" +#include "drisw_util.h" /** @@ -58,33 +55,51 @@ /** * Data types */ -struct __DRIscreenRec { - int num; - - const __DRIextension **extensions; +struct dri_context +{ + /* mesa, base class, must be first */ + GLcontext Base; - const __DRIswrastLoaderExtension *swrast_loader; + /* dri */ + __DRIcontext *cPriv; }; -struct __DRIcontextRec { - GLcontext Base; - - void *loaderPrivate; +static INLINE struct dri_context * +dri_context(__DRIcontext * driContextPriv) +{ + return (struct dri_context *)driContextPriv->driverPrivate; +} - __DRIscreen *driScreenPriv; -}; +static INLINE struct dri_context * +swrast_context(GLcontext *ctx) +{ + return (struct dri_context *) ctx; +} -struct __DRIdrawableRec { +struct dri_drawable +{ + /* mesa, base class, must be first */ GLframebuffer Base; - void *loaderPrivate; - - __DRIscreen *driScreenPriv; + /* dri */ + __DRIdrawable *dPriv; /* scratch row for optimized front-buffer rendering */ char *row; }; +static INLINE struct dri_drawable * +dri_drawable(__DRIdrawable * driDrawPriv) +{ + return (struct dri_drawable *)driDrawPriv->driverPrivate; +} + +static INLINE struct dri_drawable * +swrast_drawable(GLframebuffer *fb) +{ + return (struct dri_drawable *) fb; +} + struct swrast_renderbuffer { struct gl_renderbuffer Base; @@ -94,18 +109,6 @@ struct swrast_renderbuffer { GLuint bpp; }; -static INLINE __DRIcontext * -swrast_context(GLcontext *ctx) -{ - return (__DRIcontext *) ctx; -} - -static INLINE __DRIdrawable * -swrast_drawable(GLframebuffer *fb) -{ - return (__DRIdrawable *) fb; -} - static INLINE struct swrast_renderbuffer * swrast_renderbuffer(struct gl_renderbuffer *rb) { @@ -121,14 +124,6 @@ swrast_renderbuffer(struct gl_renderbuffer *rb) #define PF_R3G3B2 3 /**< 8bpp TrueColor: 3-R, 3-G, 2-B bits */ #define PF_X8R8G8B8 4 /**< 32bpp TrueColor: 8-R, 8-G, 8-B bits */ -/** - * Renderbuffer pitch alignment (in bits). - * - * The xorg loader requires padding images to 32 bits. However, this should - * become a screen/drawable parameter XXX - */ -#define PITCH_ALIGN_BITS 32 - /* swrast_span.c */ diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_span.c b/mesalib/src/mesa/drivers/dri/swrast/swrast_span.c index d896e154f..c7d0bfdac 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_span.c +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_span.c @@ -3,6 +3,7 @@ * Version: 7.1 * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. + * Copyright 2008, 2010 George Sapountzis * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -22,11 +23,6 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/* - * Authors: - * George Sapountzis - */ - #include "swrast_priv.h" #define YFLIP(_xrb, Y) ((_xrb)->Base.Height - (Y) - 1) diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast_spantemp.h b/mesalib/src/mesa/drivers/dri/swrast/swrast_spantemp.h index 848736171..1e9405eeb 100644 --- a/mesalib/src/mesa/drivers/dri/swrast/swrast_spantemp.h +++ b/mesalib/src/mesa/drivers/dri/swrast/swrast_spantemp.h @@ -39,8 +39,8 @@ static INLINE void PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLvoid *p ) { - __DRIcontext *ctx = swrast_context(glCtx); - __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; + __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; @@ -53,8 +53,8 @@ PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLvoid *p ) static INLINE void GET_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) { - __DRIcontext *ctx = swrast_context(glCtx); - __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; + __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; @@ -65,8 +65,8 @@ GET_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) static INLINE void PUT_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) { - __DRIcontext *ctx = swrast_context(glCtx); - __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; + __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; @@ -78,8 +78,8 @@ PUT_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) static INLINE void GET_ROW( GLcontext *glCtx, GLint x, GLint y, GLuint n, char *row ) { - __DRIcontext *ctx = swrast_context(glCtx); - __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer); + __DRIcontext *ctx = swrast_context(glCtx)->cPriv; + __DRIdrawable *read = swrast_drawable(glCtx->ReadBuffer)->dPriv; __DRIscreen *screen = ctx->driScreenPriv; diff --git a/mesalib/src/mesa/main/APIspec.dtd b/mesalib/src/mesa/main/APIspec.dtd new file mode 100644 index 000000000..efcfa31f1 --- /dev/null +++ b/mesalib/src/mesa/main/APIspec.dtd @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mesalib/src/mesa/main/APIspec.py b/mesalib/src/mesa/main/APIspec.py new file mode 100644 index 000000000..6947f7301 --- /dev/null +++ b/mesalib/src/mesa/main/APIspec.py @@ -0,0 +1,617 @@ +#!/usr/bin/python +# +# Copyright (C) 2009 Chia-I Wu +# +# 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 +# on the rights to use, copy, modify, merge, publish, distribute, sub +# license, 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 NON-INFRINGEMENT. IN NO EVENT SHALL +# IBM AND/OR ITS SUPPLIERS 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. +""" +A parser for APIspec. +""" + +class SpecError(Exception): + """Error in the spec file.""" + + +class Spec(object): + """A Spec is an abstraction of the API spec.""" + + def __init__(self, doc): + self.doc = doc + + self.spec_node = doc.getRootElement() + self.tmpl_nodes = {} + self.api_nodes = {} + self.impl_node = None + + # parse + node = self.spec_node.children + while node: + if node.type == "element": + if node.name == "template": + self.tmpl_nodes[node.prop("name")] = node + elif node.name == "api": + self.api_nodes[node.prop("name")] = node + else: + raise SpecError("unexpected node %s in apispec" % + node.name) + node = node.next + + # find an implementation + for name, node in self.api_nodes.iteritems(): + if node.prop("implementation") == "true": + self.impl_node = node + break + if not self.impl_node: + raise SpecError("unable to find an implementation") + + def get_impl(self): + """Return the implementation.""" + return API(self, self.impl_node) + + def get_api(self, name): + """Return an API.""" + return API(self, self.api_nodes[name]) + + +class API(object): + """An API consists of categories and functions.""" + + def __init__(self, spec, api_node): + self.name = api_node.prop("name") + self.is_impl = (api_node.prop("implementation") == "true") + + self.categories = [] + self.functions = [] + + # parse + func_nodes = [] + node = api_node.children + while node: + if node.type == "element": + if node.name == "category": + cat = node.prop("name") + self.categories.append(cat) + elif node.name == "function": + func_nodes.append(node) + else: + raise SpecError("unexpected node %s in api" % node.name) + node = node.next + + # realize functions + for func_node in func_nodes: + tmpl_node = spec.tmpl_nodes[func_node.prop("template")] + try: + func = Function(tmpl_node, func_node, self.is_impl, + self.categories) + except SpecError, e: + func_name = func_node.prop("name") + raise SpecError("failed to parse %s: %s" % (func_name, e)) + self.functions.append(func) + + def match(self, func, conversions={}): + """Find a matching function in the API.""" + match = None + need_conv = False + for f in self.functions: + matched, conv = f.match(func, conversions) + if matched: + match = f + need_conv = conv + # exact match + if not need_conv: + break + return (match, need_conv) + + +class Function(object): + """Parse and realize a