From f8fe689a81f906d1b91bb3220acde2a4ecb14c5b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 May 2024 05:01:46 +0200 Subject: Adding upstream version 6.0.4-dfsg. Signed-off-by: Daniel Baumann --- src/VBox/GuestHost/OpenGL/.scm-settings | 49 + src/VBox/GuestHost/OpenGL/LICENSE | 32 + src/VBox/GuestHost/OpenGL/Makefile.kmk | 692 ++ src/VBox/GuestHost/OpenGL/error/Makefile.kup | 0 src/VBox/GuestHost/OpenGL/error/VBoxOGLerrorspu.rc | 81 + src/VBox/GuestHost/OpenGL/error/error.def | 6 + src/VBox/GuestHost/OpenGL/error/error.py | 49 + src/VBox/GuestHost/OpenGL/error/errorspu.rc | 69 + src/VBox/GuestHost/OpenGL/error/errorspu_init.c | 62 + src/VBox/GuestHost/OpenGL/glapi_parser/APIspec.txt | 10531 +++++++++++++++++++ src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py | 773 ++ src/VBox/GuestHost/OpenGL/include/GL/glext.h | 7669 ++++++++++++++ src/VBox/GuestHost/OpenGL/include/chromium.h | 864 ++ src/VBox/GuestHost/OpenGL/include/cr_bbox.h | 39 + src/VBox/GuestHost/OpenGL/include/cr_bits.h | 72 + src/VBox/GuestHost/OpenGL/include/cr_blitter.h | 377 + src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h | 25 + src/VBox/GuestHost/OpenGL/include/cr_bufpool.h | 33 + src/VBox/GuestHost/OpenGL/include/cr_calllists.h | 28 + src/VBox/GuestHost/OpenGL/include/cr_compiler.h | 45 + src/VBox/GuestHost/OpenGL/include/cr_compositor.h | 265 + .../GuestHost/OpenGL/include/cr_debugopcodes.h | 23 + src/VBox/GuestHost/OpenGL/include/cr_dispatch.h | 66 + src/VBox/GuestHost/OpenGL/include/cr_dll.h | 49 + src/VBox/GuestHost/OpenGL/include/cr_dmx.h | 55 + src/VBox/GuestHost/OpenGL/include/cr_dump.h | 177 + src/VBox/GuestHost/OpenGL/include/cr_endian.h | 90 + src/VBox/GuestHost/OpenGL/include/cr_environment.h | 23 + src/VBox/GuestHost/OpenGL/include/cr_error.h | 67 + src/VBox/GuestHost/OpenGL/include/cr_extstring.h | 323 + src/VBox/GuestHost/OpenGL/include/cr_glext.h | 34 + src/VBox/GuestHost/OpenGL/include/cr_glstate.h | 335 + src/VBox/GuestHost/OpenGL/include/cr_hash.h | 70 + src/VBox/GuestHost/OpenGL/include/cr_htable.h | 120 + src/VBox/GuestHost/OpenGL/include/cr_hull.h | 24 + src/VBox/GuestHost/OpenGL/include/cr_list.h | 48 + src/VBox/GuestHost/OpenGL/include/cr_logo.h | 2746 +++++ src/VBox/GuestHost/OpenGL/include/cr_matrix.h | 96 + src/VBox/GuestHost/OpenGL/include/cr_mem.h | 38 + src/VBox/GuestHost/OpenGL/include/cr_net.h | 360 + src/VBox/GuestHost/OpenGL/include/cr_netserver.h | 39 + src/VBox/GuestHost/OpenGL/include/cr_pack.h | 442 + src/VBox/GuestHost/OpenGL/include/cr_perf.h | 76 + src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h | 54 + src/VBox/GuestHost/OpenGL/include/cr_process.h | 54 + src/VBox/GuestHost/OpenGL/include/cr_protocol.h | 291 + src/VBox/GuestHost/OpenGL/include/cr_rand.h | 25 + src/VBox/GuestHost/OpenGL/include/cr_server.h | 594 ++ src/VBox/GuestHost/OpenGL/include/cr_sortarray.h | 102 + src/VBox/GuestHost/OpenGL/include/cr_spu.h | 483 + src/VBox/GuestHost/OpenGL/include/cr_string.h | 67 + src/VBox/GuestHost/OpenGL/include/cr_threads.h | 118 + src/VBox/GuestHost/OpenGL/include/cr_timer.h | 58 + src/VBox/GuestHost/OpenGL/include/cr_unpack.h | 98 + src/VBox/GuestHost/OpenGL/include/cr_url.h | 23 + src/VBox/GuestHost/OpenGL/include/cr_version.h | 186 + src/VBox/GuestHost/OpenGL/include/cr_vreg.h | 411 + src/VBox/GuestHost/OpenGL/include/cr_warp.h | 22 + src/VBox/GuestHost/OpenGL/include/crut_api.h | 211 + src/VBox/GuestHost/OpenGL/include/crut_clientapi.h | 45 + .../GuestHost/OpenGL/include/state/cr_attrib.h | 405 + .../GuestHost/OpenGL/include/state/cr_buffer.h | 95 + .../OpenGL/include/state/cr_bufferobject.h | 71 + .../GuestHost/OpenGL/include/state/cr_client.h | 143 + .../GuestHost/OpenGL/include/state/cr_current.h | 107 + .../GuestHost/OpenGL/include/state/cr_evaluators.h | 91 + .../GuestHost/OpenGL/include/state/cr_feedback.h | 56 + src/VBox/GuestHost/OpenGL/include/state/cr_fog.h | 62 + .../OpenGL/include/state/cr_framebuffer.h | 108 + src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h | 122 + src/VBox/GuestHost/OpenGL/include/state/cr_hint.h | 62 + .../GuestHost/OpenGL/include/state/cr_lighting.h | 92 + .../GuestHost/OpenGL/include/state/cr_limits.h | 285 + src/VBox/GuestHost/OpenGL/include/state/cr_line.h | 44 + src/VBox/GuestHost/OpenGL/include/state/cr_lists.h | 45 + .../OpenGL/include/state/cr_multisample.h | 47 + .../GuestHost/OpenGL/include/state/cr_occlude.h | 58 + src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h | 74 + src/VBox/GuestHost/OpenGL/include/state/cr_point.h | 62 + .../GuestHost/OpenGL/include/state/cr_polygon.h | 53 + .../GuestHost/OpenGL/include/state/cr_program.h | 142 + .../OpenGL/include/state/cr_regcombiner.h | 71 + .../GuestHost/OpenGL/include/state/cr_stateerror.h | 16 + .../GuestHost/OpenGL/include/state/cr_statetypes.h | 209 + .../GuestHost/OpenGL/include/state/cr_stencil.h | 107 + .../GuestHost/OpenGL/include/state/cr_texture.h | 250 + .../GuestHost/OpenGL/include/state/cr_transform.h | 91 + .../GuestHost/OpenGL/include/state/cr_viewport.h | 57 + src/VBox/GuestHost/OpenGL/packer/Makefile.kup | 0 src/VBox/GuestHost/OpenGL/packer/opcodes.py | 106 + src/VBox/GuestHost/OpenGL/packer/pack_arrays.c | 209 + src/VBox/GuestHost/OpenGL/packer/pack_bbox.h | 183 + src/VBox/GuestHost/OpenGL/packer/pack_beginend.c | 86 + src/VBox/GuestHost/OpenGL/packer/pack_bounds.c | 50 + src/VBox/GuestHost/OpenGL/packer/pack_buffer.c | 533 + .../GuestHost/OpenGL/packer/pack_bufferobject.c | 121 + src/VBox/GuestHost/OpenGL/packer/pack_client.c | 1089 ++ src/VBox/GuestHost/OpenGL/packer/pack_clipplane.c | 23 + src/VBox/GuestHost/OpenGL/packer/pack_context.c | 142 + src/VBox/GuestHost/OpenGL/packer/pack_current.py | 65 + .../GuestHost/OpenGL/packer/pack_currentheader.py | 66 + .../GuestHost/OpenGL/packer/pack_currenttypes.py | 142 + src/VBox/GuestHost/OpenGL/packer/pack_error.c | 71 + src/VBox/GuestHost/OpenGL/packer/pack_extensions.c | 37 + src/VBox/GuestHost/OpenGL/packer/pack_feedback.c | 46 + src/VBox/GuestHost/OpenGL/packer/pack_fence.c | 45 + src/VBox/GuestHost/OpenGL/packer/pack_fog.c | 69 + .../GuestHost/OpenGL/packer/pack_framebuffer.c | 71 + src/VBox/GuestHost/OpenGL/packer/pack_header.py | 91 + src/VBox/GuestHost/OpenGL/packer/pack_init.c | 74 + src/VBox/GuestHost/OpenGL/packer/pack_lights.c | 123 + src/VBox/GuestHost/OpenGL/packer/pack_lists.c | 96 + src/VBox/GuestHost/OpenGL/packer/pack_map.c | 294 + src/VBox/GuestHost/OpenGL/packer/pack_materials.c | 68 + src/VBox/GuestHost/OpenGL/packer/pack_matrices.c | 224 + src/VBox/GuestHost/OpenGL/packer/pack_misc.c | 216 + src/VBox/GuestHost/OpenGL/packer/pack_pica.c | 650 ++ src/VBox/GuestHost/OpenGL/packer/pack_pixelmap.c | 64 + src/VBox/GuestHost/OpenGL/packer/pack_pixels.c | 225 + src/VBox/GuestHost/OpenGL/packer/pack_point.c | 107 + src/VBox/GuestHost/OpenGL/packer/pack_program.c | 542 + .../GuestHost/OpenGL/packer/pack_regcombiner.c | 82 + src/VBox/GuestHost/OpenGL/packer/pack_shaders.c | 866 ++ src/VBox/GuestHost/OpenGL/packer/pack_stipple.c | 36 + src/VBox/GuestHost/OpenGL/packer/pack_swap.py | 74 + src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c | 117 + src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c | 278 + .../GuestHost/OpenGL/packer/pack_swap_pixelmap.c | 62 + .../GuestHost/OpenGL/packer/pack_swap_texture.c | 981 ++ src/VBox/GuestHost/OpenGL/packer/pack_texture.c | 1030 ++ .../GuestHost/OpenGL/packer/pack_visibleregion.c | 58 + src/VBox/GuestHost/OpenGL/packer/packer.h | 27 + src/VBox/GuestHost/OpenGL/packer/packer.py | 274 + src/VBox/GuestHost/OpenGL/packer/packer_bbox.py | 316 + src/VBox/GuestHost/OpenGL/packer/packer_defs.py | 203 + .../GuestHost/OpenGL/packer/packer_extensions.h | 13 + src/VBox/GuestHost/OpenGL/packer/packer_special | 185 + src/VBox/GuestHost/OpenGL/spu_loader/Makefile.kup | 0 .../GuestHost/OpenGL/spu_loader/choosevisual.c | 329 + src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py | 126 + .../GuestHost/OpenGL/spu_loader/dispatchheader.py | 78 + src/VBox/GuestHost/OpenGL/spu_loader/glloader.py | 609 ++ src/VBox/GuestHost/OpenGL/spu_loader/loader.def | 21 + src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py | 73 + src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py | 80 + src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c | 225 + src/VBox/GuestHost/OpenGL/spu_loader/spuload.c | 290 + .../GuestHost/OpenGL/state_tracker/Makefile.kup | 0 src/VBox/GuestHost/OpenGL/state_tracker/convert.py | 75 + src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp | 1741 +++ .../GuestHost/OpenGL/state_tracker/dump_gen.py | 249 + .../GuestHost/OpenGL/state_tracker/gendiffcode.py | 273 + .../OpenGL/state_tracker/get_components.py | 141 + src/VBox/GuestHost/OpenGL/state_tracker/state.h | 80 + .../GuestHost/OpenGL/state_tracker/state_attrib.c | 1185 +++ .../OpenGL/state_tracker/state_bits_globalop.h | 338 + .../GuestHost/OpenGL/state_tracker/state_buffer.c | 776 ++ .../OpenGL/state_tracker/state_buffer.txt | 34 + .../OpenGL/state_tracker/state_bufferobject.c | 1126 ++ .../GuestHost/OpenGL/state_tracker/state_client.c | 2433 +++++ .../OpenGL/state_tracker/state_client.txt | 32 + .../GuestHost/OpenGL/state_tracker/state_current.c | 435 + .../OpenGL/state_tracker/state_current.py | 485 + .../GuestHost/OpenGL/state_tracker/state_defs.py | 64 + .../GuestHost/OpenGL/state_tracker/state_diff.c | 644 ++ .../GuestHost/OpenGL/state_tracker/state_enable.c | 544 + .../GuestHost/OpenGL/state_tracker/state_error.c | 86 + .../OpenGL/state_tracker/state_evaluators.c | 1084 ++ .../OpenGL/state_tracker/state_extensions_get.txt | 138 + .../state_tracker/state_extensions_isenabled.txt | 71 + .../OpenGL/state_tracker/state_feedback.c | 2423 +++++ .../OpenGL/state_tracker/state_feedback_special | 73 + .../GuestHost/OpenGL/state_tracker/state_fence.c | 50 + .../GuestHost/OpenGL/state_tracker/state_flush.c | 34 + .../GuestHost/OpenGL/state_tracker/state_fog.c | 199 + .../GuestHost/OpenGL/state_tracker/state_fog.txt | 13 + .../OpenGL/state_tracker/state_framebuffer.c | 1202 +++ .../GuestHost/OpenGL/state_tracker/state_funcs.py | 62 + .../GuestHost/OpenGL/state_tracker/state_get.py | 234 + .../GuestHost/OpenGL/state_tracker/state_get.txt | 319 + .../OpenGL/state_tracker/state_getstring.c | 55 + .../GuestHost/OpenGL/state_tracker/state_glsl.c | 1527 +++ .../GuestHost/OpenGL/state_tracker/state_hint.c | 132 + .../GuestHost/OpenGL/state_tracker/state_hint.txt | 12 + .../GuestHost/OpenGL/state_tracker/state_init.c | 892 ++ .../OpenGL/state_tracker/state_internals.h | 29 + .../OpenGL/state_tracker/state_isenabled.py | 75 + .../OpenGL/state_tracker/state_isenabled.txt | 76 + .../OpenGL/state_tracker/state_lighting.c | 1212 +++ .../OpenGL/state_tracker/state_lighting.txt | 63 + .../GuestHost/OpenGL/state_tracker/state_limits.c | 475 + .../GuestHost/OpenGL/state_tracker/state_line.c | 87 + .../GuestHost/OpenGL/state_tracker/state_line.txt | 8 + .../GuestHost/OpenGL/state_tracker/state_lists.c | 1407 +++ .../OpenGL/state_tracker/state_multisample.c | 51 + .../OpenGL/state_tracker/state_multisample.txt | 9 + .../GuestHost/OpenGL/state_tracker/state_occlude.c | 354 + .../GuestHost/OpenGL/state_tracker/state_pixel.c | 857 ++ .../GuestHost/OpenGL/state_tracker/state_point.c | 447 + .../GuestHost/OpenGL/state_tracker/state_point.txt | 39 + .../GuestHost/OpenGL/state_tracker/state_polygon.c | 211 + .../OpenGL/state_tracker/state_polygon.txt | 22 + .../GuestHost/OpenGL/state_tracker/state_program.c | 2392 +++++ .../OpenGL/state_tracker/state_program.txt | 14 + .../OpenGL/state_tracker/state_rasterpos.c | 327 + .../OpenGL/state_tracker/state_regcombiner.c | 705 ++ .../OpenGL/state_tracker/state_regcombiner.txt | 38 + .../OpenGL/state_tracker/state_select_special | 61 + .../OpenGL/state_tracker/state_snapshot.c | 2678 +++++ .../GuestHost/OpenGL/state_tracker/state_special | 385 + .../GuestHost/OpenGL/state_tracker/state_stencil.c | 1450 +++ .../OpenGL/state_tracker/state_stencil.txt | 9 + .../GuestHost/OpenGL/state_tracker/state_texdiff.c | 1469 +++ .../OpenGL/state_tracker/state_teximage.c | 1762 ++++ .../GuestHost/OpenGL/state_tracker/state_texture.c | 3418 ++++++ .../OpenGL/state_tracker/state_transform.c | 1392 +++ .../OpenGL/state_tracker/state_viewport.c | 166 + .../OpenGL/state_tracker/state_viewport.txt | 14 + src/VBox/GuestHost/OpenGL/util/Makefile.kup | 0 src/VBox/GuestHost/OpenGL/util/VBoxOGLcrutil.rc | 80 + src/VBox/GuestHost/OpenGL/util/bbox.c | 229 + src/VBox/GuestHost/OpenGL/util/blitter.cpp | 2124 ++++ src/VBox/GuestHost/OpenGL/util/bmpscale.cpp | 319 + src/VBox/GuestHost/OpenGL/util/bufpool.c | 194 + src/VBox/GuestHost/OpenGL/util/calllists.c | 81 + src/VBox/GuestHost/OpenGL/util/compositor.cpp | 1070 ++ src/VBox/GuestHost/OpenGL/util/debug_opcodes.py | 42 + src/VBox/GuestHost/OpenGL/util/devnull.c | 118 + src/VBox/GuestHost/OpenGL/util/dll.c | 411 + src/VBox/GuestHost/OpenGL/util/endian.c | 39 + src/VBox/GuestHost/OpenGL/util/environment.c | 34 + src/VBox/GuestHost/OpenGL/util/error.c | 219 + src/VBox/GuestHost/OpenGL/util/filenet.c | 385 + src/VBox/GuestHost/OpenGL/util/hash.c | 777 ++ src/VBox/GuestHost/OpenGL/util/htable.cpp | 188 + src/VBox/GuestHost/OpenGL/util/hull.c | 315 + src/VBox/GuestHost/OpenGL/util/idpool.c | 288 + src/VBox/GuestHost/OpenGL/util/libteac.c | 1213 +++ src/VBox/GuestHost/OpenGL/util/list.c | 314 + src/VBox/GuestHost/OpenGL/util/lowercase.py | 27 + src/VBox/GuestHost/OpenGL/util/matrix.c | 510 + src/VBox/GuestHost/OpenGL/util/mem.c | 160 + src/VBox/GuestHost/OpenGL/util/net.c | 1406 +++ src/VBox/GuestHost/OpenGL/util/net_internals.h | 189 + src/VBox/GuestHost/OpenGL/util/pixel.c | 1863 ++++ src/VBox/GuestHost/OpenGL/util/process.c | 251 + src/VBox/GuestHost/OpenGL/util/rand.c | 115 + src/VBox/GuestHost/OpenGL/util/sortarray.cpp | 414 + src/VBox/GuestHost/OpenGL/util/string.c | 589 ++ src/VBox/GuestHost/OpenGL/util/tcpip.c | 1472 +++ src/VBox/GuestHost/OpenGL/util/threads.c | 308 + src/VBox/GuestHost/OpenGL/util/timer.c | 129 + src/VBox/GuestHost/OpenGL/util/udptcpip.c | 753 ++ src/VBox/GuestHost/OpenGL/util/url.c | 94 + src/VBox/GuestHost/OpenGL/util/util.def | 172 + src/VBox/GuestHost/OpenGL/util/util.rc | 69 + src/VBox/GuestHost/OpenGL/util/vboxhgcm.c | 2498 +++++ src/VBox/GuestHost/OpenGL/util/vreg.cpp | 1702 +++ src/VBox/GuestHost/OpenGL/util/warp.c | 24 + 259 files changed, 107438 insertions(+) create mode 100644 src/VBox/GuestHost/OpenGL/.scm-settings create mode 100644 src/VBox/GuestHost/OpenGL/LICENSE create mode 100644 src/VBox/GuestHost/OpenGL/Makefile.kmk create mode 100644 src/VBox/GuestHost/OpenGL/error/Makefile.kup create mode 100644 src/VBox/GuestHost/OpenGL/error/VBoxOGLerrorspu.rc create mode 100644 src/VBox/GuestHost/OpenGL/error/error.def create mode 100755 src/VBox/GuestHost/OpenGL/error/error.py create mode 100644 src/VBox/GuestHost/OpenGL/error/errorspu.rc create mode 100644 src/VBox/GuestHost/OpenGL/error/errorspu_init.c create mode 100644 src/VBox/GuestHost/OpenGL/glapi_parser/APIspec.txt create mode 100755 src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py create mode 100644 src/VBox/GuestHost/OpenGL/include/GL/glext.h create mode 100644 src/VBox/GuestHost/OpenGL/include/chromium.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_bbox.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_bits.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_blitter.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_bufpool.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_calllists.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_compiler.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_compositor.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_debugopcodes.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_dispatch.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_dll.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_dmx.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_dump.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_endian.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_environment.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_error.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_extstring.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_glext.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_glstate.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_hash.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_htable.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_hull.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_list.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_logo.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_matrix.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_mem.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_net.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_netserver.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_pack.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_perf.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_process.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_protocol.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_rand.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_server.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_sortarray.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_spu.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_string.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_threads.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_timer.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_unpack.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_url.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_version.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_vreg.h create mode 100644 src/VBox/GuestHost/OpenGL/include/cr_warp.h create mode 100644 src/VBox/GuestHost/OpenGL/include/crut_api.h create mode 100644 src/VBox/GuestHost/OpenGL/include/crut_clientapi.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_client.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_current.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_fog.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_hint.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_limits.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_line.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_lists.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_point.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_program.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_texture.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_transform.h create mode 100644 src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h create mode 100644 src/VBox/GuestHost/OpenGL/packer/Makefile.kup create mode 100755 src/VBox/GuestHost/OpenGL/packer/opcodes.py create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_arrays.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_bbox.h create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_beginend.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_bounds.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_buffer.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_bufferobject.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_client.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_clipplane.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_context.c create mode 100755 src/VBox/GuestHost/OpenGL/packer/pack_current.py create mode 100755 src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_currenttypes.py create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_error.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_extensions.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_feedback.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_fence.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_fog.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_framebuffer.c create mode 100755 src/VBox/GuestHost/OpenGL/packer/pack_header.py create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_init.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_lights.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_lists.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_map.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_materials.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_matrices.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_misc.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_pica.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_pixelmap.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_pixels.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_point.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_program.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_shaders.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_stipple.c create mode 100755 src/VBox/GuestHost/OpenGL/packer/pack_swap.py create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_swap_pixelmap.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_texture.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c create mode 100644 src/VBox/GuestHost/OpenGL/packer/packer.h create mode 100755 src/VBox/GuestHost/OpenGL/packer/packer.py create mode 100755 src/VBox/GuestHost/OpenGL/packer/packer_bbox.py create mode 100644 src/VBox/GuestHost/OpenGL/packer/packer_defs.py create mode 100644 src/VBox/GuestHost/OpenGL/packer/packer_extensions.h create mode 100644 src/VBox/GuestHost/OpenGL/packer/packer_special create mode 100644 src/VBox/GuestHost/OpenGL/spu_loader/Makefile.kup create mode 100644 src/VBox/GuestHost/OpenGL/spu_loader/choosevisual.c create mode 100755 src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py create mode 100755 src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py create mode 100755 src/VBox/GuestHost/OpenGL/spu_loader/glloader.py create mode 100644 src/VBox/GuestHost/OpenGL/spu_loader/loader.def create mode 100755 src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py create mode 100755 src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py create mode 100644 src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c create mode 100644 src/VBox/GuestHost/OpenGL/spu_loader/spuload.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/Makefile.kup create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/convert.py create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/get_components.py create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state.h create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_attrib.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_bits_globalop.h create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_client.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_client.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_current.c create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/state_current.py create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_defs.py create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_enable.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_error.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_evaluators.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_get.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_isenabled.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_feedback.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_feedback_special create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_fence.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_flush.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_fog.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_fog.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/state_get.py create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_get.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_getstring.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_hint.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_hint.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_init.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_internals.h create mode 100755 src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_line.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_line.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_lists.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_pixel.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_point.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_point.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_program.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_program.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_rasterpos.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_select_special create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_special create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.txt create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_texdiff.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_teximage.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_transform.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.c create mode 100644 src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.txt create mode 100644 src/VBox/GuestHost/OpenGL/util/Makefile.kup create mode 100644 src/VBox/GuestHost/OpenGL/util/VBoxOGLcrutil.rc create mode 100644 src/VBox/GuestHost/OpenGL/util/bbox.c create mode 100644 src/VBox/GuestHost/OpenGL/util/blitter.cpp create mode 100644 src/VBox/GuestHost/OpenGL/util/bmpscale.cpp create mode 100644 src/VBox/GuestHost/OpenGL/util/bufpool.c create mode 100644 src/VBox/GuestHost/OpenGL/util/calllists.c create mode 100644 src/VBox/GuestHost/OpenGL/util/compositor.cpp create mode 100755 src/VBox/GuestHost/OpenGL/util/debug_opcodes.py create mode 100644 src/VBox/GuestHost/OpenGL/util/devnull.c create mode 100644 src/VBox/GuestHost/OpenGL/util/dll.c create mode 100644 src/VBox/GuestHost/OpenGL/util/endian.c create mode 100644 src/VBox/GuestHost/OpenGL/util/environment.c create mode 100644 src/VBox/GuestHost/OpenGL/util/error.c create mode 100644 src/VBox/GuestHost/OpenGL/util/filenet.c create mode 100644 src/VBox/GuestHost/OpenGL/util/hash.c create mode 100644 src/VBox/GuestHost/OpenGL/util/htable.cpp create mode 100644 src/VBox/GuestHost/OpenGL/util/hull.c create mode 100644 src/VBox/GuestHost/OpenGL/util/idpool.c create mode 100644 src/VBox/GuestHost/OpenGL/util/libteac.c create mode 100644 src/VBox/GuestHost/OpenGL/util/list.c create mode 100644 src/VBox/GuestHost/OpenGL/util/lowercase.py create mode 100644 src/VBox/GuestHost/OpenGL/util/matrix.c create mode 100644 src/VBox/GuestHost/OpenGL/util/mem.c create mode 100644 src/VBox/GuestHost/OpenGL/util/net.c create mode 100644 src/VBox/GuestHost/OpenGL/util/net_internals.h create mode 100644 src/VBox/GuestHost/OpenGL/util/pixel.c create mode 100644 src/VBox/GuestHost/OpenGL/util/process.c create mode 100644 src/VBox/GuestHost/OpenGL/util/rand.c create mode 100644 src/VBox/GuestHost/OpenGL/util/sortarray.cpp create mode 100644 src/VBox/GuestHost/OpenGL/util/string.c create mode 100644 src/VBox/GuestHost/OpenGL/util/tcpip.c create mode 100644 src/VBox/GuestHost/OpenGL/util/threads.c create mode 100644 src/VBox/GuestHost/OpenGL/util/timer.c create mode 100644 src/VBox/GuestHost/OpenGL/util/udptcpip.c create mode 100644 src/VBox/GuestHost/OpenGL/util/url.c create mode 100644 src/VBox/GuestHost/OpenGL/util/util.def create mode 100644 src/VBox/GuestHost/OpenGL/util/util.rc create mode 100644 src/VBox/GuestHost/OpenGL/util/vboxhgcm.c create mode 100644 src/VBox/GuestHost/OpenGL/util/vreg.cpp create mode 100644 src/VBox/GuestHost/OpenGL/util/warp.c (limited to 'src/VBox/GuestHost/OpenGL') diff --git a/src/VBox/GuestHost/OpenGL/.scm-settings b/src/VBox/GuestHost/OpenGL/.scm-settings new file mode 100644 index 00000000..e78fd6fa --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/.scm-settings @@ -0,0 +1,49 @@ +# $Id: .scm-settings $ +## @file +# Source code massager settings for the OpenGL guest/host code. +# + +# +# Copyright (C) 2017-2019 Oracle Corporation +# +# This file is part of VirtualBox Open Source Edition (OSE), as +# available from http://www.virtualbox.org. This file is free software; +# you can redistribute it and/or modify it under the terms of the GNU +# General Public License (GPL) as published by the Free Software +# Foundation, in version 2 as it comes in the "COPYING" file of the +# VirtualBox OSE distribution. VirtualBox OSE is distributed in the +# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +# + +# The basic config here is external copyright, however there are lots of exceptions +/*.h: --external-copyright --no-convert-tabs --no-strip-trailing-blanks --no-fix-header-guards +/include/cr_blitter.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/cr_compositor.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/cr_dump.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/cr_glext.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/cr_htable.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/cr_sortarray.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/cr_vreg.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/state/cr_framebuffer.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/include/state/cr_glsl.h: --no-external-copyright --convert-tabs --strip-trailing-blanks +/state_tracker/state_bits_globalop.h: --no-external-copyright --convert-tabs --strip-trailing-blanks + + +/*.c: --external-copyright --no-convert-tabs --no-strip-trailing-blanks +/packer/pack_framebuffer.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/packer/pack_shaders.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/packer/pack_visibleregion.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/state_tracker/state_framebuffer.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/state_tracker/state_glsl.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/state_tracker/state_snapshot.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/util/error.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/util/vboxhgcm.c: --no-external-copyright --convert-tabs --strip-trailing-blanks +/util/vboxhgsmi.c: --no-external-copyright --convert-tabs --strip-trailing-blanks + +/*.def: --external-copyright +/*.py: --external-copyright --no-convert-tabs --no-strip-trailing-blanks + +--filter-out-files *_special +--filter-out-files /LICENSE +--filter-out-files *.txt + diff --git a/src/VBox/GuestHost/OpenGL/LICENSE b/src/VBox/GuestHost/OpenGL/LICENSE new file mode 100644 index 00000000..d609a358 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/LICENSE @@ -0,0 +1,32 @@ +Copyright (c) 2002, Stanford University +All rights reserved. + +Some portions of Chromium are copyrighted by individual organizations. +Please see the files COPYRIGHT.LLNL and COPYRIGHT.REDHAT for more +information. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Stanford University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/src/VBox/GuestHost/OpenGL/Makefile.kmk b/src/VBox/GuestHost/OpenGL/Makefile.kmk new file mode 100644 index 00000000..87840512 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/Makefile.kmk @@ -0,0 +1,692 @@ +# $Id: Makefile.kmk $ +## @file +# Sub-Makefile for the VirtualBox Guest/Host OpenGL part +# + +# +# Copyright (C) 2008-2019 Oracle Corporation +# +# This file is part of VirtualBox Open Source Edition (OSE), as +# available from http://www.virtualbox.org. This file is free software; +# you can redistribute it and/or modify it under the terms of the GNU +# General Public License (GPL) as published by the Free Software +# Foundation, in version 2 as it comes in the "COPYING" file of the +# VirtualBox OSE distribution. VirtualBox OSE is distributed in the +# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +# + +SUB_DEPTH = ../../../.. +include $(KBUILD_PATH)/subheader.kmk + + +# +# Target lists. +# +BLDDIRS += \ + $(VBOX_PATH_CROGL_GENFILES)/ \ + $(VBOX_PATH_CROGL_GENFILES)/state/ + +ifdef VBOX_WITH_ADDITIONS + ifn1of ($(KBUILD_TARGET), darwin os2) + VBOX_WITH_CROGL_ADDITIONS = 1 + endif +endif + +ifdef VBOX_WITH_CROGL_ADDITIONS + DLLS += VBoxOGLcrutil VBoxOGLerrorspu + LIBRARIES += VBoxOGLcrpacker VBoxOGLspuload VBoxOGLcrstate +endif + +ifndef VBOX_ONLY_ADDITIONS + DLLS += VBoxOGLhostcrutil VBoxOGLhosterrorspu + LIBRARIES += VBoxOGLhostcrpacker VBoxOGLhostspuload VBoxOGLhostcrstate +endif + +# +# VBoxOGLcrutil +# +VBoxOGLcrutil_TEMPLATE = VBOXCROGLR3GUESTDLL +if defined(VBOX_SIGNING_MODE) && defined(VBOX_WITH_WDDM) + VBoxOGLcrutil_INSTTYPE.win = none + VBoxOGLcrutil_DEBUG_INSTTYPE.win = both +endif +VBoxOGLcrutil_SDKS.win = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK) +VBoxOGLcrutil_INTERMEDIATES = $(VBOX_PATH_CROGL_GENFILES)/cr_opcodes.h +VBoxOGLcrutil_INCS += \ + $(VBOX_GRAPHICS_INCS) +if1of ($(KBUILD_TARGET), linux solaris freebsd) + VBoxOGLcrutil_INCS += \ + $(VBOX_GL_INCS) +endif +VBoxOGLcrutil_SOURCES = \ + util/bbox.c \ + util/bufpool.c \ + util/calllists.c \ + util/devnull.c \ + util/dll.c \ + util/endian.c \ + util/environment.c \ + util/error.c \ + util/filenet.c \ + util/hash.c \ + util/hull.c \ + util/list.c \ + util/matrix.c \ + util/mem.c \ + util/net.c \ + util/pixel.c \ + util/process.c \ + util/rand.c \ + util/string.c \ + util/threads.c \ + util/tcpip.c \ + util/udptcpip.c \ + util/timer.c \ + util/url.c \ + util/warp.c \ + util/vreg.cpp \ + util/blitter.cpp \ + util/compositor.cpp \ + util/htable.cpp \ + util/bmpscale.cpp \ + util/vboxhgcm.c \ + $(VBOX_PATH_CROGL_GENFILES)/debug_opcodes.c +VBoxOGLcrutil_SOURCES.win = \ + util/VBoxOGLcrutil.rc +VBoxOGLcrutil_SOURCES.win.x86 = \ + util/util.def +VBoxOGLcrutil_LIBS.win = \ + $(PATH_SDK_$(VBOX_WINDDK)_LIB)/ddraw.lib \ + $(PATH_SDK_$(VBOX_WINDDK)_LIB)/dxguid.lib \ + $(PATH_SDK_$(VBOX_WINDDK)_LIB)/shlwapi.lib +VBoxOGLcrutil_LIBS = \ + $(VBOX_LIB_IPRT_GUEST_R3_SHARED) \ + $(VBOX_LIB_VBGL_R3_SHARED) + +# Needed by GDEbuger +ifdef CR_NO_GL_SYSTEM_PATH +VBoxOGLcrutil_DEFS += CR_NO_GL_SYSTEM_PATH +endif +ifdef VBOX_WITH_CRHGSMI +VBoxOGLcrutil_DEFS.win += VBOX_WITH_CRHGSMI +VBoxOGLcrutil_LIBS.win += \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmKmt$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxCrHgsmi$(VBOX_SUFF_LIB) +endif +ifdef VBOX_WITH_WDDM +VBoxOGLcrutil_DEFS.win += VBOX_WITH_WDDM +VBoxOGLcrutil_DEFS.win += CR_DEBUG_BACKDOOR_ENABLE +VBoxOGLcrutil_INCS.win += $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm +VBoxOGLcrutil_LIBS.win += $(VBOX_PATH_ADDITIONS_LIB)/VBoxDispMpLogger$(VBOX_SUFF_LIB) +endif +VBoxOGLcrutil_CLEAN = \ + $(VBOX_PATH_CROGL_GENFILES)/debug_opcodes.c +if1of ($(KBUILD_TARGET), linux) +VBoxOGLcrutil_LDFLAGS += -Wl,-z,nodelete +endif + +# vc7 hangs during compilation of this file when optimizations are enabled. +#VBoxOGLcrutil_pixel.c_CFLAGS.win.x86 += -Od +#VBoxOGLhostcrutil_pixel.c_CFLAGS.win.x86 += -Od + +if defined(VBOX_WITH_WDDM) && defined(VBOX_WITH_CROGL_ADDITIONS) +# +# VBoxOGLcrutil-x86 - x86 VBoxOGLcrutil version built for amd64 build +# +DLLS.win.amd64 += VBoxOGLcrutil-x86 +VBoxOGLcrutil-x86_TEMPLATE = VBOXCROGLR3GUESTDLL +VBoxOGLcrutil-x86_EXTENDS = VBoxOGLcrutil +VBoxOGLcrutil-x86_BLD_TRG_ARCH = x86 +VBoxOGLcrutil-x86_LIBS = $(VBOX_LIB_IPRT_GUEST_R3_SHARED_X86) \ + $(VBOX_LIB_VBGL_R3_SHARED_X86) +VBoxOGLcrutil-x86_LIBS.win = \ + $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/ddraw.lib \ + $(PATH_SDK_$(VBOX_WINDDK)_LIB.x86)/dxguid.lib +ifdef VBOX_WITH_CRHGSMI +# VBOX_WITH_CRHGSMI define is inherited from VBoxOGLcrutil +VBoxOGLcrutil-x86_LIBS.win += \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxWddmUmKmt-x86$(VBOX_SUFF_LIB) \ + $(VBOX_PATH_ADDITIONS_LIB)/VBoxCrHgsmi-x86$(VBOX_SUFF_LIB) +endif +VBoxOGLcrutil-x86_DEFS = $(VBoxOGLcrutil_DEFS) VBOX_WDDM_WOW64 +ifdef VBOX_WITH_WDDM +# CR_DEBUG_BACKDOOR_ENABLE define is inherited from VBoxOGLcrutil +VBoxOGLcrutil-x86_INCS.win += $(PATH_ROOT)/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm +VBoxOGLcrutil-x86_LIBS.win += $(VBOX_PATH_ADDITIONS_LIB)/VBoxDispMpLogger-x86$(VBOX_SUFF_LIB) +endif +# vc7 hangs during compilation of this file when optimizations are enabled. +#VBoxOGLcrutil-x86_pixel.c_CFLAGS += -Od +#VBoxOGLcrutil-x86_pixel.c_CFLAGS += -Od +endif + +# +# VBoxOGLhostcrutil +# +VBoxOGLhostcrutil_EXTENDS = VBoxOGLcrutil +VBoxOGLhostcrutil_TEMPLATE = VBOXCROGLR3HOSTDLL +if defined(VBOX_SIGNING_MODE) && defined(VBOX_WITH_WDDM) + VBoxOGLhostcrutil_INSTTYPE.win = both +endif +if1of ($(KBUILD_TARGET), linux) +VBoxOGLhostcrutil_LDFLAGS = $(NO_SUCH_VARIABLE) +endif +VBoxOGLhostcrutil_LDFLAGS.darwin = $(VBoxOGLcrutil_LDFLAGS.darwin) \ + -install_name $(VBOX_DYLD_EXECUTABLE_PATH)/VBoxOGLhostcrutil.dylib +VBoxOGLhostcrutil_LIBS.win = \ + $(PATH_SDK_$(VBOX_WINDDK)_LIB)/ddraw.lib \ + $(PATH_SDK_$(VBOX_WINDDK)_LIB)/dxguid.lib +VBoxOGLhostcrutil_LIBS = $(LIB_RUNTIME) +ifdef VBOX_WITH_CRHGSMI +VBoxOGLhostcrutil_DEFS += VBOX_WITH_CRHGSMI +endif +ifdef VBOX_WITH_WDDM +VBoxOGLhostcrutil_INCS.win = $(NO_SUCH_VARIABLE) +VBoxOGLhostcrutil_DEFS.win = $(NO_SUCH_VARIABLE) +endif + +# +# Generate files for VBoxOGLcrutil and VBoxOGLhostcrutil. +# +$(VBOX_PATH_CROGL_GENFILES)/debug_opcodes.c: $(PATH_SUB_CURRENT)/util/debug_opcodes.py $(VBOX_CROGL_API_FILES) | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$<) + $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) + +ifdef VBOX_WITH_CRDUMPER +$(VBOX_PATH_CROGL_GENFILES)/dump_gen.cpp: $(PATH_SUB_CURRENT)/state_tracker/dump_gen.py $(PATH_ROOT)/src/VBox/HostServices/SharedOpenGL/crserverlib/get_sizes.py $(addprefix $(PATH_SUB_CURRENT)/state_tracker/, state_isenabled.txt state_extensions_isenabled.txt) $(VBOX_CROGL_API_FILES) | $$(dir $$@) + $(call MSG_GENERATE,python,$@,$<) + $(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI) $( +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VBOX_RC_FILE_VERSION + PRODUCTVERSION VBOX_RC_FILE_VERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS VBOX_RC_FILE_FLAGS + FILEOS VBOX_RC_FILE_OS + FILETYPE VBOX_RC_TYPE_DLL + FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" // Lang=US English, CharSet=Unicode + BEGIN +#ifdef IN_GUEST + VALUE "FileDescription", "VirtualBox crOpenGL ICD\0" +# ifdef VBOX_WDDM_WOW64 + VALUE "InternalName", "VBoxOGLerrorspu-x86\0" + VALUE "OriginalFilename", "VBoxOGLerrorspu-x86.dll\0" +# else + VALUE "InternalName", "VBoxOGLerrorspu\0" + VALUE "OriginalFilename", "VBoxOGLerrorspu.dll\0" +# endif + VALUE "ProductName", VBOX_RC_PRODUCT_NAME_GA_STR +#else + VALUE "FileDescription", "VirtualBox crOpenGL ICD\0" + VALUE "InternalName", "VBoxOGLhosterrorspu\0" + VALUE "InternalFilename", "VBoxOGLhosterrorspu.dll\0" + VALUE "ProductName", VBOX_RC_PRODUCT_NAME_STR +#endif + + VALUE "CompanyName", VBOX_RC_COMPANY_NAME + VALUE "FileVersion", VBOX_RC_FILE_VERSION_STR + VALUE "LegalCopyright", VBOX_RC_LEGAL_COPYRIGHT + VALUE "ProductVersion", VBOX_RC_PRODUCT_VERSION_STR + VBOX_RC_MORE_STRINGS + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +// XXX is this really required? +#if defined(VBOX_WDDM_WOW64) && defined(IN_GUEST) +1 RCDATA +BEGIN +// Machine dependent parameters + 17, // Height of vertical thumb + 17, // Width of horizontal thumb + 2, // Icon horiz compression factor + 2, // Icon vert compression factor + 1, // Cursor horz compression factor + 1, // Cursor vert compression factor + 0, // Kanji window height + 1, // cxBorder (thickness of vertical lines) + 1 // cyBorder (thickness of horizontal lines) +END +#endif diff --git a/src/VBox/GuestHost/OpenGL/error/error.def b/src/VBox/GuestHost/OpenGL/error/error.def new file mode 100644 index 00000000..9edc7163 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/error/error.def @@ -0,0 +1,6 @@ +; Copyright (c) 2001, Stanford University +; All rights reserved. +; +; See the file LICENSE.txt for information on redistributing this software. +EXPORTS +SPULoad diff --git a/src/VBox/GuestHost/OpenGL/error/error.py b/src/VBox/GuestHost/OpenGL/error/error.py new file mode 100755 index 00000000..7f3da03a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/error/error.py @@ -0,0 +1,49 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + + +from __future__ import print_function +import sys + +import apiutil + +apiutil.CopyrightC() + + +print("""#include +#include "cr_error.h" +#include "cr_spu.h" +#include "state/cr_statetypes.h" + +#if defined(WINDOWS) +#define ERROR_APIENTRY __stdcall +#else +#define ERROR_APIENTRY +#endif + +#define ERROR_UNUSED(x) ((void)x)""") + + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") + +for func_name in keys: + return_type = apiutil.ReturnType(func_name) + params = apiutil.Parameters(func_name) + print('\nstatic %s ERROR_APIENTRY error%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params ))) + print('{') + # Handle the void parameter list + for (name, type, vecSize) in params: + print('\tERROR_UNUSED(%s);' % name) + print('\tcrError("ERROR SPU: Unsupported function gl%s called!");' % func_name) + if return_type != "void": + print('\treturn (%s)0;' % return_type) + print('}') + +print('SPUNamedFunctionTable _cr_error_table[] = {') +for index in range(len(keys)): + func_name = keys[index] + print('\t{ "%s", (SPUGenericFunction) error%s },' % (func_name, func_name )) +print('\t{ NULL, NULL }') +print('};') diff --git a/src/VBox/GuestHost/OpenGL/error/errorspu.rc b/src/VBox/GuestHost/OpenGL/error/errorspu.rc new file mode 100644 index 00000000..390222c2 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/error/errorspu.rc @@ -0,0 +1,69 @@ +/* $Id: errorspu.rc $ */ +/** @file + * VBoxOGLerrorspu - Resource file containing version info and icon. + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VBOX_RC_FILE_VERSION + PRODUCTVERSION VBOX_RC_FILE_VERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS VBOX_RC_FILE_FLAGS + FILEOS VBOX_RC_FILE_OS + FILETYPE VBOX_RC_TYPE_DRV + FILESUBTYPE VFT2_DRV_DISPLAY +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "VirtualBox crOpenGL ICD\0" + VALUE "InternalName", "VBoxOGLerrorspu\0" +#ifdef VBOX_WDDM_WOW64 + VALUE "OriginalFilename", "VBoxOGLerrorspu-x86.dll\0" +#else + VALUE "OriginalFilename", "VBoxOGLerrorspu.dll\0" +#endif + VALUE "CompanyName", VBOX_RC_COMPANY_NAME + VALUE "FileVersion", VBOX_RC_FILE_VERSION_STR + VALUE "LegalCopyright", VBOX_RC_LEGAL_COPYRIGHT + VALUE "ProductName", VBOX_RC_PRODUCT_NAME_GA_STR + VALUE "ProductVersion", VBOX_RC_PRODUCT_VERSION_STR + VBOX_RC_MORE_STRINGS + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +1 RCDATA +BEGIN +// Machine dependent parameters + 17, // Height of vertical thumb + 17, // Width of horizontal thumb + 2, // Icon horiz compression factor + 2, // Icon vert compression factor + 1, // Cursor horz compression factor + 1, // Cursor vert compression factor + 0, // Kanji window height + 1, // cxBorder (thickness of vertical lines) + 1 // cyBorder (thickness of horizontal lines) +END diff --git a/src/VBox/GuestHost/OpenGL/error/errorspu_init.c b/src/VBox/GuestHost/OpenGL/error/errorspu_init.c new file mode 100644 index 00000000..d2b04fdf --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/error/errorspu_init.c @@ -0,0 +1,62 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "cr_spu.h" + +extern SPUNamedFunctionTable _cr_error_table[]; + +static SPUFunctions error_functions = { + NULL, /* CHILD COPY */ + NULL, /* DATA */ + _cr_error_table /* THE ACTUAL FUNCTIONS */ +}; + +static SPUFunctions *errorSPUInit( int id, SPU *child, SPU *self, + unsigned int context_id, + unsigned int num_contexts ) +{ + (void) id; + (void) context_id; + (void) num_contexts; + (void) child; + (void) self; + return &error_functions; +} + +static void errorSPUSelfDispatch(SPUDispatchTable *parent) +{ + (void)parent; +} + +static int errorSPUCleanup(void) +{ + return 1; +} + +static SPUOptions errorSPUOptions[] = { + { NULL, CR_BOOL, 0, NULL, NULL, NULL, NULL, NULL }, +}; + + +int SPULoad( char **name, char **super, SPUInitFuncPtr *init, + SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup, + SPUOptionsPtr *options, int *flags ) +{ +#ifdef IN_GUEST + *name = "error"; +#else + *name = "hosterror"; +#endif + *super = NULL; + *init = errorSPUInit; + *self = errorSPUSelfDispatch; + *cleanup = errorSPUCleanup; + *options = errorSPUOptions; + *flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO); + + return 1; +} diff --git a/src/VBox/GuestHost/OpenGL/glapi_parser/APIspec.txt b/src/VBox/GuestHost/OpenGL/glapi_parser/APIspec.txt new file mode 100644 index 00000000..f5851523 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/glapi_parser/APIspec.txt @@ -0,0 +1,10531 @@ + +# Adapted from Mesa. +# Python scripts read this file and generate various C files. + +# Possible lines: +# name Name of the function (without "gl" prefix). Required. +# +# return Datatype of returned value, or void. Required. +# +# param Zero or more of these lines may be present. Each describes a +# function parameter. Two fields follow: parameter name and the +# parameter type (which may be several tokens like "const GLvoid *"). +# +# vector Used to indicate how may elements are referenced by pointer params. +# Two fields follow: the parameter name (previously defined by a +# 'param' line) and a number indicating how may elements are +# referenced by the vector. If the number is unknown, don't use +# a vector line. Example for glGetClipPlane: +# vector equation 4 +# +# category May be 1.x to indicate that the function belongs to OpenGL +# version 1.x. Or may be the name of an extension such as +# GL_ARB_multitexture. Required. +# +# alias Indicates that this function is just an alias for a previously +# defined function. +# +# vectoralias The function is the vector version of the named function. +# +# props An optional list of properties for this function. Possible +# properties include: +# nolist - the function is not compiled into dlists. +# get - the function is a state-getter (implies nolist). +# setclient - the function sets client-side state (implies nolist). +# useclient - the function uses client-side state. +# pervertex - the function sets per-vertex state (i.e. Normal, +# Color, Material, EdgeFlag). +# render - the function is a rendering command. +# pixelstore - uses glPixelStore settings +# In general, functions without any props are state-setters. +# +# chromium An optional list of properties for Chromium. Possible properties +# include: +# pack - this command can be packed/unpacked. +# extpack - this command can be packed/unpacked, extended opcode. +# expandpack - this command can be packed (i.e. a packer function +# exists), but has no opcode of its own: it is +# expanded into other opcodes when packed. +# nopack - this command is not packed. (XXX not needed) +# stub - don't actually implement, just a stub for now. +# omit - totally omit this function. +# checklist - function may or may not be compiled into display +# lists, depending on parameter values. +# serverdependent - the function sets or queries state whose +# ultimate value is known only by the server; +# queries typically require pack/writeback to +# be correct (although crState simulations may +# suffice), and state-changing functions cannot +# effectively cache the state locally +# +# Chromium packertest properties: +# +# Packertest generates the permuted parameter lists for a GL function. +# A definition in APUutil.txt looks like this: +# +# name ColorMaterial +# return void +# param face GLenum +# paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +# param mode GLenum +# paramprop mode GL_EMISSION GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_AMBIENT_AND_DIFFUSE +# category 1.0 +# chromium pack +# +# paramaction An optional list of action names for the Chromium packertest program. +# specfied by paramaction argument property name +#` Possible property names include +# makeStripeImage - +# enableTex - +# genTex - +# pixelStore - +# +# paramprop An optional list of properties for this function. The properties correspond to +# a list of GLenums for arguments that are of type GLenum +# example: +# param face GLenum +# paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +# param mode GLenum +# paramprop mode GL_EMISSION GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_AMBIENT_AND_DIFFUSE +# After permuting all of the arguments the function we get: +# +# ('GL_FRONT', 'GL_EMISSION') +# ('GL_BACK', 'GL_EMISSION') +# ('GL_FRONT_AND_BACK', 'GL_EMISSION') +# ('GL_FRONT', 'GL_AMBIENT') +# ('GL_BACK', 'GL_AMBIENT') +# ('GL_FRONT_AND_BACK', 'GL_AMBIENT') +# ('GL_FRONT', 'GL_DIFFUSE') +# ('GL_BACK', 'GL_DIFFUSE') +# ('GL_FRONT_AND_BACK', 'GL_DIFFUSE') +# ('GL_FRONT', 'GL_SPECULAR') +# ('GL_BACK', 'GL_SPECULAR') +# ('GL_FRONT_AND_BACK', 'GL_SPECULAR') +# ('GL_FRONT', 'GL_AMBIENT_AND_DIFFUSE') +# ('GL_BACK', 'GL_AMBIENT_AND_DIFFUSE') +# ('GL_FRONT_AND_BACK', 'GL_AMBIENT_AND_DIFFUSE') +# +# paramlist An optional list of properties for a function for non GLenums +# The values are used in the generation of the permuted arguments. +# If paramlist is not used, a single default (specified in packertest.py) +# is used instead. +# +# example: +# param s GLdouble +# paramlist s 0 .5 1 +# +# +# paramset An optional list of properties for arguments of type GLenum. +# +# Used when generating multiple sets of permuted arguments of type GLenum . +# +# paramset [format type] [GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA] [GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT] +# paramset [format type] [GL_RGB] [GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV] +# paramset [format type] [GL_RGBA GL_BGRA] [GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV] +# +# paramvec An optional property used for functions with vector arguments +# The specification is similar to that of paramlist. +# +# example: +# param v const GLbyte * +# paramvec v 2 2 2 +# vector v 3 +# +# + + +# OpenGL 1.0 + +name NewList +return void +param list GLuint +param mode GLenum +paramprop mode GL_COMPILE GL_COMPILE_AND_EXECUTE +category 1.0 +props nolist +chromium extpack + +name EndList +return void +category 1.0 +props nolist +chromium extpack + +name CallList +return void +param list GLuint +category 1.0 +chromium pack +props render + +name CallLists +return void +param n GLsizei +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_2_BYTES GL_3_BYTES GL_4_BYTES +param lists const GLvoid * +category 1.0 +chromium pack +props render + +name DeleteLists +return void +param list GLuint +param range GLsizei +category 1.0 +props nolist +chromium extpack + +name GenLists +return GLuint +param range GLsizei +category 1.0 +props get +chromium extpack serverdependent + +name ListBase +return void +param base GLuint +category 1.0 +chromium extpack + +name Begin +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINES GL_LINE_STRIP GL_LINE_LOOP GL_TRIANGLES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_QUADS GL_QUAD_STRIP GL_POLYGON +category 1.0 +props pervertex render +chromium pack + +name Bitmap +return void +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param xorig GLfloat +paramlist xorig 0.0 +param yorig GLfloat +paramlist yorig 0.0 +param xmove GLfloat +paramlist xmove 0.0 +param ymove GLfloat +paramlist ymove 0.0 +param bitmap const GLubyte * +paramaction bitmap makeStripeImage +category 1.0 +props render pixelstore +chromium pack + +name Color3b +return void +param red GLbyte +param green GLbyte +param blue GLbyte +category 1.0 +props pervertex +chromium pack + +name Color3bv +return void +param v const GLbyte * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3b + +name Color3d +return void +param red GLdouble +param green GLdouble +param blue GLdouble +category 1.0 +props pervertex +chromium pack + +name Color3dv +return void +param v const GLdouble * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3d + +name Color3f +return void +param red GLfloat +param green GLfloat +param blue GLfloat +category 1.0 +props pervertex +chromium pack + +name Color3fv +return void +param v const GLfloat * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3f + +name Color3i +return void +param red GLint +param green GLint +param blue GLint +category 1.0 +props pervertex +chromium pack + +name Color3iv +return void +param v const GLint * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3i + +name Color3s +return void +param red GLshort +param green GLshort +param blue GLshort +category 1.0 +props pervertex +chromium pack + +name Color3sv +return void +param v const GLshort * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3s + +name Color3ub +return void +param red GLubyte +param green GLubyte +param blue GLubyte +category 1.0 +props pervertex +chromium pack + +name Color3ubv +return void +param v const GLubyte * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3ub + +name Color3ui +return void +param red GLuint +param green GLuint +param blue GLuint +category 1.0 +props pervertex +chromium pack + +name Color3uiv +return void +param v const GLuint * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3ui + +name Color3us +return void +param red GLushort +param green GLushort +param blue GLushort +category 1.0 +props pervertex +chromium pack + +name Color3usv +return void +param v const GLushort * +paramvec v 1 2 3 +vector v 3 +category 1.0 +props pervertex +vectoralias Color3us + +name Color4b +return void +param red GLbyte +param green GLbyte +param blue GLbyte +param alpha GLbyte +category 1.0 +props pervertex +chromium pack + +name Color4bv +return void +param v const GLbyte * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4b + +name Color4d +return void +param red GLdouble +param green GLdouble +param blue GLdouble +param alpha GLdouble +category 1.0 +props pervertex +chromium pack + +name Color4dv +return void +param v const GLdouble * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4d + +name Color4f +return void +param red GLfloat +param green GLfloat +param blue GLfloat +param alpha GLfloat +category 1.0 +props pervertex +chromium pack + +name Color4fv +return void +param v const GLfloat * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4f + +name Color4i +return void +param red GLint +param green GLint +param blue GLint +param alpha GLint +category 1.0 +props pervertex +chromium pack + +name Color4iv +return void +param v const GLint * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4i + +name Color4s +return void +param red GLshort +param green GLshort +param blue GLshort +param alpha GLshort +category 1.0 +props pervertex +chromium pack + +name Color4sv +return void +param v const GLshort * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4s + +name Color4ub +return void +param red GLubyte +param green GLubyte +param blue GLubyte +param alpha GLubyte +category 1.0 +props pervertex +chromium pack + +name Color4ubv +return void +param v const GLubyte * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4ub + +name Color4ui +return void +param red GLuint +param green GLuint +param blue GLuint +param alpha GLuint +category 1.0 +props pervertex +chromium pack + +name Color4uiv +return void +param v const GLuint * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4ui + +name Color4us +return void +param red GLushort +param green GLushort +param blue GLushort +param alpha GLushort +category 1.0 +props pervertex +chromium pack + +name Color4usv +return void +param v const GLushort * +paramvec v 1 2 3 4 +vector v 4 +category 1.0 +props pervertex +vectoralias Color4us + +name EdgeFlag +return void +param flag GLboolean +category 1.0 +props pervertex +chromium pack + +name EdgeFlagv +return void +param flag const GLboolean * +paramvec flag GL_TRUE +vector flag 1 +category 1.0 +props pervertex +vectoralias EdgeFlag + +name End +return void +category 1.0 +props pervertex render +chromium pack + +name Indexd +return void +param c GLdouble +category 1.0 +props pervertex +chromium pack + +name Indexdv +return void +param c const GLdouble * +paramvec c 1.0 +vector c 1 +category 1.0 +props pervertex +vectoralias Indexd + +name Indexf +return void +param c GLfloat +category 1.0 +props pervertex +chromium pack + +name Indexfv +return void +param c const GLfloat * +paramvec c 1.0 +vector c 1 +category 1.0 +props pervertex +vectoralias Indexf + +name Indexi +return void +param c GLint +category 1.0 +props pervertex +chromium pack + +name Indexiv +return void +param c const GLint * +paramvec c 1 +vector c 1 +category 1.0 +props pervertex +vectoralias Indexi + +name Indexs +return void +param c GLshort +category 1.0 +props pervertex +chromium pack + +name Indexsv +return void +param c const GLshort * +paramvec c 1 +vector c 1 +category 1.0 +props pervertex +vectoralias Indexs + +name Normal3b +return void +param nx GLbyte +param ny GLbyte +param nz GLbyte +category 1.0 +props pervertex +chromium pack + +name Normal3bv +return void +param v const GLbyte * +paramvec v 1 1 1 +vector v 3 +category 1.0 +props pervertex +vectoralias Normal3b + +name Normal3d +return void +param nx GLdouble +param ny GLdouble +param nz GLdouble +category 1.0 +props pervertex +chromium pack + +name Normal3dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +props pervertex +vectoralias Normal3d + +name Normal3f +return void +param nx GLfloat +param ny GLfloat +param nz GLfloat +category 1.0 +props pervertex +chromium pack + +name Normal3fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +props pervertex +vectoralias Normal3f + +name Normal3i +return void +param nx GLint +param ny GLint +param nz GLint +category 1.0 +props pervertex +chromium pack + +name Normal3iv +return void +param v const GLint * +paramvec v 1 1 1 +vector v 3 +category 1.0 +props pervertex +vectoralias Normal3i + +name Normal3s +return void +param nx GLshort +param ny GLshort +param nz GLshort +category 1.0 +props pervertex +chromium pack + +name Normal3sv +return void +param v const GLshort * +paramvec v 1 1 1 +vector v 3 +category 1.0 +props pervertex +vectoralias Normal3s + +name RasterPos2d +return void +param x GLdouble +param y GLdouble +category 1.0 +chromium pack + +name RasterPos2dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 +vector v 2 +category 1.0 +vectoralias RasterPos2d + +name RasterPos2f +return void +param x GLfloat +param y GLfloat +category 1.0 +chromium pack + +name RasterPos2fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 +vector v 2 +category 1.0 +vectoralias RasterPos2f + +name RasterPos2i +return void +param x GLint +param y GLint +category 1.0 +chromium pack + +name RasterPos2iv +return void +param v const GLint * +paramvec v 1 1 +vector v 2 +category 1.0 +vectoralias RasterPos2i + +name RasterPos2s +return void +param x GLshort +param y GLshort +category 1.0 +chromium pack + +name RasterPos2sv +return void +param v const GLshort * +paramvec v 1 1 +vector v 2 +category 1.0 +vectoralias RasterPos2s + +name RasterPos3d +return void +param x GLdouble +param y GLdouble +param z GLdouble +category 1.0 +chromium pack + +name RasterPos3dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +vectoralias RasterPos3d + +name RasterPos3f +return void +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 +chromium pack + +name RasterPos3fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +vectoralias RasterPos3f + +name RasterPos3i +return void +param x GLint +param y GLint +param z GLint +category 1.0 +chromium pack + +name RasterPos3iv +return void +param v const GLint * +paramvec v 1 1 1 +vector v 3 +category 1.0 +vectoralias RasterPos3i + +name RasterPos3s +return void +param x GLshort +param y GLshort +param z GLshort +category 1.0 +chromium pack + +name RasterPos3sv +return void +param v const GLshort * +paramvec v 1 1 1 +vector v 3 +category 1.0 +vectoralias RasterPos3s + +name RasterPos4d +return void +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category 1.0 +chromium pack + +name RasterPos4dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category 1.0 +vectoralias RasterPos4d + +name RasterPos4f +return void +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category 1.0 +chromium pack + +name RasterPos4fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category 1.0 +vectoralias RasterPos4f + +name RasterPos4i +return void +param x GLint +param y GLint +param z GLint +param w GLint +category 1.0 +chromium pack + +name RasterPos4iv +return void +param v const GLint * +paramvec v 1 1 1 1 +vector v 4 +category 1.0 +vectoralias RasterPos4i + +name RasterPos4s +return void +param x GLshort +param y GLshort +param z GLshort +param w GLshort +category 1.0 +chromium pack + +name RasterPos4sv +return void +param v const GLshort * +paramvec v 1 1 1 1 +vector v 4 +category 1.0 +vectoralias RasterPos4s + +name Rectd +return void +param x1 GLdouble +param y1 GLdouble +param x2 GLdouble +param y2 GLdouble +category 1.0 +props render +chromium pack + +name Rectdv +return void +param v1 const GLdouble * +paramvec v1 1.0 1.0 +param v2 const GLdouble * +paramvec v2 1.0 1.0 +vector v1 2 +vector v2 2 +category 1.0 +props render +vectoralias Rectd + +name Rectf +return void +param x1 GLfloat +param y1 GLfloat +param x2 GLfloat +param y2 GLfloat +category 1.0 +props render +chromium pack + +name Rectfv +return void +param v1 const GLfloat * +paramvec v1 1.0 1.0 +param v2 const GLfloat * +paramvec v2 1.0 1.0 +vector v1 2 +vector v2 2 +category 1.0 +props render +vectoralias Rectf + +name Recti +return void +param x1 GLint +param y1 GLint +param x2 GLint +param y2 GLint +category 1.0 +props render +chromium pack + +name Rectiv +return void +param v1 const GLint * +paramvec v1 1 1 +param v2 const GLint * +paramvec v2 1 1 +vector v1 2 +vector v2 2 +category 1.0 +props render +vectoralias Recti + +name Rects +return void +param x1 GLshort +param y1 GLshort +param x2 GLshort +param y2 GLshort +category 1.0 +props render +chromium pack + +name Rectsv +return void +param v1 const GLshort * +paramvec v1 1 1 +param v2 const GLshort * +paramvec v2 1 1 +vector v1 2 +vector v2 2 +category 1.0 +props render +vectoralias Rects + +name TexCoord1d +return void +param s GLdouble +category 1.0 +props pervertex +chromium pack + +name TexCoord1dv +return void +param v const GLdouble * +paramvec v 1.0 +vector v 1 +category 1.0 +props pervertex +vectoralias TexCoord1d + +name TexCoord1f +return void +param s GLfloat +category 1.0 +props pervertex +chromium pack + +name TexCoord1fv +return void +param v const GLfloat * +paramvec v 1.0 +vector v 1 +category 1.0 +props pervertex +vectoralias TexCoord1f + +name TexCoord1i +return void +param s GLint +category 1.0 +props pervertex +chromium pack + +name TexCoord1iv +return void +param v const GLint * +paramvec v 1 +vector v 1 +category 1.0 +props pervertex +vectoralias TexCoord1i + +name TexCoord1s +return void +param s GLshort +category 1.0 +props pervertex +chromium pack + +name TexCoord1sv +return void +param v const GLshort * +paramvec v 1 +vector v 1 +category 1.0 +props pervertex +vectoralias TexCoord1s + +name TexCoord2d +return void +param s GLdouble +param t GLdouble +category 1.0 +props pervertex +chromium pack + +name TexCoord2dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 +vector v 2 +category 1.0 +props pervertex +vectoralias TexCoord2d + +name TexCoord2f +return void +param s GLfloat +param t GLfloat +category 1.0 +props pervertex +chromium pack + +name TexCoord2fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 +vector v 2 +category 1.0 +props pervertex +vectoralias TexCoord2f + +name TexCoord2i +return void +param s GLint +param t GLint +category 1.0 +props pervertex +chromium pack + +name TexCoord2iv +return void +param v const GLint * +paramvec v 1 1 +vector v 2 +category 1.0 +props pervertex +vectoralias TexCoord2i + +name TexCoord2s +return void +param s GLshort +param t GLshort +category 1.0 +props pervertex +chromium pack + +name TexCoord2sv +return void +param v const GLshort * +paramvec v 1 1 +vector v 2 +category 1.0 +props pervertex +vectoralias TexCoord2s + +name TexCoord3d +return void +param s GLdouble +param t GLdouble +param r GLdouble +category 1.0 +props pervertex +chromium pack + +name TexCoord3dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +props pervertex +vectoralias TexCoord3d + +name TexCoord3f +return void +param s GLfloat +param t GLfloat +param r GLfloat +category 1.0 +props pervertex +chromium pack + +name TexCoord3fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +props pervertex +vectoralias TexCoord3f + +name TexCoord3i +return void +param s GLint +param t GLint +param r GLint +category 1.0 +props pervertex +chromium pack + +name TexCoord3iv +return void +param v const GLint * +paramvec v 1 1 1 +vector v 3 +category 1.0 +props pervertex +vectoralias TexCoord3i + +name TexCoord3s +return void +param s GLshort +param t GLshort +param r GLshort +category 1.0 +props pervertex +chromium pack + +name TexCoord3sv +return void +param v const GLshort * +paramvec v 1 1 1 +vector v 3 +category 1.0 +props pervertex +vectoralias TexCoord3s + +name TexCoord4d +return void +param s GLdouble +param t GLdouble +param r GLdouble +param q GLdouble +category 1.0 +props pervertex +chromium pack + +name TexCoord4dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category 1.0 +props pervertex +vectoralias TexCoord4d + +name TexCoord4f +return void +param s GLfloat +param t GLfloat +param r GLfloat +param q GLfloat +category 1.0 +props pervertex +chromium pack + +name TexCoord4fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category 1.0 +props pervertex +vectoralias TexCoord4f + +name TexCoord4i +return void +param s GLint +param t GLint +param r GLint +param q GLint +category 1.0 +props pervertex +chromium pack + +name TexCoord4iv +return void +param v const GLint * +paramvec v 1 1 1 1 +vector v 4 +category 1.0 +props pervertex +vectoralias TexCoord4i + +name TexCoord4s +return void +param s GLshort +param t GLshort +param r GLshort +param q GLshort +category 1.0 +props pervertex +chromium pack + +name TexCoord4sv +return void +param v const GLshort * +paramvec v 1 1 1 1 +vector v 4 +category 1.0 +props pervertex +vectoralias TexCoord4s + +name Vertex2d +return void +param x GLdouble +param y GLdouble +category 1.0 +props pervertex +chromium pack + +name Vertex2dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 +vector v 2 +category 1.0 +props pervertex +vectoralias Vertex2d + +name Vertex2f +return void +param x GLfloat +param y GLfloat +category 1.0 +props pervertex +chromium pack + +name Vertex2fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 +vector v 2 +category 1.0 +props pervertex +vectoralias Vertex2f + +name Vertex2i +return void +param x GLint +param y GLint +category 1.0 +props pervertex +chromium pack + +name Vertex2iv +return void +param v const GLint * +paramvec v 1 1 +vector v 2 +category 1.0 +props pervertex +vectoralias Vertex2i + +name Vertex2s +return void +param x GLshort +param y GLshort +category 1.0 +props pervertex +chromium pack + +name Vertex2sv +return void +param v const GLshort * +paramvec v 1 1 +vector v 2 +category 1.0 +props pervertex +vectoralias Vertex2s + +name Vertex3d +return void +param x GLdouble +param y GLdouble +param z GLdouble +category 1.0 +props pervertex +chromium pack + +name Vertex3dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +props pervertex +vectoralias Vertex3d + +name Vertex3f +return void +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 +props pervertex +chromium pack + +name Vertex3fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.0 +props pervertex +vectoralias Vertex3f + +name Vertex3i +return void +param x GLint +param y GLint +param z GLint +category 1.0 +props pervertex +chromium pack + +name Vertex3iv +return void +param v const GLint * +paramvec v 1 1 1 +vector v 3 +category 1.0 +props pervertex +vectoralias Vertex3i + +name Vertex3s +return void +param x GLshort +param y GLshort +param z GLshort +category 1.0 +props pervertex +chromium pack + +name Vertex3sv +return void +param v const GLshort * +paramvec v 1 1 1 +vector v 3 +category 1.0 +props pervertex +vectoralias Vertex3s + +name Vertex4d +return void +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category 1.0 +props pervertex +chromium pack + +name Vertex4dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category 1.0 +props pervertex +vectoralias Vertex4d + +name Vertex4f +return void +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category 1.0 +props pervertex +chromium pack + +name Vertex4fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category 1.0 +props pervertex +vectoralias Vertex4f + +name Vertex4i +return void +param x GLint +param y GLint +param z GLint +param w GLint +category 1.0 +props pervertex +chromium pack + +name Vertex4iv +return void +param v const GLint * +paramvec v 1 1 1 1 +vector v 4 +category 1.0 +props pervertex +vectoralias Vertex4i + +name Vertex4s +return void +param x GLshort +param y GLshort +param z GLshort +param w GLshort +category 1.0 +props pervertex +chromium pack + +name Vertex4sv +return void +param v const GLshort * +paramvec v 1 1 1 1 +vector v 4 +category 1.0 +props pervertex +vectoralias Vertex4s + +name ClipPlane +return void +param plane GLenum +paramprop plane GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +param equation const GLdouble * +paramvec equation 0.0 0.0 0.0 0.0 +vector equation 4 +category 1.0 +chromium pack + +name ColorMaterial +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param mode GLenum +paramprop mode GL_EMISSION GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_AMBIENT_AND_DIFFUSE +category 1.0 +chromium pack + +name CullFace +return void +param mode GLenum +paramprop mode GL_FRONT GL_BACK GL_FRONT_AND_BACK +category 1.0 +chromium pack + +# +# Can't test for GL_EYE_RADIAL_NV GL_EYE_PLANE GL_EYE_PLANE_ABSOLUTE_NV - NV_fog_distance +# Can't test for GL_FOG_COORDINATE_EXT GL_FRAGMENT_DEPTH_EXT - EXT_fog_coord +name Fogf +return void +param pname GLenum +param param GLfloat +paramset [ pname param ] [ GL_FOG_DISTANCE_MODE_NV ] [ GL_EYE_RADIAL_NV GL_EYE_PLANE GL_EYE_PLANE_ABSOLUTE_NV ] +paramset [ pname param ] [ GL_FOG_DENSITY GL_FOG_START GL_FOG_END GL_FOG_INDEX ] [ 1 ] +category 1.0 +chromium pack + +# Can't test for GL_EYE_RADIAL_NV GL_EYE_PLANE GL_EYE_PLANE_ABSOLUTE_NV - NV_fog_distance +# Can't test for GL_FOG_COORDINATE_EXT GL_FRAGMENT_DEPTH_EXT - EXT_fog_coord +# +name Fogfv +return void +param pname GLenum +paramprop pname GL_FOG_MODE GL_FOG_DENSITY GL_FOG_START GL_FOG_END GL_FOG_INDEX GL_FOG_COLOR +param params const GLfloat * +paramvec params GL_LINEAR +category 1.0 +chromium pack + +# Can't test for GL_EYE_RADIAL_NV GL_EYE_PLANE GL_EYE_PLANE_ABSOLUTE_NV - NV_fog_distance +# Can't test for GL_FOG_COORDINATE_EXT GL_FRAGMENT_DEPTH_EXT - EXT_fog_coord +name Fogi +return void +param pname GLenum +param param GLint +paramset [ pname param ] [ GL_FOG_DISTANCE_MODE_NV ] [ GL_EYE_RADIAL_NV GL_EYE_PLANE GL_EYE_PLANE_ABSOLUTE_NV ] +paramset [ pname param ] [ GL_FOG_DENSITY GL_FOG_START GL_FOG_END GL_FOG_INDEX ] [ 1 ] +category 1.0 +chromium pack + +# Can't test for GL_EYE_RADIAL_NV GL_EYE_PLANE GL_EYE_PLANE_ABSOLUTE_NV - NV_fog_distance +# Can't test for GL_FOG_COORDINATE_EXT GL_FRAGMENT_DEPTH_EXT - EXT_fog_coord +name Fogiv +return void +param pname GLenum +paramprop pname GL_FOG_MODE GL_FOG_DENSITY GL_FOG_START GL_FOG_END GL_FOG_INDEX GL_FOG_COLOR +param params const GLint * +paramvec params GL_LINEAR +category 1.0 +chromium pack + +name FrontFace +return void +param mode GLenum +paramprop mode GL_CW GL_CCW +category 1.0 +chromium pack + +name Hint +return void +param target GLenum +paramprop target GL_FOG_HINT GL_LINE_SMOOTH_HINT GL_PERSPECTIVE_CORRECTION_HINT GL_POINT_SMOOTH_HINT GL_POLYGON_SMOOTH_HINT GL_TEXTURE_COMPRESSION_HINT_ARB GL_CLIP_VOLUME_CLIPPING_HINT_EXT GL_GENERATE_MIPMAP_HINT_SGIS +param mode GLenum +paramprop mode GL_FASTEST GL_NICEST GL_DONT_CARE +category 1.0 +chromium extpack + +name Lightf +return void +param light GLenum +paramprop light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +paramprop pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param param GLfloat +paramlist param 0.0 +category 1.0 +chromium pack + +name Lightfv +return void +param light GLenum +paramprop light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION GL_SPOT_CUTOFF GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param params const GLfloat * +paramvec params 0.0 1.0 1.0 0.0 +category 1.0 +chromium pack + +name Lighti +return void +param light GLenum +paramprop light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +paramprop pname GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param param GLint +paramlist param 0.0 +category 1.0 +chromium pack + +name Lightiv +return void +param light GLenum +paramprop light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION GL_SPOT_CUTOFF GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param params const GLint * +paramvec params 0 1 1 0 +category 1.0 +chromium pack + +name LightModelf +return void +param pname GLenum +param param GLfloat +paramset [ pname param ] [ GL_LIGHT_MODEL_COLOR_CONTROL_EXT ] [ GL_SINGLE_COLOR_EXT GL_SEPARATE_SPECULAR_COLOR_EXT ] +paramset [ pname param ] [ GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_TWO_SIDE ] [ 1.0 ] +category 1.0 +chromium pack + +name LightModelfv +return void +param pname GLenum +paramprop pname GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_TWO_SIDE +param params const GLfloat * +category 1.0 +paramvec params 0.0 1.0 1.0 0.0 +chromium pack + +name LightModeli +return void +param pname GLenum +param param GLint +paramset [ pname param ] [ GL_LIGHT_MODEL_COLOR_CONTROL_EXT ] [ GL_SINGLE_COLOR_EXT GL_SEPARATE_SPECULAR_COLOR_EXT ] +paramset [ pname param ] [ GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_TWO_SIDE ] [ 1.0 ] +category 1.0 +chromium pack + +name LightModeliv +return void +param pname GLenum +paramprop pname GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_TWO_SIDE +param params const GLint * +paramvec params 0 1 1 0 +category 1.0 +chromium pack + +name LineStipple +return void +param factor GLint +param pattern GLushort +category 1.0 +chromium pack + +name LineWidth +return void +param width GLfloat +category 1.0 +chromium pack + +name Materialf +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param pname GLenum +paramprop pname GL_SHININESS +param param GLfloat +paramlist param 1.0 +props pervertex +category 1.0 +chromium pack + +name Materialfv +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_EMISSION GL_SHININESS GL_AMBIENT_AND_DIFFUSE GL_COLOR_INDEXES +param params const GLfloat * +paramvec params 0.8 0.8 0.5 0.1 +props pervertex +category 1.0 +chromium pack + +name Materiali +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param pname GLenum +paramprop pname GL_SHININESS +param param GLint +paramlist param 1 +props pervertex +category 1.0 +chromium pack + +name Materialiv +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_EMISSION GL_SHININESS GL_AMBIENT_AND_DIFFUSE GL_COLOR_INDEXES +param params const GLint * +paramvec params 1 0 1 0 +props pervertex +category 1.0 +chromium pack + +name PointSize +return void +param size GLfloat +category 1.0 +chromium pack + +name PolygonMode +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param mode GLenum +paramprop mode GL_POINT GL_LINE GL_FILL +category 1.0 +chromium pack + +name PolygonStipple +return void +param mask const GLubyte * +vector mask 128 +category 1.0 +chromium pack + +name Scissor +return void +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category 1.0 +chromium pack + +name ShadeModel +return void +param mode GLenum +paramprop mode GL_FLAT GL_SMOOTH +category 1.0 +chromium pack + +name TexParameterf +return void +param target GLenum +param pname GLenum +param param GLfloat +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_MIN_FILTER ] [ GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_MAG_FILTER ] [ GL_NEAREST GL_LINEAR ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_COMPARE_MODE_ARB ] [ GL_COMPARE_R_TO_TEXTURE_ARB ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R ] [ GL_CLAMP GL_CLAMP_TO_EDGE GL_REPEAT GL_CLAMP_TO_BORDER_ARB GL_MIRRORED_REPEAT_ARB ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_GENERATE_MIPMAP_SGIS ] [ GL_TRUE GL_FALSE ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_DEPTH_TEXTURE_MODE_ARB ] [ GL_ALPHA GL_LUMINANCE GL_INTENSITY ] +category 1.0 +chromium nopack + +# +# certain cases for texture_border_clamp_ARB have been left out +# +name TexParameterfv +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D +param pname GLenum +paramprop pname GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_LOD GL_TEXTURE_MAX_LOD GL_TEXTURE_BASE_LEVEL GL_TEXTURE_MAX_LEVEL GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R GL_TEXTURE_PRIORITY GL_TEXTURE_COMPARE_FUNC_ARB GL_TEXTURE_COMPARE_MODE_ARB +param params const GLfloat * +category 1.0 +chromium pack +vectoralias TexParameterf + +name TexParameteri +return void +param target GLenum +param pname GLenum +param param GLint +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_MIN_FILTER ] [ GL_NEAREST GL_LINEAR GL_NEAREST_MIPMAP_NEAREST GL_LINEAR_MIPMAP_NEAREST GL_NEAREST_MIPMAP_LINEAR GL_LINEAR_MIPMAP_LINEAR ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_MAG_FILTER ] [ GL_NEAREST GL_LINEAR ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_COMPARE_MODE_ARB ] [ GL_COMPARE_R_TO_TEXTURE_ARB ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R ] [ GL_CLAMP GL_CLAMP_TO_EDGE GL_REPEAT GL_CLAMP_TO_BORDER_ARB GL_MIRRORED_REPEAT_ARB ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_GENERATE_MIPMAP_SGIS ] [ GL_TRUE GL_FALSE ] +paramset [ target pname param ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_DEPTH_TEXTURE_MODE_ARB ] [ GL_ALPHA GL_LUMINANCE GL_INTENSITY ] +category 1.0 +chromium nopack + +# +# certain cases for texture_border_clamp_ARB have been left out +# +name TexParameteriv +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D +param pname GLenum +paramprop pname GL_TEXTURE_MIN_FILTER GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_LOD GL_TEXTURE_MAX_LOD GL_TEXTURE_BASE_LEVEL GL_TEXTURE_MAX_LEVEL GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R GL_TEXTURE_PRIORITY GL_TEXTURE_COMPARE_FUNC_ARB GL_TEXTURE_COMPARE_MODE_ARB +param params const GLint * +category 1.0 +chromium pack +vectoralias TexParameteri + +# internalFormat is an int but has many options +name TexImage1D +return void +param target GLenum +param level GLint +paramlist level 0 +param internalFormat GLint +paramlist internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_RGB GL_R3_G3_B2 GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_COMPRESSED_ALPHA_ARB GL_COMPRESSED_LUMINANCE_ARB GL_COMPRESSED_LUMINANCE_ALPHA_ARB GL_COMPRESSED_INTENSITY_ARB GL_COMPRESSED_RGB_ARB GL_COMPRESSED_RGBA_ARB RGBA32F_ARB RGB32F_ARB ALPHA32F_ARB INTENSITY32F_ARB LUMINANCE32F_ARB LUMINANCE_ALPHA32F_ARB RGBA16F_ARB RGB16F_ARB ALPHA16F_ARB INTENSITY16F_ARB LUMINANCE16F_ARB LUMINANCE_ALPHA16F_ARB +param width GLsizei +paramlist width 2 +param border GLint +paramlist border 0 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_STENCIL_INDEX GL_COLOR_INDEX ] [ GL_BITMAP GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGB GL_BGR ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +paramaction pixels makeStripeImage +category 1.0 +props pixelstore +chromium pack checklist + + +# paramset [ target format type ] [ GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_NV ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +# paramset [ target format type ] [ GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_NV ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +# paramset [ target format type ] [ GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_NV ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] + +name TexImage2D +return void +param target GLenum +param level GLint +paramlist level 0 +param internalFormat GLint +paramlist internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_COMPRESSED_ALPHA_ARB GL_COMPRESSED_LUMINANCE_ARB GL_COMPRESSED_LUMINANCE_ALPHA_ARB GL_COMPRESSED_INTENSITY_ARB GL_COMPRESSED_RGB_ARB GL_COMPRESSED_RGBA_ARB RGBA32F_ARB RGB32F_ARB ALPHA32F_ARB INTENSITY32F_ARB LUMINANCE32F_ARB LUMINANCE_ALPHA32F_ARB RGBA16F_ARB RGB16F_ARB ALPHA16F_ARB INTENSITY16F_ARB LUMINANCE16F_ARB LUMINANCE_ALPHA16F_ARB +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param border GLint +paramlist border 0 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_2D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_2D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_2D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +paramaction pixels makeStripeImage +category 1.0 +props pixelstore +chromium pack checklist + +# another special case + +name TexEnvf +return void +param target GLenum +param pname GLenum +paramset [ target pname ] [ GL_TEXTURE_ENV ] [ GL_TEXTURE_ENV_MODE ] +paramset [ target pname ] [ GL_POINT_SPRITE_ARB ] [ GL_COORD_REPLACE_ARB ] +paramset [ target pname ] [ GL_COMBINE_RGB_EXT ] [ GL_DOT3_RGB_EXT GL_DOT3_RGBA_EXT ] +paramset [ target pname ] [ GL_TEXTURE_FILTER_CONTROL_EXT ] [ GL_TEXTURE_LOD_BIAS_EXT ] +param param GLfloat +paramlist param GL_MODULATE GL_DECAL GL_BLEND GL_REPLACE GL_ADD +category 1.0 +chromium nopack + +name TexEnvfv +return void +param target GLenum +param pname GLenum +paramset [ target pname ] [ GL_TEXTURE_ENV ] [ GL_TEXTURE_ENV_MODE ] +paramset [ target pname ] [ GL_POINT_SPRITE_ARB ] [ GL_COORD_REPLACE_ARB ] +paramset [ target pname ] [ GL_COMBINE_RGB_EXT ] [ GL_DOT3_RGB_EXT GL_DOT3_RGBA_EXT ] +paramset [ target pname ] [ GL_TEXTURE_FILTER_CONTROL_EXT ] [ GL_TEXTURE_LOD_BIAS_EXT ] +param params const GLfloat * +paramvec params 0.0 0.0 0.0 0.0 +category 1.0 +chromium pack +vectoralias TexEnvf + +# another special case + +name TexEnvi +return void +param target GLenum +param pname GLenum +paramset [ target pname ] [ GL_TEXTURE_ENV ] [ GL_TEXTURE_ENV_MODE ] +paramset [ target pname ] [ GL_POINT_SPRITE_ARB ] [ GL_COORD_REPLACE_ARB ] +paramset [ target pname ] [ GL_COMBINE_RGB_EXT ] [ GL_DOT3_RGB_EXT GL_DOT3_RGBA_EXT ] +paramset [ target pname ] [ GL_TEXTURE_FILTER_CONTROL_EXT ] [ GL_TEXTURE_LOD_BIAS_EXT ] +param param GLint +paramlist param GL_MODULATE GL_DECAL GL_BLEND GL_REPLACE GL_ADD +category 1.0 +chromium nopack + +name TexEnviv +return void +param target GLenum +param pname GLenum +paramset [ target pname ] [ GL_TEXTURE_ENV ] [ GL_TEXTURE_ENV_MODE ] +paramset [ target pname ] [ GL_POINT_SPRITE_ARB ] [ GL_COORD_REPLACE_ARB ] +paramset [ target pname ] [ GL_COMBINE_RGB_EXT ] [ GL_DOT3_RGB_EXT GL_DOT3_RGBA_EXT ] +paramset [ target pname ] [ GL_TEXTURE_FILTER_CONTROL_EXT ] [ GL_TEXTURE_LOD_BIAS_EXT ] +param params const GLint * +paramvec params 0 0 0 0 +category 1.0 +chromium pack +vectoralias TexEnvi + +name TexGend +return void +param coord GLenum +param pname GLenum +param param GLdouble +paramset [ coord pname param ] [ GL_S GL_T ] [ GL_TEXTURE_GEN_MODE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP GL_NORMAL_MAP_NV GL_REFLECTION_MAP_NV ] +paramset [ coord pname param ] [ GL_Q GL_R ] [ GL_TEXTURE_GEN_MODE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_NORMAL_MAP_NV GL_REFLECTION_MAP_NV ] +category 1.0 +chromium nopack + +name TexGendv +return void +param coord GLenum +param pname GLenum +paramset [ coord pname params ] [ GL_S GL_T ] [ GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP ] +paramset [ coord pname params ] [ GL_Q GL_R ] [ GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR ] +param params const GLdouble * +category 1.0 +chromium pack +vectoralias TexGend + +name TexGenf +return void +param coord GLenum +param pname GLenum +param param GLfloat +paramset [ coord pname param ] [ GL_S GL_T ] [ GL_TEXTURE_GEN_MODE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP GL_NORMAL_MAP_NV GL_REFLECTION_MAP_NV ] +paramset [ coord pname param ] [ GL_Q GL_R ] [ GL_TEXTURE_GEN_MODE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_NORMAL_MAP_NV GL_REFLECTION_MAP_NV ] +category 1.0 +chromium nopack + +name TexGenfv +return void +param coord GLenum +param pname GLenum +param params const GLfloat * +paramset [ coord pname params ] [ GL_S GL_T ] [ GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP ] +paramset [ coord pname params ] [ GL_Q GL_R ] [ GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR ] +category 1.0 +chromium pack +vectoralias TexGenf + +name TexGeni +return void +param coord GLenum +param pname GLenum +param param GLint +paramset [ coord pname param ] [ GL_S GL_T ] [ GL_TEXTURE_GEN_MODE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP GL_NORMAL_MAP_NV GL_REFLECTION_MAP_NV ] +paramset [ coord pname param ] [ GL_Q GL_R ] [ GL_TEXTURE_GEN_MODE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_NORMAL_MAP_NV GL_REFLECTION_MAP_NV ] +category 1.0 +chromium nopack + +name TexGeniv +return void +param coord GLenum +param pname GLenum +param params const GLint * +paramset [ coord pname params ] [ GL_S GL_T ] [ GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR GL_SPHERE_MAP ] +paramset [ coord pname params ] [ GL_Q GL_R ] [ GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE ] [ GL_OBJECT_LINEAR GL_EYE_LINEAR ] +category 1.0 +chromium pack +vectoralias TexGeni + +name FeedbackBuffer +return void +param size GLsizei +param type GLenum +paramprop type GL_2D GL_3D GL_3D_COLOR GL_3D_COLOR_TEXTURE GL_4D_COLOR_TEXTURE +param buffer GLfloat * +category 1.0 +props nolist +chromium pack + +name SelectBuffer +return void +param size GLsizei +param buffer GLuint * +category 1.0 +props nolist +chromium pack + +name RenderMode +return GLint +param mode GLenum +paramprop mode GL_RENDER GL_SELECT GL_FEEDBACK +category 1.0 +props nolist get +chromium extpack + +name InitNames +return void +category 1.0 +chromium pack + +name LoadName +return void +param name GLuint +category 1.0 +chromium pack + +name PassThrough +return void +param token GLfloat +category 1.0 +chromium pack + +name PopName +return void +category 1.0 +chromium pack + +name PushName +return void +param name GLuint +category 1.0 +chromium pack + +name DrawBuffer +return void +param mode GLenum +paramprop mode GL_NONE GL_FRONT_LEFT GL_FRONT_RIGHT GL_BACK_LEFT GL_BACK_RIGHT GL_FRONT GL_BACK GL_LEFT GL_RIGHT GL_FRONT_AND_BACK GL_AUX0 GL_AUX1 GL_AUX2 GL_AUX3 +category 1.0 +chromium extpack + +name Clear +return void +param mask GLbitfield +category 1.0 +props render +chromium pack + +name ClearAccum +return void +param red GLfloat +param green GLfloat +param blue GLfloat +param alpha GLfloat +category 1.0 +chromium extpack + +name ClearIndex +return void +param c GLfloat +category 1.0 +chromium extpack + +name ClearColor +return void +param red GLclampf +param green GLclampf +param blue GLclampf +param alpha GLclampf +category 1.0 +chromium extpack + +name ClearStencil +return void +param s GLint +category 1.0 +chromium extpack + +name ClearDepth +return void +param depth GLclampd +category 1.0 +chromium extpack + +name StencilMask +return void +param mask GLuint +category 1.0 +chromium pack + +name ColorMask +return void +param red GLboolean +param green GLboolean +param blue GLboolean +param alpha GLboolean +category 1.0 +chromium pack + +name DepthMask +return void +param flag GLboolean +category 1.0 +chromium pack + +name IndexMask +return void +param mask GLuint +category 1.0 +chromium pack + +name Accum +return void +param op GLenum +paramprop op GL_ACCUM GL_LOAD GL_ADD GL_MULT GL_RETURN +param value GLfloat +category 1.0 +props render +chromium extpack + +name Disable +return void +param cap GLenum +paramprop cap GL_ALPHA_TEST GL_AUTO_NORMAL GL_BLEND GL_COLOR_ARRAY GL_COLOR_LOGIC_OP GL_COLOR_MATERIAL GL_COLOR_TABLE GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_CULL_FACE GL_DEPTH_TEST GL_DITHER GL_EDGE_FLAG_ARRAY GL_FOG GL_HISTOGRAM GL_INDEX_ARRAY GL_INDEX_LOGIC_OP GL_LIGHTING GL_LINE_SMOOTH GL_LINE_STIPPLE GL_MAP1_COLOR_4 GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP2_COLOR_4 GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MINMAX GL_NORMAL_ARRAY GL_NORMALIZE GL_POINT_SMOOTH GL_POLYGON_SMOOTH GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_POINT GL_POLYGON_STIPPLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_RESCALE_NORMAL GL_SCISSOR_TEST GL_SEPARABLE_2D GL_STENCIL_TEST GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_COORD_ARRAY GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_R GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_VERTEX_ARRAY GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_MULTISAMPLE_ARB GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_SAMPLE_ALPHA_TO_ONE_ARB GL_SAMPLE_COVERAGE_ARB GL_POINT_SPRITE_ARB GL_RASTER_POSITION_UNCLIPPED_IBM GL_PER_STAGE_CONSTANTS_NV GL_COLOR_SUM_EXT GL_TEXTURE_RECTANGLE_NV +category 1.0 +chromium pack + +name Enable +return void +param cap GLenum +paramprop cap GL_ALPHA_TEST GL_AUTO_NORMAL GL_BLEND GL_COLOR_ARRAY GL_COLOR_LOGIC_OP GL_COLOR_MATERIAL GL_COLOR_TABLE GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_CULL_FACE GL_DEPTH_TEST GL_DITHER GL_EDGE_FLAG_ARRAY GL_FOG GL_HISTOGRAM GL_INDEX_ARRAY GL_INDEX_LOGIC_OP GL_LIGHTING GL_LINE_SMOOTH GL_LINE_STIPPLE GL_MAP1_COLOR_4 GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP2_COLOR_4 GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MINMAX GL_NORMAL_ARRAY GL_NORMALIZE GL_POINT_SMOOTH GL_POLYGON_SMOOTH GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_POINT GL_POLYGON_STIPPLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_RESCALE_NORMAL GL_SCISSOR_TEST GL_SEPARABLE_2D GL_STENCIL_TEST GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_COORD_ARRAY GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_R GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_VERTEX_ARRAY GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_MULTISAMPLE_ARB GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_SAMPLE_ALPHA_TO_ONE_ARB GL_SAMPLE_COVERAGE_ARB GL_POINT_SPRITE_ARB GL_RASTER_POSITION_UNCLIPPED_IBM GL_PER_STAGE_CONSTANTS_NV GL_COLOR_SUM_EXT GL_TEXTURE_RECTANGLE_NV +category 1.0 +chromium pack + +name Finish +return void +category 1.0 +props nolist +chromium pack + +name Flush +return void +category 1.0 +props nolist +chromium pack + +name PopAttrib +return void +category 1.0 +chromium extpack + +# mask GL_MULTISAMPLE_BIT_ARB +name PushAttrib +return void +param mask GLbitfield +category 1.0 +chromium extpack + +name Map1d +return void +param target GLenum +paramprop target GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP1_INDEX GL_MAP1_COLOR_4 GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 +param u1 GLdouble +paramlist u1 0.0 +param u2 GLdouble +paramlist u2 1.0 +param stride GLint +paramlist stride 4 +param order GLint +paramlist order 10 +param points const GLdouble * +paramaction points initMap1 +category 1.0 +chromium pack + +name Map1f +return void +param target GLenum +paramprop target GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP1_INDEX GL_MAP1_COLOR_4 GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 +param u1 GLfloat +paramlist u1 0.0 +param u2 GLfloat +paramlist u2 1.0 +param stride GLint +paramlist stride 4 +param order GLint +paramlist order 10 +param points const GLfloat * +paramaction points initMap1 +category 1.0 +chromium pack + +name Map2d +return void +param target GLenum +paramprop target GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MAP2_INDEX GL_MAP2_COLOR_4 GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 +param u1 GLdouble +paramlist u1 0.0 +param u2 GLdouble +paramlist u2 1.0 +param ustride GLint +paramlist ustride 8 +param uorder GLint +paramlist uorder 2 +param v1 GLdouble +paramlist v1 1.0 +param v2 GLdouble +paramlist v2 0.0 +param vstride GLint +paramlist vstride 4 +param vorder GLint +paramlist vorder 3 +param points const GLdouble * +paramaction pixel enableTex +category 1.0 +chromium pack + +name Map2f +return void +param target GLenum +paramprop target GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MAP2_INDEX GL_MAP2_COLOR_4 GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 +param u1 GLfloat +paramlist u1 0.0 +param u2 GLfloat +paramlist u2 1.0 +param ustride GLint +paramlist ustride 8 +param uorder GLint +paramlist uorder 2 +param v1 GLfloat +paramlist v1 0.0 +param v2 GLfloat +paramlist v2 1.0 +param vstride GLint +paramlist vstride 4 +param vorder GLint +paramlist vorder 3 +param points const GLfloat * +paramaction pixel enableTex +category 1.0 +chromium pack + +name MapGrid1d +return void +param un GLint +paramlist un 40 +param u1 GLdouble +paramlist u1 0.0 +param u2 GLdouble +paramlist u2 1.0 +category 1.0 +chromium pack + +name MapGrid1f +return void +param un GLint +paramlist un 40 +paramlist u1 0.0 +param u1 GLfloat +param u2 GLfloat +paramlist u2 1.0 +category 1.0 +chromium pack + +name MapGrid2d +return void +param un GLint +paramlist un 40 +param u1 GLdouble +paramlist u1 0.0 +param u2 GLdouble +paramlist u2 1.0 +param vn GLint +paramlist vn 40 +param v1 GLdouble +paramlist v1 0.0 +param v2 GLdouble +paramlist v2 1.0 +category 1.0 +chromium pack + +name MapGrid2f +return void +param un GLint +paramlist un 40 +param u1 GLfloat +paramlist u1 0.0 +param u2 GLfloat +paramlist u1 0.0 +param vn GLint +paramlist vn 40 +param v1 GLfloat +paramlist v1 0.0 +param v2 GLfloat +paramlist v2 1.0 +category 1.0 +chromium pack + +name EvalCoord1d +return void +param u GLdouble +category 1.0 +props pervertex +chromium pack + +name EvalCoord1dv +return void +param u const GLdouble * +paramvec u 1.0 +vector u 1 +category 1.0 +props pervertex +vectoralias EvalCoord1d + +name EvalCoord1f +return void +param u GLfloat +paramlist u 1.0 +category 1.0 +props pervertex +chromium pack + +name EvalCoord1fv +return void +param u const GLfloat * +paramvec u 1.0 +vector u 1 +category 1.0 +props pervertex +vectoralias EvalCoord1f + +name EvalCoord2d +return void +param u GLdouble +paramlist u 1.0 +param v GLdouble +paramlist v 1.0 +category 1.0 +props pervertex +chromium pack + +name EvalCoord2dv +return void +param u const GLdouble * +paramvec u 1.0 1.0 +vector u 2 +category 1.0 +props pervertex +vectoralias EvalCoord2d + +name EvalCoord2f +return void +param u GLfloat +paramlist u 1.0 +param v GLfloat +paramlist v 1.0 +category 1.0 +props pervertex +chromium pack + +name EvalCoord2fv +return void +param u const GLfloat * +paramvec u 1.0 0.0 +vector u 2 +category 1.0 +props pervertex +vectoralias EvalCoord2f + +name EvalMesh1 +return void +param mode GLenum +paramprop mode GL_POINT GL_LINE +param i1 GLint +param i2 GLint +category 1.0 +chromium pack +props render + +name EvalPoint1 +return void +param i GLint +category 1.0 +chromium pack +props pervertex + +name EvalMesh2 +return void +param mode GLenum +paramprop mode GL_POINT GL_LINE GL_FILL +param i1 GLint +param i2 GLint +param j1 GLint +param j2 GLint +category 1.0 +chromium pack +props render + +name EvalPoint2 +return void +param i GLint +param j GLint +category 1.0 +chromium pack +props pervertex + +name AlphaFunc +return void +param func GLenum +paramprop func GL_NEVER GL_LESS GL_EQUAL GL_LEQUAL GL_GREATER GL_NOTEQUAL GL_GEQUAL GL_ALWAYS +param ref GLclampf +category 1.0 +chromium pack + +name BlendFunc +return void +param sfactor GLenum +paramprop sfactor GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_SRC_ALPHA_SATURATE GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA +param dfactor GLenum +paramprop dfactor GL_ZERO GL_ONE GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA +category 1.0 +chromium pack + +name LogicOp +return void +param opcode GLenum +paramprop opcode GL_CLEAR GL_SET GL_COPY GL_COPY_INVERTED GL_NOOP GL_INVERT GL_AND GL_NAND GL_OR GL_NOR GL_XOR GL_EQUIV GL_AND_REVERSE GL_AND_INVERTED GL_OR_REVERSE GL_OR_INVERTED +category 1.0 +chromium extpack + +name StencilFunc +return void +param func GLenum +paramprop func GL_NEVER GL_LESS GL_LEQUAL GL_GREATER GL_GEQUAL GL_EQUAL GL_NOTEQUAL GL_ALWAYS +param ref GLint +param mask GLuint +category 1.0 +chromium pack + +name StencilOp +return void +param fail GLenum +paramprop fail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP_EXT GL_DECR_WRAP_EXT +param zfail GLenum +paramprop zfail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP_EXT GL_DECR_WRAP_EXT +param zpass GLenum +paramprop zpass GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP_EXT GL_DECR_WRAP_EXT +category 1.0 +chromium pack + +name DepthFunc +return void +param func GLenum +paramprop func GL_NEVER GL_LESS GL_EQUAL GL_LEQUAL GL_GREATER GL_NOTEQUAL GL_GEQUAL GL_ALWAYS +category 1.0 +chromium pack + +name PixelZoom +return void +param xfactor GLfloat +param yfactor GLfloat +category 1.0 +chromium pack + +name PixelTransferf +return void +param pname GLenum +paramprop pname GL_MAP_COLOR GL_MAP_STENCIL GL_INDEX_SHIFT GL_INDEX_OFFSET GL_RED_SCALE GL_RED_BIAS GL_GREEN_SCALE GL_GREEN_BIAS GL_BLUE_SCALE GL_BLUE_BIAS GL_ALPHA_SCALE GL_ALPHA_BIAS GL_DEPTH_SCALE GL_DEPTH_BIAS GL_POST_COLOR_MATRIX_RED_SCALE GL_POST_COLOR_MATRIX_GREEN_SCALE GL_POST_COLOR_MATRIX_BLUE_SCALE GL_POST_COLOR_MATRIX_ALPHA_SCALE GL_POST_COLOR_MATRIX_RED_BIAS GL_POST_COLOR_MATRIX_GREEN_BIAS GL_POST_COLOR_MATRIX_BLUE_BIAS GL_POST_COLOR_MATRIX_ALPHA_BIAS GL_POST_CONVOLUTION_RED_SCALE GL_POST_CONVOLUTION_GREEN_SCALE GL_POST_CONVOLUTION_BLUE_SCALE GL_POST_CONVOLUTION_ALPHA_SCALE GL_POST_CONVOLUTION_RED_BIAS GL_POST_CONVOLUTION_GREEN_BIAS GL_POST_CONVOLUTION_BLUE_BIAS GL_POST_CONVOLUTION_ALPHA_BIAS +param param GLfloat +category 1.0 +chromium pack + +name PixelTransferi +return void +param pname GLenum +paramprop pname GL_MAP_COLOR GL_MAP_STENCIL GL_INDEX_SHIFT GL_INDEX_OFFSET GL_RED_SCALE GL_RED_BIAS GL_GREEN_SCALE GL_GREEN_BIAS GL_BLUE_SCALE GL_BLUE_BIAS GL_ALPHA_SCALE GL_ALPHA_BIAS GL_DEPTH_SCALE GL_DEPTH_BIAS GL_POST_COLOR_MATRIX_RED_SCALE GL_POST_COLOR_MATRIX_GREEN_SCALE GL_POST_COLOR_MATRIX_BLUE_SCALE GL_POST_COLOR_MATRIX_ALPHA_SCALE GL_POST_COLOR_MATRIX_RED_BIAS GL_POST_COLOR_MATRIX_GREEN_BIAS GL_POST_COLOR_MATRIX_BLUE_BIAS GL_POST_COLOR_MATRIX_ALPHA_BIAS GL_POST_CONVOLUTION_RED_SCALE GL_POST_CONVOLUTION_GREEN_SCALE GL_POST_CONVOLUTION_BLUE_SCALE GL_POST_CONVOLUTION_ALPHA_SCALE GL_POST_CONVOLUTION_RED_BIAS GL_POST_CONVOLUTION_GREEN_BIAS GL_POST_CONVOLUTION_BLUE_BIAS GL_POST_CONVOLUTION_ALPHA_BIAS +param param GLint +category 1.0 +chromium pack + +name PixelStoref +return void +param pname GLenum +paramprop pname GL_PACK_SWAP_BYTES GL_PACK_LSB_FIRST GL_PACK_ROW_LENGTH GL_PACK_IMAGE_HEIGHT GL_PACK_SKIP_PIXELS GL_PACK_SKIP_ROWS GL_PACK_SKIP_IMAGES GL_PACK_ALIGNMENT GL_UNPACK_SWAP_BYTES GL_UNPACK_LSB_FIRST GL_UNPACK_ROW_LENGTH GL_UNPACK_IMAGE_HEIGHT GL_UNPACK_SKIP_PIXELS GL_UNPACK_SKIP_ROWS GL_UNPACK_SKIP_IMAGES GL_UNPACK_ALIGNMENT +param param GLfloat +paramlist param 1 2 4 8 +category 1.0 +props setclient +chromium pack + +name PixelStorei +return void +param pname GLenum +paramprop pname GL_PACK_SWAP_BYTES GL_PACK_LSB_FIRST GL_PACK_ROW_LENGTH GL_PACK_IMAGE_HEIGHT GL_PACK_SKIP_PIXELS GL_PACK_SKIP_ROWS GL_PACK_SKIP_IMAGES GL_PACK_ALIGNMENT GL_UNPACK_SWAP_BYTES GL_UNPACK_LSB_FIRST GL_UNPACK_ROW_LENGTH GL_UNPACK_IMAGE_HEIGHT GL_UNPACK_SKIP_PIXELS GL_UNPACK_SKIP_ROWS GL_UNPACK_SKIP_IMAGES GL_UNPACK_ALIGNMENT +param param GLint +paramlist param 1 2 4 8 +category 1.0 +props setclient +chromium pack + +name PixelMapfv +return void +param map GLenum +paramprop map GL_PIXEL_MAP_I_TO_I GL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_I_TO_G GL_PIXEL_MAP_I_TO_B GL_PIXEL_MAP_I_TO_A GL_PIXEL_MAP_R_TO_R GL_PIXEL_MAP_G_TO_G GL_PIXEL_MAP_B_TO_B GL_PIXEL_MAP_A_TO_A +param mapsize GLsizei +paramlist mapsize 2 +param values const GLfloat * +paramvec values 1.0 1.0 +category 1.0 +chromium pack + +name PixelMapuiv +return void +param map GLenum +paramprop map GL_PIXEL_MAP_I_TO_I GL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_I_TO_G GL_PIXEL_MAP_I_TO_B GL_PIXEL_MAP_I_TO_A GL_PIXEL_MAP_R_TO_R GL_PIXEL_MAP_G_TO_G GL_PIXEL_MAP_B_TO_B GL_PIXEL_MAP_A_TO_A +param mapsize GLsizei +paramlist mapsize 2 +param values const GLuint * +paramvec values 1 1 +category 1.0 +chromium pack + +name PixelMapusv +return void +param map GLenum +paramprop map GL_PIXEL_MAP_I_TO_I GL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_I_TO_G GL_PIXEL_MAP_I_TO_B GL_PIXEL_MAP_I_TO_A GL_PIXEL_MAP_R_TO_R GL_PIXEL_MAP_G_TO_G GL_PIXEL_MAP_B_TO_B GL_PIXEL_MAP_A_TO_A +param mapsize GLsizei +paramlist mapsize 2 +param values const GLushort * +paramvec values 1 1 +category 1.0 +chromium pack + +name ReadBuffer +return void +param mode GLenum +paramprop mode GL_NONE GL_FRONT_LEFT GL_FRONT_RIGHT GL_BACK_LEFT GL_BACK_RIGHT GL_FRONT GL_BACK GL_LEFT GL_RIGHT GL_FRONT_AND_BACK GL_AUX0 GL_AUX1 GL_AUX2 GL_AUX3 +category 1.0 +chromium extpack + +name CopyPixels +return void +param x GLint +param y GLint +param width GLsizei +param height GLsizei +param type GLenum +paramprop type GL_COLOR GL_DEPTH GL_STENCIL +category 1.0 +props render +chromium pack + +name ReadPixels +return void +param x GLint +param y GLint +param width GLsizei +param height GLsizei +param format GLenum +param type GLenum +paramset [ format type ] [ GL_DEPTH_COMPONENT ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_STENCIL_INDEX ] [ GL_UNSIGNED_SHORT GL_UNSIGNED_INT ] +paramset [ format type ] [ GL_RGB ] [ GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA ] [ GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_COLOR_INDEX ] [ GL_BITMAP ] +paramset [ format type ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels GLvoid * +category 1.0 +chromium pack +props get pixelstore +# XXX? props get + +name DrawPixels +return void +param width GLsizei +paramlist width 4 +param height GLsizei +paramlist height 4 +param format GLenum +paramset [ format type ] [ GL_COLOR_INDEX GL_DEPTH_COMPONENT ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_STENCIL_INDEX ] [ GL_UNSIGNED_SHORT GL_UNSIGNED_INT ] +paramset [ format type ] [ GL_RGB ] [ GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA ] [ GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ format type ] [ GL_COLOR_INDEX ] [ GL_BITMAP ] +paramset [ format type ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param type GLenum +param pixels const GLvoid * +paramaction pixels makeStripeImage +category 1.0 +props render pixelstore +chromium pack + +name GetBooleanv +return void +param pname GLenum +paramprop pname GL_ACCUM_ALPHA_BITS GL_ACCUM_BLUE_BITS GL_ACCUM_CLEAR_VALUE GL_ACCUM_GREEN_BITS GL_ACCUM_RED_BITS GL_ACTIVE_TEXTURE_ARB GL_ALIASED_LINE_WIDTH_RANGE GL_ALIASED_POINT_SIZE_RANGE GL_ALPHA_BIAS GL_ALPHA_BITS GL_ALPHA_SCALE GL_ALPHA_TEST GL_ALPHA_TEST_FUNC GL_ALPHA_TEST_REF GL_ATTRIB_STACK_DEPTH GL_AUTO_NORMAL GL_AUX_BUFFERS GL_BLEND GL_BLEND_COLOR GL_BLEND_DST GL_BLEND_EQUATION GL_BLEND_SRC GL_BLUE_BIAS GL_BLUE_BITS GL_BLUE_SCALE GL_CLIENT_ACTIVE_TEXTURE_ARB GL_CLIENT_ATTRIB_STACK_DEPTH GL_COLOR_ARRAY GL_COLOR_ARRAY_SIZE GL_COLOR_ARRAY_STRIDE GL_COLOR_ARRAY_TYPE GL_COLOR_CLEAR_VALUE GL_COLOR_LOGIC_OP GL_COLOR_MATERIAL GL_COLOR_MATERIAL_FACE GL_COLOR_MATERIAL_PARAMETER GL_COLOR_MATRIX_STACK_DEPTH GL_COLOR_WRITEMASK GL_CULL_FACE GL_CULL_FACE_MODE GL_CURRENT_COLOR GL_CURRENT_INDEX GL_CURRENT_NORMAL GL_CURRENT_RASTER_COLOR GL_CURRENT_RASTER_DISTANCE GL_CURRENT_RASTER_INDEX GL_CURRENT_RASTER_POSITION GL_CURRENT_RASTER_POSITION_VALID GL_CURRENT_RASTER_TEXTURE_COORDS GL_CURRENT_TEXTURE_COORDS GL_DEPTH_BIAS GL_DEPTH_BITS GL_DEPTH_CLEAR_VALUE GL_DEPTH_FUNC GL_DEPTH_RANGE GL_DEPTH_SCALE GL_DEPTH_TEST GL_DEPTH_WRITEMASK GL_DITHER GL_DOUBLEBUFFER GL_DRAW_BUFFER GL_EDGE_FLAG GL_EDGE_FLAG_ARRAY GL_EDGE_FLAG_ARRAY_STRIDE GL_FEEDBACK_BUFFER_SIZE GL_FEEDBACK_BUFFER_TYPE GL_FOG GL_FOG_COLOR GL_FOG_DENSITY GL_FOG_END GL_FOG_HINT GL_FOG_INDEX GL_FOG_MODE GL_FOG_START GL_FRONT_FACE GL_GREEN_BIAS GL_GREEN_BITS GL_GREEN_SCALE GL_INDEX_ARRAY GL_INDEX_ARRAY_STRIDE GL_INDEX_ARRAY_TYPE GL_INDEX_BITS GL_INDEX_CLEAR_VALUE GL_INDEX_LOGIC_OP GL_INDEX_MODE GL_INDEX_OFFSET GL_INDEX_SHIFT GL_INDEX_WRITEMASK GL_LIGHTING GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_TWO_SIDE GL_LINE_SMOOTH GL_LINE_SMOOTH_HINT GL_LINE_STIPPLE GL_LINE_STIPPLE_PATTERN GL_LINE_STIPPLE_REPEAT GL_LINE_WIDTH GL_LINE_WIDTH_GRANULARITY GL_LINE_WIDTH_RANGE GL_LIST_BASE GL_LIST_INDEX GL_LIST_MODE GL_LOGIC_OP_MODE GL_MAP1_COLOR_4 GL_MAP1_GRID_DOMAIN GL_MAP1_GRID_SEGMENTS GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP2_COLOR_4 GL_MAP2_GRID_DOMAIN GL_MAP2_GRID_SEGMENTS GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MAP_COLOR GL_MAP_STENCIL GL_MATRIX_MODE GL_MAX_3D_TEXTURE_SIZE GL_MAX_ATTRIB_STACK_DEPTH GL_MAX_CLIENT_ATTRIB_STACK_DEPTH GL_MAX_CLIP_PLANES GL_MAX_COLOR_MATRIX_STACK_DEPTH GL_MAX_ELEMENTS_INDICES GL_MAX_ELEMENTS_VERTICES GL_MAX_EVAL_ORDER GL_MAX_LIGHTS GL_MAX_LIST_NESTING GL_MAX_MODELVIEW_STACK_DEPTH GL_MAX_NAME_STACK_DEPTH GL_MAX_PIXEL_MAP_TABLE GL_MAX_PROJECTION_STACK_DEPTH GL_MAX_TEXTURE_SIZE GL_MAX_TEXTURE_STACK_DEPTH GL_MAX_TEXTURE_UNITS_ARB GL_MAX_VIEWPORT_DIMS GL_MODELVIEW_MATRIX GL_MODELVIEW_STACK_DEPTH GL_NAME_STACK_DEPTH GL_NORMAL_ARRAY GL_NORMAL_ARRAY_STRIDE GL_NORMAL_ARRAY_TYPE GL_NORMALIZE GL_PACK_ALIGNMENT GL_PACK_IMAGE_HEIGHT GL_PACK_LSB_FIRST GL_PACK_ROW_LENGTH GL_PACK_SKIP_IMAGES GL_PACK_SKIP_PIXELS GL_PACK_SKIP_ROWS GL_PACK_SWAP_BYTES GL_PERSPECTIVE_CORRECTION_HINT GL_PIXEL_MAP_A_TO_A_SIZE GL_PIXEL_MAP_B_TO_B_SIZE GL_PIXEL_MAP_G_TO_G_SIZE GL_PIXEL_MAP_I_TO_A_SIZE GL_PIXEL_MAP_I_TO_B_SIZE GL_PIXEL_MAP_I_TO_G_SIZE GL_PIXEL_MAP_I_TO_I_SIZE GL_PIXEL_MAP_I_TO_R_SIZE GL_PIXEL_MAP_R_TO_R_SIZE GL_PIXEL_MAP_S_TO_S_SIZE GL_POINT_SIZE GL_POINT_SIZE_GRANULARITY GL_POINT_SIZE_RANGE GL_POINT_SMOOTH GL_POINT_SMOOTH_HINT GL_POLYGON_MODE GL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_POINT GL_POLYGON_OFFSET_UNITS GL_POLYGON_SMOOTH GL_POLYGON_SMOOTH_HINT GL_POLYGON_STIPPLE GL_PROJECTION_MATRIX GL_PROJECTION_STACK_DEPTH GL_READ_BUFFER GL_RED_BIAS GL_RED_BITS GL_RED_SCALE GL_RENDER_MODE GL_RESCALE_NORMAL GL_RGBA_MODE GL_SCISSOR_BOX GL_SCISSOR_TEST GL_SELECTION_BUFFER_SIZE GL_SHADE_MODEL GL_SMOOTH_LINE_WIDTH_GRANULARITY GL_SMOOTH_LINE_WIDTH_RANGE GL_SMOOTH_POINT_SIZE_GRANULARITY GL_SMOOTH_POINT_SIZE_RANGE GL_STENCIL_BITS GL_STENCIL_CLEAR_VALUE GL_STENCIL_FAIL GL_STENCIL_FUNC GL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_PASS GL_STENCIL_REF GL_STENCIL_TEST GL_STENCIL_VALUE_MASK GL_STENCIL_WRITEMASK GL_STEREO GL_SUBPIXEL_BITS GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_BINDING_1D GL_TEXTURE_BINDING_2D GL_TEXTURE_BINDING_3D GL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY_SIZE GL_TEXTURE_COORD_ARRAY_STRIDE GL_TEXTURE_COORD_ARRAY_TYPE GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_R GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_TEXTURE_MATRIX GL_TEXTURE_STACK_DEPTH GL_UNPACK_ALIGNMENT GL_UNPACK_IMAGE_HEIGHT GL_UNPACK_LSB_FIRST GL_UNPACK_ROW_LENGTH GL_UNPACK_SKIP_IMAGES GL_UNPACK_SKIP_PIXELS GL_UNPACK_SKIP_ROWS GL_UNPACK_SWAP_BYTES GL_VERTEX_ARRAY GL_VERTEX_ARRAY_SIZE GL_VERTEX_ARRAY_STRIDE GL_VERTEX_ARRAY_TYPE GL_VIEWPORT GL_ZOOM_X GL_ZOOM_Y GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_MULTISAMPLE_ARB GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_SAMPLE_ALPHA_TO_ONE_ARB GL_SAMPLE_COVERAGE_ARB GL_SAMPLE_BUFFERS_ARB GL_SAMPLES_ARB GL_SAMPLE_COVERAGE_VALUE_ARB GL_SAMPLE_COVERAGE_INVERT_ARB GL_POINT_SPRITE_ARB GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB GL_CLIP_VOLUME_CLIPPING_HINT_EXT GL_RASTER_POSITION_UNCLIPPED_IBM GL_GENERATE_MIPMAP_HINT_SGIS GL_FOG_DISTANCE_MODE_NV GL_TRANSPOSE_MODELVIEW_MATRIX_ARB GL_TRANSPOSE_PROJECTION_MATRIX_ARB GL_TRANSPOSE_TEXTURE_MATRIX_ARB GL_TRANSPOSE_COLOR_MATRIX_ARB GL_MAX_TEXTURE_LOD_BIAS_EXT GL_PER_STAGE_CONSTANTS_NV GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT GL_CURRENT_FOG_COORDINATE_EXT GL_FOG_COORDINATE_ARRAY_TYPE_EXT GL_FOG_COORDINATE_ARRAY_STRIDE_EXT GL_COLOR_SUM_EXT GL_CURRENT_SECONDARY_COLOR_EXT GL_SECONDARY_COLOR_ARRAY_SIZE_EXT GL_SECONDARY_COLOR_ARRAY_TYPE_EXT GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT GL_ARRAY_BUFFER_BINDING_ARB GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB GL_VERTEX_ARRAY_BUFFER_BINDING_ARB GL_NORMAL_ARRAY_BUFFER_BINDING_ARB GL_COLOR_ARRAY_BUFFER_BINDING_ARB GL_INDEX_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_BINDING_RECTANGLE_NV GL_MAX_RECTANGLE_TEXTURE_SIZE_NV GL_READ_FRAMEBUFFER_BINDING_EXT GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_ACTIVE_STENCIL_FACE_EXT +param params GLboolean * +category 1.0 +props get +chromium extpack + +name GetClipPlane +return void +param plane GLenum +paramprop plane GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 +param equation GLdouble * +paramvec equation 0.0 0.0 0.0 0.0 +vector equation 4 +category 1.0 +props get +chromium extpack + +name GetDoublev +return void +param pname GLenum +paramprop pname GL_ACCUM_ALPHA_BITS GL_ACCUM_BLUE_BITS GL_ACCUM_CLEAR_VALUE GL_ACCUM_GREEN_BITS GL_ACCUM_RED_BITS GL_ACTIVE_TEXTURE_ARB GL_ALIASED_LINE_WIDTH_RANGE GL_ALIASED_POINT_SIZE_RANGE GL_ALPHA_BIAS GL_ALPHA_BITS GL_ALPHA_SCALE GL_ALPHA_TEST GL_ALPHA_TEST_FUNC GL_ALPHA_TEST_REF GL_ATTRIB_STACK_DEPTH GL_AUTO_NORMAL GL_AUX_BUFFERS GL_BLEND GL_BLEND_COLOR GL_BLEND_DST GL_BLEND_EQUATION GL_BLEND_SRC GL_BLUE_BIAS GL_BLUE_BITS GL_BLUE_SCALE GL_CLIENT_ACTIVE_TEXTURE_ARB GL_CLIENT_ATTRIB_STACK_DEPTH GL_COLOR_ARRAY GL_COLOR_ARRAY_SIZE GL_COLOR_ARRAY_STRIDE GL_COLOR_ARRAY_TYPE GL_COLOR_CLEAR_VALUE GL_COLOR_LOGIC_OP GL_COLOR_MATERIAL GL_COLOR_MATERIAL_FACE GL_COLOR_MATERIAL_PARAMETER GL_COLOR_MATRIX_STACK_DEPTH GL_COLOR_WRITEMASK GL_CULL_FACE GL_CULL_FACE_MODE GL_CURRENT_COLOR GL_CURRENT_INDEX GL_CURRENT_NORMAL GL_CURRENT_RASTER_COLOR GL_CURRENT_RASTER_DISTANCE GL_CURRENT_RASTER_INDEX GL_CURRENT_RASTER_POSITION GL_CURRENT_RASTER_POSITION_VALID GL_CURRENT_RASTER_TEXTURE_COORDS GL_CURRENT_TEXTURE_COORDS GL_DEPTH_BIAS GL_DEPTH_BITS GL_DEPTH_CLEAR_VALUE GL_DEPTH_FUNC GL_DEPTH_RANGE GL_DEPTH_SCALE GL_DEPTH_TEST GL_DEPTH_WRITEMASK GL_DITHER GL_DOUBLEBUFFER GL_DRAW_BUFFER GL_EDGE_FLAG GL_EDGE_FLAG_ARRAY GL_EDGE_FLAG_ARRAY_STRIDE GL_FEEDBACK_BUFFER_SIZE GL_FEEDBACK_BUFFER_TYPE GL_FOG GL_FOG_COLOR GL_FOG_DENSITY GL_FOG_END GL_FOG_HINT GL_FOG_INDEX GL_FOG_MODE GL_FOG_START GL_FRONT_FACE GL_GREEN_BIAS GL_GREEN_BITS GL_GREEN_SCALE GL_INDEX_ARRAY GL_INDEX_ARRAY_STRIDE GL_INDEX_ARRAY_TYPE GL_INDEX_BITS GL_INDEX_CLEAR_VALUE GL_INDEX_LOGIC_OP GL_INDEX_MODE GL_INDEX_OFFSET GL_INDEX_SHIFT GL_INDEX_WRITEMASK GL_LIGHTING GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_TWO_SIDE GL_LINE_SMOOTH GL_LINE_SMOOTH_HINT GL_LINE_STIPPLE GL_LINE_STIPPLE_PATTERN GL_LINE_STIPPLE_REPEAT GL_LINE_WIDTH GL_LINE_WIDTH_GRANULARITY GL_LINE_WIDTH_RANGE GL_LIST_BASE GL_LIST_INDEX GL_LIST_MODE GL_LOGIC_OP_MODE GL_MAP1_COLOR_4 GL_MAP1_GRID_DOMAIN GL_MAP1_GRID_SEGMENTS GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP2_COLOR_4 GL_MAP2_GRID_DOMAIN GL_MAP2_GRID_SEGMENTS GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MAP_COLOR GL_MAP_STENCIL GL_MATRIX_MODE GL_MAX_3D_TEXTURE_SIZE GL_MAX_ATTRIB_STACK_DEPTH GL_MAX_CLIENT_ATTRIB_STACK_DEPTH GL_MAX_CLIP_PLANES GL_MAX_COLOR_MATRIX_STACK_DEPTH GL_MAX_ELEMENTS_INDICES GL_MAX_ELEMENTS_VERTICES GL_MAX_EVAL_ORDER GL_MAX_LIGHTS GL_MAX_LIST_NESTING GL_MAX_MODELVIEW_STACK_DEPTH GL_MAX_NAME_STACK_DEPTH GL_MAX_PIXEL_MAP_TABLE GL_MAX_PROJECTION_STACK_DEPTH GL_MAX_TEXTURE_SIZE GL_MAX_TEXTURE_STACK_DEPTH GL_MAX_TEXTURE_UNITS_ARB GL_MAX_VIEWPORT_DIMS GL_MODELVIEW_MATRIX GL_MODELVIEW_STACK_DEPTH GL_NAME_STACK_DEPTH GL_NORMAL_ARRAY GL_NORMAL_ARRAY_STRIDE GL_NORMAL_ARRAY_TYPE GL_NORMALIZE GL_PACK_ALIGNMENT GL_PACK_IMAGE_HEIGHT GL_PACK_LSB_FIRST GL_PACK_ROW_LENGTH GL_PACK_SKIP_IMAGES GL_PACK_SKIP_PIXELS GL_PACK_SKIP_ROWS GL_PACK_SWAP_BYTES GL_PERSPECTIVE_CORRECTION_HINT GL_PIXEL_MAP_A_TO_A_SIZE GL_PIXEL_MAP_B_TO_B_SIZE GL_PIXEL_MAP_G_TO_G_SIZE GL_PIXEL_MAP_I_TO_A_SIZE GL_PIXEL_MAP_I_TO_B_SIZE GL_PIXEL_MAP_I_TO_G_SIZE GL_PIXEL_MAP_I_TO_I_SIZE GL_PIXEL_MAP_I_TO_R_SIZE GL_PIXEL_MAP_R_TO_R_SIZE GL_PIXEL_MAP_S_TO_S_SIZE GL_POINT_SIZE GL_POINT_SIZE_GRANULARITY GL_POINT_SIZE_RANGE GL_POINT_SMOOTH GL_POINT_SMOOTH_HINT GL_POLYGON_MODE GL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_POINT GL_POLYGON_OFFSET_UNITS GL_POLYGON_SMOOTH GL_POLYGON_SMOOTH_HINT GL_POLYGON_STIPPLE GL_PROJECTION_MATRIX GL_PROJECTION_STACK_DEPTH GL_READ_BUFFER GL_RED_BIAS GL_RED_BITS GL_RED_SCALE GL_RENDER_MODE GL_RESCALE_NORMAL GL_RGBA_MODE GL_SCISSOR_BOX GL_SCISSOR_TEST GL_SELECTION_BUFFER_SIZE GL_SHADE_MODEL GL_SMOOTH_LINE_WIDTH_GRANULARITY GL_SMOOTH_LINE_WIDTH_RANGE GL_SMOOTH_POINT_SIZE_GRANULARITY GL_SMOOTH_POINT_SIZE_RANGE GL_STENCIL_BITS GL_STENCIL_CLEAR_VALUE GL_STENCIL_FAIL GL_STENCIL_FUNC GL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_PASS GL_STENCIL_REF GL_STENCIL_TEST GL_STENCIL_VALUE_MASK GL_STENCIL_WRITEMASK GL_STEREO GL_SUBPIXEL_BITS GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_BINDING_1D GL_TEXTURE_BINDING_2D GL_TEXTURE_BINDING_3D GL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY_SIZE GL_TEXTURE_COORD_ARRAY_STRIDE GL_TEXTURE_COORD_ARRAY_TYPE GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_R GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_TEXTURE_MATRIX GL_TEXTURE_STACK_DEPTH GL_UNPACK_ALIGNMENT GL_UNPACK_IMAGE_HEIGHT GL_UNPACK_LSB_FIRST GL_UNPACK_ROW_LENGTH GL_UNPACK_SKIP_IMAGES GL_UNPACK_SKIP_PIXELS GL_UNPACK_SKIP_ROWS GL_UNPACK_SWAP_BYTES GL_VERTEX_ARRAY GL_VERTEX_ARRAY_SIZE GL_VERTEX_ARRAY_STRIDE GL_VERTEX_ARRAY_TYPE GL_VIEWPORT GL_ZOOM_X GL_ZOOM_Y GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_MULTISAMPLE_ARB GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_SAMPLE_ALPHA_TO_ONE_ARB GL_SAMPLE_COVERAGE_ARB GL_SAMPLE_BUFFERS_ARB GL_SAMPLES_ARB GL_SAMPLE_COVERAGE_VALUE_ARB GL_SAMPLE_COVERAGE_INVERT_ARB GL_POINT_SPRITE_ARB GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB GL_CLIP_VOLUME_CLIPPING_HINT_EXT GL_RASTER_POSITION_UNCLIPPED_IBM GL_GENERATE_MIPMAP_HINT_SGIS GL_FOG_DISTANCE_MODE_NV GL_TRANSPOSE_MODELVIEW_MATRIX_ARB GL_TRANSPOSE_PROJECTION_MATRIX_ARB GL_TRANSPOSE_TEXTURE_MATRIX_ARB GL_TRANSPOSE_COLOR_MATRIX_ARB GL_TRANSPOSE_MODELVIEW_MATRIX_ARB GL_TRANSPOSE_PROJECTION_MATRIX_ARB GL_TRANSPOSE_TEXTURE_MATRIX_ARB GL_TRANSPOSE_COLOR_MATRIX_ARB GL_MAX_TEXTURE_LOD_BIAS_EXT GL_PER_STAGE_CONSTANTS_NV GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT GL_CURRENT_FOG_COORDINATE_EXT GL_FOG_COORDINATE_ARRAY_TYPE_EXT GL_FOG_COORDINATE_ARRAY_STRIDE_EXT GL_COLOR_SUM_EXT GL_CURRENT_SECONDARY_COLOR_EXT GL_SECONDARY_COLOR_ARRAY_SIZE_EXT GL_SECONDARY_COLOR_ARRAY_TYPE_EXT GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT GL_ARRAY_BUFFER_BINDING_ARB GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB GL_VERTEX_ARRAY_BUFFER_BINDING_ARB GL_NORMAL_ARRAY_BUFFER_BINDING_ARB GL_COLOR_ARRAY_BUFFER_BINDING_ARB GL_INDEX_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_BINDING_RECTANGLE_NV GL_MAX_RECTANGLE_TEXTURE_SIZE_NV GL_READ_FRAMEBUFFER_BINDING_EXT GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_READ_FRAMEBUFFER_BINDING_EXT GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_ACTIVE_STENCIL_FACE_EXT GL_MAX_DRAW_BUFFERS GL_DRAW_BUFFER0 GL_DRAW_BUFFER1 GL_DRAW_BUFFER2 GL_DRAW_BUFFER3 GL_DRAW_BUFFER4 GL_DRAW_BUFFER5 GL_DRAW_BUFFER6 GL_DRAW_BUFFER7 GL_DRAW_BUFFER8 GL_DRAW_BUFFER9 GL_DRAW_BUFFER10 GL_DRAW_BUFFER11 GL_DRAW_BUFFER12 GL_DRAW_BUFFER13 GL_DRAW_BUFFER14 GL_DRAW_BUFFER15 +param params GLdouble * +category 1.0 +props get +chromium extpack + +name GetError +return GLenum +category 1.0 +props get +chromium extpack + +name GetFloatv +return void +param pname GLenum +paramprop pname GL_ACCUM_ALPHA_BITS GL_ACCUM_BLUE_BITS GL_ACCUM_CLEAR_VALUE GL_ACCUM_GREEN_BITS GL_ACCUM_RED_BITS GL_ACTIVE_TEXTURE_ARB GL_ALIASED_LINE_WIDTH_RANGE GL_ALIASED_POINT_SIZE_RANGE GL_ALPHA_BIAS GL_ALPHA_BITS GL_ALPHA_SCALE GL_ALPHA_TEST GL_ALPHA_TEST_FUNC GL_ALPHA_TEST_REF GL_ATTRIB_STACK_DEPTH GL_AUTO_NORMAL GL_AUX_BUFFERS GL_BLEND GL_BLEND_COLOR GL_BLEND_DST GL_BLEND_EQUATION GL_BLEND_SRC GL_BLUE_BIAS GL_BLUE_BITS GL_BLUE_SCALE GL_CLIENT_ACTIVE_TEXTURE_ARB GL_CLIENT_ATTRIB_STACK_DEPTH GL_COLOR_ARRAY GL_COLOR_ARRAY_SIZE GL_COLOR_ARRAY_STRIDE GL_COLOR_ARRAY_TYPE GL_COLOR_CLEAR_VALUE GL_COLOR_LOGIC_OP GL_COLOR_MATERIAL GL_COLOR_MATERIAL_FACE GL_COLOR_MATERIAL_PARAMETER GL_COLOR_MATRIX_STACK_DEPTH GL_COLOR_WRITEMASK GL_CULL_FACE GL_CULL_FACE_MODE GL_CURRENT_COLOR GL_CURRENT_INDEX GL_CURRENT_NORMAL GL_CURRENT_RASTER_COLOR GL_CURRENT_RASTER_DISTANCE GL_CURRENT_RASTER_INDEX GL_CURRENT_RASTER_POSITION GL_CURRENT_RASTER_POSITION_VALID GL_CURRENT_RASTER_TEXTURE_COORDS GL_CURRENT_TEXTURE_COORDS GL_DEPTH_BIAS GL_DEPTH_BITS GL_DEPTH_CLEAR_VALUE GL_DEPTH_FUNC GL_DEPTH_RANGE GL_DEPTH_SCALE GL_DEPTH_TEST GL_DEPTH_WRITEMASK GL_DITHER GL_DOUBLEBUFFER GL_DRAW_BUFFER GL_EDGE_FLAG GL_EDGE_FLAG_ARRAY GL_EDGE_FLAG_ARRAY_STRIDE GL_FEEDBACK_BUFFER_SIZE GL_FEEDBACK_BUFFER_TYPE GL_FOG GL_FOG_COLOR GL_FOG_DENSITY GL_FOG_END GL_FOG_HINT GL_FOG_INDEX GL_FOG_MODE GL_FOG_START GL_FRONT_FACE GL_GREEN_BIAS GL_GREEN_BITS GL_GREEN_SCALE GL_INDEX_ARRAY GL_INDEX_ARRAY_STRIDE GL_INDEX_ARRAY_TYPE GL_INDEX_BITS GL_INDEX_CLEAR_VALUE GL_INDEX_LOGIC_OP GL_INDEX_MODE GL_INDEX_OFFSET GL_INDEX_SHIFT GL_INDEX_WRITEMASK GL_LIGHTING GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_TWO_SIDE GL_LINE_SMOOTH GL_LINE_SMOOTH_HINT GL_LINE_STIPPLE GL_LINE_STIPPLE_PATTERN GL_LINE_STIPPLE_REPEAT GL_LINE_WIDTH GL_LINE_WIDTH_GRANULARITY GL_LINE_WIDTH_RANGE GL_LIST_BASE GL_LIST_INDEX GL_LIST_MODE GL_LOGIC_OP_MODE GL_MAP1_COLOR_4 GL_MAP1_GRID_DOMAIN GL_MAP1_GRID_SEGMENTS GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP2_COLOR_4 GL_MAP2_GRID_DOMAIN GL_MAP2_GRID_SEGMENTS GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MAP_COLOR GL_MAP_STENCIL GL_MATRIX_MODE GL_MAX_3D_TEXTURE_SIZE GL_MAX_ATTRIB_STACK_DEPTH GL_MAX_CLIENT_ATTRIB_STACK_DEPTH GL_MAX_CLIP_PLANES GL_MAX_COLOR_MATRIX_STACK_DEPTH GL_MAX_ELEMENTS_INDICES GL_MAX_ELEMENTS_VERTICES GL_MAX_EVAL_ORDER GL_MAX_LIGHTS GL_MAX_LIST_NESTING GL_MAX_MODELVIEW_STACK_DEPTH GL_MAX_NAME_STACK_DEPTH GL_MAX_PIXEL_MAP_TABLE GL_MAX_PROJECTION_STACK_DEPTH GL_MAX_TEXTURE_SIZE GL_MAX_TEXTURE_STACK_DEPTH GL_MAX_TEXTURE_UNITS_ARB GL_MAX_VIEWPORT_DIMS GL_MODELVIEW_MATRIX GL_MODELVIEW_STACK_DEPTH GL_NAME_STACK_DEPTH GL_NORMAL_ARRAY GL_NORMAL_ARRAY_STRIDE GL_NORMAL_ARRAY_TYPE GL_NORMALIZE GL_PACK_ALIGNMENT GL_PACK_IMAGE_HEIGHT GL_PACK_LSB_FIRST GL_PACK_ROW_LENGTH GL_PACK_SKIP_IMAGES GL_PACK_SKIP_PIXELS GL_PACK_SKIP_ROWS GL_PACK_SWAP_BYTES GL_PERSPECTIVE_CORRECTION_HINT GL_PIXEL_MAP_A_TO_A_SIZE GL_PIXEL_MAP_B_TO_B_SIZE GL_PIXEL_MAP_G_TO_G_SIZE GL_PIXEL_MAP_I_TO_A_SIZE GL_PIXEL_MAP_I_TO_B_SIZE GL_PIXEL_MAP_I_TO_G_SIZE GL_PIXEL_MAP_I_TO_I_SIZE GL_PIXEL_MAP_I_TO_R_SIZE GL_PIXEL_MAP_R_TO_R_SIZE GL_PIXEL_MAP_S_TO_S_SIZE GL_POINT_SIZE GL_POINT_SIZE_GRANULARITY GL_POINT_SIZE_RANGE GL_POINT_SMOOTH GL_POINT_SMOOTH_HINT GL_POLYGON_MODE GL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_POINT GL_POLYGON_OFFSET_UNITS GL_POLYGON_SMOOTH GL_POLYGON_SMOOTH_HINT GL_POLYGON_STIPPLE GL_PROJECTION_MATRIX GL_PROJECTION_STACK_DEPTH GL_READ_BUFFER GL_RED_BIAS GL_RED_BITS GL_RED_SCALE GL_RENDER_MODE GL_RESCALE_NORMAL GL_RGBA_MODE GL_SCISSOR_BOX GL_SCISSOR_TEST GL_SELECTION_BUFFER_SIZE GL_SHADE_MODEL GL_SMOOTH_LINE_WIDTH_GRANULARITY GL_SMOOTH_LINE_WIDTH_RANGE GL_SMOOTH_POINT_SIZE_GRANULARITY GL_SMOOTH_POINT_SIZE_RANGE GL_STENCIL_BITS GL_STENCIL_CLEAR_VALUE GL_STENCIL_FAIL GL_STENCIL_FUNC GL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_PASS GL_STENCIL_REF GL_STENCIL_TEST GL_STENCIL_VALUE_MASK GL_STENCIL_WRITEMASK GL_STEREO GL_SUBPIXEL_BITS GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_BINDING_1D GL_TEXTURE_BINDING_2D GL_TEXTURE_BINDING_3D GL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY_SIZE GL_TEXTURE_COORD_ARRAY_STRIDE GL_TEXTURE_COORD_ARRAY_TYPE GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_R GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_TEXTURE_MATRIX GL_TEXTURE_STACK_DEPTH GL_UNPACK_ALIGNMENT GL_UNPACK_IMAGE_HEIGHT GL_UNPACK_LSB_FIRST GL_UNPACK_ROW_LENGTH GL_UNPACK_SKIP_IMAGES GL_UNPACK_SKIP_PIXELS GL_UNPACK_SKIP_ROWS GL_UNPACK_SWAP_BYTES GL_VERTEX_ARRAY GL_VERTEX_ARRAY_SIZE GL_VERTEX_ARRAY_STRIDE GL_VERTEX_ARRAY_TYPE GL_VIEWPORT GL_ZOOM_X GL_ZOOM_Y GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_MULTISAMPLE_ARB GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_SAMPLE_ALPHA_TO_ONE_ARB GL_SAMPLE_COVERAGE_ARB GL_SAMPLE_BUFFERS_ARB GL_SAMPLES_ARB GL_SAMPLE_COVERAGE_VALUE_ARB GL_SAMPLE_COVERAGE_INVERT_ARB GL_POINT_SPRITE_ARB GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB GL_CLIP_VOLUME_CLIPPING_HINT_EXT GL_RASTER_POSITION_UNCLIPPED_IBM GL_GENERATE_MIPMAP_HINT_SGIS GL_FOG_DISTANCE_MODE_NV GL_TRANSPOSE_MODELVIEW_MATRIX_ARB GL_TRANSPOSE_PROJECTION_MATRIX_ARB GL_TRANSPOSE_TEXTURE_MATRIX_ARB GL_TRANSPOSE_COLOR_MATRIX_ARB GL_MAX_TEXTURE_LOD_BIAS_EXT GL_PER_STAGE_CONSTANTS_NV GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT GL_CURRENT_FOG_COORDINATE_EXT GL_FOG_COORDINATE_ARRAY_TYPE_EXT GL_FOG_COORDINATE_ARRAY_STRIDE_EXT GL_COLOR_SUM_EXT GL_CURRENT_SECONDARY_COLOR_EXT GL_SECONDARY_COLOR_ARRAY_SIZE_EXT GL_SECONDARY_COLOR_ARRAY_TYPE_EXT GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT GL_ARRAY_BUFFER_BINDING_ARB GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB GL_VERTEX_ARRAY_BUFFER_BINDING_ARB GL_NORMAL_ARRAY_BUFFER_BINDING_ARB GL_COLOR_ARRAY_BUFFER_BINDING_ARB GL_INDEX_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_BINDING_RECTANGLE_NV GL_MAX_RECTANGLE_TEXTURE_SIZE_NV GL_READ_FRAMEBUFFER_BINDING_EXT GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_ACTIVE_STENCIL_FACE_EXT GL_MAX_DRAW_BUFFERS GL_DRAW_BUFFER0 GL_DRAW_BUFFER1 GL_DRAW_BUFFER2 GL_DRAW_BUFFER3 GL_DRAW_BUFFER4 GL_DRAW_BUFFER5 GL_DRAW_BUFFER6 GL_DRAW_BUFFER7 GL_DRAW_BUFFER8 GL_DRAW_BUFFER9 GL_DRAW_BUFFER10 GL_DRAW_BUFFER11 GL_DRAW_BUFFER12 GL_DRAW_BUFFER13 GL_DRAW_BUFFER14 GL_DRAW_BUFFER15 +param params GLfloat * +category 1.0 +props get +chromium extpack + +name GetIntegerv +return void +param pname GLenum +paramprop pname GL_ACCUM_ALPHA_BITS GL_ACCUM_BLUE_BITS GL_ACCUM_CLEAR_VALUE GL_ACCUM_GREEN_BITS GL_ACCUM_RED_BITS GL_ACTIVE_TEXTURE_ARB GL_ALIASED_LINE_WIDTH_RANGE GL_ALIASED_POINT_SIZE_RANGE GL_ALPHA_BIAS GL_ALPHA_BITS GL_ALPHA_SCALE GL_ALPHA_TEST GL_ALPHA_TEST_FUNC GL_ALPHA_TEST_REF GL_ATTRIB_STACK_DEPTH GL_AUTO_NORMAL GL_AUX_BUFFERS GL_BLEND GL_BLEND_COLOR GL_BLEND_DST GL_BLEND_EQUATION GL_BLEND_SRC GL_BLUE_BIAS GL_BLUE_BITS GL_BLUE_SCALE GL_CLIENT_ACTIVE_TEXTURE_ARB GL_CLIENT_ATTRIB_STACK_DEPTH GL_COLOR_ARRAY GL_COLOR_ARRAY_SIZE GL_COLOR_ARRAY_STRIDE GL_COLOR_ARRAY_TYPE GL_COLOR_CLEAR_VALUE GL_COLOR_LOGIC_OP GL_COLOR_MATERIAL GL_COLOR_MATERIAL_FACE GL_COLOR_MATERIAL_PARAMETER GL_COLOR_MATRIX_STACK_DEPTH GL_COLOR_WRITEMASK GL_CULL_FACE GL_CULL_FACE_MODE GL_CURRENT_COLOR GL_CURRENT_INDEX GL_CURRENT_NORMAL GL_CURRENT_RASTER_COLOR GL_CURRENT_RASTER_DISTANCE GL_CURRENT_RASTER_INDEX GL_CURRENT_RASTER_POSITION GL_CURRENT_RASTER_POSITION_VALID GL_CURRENT_RASTER_TEXTURE_COORDS GL_CURRENT_TEXTURE_COORDS GL_DEPTH_BIAS GL_DEPTH_BITS GL_DEPTH_CLEAR_VALUE GL_DEPTH_FUNC GL_DEPTH_RANGE GL_DEPTH_SCALE GL_DEPTH_TEST GL_DEPTH_WRITEMASK GL_DITHER GL_DOUBLEBUFFER GL_DRAW_BUFFER GL_EDGE_FLAG GL_EDGE_FLAG_ARRAY GL_EDGE_FLAG_ARRAY_STRIDE GL_FEEDBACK_BUFFER_SIZE GL_FEEDBACK_BUFFER_TYPE GL_FOG GL_FOG_COLOR GL_FOG_DENSITY GL_FOG_END GL_FOG_HINT GL_FOG_INDEX GL_FOG_MODE GL_FOG_START GL_FRONT_FACE GL_GREEN_BIAS GL_GREEN_BITS GL_GREEN_SCALE GL_INDEX_ARRAY GL_INDEX_ARRAY_STRIDE GL_INDEX_ARRAY_TYPE GL_INDEX_BITS GL_INDEX_CLEAR_VALUE GL_INDEX_LOGIC_OP GL_INDEX_MODE GL_INDEX_OFFSET GL_INDEX_SHIFT GL_INDEX_WRITEMASK GL_LIGHTING GL_LIGHT_MODEL_AMBIENT GL_LIGHT_MODEL_COLOR_CONTROL GL_LIGHT_MODEL_LOCAL_VIEWER GL_LIGHT_MODEL_TWO_SIDE GL_LINE_SMOOTH GL_LINE_SMOOTH_HINT GL_LINE_STIPPLE GL_LINE_STIPPLE_PATTERN GL_LINE_STIPPLE_REPEAT GL_LINE_WIDTH GL_LINE_WIDTH_GRANULARITY GL_LINE_WIDTH_RANGE GL_LIST_BASE GL_LIST_INDEX GL_LIST_MODE GL_LOGIC_OP_MODE GL_MAP1_COLOR_4 GL_MAP1_GRID_DOMAIN GL_MAP1_GRID_SEGMENTS GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP2_COLOR_4 GL_MAP2_GRID_DOMAIN GL_MAP2_GRID_SEGMENTS GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MAP_COLOR GL_MAP_STENCIL GL_MATRIX_MODE GL_MAX_3D_TEXTURE_SIZE GL_MAX_ATTRIB_STACK_DEPTH GL_MAX_CLIENT_ATTRIB_STACK_DEPTH GL_MAX_CLIP_PLANES GL_MAX_COLOR_MATRIX_STACK_DEPTH GL_MAX_ELEMENTS_INDICES GL_MAX_ELEMENTS_VERTICES GL_MAX_EVAL_ORDER GL_MAX_LIGHTS GL_MAX_LIST_NESTING GL_MAX_MODELVIEW_STACK_DEPTH GL_MAX_NAME_STACK_DEPTH GL_MAX_PIXEL_MAP_TABLE GL_MAX_PROJECTION_STACK_DEPTH GL_MAX_TEXTURE_SIZE GL_MAX_TEXTURE_STACK_DEPTH GL_MAX_TEXTURE_UNITS_ARB GL_MAX_VIEWPORT_DIMS GL_MODELVIEW_MATRIX GL_MODELVIEW_STACK_DEPTH GL_NAME_STACK_DEPTH GL_NORMAL_ARRAY GL_NORMAL_ARRAY_STRIDE GL_NORMAL_ARRAY_TYPE GL_NORMALIZE GL_PACK_ALIGNMENT GL_PACK_IMAGE_HEIGHT GL_PACK_LSB_FIRST GL_PACK_ROW_LENGTH GL_PACK_SKIP_IMAGES GL_PACK_SKIP_PIXELS GL_PACK_SKIP_ROWS GL_PACK_SWAP_BYTES GL_PERSPECTIVE_CORRECTION_HINT GL_PIXEL_MAP_A_TO_A_SIZE GL_PIXEL_MAP_B_TO_B_SIZE GL_PIXEL_MAP_G_TO_G_SIZE GL_PIXEL_MAP_I_TO_A_SIZE GL_PIXEL_MAP_I_TO_B_SIZE GL_PIXEL_MAP_I_TO_G_SIZE GL_PIXEL_MAP_I_TO_I_SIZE GL_PIXEL_MAP_I_TO_R_SIZE GL_PIXEL_MAP_R_TO_R_SIZE GL_PIXEL_MAP_S_TO_S_SIZE GL_POINT_SIZE GL_POINT_SIZE_GRANULARITY GL_POINT_SIZE_RANGE GL_POINT_SMOOTH GL_POINT_SMOOTH_HINT GL_POLYGON_MODE GL_POLYGON_OFFSET_FACTOR GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_POINT GL_POLYGON_OFFSET_UNITS GL_POLYGON_SMOOTH GL_POLYGON_SMOOTH_HINT GL_POLYGON_STIPPLE GL_PROJECTION_MATRIX GL_PROJECTION_STACK_DEPTH GL_READ_BUFFER GL_RED_BIAS GL_RED_BITS GL_RED_SCALE GL_RENDER_MODE GL_RESCALE_NORMAL GL_RGBA_MODE GL_SCISSOR_BOX GL_SCISSOR_TEST GL_SELECTION_BUFFER_SIZE GL_SHADE_MODEL GL_SMOOTH_LINE_WIDTH_GRANULARITY GL_SMOOTH_LINE_WIDTH_RANGE GL_SMOOTH_POINT_SIZE_GRANULARITY GL_SMOOTH_POINT_SIZE_RANGE GL_STENCIL_BITS GL_STENCIL_CLEAR_VALUE GL_STENCIL_FAIL GL_STENCIL_FUNC GL_STENCIL_PASS_DEPTH_FAIL GL_STENCIL_PASS_DEPTH_PASS GL_STENCIL_REF GL_STENCIL_TEST GL_STENCIL_VALUE_MASK GL_STENCIL_WRITEMASK GL_STEREO GL_SUBPIXEL_BITS GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_BINDING_1D GL_TEXTURE_BINDING_2D GL_TEXTURE_BINDING_3D GL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY_SIZE GL_TEXTURE_COORD_ARRAY_STRIDE GL_TEXTURE_COORD_ARRAY_TYPE GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_R GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_TEXTURE_MATRIX GL_TEXTURE_STACK_DEPTH GL_UNPACK_ALIGNMENT GL_UNPACK_IMAGE_HEIGHT GL_UNPACK_LSB_FIRST GL_UNPACK_ROW_LENGTH GL_UNPACK_SKIP_IMAGES GL_UNPACK_SKIP_PIXELS GL_UNPACK_SKIP_ROWS GL_UNPACK_SWAP_BYTES GL_VERTEX_ARRAY GL_VERTEX_ARRAY_SIZE GL_VERTEX_ARRAY_STRIDE GL_VERTEX_ARRAY_TYPE GL_VIEWPORT GL_ZOOM_X GL_ZOOM_Y GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_MULTISAMPLE_ARB GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_SAMPLE_ALPHA_TO_ONE_ARB GL_SAMPLE_COVERAGE_ARB GL_SAMPLE_BUFFERS_ARB GL_SAMPLES_ARB GL_SAMPLE_COVERAGE_VALUE_ARB GL_SAMPLE_COVERAGE_INVERT_ARB GL_POINT_SPRITE_ARB GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB GL_CLIP_VOLUME_CLIPPING_HINT_EXT GL_RASTER_POSITION_UNCLIPPED_IBM GL_GENERATE_MIPMAP_HINT_SGIS GL_FOG_DISTANCE_MODE_NV GL_TRANSPOSE_MODELVIEW_MATRIX_ARB GL_TRANSPOSE_PROJECTION_MATRIX_ARB GL_TRANSPOSE_TEXTURE_MATRIX_ARB GL_TRANSPOSE_COLOR_MATRIX_ARB GL_MAX_TEXTURE_LOD_BIAS_EXT GL_PER_STAGE_CONSTANTS_NV GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT GL_CURRENT_FOG_COORDINATE_EXT GL_FOG_COORDINATE_ARRAY_TYPE_EXT GL_FOG_COORDINATE_ARRAY_STRIDE_EXT GL_COLOR_SUM_EXT GL_CURRENT_SECONDARY_COLOR_EXT GL_SECONDARY_COLOR_ARRAY_SIZE_EXT GL_SECONDARY_COLOR_ARRAY_TYPE_EXT GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT GL_ARRAY_BUFFER_BINDING_ARB GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB GL_VERTEX_ARRAY_BUFFER_BINDING_ARB GL_NORMAL_ARRAY_BUFFER_BINDING_ARB GL_COLOR_ARRAY_BUFFER_BINDING_ARB GL_INDEX_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_BINDING_RECTANGLE_NV GL_MAX_RECTANGLE_TEXTURE_SIZE_NV GL_FRAMEBUFFER_BINDING_EXT GL_RENDERBUFFER_BINDING_EXT GL_MAX_COLOR_ATTACHMENTS_EXT GL_MAX_RENDERBUFFER_SIZE_EXT GL_READ_FRAMEBUFFER_BINDING_EXT GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_ACTIVE_STENCIL_FACE_EXT GL_MAX_DRAW_BUFFERS GL_DRAW_BUFFER0 GL_DRAW_BUFFER1 GL_DRAW_BUFFER2 GL_DRAW_BUFFER3 GL_DRAW_BUFFER4 GL_DRAW_BUFFER5 GL_DRAW_BUFFER6 GL_DRAW_BUFFER7 GL_DRAW_BUFFER8 GL_DRAW_BUFFER9 GL_DRAW_BUFFER10 GL_DRAW_BUFFER11 GL_DRAW_BUFFER12 GL_DRAW_BUFFER13 GL_DRAW_BUFFER14 GL_DRAW_BUFFER15 +param params GLint * +category 1.0 +props get +chromium extpack + +name GetLightfv +return void +param light GLenum +paramprop light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param params GLfloat * +category 1.0 +props get +chromium extpack + +name GetLightiv +return void +param light GLenum +paramprop light GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_POSITION GL_SPOT_DIRECTION GL_SPOT_EXPONENT GL_SPOT_CUTOFF GL_CONSTANT_ATTENUATION GL_LINEAR_ATTENUATION GL_QUADRATIC_ATTENUATION +param params GLint * +category 1.0 +props get +chromium extpack + +name GetMapdv +return void +param target GLenum +paramprop target GL_MAP1_COLOR_4 GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP2_COLOR_4 GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 +param query GLenum +paramprop query GL_COEFF GL_DOMAIN GL_ORDER +param v GLdouble * +category 1.0 +props get +chromium extpack + +name GetMapfv +return void +param target GLenum +paramprop target GL_MAP1_COLOR_4 GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP2_COLOR_4 GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 +param query GLenum +paramprop query GL_COEFF GL_DOMAIN GL_ORDER +param v GLfloat * +category 1.0 +props get +chromium extpack + +name GetMapiv +return void +param target GLenum +paramprop target GL_MAP1_COLOR_4 GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP1_VERTEX_3 GL_MAP1_VERTEX_4 GL_MAP2_COLOR_4 GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 +param query GLenum +paramprop query GL_COEFF GL_DOMAIN GL_ORDER +param v GLint * +category 1.0 +props get +chromium extpack + +name GetMaterialfv +return void +param face GLenum +paramprop face GL_FRONT GL_BACK +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_EMISSION GL_SHININESS GL_COLOR_INDEXES +param params GLfloat * +category 1.0 +props get +chromium extpack + +name GetMaterialiv +return void +param face GLenum +paramprop face GL_FRONT GL_BACK +param pname GLenum +paramprop pname GL_AMBIENT GL_DIFFUSE GL_SPECULAR GL_EMISSION GL_SHININESS GL_COLOR_INDEXES +param params GLint * +category 1.0 +props get +chromium extpack + +name GetPixelMapfv +return void +param map GLenum +paramprop map GL_PIXEL_MAP_I_TO_I GL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_I_TO_G GL_PIXEL_MAP_I_TO_B GL_PIXEL_MAP_I_TO_A GL_PIXEL_MAP_R_TO_R GL_PIXEL_MAP_G_TO_G GL_PIXEL_MAP_B_TO_B GL_PIXEL_MAP_A_TO_A +param values GLfloat * +category 1.0 +props get +chromium extpack + +name GetPixelMapuiv +return void +param map GLenum +paramprop map GL_PIXEL_MAP_I_TO_I GL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_I_TO_G GL_PIXEL_MAP_I_TO_B GL_PIXEL_MAP_I_TO_A GL_PIXEL_MAP_R_TO_R GL_PIXEL_MAP_G_TO_G GL_PIXEL_MAP_B_TO_B GL_PIXEL_MAP_A_TO_A +param values GLuint * +category 1.0 +props get +chromium extpack + +name GetPixelMapusv +return void +param map GLenum +paramprop map GL_PIXEL_MAP_I_TO_I GL_PIXEL_MAP_S_TO_S GL_PIXEL_MAP_I_TO_R GL_PIXEL_MAP_I_TO_G GL_PIXEL_MAP_I_TO_B GL_PIXEL_MAP_I_TO_A GL_PIXEL_MAP_R_TO_R GL_PIXEL_MAP_G_TO_G GL_PIXEL_MAP_B_TO_B GL_PIXEL_MAP_A_TO_A +param values GLushort * +category 1.0 +props get +chromium extpack + +name GetPolygonStipple +return void +param mask GLubyte * +category 1.0 +props get +chromium extpack + +name GetString +return const GLubyte * +param name GLenum +paramprop name GL_VENDOR GL_RENDERER GL_VERSION GL_EXTENSIONS +category 1.0 +props get +chromium extpack + +name GetTexEnvfv +return void +param target GLenum +param pname GLenum +paramset [ target pname ] [ GL_TEXTURE_ENV ] [ GL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_COLOR GL_POINT_SPRITE_ARB GL_COORD_REPLACE_ARB ] +paramset [ target pname ] [ GL_TEXTURE_FILTER_CONTROL_EXT ] [ GL_TEXTURE_LOD_BIAS_EXT ] +param params GLfloat * +category 1.0 +props get +chromium extpack + +name GetTexEnviv +return void +param target GLenum +param pname GLenum +paramset [ target pname ] [ GL_TEXTURE_ENV ] [ GL_TEXTURE_ENV_MODE GL_TEXTURE_ENV_COLOR GL_POINT_SPRITE_ARB GL_COORD_REPLACE_ARB ] +paramset [ target pname ] [ GL_TEXTURE_FILTER_CONTROL_EXT ] [ GL_TEXTURE_LOD_BIAS_EXT ] +param params GLint * +category 1.0 +props get +chromium extpack + +name GetTexGendv +return void +param coord GLenum +paramprop coord GL_S GL_T GL_R GL_Q +param pname GLenum +paramprop pname GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE +param params GLdouble * +category 1.0 +props get +chromium extpack + +name GetTexGenfv +return void +param coord GLenum +paramprop coord GL_S GL_T GL_R GL_Q +param pname GLenum +paramprop pname GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE +param params GLfloat * +category 1.0 +props get +chromium extpack + +name GetTexGeniv +return void +param coord GLenum +paramprop coord GL_S GL_T GL_R GL_Q +param pname GLenum +paramprop pname GL_TEXTURE_GEN_MODE GL_OBJECT_PLANE GL_EYE_PLANE +param params GLint * +category 1.0 +props get +chromium extpack + +name GetTexImage +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_RECTANGLE_NV +param level GLint +paramlist level 0 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels GLvoid * +paramaction pixels genTex +category 1.0 +props get pixelstore +chromium extpack + +name GetTexParameterfv +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_RECTANGLE_NV +param pname GLenum +paramprop pname GL_GENERATE_MIPMAP_SGIS GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_FILTER GL_TEXTURE_MIN_LOD GL_TEXTURE_MAX_LOD GL_TEXTURE_BASE_LEVEL GL_TEXTURE_MAX_LEVEL GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R GL_TEXTURE_BORDER_COLOR GL_TEXTURE_PRIORITY GL_TEXTURE_RESIDENT GL_TEXTURE_COMPARE_FUNC_ARB GL_TEXTURE_COMPARE_MODE_ARB GL_TEXTURE_MAX_ANISOTROPY_EXT +param params GLfloat * +paramvec params 0.0 0.0 0.0 0.0 +category 1.0 +props get +chromium extpack + +name GetTexParameteriv +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_RECTANGLE_NV +param pname GLenum +paramprop pname GL_GENERATE_MIPMAP_SGIS GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_FILTER GL_TEXTURE_MIN_LOD GL_TEXTURE_MAX_LOD GL_TEXTURE_BASE_LEVEL GL_TEXTURE_MAX_LEVEL GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R GL_TEXTURE_BORDER_COLOR GL_TEXTURE_PRIORITY GL_TEXTURE_RESIDENT GL_TEXTURE_COMPARE_FUNC_ARB GL_TEXTURE_COMPARE_MODE_ARB GL_TEXTURE_MAX_ANISOTROPY_EXT +param params GLint * +paramvec params 0 0 0 0 +category 1.0 +props get +chromium extpack + +name GetTexLevelParameterfv +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_PROXY_TEXTURE_1D GL_PROXY_TEXTURE_2D GL_PROXY_TEXTURE_3D GL_TEXTURE_RECTANGLE_NV +param level GLint +paramlist level 0 +param pname GLenum +paramprop pname GL_TEXTURE_WIDTH GL_TEXTURE_HEIGHT GL_TEXTURE_DEPTH GL_TEXTURE_INTERNAL_FORMAT GL_TEXTURE_BORDER GL_TEXTURE_RED_SIZE GL_TEXTURE_GREEN_SIZE GL_TEXTURE_BLUE_SIZE GL_TEXTURE_ALPHA_SIZE GL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_DEPTH_SIZE_ARB TEXTURE_RED_TYPE_ARB TEXTURE_GREEN_TYPE_ARB TEXTURE_BLUE_TYPE_ARB TEXTURE_ALPHA_TYPE_ARB TEXTURE_LUMINANCE_TYPE_ARB TEXTURE_INTENSITY_TYPE_ARB TEXTURE_DEPTH_TYPE_ARB +param params GLfloat * +paramvec params 0.0 0.0 0.0 0.0 +category 1.0 +props get +chromium extpack + +name GetTexLevelParameteriv +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_PROXY_TEXTURE_1D GL_PROXY_TEXTURE_2D GL_PROXY_TEXTURE_3D GL_TEXTURE_RECTANGLE_NV +param level GLint +paramlist level 0 +param pname GLenum +paramprop pname GL_TEXTURE_WIDTH GL_TEXTURE_HEIGHT GL_TEXTURE_DEPTH GL_TEXTURE_INTERNAL_FORMAT GL_TEXTURE_BORDER GL_TEXTURE_RED_SIZE GL_TEXTURE_GREEN_SIZE GL_TEXTURE_BLUE_SIZE GL_TEXTURE_ALPHA_SIZE GL_TEXTURE_LUMINANCE_SIZE GL_TEXTURE_INTENSITY_SIZE GL_TEXTURE_DEPTH_SIZE_ARB TEXTURE_RED_TYPE_ARB TEXTURE_GREEN_TYPE_ARB TEXTURE_BLUE_TYPE_ARB TEXTURE_ALPHA_TYPE_ARB TEXTURE_LUMINANCE_TYPE_ARB TEXTURE_INTENSITY_TYPE_ARB TEXTURE_DEPTH_TYPE_ARB +param params GLint * +paramvec params 0 0 0 0 +category 1.0 +props get +chromium extpack + +name IsEnabled +return GLboolean +param cap GLenum +paramprop cap GL_ALPHA_TEST GL_AUTO_NORMAL GL_BLEND GL_COLOR_ARRAY GL_COLOR_LOGIC_OP GL_COLOR_MATERIAL GL_COLOR_TABLE GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_CULL_FACE GL_DEPTH_TEST GL_DITHER GL_EDGE_FLAG_ARRAY GL_FOG GL_HISTOGRAM GL_INDEX_ARRAY GL_INDEX_LOGIC_OP GL_LIGHTING GL_LINE_SMOOTH GL_LINE_STIPPLE GL_MAP1_COLOR_4 GL_MAP1_INDEX GL_MAP1_NORMAL GL_MAP1_TEXTURE_COORD_1 GL_MAP1_TEXTURE_COORD_2 GL_MAP1_TEXTURE_COORD_3 GL_MAP1_TEXTURE_COORD_4 GL_MAP2_COLOR_4 GL_MAP2_INDEX GL_MAP2_NORMAL GL_MAP2_TEXTURE_COORD_1 GL_MAP2_TEXTURE_COORD_2 GL_MAP2_TEXTURE_COORD_3 GL_MAP2_TEXTURE_COORD_4 GL_MAP2_VERTEX_3 GL_MAP2_VERTEX_4 GL_MINMAX GL_NORMAL_ARRAY GL_NORMALIZE GL_POINT_SMOOTH GL_POLYGON_SMOOTH GL_POLYGON_OFFSET_FILL GL_POLYGON_OFFSET_LINE GL_POLYGON_OFFSET_POINT GL_POLYGON_STIPPLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_RESCALE_NORMAL GL_SCISSOR_TEST GL_SEPARABLE_2D GL_STENCIL_TEST GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D GL_TEXTURE_COORD_ARRAY GL_TEXTURE_GEN_Q GL_TEXTURE_GEN_R GL_TEXTURE_GEN_S GL_TEXTURE_GEN_T GL_VERTEX_ARRAY GL_LIGHT0 GL_LIGHT1 GL_LIGHT2 GL_LIGHT3 GL_LIGHT4 GL_LIGHT5 GL_LIGHT6 GL_LIGHT7 GL_CLIP_PLANE0 GL_CLIP_PLANE1 GL_CLIP_PLANE2 GL_CLIP_PLANE3 GL_CLIP_PLANE4 GL_CLIP_PLANE5 GL_MULTISAMPLE_ARB GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_SAMPLE_ALPHA_TO_ONE_ARB GL_SAMPLE_COVERAGE_ARB GL_POINT_SPRITE_ARB GL_RASTER_POSITION_UNCLIPPED_IBM GL_PER_STAGE_CONSTANTS_NV GL_COLOR_SUM_EXT GL_TEXTURE_RECTANGLE_NV + +category 1.0 +props get +chromium extpack + +name IsList +return GLboolean +param list GLuint +category 1.0 +props get +chromium extpack + +name DepthRange +return void +param zNear GLclampd +param zFar GLclampd +category 1.0 +chromium pack + +name Frustum +return void +param left GLdouble +paramlist left -1.0 +param right GLdouble +paramlist right 1.0 +param bottom GLdouble +paramlist bottom -1.0 +param top GLdouble +paramlist top 1.0 +param zNear GLdouble +paramlist zNear 1.0 +param zFar GLdouble +paramlist zFar 10.0 +category 1.0 +chromium pack + +name LoadIdentity +return void +category 1.0 +chromium pack + +name LoadMatrixf +return void +param m const GLfloat * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category 1.0 +chromium pack + +name LoadMatrixd +return void +param m const GLdouble * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category 1.0 +chromium pack + +name MatrixMode +return void +param mode GLenum +paramprop mode GL_MODELVIEW GL_PROJECTION GL_TEXTURE GL_COLOR +category 1.0 +chromium pack + +name MultMatrixf +return void +param m const GLfloat * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category 1.0 +chromium pack + +name MultMatrixd +return void +param m const GLdouble * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category 1.0 +chromium pack + +name Ortho +return void +param left GLdouble +param right GLdouble +param bottom GLdouble +param top GLdouble +param zNear GLdouble +param zFar GLdouble +category 1.0 +chromium pack + +name PopMatrix +return void +category 1.0 +chromium pack + +name PushMatrix +return void +category 1.0 +chromium pack + +name Rotated +return void +param angle GLdouble +param x GLdouble +param y GLdouble +param z GLdouble +category 1.0 +chromium pack + +name Rotatef +return void +param angle GLfloat +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 +chromium pack + +name Scaled +return void +param x GLdouble +param y GLdouble +param z GLdouble +category 1.0 +chromium pack + +name Scalef +return void +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 +chromium pack + +name Translated +return void +param x GLdouble +param y GLdouble +param z GLdouble +category 1.0 +chromium pack + +name Translatef +return void +param x GLfloat +param y GLfloat +param z GLfloat +category 1.0 +chromium pack + +name Viewport +return void +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category 1.0 +chromium pack + + +# OpenGL 1.1 + +name ArrayElement +return void +param i GLint +category 1.1 +props useclient +chromium pack + +name ColorPointer +return void +param size GLint +paramlist size 3 4 +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +category 1.1 +props setclient +chromium extpack + +name DisableClientState +return void +param array GLenum +paramprop array GL_COLOR_ARRAY GL_INDEX_ARRAY GL_NORMAL_ARRAY GL_TEXTURE_COORD_ARRAY GL_VERTEX_ARRAY GL_VERTEX_ATTRIB_ARRAY0_NV GL_VERTEX_ATTRIB_ARRAY1_NV GL_VERTEX_ATTRIB_ARRAY2_NV GL_VERTEX_ATTRIB_ARRAY3_NV GL_VERTEX_ATTRIB_ARRAY4_NV GL_VERTEX_ATTRIB_ARRAY5_NV GL_VERTEX_ATTRIB_ARRAY6_NV GL_VERTEX_ATTRIB_ARRAY7_NV GL_VERTEX_ATTRIB_ARRAY8_NV GL_VERTEX_ATTRIB_ARRAY9_NV GL_VERTEX_ATTRIB_ARRAY10_NV GL_VERTEX_ATTRIB_ARRAY11_NV GL_VERTEX_ATTRIB_ARRAY12_NV GL_VERTEX_ATTRIB_ARRAY13_NV GL_VERTEX_ATTRIB_ARRAY14_NV GL_VERTEX_ATTRIB_ARRAY15_NV GL_EDGE_FLAG_ARRAY GL_FOG_COORDINATE_ARRAY_POINTER_EXT GL_SECONDARY_COLOR_ARRAY_EXT GL_FOG_COORDINATE_ARRAY_EXT GL_SECONDARY_COLOR_ARRAY_EXT +category 1.1 +props setclient +chromium pack + +name DrawArrays +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param first GLint +param count GLsizei +category 1.1 +props useclient +chromium pack + +name DrawElements +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param count GLsizei +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT GL_UNSIGNED_INT +param indices const GLvoid * +category 1.1 +props useclient +chromium extpack + +name EdgeFlagPointer +return void +param stride GLsizei +param pointer const GLvoid * +category 1.1 +props setclient +chromium extpack + +name EnableClientState +return void +param array GLenum +paramprop array GL_COLOR_ARRAY GL_INDEX_ARRAY GL_NORMAL_ARRAY GL_TEXTURE_COORD_ARRAY GL_VERTEX_ARRAY GL_VERTEX_ATTRIB_ARRAY0_NV GL_VERTEX_ATTRIB_ARRAY1_NV GL_VERTEX_ATTRIB_ARRAY2_NV GL_VERTEX_ATTRIB_ARRAY3_NV GL_VERTEX_ATTRIB_ARRAY4_NV GL_VERTEX_ATTRIB_ARRAY5_NV GL_VERTEX_ATTRIB_ARRAY6_NV GL_VERTEX_ATTRIB_ARRAY7_NV GL_VERTEX_ATTRIB_ARRAY8_NV GL_VERTEX_ATTRIB_ARRAY9_NV GL_VERTEX_ATTRIB_ARRAY10_NV GL_VERTEX_ATTRIB_ARRAY11_NV GL_VERTEX_ATTRIB_ARRAY12_NV GL_VERTEX_ATTRIB_ARRAY13_NV GL_VERTEX_ATTRIB_ARRAY14_NV GL_VERTEX_ATTRIB_ARRAY15_NV GL_EDGE_FLAG_ARRAY GL_FOG_COORDINATE_ARRAY_POINTER_EXT GL_SECONDARY_COLOR_ARRAY_EXT GL_FOG_COORDINATE_ARRAY_EXT GL_SECONDARY_COLOR_ARRAY_EXT +category 1.1 +props setclient +chromium pack + +name GetPointerv +return void +param pname GLenum +paramprop pname GL_COLOR_ARRAY_POINTER GL_EDGE_FLAG_ARRAY_POINTER GL_FEEDBACK_BUFFER_POINTER GL_INDEX_ARRAY_POINTER GL_NORMAL_ARRAY_POINTER GL_TEXTURE_COORD_ARRAY_POINTER GL_SELECTION_BUFFER_POINTER GL_VERTEX_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER_EXT GL_SECONDARY_COLOR_ARRAY_POINTER_EXT +param params GLvoid ** +category 1.1 +props useclient get +chromium extpack + +name IndexPointer +return void +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +param pointer const GLvoid * +category 1.1 +props setclient +chromium extpack + +name InterleavedArrays +return void +param format GLenum +paramprop format GL_V2F GL_V3F GL_C4UB_V2F GL_C4UB_V3F GL_C3F_V3F GL_N3F_V3F GL_C4F_N3F_V3F GL_T2F_V3F GL_T4F_V4F GL_T2F_C4UB_V3F GL_T2F_C3F_V3F GL_T2F_N3F_V3F GL_T2F_C4F_N3F_V3F GL_T4F_C4F_N3F_V4F +param stride GLsizei +param pointer const GLvoid * +category 1.1 +props setclient +chromium extpack + +name NormalPointer +return void +param type GLenum +paramprop type GL_BYTE GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +param pointer const GLvoid * +category 1.1 +props setclient +chromium extpack + +name TexCoordPointer +return void +param size GLint +paramlist size 1 2 3 4 +param type GLenum +paramprop type GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +category 1.1 +props setclient +chromium extpack + +name VertexPointer +return void +param size GLint +paramlist size 2 3 4 +param type GLenum +paramprop type GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +category 1.1 +props setclient +chromium extpack + +name PolygonOffset +return void +param factor GLfloat +param units GLfloat +category 1.1 +chromium pack + +name CopyTexImage1D +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +paramlist level 0 +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_DEPTH_COMPONENT16_ARB GL_DEPTH_COMPONENT24_ARB GL_DEPTH_COMPONENT32_ARB +param x GLint +paramlist x 0 +param y GLint +paramlist y 0 +param width GLsizei +paramlist width 0 +param border GLint +paramlist border 0 +paramaction pixel enableTex +category 1.1 +chromium pack + +name CopyTexImage2D +return void +param target GLenum +paramprop target GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_NV +param level GLint +paramlist level 0 +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_DEPTH_COMPONENT16_ARB GL_DEPTH_COMPONENT24_ARB GL_DEPTH_COMPONENT32_ARB +param x GLint +paramlist x 0 +param y GLint +paramlist y 0 +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param border GLint +paramlist border 0 +paramaction pixel enableTex +category 1.1 +chromium pack + +name CopyTexSubImage1D +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +paramlist level 0 +param xoffset GLint +param x GLint +param y GLint +param width GLsizei +paramaction pixel enableTex +category 1.1 +chromium pack + +name CopyTexSubImage2D +return void +param target GLenum +paramprop target GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_NV +param level GLint +paramlist level 0 +param xoffset GLint +param yoffset GLint +param x GLint +param y GLint +param width GLsizei +param height GLsizei +paramaction pixel enableTex +category 1.1 +chromium pack + +# paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_COLOR_INDEX ] [ GL_BITMAP ] +name TexSubImage1D +return void +param target GLenum +param level GLint +paramlist level 0 +param xoffset GLint +paramlist xoffset 0 +param width GLsizei +paramlist width 4 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +paramaction pixels pixelStore +category 1.1 +props pixelstore +chromium pack + +# paramset [ target format type ] [ GL_TEXTURE_2D GL_TEXTURE_RECTANGLE_NV ] [ GL_COLOR_INDEX ] [ GL_BITMAP ] +name TexSubImage2D +return void +param target GLenum +param level GLint +paramlist level 0 +param xoffset GLint +paramlist xoffset 1 +param yoffset GLint +paramlist yoffset 1 +param width GLsizei +paramlist width 4 +param height GLsizei +paramlist height 4 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_2D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_2D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_2D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +paramaction pixels pixelStore +category 1.1 +props pixelstore +chromium pack + +name AreTexturesResident +return GLboolean +param n GLsizei +param textures const GLuint * +param residences GLboolean * +category 1.1 +props get +chromium extpack serverdependent + +name BindTexture +return void +param target GLenum +paramset [ target texture ] [ GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_1D ] [ 1 ] +paramset [ target texture ] [ GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_2D ] [ 2 ] +paramset [ target texture ] [ GL_TEXTURE_RECTANGLE_NV GL_TEXTURE_3D ] [ 3 ] +param texture GLuint +category 1.1 +chromium pack + +name DeleteTextures +return void +param n GLsizei +param textures const GLuint * +category 1.1 +props nolist +chromium pack + +name GenTextures +return void +param n GLsizei +param textures GLuint * +category 1.1 +props get +chromium extpack serverdependent + +name IsTexture +return GLboolean +param texture GLuint +category 1.1 +props get +chromium extpack + +name PrioritizeTextures +return void +param n GLsizei +param textures const GLuint * +param priorities const GLclampf * +category 1.1 +chromium pack + +name Indexub +return void +param c GLubyte +category 1.1 +props pervertex +chromium pack + +name Indexubv +return void +param c const GLubyte * +paramvec c 1 +vector c 1 +category 1.1 +props pervertex +vectoralias Indexub + +name PopClientAttrib +return void +category 1.1 +props setclient +chromium extpack + +name PushClientAttrib +return void +param mask GLbitfield +category 1.1 +props setclient +chromium extpack + + +# GL_EXT_blend_color + +name BlendColorEXT +return void +param red GLclampf +param green GLclampf +param blue GLclampf +param alpha GLclampf +category GL_EXT_blend_color +chromium extpack + + +# GL_EXT_blend_minmax + +name BlendEquationEXT +return void +param mode GLenum +paramprop mode GL_FUNC_ADD_EXT GL_MIN_EXT GL_MAX_EXT GL_FUNC_SUBTRACT_EXT GL_FUNC_REVERSE_SUBTRACT_EXT GL_FUNC_SUBTRACT_EXT GL_FUNC_REVERSE_SUBTRACT_EXT +category GL_EXT_blend_minmax +chromium extpack +# get GL_BLEND_EQUATION_EXT + + +# OpenGL 1.2 + +name BlendColor +return void +param red GLclampf +param green GLclampf +param blue GLclampf +param alpha GLclampf +category 1.2 +alias BlendColorEXT +chromium nopack + +name BlendEquation +return void +param mode GLenum +paramprop mode GL_FUNC_ADD GL_FUNC_SUBTRACT GL_FUNC_REVERSE_SUBTRACT GL_MIN GL_MAX GL_LOGIC_OP +category 1.2 +alias BlendEquationEXT +chromium nopack + +name DrawRangeElements +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param start GLuint +paramlist start 0 +param end GLuint +paramlist end 10 +param count GLsizei +paramlist count 10 +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT GL_UNSIGNED_INT +param indices const GLvoid * +category 1.2 +props useclient +chromium extpack + +name ColorTable +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_PROXY_COLOR_TABLE GL_PROXY_POST_CONVOLUTION_COLOR_TABLE GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param width GLsizei +paramlist width 256 +param format GLenum +paramprop format GL_COLOR_INDEX GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_2_BYTES GL_3_BYTES GL_4_BYTES +param table const GLvoid * +category 1.2 +chromium stub checklist + +name ColorTableParameterfv +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param pname GLenum +paramprop pname GL_COLOR_TABLE_SCALE GL_COLOR_TABLE_BIAS +param params const GLfloat * +category 1.2 +chromium stub + +name ColorTableParameteriv +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param pname GLenum +paramprop pname GL_COLOR_TABLE_SCALE GL_COLOR_TABLE_BIAS +param params const GLint * +category 1.2 +chromium stub + +name CopyColorTable +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param x GLint +param y GLint +param width GLsizei +category 1.2 +chromium stub + +name GetColorTable +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param table GLvoid * +category 1.2 +props get +chromium stub + +name GetColorTableParameterfv +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_PROXY_COLOR_TABLE GL_PROXY_POST_CONVOLUTION_COLOR_TABLE GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE +param pname GLenum +paramprop pname GL_COLOR_TABLE_BIAS GL_COLOR_TABLE_SCALE GL_COLOR_TABLE_FORMAT GL_COLOR_TABLE_WIDTH GL_COLOR_TABLE_RED_SIZE GL_COLOR_TABLE_GREEN_SIZE GL_COLOR_TABLE_BLUE_SIZE GL_COLOR_TABLE_ALPHA_SIZE GL_COLOR_TABLE_LUMINANCE_SIZE GL_COLOR_TABLE_INTENSITY_SIZE +param params GLfloat * +category 1.2 +props get +chromium stub + +name GetColorTableParameteriv +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_PROXY_COLOR_TABLE GL_PROXY_POST_CONVOLUTION_COLOR_TABLE GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE +param pname GLenum +paramprop pname GL_COLOR_TABLE_BIAS GL_COLOR_TABLE_SCALE GL_COLOR_TABLE_FORMAT GL_COLOR_TABLE_WIDTH GL_COLOR_TABLE_RED_SIZE GL_COLOR_TABLE_GREEN_SIZE GL_COLOR_TABLE_BLUE_SIZE GL_COLOR_TABLE_ALPHA_SIZE GL_COLOR_TABLE_LUMINANCE_SIZE GL_COLOR_TABLE_INTENSITY_SIZE +param params GLint * +category 1.2 +props get +chromium stub + +name ColorSubTable +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param start GLsizei +param count GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param data const GLvoid * +category 1.2 +chromium stub + +name CopyColorSubTable +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param start GLsizei +param x GLint +param y GLint +param width GLsizei +category 1.2 +chromium stub + +name ConvolutionFilter1D +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_INTENSITY GL_RGB GL_RGBA +param width GLsizei +param format GLenum +paramprop format GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param image const GLvoid * +category 1.2 +chromium stub + +name ConvolutionFilter2D +return void +param target GLenum +paramprop target GL_CONVOLUTION_2D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param width GLsizei +param height GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +param image const GLvoid * +category 1.2 +chromium stub + +name ConvolutionParameterf +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE +param params GLfloat +category 1.2 +chromium stub + +name ConvolutionParameterfv +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS +param params const GLfloat * +category 1.2 +chromium stub + +name ConvolutionParameteri +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE +param params GLint +category 1.2 +chromium stub + +name ConvolutionParameteriv +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS +param params const GLint * +category 1.2 +chromium stub + +name CopyConvolutionFilter1D +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param x GLint +param y GLint +param width GLsizei +category 1.2 +chromium stub + +name CopyConvolutionFilter2D +return void +param target GLenum +paramprop target GL_CONVOLUTION_2D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category 1.2 +chromium stub + +name GetConvolutionFilter +return void +param target GLenum +paramprop target GL_CONVOLUTION_2D GL_CONVOLUTION_1D +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param image GLvoid * +category 1.2 +props get +chromium stub + +name GetConvolutionParameterfv +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS GL_CONVOLUTION_FORMAT GL_CONVOLUTION_WIDTH GL_CONVOLUTION_HEIGHT GL_MAX_CONVOLUTION_WIDTH GL_MAX_CONVOLUTION_HEIGHT +param params GLfloat * +category 1.2 +props get +chromium stub + +name GetConvolutionParameteriv +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS GL_CONVOLUTION_FORMAT GL_CONVOLUTION_WIDTH GL_CONVOLUTION_HEIGHT GL_MAX_CONVOLUTION_WIDTH GL_MAX_CONVOLUTION_HEIGHT +param params GLint * +category 1.2 +props get +chromium stub + +name GetSeparableFilter +return void +param target GLenum +paramprop target GL_SEPARABLE_2D +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param row GLvoid * +param column GLvoid * +param span GLvoid * +category 1.2 +props get +chromium stub + +name SeparableFilter2D +return void +param target GLenum +paramprop target GL_SEPARABLE_2D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param width GLsizei +param height GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param row const GLvoid * +param column const GLvoid * +category 1.2 +props get +chromium stub + +name GetHistogram +return void +param target GLenum +paramprop target GL_HISTOGRAM +param reset GLboolean +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param values GLvoid * +category 1.2 +props get +chromium stub + +name GetHistogramParameterfv +return void +param target GLenum +paramprop target GL_HISTOGRAM GL_PROXY_HISTOGRAM +param pname GLenum +paramprop pname GL_HISTOGRAM_WIDTH GL_HISTOGRAM_FORMAT GL_HISTOGRAM_RED_SIZE GL_HISTOGRAM_GREEN_SIZE GL_HISTOGRAM_BLUE_SIZE GL_HISTOGRAM_ALPHA_SIZE GL_HISTOGRAM_LUMINANCE_SIZE GL_HISTOGRAM_SINK +param params GLfloat * +category 1.2 +props get +chromium stub + +name GetHistogramParameteriv +return void +param target GLenum +paramprop target GL_HISTOGRAM GL_PROXY_HISTOGRAM +param pname GLenum +paramprop pname GL_HISTOGRAM_WIDTH GL_HISTOGRAM_FORMAT GL_HISTOGRAM_RED_SIZE GL_HISTOGRAM_GREEN_SIZE GL_HISTOGRAM_BLUE_SIZE GL_HISTOGRAM_ALPHA_SIZE GL_HISTOGRAM_LUMINANCE_SIZE GL_HISTOGRAM_SINK +param params GLint * +category 1.2 +props get +chromium stub + +name GetMinmax +return void +param target GLenum +paramprop target GL_MINMAX +param reset GLboolean +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param values GLvoid * +category 1.2 +props get +chromium stub + +name GetMinmaxParameterfv +return void +param target GLenum +paramprop target GL_MINMAX +param pname GLenum +paramprop pname GL_MINMAX_FORMAT GL_MINMAX_SINK +param params GLfloat * +category 1.2 +props get +chromium stub + +name GetMinmaxParameteriv +return void +param target GLenum +paramprop target GL_MINMAX +param pname GLenum +paramprop pname GL_MINMAX_FORMAT GL_MINMAX_SINK +param params GLint * +category 1.2 +props get +chromium stub + +name Histogram +return void +param target GLenum +paramprop target GL_HISTOGRAM GL_PROXY_HISTOGRAM +param width GLsizei +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param sink GLboolean +category 1.2 +chromium stub checklist + +name Minmax +return void +param target GLenum +paramprop target GL_MINMAX +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param sink GLboolean +category 1.2 +chromium stub + +name ResetHistogram +return void +param target GLenum +paramprop target GL_HISTOGRAM +category 1.2 +chromium stub + +name ResetMinmax +return void +param target GLenum +paramprop target GL_MINMAX +category 1.2 +chromium stub + +name TexImage3D +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +paramlist level 0 +param internalFormat GLint +paramlist internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_COMPRESSED_ALPHA_ARB GL_COMPRESSED_LUMINANCE_ARB GL_COMPRESSED_LUMINANCE_ALPHA_ARB GL_COMPRESSED_INTENSITY_ARB GL_COMPRESSED_RGB_ARB GL_COMPRESSED_RGBA_ARB RGBA32F_ARB RGB32F_ARB ALPHA32F_ARB INTENSITY32F_ARB LUMINANCE32F_ARB LUMINANCE_ALPHA32F_ARB RGBA16F_ARB RGB16F_ARB ALPHA16F_ARB INTENSITY16F_ARB LUMINANCE16F_ARB LUMINANCE_ALPHA16F_ARB +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param depth GLsizei +paramlist depth 8 +param border GLint +paramlist border 0 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +paramaction pixels makeStripeImage +category 1.2 +props pixelstore +chromium pack checklist + +# paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_COLOR_INDEX ] [ GL_BITMAP ] +name TexSubImage3D +return void +param target GLenum +param level GLint +paramlist level 0 +param xoffset GLint +paramlist xoffset 1 +param yoffset GLint +paramlist yoffset 1 +param zoffset GLint +paramlist zoffset 1 +param width GLsizei +paramlist width 2 +param height GLsizei +paramlist height 2 +param depth GLsizei +paramlist depth 2 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +paramaction pixels pixelStore +category 1.2 +props pixelstore +chromium pack + +name CopyTexSubImage3D +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +param xoffset GLint +param yoffset GLint +param zoffset GLint +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category 1.2 +chromium pack + + +# GL_ARB_multitexture + +name ActiveTextureARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0_ARB GL_TEXTURE1_ARB GL_TEXTURE2_ARB GL_TEXTURE3_ARB GL_TEXTURE4_ARB GL_TEXTURE5_ARB GL_TEXTURE6_ARB GL_TEXTURE7_ARB GL_TEXTURE8_ARB GL_TEXTURE9_ARB GL_TEXTURE10_ARB GL_TEXTURE11_ARB GL_TEXTURE12_ARB GL_TEXTURE13_ARB GL_TEXTURE14_ARB GL_TEXTURE15_ARB GL_TEXTURE16_ARB GL_TEXTURE17_ARB GL_TEXTURE18_ARB GL_TEXTURE19_ARB GL_TEXTURE20_ARB GL_TEXTURE21_ARB GL_TEXTURE22_ARB GL_TEXTURE23_ARB GL_TEXTURE24_ARB GL_TEXTURE25_ARB GL_TEXTURE26_ARB GL_TEXTURE27_ARB GL_TEXTURE28_ARB GL_TEXTURE29_ARB GL_TEXTURE30_ARB GL_TEXTURE31_ARB +category GL_ARB_multitexture +chromium extpack + +name ClientActiveTextureARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0_ARB GL_TEXTURE1_ARB GL_TEXTURE2_ARB GL_TEXTURE3_ARB GL_TEXTURE4_ARB GL_TEXTURE5_ARB GL_TEXTURE6_ARB GL_TEXTURE7_ARB GL_TEXTURE8_ARB GL_TEXTURE9_ARB GL_TEXTURE10_ARB GL_TEXTURE11_ARB GL_TEXTURE12_ARB GL_TEXTURE13_ARB GL_TEXTURE14_ARB GL_TEXTURE15_ARB GL_TEXTURE16_ARB GL_TEXTURE17_ARB GL_TEXTURE18_ARB GL_TEXTURE19_ARB GL_TEXTURE20_ARB GL_TEXTURE21_ARB GL_TEXTURE22_ARB GL_TEXTURE23_ARB GL_TEXTURE24_ARB GL_TEXTURE25_ARB GL_TEXTURE26_ARB GL_TEXTURE27_ARB GL_TEXTURE28_ARB GL_TEXTURE29_ARB GL_TEXTURE30_ARB GL_TEXTURE31_ARB +category GL_ARB_multitexture +props setclient +chromium extpack + +name MultiTexCoord1dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +paramlist s 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord1dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLdouble * +paramvec t 1.0 +vector t 1 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord1dARB + +name MultiTexCoord1fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +paramlist s 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord1fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLfloat * +paramvec t 1.0 +vector t 1 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord1fARB + +name MultiTexCoord1iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +paramlist s 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord1ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLint * +paramvec t 1 +vector t 1 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord1iARB + +name MultiTexCoord1sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +paramlist s 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord1svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLshort * +paramvec t 1 +vector t 1 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord1sARB + +name MultiTexCoord2dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +paramlist s 0 .5 1 +param t GLdouble +paramlist t 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord2dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLdouble * +paramvec t 1.0 1.0 +vector t 2 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord2dARB + +name MultiTexCoord2fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +paramlist s 0 .5 1 +param t GLfloat +paramlist t 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord2fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLfloat * +paramvec t 1.0 1.0 +vector t 2 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord2fARB + +name MultiTexCoord2iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +paramlist s 0 .5 1 +param t GLint +paramlist t 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord2ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLint * +paramvec t 1 1 +vector t 2 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord2iARB + +name MultiTexCoord2sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +paramlist s 0 .5 1 +param t GLshort +paramlist t 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord2svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLshort * +paramvec t 1 1 +vector t 2 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord2sARB + +name MultiTexCoord3dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +paramlist s 0 .5 1 +param t GLdouble +paramlist t 0 .5 1 +param r GLdouble +paramlist r 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord3dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLdouble * +paramvec t 1.0 1.0 1.0 +vector t 3 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord3dARB + +name MultiTexCoord3fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +paramlist s 0 .5 1 +param t GLfloat +paramlist t 0 .5 1 +param r GLfloat +paramlist r 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord3fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLfloat * +paramvec t 1.0 1.0 1.0 +vector t 3 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord3fARB + +name MultiTexCoord3iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +paramlist s 0 1 +param t GLint +paramlist t 0 1 +param r GLint +paramlist r 0 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord3ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLint * +paramvec t 1 1 1 +vector t 3 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord3iARB + +name MultiTexCoord3sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +paramlist s 0 1 +param t GLshort +paramlist t 0 1 +param r GLshort +paramlist r 0 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord3svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLshort * +paramvec t 1 1 1 +vector t 3 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord3sARB + +name MultiTexCoord4dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +paramlist s 0 .5 1 +param t GLdouble +paramlist t 0 .5 1 +param r GLdouble +paramlist r 0 .5 1 +param q GLdouble +paramlist q 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord4dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLdouble * +paramvec t 1.0 1.0 1.0 1.0 +vector t 4 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord4dARB + +name MultiTexCoord4fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +paramlist s 0 .5 1 +param t GLfloat +paramlist t 0 .5 1 +param r GLfloat +paramlist r 0 .5 1 +param q GLfloat +paramlist q 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord4fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLfloat * +paramvec t 1.0 1.0 1.0 1.0 +vector t 4 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord4fARB + +name MultiTexCoord4iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +paramlist s 0 .5 1 +param t GLint +paramlist t 0 .5 1 +param r GLint +paramlist r 0 .5 1 +param q GLint +paramlist q 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord4ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLint * +paramvec t 1 1 1 1 +vector t 4 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord4iARB + +name MultiTexCoord4sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +paramlist s 0 .5 1 +param t GLshort +paramlist t 0 .5 1 +param r GLshort +paramlist r 0 .5 1 +param q GLshort +paramlist q 0 .5 1 +category GL_ARB_multitexture +props pervertex +chromium pack + +name MultiTexCoord4svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param t const GLshort * +paramvec t 1 1 1 1 +vector t 4 +category GL_ARB_multitexture +props pervertex +vectoralias MultiTexCoord4sARB + + +# GL_ARB_transpose_matrix + +name LoadTransposeMatrixfARB +return void +param m const GLfloat * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category GL_ARB_transpose_matrix +chromium extpack + +name LoadTransposeMatrixdARB +return void +param m const GLdouble * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category GL_ARB_transpose_matrix +chromium extpack + +name MultTransposeMatrixfARB +return void +param m const GLfloat * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category GL_ARB_transpose_matrix +chromium extpack + +name MultTransposeMatrixdARB +return void +param m const GLdouble * +paramvec m 1 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 +vector m 16 +category GL_ARB_transpose_matrix +chromium extpack + + +# GL_ARB_multisample + +name SampleCoverageARB +return void +param value GLclampf +param invert GLboolean +category GL_ARB_multisample +chromium extpack + +name __unused413 +return void +category unused +chromium omit + + +# GL_ARB_texture_compression + +name CompressedTexImage3DARB +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +paramlist level 0 +param internalFormat GLenum +paramprop internalFormat GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param depth GLsizei +paramlist depth 2 +param border GLint +paramlist border 0 +param imagesize GLsizei +paramlist imagesize 8 +param data const GLvoid * +paramaction data pixelStore +category GL_ARB_texture_compression +chromium extpack checklist + +name CompressedTexImage2DARB +return void +param target GLenum +paramprop target GL_TEXTURE_2D +param level GLint +paramlist level 0 +param internalFormat GLenum +paramprop internalFormat GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param border GLint +paramlist border 0 +param imagesize GLsizei +paramlist imagesize 8 +param data const GLvoid * +paramaction data pixelStore +category GL_ARB_texture_compression +chromium extpack checklist + +name CompressedTexImage1DARB +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +param internalFormat GLenum +paramprop internalFormat GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param width GLsizei +paramlist width 8 +param border GLint +paramlist border 1 +param imagesize GLsizei +paramlist imagesize 8 +param data const GLvoid * +paramaction data pixelStore +category GL_ARB_texture_compression +chromium extpack checklist + +name CompressedTexSubImage3DARB +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +paramlist level 0 +param xoffset GLint +paramlist xoffset 0 +param yoffset GLint +param zoffset GLint +paramlist yoffset 0 +paramlist zoffset 0 +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param depth GLsizei +paramlist depth 8 +param format GLenum +paramprop format GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param imagesize GLsizei +paramlist imagesize 8 +param data const GLvoid * +paramaction data pixelStore +category GL_ARB_texture_compression +chromium extpack + +name CompressedTexSubImage2DARB +return void +param target GLenum +paramprop target GL_TEXTURE_2D +param level GLint +param xoffset GLint +param yoffset GLint +param width GLsizei +param height GLsizei +param format GLenum +paramprop format GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param imagesize GLsizei +param data const GLvoid * +paramaction data pixelStore +category GL_ARB_texture_compression +chromium extpack + +name CompressedTexSubImage1DARB +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +paramlist level 0 +param xoffset GLint +paramlist xoffset 0 +param width GLsizei +paramlist width 8 +param format GLenum +paramprop format GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param imagesize GLsizei +paramlist imagesize 8 +param data const GLvoid * +paramaction data pixelStore +category GL_ARB_texture_compression +chromium extpack + +name GetCompressedTexImageARB +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D +param level GLint +param img GLvoid * +paramaction img pixelStore +category GL_ARB_texture_compression +props get +chromium extpack serverdependent + + +# OpenGL 1.3 + +name ActiveTexture +alias ActiveTextureARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0_ARB GL_TEXTURE1_ARB GL_TEXTURE2_ARB GL_TEXTURE3_ARB GL_TEXTURE4_ARB GL_TEXTURE5_ARB GL_TEXTURE6_ARB GL_TEXTURE7_ARB GL_TEXTURE8_ARB GL_TEXTURE9_ARB GL_TEXTURE10_ARB GL_TEXTURE11_ARB GL_TEXTURE12_ARB GL_TEXTURE13_ARB GL_TEXTURE14_ARB GL_TEXTURE15_ARB GL_TEXTURE16_ARB GL_TEXTURE17_ARB GL_TEXTURE18_ARB GL_TEXTURE19_ARB GL_TEXTURE20_ARB GL_TEXTURE21_ARB GL_TEXTURE22_ARB GL_TEXTURE23_ARB GL_TEXTURE24_ARB GL_TEXTURE25_ARB GL_TEXTURE26_ARB GL_TEXTURE27_ARB GL_TEXTURE28_ARB GL_TEXTURE29_ARB GL_TEXTURE30_ARB GL_TEXTURE31_ARB +category 1.3 +chromium nopack + +name ClientActiveTexture +alias ClientActiveTextureARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0_ARB GL_TEXTURE1_ARB GL_TEXTURE2_ARB GL_TEXTURE3_ARB GL_TEXTURE4_ARB GL_TEXTURE5_ARB GL_TEXTURE6_ARB GL_TEXTURE7_ARB GL_TEXTURE8_ARB GL_TEXTURE9_ARB GL_TEXTURE10_ARB GL_TEXTURE11_ARB GL_TEXTURE12_ARB GL_TEXTURE13_ARB GL_TEXTURE14_ARB GL_TEXTURE15_ARB GL_TEXTURE16_ARB GL_TEXTURE17_ARB GL_TEXTURE18_ARB GL_TEXTURE19_ARB GL_TEXTURE20_ARB GL_TEXTURE21_ARB GL_TEXTURE22_ARB GL_TEXTURE23_ARB GL_TEXTURE24_ARB GL_TEXTURE25_ARB GL_TEXTURE26_ARB GL_TEXTURE27_ARB GL_TEXTURE28_ARB GL_TEXTURE29_ARB GL_TEXTURE30_ARB GL_TEXTURE31_ARB +category 1.3 +props setclient +chromium nopack + +name MultiTexCoord1d +alias MultiTexCoord1dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +category 1.3 +chromium nopack + +name MultiTexCoord1dv +alias MultiTexCoord1dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLdouble * +category 1.3 + +name MultiTexCoord1f +alias MultiTexCoord1fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +category 1.3 + +name MultiTexCoord1fv +alias MultiTexCoord1fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLfloat * +category 1.3 + +name MultiTexCoord1i +alias MultiTexCoord1iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +category 1.3 + +name MultiTexCoord1iv +alias MultiTexCoord1ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLint * +category 1.3 + +name MultiTexCoord1s +alias MultiTexCoord1sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +category 1.3 + +name MultiTexCoord1sv +alias MultiTexCoord1svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLshort * +category 1.3 + +name MultiTexCoord2d +alias MultiTexCoord2dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +param t GLdouble +category 1.3 + +name MultiTexCoord2dv +alias MultiTexCoord2dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLdouble * +category 1.3 + +name MultiTexCoord2f +alias MultiTexCoord2fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +param t GLfloat +category 1.3 + +name MultiTexCoord2fv +alias MultiTexCoord2fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLfloat * +category 1.3 + +name MultiTexCoord2i +alias MultiTexCoord2iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +param t GLint +category 1.3 + +name MultiTexCoord2iv +alias MultiTexCoord2ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLint * +category 1.3 + +name MultiTexCoord2s +alias MultiTexCoord2sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +param t GLshort +category 1.3 + +name MultiTexCoord2sv +alias MultiTexCoord2svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLshort * +category 1.3 + +name MultiTexCoord3d +alias MultiTexCoord3dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +param t GLdouble +param r GLdouble +category 1.3 + +name MultiTexCoord3dv +alias MultiTexCoord3dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLdouble * +category 1.3 + +name MultiTexCoord3f +alias MultiTexCoord3fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +param t GLfloat +param r GLfloat +category 1.3 + +name MultiTexCoord3fv +alias MultiTexCoord3fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLfloat * +category 1.3 + +name MultiTexCoord3i +alias MultiTexCoord3iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +param t GLint +param r GLint +category 1.3 + +name MultiTexCoord3iv +alias MultiTexCoord3ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLint * +category 1.3 + +name MultiTexCoord3s +alias MultiTexCoord3sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +param t GLshort +param r GLshort +category 1.3 + +name MultiTexCoord3sv +alias MultiTexCoord3svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLshort * +category 1.3 + +name MultiTexCoord4d +alias MultiTexCoord4dARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLdouble +param t GLdouble +param r GLdouble +param q GLdouble +category 1.3 + +name MultiTexCoord4dv +alias MultiTexCoord4dvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLdouble * +category 1.3 + +name MultiTexCoord4f +alias MultiTexCoord4fARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLfloat +param t GLfloat +param r GLfloat +param q GLfloat +category 1.3 + +name MultiTexCoord4fv +alias MultiTexCoord4fvARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLfloat * +category 1.3 + +name MultiTexCoord4i +alias MultiTexCoord4iARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLint +param t GLint +param r GLint +param q GLint +category 1.3 + +name MultiTexCoord4iv +alias MultiTexCoord4ivARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLint * +category 1.3 + +name MultiTexCoord4s +alias MultiTexCoord4sARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param s GLshort +param t GLshort +param r GLshort +param q GLshort +category 1.3 + +name MultiTexCoord4sv +alias MultiTexCoord4svARB +return void +param texture GLenum +paramprop texture GL_TEXTURE0 GL_TEXTURE1 GL_TEXTURE2 GL_TEXTURE3 GL_TEXTURE4 GL_TEXTURE5 GL_TEXTURE6 GL_TEXTURE7 +param v const GLshort * +category 1.3 + +name LoadTransposeMatrixf +alias LoadTransposeMatrixfARB +return void +param m const GLfloat * +category 1.3 + +name LoadTransposeMatrixd +alias LoadTransposeMatrixdARB +return void +param m const GLdouble * +category 1.3 + +name MultTransposeMatrixf +alias MultTransposeMatrixfARB +return void +param m const GLfloat * +category 1.3 + +name MultTransposeMatrixd +alias MultTransposeMatrixdARB +return void +param m const GLdouble * +category 1.3 + +name SampleCoverage +alias SampleCoverageARB +return void +param value GLclampf +param invert GLboolean +category 1.3 + +name CompressedTexImage3D +alias CompressedTexImage3DARB +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +param internalFormat GLenum +paramprop internalFormat GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param width GLsizei +param height GLsizei +param depth GLsizei +param border GLint +paramlist border 1 +param imageSize GLsizei +param data const GLvoid * +category 1.3 +chromium checklist + +name CompressedTexImage2D +alias CompressedTexImage2DARB +return void +param target GLenum +paramprop target GL_TEXTURE_2D +param level GLint +param internalFormat GLenum +paramprop internalFormat GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param width GLsizei +param height GLsizei +param border GLint +paramlist border 1 +param imageSize GLsizei +param data const GLvoid * +category 1.3 +chromium checklist + +name CompressedTexImage1D +alias CompressedTexImage1DARB +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +param internalFormat GLenum +paramprop internalFormat GL_COMPRESSED_RGB_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT1_EXT GL_COMPRESSED_RGBA_S3TC_DXT3_EXT GL_COMPRESSED_RGBA_S3TC_DXT5_EXT GL_COMPRESSED_RGB_FXT1_3DFX GL_COMPRESSED_RGBA_FXT1_3DFX +param width GLsizei +param border GLint +paramlist border 1 +param imageSize GLsizei +param data const GLvoid * +category 1.3 +chromium checklist + +name CompressedTexSubImage3D +alias CompressedTexSubImage3DARB +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +param xoffset GLint +param yoffset GLint +param zoffset GLint +param width GLsizei +param height GLsizei +param depth GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param imageSize GLsizei +param data const GLvoid * +category 1.3 + +name CompressedTexSubImage2D +alias CompressedTexSubImage2DARB +return void +param target GLenum +paramprop target GL_TEXTURE_2D +param level GLint +param xoffset GLint +param yoffset GLint +param width GLsizei +param height GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param imageSize GLsizei +param data const GLvoid * +category 1.3 + +name CompressedTexSubImage1D +alias CompressedTexSubImage1DARB +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +param xoffset GLint +param width GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param imageSize GLsizei +param data const GLvoid * +category 1.3 + +name GetCompressedTexImage +alias GetCompressedTexImageARB +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D +param level GLint +param img GLvoid * +category 1.3 +props get + + +# GL_EXT_polygon_offset + +name PolygonOffsetEXT +return void +param factor GLfloat +param bias GLfloat +category GL_EXT_polygon_offset +chromium omit + + +# GL_EXT_texture3D + +name TexImage3DEXT +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +paramlist level 0 +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param width GLsizei +paramlist width 8 +param height GLsizei +paramlist height 8 +param depth GLsizei +paramlist depth 16 +param border GLint +paramlist border 1 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +category GL_EXT_texture3D +props pixelstore +chromium pack checklist + +name TexSubImage3DEXT +alias TexSubImage3D +return void +param target GLenum +param level GLint +paramlist level 0 +param xoffset GLint +paramlist xoffset 1 +param yoffset GLint +paramlist yoffset 1 +param zoffset GLint +paramlist zoffset 1 +param width GLsizei +paramlist width 2 +param height GLsizei +paramlist height 2 +param depth GLsizei +paramlist depth 2 +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_3D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +category GL_EXT_texture3D +props pixelstore + + +# GL_EXT_subtexture +# paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_COLOR_INDEX ] [ GL_BITMAP ] +name TexSubImage1DEXT +alias TexSubImage1D +return void +param target GLenum +param level GLint +param xoffset GLint +param width GLsizei +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +category GL_EXT_subtexture +props pixelstore + +# paramset [ target format type ] [ GL_TEXTURE_2D ] [ GL_COLOR_INDEX ] [ GL_BITMAP ] +name TexSubImage2DEXT +alias TexSubImage2D +return void +param target GLenum +param level GLint +param xoffset GLint +param yoffset GLint +param width GLsizei +param height GLsizei +param format GLenum +param type GLenum +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_BGR GL_LUMINANCE GL_LUMINANCE_ALPHA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGB ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV ] +paramset [ target format type ] [ GL_TEXTURE_1D ] [ GL_RGBA GL_BGRA ] [ GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV ] +param pixels const GLvoid * +category GL_EXT_subtexture +props pixelstore + +name CopyTexImage1DEXT +alias CopyTexImage1D +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_COMPRESSED_ALPHA_ARB GL_COMPRESSED_LUMINANCE_ARB GL_COMPRESSED_LUMINANCE_ALPHA_ARB GL_COMPRESSED_INTENSITY_ARB GL_COMPRESSED_RGB_ARB GL_COMPRESSED_RGBA_ARB +param x GLint +param y GLint +param width GLsizei +param border GLint +paramlist border 1 +category GL_EXT_copy_texture + +name CopyTexImage2DEXT +alias CopyTexImage2D +return void +param target GLenum +paramprop target GL_TEXTURE_2D +param level GLint +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_COMPRESSED_ALPHA_ARB GL_COMPRESSED_LUMINANCE_ARB GL_COMPRESSED_LUMINANCE_ALPHA_ARB GL_COMPRESSED_INTENSITY_ARB GL_COMPRESSED_RGB_ARB GL_COMPRESSED_RGBA_ARB +paramprop pname GL_TEXTURE_MAG_FILTER GL_TEXTURE_MIN_FILTER GL_TEXTURE_MIN_LOD GL_TEXTURE_MAX_LOD GL_TEXTURE_BASE_LEVEL GL_TEXTURE_MAX_LEVEL GL_TEXTURE_WRAP_S GL_TEXTURE_WRAP_T GL_TEXTURE_WRAP_R GL_TEXTURE_BORDER_COLOR GL_TEXTURE_PRIORITY GL_TEXTURE_RESIDENT GL_TEXTURE_COMPARE_FUNC_ARB GL_TEXTURE_COMPARE_MODE_ARB +param x GLint +param y GLint +param width GLsizei +param height GLsizei +param border GLint +paramlist border 1 +category GL_EXT_copy_texture + +name CopyTexSubImage1DEXT +alias CopyTexSubImage1D +return void +param target GLenum +paramprop target GL_TEXTURE_1D +param level GLint +param xoffset GLint +param x GLint +param y GLint +param width GLsizei +category GL_EXT_copy_texture + +name CopyTexSubImage2DEXT +alias CopyTexSubImage2D +return void +param target GLenum +paramprop target GL_TEXTURE_2D +param level GLint +param xoffset GLint +param yoffset GLint +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category GL_EXT_copy_texture + +name CopyTexSubImage3DEXT +alias CopyTexSubImage3D +return void +param target GLenum +paramprop target GL_TEXTURE_3D +param level GLint +param xoffset GLint +param yoffset GLint +param zoffset GLint +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category GL_EXT_copy_texture + + +# GL_EXT_histogram + +name GetHistogramEXT +return void +param target GLenum +paramprop target GL_HISTOGRAM +param reset GLboolean +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param values GLvoid * +category GL_EXT_histogram +props get +chromium omit + +name GetHistogramParameterfvEXT +return void +param target GLenum +paramprop target GL_HISTOGRAM GL_PROXY_HISTOGRAM +param pname GLenum +paramprop pname GL_HISTOGRAM_WIDTH GL_HISTOGRAM_FORMAT GL_HISTOGRAM_RED_SIZE GL_HISTOGRAM_GREEN_SIZE GL_HISTOGRAM_BLUE_SIZE GL_HISTOGRAM_ALPHA_SIZE GL_HISTOGRAM_LUMINANCE_SIZE GL_HISTOGRAM_SINK +param params GLfloat * +category GL_EXT_histogram +props get +chromium omit + +name GetHistogramParameterivEXT +return void +param target GLenum +paramprop target` GL_HISTOGRAM GL_PROXY_HISTOGRAM +param pname GLenum +paramprop pname GL_HISTOGRAM_WIDTH GL_HISTOGRAM_FORMAT GL_HISTOGRAM_RED_SIZE GL_HISTOGRAM_GREEN_SIZE GL_HISTOGRAM_BLUE_SIZE GL_HISTOGRAM_ALPHA_SIZE GL_HISTOGRAM_LUMINANCE_SIZE GL_HISTOGRAM_SINK +param params GLint * +category GL_EXT_histogram +props get +chromium omit + +name GetMinmaxEXT +return void +param target GLenum +paramprop target GL_MINMAX +param reset GLboolean +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param values GLvoid * +category GL_EXT_histogram +props get +chromium omit + +name GetMinmaxParameterfvEXT +return void +param target GLenum +paramprop target GL_MINMAX +param pname GLenum +paramprop pname GL_MINMAX_FORMAT GL_MINMAX_SINK +param params GLfloat * +category GL_EXT_histogram +props get +chromium omit + +name GetMinmaxParameterivEXT +return void +param target GLenum +paramprop target GL_MINMAX +param pname GLenum +paramprop pname GL_MINMAX_FORMAT GL_MINMAX_SINK +param params GLint * +category GL_EXT_histogram +props get +chromium omit + +name HistogramEXT +alias Histogram +return void +param target GLenum +paramprop target GL_HISTOGRAM GL_PROXY_HISTOGRAM +param width GLsizei +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param sink GLboolean +category GL_EXT_histogram +chromium omit checklist + +name MinmaxEXT +alias Minmax +return void +param target GLenum +paramprop target GL_MINMAX +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param sink GLboolean +category GL_EXT_histogram +chromium omit + +name ResetHistogramEXT +alias ResetHistogram +return void +param target GLenum +paramprop target GL_HISTOGRAM +category GL_EXT_histogram +chromium omit + +name ResetMinmaxEXT +alias ResetMinmax +return void +param target GLenum +paramprop target GL_MINMAX +category GL_EXT_histogram +chromium omit + +name ConvolutionFilter1DEXT +alias ConvolutionFilter1D +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_INTENSITY GL_RGB GL_RGBA +param width GLsizei +param format GLenum +paramprop format GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param image const GLvoid * +category GL_EXT_convolution +chromium omit + +name ConvolutionFilter2DEXT +alias ConvolutionFilter2D +return void +param target GLenum +paramprop target GL_CONVOLUTION_2D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param width GLsizei +param height GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT +param image const GLvoid * +category GL_EXT_convolution +chromium omit + +name ConvolutionParameterfEXT +alias ConvolutionParameterf +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE +param params GLfloat +category GL_EXT_convolution +chromium omit + +name ConvolutionParameterfvEXT +alias ConvolutionParameterfv +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS +param params const GLfloat * +category GL_EXT_convolution +chromium omit + +name ConvolutionParameteriEXT +alias ConvolutionParameteri +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE +param params GLint +category GL_EXT_convolution +chromium omit + +name ConvolutionParameterivEXT +alias ConvolutionParameteriv +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS +param params const GLint * +category GL_EXT_convolution +chromium omit + +name CopyConvolutionFilter1DEXT +alias CopyConvolutionFilter1D +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param x GLint +param y GLint +param width GLsizei +category GL_EXT_convolution +chromium omit + +name CopyConvolutionFilter2DEXT +alias CopyConvolutionFilter2D +return void +param target GLenum +paramprop target GL_CONVOLUTION_2D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param x GLint +param y GLint +param width GLsizei +param height GLsizei +category GL_EXT_convolution +chromium omit + +name GetConvolutionFilterEXT +return void +param target GLenum +paramprop target GL_CONVOLUTION_2D GL_CONVOLUTION_1D +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param image GLvoid * +category GL_EXT_convolution +props get +chromium omit + +name GetConvolutionParameterfvEXT +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS GL_CONVOLUTION_FORMAT GL_CONVOLUTION_WIDTH GL_CONVOLUTION_HEIGHT GL_MAX_CONVOLUTION_WIDTH GL_MAX_CONVOLUTION_HEIGHT +param params GLfloat * +category GL_EXT_convolution +props get +chromium omit + +name GetConvolutionParameterivEXT +return void +param target GLenum +paramprop target GL_CONVOLUTION_1D GL_CONVOLUTION_2D GL_SEPARABLE_2D +param pname GLenum +paramprop pname GL_CONVOLUTION_BORDER_MODE GL_CONVOLUTION_BORDER_COLOR GL_CONVOLUTION_FILTER_SCALE GL_CONVOLUTION_FILTER_BIAS GL_CONVOLUTION_FORMAT GL_CONVOLUTION_WIDTH GL_CONVOLUTION_HEIGHT GL_MAX_CONVOLUTION_WIDTH GL_MAX_CONVOLUTION_HEIGHT +param params GLint * +category GL_EXT_convolution +props get +chromium omit + +name GetSeparableFilterEXT +return void +param target GLenum +paramprop target GL_SEPARABLE_2D +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param row GLvoid * +param column GLvoid * +param span GLvoid * +category GL_EXT_convolution +props get +chromium omit + +name SeparableFilter2DEXT +alias SeparableFilter2D +return void +param target GLenum +paramprop target GL_SEPARABLE_2D +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param width GLsizei +param height GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param row const GLvoid * +param column const GLvoid * +category GL_EXT_convolution +chromium omit + + +# GL_EXT_texture_object + +name AreTexturesResidentEXT +return GLboolean +param n GLsizei +param textures const GLuint * +param residences GLboolean * +category GL_EXT_texture_object +alias AreTexturesResident +props get +chromium nopack serverdependent + +name BindTextureEXT +return void +param target GLenum +paramprop target GL_TEXTURE_1D GL_TEXTURE_2D GL_TEXTURE_3D +param texture GLuint +category GL_EXT_texture_object +alias BindTexture + +name DeleteTexturesEXT +return void +param n GLsizei +param textures const GLuint * +category GL_EXT_texture_object +alias DeleteTextures +props nolist + +name GenTexturesEXT +return void +param n GLsizei +param textures GLuint * +category GL_EXT_texture_object +alias GenTextures +props get + +name IsTextureEXT +return GLboolean +param texture GLuint +category GL_EXT_texture_object +alias IsTexture +props get + +name PrioritizeTexturesEXT +return void +param n GLsizei +param textures const GLuint * +param priorities const GLclampf * +category GL_EXT_texture_object +alias PrioritizeTextures + + +# GL_EXT_vertex_array + +name ArrayElementEXT +return void +param i GLint +category GL_EXT_vertex_array +alias ArrayElement +chromium omit + +name ColorPointerEXT +return void +param size GLint +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +param count GLsizei +param pointer const GLvoid * +category GL_EXT_vertex_array +props setclient +chromium omit + +name DrawArraysEXT +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param first GLint +param count GLsizei +category GL_EXT_vertex_array +alias DrawArrays +props useclient +chromium omit + +name EdgeFlagPointerEXT +return void +param stride GLsizei +param count GLsizei +param pointer const GLboolean * +category GL_EXT_vertex_array +props setclient +chromium omit + +name GetPointervEXT +return void +param pname GLenum +paramprop pname GL_COLOR_ARRAY_POINTER GL_EDGE_FLAG_ARRAY_POINTER GL_FEEDBACK_BUFFER_POINTER GL_INDEX_ARRAY_POINTER GL_NORMAL_ARRAY_POINTER GL_TEXTURE_COORD_ARRAY_POINTER GL_SELECTION_BUFFER_POINTER GL_VERTEX_ARRAY_POINTER +param params GLvoid ** +category GL_EXT_vertex_array +alias GetPointerv +props useclient get +chromium omit + +name IndexPointerEXT +return void +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +param count GLsizei +param pointer const GLvoid * +category GL_EXT_vertex_array +props setclient +chromium omit + +name NormalPointerEXT +return void +param type GLenum +paramprop type GL_BYTE GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +param count GLsizei +param pointer const GLvoid * +category GL_EXT_vertex_array +props setclient +chromium omit + +name TexCoordPointerEXT +return void +param size GLint +param type GLenum +paramprop type GL_BYTE GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +param count GLsizei +param pointer const GLvoid * +category GL_EXT_vertex_array +props setclient +chromium omit + +name VertexPointerEXT +return void +param size GLint +param type GLenum +paramprop type GL_BYTE GL_SHORT GL_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +param count GLsizei +param pointer const GLvoid * +category GL_EXT_vertex_array +props setclient +chromium omit + + +# GL_ARB_point_parameters + +name PointParameterfARB +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB +param param GLfloat +category GL_ARB_point_parameters +chromium extpack + +name PointParameterfvARB +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB GL_POINT_DISTANCE_ATTENUATION_ARB +param params const GLfloat * +category GL_ARB_point_parameters +chromium extpack + + +# GL_EXT_color_subtable + +name ColorSubTableEXT +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param start GLsizei +param count GLsizei +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param data const GLvoid * +category GL_EXT_color_subtable +alias ColorSubTable +chromium omit + +name CopyColorSubTableEXT +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param start GLsizei +param x GLint +param y GLint +param width GLsizei +category GL_EXT_color_subtable +alias CopyColorSubTable +chromium omit + + +# GL_EXT_paletted_texture + +name ColorTableEXT +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_PROXY_COLOR_TABLE GL_PROXY_POST_CONVOLUTION_COLOR_TABLE GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE +param internalFormat GLenum +paramprop internalFormat GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 +param width GLsizei +param format GLenum +paramprop format GL_COLOR_INDEX GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA GL_LUMINANCE GL_LUMINANCE_ALPHA +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_2_BYTES GL_3_BYTES GL_4_BYTES +param table const GLvoid * +category GL_EXT_paletted_texture +alias ColorTable +chromium omit checklist + +name GetColorTableEXT +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE +param format GLenum +paramprop format GL_RED GL_GREEN GL_BLUE GL_ALPHA GL_LUMINANCE GL_LUMINANCE_ALPHA GL_RGB GL_BGR GL_RGBA GL_BGRA +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_BYTE GL_BITMAP GL_UNSIGNED_SHORT GL_SHORT GL_UNSIGNED_INT GL_INT GL_FLOAT GL_UNSIGNED_BYTE_3_3_2 GL_UNSIGNED_BYTE_2_3_3_REV GL_UNSIGNED_SHORT_5_6_5 GL_UNSIGNED_SHORT_5_6_5_REV GL_UNSIGNED_SHORT_4_4_4_4 GL_UNSIGNED_SHORT_4_4_4_4_REV GL_UNSIGNED_SHORT_5_5_5_1 GL_UNSIGNED_SHORT_1_5_5_5_REV GL_UNSIGNED_INT_8_8_8_8 GL_UNSIGNED_INT_8_8_8_8_REV GL_UNSIGNED_INT_10_10_10_2 GL_UNSIGNED_INT_2_10_10_10_REV +param data GLvoid * +category GL_EXT_paletted_texture +props get +chromium omit + +name GetColorTableParameterivEXT +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_PROXY_COLOR_TABLE GL_PROXY_POST_CONVOLUTION_COLOR_TABLE GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE +param pname GLenum +paramprop pname GL_COLOR_TABLE_BIAS GL_COLOR_TABLE_SCALE GL_COLOR_TABLE_FORMAT GL_COLOR_TABLE_WIDTH GL_COLOR_TABLE_RED_SIZE GL_COLOR_TABLE_GREEN_SIZE GL_COLOR_TABLE_BLUE_SIZE GL_COLOR_TABLE_ALPHA_SIZE GL_COLOR_TABLE_LUMINANCE_SIZE GL_COLOR_TABLE_INTENSITY_SIZE +param params GLint * +category GL_EXT_paletted_texture +props get +chromium omit + +name GetColorTableParameterfvEXT +return void +param target GLenum +paramprop target GL_COLOR_TABLE GL_POST_CONVOLUTION_COLOR_TABLE GL_POST_COLOR_MATRIX_COLOR_TABLE GL_PROXY_COLOR_TABLE GL_PROXY_POST_CONVOLUTION_COLOR_TABLE GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE +param pname GLenum +paramprop pname GL_COLOR_TABLE_BIAS GL_COLOR_TABLE_SCALE GL_COLOR_TABLE_FORMAT GL_COLOR_TABLE_WIDTH GL_COLOR_TABLE_RED_SIZE GL_COLOR_TABLE_GREEN_SIZE GL_COLOR_TABLE_BLUE_SIZE GL_COLOR_TABLE_ALPHA_SIZE GL_COLOR_TABLE_LUMINANCE_SIZE GL_COLOR_TABLE_INTENSITY_SIZE +param params GLfloat * +category GL_EXT_paletted_texture +props get +chromium omit + + +# GL_EXT_draw_range_elements + +name DrawRangeElementsEXT +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param start GLuint +paramlist start 0 +param end GLuint +paramlist end 10 +param count GLsizei +paramlist count 10 +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT GL_UNSIGNED_INT +param indices const GLvoid * +category GL_EXT_draw_range_elements +alias DrawRangeElements + + +# GL_EXT_secondary_color + +name SecondaryColor3bEXT +return void +param red GLbyte +param green GLbyte +param blue GLbyte +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3bvEXT +return void +param v const GLbyte * +paramvec v 2 2 2 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3bEXT +props pervertex + +name SecondaryColor3dEXT +return void +param red GLdouble +param green GLdouble +param blue GLdouble +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3dvEXT +return void +param v const GLdouble * +paramvec v 2.0 2.0 2.0 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3dEXT +props pervertex + +name SecondaryColor3fEXT +return void +param red GLfloat +param green GLfloat +param blue GLfloat +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3fvEXT +return void +param v const GLfloat * +paramvec v 2.0 2.0 2.0 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3fEXT +props pervertex + +name SecondaryColor3iEXT +return void +param red GLint +param green GLint +param blue GLint +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3ivEXT +return void +param v const GLint * +paramvec v 2 2 2 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3iEXT +props pervertex + +name SecondaryColor3sEXT +return void +param red GLshort +param green GLshort +param blue GLshort +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3svEXT +return void +param v const GLshort * +paramvec v 2 2 2 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3sEXT +props pervertex + +name SecondaryColor3ubEXT +return void +param red GLubyte +param green GLubyte +param blue GLubyte +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3ubvEXT +return void +param v const GLubyte * +paramvec v 2 2 2 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3ubEXT +props pervertex + +name SecondaryColor3uiEXT +return void +param red GLuint +param green GLuint +param blue GLuint +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3uivEXT +return void +param v const GLuint * +paramvec v 2 2 2 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3uiEXT +props pervertex + +name SecondaryColor3usEXT +return void +param red GLushort +param green GLushort +param blue GLushort +category GL_EXT_secondary_color +chromium pack +props pervertex + +name SecondaryColor3usvEXT +return void +param v const GLushort * +paramvec v 2 2 2 +vector v 3 +category GL_EXT_secondary_color +vectoralias SecondaryColor3usEXT +props pervertex + +name SecondaryColorPointerEXT +return void +param size GLint +paramlist size 3 4 +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +category GL_EXT_secondary_color +props setclient +chromium extpack + + + +name MultiDrawArraysEXT +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param first GLint * +param count GLsizei * +param primcount GLsizei +category GL_EXT_multi_draw_arrays +props useclient +chromium expandpack + +name MultiDrawElementsEXT +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param count const GLsizei * +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT GL_UNSIGNED_INT +param indices const GLvoid ** +param primcount GLsizei +category GL_EXT_multi_draw_arrays +props useclient +chromium expandpack + + +# GL_EXT_fog_coord + +name FogCoordfEXT +return void +param coord GLfloat +paramlist coord 1.0 +category GL_EXT_fog_coord +props pervertex +chromium pack + +name FogCoordfvEXT +return void +param coord const GLfloat * +paramvec coord 1.0 +vector coord 1 +category GL_EXT_fog_coord +props pervertex +vectoralias FogCoordfEXT + +name FogCoorddEXT +return void +param coord GLdouble +paramlist coord 1.0 +category GL_EXT_fog_coord +props pervertex +chromium pack + +name FogCoorddvEXT +return void +param coord const GLdouble * +paramvec coord 1.0 +vector coord 1 +category GL_EXT_fog_coord +props pervertex +vectoralias FogCoorddEXT + +name FogCoordPointerEXT +return void +param type GLenum +paramprop type GL_FLOAT GL_DOUBLE +param stride GLsizei +param pointer const GLvoid * +category GL_EXT_fog_coord +props setclient +chromium extpack + + +# GL_EXT_blend_func_separate + +name BlendFuncSeparateEXT +return void +param sfactorRGB GLenum +paramprop sfactorRGB GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA GL_SRC_ALPHA_SATURATE +param dfactorRGB GLenum +paramprop dfactorRGB GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA +param sfactorA GLenum +paramprop sfactorA GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA GL_SRC_ALPHA_SATURATE +param dfactorA GLenum +paramprop dfactorA GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA +category GL_EXT_blend_func_separate +chromium extpack + + +# GL_NV_vertex_array_range + +name FlushVertexArrayRangeNV +return void +category GL_NV_vertex_array_range +props setclient nolist +chromium extpack + +name VertexArrayRangeNV +return void +param length GLsizei +param pointer const GLvoid * +category GL_NV_vertex_array_range +props setclient nolist +chromium extpack + + +# GL_NV_register_combiners + +name CombinerParameterfvNV +return void +param pname GLenum +paramprop pname GL_CONSTANT_COLOR0_NV GL_CONSTANT_COLOR1_NV +param params const GLfloat * +category GL_NV_register_combiners +chromium extpack + +name CombinerParameterfNV +return void +param pname GLenum +paramprop pname GL_NUM_GENERAL_COMBINERS_NV GL_COLOR_SUM_CLAMP_NV +param param GLfloat +category GL_NV_register_combiners +chromium extpack + +name CombinerParameterivNV +return void +param pname GLenum +paramprop pname GL_NUM_GENERAL_COMBINERS_NV GL_COLOR_SUM_CLAMP_NV +param params const GLint * +category GL_NV_register_combiners +chromium extpack + +name CombinerParameteriNV +return void +param pname GLenum +paramprop pname GL_NUM_GENERAL_COMBINERS_NV GL_COLOR_SUM_CLAMP_NV +param param GLint +category GL_NV_register_combiners +chromium extpack + +name CombinerInputNV +return void +param stage GLenum +param portion GLenum +param variable GLenum +param input GLenum +param mapping GLenum +param componentUsage GLenum +paramset [ stage portion variable input mapping componentUsage ] [ GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV ] [ GL_ALPHA ] [ GL_VARIABLE_A_NV GL_VARIABLE_B_NV GL_VARIABLE_C_NV GL_VARIABLE_D_NV ] [ GL_ZERO GL_CONSTANT_COLOR0_NV GL_CONSTANT_COLOR1_NV GL_PRIMARY_COLOR_NV GL_SECONDARY_COLOR_NV GL_SPARE0_NV GL_SPARE1_NV GL_TEXTURE0_ARB GL_TEXTURE1_ARB ] [ GL_UNSIGNED_IDENTITY_NV GL_UNSIGNED_INVERT_NV GL_EXPAND_NORMAL_NV GL_EXPAND_NEGATE_NV GL_HALF_BIAS_NORMAL_NV GL_HALF_BIAS_NEGATE_NV GL_SIGNED_IDENTITY_NV GL_SIGNED_NEGATE_NV ] [ GL_ALPHA ] +paramset [ stage portion input componentUsage ] [ GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV ] [ GL_RGB ] [ GL_VARIABLE_A_NV GL_VARIABLE_B_NV GL_VARIABLE_C_NV GL_VARIABLE_D_NV ] [ GL_ZERO GL_CONSTANT_COLOR0_NV GL_CONSTANT_COLOR1_NV GL_FOG GL_PRIMARY_COLOR_NV GL_SECONDARY_COLOR_NV GL_SPARE0_NV GL_SPARE1_NV GL_TEXTURE0_ARB GL_TEXTURE1_ARB ] [ GL_UNSIGNED_IDENTITY_NV GL_UNSIGNED_INVERT_NV GL_EXPAND_NORMAL_NV GL_EXPAND_NEGATE_NV GL_HALF_BIAS_NORMAL_NV GL_HALF_BIAS_NEGATE_NV GL_SIGNED_IDENTITY_NV GL_SIGNED_NEGATE_NV ] [ GL_RGB ] +category GL_NV_register_combiners +chromium extpack + +name CombinerOutputNV +return void +param stage GLenum +paramprop stage GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV +param portion GLenum +paramset [ portion abDotProduct cdDotProduct ] [ GL_ALPHA ] [ GL_FALSE ] [ GL_FALSE ] +paramset [ portion abDotProduct cdDotProduct ] [ GL_RGB ] [ GL_FALSE ] [ GL_FALSE ] +paramset [ portion abDotProduct cdDotProduct sumOutput ] [ GL_RGB ] [ GL_TRUE ] [ GL_TRUE ] [ GL_DISCARD_NV ] +paramset [ portion abDotProduct cdDotProduct sumOutput ] [ GL_RGB ] [ GL_FALSE ] [ GL_TRUE ] [ GL_DISCARD_NV ] +paramset [ portion abDotProduct cdDotProduct sumOutput ] [ GL_RGB ] [ GL_TRUE ] [ GL_FALSE ] [ GL_DISCARD_NV ] +paramset [ portion abDotProduct cdDotProduct sumOutput ] [ GL_RGB ] [ GL_FALSE ] [ GL_FALSE ] [ GL_PRIMARY_COLOR_NV GL_SECONDARY_COLOR_NV GL_SPARE0_NV GL_SPARE1_NV GL_TEXTURE0_ARB GL_TEXTURE1_ARB ] +param abOutput GLenum +paramprop abOutput GL_DISCARD_NV GL_PRIMARY_COLOR_NV GL_SECONDARY_COLOR_NV GL_SPARE0_NV GL_SPARE1_NV GL_TEXTURE0_ARB GL_TEXTURE1_ARB +param cdOutput GLenum +paramprop cdOutput GL_DISCARD_NV GL_PRIMARY_COLOR_NV GL_SECONDARY_COLOR_NV GL_SPARE0_NV GL_SPARE1_NV GL_TEXTURE0_ARB GL_TEXTURE1_ARB +param sumOutput GLenum +param scale GLenum +paramprop scale GL_NONE GL_SCALE_BY_TWO_NV GL_SCALE_BY_FOUR_NV GL_SCALE_BY_ONE_HALF_NV +param bias GLenum +paramprop bias GL_NONE GL_BIAS_BY_NEGATIVE_ONE_HALF_NV +param abDotProduct GLboolean +param cdDotProduct GLboolean +param muxSum GLboolean +category GL_NV_register_combiners +chromium extpack + +# variable GL_VARIABLE_G_NV works only with GL_BLUE +name FinalCombinerInputNV +return void +param variable GLenum +paramprop variable GL_VARIABLE_A_NV GL_VARIABLE_B_NV GL_VARIABLE_C_NV GL_VARIABLE_D_NV GL_VARIABLE_E_NV GL_VARIABLE_F_NV +param input GLenum +paramprop input GL_ZERO GL_CONSTANT_COLOR0_NV GL_CONSTANT_COLOR1_NV GL_FOG GL_PRIMARY_COLOR_NV GL_SECONDARY_COLOR_NV GL_SPARE0_NV GL_SPARE1_NV GL_TEXTURE0_ARB GL_TEXTURE1_ARB +param mapping GLenum +paramprop mapping GL_UNSIGNED_IDENTITY_NV GL_UNSIGNED_INVERT_NV +param componentUsage GLenum +paramprop componentUsage GL_RGB GL_ALPHA +category GL_NV_register_combiners +chromium extpack + +name GetCombinerInputParameterfvNV +return void +param stage GLenum +paramprop stage GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV +param portion GLenum +paramprop portion GL_RGB GL_ALPHA +param variable GLenum +paramprop variable GL_VARIABLE_A_NV GL_VARIABLE_B_NV GL_VARIABLE_C_NV GL_VARIABLE_D_NV +param pname GLenum +paramprop pname GL_COMBINER_INPUT_NV GL_COMBINER_MAPPING_NV GL_COMBINER_COMPONENT_USAGE_NV +param params GLfloat * +category GL_NV_register_combiners +props get +chromium extpack + +name GetCombinerInputParameterivNV +return void +param stage GLenum +paramprop stage GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV +param portion GLenum +paramprop portion GL_RGB GL_ALPHA +param variable GLenum +paramprop variable GL_VARIABLE_A_NV GL_VARIABLE_B_NV GL_VARIABLE_C_NV GL_VARIABLE_D_NV +param pname GLenum +paramprop pname GL_COMBINER_INPUT_NV GL_COMBINER_MAPPING_NV GL_COMBINER_COMPONENT_USAGE_NV +param params GLint * +category GL_NV_register_combiners +props get +chromium extpack + +name GetCombinerOutputParameterfvNV +return void +param stage GLenum +paramprop stage GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV +param portion GLenum +paramprop portion GL_RGB GL_ALPHA +param pname GLenum +paramprop pname GL_COMBINER_AB_DOT_PRODUCT_NV GL_COMBINER_CD_DOT_PRODUCT_NV GL_COMBINER_MUX_SUM_NV GL_COMBINER_SCALE_NV GL_COMBINER_BIAS_NV GL_COMBINER_AB_OUTPUT_NV GL_COMBINER_CD_OUTPUT_NV GL_COMBINER_SUM_OUTPUT_NV +param params GLfloat * +category GL_NV_register_combiners +props get +chromium extpack + +name GetCombinerOutputParameterivNV +return void +param stage GLenum +paramprop stage GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV +param portion GLenum +paramprop portion GL_RGB GL_ALPHA +param pname GLenum +paramprop pname GL_COMBINER_AB_DOT_PRODUCT_NV GL_COMBINER_CD_DOT_PRODUCT_NV GL_COMBINER_MUX_SUM_NV GL_COMBINER_SCALE_NV GL_COMBINER_BIAS_NV GL_COMBINER_AB_OUTPUT_NV GL_COMBINER_CD_OUTPUT_NV GL_COMBINER_SUM_OUTPUT_NV +param params GLint * +category GL_NV_register_combiners +props get +chromium extpack + +name GetFinalCombinerInputParameterfvNV +return void +param variable GLenum +paramprop variable GL_VARIABLE_A_NV GL_VARIABLE_B_NV GL_VARIABLE_C_NV GL_VARIABLE_D_NV GL_VARIABLE_E_NV GL_VARIABLE_F_NV GL_VARIABLE_G_NV +param pname GLenum +paramprop pname GL_COMBINER_INPUT_NV GL_COMBINER_MAPPING_NV GL_COMBINER_COMPONENT_USAGE_NV +param params GLfloat * +category GL_NV_register_combiners +props get +chromium extpack + +name GetFinalCombinerInputParameterivNV +return void +param variable GLenum +paramprop variable GL_VARIABLE_A_NV GL_VARIABLE_B_NV GL_VARIABLE_C_NV GL_VARIABLE_D_NV GL_VARIABLE_E_NV GL_VARIABLE_F_NV GL_VARIABLE_G_NV +param pname GLenum +paramprop pname GL_COMBINER_INPUT_NV GL_COMBINER_MAPPING_NV GL_COMBINER_COMPONENT_USAGE_NV +param params GLint * +category GL_NV_register_combiners +props get +chromium extpack + + + + +# GL_EXT_multisample + +name SampleMaskEXT +return void +param value GLclampf +param invert GLboolean +category GL_EXT_multisample +chromium stub + +name SamplePatternEXT +return void +param pattern GLenum +paramprop pattern GL_1PASS_EXT GL_2PASS_0_EXT GL_2PASS_1_EXT GL_4PASS_0_EXT GL_4PASS_1_EXT GL_4PASS_2_EXT GL_4PASS_3_EXT +category GL_EXT_multisample +chromium stub + + +# GL_NV_register_combiners2 + +name CombinerStageParameterfvNV +return void +param stage GLenum +paramprop stage GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV +param pname GLenum +paramprop pname GL_CONSTANT_COLOR0_NV GL_CONSTANT_COLOR1_NV +param params const GLfloat * +category GL_NV_register_combiners2 +chromium extpack + +name GetCombinerStageParameterfvNV +return void +param stage GLenum +paramprop stage GL_COMBINER0_NV GL_COMBINER1_NV GL_COMBINER2_NV GL_COMBINER3_NV GL_COMBINER4_NV GL_COMBINER5_NV GL_COMBINER6_NV GL_COMBINER7_NV +param pname GLenum +paramprop pname GL_CONSTANT_COLOR0_NV GL_CONSTANT_COLOR1_NV +param params GLfloat * +category GL_NV_register_combiners2 +props get +chromium extpack + + +# GL_ARB_window_pos + +name WindowPos2dARB +return void +param x GLdouble +param y GLdouble +category GL_ARB_window_pos +chromium extpack + +name WindowPos2fARB +return void +param x GLfloat +param y GLfloat +category GL_ARB_window_pos +chromium extpack + +name WindowPos2iARB +return void +param x GLint +param y GLint +category GL_ARB_window_pos +chromium extpack + +name WindowPos2sARB +return void +param x GLshort +param y GLshort +category GL_ARB_window_pos +chromium extpack + +name WindowPos2dvARB +return void +param v const GLdouble * +paramvec v 1.0 1.0 +vector v 2 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos2dARB + +name WindowPos2fvARB +return void +param v const GLfloat * +paramvec v 1.0 1.0 +vector v 2 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos2fARB + +name WindowPos2ivARB +return void +param v const GLint * +paramvec v 1 1 +vector v 2 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos2iARB + +name WindowPos2svARB +return void +param v const GLshort * +paramvec v 1 1 +vector v 2 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos2sARB + +name WindowPos3dARB +return void +param x GLdouble +param y GLdouble +param z GLdouble +category GL_ARB_window_pos +chromium extpack + +name WindowPos3fARB +return void +param x GLfloat +param y GLfloat +param z GLfloat +category GL_ARB_window_pos +chromium extpack + +name WindowPos3iARB +return void +param x GLint +param y GLint +param z GLint +category GL_ARB_window_pos +chromium extpack + +name WindowPos3sARB +return void +param x GLshort +param y GLshort +param z GLshort +category GL_ARB_window_pos +chromium extpack + +name WindowPos3dvARB +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos3dARB + +name WindowPos3fvARB +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos3fARB + +name WindowPos3ivARB +return void +param v const GLint * +paramvec v 1 1 1 +vector v 3 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos3iARB + +name WindowPos3svARB +return void +param v const GLshort * +paramvec v 1 1 1 +vector v 3 +category GL_ARB_window_pos +chromium extpack +vectoralias WindowPos3sARB + + +# OpenGL 1.4 + +name BlendFuncSeparate +alias BlendFuncSeparateEXT +return void +param sfactorRGB GLenum +paramprop sfactorRGB GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA GL_SRC_ALPHA_SATURATE +param dfactorRGB GLenum +paramprop dfactorRGB GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA +param sfactorA GLenum +paramprop sfactorA GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA GL_SRC_ALPHA_SATURATE +param dfactorA GLenum +paramprop dfactorA GL_ZERO GL_ONE GL_DST_COLOR GL_ONE_MINUS_DST_COLOR GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA GL_DST_ALPHA GL_ONE_MINUS_DST_ALPHA GL_CONSTANT_COLOR GL_ONE_MINUS_CONSTANT_COLOR GL_CONSTANT_ALPHA GL_ONE_MINUS_CONSTANT_ALPHA +category 1.4 + +name FogCoordf +return void +param coord GLfloat +category 1.4 +alias FogCoordfEXT + +name FogCoordfv +return void +param coord const GLfloat * +category 1.4 +alias FogCoordfvEXT + +name FogCoordd +return void +param coord GLdouble +category 1.4 +alias FogCoorddEXT + +name FogCoorddv +return void +param coord const GLdouble * +category 1.4 +alias FogCoorddvEXT + +name FogCoordPointer +return void +param type GLenum +paramprop type GL_FLOAT GL_DOUBLE +param stride GLsizei +param pointer const GLvoid * +category 1.4 +alias FogCoordPointerEXT +props setclient +chromium nopack + +name MultiDrawArrays +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param first GLint * +param count GLsizei * +param primcount GLsizei +category 1.4 +alias MultiDrawArraysEXT +props useclient +chromium expandpack + +name MultiDrawElements +return void +param mode GLenum +paramprop mode GL_POINTS GL_LINE_STRIP GL_LINE_LOOP GL_LINES GL_TRIANGLE_STRIP GL_TRIANGLE_FAN GL_TRIANGLES GL_QUAD_STRIP GL_QUADS GL_POLYGON +param count const GLsizei * +param type GLenum +paramprop type GL_UNSIGNED_BYTE GL_UNSIGNED_SHORT GL_UNSIGNED_INT +param indices const GLvoid ** +param primcount GLsizei +category 1.4 +alias MultiDrawElementsEXT +props useclient +chromium expandpack + +name PointParameterfEXT +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB +param param GLfloat +category GL_EXT_point_parameters +alias PointParameterfARB + +name PointParameterfvEXT +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB GL_POINT_DISTANCE_ATTENUATION_ARB +param params const GLfloat * +category GL_EXT_point_parameters +alias PointParameterfvARB + +name PointParameterf +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB +param param GLfloat +category 1.4 +alias PointParameterfARB + +name PointParameterfv +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB GL_POINT_DISTANCE_ATTENUATION_ARB +param params const GLfloat * +category 1.4 +alias PointParameterfvARB + +name PointParameteri +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB +param param GLint +category 1.4 +chromium extpack + +name PointParameteriv +return void +param pname GLenum +paramprop pname GL_POINT_SIZE_MIN_ARB GL_POINT_SIZE_MAX_ARB GL_POINT_FADE_THRESHOLD_SIZE_ARB +param param const GLint * +category 1.4 +chromium extpack + +name SecondaryColor3b +return void +param red GLbyte +param green GLbyte +param blue GLbyte +category 1.4 +alias SecondaryColor3bEXT +props pervertex + +name SecondaryColor3bv +return void +param v const GLbyte * +vector v 3 +category 1.4 +alias SecondaryColor3bvEXT +props pervertex + +name SecondaryColor3d +return void +param red GLdouble +param green GLdouble +param blue GLdouble +category 1.4 +alias SecondaryColor3dEXT +props pervertex + +name SecondaryColor3dv +return void +param v const GLdouble * +vector v 3 +category 1.4 +alias SecondaryColor3dvEXT +props pervertex + +name SecondaryColor3f +return void +param red GLfloat +param green GLfloat +param blue GLfloat +category 1.4 +alias SecondaryColor3fEXT +props pervertex + +name SecondaryColor3fv +return void +param v const GLfloat * +vector v 3 +category 1.4 +alias SecondaryColor3fvEXT +props pervertex + +name SecondaryColor3i +return void +param red GLint +param green GLint +param blue GLint +category 1.4 +alias SecondaryColor3iEXT +props pervertex + +name SecondaryColor3iv +return void +param v const GLint * +vector v 3 +category 1.4 +alias SecondaryColor3ivEXT +props pervertex + +name SecondaryColor3s +return void +param red GLshort +param green GLshort +param blue GLshort +category 1.4 +alias SecondaryColor3sEXT +props pervertex + +name SecondaryColor3sv +return void +param v const GLshort * +vector v 3 +category 1.4 +alias SecondaryColor3svEXT +props pervertex + +name SecondaryColor3ub +return void +param red GLubyte +param green GLubyte +param blue GLubyte +category 1.4 +alias SecondaryColor3ubEXT +props pervertex + +name SecondaryColor3ubv +return void +param v const GLubyte * +vector v 3 +category 1.4 +alias SecondaryColor3ubvEXT +props pervertex + +name SecondaryColor3ui +return void +param red GLuint +param green GLuint +param blue GLuint +category 1.4 +alias SecondaryColor3uiEXT +props pervertex + +name SecondaryColor3uiv +return void +param v const GLuint * +vector v 3 +category 1.4 +alias SecondaryColor3uivEXT +props pervertex + +name SecondaryColor3us +return void +param red GLushort +param green GLushort +param blue GLushort +category 1.4 +alias SecondaryColor3usEXT +props pervertex + +name SecondaryColor3usv +return void +param v const GLushort * +vector v 3 +category 1.4 +alias SecondaryColor3usvEXT +props pervertex + +name SecondaryColorPointer +return void +param size GLint +paramlist size 3 4 +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_DOUBLE +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +category 1.4 +alias SecondaryColorPointerEXT +props setclient + +name WindowPos2d +return void +param x GLdouble +param y GLdouble +category 1.4 +alias WindowPos2dARB +chromium nopack + +name WindowPos2dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 +vector v 2 +category 1.4 +alias WindowPos2dvARB +chromium nopack + +name WindowPos2f +return void +param x GLfloat +param y GLfloat +category 1.4 +alias WindowPos2fARB +chromium nopack + +name WindowPos2fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 +vector v 2 +category 1.4 +alias WindowPos2fvARB +chromium nopack + +name WindowPos2i +return void +param x GLint +param y GLint +category 1.4 +alias WindowPos2iARB +chromium nopack + +name WindowPos2iv +return void +param v const GLint * +paramvec v 1 1 +vector v 2 +category 1.4 +alias WindowPos2ivARB +chromium nopack + +name WindowPos2s +return void +param x GLshort +param y GLshort +category 1.4 +alias WindowPos2sARB +chromium nopack + +name WindowPos2sv +return void +param v const GLshort * +paramvec v 1 1 +vector v 2 +category 1.4 +alias WindowPos2svARB +chromium nopack + +name WindowPos3d +return void +param x GLdouble +param y GLdouble +param z GLdouble +category 1.4 +alias WindowPos3dARB +chromium nopack + +name WindowPos3dv +return void +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.4 +alias WindowPos3dvARB +chromium nopack + +name WindowPos3f +return void +param x GLfloat +param y GLfloat +param z GLfloat +category 1.4 +alias WindowPos3fARB +chromium nopack + +name WindowPos3fv +return void +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 1.4 +alias WindowPos3fvARB +chromium nopack + +name WindowPos3i +return void +param x GLint +param y GLint +param z GLint +category 1.4 +alias WindowPos3iARB +chromium nopack + +name WindowPos3iv +return void +param v const GLint * +paramvec v 1 1 1 +vector v 3 +category 1.4 +alias WindowPos3ivARB +chromium nopack + +name WindowPos3s +return void +param x GLshort +param y GLshort +param z GLshort +category 1.4 +alias WindowPos3sARB +chromium nopack + +name WindowPos3sv +return void +param v const GLshort * +paramvec v 1 1 1 +vector v 3 +category 1.4 +alias WindowPos3svARB +chromium nopack + + +# GL_NV_point_sprite + +name PointParameteriNV +return void +param pname GLenum +paramprop pname GL_POINT_SPRITE_R_MODE_NV +param params GLint +category GL_NV_point_sprite +alias PointParameteri +chromium nopack + +name PointParameterivNV +return void +param pname GLenum +param params const GLint * +paramprop pname GL_POINT_SPRITE_R_MODE_NV +category GL_NV_point_sprite +alias PointParameteriv +chromium nopack + + +# GL_EXT_stencil_two_side + +name ActiveStencilFaceEXT +return void +param face GLenum +paramprop face GL_FRONT GL_BACK +category GL_EXT_stencil_two_side +chromium extpack + + +# GL_NV_fence + +name DeleteFencesNV +return void +param n GLsizei +param fences const GLuint * +category GL_NV_fence +props nolist +chromium extpack + +name GenFencesNV +return void +param n GLsizei +param fences GLuint * +category GL_NV_fence +props get +chromium extpack serverdependent + +name IsFenceNV +return GLboolean +param fence GLuint +category GL_NV_fence +props get +chromium extpack serverdependent + +name TestFenceNV +return GLboolean +param fence GLuint +category GL_NV_fence +props get +chromium extpack serverdependent + +name GetFenceivNV +return void +param fence GLuint +param pname GLenum +paramprop pname GL_FENCE_STATUS_NV GL_FENCE_CONDITION_NV +param params GLint * +category GL_NV_fence +props get +chromium extpack serverdependent + +name FinishFenceNV +return void +param fence GLuint +category GL_NV_fence +props nolist +chromium extpack + +name SetFenceNV +return void +param fence GLuint +param condition GLenum +paramprop condition GL_ALL_COMPLETED_NV +category GL_NV_fence +chromium extpack + + +# GL_ARB_vertex_program + +name VertexAttrib1sARB +return void +param index GLuint +param x GLshort +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib1fARB +return void +param index GLuint +param x GLfloat +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib1dARB +return void +param index GLuint +param x GLdouble +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib2sARB +return void +param index GLuint +param x GLshort +param y GLshort +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib2fARB +return void +param index GLuint +param x GLfloat +param y GLfloat +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib2dARB +return void +param index GLuint +param x GLdouble +param y GLdouble +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib3sARB +return void +param index GLuint +param x GLshort +param y GLshort +param z GLshort +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib3fARB +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib3dARB +return void +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4sARB +return void +param index GLuint +param x GLshort +param y GLshort +param z GLshort +param w GLshort +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4fARB +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4dARB +return void +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4NubARB +return void +param index GLuint +param x GLubyte +param y GLubyte +param z GLubyte +param w GLubyte +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib1svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 +vector v 1 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib1sARB + +name VertexAttrib1fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1.0 +vector v 1 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib1fARB + +name VertexAttrib1dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 +vector v 1 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib1dARB + +name VertexAttrib2svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 +vector v 2 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib2sARB + +name VertexAttrib2fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1.0 1.0 +vector v 2 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib2fARB + +name VertexAttrib2dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 1.0 +vector v 2 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib2dARB + +name VertexAttrib3svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 +vector v 3 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib3sARB + +name VertexAttrib3fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib3fARB + +name VertexAttrib3dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib3dARB + +name VertexAttrib4bvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLbyte * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib4sARB + +name VertexAttrib4ivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLint * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4ubvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLubyte * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4usvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLushort * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4uivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLuint * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib4fARB + +name VertexAttrib4dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category GL_ARB_vertex_program +props pervertex +vectoralias VertexAttrib4dARB + +name VertexAttrib4NbvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLbyte * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4NsvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4NivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLint * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4NubvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLubyte * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4NusvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLushort * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttrib4NuivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLuint * +paramvec v 1 1 1 1 +vector v 4 +category GL_ARB_vertex_program +props pervertex +chromium pack + +name VertexAttribPointerARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param size GLint +paramlist size 1 2 3 4 +param type GLenum +paramprop type GL_SHORT GL_FLOAT GL_DOUBLE +param normalized GLboolean +paramlist normalized GL_TRUE GL_FALSE +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +category GL_ARB_vertex_program +props setclient +chromium extpack + +name EnableVertexAttribArrayARB +return void +param index GLuint +category GL_ARB_vertex_program +props setclient +chromium extpack + +name DisableVertexAttribArrayARB +return void +param index GLuint +category GL_ARB_vertex_program +props setclient +chromium extpack + +name ProgramStringARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param format GLenum +paramprop format GL_PROGRAM_FORMAT_ASCII_ARB +param len GLsizei +param string const GLvoid * +category GL_ARB_vertex_program +chromium extpack + +name BindProgramARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param program GLuint +category GL_ARB_vertex_program +chromium extpack + +name DeleteProgramsARB +return void +param n GLsizei +param programs const GLuint * +category GL_ARB_vertex_program +props nolist +chromium extpack + +name GenProgramsARB +return void +param n GLsizei +param programs GLuint * +category GL_ARB_vertex_program +props get +chromium extpack serverdependent + +name IsProgramARB +return GLboolean +param program GLuint +category GL_ARB_vertex_program +props get +chromium extpack + +name ProgramEnvParameter4dARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category GL_ARB_vertex_program +chromium extpack + +name ProgramEnvParameter4dvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params const GLdouble * +vector params 4 +category GL_ARB_vertex_program +chromium extpack +vectoralias ProgramEnvParameter4dARB + +name ProgramEnvParameter4fARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category GL_ARB_vertex_program +chromium extpack + +name ProgramEnvParameter4fvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params const GLfloat * +vector params 4 +category GL_ARB_vertex_program +chromium extpack +vectoralias ProgramEnvParameter4fARB + +name ProgramLocalParameter4dARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category GL_ARB_vertex_program +chromium extpack + +name ProgramLocalParameter4dvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params const GLdouble * +vector params 4 +category GL_ARB_vertex_program +chromium extpack +vectoralias ProgramLocalParameter4dARB + +name ProgramLocalParameter4fARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category GL_ARB_vertex_program +chromium extpack + +name ProgramLocalParameter4fvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params const GLfloat * +vector params 4 +category GL_ARB_vertex_program +chromium extpack +vectoralias ProgramLocalParameter4fARB + +name GetProgramEnvParameterdvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params GLdouble * +vector params 4 +category GL_ARB_vertex_program +props get +chromium extpack + +name GetProgramEnvParameterfvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params GLfloat * +vector params 4 +category GL_ARB_vertex_program +props get +chromium extpack + +name GetProgramLocalParameterdvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params GLdouble * +vector params 4 +category GL_ARB_vertex_program +props get +chromium extpack + +name GetProgramLocalParameterfvARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param index GLuint +param params GLfloat * +vector params 4 +category GL_ARB_vertex_program +props get +chromium extpack + +name GetProgramivARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param pname GLenum +param params GLint * +category GL_ARB_vertex_program +props get +chromium extpack serverdependent + +name GetProgramStringARB +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_ARB GL_FRAGMENT_PROGRAM_ARB +param pname GLenum +paramprop pname GL_PROGRAM_STRING_ARB +param string GLvoid * +category GL_ARB_vertex_program +props get +chromium extpack + +name GetVertexAttribdvARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB GL_CURRENT_VERTEX_ATTRIB_ARB +param params GLdouble * +paramvec params 0.0 0.0 0.0 0.0 +vector params 4 +category GL_ARB_vertex_program +props get +chromium extpack + +name GetVertexAttribfvARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB GL_CURRENT_VERTEX_ATTRIB_ARB +param params GLfloat * +paramvec params 0.0 0.0 0.0 0.0 +vector params 4 +category GL_ARB_vertex_program +props get +chromium extpack + +name GetVertexAttribivARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB GL_CURRENT_VERTEX_ATTRIB_ARB GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB +param params GLint * +paramvec params 0 0 0 0 +vector params 4 +category GL_ARB_vertex_program +props get +chromium extpack + +name GetVertexAttribPointervARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB GL_CURRENT_VERTEX_ATTRIB_ARB +param pointer GLvoid ** +category GL_ARB_vertex_program +props useclient get +chromium extpack + + + +# GL_NV_vertex_program + +name AreProgramsResidentNV +return GLboolean +param n GLsizei +param ids const GLuint * +param residences GLboolean * +category GL_NV_vertex_program +props get +chromium extpack serverdependent + +name BindProgramNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param id GLuint +category GL_NV_vertex_program +chromium extpack + +name DeleteProgramsNV +return void +param n GLsizei +param ids const GLuint * +category GL_NV_vertex_program +alias DeleteProgramsARB +props nolist +chromium nopack + +name ExecuteProgramNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param id GLuint +param params const GLfloat * +category GL_NV_vertex_program +chromium extpack + +name GenProgramsNV +return void +param n GLsizei +param ids GLuint * +category GL_NV_vertex_program +props get +chromium extpack serverdependent + +name GetProgramParameterdvNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param pname GLenum +paramprop pname GL_PROGRAM_PARAMETER_NV +param params GLdouble * +vector params 4 +category GL_NV_vertex_program +props get +chromium extpack + +name GetProgramParameterfvNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param pname GLenum +paramprop pname GL_PROGRAM_PARAMETER_NV +param params GLfloat * +category GL_NV_vertex_program +props get +chromium extpack + +name GetProgramivNV +return void +param id GLuint +param pname GLenum +paramprop target GL_PROGRAM_PARAMETER_NV +param params GLint * +category GL_NV_vertex_program +props get +chromium extpack serverdependent + +name GetProgramStringNV +return void +param id GLuint +param pname GLenum +paramprop pname GL_PROGRAM_STRING_NV +param program GLubyte * +category GL_NV_vertex_program +props get +chromium extpack + +name GetTrackMatrixivNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV +param address GLuint +paramlist address 0 4 8 +param pname GLenum +paramprop pname GL_TRACK_MATRIX_NV GL_TRACK_MATRIX_TRANSFORM_NV +param params GLint * +category GL_NV_vertex_program +props get +chromium extpack + +name GetVertexAttribdvNV +return void +param index GLuint +param pname GLenum +paramprop pname GL_ATTRIB_ARRAY_SIZE_NV GL_ATTRIB_ARRAY_STRIDE_NV GL_ATTRIB_ARRAY_TYPE_NV GL_CURRENT_ATTRIB_NV +param params GLdouble * +category GL_NV_vertex_program +props get +chromium extpack + +name GetVertexAttribfvNV +return void +param index GLuint +param pname GLenum +paramprop pname GL_ATTRIB_ARRAY_SIZE_NV GL_ATTRIB_ARRAY_STRIDE_NV GL_ATTRIB_ARRAY_TYPE_NV GL_CURRENT_ATTRIB_NV +param params GLfloat * +category GL_NV_vertex_program +props get +chromium extpack + +name GetVertexAttribivNV +return void +param index GLuint +param pname GLenum +paramprop pname GL_ATTRIB_ARRAY_SIZE_NV GL_ATTRIB_ARRAY_STRIDE_NV GL_ATTRIB_ARRAY_TYPE_NV GL_CURRENT_ATTRIB_NV +param params GLint * +category GL_NV_vertex_program +props get +chromium extpack + +name GetVertexAttribPointervNV +return void +param index GLuint +param pname GLenum +paramprop pname GL_ATTRIB_ARRAY_POINTER_NV +param pointer GLvoid ** +category GL_NV_vertex_program +props get useclient +chromium extpack + +name IsProgramNV +return GLboolean +param id GLuint +category GL_NV_vertex_program +props get +alias IsProgramARB +chromium nopack + +name LoadProgramNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param id GLuint +param len GLsizei +param program const GLubyte * +category GL_NV_vertex_program +chromium extpack + +name ProgramParameter4dNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category GL_NV_vertex_program +chromium extpack + +name ProgramParameter4dvNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param params const GLdouble * +vector params 4 +category GL_NV_vertex_program +chromium extpack +vectoralias ProgramParameter4dNV + +name ProgramParameter4fNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category GL_NV_vertex_program +chromium extpack + +name ProgramParameter4fvNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param params const GLfloat * +vector params 4 +category GL_NV_vertex_program +chromium extpack +vectoralias ProgramParameter4fNV + +name ProgramParameters4dvNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param num GLuint +param params const GLdouble * +vector params 4 +category GL_NV_vertex_program +chromium extpack + +name ProgramParameters4fvNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV GL_FRAGMENT_PROGRAM_NV +param index GLuint +param num GLuint +param params const GLfloat * +vector params 4 +category GL_NV_vertex_program +chromium extpack + +name RequestResidentProgramsNV +return void +param n GLsizei +param ids const GLuint * +category GL_NV_vertex_program +chromium extpack + +name TrackMatrixNV +return void +param target GLenum +paramprop target GL_VERTEX_PROGRAM_NV +param address GLuint +paramlist address 0 4 8 +param matrix GLenum +paramprop matrix GL_NONE GL_MODELVIEW GL_PROJECTION GL_TEXTURE GL_COLOR GL_MODELVIEW_PROJECTION_NV GL_TEXTURE0_ARB GL_TEXTURE1_ARB GL_TEXTURE2_ARB GL_TEXTURE3_ARB GL_TEXTURE4_ARB GL_TEXTURE5_ARB GL_TEXTURE6_ARB GL_TEXTURE7_ARB GL_TEXTURE8_ARB GL_TEXTURE9_ARB GL_TEXTURE10_ARB GL_TEXTURE11_ARB GL_TEXTURE12_ARB GL_TEXTURE13_ARB GL_TEXTURE14_ARB GL_TEXTURE15_ARB GL_TEXTURE16_ARB GL_TEXTURE17_ARB GL_TEXTURE18_ARB GL_TEXTURE19_ARB GL_TEXTURE20_ARB GL_TEXTURE21_ARB GL_TEXTURE22_ARB GL_TEXTURE23_ARB GL_TEXTURE24_ARB GL_TEXTURE25_ARB GL_TEXTURE26_ARB GL_TEXTURE27_ARB GL_TEXTURE28_ARB GL_TEXTURE29_ARB GL_TEXTURE30_ARB GL_TEXTURE31_ARB GL_MATRIX0_NV GL_MATRIX1_NV GL_MATRIX2_NV GL_MATRIX3_NV GL_MATRIX4_NV GL_MATRIX5_NV GL_MATRIX6_NV GL_MATRIX7_NV +param transform GLenum +paramprop transform GL_IDENTITY_NV GL_INVERSE_NV GL_TRANSPOSE_NV GL_INVERSE_TRANSPOSE_NV +category GL_NV_vertex_program +chromium extpack + +name VertexAttribPointerNV +return void +param index GLuint +param size GLint +param type GLenum +paramprop type GL_SHORT GL_FLOAT GL_DOUBLE GL_UNSIGNED_BYTE +param stride GLsizei +param pointer const GLvoid * +category GL_NV_vertex_program +props setclient +chromium extpack + +name VertexAttrib1dNV +return void +param index GLuint +param x GLdouble +category GL_NV_vertex_program +props pervertex +alias VertexAttrib1dARB + +name VertexAttrib1dvNV +return void +param index GLuint +param v const GLdouble * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib1dvARB + +name VertexAttrib1fNV +return void +param index GLuint +param x GLfloat +category GL_NV_vertex_program +props pervertex +alias VertexAttrib1fARB + +name VertexAttrib1fvNV +return void +param index GLuint +param v const GLfloat * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib1fvARB + +name VertexAttrib1sNV +return void +param index GLuint +param x GLshort +category GL_NV_vertex_program +props pervertex +alias VertexAttrib1sARB + +name VertexAttrib1svNV +return void +param index GLuint +param v const GLshort * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib1svARB + +name VertexAttrib2dNV +return void +param index GLuint +param x GLdouble +param y GLdouble +category GL_NV_vertex_program +props pervertex +alias VertexAttrib2dARB + +name VertexAttrib2dvNV +return void +param index GLuint +param v const GLdouble * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib2dvARB + +name VertexAttrib2fNV +return void +param index GLuint +param x GLfloat +param y GLfloat +category GL_NV_vertex_program +props pervertex +alias VertexAttrib2fARB + +name VertexAttrib2fvNV +return void +param index GLuint +param v const GLfloat * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib2fvARB + +name VertexAttrib2sNV +return void +param index GLuint +param x GLshort +param y GLshort +category GL_NV_vertex_program +props pervertex +alias VertexAttrib2sARB + +name VertexAttrib2svNV +return void +param index GLuint +param v const GLshort * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib2svARB + +name VertexAttrib3dNV +return void +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +category GL_NV_vertex_program +props pervertex +alias VertexAttrib3dARB + +name VertexAttrib3dvNV +return void +param index GLuint +param v const GLdouble * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib3dvARB + +name VertexAttrib3fNV +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +category GL_NV_vertex_program +props pervertex +alias VertexAttrib3fARB + +name VertexAttrib3fvNV +return void +param index GLuint +param v const GLfloat * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib3fvARB + +name VertexAttrib3sNV +return void +param index GLuint +param x GLshort +param y GLshort +param z GLshort +category GL_NV_vertex_program +props pervertex +alias VertexAttrib3sARB + +name VertexAttrib3svNV +return void +param index GLuint +param v const GLshort * +category GL_NV_vertex_program +props pervertex +alias VertexAttrib3svARB + +name VertexAttrib4dNV +return void +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category GL_NV_vertex_program +props pervertex +alias VertexAttrib4dARB + +name VertexAttrib4dvNV +return void +param index GLuint +param v const GLdouble * +vector v 4 +category GL_NV_vertex_program +props pervertex +alias VertexAttrib4dvARB + +name VertexAttrib4fNV +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category GL_NV_vertex_program +props pervertex +alias VertexAttrib4fARB + +name VertexAttrib4fvNV +return void +param index GLuint +param v const GLfloat * +vector v 4 +category GL_NV_vertex_program +props pervertex +alias VertexAttrib4fvARB + +name VertexAttrib4sNV +return void +param index GLuint +param x GLshort +param y GLshort +param z GLshort +param w GLshort +category GL_NV_vertex_program +props pervertex +alias VertexAttrib4sARB + +name VertexAttrib4svNV +return void +param index GLuint +param v const GLshort * +vector v 4 +category GL_NV_vertex_program +props pervertex +alias VertexAttrib4svARB + +name VertexAttrib4ubNV +return void +param index GLuint +param x GLubyte +param y GLubyte +param z GLubyte +param w GLubyte +category GL_NV_vertex_program +props pervertex +alias VertexAttrib4NubARB + +name VertexAttrib4ubvNV +return void +param index GLuint +param v const GLubyte * +vector v 4 +category GL_NV_vertex_program +alias VertexAttrib4NubvARB +props pervertex +chromium nopack + +name VertexAttribs1dvNV +return void +param index GLuint +param n GLsizei +param v const GLdouble * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs1fvNV +return void +param index GLuint +param n GLsizei +param v const GLfloat * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs1svNV +return void +param index GLuint +param n GLsizei +param v const GLshort * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs2dvNV +return void +param index GLuint +param n GLsizei +param v const GLdouble * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs2fvNV +return void +param index GLuint +param n GLsizei +param v const GLfloat * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs2svNV +return void +param index GLuint +param n GLsizei +param v const GLshort * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs3dvNV +return void +param index GLuint +param n GLsizei +param v const GLdouble * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs3fvNV +return void +param index GLuint +param n GLsizei +param v const GLfloat * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs3svNV +return void +param index GLuint +param n GLsizei +param v const GLshort * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs4dvNV +return void +param index GLuint +param n GLsizei +param v const GLdouble * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs4fvNV +return void +param index GLuint +param n GLsizei +param v const GLfloat * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs4svNV +return void +param index GLuint +param n GLsizei +param v const GLshort * +category GL_NV_vertex_program +props pervertex +chromium expandpack + +name VertexAttribs4ubvNV +return void +param index GLuint +param n GLsizei +param v const GLubyte * +category GL_NV_vertex_program +props pervertex +chromium expandpack + + +# GL_NV_fragment_program + +name ProgramNamedParameter4fNV +return void +param id GLuint +param len GLsizei +param name const GLubyte * +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category GL_NV_fragment_program +chromium extpack + +name ProgramNamedParameter4dNV +return void +param id GLuint +param len GLsizei +param name const GLubyte * +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category GL_NV_fragment_program +chromium extpack + +name ProgramNamedParameter4fvNV +return void +param id GLuint +param len GLsizei +param name const GLubyte * +param v const GLfloat * +category GL_NV_fragment_program +chromium extpack + +name ProgramNamedParameter4dvNV +return void +param id GLuint +param len GLsizei +param name const GLubyte * +param v const GLdouble * +vector v 4 +category GL_NV_fragment_program +chromium extpack + +name GetProgramNamedParameterfvNV +return void +param id GLuint +param len GLsizei +param name const GLubyte * +param params GLfloat * +vector params 4 +category GL_NV_fragment_program +props get +chromium extpack + +name GetProgramNamedParameterdvNV +return void +param id GLuint +param len GLsizei +param name const GLubyte * +param params GLdouble * +vector params 4 +category GL_NV_fragment_program +props get +chromium extpack + + +# GL_ARB_vertex_buffer_object + +name BindBufferARB +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param buffer GLuint +category GL_ARB_vertex_buffer_object +props nolist +chromium extpack + +name BufferDataARB +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param size GLsizeiptrARB +param data const GLvoid * +param usage GLenum +paramprop usage GL_STREAM_DRAW_ARB GL_STREAM_READ_ARB GL_STREAM_COPY_ARB GL_STATIC_DRAW_ARB GL_STATIC_READ_ARB GL_STATIC_COPY_ARB GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_READ_ARB GL_DYNAMIC_COPY_ARB +category GL_ARB_vertex_buffer_object +props nolist +chromium extpack + +name BufferSubDataARB +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param offset GLintptrARB +param size GLsizeiptrARB +param data const GLvoid * +category GL_ARB_vertex_buffer_object +props nolist +chromium extpack + +name DeleteBuffersARB +return void +param n GLsizei +param buffer const GLuint * +category GL_ARB_vertex_buffer_object +props nolist +chromium extpack + +name GenBuffersARB +return void +param n GLsizei +param buffer GLuint * +category GL_ARB_vertex_buffer_object +props get +chromium extpack serverdependent + +name GetBufferParameterivARB +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param pname GLenum +paramprop pname GL_BUFFER_SIZE_ARB GL_BUFFER_USAGE_ARB GL_BUFFER_ACCESS_ARB GL_BUFFER_MAPPED_ARB +param params GLint * +category GL_ARB_vertex_buffer_object +props get +chromium extpack + +name GetBufferPointervARB +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param pname GLenum +paramprop pname GL_BUFFER_MAP_POINTER_ARB +param params GLvoid ** +category GL_ARB_vertex_buffer_object +props get useclient +chromium nopack + +name GetBufferSubDataARB +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param offset GLintptrARB +param size GLsizeiptrARB +param data void * +category GL_ARB_vertex_buffer_object +props get +chromium extpack + +name IsBufferARB +return GLboolean +param buffer GLuint +paramaction buffer initBuffer +category GL_ARB_vertex_buffer_object +props get +chromium extpack + +name MapBufferARB +return void * +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param access GLenum +paramprop access GL_READ_ONLY_ARB GL_WRITE_ONLY_ARB GL_READ_WRITE_ARB +category GL_ARB_vertex_buffer_object +props nolist get +chromium nopack + +name UnmapBufferARB +return GLboolean +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +category GL_ARB_vertex_buffer_object +props nolist get +chromium nopack + + + +# GL_EXT_depth_bounds_test + +name DepthBoundsEXT +return void +param zmin GLclampd +param zmax GLclampd +category GL_EXT_depth_bounds_test +chromium omit + + +# GL_ARB_occlusion_query + +name GenQueriesARB +return void +param n GLsizei +param ids GLuint * +category GL_ARB_occlusion_query +props get +chromium extpack serverdependent + +name DeleteQueriesARB +return void +param n GLsizei +param ids const GLuint * +category GL_ARB_occlusion_query +props nolist +chromium extpack + +name IsQueryARB +return GLboolean +param id GLuint +category GL_ARB_occlusion_query +props get +chromium extpack + +name BeginQueryARB +return void +param target GLenum +paramprop target GL_SAMPLES_PASSED_ARB +param id GLuint +category GL_ARB_occlusion_query +chromium extpack + +name EndQueryARB +return void +param target GLenum +paramprop target GL_SAMPLES_PASSED_ARB +category GL_ARB_occlusion_query +chromium extpack + +name GetQueryivARB +return void +param target GLenum +paramprop target GL_SAMPLES_PASSED_ARB +param pname GLenum +paramprop pname GL_QUERY_COUNTER_BITS_ARB GL_CURRENT_QUERY_ARB +param params GLint * +category GL_ARB_occlusion_query +props get +chromium extpack serverdpendent + +name GetQueryObjectivARB +return void +param id GLuint +param pname GLenum +paramprop pname GL_QUERY_RESULT_ARB GL_QUERY_RESULT_AVAILABLE_ARB +param params GLint * +category GL_ARB_occlusion_query +props get +chromium extpack serverdependent + +name GetQueryObjectuivARB +return void +param id GLuint +param pname GLenum +paramprop pname GL_QUERY_RESULT_ARB GL_QUERY_RESULT_AVAILABLE_ARB +param params GLuint * +category GL_ARB_occlusion_query +props get +chromium extpack serverdependent + + + +# Chromium + +name CreateContext +return GLint +param dpyName const char * +param visual GLint +param shareCtx GLint +category Chromium +props nolist get +chromium extpack + +name DestroyContext +return void +param ctx GLint +category Chromium +props nolist +chromium extpack + +name MakeCurrent +return void +param window GLint +param nativeWindow GLint +param ctx GLint +category Chromium +props nolist +chromium extpack + +name WindowCreate +return GLint +param dpyName const char * +param visBits GLint +category Chromium +props nolist get +chromium extpack + +name WindowDestroy +return void +param window GLint +category Chromium +props nolist +chromium extpack + +name WindowSize +return void +param window GLint +param w GLint +param h GLint +category Chromium +props nolist +chromium extpack + +name WindowPosition +return void +param window GLint +param x GLint +param y GLint +category Chromium +props nolist +chromium extpack + +name WindowVisibleRegion +return void +param window GLint +param cRects GLint +param pRects const GLint * +category Chromium +props nolist +chromium extpack + +name VBoxTexPresent +return void +param texture GLuint +param cfg GLuint +param xPos GLint +param yPos GLint +param cRects GLint +param pRects const GLint * +category Chromium +props nolist +chromium extpack +chrelopcode 0 + +# custom +name GetAttribsLocations +return void +param program GLuint +param maxcbData GLsizei +param cbData GLsizei * +param pData GLvoid * +category Chromium +props get +chromium extpack +chrelopcode 1 + +name WindowShow +return void +param window GLint +param flag GLint +category Chromium +props nolist +chromium extpack + +name SwapBuffers +return void +param window GLint +param flags GLint +category Chromium +props nolist +chromium extpack + +name Writeback +return void +param writeback GLint * +category Chromium +props nolist +chromium extpack + +name BarrierCreateCR +return void +param name GLuint +param count GLuint +category GL_chromium +props nolist +chromium extpack + +name BarrierDestroyCR +return void +param name GLuint +category GL_chromium +props nolist +chromium extpack + +name BarrierExecCR +return void +param name GLuint +category GL_chromium +props nolist +chromium extpack + +name SemaphoreCreateCR +return void +param name GLuint +param count GLuint +category GL_chromium +props nolist +chromium extpack + +name SemaphoreDestroyCR +return void +param name GLuint +category GL_chromium +props nolist +chromium extpack + +name SemaphorePCR +return void +param name GLuint +category GL_chromium +props nolist +chromium extpack + +name SemaphoreVCR +return void +param name GLuint +category GL_chromium +props nolist +chromium extpack + +name BoundsInfoCR +return void +param bounds const CRrecti * +param payload const GLbyte * +param len GLint +param num_opcodes GLint +category GL_chromium +props nolist +chromium pack + +name ChromiumParameteriCR +return void +param target GLenum +paramprop target GL_CURSOR_POSITION_CR GL_DEFAULT_BBOX_CR GL_SCREEN_BBOX_CR GL_OBJECT_BBOX_CR GL_PRINT_STRING_CR GL_MURAL_SIZE_CR GL_NUM_SERVERS_CR GL_NUM_TILES_CR GL_TILE_BOUNDS_CR GL_VERTEX_COUNTS_CR GL_RESET_VERTEX_COUNTERS_CR GL_SET_MAX_VIEWPORT_CR GL_HEAD_SPU_NAME_CR GL_PERF_GET_FRAME_DATA_CR GL_PERF_GET_TIMER_DATA_CR GL_PERF_DUMP_COUNTERS_CR GL_PERF_SET_TOKEN_CR GL_PERF_SET_DUMP_ON_SWAP_CR GL_PERF_SET_DUMP_ON_FINISH_CR GL_PERF_SET_DUMP_ON_FLUSH_CR GL_PERF_START_TIMER_CR GL_PERF_STOP_TIMER_CR GL_WINDOW_SIZE_CR GL_TILE_INFO_CR GL_GATHER_DRAWPIXELS_CR GL_GATHER_PACK_CR GL_GATHER_CONNECT_CR GL_GATHER_POST_SWAPBUFFERS_CR GL_SAVEFRAME_ENABLED_CR GL_SAVEFRAME_FRAMENUM_CR GL_SAVEFRAME_STRIDE_CR GL_SAVEFRAME_SINGLE_CR GL_SAVEFRAME_FILESPEC_CR GL_READBACK_BARRIER_SIZE_CR +param value GLint +category GL_chromium +props nolist +chromium extpack + +name ChromiumParameterfCR +return void +param target GLenum +paramprop target GL_CURSOR_POSITION_CR GL_DEFAULT_BBOX_CR GL_SCREEN_BBOX_CR GL_OBJECT_BBOX_CR GL_PRINT_STRING_CR GL_MURAL_SIZE_CR GL_NUM_SERVERS_CR GL_NUM_TILES_CR GL_TILE_BOUNDS_CR GL_VERTEX_COUNTS_CR GL_RESET_VERTEX_COUNTERS_CR GL_SET_MAX_VIEWPORT_CR GL_HEAD_SPU_NAME_CR GL_PERF_GET_FRAME_DATA_CR GL_PERF_GET_TIMER_DATA_CR GL_PERF_DUMP_COUNTERS_CR GL_PERF_SET_TOKEN_CR GL_PERF_SET_DUMP_ON_SWAP_CR GL_PERF_SET_DUMP_ON_FINISH_CR GL_PERF_SET_DUMP_ON_FLUSH_CR GL_PERF_START_TIMER_CR GL_PERF_STOP_TIMER_CR GL_WINDOW_SIZE_CR GL_TILE_INFO_CR GL_GATHER_DRAWPIXELS_CR GL_GATHER_PACK_CR GL_GATHER_CONNECT_CR GL_GATHER_POST_SWAPBUFFERS_CR GL_SAVEFRAME_ENABLED_CR GL_SAVEFRAME_FRAMENUM_CR GL_SAVEFRAME_STRIDE_CR GL_SAVEFRAME_SINGLE_CR GL_SAVEFRAME_FILESPEC_CR GL_READBACK_BARRIER_SIZE_CR +param value GLfloat +category GL_chromium +props nolist +chromium extpack + +name ChromiumParametervCR +return void +param target GLenum +paramprop target GL_CURSOR_POSITION_CR GL_DEFAULT_BBOX_CR GL_SCREEN_BBOX_CR GL_OBJECT_BBOX_CR GL_PRINT_STRING_CR GL_MURAL_SIZE_CR GL_NUM_SERVERS_CR GL_NUM_TILES_CR GL_TILE_BOUNDS_CR GL_VERTEX_COUNTS_CR GL_RESET_VERTEX_COUNTERS_CR GL_SET_MAX_VIEWPORT_CR GL_HEAD_SPU_NAME_CR GL_PERF_GET_FRAME_DATA_CR GL_PERF_GET_TIMER_DATA_CR GL_PERF_DUMP_COUNTERS_CR GL_PERF_SET_TOKEN_CR GL_PERF_SET_DUMP_ON_SWAP_CR GL_PERF_SET_DUMP_ON_FINISH_CR GL_PERF_SET_DUMP_ON_FLUSH_CR GL_PERF_START_TIMER_CR GL_PERF_STOP_TIMER_CR GL_WINDOW_SIZE_CR GL_TILE_INFO_CR GL_GATHER_DRAWPIXELS_CR GL_GATHER_PACK_CR GL_GATHER_CONNECT_CR GL_GATHER_POST_SWAPBUFFERS_CR GL_SAVEFRAME_ENABLED_CR GL_SAVEFRAME_FRAMENUM_CR GL_SAVEFRAME_STRIDE_CR GL_SAVEFRAME_SINGLE_CR GL_SAVEFRAME_FILESPEC_CR GL_READBACK_BARRIER_SIZE_CR +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_DOUBLE +param count GLsizei +param values const GLvoid * +category GL_chromium +props nolist +chromium extpack serverdependent + +name GetChromiumParametervCR +return void +param target GLenum +paramprop target GL_CURSOR_POSITION_CR GL_DEFAULT_BBOX_CR GL_SCREEN_BBOX_CR GL_OBJECT_BBOX_CR GL_PRINT_STRING_CR GL_MURAL_SIZE_CR GL_NUM_SERVERS_CR GL_NUM_TILES_CR GL_TILE_BOUNDS_CR GL_VERTEX_COUNTS_CR GL_RESET_VERTEX_COUNTERS_CR GL_SET_MAX_VIEWPORT_CR GL_HEAD_SPU_NAME_CR GL_PERF_GET_FRAME_DATA_CR GL_PERF_GET_TIMER_DATA_CR GL_PERF_DUMP_COUNTERS_CR GL_PERF_SET_TOKEN_CR GL_PERF_SET_DUMP_ON_SWAP_CR GL_PERF_SET_DUMP_ON_FINISH_CR GL_PERF_SET_DUMP_ON_FLUSH_CR GL_PERF_START_TIMER_CR GL_PERF_STOP_TIMER_CR GL_WINDOW_SIZE_CR GL_TILE_INFO_CR GL_GATHER_DRAWPIXELS_CR GL_GATHER_PACK_CR GL_GATHER_CONNECT_CR GL_GATHER_POST_SWAPBUFFERS_CR GL_SAVEFRAME_ENABLED_CR GL_SAVEFRAME_FRAMENUM_CR GL_SAVEFRAME_STRIDE_CR GL_SAVEFRAME_SINGLE_CR GL_SAVEFRAME_FILESPEC_CR GL_READBACK_BARRIER_SIZE_CR +param index GLuint +paramlist index 0 1 2 +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_DOUBLE +param count GLsizei +param values GLvoid * +category GL_chromium +props get +chromium extpack + +name VBoxPackSetInjectThread +return GLint +param pHgsmi struct VBOXUHGSMI * +category VBox +chromium nopack + +name VBoxPackGetInjectID +return GLuint +param con GLint +category VBox +chromium nopack + +name VBoxPackSetInjectID +return void +param id GLuint +category VBox +chromium nopack + +name VBoxAttachThread +return void +category VBox +chromium nopack + +name VBoxDetachThread +return void +category VBox +chromium nopack + +name VBoxCreateContext +return GLint +param con GLint +param dpyName const char * +param visual GLint +param shareCtx GLint +category VBox +chromium nopack + +name VBoxConChromiumParameteriCR +return void +param con GLint +param target GLenum +paramprop target GL_CURSOR_POSITION_CR GL_DEFAULT_BBOX_CR GL_SCREEN_BBOX_CR GL_OBJECT_BBOX_CR GL_PRINT_STRING_CR GL_MURAL_SIZE_CR GL_NUM_SERVERS_CR GL_NUM_TILES_CR GL_TILE_BOUNDS_CR GL_VERTEX_COUNTS_CR GL_RESET_VERTEX_COUNTERS_CR GL_SET_MAX_VIEWPORT_CR GL_HEAD_SPU_NAME_CR GL_PERF_GET_FRAME_DATA_CR GL_PERF_GET_TIMER_DATA_CR GL_PERF_DUMP_COUNTERS_CR GL_PERF_SET_TOKEN_CR GL_PERF_SET_DUMP_ON_SWAP_CR GL_PERF_SET_DUMP_ON_FINISH_CR GL_PERF_SET_DUMP_ON_FLUSH_CR GL_PERF_START_TIMER_CR GL_PERF_STOP_TIMER_CR GL_WINDOW_SIZE_CR GL_TILE_INFO_CR GL_GATHER_DRAWPIXELS_CR GL_GATHER_PACK_CR GL_GATHER_CONNECT_CR GL_GATHER_POST_SWAPBUFFERS_CR GL_SAVEFRAME_ENABLED_CR GL_SAVEFRAME_FRAMENUM_CR GL_SAVEFRAME_STRIDE_CR GL_SAVEFRAME_SINGLE_CR GL_SAVEFRAME_FILESPEC_CR GL_READBACK_BARRIER_SIZE_CR +param value GLint +category VBox +chromium nopack + +name VBoxConChromiumParametervCR +return void +param con GLint +param target GLenum +paramprop target GL_CURSOR_POSITION_CR GL_DEFAULT_BBOX_CR GL_SCREEN_BBOX_CR GL_OBJECT_BBOX_CR GL_PRINT_STRING_CR GL_MURAL_SIZE_CR GL_NUM_SERVERS_CR GL_NUM_TILES_CR GL_TILE_BOUNDS_CR GL_VERTEX_COUNTS_CR GL_RESET_VERTEX_COUNTERS_CR GL_SET_MAX_VIEWPORT_CR GL_HEAD_SPU_NAME_CR GL_PERF_GET_FRAME_DATA_CR GL_PERF_GET_TIMER_DATA_CR GL_PERF_DUMP_COUNTERS_CR GL_PERF_SET_TOKEN_CR GL_PERF_SET_DUMP_ON_SWAP_CR GL_PERF_SET_DUMP_ON_FINISH_CR GL_PERF_SET_DUMP_ON_FLUSH_CR GL_PERF_START_TIMER_CR GL_PERF_STOP_TIMER_CR GL_WINDOW_SIZE_CR GL_TILE_INFO_CR GL_GATHER_DRAWPIXELS_CR GL_GATHER_PACK_CR GL_GATHER_CONNECT_CR GL_GATHER_POST_SWAPBUFFERS_CR GL_SAVEFRAME_ENABLED_CR GL_SAVEFRAME_FRAMENUM_CR GL_SAVEFRAME_STRIDE_CR GL_SAVEFRAME_SINGLE_CR GL_SAVEFRAME_FILESPEC_CR GL_READBACK_BARRIER_SIZE_CR +param type GLenum +paramprop type GL_BYTE GL_UNSIGNED_BYTE GL_SHORT GL_UNSIGNED_SHORT GL_INT GL_UNSIGNED_INT GL_FLOAT GL_DOUBLE +param count GLsizei +param values const GLvoid * +category VBox +props nolist +chromium nopack + + +name VBoxWindowCreate +return GLint +param con GLint +param dpyName const char * +param visBits GLint +category VBox +chromium nopack + +name VBoxWindowDestroy +return void +param con GLint +param window GLint +category VBox +chromium nopack + +name VBoxConCreate +return GLint +param pHgsmi struct VBOXUHGSMI * +category VBox +chromium nopack + +name VBoxConDestroy +return void +param con GLint +category VBox +chromium nopack + +name VBoxConFlush +return void +param con GLint +category VBox +chromium nopack + +name VBoxPresentComposition +return void +param win GLint +param pCompositor const struct VBOXVR_SCR_COMPOSITOR * +param pChangedEntry const struct VBOXVR_SCR_COMPOSITOR_ENTRY * +category VBox +chromium nopack + + +# OpenGL 1.5 + +name BindBuffer +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param buffer GLuint +category 1.5 +alias BindBufferARB +props nolist +chromium extpack + +name BufferData +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param size GLsizeiptrARB +param data const GLvoid * +param usage GLenum +paramprop usage GL_STREAM_DRAW_ARB GL_STREAM_READ_ARB GL_STREAM_COPY_ARB GL_STATIC_DRAW_ARB GL_STATIC_READ_ARB GL_STATIC_COPY_ARB GL_DYNAMIC_DRAW_ARB GL_DYNAMIC_READ_ARB GL_DYNAMIC_COPY_ARB +category 1.5 +alias BufferDataARB +props nolist +chromium extpack + +name BufferSubData +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param offset GLintptrARB +param size GLsizeiptrARB +param data const GLvoid * +category 1.5 +alias BufferSubDataARB +props nolist +chromium extpack + +name DeleteBuffers +return void +param n GLsizei +paramlist n 0 +param buffer const GLuint * +category 1.5 +alias DeleteBuffersARB +props nolist +chromium extpack + +name GenBuffers +return void +param n GLsizei +paramlist n 2 +param buffer GLuint * +category 1.5 +alias GenBuffersARB +props get +chromium extpack serverdependent + +name GetBufferParameteriv +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param pname GLenum +paramprop pname GL_BUFFER_SIZE_ARB GL_BUFFER_USAGE_ARB GL_BUFFER_ACCESS_ARB GL_BUFFER_MAPPED_ARB +param params GLint * +category 1.5 +alias GetBufferParameterivARB +props get +chromium extpack + +name GetBufferPointerv +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param pname GLenum +paramprop pname GL_BUFFER_MAP_POINTER_ARB +param params GLvoid ** +category 1.5 +alias GetBufferPointervARB +props get useclient +chromium nopack + +name GetBufferSubData +return void +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param offset GLintptrARB +param size GLsizeiptrARB +param data void * +category 1.5 +alias GetBufferSubDataARB +props get +chromium extpack + +name IsBuffer +return GLboolean +param buffer GLuint +paramlist buffer 0 +category 1.5 +alias IsBufferARB +props get +chromium extpack + +name MapBuffer +return void * +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +param access GLenum +paramprop access GL_READ_ONLY_ARB GL_WRITE_ONLY_ARB GL_READ_WRITE_ARB +category 1.5 +alias MapBufferARB +props nolist +chromium nopack + +name UnmapBuffer +return GLboolean +param target GLenum +paramprop target GL_ARRAY_BUFFER_ARB GL_ELEMENT_ARRAY_BUFFER_ARB +category 1.5 +alias UnmapBufferARB +props nolist +chromium nopack + + +name GenQueries +return void +param n GLsizei +paramlist n 0 +param ids GLuint * +category 1.5 +alias GenQueriesARB +props get +chromium omit + +name DeleteQueries +return void +param n GLsizei +paramlist n 0 +param ids const GLuint * +category 1.5 +alias DeleteQueriesARB +props nolist +chromium omit + +name IsQuery +return GLboolean +param id GLuint +paramlist id 0 +category 1.5 +alias IsQueryARB +props get +chromium omit + +name BeginQuery +return void +param target GLenum +paramprop target GL_SAMPLES_PASSED_ARB +param id GLuint +paramlist id 0 +category 1.5 +alias BeginQueryARB +chromium omit + +name EndQuery +return void +param target GLenum +paramprop target GL_SAMPLES_PASSED_ARB +category 1.5 +alias EndQueryARB +chromium omit + +name GetQueryiv +return void +param target GLenum +paramprop target GL_SAMPLES_PASSED_ARB +param pname GLenum +paramprop pname GL_QUERY_COUNTER_BITS_ARB GL_CURRENT_QUERY_ARB +param params GLint * +category 1.5 +alias GetQueryivARB +props get +chromium omit + +name GetQueryObjectiv +return void +param id GLuint +paramlist id 0 +param pname GLenum +paramprop pname GL_QUERY_RESULT_ARB GL_QUERY_RESULT_AVAILABLE_ARB +param params GLint * +category 1.5 +alias GetQueryObjectivARB +props get +chromium omit + +name GetQueryObjectuiv +return void +param id GLuint +paramlist id 0 +param pname GLenum +paramprop pname GL_QUERY_RESULT_ARB GL_QUERY_RESULT_AVAILABLE_ARB +param params GLuint * +category 1.5 +alias GetQueryObjectuivARB +props get +chromium omit + +# +# Simple-minded pixel compression for Mike Houston +# +name ZPixCR +return void +param width GLsizei +param height GLsizei +param format GLenum +param type GLenum +param ztype GLenum +param zparm GLint +param length GLint +param pixels const GLvoid * +category GL_chromium +props render pixelstore +chromium extpack + +# GL_ARB_draw_buffers + +name DrawBuffersARB +alias DrawBuffers +return void +param n GLsizei +param bufs const GLenum* +category GL_ARB_draw_buffers +chromium omit + +# OpenGL 2.0 + +name CreateShader +return GLuint +param type GLenum +paramprop type GL_VERTEX_SHADER GL_FRAGMENT_SHADER +category 2.0 +props get +chromium extpack serverdependent + +name ShaderSource +return void +param shader GLuint +param count GLsizei +param string const char ** +param length const GLint * +category 2.0 +chromium extpack + +name CompileShader +return void +param shader GLuint +category 2.0 +chromium extpack + +name DeleteShader +return void +param shader GLuint +category 2.0 +props nolist +chromium extpack + +name IsShader +return GLboolean +param shader GLuint +category 2.0 +props get +chromium extpack + +name CreateProgram +return GLuint +category 2.0 +props get +chromium extpack serverdependent + +name AttachShader +return void +param program GLuint +param shader GLuint +category 2.0 +chromium extpack + +name DetachShader +return void +param program GLuint +param shader GLuint +category 2.0 +chromium extpack + +name LinkProgram +return void +param program GLuint +category 2.0 +chromium extpack + +name UseProgram +return void +param program GLuint +category 2.0 +chromium extpack + +name DeleteProgram +return void +param program GLuint +category 2.0 +props nolist +chromium extpack + +name ValidateProgram +return void +param program GLuint +category 2.0 +chromium extpack + +name IsProgram +return GLboolean +param program GLuint +category 2.0 +props get +chromium extpack + +name GetActiveAttrib +return void +param program GLuint +param index GLuint +param bufSize GLsizei +param length GLsizei * +param size GLint * +param type GLenum * +param name char * +category 2.0 +props get +chromium extpack + +name GetAttribLocation +return GLint +param program GLuint +param name const char * +category 2.0 +props get +chromium extpack + +name BindAttribLocation +return void +param program GLuint +param index GLuint +param name const char * +category 2.0 +chromium extpack + +name GetUniformLocation +return GLint +param program GLuint +param name const char * +category 2.0 +props get +chromium extpack + +name GetActiveUniform +return void +param program GLuint +param index GLuint +param bufSize GLsizei +param length GLsizei * +param size GLint * +param type GLenum * +param name char * +category 2.0 +props get +chromium extpack + +name Uniform1f +return void +param location GLint +param v0 GLfloat +category 2.0 +chromium extpack + +name Uniform2f +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +category 2.0 +chromium extpack + +name Uniform3f +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +param v2 GLfloat +category 2.0 +chromium extpack + +name Uniform4f +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +param v2 GLfloat +param v3 GLfloat +category 2.0 +chromium extpack + +name Uniform1i +return void +param location GLint +param v0 GLint +category 2.0 +chromium extpack + +name Uniform2i +return void +param location GLint +param v0 GLint +param v1 GLint +category 2.0 +chromium extpack + +name Uniform3i +return void +param location GLint +param v0 GLint +param v1 GLint +param v2 GLint +category 2.0 +chromium extpack + +name Uniform4i +return void +param location GLint +param v0 GLint +param v1 GLint +param v2 GLint +param v3 GLint +category 2.0 +chromium extpack + +name Uniform1fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category 2.0 +chromium extpack + +name Uniform2fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category 2.0 +chromium extpack + +name Uniform3fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category 2.0 +chromium extpack + +name Uniform4fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category 2.0 +chromium extpack + +name Uniform1iv +return void +param location GLint +param count GLsizei +param value const GLint * +category 2.0 +chromium extpack + +name Uniform2iv +return void +param location GLint +param count GLsizei +param value const GLint * +category 2.0 +chromium extpack + +name Uniform3iv +return void +param location GLint +param count GLsizei +param value const GLint * +category 2.0 +chromium extpack + +name Uniform4iv +return void +param location GLint +param count GLsizei +param value const GLint * +category 2.0 +chromium extpack + +name UniformMatrix2fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.0 +chromium extpack + +name UniformMatrix3fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.0 +chromium extpack + +name UniformMatrix4fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.0 +chromium extpack + +name GetShaderiv +return void +param shader GLuint +param pname GLenum +paramprop pname GL_SHADER_TYPE GL_DELETE_STATUS GL_COMPILE_STATUS GL_INFO_LOG_LENGTH GL_SHADER_SOURCE_LENGTH +param params GLint * +category 2.0 +props get serverdependent +chromium extpack + +name GetProgramiv +return void +param program GLuint +param pname GLenum +paramprop pname GL_DELETE_STATUS GL_LINK_STATUS GL_VALIDATE_STATUS GL_INFO_LOG_LENGTH GL_ATTACHED_SHADERS GL_ACTIVE_ATTRIBUTES GL_ACTIVE_ATTRIBUTE_MAX_LENGTH GL_ACTIVE_UNIFORMS GL_ACTIVE_UNIFORM_MAX_LENGTH +param params GLint * +category 2.0 +props get serverdependent +chromium extpack + +name GetAttachedShaders +return void +param program GLuint +param maxCount GLsizei +param count GLsizei * +param shaders GLuint * +category 2.0 +props get +chromium extpack + +name GetShaderInfoLog +return void +param shader GLuint +param bufSize GLsizei +param length GLsizei * +param infoLog char * +category 2.0 +props get serverdependent +chromium extpack + +name GetProgramInfoLog +return void +param program GLuint +param bufSize GLsizei +param length GLsizei * +param infoLog char * +category 2.0 +props get serverdependent +chromium extpack + +name GetShaderSource +return void +param shader GLuint +param bufSize GLsizei +param length GLsizei * +param source char * +category 2.0 +props get +chromium extpack + +name GetVertexAttribdv +alias GetVertexAttribdvARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_VERTEX_ATTRIB_ARRAY_SIZE GL_VERTEX_ATTRIB_ARRAY_STRIDE GL_VERTEX_ATTRIB_ARRAY_TYPE GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_CURRENT_VERTEX_ATTRIB +param params GLdouble * +paramvec params 0.0 0.0 0.0 0.0 +vector params 4 +category 2.0 +props get +chromium nopack + +name GetVertexAttribfv +alias GetVertexAttribfvARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_VERTEX_ATTRIB_ARRAY_SIZE GL_VERTEX_ATTRIB_ARRAY_STRIDE GL_VERTEX_ATTRIB_ARRAY_TYPE GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_CURRENT_VERTEX_ATTRIB +param params GLfloat * +paramvec params 0.0 0.0 0.0 0.0 +vector params 4 +category 2.0 +props get +chromium nopack + +name GetVertexAttribiv +alias GetVertexAttribivARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_VERTEX_ATTRIB_ARRAY_SIZE GL_VERTEX_ATTRIB_ARRAY_STRIDE GL_VERTEX_ATTRIB_ARRAY_TYPE GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_CURRENT_VERTEX_ATTRIB GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING +param params GLint * +paramvec params 0 0 0 0 +vector params 4 +category 2.0 +props get +chromium nopack + +name GetVertexAttribPointerv +alias GetVertexAttribPointervARB +return void +param index GLuint +paramlist index 1 2 3 4 5 6 7 +param pname GLenum +paramprop pname GL_VERTEX_ATTRIB_ARRAY_ENABLED GL_VERTEX_ATTRIB_ARRAY_SIZE GL_VERTEX_ATTRIB_ARRAY_STRIDE GL_VERTEX_ATTRIB_ARRAY_TYPE GL_VERTEX_ATTRIB_ARRAY_NORMALIZED GL_CURRENT_VERTEX_ATTRIB GL_VERTEX_ATTRIB_ARRAY_POINTER +param pointer GLvoid ** +category 2.0 +props useclient get +chromium nopack + +name GetUniformfv +return void +param program GLuint +param location GLint +param params GLfloat * +category 2.0 +props get +chromium extpack + +name GetUniformiv +return void +param program GLuint +param location GLint +param params GLint * +category 2.0 +props get +chromium extpack + +name DrawBuffers +return void +param n GLsizei +param bufs const GLenum* +category 2.0 +chromium extpack + +name StencilFuncSeparate +return void +param frontfunc GLenum +paramprop func GL_NEVER GL_LESS GL_LEQUAL GL_GREATER GL_GEQUAL GL_EQUAL GL_NOTEQUAL GL_ALWAYS +param backfunc GLenum +paramprop func GL_NEVER GL_LESS GL_LEQUAL GL_GREATER GL_GEQUAL GL_EQUAL GL_NOTEQUAL GL_ALWAYS +param ref GLint +param mask GLuint +category 2.0 +chromium extpack + +name StencilOpSeparate +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param fail GLenum +paramprop fail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP_EXT GL_DECR_WRAP_EXT +param zfail GLenum +paramprop zfail GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP_EXT GL_DECR_WRAP_EXT +param zpass GLenum +paramprop zpass GL_KEEP GL_ZERO GL_REPLACE GL_INCR GL_DECR GL_INVERT GL_INCR_WRAP_EXT GL_DECR_WRAP_EXT +category 2.0 +chromium extpack + +name StencilMaskSeparate +return void +param face GLenum +paramprop face GL_FRONT GL_BACK GL_FRONT_AND_BACK +param mask GLuint +category 2.0 +chromium extpack + +name BlendEquationSeparate +return void +param modeRGB GLenum +paramprop modeRGB GL_FUNC_ADD GL_FUNC_SUBTRACT GL_FUNC_REVERSE_SUBTRACT GL_MIN GL_MAX GL_LOGIC_OP +param modeAlpha GLenum +paramprop modeAlpha GL_FUNC_ADD GL_FUNC_SUBTRACT GL_FUNC_REVERSE_SUBTRACT GL_MIN GL_MAX GL_LOGIC_OP +category 2.0 +chromium extpack + +name VertexAttrib1s +alias VertexAttrib1sARB +return void +param index GLuint +param x GLshort +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib1f +alias VertexAttrib1fARB +return void +param index GLuint +param x GLfloat +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib1d +alias VertexAttrib1dARB +return void +param index GLuint +param x GLdouble +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib2s +alias VertexAttrib2sARB +return void +param index GLuint +param x GLshort +param y GLshort +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib2f +alias VertexAttrib2fARB +return void +param index GLuint +param x GLfloat +param y GLfloat +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib2d +alias VertexAttrib2dARB +return void +param index GLuint +param x GLdouble +param y GLdouble +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib3s +alias VertexAttrib3sARB +return void +param index GLuint +param x GLshort +param y GLshort +param z GLshort +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib3f +alias VertexAttrib3fARB +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib3d +alias VertexAttrib3dARB +return void +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4s +alias VertexAttrib4sARB +return void +param index GLuint +param x GLshort +param y GLshort +param z GLshort +param w GLshort +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4f +alias VertexAttrib4fARB +return void +param index GLuint +param x GLfloat +param y GLfloat +param z GLfloat +param w GLfloat +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4d +alias VertexAttrib4dARB +return void +param index GLuint +param x GLdouble +param y GLdouble +param z GLdouble +param w GLdouble +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4Nub +alias VertexAttrib4NubARB +return void +param index GLuint +param x GLubyte +param y GLubyte +param z GLubyte +param w GLubyte +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib1sv +alias VertexAttrib1svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 +vector v 1 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib1fv +alias VertexAttrib1fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1.0 +vector v 1 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib1dv +alias VertexAttrib1dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 +vector v 1 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib2sv +alias VertexAttrib2svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 +vector v 2 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib2fv +alias VertexAttrib2fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1.0 1.0 +vector v 2 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib2dv +alias VertexAttrib2dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 1.0 +vector v 2 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib3sv +alias VertexAttrib3svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 +vector v 3 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib3fv +alias VertexAttrib3fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib3dv +alias VertexAttrib3dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 1.0 1.0 +vector v 3 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4bv +alias VertexAttrib4bvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLbyte * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4sv +alias VertexAttrib4svARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4iv +alias VertexAttrib4ivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLint * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4ubv +alias VertexAttrib4ubvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLubyte * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4usv +alias VertexAttrib4usvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLushort * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4uiv +alias VertexAttrib4uivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLuint * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4fv +alias VertexAttrib4fvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLfloat * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4dv +alias VertexAttrib4dvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLdouble * +paramvec v 1.0 1.0 1.0 1.0 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4Nbv +alias VertexAttrib4NbvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLbyte * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4Nsv +alias VertexAttrib4NsvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLshort * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4Niv +alias VertexAttrib4NivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLint * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4Nubv +alias VertexAttrib4NubvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLubyte * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4Nusv +alias VertexAttrib4NusvARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLushort * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttrib4Nuiv +alias VertexAttrib4NuivARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param v const GLuint * +paramvec v 1 1 1 1 +vector v 4 +category 2.0 +props pervertex +chromium nopack + +name VertexAttribPointer +alias VertexAttribPointerARB +return void +param index GLuint +paramlist index 0 1 2 3 4 5 6 7 +param size GLint +paramlist size 1 2 3 4 +param type GLenum +paramprop type GL_SHORT GL_FLOAT GL_DOUBLE +param normalized GLboolean +paramlist normalized GL_TRUE GL_FALSE +param stride GLsizei +paramlist stride 0 +param pointer const GLvoid * +category 2.0 +props setclient +chromium nopack + +name EnableVertexAttribArray +alias EnableVertexAttribArrayARB +return void +param index GLuint +category 2.0 +props setclient +chromium nopack + +name DisableVertexAttribArray +alias DisableVertexAttribArrayARB +return void +param index GLuint +category 2.0 +props setclient +chromium nopack + +# GL_ARB_shader_objects + +name GetHandleARB +return VBoxGLhandleARB +param pname GLenum +paramprop pname GL_PROGRAM_OBJECT_ARB +category GL_ARB_shader_objects +props get +chromium extpack serverdependent + +name DeleteObjectARB +return void +param obj VBoxGLhandleARB +category GL_ARB_shader_objects +props nolist +chromium extpack + +name DetachObjectARB +alias DetachShader +return void +param containerObj VBoxGLhandleARB +param attachedObj VBoxGLhandleARB +category GL_ARB_shader_objects +chromium extpack + +name CreateShaderObjectARB +alias CreateShader +return VBoxGLhandleARB +param shaderType GLenum +paramprop shaderType GL_FRAGMENT_SHADER_ARB GL_VERTEX_SHADER_ARB +category GL_ARB_shader_objects +props get +chromium nopack + +name ShaderSourceARB +alias ShaderSource +return void +param shaderObj VBoxGLhandleARB +param count GLsizei +param string const GLcharARB ** +param length const GLint * +category GL_ARB_shader_objects +chromium nopack + +name CompileShaderARB +alias CompileShader +return void +param shaderObj VBoxGLhandleARB +category GL_ARB_shader_objects +chromium nopack + +name CreateProgramObjectARB +alias CreateProgram +return VBoxGLhandleARB +category GL_ARB_shader_objects +props get +chromium nopack + +name AttachObjectARB +alias AttachShader +return void +param containerObj VBoxGLhandleARB +param obj VBoxGLhandleARB +category GL_ARB_shader_objects +chromium extpack + +name LinkProgramARB +alias LinkProgram +return void +param programObj VBoxGLhandleARB +category GL_ARB_shader_objects +chromium nopack + +name UseProgramObjectARB +alias UseProgram +return void +param programObj VBoxGLhandleARB +category GL_ARB_shader_objects +chromium nopack + +name ValidateProgramARB +alias ValidateProgram +return void +param programObj VBoxGLhandleARB +category GL_ARB_shader_objects +chromium nopack + +name Uniform1fARB +alias Uniform1f +return void +param location GLint +param v0 GLfloat +category GL_ARB_shader_objects +chromium nopack + +name Uniform2fARB +alias Uniform2f +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +category GL_ARB_shader_objects +chromium nopack + +name Uniform3fARB +alias Uniform3f +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +param v2 GLfloat +category GL_ARB_shader_objects +chromium nopack + +name Uniform4fARB +alias Uniform4f +return void +param location GLint +param v0 GLfloat +param v1 GLfloat +param v2 GLfloat +param v3 GLfloat +category GL_ARB_shader_objects +chromium nopack + +name Uniform1iARB +alias Uniform1i +return void +param location GLint +param v0 GLint +category GL_ARB_shader_objects +chromium nopack + +name Uniform2iARB +alias Uniform2i +return void +param location GLint +param v0 GLint +param v1 GLint +category GL_ARB_shader_objects +chromium nopack + +name Uniform3iARB +alias Uniform3i +return void +param location GLint +param v0 GLint +param v1 GLint +param v2 GLint +category GL_ARB_shader_objects +chromium nopack + +name Uniform4iARB +alias Uniform4i +return void +param location GLint +param v0 GLint +param v1 GLint +param v2 GLint +param v3 GLint +category GL_ARB_shader_objects +chromium nopack + +name Uniform1fvARB +alias Uniform1fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category GL_ARB_shader_objects +chromium nopack + +name Uniform2fvARB +alias Uniform2fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category GL_ARB_shader_objects +chromium nopack + +name Uniform3fvARB +alias Uniform3fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category GL_ARB_shader_objects +chromium nopack + +name Uniform4fvARB +alias Uniform4fv +return void +param location GLint +param count GLsizei +param value const GLfloat * +category GL_ARB_shader_objects +chromium nopack + +name Uniform1ivARB +alias Uniform1iv +return void +param location GLint +param count GLsizei +param value const GLint * +category GL_ARB_shader_objects +chromium nopack + +name Uniform2ivARB +alias Uniform2iv +return void +param location GLint +param count GLsizei +param value const GLint * +category GL_ARB_shader_objects +chromium nopack + +name Uniform3ivARB +alias Uniform3iv +return void +param location GLint +param count GLsizei +param value const GLint * +category GL_ARB_shader_objects +chromium nopack + +name Uniform4ivARB +alias Uniform4iv +return void +param location GLint +param count GLsizei +param value const GLint * +category GL_ARB_shader_objects +chromium nopack + +name UniformMatrix2fvARB +alias UniformMatrix2fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category GL_ARB_shader_objects +chromium nopack + +name UniformMatrix3fvARB +alias UniformMatrix3fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category GL_ARB_shader_objects +chromium nopack + +name UniformMatrix4fvARB +alias UniformMatrix4fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category GL_ARB_shader_objects +chromium nopack + +name GetObjectParameterfvARB +return void +param obj VBoxGLhandleARB +param pname GLenum +paramprop pname GL_OBJECT_TYPE_ARB GL_OBJECT_SUBTYPE_ARB GL_OBJECT_DELETE_STATUS_ARB GL_OBJECT_COMPILE_STATUS_ARB GL_OBJECT_LINK_STATUS_ARB GL_OBJECT_VALIDATE_STATUS_ARB GL_OBJECT_INFO_LOG_LENGTH_ARB GL_OBJECT_ATTACHED_OBJECTS_ARB GL_OBJECT_ACTIVE_UNIFORMS_ARB GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB GL_OBJECT_SHADER_SOURCE_LENGTH_ARB +param params GLfloat * +category GL_ARB_shader_objects +props get serverdependent +chromium extpack + +name GetObjectParameterivARB +return void +param obj VBoxGLhandleARB +param pname GLenum +paramprop pname GL_OBJECT_TYPE_ARB GL_OBJECT_SUBTYPE_ARB GL_OBJECT_DELETE_STATUS_ARB GL_OBJECT_COMPILE_STATUS_ARB GL_OBJECT_LINK_STATUS_ARB GL_OBJECT_VALIDATE_STATUS_ARB GL_OBJECT_INFO_LOG_LENGTH_ARB GL_OBJECT_ATTACHED_OBJECTS_ARB GL_OBJECT_ACTIVE_UNIFORMS_ARB GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB GL_OBJECT_SHADER_SOURCE_LENGTH_ARB +param params GLint * +category GL_ARB_shader_objects +props get serverdependent +chromium extpack + +name GetInfoLogARB +return void +param obj VBoxGLhandleARB +param maxLength GLsizei +param length GLsizei * +param infoLog GLcharARB * +category GL_ARB_shader_objects +props get serverdependent +chromium extpack + +name GetAttachedObjectsARB +return void +param containerObj VBoxGLhandleARB +param maxCount GLsizei +param count GLsizei * +param obj VBoxGLhandleARB * +category GL_ARB_shader_objects +props get +chromium extpack + +name GetUniformLocationARB +alias GetUniformLocation +return GLint +param programObj VBoxGLhandleARB +param name const GLcharARB * +category GL_ARB_shader_objects +props get +chromium nopack + +name GetActiveUniformARB +alias GetActiveUniform +return void +param programObj VBoxGLhandleARB +param index GLuint +param maxLength GLsizei +param length GLsizei * +param size GLint * +param type GLenum * +param name GLcharARB * +category GL_ARB_shader_objects +props get +chromium nopack + +name GetShaderSourceARB +alias GetShaderSource +return void +param obj VBoxGLhandleARB +param maxLength GLsizei +param length GLsizei * +param source GLcharARB * +category GL_ARB_shader_objects +props get +chromium nopack + +name GetUniformfvARB +alias GetUniformfv +return void +param programObj VBoxGLhandleARB +param location GLint +param params GLfloat * +category GL_ARB_shader_objects +props get +chromium nopack + +name GetUniformivARB +alias GetUniformiv +return void +param programObj VBoxGLhandleARB +param location GLint +param params GLint * +category GL_ARB_shader_objects +props get +chromium nopack + +# GL_ARB_vertex_shader + +name GetActiveAttribARB +alias GetActiveAttrib +return void +param programObj VBoxGLhandleARB +param index GLuint +param maxLength GLsizei +param length GLsizei * +param size GLint * +param type GLenum * +param name GLcharARB * +category GL_ARB_vertex_shader +props get +chromium nopack + +name GetAttribLocationARB +alias GetAttribLocation +return GLint +param programObj VBoxGLhandleARB +param name const GLcharARB * +category GL_ARB_vertex_shader +props get +chromium nopack + +name BindAttribLocationARB +alias BindAttribLocation +return void +param programObj VBoxGLhandleARB +param index GLuint +param name const GLcharARB * +category GL_ARB_vertex_shader +chromium nopack + +# GL_EXT_framebuffer_object + +name IsRenderbufferEXT +return GLboolean +param renderbuffer GLuint +category GL_EXT_framebuffer_object +props get +chromium extpack + +name BindRenderbufferEXT +return void +param target GLenum +paramprop target GL_RENDERBUFFER_EXT +param renderbuffer GLuint +category GL_EXT_framebuffer_object +chromium extpack + +name DeleteRenderbuffersEXT +return void +param n GLsizei +param renderbuffers const GLuint * +category GL_EXT_framebuffer_object +chromium extpack + +name GenRenderbuffersEXT +return void +param n GLsizei +param renderbuffers GLuint * +category GL_EXT_framebuffer_object +props get +chromium extpack + +name RenderbufferStorageEXT +return void +param target GLenum +paramprop target GL_RENDERBUFFER_EXT +param internalformat GLenum +paramprop internalformat GL_STENCIL_INDEX1_EXT GL_STENCIL_INDEX4_EXT GL_STENCIL_INDEX8_EXT GL_STENCIL_INDEX16_EXT GL_ALPHA GL_ALPHA4 GL_ALPHA8 GL_ALPHA12 GL_ALPHA16 GL_LUMINANCE GL_LUMINANCE4 GL_LUMINANCE8 GL_LUMINANCE12 GL_LUMINANCE16 GL_LUMINANCE_ALPHA GL_LUMINANCE4_ALPHA4 GL_LUMINANCE6_ALPHA2 GL_LUMINANCE8_ALPHA8 GL_LUMINANCE12_ALPHA4 GL_LUMINANCE12_ALPHA12 GL_LUMINANCE16_ALPHA16 GL_INTENSITY GL_INTENSITY4 GL_INTENSITY8 GL_INTENSITY12 GL_INTENSITY16 GL_R3_G3_B2 GL_RGB GL_RGB4 GL_RGB5 GL_RGB8 GL_RGB10 GL_RGB12 GL_RGB16 GL_RGBA GL_RGBA2 GL_RGBA4 GL_RGB5_A1 GL_RGBA8 GL_RGB10_A2 GL_RGBA12 GL_RGBA16 GL_COMPRESSED_ALPHA_ARB GL_COMPRESSED_LUMINANCE_ARB GL_COMPRESSED_LUMINANCE_ALPHA_ARB GL_COMPRESSED_INTENSITY_ARB GL_COMPRESSED_RGB_ARB GL_COMPRESSED_RGBA_ARB +param width GLsizei +param height GLsizei +category GL_EXT_framebuffer_object +chromium extpack + +name GetRenderbufferParameterivEXT +return void +param target GLenum +paramprop target GL_RENDERBUFFER_EXT +param pname GLenum +paramprop pname GL_RENDERBUFFER_WIDTH_EXT GL_RENDERBUFFER_HEIGHT_EXT GL_RENDERBUFFER_INTERNAL_FORMAT_EXT GL_RENDERBUFFER_RED_SIZE_EXT GL_RENDERBUFFER_GREEN_SIZE_EXT GL_RENDERBUFFER_BLUE_SIZE_EXT GL_RENDERBUFFER_ALPHA_SIZE_EXT GL_RENDERBUFFER_DEPTH_SIZE_EXT GL_RENDERBUFFER_STENCIL_SIZE_EXT +param params GLint * +category GL_EXT_framebuffer_object +props get +chromium extpack + +name IsFramebufferEXT +return GLboolean +param framebuffer GLuint +category GL_EXT_framebuffer_object +props get +chromium extpack + +name BindFramebufferEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param framebuffer GLuint +category GL_EXT_framebuffer_object +chromium extpack + +name BindFramebuffer +alias BindFramebufferEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param framebuffer GLuint +category GL_EXT_framebuffer_object +chromium extpack + +name DeleteFramebuffersEXT +return void +param n GLsizei +param framebuffers const GLuint * +category GL_EXT_framebuffer_object +chromium extpack + +name DeleteFramebuffers +alias DeleteFramebuffersEXT +return void +param n GLsizei +param framebuffers const GLuint * +category GL_EXT_framebuffer_object +chromium extpack + +name GenFramebuffersEXT +return void +param n GLsizei +param framebuffers GLuint * +category GL_EXT_framebuffer_object +props get +chromium extpack + +name GenFramebuffers +alias GenFramebuffersEXT +return void +param n GLsizei +param framebuffers GLuint * +category GL_EXT_framebuffer_object +props get +chromium extpack + +name CheckFramebufferStatusEXT +return GLenum +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +category GL_EXT_framebuffer_object +props get +chromium extpack + +name CheckFramebufferStatus +alias CheckFramebufferStatusEXT +return GLenum +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +category GL_EXT_framebuffer_object +props get +chromium extpack + +name FramebufferTexture1DEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param attachment GLenum +paramprop attachment GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT2_EXT GL_COLOR_ATTACHMENT3_EXT GL_COLOR_ATTACHMENT4_EXT GL_COLOR_ATTACHMENT5_EXT GL_COLOR_ATTACHMENT6_EXT GL_COLOR_ATTACHMENT7_EXT GL_COLOR_ATTACHMENT8_EXT GL_COLOR_ATTACHMENT9_EXT GL_COLOR_ATTACHMENT10_EXT GL_COLOR_ATTACHMENT11_EXT GL_COLOR_ATTACHMENT12_EXT GL_COLOR_ATTACHMENT13_EXT GL_COLOR_ATTACHMENT14_EXT GL_COLOR_ATTACHMENT15_EXT GL_DEPTH_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_EXT +param textarget GLenum +param texture GLuint +param level GLint +return void +category GL_EXT_framebuffer_object +chromium extpack + +name FramebufferTexture2DEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param attachment GLenum +paramprop attachment GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT2_EXT GL_COLOR_ATTACHMENT3_EXT GL_COLOR_ATTACHMENT4_EXT GL_COLOR_ATTACHMENT5_EXT GL_COLOR_ATTACHMENT6_EXT GL_COLOR_ATTACHMENT7_EXT GL_COLOR_ATTACHMENT8_EXT GL_COLOR_ATTACHMENT9_EXT GL_COLOR_ATTACHMENT10_EXT GL_COLOR_ATTACHMENT11_EXT GL_COLOR_ATTACHMENT12_EXT GL_COLOR_ATTACHMENT13_EXT GL_COLOR_ATTACHMENT14_EXT GL_COLOR_ATTACHMENT15_EXT GL_DEPTH_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_EXT +param textarget GLenum +param texture GLuint +param level GLint +return void +category GL_EXT_framebuffer_object +chromium extpack + +name FramebufferTexture2D +alias FramebufferTexture2DEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param attachment GLenum +paramprop attachment GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT2_EXT GL_COLOR_ATTACHMENT3_EXT GL_COLOR_ATTACHMENT4_EXT GL_COLOR_ATTACHMENT5_EXT GL_COLOR_ATTACHMENT6_EXT GL_COLOR_ATTACHMENT7_EXT GL_COLOR_ATTACHMENT8_EXT GL_COLOR_ATTACHMENT9_EXT GL_COLOR_ATTACHMENT10_EXT GL_COLOR_ATTACHMENT11_EXT GL_COLOR_ATTACHMENT12_EXT GL_COLOR_ATTACHMENT13_EXT GL_COLOR_ATTACHMENT14_EXT GL_COLOR_ATTACHMENT15_EXT GL_DEPTH_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_EXT +param textarget GLenum +param texture GLuint +param level GLint +return void +category GL_EXT_framebuffer_object +chromium extpack + +name FramebufferTexture3DEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param attachment GLenum +paramprop attachment GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT2_EXT GL_COLOR_ATTACHMENT3_EXT GL_COLOR_ATTACHMENT4_EXT GL_COLOR_ATTACHMENT5_EXT GL_COLOR_ATTACHMENT6_EXT GL_COLOR_ATTACHMENT7_EXT GL_COLOR_ATTACHMENT8_EXT GL_COLOR_ATTACHMENT9_EXT GL_COLOR_ATTACHMENT10_EXT GL_COLOR_ATTACHMENT11_EXT GL_COLOR_ATTACHMENT12_EXT GL_COLOR_ATTACHMENT13_EXT GL_COLOR_ATTACHMENT14_EXT GL_COLOR_ATTACHMENT15_EXT GL_DEPTH_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_EXT +param textarget GLenum +param texture GLuint +param level GLint +param zoffset GLint +return void +category GL_EXT_framebuffer_object +chromium extpack + +name FramebufferRenderbufferEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param attachment GLenum +paramprop attachment GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT2_EXT GL_COLOR_ATTACHMENT3_EXT GL_COLOR_ATTACHMENT4_EXT GL_COLOR_ATTACHMENT5_EXT GL_COLOR_ATTACHMENT6_EXT GL_COLOR_ATTACHMENT7_EXT GL_COLOR_ATTACHMENT8_EXT GL_COLOR_ATTACHMENT9_EXT GL_COLOR_ATTACHMENT10_EXT GL_COLOR_ATTACHMENT11_EXT GL_COLOR_ATTACHMENT12_EXT GL_COLOR_ATTACHMENT13_EXT GL_COLOR_ATTACHMENT14_EXT GL_COLOR_ATTACHMENT15_EXT GL_DEPTH_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_EXT +param renderbuffertarget GLenum +param renderbuffer GLuint +category GL_EXT_framebuffer_object +chromium extpack + +name GetFramebufferAttachmentParameterivEXT +return void +param target GLenum +paramprop target GL_FRAMEBUFFER_EXT GL_READ_FRAMEBUFFER_EXT GL_DRAW_FRAMEBUFFER_EXT +param attachment GLenum +paramprop attachment GL_COLOR_ATTACHMENT0_EXT GL_COLOR_ATTACHMENT1_EXT GL_COLOR_ATTACHMENT2_EXT GL_COLOR_ATTACHMENT3_EXT GL_COLOR_ATTACHMENT4_EXT GL_COLOR_ATTACHMENT5_EXT GL_COLOR_ATTACHMENT6_EXT GL_COLOR_ATTACHMENT7_EXT GL_COLOR_ATTACHMENT8_EXT GL_COLOR_ATTACHMENT9_EXT GL_COLOR_ATTACHMENT10_EXT GL_COLOR_ATTACHMENT11_EXT GL_COLOR_ATTACHMENT12_EXT GL_COLOR_ATTACHMENT13_EXT GL_COLOR_ATTACHMENT14_EXT GL_COLOR_ATTACHMENT15_EXT GL_DEPTH_ATTACHMENT_EXT GL_STENCIL_ATTACHMENT_EXT +param pname GLenum +paramprop pname GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT +param params GLint * +category GL_EXT_framebuffer_object +props get +chromium extpack + +name GenerateMipmapEXT +return void +param target GLenum +category GL_EXT_framebuffer_object +chromium extpack + +# GL_EXT_compiled_vertex_array + +name LockArraysEXT +return void +param first GLint +param count GLint +category GL_EXT_compiled_vertex_array +chromium extpack + +name UnlockArraysEXT +return void +category GL_EXT_compiled_vertex_array +chromium extpack + +# custom +name GetUniformsLocations +return void +param program GLuint +param maxcbData GLsizei +param cbData GLsizei * +param pData GLvoid * +category Chromium +props get +chromium extpack + +# OpenGL 2.1 +name UniformMatrix2x3fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.1 +chromium extpack + +name UniformMatrix3x2fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.1 +chromium extpack + +name UniformMatrix2x4fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.1 +chromium extpack + +name UniformMatrix4x2fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.1 +chromium extpack + +name UniformMatrix4x3fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.1 +chromium extpack + +name UniformMatrix3x4fv +return void +param location GLint +param count GLsizei +param transpose GLboolean +param value const GLfloat * +category 2.1 +chromium extpack + +# GL_EXT_framebuffer_blit +name BlitFramebufferEXT +return void +param srcX0 GLint +param srcY0 GLint +param srcX1 GLint +param srcY1 GLint +param dstX0 GLint +param dstY0 GLint +param dstX1 GLint +param dstY1 GLint +param mask GLbitfield +param filter GLenum +paramprop filter GL_LINEAR GL_NEAREST +category GL_EXT_framebuffer_blit +chromium extpack + +# GL_EXT_framebuffer_blit +name BlitFramebuffer +alias BlitFramebufferEXT +return void +param srcX0 GLint +param srcY0 GLint +param srcX1 GLint +param srcY1 GLint +param dstX0 GLint +param dstY0 GLint +param dstX1 GLint +param dstY1 GLint +param mask GLbitfield +param filter GLenum +paramprop filter GL_LINEAR GL_NEAREST +category GL_EXT_framebuffer_blit +chromium extpack + +# GL_EXT_blend_equation_separate +name BlendEquationSeparateEXT +alias BlendEquationSeparate +return void +param modeRGB GLenum +paramprop modeRGB GL_FUNC_ADD GL_FUNC_SUBTRACT GL_FUNC_REVERSE_SUBTRACT GL_MIN GL_MAX GL_LOGIC_OP +param modeAlpha GLenum +paramprop modeAlpha GL_FUNC_ADD GL_FUNC_SUBTRACT GL_FUNC_REVERSE_SUBTRACT GL_MIN GL_MAX GL_LOGIC_OP +category GL_EXT_blend_equation_separate +chromium nopack + +# GL_GREMEDY_string_marker +name StringMarkerGREMEDY +return void +param len GLsizei +param string const GLvoid* +category GL_GREMEDY_string_marker +chromium nopack + +# end of file sentinel + +name dummy +alias dummyEXT diff --git a/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py b/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py new file mode 100755 index 00000000..12d11222 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/glapi_parser/apiutil.py @@ -0,0 +1,773 @@ +#!/usr/common/bin/python + +# apiutil.py +# +# This file defines a bunch of utility functions for OpenGL API code +# generation. + +from __future__ import print_function +import sys, string, re + + +#====================================================================== + +def CopyrightC( ): + print("""/* Copyright (c) 2001, Stanford University + All rights reserved. + + See the file LICENSE.txt for information on redistributing this software. */ + """) + +def CopyrightDef( ): + print("""; Copyright (c) 2001, Stanford University + ; All rights reserved. + ; + ; See the file LICENSE.txt for information on redistributing this software. + """) + + + +#====================================================================== + +class APIFunction: + """Class to represent a GL API function (name, return type, + parameters, etc).""" + def __init__(self): + self.name = '' + self.returnType = '' + self.category = '' + self.offset = -1 + self.alias = '' + self.vectoralias = '' + self.params = [] + self.paramlist = [] + self.paramvec = [] + self.paramaction = [] + self.paramprop = [] + self.paramset = [] + self.props = [] + self.chromium = [] + self.chrelopcode = -1 + + + +def ProcessSpecFile(filename, userFunc): + """Open the named API spec file and call userFunc(record) for each record + processed.""" + specFile = open(filename, "r") + if not specFile: + print("Error: couldn't open %s file!" % filename) + sys.exit() + + record = APIFunction() + + for line in specFile.readlines(): + + # split line into tokens + tokens = line.split() + + if len(tokens) > 0 and line[0] != '#': + + if tokens[0] == 'name': + if record.name != '': + # process the function now + userFunc(record) + # reset the record + record = APIFunction() + + record.name = tokens[1] + + elif tokens[0] == 'return': + record.returnType = ' '.join(tokens[1:]) + + elif tokens[0] == 'param': + name = tokens[1] + type = ' '.join(tokens[2:]) + vecSize = 0 + record.params.append((name, type, vecSize)) + + elif tokens[0] == 'paramprop': + name = tokens[1] + str = tokens[2:] + enums = [] + for i in range(len(str)): + enums.append(str[i]) + record.paramprop.append((name, enums)) + + elif tokens[0] == 'paramlist': + name = tokens[1] + str = tokens[2:] + list = [] + for i in range(len(str)): + list.append(str[i]) + record.paramlist.append((name,list)) + + elif tokens[0] == 'paramvec': + name = tokens[1] + str = tokens[2:] + vec = [] + for i in range(len(str)): + vec.append(str[i]) + record.paramvec.append((name,vec)) + + elif tokens[0] == 'paramset': + line = tokens[1:] + result = [] + for i in range(len(line)): + tset = line[i] + if tset == '[': + nlist = [] + elif tset == ']': + result.append(nlist) + nlist = [] + else: + nlist.append(tset) + if result != []: + record.paramset.append(result) + + elif tokens[0] == 'paramaction': + name = tokens[1] + str = tokens[2:] + list = [] + for i in range(len(str)): + list.append(str[i]) + record.paramaction.append((name,list)) + + elif tokens[0] == 'category': + record.category = tokens[1] + + elif tokens[0] == 'offset': + if tokens[1] == '?': + record.offset = -2 + else: + record.offset = int(tokens[1]) + + elif tokens[0] == 'alias': + record.alias = tokens[1] + + elif tokens[0] == 'vectoralias': + record.vectoralias = tokens[1] + + elif tokens[0] == 'props': + record.props = tokens[1:] + + elif tokens[0] == 'chromium': + record.chromium = tokens[1:] + + elif tokens[0] == 'vector': + vecName = tokens[1] + vecSize = int(tokens[2]) + for i in range(len(record.params)): + (name, type, oldSize) = record.params[i] + if name == vecName: + record.params[i] = (name, type, vecSize) + break + + elif tokens[0] == 'chrelopcode': + record.chrelopcode = int(tokens[1]) + + else: + print('Invalid token %s after function %s' % (tokens[0], record.name)) + #endif + #endif + #endfor + specFile.close() +#enddef + + + + + +# Dictionary [name] of APIFunction: +__FunctionDict = {} + +# Dictionary [name] of name +__VectorVersion = {} + +# Reverse mapping of function name aliases +__ReverseAliases = {} + + +def AddFunction(record): + assert record.name not in __FunctionDict + #if not "omit" in record.chromium: + __FunctionDict[record.name] = record + + + +def GetFunctionDict(specFile = ""): + if not specFile: + specFile = sys.argv[1]+"/APIspec.txt" + if len(__FunctionDict) == 0: + ProcessSpecFile(specFile, AddFunction) + # Look for vector aliased functions + for func in __FunctionDict.keys(): + va = __FunctionDict[func].vectoralias + if va != '': + __VectorVersion[va] = func + #endif + + # and look for regular aliases (for glloader) + a = __FunctionDict[func].alias + if a: + if a in __ReverseAliases: + __ReverseAliases[a].append(func) + else: + __ReverseAliases[a] = [func] + #endif + return __FunctionDict + + +def GetAllFunctions(specFile = ""): + """Return sorted list of all functions known to Chromium.""" + d = GetFunctionDict(specFile) + funcs = [] + for func in d.keys(): + rec = d[func] + if not "omit" in rec.chromium: + funcs.append(func) + funcs.sort() + return funcs + +def GetAllFunctionsAndOmittedAliases(specFile = ""): + """Return sorted list of all functions known to Chromium.""" + d = GetFunctionDict(specFile) + funcs = [] + for func in d.keys(): + rec = d[func] + if (not "omit" in rec.chromium or + rec.alias != ''): + funcs.append(func) + funcs.sort() + return funcs + +def GetDispatchedFunctions(specFile = ""): + """Return sorted list of all functions handled by SPU dispatch table.""" + d = GetFunctionDict(specFile) + funcs = [] + for func in d.keys(): + rec = d[func] + if (not "omit" in rec.chromium and + not "stub" in rec.chromium and + rec.alias == ''): + funcs.append(func) + funcs.sort() + return funcs + +#====================================================================== + +def ReturnType(funcName): + """Return the C return type of named function. + Examples: "void" or "const GLubyte *". """ + d = GetFunctionDict() + return d[funcName].returnType + + +def Parameters(funcName): + """Return list of tuples (name, type, vecSize) of function parameters. + Example: if funcName=="ClipPlane" return + [ ("plane", "GLenum", 0), ("equation", "const GLdouble *", 4) ] """ + d = GetFunctionDict() + return d[funcName].params + +def ParamAction(funcName): + """Return list of names of actions for testing. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramaction + +def ParamList(funcName): + """Return list of tuples (name, list of values) of function parameters. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramlist + +def ParamVec(funcName): + """Return list of tuples (name, vector of values) of function parameters. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramvec + +def ParamSet(funcName): + """Return list of tuples (name, list of values) of function parameters. + For PackerTest only.""" + d = GetFunctionDict() + return d[funcName].paramset + + +def Properties(funcName): + """Return list of properties of the named GL function.""" + d = GetFunctionDict() + return d[funcName].props + +def AllWithProperty(property): + """Return list of functions that have the named property.""" + funcs = [] + for funcName in GetDispatchedFunctions(): + if property in Properties(funcName): + funcs.append(funcName) + return funcs + +def Category(funcName): + """Return the category of the named GL function.""" + d = GetFunctionDict() + return d[funcName].category + +def ChromiumProps(funcName): + """Return list of Chromium-specific properties of the named GL function.""" + d = GetFunctionDict() + return d[funcName].chromium + +def ChromiumRelOpCode(funcName): + """Return list of Chromium-specific properties of the named GL function.""" + d = GetFunctionDict() + return d[funcName].chrelopcode + + +def ParamProps(funcName): + """Return list of Parameter-specific properties of the named GL function.""" + d = GetFunctionDict() + return d[funcName].paramprop + +def Alias(funcName): + """Return the function that the named function is an alias of. + Ex: Alias('DrawArraysEXT') = 'DrawArrays'. + """ + d = GetFunctionDict() + return d[funcName].alias + + +def ReverseAliases(funcName): + """Return a list of aliases.""" + d = GetFunctionDict() + if funcName in __ReverseAliases: + return sorted(__ReverseAliases[funcName]) + else: + return [] + + +def ReverseAliasesMaxCount(): + """Returns the maximum number of aliases possible for a function.""" + d = GetFunctionDict() + return max([len(a) for a in __ReverseAliases.values()]) + + +def NonVectorFunction(funcName): + """Return the non-vector version of the given function, or ''. + For example: NonVectorFunction("Color3fv") = "Color3f".""" + d = GetFunctionDict() + return d[funcName].vectoralias + + +def VectorFunction(funcName): + """Return the vector version of the given non-vector-valued function, + or ''. + For example: VectorVersion("Color3f") = "Color3fv".""" + d = GetFunctionDict() + if funcName in __VectorVersion.keys(): + return __VectorVersion[funcName] + else: + return '' + + +def GetCategoryWrapper(func_name): + """Return a C preprocessor token to test in order to wrap code. + This handles extensions. + Example: GetTestWrapper("glActiveTextureARB") = "CR_multitexture" + Example: GetTestWrapper("glBegin") = "" + """ + cat = Category(func_name) + if (cat == "1.0" or + cat == "1.1" or + cat == "1.2" or + cat == "Chromium" or + cat == "GL_chromium" or + cat == "VBox"): + return '' + elif (cat == '1.3' or + cat == '1.4' or + cat == '1.5' or + cat == '2.0' or + cat == '2.1'): + # i.e. OpenGL 1.3 or 1.4 or 1.5 + return "OPENGL_VERSION_" + cat.replace(".", "_") + else: + assert cat != '' + return cat.replace("GL_", "") + + +def CanCompile(funcName): + """Return 1 if the function can be compiled into display lists, else 0.""" + props = Properties(funcName) + if ("nolist" in props or + "get" in props or + "setclient" in props): + return 0 + else: + return 1 + +def HasChromiumProperty(funcName, propertyList): + """Return 1 if the function or any alias has any property in the + propertyList""" + for funcAlias in [funcName, NonVectorFunction(funcName), VectorFunction(funcName)]: + if funcAlias: + props = ChromiumProps(funcAlias) + for p in propertyList: + if p in props: + return 1 + return 0 + +def CanPack(funcName): + """Return 1 if the function can be packed, else 0.""" + return HasChromiumProperty(funcName, ['pack', 'extpack', 'expandpack']) + +def HasPackOpcode(funcName): + """Return 1 if the function has a true pack opcode""" + return HasChromiumProperty(funcName, ['pack', 'extpack']) + +def SetsState(funcName): + """Return 1 if the function sets server-side state, else 0.""" + props = Properties(funcName) + + # Exceptions. The first set of these functions *do* have + # server-side state-changing effects, but will be missed + # by the general query, because they either render (e.g. + # Bitmap) or do not compile into display lists (e.g. all the others). + # + # The second set do *not* have server-side state-changing + # effects, despite the fact that they do not render + # and can be compiled. They are control functions + # that are not trackable via state. + if funcName in ['Bitmap', 'DeleteTextures', 'FeedbackBuffer', + 'RenderMode', 'BindBufferARB', 'DeleteFencesNV']: + return 1 + elif funcName in ['ExecuteProgramNV']: + return 0 + + # All compilable functions that do not render and that do + # not set or use client-side state (e.g. DrawArrays, et al.), set + # server-side state. + if CanCompile(funcName) and "render" not in props and "useclient" not in props and "setclient" not in props: + return 1 + + # All others don't set server-side state. + return 0 + +def SetsClientState(funcName): + """Return 1 if the function sets client-side state, else 0.""" + props = Properties(funcName) + if "setclient" in props: + return 1 + return 0 + +def SetsTrackedState(funcName): + """Return 1 if the function sets state that is tracked by + the state tracker, else 0.""" + # These functions set state, but aren't tracked by the state + # tracker for various reasons: + # - because the state tracker doesn't manage display lists + # (e.g. CallList and CallLists) + # - because the client doesn't have information about what + # the server supports, so the function has to go to the + # server (e.g. CompressedTexImage calls) + # - because they require a round-trip to the server (e.g. + # the CopyTexImage calls, SetFenceNV, TrackMatrixNV) + if funcName in [ + 'CopyTexImage1D', 'CopyTexImage2D', + 'CopyTexSubImage1D', 'CopyTexSubImage2D', 'CopyTexSubImage3D', + 'CallList', 'CallLists', + 'CompressedTexImage1DARB', 'CompressedTexSubImage1DARB', + 'CompressedTexImage2DARB', 'CompressedTexSubImage2DARB', + 'CompressedTexImage3DARB', 'CompressedTexSubImage3DARB', + 'SetFenceNV' + ]: + return 0 + + # Anything else that affects client-side state is trackable. + if SetsClientState(funcName): + return 1 + + # Anything else that doesn't set state at all is certainly + # not trackable. + if not SetsState(funcName): + return 0 + + # Per-vertex state isn't tracked the way other state is + # tracked, so it is specifically excluded. + if "pervertex" in Properties(funcName): + return 0 + + # Everything else is fine + return 1 + +def UsesClientState(funcName): + """Return 1 if the function uses client-side state, else 0.""" + props = Properties(funcName) + if "pixelstore" in props or "useclient" in props: + return 1 + return 0 + +def IsQuery(funcName): + """Return 1 if the function returns information to the user, else 0.""" + props = Properties(funcName) + if "get" in props: + return 1 + return 0 + +def FuncGetsState(funcName): + """Return 1 if the function gets GL state, else 0.""" + d = GetFunctionDict() + props = Properties(funcName) + if "get" in props: + return 1 + else: + return 0 + +def IsPointer(dataType): + """Determine if the datatype is a pointer. Return 1 or 0.""" + if dataType.find("*") == -1: + return 0 + else: + return 1 + + +def PointerType(pointerType): + """Return the type of a pointer. + Ex: PointerType('const GLubyte *') = 'GLubyte' + """ + t = pointerType.split(' ') + if t[0] == "const": + t[0] = t[1] + return t[0] + + + + +def OpcodeName(funcName): + """Return the C token for the opcode for the given function.""" + return "CR_" + funcName.upper() + "_OPCODE" + + +def ExtendedOpcodeName(funcName): + """Return the C token for the extended opcode for the given function.""" + return "CR_" + funcName.upper() + "_EXTEND_OPCODE" + + + + +#====================================================================== + +def MakeCallString(params): + """Given a list of (name, type, vectorSize) parameters, make a C-style + formal parameter string. + Ex return: 'index, x, y, z'. + """ + result = '' + i = 1 + n = len(params) + for (name, type, vecSize) in params: + result += name + if i < n: + result = result + ', ' + i += 1 + #endfor + return result +#enddef + + +def MakeDeclarationString(params): + """Given a list of (name, type, vectorSize) parameters, make a C-style + parameter declaration string. + Ex return: 'GLuint index, GLfloat x, GLfloat y, GLfloat z'. + """ + n = len(params) + if n == 0: + return 'void' + else: + result = '' + i = 1 + for (name, type, vecSize) in params: + result = result + type + ' ' + name + if i < n: + result = result + ', ' + i += 1 + #endfor + return result + #endif +#enddef + +def MakeDeclarationStringWithContext(ctx_macro_prefix, params): + """Same as MakeDeclarationString, but adds a context macro + """ + + n = len(params) + if n == 0: + return ctx_macro_prefix + '_ARGSINGLEDECL' + else: + result = MakeDeclarationString(params) + return ctx_macro_prefix + '_ARGDECL ' + result + #endif +#enddef + + +def MakePrototypeString(params): + """Given a list of (name, type, vectorSize) parameters, make a C-style + parameter prototype string (types only). + Ex return: 'GLuint, GLfloat, GLfloat, GLfloat'. + """ + n = len(params) + if n == 0: + return 'void' + else: + result = '' + i = 1 + for (name, type, vecSize) in params: + result = result + type + # see if we need a comma separator + if i < n: + result = result + ', ' + i += 1 + #endfor + return result + #endif +#enddef + + +#====================================================================== + +__lengths = { + 'GLbyte': 1, + 'GLubyte': 1, + 'GLshort': 2, + 'GLushort': 2, + 'GLint': 4, + 'GLuint': 4, + 'GLfloat': 4, + 'GLclampf': 4, + 'GLdouble': 8, + 'GLclampd': 8, + 'GLenum': 4, + 'GLboolean': 1, + 'GLsizei': 4, + 'GLbitfield': 4, + 'void': 0, # XXX why? + 'int': 4, + 'GLintptrARB': 4, # XXX or 8 bytes? + 'GLsizeiptrARB': 4, # XXX or 8 bytes? + 'VBoxGLhandleARB': 4, + 'GLcharARB': 1, + 'uintptr_t': 4 +} + +def sizeof(type): + """Return size of C datatype, in bytes.""" + if not type in __lengths.keys(): + print >>sys.stderr, "%s not in lengths!" % type + return __lengths[type] + + +#====================================================================== +align_types = 1 + +def FixAlignment( pos, alignment ): + # if we want double-alignment take word-alignment instead, + # yes, this is super-lame, but we know what we are doing + if alignment > 4: + alignment = 4 + if align_types and alignment and ( pos % alignment ): + pos += alignment - ( pos % alignment ) + return pos + +def WordAlign( pos ): + return FixAlignment( pos, 4 ) + +def PointerSize(): + return 8 # Leave room for a 64 bit pointer + +def PacketLength( params ): + len = 0 + for (name, type, vecSize) in params: + if IsPointer(type): + size = PointerSize() + else: + assert type.find("const") == -1 + size = sizeof(type) + len = FixAlignment( len, size ) + size + len = WordAlign( len ) + return len + +#====================================================================== + +__specials = {} + +def LoadSpecials( filename ): + table = {} + try: + f = open( filename, "r" ) + except: +# try: + f = open( sys.argv[2]+"/"+filename, "r") +# except: +# __specials[filename] = {} +# print "%s not present" % filename +# return {} + + for line in f.readlines(): + line = line.strip() + if line == "" or line[0] == '#': + continue + table[line] = 1 + + __specials[filename] = table + return table + + +def FindSpecial( table_file, glName ): + table = {} + filename = table_file + "_special" + try: + table = __specials[filename] + except KeyError: + table = LoadSpecials( filename ) + + try: + if (table[glName] == 1): + return 1 + else: + return 0 #should never happen + except KeyError: + return 0 + + +def AllSpecials( table_file ): + table = {} + filename = table_file + "_special" + try: + table = __specials[filename] + except KeyError: + table = LoadSpecials( filename ) + + return sorted(table.keys()) + + +def NumSpecials( table_file ): + filename = table_file + "_special" + table = {} + try: + table = __specials[filename] + except KeyError: + table = LoadSpecials(filename) + return len(table.keys()) + +def PrintRecord(record): + argList = MakeDeclarationString(record.params) + if record.category == "Chromium": + prefix = "cr" + else: + prefix = "gl" + print('%s %s%s(%s);' % (record.returnType, prefix, record.name, argList )) + if len(record.props) > 0: + print(' /* %s */' % string.join(record.props, ' ')) + +#ProcessSpecFile("APIspec.txt", PrintRecord) + diff --git a/src/VBox/GuestHost/OpenGL/include/GL/glext.h b/src/VBox/GuestHost/OpenGL/include/GL/glext.h new file mode 100644 index 00000000..9c50739d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/GL/glext.h @@ -0,0 +1,7669 @@ +#ifndef __glext_h_ +#define __glext_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright (c) 2007 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are 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 Materials. +** +** THE MATERIALS ARE 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 +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) +#define WIN32_LEAN_AND_MEAN 1 +# ifdef VBOX +# include +# else +#include +# endif +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +#ifndef GLAPI +#define GLAPI extern +#endif + +/*************************************************************/ + +/* Header file version number, required by OpenGL ABI for Linux */ +/* glext.h last updated 2008/08/10 */ +/* Current version at http://www.opengl.org/registry/ */ +#define GL_GLEXT_VERSION 41 + +#ifndef GL_VERSION_1_2 +#define GL_UNSIGNED_BYTE_3_3_2 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2 0x8036 +#define GL_RESCALE_NORMAL 0x803A +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_PACK_SKIP_IMAGES 0x806B +#define GL_PACK_IMAGE_HEIGHT 0x806C +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_PROXY_TEXTURE_3D 0x8070 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366 +#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_BGR 0x80E0 +#define GL_BGRA 0x80E1 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8 +#define GL_SINGLE_COLOR 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR 0x81FA +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_ARB_imaging +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_FUNC_ADD 0x8006 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_BLEND_EQUATION 0x8009 +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_CONVOLUTION_1D 0x8010 +#define GL_CONVOLUTION_2D 0x8011 +#define GL_SEPARABLE_2D 0x8012 +#define GL_CONVOLUTION_BORDER_MODE 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS 0x8015 +#define GL_REDUCE 0x8016 +#define GL_CONVOLUTION_FORMAT 0x8017 +#define GL_CONVOLUTION_WIDTH 0x8018 +#define GL_CONVOLUTION_HEIGHT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023 +#define GL_HISTOGRAM 0x8024 +#define GL_PROXY_HISTOGRAM 0x8025 +#define GL_HISTOGRAM_WIDTH 0x8026 +#define GL_HISTOGRAM_FORMAT 0x8027 +#define GL_HISTOGRAM_RED_SIZE 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C +#define GL_HISTOGRAM_SINK 0x802D +#define GL_MINMAX 0x802E +#define GL_MINMAX_FORMAT 0x802F +#define GL_MINMAX_SINK 0x8030 +#define GL_TABLE_TOO_LARGE 0x8031 +#define GL_COLOR_MATRIX 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB +#define GL_COLOR_TABLE 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2 +#define GL_PROXY_COLOR_TABLE 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5 +#define GL_COLOR_TABLE_SCALE 0x80D6 +#define GL_COLOR_TABLE_BIAS 0x80D7 +#define GL_COLOR_TABLE_FORMAT 0x80D8 +#define GL_COLOR_TABLE_WIDTH 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF +#define GL_CONSTANT_BORDER 0x8151 +#define GL_REPLICATE_BORDER 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR 0x8154 +#endif + +#ifndef GL_VERSION_1_3 +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 +#define GL_MAX_TEXTURE_UNITS 0x84E2 +#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6 +#define GL_MULTISAMPLE 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE 0x809F +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_MULTISAMPLE_BIT 0x20000000 +#define GL_NORMAL_MAP 0x8511 +#define GL_REFLECTION_MAP 0x8512 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_COMPRESSED_ALPHA 0x84E9 +#define GL_COMPRESSED_LUMINANCE 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB +#define GL_COMPRESSED_INTENSITY 0x84EC +#define GL_COMPRESSED_RGB 0x84ED +#define GL_COMPRESSED_RGBA 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_COMBINE 0x8570 +#define GL_COMBINE_RGB 0x8571 +#define GL_COMBINE_ALPHA 0x8572 +#define GL_SOURCE0_RGB 0x8580 +#define GL_SOURCE1_RGB 0x8581 +#define GL_SOURCE2_RGB 0x8582 +#define GL_SOURCE0_ALPHA 0x8588 +#define GL_SOURCE1_ALPHA 0x8589 +#define GL_SOURCE2_ALPHA 0x858A +#define GL_OPERAND0_RGB 0x8590 +#define GL_OPERAND1_RGB 0x8591 +#define GL_OPERAND2_RGB 0x8592 +#define GL_OPERAND0_ALPHA 0x8598 +#define GL_OPERAND1_ALPHA 0x8599 +#define GL_OPERAND2_ALPHA 0x859A +#define GL_RGB_SCALE 0x8573 +#define GL_ADD_SIGNED 0x8574 +#define GL_INTERPOLATE 0x8575 +#define GL_SUBTRACT 0x84E7 +#define GL_CONSTANT 0x8576 +#define GL_PRIMARY_COLOR 0x8577 +#define GL_PREVIOUS 0x8578 +#define GL_DOT3_RGB 0x86AE +#define GL_DOT3_RGBA 0x86AF +#endif + +#ifndef GL_VERSION_1_4 +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_POINT_SIZE_MIN 0x8126 +#define GL_POINT_SIZE_MAX 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION 0x8129 +#define GL_GENERATE_MIPMAP 0x8191 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_DEPTH_COMPONENT32 0x81A7 +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FOG_COORDINATE_SOURCE 0x8450 +#define GL_FOG_COORDINATE 0x8451 +#define GL_FRAGMENT_DEPTH 0x8452 +#define GL_CURRENT_FOG_COORDINATE 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456 +#define GL_FOG_COORDINATE_ARRAY 0x8457 +#define GL_COLOR_SUM 0x8458 +#define GL_CURRENT_SECONDARY_COLOR 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D +#define GL_SECONDARY_COLOR_ARRAY 0x845E +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_FILTER_CONTROL 0x8500 +#define GL_TEXTURE_LOD_BIAS 0x8501 +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_DEPTH_TEXTURE_MODE 0x884B +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_COMPARE_R_TO_TEXTURE 0x884E +#endif + +#ifndef GL_VERSION_1_5 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_QUERY_COUNTER_BITS 0x8864 +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_BUFFER_ACCESS 0x88BB +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_DRAW 0x88E0 +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_DRAW 0x88E4 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_SAMPLES_PASSED 0x8914 +#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE +#define GL_FOG_COORD GL_FOG_COORDINATE +#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE +#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE +#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE +#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER +#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY +#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING +#define GL_SRC0_RGB GL_SOURCE0_RGB +#define GL_SRC1_RGB GL_SOURCE1_RGB +#define GL_SRC2_RGB GL_SOURCE2_RGB +#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA +#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA +#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA +#endif + +#ifndef GL_VERSION_2_0 +#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_POINT_SPRITE 0x8861 +#define GL_COORD_REPLACE 0x8862 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_MAX_TEXTURE_COORDS 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_MAX_VARYING_FLOATS 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_SHADER_TYPE 0x8B4F +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_1D 0x8B5D +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_SAMPLER_1D_SHADOW 0x8B61 +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_DELETE_STATUS 0x8B80 +#define GL_COMPILE_STATUS 0x8B81 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0 +#define GL_LOWER_LEFT 0x8CA1 +#define GL_UPPER_LEFT 0x8CA2 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#endif + +#ifndef GL_VERSION_2_1 +#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB_ALPHA 0x8C42 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_SLUMINANCE_ALPHA 0x8C44 +#define GL_SLUMINANCE8_ALPHA8 0x8C45 +#define GL_SLUMINANCE 0x8C46 +#define GL_SLUMINANCE8 0x8C47 +#define GL_COMPRESSED_SRGB 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA 0x8C49 +#define GL_COMPRESSED_SLUMINANCE 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B +#endif + +#ifndef GL_VERSION_3_0 +#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB +#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0 +#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1 +#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2 +#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3 +#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4 +#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5 +#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_CONTEXT_FLAGS 0x821E +#define GL_DEPTH_BUFFER 0x8223 +#define GL_STENCIL_BUFFER 0x8224 +#define GL_COMPRESSED_RED 0x8225 +#define GL_COMPRESSED_RG 0x8226 +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_CLAMP_VERTEX_COLOR 0x891A +#define GL_CLAMP_FRAGMENT_COLOR 0x891B +#define GL_CLAMP_READ_COLOR 0x891C +#define GL_FIXED_ONLY 0x891D +#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_TEXTURE_1D_ARRAY 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_GREEN_INTEGER 0x8D95 +#define GL_BLUE_INTEGER 0x8D96 +#define GL_ALPHA_INTEGER 0x8D97 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_BGR_INTEGER 0x8D9A +#define GL_BGRA_INTEGER 0x8D9B +#define GL_SAMPLER_1D_ARRAY 0x8DC0 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_1D 0x8DC9 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_QUERY_WAIT 0x8E13 +#define GL_QUERY_NO_WAIT 0x8E14 +#define GL_QUERY_BY_REGION_WAIT 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16 +#endif + +#ifndef GL_ARB_multitexture +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 +#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 +#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 +#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 +#endif + +#ifndef GL_ARB_multisample +#define GL_MULTISAMPLE_ARB 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#endif + +#ifndef GL_ARB_texture_env_add +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C +#endif + +#ifndef GL_ARB_texture_compression +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_CLAMP_TO_BORDER_ARB 0x812D +#endif + +#ifndef GL_ARB_point_parameters +#define GL_POINT_SIZE_MIN_ARB 0x8126 +#define GL_POINT_SIZE_MAX_ARB 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128 +#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129 +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_MAX_VERTEX_UNITS_ARB 0x86A4 +#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5 +#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6 +#define GL_VERTEX_BLEND_ARB 0x86A7 +#define GL_CURRENT_WEIGHT_ARB 0x86A8 +#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9 +#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA +#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB +#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC +#define GL_WEIGHT_ARRAY_ARB 0x86AD +#define GL_MODELVIEW0_ARB 0x1700 +#define GL_MODELVIEW1_ARB 0x850A +#define GL_MODELVIEW2_ARB 0x8722 +#define GL_MODELVIEW3_ARB 0x8723 +#define GL_MODELVIEW4_ARB 0x8724 +#define GL_MODELVIEW5_ARB 0x8725 +#define GL_MODELVIEW6_ARB 0x8726 +#define GL_MODELVIEW7_ARB 0x8727 +#define GL_MODELVIEW8_ARB 0x8728 +#define GL_MODELVIEW9_ARB 0x8729 +#define GL_MODELVIEW10_ARB 0x872A +#define GL_MODELVIEW11_ARB 0x872B +#define GL_MODELVIEW12_ARB 0x872C +#define GL_MODELVIEW13_ARB 0x872D +#define GL_MODELVIEW14_ARB 0x872E +#define GL_MODELVIEW15_ARB 0x872F +#define GL_MODELVIEW16_ARB 0x8730 +#define GL_MODELVIEW17_ARB 0x8731 +#define GL_MODELVIEW18_ARB 0x8732 +#define GL_MODELVIEW19_ARB 0x8733 +#define GL_MODELVIEW20_ARB 0x8734 +#define GL_MODELVIEW21_ARB 0x8735 +#define GL_MODELVIEW22_ARB 0x8736 +#define GL_MODELVIEW23_ARB 0x8737 +#define GL_MODELVIEW24_ARB 0x8738 +#define GL_MODELVIEW25_ARB 0x8739 +#define GL_MODELVIEW26_ARB 0x873A +#define GL_MODELVIEW27_ARB 0x873B +#define GL_MODELVIEW28_ARB 0x873C +#define GL_MODELVIEW29_ARB 0x873D +#define GL_MODELVIEW30_ARB 0x873E +#define GL_MODELVIEW31_ARB 0x873F +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_MATRIX_PALETTE_ARB 0x8840 +#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841 +#define GL_MAX_PALETTE_MATRICES_ARB 0x8842 +#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843 +#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844 +#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845 +#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846 +#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847 +#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848 +#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849 +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_COMBINE_ARB 0x8570 +#define GL_COMBINE_RGB_ARB 0x8571 +#define GL_COMBINE_ALPHA_ARB 0x8572 +#define GL_SOURCE0_RGB_ARB 0x8580 +#define GL_SOURCE1_RGB_ARB 0x8581 +#define GL_SOURCE2_RGB_ARB 0x8582 +#define GL_SOURCE0_ALPHA_ARB 0x8588 +#define GL_SOURCE1_ALPHA_ARB 0x8589 +#define GL_SOURCE2_ALPHA_ARB 0x858A +#define GL_OPERAND0_RGB_ARB 0x8590 +#define GL_OPERAND1_RGB_ARB 0x8591 +#define GL_OPERAND2_RGB_ARB 0x8592 +#define GL_OPERAND0_ALPHA_ARB 0x8598 +#define GL_OPERAND1_ALPHA_ARB 0x8599 +#define GL_OPERAND2_ALPHA_ARB 0x859A +#define GL_RGB_SCALE_ARB 0x8573 +#define GL_ADD_SIGNED_ARB 0x8574 +#define GL_INTERPOLATE_ARB 0x8575 +#define GL_SUBTRACT_ARB 0x84E7 +#define GL_CONSTANT_ARB 0x8576 +#define GL_PRIMARY_COLOR_ARB 0x8577 +#define GL_PREVIOUS_ARB 0x8578 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_DOT3_RGB_ARB 0x86AE +#define GL_DOT3_RGBA_ARB 0x86AF +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_ARB 0x8370 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_DEPTH_COMPONENT16_ARB 0x81A5 +#define GL_DEPTH_COMPONENT24_ARB 0x81A6 +#define GL_DEPTH_COMPONENT32_ARB 0x81A7 +#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A +#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B +#endif + +#ifndef GL_ARB_shadow +#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C +#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D +#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF +#endif + +#ifndef GL_ARB_window_pos +#endif + +#ifndef GL_ARB_vertex_program +#define GL_COLOR_SUM_ARB 0x8458 +#define GL_VERTEX_PROGRAM_ARB 0x8620 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625 +#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626 +#define GL_PROGRAM_LENGTH_ARB 0x8627 +#define GL_PROGRAM_STRING_ARB 0x8628 +#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E +#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F +#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640 +#define GL_CURRENT_MATRIX_ARB 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643 +#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645 +#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B +#define GL_PROGRAM_BINDING_ARB 0x8677 +#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A +#define GL_PROGRAM_ERROR_STRING_ARB 0x8874 +#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875 +#define GL_PROGRAM_FORMAT_ARB 0x8876 +#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0 +#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1 +#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2 +#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3 +#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4 +#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5 +#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6 +#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7 +#define GL_PROGRAM_PARAMETERS_ARB 0x88A8 +#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9 +#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA +#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB +#define GL_PROGRAM_ATTRIBS_ARB 0x88AC +#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD +#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE +#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF +#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0 +#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1 +#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2 +#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3 +#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4 +#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5 +#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6 +#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7 +#define GL_MATRIX0_ARB 0x88C0 +#define GL_MATRIX1_ARB 0x88C1 +#define GL_MATRIX2_ARB 0x88C2 +#define GL_MATRIX3_ARB 0x88C3 +#define GL_MATRIX4_ARB 0x88C4 +#define GL_MATRIX5_ARB 0x88C5 +#define GL_MATRIX6_ARB 0x88C6 +#define GL_MATRIX7_ARB 0x88C7 +#define GL_MATRIX8_ARB 0x88C8 +#define GL_MATRIX9_ARB 0x88C9 +#define GL_MATRIX10_ARB 0x88CA +#define GL_MATRIX11_ARB 0x88CB +#define GL_MATRIX12_ARB 0x88CC +#define GL_MATRIX13_ARB 0x88CD +#define GL_MATRIX14_ARB 0x88CE +#define GL_MATRIX15_ARB 0x88CF +#define GL_MATRIX16_ARB 0x88D0 +#define GL_MATRIX17_ARB 0x88D1 +#define GL_MATRIX18_ARB 0x88D2 +#define GL_MATRIX19_ARB 0x88D3 +#define GL_MATRIX20_ARB 0x88D4 +#define GL_MATRIX21_ARB 0x88D5 +#define GL_MATRIX22_ARB 0x88D6 +#define GL_MATRIX23_ARB 0x88D7 +#define GL_MATRIX24_ARB 0x88D8 +#define GL_MATRIX25_ARB 0x88D9 +#define GL_MATRIX26_ARB 0x88DA +#define GL_MATRIX27_ARB 0x88DB +#define GL_MATRIX28_ARB 0x88DC +#define GL_MATRIX29_ARB 0x88DD +#define GL_MATRIX30_ARB 0x88DE +#define GL_MATRIX31_ARB 0x88DF +#endif + +#ifndef GL_ARB_fragment_program +#define GL_FRAGMENT_PROGRAM_ARB 0x8804 +#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805 +#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806 +#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807 +#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808 +#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809 +#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A +#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B +#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C +#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D +#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E +#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F +#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810 +#define GL_MAX_TEXTURE_COORDS_ARB 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872 +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_BUFFER_SIZE_ARB 0x8764 +#define GL_BUFFER_USAGE_ARB 0x8765 +#define GL_ARRAY_BUFFER_ARB 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893 +#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895 +#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896 +#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897 +#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898 +#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899 +#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A +#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B +#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C +#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D +#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F +#define GL_READ_ONLY_ARB 0x88B8 +#define GL_WRITE_ONLY_ARB 0x88B9 +#define GL_READ_WRITE_ARB 0x88BA +#define GL_BUFFER_ACCESS_ARB 0x88BB +#define GL_BUFFER_MAPPED_ARB 0x88BC +#define GL_BUFFER_MAP_POINTER_ARB 0x88BD +#define GL_STREAM_DRAW_ARB 0x88E0 +#define GL_STREAM_READ_ARB 0x88E1 +#define GL_STREAM_COPY_ARB 0x88E2 +#define GL_STATIC_DRAW_ARB 0x88E4 +#define GL_STATIC_READ_ARB 0x88E5 +#define GL_STATIC_COPY_ARB 0x88E6 +#define GL_DYNAMIC_DRAW_ARB 0x88E8 +#define GL_DYNAMIC_READ_ARB 0x88E9 +#define GL_DYNAMIC_COPY_ARB 0x88EA +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_QUERY_COUNTER_BITS_ARB 0x8864 +#define GL_CURRENT_QUERY_ARB 0x8865 +#define GL_QUERY_RESULT_ARB 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867 +#define GL_SAMPLES_PASSED_ARB 0x8914 +#endif + +#ifndef GL_ARB_shader_objects +#define GL_PROGRAM_OBJECT_ARB 0x8B40 +#define GL_SHADER_OBJECT_ARB 0x8B48 +#define GL_OBJECT_TYPE_ARB 0x8B4E +#define GL_OBJECT_SUBTYPE_ARB 0x8B4F +#define GL_FLOAT_VEC2_ARB 0x8B50 +#define GL_FLOAT_VEC3_ARB 0x8B51 +#define GL_FLOAT_VEC4_ARB 0x8B52 +#define GL_INT_VEC2_ARB 0x8B53 +#define GL_INT_VEC3_ARB 0x8B54 +#define GL_INT_VEC4_ARB 0x8B55 +#define GL_BOOL_ARB 0x8B56 +#define GL_BOOL_VEC2_ARB 0x8B57 +#define GL_BOOL_VEC3_ARB 0x8B58 +#define GL_BOOL_VEC4_ARB 0x8B59 +#define GL_FLOAT_MAT2_ARB 0x8B5A +#define GL_FLOAT_MAT3_ARB 0x8B5B +#define GL_FLOAT_MAT4_ARB 0x8B5C +#define GL_SAMPLER_1D_ARB 0x8B5D +#define GL_SAMPLER_2D_ARB 0x8B5E +#define GL_SAMPLER_3D_ARB 0x8B5F +#define GL_SAMPLER_CUBE_ARB 0x8B60 +#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61 +#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62 +#define GL_SAMPLER_2D_RECT_ARB 0x8B63 +#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64 +#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80 +#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81 +#define GL_OBJECT_LINK_STATUS_ARB 0x8B82 +#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83 +#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84 +#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85 +#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86 +#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87 +#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88 +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_VERTEX_SHADER_ARB 0x8B31 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A +#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D +#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89 +#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_FRAGMENT_SHADER_ARB 0x8B30 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#endif + +#ifndef GL_ARB_point_sprite +#define GL_POINT_SPRITE_ARB 0x8861 +#define GL_COORD_REPLACE_ARB 0x8862 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ARB 0x8824 +#define GL_DRAW_BUFFER0_ARB 0x8825 +#define GL_DRAW_BUFFER1_ARB 0x8826 +#define GL_DRAW_BUFFER2_ARB 0x8827 +#define GL_DRAW_BUFFER3_ARB 0x8828 +#define GL_DRAW_BUFFER4_ARB 0x8829 +#define GL_DRAW_BUFFER5_ARB 0x882A +#define GL_DRAW_BUFFER6_ARB 0x882B +#define GL_DRAW_BUFFER7_ARB 0x882C +#define GL_DRAW_BUFFER8_ARB 0x882D +#define GL_DRAW_BUFFER9_ARB 0x882E +#define GL_DRAW_BUFFER10_ARB 0x882F +#define GL_DRAW_BUFFER11_ARB 0x8830 +#define GL_DRAW_BUFFER12_ARB 0x8831 +#define GL_DRAW_BUFFER13_ARB 0x8832 +#define GL_DRAW_BUFFER14_ARB 0x8833 +#define GL_DRAW_BUFFER15_ARB 0x8834 +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_RGBA_FLOAT_MODE_ARB 0x8820 +#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A +#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B +#define GL_CLAMP_READ_COLOR_ARB 0x891C +#define GL_FIXED_ONLY_ARB 0x891D +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_HALF_FLOAT_ARB 0x140B +#endif + +#ifndef GL_ARB_texture_float +#define GL_TEXTURE_RED_TYPE_ARB 0x8C10 +#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11 +#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13 +#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14 +#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15 +#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16 +#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17 +#define GL_RGBA32F_ARB 0x8814 +#define GL_RGB32F_ARB 0x8815 +#define GL_ALPHA32F_ARB 0x8816 +#define GL_INTENSITY32F_ARB 0x8817 +#define GL_LUMINANCE32F_ARB 0x8818 +#define GL_LUMINANCE_ALPHA32F_ARB 0x8819 +#define GL_RGBA16F_ARB 0x881A +#define GL_RGB16F_ARB 0x881B +#define GL_ALPHA16F_ARB 0x881C +#define GL_INTENSITY16F_ARB 0x881D +#define GL_LUMINANCE16F_ARB 0x881E +#define GL_LUMINANCE_ALPHA16F_ARB 0x881F +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#endif + +#ifndef GL_ARB_draw_instanced +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_INDEX 0x8222 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_STENCIL_INDEX1 0x8D46 +#define GL_STENCIL_INDEX4 0x8D47 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_STENCIL_INDEX16 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB 0x8DB9 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_LINES_ADJACENCY_ARB 0x000A +#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B +#define GL_TRIANGLES_ADJACENCY_ARB 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D +#define GL_PROGRAM_POINT_SIZE_ARB 0x8642 +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9 +#define GL_GEOMETRY_SHADER_ARB 0x8DD9 +#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1 +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_HALF_FLOAT 0x140B +#endif + +#ifndef GL_ARB_instanced_arrays +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_TEXTURE_BUFFER_ARB 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC +#define GL_COMPRESSED_RG_RGTC2 0x8DBD +#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE +#endif + +#ifndef GL_ARB_texture_rg +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_R16 0x822A +#define GL_RG8 0x822B +#define GL_RG16 0x822C +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#endif + +#ifndef GL_EXT_abgr +#define GL_ABGR_EXT 0x8000 +#endif + +#ifndef GL_EXT_blend_color +#define GL_CONSTANT_COLOR_EXT 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002 +#define GL_CONSTANT_ALPHA_EXT 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004 +#define GL_BLEND_COLOR_EXT 0x8005 +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_POLYGON_OFFSET_EXT 0x8037 +#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038 +#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039 +#endif + +#ifndef GL_EXT_texture +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 +#define GL_TEXTURE_TOO_LARGE_EXT 0x8065 +#endif + +#ifndef GL_EXT_texture3D +#define GL_PACK_SKIP_IMAGES_EXT 0x806B +#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C +#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D +#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E +#define GL_TEXTURE_3D_EXT 0x806F +#define GL_PROXY_TEXTURE_3D_EXT 0x8070 +#define GL_TEXTURE_DEPTH_EXT 0x8071 +#define GL_TEXTURE_WRAP_R_EXT 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073 +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 +#endif + +#ifndef GL_EXT_subtexture +#endif + +#ifndef GL_EXT_copy_texture +#endif + +#ifndef GL_EXT_histogram +#define GL_HISTOGRAM_EXT 0x8024 +#define GL_PROXY_HISTOGRAM_EXT 0x8025 +#define GL_HISTOGRAM_WIDTH_EXT 0x8026 +#define GL_HISTOGRAM_FORMAT_EXT 0x8027 +#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028 +#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029 +#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A +#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B +#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C +#define GL_HISTOGRAM_SINK_EXT 0x802D +#define GL_MINMAX_EXT 0x802E +#define GL_MINMAX_FORMAT_EXT 0x802F +#define GL_MINMAX_SINK_EXT 0x8030 +#define GL_TABLE_TOO_LARGE_EXT 0x8031 +#endif + +#ifndef GL_EXT_convolution +#define GL_CONVOLUTION_1D_EXT 0x8010 +#define GL_CONVOLUTION_2D_EXT 0x8011 +#define GL_SEPARABLE_2D_EXT 0x8012 +#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013 +#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014 +#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015 +#define GL_REDUCE_EXT 0x8016 +#define GL_CONVOLUTION_FORMAT_EXT 0x8017 +#define GL_CONVOLUTION_WIDTH_EXT 0x8018 +#define GL_CONVOLUTION_HEIGHT_EXT 0x8019 +#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A +#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B +#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C +#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D +#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E +#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F +#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020 +#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021 +#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022 +#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023 +#endif + +#ifndef GL_SGI_color_matrix +#define GL_COLOR_MATRIX_SGI 0x80B1 +#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2 +#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3 +#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4 +#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5 +#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6 +#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7 +#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8 +#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9 +#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA +#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB +#endif + +#ifndef GL_SGI_color_table +#define GL_COLOR_TABLE_SGI 0x80D0 +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B +#endif + +#ifndef GL_SGIS_texture4D +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD +#endif + +#ifndef GL_EXT_cmyka +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F +#endif + +#ifndef GL_EXT_texture_object +#define GL_TEXTURE_PRIORITY_EXT 0x8066 +#define GL_TEXTURE_RESIDENT_EXT 0x8067 +#define GL_TEXTURE_1D_BINDING_EXT 0x8068 +#define GL_TEXTURE_2D_BINDING_EXT 0x8069 +#define GL_TEXTURE_3D_BINDING_EXT 0x806A +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095 +#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096 +#define GL_LINEAR_DETAIL_SGIS 0x8097 +#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098 +#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099 +#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A +#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B +#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_LINEAR_SHARPEN_SGIS 0x80AD +#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE +#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF +#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0 +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032 +#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034 +#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035 +#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D +#endif + +#ifndef GL_SGIS_multisample +#define GL_MULTISAMPLE_SGIS 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F +#define GL_SAMPLE_MASK_SGIS 0x80A0 +#define GL_1PASS_SGIS 0x80A1 +#define GL_2PASS_0_SGIS 0x80A2 +#define GL_2PASS_1_SGIS 0x80A3 +#define GL_4PASS_0_SGIS 0x80A4 +#define GL_4PASS_1_SGIS 0x80A5 +#define GL_4PASS_2_SGIS 0x80A6 +#define GL_4PASS_3_SGIS 0x80A7 +#define GL_SAMPLE_BUFFERS_SGIS 0x80A8 +#define GL_SAMPLES_SGIS 0x80A9 +#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA +#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB +#define GL_SAMPLE_PATTERN_SGIS 0x80AC +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_RESCALE_NORMAL_EXT 0x803A +#endif + +#ifndef GL_EXT_vertex_array +#define GL_VERTEX_ARRAY_EXT 0x8074 +#define GL_NORMAL_ARRAY_EXT 0x8075 +#define GL_COLOR_ARRAY_EXT 0x8076 +#define GL_INDEX_ARRAY_EXT 0x8077 +#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078 +#define GL_EDGE_FLAG_ARRAY_EXT 0x8079 +#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A +#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B +#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C +#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D +#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E +#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F +#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080 +#define GL_COLOR_ARRAY_SIZE_EXT 0x8081 +#define GL_COLOR_ARRAY_TYPE_EXT 0x8082 +#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083 +#define GL_COLOR_ARRAY_COUNT_EXT 0x8084 +#define GL_INDEX_ARRAY_TYPE_EXT 0x8085 +#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086 +#define GL_INDEX_ARRAY_COUNT_EXT 0x8087 +#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088 +#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089 +#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A +#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B +#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C +#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D +#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E +#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F +#define GL_COLOR_ARRAY_POINTER_EXT 0x8090 +#define GL_INDEX_ARRAY_POINTER_EXT 0x8091 +#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092 +#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093 +#endif + +#ifndef GL_EXT_misc_attribute +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 +#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D +#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E +#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F +#endif + +#ifndef GL_SGIX_shadow +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_CLAMP_TO_EDGE_SGIS 0x812F +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_CLAMP_TO_BORDER_SGIS 0x812D +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_FUNC_ADD_EXT 0x8006 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#define GL_BLEND_EQUATION_EXT 0x8009 +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_FUNC_SUBTRACT_EXT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B +#endif + +#ifndef GL_EXT_blend_logic_op +#endif + +#ifndef GL_SGIX_interlace +#define GL_INTERLACE_SGIX 0x8094 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E +#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F +#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140 +#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141 +#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142 +#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143 +#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144 +#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145 +#endif + +#ifndef GL_SGIS_texture_select +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS 0x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SPRITE_SGIX 0x8148 +#define GL_SPRITE_MODE_SGIX 0x8149 +#define GL_SPRITE_AXIS_SGIX 0x814A +#define GL_SPRITE_TRANSLATION_SGIX 0x814B +#define GL_SPRITE_AXIAL_SGIX 0x814C +#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D +#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E +#endif + +#ifndef GL_EXT_point_parameters +#define GL_POINT_SIZE_MIN_EXT 0x8126 +#define GL_POINT_SIZE_MAX_EXT 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128 +#define GL_DISTANCE_ATTENUATION_EXT 0x8129 +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_POINT_SIZE_MIN_SGIS 0x8126 +#define GL_POINT_SIZE_MAX_SGIS 0x8127 +#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128 +#define GL_DISTANCE_ATTENUATION_SGIS 0x8129 +#endif + +#ifndef GL_SGIX_instruments +#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180 +#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181 +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C +#endif + +#ifndef GL_SGIX_framezoom +#define GL_FRAMEZOOM_SGIX 0x818B +#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C +#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#endif + +#ifndef GL_FfdMaskSGIX +#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001 +#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002 +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194 +#define GL_TEXTURE_DEFORMATION_SGIX 0x8195 +#define GL_DEFORMATIONS_MASK_SGIX 0x8196 +#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197 +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_REFERENCE_PLANE_SGIX 0x817D +#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E +#endif + +#ifndef GL_SGIX_flush_raster +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 +#endif + +#ifndef GL_HP_image_transform +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 +#endif + +#ifndef GL_INGR_palette_buffer +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE +#endif + +#ifndef GL_EXT_color_subtable +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_VERTEX_DATA_HINT_PGI 0x1A22A +#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B +#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C +#define GL_MAX_VERTEX_HINT_PGI 0x1A22D +#define GL_COLOR3_BIT_PGI 0x00010000 +#define GL_COLOR4_BIT_PGI 0x00020000 +#define GL_EDGEFLAG_BIT_PGI 0x00040000 +#define GL_INDEX_BIT_PGI 0x00080000 +#define GL_MAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_MAT_EMISSION_BIT_PGI 0x00800000 +#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_MAT_SHININESS_BIT_PGI 0x02000000 +#define GL_MAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_NORMAL_BIT_PGI 0x08000000 +#define GL_TEXCOORD1_BIT_PGI 0x10000000 +#define GL_TEXCOORD2_BIT_PGI 0x20000000 +#define GL_TEXCOORD3_BIT_PGI 0x40000000 +#define GL_TEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8 +#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD +#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE +#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202 +#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203 +#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204 +#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C +#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D +#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E +#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F +#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210 +#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211 +#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216 +#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217 +#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218 +#define GL_FULL_STIPPLE_HINT_PGI 0x1A219 +#define GL_CLIP_NEAR_HINT_PGI 0x1A220 +#define GL_CLIP_FAR_HINT_PGI 0x1A221 +#define GL_WIDE_LINE_HINT_PGI 0x1A222 +#define GL_BACK_NORMALS_HINT_PGI 0x1A223 +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_COLOR_INDEX1_EXT 0x80E2 +#define GL_COLOR_INDEX2_EXT 0x80E3 +#define GL_COLOR_INDEX4_EXT 0x80E4 +#define GL_COLOR_INDEX8_EXT 0x80E5 +#define GL_COLOR_INDEX12_EXT 0x80E6 +#define GL_COLOR_INDEX16_EXT 0x80E7 +#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_LIST_PRIORITY_SGIX 0x8182 +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_IR_INSTRUMENT1_SGIX 0x817F +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SHADOW_AMBIENT_SGIX 0x80BF +#endif + +#ifndef GL_EXT_index_texture +#endif + +#ifndef GL_EXT_index_material +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA +#endif + +#ifndef GL_EXT_index_func +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8 +#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9 +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_CULL_VERTEX_EXT 0x81AA +#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB +#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_FRAGMENT_LIGHTING_SGIX 0x8400 +#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401 +#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402 +#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403 +#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404 +#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405 +#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406 +#define GL_LIGHT_ENV_MODE_SGIX 0x8407 +#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408 +#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409 +#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A +#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B +#define GL_FRAGMENT_LIGHT0_SGIX 0x840C +#define GL_FRAGMENT_LIGHT1_SGIX 0x840D +#define GL_FRAGMENT_LIGHT2_SGIX 0x840E +#define GL_FRAGMENT_LIGHT3_SGIX 0x840F +#define GL_FRAGMENT_LIGHT4_SGIX 0x8410 +#define GL_FRAGMENT_LIGHT5_SGIX 0x8411 +#define GL_FRAGMENT_LIGHT6_SGIX 0x8412 +#define GL_FRAGMENT_LIGHT7_SGIX 0x8413 +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 +#endif + +#ifndef GL_WIN_phong_shading +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB +#endif + +#ifndef GL_WIN_specular_fog +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#endif + +#ifndef GL_EXT_light_texture +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 +/* reuse GL_FRAGMENT_DEPTH_EXT */ +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_ALPHA_MIN_SGIX 0x8320 +#define GL_ALPHA_MAX_SGIX 0x8321 +#endif + +#ifndef GL_SGIX_impact_pixel_texture +#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184 +#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185 +#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186 +#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187 +#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188 +#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189 +#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A +#endif + +#ifndef GL_EXT_bgra +#define GL_BGR_EXT 0x80E0 +#define GL_BGRA_EXT 0x80E1 +#endif + +#ifndef GL_SGIX_async +#define GL_ASYNC_MARKER_SGIX 0x8329 +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C +#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D +#define GL_ASYNC_READ_PIXELS_SGIX 0x835E +#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F +#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360 +#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_ASYNC_HISTOGRAM_SGIX 0x832C +#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D +#endif + +#ifndef GL_INTEL_texture_scissor +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 +#endif + +#ifndef GL_HP_occlusion_test +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA +#endif + +#ifndef GL_EXT_secondary_color +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF +#endif + +#ifndef GL_EXT_multi_draw_arrays +#endif + +#ifndef GL_EXT_fog_coord +#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 +#define GL_FOG_COORDINATE_EXT 0x8451 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 +#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 +#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457 +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_COMBINE_EXT 0x8570 +#define GL_COMBINE_RGB_EXT 0x8571 +#define GL_COMBINE_ALPHA_EXT 0x8572 +#define GL_RGB_SCALE_EXT 0x8573 +#define GL_ADD_SIGNED_EXT 0x8574 +#define GL_INTERPOLATE_EXT 0x8575 +#define GL_CONSTANT_EXT 0x8576 +#define GL_PRIMARY_COLOR_EXT 0x8577 +#define GL_PREVIOUS_EXT 0x8578 +#define GL_SOURCE0_RGB_EXT 0x8580 +#define GL_SOURCE1_RGB_EXT 0x8581 +#define GL_SOURCE2_RGB_EXT 0x8582 +#define GL_SOURCE0_ALPHA_EXT 0x8588 +#define GL_SOURCE1_ALPHA_EXT 0x8589 +#define GL_SOURCE2_ALPHA_EXT 0x858A +#define GL_OPERAND0_RGB_EXT 0x8590 +#define GL_OPERAND1_RGB_EXT 0x8591 +#define GL_OPERAND2_RGB_EXT 0x8592 +#define GL_OPERAND0_ALPHA_EXT 0x8598 +#define GL_OPERAND1_ALPHA_EXT 0x8599 +#define GL_OPERAND2_ALPHA_EXT 0x859A +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_TRANSFORM_HINT_APPLE 0x85B1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_FOG_SCALE_SGIX 0x81FC +#define GL_FOG_SCALE_VALUE_SGIX 0x81FD +#endif + +#ifndef GL_SUNX_constant_data +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 +#endif + +#ifndef GL_SUN_global_alpha +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA +#endif + +#ifndef GL_SUN_triangle_list +#define GL_RESTART_SUN 0x0001 +#define GL_REPLACE_MIDDLE_SUN 0x0002 +#define GL_REPLACE_OLDEST_SUN 0x0003 +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB +#endif + +#ifndef GL_SUN_vertex +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_BLEND_DST_RGB_EXT 0x80C8 +#define GL_BLEND_SRC_RGB_EXT 0x80C9 +#define GL_BLEND_DST_ALPHA_EXT 0x80CA +#define GL_BLEND_SRC_ALPHA_EXT 0x80CB +#endif + +#ifndef GL_INGR_color_clamp +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INTERLACE_READ_INGR 0x8568 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_INCR_WRAP_EXT 0x8507 +#define GL_DECR_WRAP_EXT 0x8508 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NORMAL_MAP_NV 0x8511 +#define GL_REFLECTION_MAP_NV 0x8512 +#endif + +#ifndef GL_EXT_texture_cube_map +#define GL_NORMAL_MAP_EXT 0x8511 +#define GL_REFLECTION_MAP_EXT 0x8512 +#define GL_TEXTURE_CUBE_MAP_EXT 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_WRAP_BORDER_SUN 0x81D4 +#endif + +#ifndef GL_EXT_texture_env_add +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH +#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 +#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX +#define GL_MODELVIEW1_MATRIX_EXT 0x8506 +#define GL_VERTEX_WEIGHTING_EXT 0x8509 +#define GL_MODELVIEW0_EXT GL_MODELVIEW +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F +#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_MAX_SHININESS_NV 0x8504 +#define GL_MAX_SPOT_EXPONENT_NV 0x8505 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 +#endif + +#ifndef GL_NV_register_combiners +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_DISCARD_NV 0x8530 +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +/* reuse GL_TEXTURE0_ARB */ +/* reuse GL_TEXTURE1_ARB */ +/* reuse GL_ZERO */ +/* reuse GL_NONE */ +/* reuse GL_FOG */ +#endif + +#ifndef GL_NV_fog_distance +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C +/* reuse GL_EYE_PLANE */ +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E +#define GL_EMBOSS_MAP_NV 0x855F +#endif + +#ifndef GL_NV_blend_square +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_COMBINE4_NV 0x8503 +#define GL_SOURCE3_RGB_NV 0x8583 +#define GL_SOURCE3_ALPHA_NV 0x858B +#define GL_OPERAND3_RGB_NV 0x8593 +#define GL_OPERAND3_ALPHA_NV 0x859B +#endif + +#ifndef GL_MESA_resize_buffers +#endif + +#ifndef GL_MESA_window_pos +#endif + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_CULL_VERTEX_IBM 103050 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 +#endif + +#ifndef GL_SGIX_subsample +#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0 +#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1 +#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2 +#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3 +#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_YCRCB_SGIX 0x8318 +#define GL_YCRCBA_SGIX 0x8319 +#endif + +#ifndef GL_SGI_depth_pass_instrument +#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310 +#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311 +#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 +#endif + +#ifndef GL_3DFX_tbuffer +#endif + +#ifndef GL_EXT_multisample +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 +#define GL_1PASS_EXT 0x80A1 +#define GL_2PASS_0_EXT 0x80A2 +#define GL_2PASS_1_EXT 0x80A3 +#define GL_4PASS_0_EXT 0x80A4 +#define GL_4PASS_1_EXT 0x80A5 +#define GL_4PASS_2_EXT 0x80A6 +#define GL_4PASS_3_EXT 0x80A7 +#define GL_SAMPLE_BUFFERS_EXT 0x80A8 +#define GL_SAMPLES_EXT 0x80A9 +#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA +#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB +#define GL_SAMPLE_PATTERN_EXT 0x80AC +#define GL_MULTISAMPLE_BIT_EXT 0x20000000 +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_CONVOLUTION_HINT_SGIX 0x8316 +#endif + +#ifndef GL_SGIX_resample +#define GL_PACK_RESAMPLE_SGIX 0x842C +#define GL_UNPACK_RESAMPLE_SGIX 0x842D +#define GL_RESAMPLE_REPLICATE_SGIX 0x842E +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F +#define GL_RESAMPLE_DECIMATE_SGIX 0x8430 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0 +#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1 +#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2 +#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3 +#define GL_EYE_POINT_SGIS 0x81F4 +#define GL_OBJECT_POINT_SGIS 0x81F5 +#define GL_EYE_LINE_SGIS 0x81F6 +#define GL_OBJECT_LINE_SGIS 0x81F7 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_DOT3_RGB_EXT 0x8740 +#define GL_DOT3_RGBA_EXT 0x8741 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_MIRROR_CLAMP_ATI 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743 +#endif + +#ifndef GL_NV_fence +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +#endif + +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_MIRRORED_REPEAT_IBM 0x8370 +#endif + +#ifndef GL_NV_evaluators +#define GL_EVAL_2D_NV 0x86C0 +#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1 +#define GL_MAP_TESSELLATION_NV 0x86C2 +#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3 +#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4 +#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5 +#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6 +#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7 +#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8 +#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9 +#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA +#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB +#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC +#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD +#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE +#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF +#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0 +#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1 +#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2 +#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3 +#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4 +#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5 +#define GL_MAX_MAP_TESSELLATION_NV 0x86D6 +#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7 +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_DEPTH_STENCIL_NV 0x84F9 +#define GL_UNSIGNED_INT_24_8_NV 0x84FA +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_NV_texture_compression_vtc +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_TEXTURE_RECTANGLE_NV 0x84F5 +#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6 +#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7 +#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8 +#endif + +#ifndef GL_NV_texture_shader +#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C +#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D +#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E +#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9 +#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA +#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB +#define GL_DSDT_MAG_INTENSITY_NV 0x86DC +#define GL_SHADER_CONSISTENT_NV 0x86DD +#define GL_TEXTURE_SHADER_NV 0x86DE +#define GL_SHADER_OPERATION_NV 0x86DF +#define GL_CULL_MODES_NV 0x86E0 +#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1 +#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2 +#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3 +#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV +#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV +#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV +#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4 +#define GL_CONST_EYE_NV 0x86E5 +#define GL_PASS_THROUGH_NV 0x86E6 +#define GL_CULL_FRAGMENT_NV 0x86E7 +#define GL_OFFSET_TEXTURE_2D_NV 0x86E8 +#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9 +#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA +#define GL_DOT_PRODUCT_NV 0x86EC +#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED +#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE +#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0 +#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1 +#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2 +#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3 +#define GL_HILO_NV 0x86F4 +#define GL_DSDT_NV 0x86F5 +#define GL_DSDT_MAG_NV 0x86F6 +#define GL_DSDT_MAG_VIB_NV 0x86F7 +#define GL_HILO16_NV 0x86F8 +#define GL_SIGNED_HILO_NV 0x86F9 +#define GL_SIGNED_HILO16_NV 0x86FA +#define GL_SIGNED_RGBA_NV 0x86FB +#define GL_SIGNED_RGBA8_NV 0x86FC +#define GL_SIGNED_RGB_NV 0x86FE +#define GL_SIGNED_RGB8_NV 0x86FF +#define GL_SIGNED_LUMINANCE_NV 0x8701 +#define GL_SIGNED_LUMINANCE8_NV 0x8702 +#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703 +#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704 +#define GL_SIGNED_ALPHA_NV 0x8705 +#define GL_SIGNED_ALPHA8_NV 0x8706 +#define GL_SIGNED_INTENSITY_NV 0x8707 +#define GL_SIGNED_INTENSITY8_NV 0x8708 +#define GL_DSDT8_NV 0x8709 +#define GL_DSDT8_MAG8_NV 0x870A +#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B +#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C +#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D +#define GL_HI_SCALE_NV 0x870E +#define GL_LO_SCALE_NV 0x870F +#define GL_DS_SCALE_NV 0x8710 +#define GL_DT_SCALE_NV 0x8711 +#define GL_MAGNITUDE_SCALE_NV 0x8712 +#define GL_VIBRANCE_SCALE_NV 0x8713 +#define GL_HI_BIAS_NV 0x8714 +#define GL_LO_BIAS_NV 0x8715 +#define GL_DS_BIAS_NV 0x8716 +#define GL_DT_BIAS_NV 0x8717 +#define GL_MAGNITUDE_BIAS_NV 0x8718 +#define GL_VIBRANCE_BIAS_NV 0x8719 +#define GL_TEXTURE_BORDER_VALUES_NV 0x871A +#define GL_TEXTURE_HI_SIZE_NV 0x871B +#define GL_TEXTURE_LO_SIZE_NV 0x871C +#define GL_TEXTURE_DS_SIZE_NV 0x871D +#define GL_TEXTURE_DT_SIZE_NV 0x871E +#define GL_TEXTURE_MAG_SIZE_NV 0x871F +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533 +#endif + +#ifndef GL_NV_vertex_program +#define GL_VERTEX_PROGRAM_NV 0x8620 +#define GL_VERTEX_STATE_PROGRAM_NV 0x8621 +#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623 +#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624 +#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625 +#define GL_CURRENT_ATTRIB_NV 0x8626 +#define GL_PROGRAM_LENGTH_NV 0x8627 +#define GL_PROGRAM_STRING_NV 0x8628 +#define GL_MODELVIEW_PROJECTION_NV 0x8629 +#define GL_IDENTITY_NV 0x862A +#define GL_INVERSE_NV 0x862B +#define GL_TRANSPOSE_NV 0x862C +#define GL_INVERSE_TRANSPOSE_NV 0x862D +#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E +#define GL_MAX_TRACK_MATRICES_NV 0x862F +#define GL_MATRIX0_NV 0x8630 +#define GL_MATRIX1_NV 0x8631 +#define GL_MATRIX2_NV 0x8632 +#define GL_MATRIX3_NV 0x8633 +#define GL_MATRIX4_NV 0x8634 +#define GL_MATRIX5_NV 0x8635 +#define GL_MATRIX6_NV 0x8636 +#define GL_MATRIX7_NV 0x8637 +#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640 +#define GL_CURRENT_MATRIX_NV 0x8641 +#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642 +#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643 +#define GL_PROGRAM_PARAMETER_NV 0x8644 +#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645 +#define GL_PROGRAM_TARGET_NV 0x8646 +#define GL_PROGRAM_RESIDENT_NV 0x8647 +#define GL_TRACK_MATRIX_NV 0x8648 +#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649 +#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A +#define GL_PROGRAM_ERROR_POSITION_NV 0x864B +#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650 +#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651 +#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652 +#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653 +#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654 +#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655 +#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656 +#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657 +#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658 +#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659 +#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A +#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B +#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C +#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D +#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E +#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F +#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660 +#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661 +#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662 +#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663 +#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664 +#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665 +#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666 +#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667 +#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668 +#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669 +#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A +#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B +#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C +#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D +#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E +#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F +#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670 +#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671 +#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672 +#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673 +#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674 +#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675 +#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676 +#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677 +#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678 +#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679 +#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A +#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B +#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C +#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D +#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E +#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369 +#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A +#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SCALEBIAS_HINT_SGIX 0x8322 +#endif + +#ifndef GL_OML_interlace +#define GL_INTERLACE_OML 0x8980 +#define GL_INTERLACE_READ_OML 0x8981 +#endif + +#ifndef GL_OML_subsample +#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982 +#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983 +#endif + +#ifndef GL_OML_resample +#define GL_PACK_RESAMPLE_OML 0x8984 +#define GL_UNPACK_RESAMPLE_OML 0x8985 +#define GL_RESAMPLE_REPLICATE_OML 0x8986 +#define GL_RESAMPLE_ZERO_FILL_OML 0x8987 +#define GL_RESAMPLE_AVERAGE_OML 0x8988 +#define GL_RESAMPLE_DECIMATE_OML 0x8989 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E +#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_BUMP_ROT_MATRIX_ATI 0x8775 +#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776 +#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777 +#define GL_BUMP_TEX_UNITS_ATI 0x8778 +#define GL_DUDV_ATI 0x8779 +#define GL_DU8DV8_ATI 0x877A +#define GL_BUMP_ENVMAP_ATI 0x877B +#define GL_BUMP_TARGET_ATI 0x877C +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_FRAGMENT_SHADER_ATI 0x8920 +#define GL_REG_0_ATI 0x8921 +#define GL_REG_1_ATI 0x8922 +#define GL_REG_2_ATI 0x8923 +#define GL_REG_3_ATI 0x8924 +#define GL_REG_4_ATI 0x8925 +#define GL_REG_5_ATI 0x8926 +#define GL_REG_6_ATI 0x8927 +#define GL_REG_7_ATI 0x8928 +#define GL_REG_8_ATI 0x8929 +#define GL_REG_9_ATI 0x892A +#define GL_REG_10_ATI 0x892B +#define GL_REG_11_ATI 0x892C +#define GL_REG_12_ATI 0x892D +#define GL_REG_13_ATI 0x892E +#define GL_REG_14_ATI 0x892F +#define GL_REG_15_ATI 0x8930 +#define GL_REG_16_ATI 0x8931 +#define GL_REG_17_ATI 0x8932 +#define GL_REG_18_ATI 0x8933 +#define GL_REG_19_ATI 0x8934 +#define GL_REG_20_ATI 0x8935 +#define GL_REG_21_ATI 0x8936 +#define GL_REG_22_ATI 0x8937 +#define GL_REG_23_ATI 0x8938 +#define GL_REG_24_ATI 0x8939 +#define GL_REG_25_ATI 0x893A +#define GL_REG_26_ATI 0x893B +#define GL_REG_27_ATI 0x893C +#define GL_REG_28_ATI 0x893D +#define GL_REG_29_ATI 0x893E +#define GL_REG_30_ATI 0x893F +#define GL_REG_31_ATI 0x8940 +#define GL_CON_0_ATI 0x8941 +#define GL_CON_1_ATI 0x8942 +#define GL_CON_2_ATI 0x8943 +#define GL_CON_3_ATI 0x8944 +#define GL_CON_4_ATI 0x8945 +#define GL_CON_5_ATI 0x8946 +#define GL_CON_6_ATI 0x8947 +#define GL_CON_7_ATI 0x8948 +#define GL_CON_8_ATI 0x8949 +#define GL_CON_9_ATI 0x894A +#define GL_CON_10_ATI 0x894B +#define GL_CON_11_ATI 0x894C +#define GL_CON_12_ATI 0x894D +#define GL_CON_13_ATI 0x894E +#define GL_CON_14_ATI 0x894F +#define GL_CON_15_ATI 0x8950 +#define GL_CON_16_ATI 0x8951 +#define GL_CON_17_ATI 0x8952 +#define GL_CON_18_ATI 0x8953 +#define GL_CON_19_ATI 0x8954 +#define GL_CON_20_ATI 0x8955 +#define GL_CON_21_ATI 0x8956 +#define GL_CON_22_ATI 0x8957 +#define GL_CON_23_ATI 0x8958 +#define GL_CON_24_ATI 0x8959 +#define GL_CON_25_ATI 0x895A +#define GL_CON_26_ATI 0x895B +#define GL_CON_27_ATI 0x895C +#define GL_CON_28_ATI 0x895D +#define GL_CON_29_ATI 0x895E +#define GL_CON_30_ATI 0x895F +#define GL_CON_31_ATI 0x8960 +#define GL_MOV_ATI 0x8961 +#define GL_ADD_ATI 0x8963 +#define GL_MUL_ATI 0x8964 +#define GL_SUB_ATI 0x8965 +#define GL_DOT3_ATI 0x8966 +#define GL_DOT4_ATI 0x8967 +#define GL_MAD_ATI 0x8968 +#define GL_LERP_ATI 0x8969 +#define GL_CND_ATI 0x896A +#define GL_CND0_ATI 0x896B +#define GL_DOT2_ADD_ATI 0x896C +#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D +#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E +#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F +#define GL_NUM_PASSES_ATI 0x8970 +#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971 +#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972 +#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973 +#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974 +#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975 +#define GL_SWIZZLE_STR_ATI 0x8976 +#define GL_SWIZZLE_STQ_ATI 0x8977 +#define GL_SWIZZLE_STR_DR_ATI 0x8978 +#define GL_SWIZZLE_STQ_DQ_ATI 0x8979 +#define GL_SWIZZLE_STRQ_ATI 0x897A +#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B +#define GL_RED_BIT_ATI 0x00000001 +#define GL_GREEN_BIT_ATI 0x00000002 +#define GL_BLUE_BIT_ATI 0x00000004 +#define GL_2X_BIT_ATI 0x00000001 +#define GL_4X_BIT_ATI 0x00000002 +#define GL_8X_BIT_ATI 0x00000004 +#define GL_HALF_BIT_ATI 0x00000008 +#define GL_QUARTER_BIT_ATI 0x00000010 +#define GL_EIGHTH_BIT_ATI 0x00000020 +#define GL_SATURATE_BIT_ATI 0x00000040 +#define GL_COMP_BIT_ATI 0x00000002 +#define GL_NEGATE_BIT_ATI 0x00000004 +#define GL_BIAS_BIT_ATI 0x00000008 +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_PN_TRIANGLES_ATI 0x87F0 +#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1 +#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2 +#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3 +#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4 +#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5 +#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6 +#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7 +#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8 +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_STATIC_ATI 0x8760 +#define GL_DYNAMIC_ATI 0x8761 +#define GL_PRESERVE_ATI 0x8762 +#define GL_DISCARD_ATI 0x8763 +#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764 +#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765 +#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766 +#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767 +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_VERTEX_SHADER_EXT 0x8780 +#define GL_VERTEX_SHADER_BINDING_EXT 0x8781 +#define GL_OP_INDEX_EXT 0x8782 +#define GL_OP_NEGATE_EXT 0x8783 +#define GL_OP_DOT3_EXT 0x8784 +#define GL_OP_DOT4_EXT 0x8785 +#define GL_OP_MUL_EXT 0x8786 +#define GL_OP_ADD_EXT 0x8787 +#define GL_OP_MADD_EXT 0x8788 +#define GL_OP_FRAC_EXT 0x8789 +#define GL_OP_MAX_EXT 0x878A +#define GL_OP_MIN_EXT 0x878B +#define GL_OP_SET_GE_EXT 0x878C +#define GL_OP_SET_LT_EXT 0x878D +#define GL_OP_CLAMP_EXT 0x878E +#define GL_OP_FLOOR_EXT 0x878F +#define GL_OP_ROUND_EXT 0x8790 +#define GL_OP_EXP_BASE_2_EXT 0x8791 +#define GL_OP_LOG_BASE_2_EXT 0x8792 +#define GL_OP_POWER_EXT 0x8793 +#define GL_OP_RECIP_EXT 0x8794 +#define GL_OP_RECIP_SQRT_EXT 0x8795 +#define GL_OP_SUB_EXT 0x8796 +#define GL_OP_CROSS_PRODUCT_EXT 0x8797 +#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798 +#define GL_OP_MOV_EXT 0x8799 +#define GL_OUTPUT_VERTEX_EXT 0x879A +#define GL_OUTPUT_COLOR0_EXT 0x879B +#define GL_OUTPUT_COLOR1_EXT 0x879C +#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D +#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E +#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F +#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0 +#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1 +#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2 +#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3 +#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4 +#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5 +#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6 +#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7 +#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8 +#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9 +#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA +#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB +#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC +#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD +#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE +#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF +#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0 +#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1 +#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2 +#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3 +#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4 +#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5 +#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6 +#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7 +#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8 +#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9 +#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA +#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB +#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC +#define GL_OUTPUT_FOG_EXT 0x87BD +#define GL_SCALAR_EXT 0x87BE +#define GL_VECTOR_EXT 0x87BF +#define GL_MATRIX_EXT 0x87C0 +#define GL_VARIANT_EXT 0x87C1 +#define GL_INVARIANT_EXT 0x87C2 +#define GL_LOCAL_CONSTANT_EXT 0x87C3 +#define GL_LOCAL_EXT 0x87C4 +#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5 +#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6 +#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7 +#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8 +#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9 +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD +#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE +#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF +#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0 +#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1 +#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2 +#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3 +#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4 +#define GL_X_EXT 0x87D5 +#define GL_Y_EXT 0x87D6 +#define GL_Z_EXT 0x87D7 +#define GL_W_EXT 0x87D8 +#define GL_NEGATIVE_X_EXT 0x87D9 +#define GL_NEGATIVE_Y_EXT 0x87DA +#define GL_NEGATIVE_Z_EXT 0x87DB +#define GL_NEGATIVE_W_EXT 0x87DC +#define GL_ZERO_EXT 0x87DD +#define GL_ONE_EXT 0x87DE +#define GL_NEGATIVE_ONE_EXT 0x87DF +#define GL_NORMALIZED_RANGE_EXT 0x87E0 +#define GL_FULL_RANGE_EXT 0x87E1 +#define GL_CURRENT_VERTEX_EXT 0x87E2 +#define GL_MVP_MATRIX_EXT 0x87E3 +#define GL_VARIANT_VALUE_EXT 0x87E4 +#define GL_VARIANT_DATATYPE_EXT 0x87E5 +#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6 +#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7 +#define GL_VARIANT_ARRAY_EXT 0x87E8 +#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9 +#define GL_INVARIANT_VALUE_EXT 0x87EA +#define GL_INVARIANT_DATATYPE_EXT 0x87EB +#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC +#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_MAX_VERTEX_STREAMS_ATI 0x876B +#define GL_VERTEX_STREAM0_ATI 0x876C +#define GL_VERTEX_STREAM1_ATI 0x876D +#define GL_VERTEX_STREAM2_ATI 0x876E +#define GL_VERTEX_STREAM3_ATI 0x876F +#define GL_VERTEX_STREAM4_ATI 0x8770 +#define GL_VERTEX_STREAM5_ATI 0x8771 +#define GL_VERTEX_STREAM6_ATI 0x8772 +#define GL_VERTEX_STREAM7_ATI 0x8773 +#define GL_VERTEX_SOURCE_ATI 0x8774 +#endif + +#ifndef GL_ATI_element_array +#define GL_ELEMENT_ARRAY_ATI 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A +#endif + +#ifndef GL_SUN_mesh_array +#define GL_QUAD_MESH_SUN 0x8614 +#define GL_TRIANGLE_MESH_SUN 0x8615 +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SLICE_ACCUM_SUN 0x85CC +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_DEPTH_CLAMP_NV 0x864F +#endif + +#ifndef GL_NV_occlusion_query +#define GL_PIXEL_COUNTER_BITS_NV 0x8864 +#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865 +#define GL_PIXEL_COUNT_NV 0x8866 +#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867 +#endif + +#ifndef GL_NV_point_sprite +#define GL_POINT_SPRITE_NV 0x8861 +#define GL_COORD_REPLACE_NV 0x8862 +#define GL_POINT_SPRITE_R_MODE_NV 0x8863 +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850 +#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852 +#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853 +#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854 +#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856 +#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857 +#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858 +#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859 +#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A +#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B +#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C +#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D +#define GL_HILO8_NV 0x885E +#define GL_SIGNED_HILO8_NV 0x885F +#define GL_FORCE_BLUE_TO_ONE_NV 0x8860 +#endif + +#ifndef GL_NV_vertex_program1_1 +#endif + +#ifndef GL_EXT_shadow_funcs +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910 +#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911 +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2 +#endif + +#ifndef GL_APPLE_element_array +#define GL_ELEMENT_ARRAY_APPLE 0x8768 +#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769 +#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A +#endif + +#ifndef GL_APPLE_fence +#define GL_DRAW_PIXELS_APPLE 0x8A0A +#define GL_FENCE_APPLE 0x8A0B +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5 +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E +#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F +#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521 +#define GL_STORAGE_CACHED_APPLE 0x85BE +#define GL_STORAGE_SHARED_APPLE 0x85BF +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_YCBCR_422_APPLE 0x85B9 +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#endif + +#ifndef GL_S3_s3tc +#define GL_RGB_S3TC 0x83A0 +#define GL_RGB4_S3TC 0x83A1 +#define GL_RGBA_S3TC 0x83A2 +#define GL_RGBA4_S3TC 0x83A3 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_MAX_DRAW_BUFFERS_ATI 0x8824 +#define GL_DRAW_BUFFER0_ATI 0x8825 +#define GL_DRAW_BUFFER1_ATI 0x8826 +#define GL_DRAW_BUFFER2_ATI 0x8827 +#define GL_DRAW_BUFFER3_ATI 0x8828 +#define GL_DRAW_BUFFER4_ATI 0x8829 +#define GL_DRAW_BUFFER5_ATI 0x882A +#define GL_DRAW_BUFFER6_ATI 0x882B +#define GL_DRAW_BUFFER7_ATI 0x882C +#define GL_DRAW_BUFFER8_ATI 0x882D +#define GL_DRAW_BUFFER9_ATI 0x882E +#define GL_DRAW_BUFFER10_ATI 0x882F +#define GL_DRAW_BUFFER11_ATI 0x8830 +#define GL_DRAW_BUFFER12_ATI 0x8831 +#define GL_DRAW_BUFFER13_ATI 0x8832 +#define GL_DRAW_BUFFER14_ATI 0x8833 +#define GL_DRAW_BUFFER15_ATI 0x8834 +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_TYPE_RGBA_FLOAT_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_MODULATE_ADD_ATI 0x8744 +#define GL_MODULATE_SIGNED_ADD_ATI 0x8745 +#define GL_MODULATE_SUBTRACT_ATI 0x8746 +#endif + +#ifndef GL_ATI_texture_float +#define GL_RGBA_FLOAT32_ATI 0x8814 +#define GL_RGB_FLOAT32_ATI 0x8815 +#define GL_ALPHA_FLOAT32_ATI 0x8816 +#define GL_INTENSITY_FLOAT32_ATI 0x8817 +#define GL_LUMINANCE_FLOAT32_ATI 0x8818 +#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819 +#define GL_RGBA_FLOAT16_ATI 0x881A +#define GL_RGB_FLOAT16_ATI 0x881B +#define GL_ALPHA_FLOAT16_ATI 0x881C +#define GL_INTENSITY_FLOAT16_ATI 0x881D +#define GL_LUMINANCE_FLOAT16_ATI 0x881E +#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F +#endif + +#ifndef GL_NV_float_buffer +#define GL_FLOAT_R_NV 0x8880 +#define GL_FLOAT_RG_NV 0x8881 +#define GL_FLOAT_RGB_NV 0x8882 +#define GL_FLOAT_RGBA_NV 0x8883 +#define GL_FLOAT_R16_NV 0x8884 +#define GL_FLOAT_R32_NV 0x8885 +#define GL_FLOAT_RG16_NV 0x8886 +#define GL_FLOAT_RG32_NV 0x8887 +#define GL_FLOAT_RGB16_NV 0x8888 +#define GL_FLOAT_RGB32_NV 0x8889 +#define GL_FLOAT_RGBA16_NV 0x888A +#define GL_FLOAT_RGBA32_NV 0x888B +#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C +#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D +#define GL_FLOAT_RGBA_MODE_NV 0x888E +#endif + +#ifndef GL_NV_fragment_program +#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868 +#define GL_FRAGMENT_PROGRAM_NV 0x8870 +#define GL_MAX_TEXTURE_COORDS_NV 0x8871 +#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872 +#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873 +#define GL_PROGRAM_ERROR_STRING_NV 0x8874 +#endif + +#ifndef GL_NV_half_float +#define GL_HALF_FLOAT_NV 0x140B +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878 +#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879 +#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A +#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B +#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C +#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D +#endif + +#ifndef GL_NV_primitive_restart +#define GL_PRIMITIVE_RESTART_NV 0x8558 +#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559 +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F +#endif + +#ifndef GL_NV_vertex_program2 +#endif + +#ifndef GL_ATI_map_object_buffer +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_STENCIL_BACK_FUNC_ATI 0x8800 +#define GL_STENCIL_BACK_FAIL_ATI 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803 +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#endif + +#ifndef GL_OES_read_format +#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890 +#define GL_DEPTH_BOUNDS_EXT 0x8891 +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_MIRROR_CLAMP_EXT 0x8742 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION +#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D +#endif + +#ifndef GL_MESA_pack_invert +#define GL_PACK_INVERT_MESA 0x8758 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB +#define GL_YCBCR_MESA 0x8757 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF +#endif + +#ifndef GL_NV_fragment_program_option +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4 +#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5 +#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6 +#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7 +#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8 +#endif + +#ifndef GL_NV_vertex_program2_option +/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */ +/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */ +#endif + +#ifndef GL_NV_vertex_program3 +/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */ +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 +#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 +#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 +#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 +#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC +#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 +#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 +#define GL_FRAMEBUFFER_EXT 0x8D40 +#define GL_RENDERBUFFER_EXT 0x8D41 +#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 +#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 +#define GL_STENCIL_INDEX1_EXT 0x8D46 +#define GL_STENCIL_INDEX4_EXT 0x8D47 +#define GL_STENCIL_INDEX8_EXT 0x8D48 +#define GL_STENCIL_INDEX16_EXT 0x8D49 +#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 +#endif + +#ifndef GL_GREMEDY_string_marker +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_DEPTH_STENCIL_EXT 0x84F9 +#define GL_UNSIGNED_INT_24_8_EXT 0x84FA +#define GL_DEPTH24_STENCIL8_EXT 0x88F0 +#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_STENCIL_TAG_BITS_EXT 0x88F2 +#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3 +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB8_EXT 0x8C41 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_SLUMINANCE_ALPHA_EXT 0x8C44 +#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45 +#define GL_SLUMINANCE_EXT 0x8C46 +#define GL_SLUMINANCE8_EXT 0x8C47 +#define GL_COMPRESSED_SRGB_EXT 0x8C48 +#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49 +#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A +#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_READ_FRAMEBUFFER_EXT 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT +#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_TEXTURE_1D_STACK_MESAX 0x8759 +#define GL_TEXTURE_2D_STACK_MESAX 0x875A +#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B +#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C +#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D +#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E +#endif + +#ifndef GL_EXT_timer_query +#define GL_TIME_ELAPSED_EXT 0x88BF +#endif + +#ifndef GL_EXT_gpu_program_parameters +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12 +#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13 +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905 +#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906 +#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907 +#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908 +#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909 +#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5 +#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6 +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_GEOMETRY_PROGRAM_NV 0x8C26 +#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27 +#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28 +#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA +#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB +#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4 +#define GL_PROGRAM_POINT_SIZE_EXT 0x8642 +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */ +/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */ +/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */ +/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */ +#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD +#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE +#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +/* reuse GL_LINES_ADJACENCY_EXT */ +/* reuse GL_LINE_STRIP_ADJACENCY_EXT */ +/* reuse GL_TRIANGLES_ADJACENCY_EXT */ +/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */ +/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */ +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +/* reuse GL_PROGRAM_POINT_SIZE_EXT */ +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0 +#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1 +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3 +#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5 +#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6 +#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7 +#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8 +#define GL_INT_SAMPLER_1D_EXT 0x8DC9 +#define GL_INT_SAMPLER_2D_EXT 0x8DCA +#define GL_INT_SAMPLER_3D_EXT 0x8DCB +#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC +#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD +#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE +#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1 +#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5 +#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#endif + +#ifndef GL_EXT_draw_instanced +#endif + +#ifndef GL_EXT_packed_float +#define GL_R11F_G11F_B10F_EXT 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B +#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C +#endif + +#ifndef GL_EXT_texture_array +#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 +#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 +#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A +#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B +#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C +#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D +#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF +#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E +/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */ +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70 +#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71 +#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72 +#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_RGB9_E5_EXT 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E +#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_DEPTH_COMPONENT32F_NV 0x8DAB +#define GL_DEPTH32F_STENCIL8_NV 0x8DAC +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD +#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF +#endif + +#ifndef GL_NV_fragment_program4 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB +#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10 +#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11 +#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12 +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA +#endif + +#ifndef GL_NV_geometry_shader4 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0 +#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1 +#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2 +#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3 +#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4 +#endif + +#ifndef GL_EXT_draw_buffers2 +#endif + +#ifndef GL_NV_transform_feedback +#define GL_BACK_PRIMARY_COLOR_NV 0x8C77 +#define GL_BACK_SECONDARY_COLOR_NV 0x8C78 +#define GL_TEXTURE_COORD_NV 0x8C79 +#define GL_CLIP_DISTANCE_NV 0x8C7A +#define GL_VERTEX_ID_NV 0x8C7B +#define GL_PRIMITIVE_ID_NV 0x8C7C +#define GL_GENERIC_ATTRIB_NV 0x8C7D +#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80 +#define GL_ACTIVE_VARYINGS_NV 0x8C81 +#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85 +#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86 +#define GL_PRIMITIVES_GENERATED_NV 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88 +#define GL_RASTERIZER_DISCARD_NV 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B +#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C +#define GL_SEPARATE_ATTRIBS_NV 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2 +#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3 +#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4 +#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED +#define GL_UNIFORM_BUFFER_EXT 0x8DEE +#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF +#endif + +#ifndef GL_EXT_texture_integer +#define GL_RGBA32UI_EXT 0x8D70 +#define GL_RGB32UI_EXT 0x8D71 +#define GL_ALPHA32UI_EXT 0x8D72 +#define GL_INTENSITY32UI_EXT 0x8D73 +#define GL_LUMINANCE32UI_EXT 0x8D74 +#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75 +#define GL_RGBA16UI_EXT 0x8D76 +#define GL_RGB16UI_EXT 0x8D77 +#define GL_ALPHA16UI_EXT 0x8D78 +#define GL_INTENSITY16UI_EXT 0x8D79 +#define GL_LUMINANCE16UI_EXT 0x8D7A +#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B +#define GL_RGBA8UI_EXT 0x8D7C +#define GL_RGB8UI_EXT 0x8D7D +#define GL_ALPHA8UI_EXT 0x8D7E +#define GL_INTENSITY8UI_EXT 0x8D7F +#define GL_LUMINANCE8UI_EXT 0x8D80 +#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81 +#define GL_RGBA32I_EXT 0x8D82 +#define GL_RGB32I_EXT 0x8D83 +#define GL_ALPHA32I_EXT 0x8D84 +#define GL_INTENSITY32I_EXT 0x8D85 +#define GL_LUMINANCE32I_EXT 0x8D86 +#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87 +#define GL_RGBA16I_EXT 0x8D88 +#define GL_RGB16I_EXT 0x8D89 +#define GL_ALPHA16I_EXT 0x8D8A +#define GL_INTENSITY16I_EXT 0x8D8B +#define GL_LUMINANCE16I_EXT 0x8D8C +#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D +#define GL_RGBA8I_EXT 0x8D8E +#define GL_RGB8I_EXT 0x8D8F +#define GL_ALPHA8I_EXT 0x8D90 +#define GL_INTENSITY8I_EXT 0x8D91 +#define GL_LUMINANCE8I_EXT 0x8D92 +#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93 +#define GL_RED_INTEGER_EXT 0x8D94 +#define GL_GREEN_INTEGER_EXT 0x8D95 +#define GL_BLUE_INTEGER_EXT 0x8D96 +#define GL_ALPHA_INTEGER_EXT 0x8D97 +#define GL_RGB_INTEGER_EXT 0x8D98 +#define GL_RGBA_INTEGER_EXT 0x8D99 +#define GL_BGR_INTEGER_EXT 0x8D9A +#define GL_BGRA_INTEGER_EXT 0x8D9B +#define GL_LUMINANCE_INTEGER_EXT 0x8D9C +#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D +#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E +#endif + +#ifndef GL_GREMEDY_frame_terminator +#endif + +#ifndef GL_NV_conditional_render +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +#endif + +#ifndef GL_NV_present_video +#define GL_FRAME_NV 0x8E26 +#define GL_FIELDS_NV 0x8E27 +#define GL_CURRENT_TIME_NV 0x8E28 +#define GL_NUM_FILL_STREAMS_NV 0x8E29 +#define GL_PRESENT_TIME_NV 0x8E2A +#define GL_PRESENT_DURATION_NV 0x8E2B +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85 +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F +#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C +#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88 +#define GL_RASTERIZER_DISCARD_EXT 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76 +#endif + + +/*************************************************************/ + +#include +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +#endif + +#ifndef GL_VERSION_1_5 +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; +#endif + +#ifndef GL_ARB_vertex_buffer_object +/* GL types for handling large vertex buffer objects */ +typedef ptrdiff_t GLintptrARB; +typedef ptrdiff_t GLsizeiptrARB; +#endif + +#ifndef GL_ARB_shader_objects +/* GL types for handling shader object handles and program/shader text */ +typedef char GLcharARB; /* native character */ +typedef unsigned int VBoxGLhandleARB; /* shader object handle */ +# ifdef RT_OS_DARWIN +typedef void* GLhandleARB; /* shader object handle */ +# else +typedef unsigned int GLhandleARB; /* native shader object handle */ +# endif +#else +# error "GL_ARB_shader_objects should NOT be defined here!!" +#endif + +/* GL types for "half" precision (s10e5) float data in host memory */ +#ifndef GL_ARB_half_float_pixel +typedef unsigned short GLhalfARB; +#endif + +#ifndef GL_NV_half_float +typedef unsigned short GLhalfNV; +#endif + +#ifndef GLEXT_64_TYPES_DEFINED +/* This code block is duplicated in glxext.h, so must be protected */ +#define GLEXT_64_TYPES_DEFINED +/* Define int32_t, int64_t, and uint64_t types for UST/MSC */ +/* (as used in the GL_EXT_timer_query extension). */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#include +#elif defined(__sun__) || defined(__digital__) +#include +#if defined(__STDC__) +#if defined(__arch64__) || defined(_LP64) +typedef long int int64_t; +typedef unsigned long int uint64_t; +#else +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#endif /* __arch64__ */ +#endif /* __STDC__ */ +#elif defined( __VMS ) || defined(__sgi) +#include +#elif defined(__SCO__) || defined(__USLC__) +#include +#elif defined(__UNIXOS2__) || defined(__SOL64__) +typedef long int int32_t; +typedef long long int int64_t; +typedef unsigned long long int uint64_t; +#elif defined(_WIN32) && defined(__GNUC__) +#include +#elif defined(_WIN32) +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +#include /* Fallback option */ +#endif +#endif + +#ifndef GL_EXT_timer_query +typedef int64_t GLint64EXT; +typedef uint64_t GLuint64EXT; +#endif + +#ifndef GL_VERSION_1_2 +#define GL_VERSION_1_2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf); +GLAPI void APIENTRY glBlendEquation (GLenum); +GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei); +GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogram (GLenum); +GLAPI void APIENTRY glResetMinmax (GLenum); +GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target); +typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_VERSION_1_3 +#define GL_VERSION_1_3 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTexture (GLenum); +GLAPI void APIENTRY glClientActiveTexture (GLenum); +GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *); +GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *); +GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean); +GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_VERSION_1_4 +#define GL_VERSION_1_4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glFogCoordf (GLfloat); +GLAPI void APIENTRY glFogCoordfv (const GLfloat *); +GLAPI void APIENTRY glFogCoordd (GLdouble); +GLAPI void APIENTRY glFogCoorddv (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *); +GLAPI void APIENTRY glPointParameteri (GLenum, GLint); +GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *); +GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3iv (const GLint *); +GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos2i (GLint, GLint); +GLAPI void APIENTRY glWindowPos2iv (const GLint *); +GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2sv (const GLshort *); +GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dv (const GLdouble *); +GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fv (const GLfloat *); +GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3iv (const GLint *); +GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3sv (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v); +#endif + +#ifndef GL_VERSION_1_5 +#define GL_VERSION_1_5 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQuery (GLuint); +GLAPI void APIENTRY glBeginQuery (GLenum, GLuint); +GLAPI void APIENTRY glEndQuery (GLenum); +GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *); +GLAPI void APIENTRY glBindBuffer (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBuffer (GLuint); +GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum); +GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_VERSION_2_0 +#define GL_VERSION_2_0 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum); +GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *); +GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint); +GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint); +GLAPI void APIENTRY glAttachShader (GLuint, GLuint); +GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *); +GLAPI void APIENTRY glCompileShader (GLuint); +GLAPI GLuint APIENTRY glCreateProgram (void); +GLAPI GLuint APIENTRY glCreateShader (GLenum); +GLAPI void APIENTRY glDeleteProgram (GLuint); +GLAPI void APIENTRY glDeleteShader (GLuint); +GLAPI void APIENTRY glDetachShader (GLuint, GLuint); +GLAPI void APIENTRY glDisableVertexAttribArray (GLuint); +GLAPI void APIENTRY glEnableVertexAttribArray (GLuint); +GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *); +GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *); +GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *); +GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *); +GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgram (GLuint); +GLAPI GLboolean APIENTRY glIsShader (GLuint); +GLAPI void APIENTRY glLinkProgram (GLuint); +GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *); +GLAPI void APIENTRY glUseProgram (GLuint); +GLAPI void APIENTRY glUniform1f (GLint, GLfloat); +GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1i (GLint, GLint); +GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glValidateProgram (GLuint); +GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length); +typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_VERSION_2_1 +#define GL_VERSION_2_1 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformMatrix2x3fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3x2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix2x4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4x2fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3x4fv (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4x3fv (GLint, GLsizei, GLboolean, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif + +#ifndef GL_VERSION_3_0 +#define GL_VERSION_3_0 1 +#endif + +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveTextureARB (GLenum); +GLAPI void APIENTRY glClientActiveTextureARB (GLenum); +GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble); +GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat); +GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint); +GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort); +GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *); +GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *); +GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *); +GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *); +GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v); +#endif + +#ifndef GL_ARB_transpose_matrix +#define GL_ARB_transpose_matrix 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *); +GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *); +GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m); +typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m); +#endif + +#ifndef GL_ARB_multisample +#define GL_ARB_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert); +#endif + +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 +#endif + +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 +#endif + +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img); +#endif + +#ifndef GL_ARB_texture_border_clamp +#define GL_ARB_texture_border_clamp 1 +#endif + +#ifndef GL_ARB_point_parameters +#define GL_ARB_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_ARB_vertex_blend +#define GL_ARB_vertex_blend 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *); +GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *); +GLAPI void APIENTRY glWeightivARB (GLint, const GLint *); +GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *); +GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *); +GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexBlendARB (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights); +typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights); +typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights); +typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights); +typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights); +typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights); +typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights); +typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count); +#endif + +#ifndef GL_ARB_matrix_palette +#define GL_ARB_matrix_palette 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint); +GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *); +GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *); +GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *); +GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index); +typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices); +typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_ARB_texture_env_combine +#define GL_ARB_texture_env_combine 1 +#endif + +#ifndef GL_ARB_texture_env_crossbar +#define GL_ARB_texture_env_crossbar 1 +#endif + +#ifndef GL_ARB_texture_env_dot3 +#define GL_ARB_texture_env_dot3 1 +#endif + +#ifndef GL_ARB_texture_mirrored_repeat +#define GL_ARB_texture_mirrored_repeat 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_ARB_depth_texture +#define GL_ARB_depth_texture 1 +#endif + +#ifndef GL_ARB_shadow +#define GL_ARB_shadow 1 +#endif + +#ifndef GL_ARB_shadow_ambient +#define GL_ARB_shadow_ambient 1 +#endif + +#ifndef GL_ARB_window_pos +#define GL_ARB_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svARB (const GLshort *); +GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivARB (const GLint *); +GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svARB (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v); +#endif + +#ifndef GL_ARB_vertex_program +#define GL_ARB_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *); +GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint); +GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *); +GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *); +GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *); +GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramARB (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index); +typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string); +typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program); +#endif + +#ifndef GL_ARB_fragment_program +#define GL_ARB_fragment_program 1 +/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */ +#endif + +#ifndef GL_ARB_vertex_buffer_object +#define GL_ARB_vertex_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint); +GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsBufferARB (GLuint); +GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum); +GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *); +GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *); +GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum); +GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum); +GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer); +typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers); +typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers); +typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage); +typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data); +typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data); +typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access); +typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params); +#endif + +#ifndef GL_ARB_occlusion_query +#define GL_ARB_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsQueryARB (GLuint); +GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint); +GLAPI void APIENTRY glEndQueryARB (GLenum); +GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target); +typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_ARB_shader_objects +#define GL_ARB_shader_objects 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteObjectARB (VBoxGLhandleARB); +GLAPI VBoxGLhandleARB APIENTRY glGetHandleARB (GLenum); +GLAPI void APIENTRY glDetachObjectARB (VBoxGLhandleARB, VBoxGLhandleARB); +GLAPI VBoxGLhandleARB APIENTRY glCreateShaderObjectARB (GLenum); +GLAPI void APIENTRY glShaderSourceARB (VBoxGLhandleARB, GLsizei, const GLcharARB* *, const GLint *); +GLAPI void APIENTRY glCompileShaderARB (VBoxGLhandleARB); +GLAPI VBoxGLhandleARB APIENTRY glCreateProgramObjectARB (void); +GLAPI void APIENTRY glAttachObjectARB (VBoxGLhandleARB, VBoxGLhandleARB); +GLAPI void APIENTRY glLinkProgramARB (VBoxGLhandleARB); +GLAPI void APIENTRY glUseProgramObjectARB (VBoxGLhandleARB); +GLAPI void APIENTRY glValidateProgramARB (VBoxGLhandleARB); +GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat); +GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glUniform1iARB (GLint, GLint); +GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint); +GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *); +GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *); +GLAPI void APIENTRY glGetObjectParameterfvARB (VBoxGLhandleARB, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectParameterivARB (VBoxGLhandleARB, GLenum, GLint *); +GLAPI void APIENTRY glGetInfoLogARB (VBoxGLhandleARB, GLsizei, GLsizei *, GLcharARB *); +GLAPI void APIENTRY glGetAttachedObjectsARB (VBoxGLhandleARB, GLsizei, GLsizei *, VBoxGLhandleARB *); +GLAPI GLint APIENTRY glGetUniformLocationARB (VBoxGLhandleARB, const GLcharARB *); +GLAPI void APIENTRY glGetActiveUniformARB (VBoxGLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI void APIENTRY glGetUniformfvARB (VBoxGLhandleARB, GLint, GLfloat *); +GLAPI void APIENTRY glGetUniformivARB (VBoxGLhandleARB, GLint, GLint *); +GLAPI void APIENTRY glGetShaderSourceARB (VBoxGLhandleARB, GLsizei, GLsizei *, GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (VBoxGLhandleARB obj); +typedef VBoxGLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (VBoxGLhandleARB containerObj, VBoxGLhandleARB attachedObj); +typedef VBoxGLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType); +typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (VBoxGLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length); +typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (VBoxGLhandleARB shaderObj); +typedef VBoxGLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void); +typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (VBoxGLhandleARB containerObj, VBoxGLhandleARB obj); +typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (VBoxGLhandleARB programObj); +typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (VBoxGLhandleARB programObj); +typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (VBoxGLhandleARB programObj); +typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0); +typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0); +typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1); +typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (VBoxGLhandleARB obj, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (VBoxGLhandleARB obj, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (VBoxGLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog); +typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (VBoxGLhandleARB containerObj, GLsizei maxCount, GLsizei *count, VBoxGLhandleARB *obj); +typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (VBoxGLhandleARB programObj, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (VBoxGLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (VBoxGLhandleARB programObj, GLint location, GLfloat *params); +typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (VBoxGLhandleARB programObj, GLint location, GLint *params); +typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (VBoxGLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +#endif + +#ifndef GL_ARB_vertex_shader +#define GL_ARB_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindAttribLocationARB (VBoxGLhandleARB, GLuint, const GLcharARB *); +GLAPI void APIENTRY glGetActiveAttribARB (VBoxGLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *); +GLAPI GLint APIENTRY glGetAttribLocationARB (VBoxGLhandleARB, const GLcharARB *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (VBoxGLhandleARB programObj, GLuint index, const GLcharARB *name); +typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (VBoxGLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name); +typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (VBoxGLhandleARB programObj, const GLcharARB *name); +#endif + +#ifndef GL_ARB_fragment_shader +#define GL_ARB_fragment_shader 1 +#endif + +#ifndef GL_ARB_shading_language_100 +#define GL_ARB_shading_language_100 1 +#endif + +#ifndef GL_ARB_texture_non_power_of_two +#define GL_ARB_texture_non_power_of_two 1 +#endif + +#ifndef GL_ARB_point_sprite +#define GL_ARB_point_sprite 1 +#endif + +#ifndef GL_ARB_fragment_program_shadow +#define GL_ARB_fragment_program_shadow 1 +#endif + +#ifndef GL_ARB_draw_buffers +#define GL_ARB_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ARB_texture_rectangle +#define GL_ARB_texture_rectangle 1 +#endif + +#ifndef GL_ARB_color_buffer_float +#define GL_ARB_color_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glClampColorARB (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp); +#endif + +#ifndef GL_ARB_half_float_pixel +#define GL_ARB_half_float_pixel 1 +#endif + +#ifndef GL_ARB_texture_float +#define GL_ARB_texture_float 1 +#endif + +#ifndef GL_ARB_pixel_buffer_object +#define GL_ARB_pixel_buffer_object 1 +#endif + +#ifndef GL_ARB_depth_buffer_float +#define GL_ARB_depth_buffer_float 1 +#endif + +#ifndef GL_ARB_draw_instanced +#define GL_ARB_draw_instanced 1 +#endif + +#ifndef GL_ARB_framebuffer_object +#define GL_ARB_framebuffer_object 1 +#endif + +#ifndef GL_ARB_framebuffer_sRGB +#define GL_ARB_framebuffer_sRGB 1 +#endif + +#ifndef GL_ARB_geometry_shader4 +#define GL_ARB_geometry_shader4 1 +#endif + +#ifndef GL_ARB_half_float_vertex +#define GL_ARB_half_float_vertex 1 +#endif + +#ifndef GL_ARB_instanced_arrays +#define GL_ARB_instanced_arrays 1 +#endif + +#ifndef GL_ARB_map_buffer_range +#define GL_ARB_map_buffer_range 1 +#endif + +#ifndef GL_ARB_texture_buffer_object +#define GL_ARB_texture_buffer_object 1 +#endif + +#ifndef GL_ARB_texture_compression_rgtc +#define GL_ARB_texture_compression_rgtc 1 +#endif + +#ifndef GL_ARB_texture_rg +#define GL_ARB_texture_rg 1 +#endif + +#ifndef GL_ARB_vertex_array_object +#define GL_ARB_vertex_array_object 1 +#endif + +#ifndef GL_EXT_abgr +#define GL_EXT_abgr 1 +#endif + +#ifndef GL_EXT_blend_color +#define GL_EXT_blend_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +#endif + +#ifndef GL_EXT_polygon_offset +#define GL_EXT_polygon_offset 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias); +#endif + +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 +#endif + +#ifndef GL_EXT_texture3D +#define GL_EXT_texture3D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGIS_texture_filter4 +#define GL_SGIS_texture_filter4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights); +typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); +#endif + +#ifndef GL_EXT_subtexture +#define GL_EXT_subtexture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_EXT_copy_texture +#define GL_EXT_copy_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); +GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_histogram +#define GL_EXT_histogram 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean); +GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean); +GLAPI void APIENTRY glResetHistogramEXT (GLenum); +GLAPI void APIENTRY glResetMinmaxEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink); +typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target); +#endif + +#ifndef GL_EXT_convolution +#define GL_EXT_convolution 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *); +GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params); +typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span); +typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); +#endif + +#ifndef GL_SGI_color_matrix +#define GL_SGI_color_matrix 1 +#endif + +#ifndef GL_SGI_color_table +#define GL_SGI_color_table 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei); +GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); +typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params); +#endif + +#ifndef GL_SGIX_pixel_texture +#define GL_SGIX_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenSGIX (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); +#endif + +#ifndef GL_SGIS_pixel_texture +#define GL_SGIS_pixel_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint); +GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *); +GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *); +GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIS_texture4D +#define GL_SGIS_texture4D 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels); +typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels); +#endif + +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 +#endif + +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 +#endif + +#ifndef GL_EXT_texture_object +#define GL_EXT_texture_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint); +GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture); +typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures); +typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures); +typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture); +typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities); +#endif + +#ifndef GL_SGIS_detail_texture +#define GL_SGIS_detail_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_SGIS_sharpen_texture +#define GL_SGIS_sharpen_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points); +#endif + +#ifndef GL_EXT_packed_pixels +#define GL_EXT_packed_pixels 1 +#endif + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 +#endif + +#ifndef GL_SGIS_multisample +#define GL_SGIS_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternSGIS (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); +#endif + +#ifndef GL_EXT_rescale_normal +#define GL_EXT_rescale_normal 1 +#endif + +#ifndef GL_EXT_vertex_array +#define GL_EXT_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glArrayElementEXT (GLint); +GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *); +GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *); +GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i); +typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer); +typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params); +typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 +#endif + +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 +#endif + +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 +#endif + +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 +#endif + +#ifndef GL_SGIS_texture_edge_clamp +#define GL_SGIS_texture_edge_clamp 1 +#endif + +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 +#endif + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_blend_subtract +#define GL_EXT_blend_subtract 1 +#endif + +#ifndef GL_EXT_blend_logic_op +#define GL_EXT_blend_logic_op 1 +#endif + +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 +#endif + +#ifndef GL_SGIX_pixel_tiles +#define GL_SGIX_pixel_tiles 1 +#endif + +#ifndef GL_SGIX_texture_select +#define GL_SGIX_texture_select 1 +#endif + +#ifndef GL_SGIX_sprite +#define GL_SGIX_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint); +GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_texture_multi_buffer +#define GL_SGIX_texture_multi_buffer 1 +#endif + +#ifndef GL_EXT_point_parameters +#define GL_EXT_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIS_point_parameters +#define GL_SGIS_point_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat); +GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_SGIX_instruments +#define GL_SGIX_instruments 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLint APIENTRY glGetInstrumentsSGIX (void); +GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *); +GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *); +GLAPI void APIENTRY glReadInstrumentsSGIX (GLint); +GLAPI void APIENTRY glStartInstrumentsSGIX (void); +GLAPI void APIENTRY glStopInstrumentsSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer); +typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p); +typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); +typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void); +typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); +#endif + +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 +#endif + +#ifndef GL_SGIX_framezoom +#define GL_SGIX_framezoom 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameZoomSGIX (GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor); +#endif + +#ifndef GL_SGIX_tag_sample_buffer +#define GL_SGIX_tag_sample_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTagSampleBufferSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_polynomial_ffd +#define GL_SGIX_polynomial_ffd 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *); +GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *); +GLAPI void APIENTRY glDeformSGIX (GLbitfield); +GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points); +typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points); +typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask); +typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask); +#endif + +#ifndef GL_SGIX_reference_plane +#define GL_SGIX_reference_plane 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation); +#endif + +#ifndef GL_SGIX_flush_raster +#define GL_SGIX_flush_raster 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushRasterSGIX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void); +#endif + +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 +#endif + +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *); +GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points); +typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points); +#endif + +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 +#endif + +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint); +GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 +#endif + +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 +#endif + +#ifndef GL_EXT_color_subtable +#define GL_EXT_color_subtable 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); +#endif + +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 +#endif + +#ifndef GL_PGI_misc_hints +#define GL_PGI_misc_hints 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glHintPGI (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode); +#endif + +#ifndef GL_EXT_paletted_texture +#define GL_EXT_paletted_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *); +GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *); +GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_EXT_clip_volume_hint +#define GL_EXT_clip_volume_hint 1 +#endif + +#ifndef GL_SGIX_list_priority +#define GL_SGIX_list_priority 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat); +GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *); +GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint); +GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params); +#endif + +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 +#endif + +#ifndef GL_SGIX_calligraphic_fragment +#define GL_SGIX_calligraphic_fragment 1 +#endif + +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 +#endif + +#ifndef GL_SGIX_shadow_ambient +#define GL_SGIX_shadow_ambient 1 +#endif + +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 +#endif + +#ifndef GL_EXT_index_material +#define GL_EXT_index_material 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_EXT_index_func +#define GL_EXT_index_func 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref); +#endif + +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 +#endif + +#ifndef GL_EXT_compiled_vertex_array +#define GL_EXT_compiled_vertex_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei); +GLAPI void APIENTRY glUnlockArraysEXT (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void); +#endif + +#ifndef GL_EXT_cull_vertex +#define GL_EXT_cull_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *); +GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params); +#endif + +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 +#endif + +#ifndef GL_SGIX_fragment_lighting +#define GL_SGIX_fragment_lighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum); +GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat); +GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint); +GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *); +GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 +#endif + +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 +#endif + +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); +#endif + +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 +#endif + +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 +#endif + +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glApplyTextureEXT (GLenum); +GLAPI void APIENTRY glTextureLightEXT (GLenum); +GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); +#endif + +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 +#endif + +#ifndef GL_EXT_bgra +#define GL_EXT_bgra 1 +#endif + +#ifndef GL_SGIX_async +#define GL_SGIX_async 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint); +GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *); +GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *); +GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei); +GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei); +GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker); +typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp); +typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp); +typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range); +typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range); +typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker); +#endif + +#ifndef GL_SGIX_async_pixel +#define GL_SGIX_async_pixel 1 +#endif + +#ifndef GL_SGIX_async_histogram +#define GL_SGIX_async_histogram 1 +#endif + +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *); +GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *); +GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer); +#endif + +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 +#endif + +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint); +GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat); +GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params); +#endif + +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 +#endif + +#ifndef GL_EXT_shared_texture_palette +#define GL_EXT_shared_texture_palette 1 +#endif + +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 +#endif + +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *); +GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *); +GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *); +GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *); +GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *); +GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *); +GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *); +GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort); +GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *); +GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureNormalEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode); +#endif + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_fog_coord +#define GL_EXT_fog_coord 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFogCoordfEXT (GLfloat); +GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *); +GLAPI void APIENTRY glFogCoorddEXT (GLdouble); +GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *); +GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord); +typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord); +typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord); +typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 +#endif + +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *); +GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *); +GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *); +GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glTangent3ivEXT (const GLint *); +GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glTangent3svEXT (const GLshort *); +GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *); +GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *); +GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *); +GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint); +GLAPI void APIENTRY glBinormal3ivEXT (const GLint *); +GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glBinormal3svEXT (const GLshort *); +GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz); +typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz); +typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz); +typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz); +typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz); +typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz); +typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v); +typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz); +typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz); +typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz); +typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz); +typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_EXT_texture_env_combine +#define GL_EXT_texture_env_combine 1 +#endif + +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 +#endif + +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 +#endif + +#ifndef GL_SGIX_fog_scale +#define GL_SGIX_fog_scale 1 +#endif + +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFinishTextureSUNX (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void); +#endif + +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat); +GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor); +typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor); +#endif + +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint); +GLAPI void APIENTRY glReplacementCodeusSUN (GLushort); +GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte); +GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *); +GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *); +GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *); +GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer); +#endif + +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +#endif + +#ifndef GL_EXT_blend_func_separate +#define GL_EXT_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_blend_func_separate +#define GL_INGR_blend_func_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +#endif + +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 +#endif + +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 +#endif + +#ifndef GL_EXT_stencil_wrap +#define GL_EXT_stencil_wrap 1 +#endif + +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 +#endif + +#ifndef GL_NV_texgen_reflection +#define GL_NV_texgen_reflection 1 +#endif + +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 +#endif + +#ifndef GL_EXT_texture_env_add +#define GL_EXT_texture_env_add 1 +#endif + +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 +#endif + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#endif + +#ifndef GL_EXT_vertex_weighting +#define GL_EXT_vertex_weighting 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexWeightfEXT (GLfloat); +GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *); +GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer); +#endif + +#ifndef GL_NV_light_max_exponent +#define GL_NV_light_max_exponent 1 +#endif + +#ifndef GL_NV_vertex_array_range +#define GL_NV_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFlushVertexArrayRangeNV (void); +GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer); +#endif + +#ifndef GL_NV_register_combiners +#define GL_NV_register_combiners 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *); +GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat); +GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *); +GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); +typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params); +#endif + +#ifndef GL_NV_fog_distance +#define GL_NV_fog_distance 1 +#endif + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 +#endif + +#ifndef GL_NV_blend_square +#define GL_NV_blend_square 1 +#endif + +#ifndef GL_NV_texture_env_combine4 +#define GL_NV_texture_env_combine4 1 +#endif + +#ifndef GL_MESA_resize_buffers +#define GL_MESA_resize_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glResizeBuffersMESA (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void); +#endif + +#ifndef GL_MESA_window_pos +#define GL_MESA_window_pos 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint); +GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort); +GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *); +GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *); +GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *); +GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *); +GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y); +typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v); +typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v); +#endif + +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 +#endif + +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint); +GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride); +#endif + +#ifndef GL_IBM_vertex_array_lists +#define GL_IBM_vertex_array_lists 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint); +GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride); +#endif + +#ifndef GL_SGIX_subsample +#define GL_SGIX_subsample 1 +#endif + +#ifndef GL_SGIX_ycrcba +#define GL_SGIX_ycrcba 1 +#endif + +#ifndef GL_SGIX_ycrcb_subsample +#define GL_SGIX_ycrcb_subsample 1 +#endif + +#ifndef GL_SGIX_depth_pass_instrument +#define GL_SGIX_depth_pass_instrument 1 +#endif + +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 +#endif + +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 +#endif + +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTbufferMask3DFX (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask); +#endif + +#ifndef GL_EXT_multisample +#define GL_EXT_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean); +GLAPI void APIENTRY glSamplePatternEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); +#endif + +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 +#endif + +#ifndef GL_SGIX_convolution_accuracy +#define GL_SGIX_convolution_accuracy 1 +#endif + +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 +#endif + +#ifndef GL_SGIS_point_line_texgen +#define GL_SGIS_point_line_texgen 1 +#endif + +#ifndef GL_SGIS_texture_color_mask +#define GL_SGIS_texture_color_mask 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +#endif + +#ifndef GL_SGIX_igloo_interface +#define GL_SGIX_igloo_interface 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params); +#endif + +#ifndef GL_EXT_texture_env_dot3 +#define GL_EXT_texture_env_dot3 1 +#endif + +#ifndef GL_ATI_texture_mirror_once +#define GL_ATI_texture_mirror_once 1 +#endif + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsFenceNV (GLuint); +GLAPI GLboolean APIENTRY glTestFenceNV (GLuint); +GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFinishFenceNV (GLuint); +GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#endif + +#ifndef GL_NV_evaluators +#define GL_NV_evaluators 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *); +GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *); +GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points); +typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode); +#endif + +#ifndef GL_NV_packed_depth_stencil +#define GL_NV_packed_depth_stencil 1 +#endif + +#ifndef GL_NV_register_combiners2 +#define GL_NV_register_combiners2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *); +GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params); +typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params); +#endif + +#ifndef GL_NV_texture_compression_vtc +#define GL_NV_texture_compression_vtc 1 +#endif + +#ifndef GL_NV_texture_rectangle +#define GL_NV_texture_rectangle 1 +#endif + +#ifndef GL_NV_texture_shader +#define GL_NV_texture_shader 1 +#endif + +#ifndef GL_NV_texture_shader2 +#define GL_NV_texture_shader2 1 +#endif + +#ifndef GL_NV_vertex_array_range2 +#define GL_NV_vertex_array_range2 1 +#endif + +#ifndef GL_NV_vertex_program +#define GL_NV_vertex_program 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *); +GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint); +GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *); +GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *); +GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *); +GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *); +GLAPI GLboolean APIENTRY glIsProgramNV (GLuint); +GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *); +GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *); +GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *); +GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *); +GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *); +GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum); +GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble); +GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat); +GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort); +GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *); +GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *); +GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte); +GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *); +GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *); +GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences); +typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id); +typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params); +typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program); +typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer); +typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v); +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v); +typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs); +typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform); +typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v); +#endif + +#ifndef GL_SGIX_texture_coordinate_clamp +#define GL_SGIX_texture_coordinate_clamp 1 +#endif + +#ifndef GL_SGIX_scalebias_hint +#define GL_SGIX_scalebias_hint 1 +#endif + +#ifndef GL_OML_interlace +#define GL_OML_interlace 1 +#endif + +#ifndef GL_OML_subsample +#define GL_OML_subsample 1 +#endif + +#ifndef GL_OML_resample +#define GL_OML_resample 1 +#endif + +#ifndef GL_NV_copy_depth_to_color +#define GL_NV_copy_depth_to_color 1 +#endif + +#ifndef GL_ATI_envmap_bumpmap +#define GL_ATI_envmap_bumpmap 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *); +GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *); +GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param); +typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param); +typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param); +#endif + +#ifndef GL_ATI_fragment_shader +#define GL_ATI_fragment_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint); +GLAPI void APIENTRY glBindFragmentShaderATI (GLuint); +GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint); +GLAPI void APIENTRY glBeginFragmentShaderATI (void); +GLAPI void APIENTRY glEndFragmentShaderATI (void); +GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum); +GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range); +typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void); +typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle); +typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); +typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); +typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value); +#endif + +#ifndef GL_ATI_pn_triangles +#define GL_ATI_pn_triangles 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint); +GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_vertex_array_object +#define GL_ATI_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum); +GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint); +GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum); +GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glFreeObjectBufferATI (GLuint); +GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *); +GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage); +typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params); +#endif + +#ifndef GL_EXT_vertex_shader +#define GL_EXT_vertex_shader 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginVertexShaderEXT (void); +GLAPI void APIENTRY glEndVertexShaderEXT (void); +GLAPI void APIENTRY glBindVertexShaderEXT (GLuint); +GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint); +GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint); +GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint); +GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *); +GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *); +GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *); +GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *); +GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint); +GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint); +GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum); +GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum); +GLAPI GLuint APIENTRY glBindParameterEXT (GLenum); +GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum); +GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *); +GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *); +GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void); +typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range); +typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1); +typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2); +typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3); +typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW); +typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num); +typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components); +typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr); +typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr); +typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr); +typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr); +typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr); +typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr); +typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr); +typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr); +typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr); +typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr); +typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id); +typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value); +typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value); +typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap); +typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data); +typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data); +typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data); +#endif + +#ifndef GL_ATI_vertex_streams +#define GL_ATI_vertex_streams 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort); +GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint); +GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat); +GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble); +GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint); +GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte); +GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *); +GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort); +GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *); +GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint); +GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *); +GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *); +GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *); +GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum); +GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint); +GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x); +typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y); +typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz); +typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords); +typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param); +#endif + +#ifndef GL_ATI_element_array +#define GL_ATI_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count); +#endif + +#ifndef GL_SUN_mesh_array +#define GL_SUN_mesh_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width); +#endif + +#ifndef GL_SUN_slice_accum +#define GL_SUN_slice_accum 1 +#endif + +#ifndef GL_NV_multisample_filter_hint +#define GL_NV_multisample_filter_hint 1 +#endif + +#ifndef GL_NV_depth_clamp +#define GL_NV_depth_clamp 1 +#endif + +#ifndef GL_NV_occlusion_query +#define GL_NV_occlusion_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *); +GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint); +GLAPI void APIENTRY glEndOcclusionQueryNV (void); +GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids); +typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id); +typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params); +#endif + +#ifndef GL_NV_point_sprite +#define GL_NV_point_sprite 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint); +GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params); +#endif + +#ifndef GL_NV_texture_shader3 +#define GL_NV_texture_shader3 1 +#endif + +#ifndef GL_NV_vertex_program1_1 +#define GL_NV_vertex_program1_1 1 +#endif + +#ifndef GL_EXT_shadow_funcs +#define GL_EXT_shadow_funcs 1 +#endif + +#ifndef GL_EXT_stencil_two_side +#define GL_EXT_stencil_two_side 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face); +#endif + +#ifndef GL_ATI_text_fragment_shader +#define GL_ATI_text_fragment_shader 1 +#endif + +#ifndef GL_APPLE_client_storage +#define GL_APPLE_client_storage 1 +#endif + +#ifndef GL_APPLE_element_array +#define GL_APPLE_element_array 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *); +GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei); +GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei); +GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei); +GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count); +typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount); +#endif + +#ifndef GL_APPLE_fence +#define GL_APPLE_fence 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *); +GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glSetFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint); +GLAPI void APIENTRY glFinishFenceAPPLE (GLuint); +GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint); +GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences); +typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences); +typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence); +typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence); +typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name); +typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name); +#endif + +#ifndef GL_APPLE_vertex_array_object +#define GL_APPLE_vertex_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint); +GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, GLuint *); +GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array); +typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays); +typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array); +#endif + +#ifndef GL_APPLE_vertex_array_range +#define GL_APPLE_vertex_array_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *); +GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param); +#endif + +#ifndef GL_APPLE_ycbcr_422 +#define GL_APPLE_ycbcr_422 1 +#endif + +#ifndef GL_S3_s3tc +#define GL_S3_s3tc 1 +#endif + +#ifndef GL_ATI_draw_buffers +#define GL_ATI_draw_buffers 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs); +#endif + +#ifndef GL_ATI_pixel_format_float +#define GL_ATI_pixel_format_float 1 +/* This is really a WGL extension, but defines some associated GL enums. + * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string. + */ +#endif + +#ifndef GL_ATI_texture_env_combine3 +#define GL_ATI_texture_env_combine3 1 +#endif + +#ifndef GL_ATI_texture_float +#define GL_ATI_texture_float 1 +#endif + +#ifndef GL_NV_float_buffer +#define GL_NV_float_buffer 1 +#endif + +#ifndef GL_NV_fragment_program +#define GL_NV_fragment_program 1 +/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */ +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat); +GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble); +GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *); +GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *); +GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *); +GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v); +typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params); +typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params); +#endif + +#ifndef GL_NV_half_float +#define GL_NV_half_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV); +GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *); +GLAPI void APIENTRY glFogCoordhNV (GLhalfNV); +GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *); +GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV); +GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV); +GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *); +GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz); +typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha); +typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s); +typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s); +typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t); +typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r); +typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q); +typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog); +typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue); +typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight); +typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x); +typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y); +typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z); +typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w); +typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v); +#endif + +#ifndef GL_NV_pixel_data_range +#define GL_NV_pixel_data_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *); +GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer); +typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target); +#endif + +#ifndef GL_NV_primitive_restart +#define GL_NV_primitive_restart 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glPrimitiveRestartNV (void); +GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void); +typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index); +#endif + +#ifndef GL_NV_texture_expand_normal +#define GL_NV_texture_expand_normal 1 +#endif + +#ifndef GL_NV_vertex_program2 +#define GL_NV_vertex_program2 1 +#endif + +#ifndef GL_ATI_map_object_buffer +#define GL_ATI_map_object_buffer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint); +GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer); +typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer); +#endif + +#ifndef GL_ATI_separate_stencil +#define GL_ATI_separate_stencil 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum); +GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask); +#endif + +#ifndef GL_ATI_vertex_attrib_array_object +#define GL_ATI_vertex_attrib_array_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint); +GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *); +GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params); +#endif + +#ifndef GL_OES_read_format +#define GL_OES_read_format 1 +#endif + +#ifndef GL_EXT_depth_bounds_test +#define GL_EXT_depth_bounds_test 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax); +#endif + +#ifndef GL_EXT_texture_mirror_clamp +#define GL_EXT_texture_mirror_clamp 1 +#endif + +#ifndef GL_EXT_blend_equation_separate +#define GL_EXT_blend_equation_separate 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha); +#endif + +#ifndef GL_MESA_pack_invert +#define GL_MESA_pack_invert 1 +#endif + +#ifndef GL_MESA_ycbcr_texture +#define GL_MESA_ycbcr_texture 1 +#endif + +#ifndef GL_EXT_pixel_buffer_object +#define GL_EXT_pixel_buffer_object 1 +#endif + +#ifndef GL_NV_fragment_program_option +#define GL_NV_fragment_program_option 1 +#endif + +#ifndef GL_NV_fragment_program2 +#define GL_NV_fragment_program2 1 +#endif + +#ifndef GL_NV_vertex_program2_option +#define GL_NV_vertex_program2_option 1 +#endif + +#ifndef GL_NV_vertex_program3 +#define GL_NV_vertex_program3 1 +#endif + +#ifndef GL_EXT_framebuffer_object +#define GL_EXT_framebuffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint); +GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *); +GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei); +GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *); +GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint); +GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint); +GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *); +GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *); +GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum); +GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint); +GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGenerateMipmapEXT (GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer); +typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer); +typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer); +typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers); +typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target); +#endif + +#ifndef GL_GREMEDY_string_marker +#define GL_GREMEDY_string_marker 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string); +#endif + +#ifndef GL_EXT_packed_depth_stencil +#define GL_EXT_packed_depth_stencil 1 +#endif + +#ifndef GL_EXT_stencil_clear_tag +#define GL_EXT_stencil_clear_tag 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glStencilClearTagEXT (GLsizei, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag); +#endif + +#ifndef GL_EXT_texture_sRGB +#define GL_EXT_texture_sRGB 1 +#endif + +#ifndef GL_EXT_framebuffer_blit +#define GL_EXT_framebuffer_blit 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBlitFramebufferEXT (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif + +#ifndef GL_EXT_framebuffer_multisample +#define GL_EXT_framebuffer_multisample 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_MESAX_texture_stack +#define GL_MESAX_texture_stack 1 +#endif + +#ifndef GL_EXT_timer_query +#define GL_EXT_timer_query 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint, GLenum, GLint64EXT *); +GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint, GLenum, GLuint64EXT *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params); +typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params); +#endif + +#ifndef GL_EXT_gpu_program_parameters +#define GL_EXT_gpu_program_parameters 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params); +#endif + +#ifndef GL_APPLE_flush_buffer_range +#define GL_APPLE_flush_buffer_range 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum, GLenum, GLint); +GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum, GLintptr, GLsizeiptr); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param); +typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size); +#endif + +#ifndef GL_NV_gpu_program4 +#define GL_NV_gpu_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum, GLuint, const GLint *); +GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum, GLuint, const GLuint *); +GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); +GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum, GLuint, const GLint *); +GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum, GLuint, const GLuint *); +GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *); +GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum, GLuint, GLint *); +GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum, GLuint, GLuint *); +GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum, GLuint, GLint *); +GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum, GLuint, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params); +typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params); +typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params); +#endif + +#ifndef GL_NV_geometry_program4 +#define GL_NV_geometry_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramVertexLimitNV (GLenum, GLint); +GLAPI void APIENTRY glFramebufferTextureEXT (GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum, GLenum, GLuint, GLint, GLint); +GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum, GLenum, GLuint, GLint, GLenum); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face); +#endif + +#ifndef GL_EXT_geometry_shader4 +#define GL_EXT_geometry_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramParameteriEXT (GLuint, GLenum, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +#endif + +#ifndef GL_NV_vertex_program4 +#define GL_NV_vertex_program4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint, GLint); +GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint, GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint, const GLint *); +GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint, const GLuint *); +GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint, const GLbyte *); +GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint, const GLshort *); +GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint, const GLubyte *); +GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint, const GLushort *); +GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint, GLint, GLenum, GLsizei, const GLvoid *); +GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint, GLenum, GLint *); +GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint, GLenum, GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v); +typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params); +#endif + +#ifndef GL_EXT_gpu_shader4 +#define GL_EXT_gpu_shader4 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glGetUniformuivEXT (GLuint, GLint, GLuint *); +GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint, GLuint, const GLchar *); +GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint, const GLchar *); +GLAPI void APIENTRY glUniform1uiEXT (GLint, GLuint); +GLAPI void APIENTRY glUniform2uiEXT (GLint, GLuint, GLuint); +GLAPI void APIENTRY glUniform3uiEXT (GLint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glUniform4uiEXT (GLint, GLuint, GLuint, GLuint, GLuint); +GLAPI void APIENTRY glUniform1uivEXT (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform2uivEXT (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform3uivEXT (GLint, GLsizei, const GLuint *); +GLAPI void APIENTRY glUniform4uivEXT (GLint, GLsizei, const GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params); +typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0); +typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value); +#endif + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum, GLint, GLsizei, GLsizei); +GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount); +#endif + +#ifndef GL_EXT_packed_float +#define GL_EXT_packed_float 1 +#endif + +#ifndef GL_EXT_texture_array +#define GL_EXT_texture_array 1 +#endif + +#ifndef GL_EXT_texture_buffer_object +#define GL_EXT_texture_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexBufferEXT (GLenum, GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +#endif + +#ifndef GL_EXT_texture_compression_latc +#define GL_EXT_texture_compression_latc 1 +#endif + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#endif + +#ifndef GL_EXT_texture_shared_exponent +#define GL_EXT_texture_shared_exponent 1 +#endif + +#ifndef GL_NV_depth_buffer_float +#define GL_NV_depth_buffer_float 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glDepthRangedNV (GLdouble, GLdouble); +GLAPI void APIENTRY glClearDepthdNV (GLdouble); +GLAPI void APIENTRY glDepthBoundsdNV (GLdouble, GLdouble); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar); +typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth); +typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax); +#endif + +#ifndef GL_NV_fragment_program4 +#define GL_NV_fragment_program4 1 +#endif + +#ifndef GL_NV_framebuffer_multisample_coverage +#define GL_NV_framebuffer_multisample_coverage 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif + +#ifndef GL_EXT_framebuffer_sRGB +#define GL_EXT_framebuffer_sRGB 1 +#endif + +#ifndef GL_NV_geometry_shader4 +#define GL_NV_geometry_shader4 1 +#endif + +#ifndef GL_NV_parameter_buffer_object +#define GL_NV_parameter_buffer_object 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum, GLuint, GLuint, GLsizei, const GLfloat *); +GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum, GLuint, GLuint, GLsizei, const GLint *); +GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum, GLuint, GLuint, GLsizei, const GLuint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params); +typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params); +#endif + +#ifndef GL_EXT_draw_buffers2 +#define GL_EXT_draw_buffers2 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint, GLboolean, GLboolean, GLboolean, GLboolean); +GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum, GLuint, GLboolean *); +GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum, GLuint, GLint *); +GLAPI void APIENTRY glEnableIndexedEXT (GLenum, GLuint); +GLAPI void APIENTRY glDisableIndexedEXT (GLenum, GLuint); +GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data); +typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index); +typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index); +#endif + +#ifndef GL_NV_transform_feedback +#define GL_NV_transform_feedback 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum); +GLAPI void APIENTRY glEndTransformFeedbackNV (void); +GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint, const GLint *, GLenum); +GLAPI void APIENTRY glBindBufferRangeNV (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr); +GLAPI void APIENTRY glBindBufferOffsetNV (GLenum, GLuint, GLuint, GLintptr); +GLAPI void APIENTRY glBindBufferBaseNV (GLenum, GLuint, GLuint); +GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint, GLsizei, const GLint *, GLenum); +GLAPI void APIENTRY glActiveVaryingNV (GLuint, const GLchar *); +GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint, const GLchar *); +GLAPI void APIENTRY glGetActiveVaryingNV (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *); +GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint, GLuint, GLint *); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode); +typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode); +typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset); +typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode); +typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name); +typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name); +typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location); +#endif + +#ifndef GL_EXT_bindable_uniform +#define GL_EXT_bindable_uniform 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glUniformBufferEXT (GLuint, GLint, GLuint); +GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint, GLint); +GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint, GLint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer); +typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location); +typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location); +#endif + +#ifndef GL_EXT_texture_integer +#define GL_EXT_texture_integer 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glTexParameterIivEXT (GLenum, GLenum, const GLint *); +GLAPI void APIENTRY glTexParameterIuivEXT (GLenum, GLenum, const GLuint *); +GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum, GLenum, GLint *); +GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum, GLenum, GLuint *); +GLAPI void APIENTRY glClearColorIiEXT (GLint, GLint, GLint, GLint); +GLAPI void APIENTRY glClearColorIuiEXT (GLuint, GLuint, GLuint, GLuint); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha); +typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha); +#endif + +#ifndef GL_GREMEDY_frame_terminator +#define GL_GREMEDY_frame_terminator 1 +#ifdef GL_GLEXT_PROTOTYPES +GLAPI void APIENTRY glFrameTerminatorGREMEDY (void); +#endif /* GL_GLEXT_PROTOTYPES */ +typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void); +#endif + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#endif + +#ifndef GL_NV_present_video +#define GL_NV_present_video 1 +#endif + +#ifndef GL_EXT_transform_feedback +#define GL_EXT_transform_feedback 1 +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/VBox/GuestHost/OpenGL/include/chromium.h b/src/VBox/GuestHost/OpenGL/include/chromium.h new file mode 100644 index 00000000..8de678e4 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/chromium.h @@ -0,0 +1,864 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +/** + * Public Chromium exports. + * Parallel Chromium applications will include this header. + */ + + +#ifndef __CHROMIUM_H__ +#define __CHROMIUM_H__ + + +/**********************************************************************/ +/***** System includes and other cruft *****/ +/**********************************************************************/ + +#include "cr_compiler.h" + +#ifdef IN_RING0 + +# ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_common_VBoxVideoLog_h +# undef WARN /* VBoxMpUtils.h includes common/VBoxVideoLog.h which */ +# undef LOG /* uncondtionally redefines these three macros. */ +# undef LOGREL +# endif +# include + +# define WINGDIAPI /* gl/gl.h is using this (wingdi.h defines it a __declspec(dllimport) normaly). */ + +#endif + +/* + * We effectively wrap gl.h, glu.h, etc, just like GLUT + */ + +#ifndef GL_GLEXT_PROTOTYPES +# define GL_GLEXT_PROTOTYPES +#endif + +#if defined(WINDOWS) +# ifdef IN_RING0 +# error "should not happen!" /* bird: This is certifiably insane, in my opinion. */ +# endif +# define WIN32_LEAN_AND_MEAN +# define WGL_APIENTRY __stdcall +# ifdef VBOX +# include +# else +# include +# endif +#elif defined(DARWIN) +/* nothing */ +#else +# ifndef IN_RING0 +# define GLX +# endif +#endif + +#include +/* Quick fix so as not to update the version of glext.h we provide. */ +#ifdef GL_GLEXT_PROTOTYPES +# if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) +GLAPI void APIENTRY glBindFramebuffer (GLenum, GLuint); +GLAPI void APIENTRY glBlitFramebuffer (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum); +GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum); +GLAPI void APIENTRY glDeleteFramebuffers (GLsizei, const GLuint *); +GLAPI void APIENTRY glFramebufferTexture2D (GLenum, GLenum, GLenum, GLuint, GLint); +GLAPI void APIENTRY glGenFramebuffers (GLsizei, GLuint *); +# endif +#endif + +#ifndef WINDOWS +# ifndef RT_OS_WINDOWS /* If we don't need it in ring-3, we probably not need it in ring-0 either (triggers warnings). */ +# include +# if RT_GNUC_PREREQ(4, 6) +# pragma GCC diagnostic push +# endif +# if RT_GNUC_PREREQ(4, 2) +# ifndef __cplusplus +# pragma GCC diagnostic ignored "-Wstrict-prototypes" +# endif +# endif +# include +# if RT_GNUC_PREREQ(4, 6) +# pragma GCC diagnostic pop +# endif +# endif /* !RT_OS_WINDOWS */ +#endif + + +#ifdef GLX +# ifndef GLX_GLXEXT_PROTOTYPES +# define GLX_GLXEXT_PROTOTYPES +# endif +# include +#endif + +#ifdef USE_OSMESA +# include +#endif + +#ifdef DARWIN +# include +#elif !defined(FreeBSD) +# include /* to get ptrdiff_t used below */ +#endif + +#include "cr_glext.h" + +#ifdef IN_RING0 +# undef WINGDIAPI /* don't want it clashing with wingdi.h should it be included. */ +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* to shut up gcc warning for struct VBOXUHGSMI * parameters */ +struct VBOXUHGSMI; +struct VBOXVR_SCR_COMPOSITOR; +struct VBOXVR_SCR_COMPOSITOR_ENTRY; + +#define CR_RENDER_DEFAULT_CONTEXT_ID (INT32_MAX-1) +#define CR_RENDER_DEFAULT_WINDOW_ID (INT32_MAX-1) + +#if defined(IN_GUEST) && defined(RT_OS_WINDOWS) && defined(VBOX_WITH_WDDM) +# ifdef VBOX_WDDM_WOW64 +# define VBOX_MODNAME_DISPD3D "VBoxDispD3D-x86" +# else +# define VBOX_MODNAME_DISPD3D "VBoxDispD3D" +# endif +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif + + +/**********************************************************************/ +/***** Define things that might have been missing in gl.h *****/ +/**********************************************************************/ + +/* + * Define missing GLX tokens: + */ + +#ifndef GLX_SAMPLE_BUFFERS_SGIS +#define GLX_SAMPLE_BUFFERS_SGIS 0x186a0 /*100000*/ +#endif +#ifndef GLX_SAMPLES_SGIS +#define GLX_SAMPLES_SGIS 0x186a1 /*100001*/ +#endif +#ifndef GLX_VISUAL_CAVEAT_EXT +#define GLX_VISUAL_CAVEAT_EXT 0x20 /* visual_rating extension type */ +#endif + +/* + * Define missing WGL tokens: + */ +#ifndef WGL_COLOR_BITS_EXT +#define WGL_COLOR_BITS_EXT 0x2014 +#endif +#ifndef WGL_DRAW_TO_WINDOW_EXT +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#endif +#ifndef WGL_FULL_ACCELERATION_EXT +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#endif +#ifndef WGL_ACCELERATION_EXT +#define WGL_ACCELERATION_EXT 0x2003 +#endif +#ifndef WGL_TYPE_RGBA_EXT +#define WGL_TYPE_RGBA_EXT 0x202B +#endif +#ifndef WGL_RED_BITS_EXT +#define WGL_RED_BITS_EXT 0x2015 +#endif +#ifndef WGL_GREEN_BITS_EXT +#define WGL_GREEN_BITS_EXT 0x2017 +#endif +#ifndef WGL_BLUE_BITS_EXT +#define WGL_BLUE_BITS_EXT 0x2019 +#endif +#ifndef WGL_ALPHA_BITS_EXT +#define WGL_ALPHA_BITS_EXT 0x201B +#endif +#ifndef WGL_DOUBLE_BUFFER_EXT +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#endif +#ifndef WGL_STEREO_EXT +#define WGL_STEREO_EXT 0x2012 +#endif +#ifndef WGL_ACCUM_RED_BITS_EXT +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#endif +#ifndef WGL_ACCUM_GREEN_BITS_EXT +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#endif +#ifndef WGL_ACCUM_BLUE_BITS_EXT +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#endif +#ifndef WGL_ACCUM_ALPHA_BITS_EXT +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#endif +#ifndef WGL_DEPTH_BITS_EXT +#define WGL_DEPTH_BITS_EXT 0x2022 +#endif +#ifndef WGL_STENCIL_BITS_EXT +#define WGL_STENCIL_BITS_EXT 0x2023 +#endif +#ifndef WGL_SAMPLE_BUFFERS_EXT +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#endif +#ifndef WGL_SAMPLES_EXT +#define WGL_SAMPLES_EXT 0x2042 +#endif +#ifndef WGL_SUPPORT_OPENGL_ARB +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#endif +#ifndef WGL_NUMBER_PIXEL_FORMATS_ARB +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#endif +#ifndef WGL_FULL_ACCELERATION_ARB +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#endif +#ifndef WGL_SWAP_UNDEFINED_ARB +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#endif +#ifndef WGL_TYPE_RGBA_ARB +#define WGL_TYPE_RGBA_ARB 0x202B +#endif +#ifndef WGL_DRAW_TO_WINDOW_ARB +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#endif +#ifndef WGL_DRAW_TO_BITMAP_ARB +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#endif +#ifndef WGL_DOUBLE_BUFFER_ARB +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#endif +#ifndef WGL_NEED_PALETTE_ARB +#define WGL_NEED_PALETTE_ARB 0x2004 +#endif +#ifndef WGL_NEED_SYSTEM_PALETTE_ARB +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#endif +#ifndef WGL_SWAP_LAYER_BUFFERS_ARB +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#endif +#ifndef WGL_NUMBER_OVERLAYS_ARB +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#endif +#ifndef WGL_NUMBER_UNDERLAYS_ARB +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#endif +#ifndef WGL_TRANSPARENT_ARB +#define WGL_TRANSPARENT_ARB 0x200A +#endif +#ifndef WGL_TRANSPARENT_RED_VALUE_ARB +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#endif +#ifndef WGL_TRANSPARENT_GREEN_VALUE_ARB +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#endif +#ifndef WGL_TRANSPARENT_BLUE_VALUE_ARB +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#endif +#ifndef WGL_TRANSPARENT_ALPHA_VALUE_ARB +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#endif +#ifndef WGL_TRANSPARENT_INDEX_VALUE_ARB +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#endif +#ifndef WGL_SHARE_STENCIL_ARB +#define WGL_SHARE_STENCIL_ARB 0x200D +#endif +#ifndef WGL_SHARE_ACCUM_ARB +#define WGL_SHARE_ACCUM_ARB 0x200E +#endif +#ifndef WGL_SUPPORT_GDI_ARB +#define WGL_SUPPORT_GDI_ARB 0x200F +#endif +#ifndef WGL_RED_BITS_ARB +#define WGL_RED_BITS_ARB 0x2015 +#endif +#ifndef WGL_RED_SHIFT_ARB +#define WGL_RED_SHIFT_ARB 0x2016 +#endif +#ifndef WGL_GREEN_BITS_ARB +#define WGL_GREEN_BITS_ARB 0x2017 +#endif +#ifndef WGL_GREEN_SHIFT_ARB +#define WGL_GREEN_SHIFT_ARB 0x2018 +#endif +#ifndef WGL_BLUE_BITS_ARB +#define WGL_BLUE_BITS_ARB 0x2019 +#endif +#ifndef WGL_BLUE_SHIFT_ARB +#define WGL_BLUE_SHIFT_ARB 0x201A +#endif +#ifndef WGL_ALPHA_BITS_ARB +#define WGL_ALPHA_BITS_ARB 0x201B +#endif +#ifndef WGL_ALPHA_SHIFT_ARB +#define WGL_ALPHA_SHIFT_ARB 0x201C +#endif +#ifndef WGL_ACCUM_BITS_ARB +#define WGL_ACCUM_BITS_ARB 0x201D +#endif +#ifndef WGL_ACCUM_RED_BITS_ARB +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#endif +#ifndef WGL_ACCUM_GREEN_BITS_ARB +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#endif +#ifndef WGL_ACCUM_BLUE_BITS_ARB +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#endif +#ifndef WGL_ACCUM_ALPHA_BITS_ARB +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#endif +#ifndef WGL_DEPTH_BITS_ARB +#define WGL_DEPTH_BITS_ARB 0x2022 +#endif +#ifndef WGL_STENCIL_BITS_ARB +#define WGL_STENCIL_BITS_ARB 0x2023 +#endif +#ifndef WGL_AUX_BUFFERS_ARB +#define WGL_AUX_BUFFERS_ARB 0x2024 +#endif +#ifndef WGL_STEREO_ARB +#define WGL_STEREO_ARB 0x2012 +#endif +#ifndef WGL_ACCELERATION_ARB +#define WGL_ACCELERATION_ARB 0x2003 +#endif +#ifndef WGL_SHARE_DEPTH_ARB +#define WGL_SHARE_DEPTH_ARB 0x200C +#endif +#ifndef WGL_PIXEL_TYPE_ARB +#define WGL_PIXEL_TYPE_ARB 0x2013 +#endif +#ifndef WGL_COLOR_BITS_ARB +#define WGL_COLOR_BITS_ARB 0x2014 +#endif +#ifndef WGL_SWAP_METHOD_ARB +#define WGL_SWAP_METHOD_ARB 0x2007 +#endif + +/* + * Define missing 1.2 tokens: + */ +#ifndef GL_SMOOTH_POINT_SIZE_RANGE +#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 +#endif + +#ifndef GL_SMOOTH_POINT_SIZE_GRANULARITY +#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13 +#endif + +#ifndef GL_SMOOTH_LINE_WIDTH_RANGE +#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 +#endif + +#ifndef GL_SMOOTH_LINE_WIDTH_GRANULARITY +#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23 +#endif + +#ifndef GL_ALIASED_POINT_SIZE_RANGE +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#endif + +#ifndef GL_ALIASED_LINE_WIDTH_RANGE +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#endif + +#ifndef GL_COLOR_MATRIX_STACK_DEPTH +#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2 +#endif + +#ifndef GL_COLOR_MATRIX +#define GL_COLOR_MATRIX 0x80B1 +#endif + +#ifndef GL_TEXTURE_3D +#define GL_TEXTURE_3D 0x806F +#endif + +#ifndef GL_MAX_3D_TEXTURE_SIZE +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#endif + +#ifndef GL_PACK_SKIP_IMAGES +#define GL_PACK_SKIP_IMAGES 0x806B +#endif + +#ifndef GL_PACK_IMAGE_HEIGHT +#define GL_PACK_IMAGE_HEIGHT 0x806C +#endif + +#ifndef GL_UNPACK_SKIP_IMAGES +#define GL_UNPACK_SKIP_IMAGES 0x806D +#endif + +#ifndef GL_UNPACK_IMAGE_HEIGHT +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#endif + +#ifndef GL_PROXY_TEXTURE_3D +#define GL_PROXY_TEXTURE_3D 0x8070 +#endif + +#ifndef GL_TEXTURE_DEPTH +#define GL_TEXTURE_DEPTH 0x8071 +#endif + +#ifndef GL_TEXTURE_WRAP_R +#define GL_TEXTURE_WRAP_R 0x8072 +#endif + +#ifndef GL_TEXTURE_BINDING_3D +#define GL_TEXTURE_BINDING_3D 0x806A +#endif + +#ifndef GL_MAX_ELEMENTS_VERTICES +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#endif + +#ifndef GL_MAX_ELEMENTS_INDICES +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#endif + + +/* + * Define missing ARB_imaging tokens + */ + +#ifndef GL_BLEND_EQUATION +#define GL_BLEND_EQUATION 0x8009 +#endif + +#ifndef GL_MIN +#define GL_MIN 0x8007 +#endif + +#ifndef GL_MAX +#define GL_MAX 0x8008 +#endif + +#ifndef GL_FUNC_ADD +#define GL_FUNC_ADD 0x8006 +#endif + +#ifndef GL_FUNC_SUBTRACT +#define GL_FUNC_SUBTRACT 0x800A +#endif + +#ifndef GL_FUNC_REVERSE_SUBTRACT +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#endif + +#ifndef GL_BLEND_COLOR +#define GL_BLEND_COLOR 0x8005 +#endif + +#ifndef GL_PER_STAGE_CONSTANTS_NV +#define GL_PER_STAGE_CONSTANTS_NV 0x8535 +#endif + +#ifndef GL_FOG_COORDINATE_ARRAY_POINTER_EXT +#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456 +#endif + +typedef void (*CR_GLXFuncPtr)(void); +#ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 +CR_GLXFuncPtr glXGetProcAddressARB( const GLubyte *name ); +#endif /* GLX_ARB_get_proc_address */ + +#ifndef GLX_VERSION_1_4 +CR_GLXFuncPtr glXGetProcAddress( const GLubyte *name ); +#endif /* GLX_ARB_get_proc_address */ + +#ifndef GL_RASTER_POSITION_UNCLIPPED_IBM +#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262 +#endif + +#ifdef WINDOWS +/* XXX how about this prototype for wglGetProcAddress()? +PROC WINAPI wglGetProcAddress_prox( LPCSTR name ) +*/ +#endif + + +#ifndef GL_VERSION_1_5 + +typedef ptrdiff_t GLintptr; +typedef ptrdiff_t GLsizeiptr; + +/* prototype these functions for opengl_stub/getprocaddress.c */ +extern void APIENTRY glGenQueries(GLsizei n, GLuint *ids); +extern void APIENTRY glDeleteQueries(GLsizei n, const GLuint *ids); +extern GLboolean APIENTRY glIsQuery(GLuint id); +extern void APIENTRY glBeginQuery(GLenum target, GLuint id); +extern void APIENTRY glEndQuery(GLenum target); +extern void APIENTRY glGetQueryiv(GLenum target, GLenum pname, GLint *params); +extern void APIENTRY glGetQueryObjectiv(GLuint id, GLenum pname, GLint *params); +extern void APIENTRY glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params); +extern void APIENTRY glBindBuffer(GLenum, GLuint); +extern void APIENTRY glDeleteBuffers(GLsizei, const GLuint *); +extern void APIENTRY glGenBuffers(GLsizei, GLuint *); +extern GLboolean APIENTRY glIsBuffer(GLuint); +extern void APIENTRY glBufferData(GLenum, GLsizeiptr, const GLvoid *, GLenum); +extern void APIENTRY glBufferSubData(GLenum, GLintptr, GLsizeiptr, const GLvoid *); +extern void APIENTRY glGetBufferSubData(GLenum, GLintptr, GLsizeiptr, GLvoid *); +extern GLvoid* APIENTRY glMapBuffer(GLenum, GLenum); +extern GLboolean APIENTRY glUnmapBuffer(GLenum); +extern void APIENTRY glGetBufferParameteriv(GLenum, GLenum, GLint *); +extern void APIENTRY glGetBufferPointerv(GLenum, GLenum, GLvoid* *); + +#endif + + +/**********************************************************************/ +/***** Chromium Extensions to OpenGL *****/ +/***** *****/ +/***** Chromium owns the OpenGL enum range 0x8AF0-0x8B2F *****/ +/**********************************************************************/ + +#ifndef GL_CR_synchronization +#define GL_CR_synchronization 1 + +typedef void (APIENTRY *glBarrierCreateCRProc) (GLuint name, GLuint count); +typedef void (APIENTRY *glBarrierDestroyCRProc) (GLuint name); +typedef void (APIENTRY *glBarrierExecCRProc) (GLuint name); +typedef void (APIENTRY *glSemaphoreCreateCRProc) (GLuint name, GLuint count); +typedef void (APIENTRY *glSemaphoreDestroyCRProc) (GLuint name); +typedef void (APIENTRY *glSemaphorePCRProc) (GLuint name); +typedef void (APIENTRY *glSemaphoreVCRProc) (GLuint name); + +extern void APIENTRY glBarrierCreateCR(GLuint name, GLuint count); +extern void APIENTRY glBarrierDestroyCR(GLuint name); +extern void APIENTRY glBarrierExecCR(GLuint name); +extern void APIENTRY glSemaphoreCreateCR(GLuint name, GLuint count); +extern void APIENTRY glSemaphoreDestroyCR(GLuint name); +extern void APIENTRY glSemaphorePCR(GLuint name); +extern void APIENTRY glSemaphoreVCR(GLuint name); + +#endif /* GL_CR_synchronization */ + + +#ifndef GL_CR_bounds_info +#define GL_CR_bounds_info 1 +/* Private, internal Chromium function */ +/* +typedef void (APIENTRY *glBoundsInfoCRProc)(const CRrecti *, const GLbyte *, GLint, GLint); +*/ +#endif /* GL_CR_bounds_info */ + + +#ifndef GL_CR_state_parameter +#define GL_CR_state_parameter 1 + +typedef void (APIENTRY *glChromiumParameteriCRProc) (GLenum target, GLint value); +typedef void (APIENTRY *glChromiumParameterfCRProc) (GLenum target, GLfloat value); +typedef void (APIENTRY *glChromiumParametervCRProc) (GLenum target, GLenum type, GLsizei count, const GLvoid *values); +typedef void (APIENTRY *glGetChromiumParametervCRProc) (GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values); + +extern void APIENTRY glChromiumParameteriCR(GLenum target, GLint value); +extern void APIENTRY glChromiumParameterfCR(GLenum target, GLfloat value); +extern void APIENTRY glChromiumParametervCR(GLenum target, GLenum type, GLsizei count, const GLvoid *values); +extern void APIENTRY glGetChromiumParametervCR(GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values); + + +#endif /* GL_CR_state_parameter */ + + +#ifndef GL_CR_cursor_position +#define GL_CR_cursor_position 1 +/* For virtual cursor feature (show_cursor) */ + +#define GL_CURSOR_POSITION_CR 0x8AF0 + +#endif /* GL_CR_cursor_position */ + + +#ifndef GL_CR_bounding_box +#define GL_CR_bounding_box 1 +/* To set bounding box from client app */ + +#define GL_DEFAULT_BBOX_CR 0x8AF1 +#define GL_SCREEN_BBOX_CR 0x8AF2 +#define GL_OBJECT_BBOX_CR 0x8AF3 + +#endif /* GL_CR_bounding_box */ + + +#ifndef GL_CR_print_string +#define GL_CR_print_string 1 +/* To print a string to stdout */ +#define GL_PRINT_STRING_CR 0x8AF4 + +#endif /* GL_CR_print_string */ + + +#ifndef GL_CR_tilesort_info +#define GL_CR_tilesort_info 1 +/* To query tilesort information */ + +#define GL_MURAL_SIZE_CR 0x8AF5 +#define GL_NUM_SERVERS_CR 0x8AF6 +#define GL_NUM_TILES_CR 0x8AF7 +#define GL_TILE_BOUNDS_CR 0x8AF8 +#define GL_VERTEX_COUNTS_CR 0x8AF9 +#define GL_RESET_VERTEX_COUNTERS_CR 0x8AFA +#define GL_SET_MAX_VIEWPORT_CR 0x8AFB + +#endif /* GL_CR_tilesort_info */ + + +#ifndef GL_CR_head_spu_name +#define GL_CR_head_spu_name 1 +/* To fetch name of first SPU on a node */ + +#define GL_HEAD_SPU_NAME_CR 0x8AFC + +#endif /* GL_CR_head_spu_name */ + + +#ifndef GL_CR_performance_info +#define GL_CR_performance_info 1 +/* For gathering performance metrics */ + +#define GL_PERF_GET_FRAME_DATA_CR 0x8AFD +#define GL_PERF_GET_TIMER_DATA_CR 0x8AFE +#define GL_PERF_DUMP_COUNTERS_CR 0x8AFF +#define GL_PERF_SET_TOKEN_CR 0x8B00 +#define GL_PERF_SET_DUMP_ON_SWAP_CR 0x8B01 +#define GL_PERF_SET_DUMP_ON_FINISH_CR 0x8B02 +#define GL_PERF_SET_DUMP_ON_FLUSH_CR 0x8B03 +#define GL_PERF_START_TIMER_CR 0x8B04 +#define GL_PERF_STOP_TIMER_CR 0x8B05 + +#endif /* GL_CR_performance_info */ + + +#ifndef GL_CR_window_size +#define GL_CR_window_size 1 +/* To communicate window size changes */ + +#define GL_WINDOW_SIZE_CR 0x8B06 +#define GL_MAX_WINDOW_SIZE_CR 0x8B24 /* new */ +#define GL_WINDOW_VISIBILITY_CR 0x8B25 /* new */ + +#endif /* GL_CR_window_size */ + + +#ifndef GL_CR_tile_info +#define GL_CR_tile_info 1 +/* To send new tile information to a server */ + +#define GL_TILE_INFO_CR 0x8B07 + +#endif /* GL_CR_tile_info */ + + +#ifndef GL_CR_gather +#define GL_CR_gather 1 +/* For aggregate transfers */ + +#define GL_GATHER_DRAWPIXELS_CR 0x8B08 +#define GL_GATHER_PACK_CR 0x8B09 +#define GL_GATHER_CONNECT_CR 0x8B0A +#define GL_GATHER_POST_SWAPBUFFERS_CR 0x8B0B + +#endif /* GL_CR_gather */ + + +#ifndef GL_CR_saveframe +#define GL_CR_saveframe 1 + +#define GL_SAVEFRAME_ENABLED_CR 0x8B0C +#define GL_SAVEFRAME_FRAMENUM_CR 0x8B0D +#define GL_SAVEFRAME_STRIDE_CR 0x8B0E +#define GL_SAVEFRAME_SINGLE_CR 0x8B0F +#define GL_SAVEFRAME_FILESPEC_CR 0x8B10 + +#endif /* GL_CR_saveframe */ + + +#ifndef GL_CR_readback_barrier_size +#define GL_CR_readback_barrier_size 1 + +#define GL_READBACK_BARRIER_SIZE_CR 0x8B11 + +#endif /* GL_CR_readback_barrier_size */ + + +#ifndef GL_CR_server_id_sharing +#define GL_CR_server_id_sharing 1 + +#define GL_SHARED_DISPLAY_LISTS_CR 0x8B12 +#define GL_SHARED_TEXTURE_OBJECTS_CR 0x8B13 +#define GL_SHARED_PROGRAMS_CR 0x8B14 + +#endif /* GL_CR_server_id_sharing */ + + +#ifndef GL_CR_server_matrix +#define GL_CR_server_matrix 1 + +#define GL_SERVER_VIEW_MATRIX_CR 0x8B15 +#define GL_SERVER_PROJECTION_MATRIX_CR 0x8B16 +#define GL_SERVER_FRUSTUM_CR 0x8B17 +#define GL_SERVER_CURRENT_EYE_CR 0x8B18 + +#endif /* GL_CR_server_matrix */ + + +#ifndef GL_CR_window_position +#define GL_CR_window_position 1 + +#define GL_WINDOW_POSITION_CR 0x8B19 + +#endif /* GL_CR_window_position */ + + +#ifndef GL_CR_zpix +#define GL_CR_zpix 1 + +#define GL_ZLIB_COMPRESSION_CR 0x8B20 +#define GL_RLE_COMPRESSION_CR 0x8B21 +#define GL_PLE_COMPRESSION_CR 0x8B22 + +/* XXX A better name would be glCompressedDrawPixelsCR() */ +extern void APIENTRY glZPixCR(GLsizei width, GLsizei height, GLenum format, + GLenum type, GLenum compressionType, + GLint client, GLint compressedSize, + const GLvoid *image); + +#endif /* GL_CR_zpix */ + +/*Allow to use glGetString to query real host GPU info*/ +#ifndef GL_CR_real_vendor_strings +#define GL_CR_real_vendor_strings 1 +#define GL_REAL_VENDOR 0x8B23 +#define GL_REAL_VERSION 0x8B24 +#define GL_REAL_RENDERER 0x8B25 +#define GL_REAL_EXTENSIONS 0x8B26 +#endif + +/*Global resource ids sharing*/ +#define GL_SHARE_CONTEXT_RESOURCES_CR 0x8B27 +/*do flush for the command buffer of a thread the context was previusly current for*/ +#define GL_FLUSH_ON_THREAD_SWITCH_CR 0x8B28 +/*report that the shared resource is used by this context, the parameter value is a texture name*/ +#define GL_RCUSAGE_TEXTURE_SET_CR 0x8B29 +/*report that the shared resource is no longer used by this context, the parameter value is a texture name*/ +#define GL_RCUSAGE_TEXTURE_CLEAR_CR 0x8B2A +/*configures host to create windows initially hidden*/ +#define GL_HOST_WND_CREATED_HIDDEN_CR 0x8B2B +/* guest requests host whether e debug break is needed*/ +#define GL_DBG_CHECK_BREAK_CR 0x8B2C +/* Tells renderspu the default context id being used by the crserver */ +#define GL_HH_SET_DEFAULT_SHARED_CTX 0x8B2D + +#define GL_HH_SET_TMPCTX_MAKE_CURRENT 0x8B2E +/* inform renderspu about the current render thread */ +#define GL_HH_RENDERTHREAD_INFORM 0x8B2F + +/* enable zero vertex attribute generation to work around wine bug */ +#define GL_CHECK_ZERO_VERT_ARRT 0x8B30 + +/* share lists */ +#define GL_SHARE_LISTS_CR 0x8B31 + +#define GL_HH_SET_CLIENT_CALLOUT 0x8B32 + +/* ensure the resource is */ +#define GL_PIN_TEXTURE_SET_CR 0x8B32 +#define GL_PIN_TEXTURE_CLEAR_CR 0x8B33 + +/**********************************************************************/ +/***** Chromium-specific API *****/ +/**********************************************************************/ + + +/* + * Accepted by crCreateContext() and crCreateWindow() visBits parameter. + * Used to communicate visual attributes throughout Chromium. + */ +#define CR_RGB_BIT 0x1 +#define CR_ALPHA_BIT 0x2 +#define CR_DEPTH_BIT 0x4 +#define CR_STENCIL_BIT 0x8 +#define CR_ACCUM_BIT 0x10 +#define CR_DOUBLE_BIT 0x20 +#define CR_STEREO_BIT 0x40 +#define CR_MULTISAMPLE_BIT 0x80 +#define CR_OVERLAY_BIT 0x100 +#define CR_PBUFFER_BIT 0x200 +#define CR_ALL_BITS 0x3ff + + +/* Accepted by crSwapBuffers() flag parameter */ +#define CR_SUPPRESS_SWAP_BIT 0x1 + + +typedef GLint (APIENTRY *crCreateContextProc)(const char *dpyName, GLint visBits); +typedef void (APIENTRY *crDestroyContextProc)(GLint context); +typedef void (APIENTRY *crMakeCurrentProc)(GLint window, GLint context); +typedef GLint (APIENTRY *crGetCurrentContextProc)(void); +typedef GLint (APIENTRY *crGetCurrentWindowProc)(void); +typedef void (APIENTRY *crSwapBuffersProc)(GLint window, GLint flags); + +typedef GLint (APIENTRY *crWindowCreateProc)(const char *dpyName, GLint visBits); +typedef void (APIENTRY *crWindowDestroyProc)(GLint window); +typedef void (APIENTRY *crWindowSizeProc)(GLint window, GLint w, GLint h); +typedef void (APIENTRY *crWindowPositionProc)(GLint window, GLint x, GLint y); +typedef void (APIENTRY *crWindowShowProc)( GLint window, GLint flag ); + +extern GLint APIENTRY crCreateContext(char *dpyName, GLint visBits); +extern void APIENTRY crDestroyContext(GLint context); +extern void APIENTRY crMakeCurrent(GLint window, GLint context); +extern GLint APIENTRY crGetCurrentContext(void); +extern GLint APIENTRY crGetCurrentWindow(void); +extern void APIENTRY crSwapBuffers(GLint window, GLint flags); +extern GLint APIENTRY crWindowCreate(const char *dpyName, GLint visBits); +extern void APIENTRY crWindowDestroy(GLint window); +extern void APIENTRY crWindowSize(GLint window, GLint w, GLint h); +extern void APIENTRY crWindowPosition(GLint window, GLint x, GLint y); +extern void APIENTRY crWindowVisibleRegion( GLint window, GLint cRects, const void *pRects ); +extern void APIENTRY crWindowShow( GLint window, GLint flag ); +extern void APIENTRY crVBoxTexPresent(GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, const GLint *pRects); + +typedef int (CR_APIENTRY *CR_PROC)(void); +CR_PROC APIENTRY crGetProcAddress( const char *name ); + + + +/**********************************************************************/ +/***** Other useful stuff *****/ +/**********************************************************************/ + +#ifdef WINDOWS +#define GET_PROC(NAME) wglGetProcAddress((const GLbyte *) (NAME)) +#elif defined(DARWIN) +#define GET_PROC(NAME) NULL +#elif defined(GLX_ARB_get_proc_address) +#define GET_PROC(NAME) glXGetProcAddressARB((const GLubyte *) (NAME)) +#else +/* For SGI, etc that don't have glXGetProcAddress(). */ +#define GET_PROC(NAME) NULL +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* __CHROMIUM_H__ */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_bbox.h b/src/VBox/GuestHost/OpenGL/include/cr_bbox.h new file mode 100644 index 00000000..494ae404 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_bbox.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_BBOX_H +#define CR_BBOX_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern DECLEXPORT(void) +crTransformBBox(float xmin, float ymin, float zmin, + float xmax, float ymax, float zmax, + const CRmatrix *m, + float *out_xmin, float *out_ymin, float *out_zmin, + float *out_xmax, float *out_ymax, float *out_zmax); + +extern DECLEXPORT(void) +crProjectBBox(const GLfloat modl[16], const GLfloat proj[16], + GLfloat *x1, GLfloat *y1, GLfloat *z1, + GLfloat *x2, GLfloat *y2, GLfloat *z2); + + +extern DECLEXPORT(void) +crRectiUnion(CRrecti *result, const CRrecti *a, const CRrecti *b); + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_BBOX_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_bits.h b/src/VBox/GuestHost/OpenGL/include/cr_bits.h new file mode 100644 index 00000000..b641a9cb --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_bits.h @@ -0,0 +1,72 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +/* Bit vector functions */ + +#ifndef CR_BITS_H +#define CR_BITS_H + + +#include "cr_compiler.h" + + +#define CR_MAX_CONTEXTS 512 +#define CR_MAX_BITARRAY (CR_MAX_CONTEXTS / 32) /* 32 contexts per uint */ + +#ifdef __cplusplus +extern "C" { +#endif + +static INLINE void RESET( unsigned int *b, const unsigned int *d ) +{ + int j; + for (j=0;j +#include +#include +#include "cr_vreg.h" +#ifdef IN_VMSVGA3D +# include +typedef struct TODO_VMSVGA3D_DISPATCH_TABLE SPUDispatchTable; +# include +#else +# include "cr_spu.h" +#endif + +/** @todo r=bird: VBOXBLITTERDECL makes no sense. */ +#ifndef IN_RING0 +# define VBOXBLITTERDECL(_type) DECLEXPORT(_type) +#else +# define VBOXBLITTERDECL(_type) RTDECL(_type) +#endif + +RT_C_DECLS_BEGIN +typedef struct CR_BLITTER_IMG +{ + void *pvData; + GLuint cbData; + GLenum enmFormat; + GLuint width, height; + GLuint bpp; + GLuint pitch; +} CR_BLITTER_IMG; +typedef CR_BLITTER_IMG *PCR_BLITTER_IMG; +typedef CR_BLITTER_IMG const *PCCR_BLITTER_IMG; + +VBOXBLITTERDECL(void) CrMClrFillImgRect(PCR_BLITTER_IMG pDst, PCRTRECT pCopyRect, uint32_t u32Color); +VBOXBLITTERDECL(void) CrMClrFillImg(PCR_BLITTER_IMG pImg, uint32_t cRects, PCRTRECT pRects, uint32_t u32Color); +VBOXBLITTERDECL(void) CrMBltImgRect(PCCR_BLITTER_IMG pSrc, PCRTPOINT pSrcDataPoint, bool fSrcInvert, PCRTRECT pCopyRect, + PCR_BLITTER_IMG pDst); +VBOXBLITTERDECL(void) CrMBltImg(PCCR_BLITTER_IMG pSrc, PCRTPOINT pPos, uint32_t cRects, PCRTRECT pRects, PCR_BLITTER_IMG pDst); +VBOXBLITTERDECL(void) CrMBltImgRectScaled(PCCR_BLITTER_IMG pSrc, PCRTPOINT pPos, bool fSrcInvert, PCRTRECT pCopyRect, + float strX, float strY, PCR_BLITTER_IMG pDst); +VBOXBLITTERDECL(void) CrMBltImgScaled(PCCR_BLITTER_IMG pSrc, PCRTRECTSIZE pSrcRectSize, PCRTRECT pDstRect, uint32_t cRects, + PCRTRECT pRects, PCR_BLITTER_IMG pDst); + +/* + * GLSL Cache + */ +typedef struct CR_GLSL_CACHE +{ + int iGlVersion; + GLuint uNoAlpha2DProg; + GLuint uNoAlpha2DRectProg; + SPUDispatchTable *pDispatch; +} CR_GLSL_CACHE; +typedef CR_GLSL_CACHE *PCR_GLSL_CACHE; +typedef CR_GLSL_CACHE const *PCCR_GLSL_CACHE; + +DECLINLINE(void) CrGlslInit(PCR_GLSL_CACHE pCache, SPUDispatchTable *pDispatch) +{ + RT_ZERO(*pCache); + pCache->pDispatch = pDispatch; +} + +DECLINLINE(bool) CrGlslIsInited(PCCR_GLSL_CACHE pCache) +{ + return !!pCache->pDispatch; +} + +/* clients should set proper context before calling these funcs */ +VBOXBLITTERDECL(bool) CrGlslIsSupported(PCR_GLSL_CACHE pCache); +VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(PCR_GLSL_CACHE pCache); +VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(PCR_GLSL_CACHE pCache, GLenum enmTexTarget); +VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(PCR_GLSL_CACHE pCache, GLenum enmTexTarget); +VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(PCCR_GLSL_CACHE pCache, GLenum enmTexTarget); +VBOXBLITTERDECL(void) CrGlslProgClear(PCCR_GLSL_CACHE pCache); +VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(PCCR_GLSL_CACHE pCache); +VBOXBLITTERDECL(void) CrGlslCleanup(PCR_GLSL_CACHE pCache); +VBOXBLITTERDECL(void) CrGlslTerm(PCR_GLSL_CACHE pCache); + +/* + * BLITTER + */ +typedef struct CR_BLITTER_BUFFER +{ + GLuint cbBuffer; + GLvoid *pvBuffer; +} CR_BLITTER_BUFFER; +typedef CR_BLITTER_BUFFER *PCR_BLITTER_BUFFER; +typedef CR_BLITTER_BUFFER const *PCCR_BLITTER_BUFFER; + +typedef union CR_BLITTER_FLAGS +{ + struct + { + uint32_t Initialized : 1; + uint32_t CtxCreated : 1; + uint32_t SupportsFBO : 1; + uint32_t SupportsPBO : 1; + uint32_t CurrentMuralChanged : 1; + uint32_t LastWasFBODraw : 1; + uint32_t ForceDrawBlit : 1; + uint32_t ShadersGloal : 1; + uint32_t Reserved : 24; + }; + uint32_t Value; +} CR_BLITTER_FLAGS; + +struct CR_BLITTER; + +typedef DECLCALLBACK(int) FNCRBLT_BLITTER(struct CR_BLITTER *pBlitter, PCVBOXVR_TEXTURE pSrc, PCRTRECT paSrcRect, + PCRTRECTSIZE pDstSize, PCRTRECT paDstRect, uint32_t cRects, uint32_t fFlags); +typedef FNCRBLT_BLITTER *PFNCRBLT_BLITTER; + +typedef struct CR_BLITTER_SPUITEM +{ + int id; + GLint visualBits; +} CR_BLITTER_SPUITEM, *PCR_BLITTER_SPUITEM; + +typedef struct CR_BLITTER_CONTEXT +{ + CR_BLITTER_SPUITEM Base; +} CR_BLITTER_CONTEXT; +typedef CR_BLITTER_CONTEXT *PCR_BLITTER_CONTEXT; +typedef CR_BLITTER_CONTEXT const *PCCR_BLITTER_CONTEXT; + +typedef struct CR_BLITTER_WINDOW +{ + CR_BLITTER_SPUITEM Base; + GLuint width, height; +} CR_BLITTER_WINDOW; +typedef CR_BLITTER_WINDOW *PCR_BLITTER_WINDOW; +typedef CR_BLITTER_WINDOW const *PCCR_BLITTER_WINDOW; + +typedef struct CR_BLITTER +{ + GLuint idFBO; + CR_BLITTER_FLAGS Flags; + uint32_t cEnters; + PFNCRBLT_BLITTER pfnBlt; + CR_BLITTER_BUFFER Verticies; + CR_BLITTER_BUFFER Indicies; + RTRECTSIZE CurrentSetSize; + CR_BLITTER_WINDOW CurrentMural; + CR_BLITTER_CONTEXT CtxInfo; + int32_t i32MakeCurrentUserData; + SPUDispatchTable *pDispatch; + PCCR_GLSL_CACHE pGlslCache; + CR_GLSL_CACHE LocalGlslCache; +} CR_BLITTER; +typedef CR_BLITTER *PCR_BLITTER; +typedef CR_BLITTER const *PCCR_BLITTER; + +DECLINLINE(GLboolean) CrBltIsInitialized(PCR_BLITTER pBlitter) +{ + return !!pBlitter->pDispatch; +} + +VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, PCCR_BLITTER_CONTEXT pCtxBase, bool fCreateNewCtx, + bool fForceDrawBlt, PCCR_GLSL_CACHE pShaders, SPUDispatchTable *pDispatch); + +VBOXBLITTERDECL(void) CrBltTerm(PCR_BLITTER pBlitter); + +VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter); + +DECLINLINE(GLboolean) CrBltSupportsTexTex(PCR_BLITTER pBlitter) +{ + return pBlitter->Flags.SupportsFBO; +} + +DECLINLINE(GLboolean) CrBltIsEntered(PCR_BLITTER pBlitter) +{ + return !!pBlitter->cEnters; +} + +DECLINLINE(GLint) CrBltGetVisBits(PCR_BLITTER pBlitter) +{ + return pBlitter->CtxInfo.Base.visualBits; +} + + +DECLINLINE(GLboolean) CrBltIsEverEntered(PCR_BLITTER pBlitter) +{ + return !!pBlitter->Flags.Initialized; +} + +DECLINLINE(void) CrBltSetMakeCurrentUserData(PCR_BLITTER pBlitter, int32_t i32MakeCurrentUserData) +{ + pBlitter->i32MakeCurrentUserData = i32MakeCurrentUserData; +} + +VBOXBLITTERDECL(int) CrBltMuralSetCurrentInfo(PCR_BLITTER pBlitter, PCCR_BLITTER_WINDOW pMural); + +DECLINLINE(PCCR_BLITTER_WINDOW) CrBltMuralGetCurrentInfo(PCR_BLITTER pBlitter) +{ + return &pBlitter->CurrentMural; +} + +VBOXBLITTERDECL(void) CrBltCheckUpdateViewport(PCR_BLITTER pBlitter); + +VBOXBLITTERDECL(void) CrBltLeave(PCR_BLITTER pBlitter); +VBOXBLITTERDECL(int) CrBltEnter(PCR_BLITTER pBlitter); +VBOXBLITTERDECL(void) CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, PCVBOXVR_TEXTURE pSrc, PCRTRECT paSrcRects, + PCRTRECT paDstRects, uint32_t cRects, uint32_t fFlags); +VBOXBLITTERDECL(void) CrBltBlitTexTex(PCR_BLITTER pBlitter, PCVBOXVR_TEXTURE pSrc, PCRTRECT pSrcRect, PCVBOXVR_TEXTURE pDst, + PCRTRECT pDstRect, uint32_t cRects, uint32_t fFlags); +VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, PCVBOXVR_TEXTURE pSrc, GLenum enmFormat, PCR_BLITTER_IMG pDst); + +VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, PCR_BLITTER_IMG pDst); +VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, PCR_BLITTER_IMG pDst); +VBOXBLITTERDECL(void) CrBltPresent(PCR_BLITTER pBlitter); +/* */ +struct CR_TEXDATA; + +typedef DECLCALLBACK(void) FNCRTEXDATA_RELEASED(struct CR_TEXDATA *pTexture); +typedef FNCRTEXDATA_RELEASED *PFNCRTEXDATA_RELEASED; + +typedef union CR_TEXDATA_FLAGS +{ + struct + { + uint32_t DataValid : 1; + uint32_t DataAcquired : 1; + uint32_t DataInverted : 1; + uint32_t Entered : 1; + uint32_t Reserved : 28; + }; + uint32_t Value; +} CR_TEXDATA_FLAGS; + + +typedef struct CR_TEXDATA +{ + VBOXVR_TEXTURE Tex; + volatile uint32_t cRefs; + /* fields specific to texture data download */ + uint32_t idInvertTex; + uint32_t idPBO; + CR_TEXDATA_FLAGS Flags; + PCR_BLITTER pBlitter; + CR_BLITTER_IMG Img; + /*dtor*/ + PFNCRTEXDATA_RELEASED pfnTextureReleased; + struct CR_TEXDATA *pScaledCache; +} CR_TEXDATA; +typedef CR_TEXDATA *PCR_TEXDATA; +typedef CR_TEXDATA const *PCCR_TEXDATA; + +DECLINLINE(void) CrTdInit(PCR_TEXDATA pTex, PCVBOXVR_TEXTURE pVrTex, PCR_BLITTER pBlitter, PFNCRTEXDATA_RELEASED pfnTextureReleased) +{ + memset(pTex, 0, sizeof (*pTex)); + pTex->Tex = *pVrTex; + pTex->cRefs = 1; + pTex->pBlitter = pBlitter; + pTex->pfnTextureReleased = pfnTextureReleased; +} + +DECLINLINE(PCVBOXVR_TEXTURE) CrTdTexGet(PCCR_TEXDATA pTex) +{ + return &pTex->Tex; +} + +DECLINLINE(PCR_BLITTER) CrTdBlitterGet(PCR_TEXDATA pTex) +{ + return pTex->pBlitter; +} + +DECLINLINE(int) CrTdBltEnter(PCR_TEXDATA pTex) +{ + int rc; + if (pTex->Flags.Entered) + return VERR_INVALID_STATE; + rc = CrBltEnter(pTex->pBlitter); +#ifdef IN_VMSVGA3D + AssertRCReturn(rc, rc); +#else + if (!RT_SUCCESS(rc)) + { + WARN(("CrBltEnter failed rc %d", rc)); + return rc; + } +#endif + pTex->Flags.Entered = 1; + return VINF_SUCCESS; +} + +DECLINLINE(bool) CrTdBltIsEntered(PCR_TEXDATA pTex) +{ + return pTex->Flags.Entered; +} + +DECLINLINE(void) CrTdBltLeave(PCR_TEXDATA pTex) +{ +#ifdef IN_VMSVGA3D + AssertReturnVoid(pTex->Flags.Entered); +#else + if (!pTex->Flags.Entered) + { + WARN(("invalid Blt Leave")); + return; + } +#endif + + CrBltLeave(pTex->pBlitter); + + pTex->Flags.Entered = 0; +} + +/* the CrTdBltXxx calls are done with the entered blitter */ +/** Acquire the texture data, returns the cached data in case it is cached. + * The data remains cached in the CR_TEXDATA object until it is discarded with + * CrTdBltDataFree or CrTdBltDataCleanup. */ +VBOXBLITTERDECL(int) CrTdBltDataAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, PCCR_BLITTER_IMG *ppImg); + +VBOXBLITTERDECL(int) CrTdBltDataAcquireScaled(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, + uint32_t width, uint32_t height, PCCR_BLITTER_IMG *ppImg); + +VBOXBLITTERDECL(int) CrTdBltDataReleaseScaled(PCR_TEXDATA pTex, PCCR_BLITTER_IMG pImg); + +VBOXBLITTERDECL(void) CrTdBltScaleCacheMoveTo(PCR_TEXDATA pTex, PCR_TEXDATA pDstTex); + +/** Release the texture data, the data remains cached in the CR_TEXDATA object + * until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup. */ +VBOXBLITTERDECL(int) CrTdBltDataRelease(PCR_TEXDATA pTex); +/** Discard the texture data cached with previous CrTdBltDataAcquire. + * Must be called wit data released (CrTdBltDataRelease). */ +VBOXBLITTERDECL(int) CrTdBltDataFree(PCR_TEXDATA pTex); +VBOXBLITTERDECL(int) CrTdBltDataFreeNe(PCR_TEXDATA pTex); +VBOXBLITTERDECL(void) CrTdBltDataInvalidateNe(PCR_TEXDATA pTex); +/** Does same as CrTdBltDataFree, and in addition cleans up. + * This is kind of a texture destructor, which clients should call on texture object destruction, + * e.g. from the PFNCRTEXDATA_RELEASED callback. */ +VBOXBLITTERDECL(int) CrTdBltDataCleanup(PCR_TEXDATA pTex); + +VBOXBLITTERDECL(int) CrTdBltDataCleanupNe(PCR_TEXDATA pTex); + +DECLINLINE(uint32_t) CrTdAddRef(PCR_TEXDATA pTex) +{ + return ASMAtomicIncU32(&pTex->cRefs); +} + +DECLINLINE(uint32_t) CrTdRelease(PCR_TEXDATA pTex) +{ + uint32_t cRefs = ASMAtomicDecU32(&pTex->cRefs); + if (!cRefs) + { + if (pTex->pfnTextureReleased) + pTex->pfnTextureReleased(pTex); + else + CrTdBltDataCleanupNe(pTex); + } + + return cRefs; +} + +RT_C_DECLS_END + +#endif + diff --git a/src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h b/src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h new file mode 100644 index 00000000..fda56bac --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_bmpscale.h @@ -0,0 +1,25 @@ +#ifndef ___cr_bmpscale_h__ +#define ___cr_bmpscale_h__ + +#include +#include + + +RT_C_DECLS_BEGIN + +#ifndef IN_RING0 +# define VBOXBMPSCALEDECL(_type) DECLEXPORT(_type) +#else +# define VBOXBLITTERDECL(_type) RTDECL(_type) +#endif + +VBOXBMPSCALEDECL(void) CrBmpScale32 (uint8_t *dst, + int iDstDeltaLine, + int dstW, int dstH, + const uint8_t *src, + int iSrcDeltaLine, + int srcW, int srcH); + +RT_C_DECLS_END + +#endif /* #ifndef ___cr_bmpscale_h__ */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_bufpool.h b/src/VBox/GuestHost/OpenGL/include/cr_bufpool.h new file mode 100644 index 00000000..60ec216c --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_bufpool.h @@ -0,0 +1,33 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_BUFPOOL_H +#define CR_BUFPOOL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct CRBufferPool_t CRBufferPool; +typedef void (*CRBufferPoolDeleteCallback)(void *data); + +DECLEXPORT(CRBufferPool *) crBufferPoolInit( unsigned int maxBuffers ); +DECLEXPORT(void) crBufferPoolFree( CRBufferPool *pool ); +DECLEXPORT(void) crBufferPoolCallbackFree(CRBufferPool *pool, CRBufferPoolDeleteCallback pfnDelete); + +DECLEXPORT(void) crBufferPoolPush( CRBufferPool *pool, void *buf, unsigned int bytes ); +DECLEXPORT(void *) crBufferPoolPop( CRBufferPool *pool, unsigned int bytes ); + +DECLEXPORT(int) crBufferPoolGetNumBuffers( CRBufferPool *pool ); +DECLEXPORT(int) crBufferPoolGetMaxBuffers( CRBufferPool *pool ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_BUFPOOL_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_calllists.h b/src/VBox/GuestHost/OpenGL/include/cr_calllists.h new file mode 100644 index 00000000..4d9d0670 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_calllists.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_CALLLISTS_H +#define CR_CALLLISTS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern DECLEXPORT(int) +crExpandCallLists(GLsizei n, GLenum type, const GLvoid *lists, + GLuint base, void (*callListFunc)(GLuint list)); + +extern DECLEXPORT(int) +crExpandCallListsWithData(GLsizei n, GLenum type, const GLvoid *lists, + GLuint base, void (*callListFunc)(GLuint list, GLuint index, GLvoid *data), GLvoid *data); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_CALLLISTS_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_compiler.h b/src/VBox/GuestHost/OpenGL/include/cr_compiler.h new file mode 100644 index 00000000..15f73bd0 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_compiler.h @@ -0,0 +1,45 @@ +/** + * Compiler-related definitions, etc. + */ + +#ifndef CR_COMPILER_H +#define CR_COMPILER_H 1 + + +/** + * Function inlining + */ +#if defined(__GNUC__) +# define INLINE __inline__ +#elif defined(__MSC__) +# define INLINE __inline +#elif defined(_MSC_VER) +# define INLINE __inline +#elif defined(__ICL) +# define INLINE __inline +#else +# define INLINE +#endif + + +/** + * For global vars in shared libs + */ +#include + +#ifndef DLLDATA +#define DLLDATA(type) DECLIMPORT(type) +#endif + +/** + * For functions called via the public API. + * XXX CR_APIENTRY could probably replace all the other *_APIENTRY defines. + */ +#ifdef WINDOWS +#define CR_APIENTRY __stdcall +#else +#define CR_APIENTRY +#endif + + +#endif /* CR_COMPILER_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_compositor.h b/src/VBox/GuestHost/OpenGL/include/cr_compositor.h new file mode 100644 index 00000000..c97c9a81 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_compositor.h @@ -0,0 +1,265 @@ +/* $Id: cr_compositor.h $ */ +/** @file + * Compositor API. + */ + +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#ifndef ___cr_compositor_h +#define ___cr_compositor_h + +#include "cr_vreg.h" +#include "cr_blitter.h" + + +/* Compositor with Stretching & Cached Rectangles info */ + +RT_C_DECLS_BEGIN + +struct VBOXVR_SCR_COMPOSITOR_ENTRY; +struct VBOXVR_SCR_COMPOSITOR; + +typedef DECLCALLBACK(void) FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_SCR_COMPOSITOR *pCompositor, + struct VBOXVR_SCR_COMPOSITOR_ENTRY *pEntry, + struct VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacingEntry); +typedef FNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED; + + +typedef struct VBOXVR_SCR_COMPOSITOR_ENTRY +{ + VBOXVR_COMPOSITOR_ENTRY Ce; + RTRECT Rect; + uint32_t fChanged; + uint32_t fFlags; + uint32_t cRects; + PRTRECT paSrcRects; + PRTRECT paDstRects; + PRTRECT paDstUnstretchedRects; + PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased; + PCR_TEXDATA pTex; +} VBOXVR_SCR_COMPOSITOR_ENTRY; +typedef VBOXVR_SCR_COMPOSITOR_ENTRY *PVBOXVR_SCR_COMPOSITOR_ENTRY; +typedef VBOXVR_SCR_COMPOSITOR_ENTRY const *PCVBOXVR_SCR_COMPOSITOR_ENTRY; + +typedef struct VBOXVR_SCR_COMPOSITOR +{ + VBOXVR_COMPOSITOR Compositor; + RTRECT Rect; +#ifndef IN_RING0 + float StretchX; + float StretchY; +#endif + uint32_t fFlags; + uint32_t cRects; + uint32_t cRectsBuffer; + PRTRECT paSrcRects; + PRTRECT paDstRects; + PRTRECT paDstUnstretchedRects; +} VBOXVR_SCR_COMPOSITOR; +typedef VBOXVR_SCR_COMPOSITOR *PVBOXVR_SCR_COMPOSITOR; +typedef VBOXVR_SCR_COMPOSITOR const *PCVBOXVR_SCR_COMPOSITOR; + + +typedef DECLCALLBACK(bool) FNVBOXVRSCRCOMPOSITOR_VISITOR(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + void *pvVisitor); +typedef FNVBOXVRSCRCOMPOSITOR_VISITOR *PFNVBOXVRSCRCOMPOSITOR_VISITOR; + +DECLINLINE(void) CrVrScrCompositorEntryInit(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, PCRTRECT pRect, CR_TEXDATA *pTex, + PFNVBOXVRSCRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased) +{ + memset(pEntry, 0, sizeof (*pEntry)); + VBoxVrCompositorEntryInit(&pEntry->Ce); + pEntry->Rect = *pRect; + pEntry->pfnEntryReleased = pfnEntryReleased; + if (pTex) + { + CrTdAddRef(pTex); + pEntry->pTex = pTex; + } +} + +DECLINLINE(void) CrVrScrCompositorEntryCleanup(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + if (pEntry->pTex) + { + CrTdRelease(pEntry->pTex); + pEntry->pTex = NULL; + } +} + +DECLINLINE(bool) CrVrScrCompositorEntryIsUsed(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + return VBoxVrCompositorEntryIsInList(&pEntry->Ce); +} + +DECLINLINE(void) CrVrScrCompositorEntrySetChanged(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, bool fChanged) +{ + pEntry->fChanged = !!fChanged; +} + +DECLINLINE(void) CrVrScrCompositorEntryTexSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, CR_TEXDATA *pTex) +{ + if (pEntry->pTex) + CrTdRelease(pEntry->pTex); + + if (pTex) + CrTdAddRef(pTex); + + pEntry->pTex = pTex; +} + +DECLINLINE(CR_TEXDATA *) CrVrScrCompositorEntryTexGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + return pEntry->pTex; +} + +DECLINLINE(bool) CrVrScrCompositorEntryIsChanged(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + return !!pEntry->fChanged; +} + +DECLINLINE(bool) CrVrScrCompositorIsEmpty(PCVBOXVR_SCR_COMPOSITOR pCompositor) +{ + return VBoxVrCompositorIsEmpty(&pCompositor->Compositor); +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTRECT pRect); +VBOXVREGDECL(int) CrVrScrCompositorEntryTexAssign(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + CR_TEXDATA *pTex); +VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor, + void *pvVisitor); +VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged); +DECLINLINE(bool) CrVrScrCompositorEntryIsInList(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + return VBoxVrCompositorEntryIsInList(&pEntry->Ce); +} +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions, bool fPosRelated, + VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry, uint32_t *pfChangeFlags); +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions, bool fPosRelated, + bool *pfChanged); +VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCVBOXVR_LIST pList2, bool *pfChanged); +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged); +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions, + PCRTRECT paRegions, bool *pfChanged); +VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2, + bool *pfChanged); +VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTPOINT pPos); +DECLINLINE(PCRTRECT) CrVrScrCompositorEntryRectGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + return &pEntry->Rect; +} + +/* regions are valid until the next CrVrScrCompositor call */ +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, + PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t *pcRegions, + PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions, + PCRTRECT *ppaDstUnstretchedRects); +VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry); +VBOXVREGDECL(bool) CrVrScrCompositorEntryReplace(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_SCR_COMPOSITOR_ENTRY pNewEntry); +VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags); +VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, + PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry); +DECLINLINE(uint32_t) CrVrScrCompositorEntryFlagsGet(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + return pEntry->fFlags; +} + +VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect); +VBOXVREGDECL(int) CrVrScrCompositorRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect, bool *pfChanged); +DECLINLINE(PCRTRECT) CrVrScrCompositorRectGet(PCVBOXVR_SCR_COMPOSITOR pCompositor) +{ + return &pCompositor->Rect; +} + +VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor); +VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged); + +typedef DECLCALLBACK(VBOXVR_SCR_COMPOSITOR_ENTRY*) FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR(PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + void *pvContext); +typedef FNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR *PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR; + +VBOXVREGDECL(int) CrVrScrCompositorClone(PCVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor, + PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor); +VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr, bool *pfChanged); +VBOXVREGDECL(int) CrVrScrCompositorIntersectedList(PCVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr, + PVBOXVR_SCR_COMPOSITOR pDstCompositor, + PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor, bool *pfChanged); +#ifndef IN_RING0 +VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY); +DECLINLINE(void) CrVrScrCompositorGetStretching(PCVBOXVR_SCR_COMPOSITOR pCompositor, float *pStretchX, float *pStretchY) +{ + if (pStretchX) + *pStretchX = pCompositor->StretchX; + + if (pStretchY) + *pStretchY = pCompositor->StretchY; +} +#endif +/* regions are valid until the next CrVrScrCompositor call */ +VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t *pcRegions, + PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions, PCRTRECT *ppaDstUnstretchedRects); + +#define VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(_p) RT_FROM_MEMBER(_p, VBOXVR_SCR_COMPOSITOR_ENTRY, Ce) +#define VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(_p) RT_FROM_MEMBER(_p, const VBOXVR_SCR_COMPOSITOR_ENTRY, Ce) +#define VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(_p) RT_FROM_MEMBER(_p, VBOXVR_SCR_COMPOSITOR, Compositor) + +typedef struct VBOXVR_SCR_COMPOSITOR_ITERATOR +{ + VBOXVR_COMPOSITOR_ITERATOR Base; +} VBOXVR_SCR_COMPOSITOR_ITERATOR; +typedef VBOXVR_SCR_COMPOSITOR_ITERATOR *PVBOXVR_SCR_COMPOSITOR_ITERATOR; + +typedef struct VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR +{ + VBOXVR_COMPOSITOR_CONST_ITERATOR Base; +} VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR; +typedef VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR *PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR; + +DECLINLINE(void) CrVrScrCompositorIterInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter) +{ + VBoxVrCompositorIterInit(&pCompositor->Compositor, &pIter->Base); +} + +DECLINLINE(void) CrVrScrCompositorConstIterInit(PCVBOXVR_SCR_COMPOSITOR pCompositor, + PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter) +{ + VBoxVrCompositorConstIterInit(&pCompositor->Compositor, &pIter->Base); +} + +DECLINLINE(PVBOXVR_SCR_COMPOSITOR_ENTRY) CrVrScrCompositorIterNext(PVBOXVR_SCR_COMPOSITOR_ITERATOR pIter) +{ + PVBOXVR_COMPOSITOR_ENTRY pCe = VBoxVrCompositorIterNext(&pIter->Base); + if (pCe) + return VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCe); + return NULL; +} + +DECLINLINE(PCVBOXVR_SCR_COMPOSITOR_ENTRY) CrVrScrCompositorConstIterNext(PVBOXVR_SCR_COMPOSITOR_CONST_ITERATOR pIter) +{ + PCVBOXVR_COMPOSITOR_ENTRY pCe = VBoxVrCompositorConstIterNext(&pIter->Base); + if (pCe) + return VBOXVR_SCR_COMPOSITOR_CONST_ENTRY_FROM_ENTRY(pCe); + return NULL; +} + +RT_C_DECLS_END + +#endif + diff --git a/src/VBox/GuestHost/OpenGL/include/cr_debugopcodes.h b/src/VBox/GuestHost/OpenGL/include/cr_debugopcodes.h new file mode 100644 index 00000000..9368e25a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_debugopcodes.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_DEBUG_OPCODES_H +#define CR_DEBUG_OPCODES_H + +#include "cr_opcodes.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void crDebugOpcodes( FILE *fp, unsigned char *ptr, unsigned int num_opcodes ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_DEBUG_OPCODES_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_dispatch.h b/src/VBox/GuestHost/OpenGL/include/cr_dispatch.h new file mode 100644 index 00000000..9f6180b5 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_dispatch.h @@ -0,0 +1,66 @@ +#ifndef CR_DISPATCH_H +#define CR_DISPATCH_H + +#include "spu_dispatch_table.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This structure offers a set of layers for controlling the + * dispatch table. The top layer is always the active layer, + * and controls the dispatch table. Utilities may push new + * layers onto the stack, or pop layers off, to control how + * dispatches are made. A utility may keep track of the + * layer it created, and change it as needed, if dynamic + * control of dispatch tables is needed. + */ + +typedef struct crDispatchLayer { + SPUDispatchTable *dispatchTable; + void (*changedCallback)(SPUDispatchTable *changedTable, void *callbackParm); + void *callbackParm; + struct crDispatchLayer *next, *prev; +} crDispatchLayer; + +/** This has to be saved and restored for each graphics context */ +typedef struct { + crDispatchLayer *topLayer; + crDispatchLayer *bottomLayer; +} crCurrentDispatchInfo; + +/** + * These are already called from appropriate opengl_stub + * routines, so SPUs or utilities shouldn't have to + * worry about them, as long as they let their + * parent routines for NewContext and MakeCurrent + * execute before they try to use any of the + * dispatch utilities. + */ +DECLEXPORT(void) crDispatchInit(SPUDispatchTable *defaultTable); +DECLEXPORT(void) crInitDispatchInfo(crCurrentDispatchInfo *info); +DECLEXPORT(void) crSetCurrentDispatchInfo(crCurrentDispatchInfo *info); + +/** + * SPUs and utilities are expected to use these routines + * to modify dispatch tables. They should only be called + * once the current dispatch info is set (i.e., after + * the opengl_stub routine for MakeCurrent has a chance + * to run). + */ +DECLEXPORT(crDispatchLayer) *crNewDispatchLayer(SPUDispatchTable *newTable, + void (*changedCallback)(SPUDispatchTable *changedTable, void *callbackParm), + void *callbackParm); +DECLEXPORT(void) crChangeDispatchLayer(crDispatchLayer *layer, + SPUDispatchTable *changedTable); +DECLEXPORT(void) crFreeDispatchLayer(crDispatchLayer *layer); + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_DISPATCH_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_dll.h b/src/VBox/GuestHost/OpenGL/include/cr_dll.h new file mode 100644 index 00000000..81c1b687 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_dll.h @@ -0,0 +1,49 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_DLL_H +#define CR_DLL_H + +#if defined(WINDOWS) +#define WIN32_LEAN_AND_MEAN +# ifdef VBOX +# include +# else +#include +# endif +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char *name; +#if defined(WINDOWS) + HINSTANCE hinstLib; +#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) + void *hinstLib; +#elif defined(DARWIN) + void *hinstLib; /* void to avoid including the headers */ + int type; /* to avoid calling crStrstr all the time */ +#else +#error ARCHITECTURE DLL NOT IMPLEMENTED +#endif +} CRDLL; + +typedef void (*CRDLLFunc)(void); +DECLEXPORT(CRDLL *) crDLLOpen( const char *dllname, int resolveGlobal ); +DECLEXPORT(CRDLLFunc) crDLLGetNoError( CRDLL *dll, const char *symname ); +DECLEXPORT(CRDLLFunc) crDLLGet( CRDLL *dll, const char *symname ); +DECLEXPORT(void) crDLLClose( CRDLL *dll ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_DLL_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_dmx.h b/src/VBox/GuestHost/OpenGL/include/cr_dmx.h new file mode 100644 index 00000000..4ae6456d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_dmx.h @@ -0,0 +1,55 @@ +/** + * DMX utility functions. + */ + +#ifndef CR_DMX_H +#define CR_DMX_H + +#include +#include + +#include "cr_spu.h" +#include "state/cr_statetypes.h" + + +typedef struct { + GLXDrawable xwin; /**< backend server's X window */ + GLXDrawable xsubwin; /**< child of xwin, clipped to screen bounds */ + Display *dpy; /**< DMX back-end server display */ + CRrecti visrect; /**< visible rect, in front-end screen coords */ +} CRDMXBackendWindowInfo; + + +#ifdef __cplusplus +extern "C" { +#endif + + +extern int +crDMXSupported(Display *dpy); + +extern CRDMXBackendWindowInfo * +crDMXAllocBackendWindowInfo(unsigned int numBackendWindows); + +extern void +crDMXFreeBackendWindowInfo(unsigned int numBackendWindows, + CRDMXBackendWindowInfo *backendWindows); + +/* Given the DMX front-end display "dpy" and window "xwin", update the + * backend window information in "backendWindows". If new subwindows are + * needed, and an OpenGL interface pointer is provided, use that interface + * and the subwindowVisBits to create new subwindows. + */ +extern GLboolean +crDMXGetBackendWindowInfo(Display *dpy, GLXDrawable xwin, + unsigned int numBackendWindows, + CRDMXBackendWindowInfo *backendWindows, + const crOpenGLInterface *openGlInterface, + GLint subwindowVisBits); + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_DLM_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_dump.h b/src/VBox/GuestHost/OpenGL/include/cr_dump.h new file mode 100644 index 00000000..d156b169 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_dump.h @@ -0,0 +1,177 @@ +/* $Id: cr_dump.h $ */ + +/** @file + * Debugging: Dump API + */ +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ +#ifndef ___cr_dump_h__ +#define ___cr_dump_h__ + +/* dump stuff */ +//#define VBOX_WITH_CRDUMPER +#ifdef VBOX_WITH_CRDUMPER + +#include +#include +#include +#include +#include + +# define VBOXDUMPDECL(_type) _type RTCALL + +RT_C_DECLS_BEGIN + +#ifdef RT_OS_WINDOWS +DECLEXPORT(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc); + +DECLEXPORT(void) crDmpDumpStrDbgPrint(struct CR_DUMPER * pDumper, const char*pszStr); +#endif + +struct CR_DUMPER; + +typedef DECLCALLBACKPTR(void, PFNCRDUMPIMG)(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc); +typedef DECLCALLBACKPTR(void, PFNCRDUMPSTR)(struct CR_DUMPER * pDumper, const char*pszStr); + +typedef struct CR_DUMPER +{ + PFNCRDUMPIMG pfnDumpImg; + PFNCRDUMPSTR pfnDumpStr; +} CR_DUMPER; + +#define crDmpImg(_pDumper, _pImg, _pDesc) do { \ + (_pDumper)->pfnDumpImg((_pDumper), (_pImg), (_pDesc)); \ + } while (0) + +#define crDmpStr(_pDumper, _pDesc) do { \ + (_pDumper)->pfnDumpStr((_pDumper), (_pDesc)); \ + } while (0) + +#ifndef RT_OS_WINDOWS +# define vsprintf_s vsnprintf +# define sprintf_s snprintf +#endif + +DECLINLINE(void) crDmpStrV(CR_DUMPER *pDumper, const char *pszStr, va_list pArgList) +{ + char szBuffer[4096] = {0}; + vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList); + crDmpStr(pDumper, szBuffer); +} + +DECLINLINE(void) crDmpStrF(CR_DUMPER *pDumper, const char *pszStr, ...) +{ + va_list pArgList; + va_start(pArgList, pszStr); + crDmpStrV(pDumper, pszStr, pArgList); + va_end(pArgList); +} + +DECLINLINE(void) crDmpImgV(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, va_list pArgList) +{ + char szBuffer[4096] = {0}; + vsprintf_s(szBuffer, sizeof (szBuffer), pszStr, pArgList); + crDmpImg(pDumper, pImg, szBuffer); +} + +DECLINLINE(void) crDmpImgF(CR_DUMPER *pDumper, CR_BLITTER_IMG *pImg, const char *pszStr, ...) +{ + va_list pArgList; + va_start(pArgList, pszStr); + crDmpImgV(pDumper, pImg, pszStr, pArgList); + va_end(pArgList); +} + +VBOXDUMPDECL(size_t) crDmpFormatArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cVal); +VBOXDUMPDECL(size_t) crDmpFormatRawArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cVal); +VBOXDUMPDECL(size_t) crDmpFormatMatrixArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pVal, uint32_t cX, uint32_t cY); + +typedef struct CR_DBGPRINT_DUMPER +{ + CR_DUMPER Base; +} CR_DBGPRINT_DUMPER; + +typedef struct CR_HTML_DUMPER +{ + CR_DUMPER Base; + const char* pszFile; + const char* pszDir; + FILE *pFile; + uint32_t cImg; +} CR_HTML_DUMPER; + +DECLEXPORT(bool) crDmpHtmlIsInited(struct CR_HTML_DUMPER * pDumper); +DECLEXPORT(void) crDmpHtmlTerm(struct CR_HTML_DUMPER * pDumper); +DECLEXPORT(int) crDmpHtmlInit(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile); +DECLEXPORT(int) crDmpHtmlInitV(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, va_list pArgList); +DECLEXPORT(int) crDmpHtmlInitF(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, ...); + +#ifdef RT_OS_WINDOWS +DECLINLINE(void) crDmpDbgPrintInit(CR_DBGPRINT_DUMPER *pDumper) +{ + pDumper->Base.pfnDumpImg = crDmpDumpImgDmlBreak; + pDumper->Base.pfnDumpStr = crDmpDumpStrDbgPrint; +} +#endif + +typedef struct CR_RECORDER +{ + CR_BLITTER *pBlitter; + SPUDispatchTable *pDispatch; + CR_DUMPER *pDumper; +} CR_RECORDER; + +DECLINLINE(void) crRecInit(CR_RECORDER *pRec, CR_BLITTER *pBlitter, SPUDispatchTable *pDispatch, CR_DUMPER *pDumper) +{ + pRec->pBlitter = pBlitter; + pRec->pDispatch = pDispatch; + pRec->pDumper = pDumper; +} + +VBOXDUMPDECL(void) crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex); +VBOXDUMPDECL(void) crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecDumpTextureV(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, va_list pArgList); +VBOXDUMPDECL(void) crRecDumpTextureF(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, const char *pszStr, ...); +VBOXDUMPDECL(void) crRecDumpTextureByIdV(CR_RECORDER *pRec, CRContext *ctx, GLint id, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, va_list pArgList); +VBOXDUMPDECL(void) crRecDumpTextureByIdF(CR_RECORDER *pRec, CRContext *ctx, GLint id, CR_BLITTER_CONTEXT *pCurCtx, CR_BLITTER_WINDOW *pCurWin, const char *pszStr, ...); +VBOXDUMPDECL(void) crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); +VBOXDUMPDECL(void) crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); +VBOXDUMPDECL(void) crRecRecompileShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); +VBOXDUMPDECL(void) crRecRecompileProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); +VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecDumpProgramUniforms(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); +VBOXDUMPDECL(void) crRecDumpCurrentProgramUniforms(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecRecompileCurrentProgram(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecDumpProgramAttribs(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid); +VBOXDUMPDECL(void) crRecDumpCurrentProgramAttribs(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecDumpVertAttrv(CR_RECORDER *pRec, CRContext *ctx, GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal); +VBOXDUMPDECL(void) crRecDumpVertAttrF(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, ...); +VBOXDUMPDECL(void) crRecDumpVertAttrV(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, va_list pArgList); +VBOXDUMPDECL(void) crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget); +VBOXDUMPDECL(void) crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx); +VBOXDUMPDECL(void) crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx); + +VBOXDUMPDECL(int) crRecAlphaImgCreate(const CR_BLITTER_IMG *pImg, CR_BLITTER_IMG *pAlphaImg); +VBOXDUMPDECL(void) crRecAlphaImgDestroy(CR_BLITTER_IMG *pImg); + + +typedef DECLCALLBACKPTR(GLuint, PFNCRDUMPGETHWID)(void *pvObj); +void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey); + +RT_C_DECLS_END + +#endif /* VBOX_WITH_CRDUMPER */ +/* */ + +#endif /* #ifndef ___cr_dump_h__ */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_endian.h b/src/VBox/GuestHost/OpenGL/include/cr_endian.h new file mode 100644 index 00000000..29366e84 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_endian.h @@ -0,0 +1,90 @@ +#ifndef CR_ENDIAN_H +#define CR_ENDIAN_H + +#define CR_LITTLE_ENDIAN 0 +#define CR_BIG_ENDIAN 1 + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern DECLEXPORT(char) crDetermineEndianness( void ); + +#ifdef WINDOWS +typedef __int64 CR64BitType; +#else +#ifndef __STDC__ +typedef long long CR64BitType; +#else +typedef struct _CR64BitType +{ + unsigned int lo; + unsigned int hi; + +} CR64BitType; +#endif +#endif + +#define SWAP8(x) x +#define SWAP16(x) (short) ((((x) & 0x00FF) << 8) | (((x) & 0xFF00) >> 8)) +#define SWAP32(x) ((((x) & 0x000000FF) << 24) | \ + (((x) & 0x0000FF00) << 8) | \ + (((x) & 0x00FF0000) >> 8) | \ + (((x) & 0xFF000000) >> 24)) +#ifdef WINDOWS +#define SWAP64(x) \ + ((((x) & 0xFF00000000000000L) >> 56) | \ + (((x) & 0x00FF000000000000L) >> 40) | \ + (((x) & 0x0000FF0000000000L) >> 24) | \ + (((x) & 0x000000FF00000000L) >> 8) | \ + (((x) & 0x00000000FF000000L) << 8) | \ + (((x) & 0x0000000000FF0000L) << 24) | \ + (((x) & 0x000000000000FF00L) << 40) | \ + (((x) & 0x00000000000000FFL) << 56)) +#else +#ifndef __STDC__ +#define SWAP64(x) \ + x = ((((x) & 0xFF00000000000000LL) >> 56) | \ + (((x) & 0x00FF000000000000LL) >> 40) | \ + (((x) & 0x0000FF0000000000LL) >> 24) | \ + (((x) & 0x000000FF00000000LL) >> 8) | \ + (((x) & 0x00000000FF000000LL) << 8) | \ + (((x) & 0x0000000000FF0000LL) << 24) | \ + (((x) & 0x000000000000FF00LL) << 40) | \ + (((x) & 0x00000000000000FFLL) << 56)) +#else +#define SWAP64(x) \ + { \ + GLubyte *bytes = (GLubyte *) &(x); \ + GLubyte tmp = bytes[0]; \ + bytes[0] = bytes[7]; \ + bytes[7] = tmp; \ + tmp = bytes[1]; \ + bytes[1] = bytes[6]; \ + bytes[6] = tmp; \ + tmp = bytes[2]; \ + bytes[2] = bytes[5]; \ + bytes[5] = tmp; \ + tmp = bytes[4]; \ + bytes[4] = bytes[3]; \ + bytes[3] = tmp; \ + } +#endif +#endif + +DECLEXPORT(double) SWAPDOUBLE( double d ); + +#define SWAPFLOAT(x) ( ((*((int *) &(x)) & 0x000000FF) << 24) | \ + ((*((int *) &(x)) & 0x0000FF00) << 8) | \ + ((*((int *) &(x)) & 0x00FF0000) >> 8) | \ + ((*((int *) &(x)) & 0xFF000000) >> 24)) + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + + +#endif /* CR_ENDIAN_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_environment.h b/src/VBox/GuestHost/OpenGL/include/cr_environment.h new file mode 100644 index 00000000..7a8a6dcb --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_environment.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_ENVIRONMENT_H +#define CR_ENVIRONMENT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern DECLEXPORT(void) crSetenv( const char *var, const char *value ); +extern DECLEXPORT(const char *) crGetenv( const char *var ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_ENVIRONMENT_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_error.h b/src/VBox/GuestHost/OpenGL/include/cr_error.h new file mode 100644 index 00000000..81572dc0 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_error.h @@ -0,0 +1,67 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_ERROR_H +#define CR_ERROR_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef WARN +# ifndef IN_RING0 +# define LOG(_m) do { crDebug _m ; } while (0) +# define LOGREL(_m) do { crDebug _m ; } while (0) +# define WARN(_m) do { crWarning _m ; AssertMsgFailed(_m); } while (0) +# else +# define LOG(_m) do { } while (0) +# define LOGREL(_m) do { } while (0) +# define WARN(_m) do { AssertMsgFailed(_m); } while (0) +# endif +#endif + +DECLEXPORT(void) crEnableWarnings(int onOff); + +DECLEXPORT(void) crDebug(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2); +DECLEXPORT(void) crDbgCmdPrint(const char *description1, const char *description2, const char *cmd, ...); +DECLEXPORT(void) crDbgCmdSymLoadPrint(const char *modName, const void*pvAddress); +#if defined(DEBUG_misha) && defined(RT_OS_WINDOWS) +typedef void FNCRDEBUG(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2); +typedef FNCRDEBUG *PFNCRDEBUG; +DECLINLINE(PFNCRDEBUG) crGetDebug() {return crDebug;} +# define crWarning (RT_BREAKPOINT(), crDebug) +#else +DECLEXPORT(void) crWarning(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2); +#endif +DECLEXPORT(void) crInfo(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2); + +DECLEXPORT(void) crError(const char *format, ... ) RT_IPRT_FORMAT_ATTR(1, 2); + +/* Throw more info while opengl is not stable */ +#if defined(DEBUG) || 1 +# ifdef DEBUG_misha +# include +# define CRASSERT Assert +/*extern int g_VBoxFbgFBreakDdi;*/ +# define CR_DDI_PROLOGUE() do { /*if (g_VBoxFbgFBreakDdi) {Assert(0);}*/ } while (0) +# else +# define CRASSERT( PRED ) ((PRED)?(void)0:crWarning( "Assertion failed: %s=%d, file %s, line %d", #PRED, (int)(intptr_t)(PRED), __FILE__, __LINE__)) +# define CR_DDI_PROLOGUE() do {} while (0) +# endif +# define THREADASSERT( PRED ) ((PRED)?(void)0:crError( "Are you trying to run a threaded app ?\nBuild with 'make threadsafe'\nAssertion failed: %s, file %s, line %d", #PRED, __FILE__, __LINE__)) +#else +# define CRASSERT( PRED ) ((void)0) +# define THREADASSERT( PRED ) ((void)0) +# define CR_DDI_PROLOGUE() do {} while (0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CR_ERROR_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_extstring.h b/src/VBox/GuestHost/OpenGL/include/cr_extstring.h new file mode 100644 index 00000000..b2fe4fe9 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_extstring.h @@ -0,0 +1,323 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_EXTSTRING_H +#define CR_EXTSTRING_H + +#include "cr_version.h" + +/* + * This string is the list of OpenGL extensions which Chromium can understand + * (in the packer, unpacker, state-tracker, etc). + * In practice, this string will get intersected with what's reported by the + * rendering SPUs to reflect what we can really offer to client apps. + * + * Yes, we want static declarations here to avoid linking problems. + */ +static const char *crExtensions = +#ifdef CR_EXT_texture_compression_s3tc + "GL_EXT_texture_compression_s3tc " +#endif +#ifdef CR_EXT_draw_range_elements + "GL_EXT_draw_range_elements " +#endif +#ifdef CR_EXT_framebuffer_object + "GL_EXT_framebuffer_object " +#endif +#ifdef CR_EXT_compiled_vertex_array + "GL_EXT_compiled_vertex_array " +#endif +#ifdef CR_ARB_depth_texture + "GL_ARB_depth_texture " +#endif +#ifdef CR_ARB_fragment_program + "GL_ARB_fragment_program " +#endif +#ifdef CR_ARB_imaging + "GL_ARB_imaging " +#endif +#ifdef CR_ARB_multisample + "GL_ARB_multisample " +#endif +#ifdef CR_ARB_multitexture + "GL_ARB_multitexture " +#endif +#ifdef CR_ARB_occlusion_query + "GL_ARB_occlusion_query " +#endif +#ifdef CR_ARB_point_parameters + "GL_ARB_point_parameters " +#endif +#ifdef CR_ARB_point_sprite + "GL_ARB_point_sprite " +#endif +#ifdef CR_ARB_shadow + "GL_ARB_shadow " +#endif +#ifdef CR_ARB_shadow_ambient + "GL_ARB_shadow_ambient " +#endif +#ifdef CR_ARB_texture_border_clamp + "GL_ARB_texture_border_clamp " +#endif +#ifdef CR_ARB_texture_compression + "GL_ARB_texture_compression " +#endif +#ifdef CR_ARB_texture_cube_map + "GL_ARB_texture_cube_map " +#endif +#ifdef CR_ARB_texture_env_add + "GL_ARB_texture_env_add " +#endif +#ifdef CR_ARB_texture_env_combine + "GL_ARB_texture_env_combine GL_EXT_texture_env_combine " +#endif +#ifdef CR_ARB_texture_env_crossbar + "GL_ARB_texture_env_crossbar " +#endif +#ifdef CR_ARB_texture_env_dot3 + "GL_ARB_texture_env_dot3 GL_EXT_texture_env_dot3 " +#endif +#ifdef CR_ARB_texture_mirrored_repeat + "GL_ARB_texture_mirrored_repeat GL_IBM_texture_mirrored_repeat " +#endif +#ifdef CR_ATI_texture_mirror_once + "GL_ATI_texture_mirror_once " +#endif +#ifdef CR_ARB_texture_non_power_of_two + "GL_ARB_texture_non_power_of_two " +#endif +#ifdef CR_ARB_transpose_matrix + "GL_ARB_transpose_matrix " +#endif +#ifdef CR_ARB_vertex_buffer_object + "GL_ARB_vertex_buffer_object " +#endif +#ifdef CR_ARB_pixel_buffer_object + "GL_ARB_pixel_buffer_object " +#endif +#ifdef CR_ARB_vertex_program + "GL_ARB_vertex_program " +#endif +#ifdef CR_ARB_window_pos + "GL_ARB_window_pos " +#endif +#ifdef CR_EXT_blend_color + "GL_EXT_blend_color " +#endif +#ifdef CR_EXT_blend_minmax + "GL_EXT_blend_minmax " +#endif +#ifdef CR_EXT_blend_func_separate + "GL_EXT_blend_func_separate " +#endif +#ifdef CR_EXT_clip_volume_hint + "GL_EXT_clip_volume_hint " +#endif +#ifdef CR_EXT_blend_logic_op + "GL_EXT_blend_logic_op " +#endif +#ifdef CR_EXT_blend_subtract + "GL_EXT_blend_subtract " +#endif +#ifdef CR_EXT_texture_env_add + "GL_EXT_texture_env_add " +#endif +#ifdef CR_EXT_fog_coord + "GL_EXT_fog_coord " +#endif +#ifdef CR_EXT_multi_draw_arrays + "GL_EXT_multi_draw_arrays " +#endif +#ifdef CR_EXT_secondary_color + "GL_EXT_secondary_color " +#endif +#ifdef CR_EXT_separate_specular_color + "GL_EXT_separate_specular_color " +#endif +#ifdef CR_EXT_shadow_funcs + "GL_EXT_shadow_funcs " +#endif +#ifdef CR_EXT_stencil_wrap + "GL_EXT_stencil_wrap " +#endif +#ifdef CR_EXT_texture_cube_map + "GL_EXT_texture_cube_map " +#endif +#ifdef CR_EXT_texture_edge_clamp + "GL_EXT_texture_edge_clamp " +#endif +#ifdef CR_EXT_texture_filter_anisotropic + "GL_EXT_texture_filter_anisotropic " +#endif +#ifdef CR_EXT_texture_lod_bias + "GL_EXT_texture_lod_bias " +#endif +#ifdef CR_EXT_texture_object + "GL_EXT_texture_object " +#endif +#ifdef CR_EXT_texture3D + "GL_EXT_texture3D " +#endif +#ifdef CR_IBM_rasterpos_clip + "GL_IBM_rasterpos_clip " +#endif +#ifdef CR_NV_fog_distance + "GL_NV_fog_distance " +#endif +#ifdef CR_NV_fragment_program + "GL_NV_fragment_program " +#endif +#ifdef CR_NV_fragment_program_option + "GL_NV_fragment_program_option " +#endif +#ifdef CR_NV_fragment_program2 + "GL_NV_fragment_program2 " +#endif +#ifdef CR_NV_register_combiners + "GL_NV_register_combiners " +#endif +#ifdef CR_NV_register_combiners2 + "GL_NV_register_combiners2 " +#endif +#ifdef CR_NV_texgen_reflection + "GL_NV_texgen_reflection " +#endif +#ifdef CR_NV_texture_rectangle + "GL_NV_texture_rectangle GL_EXT_texture_rectangle GL_ARB_texture_rectangle " +#endif +#ifdef CR_NV_vertex_program + "GL_NV_vertex_program " +#endif +#ifdef CR_NV_vertex_program1_1 + "GL_NV_vertex_program1_1 " +#endif +#ifdef CR_NV_vertex_program2 + "GL_NV_vertex_program2 " +#endif +#ifdef CR_NV_vertex_program2_option + "GL_NV_vertex_program2_option " +#endif +#ifdef CR_NV_vertex_program3 + "GL_NV_vertex_program3 " +#endif +#ifdef CR_SGIS_generate_mipmap + "GL_SGIS_generate_mipmap " +#endif +#ifdef CR_SGIS_texture_border_clamp + "GL_SGIS_texture_border_clamp " +#endif +#ifdef CR_SGIS_texture_edge_clamp + "GL_SGIS_texture_edge_clamp " +#endif +#ifdef CR_ARB_shading_language_100 + "GL_ARB_shading_language_100 " +#endif +#ifdef CR_ARB_shader_objects + "GL_ARB_shader_objects " +#endif +#ifdef CR_ARB_vertex_shader + "GL_ARB_vertex_shader " +#endif +#ifdef CR_ARB_fragment_shader + "GL_ARB_fragment_shader " +#endif +#ifdef CR_EXT_texture_sRGB + "GL_EXT_texture_sRGB " +#endif +#ifdef CR_EXT_framebuffer_blit + "GL_EXT_framebuffer_blit " +#endif +#ifdef CR_EXT_blend_equation_separate + "GL_EXT_blend_equation_separate " +#endif +#ifdef CR_EXT_stencil_two_side + "GL_EXT_stencil_two_side " +#endif +#ifdef CR_GREMEDY_string_marker + "GL_GREMEDY_string_marker " +#endif +#ifdef CR_ARB_texture_float + "GL_ARB_texture_float " +#endif +#ifdef CR_ARB_draw_buffers + "GL_ARB_draw_buffers " +#endif +#ifdef CR_ARB_shader_texture_lod + "GL_ARB_shader_texture_lod " +#endif + + ""; + +/* + * Extensions which are only supported if the render/readback SPU is + * on the app node (no packing/unpacking/state-tracking support). + */ +static const char *crAppOnlyExtensions = + "GL_NV_fence " \ + "GL_NV_texture_env_combine4 " \ + "GL_NV_texture_shader " \ + "GL_NV_vertex_array_range " +; + + +/* + * Special extensions which are unique to Chromium. + * We typically append this to the result of glGetString(GL_EXTENSIONS). + */ +static const char *crChromiumExtensions = +#ifdef GL_CR_state_parameter + "GL_CR_state_parameter " +#endif +#ifdef GL_CR_cursor_position + "GL_CR_cursor_position " +#endif +#ifdef GL_CR_bounding_box + "GL_CR_bounding_box " +#endif +#ifdef GL_CR_print_string + "GL_CR_print_string " +#endif +#ifdef GL_CR_tilesort_info + "GL_CR_tilesort_info " +#endif +#ifdef GL_CR_client_clear_control + "GL_CR_client_clear_control " +#endif +#ifdef GL_CR_synchronization + "GL_CR_synchronization " +#endif +#ifdef GL_CR_head_spu_name + "GL_CR_head_spu_name " +#endif +#ifdef GL_CR_performance_info + "GL_CR_performance_info " +#endif +#ifdef GL_CR_window_size + "GL_CR_window_size " +#endif +#ifdef GL_CR_tile_info + "GL_CR_tile_info " +#endif +#ifdef GL_CR_saveframe + "GL_CR_saveframe " +#endif +#ifdef GL_CR_readback_barrier_size + "GL_CR_readback_barrier_size " +#endif +#ifdef GL_CR_server_id_sharing + "GL_CR_server_id_sharing " +#endif +#ifdef GL_CR_server_matrix + "GL_CR_server_matrix " +#endif +#ifdef USE_DMX + "GL_CR_dmx " +#endif + ""; + +#endif /* CR_EXTSTRING_H */ + diff --git a/src/VBox/GuestHost/OpenGL/include/cr_glext.h b/src/VBox/GuestHost/OpenGL/include/cr_glext.h new file mode 100644 index 00000000..bfa505f4 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_glext.h @@ -0,0 +1,34 @@ +/* $Id: cr_glext.h $ */ + +/** @file + * GL chromium platform specifics + */ +/* + * Copyright (C) 2014-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ +#ifndef ___cr_glext_h__ +#define ___cr_glext_h__ + +#include + +#ifndef __glext_h_ +/* glext NOT included yet */ +# include "GL/glext.h" +#else +/* glext IS included yet */ +# ifndef RT_OS_DARWIN +typedef unsigned int VBoxGLhandleARB; /* shader object handle */ +AssertCompile(sizeof (VBoxGLhandleARB) == sizeof (GLhandleARB)); +# else +# error "patched glext is required for OSX!" +# endif +#endif +#endif /*___cr_glext_h__*/ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_glstate.h b/src/VBox/GuestHost/OpenGL/include/cr_glstate.h new file mode 100644 index 00000000..442e4d81 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_glstate.h @@ -0,0 +1,335 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_GLSTATE_H +#define CR_GLSTATE_H + +/* Forward declaration since some of the state/cr_*.h files need the CRContext type */ +struct CRContext; +typedef struct CRContext CRContext; + +#include "cr_version.h" + +#include "state/cr_buffer.h" +#include "state/cr_bufferobject.h" +#include "state/cr_client.h" +#include "state/cr_current.h" +#include "state/cr_evaluators.h" +#include "state/cr_feedback.h" +#include "state/cr_fog.h" +#include "state/cr_hint.h" +#include "state/cr_lighting.h" +#include "state/cr_limits.h" +#include "state/cr_line.h" +#include "state/cr_lists.h" +#include "state/cr_multisample.h" +#include "state/cr_occlude.h" +#include "state/cr_pixel.h" +#include "state/cr_point.h" +#include "state/cr_polygon.h" +#include "state/cr_program.h" +#include "state/cr_regcombiner.h" +#include "state/cr_stencil.h" +#include "state/cr_texture.h" +#include "state/cr_transform.h" +#include "state/cr_viewport.h" +#include "state/cr_attrib.h" +#include "state/cr_framebuffer.h" +#include "state/cr_glsl.h" + +#include "state/cr_statefuncs.h" +#include "state/cr_stateerror.h" + +#include "spu_dispatch_table.h" + +#ifdef CHROMIUM_THREADSAFE +# include +#endif + +#include + +# include +# include + +# define CR_STATE_SHAREDOBJ_USAGE_INIT(_pObj) (crMemset((_pObj)->ctxUsage, 0, sizeof ((_pObj)->ctxUsage))) +# define CR_STATE_SHAREDOBJ_USAGE_SET(_pObj, _pCtx) (ASMBitSet((_pObj)->ctxUsage, (_pCtx)->id)) +# define CR_STATE_SHAREDOBJ_USAGE_IS_SET(_pObj, _pCtx) (ASMBitTest((_pObj)->ctxUsage, (_pCtx)->id)) +# define CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(_pObj, _i) (ASMBitClear((_pObj)->ctxUsage, (_i))) +# define CR_STATE_SHAREDOBJ_USAGE_CLEAR(_pObj, _pCtx) (CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX((_pObj), (_pCtx)->id)) +# define CR_STATE_SHAREDOBJ_USAGE_IS_USED(_pObj) (ASMBitFirstSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3) >= 0) +# define CR_STATE_SHAREDOBJ_USAGE_GET_FIRST_USED_IDX(_pObj) (ASMBitFirstSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3)) +# define CR_STATE_SHAREDOBJ_USAGE_GET_NEXT_USED_IDX(_pObj, _i) (ASMBitNextSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3, (_i))) + +# define CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(_pObj, _i) for ((_i) = CR_STATE_SHAREDOBJ_USAGE_GET_FIRST_USED_IDX(_pObj); ((int)(_i)) >= 0; (_i) = CR_STATE_SHAREDOBJ_USAGE_GET_NEXT_USED_IDX((_pObj), ((int)(_i)))) + +#define CR_MAX_EXTENTS 256 + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Bit vectors describing GL state + */ +typedef struct { + CRAttribBits attrib; + CRBufferBits buffer; +#ifdef CR_ARB_vertex_buffer_object + CRBufferObjectBits bufferobject; +#endif + CRClientBits client; + CRCurrentBits current; + CREvaluatorBits eval; + CRFeedbackBits feedback; + CRFogBits fog; + CRHintBits hint; + CRLightingBits lighting; + CRLineBits line; + CRListsBits lists; + CRMultisampleBits multisample; +#if CR_ARB_occlusion_query + CROcclusionBits occlusion; +#endif + CRPixelBits pixel; + CRPointBits point; + CRPolygonBits polygon; + CRProgramBits program; + CRRegCombinerBits regcombiner; + CRSelectionBits selection; + CRStencilBits stencil; + CRTextureBits texture; + CRTransformBits transform; + CRViewportBits viewport; +} CRStateBits; + +typedef void (*CRStateFlushFunc)( void *arg ); + + +typedef struct _CRSharedState { + CRHashTable *textureTable; /* all texture objects */ + CRHashTable *dlistTable; /* all display lists */ + CRHashTable *buffersTable; /* vbo/pbo */ + CRHashTable *fbTable; /* frame buffers */ + CRHashTable *rbTable; /* render buffers */ + + volatile int32_t refCount; + GLint id; /*unique shared state id, it's not always matching some existing context id!*/ + GLint saveCount; + + /* Indicates that we have to resend data to GPU on first glMakeCurrent call with owning context */ + GLboolean bTexResyncNeeded; + GLboolean bVBOResyncNeeded; + GLboolean bFBOResyncNeeded; +} CRSharedState; + +/** + * Chromium version of the state variables in OpenGL + */ +struct CRContext { + int id; + +#ifdef CHROMIUM_THREADSAFE + /* we keep reference counting of context's makeCurrent for different threads + * this is primarily needed to avoid having an invalid memory reference in the TLS + * when the context is assigned to more than one threads and then destroyed from + * one of those, i.e. + * 1. Thread1 -> MakeCurrent(ctx1); + * 2. Thread2 -> MakeCurrent(ctx1); + * 3. Thread1 -> Destroy(ctx1); + * => Thread2 still refers to destroyed ctx1 + * */ + VBOXTLSREFDATA +#endif + + CRbitvalue bitid[CR_MAX_BITARRAY]; + CRbitvalue neg_bitid[CR_MAX_BITARRAY]; + + CRSharedState *shared; + + GLenum renderMode; + + GLenum error; + + CRStateFlushFunc flush_func; + void *flush_arg; + + CRAttribState attrib; + CRBufferState buffer; +#ifdef CR_ARB_vertex_buffer_object + CRBufferObjectState bufferobject; +#endif + CRClientState client; + CRCurrentState current; + CREvaluatorState eval; + CRExtensionState extensions; + CRFeedbackState feedback; + CRFogState fog; + CRHintState hint; + CRLightingState lighting; + CRLimitsState limits; + CRLineState line; + CRListsState lists; + CRMultisampleState multisample; +#if CR_ARB_occlusion_query + CROcclusionState occlusion; +#endif + CRPixelState pixel; + CRPointState point; + CRPolygonState polygon; + CRProgramState program; + CRRegCombinerState regcombiner; + CRSelectionState selection; + CRStencilState stencil; + CRTextureState texture; + CRTransformState transform; + CRViewportState viewport; + +#ifdef CR_EXT_framebuffer_object + CRFramebufferObjectState framebufferobject; +#endif + +#ifdef CR_OPENGL_VERSION_2_0 + CRGLSLState glsl; +#endif + + /** For buffering vertices for selection/feedback */ + /*@{*/ + GLuint vCount; + CRVertex vBuffer[4]; + GLboolean lineReset; + GLboolean lineLoop; + /*@}*/ +}; + + +DECLEXPORT(void) crStateInit(void); +DECLEXPORT(void) crStateDestroy(void); +DECLEXPORT(void) crStateVBoxDetachThread(void); +DECLEXPORT(void) crStateVBoxAttachThread(void); +DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share); +DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID); +DECLEXPORT(void) crStateMakeCurrent(CRContext *ctx); +DECLEXPORT(void) crStateSetCurrent(CRContext *ctx); +DECLEXPORT(void) crStateCleanupCurrent(void); +DECLEXPORT(CRContext *) crStateGetCurrent(void); +DECLEXPORT(void) crStateDestroyContext(CRContext *ctx); +DECLEXPORT(GLboolean) crStateEnableDiffOnMakeCurrent(GLboolean fEnable); + +void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO); +void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO); + +void crStateSyncHWErrorState(CRContext *ctx); +GLenum crStateCleanHWErrorState(void); + +#define CR_STATE_CLEAN_HW_ERR_WARN(_s) do {\ + GLenum _err = crStateCleanHWErrorState(); \ + if (_err != GL_NO_ERROR) { \ + static int _cErrPrints = 0; \ + if (_cErrPrints < 5) { \ + ++_cErrPrints; \ + WARN(("%s %#x, ignoring.. (%d out of 5)", _s, _err, _cErrPrints)); \ + } \ + } \ + } while (0) + +DECLEXPORT(void) crStateFlushFunc( CRStateFlushFunc ff ); +DECLEXPORT(void) crStateFlushArg( void *arg ); +DECLEXPORT(void) crStateDiffAPI( SPUDispatchTable *api ); +DECLEXPORT(void) crStateUpdateColorBits( void ); + +DECLEXPORT(void) crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current ); +DECLEXPORT(void) crStateResetCurrentPointers( CRCurrentStatePointers *current ); + +DECLEXPORT(void) crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions ); + +DECLEXPORT(void) crStateDiffContext( CRContext *from, CRContext *to ); +DECLEXPORT(void) crStateSwitchContext( CRContext *from, CRContext *to ); + +DECLEXPORT(unsigned int) crStateHlpComponentsCount( GLenum pname ); + +typedef struct CRFBDataElement +{ + /* FBO, can be NULL */ + GLint idFBO; + /* to be used for glDraw/ReadBuffer, i.e. GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENTX */ + GLenum enmBuffer; + GLint posX; + GLint posY; + GLint width; + GLint height; + GLenum enmFormat; + GLenum enmType; + GLuint cbData; + GLvoid *pvData; +} CRFBDataElement; + +typedef struct CRFBData +{ + /* override default draw and read buffers to be used for offscreen rendering */ + GLint idOverrrideFBO; + uint32_t u32Version; + uint32_t cElements; + CRFBDataElement aElements[1]; +} CRFBData; + +DECLEXPORT(void) crStateApplyFBImage(CRContext *to, CRFBData *data); +DECLEXPORT(int) crStateAcquireFBImage(CRContext *to, CRFBData *data); +DECLEXPORT(void) crStateFreeFBImageLegacy(CRContext *to); + +DECLEXPORT(void) crStateGetTextureObjectAndImage(CRContext *g, GLenum texTarget, GLint level, + CRTextureObj **obj, CRTextureLevel **img); + + +DECLEXPORT(void) crStateReleaseTexture(CRContext *pCtx, CRTextureObj *pObj); + +#ifndef IN_GUEST +DECLEXPORT(int32_t) crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM); +typedef DECLCALLBACK(CRContext*) FNCRSTATE_CONTEXT_GET(void*); +typedef FNCRSTATE_CONTEXT_GET *PFNCRSTATE_CONTEXT_GET; +DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM, uint32_t u32Version); +DECLEXPORT(void) crStateFreeShared(CRContext *pContext, CRSharedState *s); + +DECLEXPORT(int32_t) crStateLoadGlobals(PSSMHANDLE pSSM, uint32_t u32Version); +DECLEXPORT(int32_t) crStateSaveGlobals(PSSMHANDLE pSSM); + +DECLEXPORT(CRSharedState *) crStateGlobalSharedAcquire(void); +DECLEXPORT(void) crStateGlobalSharedRelease(void); +#endif + +DECLEXPORT(void) crStateSetTextureUsed(GLuint texture, GLboolean used); +DECLEXPORT(void) crStatePinTexture(GLuint texture, GLboolean pin); +DECLEXPORT(void) crStateDeleteTextureCallback(void *texObj); + + /* XXX move these! */ + +DECLEXPORT(void) STATE_APIENTRY +crStateChromiumParameteriCR( GLenum target, GLint value ); + +DECLEXPORT(void) STATE_APIENTRY +crStateChromiumParameterfCR( GLenum target, GLfloat value ); + +DECLEXPORT(void) STATE_APIENTRY +crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values ); + +DECLEXPORT(void) STATE_APIENTRY +crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type, + GLsizei count, GLvoid *values ); + +DECLEXPORT(void) STATE_APIENTRY +crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ); + +DECLEXPORT(void) STATE_APIENTRY crStateShareContext(GLboolean value); +DECLEXPORT(void) STATE_APIENTRY crStateShareLists(CRContext *pContext1, CRContext *pContext2); +DECLEXPORT(void) STATE_APIENTRY crStateSetSharedContext(CRContext *pCtx); +DECLEXPORT(GLboolean) STATE_APIENTRY crStateContextIsShared(CRContext *pCtx); + +DECLEXPORT(void) STATE_APIENTRY crStateQueryHWState(GLuint fbFbo, GLuint bbFbo); +#ifdef __cplusplus +} +#endif + +#endif /* CR_GLSTATE_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_hash.h b/src/VBox/GuestHost/OpenGL/include/cr_hash.h new file mode 100644 index 00000000..51302617 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_hash.h @@ -0,0 +1,70 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_HASH_H +#define CR_HASH_H + +#include "chromium.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct CRHashIdPool CRHashIdPool; +typedef struct CRHashTable CRHashTable; + +/* Callback function used for freeing/deleting table entries */ +typedef void (*CRHashtableCallback)(void *data); +typedef void (*CRHashtableCallbackEx)(void *data1, void *data2); +/* Callback function used for walking through table entries */ +typedef void (*CRHashtableWalkCallback)(unsigned long key, void *data1, void *data2); +/* Callback function used for walking through allocated keys */ +typedef void (*CRHashIdWalkKeys)(unsigned long firstKey, unsigned long count, void *data); + +DECLEXPORT(CRHashIdPool *) crAllocHashIdPool( void ); +DECLEXPORT(CRHashIdPool *) crAllocHashIdPoolEx( GLuint min, GLuint max ); +DECLEXPORT(void) crFreeHashIdPool( CRHashIdPool *pool ); +DECLEXPORT(GLboolean) crHashIdPoolIsIdFree( const CRHashIdPool *pool, GLuint id ); +DECLEXPORT(GLuint) crHashIdPoolAllocBlock( CRHashIdPool *pool, GLuint count ); +DECLEXPORT(void) crHashIdPoolFreeBlock( CRHashIdPool *pool, GLuint first, GLuint count ); +/* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */ +DECLEXPORT(GLboolean) crHashIdPoolAllocId( CRHashIdPool *pool, GLuint id ); +DECLEXPORT(void) crHashIdWalkKeys( CRHashIdPool *pool, CRHashIdWalkKeys walkFunc , void *data); + +DECLEXPORT(CRHashTable *) crAllocHashtable( void ); +DECLEXPORT(CRHashTable *) crAllocHashtableEx( GLuint min, GLuint max ); +DECLEXPORT(void) crFreeHashtable( CRHashTable *hash, CRHashtableCallback deleteCallback ); +DECLEXPORT(void) crFreeHashtableEx( CRHashTable *hash, CRHashtableCallbackEx deleteCallback, void *pData ); +DECLEXPORT(void) crHashtableAdd( CRHashTable *h, unsigned long key, void *data ); +/* to ensure hash table pool id consistency, there is no crHashTableFreeKeys/UnregisterKey, + * one should call crHashtableDelete to free unneeded keys, + * which will also ensure there is no entry with the specified key left in the table */ +DECLEXPORT(GLuint) crHashtableAllocKeys( CRHashTable *h, GLsizei range ); +/* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */ +DECLEXPORT(GLboolean) crHashtableAllocRegisterKey( CRHashTable *h, GLuint key); +DECLEXPORT(void) crHashtableDelete( CRHashTable *h, unsigned long key, CRHashtableCallback deleteCallback ); +DECLEXPORT(void) crHashtableDeleteEx( CRHashTable *h, unsigned long key, CRHashtableCallbackEx deleteCallback, void *pData ); +DECLEXPORT(void) crHashtableDeleteBlock( CRHashTable *h, unsigned long key, GLsizei range, CRHashtableCallback deleteFunc ); +DECLEXPORT(void *) crHashtableSearch( const CRHashTable *h, unsigned long key ); +DECLEXPORT(void) crHashtableReplace( CRHashTable *h, unsigned long key, void *data, CRHashtableCallback deleteFunc); +DECLEXPORT(unsigned int) crHashtableNumElements( const CRHashTable *h) ; +DECLEXPORT(GLboolean) crHashtableIsKeyUsed( const CRHashTable *h, GLuint id ); +DECLEXPORT(void) crHashtableWalk( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data); +/* walk the hashtable w/o holding the table lock */ +DECLEXPORT(void) crHashtableWalkUnlocked( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *data); +/*Returns GL_TRUE if given hashtable hold the data, pKey is updated with key value for data in this case*/ +DECLEXPORT(GLboolean) crHashtableGetDataKey(CRHashTable *pHash, void *pData, unsigned long *pKey); +DECLEXPORT(void) crHashtableLock(CRHashTable *h); +DECLEXPORT(void) crHashtableUnlock(CRHashTable *h); +DECLEXPORT(void) crHashtableWalkKeys(CRHashTable *hash, CRHashIdWalkKeys walkFunc , void *data); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CR_HASH_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_htable.h b/src/VBox/GuestHost/OpenGL/include/cr_htable.h new file mode 100644 index 00000000..5c12829a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_htable.h @@ -0,0 +1,120 @@ +/* $Id: cr_htable.h $ */ + +/** @file + * uint32_t handle to void simple table API + */ + +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ +#ifndef ___cr_htable_h_ +#define ___cr_htable_h_ + +#include +#include + +#include + +#ifndef IN_RING0 +# define VBOXHTABLEDECL(_type) DECLEXPORT(_type) +#else +# define VBOXHTABLEDECL(_type) RTDECL(_type) +#endif + + + +RT_C_DECLS_BEGIN + +typedef uint32_t CRHTABLE_HANDLE; +#define CRHTABLE_HANDLE_INVALID 0UL + +typedef struct CRHTABLE +{ + uint32_t cData; + uint32_t iNext2Search; + uint32_t cSize; + void **paData; +} CRHTABLE, *PCRHTABLE; + +typedef struct CRHTABLE_ITERATOR +{ + PCRHTABLE pTbl; + uint32_t iCur; + uint32_t cLeft; +} VCRHTABLE_ITERATOR, *PCRHTABLE_ITERATOR; + +/*private stuff, not to be used directly */ +DECLINLINE(CRHTABLE_HANDLE) crHTableIndex2Handle(uint32_t iIndex) +{ + return iIndex+1; +} + +DECLINLINE(uint32_t) crHTableHandle2Index(CRHTABLE_HANDLE hHandle) +{ + return hHandle-1; +} + +/* public API */ +DECLINLINE(void) CrHTableIterInit(PCRHTABLE pTbl, PCRHTABLE_ITERATOR pIter) +{ + pIter->pTbl = pTbl; + pIter->iCur = 0; + pIter->cLeft = pTbl->cData; +} + +DECLINLINE(void*) CrHTableIterNext(PCRHTABLE_ITERATOR pIter, CRHTABLE_HANDLE *phHandle) +{ + PCRHTABLE pTbl; + uint32_t i; + if (!pIter->cLeft) + { + if (phHandle) + *phHandle = 0; + return NULL; + } + + pTbl = pIter->pTbl; + + for (i = pIter->iCur; i < pTbl->cSize; ++i) + { + if (pTbl->paData[i]) + { + pIter->iCur = i+1; + --(pIter->cLeft); + if (phHandle) + *phHandle = crHTableIndex2Handle(i); + return pTbl->paData[i]; + } + } + + crWarning("interator concurent modification!"); + return NULL; +} + +VBOXHTABLEDECL(int) CrHTableCreate(PCRHTABLE pTbl, uint32_t cSize); +DECLINLINE(void) CrHTableMoveTo(PCRHTABLE pSrcTbl, PCRHTABLE pDstTbl) +{ + *pDstTbl = *pSrcTbl; + CrHTableCreate(pSrcTbl, 0); +} +VBOXHTABLEDECL(void) CrHTableEmpty(PCRHTABLE pTbl); +VBOXHTABLEDECL(void) CrHTableDestroy(PCRHTABLE pTbl); +VBOXHTABLEDECL(int) CrHTableRealloc(PCRHTABLE pTbl, uint32_t cNewSize); +VBOXHTABLEDECL(CRHTABLE_HANDLE) CrHTablePut(PCRHTABLE pTbl, void *pvData); +VBOXHTABLEDECL(int) CrHTablePutToSlot(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle, void* pvData); + +/* note: can be called for the element returned with CrHTableIterNext w/o corrupting the iterator */ +VBOXHTABLEDECL(void*) CrHTableRemove(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle); +VBOXHTABLEDECL(void*) CrHTableGet(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle); + +RT_C_DECLS_END + +#endif /* #ifndef ___cr_htable_h_*/ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_hull.h b/src/VBox/GuestHost/OpenGL/include/cr_hull.h new file mode 100644 index 00000000..9fa6ea10 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_hull.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_HULL_H +#define CR_HULL_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DECLEXPORT(void) crHullInteriorBox(const double *pnts, int npnts, double *bbox); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_BBOX_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_list.h b/src/VBox/GuestHost/OpenGL/include/cr_list.h new file mode 100644 index 00000000..8290df38 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_list.h @@ -0,0 +1,48 @@ +#ifndef CR_LIST_H +#define CR_LIST_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct CRList CRList; +typedef struct CRListIterator CRListIterator; +typedef int ( *CRListCompareFunc ) ( const void *element1, const void *element2 ); +typedef void ( *CRListApplyFunc ) ( void *element, void *arg ); + +DECLEXPORT(CRList *) crAllocList( void ); +DECLEXPORT(void) crFreeList( CRList *l ); + +DECLEXPORT(unsigned) crListSize( const CRList *l ); +DECLEXPORT(int) crListIsEmpty( const CRList *l ); + +DECLEXPORT(void) crListInsert( CRList *l, CRListIterator *iter, void *elem ); +DECLEXPORT(void) crListErase( CRList *l, CRListIterator *iter ); +DECLEXPORT(void) crListClear( CRList *l ); + +DECLEXPORT(void) crListPushBack( CRList *l, void *elem ); +DECLEXPORT(void) crListPushFront( CRList *l, void *elem ); + +DECLEXPORT(void) crListPopBack( CRList *l ); +DECLEXPORT(void) crListPopFront( CRList *l ); + +DECLEXPORT(void *) crListFront( CRList *l ); +DECLEXPORT(void *) crListBack( CRList *l ); + +DECLEXPORT(CRListIterator *) crListBegin( CRList *l ); +DECLEXPORT(CRListIterator *) crListEnd( CRList *l ); + +DECLEXPORT(CRListIterator *) crListNext( CRListIterator *iter ); +DECLEXPORT(CRListIterator *) crListPrev( CRListIterator *iter ); +DECLEXPORT(void *) crListElement( CRListIterator *iter ); + +DECLEXPORT(CRListIterator *) crListFind( CRList *l, void *element, CRListCompareFunc compare ); +DECLEXPORT(void) crListApply( CRList *l, CRListApplyFunc apply, void *arg ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CR_LIST_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_logo.h b/src/VBox/GuestHost/OpenGL/include/cr_logo.h new file mode 100644 index 00000000..8987db7d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_logo.h @@ -0,0 +1,2746 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_LOGO_H +#define CR_LOGO_H + +#define CR_LOGO_H_WIDTH 128 +#define CR_LOGO_H_HEIGHT 64 + +static unsigned char raw_bytes[] = { +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x03, 0x03, 0x03, 0x00, 0x11, 0x11, 0x11, 0x00, 0x14, 0x14, 0x14, 0x00, +0x13, 0x13, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x2f, 0x2f, 0x2f, 0x00, +0x1d, 0x1d, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x0e, 0x0e, 0x0e, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, +0x09, 0x09, 0x09, 0x00, 0x0b, 0x0b, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, +0x01, 0x01, 0x01, 0x00, 0x11, 0x11, 0x11, 0x00, 0x04, 0x04, 0x04, 0x00, +0x11, 0x11, 0x11, 0x00, 0x14, 0x14, 0x14, 0x00, 0x14, 0x14, 0x14, 0x00, +0x14, 0x14, 0x14, 0x00, 0x06, 0x06, 0x06, 0x00, 0x09, 0x09, 0x09, 0x00, +0x13, 0x13, 0x13, 0x00, 0x14, 0x14, 0x14, 0x00, 0x0e, 0x0e, 0x0e, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, +0x13, 0x13, 0x13, 0x00, 0x14, 0x14, 0x14, 0x00, 0x14, 0x14, 0x14, 0x00, +0x0e, 0x0e, 0x0e, 0x00, 0x03, 0x03, 0x03, 0x00, 0x11, 0x11, 0x11, 0x00, +0x14, 0x14, 0x14, 0x00, 0x0c, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x03, 0x03, 0x03, 0x00, 0x11, 0x11, 0x11, 0x00, 0x14, 0x14, 0x14, 0x00, +0x11, 0x11, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x0b, 0x0b, 0x0b, 0x00, 0x0a, 0x0a, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x15, 0x15, 0x15, 0x00, +0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x59, 0x59, 0x38, +0xed, 0xed, 0xed, 0x80, 0xe0, 0xe0, 0xe0, 0x83, 0xe6, 0xe6, 0xe6, 0x82, +0xa4, 0xa4, 0xa4, 0x58, 0x00, 0x00, 0x00, 0x00, 0x32, 0x32, 0x32, 0x03, +0xcd, 0xcd, 0xcd, 0x6e, 0xd3, 0xd3, 0xd3, 0xb1, 0xe8, 0xe8, 0xe8, 0x9a, +0x74, 0x74, 0x74, 0x38, 0x0b, 0x0b, 0x0b, 0x05, 0xdc, 0xdc, 0xdc, 0x78, +0x29, 0x29, 0x29, 0x2a, 0x08, 0x08, 0x08, 0x00, 0xdc, 0xdc, 0xdc, 0x76, +0x99, 0x99, 0x99, 0x62, 0x00, 0x00, 0x00, 0x00, 0x85, 0x85, 0x85, 0x3f, +0xa8, 0xa8, 0xa8, 0x74, 0x57, 0x57, 0x57, 0x45, 0xec, 0xec, 0xec, 0x80, +0xdf, 0xdf, 0xdf, 0x83, 0xdf, 0xdf, 0xdf, 0x83, 0xd7, 0xd7, 0xd7, 0x83, +0x2b, 0x2b, 0x2b, 0x39, 0xbd, 0xbd, 0xbd, 0x6b, 0xe5, 0xe5, 0xe5, 0x82, +0xe0, 0xe0, 0xe0, 0x83, 0xde, 0xde, 0xde, 0x81, 0x5c, 0x5c, 0x5c, 0x2f, +0x00, 0x00, 0x00, 0x01, 0xc3, 0xc3, 0xc3, 0x70, 0xe4, 0xe4, 0xe4, 0x82, +0xdf, 0xdf, 0xdf, 0x83, 0xdf, 0xdf, 0xdf, 0x83, 0x7d, 0x7d, 0x7d, 0x61, +0x51, 0x51, 0x51, 0x40, 0xed, 0xed, 0xed, 0x80, 0xe0, 0xe0, 0xe0, 0x83, +0xda, 0xda, 0xda, 0x7c, 0x55, 0x55, 0x55, 0x26, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x59, 0x59, 0x38, +0xed, 0xed, 0xed, 0x80, 0xe0, 0xe0, 0xe0, 0x83, 0xdf, 0xdf, 0xdf, 0x81, +0x88, 0x88, 0x88, 0x47, 0x01, 0x01, 0x01, 0x00, 0x4b, 0x4b, 0x4b, 0x40, +0xd5, 0xd5, 0xd5, 0x7a, 0x0e, 0x0e, 0x0e, 0x0c, 0x00, 0x00, 0x00, 0x00, +0xa4, 0xa4, 0xa4, 0x4b, 0xaf, 0xaf, 0xaf, 0x7e, 0x00, 0x00, 0x00, 0x15, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x9f, 0x9f, 0x9f, 0x8f, 0xa4, 0xa4, 0xa4, 0xff, +0x09, 0x09, 0x09, 0xfb, 0x2f, 0x2f, 0x2f, 0xff, 0xf9, 0xf9, 0xf9, 0xff, +0x3e, 0x3e, 0x3e, 0x5b, 0xd8, 0xd8, 0xd8, 0xa4, 0x8d, 0x8d, 0x8d, 0xff, +0x0d, 0x0d, 0x0d, 0xf2, 0x44, 0x44, 0x44, 0xff, 0xec, 0xec, 0xec, 0xeb, +0x3a, 0x3a, 0x3a, 0x5d, 0xd6, 0xd6, 0xd6, 0xff, 0x27, 0x27, 0x27, 0x8d, +0x71, 0x71, 0x71, 0x61, 0xff, 0xff, 0xff, 0xff, 0x9a, 0x9a, 0x9a, 0xeb, +0x0a, 0x0a, 0x0a, 0x48, 0xe8, 0xe8, 0xe8, 0xda, 0x42, 0x42, 0x42, 0xe2, +0x93, 0x93, 0x93, 0xc2, 0xa7, 0xa7, 0xa7, 0xff, 0x0b, 0x0b, 0x0b, 0xf9, +0x0c, 0x0c, 0x0c, 0xf8, 0x0e, 0x0e, 0x0e, 0xf3, 0x24, 0x24, 0x24, 0x98, +0xeb, 0xeb, 0xeb, 0xfd, 0x28, 0x28, 0x28, 0xff, 0x04, 0x04, 0x04, 0xf9, +0x92, 0x92, 0x92, 0xff, 0xc3, 0xc3, 0xc3, 0xd0, 0x1f, 0x1f, 0x1f, 0x42, +0xeb, 0xeb, 0xeb, 0xfc, 0x2f, 0x2f, 0x2f, 0xff, 0x0c, 0x0c, 0x0c, 0xf8, +0x0c, 0x0c, 0x0c, 0xf8, 0x07, 0x07, 0x07, 0xc1, 0x9e, 0x9e, 0x9e, 0xb9, +0xac, 0xac, 0xac, 0xff, 0x14, 0x14, 0x14, 0xfd, 0x61, 0x61, 0x61, 0xff, +0xe7, 0xe7, 0xe7, 0xd9, 0x15, 0x15, 0x15, 0x2b, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x9f, 0x9f, 0x9f, 0x8f, 0xa1, 0xa1, 0xa1, 0xff, +0x02, 0x02, 0x02, 0xfa, 0x50, 0x50, 0x50, 0xff, 0xfb, 0xfb, 0xfb, 0xf7, +0x0e, 0x0e, 0x0e, 0x3b, 0x06, 0x06, 0x06, 0x5a, 0xdd, 0xdd, 0xdd, 0xff, +0x6c, 0x6c, 0x6c, 0x7a, 0x69, 0x69, 0x69, 0x40, 0xea, 0xea, 0xea, 0xf9, +0x20, 0x20, 0x20, 0xe2, 0x41, 0x41, 0x41, 0x56, 0x44, 0x44, 0x44, 0x0f, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x06, +0xc6, 0xc6, 0xc6, 0xca, 0xa2, 0xa2, 0xa2, 0xfc, 0x4b, 0x4b, 0x4b, 0xc5, +0xa1, 0xa1, 0xa1, 0xcd, 0xbf, 0xbf, 0xbf, 0xff, 0x69, 0x69, 0x69, 0xdc, +0xd1, 0xd1, 0xd1, 0xff, 0x01, 0x01, 0x01, 0xe2, 0x00, 0x00, 0x00, 0xba, +0x00, 0x00, 0x00, 0xb7, 0xd2, 0xd2, 0xd2, 0xff, 0x59, 0x59, 0x59, 0xc9, +0xb7, 0xb7, 0xb7, 0xf2, 0x50, 0x50, 0x50, 0xc8, 0xd1, 0xd1, 0xd1, 0xe1, +0xaf, 0xaf, 0xaf, 0xff, 0xa2, 0xa2, 0xa2, 0xf2, 0x79, 0x79, 0x79, 0xb7, +0xc2, 0xc2, 0xc2, 0xfd, 0x00, 0x00, 0x00, 0xd5, 0xc1, 0xc1, 0xc1, 0xed, +0xd7, 0xd7, 0xd7, 0xf9, 0x9c, 0x9c, 0x9c, 0xdb, 0xa5, 0xa5, 0xa5, 0xcd, +0x5a, 0x5a, 0x5a, 0xb7, 0x4a, 0x4a, 0x4a, 0xaf, 0xf0, 0xf0, 0xf0, 0xfd, +0x72, 0x72, 0x72, 0xe0, 0x6b, 0x6b, 0x6b, 0xbb, 0xd2, 0xd2, 0xd2, 0xec, +0x70, 0x70, 0x70, 0xf7, 0x44, 0x44, 0x44, 0xb7, 0xfa, 0xfa, 0xfa, 0xfc, +0xa8, 0xa8, 0xa8, 0xe9, 0xa1, 0xa1, 0xa1, 0xd1, 0x9c, 0x9c, 0x9c, 0xcb, +0x20, 0x20, 0x20, 0xa1, 0xc1, 0xc1, 0xc1, 0xe0, 0x6c, 0x6c, 0x6c, 0xf8, +0x00, 0x00, 0x00, 0xc6, 0x09, 0x09, 0x09, 0xc3, 0xed, 0xed, 0xed, 0xff, +0x34, 0x34, 0x34, 0x94, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, +0xc5, 0xc5, 0xc5, 0xca, 0xcb, 0xcb, 0xcb, 0xfc, 0x8d, 0x8d, 0x8d, 0xca, +0xc4, 0xc4, 0xc4, 0xdf, 0x8f, 0x8f, 0x8f, 0xff, 0x02, 0x02, 0x02, 0x94, +0x00, 0x00, 0x00, 0x34, 0x68, 0x68, 0x68, 0xdd, 0xee, 0xee, 0xee, 0xe9, +0xf2, 0xf2, 0xf2, 0xe3, 0x41, 0x41, 0x41, 0xf9, 0x00, 0x00, 0x00, 0xbe, +0x85, 0x85, 0x85, 0xdb, 0x67, 0x67, 0x67, 0xa1, 0x00, 0x00, 0x00, 0x0e, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x14, 0xe8, 0xe8, 0xe8, 0xed, +0xc1, 0xc1, 0xc1, 0xff, 0xb3, 0xb3, 0xb3, 0xef, 0xa8, 0xa8, 0xa8, 0xf8, +0x20, 0x20, 0x20, 0xf2, 0x8a, 0x8a, 0x8a, 0xf1, 0xab, 0xab, 0xab, 0xfd, +0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x43, 0x25, 0x25, 0x25, 0x3c, +0xed, 0xed, 0xed, 0xf8, 0x33, 0x33, 0x33, 0xe3, 0xb9, 0xb9, 0xb9, 0xf4, +0xc0, 0xc0, 0xc0, 0xed, 0xa4, 0xa4, 0xa4, 0xfb, 0x57, 0x57, 0x57, 0xf5, +0xcc, 0xcc, 0xcc, 0xf9, 0xe2, 0xe2, 0xe2, 0xf6, 0x46, 0x46, 0x46, 0xf2, +0x08, 0x08, 0x08, 0xb9, 0xe4, 0xe4, 0xe4, 0xf2, 0x83, 0x83, 0x83, 0xff, +0x6b, 0x6b, 0x6b, 0xfc, 0x70, 0x70, 0x70, 0xfb, 0x35, 0x35, 0x35, 0xbe, +0x7d, 0x7d, 0x7d, 0xa7, 0xd5, 0xd5, 0xd5, 0xff, 0x98, 0x98, 0x98, 0xfb, +0xff, 0xff, 0xff, 0xf5, 0x6f, 0x6f, 0x6f, 0xf6, 0x00, 0x00, 0x00, 0xdc, +0x83, 0x83, 0x83, 0xd3, 0xd0, 0xd0, 0xd0, 0xff, 0x69, 0x69, 0x69, 0xfe, +0x6c, 0x6c, 0x6c, 0xfa, 0x65, 0x65, 0x65, 0xf4, 0x21, 0x21, 0x21, 0x8e, +0xe3, 0xe3, 0xe3, 0xed, 0x37, 0x37, 0x37, 0xeb, 0x00, 0x00, 0x00, 0x67, +0x3a, 0x3a, 0x3a, 0x55, 0xec, 0xec, 0xec, 0xff, 0x18, 0x18, 0x18, 0xc4, +0x00, 0x00, 0x00, 0x1f, 0x12, 0x12, 0x12, 0x0f, 0xe5, 0xe5, 0xe5, 0xed, +0x9b, 0x9b, 0x9b, 0xff, 0x8d, 0x8d, 0x8d, 0xf8, 0xc0, 0xc0, 0xc0, 0xfc, +0x9e, 0x9e, 0x9e, 0xf5, 0x02, 0x02, 0x02, 0x94, 0x00, 0x00, 0x00, 0x15, +0x10, 0x10, 0x10, 0x8b, 0xf3, 0xf3, 0xf3, 0xff, 0x80, 0x80, 0x80, 0xff, +0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x8e, +0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x3f, 0x3f, 0x3f, 0x3d, 0xe7, 0xe7, 0xe7, 0xfc, 0x10, 0x10, 0x10, 0xf9, +0x00, 0x00, 0x00, 0xec, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0xc2, +0x66, 0x66, 0x66, 0xd8, 0xe2, 0xe2, 0xe2, 0xff, 0x1d, 0x1d, 0x1d, 0x87, +0x16, 0x16, 0x16, 0x00, 0xc2, 0xc2, 0xc2, 0x73, 0xaa, 0xaa, 0xaa, 0xff, +0x03, 0x03, 0x03, 0xd5, 0xc4, 0xc4, 0xc4, 0xf5, 0xff, 0xff, 0xff, 0xff, +0x3a, 0x3a, 0x3a, 0xee, 0x37, 0x37, 0x37, 0xe5, 0xff, 0xff, 0xff, 0xff, +0xc0, 0xc0, 0xc0, 0xff, 0x00, 0x00, 0x00, 0xd5, 0x3d, 0x3d, 0x3d, 0x9b, +0xea, 0xea, 0xea, 0xf8, 0x18, 0x18, 0x18, 0xee, 0x06, 0x06, 0x06, 0xca, +0x05, 0x05, 0x05, 0xbb, 0x03, 0x03, 0x03, 0x9e, 0xbb, 0xbb, 0xbb, 0xd1, +0x7e, 0x7e, 0x7e, 0xfe, 0x00, 0x00, 0x00, 0xed, 0xa9, 0xa9, 0xa9, 0xff, +0x94, 0x94, 0x94, 0xed, 0x00, 0x00, 0x00, 0xa2, 0xbb, 0xbb, 0xbb, 0xcc, +0x8c, 0x8c, 0x8c, 0xfd, 0x06, 0x06, 0x06, 0xdc, 0x05, 0x05, 0x05, 0xbf, +0x05, 0x05, 0x05, 0xb1, 0x3e, 0x3e, 0x3e, 0xa5, 0xea, 0xea, 0xea, 0xfd, +0x1f, 0x1f, 0x1f, 0xcb, 0x30, 0x30, 0x30, 0x33, 0xd9, 0xd9, 0xd9, 0x8b, +0x9a, 0x9a, 0x9a, 0xff, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0x1d, +0x3f, 0x3f, 0x3f, 0x38, 0xea, 0xea, 0xea, 0xfc, 0x15, 0x15, 0x15, 0xf1, +0x02, 0x02, 0x02, 0xd2, 0x87, 0x87, 0x87, 0xec, 0xd2, 0xd2, 0xd2, 0xff, +0x04, 0x04, 0x04, 0x7c, 0x00, 0x00, 0x00, 0x01, 0x21, 0x21, 0x21, 0x41, +0xec, 0xec, 0xec, 0xfc, 0x21, 0x21, 0x21, 0xfa, 0x00, 0x00, 0x00, 0xa0, +0x0f, 0x0f, 0x0f, 0x1d, 0x26, 0x26, 0x26, 0x26, 0x00, 0x00, 0x00, 0x59, +0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0x7c, +0xb6, 0xb6, 0xb6, 0xff, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x94, +0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x4b, 0x0a, 0x0a, 0x0a, 0x84, +0xac, 0xac, 0xac, 0xff, 0xe0, 0xe0, 0xe0, 0xc7, 0xda, 0xda, 0xda, 0x95, +0xaf, 0xaf, 0xaf, 0xf8, 0x11, 0x11, 0x11, 0xed, 0x00, 0x00, 0x00, 0xb3, +0xb1, 0xb1, 0xb1, 0xef, 0xbb, 0xbb, 0xbb, 0xff, 0x00, 0x00, 0x00, 0xdb, +0x3f, 0x3f, 0x3f, 0xc7, 0xed, 0xed, 0xed, 0xff, 0x47, 0x47, 0x47, 0xff, +0x00, 0x00, 0x00, 0xa5, 0x60, 0x60, 0x60, 0x9c, 0xec, 0xec, 0xec, 0xff, +0xe0, 0xe0, 0xe0, 0xed, 0xe0, 0xe0, 0xe0, 0xcb, 0xe0, 0xe0, 0xe0, 0xc0, +0x5f, 0x5f, 0x5f, 0x90, 0xbd, 0xbd, 0xbd, 0xea, 0x4a, 0x4a, 0x4a, 0xf4, +0x00, 0x00, 0x00, 0xa4, 0x3a, 0x3a, 0x3a, 0xd1, 0xdc, 0xdc, 0xdc, 0xff, +0x26, 0x26, 0x26, 0x81, 0xc3, 0xc3, 0xc3, 0xe6, 0xe5, 0xe5, 0xe5, 0xfd, +0xe0, 0xe0, 0xe0, 0xdb, 0xe0, 0xe0, 0xe0, 0xc2, 0xac, 0xac, 0xac, 0xad, +0x66, 0x66, 0x66, 0xa8, 0xec, 0xec, 0xec, 0xff, 0xdf, 0xdf, 0xdf, 0xdc, +0xde, 0xde, 0xde, 0xc3, 0x9a, 0x9a, 0x9a, 0xfe, 0x0f, 0x0f, 0x0f, 0xf0, +0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x05, 0x60, 0x60, 0x60, 0x78, +0xec, 0xec, 0xec, 0xff, 0xe0, 0xe0, 0xe0, 0xef, 0xe0, 0xe0, 0xe0, 0xd5, +0xc9, 0xc9, 0xc9, 0xf5, 0x40, 0x40, 0x40, 0xfb, 0x00, 0x00, 0x00, 0x8b, +0x00, 0x00, 0x00, 0x00, 0x4e, 0x4e, 0x4e, 0x5f, 0xc9, 0xc9, 0xc9, 0xff, +0x07, 0x07, 0x07, 0xd7, 0x00, 0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x53, +0xae, 0xae, 0xae, 0xad, 0x01, 0x01, 0x01, 0x1d, 0x00, 0x00, 0x00, 0x01, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x06, 0x05, 0x05, 0x69, 0x05, 0x05, 0x05, 0xe4, +0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x04, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0xc4, +0x27, 0x27, 0x27, 0xff, 0x25, 0x24, 0x24, 0xff, 0x00, 0x00, 0x00, 0xe7, +0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x5e, 0x08, 0x08, 0x08, 0xb3, +0x02, 0x02, 0x02, 0xf9, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x78, +0x0a, 0x0a, 0x0a, 0xe6, 0x00, 0x00, 0x00, 0xed, 0x00, 0x00, 0x00, 0x61, +0x04, 0x04, 0x04, 0x6a, 0x0c, 0x0c, 0x0c, 0xec, 0x0f, 0x0f, 0x0f, 0xfd, +0x0f, 0x0f, 0x0f, 0xf5, 0x0f, 0x0f, 0x0f, 0xf3, 0x02, 0x02, 0x02, 0xb8, +0x0a, 0x0a, 0x0a, 0xd3, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x4b, +0x00, 0x00, 0x00, 0x62, 0x0c, 0x0c, 0x0c, 0xe5, 0x03, 0x03, 0x03, 0xab, +0x0a, 0x0a, 0x0a, 0xca, 0x0d, 0x0d, 0x0d, 0xfa, 0x0f, 0x0f, 0x0f, 0xf8, +0x0f, 0x0f, 0x0f, 0xf5, 0x08, 0x08, 0x08, 0xdd, 0x04, 0x04, 0x04, 0xb0, +0x0c, 0x0c, 0x0c, 0xec, 0x10, 0x10, 0x0f, 0xfd, 0x0c, 0x0c, 0x0b, 0xf7, +0x00, 0x00, 0x00, 0xe7, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x47, +0x00, 0x00, 0x00, 0x00, 0x05, 0x04, 0x04, 0x65, 0x0c, 0x0c, 0x0c, 0xeb, +0x10, 0x0f, 0x0f, 0xfb, 0x10, 0x10, 0x10, 0xf2, 0x01, 0x01, 0x01, 0xee, +0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x00, +0x03, 0x03, 0x03, 0x56, 0x06, 0x06, 0x06, 0xe0, 0x00, 0x00, 0x00, 0xac, +0x00, 0x00, 0x00, 0x11, 0x06, 0x06, 0x06, 0x61, 0x09, 0x09, 0x08, 0xd2, +0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x10, 0x0f, 0x10, 0x00, 0x10, 0x10, 0x0f, 0x00, +0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, +0x0e, 0x0e, 0x0e, 0x21, 0x0e, 0x0d, 0x0d, 0x73, 0x11, 0x10, 0x10, 0x4a, +0x11, 0x10, 0x10, 0x00, 0x11, 0x10, 0x10, 0x00, 0x12, 0x11, 0x10, 0x00, +0x12, 0x11, 0x10, 0x03, 0x10, 0x0f, 0x0e, 0x49, 0x0b, 0x09, 0x08, 0x9d, +0x0b, 0x09, 0x09, 0xb0, 0x10, 0x0f, 0x0e, 0x97, 0x12, 0x11, 0x10, 0x4d, +0x12, 0x10, 0x10, 0x0b, 0x0e, 0x0d, 0x0d, 0x45, 0x0e, 0x0e, 0x0d, 0x8f, +0x11, 0x10, 0x10, 0x4b, 0x10, 0x0f, 0x0f, 0x1a, 0x0c, 0x0c, 0x0c, 0x76, +0x10, 0x0f, 0x0f, 0x7c, 0x10, 0x10, 0x10, 0x1a, 0x0e, 0x0e, 0x0e, 0x1f, +0x0b, 0x0b, 0x0b, 0x8b, 0x0b, 0x0b, 0x0b, 0xb1, 0x0b, 0x0b, 0x0b, 0xaa, +0x0b, 0x0b, 0x0b, 0xa7, 0x0e, 0x0e, 0x0e, 0x87, 0x0c, 0x0c, 0x0c, 0x76, +0x0e, 0x0e, 0x0e, 0x75, 0x0f, 0x0f, 0x0f, 0x1e, 0x0f, 0x0f, 0x0f, 0x18, +0x0b, 0x0b, 0x0b, 0x74, 0x0e, 0x0e, 0x0e, 0x73, 0x0c, 0x0c, 0x0c, 0x6a, +0x0b, 0x0b, 0x0b, 0xa9, 0x0b, 0x0b, 0x0b, 0xad, 0x0b, 0x0b, 0x0b, 0xa9, +0x0c, 0x0c, 0x0c, 0x99, 0x0e, 0x0e, 0x0e, 0x70, 0x0c, 0x0c, 0x0b, 0x8b, +0x0d, 0x0c, 0x0b, 0xaa, 0x0d, 0x0c, 0x0c, 0xa2, 0x10, 0x0f, 0x0f, 0x8a, +0x12, 0x11, 0x10, 0x45, 0x12, 0x11, 0x10, 0x05, 0x11, 0x10, 0x10, 0x00, +0x10, 0x0f, 0x0e, 0x22, 0x0d, 0x0c, 0x0c, 0x87, 0x0d, 0x0c, 0x0c, 0xab, +0x0d, 0x0c, 0x0b, 0xa3, 0x0e, 0x0d, 0x0d, 0x9a, 0x11, 0x10, 0x10, 0x69, +0x11, 0x10, 0x10, 0x17, 0x11, 0x10, 0x10, 0x00, 0x0f, 0x0f, 0x0e, 0x17, +0x0d, 0x0d, 0x0c, 0x6d, 0x11, 0x10, 0x10, 0x54, 0x11, 0x10, 0x10, 0x00, +0x0e, 0x0e, 0x0e, 0x1b, 0x0d, 0x0d, 0x0d, 0x68, 0x11, 0x10, 0x10, 0x44, +0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, +0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, +0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10, 0x0f, 0x00, +0x10, 0x10, 0x0f, 0x00, 0x10, 0x10, 0x0f, 0x00, 0x10, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, 0x0f, 0x0f, 0x0f, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf1, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x0b, 0xf0, 0xef, 0xf0, 0x1c, +0xef, 0xef, 0xef, 0x31, 0xee, 0xec, 0xef, 0x47, 0xed, 0xeb, 0xed, 0x61, +0xea, 0xe8, 0xec, 0x7b, 0xe5, 0xe5, 0xeb, 0x87, 0xe1, 0xe2, 0xe9, 0x8e, +0xdb, 0xdf, 0xe7, 0x98, 0xd6, 0xdd, 0xe6, 0xa0, 0xd0, 0xdb, 0xe5, 0xa4, +0xcc, 0xd9, 0xe4, 0xaa, 0xca, 0xd7, 0xe3, 0xb9, 0xca, 0xd6, 0xe3, 0xc2, +0xcc, 0xd9, 0xe4, 0xb7, 0xcf, 0xda, 0xe5, 0xa7, 0xd5, 0xdb, 0xe6, 0xa0, +0xd9, 0xde, 0xe6, 0xa1, 0xdf, 0xe1, 0xe7, 0x9b, 0xe4, 0xe5, 0xea, 0x85, +0xe9, 0xe8, 0xec, 0x71, 0xec, 0xeb, 0xed, 0x67, 0xed, 0xed, 0xee, 0x4f, +0xef, 0xee, 0xef, 0x2b, 0xf0, 0xf0, 0xf0, 0x1a, 0xf0, 0xf0, 0xf0, 0x18, +0xf1, 0xf0, 0xf0, 0x17, 0xf0, 0xf0, 0xf0, 0x16, 0xf0, 0xf0, 0xf0, 0x17, +0xf0, 0xf0, 0xf0, 0x12, 0xf0, 0xf0, 0xf0, 0x0f, 0xf0, 0xf0, 0xf0, 0x0c, +0xf0, 0xf0, 0xf0, 0x02, 0xf0, 0xf0, 0xf0, 0x01, 0xf0, 0xf0, 0xf0, 0x0c, +0xf0, 0xf0, 0xf0, 0x0f, 0xf0, 0xf0, 0xf0, 0x0f, 0xf0, 0xf0, 0xf0, 0x18, +0xf0, 0xf0, 0xf0, 0x1b, 0xf0, 0xf0, 0xf0, 0x1c, 0xef, 0xef, 0xf0, 0x23, +0xe9, 0xeb, 0xee, 0x5a, 0xe1, 0xe5, 0xea, 0x9b, 0xd7, 0xdd, 0xe6, 0xb2, +0xd5, 0xdc, 0xe6, 0xb2, 0xd5, 0xdc, 0xe6, 0xa9, 0xd6, 0xdd, 0xe6, 0x9f, +0xd7, 0xde, 0xe7, 0x9c, 0xd8, 0xde, 0xe7, 0x9c, 0xda, 0xdf, 0xe7, 0x9f, +0xdb, 0xe0, 0xe8, 0xa4, 0xdc, 0xe0, 0xe8, 0xa7, 0xde, 0xe2, 0xe9, 0xa6, +0xe1, 0xe3, 0xe9, 0x9e, 0xe2, 0xe4, 0xea, 0x8f, 0xe3, 0xe4, 0xea, 0x84, +0xe5, 0xe5, 0xea, 0x81, 0xe6, 0xe6, 0xea, 0x7f, 0xe8, 0xe8, 0xec, 0x7f, +0xe9, 0xe9, 0xec, 0x76, 0xea, 0xe9, 0xed, 0x69, 0xec, 0xea, 0xed, 0x67, +0xeb, 0xea, 0xed, 0x68, 0xed, 0xeb, 0xee, 0x5a, 0xee, 0xec, 0xef, 0x4a, +0xee, 0xee, 0xef, 0x41, 0xef, 0xee, 0xef, 0x39, 0xef, 0xee, 0xef, 0x30, +0xef, 0xef, 0xf0, 0x27, 0xf0, 0xef, 0xf0, 0x1f, 0xf0, 0xef, 0xf0, 0x17, +0xf0, 0xf0, 0xf0, 0x0f, 0xf1, 0xf0, 0xf0, 0x09, 0xf0, 0xf0, 0xf0, 0x04, +0xf1, 0xf0, 0xf0, 0x00, 0xf1, 0xf1, 0xf0, 0x00, 0xf1, 0xf0, 0xf0, 0x00, +0xf1, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, +0xf0, 0xf0, 0xf0, 0x00, 0xf0, 0xf0, 0xf0, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c, +0xff, 0xff, 0xff, 0x29, 0xff, 0xff, 0xff, 0x4c, 0xfd, 0xfd, 0xff, 0x75, +0xf4, 0xf7, 0xfd, 0x9c, 0xe5, 0xee, 0xf9, 0xbd, 0xd0, 0xe7, 0xf5, 0xd6, +0xb7, 0xdc, 0xef, 0xe8, 0x9d, 0xd4, 0xeb, 0xf4, 0x85, 0xcf, 0xe9, 0xfa, +0x74, 0xcb, 0xe7, 0xff, 0x5e, 0xc6, 0xe5, 0xff, 0x53, 0xc3, 0xe2, 0xff, +0x4e, 0xc6, 0xe6, 0xff, 0x46, 0xc0, 0xde, 0xff, 0x3c, 0xbf, 0xde, 0xff, +0x39, 0xc2, 0xe1, 0xff, 0x38, 0xba, 0xd8, 0xff, 0x3a, 0xb8, 0xd6, 0xff, +0x40, 0xbe, 0xdd, 0xff, 0x4c, 0xc4, 0xe3, 0xff, 0x4f, 0xc5, 0xe6, 0xff, +0x59, 0xc4, 0xe4, 0xff, 0x72, 0xca, 0xe6, 0xff, 0x85, 0xce, 0xe7, 0xfc, +0xa0, 0xd5, 0xeb, 0xf1, 0xbb, 0xdd, 0xef, 0xe2, 0xd6, 0xe6, 0xf3, 0xcf, +0xeb, 0xf1, 0xf9, 0xb0, 0xf8, 0xf9, 0xfe, 0x86, 0xff, 0xfe, 0xff, 0x59, +0xff, 0xff, 0xff, 0x2f, 0xff, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x2b, 0xd3, 0xe5, 0xf2, 0xc1, +0x54, 0xb1, 0xd4, 0xff, 0x49, 0xc2, 0xe3, 0xff, 0x50, 0xc4, 0xe2, 0xff, +0x50, 0xc1, 0xde, 0xff, 0x4d, 0xc2, 0xdf, 0xff, 0x4f, 0xc0, 0xde, 0xff, +0x53, 0xc3, 0xe0, 0xff, 0x54, 0xc3, 0xe1, 0xff, 0x55, 0xc3, 0xe1, 0xff, +0x58, 0xc5, 0xe4, 0xff, 0x5c, 0xc4, 0xe0, 0xff, 0x61, 0xc6, 0xe3, 0xff, +0x62, 0xc5, 0xe1, 0xff, 0x69, 0xc8, 0xe3, 0xff, 0x74, 0xca, 0xe7, 0xff, +0x7a, 0xcb, 0xe6, 0xff, 0x81, 0xcc, 0xe6, 0xfc, 0x85, 0xcf, 0xe8, 0xfb, +0x8c, 0xd0, 0xe9, 0xfa, 0x92, 0xd1, 0xe8, 0xf6, 0xa1, 0xd4, 0xea, 0xf1, +0xa9, 0xd8, 0xed, 0xed, 0xb1, 0xdb, 0xef, 0xea, 0xba, 0xde, 0xf0, 0xe5, +0xc5, 0xe2, 0xf2, 0xde, 0xd0, 0xe5, 0xf4, 0xd5, 0xd7, 0xe7, 0xf3, 0xcd, +0xde, 0xeb, 0xf5, 0xc2, 0xe7, 0xf0, 0xf9, 0xb7, 0xee, 0xf4, 0xfc, 0xa9, +0xf3, 0xf6, 0xfd, 0x9a, 0xf7, 0xf8, 0xfd, 0x8a, 0xfc, 0xfb, 0xff, 0x7a, +0xff, 0xfe, 0xff, 0x68, 0xff, 0xff, 0xff, 0x56, 0xff, 0xff, 0xff, 0x46, +0xff, 0xff, 0xff, 0x34, 0xff, 0xff, 0xff, 0x24, 0xff, 0xff, 0xff, 0x18, +0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f, 0xfd, 0xfd, 0xff, 0x35, +0xfb, 0xfa, 0xfd, 0x67, 0xf0, 0xf2, 0xf8, 0x9e, 0xd7, 0xe6, 0xf2, 0xcb, +0xb2, 0xd8, 0xeb, 0xe9, 0x87, 0xcb, 0xe3, 0xfa, 0x60, 0xc4, 0xe0, 0xff, +0x45, 0xc3, 0xe2, 0xff, 0x30, 0xbc, 0xda, 0xff, 0x25, 0xbe, 0xdd, 0xff, +0x20, 0xc4, 0xe5, 0xff, 0x15, 0xbe, 0xdc, 0xff, 0x11, 0xba, 0xd7, 0xff, +0x10, 0xbf, 0xdf, 0xff, 0x09, 0xb9, 0xd8, 0xff, 0x0f, 0xba, 0xd7, 0xff, +0x11, 0xb8, 0xd7, 0xff, 0x11, 0xb9, 0xd9, 0xff, 0x0d, 0xb8, 0xd8, 0xff, +0x10, 0xb6, 0xd4, 0xff, 0x11, 0xb6, 0xd4, 0xff, 0x0e, 0xb5, 0xd3, 0xff, +0x09, 0xb5, 0xd4, 0xff, 0x01, 0xb5, 0xd7, 0xff, 0x03, 0xb8, 0xda, 0xff, +0x09, 0xb4, 0xd3, 0xff, 0x09, 0xb8, 0xd9, 0xff, 0x09, 0xb3, 0xd5, 0xff, +0x13, 0xb4, 0xd6, 0xff, 0x26, 0xb4, 0xd6, 0xff, 0x45, 0xb8, 0xd8, 0xff, +0x6e, 0xc0, 0xdb, 0xff, 0x9e, 0xce, 0xe4, 0xf3, 0xca, 0xdd, 0xec, 0xd7, +0xe9, 0xee, 0xf6, 0xa9, 0xf8, 0xf8, 0xfc, 0x6d, 0xfd, 0xfd, 0xfe, 0x34, +0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfc, 0xfe, 0x4a, 0xab, 0xd3, 0xe6, 0xea, 0x00, 0xaf, 0xd8, 0xff, +0x0a, 0xbe, 0xdd, 0xff, 0x10, 0xb6, 0xd3, 0xff, 0x14, 0xba, 0xd7, 0xff, +0x13, 0xbe, 0xde, 0xff, 0x12, 0xb7, 0xd5, 0xff, 0x14, 0xba, 0xd8, 0xff, +0x10, 0xb6, 0xd6, 0xff, 0x0d, 0xb6, 0xd5, 0xff, 0x0f, 0xb7, 0xd5, 0xff, +0x0e, 0xb9, 0xd7, 0xff, 0x0b, 0xb6, 0xd5, 0xff, 0x09, 0xb7, 0xd4, 0xff, +0x0e, 0xbb, 0xdb, 0xff, 0x09, 0xb7, 0xd7, 0xff, 0x09, 0xb8, 0xd7, 0xff, +0x11, 0xb9, 0xd6, 0xff, 0x12, 0xb6, 0xd3, 0xff, 0x18, 0xbb, 0xd9, 0xff, +0x14, 0xbc, 0xdc, 0xff, 0x1b, 0xc3, 0xe7, 0xff, 0x15, 0xb9, 0xd8, 0xff, +0x17, 0xba, 0xdc, 0xff, 0x1a, 0xb6, 0xd7, 0xff, 0x20, 0xb9, 0xdb, 0xff, +0x26, 0xba, 0xdc, 0xff, 0x29, 0xb2, 0xd2, 0xff, 0x39, 0xbf, 0xe0, 0xff, +0x4e, 0xc2, 0xe0, 0xff, 0x54, 0xbe, 0xda, 0xff, 0x5d, 0xc3, 0xdf, 0xff, +0x72, 0xc7, 0xe3, 0xff, 0x7f, 0xc8, 0xe2, 0xfc, 0x8e, 0xcb, 0xe3, 0xf7, +0xa4, 0xd3, 0xe7, 0xf0, 0xb3, 0xd8, 0xea, 0xe6, 0xc5, 0xdf, 0xee, 0xda, +0xd4, 0xe5, 0xf1, 0xca, 0xe1, 0xeb, 0xf4, 0xb7, 0xec, 0xf0, 0xf7, 0xa0, +0xf4, 0xf4, 0xf9, 0x87, 0xfa, 0xf9, 0xfb, 0x6d, 0xfd, 0xfc, 0xfd, 0x52, +0xfe, 0xfd, 0xfe, 0x38, 0xff, 0xfe, 0xff, 0x22, 0xff, 0xff, 0xff, 0x10, +0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x04, 0xfd, 0xfe, 0xff, 0x27, 0xfb, 0xfb, 0xfd, 0x61, +0xef, 0xf2, 0xf8, 0xa2, 0xcd, 0xe3, 0xf1, 0xd6, 0x99, 0xd1, 0xe7, 0xf5, +0x62, 0xc4, 0xe1, 0xff, 0x3c, 0xc2, 0xe2, 0xff, 0x31, 0xc6, 0xe4, 0xff, +0x2d, 0xc8, 0xe6, 0xff, 0x30, 0xd0, 0xef, 0xff, 0x2d, 0xcc, 0xee, 0xff, +0x25, 0xc1, 0xe1, 0xff, 0x1d, 0xb6, 0xd5, 0xff, 0x16, 0xb3, 0xd4, 0xff, +0x09, 0xa6, 0xc8, 0xff, 0x03, 0x9e, 0xc1, 0xff, 0x01, 0x9d, 0xc5, 0xff, +0x00, 0x97, 0xbd, 0xff, 0x00, 0x90, 0xb4, 0xff, 0x00, 0x91, 0xb8, 0xff, +0x00, 0x8d, 0xb2, 0xff, 0x00, 0x93, 0xba, 0xff, 0x00, 0x8e, 0xb3, 0xff, +0x00, 0x90, 0xb5, 0xff, 0x00, 0x8d, 0xb1, 0xff, 0x00, 0x8c, 0xaf, 0xff, +0x00, 0x90, 0xb6, 0xff, 0x01, 0x93, 0xb8, 0xff, 0x01, 0x9a, 0xbf, 0xff, +0x02, 0xa3, 0xca, 0xff, 0x02, 0xa2, 0xc6, 0xff, 0x03, 0xaa, 0xce, 0xff, +0x02, 0xaf, 0xd4, 0xff, 0x02, 0xb5, 0xdc, 0xff, 0x00, 0xba, 0xe2, 0xff, +0x0a, 0xbb, 0xe5, 0xff, 0x25, 0xba, 0xe1, 0xff, 0x55, 0xbb, 0xdb, 0xff, +0x92, 0xc9, 0xe0, 0xf7, 0xcd, 0xe0, 0xed, 0xd5, 0xef, 0xf1, 0xf6, 0x99, +0xfb, 0xfb, 0xfc, 0x4f, 0xff, 0xff, 0xff, 0x16, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xfa, 0xfc, 0x51, +0xa5, 0xd0, 0xe4, 0xed, 0x04, 0xaf, 0xd6, 0xff, 0x01, 0xa7, 0xd1, 0xff, +0x00, 0x95, 0xbb, 0xff, 0x00, 0x95, 0xb9, 0xff, 0x01, 0x9a, 0xc1, 0xff, +0x00, 0x96, 0xbb, 0xff, 0x01, 0x90, 0xb0, 0xff, 0x01, 0x90, 0xb1, 0xff, +0x02, 0x8e, 0xaf, 0xff, 0x00, 0x93, 0xb6, 0xff, 0x00, 0x97, 0xbc, 0xff, +0x01, 0x9a, 0xc1, 0xff, 0x02, 0x99, 0xbe, 0xff, 0x02, 0x99, 0xbc, 0xff, +0x02, 0x9f, 0xc4, 0xff, 0x03, 0xa4, 0xcd, 0xff, 0x05, 0xa7, 0xcf, 0xff, +0x06, 0xa3, 0xc6, 0xff, 0x0a, 0xa1, 0xc0, 0xff, 0x0a, 0x9f, 0xbe, 0xff, +0x0c, 0xab, 0xd0, 0xff, 0x07, 0xa7, 0xc9, 0xff, 0x09, 0xb0, 0xd6, 0xff, +0x0c, 0xa8, 0xc9, 0xff, 0x0a, 0xae, 0xd2, 0xff, 0x04, 0xb3, 0xd9, 0xff, +0x05, 0xb1, 0xd2, 0xff, 0x15, 0xb8, 0xd7, 0xff, 0x20, 0xbb, 0xd8, 0xff, +0x1b, 0xb5, 0xd0, 0xff, 0x17, 0xb9, 0xd7, 0xff, 0x1c, 0xbb, 0xd9, 0xff, +0x20, 0xbc, 0xda, 0xff, 0x24, 0xc3, 0xe6, 0xff, 0x26, 0xc3, 0xe6, 0xff, +0x28, 0xbf, 0xe3, 0xff, 0x39, 0xc3, 0xe3, 0xff, 0x43, 0xc2, 0xe2, 0xff, +0x52, 0xc1, 0xdf, 0xff, 0x5e, 0xc3, 0xe0, 0xff, 0x73, 0xc6, 0xe1, 0xff, +0x8a, 0xcc, 0xe3, 0xf8, 0xa7, 0xd4, 0xe8, 0xed, 0xc1, 0xdd, 0xec, 0xdd, +0xd7, 0xe6, 0xf1, 0xc6, 0xe8, 0xee, 0xf6, 0xa9, 0xf4, 0xf5, 0xf9, 0x86, +0xfa, 0xfa, 0xfc, 0x61, 0xfd, 0xfd, 0xfe, 0x3e, 0xfe, 0xff, 0xff, 0x1e, +0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x07, 0xfc, 0xfd, 0xff, 0x35, 0xf6, 0xf7, 0xfb, 0x7e, +0xdc, 0xe9, 0xf4, 0xc5, 0xa6, 0xd4, 0xe9, 0xf2, 0x6b, 0xc7, 0xe2, 0xff, +0x4c, 0xc8, 0xe3, 0xff, 0x43, 0xcd, 0xe6, 0xff, 0x42, 0xd1, 0xed, 0xff, +0x45, 0xd2, 0xf1, 0xff, 0x42, 0xcc, 0xf1, 0xff, 0x2e, 0xc0, 0xe8, 0xff, +0x17, 0xae, 0xd5, 0xff, 0x05, 0x9e, 0xc6, 0xff, 0x00, 0x8f, 0xb2, 0xff, +0x00, 0x86, 0xa7, 0xff, 0x00, 0x81, 0xa0, 0xff, 0x00, 0x81, 0xa1, 0xff, +0x00, 0x77, 0x99, 0xff, 0x00, 0x77, 0x9a, 0xff, 0x00, 0x74, 0x99, 0xff, +0x00, 0x73, 0x9c, 0xff, 0x00, 0x67, 0x92, 0xff, 0x00, 0x65, 0x90, 0xff, +0x00, 0x65, 0x92, 0xff, 0x00, 0x61, 0x8b, 0xff, 0x00, 0x68, 0x93, 0xff, +0x00, 0x6f, 0x9b, 0xff, 0x00, 0x6b, 0x96, 0xff, 0x00, 0x6f, 0x99, 0xff, +0x00, 0x77, 0x9f, 0xff, 0x00, 0x74, 0x99, 0xff, 0x00, 0x77, 0x9c, 0xff, +0x00, 0x81, 0xa6, 0xff, 0x00, 0x85, 0xa8, 0xff, 0x00, 0x82, 0xa4, 0xff, +0x00, 0x8c, 0xae, 0xff, 0x02, 0x9e, 0xc8, 0xff, 0x04, 0xaa, 0xd4, 0xff, +0x10, 0xb9, 0xe2, 0xff, 0x18, 0xb8, 0xdb, 0xff, 0x15, 0xb0, 0xd3, 0xff, +0x2a, 0xb1, 0xd4, 0xff, 0x68, 0xbf, 0xdc, 0xff, 0xb4, 0xd5, 0xe6, 0xe8, +0xe9, 0xed, 0xf4, 0xaa, 0xfa, 0xfb, 0xfd, 0x55, 0xfe, 0xfe, 0xff, 0x14, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfb, 0xfa, 0xfc, 0x50, 0xa3, 0xcd, 0xe1, 0xec, +0x06, 0xa7, 0xce, 0xff, 0x00, 0xa3, 0xd0, 0xff, 0x00, 0x92, 0xbb, 0xff, +0x00, 0x85, 0xa9, 0xff, 0x00, 0x85, 0xa8, 0xff, 0x00, 0x84, 0xa6, 0xff, +0x01, 0x7e, 0x9f, 0xff, 0x00, 0x79, 0x95, 0xff, 0x00, 0x78, 0x98, 0xff, +0x01, 0x7c, 0xa1, 0xff, 0x01, 0x71, 0x93, 0xff, 0x01, 0x76, 0x9b, 0xff, +0x00, 0x77, 0x9e, 0xff, 0x00, 0x70, 0x90, 0xff, 0x00, 0x77, 0x9a, 0xff, +0x00, 0x79, 0x9e, 0xff, 0x00, 0x7b, 0x9e, 0xff, 0x00, 0x79, 0x99, 0xff, +0x00, 0x7d, 0xa0, 0xff, 0x00, 0x7e, 0x9e, 0xff, 0x00, 0x7e, 0x9f, 0xff, +0x00, 0x85, 0xa8, 0xff, 0x00, 0x85, 0xa9, 0xff, 0x00, 0x81, 0xa3, 0xff, +0x00, 0x87, 0xab, 0xff, 0x00, 0x8d, 0xb3, 0xff, 0x00, 0x8a, 0xad, 0xff, +0x00, 0x94, 0xbb, 0xff, 0x00, 0x8e, 0xac, 0xff, 0x02, 0x92, 0xb1, 0xff, +0x03, 0x98, 0xba, 0xff, 0x06, 0x9b, 0xbb, 0xff, 0x0d, 0x9f, 0xbd, 0xff, +0x14, 0xab, 0xce, 0xff, 0x13, 0xa9, 0xc9, 0xff, 0x18, 0xaf, 0xcf, 0xff, +0x27, 0xba, 0xdd, 0xff, 0x31, 0xc0, 0xe3, 0xff, 0x2c, 0xb6, 0xd3, 0xff, +0x2e, 0xc0, 0xde, 0xff, 0x30, 0xc9, 0xeb, 0xff, 0x30, 0xc5, 0xe9, 0xff, +0x2d, 0xc1, 0xe4, 0xff, 0x32, 0xbe, 0xde, 0xff, 0x43, 0xbd, 0xdc, 0xff, +0x5a, 0xc3, 0xe0, 0xff, 0x76, 0xc5, 0xe0, 0xff, 0x9a, 0xcf, 0xe4, 0xf4, +0xbd, 0xdb, 0xea, 0xdf, 0xdb, 0xe7, 0xf1, 0xc0, 0xef, 0xf3, 0xf8, 0x93, +0xfa, 0xfa, 0xfc, 0x5f, 0xfd, 0xfe, 0xff, 0x30, 0xff, 0xff, 0xff, 0x0e, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x05, 0xfc, 0xfe, 0xff, 0x34, 0xf4, 0xf7, 0xfb, 0x86, +0xd4, 0xe6, 0xf2, 0xd3, 0x96, 0xcf, 0xe6, 0xfb, 0x5e, 0xc6, 0xe0, 0xff, +0x4a, 0xcb, 0xe4, 0xff, 0x59, 0xd5, 0xec, 0xff, 0x67, 0xd7, 0xf0, 0xff, +0x62, 0xcc, 0xec, 0xff, 0x47, 0xbc, 0xe1, 0xff, 0x2c, 0xb0, 0xda, 0xff, +0x0f, 0xa0, 0xc9, 0xff, 0x00, 0x89, 0xa9, 0xff, 0x00, 0x81, 0x9e, 0xff, +0x00, 0x81, 0x9f, 0xff, 0x01, 0x78, 0x97, 0xff, 0x00, 0x71, 0x97, 0xff, +0x00, 0x5b, 0x84, 0xff, 0x00, 0x54, 0x85, 0xff, 0x00, 0x41, 0x7a, 0xff, +0x00, 0x2f, 0x6e, 0xff, 0x00, 0x2e, 0x6c, 0xff, 0x00, 0x32, 0x70, 0xff, +0x00, 0x2c, 0x69, 0xff, 0x00, 0x27, 0x63, 0xff, 0x00, 0x25, 0x63, 0xff, +0x00, 0x2b, 0x68, 0xff, 0x00, 0x2f, 0x68, 0xff, 0x00, 0x2d, 0x6a, 0xff, +0x00, 0x31, 0x70, 0xff, 0x00, 0x2e, 0x6e, 0xff, 0x00, 0x39, 0x77, 0xff, +0x00, 0x3b, 0x76, 0xff, 0x00, 0x40, 0x78, 0xff, 0x00, 0x4c, 0x83, 0xff, +0x00, 0x4c, 0x80, 0xff, 0x00, 0x5a, 0x88, 0xff, 0x00, 0x6a, 0x97, 0xff, +0x00, 0x6e, 0x93, 0xff, 0x00, 0x75, 0x96, 0xff, 0x00, 0x84, 0xa5, 0xff, +0x04, 0x90, 0xb1, 0xff, 0x07, 0x9d, 0xbc, 0xff, 0x08, 0xa9, 0xcb, 0xff, +0x10, 0xb6, 0xde, 0xff, 0x29, 0xb8, 0xe0, 0xff, 0x65, 0xbe, 0xdb, 0xff, +0xb5, 0xd5, 0xe4, 0xe8, 0xec, 0xef, 0xf5, 0xa0, 0xfb, 0xfb, 0xfd, 0x41, +0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfb, 0xfa, 0xfc, 0x50, 0xa3, 0xce, 0xe2, 0xec, 0x20, 0xb6, 0xe1, 0xff, +0x11, 0xab, 0xd8, 0xff, 0x00, 0x97, 0xbe, 0xff, 0x01, 0x93, 0xba, 0xff, +0x02, 0x95, 0xbb, 0xff, 0x01, 0x90, 0xb5, 0xff, 0x00, 0x8a, 0xad, 0xff, +0x00, 0x84, 0xa6, 0xff, 0x00, 0x8c, 0xb4, 0xff, 0x00, 0x61, 0x94, 0xff, +0x00, 0x34, 0x70, 0xff, 0x00, 0x33, 0x6f, 0xff, 0x00, 0x31, 0x6d, 0xff, +0x00, 0x2b, 0x6a, 0xff, 0x00, 0x31, 0x6c, 0xff, 0x00, 0x3b, 0x74, 0xff, +0x00, 0x42, 0x79, 0xff, 0x00, 0x3c, 0x71, 0xff, 0x00, 0x41, 0x78, 0xff, +0x00, 0x46, 0x7d, 0xff, 0x00, 0x4a, 0x7d, 0xff, 0x00, 0x4a, 0x7e, 0xff, +0x00, 0x4a, 0x7d, 0xff, 0x00, 0x57, 0x86, 0xff, 0x00, 0x58, 0x89, 0xff, +0x00, 0x56, 0x84, 0xff, 0x00, 0x6c, 0x9a, 0xff, 0x00, 0x75, 0xa0, 0xff, +0x00, 0x68, 0x8c, 0xff, 0x00, 0x6b, 0x91, 0xff, 0x00, 0x70, 0x95, 0xff, +0x00, 0x77, 0x9b, 0xff, 0x00, 0x7a, 0x9e, 0xff, 0x00, 0x84, 0xa8, 0xff, +0x00, 0x82, 0xa1, 0xff, 0x00, 0x85, 0xa4, 0xff, 0x00, 0x85, 0xa3, 0xff, +0x01, 0x8a, 0xa7, 0xff, 0x02, 0x90, 0xae, 0xff, 0x06, 0x94, 0xb2, 0xff, +0x13, 0xa1, 0xc2, 0xff, 0x1e, 0xa9, 0xcc, 0xff, 0x24, 0xb6, 0xdc, 0xff, +0x26, 0xb8, 0xdc, 0xff, 0x32, 0xbc, 0xdf, 0xff, 0x3c, 0xc5, 0xe8, 0xff, +0x42, 0xc8, 0xea, 0xff, 0x43, 0xc5, 0xe6, 0xff, 0x3f, 0xbf, 0xdf, 0xff, +0x4e, 0xbe, 0xdd, 0xff, 0x75, 0xc5, 0xdf, 0xff, 0xa2, 0xd2, 0xe5, 0xf2, +0xcd, 0xe1, 0xee, 0xd2, 0xec, 0xf1, 0xf7, 0x9e, 0xf9, 0xfa, 0xfc, 0x5a, +0xfe, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xff, 0x21, 0xf6, 0xf9, 0xfd, 0x76, +0xd9, 0xe9, 0xf4, 0xce, 0x9e, 0xd0, 0xe5, 0xfc, 0x6c, 0xc8, 0xde, 0xff, +0x68, 0xd8, 0xe8, 0xff, 0x74, 0xdd, 0xee, 0xff, 0x74, 0xd3, 0xec, 0xff, +0x61, 0xc0, 0xe2, 0xff, 0x4c, 0xb1, 0xd6, 0xff, 0x3f, 0xa5, 0xca, 0xff, +0x2c, 0x98, 0xb7, 0xff, 0x1e, 0x9d, 0xc1, 0xff, 0x04, 0x8b, 0xac, 0xff, +0x00, 0x74, 0x8d, 0xff, 0x01, 0x74, 0x95, 0xff, 0x00, 0x5a, 0x87, 0xff, +0x00, 0x3a, 0x70, 0xff, 0x00, 0x33, 0x6f, 0xff, 0x00, 0x26, 0x5e, 0xff, +0x0f, 0x35, 0x66, 0xf8, 0x24, 0x47, 0x6e, 0xe8, 0x3b, 0x5a, 0x76, 0xd5, +0x52, 0x6e, 0x82, 0xc3, 0x64, 0x7d, 0x8d, 0xb3, 0x71, 0x89, 0x96, 0xa9, +0x7a, 0x90, 0x9b, 0xa2, 0x7c, 0x93, 0x9d, 0xa1, 0x7c, 0x92, 0x9d, 0xa2, +0x7a, 0x8f, 0x9b, 0xa6, 0x75, 0x8c, 0x99, 0xab, 0x6d, 0x86, 0x95, 0xb3, +0x64, 0x80, 0x91, 0xbc, 0x5a, 0x77, 0x8a, 0xc7, 0x4e, 0x6e, 0x87, 0xd2, +0x41, 0x67, 0x82, 0xdd, 0x32, 0x5c, 0x7c, 0xe9, 0x24, 0x4f, 0x76, 0xf3, +0x16, 0x4a, 0x75, 0xfb, 0x09, 0x45, 0x74, 0xff, 0x00, 0x45, 0x76, 0xff, +0x00, 0x47, 0x79, 0xff, 0x00, 0x53, 0x84, 0xff, 0x00, 0x62, 0x8e, 0xff, +0x00, 0x6b, 0x91, 0xff, 0x00, 0x7e, 0xa4, 0xff, 0x07, 0x9a, 0xc0, 0xff, +0x1e, 0xb0, 0xd7, 0xff, 0x25, 0xb1, 0xd4, 0xff, 0x33, 0xb5, 0xd9, 0xff, +0x71, 0xbe, 0xd9, 0xff, 0xcc, 0xdd, 0xe9, 0xd6, 0xf5, 0xf6, 0xf9, 0x76, +0xfd, 0xfd, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfa, 0xfc, 0x4f, +0xa5, 0xd1, 0xe2, 0xec, 0x41, 0xba, 0xe1, 0xff, 0x34, 0xab, 0xd2, 0xff, +0x1a, 0x98, 0xba, 0xff, 0x25, 0x9a, 0xbd, 0xff, 0x27, 0x9b, 0xbc, 0xff, +0x22, 0x9b, 0xbd, 0xff, 0x19, 0x99, 0xbd, 0xff, 0x0c, 0x97, 0xbb, 0xff, +0x00, 0x89, 0xb0, 0xff, 0x00, 0x41, 0x76, 0xff, 0x24, 0x47, 0x6d, 0xeb, +0x49, 0x69, 0x80, 0xcf, 0x4c, 0x6b, 0x83, 0xcf, 0x49, 0x69, 0x83, 0xd2, +0x46, 0x66, 0x80, 0xd5, 0x42, 0x65, 0x80, 0xd8, 0x3e, 0x63, 0x80, 0xdc, +0x3a, 0x60, 0x7e, 0xe0, 0x33, 0x5b, 0x7a, 0xe4, 0x2e, 0x54, 0x77, 0xe9, +0x29, 0x52, 0x76, 0xed, 0x24, 0x4f, 0x75, 0xf1, 0x1e, 0x4c, 0x73, 0xf4, +0x18, 0x48, 0x72, 0xf8, 0x12, 0x3f, 0x6e, 0xfb, 0x0d, 0x3c, 0x6d, 0xfd, +0x09, 0x43, 0x72, 0xff, 0x04, 0x47, 0x73, 0xff, 0x01, 0x42, 0x72, 0xff, +0x00, 0x35, 0x6d, 0xff, 0x00, 0x31, 0x6c, 0xff, 0x00, 0x40, 0x77, 0xff, +0x00, 0x42, 0x7a, 0xff, 0x00, 0x44, 0x7a, 0xff, 0x00, 0x4e, 0x7f, 0xff, +0x00, 0x54, 0x84, 0xff, 0x00, 0x50, 0x7c, 0xff, 0x00, 0x5a, 0x84, 0xff, +0x00, 0x66, 0x8f, 0xff, 0x00, 0x6c, 0x94, 0xff, 0x00, 0x6e, 0x93, 0xff, +0x00, 0x76, 0x96, 0xff, 0x00, 0x7b, 0x9c, 0xff, 0x00, 0x81, 0xa0, 0xff, +0x01, 0x8d, 0xaf, 0xff, 0x0d, 0x9c, 0xc1, 0xff, 0x27, 0xa8, 0xcc, 0xff, +0x41, 0xb9, 0xdf, 0xff, 0x4b, 0xc4, 0xe9, 0xff, 0x49, 0xc4, 0xe7, 0xff, +0x51, 0xc7, 0xe7, 0xff, 0x50, 0xc5, 0xe4, 0xff, 0x56, 0xbf, 0xdd, 0xff, +0x7b, 0xc6, 0xdf, 0xff, 0xb2, 0xd6, 0xe6, 0xed, 0xe2, 0xeb, 0xf2, 0xb7, +0xf8, 0xf9, 0xfc, 0x60, 0xfe, 0xfe, 0xff, 0x16, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x08, 0xfb, 0xfd, 0xfe, 0x4a, +0xe9, 0xf1, 0xf8, 0xb1, 0xb5, 0xd8, 0xe9, 0xf6, 0x81, 0xcb, 0xe0, 0xff, +0x7b, 0xd9, 0xe7, 0xff, 0x8c, 0xe6, 0xf2, 0xff, 0x87, 0xda, 0xf1, 0xff, +0x70, 0xbf, 0xdf, 0xff, 0x5e, 0xad, 0xce, 0xff, 0x51, 0xa6, 0xc7, 0xff, +0x41, 0x9c, 0xba, 0xff, 0x2f, 0x8b, 0xa6, 0xff, 0x1f, 0x86, 0xa0, 0xff, +0x13, 0x96, 0xb7, 0xff, 0x00, 0x83, 0xa7, 0xff, 0x00, 0x4e, 0x7d, 0xff, +0x00, 0x31, 0x69, 0xff, 0x03, 0x2b, 0x5e, 0xfe, 0x22, 0x40, 0x66, 0xe8, +0x4d, 0x68, 0x7d, 0xc2, 0x7b, 0x8f, 0x97, 0x97, 0xa1, 0xab, 0xaf, 0x6c, +0xbc, 0xc1, 0xc2, 0x4a, 0xd0, 0xd2, 0xd1, 0x30, 0xdc, 0xdc, 0xda, 0x1f, +0xe4, 0xe2, 0xe1, 0x14, 0xe9, 0xe7, 0xe6, 0x0f, 0xea, 0xe9, 0xe8, 0x0c, +0xeb, 0xea, 0xe9, 0x0b, 0xeb, 0xea, 0xe9, 0x0d, 0xeb, 0xe9, 0xe9, 0x0e, +0xea, 0xe8, 0xe8, 0x0f, 0xe8, 0xe7, 0xe6, 0x14, 0xe5, 0xe4, 0xe3, 0x19, +0xe1, 0xe0, 0xe0, 0x22, 0xdc, 0xdc, 0xdb, 0x2d, 0xd4, 0xd6, 0xd5, 0x39, +0xca, 0xce, 0xce, 0x4a, 0xbd, 0xc5, 0xc6, 0x5e, 0xad, 0xb8, 0xba, 0x77, +0x99, 0xa9, 0xaf, 0x92, 0x80, 0x96, 0xa1, 0xae, 0x64, 0x82, 0x93, 0xca, +0x46, 0x6e, 0x85, 0xe3, 0x27, 0x5c, 0x7c, 0xf6, 0x0f, 0x4c, 0x75, 0xff, +0x00, 0x49, 0x78, 0xff, 0x00, 0x60, 0x8c, 0xff, 0x00, 0x71, 0x9a, 0xff, +0x05, 0x8b, 0xb0, 0xff, 0x16, 0x9c, 0xbd, 0xff, 0x19, 0xad, 0xd5, 0xff, +0x3b, 0xb2, 0xd8, 0xff, 0xa4, 0xcd, 0xdf, 0xf4, 0xed, 0xef, 0xf5, 0xa0, +0xfc, 0xfd, 0xfd, 0x29, 0xfa, 0xfa, 0xfc, 0x4f, 0xad, 0xd2, 0xe3, 0xeb, +0x5c, 0xbe, 0xe0, 0xff, 0x55, 0xaf, 0xd0, 0xff, 0x44, 0x9b, 0xb9, 0xff, +0x4d, 0x9f, 0xbe, 0xff, 0x50, 0xa1, 0xc0, 0xff, 0x4b, 0x9f, 0xbd, 0xff, +0x49, 0x9f, 0xbf, 0xff, 0x33, 0x9b, 0xbb, 0xff, 0x02, 0x85, 0xa8, 0xff, +0x10, 0x62, 0x83, 0xff, 0x98, 0xa8, 0xae, 0xa7, 0xd6, 0xd5, 0xd4, 0x2f, +0xdb, 0xdb, 0xda, 0x27, 0xd9, 0xda, 0xd9, 0x2b, 0xd7, 0xd8, 0xd7, 0x30, +0xd5, 0xd6, 0xd5, 0x33, 0xd2, 0xd4, 0xd4, 0x37, 0xcf, 0xd2, 0xd1, 0x3d, +0xcb, 0xcf, 0xce, 0x43, 0xc7, 0xcb, 0xcb, 0x4a, 0xc2, 0xc7, 0xc8, 0x51, +0xbd, 0xc3, 0xc5, 0x59, 0xb7, 0xbf, 0xc0, 0x62, 0xb0, 0xb9, 0xbb, 0x6b, +0xa8, 0xb4, 0xb7, 0x74, 0xa0, 0xae, 0xb2, 0x80, 0x97, 0xa6, 0xac, 0x8b, +0x8f, 0x9f, 0xa6, 0x96, 0x84, 0x98, 0xa2, 0xa2, 0x77, 0x8e, 0x9b, 0xae, +0x6a, 0x85, 0x93, 0xba, 0x5d, 0x7a, 0x8d, 0xc5, 0x51, 0x71, 0x87, 0xd0, +0x46, 0x6a, 0x82, 0xdb, 0x39, 0x62, 0x7e, 0xe4, 0x2e, 0x59, 0x78, 0xec, +0x23, 0x51, 0x74, 0xf3, 0x19, 0x4d, 0x73, 0xf9, 0x0f, 0x47, 0x72, 0xfe, +0x07, 0x42, 0x71, 0xff, 0x00, 0x3e, 0x6f, 0xff, 0x00, 0x47, 0x77, 0xff, +0x00, 0x42, 0x71, 0xff, 0x00, 0x46, 0x76, 0xff, 0x00, 0x54, 0x82, 0xff, +0x00, 0x5d, 0x89, 0xff, 0x00, 0x61, 0x85, 0xff, 0x00, 0x72, 0x95, 0xff, +0x05, 0x80, 0xa7, 0xff, 0x0b, 0x91, 0xb4, 0xff, 0x20, 0x9b, 0xbb, 0xff, +0x44, 0xb5, 0xd7, 0xff, 0x59, 0xc7, 0xea, 0xff, 0x58, 0xc1, 0xe0, 0xff, +0x58, 0xbe, 0xdc, 0xff, 0x70, 0xc0, 0xdc, 0xff, 0xb4, 0xd5, 0xe5, 0xed, +0xed, 0xf1, 0xf5, 0x98, 0xfc, 0xfc, 0xfd, 0x2a, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xff, 0x19, +0xf6, 0xfa, 0xfd, 0x77, 0xd6, 0xe7, 0xf1, 0xdb, 0x9d, 0xd0, 0xe4, 0xff, +0x89, 0xd9, 0xe6, 0xff, 0x9b, 0xea, 0xf3, 0xff, 0x99, 0xe1, 0xf3, 0xff, +0x81, 0xc3, 0xdf, 0xff, 0x6f, 0xb0, 0xcc, 0xff, 0x63, 0xa4, 0xbe, 0xff, +0x61, 0xa3, 0xbe, 0xff, 0x60, 0xa4, 0xc0, 0xff, 0x4e, 0x97, 0xb2, 0xff, +0x34, 0x8e, 0xa8, 0xff, 0x18, 0x8d, 0xad, 0xff, 0x00, 0x61, 0x8c, 0xff, +0x00, 0x34, 0x68, 0xff, 0x13, 0x37, 0x62, 0xf4, 0x48, 0x63, 0x78, 0xc7, +0x85, 0x97, 0x9c, 0x88, 0xb7, 0xbe, 0xbd, 0x4c, 0xd7, 0xd6, 0xd5, 0x21, +0xe9, 0xe7, 0xe6, 0x09, 0xf2, 0xf1, 0xf0, 0x00, 0xf8, 0xf7, 0xf6, 0x00, +0xfb, 0xfb, 0xfa, 0x00, 0xfd, 0xfc, 0xfc, 0x00, 0xfd, 0xfd, 0xfd, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00, +0xfd, 0xfc, 0xfc, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xfa, 0xf9, 0xf9, 0x00, +0xf8, 0xf8, 0xf7, 0x00, 0xf6, 0xf5, 0xf5, 0x00, 0xf1, 0xf1, 0xf0, 0x07, +0xec, 0xea, 0xea, 0x13, 0xe3, 0xe2, 0xe2, 0x26, 0xd6, 0xd6, 0xd7, 0x42, +0xc0, 0xc5, 0xc8, 0x65, 0xa3, 0xb0, 0xb6, 0x8f, 0x7e, 0x95, 0xa1, 0xba, +0x55, 0x7b, 0x8e, 0xdf, 0x2c, 0x68, 0x83, 0xf7, 0x0d, 0x59, 0x7c, 0xff, +0x00, 0x58, 0x7e, 0xff, 0x00, 0x78, 0x9e, 0xff, 0x06, 0x9e, 0xca, 0xff, +0x11, 0xa3, 0xcb, 0xff, 0x7b, 0xbc, 0xd2, 0xfd, 0xe5, 0xeb, 0xf1, 0xaf, +0xf3, 0xf6, 0xf8, 0x82, 0xb4, 0xd4, 0xe3, 0xea, 0x70, 0xc1, 0xdf, 0xff, +0x6f, 0xb8, 0xd7, 0xff, 0x60, 0xa1, 0xbb, 0xff, 0x65, 0xa4, 0xbe, 0xff, +0x65, 0xa4, 0xbf, 0xff, 0x62, 0xa3, 0xbe, 0xff, 0x64, 0xa4, 0xc0, 0xff, +0x54, 0x9d, 0xb8, 0xff, 0x18, 0x88, 0xa6, 0xff, 0x23, 0x72, 0x8d, 0xff, +0xba, 0xc0, 0xc6, 0x93, 0xf7, 0xf5, 0xf5, 0x02, 0xfd, 0xfc, 0xfc, 0x00, +0xfd, 0xfc, 0xfc, 0x00, 0xfc, 0xfb, 0xfb, 0x00, 0xfc, 0xfb, 0xfb, 0x00, +0xfc, 0xfb, 0xfb, 0x00, 0xfb, 0xfa, 0xfa, 0x00, 0xfa, 0xfa, 0xf9, 0x00, +0xfa, 0xf9, 0xf9, 0x00, 0xfa, 0xf8, 0xf8, 0x00, 0xf8, 0xf7, 0xf7, 0x00, +0xf7, 0xf6, 0xf5, 0x00, 0xf6, 0xf5, 0xf4, 0x00, 0xf6, 0xf4, 0xf3, 0x00, +0xf4, 0xf2, 0xf2, 0x02, 0xf1, 0xf0, 0xef, 0x04, 0xef, 0xee, 0xed, 0x08, +0xed, 0xeb, 0xeb, 0x0c, 0xea, 0xe8, 0xe8, 0x12, 0xe6, 0xe4, 0xe4, 0x18, +0xe2, 0xe1, 0xe0, 0x21, 0xdd, 0xdc, 0xdc, 0x2b, 0xd6, 0xd7, 0xd7, 0x36, +0xcf, 0xd0, 0xd1, 0x42, 0xc7, 0xcb, 0xcb, 0x50, 0xbd, 0xc3, 0xc5, 0x5e, +0xb0, 0xb9, 0xbc, 0x6f, 0xa3, 0xaf, 0xb3, 0x7f, 0x94, 0xa4, 0xaa, 0x92, +0x84, 0x98, 0xa1, 0xa5, 0x73, 0x8c, 0x98, 0xb6, 0x61, 0x80, 0x90, 0xc7, +0x4f, 0x72, 0x87, 0xd6, 0x3d, 0x66, 0x7f, 0xe4, 0x2d, 0x5b, 0x78, 0xf0, +0x1f, 0x56, 0x76, 0xf9, 0x11, 0x51, 0x74, 0xff, 0x03, 0x4d, 0x74, 0xff, +0x00, 0x54, 0x7c, 0xff, 0x00, 0x5b, 0x80, 0xff, 0x00, 0x63, 0x88, 0xff, +0x04, 0x78, 0x9e, 0xff, 0x1b, 0x8b, 0xad, 0xff, 0x32, 0xa0, 0xbf, 0xff, +0x3b, 0xad, 0xce, 0xff, 0x36, 0xa8, 0xca, 0xff, 0x89, 0xc2, 0xd7, 0xfc, +0xe7, 0xeb, 0xf1, 0xa4, 0xfb, 0xfc, 0xfc, 0x22, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfe, 0xff, 0x2c, 0xf1, 0xf6, 0xfc, 0x9e, 0xc3, 0xde, 0xeb, 0xf4, +0x9b, 0xd4, 0xe3, 0xff, 0xa4, 0xe7, 0xee, 0xff, 0xae, 0xed, 0xf8, 0xff, +0x97, 0xd2, 0xe9, 0xff, 0x81, 0xb7, 0xd0, 0xff, 0x79, 0xab, 0xc2, 0xff, +0x75, 0xa9, 0xbf, 0xff, 0x74, 0xa8, 0xbf, 0xff, 0x71, 0xa7, 0xbf, 0xff, +0x68, 0xa1, 0xba, 0xff, 0x4c, 0x98, 0xb1, 0xff, 0x15, 0x7b, 0x9a, 0xff, +0x00, 0x40, 0x6a, 0xff, 0x15, 0x3a, 0x5e, 0xf3, 0x5a, 0x70, 0x7f, 0xb7, +0xa2, 0xab, 0xad, 0x64, 0xd2, 0xd3, 0xd2, 0x25, 0xeb, 0xe9, 0xe9, 0x05, +0xf6, 0xf5, 0xf4, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00, +0xfe, 0xfe, 0xfd, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xf9, 0xf9, 0xf9, 0x00, +0xf4, 0xf3, 0xf3, 0x06, 0xec, 0xeb, 0xeb, 0x19, 0xde, 0xdd, 0xdd, 0x3a, +0xc4, 0xc8, 0xca, 0x69, 0xa0, 0xad, 0xb4, 0xa0, 0x71, 0x8c, 0x9a, 0xd3, +0x3e, 0x70, 0x87, 0xf6, 0x16, 0x6c, 0x8c, 0xff, 0x00, 0x7c, 0xa2, 0xff, +0x00, 0x86, 0xae, 0xff, 0x60, 0xab, 0xc6, 0xfc, 0xd9, 0xe3, 0xec, 0xd9, +0xb5, 0xd3, 0xe2, 0xf1, 0x85, 0xcb, 0xe4, 0xff, 0x7f, 0xbb, 0xd5, 0xff, +0x72, 0xa7, 0xbe, 0xff, 0x74, 0xa9, 0xc0, 0xff, 0x74, 0xa9, 0xc0, 0xff, +0x74, 0xa9, 0xc0, 0xff, 0x71, 0xa8, 0xbf, 0xff, 0x6a, 0xa1, 0xb8, 0xff, +0x3c, 0x91, 0xad, 0xff, 0x2c, 0x78, 0x90, 0xff, 0xbe, 0xc2, 0xc8, 0x96, +0xf9, 0xf8, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfd, 0x00, 0xfe, 0xfe, 0xfd, 0x00, +0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xfc, 0xfb, 0xfb, 0x00, +0xfa, 0xfa, 0xf9, 0x00, 0xf9, 0xf8, 0xf8, 0x00, 0xf7, 0xf6, 0xf5, 0x00, +0xf5, 0xf4, 0xf3, 0x00, 0xf2, 0xf1, 0xf0, 0x05, 0xef, 0xed, 0xec, 0x0c, +0xea, 0xe8, 0xe7, 0x14, 0xe4, 0xe2, 0xe2, 0x20, 0xdd, 0xdc, 0xdc, 0x2d, +0xd3, 0xd4, 0xd4, 0x3f, 0xc6, 0xcb, 0xcc, 0x52, 0xb8, 0xbf, 0xc1, 0x69, +0xa7, 0xb1, 0xb6, 0x81, 0x92, 0xa1, 0xa9, 0x9c, 0x7c, 0x90, 0x9b, 0xb5, +0x64, 0x81, 0x90, 0xce, 0x48, 0x71, 0x85, 0xe4, 0x2d, 0x62, 0x7a, 0xf5, +0x17, 0x5e, 0x7a, 0xff, 0x03, 0x60, 0x80, 0xff, 0x00, 0x71, 0x93, 0xff, +0x09, 0x8f, 0xb5, 0xff, 0x0f, 0x99, 0xc0, 0xff, 0x8b, 0xbb, 0xce, 0xf5, +0xef, 0xf0, 0xf2, 0x71, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xff, 0x36, 0xed, 0xf4, 0xfa, 0xb3, +0xbc, 0xda, 0xe6, 0xfd, 0xa7, 0xd8, 0xe2, 0xff, 0xbd, 0xef, 0xf4, 0xff, +0xb3, 0xe6, 0xf2, 0xff, 0x94, 0xc2, 0xd7, 0xff, 0x85, 0xb1, 0xc5, 0xff, +0x82, 0xae, 0xc2, 0xff, 0x6b, 0x8e, 0x9a, 0xff, 0x61, 0x80, 0x89, 0xff, +0x77, 0xa3, 0xb5, 0xff, 0x77, 0xa6, 0xbc, 0xff, 0x4f, 0x91, 0xa6, 0xff, +0x07, 0x63, 0x80, 0xff, 0x02, 0x3c, 0x5f, 0xff, 0x46, 0x61, 0x72, 0xcd, +0x9e, 0xa6, 0xa8, 0x6d, 0xd5, 0xd5, 0xd4, 0x1f, 0xef, 0xee, 0xee, 0x00, +0xf9, 0xf9, 0xf9, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfc, 0x00, 0xf9, 0xf8, 0xf8, 0x00, +0xf2, 0xf1, 0xf1, 0x0e, 0xe4, 0xe3, 0xe4, 0x31, 0xcb, 0xcd, 0xd0, 0x6b, +0xa2, 0xad, 0xb5, 0xae, 0x70, 0x90, 0x9f, 0xe5, 0x3e, 0x80, 0x9a, 0xfe, +0x0a, 0x69, 0x91, 0xff, 0x58, 0x92, 0xae, 0xfe, 0xac, 0xce, 0xdd, 0xfb, +0x9a, 0xd5, 0xe8, 0xff, 0x8f, 0xc2, 0xd8, 0xff, 0x7f, 0xab, 0xc0, 0xff, +0x81, 0xae, 0xc1, 0xff, 0x81, 0xae, 0xc1, 0xff, 0x82, 0xae, 0xc2, 0xff, +0x7d, 0xaa, 0xbd, 0xff, 0x7a, 0xa6, 0xba, 0xff, 0x53, 0x94, 0xac, 0xff, +0x3a, 0x7b, 0x90, 0xff, 0xbe, 0xc4, 0xc8, 0x96, 0xf8, 0xf7, 0xf8, 0x08, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xfe, 0xfe, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfb, 0xfb, 0x00, +0xfa, 0xfa, 0xf9, 0x00, 0xf8, 0xf7, 0xf6, 0x00, 0xf4, 0xf3, 0xf3, 0x01, +0xf0, 0xee, 0xee, 0x0a, 0xea, 0xe8, 0xe8, 0x15, 0xe1, 0xdf, 0xe0, 0x28, +0xd4, 0xd4, 0xd5, 0x41, 0xc4, 0xc6, 0xc9, 0x5f, 0xac, 0xb3, 0xb8, 0x85, +0x8b, 0x9c, 0xa5, 0xb0, 0x62, 0x85, 0x95, 0xde, 0x33, 0x7a, 0x94, 0xfb, +0x06, 0x83, 0xa5, 0xff, 0x2e, 0x8e, 0xab, 0xff, 0xd2, 0xd8, 0xde, 0xa8, +0xfd, 0xfd, 0xfd, 0x0d, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xff, 0x36, +0xec, 0xf4, 0xf9, 0xba, 0xbc, 0xd9, 0xe4, 0xff, 0xb5, 0xdb, 0xe3, 0xff, +0xcc, 0xf0, 0xf4, 0xff, 0xb3, 0xdb, 0xe9, 0xff, 0x96, 0xbb, 0xcc, 0xff, +0x8c, 0xaf, 0xbf, 0xff, 0x8e, 0xb3, 0xc4, 0xff, 0x8e, 0xb3, 0xc5, 0xff, +0x77, 0x95, 0x9f, 0xff, 0x6d, 0x8a, 0x94, 0xff, 0x7b, 0xa1, 0xb3, 0xff, +0x63, 0x9a, 0xad, 0xff, 0x10, 0x60, 0x7c, 0xff, 0x14, 0x46, 0x61, 0xf7, +0x72, 0x82, 0x89, 0xa8, 0xc6, 0xc5, 0xc6, 0x39, 0xea, 0xe9, 0xe9, 0x03, +0xf9, 0xf9, 0xf9, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfd, 0xfd, 0x00, 0xf9, 0xf8, 0xf8, 0x00, 0xef, 0xef, 0xef, 0x17, +0xdc, 0xdc, 0xde, 0x4d, 0xbf, 0xc4, 0xc9, 0x99, 0x98, 0xa8, 0xb6, 0xd4, +0x55, 0x85, 0x9e, 0xf2, 0x78, 0xad, 0xc1, 0xfe, 0xaa, 0xda, 0xe8, 0xff, +0x95, 0xbd, 0xcf, 0xff, 0x8b, 0xb0, 0xc2, 0xff, 0x8d, 0xb2, 0xc3, 0xff, +0x8b, 0xb0, 0xc1, 0xff, 0x8e, 0xb3, 0xc4, 0xff, 0x8c, 0xb1, 0xc3, 0xff, +0x80, 0xa6, 0xb6, 0xff, 0x62, 0x94, 0xa7, 0xff, 0x49, 0x7e, 0x90, 0xff, +0xbf, 0xc5, 0xc9, 0x95, 0xf8, 0xf8, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfb, 0xfa, 0x04, +0xf9, 0xf7, 0xf8, 0x16, 0xf2, 0xf2, 0xf4, 0x37, 0xe8, 0xe9, 0xea, 0x6e, +0xd2, 0xd7, 0xdb, 0xbd, 0xa6, 0xba, 0xc8, 0xf7, 0x54, 0x9e, 0xb9, 0xff, +0x2a, 0x84, 0x9f, 0xff, 0xbb, 0xc3, 0xca, 0xad, 0xfa, 0xfa, 0xfa, 0x0f, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xff, 0x2b, 0xee, 0xf5, 0xf9, 0xb2, 0xc2, 0xdb, 0xe5, 0xff, +0xc3, 0xe1, 0xe7, 0xff, 0xd3, 0xef, 0xf3, 0xff, 0xb7, 0xdb, 0xe7, 0xff, +0x9c, 0xba, 0xc8, 0xff, 0x95, 0xb2, 0xbf, 0xff, 0x99, 0xb7, 0xc5, 0xff, +0x99, 0xb7, 0xc4, 0xff, 0x97, 0xb6, 0xc5, 0xff, 0x95, 0xb6, 0xc7, 0xff, +0x8a, 0xac, 0xbd, 0xff, 0x73, 0x9c, 0xad, 0xff, 0x1c, 0x62, 0x7a, 0xff, +0x21, 0x4e, 0x63, 0xf0, 0x90, 0x97, 0x9b, 0x8b, 0xd7, 0xd5, 0xd5, 0x1f, +0xf4, 0xf3, 0xf3, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00, 0xfc, 0xfb, 0xfb, 0x00, +0xf3, 0xf3, 0xf3, 0x0f, 0xe5, 0xe6, 0xe7, 0x41, 0xd3, 0xd8, 0xdc, 0x9f, +0xa7, 0xc2, 0xcf, 0xf8, 0xa7, 0xd1, 0xdd, 0xff, 0x9c, 0xbe, 0xcc, 0xff, +0x91, 0xb0, 0xbf, 0xff, 0x96, 0xb4, 0xc3, 0xff, 0x98, 0xb7, 0xc4, 0xff, +0x98, 0xb6, 0xc4, 0xff, 0x97, 0xb5, 0xc3, 0xff, 0x89, 0xa8, 0xb5, 0xff, +0x6a, 0x94, 0xa5, 0xff, 0x54, 0x7f, 0x8f, 0xff, 0xc0, 0xc5, 0xca, 0x93, +0xf8, 0xf8, 0xf8, 0x03, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x05, +0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x15, +0xff, 0xff, 0xff, 0x1c, 0xff, 0xff, 0xff, 0x26, 0xfe, 0xfe, 0xff, 0x32, +0xfd, 0xfe, 0xff, 0x41, 0xfd, 0xfd, 0xff, 0x52, 0xfa, 0xfd, 0xfe, 0x67, +0xf7, 0xfb, 0xfe, 0x80, 0xf2, 0xf8, 0xfb, 0x9a, 0xeb, 0xf3, 0xf8, 0xb7, +0xe0, 0xec, 0xf2, 0xd4, 0xd0, 0xe3, 0xeb, 0xeb, 0xbc, 0xda, 0xe4, 0xfa, +0xa5, 0xd5, 0xe1, 0xff, 0x6b, 0xb1, 0xca, 0xff, 0x5d, 0x8e, 0xa0, 0xfb, +0xc2, 0xc5, 0xc8, 0x80, 0xfa, 0xfa, 0xfa, 0x05, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x17, 0xf4, 0xf8, 0xfb, 0x99, +0xcd, 0xe0, 0xe8, 0xfc, 0xcb, 0xe0, 0xe6, 0xff, 0xdf, 0xf4, 0xf7, 0xff, +0xbf, 0xdc, 0xe8, 0xff, 0x9f, 0xb7, 0xc3, 0xff, 0x9c, 0xb3, 0xbd, 0xff, +0xa1, 0xb9, 0xc4, 0xff, 0xa1, 0xb8, 0xc4, 0xff, 0xa1, 0xb9, 0xc5, 0xff, +0x9c, 0xb5, 0xc0, 0xff, 0x99, 0xb6, 0xc3, 0xff, 0x87, 0xa4, 0xb3, 0xff, +0x34, 0x6c, 0x7d, 0xff, 0x29, 0x56, 0x66, 0xf3, 0x99, 0x9d, 0xa0, 0x85, +0xde, 0xdd, 0xdd, 0x14, 0xf7, 0xf7, 0xf7, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xfe, 0x00, +0xfd, 0xfc, 0xfc, 0x00, 0xf1, 0xf3, 0xf4, 0x57, 0xc6, 0xd7, 0xdf, 0xef, +0xad, 0xce, 0xd7, 0xff, 0xa9, 0xc6, 0xd2, 0xff, 0x99, 0xb2, 0xbd, 0xff, +0x9b, 0xb2, 0xbd, 0xff, 0xa2, 0xba, 0xc5, 0xff, 0xa2, 0xba, 0xc5, 0xff, +0x9a, 0xb1, 0xbc, 0xff, 0x95, 0xaf, 0xbc, 0xff, 0x7c, 0xa0, 0xb0, 0xff, +0x64, 0x85, 0x93, 0xff, 0xbf, 0xc5, 0xc9, 0xa2, 0xf8, 0xf8, 0xf8, 0x27, +0xff, 0xff, 0xff, 0x1e, 0xff, 0xff, 0xff, 0x20, 0xff, 0xff, 0xff, 0x20, +0xfe, 0xff, 0xff, 0x21, 0xff, 0xff, 0xff, 0x22, 0xff, 0xff, 0xff, 0x24, +0xfe, 0xff, 0xff, 0x26, 0xfe, 0xff, 0xff, 0x27, 0xfe, 0xff, 0xff, 0x28, +0xff, 0xff, 0xff, 0x2a, 0xfe, 0xfe, 0xff, 0x2b, 0xfe, 0xfe, 0xff, 0x2d, +0xfe, 0xfe, 0xff, 0x2f, 0xfe, 0xff, 0xff, 0x32, 0xfe, 0xff, 0xff, 0x34, +0xfe, 0xfe, 0xff, 0x37, 0xfd, 0xfe, 0xfe, 0x3b, 0xfd, 0xfe, 0xff, 0x3f, +0xfd, 0xfe, 0xff, 0x43, 0xfc, 0xfe, 0xff, 0x49, 0xfc, 0xfe, 0xff, 0x4d, +0xfc, 0xfd, 0xfe, 0x52, 0xfb, 0xfd, 0xfe, 0x59, 0xfb, 0xfc, 0xfe, 0x60, +0xfa, 0xfc, 0xfd, 0x68, 0xfa, 0xfc, 0xfe, 0x70, 0xf7, 0xfa, 0xfc, 0x79, +0xf6, 0xfa, 0xfc, 0x83, 0xf4, 0xf8, 0xfb, 0x8e, 0xf2, 0xf7, 0xfa, 0x9a, +0xef, 0xf6, 0xf9, 0xa5, 0xed, 0xf4, 0xf8, 0xb2, 0xea, 0xf2, 0xf6, 0xbe, +0xe6, 0xef, 0xf4, 0xcb, 0xe1, 0xed, 0xf3, 0xd7, 0xdf, 0xeb, 0xf1, 0xe2, +0xd9, 0xe6, 0xee, 0xed, 0xd3, 0xe4, 0xeb, 0xf6, 0xce, 0xe1, 0xe8, 0xfe, +0xc7, 0xdd, 0xe4, 0xff, 0xc3, 0xdb, 0xe3, 0xff, 0xc0, 0xdd, 0xe3, 0xff, +0xbc, 0xe0, 0xe6, 0xff, 0xb1, 0xdd, 0xe5, 0xff, 0x86, 0xbc, 0xcc, 0xff, +0x5c, 0x8a, 0x9c, 0xff, 0x92, 0x9d, 0xa4, 0xc0, 0xd8, 0xd9, 0xda, 0x33, +0xfd, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05, +0xf9, 0xfb, 0xfd, 0x6e, 0xd8, 0xe6, 0xec, 0xf1, 0xcf, 0xe0, 0xe6, 0xff, +0xe7, 0xf3, 0xf5, 0xff, 0xc7, 0xde, 0xe6, 0xff, 0xab, 0xbf, 0xc9, 0xff, +0xa5, 0xb6, 0xbe, 0xff, 0xa6, 0xb6, 0xbf, 0xff, 0xa7, 0xb9, 0xc1, 0xff, +0xac, 0xbe, 0xc6, 0xff, 0xa9, 0xb9, 0xc2, 0xff, 0x9b, 0xad, 0xb6, 0xff, +0x95, 0xab, 0xb5, 0xff, 0x5f, 0x84, 0x92, 0xff, 0x2e, 0x5a, 0x67, 0xfc, +0x91, 0x97, 0x9b, 0x98, 0xdd, 0xdc, 0xdc, 0x18, 0xf8, 0xf8, 0xf8, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xf9, 0xfb, 0xfc, 0x4e, 0xd1, 0xdf, 0xe5, 0xec, 0xbf, 0xdb, 0xe0, 0xff, +0xc0, 0xd8, 0xe4, 0xff, 0xa4, 0xb6, 0xbf, 0xff, 0xa5, 0xb6, 0xbf, 0xff, +0xa0, 0xb1, 0xba, 0xff, 0xa3, 0xb4, 0xbd, 0xff, 0xa1, 0xb3, 0xbb, 0xff, +0xa0, 0xb5, 0xc0, 0xff, 0x96, 0xb1, 0xbf, 0xff, 0x7b, 0x94, 0xa0, 0xff, +0xb7, 0xc3, 0xc9, 0xe6, 0xe5, 0xed, 0xf1, 0xc6, 0xeb, 0xf2, 0xf6, 0xc4, +0xeb, 0xf2, 0xf7, 0xc4, 0xea, 0xf2, 0xf5, 0xc5, 0xea, 0xf1, 0xf6, 0xc6, +0xe9, 0xf1, 0xf5, 0xc7, 0xea, 0xf1, 0xf5, 0xc9, 0xeb, 0xf3, 0xf6, 0xca, +0xe9, 0xf2, 0xf6, 0xcc, 0xe9, 0xf1, 0xf5, 0xce, 0xe9, 0xf0, 0xf5, 0xcf, +0xe7, 0xf0, 0xf4, 0xd1, 0xe7, 0xef, 0xf3, 0xd3, 0xe6, 0xee, 0xf3, 0xd5, +0xe5, 0xee, 0xf3, 0xd7, 0xe5, 0xef, 0xf3, 0xd9, 0xe4, 0xee, 0xf2, 0xdc, +0xe3, 0xed, 0xf1, 0xdf, 0xe3, 0xed, 0xf2, 0xe2, 0xe2, 0xeb, 0xf1, 0xe5, +0xdf, 0xea, 0xef, 0xe8, 0xde, 0xe9, 0xee, 0xeb, 0xdc, 0xe9, 0xee, 0xee, +0xdc, 0xe8, 0xee, 0xf1, 0xda, 0xe7, 0xec, 0xf4, 0xd9, 0xe6, 0xec, 0xf7, +0xd5, 0xe3, 0xe9, 0xfa, 0xd6, 0xe4, 0xea, 0xfc, 0xd3, 0xe1, 0xe8, 0xff, +0xd3, 0xe3, 0xe9, 0xff, 0xd1, 0xe2, 0xe8, 0xff, 0xd1, 0xe1, 0xe7, 0xff, +0xd1, 0xe1, 0xe7, 0xff, 0xd2, 0xe1, 0xe8, 0xff, 0xd1, 0xe1, 0xe7, 0xff, +0xd3, 0xe1, 0xe6, 0xff, 0xcf, 0xdc, 0xe2, 0xff, 0xcf, 0xdb, 0xe1, 0xff, +0xd3, 0xe0, 0xe5, 0xff, 0xd4, 0xe4, 0xe8, 0xff, 0xd4, 0xe6, 0xea, 0xff, +0xd0, 0xe8, 0xec, 0xff, 0xc4, 0xe4, 0xec, 0xff, 0x9e, 0xc7, 0xd5, 0xff, +0x69, 0x96, 0xa7, 0xff, 0x56, 0x77, 0x85, 0xfc, 0x85, 0x90, 0x96, 0xbf, +0xc6, 0xc7, 0xc9, 0x47, 0xf0, 0xf0, 0xf0, 0x03, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x38, 0xe9, 0xf0, 0xf5, 0xd0, +0xce, 0xde, 0xe3, 0xff, 0xed, 0xf2, 0xf3, 0xff, 0xd8, 0xe9, 0xee, 0xff, +0xb0, 0xbe, 0xc6, 0xff, 0xa4, 0xb0, 0xb7, 0xff, 0xa8, 0xb5, 0xbc, 0xff, +0xaf, 0xbc, 0xc3, 0xff, 0x9f, 0xad, 0xb3, 0xff, 0x90, 0x9b, 0xa1, 0xff, +0x9d, 0xa8, 0xae, 0xff, 0xa3, 0xb2, 0xba, 0xff, 0x8c, 0xa2, 0xac, 0xff, +0x43, 0x65, 0x71, 0xff, 0x78, 0x84, 0x89, 0xc3, 0xd3, 0xd3, 0xd3, 0x2e, +0xf7, 0xf6, 0xf6, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfc, 0xfe, 0x50, +0xd6, 0xe1, 0xe7, 0xec, 0xc3, 0xd5, 0xd9, 0xff, 0xc2, 0xd3, 0xdb, 0xff, +0xab, 0xb8, 0xc0, 0xff, 0xac, 0xb9, 0xc0, 0xff, 0x9c, 0xa7, 0xae, 0xff, +0xa5, 0xb2, 0xb9, 0xff, 0xa8, 0xb6, 0xbc, 0xff, 0xa7, 0xb6, 0xbe, 0xff, +0xaa, 0xbd, 0xc7, 0xff, 0xad, 0xc1, 0xcb, 0xff, 0xc7, 0xd5, 0xda, 0xff, +0xd1, 0xdb, 0xe0, 0xff, 0xd1, 0xdd, 0xe2, 0xff, 0xd3, 0xde, 0xe3, 0xff, +0xd3, 0xde, 0xe4, 0xff, 0xcd, 0xd9, 0xde, 0xff, 0xce, 0xd9, 0xde, 0xff, +0xd0, 0xdb, 0xe1, 0xff, 0xd0, 0xdb, 0xe0, 0xff, 0xd0, 0xda, 0xe0, 0xff, +0xd0, 0xdb, 0xdf, 0xff, 0xd0, 0xdb, 0xdf, 0xff, 0xcf, 0xda, 0xdf, 0xff, +0xd0, 0xda, 0xdf, 0xff, 0xd0, 0xda, 0xe0, 0xff, 0xd2, 0xdd, 0xe2, 0xff, +0xd4, 0xdf, 0xe4, 0xff, 0xd0, 0xdb, 0xdf, 0xff, 0xd6, 0xe0, 0xe5, 0xff, +0xdc, 0xe5, 0xea, 0xff, 0xd7, 0xe1, 0xe5, 0xff, 0xd9, 0xe3, 0xe7, 0xff, +0xd9, 0xe2, 0xe6, 0xff, 0xd8, 0xe1, 0xe5, 0xff, 0xd9, 0xe1, 0xe5, 0xff, +0xdd, 0xe6, 0xe9, 0xff, 0xdf, 0xe8, 0xec, 0xff, 0xe1, 0xe8, 0xeb, 0xff, +0xe6, 0xed, 0xf0, 0xff, 0xe5, 0xeb, 0xee, 0xff, 0xe5, 0xec, 0xef, 0xff, +0xe7, 0xed, 0xef, 0xff, 0xe6, 0xed, 0xef, 0xff, 0xe4, 0xeb, 0xed, 0xff, +0xe5, 0xeb, 0xee, 0xff, 0xe0, 0xe8, 0xeb, 0xff, 0xde, 0xe9, 0xec, 0xff, +0xd9, 0xe5, 0xe9, 0xff, 0xd3, 0xe3, 0xe8, 0xff, 0xcd, 0xe1, 0xe7, 0xff, +0xba, 0xd0, 0xd8, 0xff, 0xa5, 0xc2, 0xcd, 0xff, 0x7f, 0xa0, 0xac, 0xff, +0x56, 0x7e, 0x8c, 0xff, 0x44, 0x68, 0x76, 0xff, 0x60, 0x73, 0x7a, 0xde, +0x97, 0x9b, 0x9e, 0x8e, 0xcc, 0xcc, 0xcd, 0x30, 0xef, 0xee, 0xee, 0x01, +0xfc, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0a, +0xf7, 0xfa, 0xfc, 0x8c, 0xd8, 0xe3, 0xe8, 0xfd, 0xe4, 0xe9, 0xec, 0xff, +0xe9, 0xf1, 0xf3, 0xff, 0xc0, 0xcc, 0xd2, 0xff, 0x9c, 0xa5, 0xab, 0xff, +0x9b, 0xa3, 0xaa, 0xff, 0xa8, 0xb0, 0xb6, 0xff, 0xaa, 0xb4, 0xba, 0xff, +0x7a, 0x7f, 0x82, 0xff, 0x4e, 0x4a, 0x44, 0xff, 0x88, 0x8f, 0x91, 0xff, +0xa7, 0xb3, 0xbb, 0xff, 0x75, 0x89, 0x93, 0xff, 0x5f, 0x6f, 0x77, 0xf1, +0xba, 0xbc, 0xbd, 0x66, 0xf1, 0xf1, 0xf0, 0x01, 0xfe, 0xfd, 0xfe, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfb, 0xfd, 0xfe, 0x50, 0xd9, 0xe3, 0xe7, 0xec, +0xc6, 0xd1, 0xd5, 0xff, 0xb8, 0xc2, 0xc8, 0xff, 0xb0, 0xb9, 0xbe, 0xff, +0x96, 0x9e, 0xa4, 0xff, 0x93, 0x9b, 0xa1, 0xff, 0xa0, 0xa9, 0xaf, 0xff, +0xa8, 0xb2, 0xb7, 0xff, 0xb0, 0xba, 0xc0, 0xff, 0xad, 0xb8, 0xbf, 0xff, +0xc9, 0xd8, 0xdf, 0xff, 0xe3, 0xec, 0xef, 0xff, 0xde, 0xe3, 0xe5, 0xff, +0xdd, 0xe2, 0xe4, 0xff, 0xd7, 0xdd, 0xdf, 0xff, 0xdb, 0xe1, 0xe4, 0xff, +0xdc, 0xe2, 0xe5, 0xff, 0xdc, 0xe2, 0xe4, 0xff, 0xdd, 0xe2, 0xe5, 0xff, +0xdd, 0xe1, 0xe5, 0xff, 0xdb, 0xe0, 0xe3, 0xff, 0xe0, 0xe6, 0xe9, 0xff, +0xe1, 0xe7, 0xea, 0xff, 0xdd, 0xe3, 0xe5, 0xff, 0xde, 0xe3, 0xe6, 0xff, +0xdd, 0xe3, 0xe6, 0xff, 0xe3, 0xe9, 0xeb, 0xff, 0xdd, 0xe3, 0xe5, 0xff, +0xd9, 0xe0, 0xe3, 0xff, 0xe0, 0xe7, 0xe9, 0xff, 0xdd, 0xe3, 0xe6, 0xff, +0xd4, 0xd9, 0xdc, 0xff, 0xdd, 0xe3, 0xe5, 0xff, 0xda, 0xe0, 0xe4, 0xff, +0xd3, 0xd9, 0xdd, 0xff, 0xd5, 0xdc, 0xde, 0xff, 0xd1, 0xd8, 0xdb, 0xff, +0xd5, 0xdd, 0xe1, 0xff, 0xd5, 0xde, 0xe2, 0xff, 0xd1, 0xda, 0xdf, 0xff, +0xcb, 0xd5, 0xd9, 0xff, 0xc5, 0xd0, 0xd4, 0xff, 0xba, 0xc7, 0xcb, 0xff, +0xbb, 0xc7, 0xcd, 0xff, 0xb8, 0xc4, 0xcb, 0xff, 0xb1, 0xbd, 0xc2, 0xff, +0xb0, 0xbe, 0xc5, 0xff, 0xa3, 0xb4, 0xbc, 0xff, 0xa0, 0xb3, 0xbd, 0xff, +0x8a, 0xa0, 0xaa, 0xff, 0x74, 0x8d, 0x97, 0xff, 0x5a, 0x77, 0x82, 0xff, +0x44, 0x63, 0x6e, 0xff, 0x49, 0x63, 0x6c, 0xf4, 0x65, 0x75, 0x7b, 0xcf, +0x93, 0x97, 0x9b, 0x8f, 0xbf, 0xc0, 0xc0, 0x43, 0xe1, 0xe1, 0xe1, 0x0d, +0xf6, 0xf5, 0xf5, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x2d, 0xeb, 0xf1, 0xf4, 0xd4, +0xdc, 0xe2, 0xe6, 0xff, 0xf2, 0xf4, 0xf6, 0xff, 0xd6, 0xdf, 0xe2, 0xff, +0x90, 0x94, 0x98, 0xff, 0x69, 0x6a, 0x6b, 0xff, 0x6e, 0x70, 0x74, 0xff, +0x6a, 0x6d, 0x70, 0xff, 0x5e, 0x5e, 0x60, 0xff, 0x4f, 0x4b, 0x47, 0xff, +0x64, 0x63, 0x62, 0xff, 0xa9, 0xb2, 0xb7, 0xff, 0x97, 0xa2, 0xa7, 0xff, +0x69, 0x77, 0x7e, 0xff, 0x8f, 0x95, 0x99, 0xbe, 0xe0, 0xe0, 0xe0, 0x20, +0xfc, 0xfb, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfb, 0xfd, 0xfe, 0x50, 0xdd, 0xe5, 0xe8, 0xec, 0xcc, 0xd3, 0xd6, 0xff, +0xc1, 0xc9, 0xcd, 0xff, 0xa0, 0xa5, 0xa7, 0xff, 0x57, 0x55, 0x54, 0xff, +0x9b, 0xa1, 0xa6, 0xff, 0x95, 0x9a, 0x9f, 0xff, 0xb0, 0xb6, 0xba, 0xff, +0xa6, 0xab, 0xaf, 0xff, 0x9c, 0xa0, 0xa3, 0xff, 0xa1, 0xa7, 0xaa, 0xff, +0xaf, 0xb7, 0xba, 0xff, 0xb8, 0xc0, 0xc3, 0xff, 0xbb, 0xc2, 0xc5, 0xff, +0xbd, 0xc5, 0xc8, 0xff, 0xbf, 0xc8, 0xcc, 0xff, 0xc2, 0xcb, 0xd0, 0xff, +0xc2, 0xca, 0xce, 0xff, 0xb8, 0xbf, 0xc2, 0xff, 0xa9, 0xad, 0xb0, 0xff, +0xaf, 0xb5, 0xb8, 0xff, 0xa6, 0xac, 0xad, 0xff, 0xa3, 0xa8, 0xab, 0xff, +0xb1, 0xb8, 0xbc, 0xff, 0xb7, 0xc0, 0xc3, 0xff, 0xb5, 0xbc, 0xc1, 0xff, +0x9b, 0xa0, 0xa4, 0xff, 0xa0, 0xa6, 0xa9, 0xff, 0xad, 0xb6, 0xba, 0xff, +0xb4, 0xbc, 0xc0, 0xff, 0xb5, 0xbe, 0xc2, 0xff, 0xaf, 0xb8, 0xbc, 0xff, +0xa7, 0xaf, 0xb4, 0xff, 0x96, 0x9b, 0x9f, 0xff, 0x8d, 0x92, 0x95, 0xff, +0x93, 0x99, 0x9e, 0xff, 0x8e, 0x95, 0x9a, 0xff, 0x94, 0x9c, 0xa1, 0xff, +0x9f, 0xa9, 0xad, 0xff, 0xa8, 0xb0, 0xb6, 0xff, 0x9c, 0xa5, 0xab, 0xff, +0x9a, 0xa5, 0xab, 0xff, 0x92, 0x9d, 0xa4, 0xff, 0x87, 0x93, 0x9a, 0xff, +0x8e, 0x9c, 0xa3, 0xff, 0x72, 0x7f, 0x86, 0xff, 0x6d, 0x7e, 0x86, 0xff, +0x5b, 0x6f, 0x78, 0xff, 0x56, 0x6b, 0x74, 0xff, 0x4d, 0x62, 0x6a, 0xfe, +0x55, 0x67, 0x6d, 0xed, 0x6b, 0x77, 0x7d, 0xcd, 0x8b, 0x91, 0x94, 0x9e, +0xae, 0xaf, 0xb1, 0x65, 0xcd, 0xcd, 0xcd, 0x2f, 0xe5, 0xe5, 0xe5, 0x09, +0xf4, 0xf4, 0xf3, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfe, 0xfe, 0x57, 0xe1, 0xe7, 0xea, 0xfb, 0xde, 0xe0, 0xe3, 0xff, +0xe0, 0xe3, 0xe6, 0xff, 0x93, 0x95, 0x96, 0xff, 0x30, 0x2b, 0x28, 0xff, +0x5e, 0x5f, 0x60, 0xff, 0x62, 0x64, 0x66, 0xff, 0x46, 0x44, 0x43, 0xff, +0x31, 0x2a, 0x25, 0xff, 0x46, 0x42, 0x3f, 0xff, 0x7d, 0x7d, 0x7f, 0xff, +0xb8, 0xbf, 0xc2, 0xff, 0x8a, 0x91, 0x95, 0xff, 0x73, 0x7b, 0x7f, 0xfc, +0xba, 0xbb, 0xbd, 0x80, 0xf2, 0xf2, 0xf2, 0x03, 0xfe, 0xfe, 0xfe, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x50, +0xe2, 0xe6, 0xea, 0xec, 0xcc, 0xd0, 0xd2, 0xff, 0xcc, 0xd2, 0xd5, 0xff, +0x5a, 0x59, 0x5a, 0xff, 0x14, 0x0b, 0x05, 0xff, 0x62, 0x61, 0x61, 0xff, +0x5e, 0x5e, 0x5e, 0xff, 0x5d, 0x5c, 0x5c, 0xff, 0x39, 0x35, 0x32, 0xff, +0x43, 0x3f, 0x3c, 0xff, 0x4b, 0x49, 0x47, 0xff, 0x49, 0x46, 0x46, 0xff, +0x62, 0x62, 0x62, 0xff, 0x5c, 0x5b, 0x5c, 0xff, 0x72, 0x74, 0x77, 0xff, +0x83, 0x85, 0x86, 0xff, 0x73, 0x75, 0x77, 0xff, 0x6e, 0x6e, 0x70, 0xff, +0x57, 0x56, 0x56, 0xff, 0x4e, 0x4b, 0x48, 0xff, 0x41, 0x3e, 0x3c, 0xff, +0x52, 0x4f, 0x4d, 0xff, 0x65, 0x63, 0x62, 0xff, 0x66, 0x66, 0x67, 0xff, +0x75, 0x77, 0x79, 0xff, 0x8f, 0x92, 0x96, 0xff, 0x6e, 0x70, 0x72, 0xff, +0x7f, 0x82, 0x84, 0xff, 0x87, 0x8b, 0x8e, 0xff, 0x88, 0x8c, 0x8e, 0xff, +0x92, 0x98, 0x9c, 0xff, 0x9d, 0xa2, 0xa6, 0xff, 0xa1, 0xa6, 0xaa, 0xff, +0x84, 0x88, 0x8a, 0xff, 0x87, 0x8c, 0x8f, 0xff, 0x8e, 0x95, 0x99, 0xff, +0x79, 0x80, 0x84, 0xff, 0x87, 0x8f, 0x94, 0xff, 0x83, 0x8d, 0x92, 0xff, +0x80, 0x8b, 0x90, 0xff, 0x79, 0x85, 0x8b, 0xff, 0x65, 0x72, 0x79, 0xff, +0x5f, 0x6b, 0x72, 0xff, 0x5f, 0x6d, 0x73, 0xff, 0x5d, 0x6a, 0x70, 0xfd, +0x62, 0x6d, 0x73, 0xf3, 0x68, 0x72, 0x76, 0xe1, 0x76, 0x7e, 0x82, 0xc7, +0x8a, 0x90, 0x93, 0xa5, 0xa4, 0xa6, 0xa8, 0x7b, 0xbc, 0xbd, 0xbd, 0x50, +0xd3, 0xd2, 0xd2, 0x29, 0xe4, 0xe3, 0xe3, 0x0c, 0xf1, 0xf0, 0xf0, 0x00, +0xf9, 0xf9, 0xf9, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xfb, 0xfc, 0x74, +0xd9, 0xdd, 0xe0, 0xff, 0xdb, 0xdc, 0xde, 0xff, 0xbe, 0xc0, 0xc2, 0xff, +0x54, 0x53, 0x52, 0xff, 0x46, 0x46, 0x44, 0xff, 0x52, 0x54, 0x53, 0xff, +0x54, 0x54, 0x54, 0xff, 0x55, 0x56, 0x55, 0xff, 0x56, 0x55, 0x53, 0xff, +0x47, 0x45, 0x44, 0xff, 0x63, 0x63, 0x63, 0xff, 0xa6, 0xa9, 0xac, 0xff, +0x85, 0x8b, 0x8f, 0xff, 0x88, 0x8c, 0x8f, 0xee, 0xd4, 0xd5, 0xd5, 0x52, +0xfa, 0xfa, 0xf9, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfc, 0xfd, 0xfd, 0x50, 0xe3, 0xe6, 0xe9, 0xec, +0xd1, 0xd4, 0xd6, 0xff, 0xd3, 0xd7, 0xd9, 0xff, 0x61, 0x61, 0x62, 0xff, +0x33, 0x33, 0x31, 0xff, 0x4c, 0x4b, 0x47, 0xff, 0x56, 0x57, 0x56, 0xff, +0x44, 0x44, 0x43, 0xff, 0x55, 0x55, 0x54, 0xff, 0x8f, 0x91, 0x93, 0xff, +0x88, 0x8b, 0x8d, 0xff, 0x90, 0x93, 0x95, 0xff, 0x6c, 0x6d, 0x6f, 0xff, +0x4b, 0x4d, 0x4e, 0xff, 0x55, 0x58, 0x5a, 0xff, 0x5b, 0x5b, 0x5c, 0xff, +0x5b, 0x5d, 0x5d, 0xff, 0x72, 0x74, 0x74, 0xff, 0x8b, 0x8f, 0x92, 0xff, +0x79, 0x7c, 0x7d, 0xff, 0x73, 0x77, 0x7a, 0xff, 0x7a, 0x7f, 0x82, 0xff, +0x9b, 0xa1, 0xa4, 0xff, 0x8e, 0x94, 0x97, 0xff, 0x86, 0x8b, 0x8e, 0xff, +0x94, 0x99, 0x9d, 0xff, 0x91, 0x97, 0x9a, 0xff, 0x8c, 0x92, 0x95, 0xff, +0x8a, 0x90, 0x94, 0xff, 0x85, 0x8b, 0x8f, 0xff, 0x76, 0x7b, 0x7f, 0xff, +0x74, 0x7a, 0x7e, 0xff, 0x72, 0x78, 0x7d, 0xff, 0x74, 0x7d, 0x80, 0xff, +0x69, 0x73, 0x77, 0xff, 0x62, 0x6b, 0x70, 0xff, 0x58, 0x61, 0x66, 0xff, +0x60, 0x69, 0x6f, 0xff, 0x63, 0x6b, 0x70, 0xf9, 0x67, 0x6f, 0x73, 0xf0, +0x6e, 0x75, 0x79, 0xe2, 0x78, 0x7f, 0x82, 0xd0, 0x85, 0x8a, 0x8c, 0xb9, +0x94, 0x98, 0x99, 0x9e, 0xa5, 0xa7, 0xa8, 0x80, 0xb7, 0xb8, 0xb8, 0x5f, +0xc7, 0xc7, 0xc7, 0x3f, 0xd7, 0xd6, 0xd6, 0x23, 0xe4, 0xe3, 0xe3, 0x0e, +0xee, 0xed, 0xed, 0x01, 0xf5, 0xf5, 0xf5, 0x00, 0xfa, 0xfa, 0xfa, 0x00, +0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xf6, 0xf7, 0xf8, 0x82, 0xd7, 0xda, 0xdc, 0xff, +0xe0, 0xe0, 0xe1, 0xff, 0xbe, 0xbf, 0xbf, 0xff, 0xac, 0xad, 0xad, 0xff, +0xb6, 0xb8, 0xb8, 0xff, 0xad, 0xae, 0xae, 0xff, 0xb0, 0xb0, 0xb0, 0xff, +0xb2, 0xb2, 0xb2, 0xff, 0xb4, 0xb5, 0xb5, 0xff, 0xae, 0xaf, 0xaf, 0xff, +0xab, 0xac, 0xab, 0xff, 0xb2, 0xb4, 0xb5, 0xff, 0x8a, 0x8e, 0x91, 0xff, +0x9a, 0x9c, 0x9e, 0xdd, 0xe2, 0xe2, 0xe2, 0x39, 0xfc, 0xfc, 0xfc, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfd, 0xfe, 0x50, 0xe4, 0xe7, 0xe9, 0xec, 0xcc, 0xce, 0xd0, 0xff, +0xcf, 0xd0, 0xd1, 0xff, 0xb0, 0xb1, 0xb1, 0xff, 0xab, 0xac, 0xab, 0xff, +0xb2, 0xb4, 0xb3, 0xff, 0xb2, 0xb3, 0xb2, 0xff, 0xab, 0xad, 0xad, 0xff, +0xaf, 0xb1, 0xb2, 0xff, 0xb8, 0xba, 0xba, 0xff, 0x9b, 0x9e, 0xa0, 0xff, +0x8a, 0x8e, 0x90, 0xff, 0x80, 0x84, 0x87, 0xff, 0x72, 0x77, 0x7a, 0xff, +0x4f, 0x54, 0x57, 0xff, 0x66, 0x6b, 0x6d, 0xff, 0x75, 0x7a, 0x7d, 0xff, +0x7a, 0x80, 0x84, 0xff, 0x77, 0x7c, 0x80, 0xff, 0x73, 0x79, 0x7d, 0xff, +0x72, 0x78, 0x7c, 0xff, 0x72, 0x76, 0x7a, 0xff, 0x6b, 0x71, 0x74, 0xff, +0x6e, 0x73, 0x77, 0xff, 0x6b, 0x71, 0x75, 0xff, 0x68, 0x6e, 0x72, 0xff, +0x68, 0x6e, 0x72, 0xfe, 0x68, 0x6e, 0x71, 0xfb, 0x69, 0x6e, 0x71, 0xf8, +0x6d, 0x72, 0x76, 0xf3, 0x71, 0x75, 0x79, 0xec, 0x76, 0x7a, 0x7c, 0xe4, +0x79, 0x7d, 0x80, 0xd9, 0x80, 0x84, 0x86, 0xcc, 0x88, 0x8b, 0x8e, 0xbd, +0x92, 0x95, 0x96, 0xad, 0x9d, 0x9f, 0xa0, 0x9a, 0xa5, 0xa7, 0xa9, 0x86, +0xb1, 0xb2, 0xb3, 0x6f, 0xbd, 0xbd, 0xbe, 0x58, 0xc8, 0xc8, 0xc9, 0x41, +0xd4, 0xd3, 0xd4, 0x2b, 0xdd, 0xdd, 0xdd, 0x1a, 0xe6, 0xe6, 0xe6, 0x0b, +0xed, 0xed, 0xec, 0x02, 0xf3, 0xf3, 0xf3, 0x00, 0xf7, 0xf7, 0xf7, 0x00, +0xfb, 0xfb, 0xfb, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xf4, 0xf5, 0xf6, 0x86, 0xda, 0xdb, 0xdb, 0xff, 0xc7, 0xc7, 0xc5, 0xff, +0xad, 0xaa, 0xa0, 0xff, 0xac, 0xa5, 0x8f, 0xff, 0xae, 0xa6, 0x8d, 0xff, +0xad, 0xa5, 0x8c, 0xff, 0xab, 0xa3, 0x8a, 0xff, 0xac, 0xa4, 0x8b, 0xff, +0xad, 0xa5, 0x8c, 0xff, 0xaa, 0xa4, 0x8e, 0xff, 0xa6, 0xa1, 0x98, 0xff, +0xa4, 0xa4, 0xa1, 0xff, 0x91, 0x94, 0x93, 0xff, 0xa9, 0xaa, 0xab, 0xd5, +0xe9, 0xea, 0xea, 0x2f, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfd, 0x50, +0xe9, 0xea, 0xea, 0xec, 0xd5, 0xd5, 0xd5, 0xff, 0xbd, 0xbc, 0xb7, 0xff, +0xa8, 0xa3, 0x96, 0xff, 0xad, 0xa6, 0x90, 0xff, 0xac, 0xa4, 0x8c, 0xff, +0xac, 0xa6, 0x8c, 0xff, 0xab, 0xa5, 0x8e, 0xff, 0xa9, 0xa4, 0x96, 0xff, +0xa5, 0xa4, 0x9e, 0xff, 0x9e, 0x9e, 0x9c, 0xff, 0x88, 0x8a, 0x8a, 0xff, +0x87, 0x89, 0x8b, 0xfe, 0x8a, 0x8c, 0x8f, 0xf1, 0x8c, 0x8f, 0x91, 0xd9, +0x89, 0x8c, 0x8e, 0xc9, 0x88, 0x8b, 0x8d, 0xc6, 0x89, 0x8b, 0x8d, 0xc6, +0x8b, 0x8d, 0x8f, 0xc2, 0x8e, 0x8f, 0x92, 0xbd, 0x91, 0x93, 0x94, 0xb8, +0x94, 0x96, 0x97, 0xb1, 0x97, 0x9a, 0x9b, 0xaa, 0x9b, 0x9c, 0x9e, 0xa1, +0x9f, 0xa1, 0xa2, 0x98, 0xa6, 0xa7, 0xa8, 0x8d, 0xab, 0xab, 0xad, 0x83, +0xb1, 0xb1, 0xb2, 0x77, 0xb7, 0xb8, 0xb9, 0x6b, 0xbd, 0xbe, 0xbf, 0x5d, +0xc4, 0xc4, 0xc4, 0x4f, 0xca, 0xca, 0xca, 0x42, 0xd1, 0xd1, 0xd1, 0x34, +0xd7, 0xd7, 0xd7, 0x27, 0xde, 0xde, 0xdd, 0x1b, 0xe4, 0xe4, 0xe3, 0x11, +0xe8, 0xe8, 0xe8, 0x09, 0xed, 0xec, 0xed, 0x03, 0xf1, 0xf1, 0xf1, 0x00, +0xf6, 0xf5, 0xf5, 0x00, 0xf8, 0xf8, 0xf8, 0x00, 0xfb, 0xfb, 0xfb, 0x00, +0xfd, 0xfc, 0xfd, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf4, 0xf4, 0xf4, 0x86, +0xcd, 0xcd, 0xcb, 0xff, 0xc8, 0xc1, 0xae, 0xff, 0xb3, 0xa1, 0x59, 0xff, +0xa4, 0x8b, 0x22, 0xff, 0xa4, 0x88, 0x1a, 0xff, 0xa5, 0x8a, 0x1b, 0xff, +0xa4, 0x89, 0x1c, 0xff, 0xa2, 0x88, 0x19, 0xff, 0xa2, 0x88, 0x1b, 0xff, +0xa3, 0x89, 0x20, 0xff, 0xab, 0x96, 0x43, 0xff, 0xa8, 0x9f, 0x7f, 0xff, +0x8a, 0x88, 0x82, 0xff, 0xad, 0xae, 0xad, 0xd9, 0xec, 0xec, 0xec, 0x33, +0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x50, 0xe4, 0xe5, 0xe4, 0xec, +0xcc, 0xca, 0xc3, 0xff, 0xc8, 0xbc, 0x99, 0xff, 0xad, 0x97, 0x3e, 0xff, +0xa3, 0x8a, 0x20, 0xff, 0xa4, 0x8a, 0x1d, 0xff, 0xa2, 0x88, 0x1c, 0xff, +0xa4, 0x8a, 0x1f, 0xff, 0xa7, 0x90, 0x2d, 0xff, 0xab, 0x99, 0x52, 0xff, +0xb7, 0xac, 0x86, 0xff, 0xca, 0xc3, 0xb2, 0xff, 0xc9, 0xc5, 0xba, 0xff, +0xc6, 0xc5, 0xbe, 0xf8, 0xcf, 0xcf, 0xce, 0xcf, 0xd7, 0xd7, 0xd8, 0x81, +0xdb, 0xdb, 0xdb, 0x3c, 0xdc, 0xdc, 0xdd, 0x20, 0xde, 0xde, 0xde, 0x1b, +0xe0, 0xe0, 0xe0, 0x1b, 0xe1, 0xe1, 0xe1, 0x17, 0xe4, 0xe3, 0xe3, 0x14, +0xe6, 0xe6, 0xe5, 0x0f, 0xe7, 0xe8, 0xe8, 0x0c, 0xea, 0xea, 0xea, 0x08, +0xed, 0xec, 0xec, 0x05, 0xef, 0xee, 0xee, 0x02, 0xf1, 0xf0, 0xf0, 0x00, +0xf3, 0xf3, 0xf3, 0x00, 0xf5, 0xf5, 0xf5, 0x00, 0xf7, 0xf7, 0xf7, 0x00, +0xf8, 0xf8, 0xf8, 0x00, 0xfa, 0xfa, 0xfa, 0x00, 0xfb, 0xfb, 0xfb, 0x00, +0xfc, 0xfc, 0xfc, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xff, 0xff, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xf2, 0xf3, 0xf2, 0x81, 0xcf, 0xca, 0xbd, 0xff, +0xcd, 0xba, 0x79, 0xff, 0xa5, 0x84, 0x02, 0xff, 0x9b, 0x73, 0x00, 0xff, +0x9c, 0x75, 0x00, 0xff, 0x9d, 0x76, 0x00, 0xff, 0x9b, 0x75, 0x00, 0xff, +0x9b, 0x73, 0x00, 0xff, 0x9a, 0x72, 0x00, 0xff, 0x99, 0x71, 0x00, 0xff, +0x9d, 0x7a, 0x00, 0xff, 0xa4, 0x8e, 0x22, 0xff, 0x97, 0x8b, 0x60, 0xff, +0xaa, 0xa8, 0xa2, 0xe7, 0xeb, 0xeb, 0xeb, 0x49, 0xfe, 0xfe, 0xfe, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfd, 0xfd, 0x50, 0xe3, 0xe1, 0xdb, 0xec, 0xdb, 0xcf, 0xaf, 0xff, +0xc2, 0xa8, 0x3f, 0xff, 0xa0, 0x7d, 0x00, 0xff, 0x9a, 0x74, 0x00, 0xff, +0x9b, 0x74, 0x00, 0xff, 0x9b, 0x73, 0x00, 0xff, 0x9d, 0x75, 0x00, 0xff, +0x9a, 0x74, 0x00, 0xff, 0x9f, 0x7c, 0x00, 0xff, 0xaa, 0x8d, 0x13, 0xff, +0xc0, 0xa8, 0x45, 0xff, 0xd8, 0xc5, 0x82, 0xff, 0xdd, 0xce, 0xa3, 0xff, +0xd4, 0xca, 0xb1, 0xff, 0xdc, 0xd7, 0xce, 0xe8, 0xef, 0xee, 0xf0, 0xa0, +0xf9, 0xf9, 0xf9, 0x42, 0xfc, 0xfc, 0xfc, 0x06, 0xfd, 0xfd, 0xfd, 0x00, +0xfd, 0xfd, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xf4, 0xf4, 0xf5, 0x73, 0xcc, 0xbf, 0x9b, 0xff, 0xc0, 0xa5, 0x28, 0xff, +0xac, 0x86, 0x00, 0xff, 0xa6, 0x7d, 0x00, 0xff, 0xa6, 0x7f, 0x01, 0xff, +0xa6, 0x7f, 0x01, 0xff, 0xa8, 0x81, 0x01, 0xff, 0xa6, 0x7e, 0x01, 0xff, +0xa6, 0x7d, 0x01, 0xff, 0xa6, 0x7d, 0x01, 0xff, 0xa5, 0x7e, 0x01, 0xff, +0xa3, 0x81, 0x00, 0xff, 0x98, 0x7f, 0x09, 0xff, 0x9f, 0x94, 0x6b, 0xfa, +0xe2, 0xe1, 0xe2, 0x78, 0xfd, 0xfd, 0xfd, 0x01, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfc, 0x50, +0xde, 0xd7, 0xc5, 0xec, 0xd0, 0xb7, 0x51, 0xff, 0xbb, 0x98, 0x03, 0xff, +0xa5, 0x7d, 0x00, 0xff, 0xa6, 0x7e, 0x01, 0xff, 0xa6, 0x7e, 0x00, 0xff, +0xa6, 0x7d, 0x01, 0xff, 0xa7, 0x7f, 0x01, 0xff, 0xa5, 0x7d, 0x01, 0xff, +0xa4, 0x7d, 0x00, 0xff, 0xa3, 0x7d, 0x00, 0xff, 0xa6, 0x83, 0x00, 0xff, +0xb2, 0x91, 0x03, 0xff, 0xc7, 0xaa, 0x26, 0xff, 0xd5, 0xbc, 0x4c, 0xff, +0xd3, 0xbc, 0x65, 0xff, 0xd0, 0xc0, 0x81, 0xff, 0xe0, 0xd9, 0xc5, 0xdf, +0xf4, 0xf2, 0xf1, 0x8d, 0xfd, 0xfd, 0xfc, 0x32, 0xff, 0xff, 0xff, 0x03, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf7, 0xf7, 0xfa, 0x59, +0xc6, 0xb8, 0x84, 0xfc, 0xb8, 0x95, 0x00, 0xff, 0xb3, 0x8e, 0x00, 0xff, +0xb0, 0x88, 0x01, 0xff, 0xb1, 0x8b, 0x01, 0xff, 0xb1, 0x89, 0x01, 0xff, +0xab, 0x86, 0x01, 0xff, 0xb0, 0x89, 0x01, 0xff, 0xb2, 0x8b, 0x01, 0xff, +0xb2, 0x8b, 0x01, 0xff, 0xb1, 0x89, 0x01, 0xff, 0xad, 0x87, 0x01, 0xff, +0xa0, 0x7d, 0x00, 0xff, 0x97, 0x7d, 0x21, 0xff, 0xcf, 0xca, 0xbd, 0xba, +0xf9, 0xf9, 0xf9, 0x1f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfb, 0xfa, 0xfc, 0x50, 0xd8, 0xcc, 0xa5, 0xec, +0xcd, 0xaa, 0x00, 0xff, 0xc1, 0x9b, 0x00, 0xff, 0xb0, 0x89, 0x00, 0xff, +0xaf, 0x88, 0x01, 0xff, 0xb0, 0x89, 0x01, 0xff, 0xb0, 0x89, 0x01, 0xff, +0xaf, 0x88, 0x01, 0xff, 0xb1, 0x8a, 0x01, 0xff, 0xb3, 0x8c, 0x01, 0xff, +0xb2, 0x8b, 0x00, 0xff, 0xb1, 0x8b, 0x01, 0xff, 0xaf, 0x89, 0x00, 0xff, +0xb2, 0x8e, 0x00, 0xff, 0xbd, 0x9a, 0x00, 0xff, 0xcb, 0xab, 0x06, 0xff, +0xd1, 0xb0, 0x00, 0xff, 0xcb, 0xac, 0x1e, 0xff, 0xd0, 0xbc, 0x7a, 0xfd, +0xe5, 0xde, 0xd0, 0xcc, 0xf7, 0xf6, 0xf4, 0x71, 0xfe, 0xfe, 0xfd, 0x23, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfc, 0x33, 0xd3, 0xc9, 0xaf, 0xdd, +0xb1, 0x8d, 0x0d, 0xff, 0xbd, 0x95, 0x00, 0xff, 0xb9, 0x92, 0x01, 0xff, +0xb2, 0x8d, 0x01, 0xff, 0xb0, 0x8b, 0x01, 0xff, 0xa3, 0x83, 0x01, 0xff, +0xaf, 0x8c, 0x01, 0xff, 0xb1, 0x8c, 0x01, 0xff, 0xb4, 0x8f, 0x01, 0xff, +0xaf, 0x8b, 0x01, 0xff, 0xb4, 0x8e, 0x01, 0xff, 0xb0, 0x8b, 0x00, 0xff, +0xa4, 0x7f, 0x00, 0xff, 0xb8, 0xa7, 0x72, 0xf2, 0xee, 0xec, 0xeb, 0x6e, +0xfe, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfa, 0xf9, 0xfa, 0x50, 0xd9, 0xca, 0x9c, 0xec, 0xd5, 0xae, 0x00, 0xff, +0xcf, 0xa6, 0x00, 0xff, 0xb8, 0x94, 0x01, 0xff, 0xb7, 0x92, 0x01, 0xff, +0xb9, 0x94, 0x01, 0xff, 0xb9, 0x94, 0x01, 0xff, 0xb7, 0x93, 0x01, 0xff, +0xb3, 0x8e, 0x01, 0xff, 0xaf, 0x8c, 0x01, 0xff, 0xa6, 0x86, 0x01, 0xff, +0xaa, 0x89, 0x01, 0xff, 0xb2, 0x8f, 0x01, 0xff, 0xb7, 0x93, 0x01, 0xff, +0xbc, 0x97, 0x00, 0xff, 0xbf, 0x9b, 0x00, 0xff, 0xca, 0xa5, 0x00, 0xff, +0xd8, 0xaf, 0x00, 0xff, 0xd8, 0xaf, 0x00, 0xff, 0xce, 0xae, 0x2e, 0xff, +0xd7, 0xc6, 0x91, 0xf5, 0xed, 0xe6, 0xdc, 0xb9, 0xfa, 0xf9, 0xf8, 0x5e, +0xfe, 0xff, 0xfe, 0x17, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xff, 0xfe, 0x0e, 0xe7, 0xe4, 0xdc, 0x9c, 0xb8, 0x9d, 0x47, 0xff, +0xba, 0x91, 0x00, 0xff, 0xbf, 0x9a, 0x01, 0xff, 0xb9, 0x96, 0x01, 0xff, +0xb9, 0x97, 0x01, 0xff, 0xb8, 0x97, 0x01, 0xff, 0xb6, 0x94, 0x01, 0xff, +0xb4, 0x92, 0x01, 0xff, 0xb7, 0x95, 0x01, 0xff, 0xb2, 0x91, 0x01, 0xff, +0xb1, 0x8f, 0x01, 0xff, 0xbb, 0x97, 0x01, 0xff, 0xbc, 0x96, 0x00, 0xff, +0xb4, 0x94, 0x1a, 0xff, 0xd6, 0xcc, 0xb1, 0xd6, 0xf7, 0xf7, 0xf6, 0x49, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfa, 0xfa, 0xfa, 0x50, +0xde, 0xce, 0x9b, 0xec, 0xde, 0xb7, 0x01, 0xff, 0xd1, 0xad, 0x00, 0xff, +0xbb, 0x9a, 0x01, 0xff, 0xbe, 0x9b, 0x01, 0xff, 0xbc, 0x9b, 0x01, 0xff, +0xb6, 0x96, 0x01, 0xff, 0xba, 0x98, 0x00, 0xff, 0xac, 0x8c, 0x00, 0xff, +0x91, 0x7a, 0x01, 0xff, 0x93, 0x7d, 0x01, 0xff, 0x9a, 0x82, 0x01, 0xff, +0x96, 0x7f, 0x01, 0xff, 0x99, 0x81, 0x01, 0xff, 0x9f, 0x85, 0x01, 0xff, +0xab, 0x8e, 0x01, 0xff, 0xbd, 0x9c, 0x01, 0xff, 0xc6, 0xa2, 0x01, 0xff, +0xd5, 0xb0, 0x00, 0xff, 0xe1, 0xb8, 0x00, 0xff, 0xdc, 0xb5, 0x01, 0xff, +0xd6, 0xba, 0x40, 0xff, 0xdf, 0xd0, 0xa0, 0xee, 0xf1, 0xec, 0xe2, 0xac, +0xfb, 0xfa, 0xf8, 0x53, 0xff, 0xff, 0xfe, 0x13, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xf6, 0xf6, 0xf5, 0x49, 0xcf, 0xc3, 0x9e, 0xe1, 0xb7, 0x92, 0x09, 0xff, +0xc1, 0x9d, 0x00, 0xff, 0xbb, 0x9c, 0x01, 0xff, 0xc1, 0xa2, 0x01, 0xff, +0xc1, 0xa2, 0x01, 0xff, 0xbe, 0x9f, 0x01, 0xff, 0xc2, 0xa3, 0x01, 0xff, +0xc2, 0xa3, 0x01, 0xff, 0xbe, 0x9e, 0x01, 0xff, 0xbc, 0x9c, 0x01, 0xff, +0xbc, 0x9c, 0x01, 0xff, 0xc2, 0xa0, 0x00, 0xff, 0xc7, 0xa2, 0x00, 0xff, +0xc4, 0xa9, 0x3e, 0xff, 0xe4, 0xdd, 0xcb, 0xc6, 0xfb, 0xf9, 0xf7, 0x43, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfa, 0x4f, 0xe2, 0xd2, 0x9c, 0xec, +0xde, 0xbd, 0x01, 0xff, 0xd0, 0xb0, 0x00, 0xff, 0xbd, 0x9f, 0x01, 0xff, +0xbe, 0x9f, 0x01, 0xff, 0xb7, 0x9a, 0x01, 0xff, 0xaf, 0x93, 0x01, 0xff, +0xbc, 0x9c, 0x01, 0xff, 0xbd, 0x9e, 0x01, 0xff, 0x9d, 0x84, 0x01, 0xff, +0x9b, 0x83, 0x01, 0xff, 0x90, 0x7c, 0x01, 0xff, 0x83, 0x72, 0x01, 0xff, +0x9a, 0x84, 0x01, 0xff, 0x91, 0x7e, 0x01, 0xff, 0x96, 0x81, 0x01, 0xff, +0xa8, 0x8e, 0x01, 0xff, 0xb7, 0x9a, 0x01, 0xff, 0xbe, 0xa0, 0x01, 0xff, +0xcb, 0xab, 0x01, 0xff, 0xde, 0xbc, 0x00, 0xff, 0xe5, 0xc3, 0x00, 0xff, +0xd9, 0xbb, 0x07, 0xff, 0xd7, 0xc0, 0x4e, 0xff, 0xe5, 0xd8, 0xaf, 0xe9, +0xf5, 0xef, 0xe8, 0xa1, 0xfc, 0xfb, 0xf9, 0x48, 0xfe, 0xff, 0xff, 0x0d, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfd, 0x0d, +0xea, 0xe6, 0xdf, 0x8d, 0xbd, 0xa7, 0x59, 0xfc, 0xb4, 0x91, 0x00, 0xff, +0xbd, 0x9f, 0x00, 0xff, 0xc2, 0xa6, 0x01, 0xff, 0xc1, 0xa5, 0x01, 0xff, +0xc1, 0xa6, 0x01, 0xff, 0xc2, 0xa7, 0x00, 0xff, 0xc0, 0xa5, 0x01, 0xff, +0xbe, 0xa3, 0x01, 0xff, 0xbf, 0xa3, 0x01, 0xff, 0xbe, 0xa3, 0x01, 0xff, +0xbb, 0x9f, 0x01, 0xff, 0xca, 0xac, 0x00, 0xff, 0xcf, 0xae, 0x00, 0xff, +0xce, 0xb6, 0x4d, 0xff, 0xe9, 0xe0, 0xce, 0xcb, 0xfa, 0xf9, 0xf6, 0x55, +0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfb, 0xfb, 0xfa, 0x51, 0xe4, 0xd5, 0x9d, 0xee, 0xdc, 0xc1, 0x01, 0xff, +0xd5, 0xb7, 0x00, 0xff, 0xbb, 0xa2, 0x01, 0xff, 0xc0, 0xa6, 0x01, 0xff, +0xc4, 0xa8, 0x00, 0xff, 0xc4, 0xa8, 0x01, 0xff, 0xc2, 0xa6, 0x01, 0xff, +0xb8, 0x9d, 0x01, 0xff, 0xb8, 0x99, 0x01, 0xff, 0x9a, 0x79, 0x01, 0xff, +0x7f, 0x64, 0x00, 0xff, 0x9e, 0x82, 0x00, 0xff, 0xbd, 0x9d, 0x01, 0xff, +0xba, 0x9d, 0x01, 0xff, 0xb4, 0x9a, 0x01, 0xff, 0xbc, 0xa0, 0x01, 0xff, +0xbd, 0xa2, 0x01, 0xff, 0xbf, 0xa3, 0x01, 0xff, 0xbf, 0xa5, 0x01, 0xff, +0xbf, 0xa5, 0x01, 0xff, 0xd2, 0xb4, 0x01, 0xff, 0xe6, 0xc7, 0x00, 0xff, +0xe6, 0xc9, 0x00, 0xff, 0xdc, 0xc3, 0x10, 0xff, 0xda, 0xc6, 0x60, 0xff, +0xe9, 0xdd, 0xbc, 0xe0, 0xf7, 0xf3, 0xed, 0x95, 0xfd, 0xfc, 0xfb, 0x3f, +0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf8, 0xf7, 0x2d, +0xdb, 0xd4, 0xbf, 0xbd, 0xaf, 0x96, 0x2d, 0xff, 0xb6, 0x98, 0x00, 0xff, +0xc3, 0xa7, 0x01, 0xff, 0xc5, 0xaa, 0x01, 0xff, 0xc0, 0xa8, 0x00, 0xff, +0xc1, 0xaa, 0x00, 0xff, 0xbe, 0xa8, 0x00, 0xff, 0xb9, 0xa4, 0x00, 0xff, +0xba, 0xa4, 0x00, 0xff, 0xb9, 0xa5, 0x00, 0xff, 0xb2, 0x9d, 0x00, 0xff, +0xc2, 0xa9, 0x00, 0xff, 0xd5, 0xb8, 0x00, 0xff, 0xdc, 0xbf, 0x00, 0xff, +0xd5, 0xbf, 0x3f, 0xff, 0xe6, 0xdc, 0xbc, 0xe0, 0xf8, 0xf5, 0xf1, 0x7f, +0xfe, 0xfe, 0xfc, 0x22, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xfd, 0x2c, 0xfe, 0xfb, 0xf7, 0x8c, +0xe5, 0xd7, 0x97, 0xf6, 0xde, 0xc9, 0x00, 0xff, 0xde, 0xc2, 0x00, 0xff, +0xbe, 0xa7, 0x00, 0xff, 0xbd, 0xa8, 0x00, 0xff, 0xbf, 0xa7, 0x00, 0xff, +0xc1, 0xa9, 0x00, 0xff, 0xb8, 0xa3, 0x00, 0xff, 0xb9, 0xa0, 0x00, 0xff, +0xad, 0x93, 0x01, 0xff, 0x7b, 0x56, 0x00, 0xff, 0x72, 0x4f, 0x00, 0xff, +0x93, 0x73, 0x00, 0xff, 0xac, 0x8c, 0x00, 0xff, 0xa4, 0x8b, 0x00, 0xff, +0xb0, 0x96, 0x01, 0xff, 0xbc, 0xa2, 0x01, 0xff, 0xc4, 0xab, 0x01, 0xff, +0xc5, 0xac, 0x01, 0xff, 0xc2, 0xaa, 0x00, 0xff, 0xba, 0xa5, 0x00, 0xff, +0xb7, 0xa2, 0x00, 0xff, 0xc8, 0xb0, 0x00, 0xff, 0xdb, 0xbf, 0x00, 0xff, +0xe8, 0xcd, 0x00, 0xff, 0xe5, 0xcf, 0x00, 0xff, 0xdd, 0xc9, 0x1a, 0xff, +0xdf, 0xcf, 0x6c, 0xff, 0xec, 0xe3, 0xc4, 0xd9, 0xf8, 0xf5, 0xf0, 0x8b, +0xfe, 0xfd, 0xfc, 0x36, 0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x01, 0xf4, 0xf3, 0xf0, 0x4a, +0xcf, 0xc5, 0xa5, 0xd4, 0xa9, 0x91, 0x1c, 0xff, 0xb7, 0x9c, 0x00, 0xff, +0xbf, 0xa7, 0x00, 0xff, 0xbc, 0xa7, 0x04, 0xff, 0xc5, 0xaf, 0x0f, 0xff, +0xc4, 0xaf, 0x15, 0xff, 0xb9, 0xa6, 0x13, 0xff, 0xb6, 0xa5, 0x13, 0xff, +0xb8, 0xa7, 0x15, 0xff, 0xb2, 0xa1, 0x0d, 0xff, 0xbf, 0xab, 0x10, 0xff, +0xcc, 0xb5, 0x0d, 0xff, 0xdb, 0xc3, 0x11, 0xff, 0xe5, 0xcd, 0x14, 0xff, +0xda, 0xc7, 0x30, 0xff, 0xe0, 0xd2, 0x90, 0xf8, 0xf1, 0xeb, 0xdd, 0xb7, +0xfc, 0xfa, 0xf7, 0x5c, 0xff, 0xfe, 0xfe, 0x19, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x13, 0xff, 0xfe, 0xfc, 0x43, 0xfe, 0xfa, 0xf6, 0x88, +0xf7, 0xf0, 0xdd, 0xc5, 0xdc, 0xcb, 0x96, 0xea, 0xd1, 0xbb, 0x49, 0xfe, +0xe9, 0xd9, 0x16, 0xff, 0xde, 0xc6, 0x17, 0xff, 0xbf, 0xab, 0x13, 0xff, +0xb7, 0xa6, 0x16, 0xff, 0xb4, 0xa2, 0x10, 0xff, 0xb6, 0xa5, 0x11, 0xff, +0xbb, 0xa8, 0x10, 0xff, 0xc3, 0xac, 0x02, 0xff, 0xb2, 0x98, 0x00, 0xff, +0x88, 0x70, 0x05, 0xfe, 0x9a, 0x8e, 0x54, 0xdb, 0x9e, 0x90, 0x56, 0xdf, +0x8c, 0x75, 0x17, 0xff, 0x8b, 0x70, 0x00, 0xff, 0xa1, 0x86, 0x00, 0xff, +0xb8, 0x9f, 0x00, 0xff, 0xbf, 0xa9, 0x01, 0xff, 0xb1, 0x9c, 0x01, 0xff, +0xbe, 0xa9, 0x06, 0xff, 0xc3, 0xae, 0x0e, 0xff, 0xbf, 0xab, 0x14, 0xff, +0xbb, 0xa9, 0x12, 0xff, 0xc1, 0xad, 0x13, 0xff, 0xce, 0xb7, 0x18, 0xff, +0xe0, 0xc8, 0x23, 0xff, 0xeb, 0xd5, 0x28, 0xff, 0xe7, 0xd6, 0x24, 0xff, +0xdf, 0xcf, 0x37, 0xff, 0xe1, 0xd4, 0x80, 0xfd, 0xef, 0xe6, 0xcd, 0xd1, +0xf9, 0xf6, 0xf1, 0x83, 0xfe, 0xfd, 0xfc, 0x33, 0xff, 0xff, 0xff, 0x06, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xfd, 0x05, 0xef, 0xed, 0xea, 0x59, +0xc6, 0xbc, 0x98, 0xda, 0xa3, 0x8d, 0x1c, 0xff, 0xa9, 0x92, 0x00, 0xff, +0xb8, 0xa6, 0x0a, 0xff, 0xc9, 0xb5, 0x39, 0xff, 0xc4, 0xb2, 0x48, 0xff, +0xc0, 0xb0, 0x4d, 0xff, 0xbe, 0xaf, 0x52, 0xff, 0xbc, 0xad, 0x50, 0xff, +0xb9, 0xaa, 0x4d, 0xff, 0xb8, 0xa9, 0x4a, 0xff, 0xbc, 0xac, 0x47, 0xff, +0xc2, 0xb1, 0x44, 0xff, 0xd8, 0xc3, 0x52, 0xff, 0xe7, 0xd3, 0x50, 0xff, +0xe3, 0xd3, 0x48, 0xff, 0xdd, 0xd0, 0x73, 0xff, 0xe7, 0xdf, 0xb7, 0xec, +0xf5, 0xf0, 0xe3, 0xb0, 0xfc, 0xfa, 0xf6, 0x64, 0xff, 0xfe, 0xfd, 0x27, +0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c, +0xff, 0xfe, 0xfd, 0x30, 0xfe, 0xfc, 0xf9, 0x67, 0xfb, 0xf6, 0xeb, 0xa8, +0xf3, 0xea, 0xc8, 0xdf, 0xe7, 0xd8, 0x83, 0xfc, 0xc8, 0xac, 0x2d, 0xff, +0xaf, 0x91, 0x24, 0xff, 0xce, 0xbc, 0x60, 0xfe, 0xe8, 0xd7, 0x44, 0xff, +0xdf, 0xc9, 0x58, 0xff, 0xc3, 0xb3, 0x53, 0xff, 0xb8, 0xaa, 0x52, 0xff, +0xb6, 0xa8, 0x4c, 0xff, 0xba, 0xab, 0x4e, 0xff, 0xb8, 0xa8, 0x48, 0xff, +0xc2, 0xaf, 0x2b, 0xff, 0xb7, 0xa0, 0x01, 0xff, 0x93, 0x80, 0x17, 0xff, +0xbf, 0xba, 0xac, 0x9f, 0xdb, 0xda, 0xd9, 0x4e, 0xc4, 0xc0, 0xac, 0x99, +0xa1, 0x95, 0x5f, 0xe1, 0x8e, 0x7a, 0x1b, 0xff, 0x94, 0x7c, 0x00, 0xff, +0xaa, 0x92, 0x00, 0xff, 0xae, 0x98, 0x00, 0xff, 0xb2, 0x9e, 0x09, 0xff, +0xb0, 0x9d, 0x1e, 0xff, 0xb9, 0xa7, 0x3b, 0xff, 0xc2, 0xb0, 0x4a, 0xff, +0xb3, 0xa4, 0x45, 0xff, 0xbd, 0xad, 0x4e, 0xff, 0xba, 0xab, 0x47, 0xff, +0xca, 0xb7, 0x50, 0xff, 0xe1, 0xcc, 0x60, 0xff, 0xeb, 0xdb, 0x61, 0xff, +0xe8, 0xdd, 0x56, 0xff, 0xdf, 0xd4, 0x65, 0xff, 0xe3, 0xd8, 0x9b, 0xfb, +0xef, 0xe8, 0xd2, 0xcf, 0xf9, 0xf7, 0xf0, 0x81, 0xfe, 0xfd, 0xfc, 0x33, +0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfc, 0x06, 0xec, 0xeb, 0xe8, 0x59, +0xc4, 0xbc, 0x9e, 0xd4, 0x9d, 0x8b, 0x2a, 0xff, 0xa2, 0x8f, 0x00, 0xff, +0xbc, 0xaa, 0x2d, 0xff, 0xc3, 0xb3, 0x61, 0xff, 0xc5, 0xb5, 0x6b, 0xff, +0xc3, 0xb6, 0x71, 0xff, 0xc5, 0xb7, 0x75, 0xff, 0xc7, 0xb9, 0x76, 0xff, +0xc1, 0xb4, 0x73, 0xff, 0xb2, 0xa7, 0x6a, 0xff, 0xb9, 0xad, 0x6b, 0xff, +0xc9, 0xba, 0x70, 0xff, 0xd4, 0xc3, 0x73, 0xff, 0xe6, 0xd4, 0x7c, 0xff, +0xec, 0xe2, 0x7c, 0xff, 0xe2, 0xdc, 0x7c, 0xff, 0xe1, 0xd8, 0x95, 0xff, +0xe8, 0xe0, 0xb9, 0xf2, 0xf2, 0xed, 0xdb, 0xc7, 0xfa, 0xf6, 0xef, 0x8b, +0xfd, 0xfc, 0xfa, 0x50, 0xff, 0xfe, 0xfe, 0x24, 0xff, 0xff, 0xff, 0x0a, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x14, 0xff, 0xfe, 0xfc, 0x36, +0xfe, 0xfc, 0xf8, 0x65, 0xfc, 0xf8, 0xee, 0x9d, 0xf5, 0xf0, 0xda, 0xd1, +0xec, 0xe3, 0xb5, 0xf4, 0xe3, 0xd8, 0x7d, 0xff, 0xdf, 0xd4, 0x2c, 0xff, +0xd2, 0xbd, 0x00, 0xff, 0xb0, 0x97, 0x17, 0xff, 0xb9, 0xad, 0x84, 0xed, +0xca, 0xbe, 0x87, 0xf6, 0xe6, 0xd9, 0x6d, 0xff, 0xdf, 0xce, 0x79, 0xff, +0xc1, 0xb4, 0x6f, 0xff, 0xbd, 0xb1, 0x72, 0xff, 0xbf, 0xb2, 0x73, 0xff, +0xbf, 0xb2, 0x71, 0xff, 0xb5, 0xa9, 0x67, 0xff, 0xc4, 0xb3, 0x64, 0xff, +0xb1, 0x9e, 0x18, 0xff, 0x91, 0x81, 0x1e, 0xff, 0xc9, 0xc5, 0xba, 0x94, +0xf4, 0xf5, 0xf5, 0x04, 0xf4, 0xf4, 0xf4, 0x0d, 0xe2, 0xe2, 0xdf, 0x47, +0xc5, 0xc1, 0xb2, 0x96, 0xa2, 0x99, 0x6b, 0xda, 0x8c, 0x7b, 0x27, 0xfd, +0x8c, 0x78, 0x01, 0xff, 0xa2, 0x8d, 0x00, 0xff, 0xac, 0x9a, 0x0e, 0xff, +0xad, 0x9e, 0x35, 0xff, 0xb1, 0xa1, 0x50, 0xff, 0xa2, 0x96, 0x50, 0xff, +0xc0, 0xb1, 0x6a, 0xff, 0xc2, 0xb3, 0x6c, 0xff, 0xb9, 0xad, 0x6a, 0xff, +0xc3, 0xb5, 0x6f, 0xff, 0xd2, 0xc2, 0x75, 0xff, 0xe4, 0xd3, 0x81, 0xff, +0xeb, 0xe0, 0x80, 0xff, 0xe6, 0xde, 0x78, 0xff, 0xdf, 0xd6, 0x81, 0xff, +0xe3, 0xd9, 0xa8, 0xfb, 0xef, 0xe9, 0xd5, 0xcf, 0xf9, 0xf7, 0xf0, 0x82, +0xfe, 0xfd, 0xfc, 0x35, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfb, 0xfc, 0xfc, 0x05, 0xed, 0xec, 0xea, 0x4a, +0xc9, 0xc3, 0xb1, 0xbf, 0x9d, 0x90, 0x48, 0xfd, 0x96, 0x86, 0x09, 0xff, +0xb0, 0xa0, 0x3b, 0xff, 0xc2, 0xb4, 0x6f, 0xff, 0xc2, 0xb6, 0x7a, 0xff, +0xc2, 0xb7, 0x80, 0xff, 0xbd, 0xb1, 0x7e, 0xff, 0xc2, 0xb7, 0x84, 0xff, +0xc3, 0xb7, 0x85, 0xff, 0xba, 0xb0, 0x7f, 0xff, 0xb8, 0xad, 0x7c, 0xff, +0xc4, 0xb8, 0x83, 0xff, 0xcb, 0xbf, 0x86, 0xff, 0xdb, 0xcd, 0x90, 0xff, +0xed, 0xe2, 0x9c, 0xff, 0xed, 0xe7, 0x9c, 0xff, 0xe6, 0xe1, 0x98, 0xff, +0xe1, 0xda, 0x9e, 0xff, 0xe5, 0xde, 0xb1, 0xfe, 0xec, 0xe5, 0xc9, 0xea, +0xf3, 0xef, 0xdf, 0xc6, 0xf9, 0xf7, 0xee, 0x99, 0xfc, 0xfb, 0xf6, 0x6b, +0xfe, 0xfd, 0xfb, 0x44, 0xff, 0xff, 0xfe, 0x26, 0xff, 0xff, 0xff, 0x12, +0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x0b, 0xff, 0xff, 0xfe, 0x1b, +0xff, 0xff, 0xfe, 0x35, 0xff, 0xfd, 0xfa, 0x58, 0xfd, 0xfb, 0xf4, 0x83, +0xfa, 0xf6, 0xea, 0xb0, 0xf5, 0xef, 0xda, 0xd8, 0xed, 0xe6, 0xc2, 0xf4, +0xe5, 0xdc, 0xa7, 0xff, 0xe1, 0xd9, 0x93, 0xff, 0xe3, 0xdd, 0x85, 0xff, +0xe8, 0xdf, 0x66, 0xff, 0xcc, 0xbb, 0x10, 0xff, 0xa0, 0x8c, 0x12, 0xff, +0x9e, 0x95, 0x74, 0xd1, 0xc2, 0xbe, 0xb5, 0x9e, 0xd7, 0xce, 0xa7, 0xeb, +0xe6, 0xde, 0x8b, 0xff, 0xe2, 0xd5, 0x90, 0xff, 0xc1, 0xb6, 0x82, 0xff, +0xb9, 0xb0, 0x80, 0xff, 0xb8, 0xae, 0x80, 0xff, 0xb1, 0xa8, 0x7b, 0xff, +0xbf, 0xb4, 0x81, 0xff, 0xc7, 0xba, 0x7f, 0xff, 0xb5, 0xa4, 0x46, 0xff, +0x94, 0x86, 0x2a, 0xff, 0xc9, 0xc6, 0xbc, 0x96, 0xf8, 0xf7, 0xf9, 0x07, +0xfe, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x00, 0xf4, 0xf5, 0xf5, 0x0d, +0xe5, 0xe3, 0xe3, 0x3d, 0xca, 0xc6, 0xbc, 0x87, 0xa8, 0xa1, 0x80, 0xcd, +0x8e, 0x82, 0x3c, 0xf7, 0x8d, 0x7c, 0x0e, 0xff, 0x98, 0x87, 0x06, 0xff, +0x9e, 0x8f, 0x22, 0xff, 0xa7, 0x98, 0x4b, 0xff, 0xae, 0xa0, 0x63, 0xff, +0xc1, 0xb4, 0x77, 0xff, 0xbd, 0xb1, 0x7a, 0xff, 0xb2, 0xa9, 0x77, 0xff, +0xbd, 0xb1, 0x7e, 0xff, 0xc3, 0xb8, 0x82, 0xff, 0xcf, 0xc3, 0x89, 0xff, +0xe6, 0xda, 0x97, 0xff, 0xee, 0xe5, 0x99, 0xff, 0xe7, 0xe1, 0x92, 0xff, +0xdf, 0xd7, 0x96, 0xff, 0xe3, 0xdc, 0xb2, 0xfb, 0xef, 0xea, 0xd7, 0xd2, +0xf9, 0xf7, 0xf1, 0x89, 0xfd, 0xfd, 0xfb, 0x3c, 0xff, 0xff, 0xff, 0x0c, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfc, 0xfd, 0xfd, 0x01, 0xf1, 0xf1, 0xee, 0x30, +0xd3, 0xd0, 0xc8, 0x99, 0xa7, 0x9f, 0x75, 0xec, 0x93, 0x85, 0x29, 0xff, +0xa1, 0x93, 0x39, 0xff, 0xb7, 0xab, 0x6d, 0xff, 0xba, 0xaf, 0x7f, 0xff, +0x9b, 0x93, 0x71, 0xff, 0xba, 0xb1, 0x88, 0xff, 0xb3, 0xab, 0x86, 0xff, +0xbe, 0xb6, 0x90, 0xff, 0xbd, 0xb6, 0x90, 0xff, 0xbd, 0xb5, 0x91, 0xff, +0xbf, 0xb7, 0x93, 0xff, 0xb8, 0xb1, 0x8e, 0xff, 0xca, 0xc0, 0x97, 0xff, +0xde, 0xd3, 0xa3, 0xff, 0xea, 0xe2, 0xad, 0xff, 0xf1, 0xec, 0xb6, 0xff, +0xec, 0xea, 0xb3, 0xff, 0xe7, 0xe3, 0xb0, 0xff, 0xe2, 0xdd, 0xb0, 0xff, +0xe4, 0xde, 0xb9, 0xff, 0xe9, 0xe3, 0xc6, 0xf7, 0xef, 0xea, 0xd4, 0xe4, +0xf4, 0xf1, 0xe1, 0xca, 0xf8, 0xf6, 0xeb, 0xad, 0xfa, 0xf9, 0xf2, 0x90, +0xfc, 0xfc, 0xf6, 0x76, 0xfe, 0xfd, 0xf9, 0x60, 0xfe, 0xfd, 0xfb, 0x4e, +0xfe, 0xfe, 0xfc, 0x40, 0xff, 0xff, 0xfd, 0x36, 0xff, 0xff, 0xfe, 0x2f, +0xff, 0xff, 0xfe, 0x2c, 0xff, 0xfe, 0xfe, 0x29, 0xff, 0xff, 0xfe, 0x2a, +0xff, 0xff, 0xfe, 0x2f, 0xff, 0xff, 0xfd, 0x36, 0xff, 0xfe, 0xfc, 0x41, +0xfe, 0xfe, 0xfb, 0x52, 0xfe, 0xfd, 0xf8, 0x66, 0xfd, 0xfb, 0xf5, 0x80, +0xfa, 0xf8, 0xef, 0x9e, 0xf8, 0xf5, 0xe8, 0xbc, 0xf3, 0xf0, 0xdd, 0xd8, +0xed, 0xe8, 0xd0, 0xef, 0xe9, 0xe3, 0xc1, 0xfe, 0xe5, 0xde, 0xb6, 0xff, +0xe3, 0xdd, 0xaf, 0xff, 0xe6, 0xe2, 0xab, 0xff, 0xe9, 0xe5, 0xa8, 0xff, +0xed, 0xe7, 0x9f, 0xff, 0xd3, 0xc8, 0x6b, 0xff, 0xa8, 0x97, 0x1c, 0xff, +0x83, 0x74, 0x1b, 0xfb, 0x92, 0x8b, 0x72, 0xbd, 0xc1, 0xc0, 0xbe, 0x46, +0xe6, 0xe5, 0xe2, 0x57, 0xe4, 0xdd, 0xbe, 0xeb, 0xe4, 0xde, 0x9d, 0xff, +0xe1, 0xd6, 0xa2, 0xff, 0xc0, 0xb8, 0x91, 0xff, 0xba, 0xb3, 0x90, 0xff, +0xbf, 0xb7, 0x94, 0xff, 0xb6, 0xaf, 0x8e, 0xff, 0xba, 0xb2, 0x8e, 0xff, +0xc8, 0xbe, 0x91, 0xff, 0xb9, 0xac, 0x6b, 0xff, 0x96, 0x8b, 0x46, 0xff, +0xc9, 0xc6, 0xbd, 0x96, 0xf7, 0xf7, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x00, +0xf5, 0xf6, 0xf6, 0x07, 0xe8, 0xe8, 0xe8, 0x2e, 0xd0, 0xce, 0xca, 0x73, +0xb0, 0xab, 0x96, 0xbb, 0x95, 0x8c, 0x59, 0xec, 0x88, 0x7b, 0x24, 0xff, +0x8f, 0x80, 0x16, 0xff, 0x9a, 0x8d, 0x33, 0xff, 0xab, 0x9f, 0x5c, 0xff, +0xaa, 0x9f, 0x6f, 0xff, 0xa2, 0x98, 0x71, 0xff, 0xad, 0xa4, 0x7d, 0xff, +0xb4, 0xab, 0x85, 0xff, 0xb8, 0xb1, 0x8c, 0xff, 0xc1, 0xb9, 0x92, 0xff, +0xd6, 0xcc, 0xa0, 0xff, 0xeb, 0xe0, 0xac, 0xff, 0xee, 0xe8, 0xad, 0xff, +0xe7, 0xe4, 0xa7, 0xff, 0xe0, 0xdb, 0xa9, 0xff, 0xe4, 0xdd, 0xbc, 0xfd, +0xee, 0xea, 0xd8, 0xd9, 0xf9, 0xf6, 0xef, 0x94, 0xfd, 0xfd, 0xfb, 0x46, +0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfe, 0x00, 0xf6, 0xf6, 0xf6, 0x13, +0xe2, 0xe1, 0xde, 0x5d, 0xbd, 0xb8, 0xa8, 0xbc, 0x98, 0x8f, 0x5c, 0xf6, +0x8d, 0x83, 0x3d, 0xff, 0x9b, 0x90, 0x53, 0xff, 0xa5, 0x9c, 0x6f, 0xff, +0xb4, 0xac, 0x88, 0xff, 0xb7, 0xb0, 0x90, 0xff, 0xba, 0xb4, 0x96, 0xff, +0xbf, 0xb9, 0x9c, 0xff, 0xc2, 0xbc, 0xa0, 0xff, 0xbe, 0xb8, 0x9e, 0xff, +0xbb, 0xb6, 0x9e, 0xff, 0xb8, 0xb3, 0x9c, 0xff, 0xc1, 0xba, 0xa0, 0xff, +0xc6, 0xbf, 0xa3, 0xff, 0xd9, 0xd1, 0xb1, 0xff, 0xe8, 0xe1, 0xbe, 0xff, +0xee, 0xe9, 0xc5, 0xff, 0xf0, 0xec, 0xc9, 0xff, 0xef, 0xed, 0xca, 0xff, +0xec, 0xe9, 0xc7, 0xff, 0xe8, 0xe4, 0xc5, 0xff, 0xe5, 0xe1, 0xc3, 0xff, +0xe5, 0xe1, 0xc7, 0xff, 0xe8, 0xe4, 0xcc, 0xff, 0xe9, 0xe5, 0xce, 0xfb, +0xeb, 0xe6, 0xd2, 0xf4, 0xed, 0xe9, 0xd6, 0xec, 0xf0, 0xed, 0xdc, 0xe3, +0xf3, 0xef, 0xe0, 0xdc, 0xf3, 0xef, 0xe1, 0xd6, 0xf3, 0xf0, 0xe2, 0xd3, +0xf4, 0xf0, 0xe3, 0xd1, 0xf3, 0xf0, 0xe3, 0xd2, 0xf4, 0xf1, 0xe2, 0xd5, +0xf3, 0xf0, 0xe0, 0xdc, 0xf1, 0xed, 0xdc, 0xe4, 0xed, 0xe8, 0xd5, 0xed, +0xec, 0xe7, 0xd1, 0xf6, 0xea, 0xe5, 0xcc, 0xfe, 0xea, 0xe4, 0xca, 0xff, +0xe8, 0xe3, 0xc8, 0xff, 0xe6, 0xe1, 0xc5, 0xff, 0xe4, 0xe0, 0xc4, 0xff, +0xe6, 0xe3, 0xc3, 0xff, 0xea, 0xe7, 0xc4, 0xff, 0xe7, 0xe3, 0xbd, 0xff, +0xda, 0xd4, 0xa7, 0xff, 0xc2, 0xb8, 0x75, 0xff, 0x9a, 0x8d, 0x31, 0xff, +0x78, 0x6b, 0x13, 0xff, 0x7a, 0x73, 0x45, 0xdc, 0xa1, 0x9e, 0x96, 0x86, +0xcf, 0xcf, 0xce, 0x2a, 0xef, 0xef, 0xef, 0x00, 0xf8, 0xf8, 0xf5, 0x4e, +0xe7, 0xe2, 0xca, 0xec, 0xe5, 0xe1, 0xb2, 0xff, 0xe4, 0xdb, 0xb4, 0xff, +0xc3, 0xbc, 0xa0, 0xff, 0xb5, 0xb1, 0x9a, 0xff, 0xc1, 0xbb, 0xa3, 0xff, +0xbf, 0xba, 0xa2, 0xff, 0xb7, 0xb2, 0x9b, 0xff, 0xc2, 0xbb, 0x9c, 0xff, +0xb9, 0xaf, 0x80, 0xff, 0x97, 0x8e, 0x60, 0xff, 0xc9, 0xc7, 0xbe, 0x96, +0xf7, 0xf7, 0xf8, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfe, 0xfe, 0x00, 0xf8, 0xf8, 0xf8, 0x02, 0xed, 0xed, 0xed, 0x1e, +0xdb, 0xd9, 0xd8, 0x54, 0xbf, 0xbc, 0xb4, 0x96, 0xa2, 0x9d, 0x80, 0xd2, +0x8c, 0x84, 0x4a, 0xf6, 0x86, 0x7b, 0x33, 0xff, 0x8e, 0x83, 0x3e, 0xff, +0xa2, 0x98, 0x5e, 0xff, 0xa5, 0x9d, 0x72, 0xff, 0x8a, 0x83, 0x65, 0xff, +0xbd, 0xb6, 0x94, 0xff, 0xb4, 0xae, 0x92, 0xff, 0xa2, 0x9d, 0x85, 0xff, +0xac, 0xa7, 0x8d, 0xff, 0xd3, 0xcb, 0xa8, 0xff, 0xe4, 0xdd, 0xb6, 0xff, +0xec, 0xe8, 0xc0, 0xff, 0xeb, 0xe8, 0xc0, 0xff, 0xe3, 0xdf, 0xbb, 0xff, +0xe3, 0xdd, 0xc2, 0xff, 0xec, 0xe8, 0xd8, 0xe2, 0xf7, 0xf5, 0xee, 0xa5, +0xfd, 0xfd, 0xf9, 0x5b, 0xfe, 0xff, 0xfe, 0x21, 0xff, 0xff, 0xff, 0x02, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfb, 0xfb, 0xfc, 0x00, +0xf0, 0xf0, 0xef, 0x23, 0xd6, 0xd5, 0xd2, 0x74, 0xb2, 0xad, 0x9d, 0xc5, +0x93, 0x8c, 0x67, 0xf5, 0x86, 0x7e, 0x4e, 0xff, 0x8d, 0x85, 0x5b, 0xff, +0x9f, 0x99, 0x75, 0xff, 0x9c, 0x96, 0x7b, 0xff, 0xb6, 0xb1, 0x97, 0xff, +0xbc, 0xb7, 0xa0, 0xff, 0xac, 0xa7, 0x94, 0xff, 0xae, 0xaa, 0x98, 0xff, +0xa1, 0x9d, 0x8f, 0xff, 0xa6, 0xa3, 0x96, 0xff, 0xb8, 0xb4, 0xa6, 0xff, +0xb5, 0xb2, 0xa3, 0xff, 0xb4, 0xb0, 0xa1, 0xff, 0xc3, 0xbe, 0xac, 0xff, +0xd3, 0xce, 0xb9, 0xff, 0xde, 0xd9, 0xc2, 0xff, 0xe9, 0xe5, 0xcd, 0xff, +0xf1, 0xee, 0xd8, 0xff, 0xf1, 0xee, 0xdb, 0xff, 0xf1, 0xef, 0xde, 0xff, +0xef, 0xed, 0xe0, 0xff, 0xec, 0xeb, 0xdf, 0xff, 0xe9, 0xe6, 0xd9, 0xff, +0xea, 0xe7, 0xd9, 0xff, 0xeb, 0xe8, 0xd9, 0xff, 0xe9, 0xe6, 0xd8, 0xff, +0xe9, 0xe6, 0xd6, 0xff, 0xe8, 0xe4, 0xd5, 0xff, 0xe0, 0xdc, 0xcc, 0xff, +0xe1, 0xdd, 0xcd, 0xff, 0xe8, 0xe5, 0xd7, 0xff, 0xea, 0xe7, 0xd9, 0xff, +0xea, 0xe8, 0xd9, 0xff, 0xea, 0xe7, 0xda, 0xff, 0xeb, 0xe9, 0xdc, 0xff, +0xed, 0xeb, 0xde, 0xff, 0xee, 0xec, 0xdf, 0xff, 0xee, 0xeb, 0xdc, 0xff, +0xe8, 0xe6, 0xd3, 0xff, 0xe1, 0xde, 0xc6, 0xff, 0xd7, 0xd2, 0xb3, 0xff, +0xc5, 0xbe, 0x97, 0xff, 0xa5, 0x9c, 0x68, 0xff, 0x82, 0x77, 0x35, 0xff, +0x6c, 0x62, 0x1e, 0xff, 0x72, 0x6b, 0x3e, 0xe0, 0x94, 0x91, 0x84, 0x9a, +0xc0, 0xc0, 0xc0, 0x42, 0xe3, 0xe4, 0xe5, 0x09, 0xf6, 0xf6, 0xf7, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfc, 0xfc, 0xf9, 0x50, 0xe9, 0xe5, 0xd2, 0xec, +0xe7, 0xe4, 0xc6, 0xff, 0xe3, 0xde, 0xc3, 0xff, 0xc7, 0xc2, 0xb0, 0xff, +0xba, 0xb6, 0xa9, 0xff, 0xc6, 0xc2, 0xb3, 0xff, 0xc4, 0xbf, 0xb0, 0xff, +0xb5, 0xb1, 0xa3, 0xff, 0xc2, 0xbc, 0xa8, 0xff, 0xba, 0xb3, 0x91, 0xff, +0x98, 0x91, 0x71, 0xff, 0xca, 0xc8, 0xc1, 0x96, 0xf7, 0xf8, 0xf8, 0x08, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfb, 0xfb, 0xfc, 0x00, +0xf4, 0xf4, 0xf4, 0x0a, 0xe6, 0xe6, 0xe6, 0x30, 0xd0, 0xcf, 0xcd, 0x6a, +0xb5, 0xb2, 0xa6, 0xaa, 0x9a, 0x94, 0x78, 0xdd, 0x87, 0x81, 0x55, 0xfa, +0x84, 0x7c, 0x4c, 0xff, 0x93, 0x8a, 0x5d, 0xff, 0x9e, 0x97, 0x72, 0xff, +0xa2, 0x9c, 0x80, 0xff, 0x94, 0x8e, 0x78, 0xff, 0xa5, 0xa1, 0x8d, 0xff, +0xb8, 0xb2, 0x9d, 0xff, 0xc0, 0xba, 0xa6, 0xff, 0xcb, 0xc5, 0xae, 0xff, +0xdd, 0xd8, 0xbf, 0xff, 0xed, 0xea, 0xd0, 0xff, 0xec, 0xea, 0xd0, 0xff, +0xe5, 0xe2, 0xcb, 0xff, 0xe2, 0xde, 0xcb, 0xff, 0xea, 0xe7, 0xd9, 0xef, +0xf5, 0xf3, 0xeb, 0xbe, 0xfc, 0xfb, 0xf8, 0x78, 0xfe, 0xfe, 0xfd, 0x36, +0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xf9, 0xf9, 0xf9, 0x03, 0xeb, 0xeb, 0xeb, 0x28, 0xd4, 0xd4, 0xd0, 0x6c, +0xb6, 0xb3, 0xa7, 0xb5, 0x99, 0x94, 0x7f, 0xe7, 0x88, 0x82, 0x65, 0xff, +0x82, 0x7c, 0x5d, 0xff, 0x8c, 0x85, 0x69, 0xff, 0xa0, 0x99, 0x80, 0xff, +0xad, 0xa8, 0x92, 0xff, 0xa9, 0xa4, 0x92, 0xff, 0xa1, 0x9d, 0x90, 0xff, +0x99, 0x96, 0x8c, 0xff, 0xb3, 0xb0, 0xa5, 0xff, 0x98, 0x96, 0x8e, 0xff, +0x81, 0x7e, 0x78, 0xff, 0xa4, 0xa0, 0x97, 0xff, 0xaa, 0xa7, 0x9d, 0xff, +0xaf, 0xac, 0xa3, 0xff, 0xb9, 0xb6, 0xac, 0xff, 0xb9, 0xb6, 0xab, 0xff, +0xca, 0xc7, 0xba, 0xff, 0xcf, 0xcb, 0xbd, 0xff, 0xd9, 0xd6, 0xc9, 0xff, +0xde, 0xdc, 0xcf, 0xff, 0xea, 0xe9, 0xdd, 0xff, 0xef, 0xee, 0xe4, 0xff, +0xed, 0xec, 0xe3, 0xff, 0xed, 0xec, 0xe4, 0xff, 0xeb, 0xea, 0xe4, 0xff, +0xe6, 0xe4, 0xde, 0xff, 0xe3, 0xe1, 0xdb, 0xff, 0xe5, 0xe4, 0xde, 0xff, +0xeb, 0xea, 0xe3, 0xff, 0xe7, 0xe6, 0xde, 0xff, 0xe5, 0xe3, 0xdb, 0xff, +0xe7, 0xe6, 0xdb, 0xff, 0xe4, 0xe2, 0xd5, 0xff, 0xdc, 0xd9, 0xc9, 0xff, +0xd6, 0xd2, 0xbf, 0xff, 0xc5, 0xc1, 0xaa, 0xff, 0xb5, 0xaf, 0x95, 0xff, +0xa0, 0x9a, 0x78, 0xff, 0x87, 0x7f, 0x56, 0xff, 0x71, 0x69, 0x38, 0xff, +0x68, 0x62, 0x35, 0xf7, 0x78, 0x74, 0x57, 0xd2, 0x99, 0x97, 0x8e, 0x92, +0xbf, 0xbe, 0xbe, 0x46, 0xdf, 0xdf, 0xdf, 0x0f, 0xf3, 0xf3, 0xf3, 0x00, +0xfc, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfc, 0xfc, 0xfa, 0x50, 0xe8, 0xe5, 0xd8, 0xec, 0xe5, 0xe4, 0xd2, 0xff, +0xe2, 0xdd, 0xce, 0xff, 0xbe, 0xbb, 0xb1, 0xff, 0x9b, 0x99, 0x93, 0xff, +0x9b, 0x99, 0x93, 0xff, 0x96, 0x94, 0x8d, 0xff, 0xad, 0xab, 0xa2, 0xff, +0xc2, 0xbf, 0xb2, 0xff, 0xbd, 0xb7, 0xa1, 0xff, 0x98, 0x92, 0x7b, 0xff, +0xca, 0xc8, 0xc3, 0x96, 0xf7, 0xf8, 0xf7, 0x08, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfd, 0xfd, 0x00, 0xf8, 0xf8, 0xf9, 0x00, 0xef, 0xef, 0xef, 0x13, +0xe0, 0xdf, 0xdf, 0x3d, 0xca, 0xc9, 0xc5, 0x77, 0xb0, 0xad, 0xa2, 0xb2, +0x97, 0x92, 0x7f, 0xe0, 0x87, 0x81, 0x65, 0xfb, 0x80, 0x7a, 0x5c, 0xff, +0x8e, 0x88, 0x68, 0xff, 0x9e, 0x99, 0x7e, 0xff, 0xa6, 0xa1, 0x8c, 0xff, +0xaf, 0xab, 0x98, 0xff, 0xaa, 0xa6, 0x97, 0xff, 0x9f, 0x9a, 0x90, 0xff, +0xbc, 0xb7, 0xa8, 0xff, 0xd6, 0xd3, 0xc1, 0xff, 0xe3, 0xe1, 0xd2, 0xff, +0xe7, 0xe5, 0xda, 0xff, 0xde, 0xdc, 0xd1, 0xff, 0xdf, 0xdc, 0xcf, 0xff, +0xe6, 0xe4, 0xd7, 0xf9, 0xf2, 0xf0, 0xe8, 0xd6, 0xfa, 0xf9, 0xf5, 0x99, +0xfe, 0xfd, 0xfc, 0x56, 0xfe, 0xff, 0xfe, 0x21, 0xff, 0xff, 0xff, 0x04, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfd, 0xfe, 0x00, 0xf8, 0xf9, 0xf9, 0x00, 0xee, 0xee, 0xed, 0x1b, +0xdd, 0xdc, 0xda, 0x4d, 0xc3, 0xc2, 0xbd, 0x8a, 0xa9, 0xa6, 0x9b, 0xc1, +0x90, 0x8c, 0x7c, 0xe7, 0x81, 0x7d, 0x68, 0xfb, 0x83, 0x7e, 0x68, 0xff, +0x85, 0x81, 0x6d, 0xff, 0x95, 0x90, 0x7d, 0xff, 0xa1, 0x9e, 0x8d, 0xff, +0x97, 0x94, 0x86, 0xff, 0x9b, 0x98, 0x8d, 0xff, 0xa0, 0x9e, 0x93, 0xff, +0xa1, 0x9f, 0x96, 0xff, 0xa2, 0xa0, 0x98, 0xff, 0xa3, 0xa1, 0x99, 0xff, +0x83, 0x82, 0x7e, 0xff, 0x7e, 0x7d, 0x7a, 0xff, 0x73, 0x72, 0x70, 0xff, +0x82, 0x81, 0x7f, 0xff, 0x88, 0x86, 0x81, 0xff, 0x71, 0x70, 0x6f, 0xff, +0x8f, 0x8e, 0x8c, 0xff, 0xa7, 0xa5, 0x9e, 0xff, 0x91, 0x90, 0x8b, 0xff, +0xad, 0xab, 0xa3, 0xff, 0xb2, 0xaf, 0xa6, 0xff, 0xbd, 0xbb, 0xb1, 0xff, +0xc4, 0xc1, 0xb6, 0xff, 0xbb, 0xb8, 0xad, 0xff, 0xba, 0xb7, 0xab, 0xff, +0xc0, 0xbc, 0xaf, 0xff, 0xab, 0xa7, 0x9b, 0xff, 0xa9, 0xa5, 0x95, 0xff, +0xaa, 0xa6, 0x93, 0xff, 0x9b, 0x96, 0x80, 0xff, 0x85, 0x80, 0x69, 0xff, +0x73, 0x6e, 0x53, 0xff, 0x6c, 0x67, 0x4a, 0xff, 0x6b, 0x66, 0x4a, 0xf6, +0x76, 0x72, 0x5c, 0xda, 0x8d, 0x8a, 0x7e, 0xab, 0xac, 0xaa, 0xa8, 0x6e, +0xcb, 0xca, 0xca, 0x32, 0xe3, 0xe3, 0xe4, 0x0b, 0xf3, 0xf3, 0xf4, 0x00, +0xfb, 0xfb, 0xfb, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfb, 0x51, +0xe8, 0xe5, 0xdb, 0xed, 0xda, 0xd7, 0xcf, 0xff, 0xd3, 0xd1, 0xc7, 0xff, +0x95, 0x93, 0x8e, 0xff, 0x6c, 0x6b, 0x69, 0xff, 0x82, 0x81, 0x7f, 0xff, +0x3f, 0x3f, 0x42, 0xff, 0x62, 0x61, 0x61, 0xff, 0xae, 0xab, 0xa4, 0xff, +0xa9, 0xa5, 0x98, 0xff, 0x95, 0x90, 0x80, 0xff, 0xca, 0xc9, 0xc4, 0x96, +0xf7, 0xf7, 0xf7, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xff, 0xff, 0x00, 0xfc, 0xfc, 0xfd, 0x00, +0xf6, 0xf7, 0xf7, 0x02, 0xed, 0xed, 0xed, 0x18, 0xde, 0xde, 0xdc, 0x40, +0xc8, 0xc7, 0xc4, 0x77, 0xb0, 0xaf, 0xa6, 0xae, 0x98, 0x95, 0x87, 0xd9, +0x87, 0x83, 0x71, 0xf5, 0x81, 0x7d, 0x68, 0xff, 0x85, 0x80, 0x6c, 0xff, +0x8b, 0x87, 0x75, 0xff, 0x98, 0x95, 0x86, 0xff, 0xa2, 0x9f, 0x93, 0xff, +0xac, 0xaa, 0x9f, 0xff, 0xb9, 0xb7, 0xab, 0xff, 0xc3, 0xbf, 0xb4, 0xff, +0xd6, 0xd5, 0xcb, 0xff, 0xde, 0xdd, 0xd6, 0xff, 0xdb, 0xd9, 0xd2, 0xff, +0xd9, 0xd7, 0xce, 0xff, 0xe1, 0xde, 0xd5, 0xff, 0xeb, 0xe9, 0xe2, 0xec, +0xf6, 0xf4, 0xf0, 0xc0, 0xfc, 0xfb, 0xf8, 0x84, 0xfe, 0xfe, 0xfd, 0x49, +0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfb, 0xfb, 0xfb, 0x00, +0xf4, 0xf5, 0xf4, 0x06, 0xe9, 0xe9, 0xe9, 0x21, 0xd9, 0xd9, 0xd7, 0x4a, +0xc5, 0xc4, 0xc1, 0x7a, 0xae, 0xad, 0xa7, 0xa7, 0x9a, 0x98, 0x8e, 0xcd, +0x8a, 0x87, 0x7c, 0xe7, 0x80, 0x7d, 0x72, 0xf7, 0x7c, 0x79, 0x6d, 0xff, +0x7c, 0x78, 0x6c, 0xff, 0x7f, 0x7c, 0x70, 0xff, 0x87, 0x84, 0x79, 0xff, +0x8a, 0x87, 0x7d, 0xff, 0x8d, 0x8b, 0x82, 0xff, 0x91, 0x8e, 0x85, 0xff, +0x97, 0x94, 0x8d, 0xff, 0x8c, 0x8a, 0x82, 0xff, 0x90, 0x8f, 0x86, 0xff, +0x64, 0x62, 0x5b, 0xff, 0x57, 0x56, 0x51, 0xff, 0x64, 0x62, 0x5e, 0xff, +0x6c, 0x6b, 0x65, 0xff, 0x85, 0x83, 0x7c, 0xff, 0x94, 0x92, 0x8a, 0xff, +0x8e, 0x8c, 0x84, 0xff, 0x96, 0x94, 0x8b, 0xff, 0x8f, 0x8c, 0x83, 0xff, +0x87, 0x83, 0x79, 0xff, 0x7e, 0x7b, 0x6e, 0xff, 0x79, 0x76, 0x69, 0xff, +0x6e, 0x6b, 0x5d, 0xff, 0x6d, 0x69, 0x5a, 0xff, 0x6c, 0x68, 0x58, 0xfe, +0x6f, 0x6b, 0x5b, 0xf3, 0x76, 0x72, 0x65, 0xe0, 0x84, 0x82, 0x77, 0xc2, +0x97, 0x97, 0x90, 0x9a, 0xb1, 0xb0, 0xae, 0x69, 0xc9, 0xc9, 0xc8, 0x38, +0xde, 0xdd, 0xde, 0x13, 0xee, 0xee, 0xee, 0x00, 0xf8, 0xf8, 0xf8, 0x00, +0xfc, 0xfc, 0xfc, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfc, 0x47, 0xe5, 0xe3, 0xda, 0xe7, +0xc6, 0xc4, 0xb7, 0xff, 0xbf, 0xbc, 0xb2, 0xff, 0x88, 0x86, 0x80, 0xff, +0x5d, 0x5c, 0x5a, 0xff, 0x71, 0x70, 0x6b, 0xff, 0x80, 0x7f, 0x7a, 0xff, +0x80, 0x7e, 0x78, 0xff, 0x99, 0x97, 0x8f, 0xff, 0x90, 0x8d, 0x81, 0xff, +0x89, 0x86, 0x76, 0xff, 0xcc, 0xcb, 0xc7, 0x8b, 0xf8, 0xf8, 0xf8, 0x06, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xf6, 0xf7, 0xf7, 0x01, +0xee, 0xee, 0xed, 0x14, 0xe0, 0xe0, 0xdf, 0x37, 0xce, 0xcd, 0xca, 0x65, +0xb8, 0xb6, 0xb1, 0x98, 0xa2, 0x9f, 0x98, 0xc4, 0x90, 0x8e, 0x83, 0xe6, +0x84, 0x81, 0x75, 0xf9, 0x80, 0x7d, 0x71, 0xff, 0x82, 0x7f, 0x74, 0xff, +0x8b, 0x88, 0x7e, 0xff, 0x8d, 0x8a, 0x81, 0xff, 0xa6, 0xa3, 0x99, 0xff, +0xb1, 0xae, 0xa4, 0xff, 0xca, 0xc9, 0xc0, 0xff, 0xd9, 0xd9, 0xd2, 0xff, +0xd7, 0xd6, 0xd0, 0xff, 0xda, 0xd8, 0xd2, 0xff, 0xdc, 0xd9, 0xd2, 0xff, +0xe4, 0xe1, 0xda, 0xfd, 0xef, 0xed, 0xe8, 0xe5, 0xf9, 0xf8, 0xf4, 0xb8, +0xfe, 0xfd, 0xfb, 0x81, 0xff, 0xff, 0xfe, 0x4d, 0xff, 0xff, 0xfe, 0x26, +0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfd, 0xfe, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xf5, 0xf5, 0xf6, 0x02, +0xee, 0xed, 0xee, 0x10, 0xe2, 0xe2, 0xe2, 0x29, 0xd5, 0xd5, 0xd5, 0x48, +0xc7, 0xc6, 0xc4, 0x69, 0xb7, 0xb7, 0xb4, 0x88, 0xa9, 0xa8, 0xa4, 0xa3, +0x9c, 0x9b, 0x96, 0xbb, 0x91, 0x8f, 0x8a, 0xcd, 0x89, 0x88, 0x82, 0xdb, +0x83, 0x82, 0x7c, 0xe6, 0x81, 0x7f, 0x78, 0xee, 0x7d, 0x7b, 0x75, 0xf3, +0x78, 0x76, 0x6f, 0xf7, 0x78, 0x76, 0x6e, 0xfa, 0x74, 0x73, 0x6b, 0xfb, +0x74, 0x72, 0x69, 0xfc, 0x70, 0x6e, 0x66, 0xfc, 0x74, 0x73, 0x6a, 0xfc, +0x76, 0x73, 0x6d, 0xfb, 0x73, 0x71, 0x6a, 0xfa, 0x76, 0x74, 0x6c, 0xf7, +0x75, 0x73, 0x6c, 0xf4, 0x76, 0x74, 0x6d, 0xee, 0x79, 0x77, 0x70, 0xe6, +0x7e, 0x7c, 0x75, 0xda, 0x84, 0x83, 0x7d, 0xcb, 0x8e, 0x8d, 0x87, 0xb7, +0x99, 0x99, 0x94, 0x9e, 0xa8, 0xa7, 0xa3, 0x81, 0xb8, 0xb7, 0xb5, 0x5f, +0xc8, 0xc8, 0xc7, 0x3e, 0xd7, 0xd7, 0xd8, 0x21, 0xe4, 0xe5, 0xe5, 0x0b, +0xf0, 0xf0, 0xf0, 0x00, 0xf7, 0xf7, 0xf7, 0x00, 0xfc, 0xfc, 0xfc, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x28, 0xea, 0xe8, 0xe4, 0xb4, 0xb3, 0xb1, 0xa6, 0xfb, +0x8c, 0x89, 0x80, 0xff, 0x71, 0x70, 0x69, 0xff, 0x70, 0x6e, 0x67, 0xff, +0x66, 0x64, 0x5c, 0xff, 0x67, 0x65, 0x5d, 0xff, 0x71, 0x6f, 0x67, 0xff, +0x79, 0x77, 0x6f, 0xff, 0x70, 0x6d, 0x5f, 0xff, 0x85, 0x82, 0x75, 0xe1, +0xd4, 0xd4, 0xd2, 0x5b, 0xf9, 0xf9, 0xf9, 0x01, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xfd, 0xfd, 0xfd, 0x00, 0xf8, 0xf8, 0xf8, 0x00, 0xf1, 0xf1, 0xf1, 0x0a, +0xe7, 0xe7, 0xe6, 0x23, 0xd8, 0xd8, 0xd7, 0x46, 0xc7, 0xc6, 0xc4, 0x71, +0xb3, 0xb3, 0xaf, 0x9d, 0xa0, 0x9f, 0x9b, 0xc3, 0x90, 0x8e, 0x88, 0xe1, +0x84, 0x83, 0x7c, 0xf5, 0x7c, 0x7a, 0x73, 0xff, 0x79, 0x76, 0x6f, 0xff, +0x87, 0x84, 0x7c, 0xff, 0x9b, 0x98, 0x90, 0xff, 0xa9, 0xa7, 0x9e, 0xff, +0xb4, 0xb1, 0xaa, 0xff, 0xc8, 0xc6, 0xbf, 0xff, 0xcc, 0xcb, 0xc2, 0xff, +0xd0, 0xce, 0xc6, 0xff, 0xd4, 0xd1, 0xc7, 0xff, 0xe0, 0xdd, 0xd3, 0xfb, +0xee, 0xec, 0xe5, 0xe3, 0xf9, 0xf8, 0xf4, 0xbc, 0xff, 0xff, 0xfe, 0x8b, +0xff, 0xff, 0xff, 0x5b, 0xff, 0xff, 0xff, 0x35, 0xff, 0xff, 0xff, 0x1b, +0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfd, 0xfd, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xf7, 0xf7, 0xf7, 0x00, +0xf2, 0xf2, 0xf3, 0x04, 0xec, 0xec, 0xec, 0x0d, 0xe6, 0xe6, 0xe6, 0x1a, +0xde, 0xde, 0xde, 0x29, 0xd7, 0xd7, 0xd6, 0x37, 0xd0, 0xd0, 0xcf, 0x45, +0xca, 0xca, 0xc8, 0x53, 0xc4, 0xc4, 0xc2, 0x5e, 0xc0, 0xc0, 0xbe, 0x68, +0xbb, 0xbb, 0xb9, 0x70, 0xb8, 0xb8, 0xb6, 0x75, 0xb7, 0xb6, 0xb5, 0x79, +0xb5, 0xb5, 0xb3, 0x7a, 0xb4, 0xb4, 0xb2, 0x79, 0xb5, 0xb5, 0xb3, 0x76, +0xb7, 0xb6, 0xb5, 0x70, 0xb9, 0xb9, 0xb8, 0x69, 0xbd, 0xbd, 0xbb, 0x5f, +0xc2, 0xc2, 0xc2, 0x53, 0xc8, 0xc9, 0xc8, 0x45, 0xcf, 0xcf, 0xcf, 0x36, +0xd7, 0xd7, 0xd7, 0x26, 0xdf, 0xdf, 0xde, 0x18, 0xe6, 0xe6, 0xe6, 0x0b, +0xed, 0xed, 0xed, 0x03, 0xf3, 0xf3, 0xf3, 0x00, 0xf8, 0xf8, 0xf8, 0x00, +0xfc, 0xfc, 0xfc, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xff, 0x07, +0xf5, 0xf5, 0xf5, 0x3f, 0xd9, 0xd9, 0xd6, 0x80, 0xb4, 0xb4, 0xb0, 0x98, +0xa7, 0xa7, 0xa4, 0x9a, 0xa6, 0xa6, 0xa3, 0x9a, 0xa7, 0xa6, 0xa4, 0x9c, +0xa6, 0xa5, 0xa1, 0x9c, 0xa4, 0xa4, 0xa1, 0x9d, 0xa2, 0xa2, 0xa0, 0x9d, +0xa8, 0xa7, 0xa5, 0x92, 0xc1, 0xc0, 0xbf, 0x5f, 0xe6, 0xe6, 0xe6, 0x18, +0xfb, 0xfb, 0xfb, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xfb, 0xfb, 0xfb, 0x00, 0xf6, 0xf6, 0xf6, 0x00, 0xf0, 0xf0, 0xf0, 0x0c, +0xe6, 0xe6, 0xe6, 0x21, 0xd9, 0xd9, 0xd8, 0x40, 0xca, 0xca, 0xc8, 0x64, +0xba, 0xba, 0xb7, 0x88, 0xaa, 0xa9, 0xa7, 0xab, 0x9a, 0x99, 0x95, 0xc8, +0x8e, 0x8c, 0x88, 0xdf, 0x87, 0x86, 0x81, 0xf0, 0x86, 0x84, 0x7f, 0xfa, +0x8d, 0x8b, 0x84, 0xff, 0x98, 0x95, 0x8c, 0xff, 0xa2, 0x9f, 0x96, 0xff, +0xa8, 0xa5, 0x9a, 0xff, 0xad, 0xa9, 0x9c, 0xff, 0xb0, 0xad, 0x9e, 0xff, +0xb1, 0xae, 0xa0, 0xff, 0xb9, 0xb6, 0xac, 0xf6, 0xc2, 0xc0, 0xb7, 0xd7, +0xce, 0xce, 0xcc, 0xa9, 0xe5, 0xe5, 0xe4, 0x70, 0xf2, 0xf2, 0xf1, 0x3a, +0xfa, 0xfa, 0xfa, 0x13, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfc, 0xfc, 0xfd, 0x00, +0xfb, 0xfb, 0xfb, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0xf9, 0xf9, 0xf9, 0x00, +0xf7, 0xf7, 0xf7, 0x00, 0xf5, 0xf5, 0xf5, 0x00, 0xf4, 0xf4, 0xf4, 0x00, +0xf3, 0xf3, 0xf3, 0x00, 0xf2, 0xf2, 0xf2, 0x00, 0xf2, 0xf2, 0xf2, 0x00, +0xf2, 0xf2, 0xf2, 0x00, 0xf2, 0xf2, 0xf2, 0x00, 0xf2, 0xf2, 0xf2, 0x00, +0xf4, 0xf4, 0xf4, 0x00, 0xf5, 0xf5, 0xf5, 0x00, 0xf6, 0xf6, 0xf6, 0x00, +0xf8, 0xf8, 0xf8, 0x00, 0xfa, 0xfa, 0xfa, 0x00, 0xfb, 0xfb, 0xfb, 0x00, +0xfd, 0xfd, 0xfd, 0x00, 0xfd, 0xfd, 0xfd, 0x00, 0xfe, 0xfe, 0xfe, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfd, 0xfd, 0x00, +0xf6, 0xf6, 0xf5, 0x05, 0xee, 0xee, 0xee, 0x09, 0xeb, 0xeb, 0xeb, 0x09, +0xeb, 0xeb, 0xeb, 0x06, 0xeb, 0xeb, 0xeb, 0x04, 0xea, 0xea, 0xea, 0x08, +0xea, 0xea, 0xeb, 0x0a, 0xea, 0xea, 0xeb, 0x0a, 0xec, 0xec, 0xec, 0x08, +0xf0, 0xf1, 0xf1, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfd, 0xfe, 0xfe, 0x00, +0xfb, 0xfb, 0xfb, 0x00, 0xf8, 0xf8, 0xf8, 0x00, 0xf3, 0xf3, 0xf3, 0x01, +0xec, 0xec, 0xec, 0x0e, 0xe2, 0xe3, 0xe3, 0x24, 0xd9, 0xd8, 0xd8, 0x3c, +0xcd, 0xcd, 0xcc, 0x56, 0xc1, 0xc1, 0xc0, 0x72, 0xb7, 0xb6, 0xb5, 0x8c, +0xae, 0xae, 0xab, 0xa3, 0xaa, 0xaa, 0xa7, 0xb7, 0xac, 0xab, 0xa6, 0xc7, +0xb1, 0xb0, 0xab, 0xd3, 0xb8, 0xb7, 0xb1, 0xd8, 0xbc, 0xbb, 0xb4, 0xd5, +0xbe, 0xbc, 0xb5, 0xd3, 0xbb, 0xb9, 0xb1, 0xcb, 0xba, 0xb9, 0xb6, 0xb1, +0xc1, 0xc1, 0xc1, 0x87, 0xd4, 0xd4, 0xd4, 0x50, 0xeb, 0xeb, 0xeb, 0x19, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x31, +0xff, 0xff, 0xff, 0x37, 0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x01, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x0e, +0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x05, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x19, 0xff, 0xff, 0xff, 0x1d, +0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x0d, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x36, +0xff, 0xff, 0xff, 0x34, 0xff, 0xff, 0xff, 0x17, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x08, +0xff, 0xff, 0xff, 0x15, 0xff, 0xff, 0xff, 0x03, 0xfe, 0xfe, 0xfe, 0x00, +0xfe, 0xfe, 0xfe, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xff, 0xff, 0xff, 0x08, +0xff, 0xff, 0xff, 0x18, 0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x07, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x0f, +0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x0b, 0xff, 0xff, 0xff, 0x04, +0xfc, 0xfc, 0xfc, 0x00, 0xfb, 0xfb, 0xfb, 0x00, 0xf9, 0xf8, 0xf9, 0x00, +0xf5, 0xf5, 0xf6, 0x00, 0xf1, 0xf1, 0xf1, 0x05, 0xec, 0xec, 0xec, 0x0d, +0xe6, 0xe6, 0xe6, 0x18, 0xe0, 0xe1, 0xe0, 0x25, 0xdd, 0xdd, 0xdd, 0x33, +0xdf, 0xdf, 0xde, 0x45, 0xef, 0xee, 0xee, 0x5f, 0xed, 0xed, 0xec, 0x5a, +0xec, 0xec, 0xeb, 0x4e, 0xf4, 0xf4, 0xf4, 0x46, 0xf9, 0xf9, 0xf8, 0x34, +0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x0a, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x4a, +0xab, 0xab, 0xab, 0xbb, 0x5f, 0x5f, 0x5f, 0xee, 0x5c, 0x5c, 0x5c, 0xf5, +0x7e, 0x7e, 0x7e, 0xd8, 0xe8, 0xe8, 0xe8, 0x7a, 0xff, 0xff, 0xff, 0x10, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03, +0xdd, 0xdd, 0xdd, 0x78, 0xaa, 0xaa, 0xaa, 0xbc, 0xfd, 0xfd, 0xfd, 0x30, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xf0, 0xf0, 0x50, +0xa1, 0xa1, 0xa1, 0xc2, 0xf3, 0xf3, 0xf3, 0x4f, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x03, 0xe0, 0xe0, 0xe0, 0x78, +0x8e, 0x8e, 0x8e, 0xd3, 0x83, 0x83, 0x83, 0xda, 0x83, 0x83, 0x83, 0xdc, +0x82, 0x82, 0x82, 0xd9, 0xa3, 0xa3, 0xa3, 0xbe, 0xf6, 0xf6, 0xf6, 0x62, +0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0e, 0xeb, 0xeb, 0xeb, 0x78, +0x85, 0x85, 0x85, 0xd5, 0x5c, 0x5c, 0x5c, 0xf3, 0x5d, 0x5d, 0x5d, 0xf1, +0x97, 0x97, 0x97, 0xca, 0xf8, 0xf8, 0xf8, 0x63, 0xff, 0xff, 0xff, 0x07, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x09, 0xd5, 0xd5, 0xd5, 0x8b, 0x90, 0x90, 0x90, 0xd2, +0xe6, 0xe6, 0xe6, 0x77, 0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0d, 0xd5, 0xd5, 0xd5, 0x90, 0x8e, 0x8e, 0x8e, 0xd1, +0xe1, 0xe1, 0xe1, 0x71, 0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x26, +0xac, 0xac, 0xac, 0xb4, 0xd3, 0xd3, 0xd3, 0x81, 0xff, 0xff, 0xff, 0x06, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfb, 0xfb, 0xfb, 0x39, 0xa6, 0xa6, 0xa6, 0xc0, 0xe4, 0xe4, 0xe4, 0x6a, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x20, +0xb4, 0xb4, 0xb4, 0xb2, 0xcf, 0xcf, 0xcf, 0x8a, 0xff, 0xff, 0xff, 0x08, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x00, 0xfd, 0xfd, 0xfe, 0x00, +0xfc, 0xfc, 0xfd, 0x00, 0xfc, 0xfc, 0xfc, 0x00, 0xe8, 0xe8, 0xe8, 0x58, +0x8e, 0x8e, 0x8e, 0xcc, 0xc1, 0xc1, 0xc1, 0xa4, 0xfb, 0xfb, 0xfb, 0x1e, +0xf8, 0xf9, 0xf9, 0x08, 0xfb, 0xfb, 0xfb, 0x07, 0xf2, 0xf2, 0xf2, 0x5c, +0x97, 0x97, 0x97, 0xca, 0xd9, 0xd9, 0xd9, 0x7b, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x41, 0x74, 0x74, 0x74, 0xe7, 0x23, 0x23, 0x23, 0xff, +0x90, 0x90, 0x90, 0xd7, 0xa4, 0xa4, 0xa4, 0xc5, 0x55, 0x55, 0x55, 0xf7, +0x30, 0x30, 0x30, 0xff, 0xe7, 0xe7, 0xe7, 0x7a, 0xff, 0xff, 0xff, 0x02, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0b, 0xaa, 0xaa, 0xaa, 0xbd, +0x30, 0x30, 0x30, 0xff, 0xfa, 0xfa, 0xfa, 0x57, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xda, 0xda, 0xda, 0x87, 0x15, 0x15, 0x15, 0xff, +0xe1, 0xe1, 0xe1, 0x87, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0c, 0xaa, 0xaa, 0xaa, 0xbe, 0x12, 0x12, 0x12, 0xff, +0x76, 0x76, 0x76, 0xeb, 0x79, 0x79, 0x79, 0xdc, 0x7a, 0x7a, 0x7a, 0xe3, +0x37, 0x37, 0x37, 0xff, 0x55, 0x55, 0x55, 0xf5, 0xfb, 0xfb, 0xfb, 0x4c, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x04, +0xea, 0xea, 0xea, 0x7e, 0x31, 0x31, 0x31, 0xff, 0x45, 0x45, 0x45, 0xfe, +0x9d, 0x9d, 0x9d, 0xcb, 0x96, 0x96, 0x96, 0xd2, 0x35, 0x35, 0x35, 0xff, +0x4a, 0x4a, 0x4a, 0xf8, 0xf6, 0xf6, 0xf6, 0x66, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x17, +0x98, 0x98, 0x98, 0xd3, 0x00, 0x00, 0x00, 0xff, 0x85, 0x85, 0x85, 0xdf, +0xff, 0xff, 0xff, 0x25, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x3e, +0x5c, 0x5c, 0x5c, 0xf4, 0x00, 0x00, 0x00, 0xff, 0xb4, 0xb4, 0xb4, 0xb5, +0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4a, 0x34, 0x34, 0x34, 0xff, +0x92, 0x92, 0x92, 0xcc, 0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf4, 0xf4, 0xf4, 0x67, +0x26, 0x26, 0x26, 0xff, 0xbc, 0xbc, 0xbc, 0xab, 0xff, 0xff, 0xff, 0x04, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x41, 0x47, 0x47, 0x47, 0xff, +0x88, 0x88, 0x88, 0xd3, 0xff, 0xff, 0xff, 0x15, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xcf, 0xcf, 0xcf, 0x99, 0x00, 0x00, 0x00, 0xff, +0x3a, 0x3a, 0x3a, 0xff, 0xff, 0xff, 0xff, 0x58, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0e, 0xb0, 0xb0, 0xb0, 0xbf, 0x00, 0x00, 0x00, 0xff, +0xa3, 0xa3, 0xa3, 0xbd, 0xff, 0xff, 0xff, 0x06, 0xc8, 0xc8, 0xc8, 0xa5, +0x15, 0x15, 0x15, 0xff, 0xd4, 0xd4, 0xd4, 0xab, 0xff, 0xff, 0xff, 0x22, +0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x64, 0x50, 0x50, 0x50, 0xf9, +0x9b, 0x9b, 0x9b, 0xc1, 0xff, 0xff, 0xff, 0x0b, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0c, 0xad, 0xad, 0xad, 0xba, 0x3c, 0x3c, 0x3c, 0xff, +0xff, 0xff, 0xff, 0x5d, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x02, +0xe5, 0xe5, 0xe5, 0x8a, 0x21, 0x21, 0x21, 0xff, 0xe3, 0xe3, 0xe3, 0x88, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f, +0xa8, 0xa8, 0xa8, 0xbd, 0x3f, 0x3f, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x68, +0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x26, 0xd3, 0xd3, 0xd3, 0xb6, +0x0c, 0x0c, 0x0c, 0xff, 0xdf, 0xdf, 0xdf, 0x80, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x2e, 0x70, 0x70, 0x70, 0xe6, +0x43, 0x43, 0x43, 0xf9, 0xff, 0xff, 0xff, 0x71, 0xff, 0xff, 0xff, 0x13, +0xff, 0xff, 0xff, 0x1a, 0xef, 0xef, 0xef, 0x8c, 0x23, 0x23, 0x23, 0xff, +0x92, 0x92, 0x92, 0xd1, 0xff, 0xff, 0xff, 0x1c, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x19, 0x97, 0x97, 0x97, 0xd0, +0x20, 0x20, 0x20, 0xff, 0x49, 0x49, 0x49, 0xfc, 0xfb, 0xfb, 0xfb, 0x5e, +0xff, 0xff, 0xff, 0x00, 0xe9, 0xe9, 0xe9, 0x7f, 0x3c, 0x3c, 0x3c, 0xff, +0x2a, 0x2a, 0x2a, 0xff, 0xb2, 0xb2, 0xb2, 0xb3, 0xff, 0xff, 0xff, 0x09, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x4d, 0x3c, 0x3c, 0x3c, 0xff, 0x97, 0x97, 0x97, 0xc9, +0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xf5, 0xf5, 0xf5, 0x69, 0x2f, 0x2f, 0x2f, 0xff, +0xbf, 0xbf, 0xbf, 0xa9, 0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x44, 0x4e, 0x4e, 0x4e, 0xfb, 0x8e, 0x8e, 0x8e, 0xd0, +0xff, 0xff, 0xff, 0x17, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, +0xcc, 0xcc, 0xcc, 0x99, 0x2b, 0x2b, 0x2b, 0xff, 0x34, 0x34, 0x34, 0xff, +0xce, 0xce, 0xce, 0x9d, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x3a, +0x6a, 0x6a, 0x6a, 0xee, 0x26, 0x26, 0x26, 0xff, 0xa6, 0xa6, 0xa6, 0xb9, +0xff, 0xff, 0xff, 0x1d, 0x7d, 0x7d, 0x7d, 0xd9, 0x4b, 0x4b, 0x4b, 0xfa, +0xff, 0xff, 0xff, 0x49, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x07, 0xf9, 0xf9, 0xf9, 0x4e, 0xf4, 0xf4, 0xf4, 0x43, +0xff, 0xff, 0xff, 0x04, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c, +0xb1, 0xb1, 0xb1, 0xb9, 0x2c, 0x2c, 0x2c, 0xff, 0xbc, 0xbc, 0xbc, 0xc3, +0xc0, 0xc0, 0xc0, 0x9e, 0xc1, 0xc1, 0xc1, 0xa1, 0xa7, 0xa7, 0xa7, 0xd4, +0x1f, 0x1f, 0x1f, 0xff, 0xe4, 0xe4, 0xe4, 0x87, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f, 0xa9, 0xa9, 0xa9, 0xbd, +0x3a, 0x3a, 0x3a, 0xff, 0xf4, 0xf4, 0xf4, 0x93, 0xf8, 0xf8, 0xf8, 0x55, +0xf6, 0xf6, 0xf6, 0x6a, 0xa0, 0xa0, 0xa0, 0xd4, 0x2e, 0x2e, 0x2e, 0xfd, +0xf1, 0xf1, 0xf1, 0x66, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xf9, 0xf9, 0xf9, 0x60, 0x30, 0x30, 0x30, 0xff, 0xad, 0xad, 0xad, 0xc1, +0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x24, 0x85, 0x85, 0x85, 0xde, 0x42, 0x42, 0x42, 0xfc, +0xfe, 0xfe, 0xfe, 0x47, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x19, 0x91, 0x91, 0x91, 0xcf, 0x58, 0x58, 0x58, 0xff, +0x4f, 0x4f, 0x4f, 0xff, 0xc5, 0xc5, 0xc5, 0x9f, 0xff, 0xff, 0xff, 0x16, +0xa1, 0xa1, 0xa1, 0xbe, 0x5f, 0x5f, 0x5f, 0xff, 0x4b, 0x4b, 0x4b, 0xff, +0xaf, 0xaf, 0xaf, 0xb2, 0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c, +0x3d, 0x3d, 0x3d, 0xff, 0x97, 0x97, 0x97, 0xc8, 0xff, 0xff, 0xff, 0x13, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xf5, 0xf5, 0xf5, 0x68, 0x30, 0x30, 0x30, 0xff, 0xbf, 0xbf, 0xbf, 0xa8, +0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x43, +0x4f, 0x4f, 0x4f, 0xfb, 0x8e, 0x8e, 0x8e, 0xcf, 0xff, 0xff, 0xff, 0x17, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, 0xca, 0xca, 0xca, 0x97, +0x3c, 0x3c, 0x3c, 0xff, 0x6a, 0x6a, 0x6a, 0xff, 0x81, 0x81, 0x81, 0xd7, +0xff, 0xff, 0xff, 0x20, 0xea, 0xea, 0xea, 0x76, 0x48, 0x48, 0x48, 0xff, +0x6d, 0x6d, 0x6d, 0xff, 0x9e, 0x9e, 0x9e, 0xb8, 0xff, 0xff, 0xff, 0x28, +0x61, 0x61, 0x61, 0xe5, 0x5c, 0x5c, 0x5c, 0xee, 0xff, 0xff, 0xff, 0x32, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x01, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c, 0xb6, 0xb6, 0xb6, 0xb8, +0x0f, 0x0f, 0x0f, 0xff, 0x3f, 0x3f, 0x3f, 0xff, 0x41, 0x41, 0x41, 0xff, +0x42, 0x42, 0x42, 0xff, 0x37, 0x37, 0x37, 0xff, 0x18, 0x18, 0x18, 0xff, +0xe7, 0xe7, 0xe7, 0x87, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0e, 0xb0, 0xb0, 0xb0, 0xbb, 0x0e, 0x0e, 0x0e, 0xff, +0x3d, 0x3d, 0x3d, 0xff, 0x3f, 0x3f, 0x3f, 0xff, 0x39, 0x39, 0x39, 0xff, +0x01, 0x01, 0x01, 0xff, 0xa1, 0xa1, 0xa1, 0xe1, 0xff, 0xff, 0xff, 0x31, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf0, 0xf0, 0xf0, 0x74, +0x24, 0x24, 0x24, 0xff, 0xc4, 0xc4, 0xc4, 0xa2, 0xff, 0xff, 0xff, 0x03, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x11, +0xa6, 0xa6, 0xa6, 0xc4, 0x31, 0x31, 0x31, 0xff, 0xfb, 0xfb, 0xfb, 0x59, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x19, +0x8f, 0x8f, 0x8f, 0xd0, 0x67, 0x67, 0x67, 0xf9, 0x84, 0x84, 0x84, 0xf3, +0x79, 0x79, 0x79, 0xd7, 0xff, 0xff, 0xff, 0x62, 0x5d, 0x5d, 0x5d, 0xea, +0x9e, 0x9e, 0x9e, 0xee, 0x44, 0x44, 0x44, 0xff, 0xaf, 0xaf, 0xaf, 0xb2, +0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c, 0x3d, 0x3d, 0x3d, 0xff, +0x97, 0x97, 0x97, 0xc8, 0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf5, 0xf5, 0xf5, 0x68, +0x30, 0x30, 0x30, 0xff, 0xbf, 0xbf, 0xbf, 0xa7, 0xff, 0xff, 0xff, 0x05, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x42, 0x50, 0x50, 0x50, 0xfb, +0x8e, 0x8e, 0x8e, 0xcf, 0xff, 0xff, 0xff, 0x17, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x01, 0xca, 0xca, 0xca, 0x97, 0x35, 0x35, 0x35, 0xff, +0xb9, 0xb9, 0xb9, 0xea, 0x45, 0x45, 0x45, 0xf8, 0xff, 0xff, 0xff, 0x6b, +0xa4, 0xa4, 0xa4, 0xb8, 0x6a, 0x6a, 0x6a, 0xf8, 0x8d, 0x8d, 0x8d, 0xf6, +0x99, 0x99, 0x99, 0xb9, 0xff, 0xff, 0xff, 0x1f, 0x79, 0x79, 0x79, 0xdb, +0x4e, 0x4e, 0x4e, 0xf9, 0xff, 0xff, 0xff, 0x43, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x12, 0xc6, 0xc6, 0xc6, 0x9a, +0xbe, 0xbe, 0xbe, 0x95, 0xff, 0xff, 0xff, 0x0e, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0c, 0xae, 0xae, 0xae, 0xb9, 0x3a, 0x3a, 0x3a, 0xff, +0xf6, 0xf6, 0xf6, 0x94, 0xfa, 0xfa, 0xfa, 0x55, 0xfa, 0xfa, 0xfa, 0x59, +0xda, 0xda, 0xda, 0xb2, 0x21, 0x21, 0x21, 0xff, 0xe3, 0xe3, 0xe3, 0x87, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0f, +0xaa, 0xaa, 0xaa, 0xbc, 0x34, 0x34, 0x34, 0xff, 0xcc, 0xcc, 0xcc, 0xba, +0xcf, 0xcf, 0xcf, 0x94, 0xce, 0xce, 0xce, 0xa6, 0x66, 0x66, 0x66, 0xee, +0x49, 0x49, 0x49, 0xf6, 0xfc, 0xfc, 0xfc, 0x4d, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xf8, 0xf8, 0xf8, 0x63, 0x2e, 0x2e, 0x2e, 0xff, +0xb1, 0xb1, 0xb1, 0xbc, 0xff, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x20, 0x8b, 0x8b, 0x8b, 0xdb, +0x3f, 0x3f, 0x3f, 0xfd, 0xfe, 0xfe, 0xfe, 0x49, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x19, 0x8f, 0x8f, 0x8f, 0xd1, +0x5e, 0x5e, 0x5e, 0xee, 0xd0, 0xd0, 0xd0, 0xc6, 0x45, 0x45, 0x45, 0xf7, +0xe3, 0xe3, 0xe3, 0xc6, 0x3d, 0x3d, 0x3d, 0xf8, 0xe4, 0xe4, 0xe4, 0xc3, +0x3c, 0x3c, 0x3c, 0xfe, 0xaf, 0xaf, 0xaf, 0xb4, 0xff, 0xff, 0xff, 0x0a, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfe, 0xfe, 0xfe, 0x4c, 0x3d, 0x3d, 0x3d, 0xff, 0x97, 0x97, 0x97, 0xc8, +0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xf5, 0xf5, 0xf5, 0x69, 0x2e, 0x2e, 0x2e, 0xff, +0xc2, 0xc2, 0xc2, 0xaa, 0xff, 0xff, 0xff, 0x03, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x43, 0x4f, 0x4f, 0x4f, 0xfd, 0x8c, 0x8c, 0x8c, 0xcf, +0xff, 0xff, 0xff, 0x16, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, +0xca, 0xca, 0xca, 0x98, 0x2e, 0x2e, 0x2e, 0xff, 0xee, 0xee, 0xee, 0xbf, +0x43, 0x43, 0x43, 0xf6, 0xd3, 0xd3, 0xd3, 0xc9, 0x65, 0x65, 0x65, 0xec, +0xae, 0xae, 0xae, 0xd1, 0x8f, 0x8f, 0x8f, 0xe3, 0x99, 0x99, 0x99, 0xbc, +0xff, 0xff, 0xff, 0x09, 0xbd, 0xbd, 0xbd, 0xae, 0x1a, 0x1a, 0x1a, 0xff, +0xe6, 0xe6, 0xe6, 0x9a, 0xff, 0xff, 0xff, 0x15, 0xff, 0xff, 0xff, 0x0a, +0xff, 0xff, 0xff, 0x71, 0x30, 0x30, 0x30, 0xff, 0x90, 0x90, 0x90, 0xcd, +0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c, +0xae, 0xae, 0xae, 0xbb, 0x3a, 0x3a, 0x3a, 0xff, 0xfd, 0xfd, 0xfd, 0x57, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xde, 0xde, 0xde, 0x86, +0x21, 0x21, 0x21, 0xff, 0xe3, 0xe3, 0xe3, 0x87, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0e, 0xa8, 0xa8, 0xa8, 0xbe, +0x41, 0x41, 0x41, 0xff, 0xff, 0xff, 0xff, 0x54, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0b, 0xc9, 0xc9, 0xc9, 0xad, 0x2e, 0x2e, 0x2e, 0xff, +0xf6, 0xf6, 0xf6, 0x6b, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x33, 0x68, 0x68, 0x68, 0xeb, 0x4d, 0x4d, 0x4d, 0xf5, +0xff, 0xff, 0xff, 0x64, 0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x11, +0xf7, 0xf7, 0xf7, 0x80, 0x2b, 0x2b, 0x2b, 0xff, 0x88, 0x88, 0x88, 0xd7, +0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x19, 0x8f, 0x8f, 0x8f, 0xd2, 0x58, 0x58, 0x58, 0xec, +0xff, 0xff, 0xff, 0x8e, 0x4e, 0x4e, 0x4e, 0xf5, 0x6d, 0x6d, 0x6d, 0xfe, +0x6b, 0x6b, 0x6b, 0xe4, 0xff, 0xff, 0xff, 0x91, 0x38, 0x38, 0x38, 0xfe, +0xaf, 0xaf, 0xaf, 0xb5, 0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c, +0x3d, 0x3d, 0x3d, 0xff, 0x97, 0x97, 0x97, 0xc9, 0xff, 0xff, 0xff, 0x13, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xfb, 0xfb, 0xfb, 0x59, 0x2e, 0x2e, 0x2e, 0xff, 0x9b, 0x9b, 0x9b, 0xd4, +0xff, 0xff, 0xff, 0x2b, 0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x7b, +0x2b, 0x2b, 0x2b, 0xff, 0xa6, 0xa6, 0xa6, 0xbd, 0xff, 0xff, 0xff, 0x0c, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x01, 0xca, 0xca, 0xca, 0x99, +0x2c, 0x2c, 0x2c, 0xff, 0xfe, 0xfe, 0xfe, 0x95, 0x7f, 0x7f, 0x7f, 0xd5, +0x61, 0x61, 0x61, 0xfe, 0x45, 0x45, 0x45, 0xff, 0xf3, 0xf3, 0xf3, 0x97, +0x86, 0x86, 0x86, 0xd8, 0x99, 0x99, 0x99, 0xbe, 0xff, 0xff, 0xff, 0x00, +0xfd, 0xfd, 0xfd, 0x4f, 0x5c, 0x5c, 0x5c, 0xf2, 0x31, 0x31, 0x31, 0xff, +0xa8, 0xa8, 0xa8, 0xc5, 0xb7, 0xb7, 0xb7, 0xb8, 0x51, 0x51, 0x51, 0xf7, +0x3c, 0x3c, 0x3c, 0xfd, 0xf2, 0xf2, 0xf2, 0x6b, 0xff, 0xff, 0xff, 0x01, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0b, 0xa9, 0xa9, 0xa9, 0xbd, +0x2e, 0x2e, 0x2e, 0xff, 0xfa, 0xfa, 0xfa, 0x59, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xda, 0xda, 0xda, 0x89, 0x13, 0x13, 0x13, 0xff, +0xe1, 0xe1, 0xe1, 0x88, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x0d, 0xa3, 0xa3, 0xa3, 0xc0, 0x34, 0x34, 0x34, 0xff, +0xfc, 0xfc, 0xfc, 0x50, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xc9, 0xc9, 0xc9, 0x99, 0x17, 0x17, 0x17, 0xff, 0xe9, 0xe9, 0xe9, 0x7e, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05, +0xe4, 0xe4, 0xe4, 0x89, 0x25, 0x25, 0x25, 0xff, 0x53, 0x53, 0x53, 0xf6, +0xb3, 0xb3, 0xb3, 0xbb, 0xaa, 0xaa, 0xaa, 0xc3, 0x3c, 0x3c, 0x3c, 0xff, +0x3c, 0x3c, 0x3c, 0xfd, 0xf1, 0xf1, 0xf1, 0x71, 0xff, 0xff, 0xff, 0x01, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x18, +0x88, 0x88, 0x88, 0xd7, 0x4c, 0x4c, 0x4c, 0xf4, 0xff, 0xff, 0xff, 0x59, +0x89, 0x89, 0x89, 0xd5, 0x00, 0x00, 0x00, 0xff, 0xb4, 0xb4, 0xb4, 0xb6, +0xff, 0xff, 0xff, 0x6a, 0x2b, 0x2b, 0x2b, 0xff, 0xaa, 0xaa, 0xaa, 0xb7, +0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xfe, 0xfe, 0xfe, 0x4c, 0x32, 0x32, 0x32, 0xff, +0x91, 0x91, 0x91, 0xcd, 0xff, 0xff, 0xff, 0x12, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x25, +0x8e, 0x8e, 0x8e, 0xd7, 0x18, 0x18, 0x18, 0xff, 0xa1, 0xa1, 0xa1, 0xd0, +0xb9, 0xb9, 0xb9, 0xb7, 0x57, 0x57, 0x57, 0xf4, 0x32, 0x32, 0x32, 0xff, +0xf0, 0xf0, 0xf0, 0x70, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x01, 0xc7, 0xc7, 0xc7, 0x9a, 0x1f, 0x1f, 0x1f, 0xff, +0xf9, 0xf9, 0xf9, 0x78, 0xd1, 0xd1, 0xd1, 0x9e, 0x00, 0x00, 0x00, 0xff, +0x5c, 0x5c, 0x5c, 0xee, 0xff, 0xff, 0xff, 0x5b, 0x7a, 0x7a, 0x7a, 0xdd, +0x92, 0x92, 0x92, 0xc3, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05, +0xfa, 0xfa, 0xfa, 0x63, 0x89, 0x89, 0x89, 0xd5, 0x4b, 0x4b, 0x4b, 0xfc, +0x4b, 0x4b, 0x4b, 0xfe, 0x77, 0x77, 0x77, 0xdf, 0xec, 0xec, 0xec, 0x7a, +0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x03, 0xd1, 0xd1, 0xd1, 0x86, 0x8e, 0x8e, 0x8e, 0xd1, +0xfd, 0xfd, 0xfd, 0x37, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xeb, 0xeb, 0xeb, 0x5b, 0x81, 0x81, 0x81, 0xd4, 0xef, 0xef, 0xef, 0x5b, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x04, +0xce, 0xce, 0xce, 0x89, 0x91, 0x91, 0x91, 0xcd, 0xfe, 0xfe, 0xfe, 0x31, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xef, 0xef, 0xef, 0x5d, +0x7a, 0x7a, 0x7a, 0xd9, 0xda, 0xda, 0xda, 0x73, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x14, +0xe0, 0xe0, 0xe0, 0x8c, 0x6a, 0x6a, 0x6a, 0xe5, 0x49, 0x49, 0x49, 0xff, +0x4a, 0x4a, 0x4a, 0xfd, 0x7b, 0x7b, 0x7b, 0xdc, 0xf0, 0xf0, 0xf0, 0x77, +0xff, 0xff, 0xff, 0x0c, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0b, 0xbf, 0xbf, 0xbf, 0x9e, +0x9e, 0x9e, 0x9e, 0xbb, 0xff, 0xff, 0xff, 0x22, 0xdd, 0xdd, 0xdd, 0x7d, +0x79, 0x79, 0x79, 0xda, 0xf2, 0xf2, 0xf2, 0x5c, 0xff, 0xff, 0xff, 0x36, +0x8d, 0x8d, 0x8d, 0xd0, 0xd1, 0xd1, 0xd1, 0x80, 0xff, 0xff, 0xff, 0x01, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x2e, 0x8b, 0x8b, 0x8b, 0xcf, 0xc0, 0xc0, 0xc0, 0x97, +0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x4d, +0x9a, 0x9a, 0x9a, 0xcc, 0x4c, 0x4c, 0x4c, 0xfa, 0x49, 0x49, 0x49, 0xff, +0x6a, 0x6a, 0x6a, 0xe6, 0xe2, 0xe2, 0xe2, 0x88, 0xff, 0xff, 0xff, 0x11, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xe1, 0xe1, 0xe1, 0x68, 0x86, 0x86, 0x86, 0xd3, 0xf9, 0xf9, 0xf9, 0x46, +0xff, 0xff, 0xff, 0x46, 0x80, 0x80, 0x80, 0xd7, 0xc5, 0xc5, 0xc5, 0x9a, +0xff, 0xff, 0xff, 0x1c, 0xb7, 0xb7, 0xb7, 0xa0, 0xc5, 0xc5, 0xc5, 0x8a, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x21, 0xff, 0xff, 0xff, 0x44, 0xfe, 0xfe, 0xfe, 0x45, +0xff, 0xff, 0xff, 0x28, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x10, 0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x05, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0a, +0xff, 0xff, 0xff, 0x1d, 0xff, 0xff, 0xff, 0x0a, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x10, +0xff, 0xff, 0xff, 0x1b, 0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x09, 0xff, 0xff, 0xff, 0x21, +0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x06, +0xff, 0xff, 0xff, 0x2d, 0xfe, 0xfe, 0xfe, 0x47, 0xff, 0xff, 0xff, 0x46, +0xff, 0xff, 0xff, 0x26, 0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x01, 0xff, 0xff, 0xff, 0x13, 0xff, 0xff, 0xff, 0x17, +0xff, 0xff, 0xff, 0x02, 0xff, 0xff, 0xff, 0x0d, 0xff, 0xff, 0xff, 0x21, +0xff, 0xff, 0xff, 0x08, 0xff, 0xff, 0xff, 0x05, 0xff, 0xff, 0xff, 0x1b, +0xff, 0xff, 0xff, 0x0f, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x05, +0xff, 0xff, 0xff, 0x1e, 0xff, 0xff, 0xff, 0x14, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x1c, +0xff, 0xff, 0xff, 0x42, 0xfd, 0xfd, 0xfd, 0x48, 0xff, 0xff, 0xff, 0x2e, +0xff, 0xff, 0xff, 0x06, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, +0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x0c, +0xff, 0xff, 0xff, 0x1c, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0x05, +0xff, 0xff, 0xff, 0x1f, 0xff, 0xff, 0xff, 0x12, 0xff, 0xff, 0xff, 0x01, +0xff, 0xff, 0xff, 0x11, 0xff, 0xff, 0xff, 0x0e }; + +#endif /* CR_LOGO_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_matrix.h b/src/VBox/GuestHost/OpenGL/include/cr_matrix.h new file mode 100644 index 00000000..7bc2c9d9 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_matrix.h @@ -0,0 +1,96 @@ + +#ifndef CR_MATRIX_H +#define CR_MATRIX_H + +#include "chromium.h" + +#include + +/* + * Note: m[col][row] matches OpenGL's column-major memory layout + */ +typedef struct { + float m00, m01, m02, m03; + float m10, m11, m12, m13; + float m20, m21, m22, m23; + float m30, m31, m32, m33; +} CRmatrix; + +typedef struct { GLfloat x,y,z,w; } GLvectorf; +typedef struct { GLdouble x,y,z,w; } GLvectord; + +#ifdef __cplusplus +extern "C" { +#endif + +extern DECLEXPORT(void) +crMatrixInit(CRmatrix *m); + +extern DECLEXPORT(void) +crMatrixInitFromString(CRmatrix *m, const char *s); + +extern DECLEXPORT(void) +crMatrixInitFromFloats(CRmatrix *m, const float *v); + +extern DECLEXPORT(void) +crMatrixInitFromDoubles(CRmatrix *m, const double *v); + +extern DECLEXPORT(void) +crMatrixPrint(const char *msg, const CRmatrix *m); + +extern DECLEXPORT(void) +crMatrixGetFloats(float *values, const CRmatrix *m); + +extern DECLEXPORT(int) +crMatrixIsEqual(const CRmatrix *m, const CRmatrix *n); + +extern DECLEXPORT(int) +crMatrixIsIdentity(const CRmatrix *m); + +extern DECLEXPORT(int) +crMatrixIsOrthographic(const CRmatrix *m); + +extern DECLEXPORT(void) +crMatrixCopy(CRmatrix *dest, const CRmatrix *src); + +extern DECLEXPORT(void) +crMatrixMultiply(CRmatrix *p, const CRmatrix *a, const CRmatrix *b); + +extern DECLEXPORT(void) +crMatrixTransformPointf(const CRmatrix *m, GLvectorf *p); + +extern DECLEXPORT(void) +crMatrixTransformPointd(const CRmatrix *m, GLvectord *p); + +extern DECLEXPORT(void) +crMatrixInvertTranspose(CRmatrix *inv, const CRmatrix *mat); + +extern DECLEXPORT(void) +crMatrixTranspose(CRmatrix *t, const CRmatrix *m); + +extern DECLEXPORT(void) +crMatrixTranslate(CRmatrix *m, float x, float y, float z); + +extern DECLEXPORT(void) +crMatrixRotate(CRmatrix *m, float angle, float x, float y, float z); + +extern DECLEXPORT(void) +crMatrixScale(CRmatrix *m, float x, float y, float z); + +extern DECLEXPORT(void) +crMatrixFrustum(CRmatrix *m, + float left, float right, + float bottom, float top, + float zNear, float zFar); + +extern DECLEXPORT(void) +crMatrixOrtho(CRmatrix *m, + float left, float right, + float bottom, float top, + float znear, float zfar); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/VBox/GuestHost/OpenGL/include/cr_mem.h b/src/VBox/GuestHost/OpenGL/include/cr_mem.h new file mode 100644 index 00000000..a9c776e2 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_mem.h @@ -0,0 +1,38 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_MEM_H +#define CR_MEM_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DEBUG_MEM 0 + +void *crAllocDebug( unsigned int nbytes, const char *file, int line ); +void *crCallocDebug( unsigned int nbytes, const char *file, int line ); +#if DEBUG_MEM +#define crAlloc(N) crAllocDebug(N, __FILE__, __LINE__) +#define crCalloc(N) crCallocDebug(N, __FILE__, __LINE__) +#else +extern DECLEXPORT(void *) crAlloc( unsigned int nbytes ); +extern DECLEXPORT(void *) crCalloc( unsigned int nbytes ); +#endif +extern DECLEXPORT(void) crRealloc( void **ptr, unsigned int bytes ); +extern DECLEXPORT(void) crFree( void *ptr ); +extern DECLEXPORT(void) crMemcpy( void *dst, const void *src, unsigned int bytes ); +extern DECLEXPORT(void) crMemset( void *ptr, int value, unsigned int bytes ); +extern DECLEXPORT(void) crMemZero( void *ptr, unsigned int bytes ); +extern DECLEXPORT(int) crMemcmp( const void *p1, const void *p2, unsigned int bytes ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_MEM_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_net.h b/src/VBox/GuestHost/OpenGL/include/cr_net.h new file mode 100644 index 00000000..b95b4268 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_net.h @@ -0,0 +1,360 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_NET_H +#define CR_NET_H + +#ifdef WINDOWS +#define WIN32_LEAN_AND_MEAN +# ifndef VBOX +#pragma warning( push, 3 ) /* shut up about warnings in YOUR OWN HEADER FILES!!! */ +#include +# else +# include +# endif /* VBOX */ +#endif + +#include + +#ifndef WINDOWS +#include +#ifndef DARWIN +#ifdef AF_INET6 +/* getaddrinfo & co appeared with ipv6 */ +#define ADDRINFO +#endif +#endif +#include +#endif + +#ifdef SunOS +#include +#endif + +#include "cr_protocol.h" +#include "cr_threads.h" + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define DEFAULT_SERVER_PORT 7000 + +/* If you change this, update DefaultMothershipPort in mothership.py */ +#define DEFAULT_MOTHERSHIP_PORT 10000 + +typedef struct CRConnection CRConnection; + +typedef enum { + CR_NO_CONNECTION, + CR_SDP, + CR_TCPIP, + CR_UDPTCPIP, + CR_FILE, + CR_GM, + CR_IB, + CR_TEAC, + CR_TCSCOMM, + CR_VBOXHGCM, + CR_DROP_PACKETS +} CRConnectionType; + +#if defined(WINDOWS) +typedef SOCKET CRSocket; +#else +typedef int CRSocket; +#endif + +typedef void (*CRVoidFunc)( void ); +typedef int (*CRNetReceiveFunc)( CRConnection *conn, CRMessage *msg, unsigned int len ); +typedef int (*CRNetConnectFunc)( CRConnection *conn ); +typedef void (*CRNetCloseFunc)( unsigned int sender_id ); + +typedef struct __recvFuncList { + CRNetReceiveFunc recv; + struct __recvFuncList *next; +} CRNetReceiveFuncList; + +typedef struct __closeFuncList { + CRNetCloseFunc close; + struct __closeFuncList *next; +} CRNetCloseFuncList; + +typedef struct __messageListNode { + CRMessage *mesg; /* the actual message (header + payload) */ + unsigned int len; /* length of message (header + payload) */ + CRConnection *conn; /* some messages are assoc. with specific connections*/ + struct __messageListNode *next; /* next in list */ +} CRMessageListNode; + +typedef struct { + CRMessageListNode *head, *tail; + int numMessages; + CRmutex lock; + CRcondition nonEmpty; +} CRMessageList; + + +/** + * Used to accumulate CR_MESSAGE_MULTI_BODY/TAIL chunks into one big buffer. + */ +typedef struct CRMultiBuffer { + unsigned int len; /* current length (<= max) (with sizeof_buffer_header) */ + unsigned int max; /* size in bytes of data buffer */ + void *buf; /* data buffer */ +} CRMultiBuffer; + +#ifdef VBOX_WITH_CRHGSMI +# ifdef IN_GUEST +typedef struct CRVBOXHGSMI_CLIENT { + struct VBOXUHGSMI *pHgsmi; + struct VBOXUHGSMI_BUFFER *pCmdBuffer; + struct VBOXUHGSMI_BUFFER *pHGBuffer; + void *pvHGBuffer; + struct CRBufferPool_t *bufpool; +} CRVBOXHGSMI_CLIENT, *PCRVBOXHGSMI_CLIENT; +#endif /* IN_GUEST */ +#endif /* #ifdef VBOX_WITH_CRHGSMI */ +/** + * Chromium network connection (bidirectional). + */ +struct CRConnection { + int ignore; + CRConnectionType type; + unsigned int id; /* obtained from the mothership (if brokered) */ + + /* List of messages that we've received on the network connection but + * nobody has yet consumed. + */ + CRMessageList messageList; + + CRMultiBuffer multi; + + unsigned int mtu; /* max transmission unit size (in bytes) */ + unsigned int buffer_size; + unsigned int krecv_buf_size; + int broker; /* is connection brokered through mothership? */ + int threaded; /* is this a threaded connection? */ + int endianness, swap; + int actual_network; /* is this a real network? */ + + unsigned char *userbuf; + int userbuf_len; + + char *hostname; + int port; + + /* To allocate a data buffer of size conn->buffer_size bytes */ + void *(*Alloc)( CRConnection *conn ); + /* To indicate the client's done with a data buffer */ + void (*Free)( CRConnection *conn, void *buf ); + /* To send a data buffer. If bufp is non-null, it must have been obtained + * from Alloc() and it'll be freed when Send() returns. + */ + void (*Send)( CRConnection *conn, void **buf, const void *start, unsigned int len ); + /* To send a data buffer than can optionally be dropped on the floor */ + void (*Barf)( CRConnection *conn, void **buf, const void *start, unsigned int len ); + /* To send 'len' bytes from buffer at 'start', no funny business */ + void (*SendExact)( CRConnection *conn, const void *start, unsigned int len ); + /* To receive data. 'len' bytes will be placed into 'buf'. */ + void (*Recv)( CRConnection *conn, void *buf, unsigned int len ); + /* To receive one message on the connection */ + void (*RecvMsg)( CRConnection *conn ); + /* What's this??? */ + void (*InstantReclaim)( CRConnection *conn, CRMessage *mess ); + /* Called when a full CR_MESSAGE_MULTI_HEAD/TAIL message has been received */ + void (*HandleNewMessage)( CRConnection *conn, CRMessage *mess, unsigned int len ); + /* To accept a new connection from a client */ + void (*Accept)( CRConnection *conn, const char *hostname, unsigned short port ); + /* To connect to a server (return 0 if error, 1 if success) */ + int (*Connect)( CRConnection *conn ); + /* To disconnect from a server */ + void (*Disconnect)( CRConnection *conn ); + + unsigned int sizeof_buffer_header; + + /* logging */ + int total_bytes_sent; + int total_bytes_recv; + int recv_count; + int opcodes_count; + + /* credits for flow control */ + int send_credits; + int recv_credits; + + /* TCP/IP */ + CRSocket tcp_socket; + int index; + + CRSocket sdp_socket; + + /* UDP/IP */ + CRSocket udp_socket; +#ifndef ADDRINFO + struct sockaddr_in remoteaddr; +#else + struct sockaddr_storage remoteaddr; +#endif + + /* UDP/TCP/IP */ + unsigned int seq; + unsigned int ack; + void *udp_packet; + int udp_packetlen; + + /* FILE Tracing */ + enum { CR_FILE_WRITE, CR_FILE_READ } file_direction; + char *filename; + int fd; + + /* Myrinet GM */ + unsigned int gm_node_id; + unsigned int gm_port_num; + + /* Mellanox IB */ + unsigned int ib_node_id; + unsigned int ib_port_num; + + /* Quadrics Elan3 (teac) */ + int teac_id; + int teac_rank; + + /* Quadrics Elan3 (tcscomm) */ + int tcscomm_id; + int tcscomm_rank; + + /* VBox HGCM */ + uint32_t u32ClientID; + uint8_t *pBuffer; + uint32_t cbBuffer; + uint8_t *pHostBuffer; + uint32_t cbHostBufferAllocated; + uint32_t cbHostBuffer; +#ifdef IN_GUEST + uint32_t u32InjectClientID; +# ifdef VBOX_WITH_CRHGSMI + CRVBOXHGSMI_CLIENT HgsmiClient; + struct VBOXUHGSMI *pExternalHgsmi; +# endif +#else +# ifdef VBOX_WITH_CRHGSMI + struct _crclient *pClient; /* back reference, just for simplicity */ + CRVBOXHGSMI_CMDDATA CmdData; +# endif + RTLISTANCHOR PendingMsgList; +#endif + /* Used on host side to indicate that we are not allowed to store above pointers for later use + * in crVBoxHGCMReceiveMessage. As those messages are going to be processed after the corresponding + * HGCM call is finished and memory is freed. So we have to store a copy. + * This happens when message processing for client associated with this connection + * is blocked by another client, which has send us glBegin call and we're waiting to receive glEnd. + */ + uint8_t allow_redir_ptr; + + uint32_t vMajor, vMinor; /*Protocol version*/ +}; + + +/* + * Network functions + */ +extern DECLEXPORT(int) crGetHostname( char *buf, unsigned int len ); + +extern DECLEXPORT(void) crNetInit( CRNetReceiveFunc recvFunc, CRNetCloseFunc closeFunc ); +extern DECLEXPORT(void) crNetTearDown(void); + +extern DECLEXPORT(void) *crNetAlloc( CRConnection *conn ); +extern DECLEXPORT(void) crNetFree( CRConnection *conn, void *buf ); + +extern DECLEXPORT(void) crNetAccept( CRConnection *conn, const char *hostname, unsigned short port ); +extern DECLEXPORT(int) crNetConnect( CRConnection *conn ); +extern DECLEXPORT(void) crNetDisconnect( CRConnection *conn ); +extern DECLEXPORT(void) crNetFreeConnection( CRConnection *conn ); +extern DECLEXPORT(void) crCloseSocket( CRSocket sock ); + +extern DECLEXPORT(void) crNetSend( CRConnection *conn, void **bufp, const void *start, unsigned int len ); +extern DECLEXPORT(void) crNetBarf( CRConnection *conn, void **bufp, const void *start, unsigned int len ); +extern DECLEXPORT(void) crNetSendExact( CRConnection *conn, const void *start, unsigned int len ); +extern DECLEXPORT(void) crNetSingleRecv( CRConnection *conn, void *buf, unsigned int len ); +extern DECLEXPORT(unsigned int) crNetGetMessage( CRConnection *conn, CRMessage **message ); +extern DECLEXPORT(unsigned int) crNetPeekMessage( CRConnection *conn, CRMessage **message ); +extern DECLEXPORT(int) crNetNumMessages(CRConnection *conn); +extern DECLEXPORT(void) crNetReadline( CRConnection *conn, void *buf ); +extern DECLEXPORT(int) crNetRecv( +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + CRConnection *conn +#else + void +#endif + ); +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) +#define CR_WRITEBACK_WAIT(_conn, _writeback) do { \ + while (_writeback) { \ + RTThreadYield(); \ + crNetRecv(_conn); \ + } \ + } while (0) +#else +#define CR_WRITEBACK_WAIT(_conn, _writeback) do { \ + while (_writeback) { \ + RTThreadYield(); \ + crNetRecv(); \ + } \ + } while (0) + +#endif +#ifdef IN_GUEST +extern DECLEXPORT(uint32_t) crNetHostCapsGet(void); +#endif +extern DECLEXPORT(void) crNetDefaultRecv( CRConnection *conn, CRMessage *msg, unsigned int len ); +extern DECLEXPORT(void) crNetDispatchMessage( CRNetReceiveFuncList *rfl, CRConnection *conn, CRMessage *msg, unsigned int len ); + +extern DECLEXPORT(CRConnection *) crNetConnectToServer( const char *server, unsigned short default_port, int mtu, int broker +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif +); +extern DECLEXPORT(CRConnection *) crNetAcceptClient( const char *protocol, const char *hostname, unsigned short port, unsigned int mtu, int broker ); + + +extern DECLEXPORT(void) crInitMessageList(CRMessageList *list); +extern DECLEXPORT(void) crEnqueueMessage(CRMessageList *list, CRMessage *msg, unsigned int len, CRConnection *conn); +extern DECLEXPORT(void) crDequeueMessage(CRMessageList *list, CRMessage **msg, unsigned int *len, CRConnection **conn); + +extern DECLEXPORT(void) crNetRecvReadPixels( const CRMessageReadPixels *rp, unsigned int len ); + + +/* + * Quadrics stuff + */ +#define CR_QUADRICS_DEFAULT_LOW_CONTEXT 32 +#define CR_QUADRICS_DEFAULT_HIGH_CONTEXT 35 + +extern DECLEXPORT(void) crNetSetRank( int my_rank ); +extern DECLEXPORT(void) crNetSetContextRange( int low_context, int high_context ); +extern DECLEXPORT(void) crNetSetNodeRange( const char *low_node, const char *high_node ); +extern DECLEXPORT(void) crNetSetKey( const unsigned char* key, const int keyLength ); + + +/* + * Socket callback facility + */ +#define CR_SOCKET_CREATE 1 +#define CR_SOCKET_DESTROY 2 +typedef void (*CRSocketCallbackProc)(int mode, int socket); +extern DECLEXPORT(void) crRegisterSocketCallback(int mode, CRSocketCallbackProc proc); + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_NET_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_netserver.h b/src/VBox/GuestHost/OpenGL/include/cr_netserver.h new file mode 100644 index 00000000..6f80835b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_netserver.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_NETSERVER_H +#define CR_NETSERVER_H + +#include "cr_net.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + char *name; + int buffer_size; + CRConnection *conn; +} CRNetServer; + +DECLEXPORT(void) crNetServerConnect( CRNetServer *ns +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif + ); +DECLEXPORT(void) crNetNewClient( CRNetServer *ns +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif +); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_NETSERVER_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_pack.h b/src/VBox/GuestHost/OpenGL/include/cr_pack.h new file mode 100644 index 00000000..ad2c6066 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_pack.h @@ -0,0 +1,442 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_PACK_H +#define CR_PACK_H + +#include "cr_compiler.h" +#include "cr_error.h" +#include "cr_protocol.h" +#include "cr_opcodes.h" +#include "cr_endian.h" +#include "state/cr_statetypes.h" +#include "state/cr_currentpointers.h" +#include "state/cr_client.h" +#ifdef CHROMIUM_THREADSAFE +#include "cr_threads.h" +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct CRPackContext_t CRPackContext; + +/** + * Packer buffer + */ +typedef struct +{ + void *pack; /**< the actual storage space/buffer */ + unsigned int size; /**< size of pack[] buffer */ + unsigned int mtu; + unsigned char *data_start, *data_current, *data_end; + unsigned char *opcode_start, *opcode_current, *opcode_end; + GLboolean geometry_only; /**< just used for debugging */ + GLboolean holds_BeginEnd; + GLboolean in_BeginEnd; + GLboolean canBarf; + GLboolean holds_List; + GLboolean in_List; + CRPackContext *context; +} CRPackBuffer; + +typedef void (*CRPackFlushFunc)(void *arg); +typedef void (*CRPackSendHugeFunc)(CROpcode, void *); +typedef void (*CRPackErrorHandlerFunc)(int line, const char *file, GLenum error, const char *info); + +#define CRPACKBLOCKSTATE_OP_BEGIN 0x01 +#define CRPACKBLOCKSTATE_OP_NEWLIST 0x02 +#define CRPACKBLOCKSTATE_OP_BEGINQUERY 0x04 +#define CRPACKBLOCKSTATE_OP_ALL 0x07 + +#define CRPACKBLOCKSTATE_IS_OP_STARTED(_state, _op) (!!((_state) & (_op))) + +#define CRPACKBLOCKSTATE_IS_STARTED(_state) (!!(_state)) + +#define CRPACKBLOCKSTATE_OP_START(_state, _op) do { \ + Assert(!CRPACKBLOCKSTATE_IS_OP_STARTED(_state, _op)); \ + (_state) |= (_op); \ + } while (0) + +#define CRPACKBLOCKSTATE_OP_STOP(_state, _op) do { \ + Assert(CRPACKBLOCKSTATE_IS_OP_STARTED(_state, _op)); \ + (_state) &= ~(_op); \ + } while (0) + +/** + * Packer context + */ +struct CRPackContext_t +{ + CRPackBuffer buffer; /**< not a pointer, see comments in pack_buffer.c */ + CRPackFlushFunc Flush; + void *flush_arg; + CRPackSendHugeFunc SendHuge; + CRPackErrorHandlerFunc Error; + CRCurrentStatePointers current; + uint32_t u32CmdBlockState; + GLvectorf bounds_min, bounds_max; + int updateBBOX; + int swapping; + CRPackBuffer *currentBuffer; +#ifdef CHROMIUM_THREADSAFE + CRmutex mutex; +#endif + char *file; /**< for debugging only */ + int line; /**< for debugging only */ +}; + +#if !defined(IN_RING0) +# define CR_PACKER_CONTEXT_ARGSINGLEDECL void +# define CR_PACKER_CONTEXT_ARGDECL +# define CR_PACKER_CONTEXT_ARG +# define CR_PACKER_CONTEXT_ARG_NOREF() do {} while (0) +# define CR_PACKER_CONTEXT_ARGCTX(C) +# ifdef CHROMIUM_THREADSAFE +extern CRtsd _PackerTSD; +# define CR_GET_PACKER_CONTEXT(C) CRPackContext *C = (CRPackContext *) crGetTSD(&_PackerTSD) +# define CR_LOCK_PACKER_CONTEXT(PC) crLockMutex(&((PC)->mutex)) +# define CR_UNLOCK_PACKER_CONTEXT(PC) crUnlockMutex(&((PC)->mutex)) +# else +extern DLLDATA(CRPackContext) cr_packer_globals; +# define CR_GET_PACKER_CONTEXT(C) CRPackContext *C = &cr_packer_globals +# define CR_LOCK_PACKER_CONTEXT(PC) +# define CR_UNLOCK_PACKER_CONTEXT(PC) +# endif +extern uint32_t cr_packer_cmd_blocks_enabled; +#else /* if defined IN_RING0 */ +# define CR_PACKER_CONTEXT_ARGSINGLEDECL CRPackContext *_pCtx +# define CR_PACKER_CONTEXT_ARGDECL CR_PACKER_CONTEXT_ARGSINGLEDECL, +# define CR_PACKER_CONTEXT_ARG _pCtx, +# define CR_PACKER_CONTEXT_ARG_NOREF() RT_NOREF_PV(_pCtx) +# define CR_PACKER_CONTEXT_ARGCTX(C) C, +# define CR_GET_PACKER_CONTEXT(C) CRPackContext *C = _pCtx +# define CR_LOCK_PACKER_CONTEXT(PC) +# define CR_UNLOCK_PACKER_CONTEXT(PC) +#endif + +extern DECLEXPORT(CRPackContext *) crPackNewContext(int swapping); +extern DECLEXPORT(void) crPackDeleteContext(CRPackContext *pc); +extern DECLEXPORT(void) crPackSetContext( CRPackContext *pc ); +extern DECLEXPORT(CRPackContext *) crPackGetContext( void ); + +extern DECLEXPORT(void) crPackSetBuffer( CRPackContext *pc, CRPackBuffer *buffer ); +extern DECLEXPORT(void) crPackSetBufferDEBUG( const char *file, int line, CRPackContext *pc, CRPackBuffer *buffer ); +extern DECLEXPORT(void) crPackReleaseBuffer( CRPackContext *pc ); +extern DECLEXPORT(void) crPackResetPointers( CRPackContext *pc ); + +extern DECLEXPORT(int) crPackMaxOpcodes( int buffer_size ); +extern DECLEXPORT(int) crPackMaxData( int buffer_size ); +extern DECLEXPORT(void) crPackInitBuffer( CRPackBuffer *buffer, void *buf, int size, int mtu +#ifdef IN_RING0 + , unsigned int num_opcodes +#endif + ); + +extern DECLEXPORT(void) crPackFlushFunc( CRPackContext *pc, CRPackFlushFunc ff ); +extern DECLEXPORT(void) crPackFlushArg( CRPackContext *pc, void *flush_arg ); +extern DECLEXPORT(void) crPackSendHugeFunc( CRPackContext *pc, CRPackSendHugeFunc shf ); +extern DECLEXPORT(void) crPackErrorFunction( CRPackContext *pc, CRPackErrorHandlerFunc errf ); +extern DECLEXPORT(void) crPackOffsetCurrentPointers( int offset ); +extern DECLEXPORT(void) crPackNullCurrentPointers( void ); + +extern DECLEXPORT(void) crPackResetBoundingBox( CRPackContext *pc ); +extern DECLEXPORT(GLboolean) crPackGetBoundingBox( CRPackContext *pc, + GLfloat *xmin, GLfloat *ymin, GLfloat *zmin, + GLfloat *xmax, GLfloat *ymax, GLfloat *zmax); + +extern DECLEXPORT(void) crPackAppendBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *buffer ); +extern DECLEXPORT(void) crPackAppendBoundedBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *buffer, const CRrecti *bounds ); +extern DECLEXPORT(int) crPackCanHoldBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *buffer ); +extern DECLEXPORT(int) crPackCanHoldBoundedBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *buffer ); + +#if defined(LINUX) || defined(WINDOWS) +#define CR_UNALIGNED_ACCESS_OKAY +#else +#undef CR_UNALIGNED_ACCESS_OKAY +#endif +#ifndef IN_RING0 +extern DECLEXPORT(void) crWriteUnalignedDouble( void *buffer, double d ); +extern DECLEXPORT(void) crWriteSwappedDouble( void *buffer, double d ); +#endif + +extern DECLEXPORT(void) *crPackAlloc( CR_PACKER_CONTEXT_ARGDECL unsigned int len ); +extern DECLEXPORT(void) crHugePacket( CR_PACKER_CONTEXT_ARGDECL CROpcode op, void *ptr ); +extern DECLEXPORT(void) crPackFree( CR_PACKER_CONTEXT_ARGDECL void *ptr ); +extern DECLEXPORT(void) crNetworkPointerWrite( CRNetworkPointer *, void * ); + +extern DECLEXPORT(void) crPackExpandDrawArrays(GLenum mode, GLint first, GLsizei count, CRClientState *c, const GLfloat *pZva); +extern DECLEXPORT(void) crPackExpandDrawArraysSWAP(GLenum mode, GLint first, GLsizei count, CRClientState *c, const GLfloat *pZva); + +extern DECLEXPORT(void) crPackUnrollDrawElements(GLsizei count, GLenum type, const GLvoid *indices); +extern DECLEXPORT(void) crPackUnrollDrawElementsSWAP(GLsizei count, GLenum type, const GLvoid *indices); + +extern DECLEXPORT(void) crPackExpandDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c, const GLfloat *pZva); +extern DECLEXPORT(void) crPackExpandDrawElementsSWAP(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c, const GLfloat *pZva); + +extern DECLEXPORT(void) crPackExpandDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c, const GLfloat *pZva); +extern DECLEXPORT(void) crPackExpandDrawRangeElementsSWAP(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c, const GLfloat *pZva); + +extern DECLEXPORT(void) crPackExpandArrayElement(GLint index, CRClientState *c, const GLfloat *pZva); +extern DECLEXPORT(void) crPackExpandArrayElementSWAP(GLint index, CRClientState *c, const GLfloat *pZva); + +extern DECLEXPORT(void) crPackExpandMultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count, GLsizei primcount, CRClientState *c, const GLfloat *pZva ); +extern DECLEXPORT(void) crPackExpandMultiDrawArraysEXTSWAP( GLenum mode, GLint *first, GLsizei *count, GLsizei primcount, CRClientState *c, const GLfloat *pZva ); + +extern DECLEXPORT(void) crPackExpandMultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount, CRClientState *c, const GLfloat *pZva ); +extern DECLEXPORT(void) crPackExpandMultiDrawElementsEXTSWAP( GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount, CRClientState *c, const GLfloat *pZva ); + +extern DECLEXPORT(void) crPackCapsSet(uint32_t u32Caps); + +/** + * Return number of opcodes in given buffer. + */ +static INLINE int +crPackNumOpcodes(const CRPackBuffer *buffer) +{ + CRASSERT(buffer->opcode_start - buffer->opcode_current >= 0); + return buffer->opcode_start - buffer->opcode_current; +} + +DECLINLINE(bool) crPackBufferIsEmpty(CRPackBuffer *buffer) +{ + return crPackNumOpcodes(buffer) == 0; +} + +/** + * Return amount of data (in bytes) in buffer. + */ +static INLINE int +crPackNumData(const CRPackBuffer *buffer) +{ + CRASSERT(buffer->data_current - buffer->data_start >= 0); + return buffer->data_current - buffer->data_start; /* in bytes */ +} + + +static INLINE int +crPackCanHoldOpcode(const CRPackContext *pc, int num_opcode, int num_data) +{ + int fitsInMTU, opcodesFit, dataFits; + + CRASSERT(pc->currentBuffer); + + fitsInMTU = (((pc->buffer.data_current - pc->buffer.opcode_current - 1 + + num_opcode + num_data + + 0x3 ) & ~0x3) + sizeof(CRMessageOpcodes) + <= pc->buffer.mtu); + opcodesFit = (pc->buffer.opcode_current - num_opcode >= pc->buffer.opcode_end); + dataFits = (pc->buffer.data_current + num_data <= pc->buffer.data_end); + + return fitsInMTU && opcodesFit && dataFits; +} + + +#define CR_PACK_SPECIAL_OP( _pc, _op) \ + do { \ + data_ptr = pc->buffer.data_current; \ + (_pc)->buffer.data_current += 4; \ + WRITE_OPCODE( (_pc), (_op) ); \ + WRITE_DATA( 0, GLuint, 0xdeadbeef ); \ + data_ptr = NULL; /* <- sanity*/ \ + } while (0) + +#define CR_CMDBLOCK_OP( _pc, _op) \ + do { \ + CR_PACK_SPECIAL_OP( _pc, _op); \ + } while (0) + +#define CR_CMDBLOCK_IS_STARTED( pc, op ) CRPACKBLOCKSTATE_IS_OP_STARTED((pc)->u32CmdBlockState, op) + +#define CR_CMDBLOCK_BEGIN( pc, op ) \ + do { \ + CR_LOCK_PACKER_CONTEXT(pc); \ + if (!cr_packer_cmd_blocks_enabled) break; \ + if (!CRPACKBLOCKSTATE_IS_STARTED((pc)->u32CmdBlockState)) { \ + THREADASSERT( pc ); \ + CRASSERT( (pc)->currentBuffer ); \ + if (!crPackBufferIsEmpty(&(pc)->buffer)) { \ + if ((*(pc)->buffer.opcode_start) != CR_NOP_OPCODE) { \ + (pc)->Flush( (pc)->flush_arg ); \ + Assert(crPackCanHoldOpcode( (pc), 1, 4 ) ); \ + CR_CMDBLOCK_OP( (pc), CR_CMDBLOCKBEGIN_OPCODE ); \ + } \ + else { \ + (*(pc)->buffer.opcode_start) = CR_CMDBLOCKBEGIN_OPCODE; \ + } \ + } \ + else { \ + Assert(crPackCanHoldOpcode( (pc), 1, 4 ) ); \ + CR_CMDBLOCK_OP( (pc), CR_CMDBLOCKBEGIN_OPCODE ); \ + } \ + } \ + Assert(!CRPACKBLOCKSTATE_IS_OP_STARTED((pc)->u32CmdBlockState, op)); \ + CRPACKBLOCKSTATE_OP_START((pc)->u32CmdBlockState, op); \ + Assert(CRPACKBLOCKSTATE_IS_OP_STARTED((pc)->u32CmdBlockState, op)); \ + } while (0) + +#define CR_CMDBLOCK_END( pc, op ) \ + do { \ + if (!cr_packer_cmd_blocks_enabled) break; \ + Assert(CRPACKBLOCKSTATE_IS_OP_STARTED((pc)->u32CmdBlockState, op)); \ + CRPACKBLOCKSTATE_OP_STOP((pc)->u32CmdBlockState, op); \ + Assert(!CRPACKBLOCKSTATE_IS_OP_STARTED((pc)->u32CmdBlockState, op)); \ + if (!CRPACKBLOCKSTATE_IS_STARTED((pc)->u32CmdBlockState)) { \ + THREADASSERT( pc ); \ + CRASSERT( (pc)->currentBuffer ); \ + if (!crPackBufferIsEmpty(&(pc)->buffer)) { \ + if ((*(pc)->buffer.opcode_start) != CR_CMDBLOCKBEGIN_OPCODE) {\ + if ( !crPackCanHoldOpcode( pc, 1, 4 ) ) { \ + (pc)->Flush( (pc)->flush_arg ); \ + Assert(crPackCanHoldOpcode( pc, 1, 4 ) ); \ + } \ + CR_CMDBLOCK_OP( pc, CR_CMDBLOCKEND_OPCODE ); \ + (pc)->Flush( (pc)->flush_arg ); \ + } \ + else { \ + (*(pc)->buffer.opcode_start) = CR_NOP_OPCODE; \ + } \ + } \ + else { \ + Assert(crPackCanHoldOpcode( pc, 1, 4 ) ); \ + CR_CMDBLOCK_OP( pc, CR_CMDBLOCKEND_OPCODE ); \ + (pc)->Flush( pc->flush_arg ); \ + } \ + } \ + } while (0) + +#define CR_CMDBLOCK_CHECK_FLUSH( pc ) \ + do { \ + if (!(cr_packer_cmd_blocks_enabled & CR_VBOX_CAP_CMDBLOCKS_FLUSH)) break; \ + if(!CRPACKBLOCKSTATE_IS_OP_STARTED((pc)->u32CmdBlockState, CRPACKBLOCKSTATE_OP_NEWLIST)) break; \ + THREADASSERT( pc ); \ + CRASSERT( (pc)->currentBuffer ); \ + if ( !crPackCanHoldOpcode( pc, 1, 4 ) ) { \ + (pc)->Flush( (pc)->flush_arg ); \ + Assert(crPackCanHoldOpcode( pc, 1, 4 ) ); \ + } \ + CR_CMDBLOCK_OP( pc, CR_CMDBLOCKFLUSH_OPCODE ); \ + (pc)->Flush( (pc)->flush_arg ); \ + } while (0) + +/** + * Alloc space for a message of 'len' bytes (plus 1 opcode). + * Only flush if buffer is full. + */ +#define CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, len, lock) \ + do { \ + THREADASSERT( pc ); \ + if (lock) CR_LOCK_PACKER_CONTEXT(pc); \ + CRASSERT( pc->currentBuffer ); \ + if ( !crPackCanHoldOpcode( pc, 1, (len) ) ) { \ + pc->Flush( pc->flush_arg ); \ + CRASSERT(crPackCanHoldOpcode( pc, 1, (len) ) ); \ + } \ + data_ptr = pc->buffer.data_current; \ + pc->buffer.data_current += (len); \ + } while (0) + +/** + * As above, flush if the buffer contains vertex data and we're + * no longer inside glBegin/glEnd. + */ +#define CR_GET_BUFFERED_POINTER( pc, len ) \ + do { \ + CR_LOCK_PACKER_CONTEXT(pc); \ + CRASSERT( pc->currentBuffer ); \ + if ( pc->buffer.holds_BeginEnd && !pc->buffer.in_BeginEnd ) { \ + CRASSERT( 0 ); /* should never be here currently */ \ + pc->Flush( pc->flush_arg ); \ + pc->buffer.holds_BeginEnd = 0; \ + } \ + CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, len, GL_FALSE ); \ + } while (0) + +/** + * As above, but without lock. + */ +#define CR_GET_BUFFERED_POINTER_NOLOCK( pc, len ) \ + do { \ + CRASSERT( pc->currentBuffer ); \ + if ( pc->buffer.holds_BeginEnd && !pc->buffer.in_BeginEnd ) { \ + CRASSERT( 0 ); /* should never be here currently */ \ + pc->Flush( pc->flush_arg ); \ + pc->buffer.holds_BeginEnd = 0; \ + } \ + CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, len, GL_FALSE ); \ + } while (0) + + +/** + * As above, but for vertex data between glBegin/End (counts vertices). + */ +#define CR_GET_BUFFERED_COUNT_POINTER( pc, len ) \ + do { \ + CR_LOCK_PACKER_CONTEXT(pc); \ + CRASSERT( pc->currentBuffer ); \ + if ( !crPackCanHoldOpcode( pc, 1, (len) ) ) { \ + pc->Flush( pc->flush_arg ); \ + CRASSERT( crPackCanHoldOpcode( pc, 1, (len) ) ); \ + } \ + data_ptr = pc->buffer.data_current; \ + pc->current.vtx_count++; \ + pc->buffer.data_current += (len); \ + } while (0) + + +/** + * Allocate space for a msg/command that has no arguments, such + * as glFinish(). + */ +#define CR_GET_BUFFERED_POINTER_NO_ARGS( pc ) \ + CR_GET_BUFFERED_POINTER( pc, 4 ); \ + WRITE_DATA( 0, GLuint, 0xdeadbeef ) + +#define WRITE_DATA( offset, type, data ) \ + *( (type *) (data_ptr + (offset))) = (data) + +/* Write data to current location and auto increment */ +#define WRITE_DATA_AI(type, data) \ + { \ + *((type*) (data_ptr)) = (data); \ + data_ptr += sizeof(type); \ + } + +#ifdef CR_UNALIGNED_ACCESS_OKAY +#define WRITE_DOUBLE( offset, data ) \ + WRITE_DATA( offset, GLdouble, data ) +#else +# ifndef IN_RING0 +# define WRITE_DOUBLE( offset, data ) \ + crWriteUnalignedDouble( data_ptr + (offset), (data) ) +# else +# define WRITE_DOUBLE( offset, data ) \ + AssertReleaseFailed() +# endif +#endif + +#ifndef IN_RING0 +#define WRITE_SWAPPED_DOUBLE( offset, data ) \ + crWriteSwappedDouble( data_ptr + (offset), (data) ) +#else +#define WRITE_SWAPPED_DOUBLE( offset, data ) \ + AssertReleaseFailed() +#endif + +#define WRITE_OPCODE( pc, opcode ) \ + *(pc->buffer.opcode_current--) = (unsigned char) opcode + +#define WRITE_NETWORK_POINTER( offset, data ) \ + crNetworkPointerWrite( (CRNetworkPointer *) ( data_ptr + (offset) ), (data) ) + +#ifdef __cplusplus +} +#endif + +#endif /* CR_PACK_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_perf.h b/src/VBox/GuestHost/OpenGL/include/cr_perf.h new file mode 100644 index 00000000..3a3f1728 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_perf.h @@ -0,0 +1,76 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_PERF_H +#define CR_PERF_H + +#ifdef __cplusplus +extern "C" { +#endif + + +/** + * For the performance SPU. Allows application to obtain it's own + * statistics, and reset etc. + */ +typedef struct { + int count; + + int v2d, v2f, v2i, v2s; + int v2dv, v2fv, v2iv, v2sv; + int v3d, v3f, v3i, v3s; + int v3dv, v3fv, v3iv, v3sv; + int v4d, v4f, v4i, v4s; + int v4dv, v4fv, v4iv, v4sv; + + int ipoints; /**< Interpreted points */ + int ilines; /**< Interpreted lines */ + int itris; /**< Interpreted tris */ + int iquads; /**< Interpreted quads */ + int ipolygons; /**< Interpreted polygons */ +} PerfVertex; + +/** + * Primitives data + */ +typedef struct { + PerfVertex points; + PerfVertex lines; + PerfVertex lineloop; + PerfVertex linestrip; + PerfVertex triangles; + PerfVertex tristrip; + PerfVertex trifan; + PerfVertex quads; + PerfVertex quadstrip; + PerfVertex polygon; +} PerfPrim; + +typedef struct { + int draw_pixels; + int read_pixels; + + int teximage1DBytes; /**< bytes given to glTexImage1D */ + int teximage2DBytes; /**< bytes given to glTexImage2D */ + int teximage3DBytes; /**< bytes given to glTexImage3D */ + int texsubimage1DBytes; /**< bytes given to glTexSubImage1D */ + int texsubimage2DBytes; /**< bytes given to glTexSubImage2D */ + int texsubimage3DBytes; /**< bytes given to glTexSubImage3D */ + int newLists; /**< glNewList calls */ + int callLists; /**< glCallList(s) calls */ + + PerfVertex *cur_vertex; + PerfVertex vertex_snapshot; + PerfPrim vertex_data; +} PerfData; + + + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CR_PERF_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h b/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h new file mode 100644 index 00000000..da3ebe34 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_pixeldata.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_PIXELDATA_H +#define CR_PIXELDATA_H + +#include "chromium.h" +#include "state/cr_client.h" + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DECLEXPORT(int) crPixelSize( GLenum format, GLenum type ); + +DECLEXPORT(unsigned int) crImageSize( GLenum format, GLenum type, + GLsizei width, GLsizei height ); + +DECLEXPORT(unsigned int) crTextureSize( GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth ); + +DECLEXPORT(void) crPixelCopy1D( GLvoid *dstPtr, GLenum dstFormat, GLenum dstType, + const GLvoid *srcPtr, GLenum srcFormat, GLenum srcType, + GLsizei width, const CRPixelPackState *srcPacking ); + +DECLEXPORT(void) crPixelCopy2D( GLsizei width, GLsizei height, + GLvoid *dstPtr, GLenum dstFormat, GLenum dstType, + const CRPixelPackState *dstPacking, + const GLvoid *srcPtr, GLenum srcFormat, GLenum srcType, + const CRPixelPackState *srcPacking ); + +DECLEXPORT(void) crPixelCopy3D( GLsizei width, GLsizei height, GLsizei depth, + GLvoid *dstPtr, GLenum dstFormat, GLenum dstType, + const CRPixelPackState *dstPacking, const GLvoid *srcPtr, + GLenum srcFormat, GLenum srcType, + const CRPixelPackState *srcPacking ); + +DECLEXPORT(void) crBitmapCopy( GLsizei width, GLsizei height, GLubyte *dstPtr, + const GLubyte *srcPtr, const CRPixelPackState *srcPacking ); + +DECLEXPORT(void) crDumpNamedTGA(const char *fname, GLint w, GLint h, GLvoid *data); +DECLEXPORT(void) crDumpNamedTGAV(GLint w, GLint h, GLvoid *data, const char* fname, va_list va); +DECLEXPORT(void) crDumpNamedTGAF(GLint w, GLint h, GLvoid *data, const char* fname, ...); +DECLEXPORT(void) crDumpTGA(GLint w, GLint h, GLvoid *data); +#ifdef __cplusplus +} +#endif + +#endif /* CR_PIXELDATA_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_process.h b/src/VBox/GuestHost/OpenGL/include/cr_process.h new file mode 100644 index 00000000..5fd981e0 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_process.h @@ -0,0 +1,54 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_PROCESS_H +#define CR_PROCESS_H + +#ifdef WINDOWS +#define WIN32_LEAN_AND_MEAN +# ifdef VBOX +# include +# else +#include +# endif +#endif + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Process ID type + */ +#ifdef WINDOWS +typedef HANDLE CRpid; +#else +typedef unsigned long CRpid; +#endif + + +extern DECLEXPORT(void) crSleep( unsigned int seconds ); + +extern DECLEXPORT(void) crMsleep( unsigned int msec ); + +extern DECLEXPORT(CRpid) crSpawn( const char *command, const char *argv[] ); + +extern DECLEXPORT(void) crKill( CRpid pid ); + +extern DECLEXPORT(void) crGetProcName( char *name, int maxLen ); + +extern DECLEXPORT(void) crGetCurrentDir( char *dir, int maxLen ); + +extern DECLEXPORT(CRpid) crGetPID(void); + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_PROCESS_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_protocol.h b/src/VBox/GuestHost/OpenGL/include/cr_protocol.h new file mode 100644 index 00000000..c4c7dd54 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_protocol.h @@ -0,0 +1,291 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_PROTOCOL_H +#define CR_PROTOCOL_H + +#include +#include +#ifdef DEBUG_misha +#include "cr_error.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define CR_CMDVBVA_VERSION 1 + +#pragma pack(1) +typedef struct CR_CAPS_INFO +{ + uint32_t u32Caps; + uint32_t u32CmdVbvaVersion; +} CR_CAPS_INFO; +#pragma pack() + + +/*For now guest is allowed to connect host opengl service if protocol version matches exactly*/ +/*Note: that after any change to this file, or glapi_parser\apispec.txt version should be changed*/ +#define CR_PROTOCOL_VERSION_MAJOR 9 +#define CR_PROTOCOL_VERSION_MINOR 1 + +/* new TexPresent mechanism is available */ +#define CR_VBOX_CAP_TEX_PRESENT 0x00000001 +/* vbva command submission mechanism supported */ +#define CR_VBOX_CAP_CMDVBVA 0x00000002 +/* host supports Command Blocks, i.e. CR_CMDBLOCKBEGIN_OPCODE and CR_CMDBLOCKEND_OPCODE opcodes. + * Command Block can be used by guest to prevent clients from blocking each other. + * The Command Block allows multiple command buffers to be processed with one run. + * Command Block commands have to obey to the following rules: + * CR_CMDBLOCKBEGIN_OPCODE - must be the first command in the command buffer, specifying the command block start + * CR_CMDBLOCKEND_OPCODE - must be the last command in the command buffer, specifying the command block end + * If not placed accordingly, CR_CMDBLOCK** commands are ignored. + * Server copies the command block buffer commands to its internal storage + * and processes them with one run when the command block end is signalled + */ +#define CR_VBOX_CAP_CMDBLOCKS 0x00000004 +/* GetAttribsLocations support */ +#define CR_VBOX_CAP_GETATTRIBSLOCATIONS 0x00000008 +/* flush command blocks for execution */ +#define CR_VBOX_CAP_CMDBLOCKS_FLUSH 0x00000010 +/* Notify guest if host reports minimal OpenGL capabilities. */ +#define CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT 0x00000020 + +#define CR_VBOX_CAPS_ALL 0x0000003f + + +#define CR_PRESENT_SCREEN_MASK 0xffff +#define CR_PRESENT_FLAGS_OFFSET 16 +#define CR_PRESENT_FLAGS_MASK 0xffff0000 +#define CR_PRESENT_DEFINE_FLAG(_f) (1 << (CR_PRESENT_FLAGS_OFFSET + _f)) + +#define CR_PRESENT_FLAG_CLEAR_RECTS CR_PRESENT_DEFINE_FLAG(0) +#define CR_PRESENT_FLAG_TEX_NONINVERT_YCOORD CR_PRESENT_DEFINE_FLAG(1) + +#define CR_PRESENT_GET_SCREEN(_cfg) ((_cfg) & CR_PRESENT_SCREEN_MASK) +#define CR_PRESENT_GET_FLAGS(_cfg) ((_cfg) & CR_PRESENT_FLAGS_MASK) + +typedef enum { + /* first message types is 'wGL\001', so we can immediately + recognize bad message types */ + CR_MESSAGE_OPCODES = 0x77474c01, + CR_MESSAGE_WRITEBACK, + CR_MESSAGE_READBACK, + CR_MESSAGE_READ_PIXELS, + CR_MESSAGE_MULTI_BODY, + CR_MESSAGE_MULTI_TAIL, + CR_MESSAGE_FLOW_CONTROL, + CR_MESSAGE_OOB, + CR_MESSAGE_NEWCLIENT, + CR_MESSAGE_GATHER, + CR_MESSAGE_ERROR, + CR_MESSAGE_CRUT, + CR_MESSAGE_REDIR_PTR +} CRMessageType; + +typedef union { + /* pointers are usually 4 bytes, but on 64-bit machines (Alpha, + * SGI-n64, etc.) they are 8 bytes. Pass network pointers around + * as an opaque array of bytes, since the interpretation & size of + * the pointer only matter to the machine which emitted the + * pointer (and will eventually receive the pointer back again) */ + unsigned int ptrAlign[2]; + unsigned char ptrSize[8]; + /* hack to make this packet big */ + /* unsigned int junk[512]; */ +} CRNetworkPointer; + +#if 0 /*def DEBUG_misha*/ +#define CRDBGPTR_SETZ(_p) crMemset((_p), 0, sizeof (CRNetworkPointer)) +#define CRDBGPTR_CHECKZ(_p) do { \ + CRNetworkPointer _ptr = {0}; \ + CRASSERT(!crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \ + } while (0) +#define CRDBGPTR_CHECKNZ(_p) do { \ + CRNetworkPointer _ptr = {0}; \ + CRASSERT(crMemcmp((_p), &_ptr, sizeof (CRNetworkPointer))); \ + } while (0) +# if 0 +# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { \ + crDebug(_tStr "%d:0x%08x%08x", (_id), (_p)->ptrAlign[1], (_p)->ptrAlign[0]); \ + } while (0) +# else +# define _CRDBGPTR_PRINT(_tStr, _id, _p) do { } while (0) +# endif +#define CRDBGPTR_PRINTWB(_id, _p) _CRDBGPTR_PRINT("wbptr:", _id, _p) +#define CRDBGPTR_PRINTRB(_id, _p) _CRDBGPTR_PRINT("rbptr:", _id, _p) +#else +#define CRDBGPTR_SETZ(_p) do { } while (0) +#define CRDBGPTR_CHECKZ(_p) do { } while (0) +#define CRDBGPTR_CHECKNZ(_p) do { } while (0) +#define CRDBGPTR_PRINTWB(_id, _p) do { } while (0) +#define CRDBGPTR_PRINTRB(_id, _p) do { } while (0) +#endif + +#ifdef VBOX_WITH_CRHGSMI +typedef struct CRVBOXHGSMI_CMDDATA { + union + { + struct VBOXVDMACMD_CHROMIUM_CMD *pHgsmiCmd; + struct VBOXCMDVBVA_CRCMD_CMD *pVbvaCmd; + const void *pvCmd; + }; + int *pCmdRc; + char *pWriteback; + unsigned int *pcbWriteback; + unsigned int cbWriteback; + bool fHgsmiCmd; +} CRVBOXHGSMI_CMDDATA, *PCRVBOXHGSMI_CMDDATA; + +#ifdef DEBUG +# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { \ + CRASSERT(!(_pData)->pvCmd == !(_pData)->pCmdRc); \ + CRASSERT(!(_pData)->pWriteback == !(_pData)->pcbWriteback); \ + CRASSERT(!(_pData)->pWriteback == !(_pData)->cbWriteback); \ + if ((_pData)->pWriteback) \ + { \ + CRASSERT((_pData)->pvCmd); \ + } \ + } while (0) + +# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { \ + CRASSERT(!(_pData)->pvCmd); \ + CRASSERT(!(_pData)->pCmdRc); \ + CRASSERT(!(_pData)->pWriteback); \ + CRASSERT(!(_pData)->pcbWriteback); \ + CRASSERT(!(_pData)->cbWriteback); \ + } while (0) + +# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { \ + CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \ + CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SET(_pData)); \ + } while (0) + +# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { \ + CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \ + CRASSERT(CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData)); \ + } while (0) +#else +# define CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData) do { } while (0) +# define CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData) do { } while (0) +# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSET(_pData) do { } while (0) +# define CRVBOXHGSMI_CMDDATA_ASSERT_ISSETWB(_pData) do { } while (0) +#endif + +#define CRVBOXHGSMI_CMDDATA_IS_HGSMICMD(_pData) (!!(_pData)->fHgsmiCmd) +#define CRVBOXHGSMI_CMDDATA_IS_SET(_pData) (!!(_pData)->pvCmd) +#define CRVBOXHGSMI_CMDDATA_IS_SETWB(_pData) (!!(_pData)->pWriteback) + +#define CRVBOXHGSMI_CMDDATA_CLEANUP(_pData) do { \ + crMemset(_pData, 0, sizeof (CRVBOXHGSMI_CMDDATA)); \ + CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \ + CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \ + } while (0) + +#define CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd) do { \ + CRVBOXHGSMI_CMDDATA_ASSERT_CLEANED(_pData); \ + (_pData)->pvCmd = (_pCmd); \ + (_pData)->pCmdRc = &(_pHdr)->result; \ + (_pData)->fHgsmiCmd = (_fHgsmiCmd); \ + CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \ + } while (0) + +#define CRVBOXHGSMI_CMDDATA_SETWB(_pData, _pCmd, _pHdr, _pWb, _cbWb, _pcbWb, _fHgsmiCmd) do { \ + CRVBOXHGSMI_CMDDATA_SET(_pData, _pCmd, _pHdr, _fHgsmiCmd); \ + (_pData)->pWriteback = (_pWb); \ + (_pData)->pcbWriteback = (_pcbWb); \ + (_pData)->cbWriteback = (_cbWb); \ + CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(_pData); \ + } while (0) + +#define CRVBOXHGSMI_CMDDATA_RC(_pData, _rc) do { \ + *(_pData)->pCmdRc = (_rc); \ + } while (0) +#endif + +typedef struct { + CRMessageType type; + unsigned int conn_id; +} CRMessageHeader; + +typedef struct CRMessageOpcodes { + CRMessageHeader header; + unsigned int numOpcodes; +} CRMessageOpcodes; + +typedef struct CRMessageRedirPtr { + CRMessageHeader header; + CRMessageHeader* pMessage; +#ifdef VBOX_WITH_CRHGSMI + CRVBOXHGSMI_CMDDATA CmdData; +#endif +} CRMessageRedirPtr; + +typedef struct CRMessageWriteback { + CRMessageHeader header; + CRNetworkPointer writeback_ptr; +} CRMessageWriteback; + +typedef struct CRMessageReadback { + CRMessageHeader header; + CRNetworkPointer writeback_ptr; + CRNetworkPointer readback_ptr; +} CRMessageReadback; + +typedef struct CRMessageMulti { + CRMessageHeader header; +} CRMessageMulti; + +typedef struct CRMessageFlowControl { + CRMessageHeader header; + unsigned int credits; +} CRMessageFlowControl; + +typedef struct CRMessageReadPixels { + CRMessageHeader header; + int width, height; + unsigned int bytes_per_row; + unsigned int stride; + int alignment; + int skipRows; + int skipPixels; + int rowLength; + int format; + int type; + CRNetworkPointer pixels; +} CRMessageReadPixels; + +typedef struct CRMessageNewClient { + CRMessageHeader header; +} CRMessageNewClient; + +typedef struct CRMessageGather { + CRMessageHeader header; + unsigned long offset; + unsigned long len; +} CRMessageGather; + +typedef union { + CRMessageHeader header; + CRMessageOpcodes opcodes; + CRMessageRedirPtr redirptr; + CRMessageWriteback writeback; + CRMessageReadback readback; + CRMessageReadPixels readPixels; + CRMessageMulti multi; + CRMessageFlowControl flowControl; + CRMessageNewClient newclient; + CRMessageGather gather; +} CRMessage; + +DECLEXPORT(void) crNetworkPointerWrite( CRNetworkPointer *dst, void *src ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_PROTOCOL_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_rand.h b/src/VBox/GuestHost/OpenGL/include/cr_rand.h new file mode 100644 index 00000000..73f5e7c5 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_rand.h @@ -0,0 +1,25 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_RAND_H +#define CR_RAND_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DECLEXPORT(void) crRandSeed( unsigned long seed ); +DECLEXPORT(void) crRandAutoSeed(void); +DECLEXPORT(float) crRandFloat( float min, float max ); +DECLEXPORT(int) crRandInt( int min, int max ); + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CR_RAND_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_server.h b/src/VBox/GuestHost/OpenGL/include/cr_server.h new file mode 100644 index 00000000..c7fd9814 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_server.h @@ -0,0 +1,594 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef INCLUDE_CR_SERVER_H +#define INCLUDE_CR_SERVER_H + +#include "cr_spu.h" +#include "cr_net.h" +#include "cr_hash.h" +#include "cr_protocol.h" +#include "cr_glstate.h" +#include "cr_vreg.h" +#include "cr_blitter.h" +#include "cr_htable.h" +#include "spu_dispatch_table.h" +#include "cr_dump.h" + +#include "state/cr_currentpointers.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CR_MAX_WINDOWS 100 +#define CR_MAX_CLIENTS 64 + +/** @todo must match MaxGuestMonitors from SchemaDefs.h*/ +#define CR_MAX_GUEST_MONITORS VBOX_VIDEO_MAX_SCREENS + +typedef DECLCALLBACKPTR(void, PFNCRSERVERPRESENTFBO) (void *data, int32_t screenId, int32_t x, int32_t y, uint32_t w, uint32_t h); + +/* Callbacks for output of the rendered frames. + * + * This allows to pass rendered frames to an external component rather than draw them on screen. + * + * An external component registers the redirection callbacks using crVBoxServerOutputRedirectSet. + * + * The list of formats supported by the caller is obtained using CRORContextProperty. + * The actual format choosed by the service is passed as a CRORBegin parameter. + */ +typedef struct { + const void *pvContext; /* Supplied by crVBoxServerOutputRedirectSet. */ + DECLR3CALLBACKMEMBER(void, CRORBegin, (const void *pvContext, void **ppvInstance, + const char *pszFormat)); + DECLR3CALLBACKMEMBER(void, CRORGeometry, (void *pvInstance, + int32_t x, int32_t y, uint32_t w, uint32_t h)); + DECLR3CALLBACKMEMBER(void, CRORVisibleRegion, (void *pvInstance, + uint32_t cRects, const RTRECT *paRects)); + DECLR3CALLBACKMEMBER(void, CRORFrame, (void *pvInstance, + void *pvData, uint32_t cbData)); + DECLR3CALLBACKMEMBER(void, CROREnd, (void *pvInstance)); + DECLR3CALLBACKMEMBER(int, CRORContextProperty, (const void *pvContext, uint32_t index, + void *pvBuffer, uint32_t cbBuffer, uint32_t *pcbOut)); +} CROutputRedirect; + +typedef struct { + CRrecti imagewindow; /**< coordinates in mural space */ + CRrectf bounds; /**< normalized coordinates in [-1,-1] x [1,1] */ + CRrecti outputwindow; /**< coordinates in server's rendering window */ + CRrecti clippedImagewindow; /**< imagewindow clipped to current viewport */ + CRmatrix baseProjection; /**< pre-multiplied onto projection matrix */ + CRrecti scissorBox; /**< passed to back-end OpenGL */ + CRrecti viewport; /**< passed to back-end OpenGL */ + GLuint serialNo; /**< an optimization */ +} CRExtent; + +struct BucketingInfo; + +typedef struct { + char *pszDpyName; + GLint visualBits; + int32_t externalID; +} CRCreateInfo_t; + +typedef struct { + char *pszDpyName; + int32_t externalID; + GLint requestedVisualBits; + GLint realVisualBits; +} CRCreateInfoEx_t; + +/* VRAM->RAM worker thread */ + +typedef enum +{ + CR_SERVER_RPW_STATE_UNINITIALIZED = 0, + CR_SERVER_RPW_STATE_INITIALIZING, + CR_SERVER_RPW_STATE_INITIALIZED, + CR_SERVER_RPW_STATE_UNINITIALIZING, +} CR_SERVER_RPW_STATE; + +/* worker control command */ +typedef enum +{ + CR_SERVER_RPW_CTL_TYPE_UNDEFINED = 0, + CR_SERVER_RPW_CTL_TYPE_WAIT_COMPLETE, + CR_SERVER_RPW_CTL_TYPE_TERM +} CR_SERVER_RPW_CTL_TYPE; + +struct CR_SERVER_RPW_ENTRY; + +typedef struct CR_SERVER_RPW_CTL { + CR_SERVER_RPW_CTL_TYPE enmType; + int rc; + RTSEMEVENT hCompleteEvent; + /* valid for *_WAIT_COMPLETE and *_CANCEL */ + struct CR_SERVER_RPW_ENTRY *pEntry; +} CR_SERVER_RPW_CTL; + + +struct CR_SERVER_RPW_ENTRY; + +typedef DECLCALLBACKPTR(void, PFNCR_SERVER_RPW_DATA) (const struct CR_SERVER_RPW_ENTRY* pEntry, void *pvEntryTexData); + +typedef DECLCALLBACKPTR(void, PFNCRSERVERNOTIFYEVENT) (int32_t screenId, uint32_t uEvent, void* pvData, uint32_t cbData); + +typedef struct CR_SERVER_RPW_ENTRY +{ + RTRECTSIZE Size; + /* We have to use 4 textures here. + * + * 1. iDrawTex - the texture clients can draw to and then submit it for contents acquisition via crServerRpwEntrySubmit + * 2. iSubmittedTex - the texture submitted to the worker for processing and, whose processing has not start yet, + * i.e. it is being in the queue and can be safely removed/replaced [from] there + * 3. iWorkerTex - the texture being prepared & passed by the worker to the GPU (stage 1 of a worker contents acquisition process) + * 4. iGpuTex - the texture passed/processed to/by the GPU, whose data is then acquired by the server (stage 2 of a worker contents acquisition process) + * + * - There can be valid distinct iGpuTex, iWorkerTex, iSubmittedTex and iDrawTex present simultaneously. + * - Either or both of iSubmittedTex and iFreeTex are always valid + * + * Detail: + * + * - iSubmittedTex and iFreeTex modifications are performed under CR_SERVER_RPW::CritSect lock. + * + * - iDrawTex can only be changed by client side (i.e. the crServerRpwEntrySubmit caller), this is why client thread can access it w/o a lock + * - iSubmittedTex and iFreeTex can be modified by both client and worker, so lock is always required + * + * - iDrawTex can be accessed by client code only + * - iWorkerTex and iGpuTex can be accessed by worker code only + * - iSubmittedTex and iFreeTex can be accessed under CR_SERVER_RPW::CritSect lock only + * - either or both of iSubmittedTex and iFreeTex are always valid (see below for more explanation), + * this is why client can easily determine the new iDrawTex value on Submit, i.e. : + * + * (if initial iSubmittedTex was valid) + * --------------- + * | ^ + * > | + * Submit-> iDrawTex -> iSubmittedTex + * ^ + * | (if initial iSubmittedTex was NOT valid) + * iFreeTex + * + * - The worker can invalidate the iSubmittedTex (i.e. do iSubmittedTex -> iWorkerTex) only after it is done + * with the last iWorkerTex -> iGpuTex transformation freeing the previously used iGpuTex to iFreeTex. + * + * - A simplified worker iXxxTex transformation logic is: + * 1. iFreeTex is initially valid + * 2. iSubmittedTex -> iWorkerTex; + * 3. submit iWorkerTex acquire request to the GPU + * 4. complete current iGpuTex + * 5. iGpuTex -> iFreeTex + * 6. iWorkerTex -> iGpuTex + * 7. goto 1 + * + * */ + int8_t iTexDraw; + int8_t iTexSubmitted; + int8_t iTexWorker; + int8_t iTexGpu; + int8_t iCurPBO; + GLuint aidWorkerTexs[4]; + GLuint aidPBOs[2]; + RTLISTNODE WorkEntry; + RTLISTNODE WorkerWorkEntry; + RTLISTNODE GpuSubmittedEntry; + PFNCR_SERVER_RPW_DATA pfnData; +} CR_SERVER_RPW_ENTRY; + +typedef struct CR_SERVER_RPW { + RTLISTNODE WorkList; + RTCRITSECT CritSect; + RTSEMEVENT hSubmitEvent; + /* only one outstanding command is supported, + * and ctl requests must be cynchronized, hold it right here */ + CR_SERVER_RPW_CTL Ctl; + int ctxId; + GLint ctxVisBits; + RTTHREAD hThread; +} CR_SERVER_RPW; +/* */ + +/* FRAMEBUFFER */ +typedef struct CR_FRAMEBUFFER *HCR_FRAMEBUFFER; +typedef struct CR_FRAMEBUFFER_ENTRY *HCR_FRAMEBUFFER_ENTRY; +/* */ + +typedef struct CR_FBDATA +{ + HCR_FRAMEBUFFER hFb; + HCR_FRAMEBUFFER_ENTRY hFbEntry; + CR_TEXDATA* apTexDatas[2]; +} CR_FBDATA; +/** + * Mural info + */ +typedef struct { + GLuint width, height; + GLint gX, gY; /*guest coordinates*/ + GLint hX, hY; /*host coordinates, screenID related*/ + + int spuWindow; /*the SPU's corresponding window ID */ + + int screenId; + + GLboolean bVisible; /*guest window is visible*/ + GLubyte u8Unused; /*redirect to FBO instead of real host window*/ + GLboolean bFbDraw; /*GL_FRONT buffer is drawn to directly*/ + GLboolean fIsDummyRefference; + + GLint cVisibleRects; /*count of visible rects*/ + GLint *pVisibleRects; /*visible rects left, top, right, bottom*/ + GLboolean bReceivedRects; /*indicates if guest did any updates for visible regions*/ + + GLuint cBuffers; + GLuint iBbBuffer; + GLuint aidFBOs[2]; + GLuint aidColorTexs[2]; + + void *pvReserved; + + CRCreateInfoEx_t CreateInfo; + + /* to avoid saved state breakage we need to keep RT_OFFSETOF(CRMuralInfo, CreateInfo) intact + * this is why we place some FBO stuff to the tail + * @todo: once we need to increment a saved state version, we could refactor this structure */ + GLint iCurDrawBuffer; + GLint iCurReadBuffer; + + GLuint idDepthStencilRB; + GLuint fboWidth, fboHeight; + + GLboolean fHasParentWindow; + + GLboolean fRedirected; + GLboolean fForcePresentState; + GLboolean fOrPresentOnReenable; + + GLboolean fIsVisible; + + CR_TEXDATA aTexs[2]; + uint32_t cUsedFBDatas; + CR_FBDATA *apUsedFBDatas[CR_MAX_GUEST_MONITORS]; + CR_FBDATA aFBDatas[CR_MAX_GUEST_MONITORS]; + + /* bitfield representing contexts the mural has been ever current with + * we just reuse CR_STATE_SHAREDOBJ_USAGE_XXX API here for simplicity */ + CRbitvalue ctxUsage[CR_MAX_BITARRAY]; +} CRMuralInfo; + +typedef struct { + CRContext *pContext; + int SpuContext; + CRCreateInfoEx_t CreateInfo; + CRMuralInfo * currentMural; +} CRContextInfo; + +/** + * A client is basically an upstream Cr Node (connected via mothership) + */ +typedef struct _crclient { + int spu_id; /**< id of the last SPU in the client's SPU chain */ + CRConnection *conn; /**< network connection from the client */ + int number; /**< a unique number for each client */ + uint64_t pid; /*guest pid*/ + GLint currentContextNumber; + CRContextInfo *currentCtxInfo; + GLint currentWindow; + CRMuralInfo *currentMural; + GLint windowList[CR_MAX_WINDOWS]; + GLint contextList[CR_MAX_CONTEXTS]; +#ifdef VBOXCR_LOGFPS + uint64_t timeUsed; +#endif +} CRClient; + +typedef struct _crclientnode { + CRClient *pClient; + struct _crclientnode *prev, *next; +} CRClientNode; + +typedef struct CRPoly_t { + int npoints; + double *points; + struct CRPoly_t *next; +} CRPoly; + +/** + * There's one of these run queue entries per client + * The run queue is a circular, doubly-linked list of these objects. + */ +typedef struct RunQueue_t { + CRClient *client; + int blocked; + struct RunQueue_t *next; + struct RunQueue_t *prev; +} RunQueue; + +typedef struct { + GLint freeWindowID; + GLint freeContextID; + GLint freeClientID; +} CRServerFreeIDsPool_t; + +typedef struct { + int32_t x, y; + uint32_t w, h; + uint64_t winID; +} CRScreenInfo; + +typedef struct { + RTRECT Rect; +} CRScreenViewportInfo; + +/* BFB (BlitFramebuffer Blitter) flags + * so far only CR_SERVER_BFB_ON_ALWAIS is supported and is alwais used if any flag is set */ +#define CR_SERVER_BFB_DISABLED 0 +#define CR_SERVER_BFB_ON_INVERTED_BLIT 1 +#define CR_SERVER_BFB_ON_STRAIGHT_BLIT 2 +#define CR_SERVER_BFB_ON_ALWAIS (CR_SERVER_BFB_ON_INVERTED_BLIT | CR_SERVER_BFB_ON_STRAIGHT_BLIT) + +typedef struct { + unsigned short tcpip_port; + + CRScreenInfo screen[CR_MAX_GUEST_MONITORS]; + CRScreenViewportInfo screenVieport[CR_MAX_GUEST_MONITORS]; + int screenCount; + + GLboolean fCrCmdEnabled; + + GLboolean fProcessingPendedCommands; + + int numClients; + CRClient *clients[CR_MAX_CLIENTS]; /**< array [numClients] */ + CRClient *curClient; + CRClientNode *pCleanupClient; /*list of clients with pending clean up*/ + CRHTABLE clientTable; + CRCurrentStatePointers current; + + GLboolean firstCallCreateContext; + GLboolean firstCallMakeCurrent; + GLboolean bIsInLoadingState; /* Indicates if we're in process of loading VM snapshot */ + GLboolean bIsInSavingState; /* Indicates if we're in process of saving VM snapshot */ + GLboolean bForceMakeCurrentOnClientSwitch; + CRContextInfo *currentCtxInfo; + GLint currentWindow; + GLint currentNativeWindow; + CRMuralInfo *currentMural; + + CRHashTable *muralTable; /**< hash table where all murals are stored */ + + int client_spu_id; + + int mtu; + int buffer_size; + char protocol[1024]; + + SPU *head_spu; + SPUDispatchTable dispatch; + + CRNetworkPointer return_ptr; + CRNetworkPointer writeback_ptr; + + CRLimitsState limits; /**< GL limits for any contexts we create */ + + CRContextInfo MainContextInfo; + + CRHashTable *contextTable; /**< hash table for rendering contexts */ + + CRHashTable *programTable; /**< for vertex programs */ + GLuint currentProgram; + + /* visBits -> dummy mural association */ + CRHashTable *dummyMuralTable; + + GLboolean fRootVrOn; + VBOXVR_LIST RootVr; + /* we need to translate Root Vr to each window coords, this one cpecifies the current translation point + * note that since window attributes modifications is performed in HGCM thread only and thus is serialized, + * we deal with the global RootVr data directly */ + RTPOINT RootVrCurPoint; + + /* blitter so far used for working around host drivers BlitFramebuffer bugs + * by implementing */ + uint32_t fBlitterMode; + CR_BLITTER Blitter; + + CR_SERVER_RPW RpwWorker; + + VBOXCRCMDCTL_HGCMDISABLE_DATA DisableData; + + RTSEMEVENT hCalloutCompletionEvent; + VBOXCRCMDCTL *pCurrentCalloutCtl; + VBOXCRCLIENT_INFO ClientInfo; + + /** configuration options */ + /*@{*/ + int useL2; + int ignore_papi; + unsigned int maxBarrierCount; + unsigned int clearCount; + int optimizeBucket; + int only_swap_once; + int debug_barriers; + int sharedDisplayLists; + int sharedTextureObjects; + int sharedPrograms; + int sharedWindows; + int uniqueWindows; + int localTileSpec; + int useDMX; + int overlapBlending; + int vpProjectionMatrixParameter; + const char *vpProjectionMatrixVariable; + int stereoView; + int vncMode; /* cmd line option */ + /*@}*/ + /** view_matrix config */ + /*@{*/ + GLboolean viewOverride; + CRmatrix viewMatrix[2]; /**< left and right eye */ + /*@}*/ + /** projection_matrix config */ + /*@{*/ + GLboolean projectionOverride; + CRmatrix projectionMatrix[2]; /**< left and right eye */ + int currentEye; + /*@}*/ + + /** for warped tiles */ + /*@{*/ + GLfloat alignment_matrix[16], unnormalized_alignment_matrix[16]; + /*@}*/ + + /** tile overlap/blending info - this should probably be per-mural */ + /*@{*/ + CRPoly **overlap_geom; + CRPoly *overlap_knockout; + float *overlap_intens; + int num_overlap_intens; + int num_overlap_levels; + /*@}*/ + + CRHashTable *barriers, *semaphores; + + RunQueue *run_queue; + + GLuint currentSerialNo; + + GLuint fVisualBitsDefault; + GLboolean bUsePBOForReadback; /*Use PBO's for data readback*/ + + CROutputRedirect outputRedirect; + + GLboolean bUseMultipleContexts; + + GLboolean bWindowsInitiallyHidden; + + /* OR-ed CR_VBOX_CAP_XXX cap values + * describing VBox Chromium functionality caps visible to guest + * Currently can have only CR_VBOX_CAP_TEX_PRESENT cap to notify + * that the TexPresent mechanism is available and enabled */ + uint32_t u32Caps; + + PFNCRSERVERNOTIFYEVENT pfnNotifyEventCB; + + SPUDispatchTable TmpCtxDispatch; + + VBOXCRCMD_SVRENABLE_INFO CrCmdClientInfo; + +#ifdef VBOX_WITH_CRSERVER_DUMPER + CR_RECORDER Recorder; + CR_BLITTER RecorderBlitter; + CR_DBGPRINT_DUMPER DbgPrintDumper; + CR_HTML_DUMPER HtmlDumper; + CR_DUMPER *pDumper; +#endif + + int RcToGuest; + int RcToGuestOnce; +} CRServer; + + +extern DECLEXPORT(void) crServerInit( int argc, char *argv[] ); +extern DECLEXPORT(int) CRServerMain( int argc, char *argv[] ); +extern DECLEXPORT(void) crServerServiceClients(void); +extern DECLEXPORT(void) crServerAddNewClient(void); +extern DECLEXPORT(SPU*) crServerHeadSPU(void); +extern DECLEXPORT(void) crServerSetPort(int port); + +extern DECLEXPORT(GLboolean) crVBoxServerInit(void); +extern DECLEXPORT(void) crVBoxServerTearDown(void); +extern DECLEXPORT(int32_t) crVBoxServerAddClient(uint32_t u32ClientID); +extern DECLEXPORT(void) crVBoxServerRemoveClient(uint32_t u32ClientID); +extern DECLEXPORT(int32_t) crVBoxServerClientWrite(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t cbBuffer); +extern DECLEXPORT(int32_t) crVBoxServerClientRead(uint32_t u32ClientID, uint8_t *pBuffer, uint32_t *pcbBuffer); +extern DECLEXPORT(int32_t) crVBoxServerClientSetVersion(uint32_t u32ClientID, uint32_t vMajor, uint32_t vMinor); +extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsLegacy(uint32_t u32ClientID, uint32_t *pu32Caps); +extern DECLEXPORT(int32_t) crVBoxServerClientGetCapsNew(uint32_t u32ClientID, CR_CAPS_INFO *pInfo); +extern DECLEXPORT(int32_t) crVBoxServerClientSetPID(uint32_t u32ClientID, uint64_t pid); + +extern DECLEXPORT(int32_t) crVBoxServerSaveState(PSSMHANDLE pSSM); +extern DECLEXPORT(int32_t) crVBoxServerLoadState(PSSMHANDLE pSSM, uint32_t version); + +typedef struct +{ + CR_BLITTER_IMG Img; + uint32_t u32Screen; + uint32_t fDataAllocated; +} CR_SCREENSHOT; + +extern DECLEXPORT(int) crServerVBoxWindowsShow(bool fShow); +extern DECLEXPORT(int) crServerVBoxScreenshotGet(uint32_t u32Screen, uint32_t width, uint32_t height, uint32_t pitch, void *pvBuffer, CR_SCREENSHOT *pScreenshot); +extern DECLEXPORT(void) crServerVBoxScreenshotRelease(CR_SCREENSHOT *pScreenshot); + +extern DECLEXPORT(void) crServerVBoxCompositionSetEnableStateGlobal(GLboolean fEnable); +extern DECLEXPORT(int32_t) crVBoxServerSetScreenCount(int sCount); +extern DECLEXPORT(int32_t) crVBoxServerUnmapScreen(int sIndex); +extern DECLEXPORT(int32_t) crVBoxServerMapScreen(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h, uint64_t winID); +extern DECLEXPORT(void) crServerVBoxCompositionSetEnableStateGlobal(GLboolean fEnable); +struct VBVAINFOSCREEN; +extern DECLEXPORT(int) crVBoxServerNotifyResize(const struct VBVAINFOSCREEN *pScreen, void *pvVRAM); +extern DECLEXPORT(int32_t) crVBoxServerSetRootVisibleRegion(GLint cRects, const RTRECT *pRects); + +extern DECLEXPORT(int32_t) crVBoxServerSetOffscreenRendering(GLboolean value); + +extern DECLEXPORT(int32_t) crVBoxServerOutputRedirectSet(const CROutputRedirect *pCallbacks); + +extern DECLEXPORT(int32_t) crVBoxServerSetScreenViewport(int sIndex, int32_t x, int32_t y, uint32_t w, uint32_t h); + +extern DECLEXPORT(void) crServerVBoxSetNotifyEventCB(PFNCRSERVERNOTIFYEVENT pfnCb); + +extern DECLEXPORT(void) crVBoxServerCalloutEnable(VBOXCRCMDCTL *pCtl); +extern DECLEXPORT(void) crVBoxServerCalloutDisable(void); +extern DECLEXPORT(void) crServerSetUnscaledHiDPI(bool fEnable); + +#ifdef VBOX_WITH_CRHGSMI +/* We moved all CrHgsmi command processing to crserverlib to keep the logic of dealing with CrHgsmi commands in one place. + * + * For now we need the notion of CrHgdmi commands in the crserver_lib to be able to complete it asynchronously once it is really processed. + * This help avoiding the "blocked-client" issues. The client is blocked if another client is doing begin-end stuff. + * For now we eliminated polling that could occur on block, which caused a higher-priority thread (in guest) polling for the blocked command complition + * to block the lower-priority thread trying to complete the blocking command. + * And removed extra memcpy done on blocked command arrival. + * + * In the future we will extend CrHgsmi functionality to maintain texture data directly in CrHgsmi allocation to avoid extra memcpy-ing with PBO, + * implement command completion and stuff necessary for GPU scheduling to work properly for WDDM Windows guests, etc. + * + * NOTE: it is ALWAYS responsibility of the crVBoxServerCrHgsmiCmd to complete the command! + * */ +extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCmd(struct VBOXVDMACMD_CHROMIUM_CMD *pCmd, uint32_t cbCmd); +extern DECLEXPORT(int32_t) crVBoxServerCrHgsmiCtl(struct VBOXVDMACMD_CHROMIUM_CTL *pCtl, uint32_t cbCtl); + +#endif + +extern DECLEXPORT(int32_t) crVBoxServerHgcmEnable(VBOXCRCMDCTL_HGCMENABLE_DATA *pData); +extern DECLEXPORT(int32_t) crVBoxServerHgcmDisable(VBOXCRCMDCTL_HGCMDISABLE_DATA *pData); + +extern int crVBoxServerHostCtl(VBOXCRCMDCTL *pCtl, uint32_t cbCtl); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/src/VBox/GuestHost/OpenGL/include/cr_sortarray.h b/src/VBox/GuestHost/OpenGL/include/cr_sortarray.h new file mode 100644 index 00000000..8e2bd90d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_sortarray.h @@ -0,0 +1,102 @@ +/* $Id: cr_sortarray.h $ */ + +/** @file + * Sorted array API + */ + +/* + * Copyright (C) 2014-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ +#ifndef ___cr_sortarray_h_ +#define ___cr_sortarray_h_ + +#include +#include + +typedef struct CR_SORTARRAY +{ + uint32_t cBufferSize; + uint32_t cSize; + uint64_t *pElements; +} CR_SORTARRAY; + + +#ifndef IN_RING0 +# define VBOXSADECL(_type) DECLEXPORT(_type) +#else +# define VBOXSADECL(_type) RTDECL(_type) +#endif + + +DECLINLINE(uint32_t) CrSaGetSize(const CR_SORTARRAY *pArray) +{ + return pArray->cSize; +} + +DECLINLINE(uint64_t) CrSaGetVal(const CR_SORTARRAY *pArray, uint32_t i) +{ + Assert(i < pArray->cSize); + return pArray->pElements[i]; +} + +DECLINLINE(const uint64_t*) CrSaGetElements(const CR_SORTARRAY *pArray) +{ + return pArray->pElements; +} + +DECLINLINE(void) CrSaClear(CR_SORTARRAY *pArray) +{ + pArray->cSize = 0; +} + +VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer); +VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray); +/* + * @return true if element is found */ +VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element); + +/* + * @return VINF_SUCCESS if element is added + * VINF_ALREADY_INITIALIZED if element was in array already + * VERR_NO_MEMORY - no memory + * */ +VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element); + +/* + * @return VINF_SUCCESS if element is removed + * VINF_ALREADY_INITIALIZED if element was NOT in array + * */ +VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element); + +/* + * @return VINF_SUCCESS on success + * VERR_NO_MEMORY - no memory + * */ +VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2); +VBOXSADECL(int) CrSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult); + +/* + * @return VINF_SUCCESS on success + * VERR_NO_MEMORY - no memory + * */ +VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult); + +/* + * @return VINF_SUCCESS on success + * VERR_NO_MEMORY - no memory + * */ +VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult); + +VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2); + +VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2); + +#endif /* ___cr_sortarray_h_ */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_spu.h b/src/VBox/GuestHost/OpenGL/include/cr_spu.h new file mode 100644 index 00000000..f23a20b1 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_spu.h @@ -0,0 +1,483 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ +#ifndef CR_SPU_H +#define CR_SPU_H + +#ifdef WINDOWS +#define SPULOAD_APIENTRY __stdcall +#else +#define SPULOAD_APIENTRY +#endif + +#include "cr_dll.h" +#include "spu_dispatch_table.h" +#include "cr_net.h" + +#include + +#ifdef DARWIN +# include +# ifdef VBOX_WITH_COCOA_QT +# else +# include +# endif +#endif + +#define SPU_ENTRY_POINT_NAME "SPULoad" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_THREADS 32 /**< max threads per spu */ + +typedef struct _SPUSTRUCT SPU; + +typedef void (*SPUGenericFunction)(void); + +/** + * SPU Named function descriptor + */ +typedef struct { + char *name; + SPUGenericFunction fn; +} SPUNamedFunctionTable; + +/** + * SPU function table descriptor + */ +typedef struct { + SPUDispatchTable *childCopy; + void *data; + SPUNamedFunctionTable *table; +} SPUFunctions; + +/** + * SPU Option callback + * \param spu + * \param response + */ +typedef void (*SPUOptionCB)( void *spu, const char *response ); + +typedef enum { CR_BOOL, CR_INT, CR_FLOAT, CR_STRING, CR_ENUM } cr_type; + +/** + * SPU Options table + */ +typedef struct { + const char *option; /**< Name of the option */ + cr_type type; /**< Type of option */ + int numValues; /**< usually 1 */ + const char *deflt; /**< comma-separated string of [numValues] defaults */ + const char *min; /**< comma-separated string of [numValues] minimums */ + const char *max; /**< comma-separated string of [numValues] maximums */ + const char *description; /**< Textual description of the option */ + SPUOptionCB cb; /**< Callback function */ +} SPUOptions, *SPUOptionsPtr; + + +/** Init spu */ +typedef SPUFunctions *(*SPUInitFuncPtr)(int id, SPU *child, + SPU *super, unsigned int, unsigned int ); +typedef void (*SPUSelfDispatchFuncPtr)(SPUDispatchTable *); +/** Cleanup spu */ +typedef int (*SPUCleanupFuncPtr)(void); +/** Load spu */ +typedef int (*SPULoadFunction)(char **, char **, void *, void *, void *, + SPUOptionsPtr *, int *); + + +/** + * masks for spu_flags + */ +#define SPU_PACKER_MASK 0x1 +#define SPU_NO_PACKER 0x0 +#define SPU_HAS_PACKER 0x1 +#define SPU_TERMINAL_MASK 0x2 +#define SPU_NOT_TERMINAL 0x0 +#define SPU_IS_TERMINAL 0x2 +#define SPU_MAX_SERVERS_MASK 0xc +#define SPU_MAX_SERVERS_ZERO 0x0 +#define SPU_MAX_SERVERS_ONE 0x4 +#define SPU_MAX_SERVERS_UNLIMITED 0x8 + + +/** + * SPU descriptor + */ +struct _SPUSTRUCT { + char *name; /**< Name of the spu */ + char *super_name; /**< Name of the super class of the spu */ + int id; /**< Id num of the spu */ + int spu_flags; /**< options fags for the SPU */ + struct _SPUSTRUCT *superSPU; /**< Pointer to the descriptor for the super class */ + CRDLL *dll; /**< pointer to shared lib for spu */ + SPULoadFunction entry_point; /**< SPU's entry point (SPULoad()) */ + SPUInitFuncPtr init; /**< SPU init function */ + SPUSelfDispatchFuncPtr self; /**< */ + SPUCleanupFuncPtr cleanup; /**< SPU cleanup func */ + SPUFunctions *function_table; /**< Function table for spu */ + SPUOptions *options; /**< Options table */ + SPUDispatchTable dispatch_table; + void *privatePtr; /**< pointer to SPU-private data */ +}; + + +/** + * These are the OpenGL / window system interface functions + */ +#if defined(WINDOWS) +/** + * Windows/WGL + */ +/*@{*/ +typedef HGLRC (WGL_APIENTRY *wglCreateContextFunc_t)(HDC); +typedef void (WGL_APIENTRY *wglDeleteContextFunc_t)(HGLRC); +typedef BOOL (WGL_APIENTRY *wglShareListsFunc_t)(HGLRC,HGLRC); +typedef BOOL (WGL_APIENTRY *wglMakeCurrentFunc_t)(HDC,HGLRC); +typedef BOOL (WGL_APIENTRY *wglSwapBuffersFunc_t)(HDC); +typedef int (WGL_APIENTRY *wglChoosePixelFormatFunc_t)(HDC, CONST PIXELFORMATDESCRIPTOR *); +typedef BOOL (WGL_APIENTRY *wglChoosePixelFormatEXTFunc_t)(HDC, const int *, const FLOAT *, UINT, int *, UINT *); +typedef int (WGL_APIENTRY *wglDescribePixelFormatFunc_t)(HDC, int, UINT, CONST PIXELFORMATDESCRIPTOR *); +typedef int (WGL_APIENTRY *wglSetPixelFormatFunc_t)(HDC, int, CONST PIXELFORMATDESCRIPTOR *); +typedef HGLRC (WGL_APIENTRY *wglGetCurrentContextFunc_t)(); +typedef PROC (WGL_APIENTRY *wglGetProcAddressFunc_t)(); +typedef BOOL (WGL_APIENTRY *wglChoosePixelFormatEXTFunc_t)(HDC, const int *, const FLOAT *, UINT, int *, UINT *); +typedef BOOL (WGL_APIENTRY *wglGetPixelFormatAttribivEXTFunc_t)(HDC, int, int, UINT, int *, int *); +typedef BOOL (WGL_APIENTRY *wglGetPixelFormatAttribfvEXTFunc_t)(HDC, int, int, UINT, int *, float *); +typedef const GLubyte *(WGL_APIENTRY *glGetStringFunc_t)( GLenum ); +typedef const GLubyte *(WGL_APIENTRY *wglGetExtensionsStringEXTFunc_t)(); +typedef const GLubyte *(WGL_APIENTRY *wglGetExtensionsStringARBFunc_t)(HDC); +/*@}*/ +#elif defined(DARWIN) +# ifndef VBOX_WITH_COCOA_QT +/** + * Apple/AGL + */ +/*@{*/ +typedef AGLContext (*aglCreateContextFunc_t)( AGLPixelFormat, AGLContext ); +typedef GLboolean (*aglDestroyContextFunc_t)( AGLContext ); +typedef GLboolean (*aglSetCurrentContextFunc_t)( AGLContext ); +typedef void (*aglSwapBuffersFunc_t)( AGLContext ); +typedef AGLPixelFormat (*aglChoosePixelFormatFunc_t) (const AGLDevice *, GLint, const GLint *); +typedef GLboolean (*aglDescribePixelFormatFunc_t)( AGLPixelFormat, GLint, GLint * ); +/* <--set pixel format */ +typedef AGLContext (*aglGetCurrentContextFunc_t)(); +/* <--get proc address -- none exists */ +typedef void* (*aglGetProcAddressFunc_t)( const GLubyte *name ); + +/* These are here just in case */ +typedef GLboolean (*aglDescribeRendererFunc_t)( AGLRendererInfo, GLint, GLint * ); +typedef void (*aglDestroyPixelFormatFunc_t)( AGLPixelFormat ); +typedef void (*aglDestroyRendererInfoFunc_t)( AGLRendererInfo ); +typedef AGLDevice* (*aglDevicesOfPixelFormatFunc_t)( AGLPixelFormat, GLint ); +typedef GLboolean (*aglDisableFunc_t)( AGLContext, GLenum ); +typedef GLboolean (*aglEnableFunc_t)( AGLContext, GLenum ); +typedef const GLubyte* (*aglErrorStringFunc_t)( GLenum ); +typedef AGLDrawable (*aglGetDrawableFunc_t)( AGLContext ); +typedef GLenum (*aglGetErrorFunc_t)(); +typedef GLboolean (*aglGetIntegerFunc_t)( AGLContext, GLenum, GLint* ); +typedef void (*aglGetVersionFunc_t)( GLint *, GLint * ); +typedef GLint (*aglGetVirtualScreenFunc_t)( AGLContext ); +typedef GLboolean (*aglIsEnabledFunc_t)( AGLContext, GLenum ); +typedef AGLPixelFormat (*aglNextPixelFormatFunc_t)( AGLPixelFormat ); +typedef AGLRendererInfo (*aglNextRendererInfoFunc_t)( AGLRendererInfo ); +typedef AGLRendererInfo (*aglQueryRendererInfoFunc_t)( const AGLDevice *, GLint ); +typedef void (*aglReserLibraryFunc_t)(); +typedef GLboolean (*aglSetDrawableFunc_t)( AGLContext, AGLDrawable ); +typedef GLboolean (*aglSetFullScreenFunc_t)( AGLContext, GLsizei, GLsizei, GLsizei, GLint ); +typedef GLboolean (*aglSetIntegerFunc_t)( AGLContext, GLenum, const GLint * ); +typedef GLboolean (*aglSetOffScreenFunc_t)( AGLContext, GLsizei, GLsizei, GLsizei, void * ); +typedef GLboolean (*aglSetVirtualScreenFunc_t)( AGLContext, GLint ); +typedef GLboolean (*aglUpdateContextFunc_t)( AGLContext ); +typedef GLboolean (*aglUseFontFunc_t)( AGLContext, GLint, Style, GLint, GLint, GLint, GLint ); +# endif + +typedef const GLubyte *(*glGetStringFunc_t)( GLenum ); +/*@}*/ + +/** + * Apple/CGL + */ +/*@{*/ +typedef CGLError (*CGLSetCurrentContextFunc_t)( CGLContextObj ); +typedef CGLContextObj (*CGLGetCurrentContextFunc_t)(); + +typedef CGLError (*CGLChoosePixelFormatFunc_t)( const CGLPixelFormatAttribute *, CGLPixelFormatObj *, long * ); +typedef CGLError (*CGLDestroyPixelFormatFunc_t)( CGLPixelFormatObj ); +typedef CGLError (*CGLDescribePixelFormatFunc_t)( CGLPixelFormatObj , long , CGLPixelFormatAttribute , long * ); + +typedef CGLError (*CGLQueryRendererInfoFunc_t)( unsigned long, CGLRendererInfoObj *, long * ); +typedef CGLError (*CGLDestroyRendererInfoFunc_t)( CGLRendererInfoObj ); +typedef CGLError (*CGLDescribeRendererFunc_t)( CGLRendererInfoObj, long, CGLRendererProperty, long * ); + +typedef CGLError (*CGLCreateContextFunc_t)( CGLPixelFormatObj, CGLContextObj, CGLContextObj * ); +typedef CGLError (*CGLDestroyContextFunc_t)( CGLContextObj ); +typedef CGLError (*CGLCopyContextFunc_t)( CGLContextObj src, CGLContextObj, unsigned long ); + +typedef CGLError (*CGLCreatePBufferFunc_t)( long, long, unsigned long, unsigned long, long, CGLPBufferObj * ) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; +typedef CGLError (*CGLDestroyPBufferFunc_t)( CGLPBufferObj ) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; +typedef CGLError (*CGLDescribePBufferFunc_t)( CGLPBufferObj, long *, long *, unsigned long *, unsigned long *, long * ) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; +typedef CGLError (*CGLTexImagePBufferFunc_t)( CGLContextObj, CGLPBufferObj, unsigned long ) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; + +typedef CGLError (*CGLSetOffScreenFunc_t)( CGLContextObj, long, long, long, void * ); +typedef CGLError (*CGLGetOffScreenFunc_t)( CGLContextObj, long *, long *, long *, void ** ); +typedef CGLError (*CGLSetFullScreenFunc_t)( CGLContextObj ); + +typedef CGLError (*CGLSetPBufferFunc_t)( CGLContextObj, CGLPBufferObj, unsigned long, long, long ) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; +typedef CGLError (*CGLGetPBufferFunc_t)( CGLContextObj, CGLPBufferObj *, unsigned long *, long *, long * ) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER; + +typedef CGLError (*CGLClearDrawableFunc_t)( CGLContextObj ); +typedef CGLError (*CGLFlushDrawableFunc_t)( CGLContextObj ); /* <-- swap buffers */ + +typedef CGLError (*CGLEnableFunc_t)( CGLContextObj, CGLContextEnable ); +typedef CGLError (*CGLDisableFunc_t)( CGLContextObj, CGLContextEnable ); +typedef CGLError (*CGLIsEnabledFunc_t)( CGLContextObj, CGLContextEnable, long * ); + +typedef CGLError (*CGLSetParameterFunc_t)( CGLContextObj, CGLContextParameter, const long * ); +typedef CGLError (*CGLGetParameterFunc_t)( CGLContextObj, CGLContextParameter, long * ); + +typedef CGLError (*CGLSetVirtualScreenFunc_t)( CGLContextObj, long ); +typedef CGLError (*CGLGetVirtualScreenFunc_t)( CGLContextObj, long *); + +typedef CGLError (*CGLSetOptionFunc_t)( CGLGlobalOption, long ); +typedef CGLError (*CGLGetOptionFunc_t)( CGLGlobalOption, long * ); +typedef void (*CGLGetVersionFunc_t)( long *, long * ); + +typedef const char * (*CGLErrorStringFunc_t)( CGLError ); + +/** XXX \todo Undocumented CGL functions. Are these all correct? */ +typedef void *CGSConnectionID; +typedef int CGSWindowID; +typedef int CGSSurfaceID; + +typedef CGLError (*CGLSetSurfaceFunc_t)( CGLContextObj, CGSConnectionID, CGSWindowID, CGSSurfaceID ); +typedef CGLError (*CGLGetSurfaceFunc_t)( CGLContextObj, CGSConnectionID, CGSWindowID, CGSSurfaceID* ); +typedef CGLError (*CGLUpdateContextFunc_t)( CGLContextObj ); +/*@}*/ +#else +/** + * X11/GLX + */ +/*@{*/ +typedef int (*glXGetConfigFunc_t)( Display *, XVisualInfo *, int, int * ); +typedef Bool (*glXQueryExtensionFunc_t) (Display *, int *, int * ); +typedef const char *(*glXQueryExtensionsStringFunc_t) (Display *, int ); +typedef Bool (*glXQueryVersionFunc_t)( Display *dpy, int *maj, int *min ); +typedef XVisualInfo *(*glXChooseVisualFunc_t)( Display *, int, int * ); +typedef GLXContext (*glXCreateContextFunc_t)( Display *, XVisualInfo *, GLXContext, Bool ); +typedef void (*glXUseXFontFunc_t)(Font font, int first, int count, int listBase); +typedef void (*glXDestroyContextFunc_t)( Display *, GLXContext ); +typedef Bool (*glXIsDirectFunc_t)( Display *, GLXContext ); +typedef Bool (*glXMakeCurrentFunc_t)( Display *, GLXDrawable, GLXContext ); +typedef void (*glXSwapBuffersFunc_t)( Display *, GLXDrawable ); +typedef CR_GLXFuncPtr (*glXGetProcAddressARBFunc_t)( const GLubyte *name ); +typedef Display *(*glXGetCurrentDisplayFunc_t)( void ); +typedef GLXContext (*glXGetCurrentContextFunc_t)( void ); +typedef GLXDrawable (*glXGetCurrentDrawableFunc_t)( void ); +typedef char * (*glXGetClientStringFunc_t)( Display *dpy, int name ); +typedef void (*glXWaitGLFunc_t)(void); +typedef void (*glXWaitXFunc_t)(void); +typedef void (*glXCopyContextFunc_t)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask ); +typedef const GLubyte *(*glGetStringFunc_t)( GLenum ); +typedef Bool (*glXJoinSwapGroupNVFunc_t)(Display *dpy, GLXDrawable drawable, GLuint group); +typedef Bool (*glXBindSwapBarrierNVFunc_t)(Display *dpy, GLuint group, GLuint barrier); +typedef Bool (*glXQuerySwapGroupNVFunc_t)(Display *dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +typedef Bool (*glXQueryMaxSwapGroupsNVFunc_t)(Display *dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +typedef Bool (*glXQueryFrameCountNVFunc_t)(Display *dpy, int screen, GLuint *count); +typedef Bool (*glXResetFrameCountNVFunc_t)(Display *dpy, int screen); +#ifdef GLX_VERSION_1_3 +typedef GLXContext (*glXCreateNewContextFunc_t)( Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct ); +typedef GLXWindow (*glXCreateWindowFunc_t)(Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef Bool (*glXMakeContextCurrentFunc_t)( Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx ); +typedef GLXFBConfig *(*glXChooseFBConfigFunc_t)( Display *dpy, int screen, const int *attribList, int *nitems ); +typedef GLXFBConfig *(*glXGetFBConfigsFunc_t)(Display *dpy, int screen, int *nelements); +typedef int (*glXGetFBConfigAttribFunc_t)(Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef XVisualInfo *(*glXGetVisualFromFBConfigFunc_t)(Display *dpy, GLXFBConfig config); +typedef GLXPbuffer (*glXCreatePbufferFunc_t)( Display *dpy, GLXFBConfig config, const int *attribList ); +typedef void (*glXDestroyPbufferFunc_t)( Display *dpy, GLXPbuffer pbuf ); +typedef int (*glXQueryContextFunc_t)(Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void (*glXQueryDrawableFunc_t)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +#endif /* GLX_VERSION_1_3 */ +/*@}*/ +#endif + + +/** + * Package up the WGL/AGL/CGL/GLX function pointers into a struct. We use + * this in a few different places. + */ +typedef struct { +#if defined(WINDOWS) + wglGetProcAddressFunc_t wglGetProcAddress; + wglCreateContextFunc_t wglCreateContext; + wglDeleteContextFunc_t wglDeleteContext; + wglShareListsFunc_t wglShareLists; + wglMakeCurrentFunc_t wglMakeCurrent; + wglSwapBuffersFunc_t wglSwapBuffers; + wglGetCurrentContextFunc_t wglGetCurrentContext; + wglChoosePixelFormatFunc_t wglChoosePixelFormat; + wglDescribePixelFormatFunc_t wglDescribePixelFormat; + wglSetPixelFormatFunc_t wglSetPixelFormat; + wglChoosePixelFormatEXTFunc_t wglChoosePixelFormatEXT; + wglGetPixelFormatAttribivEXTFunc_t wglGetPixelFormatAttribivEXT; + wglGetPixelFormatAttribfvEXTFunc_t wglGetPixelFormatAttribfvEXT; + wglGetExtensionsStringEXTFunc_t wglGetExtensionsStringEXT; +#elif defined(DARWIN) +# ifndef VBOX_WITH_COCOA_QT + aglCreateContextFunc_t aglCreateContext; + aglDestroyContextFunc_t aglDestroyContext; + aglSetCurrentContextFunc_t aglSetCurrentContext; + aglSwapBuffersFunc_t aglSwapBuffers; + aglChoosePixelFormatFunc_t aglChoosePixelFormat; + aglDestroyPixelFormatFunc_t aglDestroyPixelFormat; + aglDescribePixelFormatFunc_t aglDescribePixelFormat; + aglGetCurrentContextFunc_t aglGetCurrentContext; + aglSetDrawableFunc_t aglSetDrawable; + aglGetDrawableFunc_t aglGetDrawable; + aglSetFullScreenFunc_t aglSetFullScreen; + aglGetProcAddressFunc_t aglGetProcAddress; + aglUpdateContextFunc_t aglUpdateContext; + aglUseFontFunc_t aglUseFont; + aglSetIntegerFunc_t aglSetInteger; + aglGetErrorFunc_t aglGetError; + aglGetIntegerFunc_t aglGetInteger; + aglEnableFunc_t aglEnable; + aglDisableFunc_t aglDisable; +# endif + + CGLChoosePixelFormatFunc_t CGLChoosePixelFormat; + CGLDestroyPixelFormatFunc_t CGLDestroyPixelFormat; + CGLDescribePixelFormatFunc_t CGLDescribePixelFormat; + CGLQueryRendererInfoFunc_t CGLQueryRendererInfo; + CGLDestroyRendererInfoFunc_t CGLDestroyRendererInfo; + CGLDescribeRendererFunc_t CGLDescribeRenderer; + CGLCreateContextFunc_t CGLCreateContext; + CGLDestroyContextFunc_t CGLDestroyContext; + CGLCopyContextFunc_t CGLCopyContext; + CGLSetCurrentContextFunc_t CGLSetCurrentContext; + CGLGetCurrentContextFunc_t CGLGetCurrentContext; + CGLCreatePBufferFunc_t CGLCreatePBuffer; + CGLDestroyPBufferFunc_t CGLDestroyPBuffer; + CGLDescribePBufferFunc_t CGLDescribePBuffer; + CGLTexImagePBufferFunc_t CGLTexImagePBuffer; + CGLSetOffScreenFunc_t CGLSetOffScreen; + CGLGetOffScreenFunc_t CGLGetOffScreen; + CGLSetFullScreenFunc_t CGLSetFullScreen; + CGLSetPBufferFunc_t CGLSetPBuffer; + CGLGetPBufferFunc_t CGLGetPBuffer; + CGLClearDrawableFunc_t CGLClearDrawable; + CGLFlushDrawableFunc_t CGLFlushDrawable; + CGLEnableFunc_t CGLEnable; + CGLDisableFunc_t CGLDisable; + CGLIsEnabledFunc_t CGLIsEnabled; + CGLSetParameterFunc_t CGLSetParameter; + CGLGetParameterFunc_t CGLGetParameter; + CGLSetVirtualScreenFunc_t CGLSetVirtualScreen; + CGLGetVirtualScreenFunc_t CGLGetVirtualScreen; + CGLSetOptionFunc_t CGLSetOption; + CGLGetOptionFunc_t CGLGetOption; + CGLGetVersionFunc_t CGLGetVersion; + CGLErrorStringFunc_t CGLErrorString; + + CGLSetSurfaceFunc_t CGLSetSurface; + CGLGetSurfaceFunc_t CGLGetSurface; + CGLUpdateContextFunc_t CGLUpdateContext; +#else + glXGetConfigFunc_t glXGetConfig; + glXQueryExtensionFunc_t glXQueryExtension; + glXQueryVersionFunc_t glXQueryVersion; + glXQueryExtensionsStringFunc_t glXQueryExtensionsString; + glXChooseVisualFunc_t glXChooseVisual; + glXCreateContextFunc_t glXCreateContext; + glXDestroyContextFunc_t glXDestroyContext; + glXUseXFontFunc_t glXUseXFont; + glXIsDirectFunc_t glXIsDirect; + glXMakeCurrentFunc_t glXMakeCurrent; + glXSwapBuffersFunc_t glXSwapBuffers; + glXGetProcAddressARBFunc_t glXGetProcAddressARB; + glXGetCurrentDisplayFunc_t glXGetCurrentDisplay; + glXGetCurrentContextFunc_t glXGetCurrentContext; + glXGetCurrentDrawableFunc_t glXGetCurrentDrawable; + glXGetClientStringFunc_t glXGetClientString; + glXWaitGLFunc_t glXWaitGL; + glXWaitXFunc_t glXWaitX; + glXCopyContextFunc_t glXCopyContext; + /* GLX_NV_swap_group */ + glXJoinSwapGroupNVFunc_t glXJoinSwapGroupNV; + glXBindSwapBarrierNVFunc_t glXBindSwapBarrierNV; + glXQuerySwapGroupNVFunc_t glXQuerySwapGroupNV; + glXQueryMaxSwapGroupsNVFunc_t glXQueryMaxSwapGroupsNV; + glXQueryFrameCountNVFunc_t glXQueryFrameCountNV; + glXResetFrameCountNVFunc_t glXResetFrameCountNV; +#ifdef GLX_VERSION_1_3 + glXCreateNewContextFunc_t glXCreateNewContext; + glXCreateWindowFunc_t glXCreateWindow; + glXMakeContextCurrentFunc_t glXMakeContextCurrent; + glXChooseFBConfigFunc_t glXChooseFBConfig; + glXGetFBConfigsFunc_t glXGetFBConfigs; + glXGetFBConfigAttribFunc_t glXGetFBConfigAttrib; + glXGetVisualFromFBConfigFunc_t glXGetVisualFromFBConfig; + glXCreatePbufferFunc_t glXCreatePbuffer; + glXDestroyPbufferFunc_t glXDestroyPbuffer; + glXQueryContextFunc_t glXQueryContext; + glXQueryDrawableFunc_t glXQueryDrawable; +#endif +#endif + glGetStringFunc_t glGetString; +} crOpenGLInterface; + + +/** This is the one required function in _all_ SPUs */ +DECLEXPORT(int) SPULoad( char **name, char **super, SPUInitFuncPtr *init, + SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup, + SPUOptionsPtr *options, int *flags ); + +DECLEXPORT(SPU *) crSPULoad( SPU *child, int id, char *name, char *dir, void *server); +DECLEXPORT(SPU *) crSPULoadChain( int count, int *ids, char **names, char *dir, void *server ); +DECLEXPORT(void) crSPUUnloadChain(SPU *headSPU); + +DECLEXPORT(void) crSPUInitDispatchTable( SPUDispatchTable *table ); +DECLEXPORT(void) crSPUCopyDispatchTable( SPUDispatchTable *dst, SPUDispatchTable *src ); +DECLEXPORT(void) crSPUChangeInterface( SPUDispatchTable *table, void *origFunc, void *newFunc ); + + +DECLEXPORT(void) crSPUSetDefaultParams( void *spu, SPUOptions *options ); +DECLEXPORT(int) crSPUGetEnumIndex( const SPUOptions *option, const char *optName, const char *value ); + + +DECLEXPORT(SPUGenericFunction) crSPUFindFunction( const SPUNamedFunctionTable *table, const char *fname ); +DECLEXPORT(void) crSPUInitDispatch( SPUDispatchTable *dispatch, const SPUNamedFunctionTable *table ); +DECLEXPORT(void) crSPUInitDispatchNops(SPUDispatchTable *table); + +DECLEXPORT(int) crLoadOpenGL( crOpenGLInterface *crInterface, SPUNamedFunctionTable table[] ); +DECLEXPORT(void) crUnloadOpenGL( void ); +DECLEXPORT(int) crLoadOpenGLExtensions( const crOpenGLInterface *crInterface, SPUNamedFunctionTable table[] ); +DECLEXPORT(void) crSPUChangeDispatch(SPUDispatchTable *dispatch, const SPUNamedFunctionTable *newtable); + +#if defined(GLX) +DECLEXPORT(XVisualInfo *) +crChooseVisual(const crOpenGLInterface *ws, Display *dpy, int screen, + GLboolean directColor, int visBits); +#else +DECLEXPORT(int) +crChooseVisual(const crOpenGLInterface *ws, int visBits); +#endif + + +#ifdef USE_OSMESA +DECLEXPORT(int) +crLoadOSMesa( OSMesaContext (**createContext)( GLenum format, OSMesaContext sharelist ), + GLboolean (**makeCurrent)( OSMesaContext ctx, GLubyte *buffer, + GLenum type, GLsizei width, GLsizei height ), + void (**destroyContext)( OSMesaContext ctx )); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CR_SPU_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_string.h b/src/VBox/GuestHost/OpenGL/include/cr_string.h new file mode 100644 index 00000000..824d9f69 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_string.h @@ -0,0 +1,67 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STRING_H +#define CR_STRING_H + +#include +#include + +RT_C_DECLS_BEGIN + +DECLEXPORT(char *) crStrdup( const char *str ); +DECLEXPORT(char *) crStrndup( const char *str, unsigned int len ); +DECLEXPORT(int) crStrlen( const char *str ); +DECLEXPORT(int) crStrcmp( const char *str1, const char *str2 ); +DECLEXPORT(int) crStrncmp( const char *str1, const char *str2, int n ); +DECLEXPORT(int) crStrcasecmp( const char *str1, const char *str2 ); +DECLEXPORT(void) crStrcpy( char *dst, const char *src ); +DECLEXPORT(void) crStrncpy( char *dst, const char *src, unsigned int len ); +DECLEXPORT(void) crStrcat( char *dst, const char *src ); +DECLEXPORT(char *) crStrjoin( const char *src1, const char *src2 ); +DECLEXPORT(char *) crStrjoin3( const char *src1, const char *src2, const char *src3 ); +DECLEXPORT(char *) crStrstr( const char *str, const char *pat ); +DECLEXPORT(char *) crStrchr( const char *str, char c ); +DECLEXPORT(char *) crStrrchr( const char *str, char c ); +DECLEXPORT(int) crStrToInt( const char *str ); +DECLEXPORT(float) crStrToFloat( const char *str ); +DECLEXPORT(char **) crStrSplit( const char *str, const char *splitstr ); +DECLEXPORT(char **) crStrSplitn( const char *str, const char *splitstr, int n ); +DECLEXPORT(void) crFreeStrings( char **strings ); +DECLEXPORT(char *) crStrIntersect( const char *s1, const char *s2 ); +DECLEXPORT(int) crIsDigit( char c ); + +DECLEXPORT(void) crBytesToString( char *string, int nstring, void *data, int ndata ); +DECLEXPORT(void) crWordsToString( char *string, int nstring, void *data, int ndata ); + +#define CR_GLVERSION_OFFSET_MAJOR (24) +#define CR_GLVERSION_OFFSET_MINOR (16) +#define CR_GLVERSION_OFFSET_BUILD (0) + +#define CR_GLVERSION_MAX_MAJOR (0x7f) +#define CR_GLVERSION_MAX_MINOR (0xff) +#define CR_GLVERSION_MAX_BUILD (0xffff) + +#define CR_GLVERSION_MASK_MAJOR (CR_GLVERSION_MAX_MAJOR << CR_GLVERSION_OFFSET_MAJOR) +#define CR_GLVERSION_MASK_MINOR (CR_GLVERSION_MAX_MINOR << CR_GLVERSION_OFFSET_MINOR) +#define CR_GLVERSION_MASK_BUILD (CR_GLVERSION_MAX_BUILD << CR_GLVERSION_OFFSET_BUILD) + +#define CR_GLVERSION_COMPOSE_EL(_val, _type) (((_val) << CR_GLVERSION_OFFSET_##_type) & CR_GLVERSION_MASK_##_type) + +#define CR_GLVERSION_COMPOSE(_maj, _min, _build) (CR_GLVERSION_COMPOSE_EL((_maj), MAJOR) \ + + CR_GLVERSION_COMPOSE_EL((_min), MINOR) \ + + CR_GLVERSION_COMPOSE_EL((_build), BUILD)) + +#define CR_GLVERSION_GET_EL(_val, _type) (((_val) & CR_GLVERSION_MASK_##_type) >> CR_GLVERSION_OFFSET_##_type) +#define CR_GLVERSION_GET_MAJOR(_val) CR_GLVERSION_GET_EL((_val), MAJOR) +#define CR_GLVERSION_GET_MINOR(_val) CR_GLVERSION_GET_EL((_val), MINOR) +#define CR_GLVERSION_GET_BUILD(_val) CR_GLVERSION_GET_EL((_val), BUILD) + +DECLEXPORT(int) crStrParseGlVersion(const char * ver); +DECLEXPORT(int32_t) crStrParseI32(const char *pszStr, const int32_t defaultVal); +RT_C_DECLS_END + +#endif /* CR_STRING_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_threads.h b/src/VBox/GuestHost/OpenGL/include/cr_threads.h new file mode 100644 index 00000000..b3b6a93a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_threads.h @@ -0,0 +1,118 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_THREADS_H +#define CR_THREADS_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include "chromium.h" +#include "cr_bits.h" + +#ifdef WINDOWS +#define WIN32_LEAN_AND_MEAN +# ifdef VBOX +# include +# else +#include +# endif +#else +#include +#include +#endif + +#include "cr_error.h" + +#include +/* + * Handle for Thread-Specific Data + */ +typedef struct { +#ifdef WINDOWS + DWORD key; +#else + pthread_key_t key; +#endif + int initMagic; +} CRtsd; + + +extern DECLEXPORT(void) crInitTSD(CRtsd *tsd); +extern DECLEXPORT(void) crInitTSDF(CRtsd *tsd, void (*destructor)(void *)); +extern DECLEXPORT(void) crFreeTSD(CRtsd *tsd); +extern DECLEXPORT(void) crSetTSD(CRtsd *tsd, void *ptr); +extern DECLEXPORT(void *) crGetTSD(CRtsd *tsd); +extern DECLEXPORT(unsigned long) crThreadID(void); + + +/* Mutex datatype */ +#ifdef WINDOWS +typedef CRITICAL_SECTION CRmutex; +#else +typedef pthread_mutex_t CRmutex; +#endif + +extern DECLEXPORT(void) crInitMutex(CRmutex *mutex); +extern DECLEXPORT(void) crFreeMutex(CRmutex *mutex); +extern DECLEXPORT(void) crLockMutex(CRmutex *mutex); +extern DECLEXPORT(void) crUnlockMutex(CRmutex *mutex); + + +/* Condition variable datatype */ +#ifdef WINDOWS +typedef int CRcondition; +#else +typedef pthread_cond_t CRcondition; +#endif + +extern DECLEXPORT(void) crInitCondition(CRcondition *cond); +extern DECLEXPORT(void) crFreeCondition(CRcondition *cond); +extern DECLEXPORT(void) crWaitCondition(CRcondition *cond, CRmutex *mutex); +extern DECLEXPORT(void) crSignalCondition(CRcondition *cond); + + +/* Barrier datatype */ +typedef struct { + unsigned int count; +#ifdef WINDOWS + HANDLE hEvents[CR_MAX_CONTEXTS]; +#else + unsigned int waiting; + pthread_cond_t cond; + pthread_mutex_t mutex; +#endif +} CRbarrier; + +extern DECLEXPORT(void) crInitBarrier(CRbarrier *b, unsigned int count); +extern DECLEXPORT(void) crFreeBarrier(CRbarrier *b); +extern DECLEXPORT(void) crWaitBarrier(CRbarrier *b); + + +/* Semaphores */ +#ifdef WINDOWS + typedef int CRsemaphore; +#else + typedef sem_t CRsemaphore; +#endif + +extern DECLEXPORT(void) crInitSemaphore(CRsemaphore *s, unsigned int count); +extern DECLEXPORT(void) crWaitSemaphore(CRsemaphore *s); +extern DECLEXPORT(void) crSignalSemaphore(CRsemaphore *s); + +#define VBoxTlsRefGetImpl(_tls) (crGetTSD((CRtsd*)(_tls))) +#define VBoxTlsRefSetImpl(_tls, _val) (crSetTSD((CRtsd*)(_tls), (_val))) +#define VBoxTlsRefAssertImpl CRASSERT +#include + +#ifdef __cplusplus +} +#endif + +#endif /* CR_THREADS_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_timer.h b/src/VBox/GuestHost/OpenGL/include/cr_timer.h new file mode 100644 index 00000000..9385a76c --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_timer.h @@ -0,0 +1,58 @@ +#ifndef CR_TIMER_H +#define CR_TIMER_H + +#ifndef WINDOWS +#include + +#if defined (IRIX) || defined( IRIX64 ) +typedef unsigned long long iotimer64_t; +typedef unsigned int iotimer32_t; +#endif +#else +# ifdef VBOX +# include +# else +#include +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct Timer +{ + double time0, elapsed; + char running; + + int fd; +#if defined (IRIX) || defined( IRIX64 ) + unsigned long long counter64; + unsigned int counter32; + unsigned int cycleval; + + volatile iotimer64_t *iotimer_addr64; + volatile iotimer32_t *iotimer_addr32; + + void *unmapLocation; + int unmapSize; +#elif defined(WINDOWS) + LARGE_INTEGER performance_counter, performance_frequency; + double one_over_frequency; +#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined (SunOS) || defined(OSF1) + struct timeval timeofday; +#endif +} CRTimer; + +CRTimer *crTimerNewTimer( void ); +void crDestroyTimer( CRTimer *t ); +void crStartTimer( CRTimer *t ); +void crStopTimer( CRTimer *t ); +void crResetTimer( CRTimer *t ); +double crTimerTime( CRTimer *t ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_TIMER_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_unpack.h b/src/VBox/GuestHost/OpenGL/include/cr_unpack.h new file mode 100644 index 00000000..61de8fcc --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_unpack.h @@ -0,0 +1,98 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_UNPACK_H +#define CR_UNPACK_H + +#include "cr_compiler.h" +#include "cr_spu.h" +#include "cr_protocol.h" +#include "cr_mem.h" +#include "cr_opcodes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern SPUDispatchTable cr_unpackDispatch; +/*extern DLLDATA(const unsigned char *) cr_unpackData;*/ +extern DECLEXPORT(const unsigned char *) cr_unpackData; +extern DECLEXPORT(const unsigned char *) cr_unpackDataEnd; + +DECLEXPORT(void) crUnpackSetReturnPointer( CRNetworkPointer *ptr ); +DECLEXPORT(void) crUnpackSetWritebackPointer( CRNetworkPointer *ptr ); +DECLEXPORT(void) crUnpack( const void *data, const void *data_end, const void *opcodes, unsigned int num_opcodes, SPUDispatchTable *table ); +DECLEXPORT(void) crUnpackPush(void); +DECLEXPORT(void) crUnpackPop(void); + +typedef enum +{ + CR_UNPACK_BUFFER_TYPE_GENERIC = 0, + CR_UNPACK_BUFFER_TYPE_CMDBLOCK_BEGIN, + CR_UNPACK_BUFFER_TYPE_CMDBLOCK_FLUSH, + CR_UNPACK_BUFFER_TYPE_CMDBLOCK_END +} CR_UNPACK_BUFFER_TYPE; + +DECLEXPORT(CR_UNPACK_BUFFER_TYPE) crUnpackGetBufferType(const void *opcodes, unsigned int num_opcodes); + +extern CRNetworkPointer * return_ptr; +extern CRNetworkPointer * writeback_ptr; + +#if defined(LINUX) || defined(WINDOWS) +#define CR_UNALIGNED_ACCESS_OKAY +#else +#undef CR_UNALIGNED_ACCESS_OKAY +#endif +DECLEXPORT(double) crReadUnalignedDouble( const void *buffer ); + +#define READ_DATA( offset, type ) \ + *( (const type *) (cr_unpackData + (offset))) + +#ifdef CR_UNALIGNED_ACCESS_OKAY +#define READ_DOUBLE( offset ) \ + READ_DATA( offset, GLdouble ) +#else +#define READ_DOUBLE( offset ) \ + crReadUnalignedDouble( cr_unpackData + (offset) ) +#endif + +#define READ_NETWORK_POINTER( offset ) \ + ( cr_unpackData + (offset) ) + +/* XXX make this const */ +#define DATA_POINTER( offset, type ) \ + ( (type *) (cr_unpackData + (offset)) ) + +#define DATA_POINTER_CHECK( offset ) \ + ( (cr_unpackDataEnd >= cr_unpackData) && (size_t)(cr_unpackDataEnd - cr_unpackData) >= (size_t)(offset) ) + +#define INCR_DATA_PTR( delta ) \ + cr_unpackData += (delta) + +#define INCR_DATA_PTR_NO_ARGS() \ + INCR_DATA_PTR( 4 ) + +#define INCR_VAR_PTR() \ + INCR_DATA_PTR( *((int *) cr_unpackData ) ) + +#define SET_RETURN_PTR( offset ) do { \ + CRDBGPTR_CHECKZ(return_ptr); \ + crMemcpy( return_ptr, cr_unpackData + (offset), sizeof( *return_ptr ) ); \ + } while (0); + + +#define SET_WRITEBACK_PTR( offset ) do { \ + CRDBGPTR_CHECKZ(writeback_ptr); \ + crMemcpy( writeback_ptr, cr_unpackData + (offset), sizeof( *writeback_ptr ) ); \ + } while (0); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_UNPACK_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_url.h b/src/VBox/GuestHost/OpenGL/include/cr_url.h new file mode 100644 index 00000000..38a11313 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_url.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_URL_H +#define CR_URL_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DECLEXPORT(int) crParseURL( const char *url, char *protocol, char *hostname, + unsigned short *port, unsigned short default_port ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_URL_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_version.h b/src/VBox/GuestHost/OpenGL/include/cr_version.h new file mode 100644 index 00000000..1c3c2478 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_version.h @@ -0,0 +1,186 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_VERSION_H +#define CR_VERSION_H + +#define SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS 28 +/* version which might have context usage bits saved */ +#define SHCROGL_SSM_VERSION_WITH_SAVED_CTXUSAGE_BITS SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS +#define SHCROGL_SSM_VERSION_BEFORE_FRONT_DRAW_TRACKING 29 +/* version that might have corrupted state data */ +#define SHCROGL_SSM_VERSION_WITH_CORUPTED_STATE 30 +/* version with invalid glGetError state */ +#define SHCROGL_SSM_VERSION_WITH_INVALID_ERROR_STATE 30 +/* VBox 4.2.12 had a bug that incorrectly CRMuralInfo data + * in a different format without changing the state version, + * i.e. 30 version can have both "correct" and "incorrect" CRMuralInfo data */ +#define SHCROGL_SSM_VERSION_WITH_BUGGY_MURAL_INFO 30 +/* the saved state has incorrect front and back buffer image data */ +#define SHCROGL_SSM_VERSION_WITH_BUGGY_FB_IMAGE_DATA 31 +#define SHCROGL_SSM_VERSION_WITH_STATE_BITS 33 +#define SHCROGL_SSM_VERSION_WITH_WINDOW_CTX_USAGE 33 +#define SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL 34 +#define SHCROGL_SSM_VERSION_WITH_SAVED_DEPTH_STENCIL_BUFFER 35 +/* some ogl drivers fail to Read/DrawPixels for DEPTH and STENCIL separately + * from DEPTH_STENCIL renderbuffer we used for offscreen rendering + * this is why we switched to glReadDrawPixels(GL_DEPTH_STENCIL) in one run */ +#define SHCROGL_SSM_VERSION_WITH_SINGLE_DEPTH_STENCIL 36 +#define SHCROGL_SSM_VERSION_WITH_PRESENT_STATE 37 +/* older state did not have glPointParameter ( GL_POINT_SPRITE_COORD_ORIGIN ) implementation */ +#define SHCROGL_SSM_VERSION_WITH_SPRITE_COORD_ORIGIN 38 +/* dirty bits are not needed for now, remove */ +#define SHCROGL_SSM_VERSION_WITHOUT_DIRTY_BITS 38 +/* dummy windows and contexts have 0 external IDs, so never get stored to the state */ +#define SHCROGL_SSM_VERSION_WITH_FIXED_DUMMYIDS 39 +#define SHCROGL_SSM_VERSION_WITH_SCREEN_INFO 40 +#define SHCROGL_SSM_VERSION_WITH_ALLOCATED_KEYS 41 +#define SHCROGL_SSM_VERSION_WITH_FB_INFO 42 +#define SHCROGL_SSM_VERSION_WITH_BUGGY_KEYS 42 +#define SHCROGL_SSM_VERSION_CRCMD 44 +#define SHCROGL_SSM_VERSION_WITH_SCREEN_MAP 45 +#define SHCROGL_SSM_VERSION_WITH_SCREEN_MAP_REORDERED 46 +#define SHCROGL_SSM_VERSION_WITH_PEND_CMD_INFO 47 +#define SHCROGL_SSM_VERSION_WITH_SEPARATE_DEPTH_STENCIL_BUFFERS 48 +#define SHCROGL_SSM_VERSION_WITH_DISPLAY_LISTS 49 +#define SHCROGL_SSM_VERSION 49 + +/* These define the Chromium release number. + * Alpha Release = 0.1.0, Beta Release = 0.2.0 + */ +#define CR_MAJOR_VERSION 1 +#define CR_MINOR_VERSION 9 +#define CR_PATCH_VERSION 0 + +#define CR_VERSION_STRING "1.9" /* Chromium version, not OpenGL version */ + + +/* These define the OpenGL version that Chromium supports. + * This lets users easily recompile Chromium with/without OpenGL 1.x support. + * We use OpenGL's GL_VERSION_1_x convention. + */ +#define CR_OPENGL_VERSION_1_0 1 +#define CR_OPENGL_VERSION_1_1 1 +#define CR_OPENGL_VERSION_1_2 1 +#define CR_OPENGL_VERSION_1_2_1 1 +#define CR_OPENGL_VERSION_1_3 1 +#define CR_OPENGL_VERSION_1_4 1 +#define CR_OPENGL_VERSION_1_5 1 +#define CR_OPENGL_VERSION_2_0 1 +#define CR_OPENGL_VERSION_2_1 1 + +/* Version (string) of OpenGL functionality supported by Chromium */ +#ifdef CR_OPENGL_VERSION_2_1 +# define CR_OPENGL_VERSION_STRING "2.1" +#elif defined(CR_OPENGL_VERSION_2_0) +# define CR_OPENGL_VERSION_STRING "2.0" +#else +# define CR_OPENGL_VERSION_STRING "1.5" +#endif + + +/* These define the OpenGL extensions that Chromium supports. + * Users can enable/disable support for particular OpenGL extensions here. + * Again, use OpenGL's convention. + * WARNING: if you add new extensions here, also update this file: + * state_tracker/state_limits.c + */ + +/*#define CR_ARB_imaging 1 not yet */ +#define CR_ARB_depth_texture 1 +#define CR_ARB_fragment_program 1 +#define CR_ARB_multitexture 1 +#define CR_ARB_multisample 1 +#define CR_ARB_occlusion_query 1 +#define CR_ARB_point_parameters 1 +#define CR_ARB_point_sprite 1 +#define CR_ARB_shadow 1 +#define CR_ARB_shadow_ambient 1 +#define CR_ARB_texture_border_clamp 1 +#define CR_ARB_texture_compression 1 +#define CR_ARB_texture_cube_map 1 +#define CR_ARB_texture_env_add 1 +#define CR_ARB_texture_env_combine 1 +#define CR_ARB_texture_env_crossbar 1 +#define CR_ARB_texture_env_dot3 1 +#define CR_ARB_texture_mirrored_repeat 1 +#define CR_ATI_texture_mirror_once 1 +#define CR_ARB_texture_non_power_of_two 1 +#define CR_ARB_transpose_matrix 1 +#define CR_ARB_vertex_buffer_object 1 +#define CR_ARB_vertex_program 1 +#define CR_ARB_window_pos 1 + +#define CR_EXT_blend_color 1 +#define CR_EXT_blend_equation 1 +#define CR_EXT_blend_minmax 1 +#define CR_EXT_blend_logic_op 1 +#define CR_EXT_blend_subtract 1 +#define CR_EXT_blend_func_separate 1 +#define CR_EXT_clip_volume_hint 1 +#define CR_EXT_fog_coord 1 +#define CR_EXT_multi_draw_arrays 1 +#define CR_EXT_shadow_funcs 1 +#define CR_EXT_secondary_color 1 +#ifndef CR_OPENGL_VERSION_1_2 +#define CR_EXT_separate_specular_color 1 +#endif +#define CR_EXT_stencil_wrap 1 +#define CR_EXT_texture_cube_map 1 +#define CR_EXT_texture_edge_clamp 1 +#define CR_EXT_texture_env_add 1 +#define CR_EXT_texture_filter_anisotropic 1 +#define CR_EXT_texture_lod_bias 1 +#define CR_EXT_texture_object 1 +#define CR_EXT_texture3D 1 + +#define CR_IBM_rasterpos_clip 1 + +#define CR_NV_fog_distance 1 +#define CR_NV_register_combiners 1 +#define CR_NV_register_combiners2 1 +#define CR_NV_texgen_reflection 1 +#define CR_NV_texture_rectangle 1 +#define CR_NV_vertex_program 1 +#define CR_NV_vertex_program1_1 1 +#define CR_NV_vertex_program2 1 +#define CR_NV_vertex_program2_option 1 +#define CR_NV_vertex_program3 1 +#define CR_NV_fragment_program 1 +#define CR_NV_fragment_program_option 1 +#define CR_NV_fragment_program2 1 + +#define CR_SGIS_texture_border_clamp 1 +#define CR_SGIS_texture_edge_clamp 1 +#define CR_SGIS_generate_mipmap 1 + +#define CR_EXT_texture_from_pixmap 1 +#define CR_EXT_draw_range_elements 1 +#define CR_EXT_texture_compression_s3tc 1 + +#define CR_ARB_shader_objects 1 +#define CR_ARB_vertex_shader 1 +#define CR_ARB_fragment_shader 1 +#define CR_ARB_shading_language_100 1 + +#define CR_EXT_framebuffer_object 1 +#define CR_EXT_compiled_vertex_array 1 + +#define CR_ARB_pixel_buffer_object 1 +#define CR_EXT_texture_sRGB 1 + +#define CR_EXT_framebuffer_blit 1 +#define CR_EXT_blend_equation_separate 1 +#define CR_EXT_stencil_two_side 1 + +#define CR_GREMEDY_string_marker 1 + +#define CR_ARB_texture_float 1 +#define CR_ARB_draw_buffers 1 + +#define CR_ARB_shader_texture_lod 1 + +#endif /* CR_VERSION_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/cr_vreg.h b/src/VBox/GuestHost/OpenGL/include/cr_vreg.h new file mode 100644 index 00000000..46a0d59f --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_vreg.h @@ -0,0 +1,411 @@ +/* $Id: cr_vreg.h $ */ +/** @file + * Visible Regions processing API + */ + +/* + * Copyright (C) 2012-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#ifndef ___cr_vreg_h_ +#define ___cr_vreg_h_ + +#include +#include +#include +#include +#include +#include +#include + +#ifndef IN_RING0 +# define VBOXVREGDECL(_type) DECLEXPORT(_type) +#else +/** @todo r=bird: Using RTDECL is just SOO wrong! */ +# define VBOXVREGDECL(_type) RTDECL(_type) +#endif + + + +RT_C_DECLS_BEGIN + +typedef struct VBOXVR_LIST +{ + RTLISTANCHOR ListHead; + uint32_t cEntries; +} VBOXVR_LIST; +typedef VBOXVR_LIST *PVBOXVR_LIST; +typedef VBOXVR_LIST const *PCVBOXVR_LIST; + +DECLINLINE(int) VBoxRectCmp(PCRTRECT pRect1, PCRTRECT pRect2) +{ + return memcmp(pRect1, pRect2, sizeof(*pRect1)); +} + +#ifndef IN_RING0 +# define CR_FLOAT_RCAST(_t, _v) ((_t)((float)(_v) + 0.5)) + +DECLINLINE(void) VBoxRectScale(PRTRECT pRect, float xScale, float yScale) +{ + pRect->xLeft = CR_FLOAT_RCAST(int32_t, pRect->xLeft * xScale); + pRect->yTop = CR_FLOAT_RCAST(int32_t, pRect->yTop * yScale); + pRect->xRight = CR_FLOAT_RCAST(int32_t, pRect->xRight * xScale); + pRect->yBottom = CR_FLOAT_RCAST(int32_t, pRect->yBottom * yScale); +} + +DECLINLINE(void) VBoxRectScaled(PCRTRECT pRect, float xScale, float yScale, PRTRECT pResult) +{ + *pResult = *pRect; + VBoxRectScale(pResult, xScale, yScale); +} + +DECLINLINE(void) VBoxRectUnscale(PRTRECT pRect, float xScale, float yScale) +{ + pRect->xLeft = CR_FLOAT_RCAST(int32_t, pRect->xLeft / xScale); + pRect->yTop = CR_FLOAT_RCAST(int32_t, pRect->yTop / yScale); + pRect->xRight = CR_FLOAT_RCAST(int32_t, pRect->xRight / xScale); + pRect->yBottom = CR_FLOAT_RCAST(int32_t, pRect->yBottom / yScale); +} + +DECLINLINE(void) VBoxRectUnscaled(PCRTRECT pRect, float xScale, float yScale, PRTRECT pResult) +{ + *pResult = *pRect; + VBoxRectUnscale(pResult, xScale, yScale); +} + +#endif /* IN_RING0 */ + +DECLINLINE(void) VBoxRectIntersect(PRTRECT pRect1, PCRTRECT pRect2) +{ + Assert(pRect1); + Assert(pRect2); + pRect1->xLeft = RT_MAX(pRect1->xLeft, pRect2->xLeft); + pRect1->yTop = RT_MAX(pRect1->yTop, pRect2->yTop); + pRect1->xRight = RT_MIN(pRect1->xRight, pRect2->xRight); + pRect1->yBottom = RT_MIN(pRect1->yBottom, pRect2->yBottom); + /* ensure the rect is valid */ + pRect1->xRight = RT_MAX(pRect1->xRight, pRect1->xLeft); + pRect1->yBottom = RT_MAX(pRect1->yBottom, pRect1->yTop); +} + +DECLINLINE(void) VBoxRectIntersected(PCRTRECT pRect1, PCRTRECT pRect2, PRTRECT pResult) +{ + *pResult = *pRect1; + VBoxRectIntersect(pResult, pRect2); +} + + +DECLINLINE(void) VBoxRectTranslate(PRTRECT pRect, int32_t x, int32_t y) +{ + pRect->xLeft += x; + pRect->yTop += y; + pRect->xRight += x; + pRect->yBottom += y; +} + +DECLINLINE(void) VBoxRectTranslated(PCRTRECT pRect, int32_t x, int32_t y, PRTRECT pResult) +{ + *pResult = *pRect; + VBoxRectTranslate(pResult, x, y); +} + +DECLINLINE(void) VBoxRectInvertY(PRTRECT pRect) +{ + int32_t y = pRect->yTop; + pRect->yTop = pRect->yBottom; + pRect->yBottom = y; +} + +DECLINLINE(void) VBoxRectInvertedY(PCRTRECT pRect, PRTRECT pResult) +{ + *pResult = *pRect; + VBoxRectInvertY(pResult); +} + +DECLINLINE(void) VBoxRectMove(PRTRECT pRect, int32_t x, int32_t y) +{ + int32_t cx = pRect->xRight - pRect->xLeft; + int32_t cy = pRect->yBottom - pRect->yTop; + pRect->xLeft = x; + pRect->yTop = y; + pRect->xRight = cx + x; + pRect->yBottom = cy + y; +} + +DECLINLINE(void) VBoxRectMoved(PCRTRECT pRect, int32_t x, int32_t y, PRTRECT pResult) +{ + *pResult = *pRect; + VBoxRectMove(pResult, x, y); +} + +DECLINLINE(bool) VBoxRectCovers(PCRTRECT pRect, PCRTRECT pCovered) +{ + AssertPtr(pRect); + AssertPtr(pCovered); + if (pRect->xLeft > pCovered->xLeft) + return false; + if (pRect->yTop > pCovered->yTop) + return false; + if (pRect->xRight < pCovered->xRight) + return false; + if (pRect->yBottom < pCovered->yBottom) + return false; + return true; +} + +DECLINLINE(bool) VBoxRectIsZero(PCRTRECT pRect) +{ + return pRect->xLeft == pRect->xRight || pRect->yTop == pRect->yBottom; +} + +DECLINLINE(bool) VBoxRectIsIntersect(PCRTRECT pRect1, PCRTRECT pRect2) +{ + return !( (pRect1->xLeft < pRect2->xLeft && pRect1->xRight <= pRect2->xLeft) + || (pRect2->xLeft < pRect1->xLeft && pRect2->xRight <= pRect1->xLeft) + || (pRect1->yTop < pRect2->yTop && pRect1->yBottom <= pRect2->yTop) + || (pRect2->yTop < pRect1->yTop && pRect2->yBottom <= pRect1->yTop) ); +} + +DECLINLINE(uint32_t) VBoxVrListRectsCount(PCVBOXVR_LIST pList) +{ + return pList->cEntries; +} + +DECLINLINE(bool) VBoxVrListIsEmpty(PCVBOXVR_LIST pList) +{ + return !VBoxVrListRectsCount(pList); +} + +DECLINLINE(void) VBoxVrListInit(PVBOXVR_LIST pList) +{ + RTListInit(&pList->ListHead); + pList->cEntries = 0; +} + +VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList); + +/* moves list data to pDstList and empties the pList */ +VBOXVREGDECL(void) VBoxVrListMoveTo(PVBOXVR_LIST pList, PVBOXVR_LIST pDstList); + +VBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y); + +VBOXVREGDECL(int) VBoxVrListCmp(PCVBOXVR_LIST pList1, PCVBOXVR_LIST pList2); + +VBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT paRects, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT paRects, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT paRects, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrListRectsGet(PVBOXVR_LIST pList, uint32_t cRects, PRTRECT paRects); + +VBOXVREGDECL(int) VBoxVrListClone(PCVBOXVR_LIST pList, VBOXVR_LIST *pDstList); + +/* NOTE: with the current implementation the VBoxVrListIntersect is faster than VBoxVrListRectsIntersect, + * i.e. VBoxVrListRectsIntersect is actually a convenience function that create a temporary list and calls + * VBoxVrListIntersect internally. */ +VBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT paRects, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, PCVBOXVR_LIST pList2, bool *pfChanged); + +VBOXVREGDECL(int) VBoxVrInit(void); +VBOXVREGDECL(void) VBoxVrTerm(void); + +typedef struct VBOXVR_LIST_ITERATOR +{ + PVBOXVR_LIST pList; + PRTLISTNODE pNextEntry; +} VBOXVR_LIST_ITERATOR; +typedef VBOXVR_LIST_ITERATOR *PVBOXVR_LIST_ITERATOR; +typedef VBOXVR_LIST_ITERATOR const *PCVBOXVR_LIST_ITERATOR; + +DECLINLINE(void) VBoxVrListIterInit(PVBOXVR_LIST pList, PVBOXVR_LIST_ITERATOR pIter) +{ + pIter->pList = pList; + pIter->pNextEntry = pList->ListHead.pNext; +} + +typedef struct VBOXVR_REG +{ + RTLISTNODE ListEntry; + RTRECT Rect; +} VBOXVR_REG; +typedef VBOXVR_REG *PVBOXVR_REG; +typedef VBOXVR_REG const *PCVBOXVR_REG; + +#define PVBOXVR_REG_FROM_ENTRY(_pEntry) RT_FROM_MEMBER(_pEntry, VBOXVR_REG, ListEntry) + +DECLINLINE(PCRTRECT) VBoxVrListIterNext(PVBOXVR_LIST_ITERATOR pIter) +{ + PRTLISTNODE pNextEntry = pIter->pNextEntry; + if (pNextEntry != &pIter->pList->ListHead) + { + PCRTRECT pRect = &PVBOXVR_REG_FROM_ENTRY(pNextEntry)->Rect; + pIter->pNextEntry = pNextEntry->pNext; + return pRect; + } + return NULL; +} + +typedef struct VBOXVR_COMPOSITOR_ENTRY +{ + RTLISTNODE Node; + VBOXVR_LIST Vr; + uint32_t cRefs; +} VBOXVR_COMPOSITOR_ENTRY; +typedef VBOXVR_COMPOSITOR_ENTRY *PVBOXVR_COMPOSITOR_ENTRY; +typedef VBOXVR_COMPOSITOR_ENTRY const *PCVBOXVR_COMPOSITOR_ENTRY; + +struct VBOXVR_COMPOSITOR; + +typedef DECLCALLBACK(void) FNVBOXVRCOMPOSITOR_ENTRY_RELEASED(const struct VBOXVR_COMPOSITOR *pCompositor, + PVBOXVR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry); +typedef FNVBOXVRCOMPOSITOR_ENTRY_RELEASED *PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED; + +typedef struct VBOXVR_COMPOSITOR +{ + RTLISTANCHOR List; + PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased; +} VBOXVR_COMPOSITOR; +typedef VBOXVR_COMPOSITOR *PVBOXVR_COMPOSITOR; +typedef VBOXVR_COMPOSITOR const *PCVBOXVR_COMPOSITOR; + +typedef DECLCALLBACK(bool) FNVBOXVRCOMPOSITOR_VISITOR(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + void *pvVisitor); +typedef FNVBOXVRCOMPOSITOR_VISITOR *PFNVBOXVRCOMPOSITOR_VISITOR; + +VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased); +VBOXVREGDECL(void) VBoxVrCompositorClear(PVBOXVR_COMPOSITOR pCompositor); +VBOXVREGDECL(void) VBoxVrCompositorRegionsClear(PVBOXVR_COMPOSITOR pCompositor, bool *pfChanged); +VBOXVREGDECL(void) VBoxVrCompositorEntryInit(PVBOXVR_COMPOSITOR_ENTRY pEntry); + +DECLINLINE(bool) VBoxVrCompositorEntryIsInList(PCVBOXVR_COMPOSITOR_ENTRY pEntry) +{ + return !VBoxVrListIsEmpty(&pEntry->Vr); +} + +#define CRBLT_F_LINEAR 0x00000001 +#define CRBLT_F_INVERT_SRC_YCOORDS 0x00000002 +#define CRBLT_F_INVERT_DST_YCOORDS 0x00000004 +#define CRBLT_F_INVERT_YCOORDS (CRBLT_F_INVERT_SRC_YCOORDS | CRBLT_F_INVERT_DST_YCOORDS) +/* the blit operation with discard the source alpha channel values and set the destination alpha values to 1.0 */ +#define CRBLT_F_NOALPHA 0x00000010 + +#define CRBLT_FTYPE_XOR CRBLT_F_INVERT_YCOORDS +#define CRBLT_FTYPE_OR (CRBLT_F_LINEAR | CRBLT_F_NOALPHA) +#define CRBLT_FOP_COMBINE(_f1, _f2) ((((_f1) ^ (_f2)) & CRBLT_FTYPE_XOR) | (((_f1) | (_f2)) & CRBLT_FTYPE_OR)) + +#define CRBLT_FLAGS_FROM_FILTER(_f) ( ((_f) & GL_LINEAR) ? CRBLT_F_LINEAR : 0) +#define CRBLT_FILTER_FROM_FLAGS(_f) (((_f) & CRBLT_F_LINEAR) ? GL_LINEAR : GL_NEAREST) + +/* compositor regions changed */ +#define VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED 0x00000001 +/* other entries changed along while doing current entry modification + * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */ +#define VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED 0x00000002 +/* only current entry regions changed + * can come wither with VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED or with VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED */ +#define VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED 0x00000004 +/* the given entry has replaced some other entry, while overal regions did NOT change. + * always comes with VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED */ +#define VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED 0x00000008 + + +VBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry); +VBOXVREGDECL(bool) VBoxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_COMPOSITOR_ENTRY pNewEntry); +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, + PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, uint32_t *pfChangeFlags); +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + PCVBOXVR_LIST pList2, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, PCRTRECT paRegions, + bool *pfChanged); +VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2, bool *pfChanged); +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + int32_t x, int32_t y, bool *pfChanged); +VBOXVREGDECL(void) VBoxVrCompositorVisit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor); + +DECLINLINE(bool) VBoxVrCompositorIsEmpty(PCVBOXVR_COMPOSITOR pCompositor) +{ + return RTListIsEmpty(&pCompositor->List); +} + +typedef struct VBOXVR_COMPOSITOR_ITERATOR +{ + PVBOXVR_COMPOSITOR pCompositor; + PRTLISTNODE pNextEntry; +} VBOXVR_COMPOSITOR_ITERATOR; +typedef VBOXVR_COMPOSITOR_ITERATOR *PVBOXVR_COMPOSITOR_ITERATOR; + +typedef struct VBOXVR_COMPOSITOR_CONST_ITERATOR +{ + PCVBOXVR_COMPOSITOR pCompositor; + PCRTLISTNODE pNextEntry; +} VBOXVR_COMPOSITOR_CONST_ITERATOR; +typedef VBOXVR_COMPOSITOR_CONST_ITERATOR *PVBOXVR_COMPOSITOR_CONST_ITERATOR; + +DECLINLINE(void) VBoxVrCompositorIterInit(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ITERATOR pIter) +{ + pIter->pCompositor = pCompositor; + pIter->pNextEntry = pCompositor->List.pNext; +} + +DECLINLINE(void) VBoxVrCompositorConstIterInit(PCVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter) +{ + pIter->pCompositor = pCompositor; + pIter->pNextEntry = pCompositor->List.pNext; +} + +#define VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(_p) RT_FROM_MEMBER(_p, VBOXVR_COMPOSITOR_ENTRY, Node) +#define VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(_p) RT_FROM_MEMBER(_p, const VBOXVR_COMPOSITOR_ENTRY, Node) + +DECLINLINE(PVBOXVR_COMPOSITOR_ENTRY) VBoxVrCompositorIterNext(PVBOXVR_COMPOSITOR_ITERATOR pIter) +{ + PRTLISTNODE pNextEntry = pIter->pNextEntry; + if (pNextEntry != &pIter->pCompositor->List) + { + PVBOXVR_COMPOSITOR_ENTRY pEntry = VBOXVR_COMPOSITOR_ENTRY_FROM_NODE(pNextEntry); + pIter->pNextEntry = pNextEntry->pNext; + return pEntry; + } + return NULL; +} + +DECLINLINE(PCVBOXVR_COMPOSITOR_ENTRY) VBoxVrCompositorConstIterNext(PVBOXVR_COMPOSITOR_CONST_ITERATOR pIter) +{ + PCRTLISTNODE pNextEntry = pIter->pNextEntry; + if (pNextEntry != &pIter->pCompositor->List) + { + PCVBOXVR_COMPOSITOR_ENTRY pEntry = VBOXVR_COMPOSITOR_CONST_ENTRY_FROM_NODE(pNextEntry); + pIter->pNextEntry = pNextEntry->pNext; + return pEntry; + } + return NULL; +} + +typedef struct VBOXVR_TEXTURE +{ + int32_t width; + int32_t height; + uint32_t target; + uint32_t hwid; +} VBOXVR_TEXTURE; +typedef VBOXVR_TEXTURE *PVBOXVR_TEXTURE; +typedef VBOXVR_TEXTURE const *PCVBOXVR_TEXTURE; + +RT_C_DECLS_END + +#endif + diff --git a/src/VBox/GuestHost/OpenGL/include/cr_warp.h b/src/VBox/GuestHost/OpenGL/include/cr_warp.h new file mode 100644 index 00000000..1048a851 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/cr_warp.h @@ -0,0 +1,22 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_WARP_H +#define CR_WARP_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +DECLEXPORT(void) crWarpPoint(const float *align, const float *point, float *result); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_BBOX_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/crut_api.h b/src/VBox/GuestHost/OpenGL/include/crut_api.h new file mode 100644 index 00000000..67f80756 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/crut_api.h @@ -0,0 +1,211 @@ +#ifndef CRUTAPI_H +#define CRUTAPI_H + +#ifdef WINDOWS +#define CRUT_APIENTRY __stdcall +#else +#define CRUT_APIENTRY +#endif + +#include "cr_net.h" +#include "cr_protocol.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* Compile-time version tests */ +#define CRUT_MAJOR_VERSION 1 +#define CRUT_MINOR_VERSION 9 +#define CRUT_PATCH_VERSION 0 + +/* Display mode bit masks. */ +#define CRUT_RGB 0 +#define CRUT_RGBA GLUT_RGB +#define CRUT_INDEX 1 +#define CRUT_SINGLE 0 +#define CRUT_DOUBLE 2 +#define CRUT_ACCUM 4 +#define CRUT_ALPHA 8 +#define CRUT_DEPTH 16 +#define CRUT_STENCIL 32 + +/* Mouse buttons. */ +/* CRUT_NO_BUTTON provided for menu definition. Not every menu will + have a button associated with it. */ +#define CRUT_NO_BUTTON -1 +#define CRUT_LEFT_BUTTON 0 +#define CRUT_MIDDLE_BUTTON 1 +#define CRUT_RIGHT_BUTTON 2 + +/* Mouse button state. */ +#define CRUT_DOWN 0 +#define CRUT_UP 1 + +/* Visibility state. */ +#define CRUT_NOT_VISIBLE 0 +#define CRUT_VISIBLE 1 + +/* function keys */ +#define CRUT_KEY_F1 1 +#define CRUT_KEY_F2 2 +#define CRUT_KEY_F3 3 +#define CRUT_KEY_F4 4 +#define CRUT_KEY_F5 5 +#define CRUT_KEY_F6 6 +#define CRUT_KEY_F7 7 +#define CRUT_KEY_F8 8 +#define CRUT_KEY_F9 9 +#define CRUT_KEY_F10 10 +#define CRUT_KEY_F11 11 +#define CRUT_KEY_F12 12 +/* directional keys */ +#define CRUT_KEY_LEFT 100 +#define CRUT_KEY_UP 101 +#define CRUT_KEY_RIGHT 102 +#define CRUT_KEY_DOWN 103 +#define CRUT_KEY_PAGE_UP 104 +#define CRUT_KEY_PAGE_DOWN 105 +#define CRUT_KEY_HOME 106 +#define CRUT_KEY_END 107 +#define CRUT_KEY_INSERT 108 + +/* event types */ +#define CRUT_NO_EVENT 0 +#define CRUT_MOUSE_EVENT 1 +#define CRUT_RESHAPE_EVENT 2 +#define CRUT_KEYBOARD_EVENT 3 +#define CRUT_MOTION_EVENT 4 +#define CRUT_PASSIVE_MOTION_EVENT 5 +#define CRUT_MENU_EVENT 6 +#define CRUT_VISIBILITY_EVENT 7 + +#define DEFAULT_CRUT_PORT 9000 + +#define MENU_MAX_SIZE 1024 +#define MENU_ITEM_REGULAR 0 +#define MENU_ITEM_SUBMENU 1 + +/* CRUTMessage is just a placeholder to find the msg_type */ +typedef struct +{ + CRMessageHeader header; + int msg_type; + +} CRUTMessage; + +typedef struct +{ + CRMessageHeader header; + int msg_type; + int button; + int state; + int x; + int y; + +} CRUTMouseMsg; + +typedef struct +{ + CRMessageHeader header; + int msg_type; + int width; + int height; + +} CRUTReshapeMsg; + +typedef struct +{ + CRMessageHeader header; + int msg_type; + int state; + +} CRUTVisibilityMsg; + +typedef struct +{ + CRMessageHeader header; + int msg_type; + unsigned char key; + int x; + int y; + +} CRUTKeyboardMsg; + +typedef struct +{ + CRMessageHeader header; + int msg_type; + int x; + int y; + +} CRUTMotionMsg; + +typedef struct +{ + CRMessageHeader header; + int msg_type; + int x; + int y; + +} CRUTPassiveMotionMsg; + +typedef struct +{ + CRMessageHeader header; + int msg_type; + int menuID; + int value; + +} CRUTMenuMsg; + +typedef struct +{ + unsigned short tcpip_port; + int mtu; + char protocol[1024]; + CRConnection *send_conn; + +} CRUTClientPointer; + +typedef struct +{ + CRUTClientPointer *crutclients; + CRConnection *mothershipConn; + int numclients; + int winX; + int winY; + int winWidth; + int winHeight; + + int compositeAlpha; + int compositeDepth; + + char menuBuffer[MENU_MAX_SIZE]; + +} CRUTAPI; + +#define MAX_MSG_SIZE sizeof(CRUTMouseMsg) + + +/* extern CRUTAPI crut_api;*/ + +void CRUT_APIENTRY crutInitAPI( CRUTAPI *crut_api, const char *mothership ); +void CRUT_APIENTRY crutGetWindowParams( CRUTAPI *crut_api ); +void CRUT_APIENTRY crutGetMenuXML( CRUTAPI *crut_api ); +void CRUT_APIENTRY crutSetWindowID( CRUTAPI *crut_api, int windowID ); +void CRUT_APIENTRY crutConnectToClients( CRUTAPI *crut_api ); +void crutSendEvent( CRUTAPI *crut_api, void *msg, int size ); +void CRUT_APIENTRY crutSendMouseEvent( CRUTAPI *crut_api, int button, int state, int x, int y ); +void CRUT_APIENTRY crutSendKeyboardEvent( CRUTAPI *crut_api, int key, int x, int y ); +void CRUT_APIENTRY crutSendReshapeEvent( CRUTAPI *crut_api, int width, int height ); +void CRUT_APIENTRY crutSendVisibilityEvent( CRUTAPI *crut_api, int state ); +void CRUT_APIENTRY crutSendMotionEvent( CRUTAPI *crut_api, int x, int y ); +void CRUT_APIENTRY crutSendPassiveMotionEvent( CRUTAPI *crut_api, int x, int y ); +void CRUT_APIENTRY crutSendMenuEvent( CRUTAPI *crut_api, int menuID, int value ); + +#ifdef __cplusplus +} +#endif + +#endif /* CRUTAPI_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/crut_clientapi.h b/src/VBox/GuestHost/OpenGL/include/crut_clientapi.h new file mode 100644 index 00000000..570c2be7 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/crut_clientapi.h @@ -0,0 +1,45 @@ +#ifndef CRUT_CLIENTAPI_H +#define CRUT_CLEINTAPI_H + +#ifdef WINDOWS +#define CRUT_CLIENT_APIENTRY __stdcall +#else +#define CRUT_CLIENT_APIENTRY +#endif + +#include "chromium.h" +#include "crut_api.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void CRUT_CLIENT_APIENTRY crutInitClient(void); +void CRUT_CLIENT_APIENTRY crutReceiveEventType(int type); +void CRUT_CLIENT_APIENTRY crutMouseFunc( void (*func)(int button, int state, int x, int y) ); +void CRUT_CLIENT_APIENTRY crutKeyboardFunc( void (*func) (unsigned char key, int x, int y) ); +void CRUT_CLIENT_APIENTRY crutReshapeFunc( void (*func) (int width, int height) ); +void CRUT_CLIENT_APIENTRY crutVisibilityFunc( void (*func) (int state) ); +void CRUT_CLIENT_APIENTRY crutMotionFunc( void (*func) (int x, int y) ); +void CRUT_CLIENT_APIENTRY crutPassiveMotionFunc( void (*func) (int x, int y) ); +void CRUT_CLIENT_APIENTRY crutIdleFunc( void (*func)(void)); +void CRUT_CLIENT_APIENTRY crutDisplayFunc(void (*func)(void)); +void CRUT_CLIENT_APIENTRY crutPostRedisplay(void); +void CRUT_CLIENT_APIENTRY crutMainLoop(void); +int CRUT_CLIENT_APIENTRY crutCreateContext ( unsigned int visual ); +int CRUT_CLIENT_APIENTRY crutCreateWindow ( unsigned int visual ); +void CRUT_CLIENT_APIENTRY crutMakeCurrent( int window, int context ); +void CRUT_CLIENT_APIENTRY crutSwapBuffers( int window, int flags ); +void CRUT_CLIENT_APIENTRY crutReceiveEvent(CRUTMessage **msg); +int CRUT_CLIENT_APIENTRY crutCheckEvent( void ); +int CRUT_CLIENT_APIENTRY crutPeekNextEvent( void ); +int CRUT_CLIENT_APIENTRY crutCreateMenu( void (*func) (int val) ); +void CRUT_CLIENT_APIENTRY crutAddMenuEntry( char* name, int value ); +void CRUT_CLIENT_APIENTRY crutAddSubMenu( char* name, int menuID ); +void CRUT_CLIENT_APIENTRY crutAttachMenu( int button ); + +#ifdef __cplusplus +} +#endif + +#endif /* CRUT_CLIENTAPI_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h b/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h new file mode 100644 index 00000000..579e71dd --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_attrib.h @@ -0,0 +1,405 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_ATTRIB_H +#define CR_STATE_ATTRIB_H + +#include "state/cr_limits.h" +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CRAttribBits; + +typedef struct { + GLcolorf accumClearValue; +} CRAccumBufferStack; + +typedef struct { + GLboolean blend; + GLboolean alphaTest; + GLboolean logicOp; + GLboolean indexLogicOp; + GLboolean dither; + + GLenum alphaTestFunc; + GLfloat alphaTestRef; + GLenum blendSrcRGB; + GLenum blendDstRGB; + GLenum blendSrcA; + GLenum blendDstA; + GLcolorf blendColor; + GLenum blendEquation; + GLenum logicOpMode; + GLenum drawBuffer; + GLint indexWriteMask; + GLcolorb colorWriteMask; + GLcolorf colorClearValue; + GLfloat indexClearValue; +} CRColorBufferStack; + +typedef struct { + GLboolean rasterValid; + GLfloat attrib[CR_MAX_VERTEX_ATTRIBS][4]; + GLfloat rasterAttrib[CR_MAX_VERTEX_ATTRIBS][4]; + GLboolean edgeFlag; + GLfloat colorIndex; +} CRCurrentStack; + +typedef struct { + GLboolean depthTest; + GLboolean depthMask; + GLenum depthFunc; + GLdefault depthClearValue; +} CRDepthBufferStack; + +typedef struct { + GLboolean alphaTest; + GLboolean autoNormal; + GLboolean blend; + GLboolean *clip; + GLboolean colorMaterial; + GLboolean cullFace; + GLboolean depthTest; + GLboolean dither; + GLboolean fog; + GLboolean *light; + GLboolean lighting; + GLboolean lineSmooth; + GLboolean lineStipple; + GLboolean logicOp; + GLboolean indexLogicOp; + GLboolean map1[GLEVAL_TOT]; + GLboolean map2[GLEVAL_TOT]; + GLboolean normalize; + GLboolean pointSmooth; +#ifdef CR_ARB_point_sprite + GLboolean pointSprite; + GLboolean coordReplacement[CR_MAX_TEXTURE_UNITS]; +#endif + GLboolean polygonOffsetLine; + GLboolean polygonOffsetFill; + GLboolean polygonOffsetPoint; + GLboolean polygonSmooth; + GLboolean polygonStipple; +#ifdef CR_OPENGL_VERSION_1_2 + GLboolean rescaleNormals; +#endif + GLboolean scissorTest; + GLboolean stencilTest; + GLboolean texture1D[CR_MAX_TEXTURE_UNITS]; + GLboolean texture2D[CR_MAX_TEXTURE_UNITS]; + GLboolean texture3D[CR_MAX_TEXTURE_UNITS]; +#ifdef CR_ARB_texture_cube_map + GLboolean textureCubeMap[CR_MAX_TEXTURE_UNITS]; +#endif +#ifdef CR_NV_texture_rectangle + GLboolean textureRect[CR_MAX_TEXTURE_UNITS]; +#endif + GLboolean textureGenS[CR_MAX_TEXTURE_UNITS]; + GLboolean textureGenT[CR_MAX_TEXTURE_UNITS]; + GLboolean textureGenR[CR_MAX_TEXTURE_UNITS]; + GLboolean textureGenQ[CR_MAX_TEXTURE_UNITS]; +} CREnableStack; + +typedef struct { + GLboolean enable1D[GLEVAL_TOT]; + GLboolean enable2D[GLEVAL_TOT]; + GLboolean autoNormal; + CREvaluator1D eval1D[GLEVAL_TOT]; + CREvaluator2D eval2D[GLEVAL_TOT]; + GLint un1D; + GLfloat u11D, u21D; + GLint un2D; + GLint vn2D; + GLfloat u12D, u22D; + GLfloat v12D, v22D; +} CREvalStack; + +typedef struct { + GLboolean lighting; + GLboolean colorMaterial; + GLenum shadeModel; + GLenum colorMaterialMode; + GLenum colorMaterialFace; + GLcolorf ambient[2]; + GLcolorf diffuse[2]; + GLcolorf specular[2]; + GLcolorf emission[2]; + GLfloat shininess[2]; + GLint indexes[2][3]; + GLcolorf lightModelAmbient; + GLboolean lightModelLocalViewer; + GLboolean lightModelTwoSide; +#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2) + GLenum lightModelColorControlEXT; +#endif + CRLight *light; +} CRLightingStack; + +typedef struct { + GLcolorf color; + GLint index; + GLfloat density; + GLfloat start; + GLfloat end; + GLint mode; + GLboolean enable; +} CRFogStack; + +typedef struct { + GLenum perspectiveCorrection; + GLenum pointSmooth; + GLenum lineSmooth; + GLenum polygonSmooth; + GLenum fog; +#ifdef CR_EXT_clip_volume_hint + GLenum clipVolumeClipping; +#endif +#ifdef CR_ARB_texture_compression + GLenum textureCompression; +#endif +#ifdef CR_SGIS_generate_mipmap + GLenum generateMipmap; +#endif +} CRHintStack; + +typedef struct { + GLboolean lineSmooth; + GLboolean lineStipple; + GLfloat width; + GLushort pattern; + GLint repeat; +} CRLineStack; + +typedef struct { + GLuint base; +} CRListStack; + +typedef struct { + GLboolean mapColor; + GLboolean mapStencil; + GLint indexShift; + GLint indexOffset; + GLcolorf scale; + GLfloat depthScale; + GLcolorf bias; + GLfloat depthBias; + GLfloat xZoom; + GLfloat yZoom; + GLenum readBuffer; +} CRPixelModeStack; + +typedef struct { + GLboolean pointSmooth; + GLfloat pointSize; +#if CR_ARB_point_sprite + GLboolean pointSprite; + GLboolean coordReplacement[CR_MAX_TEXTURE_UNITS]; +#endif +} CRPointStack; + +typedef struct { + GLboolean polygonSmooth; + GLboolean polygonOffsetFill; + GLboolean polygonOffsetLine; + GLboolean polygonOffsetPoint; + GLboolean polygonStipple; + GLboolean cullFace; + GLfloat offsetFactor; + GLfloat offsetUnits; + GLenum cullFaceMode; + GLenum frontFace; + GLenum frontMode; + GLenum backMode; +} CRPolygonStack; + +typedef struct { + GLint pattern[32]; +} CRPolygonStippleStack; + +typedef struct { + GLboolean scissorTest; + GLint scissorX; + GLint scissorY; + GLsizei scissorW; + GLsizei scissorH; +} CRScissorStack; + +typedef struct { + GLboolean stencilTest; + GLenum func; + GLint mask; + GLint ref; + GLenum fail; + GLenum passDepthFail; + GLenum passDepthPass; + GLint clearValue; + GLint writeMask; +} CRStencilBufferStack_v_33; + +typedef struct { + /* true if stencil test is enabled */ + GLboolean stencilTest; + /* true if GL_EXT_stencil_two_side is enabled (glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)) */ + GLboolean stencilTwoSideEXT; + /* GL_FRONT or GL_BACK */ + GLenum activeStencilFace; + GLint clearValue; + GLint writeMask; + CRStencilBufferState buffers[CRSTATE_STENCIL_BUFFER_COUNT]; +} CRStencilBufferStack; + +typedef struct { +#if 111 + GLuint curTextureUnit; + CRTextureUnit unit[CR_MAX_TEXTURE_UNITS]; + +#else + GLboolean enabled1D[CR_MAX_TEXTURE_UNITS]; + GLboolean enabled2D[CR_MAX_TEXTURE_UNITS]; + GLboolean enabled3D[CR_MAX_TEXTURE_UNITS]; +# ifdef CR_ARB_texture_cube_map + GLboolean enabledCubeMap[CR_MAX_TEXTURE_UNITS]; +# endif + CRTextureObj *current1D[CR_MAX_TEXTURE_UNITS]; + CRTextureObj *current2D[CR_MAX_TEXTURE_UNITS]; + CRTextureObj *current3D[CR_MAX_TEXTURE_UNITS]; +# ifdef CR_ARB_texture_cube_map + CRTextureObj *currentCubeMap[CR_MAX_TEXTURE_UNITS]; +# endif + GLcolorf borderColor[4]; /* 4 = 1D, 2D, 3D and cube map textures */ + GLenum minFilter[4]; + GLenum magFilter[4]; + GLenum wrapS[4]; + GLenum wrapT[4]; +# ifdef CR_OPENGL_VERSION_1_2 + GLenum wrapR[4]; + GLfloat priority[4]; + GLfloat minLod[4]; + GLfloat maxLod[4]; + GLint baseLevel[4]; + GLint maxLevel[4]; +# endif + + GLuint curTextureUnit; + GLenum envMode[CR_MAX_TEXTURE_UNITS]; + GLcolorf envColor[CR_MAX_TEXTURE_UNITS]; + + GLtexcoordb textureGen[CR_MAX_TEXTURE_UNITS]; + GLvectorf objSCoeff[CR_MAX_TEXTURE_UNITS]; + GLvectorf objTCoeff[CR_MAX_TEXTURE_UNITS]; + GLvectorf objRCoeff[CR_MAX_TEXTURE_UNITS]; + GLvectorf objQCoeff[CR_MAX_TEXTURE_UNITS]; + GLvectorf eyeSCoeff[CR_MAX_TEXTURE_UNITS]; + GLvectorf eyeTCoeff[CR_MAX_TEXTURE_UNITS]; + GLvectorf eyeRCoeff[CR_MAX_TEXTURE_UNITS]; + GLvectorf eyeQCoeff[CR_MAX_TEXTURE_UNITS]; + GLtexcoorde gen[CR_MAX_TEXTURE_UNITS]; +#endif +} CRTextureStack; + +typedef struct { + GLenum matrixMode; + GLvectord *clipPlane; + GLboolean *clip; + GLboolean normalize; +#ifdef CR_OPENGL_VERSION_1_2 + GLboolean rescaleNormals; +#endif +} CRTransformStack; + +typedef struct { + GLint viewportX; + GLint viewportY; + GLint viewportW; + GLint viewportH; + GLclampd nearClip; + GLclampd farClip; +} CRViewportStack; + +typedef struct { + GLint attribStackDepth; + CRbitvalue pushMaskStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint accumBufferStackDepth; + CRAccumBufferStack accumBufferStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint colorBufferStackDepth; + CRColorBufferStack colorBufferStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint currentStackDepth; + CRCurrentStack currentStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint depthBufferStackDepth; + CRDepthBufferStack depthBufferStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint enableStackDepth; + CREnableStack enableStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint evalStackDepth; + CREvalStack evalStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint fogStackDepth; + CRFogStack fogStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint hintStackDepth; + CRHintStack hintStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint lightingStackDepth; + CRLightingStack lightingStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint lineStackDepth; + CRLineStack lineStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint listStackDepth; + CRListStack listStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint pixelModeStackDepth; + CRPixelModeStack pixelModeStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint pointStackDepth; + CRPointStack pointStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint polygonStackDepth; + CRPolygonStack polygonStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint polygonStippleStackDepth; + CRPolygonStippleStack polygonStippleStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint scissorStackDepth; + CRScissorStack scissorStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint stencilBufferStackDepth; + CRStencilBufferStack stencilBufferStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint textureStackDepth; + CRTextureStack textureStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint transformStackDepth; + CRTransformStack transformStack[CR_MAX_ATTRIB_STACK_DEPTH]; + + GLint viewportStackDepth; + CRViewportStack viewportStack[CR_MAX_ATTRIB_STACK_DEPTH]; +} CRAttribState; + +DECLEXPORT(void) crStateAttribInit(CRAttribState *a); + +/* No diff! */ +DECLEXPORT(void) crStateAttribSwitch(CRAttribBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_ATTRIB_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h b/src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h new file mode 100644 index 00000000..7a57aae9 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_buffer.h @@ -0,0 +1,95 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_BUFFER_H +#define CR_STATE_BUFFER_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue alphaFunc[CR_MAX_BITARRAY]; + CRbitvalue depthFunc[CR_MAX_BITARRAY]; + CRbitvalue blendFunc[CR_MAX_BITARRAY]; + CRbitvalue logicOp[CR_MAX_BITARRAY]; + CRbitvalue indexLogicOp[CR_MAX_BITARRAY]; + CRbitvalue drawBuffer[CR_MAX_BITARRAY]; + CRbitvalue readBuffer[CR_MAX_BITARRAY]; + CRbitvalue indexMask[CR_MAX_BITARRAY]; + CRbitvalue colorWriteMask[CR_MAX_BITARRAY]; + CRbitvalue clearColor[CR_MAX_BITARRAY]; + CRbitvalue clearIndex[CR_MAX_BITARRAY]; + CRbitvalue clearDepth[CR_MAX_BITARRAY]; + CRbitvalue clearAccum[CR_MAX_BITARRAY]; + CRbitvalue depthMask[CR_MAX_BITARRAY]; +#ifdef CR_EXT_blend_color + CRbitvalue blendColor[CR_MAX_BITARRAY]; +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) + CRbitvalue blendEquation[CR_MAX_BITARRAY]; +#endif +#if defined(CR_EXT_blend_func_separate) + CRbitvalue blendFuncSeparate[CR_MAX_BITARRAY]; +#endif +} CRBufferBits; + +typedef struct { + GLboolean depthTest; + GLboolean blend; + GLboolean alphaTest; + GLboolean logicOp; + GLboolean indexLogicOp; + GLboolean dither; + GLboolean depthMask; + + GLenum alphaTestFunc; + GLfloat alphaTestRef; + GLenum depthFunc; + GLenum blendSrcRGB; + GLenum blendDstRGB; + GLenum blendSrcA; + GLenum blendDstA; + GLenum logicOpMode; + GLenum drawBuffer; + GLenum readBuffer; + GLint indexWriteMask; + GLcolorb colorWriteMask; + GLcolorf colorClearValue; + GLfloat indexClearValue; + GLdefault depthClearValue; + GLcolorf accumClearValue; +#ifdef CR_EXT_blend_color + GLcolorf blendColor; +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) + GLenum blendEquation; +#endif + + GLint width, height; + GLint storedWidth, storedHeight; + GLvoid *pFrontImg; + GLvoid *pBackImg; +} CRBufferState; + +DECLEXPORT(void) crStateBufferInit(CRContext *ctx); + +DECLEXPORT(void) crStateBufferDiff(CRBufferBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateBufferSwitch(CRBufferBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_BUFFER_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h b/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h new file mode 100644 index 00000000..8584adc0 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_bufferobject.h @@ -0,0 +1,71 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_BUFFEROBJECT_H +#define CR_STATE_BUFFEROBJECT_H + +#include "cr_hash.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue arrayBinding[CR_MAX_BITARRAY]; + CRbitvalue elementsBinding[CR_MAX_BITARRAY]; + CRbitvalue packBinding[CR_MAX_BITARRAY]; + CRbitvalue unpackBinding[CR_MAX_BITARRAY]; +} CRBufferObjectBits; + + +/* + * Buffer object, like a texture object, but encapsulates arbitrary + * data (vertex, image, etc). + */ +typedef struct { + GLuint refCount; + GLuint id; + GLuint hwid; + GLenum usage; + GLenum access; + GLuint size; /* buffer size in bytes */ + GLvoid *pointer; /* only valid while buffer is mapped */ + GLvoid *data; /* the buffer data, if retainBufferData is true */ + GLboolean bResyncOnRead; /* buffer data could be changed on server side, + so we need to resync every time guest wants to read from it*/ + CRbitvalue dirty[CR_MAX_BITARRAY]; /* dirty data or state */ + GLintptrARB dirtyStart, dirtyLength; /* dirty region */ + /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */ + CRbitvalue ctxUsage[CR_MAX_BITARRAY]; +} CRBufferObject; + +typedef struct { + GLboolean retainBufferData; /* should state tracker retain buffer data? */ + CRBufferObject *arrayBuffer; + CRBufferObject *elementsBuffer; + CRBufferObject *packBuffer; + CRBufferObject *unpackBuffer; + + CRBufferObject *nullBuffer; /* name = 0 */ +} CRBufferObjectState; + +DECLEXPORT(CRBufferObject *) crStateGetBoundBufferObject(GLenum target, CRBufferObjectState *b); +DECLEXPORT(GLboolean) crStateIsBufferBound(GLenum target); +struct CRContext; +DECLEXPORT(GLboolean) crStateIsBufferBoundForCtx(struct CRContext *g, GLenum target); + +DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(GLuint hwid); +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(GLuint id); + +DECLEXPORT(void) crStateRegBuffers(GLsizei n, GLuint *buffers); +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_BUFFEROBJECT_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_client.h b/src/VBox/GuestHost/OpenGL/include/state/cr_client.h new file mode 100644 index 00000000..a727f260 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_client.h @@ -0,0 +1,143 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_CLIENT_H +#define CR_STATE_CLIENT_H + +#include "state/cr_statetypes.h" +#include "state/cr_limits.h" +#include "state/cr_bufferobject.h" +#include "cr_bits.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + /* pixel pack/unpack */ + CRbitvalue pack[CR_MAX_BITARRAY]; + CRbitvalue unpack[CR_MAX_BITARRAY]; + /* vertex array */ + CRbitvalue enableClientState[CR_MAX_BITARRAY]; + CRbitvalue clientPointer[CR_MAX_BITARRAY]; + CRbitvalue *v; /* vertex */ + CRbitvalue *n; /* normal */ + CRbitvalue *c; /* color */ + CRbitvalue *i; /* index */ + CRbitvalue *t[CR_MAX_TEXTURE_UNITS]; /* texcoord */ + CRbitvalue *e; /* edgeflag */ + CRbitvalue *s; /* secondary color */ + CRbitvalue *f; /* fog coord */ +#ifdef CR_NV_vertex_program + CRbitvalue *a[CR_MAX_VERTEX_ATTRIBS]; /* NV_vertex_program */ +#endif +} CRClientBits; + +/* + * NOTE!!!! If you change this structure, search through the code for + * occurrences of 'defaultPacking' and fix the static initializations!!!! + */ +typedef struct { + GLint rowLength; + GLint skipRows; + GLint skipPixels; + GLint alignment; + GLint imageHeight; + GLint skipImages; + GLboolean swapBytes; + GLboolean psLSBFirst; /* don't conflict with crap from Xlib.h */ +} CRPixelPackState; + +typedef struct { + unsigned char *p; + GLint size; + GLint type; + GLint stride; + GLboolean enabled; + GLboolean normalized; /* Added with GL_ARB_vertex_program */ + int bytesPerIndex; +#ifdef CR_ARB_vertex_buffer_object + CRBufferObject *buffer; +#endif +#ifdef CR_EXT_compiled_vertex_array + GLboolean locked; + unsigned char *prevPtr; + GLint prevStride; +#endif +} CRClientPointer; + +typedef struct { + CRClientPointer v; /* vertex */ + CRClientPointer n; /* normal */ + CRClientPointer c; /* color */ + CRClientPointer i; /* color index */ + CRClientPointer t[CR_MAX_TEXTURE_UNITS]; /* texcoords */ + CRClientPointer e; /* edge flags */ + CRClientPointer s; /* secondary color */ + CRClientPointer f; /* fog coord */ +#ifdef CR_NV_vertex_program + CRClientPointer a[CR_MAX_VERTEX_ATTRIBS]; /* vertex attribs */ +#endif +#ifdef CR_NV_vertex_array_range + GLboolean arrayRange; + GLboolean arrayRangeValid; + void *arrayRangePointer; + GLuint arrayRangeLength; +#endif +#ifdef CR_EXT_compiled_vertex_array + GLint lockFirst; + GLint lockCount; + GLboolean locked; +# ifdef IN_GUEST + GLboolean synced; +# endif +#endif +} CRVertexArrays; + +#define CRSTATECLIENT_MAX_VERTEXARRAYS (7+CR_MAX_TEXTURE_UNITS+CR_MAX_VERTEX_ATTRIBS) + +typedef struct { + /* pixel pack/unpack */ + CRPixelPackState pack; + CRPixelPackState unpack; + + CRVertexArrays array; + + GLint curClientTextureUnit; + + /* state stacks (glPush/PopClientState) */ + GLint attribStackDepth; + CRbitvalue pushMaskStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH]; + + GLint pixelStoreStackDepth; + CRPixelPackState pixelPackStoreStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH]; + CRPixelPackState pixelUnpackStoreStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH]; + + GLint vertexArrayStackDepth; + CRVertexArrays vertexArrayStack[CR_MAX_CLIENT_ATTRIB_STACK_DEPTH]; +} CRClientState; + +extern const CRPixelPackState crStateNativePixelPacking; + +struct CRContext; + +DECLEXPORT(void) crStateClientInitBits(CRClientBits *c); +DECLEXPORT(void) crStateClientDestroyBits(CRClientBits *c); +DECLEXPORT(void) crStateClientInit(struct CRContext *g); +DECLEXPORT(void) crStateClientDestroy(struct CRContext *g); + +DECLEXPORT(GLboolean) crStateUseServerArrays(void); +DECLEXPORT(GLboolean) crStateUseServerArrayElements(void); +DECLEXPORT(CRClientPointer*) crStateGetClientPointerByIndex(int index, CRVertexArrays *array); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_CLIENT_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_current.h b/src/VBox/GuestHost/OpenGL/include/state/cr_current.h new file mode 100644 index 00000000..d4a05708 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_current.h @@ -0,0 +1,107 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_CURRENT_H +#define CR_STATE_CURRENT_H + +#include "state/cr_currentpointers.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#define VERT_ATTRIB_POS 0 +#define VERT_ATTRIB_WEIGHT 1 +#define VERT_ATTRIB_NORMAL 2 +#define VERT_ATTRIB_COLOR0 3 +#define VERT_ATTRIB_COLOR1 4 +#define VERT_ATTRIB_FOG 5 +#define VERT_ATTRIB_SIX 6 +#define VERT_ATTRIB_SEVEN 7 +#define VERT_ATTRIB_TEX0 8 +#define VERT_ATTRIB_TEX1 9 +#define VERT_ATTRIB_TEX2 10 +#define VERT_ATTRIB_TEX3 11 +#define VERT_ATTRIB_TEX4 12 +#define VERT_ATTRIB_TEX5 13 +#define VERT_ATTRIB_TEX6 14 +#define VERT_ATTRIB_TEX7 15 +#define VERT_ATTRIB_MAX 16 + + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + /* Regardless of NV_vertex_program, we use this array */ + CRbitvalue vertexAttrib[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY]; + CRbitvalue edgeFlag[CR_MAX_BITARRAY]; + CRbitvalue colorIndex[CR_MAX_BITARRAY]; + CRbitvalue rasterPos[CR_MAX_BITARRAY]; +} CRCurrentBits; + + +typedef struct { + /* Pre-transform values */ + /* Regardless of NV_vertex_program, we use this array */ + GLfloat attrib[CR_MAX_VERTEX_ATTRIBS][4]; + GLboolean edgeFlag; + GLfloat colorIndex; + /* Post-transform values */ + GLvectorf eyePos; + GLvectorf clipPos; + GLvectorf winPos; +} CRVertex; + + +typedef struct { + /* Regardless of NV_vertex_program, we use this array */ + GLfloat vertexAttrib[CR_MAX_VERTEX_ATTRIBS][4]; + GLfloat vertexAttribPre[CR_MAX_VERTEX_ATTRIBS][4]; + + CRCurrentStatePointers *current; + + GLboolean rasterValid; + GLfloat rasterAttrib[CR_MAX_VERTEX_ATTRIBS][4]; + GLfloat rasterAttribPre[CR_MAX_VERTEX_ATTRIBS][4]; + + GLdouble rasterIndex; + GLboolean edgeFlag; + GLboolean edgeFlagPre; + GLfloat colorIndex; + GLfloat colorIndexPre; + + /* XXX this isn't really "current" state - move someday */ + GLuint attribsUsedMask; /* for ARB_vertex_program */ + GLboolean inBeginEnd; + GLenum mode; + GLuint beginEndMax; + GLuint beginEndNum; + GLuint flushOnEnd; + +} CRCurrentState; + +DECLEXPORT(void) crStateCurrentInit( CRContext *ctx ); + +DECLEXPORT(void) crStateCurrentRecover( void ); + +DECLEXPORT(void) crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers *current); + +DECLEXPORT(void) crStateCurrentDiff(CRCurrentBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateCurrentSwitch(CRCurrentBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +DECLEXPORT(void) crStateRasterPosUpdate(GLfloat x, GLfloat y, GLfloat z, GLfloat w); + +DECLEXPORT(GLuint) crStateNeedDummyZeroVertexArray(CRContext *g, CRCurrentStatePointers *current, GLfloat *pZva); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_CURRENT_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h b/src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h new file mode 100644 index 00000000..2a3d7836 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_evaluators.h @@ -0,0 +1,91 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_EVALUATORS +#define CR_STATE_EVALUATORS + +#include "state/cr_statetypes.h" + +#include + +#define GLEVAL_TOT 9 +#define MAX_EVAL_ORDER 30 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue eval1D[GLEVAL_TOT][CR_MAX_BITARRAY]; + CRbitvalue eval2D[GLEVAL_TOT][CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue enable1D[GLEVAL_TOT][CR_MAX_BITARRAY]; + CRbitvalue enable2D[GLEVAL_TOT][CR_MAX_BITARRAY]; + CRbitvalue grid1D[CR_MAX_BITARRAY]; + CRbitvalue grid2D[CR_MAX_BITARRAY]; + CRbitvalue dirty[CR_MAX_BITARRAY]; +#ifdef CR_NV_vertex_program + CRbitvalue enableAttrib1D[CR_MAX_VERTEX_ATTRIBS]; + CRbitvalue enableAttrib2D[CR_MAX_VERTEX_ATTRIBS]; +#endif +} CREvaluatorBits; + +typedef struct { + GLfloat u1, u2; + GLfloat du; + GLint order; + GLfloat *coeff; +} CREvaluator1D; + +typedef struct { + GLfloat u1, u2; + GLfloat v1, v2; + GLfloat du, dv; + GLint uorder; + GLint vorder; + GLfloat *coeff; +} CREvaluator2D; + +typedef struct { + GLboolean enable1D[GLEVAL_TOT]; + GLboolean enable2D[GLEVAL_TOT]; +#ifdef CR_NV_vertex_program + GLboolean enableAttrib1D[CR_MAX_VERTEX_ATTRIBS]; + GLboolean enableAttrib2D[CR_MAX_VERTEX_ATTRIBS]; +#endif + GLboolean autoNormal; + + CREvaluator1D eval1D[GLEVAL_TOT]; + CREvaluator2D eval2D[GLEVAL_TOT]; +#ifdef CR_NV_vertex_program + CREvaluator1D attribEval1D[CR_MAX_VERTEX_ATTRIBS]; + CREvaluator2D attribEval2D[CR_MAX_VERTEX_ATTRIBS]; +#endif + + GLint un1D; /* GL_MAP1_GRID_SEGMENTS */ + GLfloat u11D, u21D; /* GL_MAP1_GRID_DOMAIN */ + + GLint un2D; /* GL_MAP2_GRID_SEGMENTS (u) */ + GLint vn2D; /* GL_MAP2_GRID_SEGMENTS (v) */ + GLfloat u12D, u22D; /* GL_MAP2_GRID_DOMAIN (u) */ + GLfloat v12D, v22D; /* GL_MAP2_GRID_DOMAIN (v) */ +} CREvaluatorState; + +extern const int gleval_sizes[]; + +DECLEXPORT(void) crStateEvaluatorInit (CRContext *ctx); +DECLEXPORT(void) crStateEvaluatorDestroy (CRContext *ctx); + +DECLEXPORT(void) crStateEvaluatorDiff(CREvaluatorBits *e, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateEvaluatorSwitch(CREvaluatorBits *e, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_EVALUATORS */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h b/src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h new file mode 100644 index 00000000..168f20eb --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_feedback.h @@ -0,0 +1,56 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_FEEDBACK_H +#define CR_STATE_FEEDBACK_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MAX_NAME_STACK_DEPTH 64 + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CRFeedbackBits; + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CRSelectionBits; + +typedef struct { + GLenum type; + GLuint mask; + GLfloat *buffer; + GLuint bufferSize; + GLuint count; +} CRFeedbackState; + +typedef struct { + GLuint *buffer; + GLuint bufferSize; + GLuint bufferCount; + GLuint hits; + GLuint nameStackDepth; + GLuint nameStack[MAX_NAME_STACK_DEPTH]; + GLboolean hitFlag; + GLfloat hitMinZ, hitMaxZ; +} CRSelectionState; + +extern DECLEXPORT(void) crStateFeedbackDiff(CRFeedbackState *from, CRFeedbackState *to, + CRFeedbackBits *bb, CRbitvalue *bitID); +extern DECLEXPORT(void) crStateFeedbackSwitch(CRFeedbackBits *bb, CRbitvalue *bitID, + CRFeedbackState *from, CRFeedbackState *to); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_FEEDBACK_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_fog.h b/src/VBox/GuestHost/OpenGL/include/state/cr_fog.h new file mode 100644 index 00000000..f0f85129 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_fog.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_FOG_H +#define CR_STATE_FOG_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue color[CR_MAX_BITARRAY]; + CRbitvalue index[CR_MAX_BITARRAY]; + CRbitvalue density[CR_MAX_BITARRAY]; + CRbitvalue start[CR_MAX_BITARRAY]; + CRbitvalue end[CR_MAX_BITARRAY]; + CRbitvalue mode[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; +#ifdef CR_NV_fog_distance + CRbitvalue fogDistanceMode[CR_MAX_BITARRAY]; +#endif +#ifdef CR_EXT_fog_coord + CRbitvalue fogCoordinateSource[CR_MAX_BITARRAY]; +#endif +} CRFogBits; + +typedef struct { + GLcolorf color; + GLint index; + GLfloat density; + GLfloat start; + GLfloat end; + GLint mode; + GLboolean enable; +#ifdef CR_NV_fog_distance + GLenum fogDistanceMode; +#endif +#ifdef CR_EXT_fog_coord + GLenum fogCoordinateSource; +#endif +} CRFogState; + +DECLEXPORT(void) crStateFogInit(CRContext *ctx); + +DECLEXPORT(void) crStateFogDiff(CRFogBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateFogSwitch(CRFogBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_FOG_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h b/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h new file mode 100644 index 00000000..13dd6e02 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_framebuffer.h @@ -0,0 +1,108 @@ +/* $Id: cr_framebuffer.h $ */ + +/** @file + * VBox crOpenGL: FBO related state info + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + + +#ifndef CR_STATE_FRAMEBUFFEROBJECT_H +#define CR_STATE_FRAMEBUFFEROBJECT_H + +#include "cr_hash.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define CR_MAX_COLOR_ATTACHMENTS 16 + +typedef struct { + GLenum type; /*one of GL_NONE GL_TEXTURE GL_RENDERBUFFER_EXT*/ + GLuint name; + GLint level; + GLint face; + GLint zoffset; +} CRFBOAttachmentPoint; + +typedef struct { + GLuint id, hwid; + CRFBOAttachmentPoint color[CR_MAX_COLOR_ATTACHMENTS]; + CRFBOAttachmentPoint depth; + CRFBOAttachmentPoint stencil; + GLenum readbuffer; + /*@todo: we don't support drawbufferS yet, so it's a stub*/ + GLenum drawbuffer[1]; +#ifdef IN_GUEST + GLenum status; +#endif + /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */ + CRbitvalue ctxUsage[CR_MAX_BITARRAY]; +} CRFramebufferObject; + +typedef struct { + GLuint id, hwid; + GLsizei width, height; + GLenum internalformat; + GLuint redBits, greenBits, blueBits, alphaBits, depthBits, stencilBits; + /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */ + CRbitvalue ctxUsage[CR_MAX_BITARRAY]; +} CRRenderbufferObject; + +typedef struct { + CRFramebufferObject *readFB, *drawFB; + CRRenderbufferObject *renderbuffer; +} CRFramebufferObjectState; + +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectInit(CRContext *ctx); +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectDestroy(CRContext *ctx); +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectSwitch(CRContext *from, CRContext *to); + +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectDisableHW(CRContext *ctx, GLuint idDrawFBO, GLuint idReadFBO); +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferObjectReenableHW(CRContext *fromCtx, CRContext *toCtx, GLuint idDrawFBO, GLuint idReadFBO); + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetFramebufferHWID(GLuint id); +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetRenderbufferHWID(GLuint id); + +DECLEXPORT(void) STATE_APIENTRY crStateBindRenderbufferEXT(GLenum target, GLuint renderbuffer); +DECLEXPORT(void) STATE_APIENTRY crStateDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers); +DECLEXPORT(void) STATE_APIENTRY crStateRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +DECLEXPORT(void) STATE_APIENTRY crStateGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params); +DECLEXPORT(void) STATE_APIENTRY crStateBindFramebufferEXT(GLenum target, GLuint framebuffer); +DECLEXPORT(void) STATE_APIENTRY crStateDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers); +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +DECLEXPORT(void) STATE_APIENTRY crStateFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +DECLEXPORT(void) STATE_APIENTRY crStateGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params); +DECLEXPORT(void) STATE_APIENTRY crStateGenerateMipmapEXT(GLenum target); + +DECLEXPORT(GLuint) STATE_APIENTRY crStateFBOHWIDtoID(GLuint hwid); +DECLEXPORT(GLuint) STATE_APIENTRY crStateRBOHWIDtoID(GLuint hwid); + +DECLEXPORT(void) crStateRegFramebuffers(GLsizei n, GLuint *buffers); +DECLEXPORT(void) crStateRegRenderbuffers(GLsizei n, GLuint *buffers); + +#ifdef IN_GUEST +DECLEXPORT(GLenum) STATE_APIENTRY crStateCheckFramebufferStatusEXT(GLenum target); +DECLEXPORT(GLenum) STATE_APIENTRY crStateSetFramebufferStatus(GLenum target, GLenum status); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_FRAMEBUFFEROBJECT_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h b/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h new file mode 100644 index 00000000..32c3a80c --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h @@ -0,0 +1,122 @@ +/* $Id: cr_glsl.h $ */ + +/** @file + * VBox crOpenGL: GLSL related state info + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#ifndef CR_STATE_GLSL_H +#define CR_STATE_GLSL_H + +#include "cr_hash.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* We can't go the "easy" way of just extracting all the required data when taking snapshots. + Shader objects might be modified *after* program linkage and wouldn't affect program until it's relinked. + So we have to keep track of shaders statuses right before each program was linked as well as their "current" status. +*/ + +/*@todo: check rare case when successfully linked and active program is relinked with failure*/ + +typedef struct { + GLuint id, hwid; + GLenum type; /*GL_VERTEX_SHADER or GL_FRAGMENT_SHADER*/ + GLchar* source; /*NULL after context loading unless in program's "active" hash*/ + GLboolean compiled, deleted; + GLuint refCount; /*valid only for shaders in CRGLSLState's hash*/ +} CRGLSLShader; + +typedef struct { + GLchar* name; + GLuint index; +} CRGLSLAttrib; + +/*Note: active state will hold copies of shaders while current state references shaders in the CRGLSLState hashtable*/ +/*@todo: probably don't need a hashtable here*/ +typedef struct { + CRHashTable *attachedShaders; + CRGLSLAttrib *pAttribs; /*several names could be bound to the same index*/ + GLuint cAttribs; +} CRGLSLProgramState; + +typedef struct{ + GLchar *name; + GLenum type; + GLvoid *data; +#ifdef IN_GUEST + GLint location; +#endif +} CRGLSLUniform; + +typedef struct { + GLuint id, hwid; + GLboolean validated, linked, deleted; + CRGLSLProgramState activeState, currentState; + CRGLSLUniform *pUniforms; + GLuint cUniforms; +#ifdef IN_GUEST + CRGLSLAttrib *pAttribs; + GLuint cAttribs; + GLboolean bUniformsSynced; /*uniforms info is updated since last link program call.*/ + GLboolean bAttribsSynced; /*attribs info is updated since last link program call.*/ +#endif +} CRGLSLProgram; + +typedef struct { + CRHashTable *shaders; + CRHashTable *programs; + + CRGLSLProgram *activeProgram; + + /* Indicates that we have to resend GLSL data to GPU on first glMakeCurrent call with owning context */ + GLboolean bResyncNeeded; +} CRGLSLState; + +DECLEXPORT(void) STATE_APIENTRY crStateGLSLInit(CRContext *ctx); +DECLEXPORT(void) STATE_APIENTRY crStateGLSLDestroy(CRContext *ctx); +DECLEXPORT(void) STATE_APIENTRY crStateGLSLSwitch(CRContext *from, CRContext *to); + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetShaderHWID(GLuint id); +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetProgramHWID(GLuint id); +DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLProgramHWIDtoID(GLuint hwid); +DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLShaderHWIDtoID(GLuint hwid); + +DECLEXPORT(GLint) STATE_APIENTRY crStateGetUniformSize(GLenum type); +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsIntUniform(GLenum type); + +DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint id, GLenum type); +DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateProgram(GLuint id); +DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( VBoxGLhandleARB obj ); + +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(GLuint program); +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramAttribsCached(GLuint program); + +#ifdef IN_GUEST +DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei cbData, GLvoid *pData); +DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheAttribs(GLuint program, GLsizei cbData, GLvoid *pData); +#else +DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheUniforms(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData); +DECLEXPORT(void) STATE_APIENTRY crStateGLSLProgramCacheAttribs(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_GLSL_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_hint.h b/src/VBox/GuestHost/OpenGL/include/state/cr_hint.h new file mode 100644 index 00000000..f6b64492 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_hint.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_HINT_H +#define CR_STATE_HINT_H + +#include "state/cr_statetypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue perspectiveCorrection[CR_MAX_BITARRAY]; + CRbitvalue pointSmooth[CR_MAX_BITARRAY]; + CRbitvalue lineSmooth[CR_MAX_BITARRAY]; + CRbitvalue polygonSmooth[CR_MAX_BITARRAY]; + CRbitvalue fog[CR_MAX_BITARRAY]; +#ifdef CR_EXT_clip_volume_hint + CRbitvalue clipVolumeClipping[CR_MAX_BITARRAY]; +#endif +#ifdef CR_ARB_texture_compression + CRbitvalue textureCompression[CR_MAX_BITARRAY]; +#endif +#ifdef CR_SGIS_generate_mipmap + CRbitvalue generateMipmap[CR_MAX_BITARRAY]; +#endif +} CRHintBits; + +typedef struct { + GLenum perspectiveCorrection; + GLenum pointSmooth; + GLenum lineSmooth; + GLenum polygonSmooth; + GLenum fog; +#ifdef CR_EXT_clip_volume_hint + GLenum clipVolumeClipping; +#endif +#ifdef CR_ARB_texture_compression + GLenum textureCompression; +#endif +#ifdef CR_SGIS_generate_mipmap + GLenum generateMipmap; +#endif +} CRHintState; + +DECLEXPORT(void) crStateHintInit(CRContext *ctx); + +DECLEXPORT(void) crStateHintDiff(CRHintBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateHintSwitch(CRHintBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_HINT_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h b/src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h new file mode 100644 index 00000000..f10f10ec --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_lighting.h @@ -0,0 +1,92 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_LIGHTING_H +#define CR_STATE_LIGHTING_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue ambient[CR_MAX_BITARRAY]; + CRbitvalue diffuse[CR_MAX_BITARRAY]; + CRbitvalue specular[CR_MAX_BITARRAY]; + CRbitvalue position[CR_MAX_BITARRAY]; + CRbitvalue attenuation[CR_MAX_BITARRAY]; + CRbitvalue spot[CR_MAX_BITARRAY]; +} CRLightBits; + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue shadeModel[CR_MAX_BITARRAY]; + CRbitvalue colorMaterial[CR_MAX_BITARRAY]; + CRbitvalue lightModel[CR_MAX_BITARRAY]; + CRbitvalue material[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRLightBits *light; +} CRLightingBits; + +typedef struct { + GLboolean enable; + GLcolorf ambient; + GLcolorf diffuse; + GLcolorf specular; + GLvectorf position; + GLvectorf objPosition; + GLfloat constantAttenuation; + GLfloat linearAttenuation; + GLfloat quadraticAttenuation; + GLvectorf spotDirection; + GLfloat spotExponent; + GLfloat spotCutoff; +} CRLight; + +typedef struct { + GLboolean lighting; + GLboolean colorMaterial; + GLenum shadeModel; + GLenum colorMaterialMode; + GLenum colorMaterialFace; + GLcolorf ambient[2]; /* material front/back */ + GLcolorf diffuse[2]; /* material front/back */ + GLcolorf specular[2]; /* material front/back */ + GLcolorf emission[2]; /* material front/back */ + GLfloat shininess[2]; /* material front/back */ + GLint indexes[2][3]; /* material front/back amb/diff/spec */ + GLcolorf lightModelAmbient; + GLboolean lightModelLocalViewer; + GLboolean lightModelTwoSide; +#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2) + GLenum lightModelColorControlEXT; /* CR_EXT_separate_specular_color */ +#endif + GLboolean colorSumEXT; /* CR_EXT_secondary_color */ + CRLight *light; +} CRLightingState; + +DECLEXPORT(void) crStateLightingInitBits (CRLightingBits *l); +DECLEXPORT(void) crStateLightingDestroyBits (CRLightingBits *l); +DECLEXPORT(void) crStateLightingInit (CRContext *ctx); +DECLEXPORT(void) crStateLightingDestroy (CRContext *ctx); + +DECLEXPORT(void) crStateLightingDiff(CRLightingBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateLightingSwitch(CRLightingBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +DECLEXPORT(void) crStateColorMaterialRecover( void ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_LIGHTING_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h b/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h new file mode 100644 index 00000000..0378ff07 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_limits.h @@ -0,0 +1,285 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_LIMITS_H +#define CR_LIMITS_H + +#include "chromium.h" +#include "cr_version.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +/* glGetString strings */ +#define CR_RENDERER "Chromium" +#define CR_VENDOR "Humper" + + +#define CR_MAX_TEXTURE_UNITS 8 +#define CR_MAX_GENERAL_COMBINERS 8 +#define CR_MAX_TEXTURE_SIZE 8192 +#define CR_MAX_3D_TEXTURE_SIZE 512 +#define CR_MAX_CUBE_TEXTURE_SIZE 4096 +#define CR_MAX_RECTANGLE_TEXTURE_SIZE 4096 +#define CR_MAX_TEXTURE_ANISOTROPY 8.0 +#define CR_MAX_LIGHTS 8 +#define CR_MAX_CLIP_PLANES 8 +#define CR_MAX_PROJECTION_STACK_DEPTH 32 +#define CR_MAX_MODELVIEW_STACK_DEPTH 32 +#define CR_MAX_TEXTURE_STACK_DEPTH 10 +#define CR_MAX_COLOR_STACK_DEPTH 2 +#define CR_MAX_ATTRIB_STACK_DEPTH 16 +#define CR_MAX_CLIENT_ATTRIB_STACK_DEPTH 16 +#define CR_MAX_NAME_STACK_DEPTH 64 +#define CR_MAX_ELEMENTS_INDICES 16384 +#define CR_MAX_ELEMENTS_VERTICES 16384 +#define CR_MAX_EVAL_ORDER 8 +#define CR_MAX_LIST_NESTING 64 +#define CR_MAX_PIXEL_MAP_TABLE 256 +#define CR_MAX_VIEWPORT_DIM 16384 +#define CR_SUBPIXEL_BITS 8 +#define CR_ALIASED_POINT_SIZE_MIN 1.0 +#define CR_ALIASED_POINT_SIZE_MAX 64.0 +#define CR_SMOOTH_POINT_SIZE_MIN 1.0 +#define CR_SMOOTH_POINT_SIZE_MAX 64.0 +#define CR_POINT_SIZE_GRANULARITY 0.5 +#define CR_ALIASED_LINE_WIDTH_MIN 1.0 +#define CR_ALIASED_LINE_WIDTH_MAX 64.0 +#define CR_SMOOTH_LINE_WIDTH_MIN 1.0 +#define CR_SMOOTH_LINE_WIDTH_MAX 64.0 +#define CR_LINE_WIDTH_GRANULARITY 0.5 +#define CR_MAX_VERTEX_ATTRIBS 16 +#define CR_MAX_TEXTURE_LOD_BIAS 8.0 +#ifdef CR_NV_fragment_program +#define CR_MAX_TEXTURE_COORDS 2 +#define CR_MAX_TEXTURE_IMAGE_UNITS 2 +#define CR_MAX_FRAGMENT_LOCAL_PARAMS 64 +#endif +#ifdef CR_NV_vertex_program +#define CR_MAX_PROGRAM_MATRICES 8 +#define CR_MAX_PROGRAM_MATRIX_STACK_DEPTH 4 +#endif +#ifdef CR_ARB_fragment_program +#define CR_MAX_FRAGMENT_PROGRAM_INSTRUCTIONS 72 +#define CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS 24 +#define CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS 256 +#define CR_MAX_FRAGMENT_PROGRAM_TEMPS 16 +#define CR_MAX_FRAGMENT_PROGRAM_ATTRIBS 10 +#define CR_MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 1 +#define CR_MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS 48 +#define CR_MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS 24 +#define CR_MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS 4 +#endif +#ifdef CR_ARB_vertex_program +#define CR_MAX_VERTEX_PROGRAM_INSTRUCTIONS 128 +#define CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS 96 +#define CR_MAX_VERTEX_PROGRAM_ENV_PARAMS 256 /* for GL_NV_vertex_program2 */ +#define CR_MAX_VERTEX_PROGRAM_TEMPS 12 +#define CR_MAX_VERTEX_PROGRAM_ATTRIBS 16 +#define CR_MAX_VERTEX_PROGRAM_ADDRESS_REGS 1 +#endif + +#if defined(CR_ARB_vertex_program) || defined(CR_ARB_fragment_program) +/* These must be the max of the fragment and vertex program limits */ +#define CR_MAX_PROGRAM_LOCAL_PARAMS (CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS > CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS ? CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS : CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS) + +#define CR_MAX_PROGRAM_ENV_PARAMS (CR_MAX_VERTEX_PROGRAM_ENV_PARAMS > CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS ? CR_MAX_VERTEX_PROGRAM_ENV_PARAMS : CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS) +#endif + + +/* Just need these for autogenerated code in state_get.c, etc */ +#if defined(CR_ARB_vertex_program) || defined(CR_NV_vertex_program) +#define CR_any_vertex_program 1 +#endif + +#if defined(CR_ARB_fragment_program) || defined(CR_NV_fragment_program) +#define CR_any_fragment_program 1 +#endif + +#if defined(CR_any_vertex_program) || defined(CR_any_fragment_program) +#define CR_any_program 1 +#endif + + + +/* + * OpenGL's implementation-dependent values (not part of any attribute group). + */ +typedef struct { + GLuint maxTextureUnits; + GLuint maxTextureSize; + GLuint max3DTextureSize; /* OpenGL 1.2 */ +#ifdef CR_ARB_texture_cube_map + GLuint maxCubeMapTextureSize; +#endif + GLuint maxLights; + GLuint maxClipPlanes; + GLuint maxProjectionStackDepth; + GLuint maxModelviewStackDepth; + GLuint maxTextureStackDepth; + GLuint maxColorStackDepth; /* OpenGL 1.2 */ + GLuint maxAttribStackDepth; + GLuint maxClientAttribStackDepth; + GLuint maxNameStackDepth; + GLuint maxElementsIndices; + GLuint maxElementsVertices; + GLuint maxEvalOrder; + GLuint maxListNesting; + GLuint maxPixelMapTable; + GLint maxViewportDims[2]; + GLuint subpixelBits; + GLfloat aliasedPointSizeRange[2]; + GLfloat smoothPointSizeRange[2]; + GLfloat pointSizeGranularity; + GLfloat aliasedLineWidthRange[2]; + GLfloat smoothLineWidthRange[2]; + GLfloat lineWidthGranularity; +#ifdef CR_EXT_texture_lod_bias + GLfloat maxTextureLodBias; +#endif +#ifdef CR_EXT_texture_filter_anisotropic + GLfloat maxTextureAnisotropy; +#endif +#ifdef CR_ARB_texture_compression + GLuint numCompressedFormats; + GLenum compressedFormats[10]; +#endif +#ifdef CR_NV_register_combiners + GLuint maxGeneralCombiners; +#endif +#ifdef CR_NV_texture_rectangle + GLuint maxRectTextureSize; +#endif +#ifdef CR_NV_fragment_program + GLuint maxTextureCoords; + GLuint maxTextureImageUnits; + /*GLuint maxFragmentProgramLocalParams;*/ +#endif +#ifdef CR_NV_vertex_program + GLuint maxProgramMatrixStackDepth; + GLuint maxProgramMatrices; +#endif +#ifdef CR_ARB_fragment_program + GLuint maxFragmentProgramInstructions; + GLuint maxFragmentProgramLocalParams; + GLuint maxFragmentProgramEnvParams; + GLuint maxFragmentProgramTemps; + GLuint maxFragmentProgramAttribs; + GLuint maxFragmentProgramAddressRegs; + GLuint maxFragmentProgramAluInstructions; + GLuint maxFragmentProgramTexInstructions; + GLuint maxFragmentProgramTexIndirections; +#endif +#ifdef CR_ARB_vertex_program + GLuint maxVertexProgramInstructions; + GLuint maxVertexProgramLocalParams; + GLuint maxVertexProgramEnvParams; + GLuint maxVertexProgramTemps; + GLuint maxVertexProgramAttribs; + GLuint maxVertexProgramAddressRegs; +#endif + const GLubyte *extensions; + + /* Framebuffer/visual attributes */ + GLuint redBits, greenBits, blueBits, alphaBits; + GLuint depthBits, stencilBits, indexBits; + GLuint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits; + GLuint auxBuffers; + GLboolean rgbaMode; + GLboolean doubleBuffer; + GLboolean stereo; + GLuint sampleBuffers; + GLuint samples; + GLuint level; + +} CRLimitsState; + + +/* Booleans to indicate which OpenGL extensions are supported at runtime. + * XXX might merge this into the above structure someday. + */ +typedef struct { + GLboolean ARB_depth_texture; + GLboolean ARB_fragment_program; + GLboolean ARB_imaging; + GLboolean ARB_multisample; + GLboolean ARB_multitexture; + GLboolean ARB_occlusion_query; + GLboolean ARB_point_parameters; + GLboolean ARB_point_sprite; + GLboolean ARB_shadow; + GLboolean ARB_shadow_ambient; + GLboolean ARB_texture_border_clamp; /* or SGIS_texture_border_clamp */ + GLboolean ARB_texture_compression; + GLboolean ARB_texture_cube_map; /* or EXT_texture_cube_map */ + GLboolean ARB_texture_env_add; /* standard in OpenGL 1.3 */ + GLboolean ARB_texture_env_combine; /* standard in OpenGL 1.3 */ + GLboolean ARB_texture_env_crossbar; /* standard in OpenGL 1.4 */ + GLboolean ARB_texture_env_dot3; /* standard in OpenGL 1.3 */ + GLboolean ARB_texture_mirrored_repeat; + GLboolean ARB_texture_non_power_of_two; /* standard in 1.5 */ + GLboolean ARB_transpose_matrix; + GLboolean ARB_vertex_buffer_object; + GLboolean ARB_pixel_buffer_object; + GLboolean ARB_vertex_program; + GLboolean ARB_window_pos; + GLboolean EXT_blend_color; + GLboolean EXT_blend_logic_op; + GLboolean EXT_blend_func_separate; + GLboolean EXT_blend_minmax; + GLboolean EXT_blend_subtract; + GLboolean EXT_clip_volume_hint; + GLboolean EXT_fog_coord; + GLboolean EXT_multi_draw_arrays; + GLboolean EXT_secondary_color; + GLboolean EXT_separate_specular_color; + GLboolean EXT_shadow_funcs; + GLboolean EXT_stencil_wrap; + GLboolean EXT_texture_edge_clamp; /* or SGIS_texture_edge_clamp */ + GLboolean EXT_texture_filter_anisotropic; + GLboolean EXT_texture_lod_bias; + GLboolean EXT_texture3D; + GLboolean IBM_rasterpos_clip; + GLboolean NV_fog_distance; + GLboolean NV_fragment_program; + GLboolean NV_register_combiners; + GLboolean NV_register_combiners2; + GLboolean NV_texgen_reflection; + GLboolean NV_texture_rectangle; + GLboolean NV_vertex_program; + GLboolean NV_vertex_program1_1; + GLboolean NV_vertex_program2; + GLboolean SGIS_generate_mipmap; + GLboolean EXT_texture_from_pixmap; + GLboolean ATI_texture_mirror_once; + + /* derived from above */ + GLboolean any_vertex_program; /* NV or ARB */ + GLboolean any_fragment_program; /* NV or ARB */ + GLboolean any_program; /* vertex or fragment */ +} CRExtensionState; + +extern DECLEXPORT(void) crStateLimitsInit(CRLimitsState *limits); +extern DECLEXPORT(void) crStateLimitsDestroy(CRLimitsState *limits); + +extern DECLEXPORT(void) crStateLimitsPrint(const CRLimitsState *limits); + +extern DECLEXPORT(GLfloat) crStateComputeVersion(float minVersion); + +extern DECLEXPORT(GLubyte *) crStateMergeExtensions(GLuint n, const GLubyte **extensions); + +extern DECLEXPORT(void) crStateExtensionsInit( CRLimitsState *limits, CRExtensionState *extensions ); + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_FOG_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_line.h b/src/VBox/GuestHost/OpenGL/include/state/cr_line.h new file mode 100644 index 00000000..98a0bd26 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_line.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_LINE_H +#define CR_STATE_LINE_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue width[CR_MAX_BITARRAY]; + CRbitvalue stipple[CR_MAX_BITARRAY]; + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CRLineBits; + +typedef struct { + GLboolean lineSmooth; + GLboolean lineStipple; + GLfloat width; + GLushort pattern; + GLint repeat; +} CRLineState; + +DECLEXPORT(void) crStateLineInit (CRContext *ctx); + +DECLEXPORT(void) crStateLineDiff(CRLineBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateLineSwitch(CRLineBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_LINE_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_lists.h b/src/VBox/GuestHost/OpenGL/include/state/cr_lists.h new file mode 100644 index 00000000..f8608db7 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_lists.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_LISTS_H +#define CR_STATE_LISTS_H + +#include "cr_hash.h" +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue base[CR_MAX_BITARRAY]; +} CRListsBits; + +typedef struct { + GLboolean newEnd; + GLuint base; /* set by glListBase */ + GLuint currentIndex; /* list currently being built (or zero) */ + GLenum mode; /* GL_COMPILE, GL_COMPILE_AND_EXECUTE or zero */ +} CRListsState; + + +DECLEXPORT(void) crStateListsInit(CRContext *ctx); +DECLEXPORT(void) crStateListsDestroy(CRContext *ctx); + +DECLEXPORT(void) crStateListsDiff(CRListsBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateListsSwitch(CRListsBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h b/src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h new file mode 100644 index 00000000..38634ed0 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_multisample.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_MULTISAMPLE_H +#define CR_STATE_MULTISAMPLE_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue sampleAlphaToCoverage[CR_MAX_BITARRAY]; + CRbitvalue sampleAlphaToOne[CR_MAX_BITARRAY]; + CRbitvalue sampleCoverage[CR_MAX_BITARRAY]; + CRbitvalue sampleCoverageValue[CR_MAX_BITARRAY]; /* and invert */ +} CRMultisampleBits; + +typedef struct { + GLboolean enabled; + GLboolean sampleAlphaToCoverage; + GLboolean sampleAlphaToOne; + GLboolean sampleCoverage; + GLfloat sampleCoverageValue; + GLboolean sampleCoverageInvert; +} CRMultisampleState; + +DECLEXPORT(void) crStateMultisampleInit(CRContext *ctx); + +DECLEXPORT(void) crStateMultisampleDiff(CRMultisampleBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateMultisampleSwitch(CRMultisampleBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_MULTISAMPLE_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h b/src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h new file mode 100644 index 00000000..9791ec6a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_occlude.h @@ -0,0 +1,58 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_OCCLUSION_H +#define CR_OCCLUSION_H + +#include "cr_hash.h" +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CROcclusionBits; + + +/* + * Occlusion query object. + */ +typedef struct { + GLenum target; + GLuint name; + GLuint refCount; + GLuint passedCounter; + GLboolean active; + CRbitvalue dirty[CR_MAX_BITARRAY]; /* dirty data or state */ + GLintptrARB dirtyStart, dirtyLength; /* dirty region */ +} CROcclusionObject; + + +typedef struct { + CRHashTable *objects; + GLuint currentQueryObject; +} CROcclusionState; + + +DECLEXPORT(void) crStateOcclusionInit(CRContext *ctx); + +DECLEXPORT(void) crStateOcclusionDestroy(CRContext *ctx); + +DECLEXPORT(void) crStateOcclusionDiff(CROcclusionBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateOcclusionSwitch(CROcclusionBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_OCCLUSION_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h b/src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h new file mode 100644 index 00000000..1afed66e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_pixel.h @@ -0,0 +1,74 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_PIXEL_H +#define CR_STATE_PIXEL_H + +#include "state/cr_statetypes.h" +#include "state/cr_limits.h" +#include "cr_bits.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue transfer[CR_MAX_BITARRAY]; + CRbitvalue zoom[CR_MAX_BITARRAY]; + CRbitvalue maps[CR_MAX_BITARRAY]; +} CRPixelBits; + +typedef struct { + GLboolean mapColor; + GLboolean mapStencil; + GLint indexShift; + GLint indexOffset; + GLcolorf scale; + GLfloat depthScale; + GLcolorf bias; + GLfloat depthBias; + GLfloat xZoom; + GLfloat yZoom; + + GLint mapItoI[CR_MAX_PIXEL_MAP_TABLE]; + GLint mapStoS[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapItoR[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapItoG[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapItoB[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapItoA[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapRtoR[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapGtoG[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapBtoB[CR_MAX_PIXEL_MAP_TABLE]; + GLfloat mapAtoA[CR_MAX_PIXEL_MAP_TABLE]; + + GLint mapItoIsize; + GLint mapStoSsize; + GLint mapItoRsize; + GLint mapItoGsize; + GLint mapItoBsize; + GLint mapItoAsize; + GLint mapRtoRsize; + GLint mapGtoGsize; + GLint mapBtoBsize; + GLint mapAtoAsize; +} CRPixelState; + +DECLEXPORT(void) crStatePixelInit( CRContext *ctx ); + +DECLEXPORT(void) crStatePixelDiff(CRPixelBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStatePixelSwitch(CRPixelBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + + +#endif /* CR_STATE_PIXEL_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_point.h b/src/VBox/GuestHost/OpenGL/include/state/cr_point.h new file mode 100644 index 00000000..1db3f7a1 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_point.h @@ -0,0 +1,62 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_POINT_H +#define CR_STATE_POINT_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue enableSmooth[CR_MAX_BITARRAY]; + CRbitvalue size[CR_MAX_BITARRAY]; +#ifdef CR_ARB_point_parameters + CRbitvalue minSize[CR_MAX_BITARRAY]; + CRbitvalue maxSize[CR_MAX_BITARRAY]; + CRbitvalue fadeThresholdSize[CR_MAX_BITARRAY]; + CRbitvalue distanceAttenuation[CR_MAX_BITARRAY]; +#endif +#ifdef CR_ARB_point_sprite + CRbitvalue enableSprite[CR_MAX_BITARRAY]; + CRbitvalue coordReplacement[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; +#endif + CRbitvalue spriteCoordOrigin[CR_MAX_BITARRAY]; + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CRPointBits; + +typedef struct { + GLboolean pointSmooth; + GLfloat pointSize; +#ifdef CR_ARB_point_parameters + GLfloat minSize, maxSize; + GLfloat fadeThresholdSize; + GLfloat distanceAttenuation[3]; +#endif +#ifdef CR_ARB_point_sprite + GLboolean pointSprite; + GLboolean coordReplacement[CR_MAX_TEXTURE_UNITS]; +#endif + GLfloat spriteCoordOrigin; + GLfloat reserved; /* added to make sure alignment of sttructures following CRPointState in CRContext does not change */ +} CRPointState; + +DECLEXPORT(void) crStatePointInit (CRContext *ctx); + +DECLEXPORT(void) crStatePointDiff(CRPointBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStatePointSwitch(CRPointBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_POINT_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h b/src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h new file mode 100644 index 00000000..33cdf79d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_polygon.h @@ -0,0 +1,53 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_POLYGON_H +#define CR_STATE_POLYGON_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue offset[CR_MAX_BITARRAY]; + CRbitvalue mode[CR_MAX_BITARRAY]; + CRbitvalue stipple[CR_MAX_BITARRAY]; + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CRPolygonBits; + +typedef struct { + GLboolean polygonSmooth; + GLboolean polygonOffsetFill; + GLboolean polygonOffsetLine; + GLboolean polygonOffsetPoint; + GLboolean polygonStipple; + GLboolean cullFace; + GLfloat offsetFactor; + GLfloat offsetUnits; + GLenum cullFaceMode; + GLenum frontFace; + GLenum frontMode; + GLenum backMode; + GLint stipple[32]; +} CRPolygonState; + +DECLEXPORT(void) crStatePolygonInit(CRContext *ctx); + +DECLEXPORT(void) crStatePolygonDiff(CRPolygonBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStatePolygonSwitch(CRPolygonBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_program.h b/src/VBox/GuestHost/OpenGL/include/state/cr_program.h new file mode 100644 index 00000000..e43dcacd --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_program.h @@ -0,0 +1,142 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_PROGRAM_H +#define CR_STATE_PROGRAM_H + +#include "cr_hash.h" +#include "state/cr_statetypes.h" +#include "state/cr_limits.h" + +#include + +/* + * Dirty bits for per-context program state. Per-program dirty bits + * are in the CRProgram structure. + */ +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue vpEnable[CR_MAX_BITARRAY]; + CRbitvalue fpEnable[CR_MAX_BITARRAY]; + CRbitvalue vpBinding[CR_MAX_BITARRAY]; + CRbitvalue fpBinding[CR_MAX_BITARRAY]; + CRbitvalue vertexAttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY]; + CRbitvalue map1AttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY]; + CRbitvalue map2AttribArrayEnable[CR_MAX_VERTEX_ATTRIBS][CR_MAX_BITARRAY]; + /* per-param flags: */ + CRbitvalue vertexEnvParameter[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS][CR_MAX_BITARRAY]; + CRbitvalue fragmentEnvParameter[CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS][CR_MAX_BITARRAY]; + /* any param flags: */ + CRbitvalue vertexEnvParameters[CR_MAX_BITARRAY]; + CRbitvalue fragmentEnvParameters[CR_MAX_BITARRAY]; + CRbitvalue trackMatrix[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4][CR_MAX_BITARRAY]; +} CRProgramBits; + + +/* + * Fragment programs have named symbols which are defined/declared + * within the fragment program that can also be set with the + * glProgramNamedParameter4*NV() functions. + * We keep a linked list of these CRProgramSymbol structures to implement + * a symbol table. A simple linked list is sufficient since a fragment + * program typically has just a few symbols. + */ +typedef struct CRProgramSymbol { + const char *name; + GLuint cbName; + GLfloat value[4]; + CRbitvalue dirty[CR_MAX_BITARRAY]; + struct CRProgramSymbol *next; +} CRProgramSymbol; + + +/* + * A vertex or fragment program. + */ +typedef struct { + GLenum target; + GLuint id; + GLboolean isARBprogram; /* to distinguish between NV and ARB programs */ + const GLubyte *string; + GLsizei length; + GLboolean resident; + GLenum format; + + /* Set with ProgramNamedParameterNV */ + struct CRProgramSymbol *symbolTable; + + /* Set with ProgramLocalParameterARB: */ + GLfloat parameters[CR_MAX_PROGRAM_LOCAL_PARAMS][4]; + + /* ARB info (this could be impossible to implement without parsing */ + GLint numInstructions; + GLint numTemporaries; + GLint numParameters; + GLint numAttributes; + GLint numAddressRegs; + GLint numAluInstructions; + GLint numTexInstructions; + GLint numTexIndirections; + + CRbitvalue dirtyNamedParams[CR_MAX_BITARRAY]; + CRbitvalue dirtyParam[CR_MAX_PROGRAM_LOCAL_PARAMS][CR_MAX_BITARRAY]; + CRbitvalue dirtyParams[CR_MAX_BITARRAY]; + CRbitvalue dirtyProgram[CR_MAX_BITARRAY]; +} CRProgram; + + + +typedef struct { + CRProgram *currentVertexProgram; + CRProgram *currentFragmentProgram; + GLint errorPos; + const GLubyte *errorString; + GLboolean loadedProgram; /* XXX temporary */ + + CRProgram *defaultVertexProgram; + CRProgram *defaultFragmentProgram; + + /* tracking matrices for vertex programs */ +#ifdef VBOX /* see state_program.c */ + GLenum TrackMatrix[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4]; + GLenum TrackMatrixTransform[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS / 4]; +#else + GLenum TrackMatrix[CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS / 4]; + GLenum TrackMatrixTransform[CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS / 4]; +#endif + + /* global/env params shared by all programs */ + GLfloat fragmentParameters[CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS][4]; + GLfloat vertexParameters[CR_MAX_VERTEX_PROGRAM_ENV_PARAMS][4]; + + CRHashTable *programHash; /* XXX belongs in shared state, actually */ + + GLuint vpProgramBinding; + GLuint fpProgramBinding; + GLboolean vpEnabled; /* GL_VERTEX_PROGRAM_NV / ARB*/ + GLboolean fpEnabled; /* GL_FRAGMENT_PROGRAM_NV */ + GLboolean fpEnabledARB; /* GL_FRAGMENT_PROGRAM_ARB */ + GLboolean vpPointSize; /* GL_VERTEX_PROGRAM_NV */ + GLboolean vpTwoSide; /* GL_VERTEX_PROGRAM_NV */ + + /* Indicates that we have to resend program data to GPU on first glMakeCurrent call with owning context */ + GLboolean bResyncNeeded; + +} CRProgramState; + + + +extern DECLEXPORT(void) crStateProgramInit(CRContext *ctx); +extern DECLEXPORT(void) crStateProgramDestroy(CRContext *ctx); + +extern DECLEXPORT(void) crStateProgramDiff(CRProgramBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +extern DECLEXPORT(void) crStateProgramSwitch(CRProgramBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +DECLEXPORT(void) crStateDiffAllPrograms(CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate); + +#endif /* CR_STATE_PROGRAM_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h b/src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h new file mode 100644 index 00000000..69af2a93 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_regcombiner.h @@ -0,0 +1,71 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_REGCOMBINER_H +#define CR_STATE_REGCOMBINER_H + +#include "state/cr_statetypes.h" +#include "state/cr_limits.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + GLenum a, b, c, d; + GLenum aMapping, bMapping, cMapping, dMapping; + GLenum aPortion, bPortion, cPortion, dPortion; + GLenum scale, bias; + GLenum abOutput, cdOutput, sumOutput; + GLboolean abDotProduct, cdDotProduct, muxSum; +} CRRegCombinerPortionState; + +typedef struct { + GLboolean enabledRegCombiners; + GLboolean enabledPerStageConstants; + + GLcolorf constantColor0; + GLcolorf constantColor1; + GLcolorf stageConstantColor0[CR_MAX_GENERAL_COMBINERS]; + GLcolorf stageConstantColor1[CR_MAX_GENERAL_COMBINERS]; + GLboolean colorSumClamp; + GLint numGeneralCombiners; + + CRRegCombinerPortionState rgb[CR_MAX_GENERAL_COMBINERS]; + CRRegCombinerPortionState alpha[CR_MAX_GENERAL_COMBINERS]; + + GLenum a, b, c, d, e, f, g; + GLenum aMapping, bMapping, cMapping, dMapping, eMapping, fMapping, gMapping; + GLenum aPortion, bPortion, cPortion, dPortion, ePortion, fPortion, gPortion; +} CRRegCombinerState; + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue regCombinerVars[CR_MAX_BITARRAY]; /* numGeneralCombiners, colorSumClamp */ + CRbitvalue regCombinerColor0[CR_MAX_BITARRAY]; + CRbitvalue regCombinerColor1[CR_MAX_BITARRAY]; + CRbitvalue regCombinerStageColor0[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY]; + CRbitvalue regCombinerStageColor1[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY]; + CRbitvalue regCombinerInput[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY]; /* rgb/alpha[].a/b/c/d, .aMapping, .aPortion */ + CRbitvalue regCombinerOutput[CR_MAX_GENERAL_COMBINERS][CR_MAX_BITARRAY]; /* rgb/alpha[].abOutput, .cdOutput, .sumOutput, .scale, .bias, .abDotProduct, .cdDotProduct, .muxSum */ + CRbitvalue regCombinerFinalInput[CR_MAX_BITARRAY]; /* a/b/c/d/e/f/g, aMapping, aPortion */ +} CRRegCombinerBits; + +DECLEXPORT(void) crStateRegCombinerInit( CRContext *ctx ); + +DECLEXPORT(void) crStateRegCombinerDiff(CRRegCombinerBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateRegCombinerSwitch( CRRegCombinerBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_REGCOMBINER_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h b/src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h new file mode 100644 index 00000000..d903e8a9 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_stateerror.h @@ -0,0 +1,16 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_ERROR_H +#define CR_STATE_ERROR_H + +#include "chromium.h" + +#include + +DECLEXPORT(void) crStateError( int line, const char *file, GLenum err, const char *format, ... ); + +#endif /* CR_STATE_ERROR_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h b/src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h new file mode 100644 index 00000000..4dad5ca6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_statetypes.h @@ -0,0 +1,209 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_TYPES_H +#define CR_STATE_TYPES_H + +#include "chromium.h" +#include "cr_bits.h" +#include "cr_matrix.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef GLfloat GLdefault; +#define CR_DEFAULTTYPE_FLOAT + +#define CR_MAXBYTE ((GLbyte) 0x7F) +#define CR_MAXUBYTE ((GLubyte) 0xFF) +#define CR_MAXSHORT ((GLshort) 0x7FFF) +#define CR_MAXUSHORT ((GLushort) 0xFFFF) +#define CR_MAXINT ((GLint) 0x7FFFFFFF) +#define CR_MAXUINT ((GLuint) 0xFFFFFFFF) +#define CR_MAXFLOAT 1.0f +#define CR_MAXDOUBLE 1.0 + +#define CRBITS_LENGTH 32 +#define CRBITS_ONES 0xFFFFFFFF +typedef unsigned int CRbitvalue; + +typedef struct { + GLfloat x1, x2, y1, y2; +} CRrectf; + +typedef struct { + GLint x1, y1, x2, y2; +} CRrecti; + +#define VECTOR(type, name) typedef struct { type x,y,z,w; } name +#define COLOR(type, name) typedef struct { type r,g,b,a; } name +#define TEXCOORD(type, name) typedef struct { type s,t,r,q; } name + +VECTOR(GLdefault,GLvector); +VECTOR(GLenum,GLvectore); +VECTOR(GLubyte,GLvectorub); +VECTOR(GLbyte,GLvectorb); +VECTOR(GLushort,GLvectorus); +VECTOR(GLshort,GLvectors); +VECTOR(GLint,GLvectori); +VECTOR(GLuint,GLvectorui); +/* These two are defined in cr_matrix.h */ +/* VECTOR(GLfloat,GLvectorf); */ +/* VECTOR(GLdouble,GLvectord); */ +COLOR(GLdefault,GLcolor); +COLOR(GLenum,GLcolore); +COLOR(GLubyte,GLcolorub); +COLOR(GLbyte,GLcolorb); +COLOR(GLushort,GLcolorus); +COLOR(GLshort,GLcolors); +COLOR(GLint,GLcolori); +COLOR(GLuint,GLcolorui); +COLOR(GLfloat,GLcolorf); +COLOR(GLdouble,GLcolord); +TEXCOORD(GLdefault,GLtexcoord); +TEXCOORD(GLenum,GLtexcoorde); +TEXCOORD(GLubyte,GLtexcoordub); +TEXCOORD(GLbyte,GLtexcoordb); +TEXCOORD(GLushort,GLtexcoordus); +TEXCOORD(GLshort,GLtexcoords); +TEXCOORD(GLint,GLtexcoordi); +TEXCOORD(GLuint,GLtexcoordui); +TEXCOORD(GLfloat,GLtexcoordf); +TEXCOORD(GLdouble,GLtexcoordd); + +#undef VECTOR +#undef COLOR +#undef TEXCOORD + +#define COMPARE_VECTOR(a,b) ((a)[0] != (b)[0] || (a)[1] != (b)[1] || (a)[2] != (b)[2] || (a)[3] != (b)[3]) +#define COMPARE_TEXCOORD(a,b) ((a)[0] != (b)[0] || (a)[1] != (b)[1] || (a)[2] != (b)[2] || (a)[3] != (b)[3]) +#define COMPARE_COLOR(x,y) ((x)[0] != (y)[0] || (x)[1] != (y)[1] || (x)[2] != (y)[2] || (x)[3] != (y)[3]) + +/* Assign scalers to short vectors: */ +#define ASSIGN_2V( V, V0, V1 ) \ +do { \ + (V)[0] = V0; \ + (V)[1] = V1; \ +} while(0) + +#define ASSIGN_3V( V, V0, V1, V2 ) \ +do { \ + (V)[0] = V0; \ + (V)[1] = V1; \ + (V)[2] = V2; \ +} while(0) + +#define ASSIGN_4V( V, V0, V1, V2, V3 ) \ +do { \ + (V)[0] = V0; \ + (V)[1] = V1; \ + (V)[2] = V2; \ + (V)[3] = V3; \ +} while(0) + + +/* Copy short vectors: */ +#define COPY_2V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ +} while (0) + +#define COPY_3V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ +} while (0) + +#define COPY_4V( DST, SRC ) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ + (DST)[3] = (SRC)[3]; \ +} while (0) + +#define COPY_2V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ +} while (0) + +#define COPY_3V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ + (DST)[2] = (CAST)(SRC)[2]; \ +} while (0) + +#define COPY_4V_CAST( DST, SRC, CAST ) \ +do { \ + (DST)[0] = (CAST)(SRC)[0]; \ + (DST)[1] = (CAST)(SRC)[1]; \ + (DST)[2] = (CAST)(SRC)[2]; \ + (DST)[3] = (CAST)(SRC)[3]; \ +} while (0) + +#if defined(__i386__) +#define COPY_4UBV(DST, SRC) \ +do { \ + *((GLuint*)(DST)) = *((GLuint*)(SRC)); \ +} while (0) +#else +/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */ +#define COPY_4UBV(DST, SRC) \ +do { \ + (DST)[0] = (SRC)[0]; \ + (DST)[1] = (SRC)[1]; \ + (DST)[2] = (SRC)[2]; \ + (DST)[3] = (SRC)[3]; \ +} while (0) +#endif + +#define COPY_2FV( DST, SRC ) \ +do { \ + const GLfloat *_tmp = (SRC); \ + (DST)[0] = _tmp[0]; \ + (DST)[1] = _tmp[1]; \ +} while (0) + +#define COPY_3FV( DST, SRC ) \ +do { \ + const GLfloat *_tmp = (SRC); \ + (DST)[0] = _tmp[0]; \ + (DST)[1] = _tmp[1]; \ + (DST)[2] = _tmp[2]; \ +} while (0) + +#define COPY_4FV( DST, SRC ) \ +do { \ + const GLfloat *_tmp = (SRC); \ + (DST)[0] = _tmp[0]; \ + (DST)[1] = _tmp[1]; \ + (DST)[2] = _tmp[2]; \ + (DST)[3] = _tmp[3]; \ +} while (0) + + + +#define COPY_SZ_4V(DST, SZ, SRC) \ +do { \ + switch (SZ) { \ + case 4: (DST)[3] = (SRC)[3]; \ + case 3: (DST)[2] = (SRC)[2]; \ + case 2: (DST)[1] = (SRC)[1]; \ + case 1: (DST)[0] = (SRC)[0]; \ + } \ +} while(0) + + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_TYPES_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h b/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h new file mode 100644 index 00000000..27823eb2 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_stencil.h @@ -0,0 +1,107 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_STENCIL_H +#define CR_STATE_STENCIL_H + +#include "cr_glstate.h" +#include "state/cr_statetypes.h" + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define CRSTATE_STENCIL_BUFFER_ID_FRONT 0 +#define CRSTATE_STENCIL_BUFFER_ID_BACK 1 +#define CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK 2 +#define CRSTATE_STENCIL_BUFFER_COUNT 3 + +/* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_FRONT or StencilXxxSeparate(GL_FRONT_AND_BACK) */ +#define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK 0 +/* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_FRONT) */ +#define CRSTATE_STENCIL_BUFFER_REF_ID_FRONT 1 +/* stencil buffer settings were accessed with StencilXxxSeparate(GL_FRONT_BACK) */ +#define CRSTATE_STENCIL_BUFFER_REF_ID_BACK 2 +/* stencil buffer settings were accessed with StencilXxx with ActiveStencilFaceEXT == GL_BACK */ +#define CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK 3 +#define CRSTATE_STENCIL_BUFFER_REF_COUNT 4 + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue func[CR_MAX_BITARRAY]; + CRbitvalue op[CR_MAX_BITARRAY]; + CRbitvalue clearValue[CR_MAX_BITARRAY]; + CRbitvalue writeMask[CR_MAX_BITARRAY]; +} CRStencilBits_v_33; + +typedef struct { + CRbitvalue func[CR_MAX_BITARRAY]; + CRbitvalue op[CR_MAX_BITARRAY]; +} CRStencilBufferRefBits; + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue enableTwoSideEXT[CR_MAX_BITARRAY]; + CRbitvalue activeStencilFace[CR_MAX_BITARRAY]; + CRbitvalue clearValue[CR_MAX_BITARRAY]; + CRbitvalue writeMask[CR_MAX_BITARRAY]; + /* note: here we use _BUFFER_REF_ rather than _REF_ because we track the way buffers are accessed here, + * to ensure the correct function is called on hw->chromium state restoration, + * i.e. we want to avoid always calling StencilXxxSeparate, but call StencilXxx when it was actually called */ + CRStencilBufferRefBits bufferRefs[CRSTATE_STENCIL_BUFFER_REF_COUNT]; +} CRStencilBits; + +typedef struct { + GLboolean stencilTest; + GLenum func; + GLint mask; + GLint ref; + GLenum fail; + GLenum passDepthFail; + GLenum passDepthPass; + GLint clearValue; + GLint writeMask; +} CRStencilState_v_33; + +typedef struct { + GLenum func; + GLint mask; + GLint ref; + GLenum fail; + GLenum passDepthFail; + GLenum passDepthPass; +} CRStencilBufferState; + +typedef struct { + /* true if stencil test is enabled */ + GLboolean stencilTest; + /* true if GL_EXT_stencil_two_side is enabled (glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT)) */ + GLboolean stencilTwoSideEXT; + /* GL_FRONT or GL_BACK */ + GLenum activeStencilFace; + GLint clearValue; + GLint writeMask; + CRStencilBufferState buffers[CRSTATE_STENCIL_BUFFER_COUNT]; +} CRStencilState; + +DECLEXPORT(void) crStateStencilInit(CRContext *ctx); +DECLEXPORT(void) crStateStencilBufferInit(CRStencilBufferState *s); + +DECLEXPORT(void) crStateStencilDiff(CRStencilBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateStencilSwitch(CRStencilBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_STENCIL_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h b/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h new file mode 100644 index 00000000..707db996 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_texture.h @@ -0,0 +1,250 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_TEXTURE_H +#define CR_STATE_TEXTURE_H + +#include "cr_hash.h" +#include "state/cr_statetypes.h" +#include "state/cr_limits.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Tells state tracker to rely on diff_api to store/load texture images + * and avoid host memory allocation. + */ +#define CR_STATE_NO_TEXTURE_IMAGE_STORE + +#if defined(CR_ARB_pixel_buffer_object) && !defined(CR_STATE_NO_TEXTURE_IMAGE_STORE) +#error CR_ARB_pixel_buffer_object not supported without CR_STATE_NO_TEXTURE_IMAGE_STORE +#endif + +#define CR_MAX_MIPMAP_LEVELS 20 + +typedef struct { + GLubyte redbits; + GLubyte greenbits; + GLubyte bluebits; + GLubyte alphabits; + GLubyte luminancebits; + GLubyte intensitybits; + GLubyte indexbits; +} CRTextureFormat; + +typedef struct { + GLubyte *img; + int bytes; + GLint width; /* width, height, depth includes the border */ + GLint height; + GLint depth; + GLint internalFormat; + GLint border; + GLenum format; + GLenum type; + int bytesPerPixel; +#if CR_ARB_texture_compression + GLboolean compressed; +#endif + GLboolean generateMipmap; + const CRTextureFormat *texFormat; + + CRbitvalue dirty[CR_MAX_BITARRAY]; +} CRTextureLevel; + +typedef struct { + GLenum target; + GLuint id; + GLuint hwid; + + /* The mipmap levels */ + CRTextureLevel *level[6]; /* 6 cube faces */ + + GLcolorf borderColor; + GLenum minFilter, magFilter; + GLenum wrapS, wrapT; +#ifdef CR_OPENGL_VERSION_1_2 + GLenum wrapR; + GLfloat priority; + GLfloat minLod; + GLfloat maxLod; + GLint baseLevel; + GLint maxLevel; +#endif +#ifdef CR_EXT_texture_filter_anisotropic + GLfloat maxAnisotropy; +#endif +#ifdef CR_ARB_depth_texture + GLenum depthMode; +#endif +#ifdef CR_ARB_shadow + GLenum compareMode; + GLenum compareFunc; +#endif +#ifdef CR_ARB_shadow_ambient + GLfloat compareFailValue; +#endif +#ifdef CR_SGIS_generate_mipmap + GLboolean generateMipmap; +#endif + GLboolean pinned; /* <- keep the texture alive if its ctxUsage reaches zero */ + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue imageBit[CR_MAX_BITARRAY]; + CRbitvalue paramsBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; + /* bitfield representing the object usage. 1 means the object is used by the context with the given bitid */ + CRbitvalue ctxUsage[CR_MAX_BITARRAY]; +} CRTextureObj; + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; + CRbitvalue current[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; + CRbitvalue objGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; + CRbitvalue eyeGen[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; + CRbitvalue genMode[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; + /* XXX someday create more bits for texture env state */ + CRbitvalue envBit[CR_MAX_TEXTURE_UNITS][CR_MAX_BITARRAY]; +} CRTextureBits; + +typedef struct { + /* Current texture objects (in terms of glBindTexture and glActiveTexture) */ + CRTextureObj *currentTexture1D; + CRTextureObj *currentTexture2D; + CRTextureObj *currentTexture3D; +#ifdef CR_ARB_texture_cube_map + CRTextureObj *currentTextureCubeMap; +#endif +#ifdef CR_NV_texture_rectangle + CRTextureObj *currentTextureRect; +#endif + + GLboolean enabled1D; + GLboolean enabled2D; + GLboolean enabled3D; +#ifdef CR_ARB_texture_cube_map + GLboolean enabledCubeMap; +#endif +#ifdef CR_NV_texture_rectangle + GLboolean enabledRect; +#endif +#ifdef CR_EXT_texture_lod_bias + GLfloat lodBias; +#endif + + GLenum envMode; + GLcolorf envColor; + + /* GL_ARB_texture_env_combine */ + GLenum combineModeRGB; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + GLenum combineModeA; /* GL_REPLACE, GL_DECAL, GL_ADD, etc. */ + GLenum combineSourceRGB[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */ + GLenum combineSourceA[3]; /* GL_PRIMARY_COLOR, GL_TEXTURE, etc. */ + GLenum combineOperandRGB[3]; /* SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */ + GLenum combineOperandA[3]; /* SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */ + GLfloat combineScaleRGB; /* 1 or 2 or 4 */ + GLfloat combineScaleA; /* 1 or 2 or 4 */ + + GLtexcoordb textureGen; + GLvectorf objSCoeff; + GLvectorf objTCoeff; + GLvectorf objRCoeff; + GLvectorf objQCoeff; + GLvectorf eyeSCoeff; + GLvectorf eyeTCoeff; + GLvectorf eyeRCoeff; + GLvectorf eyeQCoeff; + GLtexcoorde gen; + + /* These are only used for glPush/PopAttrib */ + CRTextureObj Saved1D; + CRTextureObj Saved2D; + CRTextureObj Saved3D; +#ifdef CR_ARB_texture_cube_map + CRTextureObj SavedCubeMap; +#endif +#ifdef CR_NV_texture_rectangle + CRTextureObj SavedRect; +#endif +} CRTextureUnit; + +typedef struct { + /* Default texture objects (name = 0) */ + CRTextureObj base1D; + CRTextureObj base2D; + CRTextureObj base3D; +#ifdef CR_ARB_texture_cube_map + CRTextureObj baseCubeMap; +#endif +#ifdef CR_NV_texture_rectangle + CRTextureObj baseRect; +#endif + + /* Proxy texture objects */ + CRTextureObj proxy1D; + CRTextureObj proxy2D; + CRTextureObj proxy3D; +#ifdef CR_ARB_texture_cube_map + CRTextureObj proxyCubeMap; +#endif +#ifdef CR_NV_texture_rectangle + CRTextureObj proxyRect; +#endif + + GLuint curTextureUnit; /* GL_ACTIVE_TEXTURE */ + + GLint maxLevel; /* number of mipmap levels possible: [0..max] */ + GLint max3DLevel; + GLint maxCubeMapLevel; + GLint maxRectLevel; + + GLboolean broadcastTextures; /*@todo what is it for?*/ + + /* Per-texture unit state: */ + CRTextureUnit unit[CR_MAX_TEXTURE_UNITS]; +} CRTextureState; + +DECLEXPORT(void) crStateTextureInit(CRContext *ctx); +DECLEXPORT(void) crStateTextureDestroy(CRContext *ctx); +DECLEXPORT(void) crStateTextureFree(CRContext *ctx); + +DECLEXPORT(void) crStateTextureInitTexture(GLuint name); +DECLEXPORT(CRTextureObj *) crStateTextureAllocate(GLuint name); + /*void crStateTextureDelete(GLuint name);*/ +DECLEXPORT(CRTextureObj *) crStateTextureGet(GLenum target, GLuint textureid); +DECLEXPORT(int) crStateTextureGetSize(GLenum target, GLenum level); +DECLEXPORT(const GLvoid *) crStateTextureGetData(GLenum target, GLenum level); + +DECLEXPORT(int) crStateTextureCheckDirtyImages(CRContext *from, CRContext *to, GLenum target, int textureUnit); + +DECLEXPORT(void) crStateTextureDiff(CRTextureBits *t, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateTextureSwitch(CRTextureBits *t, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +DECLEXPORT(void) crStateTextureObjectDiff(CRContext *fromCtx, + const CRbitvalue *bitID, + const CRbitvalue *nbitID, + CRTextureObj *tobj, GLboolean alwaysDirty); + +DECLEXPORT(void) crStateDiffAllTextureObjects( CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate ); + +DECLEXPORT(void) crStateDeleteTextureObjectData(CRTextureObj *tobj); +DECLEXPORT(void) crStateDeleteTextureObject(CRTextureObj *tobj); + +DECLEXPORT(GLuint) STATE_APIENTRY crStateTextureHWIDtoID(GLuint hwid); +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureHWID(GLuint id); +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureObjHWID(CRTextureObj *tobj); + +void crStateRegTextures(GLsizei n, GLuint *names); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_TEXTURE_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_transform.h b/src/VBox/GuestHost/OpenGL/include/state/cr_transform.h new file mode 100644 index 00000000..66e4709e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_transform.h @@ -0,0 +1,91 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef GLTRANS_H +#define GLTRANS_H + +#include "state/cr_statetypes.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define NUM_MATRICES 4 + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue *currentMatrix; /* points to one of the following */ + CRbitvalue matrixMode[CR_MAX_BITARRAY]; + CRbitvalue modelviewMatrix[CR_MAX_BITARRAY]; + CRbitvalue projectionMatrix[CR_MAX_BITARRAY]; + CRbitvalue colorMatrix[CR_MAX_BITARRAY]; + CRbitvalue textureMatrix[CR_MAX_BITARRAY]; + CRbitvalue programMatrix[CR_MAX_BITARRAY]; + CRbitvalue clipPlane[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue base[CR_MAX_BITARRAY]; +} CRTransformBits; + +typedef struct { + CRmatrix *top; /* points into stack */ + CRmatrix *stack; /* array [maxDepth] of CRmatrix */ + GLuint depth; /* 0 <= depth < maxDepth */ + GLuint maxDepth; /* size of stack[] array */ +} CRMatrixStack; + +typedef struct { + GLvectord *clipPlane; + GLboolean *clip; + + GLenum matrixMode; + + /* matrix stacks */ + CRMatrixStack modelViewStack; + CRMatrixStack projectionStack; + CRMatrixStack colorStack; + CRMatrixStack textureStack[CR_MAX_TEXTURE_UNITS]; + CRMatrixStack programStack[CR_MAX_PROGRAM_MATRICES]; + CRMatrixStack *currentStack; + + GLboolean modelViewProjectionValid; + CRmatrix modelViewProjection; /* product of modelview and projection */ + +#ifdef CR_OPENGL_VERSION_1_2 + GLboolean rescaleNormals; +#endif +#ifdef CR_IBM_rasterpos_clip + GLboolean rasterPositionUnclipped; +#endif + GLboolean normalize; +} CRTransformState; + + +DECLEXPORT(void) crStateTransformInit(CRContext *ctx); +DECLEXPORT(void) crStateTransformDestroy(CRContext *ctx); + +DECLEXPORT(void) crStateInitMatrixStack(CRMatrixStack *stack, int maxDepth); + +DECLEXPORT(void) crStateLoadMatrix(const CRmatrix *m); + +DECLEXPORT(void) crStateTransformUpdateTransform(CRTransformState *t); +DECLEXPORT(void) crStateTransformXformPoint(CRTransformState *t, GLvectorf *p); + +DECLEXPORT(void) crStateTransformXformPointMatrixf(const CRmatrix *m, GLvectorf *p); +DECLEXPORT(void) crStateTransformXformPointMatrixd(const CRmatrix *m, GLvectord *p); + +DECLEXPORT(void) crStateTransformDiff(CRTransformBits *t, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +DECLEXPORT(void) crStateTransformSwitch(CRTransformBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_TRANSFORM_H */ diff --git a/src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h b/src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h new file mode 100644 index 00000000..6ea7b7a2 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/include/state/cr_viewport.h @@ -0,0 +1,57 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_STATE_VIEWPORT_H +#define CR_STATE_VIEWPORT_H + +#include "state/cr_statetypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + CRbitvalue dirty[CR_MAX_BITARRAY]; + CRbitvalue v_dims[CR_MAX_BITARRAY]; + CRbitvalue s_dims[CR_MAX_BITARRAY]; + CRbitvalue enable[CR_MAX_BITARRAY]; + CRbitvalue depth[CR_MAX_BITARRAY]; +} CRViewportBits; + +typedef struct { + /* Viewport state */ + GLint viewportX; + GLint viewportY; + GLint viewportW; + GLint viewportH; + GLclampd nearClip; + GLclampd farClip; + GLboolean viewportValid; + + /* Scissor state */ + GLboolean scissorTest; + GLint scissorX; + GLint scissorY; + GLsizei scissorW; + GLsizei scissorH; + GLboolean scissorValid; +} CRViewportState; + +DECLEXPORT(void) crStateViewportInit(CRContext *ctx); + +DECLEXPORT(void) crStateViewportApply( CRViewportState *v, GLvectorf *p ); +DECLEXPORT(void) crStateViewportMakeCurrent(CRViewportState *v, CRViewportBits *vb); + +DECLEXPORT(void) crStateViewportDiff(CRViewportBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); +DECLEXPORT(void) crStateViewportSwitch(CRViewportBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_VIEWPORT_H */ diff --git a/src/VBox/GuestHost/OpenGL/packer/Makefile.kup b/src/VBox/GuestHost/OpenGL/packer/Makefile.kup new file mode 100644 index 00000000..e69de29b diff --git a/src/VBox/GuestHost/OpenGL/packer/opcodes.py b/src/VBox/GuestHost/OpenGL/packer/opcodes.py new file mode 100755 index 00000000..798ca677 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/opcodes.py @@ -0,0 +1,106 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This script generates include/cr_opcodes.h from the gl_header.parsed file. + +from __future__ import print_function +import sys; +import string; +import re; + +import apiutil + +apiutil.CopyrightC() + +print("") +print("/* DO NOT EDIT - THIS FILE GENERATED BY THE opcodes.py SCRIPT */") +print("") +print("#ifndef CR_OPCODES_H") +print("#define CR_OPCODES_H") +print("") + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") +assert len(keys) > 0 + +print("/* Functions with no return value and input-only parameters */") +print("typedef enum {") + +enum_index = 0 +for func in keys: + if "pack" in apiutil.ChromiumProps(func): + print("\t%s = %d," % ( apiutil.OpcodeName(func), enum_index )) + enum_index = enum_index + 1 + +print("\tCR_EXTEND_OPCODE=%d," % enum_index) +enum_index = enum_index + 1 +print("\tCR_CMDBLOCKBEGIN_OPCODE=%d," % enum_index) +enum_index = enum_index + 1 +print("\tCR_CMDBLOCKEND_OPCODE=%d," % enum_index) +enum_index = enum_index + 1 +print("\tCR_CMDBLOCKFLUSH_OPCODE=%d," % enum_index) +print("\tCR_NOP_OPCODE=255") +if enum_index > 254: + # This would have saved Mike some grief if it had been here earlier. + print >> sys.stderr, "You have more than 255 opcodes! You've been adding functions to" + print >> sys.stderr, "glapi_parser/APIspec! Each new function you add" + print >> sys.stderr, "gets an opcode assigned to it. Fortunately for you, we have" + print >> sys.stderr, "an ``extend'' opcode. Please mark the function as" + print >> sys.stderr, "'extpack' in APIspec so as to keep the main opcode pool" + print >> sys.stderr, "less than 255! THIS IS A CATASTROPHIC FAILURE, and I WILL NOT CONTINUE!" + print >> sys.stderr, "I'm putting an error in the generated header file so you won't miss" + print >> sys.stderr, "this even if you're doing a 'make -k.'" + print("#error -- more than 255 opcodes!") + sys.exit(-1) +print("} CROpcode;\n") + +# count up number of extended opcode commands +num_extends = 0 +num_auto_codes = 0 +for func in keys: + if "extpack" in apiutil.ChromiumProps(func): + num_extends += 1 + if apiutil.ChromiumRelOpCode(func) < 0: + num_auto_codes += 1 + +# sanity check for compatibility breakage +# we currently have 304 +if num_auto_codes != 304: + print >> sys.stderr, "number of auto-generated op-codes should be 304, but is " + str(num_auto_codes) + print >> sys.stderr, "which breaks backwards compatibility" + print >> sys.stderr, "if this is really what you want to do, please adjust this script" + print >> sys.stderr, "to handle a new auto-generated opcodes count" + print("#error -- num_auto_codes should be 304, but is " + str(num_auto_codes)) + sys.exit(-1) + +print("/* Functions with a return value or output parameters */") +print("typedef enum {") + +opcode_index = 0 +enum_index = 0 +chrelopcodes = {} +for func in keys: + if "extpack" in apiutil.ChromiumProps(func): + opcodeName = apiutil.ExtendedOpcodeName(func) + chrelopcode = apiutil.ChromiumRelOpCode(func) + opcode = -1 + if chrelopcode >= 0: + if not chrelopcode in chrelopcodes: + chrelopcodes[chrelopcode] = chrelopcode + else: + print >> sys.stderr, "non-unique chrelopcode: " + str(chrelopcode) + print("#error -- non-unique chrelopcode: " + str(num_auto_codes)) + sys.exit(-1) + opcode = num_auto_codes + chrelopcode + else: + opcode = opcode_index + opcode_index = opcode_index + 1 + + if enum_index != num_extends-1: + print("\t%s = %d," % (opcodeName, opcode )) + else: + print("\t%s = %d" % (opcodeName, opcode )) + enum_index = enum_index + 1 +print("} CRExtendOpcode;\n") +print("#endif /* CR_OPCODES_H */") diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_arrays.c b/src/VBox/GuestHost/OpenGL/packer/pack_arrays.c new file mode 100644 index 00000000..540865c6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_arrays.c @@ -0,0 +1,209 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_error.h" +#include "iprt/types.h" + +#define UNUSED(x) ((void)(x)) +/** + * \mainpage Packer + * + * \section PackerIntroduction Introduction + * + * Chromium consists of all the top-level files in the cr + * directory. The packer module basically takes care of API dispatch, + * and OpenGL state management. + * + */ + +void PACK_APIENTRY crPackVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + /* Packing this command is only useful if we have server-side vertex + * arrays - GL_ARB_vertex_buffer_object. Note that pointer will really + * be an offset into a server-side buffer. + * @todo Because of that we'd only transfer lowest 32bit as there're no 4gb+VBOs (yet?). + * Look at glgets regarding max vertices in arrays. + */ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 24; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_VERTEXPOINTER_EXTEND_OPCODE ); + WRITE_DATA( 8, GLint, size ); + WRITE_DATA( 12, GLenum, type ); + WRITE_DATA( 16, GLsizei, stride ); + WRITE_DATA( 20, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 24; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_COLORPOINTER_EXTEND_OPCODE ); + WRITE_DATA( 8, GLint, size ); + WRITE_DATA( 12, GLenum, type ); + WRITE_DATA( 16, GLsizei, stride ); + WRITE_DATA( 20, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 20; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_NORMALPOINTER_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, type ); + WRITE_DATA( 12, GLsizei, stride ); + WRITE_DATA( 16, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 24; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_TEXCOORDPOINTER_EXTEND_OPCODE ); + WRITE_DATA( 8, GLint, size ); + WRITE_DATA( 12, GLenum, type ); + WRITE_DATA( 16, GLsizei, stride ); + WRITE_DATA( 20, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackEdgeFlagPointer( GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_EDGEFLAGPOINTER_EXTEND_OPCODE ); + WRITE_DATA( 8, GLsizei, stride ); + WRITE_DATA( 12, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackIndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 20; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_INDEXPOINTER_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, type ); + WRITE_DATA( 12, GLsizei, stride ); + WRITE_DATA( 16, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackSecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 24; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_SECONDARYCOLORPOINTEREXT_EXTEND_OPCODE ); + WRITE_DATA( 8, GLint, size ); + WRITE_DATA( 12, GLenum, type ); + WRITE_DATA( 16, GLsizei, stride ); + WRITE_DATA( 20, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackFogCoordPointerEXT( GLenum type, GLsizei stride, const GLvoid * pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 20; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_FOGCOORDPOINTEREXT_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, type ); + WRITE_DATA( 12, GLsizei, stride ); + WRITE_DATA( 16, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttribPointerARB( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 32; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_VERTEXATTRIBPOINTERARB_EXTEND_OPCODE ); + WRITE_DATA( 8, GLint, index ); + WRITE_DATA( 12, GLint, size ); + WRITE_DATA( 16, GLenum, type ); + WRITE_DATA( 20, GLboolean, normalized ); + WRITE_DATA( 24, GLsizei, stride ); + WRITE_DATA( 28, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttribPointerNV( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 28; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_VERTEXATTRIBPOINTERNV_EXTEND_OPCODE ); + WRITE_DATA( 8, GLint, index ); + WRITE_DATA( 12, GLint, size ); + WRITE_DATA( 16, GLenum, type ); + WRITE_DATA( 20, GLsizei, stride ); + WRITE_DATA( 24, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 20; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_INTERLEAVEDARRAYS_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, format ); + WRITE_DATA( 12, GLsizei, stride ); + WRITE_DATA( 16, GLuint, (GLuint) ((uintptr_t) pointer) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void PACK_APIENTRY crPackVertexArrayRangeNV( GLsizei length, const GLvoid *pointer ) +{ + UNUSED( length ); + UNUSED( pointer ); + crWarning( "Unimplemented crPackVertexArrayRangeNV" ); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_bbox.h b/src/VBox/GuestHost/OpenGL/packer/pack_bbox.h new file mode 100644 index 00000000..8602f664 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_bbox.h @@ -0,0 +1,183 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_PACK_BBOX_H +#define CR_PACK_BBOX_H + +#include "cr_pack.h" + +#define UPDATE_1D_BBOX() \ +if (pc->bounds_min.x > fx) pc->bounds_min.x = fx;\ +if (pc->bounds_min.y > 0.0f) pc->bounds_min.y = 0.0f;\ +if (pc->bounds_min.z > 0.0f) pc->bounds_min.z = 0.0f;\ +if (pc->bounds_max.x < fx) pc->bounds_max.x = fx;\ +if (pc->bounds_max.y < 0.0f) pc->bounds_max.y = 0.0f;\ +if (pc->bounds_max.z < 0.0f) pc->bounds_max.z = 0.0f + +#define UPDATE_2D_BBOX() \ +if (pc->bounds_min.x > fx) pc->bounds_min.x = fx;\ +if (pc->bounds_min.y > fy) pc->bounds_min.y = fy;\ +if (pc->bounds_min.z > 0.0f) pc->bounds_min.z = 0.0f;\ +if (pc->bounds_max.x < fx) pc->bounds_max.x = fx;\ +if (pc->bounds_max.y < fy) pc->bounds_max.y = fy;\ +if (pc->bounds_max.z < 0.0f) pc->bounds_max.z = 0.0f + +#define UPDATE_3D_BBOX() \ +if (pc->bounds_min.x > fx) pc->bounds_min.x = fx; \ +if (pc->bounds_min.y > fy) pc->bounds_min.y = fy; \ +if (pc->bounds_min.z > fz) pc->bounds_min.z = fz; \ +if (pc->bounds_max.x < fx) pc->bounds_max.x = fx; \ +if (pc->bounds_max.y < fy) pc->bounds_max.y = fy; \ +if (pc->bounds_max.z < fz) pc->bounds_max.z = fz + +#ifdef SIMD +#define UPDATE_3D_BBOX_SIMD() \ +__asm {\ + __asm movups xmm0, fx\ + __asm movaps xmm1, pc->bounds_min.x\ + __asm movaps xmm2, pc->bounds_max.x\ + __asm minps xmm1, xmm0\ + __asm maxps xmm2, xmm0\ + __asm movaps pc->bounds_min.x, xmm1\ + __asm movaps pc->bounds_max.x, xmm2\ +} +#define UPDATE_3D_BBOX_SIMD_PACK() \ +__asm {\ + __asm mov ecx, [data_ptr]\ + __asm movups xmm0, fx\ + __asm movaps xmm1, pc->bounds_min.x\ + __asm movaps xmm2, pc->bounds_max.x\ + __asm minps xmm1, xmm0\ + __asm maxps xmm2, xmm0\ + __asm movaps pc->bounds_min.x, xmm1\ + __asm movaps pc->bounds_max.x, xmm2\ + __asm movups [ecx], xmm0\ +} +#define UPDATE_3DV_BBOX_SIMD() \ +__asm {\ + __asm mov eax, [v]\ + __asm mov ecx, [data_ptr]\ + __asm movups xmm0, [eax]\ + __asm movaps xmm1, pc->bounds_min.x\ + __asm movaps xmm2, pc->bounds_max.x\ + __asm minps xmm1, xmm0\ + __asm maxps xmm2, xmm0\ + __asm movaps pc->bounds_min.x, xmm1\ + __asm movaps pc->bounds_max.x, xmm2\ + __asm movups [ecx], xmm0\ +} +#else +#define UPDATE_3DV_BBOX_SIMD() { CREATE_3D_VFLOATS(); UPDATE_3D_BBOX();} +#define UPDATE_3D_BBOX_SIMD() UPDATE_3D_BBOX() +#endif + +#define CREATE_1D_FLOATS() \ + GLfloat fx = (GLfloat) x; + +#define CREATE_2D_FLOATS() \ + GLfloat fx = (GLfloat) x; \ + GLfloat fy = (GLfloat) y + +#define CREATE_3D_FLOATS() \ + GLfloat fx = (GLfloat) x; \ + GLfloat fy = (GLfloat) y; \ + GLfloat fz = (GLfloat) z + +#define CREATE_4D_FLOATS() \ + GLfloat fx = (GLfloat) x; \ + GLfloat fy = (GLfloat) y; \ + GLfloat fz = (GLfloat) z; \ + GLfloat fw = (GLfloat) w; \ + fx /= fw; fy /= fw; fz/= fw + +/* For glVertexAttrib4N*ARB */ +#define CREATE_3D_FLOATS_B_NORMALIZED() \ + GLfloat fx = (GLfloat) x * (1.0 / 128.0); \ + GLfloat fy = (GLfloat) y * (1.0 / 128.0); \ + GLfloat fz = (GLfloat) z * (1.0 / 128.0); + +#define CREATE_3D_FLOATS_UB_NORMALIZED() \ + GLfloat fx = (GLfloat) x * (1.0 / 255.0); \ + GLfloat fy = (GLfloat) y * (1.0 / 255.0); \ + GLfloat fz = (GLfloat) z * (1.0 / 255.0); + +#define CREATE_3D_FLOATS_US_NORMALIZED() \ + GLfloat fx = (GLfloat) x * (1.0 / 65535.0); \ + GLfloat fy = (GLfloat) y * (1.0 / 65535.0); \ + GLfloat fz = (GLfloat) z * (1.0 / 65535.0); + + +#define CREATE_1D_VFLOATS() \ + GLfloat fx = (GLfloat) v[0]; + +#define CREATE_2D_VFLOATS() \ + GLfloat fx = (GLfloat) v[0]; \ + GLfloat fy = (GLfloat) v[1] + +#define CREATE_3D_VFLOATS() \ + GLfloat fx = (GLfloat) v[0]; \ + GLfloat fy = (GLfloat) v[1]; \ + GLfloat fz = (GLfloat) v[2] + +#define CREATE_4D_VFLOATS() \ + GLfloat fx = (GLfloat) v[0]; \ + GLfloat fy = (GLfloat) v[1]; \ + GLfloat fz = (GLfloat) v[2]; \ + GLfloat fw = (GLfloat) v[3]; \ + fx /= fw; fy /= fw; fz/= fw + +/* For glVertexAttrib4N*ARB */ +#define CREATE_4D_FLOATS_UB_NORMALIZED() \ + GLfloat fx = (GLfloat) (x * (1.0 / 255.0)); \ + GLfloat fy = (GLfloat) (y * (1.0 / 255.0)); \ + GLfloat fz = (GLfloat) (z * (1.0 / 255.0)); \ + GLfloat fw = (GLfloat) (w * (1.0 / 255.0)); \ + fx /= fw; fy /= fw; fz/= fw + +#define CREATE_4D_VFLOATS_B_NORMALIZED() \ + GLfloat fx = (GLfloat) (v[0] * (1.0 / 128.0)); \ + GLfloat fy = (GLfloat) (v[1] * (1.0 / 128.0)); \ + GLfloat fz = (GLfloat) (v[2] * (1.0 / 128.0)); \ + GLfloat fw = (GLfloat) (v[3] * (1.0 / 128.0)); \ + fx /= fw; fy /= fw; fz/= fw + +#define CREATE_4D_VFLOATS_S_NORMALIZED() \ + GLfloat fx = (GLfloat) (2.0 * v[0] + 1.0) / ((GLfloat) (0xffff)); \ + GLfloat fy = (GLfloat) (2.0 * v[1] + 1.0) / ((GLfloat) (0xffff)); \ + GLfloat fz = (GLfloat) (2.0 * v[2] + 1.0) / ((GLfloat) (0xffff)); \ + GLfloat fw = (GLfloat) (2.0 * v[3] + 1.0) / ((GLfloat) (0xffff)); \ + fx /= fw; fy /= fw; fz/= fw + +#define CREATE_4D_VFLOATS_I_NORMALIZED() \ + GLfloat fx = (GLfloat) (2.0 * v[0] + 1.0) / ((GLfloat) (0xffffffff)); \ + GLfloat fy = (GLfloat) (2.0 * v[1] + 1.0) / ((GLfloat) (0xffffffff)); \ + GLfloat fz = (GLfloat) (2.0 * v[2] + 1.0) / ((GLfloat) (0xffffffff)); \ + GLfloat fw = (GLfloat) (2.0 * v[3] + 1.0) / ((GLfloat) (0xffffffff)); \ + fx /= fw; fy /= fw; fz/= fw + +#define CREATE_4D_VFLOATS_UB_NORMALIZED() \ + GLfloat fx = (GLfloat) (v[0] * (1.0 / 255.0)); \ + GLfloat fy = (GLfloat) (v[1] * (1.0 / 255.0)); \ + GLfloat fz = (GLfloat) (v[2] * (1.0 / 255.0)); \ + GLfloat fw = (GLfloat) (v[3] * (1.0 / 255.0)); \ + fx /= fw; fy /= fw; fz/= fw + +#define CREATE_4D_VFLOATS_US_NORMALIZED() \ + GLfloat fx = (GLfloat) (v[0] * (1.0 / 65535.0)); \ + GLfloat fy = (GLfloat) (v[1] * (1.0 / 65535.0)); \ + GLfloat fz = (GLfloat) (v[2] * (1.0 / 65535.0)); \ + GLfloat fw = (GLfloat) (v[3] * (1.0 / 65535.0)); \ + fx /= fw; fy /= fw; fz/= fw + +#define CREATE_4D_VFLOATS_UI_NORMALIZED() \ + GLfloat fx = v[0] / ((GLfloat) (0xffffffff)); \ + GLfloat fy = v[1] / ((GLfloat) (0xffffffff)); \ + GLfloat fz = v[2] / ((GLfloat) (0xffffffff)); \ + GLfloat fw = v[3] / ((GLfloat) (0xffffffff)); \ + fx /= fw; fy /= fw; fz/= fw + +#endif /* CR_PACK_BBOX_H */ + diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c b/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c new file mode 100644 index 00000000..e6057639 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_beginend.c @@ -0,0 +1,86 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_protocol.h" + +void PACK_APIENTRY crPackBegin( GLenum mode ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + + if (CR_CMDBLOCK_IS_STARTED(pc, CRPACKBLOCKSTATE_OP_BEGIN)) + { + WARN(("recursive begin?")); + return; + } + + CR_CMDBLOCK_BEGIN( pc, CRPACKBLOCKSTATE_OP_BEGIN ); +#ifndef VBOX + if (pc->buffer.canBarf) + { + if (!pc->buffer.holds_BeginEnd) + pc->Flush( pc->flush_arg ); + pc->buffer.in_BeginEnd = 1; + pc->buffer.holds_BeginEnd = 1; + } +#endif + CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, 4, GL_FALSE); + pc->current.begin_data = data_ptr; + pc->current.begin_op = pc->buffer.opcode_current; + pc->current.attribsUsedMask = 0; + WRITE_DATA( 0, GLenum, mode ); + WRITE_OPCODE( pc, CR_BEGIN_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackBeginSWAP( GLenum mode ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; +#ifndef VBOX + if (pc->buffer.canBarf) + { + if (!pc->buffer.holds_BeginEnd) + pc->Flush( pc->flush_arg ); + pc->buffer.in_BeginEnd = 1; + pc->buffer.holds_BeginEnd = 1; + } +#endif + CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, 4, GL_FALSE); + pc->current.begin_data = data_ptr; + pc->current.begin_op = pc->buffer.opcode_current; + pc->current.attribsUsedMask = 0; + WRITE_DATA( 0, GLenum, SWAP32(mode) ); + WRITE_OPCODE( pc, CR_BEGIN_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackEnd( void ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + CR_GET_BUFFERED_POINTER_NO_ARGS( pc ); + WRITE_OPCODE( pc, CR_END_OPCODE ); + pc->buffer.in_BeginEnd = 0; + CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_BEGIN ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackEndSWAP( void ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + CR_GET_BUFFERED_POINTER_NO_ARGS( pc ); + WRITE_OPCODE( pc, CR_END_OPCODE ); + pc->buffer.in_BeginEnd = 0; + CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_BEGIN ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_bounds.c b/src/VBox/GuestHost/OpenGL/packer/pack_bounds.c new file mode 100644 index 00000000..191383bd --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_bounds.c @@ -0,0 +1,50 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_mem.h" + +void PACK_APIENTRY crPackBoundsInfoCR( CR_PACKER_CONTEXT_ARGDECL const CRrecti *bounds, const GLbyte *payload, GLint len, GLint num_opcodes ) +{ + CR_GET_PACKER_CONTEXT(pc); + /* Don't get the buffered_ptr here because we've already + * verified that there's enough space for everything. */ + + unsigned char *data_ptr; + int len_aligned, total_len; + + CR_LOCK_PACKER_CONTEXT(pc); + + data_ptr = pc->buffer.data_current; + len_aligned = ( len + 0x3 ) & ~0x3; + total_len = 24 + len_aligned; + + WRITE_DATA( 0, int, total_len ); + WRITE_DATA( 4, int, bounds->x1 ); + WRITE_DATA( 8, int, bounds->y1 ); + WRITE_DATA( 12, int, bounds->x2 ); + WRITE_DATA( 16, int, bounds->y2 ); + WRITE_DATA( 20, int, num_opcodes ); + + /* skip the BOUNDSINFO */ + data_ptr += 24; + + /* put in padding opcodes (deliberately bogus) */ + switch ( len_aligned - len ) + { + case 3: *data_ptr++ = 0xff; RT_FALL_THRU(); + case 2: *data_ptr++ = 0xff; RT_FALL_THRU(); + case 1: *data_ptr++ = 0xff; RT_FALL_THRU(); + default: break; + } + + crMemcpy( data_ptr, payload, len ); + + WRITE_OPCODE( pc, CR_BOUNDSINFOCR_OPCODE ); + pc->buffer.data_current += 24 + len_aligned; + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c b/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c new file mode 100644 index 00000000..003b76c0 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_buffer.c @@ -0,0 +1,533 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "cr_string.h" +#include "packer.h" +#include "cr_error.h" +#include "cr_protocol.h" +#ifndef IN_RING0 +#include "cr_unpack.h" +#endif + +#ifndef IN_RING0 +void crWriteUnalignedDouble( void *buffer, double d ) +{ + unsigned int *ui = (unsigned int *) buffer; + ui[0] = ((unsigned int *) &d)[0]; + ui[1] = ((unsigned int *) &d)[1]; +} + +void crWriteSwappedDouble( void *buffer, double d ) +{ + unsigned int *ui = (unsigned int *) buffer; + ui[0] = SWAP32(((unsigned int *) &d)[1]); + ui[1] = SWAP32(((unsigned int *) &d)[0]); +} + +double crReadUnalignedDouble( const void *buffer ) +{ + const unsigned int *ui = (unsigned int *) buffer; + double d; + ((unsigned int *) &d)[0] = ui[0]; + ((unsigned int *) &d)[1] = ui[1]; + return d; +} +#endif +/* + * We need the packer to run as efficiently as possible. To avoid one + * pointer dereference from the CRPackContext to the current CRPackBuffer, + * we keep a _copy_ of the current CRPackBuffer in the CRPackContext and + * operate on the fields in CRPackContext, rather than the CRPackBuffer. + * + * To keep things in sync, when we change a context's + * buffer, we have to use the crPackSet/GetBuffer() functions. + */ + +void crPackSetBuffer( CRPackContext *pc, CRPackBuffer *buffer ) +{ + CRASSERT( pc ); + CRASSERT( buffer ); + + if (pc->currentBuffer == buffer) + return; /* re-bind is no-op */ + + if (pc->currentBuffer) { + /* Another buffer currently bound to this packer (shouldn't normally occur) + * Release it. Fixes Ensight issue. + */ + crPackReleaseBuffer(pc); + } + + CRASSERT( pc->currentBuffer == NULL); /* release if NULL? */ + CRASSERT( buffer->context == NULL ); + + /* bind context to buffer */ + pc->currentBuffer = buffer; + buffer->context = pc; + + /* update the context's packing fields with those from the buffer */ + pc->buffer = *buffer; /* struct copy */ +} + +#ifndef IN_RING0 +/* This is useful for debugging packer problems */ +void crPackSetBufferDEBUG( const char *file, int line, CRPackContext *pc, CRPackBuffer *buffer) + +{ + crPackSetBuffer( pc, buffer ); + /* record debugging info */ + pc->file = crStrdup(file); + pc->line = line; +} +#endif + +/* + * Release the buffer currently attached to the context. + * Update/resync data structures. + */ +void crPackReleaseBuffer( CRPackContext *pc ) +{ + CRPackBuffer *buf; + CRASSERT( pc ); + + if (!pc->currentBuffer) { + crWarning("crPackReleaseBuffer called with no current buffer"); + return; /* nothing to do */ + } + + CRASSERT( pc->currentBuffer->context == pc ); + + /* buffer to release */ + buf = pc->currentBuffer; + + /* copy context's fields back into the buffer to update it */ + *buf = pc->buffer; /* struct copy */ + + /* unbind buffer from context */ + buf->context = NULL; + pc->currentBuffer = NULL; + + /* zero-out context's packing fields just to be safe */ + crMemZero(&(pc->buffer), sizeof(pc->buffer)); + + /* update the debugging fields */ + if (pc->file) + crFree(pc->file); + pc->file = NULL; + pc->line = -1; +} + +void crPackFlushFunc( CRPackContext *pc, CRPackFlushFunc ff ) +{ + pc->Flush = ff; +} + +void crPackFlushArg( CRPackContext *pc, void *flush_arg ) +{ + pc->flush_arg = flush_arg; +} + +void crPackSendHugeFunc( CRPackContext *pc, CRPackSendHugeFunc shf ) +{ + pc->SendHuge = shf; +} + +/* + * This basically resets the buffer attached to to the default, empty + * state. + */ +void crPackResetPointers( CRPackContext *pc ) +{ + const GLboolean geom_only = pc->buffer.geometry_only; /* save this flag */ + const GLboolean holds_BeginEnd = pc->buffer.holds_BeginEnd; + const GLboolean in_BeginEnd = pc->buffer.in_BeginEnd; + const GLboolean canBarf = pc->buffer.canBarf; + CRPackBuffer *buf = pc->currentBuffer; + CRASSERT(buf); + crPackInitBuffer( buf, buf->pack, buf->size, buf->mtu +#ifdef IN_RING0 + , 0 +#endif + ); + pc->buffer.geometry_only = geom_only; /* restore the flag */ + pc->buffer.holds_BeginEnd = holds_BeginEnd; + pc->buffer.in_BeginEnd = in_BeginEnd; + pc->buffer.canBarf = canBarf; +} + + +/** + * Return max number of opcodes that'll fit in the given buffer size. + * Each opcode has at least a 1-word payload, so opcodes can occupy at most + * 20% of the space. + */ +int +crPackMaxOpcodes( int buffer_size ) +{ + int n = ( buffer_size - sizeof(CRMessageOpcodes) ) / 5; + /* Don't forget to add one here in case the buffer size is not + * divisible by 4. Thanks to Ken Moreland for finding this. + */ + n++; + /* round up to multiple of 4 */ + n = (n + 0x3) & (~0x3); + return n; +} + + +/** + * Return max number of data bytes that'll fit in the given buffer size. + */ +int +crPackMaxData( int buffer_size ) +{ + int n = buffer_size - sizeof(CRMessageOpcodes); + n -= crPackMaxOpcodes(buffer_size); + return n; +} + + +/** + * Initialize the given CRPackBuffer object. + * The buffer may or may not be currently bound to a CRPackContext. + * + * Opcodes and operands are packed into a buffer in a special way. + * Opcodes start at opcode_start and go downward in memory while operands + * start at data_start and go upward in memory. The buffer is full when we + * either run out of opcode space or operand space. + * + * Diagram (memory addresses increase upward): + * + * data_end -> | | <- buf->pack + buf->size + * +---------+ + * | | + * | | + * | operands| + * | | + * | | + * data_start -> +---------+ + * opcode_start -> | | + * | | + * | opcodes | + * | | + * | | + * opcode_end -> +---------+ <- buf->pack + * + * \param buf the CRPackBuffer to initialize + * \param pack the address of the buffer for packing opcodes/operands. + * \param size size of the buffer, in bytes + * \param mtu max transmission unit size, in bytes. When the buffer + * has 'mtu' bytes in it, we have to send it. The MTU might + * be somewhat smaller than the buffer size. + */ +void crPackInitBuffer( CRPackBuffer *buf, void *pack, int size, int mtu +#ifdef IN_RING0 + , unsigned int num_opcodes +#endif + ) +{ +#ifndef IN_RING0 + unsigned int num_opcodes; +#endif + + CRASSERT(mtu <= size); + + buf->size = size; + buf->mtu = mtu; + buf->pack = pack; + +#ifdef IN_RING0 + if(num_opcodes) + { + num_opcodes = (num_opcodes + 0x3) & (~0x3); + } + else +#endif + { + num_opcodes = crPackMaxOpcodes( buf->size ); + } + + buf->data_start = + (unsigned char *) buf->pack + num_opcodes + sizeof(CRMessageOpcodes); + buf->data_current = buf->data_start; + buf->data_end = (unsigned char *) buf->pack + buf->size; + + buf->opcode_start = buf->data_start - 1; + buf->opcode_current = buf->opcode_start; + buf->opcode_end = buf->opcode_start - num_opcodes; + + buf->geometry_only = GL_FALSE; + buf->holds_BeginEnd = GL_FALSE; + buf->in_BeginEnd = GL_FALSE; + buf->canBarf = GL_FALSE; + + if (buf->context) { + /* Also reset context's packing fields */ + CRPackContext *pc = buf->context; + CRASSERT(pc->currentBuffer == buf); + /*crMemcpy( &(pc->buffer), buf, sizeof(*buf) );*/ + pc->buffer = *buf; + } +} + + +int crPackCanHoldBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *src ) +{ + const int num_data = crPackNumData(src); + const int num_opcode = crPackNumOpcodes(src); + int res; + CR_GET_PACKER_CONTEXT(pc); + CR_LOCK_PACKER_CONTEXT(pc); + res = crPackCanHoldOpcode( pc, num_opcode, num_data ); + CR_UNLOCK_PACKER_CONTEXT(pc); + return res; +} + + +int crPackCanHoldBoundedBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *src ) +{ + const int len_aligned = (src->data_current - src->opcode_current - 1 + 3) & ~3; + CR_GET_PACKER_CONTEXT(pc); + /* 24 is the size of the bounds-info packet... */ + return crPackCanHoldOpcode( pc, 1, len_aligned + 24 ); +} + +void crPackAppendBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *src ) +{ + CR_GET_PACKER_CONTEXT(pc); + const int num_data = crPackNumData(src); + const int num_opcode = crPackNumOpcodes(src); + + CRASSERT(num_data >= 0); + CRASSERT(num_opcode >= 0); + + CR_LOCK_PACKER_CONTEXT(pc); + + /* don't append onto ourself! */ + CRASSERT(pc->currentBuffer); + CRASSERT(pc->currentBuffer != src); + + if (!crPackCanHoldBuffer(CR_PACKER_CONTEXT_ARG src)) + { + if (src->holds_BeginEnd) + { + crWarning( "crPackAppendBuffer: overflowed the destination!" ); + CR_UNLOCK_PACKER_CONTEXT(pc); + return; + } + else + { + crError( "crPackAppendBuffer: overflowed the destination!" ); + CR_UNLOCK_PACKER_CONTEXT(pc); + } + } + + /* Copy the buffer data/operands which are at the head of the buffer */ + crMemcpy( pc->buffer.data_current, src->data_start, num_data ); + pc->buffer.data_current += num_data; + + /* Copy the buffer opcodes which are at the tail of the buffer */ + CRASSERT( pc->buffer.opcode_current - num_opcode >= pc->buffer.opcode_end ); + crMemcpy( pc->buffer.opcode_current + 1 - num_opcode, src->opcode_current + 1, + num_opcode ); + pc->buffer.opcode_current -= num_opcode; + pc->buffer.holds_BeginEnd |= src->holds_BeginEnd; + pc->buffer.in_BeginEnd = src->in_BeginEnd; + pc->buffer.holds_List |= src->holds_List; + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void +crPackAppendBoundedBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *src, const CRrecti *bounds ) +{ + CR_GET_PACKER_CONTEXT(pc); + const GLbyte *payload = (const GLbyte *) src->opcode_current + 1; + const int num_opcodes = crPackNumOpcodes(src); + const int length = src->data_current - src->opcode_current - 1; + + CRASSERT(pc); + CR_LOCK_PACKER_CONTEXT(pc); + CRASSERT(pc->currentBuffer); + CRASSERT(pc->currentBuffer != src); + + /* + * payload points to the block of opcodes immediately followed by operands. + */ + + if ( !crPackCanHoldBoundedBuffer( CR_PACKER_CONTEXT_ARG src ) ) + { + if (src->holds_BeginEnd) + { + crWarning( "crPackAppendBoundedBuffer: overflowed the destination!" ); + CR_UNLOCK_PACKER_CONTEXT(pc); + return; + } + else + { + crError( "crPackAppendBoundedBuffer: overflowed the destination!" ); + CR_UNLOCK_PACKER_CONTEXT(pc); + } + } + + if (pc->swapping) + crPackBoundsInfoCRSWAP( CR_PACKER_CONTEXT_ARG bounds, payload, length, num_opcodes ); + else + crPackBoundsInfoCR( CR_PACKER_CONTEXT_ARG bounds, payload, length, num_opcodes ); + + pc->buffer.holds_BeginEnd |= src->holds_BeginEnd; + pc->buffer.in_BeginEnd = src->in_BeginEnd; + pc->buffer.holds_List |= src->holds_List; + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +#ifndef CHROMIUM_THREADSAFE +static unsigned char *sanityCheckPointer = NULL; +#endif + + +/* + * Allocate space for a command that might be very large, such as + * glTexImage2D or glBufferDataARB call. + * The command buffer _MUST_ then be transmitted by calling crHugePacket. + */ +void *crPackAlloc( CR_PACKER_CONTEXT_ARGDECL unsigned int size ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + + /* include space for the length and make the payload word-aligned */ + size = ( size + sizeof(unsigned int) + 0x3 ) & ~0x3; + + CR_LOCK_PACKER_CONTEXT(pc); + + if ( crPackCanHoldOpcode( pc, 1, size ) ) + { + /* we can just put it in the current buffer */ + CR_GET_BUFFERED_POINTER_NOLOCK(pc, size ); /* NOTE: this sets data_ptr */ + } + else + { + /* Okay, it didn't fit. Maybe it will after we flush. */ + CR_UNLOCK_PACKER_CONTEXT(pc); + pc->Flush( pc->flush_arg ); + CR_LOCK_PACKER_CONTEXT(pc); + if ( crPackCanHoldOpcode( pc, 1, size ) ) + { + CR_GET_BUFFERED_POINTER_NOLOCK(pc, size ); /* NOTE: this sets data_ptr */ + } + else + { + /* It's really way too big, so allocate a temporary packet + * with space for the single opcode plus the payload & + * header. + */ + data_ptr = (unsigned char *) + crAlloc( sizeof(CRMessageOpcodes) + 4 + size ); + + /* skip the header & opcode space */ + data_ptr += sizeof(CRMessageOpcodes) + 4; + } + } + + /* At the top of the function, we added four to the request size and + * rounded it up to the next multiple of four. + * + * At this point, we have: + * + * HIGH MEM | byte size - 1 | \ + * ... | + * ... | - original 'size' bytes for data + * | operand data | | + * return value -> | operand data | / + * | byte 3 | \ + * | byte 2 | |- These bytes will store 'size' + * | byte 1 | | + * data_ptr -> | byte 0 | / + * | CR opcode | <- Set in packspuHuge() + * | unused | + * | unused | + * | unused | + * | CRMessageOpcodes | + * | CRMessageOpcodes | + * ... + * | CRMessageOpcodes | + * | CRMessageOpcodes | + * LOW MEM +------------------+ + */ + + if (pc->swapping) + { + *((unsigned int *) data_ptr) = SWAP32(size); + crDebug( "Just swapped the length, putting %d on the wire!", *((unsigned int *) data_ptr)); + } + else + { + *((unsigned int *) data_ptr) = size; + } +#ifndef CHROMIUM_THREADSAFE + sanityCheckPointer = data_ptr + 4; +#endif + return data_ptr + 4; +} + +#define IS_BUFFERED( packet ) \ + ((unsigned char *) (packet) >= pc->buffer.data_start && \ + (unsigned char *) (packet) < pc->buffer.data_end) + + +/* + * Transmit a packet which was allocated with crPackAlloc. + */ +void crHugePacket( CR_PACKER_CONTEXT_ARGDECL CROpcode opcode, void *packet ) +{ + CR_GET_PACKER_CONTEXT(pc); +#ifndef CHROMIUM_THREADSAFE + CRASSERT(sanityCheckPointer == packet); + sanityCheckPointer = NULL; +#endif + + if ( IS_BUFFERED( packet ) ) + WRITE_OPCODE( pc, opcode ); + else + pc->SendHuge( opcode, packet ); +} + +void crPackFree( CR_PACKER_CONTEXT_ARGDECL void *packet ) +{ + CR_GET_PACKER_CONTEXT(pc); + + if ( IS_BUFFERED( packet ) ) + { + CR_UNLOCK_PACKER_CONTEXT(pc); + return; + } + + CR_UNLOCK_PACKER_CONTEXT(pc); + + /* the pointer passed in doesn't include the space for the single + * opcode (4 bytes because of the alignment requirement) or the + * length field or the header */ + crFree( (unsigned char *) packet - 8 - sizeof(CRMessageOpcodes) ); +} + +void crNetworkPointerWrite( CRNetworkPointer *dst, void *src ) +{ + /* init CRNetworkPointer with invalid values */ + dst->ptrAlign[0] = 0xDeadBeef; + dst->ptrAlign[1] = 0xCafeBabe; + /* copy the pointer's value into the CRNetworkPointer */ + crMemcpy( dst, &src, sizeof(src) ); + + /* if either assertion fails, it probably means that a packer function + * (which returns a value) was called without setting up the writeback + * pointer, or something like that. + */ + CRASSERT(dst->ptrAlign[0] != 0xffffffff); + CRASSERT(dst->ptrAlign[0] != 0xDeadBeef); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_bufferobject.c b/src/VBox/GuestHost/OpenGL/packer/pack_bufferobject.c new file mode 100644 index 00000000..d7bb275a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_bufferobject.c @@ -0,0 +1,121 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_error.h" +#include "cr_string.h" +#include "cr_version.h" + + +void PACK_APIENTRY +crPackMapBufferARB( GLenum target, GLenum access, + void * return_value, int * writeback ) +{ + (void)writeback; + (void)return_value; + (void)target; + (void)access; + crWarning("Can't pack MapBufferARB command!"); +} + + +void PACK_APIENTRY +crPackUnmapBufferARB( GLenum target, GLboolean* return_value, int * writeback ) +{ + (void)target; + (void)return_value; + (void)writeback; + crWarning("Can't pack UnmapBufferARB command!"); +} + + +void PACK_APIENTRY +crPackBufferDataARB( GLenum target, GLsizeiptrARB size, + const GLvoid * data, GLenum usage ) +{ + unsigned char *data_ptr, *start_ptr; + int packet_length; + + packet_length = sizeof(GLenum) + + sizeof(target) + sizeof(GLuint) + sizeof(usage) + sizeof(GLint); + + /*Note: it's valid to pass a NULL pointer here, which tells GPU drivers to allocate memory for the VBO*/ + if (data) packet_length += size; + + start_ptr = data_ptr = (unsigned char *) crPackAlloc( packet_length ); + + WRITE_DATA_AI(GLenum, CR_BUFFERDATAARB_EXTEND_OPCODE); + WRITE_DATA_AI(GLenum, target); + WRITE_DATA_AI(GLuint, (GLuint) size); + WRITE_DATA_AI(GLenum, usage); + WRITE_DATA_AI(GLint, (GLint) (data!=NULL)); + if (data) + crMemcpy(data_ptr, data, size); + + crHugePacket( CR_EXTEND_OPCODE, start_ptr ); + crPackFree( start_ptr ); +} + + +void PACK_APIENTRY +crPackBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, + const GLvoid * data ) +{ + unsigned char *data_ptr, *start_ptr; + int packet_length; + + if (!data) + return; + + packet_length = sizeof(GLenum) + + sizeof(target) + sizeof(GLuint) + sizeof(GLuint) + size; + + start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA_AI(GLenum, CR_BUFFERSUBDATAARB_EXTEND_OPCODE); + WRITE_DATA_AI(GLenum, target); + WRITE_DATA_AI(GLuint, (GLuint) offset); + WRITE_DATA_AI(GLuint, (GLuint) size); + crMemcpy(data_ptr, data, size); + + crHugePacket(CR_EXTEND_OPCODE, start_ptr); + crPackFree(start_ptr); +} + +void PACK_APIENTRY +crPackGetBufferSubDataARB( GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data, int * writeback ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + CR_GET_BUFFERED_POINTER( pc, 36 ); + WRITE_DATA( 0, GLint, 36 ); + WRITE_DATA( 4, GLenum, CR_GETBUFFERSUBDATAARB_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, target ); + WRITE_DATA( 12, GLuint, (GLuint) offset ); + WRITE_DATA( 16, GLuint, (GLuint) size ); + WRITE_NETWORK_POINTER( 20, (void *) data ); + WRITE_NETWORK_POINTER( 28, (void *) writeback ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY +crPackDeleteBuffersARB(GLsizei n, const GLuint * buffers) +{ + unsigned char *data_ptr; + int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*buffers); + + if (!buffers) + return; + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA( 0, GLenum, CR_DELETEBUFFERSARB_EXTEND_OPCODE ); + WRITE_DATA( 4, GLsizei, n ); + crMemcpy( data_ptr + 8, buffers, n * sizeof(*buffers) ); + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_client.c b/src/VBox/GuestHost/OpenGL/packer/pack_client.c new file mode 100644 index 00000000..e9247692 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_client.c @@ -0,0 +1,1089 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_version.h" +#include "state/cr_limits.h" +#include "cr_glstate.h" + +/*Convert from GLint to GLfloat in [-1.f,1.f]*/ +#define CRP_I2F_NORM(i) ((2.f*((GLint)(i))+1.f) * (1.f/4294967294.f)) +/*Convert from GLshort to GLfloat in [-1.f,1.f]*/ +#define CRP_S2F_NORM(s) ((2.f*((GLshort)(s))+1.f) * (1.f/65535.f)) +/*Convert from GLbyte to GLfloat in [-1.f,1.f]*/ +#define CRP_B2F_NORM(b) ((2.f*((GLbyte)(b))+1.f) * (1.f/255.f)) +/*Convert from GLuint to GLfloat in [0.f,1.f]*/ +#define CRP_UI2F_NORM(i) ((GLfloat)(i) * (1.f/4294967295.f)) +/*Convert from GLushort to GLfloat in [0.f,1.f]*/ +#define CRP_US2F_NORM(s) ((GLfloat)(s) * (1.f/65535.f)) +/*Convert from GLubyte to GLfloat in [0.f,1.f]*/ +#define CRP_UB2F_NORM(b) ((GLfloat)(b) * (1.f/255.f)) + +static void crPackVertexAttrib(const CRVertexArrays *array, unsigned int attr, GLint index) +{ + unsigned char *p = array->a[attr].p + index * array->a[attr].stride; + +#ifdef DEBUG_misha + Assert(index >= 0); +#endif + +#ifdef CR_ARB_vertex_buffer_object + if (array->a[attr].buffer && array->a[attr].buffer->data) + { + Assert(((uintptr_t)p) < array->a[attr].buffer->size); + p = (unsigned char *)(array->a[attr].buffer->data) + (uintptr_t)p; + } +#endif + + if (!p) + { + crWarning("crPackVertexAttrib: NULL ptr!"); + return; + } + + switch (array->a[attr].type) + { + case GL_SHORT: + { + GLshort *sPtr = (GLshort*) p; + switch (array->a[attr].size) + { + case 1: + if (array->a[attr].normalized) + crPackVertexAttrib1fARB(attr, CRP_S2F_NORM(sPtr[0])); + else + crPackVertexAttrib1svARB(attr, sPtr); + break; + case 2: + if (array->a[attr].normalized) + crPackVertexAttrib2fARB(attr, CRP_S2F_NORM(sPtr[0]), CRP_S2F_NORM(sPtr[1])); + else + crPackVertexAttrib2svARB(attr, sPtr); + break; + case 3: + if (array->a[attr].normalized) + crPackVertexAttrib3fARB(attr, CRP_S2F_NORM(sPtr[0]), CRP_S2F_NORM(sPtr[1]), CRP_S2F_NORM(sPtr[2])); + else + crPackVertexAttrib3svARB(attr, sPtr); + break; + case 4: + if (array->a[attr].normalized) + crPackVertexAttrib4NsvARB(attr, sPtr); + else + crPackVertexAttrib4svARB(attr, sPtr); + break; + } + break; + } + case GL_UNSIGNED_SHORT: + { + GLushort *usPtr = (GLushort*) p; + if (array->a[attr].normalized) + { + switch (array->a[attr].size) + { + case 1: + crPackVertexAttrib1fARB(attr, CRP_US2F_NORM(usPtr[0])); + break; + case 2: + crPackVertexAttrib2fARB(attr, CRP_US2F_NORM(usPtr[0]), CRP_US2F_NORM(usPtr[1])); + break; + case 3: + crPackVertexAttrib3fARB(attr, CRP_US2F_NORM(usPtr[0]), CRP_US2F_NORM(usPtr[1]), CRP_US2F_NORM(usPtr[2])); + break; + case 4: + crPackVertexAttrib4NusvARB(attr, usPtr); + break; + } + } + else + { + GLushort usv[4]; + switch (array->a[attr].size) + { + case 4: + crPackVertexAttrib4usvARB(attr, usPtr); + break; + case 3: usv[2] = usPtr[2]; RT_FALL_THRU(); + case 2: usv[1] = usPtr[1]; RT_FALL_THRU(); + case 1: + usv[0] = usPtr[0]; + crPackVertexAttrib4usvARB(attr, usv); + break; + } + } + break; + } + case GL_INT: + { + GLint *iPtr = (GLint*) p; + if (array->a[attr].normalized) + { + switch (array->a[attr].size) + { + case 1: + crPackVertexAttrib1fARB(attr, CRP_I2F_NORM(iPtr[0])); + break; + case 2: + crPackVertexAttrib2fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1])); + break; + case 3: + crPackVertexAttrib3fARB(attr, CRP_I2F_NORM(iPtr[0]), CRP_I2F_NORM(iPtr[1]), CRP_I2F_NORM(iPtr[2])); + break; + case 4: + crPackVertexAttrib4NivARB(attr, iPtr); + break; + } + } + else + { + GLint iv[4]; + switch (array->a[attr].size) + { + case 4: + crPackVertexAttrib4ivARB(attr, iPtr); + break; + case 3: iv[2] = iPtr[2]; RT_FALL_THRU(); + case 2: iv[1] = iPtr[1]; RT_FALL_THRU(); + case 1: + iv[0] = iPtr[0]; + crPackVertexAttrib4ivARB(attr, iv); + break; + } + } + break; + } + case GL_UNSIGNED_INT: + { + GLuint *uiPtr = (GLuint*) p; + if (array->a[attr].normalized) + { + switch (array->a[attr].size) + { + case 1: + crPackVertexAttrib1fARB(attr, CRP_UI2F_NORM(uiPtr[0])); + break; + case 2: + crPackVertexAttrib2fARB(attr, CRP_UI2F_NORM(uiPtr[0]), CRP_UI2F_NORM(uiPtr[1])); + break; + case 3: + crPackVertexAttrib3fARB(attr, CRP_UI2F_NORM(uiPtr[0]), CRP_UI2F_NORM(uiPtr[1]), CRP_UI2F_NORM(uiPtr[2])); + break; + case 4: + crPackVertexAttrib4NuivARB(attr, uiPtr); + break; + } + } + else + { + GLuint uiv[4]; + switch (array->a[attr].size) + { + case 4: + crPackVertexAttrib4uivARB(attr, uiPtr); + break; + case 3: uiv[2] = uiPtr[2]; RT_FALL_THRU(); + case 2: uiv[1] = uiPtr[1]; RT_FALL_THRU(); + case 1: + uiv[0] = uiPtr[0]; + crPackVertexAttrib4uivARB(attr, uiv); + break; + } + } + break; + } + case GL_FLOAT: + switch (array->a[attr].size) + { + case 1: crPackVertexAttrib1fvARB(attr, (GLfloat *)p); break; + case 2: crPackVertexAttrib2fvARB(attr, (GLfloat *)p); break; + case 3: crPackVertexAttrib3fvARB(attr, (GLfloat *)p); break; + case 4: crPackVertexAttrib4fvARB(attr, (GLfloat *)p); break; + } + break; + case GL_DOUBLE: + switch (array->a[attr].size) + { + case 1: crPackVertexAttrib1dvARB(attr, (GLdouble *)p); break; + case 2: crPackVertexAttrib2dvARB(attr, (GLdouble *)p); break; + case 3: crPackVertexAttrib3dvARB(attr, (GLdouble *)p); break; + case 4: crPackVertexAttrib4dvARB(attr, (GLdouble *)p); break; + } + break; + case GL_BYTE: + { + GLbyte *bPtr = (GLbyte*) p; + if (array->a[attr].normalized) + { + switch (array->a[attr].size) + { + case 1: + crPackVertexAttrib1fARB(attr, CRP_B2F_NORM(bPtr[0])); + break; + case 2: + crPackVertexAttrib2fARB(attr, CRP_B2F_NORM(bPtr[0]), CRP_B2F_NORM(bPtr[1])); + break; + case 3: + crPackVertexAttrib3fARB(attr, CRP_B2F_NORM(bPtr[0]), CRP_B2F_NORM(bPtr[1]), CRP_B2F_NORM(bPtr[2])); + break; + case 4: + crPackVertexAttrib4NbvARB(attr, bPtr); + break; + } + } + else + { + GLbyte bv[4]; + switch (array->a[attr].size) + { + case 4: + crPackVertexAttrib4bvARB(attr, bPtr); + break; + case 3: bv[2] = bPtr[2]; RT_FALL_THRU(); + case 2: bv[1] = bPtr[1]; RT_FALL_THRU(); + case 1: + bv[0] = bPtr[0]; + crPackVertexAttrib4bvARB(attr, bv); + break; + } + } + break; + } + case GL_UNSIGNED_BYTE: + { + GLubyte *ubPtr = (GLubyte*) p; + if (array->a[attr].normalized) + { + switch (array->a[attr].size) + { + case 1: + crPackVertexAttrib1fARB(attr, CRP_UB2F_NORM(ubPtr[0])); + break; + case 2: + crPackVertexAttrib2fARB(attr, CRP_UB2F_NORM(ubPtr[0]), CRP_UB2F_NORM(ubPtr[1])); + break; + case 3: + crPackVertexAttrib3fARB(attr, CRP_UB2F_NORM(ubPtr[0]), CRP_UB2F_NORM(ubPtr[1]), CRP_UB2F_NORM(ubPtr[2])); + break; + case 4: + crPackVertexAttrib4NubvARB(attr, ubPtr); + break; + } + } + else + { + GLubyte ubv[4]; + switch (array->a[attr].size) + { + case 4: + crPackVertexAttrib4ubvARB(attr, ubPtr); + break; + case 3: ubv[2] = ubPtr[2]; RT_FALL_THRU(); + case 2: ubv[1] = ubPtr[1]; RT_FALL_THRU(); + case 1: + ubv[0] = ubPtr[0]; + crPackVertexAttrib4ubvARB(attr, ubv); + break; + } + } + break; + } + default: + crWarning("Bad datatype for vertex attribute [%d] array: 0x%x\n", + attr, array->a[attr].type); + } +} + +/* + * Expand glArrayElement into crPackVertex/Color/Normal/etc. + */ +void +crPackExpandArrayElement(GLint index, CRClientState *c, const GLfloat *pZva) +{ + unsigned char *p; + unsigned int unit, attr; + const CRVertexArrays *array = &(c->array); + const GLboolean vpEnabled = crStateGetCurrent()->program.vpEnabled; + + /*crDebug("crPackExpandArrayElement(%i)", index);*/ + + if (array->n.enabled && !(vpEnabled && array->a[VERT_ATTRIB_NORMAL].enabled)) + { + p = array->n.p + index * array->n.stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->n.buffer && array->n.buffer->data) + { + p = (unsigned char *)(array->n.buffer->data) + (uintptr_t)p; + } +#endif + + switch (array->n.type) + { + case GL_BYTE: crPackNormal3bv((GLbyte *)p); break; + case GL_SHORT: crPackNormal3sv((GLshort *)p); break; + case GL_INT: crPackNormal3iv((GLint *)p); break; + case GL_FLOAT: crPackNormal3fv((GLfloat *)p); break; + case GL_DOUBLE: crPackNormal3dv((GLdouble *)p); break; + default: + crWarning("Unhandled: crPackExpandArrayElement, array->n.type 0x%x", array->n.type); + } + } + + if (array->c.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR0].enabled)) + { + p = array->c.p + index * array->c.stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->c.buffer && array->c.buffer->data) + { + p = (unsigned char *)(array->c.buffer->data) + (uintptr_t)p; + } +#endif + + switch (array->c.type) + { + case GL_BYTE: + switch (c->array.c.size) + { + case 3: crPackColor3bv((GLbyte *)p); break; + case 4: crPackColor4bv((GLbyte *)p); break; + } + break; + case GL_UNSIGNED_BYTE: + switch (c->array.c.size) + { + case 3: crPackColor3ubv((GLubyte *)p); break; + case 4: crPackColor4ubv((GLubyte *)p); break; + } + break; + case GL_SHORT: + switch (c->array.c.size) + { + case 3: crPackColor3sv((GLshort *)p); break; + case 4: crPackColor4sv((GLshort *)p); break; + } + break; + case GL_UNSIGNED_SHORT: + switch (c->array.c.size) + { + case 3: crPackColor3usv((GLushort *)p); break; + case 4: crPackColor4usv((GLushort *)p); break; + } + break; + case GL_INT: + switch (c->array.c.size) + { + case 3: crPackColor3iv((GLint *)p); break; + case 4: crPackColor4iv((GLint *)p); break; + } + break; + case GL_UNSIGNED_INT: + switch (c->array.c.size) + { + case 3: crPackColor3uiv((GLuint *)p); break; + case 4: crPackColor4uiv((GLuint *)p); break; + } + break; + case GL_FLOAT: + switch (c->array.c.size) + { + case 3: crPackColor3fv((GLfloat *)p); break; + case 4: crPackColor4fv((GLfloat *)p); break; + } + break; + case GL_DOUBLE: + switch (c->array.c.size) + { + case 3: crPackColor3dv((GLdouble *)p); break; + case 4: crPackColor4dv((GLdouble *)p); break; + } + break; + default: + crWarning("Unhandled: crPackExpandArrayElement, array->c.type 0x%x", array->c.type); + } + } + +#ifdef CR_EXT_secondary_color + if (array->s.enabled && !(vpEnabled && array->a[VERT_ATTRIB_COLOR1].enabled)) + { + p = array->s.p + index * array->s.stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->s.buffer && array->s.buffer->data) + { + p = (unsigned char *)(array->s.buffer->data) + (uintptr_t)p; + } +#endif + + switch (array->s.type) + { + case GL_BYTE: + crPackSecondaryColor3bvEXT((GLbyte *)p); break; + case GL_UNSIGNED_BYTE: + crPackSecondaryColor3ubvEXT((GLubyte *)p); break; + case GL_SHORT: + crPackSecondaryColor3svEXT((GLshort *)p); break; + case GL_UNSIGNED_SHORT: + crPackSecondaryColor3usvEXT((GLushort *)p); break; + case GL_INT: + crPackSecondaryColor3ivEXT((GLint *)p); break; + case GL_UNSIGNED_INT: + crPackSecondaryColor3uivEXT((GLuint *)p); break; + case GL_FLOAT: + crPackSecondaryColor3fvEXT((GLfloat *)p); break; + case GL_DOUBLE: + crPackSecondaryColor3dvEXT((GLdouble *)p); break; + default: + crWarning("Unhandled: crPackExpandArrayElement, array->s.type 0x%x", array->s.type); + } + } +#endif /* CR_EXT_secondary_color */ + + +#ifdef CR_EXT_fog_coord + if (array->f.enabled && !(vpEnabled && array->a[VERT_ATTRIB_FOG].enabled)) + { + p = array->f.p + index * array->f.stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->f.buffer && array->f.buffer->data) + { + p = (unsigned char *)(array->f.buffer->data) + (uintptr_t)p; + } +#endif + crPackFogCoordfEXT( *((GLfloat *) p) ); + } +#endif /* CR_EXT_fog_coord */ + + for (unit = 0 ; unit < CR_MAX_TEXTURE_UNITS ; unit++) + { + if (array->t[unit].enabled && !(vpEnabled && array->a[VERT_ATTRIB_TEX0+unit].enabled)) + { + p = array->t[unit].p + index * array->t[unit].stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->t[unit].buffer && array->t[unit].buffer->data) + { + p = (unsigned char *)(array->t[unit].buffer->data) + (uintptr_t)p; + } +#endif + + switch (array->t[unit].type) + { + case GL_SHORT: + switch (array->t[unit].size) + { + case 1: crPackMultiTexCoord1svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; + case 2: crPackMultiTexCoord2svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; + case 3: crPackMultiTexCoord3svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; + case 4: crPackMultiTexCoord4svARB(GL_TEXTURE0_ARB + unit, (GLshort *)p); break; + } + break; + case GL_INT: + switch (array->t[unit].size) + { + case 1: crPackMultiTexCoord1ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; + case 2: crPackMultiTexCoord2ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; + case 3: crPackMultiTexCoord3ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; + case 4: crPackMultiTexCoord4ivARB(GL_TEXTURE0_ARB + unit, (GLint *)p); break; + } + break; + case GL_FLOAT: + switch (array->t[unit].size) + { + case 1: crPackMultiTexCoord1fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; + case 2: crPackMultiTexCoord2fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; + case 3: crPackMultiTexCoord3fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; + case 4: crPackMultiTexCoord4fvARB(GL_TEXTURE0_ARB + unit, (GLfloat *)p); break; + } + break; + case GL_DOUBLE: + switch (array->t[unit].size) + { + case 1: crPackMultiTexCoord1dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; + case 2: crPackMultiTexCoord2dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; + case 3: crPackMultiTexCoord3dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; + case 4: crPackMultiTexCoord4dvARB(GL_TEXTURE0_ARB + unit, (GLdouble *)p); break; + } + break; + default: + crWarning("Unhandled: crPackExpandArrayElement, array->t[%i].type 0x%x", unit, array->t[unit].type); + } + } + } + + if (array->i.enabled) + { + p = array->i.p + index * array->i.stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->i.buffer && array->i.buffer->data) + { + p = (unsigned char *)(array->i.buffer->data) + (uintptr_t)p; + } +#endif + + switch (array->i.type) + { + case GL_SHORT: crPackIndexsv((GLshort *)p); break; + case GL_INT: crPackIndexiv((GLint *)p); break; + case GL_FLOAT: crPackIndexfv((GLfloat *)p); break; + case GL_DOUBLE: crPackIndexdv((GLdouble *)p); break; + default: + crWarning("Unhandled: crPackExpandArrayElement, array->i.type 0x%x", array->i.type); + } + } + + if (array->e.enabled) + { + p = array->e.p + index * array->e.stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->e.buffer && array->e.buffer->data) + { + p = (unsigned char *)(array->e.buffer->data) + (uintptr_t)p; + } +#endif + + crPackEdgeFlagv(p); + } + + for (attr = 1; attr < VERT_ATTRIB_MAX; attr++) + { + if (array->a[attr].enabled) + { + crPackVertexAttrib(array, attr, index); + } + } + + if (array->a[VERT_ATTRIB_POS].enabled) + { + crPackVertexAttrib(array, VERT_ATTRIB_POS, index); + } + else if (pZva) + { + crPackVertexAttrib4fvARB(VERT_ATTRIB_POS, pZva); + } + else if (array->v.enabled) + { + p = array->v.p + index * array->v.stride; + +#ifdef CR_ARB_vertex_buffer_object + if (array->v.buffer && array->v.buffer->data) + { + p = (unsigned char *)(array->v.buffer->data) + (uintptr_t)p; + } +#endif + switch (array->v.type) + { + case GL_SHORT: + switch (c->array.v.size) + { + case 2: crPackVertex2sv((GLshort *)p); break; + case 3: crPackVertex3sv((GLshort *)p); break; + case 4: crPackVertex4sv((GLshort *)p); break; + } + break; + case GL_INT: + switch (c->array.v.size) + { + case 2: crPackVertex2iv((GLint *)p); break; + case 3: crPackVertex3iv((GLint *)p); break; + case 4: crPackVertex4iv((GLint *)p); break; + } + break; + case GL_FLOAT: + switch (c->array.v.size) + { + case 2: crPackVertex2fv((GLfloat *)p); break; + case 3: crPackVertex3fv((GLfloat *)p); break; + case 4: crPackVertex4fv((GLfloat *)p); break; + } + break; + case GL_DOUBLE: + switch (c->array.v.size) + { + case 2: crPackVertex2dv((GLdouble *)p); break; + case 3: crPackVertex3dv((GLdouble *)p); break; + case 4: crPackVertex4dv((GLdouble *)p); break; + } + break; + default: + crWarning("Unhandled: crPackExpandArrayElement, array->v.type 0x%x", array->v.type); + } + } +} + + +void +crPackExpandDrawArrays(GLenum mode, GLint first, GLsizei count, CRClientState *c, const GLfloat *pZva) +{ + int i; + + if (count < 0) + { + __PackError(__LINE__, __FILE__, GL_INVALID_VALUE, "crPackDrawArrays(negative count)"); + return; + } + + if (mode > GL_POLYGON) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, "crPackDrawArrays(bad mode)"); + return; + } + + crPackBegin(mode); + for (i=0; ibufferobject.elementsBuffer; + packet_length += sizeof(GLint); + if (elementsBuffer && elementsBuffer->id) + { + /** @todo not sure it's possible, and not sure what to do*/ + if (!elementsBuffer->data) + { + crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring."); + return; + } + indexsize = 0; + } + else +#endif + { + indexsize = crPackElementsIndexSize(type); + } + + packet_length += count * indexsize; + + start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA_AI(GLenum, CR_DRAWELEMENTS_EXTEND_OPCODE ); + WRITE_DATA_AI(GLenum, mode ); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLenum, type); + WRITE_DATA_AI(GLuint, (GLuint) ((uintptr_t) indices) ); +#ifdef CR_ARB_vertex_buffer_object + WRITE_DATA_AI(GLint, (GLint)(indexsize>0)); +#endif + if (indexsize>0) + { + crMemcpy(data_ptr, indices, count * indexsize); + } + crHugePacket(CR_EXTEND_OPCODE, start_ptr); + crPackFree(start_ptr); +} + +void PACK_APIENTRY +crPackDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, + GLenum type, const GLvoid *indices) +{ + unsigned char *data_ptr, *start_ptr; + int packet_length = sizeof(int) + sizeof(mode) + sizeof(start) + + sizeof(end) + sizeof(count) + sizeof(type) + sizeof(GLuint); + GLsizei indexsize; + +#ifdef CR_ARB_vertex_buffer_object + CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer; + packet_length += sizeof(GLint); + if (elementsBuffer && elementsBuffer->id) + { + /** @todo not sure it's possible, and not sure what to do*/ + if (!elementsBuffer->data) + { + crWarning("crPackDrawElements: trying to use bound but empty elements buffer, ignoring."); + return; + } + indexsize = 0; + } + else +#endif + { + indexsize = crPackElementsIndexSize(type); + } + + packet_length += count * indexsize; + + start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA_AI(GLenum, CR_DRAWRANGEELEMENTS_EXTEND_OPCODE); + WRITE_DATA_AI(GLenum, mode); + WRITE_DATA_AI(GLuint, start); + WRITE_DATA_AI(GLuint, end); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLenum, type); + WRITE_DATA_AI(GLuint, (GLuint) ((uintptr_t) indices)); +#ifdef CR_ARB_vertex_buffer_object + WRITE_DATA_AI(GLint, (GLint) (indexsize>0)); +#endif + if (indexsize>0) + { + crMemcpy(data_ptr, indices, count * indexsize); + } + crHugePacket(CR_EXTEND_OPCODE, start_ptr); + crPackFree(start_ptr); +} + + +/** + * Expand glDrawElements into crPackBegin/Vertex/End, etc commands. + * Note: if mode==999, don't call glBegin/glEnd. + */ +void +crPackExpandDrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid *indices, CRClientState *c, const GLfloat *pZva) +{ + int i; + GLubyte *p = (GLubyte *)indices; +#ifdef CR_ARB_vertex_buffer_object + CRBufferObject *elementsBuffer = crStateGetCurrent()->bufferobject.elementsBuffer; +#endif + + if (count < 0) + { + __PackError(__LINE__, __FILE__, GL_INVALID_VALUE, + "crPackDrawElements(negative count)"); + return; + } + + if (mode > GL_POLYGON && mode != 999) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackDrawElements(bad mode)"); + return; + } + + if (type != GL_UNSIGNED_BYTE && + type != GL_UNSIGNED_SHORT && + type != GL_UNSIGNED_INT) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackDrawElements(bad type)"); + return; + } + +#ifdef CR_ARB_vertex_buffer_object + if (elementsBuffer && elementsBuffer->data) + { + p = (unsigned char *)(elementsBuffer->data) + (uintptr_t)p; + } +#endif + + if (mode != 999) + crPackBegin(mode); + + /*crDebug("crPackExpandDrawElements mode:0x%x, count:%d, type:0x%x", mode, count, type);*/ + + switch (type) + { + case GL_UNSIGNED_BYTE: + for (i=0; iend) + { + crWarning("crPackExpandDrawRangeElements start>end (%d>%d)", start, end); + return; + } + + crPackExpandDrawElements(mode, count, type, indices, c, pZva); +} + + +#ifdef CR_EXT_multi_draw_arrays +/* + * Pack real DrawArrays commands. + */ +void PACK_APIENTRY +crPackMultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count, + GLsizei primcount ) +{ + GLint i; + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + crPackDrawArrays(mode, first[i], count[i]); + } + } +} + + +/* + * Pack with crPackBegin/Vertex/End/etc. + */ +void +crPackExpandMultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count, + GLsizei primcount, CRClientState *c, const GLfloat *pZva ) +{ + GLint i; + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + crPackExpandDrawArrays(mode, first[i], count[i], c, pZva); + } + } +} + + +/* + * Pack real DrawElements commands. + */ +void PACK_APIENTRY +crPackMultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, + const GLvoid **indices, GLsizei primcount ) +{ + GLint i; + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + crPackDrawElements(mode, count[i], type, indices[i]); + } + } +} + + +/* + * Pack with crPackBegin/Vertex/End/etc. + */ +void +crPackExpandMultiDrawElementsEXT( GLenum mode, const GLsizei *count, + GLenum type, const GLvoid **indices, + GLsizei primcount, CRClientState *c, const GLfloat *pZva ) +{ + GLint i; + for (i = 0; i < primcount; i++) { + if (count[i] > 0) { + crPackExpandDrawElements(mode, count[i], type, indices[i], c, pZva); + } + } +} +#endif /* CR_EXT_multi_draw_arrays */ + +static int crPack_GetNumEnabledArrays(CRClientState *c, int *size) +{ + int i, count=0; + + *size = 0; + + if (c->array.v.enabled) + { + count++; + *size += c->array.v.bytesPerIndex; + } + + if (c->array.c.enabled) + { + count++; + *size += c->array.c.bytesPerIndex; + } + + if (c->array.f.enabled) + { + count++; + *size += c->array.f.bytesPerIndex; + } + + if (c->array.s.enabled) + { + count++; + *size += c->array.s.bytesPerIndex; + } + + if (c->array.e.enabled) + { + count++; + *size += c->array.e.bytesPerIndex; + } + + if (c->array.i.enabled) + { + count++; + *size += c->array.i.bytesPerIndex; + } + + if (c->array.n.enabled) + { + count++; + *size += c->array.n.bytesPerIndex; + } + + for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) + { + if (c->array.t[i].enabled) + { + count++; + *size += c->array.t[i].bytesPerIndex; + } + } + + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) + { + if (c->array.a[i].enabled) + { + count++; + *size += c->array.a[i].bytesPerIndex; + } + } + + return count; +} + +static void crPackLockClientPointer(GLint first, GLint count, unsigned char **ppData, int index, CRClientState *c) +{ + CRClientPointer *cp; + unsigned char *data_ptr = *ppData, *cptr; + GLint i; + + cp = crStateGetClientPointerByIndex(index, &c->array); + + if (cp->enabled) + { + if (cp->buffer && cp->buffer->id) + { + crWarning("crPackLockClientPointer called when there's VBO enabled!"); + } + + WRITE_DATA_AI(int, index); + cptr = cp->p + first*cp->stride; + if (cp->bytesPerIndex==cp->stride) + { + crMemcpy(data_ptr, cptr, count*cp->bytesPerIndex); + data_ptr += count*cp->bytesPerIndex; + } + else + { + for (i=0; ibytesPerIndex); + data_ptr += cp->bytesPerIndex; + cptr += cp->stride; + } + } + *ppData = data_ptr; + } +} + +void PACK_APIENTRY crPackLockArraysEXT(GLint first, GLint count) +{ + CRContext *g = crStateGetCurrent(); + CRClientState *c = &g->client; + unsigned char *data_ptr, *start_ptr; + int packet_length = sizeof(int); /*extopcode*/ + int vertex_size, i, numenabled; + + packet_length += sizeof(first) + sizeof(count); /*params*/ + numenabled = crPack_GetNumEnabledArrays(c, &vertex_size); + packet_length += sizeof(int) + numenabled*sizeof(int); /*numenabled + indices*/ + packet_length += vertex_size * count; /*vertices data*/ + + start_ptr = data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA_AI(GLenum, CR_LOCKARRAYSEXT_EXTEND_OPCODE ); + WRITE_DATA_AI(GLint, first); + WRITE_DATA_AI(GLint, count); + WRITE_DATA_AI(int, numenabled); + for (i=0; i +#include "packer.h" +#include "state/cr_currentpointers.h" + +#include + +void crPackOffsetCurrentPointers( int offset ) +{ + CR_GET_PACKER_CONTEXT(pc); + GLnormal_p *normal = &(pc->current.c.normal); + GLcolor_p *color = &(pc->current.c.color); + GLsecondarycolor_p *secondaryColor = &(pc->current.c.secondaryColor); + GLtexcoord_p *texCoord = &(pc->current.c.texCoord); + GLindex_p *index = &(pc->current.c.index); + GLedgeflag_p *edgeFlag = &(pc->current.c.edgeFlag); + GLvertexattrib_p *vertexAttrib = &(pc->current.c.vertexAttrib); + GLfogcoord_p *fogCoord = &(pc->current.c.fogCoord); + int i; +""") + +for k in sorted(current_fns.keys()): + name = '%s%s' % (k[:1].lower(),k[1:]) + if 'array' in current_fns[k]: + print('\tfor (i = 0; i < %s; i++)' % current_fns[k]['array']) + print('\t{') + for type in current_fns[k]['types']: + for size in current_fns[k]['sizes']: + indent = "" + ptr = "%s->%s%d" % (name, type, size ) + if 'array' in current_fns[k]: + ptr += "[i]" + indent = "\t" + print("%s\tif (%s)" % (indent, ptr)) + print("%s\t\t%s += offset;" % (indent, ptr )) + if 'array' in current_fns[k]: + print('\t}') +print(""" +} + +void crPackNullCurrentPointers( void ) +{ + CR_GET_PACKER_CONTEXT(pc); + CRCurrentStateAttr *c = &(pc->current.c); +""") +print('\tmemset (c, 0, sizeof(CRCurrentStateAttr));') +print("}") diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py b/src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py new file mode 100755 index 00000000..62a9912b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_currentheader.py @@ -0,0 +1,66 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This script generates the include/state/cr_currentpointers.h file. + +from __future__ import print_function +import sys +sys.path.append( "../glapi_parser" ) +import apiutil + +from pack_currenttypes import * + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE GENERATED BY THE pack_currentheader.py SCRIPT */ + +#ifndef CR_CURRENT_H +#define CR_CURRENT_H + +#include "state/cr_limits.h" +""") + +sorted_keys = sorted(current_fns.keys()) + +for k in sorted_keys: + name = k.lower(); + print("typedef struct {") + if 'array' in current_fns[k]: + print("\tconst unsigned char *ptr[%s];" % current_fns[k]['array']) + else: + print("\tconst unsigned char *ptr;") + for type in current_fns[k]['types']: + for size in current_fns[k]['sizes']: + if 'array' in current_fns[k]: + print("\tconst unsigned char *%s%d[%s];" % (type, size, current_fns[k]['array'])) + else: + print("\tconst unsigned char *%s%d;" % (type, size)) + print("} GL%s_p;\n" % name) + +print("typedef struct attrs {") +for k in sorted_keys: + name = k.lower() + field = '%s%s' % (k[:1].lower(),k[1:]) + print("\tGL%s_p %s;" % (name,field)) +print(" } CRCurrentStateAttr;") + + +print("typedef struct {") +print(""" + CRCurrentStateAttr c; + unsigned char *vtx_op; + unsigned char *vtx_data; + unsigned char *begin_op; + unsigned char *begin_data; + unsigned int vtx_count; + unsigned int vtx_max; + unsigned int vtx_count_begin; + unsigned int attribsUsedMask; + unsigned int changedVertexAttrib; +} CRCurrentStatePointers; + +#endif /* CR_CURRENT_H */ +""") diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_currenttypes.py b/src/VBox/GuestHost/OpenGL/packer/pack_currenttypes.py new file mode 100644 index 00000000..5e02dc85 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_currenttypes.py @@ -0,0 +1,142 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This file is imported by several other Python scripts + +current_fns = { + 'Color': { + 'types': ['b','ub','s','us','i','ui','f','d'], + 'sizes': [3,4], + 'default': [0,0,0,1], + 'members': ['[0]', '[1]', '[2]', '[3]'] + }, + 'SecondaryColor': { + 'types': ['b','ub','s','us','i','ui','f','d'], + 'sizes': [3], + 'default': [0,0,0], + 'members': ['[0]', '[1]', '[2]'] + }, + 'Normal': { + 'types': ['b','s','i','f','d'], + 'sizes': [3], + 'default': [0,0,0], + 'members': ['[0]', '[1]', '[2]'] + }, + 'TexCoord': { + 'types': ['s','i','f','d'], + 'sizes': [1,2,3,4], + 'default': [0,0,0,1], + 'members': ['[0]', '[1]', '[2]', '[3]'], + 'array': 'CR_MAX_TEXTURE_UNITS' + }, + 'EdgeFlag': { + 'types': ['l'], + 'sizes': [1], + 'default': [1], + 'members': ['[0]'] + }, + 'Index': { + 'types': ['ub','s','i','f','d'], + 'sizes': [1], + 'default': [0], + 'members': ['[0]'] + }, + 'VertexAttrib': { + 'types': ['s','f','d','b','i','ub','ui','us','Nub','Nus','Nui','Nb','Ns','Ni'], + 'sizes': [1,2,3,4], + 'default': [0,0,0,1], + 'members': ['x', 'y', 'z', 'w'], + 'array': 'CR_MAX_VERTEX_ATTRIBS' + }, + 'FogCoord': { + 'types': ['f','d'], + 'sizes': [1], + 'default': [0], + 'members': [] + }, +} + +current_fns_new = { + 'VertexAttrib': { + 'types': ['s','f','d','b','i','ub','ui','us','Nub','Nus','Nui','Nb','Ns','Ni'], + 'sizes': [1,2,3,4], + 'default': [0,0,0,1], + 'members': ['x', 'y', 'z', 'w'], + 'array': 'CR_MAX_VERTEX_ATTRIBS' + }, +} + +current_vtx = { + 'Vertex': { + 'types': ['s','i','f','d'], + 'sizes': [2,3,4], + 'default': [0,0,0,1], + 'members': ['x', 'y', 'z', 'w'] + } +} + +gltypes = { + 'l': { + 'type': 'GLboolean', + 'size': 1 + }, + 'b': { + 'type': 'GLbyte', + 'size': 1 + }, + 'ub': { + 'type': 'GLubyte', + 'size': 1 + }, + 's': { + 'type': 'GLshort', + 'size': 2 + }, + 'us': { + 'type': 'GLushort', + 'size': 2 + }, + 'i': { + 'type': 'GLint', + 'size': 4 + }, + 'ui': { + 'type': 'GLuint', + 'size': 4 + }, + 'f': { + 'type': 'GLfloat', + 'size': 4 + }, + 'd': { + 'type': 'GLdouble', + 'size': 8 + }, + + 'Nb': { + 'type': 'GLbyte', + 'size': 1 + }, + 'Nub': { + 'type': 'GLubyte', + 'size': 1 + }, + 'Ns': { + 'type': 'GLshort', + 'size': 2 + }, + 'Nus': { + 'type': 'GLushort', + 'size': 2 + }, + 'Ni': { + 'type': 'GLint', + 'size': 4 + }, + 'Nui': { + 'type': 'GLuint', + 'size': 4 + } +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_error.c b/src/VBox/GuestHost/OpenGL/packer/pack_error.c new file mode 100644 index 00000000..bb189c9a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_error.c @@ -0,0 +1,71 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + + +#include "cr_error.h" +#include "cr_environment.h" +#include "cr_pack.h" +#include "packer.h" + + +/* + * Set the error handler callback + */ +void crPackErrorFunction( CRPackContext *pc, CRPackErrorHandlerFunc function ) +{ + pc->Error = function; +} + + +/* + * This function is called by the packer functions when it detects and + * OpenGL error. + */ +void __PackError( int line, const char *file, GLenum error, const char *info) +{ + CR_GET_PACKER_CONTEXT(pc); + + if (pc->Error) + pc->Error( line, file, error, info ); + + if (crGetenv("CR_DEBUG")) + { + char *glerr; + + switch (error) { + case GL_NO_ERROR: + glerr = "GL_NO_ERROR"; + break; + case GL_INVALID_VALUE: + glerr = "GL_INVALID_VALUE"; + break; + case GL_INVALID_ENUM: + glerr = "GL_INVALID_ENUM"; + break; + case GL_INVALID_OPERATION: + glerr = "GL_INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + glerr = "GL_STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + glerr = "GL_STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + glerr = "GL_OUT_OF_MEMORY"; + break; + case GL_TABLE_TOO_LARGE: + glerr = "GL_TABLE_TOO_LARGE"; + break; + default: + glerr = "unknown"; + break; + } + + crWarning( "GL error in packer: %s, line %d: %s: %s", + file, line, glerr, info ); + } +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_extensions.c b/src/VBox/GuestHost/OpenGL/packer/pack_extensions.c new file mode 100644 index 00000000..a8ae7fc4 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_extensions.c @@ -0,0 +1,37 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" + +int __packTexParameterNumParams( GLenum param ) +{ + switch( param ) + { +#ifdef CR_EXT_texture_filter_anisotropic + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + return 1; +#endif + default: + break; + } + return 0; +} + +int __packFogParamsLength( GLenum param ) +{ + static int one_param = sizeof( GLfloat ); + (void) one_param; + switch( param ) + { +#ifdef CR_NV_fog_distance + case GL_FOG_DISTANCE_MODE_NV: + return one_param; +#endif + default: + break; + } + return 0; +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_feedback.c b/src/VBox/GuestHost/OpenGL/packer/pack_feedback.c new file mode 100644 index 00000000..159428ef --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_feedback.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_error.h" + +void PACK_APIENTRY crPackFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) +{ + (void) size; + (void) type; + (void) buffer; + + crWarning("Packer wont pass FeedbackBuffer()\n"); + crWarning("Try using the feedbackspu\n"); +} + +void PACK_APIENTRY crPackFeedbackBufferSWAP( GLsizei size, GLenum type, GLfloat *buffer ) +{ + (void) size; + (void) type; + (void) buffer; + + crWarning("Packer wont pass FeedbackBuffer()\n"); + crWarning("Try using the feedbackspu\n"); +} + +void PACK_APIENTRY crPackSelectBuffer( GLsizei size, GLuint *buffer ) +{ + (void) size; + (void) buffer; + + crWarning("Packer wont pass SelectBuffer()\n"); + crWarning("Try using the feedbackspu\n"); +} + +void PACK_APIENTRY crPackSelectBufferSWAP( GLsizei size, GLuint *buffer ) +{ + (void) size; + (void) buffer; + + crWarning("Packer wont pass SelectBuffer()\n"); + crWarning("Try using the feedbackspu\n"); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_fence.c b/src/VBox/GuestHost/OpenGL/packer/pack_fence.c new file mode 100644 index 00000000..f42f1a06 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_fence.c @@ -0,0 +1,45 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" + +void PACK_APIENTRY +crPackDeleteFencesNV(GLsizei n, const GLuint * fences) +{ + unsigned char *data_ptr; + int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*fences); + + if( !fences ) + return; + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, CR_DELETEFENCESNV_EXTEND_OPCODE); + WRITE_DATA(4, GLsizei, n); + crMemcpy(data_ptr + 8, fences, n * sizeof(*fences)); + crHugePacket(CR_EXTEND_OPCODE, data_ptr); + crPackFree(data_ptr); +} + +void PACK_APIENTRY crPackDeleteFencesNVSWAP( GLsizei n, const GLuint *fences ) +{ + unsigned char *data_ptr; + int i; + int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*fences); + + if( !fences ) + return; + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA(0, GLenum, CR_DELETEFENCESNV_EXTEND_OPCODE); + WRITE_DATA(4, GLsizei, n); + for (i = 0 ; i < n ; i++) + { + WRITE_DATA(i*sizeof(GLuint) + 8, GLuint, SWAP32(fences[i])); + } + crHugePacket(CR_EXTEND_OPCODE, data_ptr); + crPackFree(data_ptr); +} + diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_fog.c b/src/VBox/GuestHost/OpenGL/packer/pack_fog.c new file mode 100644 index 00000000..376ef53a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_fog.c @@ -0,0 +1,69 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" + +static GLboolean __handleFogData( GLenum pname, const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + int params_length = 0; + int packet_length = sizeof( int ) + sizeof( pname ); + unsigned char *data_ptr; + switch( pname ) + { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + params_length = sizeof( *params ); + break; + case GL_FOG_COLOR: + params_length = 4*sizeof( *params ); + break; + default: + params_length = __packFogParamsLength( pname ); + if (!params_length) + { + char msg[100]; + sprintf(msg, "Invalid pname in Fog: %d", (int) pname ); + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg); + return GL_FALSE; + } + break; + } + packet_length += params_length; + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, int, packet_length ); + WRITE_DATA( 4, GLenum, pname ); + WRITE_DATA( 8, GLfloat, params[0] ); + if (packet_length > 12) + { + WRITE_DATA( 12, GLfloat, params[1] ); + WRITE_DATA( 16, GLfloat, params[2] ); + WRITE_DATA( 20, GLfloat, params[3] ); + } + return GL_TRUE; +} + +void PACK_APIENTRY crPackFogfv(GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleFogData( pname, params )) + WRITE_OPCODE( pc, CR_FOGFV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackFogiv(GLenum pname, const GLint *params) +{ + CR_GET_PACKER_CONTEXT(pc); + /* floats and ints are the same size, so the packing should be the same */ + if (__handleFogData( pname, (const GLfloat *) params )) + WRITE_OPCODE( pc, CR_FOGIV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_framebuffer.c b/src/VBox/GuestHost/OpenGL/packer/pack_framebuffer.c new file mode 100644 index 00000000..7a578136 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_framebuffer.c @@ -0,0 +1,71 @@ +/* $Id: pack_framebuffer.c $ */ + +/** @file + * VBox OpenGL: EXT_framebuffer_object + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "packer.h" +#include "cr_error.h" +#include "cr_string.h" + +void PACK_APIENTRY +crPackDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers) +{ + unsigned char *data_ptr; + int packet_length = sizeof(GLenum) + sizeof(n) + n*sizeof(*renderbuffers); + + if (!renderbuffers) + return; + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, CR_DELETERENDERBUFFERSEXT_EXTEND_OPCODE); + WRITE_DATA(4, GLsizei, n); + crMemcpy(data_ptr + 8, renderbuffers, n* sizeof(*renderbuffers)); + crHugePacket(CR_EXTEND_OPCODE, data_ptr); + crPackFree(data_ptr); +} + +void PACK_APIENTRY +crPackDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers) +{ + unsigned char *data_ptr; + int packet_length = sizeof(GLenum) + sizeof(n) + n*sizeof(*framebuffers); + + if (!framebuffers) + return; + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, CR_DELETEFRAMEBUFFERSEXT_EXTEND_OPCODE); + WRITE_DATA(4, GLsizei, n); + crMemcpy(data_ptr + 8, framebuffers, n* sizeof(*framebuffers)); + crHugePacket(CR_EXTEND_OPCODE, data_ptr); + crPackFree(data_ptr); +} + +void PACK_APIENTRY +crPackDeleteRenderbuffersEXTSWAP(GLsizei n, const GLuint * renderbuffers) +{ + (void) n; + (void) renderbuffers; + crError ("No swap version"); +} + +void PACK_APIENTRY +crPackDeleteFramebuffersEXTSWAP(GLsizei n, const GLuint * framebuffers) +{ + (void) n; + (void) framebuffers; + crError ("No swap version"); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_header.py b/src/VBox/GuestHost/OpenGL/packer/pack_header.py new file mode 100755 index 00000000..d86d0789 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_header.py @@ -0,0 +1,91 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This script generates the cr/include/cr_packfunctions.h file from the +# gl_header.parsed file. + +from __future__ import print_function +import sys +import string + +import apiutil + + +apiutil.CopyrightC() + +print("""#ifndef CR_PACKFUNCTIONS_H +#define CR_PACKFUNCTIONS_H + +/* DO NOT EDIT - THIS FILE GENERATED BY THE pack_header.py SCRIPT */ + +/* Prototypes for the OpenGL packer functions in packer.c and pack_bbox.c */ + +#include "chromium.h" +#include "state/cr_client.h" +#include "cr_pack.h" + +#ifdef WINDOWS +#define PACK_APIENTRY __stdcall +#else +#define PACK_APIENTRY +#endif + +#ifdef __cplusplus +extern "C" { +#endif +""") + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") + + +for func_name in keys: + if ("pack" in apiutil.ChromiumProps(func_name) or + "extpack" in apiutil.ChromiumProps(func_name) or + apiutil.NonVectorFunction(func_name) != '' or + apiutil.FindSpecial('packer', func_name)): + + # OK, generate a crPackFooBar() prototype for this function + return_type = apiutil.ReturnType(func_name) + args = apiutil.Parameters(func_name) + if return_type != 'void': + if apiutil.IsPointer(return_type): + args.append(("return_value", return_type, 0)) + else: + args.append(("return_value", return_type + "*", 0)) + elif "pixelstore" in apiutil.Properties(func_name): + args.append(("packstate", "const CRPixelPackState *", 0)) + + if "get" in apiutil.Properties(func_name): + args.append(("writeback", "int *", 0)) + + print('void PACK_APIENTRY crPack%s(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args))) + print('void PACK_APIENTRY crPack%sSWAP(%s);' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', args))) + + + +# Now generate special BBOX, COUNT, SWAP variations on the glVertex and +# glVertexAttrib functions. +for func_name in keys: + if (func_name[0:6] == "Vertex" and + "pervertex" in apiutil.Properties(func_name) and + ("pack" in apiutil.ChromiumProps(func_name) or + apiutil.NonVectorFunction(func_name) != '')): + + assert apiutil.ReturnType(func_name) == "void" + + args = apiutil.Parameters(func_name) + print('void PACK_APIENTRY crPack%sBBOX(%s);' % (func_name, apiutil.MakeDeclarationString(args))) + print('void PACK_APIENTRY crPack%sBBOX_COUNT(%s);' % (func_name, apiutil.MakeDeclarationString(args))) + print('void PACK_APIENTRY crPack%sBBOXSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args))) + print('void PACK_APIENTRY crPack%sBBOX_COUNTSWAP(%s);' % (func_name, apiutil.MakeDeclarationString(args))) + + +print(""" +#ifdef __cplusplus +} +#endif + +#endif /* CR_PACKFUNCTIONS_H */ +""") diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_init.c b/src/VBox/GuestHost/OpenGL/packer/pack_init.c new file mode 100644 index 00000000..8332a5c3 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_init.c @@ -0,0 +1,74 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_error.h" +#include "cr_mem.h" +#include "packer.h" +#include + +#ifdef CHROMIUM_THREADSAFE +CRtsd _PackerTSD; +int cr_packer_globals; /* dummy - for the sake of packer.def */ +#else +int _PackerTSD; /* dummy - for the sake of packer.def */ /* drm1 */ +DLLDATA(CRPackContext) cr_packer_globals; +#endif + +uint32_t cr_packer_cmd_blocks_enabled = 0; + +CRPackContext *crPackNewContext( int swapping ) +{ +#ifdef CHROMIUM_THREADSAFE + CRPackContext *pc = crCalloc(sizeof(CRPackContext)); + if (!pc) + return NULL; + crInitMutex(&pc->mutex); +#else + GET_PACKER_CONTEXT(pc); + crMemZero( pc, sizeof(CRPackContext)); +#endif + pc->u32CmdBlockState = 0; + pc->swapping = swapping; + pc->Flush = NULL; + pc->SendHuge = NULL; + pc->updateBBOX = 0; + return pc; +} + +void crPackDeleteContext(CRPackContext *pc) +{ +#ifdef CHROMIUM_THREADSAFE + crFreeMutex(&pc->mutex); + crFree(pc); +#endif +} + +/* Set packing context for the calling thread */ +void crPackSetContext( CRPackContext *pc ) +{ +#ifdef CHROMIUM_THREADSAFE + crSetTSD( &_PackerTSD, pc ); +#else + CRASSERT( pc == &cr_packer_globals ); + (void)pc; +#endif +} + + +/* Return packing context for the calling thread */ +CRPackContext *crPackGetContext( void ) +{ +#ifdef CHROMIUM_THREADSAFE + return (CRPackContext *) crGetTSD( &_PackerTSD ); +#else + return &cr_packer_globals; +#endif +} + +void crPackCapsSet(uint32_t u32Caps) +{ + cr_packer_cmd_blocks_enabled = (u32Caps & (CR_VBOX_CAP_CMDBLOCKS_FLUSH | CR_VBOX_CAP_CMDBLOCKS)); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_lights.c b/src/VBox/GuestHost/OpenGL/packer/pack_lights.c new file mode 100644 index 00000000..a2c88f9e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_lights.c @@ -0,0 +1,123 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_error.h" + +static GLboolean __handleLightData(GLenum light, GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned int packet_length = sizeof(int) + sizeof(light) + sizeof(pname); + unsigned int params_length = 0; + unsigned char *data_ptr; + switch(pname) + { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_POSITION: + params_length = 4*sizeof(*params); + break; + case GL_SPOT_DIRECTION: + params_length = 3*sizeof(*params); + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + params_length = sizeof(*params); + break; + default: + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackLight(bad pname)"); + return GL_FALSE; + } + packet_length += params_length; + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, light); + WRITE_DATA(sizeof(int) + 4, GLenum, pname); + WRITE_DATA(sizeof(int) + 8, GLfloat, params[0]); + if (params_length > sizeof(*params)) + { + WRITE_DATA(sizeof(int) + 12, GLfloat, params[1]); + WRITE_DATA(sizeof(int) + 16, GLfloat, params[2]); + } + if (params_length > 3*sizeof(*params)) + { + WRITE_DATA(sizeof(int) + 20, GLfloat, params[3]); + } + return GL_TRUE; +} + +void PACK_APIENTRY crPackLightfv (GLenum light, GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleLightData(light, pname, params)) + WRITE_OPCODE(pc, CR_LIGHTFV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackLightiv (GLenum light, GLenum pname, const GLint *params) +{ + /* floats and ints are the same size, so the packing should be the same */ + CR_GET_PACKER_CONTEXT(pc); + if (__handleLightData(light, pname, (const GLfloat *) params)) + WRITE_OPCODE(pc, CR_LIGHTIV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +static GLboolean __handleLightModelData(GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned int packet_length = sizeof(int) + sizeof(pname); + unsigned int params_length = 0; + unsigned char *data_ptr; + switch(pname) + { + case GL_LIGHT_MODEL_AMBIENT: + params_length = 4*sizeof(*params); + break; + case GL_LIGHT_MODEL_TWO_SIDE: + case GL_LIGHT_MODEL_LOCAL_VIEWER: + params_length = sizeof(*params); + break; + default: + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackLightModel(bad pname)"); + return GL_FALSE; + } + packet_length += params_length; + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, pname); + WRITE_DATA(sizeof(int) + 4, GLfloat, params[0]); + if (params_length > sizeof(*params)) + { + WRITE_DATA(sizeof(int) + 8, GLfloat, params[1]); + WRITE_DATA(sizeof(int) + 12, GLfloat, params[2]); + WRITE_DATA(sizeof(int) + 16, GLfloat, params[3]); + } + return GL_TRUE; +} + +void PACK_APIENTRY crPackLightModelfv (GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleLightModelData(pname, params)) + WRITE_OPCODE(pc, CR_LIGHTMODELFV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackLightModeliv (GLenum pname, const GLint *params) +{ + /* floats and ints are the same size, so the packing should be the same */ + CR_GET_PACKER_CONTEXT(pc); + if (__handleLightModelData(pname, (const GLfloat *) params)) + WRITE_OPCODE(pc, CR_LIGHTMODELIV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_lists.c b/src/VBox/GuestHost/OpenGL/packer/pack_lists.c new file mode 100644 index 00000000..f3519014 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_lists.c @@ -0,0 +1,96 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_error.h" +#include "cr_mem.h" + +static int __gl_CallListsNumBytes( GLenum type ) +{ + switch( type ) + { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_2_BYTES: + return 1; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_3_BYTES: + return 2; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_4_BYTES: + return 4; + default: + return -1; + } +} + +void PACK_APIENTRY crPackCallLists(GLint n, GLenum type, + const GLvoid *lists ) +{ + unsigned char *data_ptr; + int packet_length; + + int num_bytes = __gl_CallListsNumBytes( type ) * n; + if (num_bytes < 0) + { + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackCallLists(bad type)" ); + return; + } + + packet_length = + sizeof( n ) + + sizeof( type ) + + num_bytes; + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLint, n ); + WRITE_DATA( 4, GLenum, type ); + crMemcpy( data_ptr + 8, lists, num_bytes ); + + crHugePacket( CR_CALLLISTS_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackNewList( GLuint list, GLenum mode ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + + if (CR_CMDBLOCK_IS_STARTED(pc, CRPACKBLOCKSTATE_OP_NEWLIST)) + { + WARN(("recursive NewList?")); + return; + } + + CR_CMDBLOCK_BEGIN( pc, CRPACKBLOCKSTATE_OP_NEWLIST ); + CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, 16, GL_FALSE ); + WRITE_DATA( 0, GLint, 16 ); + WRITE_DATA( 4, GLenum, CR_NEWLIST_EXTEND_OPCODE ); + WRITE_DATA( 8, GLuint, list ); + WRITE_DATA( 12, GLenum, mode ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + pc->buffer.in_List = GL_TRUE; + pc->buffer.holds_List = GL_TRUE; + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackEndList( void ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + CR_GET_BUFFERED_POINTER( pc, 8 ); + WRITE_DATA( 0, GLint, 8 ); + WRITE_DATA( 4, GLenum, CR_ENDLIST_EXTEND_OPCODE ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + pc->buffer.in_List = GL_FALSE; + CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_NEWLIST ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_map.c b/src/VBox/GuestHost/OpenGL/packer/pack_map.c new file mode 100644 index 00000000..67ca330b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_map.c @@ -0,0 +1,294 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_error.h" +#include "cr_mem.h" + +/* Note -- for these packets, the ustride and vstride are implicit, + * and are computed into the packet instead of copied. + */ + +static int __gl_Map2NumComponents( GLenum target ) +{ + switch( target ) + { + case GL_MAP2_VERTEX_3: + case GL_MAP2_NORMAL: + case GL_MAP2_TEXTURE_COORD_3: + return 3; + case GL_MAP2_VERTEX_4: + case GL_MAP2_COLOR_4: + case GL_MAP2_TEXTURE_COORD_4: + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + return 4; + case GL_MAP2_INDEX: + case GL_MAP2_TEXTURE_COORD_1: + return 1; + case GL_MAP2_TEXTURE_COORD_2: + return 2; + default: + return -1; + } +} + +static int __gl_Map1NumComponents( GLenum target ) +{ + switch( target ) + { + case GL_MAP1_VERTEX_3: + case GL_MAP1_NORMAL: + case GL_MAP1_TEXTURE_COORD_3: + return 3; + case GL_MAP1_VERTEX_4: + case GL_MAP1_COLOR_4: + case GL_MAP1_TEXTURE_COORD_4: + return 4; + case GL_MAP1_INDEX: + case GL_MAP1_TEXTURE_COORD_1: + return 1; + case GL_MAP1_TEXTURE_COORD_2: + return 2; + default: + return -1; + } +} + +void PACK_APIENTRY crPackMap2d(GLenum target, GLdouble u1, + GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, + GLint vstride, GLint vorder, const GLdouble *points) +{ + unsigned char *data_ptr; + int u,v; + GLdouble *dest_data, *src_data; + int packet_length = + sizeof( target ) + + sizeof( u1 ) + + sizeof( u2 ) + + sizeof( uorder ) + + sizeof( ustride ) + + sizeof( v1 ) + + sizeof( v2 ) + + sizeof( vorder ) + + sizeof( vstride ); + + int num_components = __gl_Map2NumComponents( target ); + if (num_components < 0) + { + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap2d(bad target)" ); + return; + } + + packet_length += num_components*uorder*vorder*sizeof( *points ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + + WRITE_DATA( 0, GLenum, target ); + WRITE_DOUBLE( 4, u1 ); + WRITE_DOUBLE( 12, u2 ); + WRITE_DATA( 20, GLint, num_components ); + WRITE_DATA( 24, GLint, uorder ); + WRITE_DOUBLE( 28, v1 ); + WRITE_DOUBLE( 36, v2 ); + WRITE_DATA( 44, GLint, num_components*uorder ); + WRITE_DATA( 48, GLint, vorder ); + + dest_data = (GLdouble *) (data_ptr + 52); + src_data = (GLdouble *) points; + for (v = 0 ; v < vorder ; v++) + { + for (u = 0 ; u < uorder ; u++) + { + crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); + dest_data += num_components; + src_data += ustride; + } + src_data += vstride - ustride*uorder; + } + + crHugePacket( CR_MAP2D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackMap2f(GLenum target, GLfloat u1, + GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, + GLint vstride, GLint vorder, const GLfloat *points) +{ + unsigned char *data_ptr; + int u,v; + GLfloat *dest_data, *src_data; + int packet_length = + sizeof( target ) + + sizeof( u1 ) + + sizeof( u2 ) + + sizeof( uorder ) + + sizeof( ustride ) + + sizeof( v1 ) + + sizeof( v2 ) + + sizeof( vorder ) + + sizeof( vstride ); + + int num_components = __gl_Map2NumComponents( target ); + if (num_components < 0) + { + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap2f(bad target)" ); + return; + } + + packet_length += num_components*uorder*vorder*sizeof( *points ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + + WRITE_DATA( 0, GLenum, target ); + WRITE_DATA( 4, GLfloat, u1 ); + WRITE_DATA( 8, GLfloat, u2 ); + WRITE_DATA( 12, GLint, num_components ); + WRITE_DATA( 16, GLint, uorder ); + WRITE_DATA( 20, GLfloat, v1 ); + WRITE_DATA( 24, GLfloat, v2 ); + WRITE_DATA( 28, GLint, num_components*uorder ); + WRITE_DATA( 32, GLint, vorder ); + + dest_data = (GLfloat *) (data_ptr + 36); + src_data = (GLfloat *) points; + for (v = 0 ; v < vorder ; v++) + { + for (u = 0 ; u < uorder ; u++) + { + crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); + dest_data += num_components; + src_data += ustride; + } + src_data += vstride - ustride*uorder; + } + + crHugePacket( CR_MAP2F_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackMap1d( GLenum target, GLdouble u1, + GLdouble u2, GLint stride, GLint order, const GLdouble *points ) +{ + unsigned char *data_ptr; + int packet_length = + sizeof( target ) + + sizeof( u1 ) + + sizeof( u2 ) + + sizeof( stride ) + + sizeof( order ); + + int num_components = __gl_Map1NumComponents( target ); + GLdouble *src_data, *dest_data; + int u; + + if (num_components < 0) + { + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap1d(bad target)" ); + return; + } + + packet_length += num_components * order * sizeof( *points ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + + WRITE_DATA( 0, GLenum, target ); + WRITE_DOUBLE( 4, u1 ); + WRITE_DOUBLE( 12, u2 ); + WRITE_DATA( 20, GLint, num_components ); + WRITE_DATA( 24, GLint, order ); + + dest_data = (GLdouble *) (data_ptr + 28); + src_data = (GLdouble *) points; + for (u = 0 ; u < order ; u++) + { + crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); + dest_data += num_components; + src_data += stride; + } + + crHugePacket( CR_MAP1D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackMap1f( GLenum target, GLfloat u1, + GLfloat u2, GLint stride, GLint order, const GLfloat *points ) +{ + unsigned char *data_ptr; + int packet_length = + sizeof( target ) + + sizeof( u1 ) + + sizeof( u2 ) + + sizeof( stride ) + + sizeof( order ); + + int num_components = __gl_Map1NumComponents( target ); + GLfloat *src_data, *dest_data; + int u; + + if (num_components < 0) + { + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap1f(bad target)" ); + return; + } + + packet_length += num_components * order * sizeof( *points ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + + WRITE_DATA( 0, GLenum, target ); + WRITE_DATA( 4, GLfloat, u1 ); + WRITE_DATA( 8, GLfloat, u2 ); + WRITE_DATA( 12, GLint, num_components ); + WRITE_DATA( 16, GLint, order ); + + dest_data = (GLfloat *) (data_ptr + 20); + src_data = (GLfloat *) points; + for (u = 0 ; u < order ; u++) + { + crMemcpy( dest_data, src_data, num_components * sizeof( *points ) ); + dest_data += num_components; + src_data += stride; + } + + crHugePacket( CR_MAP1F_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_materials.c b/src/VBox/GuestHost/OpenGL/packer/pack_materials.c new file mode 100644 index 00000000..e7a027d4 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_materials.c @@ -0,0 +1,68 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_error.h" + +static void __handleMaterialData( GLenum face, GLenum pname, const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned int packet_length = sizeof( int ) + sizeof( face ) + sizeof( pname ); + unsigned int params_length = 0; + unsigned char *data_ptr; + switch( pname ) + { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + case GL_EMISSION: + case GL_AMBIENT_AND_DIFFUSE: + params_length = 4*sizeof( *params ); + break; + case GL_COLOR_INDEXES: + params_length = 3*sizeof( *params ); + break; + case GL_SHININESS: + params_length = sizeof( *params ); + break; + default: + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterial(pname)"); + return; + } + packet_length += params_length; + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, int, packet_length ); + WRITE_DATA( sizeof( int ) + 0, GLenum, face ); + WRITE_DATA( sizeof( int ) + 4, GLenum, pname ); + WRITE_DATA( sizeof( int ) + 8, GLfloat, params[0] ); + if (params_length > sizeof( *params )) + { + WRITE_DATA( sizeof( int ) + 12, GLfloat, params[1] ); + WRITE_DATA( sizeof( int ) + 16, GLfloat, params[2] ); + } + if (packet_length > 3*sizeof( *params ) ) + { + WRITE_DATA( sizeof( int ) + 20, GLfloat, params[3] ); + } +} + +void PACK_APIENTRY crPackMaterialfv(GLenum face, GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleMaterialData( face, pname, params ); + WRITE_OPCODE( pc, CR_MATERIALFV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackMaterialiv(GLenum face, GLenum pname, const GLint *params) +{ + /* floats and ints are the same size, so the packing should be the same */ + CR_GET_PACKER_CONTEXT(pc); + __handleMaterialData( face, pname, (const GLfloat *) params ); + WRITE_OPCODE( pc, CR_MATERIALIV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c b/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c new file mode 100644 index 00000000..b16857ae --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_matrices.c @@ -0,0 +1,224 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" + +void PACK_APIENTRY crPackMultMatrixd(const GLdouble *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DOUBLE(0*sizeof(double), m[ 0]); + WRITE_DOUBLE(1*sizeof(double), m[ 1]); + WRITE_DOUBLE(2*sizeof(double), m[ 2]); + WRITE_DOUBLE(3*sizeof(double), m[ 3]); + WRITE_DOUBLE(4*sizeof(double), m[ 4]); + WRITE_DOUBLE(5*sizeof(double), m[ 5]); + WRITE_DOUBLE(6*sizeof(double), m[ 6]); + WRITE_DOUBLE(7*sizeof(double), m[ 7]); + WRITE_DOUBLE(8*sizeof(double), m[ 8]); + WRITE_DOUBLE(9*sizeof(double), m[ 9]); + WRITE_DOUBLE(10*sizeof(double), m[10]); + WRITE_DOUBLE(11*sizeof(double), m[11]); + WRITE_DOUBLE(12*sizeof(double), m[12]); + WRITE_DOUBLE(13*sizeof(double), m[13]); + WRITE_DOUBLE(14*sizeof(double), m[14]); + WRITE_DOUBLE(15*sizeof(double), m[15]); + WRITE_OPCODE(pc, CR_MULTMATRIXD_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackMultMatrixf(const GLfloat *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0*sizeof(GLfloat), GLfloat, m[ 0]); + WRITE_DATA(1*sizeof(GLfloat), GLfloat, m[ 1]); + WRITE_DATA(2*sizeof(GLfloat), GLfloat, m[ 2]); + WRITE_DATA(3*sizeof(GLfloat), GLfloat, m[ 3]); + WRITE_DATA(4*sizeof(GLfloat), GLfloat, m[ 4]); + WRITE_DATA(5*sizeof(GLfloat), GLfloat, m[ 5]); + WRITE_DATA(6*sizeof(GLfloat), GLfloat, m[ 6]); + WRITE_DATA(7*sizeof(GLfloat), GLfloat, m[ 7]); + WRITE_DATA(8*sizeof(GLfloat), GLfloat, m[ 8]); + WRITE_DATA(9*sizeof(GLfloat), GLfloat, m[ 9]); + WRITE_DATA(10*sizeof(GLfloat), GLfloat, m[10]); + WRITE_DATA(11*sizeof(GLfloat), GLfloat, m[11]); + WRITE_DATA(12*sizeof(GLfloat), GLfloat, m[12]); + WRITE_DATA(13*sizeof(GLfloat), GLfloat, m[13]); + WRITE_DATA(14*sizeof(GLfloat), GLfloat, m[14]); + WRITE_DATA(15*sizeof(GLfloat), GLfloat, m[15]); + WRITE_OPCODE(pc, CR_MULTMATRIXF_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackLoadMatrixd(const GLdouble *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DOUBLE(0*sizeof(double), m[ 0]); + WRITE_DOUBLE(1*sizeof(double), m[ 1]); + WRITE_DOUBLE(2*sizeof(double), m[ 2]); + WRITE_DOUBLE(3*sizeof(double), m[ 3]); + WRITE_DOUBLE(4*sizeof(double), m[ 4]); + WRITE_DOUBLE(5*sizeof(double), m[ 5]); + WRITE_DOUBLE(6*sizeof(double), m[ 6]); + WRITE_DOUBLE(7*sizeof(double), m[ 7]); + WRITE_DOUBLE(8*sizeof(double), m[ 8]); + WRITE_DOUBLE(9*sizeof(double), m[ 9]); + WRITE_DOUBLE(10*sizeof(double), m[10]); + WRITE_DOUBLE(11*sizeof(double), m[11]); + WRITE_DOUBLE(12*sizeof(double), m[12]); + WRITE_DOUBLE(13*sizeof(double), m[13]); + WRITE_DOUBLE(14*sizeof(double), m[14]); + WRITE_DOUBLE(15*sizeof(double), m[15]); + WRITE_OPCODE(pc, CR_LOADMATRIXD_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackLoadMatrixf(const GLfloat *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0*sizeof(GLfloat), GLfloat, m[ 0]); + WRITE_DATA(1*sizeof(GLfloat), GLfloat, m[ 1]); + WRITE_DATA(2*sizeof(GLfloat), GLfloat, m[ 2]); + WRITE_DATA(3*sizeof(GLfloat), GLfloat, m[ 3]); + WRITE_DATA(4*sizeof(GLfloat), GLfloat, m[ 4]); + WRITE_DATA(5*sizeof(GLfloat), GLfloat, m[ 5]); + WRITE_DATA(6*sizeof(GLfloat), GLfloat, m[ 6]); + WRITE_DATA(7*sizeof(GLfloat), GLfloat, m[ 7]); + WRITE_DATA(8*sizeof(GLfloat), GLfloat, m[ 8]); + WRITE_DATA(9*sizeof(GLfloat), GLfloat, m[ 9]); + WRITE_DATA(10*sizeof(GLfloat), GLfloat, m[10]); + WRITE_DATA(11*sizeof(GLfloat), GLfloat, m[11]); + WRITE_DATA(12*sizeof(GLfloat), GLfloat, m[12]); + WRITE_DATA(13*sizeof(GLfloat), GLfloat, m[13]); + WRITE_DATA(14*sizeof(GLfloat), GLfloat, m[14]); + WRITE_DATA(15*sizeof(GLfloat), GLfloat, m[15]); + WRITE_OPCODE(pc, CR_LOADMATRIXF_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackMultTransposeMatrixdARB(const GLdouble *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_MULTTRANSPOSEMATRIXDARB_EXTEND_OPCODE); + WRITE_DOUBLE(8 + 0*sizeof(double), m[ 0]); + WRITE_DOUBLE(8 + 1*sizeof(double), m[ 1]); + WRITE_DOUBLE(8 + 2*sizeof(double), m[ 2]); + WRITE_DOUBLE(8 + 3*sizeof(double), m[ 3]); + WRITE_DOUBLE(8 + 4*sizeof(double), m[ 4]); + WRITE_DOUBLE(8 + 5*sizeof(double), m[ 5]); + WRITE_DOUBLE(8 + 6*sizeof(double), m[ 6]); + WRITE_DOUBLE(8 + 7*sizeof(double), m[ 7]); + WRITE_DOUBLE(8 + 8*sizeof(double), m[ 8]); + WRITE_DOUBLE(8 + 9*sizeof(double), m[ 9]); + WRITE_DOUBLE(8 + 10*sizeof(double), m[10]); + WRITE_DOUBLE(8 + 11*sizeof(double), m[11]); + WRITE_DOUBLE(8 + 12*sizeof(double), m[12]); + WRITE_DOUBLE(8 + 13*sizeof(double), m[13]); + WRITE_DOUBLE(8 + 14*sizeof(double), m[14]); + WRITE_DOUBLE(8 + 15*sizeof(double), m[15]); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackMultTransposeMatrixfARB(const GLfloat *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_MULTTRANSPOSEMATRIXFARB_EXTEND_OPCODE); + WRITE_DATA(8 + 0*sizeof(GLfloat), GLfloat, m[ 0]); + WRITE_DATA(8 + 1*sizeof(GLfloat), GLfloat, m[ 1]); + WRITE_DATA(8 + 2*sizeof(GLfloat), GLfloat, m[ 2]); + WRITE_DATA(8 + 3*sizeof(GLfloat), GLfloat, m[ 3]); + WRITE_DATA(8 + 4*sizeof(GLfloat), GLfloat, m[ 4]); + WRITE_DATA(8 + 5*sizeof(GLfloat), GLfloat, m[ 5]); + WRITE_DATA(8 + 6*sizeof(GLfloat), GLfloat, m[ 6]); + WRITE_DATA(8 + 7*sizeof(GLfloat), GLfloat, m[ 7]); + WRITE_DATA(8 + 8*sizeof(GLfloat), GLfloat, m[ 8]); + WRITE_DATA(8 + 9*sizeof(GLfloat), GLfloat, m[ 9]); + WRITE_DATA(8 + 10*sizeof(GLfloat), GLfloat, m[10]); + WRITE_DATA(8 + 11*sizeof(GLfloat), GLfloat, m[11]); + WRITE_DATA(8 + 12*sizeof(GLfloat), GLfloat, m[12]); + WRITE_DATA(8 + 13*sizeof(GLfloat), GLfloat, m[13]); + WRITE_DATA(8 + 14*sizeof(GLfloat), GLfloat, m[14]); + WRITE_DATA(8 + 15*sizeof(GLfloat), GLfloat, m[15]); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackLoadTransposeMatrixdARB(const GLdouble *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_LOADTRANSPOSEMATRIXDARB_EXTEND_OPCODE); + WRITE_DOUBLE(8 + 0*sizeof(double), m[ 0]); + WRITE_DOUBLE(8 + 1*sizeof(double), m[ 1]); + WRITE_DOUBLE(8 + 2*sizeof(double), m[ 2]); + WRITE_DOUBLE(8 + 3*sizeof(double), m[ 3]); + WRITE_DOUBLE(8 + 4*sizeof(double), m[ 4]); + WRITE_DOUBLE(8 + 5*sizeof(double), m[ 5]); + WRITE_DOUBLE(8 + 6*sizeof(double), m[ 6]); + WRITE_DOUBLE(8 + 7*sizeof(double), m[ 7]); + WRITE_DOUBLE(8 + 8*sizeof(double), m[ 8]); + WRITE_DOUBLE(8 + 9*sizeof(double), m[ 9]); + WRITE_DOUBLE(8 + 10*sizeof(double), m[10]); + WRITE_DOUBLE(8 + 11*sizeof(double), m[11]); + WRITE_DOUBLE(8 + 12*sizeof(double), m[12]); + WRITE_DOUBLE(8 + 13*sizeof(double), m[13]); + WRITE_DOUBLE(8 + 14*sizeof(double), m[14]); + WRITE_DOUBLE(8 + 15*sizeof(double), m[15]); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackLoadTransposeMatrixfARB(const GLfloat *m) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = 16*sizeof(*m) + sizeof(GLint) + sizeof(GLenum); + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_LOADTRANSPOSEMATRIXFARB_EXTEND_OPCODE); + WRITE_DATA(8 + 0*sizeof(GLfloat), GLfloat, m[ 0]); + WRITE_DATA(8 + 1*sizeof(GLfloat), GLfloat, m[ 1]); + WRITE_DATA(8 + 2*sizeof(GLfloat), GLfloat, m[ 2]); + WRITE_DATA(8 + 3*sizeof(GLfloat), GLfloat, m[ 3]); + WRITE_DATA(8 + 4*sizeof(GLfloat), GLfloat, m[ 4]); + WRITE_DATA(8 + 5*sizeof(GLfloat), GLfloat, m[ 5]); + WRITE_DATA(8 + 6*sizeof(GLfloat), GLfloat, m[ 6]); + WRITE_DATA(8 + 7*sizeof(GLfloat), GLfloat, m[ 7]); + WRITE_DATA(8 + 8*sizeof(GLfloat), GLfloat, m[ 8]); + WRITE_DATA(8 + 9*sizeof(GLfloat), GLfloat, m[ 9]); + WRITE_DATA(8 + 10*sizeof(GLfloat), GLfloat, m[10]); + WRITE_DATA(8 + 11*sizeof(GLfloat), GLfloat, m[11]); + WRITE_DATA(8 + 12*sizeof(GLfloat), GLfloat, m[12]); + WRITE_DATA(8 + 13*sizeof(GLfloat), GLfloat, m[13]); + WRITE_DATA(8 + 14*sizeof(GLfloat), GLfloat, m[14]); + WRITE_DATA(8 + 15*sizeof(GLfloat), GLfloat, m[15]); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_misc.c b/src/VBox/GuestHost/OpenGL/packer/pack_misc.c new file mode 100644 index 00000000..17d643cc --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_misc.c @@ -0,0 +1,216 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_error.h" + +void PACK_APIENTRY crPackChromiumParametervCR(CR_PACKER_CONTEXT_ARGDECL GLenum target, GLenum type, GLsizei count, const GLvoid *values) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned int header_length = 2 * sizeof(int) + sizeof(target) + sizeof(type) + sizeof(count); + unsigned int packet_length; + unsigned int params_length = 0; + unsigned char *data_ptr; + int i, pos; + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + params_length = sizeof(GLbyte) * count; + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + params_length = sizeof(GLshort) * count; + break; + case GL_INT: + case GL_UNSIGNED_INT: + params_length = sizeof(GLint) * count; + break; +#ifndef IN_RING0 + case GL_FLOAT: + params_length = sizeof(GLfloat) * count; + break; +#endif +#if 0 + case GL_DOUBLE: + params_length = sizeof(GLdouble) * count; + break; +#endif + default: + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackChromiumParametervCR(bad type)" ); + return; + } + + packet_length = header_length + params_length; + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_CHROMIUMPARAMETERVCR_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, target ); + WRITE_DATA( 12, GLenum, type ); + WRITE_DATA( 16, GLsizei, count ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + + pos = header_length; + + switch (type) { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + for (i = 0; i < count; i++, pos += sizeof(GLbyte)) { + WRITE_DATA( pos, GLbyte, ((GLbyte *) values)[i]); + } + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + for (i = 0; i < count; i++, pos += sizeof(GLshort)) { + WRITE_DATA( pos, GLshort, ((GLshort *) values)[i]); + } + break; + case GL_INT: + case GL_UNSIGNED_INT: + for (i = 0; i < count; i++, pos += sizeof(GLint)) { + WRITE_DATA( pos, GLint, ((GLint *) values)[i]); + } + break; +#ifndef IN_RING0 + case GL_FLOAT: + for (i = 0; i < count; i++, pos += sizeof(GLfloat)) { + WRITE_DATA( pos, GLfloat, ((GLfloat *) values)[i]); + } + break; +#endif +#if 0 + case GL_DOUBLE: + for (i = 0; i < count; i++) { + WRITE_foo_DATA( sizeof(int) + 12, GLdouble, ((GLdouble *) values)[i]); + } + break; +#endif + default: + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackChromiumParametervCR(bad type)" ); + CR_UNLOCK_PACKER_CONTEXT(pc); + return; + } + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +#ifndef IN_RING0 +void PACK_APIENTRY crPackDeleteQueriesARB(CR_PACKER_CONTEXT_ARGDECL GLsizei n, const GLuint * ids) +{ + unsigned char *data_ptr; + int packet_length = sizeof(GLenum)+sizeof(n)+n*sizeof(*ids); + if (!ids) return; + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, CR_DELETEQUERIESARB_EXTEND_OPCODE); + WRITE_DATA(4, GLsizei, n); + crMemcpy(data_ptr + 8, ids, n*sizeof(*ids)); + crHugePacket(CR_EXTEND_OPCODE, data_ptr); + crPackFree(data_ptr); +} +#endif + +void PACK_APIENTRY crPackVBoxTexPresent( CR_PACKER_CONTEXT_ARGDECL GLuint texture, GLuint cfg, GLint xPos, GLint yPos, GLint cRects, const GLint * pRects ) +{ + GLint i, size, cnt; + + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + size = 28 + cRects * 4 * sizeof(GLint); + CR_GET_BUFFERED_POINTER( pc, size ); + WRITE_DATA( 0, GLint, size ); + WRITE_DATA( 4, GLenum, CR_VBOXTEXPRESENT_EXTEND_OPCODE ); + WRITE_DATA( 8, GLuint, texture ); + WRITE_DATA( 12, GLuint, cfg ); + WRITE_DATA( 16, GLint, xPos ); + WRITE_DATA( 20, GLint, yPos ); + WRITE_DATA( 24, GLint, cRects ); + + cnt = 28; + for (i=0; ialignment != 1) { + GLint remainder = bytes_per_row % packstate->alignment; + if (remainder) + stride = bytes_per_row + (packstate->alignment - remainder); + } + + CR_GET_BUFFERED_POINTER(pc, 48 + sizeof(CRNetworkPointer) ); + WRITE_DATA( 0, GLint, x ); + WRITE_DATA( 4, GLint, y ); + WRITE_DATA( 8, GLsizei, width ); + WRITE_DATA( 12, GLsizei, height ); + WRITE_DATA( 16, GLenum, format ); + WRITE_DATA( 20, GLenum, type ); + WRITE_DATA( 24, GLint, stride ); /* XXX not really used! */ + WRITE_DATA( 28, GLint, packstate->alignment ); + WRITE_DATA( 32, GLint, packstate->skipRows ); + WRITE_DATA( 36, GLint, packstate->skipPixels ); + WRITE_DATA( 40, GLint, bytes_per_row ); + WRITE_DATA( 44, GLint, packstate->rowLength ); + WRITE_NETWORK_POINTER( 48, (char *) pixels ); + WRITE_OPCODE( pc, CR_READPIXELS_OPCODE ); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +/* Round N up to the next multiple of 8 */ +#define CEIL8(N) (((N) + 7) & ~0x7) + +void PACK_APIENTRY crPackBitmap(GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap, const CRPixelPackState *unpack ) +{ + const int noimagedata = (bitmap == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + unsigned char *data_ptr; + int data_length = 0; + /*GLubyte *destBitmap = NULL; - unused */ + int packet_length = + sizeof( width ) + + sizeof( height ) + + sizeof( xorig ) + + sizeof( yorig ) + + sizeof( xmove ) + + sizeof( ymove ) + + sizeof( GLuint ) + sizeof(GLint); + + if (!noimagedata) + { + data_length = CEIL8(width) * height / 8; + packet_length += data_length; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + + WRITE_DATA( 0, GLsizei, width ); + WRITE_DATA( 4, GLsizei, height ); + WRITE_DATA( 8, GLfloat, xorig ); + WRITE_DATA( 12, GLfloat, yorig ); + WRITE_DATA( 16, GLfloat, xmove ); + WRITE_DATA( 20, GLfloat, ymove ); + WRITE_DATA( 24, GLuint, noimagedata ); + WRITE_DATA( 28, GLint, (GLint) (uintptr_t) bitmap); + + if (!noimagedata) + crBitmapCopy(width, height, (GLubyte *)(data_ptr + 32), bitmap, unpack); + + crHugePacket( CR_BITMAP_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} +/* + ZPix - compressed DrawPixels +*/ +void PACK_APIENTRY crPackZPixCR( GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLenum ztype, GLint zparm, GLint length, + const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + (void)unpackstate; + + if (pixels == NULL) + { + return; + } + + packet_length = + sizeof( int ) + /* packet size */ + sizeof( GLenum ) + /* extended opcode */ + sizeof( width ) + + sizeof( height ) + + sizeof( format ) + + sizeof( type ) + + sizeof( ztype ) + + sizeof( zparm ) + + sizeof( length ); + + packet_length += length; + +/* XXX JAG + crDebug("PackZPixCR: fb %d x %d, state %d, zlen = %d, plen = %d", + width, height, ztype, length, packet_length); +*/ + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum , CR_ZPIXCR_EXTEND_OPCODE ); + WRITE_DATA( 4, GLsizei, width ); + WRITE_DATA( 8, GLsizei, height ); + WRITE_DATA( 12, GLenum, format ); + WRITE_DATA( 16, GLenum, type ); + WRITE_DATA( 20, GLenum, ztype ); + WRITE_DATA( 24, GLint, zparm ); + WRITE_DATA( 28, GLint, length ); + + crMemcpy((void *) (data_ptr+32), pixels, length); + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + + +void PACK_APIENTRY +crPackGetTexImage( GLenum target, GLint level, GLenum format, GLenum type, + GLvoid * pixels, const CRPixelPackState * packstate, + int * writeback ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; (void) packstate; + CR_GET_BUFFERED_POINTER( pc, 40 ); + WRITE_DATA( 0, GLint, 40 ); + WRITE_DATA( 4, GLenum, CR_GETTEXIMAGE_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, target ); + WRITE_DATA( 12, GLint, level ); + WRITE_DATA( 16, GLenum, format ); + WRITE_DATA( 20, GLenum, type ); + WRITE_NETWORK_POINTER( 24, (void *) pixels ); + WRITE_NETWORK_POINTER( 32, (void *) writeback ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_point.c b/src/VBox/GuestHost/OpenGL/packer/pack_point.c new file mode 100644 index 00000000..3df4ddb8 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_point.c @@ -0,0 +1,107 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_version.h" + +#ifdef CR_ARB_point_parameters + +static GLboolean __handlePointDataf( GLenum pname, const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + int params_length = 0; + int packet_length = 2 * sizeof( int ) + sizeof( pname ); + unsigned char *data_ptr; + switch( pname ) + { + case GL_POINT_SIZE_MIN_ARB: + case GL_POINT_SIZE_MAX_ARB: + case GL_POINT_FADE_THRESHOLD_SIZE_ARB: + params_length = sizeof( *params ); + break; + case GL_POINT_DISTANCE_ATTENUATION_ARB: + params_length = 3 * sizeof( *params ); + break; + default: + { + char msg[100]; + sprintf(msg, "Invalid pname in PointParameter: %d", (int) pname ); + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg); + } + return GL_FALSE; + } + packet_length += params_length; + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_POINTPARAMETERFVARB_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, pname ); + WRITE_DATA( 12, GLfloat, params[0] ); + if (packet_length > 16) + { + WRITE_DATA( 16, GLfloat, params[1] ); + WRITE_DATA( 20, GLfloat, params[2] ); + } + return GL_TRUE; +} + +void PACK_APIENTRY crPackPointParameterfvARB(GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handlePointDataf( pname, params )) + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +#endif + +static GLboolean __handlePointDatai( GLenum pname, const GLint *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + int params_length = 0; + int packet_length = 2 * sizeof( int ) + sizeof( pname ); + unsigned char *data_ptr; + switch( pname ) + { + case GL_POINT_SIZE_MIN_ARB: + case GL_POINT_SIZE_MAX_ARB: + case GL_POINT_FADE_THRESHOLD_SIZE_ARB: + params_length = sizeof( *params ); + break; + case GL_POINT_DISTANCE_ATTENUATION_ARB: + params_length = 3 * sizeof( *params ); + break; + default: + { + char msg[100]; + sprintf(msg, "Invalid pname in PointParameter: %d", (int) pname ); + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, msg); + } + return GL_FALSE; + } + packet_length += params_length; + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, GLint, packet_length ); + WRITE_DATA( 4, GLenum, CR_POINTPARAMETERIV_EXTEND_OPCODE ); + WRITE_DATA( 8, GLenum, pname ); + WRITE_DATA( 12, GLint, params[0] ); + if (packet_length > 16) + { + WRITE_DATA( 16, GLint, params[1] ); + WRITE_DATA( 20, GLint, params[2] ); + } + return GL_TRUE; +} + +void PACK_APIENTRY crPackPointParameteriv(GLenum pname, const GLint *params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handlePointDatai( pname, params )) + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_program.c b/src/VBox/GuestHost/OpenGL/packer/pack_program.c new file mode 100644 index 00000000..8a62e01b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_program.c @@ -0,0 +1,542 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +/* + * Packer functions for GL_NV_vertex_program extension. + * XXX: Quite a few of these functions are unfinished. + */ + + +#include "packer.h" +#include "cr_error.h" + + +void PACK_APIENTRY crPackProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + int packet_length = sizeof(int) + sizeof(target) + sizeof(index) + sizeof(num) + num * 4 * sizeof(GLdouble); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, target); + WRITE_DATA(sizeof(int) + 4, GLuint, index); + WRITE_DATA(sizeof(int) + 8, GLuint, num); + crMemcpy(data_ptr + sizeof(int) + 12, params, num * 4 * sizeof(GLdouble)); + + WRITE_OPCODE(pc, CR_PROGRAMPARAMETERS4DVNV_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void PACK_APIENTRY crPackProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + int packet_length = sizeof(int) + sizeof(target) + sizeof(index) + sizeof(num) + num * 4 * sizeof(GLfloat); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, target); + WRITE_DATA(sizeof(int) + 4, GLuint, index); + WRITE_DATA(sizeof(int) + 8, GLuint, num); + crMemcpy(data_ptr + sizeof(int) + 12, params, num * 4 * sizeof(GLfloat)); + + WRITE_OPCODE(pc, CR_PROGRAMPARAMETERS4FVNV_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void PACK_APIENTRY crPackVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib1dvARB(index + i, v + i); +} + + +void PACK_APIENTRY crPackVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib1fvARB(index + i, v + i); +} + + +void PACK_APIENTRY crPackVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib1svARB(index + i, v + i); +} + + +void PACK_APIENTRY crPackVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib2dvARB(index + i, v + 2 * i); +} + +void PACK_APIENTRY crPackVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib2fvARB(index + i, v + 2 * i); +} + +void PACK_APIENTRY crPackVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib2svARB(index + i, v + 2 * i); +} + +void PACK_APIENTRY crPackVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib3dvARB(index + i, v + 3 * i); +} + +void PACK_APIENTRY crPackVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib3fvARB(index + i, v + 3 * i); +} + +void PACK_APIENTRY crPackVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib3svARB(index + i, v + 3 * i); +} + +void PACK_APIENTRY crPackVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib4dvARB(index + i, v + 4 * i); +} + +void PACK_APIENTRY crPackVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib4fvARB(index + i, v + 4 * i); +} + +void PACK_APIENTRY crPackVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib4svARB(index + i, v + 4 * i); +} + +void PACK_APIENTRY crPackVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v) +{ + GLint i; + /* reverse order so we hit index 0 last (provoking glVertex) */ + for (i = n - 1; i >= 0; i--) + crPackVertexAttrib4ubvARB(index + i, v + 4 * i); +} + + +void PACK_APIENTRY crPackExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) +{ + const int packet_length = 32; + unsigned char *data_ptr = NULL; + CR_GET_PACKER_CONTEXT(pc); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(4, GLenum, CR_EXECUTEPROGRAMNV_EXTEND_OPCODE); + WRITE_DATA(8, GLenum, target); + WRITE_DATA(12, GLuint, id); + WRITE_DATA(16, GLfloat, params[0]); + WRITE_DATA(20, GLfloat, params[1]); + WRITE_DATA(24, GLfloat, params[2]); + WRITE_DATA(28, GLfloat, params[3]); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program) +{ + const int packet_length = 20 + len; + unsigned char *data_ptr = NULL; + CR_GET_PACKER_CONTEXT(pc); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(4, GLenum, CR_LOADPROGRAMNV_EXTEND_OPCODE); + WRITE_DATA(8, GLenum, target); + WRITE_DATA(12, GLuint, id); + WRITE_DATA(16, GLsizei, len); + crMemcpy((void *) (data_ptr + 20), program, len); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackRequestResidentProgramsNV(GLsizei n, const GLuint *ids) +{ + CR_GET_PACKER_CONTEXT(pc); + (void) pc; + (void) n; + (void) ids; + /* We're no-op'ing this function for now. */ +} + + +void PACK_APIENTRY crPackProgramNamedParameter4fNV (GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + int packet_length = 32 + len; + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_PROGRAMNAMEDPARAMETER4FNV_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, id); + WRITE_DATA(12, GLsizei, len); + WRITE_DATA(16, GLfloat, x); + WRITE_DATA(20, GLfloat, y); + WRITE_DATA(24, GLfloat, z); + WRITE_DATA(28, GLfloat, w); + crMemcpy((void *) (data_ptr + 32), name, len); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackProgramNamedParameter4dNV (GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + int packet_length = 48 + len; + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_PROGRAMNAMEDPARAMETER4DNV_EXTEND_OPCODE); + WRITE_DATA(8, GLenum, id); + WRITE_DATA(12, GLuint, len); + WRITE_DOUBLE(16, x); + WRITE_DOUBLE(24, y); + WRITE_DOUBLE(32, z); + WRITE_DOUBLE(40, w); + crMemcpy((void *) (data_ptr + 48), name, len); + + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackProgramNamedParameter4fvNV (GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v) +{ + crPackProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); +} + +void PACK_APIENTRY crPackProgramNamedParameter4dvNV (GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v) +{ + crPackProgramNamedParameter4dNV(id, len, name, v[0], v[1], v[2], v[3]); +} + + +void PACK_APIENTRY +crPackAreProgramsResidentNV(GLsizei n, const GLuint * programs, + GLboolean *residences, GLboolean *return_val, + int *writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + int packet_length; + + (void) return_val; /* Caller must compute this from residences!!! */ + + packet_length = sizeof(int) + /* packet length */ + sizeof(GLenum) + /* extend opcode */ + sizeof(n) + /* num programs */ + n * sizeof(*programs) + /* programs */ + 8 + 8; + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(4, GLenum, CR_AREPROGRAMSRESIDENTNV_EXTEND_OPCODE); + WRITE_DATA(8, GLsizei, n); + crMemcpy(data_ptr + 12, programs, n * sizeof(*programs)); + WRITE_NETWORK_POINTER(12 + n * sizeof(*programs), (void *) residences); + WRITE_NETWORK_POINTER(20 + n * sizeof(*programs), (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void PACK_APIENTRY crPackGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, GLfloat *params, int *writeback) +{ + int packet_length = 32 + len; + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_GETPROGRAMNAMEDPARAMETERFVNV_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, id); + WRITE_DATA(12, GLsizei, len); + crMemcpy(data_ptr + 16, name, len); + WRITE_NETWORK_POINTER(16 + len, (void *) params); + WRITE_NETWORK_POINTER(16 + len + 8, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, GLdouble *params, int *writeback) +{ + int packet_length = 32 + len; + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, GLint, packet_length); + WRITE_DATA(4, GLenum, CR_GETPROGRAMNAMEDPARAMETERDVNV_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, id); + WRITE_DATA(12, GLsizei, len); + crMemcpy(data_ptr + 16, name, len); + WRITE_NETWORK_POINTER(16 + len, (void *) params); + WRITE_NETWORK_POINTER(16 + len + 8, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void PACK_APIENTRY crPackDeleteProgramsARB(GLsizei n, const GLuint *ids) +{ + unsigned char *data_ptr = NULL; + int packet_length = sizeof(GLenum) + sizeof(n) + n * sizeof(*ids); + + if (!ids) + return; + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, CR_DELETEPROGRAMSARB_EXTEND_OPCODE); + WRITE_DATA(4, GLsizei, n); + crMemcpy(data_ptr + 8, ids, n * sizeof(*ids)); + crHugePacket(CR_EXTEND_OPCODE, data_ptr); + crPackFree(data_ptr); +} + + +void PACK_APIENTRY crPackProgramStringARB(GLenum target, GLenum format, GLsizei len, const void *string) +{ + const int packet_length = 20 + len; + unsigned char *data_ptr = NULL; + CR_GET_PACKER_CONTEXT(pc); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(4, GLenum, CR_PROGRAMSTRINGARB_EXTEND_OPCODE); + WRITE_DATA(8, GLenum, target); + WRITE_DATA(12, GLuint, format); + WRITE_DATA(16, GLsizei, len); + crMemcpy((void *) (data_ptr + 20), string, len); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +/* + * Can't easily auto-generate these functions since there aren't + * non-vector versions. + */ + +void PACK_APIENTRY crPackVertexAttrib4NbvARB(GLuint index, const GLbyte *v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 8); + pc->current.c.vertexAttrib.b4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLbyte, v[0]); + WRITE_DATA(5, GLbyte, v[1]); + WRITE_DATA(6, GLbyte, v[2]); + WRITE_DATA(7, GLbyte, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4NBVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4NivARB(GLuint index, const GLint *v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 20); + pc->current.c.vertexAttrib.i4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLint, v[0]); + WRITE_DATA(8, GLint, v[1]); + WRITE_DATA(12, GLint, v[2]); + WRITE_DATA(16, GLint, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4NIVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4NsvARB(GLuint index, const GLshort *v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 12); + pc->current.c.vertexAttrib.s4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLshort, v[0]); + WRITE_DATA(6, GLshort, v[1]); + WRITE_DATA(8, GLshort, v[2]); + WRITE_DATA(10, GLshort, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4NSVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4NubvARB(GLuint index, const GLubyte * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 8); + pc->current.c.vertexAttrib.ub4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLubyte, v[0]); + WRITE_DATA(5, GLubyte, v[1]); + WRITE_DATA(6, GLubyte, v[2]); + WRITE_DATA(7, GLubyte, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4NUBVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4NuivARB(GLuint index, const GLuint * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 20); + pc->current.c.vertexAttrib.ui4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLuint, v[0]); + WRITE_DATA(8, GLuint, v[1]); + WRITE_DATA(12, GLuint, v[2]); + WRITE_DATA(16, GLuint, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4NUIVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4NusvARB(GLuint index, const GLushort * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 12); + pc->current.c.vertexAttrib.s4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLushort, v[0]); + WRITE_DATA(6, GLushort, v[1]); + WRITE_DATA(8, GLushort, v[2]); + WRITE_DATA(10, GLushort, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4NUSVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4bvARB(GLuint index, const GLbyte * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 8); + pc->current.c.vertexAttrib.b4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLbyte, v[0]); + WRITE_DATA(5, GLbyte, v[1]); + WRITE_DATA(6, GLbyte, v[2]); + WRITE_DATA(7, GLbyte, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4BVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4ivARB(GLuint index, const GLint * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 20); + pc->current.c.vertexAttrib.i4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLint, v[0]); + WRITE_DATA(8, GLint, v[1]); + WRITE_DATA(12, GLint, v[2]); + WRITE_DATA(16, GLint, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4IVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4uivARB(GLuint index, const GLuint * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 20); + pc->current.c.vertexAttrib.ui4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLuint, v[0]); + WRITE_DATA(8, GLuint, v[1]); + WRITE_DATA(12, GLuint, v[2]); + WRITE_DATA(16, GLuint, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4UIVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackVertexAttrib4usvARB(GLuint index, const GLushort * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 12); + pc->current.c.vertexAttrib.s4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLushort, v[0]); + WRITE_DATA(6, GLushort, v[1]); + WRITE_DATA(8, GLushort, v[2]); + WRITE_DATA(10, GLushort, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4USVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void PACK_APIENTRY crPackVertexAttrib4ubvARB(GLuint index, const GLubyte * v) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr = NULL; + CR_GET_BUFFERED_POINTER(pc, 8); + pc->current.c.vertexAttrib.ub4[index] = data_ptr + 4; + pc->current.attribsUsedMask |= (1 << index); + WRITE_DATA(0, GLuint, index); + WRITE_DATA(4, GLubyte, v[0]); + WRITE_DATA(5, GLubyte, v[1]); + WRITE_DATA(6, GLubyte, v[2]); + WRITE_DATA(7, GLubyte, v[3]); + WRITE_OPCODE(pc, CR_VERTEXATTRIB4UBVARB_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c b/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c new file mode 100644 index 00000000..ddfff764 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_regcombiner.c @@ -0,0 +1,82 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" + +static GLboolean __handleCombinerParameterData(GLenum pname, const GLfloat *params, GLenum extended_opcode) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned int params_length = 0; + unsigned int packet_length = sizeof(int) + sizeof(extended_opcode) + sizeof(pname); + unsigned char *data_ptr; + + switch(pname) + { + case GL_CONSTANT_COLOR0_NV: + case GL_CONSTANT_COLOR1_NV: + params_length = 4 * sizeof(*params); + break; + case GL_NUM_GENERAL_COMBINERS_NV: + case GL_COLOR_SUM_CLAMP_NV: + params_length = sizeof(*params); + break; + default: + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackCombinerParameter(bad pname)"); + CRASSERT(0); + return GL_FALSE; + } + packet_length += params_length; + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, extended_opcode); + WRITE_DATA(sizeof(int) + 4, GLenum, pname); + WRITE_DATA(sizeof(int) + 8, GLfloat, params[0]); + if (params_length > sizeof(*params)) + { + WRITE_DATA(sizeof(int) + 12, GLfloat, params[1]); + WRITE_DATA(sizeof(int) + 16, GLfloat, params[2]); + WRITE_DATA(sizeof(int) + 20, GLfloat, params[3]); + CRASSERT(packet_length == sizeof(int) + 20 + 4); + } + return GL_TRUE; +} + +void PACK_APIENTRY crPackCombinerParameterfvNV(GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleCombinerParameterData(pname, params, CR_COMBINERPARAMETERFVNV_EXTEND_OPCODE)) + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackCombinerParameterivNV(GLenum pname, const GLint *params) +{ + /* floats and ints are the same size, so the packing should be the same */ + CR_GET_PACKER_CONTEXT(pc); + if (__handleCombinerParameterData(pname, (const GLfloat *) params, CR_COMBINERPARAMETERIVNV_EXTEND_OPCODE)) + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackCombinerStageParameterfvNV(GLenum stage, GLenum pname, const GLfloat *params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_COMBINERSTAGEPARAMETERFVNV_EXTEND_OPCODE); + WRITE_DATA(8, GLenum, stage); + WRITE_DATA(12, GLenum, pname); + WRITE_DATA(16, GLfloat, params[0]); + WRITE_DATA(20, GLfloat, params[1]); + WRITE_DATA(24, GLfloat, params[2]); + WRITE_DATA(28, GLfloat, params[3]); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_shaders.c b/src/VBox/GuestHost/OpenGL/packer/pack_shaders.c new file mode 100644 index 00000000..77114118 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_shaders.c @@ -0,0 +1,866 @@ +/* $Id: pack_shaders.c $ */ + +/** @file + * VBox OpenGL DRI driver functions + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "packer.h" +#include "cr_error.h" +#include "cr_string.h" + +void PACK_APIENTRY crPackBindAttribLocation(GLuint program, GLuint index, const char *name) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int cbName = crStrlen(name)+1; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(program)+sizeof(index) + cbName*sizeof(*name); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_BINDATTRIBLOCATION_EXTEND_OPCODE); + WRITE_DATA_AI(GLuint, program); + WRITE_DATA_AI(GLuint, index); + crMemcpy(data_ptr, name, cbName*sizeof(*name)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackShaderSource(GLuint shader, GLsizei count, const char **string, const GLint *length) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + GLint *pLocalLength; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(shader)+sizeof(count)+sizeof(GLint)+count*sizeof(*pLocalLength); + GLsizei i; + + if ((0==count) || (!string)) return; + + pLocalLength = crAlloc(count*sizeof(*length)); + if (!pLocalLength) return; + + for (i=0; i=0)) ? length[i] : crStrlen(string[i]))+1; + packet_length += pLocalLength[i]; + } + + if (length) + { + packet_length += count*sizeof(*length); + } + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_SHADERSOURCE_EXTEND_OPCODE); + WRITE_DATA_AI(GLuint, shader); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLint, (GLint)(length ? 1:0)); + crMemcpy(data_ptr, pLocalLength, count*sizeof(*pLocalLength)); + data_ptr += count*sizeof(*pLocalLength); + + if (length) + { + crMemcpy(data_ptr, length, count*sizeof(*length)); + data_ptr += count*sizeof(*length); + } + + for (i=0; i=0)) + { + /* include \0 in the string to make intel drivers happy */ + crMemcpy(data_ptr, string[i], pLocalLength[i] - 1); + data_ptr[pLocalLength[i] - 1] = '\0'; + } + else + { + /* the \0 s already in the string */ + crMemcpy(data_ptr, string[i], pLocalLength[i]); + } + } + else + { + CRASSERT(pLocalLength[i]==1); + *data_ptr = 0; + } + data_ptr += pLocalLength[i]; + } + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); + + crFree(pLocalLength); +} + +void PACK_APIENTRY crPackUniform1fv(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM1FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniform1iv(GLint location, GLsizei count, const GLint *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM1IV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniform2fv(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + 2*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM2FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, 2*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniform2iv(GLint location, GLsizei count, const GLint *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + 2*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM2IV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, 2*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniform3fv(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + 3*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM3FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, 3*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniform3iv(GLint location, GLsizei count, const GLint *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + 3*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM3IV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, 3*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniform4fv(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + 4*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM4FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, 4*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniform4iv(GLint location, GLsizei count, const GLint *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count) + 4*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORM4IV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + crMemcpy(data_ptr, value, 4*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + 2*2*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX2FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 2*2*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + 3*3*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX3FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 3*3*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + 4*4*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX4FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 4*4*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + + 2*3*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX2X3FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 2*3*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + + 3*2*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX3X2FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 3*2*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + + 2*4*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX2X4FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 2*4*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + + 4*2*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX4X2FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 4*2*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + + 3*4*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX3X4FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 3*4*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(location)+sizeof(count)+sizeof(transpose) + + 4*3*count*sizeof(*value); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_UNIFORMMATRIX4X3FV_EXTEND_OPCODE); + WRITE_DATA_AI(GLint, location); + WRITE_DATA_AI(GLsizei, count); + WRITE_DATA_AI(GLboolean, transpose); + crMemcpy(data_ptr, value, 4*3*count*sizeof(*value)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackDrawBuffers(GLsizei n, const GLenum *bufs) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(n) + n*sizeof(*bufs); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_DRAWBUFFERS_EXTEND_OPCODE); + WRITE_DATA_AI(GLsizei, n); + crMemcpy(data_ptr, bufs, n*sizeof(*bufs)); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +/** @todo next 8 functions are bit hacky, + * we expect packspu to pass a single structure with all output parameters via first output pointer. + * it'd be better to add CRMessageMultiReadback one day. + */ +void PACK_APIENTRY crPackGetActiveAttrib(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, char * name, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + (void) size; + (void) type; + (void) name; + CR_GET_BUFFERED_POINTER(pc, 36); + WRITE_DATA(0, GLint, 36); + WRITE_DATA(4, GLenum, CR_GETACTIVEATTRIB_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, program); + WRITE_DATA(12, GLuint, index); + WRITE_DATA(16, GLsizei, bufSize); + WRITE_NETWORK_POINTER(20, (void *) length); + WRITE_NETWORK_POINTER(28, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetActiveUniform(GLuint program, GLuint index, GLsizei bufSize, GLsizei * length, GLint * size, GLenum * type, char * name, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + (void) size; + (void) type; + (void) name; + CR_GET_BUFFERED_POINTER(pc, 36); + WRITE_DATA(0, GLint, 36); + WRITE_DATA(4, GLenum, CR_GETACTIVEUNIFORM_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, program); + WRITE_DATA(12, GLuint, index); + WRITE_DATA(16, GLsizei, bufSize); + WRITE_NETWORK_POINTER(20, (void *) length); + WRITE_NETWORK_POINTER(28, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetAttachedShaders(GLuint program, GLsizei maxCount, GLsizei * count, GLuint * shaders, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + (void) shaders; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETATTACHEDSHADERS_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, program); + WRITE_DATA(12, GLsizei, maxCount); + WRITE_NETWORK_POINTER(16, (void *) count); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetAttachedObjectsARB(VBoxGLhandleARB containerObj, GLsizei maxCount, GLsizei * count, VBoxGLhandleARB * obj, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; (void) obj; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETATTACHEDOBJECTSARB_EXTEND_OPCODE); + WRITE_DATA(8, VBoxGLhandleARB, containerObj); + WRITE_DATA(12, GLsizei, maxCount); + WRITE_NETWORK_POINTER(16, (void *) count); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetInfoLogARB(VBoxGLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; (void) infoLog; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETINFOLOGARB_EXTEND_OPCODE); + WRITE_DATA(8, VBoxGLhandleARB, obj); + WRITE_DATA(12, GLsizei, maxLength); + WRITE_NETWORK_POINTER(16, (void *) length); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetProgramInfoLog(GLuint program, GLsizei bufSize, GLsizei * length, char * infoLog, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + (void) infoLog; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETPROGRAMINFOLOG_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, program); + WRITE_DATA(12, GLsizei, bufSize); + WRITE_NETWORK_POINTER(16, (void *) length); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetShaderInfoLog(GLuint shader, GLsizei bufSize, GLsizei * length, char * infoLog, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + (void) infoLog; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETSHADERINFOLOG_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, shader); + WRITE_DATA(12, GLsizei, bufSize); + WRITE_NETWORK_POINTER(16, (void *) length); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetShaderSource(GLuint shader, GLsizei bufSize, GLsizei * length, char * source, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + (void) source; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETSHADERSOURCE_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, shader); + WRITE_DATA(12, GLsizei, bufSize); + WRITE_NETWORK_POINTER(16, (void *) length); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetUniformsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pData; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETUNIFORMSLOCATIONS_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, program); + WRITE_DATA(12, GLsizei, maxcbData); + WRITE_NETWORK_POINTER(16, (void *) cbData); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetAttribsLocations(GLuint program, GLsizei maxcbData, GLsizei * cbData, GLvoid * pData, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pData; + CR_GET_BUFFERED_POINTER(pc, 32); + WRITE_DATA(0, GLint, 32); + WRITE_DATA(4, GLenum, CR_GETATTRIBSLOCATIONS_EXTEND_OPCODE); + WRITE_DATA(8, GLuint, program); + WRITE_DATA(12, GLsizei, maxcbData); + WRITE_NETWORK_POINTER(16, (void *) cbData); + WRITE_NETWORK_POINTER(24, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetAttribLocation(GLuint program, const char * name, GLint * return_value, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int cbName = crStrlen(name)+1; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(program)+cbName*sizeof(*name)+16; + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_GETATTRIBLOCATION_EXTEND_OPCODE); + WRITE_DATA_AI(GLuint, program); + crMemcpy(data_ptr, name, cbName*sizeof(*name)); + data_ptr += cbName*sizeof(*name); + WRITE_NETWORK_POINTER(0, (void *) return_value); + WRITE_NETWORK_POINTER(8, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackGetUniformLocation(GLuint program, const char * name, GLint * return_value, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int cbName = crStrlen(name)+1; + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(program)+cbName*sizeof(*name)+16; + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_GETUNIFORMLOCATION_EXTEND_OPCODE); + WRITE_DATA_AI(GLuint, program); + crMemcpy(data_ptr, name, cbName*sizeof(*name)); + data_ptr += cbName*sizeof(*name); + WRITE_NETWORK_POINTER(0, (void *) return_value); + WRITE_NETWORK_POINTER(8, (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackBindAttribLocationSWAP(GLuint program, GLuint index, const char *name) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)program; + (void)index; + (void)name; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackShaderSourceSWAP(GLuint shader, GLsizei count, const char **string, const GLint *length) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)shader; + (void)count; + (void)string; + (void)length; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniform1fvSWAP(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + + +void PACK_APIENTRY crPackUniform1ivSWAP(GLint location, GLsizei count, const GLint *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniform2fvSWAP(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniform2ivSWAP(GLint location, GLsizei count, const GLint * value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniform3fvSWAP(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniform3ivSWAP(GLint location, GLsizei count, const GLint *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniform4fvSWAP(GLint location, GLsizei count, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniform4ivSWAP(GLint location, GLsizei count, const GLint *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix2fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix3fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix4fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix2x3fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix3x2fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix2x4fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix4x2fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix3x4fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackUniformMatrix4x3fvSWAP(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)location; + (void)count; + (void)transpose; + (void)value; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackDrawBuffersSWAP(GLsizei n, const GLenum *bufs) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)n; + (void)bufs; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackGetAttribLocationSWAP(GLuint program, const char * name, GLint * return_value, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)program; + (void)name; + (void)return_value; + (void)writeback; + (void)pc; + crError ("No swap version"); +} + +void PACK_APIENTRY crPackGetUniformLocationSWAP(GLuint program, const char * name, GLint * return_value, int * writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + (void)program; + (void)name; + (void)return_value; + (void)writeback; + (void)pc; + crError ("No swap version"); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_stipple.c b/src/VBox/GuestHost/OpenGL/packer/pack_stipple.c new file mode 100644 index 00000000..8d3e59dd --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_stipple.c @@ -0,0 +1,36 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_mem.h" +#include "cr_glstate.h" + +void PACK_APIENTRY crPackPolygonStipple( const GLubyte *mask ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int nodata = crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + int packet_length = sizeof(int); + + if (nodata) + packet_length += sizeof(GLint); + else + packet_length += 32*32/8; + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA_AI(int, nodata); + if (nodata) + { + WRITE_DATA_AI(GLint, (GLint)(uintptr_t)mask); + } + else + { + crMemcpy( data_ptr, mask, 32*32/8 ); + } + WRITE_OPCODE( pc, CR_POLYGONSTIPPLE_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_swap.py b/src/VBox/GuestHost/OpenGL/packer/pack_swap.py new file mode 100755 index 00000000..763f04eb --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_swap.py @@ -0,0 +1,74 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys, string + +sys.path.append( "../glapi_parser" ) +import apiutil + + +if len(sys.argv) != 2: + print >> sys.stderr, "Usage: %s " % sys.argv[0] + sys.exit(-1) + +file = open(sys.argv[1]) + +print("/* THIS FILE IS AUTOGENERATED FROM %s BY pack_swap.py */\n\n" % sys.argv[1]) + +for line in file.readlines(): + line = line.rstrip() + if line.find( "crPackAlloc" ) != -1 or line.find( "crPackFree" ) != -1: + print(line) + continue + elif line.find( "crPack" ) != -1: + fun_index = line.find( "crPack" ) + paren_index = line.find( "(", fun_index ) + space_index = line.find( " ", fun_index ) + quote_index = line.find( '"', fun_index ) + if paren_index == -1: + paren_index = 1000000; # HACK HACK + if space_index == -1: + space_index = 1000000; # HACK HACK + if quote_index == -1: + quote_index = 1000000; # HACK HACK + the_index = min( min( paren_index, space_index ), quote_index ) + print("%sSWAP%s" % (line[:the_index], line[the_index:])) + elif line.find("WRITE_DATA_AI") != -1: + lparen_index = line.find( "(" ) + rparen_index = line.rfind( ")" ) + args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) )) + indentation = line[:line.find( "WRITE_DATA_AI" )] + if apiutil.sizeof(args[0]) == 1: + print("%sWRITE_DATA_AI(%s, %s);" % (indentation, args[0], args[1])) + elif apiutil.sizeof(args[0]) == 2: + print("%sWRITE_DATA_AI(%s, SWAP16(%s) );" % (indentation, args[0], args[1])) + elif args[0] == 'GLfloat' or args[0] == 'GLclampf': + print("%sWRITE_DATA_AI(GLuint, SWAPFLOAT(%s) );" % (indentation, args[0])) + elif apiutil.sizeof(args[0]) == 4: + print("%sWRITE_DATA_AI(%s, SWAP32(%s));" % (indentation, args[0], args[1])) + else: + print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1] + sys.exit(-1) + elif line.find( "WRITE_DATA" ) != -1: + lparen_index = line.find( "(" ) + rparen_index = line.rfind( ")" ) + args = list(map( str.strip, line[lparen_index+1:rparen_index].split( "," ) )) + indentation = line[:line.find( "WRITE_DATA" )] + if apiutil.sizeof(args[1]) == 1: + print("%sWRITE_DATA(%s, %s, %s);" % (indentation, args[0], args[1], args[2])) + elif apiutil.sizeof(args[1]) == 2: + print("%sWRITE_DATA(%s, %s, SWAP16(%s));" % (indentation, args[0], args[1], args[2])) + elif args[1] == 'GLfloat' or args[1] == 'GLclampf': + print("%sWRITE_DATA(%s, GLuint, SWAPFLOAT(%s));" % (indentation, args[0], args[2])) + elif apiutil.sizeof(args[1]) == 4: + print("%sWRITE_DATA(%s, %s, SWAP32(%s));" % (indentation, args[0], args[1], args[2])) + else: + print >> sys.stderr, "UNKNOWN TYPE FOR WRITE_DATA: %s" % args[1] + sys.exit(-1) + elif line.find( "WRITE_DOUBLE" ) != -1: + print(line.replace( "WRITE_DOUBLE", "WRITE_SWAPPED_DOUBLE" )) + else: + print(line) diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c b/src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c new file mode 100644 index 00000000..aa99db5b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_swap_lists.c @@ -0,0 +1,117 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_error.h" +#include "cr_mem.h" + +static int __gl_CallListsNumBytes( GLenum type ) +{ + switch( type ) + { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_2_BYTES: + return 1; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_3_BYTES: + return 2; + case GL_INT: + case GL_UNSIGNED_INT: + case GL_FLOAT: + case GL_4_BYTES: + return 4; + default: + return -1; + } +} + +void PACK_APIENTRY crPackCallListsSWAP(GLint n, GLenum type, + const GLvoid *lists ) +{ + unsigned char *data_ptr; + int packet_length; + GLshort *shortPtr; + GLint *intPtr; + int i; + + int bytesPerList = __gl_CallListsNumBytes( type ); + int numBytes = bytesPerList * n; + + if (numBytes < 0) + { + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackCallLists(bad type)" ); + return; + } + + packet_length = sizeof( n ) + + sizeof( type ) + + numBytes; + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLint, SWAP32(n) ); + WRITE_DATA( 4, GLenum, SWAP32(type) ); + + crMemcpy( data_ptr + 8, lists, numBytes ); + shortPtr = (GLshort *) (data_ptr + 8); + intPtr = (GLint *) (data_ptr + 8); + + if (bytesPerList > 1) + { + for ( i = 0 ; i < n ; i++) + { + switch( bytesPerList ) + { + case 2: + *shortPtr = SWAP16(*shortPtr); + shortPtr+=1; + break; + case 4: + *intPtr = SWAP32(*intPtr); + intPtr+=1; + break; + } + } + } + + crHugePacket( CR_CALLLISTS_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + + +void PACK_APIENTRY crPackNewListSWAP( GLuint list, GLenum mode ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + CR_CMDBLOCK_BEGIN( pc, CRPACKBLOCKSTATE_OP_NEWLIST ); + CR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH( pc, 16, GL_FALSE ); + WRITE_DATA( 0, GLint, SWAP32(16) ); + WRITE_DATA( 4, GLenum, SWAP32(CR_NEWLIST_EXTEND_OPCODE) ); + WRITE_DATA( 8, GLuint, SWAP32(list) ); + WRITE_DATA( 12, GLenum, SWAP32(mode) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + pc->buffer.in_List = GL_TRUE; + pc->buffer.holds_List = GL_TRUE; + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +void PACK_APIENTRY crPackEndListSWAP( void ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + CR_GET_BUFFERED_POINTER( pc, 8 ); + WRITE_DATA( 0, GLint, SWAP32(8) ); + WRITE_DATA( 4, GLenum, SWAP32(CR_ENDLIST_EXTEND_OPCODE) ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + pc->buffer.in_List = GL_FALSE; + CR_CMDBLOCK_END( pc, CRPACKBLOCKSTATE_OP_NEWLIST ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c b/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c new file mode 100644 index 00000000..241f899e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_swap_map.c @@ -0,0 +1,278 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_error.h" + + +/* Note -- for these packets, the ustride and vstride are implicit, + * and are computed into the packet instead of copied. + */ + +static int __gl_Map2NumComponents(GLenum target) +{ + switch(target) + { + case GL_MAP2_VERTEX_3: + case GL_MAP2_NORMAL: + case GL_MAP2_TEXTURE_COORD_3: + return 3; + case GL_MAP2_VERTEX_4: + case GL_MAP2_COLOR_4: + case GL_MAP2_TEXTURE_COORD_4: + return 4; + case GL_MAP2_INDEX: + case GL_MAP2_TEXTURE_COORD_1: + return 1; + case GL_MAP2_TEXTURE_COORD_2: + return 2; + default: + return -1; + } +} + +static int __gl_Map1NumComponents(GLenum target) +{ + switch(target) + { + case GL_MAP1_VERTEX_3: + case GL_MAP1_NORMAL: + case GL_MAP1_TEXTURE_COORD_3: + return 3; + case GL_MAP1_VERTEX_4: + case GL_MAP1_COLOR_4: + case GL_MAP1_TEXTURE_COORD_4: + return 4; + case GL_MAP1_INDEX: + case GL_MAP1_TEXTURE_COORD_1: + return 1; + case GL_MAP1_TEXTURE_COORD_2: + return 2; + default: + return -1; + } +} + +void PACK_APIENTRY crPackMap2dSWAP(GLenum target, GLdouble u1, + GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, + GLint vstride, GLint vorder, const GLdouble *points) +{ + unsigned char *data_ptr; + int u,v; + int comp; + GLdouble *dest_data, *src_data; + int packet_length = + sizeof(target) + + sizeof(u1) + + sizeof(u2) + + sizeof(uorder) + + sizeof(ustride) + + sizeof(v1) + + sizeof(v2) + + sizeof(vorder) + + sizeof(vstride); + + int num_components = __gl_Map2NumComponents(target); + if (num_components < 0) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap2d(bad target)"); + return; + } + + packet_length += num_components*uorder*vorder*sizeof(*points); + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + + WRITE_DATA(0, GLenum, SWAP32(target)); + WRITE_SWAPPED_DOUBLE(4, u1); + WRITE_SWAPPED_DOUBLE(12, u2); + WRITE_DATA(20, GLint, SWAP32(num_components)); + WRITE_DATA(24, GLint, SWAP32(uorder)); + WRITE_SWAPPED_DOUBLE(28, v1); + WRITE_SWAPPED_DOUBLE(36, v2); + WRITE_DATA(44, GLint, SWAP32(num_components*uorder)); + WRITE_DATA(48, GLint, SWAP32(vorder)); + + dest_data = (GLdouble *) (data_ptr + 52); + src_data = (GLdouble *) points; + for (v = 0 ; v < vorder ; v++) + { + for (u = 0 ; u < uorder ; u++) + { + for (comp = 0 ; comp < num_components ; comp++) + { + WRITE_SWAPPED_DOUBLE(((unsigned char *) dest_data + comp*sizeof(*points)) - data_ptr, *(src_data + comp)); + } + dest_data += num_components; + src_data += ustride; + } + src_data += vstride - ustride*uorder; + } + + crHugePacket(CR_MAP2D_OPCODE, data_ptr); + crPackFree(data_ptr); +} + +void PACK_APIENTRY crPackMap2fSWAP(GLenum target, GLfloat u1, + GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, + GLint vstride, GLint vorder, const GLfloat *points) +{ + unsigned char *data_ptr; + int u,v; + int comp; + GLfloat *dest_data, *src_data; + int packet_length = + sizeof(target) + + sizeof(u1) + + sizeof(u2) + + sizeof(uorder) + + sizeof(ustride) + + sizeof(v1) + + sizeof(v2) + + sizeof(vorder) + + sizeof(vstride); + + int num_components = __gl_Map2NumComponents(target); + if (num_components < 0) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap2f(bad target)"); + return; + } + + packet_length += num_components*uorder*vorder*sizeof(*points); + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + + WRITE_DATA(0, GLenum, SWAP32(target)); + WRITE_DATA(4, GLuint, SWAPFLOAT(u1)); + WRITE_DATA(8, GLuint, SWAPFLOAT(u2)); + WRITE_DATA(12, GLint, SWAP32(num_components)); + WRITE_DATA(16, GLint, SWAP32(uorder)); + WRITE_DATA(20, GLuint, SWAPFLOAT(v1)); + WRITE_DATA(24, GLuint, SWAPFLOAT(v2)); + WRITE_DATA(28, GLint, SWAP32(num_components*uorder)); + WRITE_DATA(32, GLint, SWAP32(vorder)); + + dest_data = (GLfloat *) (data_ptr + 36); + src_data = (GLfloat *) points; + for (v = 0 ; v < vorder ; v++) + { + for (u = 0 ; u < uorder ; u++) + { + for (comp = 0 ; comp < num_components ; comp++) + { + WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp))); + } + dest_data += num_components; + src_data += ustride; + } + src_data += vstride - ustride*uorder; + } + + crHugePacket(CR_MAP2F_OPCODE, data_ptr); + crPackFree(data_ptr); +} + +void PACK_APIENTRY crPackMap1dSWAP(GLenum target, GLdouble u1, + GLdouble u2, GLint stride, GLint order, const GLdouble *points) +{ + unsigned char *data_ptr; + int packet_length = + sizeof(target) + + sizeof(u1) + + sizeof(u2) + + sizeof(stride) + + sizeof(order); + + int num_components = __gl_Map1NumComponents(target); + GLdouble *src_data, *dest_data; + int u; + int comp; + + if (num_components < 0) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap1d(bad target)"); + return; + } + + packet_length += num_components * order * sizeof(*points); + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + + WRITE_DATA(0, GLenum, SWAP32(target)); + WRITE_SWAPPED_DOUBLE(4, u1); + WRITE_SWAPPED_DOUBLE(12, u2); + WRITE_DATA(20, GLint, SWAP32(num_components)); + WRITE_DATA(24, GLint, SWAP32(order)); + + dest_data = (GLdouble *) (data_ptr + 28); + src_data = (GLdouble *) points; + for (u = 0 ; u < order ; u++) + { + for (comp = 0 ; comp < num_components ; comp++) + { + WRITE_SWAPPED_DOUBLE((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, *(src_data + comp)); + } + dest_data += num_components; + src_data += stride; + } + + crHugePacket(CR_MAP1D_OPCODE, data_ptr); + crPackFree(data_ptr); +} + +void PACK_APIENTRY crPackMap1fSWAP(GLenum target, GLfloat u1, + GLfloat u2, GLint stride, GLint order, const GLfloat *points) +{ + unsigned char *data_ptr; + int packet_length = + sizeof(target) + + sizeof(u1) + + sizeof(u2) + + sizeof(stride) + + sizeof(order); + + int num_components = __gl_Map1NumComponents(target); + GLfloat *src_data, *dest_data; + int u; + int comp; + + if (num_components < 0) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackMap1f(bad target)"); + return; + } + + packet_length += num_components * order * sizeof(*points); + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + + WRITE_DATA(0, GLenum, SWAP32(target)); + WRITE_DATA(4, GLuint, SWAPFLOAT(u1)); + WRITE_DATA(8, GLuint, SWAPFLOAT(u2)); + WRITE_DATA(12, GLint, SWAP32(num_components)); + WRITE_DATA(16, GLint, SWAP32(order)); + + dest_data = (GLfloat *) (data_ptr + 20); + src_data = (GLfloat *) points; + for (u = 0 ; u < order ; u++) + { + for (comp = 0 ; comp < num_components ; comp++) + { + WRITE_DATA((unsigned char *) dest_data + comp*sizeof(*points) - data_ptr, GLuint, SWAPFLOAT(*(src_data + comp))); + } + dest_data += num_components; + src_data += stride; + } + + crHugePacket(CR_MAP1F_OPCODE, data_ptr); + crPackFree(data_ptr); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_swap_pixelmap.c b/src/VBox/GuestHost/OpenGL/packer/pack_swap_pixelmap.c new file mode 100644 index 00000000..2336e8f8 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_swap_pixelmap.c @@ -0,0 +1,62 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" + +static unsigned char * __gl_HandlePixelMapData( GLenum map, GLsizei mapsize, int size_of_value, const GLvoid *values ) +{ + int i; + + int packet_length = + sizeof( map ) + + sizeof( mapsize ) + + mapsize*size_of_value; + unsigned char *data_ptr = (unsigned char *) crPackAlloc( packet_length ); + + WRITE_DATA( 0, GLenum, SWAP32(map) ); + WRITE_DATA( 4, GLsizei, SWAP32(mapsize) ); + + for (i = 0 ; i < mapsize ; i++) + { + switch( size_of_value ) + { + case 2: + WRITE_DATA( 8 + i*sizeof(GLshort), GLshort, SWAP16(*((GLshort *)values + i) )); + break; + case 4: + WRITE_DATA( 8 + i*sizeof(GLint), GLint, SWAP32(*((GLint *)values + i) )); + break; + } + } + return data_ptr; +} + +void PACK_APIENTRY crPackPixelMapfvSWAP(GLenum map, GLsizei mapsize, + const GLfloat *values ) +{ + unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values ); + + crHugePacket( CR_PIXELMAPFV_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackPixelMapuivSWAP(GLenum map, GLsizei mapsize, + const GLuint *values ) +{ + unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values ); + + crHugePacket( CR_PIXELMAPUIV_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackPixelMapusvSWAP(GLenum map, GLsizei mapsize, + const GLushort *values ) +{ + unsigned char *data_ptr = __gl_HandlePixelMapData( map, mapsize, sizeof( *values ), values ); + + crHugePacket( CR_PIXELMAPUSV_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c b/src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c new file mode 100644 index 00000000..4fd59ed6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_swap_texture.c @@ -0,0 +1,981 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_pixeldata.h" +#include "cr_error.h" +#include "cr_string.h" +#include "cr_version.h" + +void PACK_APIENTRY crPackTexImage1DSWAP(GLenum target, GLint level, + GLint internalformat, GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid *pixels, const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (pixels == NULL); + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( border ) + + sizeof( format ) + + sizeof( type ) + + sizeof( int ); + + if (pixels) + { + packet_length += crImageSize( format, type, width, 1 ); + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(target) ); + WRITE_DATA( 4, GLint, SWAP32(level) ); + WRITE_DATA( 8, GLint, SWAP32(internalformat) ); + WRITE_DATA( 12, GLsizei, SWAP32(width) ); + WRITE_DATA( 16, GLint, SWAP32(border) ); + WRITE_DATA( 20, GLenum, SWAP32(format) ); + WRITE_DATA( 24, GLenum, SWAP32(type) ); + WRITE_DATA( 28, int, SWAP32(isnull) ); + + if (pixels) { + CRPixelPackState tmpUnpackState = *unpackstate; + /* flip application-requested swapBytes state */ + tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; + + crPixelCopy1D( (void *)(data_ptr + 32), format, type, + pixels, format, type, width, &tmpUnpackState ); + } + + crHugePacket( CR_TEXIMAGE1D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackTexImage2DSWAP(GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (pixels == NULL); + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( border ) + + sizeof( format ) + + sizeof( type ) + + sizeof( int ); + + if (pixels) + { + packet_length += crImageSize( format, type, width, height ); + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(target) ); + WRITE_DATA( 4, GLint, SWAP32(level) ); + WRITE_DATA( 8, GLint, SWAP32(internalformat) ); + WRITE_DATA( 12, GLsizei, SWAP32(width) ); + WRITE_DATA( 16, GLsizei, SWAP32(height) ); + WRITE_DATA( 20, GLint, SWAP32(border) ); + WRITE_DATA( 24, GLenum, SWAP32(format) ); + WRITE_DATA( 28, GLenum, SWAP32(type) ); + WRITE_DATA( 32, int, SWAP32(isnull) ); + + if (pixels) + { + CRPixelPackState tmpUnpackState = *unpackstate; + /* flip application-requested swapBytes state */ + tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; + + crPixelCopy2D( width, height, + (void *)(data_ptr + 36), format, type, NULL, /* dst */ + pixels, format, type, &tmpUnpackState ); /* src */ + } + + crHugePacket( CR_TEXIMAGE2D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +#if defined( GL_EXT_texture3D ) +void PACK_APIENTRY crPackTexImage3DEXTSWAP(GLenum target, GLint level, + GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (pixels == NULL); + int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; + int distrib_buf_len = 0; + int tex_size = 0; + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( border ) + + sizeof( format ) + + sizeof( type ) + + sizeof( int ); + + if (pixels) + { + if ( is_distrib ) + { + distrib_buf_len = crStrlen( pixels ) + 1 + + ( (type == GL_TRUE) ? width*height*3 : 0 ) ; + packet_length += distrib_buf_len ; + } + else + { + tex_size = crTextureSize( format, type, width, height, depth ); + packet_length += tex_size; + } + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32( target ) ); + WRITE_DATA( 4, GLint, SWAP32( level ) ); + WRITE_DATA( 8, GLint, SWAP32( internalformat ) ); + WRITE_DATA( 12, GLsizei, SWAP32( width ) ); + WRITE_DATA( 16, GLsizei, SWAP32( height ) ); + WRITE_DATA( 20, GLsizei, SWAP32( depth ) ); + WRITE_DATA( 24, GLint, SWAP32( border ) ); + WRITE_DATA( 28, GLenum, SWAP32( format ) ); + WRITE_DATA( 32, GLenum, SWAP32( type ) ); + WRITE_DATA( 36, int, SWAP32( isnull ) ); + + if (pixels) + { + if ( is_distrib ) + { + crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ; + } + else + { + CRPixelPackState tmpUnpackState = *unpackstate; + /* flip application-requested swapBytes state */ + tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; + + crPixelCopy3D( width, height, depth, + (void *)(data_ptr + 40), format, type, NULL, + pixels, format, type, &tmpUnpackState ); + } + } + + crHugePacket( CR_TEXIMAGE3DEXT_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} +#endif /* GL_EXT_texture3D */ + +#ifdef CR_OPENGL_VERSION_1_2 +void PACK_APIENTRY crPackTexImage3DSWAP(GLenum target, GLint level, + GLint internalformat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (pixels == NULL); + int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; + int distrib_buf_len = 0; + int tex_size = 0; + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( border ) + + sizeof( format ) + + sizeof( type ) + + sizeof( int ); + + if (pixels) + { + if ( is_distrib ) + { + distrib_buf_len = crStrlen( pixels ) + 1 + + ( (type == GL_TRUE) ? width*height*3 : 0 ) ; + packet_length += distrib_buf_len ; + } + else + { + tex_size = crTextureSize( format, type, width, height, depth ); + packet_length += tex_size; + } + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32( target ) ); + WRITE_DATA( 4, GLint, SWAP32( level ) ); + WRITE_DATA( 8, GLint, SWAP32( internalformat ) ); + WRITE_DATA( 12, GLsizei, SWAP32( width ) ); + WRITE_DATA( 16, GLsizei, SWAP32( height ) ); + WRITE_DATA( 20, GLsizei, SWAP32( depth ) ); + WRITE_DATA( 24, GLint, SWAP32( border ) ); + WRITE_DATA( 28, GLenum, SWAP32( format ) ); + WRITE_DATA( 32, GLenum, SWAP32( type ) ); + WRITE_DATA( 36, int, SWAP32( isnull ) ); + + if (pixels) + { + if ( is_distrib ) + { + crMemcpy( (void*)(data_ptr + 40), pixels, distrib_buf_len ) ; + } + else + { + CRPixelPackState tmpUnpackState = *unpackstate; + /* flip application-requested swapBytes state */ + tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; + + crPixelCopy3D( width, height, depth, + (void *)(data_ptr + 40), format, type, NULL, + pixels, format, type, &tmpUnpackState ); + } + } + + crHugePacket( CR_TEXIMAGE3D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} +#endif /* CR_OPENGL_VERSION_1_2 */ + + +void PACK_APIENTRY crPackDeleteTexturesSWAP( GLsizei n, const GLuint *textures ) +{ + unsigned char *data_ptr; + int i; + + int packet_length = + sizeof( n ) + + n*sizeof( *textures ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLsizei, SWAP32(n) ); + + for ( i = 0 ; i < n ; i++) + { + WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i]) ); + } + crHugePacket( CR_DELETETEXTURES_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +static void __handleTexEnvData( GLenum target, GLenum pname, const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int num_params; + int i; + + int packet_length = + sizeof( int ) + + sizeof( target ) + + sizeof( pname ); + + num_params = 1; + if ( pname == GL_TEXTURE_ENV_COLOR ) + { + num_params = 4; + } + + packet_length += num_params*sizeof(*params); + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, int, SWAP32(packet_length) ); + WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) ); + WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) ); + for ( i = 0 ; i < num_params ; i++) + { + WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT( params[i] ) ); + } +} + + +void PACK_APIENTRY crPackTexEnvfvSWAP( GLenum target, GLenum pname, + const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexEnvData( target, pname, params ); + WRITE_OPCODE( pc, CR_TEXENVFV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexEnvivSWAP( GLenum target, GLenum pname, + const GLint *params ) +{ + /* floats and ints are the same size, so the packing should be the same */ + CR_GET_PACKER_CONTEXT(pc); + __handleTexEnvData( target, pname, (const GLfloat *) params ); + WRITE_OPCODE( pc, CR_TEXENVIV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexEnviSWAP( GLenum target, GLenum pname, GLint param ) +{ + crPackTexEnvivSWAP( target, pname, ¶m ); +} + +void PACK_APIENTRY crPackTexEnvfSWAP( GLenum target, GLenum pname, GLfloat param ) +{ + crPackTexEnvfvSWAP( target, pname, ¶m ); +} + +void PACK_APIENTRY crPackPrioritizeTexturesSWAP( GLsizei n, + const GLuint *textures, const GLclampf *priorities ) +{ + unsigned char *data_ptr; + int packet_length = + sizeof( n ) + + n*sizeof( *textures ) + + n*sizeof( *priorities ); + int i; + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLsizei, SWAP32(n) ); + for ( i = 0 ; i < n ; i++) + { + WRITE_DATA( i*sizeof(int) + 4, GLint, SWAP32(textures[i])); + } + for ( i = 0 ; i < n ; i++) + { + WRITE_DATA( i*sizeof(int) + 4 + n*sizeof( *textures ), + GLuint, SWAPFLOAT(priorities[i])); + } + + crHugePacket( CR_PRIORITIZETEXTURES_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +static void __handleTexGenData( GLenum coord, GLenum pname, + int sizeof_param, const GLvoid *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof( int ) + sizeof( coord ) + sizeof( pname ); + int num_params = 1; + int i; + if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE) + { + num_params = 4; + } + packet_length += num_params * sizeof_param; + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, int, SWAP32(packet_length) ); + WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(coord) ); + WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) ); + for ( i = 0 ; i < num_params ; i++) + { + WRITE_DATA( (i+1)*sizeof( int ) + 8, GLint, SWAP32(((GLint *)params)[i]) ); + } +} + +void PACK_APIENTRY crPackTexGendvSWAP( GLenum coord, GLenum pname, + const GLdouble *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexGenData( coord, pname, sizeof( *params ), params ); + WRITE_OPCODE( pc, CR_TEXGENDV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexGenfvSWAP( GLenum coord, GLenum pname, + const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexGenData( coord, pname, sizeof( *params ), params ); + WRITE_OPCODE( pc, CR_TEXGENFV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexGenivSWAP( GLenum coord, GLenum pname, + const GLint *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexGenData( coord, pname, sizeof( *params ), params ); + WRITE_OPCODE( pc, CR_TEXGENIV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexGendSWAP( GLenum coord, GLenum pname, GLdouble param ) +{ + crPackTexGendvSWAP( coord, pname, ¶m ); +} + +void PACK_APIENTRY crPackTexGenfSWAP( GLenum coord, GLenum pname, GLfloat param ) +{ + crPackTexGenfvSWAP( coord, pname, ¶m ); +} + +void PACK_APIENTRY crPackTexGeniSWAP( GLenum coord, GLenum pname, GLint param ) +{ + crPackTexGenivSWAP( coord, pname, ¶m ); +} + +static GLboolean __handleTexParameterData( GLenum target, GLenum pname, const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof( int ) + sizeof( target ) + sizeof( pname ); + int num_params = 0; + int i; + + switch( pname ) + { + + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: +#ifdef GL_TEXTURE_PRIORITY + case GL_TEXTURE_PRIORITY: +#endif + num_params = 1; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + num_params = 1; + break; + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + num_params = 1; + break; + case GL_TEXTURE_BORDER_COLOR: + num_params = 4; + break; +#ifdef CR_ARB_shadow + case GL_TEXTURE_COMPARE_MODE_ARB: + case GL_TEXTURE_COMPARE_FUNC_ARB: + num_params = 1; + break; +#endif +#ifdef CR_ARB_shadow_ambient + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + num_params = 1; + break; +#endif +#ifdef CR_ARB_depth_texture + case GL_DEPTH_TEXTURE_MODE_ARB: + num_params = 1; + break; +#endif +#ifdef CR_SGIS_generate_mipmap + case GL_GENERATE_MIPMAP_SGIS: + num_params = 1; + break; +#endif + default: + num_params = __packTexParameterNumParams( pname ); + if (!num_params) + { + __PackError( __LINE__, __FILE__, GL_INVALID_ENUM, + "crPackTexParameter(bad pname)" ); + return GL_FALSE; + } + } + packet_length += num_params * sizeof(*params); + + CR_GET_BUFFERED_POINTER(pc, packet_length ); + WRITE_DATA( 0, int, SWAP32(packet_length) ); + WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(target) ); + WRITE_DATA( sizeof( int ) + 4, GLenum, SWAP32(pname) ); + for ( i = 0 ; i < num_params ; i++) + { + WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAPFLOAT(params[i]) ); + } + return GL_TRUE; +} + +void PACK_APIENTRY crPackTexParameterfvSWAP( GLenum target, GLenum pname, + const GLfloat *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleTexParameterData( target, pname, params )) + WRITE_OPCODE( pc, CR_TEXPARAMETERFV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexParameterivSWAP( GLenum target, GLenum pname, + const GLint *params ) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleTexParameterData( target, pname, (GLfloat *) params )) + WRITE_OPCODE( pc, CR_TEXPARAMETERIV_OPCODE ); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY crPackTexParameterfSWAP( GLenum target, GLenum pname, GLfloat param ) +{ + crPackTexParameterfvSWAP( target, pname, ¶m ); +} + +void PACK_APIENTRY crPackTexParameteriSWAP( GLenum target, GLenum pname, GLint param ) +{ + crPackTexParameterivSWAP( target, pname, ¶m ); +} + +#ifdef CR_OPENGL_VERSION_1_2 +void PACK_APIENTRY crPackTexSubImage3DSWAP (GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( yoffset ) + + sizeof( zoffset ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( format ) + + sizeof( type ) + + crTextureSize( format, type, width, height, depth ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(target) ); + WRITE_DATA( 4, GLint, SWAP32(level) ); + WRITE_DATA( 8, GLint, SWAP32(xoffset) ); + WRITE_DATA( 12, GLint, SWAP32(yoffset) ); + WRITE_DATA( 16, GLint, SWAP32(zoffset) ); + WRITE_DATA( 20, GLsizei, SWAP32(width) ); + WRITE_DATA( 24, GLsizei, SWAP32(height) ); + WRITE_DATA( 28, GLsizei, SWAP32(depth) ); + WRITE_DATA( 32, GLenum, SWAP32(format) ); + WRITE_DATA( 36, GLenum, SWAP32(type) ); + + crPixelCopy3D( width, height, depth, + (GLvoid *) (data_ptr + 36), format, type, NULL, /* dst */ + pixels, format, type, unpackstate ); /* src */ + + crHugePacket( CR_TEXSUBIMAGE3D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} +#endif /* CR_OPENGL_VERSION_1_2 */ + +void PACK_APIENTRY crPackTexSubImage2DSWAP (GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + + CRPixelPackState tmpUnpackState = *unpackstate; + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( yoffset ) + + sizeof( width ) + + sizeof( height ) + + sizeof( format ) + + sizeof( type ) + + crImageSize( format, type, width, height ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(target) ); + WRITE_DATA( 4, GLint, SWAP32(level) ); + WRITE_DATA( 8, GLint, SWAP32(xoffset) ); + WRITE_DATA( 12, GLint, SWAP32(yoffset) ); + WRITE_DATA( 16, GLsizei, SWAP32(width) ); + WRITE_DATA( 20, GLsizei, SWAP32(height) ); + WRITE_DATA( 24, GLenum, SWAP32(format) ); + WRITE_DATA( 28, GLenum, SWAP32(type) ); + + /* flip application-requested swapBytes state */ + tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; + + crPixelCopy2D( width, height, + (GLvoid *) (data_ptr + 32), format, type, NULL, /* dst */ + pixels, format, type, &tmpUnpackState ); /* src */ + + crHugePacket( CR_TEXSUBIMAGE2D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackTexSubImage1DSWAP (GLenum target, GLint level, + GLint xoffset, GLsizei width, GLenum format, GLenum type, + const GLvoid *pixels, const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + CRPixelPackState tmpUnpackState = *unpackstate; + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( width ) + + sizeof( format ) + + sizeof( type ) + + crImageSize( format, type, width, 1 ); + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(target) ); + WRITE_DATA( 4, GLint, SWAP32(level) ); + WRITE_DATA( 8, GLint, SWAP32(xoffset) ); + WRITE_DATA( 12, GLsizei, SWAP32(width) ); + WRITE_DATA( 16, GLenum, SWAP32(format) ); + WRITE_DATA( 20, GLenum, SWAP32(type) ); + + /* flip application-requested swapBytes state */ + tmpUnpackState.swapBytes = unpackstate->swapBytes ? GL_FALSE : GL_TRUE; + + crPixelCopy1D((GLvoid *) (data_ptr + 24), format, type, + pixels, format, type, width, &tmpUnpackState ); + + crHugePacket( CR_TEXSUBIMAGE1D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackAreTexturesResidentSWAP( GLsizei n, const GLuint *textures, GLboolean *residences, GLboolean *return_val, int *writeback ) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length; + int i; + + packet_length = + sizeof( int ) + /* packet length */ + sizeof( GLenum ) + /* extend-o opcode */ + sizeof( n ) + /* num_textures */ + n*sizeof( *textures ) + /* textures */ + 8 + 8 + 8; /* return pointers */ + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA( 0, int, SWAP32(packet_length) ); + WRITE_DATA( sizeof( int ) + 0, GLenum, SWAP32(CR_ARETEXTURESRESIDENT_EXTEND_OPCODE) ); + WRITE_DATA( sizeof( int ) + 4, GLsizei, SWAP32(n) ); + for (i = 0 ; i < n ; i++) + { + WRITE_DATA( (i+1)*sizeof( int ) + 8, GLuint, SWAP32(textures[i]) ); + } + WRITE_NETWORK_POINTER( sizeof( int ) + 8 + n*sizeof( *textures ), (void *) residences ); + WRITE_NETWORK_POINTER( sizeof( int ) + 16 + n*sizeof( *textures ), (void *) return_val ); + WRITE_NETWORK_POINTER( sizeof( int ) + 24 + n*sizeof( *textures ), (void *) writeback ); + WRITE_OPCODE( pc, CR_EXTEND_OPCODE ); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +/********************************************************************** + * Texture compression + */ + +void PACK_APIENTRY crPackCompressedTexImage1DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (data == NULL); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( border ) + + sizeof( imagesize ) + + sizeof( int ); + + if (data) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE) ); + WRITE_DATA( 4, GLenum, SWAP32(target) ); + WRITE_DATA( 8, GLint, SWAP32(level) ); + WRITE_DATA( 12, GLint, SWAP32(internalformat) ); + WRITE_DATA( 16, GLsizei, SWAP32(width) ); + WRITE_DATA( 20, GLint, SWAP32(border) ); + WRITE_DATA( 24, GLsizei, SWAP32(imagesize) ); + WRITE_DATA( 28, int, SWAP32(isnull) ); + + if (data) { + crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexImage2DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (data == NULL); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( border ) + + sizeof( imagesize ) + + sizeof( int ); /* isnull */ + + if (data) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE2DARB_EXTEND_OPCODE) ); + WRITE_DATA( 4, GLenum, SWAP32(target) ); + WRITE_DATA( 8, GLint, SWAP32(level) ); + WRITE_DATA( 12, GLint, SWAP32(internalformat) ); + WRITE_DATA( 16, GLsizei, SWAP32(width) ); + WRITE_DATA( 20, GLsizei, SWAP32(height) ); + WRITE_DATA( 24, GLint, SWAP32(border) ); + WRITE_DATA( 28, GLsizei, SWAP32(imagesize) ); + WRITE_DATA( 32, int, SWAP32(isnull) ); + + if (data) { + crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexImage3DARBSWAP( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (data == NULL); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( border ) + + sizeof( imagesize ) + + sizeof( int ); /* isnull */ + + if (data) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXIMAGE3DARB_EXTEND_OPCODE) ); + WRITE_DATA( 4, GLenum, SWAP32(target) ); + WRITE_DATA( 8, GLint, SWAP32(level) ); + WRITE_DATA( 12, GLint, SWAP32(internalformat) ); + WRITE_DATA( 16, GLsizei, SWAP32(width) ); + WRITE_DATA( 20, GLsizei, SWAP32(height) ); + WRITE_DATA( 24, GLsizei, SWAP32(depth) ); + WRITE_DATA( 28, GLint, SWAP32(border) ); + WRITE_DATA( 32, GLsizei, SWAP32(imagesize) ); + WRITE_DATA( 36, int, SWAP32(isnull) ); + + if (data) { + crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexSubImage1DARBSWAP( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (data == NULL); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( width ) + + sizeof( format ) + + sizeof( imagesize ) + + sizeof( int ); /* isnull */ + + if (data) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE1DARB_EXTEND_OPCODE) ); + WRITE_DATA( 4, GLenum, SWAP32(target) ); + WRITE_DATA( 8, GLint, SWAP32(level) ); + WRITE_DATA( 12, GLint, SWAP32(xoffset) ); + WRITE_DATA( 16, GLsizei, SWAP32(width) ); + WRITE_DATA( 20, GLenum, SWAP32(format) ); + WRITE_DATA( 24, GLsizei, SWAP32(imagesize) ); + WRITE_DATA( 28, int, SWAP32(isnull) ); + + if (data) { + crMemcpy( (void *)(data_ptr + 32), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexSubImage2DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (data == NULL); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( yoffset ) + + sizeof( width ) + + sizeof( height ) + + sizeof( format ) + + sizeof( imagesize ) + + sizeof( int ); /* isnull */ + + if (data) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE2DARB_EXTEND_OPCODE) ); + WRITE_DATA( 4, GLenum, SWAP32(target) ); + WRITE_DATA( 8, GLint, SWAP32(level) ); + WRITE_DATA( 12, GLint, SWAP32(xoffset) ); + WRITE_DATA( 16, GLint, SWAP32(yoffset) ); + WRITE_DATA( 20, GLsizei, SWAP32(width) ); + WRITE_DATA( 24, GLsizei, SWAP32(height) ); + WRITE_DATA( 28, GLenum, SWAP32(format) ); + WRITE_DATA( 32, GLsizei, SWAP32(imagesize) ); + WRITE_DATA( 36, int, SWAP32(isnull) ); + + if (data) { + crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexSubImage3DARBSWAP( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int isnull = (data == NULL); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( yoffset ) + + sizeof( zoffset ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( format ) + + sizeof( imagesize ) + + sizeof( int ); /* isnull */ + + if (data) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, SWAP32(CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE) ); + WRITE_DATA( 4, GLenum, SWAP32(target) ); + WRITE_DATA( 8, GLint, SWAP32(level) ); + WRITE_DATA( 12, GLint, SWAP32(xoffset) ); + WRITE_DATA( 16, GLint, SWAP32(yoffset) ); + WRITE_DATA( 20, GLint, SWAP32(zoffset) ); + WRITE_DATA( 24, GLsizei, SWAP32(width) ); + WRITE_DATA( 28, GLsizei, SWAP32(height) ); + WRITE_DATA( 32, GLsizei, SWAP32(depth) ); + WRITE_DATA( 36, GLenum, SWAP32(format) ); + WRITE_DATA( 40, GLsizei, SWAP32(imagesize) ); + WRITE_DATA( 44, int, SWAP32(isnull) ); + + if (data) { + crMemcpy( (void *)(data_ptr + 48), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackGetCompressedTexImageARBSWAP( GLenum target, GLint level, GLvoid *img, int *writeback ) +{ + CR_GET_PACKER_CONTEXT(pc); + crError ( "GetCompressedTexImageARB needs to be special cased!"); + (void) pc; + (void) target; + (void) level; + (void) img; + (void) writeback; +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_texture.c b/src/VBox/GuestHost/OpenGL/packer/pack_texture.c new file mode 100644 index 00000000..6b33b1c4 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_texture.c @@ -0,0 +1,1030 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "packer.h" +#include "cr_pixeldata.h" +#include "cr_error.h" +#include "cr_string.h" +#include "cr_version.h" +#include "cr_glstate.h" + +void PACK_APIENTRY +crPackTexImage1D(GLenum target, GLint level, + GLint internalformat, GLsizei width, GLint border, + GLenum format, GLenum type, const GLvoid * pixels, + const CRPixelPackState * unpackstate) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + packet_length = + sizeof(target) + + sizeof(level) + + sizeof(internalformat) + + sizeof(width) + + sizeof(border) + sizeof(format) + sizeof(type) + sizeof(int) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += crImageSize(format, type, width, 1); + } + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, target); + WRITE_DATA(4, GLint, level); + WRITE_DATA(8, GLint, internalformat); + WRITE_DATA(12, GLsizei, width); + WRITE_DATA(16, GLint, border); + WRITE_DATA(20, GLenum, format); + WRITE_DATA(24, GLenum, type); + WRITE_DATA(28, int, noimagedata); + WRITE_DATA(32, GLint, (GLint)(uintptr_t) pixels); + + if (!noimagedata) + { + crPixelCopy1D((void *) (data_ptr + 36), format, type, + pixels, format, type, width, unpackstate); + } + + crHugePacket(CR_TEXIMAGE1D_OPCODE, data_ptr); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY +crPackTexImage2D(GLenum target, GLint level, + GLint internalformat, GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid * pixels, const CRPixelPackState * unpackstate) +{ + unsigned char *data_ptr; + int packet_length; + const int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + const int is_distrib = ((type == GL_TRUE) || (type == GL_FALSE)); + int distrib_buf_len = 0; + + packet_length = + sizeof(target) + + sizeof(level) + + sizeof(internalformat) + + sizeof(width) + + sizeof(height) + + sizeof(border) + sizeof(format) + sizeof(type) + sizeof(int) + sizeof(GLint); + + if (!noimagedata) + { + if (is_distrib) + { + /* Pixels is a zero-terminated filename, followed by the usual image + * data if type == GL_TRUE. + * Also note that the image data can't have any unusual pixel packing + * parameters. + */ + CRASSERT(format == GL_RGB); + distrib_buf_len = crStrlen(pixels) + 1 + + ((type == GL_TRUE) ? width * height * 3 : 0); + packet_length += distrib_buf_len; + } + else + { + packet_length += crImageSize(format, type, width, height); + } + } + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, target); + WRITE_DATA(4, GLint, level); + WRITE_DATA(8, GLint, internalformat); + WRITE_DATA(12, GLsizei, width); + WRITE_DATA(16, GLsizei, height); + WRITE_DATA(20, GLint, border); + WRITE_DATA(24, GLenum, format); + WRITE_DATA(28, GLenum, type); + WRITE_DATA(32, int, noimagedata); + WRITE_DATA(36, GLint, (GLint)(uintptr_t) pixels); + + if (!noimagedata) + { + if (is_distrib) + { + crMemcpy((void *) (data_ptr + 40), pixels, distrib_buf_len); + } + else + { + crPixelCopy2D(width, height, + (void *) (data_ptr + 40), /* dest image addr */ + format, type, /* dest image format/type */ + NULL, /* dst packing (use default params) */ + pixels, /* src image addr */ + format, type, /* src image format/type */ + unpackstate); /* src packing */ + } + } + + crHugePacket(CR_TEXIMAGE2D_OPCODE, data_ptr); + crPackFree( data_ptr ); +} + +#if defined( GL_EXT_texture3D ) +void PACK_APIENTRY +crPackTexImage3DEXT(GLenum target, GLint level, + GLenum internalformat, + GLsizei width, GLsizei height, GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; + int distrib_buf_len = 0; + int tex_size = 0; + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( border ) + + sizeof( format ) + + sizeof( type ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + if ( is_distrib ) + { + distrib_buf_len = crStrlen( pixels ) + 1 + + ( (type == GL_TRUE) ? width*height*3 : 0 ) ; + packet_length += distrib_buf_len ; + } + else + { + tex_size = crTextureSize( format, type, width, height, depth ); + packet_length += tex_size; + } + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, target ); + WRITE_DATA( 4, GLint, level ); + WRITE_DATA( 8, GLint, internalformat ); + WRITE_DATA( 12, GLsizei, width ); + WRITE_DATA( 16, GLsizei, height ); + WRITE_DATA( 20, GLsizei, depth ); + WRITE_DATA( 24, GLint, border ); + WRITE_DATA( 28, GLenum, format ); + WRITE_DATA( 32, GLenum, type ); + WRITE_DATA( 36, int, noimagedata ); + WRITE_DATA( 40, GLint, (GLint)(uintptr_t) pixels); + + if (!noimagedata) + { + if ( is_distrib ) + { + crMemcpy( (void*)(data_ptr + 44), pixels, distrib_buf_len ) ; + } + else + { + crPixelCopy3D( width, height, depth, + (void *)(data_ptr + 44), format, type, NULL, + pixels, format, type, unpackstate ); + } + } + + crHugePacket( CR_TEXIMAGE3DEXT_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} +#endif /* GL_EXT_texture3D */ + +#ifdef CR_OPENGL_VERSION_1_2 +void PACK_APIENTRY +crPackTexImage3D(GLenum target, GLint level, + GLint internalformat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels, + const CRPixelPackState *unpackstate ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + int is_distrib = ( (type == GL_TRUE) || (type == GL_FALSE) ) ; + int distrib_buf_len = 0; + int tex_size = 0; + + packet_length = + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( border ) + + sizeof( format ) + + sizeof( type ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + if ( is_distrib ) + { + distrib_buf_len = crStrlen( pixels ) + 1 + + ( (type == GL_TRUE) ? width*height*3 : 0 ) ; + packet_length += distrib_buf_len ; + } + else + { + tex_size = crTextureSize( format, type, width, height, depth ); + packet_length += tex_size; + } + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, target ); + WRITE_DATA( 4, GLint, level ); + WRITE_DATA( 8, GLint, internalformat ); + WRITE_DATA( 12, GLsizei, width ); + WRITE_DATA( 16, GLsizei, height ); + WRITE_DATA( 20, GLsizei, depth ); + WRITE_DATA( 24, GLint, border ); + WRITE_DATA( 28, GLenum, format ); + WRITE_DATA( 32, GLenum, type ); + WRITE_DATA( 36, int, noimagedata ); + WRITE_DATA( 40, GLint, (GLint)(uintptr_t) pixels); + + if (!noimagedata) + { + if ( is_distrib ) + { + crMemcpy( (void*)(data_ptr + 44), pixels, distrib_buf_len ) ; + } + else + { + crPixelCopy3D( width, height, depth, + (void *)(data_ptr + 44), format, type, NULL, + pixels, format, type, unpackstate ); + } + } + + crHugePacket( CR_TEXIMAGE3D_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} +#endif /* CR_OPENGL_VERSION_1_2 */ + + +void PACK_APIENTRY +crPackDeleteTextures(GLsizei n, const GLuint * textures) +{ + unsigned char *data_ptr; + int packet_length = + sizeof( n ) + + n * sizeof( *textures ); + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLsizei, n); + crMemcpy(data_ptr + 4, textures, n * sizeof(*textures)); + crHugePacket(CR_DELETETEXTURES_OPCODE, data_ptr); + crPackFree( data_ptr ); +} + +static void +__handleTexEnvData(GLenum target, GLenum pname, const GLfloat * params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int params_length; + + int packet_length = + sizeof( int ) + + sizeof( target ) + + sizeof( pname ); + + if (pname == GL_TEXTURE_ENV_COLOR) + { + params_length = 4 * sizeof(*params); + } + else + { + params_length = sizeof(*params); + } + + packet_length += params_length; + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, target); + WRITE_DATA(sizeof(int) + 4, GLenum, pname); + crMemcpy(data_ptr + sizeof(int) + 8, params, params_length); +} + + +void PACK_APIENTRY +crPackTexEnvfv(GLenum target, GLenum pname, const GLfloat * params) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexEnvData(target, pname, params); + WRITE_OPCODE(pc, CR_TEXENVFV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY +crPackTexEnviv(GLenum target, GLenum pname, const GLint * params) +{ + /* floats and ints are the same size, so the packing should be the same */ + CR_GET_PACKER_CONTEXT(pc); + __handleTexEnvData(target, pname, (const GLfloat *) params); + WRITE_OPCODE(pc, CR_TEXENVIV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY +crPackTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + crPackTexEnvfv(target, pname, ¶m); +} + +void PACK_APIENTRY +crPackTexEnvi(GLenum target, GLenum pname, GLint param) +{ + crPackTexEnviv(target, pname, ¶m); +} + +void PACK_APIENTRY +crPackPrioritizeTextures(GLsizei n, const GLuint * textures, + const GLclampf * priorities) +{ + unsigned char *data_ptr; + int packet_length = + sizeof(n) + + n * sizeof(*textures) + + n * sizeof(*priorities); + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + + WRITE_DATA(0, GLsizei, n); + crMemcpy(data_ptr + 4, textures, n * sizeof(*textures)); + crMemcpy(data_ptr + 4 + n * sizeof(*textures), + priorities, n * sizeof(*priorities)); + + crHugePacket(CR_PRIORITIZETEXTURES_OPCODE, data_ptr); + crPackFree( data_ptr ); +} + +static void +__handleTexGenData(GLenum coord, GLenum pname, + int sizeof_param, const GLvoid * params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = + sizeof(int) + sizeof(coord) + sizeof(pname) + sizeof_param; + int params_length = sizeof_param; + if (pname == GL_OBJECT_PLANE || pname == GL_EYE_PLANE) + { + packet_length += 3 * sizeof_param; + params_length += 3 * sizeof_param; + } + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, coord); + WRITE_DATA(sizeof(int) + 4, GLenum, pname); + crMemcpy(data_ptr + sizeof(int) + 8, params, params_length); +} + +void PACK_APIENTRY +crPackTexGendv(GLenum coord, GLenum pname, const GLdouble * params) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexGenData(coord, pname, sizeof(*params), params); + WRITE_OPCODE(pc, CR_TEXGENDV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY +crPackTexGenfv(GLenum coord, GLenum pname, const GLfloat * params) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexGenData(coord, pname, sizeof(*params), params); + WRITE_OPCODE(pc, CR_TEXGENFV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY +crPackTexGeniv(GLenum coord, GLenum pname, const GLint * params) +{ + CR_GET_PACKER_CONTEXT(pc); + __handleTexGenData(coord, pname, sizeof(*params), params); + WRITE_OPCODE(pc, CR_TEXGENIV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + +void PACK_APIENTRY +crPackTexGend(GLenum coord, GLenum pname, GLdouble param) +{ + crPackTexGendv(coord, pname, ¶m); +} + +void PACK_APIENTRY +crPackTexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + crPackTexGenfv(coord, pname, ¶m); +} + +void PACK_APIENTRY +crPackTexGeni(GLenum coord, GLenum pname, GLint param) +{ + crPackTexGeniv(coord, pname, ¶m); +} + +static GLboolean +__handleTexParameterData(GLenum target, GLenum pname, const GLfloat * params) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length = sizeof(int) + sizeof(target) + sizeof(pname); + int num_params = 0; + + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: +#ifdef GL_TEXTURE_PRIORITY + case GL_TEXTURE_PRIORITY: +#endif + num_params = 1; + break; + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + num_params = 1; + break; + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: + num_params = 1; + break; + case GL_TEXTURE_BORDER_COLOR: + num_params = 4; + break; +#ifdef CR_ARB_shadow + case GL_TEXTURE_COMPARE_MODE_ARB: + case GL_TEXTURE_COMPARE_FUNC_ARB: + num_params = 1; + break; +#endif +#ifdef CR_ARB_shadow_ambient + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + num_params = 1; + break; +#endif +#ifdef CR_ARB_depth_texture + case GL_DEPTH_TEXTURE_MODE_ARB: + num_params = 1; + break; +#endif +#ifdef CR_SGIS_generate_mipmap + case GL_GENERATE_MIPMAP_SGIS: + num_params = 1; + break; +#endif + default: + num_params = __packTexParameterNumParams(pname); + if (!num_params) + { + __PackError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crPackTexParameter(bad pname)"); + return GL_FALSE; + } + } + packet_length += num_params * sizeof(*params); + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(sizeof(int) + 0, GLenum, target); + WRITE_DATA(sizeof(int) + 4, GLenum, pname); + crMemcpy(data_ptr + sizeof(int) + 8, params, num_params * sizeof(*params)); + return GL_TRUE; +} + +void PACK_APIENTRY +crPackTexParameterfv(GLenum target, GLenum pname, const GLfloat * params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleTexParameterData(target, pname, params)) + { + WRITE_OPCODE(pc, CR_TEXPARAMETERFV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); + } +} + +void PACK_APIENTRY +crPackTexParameteriv(GLenum target, GLenum pname, const GLint * params) +{ + CR_GET_PACKER_CONTEXT(pc); + if (__handleTexParameterData(target, pname, (GLfloat *) params)) + { + WRITE_OPCODE(pc, CR_TEXPARAMETERIV_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); + } +} + +void PACK_APIENTRY +crPackTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + crPackTexParameterfv(target, pname, ¶m); +} + +void PACK_APIENTRY +crPackTexParameteri(GLenum target, GLenum pname, GLint param) +{ + crPackTexParameteriv(target, pname, ¶m); +} + +#ifdef CR_OPENGL_VERSION_1_2 +void PACK_APIENTRY +crPackTexSubImage3D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid * pixels, + const CRPixelPackState * unpackstate) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + packet_length = + sizeof(target) + + sizeof(level) + + sizeof(xoffset) + + sizeof(yoffset) + + sizeof(zoffset) + + sizeof(width) + + sizeof(height) + + sizeof(depth) + + sizeof(format) + + sizeof(type) + sizeof(int) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += crTextureSize(format, type, width, height, depth); + } + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, target); + WRITE_DATA(4, GLint, level); + WRITE_DATA(8, GLint, xoffset); + WRITE_DATA(12, GLint, yoffset); + WRITE_DATA(16, GLint, zoffset); + WRITE_DATA(20, GLsizei, width); + WRITE_DATA(24, GLsizei, height); + WRITE_DATA(28, GLsizei, depth); + WRITE_DATA(32, GLenum, format); + WRITE_DATA(36, GLenum, type); + WRITE_DATA(40, GLint, noimagedata); + WRITE_DATA(44, GLint, (GLint)(uintptr_t) pixels); + + if (!noimagedata) + { + crPixelCopy3D(width, height, depth, (GLvoid *) (data_ptr + 48), format, type, NULL, /* dst */ + pixels, format, type, unpackstate); /* src */ + } + + crHugePacket(CR_TEXSUBIMAGE3D_OPCODE, data_ptr); + crPackFree( data_ptr ); +} +#endif /* CR_OPENGL_VERSION_1_2 */ + +void PACK_APIENTRY +crPackTexSubImage2D(GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLsizei width, + GLsizei height, GLenum format, GLenum type, + const GLvoid * pixels, + const CRPixelPackState * unpackstate) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + packet_length = + sizeof(target) + + sizeof(level) + + sizeof(xoffset) + + sizeof(yoffset) + + sizeof(width) + + sizeof(height) + + sizeof(format) + sizeof(type) + sizeof(int) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += crImageSize(format, type, width, height); + } + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, target); + WRITE_DATA(4, GLint, level); + WRITE_DATA(8, GLint, xoffset); + WRITE_DATA(12, GLint, yoffset); + WRITE_DATA(16, GLsizei, width); + WRITE_DATA(20, GLsizei, height); + WRITE_DATA(24, GLenum, format); + WRITE_DATA(28, GLenum, type); + WRITE_DATA(32, GLint, noimagedata); + WRITE_DATA(36, GLint, (GLint)(uintptr_t) pixels); + + if (!noimagedata) + { + crPixelCopy2D(width, height, (GLvoid *) (data_ptr + 40), format, type, NULL, /* dst */ + pixels, format, type, unpackstate); /* src */ + } + + crHugePacket(CR_TEXSUBIMAGE2D_OPCODE, data_ptr); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY +crPackTexSubImage1D(GLenum target, GLint level, + GLint xoffset, GLsizei width, GLenum format, GLenum type, + const GLvoid * pixels, + const CRPixelPackState * unpackstate) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (pixels == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + packet_length = + sizeof(target) + + sizeof(level) + + sizeof(xoffset) + + sizeof(width) + + sizeof(format) + sizeof(type) + sizeof(int) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += crImageSize(format, type, width, 1); + } + + data_ptr = (unsigned char *) crPackAlloc(packet_length); + WRITE_DATA(0, GLenum, target); + WRITE_DATA(4, GLint, level); + WRITE_DATA(8, GLint, xoffset); + WRITE_DATA(12, GLsizei, width); + WRITE_DATA(16, GLenum, format); + WRITE_DATA(20, GLenum, type); + WRITE_DATA(24, GLint, noimagedata); + WRITE_DATA(28, GLint, (GLint)(uintptr_t) pixels); + + if (!noimagedata) + { + crPixelCopy1D((GLvoid *) (data_ptr + 32), format, type, + pixels, format, type, width, unpackstate); + } + + crHugePacket(CR_TEXSUBIMAGE1D_OPCODE, data_ptr); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY +crPackAreTexturesResident(GLsizei n, const GLuint * textures, + GLboolean * residences, GLboolean * return_val, + int *writeback) +{ + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + int packet_length; + + (void) return_val; /* Caller must compute this from residences!!! */ + + packet_length = sizeof(int) + /* packet length */ + sizeof(GLenum) + /* extend-o opcode */ + sizeof(n) + /* num_textures */ + n * sizeof(*textures) + /* textures */ + 8 + 8; + + CR_GET_BUFFERED_POINTER(pc, packet_length); + WRITE_DATA(0, int, packet_length); + WRITE_DATA(4, GLenum, CR_ARETEXTURESRESIDENT_EXTEND_OPCODE); + WRITE_DATA(8, GLsizei, n); + crMemcpy(data_ptr + 12, textures, n * sizeof(*textures)); + WRITE_NETWORK_POINTER(12 + n * sizeof(*textures), (void *) residences); + WRITE_NETWORK_POINTER(20 + n * sizeof(*textures), (void *) writeback); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_CMDBLOCK_CHECK_FLUSH(pc); + CR_UNLOCK_PACKER_CONTEXT(pc); +} + + +/********************************************************************** + * Texture compression + */ + +void PACK_APIENTRY crPackCompressedTexImage1DARB( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( border ) + + sizeof( imagesize ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += imagesize; + } + + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, CR_COMPRESSEDTEXIMAGE1DARB_EXTEND_OPCODE ); + WRITE_DATA( 4, GLenum, target ); + WRITE_DATA( 8, GLint, level ); + WRITE_DATA( 12, GLint, internalformat ); + WRITE_DATA( 16, GLsizei, width ); + WRITE_DATA( 20, GLint, border ); + WRITE_DATA( 24, GLsizei, imagesize ); + WRITE_DATA( 28, int, noimagedata ); + WRITE_DATA( 32, GLint, (GLint)(uintptr_t) data); + + if (!noimagedata) { + crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexImage2DARB( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( border ) + + sizeof( imagesize ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += imagesize; + } + + /*crDebug( "Compressing that shit: %d", level );*/ + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, CR_COMPRESSEDTEXIMAGE2DARB_EXTEND_OPCODE ); + WRITE_DATA( 4, GLenum, target ); + WRITE_DATA( 8, GLint, level ); + WRITE_DATA( 12, GLint, internalformat ); + WRITE_DATA( 16, GLsizei, width ); + WRITE_DATA( 20, GLsizei, height ); + WRITE_DATA( 24, GLint, border ); + WRITE_DATA( 28, GLsizei, imagesize ); + WRITE_DATA( 32, int, noimagedata ); + WRITE_DATA( 36, GLint, (GLint)(uintptr_t) data); + + if (!noimagedata) { + crMemcpy( (void *)(data_ptr + 40), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexImage3DARB( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( internalformat ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( border ) + + sizeof( imagesize ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, CR_COMPRESSEDTEXIMAGE3DARB_EXTEND_OPCODE ); + WRITE_DATA( 4, GLenum, target ); + WRITE_DATA( 8, GLint, level ); + WRITE_DATA( 12, GLint, internalformat ); + WRITE_DATA( 16, GLsizei, width ); + WRITE_DATA( 20, GLsizei, height ); + WRITE_DATA( 24, GLsizei, depth ); + WRITE_DATA( 28, GLint, border ); + WRITE_DATA( 32, GLsizei, imagesize ); + WRITE_DATA( 36, int, noimagedata ); + WRITE_DATA( 40, GLint, (GLint)(uintptr_t) data); + + if (!noimagedata) { + crMemcpy( (void *)(data_ptr + 44), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexSubImage1DARB( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( width ) + + sizeof( format ) + + sizeof( imagesize ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, CR_COMPRESSEDTEXSUBIMAGE1DARB_EXTEND_OPCODE ); + WRITE_DATA( 4, GLenum, target ); + WRITE_DATA( 8, GLint, level ); + WRITE_DATA( 12, GLint, xoffset ); + WRITE_DATA( 16, GLsizei, width ); + WRITE_DATA( 20, GLenum, format ); + WRITE_DATA( 24, GLsizei, imagesize ); + WRITE_DATA( 28, int, noimagedata ); + WRITE_DATA( 32, GLint, (GLint)(uintptr_t) data); + + if (!noimagedata) { + crMemcpy( (void *)(data_ptr + 36), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexSubImage2DARB( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( yoffset ) + + sizeof( width ) + + sizeof( height ) + + sizeof( format ) + + sizeof( imagesize ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, CR_COMPRESSEDTEXSUBIMAGE2DARB_EXTEND_OPCODE ); + WRITE_DATA( 4, GLenum, target ); + WRITE_DATA( 8, GLint, level ); + WRITE_DATA( 12, GLint, xoffset ); + WRITE_DATA( 16, GLint, yoffset ); + WRITE_DATA( 20, GLsizei, width ); + WRITE_DATA( 24, GLsizei, height ); + WRITE_DATA( 28, GLenum, format ); + WRITE_DATA( 32, GLsizei, imagesize ); + WRITE_DATA( 36, int, noimagedata ); + WRITE_DATA( 40, GLint, (GLint)(uintptr_t) data); + + if (!noimagedata) { + crMemcpy( (void *)(data_ptr + 44), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackCompressedTexSubImage3DARB( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imagesize, const GLvoid *data ) +{ + unsigned char *data_ptr; + int packet_length; + int noimagedata = (data == NULL) || crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + /* All extended opcodes have their first 8 bytes predefined: + * the first four indicate the packet size, and the next four + * indicate the actual extended opcode. + */ + packet_length = + sizeof( GLenum) + /* extended opcode */ + sizeof( target ) + + sizeof( level ) + + sizeof( xoffset ) + + sizeof( yoffset ) + + sizeof( zoffset ) + + sizeof( width ) + + sizeof( height ) + + sizeof( depth ) + + sizeof( format ) + + sizeof( imagesize ) + + sizeof( int ) + sizeof(GLint); + + if (!noimagedata) + { + packet_length += imagesize; + } + + data_ptr = (unsigned char *) crPackAlloc( packet_length ); + WRITE_DATA( 0, GLenum, CR_COMPRESSEDTEXSUBIMAGE3DARB_EXTEND_OPCODE ); + WRITE_DATA( 4, GLenum, target ); + WRITE_DATA( 8, GLint, level ); + WRITE_DATA( 12, GLint, xoffset ); + WRITE_DATA( 16, GLint, yoffset ); + WRITE_DATA( 20, GLint, zoffset ); + WRITE_DATA( 24, GLsizei, width ); + WRITE_DATA( 28, GLsizei, height ); + WRITE_DATA( 32, GLsizei, depth ); + WRITE_DATA( 36, GLenum, format ); + WRITE_DATA( 40, GLsizei, imagesize ); + WRITE_DATA( 44, int, noimagedata ); + WRITE_DATA( 48, GLint, (GLint)(uintptr_t) data); + + if (!noimagedata) { + crMemcpy( (void *)(data_ptr + 52), (void *)data, imagesize); + } + + crHugePacket( CR_EXTEND_OPCODE, data_ptr ); + crPackFree( data_ptr ); +} + +void PACK_APIENTRY crPackGetCompressedTexImageARB( GLenum target, GLint level, GLvoid *img, int *writeback ) +{ + CR_GET_PACKER_CONTEXT(pc); + int packet_length = sizeof(int)+sizeof(GLenum)+sizeof(target)+sizeof(level)+2*8; + unsigned char *data_ptr; + CR_GET_BUFFERED_POINTER( pc, packet_length ); + + WRITE_DATA_AI(int, packet_length); + WRITE_DATA_AI(GLenum, CR_GETCOMPRESSEDTEXIMAGEARB_EXTEND_OPCODE); + WRITE_DATA_AI(GLenum, target); + WRITE_DATA_AI(GLint, level); + WRITE_NETWORK_POINTER(0, (void *) img ); + WRITE_NETWORK_POINTER(8, (void *) writeback ); + WRITE_OPCODE(pc, CR_EXTEND_OPCODE); + CR_UNLOCK_PACKER_CONTEXT(pc); +} diff --git a/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c b/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c new file mode 100644 index 00000000..152077bc --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/pack_visibleregion.c @@ -0,0 +1,58 @@ +/* $Id: pack_visibleregion.c $ */ +/** @file + * VBox Packing VisibleRegion information + */ + +/* + * Copyright (C) 2008-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "cr_error.h" + +#ifdef WINDOWS +# include +#endif + +void PACK_APIENTRY crPackWindowVisibleRegion( CR_PACKER_CONTEXT_ARGDECL GLint window, GLint cRects, const GLint * pRects ) +{ + GLint i, size, cnt; + + CR_GET_PACKER_CONTEXT(pc); + unsigned char *data_ptr; + (void) pc; + size = 16 + cRects * 4 * sizeof(GLint); + CR_GET_BUFFERED_POINTER( pc, size ); + WRITE_DATA( 0, GLint, size ); + WRITE_DATA( 4, GLenum, CR_WINDOWVISIBLEREGION_EXTEND_OPCODE ); + WRITE_DATA( 8, GLint, window ); + WRITE_DATA( 12, GLint, cRects ); + + cnt = 16; + for (i=0; i /* for sprintf() */ +#include "cr_pack.h" +#include "cr_packfunctions.h" +#include "packer_extensions.h" +#include "cr_mem.h" + +#ifndef IN_RING0 +extern void __PackError( int line, const char *file, GLenum error, const char *info ); +#else +# define __PackError( line, file, error, info) do { AssertReleaseFailed(); } while (0) +#endif + +#endif /* CR_PACKER_H */ diff --git a/src/VBox/GuestHost/OpenGL/packer/packer.py b/src/VBox/GuestHost/OpenGL/packer/packer.py new file mode 100755 index 00000000..b0b5ad6a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/packer.py @@ -0,0 +1,274 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This script generates the packer.c file from the gl_header.parsed file. + +from __future__ import print_function +import sys, string, re + +import apiutil + + + +def WriteData( offset, arg_type, arg_name, is_swapped ): + """Return a string to write a variable to the packing buffer.""" + retval = 9 + if apiutil.IsPointer(arg_type): + retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name ) + else: + if is_swapped: + if arg_type == "GLfloat" or arg_type == "GLclampf": + retval = "\tWRITE_DATA(%d, GLuint, SWAPFLOAT(%s));" % (offset, arg_name) + elif arg_type == "GLdouble" or arg_type == "GLclampd": + retval = "\tWRITE_SWAPPED_DOUBLE(%d, %s);" % (offset, arg_name) + elif apiutil.sizeof(arg_type) == 1: + retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name) + elif apiutil.sizeof(arg_type) == 2: + retval = "\tWRITE_DATA(%d, %s, SWAP16(%s));" % (offset, arg_type, arg_name) + elif apiutil.sizeof(arg_type) == 4: + retval = "\tWRITE_DATA(%d, %s, SWAP32(%s));" % (offset, arg_type, arg_name) + else: + if arg_type == "GLdouble" or arg_type == "GLclampd": + retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name) + else: + retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name) + if retval == 9: + print >>sys.stderr, "no retval for %s %s" % (arg_name, arg_type) + assert 0 + return retval + + +def UpdateCurrentPointer( func_name ): + m = re.search( r"^(Color|Normal)([1234])(ub|b|us|s|ui|i|f|d)$", func_name ) + if m : + k = m.group(1) + name = '%s%s' % (k[:1].lower(),k[1:]) + type = m.group(3) + m.group(2) + print("\tpc->current.c.%s.%s = data_ptr;" % (name,type)) + return + + m = re.search( r"^(SecondaryColor)(3)(ub|b|us|s|ui|i|f|d)EXT$", func_name ) + if m : + k = m.group(1) + name = 'secondaryColor' + type = m.group(3) + m.group(2) + print("\tpc->current.c.%s.%s = data_ptr;" % (name,type)) + return + + m = re.search( r"^(TexCoord)([1234])(ub|b|us|s|ui|i|f|d)$", func_name ) + if m : + k = m.group(1) + name = 'texCoord' + type = m.group(3) + m.group(2) + print("\tpc->current.c.%s.%s[0] = data_ptr;" % (name,type)) + return + + m = re.search( r"^(MultiTexCoord)([1234])(ub|b|us|s|ui|i|f|d)ARB$", func_name ) + if m : + k = m.group(1) + name = 'texCoord' + type = m.group(3) + m.group(2) + print("\tpc->current.c.%s.%s[texture-GL_TEXTURE0_ARB] = data_ptr + 4;" % (name,type)) + return + + m = re.match( r"^(Index)(ub|b|us|s|ui|i|f|d)$", func_name ) + if m : + k = m.group(1) + name = 'index' + type = m.group(2) + "1" + print("\tpc->current.c.%s.%s = data_ptr;" % (name,type)) + return + + m = re.match( r"^(EdgeFlag)$", func_name ) + if m : + k = m.group(1) + name = 'edgeFlag' + type = "l1" + print("\tpc->current.c.%s.%s = data_ptr;" % (name,type)) + return + + m = re.match( r"^(FogCoord)(f|d)EXT$", func_name ) + if m : + k = m.group(1) + name = 'fogCoord' + type = m.group(2) + "1" + print("\tpc->current.c.%s.%s = data_ptr;" % (name,type)) + return + + + m = re.search( r"^(VertexAttrib)([1234])N?(ub|b|s|f|d)(NV|ARB)$", func_name ) + if m : + k = m.group(1) + name = 'vertexAttrib' + type = m.group(3) + m.group(2) + # Add 12 to skip the packet length, opcode and index fields + print("\tpc->current.c.%s.%s[index] = data_ptr + 4;" % (name,type)) + if m.group(4) == "ARB" or m.group(4) == "NV": + print("\tpc->current.attribsUsedMask |= (1 << index);") + print("\tpc->current.changedVertexAttrib |= (1 << index);") + return + + + +def PrintFunc( func_name, params, is_swapped, can_have_pointers ): + """Emit a packer function.""" + if is_swapped: + print('void PACK_APIENTRY crPack%sSWAP(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params))) + else: + print('void PACK_APIENTRY crPack%s(%s)' % (func_name, apiutil.MakeDeclarationStringWithContext('CR_PACKER_CONTEXT', params))) + print('{') + print('\tCR_GET_PACKER_CONTEXT(pc);') + + # Save original function name + orig_func_name = func_name + + # Convert to a non-vector version of the function if possible + func_name = apiutil.NonVectorFunction( func_name ) + if not func_name: + func_name = orig_func_name + + # Check if there are any pointer parameters. + # That's usually a problem so we'll emit an error function. + nonVecParams = apiutil.Parameters(func_name) + bail_out = 0 + for (name, type, vecSize) in nonVecParams: + if apiutil.IsPointer(type) and vecSize == 0 and not can_have_pointers: + bail_out = 1 + if bail_out: + for (name, type, vecSize) in nonVecParams: + print('\t(void)%s;' % (name)) + print('\tcrError ( "%s needs to be special cased %d %d!");' % (func_name, vecSize, can_have_pointers)) + print('\t(void) pc;') + print('}') + # XXX we should really abort here + return + + if "extpack" in apiutil.ChromiumProps(func_name): + is_extended = 1 + else: + is_extended = 0 + + + print("\tunsigned char *data_ptr = NULL;") + print('\t(void) pc;') + #if func_name == "Enable" or func_name == "Disable": + # print "\tCRASSERT(!pc->buffer.geometry_only); /* sanity check */" + + for index in range(0,len(params)): + (name, type, vecSize) = params[index] + if vecSize>0 and func_name!=orig_func_name: + print(" if (!%s) {" % name) + # Know the reason for this one, so avoid the spam. + if orig_func_name != "SecondaryColor3fvEXT": + print(" crDebug(\"App passed NULL as %s for %s\");" % (name, orig_func_name)) + print(" return;") + print(" }") + + packet_length = apiutil.PacketLength(nonVecParams) + + if packet_length == 0 and not is_extended: + print("\tCR_GET_BUFFERED_POINTER_NO_ARGS(pc);") + elif func_name[:9] == "Translate" or func_name[:5] == "Color": + # XXX WTF is the purpose of this? + if is_extended: + packet_length += 8 + print("\tCR_GET_BUFFERED_POINTER_NO_BEGINEND_FLUSH(pc, %d, GL_TRUE);" % packet_length) + else: + if is_extended: + packet_length += 8 + print("\tCR_GET_BUFFERED_POINTER(pc, %d);" % packet_length) + UpdateCurrentPointer( func_name ) + + if is_extended: + counter = 8 + print(WriteData( 0, 'GLint', packet_length, is_swapped )) + print(WriteData( 4, 'GLenum', apiutil.ExtendedOpcodeName( func_name ), is_swapped )) + else: + counter = 0 + + # Now emit the WRITE_() macros for all parameters + for index in range(0,len(params)): + (name, type, vecSize) = params[index] + # if we're converting a vector-valued function to a non-vector func: + if vecSize > 0 and func_name != orig_func_name: + ptrType = apiutil.PointerType(type) + for i in range(0, vecSize): + print(WriteData( counter + i * apiutil.sizeof(ptrType), + ptrType, "%s[%d]" % (name, i), is_swapped )) + # XXX increment counter here? + else: + print(WriteData( counter, type, name, is_swapped )) + if apiutil.IsPointer(type): + counter += apiutil.PointerSize() + else: + counter += apiutil.sizeof(type) + + # finish up + if is_extended: + print("\tWRITE_OPCODE(pc, CR_EXTEND_OPCODE);") + else: + print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name )) + + if "get" in apiutil.Properties(func_name): + print('\tCR_CMDBLOCK_CHECK_FLUSH(pc);') + + print('\tCR_UNLOCK_PACKER_CONTEXT(pc);') + print('}\n') + + +r0_funcs = [ 'ChromiumParameteriCR', 'WindowSize', 'WindowShow', 'WindowPosition' ] + + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE GENERATED BY THE packer.py SCRIPT */ + +/* For each of the OpenGL functions we have a packer function which + * packs the function's opcode and arguments into a buffer. + */ + +#include "packer.h" +#include "cr_opcodes.h" + +""") + + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") + +for func_name in keys: + if apiutil.FindSpecial( "packer", func_name ): + continue + + if not apiutil.HasPackOpcode(func_name): + continue + + pointers_ok = 0 + + return_type = apiutil.ReturnType(func_name) + params = apiutil.Parameters(func_name) + + if return_type != 'void': + # Yet another gross hack for glGetString + if return_type.find('*') == -1: + return_type = return_type + " *" + params.append(("return_value", return_type, 0)) + + if "get" in apiutil.Properties(func_name): + pointers_ok = 1 + params.append(("writeback", "int *", 0)) + + if func_name == 'Writeback': + pointers_ok = 1 + + if not func_name in r0_funcs: + print('#ifndef IN_RING0') + + PrintFunc( func_name, params, 0, pointers_ok ) + PrintFunc( func_name, params, 1, pointers_ok ) + + if not func_name in r0_funcs: + print('#endif') + diff --git a/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py b/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py new file mode 100755 index 00000000..5abb6e2e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/packer_bbox.py @@ -0,0 +1,316 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This script generates the packer_bbox.c file from gl_header.parsed + +from __future__ import print_function +import sys +import string + +import apiutil + + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE GENERATED BY THE packer_bbox.py SCRIPT */ + +/* These functions pack glVertex functions and also update the bounding box + * if the cr_packer_globals.updateBBOX variable is non-zero. + */ + +#include "packer.h" +#include "cr_opcodes.h" +#include "pack_bbox.h" + +#include + +/** + * Reset packer bounding box to empty state. + */ +void crPackResetBoundingBox(CRPackContext *pc) +{ + pc->bounds_min.x = FLT_MAX; + pc->bounds_min.y = FLT_MAX; + pc->bounds_min.z = FLT_MAX; + pc->bounds_max.x = -FLT_MAX; + pc->bounds_max.y = -FLT_MAX; + pc->bounds_max.z = -FLT_MAX; + pc->updateBBOX = 1; +} + +/** + * Query current bounding box. + * \return GL_TRUE if non-empty box, GL_FALSE if empty box. + */ +GLboolean crPackGetBoundingBox(CRPackContext *pc, + GLfloat *xmin, GLfloat *ymin, GLfloat *zmin, + GLfloat *xmax, GLfloat *ymax, GLfloat *zmax) +{ + if (pc->bounds_min.x != FLT_MAX) { + *xmin = pc->bounds_min.x; + *ymin = pc->bounds_min.y; + *zmin = pc->bounds_min.z; + *xmax = pc->bounds_max.x; + *ymax = pc->bounds_max.y; + *zmax = pc->bounds_max.z; + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + +""") + +def WriteData( offset, arg_type, arg_name, is_swapped ): + if arg_type.find('*') != -1: + retval = "\tWRITE_NETWORK_POINTER(%d, (void *) %s);" % (offset, arg_name ) + else: + if is_swapped: + if arg_type == "GLfloat" or arg_type == "GLclampf": + retval = "\tWRITE_DATA(%d, GLuint, SWAPFLOAT(%s));" % (offset, arg_name) + elif arg_type == "GLdouble" or arg_type == "GLclampd": + retval = "\tWRITE_SWAPPED_DOUBLE(%d, %s);" % (offset, arg_name) + elif apiutil.sizeof(arg_type) == 1: + retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name) + elif apiutil.sizeof(arg_type) == 2: + retval = "\tWRITE_DATA(%d, %s, SWAP16(%s));" % (offset, arg_type, arg_name) + elif apiutil.sizeof(arg_type) == 4: + retval = "\tWRITE_DATA(%d, %s, SWAP32(%s));" % (offset, arg_type, arg_name) + else: + if arg_type == "GLdouble" or arg_type == "GLclampd": + retval = "\tWRITE_DOUBLE(%d, %s);" % (offset, arg_name) + else: + retval = "\tWRITE_DATA(%d, %s, %s);" % (offset, arg_type, arg_name) + return retval + + +def PrintFunction( func_name, extSuffix, num_coords, argtype, + do_swapped, do_count, do_vector ): + """ + Generate all the functions named crPackVertex[234][dfis][v]BBOX() and + crPackVertex[234][dfis][v]BBOX_COUNT(). + We also handle glVertexAttrib*ARB. + Note: func_name should not have an ARB suffix. + """ + + if do_count: + countSuffix = "_COUNT" + else: + countSuffix = "" + + if do_swapped: + swapSuffix = "SWAP" + else: + swapSuffix = "" + + if func_name[0:12] == "VertexAttrib": + isVertexAttrib = 1 + else: + isVertexAttrib = 0 + + if argtype[0] == "N": + normalized = 1 + else: + normalized = 0; + + if argtype == "b" or argtype == "Nb": + vector_type = "GLbyte" + elif argtype == "ub" or argtype == "Nub": + vector_type = "GLubyte" + elif argtype == "s" or argtype == "Ns": + vector_type = "GLshort" + elif argtype == "us" or argtype == "Nus": + vector_type = "GLushort" + elif argtype == "i" or argtype == "Ni": + vector_type = "GLint" + elif argtype == "ui" or argtype == "Nui": + vector_type = "GLuint" + elif argtype == "f": + vector_type = "GLfloat" + elif argtype == "d": + vector_type = "GLdouble" + else: + print("type is %s" % argtype) + abort() + + if do_vector: + if isVertexAttrib: + func_name = 'VertexAttrib%d%sv' % (num_coords, argtype) + else: + func_name = 'Vertex%d%sv' % (num_coords,argtype) + + params = apiutil.Parameters(func_name + extSuffix) + + print('void PACK_APIENTRY crPack%sBBOX%s%s(%s)' % (func_name + extSuffix, countSuffix, + swapSuffix, apiutil.MakeDeclarationString(params))) + print('{') + + if do_vector: + # vector version + packet_length = num_coords * apiutil.sizeof(vector_type) + if isVertexAttrib: + packet_length += 4 # for index + if packet_length % 4 != 0: + packet_length += 2 + + else: + # non-vector + packet_length = apiutil.PacketLength( params ) + if isVertexAttrib: + packet_length += 0 # for index + if packet_length % 4 != 0: + packet_length += 2 + + + print("\tCR_GET_PACKER_CONTEXT(pc);") + print("\tunsigned char *data_ptr = NULL;") + + if normalized: + if argtype == "Nb": + t = "B" + elif argtype == "Ni": + t = "I" + elif argtype == "Nui": + t = "UI" + elif argtype == "Nub": + t = "UB" + elif argtype == "Ns": + t = "S" + elif argtype == "Nus": + t = "US" + else: + abort() + if do_vector: + print("\tCREATE_%dD_VFLOATS_%s_NORMALIZED();" % (num_coords, t)) + else: + print("\tCREATE_%dD_FLOATS_%s_NORMALIZED();" % (num_coords, t)) + else: + if do_vector: + print("\tCREATE_%dD_VFLOATS();" % num_coords) + else: + print("\tCREATE_%dD_FLOATS();" % num_coords) + + print("\tCR_GET_BUFFERED%s_POINTER(pc, %d);" % (countSuffix, packet_length)) + + # Bounding box code + if isVertexAttrib: + print("\tif (pc->updateBBOX && index == 0)") + else: + print("\tif (pc->updateBBOX)") + print("\t{") + if num_coords < 4: + print("\t\tUPDATE_%dD_BBOX();" % num_coords) + else: + print("\t\tUPDATE_3D_BBOX();") + print("\t}") + + if isVertexAttrib: + print("\tif (index > 0) {") + t = argtype + print("\t\tpc->current.c.vertexAttrib.%s%d[index] = data_ptr + 4;" % (t, num_coords)) + print("\t\tpc->current.attribsUsedMask |= (1 << index);") + if do_count: + print("\t\tpc->current.vtx_count--;") + + print("\t}") + + fname = func_name + extSuffix + if do_vector: + # use non-vector opcode + opcode = apiutil.OpcodeName( func_name[:-1] + extSuffix ) + else: + opcode = apiutil.OpcodeName( func_name + extSuffix ) + counter = 0 + + if do_vector: + if isVertexAttrib: + if do_swapped: + print("\tWRITE_DATA(0, GLuint, SWAP32(index));") + else: + print("\tWRITE_DATA(0, GLuint, index);") + counter += 4 + argname = params[1][0] # skip 'index' parameter + else: + argname = params[0][0] + + for index in range(num_coords): + print(WriteData( counter, vector_type, "%s[%d]" % (argname, index), do_swapped )) + counter += apiutil.sizeof(vector_type) + + if isVertexAttrib: + if do_vector == 2: + # this is a bit of a hack + print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name + "ARB" )) + else: + print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name[:-1] + "ARB" )) + else: + print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name[:-1] )) + else: + for index in range(0,len(params)): + (name, type, vecSize) = params[index] + print(WriteData( counter, type, name, do_swapped )) + counter += apiutil.sizeof(type) + + if isVertexAttrib: + print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name + "ARB" )) + else: + print("\tWRITE_OPCODE(pc, %s);" % apiutil.OpcodeName( func_name )) + + print("\tCR_UNLOCK_PACKER_CONTEXT(pc);") + + + print('}\n') + +#end PrintFunction() + + +for num_coords in [2,3,4]: + for argtype in ['d', 'f', 'i', 's']: + func_name = 'Vertex%d%s' % (num_coords, argtype) + for swap in range(0, 2): + for count in range(0, 2): + for vec in range(0, 2): + PrintFunction( func_name, "", num_coords, argtype, swap, + count, vec ) + +for num_coords in [1,2,3,4]: + for argtype in ['d', 'f', 's']: + func_name = 'VertexAttrib%d%s' % (num_coords, argtype) + for swap in range(0, 2): + for count in range(0, 2): + for vec in range(0, 2): + PrintFunction( func_name, "ARB", num_coords, argtype, swap, + count, vec ) + +# Special vector functions +moreFuncs = [ [ "VertexAttrib4ubv", "ub" ], + [ "VertexAttrib4usv", "us" ], + [ "VertexAttrib4uiv", "ui" ], + [ "VertexAttrib4bv", "b" ], + [ "VertexAttrib4iv", "i" ], + [ "VertexAttrib4Nbv", "Nb" ], + [ "VertexAttrib4Nsv", "Ns" ], + [ "VertexAttrib4Niv", "Ni" ], + [ "VertexAttrib4Nubv", "Nub" ], + [ "VertexAttrib4Nusv", "Nus" ], + [ "VertexAttrib4Nuiv", "Nui" ] + ] +for (func_name, argtype) in moreFuncs: + vec = 2 # special, hacked value + num_coords = 4 + for swap in range(0, 2): + for count in range(0, 2): + PrintFunction( func_name, "ARB", num_coords, argtype, swap, count, vec ) + +# Special non-vector functions +moreFuncs = [ [ "VertexAttrib4Nub", "Nub" ] ] +for (func_name, argtype) in moreFuncs: + vec = 0 + num_coords = 4 + for swap in range(0, 2): + for count in range(0, 2): + PrintFunction( func_name, "ARB", num_coords, argtype, swap, count, vec ) diff --git a/src/VBox/GuestHost/OpenGL/packer/packer_defs.py b/src/VBox/GuestHost/OpenGL/packer/packer_defs.py new file mode 100644 index 00000000..40595871 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/packer_defs.py @@ -0,0 +1,203 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This script generates the packer/packer.def file. + +import sys +import cPickle + +import apiutil + + +apiutil.CopyrightDef() + +print "DESCRIPTION \"\"" +print "EXPORTS" + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") +for func_name in keys: + if apiutil.CanPack(func_name): + print "crPack%s" % func_name + print "crPack%sSWAP" % func_name + +functions = [ + 'crPackVertexAttrib1dARBBBOX', + 'crPackVertexAttrib1dvARBBBOX', + 'crPackVertexAttrib1fARBBBOX', + 'crPackVertexAttrib1fvARBBBOX', + 'crPackVertexAttrib1sARBBBOX', + 'crPackVertexAttrib1svARBBBOX', + 'crPackVertexAttrib2dARBBBOX', + 'crPackVertexAttrib2dvARBBBOX', + 'crPackVertexAttrib2fARBBBOX', + 'crPackVertexAttrib2fvARBBBOX', + 'crPackVertexAttrib2sARBBBOX', + 'crPackVertexAttrib2svARBBBOX', + 'crPackVertexAttrib3dARBBBOX', + 'crPackVertexAttrib3dvARBBBOX', + 'crPackVertexAttrib3fARBBBOX', + 'crPackVertexAttrib3fvARBBBOX', + 'crPackVertexAttrib3sARBBBOX', + 'crPackVertexAttrib3svARBBBOX', + 'crPackVertexAttrib4dARBBBOX', + 'crPackVertexAttrib4dvARBBBOX', + 'crPackVertexAttrib4fARBBBOX', + 'crPackVertexAttrib4fvARBBBOX', + 'crPackVertexAttrib4sARBBBOX', + 'crPackVertexAttrib4svARBBBOX', + 'crPackVertexAttrib4usvARBBBOX', + 'crPackVertexAttrib4ivARBBBOX', + 'crPackVertexAttrib4uivARBBBOX', + 'crPackVertexAttrib4bvARBBBOX', + 'crPackVertexAttrib4ubvARBBBOX', + 'crPackVertexAttrib4NusvARBBBOX', + 'crPackVertexAttrib4NsvARBBBOX', + 'crPackVertexAttrib4NuivARBBBOX', + 'crPackVertexAttrib4NivARBBBOX', + 'crPackVertexAttrib4NubvARBBBOX', + 'crPackVertexAttrib4NbvARBBBOX', + 'crPackVertexAttrib4NubARBBBOX', + 'crPackVertex2dBBOX', + 'crPackVertex2dvBBOX', + 'crPackVertex2fBBOX', + 'crPackVertex2fvBBOX', + 'crPackVertex2iBBOX', + 'crPackVertex2ivBBOX', + 'crPackVertex2sBBOX', + 'crPackVertex2svBBOX', + 'crPackVertex3dBBOX', + 'crPackVertex3dvBBOX', + 'crPackVertex3fBBOX', + 'crPackVertex3fvBBOX', + 'crPackVertex3iBBOX', + 'crPackVertex3ivBBOX', + 'crPackVertex3sBBOX', + 'crPackVertex3svBBOX', + 'crPackVertex4dBBOX', + 'crPackVertex4dvBBOX', + 'crPackVertex4fBBOX', + 'crPackVertex4fvBBOX', + 'crPackVertex4iBBOX', + 'crPackVertex4ivBBOX', + 'crPackVertex4sBBOX', + 'crPackVertex4svBBOX', + 'crPackVertexAttrib1dARBBBOX_COUNT', + 'crPackVertexAttrib1dvARBBBOX_COUNT', + 'crPackVertexAttrib1fARBBBOX_COUNT', + 'crPackVertexAttrib1fvARBBBOX_COUNT', + 'crPackVertexAttrib1sARBBBOX_COUNT', + 'crPackVertexAttrib1svARBBBOX_COUNT', + 'crPackVertexAttrib2dARBBBOX_COUNT', + 'crPackVertexAttrib2dvARBBBOX_COUNT', + 'crPackVertexAttrib2fARBBBOX_COUNT', + 'crPackVertexAttrib2fvARBBBOX_COUNT', + 'crPackVertexAttrib2sARBBBOX_COUNT', + 'crPackVertexAttrib2svARBBBOX_COUNT', + 'crPackVertexAttrib3dARBBBOX_COUNT', + 'crPackVertexAttrib3dvARBBBOX_COUNT', + 'crPackVertexAttrib3fARBBBOX_COUNT', + 'crPackVertexAttrib3fvARBBBOX_COUNT', + 'crPackVertexAttrib3sARBBBOX_COUNT', + 'crPackVertexAttrib3svARBBBOX_COUNT', + 'crPackVertexAttrib4dARBBBOX_COUNT', + 'crPackVertexAttrib4dvARBBBOX_COUNT', + 'crPackVertexAttrib4fARBBBOX_COUNT', + 'crPackVertexAttrib4fvARBBBOX_COUNT', + 'crPackVertexAttrib4sARBBBOX_COUNT', + 'crPackVertexAttrib4svARBBBOX_COUNT', + 'crPackVertexAttrib4usvARBBBOX_COUNT', + 'crPackVertexAttrib4ivARBBBOX_COUNT', + 'crPackVertexAttrib4uivARBBBOX_COUNT', + 'crPackVertexAttrib4bvARBBBOX_COUNT', + 'crPackVertexAttrib4ubvARBBBOX_COUNT', + 'crPackVertexAttrib4NusvARBBBOX_COUNT', + 'crPackVertexAttrib4NsvARBBBOX_COUNT', + 'crPackVertexAttrib4NuivARBBBOX_COUNT', + 'crPackVertexAttrib4NivARBBBOX_COUNT', + 'crPackVertexAttrib4NubvARBBBOX_COUNT', + 'crPackVertexAttrib4NbvARBBBOX_COUNT', + 'crPackVertexAttrib4NubARBBBOX_COUNT', + 'crPackVertex2dBBOX_COUNT', + 'crPackVertex2dvBBOX_COUNT', + 'crPackVertex2fBBOX_COUNT', + 'crPackVertex2fvBBOX_COUNT', + 'crPackVertex2iBBOX_COUNT', + 'crPackVertex2ivBBOX_COUNT', + 'crPackVertex2sBBOX_COUNT', + 'crPackVertex2svBBOX_COUNT', + 'crPackVertex3dBBOX_COUNT', + 'crPackVertex3dvBBOX_COUNT', + 'crPackVertex3fBBOX_COUNT', + 'crPackVertex3fvBBOX_COUNT', + 'crPackVertex3iBBOX_COUNT', + 'crPackVertex3ivBBOX_COUNT', + 'crPackVertex3sBBOX_COUNT', + 'crPackVertex3svBBOX_COUNT', + 'crPackVertex4dBBOX_COUNT', + 'crPackVertex4dvBBOX_COUNT', + 'crPackVertex4fBBOX_COUNT', + 'crPackVertex4fvBBOX_COUNT', + 'crPackVertex4iBBOX_COUNT', + 'crPackVertex4ivBBOX_COUNT', + 'crPackVertex4sBBOX_COUNT', + 'crPackVertex4svBBOX_COUNT', + 'crPackVertexAttribs1dvNV', + 'crPackVertexAttribs1fvNV', + 'crPackVertexAttribs1svNV', + 'crPackVertexAttribs2dvNV', + 'crPackVertexAttribs2fvNV', + 'crPackVertexAttribs2svNV', + 'crPackVertexAttribs3dvNV', + 'crPackVertexAttribs3fvNV', + 'crPackVertexAttribs3svNV', + 'crPackVertexAttribs4dvNV', + 'crPackVertexAttribs4fvNV', + 'crPackVertexAttribs4svNV', + 'crPackVertexAttribs4ubvNV', + 'crPackExpandDrawArrays', + 'crPackExpandDrawElements', + 'crPackUnrollDrawElements', + 'crPackExpandDrawRangeElements', + 'crPackExpandArrayElement', + 'crPackExpandMultiDrawArraysEXT', + 'crPackMultiDrawArraysEXT', + 'crPackMultiDrawElementsEXT', + 'crPackExpandMultiDrawElementsEXT', + 'crPackMapBufferARB', + 'crPackUnmapBufferARB' ] + +for func_name in functions: + print "%s" % func_name + print "%sSWAP" % func_name + + +print """ +crPackInitBuffer +crPackResetPointers +crPackAppendBuffer +crPackAppendBoundedBuffer +crPackSetBuffer +crPackSetBufferDEBUG +crPackReleaseBuffer +crPackFlushFunc +crPackFlushArg +crPackSendHugeFunc +crPackBoundsInfoCR +crPackResetBoundingBox +crPackGetBoundingBox +crPackOffsetCurrentPointers +crPackNullCurrentPointers +crPackNewContext +crPackGetContext +crPackSetContext +crPackFree +crNetworkPointerWrite +crPackCanHoldBuffer +crPackCanHoldBoundedBuffer +crPackMaxData +crPackErrorFunction +cr_packer_globals +_PackerTSD +""" diff --git a/src/VBox/GuestHost/OpenGL/packer/packer_extensions.h b/src/VBox/GuestHost/OpenGL/packer/packer_extensions.h new file mode 100644 index 00000000..fba8d2f2 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/packer_extensions.h @@ -0,0 +1,13 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef CR_PACKER_EXTENSIONS_H +#define CR_PACKER_EXTENSIONS_H + +int __packTexParameterNumParams( GLenum pname ); +int __packFogParamsLength( GLenum pname ); + +#endif /* CR_PACKER_EXTENSION_H */ diff --git a/src/VBox/GuestHost/OpenGL/packer/packer_special b/src/VBox/GuestHost/OpenGL/packer/packer_special new file mode 100644 index 00000000..42fe6659 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/packer/packer_special @@ -0,0 +1,185 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +BoundsInfoCR +VertexPointer +ColorPointer +CreateContext +SecondaryColorPointerEXT +NormalPointer +TexCoordPointer +EdgeFlagPointer +InterleavedArrays +IndexPointer +AreTexturesResident +AreProgramsResidentNV +Bitmap +CallLists +NewList +EndList +ClipPlane +DeleteTextures +DrawPixels +Fogfv +Fogiv +GetTexImage +Lightfv +Lightiv +LightModelfv +LightModeliv +LoadMatrixf +LoadMatrixd +Map1d +Map1f +Map2d +Map2f +Materialfv +Materialiv +MultMatrixd +MultMatrixf +PixelMapfv +PixelMapuiv +PixelMapusv +PolygonStipple +PrioritizeTextures +ReadPixels +TexEnvfv +TexEnviv +TexGendv +TexGenfv +TexGeniv +TexEnvf +TexEnvi +TexGend +TexGenf +TexGeni +TexImage1D +TexImage2D +TexImage3D +TexImage3DEXT +TexParameterfv +TexParameteriv +TexParameterf +TexParameteri +TexSubImage1D +TexSubImage2D +TexSubImage3D +DrawElements +MultiDrawArraysEXT +MultiDrawElementsEXT +DrawRangeElements +CombinerParameterfvNV +CombinerParameterivNV +CombinerStageParameterfvNV +ChromiumParametervCR +WindowCreate +FeedbackBuffer +SelectBuffer +Begin +End +VertexArrayRangeNV +LoadTransposeMatrixfARB +LoadTransposeMatrixdARB +MultTransposeMatrixfARB +MultTransposeMatrixdARB +ProgramParameters4dvNV +ProgramParameters4fvNV +VertexAttribPointerNV +VertexAttribs1dvNV +VertexAttribs1fvNV +VertexAttribs1svNV +VertexAttribs2dvNV +VertexAttribs2fvNV +VertexAttribs2svNV +VertexAttribs3dvNV +VertexAttribs3fvNV +VertexAttribs3svNV +VertexAttribs4dvNV +VertexAttribs4fvNV +VertexAttribs4svNV +VertexAttribs4ubvNV +ExecuteProgramNV +LoadProgramNV +RequestResidentProgramsNV +CompressedTexImage3DARB +CompressedTexImage2DARB +CompressedTexImage1DARB +CompressedTexSubImage3DARB +CompressedTexSubImage2DARB +CompressedTexSubImage1DARB +GetCompressedTexImageARB +DeleteFencesNV +FogCoordPointerEXT +PointParameterfvARB +PointParameteriv +ProgramNamedParameter4fNV +ProgramNamedParameter4dNV +ProgramNamedParameter4fvNV +ProgramNamedParameter4dvNV +GetProgramNamedParameterdvNV +GetProgramNamedParameterfvNV +VertexAttrib4bvARB +VertexAttrib4ivARB +VertexAttrib4ubvARB +VertexAttrib4uivARB +VertexAttrib4usvARB +VertexAttribPointerARB +DeleteProgramsARB +ProgramStringARB +VertexAttrib4NbvARB +VertexAttrib4NivARB +VertexAttrib4NsvARB +VertexAttrib4NubvARB +VertexAttrib4NuivARB +VertexAttrib4NusvARB +BufferDataARB +BufferSubDataARB +MapBufferARB +UnmapBufferARB +DeleteBuffersARB +ZPixCR +WindowVisibleRegion +BindAttribLocation +ShaderSource +Uniform1fv +Uniform1iv +Uniform2fv +Uniform2iv +Uniform3fv +Uniform3iv +Uniform4fv +Uniform4iv +UniformMatrix2fv +UniformMatrix3fv +UniformMatrix4fv +DrawBuffers +GetActiveAttrib +GetActiveUniform +GetAttachedShaders +GetShaderInfoLog +GetProgramInfoLog +GetShaderSource +GetAttribLocation +GetUniformLocation +GetAttachedObjectsARB +GetInfoLogARB +GetBufferSubDataARB +DeleteQueriesARB +DeleteFramebuffersEXT +DeleteRenderbuffersEXT +LockArraysEXT +GetUniformsLocations +GetAttribsLocations +UniformMatrix2x3fv +UniformMatrix3x2fv +UniformMatrix2x4fv +UniformMatrix4x2fv +UniformMatrix3x4fv +UniformMatrix4x3fv +VBoxTexPresent +WindowPosition +WindowShow +WindowSize +BeginQueryARB +EndQueryARB diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/Makefile.kup b/src/VBox/GuestHost/OpenGL/spu_loader/Makefile.kup new file mode 100644 index 00000000..e69de29b diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/choosevisual.c b/src/VBox/GuestHost/OpenGL/spu_loader/choosevisual.c new file mode 100644 index 00000000..1dc797e1 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/choosevisual.c @@ -0,0 +1,329 @@ + +#include "chromium.h" +#include "cr_spu.h" +#include "cr_error.h" +#include "cr_string.h" + + +/** + * Wrappers for glXChooseVisual/etc. + * + * By using this function, the fake GLX, render SPU, tilesort SPU, + * etc can be assured of getting the same GLX visual for a set of CR_*_BIT + * visual flags. This helps ensure that render_to_app_window will work + * properly. + */ + + +#if defined(WINDOWS) +int +crChooseVisual(const crOpenGLInterface *ws, int visBits) +{ + /* placeholder */ + return 0; +} +#endif + + +#if defined(DARWIN) +int +crChooseVisual(const crOpenGLInterface *ws, int visBits) +{ + /* placeholder */ + return 0; +} +#endif + + +#if defined(GLX) + +XVisualInfo * +crChooseVisual(const crOpenGLInterface *ws, Display *dpy, int screen, + GLboolean directColor, int visBits) +{ + XVisualInfo *vis; + int errorBase, eventBase; + + if (ws->glXQueryExtension(dpy, &errorBase, &eventBase)) + { + + if (ws->glXChooseVisual) + { + /* Use the real OpenGL's glXChooseVisual function */ + int attribList[100]; + int i = 0; + + /* Build the attribute list */ + if (visBits & CR_RGB_BIT) + { + attribList[i++] = GLX_RGBA; + attribList[i++] = GLX_RED_SIZE; + attribList[i++] = 1; + attribList[i++] = GLX_GREEN_SIZE; + attribList[i++] = 1; + attribList[i++] = GLX_BLUE_SIZE; + attribList[i++] = 1; + } + + if (visBits & CR_ALPHA_BIT) + { + attribList[i++] = GLX_ALPHA_SIZE; + attribList[i++] = 1; + } + + if (visBits & CR_DOUBLE_BIT) + { + attribList[i++] = GLX_DOUBLEBUFFER; + } + + if (visBits & CR_STEREO_BIT) + { + attribList[i++] = GLX_STEREO; + } + + if (visBits & CR_DEPTH_BIT) + { + attribList[i++] = GLX_DEPTH_SIZE; + attribList[i++] = 1; + } + + if (visBits & CR_STENCIL_BIT) + { + attribList[i++] = GLX_STENCIL_SIZE; + attribList[i++] = 1; + } + + if (visBits & CR_ACCUM_BIT) + { + attribList[i++] = GLX_ACCUM_RED_SIZE; + attribList[i++] = 1; + attribList[i++] = GLX_ACCUM_GREEN_SIZE; + attribList[i++] = 1; + attribList[i++] = GLX_ACCUM_BLUE_SIZE; + attribList[i++] = 1; + if (visBits & CR_ALPHA_BIT) + { + attribList[i++] = GLX_ACCUM_ALPHA_SIZE; + attribList[i++] = 1; + } + } + + if (visBits & CR_MULTISAMPLE_BIT) + { + attribList[i++] = GLX_SAMPLE_BUFFERS_SGIS; + attribList[i++] = 1; + attribList[i++] = GLX_SAMPLES_SGIS; + attribList[i++] = 4; + } + + if (visBits & CR_OVERLAY_BIT) + { + attribList[i++] = GLX_LEVEL; + attribList[i++] = 1; + } + + if (directColor) + { + /* + * See if we have have GLX_EXT_visual_info so we + * can grab a Direct Color visual + */ +#ifdef GLX_EXT_visual_info + if (crStrstr(ws->glXQueryExtensionsString(dpy, screen), + "GLX_EXT_visual_info")) + { + attribList[i++] = GLX_X_VISUAL_TYPE_EXT; + attribList[i++] = GLX_DIRECT_COLOR_EXT; + } +#endif + } + + /* End the list */ + attribList[i++] = None; + + vis = ws->glXChooseVisual(dpy, screen, attribList); + return vis; + } + else + { + /* Don't use glXChooseVisual, use glXGetConfig. + * + * Here's the deal: + * Some (all?) versions of the libGL.so that's shipped with ATI's + * drivers aren't built with the -Bsymbolic flag. That's bad. + * + * If we call the glXChooseVisual() function that's built into ATI's + * libGL, it in turn calls the glXGetConfig() function. Now, there's + * a glXGetConfig function in libGL.so **AND** there's a glXGetConfig + * function in Chromium's libcrfaker.so library. Unfortunately, the + * later one gets called instead of the former. At this point, things + * go haywire. If -Bsymbolic were used, this would not happen. + */ + XVisualInfo templateVis; + long templateFlags; + int count, i, visType; + + visType = directColor ? DirectColor : TrueColor; + + /* Get list of candidate visuals */ + templateFlags = VisualScreenMask | VisualClassMask; + templateVis.screen = screen; +#if defined(__cplusplus) || defined(c_plusplus) + templateVis.c_class = visType; +#else + templateVis.class = visType; +#endif + + vis = XGetVisualInfo(dpy, templateFlags, &templateVis, &count); + /* find first visual that's good enough */ + for (i = 0; i < count; i++) + { + int val; + + /* Need exact match on RGB, DOUBLEBUFFER, STEREO, LEVEL, MULTISAMPLE */ + ws->glXGetConfig(dpy, vis + i, GLX_RGBA, &val); + if (((visBits & CR_RGB_BIT) && !val) || + (((visBits & CR_RGB_BIT) == 0) && val)) + { + continue; + } + + ws->glXGetConfig(dpy, vis + i, GLX_DOUBLEBUFFER, &val); + if (((visBits & CR_DOUBLE_BIT) && !val) || + (((visBits & CR_DOUBLE_BIT) == 0) && val)) + { + continue; + } + + ws->glXGetConfig(dpy, vis + i, GLX_STEREO, &val); + if (((visBits & CR_STEREO_BIT) && !val) || + (((visBits & CR_STEREO_BIT) == 0) && val)) + { + continue; + } + + ws->glXGetConfig(dpy, vis + i, GLX_LEVEL, &val); + if (((visBits & CR_OVERLAY_BIT) && !val) || + (((visBits & CR_OVERLAY_BIT) == 0) && val)) + { + continue; + } + + ws->glXGetConfig(dpy, vis + i, GLX_SAMPLE_BUFFERS_SGIS, &val); + if (visBits & CR_MULTISAMPLE_BIT) + { + if (!val) + continue; + ws->glXGetConfig(dpy, vis + i, GLX_SAMPLES_SGIS, &val); + if (val < 4) + continue; + } + else { + /* don't want multisample */ + if (val) + continue; + } + + /* Need good enough for ALPHA, DEPTH, STENCIL, ACCUM */ + if (visBits & CR_ALPHA_BIT) + { + ws->glXGetConfig(dpy, vis + i, GLX_ALPHA_SIZE, &val); + if (!val) + continue; + } + + if (visBits & CR_DEPTH_BIT) + { + ws->glXGetConfig(dpy, vis + i, GLX_DEPTH_SIZE, &val); + if (!val) + continue; + } + + if (visBits & CR_STENCIL_BIT) + { + ws->glXGetConfig(dpy, vis + i, GLX_STENCIL_SIZE, &val); + if (!val) + continue; + } + + if (visBits & CR_ACCUM_BIT) + { + ws->glXGetConfig(dpy, vis + i, GLX_ACCUM_RED_SIZE, &val); + if (!val) + continue; + if (visBits & CR_ALPHA_BIT) + { + ws->glXGetConfig(dpy, vis + i, GLX_ACCUM_ALPHA_SIZE, &val); + if (!val) + continue; + } + } + + /* If we get here, we found a good visual. + * Now, we need to get a new XVisualInfo pointer in case the caller + * calls XFree on it. + */ + templateFlags = VisualScreenMask | VisualIDMask; + templateVis.screen = screen; + templateVis.visualid = vis[i].visual->visualid; + XFree(vis); /* free the list */ + vis = XGetVisualInfo(dpy, templateFlags, &templateVis, &count); + return vis; + } + + /* if we get here, we failed to find a sufficient visual */ + return NULL; + } + } + else + { + /* use Xlib instead of GLX */ + XVisualInfo templateVis, *best; + long templateFlags; + int i, count, visType; + + if (visBits & CR_RGB_BIT) + visType = directColor ? DirectColor : TrueColor; + else + visType = PseudoColor; + + /* Get list of candidate visuals */ + templateFlags = VisualScreenMask | VisualClassMask; + templateVis.screen = screen; +#if defined(__cplusplus) || defined(c_plusplus) + templateVis.c_class = visType; +#else + templateVis.class = visType; +#endif + + vis = XGetVisualInfo(dpy, templateFlags, &templateVis, &count); + if (!vis) + return NULL; + + /* okay, select the RGB visual with the most depth */ + best = vis + 0; + for (i = 1; i < count; i++) + { + if (vis[i].depth > best->depth && + vis[i].bits_per_rgb > best->bits_per_rgb ) + best = vis + i; + } + + if (best) + { + /* If we get here, we found a good visual. + * Now, we need to get a new XVisualInfo pointer in case the caller + * calls XFree on it. + */ + templateFlags = VisualScreenMask | VisualIDMask; + templateVis.screen = screen; + templateVis.visualid = best->visualid; + XFree(vis); /* free the list */ + best = XGetVisualInfo(dpy, templateFlags, &templateVis, &count); + } + + return best; + } +} + +#endif /* GLX */ diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py b/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py new file mode 100755 index 00000000..581121d5 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/dispatch.py @@ -0,0 +1,126 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys +import apiutil + + +apiutil.CopyrightC() + +print(""" + +/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY dispatch.py SCRIPT */ + +#include "cr_spu.h" +#include "cr_string.h" +#include "cr_error.h" + + +static SPUGenericFunction __findFunc( char *name, SPU *spu ) +{ + SPUNamedFunctionTable *temp; + + if (spu == NULL) + return NULL; + + for (temp = spu->function_table->table ; temp->name != NULL ; temp++) + { + if (!crStrcmp(name, temp->name)) + { + return temp->fn; + } + } + return __findFunc(name, spu->superSPU); +} + + +/* + * This function is not public outside the loader SPU. + */ +extern void __buildDispatch( SPU *spu ); + +void __buildDispatch( SPU *spu ) +{""") + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") +for func_name in keys: + print('\tspu->dispatch_table.%s = (%sFunc_t) __findFunc( "%s", spu );' % (func_name,func_name,func_name)) +print('}') + + +print(""" + +/* + * Public function: + * Search a SPU named function table for a specific function. Return + * a pointer to it or NULL if not found. + */ +SPUGenericFunction crSPUFindFunction( const SPUNamedFunctionTable *table, const char *fname ) +{ + const SPUNamedFunctionTable *temp; + + for (temp = table ; temp->name != NULL ; temp++) + { + if (!crStrcmp(fname, temp->name)) + { + return temp->fn; + } + } + return NULL; +} + + +/* + * Public function: + * Initializes the pointers in an SPUDispatchTable by looking for functions + * in an SPUNamedFunctionTable. + * It doesn't know anything about SPUs and SPU inheritance. + */ +void crSPUInitDispatch( SPUDispatchTable *dispatch, const SPUNamedFunctionTable *table ) +{""") + +for func_name in keys: + print('\tdispatch->%s = (%sFunc_t) crSPUFindFunction(table, "%s");' % (func_name, func_name, func_name)) +print('}') + + + +print(""" +/* + * Generic no-op function + */ +static int NopFunction(void) +{ +/* + crWarning("Calling generic no-op function in dispatch.c"); +*/ + return 0; +} + + +/* + * Scan the given dispatch table for NULL pointers. Hook in the generic + * no-op function wherever we find a NULL pointer. + */ +void crSPUInitDispatchNops(SPUDispatchTable *table) +{ + /* + * This is a bit tricky. We walk over all the function pointers in + * the SPUDispatchTable struct, checking for NULL and setting NULL + * pointers to point to NopFunction(). + * But we have to stop when we get to the copyList pointer! + */ + const int numEntries = (void **) &(table->copyList) - (void **) &(table->Accum); + void **ptr = (void **) table; + int i; + for (i = 0; i < numEntries; i++) { + if (ptr[i] == NULL) { + /*printf("!!!!!!!Warning entry[%d] = NULL\n", i);*/ + ptr[i] = (void *)(uintptr_t)NopFunction; + } + } +} +""") diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py b/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py new file mode 100755 index 00000000..f3f15bee --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/dispatchheader.py @@ -0,0 +1,78 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# This script generates the spu_dispatch_table.h file from gl_header.parsed + +from __future__ import print_function +import sys, string + +import apiutil + + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE GENERATED BY THE dispatchheader.py SCRIPT */ + +#ifndef CR_SPU_DISPATCH_TABLE_H +#define CR_SPU_DISPATCH_TABLE_H + +#ifdef WINDOWS +#define SPU_APIENTRY __stdcall +#else +#define SPU_APIENTRY +#endif + +#include "chromium.h" +#include "state/cr_statetypes.h" +""") + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") + + +print('/* Offsets of each function within the dispatch table */') +offset = 0 +for func_name in keys: + print('#define DISPATCH_OFFSET_%s %d' % (func_name, offset)) + offset += 1 +print('') + +print('/* Function typedefs */') +for func_name in keys: + return_type = apiutil.ReturnType(func_name) + params = apiutil.Parameters(func_name) + + print('typedef %s (SPU_APIENTRY *%sFunc_t)(%s);' % (return_type, func_name, apiutil.MakePrototypeString(params))) +print('') + +print('struct _copy_list_node;') +print('') +print('/* Prototype for SPU internal state load/unload callbacks. */') +print('') +print('typedef int (*SPUStateFunc_t)(void *);') +print('') +print('/* The SPU dispatch table */') +print('typedef struct _spu_dispatch_table {') + +for func_name in keys: + print("\t%sFunc_t %s; " % ( func_name, func_name )) + +print(""" + struct _copy_list_node *copyList; + struct _spu_dispatch_table *copy_of; + int mark; + void *server; + SPUStateFunc_t spu_save_state; /* Save SPU internal state callback (optional) */ + SPUStateFunc_t spu_load_state; /* Load SPU internal state callback (optional) */ +} SPUDispatchTable; + +struct _copy_list_node { + SPUDispatchTable *copy; + struct _copy_list_node *next; +}; + + +#endif /* CR_SPU_DISPATCH_TABLE_H */ +""") diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py b/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py new file mode 100755 index 00000000..c73c12f1 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/glloader.py @@ -0,0 +1,609 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + + +from __future__ import print_function +import sys +import apiutil + + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE GENERATED BY THE glloader.py SCRIPT */ +#include "cr_error.h" +#include "cr_dll.h" +#include "cr_spu.h" +#include "cr_string.h" +#include "cr_error.h" +#include "cr_environment.h" + +#include +#if defined(WINDOWS) +# ifdef VBOX +# include +# else +#include +# endif +#include +#include +#define SYSTEM_GL "opengl32.dll" +#elif defined (DARWIN) +#define SYSTEM_GL "libGL.dylib" +#define SYSTEM_CGL "OpenGL" +# ifndef VBOX_WITH_COCOA_QT +# define SYSTEM_AGL "AGL" +# endif +#include /* VBOX */ +#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) +#include +#if defined(AIX) +#define SYSTEM_GL "libGL.o" +#else +#define SYSTEM_GL "libGL.so.1" +#endif +typedef void (*glxfuncptr)(void); +extern glxfuncptr glxGetProcAddressARB( const GLubyte *name ); +#else +#error I don't know where your system's GL lives. Too bad. +#endif + +static CRDLL *glDll = NULL; + +#ifdef DARWIN +#define SYSTEM_GL_LIB_DIR "/System/Library/Frameworks/OpenGL.framework/Libraries" +#define SYSTEM_CGL_DIR "/System/Library/Frameworks/OpenGL.framework" +static CRDLL *cglDll = NULL; +# ifndef VBOX_WITH_COCOA_QT +# define SYSTEM_AGL_DIR "/System/Library/Frameworks/AGL.framework" +static CRDLL *aglDll = NULL; +# endif +#endif + +#if defined(WINDOWS) +#define GLLOADER_APIENTRY __stdcall +#else +#define GLLOADER_APIENTRY +#endif + +/* + * Add an entry to the SPUNamedFunctionTable + */ +static int +fillin(SPUNamedFunctionTable *entry, const char *funcName, SPUGenericFunction funcPtr) +{ + if (funcPtr) { + entry->name = crStrdup(funcName); + entry->fn = funcPtr; + return 1; + } + return 0; +} + +#ifndef WINDOWS +/*static int FileExists(char *directory, char *filename) +{ + FILE *f; + char fullFilename[8096]; + + crStrcpy(fullFilename, directory); + crStrcat(fullFilename, "/"); + crStrcat(fullFilename, filename); + + f = fopen(fullFilename, "r"); + if (f) { + fclose(f); + return 1; + } + else { + return 0; + } +}*/ +#endif + + +/* + * Locate the native OpenGL library, open it and return shared library + * handle. + */ +static CRDLL * +__findSystemLib( const char *provided_system_path, char *lib ) +{ + CRDLL *dll; + char system_path[8096]; + + memset(system_path, 0, sizeof(system_path)); + + if (provided_system_path && (crStrlen(provided_system_path) > 0) ) + { + crStrcpy( system_path, provided_system_path ); + } + else + { +#if defined(WINDOWS) + GetSystemDirectory(system_path, MAX_PATH); +#elif defined(IRIX) || defined(IRIX64) +#ifdef IRIX_64BIT + crStrcpy( system_path, "/usr/lib64" ); +#else + crStrcpy( system_path, "/usr/lib32" ); +#endif +#elif defined(PLAYSTATION2) + crStrcpy( system_path, "/usr/X11R6/lib" ); +#else + /* On RedHat 9, the correct default system directory + * is /usr/lib/tls/ (and if /usr/lib/ is used, + * the dynamic loader will generate a floating point + * exception SIGFPE). On other systems, including + * earlier versions of RedHat, the OpenGL library + * lives in /usr/lib. We'll use the /usr/lib/tls/ + * version if it exists; otherwise, we'll use /usr/lib. + */ + /*crStrcpy(system_path, "/usr/lib");*/ +#if defined(__linux__) && defined(__amd64__) + /*if (sizeof(void *) == 8 && FileExists("/usr/lib64", lib)) { + crStrcat(system_path, "64"); + }*/ +#endif + /*if (FileExists("/usr/lib/tls", lib) || + FileExists("/usr/lib64/tls", lib)) { + crStrcat(system_path, "/tls"); + }*/ +#endif + } +#if !defined(__linux__) && !defined(SunOS) && !defined(__FreeBSD__) + crStrcat( system_path, "/" ); +#endif +#if !defined(CR_NO_GL_SYSTEM_PATH) + crStrcat( system_path, lib ); + dll = crDLLOpen(system_path, 1 /*resolveGlobal*/); +#else + dll = crDLLOpen(lib, 1 /*resolveGlobal*/); +#endif + return dll; +} + + +static CRDLL * +#ifdef DARWIN +__findSystemGL( const char *provided_system_path, const char *default_system_path, char *provided_lib_name ) +#else +__findSystemGL( const char *provided_system_path ) +#endif +{ +#ifdef DARWIN + const char *the_path = (provided_system_path && crStrlen(provided_system_path) > 0) ? provided_system_path : default_system_path; + + /* Fallback for loading frameworks */ + if( !provided_lib_name ) + return crDLLOpen( the_path, 1 ); + else + return __findSystemLib( the_path, provided_lib_name ); +#else + return __findSystemLib( provided_system_path, SYSTEM_GL ); +#endif +} + +static SPUGenericFunction +findExtFunction( const crOpenGLInterface *interface, const char *funcName ) +{ +#ifdef WINDOWS + if (interface->wglGetProcAddress) + return (SPUGenericFunction) interface->wglGetProcAddress( funcName ); + else + return (SPUGenericFunction) NULL; +#else + /* XXX for some reason, the NVIDIA glXGetProcAddressARB() function + * returns pointers that cause Chromium to crash. If we use the + * pointer returned by crDLLGetNoError() instead, we're OK. + */ + SPUGenericFunction f = crDLLGetNoError(glDll, funcName); + if (f) + return f; +#if !defined(DARWIN) + else if (interface->glXGetProcAddressARB) + return interface->glXGetProcAddressARB( (const GLubyte *) funcName ); +#endif + else + return NULL; +#endif +} +""") + + +def IsExtensionFunc(func_name): + """Determine if the named function is a core function, or extension.""" + cat = apiutil.Category(func_name) + if cat == "1.0" or cat == "1.1" or cat == "1.2" or cat == "1.3": + return 0 + else: + return 1 + +# +# Generate a no-op function. +# +def GenerateNop(func_name): + return_type = apiutil.ReturnType(func_name); + params = apiutil.Parameters(func_name) + print('static %s GLLOADER_APIENTRY Nop%s(%s)' % (return_type, func_name, apiutil.MakeDeclarationString(params))) + print('{') + for (name, type, vecSize) in params: + if name != "": + print('\t(void) %s;' % name) + if apiutil.ReturnType(func_name) != 'void': + print('\treturn 0;') + print('}') + print('') + + + +# +# Make no-op funcs for all OpenGL extension functions +# +for func_name in keys: + if IsExtensionFunc(func_name): + GenerateNop(func_name) + + +# +# Generate the crLoadOpenGL() function +# +print(""" +void +crUnloadOpenGL( void ) +{ + crDLLClose( glDll ); + glDll = NULL; + +#ifdef DARWIN + crDLLClose( cglDll ); + cglDll = NULL; + +# ifndef VBOX_WITH_COCOA_QT + crDLLClose( aglDll ); + aglDll = NULL; +# endif +#endif +} + +/* + * Initialize the 'interface' structure with the WGL or GLX window system + * interface functions. + * Then, fill in the table with (name, pointer) pairs for all the core + * OpenGL entrypoint functions. But only if table is not NULL + * Return: number of entries placed in table[], or 0 if error. + */ +int +crLoadOpenGL( crOpenGLInterface *interface, SPUNamedFunctionTable table[] ) +{ + static const char *coreFunctions[] = { +""") + +for func_name in keys: + if not IsExtensionFunc(func_name): + print('\t\t"gl%s",' % func_name) + +print(""" + NULL + }; + SPUNamedFunctionTable *entry = table; + int i; + + const char *env_syspath = crGetenv( "CR_SYSTEM_GL_PATH" ); +#ifdef DARWIN + const char *env_cgl_syspath = crGetenv( "CR_SYSTEM_CGL_PATH" ); +# ifndef VBOX_WITH_COCOA_QT + const char *env_agl_syspath = crGetenv( "CR_SYSTEM_AGL_PATH" ); +# endif +#endif + + crDebug( "Looking for the system's OpenGL library..." ); +#ifdef DARWIN + glDll = __findSystemGL( env_syspath, SYSTEM_GL_LIB_DIR, SYSTEM_GL ); +#else + glDll = __findSystemGL( env_syspath ); +#endif + if (!glDll) + { + crError("Unable to find system OpenGL!"); + return 0; + } + + crDebug( "Found it in %s.", !env_syspath ? "default path" : env_syspath ); + +#ifdef DARWIN + crDebug( "Looking for the system's CGL library..." ); + cglDll = __findSystemGL( env_cgl_syspath, SYSTEM_CGL_DIR, SYSTEM_CGL ); + if (!cglDll) + { + crError("Unable to find system CGL!"); + return 0; + } + + crDebug( "Found it in %s.", !env_cgl_syspath ? "default path" : env_cgl_syspath ); + +# ifndef VBOX_WITH_COCOA_QT + crDebug( "Looking for the system's AGL library..." ); + aglDll = __findSystemGL( env_agl_syspath, SYSTEM_AGL_DIR, SYSTEM_AGL ); + if (!aglDll) + { + crError("Unable to find system AGL!"); + return 0; + } + + crDebug( "Found it in %s.", !env_agl_syspath ? "default path" : env_agl_syspath ); +# endif +#endif +""") + +useful_wgl_functions = [ + "wglGetProcAddress", + "wglMakeCurrent", + "wglSwapBuffers", + "wglCreateContext", + "wglDeleteContext", + "wglShareLists", + "wglGetCurrentContext", + "wglChoosePixelFormat", + "wglDescribePixelFormat", + "wglSetPixelFormat", + "wglChoosePixelFormatEXT", + "wglGetPixelFormatAttribivEXT", + "wglGetPixelFormatAttribfvEXT", + "glGetString" +] +useful_agl_functions = [ + "aglCreateContext", + "aglDestroyContext", + "aglSetCurrentContext", + "aglSwapBuffers", + "aglChoosePixelFormat", + "aglDestroyPixelFormat", + "aglDescribePixelFormat", + "aglGetCurrentContext", + "aglSetDrawable", + "aglGetDrawable", + "aglSetFullScreen", + "aglUpdateContext", + "aglUseFont", + "aglSetInteger", + "aglGetInteger", + "aglGetError", + "aglEnable", + "aglDisable" +] +in_gl_functions = [ + "CGLGetCurrentContext", + "CGLSetCurrentContext" +] +useful_cgl_functions = [ + "CGLChoosePixelFormat", + "CGLDestroyPixelFormat", + "CGLDescribePixelFormat", + "CGLQueryRendererInfo", + "CGLDestroyRendererInfo", + "CGLDescribeRenderer", + "CGLCreateContext", + "CGLDestroyContext", + "CGLCopyContext", + "CGLCreatePBuffer", + "CGLDestroyPBuffer", + "CGLDescribePBuffer", + "CGLTexImagePBuffer", + "CGLSetOffScreen", + "CGLGetOffScreen", + "CGLSetFullScreen", + "CGLSetPBuffer", + "CGLGetPBuffer", + "CGLClearDrawable", + "CGLFlushDrawable", + "CGLEnable", + "CGLDisable", + "CGLIsEnabled", + "CGLSetParameter", + "CGLGetParameter", + "CGLSetVirtualScreen", + "CGLGetVirtualScreen", + "CGLSetOption", + "CGLGetOption", + "CGLGetVersion", + "CGLErrorString", + "CGLSetSurface", + "CGLGetSurface", + "CGLUpdateContext", + "glGetString" +] +useful_glx_functions = [ + "glXGetConfig", + "glXQueryExtension", + "glXQueryVersion", + "glXQueryExtensionsString", + "glXChooseVisual", + "glXCreateContext", + "glXDestroyContext", + "glXUseXFont", + "glXIsDirect", + "glXMakeCurrent", + "glGetString", + "glXSwapBuffers", + "glXGetCurrentDisplay", + "glXGetCurrentContext", + "glXGetClientString", + "glXWaitGL", + "glXWaitX", + "glXCopyContext" +] +possibly_useful_glx_functions = [ + "glXGetProcAddressARB", + "glXJoinSwapGroupNV", + "glXBindSwapBarrierNV", + "glXQuerySwapGroupNV", + "glXQueryMaxSwapGroupsNV", + "glXQueryFrameCountNV", + "glXResetFrameCountNV", + "glXChooseFBConfig", + "glXGetFBConfigs", + "glXGetFBConfigAttrib", + "glXGetVisualFromFBConfig", + "glXCreateNewContext", + "glXCreatePbuffer", + "glXDestroyPbuffer", + "glXQueryContext", + "glXQueryDrawable", + "glXMakeContextCurrent", + "glXCreateWindow", + "glXGetVisualFromFBConfig", +] + +print('#ifdef WINDOWS') + +for fun in useful_wgl_functions: + print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun,fun,fun)) + +print('#elif defined(DARWIN)') +print('# ifndef VBOX_WITH_COCOA_QT') +for fun in useful_agl_functions: + print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(aglDll, "%s");' % (fun,fun,fun)) +print('# endif') + +for fun in useful_cgl_functions: + print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(cglDll, "%s");' % (fun, fun,fun)) + +for fun in in_gl_functions: + print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun,fun)) + +print('#else') +print('\t/* GLX */') + +# XXX merge these loops? +for fun in useful_glx_functions: + print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun, fun)) +for fun in possibly_useful_glx_functions: + print('\tinterface->%s = (%sFunc_t) crDLLGetNoError(glDll, "%s");' % (fun, fun, fun)) +print('#endif') + +print(""" + if (!entry) + return 1; /* token value */ + + for (i = 0; coreFunctions[i]; i++) { + const char *name = coreFunctions[i]; + if (fillin(entry, name + 2, crDLLGetNoError(glDll, name))) + entry++; + else + crDebug("glLoader: NULL function %s", name); + } + + /* end of table markers */ + entry->name = NULL; + entry->fn = NULL; + return entry - table; /* number of entries filled */ +} + + +/* + * Fill in table[] with all the OpenGL extension functions that we're + * interested in. + */ +int +crLoadOpenGLExtensions( const crOpenGLInterface *interface, SPUNamedFunctionTable table[] ) +{ + struct extfunc { + const char *funcName;""") +max_aliases = apiutil.ReverseAliasesMaxCount() +for i in range(1, 1 + max_aliases): + print("\t\tconst char *aliasName%d;" % i) +print(""" SPUGenericFunction nopFunction; + }; + static const struct extfunc functions[] = { +""") + +for func_name in keys: + if IsExtensionFunc(func_name): + if apiutil.Category(func_name) == "Chromium": + prefix = "cr" + else: + prefix = "gl" + s = '\t\t{ "' + prefix + func_name + '"' + aliases = apiutil.ReverseAliases(func_name) + s += ''.join([', "' + prefix + a + '"' for a in aliases]) + ', NULL' * (max_aliases - len(aliases)) + s += ', (SPUGenericFunction) Nop' + func_name + ' },' + print(s) + +print('\t\t{ NULL%s, NULL}' % (', NULL' * max_aliases)) +print(""" + }; + const struct extfunc *func; + SPUNamedFunctionTable *entry = table; + +#ifdef WINDOWS + if (interface->wglGetProcAddress == NULL) + crWarning("Unable to find wglGetProcAddress() in system GL library"); +#elif !defined(DARWIN) + if (interface->glXGetProcAddressARB == NULL) + crWarning("Unable to find glXGetProcAddressARB() in system GL library"); +#endif + + for (func = functions; func->funcName; func++) { + SPUGenericFunction f = findExtFunction(interface, func->funcName);""") +for i in range(1, 1 + max_aliases): + print(""" if (!f && func->aliasName%d) { + f = findExtFunction(interface, func->aliasName%d); + }"""% (i, i)) +print(""" if (!f) { + f = func->nopFunction; + } + (void) fillin(entry, func->funcName + 2 , f); /* +2 to skip "gl" */ + entry++; + } + + /* end of list */ + entry->name = NULL; + entry->fn = NULL; + return entry - table; /* number of entries filled */ +} +""") + + +print(""" + +#ifdef USE_OSMESA +int crLoadOSMesa( OSMesaContext (**createContext)( GLenum format, OSMesaContext sharelist ), + GLboolean (**makeCurrent)( OSMesaContext ctx, GLubyte *buffer, + GLenum type, GLsizei width, GLsizei height ), + void (**destroyContext)( OSMesaContext ctx )) +{ + static CRDLL *osMesaDll = NULL; + + const char *env_syspath = crGetenv( "CR_SYSTEM_GL_PATH" ); + + crDebug( "Looking for the system's OSMesa library..." ); + osMesaDll = __findSystemLib( env_syspath, "libOSMesa.so" ); + if (!osMesaDll) + { + crError("Unable to find system OSMesa!"); + return 0; + } + + crDebug( "Found it in %s.", !env_syspath ? "default path" : env_syspath ); + + *createContext = (OSMesaContext (*) ( GLenum format, OSMesaContext sharelist )) + crDLLGetNoError(osMesaDll, "OSMesaCreateContext"); + + *makeCurrent = (GLboolean (*) ( OSMesaContext ctx, GLubyte *buffer, + GLenum type, GLsizei width, GLsizei height )) + crDLLGetNoError(osMesaDll, "OSMesaMakeCurrent"); + + *destroyContext = (void (*) ( OSMesaContext ctx)) + crDLLGetNoError(osMesaDll, "OSMesaDestroyContext"); + + return 1; +} +#endif + +""") + diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/loader.def b/src/VBox/GuestHost/OpenGL/spu_loader/loader.def new file mode 100644 index 00000000..42065235 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/loader.def @@ -0,0 +1,21 @@ +; Copyright (c) 2001, Stanford University +; All rights reserved. +; +; See the file LICENSE.txt for information on redistributing this software. +EXPORTS +crSPULoad +crSPULoadChain +crSPUUnloadChain +crSPUCopyDispatchTable +crSPUFindFunction +crSPUChangeInterface +crSPUInitDispatchTable +crSPUInitDispatchNops +crSPUInitDispatch +crSPUSetDefaultParams +crSPUGetEnumIndex +crLoadOpenGLExtensions +crLoadOpenGL +crUnloadOpenGL +crChooseVisual +crSPUChangeDispatch diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py b/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py new file mode 100755 index 00000000..7562348e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py @@ -0,0 +1,73 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys +import apiutil + + +apiutil.CopyrightC() + +print(""" + +/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spuchange.py SCRIPT */ + +#include "cr_spu.h" +#include "cr_error.h" + +void crSPUChangeInterface(SPUDispatchTable *table, void *orig_func, void *new_func) +{ + struct _copy_list_node *temp; + if (table->mark == 1) + { + return; + } + if (orig_func == new_func) + { + return; + } + table->mark = 1; +""") + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") +for func_name in keys: + print('\tif ((uintptr_t)table->%s == (uintptr_t)orig_func)' % func_name) + print('\t{') + print('\t\ttable->%s = (%sFunc_t)(uintptr_t)new_func;' % (func_name, func_name)) + print('\t\tfor (temp = table->copyList ; temp ; temp = temp->next)') + print('\t\t{') + print('\t\t\tcrSPUChangeInterface(temp->copy, orig_func, new_func);') + print('\t\t}') + print('\t}') + +print(""" + if (table->copy_of != NULL) + { + crSPUChangeInterface(table->copy_of, orig_func, new_func); + } + for (temp = table->copyList; temp; temp = temp->next) + { + crSPUChangeInterface(temp->copy, orig_func, new_func); + } + table->mark = 0; +""") +print('}') + +print(""" +void crSPUChangeDispatch(SPUDispatchTable *dispatch, const SPUNamedFunctionTable *newtable) +{ + SPUGenericFunction func; +""") +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") +for func_name in keys: + print('\tfunc = crSPUFindFunction(newtable, "%s");' % func_name) + print('\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name) + print('\t{') + print('\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % (func_name, func_name)) + print('\t\tcrSPUChangeInterface(dispatch, (void *)(uintptr_t)dispatch->%s, (void *)(uintptr_t)func);' % func_name) + print('\t}\n') +print(""" +} +""") diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py b/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py new file mode 100755 index 00000000..bf1990a1 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/spucopy.py @@ -0,0 +1,80 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys +import apiutil + + +apiutil.CopyrightC() + +print(""" + +/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spucopy.py SCRIPT */ + +#include "cr_spu.h" +#include "cr_mem.h" + +void crSPUCopyDispatchTable( SPUDispatchTable *dst, SPUDispatchTable *src ) +{ +""") + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") +for func_name in keys: + print('\tdst->%s = src->%s;' % (func_name, func_name)) + +# if the destination is already a copy of something, we'd better make sure +# that we take it off its source's copy list first. + +print(""" + if (dst->copy_of != NULL) + { + /* + * dst was already a copy, go back to the original, + * and remove dst from the original's copyList. + */ + struct _copy_list_node *temp, *prior = NULL; + for (temp = dst->copy_of->copyList; temp; prior = temp, temp = temp->next) + { + if (temp->copy == dst) + { + if (prior) + { + prior->next = temp->next; + } + else + { + dst->copy_of->copyList = temp->next; + } + crFree( temp ); + break; + } + } + } + /* + * Now that dst->copy_of is unused, set it to point to our + * new original. + */ + if (src->copy_of) + { + dst->copy_of = src->copy_of; + } + else + { + dst->copy_of = src; + } + /* + * Create a new copy node, so the src can keep track of the + * new copy (i.e. dst). + */ + { + struct _copy_list_node *copynode; + copynode = (struct _copy_list_node*)crAlloc( sizeof( *copynode ) ); + copynode->copy = dst; + copynode->next = src->copyList; + src->copyList = copynode; + } +} +""") diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c b/src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c new file mode 100644 index 00000000..5591df9b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/spuinit.c @@ -0,0 +1,225 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_spu.h" +#include "cr_error.h" +#include "cr_string.h" +#include + +/** + * \mainpage spu_loader + * + * \section Spu_loaderIntroduction Introduction + * + * Chromium consists of all the top-level files in the cr + * directory. The spu_loader module basically takes care of API dispatch, + * and OpenGL state management. + * + */ +void crSPUInitDispatchTable( SPUDispatchTable *table ) +{ + table->copyList = NULL; + table->copy_of = NULL; + table->mark = 0; + table->server = NULL; +} + +#if 0 /* unused */ + +static int validate_int( const char *response, + const char *min, + const char *max ) +{ + int i, imin, imax; + if (sscanf(response, "%d", &i) != 1) + return 0; + if (min && sscanf(min, "%d", &imin) == 1 && imin > i) + return 0; + if (max && sscanf(max, "%d", &imax) == 1 && imax < i) + return 0; + return 1; +} + +static int validate_float( const char *response, + const char *min, + const char *max ) +{ + float f, fmin, fmax; + if (sscanf(response, "%f", &f) != 1) + return 0; + if (min && sscanf(min, "%f", &fmin) == 1 && fmin > f) + return 0; + if (max && sscanf(max, "%f", &fmax) == 1 && fmax < f) + return 0; + return 1; +} + +static int validate_one_option( const SPUOptions *opt, + const char *response, + const char *min, + const char *max ) +{ + switch (opt->type) { + case CR_BOOL: + return validate_int( response, "0", "1" ); + case CR_INT: + return validate_int( response, min, max ); + case CR_FLOAT: + return validate_float( response, min, max ); + case CR_ENUM: + /* Make sure response string is present in the min string. + * For enums, the min string is a comma-separated list of valid values. + */ + CRASSERT(opt->numValues == 1); /* an enum limitation for now */ + { + const char *p = crStrstr(min, response); + if (!p) + return 0; /* invalid value! */ + if (p[-1] != '\'') + return 0; /* right substring */ + if (p[crStrlen(response)] != '\'') + return 0; /* left substring */ + return 1; + } + default: + return 0; + } +} + + +/** + * Make sure the response matches the opt's parameters (right number + * and type of values, etc.) + * Return 1 if OK, 0 if error. + */ +static int validate_option( const SPUOptions *opt, const char *response ) +{ + const char *min = opt->min; + const char *max = opt->max; + int i = 0; + int retval; + + if (opt->type == CR_STRING) + return 1; + + CRASSERT(opt->numValues > 0); + + /* skip leading [ for multi-value options */ + if (opt->numValues > 1) { + /* multi-valued options must be enclosed in brackets */ + if (*response != '[') + return 0; + response++; /* skip [ */ + /* make sure min and max are bracketed as well */ + if (min) { + CRASSERT(*min == '['); /* error in spu_config.c code!!! */ + min++; + } + if (max) { + CRASSERT(*max == '['); /* error in spu_config.c code!!! */ + max++; + } + } + + for (;;) + { + if (!validate_one_option( opt, response, min, max )) + { + retval = 0; + break; + } + if (++i == opt->numValues) + { + retval = 1; /* all done! */ + break; + } + /* advance pointers to next item */ + if (min) + { + while (*min != ' ' && *min) + min++; + while (*min == ' ') + min++; + } + if (max) + { + while (*max != ' ' && *max) + max++; + while (*max == ' ') + max++; + } + if (response) + { + while (*response != ' ' && *response) + response++; + while (*response == ' ') + response++; + } + } + + return retval; +} + +#endif /* unused */ + +/** Use the default values for all the options: + */ +void crSPUSetDefaultParams( void *spu, SPUOptions *options ) +{ + int i; + + for (i = 0 ; options[i].option ; i++) + { + SPUOptions *opt = &options[i]; + opt->cb( spu, opt->deflt ); + } +} + + +/** + * Find the index of the given enum value in the SPUOption's list of + * possible enum values. + * Return the enum index, or -1 if not found. + */ +int crSPUGetEnumIndex( const SPUOptions *options, const char *optName, const char *value ) +{ + const SPUOptions *opt; + const int valueLen = crStrlen(value); + + /* first, find the right option */ + for (opt = options; opt->option; opt++) { + if (crStrcmp(opt->option, optName) == 0) { + char **values; + int i; + + CRASSERT(opt->type == CR_ENUM); + + /* break into array of strings */ + /* min string should be of form "'enum1', 'enum2', 'enum3', etc" */ + values = crStrSplit(opt->min, ","); + + /* search the array */ + for (i = 0; values[i]; i++) { + /* find leading quote */ + const char *e = crStrchr(values[i], '\''); + CRASSERT(e); + if (e) { + /* test for match */ + if (crStrncmp(value, e + 1, valueLen) == 0 && e[valueLen + 1] == '\'') { + crFreeStrings(values); + return i; + } + } + } + + /* enum value not found! */ + crFreeStrings(values); + return -1; + } + } + + return -1; +} diff --git a/src/VBox/GuestHost/OpenGL/spu_loader/spuload.c b/src/VBox/GuestHost/OpenGL/spu_loader/spuload.c new file mode 100644 index 00000000..8930ef9a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/spu_loader/spuload.c @@ -0,0 +1,290 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "cr_environment.h" +#include "cr_string.h" +#include "cr_dll.h" +#include "cr_error.h" +#include "cr_spu.h" + + +#include +#include +#include + +#include + +#ifdef WINDOWS +#ifdef VBOX_WDDM_WOW64 +#define DLL_SUFFIX "-x86.dll" +#else +#define DLL_SUFFIX ".dll" +#endif +#define DLL_PREFIX "VBoxOGL" +#define snprintf _snprintf +#elif defined(DARWIN) +#define DLL_SUFFIX ".dylib" +#define DLL_PREFIX "VBoxOGL" +/* +#define DLL_SUFFIX ".bundle" +#define DLL_PREFIX "" +*/ +#else +#ifdef AIX +#define DLL_SUFFIX ".o" +#define DLL_PREFIX "VBoxOGL" +#else +#define DLL_SUFFIX ".so" +#define DLL_PREFIX "VBoxOGL" +#endif +#endif + +extern void __buildDispatch( SPU *spu ); + +static char *__findDLL( char *name, char *dir ) +{ + static char path[8092]; + + if (!dir) + { +#if defined(DARWIN) + char szSharedLibPath[8092]; + int rc = RTPathAppPrivateArch (szSharedLibPath, sizeof(szSharedLibPath)); + if (RT_SUCCESS(rc)) + sprintf ( path, "%s/%s%sspu%s", szSharedLibPath, DLL_PREFIX, name, DLL_SUFFIX ); + else +#endif /* DARWIN */ +#ifdef VBOX + snprintf ( path, sizeof(path), "%s%sspu%s", DLL_PREFIX, name, DLL_SUFFIX ); +#else + sprintf ( path, "%s%sspu%s", DLL_PREFIX, name, DLL_SUFFIX ); +#endif + } + else + { +#ifdef VBOX + snprintf ( path, sizeof(path), "%s/%s%sspu%s", dir, DLL_PREFIX, name, DLL_SUFFIX ); +#else + sprintf ( path, "%s/%s%sspu%s", dir, DLL_PREFIX, name, DLL_SUFFIX ); +#endif + } + return path; +} + +/** + * Load a single SPU from disk and initialize it. Is there any reason + * to export this from the SPU loader library? */ + +SPU * crSPULoad( SPU *child, int id, char *name, char *dir, void *server ) +{ + SPU *the_spu; + char *path; + bool fNeedSuperSPU = false; + + CRASSERT( name != NULL ); + + the_spu = (SPU*)crAlloc( sizeof( *the_spu ) ); + /* ensure all fields are initially zero, + * NOTE: what actually MUST be zero at this point is the_spu->superSPU, otherwise + * crSPUUnloadChain in the failure branches below will misbehave */ + crMemset(the_spu, 0, sizeof (*the_spu)); + the_spu->id = id; + the_spu->privatePtr = NULL; + path = __findDLL( name, dir ); + the_spu->dll = crDLLOpen( path, 0/*resolveGlobal*/ ); + if (the_spu->dll == NULL) + { + crError("Couldn't load the DLL \"%s\"!\n", path); + crFree(the_spu); + return NULL; + } +#if defined(DEBUG_misha) && defined(RT_OS_WINDOWS) + crDbgCmdSymLoadPrint(path, the_spu->dll->hinstLib); +#endif + the_spu->entry_point = + (SPULoadFunction) crDLLGetNoError( the_spu->dll, SPU_ENTRY_POINT_NAME ); + if (!the_spu->entry_point) + { + crError( "Couldn't load the SPU entry point \"%s\" from SPU \"%s\"!", + SPU_ENTRY_POINT_NAME, name ); + crSPUUnloadChain(the_spu); + return NULL; + } + + /* This basically calls the SPU's SPULoad() function */ + if (!the_spu->entry_point( &(the_spu->name), &(the_spu->super_name), + &(the_spu->init), &(the_spu->self), + &(the_spu->cleanup), + &(the_spu->options), + &(the_spu->spu_flags)) ) + { + crError( "I found the SPU \"%s\", but loading it failed!", name ); + crSPUUnloadChain(the_spu); + return NULL; + } +#ifdef IN_GUEST + if (crStrcmp(the_spu->name,"error")) + { + /* the default super/base class for an SPU is the error SPU */ + if (the_spu->super_name == NULL) + { + the_spu->super_name = "error"; + } + the_spu->superSPU = crSPULoad( child, id, the_spu->super_name, dir, server ); + fNeedSuperSPU = true; + } +#else + if (crStrcmp(the_spu->name,"hosterror")) + { + /* the default super/base class for an SPU is the error SPU */ + if (the_spu->super_name == NULL) + { + the_spu->super_name = "hosterror"; + } + the_spu->superSPU = crSPULoad( child, id, the_spu->super_name, dir, server ); + fNeedSuperSPU = true; + } +#endif + else + { + the_spu->superSPU = NULL; + } + if (fNeedSuperSPU && !the_spu->superSPU) + { + crError( "Unable to load super SPU \"%s\" of \"%s\"!", the_spu->super_name, name ); + crSPUUnloadChain(the_spu); + return NULL; + } + crDebug("Initializing %s SPU", name); + the_spu->function_table = the_spu->init( id, child, the_spu, 0, 1 ); + if (!the_spu->function_table) { + crDebug("Failed to init %s SPU", name); + crSPUUnloadChain(the_spu); + return NULL; + } + __buildDispatch( the_spu ); + /*crDebug( "initializing dispatch table %p (for SPU %s)", (void*)&(the_spu->dispatch_table), name );*/ + crSPUInitDispatchTable( &(the_spu->dispatch_table) ); + /*crDebug( "Done initializing the dispatch table for SPU %s, calling the self function", name );*/ + + the_spu->dispatch_table.server = server; + the_spu->self( &(the_spu->dispatch_table) ); + /*crDebug( "Done with the self function" );*/ + + return the_spu; +} + +/** + * Load the entire chain of SPUs and initialize all of them. + * This function returns the first one in the chain. + */ +SPU * +crSPULoadChain( int count, int *ids, char **names, char *dir, void *server ) +{ + int i; + SPU *child_spu = NULL; + CRASSERT( count > 0 ); + + for (i = count-1 ; i >= 0 ; i--) + { + int spu_id = ids[i]; + char *spu_name = names[i]; + SPU *the_spu, *temp; + + /* This call passes the previous version of spu, which is the SPU's + * "child" in this chain. */ + + the_spu = crSPULoad( child_spu, spu_id, spu_name, dir, server ); + if (!the_spu) { + return NULL; + } + + if (child_spu != NULL) + { + /* keep track of this so that people can pass functions through but + * still get updated when API's change on the fly. */ + for (temp = the_spu ; temp ; temp = temp->superSPU ) + { + struct _copy_list_node *node = (struct _copy_list_node *) crAlloc( sizeof( *node ) ); + node->copy = &(temp->dispatch_table); + node->next = child_spu->dispatch_table.copyList; + child_spu->dispatch_table.copyList = node; + } + } + child_spu = the_spu; + } + return child_spu; +} + + +#if 00 +/* XXXX experimental code - not used at this time */ +/** + * Like crSPUChangeInterface(), but don't loop over all functions in + * the table to search for 'old_func'. + */ +void +crSPUChangeFunction(SPUDispatchTable *table, unsigned int funcOffset, + void *newFunc) +{ + SPUGenericFunction *f = (SPUGenericFunction *) table + funcOffset; + struct _copy_list_node *temp; + + CRASSERT(funcOffset < sizeof(*table) / sizeof(SPUGenericFunction)); + + printf("%s\n", __FUNCTION__); + if (table->mark == 1) + return; + table->mark = 1; + *f = newFunc; + + /* update all copies of this table */ +#if 1 + for (temp = table->copyList ; temp ; temp = temp->next) + { + crSPUChangeFunction( temp->copy, funcOffset, newFunc ); + } +#endif + if (table->copy_of != NULL) + { + crSPUChangeFunction( table->copy_of, funcOffset, newFunc ); + } +#if 0 + for (temp = table->copyList ; temp ; temp = temp->next) + { + crSPUChangeFunction( temp->copy, funcOffset, newFunc ); + } +#endif + table->mark = 0; +} +#endif + + + +/** + * Call the cleanup() function for each SPU in a chain, close the SPU + * DLLs and free the SPU objects. + * \param headSPU pointer to the first SPU in the chain + */ +void +crSPUUnloadChain(SPU *headSPU) +{ + SPU *the_spu = headSPU, *next_spu; + + while (the_spu) + { + crDebug("Cleaning up SPU %s", the_spu->name); + + if (the_spu->cleanup) + the_spu->cleanup(); + + next_spu = the_spu->superSPU; + crDLLClose(the_spu->dll); + crFree(the_spu); + the_spu = next_spu; + } +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/Makefile.kup b/src/VBox/GuestHost/OpenGL/state_tracker/Makefile.kup new file mode 100644 index 00000000..e69de29b diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/convert.py b/src/VBox/GuestHost/OpenGL/state_tracker/convert.py new file mode 100755 index 00000000..1adbf4e6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/convert.py @@ -0,0 +1,75 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys + +# Two different paths to the packer and opengl_stub directories since this +# script will be called from both cr/state_tracker/ and cr/spu/tilesort/. +sys.path.append( '../packer' ) +sys.path.append( '../../packer' ) +sys.path.append( '../glapi_parser' ) +sys.path.append( '../../glapi_parser' ) +from pack_currenttypes import * +import apiutil + +apiutil.CopyrightC() + +print(''' +#include "state/cr_statetypes.h" + +static double __read_double( const void *src ) +{ + const unsigned int *ui = (const unsigned int *) src; + double d; + ((unsigned int *) &d)[0] = ui[0]; + ((unsigned int *) &d)[1] = ui[1]; + return d; +} +''') + +for k in sorted(gltypes.keys()): + for i in range(1,5): + print('static void __convert_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k]['type'])) + if k == 'd': + for j in range(i-1): + print('\t*dst++ = (GLfloat) __read_double(src++);') + print('\t*dst = (GLfloat) __read_double(src);') + else: + for j in range(i-1): + print('\t*dst++ = (GLfloat) *src++;') + print('\t*dst = (GLfloat) *src;') + print('}\n') + +scale = { + 'ub' : 'CR_MAXUBYTE', + 'b' : 'CR_MAXBYTE', + 'us' : 'CR_MAXUSHORT', + 's' : 'CR_MAXSHORT', + 'ui' : 'CR_MAXUINT', + 'i' : 'CR_MAXINT', + 'f' : '', + 'd' : '' +} + +for k in sorted(gltypes.keys()): + if k != 'f' and k != 'd' and k != 'l': + if k[0:1] == "N": + k2 = k[1:] + else: + k2 = k + for i in range(1,5): + print('static void __convert_rescale_%s%d (GLfloat *dst, const %s *src) {' % (k,i,gltypes[k2]['type'])) + for j in range(i-1): + print('\t*dst++ = ((GLfloat) *src++) / %s;' % scale[k2]) + print('\t*dst = ((GLfloat) *src) / %s;' % scale[k2]) + print('}\n') + +print(''' + +static void __convert_boolean (GLboolean *dst, const GLboolean *src) { + *dst = *src; +} +''') diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp b/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp new file mode 100644 index 00000000..42a41df1 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp @@ -0,0 +1,1741 @@ +/* $Id: dump.cpp $ */ + +/** @file + * Blitter API implementation + */ +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ +#include "cr_blitter.h" +#include "cr_spu.h" +#include "chromium.h" +#include "cr_error.h" +#include "cr_net.h" +#include "cr_rand.h" +#include "cr_mem.h" +#include "cr_string.h" +#include +#include "cr_pixeldata.h" + +#include +#include +#include + +#include + +#ifdef VBOX_WITH_CRDUMPER + +static uint32_t g_CrDbgDumpRecTexInfo = 1; +static uint32_t g_CrDbgDumpAlphaData = 1; + +/* dump stuff */ +#pragma pack(1) +typedef struct VBOX_BITMAPFILEHEADER { + uint16_t bfType; + uint32_t bfSize; + uint16_t bfReserved1; + uint16_t bfReserved2; + uint32_t bfOffBits; +} VBOX_BITMAPFILEHEADER; + +typedef struct VBOX_BITMAPINFOHEADER { + uint32_t biSize; + int32_t biWidth; + int32_t biHeight; + uint16_t biPlanes; + uint16_t biBitCount; + uint32_t biCompression; + uint32_t biSizeImage; + int32_t biXPelsPerMeter; + int32_t biYPelsPerMeter; + uint32_t biClrUsed; + uint32_t biClrImportant; +} VBOX_BITMAPINFOHEADER; +#pragma pack() + +void crDmpImgBmp(CR_BLITTER_IMG *pImg, const char *pszFilename) +{ + static int sIdx = 0; + + if ( pImg->bpp != 16 + && pImg->bpp != 24 + && pImg->bpp != 32) + { + crWarning("not supported bpp %d", pImg->bpp); + return; + } + + FILE *f = fopen (pszFilename, "wb"); + if (!f) + { + crWarning("fopen failed"); + return; + } + + VBOX_BITMAPFILEHEADER bf; + + bf.bfType = 'MB'; + bf.bfSize = sizeof (VBOX_BITMAPFILEHEADER) + sizeof (VBOX_BITMAPINFOHEADER) + pImg->cbData; + bf.bfReserved1 = 0; + bf.bfReserved2 = 0; + bf.bfOffBits = sizeof (VBOX_BITMAPFILEHEADER) + sizeof (VBOX_BITMAPINFOHEADER); + + VBOX_BITMAPINFOHEADER bi; + + bi.biSize = sizeof (bi); + bi.biWidth = pImg->width; + bi.biHeight = pImg->height; + bi.biPlanes = 1; + bi.biBitCount = pImg->bpp; + bi.biCompression = 0; + bi.biSizeImage = pImg->cbData; + bi.biXPelsPerMeter = 0; + bi.biYPelsPerMeter = 0; + bi.biClrUsed = 0; + bi.biClrImportant = 0; + + fwrite (&bf, 1, sizeof (bf), f); + fwrite (&bi, 1, sizeof (bi), f); + fwrite (pImg->pvData, 1, pImg->cbData, f); + + fclose (f); +} + +typedef struct CRDUMPGETHWID_DATA +{ + GLuint hwid; + PFNCRDUMPGETHWID pfnGetHwid; + unsigned long Key; + void* pvObj; +} CRDUMPGETHWID_DATA; + +static void crDmpHashtableSearchByHwidCB(unsigned long key, void *pData1, void *pData2) +{ + CRDUMPGETHWID_DATA *pData = (CRDUMPGETHWID_DATA*)pData2; + if (pData->pvObj) + return; + + if (pData->hwid == pData->pfnGetHwid(pData1)) + { + pData->Key = key; + pData->pvObj = pData1; + } +} + +void* crDmpHashtableSearchByHwid(CRHashTable *pHash, GLuint hwid, PFNCRDUMPGETHWID pfnGetHwid, unsigned long *pKey) +{ + CRDUMPGETHWID_DATA Data = {0}; + Data.hwid = hwid; + Data.pfnGetHwid = pfnGetHwid; + crHashtableWalk(pHash, crDmpHashtableSearchByHwidCB, &Data); + + Assert(Data.pvObj); + + if (pKey) + *pKey = Data.Key; + return Data.pvObj; +} + +#if 0 +typedef struct CR_SERVER_DUMP_FIND_TEX +{ + GLint hwid; + CRTextureObj *pTobj +} CR_SERVER_DUMP_FIND_TEX; + +void crServerDumpFindTexCb(unsigned long key, void *pData1, void *pData2) +{ + CR_SERVER_DUMP_FIND_TEX *pTex = (CR_SERVER_DUMP_FIND_TEX*)pData2; + CRTextureObj *pTobj = (CRTextureObj *)pData1; + if (pTobj->hwid == pTex->hwid) + pTex->pTobj = pTobj; +} +#endif + +#define CR_DUMP_MAKE_CASE(_val) case _val: return #_val +#define CR_DUMP_MAKE_CASE_UNKNOWN(_val, _str, _pDumper) default: { \ + crWarning("%s %d", (_str), _val); \ + crDmpStrF((_pDumper), "WARNING: %s %d", (_str), _val); \ + return (_str); \ +} + +DECLINLINE(size_t) crDmpFormatVal(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbVal, const void *pvVal) +{ + if (pszElFormat[0] != '%' || pszElFormat[1] == '\0') + { + crWarning("invalid format %s", pszElFormat); + return 0; + } + switch (cbVal) + { + case 8: + return sprintf_s(pString, cbString, pszElFormat, *((double*)pvVal)); + case 4: + { + /* we do not care only about type specifiers, all the rest is not accepted */ + switch (pszElFormat[1]) + { + case 'f': + /* float would be promoted to double */ + return sprintf_s(pString, cbString, pszElFormat, *((float*)pvVal)); + default: + return sprintf_s(pString, cbString, pszElFormat, *((uint32_t*)pvVal)); + } + } + case 2: + return sprintf_s(pString, cbString, pszElFormat, *((uint16_t*)pvVal)); + case 1: + return sprintf_s(pString, cbString, pszElFormat, *((uint8_t*)pvVal)); + default: + crWarning("unsupported size %d", cbVal); + return 0; + } +} + +VBOXDUMPDECL(size_t) crDmpFormatRawArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal) +{ + if (cbString < 2) + { + crWarning("too few buffer size"); + return 0; + } + + const size_t cbInitString = cbString; + *pString++ = '{'; + --cbString; + size_t cbWritten; + const uint8_t *pu8Val = (const uint8_t *)pvVal; + for (uint32_t i = 0; i < cVal; ++i) + { + cbWritten = crDmpFormatVal(pString, cbString, pszElFormat, cbEl, (const void *)pu8Val); + pu8Val += cbEl; + Assert(cbString >= cbWritten); + pString += cbWritten; + cbString -= cbWritten; + if (i != cVal - 1) + { + cbWritten = sprintf_s(pString, cbString, ", "); + Assert(cbString >= cbWritten); + pString += cbWritten; + cbString -= cbWritten; + } + } + + if (!cbString) + { + crWarning("too few buffer size"); + return 0; + } + *pString++ = '}'; + --cbString; + + if (!cbString) + { + crWarning("too few buffer size"); + return 0; + } + *pString++ = '\0'; + + return cbInitString - cbString; +} + +VBOXDUMPDECL(size_t) crDmpFormatMatrixArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cX, uint32_t cY) +{ + if (cbString < 2) + { + crWarning("too few buffer size"); + return 0; + } + + const size_t cbInitString = cbString; + *pString++ = '{'; + --cbString; + size_t cbWritten; + const uint8_t *pu8Val = (const uint8_t *)pvVal; + for (uint32_t i = 0; i < cY; ++i) + { + cbWritten = crDmpFormatRawArray(pString, cbString, pszElFormat, cbEl, (const void *)pu8Val, cX); + pu8Val += (cbEl * cX); + Assert(cbString >= cbWritten); + pString += cbWritten; + cbString -= cbWritten; + if (i != cY - 1) + { + if (cbString < 3) + { + crWarning("too few buffer size"); + return 0; + } + *pString++ = ','; + --cbString; + *pString++ = '\n'; + --cbString; + } + } + if (!cbString) + { + crWarning("too few buffer size"); + return 0; + } + *pString++ = '}'; + --cbString; + + if (!cbString) + { + crWarning("too few buffer size"); + return 0; + } + *pString++ = '\0'; + + return cbInitString - cbString; +} + +VBOXDUMPDECL(size_t) crDmpFormatArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal) +{ + switch(cVal) + { + case 1: + return crDmpFormatVal(pString, cbString, pszElFormat, cbEl, pvVal); + case 16: + return crDmpFormatMatrixArray(pString, cbString, pszElFormat, cbEl, pvVal, 4, 4); + case 9: + return crDmpFormatMatrixArray(pString, cbString, pszElFormat, cbEl, pvVal, 3, 3); + case 0: + crWarning("value array is empty"); + return 0; + default: + return crDmpFormatRawArray(pString, cbString, pszElFormat, cbEl, pvVal, cVal); + } +} + +VBOXDUMPDECL(void) crRecDumpVertAttrv(CR_RECORDER *pRec, CRContext *ctx, GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal) +{ + char aBuf[1024]; + crDmpFormatRawArray(aBuf, sizeof (aBuf), pszElFormat, cbEl, pvVal, cVal); + crDmpStrF(pRec->pDumper, "(%u, %s)", idx, aBuf); +} + +VBOXDUMPDECL(void) crRecDumpVertAttrV(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, va_list pArgList) +{ + crDmpStrV(pRec->pDumper, pszFormat, pArgList); +} + +VBOXDUMPDECL(void) crRecDumpVertAttrF(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, ...) +{ + va_list pArgList; + va_start(pArgList, pszFormat); + crRecDumpVertAttrV(pRec, ctx, pszFormat, pArgList); + va_end(pArgList); +} + +void crRecDumpBuffer(CR_RECORDER *pRec, CRContext *ctx, GLint idRedirFBO, VBOXVR_TEXTURE *pRedirTex) +{ + GLenum texTarget = 0; + GLint hwBuf = 0, hwDrawBuf = 0; + GLint hwTex = 0, hwObjType = 0, hwTexLevel = 0, hwCubeFace = 0; + GLint width = 0, height = 0, depth = 0; + GLint id = 0; + CR_BLITTER_IMG Img = {0}; + VBOXVR_TEXTURE Tex; + int rc; + + pRec->pDispatch->GetIntegerv(GL_DRAW_BUFFER, &hwDrawBuf); + pRec->pDispatch->GetIntegerv(GL_FRAMEBUFFER_BINDING, &hwBuf); + if (hwBuf) + { + pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME, &hwTex); + pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &hwObjType); + if (hwObjType == GL_TEXTURE) + { + pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL, &hwTexLevel); + pRec->pDispatch->GetFramebufferAttachmentParameterivEXT(GL_DRAW_FRAMEBUFFER, hwDrawBuf, GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE, &hwCubeFace); + if (hwCubeFace) + { + crWarning("cube face: unsupported"); + return; + } + + if (hwTexLevel) + { + crWarning("non-zero tex level attached, unsupported"); + return; + } + } + else + { + crWarning("unsupported"); + return; + } + } + else + { + crWarning("no buffer attached: unsupported"); + return; + } + + if (ctx->framebufferobject.drawFB) + { + GLuint iColor = (hwDrawBuf - GL_COLOR_ATTACHMENT0_EXT); + CRTextureObj *pTobj = (CRTextureObj *)crHashtableSearch(ctx->shared->textureTable, ctx->framebufferobject.drawFB->color[iColor].name); + CRTextureLevel *pTl = NULL; + + id = pTobj->id; + + Assert(iColor < RT_ELEMENTS(ctx->framebufferobject.drawFB->color)); + + if (!pTobj) + { + crWarning("no tobj"); + return; + } + Assert(pTobj->hwid == hwTex); + Assert(pTobj); + Assert(ctx->framebufferobject.drawFB->hwid); + Assert(ctx->framebufferobject.drawFB->hwid == hwBuf); + Assert(ctx->framebufferobject.drawFB->drawbuffer[0] == hwDrawBuf); + + Assert(ctx->framebufferobject.drawFB->color[iColor].level == hwTexLevel); + Assert(ctx->framebufferobject.drawFB->color[iColor].type == hwObjType); + + texTarget = pTobj->target; + + Assert(texTarget == GL_TEXTURE_2D); + + pTl = &pTobj->level[0][hwTexLevel]; + + rc = CrBltEnter(pRec->pBlitter); + if (!RT_SUCCESS(rc)) + { + crWarning("CrBltEnter failed, rc %d", rc); + return; + } + + pRec->pDispatch->BindTexture(texTarget, hwTex); + + pRec->pDispatch->GetTexLevelParameteriv(texTarget, hwTexLevel, GL_TEXTURE_WIDTH, &width); + pRec->pDispatch->GetTexLevelParameteriv(texTarget, hwTexLevel, GL_TEXTURE_HEIGHT, &height); + pRec->pDispatch->GetTexLevelParameteriv(texTarget, hwTexLevel, GL_TEXTURE_DEPTH, &depth); + + Assert(width == pTl->width); + Assert(height == pTl->height); + Assert(depth == pTl->depth); + + pRec->pDispatch->BindTexture(texTarget, 0); + } + else + { + Assert(hwBuf == idRedirFBO); + if (!pRedirTex) + { + crWarning("pRedirTex is expected for non-FBO state!"); + return; + } + + Assert(hwTex == pRedirTex->hwid); + + texTarget = pRedirTex->target; + + width = pRedirTex->width; + height = pRedirTex->height; + + rc = CrBltEnter(pRec->pBlitter); + if (!RT_SUCCESS(rc)) + { + crWarning("CrBltEnter failed, rc %d", rc); + return; + } + } + + Tex.width = width; + Tex.height = height; + Tex.target = texTarget; + Tex.hwid = hwTex; + + rc = CrBltImgGetTex(pRec->pBlitter, &Tex, GL_BGRA, &Img); + if (RT_SUCCESS(rc)) + { + crDmpImgF(pRec->pDumper, &Img, "ctx(%d), BUFFER: id(%d) hwid(%d), width(%d), height(%d)", ctx, id, Tex.hwid, width, height); + + if (g_CrDbgDumpAlphaData) + { + CR_BLITTER_IMG AlphaImg = {0}; + rc = crRecAlphaImgCreate(&Img, &AlphaImg); + if (RT_SUCCESS(rc)) + { + crDmpImgF(pRec->pDumper, &AlphaImg, "Buffer ALPHA Data"); + crRecAlphaImgDestroy(&AlphaImg); + } + else + { + crWarning("crRecAlphaImgCreate failed rc %d", rc); + } + } + + CrBltImgFree(pRec->pBlitter, &Img); + } + else + { + crWarning("CrBltImgGetTex failed, rc %d", rc); + } + + CrBltLeave(pRec->pBlitter); +} + +static const char *crRecDumpShaderTypeString(GLenum enmType, CR_DUMPER *pDumper) +{ + switch (enmType) + { + CR_DUMP_MAKE_CASE(GL_VERTEX_SHADER_ARB); + CR_DUMP_MAKE_CASE(GL_FRAGMENT_SHADER_ARB); + CR_DUMP_MAKE_CASE(GL_GEOMETRY_SHADER_ARB); + CR_DUMP_MAKE_CASE_UNKNOWN(enmType, "Unknown Shader Type", pDumper); + } +} + +static const char *crRecDumpVarTypeString(GLenum enmType, CR_DUMPER *pDumper) +{ + switch (enmType) + { + CR_DUMP_MAKE_CASE(GL_BYTE); + CR_DUMP_MAKE_CASE(GL_UNSIGNED_BYTE); + CR_DUMP_MAKE_CASE(GL_SHORT); + CR_DUMP_MAKE_CASE(GL_UNSIGNED_SHORT); + CR_DUMP_MAKE_CASE(GL_FLOAT); + CR_DUMP_MAKE_CASE(GL_DOUBLE); + CR_DUMP_MAKE_CASE(GL_FLOAT_VEC2); + CR_DUMP_MAKE_CASE(GL_FLOAT_VEC3); + CR_DUMP_MAKE_CASE(GL_FLOAT_VEC4); + CR_DUMP_MAKE_CASE(GL_INT); + CR_DUMP_MAKE_CASE(GL_UNSIGNED_INT); + CR_DUMP_MAKE_CASE(GL_INT_VEC2); + CR_DUMP_MAKE_CASE(GL_INT_VEC3); + CR_DUMP_MAKE_CASE(GL_INT_VEC4); + CR_DUMP_MAKE_CASE(GL_BOOL); + CR_DUMP_MAKE_CASE(GL_BOOL_VEC2); + CR_DUMP_MAKE_CASE(GL_BOOL_VEC3); + CR_DUMP_MAKE_CASE(GL_BOOL_VEC4); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT2); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT3); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT4); + CR_DUMP_MAKE_CASE(GL_SAMPLER_1D); + CR_DUMP_MAKE_CASE(GL_SAMPLER_2D); + CR_DUMP_MAKE_CASE(GL_SAMPLER_3D); + CR_DUMP_MAKE_CASE(GL_SAMPLER_CUBE); + CR_DUMP_MAKE_CASE(GL_SAMPLER_1D_SHADOW); + CR_DUMP_MAKE_CASE(GL_SAMPLER_2D_SHADOW); + CR_DUMP_MAKE_CASE(GL_SAMPLER_2D_RECT_ARB); + CR_DUMP_MAKE_CASE(GL_SAMPLER_2D_RECT_SHADOW_ARB); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT2x3); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT2x4); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT3x2); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT3x4); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT4x2); + CR_DUMP_MAKE_CASE(GL_FLOAT_MAT4x3); + CR_DUMP_MAKE_CASE_UNKNOWN(enmType, "Unknown Variable Type", pDumper); + } +} + +static char *crRecDumpGetLine(char **ppszStr, uint32_t *pcbStr) +{ + char *pszStr, *pNewLine; + const uint32_t cbStr = *pcbStr; + + if (!cbStr) + { + /* zero-length string */ + return NULL; + } + + if ((*ppszStr)[cbStr-1] != '\0') + { + crWarning("string should be null-rerminated, forcing it!"); + (*ppszStr)[cbStr-1] = '\0'; + } + pszStr = *ppszStr; + if (!*pszStr) + { + *pcbStr = 0; + return NULL; + } + + if (!(pNewLine = strstr(pszStr, "\n"))) + { + /* the string contains a single line! */ + *ppszStr += strlen(pszStr); + *pcbStr = 0; + return pszStr; + } + + *pNewLine = '\0'; + *pcbStr = cbStr - (((uintptr_t)pNewLine) - ((uintptr_t)pszStr)) - 1; + Assert((*pcbStr) < UINT32_MAX/2); + Assert((*pcbStr) < cbStr); + *ppszStr = pNewLine + 1; + + return pszStr; +} + +static void crRecDumpStrByLine(CR_DUMPER *pDumper, char *pszStr, uint32_t cbStr) +{ + char *pszCurLine; + while ((pszCurLine = crRecDumpGetLine(&pszStr, &cbStr)) != NULL) + { + crDmpStrF(pDumper, "%s", pszCurLine); + } +} + +static DECLCALLBACK(GLuint) crDmpGetHwidShaderCB(void *pvObj) +{ + return ((CRGLSLShader*)pvObj)->hwid; +} + +static DECLCALLBACK(GLuint) crDmpGetHwidProgramCB(void *pvObj) +{ + return ((CRGLSLProgram*)pvObj)->hwid; +} + +/* Context activation is done by the caller. */ +void crRecDumpLog(CR_RECORDER *pRec, GLint hwid) +{ + GLint cbLog = 0; + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_INFO_LOG_LENGTH_ARB, &cbLog); + + crDmpStrF(pRec->pDumper, "Log===%d===", hwid); + + if (cbLog > 1) + { + GLchar *pszLog = (GLchar *) crAlloc(cbLog*sizeof (GLchar)); + + pRec->pDispatch->GetInfoLogARB(hwid, cbLog, NULL, pszLog); + + crRecDumpStrByLine(pRec->pDumper, pszLog, cbLog); + + crFree(pszLog); + } + crDmpStrF(pRec->pDumper, "End Log======"); +} + +void crRecDumpShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid) +{ + GLint length = 0; + GLint type = 0; + GLint compileStatus = 0; + +#ifndef IN_GUEST + CRGLSLShader *pShad; + + if (!id) + { + unsigned long tstKey = 0; + Assert(hwid); + pShad = (CRGLSLShader *)crDmpHashtableSearchByHwid(ctx->glsl.shaders, hwid, crDmpGetHwidShaderCB, &tstKey); + Assert(pShad); + if (!pShad) + return; + id = pShad->id; + Assert(tstKey == id); + } + else + { + pShad = (CRGLSLShader *)crHashtableSearch(ctx->glsl.shaders, id); + Assert(pShad); + if (!pShad) + return; + } + + if (!hwid) + hwid = pShad->hwid; + + Assert(pShad->hwid == hwid); + Assert(pShad->id == id); +#else + if (!id) + id = hwid; + else if (!hwid) + hwid = id; + + Assert(id); + Assert(hwid); + Assert(hwid == id); +#endif + + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_SUBTYPE_ARB, &type); + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_COMPILE_STATUS_ARB, &compileStatus); + crDmpStrF(pRec->pDumper, "SHADER ctx(%d) id(%d) hwid(%d) type(%s) status(%d):", ctx->id, id, hwid, crRecDumpShaderTypeString(type, pRec->pDumper), compileStatus); + + crRecDumpLog(pRec, hwid); + + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_SHADER_SOURCE_LENGTH_ARB, &length); + + char *pszSource = (char*)crCalloc(length + 1); + if (!pszSource) + { + crWarning("crCalloc failed"); + crDmpStrF(pRec->pDumper, "WARNING: crCalloc failed"); + return; + } + + pRec->pDispatch->GetShaderSource(hwid, length, NULL, pszSource); + crRecDumpStrByLine(pRec->pDumper, pszSource, length); + + crFree(pszSource); + + crDmpStr(pRec->pDumper, "===END SHADER===="); +} + +void crRecDumpProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid) +{ + GLint cShaders = 0, linkStatus = 0; + char *source = NULL; + CRGLSLProgram *pProg; + + if (!id) + { + unsigned long tstKey = 0; + Assert(hwid); + pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey); + Assert(pProg); + if (!pProg) + return; + id = pProg->id; + Assert(tstKey == id); + } + else + { + pProg = (CRGLSLProgram *) crHashtableSearch(ctx->glsl.programs, id); + Assert(pProg); + if (!pProg) + return; + } + + if (!hwid) + hwid = pProg->hwid; + + Assert(pProg->hwid == hwid); + Assert(pProg->id == id); + + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_ATTACHED_OBJECTS_ARB, &cShaders); + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_LINK_STATUS_ARB, &linkStatus); + + crDmpStrF(pRec->pDumper, "PROGRAM ctx(%d) id(%d) hwid(%d) status(%d) shaders(%d):", ctx->id, id, hwid, linkStatus, cShaders); + + crRecDumpLog(pRec, hwid); + + VBoxGLhandleARB *pShaders = (VBoxGLhandleARB*)crCalloc(cShaders * sizeof (*pShaders)); + if (!pShaders) + { + crWarning("crCalloc failed"); + crDmpStrF(pRec->pDumper, "WARNING: crCalloc failed"); + return; + } + + pRec->pDispatch->GetAttachedObjectsARB(hwid, cShaders, NULL, pShaders); + for (GLint i = 0; i < cShaders; ++i) + { + if (pShaders[i]) + crRecDumpShader(pRec, ctx, 0, pShaders[i]); + else + crDmpStrF(pRec->pDumper, "WARNING: Shader[%d] is null", i); + } + + crFree(pShaders); + + GLsizei cbLog = 0; + + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_INFO_LOG_LENGTH_ARB, &cbLog); + if (cbLog) + { + char *pszLog = (char *)crCalloc(cbLog+1); + pRec->pDispatch->GetInfoLogARB(hwid, cbLog, NULL, pszLog); + crDmpStrF(pRec->pDumper, "==LOG=="); + crRecDumpStrByLine(pRec->pDumper, pszLog, cbLog); + crDmpStrF(pRec->pDumper, "==Done LOG=="); + crFree(pszLog); + } + else + { + crDmpStrF(pRec->pDumper, "==No LOG=="); + } + + crDmpStr(pRec->pDumper, "===END PROGRAM===="); +} + +void crRecRecompileShader(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid) +{ + GLint length = 0; + GLint type = 0; + GLint compileStatus = 0; + CRGLSLShader *pShad; + + if (!id) + { + unsigned long tstKey = 0; + Assert(hwid); + pShad = (CRGLSLShader *)crDmpHashtableSearchByHwid(ctx->glsl.shaders, hwid, crDmpGetHwidShaderCB, &tstKey); + Assert(pShad); + if (!pShad) + return; + id = pShad->id; + Assert(tstKey == id); + } + else + { + pShad = (CRGLSLShader *)crHashtableSearch(ctx->glsl.shaders, id); + Assert(pShad); + if (!pShad) + return; + } + + if (!hwid) + hwid = pShad->hwid; + + Assert(pShad->hwid == hwid); + Assert(pShad->id == id); + + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_SUBTYPE_ARB, &type); + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_COMPILE_STATUS_ARB, &compileStatus); + crDmpStrF(pRec->pDumper, "==RECOMPILE SHADER ctx(%d) id(%d) hwid(%d) type(%s) status(%d)==", ctx->id, id, hwid, crRecDumpShaderTypeString(type, pRec->pDumper), compileStatus); + + compileStatus = 0; + GLenum status; + while ((status = pRec->pDispatch->GetError()) != GL_NO_ERROR) {/*Assert(0);*/} + pRec->pDispatch->CompileShader(hwid); + while ((status = pRec->pDispatch->GetError()) != GL_NO_ERROR) {Assert(0);} + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_COMPILE_STATUS_ARB, &compileStatus); + + crDmpStrF(pRec->pDumper, "==Done RECOMPILE SHADER, status(%d)==", compileStatus); +} + +void crRecRecompileProgram(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid) +{ + GLint cShaders = 0, linkStatus = 0; + char *source = NULL; + CRGLSLProgram *pProg; + + if (!id) + { + unsigned long tstKey = 0; + Assert(hwid); + pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey); + Assert(pProg); + if (!pProg) + return; + id = pProg->id; + Assert(tstKey == id); + } + else + { + pProg = (CRGLSLProgram *) crHashtableSearch(ctx->glsl.programs, id); + Assert(pProg); + if (!pProg) + return; + } + + if (!hwid) + hwid = pProg->hwid; + + Assert(pProg->hwid == hwid); + Assert(pProg->id == id); + + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_ATTACHED_OBJECTS_ARB, &cShaders); + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_LINK_STATUS_ARB, &linkStatus); + + crDmpStrF(pRec->pDumper, "==RECOMPILE PROGRAM ctx(%d) id(%d) hwid(%d) status(%d) shaders(%d)==", ctx->id, id, hwid, linkStatus, cShaders); + + VBoxGLhandleARB *pShaders = (VBoxGLhandleARB*)crCalloc(cShaders * sizeof (*pShaders)); + if (!pShaders) + { + crWarning("crCalloc failed"); + crDmpStrF(pRec->pDumper, "WARNING: crCalloc failed"); + return; + } + + pRec->pDispatch->GetAttachedObjectsARB(hwid, cShaders, NULL, pShaders); + for (GLint i = 0; i < cShaders; ++i) + { + crRecRecompileShader(pRec, ctx, 0, pShaders[i]); + } + + crFree(pShaders); + + linkStatus = 0; + GLenum status; + while ((status = pRec->pDispatch->GetError()) != GL_NO_ERROR) {/*Assert(0);*/} + pRec->pDispatch->LinkProgram(hwid); + while ((status = pRec->pDispatch->GetError()) != GL_NO_ERROR) {Assert(0);} + pRec->pDispatch->GetObjectParameterivARB(hwid, GL_OBJECT_LINK_STATUS_ARB, &linkStatus); + + crDmpStrF(pRec->pDumper, "==Done RECOMPILE PROGRAM, status(%d)==", linkStatus); +} + +VBOXDUMPDECL(void) crRecDumpCurrentProgram(CR_RECORDER *pRec, CRContext *ctx) +{ + GLint curProgram = 0; + pRec->pDispatch->GetIntegerv(GL_CURRENT_PROGRAM, &curProgram); + if (curProgram) + { + Assert(ctx->glsl.activeProgram); + if (!ctx->glsl.activeProgram) + crWarning("no active program state with active hw program"); + else + Assert(ctx->glsl.activeProgram->hwid == curProgram); + crRecDumpProgram(pRec, ctx, 0, curProgram); + } + else + { + Assert(!ctx->glsl.activeProgram); + crDmpStrF(pRec->pDumper, "--no active program"); + } +} + +void crRecDumpProgramUniforms(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid) +{ + CRGLSLProgram *pProg; + + if (!id) + { + unsigned long tstKey = 0; + Assert(hwid); + pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey); + Assert(pProg); + if (!pProg) + return; + id = pProg->id; + Assert(tstKey == id); + } + else + { + pProg = (CRGLSLProgram *) crHashtableSearch(ctx->glsl.programs, id); + Assert(pProg); + if (!pProg) + return; + } + + if (!hwid) + hwid = pProg->hwid; + + Assert(pProg->hwid == hwid); + Assert(pProg->id == id); + + GLint maxUniformLen = 0, activeUniforms = 0, i, j, uniformsCount = 0; + GLenum type; + GLint size, location; + GLchar *pszName = NULL; + pRec->pDispatch->GetProgramiv(hwid, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLen); + pRec->pDispatch->GetProgramiv(hwid, GL_ACTIVE_UNIFORMS, &activeUniforms); + + if (!maxUniformLen) + { + if (activeUniforms) + { + crWarning("activeUniforms (%d), while maxUniformLen is zero", activeUniforms); + activeUniforms = 0; + } + } + + if (activeUniforms>0) + { + pszName = (GLchar *) crAlloc((maxUniformLen+8)*sizeof(GLchar)); + + if (!pszName) + { + crWarning("crRecDumpProgramUniforms: out of memory"); + return; + } + } + + for (i=0; ipDispatch->GetActiveUniform(hwid, i, maxUniformLen, NULL, &size, &type, pszName); + uniformsCount += size; + } + Assert(uniformsCount>=activeUniforms); + + if (activeUniforms>0) + { + GLfloat fdata[16]; + GLint idata[16]; + char *pIndexStr=NULL; + + for (i=0; ipDispatch->GetActiveUniform(hwid, i, maxUniformLen, NULL, &size, &type, pszName); + + if (size>1) + { + pIndexStr = crStrchr(pszName, '['); + if (!pIndexStr) + { + pIndexStr = pszName+crStrlen(pszName); + fPrintBraketsWithName = true; + } + } + + if (fPrintBraketsWithName) + { + crDmpStrF(pRec->pDumper, "%s %s[%d];", crRecDumpVarTypeString(type, pRec->pDumper), pszName, size); + Assert(size > 1); + } + else + crDmpStrF(pRec->pDumper, "%s %s;", crRecDumpVarTypeString(type, pRec->pDumper), pszName); + + GLint uniformTypeSize = crStateGetUniformSize(type); + Assert(uniformTypeSize >= 1); + + for (j=0; j1) + { + sprintf(pIndexStr, "[%i]", j); + } + location = pRec->pDispatch->GetUniformLocation(hwid, pszName); + + if (crStateIsIntUniform(type)) + { + pRec->pDispatch->GetUniformiv(hwid, location, &idata[0]); + switch (uniformTypeSize) + { + case 1: + crDmpStrF(pRec->pDumper, "%s = %d; //location %d", pszName, idata[0], location); + break; + case 2: + crDmpStrF(pRec->pDumper, "%s = {%d, %d}; //location %d", pszName, idata[0], idata[1], location); + break; + case 3: + crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], location); + break; + case 4: + crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], idata[3], location); + break; + default: + for (GLint k = 0; k < uniformTypeSize; ++k) + { + crDmpStrF(pRec->pDumper, "%s[%d] = %d; //location %d", pszName, k, idata[k], location); + } + break; + } + } + else + { + pRec->pDispatch->GetUniformfv(hwid, location, &fdata[0]); + switch (uniformTypeSize) + { + case 1: + crDmpStrF(pRec->pDumper, "%s = %f; //location %d", pszName, fdata[0], location); + break; + case 2: + crDmpStrF(pRec->pDumper, "%s = {%f, %f}; //location %d", pszName, fdata[0], fdata[1], location); + break; + case 3: + crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], location); + break; + case 4: + crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], fdata[3], location); + break; + default: + for (GLint k = 0; k < uniformTypeSize; ++k) + { + crDmpStrF(pRec->pDumper, "%s[%d] = %f; //location %d", pszName, k, fdata[k], location); + } + break; + } + } + } + } + + crFree(pszName); + } +} + +void crRecDumpProgramAttribs(CR_RECORDER *pRec, CRContext *ctx, GLint id, GLint hwid) +{ + CRGLSLProgram *pProg; + + if (!id) + { + unsigned long tstKey = 0; + Assert(hwid); + pProg = (CRGLSLProgram*)crDmpHashtableSearchByHwid(ctx->glsl.programs, hwid, crDmpGetHwidProgramCB, &tstKey); + Assert(pProg); + if (!pProg) + return; + id = pProg->id; + Assert(tstKey == id); + } + else + { + pProg = (CRGLSLProgram *) crHashtableSearch(ctx->glsl.programs, id); + Assert(pProg); + if (!pProg) + return; + } + + if (!hwid) + hwid = pProg->hwid; + + Assert(pProg->hwid == hwid); + Assert(pProg->id == id); + + GLint maxAttribLen = 0, activeAttrib = 0, i, j, attribCount = 0; + GLenum type; + GLint size, location; + GLchar *pszName = NULL; + pRec->pDispatch->GetProgramiv(hwid, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttribLen); + pRec->pDispatch->GetProgramiv(hwid, GL_ACTIVE_ATTRIBUTES, &activeAttrib); + + if (!maxAttribLen) + { + if (activeAttrib) + { + crWarning("activeAttrib (%d), while maxAttribLen is zero", activeAttrib); + activeAttrib = 0; + } + } + + if (activeAttrib>0) + { + pszName = (GLchar *) crAlloc((maxAttribLen+8)*sizeof(GLchar)); + + if (!pszName) + { + crWarning("crRecDumpProgramAttrib: out of memory"); + return; + } + } + + for (i=0; ipDispatch->GetActiveAttrib(hwid, i, maxAttribLen, NULL, &size, &type, pszName); + attribCount += size; + } + Assert(attribCount>=activeAttrib); + + if (activeAttrib>0) + { + GLfloat fdata[16]; + GLint idata[16]; + char *pIndexStr=NULL; + + for (i=0; ipDispatch->GetActiveAttrib(hwid, i, maxAttribLen, NULL, &size, &type, pszName); + GLint arrayBufferBind = 0, arrayEnabled = 0, arraySize = 0, arrayStride = 0, arrayType = 0, arrayNormalized = 0, arrayInteger = 0/*, arrayDivisor = 0*/; + + pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &arrayBufferBind); + pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_ENABLED, &arrayEnabled); + pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_SIZE, &arraySize); + pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &arrayStride); + pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_TYPE, &arrayType); + pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &arrayNormalized); + pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_INTEGER, &arrayInteger); +// pRec->pDispatch->GetVertexAttribivARB(i, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &arrayDivisor); + + if (size>1) + { + pIndexStr = crStrchr(pszName, '['); + if (!pIndexStr) + { + pIndexStr = pszName+crStrlen(pszName); + fPrintBraketsWithName = true; + } + } + + if (fPrintBraketsWithName) + { + crDmpStrF(pRec->pDumper, "%s %s[%d];", crRecDumpVarTypeString(type, pRec->pDumper), pszName, size); + Assert(size > 1); + } + else + crDmpStrF(pRec->pDumper, "%s %s;", crRecDumpVarTypeString(type, pRec->pDumper), pszName); + + crDmpStrF(pRec->pDumper, "Array buff(%d), enabled(%d) size(%d), stride(%d), type(%s), normalized(%d), integer(%d)", arrayBufferBind, arrayEnabled, arraySize, arrayStride, crRecDumpVarTypeString(arrayType, pRec->pDumper), arrayNormalized, arrayInteger); + + GLint attribTypeSize = crStateGetUniformSize(type); + Assert(attribTypeSize >= 1); + + for (j=0; j1) + { + sprintf(pIndexStr, "[%i]", j); + } + location = pRec->pDispatch->GetAttribLocation(hwid, pszName); + + if (crStateIsIntUniform(type)) + { + pRec->pDispatch->GetVertexAttribivARB(location, GL_CURRENT_VERTEX_ATTRIB, &idata[0]); + switch (attribTypeSize) + { + case 1: + crDmpStrF(pRec->pDumper, "%s = %d; //location %d", pszName, idata[0], location); + break; + case 2: + crDmpStrF(pRec->pDumper, "%s = {%d, %d}; //location %d", pszName, idata[0], idata[1], location); + break; + case 3: + crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], location); + break; + case 4: + crDmpStrF(pRec->pDumper, "%s = {%d, %d, %d, %d}; //location %d", pszName, idata[0], idata[1], idata[2], idata[3], location); + break; + default: + for (GLint k = 0; k < attribTypeSize; ++k) + { + crDmpStrF(pRec->pDumper, "%s[%d] = %d; //location %d", pszName, k, idata[k], location); + } + break; + } + } + else + { + pRec->pDispatch->GetVertexAttribfvARB(location, GL_CURRENT_VERTEX_ATTRIB, &fdata[0]); + switch (attribTypeSize) + { + case 1: + crDmpStrF(pRec->pDumper, "%s = %f; //location %d", pszName, fdata[0], location); + break; + case 2: + crDmpStrF(pRec->pDumper, "%s = {%f, %f}; //location %d", pszName, fdata[0], fdata[1], location); + break; + case 3: + crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], location); + break; + case 4: + crDmpStrF(pRec->pDumper, "%s = {%f, %f, %f, %f}; //location %d", pszName, fdata[0], fdata[1], fdata[2], fdata[3], location); + break; + default: + for (GLint k = 0; k < attribTypeSize; ++k) + { + crDmpStrF(pRec->pDumper, "%s[%d] = %f; //location %d", pszName, k, fdata[k], location); + } + break; + } + } + } + } + + crFree(pszName); + } +} + +VBOXDUMPDECL(void) crRecDumpCurrentProgramUniforms(CR_RECORDER *pRec, CRContext *ctx) +{ + GLint curProgram = 0; + pRec->pDispatch->GetIntegerv(GL_CURRENT_PROGRAM, &curProgram); + if (curProgram) + { + Assert(ctx->glsl.activeProgram); + if (!ctx->glsl.activeProgram) + crWarning("no active program state with active hw program"); + else + Assert(ctx->glsl.activeProgram->hwid == curProgram); + crRecDumpProgramUniforms(pRec, ctx, 0, curProgram); + } + else + { + Assert(!ctx->glsl.activeProgram); + crDmpStrF(pRec->pDumper, "--no active program"); + } +} + +VBOXDUMPDECL(void) crRecDumpCurrentProgramAttribs(CR_RECORDER *pRec, CRContext *ctx) +{ + GLint curProgram = 0; + pRec->pDispatch->GetIntegerv(GL_CURRENT_PROGRAM, &curProgram); + if (curProgram) + { + Assert(ctx->glsl.activeProgram); + if (!ctx->glsl.activeProgram) + crWarning("no active program state with active hw program"); + else + Assert(ctx->glsl.activeProgram->hwid == curProgram); + crRecDumpProgramAttribs(pRec, ctx, 0, curProgram); + } + else + { + Assert(!ctx->glsl.activeProgram); + crDmpStrF(pRec->pDumper, "--no active program"); + } +} + +VBOXDUMPDECL(void) crRecRecompileCurrentProgram(CR_RECORDER *pRec, CRContext *ctx) +{ + GLint curProgram = 0; + pRec->pDispatch->GetIntegerv(GL_CURRENT_PROGRAM, &curProgram); + if (curProgram) + { + Assert(ctx->glsl.activeProgram); + if (!ctx->glsl.activeProgram) + crWarning("no active program state with active hw program"); + else + Assert(ctx->glsl.activeProgram->hwid == curProgram); + crRecRecompileProgram(pRec, ctx, 0, curProgram); + } + else + { + Assert(!ctx->glsl.activeProgram); + crDmpStrF(pRec->pDumper, "--no active program"); + } +} + +int crRecAlphaImgCreate(const CR_BLITTER_IMG *pImg, CR_BLITTER_IMG *pAlphaImg) +{ + if (pImg->enmFormat != GL_RGBA + && pImg->enmFormat != GL_BGRA) + { + crWarning("unsupported format 0x%x", pImg->enmFormat); + return VERR_NOT_IMPLEMENTED; + } + + pAlphaImg->bpp = 32; + pAlphaImg->pitch = pImg->width * 4; + pAlphaImg->cbData = pAlphaImg->pitch * pImg->height; + pAlphaImg->enmFormat = GL_BGRA; + pAlphaImg->width = pImg->width; + pAlphaImg->height = pImg->height; + + pAlphaImg->pvData = RTMemAlloc(pAlphaImg->cbData); + if (!pAlphaImg->pvData) + { + crWarning("RTMemAlloc failed"); + return VERR_NO_MEMORY; + } + + uint8_t *pu8SrcBuf = (uint8_t*)pImg->pvData; + uint8_t *pu8DstBuf = (uint8_t*)pAlphaImg->pvData; + for (uint32_t ih = 0; ih < pAlphaImg->height; ++ih) + { + uint32_t *pu32SrcBuf = (uint32_t*)pu8SrcBuf; + uint32_t *pu32DstBuf = (uint32_t*)pu8DstBuf; + for (uint32_t iw = 0; iw < pAlphaImg->width; ++iw) + { + uint8_t alpha = (((*pu32SrcBuf) >> 24) & 0xff); + *pu32DstBuf = (0xff << 24) || (alpha << 16) || (alpha << 8) || alpha; + ++pu32SrcBuf; + ++pu32DstBuf; + } + pu8SrcBuf += pImg->pitch; + pu8DstBuf += pAlphaImg->pitch; + } + + return VINF_SUCCESS; +} + +void crRecAlphaImgDestroy(CR_BLITTER_IMG *pImg) +{ + RTMemFree(pImg->pvData); + pImg->pvData = NULL; +} + +void crRecDumpTextureV(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, const char *pszStr, va_list pArgList) +{ + CR_BLITTER_IMG Img = {0}; + int rc = CrBltEnter(pRec->pBlitter); + if (RT_SUCCESS(rc)) + { + rc = CrBltImgGetTex(pRec->pBlitter, pTex, GL_BGRA, &Img); + if (RT_SUCCESS(rc)) + { + crDmpImgV(pRec->pDumper, &Img, pszStr, pArgList); + if (g_CrDbgDumpAlphaData) + { + CR_BLITTER_IMG AlphaImg = {0}; + rc = crRecAlphaImgCreate(&Img, &AlphaImg); + if (RT_SUCCESS(rc)) + { + crDmpImgF(pRec->pDumper, &AlphaImg, "Texture ALPHA Data"); + crRecAlphaImgDestroy(&AlphaImg); + } + else + { + crWarning("crRecAlphaImgCreate failed rc %d", rc); + } + } + CrBltImgFree(pRec->pBlitter, &Img); + } + else + { + crWarning("CrBltImgGetTex failed, rc %d", rc); + } + CrBltLeave(pRec->pBlitter); + } + else + { + crWarning("CrBltEnter failed, rc %d", rc); + } +} + +void crRecDumpTextureF(CR_RECORDER *pRec, const VBOXVR_TEXTURE *pTex, const char *pszStr, ...) +{ + va_list pArgList; + va_start(pArgList, pszStr); + crRecDumpTextureV(pRec, pTex, pszStr, pArgList); + va_end(pArgList); +} + +void crRecDumpTextureByIdV(CR_RECORDER *pRec, CRContext *ctx, GLint id, const char *pszStr, va_list pArgList) +{ + CRTextureObj *pTobj = (CRTextureObj *)crHashtableSearch(ctx->shared->textureTable, id); + if (!pTobj) + { + crWarning("no texture of id %d", id); + return; + } + + CRTextureLevel *pTl = &pTobj->level[0][0 /* level */]; + VBOXVR_TEXTURE Tex; + Tex.width = pTl->width; + Tex.height = pTl->height; + Tex.target = pTobj->target; + Assert(Tex.target == GL_TEXTURE_2D); + Tex.hwid = pTobj->hwid; + if (!Tex.hwid) + { + crWarning("no texture hwid of id %d", id); + return; + } + + crRecDumpTextureV(pRec, &Tex, pszStr, pArgList); +} + +void crRecDumpTextureByIdF(CR_RECORDER *pRec, CRContext *ctx, GLint id, const char *pszStr, ...) +{ + va_list pArgList; + va_start(pArgList, pszStr); + crRecDumpTextureByIdV(pRec, ctx, id, pszStr, pArgList); + va_end(pArgList); +} + +void crRecDumpTextures(CR_RECORDER *pRec, CRContext *ctx) +{ + GLint maxUnits = 0; + GLint curTexUnit = 0; + GLint restoreTexUnit = 0; + GLint curProgram = 0; + int i; + + pRec->pDispatch->GetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxUnits); + maxUnits = RT_MIN(CR_MAX_TEXTURE_UNITS, maxUnits); + + pRec->pDispatch->GetIntegerv(GL_CURRENT_PROGRAM, &curProgram); + Assert(curProgram); + Assert(ctx->glsl.activeProgram && ctx->glsl.activeProgram->hwid == curProgram); + + Assert(maxUnits); + pRec->pDispatch->GetIntegerv(GL_ACTIVE_TEXTURE, &curTexUnit); + restoreTexUnit = curTexUnit; + Assert(curTexUnit >= GL_TEXTURE0); + Assert(curTexUnit < GL_TEXTURE0 + maxUnits); + + Assert(ctx->texture.curTextureUnit == restoreTexUnit - GL_TEXTURE0); + + for (i = 0; i < maxUnits; ++i) + { + GLboolean enabled1D; + GLboolean enabled2D; + GLboolean enabled3D; + GLboolean enabledCubeMap; + GLboolean enabledRect; + CRTextureUnit *tu = &ctx->texture.unit[i]; + + if (i > 1) + break; + + if (curTexUnit != i + GL_TEXTURE0) + { + pRec->pDispatch->ActiveTextureARB(i + GL_TEXTURE0); + curTexUnit = i + GL_TEXTURE0; + } + + enabled1D = pRec->pDispatch->IsEnabled(GL_TEXTURE_1D); + enabled2D = pRec->pDispatch->IsEnabled(GL_TEXTURE_2D); + enabled3D = pRec->pDispatch->IsEnabled(GL_TEXTURE_3D); + enabledCubeMap = pRec->pDispatch->IsEnabled(GL_TEXTURE_CUBE_MAP_ARB); + enabledRect = pRec->pDispatch->IsEnabled(GL_TEXTURE_RECTANGLE_NV); + + Assert(enabled1D == tu->enabled1D); + Assert(enabled2D == tu->enabled2D); + Assert(enabled3D == tu->enabled3D); + Assert(enabledCubeMap == tu->enabledCubeMap); + Assert(enabledRect == tu->enabledRect); + + if (enabled1D) + { + crWarning("GL_TEXTURE_1D: unsupported"); + } + +// if (enabled2D) + { + GLint hwTex = 0; + VBOXVR_TEXTURE Tex; + + GLint width = 0, height = 0, depth = 0; + CRTextureObj *pTobj = tu->currentTexture2D; + + pRec->pDispatch->GetIntegerv(GL_TEXTURE_BINDING_2D, &hwTex); + if (hwTex) + { + CRTextureLevel *pTl = &pTobj->level[0][0 /* level */]; + Assert(pTobj + && pTobj->hwid == hwTex); + + pRec->pDispatch->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width); + pRec->pDispatch->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height); + pRec->pDispatch->GetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_DEPTH, &depth); + + Assert(width == pTl->width); + Assert(height == pTl->height); + Assert(depth == pTl->depth); + + Tex.width = width; + Tex.height = height; + Tex.target = GL_TEXTURE_2D; + Tex.hwid = hwTex; + + if (g_CrDbgDumpRecTexInfo) + { + crRecDumpTexParam(pRec, ctx, GL_TEXTURE_2D); + crRecDumpTexEnv(pRec, ctx); + crRecDumpTexGen(pRec, ctx); + } + + crRecDumpTextureF(pRec, &Tex, "ctx(%d), Unit %d: TEXTURE_2D id(%d) hwid(%d), width(%d), height(%d)", ctx, i, pTobj->id, pTobj->hwid, width, height); + } +// else +// { +// Assert(!pTobj || pTobj->hwid == 0); +// crWarning("no TEXTURE_2D bound!"); +// } + } +#if 0 + if (enabled3D) + { + crWarning("GL_TEXTURE_3D: unsupported"); + } + + if (enabledCubeMap) + { + crWarning("GL_TEXTURE_CUBE_MAP_ARB: unsupported"); + } + +// if (enabledRect) + { + GLint hwTex = 0; + CR_BLITTER_IMG Img = {0}; + VBOXVR_TEXTURE Tex; + + GLint width = 0, height = 0, depth = 0; + CRTextureObj *pTobj = tu->currentTextureRect; + + pRec->pDispatch->GetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_NV, &hwTex); + if (hwTex) + { + CRTextureLevel *pTl = &pTobj->level[0][0 /* level */]; + Assert(pTobj + && pTobj->hwid == hwTex); + + pRec->pDispatch->GetTexLevelParameteriv(GL_TEXTURE_RECTANGLE_NV, 0, GL_TEXTURE_WIDTH, &width); + pRec->pDispatch->GetTexLevelParameteriv(GL_TEXTURE_RECTANGLE_NV, 0, GL_TEXTURE_HEIGHT, &height); + pRec->pDispatch->GetTexLevelParameteriv(GL_TEXTURE_RECTANGLE_NV, 0, GL_TEXTURE_DEPTH, &depth); + + Assert(width == pTl->width); + Assert(height == pTl->height); + Assert(depth == pTl->depth); + + Tex.width = width; + Tex.height = height; + Tex.target = GL_TEXTURE_RECTANGLE_NV; + Tex.hwid = hwTex; + + rc = CrBltEnter(pRec->pBlitter); + if (RT_SUCCESS(rc)) + { + rc = CrBltImgGetTex(pRec->pBlitter, &Tex, GL_BGRA, &Img); + if (RT_SUCCESS(rc)) + { + crDmpImgF(pRec->pDumper, &Img, "Unit %d: TEXTURE_RECTANGLE data", i); + CrBltImgFree(pRec->pBlitter, &Img); + } + else + { + crWarning("CrBltImgGetTex failed, rc %d", rc); + } + CrBltLeave(pRec->pBlitter); + } + else + { + crWarning("CrBltEnter failed, rc %d", rc); + } + } +// else +// { +// Assert(!pTobj || pTobj->hwid == 0); +// crWarning("no TEXTURE_RECTANGLE bound!"); +// } + } +#endif + } + + if (curTexUnit != restoreTexUnit) + { + pRec->pDispatch->ActiveTextureARB(restoreTexUnit); + curTexUnit = restoreTexUnit; + } +} + +#ifdef RT_OS_WINDOWS +static void crDmpPrint(const char* szString, ...) +{ + char szBuffer[4096] = {0}; + va_list pArgList; + va_start(pArgList, szString); + RTStrPrintfV(szBuffer, sizeof (szBuffer), szString, pArgList); + va_end(pArgList); + + OutputDebugStringA(szBuffer); +} + +static void crDmpPrintDmlCmd(const char* pszDesc, const char* pszCmd) +{ + crDmpPrint("%s, ( %s )\n", pszCmd, pszDesc, pszCmd); +} + +void crDmpPrintDumpDmlCmd(const char* pszDesc, const void *pvData, uint32_t width, uint32_t height, uint32_t bpp, uint32_t pitch) +{ + char Cmd[1024]; + sprintf(Cmd, "!vbvdbg.ms 0x%p 0n%d 0n%d 0n%d 0n%d", pvData, width, height, bpp, pitch); + crDmpPrintDmlCmd(pszDesc, Cmd); +} + +DECLCALLBACK(void) crDmpDumpImgDmlBreak(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc) +{ + crDmpPrintDumpDmlCmd(pszEntryDesc, pImg->pvData, pImg->width, pImg->height, pImg->bpp, pImg->pitch); + RT_BREAKPOINT(); +} + +DECLCALLBACK(void) crDmpDumpStrDbgPrint(struct CR_DUMPER * pDumper, const char*pszStr) +{ + crDmpPrint("%s\n", pszStr); +} +#endif + +static void crDmpHtmlDumpStrExact(struct CR_HTML_DUMPER * pDumper, const char *pszStr) +{ + fprintf(pDumper->pFile, "%s", pszStr); + fflush(pDumper->pFile); +} + +static DECLCALLBACK(void) crDmpHtmlDumpStr(struct CR_DUMPER * pDumper, const char*pszStr) +{ + CR_HTML_DUMPER * pHtmlDumper = (CR_HTML_DUMPER*)pDumper; + fprintf(pHtmlDumper->pFile, "
%s
\n", pszStr); + fflush(pHtmlDumper->pFile); +} + +static DECLCALLBACK(void) crDmpHtmlDumpImg(struct CR_DUMPER * pDumper, CR_BLITTER_IMG *pImg, const char*pszEntryDesc) +{ + CR_HTML_DUMPER * pHtmlDumper = (CR_HTML_DUMPER*)pDumper; + char szBuffer[4096] = {0}; + size_t cbWritten = RTStrPrintf(szBuffer, sizeof(szBuffer), "%s/", pHtmlDumper->pszDir); + char *pszFileName = szBuffer + cbWritten; + RTStrPrintf(pszFileName, sizeof(szBuffer) - cbWritten, "img%d.bmp", ++pHtmlDumper->cImg); + crDmpImgBmp(pImg, szBuffer); + fprintf(pHtmlDumper->pFile, "
%s
\"%s\"

\n", + pszFileName, pszEntryDesc, pszFileName, pszEntryDesc); + fflush(pHtmlDumper->pFile); +} + +static void crDmpHtmlPrintHeader(struct CR_HTML_DUMPER * pDumper) +{ + fprintf(pDumper->pFile, "\n"); + fflush(pDumper->pFile); +} + +static void crDmpHtmlPrintFooter(struct CR_HTML_DUMPER * pDumper) +{ + fprintf(pDumper->pFile, "\n"); + fflush(pDumper->pFile); +} + +DECLEXPORT(bool) crDmpHtmlIsInited(struct CR_HTML_DUMPER * pDumper) +{ + return !!pDumper->pFile; +} + +DECLEXPORT(void) crDmpHtmlTerm(struct CR_HTML_DUMPER * pDumper) +{ + crDmpHtmlPrintFooter(pDumper); + fclose (pDumper->pFile); + pDumper->pFile = NULL; +} + +DECLEXPORT(int) crDmpHtmlInit(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile) +{ + int rc = VERR_NO_MEMORY; + pDumper->Base.pfnDumpImg = crDmpHtmlDumpImg; + pDumper->Base.pfnDumpStr = crDmpHtmlDumpStr; + pDumper->cImg = 0; + pDumper->pszDir = crStrdup(pszDir); + if (pDumper->pszDir) + { + pDumper->pszFile = crStrdup(pszFile); + if (pDumper->pszFile) + { + char szBuffer[4096] = {0}; + RTStrPrintf(szBuffer, sizeof(szBuffer), "%s/%s", pszDir, pszFile); + + pDumper->pszFile = crStrdup(pszFile); + pDumper->pFile = fopen(szBuffer, "w"); + if (pDumper->pFile) + { + crDmpHtmlPrintHeader(pDumper); + return VINF_SUCCESS; + } + else + { + crWarning("open failed"); + rc = VERR_OPEN_FAILED; + } + crFree((void*)pDumper->pszFile); + } + else + { + crWarning("open failed"); + } + crFree((void*)pDumper->pszDir); + } + else + { + crWarning("open failed"); + } + return rc; +} + +DECLEXPORT(int) crDmpHtmlInitV(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, va_list pArgList) +{ + char szBuffer[4096] = {0}; + vsprintf_s(szBuffer, sizeof (szBuffer), pszFile, pArgList); + return crDmpHtmlInit(pDumper, pszDir, szBuffer); +} + +DECLEXPORT(int) crDmpHtmlInitF(struct CR_HTML_DUMPER * pDumper, const char *pszDir, const char *pszFile, ...) +{ + int rc; + va_list pArgList; + va_start(pArgList, pszFile); + rc = crDmpHtmlInitV(pDumper, pszDir, pszFile, pArgList); + va_end(pArgList); + return rc; +} + +#endif diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py b/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py new file mode 100755 index 00000000..c4cae06e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py @@ -0,0 +1,249 @@ +from __future__ import print_function +import sys + +import apiutil + +import sys, re, string + + +line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s+(.*)\s*$') +extensions_line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s(\S+)\s+(.*)\s*$') + +params = {} +extended_params = {} + +input = open( sys.argv[2]+"/state_isenabled.txt", 'r' ) +for line in input.readlines(): + match = line_re.match( line ) + if match: + type = match.group(1) + pname = match.group(2) + fields = string.split( match.group(3) ) + params[pname] = ( type, fields ) + +input = open( sys.argv[2]+"/state_extensions_isenabled.txt", 'r' ) +for line in input.readlines(): + match = extensions_line_re.match( line ) + if match: + type = match.group(1) + pname = match.group(2) + ifdef = match.group(3) + fields = string.split( match.group(4) ) + extended_params[pname] = ( type, ifdef, fields ) + + +apiutil.CopyrightC() + +print("""#include "cr_blitter.h" +#include "cr_spu.h" +#include "chromium.h" +#include "cr_error.h" +#include "cr_net.h" +#include "cr_rand.h" +#include "cr_mem.h" +#include "cr_string.h" +#include +#include "cr_pixeldata.h" + +#include +#include +#include + +#include + +#ifdef VBOX_WITH_CRDUMPER +""") + +from get_sizes import *; + +getprops = apiutil.ParamProps("GetDoublev") +enableprops = apiutil.ParamProps("Enable") + +#print "//missing get props:" +#for prop in getprops: +# try: +# tmp = num_get_values[prop] +# except KeyError: +# try: +# keyvalues = extensions_num_get_values[prop] +# except KeyError: +# print "//%s" % prop +# +print(""" +static void crRecDumpPrintVal(CR_DUMPER *pDumper, struct nv_struct *pDesc, float *pfData) +{ + char aBuf[4096]; + crDmpFormatArray(aBuf, sizeof (aBuf), "%f", sizeof (float), pfData, pDesc->num_values); + crDmpStrF(pDumper, "%s = %s;", pDesc->pszName, aBuf); +} + + +void crRecDumpGlGetState(CR_RECORDER *pRec, CRContext *ctx) +{ + float afData[CR_MAX_GET_VALUES]; + struct nv_struct *pDesc; + + for (pDesc = num_values_array; pDesc->num_values != 0 ; pDesc++) + { + memset(afData, 0, sizeof(afData)); + pRec->pDispatch->GetFloatv(pDesc->pname, afData); + crRecDumpPrintVal(pRec->pDumper, pDesc, afData); + } +} + +void crRecDumpGlEnableState(CR_RECORDER *pRec, CRContext *ctx) +{ + GLboolean fEnabled; +""") +for pname in sorted(params.keys()): + print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname) + print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname) + +for pname in sorted(extended_params.keys()): + (srctype,ifdef,fields) = extended_params[pname] + ext = ifdef[3:] # the extension name with the "GL_" prefix removed + ext = ifdef + print('#ifdef CR_%s' % ext) + print("\tfEnabled = pRec->pDispatch->IsEnabled(%s);" % pname) + print("\tcrDmpStrF(pRec->pDumper, \"%s = %%d;\", fEnabled);" % pname) + print('#endif /* CR_%s */' % ext) + +#print "//missing enable props:" +#for prop in enableprops: +# try: +# keyvalues = params[prop] +# except KeyError: +# try: +# keyvalues = extended_params[prop] +# except KeyError: +# print "//%s" % prop +# +print(""" +} +#endif +""") + +texenv_mappings = { + 'GL_TEXTURE_ENV' : [ + 'GL_TEXTURE_ENV_MODE', + 'GL_TEXTURE_ENV_COLOR', + 'GL_COMBINE_RGB', + 'GL_COMBINE_ALPHA', + 'GL_RGB_SCALE', + 'GL_ALPHA_SCALE', + 'GL_SRC0_RGB', + 'GL_SRC1_RGB', + 'GL_SRC2_RGB', + 'GL_SRC0_ALPHA', + 'GL_SRC1_ALPHA', + 'GL_SRC2_ALPHA' + ], + 'GL_TEXTURE_FILTER_CONTROL' : [ + 'GL_TEXTURE_LOD_BIAS' + ], + 'GL_POINT_SPRITE' : [ + 'GL_COORD_REPLACE' + ] +} + +texgen_coords = [ + 'GL_S', + 'GL_T', + 'GL_R', + 'GL_Q' +] + +texgen_names = [ + 'GL_TEXTURE_GEN_MODE', + 'GL_OBJECT_PLANE', + 'GL_EYE_PLANE' +] + +texparam_names = [ + 'GL_TEXTURE_MAG_FILTER', + 'GL_TEXTURE_MIN_FILTER', + 'GL_TEXTURE_MIN_LOD', + 'GL_TEXTURE_MAX_LOD', + 'GL_TEXTURE_BASE_LEVEL', + 'GL_TEXTURE_MAX_LEVEL', + 'GL_TEXTURE_WRAP_S', + 'GL_TEXTURE_WRAP_T', + 'GL_TEXTURE_WRAP_R', + 'GL_TEXTURE_BORDER_COLOR', + 'GL_TEXTURE_PRIORITY', + 'GL_TEXTURE_RESIDENT', + 'GL_TEXTURE_COMPARE_MODE', + 'GL_TEXTURE_COMPARE_FUNC', + 'GL_DEPTH_TEXTURE_MODE', + 'GL_GENERATE_MIPMAP' +] + +print(""" +void crRecDumpTexParam(CR_RECORDER *pRec, CRContext *ctx, GLenum enmTarget) +{ + GLfloat afBuf[4]; + char acBuf[1024]; + unsigned int cComponents; + crDmpStrF(pRec->pDumper, "==TEX_PARAM for target(0x%x)==", enmTarget); +""") +for pname in texparam_names: + print("\tcComponents = crStateHlpComponentsCount(%s);" % pname) + print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));") + print("\tmemset(afBuf, 0, sizeof (afBuf));") + print("\tpRec->pDispatch->GetTexParameterfv(enmTarget, %s, afBuf);" % pname) + print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);") + print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname) +print(""" + crDmpStrF(pRec->pDumper, "==Done TEX_PARAM for target(0x%x)==", enmTarget); +} +""") + +print(""" +void crRecDumpTexEnv(CR_RECORDER *pRec, CRContext *ctx) +{ + GLfloat afBuf[4]; + char acBuf[1024]; + unsigned int cComponents; + crDmpStrF(pRec->pDumper, "==TEX_ENV=="); +""") + +for target in sorted(texenv_mappings.keys()): + print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % target) + values = texenv_mappings[target] + for pname in values: + print("\tcComponents = crStateHlpComponentsCount(%s);" % pname) + print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));") + print("\tmemset(afBuf, 0, sizeof (afBuf));") + print("\tpRec->pDispatch->GetTexEnvfv(%s, %s, afBuf);" % (target, pname)) + print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);") + print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname) + print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % target) +print(""" + crDmpStrF(pRec->pDumper, "==Done TEX_ENV=="); +} +""") + + +print(""" +void crRecDumpTexGen(CR_RECORDER *pRec, CRContext *ctx) +{ + GLdouble afBuf[4]; + char acBuf[1024]; + unsigned int cComponents; + crDmpStrF(pRec->pDumper, "==TEX_GEN=="); +""") + +for coord in texgen_coords: + print("\tcrDmpStrF(pRec->pDumper, \"===%s===\");" % coord) + for pname in texgen_names: + print("\tcComponents = crStateHlpComponentsCount(%s);" % pname) + print("\tAssert(cComponents <= RT_ELEMENTS(afBuf));") + print("\tmemset(afBuf, 0, sizeof (afBuf));") + print("\tpRec->pDispatch->GetTexGendv(%s, %s, afBuf);" % (coord, pname)) + print("\tcrDmpFormatArray(acBuf, sizeof (acBuf), \"%f\", sizeof (afBuf[0]), afBuf, cComponents);") + print("\tcrDmpStrF(pRec->pDumper, \"%s = %%s;\", acBuf);" % pname) + print("\tcrDmpStrF(pRec->pDumper, \"===Done %s===\");" % coord) +print(""" + crDmpStrF(pRec->pDumper, "==Done TEX_GEN=="); +} +""") diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py b/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py new file mode 100755 index 00000000..6c3e91d6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/gendiffcode.py @@ -0,0 +1,273 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software + +from __future__ import print_function +import sys + +def main(): + name = sys.argv[1] + Name = sys.argv[2] + + print("""/* This code is AUTOGENERATED!!! */ + +#include "state.h" +#include "state_internals.h\"""") + + print(""" +void crState%(Name)sDiff(CR%(Name)sBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CR%(Name)sState *from = &(fromCtx->%(name)s); + CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()) + gendiffcode("state_%s.txt"%(name.lower()), name, docopy=1, doinvalid=0) + print("""} + +void crState%(Name)sSwitch(CR%(Name)sBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CR%(Name)sState *from = &(fromCtx->%(name)s); + CR%(Name)sState *to = &(toCtx->%(name)s);"""%vars()) + gendiffcode("state_%s.txt"%(Name.lower()), Name, docopy=0, doinvalid=1) + print("}\n") + +def gendiffcode(fname, state_name, docopy, doinvalid): + target = "to" + current = "from" + bit = "b" + extrabit = "" + tab = "\t" + current_guard = "" + current_dependency = "" + + v_types = { + 'l': 'GLboolean', + 'b': 'GLbyte', + 'ub': 'GLubyte', + 's': 'GLshort', + 'us': 'GLushort', + 'i': 'GLint', + 'ui': 'GLuint', + 'f': 'GLfloat', + 'd': 'GLdouble' + } + + FILE = open(sys.argv[3]+"/"+fname, "r") + + print(""" unsigned int j, i; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + for (j = 0; j(.*)", line) + if m: + text = m.group(1) + if re.search("}", line): + tab = tab[:-1] + print(tab+text) + if re.search("{", line): + tab = tab+"\t" + continue + +## Handle commands + + m = re.search("%target=(\w*)", line) + if m: + target = m.group(1) + m = re.search("%current=(\w*)", line) + if m: + current = m.group(1) + m = re.search("%bit=(\w*)", line) + if m: + bit = m.group(1) + m = re.search("%extrabit=(\w*)", line) + if m: + extrabit = m.group(1) + + if re.search("%flush", line): + if current_guard != "": + print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()) + tab = tab[:-1] + print(tab+"}") + if docopy and current_dependency != "": + tab = tab[:-1] + print(tab+"}") + current_guard = "" + current_dependency = "" + if re.search("%", line): + continue + +## Load the line + (dependency, guardbit, members, func) = \ + (re.split(":", line) + ["", ""])[0:4] + func = func.rstrip() + +## Close the guardbit and dependency + if current_guard != "" and current_guard != guardbit: + print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()) + tab = tab[:-1] + print(tab+"}") + if docopy and current_dependency != "" and current_dependency != dependency: + tab = tab[:-1] + print(tab+"}") + +## Open the dependency if + if docopy and current_dependency != dependency and dependency != "": + print(tab+"if (%(target)s->%(dependency)s)\n%(tab)s{"%vars()) + tab = tab+"\t" + current_dependency = dependency + +## Open the guard if + if docopy and current_dependency != dependency and dependency != "": + print(tab+"if ($(target)s->%(dependency)s)\n%(tab)s{"%vars()) + tab = tab+"\t" + + if current_guard != guardbit and guardbit != "": + print(tab+"if (CHECKDIRTY(%(bit)s->%(guardbit)s, bitID))\n%(tab)s{"%vars()) + tab = tab+"\t" + if members[0] != "*" and guardbit[0:6] == "enable": + print(tab+"glAble able[2];") + print(tab+"able[0] = diff_api.Disable;") + print(tab+"able[1] = diff_api.Enable;") + + current_dependency = dependency + current_guard = guardbit + +## Handle text dump + if members[0] == "*": + print(tab+members[1:]) + else: + ## Parse the members variable + mainelem = re.split(",", members) + elems = re.split("\|", members) + if len(elems) > 1: + mainelem = [""] + mainelem[0] = elems[0] + elems = re.split(",", elems[1]) + newelems = [] + for elem in elems: + elem = mainelem[0] + "." + elem + newelems += [elem] + elems = newelems + else: + elems = re.split(",", members) + + ## Check member values + if guardbit != "extensions": + sys.stdout.write(tab+"if (") + first = 1 + for elem in elems: + if first != 1: + print(" ||\n"+tab+" ", end="") + first = 0 + sys.stdout.write("%(current)s->%(elem)s != %(target)s->%(elem)s"%vars()) + print(")\n"+tab+"{") + tab = tab+"\t" + +## Handle text function + if func[0] == "*": + func = func[1:] + print(tab+func) + else: + if func != "": +## Call the glhw function + if guardbit[0:6] == "enable": + print(tab+"able["+target+"->"+elems[0]+"]("+func+");") + elif guardbit == "extensions": + print(tab+"crState$state_name",end="") + if docopy == 1: + print("Diff",end="") + else: + print("Switch",end="") + print("Extensions(from, to);") + else: + funcargs = re.split(",", func) + #print "// funcargs:",funcargs + func = funcargs.pop(0) + + if func[-1] == "v": + v_type = func[-2:-1] + num_elems = len(elems) + print(tab+v_types[v_type]+" varg["+str(num_elems)+"];") + i = 0 + for elem in elems: + print(tab+"varg["+str(i)+"] = "+target+"->"+elem+";") + i += 1 + elif func[-3:] == "vNV": + v_type = func[-4:-3] + num_elems = len(elems) + print(tab+v_types[v_type]+" varg["+str(num_elems)+"];") + i = 0 + for elem in elems: + print(tab+"varg["+str(i)+"] = "+target+"->"+elem+";") + i += 1 + + sys.stdout.write(tab+"diff_api.%(func)s("%vars()) + for funcarg in funcargs: + sys.stdout.write(funcarg+", ") + +## Handle vargs + if func[-1] == "v" or func[-3:] == "vNV": + sys.stdout.write("varg") + else: + first = 1 + for elem in elems: + if first != 1: + sys.stdout.write(",\n"+tab+" ") + first = 0 + sys.stdout.write(target+"->"+elem) + print(");") + +## Do the sync if necessary + if docopy and guardbit != "extensions": + for elem in mainelem: + print(tab+current+"->"+elem+" = "+target+"->"+elem+";") + + ## Do the clear if necessary + if doinvalid: + if guardbit != "": + print(tab+"FILLDIRTY(%(bit)s->%(guardbit)s);"%vars()) + print(tab+"FILLDIRTY(%(bit)s->dirty);"%vars()) + if extrabit != "": + print(tab+"FILLDIRTY(%(extrabit)s->dirty);"%vars()) + + ## Close the compare + if guardbit != "extensions": + tab = tab[:-1] + print(tab+"}") + +## Do final closures + if current_guard != "": + print(tab+"CLEARDIRTY(%(bit)s->%(current_guard)s, nbitID);"%vars()) + tab = tab[:-1] + print(tab+"}") + if docopy and current_dependency != "": + tab = tab[:-1] + print(tab+"} /*%(current_dependency)s*/"%vars()) + + print(tab+"CLEARDIRTY(%(bit)s->dirty, nbitID);"%vars()) + +main() diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py b/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py new file mode 100755 index 00000000..dc7da7b2 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/get_components.py @@ -0,0 +1,141 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function + +num_components = { + 'GL_AMBIENT' : 4, + 'GL_DIFFUSE' : 4, + 'GL_SPECULAR' : 4, + 'GL_POSITION' : 4, + 'GL_SPOT_DIRECTION' : 3, + 'GL_SPOT_EXPONENT' : 1, + 'GL_SPOT_CUTOFF' : 1, + 'GL_CONSTANT_ATTENUATION' : 1, + 'GL_LINEAR_ATTENUATION' : 1, + 'GL_QUADRATIC_ATTENUATION' : 1, + 'GL_EMISSION' : 4, + 'GL_SHININESS' : 1, + 'GL_COLOR_INDEXES' : 3, + 'GL_TEXTURE_ENV_MODE' : 1, + 'GL_TEXTURE_ENV_COLOR' : 4, + 'GL_TEXTURE_GEN_MODE' : 1, + 'GL_OBJECT_PLANE' : 4, + 'GL_EYE_PLANE' : 4, + 'GL_TEXTURE_MAG_FILTER' : 1, + 'GL_TEXTURE_MIN_FILTER' : 1, + 'GL_TEXTURE_WRAP_S' : 1, + 'GL_TEXTURE_WRAP_T' : 1, + 'GL_TEXTURE_BORDER_COLOR' : 4, + 'GL_TEXTURE_WIDTH': 1, + 'GL_TEXTURE_HEIGHT': 1, + 'GL_TEXTURE_DEPTH': 1, + # 'GL_TEXTURE_INTERNAL_FORMAT': 1, THIS CONFLICTS WITH GL_TEXTURE_COMPONENTS! + 'GL_TEXTURE_BORDER': 1, + 'GL_TEXTURE_RED_SIZE': 1, + 'GL_TEXTURE_GREEN_SIZE': 1, + 'GL_TEXTURE_BLUE_SIZE': 1, + 'GL_TEXTURE_ALPHA_SIZE': 1, + 'GL_TEXTURE_LUMINANCE_SIZE': 1, + 'GL_TEXTURE_INTENSITY_SIZE': 1, + 'GL_TEXTURE_COMPONENTS': 1, + 'GL_TEXTURE_RESIDENT': 1 +} + +num_extended_components = { + 'GL_TEXTURE_MAX_ANISOTROPY_EXT': ( 1, 'CR_EXT_texture_filter_anisotropic' ), + 'GL_TEXTURE_WRAP_R': ( 1, 'CR_OPENGL_VERSION_1_2'), + 'GL_TEXTURE_PRIORITY': ( 1, 'CR_OPENGL_VERSION_1_2'), + 'GL_TEXTURE_MIN_LOD': ( 1, 'CR_OPENGL_VERSION_1_2'), + 'GL_TEXTURE_MAX_LOD': ( 1, 'CR_OPENGL_VERSION_1_2'), + 'GL_TEXTURE_BASE_LEVEL': ( 1, 'CR_OPENGL_VERSION_1_2'), + 'GL_TEXTURE_MAX_LEVEL': ( 1, 'CR_OPENGL_VERSION_1_2'), + 'GL_COMBINER_INPUT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_MAPPING_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_COMPONENT_USAGE_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_AB_DOT_PRODUCT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_CD_DOT_PRODUCT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_MUX_SUM_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_SCALE_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_BIAS_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_AB_OUTPUT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_CD_OUTPUT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_SUM_OUTPUT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_INPUT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_INPUT_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_MAPPING_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_COMBINER_COMPONENT_USAGE_NV': ( 1, 'CR_NV_register_combiners'), + 'GL_CONSTANT_COLOR0_NV': ( 4, 'CR_NV_register_combiners'), + 'GL_CONSTANT_COLOR1_NV': ( 4, 'CR_NV_register_combiners'), + 'GL_COMBINE_RGB_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_COMBINE_ALPHA_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_SOURCE0_RGB_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_SOURCE1_RGB_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_SOURCE2_RGB_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_SOURCE0_ALPHA_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_SOURCE1_ALPHA_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_SOURCE2_ALPHA_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_OPERAND0_RGB_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_OPERAND1_RGB_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_OPERAND2_RGB_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_OPERAND0_ALPHA_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_OPERAND1_ALPHA_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_OPERAND2_ALPHA_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_RGB_SCALE_ARB': (1, 'CR_ARB_texture_env_combine'), + 'GL_ALPHA_SCALE': (1, 'CR_ARB_texture_env_combine'), + 'GL_DEPTH_TEXTURE_MODE_ARB': (1, 'CR_ARB_depth_texture'), + 'GL_TEXTURE_DEPTH_SIZE_ARB': (1, 'CR_ARB_depth_texture'), + 'GL_TEXTURE_COMPARE_MODE_ARB': (1, 'CR_ARB_shadow'), + 'GL_TEXTURE_COMPARE_FUNC_ARB': (1, 'CR_ARB_shadow'), + 'GL_TEXTURE_COMPARE_FAIL_VALUE_ARB': (1, 'CR_ARB_shadow_ambient'), + 'GL_GENERATE_MIPMAP_SGIS': (1, 'CR_SGIS_generate_mipmap'), + 'GL_TEXTURE_LOD_BIAS_EXT': (1, 'CR_EXT_texture_lod_bias'), + 'GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB': (1, 'CR_any_vertex_program'), + 'GL_CURRENT_VERTEX_ATTRIB_ARB': (4, 'CR_any_vertex_program'), + 'GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB': (1, 'CR_any_vertex_program'), + 'GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB': (1, 'CR_any_vertex_program'), + 'GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB': (1, 'CR_any_vertex_program'), + 'GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB': (1, 'CR_any_vertex_program'), + 'GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB': (1, 'CR_any_vertex_program'), + 'GL_TRACK_MATRIX_NV': (24, 'CR_any_vertex_program'), + 'GL_TRACK_MATRIX_TRANSFORM_NV': (24, 'CR_any_vertex_program'), + 'GL_BUFFER_SIZE_ARB': (1, 'CR_ARB_vertex_buffer_object'), + 'GL_BUFFER_USAGE_ARB': (1, 'CR_ARB_vertex_buffer_object'), + 'GL_BUFFER_ACCESS_ARB': (1, 'CR_ARB_vertex_buffer_object'), + 'GL_BUFFER_MAPPED_ARB': (1, 'CR_ARB_vertex_buffer_object'), + 'GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB': (1, 'CR_ARB_vertex_buffer_object'), + 'GL_QUERY_COUNTER_BITS_ARB': (1, 'CR_ARB_occlusion_query'), + 'GL_QUERY_RESULT_AVAILABLE_ARB': (1, 'CR_ARB_occlusion_query'), + 'GL_QUERY_RESULT_ARB': (1, 'CR_ARB_occlusion_query'), + 'GL_CURRENT_QUERY_ARB': (1, 'CR_ARB_occlusion_query'), + 'GL_TEXTURE_COMPRESSED_IMAGE_SIZE': (1, 'CR_ARB_texture_compression'), + 'GL_TEXTURE_COMPRESSED': (1, 'CR_ARB_texture_compression'), + 'GL_COORD_REPLACE_ARB': (1, 'CR_ARB_point_sprite'), +} + +print("""unsigned int crStateHlpComponentsCount( GLenum pname ) +{ + switch( pname ) + { +""") +for comp in sorted(num_components.keys()): + print('\t\t\tcase %s: return %d;' % (comp,num_components[comp])) + +for comp in sorted(num_extended_components.keys()): + (nc, ifdef) = num_extended_components[comp] + print('#ifdef %s' % ifdef) + print('\t\t\tcase %s: return %d;' % (comp,nc)) + print('#endif /* %s */' % ifdef) + +print(""" + default: + crError( "Unknown parameter name in crStateHlpComponentsCount: %d", (int) pname ); + break; + } + /* NOTREACHED */ + return 0; +} +""") + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state.h b/src/VBox/GuestHost/OpenGL/state_tracker/state.h new file mode 100644 index 00000000..9ba9d4c6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state.h @@ -0,0 +1,80 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef STATE_H +#define STATE_H + +#include "cr_glstate.h" + +#define CRSTATE_CHECKERR_RET(expr, result, message, ret) \ + if (expr) { \ + crStateError(__LINE__, __FILE__, result, message); \ + return ret; \ + } + +#define CRSTATE_NO_RETURN + +#define CRSTATE_CHECKERR(expr, result, message) CRSTATE_CHECKERR_RET(expr, result, message, CRSTATE_NO_RETURN) + +typedef struct _crCheckIDHWID { + GLuint id, hwid; +} crCheckIDHWID_t; + +extern SPUDispatchTable diff_api; +extern CRStateBits *__currentBits; + +#define GetCurrentBits() __currentBits + +#ifdef CHROMIUM_THREADSAFE +#include + +extern CRtsd __contextTSD; +#define GetCurrentContext() VBoxTlsRefGetCurrent(CRContext, &__contextTSD) + +/* NOTE: below SetCurrentContext stuff is supposed to be used only internally!! + * it is placed here only to simplify things since some code besides state_init.c + * (i.e. state_glsl.c) is using it */ +#define SetCurrentContext(_ctx) VBoxTlsRefSetCurrent(CRContext, &__contextTSD, _ctx) +#else +extern CRContext *__currentContext; +#define GetCurrentContext() __currentContext +#endif + +extern GLboolean g_bVBoxEnableDiffOnMakeCurrent; + +extern CRContext *g_pAvailableContexts[CR_MAX_CONTEXTS]; +extern uint32_t g_cContexts; + +extern void crStateTextureInitTextureObj (CRContext *ctx, CRTextureObj *tobj, GLuint name, GLenum target); +extern void crStateTextureInitTextureFormat( CRTextureLevel *tl, GLenum internalFormat ); + +/* Normally these functions would have been in cr_bufferobject.h but + * that led to a number of issues. + */ +void crStateBufferObjectInit(CRContext *ctx); + +void crStateBufferObjectDestroy (CRContext *ctx); + +void crStateBufferObjectDiff(CRBufferObjectBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +void crStateBufferObjectSwitch(CRBufferObjectBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx); + +/* These would normally be in cr_client.h */ + +void crStateClientDiff(CRClientBits *cb, CRbitvalue *bitID, CRContext *from, CRContext *to); + +void crStateClientSwitch(CRClientBits *cb, CRbitvalue *bitID, CRContext *from, CRContext *to); + +void crStateFreeBufferObject(void *data); +void crStateFreeFBO(void *data); +void crStateFreeRBO(void *data); + +void crStateGenNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names); +void crStateRegNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names); +void crStateOnTextureUsageRelease(CRSharedState *pS, CRTextureObj *pObj); +#endif diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_attrib.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_attrib.c new file mode 100644 index 00000000..a226a8d7 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_attrib.c @@ -0,0 +1,1185 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" +#include "cr_error.h" +#include "cr_mem.h" + +/** + * \mainpage state_tracker + * + * \section StateTrackerIntroduction Introduction + * + * Chromium consists of all the top-level files in the cr + * directory. The state_tracker module basically takes care of API dispatch, + * and OpenGL state management. + * + * + */ +void crStateAttribInit (CRAttribState *a) +{ + int i; + a->attribStackDepth = 0; + a->accumBufferStackDepth = 0; + a->colorBufferStackDepth = 0; + a->currentStackDepth = 0; + a->depthBufferStackDepth = 0; + a->enableStackDepth = 0; + for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++) + { + a->enableStack[i].clip = NULL; + a->enableStack[i].light = NULL; + a->lightingStack[i].light = NULL; + a->transformStack[i].clip = NULL; + a->transformStack[i].clipPlane = NULL; + } + a->evalStackDepth = 0; + a->fogStackDepth = 0; + a->lightingStackDepth = 0; + a->lineStackDepth = 0; + a->listStackDepth = 0; + a->pixelModeStackDepth = 0; + a->pointStackDepth = 0; + a->polygonStackDepth = 0; + a->polygonStippleStackDepth = 0; + a->scissorStackDepth = 0; + a->stencilBufferStackDepth = 0; + a->textureStackDepth = 0; + a->transformStackDepth = 0; + a->viewportStackDepth = 0; +} + +/** @todo check if NV rect needed too*/ +static void +copy_texunit(CRTextureUnit *dest, const CRTextureUnit *src) +{ + dest->enabled1D = src->enabled1D; + dest->enabled2D = src->enabled2D; + dest->enabled3D = src->enabled3D; + dest->enabledCubeMap = src->enabledCubeMap; + dest->envMode = src->envMode; + dest->envColor = src->envColor; + dest->textureGen = src->textureGen; + dest->objSCoeff = src->objSCoeff; + dest->objTCoeff = src->objTCoeff; + dest->objRCoeff = src->objRCoeff; + dest->objQCoeff = src->objQCoeff; + dest->eyeSCoeff = src->eyeSCoeff; + dest->eyeTCoeff = src->eyeTCoeff; + dest->eyeRCoeff = src->eyeRCoeff; + dest->eyeQCoeff = src->eyeQCoeff; + dest->gen = src->gen; + dest->currentTexture1D = src->currentTexture1D; + dest->currentTexture2D = src->currentTexture2D; + dest->currentTexture3D = src->currentTexture3D; + dest->currentTextureCubeMap = src->currentTextureCubeMap; +} + +static void +copy_texobj(CRTextureObj *dest, CRTextureObj *src, GLboolean copyName) +{ + if (copyName) + { + dest->id = src->id; + dest->hwid = crStateGetTextureObjHWID(src); + } + + dest->borderColor = src->borderColor; + dest->wrapS = src->wrapS; + dest->wrapT = src->wrapT; + dest->minFilter = src->minFilter; + dest->magFilter = src->magFilter; +#ifdef CR_OPENGL_VERSION_1_2 + dest->priority = src->priority; + dest->wrapR = src->wrapR; + dest->minLod = src->minLod; + dest->maxLod = src->maxLod; + dest->baseLevel = src->baseLevel; + dest->maxLevel = src->maxLevel; +#endif +#ifdef CR_EXT_texture_filter_anisotropic + dest->maxAnisotropy = src->maxAnisotropy; +#endif +} + +void STATE_APIENTRY crStatePushAttrib(GLbitfield mask) +{ + CRContext *g = GetCurrentContext(); + CRAttribState *a = &(g->attrib); + CRStateBits *sb = GetCurrentBits(); + CRAttribBits *ab = &(sb->attrib); + unsigned int i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPushAttrib called in Begin/End"); + return; + } + + if (a->attribStackDepth == CR_MAX_ATTRIB_STACK_DEPTH - 1) + { + crStateError(__LINE__, __FILE__, GL_STACK_OVERFLOW, "glPushAttrib called with a full stack!" ); + return; + } + + FLUSH(); + + a->pushMaskStack[a->attribStackDepth++] = mask; + + if (mask & GL_ACCUM_BUFFER_BIT) + { + a->accumBufferStack[a->accumBufferStackDepth].accumClearValue = g->buffer.accumClearValue; + a->accumBufferStackDepth++; + } + if (mask & GL_COLOR_BUFFER_BIT) + { + a->colorBufferStack[a->colorBufferStackDepth].alphaTest = g->buffer.alphaTest; + a->colorBufferStack[a->colorBufferStackDepth].alphaTestFunc = g->buffer.alphaTestFunc; + a->colorBufferStack[a->colorBufferStackDepth].alphaTestRef = g->buffer.alphaTestRef; + a->colorBufferStack[a->colorBufferStackDepth].blend = g->buffer.blend; + a->colorBufferStack[a->colorBufferStackDepth].blendSrcRGB = g->buffer.blendSrcRGB; + a->colorBufferStack[a->colorBufferStackDepth].blendDstRGB = g->buffer.blendDstRGB; +#if defined(CR_EXT_blend_func_separate) + a->colorBufferStack[a->colorBufferStackDepth].blendSrcA = g->buffer.blendSrcA; + a->colorBufferStack[a->colorBufferStackDepth].blendDstA = g->buffer.blendDstA; +#endif +#ifdef CR_EXT_blend_color + a->colorBufferStack[a->colorBufferStackDepth].blendColor = g->buffer.blendColor; +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) + a->colorBufferStack[a->colorBufferStackDepth].blendEquation = g->buffer.blendEquation; +#endif + a->colorBufferStack[a->colorBufferStackDepth].dither = g->buffer.dither; + a->colorBufferStack[a->colorBufferStackDepth].drawBuffer = g->buffer.drawBuffer; + a->colorBufferStack[a->colorBufferStackDepth].logicOp = g->buffer.logicOp; + a->colorBufferStack[a->colorBufferStackDepth].indexLogicOp = g->buffer.indexLogicOp; + a->colorBufferStack[a->colorBufferStackDepth].logicOpMode = g->buffer.logicOpMode; + a->colorBufferStack[a->colorBufferStackDepth].colorClearValue = g->buffer.colorClearValue; + a->colorBufferStack[a->colorBufferStackDepth].indexClearValue = g->buffer.indexClearValue; + a->colorBufferStack[a->colorBufferStackDepth].colorWriteMask = g->buffer.colorWriteMask; + a->colorBufferStack[a->colorBufferStackDepth].indexWriteMask = g->buffer.indexWriteMask; + a->colorBufferStackDepth++; + } + if (mask & GL_CURRENT_BIT) + { + for (i = 0 ; i < CR_MAX_VERTEX_ATTRIBS ; i++) + { + COPY_4V(a->currentStack[a->currentStackDepth].attrib[i] , g->current.vertexAttrib[i]); + COPY_4V(a->currentStack[a->currentStackDepth].rasterAttrib[i] , g->current.rasterAttrib[i]); + } + a->currentStack[a->currentStackDepth].rasterValid = g->current.rasterValid; + a->currentStack[a->currentStackDepth].edgeFlag = g->current.edgeFlag; + a->currentStack[a->currentStackDepth].colorIndex = g->current.colorIndex; + a->currentStackDepth++; + } + if (mask & GL_DEPTH_BUFFER_BIT) + { + a->depthBufferStack[a->depthBufferStackDepth].depthTest = g->buffer.depthTest; + a->depthBufferStack[a->depthBufferStackDepth].depthFunc = g->buffer.depthFunc; + a->depthBufferStack[a->depthBufferStackDepth].depthClearValue = g->buffer.depthClearValue; + a->depthBufferStack[a->depthBufferStackDepth].depthMask = g->buffer.depthMask; + a->depthBufferStackDepth++; + } + if (mask & GL_ENABLE_BIT) + { + if (a->enableStack[a->enableStackDepth].clip == NULL) + { + a->enableStack[a->enableStackDepth].clip = (GLboolean *) crCalloc( g->limits.maxClipPlanes * sizeof( GLboolean )); + } + if (a->enableStack[a->enableStackDepth].light == NULL) + { + a->enableStack[a->enableStackDepth].light = (GLboolean *) crCalloc( g->limits.maxLights * sizeof( GLboolean )); + } + a->enableStack[a->enableStackDepth].alphaTest = g->buffer.alphaTest; + a->enableStack[a->enableStackDepth].autoNormal = g->eval.autoNormal; + a->enableStack[a->enableStackDepth].blend = g->buffer.blend; + for (i = 0 ; i < g->limits.maxClipPlanes ; i++) + { + a->enableStack[a->enableStackDepth].clip[i] = g->transform.clip[i]; + } + a->enableStack[a->enableStackDepth].colorMaterial = g->lighting.colorMaterial; + a->enableStack[a->enableStackDepth].cullFace = g->polygon.cullFace; + a->enableStack[a->enableStackDepth].depthTest = g->buffer.depthTest; + a->enableStack[a->enableStackDepth].dither = g->buffer.dither; + a->enableStack[a->enableStackDepth].fog = g->fog.enable; + for (i = 0 ; i < g->limits.maxLights ; i++) + { + a->enableStack[a->enableStackDepth].light[i] = g->lighting.light[i].enable; + } + a->enableStack[a->enableStackDepth].lighting = g->lighting.lighting; + a->enableStack[a->enableStackDepth].lineSmooth = g->line.lineSmooth; + a->enableStack[a->enableStackDepth].lineStipple = g->line.lineStipple; + a->enableStack[a->enableStackDepth].logicOp = g->buffer.logicOp; + a->enableStack[a->enableStackDepth].indexLogicOp = g->buffer.indexLogicOp; + for (i = 0 ; i < GLEVAL_TOT ; i++) + { + a->enableStack[a->enableStackDepth].map1[i] = g->eval.enable1D[i]; + a->enableStack[a->enableStackDepth].map2[i] = g->eval.enable2D[i]; + } + a->enableStack[a->enableStackDepth].normalize = g->transform.normalize; + a->enableStack[a->enableStackDepth].pointSmooth = g->point.pointSmooth; +#if CR_ARB_point_sprite + a->enableStack[a->enableStackDepth].pointSprite = g->point.pointSprite; + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) + a->enableStack[a->enableStackDepth].coordReplacement[i] = g->point.coordReplacement[i]; +#endif + a->enableStack[a->enableStackDepth].polygonOffsetLine = g->polygon.polygonOffsetLine; + a->enableStack[a->enableStackDepth].polygonOffsetFill = g->polygon.polygonOffsetFill; + a->enableStack[a->enableStackDepth].polygonOffsetPoint = g->polygon.polygonOffsetPoint; + a->enableStack[a->enableStackDepth].polygonSmooth = g->polygon.polygonSmooth; + a->enableStack[a->enableStackDepth].polygonStipple = g->polygon.polygonStipple; +#ifdef CR_OPENGL_VERSION_1_2 + a->enableStack[a->enableStackDepth].rescaleNormals = g->transform.rescaleNormals; +#endif + a->enableStack[a->enableStackDepth].scissorTest = g->viewport.scissorTest; + a->enableStack[a->enableStackDepth].stencilTest = g->stencil.stencilTest; + for (i = 0 ; i < g->limits.maxTextureUnits; i++) + { + a->enableStack[a->enableStackDepth].texture1D[i] = g->texture.unit[i].enabled1D; + a->enableStack[a->enableStackDepth].texture2D[i] = g->texture.unit[i].enabled2D; +#ifdef CR_OPENGL_VERSION_1_2 + a->enableStack[a->enableStackDepth].texture3D[i] = g->texture.unit[i].enabled3D; +#endif +#ifdef CR_ARB_texture_cube_map + a->enableStack[a->enableStackDepth].textureCubeMap[i] = g->texture.unit[i].enabledCubeMap; +#endif +#ifdef CR_NV_texture_rectangle + a->enableStack[a->enableStackDepth].textureRect[i] = g->texture.unit[i].enabledRect; +#endif + a->enableStack[a->enableStackDepth].textureGenS[i] = g->texture.unit[i].textureGen.s; + a->enableStack[a->enableStackDepth].textureGenT[i] = g->texture.unit[i].textureGen.t; + a->enableStack[a->enableStackDepth].textureGenR[i] = g->texture.unit[i].textureGen.r; + a->enableStack[a->enableStackDepth].textureGenQ[i] = g->texture.unit[i].textureGen.q; + } + a->enableStackDepth++; + } + if (mask & GL_EVAL_BIT) + { + for (i = 0 ; i < GLEVAL_TOT ; i++) + { + int size1 = g->eval.eval1D[i].order * gleval_sizes[i] * + sizeof (GLfloat); + int size2 = g->eval.eval2D[i].uorder * g->eval.eval2D[i].vorder * + gleval_sizes[i] * sizeof (GLfloat); + a->evalStack[a->evalStackDepth].enable1D[i] = g->eval.enable1D[i]; + a->evalStack[a->evalStackDepth].enable2D[i] = g->eval.enable2D[i]; + a->evalStack[a->evalStackDepth].eval1D[i].u1 = g->eval.eval1D[i].u1; + a->evalStack[a->evalStackDepth].eval1D[i].u2 = g->eval.eval1D[i].u2; + a->evalStack[a->evalStackDepth].eval1D[i].order = g->eval.eval1D[i].order; + a->evalStack[a->evalStackDepth].eval1D[i].coeff = (GLfloat*)crCalloc(size1); + crMemcpy(a->evalStack[a->evalStackDepth].eval1D[i].coeff, g->eval.eval1D[i].coeff, size1); + a->evalStack[a->evalStackDepth].eval2D[i].u1 = g->eval.eval2D[i].u1; + a->evalStack[a->evalStackDepth].eval2D[i].u2 = g->eval.eval2D[i].u2; + a->evalStack[a->evalStackDepth].eval2D[i].v1 = g->eval.eval2D[i].v1; + a->evalStack[a->evalStackDepth].eval2D[i].v2 = g->eval.eval2D[i].v2; + a->evalStack[a->evalStackDepth].eval2D[i].uorder = g->eval.eval2D[i].uorder; + a->evalStack[a->evalStackDepth].eval2D[i].vorder = g->eval.eval2D[i].vorder; + a->evalStack[a->evalStackDepth].eval2D[i].coeff = (GLfloat*)crCalloc(size2); + crMemcpy(a->evalStack[a->evalStackDepth].eval2D[i].coeff, g->eval.eval2D[i].coeff, size2); + } + a->evalStack[a->evalStackDepth].autoNormal = g->eval.autoNormal; + a->evalStack[a->evalStackDepth].un1D = g->eval.un1D; + a->evalStack[a->evalStackDepth].u11D = g->eval.u11D; + a->evalStack[a->evalStackDepth].u21D = g->eval.u21D; + a->evalStack[a->evalStackDepth].un2D = g->eval.un2D; + a->evalStack[a->evalStackDepth].u12D = g->eval.u12D; + a->evalStack[a->evalStackDepth].u22D = g->eval.u22D; + a->evalStack[a->evalStackDepth].vn2D = g->eval.vn2D; + a->evalStack[a->evalStackDepth].v12D = g->eval.v12D; + a->evalStack[a->evalStackDepth].v22D = g->eval.v22D; + a->evalStackDepth++; + } + if (mask & GL_FOG_BIT) + { + a->fogStack[a->fogStackDepth].enable = g->fog.enable; + a->fogStack[a->fogStackDepth].color = g->fog.color; + a->fogStack[a->fogStackDepth].density = g->fog.density; + a->fogStack[a->fogStackDepth].start = g->fog.start; + a->fogStack[a->fogStackDepth].end = g->fog.end; + a->fogStack[a->fogStackDepth].index = g->fog.index; + a->fogStack[a->fogStackDepth].mode = g->fog.mode; + a->fogStackDepth++; + } + if (mask & GL_HINT_BIT) + { + a->hintStack[a->hintStackDepth].perspectiveCorrection = g->hint.perspectiveCorrection; + a->hintStack[a->hintStackDepth].pointSmooth = g->hint.pointSmooth; + a->hintStack[a->hintStackDepth].lineSmooth = g->hint.lineSmooth; + a->hintStack[a->hintStackDepth].polygonSmooth = g->hint.polygonSmooth; + a->hintStack[a->hintStackDepth].fog = g->hint.fog; +#ifdef CR_EXT_clip_volume_hint + a->hintStack[a->hintStackDepth].clipVolumeClipping = g->hint.clipVolumeClipping; +#endif +#ifdef CR_ARB_texture_compression + a->hintStack[a->hintStackDepth].textureCompression = g->hint.textureCompression; +#endif +#ifdef CR_SGIS_generate_mipmap + a->hintStack[a->hintStackDepth].generateMipmap = g->hint.generateMipmap; +#endif + a->hintStackDepth++; + } + if (mask & GL_LIGHTING_BIT) + { + if (a->lightingStack[a->lightingStackDepth].light == NULL) + { + a->lightingStack[a->lightingStackDepth].light = (CRLight *) crCalloc( g->limits.maxLights * sizeof( CRLight )); + } + a->lightingStack[a->lightingStackDepth].lightModelAmbient = g->lighting.lightModelAmbient; + a->lightingStack[a->lightingStackDepth].lightModelLocalViewer = g->lighting.lightModelLocalViewer; + a->lightingStack[a->lightingStackDepth].lightModelTwoSide = g->lighting.lightModelTwoSide; +#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2) + a->lightingStack[a->lightingStackDepth].lightModelColorControlEXT = g->lighting.lightModelColorControlEXT; +#endif + a->lightingStack[a->lightingStackDepth].lighting = g->lighting.lighting; + a->lightingStack[a->lightingStackDepth].colorMaterial = g->lighting.colorMaterial; + a->lightingStack[a->lightingStackDepth].colorMaterialMode = g->lighting.colorMaterialMode; + a->lightingStack[a->lightingStackDepth].colorMaterialFace = g->lighting.colorMaterialFace; + for (i = 0 ; i < g->limits.maxLights; i++) + { + a->lightingStack[a->lightingStackDepth].light[i].enable = g->lighting.light[i].enable; + a->lightingStack[a->lightingStackDepth].light[i].ambient = g->lighting.light[i].ambient; + a->lightingStack[a->lightingStackDepth].light[i].diffuse = g->lighting.light[i].diffuse; + a->lightingStack[a->lightingStackDepth].light[i].specular = g->lighting.light[i].specular; + a->lightingStack[a->lightingStackDepth].light[i].spotDirection = g->lighting.light[i].spotDirection; + a->lightingStack[a->lightingStackDepth].light[i].position = g->lighting.light[i].position; + a->lightingStack[a->lightingStackDepth].light[i].spotExponent = g->lighting.light[i].spotExponent; + a->lightingStack[a->lightingStackDepth].light[i].spotCutoff = g->lighting.light[i].spotCutoff; + a->lightingStack[a->lightingStackDepth].light[i].constantAttenuation = g->lighting.light[i].constantAttenuation; + a->lightingStack[a->lightingStackDepth].light[i].linearAttenuation = g->lighting.light[i].linearAttenuation; + a->lightingStack[a->lightingStackDepth].light[i].quadraticAttenuation = g->lighting.light[i].quadraticAttenuation; + } + for (i = 0 ; i < 2 ; i++) + { + a->lightingStack[a->lightingStackDepth].ambient[i] = g->lighting.ambient[i]; + a->lightingStack[a->lightingStackDepth].diffuse[i] = g->lighting.diffuse[i]; + a->lightingStack[a->lightingStackDepth].specular[i] = g->lighting.specular[i]; + a->lightingStack[a->lightingStackDepth].emission[i] = g->lighting.emission[i]; + a->lightingStack[a->lightingStackDepth].shininess[i] = g->lighting.shininess[i]; + a->lightingStack[a->lightingStackDepth].indexes[i][0] = g->lighting.indexes[i][0]; + a->lightingStack[a->lightingStackDepth].indexes[i][1] = g->lighting.indexes[i][1]; + a->lightingStack[a->lightingStackDepth].indexes[i][2] = g->lighting.indexes[i][2]; + } + a->lightingStack[a->lightingStackDepth].shadeModel = g->lighting.shadeModel; + a->lightingStackDepth++; + } + if (mask & GL_LINE_BIT) + { + a->lineStack[a->lineStackDepth].lineSmooth = g->line.lineSmooth; + a->lineStack[a->lineStackDepth].lineStipple = g->line.lineStipple; + a->lineStack[a->lineStackDepth].pattern = g->line.pattern; + a->lineStack[a->lineStackDepth].repeat = g->line.repeat; + a->lineStack[a->lineStackDepth].width = g->line.width; + a->lineStackDepth++; + } + if (mask & GL_LIST_BIT) + { + a->listStack[a->listStackDepth].base = g->lists.base; + a->listStackDepth++; + } + if (mask & GL_PIXEL_MODE_BIT) + { + a->pixelModeStack[a->pixelModeStackDepth].bias = g->pixel.bias; + a->pixelModeStack[a->pixelModeStackDepth].scale = g->pixel.scale; + a->pixelModeStack[a->pixelModeStackDepth].indexOffset = g->pixel.indexOffset; + a->pixelModeStack[a->pixelModeStackDepth].indexShift = g->pixel.indexShift; + a->pixelModeStack[a->pixelModeStackDepth].mapColor = g->pixel.mapColor; + a->pixelModeStack[a->pixelModeStackDepth].mapStencil = g->pixel.mapStencil; + a->pixelModeStack[a->pixelModeStackDepth].xZoom = g->pixel.xZoom; + a->pixelModeStack[a->pixelModeStackDepth].yZoom = g->pixel.yZoom; + a->pixelModeStack[a->pixelModeStackDepth].readBuffer = g->buffer.readBuffer; + a->pixelModeStackDepth++; + } + if (mask & GL_POINT_BIT) + { + a->pointStack[a->pointStackDepth].pointSmooth = g->point.pointSmooth; +#if CR_ARB_point_sprite + a->pointStack[a->pointStackDepth].pointSprite = g->point.pointSprite; + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) + a->pointStack[a->enableStackDepth].coordReplacement[i] = g->point.coordReplacement[i]; +#endif + a->pointStack[a->pointStackDepth].pointSize = g->point.pointSize; + a->pointStackDepth++; + } + if (mask & GL_POLYGON_BIT) + { + a->polygonStack[a->polygonStackDepth].cullFace = g->polygon.cullFace; + a->polygonStack[a->polygonStackDepth].cullFaceMode = g->polygon.cullFaceMode; + a->polygonStack[a->polygonStackDepth].frontFace = g->polygon.frontFace; + a->polygonStack[a->polygonStackDepth].frontMode = g->polygon.frontMode; + a->polygonStack[a->polygonStackDepth].backMode = g->polygon.backMode; + a->polygonStack[a->polygonStackDepth].polygonSmooth = g->polygon.polygonSmooth; + a->polygonStack[a->polygonStackDepth].polygonStipple = g->polygon.polygonStipple; + a->polygonStack[a->polygonStackDepth].polygonOffsetFill = g->polygon.polygonOffsetFill; + a->polygonStack[a->polygonStackDepth].polygonOffsetLine = g->polygon.polygonOffsetLine; + a->polygonStack[a->polygonStackDepth].polygonOffsetPoint = g->polygon.polygonOffsetPoint; + a->polygonStack[a->polygonStackDepth].offsetFactor = g->polygon.offsetFactor; + a->polygonStack[a->polygonStackDepth].offsetUnits = g->polygon.offsetUnits; + a->polygonStackDepth++; + } + if (mask & GL_POLYGON_STIPPLE_BIT) + { + crMemcpy( a->polygonStippleStack[a->polygonStippleStackDepth].pattern, g->polygon.stipple, 32*sizeof(GLint) ); + a->polygonStippleStackDepth++; + } + if (mask & GL_SCISSOR_BIT) + { + a->scissorStack[a->scissorStackDepth].scissorTest = g->viewport.scissorTest; + a->scissorStack[a->scissorStackDepth].scissorX = g->viewport.scissorX; + a->scissorStack[a->scissorStackDepth].scissorY = g->viewport.scissorY; + a->scissorStack[a->scissorStackDepth].scissorW = g->viewport.scissorW; + a->scissorStack[a->scissorStackDepth].scissorH = g->viewport.scissorH; + a->scissorStackDepth++; + } + if (mask & GL_STENCIL_BUFFER_BIT) + { + a->stencilBufferStack[a->stencilBufferStackDepth].stencilTest = g->stencil.stencilTest; + a->stencilBufferStack[a->stencilBufferStackDepth].clearValue = g->stencil.clearValue; + a->stencilBufferStack[a->stencilBufferStackDepth].writeMask = g->stencil.writeMask; + for (i = 0; i < CRSTATE_STENCIL_BUFFER_COUNT; ++i) + { + a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].func = g->stencil.buffers[i].func; + a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].mask = g->stencil.buffers[i].mask; + a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].ref = g->stencil.buffers[i].ref; + a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].fail = g->stencil.buffers[i].fail; + a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthFail = g->stencil.buffers[i].passDepthFail; + a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthPass = g->stencil.buffers[i].passDepthPass; + } + a->stencilBufferStackDepth++; + } + if (mask & GL_TEXTURE_BIT) + { + CRTextureStack *tState = a->textureStack + a->textureStackDepth; + tState->curTextureUnit = g->texture.curTextureUnit; + for (i = 0 ; i < g->limits.maxTextureUnits ; i++) + { + /* per-unit state */ + copy_texunit(&tState->unit[i], &g->texture.unit[i]); + /* texture object state */ + copy_texobj(&tState->unit[i].Saved1D, g->texture.unit[i].currentTexture1D, GL_TRUE); + copy_texobj(&tState->unit[i].Saved2D, g->texture.unit[i].currentTexture2D, GL_TRUE); +#ifdef CR_OPENGL_VERSION_1_2 + copy_texobj(&tState->unit[i].Saved3D, g->texture.unit[i].currentTexture3D, GL_TRUE); +#endif +#ifdef CR_ARB_texture_cube_map + copy_texobj(&tState->unit[i].SavedCubeMap, g->texture.unit[i].currentTextureCubeMap, GL_TRUE); +#endif +#ifdef CR_NV_texture_rectangle + copy_texobj(&tState->unit[i].SavedRect, g->texture.unit[i].currentTextureRect, GL_TRUE); +#endif + } + a->textureStackDepth++; + } + if (mask & GL_TRANSFORM_BIT) + { + if (a->transformStack[a->transformStackDepth].clip == NULL) + { + a->transformStack[a->transformStackDepth].clip = (GLboolean *) crCalloc( g->limits.maxClipPlanes * sizeof( GLboolean )); + } + if (a->transformStack[a->transformStackDepth].clipPlane == NULL) + { + a->transformStack[a->transformStackDepth].clipPlane = (GLvectord *) crCalloc( g->limits.maxClipPlanes * sizeof( GLvectord )); + } + a->transformStack[a->transformStackDepth].matrixMode = g->transform.matrixMode; + for (i = 0 ; i < g->limits.maxClipPlanes ; i++) + { + a->transformStack[a->transformStackDepth].clip[i] = g->transform.clip[i]; + a->transformStack[a->transformStackDepth].clipPlane[i] = g->transform.clipPlane[i]; + } + a->transformStack[a->transformStackDepth].normalize = g->transform.normalize; +#ifdef CR_OPENGL_VERSION_1_2 + a->transformStack[a->transformStackDepth].rescaleNormals = g->transform.rescaleNormals; +#endif + a->transformStackDepth++; + } + if (mask & GL_VIEWPORT_BIT) + { + a->viewportStack[a->viewportStackDepth].viewportX = g->viewport.viewportX; + a->viewportStack[a->viewportStackDepth].viewportY = g->viewport.viewportY; + a->viewportStack[a->viewportStackDepth].viewportW = g->viewport.viewportW; + a->viewportStack[a->viewportStackDepth].viewportH = g->viewport.viewportH; + a->viewportStack[a->viewportStackDepth].nearClip = g->viewport.nearClip; + a->viewportStack[a->viewportStackDepth].farClip = g->viewport.farClip; + a->viewportStackDepth++; + } + + DIRTY(ab->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePopAttrib(void) +{ + CRContext *g = GetCurrentContext(); + CRAttribState *a = &(g->attrib); + CRStateBits *sb = GetCurrentBits(); + CRAttribBits *ab = &(sb->attrib); + CRbitvalue mask; + unsigned int i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPopAttrib called in Begin/End"); + return; + } + + if (a->attribStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty stack!" ); + return; + } + + FLUSH(); + + mask = a->pushMaskStack[--a->attribStackDepth]; + + if (mask & GL_ACCUM_BUFFER_BIT) + { + if (a->accumBufferStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty accum buffer stack!" ); + return; + } + a->accumBufferStackDepth--; + g->buffer.accumClearValue = a->accumBufferStack[a->accumBufferStackDepth].accumClearValue; + DIRTY(sb->buffer.dirty, g->neg_bitid); + DIRTY(sb->buffer.clearAccum, g->neg_bitid); + } + if (mask & GL_COLOR_BUFFER_BIT) + { + if (a->colorBufferStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty color buffer stack!" ); + return; + } + a->colorBufferStackDepth--; + g->buffer.alphaTest = a->colorBufferStack[a->colorBufferStackDepth].alphaTest; + g->buffer.alphaTestFunc = a->colorBufferStack[a->colorBufferStackDepth].alphaTestFunc; + g->buffer.alphaTestRef = a->colorBufferStack[a->colorBufferStackDepth].alphaTestRef; + g->buffer.blend = a->colorBufferStack[a->colorBufferStackDepth].blend; + g->buffer.blendSrcRGB = a->colorBufferStack[a->colorBufferStackDepth].blendSrcRGB; + g->buffer.blendDstRGB = a->colorBufferStack[a->colorBufferStackDepth].blendDstRGB; +#if defined(CR_EXT_blend_func_separate) + g->buffer.blendSrcA = a->colorBufferStack[a->colorBufferStackDepth].blendSrcA; + g->buffer.blendDstA = a->colorBufferStack[a->colorBufferStackDepth].blendDstA; +#endif +#ifdef CR_EXT_blend_color + g->buffer.blendColor = a->colorBufferStack[a->colorBufferStackDepth].blendColor; +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) + g->buffer.blendEquation = a->colorBufferStack[a->colorBufferStackDepth].blendEquation; +#endif + g->buffer.dither = a->colorBufferStack[a->colorBufferStackDepth].dither; + g->buffer.drawBuffer = a->colorBufferStack[a->colorBufferStackDepth].drawBuffer; + g->buffer.logicOp = a->colorBufferStack[a->colorBufferStackDepth].logicOp; + g->buffer.indexLogicOp = a->colorBufferStack[a->colorBufferStackDepth].indexLogicOp; + g->buffer.logicOpMode = a->colorBufferStack[a->colorBufferStackDepth].logicOpMode; + g->buffer.colorClearValue = a->colorBufferStack[a->colorBufferStackDepth].colorClearValue; + g->buffer.indexClearValue = a->colorBufferStack[a->colorBufferStackDepth].indexClearValue; + g->buffer.colorWriteMask = a->colorBufferStack[a->colorBufferStackDepth].colorWriteMask; + g->buffer.indexWriteMask = a->colorBufferStack[a->colorBufferStackDepth].indexWriteMask; + DIRTY(sb->buffer.dirty, g->neg_bitid); + DIRTY(sb->buffer.enable, g->neg_bitid); + DIRTY(sb->buffer.alphaFunc, g->neg_bitid); + DIRTY(sb->buffer.blendFunc, g->neg_bitid); +#ifdef CR_EXT_blend_color + DIRTY(sb->buffer.blendColor, g->neg_bitid); +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) + DIRTY(sb->buffer.blendEquation, g->neg_bitid); +#endif + DIRTY(sb->buffer.drawBuffer, g->neg_bitid); + DIRTY(sb->buffer.logicOp, g->neg_bitid); + DIRTY(sb->buffer.indexLogicOp, g->neg_bitid); + DIRTY(sb->buffer.clearColor, g->neg_bitid); + DIRTY(sb->buffer.clearIndex, g->neg_bitid); + DIRTY(sb->buffer.colorWriteMask, g->neg_bitid); + DIRTY(sb->buffer.indexMask, g->neg_bitid); + } + if (mask & GL_CURRENT_BIT) + { + if (a->currentStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty current stack!" ); + return; + } + a->currentStackDepth--; + for (i = 0 ; i < CR_MAX_VERTEX_ATTRIBS ; i++) + { + COPY_4V(g->current.vertexAttrib[i], a->currentStack[a->currentStackDepth].attrib[i]); + COPY_4V(g->current.rasterAttrib[i], a->currentStack[a->currentStackDepth].rasterAttrib[i]); + DIRTY(sb->current.vertexAttrib[i], g->neg_bitid); + } + g->current.rasterValid = a->currentStack[a->currentStackDepth].rasterValid; + g->current.edgeFlag = a->currentStack[a->currentStackDepth].edgeFlag; + g->current.colorIndex = a->currentStack[a->currentStackDepth].colorIndex; + DIRTY(sb->current.dirty, g->neg_bitid); + DIRTY(sb->current.edgeFlag, g->neg_bitid); + DIRTY(sb->current.colorIndex, g->neg_bitid); + DIRTY(sb->current.rasterPos, g->neg_bitid); + } + if (mask & GL_DEPTH_BUFFER_BIT) + { + if (a->depthBufferStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty depth buffer stack!" ); + return; + } + a->depthBufferStackDepth--; + g->buffer.depthTest = a->depthBufferStack[a->depthBufferStackDepth].depthTest; + g->buffer.depthFunc = a->depthBufferStack[a->depthBufferStackDepth].depthFunc; + g->buffer.depthClearValue = a->depthBufferStack[a->depthBufferStackDepth].depthClearValue; + g->buffer.depthMask = a->depthBufferStack[a->depthBufferStackDepth].depthMask; + DIRTY(sb->buffer.dirty, g->neg_bitid); + DIRTY(sb->buffer.enable, g->neg_bitid); + DIRTY(sb->buffer.depthFunc, g->neg_bitid); + DIRTY(sb->buffer.clearDepth, g->neg_bitid); + DIRTY(sb->buffer.depthMask, g->neg_bitid); + } + if (mask & GL_ENABLE_BIT) + { + if (a->enableStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty enable stack!" ); + return; + } + a->enableStackDepth--; + g->buffer.alphaTest = a->enableStack[a->enableStackDepth].alphaTest; + g->eval.autoNormal = a->enableStack[a->enableStackDepth].autoNormal; + g->buffer.blend = a->enableStack[a->enableStackDepth].blend; + for (i = 0 ; i < g->limits.maxClipPlanes ; i++) + { + g->transform.clip[i] = a->enableStack[a->enableStackDepth].clip[i]; + } + g->lighting.colorMaterial = a->enableStack[a->enableStackDepth].colorMaterial; + g->polygon.cullFace = a->enableStack[a->enableStackDepth].cullFace; + g->buffer.depthTest = a->enableStack[a->enableStackDepth].depthTest; + g->buffer.dither = a->enableStack[a->enableStackDepth].dither; + g->fog.enable = a->enableStack[a->enableStackDepth].fog; + for (i = 0 ; i < g->limits.maxLights ; i++) + { + g->lighting.light[i].enable = a->enableStack[a->enableStackDepth].light[i]; + } + g->lighting.lighting = a->enableStack[a->enableStackDepth].lighting; + g->line.lineSmooth = a->enableStack[a->enableStackDepth].lineSmooth; + g->line.lineStipple = a->enableStack[a->enableStackDepth].lineStipple; + g->buffer.logicOp = a->enableStack[a->enableStackDepth].logicOp; + g->buffer.indexLogicOp = a->enableStack[a->enableStackDepth].indexLogicOp; + for (i = 0 ; i < GLEVAL_TOT ; i++) + { + g->eval.enable1D[i] = a->enableStack[a->enableStackDepth].map1[i]; + g->eval.enable2D[i] = a->enableStack[a->enableStackDepth].map2[i]; + } + g->transform.normalize = a->enableStack[a->enableStackDepth].normalize; + g->point.pointSmooth = a->enableStack[a->enableStackDepth].pointSmooth; +#ifdef CR_ARB_point_sprite + g->point.pointSprite = a->enableStack[a->enableStackDepth].pointSprite; + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) + g->point.coordReplacement[i] = a->enableStack[a->enableStackDepth].coordReplacement[i]; +#endif + g->polygon.polygonOffsetLine = a->enableStack[a->enableStackDepth].polygonOffsetLine; + g->polygon.polygonOffsetFill = a->enableStack[a->enableStackDepth].polygonOffsetFill; + g->polygon.polygonOffsetPoint = a->enableStack[a->enableStackDepth].polygonOffsetPoint; + g->polygon.polygonSmooth = a->enableStack[a->enableStackDepth].polygonSmooth; + g->polygon.polygonStipple = a->enableStack[a->enableStackDepth].polygonStipple; +#ifdef CR_OPENGL_VERSION_1_2 + g->transform.rescaleNormals = a->enableStack[a->enableStackDepth].rescaleNormals; +#endif + g->viewport.scissorTest = a->enableStack[a->enableStackDepth].scissorTest; + g->stencil.stencilTest = a->enableStack[a->enableStackDepth].stencilTest; + for (i = 0 ; i < g->limits.maxTextureUnits; i++) + { + g->texture.unit[i].enabled1D = a->enableStack[a->enableStackDepth].texture1D[i]; + g->texture.unit[i].enabled2D = a->enableStack[a->enableStackDepth].texture2D[i]; +#ifdef CR_OPENGL_VERSION_1_2 + g->texture.unit[i].enabled3D = a->enableStack[a->enableStackDepth].texture3D[i]; +#endif +#ifdef CR_ARB_texture_cube_map + g->texture.unit[i].enabledCubeMap = a->enableStack[a->enableStackDepth].textureCubeMap[i]; +#endif +#ifdef CR_NV_texture_rectangle + g->texture.unit[i].enabledRect = a->enableStack[a->enableStackDepth].textureRect[i]; +#endif + g->texture.unit[i].textureGen.s = a->enableStack[a->enableStackDepth].textureGenS[i]; + g->texture.unit[i].textureGen.t = a->enableStack[a->enableStackDepth].textureGenT[i]; + g->texture.unit[i].textureGen.r = a->enableStack[a->enableStackDepth].textureGenR[i]; + g->texture.unit[i].textureGen.q = a->enableStack[a->enableStackDepth].textureGenQ[i]; + } + DIRTY(sb->buffer.dirty, g->neg_bitid); + DIRTY(sb->eval.dirty, g->neg_bitid); + DIRTY(sb->transform.dirty, g->neg_bitid); + DIRTY(sb->lighting.dirty, g->neg_bitid); + DIRTY(sb->fog.dirty, g->neg_bitid); + DIRTY(sb->line.dirty, g->neg_bitid); + DIRTY(sb->polygon.dirty, g->neg_bitid); + DIRTY(sb->viewport.dirty, g->neg_bitid); + DIRTY(sb->stencil.dirty, g->neg_bitid); + DIRTY(sb->texture.dirty, g->neg_bitid); + + DIRTY(sb->buffer.enable, g->neg_bitid); + DIRTY(sb->eval.enable, g->neg_bitid); + DIRTY(sb->transform.enable, g->neg_bitid); + DIRTY(sb->lighting.enable, g->neg_bitid); + DIRTY(sb->fog.enable, g->neg_bitid); + DIRTY(sb->line.enable, g->neg_bitid); + DIRTY(sb->polygon.enable, g->neg_bitid); + DIRTY(sb->viewport.enable, g->neg_bitid); + DIRTY(sb->stencil.enable, g->neg_bitid); + for (i = 0 ; i < g->limits.maxTextureUnits ; i++) + { + DIRTY(sb->texture.enable[i], g->neg_bitid); + } + } + if (mask & GL_EVAL_BIT) + { + if (a->evalStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty eval stack!" ); + return; + } + a->evalStackDepth--; + for (i = 0 ; i < GLEVAL_TOT ; i++) + { + int size1 = a->evalStack[a->evalStackDepth].eval1D[i].order * gleval_sizes[i] * sizeof(GLfloat); + int size2 = a->evalStack[a->evalStackDepth].eval2D[i].uorder * a->evalStack[a->evalStackDepth].eval2D[i].vorder * gleval_sizes[i] * sizeof (GLfloat); + g->eval.enable1D[i] = a->evalStack[a->evalStackDepth].enable1D[i]; + g->eval.enable2D[i] = a->evalStack[a->evalStackDepth].enable2D[i]; + g->eval.eval1D[i].u1 = a->evalStack[a->evalStackDepth].eval1D[i].u1; + g->eval.eval1D[i].u2 = a->evalStack[a->evalStackDepth].eval1D[i].u2; + g->eval.eval1D[i].order = a->evalStack[a->evalStackDepth].eval1D[i].order; + crMemcpy((char*)g->eval.eval1D[i].coeff, a->evalStack[a->evalStackDepth].eval1D[i].coeff, size1); + crFree(a->evalStack[a->evalStackDepth].eval1D[i].coeff); + a->evalStack[a->evalStackDepth].eval1D[i].coeff = NULL; + g->eval.eval2D[i].u1 = a->evalStack[a->evalStackDepth].eval2D[i].u1; + g->eval.eval2D[i].u2 = a->evalStack[a->evalStackDepth].eval2D[i].u2; + g->eval.eval2D[i].v1 = a->evalStack[a->evalStackDepth].eval2D[i].v1; + g->eval.eval2D[i].v2 = a->evalStack[a->evalStackDepth].eval2D[i].v2; + g->eval.eval2D[i].uorder = a->evalStack[a->evalStackDepth].eval2D[i].uorder; + g->eval.eval2D[i].vorder = a->evalStack[a->evalStackDepth].eval2D[i].vorder; + crMemcpy((char*)g->eval.eval2D[i].coeff, a->evalStack[a->evalStackDepth].eval2D[i].coeff, size2); + crFree(a->evalStack[a->evalStackDepth].eval2D[i].coeff); + a->evalStack[a->evalStackDepth].eval2D[i].coeff = NULL; + } + g->eval.autoNormal = a->evalStack[a->evalStackDepth].autoNormal; + g->eval.un1D = a->evalStack[a->evalStackDepth].un1D; + g->eval.u11D = a->evalStack[a->evalStackDepth].u11D; + g->eval.u21D = a->evalStack[a->evalStackDepth].u21D; + g->eval.un2D = a->evalStack[a->evalStackDepth].un2D; + g->eval.u12D = a->evalStack[a->evalStackDepth].u12D; + g->eval.u22D = a->evalStack[a->evalStackDepth].u22D; + g->eval.vn2D = a->evalStack[a->evalStackDepth].vn2D; + g->eval.v12D = a->evalStack[a->evalStackDepth].v12D; + g->eval.v22D = a->evalStack[a->evalStackDepth].v22D; + for (i = 0; i < GLEVAL_TOT; i++) { + DIRTY(sb->eval.eval1D[i], g->neg_bitid); + DIRTY(sb->eval.eval2D[i], g->neg_bitid); + } + DIRTY(sb->eval.dirty, g->neg_bitid); + DIRTY(sb->eval.grid1D, g->neg_bitid); + DIRTY(sb->eval.grid2D, g->neg_bitid); + DIRTY(sb->eval.enable, g->neg_bitid); + } + if (mask & GL_FOG_BIT) + { + if (a->fogStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty fog stack!" ); + return; + } + a->fogStackDepth--; + g->fog.enable = a->fogStack[a->fogStackDepth].enable; + g->fog.color = a->fogStack[a->fogStackDepth].color; + g->fog.density = a->fogStack[a->fogStackDepth].density; + g->fog.start = a->fogStack[a->fogStackDepth].start; + g->fog.end = a->fogStack[a->fogStackDepth].end; + g->fog.index = a->fogStack[a->fogStackDepth].index; + g->fog.mode = a->fogStack[a->fogStackDepth].mode; + DIRTY(sb->fog.dirty, g->neg_bitid); + DIRTY(sb->fog.color, g->neg_bitid); + DIRTY(sb->fog.index, g->neg_bitid); + DIRTY(sb->fog.density, g->neg_bitid); + DIRTY(sb->fog.start, g->neg_bitid); + DIRTY(sb->fog.end, g->neg_bitid); + DIRTY(sb->fog.mode, g->neg_bitid); + DIRTY(sb->fog.enable, g->neg_bitid); + } + if (mask & GL_HINT_BIT) + { + if (a->hintStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty hint stack!" ); + return; + } + a->hintStackDepth--; + g->hint.perspectiveCorrection = a->hintStack[a->hintStackDepth].perspectiveCorrection; + g->hint.pointSmooth = a->hintStack[a->hintStackDepth].pointSmooth; + g->hint.lineSmooth = a->hintStack[a->hintStackDepth].lineSmooth; + g->hint.polygonSmooth = a->hintStack[a->hintStackDepth].polygonSmooth; + g->hint.fog = a->hintStack[a->hintStackDepth].fog; + DIRTY(sb->hint.dirty, g->neg_bitid); + DIRTY(sb->hint.perspectiveCorrection, g->neg_bitid); + DIRTY(sb->hint.pointSmooth, g->neg_bitid); + DIRTY(sb->hint.lineSmooth, g->neg_bitid); + DIRTY(sb->hint.polygonSmooth, g->neg_bitid); +#ifdef CR_EXT_clip_volume_hint + g->hint.clipVolumeClipping = a->hintStack[a->hintStackDepth].clipVolumeClipping; + DIRTY(sb->hint.clipVolumeClipping, g->neg_bitid); +#endif +#ifdef CR_ARB_texture_compression + g->hint.textureCompression = a->hintStack[a->hintStackDepth].textureCompression; + DIRTY(sb->hint.textureCompression, g->neg_bitid); +#endif +#ifdef CR_SGIS_generate_mipmap + g->hint.generateMipmap = a->hintStack[a->hintStackDepth].generateMipmap; + DIRTY(sb->hint.generateMipmap, g->neg_bitid); +#endif + } + if (mask & GL_LIGHTING_BIT) + { + if (a->lightingStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty lighting stack!" ); + return; + } + a->lightingStackDepth--; + g->lighting.lightModelAmbient = a->lightingStack[a->lightingStackDepth].lightModelAmbient; + g->lighting.lightModelLocalViewer = a->lightingStack[a->lightingStackDepth].lightModelLocalViewer; + g->lighting.lightModelTwoSide = a->lightingStack[a->lightingStackDepth].lightModelTwoSide; +#if defined(CR_EXT_separate_specular_color) || defined(CR_OPENGL_VERSION_1_2) + g->lighting.lightModelColorControlEXT = a->lightingStack[a->lightingStackDepth].lightModelColorControlEXT; +#endif + g->lighting.lighting = a->lightingStack[a->lightingStackDepth].lighting; + g->lighting.colorMaterial = a->lightingStack[a->lightingStackDepth].colorMaterial; + g->lighting.colorMaterialMode = a->lightingStack[a->lightingStackDepth].colorMaterialMode; + g->lighting.colorMaterialFace = a->lightingStack[a->lightingStackDepth].colorMaterialFace; + for (i = 0 ; i < g->limits.maxLights; i++) + { + g->lighting.light[i].enable = a->lightingStack[a->lightingStackDepth].light[i].enable; + g->lighting.light[i].ambient = a->lightingStack[a->lightingStackDepth].light[i].ambient; + g->lighting.light[i].diffuse = a->lightingStack[a->lightingStackDepth].light[i].diffuse; + g->lighting.light[i].specular = a->lightingStack[a->lightingStackDepth].light[i].specular; + g->lighting.light[i].spotDirection = a->lightingStack[a->lightingStackDepth].light[i].spotDirection; + g->lighting.light[i].position = a->lightingStack[a->lightingStackDepth].light[i].position; + g->lighting.light[i].spotExponent = a->lightingStack[a->lightingStackDepth].light[i].spotExponent; + g->lighting.light[i].spotCutoff = a->lightingStack[a->lightingStackDepth].light[i].spotCutoff; + g->lighting.light[i].constantAttenuation = a->lightingStack[a->lightingStackDepth].light[i].constantAttenuation; + g->lighting.light[i].linearAttenuation = a->lightingStack[a->lightingStackDepth].light[i].linearAttenuation; + g->lighting.light[i].quadraticAttenuation = a->lightingStack[a->lightingStackDepth].light[i].quadraticAttenuation; + } + for (i = 0 ; i < 2 ; i++) + { + g->lighting.ambient[i] = a->lightingStack[a->lightingStackDepth].ambient[i]; + g->lighting.diffuse[i] = a->lightingStack[a->lightingStackDepth].diffuse[i]; + g->lighting.specular[i] = a->lightingStack[a->lightingStackDepth].specular[i]; + g->lighting.emission[i] = a->lightingStack[a->lightingStackDepth].emission[i]; + g->lighting.shininess[i] = a->lightingStack[a->lightingStackDepth].shininess[i]; + g->lighting.indexes[i][0] = a->lightingStack[a->lightingStackDepth].indexes[i][0]; + g->lighting.indexes[i][1] = a->lightingStack[a->lightingStackDepth].indexes[i][1]; + g->lighting.indexes[i][2] = a->lightingStack[a->lightingStackDepth].indexes[i][2]; + } + g->lighting.shadeModel = a->lightingStack[a->lightingStackDepth].shadeModel; + DIRTY(sb->lighting.dirty, g->neg_bitid); + DIRTY(sb->lighting.shadeModel, g->neg_bitid); + DIRTY(sb->lighting.lightModel, g->neg_bitid); + DIRTY(sb->lighting.material, g->neg_bitid); + DIRTY(sb->lighting.enable, g->neg_bitid); + for (i = 0 ; i < g->limits.maxLights; i++) + { + DIRTY(sb->lighting.light[i].dirty, g->neg_bitid); + DIRTY(sb->lighting.light[i].enable, g->neg_bitid); + DIRTY(sb->lighting.light[i].ambient, g->neg_bitid); + DIRTY(sb->lighting.light[i].diffuse, g->neg_bitid); + DIRTY(sb->lighting.light[i].specular, g->neg_bitid); + DIRTY(sb->lighting.light[i].position, g->neg_bitid); + DIRTY(sb->lighting.light[i].attenuation, g->neg_bitid); + DIRTY(sb->lighting.light[i].spot, g->neg_bitid); + } + } + if (mask & GL_LINE_BIT) + { + if (a->lineStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty line stack!" ); + return; + } + a->lineStackDepth--; + g->line.lineSmooth = a->lineStack[a->lineStackDepth].lineSmooth; + g->line.lineStipple = a->lineStack[a->lineStackDepth].lineStipple; + g->line.pattern = a->lineStack[a->lineStackDepth].pattern; + g->line.repeat = a->lineStack[a->lineStackDepth].repeat; + g->line.width = a->lineStack[a->lineStackDepth].width; + DIRTY(sb->line.dirty, g->neg_bitid); + DIRTY(sb->line.enable, g->neg_bitid); + DIRTY(sb->line.width, g->neg_bitid); + DIRTY(sb->line.stipple, g->neg_bitid); + } + if (mask & GL_LIST_BIT) + { + if (a->listStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty list stack!" ); + return; + } + a->listStackDepth--; + g->lists.base = a->listStack[a->listStackDepth].base; + DIRTY(sb->lists.dirty, g->neg_bitid); + } + if (mask & GL_PIXEL_MODE_BIT) + { + if (a->pixelModeStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty pixel mode stack!" ); + return; + } + a->pixelModeStackDepth--; + g->pixel.bias = a->pixelModeStack[a->pixelModeStackDepth].bias; + g->pixel.scale = a->pixelModeStack[a->pixelModeStackDepth].scale; + g->pixel.indexOffset = a->pixelModeStack[a->pixelModeStackDepth].indexOffset; + g->pixel.indexShift = a->pixelModeStack[a->pixelModeStackDepth].indexShift; + g->pixel.mapColor = a->pixelModeStack[a->pixelModeStackDepth].mapColor; + g->pixel.mapStencil = a->pixelModeStack[a->pixelModeStackDepth].mapStencil; + g->pixel.xZoom = a->pixelModeStack[a->pixelModeStackDepth].xZoom; + g->pixel.yZoom = a->pixelModeStack[a->pixelModeStackDepth].yZoom; + g->buffer.readBuffer = a->pixelModeStack[a->pixelModeStackDepth].readBuffer; + DIRTY(sb->pixel.dirty, g->neg_bitid); + DIRTY(sb->pixel.transfer, g->neg_bitid); + DIRTY(sb->pixel.zoom, g->neg_bitid); + DIRTY(sb->buffer.dirty, g->neg_bitid); + DIRTY(sb->buffer.readBuffer, g->neg_bitid); + } + if (mask & GL_POINT_BIT) + { + if (a->pointStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty point stack!" ); + return; + } + a->pointStackDepth--; + g->point.pointSmooth = a->pointStack[a->pointStackDepth].pointSmooth; + g->point.pointSize = a->pointStack[a->pointStackDepth].pointSize; +#if GL_ARB_point_sprite + g->point.pointSprite = a->pointStack[a->pointStackDepth].pointSprite; + DIRTY(sb->point.enableSprite, g->neg_bitid); + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) { + g->point.coordReplacement[i] = a->enableStack[a->enableStackDepth].coordReplacement[i]; + DIRTY(sb->point.coordReplacement[i], g->neg_bitid); + } +#endif + DIRTY(sb->point.dirty, g->neg_bitid); + DIRTY(sb->point.size, g->neg_bitid); + DIRTY(sb->point.enableSmooth, g->neg_bitid); + } + if (mask & GL_POLYGON_BIT) + { + if (a->polygonStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty polygon stack!" ); + return; + } + a->polygonStackDepth--; + g->polygon.cullFace = a->polygonStack[a->polygonStackDepth].cullFace; + g->polygon.cullFaceMode = a->polygonStack[a->polygonStackDepth].cullFaceMode; + g->polygon.frontFace = a->polygonStack[a->polygonStackDepth].frontFace; + g->polygon.frontMode = a->polygonStack[a->polygonStackDepth].frontMode; + g->polygon.backMode = a->polygonStack[a->polygonStackDepth].backMode; + g->polygon.polygonSmooth = a->polygonStack[a->polygonStackDepth].polygonSmooth; + g->polygon.polygonStipple = a->polygonStack[a->polygonStackDepth].polygonStipple; + g->polygon.polygonOffsetFill = a->polygonStack[a->polygonStackDepth].polygonOffsetFill; + g->polygon.polygonOffsetLine = a->polygonStack[a->polygonStackDepth].polygonOffsetLine; + g->polygon.polygonOffsetPoint = a->polygonStack[a->polygonStackDepth].polygonOffsetPoint; + g->polygon.offsetFactor = a->polygonStack[a->polygonStackDepth].offsetFactor; + g->polygon.offsetUnits = a->polygonStack[a->polygonStackDepth].offsetUnits; + DIRTY(sb->polygon.dirty, g->neg_bitid); + DIRTY(sb->polygon.enable, g->neg_bitid); + DIRTY(sb->polygon.offset, g->neg_bitid); + DIRTY(sb->polygon.mode, g->neg_bitid); + DIRTY(sb->polygon.stipple, g->neg_bitid); + } + if (mask & GL_POLYGON_STIPPLE_BIT) + { + if (a->polygonStippleStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty polygon stipple stack!" ); + return; + } + a->polygonStippleStackDepth--; + crMemcpy( g->polygon.stipple, a->polygonStippleStack[a->polygonStippleStackDepth].pattern, 32*sizeof(GLint) ); + DIRTY(sb->polygon.dirty, g->neg_bitid); + DIRTY(sb->polygon.stipple, g->neg_bitid); + } + if (mask & GL_SCISSOR_BIT) + { + if (a->scissorStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty scissor stack!" ); + return; + } + a->scissorStackDepth--; + g->viewport.scissorTest = a->scissorStack[a->scissorStackDepth].scissorTest; + g->viewport.scissorX = a->scissorStack[a->scissorStackDepth].scissorX; + g->viewport.scissorY = a->scissorStack[a->scissorStackDepth].scissorY; + g->viewport.scissorW = a->scissorStack[a->scissorStackDepth].scissorW; + g->viewport.scissorH = a->scissorStack[a->scissorStackDepth].scissorH; + DIRTY(sb->viewport.dirty, g->neg_bitid); + DIRTY(sb->viewport.enable, g->neg_bitid); + DIRTY(sb->viewport.s_dims, g->neg_bitid); + } + if (mask & GL_STENCIL_BUFFER_BIT) + { + if (a->stencilBufferStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty stencil stack!" ); + return; + } + a->stencilBufferStackDepth--; + g->stencil.stencilTest = a->stencilBufferStack[a->stencilBufferStackDepth].stencilTest; + g->stencil.clearValue = a->stencilBufferStack[a->stencilBufferStackDepth].clearValue; + g->stencil.writeMask = a->stencilBufferStack[a->stencilBufferStackDepth].writeMask; + for (i = 0; i < CRSTATE_STENCIL_BUFFER_COUNT; ++i) + { + g->stencil.buffers[i].func = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].func; + g->stencil.buffers[i].mask = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].mask; + g->stencil.buffers[i].ref = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].ref; + g->stencil.buffers[i].fail = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].fail; + g->stencil.buffers[i].passDepthFail = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthFail; + g->stencil.buffers[i].passDepthPass = a->stencilBufferStack[a->stencilBufferStackDepth].buffers[i].passDepthPass; + } + + DIRTY(sb->stencil.dirty, g->neg_bitid); + DIRTY(sb->stencil.enable, g->neg_bitid); + DIRTY(sb->stencil.clearValue, g->neg_bitid); + DIRTY(sb->stencil.writeMask, g->neg_bitid); + + for (i = 0; i < CRSTATE_STENCIL_BUFFER_REF_COUNT; ++i) + { + DIRTY(sb->stencil.bufferRefs[i].func, g->neg_bitid); + DIRTY(sb->stencil.bufferRefs[i].op, g->neg_bitid); + } + } + if (mask & GL_TEXTURE_BIT) + { + CRTextureStack *tState; + if (a->textureStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty texture stack!" ); + return; + } + a->textureStackDepth--; + tState = a->textureStack + a->textureStackDepth; + + g->texture.curTextureUnit = tState->curTextureUnit; + for (i = 0 ; i < g->limits.maxTextureUnits ; i++) + { + copy_texunit(&g->texture.unit[i], &tState->unit[i]); + /* first, restore the bindings! */ + g->texture.unit[i].currentTexture1D = crStateTextureGet(GL_TEXTURE_1D, tState->unit[i].Saved1D.id); + copy_texobj(g->texture.unit[i].currentTexture1D, &tState->unit[i].Saved1D, GL_FALSE); + g->texture.unit[i].currentTexture2D = crStateTextureGet(GL_TEXTURE_2D, tState->unit[i].Saved2D.id); + copy_texobj(g->texture.unit[i].currentTexture2D, &tState->unit[i].Saved2D, GL_FALSE); +#ifdef CR_OPENGL_VERSION_1_2 + g->texture.unit[i].currentTexture3D = crStateTextureGet(GL_TEXTURE_3D, tState->unit[i].Saved3D.id); + copy_texobj(g->texture.unit[i].currentTexture3D, &tState->unit[i].Saved3D, GL_FALSE); +#endif +#ifdef CR_ARB_texture_cube_map + g->texture.unit[i].currentTextureCubeMap = crStateTextureGet(GL_TEXTURE_CUBE_MAP_ARB, tState->unit[i].SavedCubeMap.id); + copy_texobj(g->texture.unit[i].currentTextureCubeMap, &tState->unit[i].SavedCubeMap, GL_FALSE); +#endif +#ifdef CR_NV_texture_rectangle + g->texture.unit[i].currentTextureRect = crStateTextureGet(GL_TEXTURE_CUBE_MAP_ARB, tState->unit[i].SavedRect.id); + copy_texobj(g->texture.unit[i].currentTextureRect, &tState->unit[i].SavedRect, GL_FALSE); +#endif + } + DIRTY(sb->texture.dirty, g->neg_bitid); + for (i = 0 ; i < g->limits.maxTextureUnits ; i++) + { + DIRTY(sb->texture.enable[i], g->neg_bitid); + DIRTY(sb->texture.current[i], g->neg_bitid); + DIRTY(sb->texture.objGen[i], g->neg_bitid); + DIRTY(sb->texture.eyeGen[i], g->neg_bitid); + DIRTY(sb->texture.envBit[i], g->neg_bitid); + DIRTY(sb->texture.genMode[i], g->neg_bitid); + } + + for (i = 0 ; i < g->limits.maxTextureUnits ; i++) + { + DIRTY(g->texture.unit[i].currentTexture1D->dirty, g->neg_bitid); + DIRTY(g->texture.unit[i].currentTexture2D->dirty, g->neg_bitid); + DIRTY(g->texture.unit[i].currentTexture3D->dirty, g->neg_bitid); +#ifdef CR_ARB_texture_cube_map + DIRTY(g->texture.unit[i].currentTextureCubeMap->dirty, g->neg_bitid); +#endif +#ifdef CR_NV_texture_rectangle + DIRTY(g->texture.unit[i].currentTextureRect->dirty, g->neg_bitid); +#endif + DIRTY(g->texture.unit[i].currentTexture1D->paramsBit[i], g->neg_bitid); + DIRTY(g->texture.unit[i].currentTexture2D->paramsBit[i], g->neg_bitid); + DIRTY(g->texture.unit[i].currentTexture3D->paramsBit[i], g->neg_bitid); +#ifdef CR_ARB_texture_cube_map + DIRTY(g->texture.unit[i].currentTextureCubeMap->paramsBit[i], g->neg_bitid); +#endif +#ifdef CR_NV_texture_rectangle + DIRTY(g->texture.unit[i].currentTextureRect->paramsBit[i], g->neg_bitid); +#endif + } + } + if (mask & GL_TRANSFORM_BIT) + { + if (a->transformStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty transform stack!" ); + return; + } + a->transformStackDepth--; + g->transform.matrixMode = a->transformStack[a->transformStackDepth].matrixMode; + crStateMatrixMode(g->transform.matrixMode); + for (i = 0 ; i < g->limits.maxClipPlanes ; i++) + { + g->transform.clip[i] = a->transformStack[a->transformStackDepth].clip[i]; + g->transform.clipPlane[i] = a->transformStack[a->transformStackDepth].clipPlane[i]; + } + g->transform.normalize = a->transformStack[a->transformStackDepth].normalize; +#ifdef CR_OPENGL_VERSION_1_2 + g->transform.rescaleNormals = a->transformStack[a->transformStackDepth].rescaleNormals; +#endif + DIRTY(sb->transform.dirty, g->neg_bitid); + DIRTY(sb->transform.matrixMode, g->neg_bitid); + DIRTY(sb->transform.clipPlane, g->neg_bitid); + DIRTY(sb->transform.enable, g->neg_bitid); + } + if (mask & GL_VIEWPORT_BIT) + { + if (a->viewportStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "glPopAttrib called with an empty viewport stack!" ); + return; + } + a->viewportStackDepth--; + g->viewport.viewportX = a->viewportStack[a->viewportStackDepth].viewportX; + g->viewport.viewportY = a->viewportStack[a->viewportStackDepth].viewportY; + g->viewport.viewportW = a->viewportStack[a->viewportStackDepth].viewportW; + g->viewport.viewportH = a->viewportStack[a->viewportStackDepth].viewportH; + g->viewport.nearClip = a->viewportStack[a->viewportStackDepth].nearClip; + g->viewport.farClip = a->viewportStack[a->viewportStackDepth].farClip; + DIRTY(sb->viewport.dirty, g->neg_bitid); + DIRTY(sb->viewport.v_dims, g->neg_bitid); + DIRTY(sb->viewport.depth, g->neg_bitid); + } + DIRTY(ab->dirty, g->neg_bitid); +} + +void crStateAttribSwitch( CRAttribBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + CRAttribState *to = &(toCtx->attrib); + CRAttribState *from = &(fromCtx->attrib); + if (to->attribStackDepth != 0 || from->attribStackDepth != 0) + { + crWarning( "Trying to switch contexts when the attribute stacks " + "weren't empty. Currently, this is not supported." ); + } + (void) bb; + (void) bitID; +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_bits_globalop.h b/src/VBox/GuestHost/OpenGL/state_tracker/state_bits_globalop.h new file mode 100644 index 00000000..506da3c5 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_bits_globalop.h @@ -0,0 +1,338 @@ +/* $Id: state_bits_globalop.h $ */ + +/** @file + * Global State bits operation + */ + +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include + +#include + +#ifndef CRSTATE_BITS_OP +# error "CRSTATE_BITS_OP must be defined!" +#endif + +#define _CRSTATE_BITS_OP_SIZEOF(_val) CRSTATE_BITS_OP(_val, RT_SIZEOFMEMB(CRStateBits, _val)) + +#ifndef CRSTATE_BITS_OP_VERSION +# define CRSTATE_BITS_OP_VERSION SHCROGL_SSM_VERSION +#endif + +do { +int i; +#ifdef _CRSTATE_BITS_OP_STENCIL_V_33 +# error "_CRSTATE_BITS_OP_STENCIL_V_33 must no be defined!" +#endif +#if CRSTATE_BITS_OP_VERSION < SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL +# define _CRSTATE_BITS_OP_STENCIL_V_33 +#endif + +#ifdef _CRSTATE_BITS_OP_STENCIL_V_33 +# ifndef CRSTATE_BITS_OP_STENCIL_OP_V_33 +# error "CRSTATE_BITS_OP_STENCIL_OP_V_33 undefined!" +# endif +# ifndef CRSTATE_BITS_OP_STENCIL_FUNC_V_33 +# error "CRSTATE_BITS_OP_STENCIL_FUNC_V_33 undefined!" +# endif +#endif + +_CRSTATE_BITS_OP_SIZEOF(attrib.dirty); + +_CRSTATE_BITS_OP_SIZEOF(buffer.dirty); +_CRSTATE_BITS_OP_SIZEOF(buffer.enable); +_CRSTATE_BITS_OP_SIZEOF(buffer.alphaFunc); +_CRSTATE_BITS_OP_SIZEOF(buffer.depthFunc); +_CRSTATE_BITS_OP_SIZEOF(buffer.blendFunc); +_CRSTATE_BITS_OP_SIZEOF(buffer.logicOp); +_CRSTATE_BITS_OP_SIZEOF(buffer.indexLogicOp); +_CRSTATE_BITS_OP_SIZEOF(buffer.drawBuffer); +_CRSTATE_BITS_OP_SIZEOF(buffer.readBuffer); +_CRSTATE_BITS_OP_SIZEOF(buffer.indexMask); +_CRSTATE_BITS_OP_SIZEOF(buffer.colorWriteMask); +_CRSTATE_BITS_OP_SIZEOF(buffer.clearColor); +_CRSTATE_BITS_OP_SIZEOF(buffer.clearIndex); +_CRSTATE_BITS_OP_SIZEOF(buffer.clearDepth); +_CRSTATE_BITS_OP_SIZEOF(buffer.clearAccum); +_CRSTATE_BITS_OP_SIZEOF(buffer.depthMask); +#ifdef CR_EXT_blend_color +_CRSTATE_BITS_OP_SIZEOF(buffer.blendColor); +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) +_CRSTATE_BITS_OP_SIZEOF(buffer.blendEquation); +#endif +#if defined(CR_EXT_blend_func_separate) +_CRSTATE_BITS_OP_SIZEOF(buffer.blendFuncSeparate); +#endif + +#ifdef CR_ARB_vertex_buffer_object +_CRSTATE_BITS_OP_SIZEOF(bufferobject.dirty); +_CRSTATE_BITS_OP_SIZEOF(bufferobject.arrayBinding); +_CRSTATE_BITS_OP_SIZEOF(bufferobject.elementsBinding); +# ifdef CR_ARB_pixel_buffer_object +_CRSTATE_BITS_OP_SIZEOF(bufferobject.packBinding); +_CRSTATE_BITS_OP_SIZEOF(bufferobject.unpackBinding); +# endif +#endif + +_CRSTATE_BITS_OP_SIZEOF(client.dirty); +_CRSTATE_BITS_OP_SIZEOF(client.pack); +_CRSTATE_BITS_OP_SIZEOF(client.unpack); +_CRSTATE_BITS_OP_SIZEOF(client.enableClientState); +_CRSTATE_BITS_OP_SIZEOF(client.clientPointer); +CRSTATE_BITS_OP(client.v, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +CRSTATE_BITS_OP(client.n, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +CRSTATE_BITS_OP(client.c, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +CRSTATE_BITS_OP(client.i, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +CRSTATE_BITS_OP(client.e, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +CRSTATE_BITS_OP(client.s, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +CRSTATE_BITS_OP(client.f, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +for (i=0; i= SHCROGL_SSM_VERSION_WITH_SPRITE_COORD_ORIGIN +_CRSTATE_BITS_OP_SIZEOF(point.spriteCoordOrigin); +#endif + +_CRSTATE_BITS_OP_SIZEOF(polygon.dirty); +_CRSTATE_BITS_OP_SIZEOF(polygon.enable); +_CRSTATE_BITS_OP_SIZEOF(polygon.offset); +_CRSTATE_BITS_OP_SIZEOF(polygon.mode); +_CRSTATE_BITS_OP_SIZEOF(polygon.stipple); + +_CRSTATE_BITS_OP_SIZEOF(program.dirty); +_CRSTATE_BITS_OP_SIZEOF(program.vpEnable); +_CRSTATE_BITS_OP_SIZEOF(program.fpEnable); +_CRSTATE_BITS_OP_SIZEOF(program.vpBinding); +_CRSTATE_BITS_OP_SIZEOF(program.fpBinding); +for (i=0; i +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateBufferInit (CRContext *ctx) +{ + CRBufferState *b = &ctx->buffer; + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + GLcolorf zero_colorf = {0.0f, 0.0f, 0.0f, 0.0f}; + + b->width = 640; + b->height = 480; + b->storedWidth = 0; + b->storedHeight = 0; + b->pFrontImg = NULL; + b->pBackImg = NULL; + + b->depthTest = GL_FALSE; + b->blend = GL_FALSE; + b->alphaTest = GL_FALSE; + b->dither = GL_TRUE; + RESET(bb->enable, ctx->bitid); + + b->logicOp = GL_FALSE; + RESET(bb->logicOp, ctx->bitid); + b->indexLogicOp = GL_FALSE; + RESET(bb->indexLogicOp, ctx->bitid); + b->depthMask = GL_TRUE; + RESET(bb->depthMask, ctx->bitid); + + b->alphaTestFunc = GL_ALWAYS; + b->alphaTestRef = 0; + RESET(bb->alphaFunc, ctx->bitid); + b->depthFunc = GL_LESS; + RESET(bb->depthFunc, ctx->bitid); + b->blendSrcRGB = GL_ONE; + b->blendDstRGB = GL_ZERO; + RESET(bb->blendFunc, ctx->bitid); +#ifdef CR_EXT_blend_func_separate + b->blendSrcA = GL_ONE; + b->blendDstA = GL_ZERO; + RESET(bb->blendFuncSeparate, ctx->bitid); +#endif + b->logicOpMode = GL_COPY; + b->drawBuffer = GL_BACK; + RESET(bb->drawBuffer, ctx->bitid); + b->readBuffer = GL_BACK; + RESET(bb->readBuffer, ctx->bitid); + b->indexWriteMask = 0xffffffff; + RESET(bb->indexMask, ctx->bitid); + b->colorWriteMask.r = GL_TRUE; + b->colorWriteMask.g = GL_TRUE; + b->colorWriteMask.b = GL_TRUE; + b->colorWriteMask.a = GL_TRUE; + RESET(bb->colorWriteMask, ctx->bitid); + b->colorClearValue = zero_colorf; + RESET(bb->clearColor, ctx->bitid); + b->indexClearValue = 0; + RESET(bb->clearIndex, ctx->bitid); + b->depthClearValue = (GLdefault) 1.0; + RESET(bb->clearDepth, ctx->bitid); + b->accumClearValue = zero_colorf; + RESET(bb->clearAccum, ctx->bitid); + +#ifdef CR_EXT_blend_color + b->blendColor = zero_colorf; + RESET(bb->blendColor, ctx->bitid); +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) + b->blendEquation = GL_FUNC_ADD_EXT; + RESET(bb->blendEquation, ctx->bitid); +#endif + + RESET(bb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateAlphaFunc (GLenum func, GLclampf ref) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glAlphaFunc called in begin/end"); + return; + } + + FLUSH(); + + switch (func) + { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glAlphaFunc: Invalid func: %d", func); + return; + } + + if (ref < 0.0f) ref = 0.0f; + if (ref > 1.0f) ref = 1.0f; + + b->alphaTestFunc = func; + b->alphaTestRef = ref; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->alphaFunc, g->neg_bitid); +} + +void STATE_APIENTRY crStateDepthFunc (GLenum func) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDepthFunc called in begin/end"); + return; + } + + FLUSH(); + + switch (func) + { + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glDepthFunc: Invalid func: %d", func); + return; + } + + + b->depthFunc = func; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->depthFunc, g->neg_bitid); +} + +void STATE_APIENTRY crStateBlendFunc (GLenum sfactor, GLenum dfactor) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBlendFunc called in begin/end"); + return; + } + + FLUSH(); + + switch (sfactor) + { + case GL_ZERO: + case GL_ONE: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; /* OK */ +#ifdef CR_EXT_blend_color + case GL_CONSTANT_COLOR_EXT: + case GL_ONE_MINUS_CONSTANT_COLOR_EXT: + case GL_CONSTANT_ALPHA_EXT: + case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: + if (g->extensions.EXT_blend_color) + break; /* OK */ +#endif + RT_FALL_THRU(); + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactor passed to glBlendFunc: %d", sfactor); + return; + } + + switch (dfactor) + { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + break; /* OK */ +#ifdef CR_EXT_blend_color + case GL_CONSTANT_COLOR_EXT: + case GL_ONE_MINUS_CONSTANT_COLOR_EXT: + case GL_CONSTANT_ALPHA_EXT: + case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: + if (g->extensions.EXT_blend_color) + break; /* OK */ +#endif + RT_FALL_THRU(); + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactor passed to glBlendFunc: %d", dfactor); + return; + } + + b->blendSrcRGB = sfactor; + b->blendDstRGB = dfactor; + b->blendSrcA = sfactor; + b->blendDstA = dfactor; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->blendFunc, g->neg_bitid); +} + +void STATE_APIENTRY crStateBlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendColorEXT called inside a Begin/End" ); + return; + } + + b->blendColor.r = red; + b->blendColor.g = green; + b->blendColor.b = blue; + b->blendColor.a = alpha; + DIRTY(bb->blendColor, g->neg_bitid); + DIRTY(bb->dirty, g->neg_bitid); +} + +#ifdef CR_EXT_blend_func_separate +void STATE_APIENTRY crStateBlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorA, GLenum dfactorA ) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendFuncSeparateEXT called inside a Begin/End" ); + return; + } + + FLUSH(); + + switch (sfactorRGB) + { + case GL_ZERO: + case GL_ONE: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; /* OK */ +#ifdef CR_EXT_blend_color + case GL_CONSTANT_COLOR_EXT: + case GL_ONE_MINUS_CONSTANT_COLOR_EXT: + case GL_CONSTANT_ALPHA_EXT: + case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: + if (g->extensions.EXT_blend_color) + break; /* OK */ +#endif + RT_FALL_THRU(); + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactorRGB passed to glBlendFuncSeparateEXT: %d", sfactorRGB); + return; + } + + switch (sfactorA) + { + case GL_ZERO: + case GL_ONE: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; /* OK */ +#ifdef CR_EXT_blend_color + case GL_CONSTANT_COLOR_EXT: + case GL_ONE_MINUS_CONSTANT_COLOR_EXT: + case GL_CONSTANT_ALPHA_EXT: + case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: + if (g->extensions.EXT_blend_color) + break; /* OK */ +#endif + RT_FALL_THRU(); + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid sfactorA passed to glBlendFuncSeparateEXT: %d", sfactorA); + return; + } + + switch (dfactorRGB) + { + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; /* OK */ +#ifdef CR_EXT_blend_color + case GL_CONSTANT_COLOR_EXT: + case GL_ONE_MINUS_CONSTANT_COLOR_EXT: + case GL_CONSTANT_ALPHA_EXT: + case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: + if (g->extensions.EXT_blend_color) + break; /* OK */ +#endif + RT_FALL_THRU(); + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactorRGB passed to glBlendFuncSeparateEXT: %d", dfactorRGB); + return; + } + + switch (dfactorA) + { + case GL_ZERO: + case GL_ONE: + case GL_DST_COLOR: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; /* OK */ +#ifdef CR_EXT_blend_color + case GL_CONSTANT_COLOR_EXT: + case GL_ONE_MINUS_CONSTANT_COLOR_EXT: + case GL_CONSTANT_ALPHA_EXT: + case GL_ONE_MINUS_CONSTANT_ALPHA_EXT: + if (g->extensions.EXT_blend_color) + break; /* OK */ +#endif + RT_FALL_THRU(); + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid dfactorA passed to glBlendFuncSeparateEXT: %d", dfactorA); + return; + } + + b->blendSrcRGB = sfactorRGB; + b->blendDstRGB = dfactorRGB; + b->blendSrcA = sfactorA; + b->blendDstA = dfactorA; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->blendFuncSeparate, g->neg_bitid); +} +#endif + +void STATE_APIENTRY crStateBlendEquationEXT( GLenum mode ) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if( g->current.inBeginEnd ) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "BlendEquationEXT called inside a Begin/End" ); + return; + } + switch( mode ) + { +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) + case GL_FUNC_ADD_EXT: +#ifdef CR_EXT_blend_subtract + case GL_FUNC_SUBTRACT_EXT: + case GL_FUNC_REVERSE_SUBTRACT_EXT: +#endif /* CR_EXT_blend_subtract */ +#ifdef CR_EXT_blend_minmax + case GL_MIN_EXT: + case GL_MAX_EXT: +#endif /* CR_EXT_blend_minmax */ +#ifdef CR_EXT_blend_logic_op + case GL_LOGIC_OP: +#endif /* CR_EXT_blend_logic_op */ + b->blendEquation = mode; + break; +#endif /* defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) */ + default: + crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, + "BlendEquationEXT: mode called with illegal parameter: 0x%x", (GLenum) mode ); + return; + } + DIRTY(bb->blendEquation, g->neg_bitid); + DIRTY(bb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateLogicOp (GLenum opcode) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glLogicOp called in begin/end"); + return; + } + + FLUSH(); + + switch (opcode) + { + case GL_CLEAR: + case GL_SET: + case GL_COPY: + case GL_COPY_INVERTED: + case GL_NOOP: + case GL_INVERT: + case GL_AND: + case GL_NAND: + case GL_OR: + case GL_NOR: + case GL_XOR: + case GL_EQUIV: + case GL_AND_REVERSE: + case GL_AND_INVERTED: + case GL_OR_REVERSE: + case GL_OR_INVERTED: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLogicOp called with bogus opcode: %d", opcode); + return; + } + + b->logicOpMode = opcode; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->logicOp, g->neg_bitid); + DIRTY(bb->indexLogicOp, g->neg_bitid); +} + +void STATE_APIENTRY crStateDrawBuffer (GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDrawBuffer called in begin/end"); + return; + } + + FLUSH(); + + switch (mode) + { + case GL_NONE: + break; + case GL_FRONT_LEFT: + case GL_FRONT_RIGHT: + case GL_BACK_LEFT: + case GL_BACK_RIGHT: + case GL_FRONT: + case GL_BACK: + case GL_LEFT: + case GL_RIGHT: + case GL_FRONT_AND_BACK: + case GL_AUX0: + case GL_AUX1: + case GL_AUX2: + case GL_AUX3: + if (g->framebufferobject.drawFB) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDrawBuffer invalid mode while fbo is active"); + return; + } + break; + default: + if (mode>=GL_COLOR_ATTACHMENT0_EXT && mode<=GL_COLOR_ATTACHMENT15_EXT) + { + if (!g->framebufferobject.drawFB) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDrawBuffer invalid mode while fbo is inactive"); + return; + } + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glDrawBuffer called with bogus mode: %d", mode); + return; + } + } + + if (g->framebufferobject.drawFB) + { + g->framebufferobject.drawFB->drawbuffer[0] = mode; + } + else + { + b->drawBuffer = mode; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->drawBuffer, g->neg_bitid); + } +} + +void STATE_APIENTRY crStateReadBuffer (GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sb = GetCurrentBits(); + CRBufferBits *bb = &(sb->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end"); + return; + } + + FLUSH(); + + switch (mode) + { + case GL_NONE: + break; + case GL_FRONT_LEFT: + case GL_FRONT_RIGHT: + case GL_BACK_LEFT: + case GL_BACK_RIGHT: + case GL_FRONT: + case GL_BACK: + case GL_LEFT: + case GL_RIGHT: + case GL_FRONT_AND_BACK: + case GL_AUX0: + case GL_AUX1: + case GL_AUX2: + case GL_AUX3: + if (g->framebufferobject.readFB) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer invalid mode while fbo is active"); + return; + } + break; + default: + if (mode>=GL_COLOR_ATTACHMENT0_EXT && mode<=GL_COLOR_ATTACHMENT15_EXT) + { + if (!g->framebufferobject.readFB) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer invalid mode while fbo is inactive"); + return; + } + else + { + /*@todo, check if fbo binding is complete*/ + } + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glReadBuffer called with bogus mode: %d", mode); + return; + } + } + + if (g->framebufferobject.readFB) + { + g->framebufferobject.readFB->readbuffer = mode; + } + else + { + b->readBuffer = mode; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->readBuffer, g->neg_bitid); + } +} + +void STATE_APIENTRY crStateIndexMask (GLuint mask) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sp = GetCurrentBits(); + CRBufferBits *bb = &(sp->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end"); + return; + } + + FLUSH(); + + b->indexWriteMask = mask; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->indexMask, g->neg_bitid); +} + +void STATE_APIENTRY crStateColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sp = GetCurrentBits(); + CRBufferBits *bb = &(sp->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glReadBuffer called in begin/end"); + return; + } + + FLUSH(); + + b->colorWriteMask.r = red; + b->colorWriteMask.g = green; + b->colorWriteMask.b = blue; + b->colorWriteMask.a = alpha; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->colorWriteMask, g->neg_bitid); +} + +void STATE_APIENTRY crStateClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sp = GetCurrentBits(); + CRBufferBits *bb = &(sp->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearColor called in begin/end"); + return; + } + + FLUSH(); + + if (red < 0.0f) red = 0.0f; + if (red > 1.0f) red = 1.0f; + if (green < 0.0f) green = 0.0f; + if (green > 1.0f) green = 1.0f; + if (blue < 0.0f) blue = 0.0f; + if (blue > 1.0f) blue = 1.0f; + if (alpha < 0.0f) alpha = 0.0f; + if (alpha > 1.0f) alpha = 1.0f; + + b->colorClearValue.r = red; + b->colorClearValue.g = green; + b->colorClearValue.b = blue; + b->colorClearValue.a = alpha; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->clearColor, g->neg_bitid); +} + +void STATE_APIENTRY crStateClearIndex (GLfloat c) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sp = GetCurrentBits(); + CRBufferBits *bb = &(sp->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearIndex called in begin/end"); + return; + } + + b->indexClearValue = c; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->clearIndex, g->neg_bitid); +} + +void STATE_APIENTRY crStateClearDepth (GLclampd depth) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sp = GetCurrentBits(); + CRBufferBits *bb = &(sp->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearDepth called in begin/end"); + return; + } + + FLUSH(); + + if (depth < 0.0) depth = 0.0; + if (depth > 1.0) depth = 1.0; + + b->depthClearValue = (GLdefault) depth; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->clearDepth, g->neg_bitid); +} + +void STATE_APIENTRY crStateClearAccum (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *b = &(g->buffer); + CRStateBits *sp = GetCurrentBits(); + CRBufferBits *bb = &(sp->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glClearAccum called in begin/end"); + return; + } + + FLUSH(); + + if (red < -1.0f) red = 0.0f; + if (red > 1.0f) red = 1.0f; + if (green < -1.0f) green = 0.0f; + if (green > 1.0f) green = 1.0f; + if (blue < -1.0f) blue = 0.0f; + if (blue > 1.0f) blue = 1.0f; + if (alpha < -1.0f) alpha = 0.0f; + if (alpha > 1.0f) alpha = 1.0f; + + b->accumClearValue.r = red; + b->accumClearValue.g = green; + b->accumClearValue.b = blue; + b->accumClearValue.a = alpha; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->clearAccum, g->neg_bitid); +} + +void STATE_APIENTRY crStateDepthMask (GLboolean b) +{ + CRContext *g = GetCurrentContext(); + CRBufferState *bs = &(g->buffer); + CRStateBits *sp = GetCurrentBits(); + CRBufferBits *bb = &(sp->buffer); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "DepthMask called in begin/end"); + return; + } + + FLUSH(); + + bs->depthMask = b; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->depthMask, g->neg_bitid); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.txt new file mode 100644 index 00000000..768a205b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_buffer.txt @@ -0,0 +1,34 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +#-:enable:*glAble able[2]; +#-:enable:*able[0] = diff_api.Disable; +#-:enable:*able[1] = diff_api.Enable; +#-:enable:*able[to->depthTest](GL_DEPTH_TEST); +#-:enable:*FILLDIRTY(b->enable); +#-:enable:*FILLDIRTY(b->dirty); +#+:enable:depthTest:GL_DEPTH_TEST +:enable:depthTest:GL_DEPTH_TEST +:enable:blend:GL_BLEND +:enable:alphaTest:GL_ALPHA_TEST +:enable:logicOp:GL_COLOR_LOGIC_OP +:enable:indexLogicOp:GL_INDEX_LOGIC_OP +:enable:dither:GL_DITHER +:alphaFunc:alphaTestFunc,alphaTestRef:AlphaFunc +:depthFunc:depthFunc:DepthFunc +:blendFunc:blendSrcRGB,blendDstRGB:BlendFunc +:blendFuncSeparate:blendSrcRGB,blendDstRGB,blendSrcA,blendDstA:BlendFuncSeparateEXT +:logicOp:logicOpMode:LogicOp +:indexLogicOp:logicOpMode:LogicOp +:drawBuffer:drawBuffer:DrawBuffer +:readBuffer:readBuffer:ReadBuffer +:indexMask:indexWriteMask:IndexMask +:colorWriteMask:colorWriteMask|r,g,b,a:ColorMask +:clearColor:colorClearValue|r,g,b,a:ClearColor +:clearIndex:indexClearValue:ClearIndex +:clearDepth:depthClearValue:ClearDepth +:clearAccum:accumClearValue|r,g,b,a:ClearAccum +:depthMask:depthMask:DepthMask +:blendEquation:blendEquation:BlendEquationEXT +:blendColor:blendColor|r,g,b,a:BlendColorEXT diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c new file mode 100644 index 00000000..373b24f8 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_bufferobject.c @@ -0,0 +1,1126 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" +#include "state_internals.h" +#include "cr_mem.h" +#include "cr_string.h" + + +static CRBufferObject *AllocBufferObject(GLuint name) +{ + CRBufferObject *b = crCalloc(sizeof(CRBufferObject)); + if (b) { + b->refCount = 1; + b->id = name; + b->hwid = name; + b->usage = GL_STATIC_DRAW_ARB; + b->access = GL_READ_WRITE_ARB; + b->bResyncOnRead = GL_FALSE; + CR_STATE_SHAREDOBJ_USAGE_INIT(b); + } + return b; +} + +void STATE_APIENTRY crStateGenBuffersARB(GLsizei n, GLuint *buffers) +{ + CRContext *g = GetCurrentContext(); + crStateGenNames(g, g->shared->buffersTable, n, buffers); +} + +void crStateRegBuffers(GLsizei n, GLuint *buffers) +{ + CRContext *g = GetCurrentContext(); + crStateRegNames(g, g->shared->buffersTable, n, buffers); +} + +GLboolean crStateIsBufferBoundForCtx(CRContext *g, GLenum target) +{ + CRBufferObjectState *b = &(g->bufferobject); + + switch (target) + { + case GL_ARRAY_BUFFER_ARB: + return b->arrayBuffer->id!=0; + case GL_ELEMENT_ARRAY_BUFFER_ARB: + return b->elementsBuffer->id!=0; +#ifdef CR_ARB_pixel_buffer_object + case GL_PIXEL_PACK_BUFFER_ARB: + return b->packBuffer->id!=0; + case GL_PIXEL_UNPACK_BUFFER_ARB: + return b->unpackBuffer->id!=0; +#endif + default: + return GL_FALSE; + } +} + +GLboolean crStateIsBufferBound(GLenum target) +{ + CRContext *g = GetCurrentContext(); + return crStateIsBufferBoundForCtx(g, target); +} + +CRBufferObject *crStateGetBoundBufferObject(GLenum target, CRBufferObjectState *b) +{ + switch (target) + { + case GL_ARRAY_BUFFER_ARB: + return b->arrayBuffer; + case GL_ELEMENT_ARRAY_BUFFER_ARB: + return b->elementsBuffer; +#ifdef CR_ARB_pixel_buffer_object + case GL_PIXEL_PACK_BUFFER_ARB: + return b->packBuffer; + case GL_PIXEL_UNPACK_BUFFER_ARB: + return b->unpackBuffer; +#endif + default: + return NULL; + } +} + +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsBufferARB( GLuint buffer ) +{ + CRContext *g = GetCurrentContext(); + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glIsBufferARB called in begin/end"); + return GL_FALSE; + } + + return buffer ? crHashtableIsKeyUsed(g->shared->buffersTable, buffer) : GL_FALSE; +} + +void crStateBufferObjectInit (CRContext *ctx) +{ + CRStateBits *sb = GetCurrentBits(); + CRBufferObjectBits *bb = &sb->bufferobject; + CRBufferObjectState *b = &ctx->bufferobject; + + RESET(bb->dirty, ctx->bitid); + RESET(bb->arrayBinding, ctx->bitid); + RESET(bb->elementsBinding, ctx->bitid); +#ifdef CR_ARB_pixel_buffer_object + RESET(bb->unpackBinding, ctx->bitid); + RESET(bb->packBinding, ctx->bitid); +#endif + +#ifdef IN_GUEST + b->retainBufferData = GL_TRUE; +#else + b->retainBufferData = GL_FALSE; +#endif + + b->nullBuffer = AllocBufferObject(0); + b->arrayBuffer = b->nullBuffer; + b->elementsBuffer = b->nullBuffer; + b->nullBuffer->refCount += 2; +#ifdef CR_ARB_pixel_buffer_object + b->packBuffer = b->nullBuffer; + b->unpackBuffer = b->nullBuffer; + b->nullBuffer->refCount += 2; +#endif + + ctx->shared->bVBOResyncNeeded = GL_FALSE; +} + +void crStateFreeBufferObject(void *data) +{ + CRBufferObject *pObj = (CRBufferObject *)data; + if (pObj->data) crFree(pObj->data); + +#ifndef IN_GUEST + if (diff_api.DeleteBuffersARB) + { + diff_api.DeleteBuffersARB(1, &pObj->hwid); + } +#endif + + crFree(pObj); +} + +void crStateBufferObjectDestroy (CRContext *ctx) +{ + CRBufferObjectState *b = &ctx->bufferobject; + crFree(b->nullBuffer); +} + +static void crStateCheckBufferHWIDCB(unsigned long key, void *data1, void *data2) +{ + CRBufferObject *pObj = (CRBufferObject *) data1; + crCheckIDHWID_t *pParms = (crCheckIDHWID_t*) data2; + (void) key; + + if (pObj->hwid==pParms->hwid) + pParms->id = pObj->id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateBufferHWIDtoID(GLuint hwid) +{ + CRContext *g = GetCurrentContext(); + crCheckIDHWID_t parms; + + parms.id = hwid; + parms.hwid = hwid; + + crHashtableWalk(g->shared->buffersTable, crStateCheckBufferHWIDCB, &parms); + return parms.id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetBufferHWID(GLuint id) +{ + CRContext *g = GetCurrentContext(); + CRBufferObject *pObj = (CRBufferObject *) crHashtableSearch(g->shared->buffersTable, id); + + return pObj ? pObj->hwid : 0; +} + +void STATE_APIENTRY +crStateBindBufferARB (GLenum target, GLuint buffer) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &(g->bufferobject); + CRStateBits *sb = GetCurrentBits(); + CRBufferObjectBits *bb = &(sb->bufferobject); + CRBufferObject *oldObj, *newObj; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBindBufferARB called in begin/end"); + return; + } + + FLUSH(); + + oldObj = crStateGetBoundBufferObject(target, b); + if (!oldObj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBindBufferARB(target)"); + return; + } + + if (buffer == 0) { + newObj = b->nullBuffer; + } + else { + newObj = (CRBufferObject *) crHashtableSearch(g->shared->buffersTable, buffer); + if (!newObj) { + CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->buffersTable, buffer), GL_INVALID_OPERATION, "name is not a buffer object"); + newObj = AllocBufferObject(buffer); + CRSTATE_CHECKERR(!newObj, GL_OUT_OF_MEMORY, "glBindBuffer"); +#ifndef IN_GUEST + diff_api.GenBuffersARB(1, &newObj->hwid); + if (!newObj->hwid) + { + crWarning("GenBuffersARB failed!"); + crFree(newObj); + return; + } +#endif + crHashtableAdd( g->shared->buffersTable, buffer, newObj ); + } + + CR_STATE_SHAREDOBJ_USAGE_SET(newObj, g); + } + + newObj->refCount++; + oldObj->refCount--; + + switch (target) + { + case GL_ARRAY_BUFFER_ARB: + b->arrayBuffer = newObj; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->arrayBinding, g->neg_bitid); + break; + case GL_ELEMENT_ARRAY_BUFFER_ARB: + b->elementsBuffer = newObj; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->elementsBinding, g->neg_bitid); + break; +#ifdef CR_ARB_pixel_buffer_object + case GL_PIXEL_PACK_BUFFER_ARB: + b->packBuffer = newObj; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->packBinding, g->neg_bitid); + break; + case GL_PIXEL_UNPACK_BUFFER_ARB: + b->unpackBuffer = newObj; + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(bb->unpackBinding, g->neg_bitid); + break; +#endif + default: /*can't get here*/ + CRASSERT(false); + return; + } + + if (oldObj->refCount <= 0) { + /*we shouldn't reach this point*/ + CRASSERT(false); + crHashtableDelete(g->shared->buffersTable, (unsigned long) oldObj->id, crStateFreeBufferObject); + } + +#ifdef IN_GUEST + if (target == GL_PIXEL_PACK_BUFFER_ARB) + { + newObj->bResyncOnRead = GL_TRUE; + } +#endif +} + +static void ctStateBuffersRefsCleanup(CRContext *ctx, CRBufferObject *obj, CRbitvalue *neg_bitid) +{ + CRBufferObjectState *b = &(ctx->bufferobject); + CRStateBits *sb = GetCurrentBits(); + CRBufferObjectBits *bb = &(sb->bufferobject); + int j, k; + + if (obj == b->arrayBuffer) + { + b->arrayBuffer = b->nullBuffer; + b->arrayBuffer->refCount++; + DIRTY(bb->dirty, neg_bitid); + DIRTY(bb->arrayBinding, neg_bitid); + } + if (obj == b->elementsBuffer) + { + b->elementsBuffer = b->nullBuffer; + b->elementsBuffer->refCount++; + DIRTY(bb->dirty, neg_bitid); + DIRTY(bb->elementsBinding, neg_bitid); + } +#ifdef CR_ARB_pixel_buffer_object + if (obj == b->packBuffer) + { + b->packBuffer = b->nullBuffer; + b->packBuffer->refCount++; + DIRTY(bb->dirty, neg_bitid); + DIRTY(bb->packBinding, neg_bitid); + } + if (obj == b->unpackBuffer) + { + b->unpackBuffer = b->nullBuffer; + b->unpackBuffer->refCount++; + DIRTY(bb->dirty, neg_bitid); + DIRTY(bb->unpackBinding, neg_bitid); + } +#endif + +#ifdef CR_ARB_vertex_buffer_object + for (j=0; jclient.array); + if (obj == cp->buffer) + { + cp->buffer = b->nullBuffer; + ++b->nullBuffer->refCount; + } + } + + for (k=0; kclient.vertexArrayStackDepth; ++k) + { + CRVertexArrays *pArray = &ctx->client.vertexArrayStack[k]; + for (j=0; jbuffer) + { + cp->buffer = b->nullBuffer; + ++b->nullBuffer->refCount; + } + } + } +#endif + + CR_STATE_SHAREDOBJ_USAGE_CLEAR(obj, ctx); +} + +void STATE_APIENTRY +crStateDeleteBuffersARB(GLsizei n, const GLuint *buffers) +{ + CRContext *g = GetCurrentContext(); + int i; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glDeleteBuffersARB called in Begin/End"); + return; + } + + if (n < 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glDeleteBuffersARB(n < 0)"); + return; + } + + for (i = 0; i < n; i++) { + if (buffers[i]) { + CRBufferObject *obj = (CRBufferObject *) + crHashtableSearch(g->shared->buffersTable, buffers[i]); + if (obj) { + int j; + + ctStateBuffersRefsCleanup(g, obj, g->neg_bitid); + + CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(obj, j) + { + /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, + * so on restore, we set mark bits as used. + * This is why g_pAvailableContexts[j] could be NULL + * also g_pAvailableContexts[0] will hold default context, which we should discard */ + CRContext *ctx = g_pAvailableContexts[j]; + if (j && ctx) + { + ctStateBuffersRefsCleanup(ctx, obj, g->neg_bitid); /* <- yes, use g->neg_bitid, i.e. neg_bitid of the current context to ensure others bits get dirtified, + * but not the current context ones*/ + } + else + CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(obj, j); + } + + crHashtableDelete(g->shared->buffersTable, buffers[i], crStateFreeBufferObject); + } + } + } +} + +void STATE_APIENTRY +crStateBufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &g->bufferobject; + CRBufferObject *obj; + CRStateBits *sb = GetCurrentBits(); + CRBufferObjectBits *bb = &sb->bufferobject; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBufferDataARB called in begin/end"); + return; + } + + if (size < 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glBufferDataARB(size < 0)"); + return; + } + + switch (usage) { + case GL_STREAM_DRAW_ARB: + case GL_STREAM_READ_ARB: + case GL_STREAM_COPY_ARB: + case GL_STATIC_DRAW_ARB: + case GL_STATIC_READ_ARB: + case GL_STATIC_COPY_ARB: + case GL_DYNAMIC_DRAW_ARB: + case GL_DYNAMIC_READ_ARB: + case GL_DYNAMIC_COPY_ARB: + /* OK */ + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glBufferDataARB(usage)"); + return; + } + + obj = crStateGetBoundBufferObject(target, b); + if (!obj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBufferDataARB(target)"); + return; + } + + if (obj->id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBufferDataARB"); + return; + } + + if (obj->pointer) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBufferDataARB(buffer is mapped)"); + return; + } + + obj->usage = usage; + obj->size = size; + + /* The user of the state tracker should set the retainBufferData field + * during context initialization, if needed. + */ + if (b->retainBufferData) { + if (obj->data) { + crFree(obj->data); + } + + obj->data = crAlloc(size); + if (!obj->data) { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBufferDataARB"); + return; + } + if (data) + crMemcpy(obj->data, data, size); + } + + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(obj->dirty, g->neg_bitid); + obj->dirtyStart = 0; + obj->dirtyLength = size; +} + + +void STATE_APIENTRY +crStateBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &g->bufferobject; + CRBufferObject *obj; + CRStateBits *sb = GetCurrentBits(); + CRBufferObjectBits *bb = &sb->bufferobject; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBufferSubDataARB called in begin/end"); + return; + } + + obj = crStateGetBoundBufferObject(target, b); + if (!obj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glBufferSubDataARB(target)"); + return; + } + + if (obj->id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBufferSubDataARB"); + return; + } + + if (obj->pointer) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBufferSubDataARB(buffer is mapped)"); + return; + } + + if (size < 0 || offset < 0 || (unsigned int)offset + size > obj->size) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBufferSubDataARB(bad offset and/or size)"); + return; + } + + if (b->retainBufferData && obj->data) { + crMemcpy((char *) obj->data + offset, data, size); + } + + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(obj->dirty, g->neg_bitid); + /* grow dirty region */ + if (offset + size > obj->dirtyStart + obj->dirtyLength) + obj->dirtyLength = offset + size; + if (offset < obj->dirtyStart) + obj->dirtyStart = offset; +} + + +void STATE_APIENTRY +crStateGetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &g->bufferobject; + CRBufferObject *obj; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetBufferSubDataARB called in begin/end"); + return; + } + + obj = crStateGetBoundBufferObject(target, b); + if (!obj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferSubDataARB(target)"); + return; + } + + if (obj->id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetBufferSubDataARB"); + return; + } + + if (obj->pointer) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetBufferSubDataARB(buffer is mapped)"); + return; + } + + if (size < 0 || offset < 0 || (unsigned int)offset + size > obj->size) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetBufferSubDataARB(bad offset and/or size)"); + return; + } + + if (b->retainBufferData && obj->data) { + crMemcpy(data, (char *) obj->data + offset, size); + } +} + + +void * STATE_APIENTRY +crStateMapBufferARB(GLenum target, GLenum access) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &g->bufferobject; + CRBufferObject *obj; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glMapBufferARB called in begin/end"); + return NULL; + } + + obj = crStateGetBoundBufferObject(target, b); + if (!obj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMapBufferARB(target)"); + return NULL; + } + + if (obj->id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glMapBufferARB"); + return GL_FALSE; + } + + switch (access) { + case GL_READ_ONLY_ARB: + case GL_WRITE_ONLY_ARB: + case GL_READ_WRITE_ARB: + obj->access = access; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glMapBufferARB(access)"); + return NULL; + } + + if (b->retainBufferData && obj->data) + obj->pointer = obj->data; + + return obj->pointer; +} + + +GLboolean STATE_APIENTRY +crStateUnmapBufferARB(GLenum target) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &g->bufferobject; + CRBufferObject *obj; + CRStateBits *sb = GetCurrentBits(); + CRBufferObjectBits *bb = &sb->bufferobject; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glUnmapBufferARB called in begin/end"); + return GL_FALSE; + } + + obj = crStateGetBoundBufferObject(target, b); + if (!obj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glUnmapBufferARB(target)"); + return GL_FALSE; + } + + if (obj->id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB"); + return GL_FALSE; + } + + if (!obj->pointer) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glUnmapBufferARB"); + return GL_FALSE; + } + + obj->pointer = NULL; + + if (obj->access != GL_READ_ONLY_ARB) { + /* the data was most likely modified */ + DIRTY(bb->dirty, g->neg_bitid); + DIRTY(obj->dirty, g->neg_bitid); + obj->dirtyStart = 0; + obj->dirtyLength = obj->size; + } + + return GL_TRUE; +} + + +void STATE_APIENTRY +crStateGetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &g->bufferobject; + CRBufferObject *obj; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetBufferParameterivARB called in begin/end"); + return; + } + + obj = crStateGetBoundBufferObject(target, b); + if (!obj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferParameterivARB(target)"); + return; + } + + switch (pname) { + case GL_BUFFER_SIZE_ARB: + *params = obj->size; + break; + case GL_BUFFER_USAGE_ARB: + *params = obj->usage; + break; + case GL_BUFFER_ACCESS_ARB: + *params = obj->access; + break; + case GL_BUFFER_MAPPED_ARB: + *params = (obj->pointer != NULL); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetBufferParameterivARB(pname)"); + return; + } +} + + +void STATE_APIENTRY +crStateGetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params) +{ + CRContext *g = GetCurrentContext(); + CRBufferObjectState *b = &g->bufferobject; + CRBufferObject *obj; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetBufferPointervARB called in begin/end"); + return; + } + + obj = crStateGetBoundBufferObject(target, b); + if (!obj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(target)"); + return; + } + + if (pname != GL_BUFFER_MAP_POINTER_ARB) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)"); + return; + } + + *params = obj->pointer; +} + + +/** + * We need to check if the GL_EXT_vertex/pixel_buffer_object extensions + * are supported before calling any of the diff_api functions. + * This flag indicates if the extensions is available (1), not available (0) + * or needs to be tested for (-1). + * If we don't do this, we can segfault inside OpenGL. + * Ideally, the render SPU should no-op unsupported GL functions, but + * that's a bit complicated. + */ +static GLboolean +HaveBufferObjectExtension(void) +{ + static GLint haveBufferObjectExt = -1; + + if (haveBufferObjectExt == -1) { + const char *ext; + /* XXX this check is temporary. We need to make the tilesort SPU plug + * GetString into the diff'ing table in order for this to really work. + */ + if (!diff_api.GetString) { + haveBufferObjectExt = 0; + return 0; + } + CRASSERT(diff_api.GetString); + ext = (const char *) diff_api.GetString(GL_EXTENSIONS); + if (crStrstr(ext, "GL_ARB_vertex_buffer_object") || + crStrstr(ext, "GL_ARB_pixel_buffer_object")) { + haveBufferObjectExt = 1; + } + else { + haveBufferObjectExt = 0; + } + } + return haveBufferObjectExt; +} + +static void crStateBufferObjectIntCmp(CRBufferObjectBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx, + GLboolean bSwitch) +{ + CRBufferObjectState *from = &(fromCtx->bufferobject); + const CRBufferObjectState *to = &(toCtx->bufferobject); + + /* ARRAY_BUFFER */ + if (CHECKDIRTY(bb->arrayBinding, bitID)) + { + if (from->arrayBuffer != to->arrayBuffer) + { + GLuint bufferID = to->arrayBuffer ? to->arrayBuffer->hwid : 0; + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, bufferID); + if (bSwitch) + { + FILLDIRTY(bb->arrayBinding); + FILLDIRTY(bb->dirty); + } + else + { + CLEARDIRTY2(bb->arrayBinding, bitID); + from->arrayBuffer = to->arrayBuffer; + } + } + if (bSwitch) CLEARDIRTY2(bb->arrayBinding, bitID); + } + + if (to->arrayBuffer && CHECKDIRTY(to->arrayBuffer->dirty, bitID)) + { + /* update array buffer data */ + CRBufferObject *bufObj = to->arrayBuffer; + CRASSERT(bufObj); + if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) + { + /* update whole buffer */ + diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, bufObj->size, + bufObj->data, bufObj->usage); + } + else + { + /* update sub buffer */ + diff_api.BufferSubDataARB(GL_ARRAY_BUFFER_ARB, + bufObj->dirtyStart, bufObj->dirtyLength, + (char *) bufObj->data + bufObj->dirtyStart); + } + if (bSwitch) FILLDIRTY(bufObj->dirty); + CLEARDIRTY2(bufObj->dirty, bitID); + } + + /* ELEMENTS_BUFFER */ + if (CHECKDIRTY(bb->elementsBinding, bitID)) + { + if (from->elementsBuffer != to->elementsBuffer) + { + GLuint bufferID = to->elementsBuffer ? to->elementsBuffer->hwid : 0; + diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufferID); + if (bSwitch) + { + FILLDIRTY(bb->elementsBinding); + FILLDIRTY(bb->dirty); + } + else + { + CLEARDIRTY2(bb->elementsBinding, bitID); + from->elementsBuffer = to->elementsBuffer; + } + } + if (bSwitch) CLEARDIRTY2(bb->elementsBinding, bitID); + } + + if (to->elementsBuffer && CHECKDIRTY(to->elementsBuffer->dirty, bitID)) + { + /* update array buffer data */ + CRBufferObject *bufObj = to->elementsBuffer; + CRASSERT(bufObj); + if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) + { + /* update whole buffer */ + diff_api.BufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, bufObj->size, + bufObj->data, bufObj->usage); + } + else + { + /* update sub buffer */ + diff_api.BufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, + bufObj->dirtyStart, bufObj->dirtyLength, + (char *) bufObj->data + bufObj->dirtyStart); + } + if (bSwitch) FILLDIRTY(bufObj->dirty); + CLEARDIRTY2(bufObj->dirty, bitID); + } + +#ifdef CR_ARB_pixel_buffer_object + /* PIXEL_PACK_BUFFER */ + if (CHECKDIRTY(bb->packBinding, bitID)) + { + if (from->packBuffer != to->packBuffer) + { + GLuint bufferID = to->packBuffer ? to->packBuffer->hwid : 0; + diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, bufferID); + if (bSwitch) + { + FILLDIRTY(bb->packBinding); + FILLDIRTY(bb->dirty); + } + else + { + CLEARDIRTY2(bb->packBinding, bitID); + from->packBuffer = to->packBuffer; + } + } + if (bSwitch) CLEARDIRTY2(bb->packBinding, bitID); + } + + if (to->packBuffer && CHECKDIRTY(to->packBuffer->dirty, bitID)) + { + /* update array buffer data */ + CRBufferObject *bufObj = to->packBuffer; + CRASSERT(bufObj); + if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) + { + /* update whole buffer */ + diff_api.BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufObj->size, + bufObj->data, bufObj->usage); + } + else + { + /* update sub buffer */ + diff_api.BufferSubDataARB(GL_PIXEL_PACK_BUFFER_ARB, + bufObj->dirtyStart, bufObj->dirtyLength, + (char *) bufObj->data + bufObj->dirtyStart); + } + if (bSwitch) FILLDIRTY(bufObj->dirty); + CLEARDIRTY2(bufObj->dirty, bitID); + } + + /* PIXEL_UNPACK_BUFFER */ + if (CHECKDIRTY(bb->unpackBinding, bitID)) + { + if (from->unpackBuffer != to->unpackBuffer) + { + GLuint bufferID = to->unpackBuffer ? to->unpackBuffer->hwid : 0; + diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufferID); + if (bSwitch) + { + FILLDIRTY(bb->unpackBinding); + FILLDIRTY(bb->dirty); + } + else + { + CLEARDIRTY2(bb->unpackBinding, bitID); + from->unpackBuffer = to->unpackBuffer; + } + } + if (bSwitch) CLEARDIRTY2(bb->unpackBinding, bitID); + } + + if (to->unpackBuffer && CHECKDIRTY(to->unpackBuffer->dirty, bitID)) + { + /* update array buffer data */ + CRBufferObject *bufObj = to->unpackBuffer; + CRASSERT(bufObj); + if (bufObj->dirtyStart == 0 && bufObj->dirtyLength == (int) bufObj->size) + { + /* update whole buffer */ + diff_api.BufferDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, bufObj->size, + bufObj->data, bufObj->usage); + } + else + { + /* update sub buffer */ + diff_api.BufferSubDataARB(GL_PIXEL_UNPACK_BUFFER_ARB, + bufObj->dirtyStart, bufObj->dirtyLength, + (char *) bufObj->data + bufObj->dirtyStart); + } + if (bSwitch) FILLDIRTY(bufObj->dirty); + CLEARDIRTY2(bufObj->dirty, bitID); + } +#endif /*ifdef CR_ARB_pixel_buffer_object*/ +} + +void crStateBufferObjectDiff(CRBufferObjectBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + /*CRBufferObjectState *from = &(fromCtx->bufferobject); - unused + const CRBufferObjectState *to = &(toCtx->bufferobject); - unused */ + + if (!HaveBufferObjectExtension()) + return; + + crStateBufferObjectIntCmp(bb, bitID, fromCtx, toCtx, GL_FALSE); +} + +static void crStateBufferObjectSyncCB(unsigned long key, void *data1, void *data2) +{ + CRBufferObject *pBufferObj = (CRBufferObject *) data1; + CRBufferObjectState *pState = (CRBufferObjectState *) data2; + (void)key; + + if (pBufferObj->id && !pBufferObj->hwid) + { + diff_api.GenBuffersARB(1, &pBufferObj->hwid); + CRASSERT(pBufferObj->hwid); + } + + if (pBufferObj->data) + { + /** @todo http://www.opengl.org/registry/specs/ARB/pixel_buffer_object.txt + "While it is entirely legal to create a buffer object by binding + it to GL_ARRAY_BUFFER and loading it with data, then using it + with the GL_PIXEL_UNPACK_BUFFER_ARB or GL_PIXEL_PACK_BUFFER_ARB + binding, such behavior is liable to confuse the driver and may + hurt performance." + */ + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->hwid); + diff_api.BufferDataARB(GL_ARRAY_BUFFER_ARB, pBufferObj->size, pBufferObj->data, pBufferObj->usage); + + if (!pState->retainBufferData) + { + crFree(pBufferObj->data); + pBufferObj->data = NULL; + } + } +} + +/* + * XXX this function might need some testing/fixing. + */ +void crStateBufferObjectSwitch(CRBufferObjectBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + /*const CRBufferObjectState *from = &(fromCtx->bufferobject); - unused */ + CRBufferObjectState *to = &(toCtx->bufferobject); + int i; + + if (!HaveBufferObjectExtension()) + return; + + if (toCtx->shared->bVBOResyncNeeded) + { + CRClientPointer *cp; + GLboolean locked = toCtx->client.array.locked; + + crHashtableWalk(toCtx->shared->buffersTable, crStateBufferObjectSyncCB, to); + toCtx->shared->bVBOResyncNeeded = GL_FALSE; + + /*@todo, move to state_client.c*/ + cp = &toCtx->client.array.v; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.VertexPointer(cp->size, cp->type, cp->stride, cp->p); + } + + cp = &toCtx->client.array.c; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.ColorPointer(cp->size, cp->type, cp->stride, cp->p); + } + + cp = &toCtx->client.array.f; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.FogCoordPointerEXT(cp->type, cp->stride, cp->p); + } + + cp = &toCtx->client.array.s; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.SecondaryColorPointerEXT(cp->size, cp->type, cp->stride, cp->p); + } + + cp = &toCtx->client.array.e; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.EdgeFlagPointer(cp->stride, cp->p); + } + + cp = &toCtx->client.array.i; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.IndexPointer(cp->type, cp->stride, cp->p); + } + + cp = &toCtx->client.array.n; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.NormalPointer(cp->type, cp->stride, cp->p); + } + + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) + { + cp = &toCtx->client.array.t[i]; + if (cp->buffer && (cp->buffer->id || locked)) + { + if (diff_api.ActiveTextureARB) + diff_api.ActiveTextureARB(i+GL_TEXTURE0_ARB); + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.TexCoordPointer(cp->size, cp->type, cp->stride, cp->p); + } + } + + if (diff_api.ActiveTextureARB) + diff_api.ActiveTextureARB(toCtx->client.curClientTextureUnit+GL_TEXTURE0_ARB); + +#ifdef CR_NV_vertex_program + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) + { + cp = &toCtx->client.array.a[i]; + if (cp->buffer && (cp->buffer->id || locked)) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, cp->buffer->hwid); + diff_api.VertexAttribPointerARB(i, cp->size, cp->type, cp->normalized, cp->stride, cp->p); + } + } +#endif + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, to->arrayBuffer->hwid); + diff_api.BindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, to->elementsBuffer->hwid); +#ifdef CR_ARB_pixel_buffer_object + diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->packBuffer->hwid); + diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->unpackBuffer->hwid); +#endif + } + else + { + crStateBufferObjectIntCmp(bb, bitID, fromCtx, toCtx, GL_TRUE); + } +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_client.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_client.c new file mode 100644 index 00000000..6ca6e159 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_client.c @@ -0,0 +1,2433 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +/* + * This file manages all the client-side state including: + * Pixel pack/unpack parameters + * Vertex arrays + */ + + +#include "cr_mem.h" +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" +#include "state_internals.h" + +const CRPixelPackState crStateNativePixelPacking = { + 0, /* rowLength */ + 0, /* skipRows */ + 0, /* skipPixels */ + 1, /* alignment */ + 0, /* imageHeight */ + 0, /* skipImages */ + GL_FALSE, /* swapBytes */ + GL_FALSE, /* psLSBFirst */ +}; + + +void crStateClientInitBits (CRClientBits *c) +{ + int i; + + /* XXX why GLCLIENT_BIT_ALLOC? */ + c->v = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + c->n = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + c->c = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + c->s = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + c->i = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + for ( i = 0; i < CR_MAX_TEXTURE_UNITS; i++ ) + c->t[i] = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + c->e = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + c->f = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + +#ifdef CR_NV_vertex_program + for ( i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++ ) + c->a[i] = (CRbitvalue *) crCalloc(GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); +#endif +} + +void crStateClientDestroyBits (CRClientBits *c) +{ + int i; + + crFree(c->v); + crFree(c->n); + crFree(c->c); + crFree(c->s); + crFree(c->i); + + for ( i = 0; i < CR_MAX_TEXTURE_UNITS; i++ ) + crFree(c->t[i]); + + crFree(c->e); + crFree(c->f); + +#ifdef CR_NV_vertex_program + for ( i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++ ) + crFree(c->a[i]); +#endif +} + +static void crStateUnlockClientPointer(CRClientPointer* cp) +{ + if (cp->locked) + { +#ifndef IN_GUEST + if (cp->p) crFree(cp->p); +#endif + cp->locked = GL_FALSE; + } +} + +void crStateClientDestroy(CRContext *g) +{ + CRClientState *c = &(g->client); +#ifdef CR_EXT_compiled_vertex_array + if (c->array.locked) + { + unsigned int i; + + crStateUnlockClientPointer(&c->array.v); + crStateUnlockClientPointer(&c->array.c); + crStateUnlockClientPointer(&c->array.f); + crStateUnlockClientPointer(&c->array.s); + crStateUnlockClientPointer(&c->array.e); + crStateUnlockClientPointer(&c->array.i); + crStateUnlockClientPointer(&c->array.n); + for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) + { + crStateUnlockClientPointer(&c->array.t[i]); + } + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) + { + crStateUnlockClientPointer(&c->array.a[i]); + } + } +#endif +} + +void crStateClientInit(CRContext *ctx) +{ + CRClientState *c = &(ctx->client); + unsigned int i; + + /* pixel pack/unpack */ + c->unpack.rowLength = 0; + c->unpack.skipRows = 0; + c->unpack.skipPixels = 0; + c->unpack.skipImages = 0; + c->unpack.alignment = 4; + c->unpack.imageHeight = 0; + c->unpack.swapBytes = GL_FALSE; + c->unpack.psLSBFirst = GL_FALSE; + c->pack.rowLength = 0; + c->pack.skipRows = 0; + c->pack.skipPixels = 0; + c->pack.skipImages = 0; + c->pack.alignment = 4; + c->pack.imageHeight = 0; + c->pack.swapBytes = GL_FALSE; + c->pack.psLSBFirst = GL_FALSE; + + /* ARB multitexture */ + c->curClientTextureUnit = 0; + +#ifdef CR_EXT_compiled_vertex_array + c->array.lockFirst = 0; + c->array.lockCount = 0; + c->array.locked = GL_FALSE; +# ifdef IN_GUEST + c->array.synced = GL_FALSE; +# endif +#endif + + /* vertex array */ + c->array.v.p = NULL; + c->array.v.size = 4; + c->array.v.type = GL_FLOAT; + c->array.v.stride = 0; + c->array.v.enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.v.buffer = ctx->bufferobject.arrayBuffer; + if (c->array.v.buffer) + ++c->array.v.buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.v.locked = GL_FALSE; + c->array.v.prevPtr = NULL; + c->array.v.prevStride = 0; +#endif + + /* color array */ + c->array.c.p = NULL; + c->array.c.size = 4; + c->array.c.type = GL_FLOAT; + c->array.c.stride = 0; + c->array.c.enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.c.buffer = ctx->bufferobject.arrayBuffer; + if (c->array.c.buffer) + ++c->array.c.buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.c.locked = GL_FALSE; + c->array.c.prevPtr = NULL; + c->array.c.prevStride = 0; +#endif + + /* fog array */ + c->array.f.p = NULL; + c->array.f.size = 0; + c->array.f.type = GL_FLOAT; + c->array.f.stride = 0; + c->array.f.enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.f.buffer = ctx->bufferobject.arrayBuffer; + if (c->array.f.buffer) + ++c->array.f.buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.f.locked = GL_FALSE; + c->array.f.prevPtr = NULL; + c->array.f.prevStride = 0; +#endif + + /* secondary color array */ + c->array.s.p = NULL; + c->array.s.size = 3; + c->array.s.type = GL_FLOAT; + c->array.s.stride = 0; + c->array.s.enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.s.buffer = ctx->bufferobject.arrayBuffer; + if (c->array.s.buffer) + ++c->array.s.buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.s.locked = GL_FALSE; + c->array.s.prevPtr = NULL; + c->array.s.prevStride = 0; +#endif + + /* edge flag array */ + c->array.e.p = NULL; + c->array.e.size = 0; + c->array.e.type = GL_FLOAT; + c->array.e.stride = 0; + c->array.e.enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.e.buffer = ctx->bufferobject.arrayBuffer; + if (c->array.e.buffer) + ++c->array.e.buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.e.locked = GL_FALSE; + c->array.e.prevPtr = NULL; + c->array.e.prevStride = 0; +#endif + + /* color index array */ + c->array.i.p = NULL; + c->array.i.size = 0; + c->array.i.type = GL_FLOAT; + c->array.i.stride = 0; + c->array.i.enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.i.buffer = ctx->bufferobject.arrayBuffer; + if (c->array.i.buffer) + ++c->array.i.buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.i.locked = GL_FALSE; + c->array.i.prevPtr = NULL; + c->array.i.prevStride = 0; +#endif + + /* normal array */ + c->array.n.p = NULL; + c->array.n.size = 4; + c->array.n.type = GL_FLOAT; + c->array.n.stride = 0; + c->array.n.enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.n.buffer = ctx->bufferobject.arrayBuffer; + if (c->array.n.buffer) + ++c->array.n.buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.n.locked = GL_FALSE; + c->array.n.prevPtr = NULL; + c->array.n.prevStride = 0; +#endif + + /* texcoord arrays */ + for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) + { + c->array.t[i].p = NULL; + c->array.t[i].size = 4; + c->array.t[i].type = GL_FLOAT; + c->array.t[i].stride = 0; + c->array.t[i].enabled = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.t[i].buffer = ctx->bufferobject.arrayBuffer; + if (c->array.t[i].buffer) + ++c->array.t[i].buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.t[i].locked = GL_FALSE; + c->array.t[i].prevPtr = NULL; + c->array.t[i].prevStride = 0; +#endif + } + + /* generic vertex attributes */ +#ifdef CR_NV_vertex_program + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) { + c->array.a[i].enabled = GL_FALSE; + c->array.a[i].type = GL_FLOAT; + c->array.a[i].size = 4; + c->array.a[i].stride = 0; +#ifdef CR_ARB_vertex_buffer_object + c->array.a[i].buffer = ctx->bufferobject.arrayBuffer; + if (c->array.a[i].buffer) + ++c->array.a[i].buffer->refCount; +#endif +#ifdef CR_EXT_compiled_vertex_array + c->array.a[i].locked = GL_FALSE; + c->array.a[i].prevPtr = NULL; + c->array.a[i].prevStride = 0; +#endif + } +#endif +} + + +/* + * PixelStore functions are here, not in state_pixel.c because this + * is client-side state, like vertex arrays. + */ + +void STATE_APIENTRY crStatePixelStoref (GLenum pname, GLfloat param) +{ + + /* The GL SPEC says I can do this on page 76. */ + switch( pname ) + { + case GL_PACK_SWAP_BYTES: + case GL_PACK_LSB_FIRST: + case GL_UNPACK_SWAP_BYTES: + case GL_UNPACK_LSB_FIRST: + crStatePixelStorei( pname, param == 0.0f ? 0: 1 ); + break; + default: + crStatePixelStorei( pname, (GLint) param ); + break; + } +} + +void STATE_APIENTRY crStatePixelStorei (GLenum pname, GLint param) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelStore{if} called in Begin/End"); + return; + } + + FLUSH(); + + switch(pname) { + case GL_PACK_SWAP_BYTES: + c->pack.swapBytes = (GLboolean) param; + DIRTY(cb->pack, g->neg_bitid); + break; + case GL_PACK_LSB_FIRST: + c->pack.psLSBFirst = (GLboolean) param; + DIRTY(cb->pack, g->neg_bitid); + break; + case GL_PACK_ROW_LENGTH: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Row Length: %f", param); + return; + } + c->pack.rowLength = param; + DIRTY(cb->pack, g->neg_bitid); + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_PACK_IMAGE_HEIGHT: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Image Height: %f", param); + return; + } + c->pack.imageHeight = param; + DIRTY(cb->pack, g->neg_bitid); + break; +#endif + case GL_PACK_SKIP_IMAGES: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Skip Images: %f", param); + return; + } + c->pack.skipImages = param; + DIRTY(cb->pack, g->neg_bitid); + break; + case GL_PACK_SKIP_PIXELS: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Skip Pixels: %f", param); + return; + } + c->pack.skipPixels = param; + DIRTY(cb->pack, g->neg_bitid); + break; + case GL_PACK_SKIP_ROWS: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Row Skip: %f", param); + return; + } + c->pack.skipRows = param; + DIRTY(cb->pack, g->neg_bitid); + break; + case GL_PACK_ALIGNMENT: + if (((GLint) param) != 1 && + ((GLint) param) != 2 && + ((GLint) param) != 4 && + ((GLint) param) != 8) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid Alignment: %f", param); + return; + } + c->pack.alignment = param; + DIRTY(cb->pack, g->neg_bitid); + break; + + case GL_UNPACK_SWAP_BYTES: + c->unpack.swapBytes = (GLboolean) param; + DIRTY(cb->unpack, g->neg_bitid); + break; + case GL_UNPACK_LSB_FIRST: + c->unpack.psLSBFirst = (GLboolean) param; + DIRTY(cb->unpack, g->neg_bitid); + break; + case GL_UNPACK_ROW_LENGTH: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Row Length: %f", param); + return; + } + c->unpack.rowLength = param; + DIRTY(cb->unpack, g->neg_bitid); + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNPACK_IMAGE_HEIGHT: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Image Height: %f", param); + return; + } + c->unpack.imageHeight = param; + DIRTY(cb->unpack, g->neg_bitid); + break; +#endif + case GL_UNPACK_SKIP_IMAGES: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Skip Images: %f", param); + return; + } + c->unpack.skipImages = param; + DIRTY(cb->unpack, g->neg_bitid); + break; + case GL_UNPACK_SKIP_PIXELS: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Skip Pixels: %f", param); + return; + } + c->unpack.skipPixels = param; + DIRTY(cb->unpack, g->neg_bitid); + break; + case GL_UNPACK_SKIP_ROWS: + if (param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative Row Skip: %f", param); + return; + } + c->unpack.skipRows = param; + DIRTY(cb->unpack, g->neg_bitid); + break; + case GL_UNPACK_ALIGNMENT: + if (((GLint) param) != 1 && + ((GLint) param) != 2 && + ((GLint) param) != 4 && + ((GLint) param) != 8) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid Alignment: %f", param); + return; + } + c->unpack.alignment = param; + DIRTY(cb->unpack, g->neg_bitid); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Unknown glPixelStore Pname: %d", pname); + return; + } + DIRTY(cb->dirty, g->neg_bitid); +} + + +static void setClientState(CRClientState *c, CRClientBits *cb, + CRbitvalue *neg_bitid, GLenum array, GLboolean state) +{ + CRContext *g = GetCurrentContext(); + + switch (array) + { +#ifdef CR_NV_vertex_program + case GL_VERTEX_ATTRIB_ARRAY0_NV: + case GL_VERTEX_ATTRIB_ARRAY1_NV: + case GL_VERTEX_ATTRIB_ARRAY2_NV: + case GL_VERTEX_ATTRIB_ARRAY3_NV: + case GL_VERTEX_ATTRIB_ARRAY4_NV: + case GL_VERTEX_ATTRIB_ARRAY5_NV: + case GL_VERTEX_ATTRIB_ARRAY6_NV: + case GL_VERTEX_ATTRIB_ARRAY7_NV: + case GL_VERTEX_ATTRIB_ARRAY8_NV: + case GL_VERTEX_ATTRIB_ARRAY9_NV: + case GL_VERTEX_ATTRIB_ARRAY10_NV: + case GL_VERTEX_ATTRIB_ARRAY11_NV: + case GL_VERTEX_ATTRIB_ARRAY12_NV: + case GL_VERTEX_ATTRIB_ARRAY13_NV: + case GL_VERTEX_ATTRIB_ARRAY14_NV: + case GL_VERTEX_ATTRIB_ARRAY15_NV: + { + const GLuint i = array - GL_VERTEX_ATTRIB_ARRAY0_NV; + c->array.a[i].enabled = state; + } + break; +#endif + case GL_VERTEX_ARRAY: + c->array.v.enabled = state; + break; + case GL_COLOR_ARRAY: + c->array.c.enabled = state; + break; + case GL_NORMAL_ARRAY: + c->array.n.enabled = state; + break; + case GL_INDEX_ARRAY: + c->array.i.enabled = state; + break; + case GL_TEXTURE_COORD_ARRAY: + c->array.t[c->curClientTextureUnit].enabled = state; + break; + case GL_EDGE_FLAG_ARRAY: + c->array.e.enabled = state; + break; +#ifdef CR_EXT_fog_coord + case GL_FOG_COORDINATE_ARRAY_EXT: + c->array.f.enabled = state; + break; +#endif +#ifdef CR_EXT_secondary_color + case GL_SECONDARY_COLOR_ARRAY_EXT: + if( g->extensions.EXT_secondary_color ){ + c->array.s.enabled = state; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid Enum passed to Enable/Disable Client State: SECONDARY_COLOR_ARRAY_EXT - EXT_secondary_color is not enabled." ); + return; + } + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid Enum passed to Enable/Disable Client State: 0x%x", array ); + return; + } + DIRTY(cb->dirty, neg_bitid); + DIRTY(cb->enableClientState, neg_bitid); +} + +void STATE_APIENTRY crStateEnableClientState (GLenum array) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + setClientState(c, cb, g->neg_bitid, array, GL_TRUE); +} + +void STATE_APIENTRY crStateDisableClientState (GLenum array) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + setClientState(c, cb, g->neg_bitid, array, GL_FALSE); +} + +static void +crStateClientSetPointer(CRClientPointer *cp, GLint size, + GLenum type, GLboolean normalized, + GLsizei stride, const GLvoid *pointer) +{ + CRContext *g = GetCurrentContext(); + +#ifdef CR_EXT_compiled_vertex_array + crStateUnlockClientPointer(cp); + cp->prevPtr = cp->p; + cp->prevStride = cp->stride; +#endif + + cp->p = (unsigned char *) pointer; + cp->size = size; + cp->type = type; + cp->normalized = normalized; + + /* Calculate the bytes per index for address calculation */ + cp->bytesPerIndex = size; + switch (type) + { + case GL_BYTE: + case GL_UNSIGNED_BYTE: + break; + case GL_SHORT: + case GL_UNSIGNED_SHORT: + cp->bytesPerIndex *= sizeof(GLshort); + break; + case GL_INT: + case GL_UNSIGNED_INT: + cp->bytesPerIndex *= sizeof(GLint); + break; + case GL_FLOAT: + cp->bytesPerIndex *= sizeof(GLfloat); + break; + case GL_DOUBLE: + cp->bytesPerIndex *= sizeof(GLdouble); + break; + default: + crStateError( __LINE__, __FILE__, GL_INVALID_VALUE, + "Unknown type of vertex array: %d", type ); + return; + } + + /* + ** Note: If stride==0 then we set the + ** stride equal address offset + ** therefore stride can never equal + ** zero. + */ + if (stride) + cp->stride = stride; + else + cp->stride = cp->bytesPerIndex; + +#ifdef CR_ARB_vertex_buffer_object + if (cp->buffer) + { + --cp->buffer->refCount; + CRASSERT(cp->buffer->refCount && cp->buffer->refCount < UINT32_MAX/2); + } + cp->buffer = g->bufferobject.arrayBuffer; + if (cp->buffer) + ++cp->buffer->refCount; +#endif +} + +void STATE_APIENTRY crStateVertexPointer(GLint size, GLenum type, + GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (size != 2 && size != 3 && size != 4) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexPointer: invalid size: %d", size); + return; + } + if (type != GL_SHORT && type != GL_INT && + type != GL_FLOAT && type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glVertexPointer: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexPointer: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.v), size, type, GL_FALSE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->v, g->neg_bitid); +} + +void STATE_APIENTRY crStateColorPointer(GLint size, GLenum type, + GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (size != 3 && size != 4) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glColorPointer: invalid size: %d", size); + return; + } + if (type != GL_BYTE && type != GL_UNSIGNED_BYTE && + type != GL_SHORT && type != GL_UNSIGNED_SHORT && + type != GL_INT && type != GL_UNSIGNED_INT && + type != GL_FLOAT && type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glColorPointer: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glColorPointer: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.c), size, type, GL_TRUE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->c, g->neg_bitid); +} + +void STATE_APIENTRY crStateSecondaryColorPointerEXT(GLint size, + GLenum type, GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if ( !g->extensions.EXT_secondary_color ) + { + crError( "glSecondaryColorPointerEXT called but EXT_secondary_color is disabled." ); + return; + } + + /*Note: According to opengl spec, only size==3 should be accepted here. + *But it turns out that most drivers accept size==4 here as well, and 4th value + *could even be accessed in shaders code. + *Having a strict check here, leads to difference between guest and host gpu states, which + *in turn could lead to crashes when using server side VBOs. + *@todo: add error reporting to state's VBO related functions and abort dispatching to + *real gpu on any failure to prevent other possible issues. + */ + + if ((size != 3) && (size != 4)) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glSecondaryColorPointerEXT: invalid size: %d", size); + return; + } + if (type != GL_BYTE && type != GL_UNSIGNED_BYTE && + type != GL_SHORT && type != GL_UNSIGNED_SHORT && + type != GL_INT && type != GL_UNSIGNED_INT && + type != GL_FLOAT && type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glSecondaryColorPointerEXT: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glSecondaryColorPointerEXT: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.s), size, type, GL_TRUE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->s, g->neg_bitid); +} + +void STATE_APIENTRY crStateIndexPointer(GLenum type, GLsizei stride, + const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (type != GL_SHORT && type != GL_INT && type != GL_UNSIGNED_BYTE && + type != GL_FLOAT && type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glIndexPointer: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glIndexPointer: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.i), 1, type, GL_TRUE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->i, g->neg_bitid); +} + +void STATE_APIENTRY crStateNormalPointer(GLenum type, GLsizei stride, + const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (type != GL_BYTE && type != GL_SHORT && + type != GL_INT && type != GL_FLOAT && + type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glNormalPointer: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glNormalPointer: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.n), 3, type, GL_TRUE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->n, g->neg_bitid); +} + +void STATE_APIENTRY crStateTexCoordPointer(GLint size, GLenum type, + GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (size != 1 && size != 2 && size != 3 && size != 4) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexCoordPointer: invalid size: %d", size); + return; + } + if (type != GL_SHORT && type != GL_INT && + type != GL_FLOAT && type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexCoordPointer: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexCoordPointer: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.t[c->curClientTextureUnit]), size, type, GL_FALSE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->t[c->curClientTextureUnit], g->neg_bitid); +} + +void STATE_APIENTRY crStateEdgeFlagPointer(GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexCoordPointer: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.e), 1, GL_UNSIGNED_BYTE, GL_FALSE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->e, g->neg_bitid); +} + +void STATE_APIENTRY crStateFogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (type != GL_BYTE && type != GL_UNSIGNED_BYTE && + type != GL_SHORT && type != GL_UNSIGNED_SHORT && + type != GL_INT && type != GL_UNSIGNED_INT && + type != GL_FLOAT && type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glFogCoordPointerEXT: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glFogCoordPointerEXT: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.f), 1, type, GL_FALSE, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->f, g->neg_bitid); +} + + +void STATE_APIENTRY crStateVertexAttribPointerNV(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *p) +{ + GLboolean normalized = GL_FALSE; + /* Extra error checking for NV arrays */ + if (type != GL_UNSIGNED_BYTE && type != GL_SHORT && + type != GL_FLOAT && type != GL_DOUBLE) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glVertexAttribPointerNV: invalid type: 0x%x", type); + return; + } + crStateVertexAttribPointerARB(index, size, type, normalized, stride, p); +} + + +void STATE_APIENTRY crStateVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + FLUSH(); + + if (index >= CR_MAX_VERTEX_ATTRIBS) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexAttribPointerARB: invalid index: %d", (int) index); + return; + } + if (size != 1 && size != 2 && size != 3 && size != 4) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexAttribPointerARB: invalid size: %d", size); + return; + } + if (type != GL_BYTE && type != GL_UNSIGNED_BYTE && + type != GL_SHORT && type != GL_UNSIGNED_SHORT && + type != GL_INT && type != GL_UNSIGNED_INT && + type != GL_FLOAT && type != GL_DOUBLE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glVertexAttribPointerARB: invalid type: 0x%x", type); + return; + } + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glVertexAttribPointerARB: stride was negative: %d", stride); + return; + } + + crStateClientSetPointer(&(c->array.a[index]), size, type, normalized, stride, p); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + DIRTY(cb->a[index], g->neg_bitid); +} + + +void STATE_APIENTRY crStateGetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetVertexAttribPointervNV called in Begin/End"); + return; + } + + if (index >= CR_MAX_VERTEX_ATTRIBS) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetVertexAttribPointervNV(index)"); + return; + } + + if (pname != GL_ATTRIB_ARRAY_POINTER_NV) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetVertexAttribPointervNV(pname)"); + return; + } + + *pointer = g->client.array.a[index].p; +} + + +void STATE_APIENTRY crStateGetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer) +{ + crStateGetVertexAttribPointervNV(index, pname, pointer); +} + + + +/* +** Currently I treat Interleaved Arrays as if the +** user uses them as separate arrays. +** Certainly not the most efficient method but it +** lets me use the same glDrawArrays method. +*/ +void STATE_APIENTRY crStateInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *p) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + CRClientPointer *cp; + unsigned char *base = (unsigned char *) p; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glInterleavedArrays called in begin/end"); + return; + } + + FLUSH(); + + if (stride < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glInterleavedArrays: stride < 0: %d", stride); + return; + } + + switch (format) + { + case GL_T4F_C4F_N3F_V4F: + case GL_T2F_C4F_N3F_V3F: + case GL_C4F_N3F_V3F: + case GL_T4F_V4F: + case GL_T2F_C3F_V3F: + case GL_T2F_N3F_V3F: + case GL_C3F_V3F: + case GL_N3F_V3F: + case GL_T2F_C4UB_V3F: + case GL_T2F_V3F: + case GL_C4UB_V3F: + case GL_V3F: + case GL_C4UB_V2F: + case GL_V2F: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glInterleavedArrays: Unrecognized format: %d", format); + return; + } + + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->clientPointer, g->neg_bitid); + +/* p, size, type, stride, enabled, bytesPerIndex */ +/* +** VertexPointer +*/ + + cp = &(c->array.v); + cp->type = GL_FLOAT; + cp->enabled = GL_TRUE; + +#ifdef CR_EXT_compiled_vertex_array + crStateUnlockClientPointer(cp); +#endif + + switch (format) + { + case GL_T4F_C4F_N3F_V4F: + cp->p = base+4*sizeof(GLfloat)+4*sizeof(GLfloat)+3*sizeof(GLfloat); + cp->size = 4; + break; + case GL_T2F_C4F_N3F_V3F: + cp->p = base+2*sizeof(GLfloat)+4*sizeof(GLfloat)+3*sizeof(GLfloat); + cp->size = 3; + break; + case GL_C4F_N3F_V3F: + cp->p = base+4*sizeof(GLfloat)+3*sizeof(GLfloat); + cp->size = 3; + break; + case GL_T4F_V4F: + cp->p = base+4*sizeof(GLfloat); + cp->size = 4; + break; + case GL_T2F_C3F_V3F: + cp->p = base+2*sizeof(GLfloat)+3*sizeof(GLfloat); + cp->size = 3; + break; + case GL_T2F_N3F_V3F: + cp->p = base+2*sizeof(GLfloat)+3*sizeof(GLfloat); + cp->size = 3; + break; + case GL_C3F_V3F: + cp->p = base+3*sizeof(GLfloat); + cp->size = 3; + break; + case GL_N3F_V3F: + cp->p = base+3*sizeof(GLfloat); + cp->size = 3; + break; + case GL_T2F_C4UB_V3F: + cp->p = base+2*sizeof(GLfloat)+4*sizeof(GLubyte); + cp->size = 3; + break; + case GL_T2F_V3F: + cp->p = base+2*sizeof(GLfloat); + cp->size = 3; + break; + case GL_C4UB_V3F: + cp->p = base+4*sizeof(GLubyte); + cp->size = 3; + break; + case GL_V3F: + cp->p = base; + cp->size = 3; + break; + case GL_C4UB_V2F: + cp->p = base+4*sizeof(GLubyte); + cp->size = 2; + break; + case GL_V2F: + cp->p = base; + cp->size = 2; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glInterleavedArrays: Unrecognized format: %d", format); + return; + } + + cp->bytesPerIndex = cp->size * sizeof (GLfloat); + + if (stride==0) + stride = cp->bytesPerIndex + (cp->p - base); + cp->stride = stride; + +/* +** NormalPointer +*/ + + cp = &(c->array.n); + cp->enabled = GL_TRUE; + cp->stride = stride; +#ifdef CR_EXT_compiled_vertex_array + crStateUnlockClientPointer(cp); +#endif + + switch (format) + { + case GL_T4F_C4F_N3F_V4F: + cp->p = base+4*sizeof(GLfloat)+4*sizeof(GLfloat); + break; + case GL_T2F_C4F_N3F_V3F: + cp->p = base+2*sizeof(GLfloat)+4*sizeof(GLfloat); + break; + case GL_C4F_N3F_V3F: + cp->p = base+4*sizeof(GLfloat); + break; + case GL_T2F_N3F_V3F: + cp->p = base+2*sizeof(GLfloat); + break; + case GL_N3F_V3F: + cp->p = base; + break; + case GL_T4F_V4F: + case GL_T2F_C3F_V3F: + case GL_C3F_V3F: + case GL_T2F_C4UB_V3F: + case GL_T2F_V3F: + case GL_C4UB_V3F: + case GL_V3F: + case GL_C4UB_V2F: + case GL_V2F: + cp->enabled = GL_FALSE; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glInterleavedArrays: Unrecognized format: %d", format); + return; + } + + if (cp->enabled) + { + cp->type = GL_FLOAT; + cp->size = 3; + cp->bytesPerIndex = cp->size * sizeof (GLfloat); + } + +/* +** ColorPointer +*/ + + cp = &(c->array.c); + cp->enabled = GL_TRUE; + cp->stride = stride; +#ifdef CR_EXT_compiled_vertex_array + crStateUnlockClientPointer(cp); +#endif + + switch (format) + { + case GL_T4F_C4F_N3F_V4F: + cp->size = 4; + cp->type = GL_FLOAT; + cp->bytesPerIndex = cp->size * sizeof(GLfloat); + cp->p = base+4*sizeof(GLfloat); + break; + case GL_T2F_C4F_N3F_V3F: + cp->size = 4; + cp->type = GL_FLOAT; + cp->bytesPerIndex = cp->size * sizeof(GLfloat); + cp->p = base+2*sizeof(GLfloat); + break; + case GL_C4F_N3F_V3F: + cp->size = 4; + cp->type = GL_FLOAT; + cp->bytesPerIndex = cp->size * sizeof(GLfloat); + cp->p = base; + break; + case GL_T2F_C3F_V3F: + cp->size = 3; + cp->type = GL_FLOAT; + cp->bytesPerIndex = cp->size * sizeof(GLfloat); + cp->p = base+2*sizeof(GLfloat); + break; + case GL_C3F_V3F: + cp->size = 3; + cp->type = GL_FLOAT; + cp->bytesPerIndex = cp->size * sizeof(GLfloat); + cp->p = base; + break; + case GL_T2F_C4UB_V3F: + cp->size = 4; + cp->type = GL_UNSIGNED_BYTE; + cp->bytesPerIndex = cp->size * sizeof(GLubyte); + cp->p = base+2*sizeof(GLfloat); + break; + case GL_C4UB_V3F: + cp->size = 4; + cp->type = GL_UNSIGNED_BYTE; + cp->bytesPerIndex = cp->size * sizeof(GLubyte); + cp->p = base; + break; + case GL_C4UB_V2F: + cp->size = 4; + cp->type = GL_UNSIGNED_BYTE; + cp->bytesPerIndex = cp->size * sizeof(GLubyte); + cp->p = base; + break; + case GL_T2F_N3F_V3F: + case GL_N3F_V3F: + case GL_T4F_V4F: + case GL_T2F_V3F: + case GL_V3F: + case GL_V2F: + cp->enabled = GL_FALSE; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glInterleavedArrays: Unrecognized format: %d", format); + return; + } + +/* +** TexturePointer +*/ + + cp = &(c->array.t[c->curClientTextureUnit]); + cp->enabled = GL_TRUE; + cp->stride = stride; +#ifdef CR_EXT_compiled_vertex_array + crStateUnlockClientPointer(cp); +#endif + + switch (format) + { + case GL_T4F_C4F_N3F_V4F: + cp->size = 4; + cp->p = base; + break; + case GL_T2F_C4F_N3F_V3F: + cp->size = 3; + cp->p = base; + break; + case GL_T2F_C3F_V3F: + case GL_T2F_N3F_V3F: + cp->size = 3; + cp->p = base; + break; + case GL_T2F_C4UB_V3F: + cp->size = 3; + cp->p = base; + break; + case GL_T4F_V4F: + cp->size = 4; + cp->p = base; + break; + case GL_T2F_V3F: + cp->size = 3; + cp->p = base; + break; + case GL_C4UB_V3F: + case GL_C4UB_V2F: + case GL_C3F_V3F: + case GL_C4F_N3F_V3F: + case GL_N3F_V3F: + case GL_V3F: + case GL_V2F: + cp->enabled = GL_FALSE; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glInterleavedArrays: Unrecognized format: %d", format); + return; + } + + if (cp->enabled) + { + cp->type = GL_FLOAT; + cp->bytesPerIndex = cp->size * sizeof (GLfloat); + } +} + +void STATE_APIENTRY crStateGetPointerv(GLenum pname, GLvoid * * params) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "GetPointerv called in begin/end"); + return; + } + + switch (pname) + { + case GL_VERTEX_ARRAY_POINTER: + *params = (GLvoid *) c->array.v.p; + break; + case GL_COLOR_ARRAY_POINTER: + *params = (GLvoid *) c->array.c.p; + break; + case GL_NORMAL_ARRAY_POINTER: + *params = (GLvoid *) c->array.n.p; + break; + case GL_INDEX_ARRAY_POINTER: + *params = (GLvoid *) c->array.i.p; + break; + case GL_TEXTURE_COORD_ARRAY_POINTER: + *params = (GLvoid *) c->array.t[c->curClientTextureUnit].p; + break; + case GL_EDGE_FLAG_ARRAY_POINTER: + *params = (GLvoid *) c->array.e.p; + break; +#ifdef CR_EXT_fog_coord + case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: + *params = (GLvoid *) c->array.f.p; + break; +#endif +#ifdef CR_EXT_secondary_color + case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT: + if( g->extensions.EXT_secondary_color ){ + *params = (GLvoid *) c->array.s.p; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid Enum passed to glGetPointerv: SECONDARY_COLOR_ARRAY_EXT - EXT_secondary_color is not enabled." ); + return; + } + break; +#endif + case GL_FEEDBACK_BUFFER_POINTER: + case GL_SELECTION_BUFFER_POINTER: + /* do nothing - API switching should pick this up */ + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetPointerv: invalid pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY crStatePushClientAttrib( GLbitfield mask ) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glPushClientAttrib called in Begin/End"); + return; + } + + if (c->attribStackDepth == CR_MAX_CLIENT_ATTRIB_STACK_DEPTH - 1) { + crStateError(__LINE__, __FILE__, GL_STACK_OVERFLOW, + "glPushClientAttrib called with a full stack!" ); + return; + } + + FLUSH(); + + c->pushMaskStack[c->attribStackDepth++] = mask; + + if (mask & GL_CLIENT_PIXEL_STORE_BIT) { + c->pixelPackStoreStack[c->pixelStoreStackDepth] = c->pack; + c->pixelUnpackStoreStack[c->pixelStoreStackDepth] = c->unpack; + c->pixelStoreStackDepth++; + } + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + c->vertexArrayStack[c->vertexArrayStackDepth] = c->array; + c->vertexArrayStackDepth++; + } + + /* dirty? - no, because we haven't really changed any state */ +} + + +void STATE_APIENTRY crStatePopClientAttrib( void ) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + CRbitvalue mask; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glPopClientAttrib called in Begin/End"); + return; + } + + if (c->attribStackDepth == 0) { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, + "glPopClientAttrib called with an empty stack!" ); + return; + } + + FLUSH(); + + mask = c->pushMaskStack[--c->attribStackDepth]; + + if (mask & GL_CLIENT_PIXEL_STORE_BIT) { + if (c->pixelStoreStackDepth == 0) { + crError("bug in glPopClientAttrib (pixel store) "); + return; + } + c->pixelStoreStackDepth--; + c->pack = c->pixelPackStoreStack[c->pixelStoreStackDepth]; + c->unpack = c->pixelUnpackStoreStack[c->pixelStoreStackDepth]; + DIRTY(cb->pack, g->neg_bitid); + } + + if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) { + if (c->vertexArrayStackDepth == 0) { + crError("bug in glPopClientAttrib (vertex array) "); + return; + } + c->vertexArrayStackDepth--; + c->array = c->vertexArrayStack[c->vertexArrayStackDepth]; + DIRTY(cb->clientPointer, g->neg_bitid); + } + + DIRTY(cb->dirty, g->neg_bitid); +} + +static void crStateLockClientPointer(CRClientPointer* cp) +{ + crStateUnlockClientPointer(cp); + if (cp->enabled) + { + cp->locked = GL_TRUE; + } +} + +static GLboolean crStateCanLockClientPointer(CRClientPointer* cp) +{ + return !(cp->enabled && cp->buffer && cp->buffer->id); +} + +void STATE_APIENTRY crStateLockArraysEXT(GLint first, GLint count) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + int i; + + for (i=0; iarray))) + { + break; + } + } + if (iarray.locked = GL_TRUE; + c->array.lockFirst = first; + c->array.lockCount = count; +#ifdef IN_GUEST + c->array.synced = GL_FALSE; +#endif + + for (i=0; iarray)); + } +} + +void STATE_APIENTRY crStateUnlockArraysEXT() +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + int i; + + if (!c->array.locked) + { + crDebug("crStateUnlockArraysEXT ignored because arrays aren't locked"); + return; + } + + c->array.locked = GL_FALSE; +#ifdef IN_GUEST + c->array.synced = GL_FALSE; +#endif + + for (i=0; iarray)); + } +} + +void STATE_APIENTRY crStateVertexArrayRangeNV(GLsizei length, const GLvoid *pointer) +{ + /* XXX todo */ + crWarning("crStateVertexArrayRangeNV not implemented"); + (void)length; (void)pointer; +} + + +void STATE_APIENTRY crStateFlushVertexArrayRangeNV(void) +{ + /* XXX todo */ + crWarning("crStateFlushVertexArrayRangeNV not implemented"); +} + +/*Returns if the given clientpointer could be used on server side directly*/ +#define CRSTATE_IS_SERVER_CP(cp) (!(cp).enabled || !(cp).p || ((cp).buffer && (cp).buffer->id) || ((cp).locked)) + +#if defined(DEBUG) && 0 +static void crStateDumpClientPointer(CRClientPointer *cp, const char *name, int i) +{ + if (i<0 && cp->enabled) + { + crDebug("CP(%s): enabled:%d ptr:%p buffer:%p buffer.name:%i locked: %i %s", + name, cp->enabled, cp->p, cp->buffer, cp->buffer ? cp->buffer->id : ~(GLuint)0, (int)cp->locked, + CRSTATE_IS_SERVER_CP(*cp) ? "":"!FAIL!"); + } + else if (0==i || cp->enabled) + { + crDebug("CP(%s%i): enabled:%d ptr:%p buffer:%p buffer.name:%i locked: %i %s", + name, i, cp->enabled, cp->p, cp->buffer, cp->buffer ? cp->buffer->id : ~(GLuint)0, (int)cp->locked, + CRSTATE_IS_SERVER_CP(*cp) ? "":"!FAIL!"); + } +} +#endif + +#ifdef DEBUG_misha +/* debugging */ +/*# define CR_NO_SERVER_ARRAYS*/ +#endif + +/* + * Determine if the enabled arrays all live on the server + * (via GL_ARB_vertex_buffer_object). + */ +GLboolean crStateUseServerArrays(void) +{ +#if defined(CR_ARB_vertex_buffer_object) && !defined(CR_NO_SERVER_ARRAYS) + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + int i; + GLboolean res; + + res = CRSTATE_IS_SERVER_CP(c->array.v) + && CRSTATE_IS_SERVER_CP(c->array.n) + && CRSTATE_IS_SERVER_CP(c->array.c) + && CRSTATE_IS_SERVER_CP(c->array.i) + && CRSTATE_IS_SERVER_CP(c->array.e) + && CRSTATE_IS_SERVER_CP(c->array.s) + && CRSTATE_IS_SERVER_CP(c->array.f); + + if (res) + { + for (i = 0; (unsigned int)i < g->limits.maxTextureUnits; i++) + if (!CRSTATE_IS_SERVER_CP(c->array.t[i])) + { + res = GL_FALSE; + break; + } + } + + if (res) + { + for (i = 0; (unsigned int)i < g->limits.maxVertexProgramAttribs; i++) + if (!CRSTATE_IS_SERVER_CP(c->array.a[i])) + { + res = GL_FALSE; + break; + } + } + +#if defined(DEBUG) && 0 + if (!res) + { + crStateDumpClientPointer(&c->array.v, "v", -1); + crStateDumpClientPointer(&c->array.n, "n", -1); + crStateDumpClientPointer(&c->array.c, "c", -1); + crStateDumpClientPointer(&c->array.i, "i", -1); + crStateDumpClientPointer(&c->array.e, "e", -1); + crStateDumpClientPointer(&c->array.s, "s", -1); + crStateDumpClientPointer(&c->array.f, "f", -1); + for (i = 0; (unsigned int)i < g->limits.maxTextureUnits; i++) + crStateDumpClientPointer(&c->array.t[i], "tex", i); + for (i = 0; (unsigned int)i < g->limits.maxVertexProgramAttribs; i++) + crStateDumpClientPointer(&c->array.a[i], "attrib", i); + crDebug("crStateUseServerArrays->%d", res); + } +#endif + + return res; +#else + return GL_FALSE; +#endif +} + +GLuint crStateNeedDummyZeroVertexArray(CRContext *g, CRCurrentStatePointers *current, GLfloat *pZva) +{ +#if defined(CR_ARB_vertex_buffer_object) + CRClientState *c = &(g->client); + int i; + GLuint zvMax = 0; + + if (c->array.a[0].enabled) + return 0; + + for (i = 1; (unsigned int)i < g->limits.maxVertexProgramAttribs; i++) + { + if (c->array.a[i].enabled) + { + if (c->array.a[i].buffer && c->array.a[i].buffer->id) + { + GLuint cElements = c->array.a[i].buffer->size / c->array.a[i].stride; + if (zvMax < cElements) + zvMax = cElements; + } + else + { + zvMax = ~0; + break; + } + } + } + + if (zvMax) + { + Assert(!c->array.v.enabled); + + crStateCurrentRecoverNew(g, current); + + crMemcpy(pZva, &g->current.vertexAttrib[0][0], sizeof (*pZva) * 4); + } + + return zvMax; +#else + return GL_FALSE; +#endif +} + + +/** + * Determine if there's a server-side array element buffer. + * Called by glDrawElements() in packing SPUs to determine if glDrawElements + * should be evaluated (unrolled) locally or if glDrawElements should be + * packed and sent to the server. + */ +GLboolean +crStateUseServerArrayElements(void) +{ +#ifdef CR_ARB_vertex_buffer_object + CRContext *g = GetCurrentContext(); + if (g->bufferobject.elementsBuffer && + g->bufferobject.elementsBuffer->id > 0) + return GL_TRUE; + else + return GL_FALSE; +#else + return GL_FALSE; +#endif +} + +#define CR_BUFFER_HWID(_p) ((_p) ? (_p)->hwid : 0) + +void +crStateClientDiff(CRClientBits *cb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRClientState *from = &(fromCtx->client); + const CRClientState *to = &(toCtx->client); + GLint curClientTextureUnit = from->curClientTextureUnit; + int i; + GLint idHwArrayBuffer = CR_BUFFER_HWID(toCtx->bufferobject.arrayBuffer); + const GLint idHwInitialBuffer = idHwArrayBuffer; + +#ifdef DEBUG_misha + { + GLint tstHwBuffer = -1; + diff_api.GetIntegerv(GL_ARRAY_BUFFER_BINDING, &tstHwBuffer); + CRASSERT(idHwInitialBuffer == tstHwBuffer); + } +#endif + + + if (CHECKDIRTY(cb->clientPointer, bitID)) { + /* one or more vertex pointers is dirty */ + if (CHECKDIRTY(cb->v, bitID)) { + if (from->array.v.size != to->array.v.size || + from->array.v.type != to->array.v.type || + from->array.v.stride != to->array.v.stride || + from->array.v.p != to->array.v.p || + from->array.v.buffer != to->array.v.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.v.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.VertexPointer(to->array.v.size, to->array.v.type, + to->array.v.stride, to->array.v.p); + from->array.v.size = to->array.v.size; + from->array.v.type = to->array.v.type; + from->array.v.stride = to->array.v.stride; + from->array.v.p = to->array.v.p; + from->array.v.buffer = to->array.v.buffer; + } + CLEARDIRTY2(cb->v, bitID); + } + /* normal */ + if (CHECKDIRTY(cb->n, bitID)) { + if (from->array.n.type != to->array.n.type || + from->array.n.stride != to->array.n.stride || + from->array.n.p != to->array.n.p || + from->array.n.buffer != to->array.n.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.n.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.NormalPointer(to->array.n.type, + to->array.n.stride, to->array.n.p); + from->array.n.type = to->array.n.type; + from->array.n.stride = to->array.n.stride; + from->array.n.p = to->array.n.p; + from->array.n.buffer = to->array.n.buffer; + } + CLEARDIRTY2(cb->n, bitID); + } + /* color */ + if (CHECKDIRTY(cb->c, bitID)) { + if (from->array.c.size != to->array.c.size || + from->array.c.type != to->array.c.type || + from->array.c.stride != to->array.c.stride || + from->array.c.p != to->array.c.p || + from->array.c.buffer != to->array.c.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.c.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.ColorPointer(to->array.c.size, to->array.c.type, + to->array.c.stride, to->array.c.p); + from->array.c.size = to->array.c.size; + from->array.c.type = to->array.c.type; + from->array.c.stride = to->array.c.stride; + from->array.c.p = to->array.c.p; + from->array.c.buffer = to->array.c.buffer; + } + CLEARDIRTY2(cb->c, bitID); + } + /* index */ + if (CHECKDIRTY(cb->i, bitID)) { + if (from->array.i.type != to->array.i.type || + from->array.i.stride != to->array.i.stride || + from->array.i.p != to->array.i.p || + from->array.i.buffer != to->array.i.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.i.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.IndexPointer(to->array.i.type, + to->array.i.stride, to->array.i.p); + from->array.i.type = to->array.i.type; + from->array.i.stride = to->array.i.stride; + from->array.i.p = to->array.i.p; + from->array.i.buffer = to->array.i.buffer; + } + CLEARDIRTY2(cb->i, bitID); + } + /* texcoords */ + for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) { + if (CHECKDIRTY(cb->t[i], bitID)) { + if (from->array.t[i].size != to->array.t[i].size || + from->array.t[i].type != to->array.t[i].type || + from->array.t[i].stride != to->array.t[i].stride || + from->array.t[i].p != to->array.t[i].p || + from->array.t[i].buffer != to->array.t[i].buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.t[i].buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i); + curClientTextureUnit = i; + diff_api.TexCoordPointer(to->array.t[i].size, to->array.t[i].type, + to->array.t[i].stride, to->array.t[i].p); + from->array.t[i].size = to->array.t[i].size; + from->array.t[i].type = to->array.t[i].type; + from->array.t[i].stride = to->array.t[i].stride; + from->array.t[i].p = to->array.t[i].p; + from->array.t[i].buffer = to->array.t[i].buffer; + } + CLEARDIRTY2(cb->t[i], bitID); + } + } + /* edge flag */ + if (CHECKDIRTY(cb->e, bitID)) { + if (from->array.e.stride != to->array.e.stride || + from->array.e.p != to->array.e.p || + from->array.e.buffer != to->array.e.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.e.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.EdgeFlagPointer(to->array.e.stride, to->array.e.p); + from->array.e.stride = to->array.e.stride; + from->array.e.p = to->array.e.p; + from->array.e.buffer = to->array.e.buffer; + } + CLEARDIRTY2(cb->e, bitID); + } + /* secondary color */ + if (CHECKDIRTY(cb->s, bitID)) { + if (from->array.s.size != to->array.s.size || + from->array.s.type != to->array.s.type || + from->array.s.stride != to->array.s.stride || + from->array.s.p != to->array.s.p || + from->array.s.buffer != to->array.s.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.s.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.SecondaryColorPointerEXT(to->array.s.size, to->array.s.type, + to->array.s.stride, to->array.s.p); + from->array.s.size = to->array.s.size; + from->array.s.type = to->array.s.type; + from->array.s.stride = to->array.s.stride; + from->array.s.p = to->array.s.p; + from->array.s.buffer = to->array.s.buffer; + } + CLEARDIRTY2(cb->s, bitID); + } + /* fog coord */ + if (CHECKDIRTY(cb->f, bitID)) { + if (from->array.f.type != to->array.f.type || + from->array.f.stride != to->array.f.stride || + from->array.f.p != to->array.f.p || + from->array.f.buffer != to->array.f.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.f.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.FogCoordPointerEXT(to->array.f.type, + to->array.f.stride, to->array.f.p); + from->array.f.type = to->array.f.type; + from->array.f.stride = to->array.f.stride; + from->array.f.p = to->array.f.p; + from->array.f.buffer = to->array.f.buffer; + } + CLEARDIRTY2(cb->f, bitID); + } +#if defined(CR_NV_vertex_program) || defined(CR_ARB_vertex_program) + /* vertex attributes */ + for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) { + if (CHECKDIRTY(cb->a[i], bitID)) { + if (from->array.a[i].size != to->array.a[i].size || + from->array.a[i].type != to->array.a[i].type || + from->array.a[i].stride != to->array.a[i].stride || + from->array.a[i].normalized != to->array.a[i].normalized || + from->array.a[i].p != to->array.a[i].p || + from->array.a[i].buffer != to->array.a[i].buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.a[i].buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.VertexAttribPointerARB(i, to->array.a[i].size, + to->array.a[i].type, + to->array.a[i].normalized, + to->array.a[i].stride, + to->array.a[i].p); + from->array.a[i].size = to->array.a[i].size; + from->array.a[i].type = to->array.a[i].type; + from->array.a[i].stride = to->array.a[i].stride; + from->array.a[i].normalized = to->array.a[i].normalized; + from->array.a[i].p = to->array.a[i].p; + from->array.a[i].buffer = to->array.a[i].buffer; + } + CLEARDIRTY2(cb->a[i], bitID); + } + } +#endif + } + + if (idHwArrayBuffer != idHwInitialBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwInitialBuffer); + } + + if (CHECKDIRTY(cb->enableClientState, bitID)) { + /* update vertex array enable/disable flags */ + glAble able[2]; + able[0] = diff_api.DisableClientState; + able[1] = diff_api.EnableClientState; + if (from->array.v.enabled != to->array.v.enabled) { + able[to->array.v.enabled](GL_VERTEX_ARRAY); + from->array.v.enabled = to->array.v.enabled; + } + if (from->array.n.enabled != to->array.n.enabled) { + able[to->array.n.enabled](GL_NORMAL_ARRAY); + from->array.n.enabled = to->array.n.enabled; + } + if (from->array.c.enabled != to->array.c.enabled) { + able[to->array.c.enabled](GL_COLOR_ARRAY); + from->array.c.enabled = to->array.c.enabled; + } + if (from->array.i.enabled != to->array.i.enabled) { + able[to->array.i.enabled](GL_INDEX_ARRAY); + from->array.i.enabled = to->array.i.enabled; + } + for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) { + if (from->array.t[i].enabled != to->array.t[i].enabled) { + diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i); + curClientTextureUnit = i; + able[to->array.t[i].enabled](GL_TEXTURE_COORD_ARRAY); + from->array.t[i].enabled = to->array.t[i].enabled; + } + } + if (from->array.e.enabled != to->array.e.enabled) { + able[to->array.e.enabled](GL_EDGE_FLAG_ARRAY); + from->array.e.enabled = to->array.e.enabled; + } + if (from->array.s.enabled != to->array.s.enabled) { + able[to->array.s.enabled](GL_SECONDARY_COLOR_ARRAY_EXT); + from->array.s.enabled = to->array.s.enabled; + } + if (from->array.f.enabled != to->array.f.enabled) { + able[to->array.f.enabled](GL_FOG_COORDINATE_ARRAY_EXT); + from->array.f.enabled = to->array.f.enabled; + } + for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) { + if (from->array.a[i].enabled != to->array.a[i].enabled) { + if (to->array.a[i].enabled) + diff_api.EnableVertexAttribArrayARB(i); + else + diff_api.DisableVertexAttribArrayARB(i); + from->array.a[i].enabled = to->array.a[i].enabled; + } + } + CLEARDIRTY2(cb->enableClientState, bitID); + } + + if (to->curClientTextureUnit != curClientTextureUnit) + { + diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + to->curClientTextureUnit); + } +} + + +void +crStateClientSwitch(CRClientBits *cb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + const CRClientState *from = &(fromCtx->client); + const CRClientState *to = &(toCtx->client); + GLint curClientTextureUnit = from->curClientTextureUnit; + int i; + GLint idHwArrayBuffer = CR_BUFFER_HWID(toCtx->bufferobject.arrayBuffer); + const GLint idHwInitialBuffer = idHwArrayBuffer; + +#ifdef DEBUG_misha + { + GLint tstHwBuffer = -1; + diff_api.GetIntegerv(GL_ARRAY_BUFFER_BINDING, &tstHwBuffer); + CRASSERT(idHwInitialBuffer == tstHwBuffer); + } +#endif + + if (CHECKDIRTY(cb->clientPointer, bitID)) { + /* one or more vertex pointers is dirty */ + if (CHECKDIRTY(cb->v, bitID)) { + if (from->array.v.size != to->array.v.size || + from->array.v.type != to->array.v.type || + from->array.v.stride != to->array.v.stride || + from->array.v.p != to->array.v.p || + from->array.v.buffer != to->array.v.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.v.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.VertexPointer(to->array.v.size, to->array.v.type, + to->array.v.stride, to->array.v.p); + FILLDIRTY(cb->v); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->v, bitID); + } + /* normal */ + if (CHECKDIRTY(cb->n, bitID)) { + if (from->array.n.type != to->array.n.type || + from->array.n.stride != to->array.n.stride || + from->array.n.p != to->array.n.p || + from->array.n.buffer != to->array.n.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.n.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.NormalPointer(to->array.n.type, + to->array.n.stride, to->array.n.p); + FILLDIRTY(cb->n); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->n, bitID); + } + /* color */ + if (CHECKDIRTY(cb->c, bitID)) { + if (from->array.c.size != to->array.c.size || + from->array.c.type != to->array.c.type || + from->array.c.stride != to->array.c.stride || + from->array.c.p != to->array.c.p || + from->array.c.buffer != to->array.c.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.c.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.ColorPointer(to->array.c.size, to->array.c.type, + to->array.c.stride, to->array.c.p); + FILLDIRTY(cb->c); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->c, bitID); + } + /* index */ + if (CHECKDIRTY(cb->i, bitID)) { + if (from->array.i.type != to->array.i.type || + from->array.i.stride != to->array.i.stride || + from->array.i.p != to->array.i.p || + from->array.i.buffer != to->array.i.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.i.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.IndexPointer(to->array.i.type, + to->array.i.stride, to->array.i.p); + FILLDIRTY(cb->i); + FILLDIRTY(cb->dirty); + FILLDIRTY(cb->clientPointer); + } + CLEARDIRTY2(cb->i, bitID); + } + /* texcoords */ + for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) { + if (CHECKDIRTY(cb->t[i], bitID)) { + if (from->array.t[i].size != to->array.t[i].size || + from->array.t[i].type != to->array.t[i].type || + from->array.t[i].stride != to->array.t[i].stride || + from->array.t[i].p != to->array.t[i].p || + from->array.t[i].buffer != to->array.t[i].buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.t[i].buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i); + curClientTextureUnit = i; + diff_api.TexCoordPointer(to->array.t[i].size, to->array.t[i].type, + to->array.t[i].stride, to->array.t[i].p); + FILLDIRTY(cb->t[i]); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->t[i], bitID); + } + } + /* edge flag */ + if (CHECKDIRTY(cb->e, bitID)) { + if (from->array.e.stride != to->array.e.stride || + from->array.e.p != to->array.e.p || + from->array.e.buffer != to->array.e.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.e.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.EdgeFlagPointer(to->array.e.stride, to->array.e.p); + FILLDIRTY(cb->e); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->e, bitID); + } + /* secondary color */ + if (CHECKDIRTY(cb->s, bitID)) { + if (from->array.s.size != to->array.s.size || + from->array.s.type != to->array.s.type || + from->array.s.stride != to->array.s.stride || + from->array.s.p != to->array.s.p || + from->array.s.buffer != to->array.s.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.s.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.SecondaryColorPointerEXT(to->array.s.size, to->array.s.type, + to->array.s.stride, to->array.s.p); + FILLDIRTY(cb->s); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->s, bitID); + } + /* fog coord */ + if (CHECKDIRTY(cb->f, bitID)) { + if (from->array.f.type != to->array.f.type || + from->array.f.stride != to->array.f.stride || + from->array.f.p != to->array.f.p || + from->array.f.buffer != to->array.f.buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.f.buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.FogCoordPointerEXT(to->array.f.type, + to->array.f.stride, to->array.f.p); + FILLDIRTY(cb->f); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->f, bitID); + } +#if defined(CR_NV_vertex_program) || defined(CR_ARB_vertex_program) + /* vertex attributes */ + for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) { + if (CHECKDIRTY(cb->a[i], bitID)) { + if (from->array.a[i].size != to->array.a[i].size || + from->array.a[i].type != to->array.a[i].type || + from->array.a[i].stride != to->array.a[i].stride || + from->array.a[i].normalized != to->array.a[i].normalized || + from->array.a[i].p != to->array.a[i].p || + from->array.a[i].buffer != to->array.a[i].buffer) { + GLint idHwArrayBufferUsed = CR_BUFFER_HWID(to->array.a[i].buffer); + if (idHwArrayBufferUsed != idHwArrayBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwArrayBufferUsed); + idHwArrayBuffer = idHwArrayBufferUsed; + } + diff_api.VertexAttribPointerARB(i, to->array.a[i].size, + to->array.a[i].type, + to->array.a[i].normalized, + to->array.a[i].stride, + to->array.a[i].p); + FILLDIRTY(cb->a[i]); + FILLDIRTY(cb->clientPointer); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->a[i], bitID); + } + } +#endif + } + + if (idHwArrayBuffer != idHwInitialBuffer) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, idHwInitialBuffer); + } + + if (CHECKDIRTY(cb->enableClientState, bitID)) { + /* update vertex array enable/disable flags */ + glAble able[2]; + able[0] = diff_api.DisableClientState; + able[1] = diff_api.EnableClientState; + if (from->array.v.enabled != to->array.v.enabled) { + able[to->array.v.enabled](GL_VERTEX_ARRAY); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + if (from->array.n.enabled != to->array.n.enabled) { + able[to->array.n.enabled](GL_NORMAL_ARRAY); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + if (from->array.c.enabled != to->array.c.enabled) { + able[to->array.c.enabled](GL_COLOR_ARRAY); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + if (from->array.i.enabled != to->array.i.enabled) { + able[to->array.i.enabled](GL_INDEX_ARRAY); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + for (i = 0; (unsigned int)i < toCtx->limits.maxTextureUnits; i++) { + if (from->array.t[i].enabled != to->array.t[i].enabled) { + diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + i); + curClientTextureUnit = i; + able[to->array.t[i].enabled](GL_TEXTURE_COORD_ARRAY); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + } + if (from->array.e.enabled != to->array.e.enabled) { + able[to->array.e.enabled](GL_EDGE_FLAG_ARRAY); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + if (from->array.s.enabled != to->array.s.enabled) { + able[to->array.s.enabled](GL_SECONDARY_COLOR_ARRAY_EXT); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + if (from->array.f.enabled != to->array.f.enabled) { + able[to->array.f.enabled](GL_FOG_COORDINATE_ARRAY_EXT); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + for (i = 0; (unsigned int)i < toCtx->limits.maxVertexProgramAttribs; i++) { + if (from->array.a[i].enabled != to->array.a[i].enabled) { + if (to->array.a[i].enabled) + diff_api.EnableVertexAttribArrayARB(i); + else + diff_api.DisableVertexAttribArrayARB(i); + FILLDIRTY(cb->enableClientState); + FILLDIRTY(cb->dirty); + } + } + CLEARDIRTY2(cb->enableClientState, bitID); + } + + if (to->curClientTextureUnit != curClientTextureUnit) + { + diff_api.ClientActiveTextureARB(GL_TEXTURE0_ARB + to->curClientTextureUnit); + } + + if (CHECKDIRTY(cb->unpack, bitID)) + { + if (from->unpack.rowLength != to->unpack.rowLength) + { + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, to->unpack.rowLength); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + if (from->unpack.skipRows != to->unpack.skipRows) + { + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, to->unpack.skipRows); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + if (from->unpack.skipPixels != to->unpack.skipPixels) + { + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, to->unpack.skipPixels); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + if (from->unpack.alignment != to->unpack.alignment) + { + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, to->unpack.alignment); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + if (from->unpack.imageHeight != to->unpack.imageHeight) + { + diff_api.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, to->unpack.imageHeight); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + if (from->unpack.skipImages != to->unpack.skipImages) + { + diff_api.PixelStorei(GL_UNPACK_SKIP_IMAGES, to->unpack.skipImages); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + if (from->unpack.swapBytes != to->unpack.swapBytes) + { + diff_api.PixelStorei(GL_UNPACK_SWAP_BYTES, to->unpack.swapBytes); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + if (from->unpack.psLSBFirst != to->unpack.psLSBFirst) + { + diff_api.PixelStorei(GL_UNPACK_LSB_FIRST, to->unpack.psLSBFirst); + FILLDIRTY(cb->unpack); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->unpack, bitID); + } + + if (CHECKDIRTY(cb->pack, bitID)) + { + if (from->pack.rowLength != to->pack.rowLength) + { + diff_api.PixelStorei(GL_PACK_ROW_LENGTH, to->pack.rowLength); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + if (from->pack.skipRows != to->pack.skipRows) + { + diff_api.PixelStorei(GL_PACK_SKIP_ROWS, to->pack.skipRows); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + if (from->pack.skipPixels != to->pack.skipPixels) + { + diff_api.PixelStorei(GL_PACK_SKIP_PIXELS, to->pack.skipPixels); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + if (from->pack.alignment != to->pack.alignment) + { + diff_api.PixelStorei(GL_PACK_ALIGNMENT, to->pack.alignment); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + if (from->pack.imageHeight != to->pack.imageHeight) + { + diff_api.PixelStorei(GL_PACK_IMAGE_HEIGHT, to->pack.imageHeight); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + if (from->pack.skipImages != to->pack.skipImages) + { + diff_api.PixelStorei(GL_PACK_SKIP_IMAGES, to->pack.skipImages); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + if (from->pack.swapBytes != to->pack.swapBytes) + { + diff_api.PixelStorei(GL_PACK_SWAP_BYTES, to->pack.swapBytes); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + if (from->pack.psLSBFirst != to->pack.psLSBFirst) + { + diff_api.PixelStorei(GL_PACK_LSB_FIRST, to->pack.psLSBFirst); + FILLDIRTY(cb->pack); + FILLDIRTY(cb->dirty); + } + CLEARDIRTY2(cb->pack, bitID); + } + + CLEARDIRTY2(cb->dirty, bitID); +} + +CRClientPointer* crStateGetClientPointerByIndex(int index, CRVertexArrays *array) +{ + CRASSERT(array && index>=0 && index= CRSTATECLIENT_MAX_VERTEXARRAYS) + { + return NULL; + } + + if (index < 7) + { + switch (index) + { + case 0: return &array->v; + case 1: return &array->c; + case 2: return &array->f; + case 3: return &array->s; + case 4: return &array->e; + case 5: return &array->i; + case 6: return &array->n; + } + } + else if (index<(7+CR_MAX_TEXTURE_UNITS)) + { + return &array->t[index-7]; + } + else + { + return &array->a[index-7-CR_MAX_TEXTURE_UNITS]; + } + + /*silence the compiler warning*/ + CRASSERT(false); + return NULL; +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_client.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_client.txt new file mode 100644 index 00000000..bdf7a729 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_client.txt @@ -0,0 +1,32 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:unpack:unpack.rowLength:PixelStorei,GL_UNPACK_ROW_LENGTH +#:unpack:unpack.skipImages:PixelStorei,GL_UNPACK_SKIP_IMAGES +:unpack:unpack.skipRows:PixelStorei,GL_UNPACK_SKIP_ROWS +:unpack:unpack.skipPixels:PixelStorei,GL_UNPACK_SKIP_PIXELS +#:unpack:unpack.imageHeight:PixelStorei,GL_UNPACK_IMAGE_HEIGHT +:pack:pack.rowLength:PixelStorei,GL_PACK_ROW_LENGTH +#:pack:pack.skipImages:PixelStorei,GL_PACK_SKIP_IMAGES +:pack:pack.skipRows:PixelStorei,GL_PACK_SKIP_ROWS +:pack:pack.skipPixels:PixelStorei,GL_PACK_SKIP_PIXELS +#:pack:pack.imageHeight:PixelStorei,GL_PACK_IMAGE_HEIGHT +#:clientPointer:v.size,v.type,v.stride,v.p:VertexPointer +#:clientPointer:c.size,c.type,c.stride,c.p:ColorPointer +#:clientPointer:s.size,s.type,s.stride,s.p:SecondaryColorPointerEXT +#:clientPointer:i.type,i.stride,i.p:IndexPointer +#:clientPointer:n.type,n.stride,n.p:NormalPointer +#:clientPointer:t.size,t.type,t.stride,t.p:TexCoordPointer +#:clientPointer:e.stride,e.p:EdgeFlagPointer +#:enableClientState:*glAble able[2]; +#:enableClientState:*able[0] = diff_api.DisableClientState; +#:enableClientState:*able[1] = diff_api.EnableClientState; +#:enableClientState:v.enabled:*able[to->v.enabled](GL_VERTEX_ARRAY); +#:enableClientState:c.enabled:*able[to->c.enabled](GL_COLOR_ARRAY); +#:enableClientState:i.enabled:*able[to->i.enabled](GL_INDEX_ARRAY); +#:enableClientState:n.enabled:*able[to->n.enabled](GL_NORMAL_ARRAY); +#:enableClientState:t.enabled:*able[to->t.enabled](GL_TEXTURE_COORD_ARRAY); +#:enableClientState:e.enabled:*able[to->e.enabled](GL_EDGE_FLAG_ARRAY); +#:enableClientState:s.enabled:*able[to->s.enabled](GL_SECONDARY_COLOR_ARRAY_EXT); +#+:element:*crError( "element in client state DiffContext!" ); /* __glclient_SendUpdates(b, bitID, from, to); */ diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_current.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_current.c new file mode 100644 index 00000000..511f997d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_current.c @@ -0,0 +1,435 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "state.h" +#include "state_internals.h" + +/* + * Note: regardless of GL_NV_vertex_program, we store all per-vertex + * attributes in an array now, instead of specially named attributes + * like color, normal, texcoord, etc. + */ + + +void crStateCurrentInit( CRContext *ctx ) +{ + CRCurrentState *c = &ctx->current; + CRStateBits *sb = GetCurrentBits(); + CRCurrentBits *cb = &(sb->current); + static const GLfloat default_normal[4] = {0.0f, 0.0f, 1.0f, 1.0f}; + static const GLfloat default_color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; + static const GLfloat default_secondaryColor[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + static const GLfloat default_attrib[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + unsigned int i; + + /* + * initialize all vertex attributes to <0,0,0,1> for starters + */ + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) { + COPY_4V(c->vertexAttrib[i], default_attrib); + COPY_4V(c->vertexAttribPre[i], default_attrib); + } + /* now re-do the exceptions */ + COPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], default_color); + COPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1], default_secondaryColor); + COPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], default_normal); + + c->rasterIndex = 1.0f; + c->colorIndex = c->colorIndexPre = 1.0; + c->edgeFlag = c->edgeFlagPre = GL_TRUE; + + /* Set the "pre" values and raster position attributes */ + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) { + COPY_4V(c->vertexAttribPre[i], c->vertexAttrib[i]); + COPY_4V(c->rasterAttrib[i], c->vertexAttrib[i]); + COPY_4V(c->rasterAttribPre[i], c->vertexAttrib[i]); + } + + c->rasterValid = GL_TRUE; + + c->inBeginEnd = GL_FALSE; + c->beginEndNum = 0; + /*c->beginEndMax = cfg->beginend_max;*/ + c->mode = 0x10; /* Undefined Mode */ + c->flushOnEnd = 0; + + c->current = 0; /* picked up by crStateSetCurrentPointers() */ + + /* init dirty bits */ + RESET(cb->dirty, ctx->bitid); + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) { + RESET(cb->vertexAttrib[i], ctx->bitid); + } + RESET(cb->edgeFlag, ctx->bitid); + RESET(cb->colorIndex, ctx->bitid); + RESET(cb->rasterPos, ctx->bitid); +} + +void STATE_APIENTRY crStateColor3f( GLfloat r, GLfloat g, GLfloat b ) +{ + crStateColor4f(r, g, b, 1.0F); +} + +void STATE_APIENTRY crStateColor3fv( const GLfloat *color ) +{ + crStateColor4f( color[0], color[1], color[2], 1.0F ); +} + +void STATE_APIENTRY crStateColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) +{ + CRContext *g = GetCurrentContext(); + CRCurrentState *c = &(g->current); + CRStateBits *sb = GetCurrentBits(); + CRCurrentBits *cb = &(sb->current); + + FLUSH(); + + c->vertexAttrib[VERT_ATTRIB_COLOR0][0] = red; + c->vertexAttrib[VERT_ATTRIB_COLOR0][1] = green; + c->vertexAttrib[VERT_ATTRIB_COLOR0][2] = blue; + c->vertexAttrib[VERT_ATTRIB_COLOR0][3] = alpha; + + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->vertexAttrib[VERT_ATTRIB_COLOR0], g->neg_bitid); +} + +void STATE_APIENTRY crStateColor4fv( const GLfloat *color ) +{ + crStateColor4f( color[0], color[1], color[2], color[3] ); +} + +void crStateSetCurrentPointers( CRContext *ctx, CRCurrentStatePointers *current ) +{ + CRCurrentState *c = &(ctx->current); + c->current = current; +} + +void crStateResetCurrentPointers( CRCurrentStatePointers *current ) +{ + uint32_t attribsUsedMask = current->attribsUsedMask; + + crMemset(current, 0, sizeof (*current)); + + current->attribsUsedMask = attribsUsedMask; +} + +void STATE_APIENTRY crStateBegin( GLenum mode ) +{ + CRContext *g = GetCurrentContext(); + CRCurrentState *c = &(g->current); + + if (mode > GL_POLYGON) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Begin called with invalid mode: %d", mode); + return; + } + + if (c->inBeginEnd) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glBegin called inside Begin/End"); + return; + } + + c->attribsUsedMask = 0; + c->inBeginEnd = GL_TRUE; + c->mode = mode; + c->beginEndNum++; +} + +void STATE_APIENTRY crStateEnd( void ) +{ + CRContext *g = GetCurrentContext(); + CRCurrentState *c = &(g->current); + + if (!c->inBeginEnd) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "glEnd called outside Begin/End" ); + return; + } + + c->inBeginEnd = GL_FALSE; +} + +void crStateCurrentSwitch( CRCurrentBits *c, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + const CRCurrentState *from = &(fromCtx->current); + const CRCurrentState *to = &(toCtx->current); + const GLuint maxTextureUnits = fromCtx->limits.maxTextureUnits; + unsigned int i, j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j=0;jrasterPos, bitID)) { + if (to->rasterValid) { + const GLfloat fromX = from->rasterAttrib[VERT_ATTRIB_POS][0]; + const GLfloat fromY = from->rasterAttrib[VERT_ATTRIB_POS][1]; + const GLfloat fromZ = from->rasterAttrib[VERT_ATTRIB_POS][2]; + const GLfloat toX = to->rasterAttrib[VERT_ATTRIB_POS][0]; + const GLfloat toY = to->rasterAttrib[VERT_ATTRIB_POS][1]; + const GLfloat toZ = to->rasterAttrib[VERT_ATTRIB_POS][2]; + if (toX != fromX || toY != fromY || toZ != fromZ) { + /* Use glWindowPos (which updates raster color) */ + diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]); + FILLDIRTY(c->rasterPos); + FILLDIRTY(c->dirty); + } + } + CLEARDIRTY(c->rasterPos, nbitID); + } + + /* Vertex Current State Switch Code */ + + /* Its important that we don't do a value check here because + ** current may not actually have the correct values, I think... + ** We also need to restore the current state tracking pointer + ** since the packing functions will set it. + */ + + if (CHECKDIRTY(c->colorIndex, bitID)) { + if (to->colorIndex != from->colorIndex) { + diff_api.Indexf(to->colorIndex); + FILLDIRTY(c->colorIndex); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->colorIndex, nbitID); + } + + if (CHECKDIRTY(c->edgeFlag, bitID)) { + if (to->edgeFlag != from->edgeFlag) { + diff_api.EdgeFlag(to->edgeFlag); + FILLDIRTY(c->edgeFlag); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->edgeFlag, nbitID); + } + + /* If using a vertex program, update the generic vertex attributes, + * which may or may not be aliased with conventional attributes. + */ +#if defined(CR_ARB_vertex_program) || defined(CR_NV_vertex_progra) + if (toCtx->program.vpEnabled && + (toCtx->extensions.ARB_vertex_program || + (toCtx->extensions.NV_vertex_program))) { + const unsigned attribsUsedMask = toCtx->current.attribsUsedMask; + for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { /* skip zero */ + if ((attribsUsedMask & (1 << i)) + && CHECKDIRTY(c->vertexAttrib[i], bitID)) { + if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) { + diff_api.VertexAttrib4fvARB(i, &(to->vertexAttrib[i][0])); + FILLDIRTY(c->vertexAttrib[i]); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->vertexAttrib[i], nbitID); + } + } + } + /* Fall-through so that attributes which don't have their bit set in the + * attribsUsedMask get handled via the conventional attribute functions. + */ +#endif + + { + /* use conventional attribute functions */ + + /* NEED TO FIX THIS!!!!!! */ + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) { + if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttrib[VERT_ATTRIB_COLOR0])) { + diff_api.Color4fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR0])); + FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0]); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], nbitID); + } + + /* NEED TO FIX THIS, ALSO?!!!!! */ +#ifdef CR_EXT_secondary_color + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) { + if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttrib[VERT_ATTRIB_COLOR1])) { + diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_COLOR1])); + FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1]); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], nbitID); + } +#endif + + /* NEED TO FIX THIS, ALSO?!!!!! */ +#ifdef CR_EXT_fog_coord + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) { + if (from->vertexAttrib[VERT_ATTRIB_FOG][0] != to->vertexAttrib[VERT_ATTRIB_FOG][0] ) { + diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_FOG][0] )); + FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG]); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], nbitID); + } +#endif + + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) { + if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttrib[VERT_ATTRIB_NORMAL])) { + diff_api.Normal3fv ((GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_NORMAL][0])); + FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL]); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], nbitID); + } + + for (i = 0; i < maxTextureUnits; i++) { + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) { + if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) { + diff_api.MultiTexCoord4fvARB (i+GL_TEXTURE0_ARB, (GLfloat *) &(to->vertexAttrib[VERT_ATTRIB_TEX0+ i][0])); + FILLDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i]); + FILLDIRTY(c->dirty); + } + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], nbitID); + } + } + } + + CLEARDIRTY(c->dirty, nbitID); +} + +void +crStateCurrentDiff( CRCurrentBits *c, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + CRCurrentState *from = &(fromCtx->current); + const CRCurrentState *to = &(toCtx->current); + unsigned int i, j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j=0;jrasterPos, bitID)) { + from->rasterValid = to->rasterValid; + if (to->rasterValid) { + const GLfloat fromX = from->rasterAttrib[VERT_ATTRIB_POS][0]; + const GLfloat fromY = from->rasterAttrib[VERT_ATTRIB_POS][1]; + const GLfloat fromZ = from->rasterAttrib[VERT_ATTRIB_POS][2]; + const GLfloat toX = to->rasterAttrib[VERT_ATTRIB_POS][0]; + const GLfloat toY = to->rasterAttrib[VERT_ATTRIB_POS][1]; + const GLfloat toZ = to->rasterAttrib[VERT_ATTRIB_POS][2]; + if (toX != fromX || toY != fromY || toZ != fromZ) { + /* Use glWindowPos (which updates raster color) */ + diff_api.WindowPos3fvARB(to->rasterAttrib[VERT_ATTRIB_POS]); + from->rasterAttrib[VERT_ATTRIB_POS][0] = toX; + from->rasterAttrib[VERT_ATTRIB_POS][1] = toY; + from->rasterAttrib[VERT_ATTRIB_POS][2] = toZ; + } + } + CLEARDIRTY(c->rasterPos, nbitID); + } + + /* Vertex Current State Sync Code */ + /* Some things to note here: + ** 1) Compare is done against the pre value since the + ** current value includes the geometry info. + ** 2) Update is done with the current value since + ** the server will be getting the geometry block + ** 3) Copy is done outside of the compare to ensure + ** that it happens. + */ + + /* edge flag */ + if (CHECKDIRTY(c->edgeFlag, bitID)) { + if (from->edgeFlag != to->edgeFlagPre) { + diff_api.EdgeFlag (to->edgeFlagPre); + } + from->edgeFlag = to->edgeFlag; + CLEARDIRTY(c->edgeFlag, nbitID); + } + + /* color index */ + if (CHECKDIRTY(c->colorIndex, bitID)) { + if (from->colorIndex != to->colorIndexPre) { + diff_api.Indexf (to->colorIndex); + } + from->colorIndex = to->colorIndex; + CLEARDIRTY(c->colorIndex, nbitID); + } + + + /* If using a vertex program, update the generic vertex attributes, + * which may or may not be aliased with conventional attributes. + */ +#if defined(CR_ARB_vertex_program) || defined(CR_NV_vertex_progra) + if (toCtx->program.vpEnabled && + (toCtx->extensions.ARB_vertex_program || + (toCtx->extensions.NV_vertex_program))) { + const unsigned attribsUsedMask = toCtx->current.attribsUsedMask; + for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { /* skip zero */ + if ((attribsUsedMask & (1 << i)) + && CHECKDIRTY(c->vertexAttrib[i], bitID)) { + if (COMPARE_VECTOR (from->vertexAttrib[i], to->vertexAttribPre[i])) { + diff_api.VertexAttrib4fvARB(i, &(to->vertexAttribPre[i][0])); + } + COPY_4V(from->vertexAttrib[i] , to->vertexAttrib[i]); + CLEARDIRTY(c->vertexAttrib[i], nbitID); + } + } + } + /* Fall-through so that attributes which don't have their bit set in the + * attribsUsedMask get handled via the conventional attribute functions. + */ +#endif + + { + /* use conventional attribute functions */ + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], bitID)) { + if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR0],to->vertexAttribPre[VERT_ATTRIB_COLOR0])) { + diff_api.Color4fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR0])); + } + COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR0] , to->vertexAttrib[VERT_ATTRIB_COLOR0]); + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR0], nbitID); + } + +#ifdef CR_EXT_secondary_color + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], bitID)) { + if (COMPARE_COLOR(from->vertexAttrib[VERT_ATTRIB_COLOR1],to->vertexAttribPre[VERT_ATTRIB_COLOR1])) { + diff_api.SecondaryColor3fvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_COLOR1])); + } + COPY_4V(from->vertexAttrib[VERT_ATTRIB_COLOR1] , to->vertexAttrib[VERT_ATTRIB_COLOR1]); + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_COLOR1], nbitID); + } +#endif + +#ifdef CR_EXT_fog_coord + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], bitID)) { + if (from->vertexAttrib[VERT_ATTRIB_FOG] != to->vertexAttribPre[VERT_ATTRIB_FOG]) { + diff_api.FogCoordfvEXT ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_FOG])); + } + COPY_4V(from->vertexAttrib[VERT_ATTRIB_FOG] , to->vertexAttrib[VERT_ATTRIB_FOG]); + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_FOG], nbitID); + } +#endif + + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], bitID)) { + if (COMPARE_VECTOR (from->vertexAttrib[VERT_ATTRIB_NORMAL], to->vertexAttribPre[VERT_ATTRIB_NORMAL])) { + diff_api.Normal3fv ((GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_NORMAL])); + } + COPY_4V(from->vertexAttrib[VERT_ATTRIB_NORMAL] , to->vertexAttrib[VERT_ATTRIB_NORMAL]); + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_NORMAL], nbitID); + } + + for ( i = 0 ; i < fromCtx->limits.maxTextureUnits ; i++) + { + if (CHECKDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], bitID)) { + if (COMPARE_TEXCOORD (from->vertexAttrib[VERT_ATTRIB_TEX0 + i], to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])) { + diff_api.MultiTexCoord4fvARB (GL_TEXTURE0_ARB + i, (GLfloat *) &(to->vertexAttribPre[VERT_ATTRIB_TEX0 + i])); + } + COPY_4V(from->vertexAttrib[VERT_ATTRIB_TEX0 + i] , to->vertexAttrib[VERT_ATTRIB_TEX0 + i]); + CLEARDIRTY(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], nbitID); + } + } + } + + CLEARDIRTY(c->dirty, nbitID); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py new file mode 100755 index 00000000..49a54aed --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_current.py @@ -0,0 +1,485 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys + +from pack_currenttypes import * +import apiutil + +apiutil.CopyrightC() + +print(''' +#include "state/cr_currentpointers.h" +#include "state.h" + +#include + +#ifdef WINDOWS +#pragma warning( disable : 4127 ) +#endif + +typedef void (*convert_func) (GLfloat *, const unsigned char *); +''') + +import convert + +for k in sorted(current_fns.keys()): + name = k + name = '%s%s' % (k[:1].lower(),k[1:]) + ucname = k.upper() + num_members = len(current_fns[k]['default']) + 1 + + print('#define VPINCH_CONVERT_%s(op,data,dst) \\' % ucname) + print('{\\') + print('\tGLfloat vdata[%d] = {' % num_members, end=' ') + +## Copy dst data into vdata + i = 0; + for defaultvar in current_fns[k]['default']: + print('%d' % defaultvar, end=' ') + if i != num_members: + print(',', end=' ') + i += 1 + print('};\\') + + print('\tswitch (op) { \\') + for type in current_fns[k]['types']: + if type[0:1] == "N": + normalize = 1 + type = type[1:] + else: + normalize = 0 + for size in current_fns[k]['sizes']: + uctype = type.upper() + if ucname == 'EDGEFLAG': + print('\tcase CR_%s_OPCODE: \\' % ucname) + else: + print('\tcase CR_%s%d%s_OPCODE: \\' % (ucname,size,uctype)) + + if (ucname == 'COLOR' or ucname == 'NORMAL' or ucname == 'SECONDARYCOLOR' or normalize) and type != 'f' and type != 'd': + print('\t\t__convert_rescale_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type'])) + else: + print('\t\t__convert_%s%d (vdata, (%s *) (data)); \\' % (type,size,gltypes[type]['type'])) + print('\t\tbreak; \\') + + print('\tdefault: \\') + print('\t\tcrSimpleError ( "Unknown opcode in VPINCH_CONVERT_%s" ); \\' % ucname) + print('\t}\\') + + i = 0 + for member in current_fns[k]['members']: + print('\t(dst).%s = vdata[%d];\\' % (member,i)) + i += 1 + + print('}\n') + +print(''' + +void crStateCurrentRecover( void ) +{ + const unsigned char *v; + convert_func convert=NULL; + CRContext *g = GetCurrentContext(); + CRCurrentState *c = &(g->current); + CRStateBits *sb = GetCurrentBits(); + CRCurrentBits *cb = &(sb->current); + static const GLfloat color_default[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + static const GLfloat secondaryColor_default[4] = {0.0f, 0.0f, 0.0f, 0.0f}; + static const GLfloat texCoord_default[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + static const GLfloat normal_default[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + static const GLfloat index_default = 0.0f; + static const GLboolean edgeFlag_default = GL_TRUE; + static const GLfloat vertexAttrib_default[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + static const GLfloat fogCoord_default = 0.0f; + GLnormal_p *normal = &(c->current->c.normal); + GLcolor_p *color = &(c->current->c.color); + GLsecondarycolor_p *secondaryColor = &(c->current->c.secondaryColor); + GLtexcoord_p *texCoord = &(c->current->c.texCoord); + GLindex_p *index = &(c->current->c.index); + GLedgeflag_p *edgeFlag = &(c->current->c.edgeFlag); + GLvertexattrib_p *vertexAttrib = &(c->current->c.vertexAttrib); + GLfogcoord_p *fogCoord = &(c->current->c.fogCoord); + unsigned int i; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + /* + * If the calling SPU hasn't called crStateSetCurrentPointers() + * we can't recover anything, so abort now. (i.e. we don't have + * a pincher, oh, and just emit the message once). + */ + if (!c->current) { + static int donewarning = 0; + if (!donewarning) + crWarning("No pincher, please call crStateSetCurrentPointers() in your SPU"); + donewarning = 1; + return; /* never get here */ + } + + c->attribsUsedMask = c->current->attribsUsedMask; + + /* silence warnings */ + (void) __convert_b1; + (void) __convert_b2; + (void) __convert_b3; + (void) __convert_b4; + (void) __convert_ui1; + (void) __convert_ui2; + (void) __convert_ui3; + (void) __convert_ui4; + (void) __convert_l1; + (void) __convert_l2; + (void) __convert_l3; + (void) __convert_l4; + (void) __convert_us1; + (void) __convert_us2; + (void) __convert_us3; + (void) __convert_us4; + (void) __convert_ub1; + (void) __convert_ub2; + (void) __convert_ub3; + (void) __convert_ub4; + (void) __convert_rescale_s1; + (void) __convert_rescale_s2; + (void) __convert_rescale_b1; + (void) __convert_rescale_b2; + (void) __convert_rescale_ui1; + (void) __convert_rescale_ui2; + (void) __convert_rescale_i1; + (void) __convert_rescale_i2; + (void) __convert_rescale_us1; + (void) __convert_rescale_us2; + (void) __convert_rescale_ub1; + (void) __convert_rescale_ub2; + (void) __convert_Ni1; + (void) __convert_Ni2; + (void) __convert_Ni3; + (void) __convert_Ni4; + (void) __convert_Nb1; + (void) __convert_Nb2; + (void) __convert_Nb3; + (void) __convert_Nb4; + (void) __convert_Nus1; + (void) __convert_Nus2; + (void) __convert_Nus3; + (void) __convert_Nus4; + (void) __convert_Nui1; + (void) __convert_Nui2; + (void) __convert_Nui3; + (void) __convert_Nui4; + (void) __convert_Ns1; + (void) __convert_Ns2; + (void) __convert_Ns3; + (void) __convert_Ns4; + (void) __convert_Nub1; + (void) __convert_Nub2; + (void) __convert_Nub3; + (void) __convert_Nub4; + + DIRTY(nbitID, g->neg_bitid); + + /* Save pre state */ + for (i = 0; i < CR_MAX_VERTEX_ATTRIBS; i++) { + COPY_4V(c->vertexAttribPre[i] , c->vertexAttrib[i]); + } + c->edgeFlagPre = c->edgeFlag; + c->colorIndexPre = c->colorIndex; + +''') + +for k in sorted(current_fns.keys()): + print('\t/* %s */' % k) + print('\tv = NULL;') + name = '%s%s' % (k[:1].lower(),k[1:]) + + indent = "" + if 'array' in current_fns[k]: + print('\tfor (i = 0; i < %s; i++)' % current_fns[k]['array']) + print('\t{') + indent += "\t" + for type in current_fns[k]['types']: + if type[0:1] == "N": + normalized = 1 + type2 = type[1:] + else: + normalized = 0 + type2 = type + for size in current_fns[k]['sizes']: + ptr = '%s->%s%d' % (name, type, size ) + if 'array' in current_fns[k]: + ptr += "[i]" + print('%s\tif (v < %s)' % (indent, ptr)) + print('%s\t{' % indent) + print('%s\t\tv = %s;' % (indent, ptr)) + if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l': + print('%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)) + else: + print('%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)) + print('%s\t}' % indent) + print('') + print('%s\tif (v != NULL) {' % indent) + if 'array' in current_fns[k]: + if k == 'TexCoord': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)) + else: + print('%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)) + else: + if k == 'Normal': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)) + elif k == 'FogCoord': + print('%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] = %s_default;' % (indent,name)) + elif k == 'Color': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)) + elif k == 'SecondaryColor': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1], %s_default);' % (indent,name)) + elif k == 'TexCoord': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)) + elif k == 'Index': + print('%s\t\tc->colorIndex = %s_default;' % (indent,name)) + elif k == 'EdgeFlag': + print('%s\t\tc->edgeFlag = %s_default;' % (indent,name)) + else: + print('%s\t\tc->%s = %s_default;' % (indent,name,name)) + if k == 'EdgeFlag': + print('%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)) + dirtyVar = 'cb->edgeFlag' + elif k == 'Normal': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]' + elif k == 'TexCoord': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]' + elif k == 'Color': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]' + elif k == 'Index': + print('%s\t\tconvert(&(c->colorIndex), v);' % (indent)) + dirtyVar = 'cb->colorIndex' + elif k == 'SecondaryColor': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]' + elif k == 'FogCoord': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]' + elif k == 'VertexAttrib': + print('%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[i]' + else: + assert 0 # should never get here + + print('%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)) + +# if current_fns[k].has_key( 'array' ): +# print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name) +# else: +# print '%s\t\tDIRTY(cb->%s, nbitID);' % (indent,name) + + + + print('%s\t\tDIRTY(cb->dirty, nbitID);' % indent) + print('%s\t}' % indent) + if 'array' in current_fns[k]: + print('%s\t%s->ptr[i] = v;' % (indent, name )) + else: + print('%s\t%s->ptr = v;' % (indent, name )) + if 'array' in current_fns[k]: + print('\t}') +print('}') + +print(''' + +void crStateCurrentRecoverNew(CRContext *g, CRCurrentStatePointers *current) +{ + const unsigned char *v; + convert_func convert=NULL; + CRCurrentState *c = &(g->current); + CRStateBits *sb = GetCurrentBits(); + CRCurrentBits *cb = &(sb->current); + + static const GLfloat vertexAttrib_default[4] = {0.0f, 0.0f, 0.0f, 1.0f}; + + GLvertexattrib_p *vertexAttrib = &(current->c.vertexAttrib); + + unsigned int i; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + /* Invalid parameters, do nothing */ + if (!g || !current) + return; + + /* silence warnings */ + (void) __convert_b1; + (void) __convert_b2; + (void) __convert_b3; + (void) __convert_b4; + (void) __convert_ui1; + (void) __convert_ui2; + (void) __convert_ui3; + (void) __convert_ui4; + (void) __convert_l1; + (void) __convert_l2; + (void) __convert_l3; + (void) __convert_l4; + (void) __convert_us1; + (void) __convert_us2; + (void) __convert_us3; + (void) __convert_us4; + (void) __convert_ub1; + (void) __convert_ub2; + (void) __convert_ub3; + (void) __convert_ub4; + (void) __convert_rescale_s1; + (void) __convert_rescale_s2; + (void) __convert_rescale_b1; + (void) __convert_rescale_b2; + (void) __convert_rescale_ui1; + (void) __convert_rescale_ui2; + (void) __convert_rescale_i1; + (void) __convert_rescale_i2; + (void) __convert_rescale_us1; + (void) __convert_rescale_us2; + (void) __convert_rescale_ub1; + (void) __convert_rescale_ub2; + (void) __convert_Ni1; + (void) __convert_Ni2; + (void) __convert_Ni3; + (void) __convert_Ni4; + (void) __convert_Nb1; + (void) __convert_Nb2; + (void) __convert_Nb3; + (void) __convert_Nb4; + (void) __convert_Nus1; + (void) __convert_Nus2; + (void) __convert_Nus3; + (void) __convert_Nus4; + (void) __convert_Nui1; + (void) __convert_Nui2; + (void) __convert_Nui3; + (void) __convert_Nui4; + (void) __convert_Ns1; + (void) __convert_Ns2; + (void) __convert_Ns3; + (void) __convert_Ns4; + (void) __convert_Nub1; + (void) __convert_Nub2; + (void) __convert_Nub3; + (void) __convert_Nub4; + + DIRTY(nbitID, g->neg_bitid); + +''') + +for k in sorted(current_fns_new.keys()): + print('\t/* %s */' % k) + print('\tif (current->changed%s)' % k) + print('\t{') + print('\t\tv=NULL;') + name = '%s%s' % (k[:1].lower(),k[1:]) + + indent = "" + if 'array' in current_fns_new[k]: + print('\t\tfor (i = 0; i < %s; i++)' % current_fns_new[k]['array']) + print('\t\t{') + indent += "\t\t" + print('\t\tif (!(current->changed%s & (1 << i))) continue;' % k) + for type in current_fns_new[k]['types']: + if type[0:1] == "N": + normalized = 1 + type2 = type[1:] + else: + normalized = 0 + type2 = type + for size in current_fns_new[k]['sizes']: + ptr = '%s->%s%d' % (name, type, size ) + if 'array' in current_fns_new[k]: + ptr += "[i]" + print('#ifdef DEBUG_misha') + print('%s\tif (%s)' % (indent, ptr)) + print('%s\t{' % (indent)) + print('%s\t\tuint32_t *pTst = (uint32_t*)(%s);' % (indent, ptr)) + print('%s\t\t--pTst;' % (indent)) + print('%s\t\tAssert((*pTst) == i);' % (indent)) + print('%s\t}' % (indent)) + print('#endif') + print('%s\tif (v < %s)' % (indent, ptr)) + print('%s\t{' % indent) + print('%s\t\tv = %s;' % (indent, ptr)) + if (k == 'Color' or k == 'Normal' or k == 'SecondaryColor' or normalized) and type != 'f' and type != 'd' and type != 'l': + print('%s\t\tconvert = (convert_func) __convert_rescale_%s%d;' % (indent,type,size)) + else: + print('%s\t\tconvert = (convert_func) __convert_%s%d;' % (indent,type,size)) + print('%s\t}' % indent) + print('') + print('%s\tif (v != NULL) {' % indent) + if 'array' in current_fns_new[k]: + if k == 'TexCoord': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0 + i], %s_default);' % (indent,name)) + else: + print('%s\t\tCOPY_4V(c->%s[i], %s_default);' % (indent,name,name)) + else: + if k == 'Normal': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_NORMAL], %s_default);' % (indent,name)) + elif k == 'FogCoord': + print('%s\t\tc->vertexAttrib[VERT_ATTRIB_FOG][0] = %s_default;' % (indent,name)) + elif k == 'Color': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR0], %s_default);' % (indent,name)) + elif k == 'SecondaryColor': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_COLOR1], %s_default);' % (indent,name)) + elif k == 'TexCoord': + print('%s\t\tCOPY_4V(c->vertexAttrib[VERT_ATTRIB_TEX0], %s_default);' % (indent,name)) + elif k == 'Index': + print('%s\t\tc->colorIndex = %s_default;' % (indent,name)) + elif k == 'EdgeFlag': + print('%s\t\tc->edgeFlag = %s_default;' % (indent,name)) + else: + print('%s\t\tc->%s = %s_default;' % (indent,name,name)) + if k == 'EdgeFlag': + print('%s\t\t__convert_boolean (&c->edgeFlag, v);' % (indent)) + dirtyVar = 'cb->edgeFlag' + elif k == 'Normal': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_NORMAL][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_NORMAL]' + elif k == 'TexCoord': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_TEX0 + i][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_TEX0 + i]' + elif k == 'Color': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR0][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR0]' + elif k == 'Index': + print('%s\t\tconvert(&(c->colorIndex), v);' % (indent)) + dirtyVar = 'cb->colorIndex' + elif k == 'SecondaryColor': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_COLOR1][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_COLOR1]' + elif k == 'FogCoord': + print('%s\t\tconvert(&(c->vertexAttrib[VERT_ATTRIB_FOG][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[VERT_ATTRIB_FOG]' + elif k == 'VertexAttrib': + print('%s\t\tconvert(&(c->vertexAttrib[i][0]), v);' % (indent)) + dirtyVar = 'cb->vertexAttrib[i]' + else: + assert 0 # should never get here + + print('%s\t\tDIRTY(%s, nbitID);' % (indent, dirtyVar)) + +# if current_fns_new[k].has_key( 'array' ): +# print '%s\t\tDIRTY(cb->%s[i], nbitID);' % (indent,name) +# else: +# print '%s\t\tDIRTY(cb->%s, nbitID);' % (indent,name) + + + + print('%s\t\tDIRTY(cb->dirty, nbitID);' % indent) + print('%s\t}' % indent) + if 'array' in current_fns_new[k]: + print('%s\t%s->ptr[i] = v;' % (indent, name )) + else: + print('%s\t%s->ptr = v;' % (indent, name )) + if 'array' in current_fns_new[k]: + print('\t\t}') + print('\t\tcurrent->changed%s = 0;' % k) + print('\t}') +print('\tcrStateResetCurrentPointers(current);') +print('}') diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_defs.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_defs.py new file mode 100644 index 00000000..1fb1a384 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_defs.py @@ -0,0 +1,64 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + + +import sys + +import apiutil + +apiutil.CopyrightDef() + +print """DESCRIPTION "" +EXPORTS +""" + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") + +for func_name in apiutil.AllSpecials( 'state' ): + print "crState%s" % func_name + +for func_name in apiutil.AllSpecials( 'state_feedback' ): + print "crStateFeedback%s" % func_name + +for func_name in apiutil.AllSpecials( 'state_select' ): + print "crStateSelect%s" % func_name + +print """crStateInit +crStateReadPixels +crStateGetChromiumParametervCR +crStateCreateContext +crStateCreateContextEx +crStateDestroyContext +crStateDiffContext +crStateSwitchContext +crStateMakeCurrent +crStateSetCurrent +crStateFlushFunc +crStateFlushArg +crStateDiffAPI +crStateSetCurrentPointers +crStateResetCurrentPointers +crStateCurrentRecover +crStateTransformUpdateTransform +crStateColorMaterialRecover +crStateError +crStateUpdateColorBits +crStateClientInit +crStateGetCurrent +crStateLimitsInit +crStateMergeExtensions +crStateRasterPosUpdate +crStateTextureCheckDirtyImages +crStateExtensionsInit +crStateSetExtensionString +crStateUseServerArrays +crStateUseServerArrayElements +crStateComputeVersion +crStateTransformXformPointMatrixf +crStateTransformXformPointMatrixd +crStateInitMatrixStack +crStateLoadMatrix +__currentBits +""" diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c new file mode 100644 index 00000000..daf22565 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_diff.c @@ -0,0 +1,644 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_pixeldata.h" +#include +#include + +void crStateDiffContext( CRContext *from, CRContext *to ) +{ + CRbitvalue *bitID = from->bitid; + CRStateBits *sb = GetCurrentBits(); + + /*crDebug( "Diffing two contexts!" ); */ + + if (CHECKDIRTY(sb->transform.dirty, bitID)) + { + crStateTransformDiff( &(sb->transform), bitID, from, to ); + } + if (CHECKDIRTY(sb->pixel.dirty, bitID)) + { + crStatePixelDiff( &(sb->pixel), bitID, from, to ); + } + if (CHECKDIRTY(sb->viewport.dirty, bitID)) + { + crStateViewportDiff( &(sb->viewport), bitID, from, to ); + } + if (CHECKDIRTY(sb->fog.dirty, bitID)) + { + crStateFogDiff( &(sb->fog), bitID, from, to ); + } + if (CHECKDIRTY(sb->texture.dirty, bitID)) + { + crStateTextureDiff( &(sb->texture), bitID, from, to ); + } + if (CHECKDIRTY(sb->lists.dirty, bitID)) + { + crStateListsDiff( &(sb->lists), bitID, from, to ); + } + if (CHECKDIRTY(sb->buffer.dirty, bitID)) + { + crStateBufferDiff( &(sb->buffer), bitID, from, to ); + } +#ifdef CR_ARB_vertex_buffer_object + if (CHECKDIRTY(sb->bufferobject.dirty, bitID)) + { + crStateBufferObjectDiff( &(sb->bufferobject), bitID, from, to ); + } +#endif + if (CHECKDIRTY(sb->client.dirty, bitID)) + { + crStateClientDiff(&(sb->client), bitID, from, to ); + } + if (CHECKDIRTY(sb->hint.dirty, bitID)) + { + crStateHintDiff( &(sb->hint), bitID, from, to ); + } + if (CHECKDIRTY(sb->lighting.dirty, bitID)) + { + crStateLightingDiff( &(sb->lighting), bitID, from, to ); + } + if (CHECKDIRTY(sb->line.dirty, bitID)) + { + crStateLineDiff( &(sb->line), bitID, from, to ); + } + if (CHECKDIRTY(sb->occlusion.dirty, bitID)) + { + crStateOcclusionDiff( &(sb->occlusion), bitID, from, to ); + } + if (CHECKDIRTY(sb->point.dirty, bitID)) + { + crStatePointDiff( &(sb->point), bitID, from, to ); + } + if (CHECKDIRTY(sb->polygon.dirty, bitID)) + { + crStatePolygonDiff( &(sb->polygon), bitID, from, to ); + } + if (CHECKDIRTY(sb->program.dirty, bitID)) + { + crStateProgramDiff( &(sb->program), bitID, from, to ); + } + if (CHECKDIRTY(sb->stencil.dirty, bitID)) + { + crStateStencilDiff( &(sb->stencil), bitID, from, to ); + } + if (CHECKDIRTY(sb->eval.dirty, bitID)) + { + crStateEvaluatorDiff( &(sb->eval), bitID, from, to ); + } +#ifdef CR_ARB_imaging + if (CHECKDIRTY(sb->imaging.dirty, bitID)) + { + crStateImagingDiff( &(sb->imaging), bitID, from, to ); + } +#endif +#if 0 + if (CHECKDIRTY(sb->selection.dirty, bitID)) + { + crStateSelectionDiff( &(sb->selection), bitID, from, to ); + } +#endif +#ifdef CR_NV_register_combiners + if (CHECKDIRTY(sb->regcombiner.dirty, bitID) && to->extensions.NV_register_combiners) + { + crStateRegCombinerDiff( &(sb->regcombiner), bitID, from, to ); + } +#endif +#ifdef CR_ARB_multisample + if (CHECKDIRTY(sb->multisample.dirty, bitID) && + from->extensions.ARB_multisample) + { + crStateMultisampleDiff( &(sb->multisample), bitID, from, to ); + } +#endif + if (CHECKDIRTY(sb->current.dirty, bitID)) + { + crStateCurrentDiff( &(sb->current), bitID, from, to ); + } +} + +void crStateFreeFBImageLegacy(CRContext *to) +{ + if (to->buffer.pFrontImg) + { + crFree(to->buffer.pFrontImg); + to->buffer.pFrontImg = NULL; + } + if (to->buffer.pBackImg) + { + crFree(to->buffer.pBackImg); + to->buffer.pBackImg = NULL; + } + + to->buffer.storedWidth = 0; + to->buffer.storedHeight = 0; +} + +int crStateAcquireFBImage(CRContext *to, CRFBData *data) +{ + /*CRBufferState *pBuf = &to->buffer; - unused */ + CRPixelPackState packing = to->client.pack; + uint32_t i; + + diff_api.PixelStorei(GL_PACK_SKIP_ROWS, 0); + diff_api.PixelStorei(GL_PACK_SKIP_PIXELS, 0); + diff_api.PixelStorei(GL_PACK_ALIGNMENT, 1); + diff_api.PixelStorei(GL_PACK_ROW_LENGTH, 0); + diff_api.PixelStorei(GL_PACK_IMAGE_HEIGHT, 0); + diff_api.PixelStorei(GL_PACK_SKIP_IMAGES, 0); + diff_api.PixelStorei(GL_PACK_SWAP_BYTES, 0); + diff_api.PixelStorei(GL_PACK_LSB_FIRST, 0); + + if (to->bufferobject.packBuffer->hwid>0) + { + diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); + } + + for (i = 0; i < data->cElements; ++i) + { + CRFBDataElement *el = &data->aElements[i]; + + if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL) + { + if (!to->buffer.depthTest) + { + diff_api.Enable(GL_DEPTH_TEST); + } + if (to->pixel.depthScale != 1.0f) + { + diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f); + } + if (to->pixel.depthBias != 0.0f) + { + diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f); + } + } + if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL) + { + if (!to->stencil.stencilTest) + { + diff_api.Enable(GL_STENCIL_TEST); + } + if (to->pixel.mapStencil) + { + diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE); + } + if (to->pixel.indexOffset) + { + diff_api.PixelTransferi (GL_INDEX_OFFSET, 0); + } + if (to->pixel.indexShift) + { + diff_api.PixelTransferi (GL_INDEX_SHIFT, 0); + } + } + + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, el->idFBO); + + if (el->enmBuffer) + diff_api.ReadBuffer(el->enmBuffer); + + diff_api.ReadPixels(el->posX, el->posY, el->width, el->height, el->enmFormat, el->enmType, el->pvData); + crDebug("Acquired %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData); + + if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL) + { + if (to->pixel.depthScale != 1.0f) + { + diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale); + } + if (to->pixel.depthBias != 0.0f) + { + diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias); + } + if (!to->buffer.depthTest) + { + diff_api.Disable(GL_DEPTH_TEST); + } + } + if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL) + { + if (to->pixel.indexOffset) + { + diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset); + } + if (to->pixel.indexShift) + { + diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift); + } + if (to->pixel.mapStencil) + { + diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE); + } + if (!to->stencil.stencilTest) + { + diff_api.Disable(GL_STENCIL_TEST); + } + } + } + + if (to->bufferobject.packBuffer->hwid>0) + { + diff_api.BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, to->bufferobject.packBuffer->hwid); + } + if (to->framebufferobject.readFB) + { + CRASSERT(to->framebufferobject.readFB->hwid); + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, to->framebufferobject.readFB->hwid); + diff_api.ReadBuffer(to->framebufferobject.readFB->readbuffer); + + } + else if (data->idOverrrideFBO) + { + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, data->idOverrrideFBO); + diff_api.ReadBuffer(GL_COLOR_ATTACHMENT0); + } + else + { + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0); + diff_api.ReadBuffer(to->buffer.readBuffer); + } + + diff_api.PixelStorei(GL_PACK_SKIP_ROWS, packing.skipRows); + diff_api.PixelStorei(GL_PACK_SKIP_PIXELS, packing.skipPixels); + diff_api.PixelStorei(GL_PACK_ALIGNMENT, packing.alignment); + diff_api.PixelStorei(GL_PACK_ROW_LENGTH, packing.rowLength); + diff_api.PixelStorei(GL_PACK_IMAGE_HEIGHT, packing.imageHeight); + diff_api.PixelStorei(GL_PACK_SKIP_IMAGES, packing.skipImages); + diff_api.PixelStorei(GL_PACK_SWAP_BYTES, packing.swapBytes); + diff_api.PixelStorei(GL_PACK_LSB_FIRST, packing.psLSBFirst); + return VINF_SUCCESS; +} + +void crStateApplyFBImage(CRContext *to, CRFBData *data) +{ + { + /*CRBufferState *pBuf = &to->buffer; - unused */ + CRPixelPackState unpack = to->client.unpack; + uint32_t i; + + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); + diff_api.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_IMAGES, 0); + diff_api.PixelStorei(GL_UNPACK_SWAP_BYTES, 0); + diff_api.PixelStorei(GL_UNPACK_LSB_FIRST, 0); + + if (to->bufferobject.unpackBuffer->hwid>0) + { + diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0); + } + + diff_api.Disable(GL_ALPHA_TEST); + diff_api.Disable(GL_SCISSOR_TEST); + diff_api.Disable(GL_BLEND); + diff_api.Disable(GL_COLOR_LOGIC_OP); + diff_api.Disable(GL_DEPTH_TEST); + diff_api.Disable(GL_STENCIL_TEST); + + for (i = 0; i < data->cElements; ++i) + { + CRFBDataElement *el = &data->aElements[i]; +#if 0 + char fname[200]; + sprintf(fname, "./img_apply_%p_%d_%d.tga", to, i, el->enmFormat); + crDumpNamedTGA(fname, el->width, el->height, el->pvData); +#endif + + /* Before SSM version SHCROGL_SSM_VERSION_WITH_SEPARATE_DEPTH_STENCIL_BUFFERS + * saved state file contined invalid DEPTH/STENCIL data. In order to prevent + * crashes and improper guest App behavior, this data should be ignored. */ + if ( data->u32Version < SHCROGL_SSM_VERSION_WITH_SEPARATE_DEPTH_STENCIL_BUFFERS + && ( el->enmFormat == GL_DEPTH_COMPONENT + || el->enmFormat == GL_STENCIL_INDEX + || el->enmFormat == GL_DEPTH_STENCIL)) + continue; + + if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL) + { + diff_api.Enable(GL_DEPTH_TEST); + if (to->pixel.depthScale != 1.0f) + { + diff_api.PixelTransferf (GL_DEPTH_SCALE, 1.0f); + } + if (to->pixel.depthBias != 0.0f) + { + diff_api.PixelTransferf (GL_DEPTH_BIAS, 0.0f); + } + } + if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL) + { + diff_api.Enable(GL_STENCIL_TEST); + if (to->pixel.mapStencil) + { + diff_api.PixelTransferi (GL_MAP_STENCIL, GL_FALSE); + } + if (to->pixel.indexOffset) + { + diff_api.PixelTransferi (GL_INDEX_OFFSET, 0); + } + if (to->pixel.indexShift) + { + diff_api.PixelTransferi (GL_INDEX_SHIFT, 0); + } + } + + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, el->idFBO); + + if (el->enmBuffer) + diff_api.DrawBuffer(el->enmBuffer); + + diff_api.WindowPos2iARB(el->posX, el->posY); + diff_api.DrawPixels(el->width, el->height, el->enmFormat, el->enmType, el->pvData); + crDebug("Applied %d;%d;%d;%d;%d;0x%p fb image", el->enmBuffer, el->width, el->height, el->enmFormat, el->enmType, el->pvData); + + if (el->enmFormat == GL_DEPTH_COMPONENT || el->enmFormat == GL_DEPTH_STENCIL) + { + if (to->pixel.depthScale != 1.0f) + { + diff_api.PixelTransferf (GL_DEPTH_SCALE, to->pixel.depthScale); + } + if (to->pixel.depthBias != 0.0f) + { + diff_api.PixelTransferf (GL_DEPTH_BIAS, to->pixel.depthBias); + } + diff_api.Disable(GL_DEPTH_TEST); + } + if (el->enmFormat == GL_STENCIL_INDEX || el->enmFormat == GL_DEPTH_STENCIL) + { + if (to->pixel.indexOffset) + { + diff_api.PixelTransferi (GL_INDEX_OFFSET, to->pixel.indexOffset); + } + if (to->pixel.indexShift) + { + diff_api.PixelTransferi (GL_INDEX_SHIFT, to->pixel.indexShift); + } + if (to->pixel.mapStencil) + { + diff_api.PixelTransferi (GL_MAP_STENCIL, GL_TRUE); + } + diff_api.Disable(GL_STENCIL_TEST); + } + } + + diff_api.WindowPos3fvARB(to->current.rasterAttrib[VERT_ATTRIB_POS]); + if (to->bufferobject.unpackBuffer->hwid>0) + { + diff_api.BindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, to->bufferobject.unpackBuffer->hwid); + } + if (to->framebufferobject.drawFB) + { + CRASSERT(to->framebufferobject.drawFB->hwid); + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, to->framebufferobject.drawFB->hwid); + diff_api.DrawBuffer(to->framebufferobject.drawFB->drawbuffer[0]); + } + else if (data->idOverrrideFBO) + { + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, data->idOverrrideFBO); + diff_api.DrawBuffer(GL_COLOR_ATTACHMENT0); + } + else + { + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); + diff_api.DrawBuffer(to->buffer.drawBuffer); + } + if (to->buffer.alphaTest) + { + diff_api.Enable(GL_ALPHA_TEST); + } + if (to->viewport.scissorTest) + { + diff_api.Enable(GL_SCISSOR_TEST); + } + if (to->buffer.blend) + { + diff_api.Enable(GL_BLEND); + } + if (to->buffer.logicOp) + { + diff_api.Enable(GL_COLOR_LOGIC_OP); + } + if (to->buffer.depthTest) + { + diff_api.Enable(GL_DEPTH_TEST); + } + if (to->stencil.stencilTest) + { + diff_api.Enable(GL_STENCIL_TEST); + } + + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, unpack.skipRows); + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, unpack.skipPixels); + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, unpack.alignment); + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, unpack.rowLength); + diff_api.PixelStorei(GL_UNPACK_IMAGE_HEIGHT, unpack.imageHeight); + diff_api.PixelStorei(GL_UNPACK_SKIP_IMAGES, unpack.skipImages); + diff_api.PixelStorei(GL_UNPACK_SWAP_BYTES, unpack.swapBytes); + diff_api.PixelStorei(GL_UNPACK_LSB_FIRST, unpack.psLSBFirst); + + diff_api.Finish(); + } +} + +void crStateSwitchContext( CRContext *from, CRContext *to ) +{ + CRbitvalue *bitID = to->bitid; + CRStateBits *sb = GetCurrentBits(); + + if (CHECKDIRTY(sb->attrib.dirty, bitID)) + { + crStateAttribSwitch(&(sb->attrib), bitID, from, to ); + } + if (CHECKDIRTY(sb->transform.dirty, bitID)) + { + crStateTransformSwitch( &(sb->transform), bitID, from, to ); + } + if (CHECKDIRTY(sb->pixel.dirty, bitID)) + { + crStatePixelSwitch(&(sb->pixel), bitID, from, to ); + } + if (CHECKDIRTY(sb->viewport.dirty, bitID)) + { + crStateViewportSwitch(&(sb->viewport), bitID, from, to ); + } + if (CHECKDIRTY(sb->fog.dirty, bitID)) + { + crStateFogSwitch(&(sb->fog), bitID, from, to ); + } + if (CHECKDIRTY(sb->texture.dirty, bitID)) + { + crStateTextureSwitch( &(sb->texture), bitID, from, to ); + } + if (CHECKDIRTY(sb->lists.dirty, bitID)) + { + crStateListsSwitch(&(sb->lists), bitID, from, to ); + } + if (CHECKDIRTY(sb->buffer.dirty, bitID)) + { + crStateBufferSwitch( &(sb->buffer), bitID, from, to ); + } +#ifdef CR_ARB_vertex_buffer_object + if (CHECKDIRTY(sb->bufferobject.dirty, bitID)) + { + crStateBufferObjectSwitch( &(sb->bufferobject), bitID, from, to ); + } +#endif + if (CHECKDIRTY(sb->client.dirty, bitID)) + { + crStateClientSwitch( &(sb->client), bitID, from, to ); + } +#if 0 + if (CHECKDIRTY(sb->hint.dirty, bitID)) + { + crStateHintSwitch( &(sb->hint), bitID, from, to ); + } +#endif + if (CHECKDIRTY(sb->lighting.dirty, bitID)) + { + crStateLightingSwitch( &(sb->lighting), bitID, from, to ); + } + if (CHECKDIRTY(sb->occlusion.dirty, bitID)) + { + crStateOcclusionSwitch( &(sb->occlusion), bitID, from, to ); + } + if (CHECKDIRTY(sb->line.dirty, bitID)) + { + crStateLineSwitch( &(sb->line), bitID, from, to ); + } + if (CHECKDIRTY(sb->point.dirty, bitID)) + { + crStatePointSwitch( &(sb->point), bitID, from, to ); + } + if (CHECKDIRTY(sb->polygon.dirty, bitID)) + { + crStatePolygonSwitch( &(sb->polygon), bitID, from, to ); + } + if (CHECKDIRTY(sb->program.dirty, bitID)) + { + crStateProgramSwitch( &(sb->program), bitID, from, to ); + } + if (CHECKDIRTY(sb->stencil.dirty, bitID)) + { + crStateStencilSwitch( &(sb->stencil), bitID, from, to ); + } + if (CHECKDIRTY(sb->eval.dirty, bitID)) + { + crStateEvaluatorSwitch( &(sb->eval), bitID, from, to ); + } +#ifdef CR_ARB_imaging + if (CHECKDIRTY(sb->imaging.dirty, bitID)) + { + crStateImagingSwitch( &(sb->imaging), bitID, from, to ); + } +#endif +#if 0 + if (CHECKDIRTY(sb->selection.dirty, bitID)) + { + crStateSelectionSwitch( &(sb->selection), bitID, from, to ); + } +#endif +#ifdef CR_NV_register_combiners + if (CHECKDIRTY(sb->regcombiner.dirty, bitID) && to->extensions.NV_register_combiners) + { + crStateRegCombinerSwitch( &(sb->regcombiner), bitID, from, to ); + } +#endif +#ifdef CR_ARB_multisample + if (CHECKDIRTY(sb->multisample.dirty, bitID)) + { + crStateMultisampleSwitch( &(sb->multisample), bitID, from, to ); + } +#endif +#ifdef CR_ARB_multisample + if (CHECKDIRTY(sb->multisample.dirty, bitID)) + { + crStateMultisampleSwitch(&(sb->multisample), bitID, from, to ); + } +#endif +#ifdef CR_EXT_framebuffer_object + /*Note, this should go after crStateTextureSwitch*/ + crStateFramebufferObjectSwitch(from, to); +#endif +#ifdef CR_OPENGL_VERSION_2_0 + crStateGLSLSwitch(from, to); +#endif + if (CHECKDIRTY(sb->current.dirty, bitID)) + { + crStateCurrentSwitch( &(sb->current), bitID, from, to ); + } + +#ifdef WINDOWS + if (to->buffer.pFrontImg) + { + CRFBData *pLazyData = (CRFBData *)to->buffer.pFrontImg; + crStateApplyFBImage(to, pLazyData); + crStateFreeFBImageLegacy(to); + } +#endif +} + +void crStateSyncHWErrorState(CRContext *ctx) +{ + GLenum err; + while ((err = diff_api.GetError()) != GL_NO_ERROR) + { + if (ctx->error != GL_NO_ERROR) + ctx->error = err; + } +} + +GLenum crStateCleanHWErrorState(void) +{ + GLenum err; + while ((err = diff_api.GetError()) != GL_NO_ERROR) + { + static int cErrPrints = 0; +#ifndef DEBUG_misha + if (cErrPrints < 5) +#endif + { + ++cErrPrints; + WARN(("cleaning gl error (0x%x), ignoring.. (%d out of 5) ..", err, cErrPrints)); + } + } + + return err; +} + + +void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO) +{ + if (!fromCtx) + return; + + if (g_bVBoxEnableDiffOnMakeCurrent && toCtx && toCtx != fromCtx) + crStateSyncHWErrorState(fromCtx); + +#ifdef CR_EXT_framebuffer_object + crStateFramebufferObjectDisableHW(fromCtx, idDrawFBO, idReadFBO); +#endif +} + +void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO) +{ + if (!toCtx) + return; + +#ifdef CR_EXT_framebuffer_object + crStateFramebufferObjectReenableHW(fromCtx, toCtx, idDrawFBO, idReadFBO); +#endif + + if (g_bVBoxEnableDiffOnMakeCurrent && fromCtx && toCtx != fromCtx) + { + CR_STATE_CLEAN_HW_ERR_WARN("error on make current"); + } +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_enable.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_enable.c new file mode 100644 index 00000000..dca7d98d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_enable.c @@ -0,0 +1,544 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +static void __enableSet (CRContext *g, CRStateBits *sb, CRbitvalue *neg_bitid, + GLenum cap, GLboolean val) +{ + unsigned int i; + i = cap - GL_CLIP_PLANE0; + if (i < g->limits.maxClipPlanes) { + g->transform.clip[i] = val; + DIRTY(sb->transform.enable, neg_bitid); + DIRTY(sb->transform.dirty, neg_bitid); + return; + } + i = cap - GL_LIGHT0; + if (i < g->limits.maxLights) { + g->lighting.light[i].enable = val; + DIRTY(sb->lighting.light[i].dirty, neg_bitid); + DIRTY(sb->lighting.light[i].enable, neg_bitid); + DIRTY(sb->lighting.dirty, neg_bitid); + return; + } + + switch (cap) { + case GL_AUTO_NORMAL: + g->eval.autoNormal = val; + DIRTY(sb->eval.enable, neg_bitid); + DIRTY(sb->eval.dirty, neg_bitid); + break; + case GL_ALPHA_TEST: + g->buffer.alphaTest = val; + DIRTY(sb->buffer.enable, neg_bitid); + DIRTY(sb->buffer.dirty, neg_bitid); + break; + case GL_BLEND: + g->buffer.blend = val; + DIRTY(sb->buffer.enable, neg_bitid); + DIRTY(sb->buffer.dirty, neg_bitid); + break; + case GL_COLOR_MATERIAL : + if (!val) + { + /* We're TURNING OFF color material. In this case, + * we should make sure that the very very latest + * color that was specified gets copied into the + * material parameters, since this might be our + * last chance (see frame 1 of progs/kirchner + * for an example of why). */ + + crStateCurrentRecover( ); + crStateColorMaterialRecover( ); + } + g->lighting.colorMaterial = val; + DIRTY(sb->lighting.enable, neg_bitid); + DIRTY(sb->lighting.dirty, neg_bitid); + break; +#ifdef CR_EXT_secondary_color + case GL_COLOR_SUM_EXT : + if (g->extensions.EXT_secondary_color) { /* XXX does EXT_separate_specular color support this enable, too? */ + g->lighting.colorSumEXT = val; + DIRTY(sb->lighting.enable, neg_bitid); + DIRTY(sb->lighting.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(GL_COLOR_SUM_EXT) - No support for secondary color!"); + return; + } + break; +#endif + case GL_CULL_FACE : + g->polygon.cullFace = val; + DIRTY(sb->polygon.enable, neg_bitid); + DIRTY(sb->polygon.dirty, neg_bitid); + break; + case GL_DEPTH_TEST : + g->buffer.depthTest = val; + DIRTY(sb->buffer.enable, neg_bitid); + DIRTY(sb->buffer.dirty, neg_bitid); + break; + case GL_DITHER : + g->buffer.dither = val; + DIRTY(sb->buffer.enable, neg_bitid); + DIRTY(sb->buffer.dirty, neg_bitid); + break; + case GL_FOG : + g->fog.enable = val; + DIRTY(sb->fog.enable, neg_bitid); + DIRTY(sb->fog.dirty, neg_bitid); + break; + case GL_LIGHTING : + g->lighting.lighting = val; + DIRTY(sb->lighting.enable, neg_bitid); + DIRTY(sb->lighting.dirty, neg_bitid); + break; + case GL_LINE_SMOOTH : + g->line.lineSmooth = val; + DIRTY(sb->line.enable, neg_bitid); + DIRTY(sb->line.dirty, neg_bitid); + break; + case GL_LINE_STIPPLE : + g->line.lineStipple = val; + DIRTY(sb->line.enable, neg_bitid); + DIRTY(sb->line.dirty, neg_bitid); + break; + case GL_COLOR_LOGIC_OP : + g->buffer.logicOp = val; + DIRTY(sb->buffer.enable, neg_bitid); + DIRTY(sb->buffer.dirty, neg_bitid); + break; + case GL_INDEX_LOGIC_OP : + g->buffer.indexLogicOp = val; + DIRTY(sb->buffer.enable, neg_bitid); + DIRTY(sb->buffer.dirty, neg_bitid); + break; + case GL_NORMALIZE : + g->transform.normalize = val; + DIRTY(sb->transform.enable, neg_bitid); + DIRTY(sb->transform.dirty, neg_bitid); + break; + case GL_POINT_SMOOTH : + g->point.pointSmooth = val; + DIRTY(sb->point.enableSmooth, neg_bitid); + DIRTY(sb->point.dirty, neg_bitid); + break; + case GL_POLYGON_OFFSET_FILL: + g->polygon.polygonOffsetFill = val; + DIRTY(sb->polygon.enable, neg_bitid); + DIRTY(sb->polygon.dirty, neg_bitid); + break; + case GL_POLYGON_OFFSET_LINE: + g->polygon.polygonOffsetLine = val; + DIRTY(sb->polygon.enable, neg_bitid); + DIRTY(sb->polygon.dirty, neg_bitid); + break; + case GL_POLYGON_OFFSET_POINT: + g->polygon.polygonOffsetPoint = val; + DIRTY(sb->polygon.enable, neg_bitid); + DIRTY(sb->polygon.dirty, neg_bitid); + break; + case GL_POLYGON_SMOOTH : + g->polygon.polygonSmooth = val; + DIRTY(sb->polygon.enable, neg_bitid); + DIRTY(sb->polygon.dirty, neg_bitid); + break; + case GL_POLYGON_STIPPLE : + g->polygon.polygonStipple = val; + DIRTY(sb->polygon.enable, neg_bitid); + DIRTY(sb->polygon.dirty, neg_bitid); + break; +#ifdef CR_NV_register_combiners + case GL_REGISTER_COMBINERS_NV : + if (g->extensions.NV_register_combiners) { + g->regcombiner.enabledRegCombiners = val; + DIRTY(sb->regcombiner.enable, neg_bitid); + DIRTY(sb->regcombiner.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(GL_REGISTER_COMBINERS_NV) - No support for NV_register_combiners"); + return; + } + break; +#endif +#ifdef CR_NV_register_combiners2 + case GL_PER_STAGE_CONSTANTS_NV : + if (g->extensions.NV_register_combiners2) { + g->regcombiner.enabledPerStageConstants = val; + DIRTY(sb->regcombiner.enable, neg_bitid); + DIRTY(sb->regcombiner.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(GL_PER_STAGE_CONSTANTS_NV) - No support for NV_register_combiners2"); + return; + } + break; +#endif +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + if (g->extensions.NV_texture_rectangle) { + g->texture.unit[g->texture.curTextureUnit].enabledRect = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap); + return; + } + break; +#endif /* CR_NV_texture_rectangle */ +#ifdef CR_OPENGL_VERSION_1_2 + case GL_RESCALE_NORMAL : + g->transform.rescaleNormals = val; + DIRTY(sb->transform.enable, neg_bitid); + DIRTY(sb->transform.dirty, neg_bitid); + break; +#endif + case GL_SCISSOR_TEST : + g->viewport.scissorTest = val; + DIRTY(sb->viewport.enable, neg_bitid); + DIRTY(sb->viewport.dirty, neg_bitid); + break; + case GL_STENCIL_TEST : + g->stencil.stencilTest= val; + DIRTY(sb->stencil.enable, neg_bitid); + DIRTY(sb->stencil.dirty, neg_bitid); + break; + case GL_TEXTURE_1D : + g->texture.unit[g->texture.curTextureUnit].enabled1D = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + break; + case GL_TEXTURE_2D : + g->texture.unit[g->texture.curTextureUnit].enabled2D = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_3D : + g->texture.unit[g->texture.curTextureUnit].enabled3D = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + break; +#endif +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_ARB: + if (g->extensions.ARB_texture_cube_map) { + g->texture.unit[g->texture.curTextureUnit].enabledCubeMap = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap); + return; + } + break; +#endif /* CR_ARB_texture_cube_map */ + case GL_TEXTURE_GEN_Q : + g->texture.unit[g->texture.curTextureUnit].textureGen.q = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + break; + case GL_TEXTURE_GEN_R : + g->texture.unit[g->texture.curTextureUnit].textureGen.r = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + break; + case GL_TEXTURE_GEN_S : + g->texture.unit[g->texture.curTextureUnit].textureGen.s = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + break; + case GL_TEXTURE_GEN_T : + g->texture.unit[g->texture.curTextureUnit].textureGen.t = val; + DIRTY(sb->texture.enable[g->texture.curTextureUnit], neg_bitid); + DIRTY(sb->texture.dirty, neg_bitid); + break; + case GL_MAP1_COLOR_4 : + case GL_MAP1_INDEX : + case GL_MAP1_NORMAL : + case GL_MAP1_TEXTURE_COORD_1 : + case GL_MAP1_TEXTURE_COORD_2 : + case GL_MAP1_TEXTURE_COORD_3 : + case GL_MAP1_TEXTURE_COORD_4 : + case GL_MAP1_VERTEX_3 : + case GL_MAP1_VERTEX_4 : + if (g->texture.curTextureUnit != 0) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "Map stuff was enabled while the current texture unit was not GL_TEXTURE0_ARB!" ); + return; + } + g->eval.enable1D[cap - GL_MAP1_COLOR_4] = val; + DIRTY(sb->eval.enable1D[cap - GL_MAP1_COLOR_4], neg_bitid); + DIRTY(sb->eval.dirty, neg_bitid); + break; + case GL_MAP2_COLOR_4 : + case GL_MAP2_INDEX : + case GL_MAP2_NORMAL : + case GL_MAP2_TEXTURE_COORD_1 : + case GL_MAP2_TEXTURE_COORD_2 : + case GL_MAP2_TEXTURE_COORD_3 : + case GL_MAP2_TEXTURE_COORD_4 : + case GL_MAP2_VERTEX_3 : + case GL_MAP2_VERTEX_4 : +#if 0 + if (g->texture.curTextureUnit != 0) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "Map stuff was enabled while the current texture unit was not GL_TEXTURE0_ARB!" ); + return; + } +#endif + g->eval.enable2D[cap - GL_MAP2_COLOR_4] = val; + DIRTY(sb->eval.enable2D[cap - GL_MAP2_COLOR_4], neg_bitid); + DIRTY(sb->eval.dirty, neg_bitid); + break; +#ifdef CR_ARB_multisample + case GL_MULTISAMPLE_ARB: + g->multisample.enabled = val; + DIRTY(sb->multisample.enable, neg_bitid); + DIRTY(sb->multisample.dirty, neg_bitid); + break; + case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB: + g->multisample.sampleAlphaToCoverage = val; + DIRTY(sb->multisample.sampleAlphaToCoverage, neg_bitid); + DIRTY(sb->multisample.dirty, neg_bitid); + break; + case GL_SAMPLE_ALPHA_TO_ONE_ARB: + g->multisample.sampleAlphaToOne = val; + DIRTY(sb->multisample.sampleAlphaToOne, neg_bitid); + DIRTY(sb->multisample.dirty, neg_bitid); + break; + case GL_SAMPLE_COVERAGE_ARB: + g->multisample.sampleCoverage = val; + DIRTY(sb->multisample.sampleCoverage, neg_bitid); + DIRTY(sb->multisample.dirty, neg_bitid); + break; +#endif +#ifdef CR_NV_vertex_program + case GL_VERTEX_PROGRAM_NV: + if (g->extensions.NV_vertex_program) { + g->program.vpEnabled = val; + DIRTY(sb->program.vpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else if (g->extensions.ARB_vertex_program) { + g->program.vpEnabled = val; + DIRTY(sb->program.vpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap); + return; + } + break; + case GL_VERTEX_PROGRAM_POINT_SIZE_NV: + if (g->extensions.NV_vertex_program) { + g->program.vpPointSize = val; + DIRTY(sb->program.vpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else if (g->extensions.ARB_vertex_program) { + g->program.vpPointSize = val; + DIRTY(sb->program.vpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap); + return; + } + break; + case GL_VERTEX_PROGRAM_TWO_SIDE_NV: + if (g->extensions.NV_vertex_program) { + g->program.vpTwoSide = val; + DIRTY(sb->program.vpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else if (g->extensions.ARB_vertex_program) { + g->program.vpTwoSide = val; + DIRTY(sb->program.vpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap); + return; + } + break; + + case GL_MAP1_VERTEX_ATTRIB0_4_NV: + case GL_MAP1_VERTEX_ATTRIB1_4_NV: + case GL_MAP1_VERTEX_ATTRIB2_4_NV: + case GL_MAP1_VERTEX_ATTRIB3_4_NV: + case GL_MAP1_VERTEX_ATTRIB4_4_NV: + case GL_MAP1_VERTEX_ATTRIB5_4_NV: + case GL_MAP1_VERTEX_ATTRIB6_4_NV: + case GL_MAP1_VERTEX_ATTRIB7_4_NV: + case GL_MAP1_VERTEX_ATTRIB8_4_NV: + case GL_MAP1_VERTEX_ATTRIB9_4_NV: + case GL_MAP1_VERTEX_ATTRIB10_4_NV: + case GL_MAP1_VERTEX_ATTRIB11_4_NV: + case GL_MAP1_VERTEX_ATTRIB12_4_NV: + case GL_MAP1_VERTEX_ATTRIB13_4_NV: + case GL_MAP1_VERTEX_ATTRIB14_4_NV: + case GL_MAP1_VERTEX_ATTRIB15_4_NV: + { + const GLint idx = cap - GL_MAP1_VERTEX_ATTRIB0_4_NV; + g->eval.enableAttrib1D[idx] = val; + DIRTY(sb->program.map1AttribArrayEnable[idx], neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + break; + case GL_MAP2_VERTEX_ATTRIB0_4_NV: + case GL_MAP2_VERTEX_ATTRIB1_4_NV: + case GL_MAP2_VERTEX_ATTRIB2_4_NV: + case GL_MAP2_VERTEX_ATTRIB3_4_NV: + case GL_MAP2_VERTEX_ATTRIB4_4_NV: + case GL_MAP2_VERTEX_ATTRIB5_4_NV: + case GL_MAP2_VERTEX_ATTRIB6_4_NV: + case GL_MAP2_VERTEX_ATTRIB7_4_NV: + case GL_MAP2_VERTEX_ATTRIB8_4_NV: + case GL_MAP2_VERTEX_ATTRIB9_4_NV: + case GL_MAP2_VERTEX_ATTRIB10_4_NV: + case GL_MAP2_VERTEX_ATTRIB11_4_NV: + case GL_MAP2_VERTEX_ATTRIB12_4_NV: + case GL_MAP2_VERTEX_ATTRIB13_4_NV: + case GL_MAP2_VERTEX_ATTRIB14_4_NV: + case GL_MAP2_VERTEX_ATTRIB15_4_NV: + { + const GLint idx = cap - GL_MAP2_VERTEX_ATTRIB0_4_NV; + g->eval.enableAttrib2D[idx] = val; + DIRTY(sb->program.map2AttribArrayEnable[idx], neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + break; +#endif +#ifdef CR_NV_fragment_program + case GL_FRAGMENT_PROGRAM_NV: + if (g->extensions.NV_fragment_program) { + g->program.fpEnabled = val; + DIRTY(sb->program.fpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap); + return; + } + break; +#endif +#ifdef CR_ARB_fragment_program + case GL_FRAGMENT_PROGRAM_ARB: + if (g->extensions.ARB_fragment_program) { + g->program.fpEnabledARB = val; + DIRTY(sb->program.fpEnable, neg_bitid); + DIRTY(sb->program.dirty, neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable(0x%x)", cap); + return; + } + break; +#endif +#ifdef CR_IBM_rasterpos_clip + case GL_RASTER_POSITION_UNCLIPPED_IBM: + g->transform.rasterPositionUnclipped = val; + DIRTY(sb->transform.enable, neg_bitid); + DIRTY(sb->transform.dirty, neg_bitid); + break; +#endif + +#ifdef CR_ARB_point_sprite + case GL_POINT_SPRITE_ARB: + g->point.pointSprite = val; + DIRTY(sb->point.enableSprite, neg_bitid); + DIRTY(sb->point.dirty, neg_bitid); + break; +#endif + + /* Client-side enables */ + case GL_VERTEX_ARRAY: + case GL_COLOR_ARRAY: + case GL_NORMAL_ARRAY: + case GL_INDEX_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_EDGE_FLAG_ARRAY: +#ifdef CR_EXT_fog_coord + case GL_FOG_COORDINATE_ARRAY_POINTER_EXT: +#endif +#ifdef CR_EXT_secondary_color + case GL_SECONDARY_COLOR_ARRAY_EXT: +#endif +#ifdef CR_NV_vertex_program + case GL_VERTEX_ATTRIB_ARRAY0_NV: + case GL_VERTEX_ATTRIB_ARRAY1_NV: + case GL_VERTEX_ATTRIB_ARRAY2_NV: + case GL_VERTEX_ATTRIB_ARRAY3_NV: + case GL_VERTEX_ATTRIB_ARRAY4_NV: + case GL_VERTEX_ATTRIB_ARRAY5_NV: + case GL_VERTEX_ATTRIB_ARRAY6_NV: + case GL_VERTEX_ATTRIB_ARRAY7_NV: + case GL_VERTEX_ATTRIB_ARRAY8_NV: + case GL_VERTEX_ATTRIB_ARRAY9_NV: + case GL_VERTEX_ATTRIB_ARRAY10_NV: + case GL_VERTEX_ATTRIB_ARRAY11_NV: + case GL_VERTEX_ATTRIB_ARRAY12_NV: + case GL_VERTEX_ATTRIB_ARRAY13_NV: + case GL_VERTEX_ATTRIB_ARRAY14_NV: + case GL_VERTEX_ATTRIB_ARRAY15_NV: +#endif + if (val) + crStateEnableClientState(cap); + else + crStateDisableClientState(cap); + break; +#ifdef CR_EXT_stencil_two_side + case GL_STENCIL_TEST_TWO_SIDE_EXT: + g->stencil.stencilTwoSideEXT= val; + DIRTY(sb->stencil.enableTwoSideEXT, neg_bitid); + DIRTY(sb->stencil.dirty, neg_bitid); + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEnable/glDisable called with bogus cap: 0x%x", cap); + return; + } +} + + +void STATE_APIENTRY crStateEnable (GLenum cap) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEnable called in begin/end"); + return; + } + + FLUSH(); + + __enableSet(g, sb, g->neg_bitid, cap, GL_TRUE); +} + + +void STATE_APIENTRY crStateDisable (GLenum cap) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDisable called in begin/end"); + return; + } + + FLUSH(); + + __enableSet(g, sb, g->neg_bitid, cap, GL_FALSE); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c new file mode 100644 index 00000000..07a7b494 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_error.c @@ -0,0 +1,86 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state/cr_stateerror.h" +#include "state/cr_statetypes.h" +#include "state.h" +#include "cr_error.h" +#include "cr_environment.h" +#include +#include + +void crStateError( int line, const char *file, GLenum error, const char *format, ... ) +{ + CRContext *g = GetCurrentContext(); + char errstr[8096]; + va_list args; + + CRASSERT(error != GL_NO_ERROR); + + if (g->error == GL_NO_ERROR) + g->error = error; + +#ifndef DEBUG_misha + if (crGetenv("CR_DEBUG")) +#endif + { + char *glerr; + va_start( args, format ); + vsprintf( errstr, format, args ); + va_end( args ); + + switch (error) { + case GL_NO_ERROR: + glerr = "GL_NO_ERROR"; + break; + case GL_INVALID_VALUE: + glerr = "GL_INVALID_VALUE"; + break; + case GL_INVALID_ENUM: + glerr = "GL_INVALID_ENUM"; + break; + case GL_INVALID_OPERATION: + glerr = "GL_INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + glerr = "GL_STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + glerr = "GL_STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + glerr = "GL_OUT_OF_MEMORY"; + break; + case GL_TABLE_TOO_LARGE: + glerr = "GL_TABLE_TOO_LARGE"; + break; + default: + glerr = "unknown"; + break; + } + + crWarning( "OpenGL error in %s, line %d: %s: %s\n", + file, line, glerr, errstr ); + } +} + + +GLenum STATE_APIENTRY crStateGetError(void) +{ + CRContext *g = GetCurrentContext(); + GLenum e = g->error; + + if (g->current.inBeginEnd) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, + "glStateGetError() called between glBegin/glEnd" ); + return 0; + } + + g->error = GL_NO_ERROR; + + return e; +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_evaluators.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_evaluators.c new file mode 100644 index 00000000..0219994d --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_evaluators.c @@ -0,0 +1,1084 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +/* + * The majority of this file is pulled from Mesa 4.0.x with the + * permission of Brian Paul + */ + +#include +#include "cr_mem.h" +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +/* free the 1-D evaluator map */ +static void +free_1d_map(CRContext *ctx, GLenum map) +{ + CREvaluatorState *e = &ctx->eval; + const GLint k = map - GL_MAP1_COLOR_4; + + crFree( e->eval1D[k].coeff ); +} + +/* free the 2-D evaluator map */ +static void +free_2d_map(CRContext *ctx, GLenum map) +{ + CREvaluatorState *e = &ctx->eval; + const GLint k = map - GL_MAP2_COLOR_4; + + crFree( e->eval2D[k].coeff ); +} + +/* Initialize a 1-D evaluator map */ +static void +init_1d_map(CRContext *ctx, GLenum map, int n, const float *initial) +{ + CREvaluatorState *e = &ctx->eval; + CRStateBits *sb = GetCurrentBits(); + CREvaluatorBits *eb = &(sb->eval); + GLint i; + const GLint k = map - GL_MAP1_COLOR_4; + CRASSERT(k >= 0); + CRASSERT(k < GLEVAL_TOT); + e->eval1D[k].u1 = 0.0; + e->eval1D[k].u2 = 1.0; + e->eval1D[k].du = 0.0; + e->eval1D[k].order = 1; + e->eval1D[k].coeff = (GLfloat *) crAlloc(n * sizeof(GLfloat)); + for (i = 0; i < n; i++) + e->eval1D[k].coeff[i] = initial[i]; + RESET(eb->eval1D[i], ctx->bitid); +} + + +/* Initialize a 2-D evaluator map */ +static void +init_2d_map(CRContext *ctx, GLenum map, int n, const float *initial) +{ + CREvaluatorState *e = &ctx->eval; + CRStateBits *sb = GetCurrentBits(); + CREvaluatorBits *eb = &(sb->eval); + GLint i; + const GLint k = map - GL_MAP2_COLOR_4; + CRASSERT(k >= 0); + CRASSERT(k < GLEVAL_TOT); + e->eval2D[k].u1 = 0.0; + e->eval2D[k].u2 = 1.0; + e->eval2D[k].du = 0.0; + e->eval2D[k].v1 = 0.0; + e->eval2D[k].v2 = 1.0; + e->eval2D[k].dv = 0.0; + e->eval2D[k].uorder = 1; + e->eval2D[k].vorder = 1; + e->eval2D[k].coeff = (GLfloat *) crAlloc(n * sizeof(GLfloat)); + for (i = 0; i < n; i++) + e->eval2D[k].coeff[i] = initial[i]; + RESET(eb->eval2D[i], ctx->bitid); +} + +void +crStateEvaluatorDestroy(CRContext *ctx) +{ + free_1d_map(ctx, GL_MAP1_VERTEX_3); + free_1d_map(ctx, GL_MAP1_VERTEX_4); + free_1d_map(ctx, GL_MAP1_INDEX); + free_1d_map(ctx, GL_MAP1_COLOR_4); + free_1d_map(ctx, GL_MAP1_NORMAL); + free_1d_map(ctx, GL_MAP1_TEXTURE_COORD_1); + free_1d_map(ctx, GL_MAP1_TEXTURE_COORD_2); + free_1d_map(ctx, GL_MAP1_TEXTURE_COORD_3); + free_1d_map(ctx, GL_MAP1_TEXTURE_COORD_4); + + free_2d_map(ctx, GL_MAP2_VERTEX_3); + free_2d_map(ctx, GL_MAP2_VERTEX_4); + free_2d_map(ctx, GL_MAP2_INDEX); + free_2d_map(ctx, GL_MAP2_COLOR_4); + free_2d_map(ctx, GL_MAP2_NORMAL); + free_2d_map(ctx, GL_MAP2_TEXTURE_COORD_1); + free_2d_map(ctx, GL_MAP2_TEXTURE_COORD_2); + free_2d_map(ctx, GL_MAP2_TEXTURE_COORD_3); + free_2d_map(ctx, GL_MAP2_TEXTURE_COORD_4); +} + +void +crStateEvaluatorInit(CRContext *ctx) +{ + CREvaluatorState *e = &ctx->eval; + CRStateBits *sb = GetCurrentBits(); + CREvaluatorBits *eb = &(sb->eval); + static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 }; + static GLfloat normal[3] = { 0.0, 0.0, 1.0 }; + static GLfloat index[1] = { 1.0 }; + static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 }; + static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 }; + + e->autoNormal = GL_FALSE; + RESET(eb->enable, ctx->bitid); + + init_1d_map(ctx, GL_MAP1_VERTEX_3, 3, vertex); + init_1d_map(ctx, GL_MAP1_VERTEX_4, 4, vertex); + init_1d_map(ctx, GL_MAP1_INDEX, 1, index); + init_1d_map(ctx, GL_MAP1_COLOR_4, 4, color); + init_1d_map(ctx, GL_MAP1_NORMAL, 3, normal); + init_1d_map(ctx, GL_MAP1_TEXTURE_COORD_1, 1, texcoord); + init_1d_map(ctx, GL_MAP1_TEXTURE_COORD_2, 2, texcoord); + init_1d_map(ctx, GL_MAP1_TEXTURE_COORD_3, 3, texcoord); + init_1d_map(ctx, GL_MAP1_TEXTURE_COORD_4, 4, texcoord); + + init_2d_map(ctx, GL_MAP2_VERTEX_3, 3, vertex); + init_2d_map(ctx, GL_MAP2_VERTEX_4, 4, vertex); + init_2d_map(ctx, GL_MAP2_INDEX, 1, index); + init_2d_map(ctx, GL_MAP2_COLOR_4, 4, color); + init_2d_map(ctx, GL_MAP2_NORMAL, 3, normal); + init_2d_map(ctx, GL_MAP2_TEXTURE_COORD_1, 1, texcoord); + init_2d_map(ctx, GL_MAP2_TEXTURE_COORD_2, 2, texcoord); + init_2d_map(ctx, GL_MAP2_TEXTURE_COORD_3, 3, texcoord); + init_2d_map(ctx, GL_MAP2_TEXTURE_COORD_4, 4, texcoord); + + e->un1D = 1; + e->u11D = 0.0; + e->u21D = 1.0; + RESET(eb->grid1D, ctx->bitid); + + e->un2D = 1; + e->vn2D = 1; + e->u12D = 0.0; + e->u22D = 1.0; + e->v12D = 0.0; + e->v22D = 1.0; + RESET(eb->grid1D, ctx->bitid); + + RESET(eb->dirty, ctx->bitid); +} + +const int gleval_sizes[] = { 4, 1, 3, 1, 2, 3, 4, 3, 4 }; + +/**********************************************************************/ +/*** Copy and deallocate control points ***/ +/**********************************************************************/ + + +/* + * Copy 1-parametric evaluator control points from user-specified + * memory space to a buffer of contiguous control points. + * Input: see glMap1f for details + * Return: pointer to buffer of contiguous control points or NULL if out + * of memory. + */ +static GLfloat * +_copy_map_points1f(GLint size, GLint ustride, GLint uorder, + const GLfloat * points) +{ + GLfloat *buffer, *p; + GLint i, k; + + if (!points || size == 0) { + return NULL; + } + + buffer = (GLfloat *) crAlloc(uorder * size * sizeof(GLfloat)); + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += ustride) + for (k = 0; k < size; k++) + *p++ = points[k]; + + return buffer; +} + + + +/* + * Same as above but convert doubles to floats. + */ +static GLfloat * +_copy_map_points1d(GLint size, GLint ustride, GLint uorder, + const GLdouble * points) +{ + GLfloat *buffer, *p; + GLint i, k; + + if (!points || size == 0) { + return NULL; + } + + buffer = (GLfloat *) crAlloc(uorder * size * sizeof(GLfloat)); + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += ustride) + for (k = 0; k < size; k++) + *p++ = (GLfloat) points[k]; + + return buffer; +} + + + +/* + * Copy 2-parametric evaluator control points from user-specified + * memory space to a buffer of contiguous control points. + * Additional memory is allocated to be used by the Horner and + * de Casteljau evaluation schemes. + * + * Input: see glMap2f for details + * Return: pointer to buffer of contiguous control points or NULL if out + * of memory. + */ +static GLfloat * +_copy_map_points2f(GLint size, + GLint ustride, GLint uorder, + GLint vstride, GLint vorder, const GLfloat * points) +{ + GLfloat *buffer, *p; + GLint i, j, k, dsize, hsize; + GLint uinc; + + if (!points || size == 0) { + return NULL; + } + + /* max(uorder, vorder) additional points are used in */ + /* Horner evaluation and uorder*vorder additional */ + /* values are needed for de Casteljau */ + dsize = (uorder == 2 && vorder == 2) ? 0 : uorder * vorder; + hsize = (uorder > vorder ? uorder : vorder) * size; + + if (hsize > dsize) + buffer = + (GLfloat *) crAlloc((uorder * vorder * size + hsize) * sizeof(GLfloat)); + else + buffer = + (GLfloat *) crAlloc((uorder * vorder * size + dsize) * sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder * vstride; + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += uinc) + for (j = 0; j < vorder; j++, points += vstride) + for (k = 0; k < size; k++) + *p++ = points[k]; + + return buffer; +} + + + +/* + * Same as above but convert doubles to floats. + */ +static GLfloat * +_copy_map_points2d(GLint size, + GLint ustride, GLint uorder, + GLint vstride, GLint vorder, const GLdouble * points) +{ + GLfloat *buffer, *p; + GLint i, j, k, hsize, dsize; + GLint uinc; + + if (!points || size == 0) { + return NULL; + } + + /* max(uorder, vorder) additional points are used in */ + /* Horner evaluation and uorder*vorder additional */ + /* values are needed for de Casteljau */ + dsize = (uorder == 2 && vorder == 2) ? 0 : uorder * vorder; + hsize = (uorder > vorder ? uorder : vorder) * size; + + if (hsize > dsize) + buffer = + (GLfloat *) crAlloc((uorder * vorder * size + hsize) * sizeof(GLfloat)); + else + buffer = + (GLfloat *) crAlloc((uorder * vorder * size + dsize) * sizeof(GLfloat)); + + /* compute the increment value for the u-loop */ + uinc = ustride - vorder * vstride; + + if (buffer) + for (i = 0, p = buffer; i < uorder; i++, points += uinc) + for (j = 0; j < vorder; j++, points += vstride) + for (k = 0; k < size; k++) + *p++ = (GLfloat) points[k]; + + return buffer; +} + + + + +/**********************************************************************/ +/*** API entry points ***/ +/**********************************************************************/ + + +/* + * This does the work of glMap1[fd]. + */ +static void +map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, + GLint uorder, const GLvoid * points, GLenum type) +{ + CRContext *g = GetCurrentContext(); + CREvaluatorState *e = &(g->eval); + CRStateBits *sb = GetCurrentBits(); + CREvaluatorBits *eb = &(sb->eval); + CRTextureState *t = &(g->texture); + GLint i; + GLint k; + GLfloat *pnts; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Map1d called in begin/end"); + return; + } + + FLUSH(); + + CRASSERT(type == GL_FLOAT || type == GL_DOUBLE); + + if (u1 == u2) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap1d(u1==u2)"); + return; + } + if (uorder < 1 || uorder > MAX_EVAL_ORDER) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap1d(bad uorder)"); + return; + } + if (!points) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glMap1d(null points)"); + return; + } + + i = target - GL_MAP1_COLOR_4; + + k = gleval_sizes[i]; + + if (k == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMap1d(k=0)"); + return; + } + + if (ustride < k) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap1d(bad ustride"); + return; + } + + if (t->curTextureUnit != 0) { + /* See OpenGL 1.2.1 spec, section F.2.13 */ + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glMap1d(current texture unit must be zero)"); + return; + } + + switch (target) { + case GL_MAP1_VERTEX_3: + case GL_MAP1_VERTEX_4: + case GL_MAP1_INDEX: + case GL_MAP1_COLOR_4: + case GL_MAP1_NORMAL: + case GL_MAP1_TEXTURE_COORD_1: + case GL_MAP1_TEXTURE_COORD_2: + case GL_MAP1_TEXTURE_COORD_3: + case GL_MAP1_TEXTURE_COORD_4: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMap1d(bad target)"); + return; + } + + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = _copy_map_points1f(k, ustride, uorder, (GLfloat *) points); + else + pnts = _copy_map_points1d(k, ustride, uorder, (GLdouble *) points); + + e->eval1D[i].order = uorder; + e->eval1D[i].u1 = u1; + e->eval1D[i].u2 = u2; + e->eval1D[i].du = 1.0f / (u2 - u1); + if (e->eval1D[i].coeff) + crFree(e->eval1D[i].coeff); + e->eval1D[i].coeff = pnts; + + DIRTY(eb->dirty, g->neg_bitid); + DIRTY(eb->eval1D[i], g->neg_bitid); +} + + + +void STATE_APIENTRY +crStateMap1f(GLenum target, GLfloat u1, GLfloat u2, + GLint stride, GLint order, const GLfloat * points) +{ + map1(target, u1, u2, stride, order, points, GL_FLOAT); +} + +void STATE_APIENTRY +crStateMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, + GLint order, const GLdouble * points) +{ + map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE); +} + +static void +map2(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLvoid * points, GLenum type) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CREvaluatorState *e = &(g->eval); + CREvaluatorBits *eb = &(sb->eval); +#if 0 + CRTextureState *t = &(g->texture); +#endif + GLint i; + GLint k; + GLfloat *pnts; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glMap2d()"); + return; + } + + FLUSH(); + + if (u1 == u2) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap2d()"); + return; + } + + if (v1 == v2) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap2d()"); + return; + } + + if (uorder < 1 || uorder > MAX_EVAL_ORDER) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap2d()"); + return; + } + + if (vorder < 1 || vorder > MAX_EVAL_ORDER) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap2d()"); + return; + } + + if (g->extensions.NV_vertex_program) { +/* XXX FIXME */ + i = target - GL_MAP2_COLOR_4; + } else { + i = target - GL_MAP2_COLOR_4; + } + + k = gleval_sizes[i]; + + if (k == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMap2d()"); + return; + } + + if (ustride < k) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap2d()"); + return; + } + if (vstride < k) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMap2d()"); + return; + } + +#if 00 + /* Disable this check for now - it looks like various OpenGL drivers + * don't do this error check. So, a bunch of the NVIDIA demos + * generate errors/warnings. + */ + if (t->curTextureUnit != 0) { + /* See OpenGL 1.2.1 spec, section F.2.13 */ + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glMap2d()"); + return; + } +#endif + + switch (target) { + case GL_MAP2_VERTEX_3: + case GL_MAP2_VERTEX_4: + case GL_MAP2_INDEX: + case GL_MAP2_COLOR_4: + case GL_MAP2_NORMAL: + case GL_MAP2_TEXTURE_COORD_1: + case GL_MAP2_TEXTURE_COORD_2: + case GL_MAP2_TEXTURE_COORD_3: + case GL_MAP2_TEXTURE_COORD_4: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMap2d()"); + return; + } + + /* make copy of the control points */ + if (type == GL_FLOAT) + pnts = _copy_map_points2f(k, ustride, uorder, + vstride, vorder, (GLfloat *) points); + else + pnts = _copy_map_points2d(k, ustride, uorder, + vstride, vorder, (GLdouble *) points); + + e->eval2D[i].uorder = uorder; + e->eval2D[i].u1 = u1; + e->eval2D[i].u2 = u2; + e->eval2D[i].du = 1.0f / (u2 - u1); + e->eval2D[i].vorder = vorder; + e->eval2D[i].v1 = v1; + e->eval2D[i].v2 = v2; + e->eval2D[i].dv = 1.0f / (v2 - v1); + if (e->eval2D[i].coeff) + crFree(e->eval2D[i].coeff); + e->eval2D[i].coeff = pnts; + + DIRTY(eb->dirty, g->neg_bitid); + DIRTY(eb->eval2D[i], g->neg_bitid); +} + +void STATE_APIENTRY +crStateMap2f(GLenum target, GLfloat u1, GLfloat u2, + GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, + GLint vstride, GLint vorder, const GLfloat * points) +{ + map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, + points, GL_FLOAT); +} + + +void STATE_APIENTRY +crStateMap2d(GLenum target, GLdouble u1, GLdouble u2, + GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, + GLint vstride, GLint vorder, const GLdouble * points) +{ + map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder, + (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE); +} + +void STATE_APIENTRY +crStateGetMapdv(GLenum target, GLenum query, GLdouble * v) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CREvaluatorState *e = &(g->eval); + GLint size; + GLint i, j; + (void) sb; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Map1d called in begin/end"); + return; + } + + FLUSH(); + + i = target - GL_MAP1_COLOR_4; + + if (i < 0 || i >= GLEVAL_TOT) { + i = target - GL_MAP2_COLOR_4; + + if (i < 0 || i >= GLEVAL_TOT) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapdv: invalid target: %d", target); + return; + } + + switch (query) { + case GL_COEFF: + size = gleval_sizes[i] * e->eval2D[i].uorder * e->eval2D[i].vorder; + for (j = 0; j < size; j++) { + v[j] = e->eval2D[i].coeff[j]; + } + break; + case GL_ORDER: + v[0] = (GLdouble) e->eval2D[i].uorder; + v[1] = (GLdouble) e->eval2D[i].vorder; + break; + case GL_DOMAIN: + v[0] = e->eval2D[i].u1; + v[1] = e->eval2D[i].u2; + v[2] = e->eval2D[i].v1; + v[3] = e->eval2D[i].v2; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapdv: invalid target: %d", target); + return; + } + } + else { + switch (query) { + case GL_COEFF: + size = gleval_sizes[i] * e->eval1D[i].order; + for (j = 0; j < size; j++) { + v[j] = e->eval1D[i].coeff[j]; + } + break; + case GL_ORDER: + *v = (GLdouble) e->eval1D[i].order; + break; + case GL_DOMAIN: + v[0] = e->eval1D[i].u1; + v[1] = e->eval1D[i].u2; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapdv: invalid target: %d", target); + return; + } + } +} + +void STATE_APIENTRY +crStateGetMapfv(GLenum target, GLenum query, GLfloat * v) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CREvaluatorState *e = &(g->eval); + GLint size; + GLint i, j; + (void) sb; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Map1d called in begin/end"); + return; + } + + FLUSH(); + + i = target - GL_MAP1_COLOR_4; + if (i < 0 || i >= GLEVAL_TOT) { + i = target - GL_MAP2_COLOR_4; + if (i < 0 || i >= GLEVAL_TOT) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapfv: invalid target: %d", target); + return; + } + switch (query) { + case GL_COEFF: + size = gleval_sizes[i] * e->eval2D[i].uorder * e->eval2D[i].vorder; + for (j = 0; j < size; j++) { + v[j] = (GLfloat) e->eval2D[i].coeff[j]; + } + break; + case GL_ORDER: + v[0] = (GLfloat) e->eval2D[i].uorder; + v[1] = (GLfloat) e->eval2D[i].vorder; + break; + case GL_DOMAIN: + v[0] = (GLfloat) e->eval2D[i].u1; + v[1] = (GLfloat) e->eval2D[i].u2; + v[2] = (GLfloat) e->eval2D[i].v1; + v[3] = (GLfloat) e->eval2D[i].v2; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapfv: invalid target: %d", target); + return; + } + } + else { + switch (query) { + case GL_COEFF: + size = gleval_sizes[i] * e->eval1D[i].order; + for (j = 0; j < size; j++) { + v[j] = (GLfloat) e->eval1D[i].coeff[j]; + } + break; + case GL_ORDER: + *v = (GLfloat) e->eval1D[i].order; + break; + case GL_DOMAIN: + v[0] = (GLfloat) e->eval1D[i].u1; + v[1] = (GLfloat) e->eval1D[i].u2; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapfv: invalid target: %d", target); + return; + } + } +} + +void STATE_APIENTRY +crStateGetMapiv(GLenum target, GLenum query, GLint * v) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CREvaluatorState *e = &(g->eval); + GLint size; + GLint i, j; + (void) sb; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Map1d called in begin/end"); + return; + } + + FLUSH(); + + i = target - GL_MAP1_COLOR_4; + if (i < 0 || i >= GLEVAL_TOT) { + i = target - GL_MAP2_COLOR_4; + if (i < 0 || i >= GLEVAL_TOT) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapiv: invalid target: %d", target); + return; + } + switch (query) { + case GL_COEFF: + size = gleval_sizes[i] * e->eval2D[i].uorder * e->eval2D[i].vorder; + for (j = 0; j < size; j++) { + v[j] = (GLint) e->eval2D[i].coeff[j]; + } + break; + case GL_ORDER: + v[0] = e->eval2D[i].uorder; + v[1] = e->eval2D[i].vorder; + break; + case GL_DOMAIN: + v[0] = (GLint) e->eval2D[i].u1; + v[1] = (GLint) e->eval2D[i].u2; + v[2] = (GLint) e->eval2D[i].v1; + v[3] = (GLint) e->eval2D[i].v2; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapiv: invalid target: %d", target); + return; + } + } + else { + switch (query) { + case GL_COEFF: + size = gleval_sizes[i] * e->eval1D[i].order; + for (j = 0; j < size; j++) { + v[j] = (GLint) e->eval1D[i].coeff[j]; + } + break; + case GL_ORDER: + *v = e->eval1D[i].order; + break; + case GL_DOMAIN: + v[0] = (GLint) e->eval1D[i].u1; + v[1] = (GLint) e->eval1D[i].u2; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetMapiv: invalid target: %d", target); + return; + } + } +} + +void STATE_APIENTRY +crStateMapGrid1f(GLint un, GLfloat u1, GLfloat u2) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CREvaluatorState *e = &(g->eval); + CREvaluatorBits *eb = &(sb->eval); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Map1d called in begin/end"); + return; + } + + FLUSH(); + + if (un < 1) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMapGrid1f(bad un)"); + return; + } + + e->un1D = un; + e->u11D = u1; + e->u21D = u2; + + DIRTY(eb->dirty, g->neg_bitid); + DIRTY(eb->grid1D, g->neg_bitid); +} + +void STATE_APIENTRY +crStateMapGrid1d(GLint un, GLdouble u1, GLdouble u2) +{ + crStateMapGrid1f(un, (GLfloat) u1, (GLfloat) u2); +} + + +void STATE_APIENTRY +crStateMapGrid2f(GLint un, GLfloat u1, GLfloat u2, + GLint vn, GLfloat v1, GLfloat v2) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CREvaluatorState *e = &(g->eval); + CREvaluatorBits *eb = &(sb->eval); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Map1d called in begin/end"); + return; + } + + FLUSH(); + + if (un < 1) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMapGrid2f(bad un)"); + return; + } + if (vn < 1) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMapGrid2f(bad vn)"); + return; + } + + e->un2D = un; + e->vn2D = vn; + e->u12D = u1; + e->u22D = u2; + e->v12D = v1; + e->v22D = v2; + + DIRTY(eb->dirty, g->neg_bitid); + DIRTY(eb->grid2D, g->neg_bitid); +} + +void STATE_APIENTRY +crStateMapGrid2d(GLint un, GLdouble u1, GLdouble u2, + GLint vn, GLdouble v1, GLdouble v2) +{ + crStateMapGrid2f(un, (GLfloat) u1, (GLfloat) u2, + vn, (GLfloat) v1, (GLfloat) v2); +} + +void +crStateEvaluatorSwitch(CREvaluatorBits *e, CRbitvalue * bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CREvaluatorState *from = &(fromCtx->eval); + CREvaluatorState *to = &(toCtx->eval); + int i, j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j = 0; j < CR_MAX_BITARRAY; j++) + nbitID[j] = ~bitID[j]; + + if (CHECKDIRTY(e->enable, bitID)) { + if (from->autoNormal != to->autoNormal) { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + able[to->autoNormal] (GL_AUTO_NORMAL); + FILLDIRTY(e->enable); + FILLDIRTY(e->dirty); + } + CLEARDIRTY(e->enable, nbitID); + } + for (i = 0; i < GLEVAL_TOT; i++) { + if (CHECKDIRTY(e->eval1D[i], bitID)) { + int size = from->eval1D[i].order * gleval_sizes[i] * + sizeof(*from->eval1D[i].coeff); + if (from->eval1D[i].order != to->eval1D[i].order || + from->eval1D[i].u1 != to->eval1D[i].u1 || + from->eval1D[i].u2 != to->eval1D[i].u2 || + crMemcmp((const void *) from->eval1D[i].coeff, + (const void *) to->eval1D[i].coeff, size)) { + diff_api.Map1f(i + GL_MAP1_COLOR_4, to->eval1D[i].u1, + to->eval1D[i].u2, gleval_sizes[i], to->eval1D[i].order, + to->eval1D[i].coeff); + FILLDIRTY(e->dirty); + FILLDIRTY(e->eval1D[i]); + } + CLEARDIRTY(e->eval1D[i], nbitID); + } + } + + for (i = 0; i < GLEVAL_TOT; i++) { + if (CHECKDIRTY(e->eval2D[i], bitID)) { + int size = from->eval2D[i].uorder * from->eval2D[i].vorder + * gleval_sizes[i] * sizeof(*from->eval2D[i].coeff); + if (from->eval2D[i].uorder != to->eval2D[i].uorder || + from->eval2D[i].vorder != to->eval2D[i].vorder || + from->eval2D[i].u1 != to->eval2D[i].u1 || + from->eval2D[i].u2 != to->eval2D[i].u2 || + from->eval2D[i].v1 != to->eval2D[i].v1 || + from->eval2D[i].v2 != to->eval2D[i].v2 || + crMemcmp((const void *) from->eval2D[i].coeff, + (const void *) to->eval2D[i].coeff, size)) { + diff_api.Map2f(i + GL_MAP2_COLOR_4, + to->eval2D[i].u1, to->eval2D[i].u2, + gleval_sizes[i], to->eval2D[i].uorder, + to->eval2D[i].v1, to->eval2D[i].v2, + gleval_sizes[i], to->eval2D[i].vorder, + to->eval2D[i].coeff); + FILLDIRTY(e->dirty); + FILLDIRTY(e->eval2D[i]); + } + CLEARDIRTY(e->eval2D[i], nbitID); + } + } + if (CHECKDIRTY(e->grid1D, bitID)) { + if (from->u11D != to->u11D || + from->u21D != to->u21D || + from->un1D != to->un1D) { + diff_api.MapGrid1d(to->un1D, to->u11D, to->u21D); + FILLDIRTY(e->dirty); + FILLDIRTY(e->grid1D); + } + CLEARDIRTY(e->grid1D, nbitID); + } + if (CHECKDIRTY(e->grid2D, bitID)) { + if (from->u12D != to->u12D || + from->u22D != to->u22D || + from->un2D != to->un2D || + from->v12D != to->v12D || + from->v22D != to->v22D || + from->vn2D != to->vn2D) { + diff_api.MapGrid2d(to->un2D, to->u12D, to->u22D, + to->vn2D, to->v12D, to->v22D); + FILLDIRTY(e->dirty); + FILLDIRTY(e->grid1D); + } + CLEARDIRTY(e->grid1D, nbitID); + } + CLEARDIRTY(e->dirty, nbitID); +} + +void +crStateEvaluatorDiff(CREvaluatorBits *e, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CREvaluatorState *from = &(fromCtx->eval); + CREvaluatorState *to = &(toCtx->eval); + glAble able[2]; + int i, j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j = 0; j < CR_MAX_BITARRAY; j++) + nbitID[j] = ~bitID[j]; + + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + + if (CHECKDIRTY(e->enable, bitID)) { + if (from->autoNormal != to->autoNormal) { + able[to->autoNormal] (GL_AUTO_NORMAL); + from->autoNormal = to->autoNormal; + } + CLEARDIRTY(e->enable, nbitID); + } + for (i = 0; i < GLEVAL_TOT; i++) { + if (CHECKDIRTY(e->enable1D[i], bitID)) { + if (from->enable1D[i] != to->enable1D[i]) { + able[to->enable1D[i]] (i + GL_MAP1_COLOR_4); + from->enable1D[i] = to->enable1D[i]; + } + CLEARDIRTY(e->enable1D[i], nbitID); + } + if (to->enable1D[i] && CHECKDIRTY(e->eval1D[i], bitID)) { + int size = from->eval1D[i].order * gleval_sizes[i] * + sizeof(*from->eval1D[i].coeff); + if (from->eval1D[i].order != to->eval1D[i].order || + from->eval1D[i].u1 != to->eval1D[i].u1 || + from->eval1D[i].u2 != to->eval1D[i].u2 || + crMemcmp((const void *) from->eval1D[i].coeff, + (const void *) to->eval1D[i].coeff, size)) { + diff_api.Map1f(i + GL_MAP1_COLOR_4, to->eval1D[i].u1, + to->eval1D[i].u2, gleval_sizes[i], to->eval1D[i].order, + to->eval1D[i].coeff); + from->eval1D[i].order = to->eval1D[i].order; + from->eval1D[i].u1 = to->eval1D[i].u1; + from->eval1D[i].u2 = to->eval1D[i].u2; + crMemcpy((void *) from->eval1D[i].coeff, + (const void *) to->eval1D[i].coeff, size); + } + CLEARDIRTY(e->eval1D[i], nbitID); + } + } + + for (i = 0; i < GLEVAL_TOT; i++) { + if (CHECKDIRTY(e->enable2D[i], bitID)) { + if (from->enable2D[i] != to->enable2D[i]) { + able[to->enable2D[i]] (i + GL_MAP2_COLOR_4); + from->enable2D[i] = to->enable2D[i]; + } + CLEARDIRTY(e->enable2D[i], nbitID); + } + if (to->enable2D[i] && CHECKDIRTY(e->eval2D[i], bitID)) { + int size = from->eval2D[i].uorder * from->eval2D[i].vorder + * gleval_sizes[i] * sizeof(*from->eval2D[i].coeff); + if (from->eval2D[i].uorder != to->eval2D[i].uorder || + from->eval2D[i].vorder != to->eval2D[i].vorder || + from->eval2D[i].u1 != to->eval2D[i].u1 || + from->eval2D[i].u2 != to->eval2D[i].u2 || + from->eval2D[i].v1 != to->eval2D[i].v1 || + from->eval2D[i].v2 != to->eval2D[i].v2 || + crMemcmp((const void *) from->eval2D[i].coeff, + (const void *) to->eval2D[i].coeff, size)) { + diff_api.Map2f(i + GL_MAP2_COLOR_4, + to->eval2D[i].u1, to->eval2D[i].u2, + gleval_sizes[i], to->eval2D[i].uorder, + to->eval2D[i].v1, to->eval2D[i].v2, + gleval_sizes[i], to->eval2D[i].vorder, + to->eval2D[i].coeff); + from->eval2D[i].uorder = to->eval2D[i].uorder; + from->eval2D[i].vorder = to->eval2D[i].vorder; + from->eval2D[i].u1 = to->eval2D[i].u1; + from->eval2D[i].u2 = to->eval2D[i].u2; + from->eval2D[i].v1 = to->eval2D[i].v1; + from->eval2D[i].v2 = to->eval2D[i].v2; + crMemcpy((void *) from->eval2D[i].coeff, + (const void *) to->eval2D[i].coeff, size); + } + CLEARDIRTY(e->eval2D[i], nbitID); + } + } + if (CHECKDIRTY(e->grid1D, bitID)) { + if (from->u11D != to->u11D || + from->u21D != to->u21D || + from->un1D != to->un1D) { + diff_api.MapGrid1d(to->un1D, to->u11D, to->u21D); + from->u11D = to->u11D; + from->u21D = to->u21D; + from->un1D = to->un1D; + } + CLEARDIRTY(e->grid1D, nbitID); + } + if (CHECKDIRTY(e->grid2D, bitID)) { + if (from->u12D != to->u12D || + from->u22D != to->u22D || + from->un2D != to->un2D || + from->v12D != to->v12D || + from->v22D != to->v22D || + from->vn2D != to->vn2D) { + diff_api.MapGrid2d(to->un2D, to->u12D, to->u22D, + to->vn2D, to->v12D, to->v22D); + from->u12D = to->u12D; + from->u22D = to->u22D; + from->un2D = to->un2D; + from->v12D = to->v12D; + from->v22D = to->v22D; + from->vn2D = to->vn2D; + } + CLEARDIRTY(e->grid1D, nbitID); + } + CLEARDIRTY(e->dirty, nbitID); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_get.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_get.txt new file mode 100644 index 00000000..7eb5ec35 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_get.txt @@ -0,0 +1,138 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# GL_NV_fog_distance + +GLenum GL_FOG_DISTANCE_MODE_NV GL_NV_fog_distance g->fog.fogDistanceMode + + +# GL_EXT_texture_filter_anisotropic + +GLenum GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT GL_EXT_texture_filter_anisotropic g->limits.maxTextureAnisotropy + + +# GL_EXT_blend_color + +GLclampf GL_BLEND_COLOR_EXT GL_EXT_blend_color g->buffer.blendColor.r g->buffer.blendColor.g g->buffer.blendColor.b g->buffer.blendColor.a + +# GL_OPENGL_VERSION_1_2 + +GLboolean GL_RESCALE_NORMAL GL_OPENGL_VERSION_1_2 g->transform.rescaleNormals +GLenum GL_LIGHT_MODEL_COLOR_CONTROL GL_OPENGL_VERSION_1_2 g->lighting.lightModelColorControlEXT + +# GL_EXT_separate_specular_color + +GLenum GL_LIGHT_MODEL_COLOR_CONTROL_EXT GL_EXT_separate_specular_color g->lighting.lightModelColorControlEXT + +# GL_EXT_blend_minmax + +GLenum GL_BLEND_EQUATION_EXT GL_EXT_blend_minmax g->buffer.blendEquation + +# GL_EXT_blend_func_separate + +GLenum GL_BLEND_SRC_RGB_EXT GL_EXT_blend_func_separate g->buffer.blendSrcRGB +GLenum GL_BLEND_DST_RGB_EXT GL_EXT_blend_func_separate g->buffer.blendDstRGB +GLenum GL_BLEND_SRC_ALPHA_EXT GL_EXT_blend_func_separate g->buffer.blendSrcA +GLenum GL_BLEND_DST_ALPHA_EXT GL_EXT_blend_func_separate g->buffer.blendDstA + +# GL_NV_register_combiners + +GLint GL_NUM_GENERAL_COMBINERS_NV GL_NV_register_combiners g->regcombiner.numGeneralCombiners +GLboolean GL_REGISTER_COMBINERS_NV GL_NV_register_combiners g->regcombiner.enabledRegCombiners +GLboolean GL_COLOR_SUM_CLAMP_NV GL_NV_register_combiners g->regcombiner.colorSumClamp +GLfloat GL_CONSTANT_COLOR0_NV GL_NV_register_combiners g->regcombiner.constantColor0.r g->regcombiner.constantColor0.g g->regcombiner.constantColor0.b g->regcombiner.constantColor0.a +GLfloat GL_CONSTANT_COLOR1_NV GL_NV_register_combiners g->regcombiner.constantColor1.r g->regcombiner.constantColor1.g g->regcombiner.constantColor1.b g->regcombiner.constantColor1.a +GLint GL_MAX_GENERAL_COMBINERS_NV GL_NV_register_combiners g->limits.maxGeneralCombiners + + +# GL_NV_register_combiners2 + +GLboolean GL_PER_STAGE_CONSTANTS_NV GL_NV_register_combiners2 g->regcombiner.enabledPerStageConstants + + +# GL_ARB_texture_cube_map + +GLboolean GL_TEXTURE_CUBE_MAP_ARB GL_ARB_texture_cube_map g->texture.unit[g->texture.curTextureUnit].enabledCubeMap +GLint GL_TEXTURE_BINDING_CUBE_MAP_ARB GL_ARB_texture_cube_map g->texture.unit[g->texture.curTextureUnit].currentTextureCubeMap->id +GLint GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB GL_ARB_texture_cube_map g->limits.maxCubeMapTextureSize + +# GL_NV_texture_rectangle +GLboolean GL_TEXTURE_RECTANGLE_NV GL_NV_texture_rectangle g->texture.unit[g->texture.curTextureUnit].enabledRect +GLint GL_TEXTURE_BINDING_RECTANGLE_NV GL_NV_texture_rectangle g->texture.unit[g->texture.curTextureUnit].currentTextureRect->id +GLint GL_MAX_RECTANGLE_TEXTURE_SIZE_NV GL_NV_texture_rectangle g->limits.maxRectTextureSize + +# GL_NV_fragment_program +GLboolean GL_FRAGMENT_PROGRAM_NV GL_NV_fragment_program g->program.fpEnabled +GLuint GL_MAX_TEXTURE_COORDS_NV GL_NV_fragment_program g->limits.maxTextureCoords +GLuint GL_MAX_TEXTURE_IMAGE_UNITS_NV GL_NV_fragment_program g->limits.maxTextureImageUnits +GLuint GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV GL_NV_fragment_program g->limits.maxFragmentProgramLocalParams +# GLint GL_PROGRAM_ERROR_POSITION_NV GL_NV_fragment_program g->program.errorPos +GLuint GL_FRAGMENT_PROGRAM_BINDING_NV GL_NV_fragment_program g->program.fpProgramBinding + +# GL_NV_vertex_program +GLboolean GL_VERTEX_PROGRAM_NV GL_any_vertex_program g->program.vpEnabled +GLint GL_PROGRAM_ERROR_POSITION_NV GL_any_program g->program.errorPos +GLuint GL_VERTEX_PROGRAM_BINDING_NV GL_NV_vertex_program g->program.vpProgramBinding +GLboolean GL_VERTEX_PROGRAM_POINT_SIZE_NV GL_any_vertex_program g->program.vpPointSize +GLboolean GL_VERTEX_PROGRAM_TWO_SIDE_NV GL_any_vertex_program g->program.vpTwoSide + + +# GL_ARB_fragment_program +GLboolean GL_FRAGMENT_PROGRAM_ARB GL_ARB_fragment_program g->program.fpEnabledARB + + +# GL_ARB_transpose_matrix +GLdefault GL_TRANSPOSE_MODELVIEW_MATRIX GL_ARB_transpose_matrix g->transform.modelViewStack.top->m00 g->transform.modelViewStack.top->m10 g->transform.modelViewStack.top->m20 g->transform.modelViewStack.top->m30 g->transform.modelViewStack.top->m01 g->transform.modelViewStack.top->m11 g->transform.modelViewStack.top->m21 g->transform.modelViewStack.top->m31 g->transform.modelViewStack.top->m02 g->transform.modelViewStack.top->m12 g->transform.modelViewStack.top->m22 g->transform.modelViewStack.top->m32 g->transform.modelViewStack.top->m03 g->transform.modelViewStack.top->m13 g->transform.modelViewStack.top->m23 g->transform.modelViewStack.top->m33 +GLdefault GL_TRANSPOSE_PROJECTION_MATRIX GL_ARB_transpose_matrix g->transform.projectionStack.top->m00 g->transform.projectionStack.top->m10 g->transform.projectionStack.top->m20 g->transform.projectionStack.top->m30 g->transform.projectionStack.top->m01 g->transform.projectionStack.top->m11 g->transform.projectionStack.top->m21 g->transform.projectionStack.top->m31 g->transform.projectionStack.top->m02 g->transform.projectionStack.top->m12 g->transform.projectionStack.top->m22 g->transform.projectionStack.top->m32 g->transform.projectionStack.top->m03 g->transform.projectionStack.top->m13 g->transform.projectionStack.top->m23 g->transform.projectionStack.top->m33 +GLdefault GL_TRANSPOSE_TEXTURE_MATRIX GL_ARB_transpose_matrix g->transform.textureStack[g->texture.curTextureUnit].top->m00 g->transform.textureStack[g->texture.curTextureUnit].top->m10 g->transform.textureStack[g->texture.curTextureUnit].top->m20 g->transform.textureStack[g->texture.curTextureUnit].top->m30 g->transform.textureStack[g->texture.curTextureUnit].top->m01 g->transform.textureStack[g->texture.curTextureUnit].top->m11 g->transform.textureStack[g->texture.curTextureUnit].top->m21 g->transform.textureStack[g->texture.curTextureUnit].top->m31 g->transform.textureStack[g->texture.curTextureUnit].top->m02 g->transform.textureStack[g->texture.curTextureUnit].top->m12 g->transform.textureStack[g->texture.curTextureUnit].top->m22 g->transform.textureStack[g->texture.curTextureUnit].top->m32 g->transform.textureStack[g->texture.curTextureUnit].top->m03 g->transform.textureStack[g->texture.curTextureUnit].top->m13 g->transform.textureStack[g->texture.curTextureUnit].top->m23 g->transform.textureStack[g->texture.curTextureUnit].top->m33 + +# GL_ARB_multisample + +GLboolean GL_MULTISAMPLE_ARB GL_ARB_multisample g->multisample.enabled +GLboolean GL_SAMPLE_ALPHA_TO_COVERAGE_ARB GL_ARB_multisample g->multisample.sampleAlphaToCoverage +GLboolean GL_SAMPLE_ALPHA_TO_ONE_ARB GL_ARB_multisample g->multisample.sampleAlphaToOne +GLboolean GL_SAMPLE_COVERAGE_ARB GL_ARB_multisample g->multisample.sampleCoverage +GLint GL_SAMPLE_BUFFERS_ARB GL_ARB_multisample g->limits.sampleBuffers +GLint GL_SAMPLES_ARB GL_ARB_multisample g->limits.samples +GLint GL_SAMPLE_COVERAGE_VALUE_ARB GL_ARB_multisample g->multisample.sampleCoverageValue +GLboolean GL_SAMPLE_COVERAGE_INVERT_ARB GL_ARB_multisample g->multisample.sampleCoverageInvert + +# GL_ARB_texture_compression + +GLint GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB GL_ARB_texture_compression g->limits.numCompressedFormats +GLint GL_COMPRESSED_TEXTURE_FORMATS_ARB GL_ARB_texture_compression g->limits.compressedFormats[0] +GLint GL_TEXTURE_COMPRESSION_HINT_ARB GL_ARB_texture_compression g->hint.textureCompression + +# GL_EXT_texture_lod_bias +GLfloat GL_MAX_TEXTURE_LOD_BIAS_EXT GL_EXT_texture_lod_bias g->limits.maxTextureLodBias + +# GL_EXT_fog_coordinate +GLfloat GL_CURRENT_FOG_COORDINATE_EXT GL_EXT_fog_coord g->current.vertexAttrib[VERT_ATTRIB_FOG][0] +GLboolean GL_FOG_COORDINATE_ARRAY_EXT GL_EXT_fog_coord g->client.array.f.enabled +GLint GL_FOG_COORDINATE_ARRAY_TYPE_EXT GL_EXT_fog_coord g->client.array.f.type +GLint GL_FOG_COORDINATE_ARRAY_STRIDE_EXT GL_EXT_fog_coord g->client.array.f.stride +GLenum GL_FOG_COORDINATE_SOURCE_EXT GL_EXT_fog_coord g->fog.fogCoordinateSource + +# GL_EXT_secondary_color +GLboolean GL_COLOR_SUM_EXT GL_EXT_secondary_color g->lighting.colorSumEXT +GLfloat GL_CURRENT_SECONDARY_COLOR_EXT GL_EXT_secondary_color g->current.vertexAttrib[VERT_ATTRIB_COLOR1][0] g->current.vertexAttrib[VERT_ATTRIB_COLOR1][1] g->current.vertexAttrib[VERT_ATTRIB_COLOR1][2] +GLboolean GL_SECONDARY_COLOR_ARRAY_EXT GL_EXT_secondary_color g->client.array.s.enabled +GLint GL_SECONDARY_COLOR_ARRAY_TYPE_EXT GL_EXT_secondary_color g->client.array.s.type +GLint GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT GL_EXT_secondary_color g->client.array.s.stride +GLint GL_SECONDARY_COLOR_ARRAY_SIZE_EXT GL_EXT_secondary_color g->client.array.s.size + +# GL_SGIS_generate_mipmap +GLint GL_GENERATE_MIPMAP_HINT GL_SGIS_generate_mipmap g->hint.generateMipmap + +# GL_ARB_point_sprite +GLboolean GL_POINT_SPRITE_ARB GL_ARB_point_sprite g->point.pointSprite + +# GL_ARB_vertex_buffer_object +GLuint GL_ARRAY_BUFFER_BINDING_ARB GL_ARB_vertex_buffer_object g->bufferobject.arrayBuffer->id +GLuint GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB GL_ARB_vertex_buffer_object g->bufferobject.elementsBuffer->id + +# GL_ARB_pixel_buffer_object +GLuint GL_PIXEL_PACK_BUFFER_BINDING_ARB GL_ARB_pixel_buffer_object g->bufferobject.packBuffer->id +GLuint GL_PIXEL_UNPACK_BUFFER_BINDING_ARB GL_ARB_pixel_buffer_object g->bufferobject.unpackBuffer->id diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_isenabled.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_isenabled.txt new file mode 100644 index 00000000..d9c1da64 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_extensions_isenabled.txt @@ -0,0 +1,71 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +# GL_OPENGL_VERSION_1_2 + +GLboolean GL_RESCALE_NORMAL OPENGL_VERSION_1_2 g->transform.rescaleNormals +GLboolean GL_TEXTURE_3D OPENGL_VERSION_1_2 g->texture.unit[g->texture.curTextureUnit].enabled3D +GLboolean GL_MULTISAMPLE_ARB ARB_multisample g->multisample.enabled +GLboolean GL_SAMPLE_ALPHA_TO_COVERAGE_ARB ARB_multisample g->multisample.sampleAlphaToCoverage +GLboolean GL_SAMPLE_ALPHA_TO_ONE_ARB ARB_multisample g->multisample.sampleAlphaToOne +GLboolean GL_SAMPLE_COVERAGE_ARB ARB_multisample g->multisample.sampleCoverage +GLboolean GL_VERTEX_PROGRAM_NV NV_vertex_program g->program.vpEnabled +GLboolean GL_VERTEX_PROGRAM_POINT_SIZE_NV NV_vertex_program g->program.vpPointSize +GLboolean GL_VERTEX_PROGRAM_TWO_SIDE_NV NV_vertex_program g->program.vpTwoSide + +GLboolean GL_FRAGMENT_PROGRAM_NV NV_fragment_program g->program.fpEnabled +GLboolean GL_FRAGMENT_PROGRAM_ARB ARB_fragment_program g->program.fpEnabledARB +GLboolean GL_SECONDARY_COLOR_ARRAY_EXT EXT_secondary_color g->client.array.s.enabled +GLboolean GL_FOG_COORDINATE_ARRAY_EXT EXT_fog_coord g->client.array.f.enabled +GLboolean GL_TEXTURE_RECTANGLE_NV NV_texture_rectangle g->texture.unit[g->texture.curTextureUnit].enabledRect +GLboolean GL_VERTEX_ATTRIB_ARRAY0_NV NV_vertex_program g->client.array.a[0].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY1_NV NV_vertex_program g->client.array.a[1].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY2_NV NV_vertex_program g->client.array.a[2].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY3_NV NV_vertex_program g->client.array.a[3].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY4_NV NV_vertex_program g->client.array.a[4].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY5_NV NV_vertex_program g->client.array.a[5].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY6_NV NV_vertex_program g->client.array.a[6].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY7_NV NV_vertex_program g->client.array.a[7].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY8_NV NV_vertex_program g->client.array.a[8].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY9_NV NV_vertex_program g->client.array.a[9].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY10_NV NV_vertex_program g->client.array.a[10].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY11_NV NV_vertex_program g->client.array.a[11].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY12_NV NV_vertex_program g->client.array.a[12].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY13_NV NV_vertex_program g->client.array.a[13].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY14_NV NV_vertex_program g->client.array.a[14].enabled +GLboolean GL_VERTEX_ATTRIB_ARRAY15_NV NV_vertex_program g->client.array.a[15].enabled +GLboolean GL_MAP1_VERTEX_ATTRIB0_4_NV NV_vertex_program g->eval.enableAttrib1D[0] +GLboolean GL_MAP1_VERTEX_ATTRIB1_4_NV NV_vertex_program g->eval.enableAttrib1D[1] +GLboolean GL_MAP1_VERTEX_ATTRIB2_4_NV NV_vertex_program g->eval.enableAttrib1D[2] +GLboolean GL_MAP1_VERTEX_ATTRIB3_4_NV NV_vertex_program g->eval.enableAttrib1D[3] +GLboolean GL_MAP1_VERTEX_ATTRIB4_4_NV NV_vertex_program g->eval.enableAttrib1D[4] +GLboolean GL_MAP1_VERTEX_ATTRIB5_4_NV NV_vertex_program g->eval.enableAttrib1D[5] +GLboolean GL_MAP1_VERTEX_ATTRIB6_4_NV NV_vertex_program g->eval.enableAttrib1D[6] +GLboolean GL_MAP1_VERTEX_ATTRIB7_4_NV NV_vertex_program g->eval.enableAttrib1D[7] +GLboolean GL_MAP1_VERTEX_ATTRIB8_4_NV NV_vertex_program g->eval.enableAttrib1D[8] +GLboolean GL_MAP1_VERTEX_ATTRIB9_4_NV NV_vertex_program g->eval.enableAttrib1D[9] +GLboolean GL_MAP1_VERTEX_ATTRIB10_4_NV NV_vertex_program g->eval.enableAttrib1D[10] +GLboolean GL_MAP1_VERTEX_ATTRIB11_4_NV NV_vertex_program g->eval.enableAttrib1D[11] +GLboolean GL_MAP1_VERTEX_ATTRIB12_4_NV NV_vertex_program g->eval.enableAttrib1D[12] +GLboolean GL_MAP1_VERTEX_ATTRIB13_4_NV NV_vertex_program g->eval.enableAttrib1D[13] +GLboolean GL_MAP1_VERTEX_ATTRIB14_4_NV NV_vertex_program g->eval.enableAttrib1D[14] +GLboolean GL_MAP1_VERTEX_ATTRIB15_4_NV NV_vertex_program g->eval.enableAttrib1D[15] +GLboolean GL_MAP2_VERTEX_ATTRIB0_4_NV NV_vertex_program g->eval.enableAttrib2D[0] +GLboolean GL_MAP2_VERTEX_ATTRIB1_4_NV NV_vertex_program g->eval.enableAttrib2D[1] +GLboolean GL_MAP2_VERTEX_ATTRIB2_4_NV NV_vertex_program g->eval.enableAttrib2D[2] +GLboolean GL_MAP2_VERTEX_ATTRIB3_4_NV NV_vertex_program g->eval.enableAttrib2D[3] +GLboolean GL_MAP2_VERTEX_ATTRIB4_4_NV NV_vertex_program g->eval.enableAttrib2D[4] +GLboolean GL_MAP2_VERTEX_ATTRIB5_4_NV NV_vertex_program g->eval.enableAttrib2D[5] +GLboolean GL_MAP2_VERTEX_ATTRIB6_4_NV NV_vertex_program g->eval.enableAttrib2D[6] +GLboolean GL_MAP2_VERTEX_ATTRIB7_4_NV NV_vertex_program g->eval.enableAttrib2D[7] +GLboolean GL_MAP2_VERTEX_ATTRIB8_4_NV NV_vertex_program g->eval.enableAttrib2D[8] +GLboolean GL_MAP2_VERTEX_ATTRIB9_4_NV NV_vertex_program g->eval.enableAttrib2D[9] +GLboolean GL_MAP2_VERTEX_ATTRIB10_4_NV NV_vertex_program g->eval.enableAttrib2D[10] +GLboolean GL_MAP2_VERTEX_ATTRIB11_4_NV NV_vertex_program g->eval.enableAttrib2D[11] +GLboolean GL_MAP2_VERTEX_ATTRIB12_4_NV NV_vertex_program g->eval.enableAttrib2D[12] +GLboolean GL_MAP2_VERTEX_ATTRIB13_4_NV NV_vertex_program g->eval.enableAttrib2D[13] +GLboolean GL_MAP2_VERTEX_ATTRIB14_4_NV NV_vertex_program g->eval.enableAttrib2D[14] +GLboolean GL_MAP2_VERTEX_ATTRIB15_4_NV NV_vertex_program g->eval.enableAttrib2D[15] +GLboolean GL_RASTER_POSITION_UNCLIPPED_IBM IBM_rasterpos_clip g->transform.rasterPositionUnclipped diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_feedback.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_feedback.c new file mode 100644 index 00000000..a8591976 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_feedback.c @@ -0,0 +1,2423 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state_internals.h" +#include "state/cr_statetypes.h" +#include "state/cr_feedback.h" + +/* + * This file is really a complement to the feedbackSPU and as such + * has big dependencies upon it. We have to monitor a whole bunch + * of state in the feedbackSPU to be able to properly implement + * full functionality. + * + * We have to intercept glColor3f(v)/4f(v) to get state updates on + * color properties and also glTexCoord* too, as unlike the tilesortSPU + * we don't have a pincher that pulls these out as they're passing + * through. + * + * - Alan. + */ + + +/* + * Selection and feedback + * + * TODO: + * 1. Implement lighting for vertex colors for feedback + * 2. Implement user clip planes for points and lines + */ + + +/**********************************************************************/ +/***** Vertex Transformation and Clipping *****/ +/**********************************************************************/ + +/* + * Transform a point (column vector) by a matrix: Q = M * P + */ +#define TRANSFORM_POINT( Q, M, P ) \ + Q.x = (M).m00 * P.x + (M).m10 * P.y + (M).m20 * P.z + (M).m30 * P.w; \ + Q.y = (M).m01 * P.x + (M).m11 * P.y + (M).m21 * P.z + (M).m31 * P.w; \ + Q.z = (M).m02 * P.x + (M).m12 * P.y + (M).m22 * P.z + (M).m32 * P.w; \ + Q.w = (M).m03 * P.x + (M).m13 * P.y + (M).m23 * P.z + (M).m33 * P.w; + +#define TRANSFORM_POINTA( Q, M, P ) \ + Q.x = (M).m00 * (P)[0] + (M).m10 * (P)[1] + (M).m20 * (P)[2] + (M).m30 * (P)[3]; \ + Q.y = (M).m01 * (P)[0] + (M).m11 * (P)[1] + (M).m21 * (P)[2] + (M).m31 * (P)[3]; \ + Q.z = (M).m02 * (P)[0] + (M).m12 * (P)[1] + (M).m22 * (P)[2] + (M).m32 * (P)[3]; \ + Q.w = (M).m03 * (P)[0] + (M).m13 * (P)[1] + (M).m23 * (P)[2] + (M).m33 * (P)[3]; + +/* + * clip coord to window coord mapping + */ +#define MAP_POINT( Q, P, VP ) \ + Q.x = (GLfloat) (((P.x / P.w) + 1.0) * VP.viewportW / 2.0 + VP.viewportX); \ + Q.y = (GLfloat) (((P.y / P.w) + 1.0) * VP.viewportH / 2.0 + VP.viewportY); \ + Q.z = (GLfloat) (((P.z / P.w) + 1.0) * (VP.farClip - VP.nearClip) / 2.0 + VP.nearClip);\ + Q.w = (GLfloat) P.w; + + +/* + * Linear interpolation: + */ +#define INTERPOLATE(T, A, B) ((A) + ((B) - (A)) * (T)) + + +/* + * Interpolate vertex position, color, texcoords, etc. + */ +static void +interpolate_vertex(GLfloat t, + const CRVertex *v0, const CRVertex *v1, + CRVertex *vOut) +{ + vOut->eyePos.x = INTERPOLATE(t, v0->eyePos.x, v1->eyePos.x); + vOut->eyePos.y = INTERPOLATE(t, v0->eyePos.y, v1->eyePos.y); + vOut->eyePos.z = INTERPOLATE(t, v0->eyePos.z, v1->eyePos.z); + vOut->eyePos.w = INTERPOLATE(t, v0->eyePos.w, v1->eyePos.w); + + vOut->clipPos.x = INTERPOLATE(t, v0->clipPos.x, v1->clipPos.x); + vOut->clipPos.y = INTERPOLATE(t, v0->clipPos.y, v1->clipPos.y); + vOut->clipPos.z = INTERPOLATE(t, v0->clipPos.z, v1->clipPos.z); + vOut->clipPos.w = INTERPOLATE(t, v0->clipPos.w, v1->clipPos.w); + + vOut->attrib[VERT_ATTRIB_COLOR0][0] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_COLOR0][0], v1->attrib[VERT_ATTRIB_COLOR0][0]); + vOut->attrib[VERT_ATTRIB_COLOR0][1] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_COLOR0][1], v1->attrib[VERT_ATTRIB_COLOR0][1]); + vOut->attrib[VERT_ATTRIB_COLOR0][2] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_COLOR0][2], v1->attrib[VERT_ATTRIB_COLOR0][2]); + vOut->attrib[VERT_ATTRIB_COLOR0][3] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_COLOR0][3], v1->attrib[VERT_ATTRIB_COLOR0][3]); + + vOut->colorIndex = INTERPOLATE(t, v0->colorIndex, v1->colorIndex); + + vOut->attrib[VERT_ATTRIB_TEX0][0] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_TEX0][0], v1->attrib[VERT_ATTRIB_TEX0][0]); + vOut->attrib[VERT_ATTRIB_TEX0][1] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_TEX0][1], v1->attrib[VERT_ATTRIB_TEX0][0]); + vOut->attrib[VERT_ATTRIB_TEX0][2] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_TEX0][2], v1->attrib[VERT_ATTRIB_TEX0][0]); + vOut->attrib[VERT_ATTRIB_TEX0][3] = INTERPOLATE(t, v0->attrib[VERT_ATTRIB_TEX0][3], v1->attrib[VERT_ATTRIB_TEX0][0]); +} + + + + +/* clip bit codes */ +#define CLIP_LEFT 1 +#define CLIP_RIGHT 2 +#define CLIP_BOTTOM 4 +#define CLIP_TOP 8 +#define CLIP_NEAR 16 +#define CLIP_FAR 32 +#define CLIP_USER0 64 +#define CLIP_USER1 128 + + +/* + * Apply clip testing to a point. + * Return: 0 - visible + * non-zero - clip code mask (or of above CLIP_ bits) + */ +static GLuint +clip_point(const CRVertex *v) +{ + CRContext *g = GetCurrentContext(); + GLuint mask = 0; + GLuint i; + + /* user-defined clip planes */ + for (i = 0; i < g->limits.maxClipPlanes; i++) + { + if (g->transform.clip[i]) + { + const GLvectord *plane = g->transform.clipPlane + i; + if (plane->x * v->eyePos.x + + plane->y * v->eyePos.y + + plane->z * v->eyePos.z + + plane->w * v->eyePos.w < 0.0) + mask |= (CLIP_USER0 << i); + } + } + + /* view volume clipping */ + if (v->clipPos.x > v->clipPos.w) + mask |= CLIP_RIGHT; + if (v->clipPos.x < -v->clipPos.w) + mask |= CLIP_LEFT; + if (v->clipPos.y > v->clipPos.w) + mask |= CLIP_TOP; + if (v->clipPos.y < -v->clipPos.w) + mask |= CLIP_BOTTOM; + if (v->clipPos.z > v->clipPos.w) + mask |= CLIP_FAR; + if (v->clipPos.z < -v->clipPos.w) + mask |= CLIP_NEAR; + return mask; +} + + +/* + * Apply clipping to a line segment. + * Input: v0, v1 - incoming vertices + * Output: v0out, v1out - result/clipped vertices + * Return: GL_TRUE: visible + * GL_FALSE: totally clipped + */ +static GLboolean +clip_line(const CRVertex *v0in, const CRVertex *v1in, + CRVertex *v0new, CRVertex *v1new) +{ + CRVertex v0, v1, vNew; + GLfloat dx, dy, dz, dw, t; + GLuint code0, code1; + + /* XXX need to do user-clip planes */ + + code0 = clip_point(v0in); + code1 = clip_point(v1in); + if (code0 & code1) + return GL_FALSE; /* totally clipped */ + + *v0new = *v0in; + *v1new = *v1in; + if (code0 == 0 && code1 == 0) + return GL_TRUE; /* no clipping needed */ + + v0 = *v0in; + v1 = *v1in; + + +/* + * We use 6 instances of this code to clip agains the 6 planes. + * For each plane, we define the OUTSIDE and COMPUTE_INTERSECTION + * macros appropriately. + */ +#define GENERAL_CLIP \ + if (OUTSIDE(v0)) { \ + if (OUTSIDE(v1)) { \ + /* both verts are outside ==> return 0 */ \ + return 0; \ + } \ + else { \ + /* v0 is outside, v1 is inside ==> clip */ \ + COMPUTE_INTERSECTION( v1, v0, vNew ) \ + interpolate_vertex(t, &v1, &v0, &vNew); \ + v0 = vNew; \ + } \ + } \ + else { \ + if (OUTSIDE(v1)) { \ + /* v0 is inside, v1 is outside ==> clip */ \ + COMPUTE_INTERSECTION( v0, v1, vNew ) \ + interpolate_vertex(t, &v0, &v1, &vNew); \ + v1 = vNew; \ + } \ + /* else both verts are inside ==> do nothing */ \ + } + + /*** Clip against +X side ***/ +#define OUTSIDE(V) (V.clipPos.x > V.clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dx = OUT.clipPos.x - IN.clipPos.x; \ + dw = OUT.clipPos.w - IN.clipPos.w; \ + t = (IN.clipPos.x - IN.clipPos.w) / (dw-dx); + GENERAL_CLIP +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + /*** Clip against -X side ***/ +#define OUTSIDE(V) (V.clipPos.x < -(V.clipPos.w)) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dx = OUT.clipPos.x - IN.clipPos.x; \ + dw = OUT.clipPos.w - IN.clipPos.w; \ + t = -(IN.clipPos.x + IN.clipPos.w) / (dw+dx); + GENERAL_CLIP +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + /*** Clip against +Y side ***/ +#define OUTSIDE(V) (V.clipPos.y > V.clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dy = OUT.clipPos.y - IN.clipPos.y; \ + dw = OUT.clipPos.w - IN.clipPos.w; \ + t = (IN.clipPos.y - IN.clipPos.w) / (dw-dy); + GENERAL_CLIP +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + /*** Clip against -Y side ***/ +#define OUTSIDE(V) (V.clipPos.y < -(V.clipPos.w)) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dy = OUT.clipPos.y - IN.clipPos.y; \ + dw = OUT.clipPos.w - IN.clipPos.w; \ + t = -(IN.clipPos.y + IN.clipPos.w) / (dw+dy); + GENERAL_CLIP +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + /*** Clip against +Z side ***/ +#define OUTSIDE(V) (V.clipPos.z > V.clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dz = OUT.clipPos.z - IN.clipPos.z; \ + dw = OUT.clipPos.w - IN.clipPos.w; \ + t = (IN.clipPos.z - IN.clipPos.w) / (dw-dz); + GENERAL_CLIP +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + + /*** Clip against -Z side ***/ +#define OUTSIDE(V) (V.clipPos.z < -(V.clipPos.w)) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dz = OUT.clipPos.z - IN.clipPos.z; \ + dw = OUT.clipPos.w - IN.clipPos.w; \ + t = -(IN.clipPos.z + IN.clipPos.w) / (dw+dz); + GENERAL_CLIP +#undef OUTSIDE +#undef COMPUTE_INTERSECTION + +#undef GENERAL_CLIP + + *v0new = v0; + *v1new = v1; + return GL_TRUE; +} + + + +/* + * Apply clipping to a polygon. + * Input: vIn - array of input vertices + * inCount - number of input vertices + * Output: vOut - new vertices + * Return: number of vertices in vOut + */ +static GLuint +clip_polygon(const CRVertex *vIn, unsigned int inCount, + CRVertex *vOut) +{ + CRVertex inlist[20], outlist[20]; + GLfloat dx, dy, dz, dw, t; + GLuint incount, outcount, previ, curri, result; + const CRVertex *currVert, *prevVert; + CRVertex *newVert; + + /* XXX need to do user-clip planes */ + +#define GENERAL_CLIP(INCOUNT, INLIST, OUTCOUNT, OUTLIST) \ + if (INCOUNT < 3) \ + return GL_FALSE; \ + previ = INCOUNT - 1; /* let previous = last vertex */ \ + prevVert = INLIST + previ; \ + OUTCOUNT = 0; \ + for (curri = 0; curri < INCOUNT; curri++) { \ + currVert = INLIST + curri; \ + if (INSIDE(currVert)) { \ + if (INSIDE(prevVert)) { \ + /* both verts are inside ==> copy current to outlist */ \ + OUTLIST[OUTCOUNT] = *currVert; \ + OUTCOUNT++; \ + } \ + else { \ + newVert = OUTLIST + OUTCOUNT; \ + /* current is inside and previous is outside ==> clip */ \ + COMPUTE_INTERSECTION( currVert, prevVert, newVert ) \ + OUTCOUNT++; \ + /* Output current */ \ + OUTLIST[OUTCOUNT] = *currVert; \ + OUTCOUNT++; \ + } \ + } \ + else { \ + if (INSIDE(prevVert)) { \ + newVert = OUTLIST + OUTCOUNT; \ + /* current is outside and previous is inside ==> clip */ \ + COMPUTE_INTERSECTION( prevVert, currVert, newVert ); \ + OUTLIST[OUTCOUNT] = *newVert; \ + OUTCOUNT++; \ + } \ + /* else both verts are outside ==> do nothing */ \ + } \ + /* let previous = current */ \ + previ = curri; \ + prevVert = currVert; \ + } + +/* + * Clip against +X + */ +#define INSIDE(V) (V->clipPos.x <= V->clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dx = OUT->clipPos.x - IN->clipPos.x; \ + dw = OUT->clipPos.w - IN->clipPos.w; \ + t = (IN->clipPos.x - IN->clipPos.w) / (dw - dx); \ + interpolate_vertex(t, IN, OUT, NEW ); + + GENERAL_CLIP(inCount, vIn, outcount, outlist) + +#undef INSIDE +#undef COMPUTE_INTERSECTION + +/* + * Clip against -X + */ +#define INSIDE(V) (V->clipPos.x >= -V->clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dx = OUT->clipPos.x - IN->clipPos.x; \ + dw = OUT->clipPos.w - IN->clipPos.w; \ + t = -(IN->clipPos.x + IN->clipPos.w) / (dw + dx); \ + interpolate_vertex(t, IN, OUT, NEW ); + + GENERAL_CLIP(outcount, outlist, incount, inlist) + +#undef INSIDE +#undef COMPUTE_INTERSECTION + +/* + * Clip against +Y + */ +#define INSIDE(V) (V->clipPos.y <= V->clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dy = OUT->clipPos.y - IN->clipPos.y; \ + dw = OUT->clipPos.w - IN->clipPos.w; \ + t = (IN->clipPos.y - IN->clipPos.w) / (dw - dy); \ + interpolate_vertex(t, IN, OUT, NEW ); + + GENERAL_CLIP(incount, inlist, outcount, outlist) + +#undef INSIDE +#undef COMPUTE_INTERSECTION + +/* + * Clip against -Y + */ +#define INSIDE(V) (V->clipPos.y >= -V->clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dy = OUT->clipPos.y - IN->clipPos.y; \ + dw = OUT->clipPos.w - IN->clipPos.w; \ + t = -(IN->clipPos.y + IN->clipPos.w) / (dw + dy); \ + interpolate_vertex(t, IN, OUT, NEW ); + + GENERAL_CLIP(outcount, outlist, incount, inlist) + +#undef INSIDE +#undef COMPUTE_INTERSECTION + +/* + * Clip against +Z + */ +#define INSIDE(V) (V->clipPos.z <= V->clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dz = OUT->clipPos.z - IN->clipPos.z; \ + dw = OUT->clipPos.w - IN->clipPos.w; \ + t = (IN->clipPos.z - IN->clipPos.w) / (dw - dz); \ + interpolate_vertex(t, IN, OUT, NEW ); + + GENERAL_CLIP(incount, inlist, outcount, outlist) + +#undef INSIDE +#undef COMPUTE_INTERSECTION + +/* + * Clip against -Z + */ +#define INSIDE(V) (V->clipPos.z >= -V->clipPos.w) +#define COMPUTE_INTERSECTION( IN, OUT, NEW ) \ + dz = OUT->clipPos.z - IN->clipPos.z; \ + dw = OUT->clipPos.w - IN->clipPos.w; \ + t = -(IN->clipPos.z + IN->clipPos.w) / (dw + dz); \ + interpolate_vertex(t, IN, OUT, NEW ); + + GENERAL_CLIP(outcount, outlist, result, vOut) + +#undef INSIDE +#undef COMPUTE_INTERSECTION + +#undef GENERAL_CLIP + + return result; +} + + +/**********************************************************************/ +/***** Feedback *****/ +/**********************************************************************/ + + +#define FB_3D 0x01 +#define FB_4D 0x02 +#define FB_INDEX 0x04 +#define FB_COLOR 0x08 +#define FB_TEXTURE 0X10 + +#define FEEDBACK_TOKEN( T ) \ + do { \ + if (f->count < f->bufferSize) { \ + f->buffer[f->count] = (GLfloat) (T); \ + } \ + f->count++; \ + } while (0) + +/* + * Put a vertex into the feedback buffer. + */ +static void +feedback_vertex(const CRVertex *v) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + CRTransformState *t = &(g->transform); + + FEEDBACK_TOKEN(v->winPos.x); + FEEDBACK_TOKEN(v->winPos.y); + + if (f->mask & FB_3D) + { + FEEDBACK_TOKEN(v->winPos.z); + } + + if (f->mask & FB_4D) + { + FEEDBACK_TOKEN(v->winPos.w); + } + + /* We don't deal with color index in Chromium */ + if (f->mask & FB_INDEX) + { + FEEDBACK_TOKEN(v->colorIndex); + } + + if (f->mask & FB_COLOR) + { + FEEDBACK_TOKEN(v->attrib[VERT_ATTRIB_COLOR0][0]); + FEEDBACK_TOKEN(v->attrib[VERT_ATTRIB_COLOR0][1]); + FEEDBACK_TOKEN(v->attrib[VERT_ATTRIB_COLOR0][2]); + FEEDBACK_TOKEN(v->attrib[VERT_ATTRIB_COLOR0][3]); + } + + if (f->mask & FB_TEXTURE) + { + GLvectorf coord, transCoord; + /* Ugh, copy (s,t,r,q) to (x,y,z,w) */ + coord.x = v->attrib[VERT_ATTRIB_TEX0][0]; + coord.y = v->attrib[VERT_ATTRIB_TEX0][1]; + coord.z = v->attrib[VERT_ATTRIB_TEX0][2]; + coord.w = v->attrib[VERT_ATTRIB_TEX0][3]; + TRANSFORM_POINT(transCoord, *(t->textureStack[0].top), coord); + FEEDBACK_TOKEN(transCoord.x); + FEEDBACK_TOKEN(transCoord.y); + FEEDBACK_TOKEN(transCoord.z); + FEEDBACK_TOKEN(transCoord.w); + } +} + + + +static void +feedback_rasterpos(void) +{ + CRContext *g = GetCurrentContext(); + CRVertex *tv = g->vBuffer + g->vCount; + CRVertex v; + + v.winPos.x = g->current.rasterAttrib[VERT_ATTRIB_POS][0]; + v.winPos.y = g->current.rasterAttrib[VERT_ATTRIB_POS][1]; + v.winPos.z = g->current.rasterAttrib[VERT_ATTRIB_POS][2]; + v.winPos.w = g->current.rasterAttrib[VERT_ATTRIB_POS][3]; + COPY_4V(v.attrib[VERT_ATTRIB_COLOR0] , g->current.rasterAttrib[VERT_ATTRIB_COLOR0]); /* XXX need to apply lighting */ + COPY_4V(v.attrib[VERT_ATTRIB_COLOR1] , g->current.rasterAttrib[VERT_ATTRIB_COLOR1]); + v.colorIndex = (GLfloat) g->current.rasterIndex; + + /* Don't do this, we're capturing TexCoord ourselves and + * we'd miss the conversion in RasterPosUpdate */ + /* v.texCoord[0] = g->current.rasterTexture; */ + + /* So we do this instead, and pluck it from the current vertex */ + COPY_4V(v.attrib[VERT_ATTRIB_TEX0] , tv->attrib[VERT_ATTRIB_TEX0]); + + feedback_vertex(&v); +} + + +static void +feedback_point(const CRVertex *v) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + if (clip_point(v) == 0) + { + CRVertex c = *v; + MAP_POINT(c.winPos, c.clipPos, g->viewport); + FEEDBACK_TOKEN((GLfloat) GL_POINT_TOKEN); + feedback_vertex(&c); + } +} + + +static void +feedback_line(const CRVertex *v0, const CRVertex *v1, GLboolean reset) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + CRVertex c0, c1; + if (clip_line(v0, v1, &c0, &c1)) + { + MAP_POINT(c0.winPos, c0.clipPos, g->viewport); + MAP_POINT(c1.winPos, c1.clipPos, g->viewport); + if (reset) + FEEDBACK_TOKEN((GLfloat) GL_LINE_RESET_TOKEN); + else + FEEDBACK_TOKEN((GLfloat) GL_LINE_TOKEN); + feedback_vertex(&c0); + feedback_vertex(&c1); + } +} + + +static void +feedback_triangle(const CRVertex *v0, const CRVertex *v1, const CRVertex *v2) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + CRVertex vlist[3], vclipped[8]; + GLuint i, n; + + vlist[0] = *v0; + vlist[1] = *v1; + vlist[2] = *v2; + n = clip_polygon(vlist, 3, vclipped); + FEEDBACK_TOKEN( (GLfloat) GL_POLYGON_TOKEN ); + FEEDBACK_TOKEN( (GLfloat) n ); + for (i = 0; i < n; i++) { + MAP_POINT(vclipped[i].winPos, vclipped[i].clipPos, g->viewport); + feedback_vertex(vclipped + i); + } +} + + +void STATE_APIENTRY +crStateFeedbackVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRPolygonState *p = &(g->polygon); + CRVertex *v = g->vBuffer + g->vCount; + + /* store the vertex */ + v->attrib[VERT_ATTRIB_POS][0] = x; + v->attrib[VERT_ATTRIB_POS][1] = y; + v->attrib[VERT_ATTRIB_POS][2] = z; + v->attrib[VERT_ATTRIB_POS][3] = w; + COPY_4V(v->attrib[VERT_ATTRIB_COLOR0] , g->current.vertexAttrib[VERT_ATTRIB_COLOR0]); /* XXX need to apply lighting */ + v->colorIndex = g->current.colorIndex; /* XXX need to apply lighting */ + /* Don't do this, we're capturing TexCoord ourselves as + * we don't have a pincher like the tilesortSPU */ + /* v->texCoord[0] = g->current.texCoord[0]; */ + + /* transform to eye space, then clip space */ + TRANSFORM_POINTA(v->eyePos, *(t->modelViewStack.top), v->attrib[VERT_ATTRIB_POS]); + TRANSFORM_POINT(v->clipPos, *(t->projectionStack.top), v->eyePos); + + switch (g->current.mode) { + case GL_POINTS: + CRASSERT(g->vCount == 0); + feedback_point(v); + break; + case GL_LINES: + if (g->vCount == 0) + { + g->vCount = 1; + } + else + { + CRASSERT(g->vCount == 1); + feedback_line(g->vBuffer + 0, g->vBuffer + 1, g->lineReset); + g->vCount = 0; + } + break; + case GL_LINE_STRIP: + if (g->vCount == 0) + { + g->vCount = 1; + } + else + { + CRASSERT(g->vCount == 1); + feedback_line(g->vBuffer + 0, g->vBuffer + 1, g->lineReset); + g->vBuffer[0] = g->vBuffer[1]; + g->lineReset = GL_FALSE; + /* leave g->vCount at 1 */ + } + break; + case GL_LINE_LOOP: + if (g->vCount == 0) + { + g->lineLoop = GL_FALSE; + g->vCount = 1; + } + else if (g->vCount == 1) + { + feedback_line(g->vBuffer + 0, g->vBuffer + 1, g->lineReset); + g->lineReset = GL_FALSE; + g->lineLoop = GL_TRUE; + g->vCount = 2; + } + else + { + CRASSERT(g->vCount == 2); + CRASSERT(g->lineReset == GL_FALSE); + g->lineLoop = GL_FALSE; + feedback_line(g->vBuffer + 1, g->vBuffer + 2, g->lineReset); + g->vBuffer[1] = g->vBuffer[2]; + /* leave g->vCount at 2 */ + } + break; + case GL_TRIANGLES: + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 2); + feedback_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vCount = 0; + } + break; + case GL_TRIANGLE_STRIP: + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else if (g->vCount == 2) + { + feedback_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vCount = 3; + } + else + { + CRASSERT(g->vCount == 3); + feedback_triangle(g->vBuffer + 1, g->vBuffer + 3, g->vBuffer + 2); + g->vBuffer[0] = g->vBuffer[2]; + g->vBuffer[1] = g->vBuffer[3]; + g->vCount = 2; + } + break; + case GL_TRIANGLE_FAN: + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 2); + feedback_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vBuffer[1] = g->vBuffer[2]; + /* leave g->vCount = 2 */ + } + break; + case GL_QUADS: + if (g->vCount < 3) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 3); + feedback_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + feedback_triangle(g->vBuffer + 0, g->vBuffer + 2, g->vBuffer + 3); + g->vCount = 0; + } + break; + case GL_QUAD_STRIP: + if (g->vCount < 3) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 3); + feedback_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + feedback_triangle(g->vBuffer + 1, g->vBuffer + 3, g->vBuffer + 2); + g->vBuffer[0] = g->vBuffer[2]; + g->vBuffer[1] = g->vBuffer[3]; + g->vCount = 2; + } + break; + case GL_POLYGON: + /* XXX need to observe polygon mode for the above TRI/QUAD prims */ + switch (p->frontMode) { + case GL_POINT: + CRASSERT(g->vCount == 0); + feedback_point(v); + break; + case GL_LINE: + if (g->vCount == 0) + { + g->lineLoop = GL_FALSE; + g->vCount = 1; + } + else if (g->vCount == 1) + { + feedback_line(g->vBuffer + 0, g->vBuffer + 1, g->lineReset); + g->lineReset = GL_FALSE; + g->lineLoop = GL_TRUE; + g->vCount = 2; + } + else + { + CRASSERT(g->vCount == 2); + CRASSERT(g->lineReset == GL_FALSE); + g->lineLoop = GL_FALSE; + feedback_line(g->vBuffer + 1, g->vBuffer + 2, g->lineReset); + g->vBuffer[1] = g->vBuffer[2]; + /* leave g->vCount at 2 */ + } + break; + case GL_FILL: + /* draw as a tri-fan */ + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 2); + feedback_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vBuffer[1] = g->vBuffer[2]; + /* leave g->vCount = 2 */ + } + break; + default: + ; /* impossible */ + } + break; + default: + ; /* impossible */ + } +} + + +void STATE_APIENTRY +crStateFeedbackBegin(GLenum mode) +{ + CRContext *g = GetCurrentContext(); + + crStateBegin(mode); + + g->vCount = 0; + g->lineReset = GL_TRUE; + g->lineLoop = GL_FALSE; +} + + +void STATE_APIENTRY +crStateFeedbackEnd(void) +{ + CRContext *g = GetCurrentContext(); + + if ( (g->current.mode == GL_LINE_LOOP || + (g->current.mode == GL_POLYGON && g->polygon.frontMode == GL_LINE)) + && g->vCount == 2 ) + { + /* draw the last line segment */ + if (g->lineLoop) + feedback_line(g->vBuffer + 1, g->vBuffer + 0, GL_FALSE); + else + feedback_line(g->vBuffer + 2, g->vBuffer + 0, GL_FALSE); + } + + crStateEnd(); +} + + +void STATE_APIENTRY +crStateFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "FeedbackBuffer called in begin/end"); + return; + } + + if (g->renderMode == GL_FEEDBACK) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Invalid Operation GL_FEEDBACK"); + return; + } + if (size < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "Invalid Value size < 0"); + return; + } + if (!buffer) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "Invalid Value buffer = NULL"); + f->bufferSize = 0; + return; + } + + FLUSH(); + + switch (type) + { + case GL_2D: + f->mask = 0; + break; + case GL_3D: + f->mask = FB_3D; + break; + case GL_3D_COLOR: + f->mask = (FB_3D | FB_COLOR); /* FB_INDEX ?? */ + break; + case GL_3D_COLOR_TEXTURE: + f->mask = (FB_3D | FB_COLOR | FB_TEXTURE); /* FB_INDEX ?? */ + break; + case GL_4D_COLOR_TEXTURE: + f->mask = (FB_3D | FB_4D | FB_COLOR | FB_TEXTURE); /* FB_INDEX ?? */ + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "invalid type"); + return; + } + + f->type = type; + f->bufferSize = size; + f->buffer = buffer; + f->count = 0; +} + + +void STATE_APIENTRY +crStatePassThrough(GLfloat token) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "PassThrough called in begin/end"); + return; + } + + FLUSH(); + + if (g->renderMode == GL_FEEDBACK) + { + FEEDBACK_TOKEN((GLfloat) (GLint) GL_PASS_THROUGH_TOKEN); + FEEDBACK_TOKEN(token); + } +} + + +/* + * Although these functions are used by the feedbackSPU alone, + * I've left them here as they interface to the other functions..... + */ +void STATE_APIENTRY +crStateFeedbackGetBooleanv(GLenum pname, GLboolean * params) +{ + CRContext *g = GetCurrentContext(); + + switch (pname) + { + + case GL_FEEDBACK_BUFFER_SIZE: + params[0] = (GLboolean) (g->feedback.bufferSize != 0); + break; + case GL_FEEDBACK_BUFFER_TYPE: + params[0] = (GLboolean) (g->feedback.type != 0); + break; + case GL_SELECTION_BUFFER_SIZE: + params[0] = (GLboolean) (g->selection.bufferSize != 0); + break; + default: + break; + } +} + + +void STATE_APIENTRY +crStateFeedbackGetDoublev(GLenum pname, GLdouble * params) +{ + CRContext *g = GetCurrentContext(); + + switch (pname) + { + + case GL_FEEDBACK_BUFFER_SIZE: + params[0] = (GLdouble) g->feedback.bufferSize; + break; + case GL_FEEDBACK_BUFFER_TYPE: + params[0] = (GLdouble) g->feedback.type; + break; + case GL_SELECTION_BUFFER_SIZE: + params[0] = (GLdouble) g->selection.bufferSize; + break; + default: + break; + } +} + + +void STATE_APIENTRY +crStateFeedbackGetFloatv(GLenum pname, GLfloat * params) +{ + CRContext *g = GetCurrentContext(); + + switch (pname) + { + + case GL_FEEDBACK_BUFFER_SIZE: + params[0] = (GLfloat) g->feedback.bufferSize; + break; + case GL_FEEDBACK_BUFFER_TYPE: + params[0] = (GLfloat) g->feedback.type; + break; + case GL_SELECTION_BUFFER_SIZE: + params[0] = (GLfloat) g->selection.bufferSize; + break; + default: + break; + } +} + + +void STATE_APIENTRY +crStateFeedbackGetIntegerv(GLenum pname, GLint * params) +{ + CRContext *g = GetCurrentContext(); + + switch (pname) + { + + case GL_FEEDBACK_BUFFER_SIZE: + params[0] = (GLint) g->feedback.bufferSize; + break; + case GL_FEEDBACK_BUFFER_TYPE: + params[0] = (GLint) g->feedback.type; + break; + case GL_SELECTION_BUFFER_SIZE: + params[0] = (GLint) g->selection.bufferSize; + break; + default: + break; + } +} + + +void STATE_APIENTRY +crStateFeedbackDrawPixels(GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + + (void) width; + (void) height; + (void) format; + (void) type; + (void) pixels; + + FEEDBACK_TOKEN((GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN); + + feedback_rasterpos(); +} + +void STATE_APIENTRY +crStateFeedbackCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum type) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + + (void) x; + (void) y; + (void) width; + (void) height; + (void) type; + + FEEDBACK_TOKEN((GLfloat) (GLint) GL_COPY_PIXEL_TOKEN); + feedback_rasterpos(); +} + +void STATE_APIENTRY +crStateFeedbackBitmap(GLsizei width, GLsizei height, GLfloat xorig, + GLfloat yorig, GLfloat xmove, GLfloat ymove, + const GLubyte * bitmap) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + + (void) width; + (void) height; + (void) bitmap; + (void) xorig; + (void) yorig; + + FEEDBACK_TOKEN((GLfloat) (GLint) GL_BITMAP_TOKEN); + + feedback_rasterpos(); + + if (g->current.rasterValid) + { + g->current.rasterAttrib[VERT_ATTRIB_POS][0] += xmove; + g->current.rasterAttrib[VERT_ATTRIB_POS][1] += ymove; + } +} + + +void STATE_APIENTRY +crStateFeedbackVertex4fv(const GLfloat * v) +{ + crStateFeedbackVertex4f(v[0], v[1], v[2], v[3]); +} + +void STATE_APIENTRY +crStateFeedbackVertex4s(GLshort v0, GLshort v1, GLshort v2, GLshort v3) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, (GLfloat) v2, + (GLfloat) v3); +} + +void STATE_APIENTRY +crStateFeedbackVertex4sv(const GLshort * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], + (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateFeedbackVertex4i(GLint v0, GLint v1, GLint v2, GLint v3) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, (GLfloat) v2, + (GLfloat) v3); +} + +void STATE_APIENTRY +crStateFeedbackVertex4iv(const GLint * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], + (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateFeedbackVertex4d(GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, (GLfloat) v2, + (GLfloat) v3); +} + +void STATE_APIENTRY +crStateFeedbackVertex4dv(const GLdouble * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], + (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateFeedbackVertex2i(GLint v0, GLint v1) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex2iv(const GLint * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex2s(GLshort v0, GLshort v1) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex2sv(const GLshort * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex2f(GLfloat v0, GLfloat v1) +{ + crStateFeedbackVertex4f(v0, v1, 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex2fv(const GLfloat * v) +{ + crStateFeedbackVertex4f(v[0], v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex2d(GLdouble v0, GLdouble v1) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex2dv(const GLdouble * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3i(GLint v0, GLint v1, GLint v2) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, (GLfloat) v2, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3iv(const GLint * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3s(GLshort v0, GLshort v1, GLshort v2) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, (GLfloat) v2, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3sv(const GLshort * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], + 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3f(GLfloat v0, GLfloat v1, GLfloat v2) +{ + crStateFeedbackVertex4f(v0, v1, v2, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3fv(const GLfloat * v) +{ + crStateFeedbackVertex4f(v[0], v[1], v[2], 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3d(GLdouble v0, GLdouble v1, GLdouble v2) +{ + crStateFeedbackVertex4f((GLfloat) v0, (GLfloat) v1, (GLfloat) v2, 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackVertex3dv(const GLdouble * v) +{ + crStateFeedbackVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], + 1.0f); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4f( GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3 ) +{ + CRContext *g = GetCurrentContext(); + CRVertex *v = g->vBuffer + g->vCount; + + /* store the texCoord in the current vertex */ + v->attrib[VERT_ATTRIB_TEX0][0] = v0; + v->attrib[VERT_ATTRIB_TEX0][1] = v1; + v->attrib[VERT_ATTRIB_TEX0][2] = v2; + v->attrib[VERT_ATTRIB_TEX0][3] = v3; +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4fv( const GLfloat *v ) +{ + crStateFeedbackTexCoord4f( v[0], v[1], v[2], v[3] ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4s( GLshort v0, GLshort v1, GLshort v2, GLshort v3 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, (GLfloat)v2, (GLfloat)v3 ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4sv( const GLshort *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3] ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4i( GLint v0, GLint v1, GLint v2, GLint v3 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, (GLfloat)v2, (GLfloat)v3 ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4iv( const GLint *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3] ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4d( GLdouble v0, GLdouble v1, GLdouble v2, GLdouble v3 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, (GLfloat)v2, (GLfloat)v3 ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord4dv( const GLdouble *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], (GLfloat)v[3] ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1i( GLint v0 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1iv( const GLint *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1s( GLshort v0 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1sv( const GLshort *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1f( GLfloat v0 ) +{ + crStateFeedbackTexCoord4f( v0, 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1fv( const GLfloat *v ) +{ + crStateFeedbackTexCoord4f( v[0], 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1d( GLdouble v0 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord1dv( const GLdouble *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], 0.0f, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2i( GLint v0, GLint v1 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2iv( const GLint *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2s( GLshort v0, GLshort v1 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2sv( const GLshort *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2f( GLfloat v0, GLfloat v1 ) +{ + crStateFeedbackTexCoord4f( v0, v1, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2fv( const GLfloat *v ) +{ + crStateFeedbackTexCoord4f( v[0], v[1], 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2d( GLdouble v0, GLdouble v1 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord2dv( const GLdouble *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3i( GLint v0, GLint v1, GLint v2 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, (GLfloat)v2, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3iv( const GLint *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], 0.0f, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3s( GLshort v0, GLshort v1, GLshort v2 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, (GLfloat)v2, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3sv( const GLshort *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3f( GLfloat v0, GLfloat v1, GLfloat v2 ) +{ + crStateFeedbackTexCoord4f( v0, v1, v2, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3fv( const GLfloat *v ) +{ + crStateFeedbackTexCoord4f( v[0], v[1], v[2], 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3d( GLdouble v0, GLdouble v1, GLdouble v2 ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v0, (GLfloat)v1, (GLfloat)v2, 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackTexCoord3dv( const GLdouble *v ) +{ + crStateFeedbackTexCoord4f( (GLfloat)v[0], (GLfloat)v[1], (GLfloat)v[2], 1.0f ); +} + +void STATE_APIENTRY +crStateFeedbackRectf(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1) +{ + crStateFeedbackBegin(GL_QUADS); + crStateFeedbackVertex2f(x0, y0); + crStateFeedbackVertex2f(x0, y1); + crStateFeedbackVertex2f(x1, y1); + crStateFeedbackVertex2f(x1, y0); + crStateFeedbackEnd(); +} + +void STATE_APIENTRY +crStateFeedbackRecti(GLint x0, GLint y0, GLint x1, GLint y1) +{ + crStateFeedbackRectf((GLfloat) x0, (GLfloat) y0, (GLfloat) x1, (GLfloat) y1); +} + +void STATE_APIENTRY +crStateFeedbackRectd(GLdouble x0, GLdouble y0, GLdouble x1, GLdouble y1) +{ + crStateFeedbackRectf((GLfloat) x0, (GLfloat) y0, (GLfloat) x1, (GLfloat) y1); +} + +void STATE_APIENTRY +crStateFeedbackRects(GLshort x0, GLshort y0, GLshort x1, GLshort y1) +{ + crStateFeedbackRectf((GLfloat) x0, (GLfloat) y0, (GLfloat) x1, (GLfloat) y1); +} + +void STATE_APIENTRY +crStateFeedbackRectiv(const GLint *v0, const GLint *v1) +{ + crStateFeedbackRectf((GLfloat) v0[0], (GLfloat) v0[1], (GLfloat) v1[0], (GLfloat) v1[1]); +} + +void STATE_APIENTRY +crStateFeedbackRectfv(const GLfloat *v0, const GLfloat *v1) +{ + crStateFeedbackRectf(v0[0], v0[1], v1[0], v1[1]); +} + +void STATE_APIENTRY +crStateFeedbackRectdv(const GLdouble *v0, const GLdouble *v1) +{ + crStateFeedbackRectf((GLfloat) v0[0], (GLfloat) v0[1], (GLfloat) v1[0], (GLfloat) v1[1]); +} + +void STATE_APIENTRY +crStateFeedbackRectsv(const GLshort *v0, const GLshort *v1) +{ + crStateFeedbackRectf((GLfloat) v0[0], (GLfloat) v0[1], (GLfloat) v1[0], (GLfloat) v1[1]); +} + +/**********************************************************************/ +/***** Selection *****/ +/**********************************************************************/ + + +void STATE_APIENTRY +crStateSelectBuffer(GLsizei size, GLuint * buffer) +{ + CRContext *g = GetCurrentContext(); + CRSelectionState *se = &(g->selection); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "SelectBuffer called in begin/end"); + return; + } + + if (g->renderMode == GL_SELECT) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "SelectBuffer called with RenderMode = GL_SELECT"); + return; + } + + FLUSH(); + + se->buffer = buffer; + se->bufferSize = size; + se->bufferCount = 0; + se->hitFlag = GL_FALSE; + se->hitMinZ = 1.0; + se->hitMaxZ = 0.0; +} + + +#define WRITE_RECORD( V ) \ + if (se->bufferCount < se->bufferSize) { \ + se->buffer[se->bufferCount] = (V); \ + } \ + se->bufferCount++; + + +static void +write_hit_record(CRSelectionState * se) +{ + GLuint i; + GLuint zmin, zmax, zscale = (~0u); + + /* hitMinZ and hitMaxZ are in [0,1]. Multiply these values by */ + /* 2^32-1 and round to nearest unsigned integer. */ + + zmin = (GLuint) ((GLfloat) zscale * se->hitMinZ); + zmax = (GLuint) ((GLfloat) zscale * se->hitMaxZ); + + WRITE_RECORD(se->nameStackDepth); + WRITE_RECORD(zmin); + WRITE_RECORD(zmax); + for (i = 0; i < se->nameStackDepth; i++) + { + WRITE_RECORD(se->nameStack[i]); + } + + se->hits++; + se->hitFlag = GL_FALSE; + se->hitMinZ = 1.0; + se->hitMaxZ = -1.0; +} + + + +void STATE_APIENTRY +crStateInitNames(void) +{ + CRContext *g = GetCurrentContext(); + CRSelectionState *se = &(g->selection); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "InitNames called in begin/end"); + return; + } + + FLUSH(); + + /* Record the hit before the hitFlag is wiped out again. */ + if (g->renderMode == GL_SELECT) + { + if (se->hitFlag) + { + write_hit_record(se); + } + } + + se->nameStackDepth = 0; + se->hitFlag = GL_FALSE; + se->hitMinZ = 1.0; + se->hitMaxZ = 0.0; +} + + +void STATE_APIENTRY +crStateLoadName(GLuint name) +{ + CRContext *g = GetCurrentContext(); + CRSelectionState *se = &(g->selection); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "LoadName called in begin/end"); + return; + } + + + if (g->renderMode != GL_SELECT) + { + return; + } + + if (se->nameStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "nameStackDepth = 0"); + return; + } + + FLUSH(); + + if (se->hitFlag) + { + write_hit_record(se); + } + if (se->nameStackDepth < MAX_NAME_STACK_DEPTH) + { + se->nameStack[se->nameStackDepth - 1] = name; + } + else + { + se->nameStack[MAX_NAME_STACK_DEPTH - 1] = name; + } +} + + +void STATE_APIENTRY +crStatePushName(GLuint name) +{ + CRContext *g = GetCurrentContext(); + CRSelectionState *se = &(g->selection); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "PushName called in begin/end"); + return; + } + + + if (g->renderMode != GL_SELECT) + { + return; + } + + FLUSH(); + + if (se->hitFlag) + { + write_hit_record(se); + } + if (se->nameStackDepth >= MAX_NAME_STACK_DEPTH) + { + crStateError(__LINE__, __FILE__, GL_STACK_OVERFLOW, + "nameStackDepth overflow"); + } + else + se->nameStack[se->nameStackDepth++] = name; +} + +void STATE_APIENTRY +crStatePopName(void) +{ + CRContext *g = GetCurrentContext(); + CRSelectionState *se = &(g->selection); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "PopName called in begin/end"); + return; + } + + if (g->renderMode != GL_SELECT) + { + return; + } + + FLUSH(); + + if (se->hitFlag) + { + write_hit_record(se); + } + + if (se->nameStackDepth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, + "nameStackDepth underflow"); + } + else + se->nameStackDepth--; +} + + +static void +update_hitflag(GLfloat z) +{ + CRContext *g = GetCurrentContext(); + CRSelectionState *se = &(g->selection); + + se->hitFlag = GL_TRUE; + + if (z < se->hitMinZ) + se->hitMinZ = z; + + if (z > se->hitMaxZ) + se->hitMaxZ = z; +} + + +static void +select_rasterpos(void) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.rasterValid) + update_hitflag(g->current.rasterAttrib[VERT_ATTRIB_POS][2]); +} + +static void +select_point(const CRVertex *v) +{ + CRContext *g = GetCurrentContext(); + if (clip_point(v) == 0) + { + CRVertex c = *v; + MAP_POINT(c.winPos, c.clipPos, g->viewport); + update_hitflag(c.winPos.z); + } +} + + +static void +select_line(const CRVertex *v0, const CRVertex *v1) +{ + CRContext *g = GetCurrentContext(); + CRVertex c0, c1; + if (clip_line(v0, v1, &c0, &c1)) + { + MAP_POINT(c0.winPos, c0.clipPos, g->viewport); + MAP_POINT(c1.winPos, c1.clipPos, g->viewport); + update_hitflag(c0.winPos.z); + update_hitflag(c1.winPos.z); + } +} + + +static void +select_triangle(const CRVertex *v0, + const CRVertex *v1, + const CRVertex *v2) +{ + CRContext *g = GetCurrentContext(); + CRVertex vlist[3], vclipped[8]; + GLuint i, n; + + vlist[0] = *v0; + vlist[1] = *v1; + vlist[2] = *v2; + n = clip_polygon(vlist, 3, vclipped); + for (i = 0; i < n; i++) { + MAP_POINT(vclipped[i].winPos, vclipped[i].clipPos, g->viewport); + update_hitflag(vclipped[i].winPos.z); + } +} + + +void STATE_APIENTRY +crStateSelectVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRVertex *v = g->vBuffer + g->vCount; + + /* store the vertex */ + v->attrib[VERT_ATTRIB_POS][0] = x; + v->attrib[VERT_ATTRIB_POS][1] = y; + v->attrib[VERT_ATTRIB_POS][2] = z; + v->attrib[VERT_ATTRIB_POS][3] = w; + COPY_4V(v->attrib[VERT_ATTRIB_COLOR0] , g->current.vertexAttrib[VERT_ATTRIB_COLOR0]); /* XXX need to apply lighting */ + v->colorIndex = g->current.colorIndex; /* XXX need to apply lighting */ + /* Don't do this, we're capturing TexCoord ourselves as + * we don't have a pincher like the tilesortSPU */ + /* v->texCoord[0] = g->current.texCoord[0]; */ + + /* transform to eye space, then clip space */ + TRANSFORM_POINTA(v->eyePos, *(t->modelViewStack.top), v->attrib[VERT_ATTRIB_POS]); + TRANSFORM_POINT(v->clipPos, *(t->projectionStack.top), v->eyePos); + + switch (g->current.mode) { + case GL_POINTS: + CRASSERT(g->vCount == 0); + select_point(v); + break; + case GL_LINES: + if (g->vCount == 0) + { + g->vCount = 1; + } + else + { + CRASSERT(g->vCount == 1); + select_line(g->vBuffer + 0, g->vBuffer + 1); + g->vCount = 0; + } + break; + case GL_LINE_STRIP: + if (g->vCount == 0) + { + g->vCount = 1; + } + else + { + CRASSERT(g->vCount == 1); + select_line(g->vBuffer + 0, g->vBuffer + 1); + g->vBuffer[0] = g->vBuffer[1]; + /* leave g->vCount at 1 */ + } + break; + case GL_LINE_LOOP: + if (g->vCount == 0) + { + g->vCount = 1; + g->lineLoop = GL_FALSE; + } + else if (g->vCount == 1) + { + select_line(g->vBuffer + 0, g->vBuffer + 1); + g->lineLoop = GL_TRUE; + g->vCount = 2; + } + else + { + CRASSERT(g->vCount == 2); + g->lineLoop = GL_FALSE; + select_line(g->vBuffer + 1, g->vBuffer + 2); + g->vBuffer[1] = g->vBuffer[2]; + /* leave g->vCount at 2 */ + } + break; + case GL_TRIANGLES: + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 2); + select_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vCount = 0; + } + break; + case GL_TRIANGLE_STRIP: + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else if (g->vCount == 2) + { + select_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vCount = 3; + } + else + { + CRASSERT(g->vCount == 3); + select_triangle(g->vBuffer + 1, g->vBuffer + 3, g->vBuffer + 2); + g->vBuffer[0] = g->vBuffer[2]; + g->vBuffer[1] = g->vBuffer[3]; + g->vCount = 2; + } + break; + case GL_TRIANGLE_FAN: + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 2); + select_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vBuffer[1] = g->vBuffer[2]; + /* leave g->vCount = 2 */ + } + break; + case GL_QUADS: + if (g->vCount < 3) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 3); + select_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + select_triangle(g->vBuffer + 0, g->vBuffer + 2, g->vBuffer + 3); + g->vCount = 0; + } + break; + case GL_QUAD_STRIP: + if (g->vCount < 3) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 3); + select_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + select_triangle(g->vBuffer + 1, g->vBuffer + 3, g->vBuffer + 2); + g->vBuffer[0] = g->vBuffer[2]; + g->vBuffer[1] = g->vBuffer[3]; + g->vCount = 2; + } + break; + case GL_POLYGON: + /* draw as a tri-fan */ + if (g->vCount == 0 || g->vCount == 1) + { + g->vCount++; + } + else + { + CRASSERT(g->vCount == 2); + select_triangle(g->vBuffer + 0, g->vBuffer + 1, g->vBuffer + 2); + g->vBuffer[1] = g->vBuffer[2]; + /* leave g->vCount = 2 */ + } + break; + default: + ; /* impossible */ + } +} + +void STATE_APIENTRY +crStateSelectRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + crStateRasterPos4f( x, y, z, w ); + + select_rasterpos(); +} + +void STATE_APIENTRY +crStateSelectBegin(GLenum mode) +{ + CRContext *g = GetCurrentContext(); + + crStateBegin(mode); + + g->vCount = 0; + g->lineReset = GL_TRUE; + g->lineLoop = GL_FALSE; +} + + +void STATE_APIENTRY +crStateSelectEnd(void) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.mode == GL_LINE_LOOP && g->vCount == 2) + { + /* draw the last line segment */ + select_line(g->vBuffer + 1, g->vBuffer + 0); + } + + crStateEnd(); +} + +void STATE_APIENTRY +crStateSelectVertex2d(GLdouble x, GLdouble y) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex2dv(const GLdouble * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex2f(GLfloat x, GLfloat y) +{ + crStateSelectVertex4f(x, y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex2fv(const GLfloat * v) +{ + crStateSelectVertex4f(v[0], v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex2i(GLint x, GLint y) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex2iv(const GLint * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex2s(GLshort x, GLshort y) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex2sv(const GLshort * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3d(GLdouble x, GLdouble y, GLdouble z) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3dv(const GLdouble * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3f(GLfloat x, GLfloat y, GLfloat z) +{ + crStateSelectVertex4f(x, y, z, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3fv(const GLfloat * v) +{ + crStateSelectVertex4f(v[0], v[1], v[2], 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3i(GLint x, GLint y, GLint z) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3iv(const GLint * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3s(GLshort x, GLshort y, GLshort z) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex3sv(const GLshort * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0); +} + +void STATE_APIENTRY +crStateSelectVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY +crStateSelectVertex4dv(const GLdouble * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateSelectVertex4fv(const GLfloat * v) +{ + crStateSelectVertex4f(v[0], v[1], v[2], v[3]); +} + +void STATE_APIENTRY +crStateSelectVertex4i(GLint x, GLint y, GLint z, GLint w) +{ + crStateSelectVertex4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY +crStateSelectVertex4iv(const GLint * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateSelectVertex4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + crStateSelectVertex4f(x, y, z, w); +} + +void STATE_APIENTRY +crStateSelectVertex4sv(const GLshort * v) +{ + crStateSelectVertex4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateSelectRasterPos2d(GLdouble x, GLdouble y) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos2dv(const GLdouble * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos2f(GLfloat x, GLfloat y) +{ + crStateSelectRasterPos4f(x, y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos2fv(const GLfloat * v) +{ + crStateSelectRasterPos4f(v[0], v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos2i(GLint x, GLint y) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos2iv(const GLint * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos2s(GLshort x, GLshort y) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos2sv(const GLshort * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3dv(const GLdouble * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] , 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + crStateSelectRasterPos4f(x, y, z, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3fv(const GLfloat * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] , 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3i(GLint x, GLint y, GLint z) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3iv(const GLint * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] , 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3s(GLshort x, GLshort y, GLshort z) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos3sv(const GLshort * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] , 1.0); +} + +void STATE_APIENTRY +crStateSelectRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY +crStateSelectRasterPos4dv(const GLdouble * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] , (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateSelectRasterPos4fv(const GLfloat * v) +{ + crStateSelectRasterPos4f(v[0], v[1], v[2], v[3]); +} + +void STATE_APIENTRY +crStateSelectRasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY +crStateSelectRasterPos4iv(const GLint * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateSelectRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + crStateSelectRasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY +crStateSelectRasterPos4sv(const GLshort * v) +{ + crStateSelectRasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] , (GLfloat) v[3]); +} + +void STATE_APIENTRY +crStateSelectRectf(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1) +{ + crStateSelectBegin(GL_QUADS); + crStateSelectVertex2f(x0, y0); + crStateSelectVertex2f(x0, y1); + crStateSelectVertex2f(x1, y1); + crStateSelectVertex2f(x1, y0); + crStateSelectEnd(); +} + +void STATE_APIENTRY +crStateSelectRecti(GLint x0, GLint y0, GLint x1, GLint y1) +{ + crStateSelectRectf((GLfloat) x0, (GLfloat) y0, (GLfloat) x1, (GLfloat) y1); +} + +void STATE_APIENTRY +crStateSelectRectd(GLdouble x0, GLdouble y0, GLdouble x1, GLdouble y1) +{ + crStateSelectRectf((GLfloat) x0, (GLfloat) y0, (GLfloat) x1, (GLfloat) y1); +} + +void STATE_APIENTRY +crStateSelectRects(GLshort x0, GLshort y0, GLshort x1, GLshort y1) +{ + crStateSelectRectf((GLfloat) x0, (GLfloat) y0, (GLfloat) x1, (GLfloat) y1); +} + +void STATE_APIENTRY +crStateSelectRectiv(const GLint *v0, const GLint *v1) +{ + crStateSelectRectf((GLfloat) v0[0], (GLfloat) v0[1], (GLfloat) v1[0], (GLfloat) v1[1]); +} + +void STATE_APIENTRY +crStateSelectRectfv(const GLfloat *v0, const GLfloat *v1) +{ + crStateSelectRectf(v0[0], v0[1], v1[0], v1[1]); +} + +void STATE_APIENTRY +crStateSelectRectdv(const GLdouble *v0, const GLdouble *v1) +{ + crStateSelectRectf((GLfloat) v0[0], (GLfloat) v0[1], (GLfloat) v1[0], (GLfloat) v1[1]); +} + +void STATE_APIENTRY +crStateSelectRectsv(const GLshort *v0, const GLshort *v1) +{ + crStateSelectRectf((GLfloat) v0[0], (GLfloat) v0[1], (GLfloat) v1[0], (GLfloat) v1[1]); +} + + +GLint STATE_APIENTRY +crStateRenderMode(GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRFeedbackState *f = &(g->feedback); + CRSelectionState *se = &(g->selection); + GLint result; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "RenderMode called in begin/end"); + return 0; + } + + FLUSH(); + + switch (g->renderMode) + { + case GL_RENDER: + result = 0; + break; + case GL_SELECT: + if (se->hitFlag) + { + write_hit_record(se); + } + + if (se->bufferCount > se->bufferSize) + { + /* overflow */ + result = -1; + } + else + { + result = se->hits; + } + se->bufferCount = 0; + se->hits = 0; + se->nameStackDepth = 0; + break; + case GL_FEEDBACK: + if (f->count > f->bufferSize) + { + /* overflow */ + result = -1; + } + else + { + result = f->count; + } + f->count = 0; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "invalid rendermode"); + return 0; + } + + switch (mode) + { + case GL_RENDER: + break; + case GL_SELECT: + if (se->bufferSize == 0) + { + /* haven't called glSelectBuffer yet */ + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "buffersize = 0"); + } + break; + case GL_FEEDBACK: + if (f->bufferSize == 0) + { + /* haven't called glFeedbackBuffer yet */ + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "buffersize = 0"); + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "invalid rendermode"); + return 0; + } + + g->renderMode = mode; + + return result; +} + + +void STATE_APIENTRY +crStateSelectDrawPixels(GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid * pixels) +{ + (void) width; + (void) height; + (void) format; + (void) type; + (void) pixels; + select_rasterpos(); +} + +void STATE_APIENTRY +crStateSelectCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum type) +{ + (void) x; + (void) y; + (void) width; + (void) height; + (void) type; + select_rasterpos(); +} + +void STATE_APIENTRY +crStateSelectBitmap(GLsizei width, GLsizei height, GLfloat xorig, + GLfloat yorig, GLfloat xmove, GLfloat ymove, + const GLubyte * bitmap) +{ + CRContext *g = GetCurrentContext(); + (void) width; + (void) height; + (void) xorig; + (void) yorig; + (void) bitmap; + + select_rasterpos(); + if (g->current.rasterValid) + { + g->current.rasterAttrib[VERT_ATTRIB_POS][0] += xmove; + g->current.rasterAttrib[VERT_ATTRIB_POS][1] += ymove; + } +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_feedback_special b/src/VBox/GuestHost/OpenGL/state_tracker/state_feedback_special new file mode 100644 index 00000000..e0b16e71 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_feedback_special @@ -0,0 +1,73 @@ +Vertex4f +Begin +End +GetBooleanv +GetDoublev +GetFloatv +GetIntegerv +DrawPixels +CopyPixels +Bitmap +Vertex4fv +Vertex4s +Vertex4sv +Vertex4i +Vertex4iv +Vertex4d +Vertex4dv +Vertex2i +Vertex2iv +Vertex2s +Vertex2sv +Vertex2f +Vertex2fv +Vertex2d +Vertex2dv +Vertex3i +Vertex3iv +Vertex3s +Vertex3sv +Vertex3f +Vertex3fv +Vertex3d +Vertex3dv +Rectf +Recti +Rectd +Rects +Rectiv +Rectfv +Rectdv +Rectsv +TexCoord1d +TexCoord1dv +TexCoord1f +TexCoord1fv +TexCoord1i +TexCoord1iv +TexCoord1s +TexCoord1sv +TexCoord2d +TexCoord2dv +TexCoord2f +TexCoord2fv +TexCoord2i +TexCoord2iv +TexCoord2s +TexCoord2sv +TexCoord3d +TexCoord3dv +TexCoord3f +TexCoord3fv +TexCoord3i +TexCoord3iv +TexCoord3s +TexCoord3sv +TexCoord4d +TexCoord4dv +TexCoord4f +TexCoord4fv +TexCoord4i +TexCoord4iv +TexCoord4s +TexCoord4sv diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_fence.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_fence.c new file mode 100644 index 00000000..054f1c4b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_fence.c @@ -0,0 +1,50 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state_internals.h" +#include "state/cr_statetypes.h" + + + +void APIENTRY crStateGenFencesNV(GLsizei n, GLuint *fences) +{ + (void)n; (void)fences; +} + + +void APIENTRY crStateDeleteFencesNV(GLsizei n, const GLuint *fences) +{ + (void)n; (void)fences; +} + +void APIENTRY crStateSetFenceNV(GLuint fence, GLenum condition) +{ + (void)fence; (void)condition; +} + +GLboolean APIENTRY crStateTestFenceNV(GLuint fence) +{ + (void)fence; + return GL_FALSE; +} + +void APIENTRY crStateFinishFenceNV(GLuint fence) +{ + (void)fence; +} + +GLboolean APIENTRY crStateIsFenceNV(GLuint fence) +{ + (void)fence; + return GL_FALSE; +} + +void APIENTRY crStateGetFenceivNV(GLuint fence, GLenum pname, GLint *params) +{ + (void)fence; (void)pname; (void)params; +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_flush.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_flush.c new file mode 100644 index 00000000..052080e0 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_flush.c @@ -0,0 +1,34 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "cr_spu.h" + +SPUDispatchTable diff_api; + +void crStateFlushFunc( CRStateFlushFunc func ) +{ + CRContext *g = GetCurrentContext(); + + g->flush_func = func; +} + +void crStateFlushArg( void *arg ) +{ + CRContext *g = GetCurrentContext(); + + g->flush_arg = arg; +} + +void crStateDiffAPI( SPUDispatchTable *api ) +{ + if (!diff_api.AlphaFunc) + { + /* Called when starting up Chromium */ + crSPUInitDispatchTable( &(diff_api) ); + } + crSPUCopyDispatchTable( &(diff_api), api ); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_fog.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_fog.c new file mode 100644 index 00000000..41f1f313 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_fog.c @@ -0,0 +1,199 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateFogInit (CRContext *ctx) +{ + CRFogState *f = &ctx->fog; + CRStateBits *sb = GetCurrentBits(); + CRFogBits *fb = &(sb->fog); + GLcolorf black = {0.0f, 0.0f, 0.0f, 0.0f}; + + f->color = black; + RESET(fb->color, ctx->bitid); + f->density = 1.0f; + RESET(fb->density, ctx->bitid); + f->end = 1.0f; + RESET(fb->end, ctx->bitid); + f->start = 0.0f; + RESET(fb->start, ctx->bitid); + f->mode = GL_EXP; + RESET(fb->mode, ctx->bitid); + f->index = 0; + RESET(fb->index, ctx->bitid); + f->enable = GL_FALSE; + RESET(fb->enable, ctx->bitid); + +#ifdef CR_NV_fog_distance + f->fogDistanceMode = GL_EYE_PLANE_ABSOLUTE_NV; + RESET(fb->fogDistanceMode, ctx->bitid); +#endif +#ifdef CR_EXT_fog_coord + f->fogCoordinateSource = GL_FRAGMENT_DEPTH_EXT; + RESET(fb->fogCoordinateSource, ctx->bitid); +#endif + RESET(fb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateFogf(GLenum pname, GLfloat param) +{ + crStateFogfv( pname, ¶m ); +} + +void STATE_APIENTRY crStateFogi(GLenum pname, GLint param) +{ + GLfloat f_param = (GLfloat) param; + crStateFogfv( pname, &f_param ); +} + +void STATE_APIENTRY crStateFogiv(GLenum pname, const GLint *param) +{ + GLcolor f_color; + GLfloat f_param; + switch (pname) + { + case GL_FOG_MODE: + case GL_FOG_DENSITY: + case GL_FOG_START: + case GL_FOG_END: + case GL_FOG_INDEX: + f_param = (GLfloat) (*param); + crStateFogfv( pname, &f_param ); + break; + case GL_FOG_COLOR: + f_color.r = ((GLfloat) param[0]) / ((GLfloat) CR_MAXINT); + f_color.g = ((GLfloat) param[1]) / ((GLfloat) CR_MAXINT); + f_color.b = ((GLfloat) param[2]) / ((GLfloat) CR_MAXINT); + f_color.a = ((GLfloat) param[3]) / ((GLfloat) CR_MAXINT); + crStateFogfv( pname, (GLfloat *) &f_color ); + break; +#ifdef CR_NV_fog_distance + case GL_FOG_DISTANCE_MODE_NV: + f_param = (GLfloat) (*param); + crStateFogfv( pname, &f_param ); + break; +#endif +#ifdef CR_EXT_fog_coord + case GL_FOG_COORDINATE_SOURCE_EXT: + f_param = (GLfloat) (*param); + crStateFogfv( pname, &f_param ); + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param); + return; + } +} + +void STATE_APIENTRY crStateFogfv(GLenum pname, const GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRFogState *f = &(g->fog); + CRStateBits *sb = GetCurrentBits(); + CRFogBits *fb = &(sb->fog); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glFogfv called in Begin/End"); + return; + } + + FLUSH(); + + switch (pname) + { + case GL_FOG_MODE: + { + GLenum e = (GLenum) *param; + if (e != GL_LINEAR && e != GL_EXP && e != GL_EXP2) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid param for glFog: %d", e); + return; + } + f->mode = e; + DIRTY(fb->mode, g->neg_bitid); + } + break; + case GL_FOG_DENSITY: + f->density = *param; + if (f->density < 0.0f) + { + f->density = 0.0f; + } + DIRTY(fb->density, g->neg_bitid); + break; + case GL_FOG_START: + f->start = *param; + DIRTY(fb->start, g->neg_bitid); + break; + case GL_FOG_END: + f->end = *param; + DIRTY(fb->end, g->neg_bitid); + break; + case GL_FOG_INDEX: + f->index = (GLint) *param; + DIRTY(fb->index, g->neg_bitid); + break; + case GL_FOG_COLOR: + f->color.r = param[0]; + f->color.g = param[1]; + f->color.b = param[2]; + f->color.a = param[3]; + DIRTY(fb->color, g->neg_bitid); + break; +#ifdef CR_NV_fog_distance + case GL_FOG_DISTANCE_MODE_NV: + if (g->extensions.NV_fog_distance) + { + if (param[0] != GL_EYE_RADIAL_NV && + param[0] != GL_EYE_PLANE && + param[0] != GL_EYE_PLANE_ABSOLUTE_NV ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "Fogfv: GL_FOG_DISTANCE_MODE_NV called with illegal parameter: 0x%x", (GLenum) param[0]); + return; + } + f->fogDistanceMode = (GLenum) param[0]; + DIRTY(fb->fogDistanceMode, g->neg_bitid); + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param); + return; + } + break; +#endif +#ifdef CR_EXT_fog_coord + case GL_FOG_COORDINATE_SOURCE_EXT: + if (g->extensions.EXT_fog_coord) + { + if ((GLenum) param[0] != GL_FOG_COORDINATE_EXT && + (GLenum) param[0] != GL_FRAGMENT_DEPTH_EXT) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "Fogfv: GL_FOG_COORDINATE_SOURCE_EXT called with illegal parameter: 0x%x", (GLenum) param[0]); + return; + } + f->fogCoordinateSource = (GLenum) param[0]; + DIRTY(fb->fogCoordinateSource, g->neg_bitid); + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: 0x%x", (GLint) param[0]); + return; + } + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Invalid glFog Param: %d", param); + return; + } + DIRTY(fb->dirty, g->neg_bitid); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_fog.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_fog.txt new file mode 100644 index 00000000..d8e62c0e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_fog.txt @@ -0,0 +1,13 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enable:enable:GL_FOG +:color:color|r,g,b,a:Fogfv,GL_FOG_COLOR +:index:index:Fogi,GL_FOG_INDEX +:density:density:Fogf,GL_FOG_DENSITY +:start:start:Fogf,GL_FOG_START +:end:end:Fogf,GL_FOG_END +:mode:mode:Fogi,GL_FOG_MODE +:fogDistanceMode:fogDistanceMode:Fogi,GL_FOG_DISTANCE_MODE_NV +:fogCoordinateSource:fogCoordinateSource:Fogi,GL_FOG_COORDINATE_SOURCE_EXT diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c new file mode 100644 index 00000000..c82d53a3 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_framebuffer.c @@ -0,0 +1,1202 @@ +/* $Id: state_framebuffer.c $ */ + +/** @file + * VBox OpenGL: EXT_framebuffer_object state tracking + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" +#include "state_internals.h" +#include "cr_mem.h" + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferObjectInit(CRContext *ctx) +{ + CRFramebufferObjectState *fbo = &ctx->framebufferobject; + + fbo->readFB = NULL; + fbo->drawFB = NULL; + fbo->renderbuffer = NULL; + ctx->shared->bFBOResyncNeeded = GL_FALSE; +} + +void STATE_APIENTRY crStateGenFramebuffersEXT(GLsizei n, GLuint *buffers) +{ + CRContext *g = GetCurrentContext(); + crStateGenNames(g, g->shared->fbTable, n, buffers); +} + +void STATE_APIENTRY crStateGenRenderbuffersEXT(GLsizei n, GLuint *buffers) +{ + CRContext *g = GetCurrentContext(); + crStateGenNames(g, g->shared->rbTable, n, buffers); +} + +void crStateRegFramebuffers(GLsizei n, GLuint *buffers) +{ + CRContext *g = GetCurrentContext(); + crStateRegNames(g, g->shared->fbTable, n, buffers); +} + +void crStateRegRenderbuffers(GLsizei n, GLuint *buffers) +{ + CRContext *g = GetCurrentContext(); + crStateRegNames(g, g->shared->rbTable, n, buffers); +} + +static void crStateInitFrameBuffer(CRFramebufferObject *fbo); + +static CRFramebufferObject * +crStateFramebufferAllocate(CRContext *ctx, GLuint name) +{ + CRFramebufferObject *buffer = (CRFramebufferObject*) crCalloc(sizeof(CRFramebufferObject)); + CRSTATE_CHECKERR_RET(!buffer, GL_OUT_OF_MEMORY, "crStateFramebufferAllocate", NULL); + buffer->id = name; +#ifndef IN_GUEST + diff_api.GenFramebuffersEXT(1, &buffer->hwid); + if (!buffer->hwid) + { + crWarning("GenFramebuffersEXT failed!"); + crFree(buffer); + return NULL; + } +#else + buffer->hwid = name; +#endif + + crStateInitFrameBuffer(buffer); + crHashtableAdd(ctx->shared->fbTable, name, buffer); + CR_STATE_SHAREDOBJ_USAGE_INIT(buffer); + + return buffer; +} + +static CRRenderbufferObject * +crStateRenderbufferAllocate(CRContext *ctx, GLuint name) +{ + CRRenderbufferObject *buffer = (CRRenderbufferObject*) crCalloc(sizeof(CRRenderbufferObject)); + CRSTATE_CHECKERR_RET(!buffer, GL_OUT_OF_MEMORY, "crStateRenderbufferAllocate", NULL); + buffer->id = name; +#ifndef IN_GUEST + diff_api.GenRenderbuffersEXT(1, &buffer->hwid); + if (!buffer->hwid) + { + crWarning("GenRenderbuffersEXT failed!"); + crFree(buffer); + return NULL; + } +#else + buffer->hwid = name; +#endif + + buffer->internalformat = GL_RGBA; + crHashtableAdd(ctx->shared->rbTable, name, buffer); + CR_STATE_SHAREDOBJ_USAGE_INIT(buffer); + + return buffer; +} + +void crStateFreeFBO(void *data) +{ + CRFramebufferObject *pObj = (CRFramebufferObject *)data; + +#ifndef IN_GUEST + if (diff_api.DeleteFramebuffersEXT) + { + diff_api.DeleteFramebuffersEXT(1, &pObj->hwid); + } +#endif + + crFree(pObj); +} + +void crStateFreeRBO(void *data) +{ + CRRenderbufferObject *pObj = (CRRenderbufferObject *)data; + +#ifndef IN_GUEST + if (diff_api.DeleteRenderbuffersEXT) + { + diff_api.DeleteRenderbuffersEXT(1, &pObj->hwid); + } +#endif + + crFree(pObj); +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferObjectDestroy(CRContext *ctx) +{ + CRFramebufferObjectState *fbo = &ctx->framebufferobject; + + fbo->readFB = NULL; + fbo->drawFB = NULL; + fbo->renderbuffer = NULL; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateBindRenderbufferEXT(GLenum target, GLuint renderbuffer) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target"); + + if (renderbuffer) + { + fbo->renderbuffer = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, renderbuffer); + if (!fbo->renderbuffer) + { + CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->rbTable, renderbuffer), GL_INVALID_OPERATION, "name is not a renderbuffer"); + fbo->renderbuffer = crStateRenderbufferAllocate(g, renderbuffer); + } + CR_STATE_SHAREDOBJ_USAGE_SET(fbo->renderbuffer, g); + } + else fbo->renderbuffer = NULL; +} + +static void crStateCheckFBOAttachments(CRFramebufferObject *pFBO, GLuint rbo, GLenum target) +{ + CRFBOAttachmentPoint *ap; + int u; + + if (!pFBO) + return; + + for (u=0; ucolor[u]; + if (ap->type==GL_RENDERBUFFER_EXT && ap->name==rbo) + { + crStateFramebufferRenderbufferEXT(target, u+GL_COLOR_ATTACHMENT0_EXT, 0, 0); +#ifdef IN_GUEST + pFBO->status = GL_FRAMEBUFFER_UNDEFINED; +#endif + } + } + + ap = &pFBO->depth; + if (ap->type==GL_RENDERBUFFER_EXT && ap->name==rbo) + { + crStateFramebufferRenderbufferEXT(target, GL_DEPTH_ATTACHMENT_EXT, 0, 0); +#ifdef IN_GUEST + pFBO->status = GL_FRAMEBUFFER_UNDEFINED; +#endif + } + ap = &pFBO->stencil; + if (ap->type==GL_RENDERBUFFER_EXT && ap->name==rbo) + { + crStateFramebufferRenderbufferEXT(target, GL_STENCIL_ATTACHMENT_EXT, 0, 0); +#ifdef IN_GUEST + pFBO->status = GL_FRAMEBUFFER_UNDEFINED; +#endif + } +} + +static void ctStateRenderbufferRefsCleanup(CRContext *g, GLuint fboId, CRRenderbufferObject *rbo) +{ + CRFramebufferObjectState *fbo = &g->framebufferobject; + + if (fbo->renderbuffer==rbo) + { + fbo->renderbuffer = NULL; + } + + /* check the attachments of current framebuffers */ + crStateCheckFBOAttachments(fbo->readFB, fboId, GL_READ_FRAMEBUFFER); + crStateCheckFBOAttachments(fbo->drawFB, fboId, GL_DRAW_FRAMEBUFFER); + + CR_STATE_SHAREDOBJ_USAGE_CLEAR(rbo, g); +} + +DECLEXPORT(void) STATE_APIENTRY +crStateDeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers) +{ + CRContext *g = GetCurrentContext(); + /*CRFramebufferObjectState *fbo = &g->framebufferobject; - unused */ + int i; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0"); + + for (i = 0; i < n; i++) + { + if (renderbuffers[i]) + { + CRRenderbufferObject *rbo; + rbo = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, renderbuffers[i]); + if (rbo) + { + int j; + + ctStateRenderbufferRefsCleanup(g, renderbuffers[i], rbo); + CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(rbo, j) + { + /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, + * so on restore, we set mark bits as used. + * This is why g_pAvailableContexts[j] could be NULL + * also g_pAvailableContexts[0] will hold default context, which we should discard */ + CRContext *ctx = g_pAvailableContexts[j]; + if (j && ctx) + { + CRFramebufferObjectState *ctxFbo; + CRASSERT(ctx); + ctxFbo = &ctx->framebufferobject; + if (ctxFbo->renderbuffer==rbo) + crWarning("deleting RBO being used by another context %d", ctx->id); + + ctStateRenderbufferRefsCleanup(ctx, renderbuffers[i], rbo); + } + else + CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(rbo, j); + } + crHashtableDelete(g->shared->rbTable, renderbuffers[i], crStateFreeRBO); + } + } + } +} + +DECLEXPORT(void) STATE_APIENTRY +crStateRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRRenderbufferObject *rb = fbo->renderbuffer; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target"); + CRSTATE_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer"); + + rb->width = width; + rb->height = height; + rb->internalformat = internalformat; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRRenderbufferObject *rb = fbo->renderbuffer; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(target!=GL_RENDERBUFFER_EXT, GL_INVALID_ENUM, "invalid target"); + CRSTATE_CHECKERR(!rb, GL_INVALID_OPERATION, "no bound renderbuffer"); + + switch (pname) + { + case GL_RENDERBUFFER_WIDTH_EXT: + *params = rb->width; + break; + case GL_RENDERBUFFER_HEIGHT_EXT: + *params = rb->height; + break; + case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT: + *params = rb->internalformat; + break; + case GL_RENDERBUFFER_RED_SIZE_EXT: + case GL_RENDERBUFFER_GREEN_SIZE_EXT: + case GL_RENDERBUFFER_BLUE_SIZE_EXT: + case GL_RENDERBUFFER_ALPHA_SIZE_EXT: + case GL_RENDERBUFFER_DEPTH_SIZE_EXT: + case GL_RENDERBUFFER_STENCIL_SIZE_EXT: + CRSTATE_CHECKERR(GL_TRUE, GL_INVALID_OPERATION, "unimplemented"); + break; + default: + CRSTATE_CHECKERR(GL_TRUE, GL_INVALID_ENUM, "invalid pname"); + } +} + +static void crStateInitFBOAttachmentPoint(CRFBOAttachmentPoint *fboap) +{ + fboap->type = GL_NONE; + fboap->name = 0; + fboap->level = 0; + fboap->face = GL_TEXTURE_CUBE_MAP_POSITIVE_X; + fboap->zoffset = 0; +} + +static void crStateInitFrameBuffer(CRFramebufferObject *fbo) +{ + int i; + + for (i=0; icolor[i]); + + crStateInitFBOAttachmentPoint(&fbo->depth); + crStateInitFBOAttachmentPoint(&fbo->stencil); + + fbo->readbuffer = GL_COLOR_ATTACHMENT0_EXT; + fbo->drawbuffer[0] = GL_COLOR_ATTACHMENT0_EXT; + +#ifdef IN_GUEST + fbo->status = GL_FRAMEBUFFER_UNDEFINED; +#endif +} + +static GLboolean crStateGetFBOAttachmentPoint(CRFramebufferObject *fb, GLenum attachment, CRFBOAttachmentPoint **ap) +{ + switch (attachment) + { + case GL_DEPTH_ATTACHMENT_EXT: + *ap = &fb->depth; + break; + case GL_STENCIL_ATTACHMENT_EXT: + *ap = &fb->stencil; + break; + default: + if (attachment>=GL_COLOR_ATTACHMENT0_EXT && attachment<=GL_COLOR_ATTACHMENT15_EXT) + { + *ap = &fb->color[attachment-GL_COLOR_ATTACHMENT0_EXT]; + } + else return GL_FALSE; + } + + return GL_TRUE; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateBindFramebufferEXT(GLenum target, GLuint framebuffer) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRFramebufferObject *pFBO=NULL; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)), + GL_INVALID_ENUM, "invalid target"); + + if (framebuffer) + { + pFBO = (CRFramebufferObject*) crHashtableSearch(g->shared->fbTable, framebuffer); + if (!pFBO) + { + CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->fbTable, framebuffer), GL_INVALID_OPERATION, "name is not a framebuffer"); + pFBO = crStateFramebufferAllocate(g, framebuffer); + } + + + CR_STATE_SHAREDOBJ_USAGE_SET(pFBO, g); + } + + /** @todo http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt + * FBO status might change when binding a different FBO here...but I doubt it happens. + * So no status reset here until a proper check. + */ + + switch (target) + { + case GL_FRAMEBUFFER_EXT: + fbo->readFB = pFBO; + fbo->drawFB = pFBO; + break; + case GL_READ_FRAMEBUFFER: + fbo->readFB = pFBO; + break; + case GL_DRAW_FRAMEBUFFER: + fbo->drawFB = pFBO; + break; + } +} + +static void ctStateFramebufferRefsCleanup(CRContext *g, CRFramebufferObject *fb) +{ + CRFramebufferObjectState *fbo = &g->framebufferobject; + if (fbo->readFB==fb) + { + fbo->readFB = NULL; + } + if (fbo->drawFB==fb) + { + fbo->drawFB = NULL; + } + + CR_STATE_SHAREDOBJ_USAGE_CLEAR(fb, g); +} + +DECLEXPORT(void) STATE_APIENTRY +crStateDeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers) +{ + CRContext *g = GetCurrentContext(); + int i; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(n<0, GL_INVALID_OPERATION, "n<0"); + + for (i = 0; i < n; i++) + { + if (framebuffers[i]) + { + CRFramebufferObject *fb; + fb = (CRFramebufferObject*) crHashtableSearch(g->shared->fbTable, framebuffers[i]); + if (fb) + { + int j; + + ctStateFramebufferRefsCleanup(g, fb); + + CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(fb, j) + { + /* saved state version <= SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS does not have usage bits info, + * so on restore, we set mark bits as used. + * This is why g_pAvailableContexts[j] could be NULL + * also g_pAvailableContexts[0] will hold default context, which we should discard */ + CRContext *ctx = g_pAvailableContexts[j]; + if (j && ctx) + { + CRFramebufferObjectState *ctxFbo; + CRASSERT(ctx); + ctxFbo = &ctx->framebufferobject; + if (ctxFbo->readFB==fb) + crWarning("deleting FBO being used as read buffer by another context %d", ctx->id); + + if (ctxFbo->drawFB==fb) + crWarning("deleting FBO being used as draw buffer by another context %d", ctx->id); + + ctStateFramebufferRefsCleanup(ctx, fb); + } + else + CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX(fb, j); + } + crHashtableDelete(g->shared->fbTable, framebuffers[i], crStateFreeFBO); + } + } + } +} + +/** @todo move this function somewhere else*/ +/*return floor of base 2 log of x. log(0)==0*/ +static unsigned int crLog2Floor(unsigned int x) +{ + x |= (x >> 1); + x |= (x >> 2); + x |= (x >> 4); + x |= (x >> 8); + x |= (x >> 16); + x -= ((x >> 1) & 0x55555555); + x = (((x >> 2) & 0x33333333) + (x & 0x33333333)); + x = (((x >> 4) + x) & 0x0f0f0f0f); + x += (x >> 8); + x += (x >> 16); + return (x & 0x0000003f) - 1; +} + +static GLuint crStateFramebufferGet(CRFramebufferObjectState *fbo, GLenum target, CRFramebufferObject **apFBOs) +{ + /** @todo Since this function returns not more than one FBO, callers can be cleaned up. */ + GLuint cPBOs = 0; + switch (target) + { + case GL_READ_FRAMEBUFFER: + cPBOs = 1; + apFBOs[0] = fbo->readFB; + break; + /* OpenGL glFramebufferTexture, glFramebufferRenderbuffer, glFramebufferRenderbuffer specs: + * "GL_FRAMEBUFFER is equivalent to GL_DRAW_FRAMEBUFFER." + */ + case GL_FRAMEBUFFER: + case GL_DRAW_FRAMEBUFFER: + cPBOs = 1; + apFBOs[0] = fbo->drawFB; + break; + default: + crWarning("unexpected target value: 0x%x", target); + cPBOs = 0; + break; + } + + return cPBOs; +} + +static GLuint crStateFramebufferTextureCheck(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, + CRFBOAttachmentPoint **aap, CRTextureObj **tobj) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRFramebufferObject *apFBOs[2]; + GLuint cFBOs = 0, i; + GLuint maxtexsizelog2; + + CRSTATE_CHECKERR_RET(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end", 0); + CRSTATE_CHECKERR_RET(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)), + GL_INVALID_ENUM, "invalid target", 0); + + cFBOs = crStateFramebufferGet(fbo, target, apFBOs); + CRSTATE_CHECKERR_RET(!cFBOs, GL_INVALID_ENUM, "unexpected target", 0); + for (i = 0; i < cFBOs; ++i) + { + CRSTATE_CHECKERR_RET(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound", 0); + } + + Assert(cFBOs); + Assert(cFBOs <= 2); + + for (i = 0; i < cFBOs; ++i) + { + CRSTATE_CHECKERR_RET(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment", 0); + } + + if (!texture) + { + return cFBOs; + } + + switch (textarget) + { + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + maxtexsizelog2 = crLog2Floor(g->limits.maxCubeMapTextureSize); + *tobj = crStateTextureGet(GL_TEXTURE_CUBE_MAP_ARB, texture); + break; + case GL_TEXTURE_RECTANGLE_ARB: + maxtexsizelog2 = 0; + *tobj = crStateTextureGet(textarget, texture); + break; + case GL_TEXTURE_3D: + maxtexsizelog2 = crLog2Floor(g->limits.max3DTextureSize); + *tobj = crStateTextureGet(textarget, texture); + break; + case GL_TEXTURE_2D: + case GL_TEXTURE_1D: + maxtexsizelog2 = crLog2Floor(g->limits.maxTextureSize); + *tobj = crStateTextureGet(textarget, texture); + break; + default: + CRSTATE_CHECKERR_RET(GL_TRUE, GL_INVALID_OPERATION, "invalid textarget", 0); + } + + CRSTATE_CHECKERR_RET(!*tobj, GL_INVALID_OPERATION, "invalid textarget/texture combo", 0); + + if (GL_TEXTURE_RECTANGLE_ARB==textarget) + { + CRSTATE_CHECKERR_RET(level!=0, GL_INVALID_VALUE, "non zero mipmap level", 0); + } + + CRSTATE_CHECKERR_RET(level<0, GL_INVALID_VALUE, "level<0", 0); + CRSTATE_CHECKERR_RET((GLuint)level>maxtexsizelog2, GL_INVALID_VALUE, "level too big", 0); + +#ifdef IN_GUEST + for (i = 0; i < cFBOs; ++i) + { + if ((aap[i])->type!=GL_TEXTURE || (aap[i])->name!=texture || (aap[i])->level!=level) + { + apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED; + } + } +#endif + + Assert(cFBOs); + Assert(cFBOs <= 2); + + return cFBOs; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + CRContext *g = GetCurrentContext(); + /*CRFramebufferObjectState *fbo = &g->framebufferobject; - unused */ + CRFBOAttachmentPoint *aap[2]; + GLuint cap, i; + CRTextureObj *tobj; + + cap = crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, aap, &tobj); + if (!cap) return; + + if (!texture) + { + for (i = 0; i < cap; ++i) + { + crStateInitFBOAttachmentPoint(aap[i]); + } + return; + } + + CRSTATE_CHECKERR(textarget!=GL_TEXTURE_1D, GL_INVALID_OPERATION, "textarget"); + + CR_STATE_SHAREDOBJ_USAGE_SET(tobj, g); + + for (i = 0; i < cap; ++i) + { + crStateInitFBOAttachmentPoint(aap[i]); + aap[i]->type = GL_TEXTURE; + aap[i]->name = texture; + aap[i]->level = level; + } +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) +{ + CRContext *g = GetCurrentContext(); + /* CRFramebufferObjectState *fbo = &g->framebufferobject; - unused */ + CRFBOAttachmentPoint *aap[2]; + GLuint cap, i; + CRTextureObj *tobj; + + cap = crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, aap, &tobj); + if (!cap) return; + + if (!texture) + { + for (i = 0; i < cap; ++i) + { + crStateInitFBOAttachmentPoint(aap[i]); + } + return; + } + + CRSTATE_CHECKERR(GL_TEXTURE_1D==textarget || GL_TEXTURE_3D==textarget, GL_INVALID_OPERATION, "textarget"); + + CR_STATE_SHAREDOBJ_USAGE_SET(tobj, g); + + for (i = 0; i < cap; ++i) + { + crStateInitFBOAttachmentPoint(aap[i]); + aap[i]->type = GL_TEXTURE; + aap[i]->name = texture; + aap[i]->level = level; + if (textarget!=GL_TEXTURE_2D && textarget!=GL_TEXTURE_RECTANGLE_ARB) + { + aap[i]->face = textarget; + } + } +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset) +{ + CRContext *g = GetCurrentContext(); + /* CRFramebufferObjectState *fbo = &g->framebufferobject; - unused */ + CRFBOAttachmentPoint *aap[2]; + GLuint cap, i; + CRTextureObj *tobj; + + cap = crStateFramebufferTextureCheck(target, attachment, textarget, texture, level, aap, &tobj); + if (!cap) return; + + if (!texture) + { + for (i = 0; i < cap; ++i) + { + crStateInitFBOAttachmentPoint(aap[i]); + } + return; + } + + CRSTATE_CHECKERR(zoffset>((GLint)g->limits.max3DTextureSize-1), GL_INVALID_VALUE, "zoffset too big"); + CRSTATE_CHECKERR(textarget!=GL_TEXTURE_3D, GL_INVALID_OPERATION, "textarget"); + + CR_STATE_SHAREDOBJ_USAGE_SET(tobj, g); + + for (i = 0; i < cap; ++i) + { + crStateInitFBOAttachmentPoint(aap[i]); + aap[i]->type = GL_TEXTURE; + aap[i]->name = texture; + aap[i]->level = level; + aap[i]->zoffset = zoffset; + } +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRFramebufferObject *apFBOs[2]; + GLuint cFBOs, i; + CRFBOAttachmentPoint *aap[2]; + CRRenderbufferObject *rb; + (void)renderbuffertarget; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)), + GL_INVALID_ENUM, "invalid target"); + cFBOs = crStateFramebufferGet(fbo, target, apFBOs); + CRSTATE_CHECKERR(!cFBOs, GL_INVALID_OPERATION, "no fbo bound"); + for (i = 0; i < cFBOs; ++i) + { + CRSTATE_CHECKERR(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound"); + } + + for (i = 0; i < cFBOs; ++i) + { + CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &aap[i]), GL_INVALID_ENUM, "invalid attachment"); + } + + if (!renderbuffer) + { + for (i = 0; i < cFBOs; ++i) + { +#ifdef IN_GUEST + if (&aap[i]->type!=GL_NONE) + { + apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED; + } +#endif + crStateInitFBOAttachmentPoint(aap[i]); + } + return; + } + + rb = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, renderbuffer); + if (!rb) + { + CRSTATE_CHECKERR(!crHashtableIsKeyUsed(g->shared->rbTable, renderbuffer), GL_INVALID_OPERATION, "rb doesn't exist"); + rb = crStateRenderbufferAllocate(g, renderbuffer); + } + + CR_STATE_SHAREDOBJ_USAGE_SET(rb, g); + + for (i = 0; i < cFBOs; ++i) + { +#ifdef IN_GUEST + if (aap[i]->type!=GL_RENDERBUFFER_EXT || aap[i]->name!=renderbuffer) + { + apFBOs[i]->status = GL_FRAMEBUFFER_UNDEFINED; + } +#endif + crStateInitFBOAttachmentPoint(aap[i]); + aap[i]->type = GL_RENDERBUFFER_EXT; + aap[i]->name = renderbuffer; + } +} + +DECLEXPORT(void) STATE_APIENTRY +crStateGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRFramebufferObject *apFBOs[2]; + GLint cFBOs = 0, i; + CRFBOAttachmentPoint *ap; + + CRSTATE_CHECKERR(g->current.inBeginEnd, GL_INVALID_OPERATION, "called in begin/end"); + CRSTATE_CHECKERR(((target!=GL_FRAMEBUFFER_EXT) && (target!=GL_READ_FRAMEBUFFER) && (target!=GL_DRAW_FRAMEBUFFER)), + GL_INVALID_ENUM, "invalid target"); + + cFBOs = crStateFramebufferGet(fbo, target, apFBOs); + + CRSTATE_CHECKERR(!cFBOs, GL_INVALID_OPERATION, "no fbo bound"); + for (i = 0; i < cFBOs; ++i) + { + CRSTATE_CHECKERR(!apFBOs[i], GL_INVALID_OPERATION, "zero fbo bound"); + } + + if(cFBOs != 1) + { + crWarning("different FBPs attached to draw and read buffers, returning info for the read buffer"); + } + + for (i = 0; i < 1; ++i) + { + CRSTATE_CHECKERR(!crStateGetFBOAttachmentPoint(apFBOs[i], attachment, &ap), GL_INVALID_ENUM, "invalid attachment"); + + switch (pname) + { + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT: + *params = ap->type; + break; + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT: + CRSTATE_CHECKERR(ap->type!=GL_RENDERBUFFER_EXT && ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "can't query object name when it's not bound") + *params = ap->name; + break; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT: + CRSTATE_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture"); + *params = ap->level; + break; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT: + CRSTATE_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture"); + *params = ap->face; + break; + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT: + CRSTATE_CHECKERR(ap->type!=GL_TEXTURE, GL_INVALID_ENUM, "not a texture"); + *params = ap->zoffset; + break; + default: + CRSTATE_CHECKERR(GL_TRUE, GL_INVALID_ENUM, "invalid pname"); + } + } +} + +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsFramebufferEXT( GLuint framebuffer ) +{ + CRContext *g = GetCurrentContext(); + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glIsFramebufferEXT called in begin/end"); + return GL_FALSE; + } + + return framebuffer ? crHashtableIsKeyUsed(g->shared->fbTable, framebuffer) : GL_FALSE; +} + +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsRenderbufferEXT( GLuint renderbuffer ) +{ + CRContext *g = GetCurrentContext(); + + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glIsRenderbufferEXT called in begin/end"); + return GL_FALSE; + } + + return renderbuffer ? crHashtableIsKeyUsed(g->shared->rbTable, renderbuffer) : GL_FALSE; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateGenerateMipmapEXT(GLenum target) +{ + (void)target; + /** @todo */ +} + +static void crStateSyncRenderbuffersCB(unsigned long key, void *data1, void *data2) +{ + CRRenderbufferObject *pRBO = (CRRenderbufferObject*) data1; + (void)key; (void)data2; + + diff_api.GenRenderbuffersEXT(1, &pRBO->hwid); + + if (pRBO->width && pRBO->height) + { + diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, pRBO->hwid); + diff_api.RenderbufferStorageEXT(GL_RENDERBUFFER_EXT, pRBO->internalformat, pRBO->width, pRBO->height); + } +} + +static void crStateSyncAP(CRFBOAttachmentPoint *pAP, GLenum ap, CRContext *ctx) +{ + CRRenderbufferObject *pRBO; + CRTextureObj *tobj; + + switch (pAP->type) + { + case GL_TEXTURE: + CRASSERT(pAP->name!=0); + + tobj = (CRTextureObj *) crHashtableSearch(ctx->shared->textureTable, pAP->name); + if (tobj) + { + CRASSERT(!tobj->id || tobj->hwid); + + switch (tobj->target) + { + case GL_TEXTURE_1D: + diff_api.FramebufferTexture1DEXT(GL_FRAMEBUFFER_EXT, ap, tobj->target, crStateGetTextureObjHWID(tobj), pAP->level); + break; + case GL_TEXTURE_2D: + case GL_TEXTURE_RECTANGLE_ARB: + diff_api.FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ap, tobj->target, crStateGetTextureObjHWID(tobj), pAP->level); + break; + case GL_TEXTURE_CUBE_MAP_ARB: + diff_api.FramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, ap, pAP->face, crStateGetTextureObjHWID(tobj), pAP->level); + break; + case GL_TEXTURE_3D: + diff_api.FramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, ap, tobj->target, crStateGetTextureObjHWID(tobj), pAP->level, pAP->zoffset); + break; + default: + crWarning("Unexpected textarget %d", tobj->target); + } + } + else + { + crWarning("Unknown texture id %d", pAP->name); + } + break; + case GL_RENDERBUFFER_EXT: + pRBO = (CRRenderbufferObject*) crHashtableSearch(ctx->shared->rbTable, pAP->name); + diff_api.FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, ap, GL_RENDERBUFFER_EXT, pRBO->hwid); + break; + case GL_NONE: + /* Intentionally left blank */ + break; + default: crWarning("Invalid attachment point type %d (ap: %i)", pAP->type, ap); + } +} + +static void crStateSyncFramebuffersCB(unsigned long key, void *data1, void *data2) +{ + CRFramebufferObject *pFBO = (CRFramebufferObject*) data1; + CRContext *ctx = (CRContext*) data2; + GLint i; + (void)key; + + diff_api.GenFramebuffersEXT(1, &pFBO->hwid); + + diff_api.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, pFBO->hwid); + + for (i=0; icolor[i], GL_COLOR_ATTACHMENT0_EXT+i, ctx); + } + + crStateSyncAP(&pFBO->depth, GL_DEPTH_ATTACHMENT_EXT, ctx); + crStateSyncAP(&pFBO->stencil, GL_STENCIL_ATTACHMENT_EXT, ctx); +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferObjectSwitch(CRContext *from, CRContext *to) +{ + if (to->shared->bFBOResyncNeeded) + { + to->shared->bFBOResyncNeeded = GL_FALSE; + + crHashtableWalk(to->shared->rbTable, crStateSyncRenderbuffersCB, NULL); + crHashtableWalk(to->shared->fbTable, crStateSyncFramebuffersCB, to); + + if (to->framebufferobject.drawFB==to->framebufferobject.readFB) + { + diff_api.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, to->framebufferobject.drawFB? + to->framebufferobject.drawFB->hwid:0); + } + else + { + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, to->framebufferobject.drawFB? + to->framebufferobject.drawFB->hwid:0); + + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, to->framebufferobject.readFB? + to->framebufferobject.readFB->hwid:0); + } + + diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, to->framebufferobject.renderbuffer? + to->framebufferobject.renderbuffer->hwid:0); + } + else + { + if (to->framebufferobject.drawFB!=from->framebufferobject.drawFB + || to->framebufferobject.readFB!=from->framebufferobject.readFB) + { + if (to->framebufferobject.drawFB==to->framebufferobject.readFB) + { + diff_api.BindFramebufferEXT(GL_FRAMEBUFFER_EXT, to->framebufferobject.drawFB? + to->framebufferobject.drawFB->hwid:0); + } + else + { + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, to->framebufferobject.drawFB? + to->framebufferobject.drawFB->hwid:0); + + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, to->framebufferobject.readFB? + to->framebufferobject.readFB->hwid:0); + } + + diff_api.DrawBuffer(to->framebufferobject.drawFB?to->framebufferobject.drawFB->drawbuffer[0]:to->buffer.drawBuffer); + diff_api.ReadBuffer(to->framebufferobject.readFB?to->framebufferobject.readFB->readbuffer:to->buffer.readBuffer); + } + + if (to->framebufferobject.renderbuffer!=from->framebufferobject.renderbuffer) + { + diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, to->framebufferobject.renderbuffer? + to->framebufferobject.renderbuffer->hwid:0); + } + } +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferObjectDisableHW(CRContext *ctx, GLuint idDrawFBO, GLuint idReadFBO) +{ + GLenum idDrawBuffer = 0, idReadBuffer = 0; + + if (ctx->framebufferobject.drawFB || idDrawFBO) + { + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); + idDrawBuffer = ctx->buffer.drawBuffer; + } + + if (ctx->framebufferobject.readFB || idReadFBO) + { + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, 0); + idReadBuffer = ctx->buffer.readBuffer; + } + + if (idDrawBuffer) + diff_api.DrawBuffer(idDrawBuffer); + if (idReadBuffer) + diff_api.ReadBuffer(idReadBuffer); + + if (ctx->framebufferobject.renderbuffer) + diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); +} + +DECLEXPORT(void) STATE_APIENTRY +crStateFramebufferObjectReenableHW(CRContext *fromCtx, CRContext *toCtx, GLuint idDrawFBO, GLuint idReadFBO) +{ + GLuint idReadBuffer = 0, idDrawBuffer = 0; + if (!fromCtx) + fromCtx = toCtx; /* <- in case fromCtx is zero, set it to toCtx to ensure framebuffer state gets re-enabled correctly */ + + if ((fromCtx->framebufferobject.drawFB) /* <- the FBO state was reset in crStateFramebufferObjectDisableHW */ + && fromCtx->framebufferobject.drawFB == toCtx->framebufferobject.drawFB) /* .. and it was NOT restored properly in crStateFramebufferObjectSwitch */ + { + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, toCtx->framebufferobject.drawFB->hwid); + idDrawBuffer = toCtx->framebufferobject.drawFB->drawbuffer[0]; + } + else if (idDrawFBO && !toCtx->framebufferobject.drawFB) + { + diff_api.BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, idDrawFBO); + idDrawBuffer = GL_COLOR_ATTACHMENT0; + } + + if ((fromCtx->framebufferobject.readFB) /* <- the FBO state was reset in crStateFramebufferObjectDisableHW */ + && fromCtx->framebufferobject.readFB == toCtx->framebufferobject.readFB) /* .. and it was NOT restored properly in crStateFramebufferObjectSwitch */ + { + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, toCtx->framebufferobject.readFB->hwid); + idReadBuffer = toCtx->framebufferobject.readFB->readbuffer; + } + else if (idReadFBO && !toCtx->framebufferobject.readFB) + { + diff_api.BindFramebufferEXT(GL_READ_FRAMEBUFFER, idReadFBO); + idReadBuffer = GL_COLOR_ATTACHMENT0; + } + + if (idDrawBuffer) + diff_api.DrawBuffer(idDrawBuffer); + if (idReadBuffer) + diff_api.ReadBuffer(idReadBuffer); + + if (fromCtx->framebufferobject.renderbuffer /* <- the FBO state was reset in crStateFramebufferObjectDisableHW */ + && fromCtx->framebufferobject.renderbuffer==toCtx->framebufferobject.renderbuffer) /* .. and it was NOT restored properly in crStateFramebufferObjectSwitch */ + { + diff_api.BindRenderbufferEXT(GL_RENDERBUFFER_EXT, toCtx->framebufferobject.renderbuffer->hwid); + } +} + + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetFramebufferHWID(GLuint id) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObject *pFBO = (CRFramebufferObject*) crHashtableSearch(g->shared->fbTable, id); +#if 0 /*def DEBUG_misha*/ + crDebug("FB id(%d) hw(%d)", id, pFBO ? pFBO->hwid : 0); +#endif + return pFBO ? pFBO->hwid : 0; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetRenderbufferHWID(GLuint id) +{ + CRContext *g = GetCurrentContext(); + CRRenderbufferObject *pRBO = (CRRenderbufferObject*) crHashtableSearch(g->shared->rbTable, id); + + return pRBO ? pRBO->hwid : 0; +} + +static void crStateCheckFBOHWIDCB(unsigned long key, void *data1, void *data2) +{ + CRFramebufferObject *pFBO = (CRFramebufferObject *) data1; + crCheckIDHWID_t *pParms = (crCheckIDHWID_t*) data2; + (void) key; + + if (pFBO->hwid==pParms->hwid) + pParms->id = pFBO->id; +} + +static void crStateCheckRBOHWIDCB(unsigned long key, void *data1, void *data2) +{ + CRRenderbufferObject *pRBO = (CRRenderbufferObject *) data1; + crCheckIDHWID_t *pParms = (crCheckIDHWID_t*) data2; + (void) key; + + if (pRBO->hwid==pParms->hwid) + pParms->id = pRBO->id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateFBOHWIDtoID(GLuint hwid) +{ + CRContext *g = GetCurrentContext(); + crCheckIDHWID_t parms; + + parms.id = hwid; + parms.hwid = hwid; + + crHashtableWalk(g->shared->fbTable, crStateCheckFBOHWIDCB, &parms); + return parms.id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateRBOHWIDtoID(GLuint hwid) +{ + CRContext *g = GetCurrentContext(); + crCheckIDHWID_t parms; + + parms.id = hwid; + parms.hwid = hwid; + + crHashtableWalk(g->shared->rbTable, crStateCheckRBOHWIDCB, &parms); + return parms.id; +} + +#ifdef IN_GUEST +DECLEXPORT(GLenum) STATE_APIENTRY crStateCheckFramebufferStatusEXT(GLenum target) +{ + GLenum status = GL_FRAMEBUFFER_UNDEFINED; + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRFramebufferObject *pFBO=NULL; + + switch (target) + { + case GL_FRAMEBUFFER_EXT: + pFBO = fbo->drawFB; + break; + case GL_READ_FRAMEBUFFER: + pFBO = fbo->readFB; + break; + case GL_DRAW_FRAMEBUFFER: + pFBO = fbo->drawFB; + break; + } + + if (pFBO) status = pFBO->status; + + return status; +} + +DECLEXPORT(GLenum) STATE_APIENTRY crStateSetFramebufferStatus(GLenum target, GLenum status) +{ + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRFramebufferObject *pFBO=NULL; + + switch (target) + { + case GL_FRAMEBUFFER_EXT: + pFBO = fbo->drawFB; + break; + case GL_READ_FRAMEBUFFER: + pFBO = fbo->readFB; + break; + case GL_DRAW_FRAMEBUFFER: + pFBO = fbo->drawFB; + break; + } + + if (pFBO) pFBO->status = status; + + return status; +} +#endif diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py new file mode 100755 index 00000000..ebf1b379 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_funcs.py @@ -0,0 +1,62 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + + +from __future__ import print_function +import sys + +sys.path.append( "../glapi_parser" ) +import apiutil + + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY state_funcs.py SCRIPT */ +#ifndef CR_STATE_FUNCS_H +#define CR_STATE_FUNCS_H + +#include "chromium.h" +#include "cr_error.h" + +#include + +#if defined(WINDOWS) +#define STATE_APIENTRY __stdcall +#else +#define STATE_APIENTRY +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#define STATE_UNUSED(x) ((void)x)""") + + + +for func_name in apiutil.AllSpecials( "state" ): + return_type = apiutil.ReturnType(func_name) + params = apiutil.Parameters(func_name) + print('DECLEXPORT(%s) STATE_APIENTRY crState%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params))) + +for func_name in apiutil.AllSpecials( "state_feedback" ): + return_type = apiutil.ReturnType(func_name) + params = apiutil.Parameters(func_name) + print('DECLEXPORT(%s) STATE_APIENTRY crStateFeedback%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params))) + +for func_name in apiutil.AllSpecials( "state_select" ): + return_type = apiutil.ReturnType(func_name) + params = apiutil.Parameters(func_name) + print('DECLEXPORT(%s) STATE_APIENTRY crStateSelect%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params))) + + +print(""" +#ifdef __cplusplus +} +#endif + +#endif /* CR_STATE_FUNCS_H */ +""") diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py new file mode 100755 index 00000000..d5238c45 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_get.py @@ -0,0 +1,234 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys, re, string +import apiutil + +line_re = re.compile (r'^(\S+)\s+(GL_\S+)\s+(.*)\s*$') +extensions_line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s+(GL_\S+)\s+(.*)\s*$') + +params = {} +extended_params = {} + +input = open( sys.argv[2]+"/state_get.txt", 'r' ) +for line in input.readlines(): + if line[0] == '#': + continue + match = line_re.match( line ) + if match: + type = match.group(1) + pname = match.group(2) + fields = match.group(3).split() + params[pname] = ( type, fields ) + +input = open( sys.argv[2]+"/state_extensions_get.txt", 'r' ) +for line in input.readlines(): + if line[0] == '#': + continue + match = extensions_line_re.match( line ) + if match: + type = match.group(1) + pname = match.group(2) + ifdef = match.group(3) + fields = match.group(4).split() + extended_params[pname] = ( type, ifdef, fields ) + +convert = { + 'GLenum' : { + 'Boolean' : '(GLboolean) (%s != 0)', + 'Double' : '(GLdouble) %s', + 'Float' : '(GLfloat) %s', + 'Integer' : '(GLint) %s' + }, + 'GLboolean' : { + 'Boolean' : '(GLboolean) (%s != 0)', + 'Double' : '(GLdouble) %s', + 'Float' : '(GLfloat) %s', + 'Integer' : '(GLint) %s' + }, + 'GLint' : { + 'Boolean' : '(GLboolean) (%s != 0)', + 'Double' : '(GLdouble) %s', + 'Float' : '(GLfloat) %s', + 'Integer' : '(GLint) %s' + }, + 'GLuint' : { + 'Boolean' : '(GLboolean) (%s != 0)', + 'Double' : '(GLdouble) %s', + 'Float' : '(GLfloat) %s', + 'Integer' : '(GLint) %s' + }, + 'GLfloat' : { + 'Boolean' : '(GLboolean) (%s != 0.0f)', + 'Double' : '(GLdouble) %s', + 'Float' : '%s', + 'Integer' : '(GLint) %s' + }, + 'GLdouble' : { + 'Boolean' : '(GLboolean) (%s != 0.0)', + 'Double' : '%s', + 'Float' : '(GLfloat) %s', + 'Integer' : '(GLint) %s' + }, + 'GLdefault' : { + 'Boolean' : '(GLboolean) (%s != (GLdefault) 0.0)', + 'Double' : '(GLdouble) %s', + 'Float' : '(GLfloat) %s', + 'Integer' : '(GLint) %s' + }, + 'GLclampd' : { + 'Boolean' : '(GLboolean) (%s != 0.0)', + 'Double' : '%s', + 'Float' : '(GLfloat) %s', + 'Integer' : '__clampd_to_int(%s)' + }, + 'GLclampf' : { + 'Boolean' : '(GLboolean) (%s != 0.0f)', + 'Double' : '(GLdouble) %s', + 'Float' : '%s', + 'Integer' : '__clampf_to_int(%s)' + } + } + +types = [ "Boolean", "Double", "Float", "Integer" ] + +ctypes = { + 'Boolean' : 'GLboolean', + 'Double' : 'GLdouble', + 'Float' : 'GLfloat', + 'Integer' : 'GLint' + } + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE GENERATED BY state_get.txt AND THE state_get.py SCRIPT */ +#include +#include + +#include "state.h" +#include "state/cr_statetypes.h" + +static GLint __clampd_to_int(GLdouble d) +{ + /* -1.0 -> MIN_INT, 1.0 -> MAX_INT */ + if (d > 1.0) + return 0x7fffffff; + if (d < -1.0) + return 0x80000000; + return (GLint) floor(d * 2147483647.5); +} + +static GLint __clampf_to_int(GLfloat f) +{ + /* -1.0f -> MIN_INT, 1.0f -> MAX_INT */ + if (f > 1.0f) + return 0x7fffffff; + if (f < -1.0f) + return 0x80000000; + return (GLint) floor(f * 2147483647.5f); +} + +static GLenum __getDrawBuffer(CRContext *g) +{ + return g->framebufferobject.drawFB ? g->framebufferobject.drawFB->drawbuffer[0] : g->buffer.drawBuffer; +} + +static GLenum __getReadBuffer(CRContext *g) +{ + return g->framebufferobject.readFB ? g->framebufferobject.readFB->readbuffer : g->buffer.readBuffer; +} +""") + +header = """ +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGet called in Begin/End"); + return; + } + + if (pname == GL_CURRENT_INDEX || pname == GL_CURRENT_COLOR || + pname == GL_CURRENT_SECONDARY_COLOR_EXT || + pname == GL_CURRENT_FOG_COORDINATE_EXT || + pname == GL_CURRENT_NORMAL || pname == GL_EDGE_FLAG || + pname == GL_CURRENT_TEXTURE_COORDS ) + { +#if 0 + crStateError(__LINE__,__FILE__, GL_INVALID_OPERATION, + "Unimplemented glGet of a 'current' value" ); +#else + crStateCurrentRecover();/* &g->current, &sb->current, g->bitID );*/ + +#endif + } + + switch (pname) { +""" + +for rettype in types: + print('') + print('void STATE_APIENTRY crStateGet%sv( GLenum pname, %s *params )' % ( rettype, ctypes[rettype] )) + print(header) + + for pname in sorted(params.keys()): + print('\t\tcase %s:' % pname) + (srctype,fields) = params[pname] + try: + cvt = convert[srctype][rettype] + i = 0 + for field in fields: + expr = cvt % field + print('\t\t\tparams[%d] = %s;' % (i,expr)) + i += 1 + except: + print('\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");') + print("\t\t\tbreak;") + + + for pname in sorted(extended_params.keys()): + (srctype,ifdef,fields) = extended_params[pname] + ext = ifdef[3:] # the extension name with the "GL_" prefix removed + #print '#ifdef %s' % ifdef + print('#ifdef CR_%s' % ext) + print('\t\tcase %s:' % pname) + if ext != 'OPENGL_VERSION_1_2': + print('\t\t\tif (g->extensions.%s) {' % ext) + try: + cvt = convert[srctype][rettype] + i = 0 + for field in fields: + expr = cvt % field + if field[0] == '%': + command = string.split(field, '%') + print('\t\t\t\t%s;' % command[1]) + continue + elif ext != 'OPENGL_VERSION_1_2': + print('\t\t\t\tparams[%d] = %s;' % (i,expr)) + else: + print('\t\t\tparams[%d] = %s;' % (i,expr)) + i += 1 + except: + print('\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented glGet!");') + if ext != 'OPENGL_VERSION_1_2': + print("\t\t\t}") + print("\t\t\telse {") + print('\t\t\t\tcrStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "glGet%sv");' % rettype) + print("\t\t\t}") + print("\t\t\tbreak;") + #print '#endif /* %s */' % ifdef + print('#endif /* CR_%s */' % ext) + + print('\t\tdefault:') + print('\t\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGet: Unknown enum: 0x%x", pname);') + print('\t\t\treturn;') + print('\t}') + print('}') + +from get_components import * diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_get.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_get.txt new file mode 100644 index 00000000..150d350b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_get.txt @@ -0,0 +1,319 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +GLenum GL_MATRIX_MODE g->transform.matrixMode +GLint GL_MODELVIEW_STACK_DEPTH g->transform.modelViewStack.depth+1 +GLint GL_PROJECTION_STACK_DEPTH g->transform.projectionStack.depth+1 +GLint GL_TEXTURE_STACK_DEPTH g->transform.textureStack[g->texture.curTextureUnit].depth+1 +GLint GL_COLOR_MATRIX_STACK_DEPTH g->transform.colorStack.depth+1 +GLdefault GL_MODELVIEW_MATRIX g->transform.modelViewStack.top->m00 g->transform.modelViewStack.top->m01 g->transform.modelViewStack.top->m02 g->transform.modelViewStack.top->m03 g->transform.modelViewStack.top->m10 g->transform.modelViewStack.top->m11 g->transform.modelViewStack.top->m12 g->transform.modelViewStack.top->m13 g->transform.modelViewStack.top->m20 g->transform.modelViewStack.top->m21 g->transform.modelViewStack.top->m22 g->transform.modelViewStack.top->m23 g->transform.modelViewStack.top->m30 g->transform.modelViewStack.top->m31 g->transform.modelViewStack.top->m32 g->transform.modelViewStack.top->m33 +GLdefault GL_PROJECTION_MATRIX g->transform.projectionStack.top->m00 g->transform.projectionStack.top->m01 g->transform.projectionStack.top->m02 g->transform.projectionStack.top->m03 g->transform.projectionStack.top->m10 g->transform.projectionStack.top->m11 g->transform.projectionStack.top->m12 g->transform.projectionStack.top->m13 g->transform.projectionStack.top->m20 g->transform.projectionStack.top->m21 g->transform.projectionStack.top->m22 g->transform.projectionStack.top->m23 g->transform.projectionStack.top->m30 g->transform.projectionStack.top->m31 g->transform.projectionStack.top->m32 g->transform.projectionStack.top->m33 +GLdefault GL_TEXTURE_MATRIX g->transform.textureStack[g->texture.curTextureUnit].top->m00 g->transform.textureStack[g->texture.curTextureUnit].top->m01 g->transform.textureStack[g->texture.curTextureUnit].top->m02 g->transform.textureStack[g->texture.curTextureUnit].top->m03 g->transform.textureStack[g->texture.curTextureUnit].top->m10 g->transform.textureStack[g->texture.curTextureUnit].top->m11 g->transform.textureStack[g->texture.curTextureUnit].top->m12 g->transform.textureStack[g->texture.curTextureUnit].top->m13 g->transform.textureStack[g->texture.curTextureUnit].top->m20 g->transform.textureStack[g->texture.curTextureUnit].top->m21 g->transform.textureStack[g->texture.curTextureUnit].top->m22 g->transform.textureStack[g->texture.curTextureUnit].top->m23 g->transform.textureStack[g->texture.curTextureUnit].top->m30 g->transform.textureStack[g->texture.curTextureUnit].top->m31 g->transform.textureStack[g->texture.curTextureUnit].top->m32 g->transform.textureStack[g->texture.curTextureUnit].top->m33 +GLdefault GL_COLOR_MATRIX g->transform.colorStack.top->m00 g->transform.colorStack.top->m01 g->transform.colorStack.top->m02 g->transform.colorStack.top->m03 g->transform.colorStack.top->m10 g->transform.colorStack.top->m11 g->transform.colorStack.top->m12 g->transform.colorStack.top->m13 g->transform.colorStack.top->m20 g->transform.colorStack.top->m21 g->transform.colorStack.top->m22 g->transform.colorStack.top->m23 g->transform.colorStack.top->m30 g->transform.colorStack.top->m31 g->transform.colorStack.top->m32 g->transform.colorStack.top->m33 + +GLint GL_ATTRIB_STACK_DEPTH g->attrib.attribStackDepth +GLint GL_ACTIVE_TEXTURE_ARB g->texture.curTextureUnit+GL_TEXTURE0_ARB +GLint GL_CLIENT_ACTIVE_TEXTURE_ARB g->client.curClientTextureUnit+GL_TEXTURE0_ARB + +GLint GL_VIEWPORT g->viewport.viewportX g->viewport.viewportY g->viewport.viewportW g->viewport.viewportH +GLclampd GL_DEPTH_RANGE g->viewport.nearClip g->viewport.farClip +GLint GL_SCISSOR_BOX g->viewport.scissorX g->viewport.scissorY g->viewport.scissorW g->viewport.scissorH +GLboolean GL_SCISSOR_TEST g->viewport.scissorTest + + +GLenum GL_COLOR_MATERIAL_PARAMETER g->lighting.colorMaterialMode +GLenum GL_COLOR_MATERIAL_FACE g->lighting.colorMaterialFace +GLclampf GL_LIGHT_MODEL_AMBIENT g->lighting.lightModelAmbient.r g->lighting.lightModelAmbient.g g->lighting.lightModelAmbient.b g->lighting.lightModelAmbient.a +GLboolean GL_LIGHT_MODEL_LOCAL_VIEWER g->lighting.lightModelLocalViewer +GLboolean GL_LIGHT_MODEL_TWO_SIDE g->lighting.lightModelTwoSide +GLenum GL_SHADE_MODEL g->lighting.shadeModel + +GLfloat GL_FOG_COLOR g->fog.color.r g->fog.color.g g->fog.color.b g->fog.color.a +GLfloat GL_FOG_DENSITY g->fog.density +GLfloat GL_FOG_START g->fog.start +GLfloat GL_FOG_END g->fog.end +GLenum GL_FOG_MODE g->fog.mode +GLint GL_FOG_INDEX g->fog.index + +GLenum GL_FRONT_FACE g->polygon.frontFace +GLenum GL_CULL_FACE_MODE g->polygon.cullFaceMode +GLenum GL_POLYGON_MODE g->polygon.frontMode g->polygon.backMode +GLboolean GL_CULL_FACE g->polygon.cullFace +GLboolean GL_POLYGON_OFFSET_FILL g->polygon.polygonOffsetFill +GLboolean GL_POLYGON_OFFSET_LINE g->polygon.polygonOffsetLine +GLboolean GL_POLYGON_OFFSET_POINT g->polygon.polygonOffsetPoint +GLboolean GL_POLYGON_SMOOTH g->polygon.polygonSmooth +GLboolean GL_POLYGON_STIPPLE g->polygon.polygonStipple +GLfloat GL_POLYGON_OFFSET_FACTOR g->polygon.offsetFactor +GLfloat GL_POLYGON_OFFSET_UNITS g->polygon.offsetUnits + +GLboolean GL_ALPHA_TEST g->buffer.alphaTest +GLboolean GL_BLEND g->buffer.blend +GLboolean GL_COLOR_LOGIC_OP g->buffer.logicOp +GLboolean GL_COLOR_MATERIAL GL_FALSE +GLboolean GL_CLIP_PLANE0 g->transform.clip[0] +GLboolean GL_CLIP_PLANE1 g->transform.clip[1] +GLboolean GL_CLIP_PLANE2 g->transform.clip[2] +GLboolean GL_CLIP_PLANE3 g->transform.clip[3] +GLboolean GL_CLIP_PLANE4 g->transform.clip[4] +GLboolean GL_CLIP_PLANE5 g->transform.clip[5] +GLboolean GL_DEPTH_TEST g->buffer.depthTest +GLboolean GL_DEPTH_WRITEMASK g->buffer.depthMask +GLboolean GL_DITHER g->buffer.dither +GLboolean GL_INDEX_LOGIC_OP g->buffer.indexLogicOp +GLboolean GL_FOG g->fog.enable +GLboolean GL_LIGHT0 g->lighting.light[0].enable +GLboolean GL_LIGHT1 g->lighting.light[1].enable +GLboolean GL_LIGHT2 g->lighting.light[2].enable +GLboolean GL_LIGHT3 g->lighting.light[3].enable +GLboolean GL_LIGHT4 g->lighting.light[4].enable +GLboolean GL_LIGHT5 g->lighting.light[5].enable +GLboolean GL_LIGHT6 g->lighting.light[6].enable +GLboolean GL_LIGHT7 g->lighting.light[7].enable +GLboolean GL_LIGHTING g->lighting.lighting +GLboolean GL_LINE_SMOOTH g->line.lineSmooth +GLboolean GL_LINE_STIPPLE g->line.lineStipple +GLint GL_LOGIC_OP_MODE g->buffer.logicOpMode +GLboolean GL_POINT_SMOOTH g->point.pointSmooth +GLfloat GL_POINT_SIZE g->point.pointSize +GLfloat GL_POINT_SIZE_MIN_ARB g->point.minSize +GLfloat GL_POINT_SIZE_MAX_ARB g->point.maxSize +GLfloat GL_POINT_FADE_THRESHOLD_SIZE_ARB g->point.fadeThresholdSize +GLfloat GL_POINT_SPRITE_COORD_ORIGIN g->point.spriteCoordOrigin +GLfloat GL_POINT_DISTANCE_ATTENUATION_ARB g->point.distanceAttenuation[0] g->point.distanceAttenuation[1] g->point.distanceAttenuation[2] +GLboolean GL_NORMALIZE g->transform.normalize + +GLboolean GL_TEXTURE_GEN_S g->texture.unit[g->texture.curTextureUnit].textureGen.s +GLboolean GL_TEXTURE_GEN_T g->texture.unit[g->texture.curTextureUnit].textureGen.t +GLboolean GL_TEXTURE_GEN_R g->texture.unit[g->texture.curTextureUnit].textureGen.r +GLboolean GL_TEXTURE_GEN_Q g->texture.unit[g->texture.curTextureUnit].textureGen.q +GLboolean GL_TEXTURE_1D g->texture.unit[g->texture.curTextureUnit].enabled1D +GLboolean GL_TEXTURE_2D g->texture.unit[g->texture.curTextureUnit].enabled2D +GLboolean GL_TEXTURE_3D g->texture.unit[g->texture.curTextureUnit].enabled3D + +GLfloat GL_LINE_WIDTH g->line.width +GLint GL_LINE_STIPPLE_PATTERN g->line.pattern +GLint GL_LINE_STIPPLE_REPEAT g->line.repeat + +GLboolean GL_PACK_SWAP_BYTES g->client.pack.swapBytes +GLboolean GL_PACK_LSB_FIRST g->client.pack.psLSBFirst +GLboolean GL_UNPACK_SWAP_BYTES g->client.unpack.swapBytes +GLboolean GL_UNPACK_LSB_FIRST g->client.unpack.psLSBFirst +GLint GL_PACK_ROW_LENGTH g->client.pack.rowLength +GLint GL_PACK_SKIP_ROWS g->client.pack.skipRows +GLint GL_PACK_SKIP_PIXELS g->client.pack.skipPixels +GLint GL_PACK_ALIGNMENT g->client.pack.alignment +GLint GL_PACK_IMAGE_HEIGHT g->client.pack.imageHeight +GLint GL_PACK_SKIP_IMAGES g->client.pack.skipImages +GLint GL_UNPACK_ROW_LENGTH g->client.unpack.rowLength +GLint GL_UNPACK_SKIP_ROWS g->client.unpack.skipRows +GLint GL_UNPACK_SKIP_PIXELS g->client.unpack.skipPixels +GLint GL_UNPACK_ALIGNMENT g->client.unpack.alignment +GLint GL_UNPACK_IMAGE_HEIGHT g->client.unpack.imageHeight +GLint GL_UNPACK_SKIP_IMAGES g->client.unpack.skipImages +GLfloat GL_ZOOM_X g->pixel.xZoom +GLfloat GL_ZOOM_Y g->pixel.yZoom +GLfloat GL_RED_BIAS g->pixel.bias.r +GLfloat GL_GREEN_BIAS g->pixel.bias.g +GLfloat GL_BLUE_BIAS g->pixel.bias.b +GLfloat GL_ALPHA_BIAS g->pixel.bias.a +GLfloat GL_RED_SCALE g->pixel.scale.r +GLfloat GL_GREEN_SCALE g->pixel.scale.g +GLfloat GL_BLUE_SCALE g->pixel.scale.b +GLfloat GL_ALPHA_SCALE g->pixel.scale.a +GLfloat GL_DEPTH_BIAS g->pixel.depthBias +GLfloat GL_DEPTH_SCALE g->pixel.depthScale +GLint GL_INDEX_OFFSET g->pixel.indexOffset +GLint GL_INDEX_SHIFT g->pixel.indexShift +GLboolean GL_MAP_COLOR g->pixel.mapColor +GLboolean GL_MAP_STENCIL g->pixel.mapStencil +GLint GL_PIXEL_MAP_A_TO_A_SIZE g->pixel.mapAtoAsize +GLint GL_PIXEL_MAP_B_TO_B_SIZE g->pixel.mapBtoBsize +GLint GL_PIXEL_MAP_G_TO_G_SIZE g->pixel.mapGtoGsize +GLint GL_PIXEL_MAP_I_TO_A_SIZE g->pixel.mapItoAsize +GLint GL_PIXEL_MAP_I_TO_B_SIZE g->pixel.mapItoBsize +GLint GL_PIXEL_MAP_I_TO_G_SIZE g->pixel.mapItoGsize +GLint GL_PIXEL_MAP_I_TO_I_SIZE g->pixel.mapItoIsize +GLint GL_PIXEL_MAP_I_TO_R_SIZE g->pixel.mapItoRsize +GLint GL_PIXEL_MAP_R_TO_R_SIZE g->pixel.mapRtoRsize +GLint GL_PIXEL_MAP_S_TO_S_SIZE g->pixel.mapStoSsize + +GLboolean GL_AUTO_NORMAL g->eval.autoNormal +GLboolean GL_MAP1_COLOR_4 g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_INDEX g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_NORMAL g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_1 g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_2 g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_3 g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_4 g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_VERTEX_3 g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_VERTEX_4 g->eval.enable1D[pname-GL_MAP1_COLOR_4] +GLboolean GL_MAP2_COLOR_4 g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_INDEX g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_NORMAL g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_1 g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_2 g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_3 g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_4 g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_VERTEX_3 g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_VERTEX_4 g->eval.enable2D[pname-GL_MAP2_COLOR_4] +GLdouble GL_MAP1_GRID_DOMAIN g->eval.u11D g->eval.u21D +GLint GL_MAP1_GRID_SEGMENTS g->eval.un1D +GLdouble GL_MAP2_GRID_DOMAIN g->eval.u12D g->eval.u22D g->eval.v12D g->eval.v22D +GLint GL_MAP2_GRID_SEGMENTS g->eval.un2D g->eval.vn2D + +GLint GL_NAME_STACK_DEPTH 0 + +GLenum GL_FOG_HINT g->hint.fog +GLenum GL_LINE_SMOOTH_HINT g->hint.lineSmooth +GLenum GL_POINT_SMOOTH_HINT g->hint.pointSmooth +GLenum GL_POLYGON_SMOOTH_HINT g->hint.polygonSmooth +GLenum GL_PERSPECTIVE_CORRECTION_HINT g->hint.perspectiveCorrection + +GLint GL_TEXTURE_BINDING_1D g->texture.unit[g->texture.curTextureUnit].currentTexture1D->id +GLint GL_TEXTURE_BINDING_2D g->texture.unit[g->texture.curTextureUnit].currentTexture2D->id +GLint GL_TEXTURE_BINDING_3D g->texture.unit[g->texture.curTextureUnit].currentTexture3D->id +GLenum GL_TEXTURE_ENV_MODE g->texture.unit[g->texture.curTextureUnit].envMode + +GLboolean GL_VERTEX_ARRAY g->client.array.v.enabled +GLint GL_VERTEX_ARRAY_SIZE g->client.array.v.size +GLint GL_VERTEX_ARRAY_STRIDE g->client.array.v.stride +GLint GL_VERTEX_ARRAY_TYPE g->client.array.v.type +GLboolean GL_NORMAL_ARRAY g->client.array.n.enabled +GLint GL_NORMAL_ARRAY_STRIDE g->client.array.n.stride +GLint GL_NORMAL_ARRAY_TYPE g->client.array.n.type +GLboolean GL_COLOR_ARRAY g->client.array.c.enabled +GLint GL_COLOR_ARRAY_SIZE g->client.array.c.size +GLint GL_COLOR_ARRAY_STRIDE g->client.array.c.stride +GLint GL_COLOR_ARRAY_TYPE g->client.array.c.type +GLboolean GL_INDEX_ARRAY g->client.array.i.enabled +GLint GL_INDEX_ARRAY_STRIDE g->client.array.i.stride +GLint GL_INDEX_ARRAY_TYPE g->client.array.i.type +GLboolean GL_TEXTURE_COORD_ARRAY g->client.array.t[g->client.curClientTextureUnit].enabled +GLint GL_TEXTURE_COORD_ARRAY_SIZE g->client.array.t[g->client.curClientTextureUnit].size +GLint GL_TEXTURE_COORD_ARRAY_STRIDE g->client.array.t[g->client.curClientTextureUnit].stride +GLint GL_TEXTURE_COORD_ARRAY_TYPE g->client.array.t[g->client.curClientTextureUnit].type +GLboolean GL_EDGE_FLAG_ARRAY g->client.array.e.enabled +GLint GL_EDGE_FLAG_ARRAY_STRIDE g->client.array.e.stride + +GLboolean GL_RGBA_MODE g->limits.rgbaMode +GLboolean GL_INDEX_MODE (!g->limits.rgbaMode) +GLint GL_AUX_BUFFERS g->limits.auxBuffers +GLboolean GL_STEREO g->limits.stereo +GLboolean GL_DOUBLEBUFFER g->limits.doubleBuffer +GLint GL_INDEX_BITS g->limits.indexBits +GLint GL_DEPTH_BITS g->limits.depthBits +GLint GL_RED_BITS g->limits.redBits +GLint GL_GREEN_BITS g->limits.greenBits +GLint GL_BLUE_BITS g->limits.blueBits +GLint GL_ALPHA_BITS g->limits.alphaBits +GLint GL_STENCIL_BITS g->limits.stencilBits +GLint GL_ACCUM_RED_BITS g->limits.accumRedBits +GLint GL_ACCUM_GREEN_BITS g->limits.accumGreenBits +GLint GL_ACCUM_BLUE_BITS g->limits.accumBlueBits +GLint GL_ACCUM_ALPHA_BITS g->limits.accumAlphaBits +GLclampf GL_COLOR_CLEAR_VALUE g->buffer.colorClearValue.r g->buffer.colorClearValue.g g->buffer.colorClearValue.b g->buffer.colorClearValue.a +GLclampf GL_INDEX_CLEAR_VALUE g->buffer.indexClearValue +GLclampd GL_DEPTH_CLEAR_VALUE g->buffer.depthClearValue +GLfloat GL_ACCUM_CLEAR_VALUE g->buffer.accumClearValue.r g->buffer.accumClearValue.g g->buffer.accumClearValue.b g->buffer.accumClearValue.a +GLenum GL_BLEND_SRC g->buffer.blendSrcRGB +GLenum GL_BLEND_DST g->buffer.blendDstRGB +#GLenum GL_BLEND_EQUATION g->buffer.blendEquation +#GLclampf GL_BLEND_COLOR g->buffer.blendColor.r g->buffer.blendColor.g g->buffer.blendColor.b g->buffer.blendColor.a +GLenum GL_DEPTH_FUNC g->buffer.depthFunc +GLenum GL_ALPHA_TEST_FUNC g->buffer.alphaTestFunc +GLint GL_ALPHA_TEST_REF g->buffer.alphaTestRef +GLenum GL_DRAW_BUFFER __getDrawBuffer(g) +GLenum GL_READ_BUFFER __getReadBuffer(g) +GLboolean GL_COLOR_WRITEMASK g->buffer.colorWriteMask.r g->buffer.colorWriteMask.g g->buffer.colorWriteMask.b g->buffer.colorWriteMask.a +GLint GL_INDEX_WRITEMASK g->buffer.indexWriteMask + +GLint GL_LIST_BASE g->lists.base +GLint GL_LIST_INDEX g->lists.currentIndex +GLenum GL_LIST_MODE g->lists.mode + +GLint GL_STENCIL_CLEAR_VALUE g->stencil.clearValue +GLint GL_STENCIL_FAIL g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_FRONT:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail +GLint GL_STENCIL_BACK_FAIL g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_BACK:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail +GLint GL_STENCIL_FUNC g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_FRONT:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func +GLint GL_STENCIL_BACK_FUNC g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_BACK:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func +GLint GL_STENCIL_PASS_DEPTH_FAIL g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_FRONT:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail +GLint GL_STENCIL_BACK_PASS_DEPTH_FAIL g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_BACK:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail +GLint GL_STENCIL_PASS_DEPTH_PASS g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_FRONT:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass +GLint GL_STENCIL_BACK_PASS_DEPTH_PASS g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_BACK:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass +GLint GL_STENCIL_REF g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_FRONT:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref +GLint GL_STENCIL_BACK_REF g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_BACK:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref +GLboolean GL_STENCIL_TEST g->stencil.stencilTest +GLint GL_STENCIL_VALUE_MASK g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_FRONT:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask +GLint GL_STENCIL_BACK_VALUE_MASK g->stencil.buffers[g->stencil.activeStencilFace==GL_FRONT?CRSTATE_STENCIL_BUFFER_ID_BACK:CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask +GLint GL_STENCIL_WRITEMASK g->stencil.writeMask + +GLfloat GL_CURRENT_INDEX g->current.colorIndex +GLclampf GL_CURRENT_COLOR g->current.vertexAttrib[VERT_ATTRIB_COLOR0][0] g->current.vertexAttrib[VERT_ATTRIB_COLOR0][1] g->current.vertexAttrib[VERT_ATTRIB_COLOR0][2] g->current.vertexAttrib[VERT_ATTRIB_COLOR0][3] +GLclampf GL_CURRENT_NORMAL g->current.vertexAttrib[VERT_ATTRIB_NORMAL][0] g->current.vertexAttrib[VERT_ATTRIB_NORMAL][1] g->current.vertexAttrib[VERT_ATTRIB_NORMAL][2] +GLfloat GL_CURRENT_TEXTURE_COORDS g->current.vertexAttrib[VERT_ATTRIB_TEX0+g->texture.curTextureUnit][0] g->current.vertexAttrib[VERT_ATTRIB_TEX0+g->texture.curTextureUnit][1] g->current.vertexAttrib[VERT_ATTRIB_TEX0+g->texture.curTextureUnit][2] g->current.vertexAttrib[VERT_ATTRIB_TEX0+g->texture.curTextureUnit][3] +GLboolean GL_EDGE_FLAG g->current.edgeFlag + +#?b?ub?s?us?i?ui?f?d GL_CURRENT_RASTER_POSITION g->current.rasterpos?.x g->current.rasterpos?.y g->current.rasterpos?.z g->current.rasterpos?.w +GLfloat GL_CURRENT_RASTER_POSITION g->current.rasterAttrib[VERT_ATTRIB_POS][0] g->current.rasterAttrib[VERT_ATTRIB_POS][1] g->current.rasterAttrib[VERT_ATTRIB_POS][2] g->current.rasterAttrib[VERT_ATTRIB_POS][3] +GLboolean GL_CURRENT_RASTER_POSITION_VALID g->current.rasterValid +#?s?i?f?d GL_CURRENT_RASTER_TEXTURE_COORDS g->current.rastertexture?.s g->current.rastertexture?.t g->current.rastertexture?.p g->current.rastertexture?.q +GLfloat GL_CURRENT_RASTER_TEXTURE_COORDS g->current.rasterAttrib[VERT_ATTRIB_TEX0][0] g->current.rasterAttrib[VERT_ATTRIB_TEX0][1] g->current.rasterAttrib[VERT_ATTRIB_TEX0][2] g->current.rasterAttrib[VERT_ATTRIB_TEX0][3] +#GLclampf?b?ub?s?us?i?ui?f?d GL_CURRENT_RASTER_COLOR g->current.rastercolor?.r g->current.rastercolor?.g g->current.rastercolor?.b g->current.rastercolor?.a +GLfloat GL_CURRENT_RASTER_COLOR g->current.rasterAttrib[VERT_ATTRIB_COLOR0][0] g->current.rasterAttrib[VERT_ATTRIB_COLOR0][1] g->current.rasterAttrib[VERT_ATTRIB_COLOR0][2] g->current.rasterAttrib[VERT_ATTRIB_COLOR0][3] +GLfloat GL_CURRENT_RASTER_DISTANCE g->current.rasterAttrib[VERT_ATTRIB_FOG][0] +GLdouble GL_CURRENT_RASTER_INDEX g->current.rasterIndex + +#GLclampf GL_CURRENT_SECONDARY_COLOR_EXT g->lighting.vertexAttrib[VERT_ATTRIB_COLOR1][0] g->lighting.vertexAttrib[VERT_ATTRIB_COLOR1][1] g->lighting.vertexAttrib[VERT_ATTRIB_COLOR1][2] +#GLint GL_SECONDARY_COLOR_ARRAY_SIZE_EXT +#GLint GL_SECONDARY_COLOR_ARRAY_TYPE_EXT +#GLint GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT + +GLint GL_MAX_VERTEX_ATTRIBS_ARB g->limits.maxVertexProgramAttribs + +# Implementation-dependent limits queries + +GLint GL_MAX_TEXTURE_UNITS_ARB g->limits.maxTextureUnits +GLint GL_MAX_TEXTURE_SIZE g->limits.maxTextureSize +GLint GL_MAX_3D_TEXTURE_SIZE g->limits.max3DTextureSize +GLint GL_MAX_LIGHTS g->limits.maxLights +GLint GL_MAX_CLIP_PLANES g->limits.maxClipPlanes +GLint GL_MAX_PROJECTION_STACK_DEPTH g->limits.maxProjectionStackDepth +GLint GL_MAX_MODELVIEW_STACK_DEPTH g->limits.maxModelviewStackDepth +GLint GL_MAX_TEXTURE_STACK_DEPTH g->limits.maxTextureStackDepth +GLint GL_MAX_COLOR_MATRIX_STACK_DEPTH g->limits.maxColorStackDepth +GLint GL_MAX_ATTRIB_STACK_DEPTH g->limits.maxAttribStackDepth +GLint GL_MAX_CLIENT_ATTRIB_STACK_DEPTH g->limits.maxClientAttribStackDepth +GLint GL_MAX_NAME_STACK_DEPTH g->limits.maxNameStackDepth +GLint GL_MAX_ELEMENTS_INDICES g->limits.maxElementsIndices +GLint GL_MAX_ELEMENTS_VERTICES g->limits.maxElementsVertices +GLint GL_MAX_EVAL_ORDER g->limits.maxEvalOrder +GLint GL_MAX_LIST_NESTING g->limits.maxListNesting +GLint GL_MAX_PIXEL_MAP_TABLE g->limits.maxPixelMapTable +GLint GL_MAX_VIEWPORT_DIMS g->limits.maxViewportDims[0] g->limits.maxViewportDims[1] +GLint GL_SUBPIXEL_BITS g->limits.subpixelBits +GLfloat GL_ALIASED_POINT_SIZE_RANGE g->limits.aliasedPointSizeRange[0] g->limits.aliasedPointSizeRange[1] +GLfloat GL_SMOOTH_POINT_SIZE_RANGE g->limits.smoothPointSizeRange[0] g->limits.smoothPointSizeRange[1] +GLfloat GL_SMOOTH_POINT_SIZE_GRANULARITY g->limits.pointSizeGranularity +GLfloat GL_ALIASED_LINE_WIDTH_RANGE g->limits.aliasedLineWidthRange[0] g->limits.aliasedLineWidthRange[1] +GLfloat GL_SMOOTH_LINE_WIDTH_RANGE g->limits.smoothLineWidthRange[0] g->limits.smoothLineWidthRange[1] +GLfloat GL_SMOOTH_LINE_WIDTH_GRANULARITY g->limits.lineWidthGranularity +GLint GL_RENDER_MODE g->renderMode + +# Feedback + +GLint GL_FEEDBACK_BUFFER_SIZE g->feedback.bufferSize +GLint GL_FEEDBACK_BUFFER_TYPE g->feedback.type +GLint GL_SELECTION_BUFFER_SIZE g->selection.bufferSize + +# FBO +GLint GL_FRAMEBUFFER_BINDING_EXT (g->framebufferobject.drawFB?g->framebufferobject.drawFB->id:0) +GLint GL_READ_FRAMEBUFFER_BINDING (g->framebufferobject.readFB?g->framebufferobject.readFB->id:0) +GLint GL_RENDERBUFFER_BINDING_EXT (g->framebufferobject.renderbuffer?g->framebufferobject.renderbuffer->id:0) + +#CVA +GLint GL_ARRAY_ELEMENT_LOCK_FIRST_EXT g->client.array.lockFirst +GLint GL_ARRAY_ELEMENT_LOCK_COUNT_EXT g->client.array.lockCount + +GLint GL_ACTIVE_STENCIL_FACE_EXT g->stencil.activeStencilFace \ No newline at end of file diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_getstring.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_getstring.c new file mode 100644 index 00000000..3bee1c3f --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_getstring.c @@ -0,0 +1,55 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_error.h" +#include "cr_version.h" +#include "state.h" +#include "state/cr_statetypes.h" +#include "cr_extstring.h" +#include "cr_mem.h" +#include "cr_string.h" + + +const GLubyte * STATE_APIENTRY crStateGetString( GLenum name ) +{ + CRContext *g = GetCurrentContext(); + if (!g) + return NULL; + + switch( name ) + { + case GL_VENDOR: + return (const GLubyte *) CR_VENDOR; + case GL_RENDERER: + return (const GLubyte *) CR_RENDERER; + case GL_VERSION: + return (const GLubyte *) CR_OPENGL_VERSION_STRING " Chromium " CR_VERSION_STRING; + case GL_EXTENSIONS: + /* This shouldn't normally be queried - the relevant SPU should + * catch this query and do all the extension string merging/mucking. + */ + { + static char *extensions = NULL; + if (!extensions) { + extensions = crAlloc(crStrlen(crExtensions) + crStrlen(crChromiumExtensions) + 2); + crStrcpy(extensions, crExtensions); + crStrcpy(extensions, " "); + crStrcat(extensions, crChromiumExtensions); + } + return (const GLubyte *) extensions; + } +#if defined(CR_ARB_vertex_program) || defined(CR_ARB_fragment_program) + case GL_PROGRAM_ERROR_STRING_ARB: + return g->program.errorString; +#endif + default: + crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, + "calling glGetString() with invalid name" ); + return NULL; + } + + (void) crAppOnlyExtensions; /* silence warnings */ +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c new file mode 100644 index 00000000..5767ca91 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c @@ -0,0 +1,1527 @@ +/* $Id: state_glsl.c $ */ + +/** @file + * VBox OpenGL: GLSL state tracking + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" +#include "state_internals.h" +#include "cr_mem.h" +#include "cr_string.h" + +static CRGLSLShader* crStateGetShaderObj(GLuint id) +{ + CRContext *g = GetCurrentContext(); + + if (!g) + { + crWarning("crStateGetShaderObj called without current ctx"); + } + + return !g ? NULL : (CRGLSLShader *) crHashtableSearch(g->glsl.shaders, id); +} + +static CRGLSLProgram* crStateGetProgramObj(GLuint id) +{ + CRContext *g = GetCurrentContext(); + + if (!g) + { + crWarning("crStateGetProgramObj called without current ctx"); + } + + return !g ? NULL : (CRGLSLProgram *) crHashtableSearch(g->glsl.programs, id); +} + +static void crStateFreeGLSLShader(void *data) +{ + CRGLSLShader* pShader = (CRGLSLShader *) data; + + if (pShader->source) + crFree(pShader->source); + + crFree(pShader); +} + +#ifdef IN_GUEST +static void crStateFreeProgramAttribsLocationCache(CRGLSLProgram* pProgram) +{ + if (pProgram->pAttribs) crFree(pProgram->pAttribs); + + pProgram->pAttribs = NULL; + pProgram->cAttribs = 0; +} +#endif + +static void crStateFreeProgramAttribs(CRGLSLProgram* pProgram) +{ + GLuint i; + + for (i=0; iactiveState.cAttribs; ++i) + { + crFree(pProgram->activeState.pAttribs[i].name); + } + + for (i=0; icurrentState.cAttribs; ++i) + { + crFree(pProgram->currentState.pAttribs[i].name); + } + + if (pProgram->activeState.pAttribs) + crFree(pProgram->activeState.pAttribs); + + if (pProgram->currentState.pAttribs) + crFree(pProgram->currentState.pAttribs); + +#ifdef IN_GUEST + crStateFreeProgramAttribsLocationCache(pProgram); + + pProgram->bAttribsSynced = GL_FALSE; +#endif + +} + +static void crStateFreeProgramUniforms(CRGLSLProgram* pProgram) +{ + GLuint i; + + for (i=0; icUniforms; ++i) + { + if (pProgram->pUniforms[i].name) crFree(pProgram->pUniforms[i].name); + if (pProgram->pUniforms[i].data) crFree(pProgram->pUniforms[i].data); + } + + if (pProgram->pUniforms) crFree(pProgram->pUniforms); + + pProgram->pUniforms = NULL; + pProgram->cUniforms = 0; + +#ifdef IN_GUEST + pProgram->bUniformsSynced = GL_FALSE; +#endif +} + +static void crStateShaderDecRefCount(void *data) +{ + CRGLSLShader *pShader = (CRGLSLShader *) data; + + CRASSERT(pShader->refCount>0); + + pShader->refCount--; + + if (0==pShader->refCount && pShader->deleted) + { + CRContext *g = GetCurrentContext(); + crHashtableDelete(g->glsl.shaders, pShader->id, crStateFreeGLSLShader); + } +} + +static void crStateFakeDecRefCountCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader *) data1; + CRContext *ctx = (CRContext*) data2; + CRGLSLShader *pRealShader; + (void) key; (void)ctx; + + pRealShader = crStateGetShaderObj(pShader->id); + + if (pRealShader) + { + crStateShaderDecRefCount(pRealShader); + } + else + { + crWarning("crStateFakeDecRefCountCB: NULL pRealShader"); + } +} + +static void crStateFreeGLSLProgram(void *data) +{ + CRGLSLProgram* pProgram = (CRGLSLProgram *) data; + + crFreeHashtable(pProgram->currentState.attachedShaders, crStateShaderDecRefCount); + + if (pProgram->activeState.attachedShaders) + { + CRContext *g = GetCurrentContext(); + crHashtableWalk(pProgram->activeState.attachedShaders, crStateFakeDecRefCountCB, g); + crFreeHashtable(pProgram->activeState.attachedShaders, crStateFreeGLSLShader); + } + + crStateFreeProgramAttribs(pProgram); + + crStateFreeProgramUniforms(pProgram); + + crFree(pProgram); +} + +DECLEXPORT(void) STATE_APIENTRY crStateGLSLInit(CRContext *ctx) +{ + ctx->glsl.shaders = crAllocHashtable(); + ctx->glsl.programs = crAllocHashtable(); + ctx->glsl.activeProgram = NULL; + ctx->glsl.bResyncNeeded = GL_FALSE; + + if (!ctx->glsl.shaders || !ctx->glsl.programs) + { + crWarning("crStateGLSLInit: Out of memory!"); + return; + } +} + +DECLEXPORT(void) STATE_APIENTRY crStateGLSLDestroy(CRContext *ctx) +{ + CRContext *g = GetCurrentContext(); + + /** @todo hack to allow crStateFreeGLSLProgram to work correctly, + as the current context isn't the one being destroyed*/ +#ifdef CHROMIUM_THREADSAFE + CRASSERT(g != ctx); + VBoxTlsRefAddRef(ctx); /* <- this is a hack to avoid subsequent SetCurrentContext(g) do recursive Destroy for ctx */ + if (g) + VBoxTlsRefAddRef(g); /* <- ensure the g is not destroyed by the following SetCurrentContext call */ + SetCurrentContext(ctx); +#else + __currentContext = ctx; +#endif + + crFreeHashtable(ctx->glsl.programs, crStateFreeGLSLProgram); + crFreeHashtable(ctx->glsl.shaders, crStateFreeGLSLShader); + +#ifdef CHROMIUM_THREADSAFE + SetCurrentContext(g); + if (g) + VBoxTlsRefRelease(g); + VBoxTlsRefRelease(ctx); /* <- restore back the cRefs (see above) */ +#else + __currentContext = g; +#endif + +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetShaderHWID(GLuint id) +{ + CRGLSLShader *pShader = crStateGetShaderObj(id); +#ifdef IN_GUEST + CRASSERT(!pShader || pShader->hwid == id); +#endif + return pShader ? pShader->hwid : 0; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetProgramHWID(GLuint id) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(id); +#ifdef IN_GUEST + CRASSERT(!pProgram || pProgram->hwid == id); +#endif + return pProgram ? pProgram->hwid : 0; +} + +static void crStateCheckShaderHWIDCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader *) data1; + crCheckIDHWID_t *pParms = (crCheckIDHWID_t*) data2; + (void) key; + + if (pShader->hwid==pParms->hwid) + pParms->id = pShader->id; +} + +static void crStateCheckProgramHWIDCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLProgram *pProgram = (CRGLSLProgram *) data1; + crCheckIDHWID_t *pParms = (crCheckIDHWID_t*) data2; + (void) key; + + if (pProgram->hwid==pParms->hwid) + pParms->id = pProgram->id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLShaderHWIDtoID(GLuint hwid) +{ + CRContext *g = GetCurrentContext(); + crCheckIDHWID_t parms; + + parms.id = hwid; + parms.hwid = hwid; + + crHashtableWalk(g->glsl.shaders, crStateCheckShaderHWIDCB, &parms); + return parms.id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGLSLProgramHWIDtoID(GLuint hwid) +{ + CRContext *g = GetCurrentContext(); + crCheckIDHWID_t parms; + + parms.id = hwid; + parms.hwid = hwid; + + crHashtableWalk(g->glsl.programs, crStateCheckProgramHWIDCB, &parms); + return parms.id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( VBoxGLhandleARB obj ) +{ + GLuint hwId = crStateGetProgramHWID(obj); + if (hwId) + { + crStateDeleteProgram(obj); + } + else + { + hwId = crStateGetShaderHWID(obj); + crStateDeleteShader(obj); + } + return hwId; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint hwid, GLenum type) +{ + CRGLSLShader *pShader; + CRContext *g = GetCurrentContext(); + GLuint stateId = hwid; + +#ifdef IN_GUEST + CRASSERT(!crStateGetShaderObj(stateId)); +#else + /* the proogram and shader names must not intersect because DeleteObjectARB must distinguish between them + * see crStateDeleteObjectARB + * this is why use programs table for shader keys allocation */ + stateId = crHashtableAllocKeys(g->glsl.programs, 1); + if (!stateId) + { + crWarning("failed to allocate program key"); + return 0; + } + + Assert((pShader = crStateGetShaderObj(stateId)) == NULL); +#endif + + pShader = (CRGLSLShader *) crAlloc(sizeof(*pShader)); + if (!pShader) + { + crWarning("crStateCreateShader: Out of memory!"); + return 0; + } + + pShader->id = stateId; + pShader->hwid = hwid; + pShader->type = type; + pShader->source = NULL; + pShader->compiled = GL_FALSE; + pShader->deleted = GL_FALSE; + pShader->refCount = 0; + + crHashtableAdd(g->glsl.shaders, stateId, pShader); + + return stateId; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateProgram(GLuint hwid) +{ + CRGLSLProgram *pProgram; + CRContext *g = GetCurrentContext(); + GLuint stateId = hwid; + +#ifdef IN_GUEST + pProgram = crStateGetProgramObj(stateId); + if (pProgram) + { + crWarning("Program object %d already exists!", stateId); + crStateDeleteProgram(stateId); + CRASSERT(!crStateGetProgramObj(stateId)); + } +#else + stateId = crHashtableAllocKeys(g->glsl.programs, 1); + if (!stateId) + { + crWarning("failed to allocate program key"); + return 0; + } +#endif + + pProgram = (CRGLSLProgram *) crAlloc(sizeof(*pProgram)); + if (!pProgram) + { + crWarning("crStateCreateProgram: Out of memory!"); + return 0; + } + + pProgram->id = stateId; + pProgram->hwid = hwid; + pProgram->validated = GL_FALSE; + pProgram->linked = GL_FALSE; + pProgram->deleted = GL_FALSE; + pProgram->activeState.attachedShaders = NULL; + pProgram->currentState.attachedShaders = crAllocHashtable(); + + pProgram->activeState.cAttribs = 0; + pProgram->activeState.pAttribs = NULL; + pProgram->currentState.cAttribs = 0; + pProgram->currentState.pAttribs = NULL; + + pProgram->pUniforms = NULL; + pProgram->cUniforms = 0; + +#ifdef IN_GUEST + pProgram->pAttribs = NULL; + pProgram->cAttribs = 0; + + pProgram->bUniformsSynced = GL_FALSE; + pProgram->bAttribsSynced = GL_FALSE; +#endif + + crHashtableAdd(g->glsl.programs, stateId, pProgram); + + return stateId; +} + +DECLEXPORT(void) STATE_APIENTRY crStateCompileShader(GLuint shader) +{ + CRGLSLShader *pShader = crStateGetShaderObj(shader); + if (!pShader) + { + crWarning("Unknown shader %d", shader); + return; + } + + pShader->compiled = GL_TRUE; +} + +static void crStateDbgCheckNoProgramOfId(void *data) +{ + (void)data; + crError("Unexpected Program id"); +} + +DECLEXPORT(void) STATE_APIENTRY crStateDeleteShader(GLuint shader) +{ + CRGLSLShader *pShader = crStateGetShaderObj(shader); + if (!pShader) + { + crWarning("Unknown shader %d", shader); + return; + } + + pShader->deleted = GL_TRUE; + + if (0==pShader->refCount) + { + CRContext *g = GetCurrentContext(); + crHashtableDelete(g->glsl.shaders, shader, crStateFreeGLSLShader); + /* since we use programs table for key allocation key allocation, we need to + * free the key in the programs table. + * See comment in crStateCreateShader */ + crHashtableDelete(g->glsl.programs, shader, crStateDbgCheckNoProgramOfId); + } +} + +DECLEXPORT(void) STATE_APIENTRY crStateAttachShader(GLuint program, GLuint shader) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + CRGLSLShader *pShader; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + if (crHashtableSearch(pProgram->currentState.attachedShaders, shader)) + { + /*shader already attached to this program*/ + return; + } + + pShader = crStateGetShaderObj(shader); + + if (!pShader) + { + crWarning("Unknown shader %d", shader); + return; + } + + pShader->refCount++; + + crHashtableAdd(pProgram->currentState.attachedShaders, shader, pShader); +} + +DECLEXPORT(void) STATE_APIENTRY crStateDetachShader(GLuint program, GLuint shader) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + CRGLSLShader *pShader; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + pShader = (CRGLSLShader *) crHashtableSearch(pProgram->currentState.attachedShaders, shader); + if (!pShader) + { + crWarning("Shader %d isn't attached to program %d", shader, program); + return; + } + + crHashtableDelete(pProgram->currentState.attachedShaders, shader, NULL); + + CRASSERT(pShader->refCount>0); + pShader->refCount--; + + if (0==pShader->refCount) + { + CRContext *g = GetCurrentContext(); + crHashtableDelete(g->glsl.shaders, shader, crStateFreeGLSLShader); + } +} + +DECLEXPORT(void) STATE_APIENTRY crStateUseProgram(GLuint program) +{ + CRContext *g = GetCurrentContext(); + + if (program>0) + { + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + g->glsl.activeProgram = pProgram; + } + else + { + g->glsl.activeProgram = NULL; + } +} + +DECLEXPORT(void) STATE_APIENTRY crStateDeleteProgram(GLuint program) +{ + CRContext *g = GetCurrentContext(); + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + if (g->glsl.activeProgram == pProgram) + { + g->glsl.activeProgram = NULL; + } + + crHashtableDelete(g->glsl.programs, program, crStateFreeGLSLProgram); +} + +DECLEXPORT(void) STATE_APIENTRY crStateValidateProgram(GLuint program) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + pProgram->validated = GL_TRUE; +} + +static void crStateCopyShaderCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pRealShader = (CRGLSLShader *) data1; + CRGLSLProgram *pProgram = (CRGLSLProgram *) data2; + CRGLSLShader *pShader; + GLint sLen=0; + + CRASSERT(pRealShader); + pRealShader->refCount++; + + pShader = (CRGLSLShader *) crAlloc(sizeof(*pShader)); + if (!pShader) + { + crWarning("crStateCopyShaderCB: Out of memory!"); + return; + } + + crMemcpy(pShader, pRealShader, sizeof(*pShader)); + + diff_api.GetShaderiv(pShader->hwid, GL_SHADER_SOURCE_LENGTH, &sLen); + if (sLen>0) + { + pShader->source = (GLchar*) crAlloc(sLen); + diff_api.GetShaderSource(pShader->hwid, sLen, NULL, pShader->source); + } + + crHashtableAdd(pProgram->activeState.attachedShaders, key, pShader); +} + +DECLEXPORT(void) STATE_APIENTRY crStateLinkProgram(GLuint program) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + GLuint i; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + pProgram->linked = GL_TRUE; + + /*Free program's active state*/ + if (pProgram->activeState.attachedShaders) + { + crHashtableWalk(pProgram->activeState.attachedShaders, crStateFakeDecRefCountCB, NULL); + crFreeHashtable(pProgram->activeState.attachedShaders, crStateFreeGLSLShader); + pProgram->activeState.attachedShaders = NULL; + } + for (i=0; iactiveState.cAttribs; ++i) + { + crFree(pProgram->activeState.pAttribs[i].name); + } + if (pProgram->activeState.pAttribs) crFree(pProgram->activeState.pAttribs); + + /*copy current state to active state*/ + crMemcpy(&pProgram->activeState, &pProgram->currentState, sizeof(CRGLSLProgramState)); + + pProgram->activeState.attachedShaders = crAllocHashtable(); + if (!pProgram->activeState.attachedShaders) + { + crWarning("crStateLinkProgram: Out of memory!"); + return; + } + crHashtableWalk(pProgram->currentState.attachedShaders, crStateCopyShaderCB, pProgram); + + /*that's not a bug, note the memcpy above*/ + if (pProgram->activeState.pAttribs) + { + pProgram->activeState.pAttribs = (CRGLSLAttrib *) crAlloc(pProgram->activeState.cAttribs * sizeof(CRGLSLAttrib)); + } + + for (i=0; iactiveState.cAttribs; ++i) + { + crMemcpy(&pProgram->activeState.pAttribs[i], &pProgram->currentState.pAttribs[i], sizeof(CRGLSLAttrib)); + pProgram->activeState.pAttribs[i].name = crStrdup(pProgram->currentState.pAttribs[i].name); + } + +#ifdef IN_GUEST + crStateFreeProgramAttribsLocationCache(pProgram); +#endif + + crStateFreeProgramUniforms(pProgram); +} + +DECLEXPORT(void) STATE_APIENTRY crStateBindAttribLocation(GLuint program, GLuint index, const char * name) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + GLuint i; + CRGLSLAttrib *pAttribs; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + if (index>=CR_MAX_VERTEX_ATTRIBS) + { + crWarning("crStateBindAttribLocation: Index too big %d", index); + return; + } + + for (i=0; icurrentState.cAttribs; ++i) + { + if (!crStrcmp(pProgram->currentState.pAttribs[i].name, name)) + { + pProgram->currentState.pAttribs[i].index = index; + return; + } + } + + pAttribs = (CRGLSLAttrib*) crAlloc((pProgram->currentState.cAttribs+1)*sizeof(CRGLSLAttrib)); + if (!pAttribs) + { + crWarning("crStateBindAttribLocation: Out of memory!"); + return; + } + + if (pProgram->currentState.cAttribs) + { + crMemcpy(&pAttribs[0], &pProgram->currentState.pAttribs[0], pProgram->currentState.cAttribs*sizeof(CRGLSLAttrib)); + } + pAttribs[pProgram->currentState.cAttribs].index = index; + pAttribs[pProgram->currentState.cAttribs].name = crStrdup(name); + + pProgram->currentState.cAttribs++; + if (pProgram->currentState.pAttribs) crFree(pProgram->currentState.pAttribs); + pProgram->currentState.pAttribs = pAttribs; +} + +DECLEXPORT(GLint) STATE_APIENTRY crStateGetUniformSize(GLenum type) +{ + GLint size; + + switch (type) + { + case GL_FLOAT: + size = 1; + break; + case GL_FLOAT_VEC2: + size = 2; + break; + case GL_FLOAT_VEC3: + size = 3; + break; + case GL_FLOAT_VEC4: + size = 4; + break; + case GL_INT: + size = 1; + break; + case GL_INT_VEC2: + size = 2; + break; + case GL_INT_VEC3: + size = 3; + break; + case GL_INT_VEC4: + size = 4; + break; + case GL_BOOL: + size = 1; + break; + case GL_BOOL_VEC2: + size = 2; + break; + case GL_BOOL_VEC3: + size = 3; + break; + case GL_BOOL_VEC4: + size = 4; + break; + case GL_FLOAT_MAT2: + size = 8; + break; + case GL_FLOAT_MAT3: + size = 12; + break; + case GL_FLOAT_MAT4: + size = 16; + break; + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_RECT_ARB: + case GL_SAMPLER_2D_RECT_SHADOW_ARB: + size = 1; + break; +#ifdef CR_OPENGL_VERSION_2_1 + case GL_FLOAT_MAT2x3: + size = 8; + break; + case GL_FLOAT_MAT2x4: + size = 8; + break; + case GL_FLOAT_MAT3x2: + size = 12; + break; + case GL_FLOAT_MAT3x4: + size = 12; + break; + case GL_FLOAT_MAT4x2: + size = 16; + break; + case GL_FLOAT_MAT4x3: + size = 16; + break; +#endif + default: + crWarning("crStateGetUniformSize: unknown uniform type 0x%x", (GLint)type); + size = 16; + break; + } + + return size; +} + +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsIntUniform(GLenum type) +{ + if (GL_INT==type + || GL_INT_VEC2==type + || GL_INT_VEC3==type + || GL_INT_VEC4==type + || GL_BOOL==type + || GL_BOOL_VEC2==type + || GL_BOOL_VEC3==type + || GL_BOOL_VEC4==type + || GL_SAMPLER_1D==type + || GL_SAMPLER_2D==type + || GL_SAMPLER_3D==type + || GL_SAMPLER_CUBE==type + || GL_SAMPLER_1D_SHADOW==type + || GL_SAMPLER_2D_SHADOW==type + || GL_SAMPLER_2D_RECT_ARB==type + || GL_SAMPLER_2D_RECT_SHADOW_ARB==type) + { + return GL_TRUE; + } + else return GL_FALSE; +} + +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(GLuint program) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + + if (!pProgram) + { + WARN(("Unknown program %d", program)); + return GL_FALSE; + } + +#ifdef IN_GUEST + return pProgram->bUniformsSynced; +#else + WARN(("crStateIsProgramUniformsCached called on host side!!")); + return GL_FALSE; +#endif +} + +DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramAttribsCached(GLuint program) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + + if (!pProgram) + { + WARN(("Unknown program %d", program)); + return GL_FALSE; + } + +#ifdef IN_GUEST + return pProgram->bAttribsSynced; +#else + WARN(("crStateIsProgramAttribsCached called on host side!!")); + return GL_FALSE; +#endif +} + +/** @todo one of those functions should ignore uniforms starting with "gl"*/ + +#ifdef IN_GUEST +DECLEXPORT(void) STATE_APIENTRY +crStateGLSLProgramCacheUniforms(GLuint program, GLsizei cbData, GLvoid *pData) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + char *pCurrent = pData; + GLsizei cbRead, cbName; + GLuint i; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + if (pProgram->bUniformsSynced) + { + crWarning("crStateGLSLProgramCacheUniforms: this shouldn't happen!"); + crStateFreeProgramUniforms(pProgram); + } + + if (cbData<(GLsizei)sizeof(GLsizei)) + { + crWarning("crStateGLSLProgramCacheUniforms: data too short"); + return; + } + + pProgram->cUniforms = ((GLsizei*)pCurrent)[0]; + pCurrent += sizeof(GLsizei); + cbRead = sizeof(GLsizei); + + /*crDebug("crStateGLSLProgramCacheUniforms: %i active uniforms", pProgram->cUniforms);*/ + + if (pProgram->cUniforms) + { + pProgram->pUniforms = crAlloc(pProgram->cUniforms*sizeof(CRGLSLUniform)); + if (!pProgram->pUniforms) + { + crWarning("crStateGLSLProgramCacheUniforms: no memory"); + pProgram->cUniforms = 0; + return; + } + } + + for (i=0; icUniforms; ++i) + { + cbRead += sizeof(GLuint)+sizeof(GLsizei); + if (cbRead>cbData) + { + crWarning("crStateGLSLProgramCacheUniforms: out of data reading uniform %i", i); + return; + } + pProgram->pUniforms[i].data = NULL; + pProgram->pUniforms[i].location = ((GLint*)pCurrent)[0]; + pCurrent += sizeof(GLint); + cbName = ((GLsizei*)pCurrent)[0]; + pCurrent += sizeof(GLsizei); + + cbRead += cbName; + if (cbRead>cbData) + { + crWarning("crStateGLSLProgramCacheUniforms: out of data reading uniform's name %i", i); + return; + } + + pProgram->pUniforms[i].name = crStrndup(pCurrent, cbName); + pCurrent += cbName; + + /*crDebug("crStateGLSLProgramCacheUniforms: uniform[%i]=%d, %s", i, pProgram->pUniforms[i].location, pProgram->pUniforms[i].name);*/ + } + + pProgram->bUniformsSynced = GL_TRUE; + + CRASSERT((pCurrent-((char*)pData))==cbRead); + CRASSERT(cbRead==cbData); +} + +DECLEXPORT(void) STATE_APIENTRY +crStateGLSLProgramCacheAttribs(GLuint program, GLsizei cbData, GLvoid *pData) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + char *pCurrent = pData; + GLsizei cbRead, cbName; + GLuint i; + + if (!pProgram) + { + WARN(("Unknown program %d", program)); + return; + } + + if (pProgram->bAttribsSynced) + { + WARN(("crStateGLSLProgramCacheAttribs: this shouldn't happen!")); + crStateFreeProgramAttribsLocationCache(pProgram); + } + + if (cbData<(GLsizei)sizeof(GLsizei)) + { + WARN(("crStateGLSLProgramCacheAttribs: data too short")); + return; + } + + pProgram->cAttribs = ((GLsizei*)pCurrent)[0]; + pCurrent += sizeof(GLsizei); + cbRead = sizeof(GLsizei); + + crDebug("crStateGLSLProgramCacheAttribs: %i active attribs", pProgram->cAttribs); + + if (pProgram->cAttribs) + { + pProgram->pAttribs = crAlloc(pProgram->cAttribs*sizeof(CRGLSLAttrib)); + if (!pProgram->pAttribs) + { + WARN(("crStateGLSLProgramCacheAttribs: no memory")); + pProgram->cAttribs = 0; + return; + } + } + + for (i=0; icAttribs; ++i) + { + cbRead += sizeof(GLuint)+sizeof(GLsizei); + if (cbRead>cbData) + { + crWarning("crStateGLSLProgramCacheAttribs: out of data reading attrib %i", i); + return; + } + pProgram->pAttribs[i].index = ((GLint*)pCurrent)[0]; + pCurrent += sizeof(GLint); + cbName = ((GLsizei*)pCurrent)[0]; + pCurrent += sizeof(GLsizei); + + cbRead += cbName; + if (cbRead>cbData) + { + crWarning("crStateGLSLProgramCacheAttribs: out of data reading attrib's name %i", i); + return; + } + + pProgram->pAttribs[i].name = crStrndup(pCurrent, cbName); + pCurrent += cbName; + + crDebug("crStateGLSLProgramCacheAttribs: attribs[%i]=%d, %s", i, pProgram->pAttribs[i].index, pProgram->pAttribs[i].name); + } + + pProgram->bAttribsSynced = GL_TRUE; + + CRASSERT((pCurrent-((char*)pData))==cbRead); + CRASSERT(cbRead==cbData); +} +#else /* IN_GUEST */ +static GLboolean crStateGLSLProgramCacheOneUniform(GLuint location, GLsizei cbName, GLchar *pName, + char **pCurrent, GLsizei *pcbWritten, GLsizei maxcbData) +{ + *pcbWritten += sizeof(GLint)+sizeof(GLsizei)+cbName; + if (*pcbWritten>maxcbData) + { + crWarning("crStateGLSLProgramCacheUniforms: buffer too small"); + crFree(pName); + return GL_FALSE; + } + + /*crDebug("crStateGLSLProgramCacheUniforms: uniform[%i]=%s.", location, pName);*/ + + ((GLint*)*pCurrent)[0] = location; + *pCurrent += sizeof(GLint); + ((GLsizei*)*pCurrent)[0] = cbName; + *pCurrent += sizeof(GLsizei); + crMemcpy(*pCurrent, pName, cbName); + *pCurrent += cbName; + + return GL_TRUE; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateGLSLProgramCacheUniforms(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + GLint maxUniformLen = 0, activeUniforms=0, fakeUniformsCount, i, j; + char *pCurrent = pData; + GLsizei cbWritten; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + /* + * OpenGL spec says about GL_ACTIVE_UNIFORM_MAX_LENGTH: + * "If no active uniform variable exist, 0 is returned." + */ + diff_api.GetProgramiv(pProgram->hwid, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLen); + if (maxUniformLen > 0) + diff_api.GetProgramiv(pProgram->hwid, GL_ACTIVE_UNIFORMS, &activeUniforms); + + *cbData = 0; + + cbWritten = sizeof(GLsizei); + if (cbWritten>maxcbData) + { + crWarning("crStateGLSLProgramCacheUniforms: buffer too small"); + return; + } + ((GLsizei*)pCurrent)[0] = activeUniforms; + fakeUniformsCount = activeUniforms; + pCurrent += sizeof(GLsizei); + + crDebug("crStateGLSLProgramCacheUniforms: %i active uniforms", activeUniforms); + + if (activeUniforms>0) + { + /*+8 to make sure our array uniforms with higher indices and [] will fit in as well*/ + GLchar *name = (GLchar *) crAlloc(maxUniformLen+8); + GLenum type; + GLint size; + GLsizei cbName; + GLint location; + + if (!name) + { + crWarning("crStateGLSLProgramCacheUniforms: no memory"); + return; + } + + for (i=0; ihwid, i, maxUniformLen, &cbName, &size, &type, name); + location = diff_api.GetUniformLocation(pProgram->hwid, name); + + if (!crStateGLSLProgramCacheOneUniform(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) + return; + + /* Only one active uniform variable will be reported for a uniform array by glGetActiveUniform, + * so we insert fake elements for other array elements. + */ + if (size!=1) + { + char *pIndexStr = crStrchr(name, '['); + GLint firstIndex=1; + fakeUniformsCount += size; + + crDebug("crStateGLSLProgramCacheUniforms: expanding array uniform, size=%i", size); + + /*For array uniforms it's valid to query location of 1st element as both uniform and uniform[0]. + *The name returned by glGetActiveUniform is driver dependent, + *atleast it's with [0] on win/ati and without [0] on linux/nvidia. + */ + if (!pIndexStr) + { + pIndexStr = name+cbName; + firstIndex=0; + } + else + { + cbName = pIndexStr-name; + if (!crStateGLSLProgramCacheOneUniform(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) + return; + } + + for (j=firstIndex; jhwid, name); + + if (!crStateGLSLProgramCacheOneUniform(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) + return; + } + } + } + + crFree(name); + } + + if (fakeUniformsCount!=activeUniforms) + { + ((GLsizei*)pData)[0] = fakeUniformsCount; + crDebug("FakeCount %i", fakeUniformsCount); + } + + *cbData = cbWritten; + + CRASSERT((pCurrent-((char*)pData))==cbWritten); +} + +static GLboolean crStateGLSLProgramCacheOneAttrib(GLuint location, GLsizei cbName, GLchar *pName, + char **pCurrent, GLsizei *pcbWritten, GLsizei maxcbData) +{ + *pcbWritten += sizeof(GLint)+sizeof(GLsizei)+cbName; + if (*pcbWritten>maxcbData) + { + WARN(("crStateGLSLProgramCacheOneAttrib: buffer too small")); + crFree(pName); + return GL_FALSE; + } + + crDebug("crStateGLSLProgramCacheOneAttrib: attrib[%i]=%s.", location, pName); + + ((GLint*)*pCurrent)[0] = location; + *pCurrent += sizeof(GLint); + ((GLsizei*)*pCurrent)[0] = cbName; + *pCurrent += sizeof(GLsizei); + crMemcpy(*pCurrent, pName, cbName); + *pCurrent += cbName; + + return GL_TRUE; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateGLSLProgramCacheAttribs(GLuint program, GLsizei maxcbData, GLsizei *cbData, GLvoid *pData) +{ + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + GLint maxAttribLen, activeAttribs=0, fakeAttribsCount, i, j; + char *pCurrent = pData; + GLsizei cbWritten; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return; + } + + diff_api.GetProgramiv(pProgram->hwid, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &maxAttribLen); + diff_api.GetProgramiv(pProgram->hwid, GL_ACTIVE_ATTRIBUTES, &activeAttribs); + + *cbData = 0; + + cbWritten = sizeof(GLsizei); + if (cbWritten>maxcbData) + { + crWarning("crStateGLSLProgramCacheAttribs: buffer too small"); + return; + } + ((GLsizei*)pCurrent)[0] = activeAttribs; + fakeAttribsCount = activeAttribs; + pCurrent += sizeof(GLsizei); + + crDebug("crStateGLSLProgramCacheAttribs: %i active attribs", activeAttribs); + + if (activeAttribs>0) + { + /*+8 to make sure our array attribs with higher indices and [] will fit in as well*/ + GLchar *name = (GLchar *) crAlloc(maxAttribLen+8); + GLenum type; + GLint size; + GLsizei cbName; + GLint location; + + if (!name) + { + crWarning("crStateGLSLProgramCacheAttribs: no memory"); + return; + } + + for (i=0; ihwid, i, maxAttribLen, &cbName, &size, &type, name); + location = diff_api.GetAttribLocation(pProgram->hwid, name); + + if (!crStateGLSLProgramCacheOneAttrib(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) + return; + + /* Only one active attrib variable will be reported for a attrib array by glGetActiveAttrib, + * so we insert fake elements for other array elements. + */ + if (size!=1) + { + char *pIndexStr = crStrchr(name, '['); + GLint firstIndex=1; + fakeAttribsCount += size; + + crDebug("crStateGLSLProgramCacheAttribs: expanding array attrib, size=%i", size); + + /*For array attribs it's valid to query location of 1st element as both attrib and attrib[0]. + *The name returned by glGetActiveAttrib is driver dependent, + *atleast it's with [0] on win/ati and without [0] on linux/nvidia. + */ + if (!pIndexStr) + { + pIndexStr = name+cbName; + firstIndex=0; + } + else + { + cbName = pIndexStr-name; + if (!crStateGLSLProgramCacheOneAttrib(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) + return; + } + + for (j=firstIndex; jhwid, name); + + if (!crStateGLSLProgramCacheOneAttrib(location, cbName, name, &pCurrent, &cbWritten, maxcbData)) + return; + } + } + } + + crFree(name); + } + + if (fakeAttribsCount!=activeAttribs) + { + ((GLsizei*)pData)[0] = fakeAttribsCount; + crDebug("FakeCount %i", fakeAttribsCount); + } + + *cbData = cbWritten; + + CRASSERT((pCurrent-((char*)pData))==cbWritten); +} +#endif + +DECLEXPORT(GLint) STATE_APIENTRY crStateGetUniformLocation(GLuint program, const char * name) +{ +#ifdef IN_GUEST + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + GLint result=-1; + GLuint i; + + if (!pProgram) + { + crWarning("Unknown program %d", program); + return -1; + } + + if (!pProgram->bUniformsSynced) + { + crWarning("crStateGetUniformLocation called for uncached uniforms"); + return -1; + } + + for (i=0; icUniforms; ++i) + { + if (!crStrcmp(name, pProgram->pUniforms[i].name)) + { + result = pProgram->pUniforms[i].location; + break; + } + } + + return result; +#else + crWarning("crStateGetUniformLocation called on host side!!"); + return -1; +#endif +} + +DECLEXPORT(GLint) STATE_APIENTRY crStateGetAttribLocation(GLuint program, const char * name) +{ +#ifdef IN_GUEST + CRGLSLProgram *pProgram = crStateGetProgramObj(program); + GLint result=-1; + GLuint i; + + if (!pProgram) + { + WARN(("Unknown program %d", program)); + return -1; + } + + if (!pProgram->bAttribsSynced) + { + WARN(("crStateGetAttribLocation called for uncached attribs")); + return -1; + } + + for (i=0; icAttribs; ++i) + { + if (!crStrcmp(name, pProgram->pAttribs[i].name)) + { + result = pProgram->pAttribs[i].index; + break; + } + } + + return result; +#else + crWarning("crStateGetAttribLocation called on host side!!"); + return -1; +#endif +} + +static void crStateGLSLCreateShadersCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader*) data1; + CRContext *ctx = (CRContext *) data2; + (void)ctx; (void)key; + + pShader->hwid = diff_api.CreateShader(pShader->type); +} + +static void crStateFixAttachedShaderHWIDsCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader*) data1; + CRGLSLShader *pRealShader; + CRContext *pCtx = (CRContext *) data2; + + pRealShader = (CRGLSLShader *) crHashtableSearch(pCtx->glsl.shaders, key); + CRASSERT(pRealShader); + + pShader->hwid = pRealShader->hwid; +} + +static void crStateGLSLSyncShadersCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader*) data1; + (void) key; + (void) data2; + + if (pShader->source) + { + diff_api.ShaderSource(pShader->hwid, 1, (const char**)&pShader->source, NULL); + if (pShader->compiled) + diff_api.CompileShader(pShader->hwid); + crFree(pShader->source); + pShader->source = NULL; + } + + if (pShader->deleted) + diff_api.DeleteShader(pShader->hwid); +} + +static void crStateAttachShaderCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader*) data1; + CRGLSLProgram *pProgram = (CRGLSLProgram *) data2; + (void) key; + + if (pShader->source) + { + diff_api.ShaderSource(pShader->hwid, 1, (const char**)&pShader->source, NULL); + if (pShader->compiled) + diff_api.CompileShader(pShader->hwid); + } + + diff_api.AttachShader(pProgram->hwid, pShader->hwid); +} + +static void crStateDetachShaderCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader*) data1; + CRGLSLProgram *pProgram = (CRGLSLProgram *) data2; + (void) key; + + diff_api.DetachShader(pProgram->hwid, pShader->hwid); +} + +static void crStateGLSLCreateProgramCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLProgram *pProgram = (CRGLSLProgram*) data1; + CRContext *ctx = (CRContext *) data2; + GLuint i; + (void)key; + + pProgram->hwid = diff_api.CreateProgram(); + + if (pProgram->linked) + { + CRASSERT(pProgram->activeState.attachedShaders); + + crHashtableWalk(pProgram->activeState.attachedShaders, crStateFixAttachedShaderHWIDsCB, ctx); + crHashtableWalk(pProgram->activeState.attachedShaders, crStateAttachShaderCB, pProgram); + + for (i=0; iactiveState.cAttribs; ++i) + { + diff_api.BindAttribLocation(pProgram->hwid, pProgram->activeState.pAttribs[i].index, pProgram->activeState.pAttribs[i].name); + } + + if (pProgram->validated) + diff_api.ValidateProgram(pProgram->hwid); + + diff_api.LinkProgram(pProgram->hwid); + } + + diff_api.UseProgram(pProgram->hwid); + + for (i=0; icUniforms; ++i) + { + GLint location; + GLfloat *pFdata = (GLfloat*)pProgram->pUniforms[i].data; + GLint *pIdata = (GLint*)pProgram->pUniforms[i].data; + + location = diff_api.GetUniformLocation(pProgram->hwid, pProgram->pUniforms[i].name); + switch (pProgram->pUniforms[i].type) + { + case GL_FLOAT: + diff_api.Uniform1fv(location, 1, pFdata); + break; + case GL_FLOAT_VEC2: + diff_api.Uniform2fv(location, 1, pFdata); + break; + case GL_FLOAT_VEC3: + diff_api.Uniform3fv(location, 1, pFdata); + break; + case GL_FLOAT_VEC4: + diff_api.Uniform4fv(location, 1, pFdata); + break; + case GL_INT: + case GL_BOOL: + diff_api.Uniform1iv(location, 1, pIdata); + break; + case GL_INT_VEC2: + case GL_BOOL_VEC2: + diff_api.Uniform2iv(location, 1, pIdata); + break; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + diff_api.Uniform3iv(location, 1, pIdata); + break; + case GL_INT_VEC4: + case GL_BOOL_VEC4: + diff_api.Uniform4iv(location, 1, pIdata); + break; + case GL_FLOAT_MAT2: + diff_api.UniformMatrix2fv(location, 1, GL_FALSE, pFdata); + break; + case GL_FLOAT_MAT3: + diff_api.UniformMatrix3fv(location, 1, GL_FALSE, pFdata); + break; + case GL_FLOAT_MAT4: + diff_api.UniformMatrix4fv(location, 1, GL_FALSE, pFdata); + break; + case GL_SAMPLER_1D: + case GL_SAMPLER_2D: + case GL_SAMPLER_3D: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_1D_SHADOW: + case GL_SAMPLER_2D_SHADOW: + case GL_SAMPLER_2D_RECT_ARB: + case GL_SAMPLER_2D_RECT_SHADOW_ARB: + diff_api.Uniform1iv(location, 1, pIdata); + break; +#ifdef CR_OPENGL_VERSION_2_1 + case GL_FLOAT_MAT2x3: + diff_api.UniformMatrix2x3fv(location, 1, GL_FALSE, pFdata); + break; + case GL_FLOAT_MAT2x4: + diff_api.UniformMatrix2x4fv(location, 1, GL_FALSE, pFdata); + break; + case GL_FLOAT_MAT3x2: + diff_api.UniformMatrix3x2fv(location, 1, GL_FALSE, pFdata); + break; + case GL_FLOAT_MAT3x4: + diff_api.UniformMatrix3x4fv(location, 1, GL_FALSE, pFdata); + break; + case GL_FLOAT_MAT4x2: + diff_api.UniformMatrix4x2fv(location, 1, GL_FALSE, pFdata); + break; + case GL_FLOAT_MAT4x3: + diff_api.UniformMatrix4x3fv(location, 1, GL_FALSE, pFdata); + break; +#endif + default: + crWarning("crStateGLSLCreateProgramCB: unknown uniform type 0x%x", (GLint)pProgram->pUniforms[i].type); + break; + } + crFree(pProgram->pUniforms[i].data); + crFree(pProgram->pUniforms[i].name); + } /*for (i=0; icUniforms; ++i)*/ + if (pProgram->pUniforms) crFree(pProgram->pUniforms); + pProgram->pUniforms = NULL; + pProgram->cUniforms = 0; + + crHashtableWalk(pProgram->activeState.attachedShaders, crStateDetachShaderCB, pProgram); + crHashtableWalk(pProgram->currentState.attachedShaders, crStateAttachShaderCB, pProgram); +} + +DECLEXPORT(void) STATE_APIENTRY crStateGLSLSwitch(CRContext *from, CRContext *to) +{ + GLboolean fForceUseProgramSet = GL_FALSE; + if (to->glsl.bResyncNeeded) + { + to->glsl.bResyncNeeded = GL_FALSE; + + crHashtableWalk(to->glsl.shaders, crStateGLSLCreateShadersCB, to); + + crHashtableWalk(to->glsl.programs, crStateGLSLCreateProgramCB, to); + + /* crStateGLSLCreateProgramCB changes the current program, ensure we have the proper program re-sored */ + fForceUseProgramSet = GL_TRUE; + + crHashtableWalk(to->glsl.shaders, crStateGLSLSyncShadersCB, NULL); + } + + if (to->glsl.activeProgram != from->glsl.activeProgram || fForceUseProgramSet) + { + diff_api.UseProgram(to->glsl.activeProgram ? to->glsl.activeProgram->hwid : 0); + } +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_hint.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_hint.c new file mode 100644 index 00000000..a3989258 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_hint.c @@ -0,0 +1,132 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateHintInit (CRContext *ctx) +{ + CRHintState *h = &ctx->hint; + CRStateBits *sb = GetCurrentBits(); + CRHintBits *hb = &(sb->hint); + + h->perspectiveCorrection = GL_DONT_CARE; + RESET(hb->perspectiveCorrection, ctx->bitid); + h->pointSmooth = GL_DONT_CARE; + RESET(hb->pointSmooth, ctx->bitid); + h->lineSmooth = GL_DONT_CARE; + RESET(hb->lineSmooth, ctx->bitid); + h->polygonSmooth = GL_DONT_CARE; + RESET(hb->polygonSmooth, ctx->bitid); + h->fog = GL_DONT_CARE; + RESET(hb->fog, ctx->bitid); +#ifdef CR_EXT_clip_volume_hint + h->clipVolumeClipping = GL_DONT_CARE; + RESET(hb->clipVolumeClipping, ctx->bitid); +#endif +#ifdef CR_ARB_texture_compression + h->textureCompression = GL_DONT_CARE; + RESET(hb->textureCompression, ctx->bitid); +#endif +#ifdef CR_SGIS_generate_mipmap + h->generateMipmap = GL_DONT_CARE; + RESET(hb->generateMipmap, ctx->bitid); +#endif + RESET(hb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateHint(GLenum target, GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRHintState *h = &(g->hint); + CRStateBits *sb = GetCurrentBits(); + CRHintBits *hb = &(sb->hint); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glHint called in Begin/End"); + return; + } + + FLUSH(); + + if (mode != GL_FASTEST && mode != GL_NICEST && mode != GL_DONT_CARE) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glHint(mode)"); + return; + } + + switch (target) { + case GL_PERSPECTIVE_CORRECTION_HINT: + h->perspectiveCorrection = mode; + DIRTY(hb->perspectiveCorrection, g->neg_bitid); + break; + case GL_FOG_HINT: + h->fog = mode; + DIRTY(hb->fog, g->neg_bitid); + break; + case GL_LINE_SMOOTH_HINT: + h->lineSmooth = mode; + DIRTY(hb->lineSmooth, g->neg_bitid); + break; + case GL_POINT_SMOOTH_HINT: + h->pointSmooth = mode; + DIRTY(hb->pointSmooth, g->neg_bitid); + break; + case GL_POLYGON_SMOOTH_HINT: + h->polygonSmooth = mode; + DIRTY(hb->polygonSmooth, g->neg_bitid); + break; +#ifdef CR_EXT_clip_volume_hint + case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: + if (g->extensions.EXT_clip_volume_hint) { + h->clipVolumeClipping = mode; + DIRTY(hb->clipVolumeClipping, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glHint(target)"); + return; + } + break; +#endif +#ifdef CR_ARB_texture_compression + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (g->extensions.ARB_texture_compression) { + h->textureCompression = mode; + DIRTY(hb->textureCompression, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glHint(target)"); + return; + } + break; +#endif +#ifdef CR_SGIS_generate_mipmap + case GL_GENERATE_MIPMAP_HINT_SGIS: + if (g->extensions.SGIS_generate_mipmap) { + h->generateMipmap = mode; + DIRTY(hb->generateMipmap, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glHint(target)"); + return; + } + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glHint(target)"); + return; + } + + DIRTY(hb->dirty, g->neg_bitid); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_hint.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_hint.txt new file mode 100644 index 00000000..9f129338 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_hint.txt @@ -0,0 +1,12 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:lineSmooth:lineSmooth:Hint,GL_LINE_SMOOTH_HINT +:pointSmooth:pointSmooth:Hint,GL_POINT_SMOOTH_HINT +:polygonSmooth:polygonSmooth:Hint,GL_POLYGON_SMOOTH_HINT +:perspectiveCorrection:perspectiveCorrection:Hint,GL_PERSPECTIVE_CORRECTION_HINT +:fog:fog:Hint,GL_FOG_HINT +:clipVolumeClipping:clipVolumeClipping:Hint,GL_CLIP_VOLUME_CLIPPING_HINT_EXT +:generateMipmap:generateMipmap:Hint,GL_GENERATE_MIPMAP_HINT_SGIS +:textureCompression:textureCompression:Hint,GL_TEXTURE_COMPRESSION_HINT_ARB diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c new file mode 100644 index 00000000..61e73a1b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_init.c @@ -0,0 +1,892 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "cr_mem.h" +#include "cr_error.h" +#include "cr_spu.h" + +#include + +#ifdef CHROMIUM_THREADSAFE +static bool __isContextTLSInited = false; +CRtsd __contextTSD; +#else +CRContext *__currentContext = NULL; +#endif + +CRStateBits *__currentBits = NULL; +CRContext *g_pAvailableContexts[CR_MAX_CONTEXTS]; +uint32_t g_cContexts = 0; + +static CRSharedState *gSharedState=NULL; + +static CRContext *defaultContext = NULL; + +GLboolean g_bVBoxEnableDiffOnMakeCurrent = GL_TRUE; + + +/** + * Allocate a new shared state object. + * Contains texture objects, display lists, etc. + */ +static CRSharedState * +crStateAllocShared(void) +{ + CRSharedState *s = (CRSharedState *) crCalloc(sizeof(CRSharedState)); + if (s) { + s->textureTable = crAllocHashtable(); + s->dlistTable = crAllocHashtable(); + s->buffersTable = crAllocHashtable(); + s->fbTable = crAllocHashtable(); + s->rbTable = crAllocHashtable(); + s->refCount = 1; /* refcount is number of contexts using this state */ + s->saveCount = 0; + } + return s; +} + +/** + * Callback used for crFreeHashtable(). + */ +DECLEXPORT(void) +crStateDeleteTextureCallback(void *texObj) +{ +#ifndef IN_GUEST + diff_api.DeleteTextures(1, &((CRTextureObj *)texObj)->hwid); +#endif + crStateDeleteTextureObject((CRTextureObj *) texObj); +} + +typedef struct CR_STATE_RELEASEOBJ +{ + CRContext *pCtx; + CRSharedState *s; +} CR_STATE_RELEASEOBJ, *PCR_STATE_RELEASEOBJ; + +void crStateOnTextureUsageRelease(CRSharedState *pS, CRTextureObj *pObj) +{ + if (!pObj->pinned) + crHashtableDelete(pS->textureTable, pObj->id, crStateDeleteTextureCallback); + else + Assert(crHashtableSearch(pS->textureTable, pObj->id)); +} + +static void crStateReleaseTextureInternal(CRSharedState *pS, CRContext *pCtx, CRTextureObj *pObj) +{ + Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj) || pObj->pinned); + CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx); + if (CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)) + return; + + crStateOnTextureUsageRelease(pS, pObj); +} + +DECLEXPORT(void) crStateReleaseTexture(CRContext *pCtx, CRTextureObj *pObj) +{ + Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)); + CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx); + if (CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)) + return; + + if (!gSharedState) + { + WARN(("no global shared")); + return; + } + + crStateOnTextureUsageRelease(gSharedState, pObj); +} + +static void crStateReleaseBufferObjectInternal(CRSharedState *pS, CRContext *pCtx, CRBufferObject *pObj) +{ + Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)); + CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx); + if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)) + crHashtableDelete(pS->buffersTable, pObj->id, crStateFreeBufferObject); +} + +static void crStateReleaseFBOInternal(CRSharedState *pS, CRContext *pCtx, CRFramebufferObject *pObj) +{ + Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)); + CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx); + if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)) + crHashtableDelete(pS->fbTable, pObj->id, crStateFreeFBO); +} + +static void crStateReleaseRBOInternal(CRSharedState *pS, CRContext *pCtx, CRRenderbufferObject *pObj) +{ + Assert(CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)); + CR_STATE_SHAREDOBJ_USAGE_CLEAR(pObj, pCtx); + if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pObj)) + crHashtableDelete(pS->rbTable, pObj->id, crStateFreeRBO); +} + +static void ReleaseTextureCallback(unsigned long key, void *data1, void *data2) +{ + PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2; + CRTextureObj *pObj = (CRTextureObj *)data1; + (void)key; + crStateReleaseTextureInternal(pData->s, pData->pCtx, pObj); +} + +static void ReleaseBufferObjectCallback(unsigned long key, void *data1, void *data2) +{ + PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2; + CRBufferObject *pObj = (CRBufferObject *)data1; + (void)key; + crStateReleaseBufferObjectInternal(pData->s, pData->pCtx, pObj); +} + +static void ReleaseFBOCallback(unsigned long key, void *data1, void *data2) +{ + PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2; + CRFramebufferObject *pObj = (CRFramebufferObject *)data1; + (void)key; + crStateReleaseFBOInternal(pData->s, pData->pCtx, pObj); +} + +static void ReleaseRBOCallback(unsigned long key, void *data1, void *data2) +{ + PCR_STATE_RELEASEOBJ pData = (PCR_STATE_RELEASEOBJ)data2; + CRRenderbufferObject *pObj = (CRRenderbufferObject *)data1; + (void)key; + crStateReleaseRBOInternal(pData->s, pData->pCtx, pObj); +} + + +/** + * Decrement shared state's refcount and delete when it hits zero. + */ +#ifndef IN_GUEST +DECLEXPORT(void) crStateFreeShared(CRContext *pContext, CRSharedState *s) +#else +static void crStateFreeShared(CRContext *pContext, CRSharedState *s) +#endif +{ + int32_t refCount = ASMAtomicDecS32(&s->refCount); + + Assert(refCount >= 0); + if (refCount <= 0) { + if (s==gSharedState) + { + gSharedState = NULL; + } + crFreeHashtable(s->textureTable, crStateDeleteTextureCallback); + crFreeHashtable(s->dlistTable, crFree); /* call crFree for each entry */ + crFreeHashtable(s->buffersTable, crStateFreeBufferObject); + crFreeHashtable(s->fbTable, crStateFreeFBO); + crFreeHashtable(s->rbTable, crStateFreeRBO); + crFree(s); + } + else if (pContext) + { + /* evaluate usage bits*/ + CR_STATE_RELEASEOBJ CbData; + CbData.pCtx = pContext; + CbData.s = s; + crHashtableWalk(s->textureTable, ReleaseTextureCallback, &CbData); + crHashtableWalk(s->buffersTable, ReleaseBufferObjectCallback , &CbData); + crHashtableWalk(s->fbTable, ReleaseFBOCallback, &CbData); + crHashtableWalk(s->rbTable, ReleaseRBOCallback, &CbData); + } +} + +#ifndef IN_GUEST + +DECLEXPORT(CRSharedState *) crStateGlobalSharedAcquire(void) +{ + if (!gSharedState) + { + crWarning("No Global Shared State!"); + return NULL; + } + ASMAtomicIncS32(&gSharedState->refCount); + return gSharedState; +} + +DECLEXPORT(void) crStateGlobalSharedRelease(void) +{ + crStateFreeShared(NULL, gSharedState); +} + +#endif /* IN_GUEST */ + +DECLEXPORT(void) STATE_APIENTRY +crStateShareContext(GLboolean value) +{ + CRContext *pCtx = GetCurrentContext(); + CRASSERT(pCtx && pCtx->shared); + + if (value) + { + if (pCtx->shared == gSharedState) + { + return; + } + + crDebug("Context(%i) shared", pCtx->id); + + if (!gSharedState) + { + gSharedState = pCtx->shared; + } + else + { + crStateFreeShared(pCtx, pCtx->shared); + pCtx->shared = gSharedState; + ASMAtomicIncS32(&gSharedState->refCount); + } + } + else + { + if (pCtx->shared != gSharedState) + { + return; + } + + crDebug("Context(%i) unshared", pCtx->id); + + if (gSharedState->refCount==1) + { + gSharedState = NULL; + } + else + { + pCtx->shared = crStateAllocShared(); + pCtx->shared->id = pCtx->id; + crStateFreeShared(pCtx, gSharedState); + } + } +} + +DECLEXPORT(void) STATE_APIENTRY +crStateShareLists(CRContext *pContext1, CRContext *pContext2) +{ + CRASSERT(pContext1->shared); + CRASSERT(pContext2->shared); + + if (pContext2->shared == pContext1->shared) + { + return; + } + + crStateFreeShared(pContext1, pContext1->shared); + pContext1->shared = pContext2->shared; + ASMAtomicIncS32(&pContext2->shared->refCount); +} + +DECLEXPORT(GLboolean) STATE_APIENTRY +crStateContextIsShared(CRContext *pCtx) +{ + return pCtx->shared==gSharedState; +} + +DECLEXPORT(void) STATE_APIENTRY +crStateSetSharedContext(CRContext *pCtx) +{ + if (gSharedState) + { + crWarning("crStateSetSharedContext: shared is being changed from %p to %p", gSharedState, pCtx->shared); + } + + gSharedState = pCtx->shared; +} + +#ifdef CHROMIUM_THREADSAFE +static void +crStateFreeContext(CRContext *ctx); +static DECLCALLBACK(void) crStateContextDtor(void *pvCtx) +{ + crStateFreeContext((CRContext*)pvCtx); +} +#endif + +/* + * Helper for crStateCreateContext, below. + */ +static CRContext * +crStateCreateContextId(int i, const CRLimitsState *limits, GLint visBits, CRContext *shareCtx) +{ + CRContext *ctx; + int j; + int node32 = i >> 5; + int node = i & 0x1f; + (void)limits; + + if (g_pAvailableContexts[i] != NULL) + { + crWarning("trying to create context with used id"); + return NULL; + } + + ctx = (CRContext *) crCalloc( sizeof( *ctx ) ); + if (!ctx) + { + crWarning("failed to allocate context"); + return NULL; + } + g_pAvailableContexts[i] = ctx; + ++g_cContexts; + CRASSERT(g_cContexts < RT_ELEMENTS(g_pAvailableContexts)); + ctx->id = i; +#ifdef CHROMIUM_THREADSAFE + VBoxTlsRefInit(ctx, crStateContextDtor); +#endif + ctx->flush_func = NULL; + for (j=0;jbitid[j] = (1 << node); + } else { + ctx->bitid[j] = 0; + } + ctx->neg_bitid[j] = ~(ctx->bitid[j]); + } + + if (shareCtx) { + CRASSERT(shareCtx->shared); + ctx->shared = shareCtx->shared; + ASMAtomicIncS32(&ctx->shared->refCount); + } + else { + ctx->shared = crStateAllocShared(); + ctx->shared->id = ctx->id; + } + + /* use Chromium's OpenGL defaults */ + crStateLimitsInit( &(ctx->limits) ); + crStateExtensionsInit( &(ctx->limits), &(ctx->extensions) ); + + crStateBufferObjectInit( ctx ); /* must precede client state init! */ + crStateClientInit( ctx ); + + crStateBufferInit( ctx ); + crStateCurrentInit( ctx ); + crStateEvaluatorInit( ctx ); + crStateFogInit( ctx ); + crStateHintInit( ctx ); + crStateLightingInit( ctx ); + crStateLineInit( ctx ); + crStateListsInit( ctx ); + crStateMultisampleInit( ctx ); + crStateOcclusionInit( ctx ); + crStatePixelInit( ctx ); + crStatePolygonInit( ctx ); + crStatePointInit( ctx ); + crStateProgramInit( ctx ); + crStateRegCombinerInit( ctx ); + crStateStencilInit( ctx ); + crStateTextureInit( ctx ); + crStateTransformInit( ctx ); + crStateViewportInit ( ctx ); + crStateFramebufferObjectInit(ctx); + crStateGLSLInit(ctx); + + /* This has to come last. */ + crStateAttribInit( &(ctx->attrib) ); + + ctx->renderMode = GL_RENDER; + + /* Initialize values that depend on the visual mode */ + if (visBits & CR_DOUBLE_BIT) { + ctx->limits.doubleBuffer = GL_TRUE; + } + if (visBits & CR_RGB_BIT) { + ctx->limits.redBits = 8; + ctx->limits.greenBits = 8; + ctx->limits.blueBits = 8; + if (visBits & CR_ALPHA_BIT) { + ctx->limits.alphaBits = 8; + } + } + else { + ctx->limits.indexBits = 8; + } + if (visBits & CR_DEPTH_BIT) { + ctx->limits.depthBits = 24; + } + if (visBits & CR_STENCIL_BIT) { + ctx->limits.stencilBits = 8; + } + if (visBits & CR_ACCUM_BIT) { + ctx->limits.accumRedBits = 16; + ctx->limits.accumGreenBits = 16; + ctx->limits.accumBlueBits = 16; + if (visBits & CR_ALPHA_BIT) { + ctx->limits.accumAlphaBits = 16; + } + } + if (visBits & CR_STEREO_BIT) { + ctx->limits.stereo = GL_TRUE; + } + if (visBits & CR_MULTISAMPLE_BIT) { + ctx->limits.sampleBuffers = 1; + ctx->limits.samples = 4; + ctx->multisample.enabled = GL_TRUE; + } + + if (visBits & CR_OVERLAY_BIT) { + ctx->limits.level = 1; + } + + return ctx; +} + +/** @todo crStateAttribDestroy*/ +static void +crStateFreeContext(CRContext *ctx) +{ +#ifndef DEBUG_misha + CRASSERT(g_pAvailableContexts[ctx->id] == ctx); +#endif + if (g_pAvailableContexts[ctx->id] == ctx) + { + g_pAvailableContexts[ctx->id] = NULL; + --g_cContexts; + CRASSERT(g_cContexts < RT_ELEMENTS(g_pAvailableContexts)); + } + else + { +#ifndef DEBUG_misha + crWarning("freeing context %p, id(%d) not being in the context list", ctx, ctx->id); +#endif + } + + crStateClientDestroy( ctx ); + crStateLimitsDestroy( &(ctx->limits) ); + crStateBufferObjectDestroy( ctx ); + crStateEvaluatorDestroy( ctx ); + crStateListsDestroy( ctx ); + crStateLightingDestroy( ctx ); + crStateOcclusionDestroy( ctx ); + crStateProgramDestroy( ctx ); + crStateTextureDestroy( ctx ); + crStateTransformDestroy( ctx ); + crStateFreeShared(ctx, ctx->shared); + crStateFramebufferObjectDestroy(ctx); + crStateGLSLDestroy(ctx); + if (ctx->buffer.pFrontImg) crFree(ctx->buffer.pFrontImg); + if (ctx->buffer.pBackImg) crFree(ctx->buffer.pBackImg); + crFree( ctx ); +} + +#ifdef CHROMIUM_THREADSAFE +# ifndef RT_OS_WINDOWS +static void crStateThreadTlsDtor(void *pvValue) +{ + CRContext *pCtx = (CRContext*)pvValue; + VBoxTlsRefRelease(pCtx); +} +# endif +#endif + +/* + * Allocate the state (dirty) bits data structures. + * This should be called before we create any contexts. + * We'll also create the default/NULL context at this time and make + * it the current context by default. This means that if someone + * tries to set GL state before calling MakeCurrent() they'll be + * modifying the default state object, and not segfaulting on a NULL + * pointer somewhere. + */ +void crStateInit(void) +{ + unsigned int i; + + /* Purely initialize the context bits */ + if (!__currentBits) { + __currentBits = (CRStateBits *) crCalloc( sizeof(CRStateBits) ); + crStateClientInitBits( &(__currentBits->client) ); + crStateLightingInitBits( &(__currentBits->lighting) ); + } else + { +#ifndef DEBUG_misha + crWarning("State tracker is being re-initialized..\n"); +#endif + } + + for (i=0;iclient)); + crStateLightingDestroyBits(&(__currentBits->lighting)); + crFree(__currentBits); + __currentBits = NULL; + } + + SetCurrentContext(NULL); + + for (i = CR_MAX_CONTEXTS-1; i >= 0; i--) + { + if (g_pAvailableContexts[i]) + { +#ifdef CHROMIUM_THREADSAFE + if (VBoxTlsRefIsFunctional(g_pAvailableContexts[i])) + VBoxTlsRefRelease(g_pAvailableContexts[i]); +#else + crStateFreeContext(g_pAvailableContexts[i]); +#endif + } + } + + /* default context was stored in g_pAvailableContexts[0], so it was destroyed already */ + defaultContext = NULL; + + +#ifdef CHROMIUM_THREADSAFE + crFreeTSD(&__contextTSD); + __isContextTLSInited = 0; +#endif +} + +/* + * Notes on context switching and the "default context". + * + * See the paper "Tracking Graphics State for Networked Rendering" + * by Ian Buck, Greg Humphries and Pat Hanrahan for background + * information about how the state tracker and context switching + * works. + * + * When we make a new context current, we call crStateSwitchContext() + * in order to transform the 'from' context into the 'to' context + * (i.e. the old context to the new context). The transformation + * is accomplished by calling GL functions through the 'diff_api' + * so that the downstream GL machine (represented by the __currentContext + * structure) is updated to reflect the new context state. Finally, + * we point __currentContext to the new context. + * + * A subtle problem we have to deal with is context destruction. + * This issue arose while testing with Glean. We found that when + * the currently bound context was getting destroyed that state + * tracking was incorrect when a subsequent new context was activated. + * In DestroyContext, the __hwcontext was being set to NULL and effectively + * going away. Later in MakeCurrent we had no idea what the state of the + * downstream GL machine was (since __hwcontext was gone). This meant + * we had nothing to 'diff' against and the downstream GL machine was + * in an unknown state. + * + * The solution to this problem is the "default/NULL" context. The + * default context is created the first time CreateContext is called + * and is never freed. Whenever we get a crStateMakeCurrent(NULL) call + * or destroy the currently bound context in crStateDestroyContext() + * we call crStateSwitchContext() to switch to the default context and + * then set the __currentContext pointer to point to the default context. + * This ensures that the dirty bits are updated and the diff_api functions + * are called to keep the downstream GL machine in a known state. + * Finally, the __hwcontext variable is no longer needed now. + * + * Yeah, this is kind of a mind-bender, but it really solves the problem + * pretty cleanly. + * + * -Brian + */ + + +CRContext * +crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share) +{ + return crStateCreateContextEx(limits, visBits, share, -1); +} + +CRContext * +crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID) +{ + /* Must have created the default context via crStateInit() first */ + CRASSERT(defaultContext); + + if (presetID>0) + { + if(g_pAvailableContexts[presetID]) + { + crWarning("requesting to create context with already allocated id"); + return NULL; + } + } + else + { + int i; + + for (i = 1 ; i < CR_MAX_CONTEXTS ; i++) + { + if (!g_pAvailableContexts[i]) + { + presetID = i; + break; + } + } + + if (presetID<=0) + { + crError( "Out of available contexts in crStateCreateContexts (max %d)", + CR_MAX_CONTEXTS ); + /* never get here */ + return NULL; + } + } + + return crStateCreateContextId(presetID, limits, visBits, share); +} + +void crStateDestroyContext( CRContext *ctx ) +{ + CRContext *current = GetCurrentContext(); + + if (current == ctx) { + /* destroying the current context - have to be careful here */ + CRASSERT(defaultContext); + /* Check to see if the differencer exists first, + we may not have one, aka the packspu */ + if (diff_api.AlphaFunc) + crStateSwitchContext(current, defaultContext); +#ifdef CHROMIUM_THREADSAFE + SetCurrentContext(defaultContext); +#else + __currentContext = defaultContext; +#endif + /* ensure matrix state is also current */ + crStateMatrixMode(defaultContext->transform.matrixMode); + } + +#ifdef CHROMIUM_THREADSAFE + VBoxTlsRefMarkDestroy(ctx); +# ifdef IN_GUEST + if (VBoxTlsRefCountGet(ctx) > 1 && ctx->shared == gSharedState) + { + /* we always need to free the global shared state to prevent the situation when guest thinks the shared objects are still valid, while host destroys them */ + crStateFreeShared(ctx, ctx->shared); + ctx->shared = crStateAllocShared(); + } +# endif + VBoxTlsRefRelease(ctx); +#else + crStateFreeContext(ctx); +#endif +} + +GLboolean crStateEnableDiffOnMakeCurrent(GLboolean fEnable) +{ + GLboolean bOld = g_bVBoxEnableDiffOnMakeCurrent; + g_bVBoxEnableDiffOnMakeCurrent = fEnable; + return bOld; +} + +void crStateMakeCurrent( CRContext *ctx ) +{ + CRContext *current = GetCurrentContext(); + CRContext *pLocalCtx = ctx; + + if (pLocalCtx == NULL) + pLocalCtx = defaultContext; + + if (current == pLocalCtx) + return; /* no-op */ + + CRASSERT(pLocalCtx); + + if (g_bVBoxEnableDiffOnMakeCurrent && current) { + /* Check to see if the differencer exists first, + we may not have one, aka the packspu */ + if (diff_api.AlphaFunc) + crStateSwitchContext( current, pLocalCtx ); + } + +#ifdef CHROMIUM_THREADSAFE + SetCurrentContext(pLocalCtx); +#else + __currentContext = pLocalCtx; +#endif + + /* ensure matrix state is also current */ + crStateMatrixMode(pLocalCtx->transform.matrixMode); +} + + +/* + * As above, but don't call crStateSwitchContext(). + */ +static void crStateSetCurrentEx( CRContext *ctx, GLboolean fCleanupDefault ) +{ + CRContext *current = GetCurrentContext(); + CRContext *pLocalCtx = ctx; + + if (pLocalCtx == NULL && !fCleanupDefault) + pLocalCtx = defaultContext; + + if (current == pLocalCtx) + return; /* no-op */ + +#ifdef CHROMIUM_THREADSAFE + SetCurrentContext(pLocalCtx); +#else + __currentContext = pLocalCtx; +#endif + + if (pLocalCtx) + { + /* ensure matrix state is also current */ + crStateMatrixMode(pLocalCtx->transform.matrixMode); + } +} + +void crStateSetCurrent( CRContext *ctx ) +{ + crStateSetCurrentEx( ctx, GL_FALSE ); +} + +void crStateCleanupCurrent() +{ + crStateSetCurrentEx( NULL, GL_TRUE ); +} + + +CRContext *crStateGetCurrent(void) +{ + return GetCurrentContext(); +} + + +void crStateUpdateColorBits(void) +{ + /* This is a hack to force updating the 'current' attribs */ + CRStateBits *sb = GetCurrentBits(); + FILLDIRTY(sb->current.dirty); + FILLDIRTY(sb->current.vertexAttrib[VERT_ATTRIB_COLOR0]); +} + + +void STATE_APIENTRY +crStateChromiumParameteriCR( GLenum target, GLint value ) +{ + /* This no-op function helps smooth code-gen */ + (void)target; (void)value; +} + +void STATE_APIENTRY +crStateChromiumParameterfCR( GLenum target, GLfloat value ) +{ + /* This no-op function helps smooth code-gen */ + (void)target; (void)value; +} + +void STATE_APIENTRY +crStateChromiumParametervCR( GLenum target, GLenum type, GLsizei count, const GLvoid *values ) +{ + /* This no-op function helps smooth code-gen */ + (void)target; (void)type; (void)count; (void)values; +} + +void STATE_APIENTRY +crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values ) +{ + /* This no-op function helps smooth code-gen */ + (void)target; (void)index; (void)type; (void)count; (void)values; +} + +void STATE_APIENTRY +crStateReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid *pixels ) +{ + /* This no-op function helps smooth code-gen */ + (void)x; (void)y; (void)width; (void)height; (void)format; (void)type; (void)pixels; +} + +void crStateVBoxDetachThread(void) +{ + /* release the context ref so that it can be freed */ + SetCurrentContext(NULL); +} + + +void crStateVBoxAttachThread(void) +{ +} + +#if 0 /* who's refering to these? */ + +GLint crStateVBoxCreateContext( GLint con, const char * dpyName, GLint visual, GLint shareCtx ) +{ + (void)con; (void)dpyName; (void)visual; (void)shareCtx; + return 0; +} + +GLint crStateVBoxWindowCreate( GLint con, const char *dpyName, GLint visBits ) +{ + (void)con; (void)dpyName; (void)visBits; + return 0; +} + +void crStateVBoxWindowDestroy( GLint con, GLint window ) +{ + (void)con; (void)window; +} + +GLint crStateVBoxConCreate(struct VBOXUHGSMI *pHgsmi) +{ + (void)pHgsmi; + return 0; +} + +void crStateVBoxConDestroy(GLint con) +{ + (void)con; +} + +void crStateVBoxConFlush(GLint con) +{ + (void)con; +} + +#endif /* unused? */ diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_internals.h b/src/VBox/GuestHost/OpenGL/state_tracker/state_internals.h new file mode 100644 index 00000000..6610ca8a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_internals.h @@ -0,0 +1,29 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifndef STATE_INTERNALS_H +#define STATE_INTERNALS_H + +#include "cr_spu.h" +#include "state/cr_statetypes.h" + +/* Set the flush_func to NULL *before* it's called, so that we can + * call state functions from within flush without infinite recursion. + * Yucky, but "necessary" for color material. */ + +#define FLUSH() \ + if (g->flush_func != NULL) \ + { \ + CRStateFlushFunc cached_ff = g->flush_func; \ + g->flush_func = NULL; \ + cached_ff( g->flush_arg ); \ + } + +typedef void (SPU_APIENTRY *glAble)(GLenum); + +#define GLCLIENT_BIT_ALLOC 1024 + +#endif diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py new file mode 100755 index 00000000..35a3815a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.py @@ -0,0 +1,75 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys, re, string +import apiutil + + +line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s+(.*)\s*$') +extensions_line_re = re.compile(r'^(\S+)\s+(GL_\S+)\s(\S+)\s+(.*)\s*$') + +params = {} +extended_params = {} + +input = open( sys.argv[2]+"/state_isenabled.txt", 'r' ) +for line in input.readlines(): + match = line_re.match( line ) + if match: + type = match.group(1) + pname = match.group(2) + fields = match.group(3).split() + params[pname] = ( type, fields ) + +input = open( sys.argv[2]+"/state_extensions_isenabled.txt", 'r' ) +for line in input.readlines(): + match = extensions_line_re.match( line ) + if match: + type = match.group(1) + pname = match.group(2) + ifdef = match.group(3) + fields = match.group(4).split() + extended_params[pname] = ( type, ifdef, fields ) + +apiutil.CopyrightC() + +print(""" +/* DO NOT EDIT - THIS FILE GENERATED BY THE state_isenabled.py SCRIPT */ +#include +#include + +#include "state.h" +#include "state/cr_statetypes.h" + +GLboolean STATE_APIENTRY crStateIsEnabled( GLenum pname ) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glGet called in Begin/End"); + return 0; + } + + switch (pname) { +""") + +for pname in sorted(params.keys()): + print("\tcase %s:" % pname) + print("\t\treturn %s;" % params[pname][1][0]) + +for pname in sorted(extended_params.keys()): + (srctype,ifdef,fields) = extended_params[pname] + ext = ifdef[3:] # the extension name with the "GL_" prefix removed + ext = ifdef + print('#ifdef CR_%s' % ext) + print("\tcase %s:" % pname) + print("\t\treturn %s;" % extended_params[pname][2][0]) + print('#endif /* CR_%s */' % ext) +print("\tdefault:") +print("\t\tcrStateError(__LINE__, __FILE__, GL_INVALID_ENUM, \"glIsEnabled: Unknown enum: %d\", pname);") +print("\t\treturn 0;") +print("\t}") +print("}") diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.txt new file mode 100644 index 00000000..4e7435dd --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_isenabled.txt @@ -0,0 +1,76 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +GLboolean GL_ALPHA_TEST g->buffer.alphaTest +GLboolean GL_AUTO_NORMAL g->eval.autoNormal +GLboolean GL_BLEND g->buffer.blend +GLboolean GL_CULL_FACE g->polygon.cullFace +GLboolean GL_COLOR_MATERIAL GL_FALSE +GLboolean GL_CLIP_PLANE0 g->transform.clip[0] +GLboolean GL_CLIP_PLANE1 g->transform.clip[1] +GLboolean GL_CLIP_PLANE2 g->transform.clip[2] +GLboolean GL_CLIP_PLANE3 g->transform.clip[3] +GLboolean GL_CLIP_PLANE4 g->transform.clip[4] +GLboolean GL_CLIP_PLANE5 g->transform.clip[5] +GLboolean GL_COLOR_LOGIC_OP g->buffer.logicOp +GLboolean GL_DEPTH_TEST g->buffer.depthTest +GLboolean GL_DEPTH_WRITEMASK g->buffer.depthMask +GLboolean GL_DITHER g->buffer.dither +GLboolean GL_FOG g->fog.enable +GLboolean GL_INDEX_LOGIC_OP g->buffer.indexLogicOp +GLboolean GL_LIGHT0 g->lighting.light[0].enable +GLboolean GL_LIGHT1 g->lighting.light[1].enable +GLboolean GL_LIGHT2 g->lighting.light[2].enable +GLboolean GL_LIGHT3 g->lighting.light[3].enable +GLboolean GL_LIGHT4 g->lighting.light[4].enable +GLboolean GL_LIGHT5 g->lighting.light[5].enable +GLboolean GL_LIGHT6 g->lighting.light[6].enable +GLboolean GL_LIGHT7 g->lighting.light[7].enable +GLboolean GL_LIGHTING g->lighting.lighting +GLboolean GL_LINE_SMOOTH g->line.lineSmooth +GLboolean GL_LINE_STIPPLE g->line.lineStipple +GLboolean GL_MAP1_COLOR_4 g->eval.enable1D[GL_MAP1_COLOR_4-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_INDEX g->eval.enable1D[GL_MAP1_INDEX-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_NORMAL g->eval.enable1D[GL_MAP1_NORMAL-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_1 g->eval.enable1D[GL_MAP1_TEXTURE_COORD_1-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_2 g->eval.enable1D[GL_MAP1_TEXTURE_COORD_2-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_3 g->eval.enable1D[GL_MAP1_TEXTURE_COORD_3-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_TEXTURE_COORD_4 g->eval.enable1D[GL_MAP1_TEXTURE_COORD_4-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_VERTEX_3 g->eval.enable1D[GL_MAP1_VERTEX_3-GL_MAP1_COLOR_4] +GLboolean GL_MAP1_VERTEX_4 g->eval.enable1D[GL_MAP1_VERTEX_4-GL_MAP1_COLOR_4] +GLboolean GL_MAP2_COLOR_4 g->eval.enable2D[GL_MAP2_COLOR_4-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_INDEX g->eval.enable2D[GL_MAP2_INDEX-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_NORMAL g->eval.enable2D[GL_MAP2_NORMAL-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_1 g->eval.enable2D[GL_MAP2_TEXTURE_COORD_1-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_2 g->eval.enable2D[GL_MAP2_TEXTURE_COORD_2-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_3 g->eval.enable2D[GL_MAP2_TEXTURE_COORD_3-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_TEXTURE_COORD_4 g->eval.enable2D[GL_MAP2_TEXTURE_COORD_4-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_VERTEX_3 g->eval.enable2D[GL_MAP2_VERTEX_3-GL_MAP2_COLOR_4] +GLboolean GL_MAP2_VERTEX_4 g->eval.enable2D[GL_MAP2_VERTEX_4-GL_MAP2_COLOR_4] +GLboolean GL_PACK_SWAP_BYTES g->client.pack.swapBytes +GLboolean GL_PACK_LSB_FIRST g->client.pack.psLSBFirst +GLboolean GL_POINT_SMOOTH g->point.pointSmooth +GLboolean GL_POLYGON_SMOOTH g->polygon.polygonSmooth +GLboolean GL_POLYGON_STIPPLE g->polygon.polygonStipple +GLboolean GL_POLYGON_OFFSET_POINT g->polygon.polygonOffsetPoint +GLboolean GL_POLYGON_OFFSET_LINE g->polygon.polygonOffsetLine +GLboolean GL_POLYGON_OFFSET_FILL g->polygon.polygonOffsetFill +GLboolean GL_NORMALIZE g->transform.normalize +GLboolean GL_RGBA_MODE GL_TRUE +GLboolean GL_SCISSOR_TEST g->viewport.scissorTest +GLboolean GL_STENCIL_TEST g->stencil.stencilTest +GLboolean GL_TEXTURE_GEN_S g->texture.unit[g->texture.curTextureUnit].textureGen.s +GLboolean GL_TEXTURE_GEN_T g->texture.unit[g->texture.curTextureUnit].textureGen.t +GLboolean GL_TEXTURE_GEN_R g->texture.unit[g->texture.curTextureUnit].textureGen.r +GLboolean GL_TEXTURE_GEN_Q g->texture.unit[g->texture.curTextureUnit].textureGen.q +GLboolean GL_TEXTURE_1D g->texture.unit[g->texture.curTextureUnit].enabled1D +GLboolean GL_TEXTURE_2D g->texture.unit[g->texture.curTextureUnit].enabled2D +# GLboolean GL_TEXTURE_3D g->texture.unit[g->texture.curTextureUnit].enabled3D +GLboolean GL_TEXTURE_CUBE_MAP_ARB g->texture.unit[g->texture.curTextureUnit].enabledCubeMap + +GLboolean GL_UNPACK_SWAP_BYTES g->client.unpack.swapBytes +GLboolean GL_UNPACK_LSB_FIRST g->client.unpack.psLSBFirst +GLboolean GL_REGISTER_COMBINERS_NV g->regcombiner.enabledRegCombiners +GLboolean GL_PER_STAGE_CONSTANTS_NV g->regcombiner.enabledPerStageConstants +GLboolean GL_COLOR_SUM_EXT g->lighting.colorSumEXT diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c new file mode 100644 index 00000000..bfea8559 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.c @@ -0,0 +1,1212 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "cr_mem.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateLightingInitBits (CRLightingBits *l) +{ + l->light = (CRLightBits *) crCalloc (sizeof(*(l->light)) * CR_MAX_LIGHTS); +} + +void crStateLightingDestroyBits (CRLightingBits *l) +{ + crFree(l->light); +} + +void crStateLightingDestroy (CRContext *ctx) +{ + crFree(ctx->lighting.light); +} + +void crStateLightingInit (CRContext *ctx) +{ + CRLightingState *l = &ctx->lighting; + CRStateBits *sb = GetCurrentBits(); + CRLightingBits *lb = &(sb->lighting); + int i; + GLvectorf zero_vector = {0.0f, 0.0f, 0.0f, 1.0f}; + GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 1.0f}; + GLcolorf ambient_color = {0.2f, 0.2f, 0.2f, 1.0f}; + GLcolorf diffuse_color = {0.8f, 0.8f, 0.8f, 1.0f}; + GLvectorf spot_vector = {0.0f, 0.0f, -1.0f, 0.0f}; + GLcolorf one_color = {1.0f, 1.0f, 1.0f, 1.0f}; + + l->lighting = GL_FALSE; + RESET(lb->enable, ctx->bitid); + l->colorMaterial = GL_FALSE; + RESET(lb->colorMaterial, ctx->bitid); + l->shadeModel = GL_SMOOTH; + RESET(lb->shadeModel, ctx->bitid); + l->colorMaterialMode = GL_AMBIENT_AND_DIFFUSE; + l->colorMaterialFace = GL_FRONT_AND_BACK; + l->ambient[0] = ambient_color; + l->diffuse[0] = diffuse_color; + l->specular[0] = zero_color; + l->emission[0] = zero_color; + l->shininess[0] = 0.0f; + l->indexes[0][0] = 0; + l->indexes[0][1] = 1; + l->indexes[0][2] = 1; + l->ambient[1] = ambient_color; + l->diffuse[1] = diffuse_color; + l->specular[1] = zero_color; + l->emission[1] = zero_color; + l->shininess[1] = 0.0f; + l->indexes[1][0] = 0; + l->indexes[1][1] = 1; + l->indexes[1][2] = 1; + RESET(lb->material, ctx->bitid); + l->lightModelAmbient = ambient_color; + l->lightModelLocalViewer = GL_FALSE; + l->lightModelTwoSide = GL_FALSE; +#if defined(CR_EXT_separate_specular_color) + l->lightModelColorControlEXT = GL_SINGLE_COLOR_EXT; +#elif defined(CR_OPENGL_VERSION_1_2) + l->lightModelColorControlEXT = GL_SINGLE_COLOR; +#endif + RESET(lb->lightModel, ctx->bitid); +#if defined(CR_EXT_secondary_color) + l->colorSumEXT = GL_FALSE; +#endif + l->light = (CRLight *) crCalloc (sizeof (*(l->light)) * CR_MAX_LIGHTS); + + for (i=0; ilight + i; + l->light[i].enable = GL_FALSE; + RESET(ltb->enable, ctx->bitid); + l->light[i].ambient = zero_color; + RESET(ltb->ambient, ctx->bitid); + l->light[i].diffuse = zero_color; + RESET(ltb->diffuse, ctx->bitid); + l->light[i].specular = zero_color; + RESET(ltb->specular, ctx->bitid); + l->light[i].position = zero_vector; + l->light[i].position.z = 1.0f; + l->light[i].position.w = 0.0f; + l->light[i].objPosition = l->light[i].position; + RESET(ltb->position, ctx->bitid); + l->light[i].spotDirection = spot_vector; + l->light[i].spotExponent = 0.0f; + l->light[i].spotCutoff = 180.0f; + RESET(ltb->spot, ctx->bitid); + l->light[i].constantAttenuation= 1.0f; + l->light[i].linearAttenuation= 0.0f; + l->light[i].quadraticAttenuation = 0.0f; + RESET(ltb->attenuation, ctx->bitid); + RESET(ltb->dirty, ctx->bitid); + } + l->light[0].diffuse = one_color; + l->light[0].specular = one_color; + + RESET(lb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateShadeModel (GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRStateBits *sb = GetCurrentBits(); + CRLightingBits *lb = &(sb->lighting); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "ShadeModel called in begin/end"); + return; + } + + FLUSH(); + + if (mode != GL_SMOOTH && + mode != GL_FLAT) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "ShadeModel: Bogus mode 0x%x", mode); + return; + } + + l->shadeModel = mode; + DIRTY(lb->shadeModel, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateColorMaterial (GLenum face, GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRStateBits *sb = GetCurrentBits(); + CRLightingBits *lb = &(sb->lighting); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "ColorMaterial called in begin/end"); + return; + } + + FLUSH(); + + if (face != GL_FRONT && + face != GL_BACK && + face != GL_FRONT_AND_BACK) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "ColorMaterial: Bogus face &d", face); + return; + } + + if (mode != GL_EMISSION && + mode != GL_AMBIENT && + mode != GL_DIFFUSE && + mode != GL_SPECULAR && + mode != GL_AMBIENT_AND_DIFFUSE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "ColorMaterial: Bogus mode &d", mode); + return; + } + + l->colorMaterialFace = face; + l->colorMaterialMode = mode; + /* XXX this could conceivably be needed here (BP) */ + /* + crStateColorMaterialRecover(); + */ + DIRTY(lb->colorMaterial, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateLightModelfv (GLenum pname, const GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRStateBits *sb = GetCurrentBits(); + CRLightingBits *lb = &(sb->lighting); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "LightModelfv called in begin/end"); + return; + } + + FLUSH(); + + switch (pname) + { + case GL_LIGHT_MODEL_LOCAL_VIEWER: + l->lightModelLocalViewer = (GLboolean) (*param==0.0f?GL_FALSE:GL_TRUE); + break; + case GL_LIGHT_MODEL_TWO_SIDE: + l->lightModelTwoSide = (GLboolean) (*param==0.0f?GL_FALSE:GL_TRUE); + break; + case GL_LIGHT_MODEL_AMBIENT: + l->lightModelAmbient.r = param[0]; + l->lightModelAmbient.g = param[1]; + l->lightModelAmbient.b = param[2]; + l->lightModelAmbient.a = param[3]; + break; +#if defined(CR_OPENGL_VERSION_1_2) + case GL_LIGHT_MODEL_COLOR_CONTROL: + if (param[0] == GL_SEPARATE_SPECULAR_COLOR || param[0] == GL_SINGLE_COLOR) + { + l->lightModelColorControlEXT = (GLenum) param[0]; + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModel: Invalid param for LIGHT_MODEL_COLOR_CONTROL: 0x%x", param[0]); + return; + } + break; +#else +#if defined(CR_EXT_separate_specular_color) + case GL_LIGHT_MODEL_COLOR_CONTROL_EXT: + if(g->extensions.EXT_separate_specular_color) + { + if (param[0] == GL_SEPARATE_SPECULAR_COLOR_EXT || param[0] == GL_SINGLE_COLOR_EXT) + { + l->lightModelColorControlEXT = (GLenum) param[0]; + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModel: Invalid param for LIGHT_MODEL_COLOR_CONTROL: 0x%x", param[0]); + return; + } + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModel( LIGHT_MODEL_COLOR_CONTROL, ...) - EXT_separate_specular_color is unavailable."); + return; + } + break; +#endif +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModelfv: Invalid pname: 0x%x", pname); + return; + } + DIRTY(lb->lightModel, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateLightModeliv (GLenum pname, const GLint *param) +{ + GLfloat f_param; + GLcolor f_color; +#ifndef CR_OPENGL_VERSION_1_2 + CRContext *g = GetCurrentContext(); +#endif + + switch (pname) + { + case GL_LIGHT_MODEL_LOCAL_VIEWER: + case GL_LIGHT_MODEL_TWO_SIDE: + f_param = (GLfloat) (*param); + crStateLightModelfv(pname, &f_param); + break; + case GL_LIGHT_MODEL_AMBIENT: + f_color.r = ((GLfloat)param[0])/CR_MAXINT; + f_color.g = ((GLfloat)param[1])/CR_MAXINT; + f_color.b = ((GLfloat)param[2])/CR_MAXINT; + f_color.a = ((GLfloat)param[3])/CR_MAXINT; + crStateLightModelfv(pname, (GLfloat *) &f_color); + break; +#if defined(CR_OPENGL_VERSION_1_2) + case GL_LIGHT_MODEL_COLOR_CONTROL: + f_param = (GLfloat) (*param); + crStateLightModelfv(pname, &f_param); + break; +#else +#ifdef CR_EXT_separate_specular_color + case GL_LIGHT_MODEL_COLOR_CONTROL_EXT: + if (g->extensions.EXT_separate_specular_color) { + f_param = (GLfloat) (*param); + crStateLightModelfv(pname, &f_param); + } else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModeliv(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, ...) - EXT_separate_specular_color not enabled!"); + return; + } + break; +#endif +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "LightModeliv: Invalid pname: 0x%x", pname); + return; + } +} + +void STATE_APIENTRY crStateLightModelf (GLenum pname, GLfloat param) +{ + crStateLightModelfv(pname, ¶m); +} + +void STATE_APIENTRY crStateLightModeli (GLenum pname, GLint param) +{ + GLfloat f_param = (GLfloat) param; + crStateLightModelfv(pname, &f_param); +} + +void STATE_APIENTRY crStateLightfv (GLenum light, GLenum pname, const GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRTransformState *t = &(g->transform); + CRLight *lt; + unsigned int i; + GLfloat x, y, z, w; + CRmatrix inv; + CRmatrix *mat; + CRStateBits *sb = GetCurrentBits(); + CRLightingBits *lb = &(sb->lighting); + CRLightBits *ltb; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glLightfv called in begin/end"); + return; + } + + FLUSH(); + + i = light - GL_LIGHT0; + if (i>=g->limits.maxLights) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLight: invalid light specified: 0x%x", light); + return; + } + + lt = l->light + i; + ltb = lb->light + i; + + switch (pname) + { + case GL_AMBIENT: + lt->ambient.r = param[0]; + lt->ambient.g = param[1]; + lt->ambient.b = param[2]; + lt->ambient.a = param[3]; + DIRTY(ltb->ambient, g->neg_bitid); + break; + case GL_DIFFUSE: + lt->diffuse.r = param[0]; + lt->diffuse.g = param[1]; + lt->diffuse.b = param[2]; + lt->diffuse.a = param[3]; + DIRTY(ltb->diffuse, g->neg_bitid); + break; + case GL_SPECULAR: + lt->specular.r = param[0]; + lt->specular.g = param[1]; + lt->specular.b = param[2]; + lt->specular.a = param[3]; + DIRTY(ltb->specular, g->neg_bitid); + break; + case GL_POSITION: + x = param[0]; + y = param[1]; + z = param[2]; + w = param[3]; + mat = t->modelViewStack.top; + lt->objPosition.x = x; + lt->objPosition.y = y; + lt->objPosition.z = z; + lt->objPosition.w = w; + + lt->position.x = mat->m00*x + mat->m10*y + mat->m20*z + mat->m30*w; + lt->position.y = mat->m01*x + mat->m11*y + mat->m21*z + mat->m31*w; + lt->position.z = mat->m02*x + mat->m12*y + mat->m22*z + mat->m32*w; + lt->position.w = mat->m03*x + mat->m13*y + mat->m23*z + mat->m33*w; + + DIRTY(ltb->position, g->neg_bitid); + break; + case GL_SPOT_DIRECTION: + lt->spotDirection.x = param[0]; + lt->spotDirection.y = param[1]; + lt->spotDirection.z = param[2]; + lt->spotDirection.w = 0.0f; + mat = t->modelViewStack.top; + + if (lt->objPosition.w != 0.0f) + { + lt->spotDirection.w = - ( ( lt->objPosition.x * lt->spotDirection.x + + lt->objPosition.y * lt->spotDirection.y + + lt->objPosition.z * lt->spotDirection.z ) / + lt->objPosition.w ); + } + + crMatrixInvertTranspose(&inv, mat); + crStateTransformXformPointMatrixf (&inv, &(lt->spotDirection)); + + DIRTY(ltb->spot, g->neg_bitid); + break; + case GL_SPOT_EXPONENT: + if (*param < 0.0f || *param > 180.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLight: spot exponent out of range: %f", *param); + return; + } + lt->spotExponent = *param; + DIRTY(ltb->spot, g->neg_bitid); + break; + case GL_SPOT_CUTOFF: + if ((*param < 0.0f || *param > 90.0f) && *param != 180.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLight: spot cutoff out of range: %f", *param); + return; + } + lt->spotCutoff = *param; + DIRTY(ltb->spot, g->neg_bitid); + break; + case GL_CONSTANT_ATTENUATION: + if (*param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLight: constant Attenuation negative: %f", *param); + return; + } + lt->constantAttenuation = *param; + DIRTY(ltb->attenuation, g->neg_bitid); + break; + case GL_LINEAR_ATTENUATION: + if (*param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLight: linear Attenuation negative: %f", *param); + return; + } + lt->linearAttenuation = *param; + DIRTY(ltb->attenuation, g->neg_bitid); + break; + case GL_QUADRATIC_ATTENUATION: + if (*param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLight: quadratic Attenuation negative: %f", *param); + return; + } + lt->quadraticAttenuation = *param; + DIRTY(ltb->attenuation, g->neg_bitid); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLight: invalid pname: 0x%x", pname); + return; + } + DIRTY(ltb->dirty, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateLightiv (GLenum light, GLenum pname, const GLint *param) +{ + GLfloat f_param; + GLcolor f_color; + GLvector f_vector; + + switch (pname) + { + case GL_AMBIENT: + case GL_DIFFUSE: + case GL_SPECULAR: + f_color.r = ((GLfloat)param[0])/CR_MAXINT; + f_color.g = ((GLfloat)param[1])/CR_MAXINT; + f_color.b = ((GLfloat)param[2])/CR_MAXINT; + f_color.a = ((GLfloat)param[3])/CR_MAXINT; + crStateLightfv(light, pname, (GLfloat *) &f_color); + break; + case GL_POSITION: + case GL_SPOT_DIRECTION: + f_vector.x = (GLfloat) param[0]; + f_vector.y = (GLfloat) param[1]; + f_vector.z = (GLfloat) param[2]; + f_vector.w = (GLfloat) param[3]; + crStateLightfv(light, pname, (GLfloat *) &f_vector); + break; + case GL_SPOT_EXPONENT: + case GL_SPOT_CUTOFF: + case GL_CONSTANT_ATTENUATION: + case GL_LINEAR_ATTENUATION: + case GL_QUADRATIC_ATTENUATION: + f_param = (GLfloat) (*param); + crStateLightfv(light, pname, &f_param); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glLight: invalid pname: 0x%x", pname); + return; + } +} + +void STATE_APIENTRY crStateLightf (GLenum light, GLenum pname, GLfloat param) +{ + crStateLightfv(light, pname, ¶m); +} + +void STATE_APIENTRY crStateLighti (GLenum light, GLenum pname, GLint param) +{ + GLfloat f_param = (GLfloat) param; + crStateLightfv(light, pname, &f_param); +} + +void STATE_APIENTRY crStateMaterialfv (GLenum face, GLenum pname, const GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRStateBits *sb = GetCurrentBits(); + CRLightingBits *lb = &(sb->lighting); + + if (!g->current.inBeginEnd) + { + FLUSH(); + } + + switch (pname) + { + case GL_AMBIENT : + switch (face) + { + case GL_FRONT: + l->ambient[0].r = param[0]; + l->ambient[0].g = param[1]; + l->ambient[0].b = param[2]; + l->ambient[0].a = param[3]; + break; + case GL_FRONT_AND_BACK: + l->ambient[0].r = param[0]; + l->ambient[0].g = param[1]; + l->ambient[0].b = param[2]; + l->ambient[0].a = param[3]; + RT_FALL_THRU(); + case GL_BACK: + l->ambient[1].r = param[0]; + l->ambient[1].g = param[1]; + l->ambient[1].b = param[2]; + l->ambient[1].a = param[3]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_AMBIENT_AND_DIFFUSE : + switch (face) + { + case GL_FRONT: + l->ambient[0].r = param[0]; + l->ambient[0].g = param[1]; + l->ambient[0].b = param[2]; + l->ambient[0].a = param[3]; + break; + case GL_FRONT_AND_BACK: + l->ambient[0].r = param[0]; + l->ambient[0].g = param[1]; + l->ambient[0].b = param[2]; + l->ambient[0].a = param[3]; + RT_FALL_THRU(); + case GL_BACK: + l->ambient[1].r = param[0]; + l->ambient[1].g = param[1]; + l->ambient[1].b = param[2]; + l->ambient[1].a = param[3]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad face: 0x%x", face); + return; + } + RT_FALL_THRU(); + case GL_DIFFUSE : + switch (face) + { + case GL_FRONT: + l->diffuse[0].r = param[0]; + l->diffuse[0].g = param[1]; + l->diffuse[0].b = param[2]; + l->diffuse[0].a = param[3]; + break; + case GL_FRONT_AND_BACK: + l->diffuse[0].r = param[0]; + l->diffuse[0].g = param[1]; + l->diffuse[0].b = param[2]; + l->diffuse[0].a = param[3]; + RT_FALL_THRU(); + case GL_BACK: + l->diffuse[1].r = param[0]; + l->diffuse[1].g = param[1]; + l->diffuse[1].b = param[2]; + l->diffuse[1].a = param[3]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_SPECULAR : + switch (face) + { + case GL_FRONT: + l->specular[0].r = param[0]; + l->specular[0].g = param[1]; + l->specular[0].b = param[2]; + l->specular[0].a = param[3]; + break; + case GL_FRONT_AND_BACK: + l->specular[0].r = param[0]; + l->specular[0].g = param[1]; + l->specular[0].b = param[2]; + l->specular[0].a = param[3]; + RT_FALL_THRU(); + case GL_BACK: + l->specular[1].r = param[0]; + l->specular[1].g = param[1]; + l->specular[1].b = param[2]; + l->specular[1].a = param[3]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_EMISSION : + switch (face) + { + case GL_FRONT: + l->emission[0].r = param[0]; + l->emission[0].g = param[1]; + l->emission[0].b = param[2]; + l->emission[0].a = param[3]; + break; + case GL_FRONT_AND_BACK: + l->emission[0].r = param[0]; + l->emission[0].g = param[1]; + l->emission[0].b = param[2]; + l->emission[0].a = param[3]; + RT_FALL_THRU(); + case GL_BACK: + l->emission[1].r = param[0]; + l->emission[1].g = param[1]; + l->emission[1].b = param[2]; + l->emission[1].a = param[3]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_SHININESS: + if (*param > 180.0f || *param < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glMaterialfv: param out of range: %f", param); + return; + } + + switch (face) + { + case GL_FRONT: + l->shininess[0] = *param; + break; + case GL_FRONT_AND_BACK: + l->shininess[0] = *param; + RT_FALL_THRU(); + case GL_BACK: + l->shininess[1] = *param; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_COLOR_INDEXES : + switch (face) + { + case GL_FRONT: + l->indexes[0][0] = (GLint) param[0]; + l->indexes[0][1] = (GLint) param[1]; + l->indexes[0][2] = (GLint) param[2]; + break; + case GL_FRONT_AND_BACK: + l->indexes[0][0] = (GLint) param[0]; + l->indexes[0][1] = (GLint) param[1]; + l->indexes[0][2] = (GLint) param[2]; + RT_FALL_THRU(); + case GL_BACK: + l->indexes[1][0] = (GLint) param[0]; + l->indexes[1][1] = (GLint) param[1]; + l->indexes[1][2] = (GLint) param[2]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad face: 0x%x", face); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialfv: bad pname: 0x%x", pname); + return; + } + DIRTY(lb->material, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateMaterialiv (GLenum face, GLenum pname, const GLint *param) +{ + GLfloat f_param; + GLcolor f_color; + + switch (pname) + { + case GL_AMBIENT : + case GL_AMBIENT_AND_DIFFUSE : + case GL_DIFFUSE : + case GL_SPECULAR : + case GL_EMISSION : + f_color.r = ((GLfloat) param[0]) / ((GLfloat) CR_MAXINT); + f_color.g = ((GLfloat) param[1]) / ((GLfloat) CR_MAXINT); + f_color.b = ((GLfloat) param[2]) / ((GLfloat) CR_MAXINT); + f_color.a = ((GLfloat) param[3]) / ((GLfloat) CR_MAXINT); + crStateMaterialfv(face, pname, (GLfloat *) &f_color); + break; + case GL_SHININESS: + f_param = (GLfloat) (*param); + crStateMaterialfv(face, pname, (GLfloat *) &f_param); + break; + case GL_COLOR_INDEXES : + f_param = (GLfloat) (*param); + crStateMaterialfv(face, pname, (GLfloat *) &f_param); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glMaterialiv: bad pname: 0x%x", pname); + return; + } +} + +void STATE_APIENTRY crStateMaterialf (GLenum face, GLenum pname, GLfloat param) +{ + crStateMaterialfv(face, pname, ¶m); +} + +void STATE_APIENTRY crStateMateriali (GLenum face, GLenum pname, GLint param) +{ + GLfloat f_param = (GLfloat) param; + crStateMaterialfv(face, pname, &f_param); +} + +void STATE_APIENTRY crStateGetLightfv (GLenum light, GLenum pname, GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRLight *lt; + unsigned int i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetLightfv called in begin/end"); + return; + } + + i = light - GL_LIGHT0; + if (i>=g->limits.maxLights) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetLight: invalid light specified: 0x%x", light); + return; + } + + lt = l->light + i; + + switch (pname) + { + case GL_AMBIENT: + param[0] = lt->ambient.r; + param[1] = lt->ambient.g; + param[2] = lt->ambient.b; + param[3] = lt->ambient.a; + break; + case GL_DIFFUSE: + param[0] = lt->diffuse.r; + param[1] = lt->diffuse.g; + param[2] = lt->diffuse.b; + param[3] = lt->diffuse.a; + break; + case GL_SPECULAR: + param[0] = lt->specular.r; + param[1] = lt->specular.g; + param[2] = lt->specular.b; + param[3] = lt->specular.a; + break; + case GL_POSITION: + param[0] = lt->position.x; + param[1] = lt->position.y; + param[2] = lt->position.z; + param[3] = lt->position.w; + break; + case GL_SPOT_DIRECTION: + param[0] = lt->spotDirection.x; + param[1] = lt->spotDirection.y; + param[2] = lt->spotDirection.z; +#if 0 + /* the w-component of the direction, although possibly (?) + useful to keep around internally, is not returned as part + of the get. */ + param[3] = lt->spotDirection.w; +#endif + break; + case GL_SPOT_EXPONENT: + *param = lt->spotExponent; + break; + case GL_SPOT_CUTOFF: + *param = lt->spotCutoff; + break; + case GL_CONSTANT_ATTENUATION: + *param = lt->constantAttenuation; + break; + case GL_LINEAR_ATTENUATION: + *param = lt->linearAttenuation; + break; + case GL_QUADRATIC_ATTENUATION: + *param = lt->quadraticAttenuation; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetLight: invalid pname: 0x%x", pname); + return; + } +} + +void STATE_APIENTRY crStateGetLightiv (GLenum light, GLenum pname, GLint *param) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRLight *lt; + unsigned int i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetLightiv called in begin/end"); + return; + } + + i = light - GL_LIGHT0; + if (i>=g->limits.maxLights) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetLight: invalid light specified: 0x%x", light); + return; + } + + lt = l->light + i; + + switch (pname) + { + case GL_AMBIENT: + param[0] = (GLint) (lt->ambient.r * CR_MAXINT); + param[1] = (GLint) (lt->ambient.g * CR_MAXINT); + param[2] = (GLint) (lt->ambient.b * CR_MAXINT); + param[3] = (GLint) (lt->ambient.a * CR_MAXINT); + break; + case GL_DIFFUSE: + param[0] = (GLint) (lt->diffuse.r * CR_MAXINT); + param[1] = (GLint) (lt->diffuse.g * CR_MAXINT); + param[2] = (GLint) (lt->diffuse.b * CR_MAXINT); + param[3] = (GLint) (lt->diffuse.a * CR_MAXINT); + break; + case GL_SPECULAR: + param[0] = (GLint) (lt->specular.r * CR_MAXINT); + param[1] = (GLint) (lt->specular.g * CR_MAXINT); + param[2] = (GLint) (lt->specular.b * CR_MAXINT); + param[3] = (GLint) (lt->specular.a * CR_MAXINT); + break; + case GL_POSITION: + param[0] = (GLint) (lt->position.x); + param[1] = (GLint) (lt->position.y); + param[2] = (GLint) (lt->position.z); + param[3] = (GLint) (lt->position.w); + break; + case GL_SPOT_DIRECTION: + param[0] = (GLint) (lt->spotDirection.x); + param[1] = (GLint) (lt->spotDirection.y); + param[2] = (GLint) (lt->spotDirection.z); +#if 0 + /* the w-component of the direction, although possibly (?) + useful to keep around internally, is not returned as part + of the get. */ + param[3] = (GLint) (lt->spotDirection.w); +#endif + break; + case GL_SPOT_EXPONENT: + *param = (GLint) (lt->spotExponent); + break; + case GL_SPOT_CUTOFF: + *param = (GLint) (lt->spotCutoff); + break; + case GL_CONSTANT_ATTENUATION: + *param = (GLint) (lt->constantAttenuation); + break; + case GL_LINEAR_ATTENUATION: + *param = (GLint) (lt->linearAttenuation); + break; + case GL_QUADRATIC_ATTENUATION: + *param = (GLint) (lt->quadraticAttenuation); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetLight: invalid pname: 0x%x", pname); + return; + } +} + +void STATE_APIENTRY crStateGetMaterialfv (GLenum face, GLenum pname, GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetMaterialfv called in begin/end"); + return; + } + + switch (pname) + { + case GL_AMBIENT: + switch (face) + { + case GL_FRONT: + param[0] = l->ambient[0].r; + param[1] = l->ambient[0].g; + param[2] = l->ambient[0].b; + param[3] = l->ambient[0].a; + break; + case GL_BACK: + param[0] = l->ambient[1].r; + param[1] = l->ambient[1].g; + param[2] = l->ambient[1].b; + param[3] = l->ambient[1].a; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_DIFFUSE: + switch (face) + { + case GL_FRONT: + param[0] = l->diffuse[0].r; + param[1] = l->diffuse[0].g; + param[2] = l->diffuse[0].b; + param[3] = l->diffuse[0].a; + break; + case GL_BACK: + param[0] = l->diffuse[1].r; + param[1] = l->diffuse[1].g; + param[2] = l->diffuse[1].b; + param[3] = l->diffuse[1].a; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_SPECULAR : + switch (face) + { + case GL_FRONT: + param[0] = l->specular[0].r; + param[1] = l->specular[0].g; + param[2] = l->specular[0].b; + param[3] = l->specular[0].a; + break; + case GL_BACK: + param[0] = l->specular[1].r; + param[1] = l->specular[1].g; + param[2] = l->specular[1].b; + param[3] = l->specular[1].a; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_EMISSION: + switch (face) + { + case GL_FRONT: + param[0] = l->emission[0].r; + param[1] = l->emission[0].g; + param[2] = l->emission[0].b; + param[3] = l->emission[0].a; + break; + case GL_BACK: + param[0] = l->emission[1].r; + param[1] = l->emission[1].g; + param[2] = l->emission[1].b; + param[3] = l->emission[1].a; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_SHININESS: + switch (face) + { + case GL_FRONT: + *param = l->shininess[0]; + break; + case GL_BACK: + *param = l->shininess[1]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialfv: bad face: 0x%x", face); + return; + } + break; + case GL_COLOR_INDEXES : + switch (face) + { + case GL_FRONT: + param[0] = (GLfloat) l->indexes[0][0]; + param[1] = (GLfloat) l->indexes[0][1]; + param[2] = (GLfloat) l->indexes[0][2]; + break; + case GL_BACK: + param[0] = (GLfloat) l->indexes[1][0]; + param[1] = (GLfloat) l->indexes[1][1]; + param[2] = (GLfloat) l->indexes[1][2]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialfv: bad face: 0x%x", face); + return; + } + return; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialfv: bad pname: 0x%x", pname); + return; + } +} + + +void STATE_APIENTRY crStateGetMaterialiv (GLenum face, GLenum pname, GLint *param) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetMaterialiv called in begin/end"); + return; + } + + switch (pname) + { + case GL_AMBIENT: + switch (face) + { + case GL_FRONT: + param[0] = (GLint) (l->ambient[0].r * CR_MAXINT); + param[1] = (GLint) (l->ambient[0].g * CR_MAXINT); + param[2] = (GLint) (l->ambient[0].b * CR_MAXINT); + param[3] = (GLint) (l->ambient[0].a * CR_MAXINT); + break; + case GL_BACK: + param[0] = (GLint) (l->ambient[1].r * CR_MAXINT); + param[1] = (GLint) (l->ambient[1].g * CR_MAXINT); + param[2] = (GLint) (l->ambient[1].b * CR_MAXINT); + param[3] = (GLint) (l->ambient[1].a * CR_MAXINT); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialiv: bad face: 0x%x", face); + return; + } + break; + case GL_DIFFUSE: + switch (face) + { + case GL_FRONT: + param[0] = (GLint) (l->diffuse[0].r * CR_MAXINT); + param[1] = (GLint) (l->diffuse[0].g * CR_MAXINT); + param[2] = (GLint) (l->diffuse[0].b * CR_MAXINT); + param[3] = (GLint) (l->diffuse[0].a * CR_MAXINT); + break; + case GL_BACK: + param[0] = (GLint) (l->diffuse[1].r * CR_MAXINT); + param[1] = (GLint) (l->diffuse[1].g * CR_MAXINT); + param[2] = (GLint) (l->diffuse[1].b * CR_MAXINT); + param[3] = (GLint) (l->diffuse[1].a * CR_MAXINT); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialiv: bad face: 0x%x", face); + return; + } + break; + case GL_SPECULAR: + switch (face) + { + case GL_FRONT: + param[0] = (GLint) (l->specular[0].r * CR_MAXINT); + param[1] = (GLint) (l->specular[0].g * CR_MAXINT); + param[2] = (GLint) (l->specular[0].b * CR_MAXINT); + param[3] = (GLint) (l->specular[0].a * CR_MAXINT); + break; + case GL_BACK: + param[0] = (GLint) (l->specular[1].r * CR_MAXINT); + param[1] = (GLint) (l->specular[1].g * CR_MAXINT); + param[2] = (GLint) (l->specular[1].b * CR_MAXINT); + param[3] = (GLint) (l->specular[1].a * CR_MAXINT); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialiv: bad face: 0x%x", face); + return; + } + break; + case GL_EMISSION: + switch (face) + { + case GL_FRONT: + param[0] = (GLint) (l->emission[0].r * CR_MAXINT); + param[1] = (GLint) (l->emission[0].g * CR_MAXINT); + param[2] = (GLint) (l->emission[0].b * CR_MAXINT); + param[3] = (GLint) (l->emission[0].a * CR_MAXINT); + break; + case GL_BACK: + param[0] = (GLint) (l->emission[1].r * CR_MAXINT); + param[1] = (GLint) (l->emission[1].g * CR_MAXINT); + param[2] = (GLint) (l->emission[1].b * CR_MAXINT); + param[3] = (GLint) (l->emission[1].a * CR_MAXINT); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialiv: bad face: 0x%x", face); + return; + } + break; + case GL_SHININESS: + switch (face) { + case GL_FRONT: + *param = (GLint) l->shininess[0]; + break; + case GL_BACK: + *param = (GLint) l->shininess[1]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialiv: bad face: 0x%x", face); + return; + } + break; + case GL_COLOR_INDEXES : + switch (face) + { + case GL_FRONT: + param[0] = (GLint) l->indexes[0][0]; + param[1] = (GLint) l->indexes[0][1]; + param[2] = (GLint) l->indexes[0][2]; + break; + case GL_BACK: + param[0] = (GLint) l->indexes[1][0]; + param[1] = (GLint) l->indexes[1][1]; + param[2] = (GLint) l->indexes[1][2]; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialiv: bad face: 0x%x", face); + return; + } + return; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetMaterialiv: bad pname: 0x%x", pname); + return; + } +} + +void crStateColorMaterialRecover(void) +{ + CRContext *g = GetCurrentContext(); + CRLightingState *l = &(g->lighting); + CRCurrentState *c = &(g->current); + + /* Assuming that the "current" values are up to date, + * this function will extract them into the material + * values if COLOR_MATERIAL has been enabled on the + * client. */ + + if (l->colorMaterial) + { + /* prevent recursion here (was in tilesortspu_flush.c's doFlush() for a + * short time. Without this, kirchner_colormaterial fails. + */ + crStateFlushFunc(NULL); + + crStateMaterialfv(l->colorMaterialFace, l->colorMaterialMode, &(c->vertexAttrib[VERT_ATTRIB_COLOR0][0])); + } +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.txt new file mode 100644 index 00000000..0a072213 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_lighting.txt @@ -0,0 +1,63 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:colorMaterial:colorMaterialFace,colorMaterialMode:ColorMaterial +:enable:lighting:GL_LIGHTING +:enable:colorMaterial:GL_COLOR_MATERIAL +:enable:colorSumEXT:GL_COLOR_SUM_EXT +:shadeModel:shadeModel:ShadeModel +:lightModel:lightModelAmbient|r,g,b,a:LightModelfv,GL_LIGHT_MODEL_AMBIENT +:lightModel:lightModelLocalViewer:*diff_api.LightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, to->lightModelLocalViewer==GL_TRUE); +:lightModel:lightModelTwoSide:*diff_api.LightModeli(GL_LIGHT_MODEL_TWO_SIDE, to->lightModelTwoSide==GL_TRUE); +:lightModel:lightModelColorControlEXT:*diff_api.LightModeli(GL_LIGHT_MODEL_COLOR_CONTROL_EXT, to->lightModelColorControlEXT); +%flush +:material:ambient[0]|r,g,b,a:Materialfv, GL_FRONT, GL_AMBIENT +:material:ambient[1]|r,g,b,a:Materialfv, GL_BACK, GL_AMBIENT +:material:diffuse[0]|r,g,b,a:Materialfv, GL_FRONT, GL_DIFFUSE +:material:diffuse[1]|r,g,b,a:Materialfv, GL_BACK, GL_DIFFUSE +:material:specular[0]|r,g,b,a:Materialfv, GL_FRONT, GL_SPECULAR +:material:specular[1]|r,g,b,a:Materialfv, GL_BACK, GL_SPECULAR +:material:emission[0]|r,g,b,a:Materialfv, GL_FRONT, GL_EMISSION +:material:emission[1]|r,g,b,a:Materialfv, GL_BACK, GL_EMISSION +:material:shininess[0]:Materialf, GL_FRONT, GL_SHININESS +:material:shininess[1]:Materialf, GL_BACK, GL_SHININESS +%flush +>for (i=0; iCRLightBits *lb = b->light+i; +>CRLight *tl = to->light+i; +>CRLight *cl = from->light+i; +>if (!(CHECKDIRTY(lb->dirty, bitID))) continue; +%target=tl +%current=cl +%bit=lb +%extrabit=b +:enable:enable:GL_LIGHT0+i +%flush +:ambient:ambient|r,g,b,a:Lightfv, GL_LIGHT0+i, GL_AMBIENT +:diffuse:diffuse|r,g,b,a:Lightfv, GL_LIGHT0+i, GL_DIFFUSE +:specular:specular|r,g,b,a:Lightfv, GL_LIGHT0+i, GL_SPECULAR +:attenuation:constantAttenuation:Lightf, GL_LIGHT0+i, GL_CONSTANT_ATTENUATION +:attenuation:linearAttenuation:Lightf, GL_LIGHT0+i, GL_LINEAR_ATTENUATION +:attenuation:quadraticAttenuation:Lightf, GL_LIGHT0+i, GL_QUADRATIC_ATTENUATION +:position:*diff_api.MatrixMode(GL_MODELVIEW); +:position:*diff_api.PushMatrix(); +:position:*diff_api.LoadIdentity(); +:position:position|x,y,z,w:Lightfv, GL_LIGHT0+i, GL_POSITION +:position:*diff_api.PopMatrix(); +:position:*diff_api.MatrixMode(toCtx->transform.matrixMode); +:spot:*diff_api.MatrixMode(GL_MODELVIEW); +:spot:*diff_api.PushMatrix(); +:spot:*diff_api.LoadIdentity(); +:spot:spotDirection|x,y,z:Lightfv, GL_LIGHT0+i, GL_SPOT_DIRECTION +:spot:spotExponent:Lightf, GL_LIGHT0+i, GL_SPOT_EXPONENT +:spot:spotCutoff:Lightf, GL_LIGHT0+i, GL_SPOT_CUTOFF +:spot:*diff_api.PopMatrix(); +:spot:*diff_api.MatrixMode(toCtx->transform.matrixMode); +%flush +>CLEARDIRTY(lb->dirty, nbitID); +>} +%target=to +%current=from +%bit=b +%extrabit= diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c new file mode 100644 index 00000000..91cdd84f --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_limits.c @@ -0,0 +1,475 @@ + +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_extstring.h" + +#ifdef WINDOWS +#pragma warning( disable : 4127 ) +#endif + + +/* This is a debug helper function. */ +void crStateLimitsPrint (const CRLimitsState *l) +{ + fprintf(stderr, "----------- OpenGL limits ----------------\n"); + fprintf(stderr, "GL_MAX_TEXTURE_UNITS = %d\n", (int) l->maxTextureUnits); + fprintf(stderr, "GL_MAX_TEXTURE_SIZE = %d\n", (int) l->maxTextureSize); + fprintf(stderr, "GL_MAX_3D_TEXTURE_SIZE = %d\n", (int) l->max3DTextureSize); + fprintf(stderr, "GL_MAX_CUBE_MAP_TEXTURE_SIZE = %d\n", (int) l->maxCubeMapTextureSize); + fprintf(stderr, "GL_MAX_TEXTURE_ANISOTROPY = %f\n", l->maxTextureAnisotropy); + fprintf(stderr, "GL_MAX_LIGHTS = %d\n", (int) l->maxLights); + fprintf(stderr, "GL_MAX_CLIP_PLANES = %d\n", (int) l->maxClipPlanes); + fprintf(stderr, "GL_MAX_ATTRIB_STACK_DEPTH = %d\n", (int) l->maxClientAttribStackDepth); + fprintf(stderr, "GL_MAX_PROJECTION_STACK_DEPTH = %d\n", (int) l->maxProjectionStackDepth); + fprintf(stderr, "GL_MAX_MODELVIEW_STACK_DEPTH = %d\n", (int) l->maxModelviewStackDepth); + fprintf(stderr, "GL_MAX_TEXTURE_STACK_DEPTH = %d\n", (int) l->maxTextureStackDepth); + fprintf(stderr, "GL_MAX_COLOR_STACK_DEPTH = %d\n", (int) l->maxColorStackDepth); + fprintf(stderr, "GL_MAX_ATTRIB_STACK_DEPTH = %d\n", (int) l->maxAttribStackDepth); + fprintf(stderr, "GL_MAX_ATTRIB_STACK_DEPTH = %d\n", (int) l->maxClientAttribStackDepth); + fprintf(stderr, "GL_MAX_NAME_STACK_DEPTH = %d\n", (int) l->maxNameStackDepth); + fprintf(stderr, "GL_MAX_ELEMENTS_INDICES = %d\n", (int) l->maxElementsIndices); + fprintf(stderr, "GL_MAX_ELEMENTS_VERTICES = %d\n", (int) l->maxElementsVertices); + fprintf(stderr, "GL_MAX_EVAL_ORDER = %d\n", (int) l->maxEvalOrder); + fprintf(stderr, "GL_MAX_LIST_NESTING = %d\n", (int) l->maxListNesting); + fprintf(stderr, "GL_MAX_PIXEL_MAP_TABLE = %d\n", (int) l->maxPixelMapTable); + fprintf(stderr, "GL_MAX_VIEWPORT_DIMS = %d %d\n", + (int) l->maxViewportDims[0], (int) l->maxViewportDims[1]); + fprintf(stderr, "GL_SUBPIXEL_BITS = %d\n", (int) l->subpixelBits); + fprintf(stderr, "GL_ALIASED_POINT_SIZE_RANGE = %f .. %f\n", + l->aliasedPointSizeRange[0], l->aliasedPointSizeRange[1]); + fprintf(stderr, "GL_SMOOTH_POINT_SIZE_RANGE = %f .. %f\n", + l->aliasedPointSizeRange[0], l->aliasedPointSizeRange[1]); + fprintf(stderr, "GL_POINT_SIZE_GRANULARITY = %f\n", l->pointSizeGranularity); + fprintf(stderr, "GL_ALIASED_LINE_WIDTH_RANGE = %f .. %f\n", + l->aliasedLineWidthRange[0], l->aliasedLineWidthRange[1]); + fprintf(stderr, "GL_SMOOTH_LINE_WIDTH_RANGE = %f .. %f\n", + l->smoothLineWidthRange[0], l->smoothLineWidthRange[1]); + fprintf(stderr, "GL_LINE_WIDTH_GRANULARITY = %f\n", l->lineWidthGranularity); + fprintf(stderr, "GL_MAX_GENERAL_COMBINERS_NV = %d\n", (int) l->maxGeneralCombiners); + fprintf(stderr, "GL_EXTENSIONS = %s\n", (const char *) l->extensions); + fprintf(stderr, "------------------------------------------\n"); +} + + +void crStateLimitsDestroy(CRLimitsState *l) +{ + if (l->extensions) { + crFree((void *) l->extensions); + l->extensions = NULL; + } +} + + +/* + * Initialize the CRLimitsState object to Chromium's defaults. + */ +void crStateLimitsInit (CRLimitsState *l) +{ + l->maxTextureUnits = CR_MAX_TEXTURE_UNITS; + l->maxTextureSize = CR_MAX_TEXTURE_SIZE; + l->max3DTextureSize = CR_MAX_3D_TEXTURE_SIZE; + l->maxCubeMapTextureSize = CR_MAX_CUBE_TEXTURE_SIZE; +#ifdef CR_NV_texture_rectangle + l->maxRectTextureSize = CR_MAX_RECTANGLE_TEXTURE_SIZE; +#endif + l->maxTextureAnisotropy = CR_MAX_TEXTURE_ANISOTROPY; + l->maxGeneralCombiners = CR_MAX_GENERAL_COMBINERS; + l->maxLights = CR_MAX_LIGHTS; + l->maxClipPlanes = CR_MAX_CLIP_PLANES; + l->maxClientAttribStackDepth = CR_MAX_ATTRIB_STACK_DEPTH; + l->maxProjectionStackDepth = CR_MAX_PROJECTION_STACK_DEPTH; + l->maxModelviewStackDepth = CR_MAX_MODELVIEW_STACK_DEPTH; + l->maxTextureStackDepth = CR_MAX_TEXTURE_STACK_DEPTH; + l->maxColorStackDepth = CR_MAX_COLOR_STACK_DEPTH; + l->maxAttribStackDepth = CR_MAX_ATTRIB_STACK_DEPTH; + l->maxClientAttribStackDepth = CR_MAX_ATTRIB_STACK_DEPTH; + l->maxNameStackDepth = CR_MAX_NAME_STACK_DEPTH; + l->maxElementsIndices = CR_MAX_ELEMENTS_INDICES; + l->maxElementsVertices = CR_MAX_ELEMENTS_VERTICES; + l->maxEvalOrder = CR_MAX_EVAL_ORDER; + l->maxListNesting = CR_MAX_LIST_NESTING; + l->maxPixelMapTable = CR_MAX_PIXEL_MAP_TABLE; + l->maxViewportDims[0] = l->maxViewportDims[1] = CR_MAX_VIEWPORT_DIM; + l->subpixelBits = CR_SUBPIXEL_BITS; + l->aliasedPointSizeRange[0] = CR_ALIASED_POINT_SIZE_MIN; + l->aliasedPointSizeRange[1] = CR_ALIASED_POINT_SIZE_MAX; + l->smoothPointSizeRange[0] = CR_SMOOTH_POINT_SIZE_MIN; + l->smoothPointSizeRange[1] = CR_SMOOTH_POINT_SIZE_MAX; + l->pointSizeGranularity = CR_POINT_SIZE_GRANULARITY; + l->aliasedLineWidthRange[0] = CR_ALIASED_LINE_WIDTH_MIN; + l->aliasedLineWidthRange[1] = CR_ALIASED_LINE_WIDTH_MAX; + l->smoothLineWidthRange[0] = CR_SMOOTH_LINE_WIDTH_MIN; + l->smoothLineWidthRange[1] = CR_SMOOTH_LINE_WIDTH_MAX; + l->lineWidthGranularity = CR_LINE_WIDTH_GRANULARITY; +#ifdef CR_EXT_texture_lod_bias + l->maxTextureLodBias = CR_MAX_TEXTURE_LOD_BIAS; +#endif +#ifdef CR_NV_fragment_program + l->maxTextureCoords = CR_MAX_TEXTURE_COORDS; + l->maxTextureImageUnits = CR_MAX_TEXTURE_IMAGE_UNITS; + l->maxFragmentProgramLocalParams = CR_MAX_FRAGMENT_LOCAL_PARAMS; +#endif +#ifdef CR_NV_vertex_program + l->maxProgramMatrixStackDepth = CR_MAX_PROGRAM_MATRIX_STACK_DEPTH; + l->maxProgramMatrices = CR_MAX_PROGRAM_MATRICES; +#endif +#ifdef CR_ARB_fragment_program + l->maxFragmentProgramInstructions = CR_MAX_FRAGMENT_PROGRAM_INSTRUCTIONS; + l->maxFragmentProgramLocalParams = CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS; + l->maxFragmentProgramEnvParams = CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS; + l->maxFragmentProgramTemps = CR_MAX_FRAGMENT_PROGRAM_TEMPS; + l->maxFragmentProgramAttribs = CR_MAX_FRAGMENT_PROGRAM_ATTRIBS; + l->maxFragmentProgramAddressRegs = CR_MAX_FRAGMENT_PROGRAM_ADDRESS_REGS; + l->maxFragmentProgramAluInstructions = CR_MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS; + l->maxFragmentProgramTexInstructions = CR_MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS; + l->maxFragmentProgramTexIndirections = CR_MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS; +#endif +#ifdef CR_ARB_vertex_program + l->maxVertexProgramInstructions = CR_MAX_VERTEX_PROGRAM_INSTRUCTIONS; + l->maxVertexProgramLocalParams = CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS; + l->maxVertexProgramEnvParams = CR_MAX_VERTEX_PROGRAM_ENV_PARAMS; + l->maxVertexProgramTemps = CR_MAX_VERTEX_PROGRAM_TEMPS; + l->maxVertexProgramAttribs = CR_MAX_VERTEX_PROGRAM_ATTRIBS; + l->maxVertexProgramAddressRegs = CR_MAX_VERTEX_PROGRAM_ADDRESS_REGS; +#endif + + l->extensions = (GLubyte *) crStrdup(crExtensions); + + /* These will get properly set in crStateCreateContext() by examining + * the visBits bitfield parameter. + */ + l->redBits = 0; + l->greenBits = 0; + l->blueBits = 0; + l->alphaBits = 0; + l->depthBits = 0; + l->stencilBits = 0; + l->accumRedBits = 0; + l->accumGreenBits = 0; + l->accumBlueBits = 0; + l->accumAlphaBits = 0; + l->auxBuffers = 0; + l->rgbaMode = GL_TRUE; + l->doubleBuffer = GL_FALSE; + l->stereo = GL_FALSE; + l->sampleBuffers = 0; + l->samples = 0; + l->level = 0; + + (void) crAppOnlyExtensions; /* silence warning */ +} + + +/* + * Given the GL version number returned from a real GL renderer, + * compute the version number supported by Chromium. + */ +GLfloat crStateComputeVersion(float minVersion) +{ + const GLfloat crVersion = crStrToFloat(CR_OPENGL_VERSION_STRING); + if (crVersion < minVersion) + minVersion = crVersion; + return minVersion; +} + + +/* + * is an array [n] of GLubyte pointers which contain lists of + * OpenGL extensions. + * Compute the intersection of those strings, then append the Chromium + * extension strings. + */ +GLubyte * crStateMergeExtensions(GLuint n, const GLubyte **extensions) +{ + char *merged, *result; + GLuint i; + + /* find intersection of all extension strings */ + merged = crStrdup(crExtensions); + for (i = 0; i < n; i++) + { + char *m = crStrIntersect(merged, (const char *) extensions[i]); + if (merged) + crFree(merged); + merged = m; + } + + /* append Cr extensions */ + result = crStrjoin(merged, crChromiumExtensions); + crFree(merged); + return (GLubyte *) result; +} + +static GLboolean hasExtension(const char *haystack, const char *needle) +{ + const int needleLen = crStrlen(needle); + const char *s; + + while (1) { + s = crStrstr(haystack, needle); + if (!s) + return GL_FALSE; + if (s && (s[needleLen] == ' ' || s[needleLen] == 0)) + return GL_TRUE; + haystack += needleLen; + } +} + +/* + * Examine the context's extension string and set the boolean extension + * flags accordingly. This is to be called during context initialization. + */ +void crStateExtensionsInit( CRLimitsState *limits, CRExtensionState *extensions ) +{ + /* init all booleans to false */ + crMemZero(extensions, sizeof(CRExtensionState)); + + if (hasExtension((const char*)limits->extensions, "GL_ARB_depth_texture")) + extensions->ARB_depth_texture = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_fragment_program")) + extensions->ARB_fragment_program = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_imaging")) + extensions->ARB_imaging = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_multisample")) + extensions->ARB_multisample = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_multitexture")) + extensions->ARB_multitexture = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_occlusion_query")) + extensions->ARB_occlusion_query = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_point_parameters")) + extensions->ARB_point_parameters = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_point_sprite")) + extensions->ARB_point_sprite = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_shadow")) + extensions->ARB_shadow = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_shadow_ambient")) + extensions->ARB_shadow_ambient = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_border_clamp") || + hasExtension((const char*)limits->extensions, "GL_SGIS_texture_border_clamp")) + extensions->ARB_texture_border_clamp = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_compression")) + extensions->ARB_texture_compression = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_cube_map") || + hasExtension((const char*)limits->extensions, "GL_EXT_texture_cube_map")) + extensions->ARB_texture_cube_map = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_add")) + extensions->ARB_texture_env_add = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_combine") || + hasExtension((const char*)limits->extensions, "GL_EXT_texture_env_combine")) + extensions->ARB_texture_env_combine = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_crossbar")) + extensions->ARB_texture_env_crossbar = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_env_dot3") || + hasExtension((const char*)limits->extensions, "GL_EXT_texture_env_dot3")) + extensions->ARB_texture_env_dot3 = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_mirrored_repeat")) + extensions->ARB_texture_mirrored_repeat = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ATI_texture_mirror_once")) + extensions->ATI_texture_mirror_once = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_texture_non_power_of_two")) + extensions->ARB_texture_non_power_of_two = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_transpose_matrix")) + extensions->ARB_transpose_matrix = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_vertex_buffer_object")) + extensions->ARB_vertex_buffer_object = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_pixel_buffer_object")) + extensions->ARB_pixel_buffer_object = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_vertex_program")) + extensions->ARB_vertex_program = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_ARB_window_pos")) + extensions->ARB_window_pos = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_color")) + extensions->EXT_blend_color= GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_minmax")) + extensions->EXT_blend_minmax = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_func_separate")) + extensions->EXT_blend_func_separate = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_logic_op")) + extensions->EXT_blend_logic_op = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_blend_subtract")) + extensions->EXT_blend_subtract = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_clip_volume_hint")) + extensions->EXT_clip_volume_hint = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_fog_coord")) + extensions->EXT_fog_coord = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_multi_draw_arrays")) + extensions->EXT_multi_draw_arrays = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_secondary_color")) + extensions->EXT_secondary_color = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_separate_specular_color")) + extensions->EXT_separate_specular_color = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_shadow_funcs")) + extensions->EXT_shadow_funcs = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_stencil_wrap")) + extensions->EXT_stencil_wrap = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_edge_clamp") || + hasExtension((const char*)limits->extensions, "GL_SGIS_texture_edge_clamp")) + extensions->EXT_texture_edge_clamp = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_filter_anisotropic")) + extensions->EXT_texture_filter_anisotropic = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_texture_lod_bias")) + extensions->EXT_texture_lod_bias = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_IBM_rasterpos_clip")) + extensions->IBM_rasterpos_clip = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_fog_distance")) + extensions->NV_fog_distance = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_fragment_program")) + extensions->NV_fragment_program = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_register_combiners")) + extensions->NV_register_combiners = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_register_combiners2")) + extensions->NV_register_combiners2 = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_texgen_reflection")) + extensions->NV_texgen_reflection = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_texture_rectangle") + || hasExtension((const char*)limits->extensions, "GL_EXT_texture_rectangle")) + extensions->NV_texture_rectangle = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_vertex_program")) + extensions->NV_vertex_program = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_vertex_program1_1")) + extensions->NV_vertex_program1_1 = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_NV_vertex_program2")) + extensions->NV_vertex_program2 = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_EXT_texture3D")) + extensions->EXT_texture3D = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GL_SGIS_generate_mipmap")) + extensions->SGIS_generate_mipmap = GL_TRUE; + + if (hasExtension((const char*)limits->extensions, "GLX_EXT_texture_from_pixmap")) + extensions->EXT_texture_from_pixmap = GL_TRUE; + + if (extensions->NV_vertex_program2) + limits->maxVertexProgramEnvParams = 256; + else + limits->maxVertexProgramEnvParams = 96; + + if (extensions->NV_vertex_program || extensions->ARB_vertex_program) + extensions->any_vertex_program = GL_TRUE; + if (extensions->NV_fragment_program || extensions->ARB_fragment_program) + extensions->any_fragment_program = GL_TRUE; + if (extensions->any_vertex_program || extensions->any_fragment_program) + extensions->any_program = GL_TRUE; + +#if 0 + /* Now, determine what level of OpenGL we support */ + if (extensions->ARB_multisample && + extensions->ARB_multitexture && + extensions->ARB_texture_border_clamp && + extensions->ARB_texture_compression && + extensions->ARB_texture_cube_map && + extensions->ARB_texture_env_add && + extensions->ARB_texture_env_combine && + extensions->ARB_texture_env_dot3) { + if (extensions->ARB_depth_texture && + extensions->ARB_point_parameters && + extensions->ARB_shadow && + extensions->ARB_texture_env_crossbar && + extensions->ARB_texture_mirrored_repeat && + extensions->ARB_window_pos && + extensions->EXT_blend_color && + extensions->EXT_blend_func_separate && + extensions->EXT_blend_logic_op && + extensions->EXT_blend_minmax && + extensions->EXT_blend_subtract && + extensions->EXT_fog_coord && + extensions->EXT_multi_draw_arrays && + extensions->EXT_secondary_color && + extensions->EXT_shadow_funcs && + extensions->EXT_stencil_wrap && + extensions->SGIS_generate_mipmap) { + if (extensions->ARB_occlusion_query && + extensions->ARB_vertex_buffer_object && + extensions->ARB_texture_non_power_of_two && + extensions->EXT_shadow_funcs) { + extensions->version = (const GLubyte *) "1.5 Chromium " CR_VERSION_STRING; + } + else { + extensions->version = (const GLubyte *) "1.4 Chromium " CR_VERSION_STRING; + } + } + else { + extensions->version = (const GLubyte *) "1.3 Chromium " CR_VERSION_STRING; + } + } + else { + extensions->version = (const GLubyte *) "1.2 Chromium " CR_VERSION_STRING; + } +#endif +} + + +/* + * Set the GL_EXTENSIONS string for the given context. We'll make + * a copy of the given string. + */ +void +crStateSetExtensionString( CRContext *ctx, const GLubyte *extensions ) +{ + if (ctx->limits.extensions) + crFree((void *) ctx->limits.extensions); + + ctx->limits.extensions = (const GLubyte *)crStrdup((const char*)extensions); + + crStateExtensionsInit(&(ctx->limits), &(ctx->extensions)); +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_line.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_line.c new file mode 100644 index 00000000..ef4a3b4a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_line.c @@ -0,0 +1,87 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateLineInit (CRContext *ctx) +{ + CRLineState *l = &ctx->line; + CRStateBits *sb = GetCurrentBits(); + CRLineBits *lb = &(sb->line); + + l->lineSmooth = GL_FALSE; + l->lineStipple = GL_FALSE; + RESET(lb->enable, ctx->bitid); + l->width = 1.0f; + RESET(lb->width, ctx->bitid); + l->pattern = 0xFFFF; + l->repeat = 1; + RESET(lb->stipple, ctx->bitid); + /* + *l->aliasedlinewidth_min = c->aliasedlinewidth_min; + *l->aliasedlinewidth_max = c->aliasedlinewidth_max; + *l->aliasedlinegranularity = c->aliasedlinegranularity; + *l->smoothlinewidth_min = c->smoothlinewidth_min; + *l->smoothlinewidth_max = c->smoothlinewidth_max; + *l->smoothlinegranularity = c->smoothlinegranularity; */ + + RESET(lb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateLineWidth(GLfloat width) +{ + CRContext *g = GetCurrentContext(); + CRLineState *l = &(g->line); + CRStateBits *sb = GetCurrentBits(); + CRLineBits *lb = &(sb->line); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glLineWidth called in begin/end"); + return; + } + + FLUSH(); + + if (width <= 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLineWidth called with size <= 0.0: %f", width); + return; + } + + l->width = width; + DIRTY(lb->width, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateLineStipple(GLint factor, GLushort pattern) +{ + CRContext *g = GetCurrentContext(); + CRLineState *l = &(g->line); + CRStateBits *sb = GetCurrentBits(); + CRLineBits *lb = &(sb->line); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glLineStipple called in begin/end"); + return; + } + + FLUSH(); + + if (factor < 1) factor = 1; + if (factor > 256) factor = 256; + + l->pattern = pattern; + l->repeat = factor; + DIRTY(lb->stipple, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_line.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_line.txt new file mode 100644 index 00000000..35ab8633 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_line.txt @@ -0,0 +1,8 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enable:lineSmooth:GL_LINE_SMOOTH +:enable:lineStipple:GL_LINE_STIPPLE +:width:width:LineWidth +lineStipple:stipple:repeat,pattern:LineStipple diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_lists.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_lists.c new file mode 100644 index 00000000..73511399 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_lists.c @@ -0,0 +1,1407 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "cr_mem.h" +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateListsDestroy(CRContext *ctx) +{ + /* nothing - dlists are in shared state */ + (void)ctx; +} + +void crStateListsInit(CRContext *ctx) +{ + CRListsState *l = &ctx->lists; + CRStateBits *sb = GetCurrentBits(); + CRListsBits *lb = &(sb->lists); + + l->newEnd = GL_FALSE; + l->mode = 0; + l->currentIndex = 0; + l->base = 0; + + RESET(lb->base, ctx->bitid); + RESET(lb->dirty, ctx->bitid); +} + +/*#define CRSTATE_DEBUG_QUERY_HW_STATE*/ + +#ifndef CRSTATE_DEBUG_QUERY_HW_STATE +# define CRSTATE_SET_CAP(state, value, format) g->state=value +# define CR_STATE_SETTEX_MSG(state, st, hw) +# define CR_STATE_SETMAT_MSG(state, st, hw) +#else +# define CRSTATE_SET_CAP(state, value, format) \ + if (g->state!=value) { \ + crDebug("crStateQueryHWState fixed %s from "format" to "format, #state, g->state, value); \ + g->state=value; \ + } +# define CR_STATE_SETTEX_MSG(state, st, hw) crDebug("crStateQueryHWState fixed %s from %i to %i", state, st, hw) +# define CR_STATE_SETMAT_MSG(state, st, hw) \ + { \ + crDebug("crStateQueryHWState fixed %s", state); \ + crDebug("st: [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f]", \ + st[0], st[1], st[2], st[3], st[4], st[5], st[6], st[7], \ + st[8], st[9], st[10], st[11], st[12], st[13], st[14], st[15]); \ + crDebug("hw: [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f] [%f, %f, %f, %f]", \ + hw[0], hw[1], hw[2], hw[3], hw[4], hw[5], hw[6], hw[7], \ + hw[8], hw[9], hw[10], hw[11], hw[12], hw[13], hw[14], hw[15]); \ + } +#endif + +#define CRSTATE_SET_ENABLED(state, cap) CRSTATE_SET_CAP(state, diff_api.IsEnabled(cap), "%u") + +#define CRSTATE_SET_ENUM(state, cap) {GLenum _e=g->state; diff_api.GetIntegerv(cap, &_e); CRSTATE_SET_CAP(state, _e, "%#x");} +#define CRSTATE_SET_FLOAT(state, cap) {GLfloat _f=g->state; diff_api.GetFloatv(cap, &_f); CRSTATE_SET_CAP(state, _f, "%f");} +#define CRSTATE_SET_INT(state, cap) {GLint _i=g->state; diff_api.GetIntegerv(cap, &_i); CRSTATE_SET_CAP(state, _i, "%i");} +#define CRSTATE_SET_BOOL(state, cap) {GLboolean _b=g->state; diff_api.GetBooleanv(cap, &_b); CRSTATE_SET_CAP(state, _b, "%u");} + +#define CRSTATE_SET_COLORF(state, cap) \ + { \ + GLfloat value[4]; \ + value[0]=g->state.r; \ + value[1]=g->state.g; \ + value[2]=g->state.b; \ + value[3]=g->state.a; \ + diff_api.GetFloatv(cap, &value[0]); \ + CRSTATE_SET_CAP(state.r, value[0], "%f"); \ + CRSTATE_SET_CAP(state.g, value[1], "%f"); \ + CRSTATE_SET_CAP(state.b, value[2], "%f"); \ + CRSTATE_SET_CAP(state.a, value[3], "%f"); \ + } + +#define CRSTATE_SET_TEXTURE(state, cap, target) \ + { \ + GLint _stex, _hwtex; \ + _stex = _hwtex = crStateGetTextureObjHWID(g->state); \ + diff_api.GetIntegerv(cap, &_hwtex); \ + if (_stex!=_hwtex) \ + { \ + CR_STATE_SETTEX_MSG(#state, _stex, _hwtex); \ + crStateBindTexture(target, crStateTextureHWIDtoID(_hwtex)); \ + } \ + } + +#define _CRSTATE_SET_4F_RGBA(state, p1, p2, func) \ + { \ + GLfloat value[4]; \ + value[0]=g->state.r; \ + value[1]=g->state.g; \ + value[2]=g->state.b; \ + value[3]=g->state.a; \ + diff_api.func(p1, p2, &value[0]); \ + CRSTATE_SET_CAP(state.r, value[0], "%f"); \ + CRSTATE_SET_CAP(state.g, value[1], "%f"); \ + CRSTATE_SET_CAP(state.b, value[2], "%f"); \ + CRSTATE_SET_CAP(state.a, value[3], "%f"); \ + } + +#define _CRSTATE_SET_4F_XYZW(state, p1, p2, func) \ + { \ + GLfloat value[4]; \ + value[0]=g->state.x; \ + value[1]=g->state.y; \ + value[2]=g->state.z; \ + value[3]=g->state.w; \ + diff_api.func(p1, p2, &value[0]); \ + CRSTATE_SET_CAP(state.x, value[0], "%f"); \ + CRSTATE_SET_CAP(state.y, value[1], "%f"); \ + CRSTATE_SET_CAP(state.z, value[2], "%f"); \ + CRSTATE_SET_CAP(state.w, value[3], "%f"); \ + } + +#define CRSTATE_SET_TEXGEN_4F(state, coord, pname) _CRSTATE_SET_4F_XYZW(state, coord, pname, GetTexGenfv) +#define CRSTATE_SET_TEXGEN_I(state, coord, pname) {GLint _i=g->state; diff_api.GetTexGeniv(coord, pname, &_i); CRSTATE_SET_CAP(state, _i, "%i");} + +#define CRSTATE_SET_TEXENV_I(state, target, pname) {GLint _i=g->state; diff_api.GetTexEnviv(target, pname, &_i); CRSTATE_SET_CAP(state, _i, "%i");} +#define CRSTATE_SET_TEXENV_F(state, target, pname) {GLfloat _f=g->state; diff_api.GetTexEnvfv(target, pname, &_f); CRSTATE_SET_CAP(state, _f, "%f");} +#define CRSTATE_SET_TEXENV_COLOR(state, target, pname) _CRSTATE_SET_4F_RGBA(state, target, pname, GetTexEnvfv) + +#define CRSTATE_SET_MATERIAL_COLOR(state, face, pname) _CRSTATE_SET_4F_RGBA(state, face, pname, GetMaterialfv) +#define CRSTATE_SET_MATERIAL_F(state, face, pname) {GLfloat _f=g->state; diff_api.GetMaterialfv(face, pname, &_f); CRSTATE_SET_CAP(state, _f, "%f");} + +#define CRSTATE_SET_LIGHT_COLOR(state, light, pname) _CRSTATE_SET_4F_RGBA(state, light, pname, GetLightfv) +#define CRSTATE_SET_LIGHT_F(state, light, pname) {GLfloat _f=g->state; diff_api.GetLightfv(light, pname, &_f); CRSTATE_SET_CAP(state, _f, "%f");} +#define CRSTATE_SET_LIGHT_4F(state, light, pname) _CRSTATE_SET_4F_XYZW(state, light, pname, GetLightfv) +#define CRSTATE_SET_LIGHT_3F(state, light, pname) \ + { \ + GLfloat value[3]; \ + value[0]=g->state.x; \ + value[1]=g->state.y; \ + value[2]=g->state.z; \ + diff_api.GetLightfv(light, pname, &value[0]); \ + CRSTATE_SET_CAP(state.x, value[0], "%f"); \ + CRSTATE_SET_CAP(state.y, value[1], "%f"); \ + CRSTATE_SET_CAP(state.z, value[2], "%f"); \ + } + +#define CRSTATE_SET_CLIPPLANE_4D(state, plane) \ + { \ + GLdouble value[4]; \ + value[0]=g->state.x; \ + value[1]=g->state.y; \ + value[2]=g->state.z; \ + value[3]=g->state.w; \ + diff_api.GetClipPlane(plane, &value[0]); \ + CRSTATE_SET_CAP(state.x, value[0], "%G"); \ + CRSTATE_SET_CAP(state.y, value[1], "%G"); \ + CRSTATE_SET_CAP(state.z, value[2], "%G"); \ + CRSTATE_SET_CAP(state.w, value[3], "%G"); \ + } + +#define CRSTATE_SET_MATRIX(state, cap) \ + { \ + GLfloat f[16], sm[16]; \ + crMatrixGetFloats(&f[0], g->state); \ + crMemcpy(&sm[0], &f[0], 16*sizeof(GLfloat)); \ + diff_api.GetFloatv(cap, &f[0]); \ + if (crMemcmp(&f[0], &sm[0], 16*sizeof(GLfloat))) \ + { \ + CR_STATE_SETMAT_MSG(#state, sm, f); \ + crMatrixInitFromFloats(g->state, &f[0]); \ + } \ + } + +void STATE_APIENTRY crStateQueryHWState(GLuint fbFbo, GLuint bbFbo) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CRbitvalue /* *bitID=g->bitid, */ *negbitID=g->neg_bitid; + + CRASSERT(g_bVBoxEnableDiffOnMakeCurrent); + + crStateSyncHWErrorState(g); + + if (CHECKDIRTY(sb->buffer.dirty, negbitID)) + { + if (CHECKDIRTY(sb->buffer.enable, negbitID)) + { + CRSTATE_SET_ENABLED(buffer.depthTest, GL_DEPTH_TEST); + CRSTATE_SET_ENABLED(buffer.blend, GL_BLEND); + CRSTATE_SET_ENABLED(buffer.alphaTest, GL_ALPHA_TEST); + CRSTATE_SET_ENABLED(buffer.logicOp, GL_COLOR_LOGIC_OP); + CRSTATE_SET_ENABLED(buffer.indexLogicOp, GL_INDEX_LOGIC_OP); + CRSTATE_SET_ENABLED(buffer.dither, GL_DITHER); + } + + if (CHECKDIRTY(sb->buffer.alphaFunc, negbitID)) + { + CRSTATE_SET_ENUM(buffer.alphaTestFunc, GL_ALPHA_TEST_FUNC); + CRSTATE_SET_FLOAT(buffer.alphaTestRef, GL_ALPHA_TEST_REF); + } + + if (CHECKDIRTY(sb->buffer.depthFunc, negbitID)) + { + CRSTATE_SET_ENUM(buffer.depthFunc, GL_DEPTH_FUNC); + } + + if (CHECKDIRTY(sb->buffer.blendFunc, negbitID)) + { + CRSTATE_SET_ENUM(buffer.blendSrcRGB, GL_BLEND_SRC); + CRSTATE_SET_ENUM(buffer.blendDstRGB, GL_BLEND_DST); + } + + if (CHECKDIRTY(sb->buffer.logicOp, negbitID)) + { + CRSTATE_SET_ENUM(buffer.logicOpMode, GL_LOGIC_OP_MODE); + } + +/* seems to always match previous .logicOp + if (CHECKDIRTY(sb->buffer.indexLogicOp, negbitID)) + { + CRSTATE_SET_ENUM(buffer.logicOpMode, GL_LOGIC_OP_MODE); + } +*/ + + if (CHECKDIRTY(sb->buffer.drawBuffer, negbitID)) + { + GLuint buf = 0; + diff_api.GetIntegerv(GL_DRAW_BUFFER, &buf); + + if (buf == GL_COLOR_ATTACHMENT0_EXT && (bbFbo || fbFbo)) + { + GLuint binding = 0; + diff_api.GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &binding); + if (!binding) + { + crWarning("HW state synch: GL_DRAW_FRAMEBUFFER_BINDING is NULL"); + } + + if (bbFbo && binding == bbFbo) + { + g->buffer.drawBuffer = GL_BACK; + } + else if (fbFbo && binding == fbFbo) + { + g->buffer.drawBuffer = GL_FRONT; + } + else + { + g->buffer.drawBuffer = buf; + } + } + else + { + g->buffer.drawBuffer = buf; + } + } + + if (CHECKDIRTY(sb->buffer.readBuffer, negbitID)) + { + GLuint buf = 0; + diff_api.GetIntegerv(GL_READ_BUFFER, &buf); + + if (buf == GL_COLOR_ATTACHMENT0_EXT && (bbFbo || fbFbo)) + { + GLuint binding = 0; + diff_api.GetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &binding); + if (!binding) + { + crWarning("HW state synch: GL_READ_FRAMEBUFFER_BINDING is NULL"); + } + + if (bbFbo && binding == bbFbo) + { + g->buffer.readBuffer = GL_BACK; + } + else if (fbFbo && binding == fbFbo) + { + g->buffer.readBuffer = GL_FRONT; + } + else + { + g->buffer.readBuffer = buf; + } + } + else + { + g->buffer.readBuffer = buf; + } + } + + if (CHECKDIRTY(sb->buffer.indexMask, negbitID)) + { + CRSTATE_SET_INT(buffer.indexWriteMask, GL_INDEX_WRITEMASK); + } + + if (CHECKDIRTY(sb->buffer.colorWriteMask, negbitID)) + { + GLboolean value[4]; + value[0]=g->buffer.colorWriteMask.r; + value[1]=g->buffer.colorWriteMask.g; + value[2]=g->buffer.colorWriteMask.b; + value[3]=g->buffer.colorWriteMask.a; + diff_api.GetBooleanv(GL_COLOR_WRITEMASK, &value[0]); + + CRSTATE_SET_CAP(buffer.colorWriteMask.r, value[0], "%u"); + CRSTATE_SET_CAP(buffer.colorWriteMask.g, value[1], "%u"); + CRSTATE_SET_CAP(buffer.colorWriteMask.b, value[2], "%u"); + CRSTATE_SET_CAP(buffer.colorWriteMask.a, value[3], "%u"); + } + + if (CHECKDIRTY(sb->buffer.clearColor, negbitID)) + { + CRSTATE_SET_COLORF(buffer.colorClearValue, GL_COLOR_CLEAR_VALUE); + } + + if (CHECKDIRTY(sb->buffer.clearIndex, negbitID)) + { + CRSTATE_SET_FLOAT(buffer.indexClearValue, GL_INDEX_CLEAR_VALUE); + } + + if (CHECKDIRTY(sb->buffer.clearDepth, negbitID)) + { + CRSTATE_SET_FLOAT(buffer.depthClearValue, GL_DEPTH_CLEAR_VALUE); + } + + if (CHECKDIRTY(sb->buffer.clearAccum, negbitID)) + { + CRSTATE_SET_COLORF(buffer.accumClearValue, GL_ACCUM_CLEAR_VALUE); + } + + if (CHECKDIRTY(sb->buffer.depthMask, negbitID)) + { + CRSTATE_SET_BOOL(buffer.depthMask, GL_DEPTH_WRITEMASK); + } + +#ifdef CR_EXT_blend_color + if (CHECKDIRTY(sb->buffer.blendColor, negbitID)) + { + CRSTATE_SET_COLORF(buffer.blendColor, GL_BLEND_COLOR); + } +#endif +#if defined(CR_EXT_blend_minmax) || defined(CR_EXT_blend_subtract) || defined(CR_EXT_blend_logic_op) + if (CHECKDIRTY(sb->buffer.blendEquation, negbitID)) + { + CRSTATE_SET_ENUM(buffer.blendEquation, GL_BLEND_EQUATION_EXT); + } +#endif +#if defined(CR_EXT_blend_func_separate) + if (CHECKDIRTY(sb->buffer.blendFuncSeparate, negbitID)) + { + CRSTATE_SET_ENUM(buffer.blendSrcRGB, GL_BLEND_SRC_RGB_EXT); + CRSTATE_SET_ENUM(buffer.blendDstRGB, GL_BLEND_DST_RGB_EXT); + CRSTATE_SET_ENUM(buffer.blendSrcA, GL_BLEND_SRC_ALPHA_EXT); + CRSTATE_SET_ENUM(buffer.blendDstA, GL_BLEND_DST_ALPHA_EXT); + } +#endif + } + + if (CHECKDIRTY(sb->stencil.dirty, negbitID)) + { + GLenum activeFace; + GLboolean backIsSet = GL_FALSE, frontIsSet = GL_FALSE; + + if (CHECKDIRTY(sb->stencil.enable, negbitID)) + { + CRSTATE_SET_ENABLED(stencil.stencilTest, GL_STENCIL_TEST); + } + + if (CHECKDIRTY(sb->stencil.enableTwoSideEXT, negbitID)) + { + CRSTATE_SET_ENABLED(stencil.stencilTwoSideEXT, GL_STENCIL_TEST_TWO_SIDE_EXT); + } + + if (CHECKDIRTY(sb->stencil.activeStencilFace, negbitID)) + { + CRSTATE_SET_ENUM(stencil.activeStencilFace, GL_ACTIVE_STENCIL_FACE_EXT); + } + + activeFace = g->stencil.activeStencilFace; + + +#define CRSTATE_SET_STENCIL_FUNC(_idx, _suff) do { \ + CRSTATE_SET_ENUM(stencil.buffers[(_idx)].func, GL_STENCIL##_suff##FUNC); \ + CRSTATE_SET_INT(stencil.buffers[(_idx)].ref, GL_STENCIL##_suff##REF); \ + CRSTATE_SET_INT(stencil.buffers[(_idx)].mask, GL_STENCIL##_suff##VALUE_MASK); \ + } while (0) + +#define CRSTATE_SET_STENCIL_OP(_idx, _suff) do { \ + CRSTATE_SET_ENUM(stencil.buffers[(_idx)].fail, GL_STENCIL##_suff##FAIL); \ + CRSTATE_SET_ENUM(stencil.buffers[(_idx)].passDepthFail, GL_STENCIL##_suff##PASS_DEPTH_FAIL); \ + CRSTATE_SET_ENUM(stencil.buffers[(_idx)].passDepthPass, GL_STENCIL##_suff##PASS_DEPTH_PASS); \ + } while (0) + + /* func */ + + if (CHECKDIRTY(sb->stencil.bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, negbitID)) + { + /* this if branch is not needed here actually, just in case ogl drivers misbehave */ + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_SET_STENCIL_FUNC(CRSTATE_STENCIL_BUFFER_ID_BACK, _BACK_); + backIsSet = GL_TRUE; + } + + if (CHECKDIRTY(sb->stencil.bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, negbitID)) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + CRSTATE_SET_STENCIL_FUNC(CRSTATE_STENCIL_BUFFER_ID_FRONT, _); + frontIsSet = GL_TRUE; + } + + if ((!frontIsSet || !backIsSet) && CHECKDIRTY(sb->stencil.bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, negbitID)) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + CRSTATE_SET_STENCIL_FUNC(CRSTATE_STENCIL_BUFFER_ID_FRONT, _); + if (!backIsSet) + { + g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func = g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func; + g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref = g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref; + g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask = g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask; + } + } + + /* op */ + backIsSet = GL_FALSE, frontIsSet = GL_FALSE; + + if (CHECKDIRTY(sb->stencil.bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, negbitID)) + { + /* this if branch is not needed here actually, just in case ogl drivers misbehave */ + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_SET_STENCIL_OP(CRSTATE_STENCIL_BUFFER_ID_BACK, _BACK_); + backIsSet = GL_TRUE; + } + + if (CHECKDIRTY(sb->stencil.bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, negbitID)) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + CRSTATE_SET_STENCIL_OP(CRSTATE_STENCIL_BUFFER_ID_FRONT, _); + frontIsSet = GL_TRUE; + } + + if ((!frontIsSet || !backIsSet) && CHECKDIRTY(sb->stencil.bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, negbitID)) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + CRSTATE_SET_STENCIL_OP(CRSTATE_STENCIL_BUFFER_ID_FRONT, _); + if (!backIsSet) + { + g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail = g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail; + g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail = g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail; + g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass = g->stencil.buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass; + } + } + + if (CHECKDIRTY(sb->stencil.clearValue, negbitID)) + { + CRSTATE_SET_INT(stencil.clearValue, GL_STENCIL_CLEAR_VALUE); + } + + if (CHECKDIRTY(sb->stencil.writeMask, negbitID)) + { + CRSTATE_SET_INT(stencil.writeMask, GL_STENCIL_WRITEMASK); + } + } + + if (CHECKDIRTY(sb->texture.dirty, negbitID)) + { + unsigned int i, activeUnit = g->texture.curTextureUnit; + + for (i=0; ilimits.maxTextureUnits; ++i) + { + if (CHECKDIRTY(sb->texture.enable[i], negbitID)) + { + if (i!=activeUnit) + { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); + activeUnit=i; + } + CRSTATE_SET_ENABLED(texture.unit[i].enabled1D, GL_TEXTURE_1D); + CRSTATE_SET_ENABLED(texture.unit[i].enabled2D, GL_TEXTURE_2D); +#ifdef CR_OPENGL_VERSION_1_2 + CRSTATE_SET_ENABLED(texture.unit[i].enabled3D, GL_TEXTURE_3D); +#endif +#ifdef CR_ARB_texture_cube_map + if (g->extensions.ARB_texture_cube_map) + { + CRSTATE_SET_ENABLED(texture.unit[i].enabledCubeMap, GL_TEXTURE_CUBE_MAP_ARB); + } +#endif +#ifdef CR_NV_texture_rectangle + if (g->extensions.NV_texture_rectangle) + { + CRSTATE_SET_ENABLED(texture.unit[i].enabledRect, GL_TEXTURE_RECTANGLE_NV); + } +#endif + + CRSTATE_SET_ENABLED(texture.unit[i].textureGen.s, GL_TEXTURE_GEN_S); + CRSTATE_SET_ENABLED(texture.unit[i].textureGen.t, GL_TEXTURE_GEN_T); + CRSTATE_SET_ENABLED(texture.unit[i].textureGen.r, GL_TEXTURE_GEN_R); + CRSTATE_SET_ENABLED(texture.unit[i].textureGen.q, GL_TEXTURE_GEN_Q); + } + + if (CHECKDIRTY(sb->texture.current[i], negbitID)) + { + if (i!=activeUnit) + { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); + activeUnit=i; + } + + CRSTATE_SET_TEXTURE(texture.unit[i].currentTexture1D, GL_TEXTURE_BINDING_1D, GL_TEXTURE_1D); + CRSTATE_SET_TEXTURE(texture.unit[i].currentTexture2D, GL_TEXTURE_BINDING_2D, GL_TEXTURE_2D); +#ifdef CR_OPENGL_VERSION_1_2 + CRSTATE_SET_TEXTURE(texture.unit[i].currentTexture3D, GL_TEXTURE_BINDING_3D, GL_TEXTURE_3D); +#endif +#ifdef CR_ARB_texture_cube_map + if (g->extensions.ARB_texture_cube_map) + { + CRSTATE_SET_TEXTURE(texture.unit[i].currentTextureCubeMap, GL_TEXTURE_BINDING_CUBE_MAP_ARB, GL_TEXTURE_CUBE_MAP_ARB); + } +#endif +#ifdef CR_NV_texture_rectangle + if (g->extensions.NV_texture_rectangle) + { + CRSTATE_SET_TEXTURE(texture.unit[i].currentTextureRect, GL_TEXTURE_BINDING_RECTANGLE_NV, GL_TEXTURE_RECTANGLE_NV); + } +#endif + } + + if (CHECKDIRTY(sb->texture.objGen[i], negbitID)) + { + if (i!=activeUnit) + { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); + activeUnit=i; + } + + CRSTATE_SET_TEXGEN_4F(texture.unit[i].objSCoeff, GL_S, GL_OBJECT_PLANE); + CRSTATE_SET_TEXGEN_4F(texture.unit[i].objTCoeff, GL_T, GL_OBJECT_PLANE); + CRSTATE_SET_TEXGEN_4F(texture.unit[i].objRCoeff, GL_R, GL_OBJECT_PLANE); + CRSTATE_SET_TEXGEN_4F(texture.unit[i].objQCoeff, GL_Q, GL_OBJECT_PLANE); + } + + if (CHECKDIRTY(sb->texture.eyeGen[i], negbitID)) + { + if (i!=activeUnit) + { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); + activeUnit=i; + } + + CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeSCoeff, GL_S, GL_EYE_PLANE); + CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeTCoeff, GL_T, GL_EYE_PLANE); + CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeRCoeff, GL_R, GL_EYE_PLANE); + CRSTATE_SET_TEXGEN_4F(texture.unit[i].eyeQCoeff, GL_Q, GL_EYE_PLANE); + } + + if (CHECKDIRTY(sb->texture.genMode[i], negbitID)) + { + if (i!=activeUnit) + { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); + activeUnit=i; + } + + CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.s, GL_S, GL_TEXTURE_GEN_MODE); + CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.t, GL_T, GL_TEXTURE_GEN_MODE); + CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.r, GL_R, GL_TEXTURE_GEN_MODE); + CRSTATE_SET_TEXGEN_I(texture.unit[i].gen.q, GL_Q, GL_TEXTURE_GEN_MODE); + } + + if (CHECKDIRTY(sb->texture.envBit[i], negbitID)) + { + if (i!=activeUnit) + { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); + activeUnit=i; + } + + CRSTATE_SET_TEXENV_I(texture.unit[i].envMode, GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE); + CRSTATE_SET_TEXENV_COLOR(texture.unit[i].envColor, GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineModeRGB, GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineModeA, GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceRGB[0], GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceRGB[1], GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceRGB[2], GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceA[0], GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceA[1], GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineSourceA[2], GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandRGB[0], GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandRGB[1], GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandRGB[2], GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandA[0], GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandA[1], GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB); + CRSTATE_SET_TEXENV_I(texture.unit[i].combineOperandA[2], GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB); + CRSTATE_SET_TEXENV_F(texture.unit[i].combineScaleRGB, GL_TEXTURE_ENV, GL_RGB_SCALE_ARB); + CRSTATE_SET_TEXENV_F(texture.unit[i].combineScaleA, GL_TEXTURE_ENV, GL_ALPHA_SCALE); + } + } + if (activeUnit!=g->texture.curTextureUnit) + { + diff_api.ActiveTextureARB(g->texture.curTextureUnit + GL_TEXTURE0_ARB); + } + } + + if (CHECKDIRTY(sb->lighting.dirty, negbitID)) + { + int i; + + if (CHECKDIRTY(sb->lighting.enable, negbitID)) + { + CRSTATE_SET_ENABLED(lighting.lighting, GL_LIGHTING); + CRSTATE_SET_ENABLED(lighting.colorMaterial, GL_COLOR_MATERIAL); + CRSTATE_SET_ENABLED(lighting.colorSumEXT, GL_COLOR_SUM_EXT); + } + + if (CHECKDIRTY(sb->lighting.shadeModel, negbitID)) + { + CRSTATE_SET_ENUM(lighting.shadeModel, GL_SHADE_MODEL); + } + + if (CHECKDIRTY(sb->lighting.colorMaterial, negbitID)) + { + CRSTATE_SET_ENUM(lighting.colorMaterialFace, GL_COLOR_MATERIAL_FACE); + CRSTATE_SET_ENUM(lighting.colorMaterialMode, GL_COLOR_MATERIAL_PARAMETER); + } + + if (CHECKDIRTY(sb->lighting.lightModel, negbitID)) + { + CRSTATE_SET_COLORF(lighting.lightModelAmbient, GL_LIGHT_MODEL_AMBIENT); + CRSTATE_SET_BOOL(lighting.lightModelLocalViewer, GL_LIGHT_MODEL_LOCAL_VIEWER); + CRSTATE_SET_BOOL(lighting.lightModelTwoSide, GL_LIGHT_MODEL_TWO_SIDE); + CRSTATE_SET_ENUM(lighting.lightModelColorControlEXT, GL_LIGHT_MODEL_COLOR_CONTROL); + } + + if (CHECKDIRTY(sb->lighting.material, negbitID)) + { + CRSTATE_SET_MATERIAL_COLOR(lighting.ambient[0], GL_FRONT, GL_AMBIENT); + CRSTATE_SET_MATERIAL_COLOR(lighting.ambient[1], GL_BACK, GL_AMBIENT); + CRSTATE_SET_MATERIAL_COLOR(lighting.diffuse[0], GL_FRONT, GL_DIFFUSE); + CRSTATE_SET_MATERIAL_COLOR(lighting.diffuse[1], GL_BACK, GL_DIFFUSE); + CRSTATE_SET_MATERIAL_COLOR(lighting.specular[0], GL_FRONT, GL_SPECULAR); + CRSTATE_SET_MATERIAL_COLOR(lighting.specular[1], GL_BACK, GL_SPECULAR); + CRSTATE_SET_MATERIAL_COLOR(lighting.emission[0], GL_FRONT, GL_EMISSION); + CRSTATE_SET_MATERIAL_COLOR(lighting.emission[1], GL_BACK, GL_EMISSION); + CRSTATE_SET_MATERIAL_F(lighting.shininess[0], GL_FRONT, GL_SHININESS); + CRSTATE_SET_MATERIAL_F(lighting.shininess[1], GL_BACK, GL_SHININESS); + } + + for (i=0; ilighting.light[i].dirty, negbitID)) + { + if (CHECKDIRTY(sb->lighting.light[i].enable, negbitID)) + { + CRSTATE_SET_ENABLED(lighting.light[i].enable, GL_LIGHT0+i); + } + + if (CHECKDIRTY(sb->lighting.light[i].ambient, negbitID)) + { + CRSTATE_SET_LIGHT_COLOR(lighting.light[i].ambient, GL_LIGHT0+i, GL_AMBIENT); + } + + if (CHECKDIRTY(sb->lighting.light[i].diffuse, negbitID)) + { + CRSTATE_SET_LIGHT_COLOR(lighting.light[i].diffuse, GL_LIGHT0+i, GL_DIFFUSE); + } + + if (CHECKDIRTY(sb->lighting.light[i].specular, negbitID)) + { + CRSTATE_SET_LIGHT_COLOR(lighting.light[i].specular, GL_LIGHT0+i, GL_SPECULAR); + } + + if (CHECKDIRTY(sb->lighting.light[i].position, negbitID)) + { + CRSTATE_SET_LIGHT_4F(lighting.light[i].position, GL_LIGHT0+i, GL_POSITION); + } + + if (CHECKDIRTY(sb->lighting.light[i].attenuation, negbitID)) + { + CRSTATE_SET_LIGHT_F(lighting.light[i].constantAttenuation, GL_LIGHT0+i, GL_CONSTANT_ATTENUATION); + CRSTATE_SET_LIGHT_F(lighting.light[i].linearAttenuation, GL_LIGHT0+i, GL_LINEAR_ATTENUATION); + CRSTATE_SET_LIGHT_F(lighting.light[i].quadraticAttenuation, GL_LIGHT0+i, GL_QUADRATIC_ATTENUATION); + } + + if (CHECKDIRTY(sb->lighting.light[i].spot, negbitID)) + { + CRSTATE_SET_LIGHT_3F(lighting.light[i].spotDirection, GL_LIGHT0+i, GL_SPOT_DIRECTION); + CRSTATE_SET_LIGHT_F(lighting.light[i].spotExponent, GL_LIGHT0+i, GL_SPOT_EXPONENT); + CRSTATE_SET_LIGHT_F(lighting.light[i].spotCutoff, GL_LIGHT0+i, GL_SPOT_CUTOFF); + } + } + } + } + + + if (CHECKDIRTY(sb->transform.dirty, negbitID)) + { + if (CHECKDIRTY(sb->transform.enable, negbitID)) + { + CRSTATE_SET_ENABLED(transform.normalize, GL_NORMALIZE); +#ifdef CR_OPENGL_VERSION_1_2 + CRSTATE_SET_ENABLED(transform.rescaleNormals, GL_RESCALE_NORMAL); +#endif +#ifdef CR_IBM_rasterpos_clip + CRSTATE_SET_ENABLED(transform.rasterPositionUnclipped, GL_RASTER_POSITION_UNCLIPPED_IBM); +#endif + } + + if (CHECKDIRTY(sb->transform.clipPlane, negbitID)) + { + int i; + for (i=0; itransform.modelviewMatrix, negbitID)) + { + CRSTATE_SET_MATRIX(transform.modelViewStack.top, GL_MODELVIEW_MATRIX); + } + + if (CHECKDIRTY(sb->transform.projectionMatrix, negbitID)) + { + CRSTATE_SET_MATRIX(transform.projectionStack.top, GL_PROJECTION_MATRIX); + } + + if (CHECKDIRTY(sb->transform.textureMatrix, negbitID)) + { + unsigned int i; + for (i=0; ilimits.maxTextureUnits; i++) + { + diff_api.ActiveTextureARB(GL_TEXTURE0_ARB+i); + CRSTATE_SET_MATRIX(transform.textureStack[i].top, GL_TEXTURE_MATRIX); + } + diff_api.ActiveTextureARB(g->texture.curTextureUnit + GL_TEXTURE0_ARB); + } + + if (CHECKDIRTY(sb->transform.colorMatrix, negbitID)) + { + CRSTATE_SET_MATRIX(transform.colorStack.top, GL_COLOR_MATRIX); + } + + if (CHECKDIRTY(sb->transform.matrixMode, negbitID)) + { + CRSTATE_SET_ENUM(transform.matrixMode, GL_MATRIX_MODE); + } + } + + if (CHECKDIRTY(sb->viewport.dirty, negbitID)) + { + if (CHECKDIRTY(sb->viewport.enable, negbitID)) + { + CRSTATE_SET_ENABLED(viewport.scissorTest, GL_SCISSOR_TEST); + } + + if (CHECKDIRTY(sb->viewport.s_dims, negbitID)) + { + GLint value[4]; + value[0] = g->viewport.scissorX; + value[1] = g->viewport.scissorY; + value[2] = g->viewport.scissorW; + value[3] = g->viewport.scissorH; + diff_api.GetIntegerv(GL_SCISSOR_BOX, &value[0]); + CRSTATE_SET_CAP(viewport.scissorX, value[0], "%i"); + CRSTATE_SET_CAP(viewport.scissorY, value[1], "%i"); + CRSTATE_SET_CAP(viewport.scissorW, value[2], "%i"); + CRSTATE_SET_CAP(viewport.scissorH, value[3], "%i"); + } + + if (CHECKDIRTY(sb->viewport.v_dims, negbitID)) + { + GLint value[4]; + value[0] = g->viewport.viewportX; + value[1] = g->viewport.viewportY; + value[2] = g->viewport.viewportW; + value[3] = g->viewport.viewportH; + diff_api.GetIntegerv(GL_VIEWPORT, &value[0]); + CRSTATE_SET_CAP(viewport.viewportX, value[0], "%i"); + CRSTATE_SET_CAP(viewport.viewportY, value[1], "%i"); + CRSTATE_SET_CAP(viewport.viewportW, value[2], "%i"); + CRSTATE_SET_CAP(viewport.viewportH, value[3], "%i"); + } + + if (CHECKDIRTY(sb->viewport.depth, negbitID)) + { + GLfloat value[2]; + value[0] = g->viewport.nearClip; + value[1] = g->viewport.farClip; + diff_api.GetFloatv(GL_DEPTH_RANGE, &value[0]); + CRSTATE_SET_CAP(viewport.nearClip, value[0], "%f"); + CRSTATE_SET_CAP(viewport.farClip, value[1], "%f"); + } + } + + if (CHECKDIRTY(sb->eval.dirty, negbitID)) + { + int i; + const int gleval_sizes_dup[] = {4, 1, 3, 1, 2, 3, 4, 3, 4}; + + if (CHECKDIRTY(sb->eval.enable, negbitID)) + { + CRSTATE_SET_ENABLED(eval.autoNormal, GL_AUTO_NORMAL); + } + + for (i=0; ieval.enable1D[i], negbitID)) + { + CRSTATE_SET_ENABLED(eval.enable1D[i], i + GL_MAP1_COLOR_4); + } + + if (CHECKDIRTY(sb->eval.enable2D[i], negbitID)) + { + CRSTATE_SET_ENABLED(eval.enable2D[i], i + GL_MAP2_COLOR_4); + } + + if (CHECKDIRTY(sb->eval.eval1D[i], negbitID) && g->eval.enable1D[i]) + { + GLfloat *coeffs=NULL; + GLint order; + GLfloat uval[2]; + order = g->eval.eval1D[i].order; + uval[0] = g->eval.eval1D[i].u1; + uval[1] = g->eval.eval1D[i].u2; + diff_api.GetMapiv(i + GL_MAP1_COLOR_4, GL_ORDER, &order); + diff_api.GetMapfv(i + GL_MAP1_COLOR_4, GL_DOMAIN, &uval[0]); + if (order>0) + { + coeffs = crAlloc(order * gleval_sizes_dup[i] * sizeof(GLfloat)); + if (!coeffs) + { + crWarning("crStateQueryHWState: out of memory, at eval1D[%i]", i); + continue; + } + diff_api.GetMapfv(i + GL_MAP1_COLOR_4, GL_COEFF, coeffs); + } + + CRSTATE_SET_CAP(eval.eval1D[i].order, order, "%i"); + CRSTATE_SET_CAP(eval.eval1D[i].u1, uval[0], "%f"); + CRSTATE_SET_CAP(eval.eval1D[i].u2, uval[1], "%f"); + if (g->eval.eval1D[i].coeff) + { + crFree(g->eval.eval1D[i].coeff); + } + g->eval.eval1D[i].coeff = coeffs; + + if (uval[0]!=uval[1]) + { + g->eval.eval1D[i].du = 1.0f / (uval[0] - uval[1]); + } + } + + if (CHECKDIRTY(sb->eval.eval2D[i], negbitID) && g->eval.enable2D[i]) + { + GLfloat *coeffs=NULL; + GLint order[2]; + GLfloat uval[4]; + order[0] = g->eval.eval2D[i].uorder; + order[1] = g->eval.eval2D[i].vorder; + uval[0] = g->eval.eval2D[i].u1; + uval[1] = g->eval.eval2D[i].u2; + uval[2] = g->eval.eval2D[i].v1; + uval[3] = g->eval.eval2D[i].v2; + diff_api.GetMapiv(i + GL_MAP2_COLOR_4, GL_ORDER, &order[0]); + diff_api.GetMapfv(i + GL_MAP2_COLOR_4, GL_DOMAIN, &uval[0]); + if (order[0]>0 && order[1]>0) + { + coeffs = crAlloc(order[0] * order[1] * gleval_sizes_dup[i] * sizeof(GLfloat)); + if (!coeffs) + { + crWarning("crStateQueryHWState: out of memory, at eval2D[%i]", i); + continue; + } + diff_api.GetMapfv(i + GL_MAP1_COLOR_4, GL_COEFF, coeffs); + } + CRSTATE_SET_CAP(eval.eval2D[i].uorder, order[0], "%i"); + CRSTATE_SET_CAP(eval.eval2D[i].vorder, order[1], "%i"); + CRSTATE_SET_CAP(eval.eval2D[i].u1, uval[0], "%f"); + CRSTATE_SET_CAP(eval.eval2D[i].u2, uval[1], "%f"); + CRSTATE_SET_CAP(eval.eval2D[i].v1, uval[2], "%f"); + CRSTATE_SET_CAP(eval.eval2D[i].v2, uval[3], "%f"); + if (g->eval.eval2D[i].coeff) + { + crFree(g->eval.eval2D[i].coeff); + } + g->eval.eval2D[i].coeff = coeffs; + + if (uval[0]!=uval[1]) + { + g->eval.eval2D[i].du = 1.0f / (uval[0] - uval[1]); + } + if (uval[2]!=uval[3]) + { + g->eval.eval2D[i].dv = 1.0f / (uval[2] - uval[3]); + } + } + } + + if (CHECKDIRTY(sb->eval.grid1D, negbitID)) + { + GLfloat value[2]; + CRSTATE_SET_INT(eval.un1D, GL_MAP1_GRID_SEGMENTS); + value[0] = g->eval.u11D; + value[1] = g->eval.u21D; + diff_api.GetFloatv(GL_MAP1_GRID_DOMAIN, &value[0]); + CRSTATE_SET_CAP(eval.u11D, value[0], "%f"); + CRSTATE_SET_CAP(eval.u21D, value[1], "%f"); + } + + if (CHECKDIRTY(sb->eval.grid2D, negbitID)) + { + GLint iv[2]; + GLfloat value[4]; + iv[0] = g->eval.un2D; + iv[1] = g->eval.vn2D; + diff_api.GetIntegerv(GL_MAP1_GRID_SEGMENTS, &iv[0]); + CRSTATE_SET_CAP(eval.un2D, iv[0], "%i"); + CRSTATE_SET_CAP(eval.vn2D, iv[1], "%i"); + value[0] = g->eval.u12D; + value[1] = g->eval.u22D; + value[2] = g->eval.v12D; + value[3] = g->eval.v22D; + diff_api.GetFloatv(GL_MAP2_GRID_DOMAIN, &value[0]); + CRSTATE_SET_CAP(eval.u12D, value[0], "%f"); + CRSTATE_SET_CAP(eval.u22D, value[1], "%f"); + CRSTATE_SET_CAP(eval.v12D, value[2], "%f"); + CRSTATE_SET_CAP(eval.v22D, value[3], "%f"); + } + } + + if (CHECKDIRTY(sb->fog.dirty, negbitID)) + { + if (CHECKDIRTY(sb->fog.enable, negbitID)) + { + CRSTATE_SET_ENABLED(fog.enable, GL_FOG); + } + + if (CHECKDIRTY(sb->fog.color, negbitID)) + { + CRSTATE_SET_COLORF(fog.color, GL_FOG_COLOR); + } + + if (CHECKDIRTY(sb->fog.index, negbitID)) + { + CRSTATE_SET_INT(fog.index, GL_FOG_INDEX); + } + + if (CHECKDIRTY(sb->fog.density, negbitID)) + { + CRSTATE_SET_FLOAT(fog.density, GL_FOG_DENSITY); + } + + if (CHECKDIRTY(sb->fog.start, negbitID)) + { + CRSTATE_SET_FLOAT(fog.start, GL_FOG_START); + } + + if (CHECKDIRTY(sb->fog.end, negbitID)) + { + CRSTATE_SET_FLOAT(fog.end, GL_FOG_END); + } + + if (CHECKDIRTY(sb->fog.mode, negbitID)) + { + CRSTATE_SET_INT(fog.mode, GL_FOG_MODE); + } + +#ifdef CR_NV_fog_distance + if (CHECKDIRTY(sb->fog.fogDistanceMode, negbitID)) + { + CRSTATE_SET_ENUM(fog.fogDistanceMode, GL_FOG_DISTANCE_MODE_NV); + } +#endif +#ifdef CR_EXT_fog_coord + if (CHECKDIRTY(sb->fog.fogCoordinateSource, negbitID)) + { + CRSTATE_SET_ENUM(fog.fogCoordinateSource, GL_FOG_COORDINATE_SOURCE_EXT); + } +#endif + } + + if (CHECKDIRTY(sb->hint.dirty, negbitID)) + { + if (CHECKDIRTY(sb->hint.perspectiveCorrection, negbitID)) + { + CRSTATE_SET_ENUM(hint.perspectiveCorrection, GL_PERSPECTIVE_CORRECTION_HINT); + } + + if (CHECKDIRTY(sb->hint.pointSmooth, negbitID)) + { + CRSTATE_SET_ENUM(hint.pointSmooth, GL_POINT_SMOOTH_HINT); + } + + if (CHECKDIRTY(sb->hint.lineSmooth, negbitID)) + { + CRSTATE_SET_ENUM(hint.lineSmooth, GL_LINE_SMOOTH_HINT); + } + + if (CHECKDIRTY(sb->hint.polygonSmooth, negbitID)) + { + CRSTATE_SET_ENUM(hint.polygonSmooth, GL_POINT_SMOOTH_HINT); + } + + if (CHECKDIRTY(sb->hint.fog, negbitID)) + { + CRSTATE_SET_ENUM(hint.fog, GL_FOG_HINT); + } + +#ifdef CR_EXT_clip_volume_hint + if (CHECKDIRTY(sb->hint.clipVolumeClipping, negbitID)) + { + CRSTATE_SET_ENUM(hint.clipVolumeClipping, GL_CLIP_VOLUME_CLIPPING_HINT_EXT); + } +#endif +#ifdef CR_ARB_texture_compression + if (CHECKDIRTY(sb->hint.textureCompression, negbitID)) + { + CRSTATE_SET_ENUM(hint.textureCompression, GL_TEXTURE_COMPRESSION_HINT_ARB); + } +#endif +#ifdef CR_SGIS_generate_mipmap + if (CHECKDIRTY(sb->hint.generateMipmap, negbitID)) + { + CRSTATE_SET_ENUM(hint.generateMipmap, GL_GENERATE_MIPMAP_HINT_SGIS); + } +#endif + } + + if (CHECKDIRTY(sb->line.dirty, negbitID)) + { + if (CHECKDIRTY(sb->line.enable, negbitID)) + { + CRSTATE_SET_ENABLED(line.lineSmooth, GL_LINE_SMOOTH); + CRSTATE_SET_ENABLED(line.lineStipple, GL_LINE_STIPPLE); + } + + if (CHECKDIRTY(sb->line.width, negbitID)) + { + CRSTATE_SET_FLOAT(line.width, GL_LINE_WIDTH); + } + + if (CHECKDIRTY(sb->line.stipple, negbitID)) + { + CRSTATE_SET_INT(line.repeat, GL_LINE_STIPPLE_REPEAT); + CRSTATE_SET_INT(line.pattern, GL_LINE_STIPPLE_PATTERN); + } + } + + if (CHECKDIRTY(sb->multisample.dirty, negbitID)) + { + if (CHECKDIRTY(sb->multisample.enable, negbitID)) + { + CRSTATE_SET_ENABLED(multisample.enabled, GL_MULTISAMPLE_ARB); + CRSTATE_SET_ENABLED(multisample.sampleAlphaToCoverage, GL_SAMPLE_ALPHA_TO_COVERAGE_ARB); + CRSTATE_SET_ENABLED(multisample.sampleAlphaToOne, GL_SAMPLE_ALPHA_TO_ONE_ARB); + CRSTATE_SET_ENABLED(multisample.sampleCoverage, GL_SAMPLE_COVERAGE_ARB); + } + + if (CHECKDIRTY(sb->multisample.sampleCoverageValue, negbitID)) + { + CRSTATE_SET_FLOAT(multisample.sampleCoverageValue, GL_SAMPLE_COVERAGE_VALUE_ARB) + CRSTATE_SET_BOOL(multisample.sampleCoverageInvert, GL_SAMPLE_COVERAGE_INVERT_ARB) + } + } + + if (CHECKDIRTY(sb->point.dirty, negbitID)) + { + if (CHECKDIRTY(sb->point.enableSmooth, negbitID)) + { + CRSTATE_SET_ENABLED(point.pointSmooth, GL_POINT_SMOOTH); + } + + if (CHECKDIRTY(sb->point.size, negbitID)) + { + CRSTATE_SET_FLOAT(point.pointSize, GL_POINT_SIZE); + } + +#ifdef CR_ARB_point_parameters + if (CHECKDIRTY(sb->point.minSize, negbitID)) + { + CRSTATE_SET_FLOAT(point.minSize, GL_POINT_SIZE_MIN_ARB); + } + + if (CHECKDIRTY(sb->point.maxSize, negbitID)) + { + CRSTATE_SET_FLOAT(point.maxSize, GL_POINT_SIZE_MAX_ARB); + } + + if (CHECKDIRTY(sb->point.fadeThresholdSize, negbitID)) + { + CRSTATE_SET_FLOAT(point.fadeThresholdSize, GL_POINT_FADE_THRESHOLD_SIZE_ARB); + } + + if (CHECKDIRTY(sb->point.distanceAttenuation, negbitID)) + { + GLfloat value[3]; + value[0] = g->point.distanceAttenuation[0]; + value[1] = g->point.distanceAttenuation[1]; + value[2] = g->point.distanceAttenuation[2]; + diff_api.GetFloatv(GL_POINT_DISTANCE_ATTENUATION, &value[0]); + CRSTATE_SET_CAP(point.distanceAttenuation[0], value[0], "%f"); + CRSTATE_SET_CAP(point.distanceAttenuation[1], value[1], "%f"); + CRSTATE_SET_CAP(point.distanceAttenuation[2], value[2], "%f"); + } +#endif +#ifdef CR_ARB_point_sprite + if (CHECKDIRTY(sb->point.enableSprite, negbitID)) + { + CRSTATE_SET_ENABLED(point.pointSprite, GL_POINT_SPRITE_ARB); + } + + { + unsigned int i, activeUnit = g->texture.curTextureUnit; + for (i=0; ilimits.maxTextureUnits; ++i) + { + if (CHECKDIRTY(sb->point.coordReplacement[i], negbitID)) + { + GLint val=g->point.coordReplacement[i]; + if (activeUnit!=i) + { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB); + activeUnit=i; + } + diff_api.GetTexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &val); + CRSTATE_SET_CAP(point.coordReplacement[i], val, "%i"); + } + } + + if (activeUnit!=g->texture.curTextureUnit) + { + diff_api.ActiveTextureARB(g->texture.curTextureUnit + GL_TEXTURE0_ARB); + } + } +#endif + } + + if (CHECKDIRTY(sb->polygon.dirty, negbitID)) + { + if (CHECKDIRTY(sb->polygon.enable, negbitID)) + { + CRSTATE_SET_ENABLED(polygon.polygonSmooth, GL_POLYGON_SMOOTH); + CRSTATE_SET_ENABLED(polygon.polygonOffsetFill, GL_POLYGON_OFFSET_FILL); + CRSTATE_SET_ENABLED(polygon.polygonOffsetLine, GL_POLYGON_OFFSET_LINE); + CRSTATE_SET_ENABLED(polygon.polygonOffsetPoint, GL_POLYGON_OFFSET_POINT); + CRSTATE_SET_ENABLED(polygon.polygonStipple, GL_POLYGON_STIPPLE); + CRSTATE_SET_ENABLED(polygon.cullFace, GL_CULL_FACE); + } + + if (CHECKDIRTY(sb->polygon.offset, negbitID)) + { + CRSTATE_SET_FLOAT(polygon.offsetFactor, GL_POLYGON_OFFSET_FACTOR); + CRSTATE_SET_FLOAT(polygon.offsetUnits, GL_POLYGON_OFFSET_UNITS); + } + + if (CHECKDIRTY(sb->polygon.mode, negbitID)) + { + GLint val[2]; + CRSTATE_SET_ENUM(polygon.frontFace, GL_FRONT_FACE); + CRSTATE_SET_ENUM(polygon.cullFaceMode, GL_CULL_FACE_MODE); + val[0] = g->polygon.frontMode; + val[1] = g->polygon.backMode; + diff_api.GetIntegerv(GL_POLYGON_MODE, &val[0]); + CRSTATE_SET_CAP(polygon.frontMode, val[0], "%#x"); + CRSTATE_SET_CAP(polygon.backMode, val[1], "%#x"); + + + } + + if (CHECKDIRTY(sb->polygon.stipple, negbitID)) + { + GLint stipple[32]; + crMemcpy(&stipple[0], &g->polygon.stipple[0], sizeof(stipple)); + diff_api.GetPolygonStipple((GLubyte*) &stipple[0]); + if (crMemcmp(&stipple[0], &g->polygon.stipple[0], sizeof(stipple))) + { +#ifdef CRSTATE_DEBUG_QUERY_HW_STATE + { + crDebug("crStateQueryHWState fixed polygon.stipple"); + } +#endif + crMemcpy(&g->polygon.stipple[0], &stipple[0], sizeof(stipple)); + } + } + } + + CR_STATE_CLEAN_HW_ERR_WARN("error on hw sync"); +} + +void STATE_APIENTRY crStateNewList (GLuint list, GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRListsState *l = &(g->lists); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glNewList called in Begin/End"); + return; + } + + if (list == 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glNewList(list=0)"); + return; + } + + if (l->currentIndex) + { + /* already building a list */ + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glNewList called inside display list"); + return; + } + + if (mode != GL_COMPILE && mode != GL_COMPILE_AND_EXECUTE) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glNewList invalid mode"); + return; + } + + FLUSH(); + + /* Must log that this key is used */ + if (!crHashtableIsKeyUsed(g->shared->dlistTable, list)) { + crHashtableAdd(g->shared->dlistTable, list, NULL); + } + + /* Need this??? + crStateCurrentRecover(); + */ + + l->currentIndex = list; + l->mode = mode; +} + +void STATE_APIENTRY crStateEndList (void) +{ + CRContext *g = GetCurrentContext(); + CRListsState *l = &(g->lists); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEndList called in Begin/End"); + return; + } + + if (!l->currentIndex) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glEndList called outside display list"); + return; + } + + l->currentIndex = 0; + l->mode = 0; +} + +GLuint STATE_APIENTRY crStateGenLists(GLsizei range) +{ + CRContext *g = GetCurrentContext(); + GLuint start; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glGenLists called in Begin/End"); + return 0; + } + + if (range < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative range passed to glGenLists: %d", range); + return 0; + } + + start = crHashtableAllocKeys(g->shared->dlistTable, range); + + CRASSERT(start > 0); + return start; +} + +void STATE_APIENTRY crStateDeleteLists (GLuint list, GLsizei range) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDeleteLists called in Begin/End"); + return; + } + + if (range < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "Negative range passed to glDeleteLists: %d", range); + return; + } + + crHashtableDeleteBlock(g->shared->dlistTable, list, range, crFree); /* call crFree to delete list data */ +} + +GLboolean STATE_APIENTRY crStateIsList(GLuint list) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "GenLists called in Begin/End"); + return GL_FALSE; + } + + if (list == 0) + return GL_FALSE; + + return crHashtableIsKeyUsed(g->shared->dlistTable, list); +} + +void STATE_APIENTRY crStateListBase (GLuint base) +{ + CRContext *g = GetCurrentContext(); + CRListsState *l = &(g->lists); + CRStateBits *sb = GetCurrentBits(); + CRListsBits *lb = &(sb->lists); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "ListBase called in Begin/End"); + return; + } + + l->base = base; + + DIRTY(lb->base, g->neg_bitid); + DIRTY(lb->dirty, g->neg_bitid); +} + + +void +crStateListsDiff( CRListsBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + CRListsState *from = &(fromCtx->lists); + CRListsState *to = &(toCtx->lists); + unsigned int j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j=0;jbase, bitID)) + { + if (from->base != to->base) { + diff_api.ListBase(to->base); + from->base = to->base; + } + CLEARDIRTY(b->base, nbitID); + } + + CLEARDIRTY(b->dirty, nbitID); +} + + +void +crStateListsSwitch( CRListsBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + CRListsState *from = &(fromCtx->lists); + CRListsState *to = &(toCtx->lists); + unsigned int j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j=0;jbase, bitID)) + { + if (from->base != to->base) { + diff_api.ListBase(to->base); + FILLDIRTY(b->base); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->base, nbitID); + } + + CLEARDIRTY(b->dirty, nbitID); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.c new file mode 100644 index 00000000..3b7dba5b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.c @@ -0,0 +1,51 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateMultisampleInit (CRContext *ctx) +{ + CRMultisampleState *m = &ctx->multisample; + CRStateBits *sb = GetCurrentBits(); + CRMultisampleBits *mb = &(sb->multisample); + + m->enabled = GL_FALSE; /* TRUE if the visual supports it */ + m->sampleAlphaToCoverage = GL_FALSE; + m->sampleAlphaToOne = GL_FALSE; + m->sampleCoverage = GL_FALSE; + RESET(mb->enable, ctx->bitid); + + m->sampleCoverageValue = 1.0F; + m->sampleCoverageInvert = GL_FALSE; + RESET(mb->sampleCoverageValue, ctx->bitid); + + RESET(mb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateSampleCoverageARB(GLclampf value, GLboolean invert) +{ + CRContext *g = GetCurrentContext(); + CRMultisampleState *m = &(g->multisample); + CRStateBits *sb = GetCurrentBits(); + CRMultisampleBits *mb = &(sb->multisample); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glStateSampleCoverageARB called in begin/end"); + return; + } + + FLUSH(); + + m->sampleCoverageValue = value; + m->sampleCoverageInvert = invert; + DIRTY(mb->dirty, g->neg_bitid); + DIRTY(mb->sampleCoverageValue, g->neg_bitid); +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.txt new file mode 100644 index 00000000..a0ed8bcf --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_multisample.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enable:enabled:GL_MULTISAMPLE_ARB +:enable:sampleAlphaToCoverage:GL_SAMPLE_ALPHA_TO_COVERAGE_ARB +:enable:sampleAlphaToOne:GL_SAMPLE_ALPHA_TO_ONE_ARB +:enable:sampleCoverage:GL_SAMPLE_COVERAGE_ARB +enabled:sampleCoverageValue:sampleCoverageValue,sampleCoverageInvert:SampleCoverageARB diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c new file mode 100644 index 00000000..7249e908 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_occlude.c @@ -0,0 +1,354 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_statefuncs.h" +#include "state_internals.h" +#include "cr_mem.h" + +#if !defined(IN_GUEST) +#include "cr_unpack.h" +#endif + +void +crStateOcclusionInit(CRContext *ctx) +{ + CROcclusionState *o = &ctx->occlusion; + + o->objects = crAllocHashtable(); + o->currentQueryObject = 0; +} + + +void +crStateOcclusionDestroy(CRContext *ctx) +{ + CROcclusionState *o = &(ctx->occlusion); + crFreeHashtable(o->objects, crFree); +} + + +static CROcclusionObject * +NewQueryObject(GLenum target, GLuint id) +{ + CROcclusionObject *q = (CROcclusionObject *) crAlloc(sizeof(CROcclusionObject)); + if (q) { + q->target = target; + q->name = id; + q->passedCounter = 0; + q->active = GL_FALSE; + } + return q; +} + + +void STATE_APIENTRY +crStateDeleteQueriesARB(GLsizei n, const GLuint *ids) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + /*CRStateBits *sb = GetCurrentBits();*/ + /*CROcclusionBits *bb = &(sb->occlusion);*/ + int i; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glDeleteQueriesARB called in Begin/End"); + return; + } + + if (n <= 0 || n >= (GLsizei)(INT32_MAX / sizeof(GLuint))) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glDeleteQueriesARB: parameter 'n' is out of range"); + return; + } + +#if !defined(IN_GUEST) + if (!DATA_POINTER_CHECK(n * sizeof(GLuint))) + { + crError("glDeleteQueriesARB: parameter 'n' is out of range"); + return; + } +#endif + + for (i = 0; i < n; i++) { + if (ids[i]) { + CROcclusionObject *q = (CROcclusionObject *) + crHashtableSearch(o->objects, ids[i]); + if (q) { + crHashtableDelete(o->objects, ids[i], crFree); + } + } + } +} + + +void STATE_APIENTRY +crStateGenQueriesARB(GLsizei n, GLuint * queries) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + GLint start; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGenQueriesARB called in Begin/End"); + return; + } + + if (n < 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGenQueriesARB(n < 0)"); + return; + } + + start = crHashtableAllocKeys(o->objects, n); + if (start) { + GLint i; + for (i = 0; i < n; i++) + queries[i] = (GLuint) (start + i); + } + else { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenQueriesARB"); + } +} + + +GLboolean STATE_APIENTRY +crStateIsQueryARB(GLuint id) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glIsQueryARB called in begin/end"); + return GL_FALSE; + } + + if (id && crHashtableIsKeyUsed(o->objects, id)) + return GL_TRUE; + else + return GL_FALSE; +} + + +void STATE_APIENTRY +crStateGetQueryivARB(GLenum target, GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + (void)target; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetGetQueryivARB called in begin/end"); + return; + } + + switch (pname) { + case GL_QUERY_COUNTER_BITS_ARB: + *params = 8 * sizeof(GLuint); + break; + case GL_CURRENT_QUERY_ARB: + *params = o->currentQueryObject; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetGetQueryivARB(pname)"); + return; + } +} + + +void STATE_APIENTRY +crStateGetQueryObjectivARB(GLuint id, GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + CROcclusionObject *q; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetGetQueryObjectivARB called in begin/end"); + return; + } + + q = (CROcclusionObject *) crHashtableSearch(o->objects, id); + if (!q || q->active) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetQueryObjectivARB"); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + *params = q->passedCounter; + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + *params = GL_TRUE; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetQueryObjectivARB(pname)"); + return; + } +} + + +void STATE_APIENTRY +crStateGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + CROcclusionObject *q; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetGetQueryObjectuivARB called in begin/end"); + return; + } + + q = (CROcclusionObject *) crHashtableSearch(o->objects, id); + if (!q || q->active) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetQueryObjectuivARB"); + return; + } + + switch (pname) { + case GL_QUERY_RESULT_ARB: + *params = q->passedCounter; + break; + case GL_QUERY_RESULT_AVAILABLE_ARB: + /* XXX revisit when we have a hardware implementation! */ + *params = GL_TRUE; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetQueryObjectuivARB(pname)"); + return; + } +} + + +void STATE_APIENTRY +crStateBeginQueryARB(GLenum target, GLuint id) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + CROcclusionObject *q; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetGetQueryObjectuivARB called in begin/end"); + return; + } + + if (target != GL_SAMPLES_PASSED_ARB) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glBeginQueryARB(target)"); + return; + } + + if (o->currentQueryObject) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBeginQueryARB(target)"); + return; + } + + q = (CROcclusionObject *) crHashtableSearch(o->objects, id); + if (q && q->active) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBeginQueryARB"); + return; + } + else if (!q) { + q = NewQueryObject(target, id); + if (!q) { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBeginQueryARB"); + return; + } + crHashtableAdd(o->objects, id, q); + } + + q->active = GL_TRUE; + q->passedCounter = 0; + q->active = GL_TRUE; + q->passedCounter = 0; + o->currentQueryObject = id; +} + + +void STATE_APIENTRY +crStateEndQueryARB(GLenum target) +{ + CRContext *g = GetCurrentContext(); + CROcclusionState *o = &(g->occlusion); + CROcclusionObject *q; + + FLUSH(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetGetQueryObjectuivARB called in begin/end"); + return; + } + + if (target != GL_SAMPLES_PASSED_ARB) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glEndQueryARB(target)"); + return; + } + + q = (CROcclusionObject *) crHashtableSearch(o->objects, o->currentQueryObject); + if (!q || !q->active) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glEndQueryARB with glBeginQueryARB"); + return; + } + + q->passedCounter = 0; + q->active = GL_FALSE; + o->currentQueryObject = 0; +} + + +void crStateOcclusionDiff(CROcclusionBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + /* Apparently, no occlusion state differencing needed */ + (void)bb; (void)bitID; (void)fromCtx; (void)toCtx; +} + + +/* + * XXX this function might need some testing/fixing. + */ +void crStateOcclusionSwitch(CROcclusionBits *bb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + /* Apparently, no occlusion state switching needed */ + /* Note: we better not do a switch while we're inside a glBeginQuery/ + * glEndQuery sequence. + */ + (void)bb; (void)bitID; (void)fromCtx; (void)toCtx; + CRASSERT(!fromCtx->occlusion.currentQueryObject); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_pixel.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_pixel.c new file mode 100644 index 00000000..58e08aec --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_pixel.c @@ -0,0 +1,857 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "cr_mem.h" +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStatePixelInit(CRContext *ctx) +{ + CRPixelState *p = &ctx->pixel; + CRStateBits *sb = GetCurrentBits(); + CRPixelBits *pb = &(sb->pixel); + GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f}; + GLcolorf one_color = {1.0f, 1.0f, 1.0f, 1.0f}; + + p->mapColor = GL_FALSE; + p->mapStencil = GL_FALSE; + p->indexShift = 0; + p->indexOffset = 0; + p->scale = one_color; + p->depthScale = 1.0f; + p->bias = zero_color; + p->depthBias = 0.0f; + p->xZoom = 1.0f; + p->yZoom = 1.0f; + RESET(pb->transfer, ctx->bitid); + RESET(pb->zoom, ctx->bitid); + + p->mapStoS[0] = 0; + p->mapItoI[0] = 0; + p->mapItoR[0] = 0.0; + p->mapItoG[0] = 0.0; + p->mapItoB[0] = 0.0; + p->mapItoA[0] = 0.0; + p->mapRtoR[0] = 0.0; + p->mapGtoG[0] = 0.0; + p->mapBtoB[0] = 0.0; + p->mapAtoA[0] = 0.0; + + p->mapItoIsize = 1; + p->mapStoSsize = 1; + p->mapItoRsize = 1; + p->mapItoGsize = 1; + p->mapItoBsize = 1; + p->mapItoAsize = 1; + p->mapRtoRsize = 1; + p->mapGtoGsize = 1; + p->mapBtoBsize = 1; + p->mapAtoAsize = 1; + RESET(pb->maps, ctx->bitid); + + RESET(pb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStatePixelTransferi (GLenum pname, GLint param) +{ + crStatePixelTransferf( pname, (GLfloat) param ); +} + +void STATE_APIENTRY crStatePixelTransferf (GLenum pname, GLfloat param) +{ + CRContext *g = GetCurrentContext(); + CRPixelState *p = &(g->pixel); + CRStateBits *sb = GetCurrentBits(); + CRPixelBits *pb = &(sb->pixel); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelTransfer{if} called in Begin/End"); + return; + } + + FLUSH(); + + switch( pname ) + { + case GL_MAP_COLOR: + p->mapColor = (GLboolean) ((param == 0.0f) ? GL_FALSE : GL_TRUE); + break; + case GL_MAP_STENCIL: + p->mapStencil = (GLboolean) ((param == 0.0f) ? GL_FALSE : GL_TRUE); + break; + case GL_INDEX_SHIFT: + p->indexShift = (GLint) param; + break; + case GL_INDEX_OFFSET: + p->indexOffset = (GLint) param; + break; + case GL_RED_SCALE: + p->scale.r = param; + break; + case GL_GREEN_SCALE: + p->scale.g = param; + break; + case GL_BLUE_SCALE: + p->scale.b = param; + break; + case GL_ALPHA_SCALE: + p->scale.a = param; + break; + case GL_DEPTH_SCALE: + p->depthScale = param; + break; + case GL_RED_BIAS: + p->bias.r = param; + break; + case GL_GREEN_BIAS: + p->bias.g = param; + break; + case GL_BLUE_BIAS: + p->bias.b = param; + break; + case GL_ALPHA_BIAS: + p->bias.a = param; + break; + case GL_DEPTH_BIAS: + p->depthBias = param; + break; + default: + crStateError( __LINE__, __FILE__, GL_INVALID_VALUE, "Unknown glPixelTransfer pname: %d", pname ); + return; + } + DIRTY(pb->transfer, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePixelZoom (GLfloat xfactor, GLfloat yfactor) +{ + CRContext *g = GetCurrentContext(); + CRPixelState *p = &(g->pixel); + CRStateBits *sb = GetCurrentBits(); + CRPixelBits *pb = &(sb->pixel); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelZoom called in Begin/End"); + return; + } + + FLUSH(); + + p->xZoom = xfactor; + p->yZoom = yfactor; + DIRTY(pb->zoom, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap) +{ + CRContext *g = GetCurrentContext(); + CRCurrentState *c = &(g->current); + CRStateBits *sb = GetCurrentBits(); + CRCurrentBits *cb = &(sb->current); + + (void) xorig; + (void) yorig; + (void) bitmap; + + if (g->lists.mode == GL_COMPILE) + return; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Bitmap called in begin/end"); + return; + } + + if (width < 0 || height < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "Bitmap called with neg dims: %dx%d", width, height); + return; + } + + if (!c->rasterValid) + { + return; + } + + c->rasterAttrib[VERT_ATTRIB_POS][0] += xmove; + c->rasterAttrib[VERT_ATTRIB_POS][1] += ymove; + DIRTY(cb->rasterPos, g->neg_bitid); + DIRTY(cb->dirty, g->neg_bitid); + + c->rasterAttribPre[VERT_ATTRIB_POS][0] += xmove; + c->rasterAttribPre[VERT_ATTRIB_POS][1] += ymove; +} + + +#define UNUSED(x) ((void)(x)) + +#define CLAMP(x, min, max) ((x) < (min) ? (min) : ((x) > (max) ? (max) : (x))) + +void STATE_APIENTRY crStatePixelMapfv (GLenum map, GLint mapsize, const GLfloat * values) +{ + CRContext *g = GetCurrentContext(); + CRPixelState *p = &(g->pixel); + CRStateBits *sb = GetCurrentBits(); + CRPixelBits *pb = &(sb->pixel); + GLint i; + GLboolean unpackbuffer = crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PixelMap called in Begin/End"); + return; + } + + FLUSH(); + + if (mapsize < 0 || mapsize > CR_MAX_PIXEL_MAP_TABLE) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(mapsize)"); + return; + } + + if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) { + /* XXX check that mapsize is a power of two */ + } + + switch (map) { + case GL_PIXEL_MAP_S_TO_S: + p->mapStoSsize = mapsize; + if (!unpackbuffer) + for (i=0;imapStoS[i] = (GLint) values[i]; + } + break; + case GL_PIXEL_MAP_I_TO_I: + p->mapItoIsize = mapsize; + if (!unpackbuffer) + for (i=0;imapItoI[i] = (GLint) values[i]; + } + break; + case GL_PIXEL_MAP_I_TO_R: + p->mapItoRsize = mapsize; + if (!unpackbuffer) + for (i=0;imapItoR[i] = val; + } + break; + case GL_PIXEL_MAP_I_TO_G: + p->mapItoGsize = mapsize; + if (!unpackbuffer) + for (i=0;imapItoG[i] = val; + } + break; + case GL_PIXEL_MAP_I_TO_B: + p->mapItoBsize = mapsize; + if (!unpackbuffer) + for (i=0;imapItoB[i] = val; + } + break; + case GL_PIXEL_MAP_I_TO_A: + p->mapItoAsize = mapsize; + if (!unpackbuffer) + for (i=0;imapItoA[i] = val; + } + break; + case GL_PIXEL_MAP_R_TO_R: + p->mapRtoRsize = mapsize; + if (!unpackbuffer) + for (i=0;imapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F ); + } + break; + case GL_PIXEL_MAP_G_TO_G: + p->mapGtoGsize = mapsize; + if (!unpackbuffer) + for (i=0;imapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F ); + } + break; + case GL_PIXEL_MAP_B_TO_B: + p->mapBtoBsize = mapsize; + if (!unpackbuffer) + for (i=0;imapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F ); + } + break; + case GL_PIXEL_MAP_A_TO_A: + p->mapAtoAsize = mapsize; + if (!unpackbuffer) + for (i=0;imapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F ); + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "PixelMap(map)"); + return; + } + + DIRTY(pb->maps, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePixelMapuiv (GLenum map, GLint mapsize, const GLuint * values) +{ + if (mapsize < 0 || mapsize > CR_MAX_PIXEL_MAP_TABLE) + { + crError("crStatePixelMapuiv: parameter 'mapsize' is out of range"); + return; + } + + if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + { + GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE]; + GLint i; + + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;i CR_MAX_PIXEL_MAP_TABLE) + { + crError("crStatePixelMapusv: parameter 'mapsize' is out of range"); + return; + } + + if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + { + GLfloat fvalues[CR_MAX_PIXEL_MAP_TABLE]; + GLint i; + + if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { + for (i=0;ipixel); + GLint i; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "GetPixelMapfv called in Begin/End"); + return; + } + + switch (map) { + case GL_PIXEL_MAP_S_TO_S: + for (i = 0; i < p->mapStoSsize; i++) { + values[i] = (GLfloat) p->mapStoS[i]; + } + break; + case GL_PIXEL_MAP_I_TO_I: + for (i = 0; i < p->mapItoIsize; i++) { + values[i] = (GLfloat) p->mapItoI[i]; + } + break; + case GL_PIXEL_MAP_I_TO_R: + crMemcpy(values, p->mapItoR, p->mapItoRsize * sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_I_TO_G: + crMemcpy(values, p->mapItoG, p->mapItoGsize * sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_I_TO_B: + crMemcpy(values, p->mapItoB, p->mapItoBsize * sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_I_TO_A: + crMemcpy(values, p->mapItoA, p->mapItoAsize * sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_R_TO_R: + crMemcpy(values, p->mapRtoR, p->mapRtoRsize * sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_G_TO_G: + crMemcpy(values, p->mapGtoG, p->mapGtoGsize * sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_B_TO_B: + crMemcpy(values, p->mapBtoB, p->mapBtoBsize * sizeof(GLfloat)); + break; + case GL_PIXEL_MAP_A_TO_A: + crMemcpy(values, p->mapAtoA, p->mapAtoAsize * sizeof(GLfloat)); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMap(map)"); + return; + } +} + +void STATE_APIENTRY crStateGetPixelMapuiv (GLenum map, GLuint * values) +{ + CRContext *g = GetCurrentContext(); + const GLfloat maxUint = 4294967295.0F; + CRPixelState *p = &(g->pixel); + GLint i; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "GetPixelMapuiv called in Begin/End"); + return; + } + + switch (map) { + case GL_PIXEL_MAP_S_TO_S: + for (i = 0; i < p->mapStoSsize; i++) { + values[i] = p->mapStoS[i]; + } + break; + case GL_PIXEL_MAP_I_TO_I: + for (i = 0; i < p->mapItoIsize; i++) { + values[i] = p->mapItoI[i]; + } + break; + case GL_PIXEL_MAP_I_TO_R: + for (i = 0; i < p->mapItoRsize; i++) { + values[i] = (GLuint) (p->mapItoR[i] * maxUint); + } + break; + case GL_PIXEL_MAP_I_TO_G: + for (i = 0; i < p->mapItoGsize; i++) { + values[i] = (GLuint) (p->mapItoG[i] * maxUint); + } + break; + case GL_PIXEL_MAP_I_TO_B: + for (i = 0; i < p->mapItoBsize; i++) { + values[i] = (GLuint) (p->mapItoB[i] * maxUint); + } + break; + case GL_PIXEL_MAP_I_TO_A: + for (i = 0; i < p->mapItoAsize; i++) { + values[i] = (GLuint) (p->mapItoA[i] * maxUint); + } + break; + case GL_PIXEL_MAP_R_TO_R: + for (i = 0; i < p->mapRtoRsize; i++) { + values[i] = (GLuint) (p->mapRtoR[i] * maxUint); + } + break; + case GL_PIXEL_MAP_G_TO_G: + for (i = 0; i < p->mapGtoGsize; i++) { + values[i] = (GLuint) (p->mapGtoG[i] * maxUint); + } + break; + case GL_PIXEL_MAP_B_TO_B: + for (i = 0; i < p->mapBtoBsize; i++) { + values[i] = (GLuint) (p->mapBtoB[i] * maxUint); + } + break; + case GL_PIXEL_MAP_A_TO_A: + for (i = 0; i < p->mapAtoAsize; i++) { + values[i] = (GLuint) (p->mapAtoA[i] * maxUint); + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapuiv(map)"); + return; + } +} + +void STATE_APIENTRY crStateGetPixelMapusv (GLenum map, GLushort * values) +{ + CRContext *g = GetCurrentContext(); + const GLfloat maxUshort = 65535.0F; + CRPixelState *p = &(g->pixel); + GLint i; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "GetPixelMapusv called in Begin/End"); + return; + } + + switch (map) { + case GL_PIXEL_MAP_S_TO_S: + for (i = 0; i < p->mapStoSsize; i++) { + values[i] = p->mapStoS[i]; + } + break; + case GL_PIXEL_MAP_I_TO_I: + for (i = 0; i < p->mapItoIsize; i++) { + values[i] = p->mapItoI[i]; + } + break; + case GL_PIXEL_MAP_I_TO_R: + for (i = 0; i < p->mapItoRsize; i++) { + values[i] = (GLushort) (p->mapItoR[i] * maxUshort); + } + break; + case GL_PIXEL_MAP_I_TO_G: + for (i = 0; i < p->mapItoGsize; i++) { + values[i] = (GLushort) (p->mapItoG[i] * maxUshort); + } + break; + case GL_PIXEL_MAP_I_TO_B: + for (i = 0; i < p->mapItoBsize; i++) { + values[i] = (GLushort) (p->mapItoB[i] * maxUshort); + } + break; + case GL_PIXEL_MAP_I_TO_A: + for (i = 0; i < p->mapItoAsize; i++) { + values[i] = (GLushort) (p->mapItoA[i] * maxUshort); + } + break; + case GL_PIXEL_MAP_R_TO_R: + for (i = 0; i < p->mapRtoRsize; i++) { + values[i] = (GLushort) (p->mapRtoR[i] * maxUshort); + } + break; + case GL_PIXEL_MAP_G_TO_G: + for (i = 0; i < p->mapGtoGsize; i++) { + values[i] = (GLushort) (p->mapGtoG[i] * maxUshort); + } + break; + case GL_PIXEL_MAP_B_TO_B: + for (i = 0; i < p->mapBtoBsize; i++) { + values[i] = (GLushort) (p->mapBtoB[i] * maxUshort); + } + break; + case GL_PIXEL_MAP_A_TO_A: + for (i = 0; i < p->mapAtoAsize; i++) { + values[i] = (GLushort) (p->mapAtoA[i] * maxUshort); + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "GetPixelMapusv(map)"); + return; + } +} + +void crStatePixelDiff(CRPixelBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRPixelState *from = &(fromCtx->pixel); + CRPixelState *to = &(toCtx->pixel); + int j, i; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + for (j=0;jtransfer, bitID)) + { + if (from->mapColor != to->mapColor) + { + diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor); + from->mapColor = to->mapColor; + } + if (from->mapStencil != to->mapStencil) + { + diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil); + from->mapStencil = to->mapStencil; + } + if (from->indexOffset != to->indexOffset) + { + diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset); + from->indexOffset = to->indexOffset; + } + if (from->indexShift != to->indexShift) + { + diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift); + from->indexShift = to->indexShift; + } + if (from->scale.r != to->scale.r) + { + diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r); + from->scale.r = to->scale.r; + } + if (from->scale.g != to->scale.g) + { + diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g); + from->scale.g = to->scale.g; + } + if (from->scale.b != to->scale.b) + { + diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b); + from->scale.b = to->scale.b; + } + if (from->scale.a != to->scale.a) + { + diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a); + from->scale.a = to->scale.a; + } + if (from->bias.r != to->bias.r) + { + diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r); + from->bias.r = to->bias.r; + } + if (from->bias.g != to->bias.g) + { + diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g); + from->bias.g = to->bias.g; + } + if (from->bias.b != to->bias.b) + { + diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b); + from->bias.b = to->bias.b; + } + if (from->bias.a != to->bias.a) + { + diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a); + from->bias.a = to->bias.a; + } + if (from->depthScale != to->depthScale) + { + diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale); + from->depthScale = to->depthScale; + } + if (from->depthBias != to->depthBias) + { + diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias); + from->depthBias = to->depthBias; + } + CLEARDIRTY(b->transfer, nbitID); + } + if (CHECKDIRTY(b->zoom, bitID)) + { + if (from->xZoom != to->xZoom || + from->yZoom != to->yZoom) + { + diff_api.PixelZoom (to->xZoom, + to->yZoom); + from->xZoom = to->xZoom; + from->yZoom = to->yZoom; + } + CLEARDIRTY(b->zoom, nbitID); + } + if (CHECKDIRTY(b->maps, bitID)) + { + if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS); + if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI); + if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR); + if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG); + if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB); + if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA); + if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR); + if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG); + if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB); + if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE*sizeof(GLfloat))) + diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA); + CLEARDIRTY(b->maps, nbitID); + } + CLEARDIRTY(b->dirty, nbitID); +} + +void crStatePixelSwitch(CRPixelBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRPixelState *from = &(fromCtx->pixel); + CRPixelState *to = &(toCtx->pixel); + int j, i; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + for (j=0;jtransfer, bitID)) + { + if (from->mapColor != to->mapColor) + { + diff_api.PixelTransferi (GL_MAP_COLOR, to->mapColor); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->mapStencil != to->mapStencil) + { + diff_api.PixelTransferi (GL_MAP_STENCIL, to->mapStencil); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->indexOffset != to->indexOffset) + { + diff_api.PixelTransferi (GL_INDEX_OFFSET, to->indexOffset); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->indexShift != to->indexShift) + { + diff_api.PixelTransferi (GL_INDEX_SHIFT, to->indexShift); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->scale.r != to->scale.r) + { + diff_api.PixelTransferf (GL_RED_SCALE, to->scale.r); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->scale.g != to->scale.g) + { + diff_api.PixelTransferf (GL_GREEN_SCALE, to->scale.g); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->scale.b != to->scale.b) + { + diff_api.PixelTransferf (GL_BLUE_SCALE, to->scale.b); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->scale.a != to->scale.a) + { + diff_api.PixelTransferf (GL_ALPHA_SCALE, to->scale.a); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->bias.r != to->bias.r) + { + diff_api.PixelTransferf (GL_RED_BIAS, to->bias.r); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->bias.g != to->bias.g) + { + diff_api.PixelTransferf (GL_GREEN_BIAS, to->bias.g); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->bias.b != to->bias.b) + { + diff_api.PixelTransferf (GL_BLUE_BIAS, to->bias.b); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->bias.a != to->bias.a) + { + diff_api.PixelTransferf (GL_ALPHA_BIAS, to->bias.a); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->depthScale != to->depthScale) + { + diff_api.PixelTransferf (GL_DEPTH_SCALE, to->depthScale); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + if (from->depthBias != to->depthBias) + { + diff_api.PixelTransferf (GL_DEPTH_BIAS, to->depthBias); + FILLDIRTY(b->transfer); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->transfer, nbitID); + } + if (CHECKDIRTY(b->zoom, bitID)) + { + if (from->xZoom != to->xZoom || + from->yZoom != to->yZoom) + { + diff_api.PixelZoom (to->xZoom, + to->yZoom); + FILLDIRTY(b->zoom); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->zoom, nbitID); + } + if (CHECKDIRTY(b->maps, bitID)) + { + if (crMemcmp(to->mapStoS, from->mapStoS, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_S_TO_S,to->mapStoSsize,(GLfloat*)to->mapStoS); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapItoI, from->mapItoI, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_I,to->mapItoIsize,(GLfloat*)to->mapItoI); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapItoR, from->mapItoR, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_R,to->mapItoRsize,(GLfloat*)to->mapItoR); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapItoG, from->mapItoG, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_G,to->mapItoGsize,(GLfloat*)to->mapItoG); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapItoB, from->mapItoB, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_B,to->mapItoBsize,(GLfloat*)to->mapItoB); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapItoA, from->mapItoA, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_I_TO_A,to->mapItoAsize,(GLfloat*)to->mapItoA); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapRtoR, from->mapRtoR, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_R_TO_R,to->mapRtoRsize,(GLfloat*)to->mapRtoR); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapGtoG, from->mapGtoG, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_G_TO_G,to->mapGtoGsize,(GLfloat*)to->mapGtoG); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapBtoB, from->mapBtoB, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_B_TO_B,to->mapBtoBsize,(GLfloat*)to->mapBtoB); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + if (crMemcmp(to->mapAtoA, from->mapAtoA, CR_MAX_PIXEL_MAP_TABLE)) { + diff_api.PixelMapfv(GL_PIXEL_MAP_A_TO_A,to->mapAtoAsize,(GLfloat*)to->mapAtoA); + FILLDIRTY(b->maps); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->maps, nbitID); + } + CLEARDIRTY(b->dirty, nbitID); +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_point.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_point.c new file mode 100644 index 00000000..de40c089 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_point.c @@ -0,0 +1,447 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStatePointInit (CRContext *ctx) +{ + CRPointState *p = &ctx->point; + CRStateBits *sb = GetCurrentBits(); + CRPointBits *pb = &(sb->point); + int i; + + p->pointSmooth = GL_FALSE; + RESET(pb->enableSmooth, ctx->bitid); + p->pointSize = 1.0f; + RESET(pb->size, ctx->bitid); +#ifdef CR_ARB_point_parameters + p->minSize = 0.0f; + RESET(pb->minSize, ctx->bitid); + p->maxSize = CR_ALIASED_POINT_SIZE_MAX; + RESET(pb->maxSize, ctx->bitid); + p->fadeThresholdSize = 1.0f; + RESET(pb->fadeThresholdSize, ctx->bitid); + p->distanceAttenuation[0] = 1.0f; + p->distanceAttenuation[1] = 0.0f; + p->distanceAttenuation[2] = 0.0f; + RESET(pb->distanceAttenuation, ctx->bitid); +#endif +#ifdef CR_ARB_point_sprite + p->pointSprite = GL_FALSE; + RESET(pb->enableSprite, ctx->bitid); + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) { + p->coordReplacement[i] = GL_FALSE; + RESET(pb->coordReplacement[i], ctx->bitid); + } +#endif + + p->spriteCoordOrigin = (GLfloat)GL_UPPER_LEFT; + RESET(pb->spriteCoordOrigin, ctx->bitid); + + RESET(pb->dirty, ctx->bitid); + + /* + *p->aliasedpointsizerange_min = c->aliasedpointsizerange_min; + *p->aliasedpointsizerange_max = c->aliasedpointsizerange_max; + *p->aliasedpointsizegranularity = c->aliasedpointsizegranularity; + *p->smoothpointsizerange_min = c->smoothpointsizerange_min; + *p->smoothpointsizerange_max = c->smoothpointsizerange_max; + *p->smoothpointgranularity = c->smoothpointgranularity; + */ +} + +void STATE_APIENTRY crStatePointSize(GLfloat size) +{ + CRContext *g = GetCurrentContext(); + CRPointState *p = &(g->point); + CRStateBits *sb = GetCurrentBits(); + CRPointBits *pb = &(sb->point); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointSize called in begin/end"); + return; + } + + FLUSH(); + + if (size <= 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointSize called with size <= 0.0: %f", size); + return; + } + + p->pointSize = size; + DIRTY(pb->size, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePointParameterfARB(GLenum pname, GLfloat param) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointParameterfARB called in begin/end"); + return; + } + + FLUSH(); + + crStatePointParameterfvARB(pname, ¶m); +} + +void STATE_APIENTRY crStatePointParameterfvARB(GLenum pname, const GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRPointState *p = &(g->point); + CRStateBits *sb = GetCurrentBits(); + CRPointBits *pb = &(sb->point); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glPointParameterfvARB called in begin/end"); + return; + } + + FLUSH(); + + switch (pname) { + case GL_DISTANCE_ATTENUATION_EXT: + if (g->extensions.ARB_point_parameters) { + p->distanceAttenuation[0] = params[0]; + p->distanceAttenuation[1] = params[1]; + p->distanceAttenuation[2] = params[2]; + DIRTY(pb->distanceAttenuation, g->neg_bitid); + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname); + return; + } + break; + case GL_POINT_SIZE_MIN_EXT: + if (g->extensions.ARB_point_parameters) { + if (params[0] < 0.0F) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]); + return; + } + p->minSize = params[0]; + DIRTY(pb->minSize, g->neg_bitid); + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname); + return; + } + break; + case GL_POINT_SIZE_MAX_EXT: + if (g->extensions.ARB_point_parameters) { + if (params[0] < 0.0F) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]); + return; + } + p->maxSize = params[0]; + DIRTY(pb->maxSize, g->neg_bitid); + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname); + return; + } + break; + case GL_POINT_FADE_THRESHOLD_SIZE_EXT: + if (g->extensions.ARB_point_parameters) { + if (params[0] < 0.0F) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid value: %f", params[0]); + return; + } + p->fadeThresholdSize = params[0]; + DIRTY(pb->fadeThresholdSize, g->neg_bitid); + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname); + return; + } + break; + case GL_POINT_SPRITE_COORD_ORIGIN: + { + GLenum enmVal = (GLenum)params[0]; + if (enmVal != GL_LOWER_LEFT && enmVal != GL_UPPER_LEFT) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glPointParameterfvARB invalid GL_POINT_SPRITE_COORD_ORIGIN value: %f", params[0]); + return; + } + p->spriteCoordOrigin = params[0]; + DIRTY(pb->spriteCoordOrigin, g->neg_bitid); + break; + } + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glPointParameterfvARB invalid enum: %f", pname); + return; + } + + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePointParameteri(GLenum pname, GLint param) +{ + GLfloat f_param = (GLfloat) param; + crStatePointParameterfvARB( pname, &f_param ); +} + +void STATE_APIENTRY crStatePointParameteriv(GLenum pname, const GLint *params) +{ + GLfloat f_param = (GLfloat) (*params); + crStatePointParameterfvARB( pname, &f_param ); +} + +void crStatePointDiff(CRPointBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRPointState *from = &(fromCtx->point); + CRPointState *to = &(toCtx->point); + unsigned int j, i; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + Assert(0); + for (j=0;jenableSmooth, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->pointSmooth != to->pointSmooth) + { + able[to->pointSmooth](GL_POINT_SMOOTH); + from->pointSmooth = to->pointSmooth; + } + CLEARDIRTY(b->enableSmooth, nbitID); + } + if (CHECKDIRTY(b->size, bitID)) + { + if (from->pointSize != to->pointSize) + { + diff_api.PointSize (to->pointSize); + from->pointSize = to->pointSize; + } + CLEARDIRTY(b->size, nbitID); + } + if (CHECKDIRTY(b->minSize, bitID)) + { + if (from->minSize != to->minSize) + { + diff_api.PointParameterfARB (GL_POINT_SIZE_MIN_ARB, to->minSize); + from->minSize = to->minSize; + } + CLEARDIRTY(b->minSize, nbitID); + } + if (CHECKDIRTY(b->maxSize, bitID)) + { + if (from->maxSize != to->maxSize) + { + diff_api.PointParameterfARB (GL_POINT_SIZE_MAX_ARB, to->maxSize); + from->maxSize = to->maxSize; + } + CLEARDIRTY(b->maxSize, nbitID); + } + if (CHECKDIRTY(b->fadeThresholdSize, bitID)) + { + if (from->fadeThresholdSize != to->fadeThresholdSize) + { + diff_api.PointParameterfARB (GL_POINT_FADE_THRESHOLD_SIZE_ARB, to->fadeThresholdSize); + from->fadeThresholdSize = to->fadeThresholdSize; + } + CLEARDIRTY(b->fadeThresholdSize, nbitID); + } + if (CHECKDIRTY(b->spriteCoordOrigin, bitID)) + { + if (from->spriteCoordOrigin != to->spriteCoordOrigin) + { + diff_api.PointParameterfARB (GL_POINT_SPRITE_COORD_ORIGIN, to->spriteCoordOrigin); + from->spriteCoordOrigin = to->spriteCoordOrigin; + } + CLEARDIRTY(b->spriteCoordOrigin, nbitID); + } + if (CHECKDIRTY(b->distanceAttenuation, bitID)) + { + if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) { + diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation); + from->distanceAttenuation[0] = to->distanceAttenuation[0]; + from->distanceAttenuation[1] = to->distanceAttenuation[1]; + from->distanceAttenuation[2] = to->distanceAttenuation[2]; + } + CLEARDIRTY(b->distanceAttenuation, nbitID); + } + if (CHECKDIRTY(b->enableSprite, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->pointSprite != to->pointSprite) + { + able[to->pointSprite](GL_POINT_SPRITE_ARB); + from->pointSprite = to->pointSprite; + } + CLEARDIRTY(b->enableSprite, nbitID); + } + { + unsigned int activeUnit = (unsigned int) -1; + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) { + if (CHECKDIRTY(b->coordReplacement[i], bitID)) + { + GLint replacement = to->coordReplacement[i]; + if (activeUnit != i) { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + diff_api.TexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &replacement); + from->coordReplacement[i] = to->coordReplacement[i]; + CLEARDIRTY(b->coordReplacement[i], nbitID); + } + } + if (activeUnit != toCtx->texture.curTextureUnit) + diff_api.ActiveTextureARB(GL_TEXTURE0 + toCtx->texture.curTextureUnit); + } + CLEARDIRTY(b->dirty, nbitID); +} + +void crStatePointSwitch(CRPointBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRPointState *from = &(fromCtx->point); + CRPointState *to = &(toCtx->point); + unsigned int j, i; + GLboolean fEnabled; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + for (j=0;jenableSmooth, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->pointSmooth != to->pointSmooth) + { + able[to->pointSmooth](GL_POINT_SMOOTH); + FILLDIRTY(b->enableSmooth); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->enableSmooth, nbitID); + } + if (CHECKDIRTY(b->size, bitID)) + { + if (from->pointSize != to->pointSize) + { + diff_api.PointSize (to->pointSize); + FILLDIRTY(b->size); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->size, nbitID); + } + if (CHECKDIRTY(b->minSize, bitID)) + { + if (from->minSize != to->minSize) + { + diff_api.PointParameterfARB (GL_POINT_SIZE_MIN_ARB, to->minSize); + FILLDIRTY(b->minSize); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->minSize, nbitID); + } + if (CHECKDIRTY(b->maxSize, bitID)) + { + if (from->maxSize != to->maxSize) + { + diff_api.PointParameterfARB (GL_POINT_SIZE_MAX_ARB, to->maxSize); + FILLDIRTY(b->maxSize); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->maxSize, nbitID); + } + if (CHECKDIRTY(b->fadeThresholdSize, bitID)) + { + if (from->fadeThresholdSize != to->fadeThresholdSize) + { + diff_api.PointParameterfARB (GL_POINT_FADE_THRESHOLD_SIZE_ARB, to->fadeThresholdSize); + FILLDIRTY(b->fadeThresholdSize); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->fadeThresholdSize, nbitID); + } + if (CHECKDIRTY(b->spriteCoordOrigin, bitID)) + { + if (from->spriteCoordOrigin != to->spriteCoordOrigin) + { + diff_api.PointParameterfARB (GL_POINT_SPRITE_COORD_ORIGIN, to->spriteCoordOrigin); + FILLDIRTY(b->spriteCoordOrigin); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->spriteCoordOrigin, nbitID); + } + if (CHECKDIRTY(b->distanceAttenuation, bitID)) + { + if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) { + diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation); + FILLDIRTY(b->distanceAttenuation); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->distanceAttenuation, nbitID); + } + fEnabled = from->pointSprite; + { + unsigned int activeUnit = (unsigned int) -1; + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) { + if (CHECKDIRTY(b->coordReplacement[i], bitID)) + { + if (!fEnabled) + { + diff_api.Enable(GL_POINT_SPRITE_ARB); + fEnabled = GL_TRUE; + } +#if 0 + /*don't set coord replacement, it will be set just before drawing points when necessary, + * to work around gpu driver bugs + * See crServerDispatch[Begin|End|Draw*] */ + GLint replacement = to->coordReplacement[i]; + if (activeUnit != i) { + diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + diff_api.TexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &replacement); +#endif + CLEARDIRTY(b->coordReplacement[i], nbitID); + } + } + if (activeUnit != toCtx->texture.curTextureUnit) + diff_api.ActiveTextureARB(GL_TEXTURE0 + toCtx->texture.curTextureUnit); + } + if (CHECKDIRTY(b->enableSprite, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (fEnabled != to->pointSprite) + { + able[to->pointSprite](GL_POINT_SPRITE_ARB); + FILLDIRTY(b->enableSprite); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->enableSprite, nbitID); + } + else if (fEnabled != to->pointSprite) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + able[to->pointSprite](GL_POINT_SPRITE_ARB); + } + CLEARDIRTY(b->dirty, nbitID); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_point.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_point.txt new file mode 100644 index 00000000..ba92c153 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_point.txt @@ -0,0 +1,39 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enableSmooth:pointSmooth:GL_POINT_SMOOTH +:size:pointSize:PointSize +:minSize:minSize:PointParameterfARB,GL_POINT_SIZE_MIN_ARB +:maxSize:maxSize:PointParameterfARB,GL_POINT_SIZE_MAX_ARB +:fadeThresholdSize:fadeThresholdSize:PointParameterfARB,GL_POINT_FADE_THRESHOLD_SIZE_ARB +:spriteCoordOrigin:spriteCoordOrigin:PointParameterfARB,GL_POINT_SPRITE_COORD_ORIGIN +#:distanceAttenuation:distanceAttenuation:PointParameterfvARB,GL_POINT_DISTANCE_ATTENUATION_ARB +-:distanceAttenuation:*if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) { +-:distanceAttenuation:* diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation); +-:distanceAttenuation:* FILLDIRTY(b->distanceAttenuation); +-:distanceAttenuation:* FILLDIRTY(b->dirty); +-:distanceAttenuation:*} ++:distanceAttenuation:*if (from->distanceAttenuation[0] != to->distanceAttenuation[0] || from->distanceAttenuation[1] != to->distanceAttenuation[1] || from->distanceAttenuation[2] != to->distanceAttenuation[2]) { ++:distanceAttenuation:* diff_api.PointParameterfvARB (GL_POINT_DISTANCE_ATTENUATION_ARB, to->distanceAttenuation); ++:distanceAttenuation:* from->distanceAttenuation[0] = to->distanceAttenuation[0]; ++:distanceAttenuation:* from->distanceAttenuation[1] = to->distanceAttenuation[1]; ++:distanceAttenuation:* from->distanceAttenuation[2] = to->distanceAttenuation[2]; ++:distanceAttenuation:*} +:enableSprite:pointSprite:GL_POINT_SPRITE_ARB +%flush +>{ +>unsigned int activeUnit = (unsigned int) -1; +>for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) { +:coordReplacement[i]:*GLint replacement = to->coordReplacement[i]; +:coordReplacement[i]:*if (activeUnit != i) { +:coordReplacement[i]:* diff_api.ActiveTextureARB(i + GL_TEXTURE0_ARB ); +:coordReplacement[i]:* activeUnit = i; +:coordReplacement[i]:*} +:coordReplacement[i]:*diff_api.TexEnviv(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, &replacement); ++:coordReplacement[i]:*from->coordReplacement[i] = to->coordReplacement[i]; +%flush +>} +>if (activeUnit != toCtx->texture.curTextureUnit) +> diff_api.ActiveTextureARB(GL_TEXTURE0 + toCtx->texture.curTextureUnit); +>} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.c new file mode 100644 index 00000000..b00e8e80 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.c @@ -0,0 +1,211 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" +#include "cr_pixeldata.h" + +void crStatePolygonInit(CRContext *ctx) +{ + CRPolygonState *p = &ctx->polygon; + CRStateBits *sb = GetCurrentBits(); + CRPolygonBits *pb = &(sb->polygon); + int i; + + p->polygonSmooth = GL_FALSE; + p->polygonOffsetFill = GL_FALSE; + p->polygonOffsetLine = GL_FALSE; + p->polygonOffsetPoint = GL_FALSE; + p->polygonStipple = GL_FALSE; + p->cullFace = GL_FALSE; + RESET(pb->enable, ctx->bitid); + + p->offsetFactor = 0; + p->offsetUnits = 0; + RESET(pb->offset, ctx->bitid); + + p->cullFaceMode = GL_BACK; + p->frontFace = GL_CCW; + p->frontMode = GL_FILL; + p->backMode = GL_FILL; + RESET(pb->mode, ctx->bitid); + + for (i=0; i<32; i++) + p->stipple[i] = 0xFFFFFFFF; + RESET(pb->stipple, ctx->bitid); + + RESET(pb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateCullFace(GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRPolygonState *p = &(g->polygon); + CRStateBits *sb = GetCurrentBits(); + CRPolygonBits *pb = &(sb->polygon); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glCullFace called in begin/end"); + return; + } + + FLUSH(); + + if (mode != GL_FRONT && mode != GL_BACK && mode != GL_FRONT_AND_BACK) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glCullFace called with bogus mode: 0x%x", mode); + return; + } + + p->cullFaceMode = mode; + DIRTY(pb->mode, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateFrontFace (GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRPolygonState *p = &(g->polygon); + CRStateBits *sb = GetCurrentBits(); + CRPolygonBits *pb = &(sb->polygon); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glFrontFace called in begin/end"); + return; + } + + FLUSH(); + + if (mode != GL_CW && mode != GL_CCW) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glFrontFace called with bogus mode: 0x%x", mode); + return; + } + + p->frontFace = mode; + DIRTY(pb->mode, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePolygonMode (GLenum face, GLenum mode) +{ + CRContext *g = GetCurrentContext(); + CRPolygonState *p = &(g->polygon); + CRStateBits *sb = GetCurrentBits(); + CRPolygonBits *pb = &(sb->polygon); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glPolygonMode called in begin/end"); + return; + } + + FLUSH(); + + if (mode != GL_POINT && mode != GL_LINE && mode != GL_FILL) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glPolygonMode called with bogus mode: 0x%x", mode); + return; + } + + switch (face) { + case GL_FRONT: + p->frontMode = mode; + break; + case GL_FRONT_AND_BACK: + p->frontMode = mode; + RT_FALL_THRU(); + case GL_BACK: + p->backMode = mode; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glPolygonMode called with bogus face: 0x%x", face); + return; + } + DIRTY(pb->mode, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePolygonOffset (GLfloat factor, GLfloat units) +{ + CRContext *g = GetCurrentContext(); + CRPolygonState *p = &(g->polygon); + CRStateBits *sb = GetCurrentBits(); + CRPolygonBits *pb = &(sb->polygon); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glPolygonOffset called in begin/end"); + return; + } + + FLUSH(); + + p->offsetFactor = factor; + p->offsetUnits = units; + + DIRTY(pb->offset, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePolygonStipple (const GLubyte *p) +{ + CRContext *g = GetCurrentContext(); + CRPolygonState *poly = &(g->polygon); + CRStateBits *sb = GetCurrentBits(); + CRPolygonBits *pb = &(sb->polygon); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glPolygonStipple called in begin/end"); + return; + } + + FLUSH(); + + if (!p && !crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + { + crDebug("Void pointer passed to PolygonStipple"); + return; + } + + /** @todo track mask if buffer is bound?*/ + if (!crStateIsBufferBound(GL_PIXEL_UNPACK_BUFFER_ARB)) + { + crMemcpy((char*)poly->stipple, (char*)p, 128); + } + + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->stipple, g->neg_bitid); +} + +void STATE_APIENTRY crStateGetPolygonStipple( GLubyte *b ) +{ + CRContext *g = GetCurrentContext(); + CRPolygonState *poly = &(g->polygon); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetPolygonStipple called in begin/end"); + return; + } + + crMemcpy((char*)b, (char*)poly->stipple, 128); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.txt new file mode 100644 index 00000000..8867dfbc --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_polygon.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enable:polygonSmooth:GL_POLYGON_SMOOTH +:enable:polygonOffsetFill:GL_POLYGON_OFFSET_FILL +:enable:polygonOffsetLine:GL_POLYGON_OFFSET_LINE +:enable:polygonOffsetPoint:GL_POLYGON_OFFSET_POINT +:enable:polygonStipple:GL_POLYGON_STIPPLE +:enable:cullFace:GL_CULL_FACE +:offset:offsetFactor,offsetUnits:PolygonOffset +:mode:frontFace:FrontFace +:mode:cullFaceMode:CullFace +:mode:backMode:PolygonMode,GL_BACK +:mode:frontMode:PolygonMode,GL_FRONT +-:stipple:stipple:*diff_api.PolygonStipple ((GLubyte *) to->stipple); ++:stipple:*int iStripple; ++:stipple:*diff_api.PolygonStipple ((GLubyte *) to->stipple); ++:stipple:*for (iStripple=0; iStripple<32; iStripple++) ++:stipple:*{ ++:stipple:* from->stipple[iStripple] = to->stipple[iStripple]; ++:stipple:*} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_program.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_program.c new file mode 100644 index 00000000..b7ed0fba --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_program.c @@ -0,0 +1,2392 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state_internals.h" +#include "cr_mem.h" +#include "cr_string.h" + + +/* + * General notes: + * + * Vertex programs can change vertices so bounding boxes may not be + * practical for tilesort. Tilesort may have to broadcast geometry + * when vertex programs are in effect. We could semi-parse vertex + * programs to determine if they write to the o[HPOS] register. + */ + + +/* + * Lookup the named program and return a pointer to it. + * If the program doesn't exist, create it and reserve its Id and put + * it into the hash table. + */ +static CRProgram * +GetProgram(CRProgramState *p, GLenum target, GLuint id) +{ + CRProgram *prog; + + prog = crHashtableSearch(p->programHash, id); + if (!prog) { + prog = (CRProgram *) crCalloc(sizeof(CRProgram)); + if (!prog) + return NULL; + prog->target = target; + prog->id = id; + prog->format = GL_PROGRAM_FORMAT_ASCII_ARB; + prog->resident = GL_TRUE; + prog->symbolTable = NULL; + + if (id > 0) + crHashtableAdd(p->programHash, id, (void *) prog); + } + return prog; +} + + +/* + * Delete a CRProgram object and all attached data. + */ +static void +DeleteProgram(CRProgram *prog) +{ + CRProgramSymbol *symbol, *next; + + if (prog->string) + crFree((void *) prog->string); + + for (symbol = prog->symbolTable; symbol; symbol = next) { + next = symbol->next; + crFree((void *) symbol->name); + crFree(symbol); + } + crFree(prog); +} + + +/* + * Set the named symbol to the value (x, y, z, w). + * NOTE: Symbols should only really be added during parsing of the program. + * However, the state tracker does not parse the programs (yet). So, when + * someone calls glProgramNamedParameter4fNV() we always enter the symbol + * since we don't know if it's really valid or not. + */ +static void +SetProgramSymbol(CRProgram *prog, const char *name, GLsizei len, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRProgramSymbol *symbol; + + for (symbol = prog->symbolTable; symbol; symbol = symbol->next) { + /* NOTE: may not be null-terminated! */ + if (crStrncmp(symbol->name, name, len) == 0 && symbol->name[len] == 0) { + /* found it */ + symbol->value[0] = x; + symbol->value[1] = y; + symbol->value[2] = z; + symbol->value[3] = w; + FILLDIRTY(symbol->dirty); + return; + } + } + /* add new symbol table entry */ + symbol = (CRProgramSymbol *) crAlloc(sizeof(CRProgramSymbol)); + if (symbol) { + symbol->name = crStrndup(name, len); + symbol->cbName = len; + symbol->value[0] = x; + symbol->value[1] = y; + symbol->value[2] = z; + symbol->value[3] = w; + symbol->next = prog->symbolTable; + prog->symbolTable = symbol; + FILLDIRTY(symbol->dirty); + } +} + + +/* + * Return a pointer to the values for the given symbol. Return NULL if + * the name doesn't exist in the symbol table. + */ +static const GLfloat * +GetProgramSymbol(const CRProgram *prog, const char *name, GLsizei len) +{ + CRProgramSymbol *symbol = prog->symbolTable; + for (symbol = prog->symbolTable; symbol; symbol = symbol->next) { + /* NOTE: may not be null-terminated! */ + if (crStrncmp(symbol->name, name, len) == 0 && symbol->name[len] == 0) { + return symbol->value; + } + } + return NULL; +} + + +/* + * Used by both glBindProgramNV and glBindProgramARB + */ +static CRProgram * +BindProgram(GLenum target, GLuint id, + GLenum vertexTarget, GLenum fragmentTarget) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + CRProgram *prog; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBindProgram called in Begin/End"); + return NULL; + } + + if (id == 0) { + if (target == vertexTarget) { + prog = p->defaultVertexProgram; + } + else if (target == fragmentTarget) { + prog = p->defaultFragmentProgram; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBindProgram(bad target)"); + return NULL; + } + } + else { + prog = GetProgram(p, target, id ); + } + + if (!prog) { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glBindProgram"); + return NULL; + } + else if (prog->target != target) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glBindProgram target mismatch"); + return NULL; + } + + if (target == vertexTarget) { + p->currentVertexProgram = prog; + p->vpProgramBinding = id; + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->vpBinding, g->neg_bitid); + } + else if (target == fragmentTarget) { + p->currentFragmentProgram = prog; + p->fpProgramBinding = id; + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->fpBinding, g->neg_bitid); + } + return prog; +} + + +void STATE_APIENTRY crStateBindProgramNV(GLenum target, GLuint id) +{ + CRProgram *prog = BindProgram(target, id, GL_VERTEX_PROGRAM_NV, + GL_FRAGMENT_PROGRAM_NV); + if (prog) { + prog->isARBprogram = GL_FALSE; + } +} + + +void STATE_APIENTRY crStateBindProgramARB(GLenum target, GLuint id) +{ + CRProgram *prog = BindProgram(target, id, GL_VERTEX_PROGRAM_ARB, + GL_FRAGMENT_PROGRAM_ARB); + if (prog) { + prog->isARBprogram = GL_TRUE; + } +} + + +void STATE_APIENTRY crStateDeleteProgramsARB(GLsizei n, const GLuint *ids) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + GLint i; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glDeleteProgramsNV called in Begin/End"); + return; + } + + if (n < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glDeleteProgramsNV(n)"); + return; + } + + for (i = 0; i < n; i++) { + CRProgram *prog; + if (ids[i] > 0) { + prog = (CRProgram *) crHashtableSearch(p->programHash, ids[i]); + if (prog == p->currentVertexProgram) { + p->currentVertexProgram = p->defaultVertexProgram; + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->vpBinding, g->neg_bitid); + } + else if (prog == p->currentFragmentProgram) { + p->currentFragmentProgram = p->defaultFragmentProgram; + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->fpBinding, g->neg_bitid); + } + if (prog) { + DeleteProgram(prog); + } + crHashtableDelete(p->programHash, ids[i], GL_FALSE); + } + } +} + + +void STATE_APIENTRY crStateExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params) +{ + /* Hmmm, this is really hard to do if we don't actually execute + * the program in a software simulation. + */ + (void)params; + (void)target; + (void)id; +} + + +void STATE_APIENTRY crStateGenProgramsNV(GLsizei n, GLuint *ids) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + + crStateGenNames(g, p->programHash, n, ids); +} + +void STATE_APIENTRY crStateGenProgramsARB(GLsizei n, GLuint *ids) +{ + crStateGenProgramsNV(n, ids); +} + + +GLboolean STATE_APIENTRY crStateIsProgramARB(GLuint id) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRProgram *prog; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glIsProgram called in Begin/End"); + return GL_FALSE; + } + + if (id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glIsProgram(id==0)"); + return GL_FALSE; + } + + prog = (CRProgram *) crHashtableSearch(p->programHash, id); + if (prog) + return GL_TRUE; + else + return GL_FALSE; +} + + +GLboolean STATE_APIENTRY crStateAreProgramsResidentNV(GLsizei n, const GLuint *ids, GLboolean *residences) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + int i; + GLboolean retVal = GL_TRUE; + + if (n < 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glAreProgramsResidentNV(n)"); + return GL_FALSE; + } + + for (i = 0; i < n; i++) { + CRProgram *prog; + + if (ids[i] == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glAreProgramsResidentNV(id)"); + return GL_FALSE; + } + + prog = (CRProgram *) crHashtableSearch(p->programHash, ids[i]); + if (!prog) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glAreProgramsResidentNV(id)"); + return GL_FALSE; + } + + if (!prog->resident) { + retVal = GL_FALSE; + break; + } + } + + if (retVal == GL_FALSE) { + for (i = 0; i < n; i++) { + CRProgram *prog = (CRProgram *) + crHashtableSearch(p->programHash, ids[i]); + residences[i] = prog->resident; + } + } + + return retVal; +} + + +void STATE_APIENTRY crStateRequestResidentProgramsNV(GLsizei n, const GLuint *ids) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + GLint i; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glRequestResidentProgramsNV called in Begin/End"); + return; + } + + if (n < 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glRequestResidentProgramsNV(n<0)"); + return; + } + + for (i = 0; i < n ; i++) { + CRProgram *prog = (CRProgram *) crHashtableSearch(p->programHash, ids[i]); + if (prog) + prog->resident = GL_TRUE; + } +} + + +void STATE_APIENTRY crStateLoadProgramNV(GLenum target, GLuint id, GLsizei len, + const GLubyte *program) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + CRProgram *prog; + GLubyte *progCopy; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glLoadProgramNV called in Begin/End"); + return; + } + + if (id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glLoadProgramNV(id==0)"); + return; + } + + prog = GetProgram(p, target, id); + + if (!prog) { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + else if (prog && prog->target != target) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glLoadProgramNV(target)"); + return; + } + + progCopy = crAlloc(len); + if (!progCopy) { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glLoadProgramNV"); + return; + } + if (crStrncmp((const char *) program,"!!FP1.0", 7) != 0 + && crStrncmp((const char *) program,"!!FCP1.0", 8) != 0 + && crStrncmp((const char *) program,"!!VP1.0", 7) != 0 + && crStrncmp((const char *) program,"!!VP1.1", 7) != 0 + && crStrncmp((const char *) program,"!!VP2.0", 7) != 0 + && crStrncmp((const char *) program,"!!VSP1.0", 8) != 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glLoadProgramNV"); + crDebug("program = (%s)\n",program); + return; + } + crMemcpy(progCopy, program, len); + if (prog->string) + crFree((void *) prog->string); + + prog->string = progCopy; + prog->length = len; + prog->isARBprogram = GL_FALSE; + + DIRTY(prog->dirtyProgram, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateProgramStringARB(GLenum target, GLenum format, + GLsizei len, const GLvoid *string) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + CRProgram *prog; + GLubyte *progCopy; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramStringARB called in Begin/End"); + return; + } + + if (format != GL_PROGRAM_FORMAT_ASCII_ARB) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glProgramStringARB(format)"); + return; + } + + if (target == GL_FRAGMENT_PROGRAM_ARB + && g->extensions.ARB_fragment_program) { + prog = p->currentFragmentProgram; + } + else if (target == GL_VERTEX_PROGRAM_ARB + && g->extensions.ARB_vertex_program) { + prog = p->currentVertexProgram; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glProgramStringARB(target)"); + return; + } + + CRASSERT(prog); + + + progCopy = crAlloc(len); + if (!progCopy) { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glProgramStringARB"); + return; + } + if (crStrncmp(string,"!!ARBvp1.0", 10) != 0 + && crStrncmp(string,"!!ARBfp1.0", 10) != 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glProgramStringARB"); + return; + } + crMemcpy(progCopy, string, len); + if (prog->string) + crFree((void *) prog->string); + + prog->string = progCopy; + prog->length = len; + prog->format = format; + prog->isARBprogram = GL_TRUE; + + DIRTY(prog->dirtyProgram, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateGetProgramivNV(GLuint id, GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRProgram *prog; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramivNV called in Begin/End"); + return; + } + + if (id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramivNV(bad id)"); + return; + } + + prog = (CRProgram *) crHashtableSearch(p->programHash, id); + if (!prog) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramivNV(bad id)"); + return; + } + + switch (pname) { + case GL_PROGRAM_TARGET_NV: + *params = prog->target; + return; + case GL_PROGRAM_LENGTH_NV: + *params = prog->length; + return; + case GL_PROGRAM_RESIDENT_NV: + *params = prog->resident; + return; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramivNV(pname)"); + return; + } +} + + +void STATE_APIENTRY crStateGetProgramStringNV(GLuint id, GLenum pname, GLubyte *program) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRProgram *prog; + + if (pname != GL_PROGRAM_STRING_NV) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramStringNV(pname)"); + return; + } + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramStringNV called in Begin/End"); + return; + } + + if (id == 0) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramStringNV(bad id)"); + return; + } + + prog = (CRProgram *) crHashtableSearch(p->programHash, id); + if (!prog) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramStringNV(bad id)"); + return; + } + + crMemcpy(program, prog->string, prog->length); +} + + +void STATE_APIENTRY crStateGetProgramStringARB(GLenum target, GLenum pname, GLvoid *string) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRProgram *prog; + + if (target == GL_VERTEX_PROGRAM_ARB) { + prog = p->currentVertexProgram; + } + else if (target == GL_FRAGMENT_PROGRAM_ARB) { + prog = p->currentFragmentProgram; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramStringNV(target)"); + return; + } + + if (pname != GL_PROGRAM_STRING_NV) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramStringNV(pname)"); + return; + } + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramStringNV called in Begin/End"); + return; + } + + crMemcpy(string, prog->string, prog->length); +} + + +void STATE_APIENTRY crStateProgramParameter4dNV(GLenum target, GLuint index, + GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + crStateProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y, + (GLfloat) z, (GLfloat) w); +} + + +void STATE_APIENTRY crStateProgramParameter4dvNV(GLenum target, GLuint index, + const GLdouble *params) +{ + crStateProgramParameter4fNV(target, index, + (GLfloat) params[0], (GLfloat) params[1], + (GLfloat) params[2], (GLfloat) params[3]); +} + + +void STATE_APIENTRY crStateProgramParameter4fNV(GLenum target, GLuint index, + GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramParameterNV called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_NV) { + if (index < g->limits.maxVertexProgramEnvParams) { + p->vertexParameters[index][0] = x; + p->vertexParameters[index][1] = y; + p->vertexParameters[index][2] = z; + p->vertexParameters[index][3] = w; + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->vertexEnvParameter[index], g->neg_bitid); + DIRTY(pb->vertexEnvParameters, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramParameterNV(index=%d)", index); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glProgramParameterNV(target)"); + return; + } +} + + +void STATE_APIENTRY crStateProgramParameter4fvNV(GLenum target, GLuint index, + const GLfloat *params) +{ + crStateProgramParameter4fNV(target, index, + params[0], params[1], params[2], params[3]); +} + + +void STATE_APIENTRY crStateProgramParameters4dvNV(GLenum target, GLuint index, + GLuint num, const GLdouble *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramParameters4dvNV called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_NV) { + if (index >= UINT32_MAX - num) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramParameters4dvNV(index+num) integer overflow"); + return; + } + + if (index + num < g->limits.maxVertexProgramEnvParams) { + GLuint i; + for (i = 0; i < num; i++) { + p->vertexParameters[index+i][0] = (GLfloat) params[i*4+0]; + p->vertexParameters[index+i][1] = (GLfloat) params[i*4+1]; + p->vertexParameters[index+i][2] = (GLfloat) params[i*4+2]; + p->vertexParameters[index+i][3] = (GLfloat) params[i*4+3]; + } + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->vertexEnvParameters, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramParameters4dvNV(index+num)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glProgramParameterNV(target)"); + return; + } +} + + +void STATE_APIENTRY crStateProgramParameters4fvNV(GLenum target, GLuint index, + GLuint num, const GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramParameters4dvNV called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_NV) { + if (index >= UINT32_MAX - num) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramParameters4dvNV(index+num) integer overflow"); + return; + } + + if (index + num < g->limits.maxVertexProgramEnvParams) { + GLuint i; + for (i = 0; i < num; i++) { + p->vertexParameters[index+i][0] = params[i*4+0]; + p->vertexParameters[index+i][1] = params[i*4+1]; + p->vertexParameters[index+i][2] = params[i*4+2]; + p->vertexParameters[index+i][3] = params[i*4+3]; + } + DIRTY(pb->dirty, g->neg_bitid); + DIRTY(pb->vertexEnvParameters, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramParameters4dvNV(index+num)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glProgramParameterNV(target)"); + return; + } +} + + +void STATE_APIENTRY crStateGetProgramParameterfvNV(GLenum target, GLuint index, + GLenum pname, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramParameterfvNV called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_NV) { + if (pname == GL_PROGRAM_PARAMETER_NV) { + if (index < g->limits.maxVertexProgramEnvParams) { + params[0] = p->vertexParameters[index][0]; + params[1] = p->vertexParameters[index][1]; + params[2] = p->vertexParameters[index][2]; + params[3] = p->vertexParameters[index][3]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetProgramParameterfvNV(index)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramParameterfvNV(pname)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramParameterfvNV(target)"); + return; + } +} + + +void STATE_APIENTRY crStateGetProgramParameterdvNV(GLenum target, GLuint index, + GLenum pname, GLdouble *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramParameterdvNV called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_NV) { + if (pname == GL_PROGRAM_PARAMETER_NV) { + if (index < g->limits.maxVertexProgramEnvParams) { + params[0] = p->vertexParameters[index][0]; + params[1] = p->vertexParameters[index][1]; + params[2] = p->vertexParameters[index][2]; + params[3] = p->vertexParameters[index][3]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetProgramParameterdvNV(index)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramParameterdvNV(pname)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramParameterdvNV(target)"); + return; + } +} + + +void STATE_APIENTRY crStateTrackMatrixNV(GLenum target, GLuint address, + GLenum matrix, GLenum transform) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTrackMatrixivNV called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_NV) { + if (address & 0x3 || address >= g->limits.maxVertexProgramEnvParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTrackMatrixNV(address)"); + return; + } + + switch (matrix) { + case GL_NONE: + case GL_MODELVIEW: + case GL_PROJECTION: + case GL_TEXTURE: + case GL_COLOR: + case GL_MODELVIEW_PROJECTION_NV: + case GL_MATRIX0_NV: + case GL_MATRIX1_NV: + case GL_MATRIX2_NV: + case GL_MATRIX3_NV: + case GL_MATRIX4_NV: + case GL_MATRIX5_NV: + case GL_MATRIX6_NV: + case GL_MATRIX7_NV: + case GL_TEXTURE0_ARB: + case GL_TEXTURE1_ARB: + case GL_TEXTURE2_ARB: + case GL_TEXTURE3_ARB: + case GL_TEXTURE4_ARB: + case GL_TEXTURE5_ARB: + case GL_TEXTURE6_ARB: + case GL_TEXTURE7_ARB: + /* OK, fallthrough */ + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTrackMatrixNV(matrix = %x)",matrix); + return; + } + + switch (transform) { + case GL_IDENTITY_NV: + case GL_INVERSE_NV: + case GL_TRANSPOSE_NV: + case GL_INVERSE_TRANSPOSE_NV: + /* OK, fallthrough */ + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTrackMatrixNV(transform = %x)",transform); + return; + } + + p->TrackMatrix[address / 4] = matrix; + p->TrackMatrixTransform[address / 4] = transform; + DIRTY(pb->trackMatrix[address/4], g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTrackMatrixNV(target = %x)",target); + } +} + + +void STATE_APIENTRY crStateGetTrackMatrixivNV(GLenum target, GLuint address, + GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTrackMatrixivNV called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_NV) { + if ((address & 0x3) || address >= g->limits.maxVertexProgramEnvParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetTrackMatrixivNV(address)"); + return; + } + if (pname == GL_TRACK_MATRIX_NV) { + params[0] = (GLint) p->TrackMatrix[address / 4]; + } + else if (pname == GL_TRACK_MATRIX_TRANSFORM_NV) { + params[0] = (GLint) p->TrackMatrixTransform[address / 4]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTrackMatrixivNV(pname)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTrackMatrixivNV(target)"); + return; + } +} + + +void STATE_APIENTRY crStateGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params) +{ + /* init vars to prevent compiler warnings/errors */ + GLfloat floatParams[4] = { 0.0, 0.0, 0.0, 0.0 }; + crStateGetVertexAttribfvNV(index, pname, floatParams); + params[0] = floatParams[0]; + if (pname == GL_CURRENT_ATTRIB_NV) { + params[1] = floatParams[1]; + params[2] = floatParams[2]; + params[3] = floatParams[3]; + } +} + + +void STATE_APIENTRY crStateGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetVertexAttribfvNV called in Begin/End"); + return; + } + + if (index >= CR_MAX_VERTEX_ATTRIBS) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetVertexAttribfvNV(index)"); + return; + } + + switch (pname) { + case GL_ATTRIB_ARRAY_SIZE_NV: + params[0] = (GLfloat) g->client.array.a[index].size; + break; + case GL_ATTRIB_ARRAY_STRIDE_NV: + params[0] = (GLfloat) g->client.array.a[index].stride; + break; + case GL_ATTRIB_ARRAY_TYPE_NV: + params[0] = (GLfloat) g->client.array.a[index].type; + break; + case GL_CURRENT_ATTRIB_NV: + crStateCurrentRecover(); + COPY_4V(params , g->current.vertexAttrib[index]); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetVertexAttribfvNV"); + return; + } +} + + +void STATE_APIENTRY crStateGetVertexAttribivNV(GLuint index, GLenum pname, GLint *params) +{ + /* init vars to prevent compiler warnings/errors */ + GLfloat floatParams[4] = { 0.0, 0.0, 0.0, 0.0 }; + crStateGetVertexAttribfvNV(index, pname, floatParams); + params[0] = (GLint) floatParams[0]; + if (pname == GL_CURRENT_ATTRIB_NV) { + params[1] = (GLint) floatParams[1]; + params[2] = (GLint) floatParams[2]; + params[3] = (GLint) floatParams[3]; + } +} + + + +void STATE_APIENTRY crStateGetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetVertexAttribfvARB called in Begin/End"); + return; + } + + if (index >= CR_MAX_VERTEX_ATTRIBS) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetVertexAttribfvARB(index)"); + return; + } + + switch (pname) { + case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB: + params[0] = (GLfloat) g->client.array.a[index].enabled; + break; + case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB: + params[0] = (GLfloat) g->client.array.a[index].size; + break; + case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB: + params[0] = (GLfloat) g->client.array.a[index].stride; + break; + case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB: + params[0] = (GLfloat) g->client.array.a[index].type; + break; + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB: + params[0] = (GLfloat) g->client.array.a[index].normalized; + break; + case GL_CURRENT_VERTEX_ATTRIB_ARB: + crStateCurrentRecover(); + COPY_4V(params , g->current.vertexAttrib[index]); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetVertexAttribfvARB"); + return; + } +} + + +void STATE_APIENTRY crStateGetVertexAttribivARB(GLuint index, GLenum pname, GLint *params) +{ + /* init vars to prevent compiler warnings/errors */ + GLfloat floatParams[4] = { 0.0, 0.0, 0.0, 0.0 }; + crStateGetVertexAttribfvARB(index, pname, floatParams); + params[0] = (GLint) floatParams[0]; + if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { + params[1] = (GLint) floatParams[1]; + params[2] = (GLint) floatParams[2]; + params[3] = (GLint) floatParams[3]; + } +} + + +void STATE_APIENTRY crStateGetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params) +{ + /* init vars to prevent compiler warnings/errors */ + GLfloat floatParams[4] = { 0.0, 0.0, 0.0, 0.0 }; + crStateGetVertexAttribfvARB(index, pname, floatParams); + params[0] = floatParams[0]; + if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) { + params[1] = floatParams[1]; + params[2] = floatParams[2]; + params[3] = floatParams[3]; + } +} + + +/**********************************************************************/ + +/* + * Added by GL_NV_fragment_program + */ + +void STATE_APIENTRY crStateProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRProgram *prog; + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramNamedParameterfNV called in Begin/End"); + return; + } + + prog = (CRProgram *) crHashtableSearch(p->programHash, id); + if (!prog) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramNamedParameterNV(bad id %d)", id); + return; + } + + if (prog->target != GL_FRAGMENT_PROGRAM_NV) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramNamedParameterNV(target)"); + return; + } + + SetProgramSymbol(prog, (const char *)name, len, x, y, z, w); + DIRTY(prog->dirtyNamedParams, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + crStateProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + + +void STATE_APIENTRY crStateProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name, const GLfloat v[]) +{ + crStateProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]); +} + + +void STATE_APIENTRY crStateProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name, const GLdouble v[]) +{ + crStateProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + + +void STATE_APIENTRY crStateGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + const CRProgram *prog; + const GLfloat *value; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramNamedParameterfNV called in Begin/End"); + return; + } + + prog = (const CRProgram *) crHashtableSearch(p->programHash, id); + if (!prog) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramNamedParameterNV(bad id)"); + return; + } + + if (prog->target != GL_FRAGMENT_PROGRAM_NV) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramNamedParameterNV(target)"); + return; + } + + value = GetProgramSymbol(prog, (const char *)name, len); + if (!value) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetProgramNamedParameterNV(name)"); + return; + } + + params[0] = value[0]; + params[1] = value[1]; + params[2] = value[2]; + params[3] = value[3]; +} + + +void STATE_APIENTRY crStateGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name, GLdouble *params) +{ + GLfloat floatParams[4]; + crStateGetProgramNamedParameterfvNV(id, len, name, floatParams); + params[0] = floatParams[0]; + params[1] = floatParams[1]; + params[2] = floatParams[2]; + params[3] = floatParams[3]; +} + + +void STATE_APIENTRY crStateProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + crStateProgramLocalParameter4fARB(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + + +void STATE_APIENTRY crStateProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble *params) +{ + crStateProgramLocalParameter4fARB(target, index, (GLfloat) params[0], (GLfloat) params[1], + (GLfloat) params[2], (GLfloat) params[3]); +} + + +void STATE_APIENTRY crStateProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRProgram *prog; + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramLocalParameterARB called in Begin/End"); + return; + } + + if (target == GL_FRAGMENT_PROGRAM_ARB || target == GL_FRAGMENT_PROGRAM_NV) { + if (index >= CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramLocalParameterARB(index)"); + return; + } + prog = p->currentFragmentProgram; + } + else if (target == GL_VERTEX_PROGRAM_ARB) { + if (index >= CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramLocalParameterARB(index)"); + return; + } + prog = p->currentVertexProgram; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glProgramLocalParameterARB(target)"); + return; + } + + CRASSERT(prog); + + prog->parameters[index][0] = x; + prog->parameters[index][1] = y; + prog->parameters[index][2] = z; + prog->parameters[index][3] = w; + DIRTY(prog->dirtyParam[index], g->neg_bitid); + DIRTY(prog->dirtyParams, g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat *params) +{ + crStateProgramLocalParameter4fARB(target, index, params[0], params[1], params[2], params[3]); +} + + +void STATE_APIENTRY crStateGetProgramLocalParameterfvARB(GLenum target, GLuint index, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + const CRProgram *prog = NULL; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramLocalParameterARB called in Begin/End"); + return; + } + + if (target == GL_FRAGMENT_PROGRAM_ARB || target == GL_FRAGMENT_PROGRAM_NV) { + prog = p->currentFragmentProgram; + if (index >= g->limits.maxFragmentProgramLocalParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetProgramLocalParameterARB(index)"); + return; + } + } + else if ( target == GL_VERTEX_PROGRAM_ARB +#if GL_VERTEX_PROGRAM_ARB != GL_VERTEX_PROGRAM_NV + || target == GL_VERTEX_PROGRAM_NV +#endif + ) { + prog = p->currentVertexProgram; + if (index >= g->limits.maxVertexProgramLocalParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetProgramLocalParameterARB(index)"); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramLocalParameterARB(target)"); + return; + } + if (!prog) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramLocalParameterARB(no program)"); + return; + } + + if (!prog) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramLocalParameterARB(no program)"); + return; + } + + CRASSERT(prog); + CRASSERT(index < CR_MAX_PROGRAM_LOCAL_PARAMS); + params[0] = prog->parameters[index][0]; + params[1] = prog->parameters[index][1]; + params[2] = prog->parameters[index][2]; + params[3] = prog->parameters[index][3]; +} + + +void STATE_APIENTRY crStateGetProgramLocalParameterdvARB(GLenum target, GLuint index, GLdouble *params) +{ + GLfloat floatParams[4]; + crStateGetProgramLocalParameterfvARB(target, index, floatParams); + params[0] = floatParams[0]; + params[1] = floatParams[1]; + params[2] = floatParams[2]; + params[3] = floatParams[3]; +} + + + +void STATE_APIENTRY crStateGetProgramivARB(GLenum target, GLenum pname, GLint *params) +{ + CRProgram *prog; + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramivARB called in Begin/End"); + return; + } + + if (target == GL_VERTEX_PROGRAM_ARB) { + prog = p->currentVertexProgram; + } + else if (target == GL_FRAGMENT_PROGRAM_ARB) { + prog = p->currentFragmentProgram; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramivARB(target)"); + return; + } + + CRASSERT(prog); + + switch (pname) { + case GL_PROGRAM_LENGTH_ARB: + *params = prog->length; + break; + case GL_PROGRAM_FORMAT_ARB: + *params = prog->format; + break; + case GL_PROGRAM_BINDING_ARB: + *params = prog->id; + break; + case GL_PROGRAM_INSTRUCTIONS_ARB: + *params = prog->numInstructions; + break; + case GL_MAX_PROGRAM_INSTRUCTIONS_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramInstructions; + else + *params = g->limits.maxFragmentProgramInstructions; + break; + case GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB: + *params = prog->numInstructions; + break; + case GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramInstructions; + else + *params = g->limits.maxFragmentProgramInstructions; + break; + case GL_PROGRAM_TEMPORARIES_ARB: + *params = prog->numTemporaries; + break; + case GL_MAX_PROGRAM_TEMPORARIES_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramTemps; + else + *params = g->limits.maxFragmentProgramTemps; + break; + case GL_PROGRAM_NATIVE_TEMPORARIES_ARB: + /* XXX same as GL_PROGRAM_TEMPORARIES_ARB? */ + *params = prog->numTemporaries; + break; + case GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB: + /* XXX same as GL_MAX_PROGRAM_TEMPORARIES_ARB? */ + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramTemps; + else + *params = g->limits.maxFragmentProgramTemps; + break; + case GL_PROGRAM_PARAMETERS_ARB: + *params = prog->numParameters; + break; + case GL_MAX_PROGRAM_PARAMETERS_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramLocalParams; + else + *params = g->limits.maxFragmentProgramLocalParams; + break; + case GL_PROGRAM_NATIVE_PARAMETERS_ARB: + /* XXX same as GL_MAX_PROGRAM_PARAMETERS_ARB? */ + *params = prog->numParameters; + break; + case GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB: + /* XXX same as GL_MAX_PROGRAM_PARAMETERS_ARB? */ + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramLocalParams; + else + *params = g->limits.maxFragmentProgramLocalParams; + break; + case GL_PROGRAM_ATTRIBS_ARB: + *params = prog->numAttributes; + break; + case GL_MAX_PROGRAM_ATTRIBS_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramAttribs; + else + *params = g->limits.maxFragmentProgramAttribs; + break; + case GL_PROGRAM_NATIVE_ATTRIBS_ARB: + /* XXX same as GL_PROGRAM_ATTRIBS_ARB? */ + *params = prog->numAttributes; + break; + case GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB: + /* XXX same as GL_MAX_PROGRAM_ATTRIBS_ARB? */ + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramAttribs; + else + *params = g->limits.maxFragmentProgramAttribs; + break; + case GL_PROGRAM_ADDRESS_REGISTERS_ARB: + *params = prog->numAddressRegs; + break; + case GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramAddressRegs; + else + *params = g->limits.maxFragmentProgramAddressRegs; + break; + case GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB: + /* XXX same as GL_PROGRAM_ADDRESS_REGISTERS_ARB? */ + *params = prog->numAddressRegs; + break; + case GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB: + /* XXX same as GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB? */ + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramAddressRegs; + else + *params = g->limits.maxFragmentProgramAddressRegs; + break; + case GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramLocalParams; + else + *params = g->limits.maxFragmentProgramLocalParams; + break; + case GL_MAX_PROGRAM_ENV_PARAMETERS_ARB: + if (target == GL_VERTEX_PROGRAM_ARB) + *params = g->limits.maxVertexProgramEnvParams; + else + *params = g->limits.maxFragmentProgramEnvParams; + break; + case GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB: + /* XXX ok? */ + *params = GL_TRUE; + break; + + /* + * These are for fragment programs only + */ + case GL_PROGRAM_ALU_INSTRUCTIONS_ARB: + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = prog->numAluInstructions; + break; + case GL_PROGRAM_TEX_INSTRUCTIONS_ARB: + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = prog->numTexInstructions; + break; + case GL_PROGRAM_TEX_INDIRECTIONS_ARB: + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = prog->numTexIndirections; + break; + case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: + /* XXX same as GL_PROGRAM_ALU_INSTRUCTIONS_ARB? */ + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = prog->numAluInstructions; + break; + case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB: + /* XXX same as GL_PROGRAM_ALU_INSTRUCTIONS_ARB? */ + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = prog->numTexInstructions; + break; + case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = prog->numTexIndirections; + break; + case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB: + case GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB: + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = g->limits.maxFragmentProgramAluInstructions; + break; + case GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB: + case GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB: + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = g->limits.maxFragmentProgramTexInstructions; + break; + case GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB: + case GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB: + if (target != GL_FRAGMENT_PROGRAM_ARB || !g->extensions.ARB_fragment_program) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(target or pname)"); + return; + } + *params = g->limits.maxFragmentProgramTexIndirections; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateGetProgramivARB(pname)"); + return; + } +} + + +/* XXX maybe move these two functions into state_client.c? */ +void STATE_APIENTRY crStateDisableVertexAttribArrayARB(GLuint index) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + if (index >= g->limits.maxVertexProgramAttribs) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glDisableVertexAttribArrayARB(index)"); + return; + } + c->array.a[index].enabled = GL_FALSE; + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->enableClientState, g->neg_bitid); +} + + +void STATE_APIENTRY crStateEnableVertexAttribArrayARB(GLuint index) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + CRStateBits *sb = GetCurrentBits(); + CRClientBits *cb = &(sb->client); + + if (index >= g->limits.maxVertexProgramAttribs) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glEnableVertexAttribArrayARB(index)"); + return; + } + c->array.a[index].enabled = GL_TRUE; + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->enableClientState, g->neg_bitid); +} + + +void STATE_APIENTRY crStateGetProgramEnvParameterdvARB(GLenum target, GLuint index, GLdouble *params) +{ + GLfloat fparams[4]; + crStateGetProgramEnvParameterfvARB(target, index, fparams); + params[0] = fparams[0]; + params[1] = fparams[1]; + params[2] = fparams[2]; + params[3] = fparams[3]; +} + +void STATE_APIENTRY crStateGetProgramEnvParameterfvARB(GLenum target, GLuint index, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetProgramEnvParameterARB called in Begin/End"); + return; + } + + if (target == GL_FRAGMENT_PROGRAM_ARB || target == GL_FRAGMENT_PROGRAM_NV) { + if (index >= g->limits.maxFragmentProgramEnvParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetProgramEnvParameterARB(index)"); + return; + } + params[0] = p->fragmentParameters[index][0]; + params[1] = p->fragmentParameters[index][1]; + params[2] = p->fragmentParameters[index][2]; + params[3] = p->fragmentParameters[index][3]; + } + else if ( target == GL_VERTEX_PROGRAM_ARB +#if GL_VERTEX_PROGRAM_ARB != GL_VERTEX_PROGRAM_NV + || target == GL_VERTEX_PROGRAM_NV +#endif + ) { + if (index >= g->limits.maxVertexProgramEnvParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetProgramEnvParameterARB(index)"); + return; + } + params[0] = p->vertexParameters[index][0]; + params[1] = p->vertexParameters[index][1]; + params[2] = p->vertexParameters[index][2]; + params[3] = p->vertexParameters[index][3]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetProgramEnvParameterARB(target)"); + return; + } +} + + +void STATE_APIENTRY crStateProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + crStateProgramEnvParameter4fARB(target, index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY crStateProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble *params) +{ + crStateProgramEnvParameter4fARB(target, index, (GLfloat) params[0], (GLfloat) params[1], (GLfloat) params[2], (GLfloat) params[3]); +} + +void STATE_APIENTRY crStateProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRProgramState *p = &(g->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glProgramEnvParameterARB called in Begin/End"); + return; + } + + if (target == GL_FRAGMENT_PROGRAM_ARB || target == GL_FRAGMENT_PROGRAM_NV) { + if (index >= g->limits.maxFragmentProgramEnvParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramEnvParameterARB(index)"); + return; + } + p->fragmentParameters[index][0] = x; + p->fragmentParameters[index][1] = y; + p->fragmentParameters[index][2] = z; + p->fragmentParameters[index][3] = w; + DIRTY(pb->fragmentEnvParameter[index], g->neg_bitid); + DIRTY(pb->fragmentEnvParameters, g->neg_bitid); + } + else if ( target == GL_VERTEX_PROGRAM_ARB +#if GL_VERTEX_PROGRAM_ARB != GL_VERTEX_PROGRAM_NV + || target == GL_VERTEX_PROGRAM_NV +#endif + ) { + if (index >= g->limits.maxVertexProgramEnvParams) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glProgramEnvParameterARB(index)"); + return; + } + p->vertexParameters[index][0] = x; + p->vertexParameters[index][1] = y; + p->vertexParameters[index][2] = z; + p->vertexParameters[index][3] = w; + DIRTY(pb->vertexEnvParameter[index], g->neg_bitid); + DIRTY(pb->vertexEnvParameters, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glProgramEnvParameterARB(target)"); + return; + } + + DIRTY(pb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat *params) +{ + crStateProgramEnvParameter4fARB(target, index, params[0], params[1], params[2], params[3]); +} + + +/**********************************************************************/ + + +void crStateProgramInit( CRContext *ctx ) +{ + CRProgramState *p = &(ctx->program); + CRStateBits *sb = GetCurrentBits(); + CRProgramBits *pb = &(sb->program); + GLuint i; + + CRASSERT(CR_MAX_PROGRAM_ENV_PARAMS >= CR_MAX_VERTEX_PROGRAM_ENV_PARAMS); + CRASSERT(CR_MAX_PROGRAM_ENV_PARAMS >= CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS); + + CRASSERT(CR_MAX_PROGRAM_LOCAL_PARAMS >= CR_MAX_VERTEX_PROGRAM_LOCAL_PARAMS); + CRASSERT(CR_MAX_PROGRAM_LOCAL_PARAMS >= CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS); + + p->programHash = crAllocHashtable(); + + /* ARB_vertex/fragment_program define default program objects */ + p->defaultVertexProgram = GetProgram(p, GL_VERTEX_PROGRAM_ARB, 0); + p->defaultFragmentProgram = GetProgram(p, GL_FRAGMENT_PROGRAM_ARB, 0); + + p->currentVertexProgram = p->defaultVertexProgram; + p->currentFragmentProgram = p->defaultFragmentProgram; + p->errorPos = -1; + p->errorString = NULL; + + for (i = 0; i < ctx->limits.maxVertexProgramEnvParams / 4; i++) { + p->TrackMatrix[i] = GL_NONE; + p->TrackMatrixTransform[i] = GL_IDENTITY_NV; + } + for (i = 0; i < ctx->limits.maxVertexProgramEnvParams; i++) { + p->vertexParameters[i][0] = 0.0; + p->vertexParameters[i][1] = 0.0; + p->vertexParameters[i][2] = 0.0; + p->vertexParameters[i][3] = 0.0; + } + for (i = 0; i < CR_MAX_FRAGMENT_PROGRAM_ENV_PARAMS; i++) { + p->fragmentParameters[i][0] = 0.0; + p->fragmentParameters[i][1] = 0.0; + p->fragmentParameters[i][2] = 0.0; + p->fragmentParameters[i][3] = 0.0; + } + + p->vpEnabled = GL_FALSE; + p->fpEnabled = GL_FALSE; + p->fpEnabledARB = GL_FALSE; + p->vpPointSize = GL_FALSE; + p->vpTwoSide = GL_FALSE; + RESET(pb->dirty, ctx->bitid); +} + + +static void DeleteProgramCallback( void *data ) +{ + CRProgram *prog = (CRProgram *) data; + DeleteProgram(prog); +} + +void crStateProgramDestroy(CRContext *ctx) +{ + CRProgramState *p = &(ctx->program); + crFreeHashtable(p->programHash, DeleteProgramCallback); + DeleteProgram(p->defaultVertexProgram); + DeleteProgram(p->defaultFragmentProgram); +} + + +/* XXX it would be nice to autogenerate this, but we can't for now. + */ +void +crStateProgramDiff(CRProgramBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRProgramState *from = &(fromCtx->program); + CRProgramState *to = &(toCtx->program); + unsigned int i, j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + CRASSERT(from->currentVertexProgram); + CRASSERT(to->currentVertexProgram); + CRASSERT(from->currentFragmentProgram); + CRASSERT(to->currentFragmentProgram); + + for (j=0;jvpEnable, bitID)) { + glAble able[2]; + CRProgram *toProg = to->currentVertexProgram; + + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->vpEnabled != to->vpEnabled) { + if (toProg->isARBprogram) + able[to->vpEnabled](GL_VERTEX_PROGRAM_ARB); + else + able[to->vpEnabled](GL_VERTEX_PROGRAM_NV); + from->vpEnabled = to->vpEnabled; + } + if (from->vpTwoSide != to->vpTwoSide) { + able[to->vpTwoSide](GL_VERTEX_PROGRAM_TWO_SIDE_NV); + from->vpTwoSide = to->vpTwoSide; + } + if (from->vpPointSize != to->vpPointSize) { + able[to->vpPointSize](GL_VERTEX_PROGRAM_POINT_SIZE_NV); + from->vpPointSize = to->vpPointSize; + } + CLEARDIRTY(b->vpEnable, nbitID); + } + + /* fragment program enable */ + if (CHECKDIRTY(b->fpEnable, bitID)) { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->fpEnabled != to->fpEnabled) { + able[to->fpEnabled](GL_FRAGMENT_PROGRAM_NV); + from->fpEnabled = to->fpEnabled; + } + if (from->fpEnabledARB != to->fpEnabledARB) { + able[to->fpEnabledARB](GL_FRAGMENT_PROGRAM_ARB); + from->fpEnabledARB = to->fpEnabledARB; + } + CLEARDIRTY(b->fpEnable, nbitID); + } + + /* program/track matrices */ + if (to->vpEnabled) { + for (i = 0; i < toCtx->limits.maxVertexProgramEnvParams / 4; i++) { + if (CHECKDIRTY(b->trackMatrix[i], bitID)) { + if (from->TrackMatrix[i] != to->TrackMatrix[i] || + from->TrackMatrixTransform[i] != to->TrackMatrixTransform[i]) { + diff_api.TrackMatrixNV(GL_VERTEX_PROGRAM_NV, i * 4, + to->TrackMatrix[i], + to->TrackMatrixTransform[i]); + from->TrackMatrix[i] = to->TrackMatrix[i]; + from->TrackMatrixTransform[i] = to->TrackMatrixTransform[i]; + } + CLEARDIRTY(b->trackMatrix[i], nbitID); + } + } + } + + if (to->vpEnabled) { + /* vertex program binding */ + CRProgram *fromProg = from->currentVertexProgram; + CRProgram *toProg = to->currentVertexProgram; + + if (CHECKDIRTY(b->vpBinding, bitID)) { + if (fromProg->id != toProg->id) { + if (toProg->isARBprogram) + diff_api.BindProgramARB(GL_VERTEX_PROGRAM_ARB, toProg->id); + else + diff_api.BindProgramNV(GL_VERTEX_PROGRAM_NV, toProg->id); + from->currentVertexProgram = toProg; + } + CLEARDIRTY(b->vpBinding, nbitID); + } + + if (toProg) { + /* vertex program text */ + if (CHECKDIRTY(toProg->dirtyProgram, bitID)) { + if (toProg->isARBprogram) { + diff_api.ProgramStringARB( GL_VERTEX_PROGRAM_ARB, toProg->format, toProg->length, toProg->string ); + } + else { + diff_api.LoadProgramNV( GL_VERTEX_PROGRAM_NV, toProg->id, toProg->length, toProg->string ); + } + CLEARDIRTY(toProg->dirtyProgram, nbitID); + } + + /* vertex program global/env parameters */ + if (CHECKDIRTY(b->vertexEnvParameters, bitID)) { + for (i = 0; i < toCtx->limits.maxVertexProgramEnvParams; i++) { + if (CHECKDIRTY(b->vertexEnvParameter[i], bitID)) { + if (toProg->isARBprogram) + diff_api.ProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, + to->vertexParameters[i]); + else + diff_api.ProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, i, + to->vertexParameters[i]); + if (fromProg) { + COPY_4V(from->vertexParameters[i], + to->vertexParameters[i]); + } + CLEARDIRTY(b->vertexEnvParameter[i], nbitID); + } + } + CLEARDIRTY(b->vertexEnvParameters, nbitID); + } + + /* vertex program local parameters */ + if (CHECKDIRTY(toProg->dirtyParams, bitID)) { + for (i = 0; i < toCtx->limits.maxVertexProgramLocalParams; i++) { + if (CHECKDIRTY(toProg->dirtyParam[i], bitID)) { + if (toProg->isARBprogram) + diff_api.ProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, toProg->parameters[i]); + else + diff_api.ProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_NV, i, toProg->parameters[i]); + CLEARDIRTY(toProg->dirtyParam[i], nbitID); + } + } + CLEARDIRTY(toProg->dirtyParams, nbitID); + } + } + } + + /* + * Separate paths for NV vs ARB fragment program + */ + if (to->fpEnabled) { + /* NV fragment program binding */ + CRProgram *fromProg = from->currentFragmentProgram; + CRProgram *toProg = to->currentFragmentProgram; + if (CHECKDIRTY(b->fpBinding, bitID)) { + if (fromProg->id != toProg->id) { + diff_api.BindProgramNV(GL_FRAGMENT_PROGRAM_NV, toProg->id); + from->currentFragmentProgram = toProg; + } + CLEARDIRTY(b->fpBinding, nbitID); + } + + if (toProg) { + /* fragment program text */ + if (CHECKDIRTY(toProg->dirtyProgram, bitID)) { + diff_api.LoadProgramNV( GL_FRAGMENT_PROGRAM_NV, toProg->id, + toProg->length, toProg->string ); + CLEARDIRTY(toProg->dirtyProgram, nbitID); + } + + /* fragment program global/env parameters */ + if (CHECKDIRTY(b->fragmentEnvParameters, bitID)) { + for (i = 0; i < toCtx->limits.maxFragmentProgramEnvParams; i++) { + if (CHECKDIRTY(b->fragmentEnvParameter[i], bitID)) { + diff_api.ProgramParameter4fvNV(GL_FRAGMENT_PROGRAM_NV, i, + to->fragmentParameters[i]); + if (fromProg) { + COPY_4V(from->fragmentParameters[i], + to->fragmentParameters[i]); + } + CLEARDIRTY(b->fragmentEnvParameter[i], nbitID); + } + } + CLEARDIRTY(b->fragmentEnvParameters, nbitID); + } + + /* named local parameters */ + if (CHECKDIRTY(toProg->dirtyNamedParams, bitID)) { + CRProgramSymbol *symbol; + for (symbol = toProg->symbolTable; symbol; symbol = symbol->next) { + if (CHECKDIRTY(symbol->dirty, bitID)) { + GLint len = crStrlen(symbol->name); + diff_api.ProgramNamedParameter4fvNV(toProg->id, len, + (const GLubyte *) symbol->name, + symbol->value); + if (fromProg) { + SetProgramSymbol(fromProg, symbol->name, len, + symbol->value[0], symbol->value[1], + symbol->value[2], symbol->value[3]); + } + CLEARDIRTY(symbol->dirty, nbitID); + } + } + CLEARDIRTY(toProg->dirtyNamedParams, nbitID); + } + + /* numbered local parameters */ + if (CHECKDIRTY(toProg->dirtyParams, bitID)) { + for (i = 0; i < CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS; i++) { + if (CHECKDIRTY(toProg->dirtyParam[i], bitID)) { + diff_api.ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_NV, i, + toProg->parameters[i]); + if (fromProg) { + COPY_4V(fromProg->parameters[i], toProg->parameters[i]); + } + CLEARDIRTY(toProg->dirtyParam[i], nbitID); + } + } + CLEARDIRTY(toProg->dirtyParams, nbitID); + } + } + } + else if (to->fpEnabledARB) { + /* ARB fragment program binding */ + CRProgram *fromProg = from->currentFragmentProgram; + CRProgram *toProg = to->currentFragmentProgram; + if (CHECKDIRTY(b->fpBinding, bitID)) { + if (fromProg->id != toProg->id) { + diff_api.BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, toProg->id); + from->currentFragmentProgram = toProg; + } + CLEARDIRTY(b->fpBinding, nbitID); + } + + if (toProg) { + /* fragment program text */ + if (CHECKDIRTY(toProg->dirtyProgram, bitID)) { + diff_api.ProgramStringARB( GL_FRAGMENT_PROGRAM_ARB, toProg->format, + toProg->length, toProg->string ); + CLEARDIRTY(toProg->dirtyProgram, nbitID); + } + + /* fragment program global/env parameters */ + if (CHECKDIRTY(b->fragmentEnvParameters, bitID)) { + for (i = 0; i < toCtx->limits.maxFragmentProgramEnvParams; i++) { + if (CHECKDIRTY(b->fragmentEnvParameter[i], bitID)) { + diff_api.ProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, + to->fragmentParameters[i]); + if (fromProg) { + COPY_4V(from->fragmentParameters[i], + to->fragmentParameters[i]); + } + CLEARDIRTY(b->fragmentEnvParameter[i], nbitID); + } + } + CLEARDIRTY(b->fragmentEnvParameters, nbitID); + } + + /* numbered local parameters */ + if (CHECKDIRTY(toProg->dirtyParams, bitID)) { + for (i = 0; i < CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS; i++) { + if (CHECKDIRTY(toProg->dirtyParam[i], bitID)) { + diff_api.ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, + toProg->parameters[i]); + if (fromProg) { + COPY_4V(fromProg->parameters[i], toProg->parameters[i]); + } + CLEARDIRTY(toProg->dirtyParam[i], nbitID); + } + } + CLEARDIRTY(toProg->dirtyParams, nbitID); + } + } + } + + CLEARDIRTY(b->dirty, nbitID); +} + + +void +crStateProgramSwitch(CRProgramBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRProgramState *from = &(fromCtx->program); + CRProgramState *to = &(toCtx->program); + unsigned int i, j; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + GLenum whichVert = fromCtx->extensions.ARB_vertex_program && toCtx->extensions.ARB_vertex_program ? GL_VERTEX_PROGRAM_ARB : GL_VERTEX_PROGRAM_NV; + + + for (j=0;jvpEnable, bitID)) { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->vpEnabled != to->vpEnabled) { + able[to->vpEnabled](whichVert); + } + if (from->vpTwoSide != to->vpTwoSide) { + able[to->vpTwoSide](GL_VERTEX_PROGRAM_TWO_SIDE_NV); + } + if (from->vpPointSize != to->vpPointSize) { + able[to->vpPointSize](GL_VERTEX_PROGRAM_POINT_SIZE_NV); + } + DIRTY(b->vpEnable, nbitID); + } + + /* fragment program enable */ + if (CHECKDIRTY(b->fpEnable, bitID)) { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->fpEnabled != to->fpEnabled) { + able[to->fpEnabled](GL_FRAGMENT_PROGRAM_NV); + } + if (from->fpEnabledARB != to->fpEnabledARB) { + able[to->fpEnabledARB](GL_FRAGMENT_PROGRAM_ARB); + } + DIRTY(b->fpEnable, nbitID); + } + + /* program/track matrices */ + if (to->vpEnabled) { + for (i = 0; i < toCtx->limits.maxVertexProgramEnvParams / 4; i++) { + if (CHECKDIRTY(b->trackMatrix[i], bitID)) { + if (from->TrackMatrix[i] != to->TrackMatrix[i]) { + diff_api.TrackMatrixNV(GL_VERTEX_PROGRAM_NV, i * 4, + to->TrackMatrix[i], + to->TrackMatrixTransform[i]); + } + DIRTY(b->trackMatrix[i], nbitID); + } + } + } + + if (to->vpEnabled) { + /* vertex program binding */ + CRProgram *fromProg = from->currentVertexProgram; + CRProgram *toProg = to->currentVertexProgram; + if (CHECKDIRTY(b->vpBinding, bitID)) { + if (fromProg->id != toProg->id) { + if (toProg->isARBprogram) + diff_api.BindProgramARB(GL_VERTEX_PROGRAM_ARB, toProg->id); + else + diff_api.BindProgramNV(GL_VERTEX_PROGRAM_NV, toProg->id); + } + DIRTY(b->vpBinding, nbitID); + } + + if (toProg) { + /* vertex program text */ + if (CHECKDIRTY(toProg->dirtyProgram, bitID)) { + if (toProg->isARBprogram) + diff_api.ProgramStringARB(GL_VERTEX_PROGRAM_ARB, toProg->format, toProg->length, toProg->string); + else + diff_api.LoadProgramNV(GL_VERTEX_PROGRAM_NV, toProg->id, toProg->length, toProg->string); + + DIRTY(toProg->dirtyProgram, nbitID); + } + + /* vertex program global/env parameters */ + if (CHECKDIRTY(b->vertexEnvParameters, bitID)) { + for (i = 0; i < toCtx->limits.maxVertexProgramEnvParams; i++) { + if (CHECKDIRTY(b->vertexEnvParameter[i], bitID)) { + if (toProg->isARBprogram) + diff_api.ProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, to->vertexParameters[i]); + else + diff_api.ProgramParameter4fvNV(GL_VERTEX_PROGRAM_NV, i, to->vertexParameters[i]); + + DIRTY(b->vertexEnvParameter[i], nbitID); + } + } + DIRTY(b->vertexEnvParameters, nbitID); + } + + /* vertex program local parameters */ + if (CHECKDIRTY(toProg->dirtyParams, bitID)) { + for (i = 0; i < toCtx->limits.maxVertexProgramLocalParams; i++) { + if (CHECKDIRTY(toProg->dirtyParam[i], bitID)) { + + + if (toProg->isARBprogram) + diff_api.ProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, toProg->parameters[i]); + else + diff_api.ProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_NV, i, toProg->parameters[i]); + } + } + DIRTY(toProg->dirtyParams, nbitID); + } + } + } + + /* + * Separate paths for NV vs ARB fragment program + */ + if (to->fpEnabled) { + /* NV fragment program binding */ + CRProgram *fromProg = from->currentFragmentProgram; + CRProgram *toProg = to->currentFragmentProgram; + if (CHECKDIRTY(b->fpBinding, bitID)) { + if (fromProg->id != toProg->id) { + diff_api.BindProgramNV(GL_FRAGMENT_PROGRAM_NV, toProg->id); + } + DIRTY(b->fpBinding, nbitID); + } + + if (toProg) { + /* fragment program text */ + if (CHECKDIRTY(toProg->dirtyProgram, bitID)) { + diff_api.LoadProgramNV(GL_FRAGMENT_PROGRAM_NV, toProg->id, toProg->length, toProg->string); + DIRTY(toProg->dirtyProgram, nbitID); + } + + /* fragment program global/env parameters */ + if (CHECKDIRTY(b->fragmentEnvParameters, bitID)) { + for (i = 0; i < toCtx->limits.maxFragmentProgramEnvParams; i++) { + if (CHECKDIRTY(b->fragmentEnvParameter[i], bitID)) { + diff_api.ProgramParameter4fvNV(GL_FRAGMENT_PROGRAM_NV, i, + to->fragmentParameters[i]); + DIRTY(b->fragmentEnvParameter[i], nbitID); + } + } + DIRTY(b->fragmentEnvParameters, nbitID); + } + + /* named local parameters */ + if (CHECKDIRTY(toProg->dirtyNamedParams, bitID)) { + CRProgramSymbol *symbol; + for (symbol = toProg->symbolTable; symbol; symbol = symbol->next) { + if (CHECKDIRTY(symbol->dirty, bitID)) { + GLint len = crStrlen(symbol->name); + diff_api.ProgramNamedParameter4fvNV(toProg->id, len, + (const GLubyte *) symbol->name, + symbol->value); + DIRTY(symbol->dirty, nbitID); + } + } + DIRTY(toProg->dirtyNamedParams, nbitID); + } + + /* numbered local parameters */ + if (CHECKDIRTY(toProg->dirtyParams, bitID)) { + for (i = 0; i < CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS; i++) { + if (CHECKDIRTY(toProg->dirtyParam[i], bitID)) { + if (toProg->isARBprogram) + diff_api.ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, toProg->parameters[i]); + else + diff_api.ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_NV, i, toProg->parameters[i]); + } + } + DIRTY(toProg->dirtyParams, nbitID); + } + } + } + else if (to->fpEnabledARB) { + /* ARB fragment program binding */ + CRProgram *fromProg = from->currentFragmentProgram; + CRProgram *toProg = to->currentFragmentProgram; + if (CHECKDIRTY(b->fpBinding, bitID)) { + if (fromProg->id != toProg->id) { + diff_api.BindProgramARB(GL_FRAGMENT_PROGRAM_ARB, toProg->id); + } + DIRTY(b->fpBinding, nbitID); + } + + if (toProg) { + /* fragment program text */ + if (CHECKDIRTY(toProg->dirtyProgram, bitID)) { + diff_api.ProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, toProg->format, toProg->length, toProg->string); + DIRTY(toProg->dirtyProgram, nbitID); + } + + /* fragment program global/env parameters */ + if (CHECKDIRTY(b->fragmentEnvParameters, bitID)) { + for (i = 0; i < toCtx->limits.maxFragmentProgramEnvParams; i++) { + if (CHECKDIRTY(b->fragmentEnvParameter[i], bitID)) { + diff_api.ProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, to->fragmentParameters[i]); + DIRTY(b->fragmentEnvParameter[i], nbitID); + } + } + DIRTY(b->fragmentEnvParameters, nbitID); + } + + /* numbered local parameters */ + if (CHECKDIRTY(toProg->dirtyParams, bitID)) { + for (i = 0; i < CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS; i++) { + if (CHECKDIRTY(toProg->dirtyParam[i], bitID)) { + diff_api.ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, toProg->parameters[i]); + DIRTY(toProg->dirtyParam[i], nbitID); + } + } + DIRTY(toProg->dirtyParams, nbitID); + } + } + } + + DIRTY(b->dirty, nbitID); + + /* Resend program data */ + if (toCtx->program.bResyncNeeded) + { + toCtx->program.bResyncNeeded = GL_FALSE; + + crStateDiffAllPrograms(toCtx, bitID, GL_TRUE); + } +} + +/** @todo support NVprograms and add some data validity checks*/ +static void +DiffProgramCallback(unsigned long key, void *pProg, void *pCtx) +{ + CRContext *pContext = (CRContext *) pCtx; + CRProgram *pProgram = (CRProgram *) pProg; + uint32_t i; + (void)key; + + if (pProgram->isARBprogram) + { + diff_api.BindProgramARB(pProgram->target, pProgram->id); + diff_api.ProgramStringARB(pProgram->target, pProgram->format, pProgram->length, pProgram->string); + + if (GL_VERTEX_PROGRAM_ARB == pProgram->target) + { + /* vertex program global/env parameters */ + for (i = 0; i < pContext->limits.maxVertexProgramEnvParams; i++) + { + diff_api.ProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, pContext->program.vertexParameters[i]); + } + /* vertex program local parameters */ + for (i = 0; i < pContext->limits.maxVertexProgramLocalParams; i++) + { + diff_api.ProgramLocalParameter4fvARB(GL_VERTEX_PROGRAM_ARB, i, pProgram->parameters[i]); + } + } + else if (GL_FRAGMENT_PROGRAM_ARB == pProgram->target) + { + /* vertex program global/env parameters */ + for (i = 0; i < pContext->limits.maxFragmentProgramEnvParams; i++) + { + diff_api.ProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, pContext->program.fragmentParameters[i]); + } + /* vertex program local parameters */ + for (i = 0; i < CR_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMS; i++) + { + diff_api.ProgramLocalParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, i, pProgram->parameters[i]); + } + } + else + { + crError("Unexpected program target"); + } + } + else + { + diff_api.BindProgramNV(pProgram->target, pProgram->id); + } +} + +void crStateDiffAllPrograms(CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate) +{ + CRProgram *pOrigVP, *pOrigFP; + + (void) bForceUpdate; (void)bitID; + + /* save original bindings */ + pOrigVP = g->program.currentVertexProgram; + pOrigFP = g->program.currentFragmentProgram; + + crHashtableWalk(g->program.programHash, DiffProgramCallback, g); + + /* restore original bindings */ + if (pOrigVP->isARBprogram) + diff_api.BindProgramARB(pOrigVP->target, pOrigVP->id); + else + diff_api.BindProgramNV(pOrigVP->target, pOrigVP->id); + + if (pOrigFP->isARBprogram) + diff_api.BindProgramARB(pOrigFP->target, pOrigFP->id); + else + diff_api.BindProgramNV(pOrigFP->target, pOrigFP->id); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_program.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_program.txt new file mode 100644 index 00000000..fdb5c75e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_program.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +#:enable:lineSmooth:GL_LINE_SMOOTH +#:enable:lineStipple:GL_LINE_STIPPLE +#:width:width:LineWidth +#lineStipple:stipple:repeat,pattern:LineStipple +:vpEnable:vpEnabled:Enable:GL_VERTEX_PROGRAM_NV +:fpEnable:fpEnabled:Enable:GL_FRAGMENT_PROGRAM_NV +%flush +:vpBinding:currentVertexProgram->id:BindProgramNV,GL_VERTEX_PROGRAM_NV +:fpBinding:currentFragmentProgram->id:BindProgramNV,GL_FRAGMENT_PROGRAM_NV +#:errorPos:errorPos:ErrorPos diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_rasterpos.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_rasterpos.c new file mode 100644 index 00000000..29b23970 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_rasterpos.c @@ -0,0 +1,327 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + + +/* + * Apply modelview, projection, viewport transformations to (x,y,z,w) + * and update the current raster position attributes. + * Do NOT set dirty state. + */ +void +crStateRasterPosUpdate(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRCurrentState *c = &(g->current); + CRTransformState *t = &(g->transform); + CRViewportState *v = &(g->viewport); + GLvectorf p; + int i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "RasterPos called in Begin/End"); + return; + } + + FLUSH(); + + /* update current color, texcoord, etc from the CurrentStatePointers */ + crStateCurrentRecover(); + + p.x = x; + p.y = y; + p.z = z; + p.w = w; + + /* Apply modelview and projection matrix */ + crStateTransformXformPoint(t, &p); + + /* clip test */ + if (p.x > p.w || p.y > p.w || p.z > p.w || + p.x < -p.w || p.y < -p.w || p.z < -p.w) + { + c->rasterValid = GL_FALSE; + return; + } + + /* divide by W (perspective projection) */ + p.x /= p.w; + p.y /= p.w; + p.z /= p.w; + p.w = 1.0f; + + /* map from NDC to window coords */ + crStateViewportApply(v, &p); + + c->rasterValid = GL_TRUE; + ASSIGN_4V(c->rasterAttrib[VERT_ATTRIB_POS], p.x, p.y, p.z, p.w); + ASSIGN_4V(c->rasterAttribPre[VERT_ATTRIB_POS], p.x, p.y, p.z, p.w); + for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { + COPY_4V(c->rasterAttrib[i] , c->vertexAttrib[i]); + } + + /* XXX need to update raster distance... */ + /* from Mesa... */ +#ifdef CR_EXT_fog_coord + if (g->fog.fogCoordinateSource == GL_FOG_COORDINATE_EXT) + c->rasterAttrib[VERT_ATTRIB_FOG][0] = c->vertexAttrib[VERT_ATTRIB_FOG][0]; + else +#endif + c->rasterAttrib[VERT_ATTRIB_FOG][0] = 0.0; /*(GLfloat) + sqrt( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );*/ +} + + +/* As above, but set dirty flags */ +static void RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CRCurrentBits *cb = &(sb->current); + + crStateRasterPosUpdate(x, y, z, w); + + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->rasterPos, g->neg_bitid); +} + +void STATE_APIENTRY crStateRasterPos2d(GLdouble x, GLdouble y) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos2f(GLfloat x, GLfloat y) +{ + RasterPos4f(x, y, 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos2i(GLint x, GLint y) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos2s(GLshort x, GLshort y) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3d(GLdouble x, GLdouble y, GLdouble z) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3f(GLfloat x, GLfloat y, GLfloat z) +{ + RasterPos4f(x, y, z, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3i(GLint x, GLint y, GLint z) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3s(GLshort x, GLshort y, GLshort z) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY crStateRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) +{ + RasterPos4f(x, y, z, w); +} + +void STATE_APIENTRY crStateRasterPos4i(GLint x, GLint y, GLint z, GLint w) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY crStateRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w) +{ + RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w); +} + +void STATE_APIENTRY crStateRasterPos2dv(const GLdouble *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos2fv(const GLfloat *v) +{ + RasterPos4f(v[0], v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos2iv(const GLint *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos2sv(const GLshort *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0f, 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3dv(const GLdouble *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3fv(const GLfloat *v) +{ + RasterPos4f(v[0], v[1], v[2], 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3iv(const GLint *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0f); +} + +void STATE_APIENTRY crStateRasterPos3sv(const GLshort *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0f); +} + +void STATE_APIENTRY crStateRasterPos4dv(const GLdouble *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +void STATE_APIENTRY crStateRasterPos4fv(const GLfloat *v) +{ + RasterPos4f(v[0], v[1], v[2], v[3]); +} + +void STATE_APIENTRY crStateRasterPos4iv(const GLint *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + +void STATE_APIENTRY crStateRasterPos4sv(const GLshort *v) +{ + RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]); +} + + +/**********************************************************************/ + + +static void +crStateWindowPosUpdate(GLfloat x, GLfloat y, GLfloat z) +{ + CRContext *g = GetCurrentContext(); + CRCurrentState *c = &(g->current); + CRStateBits *sb = GetCurrentBits(); + CRCurrentBits *cb = &(sb->current); + int i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "WindowPos called in Begin/End"); + return; + } + + FLUSH(); + DIRTY(cb->dirty, g->neg_bitid); + DIRTY(cb->rasterPos, g->neg_bitid); + + c->rasterValid = GL_TRUE; + ASSIGN_4V(c->rasterAttrib[VERT_ATTRIB_POS], x, y , z, 1.0); + ASSIGN_4V(c->rasterAttribPre[VERT_ATTRIB_POS], x, y, z, 1.0); + for (i = 1; i < CR_MAX_VERTEX_ATTRIBS; i++) { + COPY_4V(c->rasterAttrib[i] , c->vertexAttrib[i]); + } +} + + +void STATE_APIENTRY crStateWindowPos2dARB (GLdouble x, GLdouble y) +{ + crStateWindowPosUpdate((GLfloat) x, (GLfloat) y, 0.0); +} + +void STATE_APIENTRY crStateWindowPos2dvARB (const GLdouble *v) +{ + crStateWindowPosUpdate((GLfloat) v[0], (GLfloat) v[1], 0.0); +} + +void STATE_APIENTRY crStateWindowPos2fARB (GLfloat x, GLfloat y) +{ + crStateWindowPosUpdate(x, y, 0.0); +} + +void STATE_APIENTRY crStateWindowPos2fvARB (const GLfloat *v) +{ + crStateWindowPosUpdate(v[0], v[1], 0.0); +} + +void STATE_APIENTRY crStateWindowPos2iARB (GLint x, GLint y) +{ + crStateWindowPosUpdate((GLfloat) x, (GLfloat) y, 0.0); +} + +void STATE_APIENTRY crStateWindowPos2ivARB (const GLint *v) +{ + crStateWindowPosUpdate((GLfloat) v[0], (GLfloat) v[1], 0.0); +} + +void STATE_APIENTRY crStateWindowPos2sARB (GLshort x, GLshort y) +{ + crStateWindowPosUpdate((GLfloat) x, (GLfloat) y, 0.0); +} + +void STATE_APIENTRY crStateWindowPos2svARB (const GLshort *v) +{ + crStateWindowPosUpdate((GLfloat) v[0], (GLfloat) v[1], 0.0); +} + +void STATE_APIENTRY crStateWindowPos3dARB (GLdouble x, GLdouble y, GLdouble z) +{ + crStateWindowPosUpdate((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + +void STATE_APIENTRY crStateWindowPos3dvARB (const GLdouble *v) +{ + crStateWindowPosUpdate((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); +} + +void STATE_APIENTRY crStateWindowPos3fARB (GLfloat x, GLfloat y, GLfloat z) +{ + crStateWindowPosUpdate(x, y, z); +} + +void STATE_APIENTRY crStateWindowPos3fvARB (const GLfloat *v) +{ + crStateWindowPosUpdate(v[0], v[1], v[2]); +} + +void STATE_APIENTRY crStateWindowPos3iARB (GLint x, GLint y, GLint z) +{ + crStateWindowPosUpdate((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + +void STATE_APIENTRY crStateWindowPos3ivARB (const GLint *v) +{ + crStateWindowPosUpdate((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); +} + +void STATE_APIENTRY crStateWindowPos3sARB (GLshort x, GLshort y, GLshort z) +{ + crStateWindowPosUpdate((GLfloat) x, (GLfloat) y, (GLfloat) z); +} + +void STATE_APIENTRY crStateWindowPos3svARB (const GLshort *v) +{ + crStateWindowPosUpdate((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]); +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.c new file mode 100644 index 00000000..069c6fa5 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.c @@ -0,0 +1,705 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state/cr_statetypes.h" + + +#define UNUSED(x) ((void) (x)) + + +void crStateRegCombinerInit( CRContext *ctx ) +{ + CRRegCombinerState *reg = &ctx->regcombiner; + CRStateBits *sb = GetCurrentBits(); + CRRegCombinerBits *rb = &(sb->regcombiner); +#ifndef CR_NV_register_combiners + UNUSED(reg) +#else + GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f}; + int i; + + reg->enabledRegCombiners = GL_FALSE; + RESET(rb->enable, ctx->bitid); + reg->constantColor0 = zero_color; + RESET(rb->regCombinerColor0, ctx->bitid); + reg->constantColor1 = zero_color; + RESET(rb->regCombinerColor1, ctx->bitid); + for( i=0; irgb[i].a = GL_PRIMARY_COLOR_NV; + reg->rgb[i].b = GL_ZERO; + reg->rgb[i].c = GL_ZERO; + reg->rgb[i].d = GL_ZERO; + reg->rgb[i].aMapping = GL_UNSIGNED_IDENTITY_NV; + reg->rgb[i].bMapping = GL_UNSIGNED_INVERT_NV; + reg->rgb[i].cMapping = GL_UNSIGNED_IDENTITY_NV; + reg->rgb[i].dMapping = GL_UNSIGNED_IDENTITY_NV; + reg->rgb[i].aPortion = GL_RGB; + reg->rgb[i].bPortion = GL_RGB; + reg->rgb[i].cPortion = GL_RGB; + reg->rgb[i].dPortion = GL_RGB; + reg->rgb[i].scale = GL_NONE; + reg->rgb[i].bias = GL_NONE; + reg->rgb[i].abOutput = GL_DISCARD_NV; + reg->rgb[i].cdOutput = GL_DISCARD_NV; + reg->rgb[i].sumOutput = GL_SPARE0_NV; + reg->rgb[i].abDotProduct = GL_FALSE; + reg->rgb[i].cdDotProduct = GL_FALSE; + reg->rgb[i].muxSum = GL_FALSE; + + /* Alpha Portion */ + reg->alpha[i].a = GL_PRIMARY_COLOR_NV; + reg->alpha[i].b = GL_ZERO; + reg->alpha[i].c = GL_ZERO; + reg->alpha[i].d = GL_ZERO; + reg->alpha[i].aMapping = GL_UNSIGNED_IDENTITY_NV; + reg->alpha[i].bMapping = GL_UNSIGNED_INVERT_NV; + reg->alpha[i].cMapping = GL_UNSIGNED_IDENTITY_NV; + reg->alpha[i].dMapping = GL_UNSIGNED_IDENTITY_NV; + reg->alpha[i].aPortion = GL_ALPHA; + reg->alpha[i].bPortion = GL_ALPHA; + reg->alpha[i].cPortion = GL_ALPHA; + reg->alpha[i].dPortion = GL_ALPHA; + reg->alpha[i].scale = GL_NONE; + reg->alpha[i].bias = GL_NONE; + reg->alpha[i].abOutput = GL_DISCARD_NV; + reg->alpha[i].cdOutput = GL_DISCARD_NV; + reg->alpha[i].sumOutput = GL_SPARE0_NV; + reg->alpha[i].abDotProduct = GL_FALSE; + reg->alpha[i].cdDotProduct = GL_FALSE; + reg->alpha[i].muxSum = GL_FALSE; + RESET(rb->regCombinerInput[i], ctx->bitid); + RESET(rb->regCombinerOutput[i], ctx->bitid); + } + RESET(rb->regCombinerVars, ctx->bitid); + reg->numGeneralCombiners = 1; + reg->colorSumClamp = GL_TRUE; + reg->a = GL_FOG; + reg->b = GL_SPARE0_PLUS_SECONDARY_COLOR_NV; + reg->c = GL_FOG; + reg->d = GL_ZERO; + reg->e = GL_ZERO; + reg->f = GL_ZERO; + reg->g = GL_SPARE0_NV; + reg->aMapping = GL_UNSIGNED_IDENTITY_NV; + reg->bMapping = GL_UNSIGNED_IDENTITY_NV; + reg->cMapping = GL_UNSIGNED_IDENTITY_NV; + reg->dMapping = GL_UNSIGNED_IDENTITY_NV; + reg->eMapping = GL_UNSIGNED_IDENTITY_NV; + reg->fMapping = GL_UNSIGNED_IDENTITY_NV; + reg->gMapping = GL_UNSIGNED_IDENTITY_NV; + reg->aPortion = GL_ALPHA; + reg->bPortion = GL_RGB; + reg->cPortion = GL_RGB; + reg->dPortion = GL_RGB; + reg->ePortion = GL_RGB; + reg->fPortion = GL_RGB; + reg->gPortion = GL_ALPHA; + RESET(rb->regCombinerFinalInput, ctx->bitid); +#ifdef CR_NV_register_combiners2 + reg->enabledPerStageConstants = GL_FALSE; + for( i=0; istageConstantColor0[i] = zero_color; + reg->stageConstantColor1[i] = zero_color; + RESET(rb->regCombinerStageColor0[i], ctx->bitid); + RESET(rb->regCombinerStageColor1[i], ctx->bitid); + } +#endif /* CR_NV_register_combiners2 */ +#endif /* CR_NV_register_combiners */ + + RESET(rb->dirty, ctx->bitid); +} + +void STATE_APIENTRY crStateCombinerParameterfvNV( GLenum pname, const GLfloat *params ) +{ + CRContext *g = GetCurrentContext(); + CRRegCombinerState *r = &(g->regcombiner); + CRStateBits *sb = GetCurrentBits(); + CRRegCombinerBits *rb = &(sb->regcombiner); + + switch( pname ) + { + case GL_CONSTANT_COLOR0_NV: + r->constantColor0.r = params[0]; + r->constantColor0.g = params[1]; + r->constantColor0.b = params[2]; + r->constantColor0.a = params[3]; + DIRTY(rb->regCombinerColor0, g->neg_bitid); + break; + case GL_CONSTANT_COLOR1_NV: + r->constantColor1.r = params[0]; + r->constantColor1.g = params[1]; + r->constantColor1.b = params[2]; + r->constantColor1.a = params[3]; + DIRTY(rb->regCombinerColor1, g->neg_bitid); + break; + case GL_NUM_GENERAL_COMBINERS_NV: + if( *params < 1 || *params > g->limits.maxGeneralCombiners ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "CombinerParameter passed invalid NUM_GENERAL_COMBINERS param: %d", (GLint)*params ); + return; + } + r->numGeneralCombiners = (GLint)*params; + DIRTY(rb->regCombinerVars, g->neg_bitid); + break; + case GL_COLOR_SUM_CLAMP_NV: + r->colorSumClamp = (GLboolean)*params; + DIRTY(rb->regCombinerVars, g->neg_bitid); + break; + default: + crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerParameter passed bogus pname: 0x%x", pname ); + return; + } + + DIRTY(rb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateCombinerParameterivNV( GLenum pname, const GLint *params ) +{ + GLfloat fparams[4]; + int i; + + if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV ) + { + for( i=0; i<4; i++ ) + { + fparams[i] = (GLfloat)params[i] * (GLfloat)(1.0/255.0); + } + } + else + { + /* Only one parameter: */ + *fparams = (GLfloat) *params; + } + crStateCombinerParameterfvNV( pname, fparams ); +} + +void STATE_APIENTRY crStateCombinerParameterfNV( GLenum pname, GLfloat param ) +{ + GLfloat fparam[1]; + *fparam = (GLfloat) param; + if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV ) + { + crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameterfNV: 0x%x", (GLint)param-GL_CONSTANT_COLOR0_NV, pname ); + return; + } + crStateCombinerParameterfvNV( pname, fparam ); +} + +void STATE_APIENTRY crStateCombinerParameteriNV( GLenum pname, GLint param ) +{ + GLfloat fparam[1]; + *fparam = (GLfloat) param; + if( pname == GL_CONSTANT_COLOR0_NV || pname == GL_CONSTANT_COLOR1_NV ) + { + crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "Invalid pname (CONSTANT_COLOR%d) passed to CombinerParameteriNV: 0x%x", param-GL_CONSTANT_COLOR0_NV, pname ); + return; + } + crStateCombinerParameterfvNV( pname, fparam ); +} + +void STATE_APIENTRY crStateCombinerInputNV( GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage ) +{ + CRContext *g = GetCurrentContext(); + CRRegCombinerState *r = &(g->regcombiner); + CRStateBits *sb = GetCurrentBits(); + CRRegCombinerBits *rb = &(sb->regcombiner); + + if( stage < GL_COMBINER0_NV || stage >= GL_COMBINER0_NV + g->limits.maxGeneralCombiners ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus stage: 0x%x", stage ); + return; + } + if( input != GL_ZERO && input != GL_CONSTANT_COLOR0_NV && input != GL_CONSTANT_COLOR1_NV && input != GL_FOG && input != GL_PRIMARY_COLOR_NV && input != GL_SECONDARY_COLOR_NV && input != GL_SPARE0_NV && input != GL_SPARE1_NV && ( input < GL_TEXTURE0_ARB || input >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits )) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus input: 0x%x", input ); + return; + } + if( mapping != GL_UNSIGNED_IDENTITY_NV && mapping != GL_UNSIGNED_INVERT_NV && mapping != GL_EXPAND_NORMAL_NV && mapping != GL_EXPAND_NEGATE_NV && mapping != GL_HALF_BIAS_NORMAL_NV && mapping != GL_HALF_BIAS_NEGATE_NV && mapping != GL_SIGNED_IDENTITY_NV && mapping != GL_SIGNED_NEGATE_NV ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus mapping: 0x%x", mapping ); + return; + } + if( componentUsage != GL_RGB && componentUsage != GL_ALPHA && componentUsage != GL_BLUE ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus componentUsage: 0x%x", componentUsage ); + return; + } + + if(( componentUsage == GL_RGB && portion == GL_ALPHA )||( componentUsage == GL_BLUE && portion == GL_RGB )) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Incompatible portion and componentUsage passed to CombinerInputNV: portion = 0x%x, componentUsage = 0x%x", portion, componentUsage ); + return; + } + if( componentUsage == GL_ALPHA && input == GL_FOG ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerInputNV can not have input of GL_FOG if componentUsage is GL_ALPHA" ); + return; + } + + stage -= GL_COMBINER0_NV; + if( portion == GL_RGB ) + { + switch( variable ) + { + case GL_VARIABLE_A_NV: + r->rgb[stage].a = input; + r->rgb[stage].aMapping = mapping; + r->rgb[stage].aPortion = componentUsage; + break; + case GL_VARIABLE_B_NV: + r->rgb[stage].b = input; + r->rgb[stage].bMapping = mapping; + r->rgb[stage].bPortion = componentUsage; + break; + case GL_VARIABLE_C_NV: + r->rgb[stage].c = input; + r->rgb[stage].cMapping = mapping; + r->rgb[stage].cPortion = componentUsage; + break; + case GL_VARIABLE_D_NV: + r->rgb[stage].d = input; + r->rgb[stage].dMapping = mapping; + r->rgb[stage].dPortion = componentUsage; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable ); + return; + } + } + else if( portion == GL_ALPHA ) + { + switch( variable ) + { + case GL_VARIABLE_A_NV: + r->alpha[stage].a = input; + r->alpha[stage].aMapping = mapping; + r->alpha[stage].aPortion = componentUsage; + break; + case GL_VARIABLE_B_NV: + r->alpha[stage].b = input; + r->alpha[stage].bMapping = mapping; + r->alpha[stage].bPortion = componentUsage; + break; + case GL_VARIABLE_C_NV: + r->alpha[stage].c = input; + r->alpha[stage].cMapping = mapping; + r->alpha[stage].cPortion = componentUsage; + break; + case GL_VARIABLE_D_NV: + r->alpha[stage].d = input; + r->alpha[stage].dMapping = mapping; + r->alpha[stage].dPortion = componentUsage; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus variable: 0x%x", variable ); + return; + } + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerInputNV passed bogus portion: 0x%x", portion ); + return; + } + + DIRTY(rb->regCombinerInput[stage], g->neg_bitid); + DIRTY(rb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateCombinerOutputNV( GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum ) +{ + CRContext *g = GetCurrentContext(); + CRRegCombinerState *r = &(g->regcombiner); + CRStateBits *sb = GetCurrentBits(); + CRRegCombinerBits *rb = &(sb->regcombiner); + + /* + crDebug("%s(stage=0x%x portion=0x%x abOutput=0x%x cdOutput=0x%x " + "sumOutput=0x%x scale=0x%x bias=0x%x abDotProduct=0x%x " + "cdDotProduct=%d muxSum=%d)\n", + __FUNCTION__, + stage, portion, abOutput, cdOutput, sumOutput, scale, bias, + abDotProduct, cdDotProduct, muxSum); + */ + if( stage < GL_COMBINER0_NV || stage >= GL_COMBINER0_NV + g->limits.maxGeneralCombiners ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus stage: 0x%x", stage ); + return; + } + if( abOutput != GL_DISCARD_NV && abOutput != GL_PRIMARY_COLOR_NV && abOutput != GL_SECONDARY_COLOR_NV && abOutput != GL_SPARE0_NV && abOutput != GL_SPARE1_NV && ( abOutput < GL_TEXTURE0_ARB || abOutput >= g->limits.maxTextureUnits + GL_TEXTURE0_ARB )) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus abOutput: 0x%x", abOutput ); + return; + } + if( cdOutput != GL_DISCARD_NV && cdOutput != GL_PRIMARY_COLOR_NV && cdOutput != GL_SECONDARY_COLOR_NV && cdOutput != GL_SPARE0_NV && cdOutput != GL_SPARE1_NV && ( cdOutput < GL_TEXTURE0_ARB || cdOutput >= g->limits.maxTextureUnits + GL_TEXTURE0_ARB )) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus cdOutput: 0x%x", cdOutput ); + return; + } + if( sumOutput != GL_DISCARD_NV && sumOutput != GL_PRIMARY_COLOR_NV && sumOutput != GL_SECONDARY_COLOR_NV && sumOutput != GL_SPARE0_NV && sumOutput != GL_SPARE1_NV && sumOutput != GL_TEXTURE0_ARB && sumOutput != GL_TEXTURE1_ARB ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus sumOutput: 0x%x", sumOutput ); + return; + } + if( scale != GL_NONE && scale != GL_SCALE_BY_TWO_NV && scale != GL_SCALE_BY_FOUR_NV && scale != GL_SCALE_BY_ONE_HALF_NV ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus scale: 0x%x", scale ); + return; + } + if( bias != GL_NONE && bias != GL_BIAS_BY_NEGATIVE_ONE_HALF_NV ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV passed bogus bias: 0x%x", bias ); + return; + } + + if( bias == GL_BIAS_BY_NEGATIVE_ONE_HALF_NV && ( scale == GL_SCALE_BY_ONE_HALF_NV || scale == GL_SCALE_BY_FOUR_NV )) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can't accept bias of -1/2 if scale is by 1/2 or 4" ); + return; + } + if(( abOutput == cdOutput && abOutput != GL_DISCARD_NV )||( abOutput == sumOutput && abOutput != GL_DISCARD_NV )||( cdOutput == sumOutput && cdOutput != GL_DISCARD_NV )) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV register output names must be unique unless discarded: abOutput = 0x%x, cdOutput = 0x%x, sumOutput = 0x%x", abOutput, cdOutput, sumOutput ); + return; + } + if( abDotProduct || cdDotProduct ) + { + if( portion == GL_ALPHA ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "CombinerOutputNV can not do Dot Products when portion = GL_ALPHA" ); + return; + } + if( sumOutput != GL_DISCARD_NV ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "CombinerOutputNV can not do Dot Products when sumOutput is not discarded" ); + return; + } + } + + stage -= GL_COMBINER0_NV; + if( portion == GL_RGB ) + { + r->rgb[stage].abOutput = abOutput; + r->rgb[stage].cdOutput = cdOutput; + r->rgb[stage].sumOutput = sumOutput; + r->rgb[stage].scale = scale; + r->rgb[stage].bias = bias; + r->rgb[stage].abDotProduct = abDotProduct; + r->rgb[stage].cdDotProduct = cdDotProduct; + r->rgb[stage].muxSum = muxSum; + } + else if( portion == GL_ALPHA ) + { + r->alpha[stage].abOutput = abOutput; + r->alpha[stage].cdOutput = cdOutput; + r->alpha[stage].sumOutput = sumOutput; + r->alpha[stage].scale = scale; + r->alpha[stage].bias = bias; + r->alpha[stage].abDotProduct = abDotProduct; + r->alpha[stage].cdDotProduct = cdDotProduct; + r->alpha[stage].muxSum = muxSum; + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus portion: 0x%x", portion ); + return; + } + + DIRTY(rb->regCombinerOutput[stage], g->neg_bitid); + DIRTY(rb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateFinalCombinerInputNV( GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage ) +{ + CRContext *g = GetCurrentContext(); + CRRegCombinerState *r = &(g->regcombiner); + CRStateBits *sb = GetCurrentBits(); + CRRegCombinerBits *rb = &(sb->regcombiner); + + if( input != GL_ZERO && input != GL_CONSTANT_COLOR0_NV && input != GL_CONSTANT_COLOR1_NV && input != GL_FOG && input != GL_PRIMARY_COLOR_NV && input != GL_SECONDARY_COLOR_NV && input != GL_SPARE0_NV && input != GL_SPARE1_NV && ( input < GL_TEXTURE0_ARB || input >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits ) && input != GL_E_TIMES_F_NV && input != GL_SPARE0_PLUS_SECONDARY_COLOR_NV ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus input: 0x%x", input ); + return; + } + if( mapping != GL_UNSIGNED_IDENTITY_NV && mapping != GL_UNSIGNED_INVERT_NV && mapping != GL_EXPAND_NORMAL_NV && mapping != GL_EXPAND_NEGATE_NV && mapping != GL_HALF_BIAS_NORMAL_NV && mapping != GL_HALF_BIAS_NEGATE_NV && mapping != GL_SIGNED_IDENTITY_NV && mapping != GL_SIGNED_NEGATE_NV ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus mapping: 0x%x", mapping ); + return; + } + if( componentUsage != GL_RGB && componentUsage != GL_ALPHA && componentUsage != GL_BLUE ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "FinalCombinerInputNV passed bogus componentUsage: 0x%x", componentUsage ); + return; + } + + if( componentUsage == GL_ALPHA && ( input == GL_E_TIMES_F_NV || input == GL_SPARE0_PLUS_SECONDARY_COLOR_NV )) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV does not allow componentUsage of ALPHA when input is E_TIMES_F or SPARE0_PLUS_SECONDARY_COLOR" ); + return; + } + + switch( variable ) + { + case GL_VARIABLE_A_NV: + r->a = input; + r->aMapping = mapping; + r->aPortion = componentUsage; + break; + case GL_VARIABLE_B_NV: + r->b = input; + r->bMapping = mapping; + r->bPortion = componentUsage; + break; + case GL_VARIABLE_C_NV: + r->c = input; + r->cMapping = mapping; + r->cPortion = componentUsage; + break; + case GL_VARIABLE_D_NV: + r->d = input; + r->dMapping = mapping; + r->dPortion = componentUsage; + break; + case GL_VARIABLE_E_NV: + r->e = input; + r->eMapping = mapping; + r->ePortion = componentUsage; + break; + case GL_VARIABLE_F_NV: + r->f = input; + r->fMapping = mapping; + r->fPortion = componentUsage; + break; + case GL_VARIABLE_G_NV: + if( componentUsage != GL_ALPHA ) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, "FinalCombinerInputNV can not have variable G when componentUsage is RGB or BLUE" ); + return; + } + r->g = input; + r->gMapping = mapping; + r->gPortion = componentUsage; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerOutputNV passed bogus variable: 0x%x", variable ); + return; + } + + DIRTY(rb->regCombinerFinalInput, g->neg_bitid); + DIRTY(rb->dirty, g->neg_bitid); +} + + +/* XXX Unfinished RegCombiner State functions */ +void STATE_APIENTRY crStateGetCombinerOutputParameterfvNV( GLenum stage, GLenum portion, GLenum pname, GLfloat *params ) +{ + (void) stage; + (void) portion; + (void) pname; + (void) params; +} + +void STATE_APIENTRY crStateGetCombinerOutputParameterivNV( GLenum stage, GLenum portion, GLenum pname, GLint *params ) +{ + (void) stage; + (void) portion; + (void) pname; + (void) params; +} + +void STATE_APIENTRY crStateGetFinalCombinerInputParameterfvNV( GLenum variable, GLenum pname, GLfloat *params ) +{ + (void) variable; + (void) pname; + (void) params; +} + +void STATE_APIENTRY crStateGetFinalCombinerInputParameterivNV( GLenum variable, GLenum pname, GLint *params ) +{ + (void) variable; + (void) pname; + (void) params; +} + + +void STATE_APIENTRY crStateGetCombinerInputParameterivNV( GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params ) +{ + CRContext *g = GetCurrentContext(); + CRRegCombinerState *r = &(g->regcombiner); + int i = stage - GL_COMBINER0_NV; + GLenum input = 0, mapping = 0, usage = 0; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetCombinerParameterivNV called in begin/end"); + return; + } + + if (i < 0 || i >= CR_MAX_GENERAL_COMBINERS) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetCombinerInputParameterivNV(stage=0x%x)", stage); + return; + } + + if (portion == GL_RGB) { + switch (variable) { + case GL_VARIABLE_A_NV: + input = r->rgb[i].a; + mapping = r->rgb[i].aMapping; + usage = r->rgb[i].aPortion; + break; + case GL_VARIABLE_B_NV: + input = r->rgb[i].b; + mapping = r->rgb[i].bMapping; + usage = r->rgb[i].bPortion; + break; + case GL_VARIABLE_C_NV: + input = r->rgb[i].c; + mapping = r->rgb[i].cMapping; + usage = r->rgb[i].cPortion; + break; + case GL_VARIABLE_D_NV: + input = r->rgb[i].d; + mapping = r->rgb[i].dMapping; + usage = r->rgb[i].dPortion; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetCombinerInputParameterivNV(variable=0x%x)", variable); + return; + } + } + else if (portion == GL_ALPHA) { + switch (variable) { + case GL_VARIABLE_A_NV: + input = r->alpha[i].a; + mapping = r->alpha[i].aMapping; + usage = r->alpha[i].aPortion; + break; + case GL_VARIABLE_B_NV: + input = r->alpha[i].b; + mapping = r->alpha[i].bMapping; + usage = r->alpha[i].bPortion; + break; + case GL_VARIABLE_C_NV: + input = r->alpha[i].c; + mapping = r->alpha[i].cMapping; + usage = r->alpha[i].cPortion; + break; + case GL_VARIABLE_D_NV: + input = r->alpha[i].d; + mapping = r->alpha[i].dMapping; + usage = r->alpha[i].dPortion; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetCombinerInputParameterivNV(variable=0x%x)", variable); + return; + } + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetCombinerInputParameterivNV(portion=0x%x)", portion); + } + switch (pname) { + case GL_COMBINER_INPUT_NV: + *params = input; + return; + case GL_COMBINER_MAPPING_NV: + *params = mapping; + return; + case GL_COMBINER_COMPONENT_USAGE_NV: + *params = usage; + return; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetCombinerInputParameterivNV(pname=0x%x)", pname); + return; + } +} + + +void STATE_APIENTRY crStateGetCombinerInputParameterfvNV( GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params ) +{ + GLint iparams; + crStateGetCombinerInputParameterivNV(stage, portion, variable, pname, &iparams); + *params = (GLfloat) iparams; +} + + +void STATE_APIENTRY crStateCombinerStageParameterfvNV( GLenum stage, GLenum pname, const GLfloat *params ) +{ + CRContext *g = GetCurrentContext(); + CRRegCombinerState *r = &(g->regcombiner); + CRStateBits *sb = GetCurrentBits(); + CRRegCombinerBits *rb = &(sb->regcombiner); + + stage -= GL_COMBINER0_NV; + if( stage >= g->limits.maxGeneralCombiners ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV ); + return; + } + + switch( pname ) + { + case GL_CONSTANT_COLOR0_NV: + r->stageConstantColor0[stage].r = params[0]; + r->stageConstantColor0[stage].g = params[1]; + r->stageConstantColor0[stage].b = params[2]; + r->stageConstantColor0[stage].a = params[3]; + DIRTY(rb->regCombinerStageColor0[stage], g->neg_bitid); + break; + case GL_CONSTANT_COLOR1_NV: + r->stageConstantColor1[stage].r = params[0]; + r->stageConstantColor1[stage].g = params[1]; + r->stageConstantColor1[stage].b = params[2]; + r->stageConstantColor1[stage].a = params[3]; + DIRTY(rb->regCombinerStageColor1[stage], g->neg_bitid); + break; + default: + crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "CombinerStageParameter passed bogus pname: 0x%x", pname ); + return; + } + + DIRTY(rb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateGetCombinerStageParameterfvNV( GLenum stage, GLenum pname, GLfloat *params ) +{ + CRContext *g = GetCurrentContext(); + CRRegCombinerState *r = &(g->regcombiner); + + stage -= GL_COMBINER0_NV; + if( stage >= g->limits.maxGeneralCombiners ) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameterfvNV passed bogus stage: 0x%x", stage+GL_COMBINER0_NV ); + return; + } + switch( pname ) + { + case GL_CONSTANT_COLOR0_NV: + params[0] = r->stageConstantColor0[stage].r; + params[1] = r->stageConstantColor0[stage].g; + params[2] = r->stageConstantColor0[stage].b; + params[3] = r->stageConstantColor0[stage].a; + break; + case GL_CONSTANT_COLOR1_NV: + params[0] = r->stageConstantColor1[stage].r; + params[1] = r->stageConstantColor1[stage].g; + params[2] = r->stageConstantColor1[stage].b; + params[3] = r->stageConstantColor1[stage].a; + break; + default: + crStateError( __LINE__, __FILE__, GL_INVALID_ENUM, "GetCombinerStageParameter passed bogus pname: 0x%x", pname ); + return; + } + return; +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.txt new file mode 100644 index 00000000..4b867ee5 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_regcombiner.txt @@ -0,0 +1,38 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enable:enabledRegCombiners:GL_REGISTER_COMBINERS_NV +:enable:enabledPerStageConstants:GL_PER_STAGE_CONSTANTS_NV +%flush +:regCombinerVars:numGeneralCombiners:CombinerParameteriNV, GL_NUM_GENERAL_COMBINERS_NV +:regCombinerVars:colorSumClamp:CombinerParameteriNV, GL_COLOR_SUM_CLAMP_NV +:regCombinerColor0:constantColor0|r,g,b,a:CombinerParameterfvNV, GL_CONSTANT_COLOR0_NV +:regCombinerColor1:constantColor1|r,g,b,a:CombinerParameterfvNV, GL_CONSTANT_COLOR1_NV +%flush +>for( i=0; irgb[i].a, to->rgb[i].aMapping, to->rgb[i].aPortion ); +:regCombinerInput[i]:rgb[i].b,rgb[i].bMapping,rgb[i].bPortion:*diff_api.CombinerInputNV( GL_COMBINER0_NV+i, GL_RGB, GL_VARIABLE_B_NV, to->rgb[i].b, to->rgb[i].bMapping, to->rgb[i].bPortion ); +:regCombinerInput[i]:rgb[i].c,rgb[i].cMapping,rgb[i].cPortion:*diff_api.CombinerInputNV( GL_COMBINER0_NV+i, GL_RGB, GL_VARIABLE_C_NV, to->rgb[i].c, to->rgb[i].cMapping, to->rgb[i].cPortion ); +:regCombinerInput[i]:rgb[i].d,rgb[i].dMapping,rgb[i].dPortion:*diff_api.CombinerInputNV( GL_COMBINER0_NV+i, GL_RGB, GL_VARIABLE_D_NV, to->rgb[i].d, to->rgb[i].dMapping, to->rgb[i].dPortion ); +:regCombinerInput[i]:alpha[i].a,alpha[i].aMapping,alpha[i].aPortion:*diff_api.CombinerInputNV( GL_COMBINER0_NV+i, GL_ALPHA, GL_VARIABLE_A_NV, to->alpha[i].a, to->alpha[i].aMapping, to->alpha[i].aPortion ); +:regCombinerInput[i]:alpha[i].b,alpha[i].bMapping,alpha[i].bPortion:*diff_api.CombinerInputNV( GL_COMBINER0_NV+i, GL_ALPHA, GL_VARIABLE_B_NV, to->alpha[i].b, to->alpha[i].bMapping, to->alpha[i].bPortion ); +:regCombinerInput[i]:alpha[i].c,alpha[i].cMapping,alpha[i].cPortion:*diff_api.CombinerInputNV( GL_COMBINER0_NV+i, GL_ALPHA, GL_VARIABLE_C_NV, to->alpha[i].c, to->alpha[i].cMapping, to->alpha[i].cPortion ); +:regCombinerInput[i]:alpha[i].d,alpha[i].dMapping,alpha[i].dPortion:*diff_api.CombinerInputNV( GL_COMBINER0_NV+i, GL_ALPHA, GL_VARIABLE_D_NV, to->alpha[i].d, to->alpha[i].dMapping, to->alpha[i].dPortion ); +:regCombinerOutput[i]:rgb[i]|abOutput,cdOutput,sumOutput,scale,bias,abDotProduct,cdDotProduct,muxSum:*diff_api.CombinerOutputNV( GL_COMBINER0_NV+i, GL_RGB, to->rgb[i].abOutput, to->rgb[i].cdOutput, to->rgb[i].sumOutput, to->rgb[i].scale, to->rgb[i].bias, to->rgb[i].abDotProduct, to->rgb[i].cdDotProduct, to->rgb[i].muxSum ); +:regCombinerOutput[i]:alpha[i]|abOutput,cdOutput,sumOutput,scale,bias,abDotProduct,cdDotProduct,muxSum:*diff_api.CombinerOutputNV( GL_COMBINER0_NV+i, GL_ALPHA, to->alpha[i].abOutput, to->alpha[i].cdOutput, to->alpha[i].sumOutput, to->alpha[i].scale, to->alpha[i].bias, to->alpha[i].abDotProduct, to->alpha[i].cdDotProduct, to->alpha[i].muxSum ); +%flush +>} +:regCombinerFinalInput:a,aMapping,aPortion:*diff_api.FinalCombinerInputNV( GL_VARIABLE_A_NV, to->a, to->aMapping, to->aPortion ); +:regCombinerFinalInput:b,bMapping,bPortion:*diff_api.FinalCombinerInputNV( GL_VARIABLE_B_NV, to->b, to->bMapping, to->bPortion ); +:regCombinerFinalInput:c,cMapping,cPortion:*diff_api.FinalCombinerInputNV( GL_VARIABLE_C_NV, to->c, to->cMapping, to->cPortion ); +:regCombinerFinalInput:d,dMapping,dPortion:*diff_api.FinalCombinerInputNV( GL_VARIABLE_D_NV, to->d, to->dMapping, to->dPortion ); +:regCombinerFinalInput:e,eMapping,ePortion:*diff_api.FinalCombinerInputNV( GL_VARIABLE_E_NV, to->e, to->eMapping, to->ePortion ); +:regCombinerFinalInput:f,fMapping,fPortion:*diff_api.FinalCombinerInputNV( GL_VARIABLE_F_NV, to->f, to->fMapping, to->fPortion ); +:regCombinerFinalInput:g,gMapping,gPortion:*diff_api.FinalCombinerInputNV( GL_VARIABLE_G_NV, to->g, to->gMapping, to->gPortion ); +%flush +%target=to +%current=from +%bit=b diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_select_special b/src/VBox/GuestHost/OpenGL/state_tracker/state_select_special new file mode 100644 index 00000000..e7b41e36 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_select_special @@ -0,0 +1,61 @@ +Vertex4f +Begin +End +Vertex2d +Vertex2dv +Vertex2f +Vertex2fv +Vertex2i +Vertex2iv +Vertex2s +Vertex2sv +Vertex3d +Vertex3dv +Vertex3f +Vertex3fv +Vertex3i +Vertex3iv +Vertex3s +Vertex3sv +Vertex4d +Vertex4dv +Vertex4fv +Vertex4i +Vertex4iv +Vertex4s +Vertex4sv +Rectf +Recti +Rectd +Rects +Rectiv +Rectfv +Rectdv +Rectsv +DrawPixels +CopyPixels +Bitmap +RasterPos2d +RasterPos2dv +RasterPos2f +RasterPos2fv +RasterPos2i +RasterPos2iv +RasterPos2s +RasterPos2sv +RasterPos3d +RasterPos3dv +RasterPos3f +RasterPos3fv +RasterPos3i +RasterPos3iv +RasterPos3s +RasterPos3sv +RasterPos4d +RasterPos4dv +RasterPos4f +RasterPos4fv +RasterPos4i +RasterPos4iv +RasterPos4s +RasterPos4sv diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c new file mode 100644 index 00000000..ee17cd37 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_snapshot.c @@ -0,0 +1,2678 @@ +/* $Id: state_snapshot.c $ */ +/** @file + * VBox Context state saving/loading used by VM snapshot + */ + +/* + * Copyright (C) 2008-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include "state.h" +#include "state_internals.h" +#include "state/cr_statetypes.h" +#include "state/cr_texture.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_pixeldata.h" +#include + +#include +#include +#include +#include +#include + +/** @todo + * We have two ways of saving/loading states. + * + * First which is being used atm, just pure saving/loading of structures. + * The drawback is we have to deal with all the pointers around those structures, + * we'd have to update this code if we'd change state tracking. + * On the bright side it's fast, though it's not really needed as it's not that often operation. + * It could also worth to split those functions into appropriate parts, + * similar to the way context creation is being done. + * + * Second way would be to implement full dispatch api table and substitute diff_api during saving/loading. + * Then if we implement that api in a similar way to packer/unpacker with a change to store/load + * via provided pSSM handle instead of pack buffer, + * saving state could be done by simple diffing against empty "dummy" context. + * Restoring state in such case would look like unpacking commands from pSSM instead of network buffer. + * This would be slower (who cares) but most likely will not require any code changes to support in future. + * We will reduce amount of saved data as we'd save only changed state parts, but I doubt it'd be that much. + * It could be done for the first way as well, but requires tons of bit checks. + */ + +static int32_t crStateAllocAndSSMR3GetMem(PSSMHANDLE pSSM, void **pBuffer, size_t cbBuffer) +{ + CRASSERT(pSSM && pBuffer && cbBuffer>0); + + *pBuffer = crAlloc((unsigned int /* this case is just so stupid */)cbBuffer); + if (!*pBuffer) + return VERR_NO_MEMORY; + + return SSMR3GetMem(pSSM, *pBuffer, cbBuffer); +} + +#define SHCROGL_GET_STRUCT_PART(_pPtr, _type, _from, _to) do { \ + rc = SSMR3GetMem(pSSM, &(_pPtr)->_from, RT_UOFFSETOF(_type, _to) - RT_UOFFSETOF(_type, _from)); \ + AssertRCReturn(rc, rc); \ + } while (0) + +#define SHCROGL_GET_STRUCT_TAIL(_pPtr, _type, _from) do { \ + rc = SSMR3GetMem(pSSM, &(_pPtr)->_from, sizeof (_type) - RT_UOFFSETOF(_type, _from)); \ + AssertRCReturn(rc, rc); \ + } while (0) + +#define SHCROGL_GET_STRUCT_HEAD(_pPtr, _type, _to) do { \ + rc = SSMR3GetMem(pSSM, (_pPtr), RT_UOFFSETOF(_type, _to)); \ + AssertRCReturn(rc, rc); \ + } while (0) + +#define SHCROGL_CUT_FIELD_ALIGNMENT_SIZE(_type, _prevField, _field) (RT_UOFFSETOF(_type, _field) - RT_UOFFSETOF(_type, _prevField) - RT_SIZEOFMEMB(_type, _prevField)) +#define SHCROGL_CUT_FIELD_ALIGNMENT(_type, _prevField, _field) do { \ + const int32_t cbAlignment = SHCROGL_CUT_FIELD_ALIGNMENT_SIZE(_type, _prevField, _field) ; \ + /*AssertCompile(SHCROGL_CUT_FIELD_ALIGNMENT_SIZE(_type, _prevField, _field) >= 0 && SHCROGL_CUT_FIELD_ALIGNMENT_SIZE(_type, _prevField, _field) < sizeof (void*));*/ \ + if (cbAlignment) { \ + rc = SSMR3Skip(pSSM, cbAlignment); \ + } \ + } while (0) + +#define SHCROGL_ROUNDBOUND(_v, _b) (((_v) + ((_b) - 1)) & ~((_b) - 1)) +#define SHCROGL_ALIGNTAILSIZE(_v, _b) (SHCROGL_ROUNDBOUND((_v),(_b)) - (_v)) +#define SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT_SIZE(_type, _field, _oldFieldType, _nextFieldAllignment) (SHCROGL_ALIGNTAILSIZE(((RT_UOFFSETOF(_type, _field) + sizeof (_oldFieldType))), (_nextFieldAllignment))) +#define SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(_type, _field, _oldFieldType, _nextFieldAllignment) do { \ + const int32_t cbAlignment = SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT_SIZE(_type, _field, _oldFieldType, _nextFieldAllignment); \ + /*AssertCompile(SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) >= 0 && SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) < sizeof (void*));*/ \ + if (cbAlignment) { \ + rc = SSMR3Skip(pSSM, cbAlignment); \ + } \ + } while (0) + + +#define SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) (sizeof (_type) - RT_UOFFSETOF(_type, _lastField) - RT_SIZEOFMEMB(_type, _lastField)) +#define SHCROGL_CUT_TAIL_ALIGNMENT(_type, _lastField) do { \ + const int32_t cbAlignment = SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField); \ + /*AssertCompile(SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) >= 0 && SHCROGL_CUT_TAIL_ALIGNMENT_SIZE(_type, _lastField) < sizeof (void*));*/ \ + if (cbAlignment) { \ + rc = SSMR3Skip(pSSM, cbAlignment); \ + } \ + } while (0) + +static int32_t crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(CRTextureObj *pTexture, PSSMHANDLE pSSM) +{ + int32_t rc; + uint32_t cbObj = RT_UOFFSETOF(CRTextureObj, ctxUsage); + cbObj = ((cbObj + sizeof (void*) - 1) & ~(sizeof (void*) - 1)); + rc = SSMR3GetMem(pSSM, pTexture, cbObj); + AssertRCReturn(rc, rc); + /* just make all bits are used so that we fall back to the pre-ctxUsage behavior, + * i.e. all shared resources will be destructed on last shared context termination */ + FILLDIRTY(pTexture->ctxUsage); + return rc; +} + +static int32_t crStateLoadTextureUnit_v_BEFORE_CTXUSAGE_BITS(CRTextureUnit *t, PSSMHANDLE pSSM) +{ + int32_t rc; + SHCROGL_GET_STRUCT_HEAD(t, CRTextureUnit, Saved1D); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->Saved1D, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureUnit, Saved1D, Saved2D); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->Saved2D, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureUnit, Saved2D, Saved3D); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->Saved3D, pSSM); + AssertRCReturn(rc, rc); +#ifdef CR_ARB_texture_cube_map + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureUnit, Saved3D, SavedCubeMap); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->SavedCubeMap, pSSM); + AssertRCReturn(rc, rc); +# define SHCROGL_INTERNAL_LAST_FIELD SavedCubeMap +#else +# define SHCROGL_INTERNAL_LAST_FIELD Saved3D +#endif +#ifdef CR_NV_texture_rectangle + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureUnit, SHCROGL_INTERNAL_LAST_FIELD, SavedRect); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->SavedRect, pSSM); + AssertRCReturn(rc, rc); +# undef SHCROGL_INTERNAL_LAST_FIELD +# define SHCROGL_INTERNAL_LAST_FIELD SavedRect +#endif + SHCROGL_CUT_TAIL_ALIGNMENT(CRTextureUnit, SHCROGL_INTERNAL_LAST_FIELD); +#undef SHCROGL_INTERNAL_LAST_FIELD + return rc; +} + +static int crStateLoadStencilPoint_v_37(CRPointState *pPoint, PSSMHANDLE pSSM) +{ + int rc = VINF_SUCCESS; + SHCROGL_GET_STRUCT_HEAD(pPoint, CRPointState, spriteCoordOrigin); + pPoint->spriteCoordOrigin = (GLfloat)GL_UPPER_LEFT; + return rc; +} + +static int32_t crStateLoadStencilState_v_33(CRStencilState *s, PSSMHANDLE pSSM) +{ + CRStencilState_v_33 stencilV33; + int32_t rc = SSMR3GetMem(pSSM, &stencilV33, sizeof (stencilV33)); + AssertRCReturn(rc, rc); + s->stencilTest = stencilV33.stencilTest; + s->stencilTwoSideEXT = GL_FALSE; + s->activeStencilFace = GL_FRONT; + s->clearValue = stencilV33.clearValue; + s->writeMask = stencilV33.writeMask; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func = stencilV33.func; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask = stencilV33.mask; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref = stencilV33.ref; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail = stencilV33.fail; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail = stencilV33.passDepthFail; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass = stencilV33.passDepthPass; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK] = s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT]; + crStateStencilBufferInit(&s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK]); + return VINF_SUCCESS; +} + +static int32_t crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(CRTextureState *t, PSSMHANDLE pSSM) +{ + GLint i; + int32_t rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->base1D, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, base1D, base2D); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->base2D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->base3D, pSSM); + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, base2D, base3D); + AssertRCReturn(rc, rc); +#ifdef CR_ARB_texture_cube_map + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, base3D, baseCubeMap); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->baseCubeMap, pSSM); + AssertRCReturn(rc, rc); +# define SHCROGL_INTERNAL_LAST_FIELD baseCubeMap +#else +# define SHCROGL_INTERNAL_LAST_FIELD base3D +#endif +#ifdef CR_NV_texture_rectangle + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, SHCROGL_INTERNAL_LAST_FIELD, baseRect); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->baseRect, pSSM); + AssertRCReturn(rc, rc); +# undef SHCROGL_INTERNAL_LAST_FIELD +# define SHCROGL_INTERNAL_LAST_FIELD baseRect +#endif + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, SHCROGL_INTERNAL_LAST_FIELD, proxy1D); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->proxy1D, pSSM); + AssertRCReturn(rc, rc); +#undef SHCROGL_INTERNAL_LAST_FIELD + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, proxy1D, proxy2D); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->proxy2D, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, proxy2D, proxy3D); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->proxy3D, pSSM); + AssertRCReturn(rc, rc); +#ifdef CR_ARB_texture_cube_map + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, proxy3D, proxyCubeMap); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->proxyCubeMap, pSSM); + AssertRCReturn(rc, rc); +# define SHCROGL_INTERNAL_LAST_FIELD proxyCubeMap +#else +# define SHCROGL_INTERNAL_LAST_FIELD proxy3D +#endif +#ifdef CR_NV_texture_rectangle + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, SHCROGL_INTERNAL_LAST_FIELD, proxyRect); + rc = crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(&t->proxyRect, pSSM); + AssertRCReturn(rc, rc); +# undef SHCROGL_INTERNAL_LAST_FIELD +# define SHCROGL_INTERNAL_LAST_FIELD proxyRect +#endif + SHCROGL_CUT_FIELD_ALIGNMENT(CRTextureState, SHCROGL_INTERNAL_LAST_FIELD, curTextureUnit); +# undef SHCROGL_INTERNAL_LAST_FIELD + SHCROGL_GET_STRUCT_PART(t, CRTextureState, curTextureUnit, unit); + + for (i = 0; i < CR_MAX_TEXTURE_UNITS; ++i) + { + rc = crStateLoadTextureUnit_v_BEFORE_CTXUSAGE_BITS(&t->unit[i], pSSM); + AssertRCReturn(rc, rc); + } + + SHCROGL_CUT_TAIL_ALIGNMENT(CRTextureState, unit); + + return VINF_SUCCESS; +} + +static int32_t crStateStencilBufferStack_v_33(CRStencilBufferStack *s, PSSMHANDLE pSSM) +{ + CRStencilBufferStack_v_33 stackV33; + int32_t rc = SSMR3GetMem(pSSM, &stackV33, sizeof(stackV33)); + AssertLogRelReturn(rc, rc); + + s->stencilTest = stackV33.stencilTest; + s->stencilTwoSideEXT = GL_FALSE; + s->activeStencilFace = GL_FRONT; + s->clearValue = stackV33.clearValue; + s->writeMask = stackV33.writeMask; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func = stackV33.func; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask = stackV33.mask; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref = stackV33.ref; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail = stackV33.fail; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail = stackV33.passDepthFail; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass = stackV33.passDepthPass; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK] = s->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT]; + + s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func = GL_ALWAYS; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask = 0xFFFFFFFF; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref = 0; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail = GL_KEEP; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail = GL_KEEP; + s->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass = GL_KEEP; + + return VINF_SUCCESS; +} + +static int32_t crStateLoadAttribState_v_33(CRAttribState *t, PSSMHANDLE pSSM) +{ + int32_t i, rc; + SHCROGL_GET_STRUCT_HEAD(t, CRAttribState, stencilBufferStack); + for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i) + { + rc = crStateStencilBufferStack_v_33(&t->stencilBufferStack[i], pSSM); + AssertRCReturn(rc, rc); + } + SHCROGL_GET_STRUCT_TAIL(t, CRAttribState, textureStackDepth); + return rc; +} + +static int32_t crStateLoadTextureStack_v_BEFORE_CTXUSAGE_BITS(CRTextureStack *t, PSSMHANDLE pSSM) +{ + int32_t i, rc; + SHCROGL_GET_STRUCT_HEAD(t, CRTextureStack, unit); + for (i = 0; i < CR_MAX_TEXTURE_UNITS; ++i) + { + rc = crStateLoadTextureUnit_v_BEFORE_CTXUSAGE_BITS(&t->unit[i], pSSM); + AssertRCReturn(rc, rc); + } + SHCROGL_CUT_TAIL_ALIGNMENT(CRTextureStack, unit); + return rc; +} + +static int32_t crStateLoadAttribState_v_BEFORE_CTXUSAGE_BITS(CRAttribState *t, PSSMHANDLE pSSM) +{ + int32_t i, rc; + + SHCROGL_GET_STRUCT_HEAD(t, CRAttribState, stencilBufferStack); + for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i) + { + rc = crStateStencilBufferStack_v_33(&t->stencilBufferStack[i], pSSM); + AssertRCReturn(rc, rc); + } + SHCROGL_GET_STRUCT_PART(t, CRAttribState, textureStackDepth, textureStack); + for (i = 0; i < CR_MAX_ATTRIB_STACK_DEPTH; ++i) + { + rc = crStateLoadTextureStack_v_BEFORE_CTXUSAGE_BITS(&t->textureStack[i], pSSM); + AssertRCReturn(rc, rc); + } + SHCROGL_GET_STRUCT_TAIL(t, CRAttribState, transformStackDepth); + return rc; +} + + +static int32_t crStateLoadTextureObj(CRTextureObj *pTexture, PSSMHANDLE pSSM, uint32_t u32Version) +{ + int32_t rc; + if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS) + return crStateLoadTextureObj_v_BEFORE_CTXUSAGE_BITS(pTexture, pSSM); + rc = SSMR3GetMem(pSSM, pTexture, sizeof (*pTexture)); + AssertRCReturn(rc, rc); + return rc; +} + +static int32_t crStateLoadBufferObject(CRBufferObject *pBufferObj, PSSMHANDLE pSSM, uint32_t u32Version) +{ + int32_t rc; + if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS) + { + uint32_t cbObj = RT_UOFFSETOF(CRBufferObject, ctxUsage); + cbObj = ((cbObj + sizeof (void*) - 1) & ~(sizeof (void*) - 1)); + rc = SSMR3GetMem(pSSM, pBufferObj, cbObj); + AssertRCReturn(rc, rc); + /* just make all bits are used so that we fall back to the pre-ctxUsage behavior, + * i.e. all shared resources will be destructed on last shared context termination */ + FILLDIRTY(pBufferObj->ctxUsage); + } + else + { + rc = SSMR3GetMem(pSSM, pBufferObj, sizeof(*pBufferObj)); + AssertRCReturn(rc, rc); + } + return rc; +} + +static int32_t crStateLoadFramebufferObject(CRFramebufferObject *pFBO, PSSMHANDLE pSSM, uint32_t u32Version) +{ + int32_t rc; + if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS) + { + uint32_t cbObj = RT_UOFFSETOF(CRFramebufferObject, ctxUsage); + cbObj = ((cbObj + sizeof (void*) - 1) & ~(sizeof (void*) - 1)); + rc = SSMR3GetMem(pSSM, pFBO, cbObj); + AssertRCReturn(rc, rc); + /* just make all bits are used so that we fall back to the pre-ctxUsage behavior, + * i.e. all shared resources will be destructed on last shared context termination */ + FILLDIRTY(pFBO->ctxUsage); + } + else + { + rc = SSMR3GetMem(pSSM, pFBO, sizeof(*pFBO)); + AssertRCReturn(rc, rc); + } + return rc; +} + +static int32_t crStateLoadRenderbufferObject(CRRenderbufferObject *pRBO, PSSMHANDLE pSSM, uint32_t u32Version) +{ + int32_t rc; + if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS) + { + uint32_t cbObj = RT_UOFFSETOF(CRRenderbufferObject, ctxUsage); + cbObj = ((cbObj + sizeof (void*) - 1) & ~(sizeof (void*) - 1)); + rc = SSMR3GetMem(pSSM, pRBO, cbObj); + AssertRCReturn(rc, rc); + /* just make all bits are used so that we fall back to the pre-ctxUsage behavior, + * i.e. all shared resources will be destructed on last shared context termination */ + FILLDIRTY(pRBO->ctxUsage); + } + else + { + rc = SSMR3GetMem(pSSM, pRBO, sizeof(*pRBO)); + AssertRCReturn(rc, rc); + } + return rc; +} + +static int32_t crStateSaveTextureObjData(CRTextureObj *pTexture, PSSMHANDLE pSSM) +{ + int32_t rc, face, i; + GLint bound = 0; + + CRASSERT(pTexture && pSSM); + + crDebug("crStateSaveTextureObjData %u. START", pTexture->id); + + for (face = 0; face < 6; face++) { + CRASSERT(pTexture->level[face]); + + for (i = 0; i < CR_MAX_MIPMAP_LEVELS; i++) { + CRTextureLevel *ptl = &(pTexture->level[face][i]); + rc = SSMR3PutMem(pSSM, ptl, sizeof(*ptl)); + AssertRCReturn(rc, rc); + if (ptl->img) + { + CRASSERT(ptl->bytes); + rc = SSMR3PutMem(pSSM, ptl->img, ptl->bytes); + AssertRCReturn(rc, rc); + } +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + /* Note, this is not a bug. + * Even with CR_STATE_NO_TEXTURE_IMAGE_STORE defined, it's possible that ptl->img!=NULL. + * For ex. we're saving snapshot right after it was loaded + * and some context hasn't been used by the guest application yet + * (pContext->shared->bTexResyncNeeded==GL_TRUE). + */ + else if (ptl->bytes) + { + char *pImg; + GLenum target; + + if (!bound) + { + GLenum getEnum; + diff_api.BindTexture(pTexture->target, pTexture->hwid); + bound = 1; + + /* osx nvidia drivers seem to have a bug that 1x1 TEXTURE_2D texture becmes inaccessible for some reason + * saw that for 1x1 dummy textures generated by wine + * to avoid crashes we skip texture data save if that is the case */ + switch (pTexture->target) + { + case GL_TEXTURE_1D: + getEnum = GL_TEXTURE_BINDING_1D; + break; + case GL_TEXTURE_2D: + getEnum = GL_TEXTURE_BINDING_2D; + break; + case GL_TEXTURE_3D: + getEnum = GL_TEXTURE_BINDING_3D; + break; + case GL_TEXTURE_RECTANGLE_ARB: + getEnum = GL_TEXTURE_BINDING_RECTANGLE_ARB; + break; + case GL_TEXTURE_CUBE_MAP_ARB: + getEnum = GL_TEXTURE_BINDING_CUBE_MAP_ARB; + break; + default: + crWarning("unknown texture target: 0x%x", pTexture->target); + getEnum = 0; + break; + } + + if (getEnum) + { + GLint curTex; + diff_api.GetIntegerv(getEnum, &curTex); + if ((GLuint)curTex != pTexture->hwid) + { + crWarning("texture not bound properly: expected %d, but was %d. Texture state data: target(0x%x), id(%d), w(%d), h(%d)", + pTexture->hwid, curTex, + pTexture->target, + pTexture->id, + ptl->width, + ptl->height); + bound = -1; + } + } + + } + + if (pTexture->target!=GL_TEXTURE_CUBE_MAP_ARB) + { + target = pTexture->target; + } + else + { + target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face; + } + +#ifdef DEBUG + pImg = crAlloc(ptl->bytes+4); +#else + pImg = crAlloc(ptl->bytes); +#endif + if (!pImg) return VERR_NO_MEMORY; + +#ifdef DEBUG + *(int*)((char*)pImg+ptl->bytes) = 0xDEADDEAD; +#endif + if (bound > 0) + { +#ifdef DEBUG + { + GLint w,h=0; + crDebug("get image: compressed %i, face %i, level %i, width %i, height %i, bytes %i", + ptl->compressed, face, i, ptl->width, ptl->height, ptl->bytes); + diff_api.GetTexLevelParameteriv(target, i, GL_TEXTURE_WIDTH, &w); + diff_api.GetTexLevelParameteriv(target, i, GL_TEXTURE_HEIGHT, &h); + if (w!=ptl->width || h!=ptl->height) + { + crWarning("!!!tex size mismatch %i, %i!!!", w, h); + } + } +#endif + + /** @todo ugly workaround for crashes inside ati driver, + * they overwrite their own allocated memory in cases where texlevel >=4 + and width or height <=2. + */ + if (i<4 || (ptl->width>2 && ptl->height>2)) + { + if (!ptl->compressed) + { + diff_api.GetTexImage(target, i, ptl->format, ptl->type, pImg); + } + else + { + diff_api.GetCompressedTexImageARB(target, i, pImg); + } + } + } + else + { + crMemset(pImg, 0, ptl->bytes); + } + +#ifdef DEBUG + if (*(int*)((char*)pImg+ptl->bytes) != 0xDEADDEAD) + { + crWarning("Texture is bigger than expected!!!"); + } +#endif + + rc = SSMR3PutMem(pSSM, pImg, ptl->bytes); + crFree(pImg); + AssertRCReturn(rc, rc); + } +#endif + } + } + + crDebug("crStateSaveTextureObjData %u. END", pTexture->id); + + return VINF_SUCCESS; +} + +static int32_t crStateLoadTextureObjData(CRTextureObj *pTexture, PSSMHANDLE pSSM) +{ + int32_t rc, face, i; + + CRASSERT(pTexture && pSSM); + + for (face = 0; face < 6; face++) { + CRASSERT(pTexture->level[face]); + + for (i = 0; i < CR_MAX_MIPMAP_LEVELS; i++) { + CRTextureLevel *ptl = &(pTexture->level[face][i]); + CRASSERT(!ptl->img); + + rc = SSMR3GetMem(pSSM, ptl, sizeof(*ptl)); + AssertRCReturn(rc, rc); + if (ptl->img) + { + CRASSERT(ptl->bytes); + + ptl->img = crAlloc(ptl->bytes); + if (!ptl->img) return VERR_NO_MEMORY; + + rc = SSMR3GetMem(pSSM, ptl->img, ptl->bytes); + AssertRCReturn(rc, rc); + } +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + /* Same story as in crStateSaveTextureObjData */ + else if (ptl->bytes) + { + ptl->img = crAlloc(ptl->bytes); + if (!ptl->img) return VERR_NO_MEMORY; + + rc = SSMR3GetMem(pSSM, ptl->img, ptl->bytes); + AssertRCReturn(rc, rc); + } +#endif + crStateTextureInitTextureFormat(ptl, ptl->internalFormat); + } + } + + return VINF_SUCCESS; +} + +static void crStateSaveSharedTextureCB(unsigned long key, void *data1, void *data2) +{ + CRTextureObj *pTexture = (CRTextureObj *) data1; + PSSMHANDLE pSSM = (PSSMHANDLE) data2; + int32_t rc; + + CRASSERT(pTexture && pSSM); + + rc = SSMR3PutMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); + rc = SSMR3PutMem(pSSM, pTexture, sizeof(*pTexture)); + CRASSERT(rc == VINF_SUCCESS); + rc = crStateSaveTextureObjData(pTexture, pSSM); + CRASSERT(rc == VINF_SUCCESS); +} + +static int32_t crStateSaveMatrixStack(CRMatrixStack *pStack, PSSMHANDLE pSSM) +{ + return SSMR3PutMem(pSSM, pStack->stack, sizeof(CRmatrix) * pStack->maxDepth); +} + +static int32_t crStateLoadMatrixStack(CRMatrixStack *pStack, PSSMHANDLE pSSM) +{ + int32_t rc; + + CRASSERT(pStack && pSSM); + + rc = SSMR3GetMem(pSSM, pStack->stack, sizeof(CRmatrix) * pStack->maxDepth); + /* fixup stack top pointer */ + pStack->top = &pStack->stack[pStack->depth]; + return rc; +} + +static int32_t crStateSaveTextureObjPtr(CRTextureObj *pTexture, PSSMHANDLE pSSM) +{ + /* Current texture pointer can't be NULL for real texture unit states, + * but it could be NULL for unused attribute stack depths. + */ + if (pTexture) + return SSMR3PutU32(pSSM, pTexture->id); + else + return VINF_SUCCESS; +} + +static int32_t crStateLoadTextureObjPtr(CRTextureObj **pTexture, CRContext *pContext, GLenum target, PSSMHANDLE pSSM) +{ + uint32_t texName; + int32_t rc; + + /* We're loading attrib stack with unused state */ + if (!*pTexture) + return VINF_SUCCESS; + + rc = SSMR3GetU32(pSSM, &texName); + AssertRCReturn(rc, rc); + + if (texName) + { + *pTexture = (CRTextureObj *) crHashtableSearch(pContext->shared->textureTable, texName); + } + else + { + switch (target) + { + case GL_TEXTURE_1D: + *pTexture = &(pContext->texture.base1D); + break; + case GL_TEXTURE_2D: + *pTexture = &(pContext->texture.base2D); + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_3D: + *pTexture = &(pContext->texture.base3D); + break; +#endif +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_ARB: + *pTexture = &(pContext->texture.baseCubeMap); + break; +#endif +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + *pTexture = &(pContext->texture.baseRect); + break; +#endif + default: + crError("LoadTextureObjPtr: Unknown texture target %d", target); + } + } + + return rc; +} + +static int32_t crStateSaveTexUnitCurrentTexturePtrs(CRTextureUnit *pTexUnit, PSSMHANDLE pSSM) +{ + int32_t rc; + + rc = crStateSaveTextureObjPtr(pTexUnit->currentTexture1D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjPtr(pTexUnit->currentTexture2D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjPtr(pTexUnit->currentTexture3D, pSSM); + AssertRCReturn(rc, rc); +#ifdef CR_ARB_texture_cube_map + rc = crStateSaveTextureObjPtr(pTexUnit->currentTextureCubeMap, pSSM); + AssertRCReturn(rc, rc); +#endif +#ifdef CR_NV_texture_rectangle + rc = crStateSaveTextureObjPtr(pTexUnit->currentTextureRect, pSSM); + AssertRCReturn(rc, rc); +#endif + + return rc; +} + +static int32_t crStateLoadTexUnitCurrentTexturePtrs(CRTextureUnit *pTexUnit, CRContext *pContext, PSSMHANDLE pSSM) +{ + int32_t rc; + + rc = crStateLoadTextureObjPtr(&pTexUnit->currentTexture1D, pContext, GL_TEXTURE_1D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjPtr(&pTexUnit->currentTexture2D, pContext, GL_TEXTURE_1D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjPtr(&pTexUnit->currentTexture3D, pContext, GL_TEXTURE_2D, pSSM); + AssertRCReturn(rc, rc); +#ifdef CR_ARB_texture_cube_map + rc = crStateLoadTextureObjPtr(&pTexUnit->currentTextureCubeMap, pContext, GL_TEXTURE_CUBE_MAP_ARB, pSSM); + AssertRCReturn(rc, rc); +#endif +#ifdef CR_NV_texture_rectangle + rc = crStateLoadTextureObjPtr(&pTexUnit->currentTextureRect, pContext, GL_TEXTURE_RECTANGLE_NV, pSSM); + AssertRCReturn(rc, rc); +#endif + + return rc; +} + +static int32_t crSateSaveEvalCoeffs1D(CREvaluator1D *pEval, PSSMHANDLE pSSM) +{ + int32_t rc, i; + + for (i=0; idata) + { + /*We could get here even though retainBufferData is false on host side, in case when we're taking snapshot + after state load and before this context was ever made current*/ + CRASSERT(pBufferObj->size>0); + rc = SSMR3PutMem(pSSM, pBufferObj->data, pBufferObj->size); + CRASSERT(rc == VINF_SUCCESS); + } + else if (pBufferObj->id!=0 && pBufferObj->size>0) + { + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pBufferObj->hwid); + pBufferObj->pointer = diff_api.MapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB); + rc = SSMR3PutMem(pSSM, &pBufferObj->pointer, sizeof(pBufferObj->pointer)); + CRASSERT(rc == VINF_SUCCESS); + if (pBufferObj->pointer) + { + rc = SSMR3PutMem(pSSM, pBufferObj->pointer, pBufferObj->size); + CRASSERT(rc == VINF_SUCCESS); + } + diff_api.UnmapBufferARB(GL_ARRAY_BUFFER_ARB); + pBufferObj->pointer = NULL; + } +} + +static void crStateSaveProgramCB(unsigned long key, void *data1, void *data2) +{ + CRProgram *pProgram = (CRProgram *) data1; + PSSMHANDLE pSSM = (PSSMHANDLE) data2; + CRProgramSymbol *pSymbol; + int32_t rc; + + CRASSERT(pProgram && pSSM); + + rc = SSMR3PutMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); + rc = SSMR3PutMem(pSSM, pProgram, sizeof(*pProgram)); + CRASSERT(rc == VINF_SUCCESS); + if (pProgram->string) + { + CRASSERT(pProgram->length); + rc = SSMR3PutMem(pSSM, pProgram->string, pProgram->length); + CRASSERT(rc == VINF_SUCCESS); + } + + for (pSymbol = pProgram->symbolTable; pSymbol; pSymbol=pSymbol->next) + { + rc = SSMR3PutMem(pSSM, pSymbol, sizeof(*pSymbol)); + CRASSERT(rc == VINF_SUCCESS); + if (pSymbol->name) + { + CRASSERT(pSymbol->cbName>0); + rc = SSMR3PutMem(pSSM, pSymbol->name, pSymbol->cbName); + CRASSERT(rc == VINF_SUCCESS); + } + } +} + +static void crStateSaveFramebuffersCB(unsigned long key, void *data1, void *data2) +{ + CRFramebufferObject *pFBO = (CRFramebufferObject*) data1; + PSSMHANDLE pSSM = (PSSMHANDLE) data2; + int32_t rc; + + rc = SSMR3PutMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); + + rc = SSMR3PutMem(pSSM, pFBO, sizeof(*pFBO)); + CRASSERT(rc == VINF_SUCCESS); +} + +static void crStateSaveRenderbuffersCB(unsigned long key, void *data1, void *data2) +{ + CRRenderbufferObject *pRBO = (CRRenderbufferObject*) data1; + PSSMHANDLE pSSM = (PSSMHANDLE) data2; + int32_t rc; + + rc = SSMR3PutMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); + + rc = SSMR3PutMem(pSSM, pRBO, sizeof(*pRBO)); + CRASSERT(rc == VINF_SUCCESS); +} + +static int32_t crStateLoadProgram(CRProgram **ppProgram, PSSMHANDLE pSSM) +{ + CRProgramSymbol **ppSymbol; + int32_t rc; + unsigned long key; + + rc = SSMR3GetMem(pSSM, &key, sizeof(key)); + AssertRCReturn(rc, rc); + + /* we're loading default vertex or pixel program*/ + if (*ppProgram) + { + if (key!=0) return VERR_SSM_UNEXPECTED_DATA; + } + else + { + *ppProgram = (CRProgram*) crAlloc(sizeof(CRProgram)); + if (!ppProgram) return VERR_NO_MEMORY; + if (key==0) return VERR_SSM_UNEXPECTED_DATA; + } + + rc = SSMR3GetMem(pSSM, *ppProgram, sizeof(**ppProgram)); + AssertRCReturn(rc, rc); + + if ((*ppProgram)->string) + { + CRASSERT((*ppProgram)->length); + (*ppProgram)->string = crAlloc((*ppProgram)->length); + if (!(*ppProgram)->string) return VERR_NO_MEMORY; + rc = SSMR3GetMem(pSSM, (void*) (*ppProgram)->string, (*ppProgram)->length); + AssertRCReturn(rc, rc); + } + + for (ppSymbol = &(*ppProgram)->symbolTable; *ppSymbol; ppSymbol=&(*ppSymbol)->next) + { + *ppSymbol = crAlloc(sizeof(CRProgramSymbol)); + if (!ppSymbol) return VERR_NO_MEMORY; + + rc = SSMR3GetMem(pSSM, *ppSymbol, sizeof(**ppSymbol)); + AssertRCReturn(rc, rc); + + if ((*ppSymbol)->name) + { + CRASSERT((*ppSymbol)->cbName>0); + (*ppSymbol)->name = crAlloc((*ppSymbol)->cbName); + if (!(*ppSymbol)->name) return VERR_NO_MEMORY; + + rc = SSMR3GetMem(pSSM, (void*) (*ppSymbol)->name, (*ppSymbol)->cbName); + AssertRCReturn(rc, rc); + } + } + + return VINF_SUCCESS; +} + +static void crStateSaveString(const char *pStr, PSSMHANDLE pSSM) +{ + int32_t len; + int32_t rc; + + if (pStr) + { + len = crStrlen(pStr)+1; + + rc = SSMR3PutS32(pSSM, len); + CRASSERT(rc == VINF_SUCCESS); + + rc = SSMR3PutMem(pSSM, pStr, len*sizeof(*pStr)); + CRASSERT(rc == VINF_SUCCESS); + } + else + { + rc = SSMR3PutS32(pSSM, 0); + CRASSERT(rc == VINF_SUCCESS); + } +} + +static char* crStateLoadString(PSSMHANDLE pSSM) +{ + int32_t len, rc; + char* pStr = NULL; + + rc = SSMR3GetS32(pSSM, &len); + CRASSERT(rc == VINF_SUCCESS); + + if (len!=0) + { + pStr = crAlloc(len*sizeof(*pStr)); + + rc = SSMR3GetMem(pSSM, pStr, len*sizeof(*pStr)); + CRASSERT(rc == VINF_SUCCESS); + } + + return pStr; +} + +static void crStateSaveGLSLShaderCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLShader *pShader = (CRGLSLShader*) data1; + PSSMHANDLE pSSM = (PSSMHANDLE) data2; + int32_t rc; + + rc = SSMR3PutMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); + + rc = SSMR3PutMem(pSSM, pShader, sizeof(*pShader)); + CRASSERT(rc == VINF_SUCCESS); + + if (pShader->source) + { + crStateSaveString(pShader->source, pSSM); + } + else + { + GLint sLen=0; + GLchar *source=NULL; + + diff_api.GetShaderiv(pShader->hwid, GL_SHADER_SOURCE_LENGTH, &sLen); + if (sLen>0) + { + source = (GLchar*) crAlloc(sLen); + diff_api.GetShaderSource(pShader->hwid, sLen, NULL, source); + } + + crStateSaveString(source, pSSM); + if (source) crFree(source); + } +} + +static CRGLSLShader* crStateLoadGLSLShader(PSSMHANDLE pSSM) +{ + CRGLSLShader *pShader; + int32_t rc; + unsigned long key; + + pShader = crAlloc(sizeof(*pShader)); + if (!pShader) return NULL; + + rc = SSMR3GetMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); + + rc = SSMR3GetMem(pSSM, pShader, sizeof(*pShader)); + CRASSERT(rc == VINF_SUCCESS); + + pShader->source = crStateLoadString(pSSM); + + return pShader; +} + + +static void crStateSaveGLSLShaderKeyCB(unsigned long key, void *data1, void *data2) +{ + //CRGLSLShader *pShader = (CRGLSLShader*) data1; + PSSMHANDLE pSSM = (PSSMHANDLE) data2; + int32_t rc; + + rc = SSMR3PutMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); +} + +static void crStateSaveGLSLProgramAttribs(CRGLSLProgramState *pState, PSSMHANDLE pSSM) +{ + GLuint i; + int32_t rc; + + for (i=0; icAttribs; ++i) + { + rc = SSMR3PutMem(pSSM, &pState->pAttribs[i].index, sizeof(pState->pAttribs[i].index)); + CRASSERT(rc == VINF_SUCCESS); + crStateSaveString(pState->pAttribs[i].name, pSSM); + } +} + +static void crStateSaveGLSLProgramCB(unsigned long key, void *data1, void *data2) +{ + CRGLSLProgram *pProgram = (CRGLSLProgram*) data1; + PSSMHANDLE pSSM = (PSSMHANDLE) data2; + int32_t rc; + uint32_t ui32; + GLint maxUniformLen, activeUniforms=0, uniformsCount=0, i, j; + GLchar *name = NULL; + GLenum type; + GLint size, location; + + rc = SSMR3PutMem(pSSM, &key, sizeof(key)); + CRASSERT(rc == VINF_SUCCESS); + + rc = SSMR3PutMem(pSSM, pProgram, sizeof(*pProgram)); + CRASSERT(rc == VINF_SUCCESS); + + ui32 = crHashtableNumElements(pProgram->currentState.attachedShaders); + rc = SSMR3PutU32(pSSM, ui32); + CRASSERT(rc == VINF_SUCCESS); + + crHashtableWalk(pProgram->currentState.attachedShaders, crStateSaveGLSLShaderKeyCB, pSSM); + + if (pProgram->activeState.attachedShaders) + { + ui32 = crHashtableNumElements(pProgram->activeState.attachedShaders); + rc = SSMR3PutU32(pSSM, ui32); + CRASSERT(rc == VINF_SUCCESS); + crHashtableWalk(pProgram->currentState.attachedShaders, crStateSaveGLSLShaderCB, pSSM); + } + + crStateSaveGLSLProgramAttribs(&pProgram->currentState, pSSM); + crStateSaveGLSLProgramAttribs(&pProgram->activeState, pSSM); + + diff_api.GetProgramiv(pProgram->hwid, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformLen); + diff_api.GetProgramiv(pProgram->hwid, GL_ACTIVE_UNIFORMS, &activeUniforms); + + if (!maxUniformLen) + { + if (activeUniforms) + { + crWarning("activeUniforms (%d), while maxUniformLen is zero", activeUniforms); + activeUniforms = 0; + } + } + + if (activeUniforms>0) + { + name = (GLchar *) crAlloc((maxUniformLen+8)*sizeof(GLchar)); + + if (!name) + { + crWarning("crStateSaveGLSLProgramCB: out of memory"); + return; + } + } + + for (i=0; ihwid, i, maxUniformLen, NULL, &size, &type, name); + uniformsCount += size; + } + CRASSERT(uniformsCount>=activeUniforms); + + rc = SSMR3PutS32(pSSM, uniformsCount); + CRASSERT(rc == VINF_SUCCESS); + + if (activeUniforms>0) + { + GLfloat fdata[16]; + GLint idata[16]; + char *pIndexStr=NULL; + + for (i=0; ihwid, i, maxUniformLen, NULL, &size, &type, name); + + if (size>1) + { + pIndexStr = crStrchr(name, '['); + if (!pIndexStr) + { + pIndexStr = name+crStrlen(name); + } + } + + for (j=0; j1) + { + sprintf(pIndexStr, "[%i]", j); + } + location = diff_api.GetUniformLocation(pProgram->hwid, name); + + rc = SSMR3PutMem(pSSM, &type, sizeof(type)); + CRASSERT(rc == VINF_SUCCESS); + + crStateSaveString(name, pSSM); + + if (crStateIsIntUniform(type)) + { + diff_api.GetUniformiv(pProgram->hwid, location, &idata[0]); + rc = SSMR3PutMem(pSSM, &idata[0], crStateGetUniformSize(type)*sizeof(idata[0])); + CRASSERT(rc == VINF_SUCCESS); + } + else + { + diff_api.GetUniformfv(pProgram->hwid, location, &fdata[0]); + rc = SSMR3PutMem(pSSM, &fdata[0], crStateGetUniformSize(type)*sizeof(fdata[0])); + CRASSERT(rc == VINF_SUCCESS); + } + } + } + + crFree(name); + } +} + +static int32_t crStateSaveClientPointer(CRVertexArrays *pArrays, int32_t index, PSSMHANDLE pSSM) +{ + int32_t rc; + CRClientPointer *cp; + + cp = crStateGetClientPointerByIndex(index, pArrays); + + if (cp->buffer) + rc = SSMR3PutU32(pSSM, cp->buffer->id); + else + rc = SSMR3PutU32(pSSM, 0); + + AssertRCReturn(rc, rc); + +#ifdef CR_EXT_compiled_vertex_array + if (cp->locked) + { + CRASSERT(cp->p); + rc = SSMR3PutMem(pSSM, cp->p, cp->stride*(pArrays->lockFirst+pArrays->lockCount)); + AssertRCReturn(rc, rc); + } +#endif + + return VINF_SUCCESS; +} + +static int32_t crStateLoadClientPointer(CRVertexArrays *pArrays, int32_t index, CRContext *pContext, PSSMHANDLE pSSM) +{ + int32_t rc; + uint32_t ui; + CRClientPointer *cp; + + cp = crStateGetClientPointerByIndex(index, pArrays); + + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + cp->buffer = ui==0 ? pContext->bufferobject.nullBuffer : crHashtableSearch(pContext->shared->buffersTable, ui); + + if (!cp->buffer) + { + crWarning("crStateLoadClientPointer: ui=%d loaded as NULL buffer!", ui); + } + +#ifdef CR_EXT_compiled_vertex_array + if (cp->locked) + { + rc = crStateAllocAndSSMR3GetMem(pSSM, (void**)&cp->p, cp->stride*(pArrays->lockFirst+pArrays->lockCount)); + AssertRCReturn(rc, rc); + } +#endif + + return VINF_SUCCESS; +} + +static int32_t crStateSaveCurrentBits(CRStateBits *pBits, PSSMHANDLE pSSM) +{ + int32_t rc, i; + + rc = SSMR3PutMem(pSSM, pBits, sizeof(*pBits)); + AssertRCReturn(rc, rc); + + rc = SSMR3PutMem(pSSM, pBits->client.v, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + rc = SSMR3PutMem(pSSM, pBits->client.n, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + rc = SSMR3PutMem(pSSM, pBits->client.c, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + rc = SSMR3PutMem(pSSM, pBits->client.s, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + rc = SSMR3PutMem(pSSM, pBits->client.i, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + for (i=0; iclient.t[i], GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + } + rc = SSMR3PutMem(pSSM, pBits->client.e, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + rc = SSMR3PutMem(pSSM, pBits->client.f, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); +#ifdef CR_NV_vertex_program + for (i=0; iclient.a[i], GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + } +#endif + + rc = SSMR3PutMem(pSSM, pBits->lighting.light, CR_MAX_LIGHTS*sizeof(pBits->lighting.light)); + AssertRCReturn(rc, rc); + + return VINF_SUCCESS; +} + +static int32_t crStateLoadCurrentBits(CRStateBits *pBits, PSSMHANDLE pSSM) +{ + int32_t rc, i; + CRClientBits client; + CRLightingBits lighting; + + CRASSERT(pBits); + + client.v = pBits->client.v; + client.n = pBits->client.n; + client.c = pBits->client.c; + client.s = pBits->client.s; + client.i = pBits->client.i; + client.e = pBits->client.e; + client.f = pBits->client.f; + for (i=0; iclient.t[i]; + } +#ifdef CR_NV_vertex_program + for (i=0; iclient.a[i]; + } +#endif + lighting.light = pBits->lighting.light; + + rc = SSMR3GetMem(pSSM, pBits, sizeof(*pBits)); + AssertRCReturn(rc, rc); + + pBits->client.v = client.v; + rc = SSMR3GetMem(pSSM, pBits->client.v, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + pBits->client.n = client.n; + rc = SSMR3GetMem(pSSM, pBits->client.n, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + pBits->client.c = client.c; + rc = SSMR3GetMem(pSSM, pBits->client.c, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + pBits->client.s = client.s; + rc = SSMR3GetMem(pSSM, pBits->client.s, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + pBits->client.i = client.i; + rc = SSMR3GetMem(pSSM, pBits->client.i, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + pBits->client.e = client.e; + rc = SSMR3GetMem(pSSM, pBits->client.e, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + pBits->client.f = client.f; + rc = SSMR3GetMem(pSSM, pBits->client.f, GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + for (i=0; iclient.t[i] = client.t[i]; + rc = SSMR3GetMem(pSSM, pBits->client.t[i], GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + } +#ifdef CR_NV_vertex_program + for (i=0; iclient.a[i] = client.a[i]; + rc = SSMR3GetMem(pSSM, pBits->client.a[i], GLCLIENT_BIT_ALLOC*sizeof(CRbitvalue)); + AssertRCReturn(rc, rc); + } +#endif + + pBits->lighting.light = lighting.light; + rc = SSMR3GetMem(pSSM, pBits->lighting.light, CR_MAX_LIGHTS*sizeof(pBits->lighting.light)); + AssertRCReturn(rc, rc); + + return VINF_SUCCESS; +} + +static void crStateSaveKeysCB(unsigned long firstKey, unsigned long count, void *data) +{ + PSSMHANDLE pSSM = (PSSMHANDLE)data; + int rc; + CRASSERT(firstKey); + CRASSERT(count); + rc = SSMR3PutU32(pSSM, firstKey); + CRASSERT(RT_SUCCESS(rc)); + rc = SSMR3PutU32(pSSM, count); + CRASSERT(RT_SUCCESS(rc)); +} + +static int32_t crStateSaveKeys(CRHashTable *pHash, PSSMHANDLE pSSM) +{ + crHashtableWalkKeys(pHash, crStateSaveKeysCB , pSSM); + /* use null terminator */ + SSMR3PutU32(pSSM, 0); + return VINF_SUCCESS; +} + +static int32_t crStateLoadKeys(CRHashTable *pHash, PSSMHANDLE pSSM, uint32_t u32Version) +{ + uint32_t u32Key, u32Count, i; + int rc; + for(;;) + { + rc = SSMR3GetU32(pSSM, &u32Key); + AssertRCReturn(rc, rc); + + if (!u32Key) + return rc; + + rc = SSMR3GetU32(pSSM, &u32Count); + AssertRCReturn(rc, rc); + + CRASSERT(u32Count); + + if (u32Version > SHCROGL_SSM_VERSION_WITH_BUGGY_KEYS) + { + for (i = u32Key; i < u32Count + u32Key; ++i) + { + GLboolean fIsNew = crHashtableAllocRegisterKey(pHash, i); NOREF(fIsNew); +#if 0 //def DEBUG_misha + CRASSERT(fIsNew); +#endif + } + } + } + /* not reached*/ +} + + +int32_t crStateSaveContext(CRContext *pContext, PSSMHANDLE pSSM) +{ + int32_t rc, i; + uint32_t ui32, j; + GLboolean bSaveShared = GL_TRUE; + + CRASSERT(pContext && pSSM); + + CRASSERT(pContext->client.attribStackDepth == 0); + + /* this stuff is not used anymore, zero it up for sanity */ + pContext->buffer.storedWidth = 0; + pContext->buffer.storedHeight = 0; + + CRASSERT(VBoxTlsRefIsFunctional(pContext)); + + /* make sure the gl error state is captured by our state mechanism to store the correct gl error value */ + crStateSyncHWErrorState(pContext); + + rc = SSMR3PutMem(pSSM, pContext, sizeof (*pContext)); + AssertRCReturn(rc, rc); + + if (crHashtableNumElements(pContext->shared->dlistTable)>0) + crWarning("Saving state with %d display lists, unsupported", crHashtableNumElements(pContext->shared->dlistTable)); + + if (crHashtableNumElements(pContext->program.programHash)>0) + crDebug("Saving state with %d programs", crHashtableNumElements(pContext->program.programHash)); + + rc = SSMR3PutS32(pSSM, pContext->shared->id); + AssertRCReturn(rc, rc); + + rc = SSMR3PutS32(pSSM, crStateContextIsShared(pContext)); + AssertRCReturn(rc, rc); + + if (pContext->shared->refCount>1) + { + bSaveShared = pContext->shared->saveCount==0; + + ++pContext->shared->saveCount; + if (pContext->shared->saveCount == pContext->shared->refCount) + { + pContext->shared->saveCount=0; + } + } + + /* Save transform state */ + rc = SSMR3PutMem(pSSM, pContext->transform.clipPlane, sizeof(GLvectord)*CR_MAX_CLIP_PLANES); + AssertRCReturn(rc, rc); + rc = SSMR3PutMem(pSSM, pContext->transform.clip, sizeof(GLboolean)*CR_MAX_CLIP_PLANES); + AssertRCReturn(rc, rc); + rc = crStateSaveMatrixStack(&pContext->transform.modelViewStack, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveMatrixStack(&pContext->transform.projectionStack, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveMatrixStack(&pContext->transform.colorStack, pSSM); + AssertRCReturn(rc, rc); + for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) + { + rc = crStateSaveMatrixStack(&pContext->transform.textureStack[i], pSSM); + AssertRCReturn(rc, rc); + } + for (i = 0 ; i < CR_MAX_PROGRAM_MATRICES ; i++) + { + rc = crStateSaveMatrixStack(&pContext->transform.programStack[i], pSSM); + AssertRCReturn(rc, rc); + } + + /* Save textures */ + rc = crStateSaveTextureObjData(&pContext->texture.base1D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjData(&pContext->texture.base2D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjData(&pContext->texture.base3D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjData(&pContext->texture.proxy1D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjData(&pContext->texture.proxy2D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjData(&pContext->texture.proxy3D, pSSM); +#ifdef CR_ARB_texture_cube_map + rc = crStateSaveTextureObjData(&pContext->texture.baseCubeMap, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjData(&pContext->texture.proxyCubeMap, pSSM); + AssertRCReturn(rc, rc); +#endif +#ifdef CR_NV_texture_rectangle + rc = crStateSaveTextureObjData(&pContext->texture.baseRect, pSSM); + AssertRCReturn(rc, rc); + rc = crStateSaveTextureObjData(&pContext->texture.proxyRect, pSSM); + AssertRCReturn(rc, rc); +#endif + + /* Save shared textures */ + if (bSaveShared) + { + CRASSERT(pContext->shared && pContext->shared->textureTable); + rc = crStateSaveKeys(pContext->shared->textureTable, pSSM); + AssertRCReturn(rc, rc); + ui32 = crHashtableNumElements(pContext->shared->textureTable); + rc = SSMR3PutU32(pSSM, ui32); + AssertRCReturn(rc, rc); + crHashtableWalk(pContext->shared->textureTable, crStateSaveSharedTextureCB, pSSM); + +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + /* Restore previous texture bindings via diff_api */ + if (ui32) + { + CRTextureUnit *pTexUnit; + + pTexUnit = &pContext->texture.unit[pContext->texture.curTextureUnit]; + + diff_api.BindTexture(GL_TEXTURE_1D, pTexUnit->currentTexture1D->hwid); + diff_api.BindTexture(GL_TEXTURE_2D, pTexUnit->currentTexture2D->hwid); + diff_api.BindTexture(GL_TEXTURE_3D, pTexUnit->currentTexture3D->hwid); +#ifdef CR_ARB_texture_cube_map + diff_api.BindTexture(GL_TEXTURE_CUBE_MAP_ARB, pTexUnit->currentTextureCubeMap->hwid); +#endif +#ifdef CR_NV_texture_rectangle + diff_api.BindTexture(GL_TEXTURE_RECTANGLE_NV, pTexUnit->currentTextureRect->hwid); +#endif + } +#endif + } + + /* Save current texture pointers */ + for (i=0; itexture.unit[i], pSSM); + AssertRCReturn(rc, rc); + } + + /* Save lights */ + CRASSERT(pContext->lighting.light); + rc = SSMR3PutMem(pSSM, pContext->lighting.light, CR_MAX_LIGHTS * sizeof(*pContext->lighting.light)); + AssertRCReturn(rc, rc); + + /* Save attrib stack*/ + /** @todo could go up to used stack depth here?*/ + for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++) + { + if (pContext->attrib.enableStack[i].clip) + { + rc = SSMR3PutMem(pSSM, pContext->attrib.enableStack[i].clip, + pContext->limits.maxClipPlanes*sizeof(GLboolean)); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.enableStack[i].light) + { + rc = SSMR3PutMem(pSSM, pContext->attrib.enableStack[i].light, + pContext->limits.maxLights*sizeof(GLboolean)); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.lightingStack[i].light) + { + rc = SSMR3PutMem(pSSM, pContext->attrib.lightingStack[i].light, + pContext->limits.maxLights*sizeof(CRLight)); + AssertRCReturn(rc, rc); + } + + for (j=0; jlimits.maxTextureUnits; ++j) + { + rc = crStateSaveTexUnitCurrentTexturePtrs(&pContext->attrib.textureStack[i].unit[j], pSSM); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.transformStack[i].clip) + { + rc = SSMR3PutMem(pSSM, pContext->attrib.transformStack[i].clip, + pContext->limits.maxClipPlanes*sizeof(GLboolean)); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.transformStack[i].clipPlane) + { + rc = SSMR3PutMem(pSSM, pContext->attrib.transformStack[i].clipPlane, + pContext->limits.maxClipPlanes*sizeof(GLvectord)); + AssertRCReturn(rc, rc); + } + + rc = crSateSaveEvalCoeffs1D(pContext->attrib.evalStack[i].eval1D, pSSM); + AssertRCReturn(rc, rc); + rc = crSateSaveEvalCoeffs2D(pContext->attrib.evalStack[i].eval2D, pSSM); + AssertRCReturn(rc, rc); + } + + /* Save evaluator coeffs */ + rc = crSateSaveEvalCoeffs1D(pContext->eval.eval1D, pSSM); + AssertRCReturn(rc, rc); + rc = crSateSaveEvalCoeffs2D(pContext->eval.eval2D, pSSM); + AssertRCReturn(rc, rc); + +#ifdef CR_ARB_vertex_buffer_object + /* Save buffer objects */ + if (bSaveShared) + { + rc = crStateSaveKeys(pContext->shared->buffersTable, pSSM); + AssertRCReturn(rc, rc); + } + ui32 = bSaveShared? crHashtableNumElements(pContext->shared->buffersTable):0; + rc = SSMR3PutU32(pSSM, ui32); + AssertRCReturn(rc, rc); + + /* Save default one*/ + crStateSaveBufferObjectCB(0, pContext->bufferobject.nullBuffer, pSSM); + + if (bSaveShared) + { + /* Save all the rest */ + crHashtableWalk(pContext->shared->buffersTable, crStateSaveBufferObjectCB, pSSM); + } + + /* Restore binding */ + diff_api.BindBufferARB(GL_ARRAY_BUFFER_ARB, pContext->bufferobject.arrayBuffer->hwid); + + /* Save pointers */ + rc = SSMR3PutU32(pSSM, pContext->bufferobject.arrayBuffer->id); + AssertRCReturn(rc, rc); + rc = SSMR3PutU32(pSSM, pContext->bufferobject.elementsBuffer->id); + AssertRCReturn(rc, rc); +#ifdef CR_ARB_pixel_buffer_object + rc = SSMR3PutU32(pSSM, pContext->bufferobject.packBuffer->id); + AssertRCReturn(rc, rc); + rc = SSMR3PutU32(pSSM, pContext->bufferobject.unpackBuffer->id); + AssertRCReturn(rc, rc); +#endif + /* Save clint pointers and buffer bindings*/ + for (i=0; iclient.array, i, pSSM); + AssertRCReturn(rc, rc); + } + + crDebug("client.vertexArrayStackDepth %i", pContext->client.vertexArrayStackDepth); + for (i=0; iclient.vertexArrayStackDepth; ++i) + { + CRVertexArrays *pArray = &pContext->client.vertexArrayStack[i]; + for (j=0; jprogram.programHash); + rc = SSMR3PutU32(pSSM, ui32); + AssertRCReturn(rc, rc); + /* Save defaults programs */ + crStateSaveProgramCB(0, pContext->program.defaultVertexProgram, pSSM); + crStateSaveProgramCB(0, pContext->program.defaultFragmentProgram, pSSM); + /* Save all the rest */ + crHashtableWalk(pContext->program.programHash, crStateSaveProgramCB, pSSM); + /* Save Pointers */ + rc = SSMR3PutU32(pSSM, pContext->program.currentVertexProgram->id); + AssertRCReturn(rc, rc); + rc = SSMR3PutU32(pSSM, pContext->program.currentFragmentProgram->id); + AssertRCReturn(rc, rc); + /* This one is unused it seems*/ + CRASSERT(!pContext->program.errorString); + +#ifdef CR_EXT_framebuffer_object + /* Save FBOs */ + if (bSaveShared) + { + rc = crStateSaveKeys(pContext->shared->fbTable, pSSM); + AssertRCReturn(rc, rc); + ui32 = crHashtableNumElements(pContext->shared->fbTable); + rc = SSMR3PutU32(pSSM, ui32); + AssertRCReturn(rc, rc); + crHashtableWalk(pContext->shared->fbTable, crStateSaveFramebuffersCB, pSSM); + + rc = crStateSaveKeys(pContext->shared->rbTable, pSSM); + AssertRCReturn(rc, rc); + ui32 = crHashtableNumElements(pContext->shared->rbTable); + rc = SSMR3PutU32(pSSM, ui32); + AssertRCReturn(rc, rc); + crHashtableWalk(pContext->shared->rbTable, crStateSaveRenderbuffersCB, pSSM); + } + rc = SSMR3PutU32(pSSM, pContext->framebufferobject.drawFB?pContext->framebufferobject.drawFB->id:0); + AssertRCReturn(rc, rc); + rc = SSMR3PutU32(pSSM, pContext->framebufferobject.readFB?pContext->framebufferobject.readFB->id:0); + AssertRCReturn(rc, rc); + rc = SSMR3PutU32(pSSM, pContext->framebufferobject.renderbuffer?pContext->framebufferobject.renderbuffer->id:0); + AssertRCReturn(rc, rc); +#endif + +#ifdef CR_OPENGL_VERSION_2_0 + /* Save GLSL related info */ + ui32 = crHashtableNumElements(pContext->glsl.shaders); + rc = SSMR3PutU32(pSSM, ui32); + AssertRCReturn(rc, rc); + crHashtableWalk(pContext->glsl.shaders, crStateSaveGLSLShaderCB, pSSM); + ui32 = crHashtableNumElements(pContext->glsl.programs); + rc = SSMR3PutU32(pSSM, ui32); + AssertRCReturn(rc, rc); + crHashtableWalk(pContext->glsl.programs, crStateSaveGLSLProgramCB, pSSM); + rc = SSMR3PutU32(pSSM, pContext->glsl.activeProgram?pContext->glsl.activeProgram->id:0); + AssertRCReturn(rc, rc); +#endif + + return VINF_SUCCESS; +} + +typedef struct _crFindSharedCtxParms { + PFNCRSTATE_CONTEXT_GET pfnCtxGet; + CRContext *pSrcCtx, *pDstCtx; +} crFindSharedCtxParms_t; + +static void crStateFindSharedCB(unsigned long key, void *data1, void *data2) +{ + crFindSharedCtxParms_t *pParms = (crFindSharedCtxParms_t *) data2; + CRContext *pContext = pParms->pfnCtxGet(data1); + (void) key; + + if (pContext!=pParms->pSrcCtx && pContext->shared->id==pParms->pSrcCtx->shared->id) + { + pParms->pDstCtx->shared = pContext->shared; + } +} + +int32_t crStateSaveGlobals(PSSMHANDLE pSSM) +{ + /* don't need that for now */ +#if 0 + CRStateBits *pBits; + int rc; + + CRASSERT(g_cContexts >= 1); + if (g_cContexts <= 1) + return VINF_SUCCESS; + + pBits = GetCurrentBits(); +#define CRSTATE_BITS_OP(_var, _size) \ + rc = SSMR3PutMem(pSSM, (pBits->_var), _size); \ + AssertRCReturn(rc, rc); +#include "state_bits_globalop.h" +#undef CRSTATE_BITS_OP +#endif + return VINF_SUCCESS; +} + +int32_t crStateLoadGlobals(PSSMHANDLE pSSM, uint32_t u32Version) +{ + CRStateBits *pBits; + int rc; + CRASSERT(g_cContexts >= 1); + if (g_cContexts <= 1) + return VINF_SUCCESS; + + pBits = GetCurrentBits(); + + if (u32Version >= SHCROGL_SSM_VERSION_WITH_STATE_BITS) + { +#define CRSTATE_BITS_OP(_var, _size) \ + rc = SSMR3GetMem(pSSM, (pBits->_var), _size); \ + AssertRCReturn(rc, rc); + + if (u32Version < SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL) + { +#define CRSTATE_BITS_OP_VERSION (SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL - 1) +#define CRSTATE_BITS_OP_STENCIL_FUNC_V_33(_i, _var) do {} while (0) +#define CRSTATE_BITS_OP_STENCIL_OP_V_33(_i, _var) do {} while (0) +#include "state_bits_globalop.h" +#undef CRSTATE_BITS_OP_VERSION +#undef CRSTATE_BITS_OP_STENCIL_FUNC_V_33 +#undef CRSTATE_BITS_OP_STENCIL_OP_V_33 + } + else if (u32Version < SHCROGL_SSM_VERSION_WITH_SPRITE_COORD_ORIGIN) + { +#define CRSTATE_BITS_OP_VERSION (SHCROGL_SSM_VERSION_WITH_SPRITE_COORD_ORIGIN - 1) +#include "state_bits_globalop.h" +#undef CRSTATE_BITS_OP_VERSION + } + else + { + /* we do not put dirty bits to state anymore, + * nop */ +//#include "state_bits_globalop.h" + } +#undef CRSTATE_BITS_OP + /* always dirty all bits */ + /* return VINF_SUCCESS; */ + } + +#define CRSTATE_BITS_OP(_var, _size) FILLDIRTY(pBits->_var); +#include "state_bits_globalop.h" +#undef CRSTATE_BITS_OP + return VINF_SUCCESS; +} + + +#define SLC_COPYPTR(ptr) pTmpContext->ptr = pContext->ptr +#define SLC_ASSSERT_NULL_PTR(ptr) CRASSERT(!pContext->ptr) + +AssertCompile(VBOXTLSREFDATA_SIZE() <= CR_MAX_BITARRAY); +AssertCompile(VBOXTLSREFDATA_STATE_INITIALIZED != 0); +AssertCompile(RTASSERT_OFFSET_OF(CRContext, shared) >= VBOXTLSREFDATA_ASSERT_OFFSET(CRContext) + + VBOXTLSREFDATA_SIZE() + + RT_SIZEOFMEMB(CRContext, bitid) + + RT_SIZEOFMEMB(CRContext, neg_bitid)); + +int32_t crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM, uint32_t u32Version) +{ + CRContext* pTmpContext; + int32_t rc, i, j; + uint32_t uiNumElems, ui, k; + unsigned long key; + GLboolean bLoadShared = GL_TRUE; + GLenum err; + + CRASSERT(pContext && pSSM); + + /* This one is rather big for stack allocation and causes macs to crash */ + pTmpContext = (CRContext*)crAlloc(sizeof(*pTmpContext)); + if (!pTmpContext) + return VERR_NO_MEMORY; + + CRASSERT(VBoxTlsRefIsFunctional(pContext)); + + if (u32Version <= SHCROGL_SSM_VERSION_WITH_INVALID_ERROR_STATE) + { + union { + CRbitvalue bitid[CR_MAX_BITARRAY]; + struct { + VBOXTLSREFDATA + } tlsRef; + } bitid; + + /* do not increment the saved state version due to VBOXTLSREFDATA addition to CRContext */ + rc = SSMR3GetMem(pSSM, pTmpContext, VBOXTLSREFDATA_OFFSET(CRContext)); + AssertRCReturn(rc, rc); + + /* VBox 4.1.8 had a bug that VBOXTLSREFDATA was also stored in the snapshot, + * thus the saved state data format was changed w/o changing the saved state version. + * here we determine whether the saved state contains VBOXTLSREFDATA, and if so, treat it accordingly */ + rc = SSMR3GetMem(pSSM, &bitid, sizeof (bitid)); + AssertRCReturn(rc, rc); + + /* the bitid array has one bit set only. this is why if bitid.tlsRef has both cTlsRefs + * and enmTlsRefState non-zero - this is definitely NOT a bit id and is a VBOXTLSREFDATA */ + if (bitid.tlsRef.enmTlsRefState == VBOXTLSREFDATA_STATE_INITIALIZED + && bitid.tlsRef.cTlsRefs) + { + /* VBOXTLSREFDATA is stored, skip it */ + crMemcpy(&pTmpContext->bitid, ((uint8_t*)&bitid) + VBOXTLSREFDATA_SIZE(), sizeof (bitid) - VBOXTLSREFDATA_SIZE()); + rc = SSMR3GetMem(pSSM, ((uint8_t*)&pTmpContext->bitid) + sizeof (pTmpContext->bitid) - VBOXTLSREFDATA_SIZE(), sizeof (pTmpContext->neg_bitid) + VBOXTLSREFDATA_SIZE()); + AssertRCReturn(rc, rc); + + ui = VBOXTLSREFDATA_OFFSET(CRContext) + VBOXTLSREFDATA_SIZE() + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid); + ui = RT_UOFFSETOF(CRContext, shared) - ui; + } + else + { + /* VBOXTLSREFDATA is NOT stored */ + crMemcpy(&pTmpContext->bitid, &bitid, sizeof (bitid)); + rc = SSMR3GetMem(pSSM, &pTmpContext->neg_bitid, sizeof (pTmpContext->neg_bitid)); + AssertRCReturn(rc, rc); + + /* the pre-VBOXTLSREFDATA CRContext structure might have additional allignment bits before the CRContext::shared */ + ui = VBOXTLSREFDATA_OFFSET(CRContext) + sizeof (pTmpContext->bitid) + sizeof (pTmpContext->neg_bitid); + + ui &= (sizeof (void*) - 1); + } + + if (ui) + { + void* pTmp = NULL; + rc = SSMR3GetMem(pSSM, &pTmp, ui); + AssertRCReturn(rc, rc); + } + + if (u32Version == SHCROGL_SSM_VERSION_BEFORE_CTXUSAGE_BITS) + { + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, shared, attrib); + rc = crStateLoadAttribState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->attrib, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer); + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, point); + rc = crStateLoadStencilPoint_v_37(&pTmpContext->point, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, polygon, stencil); + rc = crStateLoadStencilState_v_33(&pTmpContext->stencil, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*)); + rc = crStateLoadTextureState_v_BEFORE_CTXUSAGE_BITS(&pTmpContext->texture, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, texture, transform); + SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, transform); + } + else + { + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, shared, attrib); + rc = crStateLoadAttribState_v_33(&pTmpContext->attrib, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer); + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, point); + rc = crStateLoadStencilPoint_v_37(&pTmpContext->point, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, polygon, stencil); + rc = crStateLoadStencilState_v_33(&pTmpContext->stencil, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*)); + SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, texture); + } + + pTmpContext->error = GL_NO_ERROR; /* <- the error state contained some random error data here + * treat as no error */ + } + else if (u32Version < SHCROGL_SSM_VERSION_WITH_FIXED_STENCIL) + { + SHCROGL_GET_STRUCT_HEAD(pTmpContext, CRContext, attrib); + rc = crStateLoadAttribState_v_33(&pTmpContext->attrib, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FIELD_ALIGNMENT(CRContext, attrib, buffer); + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, buffer, point); + rc = crStateLoadStencilPoint_v_37(&pTmpContext->point, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_GET_STRUCT_PART(pTmpContext, CRContext, polygon, stencil); + rc = crStateLoadStencilState_v_33(&pTmpContext->stencil, pSSM); + AssertRCReturn(rc, rc); + SHCROGL_CUT_FOR_OLD_TYPE_TO_ENSURE_ALIGNMENT(CRContext, stencil, CRStencilState_v_33, sizeof (void*)); + SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, texture); + } + else if (u32Version < SHCROGL_SSM_VERSION_WITH_SPRITE_COORD_ORIGIN) + { + SHCROGL_GET_STRUCT_HEAD(pTmpContext, CRContext, point); + crStateLoadStencilPoint_v_37(&pTmpContext->point, pSSM); + SHCROGL_GET_STRUCT_TAIL(pTmpContext, CRContext, polygon); + } + else + { + rc = SSMR3GetMem(pSSM, pTmpContext, sizeof (*pTmpContext)); + AssertRCReturn(rc, rc); + } + + /* preserve the error to restore it at the end of context creation, + * it should not normally change, but just in case it it changed */ + err = pTmpContext->error; + + /* we will later do crMemcpy from entire pTmpContext to pContext, + * for simplicity store the VBOXTLSREFDATA from the pContext to pTmpContext */ + VBOXTLSREFDATA_COPY(pTmpContext, pContext); + + /* Deal with shared state */ + { + crFindSharedCtxParms_t parms; + int32_t shared; + + rc = SSMR3GetS32(pSSM, &pContext->shared->id); + AssertRCReturn(rc, rc); + + rc = SSMR3GetS32(pSSM, &shared); + AssertRCReturn(rc, rc); + + pTmpContext->shared = NULL; + parms.pfnCtxGet = pfnCtxGet; + parms.pSrcCtx = pContext; + parms.pDstCtx = pTmpContext; + crHashtableWalk(pCtxTable, crStateFindSharedCB, &parms); + + if (pTmpContext->shared) + { + CRASSERT(pContext->shared->refCount==1); + bLoadShared = GL_FALSE; + crStateFreeShared(pContext, pContext->shared); + pContext->shared = NULL; + pTmpContext->shared->refCount++; + } + else + { + SLC_COPYPTR(shared); + } + + if (bLoadShared && shared) + { + crStateSetSharedContext(pTmpContext); + } + } + + SLC_COPYPTR(flush_func); + SLC_COPYPTR(flush_arg); + + /* We're supposed to be loading into an empty context, so those pointers should be NULL */ + for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++) + { + SLC_ASSSERT_NULL_PTR(attrib.enableStack[i].clip); + SLC_ASSSERT_NULL_PTR(attrib.enableStack[i].light); + + SLC_ASSSERT_NULL_PTR(attrib.lightingStack[i].light); + SLC_ASSSERT_NULL_PTR(attrib.transformStack[i].clip); + SLC_ASSSERT_NULL_PTR(attrib.transformStack[i].clipPlane); + + for (j=0; jeval.eval1D, pContext->eval.eval1D); + crStateCopyEvalPtrs2D(pTmpContext->eval.eval2D, pContext->eval.eval2D); + + SLC_COPYPTR(feedback.buffer); /** @todo */ + SLC_COPYPTR(selection.buffer); /** @todo */ + + SLC_COPYPTR(lighting.light); + + /*This one could be tricky if we're loading snapshot on host with different GPU*/ + SLC_COPYPTR(limits.extensions); + +#if CR_ARB_occlusion_query + SLC_COPYPTR(occlusion.objects); /** @todo */ +#endif + + SLC_COPYPTR(program.errorString); + SLC_COPYPTR(program.programHash); + SLC_COPYPTR(program.defaultVertexProgram); + SLC_COPYPTR(program.defaultFragmentProgram); + + /* Texture pointers */ + for (i=0; i<6; ++i) + { + SLC_COPYPTR(texture.base1D.level[i]); + SLC_COPYPTR(texture.base2D.level[i]); + SLC_COPYPTR(texture.base3D.level[i]); + SLC_COPYPTR(texture.proxy1D.level[i]); + SLC_COPYPTR(texture.proxy2D.level[i]); + SLC_COPYPTR(texture.proxy3D.level[i]); +#ifdef CR_ARB_texture_cube_map + SLC_COPYPTR(texture.baseCubeMap.level[i]); + SLC_COPYPTR(texture.proxyCubeMap.level[i]); +#endif +#ifdef CR_NV_texture_rectangle + SLC_COPYPTR(texture.baseRect.level[i]); + SLC_COPYPTR(texture.proxyRect.level[i]); +#endif + } + + /* Load transform state */ + SLC_COPYPTR(transform.clipPlane); + SLC_COPYPTR(transform.clip); + /* Don't have to worry about pContext->transform.current as it'd be set in crStateSetCurrent call */ + /*SLC_COPYPTR(transform.currentStack);*/ + SLC_COPYPTR(transform.modelViewStack.stack); + SLC_COPYPTR(transform.projectionStack.stack); + SLC_COPYPTR(transform.colorStack.stack); + + for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) + { + SLC_COPYPTR(transform.textureStack[i].stack); + } + for (i = 0 ; i < CR_MAX_PROGRAM_MATRICES ; i++) + { + SLC_COPYPTR(transform.programStack[i].stack); + } + +#ifdef CR_OPENGL_VERSION_2_0 + SLC_COPYPTR(glsl.shaders); + SLC_COPYPTR(glsl.programs); +#endif + + /* Have to preserve original context id */ + CRASSERT(pTmpContext->id == pContext->id); + CRASSERT(VBOXTLSREFDATA_EQUAL(pContext, pTmpContext)); + /* Copy ordinary state to real context */ + crMemcpy(pContext, pTmpContext, sizeof(*pTmpContext)); + crFree(pTmpContext); + pTmpContext = NULL; + + /* Now deal with pointers */ + + /* Load transform state */ + rc = SSMR3GetMem(pSSM, pContext->transform.clipPlane, sizeof(GLvectord)*CR_MAX_CLIP_PLANES); + AssertRCReturn(rc, rc); + rc = SSMR3GetMem(pSSM, pContext->transform.clip, sizeof(GLboolean)*CR_MAX_CLIP_PLANES); + AssertRCReturn(rc, rc); + rc = crStateLoadMatrixStack(&pContext->transform.modelViewStack, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadMatrixStack(&pContext->transform.projectionStack, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadMatrixStack(&pContext->transform.colorStack, pSSM); + AssertRCReturn(rc, rc); + for (i = 0 ; i < CR_MAX_TEXTURE_UNITS ; i++) + { + rc = crStateLoadMatrixStack(&pContext->transform.textureStack[i], pSSM); + AssertRCReturn(rc, rc); + } + for (i = 0 ; i < CR_MAX_PROGRAM_MATRICES ; i++) + { + rc = crStateLoadMatrixStack(&pContext->transform.programStack[i], pSSM); + AssertRCReturn(rc, rc); + } + + /* Load Textures */ + rc = crStateLoadTextureObjData(&pContext->texture.base1D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjData(&pContext->texture.base2D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjData(&pContext->texture.base3D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjData(&pContext->texture.proxy1D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjData(&pContext->texture.proxy2D, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjData(&pContext->texture.proxy3D, pSSM); + AssertRCReturn(rc, rc); +#ifdef CR_ARB_texture_cube_map + rc = crStateLoadTextureObjData(&pContext->texture.baseCubeMap, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjData(&pContext->texture.proxyCubeMap, pSSM); + AssertRCReturn(rc, rc); +#endif +#ifdef CR_NV_texture_rectangle + rc = crStateLoadTextureObjData(&pContext->texture.baseRect, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadTextureObjData(&pContext->texture.proxyRect, pSSM); + AssertRCReturn(rc, rc); +#endif + + if (bLoadShared) + { + /* Load shared textures */ + CRASSERT(pContext->shared && pContext->shared->textureTable); + + if (u32Version >= SHCROGL_SSM_VERSION_WITH_ALLOCATED_KEYS) + { + rc = crStateLoadKeys(pContext->shared->buffersTable, pSSM, u32Version); + AssertRCReturn(rc, rc); + } + + rc = SSMR3GetU32(pSSM, &uiNumElems); + AssertRCReturn(rc, rc); + for (ui=0; uihwid = 0; + + /*allocate actual memory*/ + for (i=0; i<6; ++i) { + pTexture->level[i] = (CRTextureLevel *) crCalloc(sizeof(CRTextureLevel) * CR_MAX_MIPMAP_LEVELS); + if (!pTexture->level[i]) return VERR_NO_MEMORY; + } + + rc = crStateLoadTextureObjData(pTexture, pSSM); + AssertRCReturn(rc, rc); + + crHashtableAdd(pContext->shared->textureTable, key, pTexture); + } + } + + /* Load current texture pointers */ + for (i=0; itexture.unit[i], pContext, pSSM); + AssertRCReturn(rc, rc); + } + + /* Mark textures for resending to GPU */ + pContext->shared->bTexResyncNeeded = GL_TRUE; + + /* Load lights */ + CRASSERT(pContext->lighting.light); + rc = SSMR3GetMem(pSSM, pContext->lighting.light, CR_MAX_LIGHTS * sizeof(*pContext->lighting.light)); + AssertRCReturn(rc, rc); + + /* Load attrib stack*/ + for ( i = 0 ; i < CR_MAX_ATTRIB_STACK_DEPTH ; i++) + { + if (pContext->attrib.enableStack[i].clip) + { + rc = crStateAllocAndSSMR3GetMem(pSSM, (void**)&pContext->attrib.enableStack[i].clip, + pContext->limits.maxClipPlanes*sizeof(GLboolean)); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.enableStack[i].light) + { + rc = crStateAllocAndSSMR3GetMem(pSSM, (void**)&pContext->attrib.enableStack[i].light, + pContext->limits.maxLights*sizeof(GLboolean)); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.lightingStack[i].light) + { + rc = crStateAllocAndSSMR3GetMem(pSSM, (void**)&pContext->attrib.lightingStack[i].light, + pContext->limits.maxLights*sizeof(CRLight)); + AssertRCReturn(rc, rc); + } + + for (k=0; klimits.maxTextureUnits; ++k) + { + rc = crStateLoadTexUnitCurrentTexturePtrs(&pContext->attrib.textureStack[i].unit[k], pContext, pSSM); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.transformStack[i].clip) + { + rc = crStateAllocAndSSMR3GetMem(pSSM, (void*)&pContext->attrib.transformStack[i].clip, + pContext->limits.maxClipPlanes*sizeof(GLboolean)); + AssertRCReturn(rc, rc); + } + + if (pContext->attrib.transformStack[i].clipPlane) + { + rc = crStateAllocAndSSMR3GetMem(pSSM, (void**)&pContext->attrib.transformStack[i].clipPlane, + pContext->limits.maxClipPlanes*sizeof(GLvectord)); + AssertRCReturn(rc, rc); + } + rc = crSateLoadEvalCoeffs1D(pContext->attrib.evalStack[i].eval1D, GL_TRUE, pSSM); + AssertRCReturn(rc, rc); + rc = crSateLoadEvalCoeffs2D(pContext->attrib.evalStack[i].eval2D, GL_TRUE, pSSM); + AssertRCReturn(rc, rc); + } + + /* Load evaluator coeffs */ + rc = crSateLoadEvalCoeffs1D(pContext->eval.eval1D, GL_FALSE, pSSM); + AssertRCReturn(rc, rc); + rc = crSateLoadEvalCoeffs2D(pContext->eval.eval2D, GL_FALSE, pSSM); + AssertRCReturn(rc, rc); + + /* Load buffer objects */ +#ifdef CR_ARB_vertex_buffer_object + if (bLoadShared) + { + if (u32Version >= SHCROGL_SSM_VERSION_WITH_ALLOCATED_KEYS) + { + rc = crStateLoadKeys(pContext->shared->textureTable, pSSM, u32Version); + AssertRCReturn(rc, rc); + } + } + + rc = SSMR3GetU32(pSSM, &uiNumElems); + AssertRCReturn(rc, rc); + for (ui=0; ui<=uiNumElems; ++ui) /*ui<=uiNumElems to load nullBuffer in same loop*/ + { + CRBufferObject *pBufferObj; + + rc = SSMR3GetMem(pSSM, &key, sizeof(key)); + AssertRCReturn(rc, rc); + + /* default one should be already allocated */ + if (key==0) + { + pBufferObj = pContext->bufferobject.nullBuffer; + if (!pBufferObj) return VERR_SSM_UNEXPECTED_DATA; + } + else + { + pBufferObj = (CRBufferObject *) crCalloc(sizeof(*pBufferObj)); + if (!pBufferObj) return VERR_NO_MEMORY; + } + + rc = crStateLoadBufferObject(pBufferObj, pSSM, u32Version); + AssertRCReturn(rc, rc); + + pBufferObj->hwid = 0; + + if (pBufferObj->data) + { + CRASSERT(pBufferObj->size>0); + pBufferObj->data = crAlloc(pBufferObj->size); + rc = SSMR3GetMem(pSSM, pBufferObj->data, pBufferObj->size); + AssertRCReturn(rc, rc); + } + else if (pBufferObj->id!=0 && pBufferObj->size>0) + { + rc = SSMR3GetMem(pSSM, &pBufferObj->data, sizeof(pBufferObj->data)); + AssertRCReturn(rc, rc); + + if (pBufferObj->data) + { + pBufferObj->data = crAlloc(pBufferObj->size); + rc = SSMR3GetMem(pSSM, pBufferObj->data, pBufferObj->size); + AssertRCReturn(rc, rc); + } + } + + + if (key!=0) + crHashtableAdd(pContext->shared->buffersTable, key, pBufferObj); + } + /* Load pointers */ +#define CRS_GET_BO(name) (((name)==0) ? (pContext->bufferobject.nullBuffer) : crHashtableSearch(pContext->shared->buffersTable, name)) + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->bufferobject.arrayBuffer = CRS_GET_BO(ui); + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->bufferobject.elementsBuffer = CRS_GET_BO(ui); +#ifdef CR_ARB_pixel_buffer_object + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->bufferobject.packBuffer = CRS_GET_BO(ui); + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->bufferobject.unpackBuffer = CRS_GET_BO(ui); +#endif +#undef CRS_GET_BO + + /* Load client pointers and array buffer bindings*/ + for (i=0; iclient.array, i, pContext, pSSM); + AssertRCReturn(rc, rc); + } + for (j=0; jclient.vertexArrayStackDepth; ++j) + { + CRVertexArrays *pArray = &pContext->client.vertexArrayStack[j]; + for (i=0; ishared->bVBOResyncNeeded = GL_TRUE; +#endif + + /* Load pixel/vertex programs */ + rc = SSMR3GetU32(pSSM, &uiNumElems); + AssertRCReturn(rc, rc); + /* Load defaults programs */ + rc = crStateLoadProgram(&pContext->program.defaultVertexProgram, pSSM); + AssertRCReturn(rc, rc); + rc = crStateLoadProgram(&pContext->program.defaultFragmentProgram, pSSM); + AssertRCReturn(rc, rc); + /* Load all the rest */ + for (ui=0; uiprogram.programHash, pProgram->id, pProgram); + //DIRTY(pProgram->dirtyProgram, pContext->neg_bitid); + + } + /* Load Pointers */ + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->program.currentVertexProgram = ui==0 ? pContext->program.defaultVertexProgram + : crHashtableSearch(pContext->program.programHash, ui); + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->program.currentFragmentProgram = ui==0 ? pContext->program.defaultFragmentProgram + : crHashtableSearch(pContext->program.programHash, ui); + + /* Mark programs for resending to GPU */ + pContext->program.bResyncNeeded = GL_TRUE; + +#ifdef CR_EXT_framebuffer_object + /* Load FBOs */ + if (bLoadShared) + { + if (u32Version >= SHCROGL_SSM_VERSION_WITH_ALLOCATED_KEYS) + { + rc = crStateLoadKeys(pContext->shared->fbTable, pSSM, u32Version); + AssertRCReturn(rc, rc); + } + + rc = SSMR3GetU32(pSSM, &uiNumElems); + AssertRCReturn(rc, rc); + for (ui=0; uiid); + + crHashtableAdd(pContext->shared->fbTable, key, pFBO); + } + + if (u32Version >= SHCROGL_SSM_VERSION_WITH_ALLOCATED_KEYS) + { + rc = crStateLoadKeys(pContext->shared->rbTable, pSSM, u32Version); + AssertRCReturn(rc, rc); + } + + rc = SSMR3GetU32(pSSM, &uiNumElems); + AssertRCReturn(rc, rc); + for (ui=0; uishared->rbTable, key, pRBO); + } + } + + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->framebufferobject.drawFB = ui==0 ? NULL + : crHashtableSearch(pContext->shared->fbTable, ui); + + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->framebufferobject.readFB = ui==0 ? NULL + : crHashtableSearch(pContext->shared->fbTable, ui); + + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->framebufferobject.renderbuffer = ui==0 ? NULL + : crHashtableSearch(pContext->shared->rbTable, ui); + + /* Mark FBOs/RBOs for resending to GPU */ + pContext->shared->bFBOResyncNeeded = GL_TRUE; +#endif + +#ifdef CR_OPENGL_VERSION_2_0 + /* Load GLSL related info */ + rc = SSMR3GetU32(pSSM, &uiNumElems); + AssertRCReturn(rc, rc); + + for (ui=0; uiglsl.programs, pShader->id); + CRASSERT(fNewKeyCheck); + crHashtableAdd(pContext->glsl.shaders, pShader->id, pShader); + } + + rc = SSMR3GetU32(pSSM, &uiNumElems); + AssertRCReturn(rc, rc); + + for (ui=0; uiglsl.programs, key, pProgram); + + pProgram->currentState.attachedShaders = crAllocHashtable(); + + rc = SSMR3GetU32(pSSM, &numShaders); + AssertRCReturn(rc, rc); + + for (k=0; kcurrentState.attachedShaders, key, crHashtableSearch(pContext->glsl.shaders, key)); + } + + if (pProgram->activeState.attachedShaders) + { + pProgram->activeState.attachedShaders = crAllocHashtable(); + + rc = SSMR3GetU32(pSSM, &numShaders); + AssertRCReturn(rc, rc); + + for (k=0; kactiveState.attachedShaders, pShader->id, pShader); + } + } + + if (pProgram->currentState.cAttribs) + pProgram->currentState.pAttribs = (CRGLSLAttrib*) crAlloc(pProgram->currentState.cAttribs*sizeof(CRGLSLAttrib)); + for (k=0; kcurrentState.cAttribs; ++k) + { + rc = SSMR3GetMem(pSSM, &pProgram->currentState.pAttribs[k].index, sizeof(pProgram->currentState.pAttribs[k].index)); + AssertRCReturn(rc, rc); + pProgram->currentState.pAttribs[k].name = crStateLoadString(pSSM); + } + + if (pProgram->activeState.cAttribs) + pProgram->activeState.pAttribs = (CRGLSLAttrib*) crAlloc(pProgram->activeState.cAttribs*sizeof(CRGLSLAttrib)); + for (k=0; kactiveState.cAttribs; ++k) + { + rc = SSMR3GetMem(pSSM, &pProgram->activeState.pAttribs[k].index, sizeof(pProgram->activeState.pAttribs[k].index)); + AssertRCReturn(rc, rc); + pProgram->activeState.pAttribs[k].name = crStateLoadString(pSSM); + } + + { + int32_t cUniforms; + rc = SSMR3GetS32(pSSM, &cUniforms); + pProgram->cUniforms = cUniforms; + AssertRCReturn(rc, rc); + } + + if (pProgram->cUniforms) + { + pProgram->pUniforms = crAlloc(pProgram->cUniforms*sizeof(CRGLSLUniform)); + if (!pProgram->pUniforms) return VERR_NO_MEMORY; + + for (k=0; kcUniforms; ++k) + { + size_t itemsize, datasize; + + rc = SSMR3GetMem(pSSM, &pProgram->pUniforms[k].type, sizeof(GLenum)); + AssertRCReturn(rc, rc); + pProgram->pUniforms[k].name = crStateLoadString(pSSM); + + if (crStateIsIntUniform(pProgram->pUniforms[k].type)) + { + itemsize = sizeof(GLint); + } else itemsize = sizeof(GLfloat); + + datasize = crStateGetUniformSize(pProgram->pUniforms[k].type)*itemsize; + pProgram->pUniforms[k].data = crAlloc((unsigned int /* this case is just so stupid */)datasize); + if (!pProgram->pUniforms[k].data) return VERR_NO_MEMORY; + + rc = SSMR3GetMem(pSSM, pProgram->pUniforms[k].data, datasize); + AssertRCReturn(rc, rc); + } + } + } + + rc = SSMR3GetU32(pSSM, &ui); + AssertRCReturn(rc, rc); + pContext->glsl.activeProgram = ui==0 ? NULL + : crHashtableSearch(pContext->glsl.programs, ui); + + /*Mark for resending to GPU*/ + pContext->glsl.bResyncNeeded = GL_TRUE; +#endif + + if (pContext->error != err) + { + crWarning("context error state changed on context restore, was 0x%x, but became 0x%x, resetting to its original value", + err, pContext->error); + pContext->error = err; + } + + return VINF_SUCCESS; +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_special b/src/VBox/GuestHost/OpenGL/state_tracker/state_special new file mode 100644 index 00000000..46b6805a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_special @@ -0,0 +1,385 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +Begin +End +GetString +PixelStoref +PixelStorei +PixelTransferf +PixelTransferi +PixelZoom +PixelMapfv +PixelMapuiv +PixelMapusv +PopClientAttrib +PushClientAttrib +GetPixelMapfv +GetPixelMapuiv +GetPixelMapusv +AlphaFunc +DepthFunc +BlendFunc +BlendColorEXT +BlendEquationEXT +BlendFuncSeparateEXT +LogicOp +DrawBuffer +ReadBuffer +IndexMask +ColorMask +ClearColor +ClearIndex +ClearDepth +ClearAccum +DepthMask +Enable +Disable +Map1d +Map1f +Map2d +Map2f +MapGrid1d +MapGrid1f +MapGrid2d +MapGrid2f +GetMapdv +GetMapfv +GetMapiv +Fogi +Fogf +Fogiv +Fogfv +ShadeModel +ColorMaterial +LightModelf +LightModeli +LightModelfv +LightModeliv +Lightf +Lighti +Lightfv +Lightiv +GetLightfv +GetLightiv +Materialf +Materiali +Materialfv +Materialiv +GetMaterialfv +GetMaterialiv +ShadeModel +ColorMaterial +LightModelf +LightModeli +LightModelfv +LightModeliv +Lightf +Lighti +Lightfv +Lightiv +Materialf +Materiali +Materialfv +Materialiv +ClipPlane +GetClipPlane +MatrixMode +LoadIdentity +PopMatrix +PushMatrix +LoadMatrixf +LoadMatrixd +LoadTransposeMatrixfARB +LoadTransposeMatrixdARB +MultMatrixf +MultMatrixd +MultTransposeMatrixfARB +MultTransposeMatrixdARB +Translatef +Translated +Rotatef +Rotated +Scalef +Scaled +Frustum +Ortho +PointSize +LineWidth +LineStipple +CullFace +FrontFace +PolygonMode +PolygonOffset +PolygonStipple +GetPolygonStipple +GenTextures +DeleteTextures +BindTexture +TexImage1D +TexImage2D +TexImage3D +TexImage3DEXT +TexSubImage1D +TexSubImage2D +TexSubImage3D +TexParameterfv +TexParameteriv +TexParameterf +TexParameteri +TexEnvfv +TexEnviv +TexEnvf +TexEnvi +GetTexEnvfv +GetTexEnviv +TexGendv +TexGenfv +TexGeniv +TexGend +TexGenf +TexGeni +GetTexGendv +GetTexGenfv +GetTexGeniv +GetTexImage +GetTexLevelParameterfv +GetTexLevelParameteriv +GetTexParameterfv +GetTexParameteriv +PrioritizeTextures +AreTexturesResident +GetBooleanv +GetDoublev +GetFloatv +GetIntegerv +GetError +StencilFunc +StencilOp +StencilFuncSeparate +StencilOpSeparate +ActiveStencilFaceEXT +ClearStencil +StencilMask +Viewport +DepthRange +Scissor +IsEnabled +RasterPos2d +RasterPos2f +RasterPos2i +RasterPos2s +RasterPos3d +RasterPos3f +RasterPos3i +RasterPos3s +RasterPos4d +RasterPos4f +RasterPos4i +RasterPos4s +RasterPos2dv +RasterPos2fv +RasterPos2iv +RasterPos2sv +RasterPos3dv +RasterPos3fv +RasterPos3iv +RasterPos3sv +RasterPos4dv +RasterPos4fv +RasterPos4iv +RasterPos4sv +GenLists +NewList +EndList +DeleteLists +IsList +IsTexture +ListBase +EnableClientState +DisableClientState +VertexPointer +ColorPointer +SecondaryColorPointerEXT +IndexPointer +NormalPointer +TexCoordPointer +EdgeFlagPointer +InterleavedArrays +GetPointerv +PushAttrib +PopAttrib +Bitmap +ActiveTextureARB +ClientActiveTextureARB +CombinerParameterfvNV +CombinerParameterivNV +CombinerParameterfNV +CombinerParameteriNV +CombinerInputNV +CombinerOutputNV +FinalCombinerInputNV +GetCombinerInputParameterfvNV +GetCombinerInputParameterivNV +GetCombinerOutputParameterfvNV +GetCombinerOutputParameterivNV +GetFinalCombinerInputParameterfvNV +GetFinalCombinerInputParameterivNV +CombinerStageParameterfvNV +GetCombinerStageParameterfvNV +Color3f +Color3fv +Color4f +Color4fv +Hint +FeedbackBuffer +SelectBuffer +RenderMode +InitNames +LoadName +PushName +PopName +PassThrough +FogCoordPointerEXT +VertexAttribPointerNV +PointParameterfARB +PointParameterfvARB +PointParameteri +PointParameteriv +SampleCoverageARB +WindowPos2dARB +WindowPos2dvARB +WindowPos2fARB +WindowPos2fvARB +WindowPos2iARB +WindowPos2ivARB +WindowPos2sARB +WindowPos2svARB +WindowPos3dARB +WindowPos3dvARB +WindowPos3fARB +WindowPos3fvARB +WindowPos3iARB +WindowPos3ivARB +WindowPos3sARB +WindowPos3svARB +CompressedTexImage3DARB +CompressedTexImage2DARB +CompressedTexImage1DARB +CompressedTexSubImage3DARB +CompressedTexSubImage2DARB +CompressedTexSubImage1DARB +GetCompressedTexImageARB +BindProgramNV +ExecuteProgramNV +GenProgramsNV +AreProgramsResidentNV +RequestResidentProgramsNV +LoadProgramNV +GetProgramivNV +GetProgramStringNV +ProgramParameter4dNV +ProgramParameter4dvNV +ProgramParameter4fNV +ProgramParameter4fvNV +ProgramParameters4dvNV +ProgramParameters4fvNV +GetProgramParameterfvNV +GetProgramParameterdvNV +TrackMatrixNV +GetTrackMatrixivNV +GetVertexAttribdvNV +GetVertexAttribfvNV +GetVertexAttribivNV +GetVertexAttribPointervNV +ProgramNamedParameter4fNV +ProgramNamedParameter4dNV +ProgramNamedParameter4fvNV +ProgramNamedParameter4dvNV +GetProgramNamedParameterfvNV +GetProgramNamedParameterdvNV +GetProgramStringARB +ProgramLocalParameter4dARB +ProgramLocalParameter4dvARB +ProgramLocalParameter4fARB +ProgramLocalParameter4fvARB +GetProgramLocalParameterfvARB +GetProgramLocalParameterdvARB +GetVertexAttribdvARB +GetVertexAttribfvARB +GetVertexAttribivARB +EnableVertexAttribArrayARB +DisableVertexAttribArrayARB +ProgramStringARB +BindProgramARB +DeleteProgramsARB +GenProgramsARB +ProgramEnvParameter4dARB +ProgramEnvParameter4dvARB +ProgramEnvParameter4fARB +ProgramEnvParameter4fvARB +GetProgramEnvParameterdvARB +GetProgramEnvParameterfvARB +GetProgramivARB +GetProgramStringARB +IsProgramARB +VertexAttribPointerARB +GetVertexAttribPointervARB +GenFencesNV +DeleteFencesNV +SetFenceNV +TestFenceNV +FinishFenceNV +IsFenceNV +GetFenceivNV +VertexArrayRangeNV +FlushVertexArrayRangeNV +BindBufferARB +GenBuffersARB +IsBufferARB +GetBufferParameterivARB +GetBufferPointervARB +GetBufferSubDataARB +DeleteBuffersARB +BufferDataARB +BufferSubDataARB +MapBufferARB +UnmapBufferARB +GenQueriesARB +DeleteQueriesARB +IsQueryARB +BeginQueryARB +EndQueryARB +GetQueryivARB +GetQueryObjectivARB +GetQueryObjectuivARB +BindRenderbufferEXT +DeleteRenderbuffersEXT +RenderbufferStorageEXT +BindFramebufferEXT +DeleteFramebuffersEXT +FramebufferTexture1DEXT +FramebufferTexture2DEXT +FramebufferTexture3DEXT +FramebufferRenderbufferEXT +GetFramebufferAttachmentParameterivEXT +GenerateMipmapEXT +LockArraysEXT +UnlockArraysEXT +CompileShader +DeleteShader +AttachShader +DetachShader +LinkProgram +UseProgram +DeleteProgram +ValidateProgram +BindAttribLocation +GetAttribLocation +GetUniformLocation +CopyTexImage2D +GenFramebuffersEXT +GenRenderbuffersEXT +IsRenderbufferEXT +IsFramebufferEXT diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.c new file mode 100644 index 00000000..2fc438cd --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.c @@ -0,0 +1,1450 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + + +static GLint crStateStencilBufferGetIdxAndCount(CRStencilState *s, GLenum face, GLint *pIdx, GLint *pBitsIdx) +{ + switch (face) + { + case GL_FRONT_AND_BACK: + *pIdx = 0; + *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK; + return 2; + case GL_FRONT: + *pIdx = CRSTATE_STENCIL_BUFFER_ID_FRONT; + *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_FRONT; + return 1; + case GL_BACK: + *pIdx = CRSTATE_STENCIL_BUFFER_ID_BACK; + *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_BACK; + return 1; + case 0: + if (!s->stencilTwoSideEXT || s->activeStencilFace == GL_FRONT) + { + /* both front and back */ + *pIdx = 0; + *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK; + return 2; + } + *pIdx = CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK; + *pBitsIdx = CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK; + return 1; + default: + crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilBufferGetIdxAndCount"); + return 0; + } +#ifndef VBOX /* unreachable */ + crError("should never be here!"); + return 0; +#endif +} + +void crStateStencilBufferInit(CRStencilBufferState *s) +{ + s->func = GL_ALWAYS; + s->mask = 0xFFFFFFFF; + s->ref = 0; + + s->fail = GL_KEEP; + s->passDepthFail = GL_KEEP; + s->passDepthPass = GL_KEEP; +} + +static void crStateStencilBufferRefBitsInit(CRContext *ctx, CRStencilBufferRefBits *sb) +{ + RESET(sb->func, ctx->bitid); + RESET(sb->op, ctx->bitid); +} + +void crStateStencilInit(CRContext *ctx) +{ + CRStencilState *s = &ctx->stencil; + CRStateBits *stateb = GetCurrentBits(); + CRStencilBits *sb = &(stateb->stencil); + int i; + + s->stencilTest = GL_FALSE; + RESET(sb->enable, ctx->bitid); + + s->stencilTwoSideEXT = GL_FALSE; + RESET(sb->enableTwoSideEXT, ctx->bitid); + + s->activeStencilFace = GL_FRONT; + RESET(sb->activeStencilFace, ctx->bitid); + + s->clearValue = 0; + RESET(sb->clearValue, ctx->bitid); + + s->writeMask = 0xFFFFFFFF; + RESET(sb->writeMask, ctx->bitid); + + RESET(sb->dirty, ctx->bitid); + + for (i = 0; i < CRSTATE_STENCIL_BUFFER_COUNT; ++i) + { + crStateStencilBufferInit(&s->buffers[i]); + } + + for (i = 0; i < CRSTATE_STENCIL_BUFFER_REF_COUNT; ++i) + { + crStateStencilBufferRefBitsInit(ctx, &sb->bufferRefs[i]); + } +} + +static void crStateStencilBufferFunc(CRContext *g, CRStencilBufferState *s, GLenum func, GLint ref, GLuint mask) +{ + (void)g; + s->func = func; + s->ref = ref; + s->mask = mask; +} + +static void crStateStencilFuncPerform(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + CRContext *g = GetCurrentContext(); + CRStencilState *s = &(g->stencil); + CRStateBits *stateb = GetCurrentBits(); + CRStencilBits *sb = &(stateb->stencil); + GLint idx, bitsIdx, count, i; + + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glStencilFunc called in begin/end"); + return; + } + + FLUSH(); + + if (func != GL_NEVER && + func != GL_LESS && + func != GL_LEQUAL && + func != GL_GREATER && + func != GL_GEQUAL && + func != GL_EQUAL && + func != GL_NOTEQUAL && + func != GL_ALWAYS) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glStencilFunc called with bogu func: %d", func); + return; + } + + count = crStateStencilBufferGetIdxAndCount(s, face, &idx, &bitsIdx); + if (count) + { + for (i = idx; i < idx + count; ++i) + { + crStateStencilBufferFunc(g, &s->buffers[i], func, ref, mask); + } + DIRTY(sb->bufferRefs[bitsIdx].func, g->neg_bitid); + + DIRTY(sb->dirty, g->neg_bitid); + } +} + +void STATE_APIENTRY crStateStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) +{ + if (!face) + { + /* crStateStencilFuncPerform accepts 0 value, while glStencilFuncSeparate does not, + * filter it out here */ + crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilFuncSeparate"); + return; + } + crStateStencilFuncPerform(face, func, ref, mask); +} + +void STATE_APIENTRY crStateStencilFunc(GLenum func, GLint ref, GLuint mask) +{ + crStateStencilFuncPerform(0, func, ref, mask); +} + +static void STATE_APIENTRY crStateStencilBufferOp (CRContext *g, CRStencilBufferState *s, GLenum fail, GLenum zfail, GLenum zpass) +{ + (void)g; + s->fail = fail; + s->passDepthFail = zfail; + s->passDepthPass = zpass; +} + +static void crStateStencilOpPerform (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + CRContext *g = GetCurrentContext(); + CRStencilState *s = &(g->stencil); + CRStateBits *stateb = GetCurrentBits(); + CRStencilBits *sb = &(stateb->stencil); + GLint idx, bitsIdx, count, i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glStencilOp called in begin/end"); + return; + } + + FLUSH(); + + switch (fail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: +#ifdef CR_EXT_stencil_wrap + case GL_INCR_WRAP_EXT: + case GL_DECR_WRAP_EXT: +#endif + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glStencilOp called with bogus fail: %d", fail); + return; + } + + switch (zfail) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: +#ifdef CR_EXT_stencil_wrap + case GL_INCR_WRAP_EXT: + case GL_DECR_WRAP_EXT: +#endif + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glStencilOp called with bogus zfail: %d", zfail); + return; + } + + switch (zpass) { + case GL_KEEP: + case GL_ZERO: + case GL_REPLACE: + case GL_INCR: + case GL_DECR: + case GL_INVERT: +#ifdef CR_EXT_stencil_wrap + case GL_INCR_WRAP_EXT: + case GL_DECR_WRAP_EXT: +#endif + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glStencilOp called with bogus zpass: %d", zpass); + return; + } + + count = crStateStencilBufferGetIdxAndCount(s, face, &idx, &bitsIdx); + if (count) + { + for (i = idx; i < idx + count; ++i) + { + crStateStencilBufferOp(g, &s->buffers[i], fail, zfail, zpass); + } + + DIRTY(sb->bufferRefs[bitsIdx].op, g->neg_bitid); + + DIRTY(sb->dirty, g->neg_bitid); + } +} + +void STATE_APIENTRY crStateStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass) +{ + if (!face) + { + /* crStateStencilOpPerform accepts 0 value, while glStencilOpSeparate does not, + * filter it out here */ + crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateStencilOpSeparate"); + return; + } + crStateStencilOpPerform (0, fail, zfail, zpass); +} + +void STATE_APIENTRY crStateStencilOp (GLenum fail, GLenum zfail, GLenum zpass) +{ + crStateStencilOpPerform (0, fail, zfail, zpass); +} + +void STATE_APIENTRY crStateClearStencil (GLint c) +{ + CRContext *g = GetCurrentContext(); + CRStencilState *s = &(g->stencil); + CRStateBits *stateb = GetCurrentBits(); + CRStencilBits *sb = &(stateb->stencil); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glClearStencil called in begin/end"); + return; + } + + FLUSH(); + + s->clearValue = c; + + DIRTY(sb->clearValue, g->neg_bitid); + DIRTY(sb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateStencilMask (GLuint mask) +{ + CRContext *g = GetCurrentContext(); + CRStencilState *s = &(g->stencil); + CRStateBits *stateb = GetCurrentBits(); + CRStencilBits *sb = &(stateb->stencil); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glStencilMask called in begin/end"); + return; + } + + FLUSH(); + + s->writeMask = mask; + + DIRTY(sb->writeMask, g->neg_bitid); + DIRTY(sb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateActiveStencilFaceEXT (GLenum face) +{ + CRContext *g = GetCurrentContext(); + CRStencilState *s = &(g->stencil); + CRStateBits *stateb = GetCurrentBits(); + CRStencilBits *sb = &(stateb->stencil); + + switch (face) + { + case GL_FRONT: + case GL_BACK: + s->activeStencilFace = face; + break; + default: + crStateError(__LINE__,__FILE__,GL_INVALID_ENUM, "crStateActiveStencilFaceEXT"); + return; + } + + DIRTY(sb->activeStencilFace, g->neg_bitid); + DIRTY(sb->dirty, g->neg_bitid); +} + +#ifdef CRSTATE_DEBUG_STENCIL_ERR +#define CRSTATE_CLEARERR() do { \ + while (diff_api.GetError() != GL_NO_ERROR) {} \ + } while (0) + +#define CRSTATE_CHECKGLERR(_op) do {\ + GLenum _glErr; \ + CRSTATE_CLEARERR(); \ + _op; \ + while ((_glErr = diff_api.GetError()) != GL_NO_ERROR) { Assert(0);} \ + }while (0) +#else +#define CRSTATE_CHECKGLERR(_op) do { _op; } while (0) +#endif + +#define CR_STATE_STENCIL_FUNC_MATCH(_s1, _i1, _s2, _i2) (\ + (_s1)->buffers[(_i1)].func == (_s2)->buffers[(_i2)].func && \ + (_s1)->buffers[(_i1)].ref == (_s2)->buffers[(_i2)].ref && \ + (_s1)->buffers[(_i1)].mask == (_s2)->buffers[(_i2)].mask) + +#define CR_STATE_STENCIL_FUNC_COPY(_s1, _i1, _s2, _i2) do { \ + (_s1)->buffers[(_i1)].func = (_s2)->buffers[(_i2)].func; \ + (_s1)->buffers[(_i1)].ref = (_s2)->buffers[(_i2)].ref; \ + (_s1)->buffers[(_i1)].mask = (_s2)->buffers[(_i2)].mask; \ + } while (0) + + +#define CR_STATE_STENCIL_OP_MATCH(_s1, _i1, _s2, _i2) (\ + (_s1)->buffers[(_i1)].fail == (_s2)->buffers[(_i2)].fail && \ + (_s1)->buffers[(_i1)].passDepthFail == (_s2)->buffers[(_i2)].passDepthFail && \ + (_s1)->buffers[(_i1)].passDepthPass == (_s2)->buffers[(_i2)].passDepthPass) + +#define CR_STATE_STENCIL_OP_COPY(_s1, _i1, _s2, _i2) do { \ + (_s1)->buffers[(_i1)].fail = (_s2)->buffers[(_i2)].fail; \ + (_s1)->buffers[(_i1)].passDepthFail = (_s2)->buffers[(_i2)].passDepthFail; \ + (_s1)->buffers[(_i1)].passDepthPass = (_s2)->buffers[(_i2)].passDepthPass; \ + } while (0) + + +void crStateStencilDiff(CRStencilBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRStencilState *from = &(fromCtx->stencil); + CRStencilState *to = &(toCtx->stencil); + unsigned int j, i; + GLenum activeFace; + GLboolean backIsSet = GL_FALSE, frontIsSet = GL_FALSE, frontBackDirty, frontDirty, backDirty; + GLchar frontMatch = -1, backMatch = -1, toFrontBackMatch = -1; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + for (j=0;jenable, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->stencilTest != to->stencilTest) + { + able[to->stencilTest](GL_STENCIL_TEST); + from->stencilTest = to->stencilTest; + } + CLEARDIRTY(b->enable, nbitID); + } + + if (CHECKDIRTY(b->enableTwoSideEXT, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->stencilTwoSideEXT != to->stencilTwoSideEXT) + { + able[to->stencilTwoSideEXT](GL_STENCIL_TEST_TWO_SIDE_EXT); + from->stencilTwoSideEXT = to->stencilTwoSideEXT; + } + CLEARDIRTY(b->enableTwoSideEXT, nbitID); + } + + if (CHECKDIRTY(b->clearValue, bitID)) + { + if (from->clearValue != to->clearValue) + { + diff_api.ClearStencil (to->clearValue); + from->clearValue = to->clearValue; + } + CLEARDIRTY(b->clearValue, nbitID); + } + + activeFace = to->activeStencilFace; + + + /* func */ + frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, bitID); + frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, bitID); + backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, bitID); +#define CR_STATE_STENCIL_FUNC_FRONT_MATCH() ( \ + frontMatch >= 0 ? \ + frontMatch \ + : (frontMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT))) + +#define CR_STATE_STENCIL_FUNC_BACK_MATCH() ( \ + backMatch >= 0 ? \ + backMatch \ + : (backMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + +#define CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH() ( \ + toFrontBackMatch >= 0 ? \ + toFrontBackMatch \ + : (toFrontBackMatch = CR_STATE_STENCIL_FUNC_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + + if (frontBackDirty) + { + if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH() + || !CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask); + + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask); + + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + frontIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask); + + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK); + + backIsSet = GL_TRUE; + } + } + + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, nbitID); + } + + if (frontDirty) + { + if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask); + + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask); + + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask); + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK); + backIsSet = GL_TRUE; + } + } + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, nbitID); + } + + + if (backDirty) + { + if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask); + + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask); + + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask); + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK); + backIsSet = GL_TRUE; + } + } + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, nbitID); + } + + if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, bitID)) + { + if (!CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK)) + { + if (activeFace == GL_FRONT) + { + diff_api.ActiveStencilFaceEXT(GL_BACK); + activeFace = GL_BACK; + } + + diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask); + CR_STATE_STENCIL_FUNC_COPY(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, nbitID); + } + +#undef CR_STATE_STENCIL_FUNC_FRONT_MATCH +#undef CR_STATE_STENCIL_FUNC_BACK_MATCH +#undef CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH + + /* op */ + backIsSet = GL_FALSE, frontIsSet = GL_FALSE; + frontMatch = -1, backMatch = -1, toFrontBackMatch = -1; + frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, bitID); + frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, bitID); + backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, bitID); + +#define CR_STATE_STENCIL_OP_FRONT_MATCH() ( \ + frontMatch >= 0 ? \ + frontMatch \ + : (frontMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT))) + +#define CR_STATE_STENCIL_OP_BACK_MATCH() ( \ + backMatch >= 0 ? \ + backMatch \ + : (backMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + +#define CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH() ( \ + toFrontBackMatch >= 0 ? \ + toFrontBackMatch \ + : (toFrontBackMatch = CR_STATE_STENCIL_OP_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + + if (frontBackDirty) + { + if (!CR_STATE_STENCIL_OP_FRONT_MATCH() + || !CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass); + + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + frontIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK); + backIsSet = GL_TRUE; + } + } + + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, nbitID); + } + + if (frontDirty) + { + if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass); + + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass); + + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK); + backIsSet = GL_TRUE; + } + } + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, nbitID); + } + + + if (backDirty) + { + if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass); + + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass); + + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT); + + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK); + backIsSet = GL_TRUE; + } + } + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, nbitID); + } + + if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, bitID)) + { + if (!CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK)) + { + if (activeFace == GL_FRONT) + { + diff_api.ActiveStencilFaceEXT(GL_BACK); + activeFace = GL_BACK; + } + + diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass); + CR_STATE_STENCIL_OP_COPY(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, nbitID); + } + +#undef CR_STATE_STENCIL_OP_FRONT_MATCH +#undef CR_STATE_STENCIL_OP_BACK_MATCH +#undef CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH + + + if (activeFace != to->activeStencilFace) + { + diff_api.ActiveStencilFaceEXT(activeFace); + } + + if (CHECKDIRTY(b->activeStencilFace, bitID)) + { + if (from->activeStencilFace != to->activeStencilFace) + { + /* we already did it ( see above )*/ + /* diff_api.ActiveStencilFaceEXT(to->activeStencilFace); */ + from->activeStencilFace = to->activeStencilFace; + } + CLEARDIRTY(b->activeStencilFace, nbitID); + } + + if (CHECKDIRTY(b->writeMask, bitID)) + { + if (from->writeMask != to->writeMask) + { + diff_api.StencilMask (to->writeMask); + from->writeMask = to->writeMask; + } + CLEARDIRTY(b->writeMask, nbitID); + } + CLEARDIRTY(b->dirty, nbitID); +} + +void crStateStencilSwitch(CRStencilBits *b, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx) +{ + CRStencilState *from = &(fromCtx->stencil); + CRStencilState *to = &(toCtx->stencil); + unsigned int j, i; + GLenum activeFace; + GLboolean backIsSet = GL_FALSE, frontIsSet = GL_FALSE, frontBackDirty, frontDirty, backDirty; + GLchar frontMatch = -1, backMatch = -1, toFrontBackMatch = -1; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + for (j=0;jenable, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->stencilTest != to->stencilTest) + { + CRSTATE_CHECKGLERR(able[to->stencilTest](GL_STENCIL_TEST)); + FILLDIRTY(b->enable); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->enable, nbitID); + } + if (CHECKDIRTY(b->enableTwoSideEXT, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->stencilTwoSideEXT != to->stencilTwoSideEXT) + { + CRSTATE_CHECKGLERR(able[to->stencilTwoSideEXT](GL_STENCIL_TEST_TWO_SIDE_EXT)); + FILLDIRTY(b->enableTwoSideEXT); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->enableTwoSideEXT, nbitID); + } + if (CHECKDIRTY(b->clearValue, bitID)) + { + if (from->clearValue != to->clearValue) + { + CRSTATE_CHECKGLERR(diff_api.ClearStencil (to->clearValue)); + FILLDIRTY(b->clearValue); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->clearValue, nbitID); + } + + activeFace = from->activeStencilFace; + + /* func */ + frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, bitID); + frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, bitID); + backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, bitID); +#define CR_STATE_STENCIL_FUNC_FRONT_MATCH() ( \ + frontMatch >= 0 ? \ + frontMatch \ + : (frontMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT))) + +#define CR_STATE_STENCIL_FUNC_BACK_MATCH() ( \ + backMatch >= 0 ? \ + backMatch \ + : (backMatch = CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + +#define CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH() ( \ + toFrontBackMatch >= 0 ? \ + toFrontBackMatch \ + : (toFrontBackMatch = CR_STATE_STENCIL_FUNC_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + + if (frontBackDirty) + { + if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH() + || !CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask)); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask)); + frontIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask)); + backIsSet = GL_TRUE; + } + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func); + FILLDIRTY(b->dirty); + } + + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].func, nbitID); + } + + if (frontDirty) + { + if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask)); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask)); + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask)); + backIsSet = GL_TRUE; + } + } + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].func, nbitID); + } + + + if (backDirty) + { + if (!CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask)); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].mask)); + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_FUNC_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + diff_api.ActiveStencilFaceEXT(GL_FRONT); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFuncSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].mask)); + backIsSet = GL_TRUE; + } + } + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].func, nbitID); + } + + if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, bitID)) + { + if (!CR_STATE_STENCIL_FUNC_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK)) + { + if (activeFace == GL_FRONT) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_BACK)); + activeFace = GL_BACK; + } + + CRSTATE_CHECKGLERR(diff_api.StencilFunc (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].func, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].ref, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].mask)); + + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].func, nbitID); + } + +#undef CR_STATE_STENCIL_FUNC_FRONT_MATCH +#undef CR_STATE_STENCIL_FUNC_BACK_MATCH +#undef CR_STATE_STENCIL_FUNC_TO_FRONT_BACK_MATCH + + /* op */ + backIsSet = GL_FALSE, frontIsSet = GL_FALSE; + frontMatch = -1, backMatch = -1, toFrontBackMatch = -1; + frontBackDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, bitID); + frontDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, bitID); + backDirty = CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, bitID); + +#define CR_STATE_STENCIL_OP_FRONT_MATCH() ( \ + frontMatch >= 0 ? \ + frontMatch \ + : (frontMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_FRONT))) + +#define CR_STATE_STENCIL_OP_BACK_MATCH() ( \ + backMatch >= 0 ? \ + backMatch \ + : (backMatch = CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_BACK, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + +#define CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH() ( \ + toFrontBackMatch >= 0 ? \ + toFrontBackMatch \ + : (toFrontBackMatch = CR_STATE_STENCIL_OP_MATCH(to, CRSTATE_STENCIL_BUFFER_ID_FRONT, to, CRSTATE_STENCIL_BUFFER_ID_BACK))) + + if (frontBackDirty) + { + if (!CR_STATE_STENCIL_OP_FRONT_MATCH() + || !CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass)); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass)); + frontIsSet = GL_TRUE; + } + else if (!CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass)); + backIsSet = GL_TRUE; + } + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op); + FILLDIRTY(b->dirty); + } + + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT_AND_BACK].op, nbitID); + } + + if (frontDirty) + { + if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass)); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass)); + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass)); + backIsSet = GL_TRUE; + } + } + + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_FRONT].op, nbitID); + } + + + if (backDirty) + { + if (!CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH()) + { + if (!frontIsSet || !backIsSet) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass)); + + frontIsSet = GL_TRUE; + backIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_FRONT_MATCH()) + { + if (!frontIsSet) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_FRONT, to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_FRONT].passDepthPass)); + frontIsSet = GL_TRUE; + } + } + else if (!CR_STATE_STENCIL_OP_BACK_MATCH()) + { + if (!backIsSet) + { + if (activeFace == GL_BACK) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_FRONT)); + activeFace = GL_FRONT; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOpSeparate (GL_BACK, to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_BACK].passDepthPass)); + backIsSet = GL_TRUE; + } + } + + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_BACK].op, nbitID); + } + + if (CHECKDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, bitID)) + { + if (!CR_STATE_STENCIL_OP_MATCH(from, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK, to, CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK)) + { + if (activeFace == GL_FRONT) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(GL_BACK)); + activeFace = GL_BACK; + } + + CRSTATE_CHECKGLERR(diff_api.StencilOp (to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].fail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthFail, + to->buffers[CRSTATE_STENCIL_BUFFER_ID_TWO_SIDE_BACK].passDepthPass)); + + FILLDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->bufferRefs[CRSTATE_STENCIL_BUFFER_REF_ID_TWO_SIDE_BACK].op, nbitID); + } + +#undef CR_STATE_STENCIL_OP_FRONT_MATCH +#undef CR_STATE_STENCIL_OP_BACK_MATCH +#undef CR_STATE_STENCIL_OP_TO_FRONT_BACK_MATCH + + if (activeFace != to->activeStencilFace) + { + CRSTATE_CHECKGLERR(diff_api.ActiveStencilFaceEXT(activeFace)); + } + + if (CHECKDIRTY(b->activeStencilFace, bitID)) + { + if (from->activeStencilFace != to->activeStencilFace) + { + /* we already did it ( see above )*/ + /* diff_api.ActiveStencilFaceEXT(to->activeStencilFace); */ + FILLDIRTY(b->activeStencilFace); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->activeStencilFace, nbitID); + } + + if (CHECKDIRTY(b->writeMask, bitID)) + { + if (from->writeMask != to->writeMask) + { + CRSTATE_CHECKGLERR(diff_api.StencilMask (to->writeMask)); + FILLDIRTY(b->writeMask); + FILLDIRTY(b->dirty); + } + CLEARDIRTY(b->writeMask, nbitID); + } + + CLEARDIRTY(b->dirty, nbitID); +} + diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.txt new file mode 100644 index 00000000..9632e0c3 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_stencil.txt @@ -0,0 +1,9 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enable:stencilTest:GL_STENCIL_TEST +:clearValue:clearValue:ClearStencil +stencilTest:func:func,ref,mask:StencilFunc +stencilTest:op:fail,passDepthFail,passDepthPass:StencilOp +stencilTest:writeMask:writeMask:StencilMask diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_texdiff.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_texdiff.c new file mode 100644 index 00000000..6854334b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_texdiff.c @@ -0,0 +1,1469 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_texture.h" +#include "cr_hash.h" +#include "cr_string.h" +#include "cr_mem.h" +#include "cr_version.h" +#include "state_internals.h" + + +#define UNIMPLEMENTED() crStateError(__LINE__,__FILE__,GL_INVALID_OPERATION, "Unimplemented something or other" ) + + +#if 0 /* NOT USED??? */ +void crStateTextureObjSwitchCallback( unsigned long key, void *data1, void *data2 ) +{ + CRTextureObj *tobj = (CRTextureObj *) data1; + CRContext *fromCtx = (CRContext *) data2; + unsigned int i = 0; + unsigned int j = 0; + CRbitvalue *bitID = fromCtx->bitid; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j=0;jdirty); + FILLDIRTY(tobj->imageBit); + + for (i = 0; i < fromCtx->limits.maxTextureUnits; i++) + { + int j; + + FILLDIRTY(tobj->paramsBit[i]); + + switch (tobj->target) + { + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + for (j = 0; j <= fromCtx->texture.maxLevel; j++) + { + CRTextureLevel *tl = &(tobj->level[j]); + FILLDIRTY(tl->dirty); + } + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_3D: +#endif + for (j = 0; j <= fromCtx->texture.max3DLevel; j++) + { + CRTextureLevel *tl = &(tobj->level[j]); + FILLDIRTY(tl->dirty); + } + break; +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_ARB: + for (j = 0; j <= fromCtx->texture.maxCubeMapLevel; j++) + { + CRTextureLevel *tl; + /* Positive X */ + tl = &(tobj->level[j]); + FILLDIRTY(tl->dirty); + /* Negative X */ + tl = &(tobj->negativeXlevel[j]); + FILLDIRTY(tl->dirty); + /* Positive Y */ + tl = &(tobj->positiveYlevel[j]); + FILLDIRTY(tl->dirty); + /* Negative Y */ + tl = &(tobj->negativeYlevel[j]); + FILLDIRTY(tl->dirty); + /* Positive Z */ + tl = &(tobj->positiveZlevel[j]); + FILLDIRTY(tl->dirty); + /* Negative Z */ + tl = &(tobj->negativeZlevel[j]); + FILLDIRTY(tl->dirty); + } + break; +#endif + default: + UNIMPLEMENTED(); + } + } +} +#endif + + +void crStateTextureSwitch( CRTextureBits *tb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + CRTextureState *from = &(fromCtx->texture); + const CRTextureState *to = &(toCtx->texture); + unsigned int i,j; + glAble able[2]; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + unsigned int activeUnit = (unsigned int) -1; + + for (j=0;jlimits.maxTextureUnits; i++) + { + if (CHECKDIRTY(tb->enable[i], bitID)) + { + if (activeUnit != i) { + diff_api.ActiveTextureARB( i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + if (from->unit[i].enabled1D != to->unit[i].enabled1D) + { + able[to->unit[i].enabled1D](GL_TEXTURE_1D); + FILLDIRTY(tb->enable[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].enabled2D != to->unit[i].enabled2D) + { + able[to->unit[i].enabled2D](GL_TEXTURE_2D); + FILLDIRTY(tb->enable[i]); + FILLDIRTY(tb->dirty); + } +#ifdef CR_OPENGL_VERSION_1_2 + if (from->unit[i].enabled3D != to->unit[i].enabled3D) + { + able[to->unit[i].enabled3D](GL_TEXTURE_3D); + FILLDIRTY(tb->enable[i]); + FILLDIRTY(tb->dirty); + } +#endif +#ifdef CR_ARB_texture_cube_map + if (fromCtx->extensions.ARB_texture_cube_map && + from->unit[i].enabledCubeMap != to->unit[i].enabledCubeMap) + { + able[to->unit[i].enabledCubeMap](GL_TEXTURE_CUBE_MAP_ARB); + FILLDIRTY(tb->enable[i]); + FILLDIRTY(tb->dirty); + } +#endif +#ifdef CR_NV_texture_rectangle + if (fromCtx->extensions.NV_texture_rectangle && + from->unit[i].enabledRect != to->unit[i].enabledRect) + { + able[to->unit[i].enabledRect](GL_TEXTURE_RECTANGLE_NV); + FILLDIRTY(tb->enable[i]); + FILLDIRTY(tb->dirty); + } +#endif + if (from->unit[i].textureGen.s != to->unit[i].textureGen.s || + from->unit[i].textureGen.t != to->unit[i].textureGen.t || + from->unit[i].textureGen.r != to->unit[i].textureGen.r || + from->unit[i].textureGen.q != to->unit[i].textureGen.q) + { + able[to->unit[i].textureGen.s](GL_TEXTURE_GEN_S); + able[to->unit[i].textureGen.t](GL_TEXTURE_GEN_T); + able[to->unit[i].textureGen.r](GL_TEXTURE_GEN_R); + able[to->unit[i].textureGen.q](GL_TEXTURE_GEN_Q); + FILLDIRTY(tb->enable[i]); + FILLDIRTY(tb->dirty); + } + CLEARDIRTY(tb->enable[i], nbitID); + } + + /* + ** A thought on switching with textures: + ** Since we are only performing a switch + ** and not a sync, we won't need to + ** update individual textures, just + ** the bindings.... + */ + + if (CHECKDIRTY(tb->current[i], bitID)) + { + if (activeUnit != i) { + diff_api.ActiveTextureARB( i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + if (from->unit[i].currentTexture1D->hwid != to->unit[i].currentTexture1D->hwid) + { + diff_api.BindTexture(GL_TEXTURE_1D, crStateGetTextureObjHWID(to->unit[i].currentTexture1D)); + FILLDIRTY(tb->current[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].currentTexture2D->hwid != to->unit[i].currentTexture2D->hwid) + { + diff_api.BindTexture(GL_TEXTURE_2D, crStateGetTextureObjHWID(to->unit[i].currentTexture2D)); + FILLDIRTY(tb->current[i]); + FILLDIRTY(tb->dirty); + } +#ifdef CR_OPENGL_VERSION_1_2 + if (from->unit[i].currentTexture3D->hwid != to->unit[i].currentTexture3D->hwid) + { + diff_api.BindTexture(GL_TEXTURE_3D, crStateGetTextureObjHWID(to->unit[i].currentTexture3D)); + FILLDIRTY(tb->current[i]); + FILLDIRTY(tb->dirty); + } +#endif +#ifdef CR_ARB_texture_cube_map + if (fromCtx->extensions.ARB_texture_cube_map && + from->unit[i].currentTextureCubeMap->hwid != to->unit[i].currentTextureCubeMap->hwid) + { + diff_api.BindTexture(GL_TEXTURE_CUBE_MAP_ARB, crStateGetTextureObjHWID(to->unit[i].currentTextureCubeMap)); + FILLDIRTY(tb->current[i]); + FILLDIRTY(tb->dirty); + } +#endif +#ifdef CR_NV_texture_rectangle + if (fromCtx->extensions.NV_texture_rectangle && + from->unit[i].currentTextureRect->hwid != to->unit[i].currentTextureRect->hwid) + { + diff_api.BindTexture(GL_TEXTURE_RECTANGLE_NV, crStateGetTextureObjHWID(to->unit[i].currentTextureRect)); + FILLDIRTY(tb->current[i]); + FILLDIRTY(tb->dirty); + } +#endif + CLEARDIRTY(tb->current[i], nbitID); + } + + if (CHECKDIRTY(tb->objGen[i], bitID)) + { + if (activeUnit != i) { + diff_api.ActiveTextureARB( i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + if (from->unit[i].objSCoeff.x != to->unit[i].objSCoeff.x || + from->unit[i].objSCoeff.y != to->unit[i].objSCoeff.y || + from->unit[i].objSCoeff.z != to->unit[i].objSCoeff.z || + from->unit[i].objSCoeff.w != to->unit[i].objSCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[i].objSCoeff.x; + f[1] = to->unit[i].objSCoeff.y; + f[2] = to->unit[i].objSCoeff.z; + f[3] = to->unit[i].objSCoeff.w; + diff_api.TexGenfv (GL_S, GL_OBJECT_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->objGen[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].objTCoeff.x != to->unit[i].objTCoeff.x || + from->unit[i].objTCoeff.y != to->unit[i].objTCoeff.y || + from->unit[i].objTCoeff.z != to->unit[i].objTCoeff.z || + from->unit[i].objTCoeff.w != to->unit[i].objTCoeff.w) { + GLfloat f[4]; + f[0] = to->unit[i].objTCoeff.x; + f[1] = to->unit[i].objTCoeff.y; + f[2] = to->unit[i].objTCoeff.z; + f[3] = to->unit[i].objTCoeff.w; + diff_api.TexGenfv (GL_T, GL_OBJECT_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->objGen[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].objRCoeff.x != to->unit[i].objRCoeff.x || + from->unit[i].objRCoeff.y != to->unit[i].objRCoeff.y || + from->unit[i].objRCoeff.z != to->unit[i].objRCoeff.z || + from->unit[i].objRCoeff.w != to->unit[i].objRCoeff.w) { + GLfloat f[4]; + f[0] = to->unit[i].objRCoeff.x; + f[1] = to->unit[i].objRCoeff.y; + f[2] = to->unit[i].objRCoeff.z; + f[3] = to->unit[i].objRCoeff.w; + diff_api.TexGenfv (GL_R, GL_OBJECT_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->objGen[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].objQCoeff.x != to->unit[i].objQCoeff.x || + from->unit[i].objQCoeff.y != to->unit[i].objQCoeff.y || + from->unit[i].objQCoeff.z != to->unit[i].objQCoeff.z || + from->unit[i].objQCoeff.w != to->unit[i].objQCoeff.w) { + GLfloat f[4]; + f[0] = to->unit[i].objQCoeff.x; + f[1] = to->unit[i].objQCoeff.y; + f[2] = to->unit[i].objQCoeff.z; + f[3] = to->unit[i].objQCoeff.w; + diff_api.TexGenfv (GL_Q, GL_OBJECT_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->objGen[i]); + FILLDIRTY(tb->dirty); + } + CLEARDIRTY(tb->objGen[i], nbitID); + } + if (CHECKDIRTY(tb->eyeGen[i], bitID)) + { + if (activeUnit != i) { + diff_api.ActiveTextureARB( i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + diff_api.MatrixMode(GL_MODELVIEW); + diff_api.PushMatrix(); + diff_api.LoadIdentity(); + if (from->unit[i].eyeSCoeff.x != to->unit[i].eyeSCoeff.x || + from->unit[i].eyeSCoeff.y != to->unit[i].eyeSCoeff.y || + from->unit[i].eyeSCoeff.z != to->unit[i].eyeSCoeff.z || + from->unit[i].eyeSCoeff.w != to->unit[i].eyeSCoeff.w) { + GLfloat f[4]; + f[0] = to->unit[i].eyeSCoeff.x; + f[1] = to->unit[i].eyeSCoeff.y; + f[2] = to->unit[i].eyeSCoeff.z; + f[3] = to->unit[i].eyeSCoeff.w; + diff_api.TexGenfv (GL_S, GL_EYE_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->eyeGen[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].eyeTCoeff.x != to->unit[i].eyeTCoeff.x || + from->unit[i].eyeTCoeff.y != to->unit[i].eyeTCoeff.y || + from->unit[i].eyeTCoeff.z != to->unit[i].eyeTCoeff.z || + from->unit[i].eyeTCoeff.w != to->unit[i].eyeTCoeff.w) { + GLfloat f[4]; + f[0] = to->unit[i].eyeTCoeff.x; + f[1] = to->unit[i].eyeTCoeff.y; + f[2] = to->unit[i].eyeTCoeff.z; + f[3] = to->unit[i].eyeTCoeff.w; + diff_api.TexGenfv (GL_T, GL_EYE_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->eyeGen[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].eyeRCoeff.x != to->unit[i].eyeRCoeff.x || + from->unit[i].eyeRCoeff.y != to->unit[i].eyeRCoeff.y || + from->unit[i].eyeRCoeff.z != to->unit[i].eyeRCoeff.z || + from->unit[i].eyeRCoeff.w != to->unit[i].eyeRCoeff.w) { + GLfloat f[4]; + f[0] = to->unit[i].eyeRCoeff.x; + f[1] = to->unit[i].eyeRCoeff.y; + f[2] = to->unit[i].eyeRCoeff.z; + f[3] = to->unit[i].eyeRCoeff.w; + diff_api.TexGenfv (GL_R, GL_EYE_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->eyeGen[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].eyeQCoeff.x != to->unit[i].eyeQCoeff.x || + from->unit[i].eyeQCoeff.y != to->unit[i].eyeQCoeff.y || + from->unit[i].eyeQCoeff.z != to->unit[i].eyeQCoeff.z || + from->unit[i].eyeQCoeff.w != to->unit[i].eyeQCoeff.w) { + GLfloat f[4]; + f[0] = to->unit[i].eyeQCoeff.x; + f[1] = to->unit[i].eyeQCoeff.y; + f[2] = to->unit[i].eyeQCoeff.z; + f[3] = to->unit[i].eyeQCoeff.w; + diff_api.TexGenfv (GL_Q, GL_EYE_PLANE, (const GLfloat *) f); + FILLDIRTY(tb->eyeGen[i]); + FILLDIRTY(tb->dirty); + } + diff_api.PopMatrix(); + CLEARDIRTY(tb->eyeGen[i], nbitID); + } + if (CHECKDIRTY(tb->genMode[i], bitID)) + { + if (activeUnit != i) { + diff_api.ActiveTextureARB( i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + if (from->unit[i].gen.s != to->unit[i].gen.s || + from->unit[i].gen.t != to->unit[i].gen.t || + from->unit[i].gen.r != to->unit[i].gen.r || + from->unit[i].gen.q != to->unit[i].gen.q) + { + diff_api.TexGeni (GL_S, GL_TEXTURE_GEN_MODE, to->unit[i].gen.s); + diff_api.TexGeni (GL_T, GL_TEXTURE_GEN_MODE, to->unit[i].gen.t); + diff_api.TexGeni (GL_R, GL_TEXTURE_GEN_MODE, to->unit[i].gen.r); + diff_api.TexGeni (GL_Q, GL_TEXTURE_GEN_MODE, to->unit[i].gen.q); + FILLDIRTY(tb->genMode[i]); + FILLDIRTY(tb->dirty); + } + CLEARDIRTY(tb->genMode[i], nbitID); + } + CLEARDIRTY(tb->dirty, nbitID); + + /* Texture enviroment */ + if (CHECKDIRTY(tb->envBit[i], bitID)) + { + if (activeUnit != i) { + diff_api.ActiveTextureARB( i + GL_TEXTURE0_ARB ); + activeUnit = i; + } + if (from->unit[i].envMode != to->unit[i].envMode) + { + diff_api.TexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, to->unit[i].envMode); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].envColor.r != to->unit[i].envColor.r || + from->unit[i].envColor.g != to->unit[i].envColor.g || + from->unit[i].envColor.b != to->unit[i].envColor.b || + from->unit[i].envColor.a != to->unit[i].envColor.a) + { + GLfloat f[4]; + f[0] = to->unit[i].envColor.r; + f[1] = to->unit[i].envColor.g; + f[2] = to->unit[i].envColor.b; + f[3] = to->unit[i].envColor.a; + diff_api.TexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const GLfloat *) f); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineModeRGB != to->unit[i].combineModeRGB) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, to->unit[i].combineModeRGB); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineModeA != to->unit[i].combineModeA) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, to->unit[i].combineModeA); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineSourceRGB[0] != to->unit[i].combineSourceRGB[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, to->unit[i].combineSourceRGB[0]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineSourceRGB[1] != to->unit[i].combineSourceRGB[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, to->unit[i].combineSourceRGB[1]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineSourceRGB[2] != to->unit[i].combineSourceRGB[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, to->unit[i].combineSourceRGB[2]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineSourceA[0] != to->unit[i].combineSourceA[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, to->unit[i].combineSourceA[0]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineSourceA[1] != to->unit[i].combineSourceA[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, to->unit[i].combineSourceA[1]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineSourceA[2] != to->unit[i].combineSourceA[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, to->unit[i].combineSourceA[2]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineOperandRGB[0] != to->unit[i].combineOperandRGB[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, to->unit[i].combineOperandRGB[0]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineOperandRGB[1] != to->unit[i].combineOperandRGB[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, to->unit[i].combineOperandRGB[1]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineOperandRGB[2] != to->unit[i].combineOperandRGB[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, to->unit[i].combineOperandRGB[2]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineOperandA[0] != to->unit[i].combineOperandA[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, to->unit[i].combineOperandA[0]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineOperandA[1] != to->unit[i].combineOperandA[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, to->unit[i].combineOperandA[1]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineOperandA[2] != to->unit[i].combineOperandA[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, to->unit[i].combineOperandA[2]); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineScaleRGB != to->unit[i].combineScaleRGB) + { + diff_api.TexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, to->unit[i].combineScaleRGB); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + if (from->unit[i].combineScaleA != to->unit[i].combineScaleA) + { + diff_api.TexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, to->unit[i].combineScaleA); + FILLDIRTY(tb->envBit[i]); + FILLDIRTY(tb->dirty); + } + CLEARDIRTY(tb->envBit[i], nbitID); + } + } + + /* Resend texture images */ + if (toCtx->shared->bTexResyncNeeded) + { + toCtx->shared->bTexResyncNeeded = GL_FALSE; + + crStateDiffAllTextureObjects(toCtx, bitID, GL_TRUE); + } + + /* After possible fiddling put them back now */ + if (activeUnit != toCtx->texture.curTextureUnit) { + diff_api.ActiveTextureARB( toCtx->texture.curTextureUnit + GL_TEXTURE0_ARB ); + } + diff_api.MatrixMode(toCtx->transform.matrixMode); +} + + +/* + * Check the dirty bits for the specified texture on a given unit to + * determine if any of its images are dirty. + * Return: 1 -- dirty, 0 -- clean + */ +int crStateTextureCheckDirtyImages(CRContext *from, CRContext *to, GLenum target, int textureUnit) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *tsto; + CRbitvalue *bitID; + CRTextureObj *tobj = NULL; + int maxLevel = 0, i; + int face, numFaces; + + CRASSERT(to); + CRASSERT(from); + + tsto = &(to->texture); + bitID = from->bitid; + + CRASSERT(tsto); + + switch(target) + { + case GL_TEXTURE_1D: + tobj = tsto->unit[textureUnit].currentTexture1D; + maxLevel = tsto->maxLevel; + break; + case GL_TEXTURE_2D: + tobj = tsto->unit[textureUnit].currentTexture2D; + maxLevel = tsto->maxLevel; + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_3D: + tobj = tsto->unit[textureUnit].currentTexture3D; + maxLevel = tsto->max3DLevel; + break; +#endif +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP: + if (g->extensions.ARB_texture_cube_map) { + tobj = tsto->unit[textureUnit].currentTextureCubeMap; + maxLevel = tsto->maxCubeMapLevel; + } + break; +#endif +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + if (g->extensions.NV_texture_rectangle) { + tobj = tsto->unit[textureUnit].currentTextureRect; + maxLevel = 1; + } + break; +#endif + default: + crError("Bad texture target in crStateTextureCheckDirtyImages()"); + return 0; + } + + if (!tobj) + { + return 0; + } + + numFaces = (target == GL_TEXTURE_CUBE_MAP) ? 6 : 1; + + for (face = 0; face < numFaces; face++) { + for (i = 0; i < maxLevel; i++) { + if (CHECKDIRTY(tobj->level[face][i].dirty, bitID)) + return 1; + } + } + + return 0; +} + + +/* + * Do texture state differencing for the given texture object. + */ +void +crStateTextureObjectDiff(CRContext *fromCtx, + const CRbitvalue *bitID, const CRbitvalue *nbitID, + CRTextureObj *tobj, GLboolean alwaysDirty) +{ + CRTextureState *from = &(fromCtx->texture); + glAble able[2]; + int u = 0; /* always use texture unit 0 for diff'ing */ + GLuint hwid = crStateGetTextureObjHWID(tobj); + + if (!hwid) + return; + + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + +#if 0 + /* XXX disabling this code fixed Wes Bethel's problem with missing/white + * textures. Setting the active texture unit here can screw up the + * current texture object bindings. + */ + /* Set active texture unit, and bind this texture object */ + if (from->curTextureUnit != u) { + diff_api.ActiveTextureARB( u + GL_TEXTURE0_ARB ); + from->curTextureUnit = u; + } +#endif + + diff_api.BindTexture(tobj->target, hwid); + + if (alwaysDirty || CHECKDIRTY(tobj->paramsBit[u], bitID)) + { + GLfloat f[4]; + f[0] = tobj->borderColor.r; + f[1] = tobj->borderColor.g; + f[2] = tobj->borderColor.b; + f[3] = tobj->borderColor.a; + diff_api.TexParameteri(tobj->target, GL_TEXTURE_BASE_LEVEL, tobj->baseLevel); + diff_api.TexParameteri(tobj->target, GL_TEXTURE_MAX_LEVEL, tobj->maxLevel); + diff_api.TexParameteri(tobj->target, GL_TEXTURE_MIN_FILTER, tobj->minFilter); + diff_api.TexParameteri(tobj->target, GL_TEXTURE_MAG_FILTER, tobj->magFilter); + diff_api.TexParameteri(tobj->target, GL_TEXTURE_WRAP_S, tobj->wrapS); + diff_api.TexParameteri(tobj->target, GL_TEXTURE_WRAP_T, tobj->wrapT); +#ifdef CR_OPENGL_VERSION_1_2 + diff_api.TexParameteri(tobj->target, GL_TEXTURE_WRAP_R, tobj->wrapR); + diff_api.TexParameterf(tobj->target, GL_TEXTURE_PRIORITY, tobj->priority); +#endif + diff_api.TexParameterfv(tobj->target, GL_TEXTURE_BORDER_COLOR, (const GLfloat *) f); +#ifdef CR_EXT_texture_filter_anisotropic + if (fromCtx->extensions.EXT_texture_filter_anisotropic) { + diff_api.TexParameterf(tobj->target, GL_TEXTURE_MAX_ANISOTROPY_EXT, tobj->maxAnisotropy); + } +#endif +#ifdef CR_ARB_depth_texture + if (fromCtx->extensions.ARB_depth_texture) + diff_api.TexParameteri(tobj->target, GL_DEPTH_TEXTURE_MODE_ARB, tobj->depthMode); +#endif +#ifdef CR_ARB_shadow + if (fromCtx->extensions.ARB_shadow) { + diff_api.TexParameteri(tobj->target, GL_TEXTURE_COMPARE_MODE_ARB, tobj->compareMode); + diff_api.TexParameteri(tobj->target, GL_TEXTURE_COMPARE_FUNC_ARB, tobj->compareFunc); + } +#endif +#ifdef CR_ARB_shadow_ambient + if (fromCtx->extensions.ARB_shadow_ambient) { + diff_api.TexParameterf(tobj->target, GL_TEXTURE_COMPARE_FAIL_VALUE_ARB, tobj->compareFailValue); + } +#endif +#ifdef CR_SGIS_generate_mipmap + if (fromCtx->extensions.SGIS_generate_mipmap) { + diff_api.TexParameteri(tobj->target, GL_GENERATE_MIPMAP_SGIS, tobj->generateMipmap); + } +#endif + if (!alwaysDirty) + CLEARDIRTY(tobj->paramsBit[u], nbitID); + } + + /* now, if the texture images are dirty */ + if (alwaysDirty || CHECKDIRTY(tobj->imageBit, bitID)) + { + int lvl; + int face; + + switch (tobj->target) + { + case GL_TEXTURE_1D: + for (lvl = 0; lvl <= from->maxLevel; lvl++) + { + CRTextureLevel *tl = &(tobj->level[0][lvl]); + if (alwaysDirty || CHECKDIRTY(tl->dirty, bitID)) + { + if (tl->generateMipmap) { + diff_api.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, 1); + } + if (tl->width) + { + if (tl->compressed) { + diff_api.CompressedTexImage1DARB(GL_TEXTURE_1D, lvl, + tl->internalFormat, tl->width, + tl->border, tl->bytes, tl->img); + } + else { + /* alignment must be one */ + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); + if (tl->generateMipmap) { + diff_api.TexParameteri(GL_TEXTURE_1D, GL_GENERATE_MIPMAP_SGIS, 1); + } + diff_api.TexImage1D(GL_TEXTURE_1D, lvl, + tl->internalFormat, + tl->width, tl->border, + tl->format, tl->type, tl->img); + } + } + if (!alwaysDirty) + { + CLEARDIRTY(tl->dirty, nbitID); + } +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + else + { + crFree(tl->img); + tl->img = NULL; + } +#endif + } + } + break; + case GL_TEXTURE_2D: + for (lvl = 0; lvl <= from->maxLevel; lvl++) + { + CRTextureLevel *tl = &(tobj->level[0][lvl]); + if (alwaysDirty || CHECKDIRTY(tl->dirty, bitID)) + { + if (tl->generateMipmap) { + diff_api.TexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, 1); + } + + if (tl->width && tl->height) + { + if (tl->compressed) { + diff_api.CompressedTexImage2DARB(GL_TEXTURE_2D, lvl, + tl->internalFormat, tl->width, + tl->height, tl->border, + tl->bytes, tl->img); + } + else { + /* alignment must be one */ + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); + diff_api.TexImage2D(GL_TEXTURE_2D, lvl, + tl->internalFormat, + tl->width, tl->height, tl->border, + tl->format, tl->type, tl->img); + } + } + + if (!alwaysDirty) + { + CLEARDIRTY(tl->dirty, nbitID); + } +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + else + { + crFree(tl->img); + tl->img = NULL; + } +#endif + } + } + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_3D: + for (lvl = 0; lvl <= from->max3DLevel; lvl++) + { + CRTextureLevel *tl = &(tobj->level[0][lvl]); + if (alwaysDirty || CHECKDIRTY(tl->dirty, bitID)) + { + if (tl->generateMipmap) { + diff_api.TexParameteri(GL_TEXTURE_3D, GL_GENERATE_MIPMAP_SGIS, 1); + } + + if (tl->width && tl->height) + { + if (tl->compressed) { + diff_api.CompressedTexImage3DARB(GL_TEXTURE_3D, lvl, + tl->internalFormat, tl->width, + tl->height, tl->depth, + tl->border, tl->bytes, tl->img); + } + else { + /* alignment must be one */ + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); + diff_api.TexImage3D(GL_TEXTURE_3D, lvl, + tl->internalFormat, + tl->width, tl->height, tl->depth, + tl->border, tl->format, + tl->type, tl->img); + } + } + + if (!alwaysDirty) + { + CLEARDIRTY(tl->dirty, nbitID); + } +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + else + { + crFree(tl->img); + tl->img = NULL; + } +#endif + } + } + break; +#endif +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + /* only one level */ + for (lvl = 0; lvl <= from->maxRectLevel; lvl++) + { + CRTextureLevel *tl = &(tobj->level[0][lvl]); + if (alwaysDirty || CHECKDIRTY(tl->dirty, bitID)) + { + if (tl->width && tl->height) + { + if (tl->compressed) { + diff_api.CompressedTexImage2DARB(GL_TEXTURE_RECTANGLE_NV, lvl, + tl->internalFormat, tl->width, + tl->height, tl->border, + tl->bytes, tl->img); + } + else { + /* alignment must be one */ + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); + diff_api.TexImage2D(GL_TEXTURE_RECTANGLE_NV, lvl, + tl->internalFormat, + tl->width, tl->height, tl->border, + tl->format, tl->type, tl->img); + } + } + + if (!alwaysDirty) + { + CLEARDIRTY(tl->dirty, nbitID); + } +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + else + { + crFree(tl->img); + tl->img = NULL; + } +#endif + } + } + break; +#endif +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_ARB: + for (face = 0; face < 6; face++) + { + const GLenum target = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face; + for (lvl = 0; lvl <= from->maxCubeMapLevel; lvl++) + { + CRTextureLevel *tl = &(tobj->level[face][lvl]); + if (alwaysDirty || CHECKDIRTY(tl->dirty, bitID)) + { + if (tl->generateMipmap) { + diff_api.TexParameteri(GL_TEXTURE_CUBE_MAP_ARB, + GL_GENERATE_MIPMAP_SGIS, 1); + } + + if (tl->width && tl->height) + { + if (tl->compressed) { + diff_api.CompressedTexImage2DARB(target, + lvl, tl->internalFormat, + tl->width, tl->height, + tl->border, tl->bytes, tl->img); + } + else { + /* alignment must be one */ + diff_api.PixelStorei(GL_UNPACK_ROW_LENGTH, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_PIXELS, 0); + diff_api.PixelStorei(GL_UNPACK_SKIP_ROWS, 0); + diff_api.PixelStorei(GL_UNPACK_ALIGNMENT, 1); + diff_api.TexImage2D(target, lvl, + tl->internalFormat, + tl->width, tl->height, tl->border, + tl->format, tl->type, tl->img); + } + } + + if (!alwaysDirty) + { + CLEARDIRTY(tl->dirty, nbitID); + } +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + else + { + crFree(tl->img); + tl->img = NULL; + } +#endif + } + } /* for lvl */ + } /* for face */ + break; +#endif + default: + UNIMPLEMENTED(); + + } /* switch */ + } /* if (CHECKDIRTY(tobj->imageBit, bitID)) */ +} + + + +void +crStateTextureDiff( CRTextureBits *tb, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + CRTextureState *from = &(fromCtx->texture); + CRTextureState *to = &(toCtx->texture); + unsigned int u, t, j; + glAble able[2]; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + const GLboolean haveFragProg = fromCtx->extensions.ARB_fragment_program || fromCtx->extensions.NV_fragment_program; + + for (j=0;jlimits.maxTextureUnits; u++) + { + CRTextureObj **fromBinding = NULL; + CRTextureObj *tobj; + + /* take care of enables/disables */ + if (CHECKDIRTY(tb->enable[u], bitID)) + { + + /* Activate texture unit u if needed */ + if (fromCtx->texture.curTextureUnit != u) { + diff_api.ActiveTextureARB( GL_TEXTURE0_ARB + u); + fromCtx->texture.curTextureUnit = u; + } + + if (from->unit[u].enabled1D != to->unit[u].enabled1D) + { + able[to->unit[u].enabled1D](GL_TEXTURE_1D); + from->unit[u].enabled1D = to->unit[u].enabled1D; + } + if (from->unit[u].enabled2D != to->unit[u].enabled2D) + { + able[to->unit[u].enabled2D](GL_TEXTURE_2D); + from->unit[u].enabled2D = to->unit[u].enabled2D; + } +#ifdef CR_OPENGL_VERSION_1_2 + if (from->unit[u].enabled3D != to->unit[u].enabled3D) + { + able[to->unit[u].enabled3D](GL_TEXTURE_3D); + from->unit[u].enabled3D = to->unit[u].enabled3D; + } +#endif +#ifdef CR_ARB_texture_cube_map + if (fromCtx->extensions.ARB_texture_cube_map && + from->unit[u].enabledCubeMap != to->unit[u].enabledCubeMap) + { + able[to->unit[u].enabledCubeMap](GL_TEXTURE_CUBE_MAP_ARB); + from->unit[u].enabledCubeMap = to->unit[u].enabledCubeMap; + } +#endif +#ifdef CR_NV_texture_rectangle + if (fromCtx->extensions.NV_texture_rectangle && + from->unit[u].enabledRect != to->unit[u].enabledRect) + { + able[to->unit[u].enabledRect](GL_TEXTURE_RECTANGLE_NV); + from->unit[u].enabledRect = to->unit[u].enabledRect; + } +#endif + + /* texgen enables */ + if (from->unit[u].textureGen.s != to->unit[u].textureGen.s || + from->unit[u].textureGen.t != to->unit[u].textureGen.t || + from->unit[u].textureGen.r != to->unit[u].textureGen.r || + from->unit[u].textureGen.q != to->unit[u].textureGen.q) + { + able[to->unit[u].textureGen.s](GL_TEXTURE_GEN_S); + able[to->unit[u].textureGen.t](GL_TEXTURE_GEN_T); + able[to->unit[u].textureGen.r](GL_TEXTURE_GEN_R); + able[to->unit[u].textureGen.q](GL_TEXTURE_GEN_Q); + from->unit[u].textureGen = to->unit[u].textureGen; + } + CLEARDIRTY(tb->enable[u], nbitID); + } + + + /* Texgen coefficients */ + if (CHECKDIRTY(tb->objGen[u], bitID)) + { + if (fromCtx->texture.curTextureUnit != u) { + diff_api.ActiveTextureARB( u + GL_TEXTURE0_ARB ); + fromCtx->texture.curTextureUnit = u; + } + if (from->unit[u].objSCoeff.x != to->unit[u].objSCoeff.x || + from->unit[u].objSCoeff.y != to->unit[u].objSCoeff.y || + from->unit[u].objSCoeff.z != to->unit[u].objSCoeff.z || + from->unit[u].objSCoeff.w != to->unit[u].objSCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].objSCoeff.x; + f[1] = to->unit[u].objSCoeff.y; + f[2] = to->unit[u].objSCoeff.z; + f[3] = to->unit[u].objSCoeff.w; + diff_api.TexGenfv (GL_S, GL_OBJECT_PLANE, (const GLfloat *) f); + from->unit[u].objSCoeff = to->unit[u].objSCoeff; + } + if (from->unit[u].objTCoeff.x != to->unit[u].objTCoeff.x || + from->unit[u].objTCoeff.y != to->unit[u].objTCoeff.y || + from->unit[u].objTCoeff.z != to->unit[u].objTCoeff.z || + from->unit[u].objTCoeff.w != to->unit[u].objTCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].objTCoeff.x; + f[1] = to->unit[u].objTCoeff.y; + f[2] = to->unit[u].objTCoeff.z; + f[3] = to->unit[u].objTCoeff.w; + diff_api.TexGenfv (GL_T, GL_OBJECT_PLANE, (const GLfloat *) f); + from->unit[u].objTCoeff = to->unit[u].objTCoeff; + } + if (from->unit[u].objRCoeff.x != to->unit[u].objRCoeff.x || + from->unit[u].objRCoeff.y != to->unit[u].objRCoeff.y || + from->unit[u].objRCoeff.z != to->unit[u].objRCoeff.z || + from->unit[u].objRCoeff.w != to->unit[u].objRCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].objRCoeff.x; + f[1] = to->unit[u].objRCoeff.y; + f[2] = to->unit[u].objRCoeff.z; + f[3] = to->unit[u].objRCoeff.w; + diff_api.TexGenfv (GL_R, GL_OBJECT_PLANE, (const GLfloat *) f); + from->unit[u].objRCoeff = to->unit[u].objRCoeff; + } + if (from->unit[u].objQCoeff.x != to->unit[u].objQCoeff.x || + from->unit[u].objQCoeff.y != to->unit[u].objQCoeff.y || + from->unit[u].objQCoeff.z != to->unit[u].objQCoeff.z || + from->unit[u].objQCoeff.w != to->unit[u].objQCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].objQCoeff.x; + f[1] = to->unit[u].objQCoeff.y; + f[2] = to->unit[u].objQCoeff.z; + f[3] = to->unit[u].objQCoeff.w; + diff_api.TexGenfv (GL_Q, GL_OBJECT_PLANE, (const GLfloat *) f); + from->unit[u].objQCoeff = to->unit[u].objQCoeff; + } + CLEARDIRTY(tb->objGen[u], nbitID); + } + if (CHECKDIRTY(tb->eyeGen[u], bitID)) + { + if (fromCtx->texture.curTextureUnit != u) { + diff_api.ActiveTextureARB( u + GL_TEXTURE0_ARB ); + fromCtx->texture.curTextureUnit = u; + } + if (fromCtx->transform.matrixMode != GL_MODELVIEW) { + diff_api.MatrixMode(GL_MODELVIEW); + fromCtx->transform.matrixMode = GL_MODELVIEW; + } + diff_api.PushMatrix(); + diff_api.LoadIdentity(); + if (from->unit[u].eyeSCoeff.x != to->unit[u].eyeSCoeff.x || + from->unit[u].eyeSCoeff.y != to->unit[u].eyeSCoeff.y || + from->unit[u].eyeSCoeff.z != to->unit[u].eyeSCoeff.z || + from->unit[u].eyeSCoeff.w != to->unit[u].eyeSCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].eyeSCoeff.x; + f[1] = to->unit[u].eyeSCoeff.y; + f[2] = to->unit[u].eyeSCoeff.z; + f[3] = to->unit[u].eyeSCoeff.w; + diff_api.TexGenfv (GL_S, GL_EYE_PLANE, (const GLfloat *) f); + from->unit[u].eyeSCoeff = to->unit[u].eyeSCoeff; + } + if (from->unit[u].eyeTCoeff.x != to->unit[u].eyeTCoeff.x || + from->unit[u].eyeTCoeff.y != to->unit[u].eyeTCoeff.y || + from->unit[u].eyeTCoeff.z != to->unit[u].eyeTCoeff.z || + from->unit[u].eyeTCoeff.w != to->unit[u].eyeTCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].eyeTCoeff.x; + f[1] = to->unit[u].eyeTCoeff.y; + f[2] = to->unit[u].eyeTCoeff.z; + f[3] = to->unit[u].eyeTCoeff.w; + diff_api.TexGenfv (GL_T, GL_EYE_PLANE, (const GLfloat *) f); + from->unit[u].eyeTCoeff = to->unit[u].eyeTCoeff; + } + if (from->unit[u].eyeRCoeff.x != to->unit[u].eyeRCoeff.x || + from->unit[u].eyeRCoeff.y != to->unit[u].eyeRCoeff.y || + from->unit[u].eyeRCoeff.z != to->unit[u].eyeRCoeff.z || + from->unit[u].eyeRCoeff.w != to->unit[u].eyeRCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].eyeRCoeff.x; + f[1] = to->unit[u].eyeRCoeff.y; + f[2] = to->unit[u].eyeRCoeff.z; + f[3] = to->unit[u].eyeRCoeff.w; + diff_api.TexGenfv (GL_R, GL_EYE_PLANE, (const GLfloat *) f); + from->unit[u].eyeRCoeff = to->unit[u].eyeRCoeff; + } + if (from->unit[u].eyeQCoeff.x != to->unit[u].eyeQCoeff.x || + from->unit[u].eyeQCoeff.y != to->unit[u].eyeQCoeff.y || + from->unit[u].eyeQCoeff.z != to->unit[u].eyeQCoeff.z || + from->unit[u].eyeQCoeff.w != to->unit[u].eyeQCoeff.w) + { + GLfloat f[4]; + f[0] = to->unit[u].eyeQCoeff.x; + f[1] = to->unit[u].eyeQCoeff.y; + f[2] = to->unit[u].eyeQCoeff.z; + f[3] = to->unit[u].eyeQCoeff.w; + diff_api.TexGenfv (GL_Q, GL_EYE_PLANE, (const GLfloat *) f); + from->unit[u].eyeQCoeff = to->unit[u].eyeQCoeff; + } + diff_api.PopMatrix(); + CLEARDIRTY(tb->eyeGen[u], nbitID); + } + if (CHECKDIRTY(tb->genMode[u], bitID)) + { + if (fromCtx->texture.curTextureUnit != u) { + diff_api.ActiveTextureARB( u + GL_TEXTURE0_ARB ); + fromCtx->texture.curTextureUnit = u; + } + if (from->unit[u].gen.s != to->unit[u].gen.s || + from->unit[u].gen.t != to->unit[u].gen.t || + from->unit[u].gen.r != to->unit[u].gen.r || + from->unit[u].gen.q != to->unit[u].gen.q) + { + diff_api.TexGeni (GL_S, GL_TEXTURE_GEN_MODE, to->unit[u].gen.s); + diff_api.TexGeni (GL_T, GL_TEXTURE_GEN_MODE, to->unit[u].gen.t); + diff_api.TexGeni (GL_R, GL_TEXTURE_GEN_MODE, to->unit[u].gen.r); + diff_api.TexGeni (GL_Q, GL_TEXTURE_GEN_MODE, to->unit[u].gen.q); + from->unit[u].gen = to->unit[u].gen; + } + CLEARDIRTY(tb->genMode[u], nbitID); + } + + /* Texture enviroment */ + if (CHECKDIRTY(tb->envBit[u], bitID)) + { + if (from->unit[u].envMode != to->unit[u].envMode) + { + diff_api.TexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, to->unit[u].envMode); + from->unit[u].envMode = to->unit[u].envMode; + } + if (from->unit[u].envColor.r != to->unit[u].envColor.r || + from->unit[u].envColor.g != to->unit[u].envColor.g || + from->unit[u].envColor.b != to->unit[u].envColor.b || + from->unit[u].envColor.a != to->unit[u].envColor.a) + { + GLfloat f[4]; + f[0] = to->unit[u].envColor.r; + f[1] = to->unit[u].envColor.g; + f[2] = to->unit[u].envColor.b; + f[3] = to->unit[u].envColor.a; + diff_api.TexEnvfv (GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, (const GLfloat *) f); + from->unit[u].envColor = to->unit[u].envColor; + } +#ifdef CR_ARB_texture_env_combine + if (from->unit[u].combineModeRGB != to->unit[u].combineModeRGB) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, to->unit[u].combineModeRGB); + from->unit[u].combineModeRGB = to->unit[u].combineModeRGB; + } + if (from->unit[u].combineModeA != to->unit[u].combineModeA) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_ARB, to->unit[u].combineModeA); + from->unit[u].combineModeA = to->unit[u].combineModeA; + } + if (from->unit[u].combineSourceRGB[0] != to->unit[u].combineSourceRGB[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, to->unit[u].combineSourceRGB[0]); + from->unit[u].combineSourceRGB[0] = to->unit[u].combineSourceRGB[0]; + } + if (from->unit[u].combineSourceRGB[1] != to->unit[u].combineSourceRGB[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, to->unit[u].combineSourceRGB[1]); + from->unit[u].combineSourceRGB[1] = to->unit[u].combineSourceRGB[1]; + } + if (from->unit[u].combineSourceRGB[2] != to->unit[u].combineSourceRGB[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB_ARB, to->unit[u].combineSourceRGB[2]); + from->unit[u].combineSourceRGB[2] = to->unit[u].combineSourceRGB[2]; + } + if (from->unit[u].combineSourceA[0] != to->unit[u].combineSourceA[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, to->unit[u].combineSourceA[0]); + from->unit[u].combineSourceA[0] = to->unit[u].combineSourceA[0]; + } + if (from->unit[u].combineSourceA[1] != to->unit[u].combineSourceA[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, to->unit[u].combineSourceA[1]); + from->unit[u].combineSourceA[1] = to->unit[u].combineSourceA[1]; + } + if (from->unit[u].combineSourceA[2] != to->unit[u].combineSourceA[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA_ARB, to->unit[u].combineSourceA[2]); + from->unit[u].combineSourceA[2] = to->unit[u].combineSourceA[2]; + } + if (from->unit[u].combineOperandRGB[0] != to->unit[u].combineOperandRGB[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, to->unit[u].combineOperandRGB[0]); + from->unit[u].combineOperandRGB[0] = to->unit[u].combineOperandRGB[0]; + } + if (from->unit[u].combineOperandRGB[1] != to->unit[u].combineOperandRGB[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, to->unit[u].combineOperandRGB[1]); + from->unit[u].combineOperandRGB[1] = to->unit[u].combineOperandRGB[1]; + } + if (from->unit[u].combineOperandRGB[2] != to->unit[u].combineOperandRGB[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB_ARB, to->unit[u].combineOperandRGB[2]); + from->unit[u].combineOperandRGB[2] = to->unit[u].combineOperandRGB[2]; + } + if (from->unit[u].combineOperandA[0] != to->unit[u].combineOperandA[0]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, to->unit[u].combineOperandA[0]); + from->unit[u].combineOperandA[0] = to->unit[u].combineOperandA[0]; + } + if (from->unit[u].combineOperandA[1] != to->unit[u].combineOperandA[1]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, to->unit[u].combineOperandA[1]); + from->unit[u].combineOperandA[1] = to->unit[u].combineOperandA[1]; + } + if (from->unit[u].combineOperandA[2] != to->unit[u].combineOperandA[2]) + { + diff_api.TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA_ARB, to->unit[u].combineOperandA[2]); + from->unit[u].combineOperandA[2] = to->unit[u].combineOperandA[2]; + } + if (from->unit[u].combineScaleRGB != to->unit[u].combineScaleRGB) + { + diff_api.TexEnvf(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, to->unit[u].combineScaleRGB); + from->unit[u].combineScaleRGB = to->unit[u].combineScaleRGB; + } + if (from->unit[u].combineScaleA != to->unit[u].combineScaleA) + { + diff_api.TexEnvf(GL_TEXTURE_ENV, GL_ALPHA_SCALE, to->unit[u].combineScaleA); + from->unit[u].combineScaleA = to->unit[u].combineScaleA; + } +#endif +#if CR_EXT_texture_lod_bias + if (from->unit[u].lodBias != to->unit[u].lodBias) + { + diff_api.TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, to->unit[u].lodBias); + from->unit[u].lodBias = to->unit[u].lodBias; + } +#endif + CLEARDIRTY(tb->envBit[u], nbitID); + } + + /* loop over texture targets */ + for (t = 0; t < 5; t++) + { + tobj = NULL; + + switch (t) { + case 0: + if (to->unit[u].enabled1D || haveFragProg) { + tobj = to->unit[u].currentTexture1D; + fromBinding = &(from->unit[u].currentTexture1D); + } + break; + case 1: + if (to->unit[u].enabled2D || haveFragProg) { + tobj = to->unit[u].currentTexture2D; + fromBinding = &(from->unit[u].currentTexture2D); + } + break; +#ifdef CR_OPENGL_VERSION_1_2 + case 2: + if (to->unit[u].enabled3D || haveFragProg) { + tobj = to->unit[u].currentTexture3D; + fromBinding = &(from->unit[u].currentTexture3D); + } + break; +#endif +#ifdef CR_ARB_texture_cube_map + case 3: + if (fromCtx->extensions.ARB_texture_cube_map && + (to->unit[u].enabledCubeMap || haveFragProg)) { + tobj = to->unit[u].currentTextureCubeMap; + fromBinding = &(from->unit[u].currentTextureCubeMap); + } + break; +#endif +#ifdef CR_NV_texture_rectangle + case 4: + if (fromCtx->extensions.NV_texture_rectangle && + (to->unit[u].enabledRect || haveFragProg)) { + tobj = to->unit[u].currentTextureRect; + fromBinding = &(from->unit[u].currentTextureRect); + } + break; +#endif + default: + /* maybe don't support cube maps or rects */ + continue; + } + + if (!tobj) { + continue; /* with next target */ + } + + /* Activate texture unit u if needed */ + if (fromCtx->texture.curTextureUnit != u) { + diff_api.ActiveTextureARB( GL_TEXTURE0_ARB + u); + fromCtx->texture.curTextureUnit = u; + } + + /* bind this texture if needed */ + if (CHECKDIRTY(tb->current[u], bitID)) + { + if (*fromBinding != tobj) + { + diff_api.BindTexture(tobj->target, crStateGetTextureObjHWID(tobj)); + *fromBinding = tobj; + } + } + + /* now, if the texture object is dirty */ + if (CHECKDIRTY(tobj->dirty, bitID)) + { + crStateTextureObjectDiff(fromCtx, bitID, nbitID, tobj, GL_FALSE); + } + CLEARDIRTY(tobj->dirty, nbitID); + + } /* loop over targets */ + + CLEARDIRTY(tb->current[u], nbitID); + + } /* loop over units */ + + /* After possible fiddling with the active unit, put it back now */ + if (fromCtx->texture.curTextureUnit != toCtx->texture.curTextureUnit) { + diff_api.ActiveTextureARB( toCtx->texture.curTextureUnit + GL_TEXTURE0_ARB ); + fromCtx->texture.curTextureUnit = toCtx->texture.curTextureUnit; + } + if (fromCtx->transform.matrixMode != toCtx->transform.matrixMode) { + diff_api.MatrixMode(toCtx->transform.matrixMode); + fromCtx->transform.matrixMode = toCtx->transform.matrixMode; + } + + CLEARDIRTY(tb->dirty, nbitID); +} + + + +struct callback_info +{ + CRbitvalue *bitID, *nbitID; + CRContext *g; + GLboolean bForceUpdate; +}; + + +/* Called by crHashtableWalk() below */ +static void +DiffTextureObjectCallback( unsigned long key, void *texObj , void *cbData) +{ + struct callback_info *info = (struct callback_info *) cbData; + CRTextureObj *tobj = (CRTextureObj *) texObj; + (void)key; + + /* + printf(" Checking %d 0x%x bitid=0x%x\n",tobj->name, tobj->dirty[0], info->bitID[0]); + */ + if (info->bForceUpdate || CHECKDIRTY(tobj->dirty, info->bitID)) { + /* + printf(" Found Dirty! %d\n", tobj->name); + */ + crStateTextureObjectDiff(info->g, info->bitID, info->nbitID, tobj, info->bForceUpdate); + CLEARDIRTY(tobj->dirty, info->nbitID); + } +} + + +/* + * This isn't used right now, but will be used in the future to fix some + * potential display list problems. Specifically, if glBindTexture is + * in a display list, we have to be sure that all outstanding texture object + * updates are resolved before the list is called. If we don't, we may + * wind up binding texture objects that are stale. + */ +void +crStateDiffAllTextureObjects( CRContext *g, CRbitvalue *bitID, GLboolean bForceUpdate ) +{ + CRbitvalue nbitID[CR_MAX_BITARRAY]; + struct callback_info info; + int j; + int origUnit, orig1D, orig2D, orig3D, origCube, origRect; + + for (j = 0; j < CR_MAX_BITARRAY; j++) + nbitID[j] = ~bitID[j]; + + info.bitID = bitID; + info.nbitID = nbitID; + info.g = g; + info.bForceUpdate = bForceUpdate; + + /* save current texture bindings */ + origUnit = g->texture.curTextureUnit; + orig1D = crStateGetTextureObjHWID(g->texture.unit[0].currentTexture1D); + orig2D = crStateGetTextureObjHWID(g->texture.unit[0].currentTexture2D); + orig3D = crStateGetTextureObjHWID(g->texture.unit[0].currentTexture3D); +#ifdef CR_ARB_texture_cube_map + origCube = crStateGetTextureObjHWID(g->texture.unit[0].currentTextureCubeMap); +#endif +#ifdef CR_NV_texture_rectangle + origRect = crStateGetTextureObjHWID(g->texture.unit[0].currentTextureRect); +#endif + + /* use texture unit 0 for updates */ + diff_api.ActiveTextureARB(GL_TEXTURE0_ARB); + + /* diff all the textures */ + crHashtableWalk(g->shared->textureTable, DiffTextureObjectCallback, (void *) &info); + + /* default ones */ + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.base1D, GL_TRUE); + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.base2D, GL_TRUE); + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.base3D, GL_TRUE); + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.proxy1D, GL_TRUE); + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.proxy2D, GL_TRUE); + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.proxy3D, GL_TRUE); +#ifdef CR_ARB_texture_cube_map + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.baseCubeMap, GL_TRUE); + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.proxyCubeMap, GL_TRUE); +#endif +#ifdef CR_NV_texture_rectangle + if (g->extensions.NV_texture_rectangle) + { + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.baseRect, GL_TRUE); + crStateTextureObjectDiff(g, bitID, nbitID, &g->texture.proxyRect, GL_TRUE); + } +#endif + + /* restore bindings */ + /* first restore unit 0 bindings the unit 0 is active currently */ + diff_api.BindTexture(GL_TEXTURE_1D, orig1D); + diff_api.BindTexture(GL_TEXTURE_2D, orig2D); + diff_api.BindTexture(GL_TEXTURE_3D, orig3D); +#ifdef CR_ARB_texture_cube_map + diff_api.BindTexture(GL_TEXTURE_CUBE_MAP_ARB, origCube); +#endif +#ifdef CR_NV_texture_rectangle + diff_api.BindTexture(GL_TEXTURE_RECTANGLE_NV, origRect); +#endif + /* now restore the proper active unit */ + diff_api.ActiveTextureARB(GL_TEXTURE0_ARB + origUnit); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_teximage.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_teximage.c new file mode 100644 index 00000000..295ea36f --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_teximage.c @@ -0,0 +1,1762 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_texture.h" +#include "cr_pixeldata.h" +#include "cr_string.h" +#include "cr_mem.h" +#include "cr_version.h" +#include "state_internals.h" + +#ifndef IN_GUEST +/*# define CR_DUMP_TEXTURES_2D*/ +#endif + +#ifdef CR_DUMP_TEXTURES_2D +static int _tnum = 0; + +#pragma pack(1) +typedef struct tgaheader_tag +{ + char idlen; + + char colormap; + + char imagetype; + + short cm_index; + short cm_len; + char cm_entrysize; + + short x, y, w, h; + char depth; + char imagedesc; + +} tgaheader_t; +#pragma pack() + +static crDumpTGA(short w, short h, char* data) +{ + char fname[200]; + tgaheader_t header; + FILE *out; + + if (!w || !h) return; + + sprintf(fname, "tex%i.tga", _tnum++); + out = fopen(fname, "w"); + if (!out) crError("can't create %s!", fname); + + header.idlen = 0; + header.colormap = 0; + header.imagetype = 2; + header.cm_index = 0; + header.cm_len = 0; + header.cm_entrysize = 0; + header.x = 0; + header.y = 0; + header.w = w; + header.h = h; + header.depth = 32; + header.imagedesc = 0x08; + fwrite(&header, sizeof(header), 1, out); + + fwrite(data, w*h*4, 1, out); + + fclose(out); +} +#endif + + +static int +bitcount(int value) +{ + int bits = 0; + for (; value > 0; value >>= 1) { + if (value & 0x1) + bits++; + } + return bits; +} + + +/** + * Return 1 if the target is a proxy target, 0 otherwise. + */ +static GLboolean +IsProxyTarget(GLenum target) +{ + return (target == GL_PROXY_TEXTURE_1D || + target == GL_PROXY_TEXTURE_2D || + target == GL_PROXY_TEXTURE_3D || + target == GL_PROXY_TEXTURE_RECTANGLE_NV || + target == GL_PROXY_TEXTURE_CUBE_MAP); +} + + +/** + * Test if a texture width, height or depth is legal. + * It must be true that 0 <= size <= max. + * Furthermore, if the ARB_texture_non_power_of_two extension isn't + * present, size must also be a power of two. + */ +static GLboolean +isLegalSize(CRContext *g, GLsizei size, GLsizei max) +{ + if (size < 0 || size > max) + return GL_FALSE; + if (!g->extensions.ARB_texture_non_power_of_two) { + /* check for power of two */ + if (size > 0 && bitcount(size) != 1) + return GL_FALSE; + } + return GL_TRUE; +} + + +/** + * Return the max legal texture level parameter for the given target. + */ +static GLint +MaxTextureLevel(CRContext *g, GLenum target) +{ + CRTextureState *t = &(g->texture); + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return t->maxLevel; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return t->max3DLevel; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return t->maxCubeMapLevel; + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + return t->maxRectLevel; + default: + return 0; + } +} + + +/** + * If GL_GENERATE_MIPMAP_SGIS is true and we modify the base level texture + * image we have to finish the mipmap. + * All we really have to do is fill in the width/height/format/etc for the + * remaining image levels. The image data doesn't matter here - the back- + * end OpenGL library will fill those in. + */ +static void +generate_mipmap(CRTextureObj *tobj, GLenum target) +{ + CRTextureLevel *levels; + GLint level, width, height, depth; + + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { + levels = tobj->level[target - GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB]; + } + else { + levels = tobj->level[0]; + } + + width = levels[tobj->baseLevel].width; + height = levels[tobj->baseLevel].height; + depth = levels[tobj->baseLevel].depth; + + for (level = tobj->baseLevel + 1; level <= tobj->maxLevel; level++) + { + if (width > 1) + width /= 2; + if (height > 1) + height /= 2; + if (depth > 1) + depth /= 2; + levels[level].width = width; + levels[level].height = height; + levels[level].depth = depth; + levels[level].internalFormat = levels[tobj->baseLevel].internalFormat; + levels[level].format = levels[tobj->baseLevel].format; + levels[level].type = levels[tobj->baseLevel].type; +#ifdef CR_ARB_texture_compression + levels[level].compressed = levels[tobj->baseLevel].compressed; +#endif + levels[level].texFormat = levels[tobj->baseLevel].texFormat; + if (width == 1 && height == 1 && depth == 1) + break; + } + + /* Set this flag so when we do the state diff, we enable GENERATE_MIPMAP + * prior to calling diff.TexImage(). + */ + levels[tobj->baseLevel].generateMipmap = GL_TRUE; +} + + +/** + * Given a texture target and level, return pointers to the corresponding + * texture object and texture image level. + */ +void +crStateGetTextureObjectAndImage(CRContext *g, GLenum texTarget, GLint level, + CRTextureObj **obj, CRTextureLevel **img) +{ + CRTextureState *t = &(g->texture); + CRTextureUnit *unit = t->unit + t->curTextureUnit; + + switch (texTarget) { + case GL_TEXTURE_1D: + *obj = unit->currentTexture1D; + *img = unit->currentTexture1D->level[0] + level; + return; + case GL_PROXY_TEXTURE_1D: + *obj = &(t->proxy1D); + *img = t->proxy1D.level[0] + level; + return; + case GL_TEXTURE_2D: + *obj = unit->currentTexture2D; + *img = unit->currentTexture2D->level[0] + level; + return; + case GL_PROXY_TEXTURE_2D: + *obj = &(t->proxy2D); + *img = t->proxy2D.level[0] + level; + return; + case GL_TEXTURE_3D: + *obj = unit->currentTexture3D; + *img = unit->currentTexture3D->level[0] + level; + return; + case GL_PROXY_TEXTURE_3D: + *obj = &(t->proxy3D); + *img = t->proxy3D.level[0] + level; + return; + default: + /* fall-through */ + ; + } + +#ifdef CR_NV_texture_rectangle + if (g->extensions.NV_texture_rectangle) { + switch (texTarget) { + case GL_PROXY_TEXTURE_RECTANGLE_NV: + *obj = &(t->proxyRect); + *img = t->proxyRect.level[0] + level; + return; + case GL_TEXTURE_RECTANGLE_NV: + *obj = unit->currentTextureRect; + *img = unit->currentTextureRect->level[0] + level; + return; + default: + /* fall-through */ + ; + } + } +#endif + +#ifdef CR_ARB_texture_cube_map + if (g->extensions.ARB_texture_cube_map) { + switch (texTarget) { + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + *obj = &(t->proxyCubeMap); + *img = t->proxyCubeMap.level[0] + level; + return; + case GL_TEXTURE_CUBE_MAP_ARB: + *obj = unit->currentTextureCubeMap; + *img = NULL; + return; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + *obj = unit->currentTextureCubeMap; + *img = unit->currentTextureCubeMap->level[0] + level; + return; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + *obj = unit->currentTextureCubeMap; + *img = unit->currentTextureCubeMap->level[1] + level; + return; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + *obj = unit->currentTextureCubeMap; + *img = unit->currentTextureCubeMap->level[2] + level; + return; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + *obj = unit->currentTextureCubeMap; + *img = unit->currentTextureCubeMap->level[3] + level; + return; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + *obj = unit->currentTextureCubeMap; + *img = unit->currentTextureCubeMap->level[4] + level; + return; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + *obj = unit->currentTextureCubeMap; + *img = unit->currentTextureCubeMap->level[5] + level; + return; + default: + /* fall-through */ + ; + } + } +#endif + + crWarning("unexpected texTarget 0x%x", texTarget); + *obj = NULL; + *img = NULL; +} + + +/** + * Do parameter error checking for glTexImagexD functions. + * We'll call crStateError if we detect any errors, unless it's a proxy target. + * Return GL_TRUE if any errors, GL_FALSE if no errors. + */ +static GLboolean +ErrorCheckTexImage(GLuint dims, GLenum target, GLint level, + GLsizei width, GLsizei height, GLsizei depth, GLint border) +{ + CRContext *g = GetCurrentContext(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glTexImage%uD called in Begin/End", dims); + return GL_TRUE; + } + + /* + * Test target + */ + switch (target) + { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + if (dims != 1) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexImage(invalid target=0x%x)", target); + return GL_TRUE; + } + break; + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + if (dims != 2) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexImage(invalid target=0x%x)", target); + return GL_TRUE; + } + break; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + if (dims != 3) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexImage(invalid target=0x%x)", target); + return GL_TRUE; + } + break; +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + case GL_PROXY_TEXTURE_RECTANGLE_NV: + if (dims != 2 || !g->extensions.NV_texture_rectangle) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexImage2D(invalid target=0x%x)", target); + return GL_TRUE; + } + break; +#endif +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + if (dims != 2 || !g->extensions.ARB_texture_cube_map) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexImage2D(invalid target=0x%x)", target); + return GL_TRUE; + } + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexImage%uD(invalid target=0x%x)", dims, target); + return GL_TRUE; + } + + /* + * Test level + */ + if (level < 0 || level > MaxTextureLevel(g, target)) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage%uD(level=%d)", dims, level); + return GL_TRUE; + } + + /* + * Test border + */ + if (border != 0 && border != 1) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage%uD(border=%d)", dims, border); + return GL_TRUE; + } + + if ((target == GL_PROXY_TEXTURE_RECTANGLE_NV || + target == GL_TEXTURE_RECTANGLE_NV) && border != 0) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage2D(border=%d)", border); + return GL_TRUE; + } + + /* + * Test width, height, depth + */ + if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) { + if (!isLegalSize(g, width - 2 * border, g->limits.maxTextureSize)) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage1D(width=%d)", width); + return GL_TRUE; + } + } + else if (target == GL_PROXY_TEXTURE_2D || target == GL_TEXTURE_2D) { + if (!isLegalSize(g, width - 2 * border, g->limits.maxTextureSize) || + !isLegalSize(g, height - 2 * border, g->limits.maxTextureSize)) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage2D(width=%d, height=%d)", width, height); + return GL_TRUE; + } + } + else if (target == GL_PROXY_TEXTURE_3D || target == GL_TEXTURE_3D) { + if (!isLegalSize(g, width - 2 * border, g->limits.max3DTextureSize) || + !isLegalSize(g, height - 2 * border, g->limits.max3DTextureSize) || + !isLegalSize(g, depth - 2 * border, g->limits.max3DTextureSize)) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage3D(width=%d, height=%d, depth=%d)", + width, height, depth); + return GL_TRUE; + } + } + else if (target == GL_PROXY_TEXTURE_RECTANGLE_NV || + target == GL_TEXTURE_RECTANGLE_NV) { + if (width < 0 || width > (int) g->limits.maxRectTextureSize || + height < 0 || height > (int) g->limits.maxRectTextureSize) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage2D(width=%d, height=%d)", width, height); + return GL_TRUE; + } + } + else { + /* cube map */ + if (!isLegalSize(g, width - 2*border, g->limits.maxCubeMapTextureSize) || + !isLegalSize(g, height - 2*border, g->limits.maxCubeMapTextureSize) || + width != height) { + if (!IsProxyTarget(target)) + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexImage2D(width=%d, height=%d)", width, height); + return GL_TRUE; + } + } + + /* OK, no errors */ + return GL_FALSE; +} + + +/** + * Do error check for glTexSubImage() functions. + * We'll call crStateError if we detect any errors. + * Return GL_TRUE if any errors, GL_FALSE if no errors. + */ +static GLboolean +ErrorCheckTexSubImage(GLuint dims, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + CRTextureLevel *tl; + + if (g->current.inBeginEnd) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glTexSubImage%uD called in Begin/End", dims); + return GL_TRUE; + } + + if (dims == 1) { + if (target != GL_TEXTURE_1D) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexSubImage1D(target=0x%x)", target); + return GL_TRUE; + } + } + else if (dims == 2) { + if (target != GL_TEXTURE_2D && + target != GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target != GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB && + target != GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB && + target != GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB && + target != GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB && + target != GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && + target != GL_TEXTURE_RECTANGLE_NV) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexSubImage2D(target=0x%x)", target); + return GL_TRUE; + } + } + else if (dims == 3) { + if (target != GL_TEXTURE_3D) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexSubImage3D(target=0x%x)", target); + return GL_TRUE; + } + } + + /* test level */ + if (level < 0 || level > MaxTextureLevel(g, target)) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexSubImage%uD(level=%d)", dims, level); + return GL_TRUE; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + if (!tobj || !tl) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexSubImage%uD(target or level)", dims); + return GL_TRUE; + } + + /* test x/y/zoffset and size */ + if (xoffset < -tl->border || xoffset + width > tl->width) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexSubImage%uD(xoffset=%d + width=%d > %d)", + dims, xoffset, width, tl->width); + return GL_TRUE; + } + if (dims > 1 && (yoffset < -tl->border || yoffset + height > tl->height)) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexSubImage%uD(yoffset=%d + height=%d > %d)", + dims, yoffset, height, tl->height); + return GL_TRUE; + } + if (dims > 2 && (zoffset < -tl->border || zoffset + depth > tl->depth)) { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glTexSubImage%uD(zoffset=%d and/or depth=%d)", + dims, zoffset, depth); + return GL_TRUE; + } + + /* OK, no errors */ + return GL_FALSE; +} + + + +void STATE_APIENTRY +crStateTexImage1D(GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLint border, GLenum format, + GLenum type, const GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + CRClientState *c = &(g->client); +#endif + CRTextureObj *tobj; + CRTextureLevel *tl; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); +#ifdef CR_STATE_NO_TEXTURE_IMAGE_STORE + (void)pixels; +#endif + + FLUSH(); + + if (ErrorCheckTexImage(1, target, level, width, 1, 1, border)) { + if (IsProxyTarget(target)) { + /* clear all state, but don't generate error */ + crStateTextureInitTextureObj(g, &(t->proxy1D), 0, GL_TEXTURE_1D); + } + else { + /* error was already recorded */ + } + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + + if (IsProxyTarget(target)) + tl->bytes = 0; + else + tl->bytes = crImageSize(format, type, width, 1); + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + if (tl->bytes) + { + /* this is not a proxy texture target so alloc storage */ + if (tl->img) + crFree(tl->img); + tl->img = (GLubyte *) crAlloc(tl->bytes); + if (!tl->img) + { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, + "glTexImage1D out of memory"); + return; + } + if (pixels) + crPixelCopy1D((GLvoid *) tl->img, format, type, + pixels, format, type, width, &(c->unpack)); + } +#endif + + tl->width = width; + tl->height = 1; + tl->depth = 1; + tl->format = format; + tl->border = border; + tl->internalFormat = internalFormat; + crStateTextureInitTextureFormat(tl, internalFormat); + tl->type = type; + tl->compressed = GL_FALSE; + if (width) + tl->bytesPerPixel = tl->bytes / width; + else + tl->bytesPerPixel = 0; + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + /* XXX may need to do some fine-tuning here for proxy textures */ + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +static void crStateNukeMipmaps(CRTextureObj *tobj) +{ + int i, face; + + for (face = 0; face < 6; face++) + { + CRTextureLevel *levels = tobj->level[face]; + + if (levels) + { + for (i = 0; i < CR_MAX_MIPMAP_LEVELS; i++) + { + if (levels[i].img) + { + crFree(levels[i].img); + } + levels[i].img = NULL; + levels[i].bytes = 0; + levels[i].internalFormat = GL_ONE; + levels[i].format = GL_RGBA; + levels[i].type = GL_UNSIGNED_BYTE; + + } + } + } +} + +void STATE_APIENTRY +crStateCopyTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj = NULL; + CRTextureLevel *tl = NULL; + (void)x; (void)y; + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + + if (tobj == NULL || tl == NULL) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "crStateCopyTexImage2D: invalid target: 0x%x", target); + return; + } + + crStateNukeMipmaps(tobj); + + tl->bytes = crImageSize(GL_RGBA, GL_UNSIGNED_BYTE, width, height); + + tl->width = width; + tl->height = height; + tl->depth = 1; + tl->format = GL_RGBA; + tl->internalFormat = internalFormat; + crStateTextureInitTextureFormat(tl, internalFormat); + tl->border = border; + tl->type = GL_UNSIGNED_BYTE; + tl->compressed = GL_FALSE; + if (width && height) + { + tl->bytesPerPixel = tl->bytes / (width * height); + } + else + tl->bytesPerPixel = 0; + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif +} + +void STATE_APIENTRY +crStateTexImage2D(GLenum target, GLint level, GLint internalFormat, + GLsizei width, GLsizei height, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + CRClientState *c = &(g->client); +#endif + CRTextureObj *tobj = NULL; + CRTextureLevel *tl = NULL; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + // Distributed textures are not used by VBox + const int is_distrib = 0; // ((type == GL_TRUE) || (type == GL_FALSE)); + + FLUSH(); + + /* NOTE: we skip parameter error checking if this is a distributed + * texture! The user better provide correct parameters!!! + */ + if (!is_distrib + && ErrorCheckTexImage(2, target, level, width, height, 1, border)) { + if (IsProxyTarget(target)) { + /* clear all state, but don't generate error */ + crStateTextureInitTextureObj(g, &(t->proxy2D), 0, GL_TEXTURE_2D); + } + else { + /* error was already recorded */ + } + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + + if (level==tobj->baseLevel && (tl->width!=width || tl->height!=height)) + { + crStateNukeMipmaps(tobj); + } + + /* compute size of image buffer */ + if (is_distrib) { + tl->bytes = crStrlen((char *) pixels) + 1; + tl->bytes += crImageSize(format, GL_UNSIGNED_BYTE, width, height); + } + else if (IsProxyTarget(target)) { + tl->bytes = 0; + } + else { + tl->bytes = crImageSize(format, type, width, height); + } + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + /* allocate the image buffer and fill it */ + if (tl->bytes) + { + /* this is not a proxy texture target so alloc storage */ + if (tl->img) + crFree(tl->img); + tl->img = (GLubyte *) crAlloc(tl->bytes); + if (!tl->img) + { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, + "glTexImage2D out of memory"); + return; + } + if (pixels) + { + if (is_distrib) + { + crMemcpy((void *) tl->img, (void *) pixels, tl->bytes); + } + else + { + crPixelCopy2D(width, height, + (GLvoid *) tl->img, format, type, NULL, /* dst */ + pixels, format, type, &(c->unpack)); /* src */ + } + } + } +#endif + + tl->width = width; + tl->height = height; + tl->depth = 1; + tl->format = format; + tl->internalFormat = internalFormat; + crStateTextureInitTextureFormat(tl, internalFormat); + tl->border = border; + tl->type = type; + tl->compressed = GL_FALSE; + if (width && height) + { + if (is_distrib) + tl->bytesPerPixel = 3; /* only support GL_RGB */ + else + tl->bytesPerPixel = tl->bytes / (width * height); + } + else + tl->bytesPerPixel = 0; + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + /* XXX may need to do some fine-tuning here for proxy textures */ + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + +#ifdef CR_DUMP_TEXTURES_2D + if (pixels) + { + GLint w,h; + char *data; + + diff_api.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &w); + diff_api.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &h); + + data = crAlloc(w*h*4); + if (!data) crError("no memory!"); + diff_api.GetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, data); + crDumpTGA(w, h, data); + crFree(data); + } +#endif +} + +#if defined( CR_OPENGL_VERSION_1_2 ) || defined( GL_EXT_texture3D ) +void STATE_APIENTRY +crStateTexImage3D(GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, const GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + CRClientState *c = &(g->client); +#endif + CRTextureObj *tobj = NULL; + CRTextureLevel *tl = NULL; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + (void)pixels; + + FLUSH(); + + if (ErrorCheckTexImage(3, target, level, width, height, depth, border)) { + if (IsProxyTarget(target)) { + /* clear all state, but don't generate error */ + crStateTextureInitTextureObj(g, &(t->proxy3D), 0, GL_TEXTURE_3D); + } + else { + /* error was already recorded */ + } + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + + if (IsProxyTarget(target)) + tl->bytes = 0; + else + tl->bytes = crTextureSize(format, type, width, height, depth); + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + if (tl->bytes) + { + /* this is not a proxy texture target so alloc storage */ + if (tl->img) + crFree(tl->img); + tl->img = (GLubyte *) crAlloc(tl->bytes); + if (!tl->img) + { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, + "glTexImage3D out of memory"); + return; + } + if (pixels) + crPixelCopy3D(width, height, depth, (GLvoid *) (tl->img), format, type, + NULL, pixels, format, type, &(c->unpack)); + } +#endif + + tl->internalFormat = internalFormat; + tl->border = border; + tl->width = width; + tl->height = height; + tl->depth = depth; + tl->format = format; + tl->type = type; + tl->compressed = GL_FALSE; + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + /* XXX may need to do some fine-tuning here for proxy textures */ + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} +#endif /* CR_OPENGL_VERSION_1_2 || GL_EXT_texture3D */ + + +#ifdef GL_EXT_texture3D +void STATE_APIENTRY +crStateTexImage3DEXT(GLenum target, GLint level, + GLenum internalFormat, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, + const GLvoid * pixels) +{ + crStateTexImage3D(target, level, (GLint) internalFormat, width, height, + depth, border, format, type, pixels); +} +#endif /* GL_EXT_texture3D */ + + +void STATE_APIENTRY +crStateTexSubImage1D(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + CRClientState *c = &(g->client); +#endif + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + CRTextureUnit *unit = t->unit + t->curTextureUnit; + CRTextureObj *tobj = unit->currentTexture1D; + CRTextureLevel *tl = tobj->level[0] + level; + (void)format; (void)type; (void)pixels; + + FLUSH(); + + if (ErrorCheckTexSubImage(1, target, level, xoffset, 0, 0, + width, 1, 1)) { + return; /* GL error state already set */ + } + +#ifdef DEBUG_misha + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + xoffset += tl->border; + + crPixelCopy1D((void *) (tl->img + xoffset * tl->bytesPerPixel), + tl->format, tl->type, + pixels, format, type, width, &(c->unpack)); +#endif + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + CRTextureObj *tobj; + CRTextureLevel *tl; +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + CRClientState *c = &(g->client); + GLubyte *subimg = NULL; + GLubyte *img = NULL; + GLubyte *src; + int i; +#endif + (void)format; (void)type; (void)pixels; + + FLUSH(); + + if (ErrorCheckTexSubImage(2, target, level, xoffset, yoffset, 0, + width, height, 1)) { + return; /* GL error state already set */ + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + +#ifdef DEBUG_misha + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + xoffset += tl->border; + yoffset += tl->border; + + subimg = (GLubyte *) crAlloc(crImageSize(tl->format, tl->type, width, height)); + + crPixelCopy2D(width, height, subimg, tl->format, tl->type, NULL, /* dst */ + pixels, format, type, &(c->unpack)); /* src */ + + img = tl->img + + xoffset * tl->bytesPerPixel + yoffset * tl->width * tl->bytesPerPixel; + + src = subimg; + + /* Copy the data into the texture */ + for (i = 0; i < height; i++) + { + crMemcpy(img, src, tl->bytesPerPixel * width); + img += tl->width * tl->bytesPerPixel; + src += width * tl->bytesPerPixel; + } + + crFree(subimg); +#endif + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + +#ifdef CR_DUMP_TEXTURES_2D + { + GLint w,h; + char *data; + + diff_api.GetTexLevelParameteriv(target, level, GL_TEXTURE_WIDTH, &w); + diff_api.GetTexLevelParameteriv(target, level, GL_TEXTURE_HEIGHT, &h); + + data = crAlloc(w*h*4); + if (!data) crError("no memory!"); + diff_api.GetTexImage(target, level, GL_RGBA, GL_UNSIGNED_BYTE, data); + crDumpTGA(w, h, data); + crFree(data); + } +#endif +} + +#if defined( CR_OPENGL_VERSION_1_2 ) +void STATE_APIENTRY +crStateTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, GLsizei height, + GLsizei depth, GLenum format, GLenum type, + const GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + CRTextureUnit *unit = t->unit + t->curTextureUnit; + CRTextureObj *tobj = unit->currentTexture3D; + CRTextureLevel *tl = tobj->level[0] + level; +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + CRClientState *c = &(g->client); + GLubyte *subimg = NULL; + GLubyte *img = NULL; + GLubyte *src; + int i; +#endif + (void)format; (void)type; (void)pixels; + + FLUSH(); + + if (ErrorCheckTexSubImage(3, target, level, xoffset, yoffset, zoffset, + width, height, depth)) { + return; /* GL error state already set */ + } + +#ifdef DEBUG_misha + CRASSERT(target == GL_TEXTURE_3D); + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + xoffset += tl->border; + yoffset += tl->border; + zoffset += tl->border; + + subimg = + (GLubyte *) + crAlloc(crTextureSize(tl->format, tl->type, width, height, depth)); + + crPixelCopy3D(width, height, depth, subimg, tl->format, tl->type, NULL, + pixels, format, type, &(c->unpack)); + + img = tl->img + xoffset * tl->bytesPerPixel + + yoffset * tl->width * tl->bytesPerPixel + + zoffset * tl->width * tl->height * tl->bytesPerPixel; + + src = subimg; + + /* Copy the data into the texture */ + for (i = 0; i < depth; i++) + { + crMemcpy(img, src, tl->bytesPerPixel * width * height); + img += tl->width * tl->height * tl->bytesPerPixel; + src += width * height * tl->bytesPerPixel; + } + + crFree(subimg); +#endif + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} +#endif /* CR_OPENGL_VERSION_1_2 || GL_EXT_texture3D */ + + +void STATE_APIENTRY +crStateCompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid * data) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj; + CRTextureLevel *tl; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + (void)data; + + FLUSH(); + + if (ErrorCheckTexImage(1, target, level, width, 1, 1, border)) { + if (IsProxyTarget(target)) { + /* clear all state, but don't generate error */ + crStateTextureInitTextureObj(g, &(t->proxy1D), 0, GL_TEXTURE_1D); + } + else { + /* error was already recorded */ + } + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + + if (IsProxyTarget(target)) + tl->bytes = 0; + else + tl->bytes = imageSize; + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + if (tl->bytes) + { + /* this is not a proxy texture target so alloc storage */ + if (tl->img) + crFree(tl->img); + tl->img = (GLubyte *) crAlloc(tl->bytes); + if (!tl->img) + { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, + "glTexImage1D out of memory"); + return; + } + if (data) + crMemcpy(tl->img, data, imageSize); + } +#endif + + tl->width = width; + tl->height = 1; + tl->depth = 1; + tl->border = border; + tl->format = GL_NONE; + tl->type = GL_NONE; + tl->internalFormat = internalFormat; + crStateTextureInitTextureFormat(tl, internalFormat); + tl->compressed = GL_TRUE; + tl->bytesPerPixel = 0; /* n/a */ + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateCompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, + GLsizei imageSize, const GLvoid * data) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj = NULL; + CRTextureLevel *tl = NULL; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + (void)data; + + FLUSH(); + + if (ErrorCheckTexImage(2, target, level, width, height, 1, border)) { + if (IsProxyTarget(target)) { + /* clear all state, but don't generate error */ + crStateTextureInitTextureObj(g, &(t->proxy2D), 0, GL_TEXTURE_2D); + } + else { + /* error was already recorded */ + } + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + + if (IsProxyTarget(target)) + tl->bytes = 0; + else + tl->bytes = imageSize; + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + if (tl->bytes) + { + /* this is not a proxy texture target so alloc storage */ + if (tl->img) + crFree(tl->img); + tl->img = (GLubyte *) crAlloc(tl->bytes); + if (!tl->img) + { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, + "glTexImage2D out of memory"); + return; + } + if (data) + crMemcpy(tl->img, data, imageSize); + } +#endif + + tl->width = width; + tl->height = height; + tl->depth = 1; + tl->border = border; + tl->format = GL_NONE; + tl->type = GL_NONE; + tl->internalFormat = internalFormat; + crStateTextureInitTextureFormat(tl, internalFormat); + tl->compressed = GL_TRUE; + tl->bytesPerPixel = 0; /* n/a */ + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + /* XXX may need to do some fine-tuning here for proxy textures */ + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateCompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid * data) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj = NULL; + CRTextureLevel *tl = NULL; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + (void)data; + + FLUSH(); + + if (ErrorCheckTexImage(3, target, level, width, height, depth, border)) { + if (IsProxyTarget(target)) { + /* clear all state, but don't generate error */ + crStateTextureInitTextureObj(g, &(t->proxy3D), 0, GL_TEXTURE_3D); + } + else { + /* error was already recorded */ + } + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + CRASSERT(tobj); + CRASSERT(tl); + + if (IsProxyTarget(target)) + tl->bytes = 0; + else + tl->bytes = imageSize; + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + if (tl->bytes) + { + /* this is not a proxy texture target so alloc storage */ + if (tl->img) + crFree(tl->img); + tl->img = (GLubyte *) crAlloc(tl->bytes); + if (!tl->img) + { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, + "glCompressedTexImage3D out of memory"); + return; + } + if (data) + crMemcpy(tl->img, data, imageSize); + } +#endif + + tl->width = width; + tl->height = height; + tl->depth = depth; + tl->border = border; + tl->format = GL_NONE; + tl->type = GL_NONE; + tl->internalFormat = internalFormat; + crStateTextureInitTextureFormat(tl, internalFormat); + tl->compressed = GL_TRUE; + tl->bytesPerPixel = 0; /* n/a */ + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + /* XXX may need to do some fine-tuning here for proxy textures */ + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + CRTextureUnit *unit = t->unit + t->curTextureUnit; + CRTextureObj *tobj = unit->currentTexture1D; + CRTextureLevel *tl = tobj->level[0] + level; + (void)format; (void)imageSize; (void)data; + + FLUSH(); + + if (ErrorCheckTexSubImage(1, target, level, xoffset, 0, 0, width, 1, 1)) { + return; /* GL error state already set */ + } + +#ifdef DEBUG_misha + CRASSERT(target == GL_TEXTURE_1D); + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + xoffset += tl->border; + + if (xoffset == 0 && width == tl->width) { + /* just memcpy */ + crMemcpy(tl->img, data, imageSize); + } + else { + /* XXX this depends on the exact compression method */ + crWarning("Not implemented part crStateCompressedTexSubImage1DARB"); + } +#endif + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, + GLsizei height, GLenum format, + GLsizei imageSize, const GLvoid * data) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + CRTextureUnit *unit = t->unit + t->curTextureUnit; + CRTextureObj *tobj = unit->currentTexture2D; + CRTextureLevel *tl = tobj->level[0] + level; + (void)format; (void)imageSize; (void)data; + + FLUSH(); + +#ifdef DEBUG_misha + CRASSERT(target == GL_TEXTURE_2D); + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + + if (ErrorCheckTexSubImage(2, target, level, xoffset, yoffset, 0, + width, height, 1)) { + return; /* GL error state already set */ + } + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + xoffset += tl->border; + yoffset += tl->border; + + if (xoffset == 0 && width == tl->width + && yoffset == 0 && height == tl->height) + { + /* just memcpy */ + crMemcpy(tl->img, data, imageSize); + } + else { + /* XXX this depends on the exact compression method */ + crWarning("Not implemented part crStateCompressedTexSubImage2DARB"); + } +#endif + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, + const GLvoid * data) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + CRTextureUnit *unit = t->unit + t->curTextureUnit; + CRTextureObj *tobj = unit->currentTexture3D; + CRTextureLevel *tl = tobj->level[0] + level; + (void)format; (void)imageSize; (void)data; + + FLUSH(); + +#ifdef DEBUG_misha + CRASSERT(target == GL_TEXTURE_3D); + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + + if (ErrorCheckTexSubImage(3, target, level, xoffset, yoffset, zoffset, + width, height, depth)) { + return; /* GL error state already set */ + } + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + xoffset += tl->border; + yoffset += tl->border; + zoffset += tl->border; + + if (xoffset == 0 && width == tl->width && + yoffset == 0 && height == tl->height && + zoffset == 0 && depth == tl->depth) { + /* just memcpy */ + crMemcpy(tl->img, data, imageSize); + } + else { + /* XXX this depends on the exact compression method */ + crWarning("Not implemented part crStateCompressedTexSubImage3DARB"); + } +#endif + +#ifdef CR_SGIS_generate_mipmap + if (level == tobj->baseLevel && tobj->generateMipmap) { + generate_mipmap(tobj, target); + } + else { + tl->generateMipmap = GL_FALSE; + } +#endif + + DIRTY(tobj->dirty, g->neg_bitid); + DIRTY(tobj->imageBit, g->neg_bitid); + DIRTY(tl->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateGetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + CRTextureLevel *tl; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetCompressedTexImage called in begin/end"); + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + if (!tobj || !tl) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetCompressedTexImage(invalid target or level)"); + return; + } + + if (!tl->compressed) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetCompressedTexImage(not a compressed texture)"); + return; + } + +#ifdef DEBUG_misha + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + crMemcpy(img, tl->img, tl->bytes); +#else + diff_api.GetCompressedTexImageARB(target, level, img); +#endif +} + + +void STATE_APIENTRY +crStateGetTexImage(GLenum target, GLint level, GLenum format, + GLenum type, GLvoid * pixels) +{ + CRContext *g = GetCurrentContext(); +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE + CRClientState *c = &(g->client); +#endif + CRTextureObj *tobj; + CRTextureLevel *tl; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexImage called in begin/end"); + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &tl); + if (!tobj || !tl) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexImage(invalid target or level)"); + return; + } + + if (tl->compressed) { + crWarning("glGetTexImage cannot decompress a compressed texture!"); + return; + } + +#ifdef DEBUG_misha + CRASSERT(tl->bytes); + CRASSERT(tl->height); + CRASSERT(tl->width); + CRASSERT(tl->depth); +#endif + + switch (format) + { + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexImage called with bogus format: %d", format); + return; + } + + switch (type) + { + case GL_UNSIGNED_BYTE: + case GL_BYTE: + case GL_UNSIGNED_SHORT: + case GL_SHORT: + case GL_UNSIGNED_INT: + case GL_INT: + case GL_FLOAT: + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexImage called with bogus type: %d", type); + return; + } + +#ifndef CR_STATE_NO_TEXTURE_IMAGE_STORE +#ifdef CR_OPENGL_VERSION_1_2 + if (target == GL_TEXTURE_3D) + { + crPixelCopy3D(tl->width, tl->height, tl->depth, (GLvoid *) pixels, format, + type, NULL, (tl->img), format, type, &(c->pack)); + } + else +#endif + if ((target == GL_TEXTURE_1D) || (target == GL_TEXTURE_2D)) + { + crPixelCopy2D(tl->width, tl->height, (GLvoid *) pixels, format, type, NULL, /* dst */ + tl->img, format, type, &(c->pack)); /* src */ + } +#else + diff_api.GetTexImage(target, level, format, type, pixels); +#endif +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c new file mode 100644 index 00000000..5184feb6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_texture.c @@ -0,0 +1,3418 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "state.h" +#include "state/cr_statetypes.h" +#include "state/cr_texture.h" +#include "cr_hash.h" +#include "cr_string.h" +#include "cr_mem.h" +#include "cr_version.h" +#include "state_internals.h" + +#ifdef DEBUG_misha +#include +#endif + +#define UNUSED(x) ((void) (x)) + +#define GET_TOBJ(tobj, state, id) \ + tobj = (CRTextureObj *) crHashtableSearch(g->shared->textureTable, id); + + +void crStateTextureDestroy(CRContext *ctx) +{ + crStateDeleteTextureObjectData(&ctx->texture.base1D); + crStateDeleteTextureObjectData(&ctx->texture.proxy1D); + crStateDeleteTextureObjectData(&ctx->texture.base2D); + crStateDeleteTextureObjectData(&ctx->texture.proxy2D); +#ifdef CR_OPENGL_VERSION_1_2 + crStateDeleteTextureObjectData(&ctx->texture.base3D); + crStateDeleteTextureObjectData(&ctx->texture.proxy3D); +#endif +#ifdef CR_ARB_texture_cube_map + crStateDeleteTextureObjectData(&ctx->texture.baseCubeMap); + crStateDeleteTextureObjectData(&ctx->texture.proxyCubeMap); +#endif +#ifdef CR_NV_texture_rectangle + crStateDeleteTextureObjectData(&ctx->texture.baseRect); + crStateDeleteTextureObjectData(&ctx->texture.proxyRect); +#endif +} + + +void crStateTextureInit(CRContext *ctx) +{ + CRLimitsState *limits = &ctx->limits; + CRTextureState *t = &ctx->texture; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + unsigned int i; + unsigned int a; + GLvectorf zero_vector = {0.0f, 0.0f, 0.0f, 0.0f}; + GLcolorf zero_color = {0.0f, 0.0f, 0.0f, 0.0f}; + GLvectorf x_vector = {1.0f, 0.0f, 0.0f, 0.0f}; + GLvectorf y_vector = {0.0f, 1.0f, 0.0f, 0.0f}; + + /* compute max levels from max sizes */ + for (i=0, a=limits->maxTextureSize; a; i++, a=a>>1); + t->maxLevel = i-1; + for (i=0, a=limits->max3DTextureSize; a; i++, a=a>>1); + t->max3DLevel = i-1; +#ifdef CR_ARB_texture_cube_map + for (i=0, a=limits->maxCubeMapTextureSize; a; i++, a=a>>1); + t->maxCubeMapLevel = i-1; +#endif +#ifdef CR_NV_texture_rectangle + for (i=0, a=limits->maxRectTextureSize; a; i++, a=a>>1); + t->maxRectLevel = i-1; +#endif + + crStateTextureInitTextureObj(ctx, &(t->base1D), 0, GL_TEXTURE_1D); + crStateTextureInitTextureObj(ctx, &(t->base2D), 0, GL_TEXTURE_2D); +#ifdef CR_OPENGL_VERSION_1_2 + crStateTextureInitTextureObj(ctx, &(t->base3D), 0, GL_TEXTURE_3D); +#endif +#ifdef CR_ARB_texture_cube_map + crStateTextureInitTextureObj(ctx, &(t->baseCubeMap), 0, + GL_TEXTURE_CUBE_MAP_ARB); +#endif +#ifdef CR_NV_texture_rectangle + crStateTextureInitTextureObj(ctx, &(t->baseRect), 0, + GL_TEXTURE_RECTANGLE_NV); +#endif + + crStateTextureInitTextureObj(ctx, &(t->proxy1D), 0, GL_TEXTURE_1D); + crStateTextureInitTextureObj(ctx, &(t->proxy2D), 0, GL_TEXTURE_2D); +#ifdef CR_OPENGL_VERSION_1_2 + crStateTextureInitTextureObj(ctx, &(t->proxy3D), 0, GL_TEXTURE_3D); +#endif +#ifdef CR_ARB_texture_cube_map + crStateTextureInitTextureObj(ctx, &(t->proxyCubeMap), 0, + GL_TEXTURE_CUBE_MAP_ARB); +#endif +#ifdef CR_NV_texture_rectangle + crStateTextureInitTextureObj(ctx, &(t->proxyRect), 0, + GL_TEXTURE_RECTANGLE_NV); +#endif + + t->curTextureUnit = 0; + + /* Per-unit initialization */ + for (i = 0; i < limits->maxTextureUnits; i++) + { + t->unit[i].currentTexture1D = &(t->base1D); + t->unit[i].currentTexture2D = &(t->base2D); + t->unit[i].currentTexture3D = &(t->base3D); +#ifdef CR_ARB_texture_cube_map + t->unit[i].currentTextureCubeMap = &(t->baseCubeMap); +#endif +#ifdef CR_NV_texture_rectangle + t->unit[i].currentTextureRect = &(t->baseRect); +#endif + + t->unit[i].enabled1D = GL_FALSE; + t->unit[i].enabled2D = GL_FALSE; + t->unit[i].enabled3D = GL_FALSE; + t->unit[i].enabledCubeMap = GL_FALSE; +#ifdef CR_NV_texture_rectangle + t->unit[i].enabledRect = GL_FALSE; +#endif + t->unit[i].textureGen.s = GL_FALSE; + t->unit[i].textureGen.t = GL_FALSE; + t->unit[i].textureGen.r = GL_FALSE; + t->unit[i].textureGen.q = GL_FALSE; + + t->unit[i].gen.s = GL_EYE_LINEAR; + t->unit[i].gen.t = GL_EYE_LINEAR; + t->unit[i].gen.r = GL_EYE_LINEAR; + t->unit[i].gen.q = GL_EYE_LINEAR; + + t->unit[i].objSCoeff = x_vector; + t->unit[i].objTCoeff = y_vector; + t->unit[i].objRCoeff = zero_vector; + t->unit[i].objQCoeff = zero_vector; + + t->unit[i].eyeSCoeff = x_vector; + t->unit[i].eyeTCoeff = y_vector; + t->unit[i].eyeRCoeff = zero_vector; + t->unit[i].eyeQCoeff = zero_vector; + t->unit[i].envMode = GL_MODULATE; + t->unit[i].envColor = zero_color; + + t->unit[i].combineModeRGB = GL_MODULATE; + t->unit[i].combineModeA = GL_MODULATE; + t->unit[i].combineSourceRGB[0] = GL_TEXTURE; + t->unit[i].combineSourceRGB[1] = GL_PREVIOUS_EXT; + t->unit[i].combineSourceRGB[2] = GL_CONSTANT_EXT; + t->unit[i].combineSourceA[0] = GL_TEXTURE; + t->unit[i].combineSourceA[1] = GL_PREVIOUS_EXT; + t->unit[i].combineSourceA[2] = GL_CONSTANT_EXT; + t->unit[i].combineOperandRGB[0] = GL_SRC_COLOR; + t->unit[i].combineOperandRGB[1] = GL_SRC_COLOR; + t->unit[i].combineOperandRGB[2] = GL_SRC_ALPHA; + t->unit[i].combineOperandA[0] = GL_SRC_ALPHA; + t->unit[i].combineOperandA[1] = GL_SRC_ALPHA; + t->unit[i].combineOperandA[2] = GL_SRC_ALPHA; + t->unit[i].combineScaleRGB = 1.0F; + t->unit[i].combineScaleA = 1.0F; +#ifdef CR_EXT_texture_lod_bias + t->unit[i].lodBias = 0.0F; +#endif + RESET(tb->enable[i], ctx->bitid); + RESET(tb->current[i], ctx->bitid); + RESET(tb->objGen[i], ctx->bitid); + RESET(tb->eyeGen[i], ctx->bitid); + RESET(tb->genMode[i], ctx->bitid); + RESET(tb->envBit[i], ctx->bitid); + } + RESET(tb->dirty, ctx->bitid); +} + + +void +crStateTextureInitTextureObj(CRContext *ctx, CRTextureObj *tobj, + GLuint name, GLenum target) +{ + const CRTextureState *t = &(ctx->texture); + int i, face; + + tobj->borderColor.r = 0.0f; + tobj->borderColor.g = 0.0f; + tobj->borderColor.b = 0.0f; + tobj->borderColor.a = 0.0f; + tobj->minFilter = GL_NEAREST_MIPMAP_LINEAR; + tobj->magFilter = GL_LINEAR; + tobj->wrapS = GL_REPEAT; + tobj->wrapT = GL_REPEAT; +#ifdef CR_OPENGL_VERSION_1_2 + tobj->wrapR = GL_REPEAT; + tobj->priority = 1.0f; + tobj->minLod = -1000.0; + tobj->maxLod = 1000.0; + tobj->baseLevel = 0; + tobj->maxLevel = t->maxLevel; +#endif + tobj->target = target; + tobj->id = name; + tobj->hwid = 0; + +#ifndef IN_GUEST + crStateGetTextureObjHWID(tobj); +#endif + + CRASSERT(t->maxLevel); + + /* XXX don't always need all six faces */ + for (face = 0; face < 6; face++) { + /* allocate array of mipmap levels */ + CRASSERT(t->maxLevel < CR_MAX_MIPMAP_LEVELS); + tobj->level[face] = (CRTextureLevel *) + crCalloc(sizeof(CRTextureLevel) * CR_MAX_MIPMAP_LEVELS); + + if (!tobj->level[face]) + return; /* out of memory */ + + /* init non-zero fields */ + for (i = 0; i <= t->maxLevel; i++) { + CRTextureLevel *tl = &(tobj->level[face][i]); + tl->internalFormat = GL_ONE; + tl->format = GL_RGBA; + tl->type = GL_UNSIGNED_BYTE; + crStateTextureInitTextureFormat( tl, tl->internalFormat ); + } + } + +#ifdef CR_EXT_texture_filter_anisotropic + tobj->maxAnisotropy = 1.0f; +#endif + +#ifdef CR_ARB_depth_texture + tobj->depthMode = GL_LUMINANCE; +#endif + +#ifdef CR_ARB_shadow + tobj->compareMode = GL_NONE; + tobj->compareFunc = GL_LEQUAL; +#endif + +#ifdef CR_ARB_shadow_ambient + tobj->compareFailValue = 0.0; +#endif + + RESET(tobj->dirty, ctx->bitid); + RESET(tobj->imageBit, ctx->bitid); + for (i = 0; i < CR_MAX_TEXTURE_UNITS; i++) + { + RESET(tobj->paramsBit[i], ctx->bitid); + } + + CR_STATE_SHAREDOBJ_USAGE_INIT(tobj); + CR_STATE_SHAREDOBJ_USAGE_SET(tobj, ctx); +} + + +/* ================================================================ + * Texture internal formats: + */ + +const CRTextureFormat _texformat_rgba8888 = { + 8, /* RedBits */ + 8, /* GreenBits */ + 8, /* BlueBits */ + 8, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_argb8888 = { + 8, /* RedBits */ + 8, /* GreenBits */ + 8, /* BlueBits */ + 8, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgb888 = { + 8, /* RedBits */ + 8, /* GreenBits */ + 8, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgb565 = { + 5, /* RedBits */ + 6, /* GreenBits */ + 5, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_argb4444 = { + 4, /* RedBits */ + 4, /* GreenBits */ + 4, /* BlueBits */ + 4, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_argb1555 = { + 5, /* RedBits */ + 5, /* GreenBits */ + 5, /* BlueBits */ + 1, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_al88 = { + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 8, /* AlphaBits */ + 8, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_rgb332 = { + 3, /* RedBits */ + 3, /* GreenBits */ + 2, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_a8 = { + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 8, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_l8 = { + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 0, /* AlphaBits */ + 8, /* LuminanceBits */ + 0, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_i8 = { + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 8, /* IntensityBits */ + 0, /* IndexBits */ +}; + +const CRTextureFormat _texformat_ci8 = { + 0, /* RedBits */ + 0, /* GreenBits */ + 0, /* BlueBits */ + 0, /* AlphaBits */ + 0, /* LuminanceBits */ + 0, /* IntensityBits */ + 8, /* IndexBits */ +}; + + +/** + * Given an internal texture format enum or 1, 2, 3, 4 initialize the + * texture levels texture format. This basically just indicates the + * number of red, green, blue, alpha, luminance, etc. bits are used to + * store the image. + */ +void +crStateTextureInitTextureFormat( CRTextureLevel *tl, GLenum internalFormat ) +{ + switch (internalFormat) { + case 4: + case GL_RGBA: + case GL_COMPRESSED_RGBA_ARB: +#ifdef CR_EXT_texture_sRGB + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: + case GL_COMPRESSED_SRGB_ALPHA_EXT: +#endif + tl->texFormat = &_texformat_rgba8888; + break; + + case 3: + case GL_RGB: + case GL_COMPRESSED_RGB_ARB: +#ifdef CR_EXT_texture_sRGB + case GL_SRGB_EXT: + case GL_SRGB8_EXT: + case GL_COMPRESSED_SRGB_EXT: +#endif + tl->texFormat = &_texformat_rgb888; + break; + + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + tl->texFormat = &_texformat_rgba8888; + break; + + case GL_R3_G3_B2: + tl->texFormat = &_texformat_rgb332; + break; + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + tl->texFormat = &_texformat_rgb888; + break; + + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + case GL_COMPRESSED_ALPHA_ARB: + tl->texFormat = &_texformat_a8; + break; + + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + case GL_COMPRESSED_LUMINANCE_ARB: +#ifdef CR_EXT_texture_sRGB + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: + case GL_COMPRESSED_SLUMINANCE_EXT: +#endif + tl->texFormat = &_texformat_l8; + break; + + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: +#ifdef CR_EXT_texture_sRGB + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: + case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: +#endif + tl->texFormat = &_texformat_al88; + break; + + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + case GL_COMPRESSED_INTENSITY_ARB: + tl->texFormat = &_texformat_i8; + break; + + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + tl->texFormat = &_texformat_ci8; + break; + + default: + return; + } +} + +#if 0 +void crStateTextureInitTexture (GLuint name) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj; + + GET_TOBJ(tobj, name); + if (!tobj) return; + + crStateTextureInitTextureObj(g, tobj, name, GL_NONE); +} +#endif + + + +/** + * Return the texture object corresponding to the given target and ID. + */ +CRTextureObj * +crStateTextureGet(GLenum target, GLuint name) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj; + + if (name == 0) + { + switch (target) { + case GL_TEXTURE_1D: + return &t->base1D; + case GL_TEXTURE_2D: + return &t->base2D; + case GL_TEXTURE_3D: + return &t->base3D; +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_ARB: + return &t->baseCubeMap; +#endif +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + return &t->baseRect; +#endif + default: + return NULL; + } + } + + GET_TOBJ(tobj, g, name); + + return tobj; +} + + +/* + * Allocate a new texture object with the given name. + * Also insert into hash table. + */ +static CRTextureObj * +crStateTextureAllocate_t(CRContext *ctx, GLuint name) +{ + CRTextureObj *tobj; + + if (!name) + return NULL; + + tobj = crCalloc(sizeof(CRTextureObj)); + if (!tobj) + return NULL; + + crHashtableAdd( ctx->shared->textureTable, name, (void *) tobj ); + + crStateTextureInitTextureObj(ctx, tobj, name, GL_NONE); + + return tobj; +} + + +/** + * Delete all the data that hangs off a CRTextureObj, but don't + * delete the texture object itself, since it may not have been + * dynamically allocated. + */ +void +crStateDeleteTextureObjectData(CRTextureObj *tobj) +{ + int k; + int face; + + CRASSERT(tobj); + + /* Free the texture images */ + for (face = 0; face < 6; face++) { + CRTextureLevel *levels = NULL; + levels = tobj->level[face]; + if (levels) { + /* free all mipmap levels for this face */ + for (k = 0; k < CR_MAX_MIPMAP_LEVELS; k++) { + CRTextureLevel *tl = levels + k; + if (tl->img) { + crFree(tl->img); + tl->img = NULL; + tl->bytes = 0; + } + } + crFree(levels); + } + tobj->level[face] = NULL; + } +} + + +void +crStateDeleteTextureObject(CRTextureObj *tobj) +{ + crStateDeleteTextureObjectData(tobj); + crFree(tobj); +} + +void crStateRegNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names) +{ + GLint i; + (void)g; + for (i = 0; i < n; i++) + { + if (names[i]) + { + GLboolean isNewKey = crHashtableAllocRegisterKey(table, names[i]); + CRASSERT(isNewKey); + } + else + crWarning("RegNames: requested to register a null name"); + } +} + +void crStateRegTextures(GLsizei n, GLuint *names) +{ + CRContext *g = GetCurrentContext(); + crStateRegNames(g, g->shared->textureTable, n, names); +} + +void crStateGenNames(CRContext *g, CRHashTable *table, GLsizei n, GLuint *names) +{ + GLint start; + + FLUSH(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "crStateGenNames called in Begin/End"); + return; + } + + if (n < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "Negative n passed to crStateGenNames: %d", n); + return; + } + + start = crHashtableAllocKeys(table, n); + if (start) + { + GLint i; + for (i = 0; i < n; i++) + names[i] = (GLuint) (start + i); + } + else + { + crStateError(__LINE__, __FILE__, GL_OUT_OF_MEMORY, "glGenTextures"); + } +} + +void STATE_APIENTRY crStateGenTextures(GLsizei n, GLuint *textures) +{ + CRContext *g = GetCurrentContext(); + crStateGenNames(g, g->shared->textureTable, n, textures); +} + +static void crStateTextureCheckFBOAPs(GLenum target, GLuint texture) +{ + GLuint u; + CRFBOAttachmentPoint *ap; + CRContext *g = GetCurrentContext(); + CRFramebufferObjectState *fbo = &g->framebufferobject; + CRFramebufferObject *pFBO; + + pFBO = GL_READ_FRAMEBUFFER==target ? fbo->readFB : fbo->drawFB; + if (!pFBO) return; + + for (u=0; ucolor[u]; + if (ap->type==GL_TEXTURE && ap->name==texture) + { + crStateFramebufferTexture1DEXT(target, u+GL_COLOR_ATTACHMENT0_EXT, 0, 0, 0); + } + } + + ap = &pFBO->depth; + if (ap->type==GL_TEXTURE && ap->name==texture) + { + crStateFramebufferTexture1DEXT(target, GL_DEPTH_ATTACHMENT_EXT, 0, 0, 0); + } + + ap = &pFBO->stencil; + if (ap->type==GL_TEXTURE && ap->name==texture) + { + crStateFramebufferTexture1DEXT(target, GL_STENCIL_ATTACHMENT_EXT, 0, 0, 0); + } +} + +static void crStateCleanupTextureRefs(CRContext *g, CRTextureObj *tObj) +{ + CRTextureState *t = &(g->texture); + GLuint u; + + /* + ** reset back to the base texture. + */ + for (u = 0; u < g->limits.maxTextureUnits; u++) + { + if (tObj == t->unit[u].currentTexture1D) + { + t->unit[u].currentTexture1D = &(t->base1D); + } + if (tObj == t->unit[u].currentTexture2D) + { + t->unit[u].currentTexture2D = &(t->base2D); + } +#ifdef CR_OPENGL_VERSION_1_2 + if (tObj == t->unit[u].currentTexture3D) + { + t->unit[u].currentTexture3D = &(t->base3D); + } +#endif +#ifdef CR_ARB_texture_cube_map + if (tObj == t->unit[u].currentTextureCubeMap) + { + t->unit[u].currentTextureCubeMap = &(t->baseCubeMap); + } +#endif +#ifdef CR_NV_texture_rectangle + if (tObj == t->unit[u].currentTextureRect) + { + t->unit[u].currentTextureRect = &(t->baseRect); + } +#endif + +#ifdef CR_EXT_framebuffer_object + crStateTextureCheckFBOAPs(GL_DRAW_FRAMEBUFFER, tObj->id); + crStateTextureCheckFBOAPs(GL_READ_FRAMEBUFFER, tObj->id); +#endif + } +} + +void STATE_APIENTRY crStateDeleteTextures(GLsizei n, const GLuint *textures) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + int i; + + FLUSH(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glDeleteTextures called in Begin/End"); + return; + } + + if (n < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "Negative n passed to glDeleteTextures: %d", n); + return; + } + + for (i=0; idispatch_table.DeleteTextures(n, newTextures); + * in crServerDispatchDeleteTextures, we just delete a state object here, which crStateDeleteTextureObject does */ + crHashtableDelete(g->shared->textureTable, name, (CRHashtableCallback)crStateDeleteTextureObject); + } + else + { + /* call crHashtableDelete in any way, to ensure the allocated key is freed */ + Assert(crHashtableIsKeyUsed(g->shared->textureTable, name)); + crHashtableDelete(g->shared->textureTable, name, NULL); + } + } + + DIRTY(tb->dirty, g->neg_bitid); + DIRTY(tb->current[t->curTextureUnit], g->neg_bitid); +} + + + +void STATE_APIENTRY crStateClientActiveTextureARB( GLenum texture ) +{ + CRContext *g = GetCurrentContext(); + CRClientState *c = &(g->client); + + FLUSH(); + + if (!g->extensions.ARB_multitexture) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glClientActiveTextureARB not available"); + return; + } + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glClientActiveTextureARB called in Begin/End"); + return; + } + + if ( texture < GL_TEXTURE0_ARB || + texture >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "crStateClientActiveTexture: unit = %d (max is %d)", + texture, g->limits.maxTextureUnits ); + return; + } + + c->curClientTextureUnit = texture - GL_TEXTURE0_ARB; + + DIRTY(GetCurrentBits()->client.dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateActiveTextureARB( GLenum texture ) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + + FLUSH(); + + if (!g->extensions.ARB_multitexture) { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glActiveTextureARB not available"); + return; + } + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glActiveTextureARB called in Begin/End"); + return; + } + + if ( texture < GL_TEXTURE0_ARB || texture >= GL_TEXTURE0_ARB + g->limits.maxTextureUnits) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Bad texture unit passed to crStateActiveTexture: %d (max is %d)", texture, g->limits.maxTextureUnits ); + return; + } + + t->curTextureUnit = texture - GL_TEXTURE0_ARB; + + /* update the current matrix pointer, etc. */ + if (g->transform.matrixMode == GL_TEXTURE) { + crStateMatrixMode(GL_TEXTURE); + } +} + +#ifndef IN_GUEST +# ifdef DEBUG +static uint32_t gDbgNumPinned = 0; +# endif + +DECLEXPORT(void) crStatePinTexture(GLuint texture, GLboolean pin) +{ + CRTextureObj * pTobj; + CRSharedState *pShared = crStateGlobalSharedAcquire(); + if (pShared) + { + pTobj = (CRTextureObj*)crHashtableSearch(pShared->textureTable, texture); + + if (pTobj) + { +# ifdef DEBUG + if (!pTobj->pinned != !pin) + { + if (pin) + ++gDbgNumPinned; + else + { + Assert(gDbgNumPinned); + --gDbgNumPinned; + } + } +# endif + pTobj->pinned = !!pin; + if (!pin) + { + if (!CR_STATE_SHAREDOBJ_USAGE_IS_USED(pTobj)) + crStateOnTextureUsageRelease(pShared, pTobj); + } + } + else + WARN(("texture %d not defined", texture)); + + crStateGlobalSharedRelease(); + } + else + WARN(("no global shared")); +} +#endif + +DECLEXPORT(void) crStateSetTextureUsed(GLuint texture, GLboolean used) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + + if (!texture) + { + crWarning("crStateSetTextureUsed: null texture name specified!"); + return; + } + + GET_TOBJ(tobj, g, texture); + if (!tobj) + { +#ifdef IN_GUEST + if (used) + { + tobj = crStateTextureAllocate_t(g, texture); + } + else +#endif + { + WARN(("crStateSetTextureUsed: failed to fined a HW name for texture(%d)!", texture)); + return; + } + } + + if (used) + CR_STATE_SHAREDOBJ_USAGE_SET(tobj, g); + else + { + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + CRTextureState *t = &(g->texture); + + crStateCleanupTextureRefs(g, tobj); + + crStateReleaseTexture(g, tobj); + + DIRTY(tb->dirty, g->neg_bitid); + DIRTY(tb->current[t->curTextureUnit], g->neg_bitid); + } +} + +void STATE_APIENTRY crStateBindTexture(GLenum target, GLuint texture) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + + FLUSH(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glBindTexture called in Begin/End"); + return; + } + + /* Special Case name = 0 */ + if (!texture) + { + switch (target) + { + case GL_TEXTURE_1D: + t->unit[t->curTextureUnit].currentTexture1D = &(t->base1D); + break; + case GL_TEXTURE_2D: + t->unit[t->curTextureUnit].currentTexture2D = &(t->base2D); + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_3D: + t->unit[t->curTextureUnit].currentTexture3D = &(t->base3D); + break; +#endif +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_ARB: + if (!g->extensions.ARB_texture_cube_map) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "Invalid target passed to glBindTexture: %d", target); + return; + } + t->unit[t->curTextureUnit].currentTextureCubeMap = &(t->baseCubeMap); + break; +#endif +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + if (!g->extensions.NV_texture_rectangle) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "Invalid target passed to glBindTexture: %d", target); + return; + } + t->unit[t->curTextureUnit].currentTextureRect = &(t->baseRect); + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid target passed to glBindTexture: %d", target); + return; + } + + DIRTY(tb->dirty, g->neg_bitid); + DIRTY(tb->current[t->curTextureUnit], g->neg_bitid); + return; + } + + /* texture != 0 */ + /* Get the texture */ + GET_TOBJ(tobj, g, texture); + if (!tobj) + { + Assert(crHashtableIsKeyUsed(g->shared->textureTable, texture)); + tobj = crStateTextureAllocate_t(g, texture); + } + + CR_STATE_SHAREDOBJ_USAGE_SET(tobj, g); + + /* Check the targets */ + if (tobj->target == GL_NONE) + { + /* Target isn't set so set it now.*/ + tobj->target = target; + } + else if ((tobj->target != target) + && !((target==GL_TEXTURE_RECTANGLE_NV && tobj->target==GL_TEXTURE_2D) + ||(target==GL_TEXTURE_2D && tobj->target==GL_TEXTURE_RECTANGLE_NV))) + { + crWarning( "You called glBindTexture with a target of 0x%x, but the texture you wanted was target 0x%x [1D: %x 2D: %x 3D: %x cube: %x]", (int) target, (int) tobj->target, GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_CUBE_MAP ); + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "Attempt to bind a texture of different dimensions"); + return; + } + + /* Set the current texture */ + switch (target) + { + case GL_TEXTURE_1D: + t->unit[t->curTextureUnit].currentTexture1D = tobj; + break; + case GL_TEXTURE_2D: + t->unit[t->curTextureUnit].currentTexture2D = tobj; + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_3D: + t->unit[t->curTextureUnit].currentTexture3D = tobj; + break; +#endif +#ifdef CR_ARB_texture_cube_map + case GL_TEXTURE_CUBE_MAP_ARB: + t->unit[t->curTextureUnit].currentTextureCubeMap = tobj; + break; +#endif +#ifdef CR_NV_texture_rectangle + case GL_TEXTURE_RECTANGLE_NV: + t->unit[t->curTextureUnit].currentTextureRect = tobj; + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "Invalid target passed to glBindTexture: %d", target); + return; + } + + DIRTY(tb->dirty, g->neg_bitid); + DIRTY(tb->current[t->curTextureUnit], g->neg_bitid); +} + + +void STATE_APIENTRY +crStateTexParameterfv(GLenum target, GLenum pname, const GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj = NULL; + CRTextureLevel *tl = NULL; + GLenum e = (GLenum) *param; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + unsigned int i; + + FLUSH(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "TexParameterfv called in Begin/End"); + return; + } + + crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl); + if (!tobj) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParamterfv(invalid target=0x%x)", target); + return; + } + + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: + if (e != GL_NEAREST && + e != GL_LINEAR && + e != GL_NEAREST_MIPMAP_NEAREST && + e != GL_LINEAR_MIPMAP_NEAREST && + e != GL_NEAREST_MIPMAP_LINEAR && + e != GL_LINEAR_MIPMAP_LINEAR) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParamterfv: GL_TEXTURE_MIN_FILTER invalid param: %d", e); + return; + } + tobj->minFilter = e; + break; + case GL_TEXTURE_MAG_FILTER: + if (e != GL_NEAREST && e != GL_LINEAR) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParamterfv: GL_TEXTURE_MAG_FILTER invalid param: %d", e); + return; + } + tobj->magFilter = e; + break; + case GL_TEXTURE_WRAP_S: + if (e == GL_CLAMP || e == GL_REPEAT) { + tobj->wrapS = e; + } +#ifdef CR_OPENGL_VERSION_1_2 + else if (e == GL_CLAMP_TO_EDGE) { + tobj->wrapS = e; + } +#endif +#ifdef GL_CLAMP_TO_EDGE_EXT + else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) { + tobj->wrapS = e; + } +#endif +#ifdef CR_ARB_texture_border_clamp + else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) { + tobj->wrapS = e; + } +#endif +#ifdef CR_ARB_texture_mirrored_repeat + else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) { + tobj->wrapS = e; + } +#endif +#ifdef CR_ATI_texture_mirror_once + else if ((e == GL_MIRROR_CLAMP_ATI || e == GL_MIRROR_CLAMP_TO_EDGE_ATI) && g->extensions.ATI_texture_mirror_once) { + tobj->wrapS = e; + } +#endif + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParameterfv: GL_TEXTURE_WRAP_S invalid param: 0x%x", e); + return; + } + break; + case GL_TEXTURE_WRAP_T: + if (e == GL_CLAMP || e == GL_REPEAT) { + tobj->wrapT = e; + } +#ifdef CR_OPENGL_VERSION_1_2 + else if (e == GL_CLAMP_TO_EDGE) { + tobj->wrapT = e; + } +#endif +#ifdef GL_CLAMP_TO_EDGE_EXT + else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) { + tobj->wrapT = e; + } +#endif +#ifdef CR_ARB_texture_border_clamp + else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) { + tobj->wrapT = e; + } +#endif +#ifdef CR_ARB_texture_mirrored_repeat + else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) { + tobj->wrapT = e; + } +#endif +#ifdef CR_ATI_texture_mirror_once + else if ((e == GL_MIRROR_CLAMP_ATI || e == GL_MIRROR_CLAMP_TO_EDGE_ATI) && g->extensions.ATI_texture_mirror_once) { + tobj->wrapT = e; + } +#endif + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParameterfv: GL_TEXTURE_WRAP_T invalid param: 0x%x", e); + return; + } + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_WRAP_R: + if (e == GL_CLAMP || e == GL_REPEAT) { + tobj->wrapR = e; + } + else if (e == GL_CLAMP_TO_EDGE) { + tobj->wrapR = e; + } +#ifdef GL_CLAMP_TO_EDGE_EXT + else if (e == GL_CLAMP_TO_EDGE_EXT && g->extensions.EXT_texture_edge_clamp) { + tobj->wrapR = e; + } +#endif +#ifdef CR_ARB_texture_border_clamp + else if (e == GL_CLAMP_TO_BORDER_ARB && g->extensions.ARB_texture_border_clamp) { + tobj->wrapR = e; + } +#endif +#ifdef CR_ARB_texture_mirrored_repeat + else if (e == GL_MIRRORED_REPEAT_ARB && g->extensions.ARB_texture_mirrored_repeat) { + tobj->wrapR = e; + } +#endif +#ifdef CR_ATI_texture_mirror_once + else if ((e == GL_MIRROR_CLAMP_ATI || e == GL_MIRROR_CLAMP_TO_EDGE_ATI) && g->extensions.ATI_texture_mirror_once) { + tobj->wrapR = e; + } +#endif + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParameterfv: GL_TEXTURE_WRAP_R invalid param: 0x%x", e); + return; + } + break; + case GL_TEXTURE_PRIORITY: + tobj->priority = param[0]; + break; + case GL_TEXTURE_MIN_LOD: + tobj->minLod = param[0]; + break; + case GL_TEXTURE_MAX_LOD: + tobj->maxLod = param[0]; + break; + case GL_TEXTURE_BASE_LEVEL: + if (e < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParameterfv: GL_TEXTURE_BASE_LEVEL invalid param: 0x%x", e); + return; + } + tobj->baseLevel = e; + break; + case GL_TEXTURE_MAX_LEVEL: + if (e < 0.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParameterfv: GL_TEXTURE_MAX_LEVEL invalid param: 0x%x", e); + return; + } + tobj->maxLevel = e; + break; +#endif + case GL_TEXTURE_BORDER_COLOR: + tobj->borderColor.r = param[0]; + tobj->borderColor.g = param[1]; + tobj->borderColor.b = param[2]; + tobj->borderColor.a = param[3]; + break; +#ifdef CR_EXT_texture_filter_anisotropic + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (g->extensions.EXT_texture_filter_anisotropic) { + if (param[0] < 1.0f) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "TexParameterfv: GL_TEXTURE_MAX_ANISOTROPY_EXT called with parameter less than 1: %f", param[0]); + return; + } + tobj->maxAnisotropy = param[0]; + if (tobj->maxAnisotropy > g->limits.maxTextureAnisotropy) + { + tobj->maxAnisotropy = g->limits.maxTextureAnisotropy; + } + } + break; +#endif +#ifdef CR_ARB_depth_texture + case GL_DEPTH_TEXTURE_MODE_ARB: + if (g->extensions.ARB_depth_texture) { + if (param[0] == GL_LUMINANCE || + param[0] == GL_INTENSITY || + param[0] == GL_ALPHA) { + tobj->depthMode = (GLenum) param[0]; + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "TexParameterfv: GL_DEPTH_TEXTURE_MODE_ARB called with invalid parameter: 0x%x", param[0]); + return; + } + } + break; +#endif +#ifdef CR_ARB_shadow + case GL_TEXTURE_COMPARE_MODE_ARB: + if (g->extensions.ARB_shadow) { + if (param[0] == GL_NONE || + param[0] == GL_COMPARE_R_TO_TEXTURE_ARB) { + tobj->compareMode = (GLenum) param[0]; + } + else + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "TexParameterfv: GL_TEXTURE_COMPARE_MODE_ARB called with invalid parameter: 0x%x", param[0]); + return; + } + } + break; + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (g->extensions.ARB_shadow) { + if (param[0] == GL_LEQUAL || + param[0] == GL_GEQUAL) { + tobj->compareFunc = (GLenum) param[0]; + } + } +#ifdef CR_EXT_shadow_funcs + else if (g->extensions.EXT_shadow_funcs) { + if (param[0] == GL_LEQUAL || + param[0] == GL_GEQUAL || + param[0] == GL_LESS || + param[0] == GL_GREATER || + param[0] == GL_ALWAYS || + param[0] == GL_NEVER ) { + tobj->compareFunc = (GLenum) param[0]; + } + } +#endif + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "TexParameterfv: GL_TEXTURE_COMPARE_FUNC_ARB called with invalid parameter: 0x%x", param[0]); + return; + } + break; +#endif +#ifdef CR_ARB_shadow_ambient + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (g->extensions.ARB_shadow_ambient) { + tobj->compareFailValue = param[0]; + } + break; +#endif +#ifdef CR_SGIS_generate_mipmap + case GL_GENERATE_MIPMAP_SGIS: + if (g->extensions.SGIS_generate_mipmap) { + tobj->generateMipmap = param[0] ? GL_TRUE : GL_FALSE; + } + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParamterfv: Invalid pname: %d", pname); + return; + } + + DIRTY(tobj->dirty, g->neg_bitid); + for (i = 0; i < g->limits.maxTextureUnits; i++) + { + DIRTY(tobj->paramsBit[i], g->neg_bitid); + } + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateTexParameteriv(GLenum target, GLenum pname, const GLint *param) +{ + GLfloat f_param; + GLcolor f_color; + switch (pname) + { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_WRAP_R: + case GL_TEXTURE_PRIORITY: + case GL_TEXTURE_MIN_LOD: + case GL_TEXTURE_MAX_LOD: + case GL_TEXTURE_BASE_LEVEL: + case GL_TEXTURE_MAX_LEVEL: +#endif +#ifdef CR_EXT_texture_filter_anisotropic + case GL_TEXTURE_MAX_ANISOTROPY_EXT: +#endif +#ifdef CR_ARB_depth_texture + case GL_DEPTH_TEXTURE_MODE_ARB: +#endif +#ifdef CR_ARB_shadow + case GL_TEXTURE_COMPARE_MODE_ARB: + case GL_TEXTURE_COMPARE_FUNC_ARB: +#endif +#ifdef CR_ARB_shadow_ambinet + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: +#endif +#ifdef CR_SGIS_generate_mipmap + case GL_GENERATE_MIPMAP_SGIS: +#endif + f_param = (GLfloat) (*param); + crStateTexParameterfv( target, pname, &(f_param) ); + break; + case GL_TEXTURE_BORDER_COLOR: + f_color.r = ((GLfloat) param[0])/CR_MAXINT; + f_color.g = ((GLfloat) param[1])/CR_MAXINT; + f_color.b = ((GLfloat) param[2])/CR_MAXINT; + f_color.a = ((GLfloat) param[3])/CR_MAXINT; + crStateTexParameterfv( target, pname, (const GLfloat *) &(f_color) ); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "TexParamteriv: Invalid pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateTexParameterf(GLenum target, GLenum pname, GLfloat param) +{ + crStateTexParameterfv( target, pname, ¶m ); +} + + +void STATE_APIENTRY +crStateTexParameteri(GLenum target, GLenum pname, GLint param) { + GLfloat f_param = (GLfloat) param; + crStateTexParameterfv( target, pname, &f_param ); +} + + +void STATE_APIENTRY +crStateTexEnvfv(GLenum target, GLenum pname, const GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + GLenum e; + GLcolorf c; + GLuint stage = 0; + + (void) stage; + + FLUSH(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glTexEnvfv called in begin/end"); + return; + } + +#if CR_EXT_texture_lod_bias + if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnv"); + } + else { + t->unit[t->curTextureUnit].lodBias = *param; + DIRTY(tb->envBit[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + } + return; + } + else +#endif +#if CR_ARB_point_sprite + if (target == GL_POINT_SPRITE_ARB) { + if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnv"); + } + else { + CRPointBits *pb = &(sb->point); + g->point.coordReplacement[t->curTextureUnit] = *param ? GL_TRUE : GL_FALSE; + DIRTY(pb->coordReplacement[t->curTextureUnit], g->neg_bitid); + DIRTY(pb->dirty, g->neg_bitid); + } + return; + } + else +#endif + if (target != GL_TEXTURE_ENV) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexEnvfv: target != GL_TEXTURE_ENV: %d", target); + return; + } + + switch (pname) + { + case GL_TEXTURE_ENV_MODE: + e = (GLenum) *param; + if (e != GL_MODULATE && + e != GL_DECAL && + e != GL_BLEND && + e != GL_ADD && + e != GL_REPLACE && + e != GL_COMBINE_ARB) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexEnvfv: invalid param: %f", *param); + return; + } + t->unit[t->curTextureUnit].envMode = e; + break; + case GL_TEXTURE_ENV_COLOR: + c.r = param[0]; + c.g = param[1]; + c.b = param[2]; + c.a = param[3]; + if (c.r > 1.0f) c.r = 1.0f; + if (c.g > 1.0f) c.g = 1.0f; + if (c.b > 1.0f) c.b = 1.0f; + if (c.a > 1.0f) c.a = 1.0f; + if (c.r < 0.0f) c.r = 0.0f; + if (c.g < 0.0f) c.g = 0.0f; + if (c.b < 0.0f) c.b = 0.0f; + if (c.a < 0.0f) c.a = 0.0f; + t->unit[t->curTextureUnit].envColor = c; + break; + +#ifdef CR_ARB_texture_env_combine + case GL_COMBINE_RGB_ARB: + e = (GLenum) (GLint) *param; + if (g->extensions.ARB_texture_env_combine && + (e == GL_REPLACE || + e == GL_MODULATE || + e == GL_ADD || + e == GL_ADD_SIGNED_ARB || + e == GL_INTERPOLATE_ARB || + e == GL_SUBTRACT_ARB)) { + t->unit[t->curTextureUnit].combineModeRGB = e; + } +#ifdef CR_ARB_texture_env_dot3 + else if (g->extensions.ARB_texture_env_dot3 && + (e == GL_DOT3_RGB_ARB || + e == GL_DOT3_RGBA_ARB || + e == GL_DOT3_RGB_EXT || + e == GL_DOT3_RGBA_EXT)) { + t->unit[t->curTextureUnit].combineModeRGB = e; + } +#endif + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv(param=0x%x", e); + return; + } + break; + case GL_COMBINE_ALPHA_EXT: + e = (GLenum) *param; + if (g->extensions.ARB_texture_env_combine && + (e == GL_REPLACE || + e == GL_MODULATE || + e == GL_ADD || + e == GL_ADD_SIGNED_ARB || + e == GL_INTERPOLATE_ARB || + e == GL_SUBTRACT_ARB)) { + t->unit[t->curTextureUnit].combineModeA = e; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); + return; + } + break; + case GL_SOURCE0_RGB_ARB: + case GL_SOURCE1_RGB_ARB: + case GL_SOURCE2_RGB_ARB: + e = (GLenum) *param; + stage = pname - GL_SOURCE0_RGB_ARB; + if (g->extensions.ARB_texture_env_combine && + (e == GL_TEXTURE || + e == GL_CONSTANT_ARB || + e == GL_PRIMARY_COLOR_ARB || + e == GL_PREVIOUS_ARB)) { + t->unit[t->curTextureUnit].combineSourceRGB[stage] = e; + } + else if (g->extensions.ARB_texture_env_crossbar && + e >= GL_TEXTURE0_ARB && + e < GL_TEXTURE0_ARB + g->limits.maxTextureUnits) { + t->unit[t->curTextureUnit].combineSourceRGB[stage] = e; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); + return; + } + break; + case GL_SOURCE0_ALPHA_ARB: + case GL_SOURCE1_ALPHA_ARB: + case GL_SOURCE2_ALPHA_ARB: + e = (GLenum) *param; + stage = pname - GL_SOURCE0_ALPHA_ARB; + if (g->extensions.ARB_texture_env_combine && + (e == GL_TEXTURE || + e == GL_CONSTANT_ARB || + e == GL_PRIMARY_COLOR_ARB || + e == GL_PREVIOUS_ARB)) { + t->unit[t->curTextureUnit].combineSourceA[stage] = e; + } + else if (g->extensions.ARB_texture_env_crossbar && + e >= GL_TEXTURE0_ARB && + e < GL_TEXTURE0_ARB + g->limits.maxTextureUnits) { + t->unit[t->curTextureUnit].combineSourceA[stage] = e; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); + return; + } + break; + case GL_OPERAND0_RGB_ARB: + case GL_OPERAND1_RGB_ARB: + case GL_OPERAND2_RGB_ARB: + e = (GLenum) *param; + stage = pname - GL_OPERAND0_RGB_ARB; + if (g->extensions.ARB_texture_env_combine && + (e == GL_SRC_COLOR || + e == GL_ONE_MINUS_SRC_COLOR || + e == GL_SRC_ALPHA || + e == GL_ONE_MINUS_SRC_ALPHA)) { + t->unit[t->curTextureUnit].combineOperandRGB[stage] = e; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv"); + return; + } + break; + case GL_OPERAND0_ALPHA_ARB: + case GL_OPERAND1_ALPHA_ARB: + case GL_OPERAND2_ALPHA_ARB: + e = (GLenum) *param; + stage = pname - GL_OPERAND0_ALPHA_ARB; + if (g->extensions.ARB_texture_env_combine && + (e == GL_SRC_ALPHA || + e == GL_ONE_MINUS_SRC_ALPHA)) { + t->unit[t->curTextureUnit].combineOperandA[stage] = e; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glTexEnvfv(param=0x%x)", e); + return; + } + break; + case GL_RGB_SCALE_ARB: + if (g->extensions.ARB_texture_env_combine && + (*param == 1.0 || + *param == 2.0 || + *param == 4.0)) { + t->unit[t->curTextureUnit].combineScaleRGB = *param; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexEnvfv"); + return; + } + break; + case GL_ALPHA_SCALE: + if (g->extensions.ARB_texture_env_combine && + (*param == 1.0 || + *param == 2.0 || + *param == 4.0)) { + t->unit[t->curTextureUnit].combineScaleA = *param; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, "glTexEnvfv"); + return; + } + break; +#endif /* CR_ARB_texture_env_combine */ + + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexEnvfv: invalid pname: %d", pname); + return; + } + + DIRTY(tb->envBit[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY +crStateTexEnviv(GLenum target, GLenum pname, const GLint *param) +{ + GLfloat f_param; + GLcolor f_color; + + switch (pname) { + case GL_TEXTURE_ENV_MODE: + f_param = (GLfloat) (*param); + crStateTexEnvfv( target, pname, &f_param ); + break; + case GL_TEXTURE_ENV_COLOR: + f_color.r = ((GLfloat) param[0]) / CR_MAXINT; + f_color.g = ((GLfloat) param[1]) / CR_MAXINT; + f_color.b = ((GLfloat) param[2]) / CR_MAXINT; + f_color.a = ((GLfloat) param[3]) / CR_MAXINT; + crStateTexEnvfv( target, pname, (const GLfloat *) &f_color ); + break; +#ifdef CR_ARB_texture_env_combine + case GL_COMBINE_RGB_ARB: + case GL_COMBINE_ALPHA_EXT: + case GL_SOURCE0_RGB_ARB: + case GL_SOURCE1_RGB_ARB: + case GL_SOURCE2_RGB_ARB: + case GL_SOURCE0_ALPHA_ARB: + case GL_SOURCE1_ALPHA_ARB: + case GL_SOURCE2_ALPHA_ARB: + case GL_OPERAND0_RGB_ARB: + case GL_OPERAND1_RGB_ARB: + case GL_OPERAND2_RGB_ARB: + case GL_OPERAND0_ALPHA_ARB: + case GL_OPERAND1_ALPHA_ARB: + case GL_OPERAND2_ALPHA_ARB: + case GL_RGB_SCALE_ARB: + case GL_ALPHA_SCALE: + f_param = (GLfloat) (*param); + crStateTexEnvfv( target, pname, &f_param ); + break; +#endif +#ifdef CR_EXT_texture_lod_bias + case GL_TEXTURE_LOD_BIAS_EXT: + f_param = (GLfloat) (*param); + crStateTexEnvfv( target, pname, &f_param); + break; +#endif +#ifdef CR_ARB_point_sprite + case GL_COORD_REPLACE_ARB: + f_param = (GLfloat) *param; + crStateTexEnvfv( target, pname, &f_param); + break; +#endif + + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexEnvfv: invalid pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateTexEnvf(GLenum target, GLenum pname, GLfloat param) +{ + crStateTexEnvfv( target, pname, ¶m ); +} + + +void STATE_APIENTRY +crStateTexEnvi(GLenum target, GLenum pname, GLint param) +{ + GLfloat f_param = (GLfloat) param; + crStateTexEnvfv( target, pname, &f_param ); +} + + +void STATE_APIENTRY +crStateGetTexEnvfv(GLenum target, GLenum pname, GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__,GL_INVALID_OPERATION, + "glGetTexEnvfv called in begin/end"); + return; + } + +#if CR_EXT_texture_lod_bias + if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); + } + else { + *param = t->unit[t->curTextureUnit].lodBias; + } + return; + } + else +#endif +#if CR_ARB_point_sprite + if (target == GL_POINT_SPRITE_ARB) { + if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); + } + else { + *param = (GLfloat) g->point.coordReplacement[t->curTextureUnit]; + } + return; + } + else +#endif + if (target != GL_TEXTURE_ENV) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexEnvfv: target != GL_TEXTURE_ENV: %d", target); + return; + } + + switch (pname) { + case GL_TEXTURE_ENV_MODE: + *param = (GLfloat) t->unit[t->curTextureUnit].envMode; + break; + case GL_TEXTURE_ENV_COLOR: + param[0] = t->unit[t->curTextureUnit].envColor.r; + param[1] = t->unit[t->curTextureUnit].envColor.g; + param[2] = t->unit[t->curTextureUnit].envColor.b; + param[3] = t->unit[t->curTextureUnit].envColor.a; + break; + case GL_COMBINE_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineModeRGB; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_COMBINE_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineModeA; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_SOURCE0_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_SOURCE1_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_SOURCE2_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceRGB[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_SOURCE0_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_SOURCE1_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_SOURCE2_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineSourceA[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_OPERAND0_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_OPERAND1_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_OPERAND2_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandRGB[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_OPERAND0_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_OPERAND1_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_OPERAND2_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLfloat) t->unit[t->curTextureUnit].combineOperandA[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_RGB_SCALE_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = t->unit[t->curTextureUnit].combineScaleRGB; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + case GL_ALPHA_SCALE: + if (g->extensions.ARB_texture_env_combine) { + *param = t->unit[t->curTextureUnit].combineScaleA; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnvfv(pname)"); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexEnvfv: invalid pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateGetTexEnviv(GLenum target, GLenum pname, GLint *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__,GL_INVALID_OPERATION, + "glGetTexEnviv called in begin/end"); + return; + } + +#if CR_EXT_texture_lod_bias + if (target == GL_TEXTURE_FILTER_CONTROL_EXT) { + if (!g->extensions.EXT_texture_lod_bias || pname != GL_TEXTURE_LOD_BIAS_EXT) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); + } + else { + *param = (GLint) t->unit[t->curTextureUnit].lodBias; + } + return; + } + else +#endif +#if CR_ARB_point_sprite + if (target == GL_POINT_SPRITE_ARB) { + if (!g->extensions.ARB_point_sprite || pname != GL_COORD_REPLACE_ARB) { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnv"); + } + else { + *param = (GLint) g->point.coordReplacement[t->curTextureUnit]; + } + return; + } + else +#endif + if (target != GL_TEXTURE_ENV) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexEnviv: target != GL_TEXTURE_ENV: %d", target); + return; + } + + switch (pname) { + case GL_TEXTURE_ENV_MODE: + *param = (GLint) t->unit[t->curTextureUnit].envMode; + break; + case GL_TEXTURE_ENV_COLOR: + param[0] = (GLint) (t->unit[t->curTextureUnit].envColor.r * CR_MAXINT); + param[1] = (GLint) (t->unit[t->curTextureUnit].envColor.g * CR_MAXINT); + param[2] = (GLint) (t->unit[t->curTextureUnit].envColor.b * CR_MAXINT); + param[3] = (GLint) (t->unit[t->curTextureUnit].envColor.a * CR_MAXINT); + break; + case GL_COMBINE_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineModeRGB; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_COMBINE_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineModeA; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_SOURCE0_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_SOURCE1_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_SOURCE2_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineSourceRGB[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_SOURCE0_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_SOURCE1_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_SOURCE2_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineSourceA[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_OPERAND0_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_OPERAND1_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_OPERAND2_RGB_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineOperandRGB[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_OPERAND0_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[0]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_OPERAND1_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[1]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_OPERAND2_ALPHA_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineOperandA[2]; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_RGB_SCALE_ARB: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineScaleRGB; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + case GL_ALPHA_SCALE: + if (g->extensions.ARB_texture_env_combine) { + *param = (GLint) t->unit[t->curTextureUnit].combineScaleA; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "glGetTexEnviv(pname)"); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexEnviv: invalid pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateTexGendv(GLenum coord, GLenum pname, const GLdouble *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTransformState *trans = &(g->transform); + GLvectorf v; + GLenum e; + CRmatrix inv; + CRStateBits *sb = GetCurrentBits(); + CRTextureBits *tb = &(sb->texture); + + FLUSH(); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glTexGen called in begin/end"); + return; + } + + switch (coord) + { + case GL_S: + switch (pname) + { + case GL_TEXTURE_GEN_MODE: + e = (GLenum) *param; + if (e == GL_OBJECT_LINEAR || + e == GL_EYE_LINEAR || + e == GL_SPHERE_MAP +#if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) + || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) + && g->extensions.ARB_texture_cube_map) +#endif + ) { + t->unit[t->curTextureUnit].gen.s = e; + DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGendv called with bad param: %lf", *param); + return; + } + break; + case GL_OBJECT_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + t->unit[t->curTextureUnit].objSCoeff = v; + DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + case GL_EYE_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + crMatrixInvertTranspose(&inv, trans->modelViewStack.top); + crStateTransformXformPointMatrixf(&inv, &v); + t->unit[t->curTextureUnit].eyeSCoeff = v; + DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGendv called with bogus pname: %d", pname); + return; + } + break; + case GL_T: + switch (pname) { + case GL_TEXTURE_GEN_MODE: + e = (GLenum) *param; + if (e == GL_OBJECT_LINEAR || + e == GL_EYE_LINEAR || + e == GL_SPHERE_MAP +#if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) + || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) + && g->extensions.ARB_texture_cube_map) +#endif + ) { + t->unit[t->curTextureUnit].gen.t = e; + DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGendv called with bad param: %lf", *param); + return; + } + break; + case GL_OBJECT_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + t->unit[t->curTextureUnit].objTCoeff = v; + DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + case GL_EYE_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + crMatrixInvertTranspose(&inv, trans->modelViewStack.top); + crStateTransformXformPointMatrixf(&inv, &v); + t->unit[t->curTextureUnit].eyeTCoeff = v; + DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bogus pname: %d", pname); + return; + } + break; + case GL_R: + switch (pname) { + case GL_TEXTURE_GEN_MODE: + e = (GLenum) *param; + if (e == GL_OBJECT_LINEAR || + e == GL_EYE_LINEAR || + e == GL_SPHERE_MAP +#if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) + || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) + && g->extensions.ARB_texture_cube_map) +#endif + ) { + t->unit[t->curTextureUnit].gen.r = e; + DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bad param: %lf", *param); + return; + } + break; + case GL_OBJECT_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + t->unit[t->curTextureUnit].objRCoeff = v; + DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + case GL_EYE_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + crMatrixInvertTranspose(&inv, trans->modelViewStack.top); + crStateTransformXformPointMatrixf(&inv, &v); + t->unit[t->curTextureUnit].eyeRCoeff = v; + DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bogus pname: %d", pname); + return; + } + break; + case GL_Q: + switch (pname) { + case GL_TEXTURE_GEN_MODE: + e = (GLenum) *param; + if (e == GL_OBJECT_LINEAR || + e == GL_EYE_LINEAR || + e == GL_SPHERE_MAP +#if defined(GL_ARB_texture_cube_map) || defined(GL_EXT_texture_cube_map) || defined(GL_NV_texgen_reflection) + || ((e == GL_REFLECTION_MAP_ARB || e == GL_NORMAL_MAP_ARB) + && g->extensions.ARB_texture_cube_map) +#endif + ) { + t->unit[t->curTextureUnit].gen.q = e; + DIRTY(tb->genMode[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bad param: %lf", *param); + return; + } + break; + case GL_OBJECT_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + t->unit[t->curTextureUnit].objQCoeff = v; + DIRTY(tb->objGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + case GL_EYE_PLANE: + v.x = (GLfloat) param[0]; + v.y = (GLfloat) param[1]; + v.z = (GLfloat) param[2]; + v.w = (GLfloat) param[3]; + crMatrixInvertTranspose(&inv, trans->modelViewStack.top); + crStateTransformXformPointMatrixf(&inv, &v); + t->unit[t->curTextureUnit].eyeQCoeff = v; + DIRTY(tb->eyeGen[t->curTextureUnit], g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bogus pname: %d", pname); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bogus coord: %d", coord); + return; + } +} + + +void STATE_APIENTRY +crStateTexGenfv(GLenum coord, GLenum pname, const GLfloat *param) +{ + GLdouble d_param; + GLvectord d_vector; + switch (pname) + { + case GL_TEXTURE_GEN_MODE: + d_param = (GLdouble) *param; + crStateTexGendv( coord, pname, &d_param ); + break; + case GL_OBJECT_PLANE: + case GL_EYE_PLANE: + d_vector.x = (GLdouble) param[0]; + d_vector.y = (GLdouble) param[1]; + d_vector.z = (GLdouble) param[2]; + d_vector.w = (GLdouble) param[3]; + crStateTexGendv( coord, pname, (const double *) &d_vector ); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bogus pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateTexGeniv(GLenum coord, GLenum pname, const GLint *param) +{ + GLdouble d_param; + GLvectord d_vector; + switch (pname) + { + case GL_TEXTURE_GEN_MODE: + d_param = (GLdouble) *param; + crStateTexGendv( coord, pname, &d_param ); + break; + case GL_OBJECT_PLANE: + case GL_EYE_PLANE: + d_vector.x = (GLdouble) param[0]; + d_vector.y = (GLdouble) param[1]; + d_vector.z = (GLdouble) param[2]; + d_vector.w = (GLdouble) param[3]; + crStateTexGendv( coord, pname, (const double *) &d_vector ); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glTexGen called with bogus pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateTexGend (GLenum coord, GLenum pname, GLdouble param) +{ + crStateTexGendv( coord, pname, ¶m ); +} + + +void STATE_APIENTRY +crStateTexGenf(GLenum coord, GLenum pname, GLfloat param) +{ + GLdouble d_param = (GLdouble) param; + crStateTexGendv( coord, pname, &d_param ); +} + + +void STATE_APIENTRY +crStateTexGeni(GLenum coord, GLenum pname, GLint param) +{ + GLdouble d_param = (GLdouble) param; + crStateTexGendv( coord, pname, &d_param ); +} + + +void STATE_APIENTRY +crStateGetTexGendv(GLenum coord, GLenum pname, GLdouble *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexGen called in begin/end"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + switch (coord) { + case GL_S: + *param = (GLdouble) t->unit[t->curTextureUnit].gen.s; + break; + case GL_T: + *param = (GLdouble) t->unit[t->curTextureUnit].gen.t; + break; + case GL_R: + *param = (GLdouble) t->unit[t->curTextureUnit].gen.r; + break; + case GL_Q: + *param = (GLdouble) t->unit[t->curTextureUnit].gen.q; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGen called with bogus coord: %d", coord); + return; + } + break; + case GL_OBJECT_PLANE: + switch (coord) { + case GL_S: + param[0] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].objSCoeff.w; + break; + case GL_T: + param[0] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].objTCoeff.w; + break; + case GL_R: + param[0] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].objRCoeff.w; + break; + case GL_Q: + param[0] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].objQCoeff.w; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGen called with bogus coord: %d", coord); + return; + } + break; + case GL_EYE_PLANE: + switch (coord) { + case GL_S: + param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeSCoeff.w; + break; + case GL_T: + param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeTCoeff.w; + break; + case GL_R: + param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeRCoeff.w; + break; + case GL_Q: + param[0] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.x; + param[1] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.y; + param[2] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.z; + param[3] = (GLdouble) t->unit[t->curTextureUnit].eyeQCoeff.w; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGen called with bogus coord: %d", coord); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGen called with bogus pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateGetTexGenfv(GLenum coord, GLenum pname, GLfloat *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexGenfv called in begin/end"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + switch (coord) { + case GL_S: + *param = (GLfloat) t->unit[t->curTextureUnit].gen.s; + break; + case GL_T: + *param = (GLfloat) t->unit[t->curTextureUnit].gen.t; + break; + case GL_R: + *param = (GLfloat) t->unit[t->curTextureUnit].gen.r; + break; + case GL_Q: + *param = (GLfloat) t->unit[t->curTextureUnit].gen.q; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGenfv called with bogus coord: %d", coord); + return; + } + break; + case GL_OBJECT_PLANE: + switch (coord) { + case GL_S: + param[0] = t->unit[t->curTextureUnit].objSCoeff.x; + param[1] = t->unit[t->curTextureUnit].objSCoeff.y; + param[2] = t->unit[t->curTextureUnit].objSCoeff.z; + param[3] = t->unit[t->curTextureUnit].objSCoeff.w; + break; + case GL_T: + param[0] = t->unit[t->curTextureUnit].objTCoeff.x; + param[1] = t->unit[t->curTextureUnit].objTCoeff.y; + param[2] = t->unit[t->curTextureUnit].objTCoeff.z; + param[3] = t->unit[t->curTextureUnit].objTCoeff.w; + break; + case GL_R: + param[0] = t->unit[t->curTextureUnit].objRCoeff.x; + param[1] = t->unit[t->curTextureUnit].objRCoeff.y; + param[2] = t->unit[t->curTextureUnit].objRCoeff.z; + param[3] = t->unit[t->curTextureUnit].objRCoeff.w; + break; + case GL_Q: + param[0] = t->unit[t->curTextureUnit].objQCoeff.x; + param[1] = t->unit[t->curTextureUnit].objQCoeff.y; + param[2] = t->unit[t->curTextureUnit].objQCoeff.z; + param[3] = t->unit[t->curTextureUnit].objQCoeff.w; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGenfv called with bogus coord: %d", coord); + return; + } + break; + case GL_EYE_PLANE: + switch (coord) { + case GL_S: + param[0] = t->unit[t->curTextureUnit].eyeSCoeff.x; + param[1] = t->unit[t->curTextureUnit].eyeSCoeff.y; + param[2] = t->unit[t->curTextureUnit].eyeSCoeff.z; + param[3] = t->unit[t->curTextureUnit].eyeSCoeff.w; + break; + case GL_T: + param[0] = t->unit[t->curTextureUnit].eyeTCoeff.x; + param[1] = t->unit[t->curTextureUnit].eyeTCoeff.y; + param[2] = t->unit[t->curTextureUnit].eyeTCoeff.z; + param[3] = t->unit[t->curTextureUnit].eyeTCoeff.w; + break; + case GL_R: + param[0] = t->unit[t->curTextureUnit].eyeRCoeff.x; + param[1] = t->unit[t->curTextureUnit].eyeRCoeff.y; + param[2] = t->unit[t->curTextureUnit].eyeRCoeff.z; + param[3] = t->unit[t->curTextureUnit].eyeRCoeff.w; + break; + case GL_Q: + param[0] = t->unit[t->curTextureUnit].eyeQCoeff.x; + param[1] = t->unit[t->curTextureUnit].eyeQCoeff.y; + param[2] = t->unit[t->curTextureUnit].eyeQCoeff.z; + param[3] = t->unit[t->curTextureUnit].eyeQCoeff.w; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGenfv called with bogus coord: %d", coord); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGenfv called with bogus pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateGetTexGeniv(GLenum coord, GLenum pname, GLint *param) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexGeniv called in begin/end"); + return; + } + + switch (pname) { + case GL_TEXTURE_GEN_MODE: + switch (coord) { + case GL_S: + *param = (GLint) t->unit[t->curTextureUnit].gen.s; + break; + case GL_T: + *param = (GLint) t->unit[t->curTextureUnit].gen.t; + break; + case GL_R: + *param = (GLint) t->unit[t->curTextureUnit].gen.r; + break; + case GL_Q: + *param = (GLint) t->unit[t->curTextureUnit].gen.q; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGeniv called with bogus coord: %d", coord); + return; + } + break; + case GL_OBJECT_PLANE: + switch (coord) { + case GL_S: + param[0] = (GLint) t->unit[t->curTextureUnit].objSCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].objSCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].objSCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].objSCoeff.w; + break; + case GL_T: + param[0] = (GLint) t->unit[t->curTextureUnit].objTCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].objTCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].objTCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].objTCoeff.w; + break; + case GL_R: + param[0] = (GLint) t->unit[t->curTextureUnit].objRCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].objRCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].objRCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].objRCoeff.w; + break; + case GL_Q: + param[0] = (GLint) t->unit[t->curTextureUnit].objQCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].objQCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].objQCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].objQCoeff.w; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGeniv called with bogus coord: %d", coord); + return; + } + break; + case GL_EYE_PLANE: + switch (coord) { + case GL_S: + param[0] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].eyeSCoeff.w; + break; + case GL_T: + param[0] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].eyeTCoeff.w; + break; + case GL_R: + param[0] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].eyeRCoeff.w; + break; + case GL_Q: + param[0] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.x; + param[1] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.y; + param[2] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.z; + param[3] = (GLint) t->unit[t->curTextureUnit].eyeQCoeff.w; + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGeniv called with bogus coord: %d", coord); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexGen called with bogus pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateGetTexLevelParameterfv(GLenum target, GLint level, + GLenum pname, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj; + CRTextureLevel *timg; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexLevelParameterfv called in begin/end"); + return; + } + + if (level < 0 || level > t->maxLevel) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetTexLevelParameterfv: Invalid level: %d", level); + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &timg); + if (!timg) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetTexLevelParameterfv: invalid target: 0x%x or level %d", + target, level); + return; + } + + switch (pname) + { + case GL_TEXTURE_WIDTH: + *params = (GLfloat) timg->width; + break; + case GL_TEXTURE_HEIGHT: + *params = (GLfloat) timg->height; + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_DEPTH: + *params = (GLfloat) timg->depth; + break; +#endif + case GL_TEXTURE_INTERNAL_FORMAT: + *params = (GLfloat) timg->internalFormat; + break; + case GL_TEXTURE_BORDER: + *params = (GLfloat) timg->border; + break; + case GL_TEXTURE_RED_SIZE: + *params = (GLfloat) timg->texFormat->redbits; + break; + case GL_TEXTURE_GREEN_SIZE: + *params = (GLfloat) timg->texFormat->greenbits; + break; + case GL_TEXTURE_BLUE_SIZE: + *params = (GLfloat) timg->texFormat->bluebits; + break; + case GL_TEXTURE_ALPHA_SIZE: + *params = (GLfloat) timg->texFormat->alphabits; + break; + case GL_TEXTURE_INTENSITY_SIZE: + *params = (GLfloat) timg->texFormat->intensitybits; + break; + case GL_TEXTURE_LUMINANCE_SIZE: + *params = (GLfloat) timg->texFormat->luminancebits; + break; +#if CR_ARB_texture_compression + case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB: + *params = (GLfloat) timg->bytes; + break; + case GL_TEXTURE_COMPRESSED_ARB: + *params = (GLfloat) timg->compressed; + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetTexLevelParameterfv: invalid pname: 0x%x", + pname); + return; + } +} + + +void STATE_APIENTRY +crStateGetTexLevelParameteriv(GLenum target, GLint level, + GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CRTextureState *t = &(g->texture); + CRTextureObj *tobj; + CRTextureLevel *timg; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexLevelParameteriv called in begin/end"); + return; + } + + if (level < 0 || level > t->maxLevel) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glGetTexLevelParameteriv: Invalid level: %d", level); + return; + } + + crStateGetTextureObjectAndImage(g, target, level, &tobj, &timg); + if (!timg) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetTexLevelParameteriv: invalid target: 0x%x", + target); + return; + } + + switch (pname) + { + case GL_TEXTURE_WIDTH: + *params = (GLint) timg->width; + break; + case GL_TEXTURE_HEIGHT: + *params = (GLint) timg->height; + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_DEPTH: + *params = (GLint) timg->depth; + break; +#endif + case GL_TEXTURE_INTERNAL_FORMAT: + *params = (GLint) timg->internalFormat; + break; + case GL_TEXTURE_BORDER: + *params = (GLint) timg->border; + break; + case GL_TEXTURE_RED_SIZE: + *params = (GLint) timg->texFormat->redbits; + break; + case GL_TEXTURE_GREEN_SIZE: + *params = (GLint) timg->texFormat->greenbits; + break; + case GL_TEXTURE_BLUE_SIZE: + *params = (GLint) timg->texFormat->bluebits; + break; + case GL_TEXTURE_ALPHA_SIZE: + *params = (GLint) timg->texFormat->alphabits; + break; + case GL_TEXTURE_INTENSITY_SIZE: + *params = (GLint) timg->texFormat->intensitybits; + break; + case GL_TEXTURE_LUMINANCE_SIZE: + *params = (GLint) timg->texFormat->luminancebits; + break; + +#if 0 + /* XXX TODO */ + case GL_TEXTURE_DEPTH_SIZE: + *params = (GLint) timg->texFormat->depthSize; + break; +#endif +#if CR_ARB_texture_compression + case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB: + *params = (GLint) timg->bytes; + break; + case GL_TEXTURE_COMPRESSED_ARB: + *params = (GLint) timg->compressed; + break; +#endif + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetTexLevelParameteriv: invalid pname: 0x%x", + pname); + return; + } +} + + +void STATE_APIENTRY +crStateGetTexParameterfv(GLenum target, GLenum pname, GLfloat *params) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + CRTextureLevel *tl; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexParameterfv called in begin/end"); + return; + } + + crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl); + if (!tobj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameterfv: invalid target: 0x%x", target); + return; + } + + switch (pname) + { + case GL_TEXTURE_MAG_FILTER: + *params = (GLfloat) tobj->magFilter; + break; + case GL_TEXTURE_MIN_FILTER: + *params = (GLfloat) tobj->minFilter; + break; + case GL_TEXTURE_WRAP_S: + *params = (GLfloat) tobj->wrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = (GLfloat) tobj->wrapT; + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_WRAP_R: + *params = (GLfloat) tobj->wrapR; + break; + case GL_TEXTURE_PRIORITY: + *params = (GLfloat) tobj->priority; + break; +#endif + case GL_TEXTURE_BORDER_COLOR: + params[0] = tobj->borderColor.r; + params[1] = tobj->borderColor.g; + params[2] = tobj->borderColor.b; + params[3] = tobj->borderColor.a; + break; +#ifdef CR_EXT_texture_filter_anisotropic + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (g->extensions.EXT_texture_filter_anisotropic) { + *params = (GLfloat) tobj->maxAnisotropy; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameterfv: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_ARB_depth_texture + case GL_DEPTH_TEXTURE_MODE_ARB: + if (g->extensions.ARB_depth_texture) { + *params = (GLfloat) tobj->depthMode; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_ARB_shadow + case GL_TEXTURE_COMPARE_MODE_ARB: + if (g->extensions.ARB_shadow) { + *params = (GLfloat) tobj->compareMode; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (g->extensions.ARB_shadow) { + *params = (GLfloat) tobj->compareFunc; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_ARB_shadow_ambient + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (g->extensions.ARB_shadow_ambient) { + *params = (GLfloat) tobj->compareFailValue; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_SGIS_generate_mipmap + case GL_GENERATE_MIPMAP_SGIS: + if (g->extensions.SGIS_generate_mipmap) { + *params = (GLfloat) tobj->generateMipmap; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_MIN_LOD: + *params = (GLfloat) tobj->minLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = (GLfloat) tobj->maxLod; + break; + case GL_TEXTURE_BASE_LEVEL: + *params = (GLfloat) tobj->baseLevel; + break; + case GL_TEXTURE_MAX_LEVEL: + *params = (GLfloat) tobj->maxLevel; + break; +#endif +#if 0 + case GL_TEXTURE_LOD_BIAS_EXT: + /* XXX todo */ + *params = (GLfloat) tobj->lodBias; + break; +#endif + case GL_TEXTURE_RESIDENT: + /* XXX todo */ + crWarning("glGetTexParameterfv GL_TEXTURE_RESIDENT is unimplemented"); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameterfv: invalid pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStateGetTexParameteriv(GLenum target, GLenum pname, GLint *params) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + CRTextureLevel *tl; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetTexParameter called in begin/end"); + return; + } + + crStateGetTextureObjectAndImage(g, target, 0, &tobj, &tl); + if (!tobj) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameteriv: invalid target: 0x%x", target); + return; + } + + switch (pname) + { + case GL_TEXTURE_MAG_FILTER: + *params = (GLint) tobj->magFilter; + break; + case GL_TEXTURE_MIN_FILTER: + *params = (GLint) tobj->minFilter; + break; + case GL_TEXTURE_WRAP_S: + *params = (GLint) tobj->wrapS; + break; + case GL_TEXTURE_WRAP_T: + *params = (GLint) tobj->wrapT; + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_WRAP_R: + *params = (GLint) tobj->wrapR; + break; + case GL_TEXTURE_PRIORITY: + *params = (GLint) tobj->priority; + break; +#endif + case GL_TEXTURE_BORDER_COLOR: + params[0] = (GLint) (tobj->borderColor.r * CR_MAXINT); + params[1] = (GLint) (tobj->borderColor.g * CR_MAXINT); + params[2] = (GLint) (tobj->borderColor.b * CR_MAXINT); + params[3] = (GLint) (tobj->borderColor.a * CR_MAXINT); + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_TEXTURE_MIN_LOD: + *params = (GLint) tobj->minLod; + break; + case GL_TEXTURE_MAX_LOD: + *params = (GLint) tobj->maxLod; + break; + case GL_TEXTURE_BASE_LEVEL: + *params = (GLint) tobj->baseLevel; + break; + case GL_TEXTURE_MAX_LEVEL: + *params = (GLint) tobj->maxLevel; + break; +#endif +#ifdef CR_EXT_texture_filter_anisotropic + case GL_TEXTURE_MAX_ANISOTROPY_EXT: + if (g->extensions.EXT_texture_filter_anisotropic) { + *params = (GLint) tobj->maxAnisotropy; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_ARB_depth_texture + case GL_DEPTH_TEXTURE_MODE_ARB: + if (g->extensions.ARB_depth_texture) { + *params = (GLint) tobj->depthMode; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_ARB_shadow + case GL_TEXTURE_COMPARE_MODE_ARB: + if (g->extensions.ARB_shadow) { + *params = (GLint) tobj->compareMode; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; + case GL_TEXTURE_COMPARE_FUNC_ARB: + if (g->extensions.ARB_shadow) { + *params = (GLint) tobj->compareFunc; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_ARB_shadow_ambient + case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB: + if (g->extensions.ARB_shadow_ambient) { + *params = (GLint) tobj->compareFailValue; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif +#ifdef CR_SGIS_generate_mipmap + case GL_GENERATE_MIPMAP_SGIS: + if (g->extensions.SGIS_generate_mipmap) { + *params = (GLint) tobj->generateMipmap; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: 0x%x", pname); + return; + } + break; +#endif + case GL_TEXTURE_RESIDENT: + /* XXX todo */ + crWarning("glGetTexParameteriv GL_TEXTURE_RESIDENT is unimplemented"); + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "glGetTexParameter: invalid pname: %d", pname); + return; + } +} + + +void STATE_APIENTRY +crStatePrioritizeTextures(GLsizei n, const GLuint *textures, + const GLclampf *priorities) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + GLsizei i; + UNUSED(priorities); + + for (i = 0; i < n; ++i) + { + GLuint tex = textures[i]; + GET_TOBJ(tobj, g, tex); + if (!tobj) + { + Assert(crHashtableIsKeyUsed(g->shared->textureTable, tex)); + tobj = crStateTextureAllocate_t(g, tex); + } + + /* so far the code just ensures the tex object is created to make + * the crserverlib code be able to pass it to host ogl */ + + /** @todo store texture priorities in the state data to be able to restore it properly + * on save state load */ + } + + return; +} + + +GLboolean STATE_APIENTRY +crStateAreTexturesResident(GLsizei n, const GLuint *textures, + GLboolean *residences) +{ + UNUSED(n); + UNUSED(textures); + UNUSED(residences); + /** @todo */ + return GL_TRUE; +} + + +GLboolean STATE_APIENTRY +crStateIsTexture(GLuint texture) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + + GET_TOBJ(tobj, g, texture); + return tobj != NULL; +} + +static void crStateCheckTextureHWIDCB(unsigned long key, void *data1, void *data2) +{ + CRTextureObj *pTex = (CRTextureObj *) data1; + crCheckIDHWID_t *pParms = (crCheckIDHWID_t*) data2; + (void) key; + + if (crStateGetTextureObjHWID(pTex)==pParms->hwid) + pParms->id = pTex->id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateTextureHWIDtoID(GLuint hwid) +{ + CRContext *g = GetCurrentContext(); + crCheckIDHWID_t parms; + + parms.id = hwid; + parms.hwid = hwid; + + crHashtableWalk(g->shared->textureTable, crStateCheckTextureHWIDCB, &parms); + return parms.id; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureHWID(GLuint id) +{ + CRContext *g = GetCurrentContext(); + CRTextureObj *tobj; + + GET_TOBJ(tobj, g, id); + +#ifdef DEBUG_misha + if (id) + { + Assert(tobj); + } + else + { + Assert(!tobj); + } + if (tobj) + { +/* crDebug("tex id(%d), hwid(%d)", tobj->id, tobj->hwid);*/ + } +#endif + + + return tobj ? crStateGetTextureObjHWID(tobj) : 0; +} + +DECLEXPORT(GLuint) STATE_APIENTRY crStateGetTextureObjHWID(CRTextureObj *tobj) +{ + CRASSERT(tobj); + +#ifndef IN_GUEST + if (tobj->id && !tobj->hwid) + { + CRASSERT(diff_api.GenTextures); + diff_api.GenTextures(1, &tobj->hwid); +#if 0 /*def DEBUG_misha*/ + crDebug("tex id(%d), hwid(%d)", tobj->id, tobj->hwid); +#endif + CRASSERT(tobj->hwid); + } +#endif + + return tobj->hwid; +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_transform.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_transform.c new file mode 100644 index 00000000..642561bd --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_transform.c @@ -0,0 +1,1392 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_bits.h" +#include "cr_mem.h" +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +#ifdef WINDOWS +#pragma warning( disable : 4514 ) +#endif + +/* + * This used to be a macro. + */ +static INLINE void +LOADMATRIX( const CRmatrix *a ) +{ + if (a->m00 == 1.0F && a->m01 == 0.0F && a->m02 == 0.0F && a->m03 == 0.0F && + a->m10 == 0.0F && a->m11 == 1.0F && a->m12 == 0.0F && a->m13 == 0.0F && + a->m20 == 0.0F && a->m21 == 0.0F && a->m22 == 1.0F && a->m23 == 0.0F && + a->m30 == 0.0F && a->m31 == 0.0F && a->m32 == 0.0F && a->m33 == 1.0F) { + diff_api.LoadIdentity(); + } + else { + GLfloat f[16]; + f[0] = a->m00; f[1] = a->m01; f[2] = a->m02; f[3] = a->m03; + f[4] = a->m10; f[5] = a->m11; f[6] = a->m12; f[7] = a->m13; + f[8] = a->m20; f[9] = a->m21; f[10] = a->m22; f[11] = a->m23; + f[12] = a->m30; f[13] = a->m31; f[14] = a->m32; f[15] = a->m33; + diff_api.LoadMatrixf(f); + } +} + + +static void _math_transposef( GLfloat to[16], const GLfloat from[16] ) +{ + to[0] = from[0]; + to[1] = from[4]; + to[2] = from[8]; + to[3] = from[12]; + to[4] = from[1]; + to[5] = from[5]; + to[6] = from[9]; + to[7] = from[13]; + to[8] = from[2]; + to[9] = from[6]; + to[10] = from[10]; + to[11] = from[14]; + to[12] = from[3]; + to[13] = from[7]; + to[14] = from[11]; + to[15] = from[15]; +} + +static void _math_transposed( GLdouble to[16], const GLdouble from[16] ) +{ + to[0] = from[0]; + to[1] = from[4]; + to[2] = from[8]; + to[3] = from[12]; + to[4] = from[1]; + to[5] = from[5]; + to[6] = from[9]; + to[7] = from[13]; + to[8] = from[2]; + to[9] = from[6]; + to[10] = from[10]; + to[11] = from[14]; + to[12] = from[3]; + to[13] = from[7]; + to[14] = from[11]; + to[15] = from[15]; +} + + +void +crStateInitMatrixStack(CRMatrixStack *stack, int maxDepth) +{ + stack->maxDepth = maxDepth; + stack->depth = 0; + stack->stack = crAlloc(maxDepth * sizeof(CRmatrix)); + crMatrixInit(&stack->stack[0]); + stack->top = stack->stack; +} + +static void +free_matrix_stack_data(CRMatrixStack *stack) +{ + crFree(stack->stack); +} + +void crStateTransformDestroy(CRContext *ctx) +{ + CRTransformState *t = &ctx->transform; + unsigned int i; + + free_matrix_stack_data(&(t->modelViewStack)); + free_matrix_stack_data(&(t->projectionStack)); + free_matrix_stack_data(&(t->colorStack)); + for (i = 0 ; i < ctx->limits.maxTextureUnits; i++) + free_matrix_stack_data(&(t->textureStack[i])); + for (i = 0; i < CR_MAX_PROGRAM_MATRICES; i++) + free_matrix_stack_data(&(t->programStack[i])); + + crFree( t->clipPlane ); + crFree( t->clip ); +} + +void crStateTransformInit(CRContext *ctx) +{ + CRLimitsState *limits = &ctx->limits; + CRTransformState *t = &ctx->transform; + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + unsigned int i; + + t->matrixMode = GL_MODELVIEW; + RESET(tb->matrixMode, ctx->bitid); + + crStateInitMatrixStack(&t->modelViewStack, CR_MAX_MODELVIEW_STACK_DEPTH); + crStateInitMatrixStack(&t->projectionStack, CR_MAX_PROJECTION_STACK_DEPTH); + crStateInitMatrixStack(&t->colorStack, CR_MAX_COLOR_STACK_DEPTH); + for (i = 0 ; i < limits->maxTextureUnits ; i++) + crStateInitMatrixStack(&t->textureStack[i], CR_MAX_TEXTURE_STACK_DEPTH); + for (i = 0 ; i < CR_MAX_PROGRAM_MATRICES ; i++) + crStateInitMatrixStack(&t->programStack[i], CR_MAX_PROGRAM_MATRIX_STACK_DEPTH); + t->currentStack = &(t->modelViewStack); + + /* dirty bits */ + RESET(tb->modelviewMatrix, ctx->bitid); + RESET(tb->projectionMatrix, ctx->bitid); + RESET(tb->colorMatrix, ctx->bitid); + RESET(tb->textureMatrix, ctx->bitid); + RESET(tb->programMatrix, ctx->bitid); + tb->currentMatrix = tb->modelviewMatrix; + + t->normalize = GL_FALSE; + RESET(tb->enable, ctx->bitid); + + t->clipPlane = (GLvectord *) crCalloc (sizeof (GLvectord) * CR_MAX_CLIP_PLANES); + t->clip = (GLboolean *) crCalloc (sizeof (GLboolean) * CR_MAX_CLIP_PLANES); + for (i = 0; i < CR_MAX_CLIP_PLANES; i++) + { + t->clipPlane[i].x = 0.0f; + t->clipPlane[i].y = 0.0f; + t->clipPlane[i].z = 0.0f; + t->clipPlane[i].w = 0.0f; + t->clip[i] = GL_FALSE; + } + RESET(tb->clipPlane, ctx->bitid); + +#ifdef CR_OPENGL_VERSION_1_2 + t->rescaleNormals = GL_FALSE; +#endif +#ifdef CR_IBM_rasterpos_clip + t->rasterPositionUnclipped = GL_FALSE; +#endif + + t->modelViewProjectionValid = 0; + + RESET(tb->dirty, ctx->bitid); +} + + +/* + * Compute the product of the modelview and projection matrices + */ +void crStateTransformUpdateTransform(CRTransformState *t) +{ + const CRmatrix *m1 = t->projectionStack.top; + const CRmatrix *m2 = t->modelViewStack.top; + CRmatrix *m = &(t->modelViewProjection); + crMatrixMultiply(m, m1, m2); + t->modelViewProjectionValid = 1; +} + +void crStateTransformXformPoint(CRTransformState *t, GLvectorf *p) +{ + /* XXX is this flag really needed? We may be covering a bug elsewhere */ + if (!t->modelViewProjectionValid) + crStateTransformUpdateTransform(t); + + crStateTransformXformPointMatrixf(&(t->modelViewProjection), p); +} + +void crStateTransformXformPointMatrixf(const CRmatrix *m, GLvectorf *p) +{ + GLfloat x = p->x; + GLfloat y = p->y; + GLfloat z = p->z; + GLfloat w = p->w; + + p->x = m->m00*x + m->m10*y + m->m20*z + m->m30*w; + p->y = m->m01*x + m->m11*y + m->m21*z + m->m31*w; + p->z = m->m02*x + m->m12*y + m->m22*z + m->m32*w; + p->w = m->m03*x + m->m13*y + m->m23*z + m->m33*w; +} + +void crStateTransformXformPointMatrixd(const CRmatrix *m, GLvectord *p) +{ + GLdouble x = p->x; + GLdouble y = p->y; + GLdouble z = p->z; + GLdouble w = p->w; + + p->x = (GLdouble) (m->m00*x + m->m10*y + m->m20*z + m->m30*w); + p->y = (GLdouble) (m->m01*x + m->m11*y + m->m21*z + m->m31*w); + p->z = (GLdouble) (m->m02*x + m->m12*y + m->m22*z + m->m32*w); + p->w = (GLdouble) (m->m03*x + m->m13*y + m->m23*z + m->m33*w); +} + +void STATE_APIENTRY crStateClipPlane (GLenum plane, const GLdouble *equation) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &g->transform; + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + GLvectord e; + unsigned int i; + CRmatrix inv; + + e.x = equation[0]; + e.y = equation[1]; + e.z = equation[2]; + e.w = equation[3]; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "ClipPlane called in begin/end"); + return; + } + + FLUSH(); + + i = plane - GL_CLIP_PLANE0; + if (i >= g->limits.maxClipPlanes) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "ClipPlane called with bad enumerant: %d", plane); + return; + } + + crMatrixInvertTranspose(&inv, t->modelViewStack.top); + crStateTransformXformPointMatrixd (&inv, &e); + t->clipPlane[i] = e; + DIRTY(tb->clipPlane, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateMatrixMode(GLenum e) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRTextureState *tex = &(g->texture); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "MatrixMode called in begin/end"); + return; + } + + FLUSH(); + + switch (e) + { + case GL_MODELVIEW: + t->currentStack = &(t->modelViewStack); + t->matrixMode = GL_MODELVIEW; + tb->currentMatrix = tb->modelviewMatrix; + break; + case GL_PROJECTION: + t->currentStack = &(t->projectionStack); + t->matrixMode = GL_PROJECTION; + tb->currentMatrix = tb->projectionMatrix; + break; + case GL_TEXTURE: + t->currentStack = &(t->textureStack[tex->curTextureUnit]); + t->matrixMode = GL_TEXTURE; + tb->currentMatrix = tb->textureMatrix; + break; + case GL_COLOR: + t->currentStack = &(t->colorStack); + t->matrixMode = GL_COLOR; + tb->currentMatrix = tb->colorMatrix; + break; + case GL_MATRIX0_NV: + case GL_MATRIX1_NV: + case GL_MATRIX2_NV: + case GL_MATRIX3_NV: + case GL_MATRIX4_NV: + case GL_MATRIX5_NV: + case GL_MATRIX6_NV: + case GL_MATRIX7_NV: + if (g->extensions.NV_vertex_program) { + const GLint i = e - GL_MATRIX0_NV; + t->currentStack = &(t->programStack[i]); + t->matrixMode = e; + tb->currentMatrix = tb->programMatrix; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e); + return; + } + break; + case GL_MATRIX0_ARB: + case GL_MATRIX1_ARB: + case GL_MATRIX2_ARB: + case GL_MATRIX3_ARB: + case GL_MATRIX4_ARB: + case GL_MATRIX5_ARB: + case GL_MATRIX6_ARB: + case GL_MATRIX7_ARB: + /* Note: the NV and ARB program matrices are the same, but + * use different enumerants. + */ + if (g->extensions.ARB_vertex_program) { + const GLint i = e - GL_MATRIX0_ARB; + t->currentStack = &(t->programStack[i]); + t->matrixMode = e; + tb->currentMatrix = tb->programMatrix; + } + else { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e); + return; + } + break; + default: + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, "Invalid matrix mode: %d", e); + return; + } + DIRTY(tb->matrixMode, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); + + CRASSERT(t->currentStack->top == t->currentStack->stack + t->currentStack->depth); +} + +void STATE_APIENTRY crStateLoadIdentity() +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "LoadIdentity called in begin/end"); + return; + } + + FLUSH(); + + crMatrixInit(t->currentStack->top); + t->modelViewProjectionValid = 0; + + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePopMatrix() +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &g->transform; + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PopMatrix called in begin/end"); + return; + } + + FLUSH(); + + if (t->currentStack->depth == 0) + { + crStateError(__LINE__, __FILE__, GL_STACK_UNDERFLOW, "PopMatrix of empty stack."); + return; + } + + CRASSERT(t->currentStack->top == t->currentStack->stack + t->currentStack->depth); + + t->currentStack->depth--; + t->currentStack->top = t->currentStack->stack + t->currentStack->depth; + + t->modelViewProjectionValid = 0; + + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStatePushMatrix() +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &g->transform; + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "PushMatrix called in begin/end"); + return; + } + + FLUSH(); + + if (t->currentStack->depth + 1 >= t->currentStack->maxDepth) + { + crStateError(__LINE__, __FILE__, GL_STACK_OVERFLOW, "PushMatrix pass the end of allocated stack"); + return; + } + + CRASSERT(t->currentStack->top == t->currentStack->stack + t->currentStack->depth); + /* Perform the copy */ + *(t->currentStack->top + 1) = *(t->currentStack->top); + + /* Move the stack pointer */ + t->currentStack->depth++; + t->currentStack->top = t->currentStack->stack + t->currentStack->depth; + + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +/* Load a CRMatrix */ +void crStateLoadMatrix(const CRmatrix *m) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "LoadMatrix called in begin/end"); + return; + } + + FLUSH(); + + CRASSERT(t->currentStack->top == t->currentStack->stack + t->currentStack->depth); + *t->currentStack->top = *m; + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + + +void STATE_APIENTRY crStateLoadMatrixf(const GLfloat *m1) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "LoadMatrixf called in begin/end"); + return; + } + + FLUSH(); + + crMatrixInitFromFloats(t->currentStack->top, m1); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateLoadMatrixd(const GLdouble *m1) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "LoadMatrixd called in begin/end"); + return; + } + + FLUSH(); + + crMatrixInitFromDoubles(t->currentStack->top, m1); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateLoadTransposeMatrixfARB(const GLfloat *m1) +{ + GLfloat tm[16]; + if (!m1) return; + _math_transposef(tm, m1); + crStateLoadMatrixf(tm); +} + +void STATE_APIENTRY crStateLoadTransposeMatrixdARB(const GLdouble *m1) +{ + GLdouble tm[16]; + if (!m1) return; + _math_transposed(tm, m1); + crStateLoadMatrixd(tm); +} + +/* This code is based on the Pomegranate stuff. + ** The theory is that by preloading everything, + ** the compiler could do optimizations that + ** were not doable in the array version + ** I'm not too sure with a PII with 4 registers + ** that this really helps. + */ +void STATE_APIENTRY crStateMultMatrixf(const GLfloat *m1) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + CRmatrix *m = t->currentStack->top; + + const GLdefault lm00 = m->m00; + const GLdefault lm01 = m->m01; + const GLdefault lm02 = m->m02; + const GLdefault lm03 = m->m03; + const GLdefault lm10 = m->m10; + const GLdefault lm11 = m->m11; + const GLdefault lm12 = m->m12; + const GLdefault lm13 = m->m13; + const GLdefault lm20 = m->m20; + const GLdefault lm21 = m->m21; + const GLdefault lm22 = m->m22; + const GLdefault lm23 = m->m23; + const GLdefault lm30 = m->m30; + const GLdefault lm31 = m->m31; + const GLdefault lm32 = m->m32; + const GLdefault lm33 = m->m33; + const GLdefault rm00 = (GLdefault) m1[0]; + const GLdefault rm01 = (GLdefault) m1[1]; + const GLdefault rm02 = (GLdefault) m1[2]; + const GLdefault rm03 = (GLdefault) m1[3]; + const GLdefault rm10 = (GLdefault) m1[4]; + const GLdefault rm11 = (GLdefault) m1[5]; + const GLdefault rm12 = (GLdefault) m1[6]; + const GLdefault rm13 = (GLdefault) m1[7]; + const GLdefault rm20 = (GLdefault) m1[8]; + const GLdefault rm21 = (GLdefault) m1[9]; + const GLdefault rm22 = (GLdefault) m1[10]; + const GLdefault rm23 = (GLdefault) m1[11]; + const GLdefault rm30 = (GLdefault) m1[12]; + const GLdefault rm31 = (GLdefault) m1[13]; + const GLdefault rm32 = (GLdefault) m1[14]; + const GLdefault rm33 = (GLdefault) m1[15]; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "MultMatrixf called in begin/end"); + return; + } + + FLUSH(); + + m->m00 = lm00*rm00 + lm10*rm01 + lm20*rm02 + lm30*rm03; + m->m01 = lm01*rm00 + lm11*rm01 + lm21*rm02 + lm31*rm03; + m->m02 = lm02*rm00 + lm12*rm01 + lm22*rm02 + lm32*rm03; + m->m03 = lm03*rm00 + lm13*rm01 + lm23*rm02 + lm33*rm03; + m->m10 = lm00*rm10 + lm10*rm11 + lm20*rm12 + lm30*rm13; + m->m11 = lm01*rm10 + lm11*rm11 + lm21*rm12 + lm31*rm13; + m->m12 = lm02*rm10 + lm12*rm11 + lm22*rm12 + lm32*rm13; + m->m13 = lm03*rm10 + lm13*rm11 + lm23*rm12 + lm33*rm13; + m->m20 = lm00*rm20 + lm10*rm21 + lm20*rm22 + lm30*rm23; + m->m21 = lm01*rm20 + lm11*rm21 + lm21*rm22 + lm31*rm23; + m->m22 = lm02*rm20 + lm12*rm21 + lm22*rm22 + lm32*rm23; + m->m23 = lm03*rm20 + lm13*rm21 + lm23*rm22 + lm33*rm23; + m->m30 = lm00*rm30 + lm10*rm31 + lm20*rm32 + lm30*rm33; + m->m31 = lm01*rm30 + lm11*rm31 + lm21*rm32 + lm31*rm33; + m->m32 = lm02*rm30 + lm12*rm31 + lm22*rm32 + lm32*rm33; + m->m33 = lm03*rm30 + lm13*rm31 + lm23*rm32 + lm33*rm33; + + t->modelViewProjectionValid = 0; + + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateMultMatrixd(const GLdouble *m1) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + CRmatrix *m = t->currentStack->top; + const GLdefault lm00 = m->m00; + const GLdefault lm01 = m->m01; + const GLdefault lm02 = m->m02; + const GLdefault lm03 = m->m03; + const GLdefault lm10 = m->m10; + const GLdefault lm11 = m->m11; + const GLdefault lm12 = m->m12; + const GLdefault lm13 = m->m13; + const GLdefault lm20 = m->m20; + const GLdefault lm21 = m->m21; + const GLdefault lm22 = m->m22; + const GLdefault lm23 = m->m23; + const GLdefault lm30 = m->m30; + const GLdefault lm31 = m->m31; + const GLdefault lm32 = m->m32; + const GLdefault lm33 = m->m33; + const GLdefault rm00 = (GLdefault) m1[0]; + const GLdefault rm01 = (GLdefault) m1[1]; + const GLdefault rm02 = (GLdefault) m1[2]; + const GLdefault rm03 = (GLdefault) m1[3]; + const GLdefault rm10 = (GLdefault) m1[4]; + const GLdefault rm11 = (GLdefault) m1[5]; + const GLdefault rm12 = (GLdefault) m1[6]; + const GLdefault rm13 = (GLdefault) m1[7]; + const GLdefault rm20 = (GLdefault) m1[8]; + const GLdefault rm21 = (GLdefault) m1[9]; + const GLdefault rm22 = (GLdefault) m1[10]; + const GLdefault rm23 = (GLdefault) m1[11]; + const GLdefault rm30 = (GLdefault) m1[12]; + const GLdefault rm31 = (GLdefault) m1[13]; + const GLdefault rm32 = (GLdefault) m1[14]; + const GLdefault rm33 = (GLdefault) m1[15]; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "MultMatrixd called in begin/end"); + return; + } + + FLUSH(); + + m->m00 = lm00*rm00 + lm10*rm01 + lm20*rm02 + lm30*rm03; + m->m01 = lm01*rm00 + lm11*rm01 + lm21*rm02 + lm31*rm03; + m->m02 = lm02*rm00 + lm12*rm01 + lm22*rm02 + lm32*rm03; + m->m03 = lm03*rm00 + lm13*rm01 + lm23*rm02 + lm33*rm03; + m->m10 = lm00*rm10 + lm10*rm11 + lm20*rm12 + lm30*rm13; + m->m11 = lm01*rm10 + lm11*rm11 + lm21*rm12 + lm31*rm13; + m->m12 = lm02*rm10 + lm12*rm11 + lm22*rm12 + lm32*rm13; + m->m13 = lm03*rm10 + lm13*rm11 + lm23*rm12 + lm33*rm13; + m->m20 = lm00*rm20 + lm10*rm21 + lm20*rm22 + lm30*rm23; + m->m21 = lm01*rm20 + lm11*rm21 + lm21*rm22 + lm31*rm23; + m->m22 = lm02*rm20 + lm12*rm21 + lm22*rm22 + lm32*rm23; + m->m23 = lm03*rm20 + lm13*rm21 + lm23*rm22 + lm33*rm23; + m->m30 = lm00*rm30 + lm10*rm31 + lm20*rm32 + lm30*rm33; + m->m31 = lm01*rm30 + lm11*rm31 + lm21*rm32 + lm31*rm33; + m->m32 = lm02*rm30 + lm12*rm31 + lm22*rm32 + lm32*rm33; + m->m33 = lm03*rm30 + lm13*rm31 + lm23*rm32 + lm33*rm33; + + t->modelViewProjectionValid = 0; + + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateMultTransposeMatrixfARB(const GLfloat *m1) +{ + GLfloat tm[16]; + if (!m1) return; + _math_transposef(tm, m1); + crStateMultMatrixf(tm); +} + +void STATE_APIENTRY crStateMultTransposeMatrixdARB(const GLdouble *m1) +{ + GLdouble tm[16]; + if (!m1) return; + _math_transposed(tm, m1); + crStateMultMatrixd(tm); +} + +void STATE_APIENTRY crStateTranslatef(GLfloat x_arg, GLfloat y_arg, GLfloat z_arg) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Translatef called in begin/end"); + return; + } + + FLUSH(); + + crMatrixTranslate(t->currentStack->top, x_arg, y_arg, z_arg); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateTranslated(GLdouble x_arg, GLdouble y_arg, GLdouble z_arg) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Translated called in begin/end"); + return; + } + + FLUSH(); + + crMatrixTranslate(t->currentStack->top, (float)x_arg, (float)y_arg, (float)z_arg); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + + +void STATE_APIENTRY crStateRotatef(GLfloat ang, GLfloat x, GLfloat y, GLfloat z) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Rotatef called in begin/end"); + return; + } + + FLUSH(); + + crMatrixRotate(t->currentStack->top, ang, x, y, z); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateRotated(GLdouble ang, GLdouble x, GLdouble y, GLdouble z) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Rotated called in begin/end"); + return; + } + + FLUSH(); + + crMatrixRotate(t->currentStack->top, (float)ang, (float)x, (float)y, (float)z); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateScalef (GLfloat x_arg, GLfloat y_arg, GLfloat z_arg) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Scalef called in begin/end"); + return; + } + + FLUSH(); + + crMatrixScale(t->currentStack->top, x_arg, y_arg, z_arg); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateScaled (GLdouble x_arg, GLdouble y_arg, GLdouble z_arg) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Scaled called in begin/end"); + return; + } + + FLUSH(); + + crMatrixScale(t->currentStack->top, (float)x_arg, (float)y_arg, (float)z_arg); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateFrustum(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble zNear, GLdouble zFar) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Frustum called in begin/end"); + return; + } + + FLUSH(); + + crMatrixFrustum(t->currentStack->top, (float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateOrtho(GLdouble left, GLdouble right, + GLdouble bottom, GLdouble top, + GLdouble zNear, GLdouble zFar) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &(g->transform); + CRStateBits *sb = GetCurrentBits(); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "Ortho called in begin/end"); + return; + } + + FLUSH(); + + crMatrixOrtho(t->currentStack->top, (float)left, (float)right, (float)bottom, (float)top, (float)zNear, (float)zFar); + t->modelViewProjectionValid = 0; + DIRTY(tb->currentMatrix, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateGetClipPlane(GLenum plane, GLdouble *equation) +{ + CRContext *g = GetCurrentContext(); + CRTransformState *t = &g->transform; + unsigned int i; + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glGetClipPlane called in begin/end"); + return; + } + + i = plane - GL_CLIP_PLANE0; + if (i >= g->limits.maxClipPlanes) + { + crStateError(__LINE__, __FILE__, GL_INVALID_ENUM, + "GetClipPlane called with bad enumerant: %d", plane); + return; + } + + equation[0] = t->clipPlane[i].x; + equation[1] = t->clipPlane[i].y; + equation[2] = t->clipPlane[i].z; + equation[3] = t->clipPlane[i].w; +} + +void crStateTransformSwitch( CRTransformBits *t, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + const GLuint maxTextureUnits = toCtx->limits.maxTextureUnits; + CRTransformState *from = &(fromCtx->transform); + CRTransformState *to = &(toCtx->transform); + GLuint i, j; + unsigned int checktex = 0; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j=0;jenable, bitID)) + { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + if (from->normalize != to->normalize) { + if (to->normalize == GL_TRUE) + diff_api.Enable(GL_NORMALIZE); + else + diff_api.Disable(GL_NORMALIZE); + FILLDIRTY(t->enable); + FILLDIRTY(t->dirty); + } +#ifdef CR_OPENGL_VERSION_1_2 + if (from->rescaleNormals != to->rescaleNormals) + { + able[to->rescaleNormals](GL_RESCALE_NORMAL); + FILLDIRTY(t->enable); + FILLDIRTY(t->dirty); + } +#else + (void) able; +#endif +#ifdef CR_IBM_rasterpos_clip + if (from->rasterPositionUnclipped != to->rasterPositionUnclipped) + { + able[to->rasterPositionUnclipped](GL_RASTER_POSITION_UNCLIPPED_IBM); + FILLDIRTY(t->enable); + FILLDIRTY(t->dirty); + } +#endif + CLEARDIRTY(t->enable, nbitID); + } + + if (CHECKDIRTY(t->clipPlane, bitID)) { + diff_api.MatrixMode(GL_MODELVIEW); + diff_api.PushMatrix(); + diff_api.LoadIdentity(); + for (i=0; iclipPlane[i].x != to->clipPlane[i].x || + from->clipPlane[i].y != to->clipPlane[i].y || + from->clipPlane[i].z != to->clipPlane[i].z || + from->clipPlane[i].w != to->clipPlane[i].w) { + + GLdouble cp[4]; + cp[0] = to->clipPlane[i].x; + cp[1] = to->clipPlane[i].y; + cp[2] = to->clipPlane[i].z; + cp[3] = to->clipPlane[i].w; + + diff_api.ClipPlane(GL_CLIP_PLANE0 + i, (const GLdouble *)(cp)); + + FILLDIRTY(t->clipPlane); + FILLDIRTY(t->dirty); + } + } + diff_api.PopMatrix(); + CLEARDIRTY(t->clipPlane, nbitID); + } + + /* If the matrix stack depths don't match when we're + * updating the context - we can update the wrong matrix + * and get some lovely effects!! + * So we troll each depth list here and Pop & Push the matrix stack + * to bring it right up to date before checking the current + * matrix. + * + * - Alan H. + */ + if ( (from->modelViewStack.depth != to->modelViewStack.depth) || + CHECKDIRTY(t->modelviewMatrix, bitID) ) + { + GLuint td = to->modelViewStack.depth; + GLuint fd = from->modelViewStack.depth; + + if (td != fd || + !crMatrixIsEqual(to->modelViewStack.top, from->modelViewStack.top)) + { + diff_api.MatrixMode(GL_MODELVIEW); + + if (fd > td) + { + for (i = td; i < fd; i++) + { + diff_api.PopMatrix(); + } + fd = td; + } + + for (i = fd; i <= td; i++) + { + LOADMATRIX(to->modelViewStack.stack + i); + FILLDIRTY(t->modelviewMatrix); + FILLDIRTY(t->dirty); + + /* Don't want to push on the current matrix */ + if (i != to->modelViewStack.depth) + diff_api.PushMatrix(); + } + } + CLEARDIRTY(t->modelviewMatrix, nbitID); + } + + /* Projection matrix */ + if ( (from->projectionStack.depth != to->projectionStack.depth) || + CHECKDIRTY(t->projectionMatrix, bitID) ) + { + GLuint td = to->projectionStack.depth; + GLuint fd = from->projectionStack.depth; + + if (td != fd || + !crMatrixIsEqual(to->projectionStack.top, from->projectionStack.top)) { + + diff_api.MatrixMode(GL_PROJECTION); + + if (fd > td) + { + for (i = td; i < fd; i++) + { + diff_api.PopMatrix(); + } + fd = td; + } + + for (i = fd; i <= td; i++) + { + LOADMATRIX(to->projectionStack.stack + i); + FILLDIRTY(t->projectionMatrix); + FILLDIRTY(t->dirty); + + /* Don't want to push on the current matrix */ + if (i != to->projectionStack.depth) + diff_api.PushMatrix(); + } + } + CLEARDIRTY(t->projectionMatrix, nbitID); + } + + /* Texture matrices */ + for (i = 0 ; i < maxTextureUnits ; i++) + if (from->textureStack[i].depth != to->textureStack[i].depth) + checktex = 1; + + if ( checktex || CHECKDIRTY(t->textureMatrix, bitID) ) + { + for (j = 0 ; j < maxTextureUnits ; j++) + { + GLuint td = to->textureStack[j].depth; + GLuint fd = from->textureStack[j].depth; + + if (td != fd || + !crMatrixIsEqual(to->textureStack[j].top, from->textureStack[j].top)) + { + diff_api.MatrixMode(GL_TEXTURE); + + if (fd > td) + { + for (i = td; i < fd; i++) + { + diff_api.PopMatrix(); + } + fd = td; + } + + diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB ); + for (i = fd; i <= td; i++) + { + LOADMATRIX(to->textureStack[j].stack + i); + FILLDIRTY(t->textureMatrix); + FILLDIRTY(t->dirty); + + /* Don't want to push on the current matrix */ + if (i != to->textureStack[j].depth) + diff_api.PushMatrix(); + } + } + } + /* Since we were mucking with the active texture unit above set it to the + * proper value now. + */ + diff_api.ActiveTextureARB(GL_TEXTURE0_ARB + toCtx->texture.curTextureUnit); + CLEARDIRTY(t->textureMatrix, nbitID); + } + + /* Color matrix */ + if ( (from->colorStack.depth != to->colorStack.depth) || + CHECKDIRTY(t->colorMatrix, bitID) ) + { + GLuint td = to->colorStack.depth; + GLuint fd = from->colorStack.depth; + if (td != fd || !crMatrixIsEqual(to->colorStack.top, from->colorStack.top)) + { + diff_api.MatrixMode(GL_COLOR); + + if (fd > td) + { + for (i = td; i < fd; i++) + { + diff_api.PopMatrix(); + } + fd = td; + } + + for (i = fd; i <= td; i++) + { + LOADMATRIX(to->colorStack.stack + i); + FILLDIRTY(t->colorMatrix); + FILLDIRTY(t->dirty); + + /* Don't want to push on the current matrix */ + if (i != to->colorStack.depth) + diff_api.PushMatrix(); + } + } + CLEARDIRTY(t->colorMatrix, nbitID); + } + + to->modelViewProjectionValid = 0; + CLEARDIRTY(t->dirty, nbitID); + + /* Since we were mucking with the current matrix above + * set it to the proper value now. + */ + diff_api.MatrixMode(to->matrixMode); + + /* sanity tests */ + CRASSERT(from->modelViewStack.top == from->modelViewStack.stack + from->modelViewStack.depth); + CRASSERT(from->projectionStack.top == from->projectionStack.stack + from->projectionStack.depth); + +} + +void +crStateTransformDiff( CRTransformBits *t, CRbitvalue *bitID, + CRContext *fromCtx, CRContext *toCtx ) +{ + const GLuint maxTextureUnits = toCtx->limits.maxTextureUnits; + CRTransformState *from = &(fromCtx->transform); + CRTransformState *to = &(toCtx->transform); + CRTextureState *textureFrom = &(fromCtx->texture); + GLuint i, j; + unsigned int checktex = 0; + CRbitvalue nbitID[CR_MAX_BITARRAY]; + + for (j=0;jenable, bitID)) { + glAble able[2]; + able[0] = diff_api.Disable; + able[1] = diff_api.Enable; + for (i=0; iclip[i] != to->clip[i]) { + if (to->clip[i] == GL_TRUE) + diff_api.Enable(GL_CLIP_PLANE0 + i); + else + diff_api.Disable(GL_CLIP_PLANE0 + i); + from->clip[i] = to->clip[i]; + } + } + if (from->normalize != to->normalize) { + if (to->normalize == GL_TRUE) + diff_api.Enable(GL_NORMALIZE); + else + diff_api.Disable(GL_NORMALIZE); + from->normalize = to->normalize; + } +#ifdef CR_OPENGL_VERSION_1_2 + if (from->rescaleNormals != to->rescaleNormals) { + able[to->rescaleNormals](GL_RESCALE_NORMAL); + from->rescaleNormals = to->rescaleNormals; + } +#else + (void) able; +#endif +#ifdef CR_IBM_rasterpos_clip + if (from->rasterPositionUnclipped != to->rasterPositionUnclipped) { + able[to->rasterPositionUnclipped](GL_RASTER_POSITION_UNCLIPPED_IBM); + from->rasterPositionUnclipped = to->rasterPositionUnclipped; + } +#endif + + CLEARDIRTY(t->enable, nbitID); + } + + if (CHECKDIRTY(t->clipPlane, bitID)) { + if (from->matrixMode != GL_MODELVIEW) { + diff_api.MatrixMode(GL_MODELVIEW); + from->matrixMode = GL_MODELVIEW; + } + diff_api.PushMatrix(); + diff_api.LoadIdentity(); + for (i=0; iclipPlane[i].x != to->clipPlane[i].x || + from->clipPlane[i].y != to->clipPlane[i].y || + from->clipPlane[i].z != to->clipPlane[i].z || + from->clipPlane[i].w != to->clipPlane[i].w) { + + GLdouble cp[4]; + cp[0] = to->clipPlane[i].x; + cp[1] = to->clipPlane[i].y; + cp[2] = to->clipPlane[i].z; + cp[3] = to->clipPlane[i].w; + + diff_api.ClipPlane(GL_CLIP_PLANE0 + i, (const GLdouble *)(cp)); + from->clipPlane[i] = to->clipPlane[i]; + } + } + diff_api.PopMatrix(); + CLEARDIRTY(t->clipPlane, nbitID); + } + + /* If the matrix stack depths don't match when we're + * updating the context - we can update the wrong matrix + * and get some lovely effects!! + * So we troll each depth list here and Pop & Push the matrix stack + * to bring it right up to date before checking the current + * matrix. + * + * - Alan H. + */ + if ( (from->modelViewStack.depth != to->modelViewStack.depth) || + CHECKDIRTY(t->modelviewMatrix, bitID) ) + { + if (from->matrixMode != GL_MODELVIEW) { + diff_api.MatrixMode(GL_MODELVIEW); + from->matrixMode = GL_MODELVIEW; + } + + if (from->modelViewStack.depth > to->modelViewStack.depth) + { + for (i = to->modelViewStack.depth; i < from->modelViewStack.depth; i++) + { + diff_api.PopMatrix(); + } + + from->modelViewStack.depth = to->modelViewStack.depth; + } + + for (i = from->modelViewStack.depth; i <= to->modelViewStack.depth; i++) + { + LOADMATRIX(to->modelViewStack.stack + i); + from->modelViewStack.stack[i] = to->modelViewStack.stack[i]; + + /* Don't want to push on the current matrix */ + if (i != to->modelViewStack.depth) + diff_api.PushMatrix(); + } + from->modelViewStack.depth = to->modelViewStack.depth; + from->modelViewStack.top = from->modelViewStack.stack + from->modelViewStack.depth; + + CLEARDIRTY(t->modelviewMatrix, nbitID); + } + + /* Projection matrix */ + if ( (from->projectionStack.depth != to->projectionStack.depth) || + CHECKDIRTY(t->projectionMatrix, bitID) ) + { + if (from->matrixMode != GL_PROJECTION) { + diff_api.MatrixMode(GL_PROJECTION); + from->matrixMode = GL_PROJECTION; + } + + if (from->projectionStack.depth > to->projectionStack.depth) + { + for (i = to->projectionStack.depth; i < from->projectionStack.depth; i++) + { + diff_api.PopMatrix(); + } + + from->projectionStack.depth = to->projectionStack.depth; + } + + for (i = from->projectionStack.depth; i <= to->projectionStack.depth; i++) + { + LOADMATRIX(to->projectionStack.stack + i); + from->projectionStack.stack[i] = to->projectionStack.stack[i]; + + /* Don't want to push on the current matrix */ + if (i != to->projectionStack.depth) + diff_api.PushMatrix(); + } + from->projectionStack.depth = to->projectionStack.depth; + from->projectionStack.top = from->projectionStack.stack + from->projectionStack.depth; + + CLEARDIRTY(t->projectionMatrix, nbitID); + } + + /* Texture matrices */ + for (i = 0 ; i < maxTextureUnits ; i++) + if (from->textureStack[i].depth != to->textureStack[i].depth) + checktex = 1; + + if (checktex || CHECKDIRTY(t->textureMatrix, bitID)) + { + if (from->matrixMode != GL_TEXTURE) { + diff_api.MatrixMode(GL_TEXTURE); + from->matrixMode = GL_TEXTURE; + } + for (j = 0 ; j < maxTextureUnits; j++) + { + if (from->textureStack[j].depth > to->textureStack[j].depth) + { + if (textureFrom->curTextureUnit != j) { + diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB ); + textureFrom->curTextureUnit = j; + } + for (i = to->textureStack[j].depth; i < from->textureStack[j].depth; i++) + { + diff_api.PopMatrix(); + } + + from->textureStack[j].depth = to->textureStack[j].depth; + } + + for (i = from->textureStack[j].depth; i <= to->textureStack[j].depth; i++) + { + if (textureFrom->curTextureUnit != j) { + diff_api.ActiveTextureARB( j + GL_TEXTURE0_ARB ); + textureFrom->curTextureUnit = j; + } + LOADMATRIX(to->textureStack[j].stack + i); + from->textureStack[j].stack[i] = to->textureStack[j].stack[i]; + + /* Don't want to push on the current matrix */ + if (i != to->textureStack[j].depth) + diff_api.PushMatrix(); + } + from->textureStack[j].depth = to->textureStack[j].depth; + from->textureStack[j].top = from->textureStack[j].stack + from->textureStack[j].depth; + } + CLEARDIRTY(t->textureMatrix, nbitID); + + /* Restore proper active texture unit */ + diff_api.ActiveTextureARB(GL_TEXTURE0_ARB + toCtx->texture.curTextureUnit); + } + + /* Color matrix */ + if ( (from->colorStack.depth != to->colorStack.depth) || + CHECKDIRTY(t->colorMatrix, bitID) ) + { + if (from->matrixMode != GL_COLOR) { + diff_api.MatrixMode(GL_COLOR); + from->matrixMode = GL_COLOR; + } + + if (from->colorStack.depth > to->colorStack.depth) + { + for (i = to->colorStack.depth; i < from->colorStack.depth; i++) + { + diff_api.PopMatrix(); + } + + from->colorStack.depth = to->colorStack.depth; + } + + for (i = to->colorStack.depth; i <= to->colorStack.depth; i++) + { + LOADMATRIX(to->colorStack.stack + i); + from->colorStack.stack[i] = to->colorStack.stack[i]; + + /* Don't want to push on the current matrix */ + if (i != to->colorStack.depth) + diff_api.PushMatrix(); + } + from->colorStack.depth = to->colorStack.depth; + from->colorStack.top = from->colorStack.stack + from->colorStack.depth; + + CLEARDIRTY(t->colorMatrix, nbitID); + } + + to->modelViewProjectionValid = 0; + CLEARDIRTY(t->dirty, nbitID); + + /* update MatrixMode now */ + if (from->matrixMode != to->matrixMode) { + diff_api.MatrixMode(to->matrixMode); + from->matrixMode = to->matrixMode; + } + + /* sanity tests */ + CRASSERT(from->modelViewStack.top == from->modelViewStack.stack + from->modelViewStack.depth); + CRASSERT(from->projectionStack.top == from->projectionStack.stack + from->projectionStack.depth); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.c b/src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.c new file mode 100644 index 00000000..e238f9ae --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.c @@ -0,0 +1,166 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "state.h" +#include "state/cr_statetypes.h" +#include "state_internals.h" + +void crStateViewportInit(CRContext *ctx) +{ + CRViewportState *v = &ctx->viewport; + CRStateBits *sb = GetCurrentBits(); + CRViewportBits *vb = &(sb->viewport); + CRTransformBits *tb = &(sb->transform); + + v->scissorTest = GL_FALSE; + RESET(vb->enable, ctx->bitid); + + v->viewportValid = GL_FALSE; + v->viewportX = 0; + v->viewportY = 0; + /* These are defaults, the tilesort spu overrides when + * the context has been created */ + v->viewportW = 640; + v->viewportH = 480; + RESET(vb->v_dims, ctx->bitid); + + v->scissorValid = GL_FALSE; + v->scissorX = 0; + v->scissorY = 0; + /* These are defaults, the tilesort spu overrides when + * the context has been created */ + v->scissorW = 640; + v->scissorH = 480; + RESET(vb->s_dims, ctx->bitid); + + v->farClip = 1.0; + v->nearClip = 0.0; + RESET(vb->depth, ctx->bitid); + + RESET(vb->dirty, ctx->bitid); + + /* XXX why are these here? */ + RESET(tb->base, ctx->bitid); + RESET(tb->dirty, ctx->bitid); +} + +void crStateViewportApply(CRViewportState *v, GLvectorf *p) +{ + p->x = (p->x+1.0f)*(v->viewportW / 2.0f) + v->viewportX; + p->y = (p->y+1.0f)*(v->viewportH / 2.0f) + v->viewportY; + p->z = (GLfloat) ((p->z+1.0f)*((v->farClip - v->nearClip) / 2.0f) + v->nearClip); +} + +void STATE_APIENTRY crStateViewport(GLint x, GLint y, GLsizei width, + GLsizei height) +{ + CRContext *g = GetCurrentContext(); + CRViewportState *v = &(g->viewport); + CRStateBits *sb = GetCurrentBits(); + CRViewportBits *vb = &(sb->viewport); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError( __LINE__, __FILE__, GL_INVALID_OPERATION, + "calling glViewport() between glBegin/glEnd" ); + return; + } + + FLUSH(); + + if (width < 0 || height < 0) + { + crStateError( __LINE__, __FILE__, GL_INVALID_VALUE, + "glViewport(bad width or height)" ); + return; + } + + if (x > g->limits.maxViewportDims[0]) x = g->limits.maxViewportDims[0]; + if (x < -g->limits.maxViewportDims[0]) x = -g->limits.maxViewportDims[0]; + if (y > g->limits.maxViewportDims[1]) y = g->limits.maxViewportDims[1]; + if (y < -g->limits.maxViewportDims[1]) y = -g->limits.maxViewportDims[1]; + if (width > g->limits.maxViewportDims[0]) width = g->limits.maxViewportDims[0]; + if (height > g->limits.maxViewportDims[1]) height = g->limits.maxViewportDims[1]; + + v->viewportX = (GLint) (x); + v->viewportY = (GLint) (y); + v->viewportW = (GLint) (width); + v->viewportH = (GLint) (height); + + v->viewportValid = GL_TRUE; + + DIRTY(vb->v_dims, g->neg_bitid); + DIRTY(vb->dirty, g->neg_bitid); + /* XXX why are these here? */ + DIRTY(tb->base, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateDepthRange(GLclampd znear, GLclampd zfar) +{ + CRContext *g = GetCurrentContext(); + CRViewportState *v = &(g->viewport); + CRStateBits *sb = GetCurrentBits(); + CRViewportBits *vb = &(sb->viewport); + CRTransformBits *tb = &(sb->transform); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, "glDepthRange called in Begin/End"); + return; + } + + FLUSH(); + + v->nearClip = znear; + v->farClip = zfar; + if (v->nearClip < 0.0) v->nearClip = 0.0; + if (v->nearClip > 1.0) v->nearClip = 1.0; + if (v->farClip < 0.0) v->farClip = 0.0; + if (v->farClip > 1.0) v->farClip = 1.0; + + DIRTY(vb->depth, g->neg_bitid); + DIRTY(vb->dirty, g->neg_bitid); + DIRTY(tb->dirty, g->neg_bitid); +} + +void STATE_APIENTRY crStateScissor (GLint x, GLint y, + GLsizei width, GLsizei height) +{ + CRContext *g = GetCurrentContext(); + CRViewportState *v = &(g->viewport); + CRStateBits *sb = GetCurrentBits(); + CRViewportBits *vb = &(sb->viewport); + + if (g->current.inBeginEnd) + { + crStateError(__LINE__, __FILE__, GL_INVALID_OPERATION, + "glScissor called in begin/end"); + return; + } + + FLUSH(); + + if (width < 0 || height < 0) + { + crStateError(__LINE__, __FILE__, GL_INVALID_VALUE, + "glScissor called with negative width/height: %d,%d", + width, height); + return; + } + + v->scissorX = (GLint) (x); + v->scissorY = (GLint) (y); + v->scissorW = (GLint) (width); + v->scissorH = (GLint) (height); + + v->scissorValid = GL_TRUE; + + DIRTY(vb->s_dims, g->neg_bitid); + DIRTY(vb->dirty, g->neg_bitid); +} diff --git a/src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.txt b/src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.txt new file mode 100644 index 00000000..f2857d25 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/state_tracker/state_viewport.txt @@ -0,0 +1,14 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. +:enable:scissorTest:GL_SCISSOR_TEST +:s_dims:scissorX,scissorY,scissorW,scissorH:Scissor +#+scissorTest:s_dims:*CRrecti p; +#+scissorTest:s_dims:scissorX,scissorY,scissorW,scissorH:*diff_api.Scissor(p.x1, p.y1, p.x2-p.x1, p.y2-p.y1); +#-scissorTest:s_dims:scissorX,scissorY,scissorW,scissorH:Scissor +#+:v_dims:*CRrecti p; +#+:v_dims:viewportX,viewportY,viewportW,viewportH:*diff_api.Viewport(p.x1, p.y1, p.x2-p.x1, p.y2-p.y1); +:v_dims:viewportX,viewportY,viewportW,viewportH:Viewport +#-:v_dims:viewportX,viewportY,viewportW,viewportH:Viewport +:depth:nearClip,farClip:DepthRange diff --git a/src/VBox/GuestHost/OpenGL/util/Makefile.kup b/src/VBox/GuestHost/OpenGL/util/Makefile.kup new file mode 100644 index 00000000..e69de29b diff --git a/src/VBox/GuestHost/OpenGL/util/VBoxOGLcrutil.rc b/src/VBox/GuestHost/OpenGL/util/VBoxOGLcrutil.rc new file mode 100644 index 00000000..dda4ed41 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/VBoxOGLcrutil.rc @@ -0,0 +1,80 @@ +/* $Id: VBoxOGLcrutil.rc $ */ +/** @file + * VBoxOGLcrutil - Resource file containing version info and icon. + */ + +/* + * Copyright (C) 2015-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include +#include + + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VBOX_RC_FILE_VERSION + PRODUCTVERSION VBOX_RC_FILE_VERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS VBOX_RC_FILE_FLAGS + FILEOS VBOX_RC_FILE_OS + FILETYPE VBOX_RC_TYPE_DLL + FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" // Lang=US English, CharSet=Unicode + BEGIN +#ifdef IN_GUEST + VALUE "FileDescription", "VirtualBox crOpenGL ICD\0" +# ifdef VBOX_WDDM_WOW64 + VALUE "InternalName", "VBoxOGLcrutil-x86\0" + VALUE "OriginalFilename", "VBoxOGLcrutil-x86.dll\0" +# else + VALUE "InternalName", "VBoxOGLcrutil\0" + VALUE "OriginalFilename", "VBoxOGLcrutil.dll\0" +# endif + VALUE "ProductName", VBOX_RC_PRODUCT_NAME_GA_STR +#else + VALUE "FileDescription", "VirtualBox crOpenGL ICD\0" + VALUE "InternalName", "VBoxOGLcrhostutil\0" + VALUE "InternalFilename", "VBoxOGLcrhostutil.dll\0" + VALUE "ProductName", VBOX_RC_PRODUCT_NAME_STR +#endif + VALUE "CompanyName", VBOX_RC_COMPANY_NAME + VALUE "FileVersion", VBOX_RC_FILE_VERSION_STR + VALUE "LegalCopyright", VBOX_RC_LEGAL_COPYRIGHT + VBOX_RC_MORE_STRINGS + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +// XXX is this really required? +#if defined(VBOX_WDDM_WOW64) && defined(IN_GUEST) +1 RCDATA +BEGIN +// Machine dependent parameters + 17, // Height of vertical thumb + 17, // Width of horizontal thumb + 2, // Icon horiz compression factor + 2, // Icon vert compression factor + 1, // Cursor horz compression factor + 1, // Cursor vert compression factor + 0, // Kanji window height + 1, // cxBorder (thickness of vertical lines) + 1 // cyBorder (thickness of horizontal lines) +END +#endif diff --git a/src/VBox/GuestHost/OpenGL/util/bbox.c b/src/VBox/GuestHost/OpenGL/util/bbox.c new file mode 100644 index 00000000..053e71ca --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/bbox.c @@ -0,0 +1,229 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "cr_bbox.h" + +/** + * \mainpage Util + * + * \section UtilIntroduction Introduction + * + * Chromium consists of all the top-level files in the cr + * directory. The util module basically takes care of API dispatch, + * and OpenGL state management. + * + */ +static float _vmult(const float *m, float x, float y, float z) +{ + return m[0]*x + m[4]*y + m[8]*z + m[12]; +} + +void +crTransformBBox( float xmin, float ymin, float zmin, + float xmax, float ymax, float zmax, + const CRmatrix *m, + float *out_xmin, float *out_ymin, float *out_zmin, + float *out_xmax, float *out_ymax, float *out_zmax ) +{ + float x[8], y[8], z[8], w[8]; + int i,j; + + /* Here is the arrangement of the bounding box + * + * 0 --- 1 + * |\ .\ + * | 2 --- 3 + * | | . | + * | | . | + * 4.|...5 | + * \| .| + * 6 --- 7 + * + * c array contains the edge connectivity list + */ + + static const int c[8][3] = { + {1, 2, 4}, + {0, 3, 5}, + {0, 3, 6}, + {1, 2, 7}, + {0, 5, 6}, + {1, 4, 7}, + {2, 4, 7}, + {3, 5, 6} + }; + + x[0] = _vmult(&(m->m00), xmin, ymin, zmin); + x[1] = _vmult(&(m->m00), xmax, ymin, zmin); + x[2] = _vmult(&(m->m00), xmin, ymax, zmin); + x[3] = _vmult(&(m->m00), xmax, ymax, zmin); + x[4] = _vmult(&(m->m00), xmin, ymin, zmax); + x[5] = _vmult(&(m->m00), xmax, ymin, zmax); + x[6] = _vmult(&(m->m00), xmin, ymax, zmax); + x[7] = _vmult(&(m->m00), xmax, ymax, zmax); + + y[0] = _vmult(&(m->m01), xmin, ymin, zmin); + y[1] = _vmult(&(m->m01), xmax, ymin, zmin); + y[2] = _vmult(&(m->m01), xmin, ymax, zmin); + y[3] = _vmult(&(m->m01), xmax, ymax, zmin); + y[4] = _vmult(&(m->m01), xmin, ymin, zmax); + y[5] = _vmult(&(m->m01), xmax, ymin, zmax); + y[6] = _vmult(&(m->m01), xmin, ymax, zmax); + y[7] = _vmult(&(m->m01), xmax, ymax, zmax); + + z[0] = _vmult(&(m->m02), xmin, ymin, zmin); + z[1] = _vmult(&(m->m02), xmax, ymin, zmin); + z[2] = _vmult(&(m->m02), xmin, ymax, zmin); + z[3] = _vmult(&(m->m02), xmax, ymax, zmin); + z[4] = _vmult(&(m->m02), xmin, ymin, zmax); + z[5] = _vmult(&(m->m02), xmax, ymin, zmax); + z[6] = _vmult(&(m->m02), xmin, ymax, zmax); + z[7] = _vmult(&(m->m02), xmax, ymax, zmax); + + w[0] = _vmult(&(m->m03), xmin, ymin, zmin); + w[1] = _vmult(&(m->m03), xmax, ymin, zmin); + w[2] = _vmult(&(m->m03), xmin, ymax, zmin); + w[3] = _vmult(&(m->m03), xmax, ymax, zmin); + w[4] = _vmult(&(m->m03), xmin, ymin, zmax); + w[5] = _vmult(&(m->m03), xmax, ymin, zmax); + w[6] = _vmult(&(m->m03), xmin, ymax, zmax); + w[7] = _vmult(&(m->m03), xmax, ymax, zmax); + + /* Now, the object-space bbox has been transformed into + * clip-space. */ + + /* Find the 2D bounding box of the 3D bounding box */ + xmin = ymin = zmin = FLT_MAX; + xmax = ymax = zmax = -FLT_MAX; + + for (i=0; i<8; i++) + { + float xp = x[i]; + float yp = y[i]; + float zp = z[i]; + float wp = w[i]; + + /* If corner is to be clipped... */ + if (zp < -wp) + { + + /* Point has three edges */ + for (j=0; j<3; j++) + { + /* Handle the clipping... */ + int k = c[i][j]; + float xk = x[k]; + float yk = y[k]; + float zk = z[k]; + float wk = w[k]; + float t; + + if (zp+wp-zk-wk == 0.0) + continue; /* avoid divide by zero */ + else + t = (wp + zp) / (zp+wp-zk-wk); + + if (t < 0.0f || t > 1.0f) + { + continue; + } + wp = wp + (wk-wp) * t; + xp = xp + (xk-xp) * t; + yp = yp + (yk-yp) * t; + zp = -wp; + + xp /= wp; + yp /= wp; + zp /= wp; + + if (xp < xmin) xmin = xp; + if (xp > xmax) xmax = xp; + if (yp < ymin) ymin = yp; + if (yp > ymax) ymax = yp; + if (zp < zmin) zmin = zp; + if (zp > zmax) zmax = zp; + } + } + else + { + /* corner was not clipped.. */ + xp /= wp; + yp /= wp; + zp /= wp; + if (xp < xmin) xmin = xp; + if (xp > xmax) xmax = xp; + if (yp < ymin) ymin = yp; + if (yp > ymax) ymax = yp; + if (zp < zmin) zmin = zp; + if (zp > zmax) zmax = zp; + } + } + + /* Copy for export */ + if (out_xmin) *out_xmin = xmin; + if (out_ymin) *out_ymin = ymin; + if (out_zmin) *out_zmin = zmin; + if (out_xmax) *out_xmax = xmax; + if (out_ymax) *out_ymax = ymax; + if (out_zmax) *out_zmax = zmax; +} + +/** + * Given the coordinates of the two opposite corners of a bounding box + * in object space (x1,y1,z1) and (x2,y2,z2), use the given modelview + * and projection matrices to transform the coordinates to NDC space. + * Find the 3D bounding bounding box of those eight coordinates and + * return the min/max in (x1,y1,x1) and (x2,y2,z2). + */ +void +crProjectBBox(const GLfloat modl[16], const GLfloat proj[16], + GLfloat *x1, GLfloat *y1, GLfloat *z1, + GLfloat *x2, GLfloat *y2, GLfloat *z2) +{ + CRmatrix m; + + /* compute product of modl and proj matrices */ + m.m00 = proj[0] * modl[0] + proj[4] * modl[1] + proj[8] * modl[2] + proj[12] * modl[3]; + m.m01 = proj[1] * modl[0] + proj[5] * modl[1] + proj[9] * modl[2] + proj[13] * modl[3]; + m.m02 = proj[2] * modl[0] + proj[6] * modl[1] + proj[10] * modl[2] + proj[14] * modl[3]; + m.m03 = proj[3] * modl[0] + proj[7] * modl[1] + proj[11] * modl[2] + proj[15] * modl[3]; + m.m10 = proj[0] * modl[4] + proj[4] * modl[5] + proj[8] * modl[6] + proj[12] * modl[7]; + m.m11 = proj[1] * modl[4] + proj[5] * modl[5] + proj[9] * modl[6] + proj[13] * modl[7]; + m.m12 = proj[2] * modl[4] + proj[6] * modl[5] + proj[10] * modl[6] + proj[14] * modl[7]; + m.m13 = proj[3] * modl[4] + proj[7] * modl[5] + proj[11] * modl[6] + proj[15] * modl[7]; + m.m20 = proj[0] * modl[8] + proj[4] * modl[9] + proj[8] * modl[10] + proj[12] * modl[11]; + m.m21 = proj[1] * modl[8] + proj[5] * modl[9] + proj[9] * modl[10] + proj[13] * modl[11]; + m.m22 = proj[2] * modl[8] + proj[6] * modl[9] + proj[10] * modl[10] + proj[14] * modl[11]; + m.m23 = proj[3] * modl[8] + proj[7] * modl[9] + proj[11] * modl[10] + proj[15] * modl[11]; + m.m30 = proj[0] * modl[12] + proj[4] * modl[13] + proj[8] * modl[14] + proj[12] * modl[15]; + m.m31 = proj[1] * modl[12] + proj[5] * modl[13] + proj[9] * modl[14] + proj[13] * modl[15]; + m.m32 = proj[2] * modl[12] + proj[6] * modl[13] + proj[10] * modl[14] + proj[14] * modl[15]; + m.m33 = proj[3] * modl[12] + proj[7] * modl[13] + proj[11] * modl[14] + proj[15] * modl[15]; + + crTransformBBox( *x1, *y1, *z1, + *x2, *y2, *z2, + &m, + x1, y1, z1, + x2, y2, z2 ); +} + + +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#define MAX(a, b) ((a) > (b) ? (a) : (b)) + + +/** + * Compute union of a and b and put in result. + */ +void +crRectiUnion(CRrecti *result, const CRrecti *a, const CRrecti *b) +{ + result->x1 = MIN(a->x1, b->x1); + result->x2 = MAX(a->x2, b->x2); + result->y1 = MIN(a->y1, b->y1); + result->y2 = MAX(a->y2, b->y2); +} diff --git a/src/VBox/GuestHost/OpenGL/util/blitter.cpp b/src/VBox/GuestHost/OpenGL/util/blitter.cpp new file mode 100644 index 00000000..6bbb4260 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/blitter.cpp @@ -0,0 +1,2124 @@ +/* $Id: blitter.cpp $ */ +/** @file + * Blitter API implementation + */ + +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + + +/********************************************************************************************************************************* +* Header Files * +*********************************************************************************************************************************/ +#ifdef IN_VMSVGA3D +# include +# include +# include "../include/cr_blitter.h" +# include +# define WARN AssertMsgFailed +# define CRASSERT Assert +DECLINLINE(void) crWarning(const char *format, ... ) {} +#else +# include "cr_blitter.h" +# include "cr_spu.h" +# include "chromium.h" +# include "cr_error.h" +# include "cr_net.h" +# include "cr_rand.h" +# include "cr_mem.h" +# include "cr_string.h" +# include "cr_bmpscale.h" +#endif + +#include +#include + + + +static void crMClrFillMem(uint32_t *pu32Dst, int32_t cbDstPitch, uint32_t width, uint32_t height, uint32_t u32Color) +{ + for (uint32_t i = 0; i < height; ++i) + { + for (uint32_t j = 0; j < width; ++j) + { + pu32Dst[j] = u32Color; + } + + pu32Dst = (uint32_t*)(((uint8_t*)pu32Dst) + cbDstPitch); + } +} + +void CrMClrFillImgRect(CR_BLITTER_IMG *pDst, const RTRECT *pCopyRect, uint32_t u32Color) +{ + int32_t x = pCopyRect->xLeft; + int32_t y = pCopyRect->yTop; + int32_t width = pCopyRect->xRight - pCopyRect->xLeft; + int32_t height = pCopyRect->yBottom - pCopyRect->yTop; + Assert(x >= 0); + Assert(y >= 0); + uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * y + x * 4; + + crMClrFillMem((uint32_t*)pu8Dst, pDst->pitch, width, height, u32Color); +} + +void CrMClrFillImg(CR_BLITTER_IMG *pImg, uint32_t cRects, const RTRECT *pRects, uint32_t u32Color) +{ + RTRECT Rect; + Rect.xLeft = 0; + Rect.yTop = 0; + Rect.xRight = pImg->width; + Rect.yBottom = pImg->height; + + + RTRECT Intersection; + /*const RTPOINT ZeroPoint = {0, 0}; - unused */ + + for (uint32_t i = 0; i < cRects; ++i) + { + const RTRECT * pRect = &pRects[i]; + VBoxRectIntersected(pRect, &Rect, &Intersection); + + if (VBoxRectIsZero(&Intersection)) + continue; + + CrMClrFillImgRect(pImg, &Intersection, u32Color); + } +} + +static void crMBltMem(const uint8_t *pu8Src, int32_t cbSrcPitch, uint8_t *pu8Dst, int32_t cbDstPitch, uint32_t width, uint32_t height) +{ + uint32_t cbCopyRow = width * 4; + + for (uint32_t i = 0; i < height; ++i) + { + memcpy(pu8Dst, pu8Src, cbCopyRow); + + pu8Src += cbSrcPitch; + pu8Dst += cbDstPitch; + } +} + +void CrMBltImgRect(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, CR_BLITTER_IMG *pDst) +{ + int32_t srcX = pCopyRect->xLeft - pSrcDataPoint->x; + int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y; + Assert(srcX >= 0); + Assert(srcY >= 0); + Assert(srcX < (int32_t)pSrc->width); + Assert(srcY < (int32_t)pSrc->height); + + int32_t dstX = pCopyRect->xLeft; + int32_t dstY = pCopyRect->yTop; + Assert(dstX >= 0); + Assert(dstY >= 0); + Assert(dstX < (int32_t)pDst->width); + Assert(dstY < (int32_t)pDst->height); + + uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4; + uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4; + + crMBltMem(pu8Src, fSrcInvert ? -((int32_t)pSrc->pitch) : (int32_t)pSrc->pitch, pu8Dst, pDst->pitch, pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop); +} + +void CrMBltImg(const CR_BLITTER_IMG *pSrc, const RTPOINT *pPos, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst) +{ + RTRECT Intersection; + RTRECT RestrictSrcRect; + RestrictSrcRect.xLeft = 0; + RestrictSrcRect.yTop = 0; + RestrictSrcRect.xRight = pSrc->width; + RestrictSrcRect.yBottom = pSrc->height; + RTRECT RestrictDstRect; + RestrictDstRect.xLeft = 0; + RestrictDstRect.yTop = 0; + RestrictDstRect.xRight = pDst->width; + RestrictDstRect.yBottom = pDst->height; + + for (uint32_t i = 0; i < cRects; ++i) + { + const RTRECT * pRect = &pRects[i]; + VBoxRectIntersected(pRect, &RestrictDstRect, &Intersection); + + RTRECT TranslatedSrc; + VBoxRectTranslated(&RestrictSrcRect, pPos->x, pPos->y, &TranslatedSrc); + + VBoxRectIntersect(&Intersection, &TranslatedSrc); + + if (VBoxRectIsZero(&Intersection)) + continue; + + CrMBltImgRect(pSrc, pPos, false, &Intersection, pDst); + } +} + +#ifndef IN_VMSVGA3D + +void CrMBltImgRectScaled(const CR_BLITTER_IMG *pSrc, const RTPOINT *pPos, bool fSrcInvert, const RTRECT *pCopyRect, float strX, float strY, CR_BLITTER_IMG *pDst) +{ + RTPOINT UnscaledPos; + UnscaledPos.x = CR_FLOAT_RCAST(int32_t, pPos->x / strX); + UnscaledPos.y = CR_FLOAT_RCAST(int32_t, pPos->y / strY); + + RTRECT UnscaledCopyRect; + + VBoxRectUnscaled(pCopyRect, strX, strY, &UnscaledCopyRect); + + if (VBoxRectIsZero(&UnscaledCopyRect)) + { + WARN(("ups")); + return; + } + + int32_t srcX = UnscaledCopyRect.xLeft - UnscaledPos.x; + int32_t srcY = UnscaledCopyRect.yTop - UnscaledPos.y; + if (srcX < 0) + { + WARN(("ups")); + srcX = 0; + } + if (srcY < 0) + { + WARN(("ups")); + srcY = 0; + } + + if ((GLuint)srcX >= pSrc->width) + { + WARN(("ups")); + return; + } + + if ((GLuint)srcY >= pSrc->height) + { + WARN(("ups")); + return; + } + + Assert(srcX >= 0); + Assert(srcY >= 0); + Assert(srcX < (int32_t)pSrc->width); + Assert(srcY < (int32_t)pSrc->height); + + int32_t dstX = pCopyRect->xLeft; + int32_t dstY = pCopyRect->yTop; + Assert(dstX >= 0); + Assert(dstY >= 0); + + int32_t UnscaledSrcWidth = UnscaledCopyRect.xRight - UnscaledCopyRect.xLeft; + int32_t UnscaledSrcHeight = UnscaledCopyRect.yBottom - UnscaledCopyRect.yTop; + + if (UnscaledSrcWidth + srcX > (GLint)pSrc->width) + UnscaledSrcWidth = pSrc->width - srcX; + + if (UnscaledSrcHeight + srcY > (GLint)pSrc->height) + UnscaledSrcHeight = pSrc->height - srcY; + + uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4; + uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4; + + CrBmpScale32(pu8Dst, pDst->pitch, + pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop, + pu8Src, + fSrcInvert ? -((int32_t)pSrc->pitch) : (int32_t)pSrc->pitch, + UnscaledSrcWidth, UnscaledSrcHeight); +} + + +void CrMBltImgScaled(const CR_BLITTER_IMG *pSrc, const RTRECTSIZE *pSrcRectSize, const RTRECT *pDstRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pDst) +{ + int32_t srcWidth = pSrcRectSize->cx; + int32_t srcHeight = pSrcRectSize->cy; + int32_t dstWidth = pDstRect->xRight - pDstRect->xLeft; + int32_t dstHeight = pDstRect->yBottom - pDstRect->yTop; + + float strX = ((float)dstWidth) / srcWidth; + float strY = ((float)dstHeight) / srcHeight; + Assert(dstWidth != srcWidth || dstHeight != srcHeight); + + RTRECT Intersection; + RTRECT ScaledRestrictSrcRect; + ScaledRestrictSrcRect.xLeft = 0; + ScaledRestrictSrcRect.yTop = 0; + ScaledRestrictSrcRect.xRight = CR_FLOAT_RCAST(int32_t, pSrc->width * strX); + ScaledRestrictSrcRect.yBottom = CR_FLOAT_RCAST(int32_t, pSrc->height * strY); + RTRECT RestrictDstRect; + RestrictDstRect.xLeft = 0; + RestrictDstRect.yTop = 0; + RestrictDstRect.xRight = pDst->width; + RestrictDstRect.yBottom = pDst->height; + + RTPOINT Pos = {pDstRect->xLeft, pDstRect->yTop}; + + for (uint32_t i = 0; i < cRects; ++i) + { + const RTRECT * pRect = &pRects[i]; + VBoxRectIntersected(pRect, &RestrictDstRect, &Intersection); + + RTRECT TranslatedSrc; + VBoxRectTranslated(&ScaledRestrictSrcRect, Pos.x, Pos.y, &TranslatedSrc); + + VBoxRectIntersect(&Intersection, &TranslatedSrc); + + if (VBoxRectIsZero(&Intersection)) + continue; + + CrMBltImgRectScaled(pSrc, &Pos, false, &Intersection, strX, strY, pDst); + } +} + +#endif /* !IN_VMSVGA3D */ + + +/** + * + * @param pBlitter The blitter to initialize. + * @param pCtxBase Contains the blitter context info. Its value is + * treated differently depending on the fCreateNewCtx + * value. + * @param fCreateNewCtx If true, then @a pCtxBase must NOT be NULL. Its + * visualBits is used as a visual bits info for the new + * context, its id field is used to specified the + * shared context id to be used for blitter context. + * The id can be null to specify no shared context is + * needed + * + * If false and @a pCtxBase is NOT null AND its id + * field is NOT null, then specified the blitter + * context to be used blitter treats it as if it has + * default ogl state. + * + * Otherwise, the blitter works in a "no-context" mode, + * i.e. the caller is responsible for making a proper + * context current before calling the blitter. Note + * that BltEnter/Leave MUST still be called, but the + * proper context must be set before doing BltEnter, + * and ResoreContext info is ignored in that case. Also + * note that the blitter caches the current window + * info, and assumes the current context's values are + * preserved wrt that window before the calls, so if + * one uses different contexts for one blitter, the + * blitter current window values must be explicitly + * reset by doing CrBltMuralSetCurrentInfo(pBlitter, + * NULL). + * @param fForceDrawBlt If true this forces the blitter to always use + * glDrawXxx-based blits even if + * GL_EXT_framebuffer_blit. This is needed because + * BlitFramebufferEXT is often known to be buggy, and + * glDrawXxx-based blits appear to be more reliable. + * @param pShaders + * @param pDispatch + */ +VBOXBLITTERDECL(int) CrBltInit(PCR_BLITTER pBlitter, const CR_BLITTER_CONTEXT *pCtxBase, + bool fCreateNewCtx, bool fForceDrawBlt, const CR_GLSL_CACHE *pShaders, + SPUDispatchTable *pDispatch) +{ + if (pCtxBase && pCtxBase->Base.id < 0) + { + crWarning("Default share context not initialized!"); + return VERR_INVALID_PARAMETER; + } + + if (!pCtxBase && fCreateNewCtx) + { + crWarning("pCtxBase is zero while fCreateNewCtx is set!"); + return VERR_INVALID_PARAMETER; + } + + RT_ZERO(*pBlitter); + + pBlitter->pDispatch = pDispatch; + if (pCtxBase) + pBlitter->CtxInfo = *pCtxBase; + + pBlitter->Flags.ForceDrawBlit = fForceDrawBlt; + + if (fCreateNewCtx) + { +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ + pBlitter->CtxInfo.Base.id = 0; +#else + pBlitter->CtxInfo.Base.id = pDispatch->CreateContext("", pCtxBase->Base.visualBits, pCtxBase->Base.id); +#endif + if (!pBlitter->CtxInfo.Base.id) + { + RT_ZERO(*pBlitter); + crWarning("CreateContext failed!"); + return VERR_GENERAL_FAILURE; + } + pBlitter->Flags.CtxCreated = 1; + } + + if (pShaders) + { + pBlitter->pGlslCache = pShaders; + pBlitter->Flags.ShadersGloal = 1; + } + else + { + CrGlslInit(&pBlitter->LocalGlslCache, pDispatch); + pBlitter->pGlslCache = &pBlitter->LocalGlslCache; + } + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(int) CrBltCleanup(PCR_BLITTER pBlitter) +{ + if (CrBltIsEntered(pBlitter)) + { + WARN(("CrBltBlitTexTex: blitter is entered")); + return VERR_INVALID_STATE; + } + + if (pBlitter->Flags.ShadersGloal || !CrGlslNeedsCleanup(&pBlitter->LocalGlslCache)) + return VINF_SUCCESS; + + int rc = CrBltEnter(pBlitter); + if (!RT_SUCCESS(rc)) + { + WARN(("CrBltEnter failed, rc %d", rc)); + return rc; + } + + CrGlslCleanup(&pBlitter->LocalGlslCache); + + CrBltLeave(pBlitter); + + return VINF_SUCCESS; +} + +void CrBltTerm(PCR_BLITTER pBlitter) +{ +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + if (pBlitter->Flags.CtxCreated) + pBlitter->pDispatch->DestroyContext(pBlitter->CtxInfo.Base.id); +#endif + memset(pBlitter, 0, sizeof (*pBlitter)); +} + +int CrBltMuralSetCurrentInfo(PCR_BLITTER pBlitter, const CR_BLITTER_WINDOW *pMural) +{ + if (pMural) + { + if (!memcmp(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural))) + return VINF_SUCCESS; + memcpy(&pBlitter->CurrentMural, pMural, sizeof (pBlitter->CurrentMural)); + } + else + { + if (CrBltIsEntered(pBlitter)) + { + WARN(("can not set null mural for entered bleater")); + return VERR_INVALID_STATE; + } + if (!pBlitter->CurrentMural.Base.id) + return VINF_SUCCESS; + pBlitter->CurrentMural.Base.id = 0; + } + + pBlitter->Flags.CurrentMuralChanged = 1; + + if (!CrBltIsEntered(pBlitter)) + return VINF_SUCCESS; + + if (!pBlitter->CtxInfo.Base.id) + { + WARN(("setting current mural for entered no-context blitter")); + return VERR_INVALID_STATE; + } + + WARN(("changing mural for entered blitter, is is somewhat expected?")); + +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->Flush(); + + pBlitter->pDispatch->MakeCurrent(pMural->Base.id, pBlitter->i32MakeCurrentUserData, pBlitter->CtxInfo.Base.id); +#endif + + return VINF_SUCCESS; +} + + +#ifndef IN_VMSVGA3D + +static DECLCALLBACK(int) crBltBlitTexBufImplFbo(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags) +{ + GLenum filter = CRBLT_FILTER_FROM_FLAGS(fFlags); + pBlitter->pDispatch->BindFramebufferEXT(GL_READ_FRAMEBUFFER, pBlitter->idFBO); + pBlitter->pDispatch->FramebufferTexture2DEXT(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pSrc->target, pSrc->hwid, 0); + pBlitter->pDispatch->ReadBuffer(GL_COLOR_ATTACHMENT0); + + for (uint32_t i = 0; i < cRects; ++i) + { + const RTRECT * pSrcRect = &paSrcRect[i]; + const RTRECT * pDstRect = &paDstRect[i]; + int32_t srcY1; + int32_t srcY2; + int32_t dstY1; + int32_t dstY2; + int32_t srcX1 = pSrcRect->xLeft; + int32_t srcX2 = pSrcRect->xRight; + int32_t dstX1 = pDstRect->xLeft; + int32_t dstX2 = pDstRect->xRight; + + if (CRBLT_F_INVERT_SRC_YCOORDS & fFlags) + { + srcY1 = pSrc->height - pSrcRect->yTop; + srcY2 = pSrc->height - pSrcRect->yBottom; + } + else + { + srcY1 = pSrcRect->yTop; + srcY2 = pSrcRect->yBottom; + } + + if (CRBLT_F_INVERT_DST_YCOORDS & fFlags) + { + dstY1 = pDstSize->cy - pDstRect->yTop; + dstY2 = pDstSize->cy - pDstRect->yBottom; + } + else + { + dstY1 = pDstRect->yTop; + dstY2 = pDstRect->yBottom; + } + + if (srcY1 > srcY2) + { + if (dstY1 > dstY2) + { + /* use srcY1 < srcY2 && dstY1 < dstY2 whenever possible to avoid GPU driver bugs */ + int32_t tmp = srcY1; + srcY1 = srcY2; + srcY2 = tmp; + tmp = dstY1; + dstY1 = dstY2; + dstY2 = tmp; + } + } + + if (srcX1 > srcX2) + { + if (dstX1 > dstX2) + { + /* use srcX1 < srcX2 && dstX1 < dstX2 whenever possible to avoid GPU driver bugs */ + int32_t tmp = srcX1; + srcX1 = srcX2; + srcX2 = tmp; + tmp = dstX1; + dstX1 = dstX2; + dstX2 = tmp; + } + } + + pBlitter->pDispatch->BlitFramebufferEXT(srcX1, srcY1, srcX2, srcY2, + dstX1, dstY1, dstX2, dstY2, + GL_COLOR_BUFFER_BIT, filter); + } + + return VINF_SUCCESS; +} + +/* GL_TRIANGLE_FAN */ +DECLINLINE(GLfloat*) crBltVtRectTFNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, uint32_t height) +{ + /* going ccw: + * 1. (left;top) 4. (right;top) + * | ^ + * > | + * 2. (left;bottom) -> 3. (right;bottom) */ + /* xLeft yTop */ + pBuff[0] = ((float)pRect->xLeft)/((float)normalX); + pBuff[1] = ((float)(height ? height - pRect->yTop : pRect->yTop))/((float)normalY); + + /* xLeft yBottom */ + pBuff[2] = pBuff[0]; + pBuff[3] = ((float)(height ? height - pRect->yBottom : pRect->yBottom))/((float)normalY); + + /* xRight yBottom */ + pBuff[4] = ((float)pRect->xRight)/((float)normalX); + pBuff[5] = pBuff[3]; + + /* xRight yTop */ + pBuff[6] = pBuff[4]; + pBuff[7] = pBuff[1]; + return &pBuff[8]; +} + +DECLINLINE(GLfloat*) crBltVtRectsTFNormalized(const RTRECT *paRects, uint32_t cRects, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, uint32_t height) +{ + for (uint32_t i = 0; i < cRects; ++i) + { + pBuff = crBltVtRectTFNormalized(&paRects[i], normalX, normalY, pBuff, height); + } + return pBuff; +} + +DECLINLINE(GLint*) crBltVtRectTF(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, uint32_t height) +{ + (void)normalX; (void)normalY; + + /* xLeft yTop */ + pBuff[0] = pRect->xLeft; + pBuff[1] = height ? height - pRect->yTop : pRect->yTop; + + /* xLeft yBottom */ + pBuff[2] = pBuff[0]; + pBuff[3] = height ? height - pRect->yBottom : pRect->yBottom; + + /* xRight yBottom */ + pBuff[4] = pRect->xRight; + pBuff[5] = pBuff[3]; + + /* xRight yTop */ + pBuff[6] = pBuff[4]; + pBuff[7] = pBuff[1]; + return &pBuff[8]; +} + +DECLINLINE(GLubyte*) crBltVtFillRectIndicies(GLubyte *pIndex, GLubyte *piBase) +{ + GLubyte iBase = *piBase; + /* triangle 1 */ + pIndex[0] = iBase; + pIndex[1] = iBase + 1; + pIndex[2] = iBase + 2; + + /* triangle 2 */ + pIndex[3] = iBase; + pIndex[4] = iBase + 2; + pIndex[5] = iBase + 3; + *piBase = iBase + 4; + return pIndex + 6; +} + +/* Indexed GL_TRIANGLES */ +DECLINLINE(GLfloat*) crBltVtRectITNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, uint32_t height) +{ + GLfloat* ret = crBltVtRectTFNormalized(pRect, normalX, normalY, pBuff, height); + return ret; +} + +DECLINLINE(GLint*) crBltVtRectIT(RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, GLubyte **ppIndex, GLubyte *piBase, uint32_t height) +{ + GLint* ret = crBltVtRectTF(pRect, normalX, normalY, pBuff, height); + + if (ppIndex) + *ppIndex = crBltVtFillRectIndicies(*ppIndex, piBase); + + return ret; +} + +DECLINLINE(GLuint) crBltVtGetNumVerticiesTF(GLuint cRects) +{ + return cRects * 4; +} + +#define crBltVtGetNumVerticiesIT crBltVtGetNumVerticiesTF + +DECLINLINE(GLuint) crBltVtGetNumIndiciesIT(GLuint cRects) +{ + return 6 * cRects; +} + + +static GLfloat* crBltVtRectsITNormalized(const RTRECT *paRects, uint32_t cRects, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase, uint32_t height) +{ + uint32_t i; + for (i = 0; i < cRects; ++i) + { + pBuff = crBltVtRectITNormalized(&paRects[i], normalX, normalY, pBuff, height); + } + + + if (ppIndex) + { + GLubyte *pIndex = (GLubyte*)pBuff; + *ppIndex = pIndex; + for (i = 0; i < cRects; ++i) + { + pIndex = crBltVtFillRectIndicies(pIndex, piBase); + } + pBuff = (GLfloat*)pIndex; + } + + return pBuff; +} + +static void *crBltBufGet(PCR_BLITTER_BUFFER pBuffer, GLuint cbBuffer) +{ + if (pBuffer->cbBuffer < cbBuffer) + { + if (pBuffer->pvBuffer) + { + RTMemFree(pBuffer->pvBuffer); + } + +#ifndef DEBUG_misha + /* debugging: ensure we calculate proper buffer size */ + cbBuffer += 16; +#endif + + pBuffer->pvBuffer = RTMemAlloc(cbBuffer); + if (pBuffer->pvBuffer) + pBuffer->cbBuffer = cbBuffer; + else + { + crWarning("failed to allocate buffer of size %d", cbBuffer); + pBuffer->cbBuffer = 0; + } + } + return pBuffer->pvBuffer; +} + +#endif /* !IN_VMSVGA3D */ + + +static void crBltCheckSetupViewport(PCR_BLITTER pBlitter, const RTRECTSIZE *pDstSize, bool fFBODraw) +{ + bool fUpdateViewport = pBlitter->Flags.CurrentMuralChanged; + if ( pBlitter->CurrentSetSize.cx != pDstSize->cx + || pBlitter->CurrentSetSize.cy != pDstSize->cy) + { + pBlitter->CurrentSetSize = *pDstSize; +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->MatrixMode(GL_PROJECTION); + pBlitter->pDispatch->LoadIdentity(); + pBlitter->pDispatch->Ortho(0, pDstSize->cx, 0, pDstSize->cy, -1, 1); +#endif + fUpdateViewport = true; + } + + if (fUpdateViewport) + { +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->Viewport(0, 0, pBlitter->CurrentSetSize.cx, pBlitter->CurrentSetSize.cy); +#endif + pBlitter->Flags.CurrentMuralChanged = 0; + } + + pBlitter->Flags.LastWasFBODraw = fFBODraw; +} + + +#ifndef IN_VMSVGA3D + +static DECLCALLBACK(int) crBltBlitTexBufImplDraw2D(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRect, const RTRECTSIZE *pDstSize, const RTRECT *paDstRect, uint32_t cRects, uint32_t fFlags) +{ + GLuint normalX, normalY; + uint32_t srcHeight = (fFlags & CRBLT_F_INVERT_SRC_YCOORDS) ? pSrc->height : 0; + uint32_t dstHeight = (fFlags & CRBLT_F_INVERT_DST_YCOORDS) ? pDstSize->cy : 0; + + switch (pSrc->target) + { + case GL_TEXTURE_2D: + { + normalX = pSrc->width; + normalY = pSrc->height; + break; + } + + case GL_TEXTURE_RECTANGLE_ARB: + { + normalX = 1; + normalY = 1; + break; + } + + default: + { + crWarning("Unsupported texture target 0x%x", pSrc->target); + return VERR_INVALID_PARAMETER; + } + } + + Assert(pSrc->hwid); + + pBlitter->pDispatch->BindTexture(pSrc->target, pSrc->hwid); + + if (cRects == 1) + { + /* just optimization to draw a single rect with GL_TRIANGLE_FAN */ + GLfloat *pVerticies; + GLfloat *pTexCoords; + GLuint cElements = crBltVtGetNumVerticiesTF(cRects); + + pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies)); + pTexCoords = crBltVtRectsTFNormalized(paDstRect, cRects, 1, 1, pVerticies, dstHeight); + crBltVtRectsTFNormalized(paSrcRect, cRects, normalX, normalY, pTexCoords, srcHeight); + + pBlitter->pDispatch->EnableClientState(GL_VERTEX_ARRAY); + pBlitter->pDispatch->VertexPointer(2, GL_FLOAT, 0, pVerticies); + + pBlitter->pDispatch->EnableClientState(GL_TEXTURE_COORD_ARRAY); + pBlitter->pDispatch->TexCoordPointer(2, GL_FLOAT, 0, pTexCoords); + + pBlitter->pDispatch->Enable(pSrc->target); + + pBlitter->pDispatch->DrawArrays(GL_TRIANGLE_FAN, 0, cElements); + + pBlitter->pDispatch->Disable(pSrc->target); + + pBlitter->pDispatch->DisableClientState(GL_TEXTURE_COORD_ARRAY); + pBlitter->pDispatch->DisableClientState(GL_VERTEX_ARRAY); + } + else + { + GLfloat *pVerticies; + GLfloat *pTexCoords; + GLubyte *pIndicies; + GLuint cElements = crBltVtGetNumVerticiesIT(cRects); + GLuint cIndicies = crBltVtGetNumIndiciesIT(cRects); + GLubyte iIdxBase = 0; + + pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies) + cIndicies * sizeof (*pIndicies)); + pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, 1, 1, pVerticies, &pIndicies, &iIdxBase, dstHeight); + crBltVtRectsITNormalized(paSrcRect, cRects, normalX, normalY, pTexCoords, NULL, NULL, srcHeight); + + pBlitter->pDispatch->EnableClientState(GL_VERTEX_ARRAY); + pBlitter->pDispatch->VertexPointer(2, GL_FLOAT, 0, pVerticies); + + pBlitter->pDispatch->EnableClientState(GL_TEXTURE_COORD_ARRAY); + pBlitter->pDispatch->TexCoordPointer(2, GL_FLOAT, 0, pTexCoords); + + pBlitter->pDispatch->Enable(pSrc->target); + + pBlitter->pDispatch->DrawElements(GL_TRIANGLES, cIndicies, GL_UNSIGNED_BYTE, pIndicies); + + pBlitter->pDispatch->Disable(pSrc->target); + + pBlitter->pDispatch->DisableClientState(GL_TEXTURE_COORD_ARRAY); + pBlitter->pDispatch->DisableClientState(GL_VERTEX_ARRAY); + } + + pBlitter->pDispatch->BindTexture(pSrc->target, 0); + + return VINF_SUCCESS; +} + +static int crBltInitOnMakeCurent(PCR_BLITTER pBlitter) +{ + const char * pszExtension = (const char*)pBlitter->pDispatch->GetString(GL_EXTENSIONS); + if (crStrstr(pszExtension, "GL_EXT_framebuffer_object")) + { + pBlitter->Flags.SupportsFBO = 1; + pBlitter->pDispatch->GenFramebuffersEXT(1, &pBlitter->idFBO); + Assert(pBlitter->idFBO); + } + else + crWarning("GL_EXT_framebuffer_object not supported, blitter can only blit to window"); + + if (crStrstr(pszExtension, "GL_ARB_pixel_buffer_object")) + pBlitter->Flags.SupportsPBO = 1; + else + crWarning("GL_ARB_pixel_buffer_object not supported"); + + /* BlitFramebuffer seems to be buggy on Intel, + * try always glDrawXxx for now */ + if (!pBlitter->Flags.ForceDrawBlit && crStrstr(pszExtension, "GL_EXT_framebuffer_blit")) + { + pBlitter->pfnBlt = crBltBlitTexBufImplFbo; + } + else + { +// crWarning("GL_EXT_framebuffer_blit not supported, will use Draw functions for blitting, which might be less efficient"); + pBlitter->pfnBlt = crBltBlitTexBufImplDraw2D; + } + + /* defaults. but just in case */ + pBlitter->pDispatch->MatrixMode(GL_TEXTURE); + pBlitter->pDispatch->LoadIdentity(); + pBlitter->pDispatch->MatrixMode(GL_MODELVIEW); + pBlitter->pDispatch->LoadIdentity(); + + return VINF_SUCCESS; +} + +#endif /* !IN_VMSVGA3D */ + + +void CrBltLeave(PCR_BLITTER pBlitter) +{ + if (!pBlitter->cEnters) + { + WARN(("blitter not entered!")); + return; + } + + if (--pBlitter->cEnters) + return; + +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + if (pBlitter->Flags.SupportsFBO) + { + pBlitter->pDispatch->BindFramebufferEXT(GL_FRAMEBUFFER, 0); + pBlitter->pDispatch->DrawBuffer(GL_BACK); + pBlitter->pDispatch->ReadBuffer(GL_BACK); + } + + pBlitter->pDispatch->Flush(); + + if (pBlitter->CtxInfo.Base.id) + pBlitter->pDispatch->MakeCurrent(0, 0, 0); +#endif +} + +int CrBltEnter(PCR_BLITTER pBlitter) +{ + if (!pBlitter->CurrentMural.Base.id && pBlitter->CtxInfo.Base.id) + { + WARN(("current mural not initialized!")); + return VERR_INVALID_STATE; + } + + if (pBlitter->cEnters++) + return VINF_SUCCESS; + + if (pBlitter->CurrentMural.Base.id) /* <- pBlitter->CurrentMural.Base.id can be null if the blitter is in a "no-context" mode (see comments to BltInit for detail)*/ + { +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->MakeCurrent(pBlitter->CurrentMural.Base.id, pBlitter->i32MakeCurrentUserData, pBlitter->CtxInfo.Base.id); +#endif + } + + if (pBlitter->Flags.Initialized) + return VINF_SUCCESS; + +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ + int rc = VINF_SUCCESS; +#else + int rc = crBltInitOnMakeCurent(pBlitter); +#endif + if (RT_SUCCESS(rc)) + { + pBlitter->Flags.Initialized = 1; + return VINF_SUCCESS; + } + + WARN(("crBltInitOnMakeCurent failed, rc %d", rc)); + CrBltLeave(pBlitter); + return rc; +} + + +static void crBltBlitTexBuf(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, GLenum enmDstBuff, const RTRECTSIZE *pDstSize, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags) +{ +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->DrawBuffer(enmDstBuff); + + crBltCheckSetupViewport(pBlitter, pDstSize, enmDstBuff == GL_DRAW_FRAMEBUFFER); + + if (!(fFlags & CRBLT_F_NOALPHA)) + pBlitter->pfnBlt(pBlitter, pSrc, paSrcRects, pDstSize, paDstRects, cRects, fFlags); + else + { + int rc = pBlitter->Flags.ShadersGloal + ? CrGlslProgUseNoAlpha(pBlitter->pGlslCache, pSrc->target) + : CrGlslProgUseGenNoAlpha(&pBlitter->LocalGlslCache, pSrc->target); + + if (!RT_SUCCESS(rc)) + { + crWarning("Failed to use no-alpha program rc %d!, falling back to default blit", rc); + pBlitter->pfnBlt(pBlitter, pSrc, paSrcRects, pDstSize, paDstRects, cRects, fFlags); + return; + } + + /* since we use shaders, we need to use draw commands rather than framebuffer blits. + * force using draw-based blitting */ + crBltBlitTexBufImplDraw2D(pBlitter, pSrc, paSrcRects, pDstSize, paDstRects, cRects, fFlags); + + Assert(pBlitter->Flags.ShadersGloal || &pBlitter->LocalGlslCache == pBlitter->pGlslCache); + + CrGlslProgClear(pBlitter->pGlslCache); + } +#endif +} + +void CrBltCheckUpdateViewport(PCR_BLITTER pBlitter) +{ + RTRECTSIZE DstSize = {pBlitter->CurrentMural.width, pBlitter->CurrentMural.height}; + crBltCheckSetupViewport(pBlitter, &DstSize, false); +} + +void CrBltBlitTexMural(PCR_BLITTER pBlitter, bool fBb, const VBOXVR_TEXTURE *pSrc, const RTRECT *paSrcRects, const RTRECT *paDstRects, uint32_t cRects, uint32_t fFlags) +{ + if (!CrBltIsEntered(pBlitter)) + { + WARN(("CrBltBlitTexMural: blitter not entered")); + return; + } + + RTRECTSIZE DstSize = {pBlitter->CurrentMural.width, pBlitter->CurrentMural.height}; + +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0); +#endif + + crBltBlitTexBuf(pBlitter, pSrc, paSrcRects, fBb ? GL_BACK : GL_FRONT, &DstSize, paDstRects, cRects, fFlags); +} + + +#ifndef IN_VMSVGA3D + +void CrBltBlitTexTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, const RTRECT *pSrcRect, const VBOXVR_TEXTURE *pDst, const RTRECT *pDstRect, uint32_t cRects, uint32_t fFlags) +{ + if (!CrBltIsEntered(pBlitter)) + { + WARN(("CrBltBlitTexTex: blitter not entered")); + return; + } + + RTRECTSIZE DstSize = {(uint32_t)pDst->width, (uint32_t)pDst->height}; + + pBlitter->pDispatch->BindFramebufferEXT(GL_DRAW_FRAMEBUFFER, pBlitter->idFBO); + + /** @todo mag/min filters ? */ + + pBlitter->pDispatch->FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pDst->target, pDst->hwid, 0); + +// pBlitter->pDispatch->FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, 0, 0); +// pBlitter->pDispatch->FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0); + + crBltBlitTexBuf(pBlitter, pSrc, pSrcRect, GL_DRAW_FRAMEBUFFER, &DstSize, pDstRect, cRects, fFlags); + + pBlitter->pDispatch->FramebufferTexture2DEXT(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, pDst->target, 0, 0); +} + +void CrBltPresent(PCR_BLITTER pBlitter) +{ + if (!CrBltIsEntered(pBlitter)) + { + WARN(("CrBltPresent: blitter not entered")); + return; + } + + if (pBlitter->CtxInfo.Base.visualBits & CR_DOUBLE_BIT) + pBlitter->pDispatch->SwapBuffers(pBlitter->CurrentMural.Base.id, 0); + else + pBlitter->pDispatch->Flush(); +} + +static int crBltImgInitBaseForTex(const VBOXVR_TEXTURE *pSrc, CR_BLITTER_IMG *pDst, GLenum enmFormat) +{ + memset(pDst, 0, sizeof (*pDst)); + if (enmFormat != GL_RGBA + && enmFormat != GL_BGRA) + { + WARN(("unsupported format 0x%x", enmFormat)); + return VERR_NOT_IMPLEMENTED; + } + + uint32_t bpp = 32; + + uint32_t pitch = ((bpp * pSrc->width) + 7) >> 3; + uint32_t cbData = pitch * pSrc->height; + pDst->cbData = cbData; + pDst->enmFormat = enmFormat; + pDst->width = pSrc->width; + pDst->height = pSrc->height; + pDst->bpp = bpp; + pDst->pitch = pitch; + return VINF_SUCCESS; +} + +static int crBltImgCreateForTex(const VBOXVR_TEXTURE *pSrc, CR_BLITTER_IMG *pDst, GLenum enmFormat) +{ + int rc = crBltImgInitBaseForTex(pSrc, pDst, enmFormat); + if (!RT_SUCCESS(rc)) + { + crWarning("crBltImgInitBaseForTex failed rc %d", rc); + return rc; + } + + uint32_t cbData = pDst->cbData; + pDst->pvData = RTMemAllocZ(cbData); + if (!pDst->pvData) + { + crWarning("RTMemAlloc failed"); + return VERR_NO_MEMORY; + } + +#ifdef DEBUG_misha + { + char *pTmp = (char*)pDst->pvData; + for (uint32_t i = 0; i < cbData; ++i) + { + pTmp[i] = (char)((1 << i) % 255); + } + } +#endif + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(int) CrBltImgGetTex(PCR_BLITTER pBlitter, const VBOXVR_TEXTURE *pSrc, GLenum enmFormat, CR_BLITTER_IMG *pDst) +{ + if (!CrBltIsEntered(pBlitter)) + { + WARN(("CrBltImgGetTex: blitter not entered")); + return VERR_INVALID_STATE; + } + + int rc = crBltImgCreateForTex(pSrc, pDst, enmFormat); + if (!RT_SUCCESS(rc)) + { + crWarning("crBltImgCreateForTex failed, rc %d", rc); + return rc; + } + pBlitter->pDispatch->BindTexture(pSrc->target, pSrc->hwid); + +#ifdef DEBUG_misha + { + GLint width = 0, height = 0, depth = 0; + pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_WIDTH, &width); + pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_HEIGHT, &height); + pBlitter->pDispatch->GetTexLevelParameteriv(pSrc->target, 0, GL_TEXTURE_DEPTH, &depth); + + Assert(width == pSrc->width); + Assert(height == pSrc->height); +// Assert(depth == pSrc->depth); + } +#endif + + pBlitter->pDispatch->GetTexImage(pSrc->target, 0, enmFormat, GL_UNSIGNED_BYTE, pDst->pvData); + + pBlitter->pDispatch->BindTexture(pSrc->target, 0); + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(int) CrBltImgGetMural(PCR_BLITTER pBlitter, bool fBb, CR_BLITTER_IMG *pDst) +{ + (void)fBb; (void)pDst; + if (!CrBltIsEntered(pBlitter)) + { + WARN(("CrBltImgGetMural: blitter not entered")); + return VERR_INVALID_STATE; + } + + WARN(("NOT IMPLEMENTED")); + return VERR_NOT_IMPLEMENTED; +} + +VBOXBLITTERDECL(void) CrBltImgFree(PCR_BLITTER pBlitter, CR_BLITTER_IMG *pDst) +{ + if (!CrBltIsEntered(pBlitter)) + { + WARN(("CrBltImgFree: blitter not entered")); + return; + } + + if (pDst->pvData) + { + RTMemFree(pDst->pvData); + pDst->pvData = NULL; + } +} + + +VBOXBLITTERDECL(bool) CrGlslIsSupported(CR_GLSL_CACHE *pCache) +{ + if (pCache->iGlVersion == 0) + { + const char * pszStr = (const char*)pCache->pDispatch->GetString(GL_VERSION); + pCache->iGlVersion = crStrParseGlVersion(pszStr); + if (pCache->iGlVersion <= 0) + { + crWarning("crStrParseGlVersion returned %d", pCache->iGlVersion); + pCache->iGlVersion = -1; + } + } + + if (pCache->iGlVersion >= CR_GLVERSION_COMPOSE(2, 0, 0)) + return true; + + crWarning("GLSL unsuported, gl version %d", pCache->iGlVersion); + + /** @todo we could also check for GL_ARB_shader_objects and GL_ARB_fragment_shader, + * but seems like chromium does not support properly gl*Object versions of shader functions used with those extensions */ + return false; +} + +#define CR_GLSL_STR_V_120 "#version 120\n" +#define CR_GLSL_STR_EXT_TR "#extension GL_ARB_texture_rectangle : enable\n" +#define CR_GLSL_STR_2D "2D" +#define CR_GLSL_STR_2DRECT "2DRect" + +#define CR_GLSL_PATTERN_FS_NOALPHA(_ver, _ext, _tex) \ + _ver \ + _ext \ + "uniform sampler" _tex " sampler0;\n" \ + "void main()\n" \ + "{\n" \ + "vec2 srcCoord = vec2(gl_TexCoord[0]);\n" \ + "gl_FragData[0].xyz = (texture" _tex "(sampler0, srcCoord).xyz);\n" \ + "gl_FragData[0].w = 1.0;\n" \ + "}\n" + +static const char* crGlslGetFsStringNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget) +{ + if (!CrGlslIsSupported(pCache)) + { + crWarning("CrGlslIsSupported is false"); + return NULL; + } + + if (pCache->iGlVersion >= CR_GLVERSION_COMPOSE(2, 1, 0)) + { + if (enmTexTarget == GL_TEXTURE_2D) + return CR_GLSL_PATTERN_FS_NOALPHA(CR_GLSL_STR_V_120, "", CR_GLSL_STR_2D); + else if (enmTexTarget == GL_TEXTURE_RECTANGLE_ARB) + return CR_GLSL_PATTERN_FS_NOALPHA(CR_GLSL_STR_V_120, CR_GLSL_STR_EXT_TR, CR_GLSL_STR_2DRECT); + + crWarning("invalid enmTexTarget %#x", enmTexTarget); + return NULL; + } + else if (pCache->iGlVersion >= CR_GLVERSION_COMPOSE(2, 0, 0)) + { + if (enmTexTarget == GL_TEXTURE_2D) + return CR_GLSL_PATTERN_FS_NOALPHA("", "", CR_GLSL_STR_2D); + else if (enmTexTarget == GL_TEXTURE_RECTANGLE_ARB) + return CR_GLSL_PATTERN_FS_NOALPHA("", CR_GLSL_STR_EXT_TR, CR_GLSL_STR_2DRECT); + + crWarning("invalid enmTexTarget %#x", enmTexTarget); + return NULL; + } + + crError("crGlslGetFsStringNoAlpha: we should not be here!"); + return NULL; +} + +static int crGlslProgGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget, GLuint *puiProgram) +{ + *puiProgram = 0; + + const char*pStrFsShader = crGlslGetFsStringNoAlpha(pCache, enmTexTarget); + if (!pStrFsShader) + { + crWarning("crGlslGetFsStringNoAlpha failed"); + return VERR_NOT_SUPPORTED; + } + + int rc = VINF_SUCCESS; + GLchar * pBuf = NULL; + GLuint uiProgram = 0; + GLint iUniform = -1; + GLuint uiShader = pCache->pDispatch->CreateShader(GL_FRAGMENT_SHADER); + if (!uiShader) + { + crWarning("CreateShader failed"); + return VERR_NOT_SUPPORTED; + } + + pCache->pDispatch->ShaderSource(uiShader, 1, &pStrFsShader, NULL); + + pCache->pDispatch->CompileShader(uiShader); + + GLint compiled = 0; + pCache->pDispatch->GetShaderiv(uiShader, GL_COMPILE_STATUS, &compiled); + +#ifndef DEBUG_misha + if(!compiled) +#endif + { + if (!pBuf) + pBuf = (GLchar *)RTMemAlloc(16300); + pCache->pDispatch->GetShaderInfoLog(uiShader, 16300, NULL, pBuf); +#ifdef DEBUG_misha + if (compiled) + crDebug("compile success:\n-------------------\n%s\n--------\n", pBuf); + else +#endif + { + crWarning("compile FAILURE:\n-------------------\n%s\n--------\n", pBuf); + rc = VERR_NOT_SUPPORTED; + goto end; + } + } + + Assert(compiled); + + uiProgram = pCache->pDispatch->CreateProgram(); + if (!uiProgram) + { + rc = VERR_NOT_SUPPORTED; + goto end; + } + + pCache->pDispatch->AttachShader(uiProgram, uiShader); + + pCache->pDispatch->LinkProgram(uiProgram); + + GLint linked; + pCache->pDispatch->GetProgramiv(uiProgram, GL_LINK_STATUS, &linked); +#ifndef DEBUG_misha + if(!linked) +#endif + { + if (!pBuf) + pBuf = (GLchar *)RTMemAlloc(16300); + pCache->pDispatch->GetProgramInfoLog(uiProgram, 16300, NULL, pBuf); +#ifdef DEBUG_misha + if (linked) + crDebug("link success:\n-------------------\n%s\n--------\n", pBuf); + else +#endif + { + crWarning("link FAILURE:\n-------------------\n%s\n--------\n", pBuf); + rc = VERR_NOT_SUPPORTED; + goto end; + } + } + + Assert(linked); + + iUniform = pCache->pDispatch->GetUniformLocation(uiProgram, "sampler0"); + if (iUniform == -1) + { + crWarning("GetUniformLocation failed for sampler0"); + } + else + { + pCache->pDispatch->Uniform1i(iUniform, 0); + } + + *puiProgram = uiProgram; + + /* avoid end finalizer from cleaning it */ + uiProgram = 0; + + end: + if (uiShader) + pCache->pDispatch->DeleteShader(uiShader); + if (uiProgram) + pCache->pDispatch->DeleteProgram(uiProgram); + if (pBuf) + RTMemFree(pBuf); + return rc; +} + +DECLINLINE(GLuint) crGlslProgGetNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget) +{ + switch (enmTexTarget) + { + case GL_TEXTURE_2D: + return pCache->uNoAlpha2DProg; + case GL_TEXTURE_RECTANGLE_ARB: + return pCache->uNoAlpha2DRectProg; + default: + crWarning("invalid tex enmTexTarget %#x", enmTexTarget); + return 0; + } +} + +DECLINLINE(GLuint*) crGlslProgGetNoAlphaPtr(CR_GLSL_CACHE *pCache, GLenum enmTexTarget) +{ + switch (enmTexTarget) + { + case GL_TEXTURE_2D: + return &pCache->uNoAlpha2DProg; + case GL_TEXTURE_RECTANGLE_ARB: + return &pCache->uNoAlpha2DRectProg; + default: + crWarning("invalid tex enmTexTarget %#x", enmTexTarget); + return NULL; + } +} + +VBOXBLITTERDECL(int) CrGlslProgGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget) +{ + GLuint*puiProgram = crGlslProgGetNoAlphaPtr(pCache, enmTexTarget); + if (!puiProgram) + return VERR_INVALID_PARAMETER; + + if (*puiProgram) + return VINF_SUCCESS; + + return crGlslProgGenNoAlpha(pCache, enmTexTarget, puiProgram); +} + +VBOXBLITTERDECL(int) CrGlslProgGenAllNoAlpha(CR_GLSL_CACHE *pCache) +{ + int rc = CrGlslProgGenNoAlpha(pCache, GL_TEXTURE_2D); + if (!RT_SUCCESS(rc)) + { + crWarning("CrGlslProgGenNoAlpha GL_TEXTURE_2D failed rc %d", rc); + return rc; + } + + rc = CrGlslProgGenNoAlpha(pCache, GL_TEXTURE_RECTANGLE_ARB); + if (!RT_SUCCESS(rc)) + { + crWarning("CrGlslProgGenNoAlpha GL_TEXTURE_RECTANGLE failed rc %d", rc); + return rc; + } + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(void) CrGlslProgClear(const CR_GLSL_CACHE *pCache) +{ + pCache->pDispatch->UseProgram(0); +} + +VBOXBLITTERDECL(int) CrGlslProgUseNoAlpha(const CR_GLSL_CACHE *pCache, GLenum enmTexTarget) +{ + GLuint uiProg = crGlslProgGetNoAlpha(pCache, enmTexTarget); + if (!uiProg) + { + crWarning("request to use inexistent program!"); + return VERR_INVALID_STATE; + } + + Assert(uiProg); + + pCache->pDispatch->UseProgram(uiProg); + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(int) CrGlslProgUseGenNoAlpha(CR_GLSL_CACHE *pCache, GLenum enmTexTarget) +{ + GLuint uiProg = crGlslProgGetNoAlpha(pCache, enmTexTarget); + if (!uiProg) + { + int rc = CrGlslProgGenNoAlpha(pCache, enmTexTarget); + if (!RT_SUCCESS(rc)) + { + crWarning("CrGlslProgGenNoAlpha failed, rc %d", rc); + return rc; + } + + uiProg = crGlslProgGetNoAlpha(pCache, enmTexTarget); + CRASSERT(uiProg); + } + + Assert(uiProg); + + pCache->pDispatch->UseProgram(uiProg); + + return VINF_SUCCESS; +} + +#endif /* !IN_VMSVGA3D */ + +VBOXBLITTERDECL(bool) CrGlslNeedsCleanup(const CR_GLSL_CACHE *pCache) +{ + return pCache->uNoAlpha2DProg || pCache->uNoAlpha2DRectProg; +} + +VBOXBLITTERDECL(void) CrGlslCleanup(CR_GLSL_CACHE *pCache) +{ + if (pCache->uNoAlpha2DProg) + { +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pCache->pDispatch->DeleteProgram(pCache->uNoAlpha2DProg); +#endif + pCache->uNoAlpha2DProg = 0; + } + + if (pCache->uNoAlpha2DRectProg) + { +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pCache->pDispatch->DeleteProgram(pCache->uNoAlpha2DRectProg); +#endif + pCache->uNoAlpha2DRectProg = 0; + } +} + +VBOXBLITTERDECL(void) CrGlslTerm(CR_GLSL_CACHE *pCache) +{ + CRASSERT(!CrGlslNeedsCleanup(pCache)); + + CrGlslCleanup(pCache); + + /* sanity */ + memset(pCache, 0, sizeof (*pCache)); +} + +#ifndef IN_VMSVGA3D + +/*TdBlt*/ +static void crTdBltCheckPBO(PCR_TEXDATA pTex) +{ + if (pTex->idPBO) + return; + + PCR_BLITTER pBlitter = pTex->pBlitter; + + if (!pBlitter->Flags.SupportsPBO) + return; + + pBlitter->pDispatch->GenBuffersARB(1, &pTex->idPBO); + if (!pTex->idPBO) + { + crWarning("PBO create failed"); + return; + } + + pBlitter->pDispatch->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pTex->idPBO); + pBlitter->pDispatch->BufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, + pTex->Tex.width*pTex->Tex.height*4, + 0, GL_STREAM_READ_ARB); + pBlitter->pDispatch->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); +} + +static uint32_t crTdBltTexCreate(PCR_BLITTER pBlitter, uint32_t width, uint32_t height, GLenum enmTarget) +{ + uint32_t tex = 0; + pBlitter->pDispatch->GenTextures(1, &tex); + if (!tex) + { + crWarning("Tex create failed"); + return 0; + } + + pBlitter->pDispatch->BindTexture(enmTarget, tex); + pBlitter->pDispatch->TexParameteri(enmTarget, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + pBlitter->pDispatch->TexParameteri(enmTarget, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + pBlitter->pDispatch->TexParameteri(enmTarget, GL_TEXTURE_WRAP_S, GL_CLAMP); + pBlitter->pDispatch->TexParameteri(enmTarget, GL_TEXTURE_WRAP_T, GL_CLAMP); + pBlitter->pDispatch->TexImage2D(enmTarget, 0, GL_RGBA8, + width, height, + 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + + + /*Restore gl state*/ + pBlitter->pDispatch->BindTexture(enmTarget, 0); + + return tex; +} + +int crTdBltCheckInvertTex(PCR_TEXDATA pTex) +{ + if (pTex->idInvertTex) + return VINF_SUCCESS; + + pTex->idInvertTex = crTdBltTexCreate(pTex->pBlitter, pTex->Tex.width, pTex->Tex.height, pTex->Tex.target); + if (!pTex->idInvertTex) + { + crWarning("Invert Tex create failed"); + return VERR_GENERAL_FAILURE; + } + return VINF_SUCCESS; +} + +#endif /* !IN_VMSVGA3D */ + + +void crTdBltImgRelease(PCR_TEXDATA pTex) +{ + pTex->Flags.DataValid = 0; +} + +void crTdBltImgFree(PCR_TEXDATA pTex) +{ + if (!pTex->Img.pvData) + { + Assert(!pTex->Flags.DataValid); + return; + } + + crTdBltImgRelease(pTex); + + Assert(!pTex->Flags.DataValid); + + + if (pTex->idPBO) + { + PCR_BLITTER pBlitter = pTex->pBlitter; + + Assert(CrBltIsEntered(pBlitter)); +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pTex->idPBO); + pBlitter->pDispatch->UnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); + pBlitter->pDispatch->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); +#endif + } + else + { + Assert(pTex->Img.pvData); + RTMemFree(pTex->Img.pvData); + } + + pTex->Img.pvData = NULL; +} + + +#ifndef IN_VMSVGA3D + +int crTdBltImgAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted) +{ + void *pvData = pTex->Img.pvData; + Assert(!pTex->Flags.DataValid); + int rc = crBltImgInitBaseForTex(&pTex->Tex, &pTex->Img, enmFormat); + if (!RT_SUCCESS(rc)) + { + WARN(("crBltImgInitBaseForTex failed rc %d", rc)); + return rc; + } + + PCR_BLITTER pBlitter = pTex->pBlitter; + Assert(CrBltIsEntered(pBlitter)); + pBlitter->pDispatch->BindTexture(pTex->Tex.target, fInverted ? pTex->idInvertTex : pTex->Tex.hwid); + + pBlitter->pDispatch->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pTex->idPBO); + + if (pvData) + { + if (pTex->idPBO) + { + pBlitter->pDispatch->UnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); + pvData = NULL; + + } + } + else + { + if (!pTex->idPBO) + { + pvData = RTMemAlloc(4*pTex->Tex.width*pTex->Tex.height); + if (!pvData) + { + WARN(("Out of memory in crTdBltImgAcquire")); + pBlitter->pDispatch->BindTexture(pTex->Tex.target, 0); + return VERR_NO_MEMORY; + } + } + } + + Assert(!pvData == !!pTex->idPBO); + + /*read the texture, note pixels are NULL for PBO case as it's offset in the buffer*/ + pBlitter->pDispatch->GetTexImage(GL_TEXTURE_2D, 0, enmFormat, GL_UNSIGNED_BYTE, pvData); + + /*restore gl state*/ + pBlitter->pDispatch->BindTexture(pTex->Tex.target, 0); + + if (pTex->idPBO) + { + pvData = pBlitter->pDispatch->MapBufferARB(GL_PIXEL_PACK_BUFFER_ARB, GL_READ_ONLY); + if (!pvData) + { + WARN(("Failed to MapBuffer in CrHlpGetTexImage")); + return VERR_GENERAL_FAILURE; + } + + pBlitter->pDispatch->BindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0); + } + + Assert(pvData); + pTex->Img.pvData = pvData; + pTex->Flags.DataValid = 1; + pTex->Flags.DataInverted = fInverted; + return VINF_SUCCESS; +} + +#endif /* !IN_VMSVGA3D */ + + +/* release the texture data, the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataInvalidateNe or CrTdBltDataCleanup */ +VBOXBLITTERDECL(int) CrTdBltDataRelease(PCR_TEXDATA pTex) +{ + if (!pTex->Flags.Entered) + { + WARN(("tex not entered")); + return VERR_INVALID_STATE; + } + + if (!pTex->Flags.DataAcquired) + { + WARN(("Data NOT acquired")); + return VERR_INVALID_STATE; + } + + Assert(pTex->Img.pvData); + Assert(pTex->Flags.DataValid); + + pTex->Flags.DataAcquired = 0; + + return VINF_SUCCESS; +} + +static void crTdBltDataFree(PCR_TEXDATA pTex) +{ + crTdBltImgFree(pTex); + + if (pTex->pScaledCache) + CrTdBltDataFreeNe(pTex->pScaledCache); +} + +/* discard the texture data cached with previous CrTdBltDataAcquire. + * Must be called wit data released (CrTdBltDataRelease) */ +VBOXBLITTERDECL(int) CrTdBltDataFree(PCR_TEXDATA pTex) +{ + if (!pTex->Flags.Entered) + { + WARN(("tex not entered")); + return VERR_INVALID_STATE; + } + + crTdBltDataFree(pTex); + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(void) CrTdBltDataInvalidateNe(PCR_TEXDATA pTex) +{ + crTdBltImgRelease(pTex); + + if (pTex->pScaledCache) + CrTdBltDataInvalidateNe(pTex->pScaledCache); +} + +VBOXBLITTERDECL(int) CrTdBltDataFreeNe(PCR_TEXDATA pTex) +{ + if (!pTex->Img.pvData) + return VINF_SUCCESS; + + bool fEntered = false; + if (pTex->idPBO) + { + int rc = CrTdBltEnter(pTex); + if (!RT_SUCCESS(rc)) + { + WARN(("err")); + return rc; + } + + fEntered = true; + } + + crTdBltDataFree(pTex); + + if (fEntered) + CrTdBltLeave(pTex); + + return VINF_SUCCESS; +} + +static void crTdBltSdCleanupCacheNe(PCR_TEXDATA pTex) +{ + if (pTex->pScaledCache) + { + CrTdBltDataCleanupNe(pTex->pScaledCache); + CrTdRelease(pTex->pScaledCache); + pTex->pScaledCache = NULL; + } +} + +static void crTdBltDataCleanup(PCR_TEXDATA pTex) +{ + crTdBltImgFree(pTex); + + PCR_BLITTER pBlitter = pTex->pBlitter; + + if (pTex->idPBO) + { + Assert(CrBltIsEntered(pBlitter)); +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->DeleteBuffersARB(1, &pTex->idPBO); +#endif + pTex->idPBO = 0; + } + + if (pTex->idInvertTex) + { + Assert(CrBltIsEntered(pBlitter)); +#ifdef IN_VMSVGA3D + /** @todo IN_VMSVGA3D */ +#else + pBlitter->pDispatch->DeleteTextures(1, &pTex->idInvertTex); +#endif + pTex->idInvertTex = 0; + } + + crTdBltSdCleanupCacheNe(pTex); +} + +/* does same as CrTdBltDataFree, and in addition cleans up */ +VBOXBLITTERDECL(int) CrTdBltDataCleanup(PCR_TEXDATA pTex) +{ + if (!pTex->Flags.Entered) + { + WARN(("tex not entered")); + return VERR_INVALID_STATE; + } + + crTdBltDataCleanup(pTex); + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(int) CrTdBltDataCleanupNe(PCR_TEXDATA pTex) +{ + bool fEntered = false; + if (pTex->idPBO || pTex->idInvertTex) + { + int rc = CrTdBltEnter(pTex); + if (!RT_SUCCESS(rc)) + { + WARN(("err")); + return rc; + } + + fEntered = true; + } + + crTdBltDataCleanup(pTex); + + if (fEntered) + CrTdBltLeave(pTex); + + return VINF_SUCCESS; +} + + +#ifndef IN_VMSVGA3D + +/* acquire the texture data, returns the cached data in case it is cached. + * the data remains cached in the CR_TEXDATA object until it is discarded with CrTdBltDataFree or CrTdBltDataCleanup. + * */ +VBOXBLITTERDECL(int) CrTdBltDataAcquire(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, const CR_BLITTER_IMG**ppImg) +{ + if (!pTex->Flags.Entered) + { + WARN(("tex not entered")); + return VERR_INVALID_STATE; + } + + if (pTex->Flags.DataAcquired) + { + WARN(("Data acquired already")); + return VERR_INVALID_STATE; + } + + if (pTex->Flags.DataValid && pTex->Img.enmFormat == enmFormat && !pTex->Flags.DataInverted == !fInverted) + { + Assert(pTex->Img.pvData); + *ppImg = &pTex->Img; + pTex->Flags.DataAcquired = 1; + return VINF_SUCCESS; + } + + crTdBltImgRelease(pTex); + + crTdBltCheckPBO(pTex); + + int rc; + + if (fInverted) + { + rc = crTdBltCheckInvertTex(pTex); + if (!RT_SUCCESS(rc)) + { + WARN(("crTdBltCheckInvertTex failed rc %d", rc)); + return rc; + } + + RTRECT SrcRect, DstRect; + VBOXVR_TEXTURE InvertTex; + + InvertTex = pTex->Tex; + InvertTex.hwid = pTex->idInvertTex; + + SrcRect.xLeft = 0; + SrcRect.yTop = InvertTex.height; + SrcRect.xRight = InvertTex.width; + SrcRect.yBottom = 0; + + DstRect.xLeft = 0; + DstRect.yTop = 0; + DstRect.xRight = InvertTex.width; + DstRect.yBottom = InvertTex.height; + + CrBltBlitTexTex(pTex->pBlitter, &pTex->Tex, &SrcRect, &InvertTex, &DstRect, 1, 0); + } + + rc = crTdBltImgAcquire(pTex, enmFormat, fInverted); + if (!RT_SUCCESS(rc)) + { + WARN(("crTdBltImgAcquire failed rc %d", rc)); + return rc; + } + + Assert(pTex->Img.pvData); + *ppImg = &pTex->Img; + pTex->Flags.DataAcquired = 1; + + return VINF_SUCCESS; +} + +DECLINLINE(void) crTdResize(PCR_TEXDATA pTex, const VBOXVR_TEXTURE *pVrTex) +{ + crTdBltDataCleanup(pTex); + + pTex->Tex = *pVrTex; +} + +static DECLCALLBACK(void) ctTdBltSdReleased(struct CR_TEXDATA *pTexture) +{ + PCR_BLITTER pBlitter = pTexture->pBlitter; + + int rc = CrBltEnter(pBlitter); + if (!RT_SUCCESS(rc)) + { + WARN(("CrBltEnter failed, rc %d", rc)); + return; + } + + CrTdBltDataCleanupNe(pTexture); + + pBlitter->pDispatch->DeleteTextures(1, &pTexture->Tex.hwid); + + CrBltLeave(pBlitter); + + RTMemFree(pTexture); +} + +static int ctTdBltSdCreate(PCR_BLITTER pBlitter, uint32_t width, uint32_t height, GLenum enmTarget, PCR_TEXDATA *ppScaledCache) +{ + PCR_TEXDATA pScaledCache; + + Assert(CrBltIsEntered(pBlitter)); + + *ppScaledCache = NULL; + + pScaledCache = (PCR_TEXDATA)RTMemAlloc(sizeof (*pScaledCache)); + if (!pScaledCache) + { + WARN(("RTMemAlloc failed")); + return VERR_NO_MEMORY; + } + + VBOXVR_TEXTURE Tex; + Tex.width = width; + Tex.height = height; + Tex.target = enmTarget; + Tex.hwid = crTdBltTexCreate(pBlitter, width, height, enmTarget); + if (!Tex.hwid) + { + WARN(("Tex create failed")); + RTMemFree(pScaledCache); + return VERR_GENERAL_FAILURE; + } + + CrTdInit(pScaledCache, &Tex, pBlitter, ctTdBltSdReleased); + + *ppScaledCache = pScaledCache; + + return VINF_SUCCESS; +} + +static int ctTdBltSdGet(PCR_TEXDATA pTex, uint32_t width, uint32_t height, PCR_TEXDATA *ppScaledCache) +{ + Assert(CrBltIsEntered(pTex->pBlitter)); + + PCR_TEXDATA pScaledCache; + + *ppScaledCache = NULL; + + if (!pTex->pScaledCache) + { + int rc = ctTdBltSdCreate(pTex->pBlitter, width, height, pTex->Tex.target, &pScaledCache); + if (!RT_SUCCESS(rc)) + { + WARN(("ctTdBltSdCreate failed %d", rc)); + return rc; + } + + pTex->pScaledCache = pScaledCache; + } + else + { + int cmp = pTex->pScaledCache->Tex.width - width; + if (cmp <= 0) + cmp = pTex->pScaledCache->Tex.height - height; + + if (!cmp) + pScaledCache = pTex->pScaledCache; + else if (cmp < 0) /* current cache is "less" than the requested */ + { + int rc = ctTdBltSdCreate(pTex->pBlitter, width, height, pTex->Tex.target, &pScaledCache); + if (!RT_SUCCESS(rc)) + { + WARN(("ctTdBltSdCreate failed %d", rc)); + return rc; + } + + pScaledCache->pScaledCache = pTex->pScaledCache; + pTex->pScaledCache = pScaledCache; + } + else /* cmp > 0 */ + { + int rc = ctTdBltSdGet(pTex->pScaledCache, width, height, &pScaledCache); + if (!RT_SUCCESS(rc)) + { + WARN(("ctTdBltSdGet failed %d", rc)); + return rc; + } + } + } + + Assert(pScaledCache); + +#if 0 + { + VBOXVR_TEXTURE Tex; + Tex.width = width; + Tex.height = height; + Tex.target = pTex->Tex.target; + Tex.hwid = crTdBltTexCreate(pTex, width, height); + if (!Tex.hwid) + { + WARN(("Tex create failed")); + return VERR_GENERAL_FAILURE; + } + + pTex->pBlitter->pDispatch->DeleteTextures(1, &pTex->pScaledCache->Tex.hwid); + + crTdResize(pTex->pScaledCache, &Tex); + } +#endif + + *ppScaledCache = pScaledCache; + return VINF_SUCCESS; +} + +static int ctTdBltSdGetUpdated(PCR_TEXDATA pTex, uint32_t width, uint32_t height, PCR_TEXDATA *ppScaledCache) +{ + PCR_TEXDATA pScaledCache; + + *ppScaledCache = NULL; + int rc = ctTdBltSdGet(pTex, width, height, &pScaledCache); + if (!RT_SUCCESS(rc)) + { + WARN(("ctTdBltSdGet failed %d", rc)); + return rc; + } + + Assert(width == (uint32_t)pScaledCache->Tex.width); + Assert(height == (uint32_t)pScaledCache->Tex.height); + + if (!pScaledCache->Flags.DataValid) + { + RTRECT SrcRect, DstRect; + + SrcRect.xLeft = 0; + SrcRect.yTop = 0; + SrcRect.xRight = pTex->Tex.width; + SrcRect.yBottom = pTex->Tex.height; + + DstRect.xLeft = 0; + DstRect.yTop = 0; + DstRect.xRight = width; + DstRect.yBottom = height; + + CrBltBlitTexTex(pTex->pBlitter, &pTex->Tex, &SrcRect, &pScaledCache->Tex, &DstRect, 1, 0); + } + + *ppScaledCache = pScaledCache; + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(int) CrTdBltDataAcquireScaled(PCR_TEXDATA pTex, GLenum enmFormat, bool fInverted, uint32_t width, uint32_t height, const CR_BLITTER_IMG**ppImg) +{ + if ((uint32_t)pTex->Tex.width == width && (uint32_t)pTex->Tex.height == height) + return CrTdBltDataAcquire(pTex, enmFormat, fInverted, ppImg); + + if (!pTex->Flags.Entered) + { + WARN(("tex not entered")); + return VERR_INVALID_STATE; + } + + PCR_TEXDATA pScaledCache; + + int rc = ctTdBltSdGetUpdated(pTex, width, height, &pScaledCache); + if (!RT_SUCCESS(rc)) + { + WARN(("ctTdBltSdGetUpdated failed rc %d", rc)); + return rc; + } + + rc = CrTdBltEnter(pScaledCache); + if (!RT_SUCCESS(rc)) + { + WARN(("CrTdBltEnter failed rc %d", rc)); + return rc; + } + + rc = CrTdBltDataAcquire(pScaledCache, enmFormat, fInverted, ppImg); + if (!RT_SUCCESS(rc)) + { + WARN(("CrTdBltDataAcquire failed rc %d", rc)); + CrTdBltLeave(pTex->pScaledCache); + return rc; + } + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(int) CrTdBltDataReleaseScaled(PCR_TEXDATA pTex, const CR_BLITTER_IMG *pImg) +{ + PCR_TEXDATA pScaledCache = RT_FROM_MEMBER(pImg, CR_TEXDATA, Img); + int rc = CrTdBltDataRelease(pScaledCache); + if (!RT_SUCCESS(rc)) + { + WARN(("CrTdBltDataRelease failed rc %d", rc)); + return rc; + } + + if (pScaledCache != pTex) + CrTdBltLeave(pScaledCache); + + return VINF_SUCCESS; +} + +VBOXBLITTERDECL(void) CrTdBltScaleCacheMoveTo(PCR_TEXDATA pTex, PCR_TEXDATA pDstTex) +{ + if (!pTex->pScaledCache) + return; + + crTdBltSdCleanupCacheNe(pDstTex); + + pDstTex->pScaledCache = pTex->pScaledCache; + pTex->pScaledCache = NULL; +} + +#endif /* !IN_VMSVGA3D */ + diff --git a/src/VBox/GuestHost/OpenGL/util/bmpscale.cpp b/src/VBox/GuestHost/OpenGL/util/bmpscale.cpp new file mode 100644 index 00000000..4dd9e13f --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/bmpscale.cpp @@ -0,0 +1,319 @@ +/** @file + * Image resampling code, used for snapshot thumbnails. + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +/* + * Based on gdImageCopyResampled from libgd. + * Original copyright notice follows: + + Portions copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 + Pierre-Alain Joye (pierre@libgd.org). + + Permission has been granted to copy, distribute and modify gd in + any context without fee, including a commercial application, + provided that this notice is present in user-accessible supporting + documentation. + + This does not affect your ownership of the derived work itself, and + the intent is to assure proper credit for the authors of gd, not to + interfere with your productive use of gd. If you have questions, + ask. "Derived works" includes all programs that utilize the + library. Credit must be given in user-accessible documentation. + + This software is provided "AS IS." The copyright holders disclaim + all warranties, either express or implied, including but not + limited to implied warranties of merchantability and fitness for a + particular purpose, with respect to this code and accompanying + documentation. + */ + +/* + * + * @todo Simplify: Offsets of images are 0,0 => no dstX, dstY, srcX, srcY; + * Screenshot has no alpha channel => no processing of alpha byte. + */ + +#include + +/* 2.0.10: cast instead of floor() yields 35% performance improvement. + Thanks to John Buckman. */ + +#define floor2(exp) ((long) exp) +/*#define floor2(exp) floor(exp)*/ + +typedef uint8_t *gdImagePtr; + +DECLINLINE(int) gdImageGetTrueColorPixel (gdImagePtr im, int x, int y, int w) +{ + return *(int32_t *)(im + y * w * 4 + x * 4); +} + +DECLINLINE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color, int cbLine) +{ + *(int32_t *)(im + y * cbLine + x * 4) = color; +} + +#define gdAlphaMax 127 +#define gdAlphaOpaque 0 +#define gdAlphaTransparent 127 +#define gdRedMax 255 +#define gdGreenMax 255 +#define gdBlueMax 255 +#define gdTrueColorGetAlpha(c) (((c) & 0x7F000000) >> 24) +#define gdTrueColorGetRed(c) (((c) & 0xFF0000) >> 16) +#define gdTrueColorGetGreen(c) (((c) & 0x00FF00) >> 8) +#define gdTrueColorGetBlue(c) ((c) & 0x0000FF) +#define gdTrueColorAlpha(r, g, b, a) (((a) << 24) + \ + ((r) << 16) + \ + ((g) << 8) + \ + (b)) + +void gdImageCopyResampled (uint8_t *dst, + uint8_t *src, + int dstX, int dstY, + int srcX, int srcY, + int dstW, int dstH, int srcW, int srcH) +{ + int x, y; + double sy1, sy2, sx1, sx2; + for (y = dstY; (y < dstY + dstH); y++) + { + sy1 = ((double) y - (double) dstY) * (double) srcH / (double) dstH; + sy2 = ((double) (y + 1) - (double) dstY) * (double) srcH / + (double) dstH; + for (x = dstX; (x < dstX + dstW); x++) + { + double sx, sy; + double spixels = 0; + double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; + sx1 = ((double) x - (double) dstX) * (double) srcW / dstW; + sx2 = ((double) (x + 1) - (double) dstX) * (double) srcW / dstW; + sy = sy1; + do + { + double yportion; + if (floor2 (sy) == floor2 (sy1)) + { + yportion = 1.0 - (sy - floor2 (sy)); + if (yportion > sy2 - sy1) + { + yportion = sy2 - sy1; + } + sy = floor2 (sy); + } + else if (sy == floor2 (sy2)) + { + yportion = sy2 - floor2 (sy2); + } + else + { + yportion = 1.0; + } + sx = sx1; + do + { + double xportion; + double pcontribution; + int p; + if (floor2 (sx) == floor2 (sx1)) + { + xportion = 1.0 - (sx - floor2 (sx)); + if (xportion > sx2 - sx1) + { + xportion = sx2 - sx1; + } + sx = floor2 (sx); + } + else if (sx == floor2 (sx2)) + { + xportion = sx2 - floor2 (sx2); + } + else + { + xportion = 1.0; + } + pcontribution = xportion * yportion; + /* 2.08: previously srcX and srcY were ignored. + Andrew Pattison */ + p = gdImageGetTrueColorPixel (src, + (int) sx + srcX, + (int) sy + srcY, srcW); + red += gdTrueColorGetRed (p) * pcontribution; + green += gdTrueColorGetGreen (p) * pcontribution; + blue += gdTrueColorGetBlue (p) * pcontribution; + alpha += gdTrueColorGetAlpha (p) * pcontribution; + spixels += xportion * yportion; + sx += 1.0; + } + while (sx < sx2); + sy += 1.0; + } + while (sy < sy2); + if (spixels != 0.0) + { + red /= spixels; + green /= spixels; + blue /= spixels; + alpha /= spixels; + } + /* Clamping to allow for rounding errors above */ + if (red > 255.0) + { + red = 255.0; + } + if (green > 255.0) + { + green = 255.0; + } + if (blue > 255.0) + { + blue = 255.0; + } + if (alpha > gdAlphaMax) + { + alpha = gdAlphaMax; + } + gdImageSetPixel (dst, + x, y, + gdTrueColorAlpha ((int) red, + (int) green, + (int) blue, (int) alpha), dstW * 4); + } + } +} + +/* Fast integer implementation for 32 bpp bitmap scaling. + * Use fixed point values * 16. + */ +typedef int32_t FIXEDPOINT; +#define INT_TO_FIXEDPOINT(i) (FIXEDPOINT)((i) << 4) +#define FIXEDPOINT_TO_INT(v) (int)((v) >> 4) +#define FIXEDPOINT_FLOOR(v) ((v) & ~0xF) +#define FIXEDPOINT_FRACTION(v) ((v) & 0xF) + +/* For 32 bit source only. */ +VBOXBMPSCALEDECL(void) CrBmpScale32 (uint8_t *dst, + int iDstDeltaLine, + int dstW, int dstH, + const uint8_t *src, + int iSrcDeltaLine, + int srcW, int srcH) +{ + int x, y; + + for (y = 0; y < dstH; y++) + { + FIXEDPOINT sy1 = INT_TO_FIXEDPOINT(y * srcH) / dstH; + FIXEDPOINT sy2 = INT_TO_FIXEDPOINT((y + 1) * srcH) / dstH; + + for (x = 0; x < dstW; x++) + { + FIXEDPOINT red = 0, green = 0, blue = 0; + + FIXEDPOINT sx1 = INT_TO_FIXEDPOINT(x * srcW) / dstW; + FIXEDPOINT sx2 = INT_TO_FIXEDPOINT((x + 1) * srcW) / dstW; + + FIXEDPOINT spixels = (sx2 - sx1) * (sy2 - sy1); + + FIXEDPOINT sy = sy1; + + do + { + FIXEDPOINT yportion; + if (FIXEDPOINT_FLOOR (sy) == FIXEDPOINT_FLOOR (sy1)) + { + yportion = INT_TO_FIXEDPOINT(1) - FIXEDPOINT_FRACTION(sy); + if (yportion > sy2 - sy1) + { + yportion = sy2 - sy1; + } + sy = FIXEDPOINT_FLOOR (sy); + } + else if (sy == FIXEDPOINT_FLOOR (sy2)) + { + yportion = FIXEDPOINT_FRACTION(sy2); + } + else + { + yportion = INT_TO_FIXEDPOINT(1); + } + + const uint8_t *pu8SrcLine = src + iSrcDeltaLine * FIXEDPOINT_TO_INT(sy); + FIXEDPOINT sx = sx1; + do + { + FIXEDPOINT xportion; + FIXEDPOINT pcontribution; + int p; + if (FIXEDPOINT_FLOOR (sx) == FIXEDPOINT_FLOOR (sx1)) + { + xportion = INT_TO_FIXEDPOINT(1) - FIXEDPOINT_FRACTION(sx); + if (xportion > sx2 - sx1) + { + xportion = sx2 - sx1; + } + pcontribution = xportion * yportion; + sx = FIXEDPOINT_FLOOR (sx); + } + else if (sx == FIXEDPOINT_FLOOR (sx2)) + { + xportion = FIXEDPOINT_FRACTION(sx2); + pcontribution = xportion * yportion; + } + else + { + xportion = INT_TO_FIXEDPOINT(1); + pcontribution = xportion * yportion; + } + /* Color depth specific code begin */ + p = *(uint32_t *)(pu8SrcLine + FIXEDPOINT_TO_INT(sx) * 4); + /* Color depth specific code end */ + red += gdTrueColorGetRed (p) * pcontribution; + green += gdTrueColorGetGreen (p) * pcontribution; + blue += gdTrueColorGetBlue (p) * pcontribution; + + sx += INT_TO_FIXEDPOINT(1); + } while (sx < sx2); + + sy += INT_TO_FIXEDPOINT(1); + } while (sy < sy2); + + if (spixels != 0) + { + red /= spixels; + green /= spixels; + blue /= spixels; + } + /* Clamping to allow for rounding errors above */ + if (red > 255) + { + red = 255; + } + if (green > 255) + { + green = 255; + } + if (blue > 255) + { + blue = 255; + } + gdImageSetPixel (dst, + x, y, + ( ((int) red) << 16) + (((int) green) << 8) + ((int) blue), + iDstDeltaLine); + } + } +} + diff --git a/src/VBox/GuestHost/OpenGL/util/bufpool.c b/src/VBox/GuestHost/OpenGL/util/bufpool.c new file mode 100644 index 00000000..ed8dcde6 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/bufpool.c @@ -0,0 +1,194 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "cr_error.h" +#include "cr_bufpool.h" +#include + +/* + * New (version 1.4) buffer pool implementation. + * + * Now, each buffer in the pool can be a different size. + * We only return a buffer from crBufferPoolPop() if we have exactly + * the right size buffer. + * + * Note: the old implementation had a 'max buffers' parameter but it + * really wasn't good for anything since we always grew the buffer pool + * if we pushed a new buffer that would cause use to exceed the limit. + * That's gone now. + * + * We're just using a simple linked list here. Since we seldom have + * more than about 10-15 buffers in the pool, that's OK. A binary tree + * would be nicer though. + * + * MCH: BufferPoolPop will now return the smallest buffer in the pool that + * is >= to the size required. This fixes BufferPool overruns with lots + * of MTUs. + */ + + +#ifndef NULL +#define NULL ((void *) 0) +#endif + + +typedef struct buffer +{ + void *address; + unsigned int size; + struct buffer *next; +} Buffer; + + +struct CRBufferPool_t +{ + unsigned int maxBuffers; + int numBuffers; + struct buffer *head; +}; + + +int +crBufferPoolGetNumBuffers( CRBufferPool *pool ) +{ + if ( pool ) + return pool->numBuffers; + return 0; +} + +int +crBufferPoolGetMaxBuffers( CRBufferPool *pool ) +{ + if ( pool ) + return pool->maxBuffers; + return 0; +} + +CRBufferPool * +crBufferPoolInit( unsigned int maxBuffers ) +{ + CRBufferPool *pool = crCalloc(sizeof(CRBufferPool)); + if (pool) { + pool->head = NULL; + pool->maxBuffers = maxBuffers; + pool->numBuffers = 0; + } + return pool; +} + +void +crBufferPoolFree( CRBufferPool *pool ) +{ + Buffer *b, *next; + + for (b = pool->head; b; b = next) { + next = b->next; + crFree(b->address); + crFree(b); + } +} + +void +crBufferPoolCallbackFree(CRBufferPool *pool, CRBufferPoolDeleteCallback pfnDelete) +{ + Buffer *b, *next; + + CRASSERT(pfnDelete); + + for (b = pool->head; b; b = next) { + next = b->next; + (*pfnDelete)(b->address); + crFree(b); + } +} + +void +crBufferPoolPush( CRBufferPool *pool, void *buf, unsigned int bytes ) +{ + Buffer *b = crCalloc(sizeof(Buffer)); + if (b) { +#ifdef DEBUG + /* check that the buffer to push isn't already in the pool! */ + { + const Buffer *bd; + for (bd = pool->head; bd; bd = bd->next) { + CRASSERT(bd->address != buf); + } + } +#endif + + b->address = buf; + b->size = bytes; + b->next = pool->head; + pool->head = b; + pool->numBuffers++; + } +} + +void * +crBufferPoolPop( CRBufferPool *pool, unsigned int bytes ) +{ + Buffer *b, *prev, *prev_smallest; + unsigned int smallest = UINT_MAX; /* size of smallest buffer >= bytes */ + int i; + + prev = NULL; + prev_smallest = NULL; + for (b = pool->head, i=0; inumBuffers; b = b->next, i++) { + if (b->size == bytes) { + /* we found an exact size match! */ + void *p = b->address; + if (prev) { + prev->next = b->next; + } + else { + pool->head = b->next; + } + crFree(b); + pool->numBuffers--; + CRASSERT(pool->numBuffers >= 0); + return p; + } + else if (b->size >= bytes){ + /* We found a buffer that's large enough, but keep looking + * for a smaller one that's large enough. + */ + if (b->size < smallest) { + prev_smallest = prev; /* save ptr to previous! */ + smallest = b->size; + } + } + prev = b; + } + + if (smallest < UINT_MAX) { + /* we found the smallest buffer whose size is > bytes */ + void *p; + if (prev_smallest) { + b = prev_smallest->next; + } + else { + b = pool->head; + } + CRASSERT(b->size == smallest); + CRASSERT(b->size >= bytes); + p = b->address; + if (prev_smallest) { + prev_smallest->next = b->next; + } + else { + pool->head = b->next; + } + crFree(b); + pool->numBuffers--; + CRASSERT(pool->numBuffers >= 0); + return p; + } + + /* found no buffer large enough */ + return NULL; +} diff --git a/src/VBox/GuestHost/OpenGL/util/calllists.c b/src/VBox/GuestHost/OpenGL/util/calllists.c new file mode 100644 index 00000000..6d973c66 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/calllists.c @@ -0,0 +1,81 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "chromium.h" +#include "cr_calllists.h" + +#define EXPAND(typeEnum, typeCast, increment, value) \ + case typeEnum: \ + { \ + const typeCast *array = (const typeCast *) lists; \ + for (i = 0; i < (GLuint)n; i++, array increment) { \ + (*callListFunc)(base + (GLuint) value); \ + } \ + } \ + break + +#define EXPAND_WITH_DATA(typeEnum, typeCast, increment, value) \ + case typeEnum: \ + { \ + const typeCast *array = (const typeCast *) lists; \ + for (i = 0; i < (GLuint)n; i++, array increment) {\ + (*callListFunc)(base + (GLuint) value, i, data); \ + } \ + } \ + break + + +int +crExpandCallLists(GLsizei n, GLenum type, const GLvoid *lists, + GLuint base, void (*callListFunc)(GLuint list)) +{ + GLuint i; + + switch (type) { + EXPAND(GL_BYTE, GLbyte,++,*array); + EXPAND(GL_UNSIGNED_BYTE, GLubyte,++,*array); + EXPAND(GL_SHORT, GLshort,++,*array); + EXPAND(GL_UNSIGNED_SHORT, GLushort,++,*array); + EXPAND(GL_INT, GLint,++,*array); + EXPAND(GL_UNSIGNED_INT, GLuint,++,*array); + EXPAND(GL_FLOAT, GLfloat,++,*array); + + EXPAND(GL_2_BYTES, GLubyte, +=2, 256*array[0] + array[1]); + EXPAND(GL_3_BYTES, GLubyte, +=3, 256 * (256 * array[0] + array[1]) + array[2]); + EXPAND(GL_4_BYTES, GLubyte, +=4, 256 * (256 * (256 * array[0] + array[1]) + array[2]) + array[3]); + + default: + return GL_INVALID_ENUM; + } + + return GL_NO_ERROR; +} + +int +crExpandCallListsWithData(GLsizei n, GLenum type, const GLvoid *lists, + GLuint base, void (*callListFunc)(GLuint list, GLuint index, GLvoid *data), GLvoid *data) +{ + GLuint i; + + switch (type) { + EXPAND_WITH_DATA(GL_BYTE, GLbyte,++,*array); + EXPAND_WITH_DATA(GL_UNSIGNED_BYTE, GLubyte,++,*array); + EXPAND_WITH_DATA(GL_SHORT, GLshort,++,*array); + EXPAND_WITH_DATA(GL_UNSIGNED_SHORT, GLushort,++,*array); + EXPAND_WITH_DATA(GL_INT, GLint,++,*array); + EXPAND_WITH_DATA(GL_UNSIGNED_INT, GLuint,++,*array); + EXPAND_WITH_DATA(GL_FLOAT, GLfloat,++,*array); + + EXPAND_WITH_DATA(GL_2_BYTES, GLubyte, +=2, 256*array[0] + array[1]); + EXPAND_WITH_DATA(GL_3_BYTES, GLubyte, +=3, 256 * (256 * array[0] + array[1]) + array[2]); + EXPAND_WITH_DATA(GL_4_BYTES, GLubyte, +=4, 256 * (256 * (256 * array[0] + array[1]) + array[2]) + array[3]); + + default: + return GL_INVALID_ENUM; + } + + return GL_NO_ERROR; +} diff --git a/src/VBox/GuestHost/OpenGL/util/compositor.cpp b/src/VBox/GuestHost/OpenGL/util/compositor.cpp new file mode 100644 index 00000000..4392afeb --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/compositor.cpp @@ -0,0 +1,1070 @@ +/* $Id: compositor.cpp $ */ +/** @file + * Compositor implementation. + */ + +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + + +/********************************************************************************************************************************* +* Header Files * +*********************************************************************************************************************************/ +#include "../include/cr_compositor.h" + + +/********************************************************************************************************************************* +* Defined Constants And Macros * +*********************************************************************************************************************************/ +#define VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED UINT32_MAX +#ifdef IN_VMSVGA3D +# define WARN AssertMsgFailed +#endif + +#define FLOAT_FMT_STR "%d.%02u" +#define FLOAT_FMT_ARGS(r) (int)(r), ((unsigned)(RT_ABS(r) * 100) % 100U) + +static int crVrScrCompositorRectsAssignBuffer(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRects) +{ + Assert(cRects); + + if (pCompositor->cRectsBuffer >= cRects) + { + pCompositor->cRects = cRects; + return VINF_SUCCESS; + } + + if (pCompositor->cRectsBuffer) + { + Assert(pCompositor->paSrcRects); + RTMemFree(pCompositor->paSrcRects); + pCompositor->paSrcRects = NULL; + Assert(pCompositor->paDstRects); + RTMemFree(pCompositor->paDstRects); + pCompositor->paDstRects = NULL; + Assert(pCompositor->paDstUnstretchedRects); + RTMemFree(pCompositor->paDstUnstretchedRects); + pCompositor->paDstUnstretchedRects = NULL; + } + else + { + Assert(!pCompositor->paSrcRects); + Assert(!pCompositor->paDstRects); + Assert(!pCompositor->paDstUnstretchedRects); + } + + pCompositor->paSrcRects = (PRTRECT)RTMemAlloc(sizeof(*pCompositor->paSrcRects) * cRects); + if (pCompositor->paSrcRects) + { + pCompositor->paDstRects = (PRTRECT)RTMemAlloc(sizeof(*pCompositor->paDstRects) * cRects); + if (pCompositor->paDstRects) + { + pCompositor->paDstUnstretchedRects = (PRTRECT)RTMemAlloc(sizeof(*pCompositor->paDstUnstretchedRects) * cRects); + if (pCompositor->paDstUnstretchedRects) + { + pCompositor->cRects = cRects; + pCompositor->cRectsBuffer = cRects; + return VINF_SUCCESS; + } + + RTMemFree(pCompositor->paDstRects); + pCompositor->paDstRects = NULL; + } + else + { + WARN(("RTMemAlloc failed!")); + } + RTMemFree(pCompositor->paSrcRects); + pCompositor->paSrcRects = NULL; + } + else + { + WARN(("RTMemAlloc failed!")); + } + + pCompositor->cRects = VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED; + pCompositor->cRectsBuffer = 0; + + return VERR_NO_MEMORY; +} + +static void crVrScrCompositorRectsInvalidate(PVBOXVR_SCR_COMPOSITOR pCompositor) +{ + pCompositor->cRects = VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED; +} + +static DECLCALLBACK(bool) crVrScrCompositorRectsCounterCb(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + void *pvVisitor) +{ + uint32_t* pCounter = (uint32_t*)pvVisitor; + (void)pCompositor; (void)pEntry; + + Assert(VBoxVrListRectsCount(&pEntry->Vr)); + *pCounter += VBoxVrListRectsCount(&pEntry->Vr); + return true; +} + +typedef struct VBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER +{ + PRTRECT paSrcRects; + PRTRECT paDstRects; + PRTRECT paDstUnstretchedRects; + uint32_t cRects; +} VBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER, *PVBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER; + +static DECLCALLBACK(bool) crVrScrCompositorRectsAssignerCb(PVBOXVR_COMPOSITOR pCCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry, + void *pvVisitor) +{ + PVBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER pData = (PVBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER)pvVisitor; + PVBOXVR_SCR_COMPOSITOR pCompositor = VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(pCCompositor); + PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCEntry); + pEntry->paSrcRects = pData->paSrcRects; + pEntry->paDstRects = pData->paDstRects; + pEntry->paDstUnstretchedRects = pData->paDstUnstretchedRects; + uint32_t cRects = VBoxVrListRectsCount(&pCEntry->Vr); + Assert(cRects); + Assert(cRects <= pData->cRects); + int rc = VBoxVrListRectsGet(&pCEntry->Vr, cRects, pEntry->paDstUnstretchedRects); + AssertRC(rc); + + if (!pEntry->Rect.xLeft && !pEntry->Rect.yTop) + { + memcpy(pEntry->paSrcRects, pEntry->paDstUnstretchedRects, cRects * sizeof(*pEntry->paSrcRects)); + } + else + { + for (uint32_t i = 0; i < cRects; ++i) + { + pEntry->paSrcRects[i].xLeft = (int32_t)((pEntry->paDstUnstretchedRects[i].xLeft - pEntry->Rect.xLeft)); + pEntry->paSrcRects[i].yTop = (int32_t)((pEntry->paDstUnstretchedRects[i].yTop - pEntry->Rect.yTop)); + pEntry->paSrcRects[i].xRight = (int32_t)((pEntry->paDstUnstretchedRects[i].xRight - pEntry->Rect.xLeft)); + pEntry->paSrcRects[i].yBottom = (int32_t)((pEntry->paDstUnstretchedRects[i].yBottom - pEntry->Rect.yTop)); + } + } + +#ifndef IN_RING0 + if (pCompositor->StretchX != 1. || pCompositor->StretchY != 1.) + { + for (uint32_t i = 0; i < cRects; ++i) + { + if (pCompositor->StretchX != 1.) + { + pEntry->paDstRects[i].xLeft = (int32_t)(pEntry->paDstUnstretchedRects[i].xLeft * pCompositor->StretchX); + pEntry->paDstRects[i].xRight = (int32_t)(pEntry->paDstUnstretchedRects[i].xRight * pCompositor->StretchX); + } + if (pCompositor->StretchY != 1.) + { + pEntry->paDstRects[i].yTop = (int32_t)(pEntry->paDstUnstretchedRects[i].yTop * pCompositor->StretchY); + pEntry->paDstRects[i].yBottom = (int32_t)(pEntry->paDstUnstretchedRects[i].yBottom * pCompositor->StretchY); + } + } + } + else +#endif + { + memcpy(pEntry->paDstRects, pEntry->paDstUnstretchedRects, cRects * sizeof(*pEntry->paDstUnstretchedRects)); + } + +#if 0//ndef IN_RING0 + bool canZeroX = (pCompositor->StretchX < 1.); + bool canZeroY = (pCompositor->StretchY < 1.); + if (canZeroX && canZeroY) + { + /* filter out zero rectangles*/ + uint32_t iOrig, iNew; + for (iOrig = 0, iNew = 0; iOrig < cRects; ++iOrig) + { + PRTRECT pOrigRect = &pEntry->paDstRects[iOrig]; + if (pOrigRect->xLeft != pOrigRect->xRight + && pOrigRect->yTop != pOrigRect->yBottom) + continue; + + if (iNew != iOrig) + { + PRTRECT pNewRect = &pEntry->paSrcRects[iNew]; + *pNewRect = *pOrigRect; + } + + ++iNew; + } + + Assert(iNew <= iOrig); + + uint32_t cDiff = iOrig - iNew; + + if (cDiff) + { + pCompositor->cRects -= cDiff; + cRects -= cDiff; + } + } +#endif + + pEntry->cRects = cRects; + pData->paDstRects += cRects; + pData->paSrcRects += cRects; + pData->paDstUnstretchedRects += cRects; + pData->cRects -= cRects; + return true; +} + +static int crVrScrCompositorRectsCheckInit(PCVBOXVR_SCR_COMPOSITOR pcCompositor) +{ + PVBOXVR_SCR_COMPOSITOR pCompositor = const_cast(pcCompositor); + + if (pCompositor->cRects != VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED) + return VINF_SUCCESS; + + uint32_t cRects = 0; + VBoxVrCompositorVisit(&pCompositor->Compositor, crVrScrCompositorRectsCounterCb, &cRects); + + if (!cRects) + { + pCompositor->cRects = 0; + return VINF_SUCCESS; + } + + int rc = crVrScrCompositorRectsAssignBuffer(pCompositor, cRects); + if (RT_FAILURE(rc)) + return rc; + + VBOXVR_SCR_COMPOSITOR_RECTS_ASSIGNER AssignerData; + AssignerData.paSrcRects = pCompositor->paSrcRects; + AssignerData.paDstRects = pCompositor->paDstRects; + AssignerData.paDstUnstretchedRects = pCompositor->paDstUnstretchedRects; + AssignerData.cRects = pCompositor->cRects; + VBoxVrCompositorVisit(&pCompositor->Compositor, crVrScrCompositorRectsAssignerCb, &AssignerData); + Assert(!AssignerData.cRects); + return VINF_SUCCESS; +} + + +static int crVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, + VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry, uint32_t *pfChangedFlags) +{ + uint32_t fChangedFlags = 0; + PVBOXVR_COMPOSITOR_ENTRY pReplacedEntry; + int rc = VBoxVrCompositorEntryRegionsAdd(&pCompositor->Compositor, pEntry ? &pEntry->Ce : NULL, cRegions, + paRegions, &pReplacedEntry, &fChangedFlags); + if (RT_FAILURE(rc)) + { + WARN(("VBoxVrCompositorEntryRegionsAdd failed, rc %d", rc)); + return rc; + } + + VBOXVR_SCR_COMPOSITOR_ENTRY *pReplacedScrEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pReplacedEntry); + + if (fChangedFlags & VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED) + crVrScrCompositorRectsInvalidate(pCompositor); + else if (fChangedFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED) + Assert(pReplacedScrEntry); + + if (fChangedFlags & VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED) + CrVrScrCompositorEntrySetAllChanged(pCompositor, true); + else if ((fChangedFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED) && pEntry) + CrVrScrCompositorEntrySetChanged(pEntry, true); + + if (pfChangedFlags) + *pfChangedFlags = fChangedFlags; + + if (ppReplacedScrEntry) + *ppReplacedScrEntry = pReplacedScrEntry; + + return VINF_SUCCESS; +} + +static int crVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged) +{ + bool fChanged; + int rc = VBoxVrCompositorEntryRegionsSet(&pCompositor->Compositor, &pEntry->Ce, cRegions, paRegions, &fChanged); + if (RT_FAILURE(rc)) + { + WARN(("VBoxVrCompositorEntryRegionsSet failed, rc %d", rc)); + return rc; + } + + if (fChanged) + { + CrVrScrCompositorEntrySetAllChanged(pCompositor, true); + if (!CrVrScrCompositorEntryIsInList(pEntry)) + { + pEntry->cRects = 0; + pEntry->paSrcRects = NULL; + pEntry->paDstRects = NULL; + pEntry->paDstUnstretchedRects = NULL; + } + crVrScrCompositorRectsInvalidate(pCompositor); + } + + + if (pfChanged) + *pfChanged = fChanged; + return VINF_SUCCESS; +} + +static int crVrScrCompositorEntryPositionSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTPOINT pPos, bool *pfChanged) +{ + if (pfChanged) + *pfChanged = false; + if (pEntry && (pEntry->Rect.xLeft != pPos->x || pEntry->Rect.yTop != pPos->y)) + { + if (VBoxVrCompositorEntryIsInList(&pEntry->Ce)) + { + int rc = VBoxVrCompositorEntryRegionsTranslate(&pCompositor->Compositor, &pEntry->Ce, pPos->x - pEntry->Rect.xLeft, + pPos->y - pEntry->Rect.yTop, pfChanged); + if (RT_FAILURE(rc)) + { + WARN(("VBoxVrCompositorEntryRegionsTranslate failed rc %d", rc)); + return rc; + } + + crVrScrCompositorRectsInvalidate(pCompositor); + } + + VBoxRectMove(&pEntry->Rect, pPos->x, pPos->y); + CrVrScrCompositorEntrySetChanged(pEntry, true); + + if (pfChanged) + *pfChanged = true; + } + return VINF_SUCCESS; +} + +static int crVrScrCompositorEntryEnsureRegionsBounds(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + bool *pfChanged) +{ + RTRECT Rect; + Rect.xLeft = RT_MAX(pCompositor->Rect.xLeft, pEntry->Rect.xLeft); + Rect.yTop = RT_MAX(pCompositor->Rect.yTop, pEntry->Rect.yTop); + Rect.xRight = RT_MIN(pCompositor->Rect.xRight, pEntry->Rect.xRight); + Rect.yBottom = RT_MIN(pCompositor->Rect.yBottom, pEntry->Rect.yBottom); + bool fChanged = false; + + if (pfChanged) + *pfChanged = false; + + int rc = CrVrScrCompositorEntryRegionsIntersect(pCompositor, pEntry, 1, &Rect, &fChanged); + if (RT_FAILURE(rc)) + WARN(("CrVrScrCompositorEntryRegionsIntersect failed, rc %d", rc)); + + if (pfChanged) + *pfChanged = fChanged; + return rc; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsAdd(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions, + bool fPosRelated, VBOXVR_SCR_COMPOSITOR_ENTRY **ppReplacedScrEntry, + uint32_t *pfChangeFlags) +{ + int rc; + uint32_t fChangeFlags = 0; + bool fPosChanged = false; + RTRECT *paTranslatedRects = NULL; + if (pPos) + { + rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, pPos, &fPosChanged); + if (RT_FAILURE(rc)) + { + WARN(("RegionsAdd: crVrScrCompositorEntryPositionSet failed rc %d", rc)); + return rc; + } + } + + if (fPosRelated) + { + if (!pEntry) + { + WARN(("Entry is expected to be specified for pos-related regions")); + return VERR_INVALID_PARAMETER; + } + + if (cRegions && (pEntry->Rect.xLeft || pEntry->Rect.yTop)) + { + paTranslatedRects = (RTRECT*)RTMemAlloc(sizeof(RTRECT) * cRegions); + if (!paTranslatedRects) + { + WARN(("RTMemAlloc failed")); + return VERR_NO_MEMORY; + } + memcpy (paTranslatedRects, paRegions, sizeof(RTRECT) * cRegions); + for (uint32_t i = 0; i < cRegions; ++i) + { + VBoxRectTranslate(&paTranslatedRects[i], pEntry->Rect.xLeft, pEntry->Rect.yTop); + paRegions = paTranslatedRects; + } + } + } + + rc = crVrScrCompositorEntryRegionsAdd(pCompositor, pEntry, cRegions, paRegions, ppReplacedScrEntry, &fChangeFlags); + if (RT_FAILURE(rc)) + { + WARN(("crVrScrCompositorEntryRegionsAdd failed, rc %d", rc)); + goto done; + } + + if ((fPosChanged || (fChangeFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED)) && pEntry) + { + bool fAdjusted = false; + rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, &fAdjusted); + if (RT_FAILURE(rc)) + { + WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc)); + goto done; + } + + if (fAdjusted) + { + if (CrVrScrCompositorEntryIsUsed(pEntry)) + { + fChangeFlags &= ~VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED; + fChangeFlags |= VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED; + } + else + { + fChangeFlags = 0; + } + } + } + + if (fChangeFlags & VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED) + fPosChanged = false; + else if (ppReplacedScrEntry) + *ppReplacedScrEntry = NULL; + + if (pfChangeFlags) + { + if (fPosChanged) + { + /* means entry was in list and was moved, so regions changed */ + *pfChangeFlags = VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED + | VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED; + } + else + *pfChangeFlags = fChangeFlags; + } + +done: + + if (paTranslatedRects) + RTMemFree(paTranslatedRects); + + return rc; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTRECT pRect) +{ + if (!memcmp(&pEntry->Rect, pRect, sizeof(*pRect))) + { + return VINF_SUCCESS; + } + RTPOINT Point = {pRect->xLeft, pRect->yTop}; + bool fChanged = false; + int rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, &Point, &fChanged); + if (RT_FAILURE(rc)) + { + WARN(("crVrScrCompositorEntryPositionSet failed %d", rc)); + return rc; + } + + pEntry->Rect = *pRect; + + if (!CrVrScrCompositorEntryIsUsed(pEntry)) + return VINF_SUCCESS; + + rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL); + if (RT_FAILURE(rc)) + { + WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc)); + return rc; + } + + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryTexAssign(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + CR_TEXDATA *pTex) +{ + (void)pCompositor; + + if (pEntry->pTex == pTex) + return VINF_SUCCESS; + + if (pEntry->pTex) + CrTdRelease(pEntry->pTex); + if (pTex) + CrTdAddRef(pTex); + pEntry->pTex = pTex; + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTPOINT pPos, uint32_t cRegions, PCRTRECT paRegions, + bool fPosRelated, bool *pfChanged) +{ + /** @todo the fChanged sate calculation is really rough now, this is enough for now though */ + bool fChanged = false, fPosChanged = false; + bool fWasInList = CrVrScrCompositorEntryIsInList(pEntry); + RTRECT *paTranslatedRects = NULL; + int rc = CrVrScrCompositorEntryRemove(pCompositor, pEntry); + if (RT_FAILURE(rc)) + { + WARN(("RegionsSet: CrVrScrCompositorEntryRemove failed rc %d", rc)); + return rc; + } + + if (pPos) + { + rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, pPos, &fPosChanged); + if (RT_FAILURE(rc)) + { + WARN(("RegionsSet: crVrScrCompositorEntryPositionSet failed rc %d", rc)); + return rc; + } + } + + if (fPosRelated) + { + if (!pEntry) + { + WARN(("Entry is expected to be specified for pos-related regions")); + return VERR_INVALID_PARAMETER; + } + + if (cRegions && (pEntry->Rect.xLeft || pEntry->Rect.yTop)) + { + paTranslatedRects = (RTRECT*)RTMemAlloc(sizeof(RTRECT) * cRegions); + if (!paTranslatedRects) + { + WARN(("RTMemAlloc failed")); + return VERR_NO_MEMORY; + } + memcpy (paTranslatedRects, paRegions, sizeof(RTRECT) * cRegions); + for (uint32_t i = 0; i < cRegions; ++i) + { + VBoxRectTranslate(&paTranslatedRects[i], pEntry->Rect.xLeft, pEntry->Rect.yTop); + paRegions = paTranslatedRects; + } + } + } + + rc = crVrScrCompositorEntryRegionsSet(pCompositor, pEntry, cRegions, paRegions, &fChanged); + if (RT_SUCCESS(rc)) + { + if (fChanged && CrVrScrCompositorEntryIsUsed(pEntry)) + { + rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL); + if (RT_SUCCESS(rc)) + { + if (pfChanged) + *pfChanged = fPosChanged || fChanged || fWasInList; + } + else + WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc)); + } + + } + else + WARN(("crVrScrCompositorEntryRegionsSet failed, rc %d", rc)); + + if (paTranslatedRects) + RTMemFree(paTranslatedRects); + + return rc; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCVBOXVR_LIST pList2, bool *pfChanged) +{ + bool fChanged = false; + int rc = VBoxVrCompositorEntryListIntersect(&pCompositor->Compositor, &pEntry->Ce, pList2, &fChanged); + if (RT_FAILURE(rc)) + { + WARN(("RegionsIntersect: VBoxVrCompositorEntryRegionsIntersect failed rc %d", rc)); + return rc; + } + + if (fChanged) + { + CrVrScrCompositorEntrySetChanged(pEntry, true); + crVrScrCompositorRectsInvalidate(pCompositor); + } + + if (pfChanged) + *pfChanged = fChanged; + + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersect(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + uint32_t cRegions, PCRTRECT paRegions, bool *pfChanged) +{ + bool fChanged = false; + int rc = VBoxVrCompositorEntryRegionsIntersect(&pCompositor->Compositor, &pEntry->Ce, cRegions, paRegions, &fChanged); + if (RT_FAILURE(rc)) + { + WARN(("RegionsIntersect: VBoxVrCompositorEntryRegionsIntersect failed rc %d", rc)); + return rc; + } + + if (fChanged) + crVrScrCompositorRectsInvalidate(pCompositor); + + if (pfChanged) + *pfChanged = fChanged; + + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryListIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2, bool *pfChanged) +{ + VBOXVR_SCR_COMPOSITOR_ITERATOR Iter; + CrVrScrCompositorIterInit(pCompositor, &Iter); + PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry; + int rc = VINF_SUCCESS; + bool fChanged = false; + + while ((pEntry = CrVrScrCompositorIterNext(&Iter)) != NULL) + { + bool fTmpChanged = false; + int tmpRc = CrVrScrCompositorEntryListIntersect(pCompositor, pEntry, pList2, &fTmpChanged); + if (RT_SUCCESS(tmpRc)) + { + fChanged |= fTmpChanged; + } + else + { + WARN(("CrVrScrCompositorEntryRegionsIntersect failed, rc %d", tmpRc)); + rc = tmpRc; + } + } + + if (pfChanged) + *pfChanged = fChanged; + + return rc; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsIntersectAll(PVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t cRegions, + PCRTRECT paRegions, bool *pfChanged) +{ + VBOXVR_SCR_COMPOSITOR_ITERATOR Iter; + CrVrScrCompositorIterInit(pCompositor, &Iter); + PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry; + int rc = VINF_SUCCESS; + bool fChanged = false; + + while ((pEntry = CrVrScrCompositorIterNext(&Iter)) != NULL) + { + bool fTmpChanged = false; + int tmpRc = CrVrScrCompositorEntryRegionsIntersect(pCompositor, pEntry, cRegions, paRegions, &fTmpChanged); + if (RT_SUCCESS(tmpRc)) + { + fChanged |= fTmpChanged; + } + else + { + WARN(("CrVrScrCompositorEntryRegionsIntersect failed, rc %d", tmpRc)); + rc = tmpRc; + } + } + + if (pfChanged) + *pfChanged = fChanged; + + return rc; +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryPosSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PCRTPOINT pPos) +{ + int rc = crVrScrCompositorEntryPositionSet(pCompositor, pEntry, pPos, NULL); + if (RT_FAILURE(rc)) + { + WARN(("RegionsSet: crVrScrCompositorEntryPositionSet failed rc %d", rc)); + return rc; + } + + rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL); + if (RT_FAILURE(rc)) + { + WARN(("RegionsSet: crVrScrCompositorEntryEnsureRegionsBounds failed rc %d", rc)); + return rc; + } + + return VINF_SUCCESS; +} + +/* regions are valid until the next CrVrScrCompositor call */ +VBOXVREGDECL(int) CrVrScrCompositorEntryRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, + PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t *pcRegions, + PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions, + PCRTRECT *ppaDstUnstretchedRects) +{ + crDebug("CrVrScrCompositorEntryRegionsGet ENTER, pCompositor(0x%X) StretchX=" FLOAT_FMT_STR ", StretchY=" FLOAT_FMT_STR, + pCompositor, FLOAT_FMT_ARGS(pCompositor->StretchX), FLOAT_FMT_ARGS(pCompositor->StretchY)); + + if (CrVrScrCompositorEntryIsUsed(pEntry)) + { + int rc = crVrScrCompositorRectsCheckInit(pCompositor); + if (RT_FAILURE(rc)) + { + WARN(("crVrScrCompositorRectsCheckInit failed, rc %d", rc)); + return rc; + } + } + + Assert(pCompositor->cRects != VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED); + + *pcRegions = pEntry->cRects; + if (ppaSrcRegions) + *ppaSrcRegions = pEntry->paSrcRects; + if (ppaDstRegions) + *ppaDstRegions = pEntry->paDstRects; + if (ppaDstUnstretchedRects) + *ppaDstUnstretchedRects = pEntry->paDstUnstretchedRects; + + return VINF_SUCCESS; +} + +VBOXVREGDECL(uint32_t) CrVrScrCompositorEntryFlagsCombinedGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, + PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + return CRBLT_FOP_COMBINE(pCompositor->fFlags, pEntry->fFlags); +} + +VBOXVREGDECL(void) CrVrScrCompositorEntryFlagsSet(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, uint32_t fFlags) +{ + if (pEntry->fFlags == fFlags) + return; + + pEntry->fFlags = fFlags; + CrVrScrCompositorEntrySetChanged(pEntry, true); +} + +static void crVrScrCompositorEntryDataCleanup(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + pEntry->cRects = 0; + pEntry->paSrcRects = NULL; + pEntry->paDstRects = NULL; + pEntry->paDstUnstretchedRects = NULL; +} + +static void crVrScrCompositorEntryDataCopy(PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, PVBOXVR_SCR_COMPOSITOR_ENTRY pToEntry) +{ + pToEntry->cRects = pEntry->cRects; + pToEntry->paSrcRects = pEntry->paSrcRects; + pToEntry->paDstRects = pEntry->paDstRects; + pToEntry->paDstUnstretchedRects = pEntry->paDstUnstretchedRects; + crVrScrCompositorEntryDataCleanup(pEntry); +} + +VBOXVREGDECL(int) CrVrScrCompositorEntryRemove(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry) +{ + if (!VBoxVrCompositorEntryRemove(&pCompositor->Compositor, &pEntry->Ce)) + return VINF_SUCCESS; + + CrVrScrCompositorEntrySetChanged(pEntry, true); + crVrScrCompositorEntryDataCleanup(pEntry); + + crVrScrCompositorRectsInvalidate(pCompositor); + return VINF_SUCCESS; +} + +VBOXVREGDECL(bool) CrVrScrCompositorEntryReplace(PVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_SCR_COMPOSITOR_ENTRY pNewEntry) +{ + Assert(!CrVrScrCompositorEntryIsUsed(pNewEntry)); + + if (!VBoxVrCompositorEntryReplace(&pCompositor->Compositor, &pEntry->Ce, &pNewEntry->Ce)) + return false; + + CrVrScrCompositorEntrySetChanged(pEntry, true); + crVrScrCompositorEntryDataCopy(pEntry, pNewEntry); + CrVrScrCompositorEntrySetChanged(pNewEntry, true); + + return true; +} + +static DECLCALLBACK(void) crVrScrCompositorEntryReleasedCB(PCVBOXVR_COMPOSITOR pCompositor, + PVBOXVR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) +{ + PVBOXVR_SCR_COMPOSITOR_ENTRY pCEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pEntry); + + CrVrScrCompositorEntrySetChanged(pCEntry, true); + + Assert(!CrVrScrCompositorEntryIsInList(pCEntry)); + + if (pReplacingEntry) + { + PVBOXVR_SCR_COMPOSITOR_ENTRY pCReplacingEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pReplacingEntry); + Assert(CrVrScrCompositorEntryIsInList(pCReplacingEntry)); + pCReplacingEntry->cRects = pCEntry->cRects; + pCReplacingEntry->paSrcRects = pCEntry->paSrcRects; + pCReplacingEntry->paDstRects = pCEntry->paDstRects; + pCReplacingEntry->paDstUnstretchedRects = pCEntry->paDstUnstretchedRects; + } + + if (pCEntry->pfnEntryReleased) + { + PVBOXVR_SCR_COMPOSITOR_ENTRY pCReplacingEntry = pReplacingEntry + ? VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pReplacingEntry) : NULL; + PVBOXVR_SCR_COMPOSITOR pCConpositor = VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(pCompositor); + pCEntry->pfnEntryReleased(pCConpositor, pCEntry, pCReplacingEntry); + } +} + +VBOXVREGDECL(int) CrVrScrCompositorRectSet(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect, bool *pfChanged) +{ + if (!memcmp(&pCompositor->Rect, pRect, sizeof(pCompositor->Rect))) + { + if (pfChanged) + *pfChanged = false; + return VINF_SUCCESS; + } + + pCompositor->Rect = *pRect; + + VBOXVR_SCR_COMPOSITOR_ITERATOR Iter; + CrVrScrCompositorIterInit(pCompositor, &Iter); + PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry; + while ((pEntry = CrVrScrCompositorIterNext(&Iter)) != NULL) + { + int rc = crVrScrCompositorEntryEnsureRegionsBounds(pCompositor, pEntry, NULL); + if (RT_FAILURE(rc)) + { + WARN(("crVrScrCompositorEntryEnsureRegionsBounds failed, rc %d", rc)); + return rc; + } + } + + return VINF_SUCCESS; +} + +VBOXVREGDECL(void) CrVrScrCompositorInit(PVBOXVR_SCR_COMPOSITOR pCompositor, PCRTRECT pRect) +{ + memset(pCompositor, 0, sizeof(*pCompositor)); + VBoxVrCompositorInit(&pCompositor->Compositor, crVrScrCompositorEntryReleasedCB); + pCompositor->fFlags = CRBLT_F_LINEAR | CRBLT_F_INVERT_YCOORDS; + if (pRect) + pCompositor->Rect = *pRect; +#ifndef IN_RING0 + pCompositor->StretchX = 1.0; + pCompositor->StretchY = 1.0; +#endif +} + +VBOXVREGDECL(void) CrVrScrCompositorRegionsClear(PVBOXVR_SCR_COMPOSITOR pCompositor, bool *pfChanged) +{ + /* set changed flag first, while entries are in the list and we have them */ + CrVrScrCompositorEntrySetAllChanged(pCompositor, true); + VBoxVrCompositorRegionsClear(&pCompositor->Compositor, pfChanged); + crVrScrCompositorRectsInvalidate(pCompositor); +} + +VBOXVREGDECL(void) CrVrScrCompositorClear(PVBOXVR_SCR_COMPOSITOR pCompositor) +{ + CrVrScrCompositorRegionsClear(pCompositor, NULL); + if (pCompositor->paDstRects) + { + RTMemFree(pCompositor->paDstRects); + pCompositor->paDstRects = NULL; + } + if (pCompositor->paSrcRects) + { + RTMemFree(pCompositor->paSrcRects); + pCompositor->paSrcRects = NULL; + } + if (pCompositor->paDstUnstretchedRects) + { + RTMemFree(pCompositor->paDstUnstretchedRects); + pCompositor->paDstUnstretchedRects = NULL; + } + + pCompositor->cRects = 0; + pCompositor->cRectsBuffer = 0; +} + +VBOXVREGDECL(void) CrVrScrCompositorEntrySetAllChanged(PVBOXVR_SCR_COMPOSITOR pCompositor, bool fChanged) +{ + VBOXVR_SCR_COMPOSITOR_ITERATOR CIter; + PVBOXVR_SCR_COMPOSITOR_ENTRY pCurEntry; + CrVrScrCompositorIterInit(pCompositor, &CIter); + + while ((pCurEntry = CrVrScrCompositorIterNext(&CIter)) != NULL) + { + CrVrScrCompositorEntrySetChanged(pCurEntry, fChanged); + } +} + +#ifndef IN_RING0 +VBOXVREGDECL(void) CrVrScrCompositorSetStretching(PVBOXVR_SCR_COMPOSITOR pCompositor, float StretchX, float StretchY) +{ + if (pCompositor->StretchX == StretchX && pCompositor->StretchY == StretchY) + return; + + crDebug("CrVrScrCompositorSetStretching, stretch factors change (" FLOAT_FMT_STR ", " FLOAT_FMT_STR ") => (" FLOAT_FMT_STR ", " FLOAT_FMT_STR ")", + FLOAT_FMT_ARGS(pCompositor->StretchX), FLOAT_FMT_ARGS(pCompositor->StretchY), + FLOAT_FMT_ARGS(StretchX), FLOAT_FMT_ARGS(StretchY)); + + pCompositor->StretchX = StretchX; + pCompositor->StretchY = StretchY; + crVrScrCompositorRectsInvalidate(pCompositor); + CrVrScrCompositorEntrySetAllChanged(pCompositor, true); +} +#endif + +/* regions are valid until the next CrVrScrCompositor call */ +VBOXVREGDECL(int) CrVrScrCompositorRegionsGet(PCVBOXVR_SCR_COMPOSITOR pCompositor, uint32_t *pcRegions, + PCRTRECT *ppaSrcRegions, PCRTRECT *ppaDstRegions, + PCRTRECT *ppaDstUnstretchedRects) +{ + int rc = crVrScrCompositorRectsCheckInit(pCompositor); + if (RT_FAILURE(rc)) + { + WARN(("crVrScrCompositorRectsCheckInit failed, rc %d", rc)); + return rc; + } + + Assert(pCompositor->cRects != VBOXVR_SCR_COMPOSITOR_RECTS_UNDEFINED); + + *pcRegions = pCompositor->cRects; + if (ppaSrcRegions) + *ppaSrcRegions = pCompositor->paSrcRects; + if (ppaDstRegions) + *ppaDstRegions = pCompositor->paDstRects; + if (ppaDstUnstretchedRects) + *ppaDstUnstretchedRects = pCompositor->paDstUnstretchedRects; + + return VINF_SUCCESS; +} + +typedef struct VBOXVR_SCR_COMPOSITOR_VISITOR_CB +{ + PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor; + void *pvVisitor; +} VBOXVR_SCR_COMPOSITOR_VISITOR_CB, *PVBOXVR_SCR_COMPOSITOR_VISITOR_CB; + +static DECLCALLBACK(bool) crVrScrCompositorVisitCb(PVBOXVR_COMPOSITOR pCCompositor, PVBOXVR_COMPOSITOR_ENTRY pCEntry, + void *pvVisitor) +{ + PVBOXVR_SCR_COMPOSITOR_VISITOR_CB pData = (PVBOXVR_SCR_COMPOSITOR_VISITOR_CB)pvVisitor; + PVBOXVR_SCR_COMPOSITOR pCompositor = VBOXVR_SCR_COMPOSITOR_FROM_COMPOSITOR(pCCompositor); + PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry = VBOXVR_SCR_COMPOSITOR_ENTRY_FROM_ENTRY(pCEntry); + return pData->pfnVisitor(pCompositor, pEntry, pData->pvVisitor); +} + +VBOXVREGDECL(void) CrVrScrCompositorVisit(PVBOXVR_SCR_COMPOSITOR pCompositor, PFNVBOXVRSCRCOMPOSITOR_VISITOR pfnVisitor, + void *pvVisitor) +{ + VBOXVR_SCR_COMPOSITOR_VISITOR_CB Data; + Data.pfnVisitor = pfnVisitor; + Data.pvVisitor = pvVisitor; + VBoxVrCompositorVisit(&pCompositor->Compositor, crVrScrCompositorVisitCb, &Data); +} + +VBOXVREGDECL(int) CrVrScrCompositorClone(PCVBOXVR_SCR_COMPOSITOR pCompositor, PVBOXVR_SCR_COMPOSITOR pDstCompositor, + PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor) +{ + /* for simplicity just copy from one to another */ + CrVrScrCompositorInit(pDstCompositor, CrVrScrCompositorRectGet(pCompositor)); + VBOXVR_SCR_COMPOSITOR_CONST_ITERATOR CIter; + PCVBOXVR_SCR_COMPOSITOR_ENTRY pEntry; + CrVrScrCompositorConstIterInit(pCompositor, &CIter); + int rc = VINF_SUCCESS; + uint32_t cRects; + PCRTRECT paRects; + + while ((pEntry = CrVrScrCompositorConstIterNext(&CIter)) != NULL) + { + /* get source rects, that will be non-stretched and entry pos - pased */ + rc = CrVrScrCompositorEntryRegionsGet(pCompositor, pEntry, &cRects, NULL, NULL, &paRects); + if (RT_FAILURE(rc)) + { + WARN(("CrVrScrCompositorEntryRegionsGet failed, rc %d", rc)); + return rc; + } + + PVBOXVR_SCR_COMPOSITOR_ENTRY pDstEntry = pfnEntryFor(pEntry, pvEntryFor); + if (!pDstEntry) + { + WARN(("pfnEntryFor failed")); + return VERR_INVALID_STATE; + } + + rc = CrVrScrCompositorEntryRegionsSet(pDstCompositor, pDstEntry, NULL, cRects, paRects, false, NULL); + if (RT_FAILURE(rc)) + { + WARN(("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc)); + return rc; + } + } + + return rc; +} + +VBOXVREGDECL(int) CrVrScrCompositorIntersectList(PVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr, bool *pfChanged) +{ + VBOXVR_SCR_COMPOSITOR_ITERATOR CIter; + PVBOXVR_SCR_COMPOSITOR_ENTRY pEntry; + CrVrScrCompositorIterInit(pCompositor, &CIter); + int rc = VINF_SUCCESS; + bool fChanged = false; + + while ((pEntry = CrVrScrCompositorIterNext(&CIter)) != NULL) + { + bool fCurChanged = false; + + rc = CrVrScrCompositorEntryListIntersect(pCompositor, pEntry, pVr, &fCurChanged); + if (RT_FAILURE(rc)) + { + WARN(("CrVrScrCompositorEntryRegionsSet failed, rc %d", rc)); + break; + } + + fChanged |= fCurChanged; + } + + if (pfChanged) + *pfChanged = fChanged; + + return rc; +} + +VBOXVREGDECL(int) CrVrScrCompositorIntersectedList(PCVBOXVR_SCR_COMPOSITOR pCompositor, PCVBOXVR_LIST pVr, + PVBOXVR_SCR_COMPOSITOR pDstCompositor, + PFNVBOXVR_SCR_COMPOSITOR_ENTRY_FOR pfnEntryFor, void *pvEntryFor, + bool *pfChanged) +{ + int rc = CrVrScrCompositorClone(pCompositor, pDstCompositor, pfnEntryFor, pvEntryFor); + if (RT_FAILURE(rc)) + { + WARN(("CrVrScrCompositorClone failed, rc %d", rc)); + return rc; + } + + rc = CrVrScrCompositorIntersectList(pDstCompositor, pVr, pfChanged); + if (RT_FAILURE(rc)) + { + WARN(("CrVrScrCompositorIntersectList failed, rc %d", rc)); + CrVrScrCompositorClear(pDstCompositor); + return rc; + } + + return VINF_SUCCESS; +} + diff --git a/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py b/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py new file mode 100755 index 00000000..cf07424a --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/debug_opcodes.py @@ -0,0 +1,42 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +from __future__ import print_function +import sys; +import string; +import re; + +import apiutil + +apiutil.CopyrightC() + +print(""" +#include "cr_debugopcodes.h" +#include +""") + +print("""void crDebugOpcodes( FILE *fp, unsigned char *ptr, unsigned int num_opcodes ) +{ +\tunsigned int i; +\tfor (i = 0; i < num_opcodes; i++) +\t{ +\t\tswitch(*(ptr--)) +\t\t{ +""") + +keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt") +keys.sort() + +for func_name in keys: + if "pack" in apiutil.ChromiumProps(func_name): + print('\t\tcase %s:' % apiutil.OpcodeName( func_name )) + print('\t\t\tfprintf(fp, "%s\\n"); ' % apiutil.OpcodeName( func_name )) + print( '\t\t\tbreak;') + +print(""" +\t\t} +\t} +} +""") diff --git a/src/VBox/GuestHost/OpenGL/util/devnull.c b/src/VBox/GuestHost/OpenGL/util/devnull.c new file mode 100644 index 00000000..9e7d9618 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/devnull.c @@ -0,0 +1,118 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_net.h" +#include "cr_mem.h" +#include "cr_error.h" +#include "net_internals.h" + +static void +crDevnullWriteExact( CRConnection *conn, const void *buf, unsigned int len ) +{ + (void) conn; + (void) buf; + (void) len; +} + +static void * +crDevnullAlloc( CRConnection *conn ) +{ + return crAlloc( conn->buffer_size ); +} + +static void +crDevnullSingleRecv( CRConnection *conn, void *buf, unsigned int len ) +{ + crError( "You can't receive data on a devnull connection!" ); + (void) conn; + (void) buf; + (void) len; +} + +static void +crDevnullFree( CRConnection *conn, void *buf ) +{ + crFree( buf ); + (void) conn; +} + +static void +crDevnullSend( CRConnection *conn, void **bufp, + const void *start, unsigned int len ) +{ + + if (bufp) + { + /* We're sending something we've allocated. It's now ours. + * If the callers wants to send something else, he'll allocate + * something else. + * + * ENFORCE IT! */ + + crDevnullFree( conn, *bufp ); + } + (void) conn; + (void) bufp; + (void) start; + (void) len; +} + +int +crDevnullRecv( void ) +{ + crError( "You can't receive data on a DevNull network, stupid." ); + return 0; +} + +void +crDevnullInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ) +{ + (void) rfl; + (void) cfl; + (void) mtu; +} + +static void +crDevnullAccept( CRConnection *conn, const char *hostname, unsigned short port ) +{ + crError( "Well, you *could* accept a devnull client, but you'd be disappointed. "); + (void) conn; + (void) port; + (void) hostname; +} + +static int +crDevnullDoConnect( CRConnection *conn ) +{ + (void) conn; + return 1; +} + +static void +crDevnullDoDisconnect( CRConnection *conn ) +{ + (void) conn; +} + +void crDevnullConnection( CRConnection *conn ) +{ + conn->type = CR_DROP_PACKETS; + conn->Alloc = crDevnullAlloc; + conn->Send = crDevnullSend; + conn->SendExact = crDevnullWriteExact; + conn->Recv = crDevnullSingleRecv; + conn->Free = crDevnullFree; + conn->Accept = crDevnullAccept; + conn->Connect = crDevnullDoConnect; + conn->Disconnect = crDevnullDoDisconnect; + conn->actual_network = 0; +} + +CRConnection** crDevnullDump( int * num ) +{ + *num = 0; + return NULL; +} diff --git a/src/VBox/GuestHost/OpenGL/util/dll.c b/src/VBox/GuestHost/OpenGL/util/dll.c new file mode 100644 index 00000000..b76c1558 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/dll.c @@ -0,0 +1,411 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "cr_error.h" +#include "cr_dll.h" +#include "cr_string.h" +#include "stdio.h" + +#ifndef IN_GUEST +#include +#endif + +#if defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(DARWIN) || defined(SunOS) || defined(OSF1) +# include +# include +# include +# include +#include +#endif + +#ifdef WINDOWS +# ifdef VBOX +# include +# else +#include +# endif +#endif + +#ifdef DARWIN + +#include +#include + +char *__frameworkErr=NULL; + +CFBundleRef LoadFramework( const char *frameworkName ) { + CFBundleRef bundle; + CFURLRef bundleURL; + char fullfile[8096]; + + if( frameworkName[0] != '/' ) { + /* load a system framework */ + /* XXX \todo should this folder be retrieved from somewhere else? */ + crStrcpy( fullfile, "/System/Library/Frameworks/" ); + crStrcat( fullfile, frameworkName ); + } else { + /* load any framework */ + crStrcpy( fullfile, frameworkName ); + } + + bundleURL = CFURLCreateWithString( NULL, CFStringCreateWithCStringNoCopy(NULL, fullfile, CFStringGetSystemEncoding(), NULL), NULL ); + if( !bundleURL ) { + __frameworkErr = "Could not create OpenGL Framework bundle URL"; + return NULL; + } + + bundle = CFBundleCreate( kCFAllocatorDefault, bundleURL ); + CFRelease( bundleURL ); + + if( !bundle ) { + __frameworkErr = "Could not create OpenGL Framework bundle"; + return NULL; + } + + if( !CFBundleLoadExecutable(bundle) ) { + __frameworkErr = "Could not load MachO executable"; + return NULL; + } + + return bundle; +} + +char *__bundleErr=NULL; + +void *LoadBundle( const char *filename ) { + NSObjectFileImage fileImage; + NSModule handle = NULL; + char _filename[PATH_MAX]; + + __bundleErr = NULL; + + if( filename[0] != '/' ) { + /* default to a chromium bundle */ + crStrcpy( _filename, "/cr/lib/Darwin/" ); + crStrcat( _filename, filename ); + } else { + crStrcpy( _filename, filename ); + } + + switch( NSCreateObjectFileImageFromFile(_filename, &fileImage) ) { + default: + case NSObjectFileImageFailure: + __bundleErr = "NSObjectFileImageFailure: Failure."; + break; + + case NSObjectFileImageInappropriateFile: + __bundleErr = "NSObjectFileImageInappropriateFile: The specified file is not of a valid type."; + break; + + case NSObjectFileImageArch: + __bundleErr = "NSObjectFileImageArch: The specified file is for a different CPU architecture."; + break; + + case NSObjectFileImageFormat: + __bundleErr = "NSObjectFileImageFormat: The specified file does not appear to be a Mach-O file"; + break; + + case NSObjectFileImageAccess: + __bundleErr = "NSObjectFileImageAccess: Permission to create image denied."; + break; + + case NSObjectFileImageSuccess: + handle = NSLinkModule( fileImage, _filename, + NSLINKMODULE_OPTION_RETURN_ON_ERROR | + NSLINKMODULE_OPTION_PRIVATE ); + NSDestroyObjectFileImage( fileImage ); + if( !handle ) { + NSLinkEditErrors c; + int n; + const char *name; + NSLinkEditError(&c, &n, &name, (const char**)&__bundleErr); + } + break; + } + + return handle; +} + +int check_extension( const char *name, const char *extension ) { + int nam_len = crStrlen( name ); + int ext_len = crStrlen( extension ); + char *pos = crStrstr( name, extension ); + return ( pos == &(name[nam_len-ext_len]) ); +} + +enum { + CR_DLL_NONE, + CR_DLL_FRAMEWORK, + CR_DLL_DYLIB, + CR_DLL_BUNDLE, + CR_DLL_UNKNOWN +}; + +#define NS_ADD 0 + +int get_dll_type( const char *name ) { + if( check_extension(name, ".framework") ) + return CR_DLL_FRAMEWORK; + if( check_extension(name, ".bundle") ) + return CR_DLL_BUNDLE; + if( check_extension(name, ".dylib") ) + return CR_DLL_DYLIB; + return CR_DLL_DYLIB; +} + +#endif + +/* + * Open the named shared library. + * If resolveGlobal is non-zero, unresolved symbols can be satisfied by + * any matching symbol already defined globally. Otherwise, if resolveGlobal + * is zero, unresolved symbols should be resolved using symbols in that + * object (in preference to global symbols). + * NOTE: this came about because we found that for libGL, we need the + * global-resolve option but for SPU's we need the non-global option (consider + * the state tracker duplicated in the array, tilesort, etc. SPUs). + */ +CRDLL *crDLLOpen( const char *dllname, int resolveGlobal ) +{ + CRDLL *dll; + char *dll_err; +#if defined(WINDOWS) + WCHAR szwPath[MAX_PATH]; + UINT cwcPath = 0; + + (void) resolveGlobal; + +# ifndef CR_NO_GL_SYSTEM_PATH + if (PathIsRelative(dllname)) + { + size_t cName = strlen(dllname) + 1; +# ifdef IN_GUEST + cwcPath = GetSystemDirectoryW(szwPath, RT_ELEMENTS(szwPath)); + if (!cwcPath || cwcPath >= MAX_PATH) + { + DWORD winEr = GetLastError(); + crError("GetSystemDirectoryW failed err %d", winEr); + SetLastError(winEr); + return NULL; + } +# else + WCHAR * pszwSlashFile; + cwcPath = GetModuleFileNameW(NULL, szwPath, RT_ELEMENTS(szwPath)); + if (!cwcPath || cwcPath >= MAX_PATH) + { + DWORD winEr = GetLastError(); + crError("GetModuleFileNameW failed err %d", winEr); + SetLastError(winEr); + return NULL; + } + + pszwSlashFile = wcsrchr(szwPath, L'\\'); + if (!pszwSlashFile) + { + crError("failed to match file name"); + SetLastError(ERROR_PATH_NOT_FOUND); + return NULL; + } + + cwcPath = pszwSlashFile - szwPath; +# endif + + if (cwcPath + 1 + cName > MAX_PATH) + { + crError("invalid path specified"); + SetLastError(ERROR_FILENAME_EXCED_RANGE); + return NULL; + } + szwPath[cwcPath] = '\\'; + ++cwcPath; + } +# endif /* CR_NO_GL_SYSTEM_PATH */ + if (!MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, dllname, -1, &szwPath[cwcPath], MAX_PATH - cwcPath)) + { + DWORD winEr = GetLastError(); + crError("MultiByteToWideChar failed err %d", winEr); + SetLastError(winEr); + return NULL; + } +#endif + + dll = (CRDLL *) crAlloc( sizeof( CRDLL ) ); + dll->name = crStrdup( dllname ); + +#if defined(WINDOWS) + dll->hinstLib = LoadLibraryW( szwPath ); + if (!dll->hinstLib) + { + crError("failed to load dll %s", dllname); + } + dll_err = NULL; +#elif defined(DARWIN) + /* XXX \todo Get better error handling in here */ + dll->type = get_dll_type( dllname ); + dll_err = NULL; + + switch( dll->type ) { + case CR_DLL_FRAMEWORK: + dll->hinstLib = LoadFramework( dllname ); + dll_err = __frameworkErr; + break; + + case CR_DLL_BUNDLE: + dll->hinstLib = LoadBundle( dllname ); + dll_err = __bundleErr; + break; + + case CR_DLL_DYLIB: +#if NS_ADD + dll->hinstLib = (void*)NSAddImage( dllname, NSADDIMAGE_OPTION_RETURN_ON_ERROR ); +#else + if( resolveGlobal ) + dll->hinstLib = dlopen( dllname, RTLD_LAZY | RTLD_GLOBAL ); + else + dll->hinstLib = dlopen( dllname, RTLD_LAZY | RTLD_LOCAL ); + dll_err = (char*) dlerror(); +#endif + break; + + default: + dll->hinstLib = NULL; + dll_err = "Unknown DLL type"; + break; + }; +#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) + { + int flags = RTLD_LAZY; + if (resolveGlobal) + flags |= RTLD_GLOBAL; + dll->hinstLib = dlopen( dllname, flags ); +# ifndef IN_GUEST + /* GCC address sanitiser breaks DT_RPATH. */ + if (!dll->hinstLib) do { + char szPath[RTPATH_MAX]; + int rc = RTPathSharedLibs(szPath, sizeof(szPath)); + AssertLogRelMsgRCBreak(rc, ("RTPathSharedLibs() failed: %Rrc\n", rc)); + rc = RTPathAppend(szPath, sizeof(szPath), dllname); + AssertLogRelMsgRCBreak(rc, ("RTPathAppend() failed: %Rrc\n", rc)); + dll->hinstLib = dlopen( szPath, flags ); + } while(0); +# endif + dll_err = (char*) dlerror(); + } +#else +#error DSO +#endif + + if (!dll->hinstLib) + { + if (dll_err) + { + crDebug( "DLL_ERROR(%s): %s", dllname, dll_err ); + } + crError( "DLL Loader couldn't find/open %s", dllname ); + crFree(dll); + dll = NULL; + } + return dll; +} + +CRDLLFunc crDLLGetNoError( CRDLL *dll, const char *symname ) +{ +#if defined(WINDOWS) + return (CRDLLFunc) GetProcAddress( dll->hinstLib, symname ); +#elif defined(DARWIN) + NSSymbol nssym; + + if( dll->type == CR_DLL_FRAMEWORK ) + return (CRDLLFunc) CFBundleGetFunctionPointerForName( (CFBundleRef) dll->hinstLib, CFStringCreateWithCStringNoCopy(NULL, symname, CFStringGetSystemEncoding(), NULL) ); + + if( dll->type == CR_DLL_DYLIB ) +#if NS_ADD + nssym = NSLookupSymbolInImage( dll->hinstLib, symname, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR ); +#else + return (CRDLLFunc) dlsym( dll->hinstLib, symname ); +#endif + else + nssym = NSLookupSymbolInModule( dll->hinstLib, symname ); + + if( !nssym ) { + char name[PATH_MAX]; + crStrcpy( name, "_" ); + crStrcat( name, symname ); + + if( dll->type == CR_DLL_DYLIB ) + nssym = NSLookupSymbolInImage( dll->hinstLib, name, NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR ); + else + nssym = NSLookupSymbolInModule( dll->hinstLib, name ); + } + + return (CRDLLFunc) NSAddressOfSymbol( nssym ); + +#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) + return (CRDLLFunc)(uintptr_t)dlsym( dll->hinstLib, symname ); +#else +#error CR DLL ARCHITETECTURE +#endif +} + +CRDLLFunc crDLLGet( CRDLL *dll, const char *symname ) +{ + CRDLLFunc data = crDLLGetNoError( dll, symname ); + if (!data) + { + /* Are you sure there isn't some C++ mangling messing you up? */ + crWarning( "Couldn't get symbol \"%s\" in \"%s\"", symname, dll->name ); + } + return data; +} + +void crDLLClose( CRDLL *dll ) +{ + int dll_err = 0; + + if (!dll) return; + +#if defined(WINDOWS) + FreeLibrary( dll->hinstLib ); +#elif defined(DARWIN) + switch( dll->type ) { + case CR_DLL_FRAMEWORK: + CFBundleUnloadExecutable( dll->hinstLib ); + CFRelease(dll->hinstLib); + dll->hinstLib = NULL; + break; + + case CR_DLL_DYLIB: +#if !NS_ADD + dlclose( dll->hinstLib ); +#endif + break; + + case CR_DLL_BUNDLE: + NSUnLinkModule( (NSModule) dll->hinstLib, 0L ); + break; + } +#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) + /* + * Unloading Nvidia's libGL will crash VirtualBox later during shutdown. + * Therefore we will skip unloading it. It will be unloaded later anway + * because we are already freeing all resources and VirtualBox will terminate + * soon. + */ +#ifndef IN_GUEST + if (strncmp(dll->name, "libGL", 5)) +#endif + dll_err = dlclose( dll->hinstLib ); +#else +#error DSO +#endif + + if (dll_err) + crWarning("Error closing DLL %s\n",dll->name); + + crFree( dll->name ); + crFree( dll ); +} diff --git a/src/VBox/GuestHost/OpenGL/util/endian.c b/src/VBox/GuestHost/OpenGL/util/endian.c new file mode 100644 index 00000000..55b342cc --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/endian.c @@ -0,0 +1,39 @@ +#include "chromium.h" +#include "cr_endian.h" + +char crDetermineEndianness( void ) +{ + union { + struct { + char c1; + char c2; + char c3; + char c4; + } c; + unsigned int i; + } e_test; + + e_test.c.c1 = 1; + e_test.c.c2 = 2; + e_test.c.c3 = 3; + e_test.c.c4 = 4; + + if (e_test.i == 0x01020304) + { + return CR_BIG_ENDIAN; + } + return CR_LITTLE_ENDIAN; +} + +double SWAPDOUBLE( double d ) +{ + CR64BitType *ptr = (CR64BitType *) (&d); +#ifdef __STDC__ + CR64BitType swapped; + SWAP64( *ptr ); + swapped = *ptr; +#else + CR64BitType swapped = SWAP64( *ptr ); +#endif + return *((double *) (&swapped)); +} diff --git a/src/VBox/GuestHost/OpenGL/util/environment.c b/src/VBox/GuestHost/OpenGL/util/environment.c new file mode 100644 index 00000000..82fd619e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/environment.c @@ -0,0 +1,34 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_environment.h" +#include "cr_string.h" +#include "cr_mem.h" +#include +#include + +void crSetenv( const char *var, const char *value ) +{ +#if defined(LINUX) || defined(FREEBSD) || defined(DARWIN) + setenv( var, value, 1 /* replace */ ); +#else + unsigned long len; + char *buf; + + len = crStrlen(var) + 1 + crStrlen(value) + 1; + buf = (char *) crAlloc( len ); + sprintf( buf, "%s=%s", var, value ); + putenv( buf ); + + /* don't free the buf, the string is *part* of the environment, + * and can't be reclaimed */ +#endif +} + +const char *crGetenv( const char *var ) +{ + return getenv( var ); +} diff --git a/src/VBox/GuestHost/OpenGL/util/error.c b/src/VBox/GuestHost/OpenGL/util/error.c new file mode 100644 index 00000000..00ade546 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/error.c @@ -0,0 +1,219 @@ +/* $Id: error.c $ */ +/** @file + * VBox crOpenGL error logging + */ + +/* + * Copyright (C) 2014-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#define LOG_GROUP LOG_GROUP_SHARED_CROPENGL + +#include +#include +#include +#include +#include +#include + +#include + +#ifdef RT_OS_WINDOWS +# include +# include "cr_environment.h" +# include "cr_error.h" +# include "VBox/VBoxGuestLib.h" +# include "iprt/initterm.h" +#else +# include "cr_error.h" +#endif + +#include +#include + + +/* + * Stuff that needs to be dragged into the link because other DLLs needs it. + * See also VBoxDeps.cpp in iprt and xpcom. + */ +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4232) /* nonstandard extension used: 'g_VBoxRTDeps' : address of dllimport 'RTBldCfgRevision' is not static, identiy not guaranteed */ +#endif +PFNRT g_VBoxRTDeps[] = +{ + (PFNRT)RTAssertShouldPanic, + (PFNRT)ASMAtomicReadU64, + (PFNRT)ASMAtomicCmpXchgU64, + (PFNRT)ASMBitFirstSet, + (PFNRT)RTBldCfgRevision, +}; +#ifdef _MSC_VER +# pragma warning(pop) +#endif + + +static void logMessageV(const char *pszPrefix, const char *pszFormat, va_list va) +{ + va_list vaCopy; + if (RTR3InitIsInitialized()) + { + va_copy(vaCopy, va); + LogRel(("%s%N\n", pszPrefix, pszFormat, &vaCopy)); + va_end(vaCopy); + } + +#ifdef IN_GUEST /** @todo Could be subject to pre-iprt-init issues, but hopefully not... */ + va_copy(vaCopy, va); + RTStrmPrintf(g_pStdErr, "%s%N\n", pszPrefix, pszFormat, &vaCopy); + va_end(vaCopy); +#endif +} + +#ifdef WINDOWS +static void logMessage(const char *pszPrefix, const char *pszFormat, ...) +{ + va_list va; + + va_start(va, pszFormat); + logMessageV(pszPrefix, pszFormat, va); + va_end(va); +} +#endif + +DECLEXPORT(void) crError(const char *pszFormat, ...) +{ + va_list va; +#ifdef WINDOWS + DWORD dwLastErr; +#endif + +#ifdef WINDOWS + /* Log last error on windows. */ + dwLastErr = GetLastError(); + if (dwLastErr != 0 && crGetenv("CR_WINDOWS_ERRORS") != NULL) + { + LPTSTR pszWindowsMessage; + + SetLastError(0); + FormatMessageA( FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_FROM_SYSTEM + | FORMAT_MESSAGE_MAX_WIDTH_MASK, + NULL, dwLastErr, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR)&pszWindowsMessage, 0, NULL); + if (pszWindowsMessage) + { + logMessage("OpenGL, Windows error: ", "%u\n%s", dwLastErr, pszWindowsMessage); + LocalFree(pszWindowsMessage); + } + else + logMessage("OpenGL, Windows error: ", "%u", dwLastErr); + } +#endif + + /* The message. */ + va_start(va, pszFormat); + logMessageV("OpenGL Error: ", pszFormat, va); + va_end(va); + +#ifdef DEBUG + /* Let's interrupt App execution only on debug builds and return + * bad status to upper level on release ones. */ +# ifdef IN_GUEST + /* Trigger debugger's breakpoint handler. */ + ASMBreakpoint(); +# else + /* Dump core or activate the debugger in debug builds. */ + AssertFailed(); +# endif +#endif /* DEBUG */ +} + +DECLEXPORT(void) crWarning(const char *pszFormat, ...) +{ + if (RTR3InitIsInitialized()) + { + va_list va; + + va_start(va, pszFormat); + logMessageV("OpenGL Warning: ", pszFormat, va); + va_end(va); + } +} + +DECLEXPORT(void) crInfo(const char *pszFormat, ...) +{ + if (RTR3InitIsInitialized()) + { + va_list va; + + va_start(va, pszFormat); + logMessageV("OpenGL Info: ", pszFormat, va); + va_end(va); + } +} + +DECLEXPORT(void) crDebug(const char *pszFormat, ...) +{ + if (RTR3InitIsInitialized()) + { + va_list va; + + va_start(va, pszFormat); +#if defined(DEBUG_vgalitsy) || defined(DEBUG_galitsyn) + LogRel(("OpenGL Debug: %N\n", pszFormat, &va)); +#else + Log(("OpenGL Debug: %N\n", pszFormat, &va)); +#endif + va_end(va); + } +} + +#if defined(RT_OS_WINDOWS) +BOOL WINAPI DllMain(HINSTANCE hDLLInst, DWORD fdwReason, LPVOID lpvReserved) +{ + (void) lpvReserved; (void) hDLLInst; + + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + { + int rc; + rc = RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); CRASSERT(rc==0); +# ifdef IN_GUEST + rc = VbglR3Init(); +# endif + LogRel(("crUtil DLL loaded.\n")); +# if defined(DEBUG_misha) + char aName[MAX_PATH]; + GetModuleFileNameA(hDLLInst, aName, RT_ELEMENTS(aName)); + crDbgCmdSymLoadPrint(aName, hDLLInst); +# endif + break; + } + + case DLL_PROCESS_DETACH: + { + LogRel(("crUtil DLL unloaded.")); +# ifdef IN_GUEST + VbglR3Term(); +# endif + } + + default: + break; + } + + return TRUE; +} +#endif + diff --git a/src/VBox/GuestHost/OpenGL/util/filenet.c b/src/VBox/GuestHost/OpenGL/util/filenet.c new file mode 100644 index 00000000..178c015e --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/filenet.c @@ -0,0 +1,385 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include +#include +#include +#ifdef WINDOWS +#include +#else +#include +#endif + + +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_bufpool.h" +#include "cr_net.h" +#include "cr_endian.h" +#include "cr_threads.h" +#include "net_internals.h" + +typedef enum { + CRFileMemory, + CRFileMemoryBig +} CRFileBufferKind; + +#define CR_FILE_BUFFER_MAGIC 0x89134539 + +#ifndef WINDOWS +#define O_BINARY 0 +#endif + +typedef struct CRFileBuffer { + unsigned int magic; + CRFileBufferKind kind; + unsigned int len; + unsigned int allocated; + unsigned int pad; +} CRFileBuffer; + +static struct { + int initialized; + int num_conns; + CRConnection **conns; + CRBufferPool *bufpool; +#ifdef CHROMIUM_THREADSAFE + CRmutex mutex; +#endif + CRNetReceiveFuncList *recv_list; + CRNetCloseFuncList *close_list; +} cr_file; + +static void +crFileReadExact( CRConnection *conn, void *buf, unsigned int len ) +{ + char *dst = (char *) buf; + + while ( len > 0 ) + { + int num_read = read( conn->fd, buf, len ); + + if ( num_read < 0 ) + { + crError( "Bad bad bad file error!" ); + } + if (num_read == 0) + { + crError( "END OF FILE!" ); + } + + dst += num_read; + len -= num_read; + } +} + +static void +crFileWriteExact( CRConnection *conn, const void *buf, unsigned int len ) +{ + int retval = write( conn->fd, buf, len ); + if ( retval < (int) len ) + { + crError( "crFileWriteExact: %s (tried to write %d bytes, actually wrote %d)", conn->filename, len, retval ); + } +} + +static void +crFileAccept( CRConnection *conn, const char *hostname, unsigned short port ) +{ + (void)hostname; + conn->file_direction = CR_FILE_READ; + conn->fd = open( conn->filename, O_RDONLY | O_BINARY ); + if (conn->fd < 0) + { + crError( "Couldn't open %s for reading!", conn->filename ); + } + (void) port; +} + +static void +*crFileAlloc( CRConnection *conn ) +{ + CRFileBuffer *buf; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_file.mutex); +#endif + + buf = (CRFileBuffer *) crBufferPoolPop( cr_file.bufpool, conn->buffer_size ); + + if ( buf == NULL ) + { + crDebug( "Buffer pool was empty, so I allocated %d bytes", + (int)(sizeof(CRFileBuffer) + conn->buffer_size) ); + buf = (CRFileBuffer *) + crAlloc( sizeof(CRFileBuffer) + conn->buffer_size ); + buf->magic = CR_FILE_BUFFER_MAGIC; + buf->kind = CRFileMemory; + buf->pad = 0; + buf->allocated = conn->buffer_size; + } + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_file.mutex); +#endif + + return (void *)( buf + 1 ); +} + +static void +crFileSingleRecv( CRConnection *conn, void *buf, unsigned int len ) +{ + crFileReadExact( conn, buf, len ); +} + +static void +crFileSend( CRConnection *conn, void **bufp, const void *start, unsigned int len ) +{ + CRFileBuffer *file_buffer; + unsigned int *lenp; + + if ( bufp == NULL ) + { + /* we are doing synchronous sends from user memory, so no need + * to get fancy. Simply write the length & the payload and + * return. */ + if (conn->swap) + { + len = SWAP32(len); + } + crFileWriteExact( conn, &len, sizeof(len) ); + crFileWriteExact( conn, start, len ); + return; + } + + file_buffer = (CRFileBuffer *)(*bufp) - 1; + + CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC ); + + /* All of the buffers passed to the send function were allocated + * with crFileAlloc(), which includes a header with a 4 byte + * length field, to insure that we always have a place to write + * the length field, even when start == *bufp. */ + lenp = (unsigned int *) start - 1; + *lenp = len; + + crFileWriteExact(conn, lenp, len + sizeof(int) ); + + /* reclaim this pointer for reuse and try to keep the client from + accidentally reusing it directly */ +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_file.mutex); +#endif + crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size ); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_file.mutex); +#endif + *bufp = NULL; +} + +static void +crFileFree( CRConnection *conn, void *buf ) +{ + CRFileBuffer *file_buffer = (CRFileBuffer *) buf - 1; + + CRASSERT( file_buffer->magic == CR_FILE_BUFFER_MAGIC ); + conn->recv_credits += file_buffer->len; + + switch ( file_buffer->kind ) + { + case CRFileMemory: +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_file.mutex); +#endif + crBufferPoolPush( cr_file.bufpool, file_buffer, conn->buffer_size ); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_file.mutex); +#endif + break; + + case CRFileMemoryBig: + crFree( file_buffer ); + break; + + default: + crError( "Weird buffer kind trying to free in crFileFree: %d", file_buffer->kind ); + } +} + +int +crFileRecv( void ) +{ + CRMessage *msg; + int i; + + if (!cr_file.num_conns) + { + return 0; + } + for ( i = 0; i < cr_file.num_conns; i++ ) + { + CRFileBuffer *file_buffer; + unsigned int len; + CRConnection *conn = cr_file.conns[i]; + + crFileReadExact( conn, &len, sizeof( len ) ); + + CRASSERT( len > 0 ); + + if ( len <= conn->buffer_size ) + { + file_buffer = (CRFileBuffer *) crFileAlloc( conn ) - 1; + } + else + { + file_buffer = (CRFileBuffer *) + crAlloc( sizeof(*file_buffer) + len ); + file_buffer->magic = CR_FILE_BUFFER_MAGIC; + file_buffer->kind = CRFileMemoryBig; + file_buffer->pad = 0; + } + + file_buffer->len = len; + + crFileReadExact( conn, file_buffer + 1, len ); + + conn->recv_credits -= len; + + msg = (CRMessage *) (file_buffer + 1); + crNetDispatchMessage( cr_file.recv_list, conn, msg, len ); + + /* CR_MESSAGE_OPCODES is freed in + * crserverlib/server_stream.c + * + * OOB messages are the programmer's problem. -- Humper 12/17/01 */ + if (msg->header.type != CR_MESSAGE_OPCODES && msg->header.type != CR_MESSAGE_OOB) + { + crFileFree( conn, file_buffer + 1 ); + } + } + + return 1; +} + +static void +crFileHandleNewMessage( CRConnection *conn, CRMessage *msg, + unsigned int len ) +{ + CRFileBuffer *buf = ((CRFileBuffer *) msg) - 1; + + /* build a header so we can delete the message later */ + buf->magic = CR_FILE_BUFFER_MAGIC; + buf->kind = CRFileMemory; + buf->len = len; + buf->pad = 0; + + crNetDispatchMessage( cr_file.recv_list, conn, msg, len ); +} + +static void +crFileInstantReclaim( CRConnection *conn, CRMessage *mess ) +{ + crFileFree( conn, mess ); +} + +void +crFileInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ) +{ + (void) mtu; + + cr_file.recv_list = rfl; + cr_file.close_list = cfl; + + if (cr_file.initialized) + { + return; + } + + cr_file.num_conns = 0; + cr_file.conns = NULL; + +#ifdef CHROMIUM_THREADSAFE + crInitMutex(&cr_file.mutex); +#endif + cr_file.bufpool = crBufferPoolInit(16); + + + cr_file.initialized = 1; +} + +static int +crFileDoConnect( CRConnection *conn ) +{ + conn->file_direction = CR_FILE_WRITE; + /* NOTE: the third parameter (file permissions) is only used/required when + * we specify O_CREAT as part of the flags. The permissions will be + * masked according to the effective user's umask setting. + */ +#ifdef WINDOWS + conn->fd = open( conn->filename, O_CREAT | O_WRONLY | O_BINARY | + S_IREAD | S_IWRITE); +#else + conn->fd = open( conn->filename, O_CREAT | O_WRONLY | O_BINARY, + S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); +#endif + if (conn->fd < 0) + { + crWarning( "Couldn't open %s for writing!", conn->filename ); + return 0; + } + return 1; +} + +static void +crFileDoDisconnect( CRConnection *conn ) +{ + close( conn->fd ); + conn->type = CR_NO_CONNECTION; + crMemcpy( cr_file.conns + conn->index, cr_file.conns + conn->index+1, + (cr_file.num_conns - conn->index - 1)*sizeof(*(cr_file.conns)) ); + cr_file.num_conns--; +} + +void +crFileConnection( CRConnection *conn ) +{ + int n_bytes; + + CRASSERT( cr_file.initialized ); + + conn->type = CR_FILE; + conn->Alloc = crFileAlloc; + conn->Send = crFileSend; + conn->SendExact = crFileWriteExact; + conn->Recv = crFileSingleRecv; + conn->Free = crFileFree; + conn->Accept = crFileAccept; + conn->Connect = crFileDoConnect; + conn->Disconnect = crFileDoDisconnect; + conn->InstantReclaim = crFileInstantReclaim; + conn->HandleNewMessage = crFileHandleNewMessage; + conn->index = cr_file.num_conns; + conn->sizeof_buffer_header = sizeof( CRFileBuffer ); + conn->actual_network = 0; + + conn->filename = crStrdup( conn->hostname ); + + n_bytes = ( cr_file.num_conns + 1 ) * sizeof(*cr_file.conns); + crRealloc( (void **) &cr_file.conns, n_bytes ); + + cr_file.conns[cr_file.num_conns++] = conn; +} + +CRConnection** +crFileDump( int* num ) +{ + *num = cr_file.num_conns; + + return cr_file.conns; +} + diff --git a/src/VBox/GuestHost/OpenGL/util/hash.c b/src/VBox/GuestHost/OpenGL/util/hash.c new file mode 100644 index 00000000..2c3f9db5 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/hash.c @@ -0,0 +1,777 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_threads.h" +#include "cr_hash.h" +#include "cr_mem.h" +#include "cr_error.h" + +#include + +#define CR_MAXUINT ((GLuint) 0xFFFFFFFF) +#define CR_HASH_ID_MIN ((GLuint)1) +#define CR_HASH_ID_MAX CR_MAXUINT + +#define CR_NUM_BUCKETS 1047 + +typedef struct FreeElemRec { + RTLISTNODE Node; + GLuint min; + GLuint max; +} FreeElem; + +struct CRHashIdPool { + RTLISTNODE freeList; + GLuint min; + GLuint max; +}; + +typedef struct CRHashNode { + unsigned long key; + void *data; + struct CRHashNode *next; +} CRHashNode; + +struct CRHashTable { + unsigned int num_elements; + CRHashNode *buckets[CR_NUM_BUCKETS]; + CRHashIdPool *idPool; +#ifdef CHROMIUM_THREADSAFE + CRmutex mutex; +#endif +}; + + +CRHashIdPool *crAllocHashIdPoolEx( GLuint min, GLuint max ) +{ + CRHashIdPool *pool; + FreeElem *elem; + if (min < CR_HASH_ID_MIN || max > CR_HASH_ID_MAX || min >= max) + { + crWarning("invalid min man vals"); + return NULL; + } + pool = (CRHashIdPool *) crCalloc(sizeof(CRHashIdPool)); + elem = (FreeElem *) crCalloc(sizeof(FreeElem)); + RTListInit(&pool->freeList); + elem->min = min; + elem->max = max; + RTListAppend(&pool->freeList, &elem->Node); + pool->min = min; + pool->max = max; + return pool; +} + +CRHashIdPool *crAllocHashIdPool( void ) +{ + return crAllocHashIdPoolEx( CR_HASH_ID_MIN, CR_HASH_ID_MAX ); +} + +void crFreeHashIdPool( CRHashIdPool *pool ) +{ + FreeElem *i, *next; + RTListForEachSafe(&pool->freeList, i, next, FreeElem, Node) + { + crFree(i); + } + + crFree(pool); +} + +#ifdef DEBUG_misha +static void crHashIdPoolDbgCheckConsistency(CRHashIdPool *pool) +{ + FreeElem *i; + GLuint min = 0; + + /* null is a special case, it is always treated as allocated */ + Assert(!crHashIdPoolIsIdFree(pool, 0)); + + /* first ensure entries have correct values */ + RTListForEach(&pool->freeList, i, FreeElem, Node) + { + Assert(i->min >= pool->min); + Assert(i->max <= pool->max); + Assert(i->min < i->max); + } + + /* now ensure entries do not intersect */ + /* and that they are sorted */ + RTListForEach(&pool->freeList, i, FreeElem, Node) + { + Assert(min < i->min); + min = i->max; + } +} + +static void crHashIdPoolDbgCheckUsed( const CRHashIdPool *pool, GLuint start, GLuint count, GLboolean fUsed ) +{ + GLuint i; + CRASSERT(count); + CRASSERT(start >= pool->min); + CRASSERT(start + count <= pool->max); + CRASSERT(start + count > start); + for (i = 0; i < count; ++i) + { + Assert(!fUsed == !!crHashIdPoolIsIdFree( pool, start + i )); + } +} + +# define CR_HASH_IDPOOL_DBG_CHECK_USED(_p, _start, _count, _used) do { \ + crHashIdPoolDbgCheckConsistency((_p)); \ + crHashIdPoolDbgCheckUsed( (_p), (_start), (_count), (_used) ); \ + } while (0) + +# define CR_HASH_IDPOOL_DBG_CHECK_CONSISTENCY(_p) do { crHashIdPoolDbgCheckConsistency((_p)); } while (0) +#else +# define CR_HASH_IDPOOL_DBG_CHECK_USED(_p, _start, _count, _used) do { } while (0) +# define CR_HASH_IDPOOL_DBG_CHECK_CONSISTENCY(_p) do { } while (0) +#endif + +/* + * Allocate a block of IDs. Return index of first one. + * Return 0 if we fail. + */ +GLuint crHashIdPoolAllocBlock( CRHashIdPool *pool, GLuint count ) +{ + FreeElem *f, *next; + GLuint ret; + + CRASSERT(count > 0); + RTListForEachSafe(&pool->freeList, f, next, FreeElem, Node) + { + Assert(f->max > f->min); + if (f->max - f->min >= (GLuint) count) + { + /* found a sufficiently large enough block */ + ret = f->min; + f->min += count; + if (f->min == f->max) + { + RTListNodeRemove(&f->Node); + crFree(f); + } + + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, ret, count, GL_TRUE); + return ret; + } + } + + /* failed to find free block */ + crWarning("crHashIdPoolAllocBlock failed"); + CR_HASH_IDPOOL_DBG_CHECK_CONSISTENCY(pool); + return 0; +} + + +/* + * Free a block of IDs starting at . + */ +void crHashIdPoolFreeBlock( CRHashIdPool *pool, GLuint first, GLuint count ) +{ + FreeElem *f; + GLuint last; + GLuint newMax; + FreeElem *cur, *curNext; + + /* null is a special case, it is always treated as allocated */ + if (!first) + { + Assert(!crHashIdPoolIsIdFree(pool, 0)); + ++first; + --count; + if (!count) + return; + } + + last = first + count; + CRASSERT(count > 0); + CRASSERT(last > first); + CRASSERT(first >= pool->min); + CRASSERT(last <= pool->max); + + /* the id list is sorted, first find a place to insert */ + RTListForEach(&pool->freeList, f, FreeElem, Node) + { + Assert(f->max > f->min); + + if (f->max < first) + continue; + + if (f->min > last) + { + /* we are here because first is > than prevEntry->max + * otherwise the previous loop iterations should handle that */ + FreeElem *elem = (FreeElem *) crCalloc(sizeof(FreeElem)); + elem->min = first; + elem->max = last; + RTListNodeInsertBefore(&f->Node, &elem->Node); + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, first, count, GL_FALSE); + return; + } + + /* now we have f->min <= last and f->max >= first, + * so we have either intersection */ + + if (f->min > first) + f->min = first; /* first is guaranteed not to touch any prev regions */ + + newMax = last; + + if (f->max >= last) + { + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, first, count, GL_FALSE); + return; + } + + for (cur = RTListNodeGetNext(&f->Node, FreeElem, Node), + curNext = RT_FROM_MEMBER(cur->Node.pNext, FreeElem, Node); + !RTListNodeIsDummy(&pool->freeList, cur, FreeElem, Node); + cur = curNext, + curNext = RT_FROM_MEMBER((cur)->Node.pNext, FreeElem, Node) ) + { + if (cur->min > last) + break; + + newMax = cur->max; + RTListNodeRemove(&cur->Node); + crFree(cur); + + if (newMax >= last) + break; + } + + f->max = newMax; + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, first, count, GL_FALSE); + return; + } + + /* we are here because either the list is empty or because all list rande elements have smaller values */ + f = (FreeElem *) crCalloc(sizeof(FreeElem)); + f->min = first; + f->max = last; + RTListAppend(&pool->freeList, &f->Node); + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, first, count, GL_FALSE); +} + + + +/* + * Mark the given Id as being allocated. + */ +GLboolean crHashIdPoolAllocId( CRHashIdPool *pool, GLuint id ) +{ + FreeElem *f, *next; + + if (!id) + { + /* null is a special case, it is always treated as allocated */ + Assert(!crHashIdPoolIsIdFree(pool, 0)); + return GL_FALSE; + } + +/* Assert(id != 2);*/ + + RTListForEachSafe(&pool->freeList, f, next, FreeElem, Node) + { + if (f->max <= id) + continue; + if (f->min > id) + { + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, id, 1, GL_TRUE); + return GL_FALSE; + } + + /* f->min <= id && f->max > id */ + if (id > f->min) + { + if (id + 1 < f->max) + { + FreeElem *elem = (FreeElem *) crCalloc(sizeof(FreeElem)); + elem->min = id + 1; + elem->max = f->max; + RTListNodeInsertAfter(&f->Node, &elem->Node); + } + f->max = id; + + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, id, 1, GL_TRUE); + } + else + { + Assert(id == f->min); + if (id + 1 < f->max) + { + f->min = id + 1; + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, id, 1, GL_TRUE); + } + else + { + RTListNodeRemove(&f->Node); + crFree(f); + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, id, 1, GL_TRUE); + } + } + + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, id, 1, GL_TRUE); + return GL_TRUE; + } + + /* if we get here, the ID was already allocated - that's OK */ + CR_HASH_IDPOOL_DBG_CHECK_USED(pool, id, 1, GL_TRUE); + return GL_FALSE; +} + + +/* + * Determine if the given id is free. Return GL_TRUE if so. + */ +GLboolean crHashIdPoolIsIdFree( const CRHashIdPool *pool, GLuint id ) +{ + FreeElem *f; + CRASSERT(id <= pool->max); + + RTListForEach(&pool->freeList, f, FreeElem, Node) + { + if (f->max <= id) + continue; + if (f->min > id) + return GL_FALSE; + return GL_TRUE; + } + return GL_FALSE; +} + +void crHashIdWalkKeys( CRHashIdPool *pool, CRHashIdWalkKeys walkFunc , void *data) +{ + FreeElem *prev = NULL, *f; + + RTListForEach(&pool->freeList, f, FreeElem, Node) + { + if (prev) + { + Assert(prev->max < f->min); + walkFunc(prev->max+1, f->min - prev->max, data); + } + else if (f->min > pool->min) + { + walkFunc(pool->min, f->min - pool->min, data); + } + + prev = f; + } + + Assert(prev->max <= pool->max); + + if (prev->max < pool->max) + { + walkFunc(prev->max+1, pool->max - prev->max, data); + } +} + +CRHashTable *crAllocHashtableEx( GLuint min, GLuint max ) +{ + int i; + CRHashTable *hash = (CRHashTable *) crCalloc( sizeof( CRHashTable )) ; + hash->num_elements = 0; + for (i = 0 ; i < CR_NUM_BUCKETS ; i++) + { + hash->buckets[i] = NULL; + } + hash->idPool = crAllocHashIdPoolEx( min, max ); +#ifdef CHROMIUM_THREADSAFE + crInitMutex(&hash->mutex); +#endif + return hash; +} + +CRHashTable *crAllocHashtable( void ) +{ + return crAllocHashtableEx(CR_HASH_ID_MIN, CR_HASH_ID_MAX); +} + +void crFreeHashtable( CRHashTable *hash, CRHashtableCallback deleteFunc ) +{ + int i; + CRHashNode *entry, *next; + + if ( !hash) return; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&hash->mutex); +#endif + + for ( i = 0; i < CR_NUM_BUCKETS; i++ ) + { + entry = hash->buckets[i]; + while (entry) + { + next = entry->next; + /* Clear the key in case crHashtableDelete() is called + * from this callback. + */ + entry->key = 0; + if (deleteFunc && entry->data) + { + (*deleteFunc)(entry->data); + } + crFree(entry); + entry = next; + + } + } + crFreeHashIdPool( hash->idPool ); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&hash->mutex); + crFreeMutex(&hash->mutex); +#endif + + crFree( hash ); +} + +void crFreeHashtableEx(CRHashTable *hash, CRHashtableCallbackEx deleteFunc, void *pData) +{ + int i; + CRHashNode *entry, *next; + + if (!hash) return; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&hash->mutex); +#endif + + for (i = 0; i < CR_NUM_BUCKETS; i++) + { + entry = hash->buckets[i]; + while (entry) + { + next = entry->next; + /* Clear the key in case crHashtableDelete() is called + * from this callback. + */ + entry->key = 0; + if (deleteFunc && entry->data) + { + (*deleteFunc)(entry->data, pData); + } + crFree(entry); + entry = next; + + } + } + crFreeHashIdPool(hash->idPool); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&hash->mutex); + crFreeMutex(&hash->mutex); +#endif + + crFree(hash); +} + + +void crHashtableLock(CRHashTable *h) +{ +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif +} + +void crHashtableUnlock(CRHashTable *h) +{ +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif +} + +void crHashtableWalkUnlocked( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *dataPtr2) +{ + int i; + CRHashNode *entry, *next; + + for (i = 0; i < CR_NUM_BUCKETS; i++) + { + entry = hash->buckets[i]; + while (entry) + { + /* save next ptr here, in case walkFunc deletes this entry */ + next = entry->next; + if (entry->data && walkFunc) { + (*walkFunc)( entry->key, entry->data, dataPtr2 ); + } + entry = next; + } + } +} + +void crHashtableWalk( CRHashTable *hash, CRHashtableWalkCallback walkFunc , void *dataPtr2) +{ + if (!hash) + return; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&hash->mutex); +#endif + crHashtableWalkUnlocked(hash, walkFunc , dataPtr2); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&hash->mutex); +#endif +} + +static unsigned int crHash( unsigned long key ) +{ + return key % CR_NUM_BUCKETS; +} + +void crHashtableAdd( CRHashTable *h, unsigned long key, void *data ) +{ + unsigned int index = crHash(key); + CRHashNode *node = (CRHashNode *) crCalloc( sizeof( CRHashNode ) ); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + node->key = key; + node->data = data; + node->next = h->buckets[index]; + h->buckets[index] = node; + h->num_elements++; + crHashIdPoolAllocId (h->idPool, key); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif +} + +GLboolean crHashtableAllocRegisterKey( CRHashTable *h, GLuint key) +{ + GLboolean fAllocated; +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + fAllocated = crHashIdPoolAllocId (h->idPool, key); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif + return fAllocated; +} + +void crHashtableWalkKeys( CRHashTable *h, CRHashIdWalkKeys walkFunc , void *data) +{ +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + crHashIdWalkKeys(h->idPool, walkFunc , data); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif +} + +GLuint crHashtableAllocKeys( CRHashTable *h, GLsizei range) +{ + GLuint res; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + res = crHashIdPoolAllocBlock (h->idPool, range); +#ifdef DEBUG_misha + { + int i; + Assert(res); + for (i = 0; i < range; ++i) + { + void *search = crHashtableSearch( h, res+i ); + Assert(!search); + } + } +#endif +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif + return res; +} + +void crHashtableDelete( CRHashTable *h, unsigned long key, CRHashtableCallback deleteFunc ) +{ + unsigned int index = crHash( key ); + CRHashNode *temp, *beftemp = NULL; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + for ( temp = h->buckets[index]; temp; temp = temp->next ) + { + if ( temp->key == key ) + break; + beftemp = temp; + } + if ( temp ) + { + if ( beftemp ) + beftemp->next = temp->next; + else + h->buckets[index] = temp->next; + h->num_elements--; + if (temp->data && deleteFunc) { + (*deleteFunc)( temp->data ); + } + + crFree( temp ); + } + + crHashIdPoolFreeBlock( h->idPool, key, 1 ); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif +} + +void crHashtableDeleteEx(CRHashTable *h, unsigned long key, CRHashtableCallbackEx deleteFunc, void *pData) +{ + unsigned int index = crHash( key ); + CRHashNode *temp, *beftemp = NULL; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + for (temp = h->buckets[index]; temp; temp = temp->next) + { + if (temp->key == key) + break; + beftemp = temp; + } + if (temp) + { + if (beftemp) + beftemp->next = temp->next; + else + h->buckets[index] = temp->next; + h->num_elements--; + if (temp->data && deleteFunc) { + (*deleteFunc)(temp->data, pData); + } + + crFree(temp); + } + + crHashIdPoolFreeBlock(h->idPool, key, 1); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif +} + + +void crHashtableDeleteBlock( CRHashTable *h, unsigned long key, GLsizei range, CRHashtableCallback deleteFunc ) +{ + /* XXX optimize someday */ + GLuint i; + for (i = 0; i < (GLuint)range; i++) { + crHashtableDelete( h, key, deleteFunc ); + } +} + +void *crHashtableSearch( const CRHashTable *h, unsigned long key ) +{ + unsigned int index = crHash( key ); + CRHashNode *temp; +#ifdef CHROMIUM_THREADSAFE + crLockMutex((CRmutex *)&h->mutex); +#endif + for ( temp = h->buckets[index]; temp; temp = temp->next ) + { + if ( temp->key == key ) + break; + } +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex((CRmutex *)&h->mutex); +#endif + if ( !temp ) + { + return NULL; + } + return temp->data; +} + +void crHashtableReplace( CRHashTable *h, unsigned long key, void *data, + CRHashtableCallback deleteFunc) +{ + unsigned int index = crHash( key ); + CRHashNode *temp; +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + for ( temp = h->buckets[index]; temp; temp = temp->next ) + { + if ( temp->key == key ) + break; + } +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif + if ( !temp ) + { + crHashtableAdd( h, key, data ); + return; + } +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&h->mutex); +#endif + if ( temp->data && deleteFunc ) + { + (*deleteFunc)( temp->data ); + } + temp->data = data; +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&h->mutex); +#endif +} + +unsigned int crHashtableNumElements( const CRHashTable *h) +{ + if (h) + return h->num_elements; + else + return 0; +} + +/* + * Determine if the given key is used. Return GL_TRUE if so. + */ +GLboolean crHashtableIsKeyUsed( const CRHashTable *h, GLuint id ) +{ + return (GLboolean) !crHashIdPoolIsIdFree( h->idPool, id); +} + +GLboolean crHashtableGetDataKey(CRHashTable *pHash, void *pData, unsigned long *pKey) +{ + int i; + CRHashNode *entry; + GLboolean rc = GL_FALSE; + + if (!pHash) + return rc; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&pHash->mutex); +#endif + for (i = 0; ibuckets[i]; + while (entry) + { + if (entry->data == pData) { + if (pKey) + *pKey = entry->key; + rc = GL_TRUE; + break; + } + entry = entry->next; + } + } +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&pHash->mutex); +#endif + + return rc; +} diff --git a/src/VBox/GuestHost/OpenGL/util/htable.cpp b/src/VBox/GuestHost/OpenGL/util/htable.cpp new file mode 100644 index 00000000..b3e09554 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/htable.cpp @@ -0,0 +1,188 @@ +/* $Id: htable.cpp $ */ +/** @file + * uint32_t handle to void simple table impl + * + * @todo Why couldn't you simply use iprt/handletable.h? + */ + +/* + * Copyright (C) 2013-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include +#include +#include "cr_spu.h" +#include "cr_vreg.h" + +#include "cr_htable.h" +#include "cr_spu.h" +#include "chromium.h" +#include "cr_error.h" +#include "cr_net.h" +#include "cr_rand.h" +#include "cr_mem.h" +#include "cr_string.h" + +#include +#include +#include +#include + +VBOXHTABLEDECL(int) CrHTableCreate(PCRHTABLE pTbl, uint32_t cSize) +{ + memset(pTbl, 0, sizeof (*pTbl)); + if (!cSize) + return VINF_SUCCESS; + pTbl->paData = (void**)RTMemAllocZ(sizeof (pTbl->paData[0]) * cSize); + if (pTbl->paData) + { + pTbl->cSize = cSize; + return VINF_SUCCESS; + } + WARN(("RTMemAllocZ failed!")); + return VERR_NO_MEMORY; +} + +VBOXHTABLEDECL(void) CrHTableDestroy(PCRHTABLE pTbl) +{ + if (!pTbl->paData) + return; + + RTMemFree(pTbl->paData); +} + +int crHTableRealloc(PCRHTABLE pTbl, uint32_t cNewSize) +{ + Assert(cNewSize > pTbl->cSize); + if (cNewSize > pTbl->cSize) + { + void **pvNewData = (void**)RTMemAllocZ(sizeof (pTbl->paData[0]) * cNewSize); + if (!pvNewData) + { + WARN(("RTMemAllocZ failed for size (%d)", (int)(sizeof (pTbl->paData[0]) * cNewSize))); + return VERR_NO_MEMORY; + } + memcpy(pvNewData, pTbl->paData, sizeof (pTbl->paData[0]) * pTbl->cSize); + RTMemFree(pTbl->paData); + pTbl->iNext2Search = pTbl->cSize; + pTbl->cSize = cNewSize; + pTbl->paData = pvNewData; + return VINF_SUCCESS; + } + else if (cNewSize >= pTbl->cData) + { + WARN(("not implemented")); + return VERR_NOT_IMPLEMENTED; + } + WARN(("invalid parameter")); + return VERR_INVALID_PARAMETER; + +} + +VBOXHTABLEDECL(int) CrHTableRealloc(PCRHTABLE pTbl, uint32_t cNewSize) +{ + return crHTableRealloc(pTbl, cNewSize); +} + +VBOXHTABLEDECL(void) CrHTableEmpty(PCRHTABLE pTbl) +{ + pTbl->cData = 0; + pTbl->iNext2Search = 0; + if (pTbl->cSize) + memset(pTbl->paData, 0, sizeof (pTbl->paData[0]) * pTbl->cSize); +} + +static void* crHTablePutToSlot(PCRHTABLE pTbl, uint32_t iSlot, void* pvData) +{ + Assert(pvData); + void* pvOld = pTbl->paData[iSlot]; + pTbl->paData[iSlot] = pvData; + if (!pvOld) + ++pTbl->cData; + Assert(pTbl->cData <= pTbl->cSize); + return pvOld; +} + +VBOXHTABLEDECL(int) CrHTablePutToSlot(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle, void* pvData) +{ + AssertReturn(pvData, VERR_INVALID_PARAMETER); + uint32_t iIndex = crHTableHandle2Index(hHandle); + if (iIndex >= pTbl->cSize) + { + int rc = crHTableRealloc(pTbl, iIndex + RT_MAX(10, pTbl->cSize/4)); + if (!RT_SUCCESS(rc)) + { + WARN(("crHTableRealloc failed rc %d", rc)); + return CRHTABLE_HANDLE_INVALID; + } + } + + crHTablePutToSlot(pTbl, iIndex, pvData); + + return VINF_SUCCESS; +} + +VBOXHTABLEDECL(CRHTABLE_HANDLE) CrHTablePut(PCRHTABLE pTbl, void* pvData) +{ + AssertReturn(pvData, CRHTABLE_HANDLE_INVALID); + + if (pTbl->cSize == pTbl->cData) + { + int rc = crHTableRealloc(pTbl, pTbl->cSize + RT_MAX(10, pTbl->cSize/4)); + if (!RT_SUCCESS(rc)) + { + WARN(("crHTableRealloc failed rc %d", rc)); + return CRHTABLE_HANDLE_INVALID; + } + } + for (uint32_t i = pTbl->iNext2Search; ; ++i, i %= pTbl->cSize) + { + Assert(i < pTbl->cSize); + if (!pTbl->paData[i]) + { + void *pvOld = crHTablePutToSlot(pTbl, i, pvData); + Assert(!pvOld); NOREF(pvOld); + pTbl->iNext2Search = i+1; + pTbl->iNext2Search %= pTbl->cSize; + return crHTableIndex2Handle(i); + } + } + /* not reached */ +} + +VBOXHTABLEDECL(void*) CrHTableRemove(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle) +{ + uint32_t iIndex = crHTableHandle2Index(hHandle); + Assert(iIndex < pTbl->cSize); + if (iIndex < pTbl->cSize) + { + void* pvData = pTbl->paData[iIndex]; + if (pvData) + { + pTbl->paData[iIndex] = NULL; + --pTbl->cData; + Assert(pTbl->cData <= pTbl->cSize); + pTbl->iNext2Search = iIndex; + } + return pvData; + } + WARN(("invalid handle supplied %d", hHandle)); + return NULL; +} + +VBOXHTABLEDECL(void*) CrHTableGet(PCRHTABLE pTbl, CRHTABLE_HANDLE hHandle) +{ + uint32_t iIndex = crHTableHandle2Index(hHandle); + if (iIndex < pTbl->cSize) + return pTbl->paData[iIndex]; + LOG(("invalid handle supplied %d", hHandle)); + return NULL; +} diff --git a/src/VBox/GuestHost/OpenGL/util/hull.c b/src/VBox/GuestHost/OpenGL/util/hull.c new file mode 100644 index 00000000..05246ec1 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/hull.c @@ -0,0 +1,315 @@ + +#include +#include + +#include "cr_mem.h" +#include "cr_hull.h" +#include "cr_error.h" + +#ifdef WINDOWS +/* I know while(1) is constant */ +#pragma warning( disable: 4127 ) +#endif + +/*================================================== + * + * Do S1 & S2 intersect? if so, return t for s1 + */ +static double +_segment_segment_intersection(const double *s1a, const double *s1b, + const double *s2a, const double *s2b) +{ + double r1[2], r2[2]; + double A, B, s, t; + double epsilon = .0000000001; + + r1[0] = s1b[0] - s1a[0]; + r1[1] = s1b[1] - s1a[1]; + r2[0] = s2b[0] - s2a[0]; + r2[1] = s2b[1] - s2a[1]; + + if (r1[0] == 0) + return -1; + + A = s1a[1] - s2a[1] + (r1[1] / r1[0]) * (s2a[0] - s1a[0]); + B = r2[1] - (r1[1] / r1[0]) * r2[0]; + + if (B == 0) + return -1; + s = A / B; + + if ((s <= epsilon) || (s > 1. + epsilon)) + return -1; + + t = (s2a[0] - s1a[0] + s * r2[0]) / r1[0]; + if ((t < epsilon) || (t > 1. + epsilon)) + return -1; + + return t; +} + +static int +_segment_hull_intersect(double *sa, double *sb, const double *pnts, + int *hull, int hull_len, double *hits) +{ + int a, hitnum; + double result; + double d[2]; + + hitnum = 0; + for (a = 0; a < hull_len - 1; a++) + { + result = _segment_segment_intersection(sa, sb, pnts + 2 * hull[a], + pnts + 2 * hull[a + 1]); + + if (result >= 0) + { + d[0] = sb[0] - sa[0]; + d[1] = sb[1] - sa[1]; + hits[2 * hitnum] = sa[0] + result * d[0]; + hits[2 * hitnum + 1] = sa[1] + result * d[1]; + hitnum++; + } + } + + return hitnum; +} + +/* + * given 4 points, find a rectangle that lays w/i the quad + */ +static void +_four_point_box(double *points, double *min, double *max) +{ + int a, b, tmp, sort[4]; + double npnts[8], pnt[2], retval, d[2]; + + for (a = 0; a < 4; a++) + sort[a] = a; + + for (a = 0; a < 4; a++) + for (b = a + 1; b < 4; b++) + { + if (points[2 * sort[a] + 1] > points[2 * sort[b] + 1]) + { + tmp = sort[a]; + sort[a] = sort[b]; + sort[b] = tmp; + } + } + + npnts[0] = points[2 * sort[1]]; + npnts[1] = points[2 * sort[1] + 1]; + npnts[2] = points[2 * sort[2]]; + npnts[3] = points[2 * sort[2] + 1]; + + /* now, intersect a horizontal ray from sort[1] with the quad */ + for (b = 0; b < 2; b++) + { + for (a = 0; a < 4; a++) + { + pnt[0] = points[2 * sort[b + 1]] + 10; + pnt[1] = points[2 * sort[b + 1] + 1]; + + retval = _segment_segment_intersection(points + 2 * sort[b + 1], pnt, + points + 2 * a, + points + 2 * ((a + 1) % 4)); + if (retval <= 0.001) + { + pnt[0] = points[2 * sort[b + 1]] - 10; + retval = _segment_segment_intersection(points + 2 * sort[b + 1], pnt, + points + 2 * a, + points + 2 * ((a + 1) % 4)); + } + + if (retval > 0.001) + { + d[0] = pnt[0] - points[2 * sort[b + 1]]; + d[1] = pnt[1] - points[2 * sort[b + 1] + 1]; + npnts[2 * b + 4] = points[2 * sort[b + 1]] + retval * d[0]; + npnts[2 * b + 5] = points[2 * sort[b + 1] + 1] + retval * d[1]; + } + } + } + + min[1] = points[2 * sort[1] + 1]; + max[1] = points[2 * sort[2] + 1]; + + /* finally, sort npnts by x */ + for (a = 0; a < 4; a++) + sort[a] = a; + + for (a = 0; a < 4; a++) + for (b = a + 1; b < 4; b++) + { + if (npnts[2 * sort[a]] > npnts[2 * sort[b]]) + { + tmp = sort[a]; + sort[a] = sort[b]; + sort[b] = tmp; + } + } + + /* and grab the x coord of the box */ + min[0] = npnts[2 * sort[1]]; + max[0] = npnts[2 * sort[2]]; + +} + +/* + * Given the convex hull, find a rectangle w/i it. + * + * Finding the rect from 4 pnts isn't too bad. Find the bbox + * of the CH, then intersect the diagonals of the bbox with + * the CH. Use those 4 points to compute the box + */ +static void +_bound(const double *pnts, int npnts, int *hull, int hull_len, double *bbox) +{ + double max[2], min[2], cent[2], dir[2], pnt[2]; + double x, y, intr_pnts[8]; + int a, retval; + + (void) npnts; + + max[0] = max[1] = -9999; + min[0] = min[1] = 9999; + for (a = 0; a < hull_len; a++) + { + x = pnts[2 * hull[a]]; + y = pnts[2 * hull[a] + 1]; + if (x < min[0]) + min[0] = x; + if (x > max[0]) + max[0] = x; + if (y < min[1]) + min[1] = y; + if (y > max[1]) + max[1] = y; + } + + /* push the bbox out just a hair to make intersection + * a bit more sane */ + cent[0] = (min[0] + max[0]) / 2.; + cent[1] = (min[1] + max[1]) / 2.; + dir[0] = max[0] - cent[0]; + dir[1] = max[1] - cent[1]; + max[0] = cent[0] + 1.01 * dir[0]; + max[1] = cent[1] + 1.01 * dir[1]; + dir[0] = min[0] - cent[0]; + dir[1] = min[1] - cent[1]; + min[0] = cent[0] + 1.01 * dir[0]; + min[1] = cent[1] + 1.01 * dir[1]; + + retval = _segment_hull_intersect(min, max, pnts, hull, hull_len, intr_pnts); + if (retval != 2) + crError("Bad hull intersection"); + + dir[0] = min[0]; + dir[1] = max[1]; + pnt[0] = max[0]; + pnt[1] = min[1]; + retval = + _segment_hull_intersect(dir, pnt, pnts, hull, hull_len, intr_pnts + 4); + if (retval != 2) + crError("Bad hull intersection"); + + /* swap points to get them in some order */ + cent[0] = intr_pnts[2]; + cent[1] = intr_pnts[3]; + intr_pnts[2] = intr_pnts[4]; + intr_pnts[3] = intr_pnts[5]; + intr_pnts[4] = cent[0]; + intr_pnts[5] = cent[1]; + + _four_point_box(intr_pnts, bbox, bbox + 2); +} + +/*==================================================*/ +void +crHullInteriorBox(const double *pnts, int npnts, double *bbox) +{ + int lowest, a; + int *hull, idx, low_idx = 0; + double low_dot; + const double *p0, *p1; + double v[2], A, B, vnew[2], vlow[2]; + + vlow[0] = vlow[1] = 0.0; + + hull = (int *) crAlloc((npnts + 1) * sizeof(int)); + + /* find the lowest */ + lowest = 0; + for (a = 0; a < 2 * npnts; a += 2) + { + if (pnts[a + 1] < pnts[2 * lowest + 1]) + lowest = a / 2; + } + + hull[0] = lowest; + p0 = pnts + 2 * lowest; + idx = 1; + + v[0] = 1; + v[1] = 0; + + while (1) + { + low_dot = -10; + + for (a = 0; a < npnts; a++) + { + if (a == hull[idx - 1]) + continue; + + p1 = pnts + 2 * a; + if (v[0] == 0.0) + A = 0.0; + else + A = p0[1] - p1[1] + (v[1] / v[0]) * (p1[0] - p0[0]); + if (v[0] == 0.0) + B = 0.0; + else + B = v[1] * v[1] / v[0] + v[0]; + + if (B != 0.0 && A / B > 0) + { + continue; + } + + vnew[0] = p1[0] - p0[0]; + vnew[1] = p1[1] - p0[1]; + B = sqrt(vnew[0] * vnew[0] + vnew[1] * vnew[1]); + + vnew[0] /= B; + vnew[1] /= B; + + A = vnew[0] * v[0] + vnew[1] * v[1]; + + if (A > low_dot) + { + low_dot = A; + low_idx = a; + vlow[0] = vnew[0]; + vlow[1] = vnew[1]; + } + } + + p0 = pnts + 2 * low_idx; + hull[idx] = low_idx; + idx++; + + v[0] = vlow[0]; + v[1] = vlow[1]; + + if (low_idx == lowest) + { + break; + } + } + + _bound(pnts, npnts, hull, idx, bbox); + + crFree(hull); +} diff --git a/src/VBox/GuestHost/OpenGL/util/idpool.c b/src/VBox/GuestHost/OpenGL/util/idpool.c new file mode 100644 index 00000000..89fcc6fc --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/idpool.c @@ -0,0 +1,288 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "chromium.h" +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_idpool.h" + + +#define CR_MAXUINT ((GLuint) 0xFFFFFFFF) + +typedef struct FreeElemRec { + GLuint min; + GLuint max; + struct FreeElemRec *next; + struct FreeElemRec *prev; +} FreeElem; + +struct CRIdPoolRec { + FreeElem *freeList; +}; + + + +CRIdPool *crAllocIdPool( void ) +{ + CRIdPool *pool = (CRIdPool *) crCalloc(sizeof(CRIdPool)); + pool->freeList = (FreeElem *) crCalloc(sizeof(FreeElem)); + pool->freeList->min = 1; + pool->freeList->max = CR_MAXUINT; + pool->freeList->next = NULL; + pool->freeList->prev = NULL; + return pool; +} + +void crFreeIdPool( CRIdPool *pool ) +{ + FreeElem *i, *next; + for (i = pool->freeList; i; i = next) + { + next = i->next; + crFree(i); + } + crFree(pool); +} + +/* + * Allocate a block of IDs. Return index of first one. + * Return 0 if we fail. + */ +GLuint crIdPoolAllocBlock( CRIdPool *pool, GLuint count ) +{ + FreeElem *f; + GLuint ret; + + CRASSERT(count > 0); + + f = pool->freeList; + while (f) + { + if (f->max - f->min + 1 >= (GLuint) count) + { + /* found a sufficiently large enough block */ + ret = f->min; + f->min += count; + + if (f->min == f->max) + { + /* remove this block from linked list */ + if (f == pool->freeList) + { + /* remove from head */ + pool->freeList = pool->freeList->next; + pool->freeList->prev = NULL; + } + else + { + /* remove from elsewhere */ + f->prev->next = f->next; + f->next->prev = f->prev; + } + crFree(f); + } + +#ifdef DEBUG + /* make sure the IDs really are allocated */ + { + GLuint i; + for (i = 0; i < count; i++) + { + CRASSERT(crIdPoolIsIdUsed(pool, ret + i)); + } + } +#endif + + return ret; + } + else { + f = f->next; + } + } + + /* failed to find free block */ + return 0; +} + + +/* + * Free a block of IDs starting at . + */ +void crIdPoolFreeBlock( CRIdPool *pool, GLuint first, GLuint count ) +{ + FreeElem *i; + FreeElem *newelem; + + /*********************************/ + /* Add the name to the freeList */ + /* Find the bracketing sequences */ + + for (i = pool->freeList; i && i->next && i->next->min < first; i = i->next) + { + /* EMPTY BODY */ + } + + /* j will always be valid */ + if (!i) + return; + if (!i->next && i->max == first) + return; + + /* Case: j:(~,first-1) */ + if (i->max + 1 == first) + { + i->max += count; + if (i->next && i->max+1 >= i->next->min) + { + /* Collapse */ + i->next->min = i->min; + i->next->prev = i->prev; + if (i->prev) + { + i->prev->next = i->next; + } + if (i == pool->freeList) + { + pool->freeList = i->next; + } + crFree(i); + } + return; + } + + /* Case: j->next: (first+1, ~) */ + if (i->next && i->next->min - count == first) + { + i->next->min -= count; + if (i->max + 1 >= i->next->min) + { + /* Collapse */ + i->next->min = i->min; + i->next->prev = i->prev; + if (i->prev) + { + i->prev->next = i->next; + } + if (i == pool->freeList) + { + pool->freeList = i->next; + } + crFree(i); + } + return; + } + + /* Case: j: (first+1, ~) j->next: null */ + if (!i->next && i->min - count == first) + { + i->min -= count; + return; + } + + /* allocate a new FreeElem node */ + newelem = (FreeElem *) crCalloc(sizeof(FreeElem)); + newelem->min = first; + newelem->max = first + count - 1; + + /* Case: j: (~,first-(2+)) j->next: (first+(2+), ~) or null */ + if (first > i->max) + { + newelem->prev = i; + newelem->next = i->next; + if (i->next) + { + i->next->prev = newelem; + } + i->next = newelem; + return; + } + + /* Case: j: (first+(2+), ~) */ + /* Can only happen if j = t->freeList! */ + if (i == pool->freeList && i->min > first) + { + newelem->next = i; + newelem->prev = i->prev; + i->prev = newelem; + pool->freeList = newelem; + return; + } +} + + + +/* + * Mark the given Id as being allocated. + */ +void crIdPoolAllocId( CRIdPool *pool, GLuint id ) +{ + FreeElem *f; + + CRASSERT(id > 0); + + f = pool->freeList; + while (f) + { + if (id >= f->min && id <= f->max) + { + /* found the block */ + if (id == f->min) + { + f->min++; + } + else if (id == f->max) + { + f->max--; + } + else + { + /* somewhere in the middle - split the block */ + FreeElem *newelem = (FreeElem *) crCalloc(sizeof(FreeElem)); + newelem->min = id + 1; + newelem->max = f->max; + f->max = id - 1; + newelem->next = f->next; + if (f->next) + f->next->prev = newelem; + newelem->prev = f; + f->next = newelem; + } + return; + } + f = f->next; + } + + /* if we get here, the ID was already allocated - that's OK */ +} + + +/* + * Determine if the given id is free. Return GL_TRUE if so. + */ +GLboolean crIdPoolIsIdFree( const CRIdPool *pool, GLuint id ) +{ + FreeElem *i; + + /* First find which region it fits in */ + for (i = pool->freeList; i && !(i->min <= id && id <= i->max); i=i->next) + { + /* EMPTY BODY */ + } + + if (i) + return GL_TRUE; + else + return GL_FALSE; +} + + +/* + * Determine if the given id is used. Return GL_TRUE if so. + */ +GLboolean crIdPoolIsIdUsed( const CRIdPool *pool, GLuint id ) +{ + return (GLboolean) !crIdPoolIsIdFree( pool, id); +} diff --git a/src/VBox/GuestHost/OpenGL/util/libteac.c b/src/VBox/GuestHost/OpenGL/util/libteac.c new file mode 100644 index 00000000..eb349809 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/libteac.c @@ -0,0 +1,1213 @@ +#include +#include +#include +#include +#include + +#include "teac.h" + +/* Notes- + * -Why is elan3_fini dropping core? It's intermittent, and seems to + * depend on relative timing of multiple calls. + */ + +#ifdef CHROMIUM +#include +#include +#include +#else +#define crAlloc(sz) malloc(sz) +#define crStrncpy(out,in,sz) strncpy(out,in,sz) +#define crMemcpy(out,in,bytes) memcpy(out,in,bytes) +#define crStrchr(instr,inchr) strchr(instr,inchr) +#define crFree(ptr) free(ptr) +#define crRealloc( pp, size ) { \ + if (!(*pp=realloc(*pp,size))) { \ + fprintf(stderr,"failed to reallocate %d bytes!\n",size); \ + abort(); \ + } \ +} +#include +static void crDebug( const char* fmt, ... ) { + va_list ap; + va_start(ap,fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); +} +#endif + +#define EADDR_ALLOC_ELAN 0x200000 +#define ALLOC_ELAN_SIZE 0x200000 +#define EADDR_ALLOC_MAIN 0x400000 +#define ALLOC_MAIN_SIZE 0x2000000 + +/* We need some defs to handle changes in structures between software + * revisions. + */ +/* Capability shape is the same between KITE and pre-KITE */ +#ifdef ELAN_PRE_KITE + +/* software level is PRE_KITE */ +#define TEAC_DEVINFO_TYPE 0 +#define TEAC_CAP_TYPE 0 + +#else +#ifdef ELAN_PRE_EAGLE + +/* software level is KITE */ + +#ifdef LINUX +#define TEAC_DEVINFO_TYPE 1 +#define TEAC_CREATE_TYPE 1 +#else +#define TEAC_DEVINFO_TYPE 0 +#define TEAC_CREATE_TYPE 0 +#endif +#define TEAC_CAP_TYPE 1 + +#else +/* software level is EAGLE */ +#define TEAC_DEVINFO_TYPE 2 +#define TEAC_CAP_TYPE 2 +#define TEAC_CREATE_TYPE 2 + +#endif +#endif + +#if (TEAC_CAP_TYPE == 2) +#define TEAC_CAP_ENTRIES(cap) ELAN_CAP_ENTRIES(cap) +#else +#define TEAC_CAP_ENTRIES(cap) (cap->Entries) +#endif + +/* In the future we will use the bitwise AND of the rail masks */ +#define RAIL 0 + +#ifndef HOST_TABLE_FILENAME +#define HOST_TABLE_FILENAME "/usr/users/8/welling/elanstuff/teac/teac_host_map.t" +#endif + +#define INITIAL_HOST_TABLE_SIZE 256 + +static host_t* hosts= NULL; /* this one ends up sorted by host name */ +static int* hostsIndex= NULL; /* this is sorted by node ID */ +static sdramaddr_t* sdramAddrBase= NULL; +static E3_Addr* elanAddrBase= NULL; + +static int nodeTablesInitialized= 0; +static int nodeTableSize= 0; +static int nodeCount= 0; + +static int read_node_map() +{ + FILE* f= NULL; + int i; + int iLine; + char buf[256]; + + if (hosts) crFree(hosts); + if (!(hosts= (host_t*)crAlloc(INITIAL_HOST_TABLE_SIZE*sizeof(host_t)))) { + fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n", + INITIAL_HOST_TABLE_SIZE*sizeof(host_t)); + abort(); + } + nodeTableSize= INITIAL_HOST_TABLE_SIZE; + + if (!(f=fopen(HOST_TABLE_FILENAME,"r"))) { + fprintf(stderr,"libteac: read_node_map: cannot open <%s> for reading!\n", + HOST_TABLE_FILENAME); + abort(); + } + + i= 0; + iLine= 0; + buf[sizeof(buf)-1]= '\0'; + while (!feof(f) && !ferror(f)) { + char* tmp; + char* string; + if (!fgets(buf, sizeof(buf)-1, f)) break; + iLine++; + if (buf[0]=='#' || buf[0]=='\n' || buf[0]=='\0') continue; + if (i>=nodeTableSize) { + /* We need to grow the table */ + int newSize= 2*nodeTableSize; + crRealloc((void**)&hosts,newSize*sizeof(host_t)); + nodeTableSize= newSize; + } + if (!(string=strtok_r(buf," ,;\t\n",&tmp))) { + fprintf(stderr,"libteac: read_node_map: Bad machine name at line %d of %s!\n", + iLine, HOST_TABLE_FILENAME); + abort(); + } + if (strlen(string)==0) continue; /* blank line */ + hosts[i].name= strdup(string); + + if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) { + fprintf(stderr,"libteac: read_node_map: bad integer string at line %d of %s!\n", + iLine, HOST_TABLE_FILENAME); + abort(); + } + errno= 0; + hosts[i].railMask= atoi(string); + if (errno != 0) { + fprintf(stderr,"libteac: read_node_map: bad integer %s at %s line %d!\n", + string, HOST_TABLE_FILENAME, iLine); + abort(); + } + + if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) { + fprintf(stderr,"libteac: read_node_map: bad integer string at line %d of %s!\n", + iLine, HOST_TABLE_FILENAME); + abort(); + } + errno= 0; + hosts[i].id= atoi(string); + if (errno != 0) { + fprintf(stderr,"libteac: read_node_map: bad integer %s at %s line %d!\n", + string, HOST_TABLE_FILENAME, iLine); + abort(); + } + + if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) { + fprintf(stderr,"libteac: read_node_map: bad hex value at line %d of %s!\n", + iLine, HOST_TABLE_FILENAME); + abort(); + } + errno= 0; + hosts[i].sdramAddrBase= (sdramaddr_t)strtol(string, (char**)NULL, 0); + if (errno != 0) { + fprintf(stderr,"libteac: read_node_map: bad hex address %s at %s line %d!\n", + string, HOST_TABLE_FILENAME, iLine); + abort(); + } + + if (!(string=strtok_r(NULL," ,;\t\n",&tmp))) { + fprintf(stderr,"libteac: read_node_map: bad hex value at line %d of %s!\n", + iLine, HOST_TABLE_FILENAME); + abort(); + } + errno= 0; + hosts[i].elanAddrBase= (E3_Addr)strtol(string, (char**)NULL, 0); + if (errno != 0) { + fprintf(stderr,"libteac: read_node_map: bad hex address %s at %s line %d!\n", + string, HOST_TABLE_FILENAME, iLine); + abort(); + } + +#if 0 + crDebug("line %d: %d: got <%s> %d %d 0x%x 0x%x\n", + iLine, i, hosts[i].name, hosts[i].railMask, hosts[i].id, + hosts[i].sdramAddrBase, hosts[i].elanAddrBase); +#endif + + i++; + } + if (ferror(f)) { + perror("Error reading host table"); + fprintf(stderr,"libteac: read_node_map: error reading <%s>!\n", + HOST_TABLE_FILENAME); + abort(); + } + + (void)fclose(f); + return i; +} + +static int hostnameCompare(const void* h1, const void* h2) +{ + return strcmp(((host_t*)h1)->name, ((host_t*)h2)->name); +} + +static int hostnameLookup(const void* h1, const void* h2) +{ + return strcmp((const char*)h1, ((host_t*)h2)->name); +} + +static void initialize_node_tables() +{ + if (!nodeTablesInitialized) { + int nodeMin; + int nodeMax; + int nodeRange; + int i; + + crDebug("Loading Quadrics network map from <%s>\n",HOST_TABLE_FILENAME); + + /* Load information about Quadrics network */ + nodeCount= read_node_map(); + if (nodeCount==0) { + fprintf(stderr, + "libteac: initialize_node_tables: no valid nodes in %s!\n", + HOST_TABLE_FILENAME); + abort(); + } + + /* + * Build the offset tables. Offsets are looked up by node ID, so we + * have to avoid redundant IDs and order the tables correctly. + */ + nodeMin= nodeMax= hosts[0].id; + for (i=1; inodeMax) nodeMax= hosts[i].id; + } + nodeRange= (nodeMax-nodeMin) + 1; + if (!(sdramAddrBase=(sdramaddr_t*)crAlloc(nodeRange*sizeof(sdramaddr_t)))) { + fprintf(stderr, + "libteac: initialize_node_tables: unable to allocate %d bytes!\n", + nodeRange*sizeof(sdramaddr_t)); + abort(); + } + if (!(elanAddrBase=(E3_Addr*)crAlloc(nodeRange*sizeof(E3_Addr)))) { + fprintf(stderr, + "libteac: initialize_node_tables: unable to allocate %d bytes!\n", + nodeRange*sizeof(E3_Addr)); + abort(); + } + for (i=0; i got <%s> <%d> <%x> <%x>\n", + hn,h->name,h->id,(int)h->sdramAddrBase,(int)h->elanAddrBase); + } + else fprintf(stderr,"Lookup <%s> returned NULL!\n",hn); +#endif + if (h) return h->id; + else return -1; +} + +/* + * A version of address translation with some safety checks + */ +static E3_Addr teac_main2elan( ELAN3_CTX *ctx, void* main_addr ) +{ + E3_Addr result= elan3_main2elan(ctx,main_addr); + /* + crDebug("mapping %0lx -> %d; addressable %d\n", + main_addr,result,elan3_addressable(ctx,main_addr,64)); + */ + if (result==ELAN_BAD_ADDR) { + fprintf(stderr,"Address translation error: %0x has no elan equivalent\n", + (int)main_addr); + abort(); + } + return result; +} + +Tcomm *teac_Init(char *lh, char *hh, int lctx, int hctx, int myrank, + const unsigned char key[TEAC_KEY_SIZE]) +{ +#if (TEAC_DEVINFO_TYPE == 2) + ELAN_DEVINFO info; + ELAN_POSITION position; +#else + ELAN3_DEVINFO info; +#endif + ELAN_CAPABILITY *cap; + Tcomm* result= NULL; + int i; + int j; + int a; + int b; + char buf[256]; + char* here; +#if ( TEAC_CREATE_TYPE == 0 ) + void* control; +#endif + + if (!nodeTablesInitialized) initialize_node_tables(); + + if (!(result= (Tcomm*)crAlloc(sizeof(Tcomm)))) { + fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n", + sizeof(Tcomm)); + return(NULL); + } + result->ctx = NULL; + result->dma = NULL; + result->e_dma = 0; + result->s_event = 0; + result->r_event = NULL; + for (i=0; isbuf_pull_event[i] = 0; + result->rbuf_pull_event = 0; + result->m_snd = NULL; + result->m_rcv = NULL; + for (i=0; isbuf_ready[i]= NULL; + result->rbuf_ready = NULL; + result->mbuff= NULL; + for (i=0; isendWrappers[i]= NULL; + result->vp = -1; + result->hhost = result->lhost = -1; + result->hctx = result->lctx = -1; + result->msgnum = 0; + result->poll_shift = 0; + result->totalSendBufferBytesAllocated= 0; + result->totalRecvBufferBytesAllocated= 0; + + a = trans_host(lh); + b = trans_host(hh); + result->lhost = (a < b)? a : b; + result->hhost = (a > b) ? a : b; + + result->lctx = (lctxhctx = (hctx>lctx) ? hctx : lctx; + + cap = &(result->cap); +#if (TEAC_CAP_TYPE == 2) + elan_nullcap(cap); + /* Initialize the UserKey to the given value */ + crMemcpy((void*)&(cap->cap_userkey.key_values),key,TEAC_KEY_SIZE); + cap->cap_lowcontext = lctx; + cap->cap_mycontext = lctx + (myrank%4); + cap->cap_highcontext = hctx; + cap->cap_lownode = result->lhost; + cap->cap_highnode = result->hhost; + cap->cap_type = + ELAN_CAP_TYPE_BLOCK | ELAN_CAP_TYPE_NO_BITMAP | ELAN_CAP_TYPE_MULTI_RAIL; +#else + elan3_nullcap(cap); + /* Initialize the UserKey to the given value */ + crMemcpy((void*)&(cap->UserKey),key,TEAC_KEY_SIZE); + cap->LowContext = lctx; + cap->MyContext = lctx + (myrank%4); + cap->HighContext = hctx; + cap->LowNode = result->lhost; + cap->HighNode = result->hhost; + cap->Entries = (hctx - lctx + 1) * (cap->HighNode - cap->LowNode + 1); + cap->Type = + ELAN_CAP_TYPE_BLOCK | ELAN_CAP_TYPE_NO_BITMAP | ELAN_CAP_TYPE_MULTI_RAIL; +#endif + + if ((result->ctx = elan3_init( 0, EADDR_ALLOC_MAIN, ALLOC_MAIN_SIZE, + EADDR_ALLOC_ELAN, ALLOC_ELAN_SIZE)) + == NULL) { + fprintf(stderr, "teac_Init: elan3_init returned NULL context\n"); + return(NULL); + } + elan3_block_inputter (result->ctx, 1); + +#if ( TEAC_CREATE_TYPE == 0 ) + if ((control = elan3_control_open (RAIL)) != NULL) { + if (elan3_create(control, &(result->cap))) { + crDebug("elan3_create failed with <%s>, but that's OK!\n", + strerror(errno)); + errno= 0; + } + } + else { + perror("elan3_control_open failed"); + teac_Close(result); + return NULL; + } +#elif ( TEAC_CREATE_TYPE == 1 ) + if (elan3_create(result->ctx, &(result->cap))) { + crDebug("elan3_create failed with <%s>, but that's OK!\n", + strerror(errno)); + errno= 0; + } +#else + /* I don't think we have to do anything here! */ +#endif + +#if (TEAC_DEVINFO_TYPE == 2) + (void)elan3_get_devinfo(result->ctx, &info); + (void)elan3_get_position(result->ctx, &position); + crDebug("Position mode %d, NodeID %d, NumNodes %d, NumLevels %d\n", + position.pos_mode,position.pos_nodeid, position.pos_nodes, + position.pos_levels); + if (position.pos_mode != ELAN_POS_MODE_SWITCHED) + crDebug("WARNING: position mode is not %d!\n",ELAN_POS_MODE_SWITCHED); + crDebug("Rail %d\n",info.dev_rail); +#elif (TEAC_DEVINFO_TYPE == 1) + elan3_devinfo(0, &info); + crDebug("NodeId: %d, NumNodes: %d, NumLevels: %d, NodeLevel: %d\n", + info.Position.NodeId, info.Position.NumNodes, + info.Position.NumLevels, info.Position.NodeLevel); +#else + elan3_devinfo(0, &info); + crDebug("NodeId: %d, NumLevels: %d, NodeLevel: %d\n", + info.NodeId, info.NumLevels, info.NodeLevel); +#endif + +#if 0 + { + static char junkString[256]; +#if (TEAC_CAP_TYPE == 2) + crDebug("Capability: <%s>\n", + elan_capability_string(&(result->cap),junkString)); + crDebug("railmask is %d\n",result->cap.cap_railmask); + crDebug("bitmap is %x\n",result->cap.cap_bitmap[0]); +#else + crDebug("Capability: <%s>\n", + elan3_capability_string(&(result->cap),junkString)); + crDebug("railmask is %d\n",result->cap.RailMask); + crDebug("bitmap is %x\n",result->cap.Bitmap[0]); +#endif + } +#endif + + /* Reality check. */ + if (gethostname(buf,sizeof(buf)-1)) { + perror("Can't get my own host name"); + teac_Close(result); + return NULL; + } + if ((here= crStrchr(buf,'.')) != NULL) *here= '\0'; + +#if (TEAC_DEVINFO_TYPE == 2) + if (trans_host(buf) != (int)position.pos_nodeid) { + fprintf(stderr, + "teac_Init: Expected Quadrics port id %d does not match real value %d!\n", + trans_host(buf), position.pos_nodeid); + teac_Close(result); + return NULL; + } +#elif (TEAC_DEVINFO_TYPE == 1) + if (trans_host(buf) != info.Position.NodeId) { + fprintf(stderr, + "teac_Init: Expected Quadrics port id %d does not match real value %d!\n", + trans_host(buf), info.Position.NodeId); + teac_Close(result); + return NULL; + } +#else + if (trans_host(buf) != info.NodeId) { + fprintf(stderr, + "teac_Init: Expected Quadrics port id %d does not match real value %d!\n", + trans_host(buf), info.NodeId); + teac_Close(result); + return NULL; + } +#endif + + if (elan3_attach(result->ctx, &(result->cap))) { + fprintf(stderr, "teac_Init: elan3_attach failed\n"); + teac_Close(result); + return(NULL); + } + + if (elan3_addvp(result->ctx, 0, &(result->cap))) { + fprintf(stderr, "teac_Init: elan3_addvp failed\n"); + teac_Close(result); + return(NULL); + } + + result->vp = elan3_process(result->ctx); + + if (! elan3_set_required_mappings (result->ctx)) { + fprintf(stderr, "teac_Init: elan3_set_required_mappings failed\n"); + teac_Close(result); + return(NULL); + } + + if (!(result->r_event= + (sdramaddr_t**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(sdramaddr_t*) ))) { + fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n", + TEAC_CAP_ENTRIES(cap)*sizeof(sdramaddr_t*)); + teac_Close(result); + return(NULL); + } + if (!(result->r_event[0]= + (sdramaddr_t*)crAlloc( TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS + * sizeof(sdramaddr_t) ))) { + fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n", + TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(sdramaddr_t)); + teac_Close(result); + return(NULL); + } + if (!(result->r_event[0][0]= + elan3_allocElan(result->ctx, E3_EVENT_ALIGN, + TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent)))) { + perror("teac_Init: elan3_allocElan failed for r_event block"); + teac_Close(result); + return(NULL); + } + for (j=1; jr_event[j]= result->r_event[0] + j*NUM_SEND_BUFFERS; + result->r_event[j][0]= + result->r_event[0][0]+j*NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent); + } + for (j=0; jr_event[j][i]= + result->r_event[j][0] + i*sizeof(E3_BlockCopyEvent); + } +#if 0 + crDebug("r_event[0][0] is %x\n",(int)result->r_event[0][0]); +#endif + + if (!(result->m_rcv= + (volatile E3_uint32**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(E3_uint32*) ))) { + fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n", + TEAC_CAP_ENTRIES(cap)*sizeof(E3_uint32*)); + teac_Close(result); + return(NULL); + } + if (!(result->m_rcv[0]= (volatile E3_uint32*) + elan3_allocMain(result->ctx, 0, + TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(E3_uint32)))) { + perror("teac_Init: elan3_allocMain failed for m_rcv block"); + teac_Close(result); + return(NULL); + } + for (i=1; im_rcv[i]= result->m_rcv[0] + i*NUM_SEND_BUFFERS; +#if 0 + crDebug("Base of m_rcv is %lx -> %lx\n", + (long)(result->m_rcv[0]), + (long)teac_main2elan(result->ctx,(void*)(result->m_rcv[0]))); +#endif + + if (!(result->mbuff= (teacMsg**)crAlloc( TEAC_CAP_ENTRIES(cap)*sizeof(teacMsg*) ))) { + fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n", + TEAC_CAP_ENTRIES(cap)*sizeof(teacMsg*)); + teac_Close(result); + return(NULL); + } + if (!(result->mbuff[0]= (teacMsg*) + elan3_allocMain(result->ctx, 8, + TEAC_CAP_ENTRIES(cap)*NUM_SEND_BUFFERS*sizeof(teacMsg)))) { + perror("teac_Init: elan3_allocMain failed for mbuff block"); + teac_Close(result); + return(NULL); + } + for (i=1; imbuff[i]= result->mbuff[0] + i*NUM_SEND_BUFFERS; +#if 0 + crDebug("Base of mbuff is %lx -> %lx\n", + (long)(result->mbuff[0]), + (long)teac_main2elan(result->ctx,result->mbuff[0])); +#endif + + if (!(result->dma= (E3_DMA_MAIN *) + elan3_allocMain(result->ctx, + E3_DMA_ALIGN, sizeof(E3_DMA_MAIN)))) { + perror("teac_Init: elan3_allocMain failed for dma"); + teac_Close(result); + return(NULL); + } + + if (!(result->e_dma= + elan3_allocElan(result->ctx, E3_DMA_ALIGN, sizeof(E3_DMA)))) { + perror("teac_Init: elan3_allocElan failed for e_dma"); + teac_Close(result); + return(NULL); + } + + if (!(result->s_event= + elan3_allocElan(result->ctx, E3_EVENT_ALIGN, + sizeof(E3_BlockCopyEvent)))) { + perror("teac_Init: elan3_allocElan failed for s_event"); + teac_Close(result); + return(NULL); + } +#if 0 + crDebug("s_event is %x\n",(int)result->s_event); +#endif + + if (!(result->sbuf_pull_event[0]= + elan3_allocElan(result->ctx, E3_EVENT_ALIGN, + NUM_SEND_BUFFERS*sizeof(E3_BlockCopyEvent)))) { + perror("teac_Init: elan3_allocElan failed for sbuf_pull_event block"); + teac_Close(result); + return(NULL); + } + for (i=1; isbuf_pull_event[i]= + result->sbuf_pull_event[0]+i*sizeof(E3_BlockCopyEvent); + + if (!(result->rbuf_pull_event= + elan3_allocElan(result->ctx, E3_EVENT_ALIGN, + sizeof(E3_BlockCopyEvent)))) { + perror("teac_Init: elan3_allocElan failed for rbuf_pull_event"); + teac_Close(result); + return(NULL); + } + + if (!(result->m_snd= (E3_uint32 *) + elan3_allocMain(result->ctx, 0, + sizeof(E3_uint32)))) { + perror("teac_Init: elan3_allocMain failed for m_snd"); + teac_Close(result); + return(NULL); + } + + if (!(result->sbuf_ready[0]= (E3_uint32 *) + elan3_allocMain(result->ctx, 0, + NUM_SEND_BUFFERS*sizeof(E3_uint32)))) { + perror("teac_Init: elan3_allocMain failed for sbuf_ready block"); + teac_Close(result); + return(NULL); + } + for (i=1; isbuf_ready[i]= result->sbuf_ready[0] + i; + + if (!(result->sendWrappers[0]= + (SBuffer*)crAlloc(NUM_SEND_BUFFERS*sizeof(SBuffer)))) { + fprintf(stderr,"teac_Init: unable to allocate %d bytes!\n", + NUM_SEND_BUFFERS*sizeof(SBuffer)); + teac_Close(result); + return(NULL); + } + for (i=1; isendWrappers[i]= result->sendWrappers[0] + i; + + if (!(result->rbuf_ready= (E3_uint32 *) + elan3_allocMain(result->ctx, 0, + sizeof(E3_uint32)))) { + perror("teac_Init: elan3_allocMain failed for rbuf_ready"); + teac_Close(result); + return(NULL); + } + + for (i=0; ictx, 8, + E_BUFFER_INITIAL_SIZE))) { + perror("teac_Init: elan3_allocMain failed for buffer block"); + teac_Close(result); + return(NULL); + } + result->sendWrappers[i]->bufId= i; + result->sendWrappers[i]->totSize= E_BUFFER_INITIAL_SIZE; + result->sendWrappers[i]->validSize= 0; + result->sendWrappers[i]->buf= buf; + result->totalSendBufferBytesAllocated += result->sendWrappers[i]->totSize; + } + + elan3_initevent_word (result->ctx, + result->s_event, result->m_snd); + elan3_initevent_word (result->ctx, + result->rbuf_pull_event, result->rbuf_ready); + + for (i=0; ictx, + result->sbuf_pull_event[i], result->sbuf_ready[i]); + } + + for (j=0; jctx, + result->r_event[j][i], &(result->m_rcv[j][i])); + } + + /* Get the message receive events ready to fire, in case something + * comes in before receive gets called. + */ + for (j=0; jctx, result->r_event[j][i], 1); + } + + /* Fire the sbuffer free events, so that the buffers look free when + * the first call to send happens. + */ + for (i=0; ictx, result->sbuf_pull_event[i], 1); + elan3_setevent( result->ctx, result->sbuf_pull_event[i] ); + } + + /* And now we're ready to face the world. */ + elan3_block_inputter (result->ctx, 0); + + return(result); +} + +void teac_Close(Tcomm *tcomm) +{ + int i; + + if (tcomm) { + /* First we have to wait until all pending messages have been + * pulled (assuming they got initialized in the first place). + */ + if ((tcomm->sbuf_pull_event[0] != 0) && (tcomm->sbuf_ready[0] != NULL)) { + for (i=0; ictx, tcomm->sbuf_pull_event[i], + tcomm->sbuf_ready[i], 10); + } + crDebug("All TEAC messages have reported home!\n"); + } + elan3_block_inputter (tcomm->ctx, 1); + + if (tcomm->e_dma != 0) elan3_freeElan(tcomm->ctx, tcomm->e_dma); + if (tcomm->s_event != 0) elan3_freeElan(tcomm->ctx, tcomm->s_event); + if (tcomm->r_event != NULL) { + if (tcomm->r_event[0] != NULL) { + if (tcomm->r_event[0][0] != 0) elan3_freeElan(tcomm->ctx, + tcomm->r_event[0][0]); + crFree(tcomm->r_event[0]); + } + crFree(tcomm->r_event); + } + if (tcomm->sbuf_pull_event[0] != 0) + elan3_freeElan(tcomm->ctx, tcomm->sbuf_pull_event[0]); + if (tcomm->sendWrappers[0] != NULL) { + for (i=0; isendWrappers[i]->buf != NULL) { + elan3_free(tcomm->ctx, tcomm->sendWrappers[i]->buf); + tcomm->totalSendBufferBytesAllocated -= + tcomm->sendWrappers[i]->totSize; + } + } + crFree(tcomm->sendWrappers[0]); + } + if (tcomm->rbuf_pull_event != 0) + elan3_freeElan(tcomm->ctx, tcomm->rbuf_pull_event); + if (tcomm->m_snd != NULL) elan3_free(tcomm->ctx, + (E3_uint32*)tcomm->m_snd); + if (tcomm->m_rcv != NULL) { + if (tcomm->m_rcv[0] != NULL) elan3_free(tcomm->ctx, + (E3_uint32*)tcomm->m_rcv[0]); + crFree(tcomm->m_rcv); + } + if (tcomm->sbuf_ready[0] != NULL) + elan3_free(tcomm->ctx, (E3_uint32*)tcomm->sbuf_ready[0]); + if (tcomm->rbuf_ready != NULL) elan3_free(tcomm->ctx, + (E3_uint32*)tcomm->rbuf_ready); + if (tcomm->mbuff != NULL) { + if (tcomm->mbuff[0] != NULL) elan3_free(tcomm->ctx, tcomm->mbuff[0]); + crFree(tcomm->mbuff); + } +#if (TEAC_CREATE_TYPE==2) + elan3_detach(tcomm->ctx); + elan3_fini(tcomm->ctx); +#else + /* elan3_detach and elan3_destroy seem to crash sometimes in + * these versions. + */ +#endif + } +} + +int teac_Select(Tcomm* tcomm, int *ids, int num_ids, int timeout) +{ + int id; + while (timeout-- > 0) { + if ((id= teac_Poll(tcomm, ids, num_ids)) >= 0) return id; + } + + return -1; +} + +int teac_Poll(Tcomm* tcomm, int *ids, int num_ids) +{ + int i; + int j; + + for (j=0; jpoll_shift) % num_ids; + int thisId= ids[index]; + for (i=0; ictx, &(tcomm->m_rcv[thisId][i]), 1)) { +#ifdef never + tcomm->poll_shift= index; +#endif + return thisId; + } + } + } + + return -1; +} + +int teac_sendBufferAvailable(Tcomm* tcomm) +{ + int i; + for (i=0; ictx, tcomm->sbuf_ready[i], 1)) + return 1; + } + return 0; +} + +SBuffer* teac_getSendBuffer( Tcomm* tcomm, long size ) +{ + /* Find a free send buffer. We'll busy wait in this poll loop + * if necessary. + */ + int i= 0; + while (1) { + if (elan3_pollevent_word(tcomm->ctx, tcomm->sbuf_ready[i], + 1)) break; + if (++i == NUM_SEND_BUFFERS) i= 0; + } + /* We will use this buffer! */ +#if 0 + crDebug("Allocated message buffer %d\n",i); +#endif + *(tcomm->sbuf_ready[i])= 0; /* mark it busy */ + + /* If the associated chunk of memory is smaller than that requested, + * replace it with something larger. + */ + if (tcomm->sendWrappers[i]->totSize < size) { + tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize; + elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf ); + if (!(tcomm->sendWrappers[i]->buf= + (char*)elan3_allocMain(tcomm->ctx, 8, size))) { + perror("teac_getSendBuffer: failed to grow send buffer"); + exit(-1); + } + tcomm->totalSendBufferBytesAllocated += size; + } + tcomm->sendWrappers[i]->totSize= size; + tcomm->sendWrappers[i]->validSize= 0; + return tcomm->sendWrappers[i]; +} + +SBuffer* teac_getUnreadySendBuffer( Tcomm* tcomm, long size ) +{ + SBuffer* result= NULL; + if (!(result= (SBuffer*)crAlloc(sizeof(SBuffer)))) { + fprintf(stderr,"libteac: read_node_map: unable to allocate %d bytes!\n", + sizeof(SBuffer)); + abort(); + } + result->bufId= -1; /* this marks it unready */ +#if 0 + crDebug("Allocated an unready message buffer!\n"); +#endif + + /* Allocate some DMA-able memory */ + if (!(result->buf= (char*)elan3_allocMain(tcomm->ctx, 8, size))) { + perror("teac_getUnreadySendBuffer: failed to allocate elan3 memory"); + exit(-1); + } + result->totSize= size; + result->validSize= 0; + tcomm->totalSendBufferBytesAllocated += result->totSize; + + return result; +} + +SBuffer* teac_makeSendBufferReady( Tcomm* tcomm, SBuffer* buf ) +{ + int i= 0; + /* If the input buffer is already ready, just return it */ + if (buf->bufId >= 0 && buf->bufIdctx, tcomm->sbuf_ready[i], + 1)) break; + if (++i == NUM_SEND_BUFFERS) i= 0; + } + /* We will use this buffer! */ +#if 0 + crDebug("Allocated message buffer %d in makeSendBufferReady\n",i); +#endif + *(tcomm->sbuf_ready[i])= 0; /* mark it busy */ + + /* Substitute the unready payload for the old payload */ + tcomm->totalSendBufferBytesAllocated -= tcomm->sendWrappers[i]->totSize; + elan3_free( tcomm->ctx, tcomm->sendWrappers[i]->buf ); + tcomm->sendWrappers[i]->buf= buf->buf; + + tcomm->sendWrappers[i]->totSize= buf->totSize; + tcomm->sendWrappers[i]->validSize= buf->validSize; + crFree(buf); + return tcomm->sendWrappers[i]; + +} + +int teac_Send( Tcomm* tcomm, int* ids, int num_ids, SBuffer* buf, void *start ) +{ + int vp = tcomm->vp; + int iBuf; + int iDest; + teacMsg *msg; + + /* Complain loudly if this is an unready buffer */ + if (buf->bufId==-1) { + fprintf(stderr,"teac_Send: tried to send an unready buffer!\n"); + return 0; + } + + /* Reality check: is this one of my buffers? */ + if (buf->bufId<0 || buf->bufId>=NUM_SEND_BUFFERS) { + fprintf(stderr,"teac_Send: I don't know this buffer!\n"); + return 0; + } + + /* Reality check: did they write too much into the message? */ + if (buf->validSize > buf->totSize) { + fprintf(stderr,"teac_Send: message too large! (%ld vs %ld)\n", + buf->validSize, buf->totSize); + abort(); + return 0; + } + + iBuf= buf->bufId; + msg = &(tcomm->mbuff[vp][iBuf]); + msg->msgnum = tcomm->msgnum++; + msg->size = buf->validSize; + msg->host = vp; + if ( start != NULL ) + msg->mptr = teac_main2elan( tcomm->ctx, start ); + else + msg->mptr = teac_main2elan(tcomm->ctx, buf->buf); + msg->clr_event = elan3_sdram2elan(tcomm->ctx, tcomm->ctx->sdram, + tcomm->sbuf_pull_event[iBuf]); + msg->new= 1; + + /* Set up the parts of the DMA that are not specific to destination */ + tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_WRITE,DMA_NORMAL,0); + tcomm->dma->dma_size = sizeof(teacMsg); + tcomm->dma->dma_srcEvent = + elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram,tcomm->s_event); + tcomm->dma->dma_source = teac_main2elan(tcomm->ctx, msg); + elan3_primeevent(tcomm->ctx, tcomm->sbuf_pull_event[buf->bufId], num_ids); + + /* Send this message off to each destination */ + for (iDest=0; iDestdma->dma_srcCookieVProc = + elan3_local_cookie(tcomm->ctx, vp, ids[iDest]); + tcomm->dma->dma_destCookieVProc = ids[iDest]; + tcomm->dma->dma_destEvent = + elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram, + tcomm->r_event[vp][iBuf]) + + sdramAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost] + - sdramAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost]; + tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx, msg) + + elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost] + - elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost]; + elan3_primeevent(tcomm->ctx, tcomm->s_event, 1); + *(tcomm->m_snd)= 0; + elan3_putdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma); +#if 0 + crDebug("DMA dest event %x, dest mem %lx\n", + tcomm->dma->dma_destEvent, + (long)tcomm->dma->dma_dest); + crDebug("Mem shifts are %x %x based on %d %d\n", + elanAddrBase[(ids[iDest]/NUM_SEND_BUFFERS) + tcomm->lhost], + elanAddrBase[(vp/NUM_SEND_BUFFERS) + tcomm->lhost], + ids[iDest],vp); + crDebug("Send msg %d in buffer %d to %d (list index %d)...", + msg->msgnum,iBuf, ids[iDest],iDest); +#endif + elan3_waitevent_word(tcomm->ctx, + tcomm->s_event, tcomm->m_snd, ELAN_WAIT_EVENT); +#if 0 + crDebug("message away!\n"); +#endif + } + return 1; +} + +RBuffer* teac_Recv(Tcomm* tcomm, int id) +{ + int vp = tcomm->vp; + RBuffer* result= NULL; + int iEvent= 0; + int iBuf= 0; + int i; + int lowestMsgnum; + + /* poll until we get an incoming message from the given sender */ + while (1) { + if (elan3_pollevent_word(tcomm->ctx, &(tcomm->m_rcv[id][iEvent]), 1)) + break; + if (++iEvent == NUM_SEND_BUFFERS) iEvent= 0; + } + + /* This may not be the earliest event, however. */ + lowestMsgnum= -1; + for (i=0; i %lx\n", + (long)&(tcomm->mbuff[id][i]), + (long)teac_main2elan(tcomm->ctx,(void*)(&tcomm->mbuff[id][i]))); +#endif + if (tcomm->mbuff[id][i].new) { + if ((lowestMsgnum < 0) + || (tcomm->mbuff[id][i].msgnum < (E3_uint32)lowestMsgnum)) { + lowestMsgnum= tcomm->mbuff[id][i].msgnum; + iBuf= i; + } + } + } + if (lowestMsgnum<0) { + fprintf(stderr, + "teac_Recv: internal error: can't find message I just got!\n"); + return NULL; + } + tcomm->mbuff[id][iBuf].new= 0; + tcomm->m_rcv[id][iBuf]= 0; + elan3_primeevent(tcomm->ctx, tcomm->r_event[id][iBuf],1); +#if 0 + crDebug("got msg %d in buffer %d from %d!\n", + tcomm->mbuff[id][iBuf].msgnum, iBuf, id); +#endif + + /* Make some space to put the message when it arrives */ + if (!(result= (RBuffer*)crAlloc(sizeof(RBuffer)))) { + fprintf(stderr,"teac_Recv: unable to allocate %d bytes!\n", + sizeof(RBuffer)); + return NULL; + } +#if 0 + if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8,E_BUFFER_SIZE))) { + perror("teac_Recv: elan3_allocMain failed for buffer"); + return(NULL); + } + result->totSize= E_BUFFER_SIZE; +#endif + if (!(result->buf= (void*)elan3_allocMain(tcomm->ctx, 8, + tcomm->mbuff[id][iBuf].size))) { + perror("teac_Recv: elan3_allocMain failed for buffer"); + return(NULL); + } + result->totSize= tcomm->mbuff[id][iBuf].size; + tcomm->totalRecvBufferBytesAllocated+= result->totSize; + result->validSize= tcomm->mbuff[id][iBuf].size; + result->from= tcomm->mbuff[id][iBuf].host; + result->senderMsgnum= tcomm->mbuff[id][iBuf].msgnum; + + /* Set up the DMA to pull the message */ + tcomm->dma->dma_type = E3_DMA_TYPE(DMA_BYTE,DMA_READ,DMA_NORMAL,0); + tcomm->dma->dma_size = tcomm->mbuff[id][iBuf].size; + tcomm->dma->dma_source = tcomm->mbuff[id][iBuf].mptr; + tcomm->dma->dma_dest = teac_main2elan(tcomm->ctx,result->buf); + tcomm->dma->dma_srcCookieVProc = + elan3_remote_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host); + tcomm->dma->dma_destCookieVProc = + elan3_local_cookie(tcomm->ctx, vp, tcomm->mbuff[id][iBuf].host); + tcomm->dma->dma_srcEvent = tcomm->mbuff[id][iBuf].clr_event; + tcomm->dma->dma_destEvent = + elan3_sdram2elan(tcomm->ctx,tcomm->ctx->sdram, + tcomm->rbuf_pull_event); + + + elan3_primeevent(tcomm->ctx, tcomm->rbuf_pull_event,1); + *(tcomm->rbuf_ready)= 0; + elan3_getdma_main(tcomm->ctx, tcomm->dma, tcomm->e_dma); + elan3_waitevent_word(tcomm->ctx, + tcomm->rbuf_pull_event, + tcomm->rbuf_ready, ELAN_WAIT_EVENT); + + return(result); +} + +int teac_Dispose( Tcomm* tcomm, RBuffer* buf ) +{ + tcomm->totalRecvBufferBytesAllocated -= buf->totSize; + elan3_free(tcomm->ctx, buf->buf); + crFree(buf); + return 0; +} + +char* teac_getTcommString(Tcomm *c, char* buf, int buflen) +{ + snprintf(buf,buflen-1, + "", + c->vp,c->lhost,c->hhost,c->lctx,c->hctx,c->msgnum); + buf[buflen-1]= '\0'; + return buf; +} + +char* teac_getConnString(Tcomm *c, int id, char* buf, int buflen) +{ + int rel_rank= id%4; + int node= ((id-rel_rank)/4) + c->lhost; + snprintf(buf,buflen-1,"vp %d, <%s>:%d",id, + hosts[hostsIndex[node]].name,rel_rank); + buf[buflen-1]= '\0'; +#if 0 + crDebug("getConnString: lookup id %d -> %d %d -> %s\n",id,rel_rank,node,buf); +#endif + return buf; +} + +int teac_getConnId(Tcomm *c, const char* host, int rank) +{ + int node= trans_host(host); +#if 0 + crDebug("getConnId: <%s> %d %d maps to %d %d\n", + host, rank, c->lhost, node, (4*(node - c->lhost) + (rank%4))); +#endif + return (4*(node - c->lhost) + (rank%4)); +} + +int teac_getHostInfo(Tcomm *c, char* host, const int hostLength, + int* railMask, int *nodeId, + long* sdramBaseAddr, long* elanBaseAddr) +{ +#if (TEAC_DEVINFO_TYPE == 2) + ELAN_DEVINFO info; + ELAN_POSITION position; +#else + ELAN3_DEVINFO info; +#endif + char* here; + + if (gethostname(host,hostLength-1)) { + perror("Can't get my own host name"); + return 0; + } + host[hostLength-1]= '\0'; + if ((here= crStrchr(host,'.')) != NULL) *here= '\0'; + +#if (TEAC_DEVINFO_TYPE == 2) + (void)elan3_get_devinfo(c->ctx, &info); + (void)elan3_get_position(c->ctx, &position); + *nodeId= position.pos_nodeid; +#elif (TEAC_DEVINFO_TYPE == 1) + elan3_devinfo(0, &info); + *nodeId= info.Position.NodeId; +#else + elan3_devinfo(0, &info); + *nodeId= info.NodeId; +#endif + +#if (TEAC_CAP_TYPE == 2) + *railMask= c->cap.cap_railmask; +#else + *railMask= c->cap.RailMask; +#endif + + *sdramBaseAddr= (int)c->r_event[0][0]; + + *elanBaseAddr= (long)teac_main2elan(c->ctx,(void*)c->m_rcv[0]); + return 1; +} diff --git a/src/VBox/GuestHost/OpenGL/util/list.c b/src/VBox/GuestHost/OpenGL/util/list.c new file mode 100644 index 00000000..83dcfaba --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/list.c @@ -0,0 +1,314 @@ +#include "cr_list.h" +#include "cr_error.h" +#include "cr_mem.h" + +#ifndef CR_TESTING_LIST /* vbox */ +# define CR_TESTING_LIST 0 /* vbox */ +#endif /* vbox */ +#if CR_TESTING_LIST +#include +#include +#include +#endif + +struct CRListIterator { + void *element; + CRListIterator *prev; + CRListIterator *next; +}; + +struct CRList { + CRListIterator *head; + CRListIterator *tail; + unsigned size; +}; + +CRList *crAllocList( void ) +{ + CRList *l = crAlloc( sizeof( CRList ) ); + CRASSERT( l ); + + l->head = crAlloc( sizeof( CRListIterator ) ); + CRASSERT( l->head ); + + l->tail = crAlloc( sizeof( CRListIterator ) ); + CRASSERT( l->tail ); + + l->head->prev = NULL; + l->head->next = l->tail; + + l->tail->prev = l->head; + l->tail->next = NULL; + + l->size = 0; + + return l; +} + +void crFreeList( CRList *l ) +{ + CRListIterator *t1; + + CRASSERT( l != NULL ); + t1 = l->head; + while ( t1 != NULL ) + { + CRListIterator *t2 = t1; + t1 = t1->next; + t2->prev = NULL; + t2->next = NULL; + t2->element = NULL; + crFree( t2 ); + } + l->size = 0; + crFree( l ); +} + +unsigned crListSize( const CRList *l ) +{ + return l->size; +} + +int crListIsEmpty( const CRList *l ) +{ + CRASSERT( l != NULL ); + return l->size == 0; +} + +void crListInsert( CRList *l, CRListIterator *iter, void *elem ) +{ + CRListIterator *p; + + CRASSERT( l != NULL ); + CRASSERT( iter != NULL ); + CRASSERT( iter != l->head ); + + p = crAlloc( sizeof( CRListIterator ) ); + CRASSERT( p != NULL ); + p->prev = iter->prev; + p->next = iter; + p->prev->next = p; + iter->prev = p; + + p->element = elem; + l->size++; +} + +void crListErase( CRList *l, CRListIterator *iter ) +{ + CRASSERT( l != NULL ); + CRASSERT( iter != NULL ); + CRASSERT( iter != l->head ); + CRASSERT( iter != l->tail ); + CRASSERT( l->size > 0 ); + + iter->next->prev = iter->prev; + iter->prev->next = iter->next; + + iter->prev = NULL; + iter->next = NULL; + iter->element = NULL; + crFree( iter ); + + l->size--; +} + +void crListClear( CRList *l ) +{ + CRASSERT( l != NULL ); + while ( !crListIsEmpty( l ) ) + { + crListPopFront( l ); + } +} + +void crListPushBack( CRList *l, void *elem ) +{ + CRASSERT( l != NULL ); + crListInsert( l, l->tail, elem ); +} + +void crListPushFront( CRList *l, void *elem ) +{ + CRASSERT( l != NULL ); + crListInsert( l, l->head->next, elem ); +} + +void crListPopBack( CRList *l ) +{ + CRASSERT( l != NULL ); + CRASSERT( l->size > 0 ); + crListErase( l, l->tail->prev ); +} + +void crListPopFront( CRList *l ) +{ + CRASSERT( l != NULL ); + CRASSERT( l->size > 0 ); + crListErase( l, l->head->next ); +} + +void *crListFront( CRList *l ) +{ + CRASSERT( l != NULL ); + CRASSERT( l->size > 0 ); + CRASSERT( l->head != NULL ); + CRASSERT( l->head->next != NULL ); + return l->head->next->element; +} + +void *crListBack( CRList *l ) +{ + CRASSERT( l != NULL ); + CRASSERT( l->size > 0 ); + CRASSERT( l->tail != NULL ); + CRASSERT( l->tail->prev != NULL ); + return l->tail->prev->element; +} + +CRListIterator *crListBegin( CRList *l ) +{ + CRASSERT( l != NULL ); + CRASSERT( l->head != NULL ); + CRASSERT( l->head->next != NULL ); + return l->head->next; +} + +CRListIterator *crListEnd( CRList *l ) +{ + CRASSERT( l != NULL ); + CRASSERT( l->tail != NULL ); + return l->tail; +} + +CRListIterator *crListNext( CRListIterator *iter ) +{ + CRASSERT( iter != NULL ); + CRASSERT( iter->next != NULL ); + return iter->next; +} + +CRListIterator *crListPrev( CRListIterator *iter ) +{ + CRASSERT( iter != NULL ); + CRASSERT( iter->prev != NULL ); + return iter->prev; +} + +void *crListElement( CRListIterator *iter ) +{ + CRASSERT( iter != NULL ); + return iter->element; +} + +CRListIterator *crListFind( CRList *l, void *element, CRListCompareFunc compare ) +{ + CRListIterator *iter; + + CRASSERT( l != NULL ); + CRASSERT( compare ); + + for ( iter = crListBegin( l ); iter != crListEnd( l ); iter = crListNext( iter ) ) + { + if ( compare( element, iter->element ) == 0 ) + { + return iter; + } + } + return NULL; +} + +void crListApply( CRList *l, CRListApplyFunc apply, void *arg ) +{ + CRListIterator *iter; + + CRASSERT( l != NULL ); + for ( iter = crListBegin( l ); iter != crListEnd( l ); iter = crListNext( iter ) ) + { + apply( iter->element, arg ); + } +} + +#if CR_TESTING_LIST + +static void printElement( void *elem, void *arg ) +{ + char *s = elem; + FILE *fp = arg; + + CRASSERT( s != NULL ); + CRASSERT( fp != NULL ); + fprintf( fp, "%s ", s ); +} + +static void printList( CRList *l ) +{ + CRASSERT( l != NULL ); + crListApply( l, printElement, stderr ); + fprintf( stderr, "\n" ); +} + +static int elementCompare( void *a, void *b ) +{ + return strcmp( a, b ); +} + +int main( void ) +{ + char *names[] = { "a", "b", "c", "d", "e", "f" }; + CRList *l; + CRListIterator *iter; + int i, n; + + n = sizeof( names ) / sizeof( names[0] ); + fprintf( stderr, "n=%d\n", n ); + + l = crAllocList( ); + for ( i = 0; i < n; ++i ) + { + crListPushBack( l, names[i] ); + } + printList( l ); + + crListPushFront( l, "x" ); + printList( l ); + + crListPushBack( l, "y" ); + printList( l ); + + crListPopFront( l ); + printList( l ); + + crListPopBack( l ); + printList( l ); + + iter = crListFind( l, "c", elementCompare ); + CRASSERT( iter != NULL ); + crListInsert( l, iter, "z" ); + printList( l ); + + iter = crListFind( l, "d", elementCompare ); + CRASSERT( iter != NULL ); + crListErase( l, iter ); + printList( l ); + + crListClear( l ); + printList( l ); + fprintf( stderr, "size: %u\n", crListSize( l ) ); + fprintf( stderr, "is empty: %d\n", crListIsEmpty( l ) ); + + crListPushBack( l, "w" ); + crListPushBack( l, "t" ); + crListPushBack( l, "c" ); + printList( l ); + + fprintf( stderr, "front: %s\n", ( char * ) crListFront( l ) ); + fprintf( stderr, "back: %s\n", ( char * ) crListBack( l ) ); + fprintf( stderr, "size: %u\n", crListSize( l ) ); + fprintf( stderr, "is empty: %d\n", crListIsEmpty( l ) ); + + crFreeList( l ); + return 0; +} + +#endif /* CR_TESTING_LIST */ diff --git a/src/VBox/GuestHost/OpenGL/util/lowercase.py b/src/VBox/GuestHost/OpenGL/util/lowercase.py new file mode 100644 index 00000000..eeb362cc --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/lowercase.py @@ -0,0 +1,27 @@ +# Copyright (c) 2001, Stanford University +# All rights reserved. +# +# See the file LICENSE.txt for information on redistributing this software. + +import sys,string + +stub_common.CopyrightC() + +print "char lowercase[256] = {" + +NUM_COLS = 8 + +count = 0 +for num in range(256): + if count%NUM_COLS == 0: + sys.stdout.write( '\t' ) + the_char = chr(num); + if num != 255: + print ("'\%03o'," % ord(string.lower(the_char))), + else: + print ("'\%03o'" % ord(string.lower(the_char))), + count += 1 + if count%NUM_COLS == 0: + print "" + +print "};" diff --git a/src/VBox/GuestHost/OpenGL/util/matrix.c b/src/VBox/GuestHost/OpenGL/util/matrix.c new file mode 100644 index 00000000..b4335400 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/matrix.c @@ -0,0 +1,510 @@ + +#include +#include +#include "cr_matrix.h" +#include "cr_mem.h" + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + + +static const CRmatrix identity_matrix = { + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 +}; + + +/* + * Initialize the given matrix to the identity. + */ +void +crMatrixInit(CRmatrix *m) +{ + *m = identity_matrix; +} + + +/* + * Parse a string of 16 floats to initialize a matrix (row major order). + * If there's a parsing error, initialize the matrix to the identity. + */ +void +crMatrixInitFromString(CRmatrix *m, const char *s) +{ + const char *fmt = "%f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f"; + const char *fmtb = "[ %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f, %f ]"; + int n = sscanf(s, (s[0] == '[' ? fmtb : fmt), + &m->m00, &m->m01, &m->m02, &m->m03, + &m->m10, &m->m11, &m->m12, &m->m13, + &m->m20, &m->m21, &m->m22, &m->m23, + &m->m30, &m->m31, &m->m32, &m->m33); + if (n != 16) { + /* insufficient parameters */ + crMatrixInit(m); + } +} + + +/* + * Initialize a matrix from an array of 16 values. + */ +void +crMatrixInitFromFloats(CRmatrix *m, const float *v) +{ + m->m00 = v[0]; + m->m01 = v[1]; + m->m02 = v[2]; + m->m03 = v[3]; + m->m10 = v[4]; + m->m11 = v[5]; + m->m12 = v[6]; + m->m13 = v[7]; + m->m20 = v[8]; + m->m21 = v[9]; + m->m22 = v[10]; + m->m23 = v[11]; + m->m30 = v[12]; + m->m31 = v[13]; + m->m32 = v[14]; + m->m33 = v[15]; +} + + +void +crMatrixInitFromDoubles(CRmatrix *m, const double *v) +{ + m->m00 = (float) v[0]; + m->m01 = (float) v[1]; + m->m02 = (float) v[2]; + m->m03 = (float) v[3]; + m->m10 = (float) v[4]; + m->m11 = (float) v[5]; + m->m12 = (float) v[6]; + m->m13 = (float) v[7]; + m->m20 = (float) v[8]; + m->m21 = (float) v[9]; + m->m22 = (float) v[10]; + m->m23 = (float) v[11]; + m->m30 = (float) v[12]; + m->m31 = (float) v[13]; + m->m32 = (float) v[14]; + m->m33 = (float) v[15]; +} + + +/* useful for debugging */ +void +crMatrixPrint(const char *msg, const CRmatrix *m) +{ + printf("%s\n", msg); + printf(" %f %f %f %f\n", m->m00, m->m10, m->m20, m->m30); + printf(" %f %f %f %f\n", m->m01, m->m11, m->m21, m->m31); + printf(" %f %f %f %f\n", m->m02, m->m12, m->m22, m->m32); + printf(" %f %f %f %f\n", m->m03, m->m13, m->m23, m->m33); +} + + +void +crMatrixGetFloats(float *values, const CRmatrix *m) +{ + values[0] = m->m00; + values[1] = m->m01; + values[2] = m->m02; + values[3] = m->m03; + values[4] = m->m10; + values[5] = m->m11; + values[6] = m->m12; + values[7] = m->m13; + values[8] = m->m20; + values[9] = m->m21; + values[10] = m->m22; + values[11] = m->m23; + values[12] = m->m30; + values[13] = m->m31; + values[14] = m->m32; + values[15] = m->m33; +} + + +/* Return 1 if the matrices are equal, return 0 otherwise. + */ +int +crMatrixIsEqual(const CRmatrix *m, const CRmatrix *n) +{ + return crMemcmp(m, n, sizeof(CRmatrix)) == 0; +} + + +/* + * Test if matrix is identity + */ +int +crMatrixIsIdentity(const CRmatrix *m) +{ + return crMemcmp(m, &identity_matrix, sizeof(CRmatrix)) == 0; +} + + +/* + * Test if matrix is orthographic projection matrix. + */ +int +crMatrixIsOrthographic(const CRmatrix *m) +{ + return m->m33 != 0.0; +} + + +void +crMatrixCopy(CRmatrix *dest, const CRmatrix *src) +{ + crMemcpy(dest, src, sizeof(CRmatrix)); +} + + +/* + * Compute p = a * b + */ +void +crMatrixMultiply(CRmatrix *p, const CRmatrix *a, const CRmatrix *b) +{ + CRmatrix t; /* temporary result, in case p = a or p = b */ + t.m00 = a->m00 * b->m00 + a->m10 * b->m01 + a->m20 * b->m02 + a->m30 * b->m03; + t.m01 = a->m01 * b->m00 + a->m11 * b->m01 + a->m21 * b->m02 + a->m31 * b->m03; + t.m02 = a->m02 * b->m00 + a->m12 * b->m01 + a->m22 * b->m02 + a->m32 * b->m03; + t.m03 = a->m03 * b->m00 + a->m13 * b->m01 + a->m23 * b->m02 + a->m33 * b->m03; + t.m10 = a->m00 * b->m10 + a->m10 * b->m11 + a->m20 * b->m12 + a->m30 * b->m13; + t.m11 = a->m01 * b->m10 + a->m11 * b->m11 + a->m21 * b->m12 + a->m31 * b->m13; + t.m12 = a->m02 * b->m10 + a->m12 * b->m11 + a->m22 * b->m12 + a->m32 * b->m13; + t.m13 = a->m03 * b->m10 + a->m13 * b->m11 + a->m23 * b->m12 + a->m33 * b->m13; + t.m20 = a->m00 * b->m20 + a->m10 * b->m21 + a->m20 * b->m22 + a->m30 * b->m23; + t.m21 = a->m01 * b->m20 + a->m11 * b->m21 + a->m21 * b->m22 + a->m31 * b->m23; + t.m22 = a->m02 * b->m20 + a->m12 * b->m21 + a->m22 * b->m22 + a->m32 * b->m23; + t.m23 = a->m03 * b->m20 + a->m13 * b->m21 + a->m23 * b->m22 + a->m33 * b->m23; + t.m30 = a->m00 * b->m30 + a->m10 * b->m31 + a->m20 * b->m32 + a->m30 * b->m33; + t.m31 = a->m01 * b->m30 + a->m11 * b->m31 + a->m21 * b->m32 + a->m31 * b->m33; + t.m32 = a->m02 * b->m30 + a->m12 * b->m31 + a->m22 * b->m32 + a->m32 * b->m33; + t.m33 = a->m03 * b->m30 + a->m13 * b->m31 + a->m23 * b->m32 + a->m33 * b->m33; + *p = t; +} + + +void +crMatrixTransformPointf(const CRmatrix *m, GLvectorf *p) +{ + float x = p->x; + float y = p->y; + float z = p->z; + float w = p->w; + + p->x = m->m00*x + m->m10*y + m->m20*z + m->m30*w; + p->y = m->m01*x + m->m11*y + m->m21*z + m->m31*w; + p->z = m->m02*x + m->m12*y + m->m22*z + m->m32*w; + p->w = m->m03*x + m->m13*y + m->m23*z + m->m33*w; +} + + +void +crMatrixTransformPointd(const CRmatrix *m, GLvectord *p) +{ + double x = p->x; + double y = p->y; + double z = p->z; + double w = p->w; + + p->x = (double) (m->m00*x + m->m10*y + m->m20*z + m->m30*w); + p->y = (double) (m->m01*x + m->m11*y + m->m21*z + m->m31*w); + p->z = (double) (m->m02*x + m->m12*y + m->m22*z + m->m32*w); + p->w = (double) (m->m03*x + m->m13*y + m->m23*z + m->m33*w); +} + + +void +crMatrixInvertTranspose(CRmatrix *inv, const CRmatrix *mat) +{ + /* Taken from Pomegranate code, trans.c. + * Note: We have our data structures reversed + */ + const float m00 = mat->m00; + const float m01 = mat->m10; + const float m02 = mat->m20; + const float m03 = mat->m30; + + const float m10 = mat->m01; + const float m11 = mat->m11; + const float m12 = mat->m21; + const float m13 = mat->m31; + + const float m20 = mat->m02; + const float m21 = mat->m12; + const float m22 = mat->m22; + const float m23 = mat->m32; + + const float m30 = mat->m03; + const float m31 = mat->m13; + const float m32 = mat->m23; + const float m33 = mat->m33; + +#define det3x3(a1, a2, a3, b1, b2, b3, c1, c2, c3) \ + (a1 * (b2 * c3 - b3 * c2) + \ + b1 * (c2 * a3 - a2 * c3) + \ + c1 * (a2 * b3 - a3 * b2)) + + const float cof00 = det3x3( m11, m12, m13, + m21, m22, m23, + m31, m32, m33 ); + + const float cof01 = -det3x3( m12, m13, m10, + m22, m23, m20, + m32, m33, m30 ); + + const float cof02 = det3x3( m13, m10, m11, + m23, m20, m21, + m33, m30, m31 ); + + const float cof03 = -det3x3( m10, m11, m12, + m20, m21, m22, + m30, m31, m32 ); + + + const float inv_det = 1.0f / ( m00 * cof00 + m01 * cof01 + + m02 * cof02 + m03 * cof03 ); + + + const float cof10 = -det3x3( m21, m22, m23, + m31, m32, m33, + m01, m02, m03 ); + + const float cof11 = det3x3( m22, m23, m20, + m32, m33, m30, + m02, m03, m00 ); + + const float cof12 = -det3x3( m23, m20, m21, + m33, m30, m31, + m03, m00, m01 ); + + const float cof13 = det3x3( m20, m21, m22, + m30, m31, m32, + m00, m01, m02 ); + + + + const float cof20 = det3x3( m31, m32, m33, + m01, m02, m03, + m11, m12, m13 ); + + const float cof21 = -det3x3( m32, m33, m30, + m02, m03, m00, + m12, m13, m10 ); + + const float cof22 = det3x3( m33, m30, m31, + m03, m00, m01, + m13, m10, m11 ); + + const float cof23 = -det3x3( m30, m31, m32, + m00, m01, m02, + m10, m11, m12 ); + + + const float cof30 = -det3x3( m01, m02, m03, + m11, m12, m13, + m21, m22, m23 ); + + const float cof31 = det3x3( m02, m03, m00, + m12, m13, m10, + m22, m23, m20 ); + + const float cof32 = -det3x3( m03, m00, m01, + m13, m10, m11, + m23, m20, m21 ); + + const float cof33 = det3x3( m00, m01, m02, + m10, m11, m12, + m20, m21, m22 ); + +#undef det3x3 + + /* Perform transpose in asignment */ + + inv->m00 = cof00 * inv_det; inv->m10 = cof01 * inv_det; + inv->m20 = cof02 * inv_det; inv->m30 = cof03 * inv_det; + + inv->m01 = cof10 * inv_det; inv->m11 = cof11 * inv_det; + inv->m21 = cof12 * inv_det; inv->m31 = cof13 * inv_det; + + inv->m02 = cof20 * inv_det; inv->m12 = cof21 * inv_det; + inv->m22 = cof22 * inv_det; inv->m32 = cof23 * inv_det; + + inv->m03 = cof30 * inv_det; inv->m13 = cof31 * inv_det; + inv->m23 = cof32 * inv_det; inv->m33 = cof33 * inv_det; +} + +void +crMatrixTranspose(CRmatrix *t, const CRmatrix *m) +{ + CRmatrix c; + + c.m00 = m->m00; c.m10 = m->m01; c.m20 = m->m02; c.m30 = m->m03; + c.m01 = m->m10; c.m11 = m->m11; c.m21 = m->m12; c.m31 = m->m13; + c.m02 = m->m20; c.m12 = m->m21; c.m22 = m->m22; c.m32 = m->m23; + c.m03 = m->m30; c.m13 = m->m31; c.m23 = m->m32; c.m33 = m->m33; + + *t = c; +} + +/* + * Apply a translation to the given matrix. + */ +void +crMatrixTranslate(CRmatrix *m, float x, float y, float z) +{ + m->m30 = m->m00 * x + m->m10 * y + m->m20 * z + m->m30; + m->m31 = m->m01 * x + m->m11 * y + m->m21 * z + m->m31; + m->m32 = m->m02 * x + m->m12 * y + m->m22 * z + m->m32; + m->m33 = m->m03 * x + m->m13 * y + m->m23 * z + m->m33; +} + + +/* + * Apply a rotation to the given matrix. + */ +void +crMatrixRotate(CRmatrix *m, float angle, float x, float y, float z) +{ + const float c = (float) cos(angle * M_PI / 180.0f); + const float one_minus_c = 1.0f - c; + const float s = (float) sin(angle * M_PI / 180.0f); + const float v_len = (float) sqrt (x*x + y*y + z*z); + float x_one_minus_c; + float y_one_minus_c; + float z_one_minus_c; + CRmatrix rot; + + /* Begin/end Checking and flushing will be done by MultMatrix. */ + + if (v_len == 0.0f) + return; + + /* Normalize the vector */ + if (v_len != 1.0f) { + x /= v_len; + y /= v_len; + z /= v_len; + } + /* compute some common values */ + x_one_minus_c = x * one_minus_c; + y_one_minus_c = y * one_minus_c; + z_one_minus_c = z * one_minus_c; + /* Generate the terms of the rotation matrix + ** from pg 325 OGL 1.1 Blue Book. + */ + rot.m00 = x * x_one_minus_c + c; + rot.m01 = x * y_one_minus_c + z * s; + rot.m02 = x * z_one_minus_c - y * s; + rot.m03 = 0.0f; + rot.m10 = y * x_one_minus_c - z * s; + rot.m11 = y * y_one_minus_c + c; + rot.m12 = y * z_one_minus_c + x * s; + rot.m13 = 0.0f; + rot.m20 = z * x_one_minus_c + y * s; + rot.m21 = z * y_one_minus_c - x * s; + rot.m22 = z * z_one_minus_c + c; + rot.m23 = 0.0f; + rot.m30 = 0.0f; + rot.m31 = 0.0f; + rot.m32 = 0.0f; + rot.m33 = 1.0f; + crMatrixMultiply(m, m, &rot); +} + + +/* + * Apply a scale to the given matrix. + */ +void +crMatrixScale(CRmatrix *m, float x, float y, float z) +{ + m->m00 *= x; + m->m01 *= x; + m->m02 *= x; + m->m03 *= x; + m->m10 *= y; + m->m11 *= y; + m->m12 *= y; + m->m13 *= y; + m->m20 *= z; + m->m21 *= z; + m->m22 *= z; + m->m23 *= z; +} + + +/* + * Make a projection matrix from frustum parameters. + */ +void +crMatrixFrustum(CRmatrix *m, + float left, float right, + float bottom, float top, + float zNear, float zFar) +{ + CRmatrix f; + + f.m00 = (2.0f * zNear) / (right - left); + f.m01 = 0.0; + f.m02 = 0.0; + f.m03 = 0.0; + + f.m10 = 0.0; + f.m11 = (2.0f * zNear) / (top - bottom); + f.m12 = 0.0; + f.m13 = 0.0; + + f.m20 = (right + left) / (right - left); + f.m21 = (top + bottom) / (top - bottom); + f.m22 = (-zNear - zFar) / (zFar - zNear); + f.m23 = -1.0; + + f.m30 = 0.0; + f.m31 = 0.0; + f.m32 = (2.0f * zFar * zNear) / (zNear - zFar); + f.m33 = 0.0; + + crMatrixMultiply(m, m, &f); +} + + +void +crMatrixOrtho(CRmatrix *m, + float left, float right, + float bottom, float top, + float znear, float zfar) +{ + CRmatrix ortho; + + ortho.m00 = 2.0f / (right - left); + ortho.m01 = 0.0; + ortho.m02 = 0.0; + ortho.m03 = 0.0; + + ortho.m10 = 0.0; + ortho.m11 = 2.0f / (top - bottom); + ortho.m12 = 0.0; + ortho.m13 = 0.0; + + ortho.m20 = 0.0; + ortho.m21 = 0.0; + ortho.m22 = -2.0f / (zfar - znear); + ortho.m23 = 0.0; + + ortho.m30 = -(right + left) / (right - left); + ortho.m31 = -(top + bottom) / (top - bottom); + ortho.m32= -(zfar + znear) / (zfar - znear); + ortho.m33 = 1.0; + + crMatrixMultiply(m, m, &ortho); +} + diff --git a/src/VBox/GuestHost/OpenGL/util/mem.c b/src/VBox/GuestHost/OpenGL/util/mem.c new file mode 100644 index 00000000..c28c4f55 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/mem.c @@ -0,0 +1,160 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "cr_error.h" + +#include +#include + +#include +#include + +#if DEBUG_MEM +#include +#define THRESHOLD 100 * 1024 + +#undef crAlloc +#undef crCalloc + +/* Need these stubs because util.def says we're always exporting crAlloc + * and crCalloc. + */ +extern void *crAlloc( unsigned int bytes ); +void *crAlloc( unsigned int bytes ) +{ + return NULL; +} + +extern void *crCalloc( unsigned int bytes ); +void *crCalloc( unsigned int bytes ) +{ + return NULL; +} +#endif /* DEBUG_MEM */ + + + +#if DEBUG_MEM +static void *_crAlloc( unsigned int nbytes ) +#else +DECLEXPORT(void) *crAlloc( unsigned int nbytes ) +#endif +{ +#ifdef VBOX + void *ret = RTMemAlloc( nbytes ); +#else + void *ret = malloc( nbytes ); +#endif + if (!ret) { + crError( "Out of memory trying to allocate %d bytes!", nbytes ); + abort(); + } + return ret; +} + +void *crAllocDebug( unsigned int nbytes, const char *file, int line ) +{ +#if DEBUG_MEM + if (nbytes >= THRESHOLD) + fprintf(stderr, "crAllocDebug(%d bytes) in %s at %d\n", nbytes, file, line); + return _crAlloc(nbytes); +#else + RT_NOREF2(file, line); + return crAlloc(nbytes); +#endif +} + +#if DEBUG_MEM +static void *_crCalloc( unsigned int nbytes ) +#else +DECLEXPORT(void) *crCalloc( unsigned int nbytes ) +#endif +{ +#ifdef VBOX + void *ret = RTMemAlloc( nbytes ); +#else + void *ret = malloc( nbytes ); +#endif + if (!ret) { + crError( "Out of memory trying to (c)allocate %d bytes!", nbytes ); + abort(); + } + crMemset( ret, 0, nbytes ); + return ret; +} + +void *crCallocDebug( unsigned int nbytes, const char *file, int line ) +{ +#if DEBUG_MEM + if (nbytes >= THRESHOLD) + fprintf(stderr, "crCallocDebug(%d bytes) in %s at %d\n", nbytes, file, line); + return _crCalloc(nbytes); +#else + RT_NOREF2(file, line); + return crCalloc(nbytes); +#endif +} + +DECLEXPORT(void) crRealloc( void **ptr, unsigned int nbytes ) +{ + if ( *ptr == NULL ) + { +#if DEBUG_MEM + *ptr = _crAlloc( nbytes ); +#else + *ptr = crAlloc( nbytes ); +#endif + } + else + { +#ifdef VBOX + *ptr = RTMemRealloc( *ptr, nbytes ); +#else + *ptr = realloc( *ptr, nbytes ); +#endif + if (*ptr == NULL) + crError( "Couldn't realloc %d bytes!", nbytes ); + } +} + +DECLEXPORT(void) crFree( void *ptr ) +{ +#ifdef VBOX + if (ptr) + RTMemFree(ptr); +#else + if (ptr) + free(ptr); +#endif +} + +DECLEXPORT(void) crMemcpy( void *dst, const void *src, unsigned int bytes ) +{ + CRASSERT(dst || 0==bytes); + CRASSERT(src || 0==bytes); + (void) memcpy( dst, src, bytes ); +} + +DECLEXPORT(void) crMemset( void *ptr, int value, unsigned int bytes ) +{ + CRASSERT(ptr); + memset( ptr, value, bytes ); +} + +DECLEXPORT(void) crMemZero( void *ptr, unsigned int bytes ) +{ + CRASSERT(ptr); + memset( ptr, 0, bytes ); +} + +DECLEXPORT(int) crMemcmp( const void *p1, const void *p2, unsigned int bytes ) +{ + CRASSERT(p1); + CRASSERT(p2); + return memcmp( p1, p2, bytes ); +} + diff --git a/src/VBox/GuestHost/OpenGL/util/net.c b/src/VBox/GuestHost/OpenGL/util/net.c new file mode 100644 index 00000000..1069e835 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/net.c @@ -0,0 +1,1406 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include +#include +#include +#include +#include + +#ifdef WINDOWS +#define WIN32_LEAN_AND_MEAN +#include +#else +#include +#endif + +#include "cr_mem.h" +#include "cr_error.h" +#include "cr_string.h" +#include "cr_url.h" +#include "cr_net.h" +#include "cr_netserver.h" +#include "cr_pixeldata.h" +#include "cr_environment.h" +#include "cr_endian.h" +#include "cr_bufpool.h" +#include "cr_threads.h" +#include "net_internals.h" + + +#define CR_MINIMUM_MTU 1024 + +#define CR_INITIAL_RECV_CREDITS ( 1 << 21 ) /* 2MB */ + +/* Allow up to four processes per node. . . */ +#define CR_QUADRICS_LOWEST_RANK 0 +#define CR_QUADRICS_HIGHEST_RANK 3 + +static struct { + int initialized; /* flag */ + CRNetReceiveFuncList *recv_list; /* what to do with arriving packets */ + CRNetCloseFuncList *close_list; /* what to do when a client goes down */ + + /* Number of connections using each type of interface: */ + int use_tcpip; + int use_ib; + int use_file; + int use_udp; + int use_gm; + int use_sdp; + int use_teac; + int use_tcscomm; + int use_hgcm; + + int num_clients; /* total number of clients (unused?) */ + +#ifdef CHROMIUM_THREADSAFE + CRmutex mutex; +#endif + int my_rank; /* Teac/TSComm only */ +} cr_net; + + + +/** + * Helper routine used by both crNetConnectToServer() and crNetAcceptClient(). + * Call the protocol-specific Init() and Connection() functions. + * + */ +static void +InitConnection(CRConnection *conn, const char *protocol, unsigned int mtu +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif + ) +{ + if (!crStrcmp(protocol, "devnull")) + { + crDevnullInit(cr_net.recv_list, cr_net.close_list, mtu); + crDevnullConnection(conn); + } + else if (!crStrcmp(protocol, "file")) + { + cr_net.use_file++; + crFileInit(cr_net.recv_list, cr_net.close_list, mtu); + crFileConnection(conn); + } + else if (!crStrcmp(protocol, "swapfile")) + { + /* file with byte-swapping */ + cr_net.use_file++; + crFileInit(cr_net.recv_list, cr_net.close_list, mtu); + crFileConnection(conn); + conn->swap = 1; + } + else if (!crStrcmp(protocol, "tcpip")) + { + cr_net.use_tcpip++; + crTCPIPInit(cr_net.recv_list, cr_net.close_list, mtu); + crTCPIPConnection(conn); + } + else if (!crStrcmp(protocol, "udptcpip")) + { + cr_net.use_udp++; + crUDPTCPIPInit(cr_net.recv_list, cr_net.close_list, mtu); + crUDPTCPIPConnection(conn); + } +#ifdef VBOX_WITH_HGCM + else if (!crStrcmp(protocol, "vboxhgcm")) + { + cr_net.use_hgcm++; + crVBoxHGCMInit(cr_net.recv_list, cr_net.close_list, mtu); + crVBoxHGCMConnection(conn +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , pHgsmi +#endif + ); + } +#endif +#ifdef GM_SUPPORT + else if (!crStrcmp(protocol, "gm")) + { + cr_net.use_gm++; + crGmInit(cr_net.recv_list, cr_net.close_list, mtu); + crGmConnection(conn); + } +#endif +#ifdef TEAC_SUPPORT + else if (!crStrcmp(protocol, "quadrics")) + { + cr_net.use_teac++; + crTeacInit(cr_net.recv_list, cr_net.close_list, mtu); + crTeacConnection(conn); + } +#endif +#ifdef TCSCOMM_SUPPORT + else if (!crStrcmp(protocol, "quadrics-tcscomm")) + { + cr_net.use_tcscomm++; + crTcscommInit(cr_net.recv_list, cr_net.close_list, mtu); + crTcscommConnection(conn); + } +#endif +#ifdef SDP_SUPPORT + else if (!crStrcmp(protocol, "sdp")) + { + cr_net.use_sdp++; + crSDPInit(cr_net.recv_list, cr_net.close_list, mtu); + crSDPConnection(conn); + } +#endif +#ifdef IB_SUPPORT + else if (!crStrcmp(protocol, "ib")) + { + cr_net.use_ib++; + crDebug("Calling crIBInit()"); + crIBInit(cr_net.recv_list, cr_net.close_list, mtu); + crIBConnection(conn); + crDebug("Done Calling crIBInit()"); + } +#endif +#ifdef HP_MULTICAST_SUPPORT + else if (!crStrcmp(protocol, "hpmc")) + { + cr_net.use_hpmc++; + crHPMCInit(cr_net.recv_list, cr_net.close_list, mtu); + crHPMCConnection(conn); + } +#endif + else + { + crError("Unknown protocol: \"%s\"", protocol); + } +} + + + +/** + * Establish a connection with a server. + * \param server the server to connect to, in the form + * "protocol://servername:port" where the port specifier + * is optional and if the protocol is missing it is assumed + * to be "tcpip". + * \param default_port the port to connect to, if port not specified in the + * server URL string. + * \param mtu desired maximum transmission unit size (in bytes) + * \param broker either 1 or 0 to indicate if connection is brokered through + * the mothership + */ +CRConnection * crNetConnectToServer( const char *server, unsigned short default_port, int mtu, int broker +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif +) +{ + char hostname[4096], protocol[4096]; + unsigned short port; + CRConnection *conn; + + crDebug( "In crNetConnectToServer( \"%s\", port=%d, mtu=%d, broker=%d )", + server, default_port, mtu, broker ); + + CRASSERT( cr_net.initialized ); + + if (mtu < CR_MINIMUM_MTU) + { + crError( "You tried to connect to server \"%s\" with an mtu of %d, " + "but the minimum MTU is %d", server, mtu, CR_MINIMUM_MTU ); + } + + /* Tear the URL apart into relevant portions. */ + if ( !crParseURL( server, protocol, hostname, &port, default_port ) ) { + crError( "Malformed URL: \"%s\"", server ); + } + + /* If the host name is "localhost" replace it with the _real_ name + * of the localhost. If we don't do this, there seems to be + * confusion in the mothership as to whether or not "localhost" and + * "foo.bar.com" are the same machine. + */ + if (crStrcmp(hostname, "localhost") == 0) { + int rv = crGetHostname(hostname, 4096); + CRASSERT(rv == 0); + (void) rv; + } + + /* XXX why is this here??? I think it could be moved into the + * crTeacConnection() function with no problem. I.e. change the + * connection's port, teac_rank and tcscomm_rank there. (BrianP) + */ + if ( !crStrcmp( protocol, "quadrics" ) || + !crStrcmp( protocol, "quadrics-tcscomm" ) ) { + /* For Quadrics protocols, treat "port" as "rank" */ + if ( port > CR_QUADRICS_HIGHEST_RANK ) { + crWarning( "Invalid crserver rank, %d, defaulting to %d\n", + port, CR_QUADRICS_LOWEST_RANK ); + port = CR_QUADRICS_LOWEST_RANK; + } + } + crDebug( "Connecting to %s on port %d, with protocol %s", + hostname, port, protocol ); + +#ifdef SDP_SUPPORT + /* This makes me ill, but we need to "fix" the hostname for sdp. MCH */ + if (!crStrcmp(protocol, "sdp")) { + char* temp; + temp = strtok(hostname, "."); + crStrcat(temp, crGetSDPHostnameSuffix()); + crStrcpy(hostname, temp); + crDebug("SDP rename hostname: %s", hostname); + } +#endif + + conn = (CRConnection *) crCalloc( sizeof(*conn) ); + if (!conn) + return NULL; + + /* init the non-zero fields */ + conn->type = CR_NO_CONNECTION; /* we don't know yet */ + conn->recv_credits = CR_INITIAL_RECV_CREDITS; + conn->hostname = crStrdup( hostname ); + conn->port = port; + conn->mtu = mtu; + conn->buffer_size = mtu; + conn->broker = broker; + conn->endianness = crDetermineEndianness(); + /* XXX why are these here??? Move them into the crTeacConnection() + * and crTcscommConnection() functions. + */ + conn->teac_id = -1; + conn->teac_rank = port; + conn->tcscomm_id = -1; + conn->tcscomm_rank = port; + + crInitMessageList(&conn->messageList); + + /* now, just dispatch to the appropriate protocol's initialization functions. */ + InitConnection(conn, protocol, mtu +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , pHgsmi +#endif + ); + + if (!crNetConnect( conn )) + { + crDebug("crNetConnectToServer() failed, freeing the connection"); + #ifdef CHROMIUM_THREADSAFE + crFreeMutex( &conn->messageList.lock ); + #endif + conn->Disconnect(conn); + crFree( conn ); + return NULL; + } + + crDebug( "Done connecting to %s (swapping=%d)", server, conn->swap ); + return conn; +} + +/** + * Send a message to the receiver that another connection is needed. + * We send a CR_MESSAGE_NEWCLIENT packet, then call crNetServerConnect. + */ +void crNetNewClient( CRNetServer *ns +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif +) +{ + /* + unsigned int len = sizeof(CRMessageNewClient); + CRMessageNewClient msg; + + CRASSERT( conn ); + + if (conn->swap) + msg.header.type = (CRMessageType) SWAP32(CR_MESSAGE_NEWCLIENT); + else + msg.header.type = CR_MESSAGE_NEWCLIENT; + + crNetSend( conn, NULL, &msg, len ); + */ + + crNetServerConnect( ns +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , pHgsmi +#endif +); +} + + +/** + * Accept a connection from a client. + * \param protocol the protocol to use (such as "tcpip" or "gm") + * \param hostname optional hostname of the expected client (may be NULL) + * \param port number of the port to accept on + * \param mtu maximum transmission unit + * \param broker either 1 or 0 to indicate if connection is brokered through + * the mothership + * \return new CRConnection object, or NULL + */ +CRConnection * +crNetAcceptClient( const char *protocol, const char *hostname, + unsigned short port, unsigned int mtu, int broker ) +{ + CRConnection *conn; + + CRASSERT( cr_net.initialized ); + + conn = (CRConnection *) crCalloc( sizeof( *conn ) ); + if (!conn) + return NULL; + + /* init the non-zero fields */ + conn->type = CR_NO_CONNECTION; /* we don't know yet */ + conn->recv_credits = CR_INITIAL_RECV_CREDITS; + conn->port = port; + conn->mtu = mtu; + conn->buffer_size = mtu; + conn->broker = broker; + conn->endianness = crDetermineEndianness(); + conn->teac_id = -1; + conn->teac_rank = -1; + conn->tcscomm_id = -1; + conn->tcscomm_rank = -1; + + crInitMessageList(&conn->messageList); + + /* now, just dispatch to the appropriate protocol's initialization functions. */ + crDebug("In crNetAcceptClient( protocol=\"%s\" port=%d mtu=%d )", + protocol, (int) port, (int) mtu); + + /* special case */ + if ( !crStrncmp( protocol, "file", crStrlen( "file" ) ) || + !crStrncmp( protocol, "swapfile", crStrlen( "swapfile" ) ) ) + { + char filename[4096]; + char protocol_only[4096]; + + cr_net.use_file++; + if (!crParseURL(protocol, protocol_only, filename, NULL, 0)) + { + crError( "Malformed URL: \"%s\"", protocol ); + } + conn->hostname = crStrdup( filename ); + + /* call the protocol-specific init routines */ /* ktd (add) */ + InitConnection(conn, protocol_only, mtu +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , NULL +#endif + ); /* ktd (add) */ + } + else { + /* call the protocol-specific init routines */ + InitConnection(conn, protocol, mtu +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , NULL +#endif + ); + } + + crNetAccept( conn, hostname, port ); + return conn; +} + + +/** + * Close and free given connection. + */ +void +crNetFreeConnection(CRConnection *conn) +{ + conn->Disconnect(conn); + crFree( conn->hostname ); + #ifdef CHROMIUM_THREADSAFE + crFreeMutex( &conn->messageList.lock ); + #endif + crFree(conn); +} + + +/** + * Start the ball rolling. give functions to handle incoming traffic + * (usually placing blocks on a queue), and a handler for dropped + * connections. + */ +void crNetInit( CRNetReceiveFunc recvFunc, CRNetCloseFunc closeFunc ) +{ + CRNetReceiveFuncList *rfl; + CRNetCloseFuncList *cfl; + + if ( cr_net.initialized ) + { + /*crDebug( "Networking already initialized!" );*/ + } + else + { +#ifdef WINDOWS + /** @todo do we actually need that WSA stuff with VBox at all? */ + WORD wVersionRequested = MAKEWORD(2, 0); + WSADATA wsaData; + int err; + + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) + crError("Couldn't initialize sockets on WINDOWS"); +#endif + + cr_net.use_gm = 0; + cr_net.use_udp = 0; + cr_net.use_tcpip = 0; + cr_net.use_sdp = 0; + cr_net.use_tcscomm = 0; + cr_net.use_teac = 0; + cr_net.use_file = 0; + cr_net.use_hgcm = 0; + cr_net.num_clients = 0; +#ifdef CHROMIUM_THREADSAFE + crInitMutex(&cr_net.mutex); +#endif + + cr_net.initialized = 1; + cr_net.recv_list = NULL; + cr_net.close_list = NULL; + } + + if (recvFunc != NULL) + { + /* check if function is already in the list */ + for (rfl = cr_net.recv_list ; rfl ; rfl = rfl->next ) + { + if (rfl->recv == recvFunc) + { + /* we've already seen this function -- do nothing */ + break; + } + } + /* not in list, so insert at the head */ + if (!rfl) + { + rfl = (CRNetReceiveFuncList *) crAlloc( sizeof (*rfl )); + rfl->recv = recvFunc; + rfl->next = cr_net.recv_list; + cr_net.recv_list = rfl; + } + } + + if (closeFunc != NULL) + { + /* check if function is already in the list */ + for (cfl = cr_net.close_list ; cfl ; cfl = cfl->next ) + { + if (cfl->close == closeFunc) + { + /* we've already seen this function -- do nothing */ + break; + } + } + /* not in list, so insert at the head */ + if (!cfl) + { + cfl = (CRNetCloseFuncList *) crAlloc( sizeof (*cfl )); + cfl->close = closeFunc; + cfl->next = cr_net.close_list; + cr_net.close_list = cfl; + } + } +} + +/* Free up stuff */ +void crNetTearDown(void) +{ + CRNetReceiveFuncList *rfl; + CRNetCloseFuncList *cfl; + void *tmp; + + if (!cr_net.initialized) return; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_net.mutex); +#endif + + /* Note, other protocols used by chromium should free up stuff too, + * but VBox doesn't use them, so no other checks. + */ + if (cr_net.use_hgcm) + crVBoxHGCMTearDown(); + + for (rfl = cr_net.recv_list ; rfl ; rfl = (CRNetReceiveFuncList *) tmp ) + { + tmp = rfl->next; + crFree(rfl); + } + + for (cfl = cr_net.close_list ; cfl ; cfl = (CRNetCloseFuncList *) tmp ) + { + tmp = cfl->next; + crFree(cfl); + } + + cr_net.initialized = 0; + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_net.mutex); + crFreeMutex(&cr_net.mutex); +#endif +} + +CRConnection** crNetDump( int* num ) +{ + CRConnection **c; + + c = crTCPIPDump( num ); + if ( c ) return c; + + c = crDevnullDump( num ); + if ( c ) return c; + + c = crFileDump( num ); + if ( c ) return c; + +#ifdef VBOX_WITH_HGCM + c = crVBoxHGCMDump( num ); + if ( c ) return c; +#endif +#ifdef GM_SUPPORT + c = crGmDump( num ); + if ( c ) return c; +#endif +#ifdef IB_SUPPORT + c = crIBDump( num ); + if ( c ) return c; +#endif +#ifdef SDP_SUPPORT + c = crSDPDump( num ); + if ( c ) return c; +#endif + + *num = 0; + return NULL; +} + + +/* + * Allocate a network data buffer. The size will be the mtu size specified + * earlier to crNetConnectToServer() or crNetAcceptClient(). + * + * Buffers that will eventually be transmitted on a connection + * *must* be allocated using this interface. This way, we can + * automatically pin memory and tag blocks, and we can also use + * our own buffer pool management. + */ +void *crNetAlloc( CRConnection *conn ) +{ + CRASSERT( conn ); + return conn->Alloc( conn ); +} + + +/** + * This returns a buffer (which was obtained from crNetAlloc()) back + * to the network layer so that it may be reused. + */ +void crNetFree( CRConnection *conn, void *buf ) +{ + conn->Free( conn, buf ); +} + + +void +crInitMessageList(CRMessageList *list) +{ + list->head = list->tail = NULL; + list->numMessages = 0; +#ifdef CHROMIUM_THREADSAFE + crInitMutex(&list->lock); + crInitCondition(&list->nonEmpty); +#endif +} + + +/** + * Add a message node to the end of the message list. + * \param list the message list + * \param msg points to start of message buffer + * \param len length of message, in bytes + * \param conn connection associated with message (may be NULL) + */ +void +crEnqueueMessage(CRMessageList *list, CRMessage *msg, unsigned int len, + CRConnection *conn) +{ + CRMessageListNode *node; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&list->lock); +#endif + + node = (CRMessageListNode *) crAlloc(sizeof(CRMessageListNode)); + node->mesg = msg; + node->len = len; + node->conn = conn; + node->next = NULL; + + /* insert at tail */ + if (list->tail) + list->tail->next = node; + else + list->head = node; + list->tail = node; + + list->numMessages++; + +#ifdef CHROMIUM_THREADSAFE + crSignalCondition(&list->nonEmpty); + crUnlockMutex(&list->lock); +#endif +} + + +/** + * Remove first message node from message list and return it. + * Don't block. + * \return 1 if message was dequeued, 0 otherwise. + */ +static int +crDequeueMessageNoBlock(CRMessageList *list, CRMessage **msg, + unsigned int *len, CRConnection **conn) +{ + int retval; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&list->lock); +#endif + + if (list->head) { + CRMessageListNode *node = list->head; + + /* unlink the node */ + list->head = node->next; + if (!list->head) { + /* empty list */ + list->tail = NULL; + } + + *msg = node->mesg; + *len = node->len; + if (conn) + *conn = node->conn; + + list->numMessages--; + + crFree(node); + retval = 1; + } + else { + *msg = NULL; + *len = 0; + retval = 0; + } + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&list->lock); +#endif + + return retval; +} + + +/** + * Remove message from tail of list. Block until non-empty if needed. + * \param list the message list + * \param msg returns start of message + * \param len returns message length, in bytes + * \param conn returns connection associated with message (may be NULL) + */ +void +crDequeueMessage(CRMessageList *list, CRMessage **msg, unsigned int *len, + CRConnection **conn) +{ + CRMessageListNode *node; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&list->lock); +#endif + +#ifdef CHROMIUM_THREADSAFE + while (!list->head) { + crWaitCondition(&list->nonEmpty, &list->lock); + } +#else + CRASSERT(list->head); +#endif + + node = list->head; + + /* unlink the node */ + list->head = node->next; + if (!list->head) { + /* empty list */ + list->tail = NULL; + } + + *msg = node->mesg; + CRASSERT((*msg)->header.type); + *len = node->len; + if (conn) + *conn = node->conn; + + list->numMessages--; + + crFree(node); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&list->lock); +#endif +} + + + +/** + * Send a set of commands on a connection. Pretty straightforward, just + * error checking, byte counting, and a dispatch to the protocol's + * "send" implementation. + * The payload will be prefixed by a 4-byte length field. + * + * \param conn the network connection + * \param bufp if non-null the buffer was provided by the network layer + * and will be returned to the 'free' pool after it's sent. + * \param start points to first byte to send, which must point to a CRMessage + * object! + * \param len number of bytes to send + */ +void +crNetSend(CRConnection *conn, void **bufp, const void *start, unsigned int len) +{ + CRMessage *msg = (CRMessage *) start; + + CRASSERT( conn ); + CRASSERT( len > 0 ); + if ( bufp ) { + /* The region from [start .. start + len - 1] must lie inside the + * buffer pointed to by *bufp. + */ + CRASSERT( start >= *bufp ); + CRASSERT( (unsigned char *) start + len <= + (unsigned char *) *bufp + conn->buffer_size ); + } + +#ifdef DEBUG + if ( conn->send_credits > CR_INITIAL_RECV_CREDITS ) + { + crError( "crNetSend: send_credits=%u, looks like there is a leak (max=%u)", + conn->send_credits, CR_INITIAL_RECV_CREDITS ); + } +#endif + + conn->total_bytes_sent += len; + + msg->header.conn_id = conn->id; + conn->Send( conn, bufp, start, len ); +} + + +/** + * Like crNetSend(), but the network layer is free to discard the data + * if something goes wrong. In particular, the UDP layer might discard + * the data in the event of transmission errors. + */ +void crNetBarf( CRConnection *conn, void **bufp, + const void *start, unsigned int len ) +{ + CRMessage *msg = (CRMessage *) start; + CRASSERT( conn ); + CRASSERT( len > 0 ); + CRASSERT( conn->Barf ); + if ( bufp ) { + CRASSERT( start >= *bufp ); + CRASSERT( (unsigned char *) start + len <= + (unsigned char *) *bufp + conn->buffer_size ); + } + +#ifdef DEBUG + if ( conn->send_credits > CR_INITIAL_RECV_CREDITS ) + { + crError( "crNetBarf: send_credits=%u, looks like there is a " + "leak (max=%u)", conn->send_credits, + CR_INITIAL_RECV_CREDITS ); + } +#endif + + conn->total_bytes_sent += len; + + msg->header.conn_id = conn->id; + conn->Barf( conn, bufp, start, len ); +} + + +/** + * Send a block of bytes across the connection without any sort of + * header/length information. + * \param conn the network connection + * \param buf points to first byte to send + * \param len number of bytes to send + */ +void crNetSendExact( CRConnection *conn, const void *buf, unsigned int len ) +{ + CRASSERT(conn->SendExact); + conn->SendExact( conn, buf, len ); +} + + +/** + * Connect to a server, as specified by the 'name' and 'buffer_size' fields + * of the CRNetServer parameter. + * When done, the CrNetServer's conn field will be initialized. + */ +void crNetServerConnect( CRNetServer *ns +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif +) +{ + ns->conn = crNetConnectToServer( ns->name, DEFAULT_SERVER_PORT, + ns->buffer_size, 0 +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , pHgsmi +#endif + ); +} + +/** + * Actually set up the specified connection. + * Apparently, this is only called from the crNetConnectToServer function. + */ +int crNetConnect( CRConnection *conn ) +{ + return conn->Connect( conn ); +} + + +/** + * Tear down a network connection (close the socket, etc). + */ +void crNetDisconnect( CRConnection *conn ) +{ + conn->Disconnect( conn ); + crFree( conn->hostname ); +#ifdef CHROMIUM_THREADSAFE + crFreeMutex( &conn->messageList.lock ); +#endif + crFree( conn ); +} + + +/** + * Actually set up the specified connection. + * Apparently, this is only called from the crNetConnectToServer function. + */ +void crNetAccept( CRConnection *conn, const char *hostname, unsigned short port ) +{ + conn->Accept( conn, hostname, port ); +} + + +/** + * Do a blocking receive on a particular connection. This only + * really works for TCPIP, but it's really only used (right now) by + * the mothership client library. + * Read exactly the number of bytes specified (no headers/prefixes). + */ +void crNetSingleRecv( CRConnection *conn, void *buf, unsigned int len ) +{ + if (conn->type != CR_TCPIP) + { + crError( "Can't do a crNetSingleReceive on anything other than TCPIP." ); + } + conn->Recv( conn, buf, len ); +} + + +/** + * Receive a chunk of a CR_MESSAGE_MULTI_BODY/TAIL transmission. + * \param conn the network connection + * \param msg the incoming multi-part message + * \param len number of bytes in the message + */ +static void +crNetRecvMulti( CRConnection *conn, CRMessageMulti *msg, unsigned int len ) +{ + CRMultiBuffer *multi = &(conn->multi); + unsigned char *src, *dst; + + CRASSERT( len > sizeof(*msg) ); + len -= sizeof(*msg); + + /* Check if there's enough room in the multi-buffer to append 'len' bytes */ + if ( len + multi->len > multi->max ) + { + if ( multi->max == 0 ) + { + multi->len = conn->sizeof_buffer_header; + multi->max = 8192; /* arbitrary initial size */ + } + /* grow the buffer by 2x until it's big enough */ + while ( len + multi->len > multi->max ) + { + multi->max <<= 1; + } + crRealloc( &multi->buf, multi->max ); + } + + dst = (unsigned char *) multi->buf + multi->len; + src = (unsigned char *) msg + sizeof(*msg); + crMemcpy( dst, src, len ); + multi->len += len; + + if (msg->header.type == CR_MESSAGE_MULTI_TAIL) + { + /* OK, we've collected the last chunk of the multi-part message */ + conn->HandleNewMessage( + conn, + (CRMessage *) (((char *) multi->buf) + conn->sizeof_buffer_header), + multi->len - conn->sizeof_buffer_header ); + + /* clean this up before calling the user */ + multi->buf = NULL; + multi->len = 0; + multi->max = 0; + } + + /* Don't do this too early! */ + conn->InstantReclaim( conn, (CRMessage *) msg ); +} + + +/** + * Increment the connection's send_credits by msg->credits. + */ +static void +crNetRecvFlowControl( CRConnection *conn, CRMessageFlowControl *msg, + unsigned int len ) +{ + CRASSERT( len == sizeof(CRMessageFlowControl) ); + conn->send_credits += (conn->swap ? SWAP32(msg->credits) : msg->credits); + conn->InstantReclaim( conn, (CRMessage *) msg ); +} + +#ifdef IN_GUEST +/** + * Called by the main receive function when we get a CR_MESSAGE_WRITEBACK + * message. Writeback is used to implement glGet*() functions. + */ +static void +crNetRecvWriteback( CRMessageWriteback *wb ) +{ + int *writeback; + crMemcpy( &writeback, &(wb->writeback_ptr), sizeof( writeback ) ); + (*writeback)--; +} + + +/** + * Called by the main receive function when we get a CR_MESSAGE_READBACK + * message. Used to implement glGet*() functions. + */ +static void +crNetRecvReadback( CRMessageReadback *rb, unsigned int len ) +{ + /* minus the header, the destination pointer, + * *and* the implicit writeback pointer at the head. */ + + int payload_len = len - sizeof( *rb ); + int *writeback; + void *dest_ptr; + crMemcpy( &writeback, &(rb->writeback_ptr), sizeof( writeback ) ); + crMemcpy( &dest_ptr, &(rb->readback_ptr), sizeof( dest_ptr ) ); + + (*writeback)--; + crMemcpy( dest_ptr, ((char *)rb) + sizeof(*rb), payload_len ); +} +#endif + +/** + * This is used by the SPUs that do packing (such as Pack, Tilesort and + * Replicate) to process ReadPixels messages. We can't call this directly + * from the message loop below because the SPU's have other housekeeping + * to do for ReadPixels (such as decrementing counters). + */ +void +crNetRecvReadPixels( const CRMessageReadPixels *rp, unsigned int len ) +{ + int payload_len = len - sizeof( *rp ); + char *dest_ptr; + const char *src_ptr = (const char *) rp + sizeof(*rp); + + /* set dest_ptr value */ + crMemcpy( &(dest_ptr), &(rp->pixels), sizeof(dest_ptr)); + + /* store pixel data in app's memory */ + if (rp->alignment == 1 && + rp->skipRows == 0 && + rp->skipPixels == 0 && + (rp->rowLength == 0 || rp->rowLength == rp->width)) { + /* no special packing is needed */ + crMemcpy( dest_ptr, src_ptr, payload_len ); + } + else { + /* need special packing */ + CRPixelPackState packing; + packing.skipRows = rp->skipRows; + packing.skipPixels = rp->skipPixels; + packing.alignment = rp->alignment; + packing.rowLength = rp->rowLength; + packing.imageHeight = 0; + packing.skipImages = 0; + packing.swapBytes = GL_FALSE; + packing.psLSBFirst = GL_FALSE; + crPixelCopy2D( rp->width, rp->height, + dest_ptr, rp->format, rp->type, &packing, + src_ptr, rp->format, rp->type, /*unpacking*/NULL); + } +} + + + +/** + * If an incoming message is not consumed by any of the connection's + * receive callbacks, this function will get called. + * + * XXX Make this function static??? + */ +void +crNetDefaultRecv( CRConnection *conn, CRMessage *msg, unsigned int len ) +{ + CRMessage *pRealMsg; + + pRealMsg = (msg->header.type!=CR_MESSAGE_REDIR_PTR) ? msg : (CRMessage*) msg->redirptr.pMessage; + + switch (pRealMsg->header.type) + { + case CR_MESSAGE_GATHER: + break; + case CR_MESSAGE_MULTI_BODY: + case CR_MESSAGE_MULTI_TAIL: + crNetRecvMulti( conn, &(pRealMsg->multi), len ); + return; + case CR_MESSAGE_FLOW_CONTROL: + crNetRecvFlowControl( conn, &(pRealMsg->flowControl), len ); + return; + case CR_MESSAGE_OPCODES: + case CR_MESSAGE_OOB: + { + /*CRMessageOpcodes *ops = (CRMessageOpcodes *) msg; + *unsigned char *data_ptr = (unsigned char *) ops + sizeof( *ops) + ((ops->numOpcodes + 3 ) & ~0x03); + *crDebugOpcodes( stdout, data_ptr-1, ops->numOpcodes ); */ + } + break; + case CR_MESSAGE_READ_PIXELS: + WARN(( "Can't handle read pixels" )); + return; + case CR_MESSAGE_WRITEBACK: +#ifdef IN_GUEST + crNetRecvWriteback( &(pRealMsg->writeback) ); +#else + WARN(("CR_MESSAGE_WRITEBACK not expected\n")); +#endif + return; + case CR_MESSAGE_READBACK: +#ifdef IN_GUEST + crNetRecvReadback( &(pRealMsg->readback), len ); +#else + WARN(("CR_MESSAGE_READBACK not expected\n")); +#endif + return; + case CR_MESSAGE_CRUT: + /* nothing */ + break; + default: + /* We can end up here if anything strange happens in + * the GM layer. In particular, if the user tries to + * send unpinned memory over GM it gets sent as all + * 0xAA instead. This can happen when a program exits + * ungracefully, so the GM is still DMAing memory as + * it is disappearing out from under it. We can also + * end up here if somebody adds a message type, and + * doesn't put it in the above case block. That has + * an obvious fix. */ + { + char string[128]; + crBytesToString( string, sizeof(string), msg, len ); + WARN(("crNetDefaultRecv: received a bad message: type=%d buf=[%s]\n" + "Did you add a new message type and forget to tell " + "crNetDefaultRecv() about it?\n", + msg->header.type, string )); + } + } + + /* If we make it this far, it's not a special message, so append it to + * the end of the connection's list of received messages. + */ + crEnqueueMessage(&conn->messageList, msg, len, conn); +} + + +/** + * Default handler for receiving data. Called via crNetRecv(). + * Typically, the various implementations of the network layer call this. + * \param msg this is the address of the message (of bytes) the + * first part of which is a CRMessage union. + */ +void +crNetDispatchMessage( CRNetReceiveFuncList *rfl, CRConnection *conn, + CRMessage *msg, unsigned int len ) +{ + for ( ; rfl ; rfl = rfl->next) + { + if (rfl->recv( conn, msg, len )) + { + /* Message was consumed by somebody (maybe a SPU). + * All done. + */ + return; + } + } + /* Append the message to the connection's message list. It'll be + * consumed later (by crNetPeekMessage or crNetGetMessage and + * then freed with a call to crNetFree()). At this point, the buffer + * *must* have been allocated with crNetAlloc! + */ + crNetDefaultRecv( conn, msg, len ); +} + + +/** + * Return number of messages queued up on the given connection. + */ +int +crNetNumMessages(CRConnection *conn) +{ + return conn->messageList.numMessages; +} + + +/** + * Get the next message in the connection's message list. These are + * message that have already been received. We do not try to read more + * bytes from the network connection. + * + * The crNetFree() function should be called when finished with the message! + * + * \param conn the network connection + * \param message returns a pointer to the next message + * \return length of message (header + payload, in bytes) + */ +unsigned int +crNetPeekMessage( CRConnection *conn, CRMessage **message ) +{ + unsigned int len; + CRConnection *dummyConn = NULL; + if (crDequeueMessageNoBlock(&conn->messageList, message, &len, &dummyConn)) + return len; + else + return 0; +} + + +/** + * Get the next message from the given network connection. If there isn't + * one already in the linked list of received messages, call crNetRecv() + * until we get something. + * + * \param message returns pointer to the message + * \return total length of message (header + payload, in bytes) + */ +unsigned int +crNetGetMessage( CRConnection *conn, CRMessage **message ) +{ + /* Keep getting work to do */ + for (;;) + { + int len = crNetPeekMessage( conn, message ); + if (len) + return len; + crNetRecv( +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + conn +#endif + ); + } + +#if !defined(WINDOWS) && !defined(IRIX) && !defined(IRIX64) + /* silence compiler */ + return 0; +#endif +} + + +/** + * Read a \n-terminated string from a connection. Replace the \n with \0. + * Useful for reading from the mothership. + * \note This is an extremely inefficient way to read a string! + * + * \param conn the network connection + * \param buf buffer in which to place results + */ +void crNetReadline( CRConnection *conn, void *buf ) +{ + char *temp, c; + + if (!conn || conn->type == CR_NO_CONNECTION) + return; + + if (conn->type != CR_TCPIP) + { + crError( "Can't do a crNetReadline on anything other than TCPIP (%d).",conn->type ); + } + temp = (char*)buf; + for (;;) + { + conn->Recv( conn, &c, 1 ); + if (c == '\n') + { + *temp = '\0'; + return; + } + *(temp++) = c; + } +} + +#ifdef IN_GUEST +uint32_t crNetHostCapsGet(void) +{ +#ifdef VBOX_WITH_HGCM + if ( cr_net.use_hgcm ) + return crVBoxHGCMHostCapsGet(); +#endif + WARN(("HostCaps supportted for HGCM only!")); + return 0; +} +#endif + +/** + * The big boy -- call this function to see (non-blocking) if there is + * any pending work. If there is, the networking layer's "work received" + * handler will be called, so this function only returns a flag. Work + * is assumed to be placed on queues for processing by the handler. + */ +int crNetRecv( +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + CRConnection *conn +#else + void +#endif + ) +{ + int found_work = 0; + + if ( cr_net.use_tcpip ) + found_work += crTCPIPRecv(); +#ifdef VBOX_WITH_HGCM + if ( cr_net.use_hgcm ) + found_work += crVBoxHGCMRecv( +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + conn +#endif + ); +#endif +#ifdef SDP_SUPPORT + if ( cr_net.use_sdp ) + found_work += crSDPRecv(); +#endif +#ifdef IB_SUPPORT + if ( cr_net.use_ib ) + found_work += crIBRecv(); +#endif + if ( cr_net.use_udp ) + found_work += crUDPTCPIPRecv(); + + if ( cr_net.use_file ) + found_work += crFileRecv(); + +#ifdef GM_SUPPORT + if ( cr_net.use_gm ) + found_work += crGmRecv(); +#endif + +#ifdef TEAC_SUPPORT + if ( cr_net.use_teac ) + found_work += crTeacRecv(); +#endif + +#ifdef TCSCOMM_SUPPORT + if ( cr_net.use_tcscomm ) + found_work += crTcscommRecv(); +#endif + + return found_work; +} + + +/** + * Teac/TSComm only + */ +void +crNetSetRank( int my_rank ) +{ + cr_net.my_rank = my_rank; +#ifdef TEAC_SUPPORT + crTeacSetRank( cr_net.my_rank ); +#endif +#ifdef TCSCOMM_SUPPORT + crTcscommSetRank( cr_net.my_rank ); +#endif +} + +/** + * Teac/TSComm only + */ +void +crNetSetContextRange( int low_context, int high_context ) +{ +#if !defined(TEAC_SUPPORT) && !defined(TCSCOMM_SUPPORT) + (void)low_context; (void)high_context; +#endif +#ifdef TEAC_SUPPORT + crTeacSetContextRange( low_context, high_context ); +#endif +#ifdef TCSCOMM_SUPPORT + crTcscommSetContextRange( low_context, high_context ); +#endif +} + +/** + * Teac/TSComm only + */ +void +crNetSetNodeRange( const char *low_node, const char *high_node ) +{ +#if !defined(TEAC_SUPPORT) && !defined(TCSCOMM_SUPPORT) + (void)low_node; (void)high_node; +#endif +#ifdef TEAC_SUPPORT + crTeacSetNodeRange( low_node, high_node ); +#endif +#ifdef TCSCOMM_SUPPORT + crTcscommSetNodeRange( low_node, high_node ); +#endif +} + +/** + * Teac/TSComm only + */ +void +crNetSetKey( const unsigned char* key, const int keyLength ) +{ +#ifdef TEAC_SUPPORT + crTeacSetKey( key, keyLength ); +#else + (void)key; (void)keyLength; +#endif +} diff --git a/src/VBox/GuestHost/OpenGL/util/net_internals.h b/src/VBox/GuestHost/OpenGL/util/net_internals.h new file mode 100644 index 00000000..7cac01cf --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/net_internals.h @@ -0,0 +1,189 @@ +#ifndef NET_INTERNALS_H +#define NET_INTERNALS_H + +#include "cr_bufpool.h" +#include "cr_threads.h" + +#ifndef WINDOWS +#include +#endif + +/* + * DevNull network interface + */ +extern void crDevnullInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crDevnullConnection( CRConnection *conn ); +extern int crDevnullRecv( void ); +extern CRConnection** crDevnullDump( int *num ); + + +/* + * File network interface + */ +extern void crFileInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crFileConnection( CRConnection *conn ); +extern int crFileRecv( void ); +extern CRConnection** crFileDump( int *num ); + + +/* + * TCP/IP network interface + */ +typedef enum { + CRTCPIPMemory, + CRTCPIPMemoryBig +} CRTCPIPBufferKind; + +#define CR_TCPIP_BUFFER_MAGIC 0x89134532 + +typedef struct CRTCPIPBuffer { + unsigned int magic; + CRTCPIPBufferKind kind; + unsigned int len; + unsigned int allocated; + unsigned int pad; /* may be clobbered by crTCPIPSend() */ +} CRTCPIPBuffer; + +typedef struct { + int initialized; + int num_conns; + CRConnection **conns; + CRBufferPool *bufpool; +#ifdef CHROMIUM_THREADSAFE + CRmutex mutex; + CRmutex recvmutex; +#endif + CRNetReceiveFuncList *recv_list; + CRNetCloseFuncList *close_list; + CRSocket server_sock; +} cr_tcpip_data; + +extern cr_tcpip_data cr_tcpip; + +extern void crTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crTCPIPConnection( CRConnection *conn ); +extern int crTCPIPRecv( void ); +extern CRConnection** crTCPIPDump( int *num ); +extern int crTCPIPDoConnect( CRConnection *conn ); +extern void crTCPIPDoDisconnect( CRConnection *conn ); +extern int crTCPIPErrno( void ); +extern char *crTCPIPErrorString( int err ); +extern void crTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port ); +extern void crTCPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len ); +extern void crTCPIPFree( CRConnection *conn, void *buf ); +extern void *crTCPIPAlloc( CRConnection *conn ); +extern void crTCPIPReadExact( CRConnection *conn, void *buf, unsigned int len ); +extern int __tcpip_write_exact( CRSocket sock, const void *buf, unsigned int len ); +extern int __tcpip_read_exact( CRSocket sock, void *buf, unsigned int len ); +extern void __tcpip_dead_connection( CRConnection *conn ); +extern int __crSelect( int n, fd_set *readfds, int sec, int usec ); + + +/* + * UDP network interface + */ +extern void crUDPTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crUDPTCPIPConnection( CRConnection *conn ); +extern int crUDPTCPIPRecv( void ); + +/* + * VirtualBox HGCM + */ +#ifdef VBOX_WITH_HGCM +extern void crVBoxHGCMInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crVBoxHGCMConnection( CRConnection *conn +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + , struct VBOXUHGSMI *pHgsmi +#endif + ); +extern int crVBoxHGCMRecv( +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + CRConnection *conn +#else + void +#endif + ); +#ifdef IN_GUEST +extern uint32_t crVBoxHGCMHostCapsGet(void); +#endif +extern CRConnection** crVBoxHGCMDump( int *num ); +extern void crVBoxHGCMTearDown(void); +#endif + +/* + * TEAC network interface + */ +#ifdef TEAC_SUPPORT +extern void crTeacInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, + unsigned int mtu ); +extern void crTeacConnection( CRConnection *conn ); +extern int crTeacRecv( void ); +extern void crTeacSetRank( int ); +extern void crTeacSetContextRange( int, int ); +extern void crTeacSetNodeRange( const char *, const char * ); +extern void crTeacSetKey( const unsigned char *key, const int keyLength ); +#endif /* TEAC_SUPPORT */ + + +/* + * Tcscomm network interface + */ +#ifdef TCSCOMM_SUPPORT +extern void crTcscommInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, + unsigned int mtu ); +extern void crTcscommConnection( CRConnection *conn ); +extern int crTcscommRecv( void ); +#endif /* TCSCOMM_SUPPORT */ + + +/* + * SDP network interface + */ +#ifdef SDP_SUPPORT +extern const char *crGetSDPHostnameSuffix(void); +extern void crSDPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crSDPConnection( CRConnection *conn ); +extern int crSDPRecv( void ); +extern CRConnection** crSDPDump( int *num ); +#endif /* SDP_SUPPORT */ + + +/* + * Infiniband network interface + */ +#ifdef IB_SUPPORT +extern void crIBInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crIBConnection( CRConnection *conn ); +extern int crIBRecv( void ); +extern CRConnection** crIBDump( int *num ); +#endif /* IB_SUPPORT */ + + +/* + * GM network interface + */ +#ifdef GM_SUPPORT +extern void crGmInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ); +extern void crGmConnection( CRConnection *conn ); +extern int crGmRecv( void ); +extern CRConnection** crGmDump( int *num ); +extern int crGmDoConnect( CRConnection *conn ); +extern void crGmDoDisconnect( CRConnection *conn ); +extern int crGmErrno( void ); +extern char *crGmErrorString( int err ); +extern void crGmAccept( CRConnection *conn, const char *hostname, unsigned short port ); +extern void crGmSendExact( CRConnection *conn, const void *buf, unsigned int len ); +extern void crGmFree( CRConnection *conn, void *buf ); +extern void *crGmAlloc( CRConnection *conn ); +extern void crGmReadExact( CRConnection *conn, void *buf, unsigned int len ); +extern void crGmBogusRecv( CRConnection *conn, void *buf, unsigned int len ); +extern void crGmHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len ); +extern void crGmInstantReclaim( CRConnection *conn, CRMessage *msg ); +extern unsigned int crGmNodeId( void ); +extern unsigned int crGmPortNum( void ); +#endif /* GM_SUPPORT */ + + +extern CRConnection** crNetDump( int *num ); + +#endif /* NET_INTERNALS_H */ diff --git a/src/VBox/GuestHost/OpenGL/util/pixel.c b/src/VBox/GuestHost/OpenGL/util/pixel.c new file mode 100644 index 00000000..cfa2739b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/pixel.c @@ -0,0 +1,1863 @@ +/* Cop(c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_pixeldata.h" +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_version.h" +#include +#include + +#include + +#if defined(WINDOWS) +# include +# undef isnan /* _MSC_VER 12.0+ defines this is a complicated macro */ +# define isnan(x) _isnan(x) +#endif + +/** + * Maybe export this someday. + */ +static int crSizeOfType( GLenum type ) +{ + switch (type) { +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: +#endif + case GL_UNSIGNED_BYTE: + case GL_BYTE: + return 1; + case GL_BITMAP: + return 0; /* special case */ +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: +#endif + case GL_UNSIGNED_SHORT: + case GL_SHORT: + return 2; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: +#endif +#ifdef CR_EXT_framebuffer_object + case GL_UNSIGNED_INT_24_8: +#endif + case GL_UNSIGNED_INT: + case GL_INT: + case GL_FLOAT: + return 4; + case GL_DOUBLE: + return 8; + default: + crError( "Unknown pixel type in crSizeOfType: 0x%x", (unsigned int) type ); + return 0; + } +} + + +/** + * Compute bytes per pixel for the given format/type combination. + * \return bytes per pixel or -1 for invalid format or type, 0 for bitmap data. + */ +int crPixelSize( GLenum format, GLenum type ) +{ + int bytes = 1; /* picky Windows compiler, we override later */ + + switch (type) { +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_BYTE_3_3_2: + case GL_UNSIGNED_BYTE_2_3_3_REV: + return 1; +#endif + case GL_UNSIGNED_BYTE: + case GL_BYTE: + bytes = 1; + break; + case GL_BITMAP: + return 0; /* special case */ +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_SHORT_5_6_5: + case GL_UNSIGNED_SHORT_5_6_5_REV: + case GL_UNSIGNED_SHORT_5_5_5_1: + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + return 2; +#endif + case GL_UNSIGNED_SHORT: + case GL_SHORT: + bytes = 2; + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_INT_8_8_8_8: + case GL_UNSIGNED_INT_8_8_8_8_REV: + case GL_UNSIGNED_INT_10_10_10_2: + case GL_UNSIGNED_INT_2_10_10_10_REV: + return 4; +#endif +#ifdef CR_EXT_framebuffer_object + case GL_UNSIGNED_INT_24_8: + return 4; +#endif + case GL_UNSIGNED_INT: + case GL_INT: + case GL_FLOAT: + bytes = 4; + break; + default: + crWarning( "Unknown pixel type in crPixelSize: type:0x%x(fmt:0x%x)", (unsigned int) type, (unsigned int) format); + return 0; + } + + switch (format) { + case GL_COLOR_INDEX: + case GL_STENCIL_INDEX: + case GL_DEPTH_COMPONENT: + case GL_RED: + case GL_GREEN: + case GL_BLUE: + case GL_ALPHA: + case GL_LUMINANCE: + case GL_INTENSITY: +#ifdef CR_EXT_texture_sRGB + case GL_SLUMINANCE_EXT: + case GL_SLUMINANCE8_EXT: +#endif + break; + case GL_LUMINANCE_ALPHA: +#ifdef CR_EXT_texture_sRGB + case GL_SLUMINANCE_ALPHA_EXT: + case GL_SLUMINANCE8_ALPHA8_EXT: +#endif + bytes *= 2; + break; + case GL_RGB: +#ifdef CR_OPENGL_VERSION_1_2 + case GL_BGR: +#endif +#ifdef CR_EXT_texture_sRGB + case GL_SRGB_EXT: + case GL_SRGB8_EXT: +#endif + bytes *= 3; + break; + case GL_RGBA: +#ifdef GL_ABGR_EXT + case GL_ABGR_EXT: +#endif +#ifdef CR_OPENGL_VERSION_1_2 + case GL_BGRA: +#endif +#ifdef CR_EXT_texture_sRGB + case GL_SRGB_ALPHA_EXT: + case GL_SRGB8_ALPHA8_EXT: +#endif + bytes *= 4; + break; + default: + crWarning( "Unknown pixel format in crPixelSize: type:0x%x(fmt:0x%x)", (unsigned int) type, (unsigned int) format); + return 0; + } + + return bytes; +} + + +#define BYTE_TO_FLOAT(b) ((b) * (1.0/127.0)) +#define FLOAT_TO_BYTE(f) ((GLbyte) ((f) * 127.0)) + +#define UBYTE_TO_FLOAT(b) ((b) * (1.0/255.0)) +#define FLOAT_TO_UBYTE(f) ((GLbyte) ((f) * 255.0)) + +#define SHORT_TO_FLOAT(s) ((s) * (1.0/32768.0)) +#define FLOAT_TO_SHORT(f) ((GLshort) ((f) * 32768.0)) + +#define USHORT_TO_FLOAT(s) ((s) * (1.0/65535.0)) +#define FLOAT_TO_USHORT(f) ((GLushort) ((f) * 65535.0)) + +#define INT_TO_FLOAT(i) ((i) * (1.0F/2147483647.0)) +#define FLOAT_TO_INT(f) ((GLint) ((f) * 2147483647.0)) + +#define UINT_TO_FLOAT(i) ((i) * (1.0F / 4294967295.0F)) +#define FLOAT_TO_UINT(f) ((GLuint) ((f) * 4294967295.0)) + + +static float SRGBF_TO_RGBF(float f) +{ + if (isnan(f)) return 0.f; + + if (f<=0.04045f) + { + return f/12.92f; + } + else + { + return pow((f+0.055f)/1.055f, 2.4f); + } +} + +static float RGBF_TO_SRGBF(float f) +{ + if (isnan(f)) return 0.f; + if (f>1.f) return 1.f; + if (f<0.f) return 0.f; + + if (f<0.0031308f) + { + return f*12.92f; + } + else + { + return 1.055f*pow(f, 0.41666f) - 0.055f; + } +} + +#ifdef _MSC_VER +/** @todo bird: MSC takes 5..20 mins to compile get_row and/or put_row with global + * optimizations enabled. It varies a bit between 8.0/64 and 7.1/32 - the latter seems + * to be fine with just disabling opts for get_row, while the former needs both to be + * disabled to compile it a decent time. It seems this isn't important code after all, + * so we're not overly worried about the performance degration. Even so, we might want + * to look into it before long, perhaps checking with Visual C++ 9.0 (aka 2008). */ +# pragma optimize("g", off) +#endif + +/* + * Pack src pixel data into tmpRow array as either GLfloat[][1] or + * GLfloat[][4] depending on whether the format is for colors. + */ +static void +get_row(const char *src, GLenum srcFormat, GLenum srcType, + GLsizei width, GLfloat *tmpRow) +{ + const GLbyte *bSrc = (GLbyte *) src; + const GLubyte *ubSrc = (GLubyte *) src; + const GLshort *sSrc = (GLshort *) src; + const GLushort *usSrc = (GLushort *) src; + const GLint *iSrc = (GLint *) src; + const GLuint *uiSrc = (GLuint *) src; + const GLfloat *fSrc = (GLfloat *) src; + const GLdouble *dSrc = (GLdouble *) src; + int i; + + if (srcFormat == GL_COLOR_INDEX || srcFormat == GL_STENCIL_INDEX) { + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) bSrc[i]; + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) ubSrc[i]; + break; + case GL_SHORT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) sSrc[i]; + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) usSrc[i]; + break; + case GL_INT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) iSrc[i]; + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) uiSrc[i]; + break; + case GL_FLOAT: + for (i = 0; i < width; i++) + tmpRow[i] = fSrc[i]; + break; + case GL_DOUBLE: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) dSrc[i]; + break; + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else if (srcFormat == GL_DEPTH_COMPONENT) { + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) BYTE_TO_FLOAT(bSrc[i]); + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i]); + break; + case GL_SHORT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) SHORT_TO_FLOAT(sSrc[i]); + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) USHORT_TO_FLOAT(usSrc[i]); + break; + case GL_INT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) INT_TO_FLOAT(bSrc[i]); + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) UINT_TO_FLOAT(bSrc[i]); + break; + case GL_FLOAT: + for (i = 0; i < width; i++) + tmpRow[i] = fSrc[i]; + break; + case GL_DOUBLE: + for (i = 0; i < width; i++) + tmpRow[i] = (GLfloat) dSrc[i]; + break; + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else if (srcFormat == GL_RED || srcFormat == GL_GREEN || + srcFormat == GL_BLUE || srcFormat == GL_ALPHA) { + int dst; + if (srcFormat == GL_RED) + dst = 0; + else if (srcFormat == GL_GREEN) + dst = 1; + else if (srcFormat == GL_BLUE) + dst = 2; + else + dst = 3; + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = 0.0; + tmpRow[i*4+1] = 0.0; + tmpRow[i*4+2] = 0.0; + tmpRow[i*4+3] = 1.0; + } + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = (GLfloat) BYTE_TO_FLOAT(bSrc[i]); + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i]); + break; + case GL_SHORT: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = (GLfloat) SHORT_TO_FLOAT(sSrc[i]); + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = (GLfloat) USHORT_TO_FLOAT(usSrc[i]); + break; + case GL_INT: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = (GLfloat) INT_TO_FLOAT(iSrc[i]); + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = (GLfloat) UINT_TO_FLOAT(uiSrc[i]); + break; + case GL_FLOAT: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = fSrc[i]; + break; + case GL_DOUBLE: + for (i = 0; i < width; i++, dst += 4) + tmpRow[dst] = (GLfloat) fSrc[i]; + break; + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else if (srcFormat == GL_LUMINANCE +#ifdef CR_EXT_texture_sRGB + || srcFormat == GL_SLUMINANCE_EXT + || srcFormat == GL_SLUMINANCE8_EXT +#endif + ) { + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) BYTE_TO_FLOAT(bSrc[i]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) SHORT_TO_FLOAT(sSrc[i]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) USHORT_TO_FLOAT(usSrc[i]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) INT_TO_FLOAT(iSrc[i]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) UINT_TO_FLOAT(uiSrc[i]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_FLOAT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = fSrc[i]; + tmpRow[i*4+3] = 1.0; + } + break; + case GL_DOUBLE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = (GLfloat) dSrc[i]; + tmpRow[i*4+3] = 1.0; + } + break; + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else if (srcFormat == GL_INTENSITY) { + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = (GLfloat) BYTE_TO_FLOAT(bSrc[i]); + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i]); + break; + case GL_SHORT: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = (GLfloat) SHORT_TO_FLOAT(sSrc[i]); + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = (GLfloat) USHORT_TO_FLOAT(usSrc[i]); + break; + case GL_INT: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = (GLfloat) INT_TO_FLOAT(iSrc[i]); + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = UINT_TO_FLOAT(uiSrc[i]); + break; + case GL_FLOAT: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = fSrc[i]; + break; + case GL_DOUBLE: + for (i = 0; i < width; i++) + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = tmpRow[i*4+3] + = (GLfloat) dSrc[i]; + break; + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else if (srcFormat == GL_LUMINANCE_ALPHA +#ifdef CR_EXT_texture_sRGB + || srcFormat == GL_SLUMINANCE_ALPHA_EXT + || srcFormat == GL_SLUMINANCE8_ALPHA8_EXT +#endif + ) { + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) BYTE_TO_FLOAT(bSrc[i*2+0]); + tmpRow[i*4+3] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*2+1]); + } + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*2+0]); + tmpRow[i*4+3] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*2+1]); + } + break; + case GL_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) SHORT_TO_FLOAT(sSrc[i*2+0]); + tmpRow[i*4+3] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*2+1]); + } + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) USHORT_TO_FLOAT(usSrc[i*2+0]); + tmpRow[i*4+3] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*2+1]); + } + break; + case GL_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) INT_TO_FLOAT(iSrc[i*2+0]); + tmpRow[i*4+3] = (GLfloat) INT_TO_FLOAT(iSrc[i*2+1]); + } + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) UINT_TO_FLOAT(uiSrc[i*2+0]); + tmpRow[i*4+3] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*2+1]); + } + break; + case GL_FLOAT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] = fSrc[i*2+0]; + tmpRow[i*4+3] = fSrc[i*2+1]; + } + break; + case GL_DOUBLE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = tmpRow[i*4+1] = tmpRow[i*4+2] + = (GLfloat) dSrc[i*2+0]; + tmpRow[i*4+3] = (GLfloat) dSrc[i*2+1]; + } + break; + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else if (srcFormat == GL_RGB +#ifdef CR_OPENGL_VERSION_1_2 + || srcFormat == GL_BGR +#endif +#ifdef CR_EXT_texture_sRGB + || srcFormat == GL_SRGB_EXT + || srcFormat == GL_SRGB8_EXT +#endif + ) { + int r, b; + if (srcFormat == GL_RGB +#ifdef CR_EXT_texture_sRGB + || srcFormat == GL_SRGB_EXT + || srcFormat == GL_SRGB8_EXT +#endif + ) { + r = 0; b = 2; + } + else { + r = 2; b = 0; + } + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*3+r]); + tmpRow[i*4+1] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*3+1]); + tmpRow[i*4+2] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*3+b]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*3+r]); + tmpRow[i*4+1] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*3+1]); + tmpRow[i*4+2] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*3+b]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*3+r]); + tmpRow[i*4+1] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*3+1]); + tmpRow[i*4+2] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*3+b]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*3+r]); + tmpRow[i*4+1] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*3+1]); + tmpRow[i*4+2] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*3+b]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) INT_TO_FLOAT(iSrc[i*3+r]); + tmpRow[i*4+1] = (GLfloat) INT_TO_FLOAT(iSrc[i*3+1]); + tmpRow[i*4+2] = (GLfloat) INT_TO_FLOAT(iSrc[i*3+b]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*3+r]); + tmpRow[i*4+1] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*3+1]); + tmpRow[i*4+2] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*3+b]); + tmpRow[i*4+3] = 1.0; + } + break; + case GL_FLOAT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = fSrc[i*3+r]; + tmpRow[i*4+1] = fSrc[i*3+1]; + tmpRow[i*4+2] = fSrc[i*3+b]; + tmpRow[i*4+3] = 1.0; + } + break; + case GL_DOUBLE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) dSrc[i*3+r]; + tmpRow[i*4+1] = (GLfloat) dSrc[i*3+1]; + tmpRow[i*4+2] = (GLfloat) dSrc[i*3+b]; + tmpRow[i*4+3] = 1.0; + } + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_BYTE_3_3_2: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((ubSrc[i] >> 5) ) / 7.0f; + tmpRow[i*4+1] = (GLfloat) ((ubSrc[i] >> 2) & 0x7) / 7.0f; + tmpRow[i*4+b] = (GLfloat) ((ubSrc[i] ) & 0x3) / 3.0f; + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_BYTE_2_3_3_REV: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((ubSrc[i] ) & 0x7) / 7.0f; + tmpRow[i*4+1] = (GLfloat) ((ubSrc[i] >> 3) & 0x7) / 7.0f; + tmpRow[i*4+b] = (GLfloat) ((ubSrc[i] >> 6) ) / 3.0f; + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_SHORT_5_6_5: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((usSrc[i] >> 11) & 0x1f) / 31.0f; + tmpRow[i*4+1] = (GLfloat) ((usSrc[i] >> 5) & 0x3f) / 63.0f; + tmpRow[i*4+b] = (GLfloat) ((usSrc[i] ) & 0x1f) / 31.0f; + tmpRow[i*4+3] = 1.0; + } + break; + case GL_UNSIGNED_SHORT_5_6_5_REV: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((usSrc[i] ) & 0x1f) / 31.0f; + tmpRow[i*4+1] = (GLfloat) ((usSrc[i] >> 5) & 0x3f) / 63.0f; + tmpRow[i*4+b] = (GLfloat) ((usSrc[i] >> 11) & 0x1f) / 31.0f; + tmpRow[i*4+3] = 1.0; + } + break; +#endif + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else if (srcFormat == GL_RGBA +#ifdef CR_OPENGL_VERSION_1_2 + || srcFormat == GL_BGRA +#endif +#ifdef CR_EXT_texture_sRGB + || srcFormat == GL_SRGB_ALPHA_EXT + || srcFormat == GL_SRGB8_ALPHA8_EXT +#endif + ) { + int r, b; + if (srcFormat == GL_RGBA +#ifdef CR_EXT_texture_sRGB + || srcFormat == GL_SRGB_ALPHA_EXT + || srcFormat == GL_SRGB8_ALPHA8_EXT +#endif + ) + { + r = 0; b = 2; + } + else { + r = 2; b = 0; + } + switch (srcType) { + case GL_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*4+r]); + tmpRow[i*4+1] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*4+1]); + tmpRow[i*4+2] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*4+b]); + tmpRow[i*4+3] = (GLfloat) BYTE_TO_FLOAT(bSrc[i*4+3]); + } + break; + case GL_UNSIGNED_BYTE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*4+r]); + tmpRow[i*4+1] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*4+1]); + tmpRow[i*4+2] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*4+b]); + tmpRow[i*4+3] = (GLfloat) UBYTE_TO_FLOAT(ubSrc[i*4+3]); + } + break; + case GL_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*4+r]); + tmpRow[i*4+1] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*4+1]); + tmpRow[i*4+2] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*4+b]); + tmpRow[i*4+3] = (GLfloat) SHORT_TO_FLOAT(sSrc[i*4+3]); + } + break; + case GL_UNSIGNED_SHORT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*4+r]); + tmpRow[i*4+1] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*4+1]); + tmpRow[i*4+2] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*4+b]); + tmpRow[i*4+3] = (GLfloat) USHORT_TO_FLOAT(usSrc[i*4+3]); + } + break; + case GL_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) INT_TO_FLOAT(iSrc[i*4+r]); + tmpRow[i*4+1] = (GLfloat) INT_TO_FLOAT(iSrc[i*4+1]); + tmpRow[i*4+2] = (GLfloat) INT_TO_FLOAT(iSrc[i*4+b]); + tmpRow[i*4+3] = (GLfloat) INT_TO_FLOAT(iSrc[i*4+3]); + } + break; + case GL_UNSIGNED_INT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*4+r]); + tmpRow[i*4+1] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*4+1]); + tmpRow[i*4+2] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*4+b]); + tmpRow[i*4+3] = (GLfloat) UINT_TO_FLOAT(uiSrc[i*4+3]); + } + break; + case GL_FLOAT: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = fSrc[i*4+r]; + tmpRow[i*4+1] = fSrc[i*4+1]; + tmpRow[i*4+2] = fSrc[i*4+b]; + tmpRow[i*4+3] = fSrc[i*4+3]; + } + break; + case GL_DOUBLE: + for (i = 0; i < width; i++) { + tmpRow[i*4+0] = (GLfloat) dSrc[i*4+r]; + tmpRow[i*4+1] = (GLfloat) dSrc[i*4+1]; + tmpRow[i*4+2] = (GLfloat) dSrc[i*4+b]; + tmpRow[i*4+3] = (GLfloat) dSrc[i*4+3]; + } + break; +#ifdef CR_OPENGL_VERSION_1_2 + case GL_UNSIGNED_SHORT_5_5_5_1: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((usSrc[i] >> 11) ) / 31.0f; + tmpRow[i*4+1] = (GLfloat) ((usSrc[i] >> 6) & 0x1f) / 31.0f; + tmpRow[i*4+b] = (GLfloat) ((usSrc[i] >> 1) & 0x1f) / 31.0f; + tmpRow[i*4+3] = (GLfloat) ((usSrc[i] ) & 0x01); + } + break; + case GL_UNSIGNED_SHORT_1_5_5_5_REV: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((usSrc[i] ) & 0x1f) / 31.0f; + tmpRow[i*4+1] = (GLfloat) ((usSrc[i] >> 5) & 0x1f) / 31.0f; + tmpRow[i*4+b] = (GLfloat) ((usSrc[i] >> 10) & 0x1f) / 31.0f; + tmpRow[i*4+3] = (GLfloat) ((usSrc[i] >> 15) ); + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((usSrc[i] >> 12) & 0xf) / 15.0f; + tmpRow[i*4+1] = (GLfloat) ((usSrc[i] >> 8) & 0xf) / 15.0f; + tmpRow[i*4+b] = (GLfloat) ((usSrc[i] >> 4) & 0xf) / 15.0f; + tmpRow[i*4+3] = (GLfloat) ((usSrc[i] ) & 0xf) / 15.0f; + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4_REV: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((usSrc[i] ) & 0xf) / 15.0f; + tmpRow[i*4+1] = (GLfloat) ((usSrc[i] >> 4) & 0xf) / 15.0f; + tmpRow[i*4+b] = (GLfloat) ((usSrc[i] >> 8) & 0xf) / 15.0f; + tmpRow[i*4+3] = (GLfloat) ((usSrc[i] >> 12) & 0xf) / 15.0f; + } + break; + case GL_UNSIGNED_INT_8_8_8_8: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((uiSrc[i] >> 24) & 0xff) / 255.0f; + tmpRow[i*4+1] = (GLfloat) ((uiSrc[i] >> 16) & 0xff) / 255.0f; + tmpRow[i*4+b] = (GLfloat) ((uiSrc[i] >> 8) & 0xff) / 255.0f; + tmpRow[i*4+3] = (GLfloat) ((uiSrc[i] ) & 0xff) / 255.0f; + } + break; + case GL_UNSIGNED_INT_8_8_8_8_REV: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((uiSrc[i] ) & 0xff) / 255.0f; + tmpRow[i*4+1] = (GLfloat) ((uiSrc[i] >> 8) & 0xff) / 255.0f; + tmpRow[i*4+b] = (GLfloat) ((uiSrc[i] >> 16) & 0xff) / 255.0f; + tmpRow[i*4+3] = (GLfloat) ((uiSrc[i] >> 24) & 0xff) / 255.0f; + } + break; + case GL_UNSIGNED_INT_10_10_10_2: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((uiSrc[i] >> 22) & 0x3ff) / 1023.0f; + tmpRow[i*4+1] = (GLfloat) ((uiSrc[i] >> 12) & 0x3ff) / 1023.0f; + tmpRow[i*4+b] = (GLfloat) ((uiSrc[i] >> 2) & 0x3ff) / 1023.0f; + tmpRow[i*4+3] = (GLfloat) ((uiSrc[i] ) & 0x003) / 3.0f; + } + break; + case GL_UNSIGNED_INT_2_10_10_10_REV: + for (i = 0; i < width; i++) { + tmpRow[i*4+r] = (GLfloat) ((uiSrc[i] ) & 0x3ff) / 1023.0f; + tmpRow[i*4+1] = (GLfloat) ((uiSrc[i] >> 10) & 0x3ff) / 1023.0f; + tmpRow[i*4+b] = (GLfloat) ((uiSrc[i] >> 20) & 0x3ff) / 1023.0f; + tmpRow[i*4+3] = (GLfloat) ((uiSrc[i] >> 30) & 0x003) / 3.0f; + } + break; +#endif + default: + crError("unexpected type in get_row in pixel.c"); + } + } + else{ + crError("unexpected source format in get_row in pixel.c"); + } + +#ifdef CR_EXT_texture_sRGB + if (srcFormat == GL_SRGB_EXT + || srcFormat == GL_SRGB8_EXT + || srcFormat == GL_SRGB_ALPHA_EXT + || srcFormat == GL_SRGB8_ALPHA8_EXT + || srcFormat == GL_SLUMINANCE_ALPHA_EXT + || srcFormat == GL_SLUMINANCE8_ALPHA8_EXT + || srcFormat == GL_SLUMINANCE_EXT + || srcFormat == GL_SLUMINANCE8_EXT + ) + { + for (i=0; i> 8) | (us[i] << 8); + } +} + + +/** + * Byte-swap an array of GLuints + */ +static void +swap4(GLuint *ui, GLuint n) +{ + GLuint i; + + for (i = 0; i < n; i++) { + GLuint b = ui[i]; + ui[i] = (b >> 24) + | ((b >> 8) & 0xff00) + | ((b << 8) & 0xff0000) + | ((b << 24) & 0xff000000); + } +} + + +/** + * Return number of bytes of storage needed to accommodate an + * image with the given format, type, and size. + * \return size in bytes or -1 if bad format or type + */ +unsigned int crImageSize( GLenum format, GLenum type, GLsizei width, GLsizei height ) +{ + unsigned int bytes = width * height; + + if (type == GL_BITMAP) + { + /* This was wrong in the old code! */ + bytes = ((width + 7) / 8) * height; + } + else if (GL_DEPTH_COMPONENT==format && type!=GL_FLOAT) + { + /*GL_DEPTH_COMPONENT with GL_UNSIGNED_BYTE seems to be more than 1 byte per pixel*/ + bytes = 4 * width * height * crPixelSize( format, type ); + } + else + { + bytes = width * height * crPixelSize( format, type ); + } + + return bytes; +} + +/** + * Return number of bytes of storage needed to accommodate a + * 3D texture with the give format, type, and size. + * \return size in bytes or -1 if bad format or type + */ +unsigned int crTextureSize( GLenum format, GLenum type, GLsizei width, GLsizei height, GLsizei depth ) +{ + unsigned int bytes = width * height; + + if (type == GL_BITMAP) + { + /* + * Not sure about this one, so just multiply + * by the depth? + */ + bytes = ((width + 7) / 8) * height * depth; + } + else + { + bytes = width * height * depth * crPixelSize( format, type ); + } + + return bytes; +} + +static const CRPixelPackState defaultPacking = { + 0, /* rowLength */ + 0, /* skipRows */ + 0, /* skipPixels */ + 1, /* alignment */ + 0, /* imageHeight */ + 0, /* skipImages */ + GL_FALSE, /* swapBytes */ + GL_FALSE /* psLSBFirst */ +}; + + +void crPixelCopy1D( GLvoid *dstPtr, GLenum dstFormat, GLenum dstType, + const GLvoid *srcPtr, GLenum srcFormat, GLenum srcType, + GLsizei width, const CRPixelPackState *srcPacking ) +{ + crPixelCopy2D( width, 1, + dstPtr, dstFormat, dstType, NULL, /* dst */ + srcPtr, srcFormat, srcType, srcPacking ); /* src */ +} + +void crPixelCopy2D( GLsizei width, GLsizei height, + GLvoid *dstPtr, GLenum dstFormat, GLenum dstType, + const CRPixelPackState *dstPacking, + const GLvoid *srcPtr, GLenum srcFormat, GLenum srcType, + const CRPixelPackState *srcPacking ) + +{ + const char *src = (const char *) srcPtr; + char *dst = (char *) dstPtr; + int srcBytesPerPixel; + int dstBytesPerPixel; + int srcBytesPerRow; + int dstBytesPerRow; + int srcRowStrideBytes; + int dstRowStrideBytes; + int bytesPerRow; + int i; + + if (!dstPacking) + dstPacking = &defaultPacking; + + if (!srcPacking) + srcPacking = &defaultPacking; + + if (srcType == GL_BITMAP) + { + CRASSERT(dstType == GL_BITMAP); + bytesPerRow = (width + 7) / 8; + if (srcPacking->rowLength > 0) + srcRowStrideBytes = (srcPacking->rowLength + 7) / 8; + else + srcRowStrideBytes = bytesPerRow; + dstRowStrideBytes = bytesPerRow; + + for (i=0; irowLength > 0) + srcRowStrideBytes = srcPacking->rowLength * srcBytesPerPixel; + else + srcRowStrideBytes = width * srcBytesPerPixel; + + if (dstPacking->rowLength > 0) + dstRowStrideBytes = dstPacking->rowLength * dstBytesPerPixel; + else + dstRowStrideBytes = width * dstBytesPerPixel; + + /* bytes per row */ + srcBytesPerRow = width * srcBytesPerPixel; + dstBytesPerRow = width * dstBytesPerPixel; + + /* handle the alignment */ + if (srcPacking->alignment != 1) { + i = ((intptr_t) src) % srcPacking->alignment; + if (i) + src += srcPacking->alignment - i; + i = (long) srcRowStrideBytes % srcPacking->alignment; + if (i) + srcRowStrideBytes += srcPacking->alignment - i; + } + + if (dstPacking->alignment != 1) { + i = ((intptr_t) dst) % dstPacking->alignment; + if (i) + dst += dstPacking->alignment - i; + i = (long) dstRowStrideBytes % dstPacking->alignment; + if (i) + dstRowStrideBytes += dstPacking->alignment - i; + } + + /* handle skip rows */ + src += srcPacking->skipRows * srcRowStrideBytes; + dst += dstPacking->skipRows * dstRowStrideBytes; + + /* handle skip pixels */ + src += srcPacking->skipPixels * srcBytesPerPixel; + dst += dstPacking->skipPixels * dstBytesPerPixel; + + /* we don't do LSBFirst yet */ + if (srcPacking->psLSBFirst) + crError( "Sorry, no lsbfirst for you" ); + if (dstPacking->psLSBFirst) + crError( "Sorry, no lsbfirst for you" ); + + if (srcFormat == dstFormat && srcType == dstType) + { + CRASSERT(srcBytesPerRow == dstBytesPerRow); + + if (srcBytesPerRow==srcRowStrideBytes + && srcRowStrideBytes==dstRowStrideBytes) + { + crMemcpy( (void *) dst, (const void *) src, height * srcBytesPerRow ); + } + else + /*crDebug("Sending texture, BytesPerRow!=RowStrideBytes");*/ + for (i = 0; i < height; i++) + { + crMemcpy( (void *) dst, (const void *) src, srcBytesPerRow ); +#if 0 + /* check if src XOR dst swapping */ + if (srcPacking->swapBytes ^ dstPacking->swapBytes) { + const GLint size = crSizeOfType(srcType); + CRASSERT(srcType == dstType); + if (size == 2) { + swap2((GLushort *) dst, srcBytesPerRow / size); + } + else if (size == 4) { + swap4((GLuint *) dst, srcBytesPerRow / size); + } + } +#endif + dst += dstRowStrideBytes; + src += srcRowStrideBytes; + } + } + else + { + /* need to do format and/or type conversion */ + char *swapRow = NULL; + GLfloat *tmpRow = crAlloc( 4 * width * sizeof(GLfloat) ); + + crDebug("Converting texture format"); + + if (!tmpRow) + crError("Out of memory in crPixelCopy2D"); + + if (srcPacking->swapBytes) { + swapRow = (char *) crAlloc(width * srcBytesPerPixel); + if (!swapRow) { + crError("Out of memory in crPixelCopy2D"); + } + } + + for (i = 0; i < height; i++) + { + /* get src row as floats */ + if (srcPacking->swapBytes) { + const GLint size = crSizeOfType(srcType); + const GLint bytes = width * srcBytesPerPixel; + crMemcpy(swapRow, src, bytes); + if (size == 2) + swap2((GLushort *) swapRow, bytes / 2); + else if (size == 4) + swap4((GLuint *) swapRow, bytes / 4); + get_row(swapRow, srcFormat, srcType, width, tmpRow); + } + else { + get_row(src, srcFormat, srcType, width, tmpRow); + } + + /* store floats in dest row */ + if (dstPacking->swapBytes) { + const GLint size = crSizeOfType(dstType); + const GLint bytes = dstBytesPerPixel * width; + put_row(dst, dstFormat, dstType, width, tmpRow); + if (size == 2) + swap2((GLushort *) dst, bytes / 2); + else if (size == 4) + swap4((GLuint *) dst, bytes / 4); + } + else { + put_row(dst, dstFormat, dstType, width, tmpRow); + } + + /* increment pointers for next row */ + dst += dstRowStrideBytes; + src += srcRowStrideBytes; + } + + crFree(tmpRow); + if (swapRow) + crFree(swapRow); + } + } +} + +void crPixelCopy3D( GLsizei width, GLsizei height, GLsizei depth, + GLvoid *dstPtr, GLenum dstFormat, GLenum dstType, + const CRPixelPackState *dstPacking, + const GLvoid *srcPtr, GLenum srcFormat, GLenum srcType, + const CRPixelPackState *srcPacking ) + +{ + int tex_size = 0; + + (void)srcPacking; + (void)srcType; + (void)srcFormat; + (void)dstPacking; + + /** @todo this should be implemented properly*/ + +#ifndef DEBUG_misha + crWarning( "crPixelCopy3D: simply crMemcpy'ing from srcPtr to dstPtr" ); +#endif + if (dstFormat != srcFormat) + crWarning( "crPixelCopy3D: formats don't match!" ); + if (dstType != srcType) + crWarning( "crPixelCopy3D: formats don't match!" ); + + tex_size = RT_MIN (crTextureSize( dstFormat, dstType, width, height, depth ), + crTextureSize( srcFormat, srcType, width, height, depth )); + crMemcpy( (void *) dstPtr, (void *) srcPtr, tex_size ); +} + +/* Round N up to the next multiple of 8 */ +#define CEIL8(N) (((N) + 7) & ~0x7) + +void crBitmapCopy( GLsizei width, GLsizei height, GLubyte *dstPtr, + const GLubyte *srcPtr, const CRPixelPackState *srcPacking ) +{ + if (srcPacking->psLSBFirst == GL_FALSE && + (srcPacking->rowLength == 0 || srcPacking->rowLength == width) && + srcPacking->skipRows == 0 && + srcPacking->skipPixels == 0 && + srcPacking->alignment == 1) { + /* simple case */ + crMemcpy(dstPtr, srcPtr, CEIL8(width) * height / 8); + } + else { + /* general case */ + const GLubyte *srcRow; + const GLint dst_row_length = CEIL8(width) / 8; + GLubyte *dstRow; + GLint src_row_length; + GLint i, j; + + if (srcPacking->rowLength > 0) + src_row_length = srcPacking->rowLength; + else + src_row_length = width; + + switch (srcPacking->alignment) { + case 1: + src_row_length = ( ( src_row_length + 7 ) & ~7 ) >> 3; + break; + case 2: + src_row_length = ( ( src_row_length + 15 ) & ~15 ) >> 3; + break; + case 4: + src_row_length = ( ( src_row_length + 31 ) & ~31 ) >> 3; + break; + case 8: + src_row_length = ( ( src_row_length + 63 ) & ~63 ) >> 3; + break; + default: + crError( "Invalid unpack alignment in crBitmapCopy"); + return; + } + + /* src_row_length and dst_row_length are in bytes */ + + srcRow = srcPtr + src_row_length * srcPacking->skipRows; + dstRow = dstPtr; + + if (srcPacking->psLSBFirst) { + for (j = 0; j < height; j++) { + crMemZero(dstRow, dst_row_length); + for (i = 0; i < width; i++) { + const GLint iByte = (i + srcPacking->skipPixels) / 8; + const GLint iBit = (i + srcPacking->skipPixels) % 8; + const GLubyte b = srcRow[iByte]; + if (b & (1 << iBit)) + dstRow[i / 8] |= (128 >> (i % 8)); + } + srcRow += src_row_length; + dstRow += dst_row_length; + } + } + else { + /* unpack MSB first */ + for (j = 0; j < height; j++) { + crMemZero(dstRow, dst_row_length); + for (i = 0; i < width; i++) { + const GLint iByte = (i + srcPacking->skipPixels) / 8; + const GLint iBit = (i + srcPacking->skipPixels) % 8; + const GLubyte b = srcRow[iByte]; + if (b & (128 >> iBit)) + dstRow[i / 8] |= (128 >> (i % 8)); + } + srcRow += src_row_length; + dstRow += dst_row_length; + } + } + } +} + +static int _tnum = 0; +#pragma pack(1) +typedef struct tgaheader_tag +{ + char idlen; + + char colormap; + + char imagetype; + + short cm_index; + short cm_len; + char cm_entrysize; + + short x, y, w, h; + char depth; + char imagedesc; + +} tgaheader_t; +#pragma pack() + +void crDumpTGA(GLint w, GLint h, GLvoid *data) +{ + char fname[200]; + + if (!w || !h) return; + + sprintf(fname, "tex%i.tga", _tnum++); + crDumpNamedTGA(fname, w, h, data); +} + +void crDumpNamedTGA(const char* fname, GLint w, GLint h, GLvoid *data) +{ + tgaheader_t header; + FILE *out; + + out = fopen(fname, "w"); + if (!out) crError("can't create %s!", fname); + + header.idlen = 0; + header.colormap = 0; + header.imagetype = 2; + header.cm_index = 0; + header.cm_len = 0; + header.cm_entrysize = 0; + header.x = 0; + header.y = 0; + header.w = w; + header.h = h; + header.depth = 32; + header.imagedesc = 0x08; + fwrite(&header, sizeof(header), 1, out); + + fwrite(data, w*h*4, 1, out); + + fclose(out); +} + +void crDumpNamedTGAV(GLint w, GLint h, GLvoid *data, const char* fname, va_list va) +{ + char szName[4096]; + RTStrPrintfV(szName, sizeof(szName), fname, va); + crDumpNamedTGA(szName, w, h, data); +} + +void crDumpNamedTGAF(GLint w, GLint h, GLvoid *data, const char* fname, ...) +{ + va_list va; + va_start(va, fname); + crDumpNamedTGAV(w, h, data, fname, va); + va_end(va); +} diff --git a/src/VBox/GuestHost/OpenGL/util/process.c b/src/VBox/GuestHost/OpenGL/util/process.c new file mode 100644 index 00000000..af16689f --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/process.c @@ -0,0 +1,251 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_error.h" +#include "cr_process.h" +#include "cr_string.h" +#include "cr_mem.h" +#include +#include +#include +#include +#ifndef WINDOWS +#include +# ifdef VBOX +# include +# endif +#else +#pragma warning ( disable : 4127 ) +#define snprintf _snprintf +#endif + +/** + * Sleep/pause for the given number of seconds. + */ +void crSleep( unsigned int seconds ) +{ +#ifdef WINDOWS + Sleep(seconds*1000); /* milliseconds */ +#else + sleep(seconds); +#endif +} + +/** + * Sleep/pause for the given number of milliseconds. + */ +void crMsleep( unsigned int msec ) +{ +#ifdef WINDOWS + Sleep(msec); +#else + usleep(msec*1000); /* usecs */ +#endif +} + + +/* + * Spawn (i.e. fork/exec) a new process. + */ +CRpid crSpawn( const char *command, const char *argv[] ) +{ +#ifdef WINDOWS + char newargv[1000]; + int i; + STARTUPINFO si; + PROCESS_INFORMATION pi; + + (void) command; + + ZeroMemory( &si, sizeof(si) ); + si.cb = sizeof(si); + ZeroMemory( &pi, sizeof(pi) ); + + crStrncpy(newargv, argv[0], 1000 ); + for (i = 1; argv[i]; i++) { + crStrcat(newargv, " "); + crStrcat(newargv, argv[i]); + } + + if ( !CreateProcess(NULL, newargv, NULL, NULL, FALSE, 0, NULL, + NULL, &si, &pi) ) + { + crWarning("crSpawn failed, %d", GetLastError()); + return 0; + } + return pi.hProcess; +#else + pid_t pid; + if ((pid = fork()) == 0) + { + /* I'm the child */ + int err = execvp(command, (char * const *) argv); + crWarning("crSpawn failed (return code: %d)", err); + return 0; + } + return (unsigned long) pid; +#endif +} + + +/* + * Kill the named process. + */ +void crKill( CRpid pid ) +{ +#ifdef WINDOWS + TerminateProcess( pid, 0 ); +#else + kill((pid_t) pid, SIGKILL); +#endif +} + + +/* + * Return the name of the running process. + * name[0] will be zero if anything goes wrong. + */ +void crGetProcName( char *name, int maxLen ) +{ +#ifdef WINDOWS + char command[1000]; + int c = 0; + + *name = 0; + + if (!GetModuleFileName( NULL, command, maxLen )) + return; + + while (1) { + /* crude mechanism to blank out the backslashes + * in the Windows filename and recover the actual + * program name to return */ + if (crStrstr(command, "\\")) { + crStrncpy(name, command+c+1, maxLen); + command[c] = 32; + c++; + } + else + break; + } +#else +#ifdef VBOX + const char *pszExecName, *pszProgName; +# ifdef SunOS + pszExecName = getexecname(); +# elif defined(DARWIN) + pszExecName = getprogname(); +# else + extern const char *__progname; + pszExecName = __progname; +# endif + if (!pszExecName) + pszExecName = ""; + pszProgName = strrchr(pszExecName, '/'); + if (pszProgName && *(pszProgName + 1)) + pszProgName++; + else + pszProgName = pszExecName; + strncpy(name, pszProgName, maxLen); + name[maxLen - 1] = '\0'; +# else + /* Unix: + * Call getpid() to get our process ID. + * Then use system() to write the output of 'ps' to a temp file. + * Read/scan the temp file to map the process ID to process name. + * I'd love to find a better solution! (BrianP) + */ + FILE *f; + pid_t pid = getpid(); + char *tmp, command[1000]; + + /* init to NULL in case of early return */ + *name = 0; + + /* get a temporary file name */ + tmp = tmpnam(NULL); + if (!tmp) + return; + /* pipe output of ps to temp file */ +#ifndef SunOS + sprintf(command, "ps > %s", tmp); +#else + sprintf(command, "ps -e -o 'pid tty time comm'> %s", tmp); +#endif + system(command); + + /* open/scan temp file */ + f = fopen(tmp, "r"); + if (f) { + char buffer[1000], cmd[1000], *psz, *pname; + while (!feof(f)) { + int id; + fgets(buffer, 999, f); + sscanf(buffer, "%d %*s %*s %999s", &id, cmd); + if (id == pid) { + for (pname=psz=&cmd[0]; *psz!=0; psz++) + { + switch (*psz) + { + case '/': + pname = psz+1; + break; + } + } + crStrncpy(name, pname, maxLen); + break; + } + } + fclose(f); + } + remove(tmp); +# endif +#endif +} + + +/* + * Return current directory string. + */ +void crGetCurrentDir( char *dir, int maxLen ) +{ +#ifdef WINDOWS + if (!GetCurrentDirectory(maxLen, dir)) + dir[0] = 0; +#else + if (!getcwd(dir, maxLen)) + dir[0] = 0; +#endif +} + + +/** + * Return current process ID number. + */ +CRpid crGetPID(void) +{ +#ifdef WINDOWS + /*return _getpid();*/ + return GetCurrentProcess(); +#else + return getpid(); +#endif +} + + +#if 0 +/* simple test harness */ +int main(int argc, char **argv) +{ + char name[100]; + printf("argv[0] = %s\n", argv[0]); + + crGetProcName(name, 100); + printf("crGetProcName returned %s\n", name); + + return 0; +} +#endif diff --git a/src/VBox/GuestHost/OpenGL/util/rand.c b/src/VBox/GuestHost/OpenGL/util/rand.c new file mode 100644 index 00000000..519871de --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/rand.c @@ -0,0 +1,115 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_rand.h" + +#ifdef WINDOWS +#define WIN32_LEAN_AND_MEAN +# ifdef VBOX +# include +# else +#include +# endif +#else +#include +#endif + + +/* Period parameters */ +#define N 624 +#define M 397 +#define MATRIX_A 0x9908b0df /* constant vector a */ +#define UPPER_MASK 0x80000000 /* most significant w-r bits */ +#define LOWER_MASK 0x7fffffff /* least significant r bits */ + +/* Tempering parameters */ +#define TEMPERING_MASK_B 0x9d2c5680 +#define TEMPERING_MASK_C 0xefc60000 +#define TEMPERING_SHIFT_U(y) (y >> 11) +#define TEMPERING_SHIFT_S(y) (y << 7) +#define TEMPERING_SHIFT_T(y) (y << 15) +#define TEMPERING_SHIFT_L(y) (y >> 18) + +static unsigned long mt[N]; /* the array for the state vector */ +static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */ + +void crRandSeed(unsigned long seed) +{ + /* setting initial seeds to mt[N] using the generator Line 25 of Table 1 + in [KNUTH 1981, The Art of Computer Programming Vol. 2 (2nd Ed.), + pp102 + */ + if (seed == 0) + seed = 4357; /* pick default seed if seed=0 (Guy Zadickario) */ + mt[0]= seed & 0xffffffff; + for (mti=1; mti= N) { /* generate N words at one time */ + int kk; + if (mti == N+1) /* if sgenrand() has not been called, */ + crRandSeed(4357); /* a default initial seed is used */ + + for (kk=0;kk> 1) ^ mag01[y & 0x1]; + } + for (;kk> 1) ^ mag01[y & 0x1]; + } + y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); + mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1]; + mti = 0; + } + + y = mt[mti++]; + y ^= TEMPERING_SHIFT_U(y); + y ^= TEMPERING_SHIFT_S(y) & TEMPERING_MASK_B; + y ^= TEMPERING_SHIFT_T(y) & TEMPERING_MASK_C; + y ^= TEMPERING_SHIFT_L(y); + + return ( (double)y / (unsigned long)0xffffffff ); /* reals */ + /* return y; */ /* for integer generation */ +} + +float crRandFloat(float min, float max) +{ + double t = genrand(); + return (float) (t*min + (1-t)*max); +} + +/* return a random integer in [min, max] (inclusive). */ +int crRandInt(int min, int max) +{ + double t = genrand(); + return min + (int) (t * (max - min + 1)); +} diff --git a/src/VBox/GuestHost/OpenGL/util/sortarray.cpp b/src/VBox/GuestHost/OpenGL/util/sortarray.cpp new file mode 100644 index 00000000..78210280 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/sortarray.cpp @@ -0,0 +1,414 @@ +/* $Id: sortarray.cpp $ */ + +/** @file + * Sorted array impl + */ + +/* + * Copyright (C) 2014-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include +#include +#include +#include + +#include + +VBOXSADECL(int) CrSaInit(CR_SORTARRAY *pArray, uint32_t cInitBuffer) +{ + pArray->cBufferSize = cInitBuffer; + pArray->cSize = 0; + if (cInitBuffer) + { + pArray->pElements = (uint64_t*)RTMemAlloc(cInitBuffer * sizeof (pArray->pElements[0])); + if (!pArray->pElements) + { + WARN(("no memory")); + /* sanity */ + pArray->cBufferSize = 0; + return VERR_NO_MEMORY; + } + } + else + pArray->pElements = NULL; + + return VINF_SUCCESS; +} + +VBOXSADECL(void) CrSaCleanup(CR_SORTARRAY *pArray) +{ + if (pArray->pElements) + RTMemFree(pArray->pElements); + + CrSaInit(pArray, 0); +} + +static int crSaSearch(const CR_SORTARRAY *pArray, uint64_t element) +{ + int iMin = 0; + int iMax = pArray->cSize; + int i = 0; + + while (iMin < iMax) + { + i = (iMax + iMin) / 2; + + uint64_t el = pArray->pElements[i]; + if (el == element) + return i; + else if (el < element) + iMin = i + 1; + else + iMax = i; + } + + return -1; +} + +static void crSaDbgValidate(const CR_SORTARRAY *pArray) +{ + Assert(pArray->cSize <= pArray->cBufferSize); + Assert(!pArray->pElements == !pArray->cBufferSize); + if (!pArray->cSize) + return; + uint64_t cur = pArray->pElements[0]; + for (uint32_t i = 1; i < pArray->cSize; ++i) + { + Assert(pArray->pElements[i] > cur); + cur = pArray->pElements[i]; + } +} + +#ifdef DEBUG +# define crSaValidate crSaDbgValidate +#else +# define crSaValidate(_a) do {} while (0) +#endif + +static int crSaInsAt(CR_SORTARRAY *pArray, uint32_t iPos, uint64_t element) +{ + if (pArray->cSize == pArray->cBufferSize) + { + uint32_t cNewBufferSize = pArray->cBufferSize + 16; + uint64_t *pNew; + if (pArray->pElements) + pNew = (uint64_t*)RTMemRealloc(pArray->pElements, cNewBufferSize * sizeof (pArray->pElements[0])); + else + pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pArray->pElements[0])); + if (!pNew) + { + WARN(("no memory")); + return VERR_NO_MEMORY; + } + + pArray->pElements = pNew; + pArray->cBufferSize = cNewBufferSize; + crSaValidate(pArray); + } + + for (int32_t i = (int32_t)pArray->cSize - 1; i >= (int32_t)iPos; --i) + { + pArray->pElements[i+1] = pArray->pElements[i]; + } + + pArray->pElements[iPos] = element; + ++pArray->cSize; + + crSaValidate(pArray); + + return VINF_SUCCESS; +} + +static void crSaDelAt(CR_SORTARRAY *pArray, uint32_t iPos) +{ + Assert(pArray->cSize > iPos); + + for (uint32_t i = iPos; i < pArray->cSize - 1; ++i) + { + pArray->pElements[i] = pArray->pElements[i+1]; + } + + --pArray->cSize; +} + +static int crSaAdd(CR_SORTARRAY *pArray, uint64_t element) +{ + int iMin = 0; + int iMax = pArray->cSize; + int i = 0; + uint64_t el; + + if (!iMax) + return crSaInsAt(pArray, 0, element); + + el = element; /* Shup up MSC. */ + while (iMin < iMax) + { + i = (iMax + iMin) / 2; + + el = pArray->pElements[i]; + if (el == element) + return VINF_ALREADY_INITIALIZED; + else if (el < element) + iMin = i + 1; + else + iMax = i; + } + + if (el < element) + return crSaInsAt(pArray, i+1, element); + return crSaInsAt(pArray, i, element); +} + +static int crSaRemove(CR_SORTARRAY *pArray, uint64_t element) +{ + int i = crSaSearch(pArray, element); + if (i >= 0) + { + crSaDelAt(pArray, i); + return VINF_SUCCESS; + } + return VINF_ALREADY_INITIALIZED; +} + +/* + * * @return true if element is found */ +VBOXSADECL(bool) CrSaContains(const CR_SORTARRAY *pArray, uint64_t element) +{ + return crSaSearch(pArray, element) >= 0; +} + +VBOXSADECL(int) CrSaAdd(CR_SORTARRAY *pArray, uint64_t element) +{ + return crSaAdd(pArray, element); +} + +VBOXSADECL(int) CrSaRemove(CR_SORTARRAY *pArray, uint64_t element) +{ + return crSaRemove(pArray, element); +} + +static int crSaIntersected(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult) +{ + int rc = VINF_SUCCESS; + CrSaClear(pResult); + + for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; ) + { + if (pArray1->pElements[i] == pArray2->pElements[j]) + { + rc = CrSaAdd(pResult, pArray1->pElements[i]); + if (rc < 0) + { + WARN(("CrSaAdd failed")); + return rc; + } + + ++i; + ++j; + } + else if (pArray1->pElements[i] < pArray2->pElements[j]) + { + ++i; + } + else + { + ++j; + } + } + + return VINF_SUCCESS; +} + +static void crSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2) +{ + for (uint32_t i = 0, j = 0; i < pArray1->cSize && j < pArray2->cSize; ) + { + if (pArray1->pElements[i] == pArray2->pElements[j]) + { + ++i; + ++j; + } + else if (pArray1->pElements[i] < pArray2->pElements[j]) + crSaDelAt(pArray1, i); + else + ++j; + } +} + +/* + * @return >= 0 success + * < 0 - no memory + * */ +VBOXSADECL(void) CrSaIntersect(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2) +{ + crSaIntersect(pArray1, pArray2); +} + +VBOXSADECL(int) CrSaIntersected(CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult) +{ + return crSaIntersected(pArray1, pArray2, pResult); +} + +static int crSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult) +{ + int rc = VINF_SUCCESS; + CrSaClear(pResult); + + uint32_t i = 0, j = 0; + uint32_t cResult = 0; + while (i < pArray1->cSize && j < pArray2->cSize) + { + uint64_t element; + if (pArray1->pElements[i] == pArray2->pElements[j]) + { + element = pArray1->pElements[i]; + ++i; + ++j; + } + else if (pArray1->pElements[i] < pArray2->pElements[j]) + { + element = pArray1->pElements[i]; + ++i; + } + else + { + element = pArray1->pElements[j]; + ++j; + } + + rc = crSaInsAt(pResult, cResult++, element); + if (rc < 0) + { + WARN(("crSaInsAt failed")); + return rc; + } + } + + uint32_t iTail; + const CR_SORTARRAY *pTail; + + if (i < pArray1->cSize) + { + iTail = i; + pTail = pArray1; + } + else if (j < pArray2->cSize) + { + iTail = j; + pTail = pArray2; + } + else + { + iTail = 0; + pTail = 0; + } + + if (pTail) + { + for (;iTail < pTail->cSize; ++iTail) + { + rc = crSaInsAt(pResult, cResult++, pTail->pElements[iTail]); + if (rc < 0) + { + WARN(("crSaInsAt failed")); + return rc; + } + } + } + + return VINF_SUCCESS; +} + +VBOXSADECL(int) CrSaUnited(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2, CR_SORTARRAY *pResult) +{ + return crSaUnited(pArray1, pArray2, pResult); +} + +static int crSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult) +{ + CrSaClear(pResult); + + if (pArray1->cSize > pResult->cBufferSize) + { + CrSaCleanup(pResult); + uint32_t cNewBufferSize = pArray1->cSize; + uint64_t *pNew = (uint64_t*)RTMemAlloc(cNewBufferSize * sizeof (pResult->pElements[0])); + if (!pNew) + { + WARN(("no memory")); + return VERR_NO_MEMORY; + } + + pResult->pElements = pNew; + pResult->cBufferSize = cNewBufferSize; + crSaValidate(pResult); + } + + pResult->cSize = pArray1->cSize; + memcpy(pResult->pElements, pArray1->pElements, pArray1->cSize * sizeof (pArray1->pElements[0])); + return VINF_SUCCESS; +} + +/* + * @return VINF_SUCCESS on success + * VERR_NO_MEMORY - no memory + * */ +VBOXSADECL(int) CrSaClone(const CR_SORTARRAY *pArray1, CR_SORTARRAY *pResult) +{ + return crSaClone(pArray1, pResult); +} + +static int crSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2) +{ + int diff = CrSaGetSize(pArray1) - CrSaGetSize(pArray2); + if (diff) + return diff; + + return memcmp(pArray1->pElements, pArray2->pElements, pArray1->cSize * sizeof (pArray1->pElements[0])); +} + +VBOXSADECL(int) CrSaCmp(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2) +{ + return crSaCmp(pArray1, pArray2); +} + +static bool crSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2) +{ + if (CrSaGetSize(pArray1) < CrSaGetSize(pArray2)) + return false; + + uint32_t i = 0, j = 0; + while (j < pArray2->cSize) + { + if (i == pArray1->cSize) + return false; + + if (pArray1->pElements[i] == pArray2->pElements[j]) + { + ++i; + ++j; + } + else if (pArray1->pElements[i] < pArray2->pElements[j]) + ++i; + else + return false; + } + + return true; +} + +VBOXSADECL(bool) CrSaCovers(const CR_SORTARRAY *pArray1, const CR_SORTARRAY *pArray2) +{ + return crSaCovers(pArray1, pArray2); +} + diff --git a/src/VBox/GuestHost/OpenGL/util/string.c b/src/VBox/GuestHost/OpenGL/util/string.c new file mode 100644 index 00000000..e41aa1ba --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/string.c @@ -0,0 +1,589 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_error.h" + +#include +#include +#include + +int crStrlen( const char *str ) +{ + const char *temp; + if (!str) return 0; + for (temp = str ; *temp ; temp++); + return temp-str; +} + +char *crStrdup( const char *str ) +{ + int len; + char *ret; + + /* Allow strdup'ing of NULL strings -- this makes the __fillin functions + * much cleaner. */ + + if (str == NULL) return NULL; + + len = crStrlen(str); + ret = (char*)crAlloc( len+1 ); + crMemcpy( ret, str, len ); + ret[len] = '\0'; + return ret; +} + +char *crStrndup( const char *str, unsigned int len ) +{ + char *ret = (char*)crAlloc( len+1 ); + crMemcpy( ret, str, len ); + ret[len] = '\0'; + return ret; +} + +int crStrcmp( const char *str1, const char *str2 ) +{ + while (*str1 && *str2) + { + if (*str1 != *str2) + { + break; + } + str1++; str2++; + } + return (*str1 - *str2); +} + +int crStrncmp( const char *str1, const char *str2, int n ) +{ + int i = 0; + while (*str1 && *str2 && i < n) + { + if (*str1 != *str2) + { + break; + } + str1++; str2++; i++; + } + if (i == n) return 0; + return (*str1 - *str2); +} + +static char lowercase[256] = { + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', + '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', + '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', + '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377' +}; + +int crStrcasecmp( const char *str1, const char *str2 ) +{ + while (*str1 && *str2) + { + if (lowercase[(int) *str1] != lowercase[(int) *str2]) + { + break; + } + str1++; str2++; + } + return (lowercase[(int) *str1] - lowercase[(int) *str2]); +} + +void crStrcpy( char *dest, const char *src ) +{ + while ((*dest++ = *src++)) + ; +} + +void crStrncpy( char *dest, const char *src, unsigned int len ) +{ + const unsigned int str_len = crStrlen(src); + if (str_len > len - 1) { + crMemcpy( dest, src, len ); /* NOTE: not null-terminated! */ + } + else { + crMemcpy( dest, src, str_len + 1 ); /* includes null terminator */ + } +} + +void crStrcat( char *dest, const char *src ) +{ + crStrcpy( dest + crStrlen(dest), src ); +} + +char *crStrjoin( const char *str1, const char *str2 ) +{ + const int len1 = crStrlen(str1), len2 = crStrlen(str2); + char *s = crAlloc(len1 + len2 + 1); + if (s) + { + crMemcpy( s, str1, len1 ); + crMemcpy( s + len1, str2, len2 ); + s[len1 + len2] = '\0'; + } + return s; +} + +char *crStrjoin3( const char *str1, const char *str2, const char *str3 ) +{ + const int len1 = crStrlen(str1), len2 = crStrlen(str2), len3 = crStrlen(str3); + char *s = crAlloc(len1 + len2 + len3 + 1); + if (s) + { + crMemcpy( s, str1, len1 ); + crMemcpy( s + len1, str2, len2 ); + crMemcpy( s + len1 + len2, str3, len3 ); + s[len1 + len2 + len3] = '\0'; + } + return s; +} + +char *crStrstr( const char *str, const char *pat ) +{ + int pat_len = crStrlen( pat ); + const char *end = str + crStrlen(str) - pat_len; + char first_char = *pat; + if (!str) return NULL; + for (; str <= end ; str++) + { + if (*str == first_char && !crMemcmp( str, pat, pat_len )) + return (char *) str; + } + return NULL; +} + +char *crStrchr( const char *str, char c ) +{ + for ( ; *str ; str++ ) + { + if (*str == c) + return (char *) str; + } + return NULL; +} + +char *crStrrchr( const char *str, char c ) +{ + const char *temp = str + crStrlen( str ); + for ( ; temp >= str ; temp-- ) + { + if (*temp == c) + return (char *) temp; + } + return NULL; +} + +/* These functions are from the old wiregl net.c -- hexdumps? Not sure quite yet. */ + +void crBytesToString( char *string, int nstring, void *data, int ndata ) +{ + int i, offset; + unsigned char *udata; + + offset = 0; + udata = (unsigned char *) data; + for ( i = 0; i < ndata && ( offset + 4 <= nstring ); i++ ) + { + offset += sprintf( string + offset, "%02x ", udata[i] ); + } + + if ( i == ndata && offset > 0 ) + string[offset-1] = '\0'; + else + crStrcpy( string + offset - 3, "..." ); +} + +void crWordsToString( char *string, int nstring, void *data, int ndata ) +{ + int i, offset, ellipsis; + unsigned int *udata; + + /* turn byte count into word count */ + ndata /= 4; + + /* we need an ellipsis if all the words won't fit in the string */ + ellipsis = ( ndata * 9 > nstring ); + if ( ellipsis ) + { + ndata = nstring / 9; + + /* if the ellipsis won't fit then print one less word */ + if ( ndata * 9 + 3 > nstring ) + ndata--; + } + + offset = 0; + udata = (unsigned int *) data; + for ( i = 0; i < ndata; i++ ) + { + offset += sprintf( string + offset, "%08x ", udata[i] ); + } + + if ( ellipsis ) + crStrcpy( string + offset, "..." ); + else if ( offset > 0 ) + string[offset-1] = 0; +} + +int crStrToInt( const char *str ) +{ + if (!str) return 0; + + return atoi(str); +} + +float crStrToFloat( const char *str ) +{ + if (!str) return 0.0f; + + return (float) atof(str); +} + +static int __numOccurrences( const char *str, const char *substr ) +{ + int ret = 0; + char *temp = (char *) str; + while ((temp = crStrstr( temp, substr )) != NULL ) + { + temp += crStrlen(substr); + ret++; + } + return ret; +} + +/** + * Split str into a NULL-terminated array of strings, using splitstr as + * the separator. + * It's the same as the Python call string.split(str, splitstr). + * Note: crStrSplit("a b c", " ") returns ["a", "b", "", "c", NULL] though!!! + */ +char **crStrSplit( const char *str, const char *splitstr ) +{ + char *temp = (char *) str; + int num_args = __numOccurrences( str, splitstr ) + 1; + char **faked_argv = (char **) crAlloc( (num_args + 1)*sizeof( *faked_argv ) ); + int i; + + for (i = 0 ; i < num_args ; i++) + { + char *end; + end = crStrstr( temp, splitstr ); + if (!end) + end = temp + crStrlen( temp ); + faked_argv[i] = crStrndup( temp, end-temp ); + temp = end + crStrlen(splitstr); + } + faked_argv[num_args] = NULL; + return faked_argv; +} + +char **crStrSplitn( const char *str, const char *splitstr, int n ) +{ + char **faked_argv; + int i; + char *temp = (char *) str; + int num_args = __numOccurrences( str, splitstr ); + + if (num_args > n) + num_args = n; + num_args++; + + faked_argv = (char **) crAlloc( (num_args + 1) * sizeof( *faked_argv ) ); + for (i = 0 ; i < num_args ; i++) + { + char *end; + end = crStrstr( temp, splitstr ); + if (!end || i == num_args - 1 ) + end = temp + crStrlen( temp ); + faked_argv[i] = crStrndup( temp, end-temp ); + temp = end + crStrlen(splitstr); + } + faked_argv[num_args] = NULL; + return faked_argv; +} + +/* Free an array of strings, as returned by crStrSplit() and crStrSplitn(). */ +void crFreeStrings( char **strings ) +{ + int i; + for (i = 0; strings[i]; i++) { + crFree(strings[i]); + } + crFree(strings); +} + + +/* Intersect two strings on a word-by-word basis (separated by spaces). + * We typically use this to intersect OpenGL extension strings. + * Example: if s1 = "apple banana plum pear" + * and s2 = "plum banana orange" + * then return "banana plum" (or "plum banana"). + */ +char *crStrIntersect( const char *s1, const char *s2 ) +{ + int len1, len2; + int resultLen; + char *result; + char **exten1, **exten2; + int i, j; + + if (!s1 || !s2) { + /* null strings, no intersection */ + return NULL; + } + + len1 = crStrlen(s1); + len2 = crStrlen(s2); + + /* allocate storage for result (a conservative estimate) */ + resultLen = ((len1 > len2) ? len1 : len2) + 2; + result = (char *) crAlloc(resultLen); + if (!result) + { + return NULL; + } + result[0] = 0; + + /* split s1 and s2 at space chars */ + exten1 = crStrSplit(s1, " "); + exten2 = crStrSplit(s2, " "); + + for (i = 0; exten1[i]; i++) + { + for (j = 0; exten2[j]; j++) + { + if (crStrcmp(exten1[i], exten2[j]) == 0) + { + /* found an intersection, append to result */ + crStrcat(result, exten1[i]); + crStrcat(result, " "); + break; + } + } + } + + /* free split strings */ + crFreeStrings( exten1 ); + crFreeStrings( exten2 ); + + /*CRASSERT(crStrlen(result) < resultLen);*/ + + /* all done! */ + return result; +} + + +int crIsDigit(char c) +{ + return c >= '0' && c <= '9'; +} + + +static int crStrParseGlSubver(const char * ver, const char ** pNext, bool bSpacePrefixAllowed) +{ + const char * initVer = ver; + int val = 0; + + for(;;++ver) + { + if(*ver >= '0' && *ver <= '9') + { + if(!val) + { + if(*ver == '0') + continue; + } + else + { + val *= 10; + } + val += *ver - '0'; + } + else if(*ver == '.') + { + *pNext = ver+1; + break; + } + else if(*ver == '\0') + { + *pNext = NULL; + break; + } + else if(*ver == ' ' || *ver == '\t' || *ver == 0x0d || *ver == 0x0a) + { + if(bSpacePrefixAllowed) + { + if(!val) + { + continue; + } + } + + /* treat this as the end of version string */ + *pNext = NULL; + break; + } + else + { + crWarning("error parsing version %s", initVer); + val = -1; + break; + } + } + + return val; +} + +int crStrParseGlVersion(const char * ver) +{ + const char * initVer = ver; + int tmp; + int iVer = crStrParseGlSubver(ver, &ver, true); + if(iVer <= 0) + { + crWarning("parsing major version returned %d, '%s'", iVer, initVer); + return iVer; + } + + if (iVer > CR_GLVERSION_MAX_MAJOR) + { + crWarning("major version %d is bigger than the max supported %#x, this is somewhat not expected, failing", iVer, CR_GLVERSION_MAX_MAJOR); + return -1; + } + + iVer <<= CR_GLVERSION_OFFSET_MAJOR; + if(!ver) + { + crDebug("no minor version supplied"); + goto done; + } + + tmp = crStrParseGlSubver(ver, &ver, false); + if (tmp < 0) + { + crWarning("parsing minor version failed, '%s'", initVer); + return -1; + } + + if (tmp > CR_GLVERSION_MAX_MINOR) + { + crWarning("minor version %d is bigger than the max supported %#x, this is somewhat not expected, failing", iVer, CR_GLVERSION_MAX_MAJOR); + return -1; + } + + iVer |= tmp << CR_GLVERSION_OFFSET_MINOR; + + if (!ver) + { + crDebug("no build version supplied"); + goto done; + } + + tmp = crStrParseGlSubver(ver, &ver, false); + if (tmp < 0) + { + crWarning("parsing build version failed, '%s', using 0", initVer); + tmp = 0; + } + + if (tmp > CR_GLVERSION_MAX_BUILD) + { + crWarning("build version %d is bigger than the max supported, using max supported val %#x", tmp, CR_GLVERSION_MAX_BUILD); + tmp = CR_GLVERSION_MAX_MAJOR; + } + + iVer |= tmp << CR_GLVERSION_OFFSET_BUILD; + +done: + crDebug("returning version %#x for string '%s'", iVer, initVer); + + return iVer; +} + +int32_t crStrParseI32(const char *pszStr, const int32_t defaultVal) +{ + int32_t result = 0; + bool neg = false; + unsigned char iDigit = 0; + if (!pszStr || pszStr[0] == '\0') + return defaultVal; + + for (;;) + { + if (pszStr[0] == '\0') + return defaultVal; + + if (pszStr[0] == ' ' || pszStr[0] == '\t' || pszStr[0] == '\n') + { + ++pszStr; + continue; + } + + if (pszStr[0] == '-') + { + if (neg) + return defaultVal; + + neg = true; + ++pszStr; + continue; + } + + break; + } + + for (;;) + { + unsigned char digit; + if (pszStr[0] == '\0') + { + if (!iDigit) + return defaultVal; + break; + } + + digit = pszStr[0] - '0'; + if (digit > 9) + return defaultVal; + + result *= 10; + result += digit; + ++iDigit; + + ++pszStr; + } + + return !neg ? result : -result; +} diff --git a/src/VBox/GuestHost/OpenGL/util/tcpip.c b/src/VBox/GuestHost/OpenGL/util/tcpip.c new file mode 100644 index 00000000..ce3e8f84 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/tcpip.c @@ -0,0 +1,1472 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifdef WINDOWS +#define WIN32_LEAN_AND_MEAN +# ifdef VBOX +# include +# else /* !VBOX */ +#pragma warning( push, 3 ) +#include +#pragma warning( pop ) +#pragma warning( disable : 4514 ) +#pragma warning( disable : 4127 ) +typedef int ssize_t; +# endif /* !VBOX */ +#else +#include +#include +#ifdef OSF1 +typedef int socklen_t; +#endif +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#ifdef AIX +#include +#endif + +#ifdef LINUX +#include +#include +#endif + +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_bufpool.h" +#include "cr_net.h" +#include "cr_endian.h" +#include "cr_threads.h" +#include "cr_environment.h" +#include "net_internals.h" + +#ifdef ADDRINFO +#define PF PF_UNSPEC +#endif + +#ifdef WINDOWS +# undef EADDRINUSE +#define EADDRINUSE WSAEADDRINUSE +# undef ECONNREFUSED +#define ECONNREFUSED WSAECONNREFUSED +#endif + +#ifdef WINDOWS + +#undef ECONNRESET +#define ECONNRESET WSAECONNRESET +#undef EINTR +#define EINTR WSAEINTR + +int crTCPIPErrno( void ) +{ + return WSAGetLastError( ); +} + +char *crTCPIPErrorString( int err ) +{ + static char buf[512], *temp; + + sprintf( buf, "err=%d", err ); + +#define X(x) crStrcpy(buf,x); break + + switch ( err ) + { + case WSAECONNREFUSED: X( "connection refused" ); + case WSAECONNRESET: X( "connection reset" ); + default: + FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err, + MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), + (LPTSTR) &temp, 0, NULL ); + if ( temp ) + { + crStrncpy( buf, temp, sizeof(buf)-1 ); + buf[sizeof(buf)-1] = 0; + } + } + +#undef X + + temp = buf + crStrlen(buf) - 1; + while ( temp > buf && isspace( *temp ) ) + { + *temp = '\0'; + temp--; + } + + return buf; +} + +#else /* WINDOWS */ + +int crTCPIPErrno( void ) +{ + int err = errno; + errno = 0; + return err; +} + +char *crTCPIPErrorString( int err ) +{ + static char buf[512], *temp; + + temp = strerror( err ); + if ( temp ) + { + crStrncpy( buf, temp, sizeof(buf)-1 ); + buf[sizeof(buf)-1] = 0; + } + else + { + sprintf( buf, "err=%d", err ); + } + + return buf; +} + +#endif /* WINDOWS */ + + +/* + * Socket callbacks. When a socket is created or destroyed we will + * call these callback functions. + * XXX Currently only implemented for TCP/IP. + * XXX Maybe have lists of callbacks? + */ +static CRSocketCallbackProc SocketCreateCallback = NULL; +static CRSocketCallbackProc SocketDestroyCallback = NULL; + +void +crRegisterSocketCallback(int mode, CRSocketCallbackProc proc) +{ + if (mode == CR_SOCKET_CREATE) { + SocketCreateCallback = proc; + } + else if (mode == CR_SOCKET_DESTROY) { + SocketDestroyCallback = proc; + } + else { + crError("Invalid crRegisterSocketCallbac mode=%d", mode); + } +} + + + +void crCloseSocket( CRSocket sock ) +{ + int fail; + + if (sock <= 0) + return; + + if (SocketDestroyCallback) { + SocketDestroyCallback(CR_SOCKET_DESTROY, sock); + } + +#ifdef WINDOWS + fail = ( closesocket( sock ) != 0 ); +#else + shutdown( sock, 2 /* RDWR */ ); + fail = ( close( sock ) != 0 ); +#endif + if ( fail ) + { + int err = crTCPIPErrno( ); + crWarning( "crCloseSocket( sock=%d ): %s", + sock, crTCPIPErrorString( err ) ); + } +} + +cr_tcpip_data cr_tcpip; + +/** + * Read len bytes from socket, and store in buffer. + * \return 1 if success, -1 if error, 0 if sender exited. + */ +int +__tcpip_read_exact( CRSocket sock, void *buf, unsigned int len ) +{ + char *dst = (char *) buf; + /* + * Shouldn't write to a non-existent socket, ie when + * crTCPIPDoDisconnect has removed it from the pool + */ + if ( sock <= 0 ) + return 1; + + while ( len > 0 ) + { + const int num_read = recv( sock, dst, (int) len, 0 ); + +#ifdef WINDOWS_XXXX + /* MWE: why is this necessary for windows??? Does it return a + "good" value for num_bytes despite having a reset + connection? */ + if ( crTCPIPErrno( ) == ECONNRESET ) + return -1; +#endif + + if ( num_read < 0 ) + { + int error = crTCPIPErrno(); + switch( error ) + { + case EINTR: + crWarning( "__tcpip_read_exact(TCPIP): " + "caught an EINTR, looping for more data" ); + continue; + case EFAULT: + crWarning( "EFAULT" ); + break; + case EINVAL: + crWarning( "EINVAL" ); + break; + default: + break; + } + crWarning( "Bad bad bad socket error: %s", crTCPIPErrorString( error ) ); + return -1; + } + + if ( num_read == 0 ) + { + /* client exited gracefully */ + return 0; + } + + dst += num_read; + len -= num_read; + } + + return 1; +} + +void +crTCPIPReadExact( CRConnection *conn, void *buf, unsigned int len ) +{ + if ( __tcpip_read_exact( conn->tcp_socket, buf, len ) <= 0 ) + { + __tcpip_dead_connection( conn ); + } +} + +/** + * Write the given buffer of len bytes on the socket. + * \return 1 if OK, negative value if error. + */ +int +__tcpip_write_exact( CRSocket sock, const void *buf, unsigned int len ) +{ + const char *src = (const char *) buf; + + /* + * Shouldn't write to a non-existent socket, ie when + * crTCPIPDoDisconnect has removed it from the pool + */ + if ( sock <= 0 ) + return 1; + + while ( len > 0 ) + { + const int num_written = send( sock, src, len, 0 ); + if ( num_written <= 0 ) + { + int err; + if ( (err = crTCPIPErrno( )) == EINTR ) + { + crWarning("__tcpip_write_exact(TCPIP): caught an EINTR, continuing"); + continue; + } + + return -err; + } + + len -= num_written; + src += num_written; + } + + return 1; +} + +void +crTCPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len ) +{ + if ( __tcpip_write_exact( conn->tcp_socket, buf, len) <= 0 ) + { + __tcpip_dead_connection( conn ); + } +} + + +/** + * Make sockets do what we want: + * + * 1) Change the size of the send/receive buffers to 64K + * 2) Turn off Nagle's algorithm + */ +static void +spankSocket( CRSocket sock ) +{ + /* why do we do 1) ? things work much better for me to push the + * the buffer size way up -- karl + */ +#ifdef LINUX + int sndbuf = 1*1024*1024; +#else + int sndbuf = 64*1024; +#endif + + int rcvbuf = sndbuf; + int so_reuseaddr = 1; + int tcp_nodelay = 1; + + if ( setsockopt( sock, SOL_SOCKET, SO_SNDBUF, + (char *) &sndbuf, sizeof(sndbuf) ) ) + { + int err = crTCPIPErrno( ); + crWarning( "setsockopt( SO_SNDBUF=%d ) : %s", + sndbuf, crTCPIPErrorString( err ) ); + } + + if ( setsockopt( sock, SOL_SOCKET, SO_RCVBUF, + (char *) &rcvbuf, sizeof(rcvbuf) ) ) + { + int err = crTCPIPErrno( ); + crWarning( "setsockopt( SO_RCVBUF=%d ) : %s", + rcvbuf, crTCPIPErrorString( err ) ); + } + + + if ( setsockopt( sock, SOL_SOCKET, SO_REUSEADDR, + (char *) &so_reuseaddr, sizeof(so_reuseaddr) ) ) + { + int err = crTCPIPErrno( ); + crWarning( "setsockopt( SO_REUSEADDR=%d ) : %s", + so_reuseaddr, crTCPIPErrorString( err ) ); + } + + if ( setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, + (char *) &tcp_nodelay, sizeof(tcp_nodelay) ) ) + { + int err = crTCPIPErrno( ); + crWarning( "setsockopt( TCP_NODELAY=%d )" + " : %s", tcp_nodelay, crTCPIPErrorString( err ) ); + } +} + + +#if defined( WINDOWS ) || defined( IRIX ) || defined( IRIX64 ) +typedef int socklen_t; +#endif + + +/** + * Create a listening socket using the given port. + * Caller can then pass the socket to accept(). + * If the port is one that's been seen before, we'll reuse/return the + * previously create socket. + */ +static int +CreateListeningSocket(int port) +{ + /* XXX should use an unbounded list here instead of parallel arrays... */ +#define MAX_PORTS 100 + static int ports[MAX_PORTS]; + static int sockets[MAX_PORTS]; + static int count = 0; + int i, sock = -1; + + /* search to see if we've seen this port before */ + for (i = 0; i < count; i++) { + if (ports[i] == port) { + return sockets[i]; + } + } + + /* new port so create new socket */ + { + int err; +#ifndef ADDRINFO + struct sockaddr_in servaddr; +#endif + + /* with the new OOB stuff, we can have multiple ports being + * accepted on, so we need to redo the server socket every time. + */ +#ifndef ADDRINFO + sock = socket( AF_INET, SOCK_STREAM, 0 ); + if ( sock == -1 ) + { + err = crTCPIPErrno( ); + crError( "Couldn't create socket: %s", crTCPIPErrorString( err ) ); + } + spankSocket( sock ); + + servaddr.sin_family = AF_INET; + servaddr.sin_addr.s_addr = INADDR_ANY; + servaddr.sin_port = htons( (short) port ); + + if ( bind( sock, (struct sockaddr *) &servaddr, sizeof(servaddr) ) ) + { + err = crTCPIPErrno( ); + crError( "Couldn't bind to socket (port=%d): %s", + port, crTCPIPErrorString( err ) ); + } + + if ( listen( sock, 100 /* max pending connections */ ) ) + { + err = crTCPIPErrno( ); + crError( "Couldn't listen on socket: %s", crTCPIPErrorString( err ) ); + } +#else + char port_s[NI_MAXSERV]; + struct addrinfo *res,*cur; + struct addrinfo hints; + + sprintf(port_s, "%u", (short unsigned) port); + + crMemset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_PASSIVE; + hints.ai_family = PF; + hints.ai_socktype = SOCK_STREAM; + + err = getaddrinfo( NULL, port_s, &hints, &res ); + if ( err ) + crError( "Couldn't find local TCP port %s: %s", + port_s, gai_strerror(err) ); + + for (cur=res;cur;cur=cur->ai_next) + { + sock = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol ); + if ( sock == -1 ) + { + err = crTCPIPErrno( ); + if (err != EAFNOSUPPORT) + crWarning("Couldn't create socket of family %i: %s, trying another", + cur->ai_family, crTCPIPErrorString( err ) ); + continue; + } + spankSocket( sock ); + + if ( bind( sock, cur->ai_addr, cur->ai_addrlen ) ) + { + err = crTCPIPErrno( ); + crWarning( "Couldn't bind to socket (port=%d): %s", + port, crTCPIPErrorString( err ) ); + crCloseSocket( sock ); + continue; + } + + if ( listen( sock, 100 /* max pending connections */ ) ) + { + err = crTCPIPErrno( ); + crWarning("Couldn't listen on socket: %s", crTCPIPErrorString(err)); + crCloseSocket( sock ); + continue; + } + break; + } + freeaddrinfo(res); + if (!cur) + crError( "Couldn't find/bind local TCP port %s", port_s); +#endif + } + + /* save the new port/socket */ + if (count == MAX_PORTS) { + crError("Fatal error in tcpip layer: too many listening ports/sockets"); + } + ports[count] = port; + sockets[count] = sock; + count++; + + return sock; +} + + + + +void +crTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port ) +{ + int err; + socklen_t addr_length; +#ifndef ADDRINFO + struct hostent *host; + struct in_addr sin_addr; + struct sockaddr addr; +#else + struct sockaddr_storage addr; + char host[NI_MAXHOST]; +#endif + (void)hostname; + + cr_tcpip.server_sock = CreateListeningSocket(port); + + /* If brokered, we'll contact the mothership to broker the network + * connection. We'll send the mothership our hostname, the port and + * our endianness and will get in return a connection ID number. + */ + if (conn->broker) { + crError("There shouldn't be any brokered connections in VirtualBox"); + } + + addr_length = sizeof( addr ); + conn->tcp_socket = accept( cr_tcpip.server_sock, (struct sockaddr *) &addr, &addr_length ); + if (conn->tcp_socket == -1) + { + err = crTCPIPErrno( ); + crError( "Couldn't accept client: %s", crTCPIPErrorString( err ) ); + } + + if (SocketCreateCallback) { + SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket); + } + +#ifndef ADDRINFO + sin_addr = ((struct sockaddr_in *) &addr)->sin_addr; + host = gethostbyaddr( (char *) &sin_addr, sizeof( sin_addr), AF_INET ); + if (host == NULL ) + { + char *temp = inet_ntoa( sin_addr ); + conn->hostname = crStrdup( temp ); + } +#else + err = getnameinfo ( (struct sockaddr *) &addr, addr_length, + host, sizeof( host), + NULL, 0, NI_NAMEREQD); + if ( err ) + { + err = getnameinfo ( (struct sockaddr *) &addr, addr_length, + host, sizeof( host), + NULL, 0, NI_NUMERICHOST); + if ( err ) /* shouldn't ever happen */ + conn->hostname = crStrdup("unknown ?!"); + else + conn->hostname = crStrdup( host ); + } +#endif + else + { + char *temp; +#ifndef ADDRINFO + conn->hostname = crStrdup( host->h_name ); +#else + conn->hostname = crStrdup( host ); +#endif + + temp = conn->hostname; + while (*temp && *temp != '.' ) + temp++; + *temp = '\0'; + } + +#ifdef RECV_BAIL_OUT + err = sizeof(unsigned int); + if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF, + (char *) &conn->krecv_buf_size, &err ) ) + { + conn->krecv_buf_size = 0; + } +#endif + + crDebug( "Accepted connection from \"%s\".", conn->hostname ); +} + + +void * +crTCPIPAlloc( CRConnection *conn ) +{ + CRTCPIPBuffer *buf; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_tcpip.mutex); +#endif + + buf = (CRTCPIPBuffer *) crBufferPoolPop( cr_tcpip.bufpool, conn->buffer_size ); + + if ( buf == NULL ) + { + crDebug("Buffer pool %p was empty; allocated new %d byte buffer.", + cr_tcpip.bufpool, + (unsigned int)sizeof(CRTCPIPBuffer) + conn->buffer_size); + buf = (CRTCPIPBuffer *) + crAlloc( sizeof(CRTCPIPBuffer) + conn->buffer_size ); + buf->magic = CR_TCPIP_BUFFER_MAGIC; + buf->kind = CRTCPIPMemory; + buf->pad = 0; + buf->allocated = conn->buffer_size; + } + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.mutex); +#endif + + return (void *)( buf + 1 ); +} + + +static void +crTCPIPSingleRecv( CRConnection *conn, void *buf, unsigned int len ) +{ + crTCPIPReadExact( conn, buf, len ); +} + + +static void +crTCPIPSend( CRConnection *conn, void **bufp, + const void *start, unsigned int len ) +{ + if ( !conn || conn->type == CR_NO_CONNECTION ) + return; + + if (!bufp) { + /* We're sending a user-allocated buffer. + * Simply write the length & the payload and return. + */ + const int sendable_len = conn->swap ? SWAP32(len) : len; + crTCPIPWriteExact( conn, &sendable_len, sizeof(len) ); + if (conn->type == CR_NO_CONNECTION) + return; + crTCPIPWriteExact( conn, start, len ); + } + else { + /* The region [start .. start + len + 1] lies within a buffer that + * was allocated with crTCPIPAlloc() and can be put into the free + * buffer pool when we're done sending it. + */ + CRTCPIPBuffer *tcpip_buffer; + unsigned int *lenp; + + tcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1; + + CRASSERT( tcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC ); + + /* All of the buffers passed to the send function were allocated + * with crTCPIPAlloc(), which includes a header with a 4 byte + * pad field, to insure that we always have a place to write + * the length field, even when start == *bufp. + */ + lenp = (unsigned int *) start - 1; + *lenp = conn->swap ? SWAP32(len) : len; + + crTCPIPWriteExact(conn, lenp, len + sizeof(unsigned int)); + + /* Reclaim this pointer for reuse */ +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_tcpip.mutex); +#endif + crBufferPoolPush(cr_tcpip.bufpool, tcpip_buffer, tcpip_buffer->allocated); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.mutex); +#endif + /* Since the buffer's now in the 'free' buffer pool, the caller can't + * use it any more. Setting bufp to NULL will make sure the caller + * doesn't try to re-use the buffer. + */ + *bufp = NULL; + } +} + + +void +__tcpip_dead_connection( CRConnection *conn ) +{ + crDebug( "Dead connection (sock=%d, host=%s), removing from pool", + conn->tcp_socket, conn->hostname ); + /* remove from connection pool */ + crTCPIPDoDisconnect( conn ); +} + + +int +__crSelect( int n, fd_set *readfds, int sec, int usec ) +{ + for ( ; ; ) + { + int err, num_ready; + + if (sec || usec) + { + /* We re-init everytime for Linux, as it corrupts + * the timeout structure, but other OS's + * don't have a problem with it. + */ + struct timeval timeout; + timeout.tv_sec = sec; + timeout.tv_usec = usec; + num_ready = select( n, readfds, NULL, NULL, &timeout ); + } + else + num_ready = select( n, readfds, NULL, NULL, NULL ); + + if ( num_ready >= 0 ) + { + return num_ready; + } + + err = crTCPIPErrno( ); + if ( err == EINTR ) + { + crWarning( "select interrupted by an unblocked signal, trying again" ); + } + else + { + crError( "select failed: %s", crTCPIPErrorString( err ) ); + } + } +} + + +void +crTCPIPFree( CRConnection *conn, void *buf ) +{ + CRTCPIPBuffer *tcpip_buffer = (CRTCPIPBuffer *) buf - 1; + + CRASSERT( tcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC ); + conn->recv_credits += tcpip_buffer->len; + + switch ( tcpip_buffer->kind ) + { + case CRTCPIPMemory: +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_tcpip.mutex); +#endif + if (cr_tcpip.bufpool) { + /* pool may have been deallocated just a bit earlier in response + * to a SIGPIPE (Broken Pipe) signal. + */ + crBufferPoolPush( cr_tcpip.bufpool, tcpip_buffer, tcpip_buffer->allocated ); + } +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.mutex); +#endif + break; + + case CRTCPIPMemoryBig: + crFree( tcpip_buffer ); + break; + + default: + crError( "Weird buffer kind trying to free in crTCPIPFree: %d", tcpip_buffer->kind ); + } +} + + +/** + * Check if message type is GATHER. If so, process it specially. + * \return number of bytes which were consumed + */ +static int +crTCPIPUserbufRecv(CRConnection *conn, CRMessage *msg) +{ + if (msg->header.type == CR_MESSAGE_GATHER) { + /* grab the offset and the length */ + const int len = 2 * sizeof(unsigned int); /* was unsigned long!!!! */ + unsigned int buf[2]; + + if (__tcpip_read_exact(conn->tcp_socket, buf, len) <= 0) + { + __tcpip_dead_connection( conn ); + } + msg->gather.offset = buf[0]; + msg->gather.len = buf[1]; + + /* read the rest into the userbuf */ + if (buf[0] + buf[1] > (unsigned int) conn->userbuf_len) + { + crDebug("userbuf for Gather Message is too small!"); + return len; + } + + if (__tcpip_read_exact(conn->tcp_socket, + conn->userbuf + buf[0], buf[1]) <= 0) + { + __tcpip_dead_connection( conn ); + } + return len + buf[1]; + } + else { + return 0; + } +} + + +/** + * Receive the next message on the given connection. + * If we're being called by crTCPIPRecv(), we already know there's + * something to receive. + */ +static void +crTCPIPReceiveMessage(CRConnection *conn) +{ + CRMessage *msg; + CRMessageType cached_type; + CRTCPIPBuffer *tcpip_buffer; + unsigned int len, total, leftover; + const int sock = conn->tcp_socket; + + /* Our gigE board is acting odd. If we recv() an amount + * less than what is already in the RECVBUF, performance + * goes into the toilet (somewhere around a factor of 3). + * This is an ugly hack, but seems to get around whatever + * funk is being produced + * + * Remember to set your kernel recv buffers to be bigger + * than the framebuffer 'chunk' you are sending (see + * sysctl -a | grep rmem) , or this will really have no + * effect. --karl + */ +#ifdef RECV_BAIL_OUT + { + int inbuf; + (void) recv(sock, &len, sizeof(len), MSG_PEEK); + ioctl(conn->tcp_socket, FIONREAD, &inbuf); + + if ((conn->krecv_buf_size > len) && (inbuf < len)) + return; + } +#endif + + /* this reads the length of the message */ + if ( __tcpip_read_exact( sock, &len, sizeof(len)) <= 0 ) + { + __tcpip_dead_connection( conn ); + return; + } + + if (conn->swap) + len = SWAP32(len); + + CRASSERT( len > 0 ); + + if ( len <= conn->buffer_size ) + { + /* put in pre-allocated buffer */ + tcpip_buffer = (CRTCPIPBuffer *) crTCPIPAlloc( conn ) - 1; + } + else + { + /* allocate new buffer */ + tcpip_buffer = (CRTCPIPBuffer *) crAlloc( sizeof(*tcpip_buffer) + len ); + tcpip_buffer->magic = CR_TCPIP_BUFFER_MAGIC; + tcpip_buffer->kind = CRTCPIPMemoryBig; + tcpip_buffer->pad = 0; + } + + tcpip_buffer->len = len; + + /* if we have set a userbuf, and there is room in it, we probably + * want to stick the message into that, instead of our allocated + * buffer. + */ + leftover = 0; + total = len; + if ((conn->userbuf != NULL) + && (conn->userbuf_len >= (int) sizeof(CRMessageHeader))) + { + leftover = len - sizeof(CRMessageHeader); + total = sizeof(CRMessageHeader); + } + + if ( __tcpip_read_exact( sock, tcpip_buffer + 1, total) <= 0 ) + { + crWarning( "Bad juju: %d %d on socket 0x%x", tcpip_buffer->allocated, + total, sock ); + crFree( tcpip_buffer ); + __tcpip_dead_connection( conn ); + return; + } + + conn->recv_credits -= total; + conn->total_bytes_recv += total; + + msg = (CRMessage *) (tcpip_buffer + 1); + cached_type = msg->header.type; + if (conn->swap) + { + msg->header.type = (CRMessageType) SWAP32( msg->header.type ); + msg->header.conn_id = (CRMessageType) SWAP32( msg->header.conn_id ); + } + + /* if there is still data pending, it should go into the user buffer */ + if (leftover) + { + const unsigned int handled = crTCPIPUserbufRecv(conn, msg); + + /* if there is anything left, plop it into the recv_buffer */ + if (leftover - handled) + { + if ( __tcpip_read_exact( sock, tcpip_buffer + 1 + total, leftover-handled) <= 0 ) + { + crWarning( "Bad juju: %d %d", tcpip_buffer->allocated, leftover-handled); + crFree( tcpip_buffer ); + __tcpip_dead_connection( conn ); + return; + } + } + + conn->recv_credits -= handled; + conn->total_bytes_recv += handled; + } + + crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len ); +#if 0 + crLogRead( len ); +#endif + + /* CR_MESSAGE_OPCODES is freed in crserverlib/server_stream.c with crNetFree. + * OOB messages are the programmer's problem. -- Humper 12/17/01 + */ + if (cached_type != CR_MESSAGE_OPCODES + && cached_type != CR_MESSAGE_OOB + && cached_type != CR_MESSAGE_GATHER) + { + crTCPIPFree( conn, tcpip_buffer + 1 ); + } +} + + +/** + * Loop over all TCP/IP connections, reading incoming data on those + * that are ready. + */ +int +crTCPIPRecv( void ) +{ + /* ensure we don't get caught with a new thread connecting */ + const int num_conns = cr_tcpip.num_conns; + int num_ready, max_fd, i; + fd_set read_fds; + int msock = -1; /* assumed mothership socket */ +#if CRAPPFAKER_SHOULD_DIE + int none_left = 1; +#endif + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_tcpip.recvmutex); +#endif + + /* + * Loop over all connections and determine which are TCP/IP connections + * that are ready to be read. + */ + max_fd = 0; + FD_ZERO( &read_fds ); + for ( i = 0; i < num_conns; i++ ) + { + CRConnection *conn = cr_tcpip.conns[i]; + if ( !conn || conn->type == CR_NO_CONNECTION ) + continue; + +#if CRAPPFAKER_SHOULD_DIE + none_left = 0; +#endif + + if ( conn->recv_credits > 0 || conn->type != CR_TCPIP ) + { + /* + * NOTE: may want to always put the FD in the descriptor + * set so we'll notice broken connections. Down in the + * loop that iterates over the ready sockets only peek + * (MSG_PEEK flag to recv()?) if the connection isn't + * enabled. + */ +#if 0 /* not used - see below */ +#ifndef ADDRINFO + struct sockaddr s; +#else + struct sockaddr_storage s; +#endif + socklen_t slen; +#endif + fd_set only_fd; /* testing single fd */ + CRSocket sock = conn->tcp_socket; + + if ( (int) sock + 1 > max_fd ) + max_fd = (int) sock + 1; + FD_SET( sock, &read_fds ); + + /* KLUDGE CITY...... + * + * With threads there's a race condition between + * TCPIPRecv and TCPIPSingleRecv when new + * clients are connecting, thus new mothership + * connections are also being established. + * This code below is to check that we're not + * in a state of accepting the socket without + * connecting to it otherwise we fail with + * ENOTCONN later. But, this is really a side + * effect of this routine catching a motherships + * socket connection and reading data that wasn't + * really meant for us. It was really meant for + * TCPIPSingleRecv. So, if we detect an + * in-progress connection we set the msock id + * so that we can assume the motherships socket + * and skip over them. + */ + + FD_ZERO(&only_fd); + FD_SET( sock, &only_fd ); + +#if 0 /* Disabled on Dec 13 2005 by BrianP - seems to cause trouble */ + slen = sizeof( s ); + /* Check that the socket is REALLY connected */ + /* Doesn't this call introduce some inefficiency??? (BP) */ + if (getpeername(sock, (struct sockaddr *) &s, &slen) < 0) { + /* Another kludge..... + * If we disconnect a socket without writing + * anything to it, we end up here. Detect + * the disconnected socket by checking if + * we've ever sent something and then + * disconnect it. + * + * I think the networking layer needs + * a bit of a re-write.... Alan. + */ + if (conn->total_bytes_sent > 0) { + crTCPIPDoDisconnect( conn ); + } + FD_CLR(sock, &read_fds); + msock = sock; + } +#endif + /* + * Nope, that last socket we've just caught in + * the connecting phase. We've probably found + * a mothership connection here, and we shouldn't + * process it + */ + if ((int)sock == msock+1) + FD_CLR(sock, &read_fds); + } + } + +#if CRAPPFAKER_SHOULD_DIE + if (none_left) { + /* + * Caught no more connections. + * Review this if we want to try + * restarting crserver's dynamically. + */ +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.recvmutex); +#endif + crError("No more connections to process, terminating...\n"); + exit(0); /* shouldn't get here */ + } +#endif + + if (!max_fd) { +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.recvmutex); +#endif + return 0; + } + + if ( num_conns ) { + num_ready = __crSelect( max_fd, &read_fds, 0, 500 ); + } + else { + crWarning( "Waiting for first connection..." ); + num_ready = __crSelect( max_fd, &read_fds, 0, 0 ); + } + + if ( num_ready == 0 ) { +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.recvmutex); +#endif + return 0; + } + + /* + * Loop over connections, receive data on the TCP/IP connections that + * we determined are ready above. + */ + for ( i = 0; i < num_conns; i++ ) + { + CRConnection *conn = cr_tcpip.conns[i]; + CRSocket sock; + + if ( !conn || conn->type == CR_NO_CONNECTION ) + continue; + + /* Added by Samuel Thibault during TCP/IP / UDP code factorization */ + if ( conn->type != CR_TCPIP ) + continue; + + sock = conn->tcp_socket; + if ( !FD_ISSET( sock, &read_fds ) ) + continue; + + if (conn->threaded) + continue; + + crTCPIPReceiveMessage(conn); + } + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.recvmutex); +#endif + + return 1; +} + + +static void +crTCPIPHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len ) +{ + CRTCPIPBuffer *buf = ((CRTCPIPBuffer *) msg) - 1; + + /* build a header so we can delete the message later */ + buf->magic = CR_TCPIP_BUFFER_MAGIC; + buf->kind = CRTCPIPMemory; + buf->len = len; + buf->pad = 0; + + crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len ); +} + + +static void +crTCPIPInstantReclaim( CRConnection *conn, CRMessage *mess ) +{ + crTCPIPFree( conn, mess ); +} + + +void +crTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, + unsigned int mtu ) +{ + (void) mtu; + + cr_tcpip.recv_list = rfl; + cr_tcpip.close_list = cfl; + if ( cr_tcpip.initialized ) + { + return; + } + + cr_tcpip.initialized = 1; + + cr_tcpip.num_conns = 0; + cr_tcpip.conns = NULL; + + cr_tcpip.server_sock = -1; + +#ifdef CHROMIUM_THREADSAFE + crInitMutex(&cr_tcpip.mutex); + crInitMutex(&cr_tcpip.recvmutex); +#endif + cr_tcpip.bufpool = crBufferPoolInit(16); +} + + +/** + * The function that actually connects. This should only be called by clients + * Servers have another way to set up the socket. + */ +int +crTCPIPDoConnect( CRConnection *conn ) +{ + int err; +#ifndef ADDRINFO + struct sockaddr_in servaddr; + struct hostent *hp; + int i; + + conn->tcp_socket = socket( AF_INET, SOCK_STREAM, 0 ); + if ( conn->tcp_socket < 0 ) + { + int err = crTCPIPErrno( ); + crWarning( "socket error: %s", crTCPIPErrorString( err ) ); + cr_tcpip.conns[conn->index] = NULL; /* remove from table */ + return 0; + } + + if (SocketCreateCallback) { + SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket); + } + + /* Set up the socket the way *we* want. */ + spankSocket( conn->tcp_socket ); + + /* Standard Berkeley sockets mumbo jumbo */ + hp = gethostbyname( conn->hostname ); + if ( !hp ) + { + crWarning( "Unknown host: \"%s\"", conn->hostname ); + cr_tcpip.conns[conn->index] = NULL; /* remove from table */ + return 0; + } + + crMemset( &servaddr, 0, sizeof(servaddr) ); + servaddr.sin_family = AF_INET; + servaddr.sin_port = htons( (short) conn->port ); + + crMemcpy((char *) &servaddr.sin_addr, hp->h_addr, sizeof(servaddr.sin_addr)); +#else + char port_s[NI_MAXSERV]; + struct addrinfo *res,*cur; + struct addrinfo hints; + + sprintf(port_s, "%u", (short unsigned) conn->port); + + crMemset(&hints, 0, sizeof(hints)); + hints.ai_family = PF; + hints.ai_socktype = SOCK_STREAM; + + err = getaddrinfo( conn->hostname, port_s, &hints, &res); + if ( err ) + { + crWarning( "Unknown host: \"%s\": %s", conn->hostname, gai_strerror(err) ); + cr_tcpip.conns[conn->index] = NULL; /* remove from table */ + return 0; + } +#endif + + /* If brokered, we'll contact the mothership to broker the network + * connection. We'll send the mothership our hostname, the port and + * our endianness and will get in return a connection ID number. + */ + if (conn->broker) + { + crError("There shouldn't be any brokered connections in VirtualBox"); + } + +#ifndef ADDRINFO + for (i=1;i;) +#else + for (cur=res;cur;) +#endif + { +#ifndef ADDRINFO + +#ifdef RECV_BAIL_OUT + err = sizeof(unsigned int); + if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF, + (char *) &conn->krecv_buf_size, &err ) ) + { + conn->krecv_buf_size = 0; + } +#endif + if ( !connect( conn->tcp_socket, (struct sockaddr *) &servaddr, + sizeof(servaddr) ) ) + return 1; +#else + + conn->tcp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol ); + if ( conn->tcp_socket < 0 ) + { + int err2 = crTCPIPErrno( ); + if (err2 != EAFNOSUPPORT) + crWarning( "socket error: %s, trying another way", crTCPIPErrorString( err2 ) ); + cur=cur->ai_next; + continue; + } + + if (SocketCreateCallback) { + SocketCreateCallback(CR_SOCKET_CREATE, conn->tcp_socket); + } + + err = 1; + setsockopt(conn->tcp_socket, SOL_SOCKET, SO_REUSEADDR, &err, sizeof(int)); + + /* Set up the socket the way *we* want. */ + spankSocket( conn->tcp_socket ); + +#if RECV_BAIL_OUT + err = sizeof(unsigned int); + if ( getsockopt( conn->tcp_socket, SOL_SOCKET, SO_RCVBUF, + (char *) &conn->krecv_buf_size, &err ) ) + { + conn->krecv_buf_size = 0; + } +#endif + + if ( !connect( conn->tcp_socket, cur->ai_addr, cur->ai_addrlen ) ) { + freeaddrinfo(res); + return 1; + } +#endif + + err = crTCPIPErrno( ); + if ( err == EADDRINUSE || err == ECONNREFUSED ) + crWarning( "Connection refused to %s:%d, %s", + conn->hostname, conn->port, crTCPIPErrorString( err ) ); + + else if ( err == EINTR ) + { + crWarning( "connection to %s:%d " + "interrupted, trying again", conn->hostname, conn->port ); + continue; + } + else + crWarning( "Couldn't connect to %s:%d, %s", + conn->hostname, conn->port, crTCPIPErrorString( err ) ); + crCloseSocket( conn->tcp_socket ); +#ifndef ADDRINFO + i=0; +#else + cur=cur->ai_next; +#endif + } +#ifdef ADDRINFO + freeaddrinfo(res); + crWarning( "Couldn't find any suitable way to connect to %s", conn->hostname ); +#endif + cr_tcpip.conns[conn->index] = NULL; /* remove from table */ + return 0; +} + + +/** + * Disconnect this connection, but don't free(conn). + */ +void +crTCPIPDoDisconnect( CRConnection *conn ) +{ + int num_conns = cr_tcpip.num_conns; + int none_left = 1; + int i; + + /* If this connection has already been disconnected (e.g. + * if the connection has been lost and disabled through + * a call to __tcpip_dead_connection(), which will then + * call this routine), don't disconnect it again; if we + * do, and if a new valid connection appears in the same + * slot (conn->index), we'll effectively disable the + * valid connection by mistake, leaving us unable to + * receive inbound data on that connection. + */ + if (conn->type == CR_NO_CONNECTION) return; + + crCloseSocket( conn->tcp_socket ); + if (conn->hostname) { + crFree(conn->hostname); + conn->hostname = NULL; + } + conn->tcp_socket = 0; + conn->type = CR_NO_CONNECTION; + cr_tcpip.conns[conn->index] = NULL; + + /* see if any connections remain */ + for (i = 0; i < num_conns; i++) + { + if ( cr_tcpip.conns[i] && cr_tcpip.conns[i]->type != CR_NO_CONNECTION ) + none_left = 0; /* found a live connection */ + } + +#if 0 /* disabled on 13 Dec 2005 by BrianP - this prevents future client + * connections after the last one goes away. + */ + if (none_left && cr_tcpip.server_sock != -1) + { + crDebug("Closing master socket (probably quitting)."); + crCloseSocket( cr_tcpip.server_sock ); + cr_tcpip.server_sock = -1; +#ifdef CHROMIUM_THREADSAFE + crFreeMutex(&cr_tcpip.mutex); + crFreeMutex(&cr_tcpip.recvmutex); +#endif + crBufferPoolFree( cr_tcpip.bufpool ); + cr_tcpip.bufpool = NULL; + last_port = 0; + cr_tcpip.initialized = 0; + } +#endif +} + + +/** + * Initialize a CRConnection for tcp/ip. This is called via the + * InitConnection() function (and from the UDP module). + */ +void +crTCPIPConnection( CRConnection *conn ) +{ + int i, found = 0; + int n_bytes; + + CRASSERT( cr_tcpip.initialized ); + + conn->type = CR_TCPIP; + conn->Alloc = crTCPIPAlloc; + conn->Send = crTCPIPSend; + conn->SendExact = crTCPIPWriteExact; + conn->Recv = crTCPIPSingleRecv; + conn->RecvMsg = crTCPIPReceiveMessage; + conn->Free = crTCPIPFree; + conn->Accept = crTCPIPAccept; + conn->Connect = crTCPIPDoConnect; + conn->Disconnect = crTCPIPDoDisconnect; + conn->InstantReclaim = crTCPIPInstantReclaim; + conn->HandleNewMessage = crTCPIPHandleNewMessage; + conn->index = cr_tcpip.num_conns; + conn->sizeof_buffer_header = sizeof( CRTCPIPBuffer ); + conn->actual_network = 1; + + conn->krecv_buf_size = 0; + + /* Find a free slot */ + for (i = 0; i < cr_tcpip.num_conns; i++) { + if (cr_tcpip.conns[i] == NULL) { + conn->index = i; + cr_tcpip.conns[i] = conn; + found = 1; + break; + } + } + + /* Realloc connection stack if we couldn't find a free slot */ + if (found == 0) { + n_bytes = ( cr_tcpip.num_conns + 1 ) * sizeof(*cr_tcpip.conns); + crRealloc( (void **) &cr_tcpip.conns, n_bytes ); + cr_tcpip.conns[cr_tcpip.num_conns++] = conn; + } +} + + +int crGetHostname( char *buf, unsigned int len ) +{ + const char *override; + int ret; + + override = crGetenv("CR_HOSTNAME"); + if (override) + { + crStrncpy(buf, override, len); + ret = 0; + } + else + ret = gethostname( buf, len ); + return ret; +} + + +CRConnection** crTCPIPDump( int *num ) +{ + *num = cr_tcpip.num_conns; + + return cr_tcpip.conns; +} diff --git a/src/VBox/GuestHost/OpenGL/util/threads.c b/src/VBox/GuestHost/OpenGL/util/threads.c new file mode 100644 index 00000000..5502fd7c --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/threads.c @@ -0,0 +1,308 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved. + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include "cr_threads.h" +#include "cr_error.h" + +/* perror() messages */ +#define INIT_TSD_ERROR "InitTSD: failed to allocate key" +#define FREE_TSD_ERROR "FreeTSD: failed to destroy key" +#define SET_TSD_ERROR "InitTSD: thread failed to set thread specific data" +#define GET_TSD_ERROR "InitTSD: failed to get thread specific data" + +/* Magic number to determine if a CRtsd has been initialized */ +#define INIT_MAGIC 0xff8adc98 + + +/* Initialize a CRtsd */ +void crInitTSDF(CRtsd *tsd, void (*destructor)(void *)) +{ +#ifdef WINDOWS + tsd->key = TlsAlloc(); + if (tsd->key == 0xffffffff) { + crError("crInitTSD failed!"); + } + (void) destructor; +#else + if (pthread_key_create(&tsd->key, destructor) != 0) + crDebug("crServer: failed to allocate TLS key."); + else + crDebug("crServer: TLS key %d allocated.", tsd->key); +#endif + tsd->initMagic = INIT_MAGIC; +} + + +void crInitTSD(CRtsd *tsd) +{ + crInitTSDF(tsd, NULL); +} + + +void crFreeTSD(CRtsd *tsd) +{ +#ifdef WINDOWS + /* Windows returns true on success, 0 on failure */ + if (TlsFree(tsd->key) == 0) { + crError("crFreeTSD failed!"); + } +#else + if (pthread_key_delete(tsd->key) != 0) + crDebug("crServer: failed to delete TLS key %d.", tsd->key); + else + crDebug("crServer: TLS key %d deleted.", tsd->key); +#endif + tsd->initMagic = 0x0; +} + + +/* Set thread-specific data */ +void crSetTSD(CRtsd *tsd, void *ptr) +{ + if (tsd->initMagic != (int) INIT_MAGIC) { + /* initialize this CRtsd */ + crInitTSD(tsd); + } +#ifdef WINDOWS + if (TlsSetValue(tsd->key, ptr) == 0) { + crError("crSetTSD failed!"); + } +#else + if (pthread_setspecific(tsd->key, ptr) != 0) { + crError("crSetTSD failed!"); + } +#endif +} + + +/* Get thread-specific data */ +void *crGetTSD(CRtsd *tsd) +{ +#ifdef WINDOWS + void * value; + DWORD err; + LPVOID lpMsgBuf; +#endif + if (tsd->initMagic != (int) INIT_MAGIC) { + crInitTSD(tsd); + } +#ifdef WINDOWS + value = TlsGetValue(tsd->key); + if (!value) { + err = GetLastError(); + if ( err != ERROR_SUCCESS ) { + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + err, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPTSTR) &lpMsgBuf, + 0, NULL ); + crError("crGetTSD failed with %d: %s", err, lpMsgBuf); + LocalFree(lpMsgBuf); + } + } + return value; +#else + return pthread_getspecific(tsd->key); +#endif +} + + + +/* Return ID of calling thread */ +unsigned long crThreadID(void) +{ +#ifdef WINDOWS + return (unsigned long) GetCurrentThreadId(); +#else + return (unsigned long) pthread_self(); +#endif +} + + + +void crInitMutex(CRmutex *mutex) +{ +#ifdef WINDOWS + InitializeCriticalSection(mutex); +#else + pthread_mutexattr_t mta; + int rc; + + rc = pthread_mutexattr_init(&mta); + CRASSERT(!rc); + rc = pthread_mutexattr_settype(&mta, PTHREAD_MUTEX_RECURSIVE); + CRASSERT(!rc); + rc = pthread_mutex_init(mutex, &mta); + CRASSERT(!rc); + pthread_mutexattr_destroy(&mta); +#endif +} + + +void crFreeMutex(CRmutex *mutex) +{ +#ifdef WINDOWS + DeleteCriticalSection(mutex); +#else + pthread_mutex_destroy(mutex); +#endif +} + + +void crLockMutex(CRmutex *mutex) +{ +#ifdef WINDOWS + EnterCriticalSection(mutex); +#else + pthread_mutex_lock(mutex); +#endif +} + + +void crUnlockMutex(CRmutex *mutex) +{ +#ifdef WINDOWS + LeaveCriticalSection(mutex); +#else + pthread_mutex_unlock(mutex); +#endif +} + + +void crInitCondition(CRcondition *cond) +{ +#ifdef WINDOWS + /* XXX fix me */ + (void) cond; +#else + int err = pthread_cond_init(cond, NULL); + if (err) { + crError("crInitCondition failed"); + } +#endif +} + + +void crFreeCondition(CRcondition *cond) +{ +#ifdef WINDOWS + /* XXX fix me */ + (void) cond; +#else + int err = pthread_cond_destroy(cond); + if (err) { + crError("crFreeCondition error (threads waiting on the condition?)"); + } +#endif +} + +/** + * We're basically just wrapping the pthread condition var interface. + * See the man page for pthread_cond_wait to learn about the mutex parameter. + */ +void crWaitCondition(CRcondition *cond, CRmutex *mutex) +{ +#ifdef WINDOWS + /* XXX fix me */ + (void) cond; + (void) mutex; +#else + pthread_cond_wait(cond, mutex); +#endif +} + + +void crSignalCondition(CRcondition *cond) +{ +#ifdef WINDOWS + /* XXX fix me */ + (void) cond; +#else + pthread_cond_signal(cond); +#endif +} + + +void crInitBarrier(CRbarrier *b, unsigned int count) +{ +#ifdef WINDOWS + unsigned int i; + for (i = 0; i < count; i++) + b->hEvents[i] = CreateEvent(NULL, FALSE, FALSE, NULL); +#else + b->count = count; + b->waiting = 0; + pthread_cond_init( &(b->cond), NULL ); + pthread_mutex_init( &(b->mutex), NULL ); +#endif +} + + +void crFreeBarrier(CRbarrier *b) +{ + /* XXX anything to do? */ + (void)b; +} + + +void crWaitBarrier(CRbarrier *b) +{ +#ifdef WINDOWS + DWORD dwEvent + = WaitForMultipleObjects( b->count, b->hEvents, FALSE, INFINITE ); + (void)dwEvent; +#else + pthread_mutex_lock( &(b->mutex) ); + b->waiting++; + if (b->waiting < b->count) { + pthread_cond_wait( &(b->cond), &(b->mutex) ); + } + else { + pthread_cond_broadcast( &(b->cond) ); + b->waiting = 0; + } + pthread_mutex_unlock( &(b->mutex) ); +#endif +} + + +void crInitSemaphore(CRsemaphore *s, unsigned int count) +{ +#ifdef WINDOWS + (void) s; (void) count; + crWarning("CRsemaphore functions not implemented on Windows"); +#else + sem_init(s, 0, count); +#endif +} + + +void crWaitSemaphore(CRsemaphore *s) +{ +#ifdef WINDOWS + /* to do */ + (void) s; +#else + sem_wait(s); +#endif +} + + +void crSignalSemaphore(CRsemaphore *s) +{ +#ifdef WINDOWS + /* to do */ + (void) s; +#else + sem_post(s); +#endif +} + diff --git a/src/VBox/GuestHost/OpenGL/util/timer.c b/src/VBox/GuestHost/OpenGL/util/timer.c new file mode 100644 index 00000000..9ac8433c --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/timer.c @@ -0,0 +1,129 @@ + +#ifndef WINDOWS +#include +#include +#include +#include +#include +#if defined( IRIX ) || defined( IRIX64 ) +#include +#endif +#include +#include +#else +#define WIN32_LEAN_AND_MEAN +# ifdef VBOX +# include +# else +#include +# endif +#endif + +#include "cr_timer.h" +#include "cr_mem.h" +#include "cr_error.h" + +static double crTimerGetTime( CRTimer *t ) +{ +#if defined( IRIX ) || defined( IRIX64 ) + if (t->iotimer_addr64) { + volatile iotimer64_t counter_value; + counter_value = *(t->iotimer_addr64); + return ((double) counter_value * .000000000001) * (double) t->cycleval; + } + else { + volatile iotimer32_t counter_value; + counter_value = *(t->iotimer_addr32); + return ((double) counter_value * .000000000001) * (double) t->cycleval; + } +#elif defined( WINDOWS ) + QueryPerformanceCounter( &t->performance_counter ); + return ((double) t->performance_counter.QuadPart)*t->one_over_frequency; +#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined(SunOS) || defined(OSF1) + gettimeofday( &t->timeofday, NULL ); + return t->timeofday.tv_sec + t->timeofday.tv_usec / 1000000.0; +#else +#error TIMERS +#endif +} + +CRTimer *crTimerNewTimer( void ) +{ + CRTimer *t = (CRTimer *) crAlloc( sizeof(*t) ); +#if defined(IRIX) || defined( IRIX64 ) + __psunsigned_t phys_addr, raddr; + int poffmask = getpagesize() - 1; + int counterSize = syssgi(SGI_CYCLECNTR_SIZE); + + phys_addr = syssgi(SGI_QUERY_CYCLECNTR, &(t->cycleval)); + if (phys_addr == ENODEV) { + crError( "Sorry, this SGI doesn't support timers." ); + } + + raddr = phys_addr & ~poffmask; + t->fd = open("/dev/mmem", O_RDONLY); + + if (counterSize == 64) { + t->iotimer_addr64 = + (volatile iotimer64_t *)mmap(0, poffmask, PROT_READ, + MAP_PRIVATE, t->fd, (off_t)raddr); + t->unmapLocation = (void *)t->iotimer_addr64; + t->unmapSize = poffmask; + t->iotimer_addr64 = (iotimer64_t *)((__psunsigned_t)t->iotimer_addr64 + + (phys_addr & poffmask)); + } + else if (counterSize == 32) { + t->iotimer_addr32 = (volatile iotimer32_t *)mmap(0, poffmask, PROT_READ, + MAP_PRIVATE, t->fd, + (off_t)raddr); + t->unmapLocation = (void *)t->iotimer_addr32; + t->unmapSize = poffmask; + t->iotimer_addr32 = (iotimer32_t *)((__psunsigned_t)t->iotimer_addr32 + + (phys_addr & poffmask)); + } + else { + crError( "Fatal timer init error" ); + } +#elif defined( WINDOWS ) + QueryPerformanceFrequency( &t->performance_frequency ); + t->one_over_frequency = 1.0/((double)t->performance_frequency.QuadPart); +#endif + t->time0 = t->elapsed = 0; + t->running = 0; + return t; +} + +void crDestroyTimer( CRTimer *t ) +{ +#if defined( IRIX ) || defined( IRIX64 ) + close( t->fd ); +#endif + crFree( t ); +} + +void crStartTimer( CRTimer *t ) +{ + t->running = 1; + t->time0 = crTimerGetTime( t ); +} + +void crStopTimer( CRTimer *t ) +{ + t->running = 0; + t->elapsed += crTimerGetTime( t ) - t->time0; +} + +void crResetTimer( CRTimer *t ) +{ + t->running = 0; + t->elapsed = 0; +} + +double crTimerTime( CRTimer *t ) +{ + if (t->running) { + crStopTimer( t ); + crStartTimer( t ); + } + return t->elapsed; +} diff --git a/src/VBox/GuestHost/OpenGL/util/udptcpip.c b/src/VBox/GuestHost/OpenGL/util/udptcpip.c new file mode 100644 index 00000000..6d883e83 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/udptcpip.c @@ -0,0 +1,753 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#ifdef WINDOWS +#define WIN32_LEAN_AND_MEAN +#pragma warning( push, 3 ) +#include +#include /* for ipv6 */ +#include +#pragma warning( pop ) +#pragma warning( disable : 4514 ) +#pragma warning( disable : 4127 ) +# ifndef VBOX +typedef int ssize_t; +# endif +#define write(a,b,c) send(a,b,c,0) +#else +#include +#if defined(OSF1) +typedef int socklen_t; +#endif +#include +#include +#include +#ifdef LINUX +#define IP_MTU 14 +#endif +#include +#if !defined(IRIX) /* ip6.h might not be present on other unix variants either */ +#include +#endif +#include +#ifndef DARWIN +#include +#endif +#include +#include +#include +#endif + +#include +#include +#include +#include +#include +#include +#ifdef AIX +#include +#endif + +#include "cr_error.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_bufpool.h" +#include "cr_net.h" +#include "cr_endian.h" +#include "cr_threads.h" +#include "net_internals.h" + +#ifdef ADDRINFO +#define PF PF_UNSPEC +#endif + +#ifndef MSG_TRUNC +#define MSG_TRUNC 0 +#endif + +#ifdef IRIX +/* IRIX defines this token, but appears to be missing the related types + * and functions. Turn it off. + */ +#undef AF_INET6 +#endif + +#if defined( WINDOWS ) || defined( IRIX ) || defined( IRIX64 ) +typedef int socklen_t; +#endif + +static void +crUDPIPWriteExact( CRConnection *conn, const void *buf, unsigned int len ) +{ + int retval; + if ( len > conn->mtu + sizeof(conn->seq) ) + { + crWarning( "crUDPIPWriteExact(%d): too big a packet for mtu %d, dropping !", len, (int)(conn->mtu + sizeof(conn->seq)) ); + return; + } + retval = sendto( conn->udp_socket, buf, len, 0, + (struct sockaddr *) &(conn->remoteaddr), sizeof(conn->remoteaddr)); + if ( retval <= 0 ) + { + int err = crTCPIPErrno( ); + crWarning( "crUDPIPWriteExact(%d): %s", len, crTCPIPErrorString( err ) ); +#ifdef LINUX + if ( err == EMSGSIZE ) + { + int opt; + socklen_t leno = sizeof(opt); + crDebug( "Too big a UDP packet(%d), looking at new MTU...", len ); + if ( getsockopt( conn->udp_socket, SOL_IP, IP_MTU_DISCOVER, &opt, &leno) == -1) + { + err = crTCPIPErrno( ); + crWarning( "Couldn't determine whether PMTU discovery is used : %s", crTCPIPErrorString( err ) ); + return; + } + if ( leno != sizeof(opt) ) + { + crWarning( "Unexpected length %d for PMTU_DISCOVERY option length", leno ); + return; + } + if ( opt == IP_PMTUDISC_DONT ) + { + crWarning( "Uh, PMTU discovery isn't enabled ?!" ); + return; + } + if ( getsockopt( conn->udp_socket, SOL_IP, IP_MTU, &opt, &leno) == -1 ) + { + err = crTCPIPErrno( ); + crWarning( "Couldn't determine the MTU : %s", crTCPIPErrorString( err ) ); + return; + } + if ( leno != sizeof(opt) ) + { + crWarning( "Unexpected length %d for MTU option length", leno ); + return; + } + opt -= sizeof(conn->seq) + sizeof(struct udphdr) + sizeof(struct ip6_hdr); + if (opt >= (int) conn->mtu) + { + crWarning( "But MTU discovery is still bigger ! Narrowing it by hand to %d", conn->mtu = (conn->mtu * 2 / 3) & ~0x3 ); + } + else + { + crDebug( "new MTU is %d", opt ); + conn->mtu = opt & ~0x3; + } + } +#endif + } +} + +static void +crUDPTCPIPAccept( CRConnection *conn, const char *hostname, unsigned short port ) +{ + int err; + socklen_t addr_length; +#ifndef ADDRINFO + struct sockaddr addr; + struct sockaddr_in udpaddr; +#else + struct sockaddr_storage addr; + struct addrinfo *res,*cur; + struct addrinfo hints; +#endif + + crTCPIPAccept( conn, hostname, port ); + +#ifndef ADDRINFO + conn->udp_socket = socket( AF_INET, SOCK_DGRAM, 0 ); + if ( conn->udp_socket >= 0 ) + { + memset(&udpaddr, 0, sizeof(udpaddr)); + udpaddr.sin_family = AF_INET; + udpaddr.sin_addr.s_addr = INADDR_ANY; + udpaddr.sin_port = htons(0); + if ( bind( conn->udp_socket, (struct sockaddr *) &udpaddr, sizeof(udpaddr) ) ) + { + err = crTCPIPErrno( ); + crWarning( "Couldn't bind socket: %s", crTCPIPErrorString( err ) ); + crCloseSocket( conn->udp_socket ); + conn->udp_socket = -1; + } + } +#else + memset(&hints, 0, sizeof(hints)); + hints.ai_flags = AI_PASSIVE; + hints.ai_family = PF; + hints.ai_socktype = SOCK_DGRAM; + + err = getaddrinfo( NULL, "0", &hints, &res); + if ( err ) + crError( "Couldn't find local UDP port: %s", gai_strerror(err)); + + conn->udp_socket = -1; + + for (cur=res;cur;cur=cur->ai_next) + { + conn->udp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol ); + if ( conn->udp_socket == -1 ) + { + err = crTCPIPErrno( ); + if (err != EAFNOSUPPORT) + crWarning( "Couldn't create socket of family %i: %s, trying another one", cur->ai_family, crTCPIPErrorString( err ) ); + continue; + } + if ( bind( conn->udp_socket, cur->ai_addr, cur->ai_addrlen ) ) + { + err = crTCPIPErrno( ); + crWarning( "Couldn't bind socket: %s", crTCPIPErrorString( err ) ); + crCloseSocket( conn->udp_socket ); + conn->udp_socket = -1; + continue; + } + break; + + } + freeaddrinfo(res); +#endif + + if ( conn->udp_socket < 0 ) + crError( "Couldn't find local UDP port" ); + + addr_length = sizeof(addr); + err = getsockname( conn->udp_socket, (struct sockaddr *) &addr, &addr_length ); + + if ( err == -1 ) + crError( "Couldn't get our local UDP port: %s", crTCPIPErrorString( crTCPIPErrno( ) ) ); + + switch (((struct sockaddr *) &addr)->sa_family) { + case AF_INET: + crTCPIPWriteExact( conn, &((struct sockaddr_in *)&addr)->sin_port, + sizeof(((struct sockaddr_in *)&addr)->sin_port)); + break; +#ifdef AF_INET6 + case AF_INET6: + crTCPIPWriteExact( conn, &((struct sockaddr_in6 *)&addr)->sin6_port, + sizeof(((struct sockaddr_in6 *)&addr)->sin6_port)); + break; +#endif + default: + crError( "Unknown address family: %d", ((struct sockaddr *) &addr)->sa_family); + } +} + + +static unsigned int safelen=0; +static void crUDPTCPIPSend( CRConnection *conn, void **bufp, + const void *start, unsigned int len ) +{ + static unsigned int safedone=0; + CRTCPIPBuffer *udptcpip_buffer; + unsigned int *lenp; + + if ( !conn || conn->type == CR_NO_CONNECTION ) + return; + + if ( safelen+len > safelen ) + { + safelen+=len; + if (safelen-safedone>100000) + { + safedone=safelen; + crDebug( "%dKo safe", safelen/1024 ); + } + } + + conn->seq++; + if ( bufp == NULL ) + { + unsigned int len_swap = conn->swap ? SWAP32(len) : len; + /* we are doing synchronous sends from user memory, so no need + * to get fancy. Simply write the length & the payload and + * return. */ + crTCPIPWriteExact( conn, &len_swap, sizeof(len_swap) ); + if ( conn->type == CR_NO_CONNECTION ) return; + crTCPIPWriteExact( conn, start, len ); + return; + } + + udptcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1; + + CRASSERT( udptcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC ); + + /* All of the buffers passed to the send function were allocated + * with crTCPIPAlloc(), which includes a header with a 4 byte + * length field, to insure that we always have a place to write + * the length field, even when start == *bufp. */ + lenp = (unsigned int *) start - 1; + if (conn->swap) + { + *lenp = SWAP32(len); + } + else + { + *lenp = len; + } + + if ( __tcpip_write_exact( conn->tcp_socket, lenp, len + sizeof(*lenp) ) < 0 ) + { + __tcpip_dead_connection( conn ); + } + + /* reclaim this pointer for reuse and try to keep the client from + accidentally reusing it directly */ +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_tcpip.mutex); +#endif + crBufferPoolPush( cr_tcpip.bufpool, udptcpip_buffer, conn->buffer_size ); + /* Since the buffer's now in the 'free' buffer pool, the caller can't + * use it any more. Setting bufp to NULL will make sure the caller + * doesn't try to re-use the buffer. + */ + *bufp = NULL; +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.mutex); +#endif +} + +static unsigned int barflen=0; +static void crUDPTCPIPBarf( CRConnection *conn, void **bufp, + const void *start, unsigned int len) +{ + static unsigned int barfdone=0; + static const unsigned int sizes[]={ + 0,10,50,100,500,1000,5000,10000,UINT_MAX + }; + static unsigned int nbs[sizeof(sizes)/sizeof(int)] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + static unsigned int nb; + unsigned int *seqp; + CRTCPIPBuffer *udptcpip_buffer; + int i; + + if (!bufp) { + crDebug("writing safely %d bytes because from user memory",len); + crUDPTCPIPSend( conn, bufp, start, len); + return; + } + if (len > conn->mtu) { + crDebug("writing safely %d bytes because that is too much for MTU %d", len, conn->mtu); + crUDPTCPIPSend( conn, bufp, start, len); + return; + } + + if ( barflen+len > barflen ) + { + barflen+=len; + nb++; + for(i=0;;i++) + if (len > sizes[i] && len <= sizes[i+1]) { + nbs[i]++; + break; + } + if (barflen-barfdone>1<<22) { + barfdone=barflen; + crDebug( "send traffic: %d%sMo barfed %dKo safe", barflen/(1024*1024), barflen?"":".0", safelen/1024 ); + if (nb) { + for (i=0; i < (int) (sizeof(sizes)/sizeof(int)-1); i++) + fprintf(stderr,"%u:%u%s%% ",sizes[i],(nbs[i]*100)/nb,nbs[i]==0?".0":""); + fprintf(stderr,"\n"); + } + } + } + + udptcpip_buffer = (CRTCPIPBuffer *)(*bufp) - 1; + + CRASSERT( udptcpip_buffer->magic == CR_TCPIP_BUFFER_MAGIC ); + + seqp = (unsigned int *) start - 1; + if (conn->swap) + { + *seqp = SWAP32(conn->seq); + } + else + { + *seqp = conn->seq; + } + crUDPIPWriteExact( conn, seqp, len + sizeof(*seqp) ); + + /* reclaim this pointer for reuse and try to keep the client from + accidentally reusing it directly */ +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_tcpip.mutex); +#endif + crBufferPoolPush( cr_tcpip.bufpool, udptcpip_buffer, conn->buffer_size ); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.mutex); +#endif + *bufp = NULL; +} + +static void +crUDPTCPIPReceive( CRConnection *conn, CRTCPIPBuffer *buf, int len ) +{ + CRMessage *msg; + CRMessageType cached_type; +#if 0 + crLogRead( len ); +#endif + + conn->recv_credits -= len; + + conn->total_bytes_recv += len; + + msg = (CRMessage *) (buf + 1); + cached_type = msg->header.type; + if (conn->swap) + { + msg->header.type = (CRMessageType) SWAP32( msg->header.type ); + msg->header.conn_id = (CRMessageType) SWAP32( msg->header.conn_id ); + } + + crNetDispatchMessage( cr_tcpip.recv_list, conn, msg, len ); + + /* CR_MESSAGE_OPCODES is freed in + * crserverlib/server_stream.c + * + * OOB messages are the programmer's problem. -- Humper 12/17/01 */ + if (cached_type != CR_MESSAGE_OPCODES && cached_type != CR_MESSAGE_OOB) + { + crTCPIPFree( conn, buf + 1 ); + } +} + +int +crUDPTCPIPRecv( void ) +{ + int num_ready, max_fd; + fd_set read_fds; + int i; + /* ensure we don't get caught with a new thread connecting */ + int num_conns = cr_tcpip.num_conns; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&cr_tcpip.recvmutex); +#endif + + max_fd = 0; + FD_ZERO( &read_fds ); + for ( i = 0; i < num_conns; i++ ) + { + CRConnection *conn = cr_tcpip.conns[i]; + if ( !conn || conn->type == CR_NO_CONNECTION ) continue; + if ( conn->recv_credits > 0 || conn->type != CR_UDPTCPIP ) + { + /* + * NOTE: may want to always put the FD in the descriptor + * set so we'll notice broken connections. Down in the + * loop that iterates over the ready sockets only peek + * (MSG_PEEK flag to recv()?) if the connection isn't + * enabled. + */ + CRSocket sock = conn->tcp_socket; + + if (conn->type != CR_UDPTCPIP) + continue; + + if ( (int) sock + 1 > max_fd ) + max_fd = (int) sock + 1; + FD_SET( sock, &read_fds ); + + sock = conn->udp_socket; + if ( (int) sock + 1 > max_fd ) + max_fd = (int) sock + 1; + FD_SET( sock, &read_fds ); + } + } + + if (!max_fd) { +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.recvmutex); +#endif + return 0; + } + + if ( num_conns ) + { + num_ready = __crSelect( max_fd, &read_fds, 0, 500 ); + } + else + { + crWarning( "Waiting for first connection..." ); + num_ready = __crSelect( max_fd, &read_fds, 0, 0 ); + } + + if ( num_ready == 0 ) { +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.recvmutex); +#endif + return 0; + } + + for ( i = 0; i < num_conns; i++ ) + { + CRConnection *conn = cr_tcpip.conns[i]; + CRTCPIPBuffer *buf; + int len; + int sock; + + if ( !conn || conn->type == CR_NO_CONNECTION ) continue; + + if ( conn->type != CR_UDPTCPIP ) + continue; + + if ( conn->udp_packet ) { + unsigned int *seq; + buf = conn->udp_packet; + seq = (unsigned int *)(buf + 1) - 1; + if ( *seq == conn->ack ) + { + crUDPTCPIPReceive( conn, buf, + conn->udp_packetlen ); + conn->udp_packet = NULL; + i--; /* can now read other packets */ + continue; + } + if ( *seq - conn->ack > (~(0U)) >> 1 ) + { + crError( "%u is older than %u ?!", *seq, conn->ack ); + crTCPIPFree( conn, buf + 1 ); + conn->udp_packet = NULL; + i--; /* can now read other packets */ + continue; + } + /* still too early, wait for TCP data */ + } + else if ( FD_ISSET(conn->udp_socket, &read_fds ) ) + { + unsigned int *seq; + buf = ((CRTCPIPBuffer *) crTCPIPAlloc( conn )) - 1; + seq = ((unsigned int *) (buf + 1)) - 1; + + len = recv( conn->udp_socket, (void *)seq, + buf->allocated + sizeof(*seq), MSG_TRUNC ); + + CRASSERT( len > 0 ); + CRASSERT( (unsigned int)len <= buf->allocated + sizeof(*seq) ); + if ( len < (int) sizeof(*seq) ) + { + crWarning( "too short a UDP packet : %d", len); + crTCPIPFree( conn, buf + 1 ); + continue; + } + + buf->len = len; + + if ( *seq == conn->ack) + { + crUDPTCPIPReceive( conn, buf, len ); + continue; + } + + if ( *seq - conn->ack > (~(0U)) >> 1 ) + { + crWarning( "%u is older than %u, dropping", *seq, conn->ack ); + crTCPIPFree( conn, buf + 1 ); + continue; + } + conn->udp_packet = buf; + conn->udp_packetlen = len; + } + + sock = conn->tcp_socket; + if ( !FD_ISSET( sock, &read_fds ) ) + continue; + + if ( __tcpip_read_exact( sock, &len, sizeof(len)) <= 0 ) + { + __tcpip_dead_connection( conn ); + i--; + continue; + } + + if (conn->swap) + { + len = SWAP32(len); + } + + CRASSERT( len > 0 ); + + if ( (unsigned int)len <= conn->buffer_size ) + { + buf = (CRTCPIPBuffer *) crTCPIPAlloc( conn ) - 1; + } + else + { + buf = (CRTCPIPBuffer *) + crAlloc( sizeof(*buf) + len ); + buf->magic = CR_TCPIP_BUFFER_MAGIC; + buf->kind = CRTCPIPMemoryBig; + buf->pad = 0; + } + + buf->len = len; + + if ( __tcpip_read_exact( sock, buf + 1, len ) <= 0 ) + { + crWarning( "Bad juju: %d %d", buf->allocated, len ); + crFree( buf ); + __tcpip_dead_connection( conn ); + i--; + continue; + } + + crUDPTCPIPReceive( conn, buf, len ); + conn->ack++; + } + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&cr_tcpip.recvmutex); +#endif + + return 1; +} + +void crUDPTCPIPInit( CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu ) +{ + crTCPIPInit( rfl, cfl, mtu ); +} + +/* The function that actually connects. This should only be called by clients + * Servers have another way to set up the socket. */ + +static int crUDPTCPIPDoConnect( CRConnection *conn ) +{ +#ifdef WINDOWS + unsigned short port; +#else + in_port_t port; +#endif +#ifdef LINUX + int opt = IP_PMTUDISC_DO; +#endif +#ifndef ADDRINFO + struct hostent *hp; +#else + int err; + char port_s[NI_MAXSERV]; + struct addrinfo *res,*cur; + struct addrinfo hints; +#endif + + /* first connect to its tcp port */ + if ( !crTCPIPDoConnect( conn ) ) + return 0; + + /* read its UDP port */ + crTCPIPReadExact( conn, &port, sizeof( port ) ); + port = ntohs(port); + + crDebug( "Server's UDP port is %d", port); + + /* and connect to it */ +#ifndef ADDRINFO + hp = gethostbyname( conn->hostname ); + if ( !hp ) + { + crWarning( "Unknown host: \"%s\"", conn->hostname ); + return 0; + } + conn->udp_socket = socket( AF_INET, SOCK_DGRAM, 0 ); + memset(&conn->remoteaddr, 0, sizeof(conn->remoteaddr)); + conn->remoteaddr.sin_family = AF_INET; + conn->remoteaddr.sin_port = htons( (short) port ); + + memcpy( (char *) &conn->remoteaddr.sin_addr, hp->h_addr, + sizeof(conn->remoteaddr.sin_addr) ); + if ( conn->udp_socket >= 0 ) { + if ( connect( conn->udp_socket, (struct sockaddr *) &conn->remoteaddr, + sizeof(conn->remoteaddr) ) == -1 ) + crWarning( "Couldn't connect UDP socket : %s", crTCPIPErrorString( crTCPIPErrno( ) ) ); + } else { +#else + sprintf(port_s, "%u", port); + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF; + hints.ai_socktype = SOCK_DGRAM; + + err = getaddrinfo( conn->hostname, port_s, &hints, &res); + if ( err ) + { + crWarning( "Unknown host: \"%s\": %s", conn->hostname, gai_strerror(err) ); + return 0; + } + + for (cur=res;cur;) + { + conn->udp_socket = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol ); + if ( conn->udp_socket >= 0 ) + { + if ( connect( conn->udp_socket, cur->ai_addr, cur->ai_addrlen ) == -1 ) + crWarning( "Couldn't connect UDP socket : %s", crTCPIPErrorString( crTCPIPErrno( ) ) ); + break; + } + err = crTCPIPErrno( ); + if (err != EAFNOSUPPORT) + crWarning( "socket error: %s, trying another way", crTCPIPErrorString( err ) ); + cur=cur->ai_next; + } + if (!cur) { + freeaddrinfo(res); +#endif + crWarning( "Couldn't find any suitable way to connect to %s:%d", conn->hostname, port ); + return 0; + } + +#ifdef LINUX + if ( setsockopt(conn->udp_socket, SOL_IP, IP_MTU_DISCOVER, &opt, sizeof(opt)) == -1 ) + { + err = crTCPIPErrno( ); + crWarning( "MTU discovery can't be activated : %s", crTCPIPErrorString( err ) ); + } + else + { + socklen_t len = sizeof(opt); + if ( getsockopt(conn->udp_socket, SOL_IP, IP_MTU, &opt, &len) == -1 ) + crWarning( "MTU couldn't be got : %s", crTCPIPErrorString( crTCPIPErrno ( ) ) ); + else + if ( len != sizeof(opt) ) + crWarning( "Unexpected length %d for MTU option length", len ); + else + { + opt -= sizeof(conn->seq) + sizeof(struct udphdr) + sizeof(struct ip6_hdr); + crDebug( "MTU is (for now) %d", opt ); + conn->mtu = opt; + } + } +#endif +#ifdef ADDRINFO + crMemcpy(&conn->remoteaddr, cur->ai_addr, cur->ai_addrlen); + freeaddrinfo(res); +#endif + return 1; +} + +static void crUDPTCPIPDoDisconnect( CRConnection *conn ) +{ + crCloseSocket( conn->udp_socket ); + crTCPIPDoDisconnect( conn ); +} + +void crUDPTCPIPConnection( CRConnection *conn ) +{ + crTCPIPConnection( conn ); + + conn->type = CR_UDPTCPIP; + conn->Send = crUDPTCPIPSend; + conn->Barf = crUDPTCPIPBarf; + conn->SendExact = NULL; + conn->Recv = NULL; /* none for UDP : *must* multiplex ! */ + conn->Accept = crUDPTCPIPAccept; + conn->Connect = crUDPTCPIPDoConnect; + conn->Disconnect = crUDPTCPIPDoDisconnect; + conn->seq = 0; + conn->ack = 0; + conn->udp_packet = NULL; + conn->mtu -= sizeof(conn->seq); /* some room for seq */ +} diff --git a/src/VBox/GuestHost/OpenGL/util/url.c b/src/VBox/GuestHost/OpenGL/util/url.c new file mode 100644 index 00000000..cb5cc3da --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/url.c @@ -0,0 +1,94 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include +#include +#include + +#include "cr_string.h" +#include "cr_url.h" +#include "cr_error.h" + +static int is_digit_string( const char *s ) +{ + if (!isdigit( (int) *s)) + { + return 0; + } + + while (*s && isdigit ( (int) *s)) + { + s++; + } + + return ( *s == 0 ); +} + +int crParseURL( const char *url, char *protocol, char *hostname, + unsigned short *port, unsigned short default_port ) +{ + const char *temp, *temp2; + + /* pull off the protocol */ + temp = crStrstr( url, "://" ); + if ( temp == NULL && protocol != NULL ) + { + crStrcpy( protocol, "tcpip" ); + temp = url; + } + else + { + if (protocol != NULL) { + int len = temp - url; + crStrncpy( protocol, url, len ); + protocol[len] = 0; + } + temp += 3; + } + + /* handle a trailing : to specify the port */ + + /* there might be a filename here */ + temp2 = crStrrchr( temp, '/' ); + if ( temp2 == NULL ) + { + temp2 = crStrrchr( temp, '\\' ); + } + if ( temp2 == NULL ) + { + temp2 = temp; + } + + temp2 = crStrrchr( temp2, ':' ); + if ( temp2 ) + { + if (hostname != NULL) { + int len = temp2 - temp; + crStrncpy( hostname, temp, len ); + hostname[len] = 0; + } + temp2++; + if ( !is_digit_string( temp2 ) ) + goto bad_url; + + if (port != NULL) + *port = (unsigned short) atoi( temp2 ); + } + else + { + if (hostname != NULL) + crStrcpy( hostname, temp ); + if (port != NULL) + *port = default_port; + } + + return 1; + + bad_url: + crWarning( "URL: expected ://" + "[:], what is \"%s\"?", url ); + return 0; +} diff --git a/src/VBox/GuestHost/OpenGL/util/util.def b/src/VBox/GuestHost/OpenGL/util/util.def new file mode 100644 index 00000000..2b7ad85c --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/util.def @@ -0,0 +1,172 @@ +; Copyright (c) 2001, Stanford University +; All rights reserved. +; +; See the file LICENSE.txt for information on redistributing this software. +EXPORTS +crDLLOpen +crDLLGetNoError +crDLLGet +crDLLClose +crError +crWarning +crDebug +crInfo +crParseURL +crAlloc +crCalloc +crAllocDebug +crCallocDebug +crRealloc +crMemset +crFree +crStrSplit +crStrSplitn +crFreeStrings +crStrlen +crStrchr +crStrrchr +crStrdup +crStrndup +crStrcmp +crStrncmp +crStrstr +crStrcasecmp +crStrcpy +crStrncpy +crStrcat +crStrjoin +crStrjoin3 +crStrToInt +crStrToFloat +crStrIntersect +crIsDigit +crBytesToString +crWordsToString +crGetHostname +crGetPID +crNetAcceptClient +crNetConnectToServer +crNetFreeConnection +crNetInit +crNetTearDown +crNetAlloc +crNetSend +crNetSendExact +crNetNewClient +crNetRecv +crNetRecvReadPixels +crNetSingleRecv +crNetReadline +crNetFree +crNetConnect +crNetDisconnect +crNetServerConnect +crNetGetMessage +crNetPeekMessage +crNetNumMessages +crNetDump +crNetBarf +crPixelCopy1D +crPixelCopy2D +crPixelCopy3D +crBitmapCopy +crPixelSize +crImageSize +crTextureSize +crGetenv +crSetenv +crHashtableAdd +crHashtableDelete +crHashtableDeleteEx +crHashtableSearch +crHashtableReplace +crHashtableNumElements +crHashtableWalk +crHashtableWalkUnlocked +crHashtableAllocRegisterKey +crAllocHashtable +crAllocHashtableEx +crFreeHashtable +crFreeHashtableEx +crHashtableGetDataKey +crDetermineEndianness +SWAPDOUBLE +crBufferPoolInit +crBufferPoolPush +crBufferPoolPop +crBufferPoolFree +crTimerNewTimer +crBufferPoolGetNumBuffers +crBufferPoolGetMaxBuffers +crDestroyTimer +crStartTimer +crStopTimer +crResetTimer +crTimerTime +crMemcpy +crMemcmp +crMemZero +crCalloc +crSetTSD +crGetTSD +crInitMutex +crFreeMutex +crLockMutex +crUnlockMutex +crInitCondition +crFreeCondition +crWaitCondition +crSignalCondition +crThreadID +crInitBarrier +crWaitBarrier +crInitSemaphore +crWaitSemaphore +crSignalSemaphore +crInitTSD +crInitTSDF +crSetTSD +crGetTSD +crFreeTSD +crRandFloat +crRandInt +crRandSeed +crRandAutoSeed +crTransformBBox +crProjectBBox +crRectiUnion +crWarpPoint +crHullInteriorBox +crNetSetNodeRange +crNetSetContextRange +crNetSetRank +crNetSetKey +crSleep +crSpawn +crKill +crGetProcName +crGetCurrentDir +crHashtableAllocKeys +crHashtableDeleteBlock +crHashtableIsKeyUsed +crMatrixInit +crMatrixInitFromString +crMatrixInitFromFloats +crMatrixInitFromDoubles +crMatrixPrint +crMatrixGetFloats +crMatrixIsEqual +crMatrixIsIdentity +crMatrixIsOrthographic +crMatrixCopy +crMatrixMultiply +crMatrixInvertTranspose +crMatrixTranspose +crMatrixTranslate +crMatrixRotate +crMatrixScale +crMatrixFrustum +crMatrixOrtho +crMatrixTransformPointf +crMatrixTransformPointd + diff --git a/src/VBox/GuestHost/OpenGL/util/util.rc b/src/VBox/GuestHost/OpenGL/util/util.rc new file mode 100644 index 00000000..c0856ed8 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/util.rc @@ -0,0 +1,69 @@ +/* $Id: util.rc $ */ +/** @file + * VBoxOGLcrutil - Resource file containing version info and icon. + */ + +/* + * Copyright (C) 2009-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#include +#include + +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US + +VS_VERSION_INFO VERSIONINFO + FILEVERSION VBOX_RC_FILE_VERSION + PRODUCTVERSION VBOX_RC_FILE_VERSION + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK + FILEFLAGS VBOX_RC_FILE_FLAGS + FILEOS VBOX_RC_FILE_OS + FILETYPE VBOX_RC_TYPE_DRV + FILESUBTYPE VFT2_DRV_DISPLAY +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "FileDescription", "VirtualBox crOpenGL crutil ICD\0" + VALUE "InternalName", "VBoxOGLcrutil\0" +#ifdef VBOX_WDDM_WOW64 + VALUE "OriginalFilename", "VBoxOGLcrutil-x86.dll\0" +#else + VALUE "OriginalFilename", "VBoxOGLcrutil.dll\0" +#endif + VALUE "CompanyName", VBOX_RC_COMPANY_NAME + VALUE "FileVersion", VBOX_RC_FILE_VERSION_STR + VALUE "LegalCopyright", VBOX_RC_LEGAL_COPYRIGHT + VALUE "ProductName", VBOX_RC_PRODUCT_NAME_GA_STR + VALUE "ProductVersion", VBOX_RC_PRODUCT_VERSION_STR + VBOX_RC_MORE_STRINGS + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1200 + END +END + +1 RCDATA +BEGIN +// Machine dependent parameters + 17, // Height of vertical thumb + 17, // Width of horizontal thumb + 2, // Icon horiz compression factor + 2, // Icon vert compression factor + 1, // Cursor horz compression factor + 1, // Cursor vert compression factor + 0, // Kanji window height + 1, // cxBorder (thickness of vertical lines) + 1 // cyBorder (thickness of horizontal lines) +END diff --git a/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c b/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c new file mode 100644 index 00000000..6ea14f9b --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/vboxhgcm.c @@ -0,0 +1,2498 @@ +/* $Id: vboxhgcm.c $ */ +/** @file + * VBox HGCM connection + */ + +/* + * Copyright (C) 2008-2019 Oracle Corporation + * + * This file is part of VirtualBox Open Source Edition (OSE), as + * available from http://www.virtualbox.org. This file is free software; + * you can redistribute it and/or modify it under the terms of the GNU + * General Public License (GPL) as published by the Free Software + * Foundation, in version 2 as it comes in the "COPYING" file of the + * VirtualBox OSE distribution. VirtualBox OSE is distributed in the + * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. + */ + +#ifdef RT_OS_WINDOWS +# include +# include +#else +# include +# include +# include +# include +# include +#endif + +#include "cr_error.h" +#include "cr_net.h" +#include "cr_bufpool.h" +#include "cr_mem.h" +#include "cr_string.h" +#include "cr_endian.h" +#include "cr_threads.h" +#include "net_internals.h" +#include "cr_process.h" + +#include +#include + +#include +#include + +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) +#include +#endif + +/** @todo move define somewhere else, and make sure it's less than VBGLR0_MAX_HGCM_KERNEL_PARM*/ +/*If we fail to pass data in one chunk, send it in chunks of this size instead*/ +#define CR_HGCM_SPLIT_BUFFER_SIZE (8*_1M) + +#ifndef MIN +# define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + +#ifdef DEBUG_misha +#ifdef CRASSERT +# undef CRASSERT +#endif +#define CRASSERT Assert +#endif +/*#define IN_GUEST +#if defined(IN_GUEST) +#define VBOX_WITH_CRHGSMIPROFILE +#endif */ +#ifdef VBOX_WITH_CRHGSMIPROFILE +#include +#include + +typedef struct VBOXCRHGSMIPROFILE +{ + uint64_t cStartTime; + uint64_t cStepsTime; + uint64_t cSteps; +} VBOXCRHGSMIPROFILE, *PVBOXCRHGSMIPROFILE; + +#define VBOXCRHGSMIPROFILE_GET_TIME_NANO() RTTimeNanoTS() +#define VBOXCRHGSMIPROFILE_GET_TIME_MILLI() RTTimeMilliTS() + +/* 10 sec */ +#define VBOXCRHGSMIPROFILE_LOG_STEP_TIME (10000000000.) + +DECLINLINE(void) vboxCrHgsmiProfileStart(PVBOXCRHGSMIPROFILE pProfile) +{ + pProfile->cStepsTime = 0; + pProfile->cSteps = 0; + pProfile->cStartTime = VBOXCRHGSMIPROFILE_GET_TIME_NANO(); +} + +DECLINLINE(void) vboxCrHgsmiProfileStep(PVBOXCRHGSMIPROFILE pProfile, uint64_t cStepTime) +{ + pProfile->cStepsTime += cStepTime; + ++pProfile->cSteps; +} + +typedef struct VBOXCRHGSMIPROFILE_SCOPE +{ + uint64_t cStartTime; +/* bool bDisable;*/ +} VBOXCRHGSMIPROFILE_SCOPE, *PVBOXCRHGSMIPROFILE_SCOPE; + +static VBOXCRHGSMIPROFILE g_VBoxProfile; + +static void vboxCrHgsmiLog(char * szString, ...) +{ + char szBuffer[4096] = {0}; + va_list pArgList; + va_start(pArgList, szString); + _vsnprintf(szBuffer, sizeof(szBuffer) / sizeof(szBuffer[0]), szString, pArgList); + va_end(pArgList); + +#ifdef VBOX_WITH_CRHGSMI + VBoxCrHgsmiLog(szBuffer); +#else + OutputDebugString(szBuffer); +#endif +} + +DECLINLINE(void) vboxCrHgsmiProfileLog(PVBOXCRHGSMIPROFILE pProfile, uint64_t cTime) +{ + uint64_t profileTime = cTime - pProfile->cStartTime; + double percent = ((double)100.0) * pProfile->cStepsTime / profileTime; + double cps = ((double)1000000000.) * pProfile->cSteps / profileTime; + vboxCrHgsmiLog("hgcm: cps: %.1f, host %.1f%%\n", cps, percent); +} + +DECLINLINE(void) vboxCrHgsmiProfileScopeEnter(PVBOXCRHGSMIPROFILE_SCOPE pScope) +{ +/* pScope->bDisable = false; */ + pScope->cStartTime = VBOXCRHGSMIPROFILE_GET_TIME_NANO(); +} + +DECLINLINE(void) vboxCrHgsmiProfileScopeExit(PVBOXCRHGSMIPROFILE_SCOPE pScope) +{ +/* if (!pScope->bDisable) */ + { + uint64_t cTime = VBOXCRHGSMIPROFILE_GET_TIME_NANO(); + vboxCrHgsmiProfileStep(&g_VBoxProfile, cTime - pScope->cStartTime); + if (VBOXCRHGSMIPROFILE_LOG_STEP_TIME < cTime - g_VBoxProfile.cStartTime) + { + vboxCrHgsmiProfileLog(&g_VBoxProfile, cTime); + vboxCrHgsmiProfileStart(&g_VBoxProfile); + } + } +} + + +#define VBOXCRHGSMIPROFILE_INIT() vboxCrHgsmiProfileStart(&g_VBoxProfile) +#define VBOXCRHGSMIPROFILE_TERM() do {} while (0) + +#define VBOXCRHGSMIPROFILE_FUNC_PROLOGUE() \ + VBOXCRHGSMIPROFILE_SCOPE __vboxCrHgsmiProfileScope; \ + vboxCrHgsmiProfileScopeEnter(&__vboxCrHgsmiProfileScope); + +#define VBOXCRHGSMIPROFILE_FUNC_EPILOGUE() \ + vboxCrHgsmiProfileScopeExit(&__vboxCrHgsmiProfileScope); \ + + +#else +#define VBOXCRHGSMIPROFILE_INIT() do {} while (0) +#define VBOXCRHGSMIPROFILE_TERM() do {} while (0) +#define VBOXCRHGSMIPROFILE_FUNC_PROLOGUE() do {} while (0) +#define VBOXCRHGSMIPROFILE_FUNC_EPILOGUE() do {} while (0) +#endif + +typedef struct { + int initialized; + int num_conns; + CRConnection **conns; + CRBufferPool *bufpool; +#ifdef CHROMIUM_THREADSAFE + CRmutex mutex; + CRmutex recvmutex; +#endif + CRNetReceiveFuncList *recv_list; + CRNetCloseFuncList *close_list; +#ifdef RT_OS_WINDOWS + LPDIRECTDRAW pDirectDraw; +#endif +#ifdef IN_GUEST + uint32_t u32HostCaps; + bool fHostCapsInitialized; +#endif +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + bool bHgsmiOn; +#endif +} CRVBOXHGCMDATA; + +static CRVBOXHGCMDATA g_crvboxhgcm = {0,}; + +typedef enum { + CR_VBOXHGCM_USERALLOCATED, + CR_VBOXHGCM_MEMORY, + CR_VBOXHGCM_MEMORY_BIG +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + ,CR_VBOXHGCM_UHGSMI_BUFFER +#endif +} CRVBOXHGCMBUFFERKIND; + +#define CR_VBOXHGCM_BUFFER_MAGIC 0xABCDE321 + +typedef struct CRVBOXHGCMBUFFER { + uint32_t magic; + CRVBOXHGCMBUFFERKIND kind; + union + { + struct + { + uint32_t len; + uint32_t allocated; + }; + +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + PVBOXUHGSMI_BUFFER pBuffer; +#endif + }; +} CRVBOXHGCMBUFFER; + +#ifndef RT_OS_WINDOWS + #define TRUE true + #define FALSE false + #define INVALID_HANDLE_VALUE (-1) +#endif + + +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + +/* add sizeof header + page align */ +#define CRVBOXHGSMI_PAGE_ALIGN(_s) (((_s) + 0xfff) & ~0xfff) +#define CRVBOXHGSMI_BUF_HDR_SIZE() (sizeof (CRVBOXHGCMBUFFER)) +#define CRVBOXHGSMI_BUF_SIZE(_s) CRVBOXHGSMI_PAGE_ALIGN((_s) + CRVBOXHGSMI_BUF_HDR_SIZE()) +#define CRVBOXHGSMI_BUF_LOCK_SIZE(_s) ((_s) + CRVBOXHGSMI_BUF_HDR_SIZE()) +#define CRVBOXHGSMI_BUF_DATA(_p) ((void*)(((CRVBOXHGCMBUFFER*)(_p)) + 1)) +#define CRVBOXHGSMI_BUF_HDR(_p) (((CRVBOXHGCMBUFFER*)(_p)) - 1) +#define CRVBOXHGSMI_BUF_OFFSET(_st2, _st1) ((uint32_t)(((uint8_t*)(_st2)) - ((uint8_t*)(_st1)))) + +static int _crVBoxHGSMIClientInit(PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI pHgsmi) +{ + int rc; + VBOXUHGSMI_BUFFER_TYPE_FLAGS Flags = {0}; + pClient->pHgsmi = pHgsmi; + Flags.s.fCommand = 1; + rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(1), Flags, &pClient->pCmdBuffer); + if (RT_SUCCESS(rc)) + { + Flags.Value = 0; + rc = pHgsmi->pfnBufferCreate(pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(1), Flags, &pClient->pHGBuffer); + if (RT_SUCCESS(rc)) + { + pClient->pvHGBuffer = NULL; + pClient->bufpool = crBufferPoolInit(16); + return VINF_SUCCESS; + } + else + crWarning("_crVBoxHGSMIClientInit: pfnBufferCreate failed to allocate host->guest buffer"); + + pClient->pCmdBuffer->pfnDestroy(pClient->pCmdBuffer); + } + else + crWarning("_crVBoxHGSMIClientInit: pfnBufferCreate failed to allocate cmd buffer"); + + pClient->pHgsmi = NULL; + return rc; +} + +void _crVBoxHGSMIBufferFree(void *data) +{ + PVBOXUHGSMI_BUFFER pBuffer = (PVBOXUHGSMI_BUFFER)data; + pBuffer->pfnDestroy(pBuffer); +} + +static int _crVBoxHGSMIClientTerm(PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI *ppHgsmi) +{ + if (pClient->bufpool) + crBufferPoolCallbackFree(pClient->bufpool, _crVBoxHGSMIBufferFree); + pClient->bufpool = NULL; + + if (pClient->pHGBuffer) + { + pClient->pHGBuffer->pfnDestroy(pClient->pHGBuffer); + pClient->pHGBuffer = NULL; + } + + if (pClient->pCmdBuffer) + { + pClient->pCmdBuffer->pfnDestroy(pClient->pCmdBuffer); + pClient->pCmdBuffer = NULL; + } + + if (ppHgsmi) + { + *ppHgsmi = pClient->pHgsmi; + } + pClient->pHgsmi = NULL; + + return VINF_SUCCESS; +} + + +#ifdef VBOX_CRHGSMI_WITH_D3DDEV + +static DECLCALLBACK(HVBOXCRHGSMI_CLIENT) _crVBoxHGSMIClientCreate(PVBOXUHGSMI pHgsmi) +{ + PCRVBOXHGSMI_CLIENT pClient = crAlloc(sizeof (CRVBOXHGSMI_CLIENT)); + + if (pClient) + { + int rc = _crVBoxHGSMIClientInit(pClient, pHgsmi); + if (RT_SUCCESS(rc)) + return (HVBOXCRHGSMI_CLIENT)pClient; + else + crWarning("_crVBoxHGSMIClientCreate: _crVBoxHGSMIClientInit failed rc %d", rc); + + crFree(pCLient); + } + + return NULL; +} + +static DECLCALLBACK(void) _crVBoxHGSMIClientDestroy(HVBOXCRHGSMI_CLIENT hClient) +{ + PCRVBOXHGSMI_CLIENT pClient = (PCRVBOXHGSMI_CLIENT)hClient; + _crVBoxHGSMIClientTerm(pClient, NULL); + crFree(pClient); +} +#endif + +DECLINLINE(PCRVBOXHGSMI_CLIENT) _crVBoxHGSMIClientGet(CRConnection *conn) +{ +#ifdef VBOX_CRHGSMI_WITH_D3DDEV + PCRVBOXHGSMI_CLIENT pClient = (PCRVBOXHGSMI_CLIENT)VBoxCrHgsmiQueryClient(); + CRASSERT(pClient); + return pClient; +#else + if (conn->HgsmiClient.pHgsmi) + return &conn->HgsmiClient; + { + PVBOXUHGSMI pHgsmi = conn->pExternalHgsmi ? conn->pExternalHgsmi : VBoxCrHgsmiCreate(); + if (pHgsmi) + { + int rc = _crVBoxHGSMIClientInit(&conn->HgsmiClient, pHgsmi); + if (RT_SUCCESS(rc)) + { + CRASSERT(conn->HgsmiClient.pHgsmi); + return &conn->HgsmiClient; + } + else + crWarning("_crVBoxHGSMIClientGet: _crVBoxHGSMIClientInit failed rc %d", rc); + if (!conn->pExternalHgsmi) + VBoxCrHgsmiDestroy(pHgsmi); + } + else + { + crWarning("VBoxCrHgsmiCreate failed"); + } + } + return NULL; +#endif +} + +static PVBOXUHGSMI_BUFFER _crVBoxHGSMIBufAlloc(PCRVBOXHGSMI_CLIENT pClient, uint32_t cbSize) +{ + PVBOXUHGSMI_BUFFER buf; + int rc; + + buf = (PVBOXUHGSMI_BUFFER ) crBufferPoolPop(pClient->bufpool, cbSize); + + if (!buf) + { + VBOXUHGSMI_BUFFER_TYPE_FLAGS Flags = {0}; + crDebug("Buffer pool %p was empty; allocating new %d byte buffer.", + (void *) pClient->bufpool, + cbSize); + rc = pClient->pHgsmi->pfnBufferCreate(pClient->pHgsmi, cbSize, Flags, &buf); + if (RT_FAILURE(rc)) + crWarning("_crVBoxHGSMIBufAlloc: Failed to Create a buffer of size(%d), rc(%d)\n", cbSize, rc); + } + return buf; +} + +static PVBOXUHGSMI_BUFFER _crVBoxHGSMIBufFromHdr(CRVBOXHGCMBUFFER *pHdr) +{ + PVBOXUHGSMI_BUFFER pBuf; + int rc; + CRASSERT(pHdr->magic == CR_VBOXHGCM_BUFFER_MAGIC); + CRASSERT(pHdr->kind == CR_VBOXHGCM_UHGSMI_BUFFER); + pBuf = pHdr->pBuffer; + rc = pBuf->pfnUnlock(pBuf); + if (RT_FAILURE(rc)) + { + crWarning("_crVBoxHGSMIBufFromHdr: pfnUnlock failed rc %d", rc); + return NULL; + } + return pBuf; +} + +static void _crVBoxHGSMIBufFree(PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI_BUFFER pBuf) +{ + crBufferPoolPush(pClient->bufpool, pBuf, pBuf->cbBuffer); +} + +static CRVBOXHGSMIHDR *_crVBoxHGSMICmdBufferLock(PCRVBOXHGSMI_CLIENT pClient, uint32_t cbBuffer) +{ + /* in theory it is OK to use one cmd buffer for asynch cmd submission + * because bDiscard flag should result in allocating a new memory backend if the + * allocation is still in use. + * However, NOTE: since one and the same semaphore synch event is used for completion notification, + * for the notification mechanism working as expected + * 1. host must complete commands in the same order as it receives them + * (to avoid situation when guest receives notification for another command completion) + * 2. guest must eventually wait for command completion unless he specified bDoNotSignalCompletion + * 3. guest must wait for command completion in the same order as it submits them + * in case we can not satisfy any of the above, we should introduce multiple command buffers */ + CRVBOXHGSMIHDR * pHdr; + VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags; + int rc; + fFlags.Value = 0; + fFlags.s.fDiscard = 1; + rc = pClient->pCmdBuffer->pfnLock(pClient->pCmdBuffer, 0, cbBuffer, fFlags, (void**)&pHdr); + if (RT_SUCCESS(rc)) + return pHdr; + crWarning("_crVBoxHGSMICmdBufferLock: pfnLock failed rc %d", rc); + + crWarning("Failed to Lock the command buffer of size(%d), rc(%d)\n", cbBuffer, rc); + return NULL; +} + +static CRVBOXHGSMIHDR *_crVBoxHGSMICmdBufferLockRo(PCRVBOXHGSMI_CLIENT pClient, uint32_t cbBuffer) +{ + /* in theory it is OK to use one cmd buffer for asynch cmd submission + * because bDiscard flag should result in allocating a new memory backend if the + * allocation is still in use. + * However, NOTE: since one and the same semaphore synch event is used for completion notification, + * for the notification mechanism working as expected + * 1. host must complete commands in the same order as it receives them + * (to avoid situation when guest receives notification for another command completion) + * 2. guest must eventually wait for command completion unless he specified bDoNotSignalCompletion + * 3. guest must wait for command completion in the same order as it submits them + * in case we can not satisfy any of the above, we should introduce multiple command buffers */ + CRVBOXHGSMIHDR * pHdr = NULL; + VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags; + int rc; + fFlags.Value = 0; + fFlags.s.fReadOnly = 1; + rc = pClient->pCmdBuffer->pfnLock(pClient->pCmdBuffer, 0, cbBuffer, fFlags, (void**)&pHdr); + if (RT_FAILURE(rc)) + crWarning("Failed to Lock the command buffer of size(%d), rc(%d)\n", cbBuffer, rc); + return pHdr; +} + +static void _crVBoxHGSMICmdBufferUnlock(PCRVBOXHGSMI_CLIENT pClient) +{ + int rc = pClient->pCmdBuffer->pfnUnlock(pClient->pCmdBuffer); + if (RT_FAILURE(rc)) + crError("Failed to Unlock the command buffer rc(%d)\n", rc); +} + +static int32_t _crVBoxHGSMICmdBufferGetRc(PCRVBOXHGSMI_CLIENT pClient) +{ + CRVBOXHGSMIHDR * pHdr; + VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags; + int rc; + + fFlags.Value = 0; + fFlags.s.fReadOnly = 1; + rc = pClient->pCmdBuffer->pfnLock(pClient->pCmdBuffer, 0, sizeof (*pHdr), fFlags, (void**)&pHdr); + if (RT_FAILURE(rc)) + { + crWarning("Failed to Lock the command buffer of size(%d), rc(%d)\n", sizeof (*pHdr), rc); + return rc; + } + + rc = pHdr->result; + AssertRC(rc); + pClient->pCmdBuffer->pfnUnlock(pClient->pCmdBuffer); + + return rc; +} + +DECLINLINE(PVBOXUHGSMI_BUFFER) _crVBoxHGSMIRecvBufGet(PCRVBOXHGSMI_CLIENT pClient) +{ + if (pClient->pvHGBuffer) + { + int rc = pClient->pHGBuffer->pfnUnlock(pClient->pHGBuffer); + if (RT_FAILURE(rc)) + { + return NULL; + } + pClient->pvHGBuffer = NULL; + } + return pClient->pHGBuffer; +} + +DECLINLINE(void*) _crVBoxHGSMIRecvBufData(PCRVBOXHGSMI_CLIENT pClient, uint32_t cbBuffer) +{ + VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags; + int rc; + CRASSERT(!pClient->pvHGBuffer); + fFlags.Value = 0; + rc = pClient->pHGBuffer->pfnLock(pClient->pHGBuffer, 0, cbBuffer, fFlags, &pClient->pvHGBuffer); + if (RT_SUCCESS(rc)) + return pClient->pvHGBuffer; + else + crWarning("_crVBoxHGSMIRecvBufData: pfnLock failed rc %d", rc); + + return NULL; +} + +DECLINLINE(void) _crVBoxHGSMIFillCmd(VBOXUHGSMI_BUFFER_SUBMIT *pSubm, PCRVBOXHGSMI_CLIENT pClient, uint32_t cbData) +{ + pSubm->pBuf = pClient->pCmdBuffer; + pSubm->offData = 0; + pSubm->cbData = cbData; + pSubm->fFlags.Value = 0; + pSubm->fFlags.s.fDoNotRetire = 1; +# if 0 + pSubm->fFlags.bDoNotSignalCompletion = 1; /* <- we do not need that actually since + * in case we want completion, + * we will block in _crVBoxHGSMICmdBufferGetRc (when locking the buffer) + * which is needed for getting the result */ +# endif +} +#endif + +/* Some forward declarations */ +static void _crVBoxHGCMReceiveMessage(CRConnection *conn); + +#ifndef IN_GUEST +static bool _crVBoxHGCMReadBytes(CRConnection *conn, void *buf, uint32_t len) +{ + CRASSERT(conn && buf); + + if (!conn->pBuffer || (conn->cbBufferpBuffer, len); + + conn->cbBuffer -= len; + conn->pBuffer = conn->cbBuffer>0 ? (uint8_t*)conn->pBuffer+len : NULL; + + return TRUE; +} +#endif + +#ifndef IN_GUEST +/** @todo get rid of it*/ +static bool _crVBoxHGCMWriteBytes(CRConnection *conn, const void *buf, uint32_t len) +{ + CRASSERT(conn && buf); + + /* make sure there's host buffer and it's clear */ + CRASSERT(conn->pHostBuffer && !conn->cbHostBuffer); + + if (conn->cbHostBufferAllocated < len) + { + crDebug("Host buffer too small %d out of requested %d bytes, reallocating", conn->cbHostBufferAllocated, len); + crFree(conn->pHostBuffer); + conn->pHostBuffer = crAlloc(len); + if (!conn->pHostBuffer) + { + conn->cbHostBufferAllocated = 0; + crError("OUT_OF_MEMORY trying to allocate %d bytes", len); + return FALSE; + } + conn->cbHostBufferAllocated = len; + } + + crMemcpy(conn->pHostBuffer, buf, len); + conn->cbHostBuffer = len; + + return TRUE; +} +#endif + +/** + * Send an HGCM request + * + * @return VBox status code + * @param pvData Data pointer + * @param cbData Data size + */ +static int crVBoxHGCMCall(CRConnection *conn, PVBGLIOCHGCMCALL pData, unsigned cbData) +{ +#ifdef IN_GUEST + int rc; +# ifndef VBOX_WITH_CRHGSMI + RT_NOREF(conn); +# else + PCRVBOXHGSMI_CLIENT pClient = g_crvboxhgcm.bHgsmiOn ? _crVBoxHGSMIClientGet(conn) : NULL; + if (pClient) + rc = VBoxCrHgsmiCtlConCall(pClient->pHgsmi, pData, cbData); + else +# endif + { + rc = VbglR3HGCMCall(pData, cbData); + if (RT_SUCCESS(rc)) + { /* likely */ } + else + { + crWarning("vboxCall failed with VBox status code %Rrc\n", rc); +# ifndef RT_OS_WINDOWS + if (rc == VERR_INTERRUPTED) + { + /* Not sure why we're doing the sleep stuff here. The original coder didn't + bother to mention why he thought it necessary. :-( */ + RTMSINTERVAL msSleep; + int i; + for (i = 0, msSleep = 50; i < 6; i++, msSleep = msSleep * 2) + { + RTThreadSleep(msSleep); + rc = VbglR3HGCMCall(pData, cbData); + if (rc != VERR_INTERRUPTED) + { + if (RT_SUCCESS(rc)) + crWarning("vboxCall retry(%i) succeeded", i + 1); + else + crWarning("vboxCall retry(%i) failed with VBox status code %Rrc", i + 1, rc); + break; + } + } + } +# endif + } + } + return rc; + +#else /* IN_GUEST */ + RT_NOREF(conn, pData, cbData); + crError("crVBoxHGCMCall called on host side!"); + CRASSERT(FALSE); + return VERR_NOT_SUPPORTED; +#endif /* IN_GUEST */ +} + +static void *_crVBoxHGCMAlloc(CRConnection *conn) +{ + CRVBOXHGCMBUFFER *buf; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + buf = (CRVBOXHGCMBUFFER *) crBufferPoolPop(g_crvboxhgcm.bufpool, conn->buffer_size); + + if (!buf) + { + crDebug("Buffer pool %p was empty; allocating new %d byte buffer.", + (void *) g_crvboxhgcm.bufpool, + (unsigned int)sizeof(CRVBOXHGCMBUFFER) + conn->buffer_size); + + /* We're either on host side, or we failed to allocate DDRAW buffer */ + if (!buf) + { + crDebug("Using system malloc\n"); + buf = (CRVBOXHGCMBUFFER *) crAlloc( sizeof(CRVBOXHGCMBUFFER) + conn->buffer_size ); + CRASSERT(buf); + buf->magic = CR_VBOXHGCM_BUFFER_MAGIC; + buf->kind = CR_VBOXHGCM_MEMORY; + buf->allocated = conn->buffer_size; + } + } + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + + return (void *)( buf + 1 ); + +} + +static void *crVBoxHGCMAlloc(CRConnection *conn) +{ + void *pvBuff; + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + pvBuff = _crVBoxHGCMAlloc(conn); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return pvBuff; +} + +static void _crVBoxHGCMWriteExact(CRConnection *conn, const void *buf, unsigned int len) +{ + int rc; + int32_t callRes; + +#ifdef IN_GUEST + if (conn->u32InjectClientID) + { + CRVBOXHGCMINJECT parms; + + VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_INJECT, SHCRGL_CPARMS_INJECT); + + parms.u32ClientID.type = VMMDevHGCMParmType_32bit; + parms.u32ClientID.u.value32 = conn->u32InjectClientID; + + parms.pBuffer.type = VMMDevHGCMParmType_LinAddr_In; + parms.pBuffer.u.Pointer.size = len; + parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf; + + rc = crVBoxHGCMCall(conn, &parms.hdr, sizeof(parms)); + callRes = parms.hdr.Hdr.rc; /** @todo now rc == parms.hdr.Hdr.rc */ + } + else +#endif + { + CRVBOXHGCMWRITE parms; + + VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_WRITE, SHCRGL_CPARMS_WRITE); + + parms.pBuffer.type = VMMDevHGCMParmType_LinAddr_In; + parms.pBuffer.u.Pointer.size = len; + parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf; + + rc = crVBoxHGCMCall(conn, &parms.hdr, sizeof(parms)); + callRes = parms.hdr.Hdr.rc; /** @todo now rc == parms.hdr.Hdr.rc */ + } + + if (RT_FAILURE(rc) || RT_FAILURE(callRes)) + { + crWarning("SHCRGL_GUEST_FN_WRITE failed with %x %x\n", rc, callRes); + } +} + +static void crVBoxHGCMWriteExact(CRConnection *conn, const void *buf, unsigned int len) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + _crVBoxHGCMWriteExact(conn, buf, len); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void crVBoxHGCMReadExact( CRConnection *conn, const void *buf, unsigned int len ) +{ + CRVBOXHGCMREAD parms; + int rc; + RT_NOREF(buf, len); + + VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_READ, SHCRGL_CPARMS_READ); + + CRASSERT(!conn->pBuffer); /* make sure there's no data to process */ + parms.pBuffer.type = VMMDevHGCMParmType_LinAddr_Out; + parms.pBuffer.u.Pointer.size = conn->cbHostBufferAllocated; + parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) conn->pHostBuffer; + + parms.cbBuffer.type = VMMDevHGCMParmType_32bit; + parms.cbBuffer.u.value32 = 0; + + rc = crVBoxHGCMCall(conn, &parms.hdr, sizeof(parms)); + + if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.Hdr.rc) /** @todo now rc == parms.hdr.Hdr.rc */) + { + crWarning("SHCRGL_GUEST_FN_READ failed with %x %x\n", rc, parms.hdr.Hdr.rc); + return; + } + + if (parms.cbBuffer.u.value32) + { + /*conn->pBuffer = (uint8_t*) parms.pBuffer.u.Pointer.u.linearAddr; */ + conn->pBuffer = conn->pHostBuffer; + conn->cbBuffer = parms.cbBuffer.u.value32; + } + + if (conn->cbBuffer) + _crVBoxHGCMReceiveMessage(conn); + +} + +/* Same as crVBoxHGCMWriteExact, but combined with read of writeback data. + * This halves the number of HGCM calls we do, + * most likely crVBoxHGCMPollHost shouldn't be called at all now. + */ +static void +crVBoxHGCMWriteReadExact(CRConnection *conn, const void *buf, unsigned int len, CRVBOXHGCMBUFFERKIND bufferKind) +{ + CRVBOXHGCMWRITEREAD parms; + int rc; + + VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_WRITE_READ, SHCRGL_CPARMS_WRITE_READ); + + parms.pBuffer.type = VMMDevHGCMParmType_LinAddr_In; + parms.pBuffer.u.Pointer.size = len; + parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf; + + CRASSERT(!conn->pBuffer); /*make sure there's no data to process*/ + parms.pWriteback.type = VMMDevHGCMParmType_LinAddr_Out; + parms.pWriteback.u.Pointer.size = conn->cbHostBufferAllocated; + parms.pWriteback.u.Pointer.u.linearAddr = (uintptr_t) conn->pHostBuffer; + + parms.cbWriteback.type = VMMDevHGCMParmType_32bit; + parms.cbWriteback.u.value32 = 0; + + rc = crVBoxHGCMCall(conn, &parms.hdr, sizeof(parms)); + +#if defined(RT_OS_LINUX) || defined(RT_OS_WINDOWS) + if (VERR_OUT_OF_RANGE==rc && CR_VBOXHGCM_USERALLOCATED==bufferKind) + { + /*Buffer is too big, so send it in split chunks*/ + CRVBOXHGCMWRITEBUFFER wbParms; + + VBGL_HGCM_HDR_INIT(&wbParms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_WRITE_BUFFER, SHCRGL_CPARMS_WRITE_BUFFER); + + wbParms.iBufferID.type = VMMDevHGCMParmType_32bit; + wbParms.iBufferID.u.value32 = 0; + + wbParms.cbBufferSize.type = VMMDevHGCMParmType_32bit; + wbParms.cbBufferSize.u.value32 = len; + + wbParms.ui32Offset.type = VMMDevHGCMParmType_32bit; + wbParms.ui32Offset.u.value32 = 0; + + wbParms.pBuffer.type = VMMDevHGCMParmType_LinAddr_In; + wbParms.pBuffer.u.Pointer.size = MIN(CR_HGCM_SPLIT_BUFFER_SIZE, len); + wbParms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) buf; + + if (lenu32ClientID, SHCRGL_GUEST_FN_WRITE_READ_BUFFERED, SHCRGL_CPARMS_WRITE_READ_BUFFERED); + + crMemcpy(&wrbParms.iBufferID, &wbParms.iBufferID, sizeof(HGCMFunctionParameter)); + crMemcpy(&wrbParms.pWriteback, &parms.pWriteback, sizeof(HGCMFunctionParameter)); + crMemcpy(&wrbParms.cbWriteback, &parms.cbWriteback, sizeof(HGCMFunctionParameter)); + + rc = crVBoxHGCMCall(conn, &wrbParms.hdr, sizeof(wrbParms)); + + /*bit of hack to reuse code below*/ + parms.hdr.Hdr.rc = wrbParms.hdr.Hdr.rc; + crMemcpy(&parms.cbWriteback, &wrbParms.cbWriteback, sizeof(HGCMFunctionParameter)); + crMemcpy(&parms.pWriteback, &wrbParms.pWriteback, sizeof(HGCMFunctionParameter)); + } + } +#endif + + if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.Hdr.rc) /** @todo now rc == parms.hdr.Hdr.rc */) + { + + if ((VERR_BUFFER_OVERFLOW == parms.hdr.Hdr.rc) /* && RT_SUCCESS(rc) */) + { + /* reallocate buffer and retry */ + + CRASSERT(parms.cbWriteback.u.value32>conn->cbHostBufferAllocated); + + crDebug("Reallocating host buffer from %d to %d bytes", conn->cbHostBufferAllocated, parms.cbWriteback.u.value32); + + crFree(conn->pHostBuffer); + conn->cbHostBufferAllocated = parms.cbWriteback.u.value32; + conn->pHostBuffer = crAlloc(conn->cbHostBufferAllocated); + + crVBoxHGCMReadExact(conn, buf, len); + + return; + } + else + { + crWarning("SHCRGL_GUEST_FN_WRITE_READ (%i) failed with %x %x\n", len, rc, parms.hdr.Hdr.rc); + return; + } + } + + if (parms.cbWriteback.u.value32) + { + /*conn->pBuffer = (uint8_t*) parms.pWriteback.u.Pointer.u.linearAddr;*/ + conn->pBuffer = conn->pHostBuffer; + conn->cbBuffer = parms.cbWriteback.u.value32; + } + + if (conn->cbBuffer) + _crVBoxHGCMReceiveMessage(conn); +} + +static void crVBoxHGCMSend(CRConnection *conn, void **bufp, + const void *start, unsigned int len) +{ + CRVBOXHGCMBUFFER *hgcm_buffer; + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + if (!bufp) /* We're sending a user-allocated buffer. */ + { +#ifndef IN_GUEST + /** @todo remove temp buffer allocation in unpacker*/ + /* we're at the host side, so just store data until guest polls us */ + _crVBoxHGCMWriteBytes(conn, start, len); +#else + CRASSERT(!conn->u32InjectClientID); + crDebug("SHCRGL: sending userbuf with %d bytes\n", len); + crVBoxHGCMWriteReadExact(conn, start, len, CR_VBOXHGCM_USERALLOCATED); +#endif +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return; + } + + /* The region [start .. start + len + 1] lies within a buffer that + * was allocated with crVBoxHGCMAlloc() and can be put into the free + * buffer pool when we're done sending it. + */ + + hgcm_buffer = (CRVBOXHGCMBUFFER *)(*bufp) - 1; + CRASSERT(hgcm_buffer->magic == CR_VBOXHGCM_BUFFER_MAGIC); + + /* Length would be passed as part of HGCM pointer description + * No need to prepend it to the buffer + */ +#ifdef IN_GUEST + if (conn->u32InjectClientID) + { + _crVBoxHGCMWriteExact(conn, start, len); + } + else +#endif + crVBoxHGCMWriteReadExact(conn, start, len, hgcm_buffer->kind); + + /* Reclaim this pointer for reuse */ +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + crBufferPoolPush(g_crvboxhgcm.bufpool, hgcm_buffer, hgcm_buffer->allocated); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + + /* Since the buffer's now in the 'free' buffer pool, the caller can't + * use it any more. Setting bufp to NULL will make sure the caller + * doesn't try to re-use the buffer. + */ + *bufp = NULL; + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void crVBoxHGCMPollHost(CRConnection *conn) +{ + CRVBOXHGCMREAD parms; + int rc; + + CRASSERT(!conn->pBuffer); + + VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_READ, SHCRGL_CPARMS_READ); + + parms.pBuffer.type = VMMDevHGCMParmType_LinAddr_Out; + parms.pBuffer.u.Pointer.size = conn->cbHostBufferAllocated; + parms.pBuffer.u.Pointer.u.linearAddr = (uintptr_t) conn->pHostBuffer; + + parms.cbBuffer.type = VMMDevHGCMParmType_32bit; + parms.cbBuffer.u.value32 = 0; + + rc = crVBoxHGCMCall(conn, &parms.hdr, sizeof(parms)); + + if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.Hdr.rc) /** @todo now rc == parms.hdr.Hdr.rc */) + { + crDebug("SHCRGL_GUEST_FN_READ failed with %x %x\n", rc, parms.hdr.Hdr.rc); + return; + } + + if (parms.cbBuffer.u.value32) + { + conn->pBuffer = (uint8_t*) parms.pBuffer.u.Pointer.u.linearAddr; + conn->cbBuffer = parms.cbBuffer.u.value32; + } +} + +static void crVBoxHGCMSingleRecv(CRConnection *conn, void *buf, unsigned int len) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + crVBoxHGCMReadExact(conn, buf, len); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void _crVBoxHGCMFree(CRConnection *conn, void *buf) +{ + CRVBOXHGCMBUFFER *hgcm_buffer = (CRVBOXHGCMBUFFER *) buf - 1; + + CRASSERT(hgcm_buffer->magic == CR_VBOXHGCM_BUFFER_MAGIC); + + /** @todo wrong len for redir buffers*/ + conn->recv_credits += hgcm_buffer->len; + + switch (hgcm_buffer->kind) + { + case CR_VBOXHGCM_MEMORY: +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + if (g_crvboxhgcm.bufpool) { + /** @todo o'rly? */ + /* pool may have been deallocated just a bit earlier in response + * to a SIGPIPE (Broken Pipe) signal. + */ + crBufferPoolPush(g_crvboxhgcm.bufpool, hgcm_buffer, hgcm_buffer->allocated); + } +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + break; + + case CR_VBOXHGCM_MEMORY_BIG: + crFree( hgcm_buffer ); + break; + + default: + crError( "Weird buffer kind trying to free in crVBoxHGCMFree: %d", hgcm_buffer->kind ); + } +} + +static void crVBoxHGCMFree(CRConnection *conn, void *buf) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + _crVBoxHGCMFree(conn, buf); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void _crVBoxHGCMReceiveMessage(CRConnection *conn) +{ + uint32_t len; + CRVBOXHGCMBUFFER *hgcm_buffer; + CRMessage *msg; + CRMessageType cached_type; + + len = conn->cbBuffer; + CRASSERT(len > 0); + CRASSERT(conn->pBuffer); + +#ifndef IN_GUEST + /* Expect only CR_MESSAGE_OPCODES from the guest. */ + AssertPtrReturnVoid(conn->pBuffer); + + if ( conn->cbBuffer >= sizeof(CRMessageHeader) + && ((CRMessageHeader*) (conn->pBuffer))->type == CR_MESSAGE_OPCODES) + { + /* Looks good. */ + } + else + { + AssertFailed(); + /** @todo Find out if this is the expected cleanup. */ + conn->cbBuffer = 0; + conn->pBuffer = NULL; + return; + } +#endif + +#ifndef IN_GUEST + if (conn->allow_redir_ptr) + { +#endif + CRASSERT(conn->buffer_size >= sizeof(CRMessageRedirPtr)); + + hgcm_buffer = (CRVBOXHGCMBUFFER *) _crVBoxHGCMAlloc( conn ) - 1; + hgcm_buffer->len = sizeof(CRMessageRedirPtr); + + msg = (CRMessage *) (hgcm_buffer + 1); + + msg->header.type = CR_MESSAGE_REDIR_PTR; + msg->redirptr.pMessage = (CRMessageHeader*) (conn->pBuffer); + msg->header.conn_id = msg->redirptr.pMessage->conn_id; + +#if defined(VBOX_WITH_CRHGSMI) && !defined(IN_GUEST) + msg->redirptr.CmdData = conn->CmdData; + CRVBOXHGSMI_CMDDATA_ASSERT_CONSISTENT(&msg->redirptr.CmdData); + CRVBOXHGSMI_CMDDATA_CLEANUP(&conn->CmdData); +#endif + + cached_type = msg->redirptr.pMessage->type; + + conn->cbBuffer = 0; + conn->pBuffer = NULL; +#ifndef IN_GUEST + } + else + { + /* we should NEVER have redir_ptr disabled with HGSMI command now */ + CRASSERT(!conn->CmdData.pvCmd); + if ( len <= conn->buffer_size ) + { + /* put in pre-allocated buffer */ + hgcm_buffer = (CRVBOXHGCMBUFFER *) _crVBoxHGCMAlloc( conn ) - 1; + } + else + { + /* allocate new buffer, + * not using pool here as it's most likely one time transfer of huge texture + */ + hgcm_buffer = (CRVBOXHGCMBUFFER *) crAlloc( sizeof(CRVBOXHGCMBUFFER) + len ); + hgcm_buffer->magic = CR_VBOXHGCM_BUFFER_MAGIC; + hgcm_buffer->kind = CR_VBOXHGCM_MEMORY_BIG; + hgcm_buffer->allocated = sizeof(CRVBOXHGCMBUFFER) + len; + } + + hgcm_buffer->len = len; + _crVBoxHGCMReadBytes(conn, hgcm_buffer + 1, len); + + msg = (CRMessage *) (hgcm_buffer + 1); + cached_type = msg->header.type; + } +#endif /* !IN_GUEST*/ + + conn->recv_credits -= len; + conn->total_bytes_recv += len; + conn->recv_count++; + + crNetDispatchMessage( g_crvboxhgcm.recv_list, conn, msg, len ); + + /* CR_MESSAGE_OPCODES is freed in crserverlib/server_stream.c with crNetFree. + * OOB messages are the programmer's problem. -- Humper 12/17/01 + */ + if (cached_type != CR_MESSAGE_OPCODES + && cached_type != CR_MESSAGE_OOB + && cached_type != CR_MESSAGE_GATHER) + { + _crVBoxHGCMFree(conn, msg); + } +} + +static void crVBoxHGCMReceiveMessage(CRConnection *conn) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + _crVBoxHGCMReceiveMessage(conn); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + + +/* + * Called on host side only, to "accept" client connection + */ +static void crVBoxHGCMAccept( CRConnection *conn, const char *hostname, unsigned short port ) +{ + RT_NOREF(hostname, port); + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + CRASSERT(conn && conn->pHostBuffer); +#ifdef IN_GUEST + CRASSERT(FALSE); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static int crVBoxHGCMSetVersion(CRConnection *conn, unsigned int vMajor, unsigned int vMinor) +{ + CRVBOXHGCMSETVERSION parms; + int rc; + RT_NOREF(vMajor, vMinor); + + VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_SET_VERSION, SHCRGL_CPARMS_SET_VERSION); + + parms.vMajor.type = VMMDevHGCMParmType_32bit; + parms.vMajor.u.value32 = CR_PROTOCOL_VERSION_MAJOR; + parms.vMinor.type = VMMDevHGCMParmType_32bit; + parms.vMinor.u.value32 = CR_PROTOCOL_VERSION_MINOR; + + rc = crVBoxHGCMCall(conn, &parms.hdr, sizeof(parms)); + + if (RT_SUCCESS(rc)) + { + rc = parms.hdr.Hdr.rc; /** @todo now rc == parms.hdr.Hdr.rc */ + if (RT_SUCCESS(rc)) + { + conn->vMajor = CR_PROTOCOL_VERSION_MAJOR; + conn->vMinor = CR_PROTOCOL_VERSION_MINOR; + + return VINF_SUCCESS; + } + else + WARN(("Host doesn't accept our version %d.%d. Make sure you have appropriate additions installed!", + parms.vMajor.u.value32, parms.vMinor.u.value32)); + } + else + WARN(("crVBoxHGCMCall failed %d", rc)); + + return rc; +} + +static int crVBoxHGCMGetHostCapsLegacy(CRConnection *conn, uint32_t *pu32HostCaps) +{ + CRVBOXHGCMGETCAPS caps; + int rc; + + VBGL_HGCM_HDR_INIT(&caps.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_GET_CAPS_LEGACY, SHCRGL_CPARMS_GET_CAPS_LEGACY); + + caps.Caps.type = VMMDevHGCMParmType_32bit; + caps.Caps.u.value32 = 0; + + rc = crVBoxHGCMCall(conn, &caps.hdr, sizeof(caps)); + + if (RT_SUCCESS(rc)) + { + rc = caps.hdr.Hdr.rc; + if (RT_SUCCESS(rc)) + { + *pu32HostCaps = caps.Caps.u.value32; + return VINF_SUCCESS; + } + else + WARN(("SHCRGL_GUEST_FN_GET_CAPS failed %d", rc)); + return FALSE; + } + else + WARN(("crVBoxHGCMCall failed %d", rc)); + + *pu32HostCaps = 0; + + return rc; +} + +static int crVBoxHGCMSetPID(CRConnection *conn, unsigned long long pid) +{ + CRVBOXHGCMSETPID parms; + int rc; + + VBGL_HGCM_HDR_INIT(&parms.hdr, conn->u32ClientID, SHCRGL_GUEST_FN_SET_PID, SHCRGL_CPARMS_SET_PID); + + parms.u64PID.type = VMMDevHGCMParmType_64bit; + parms.u64PID.u.value64 = pid; + + rc = crVBoxHGCMCall(conn, &parms.hdr, sizeof(parms)); + + if (RT_FAILURE(rc) || RT_FAILURE(parms.hdr.Hdr.rc) /** @todo now rc == parms.hdr.Hdr.rc */) + { + crWarning("SHCRGL_GUEST_FN_SET_PID failed!"); + return FALSE; + } + + return TRUE; +} + +/** + * The function that actually connects. This should only be called by clients, + * guests in vbox case. + * Servers go through crVBoxHGCMAccept; + */ +static int crVBoxHGCMDoConnect( CRConnection *conn ) +{ +#ifdef IN_GUEST + int rc; + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + RTR3InitDll(RTR3INIT_FLAGS_UNOBTRUSIVE); + rc = VbglR3InitUser(); + if (RT_SUCCESS(rc)) + { + uint32_t idClient; + rc = VbglR3HGCMConnect("VBoxSharedCrOpenGL", &idClient); + if (RT_SUCCESS(rc)) + { + conn->u32ClientID = idClient; + crDebug("HGCM connect was successful: client id =0x%x\n", conn->u32ClientID); + + rc = crVBoxHGCMSetVersion(conn, CR_PROTOCOL_VERSION_MAJOR, CR_PROTOCOL_VERSION_MINOR); + if (RT_FAILURE(rc)) + { + WARN(("crVBoxHGCMSetVersion failed %d", rc)); + return FALSE; + } +#ifdef RT_OS_WINDOWS + rc = crVBoxHGCMSetPID(conn, GetCurrentProcessId()); +#else + rc = crVBoxHGCMSetPID(conn, crGetPID()); +#endif + if (RT_FAILURE(rc)) + { + WARN(("crVBoxHGCMSetPID failed %Rrc", rc)); + return FALSE; + } + + if (!g_crvboxhgcm.fHostCapsInitialized) + { + rc = crVBoxHGCMGetHostCapsLegacy(conn, &g_crvboxhgcm.u32HostCaps); + if (RT_FAILURE(rc)) + { + WARN(("VBoxCrHgsmiCtlConGetHostCaps failed %Rrc", rc)); + g_crvboxhgcm.u32HostCaps = 0; + } + + /* host may not support it, ignore any failures */ + g_crvboxhgcm.fHostCapsInitialized = true; + } + + if (g_crvboxhgcm.u32HostCaps & CR_VBOX_CAP_HOST_CAPS_NOT_SUFFICIENT) + { + crDebug("HGCM connect: insufficient host capabilities\n"); + g_crvboxhgcm.u32HostCaps = 0; + return FALSE; + } + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return TRUE; + } + + crDebug("HGCM connect failed: %Rrc\n", rc); + VbglR3Term(); + } + else + crDebug("Failed to initialize VbglR3 library: %Rrc\n", rc); + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return FALSE; + +#else /* !IN_GUEST */ + crError("crVBoxHGCMDoConnect called on host side!"); + CRASSERT(FALSE); + return FALSE; +#endif /* !IN_GUEST */ +} + +static bool _crVBoxCommonDoDisconnectLocked( CRConnection *conn ) +{ + int i; + if (conn->pHostBuffer) + { + crFree(conn->pHostBuffer); + conn->pHostBuffer = NULL; + conn->cbHostBuffer = 0; + conn->cbHostBufferAllocated = 0; + } + + conn->pBuffer = NULL; + conn->cbBuffer = 0; + + if (conn->type == CR_VBOXHGCM) + { + --g_crvboxhgcm.num_conns; + + if (conn->index < g_crvboxhgcm.num_conns) + { + g_crvboxhgcm.conns[conn->index] = g_crvboxhgcm.conns[g_crvboxhgcm.num_conns]; + g_crvboxhgcm.conns[conn->index]->index = conn->index; + } + else g_crvboxhgcm.conns[conn->index] = NULL; + + conn->type = CR_NO_CONNECTION; + } + + for (i = 0; i < g_crvboxhgcm.num_conns; i++) + if (g_crvboxhgcm.conns[i] && g_crvboxhgcm.conns[i]->type != CR_NO_CONNECTION) + return true; + return false; +} + +/** @todo same, replace DeviceIoControl with vbglR3DoIOCtl */ +static void crVBoxHGCMDoDisconnect( CRConnection *conn ) +{ + bool fHasActiveCons = false; + + if (!g_crvboxhgcm.initialized) return; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + + fHasActiveCons = _crVBoxCommonDoDisconnectLocked(conn); + +#ifndef IN_GUEST +#else /* IN_GUEST */ + if (conn->u32ClientID) + { + int rc = VbglR3HGCMDisconnect(conn->u32ClientID); + if (RT_FAILURE(rc)) + crDebug("Disconnect failed with %Rrc\n", rc); + conn->u32ClientID = 0; + + VbglR3Term(); + } +#endif /* IN_GUEST */ + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif +} + +static void crVBoxHGCMInstantReclaim(CRConnection *conn, CRMessage *mess) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + _crVBoxHGCMFree(conn, mess); + CRASSERT(FALSE); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void crVBoxHGCMHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len ) +{ + RT_NOREF(conn, msg, len); + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + CRASSERT(FALSE); + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + +bool _crVBoxHGSMIInit() +{ +#ifndef VBOX_CRHGSMI_WITH_D3DDEV + static +#endif + int bHasHGSMI = -1; + + if (bHasHGSMI < 0) + { + int rc; + rc = VBoxCrHgsmiInit(); + if (RT_SUCCESS(rc)) + bHasHGSMI = 1; + else + bHasHGSMI = 0; + + crDebug("CrHgsmi is %s", bHasHGSMI ? "ENABLED" : "DISABLED"); + } + + CRASSERT(bHasHGSMI >= 0); + + return bHasHGSMI; +} + +void _crVBoxHGSMITearDown() +{ + VBoxCrHgsmiTerm(); +} + +static void *_crVBoxHGSMIDoAlloc(CRConnection *conn, PCRVBOXHGSMI_CLIENT pClient) +{ + PVBOXUHGSMI_BUFFER buf; + CRVBOXHGCMBUFFER *pData = NULL; + uint32_t cbSize = conn->buffer_size; + int rc; + + buf = _crVBoxHGSMIBufAlloc(pClient, CRVBOXHGSMI_BUF_SIZE(cbSize)); + if (buf) + { + VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags; + buf->pvUserData = pClient; + fFlags.Value = 0; + fFlags.s.fDiscard = 1; + rc = buf->pfnLock(buf, 0, CRVBOXHGSMI_BUF_LOCK_SIZE(cbSize), fFlags, (void**)&pData); + if (RT_SUCCESS(rc)) + { + pData->magic = CR_VBOXHGCM_BUFFER_MAGIC; + pData->kind = CR_VBOXHGCM_UHGSMI_BUFFER; + pData->pBuffer = buf; + } + else + { + crWarning("Failed to Lock the buffer, rc(%d)\n", rc); + } + return CRVBOXHGSMI_BUF_DATA(pData); + } + else + { + crWarning("_crVBoxHGSMIBufAlloc failed to allocate buffer of size (%d)", CRVBOXHGSMI_BUF_SIZE(cbSize)); + } + + /* fall back */ + return _crVBoxHGCMAlloc(conn); +} + +static void _crVBoxHGSMIFree(CRConnection *conn, void *buf) +{ + CRVBOXHGCMBUFFER *hgcm_buffer = (CRVBOXHGCMBUFFER *) buf - 1; + + CRASSERT(hgcm_buffer->magic == CR_VBOXHGCM_BUFFER_MAGIC); + + if (hgcm_buffer->kind == CR_VBOXHGCM_UHGSMI_BUFFER) + { + PVBOXUHGSMI_BUFFER pBuf = _crVBoxHGSMIBufFromHdr(hgcm_buffer); + PCRVBOXHGSMI_CLIENT pClient = (PCRVBOXHGSMI_CLIENT)pBuf->pvUserData; + _crVBoxHGSMIBufFree(pClient, pBuf); + } + else + { + _crVBoxHGCMFree(conn, buf); + } +} + +static void *crVBoxHGSMIAlloc(CRConnection *conn) +{ + PCRVBOXHGSMI_CLIENT pClient; + void *pvBuf; + + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + pClient = _crVBoxHGSMIClientGet(conn); + if (pClient) + { + pvBuf = _crVBoxHGSMIDoAlloc(conn, pClient); + CRASSERT(pvBuf); + } + else + { + pvBuf = _crVBoxHGCMAlloc(conn); + } + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + + return pvBuf; +} + +static void crVBoxHGSMIFree(CRConnection *conn, void *buf) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + _crVBoxHGSMIFree(conn, buf); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void _crVBoxHGSMIPollHost(CRConnection *conn, PCRVBOXHGSMI_CLIENT pClient) +{ + CRVBOXHGSMIREAD *parms = (CRVBOXHGSMIREAD *)_crVBoxHGSMICmdBufferLock(pClient, sizeof (*parms)); + int rc; + VBOXUHGSMI_BUFFER_SUBMIT aSubmit[2]; + PVBOXUHGSMI_BUFFER pRecvBuffer; + uint32_t cbBuffer; + + CRASSERT(parms); + + parms->hdr.result = VERR_WRONG_ORDER; + parms->hdr.u32ClientID = conn->u32ClientID; + parms->hdr.u32Function = SHCRGL_GUEST_FN_READ; +/* parms->hdr.u32Reserved = 0;*/ + + CRASSERT(!conn->pBuffer); /* make sure there's no data to process */ + parms->iBuffer = 1; + parms->cbBuffer = 0; + + _crVBoxHGSMICmdBufferUnlock(pClient); + + pRecvBuffer = _crVBoxHGSMIRecvBufGet(pClient); + CRASSERT(pRecvBuffer); + if (!pRecvBuffer) + return; + + _crVBoxHGSMIFillCmd(&aSubmit[0], pClient, sizeof (*parms)); + + aSubmit[1].pBuf = pRecvBuffer; + aSubmit[1].offData = 0; + aSubmit[1].cbData = pRecvBuffer->cbBuffer; + aSubmit[1].fFlags.Value = 0; + aSubmit[1].fFlags.s.fHostWriteOnly = 1; + + rc = pClient->pHgsmi->pfnBufferSubmit(pClient->pHgsmi, aSubmit, 2); + if (RT_FAILURE(rc)) + { + crError("pfnBufferSubmit failed with %d \n", rc); + return; + } + + parms = (CRVBOXHGSMIREAD *)_crVBoxHGSMICmdBufferLockRo(pClient, sizeof (*parms)); + CRASSERT(parms); + if (!parms) + { + crWarning("_crVBoxHGSMICmdBufferLockRo failed\n"); + return; + } + + if (RT_SUCCESS(parms->hdr.result)) + cbBuffer = parms->cbBuffer; + else + cbBuffer = 0; + + _crVBoxHGSMICmdBufferUnlock(pClient); + + if (cbBuffer) + { + void *pvData = _crVBoxHGSMIRecvBufData(pClient, cbBuffer); + CRASSERT(pvData); + if (pvData) + { + conn->pBuffer = pvData; + conn->cbBuffer = cbBuffer; + } + } +} + +static void _crVBoxHGSMIReadExact(CRConnection *conn, PCRVBOXHGSMI_CLIENT pClient) +{ + _crVBoxHGSMIPollHost(conn, pClient); + + if (conn->cbBuffer) + _crVBoxHGCMReceiveMessage(conn); +} + +/* Same as crVBoxHGCMWriteExact, but combined with read of writeback data. + * This halves the number of HGCM calls we do, + * most likely crVBoxHGCMPollHost shouldn't be called at all now. + */ +static void +_crVBoxHGSMIWriteReadExact(CRConnection *conn, PCRVBOXHGSMI_CLIENT pClient, void *buf, uint32_t offBuffer, unsigned int len, bool bIsBuffer) +{ + CRVBOXHGSMIWRITEREAD *parms = (CRVBOXHGSMIWRITEREAD*)_crVBoxHGSMICmdBufferLock(pClient, sizeof (*parms)); + int rc; + VBOXUHGSMI_BUFFER_SUBMIT aSubmit[3]; + PVBOXUHGSMI_BUFFER pBuf = NULL; + VBOXUHGSMI_BUFFER_LOCK_FLAGS fFlags; +/* uint32_t cbBuffer;*/ + + parms->hdr.result = VERR_WRONG_ORDER; + parms->hdr.u32ClientID = conn->u32ClientID; + parms->hdr.u32Function = SHCRGL_GUEST_FN_WRITE_READ; +/* parms->hdr.u32Reserved = 0;*/ + + parms->iBuffer = 1; + + CRASSERT(!conn->pBuffer); /* make sure there's no data to process */ + parms->iWriteback = 2; + parms->cbWriteback = 0; + + _crVBoxHGSMICmdBufferUnlock(pClient); + + if (!bIsBuffer) + { + void *pvBuf; + pBuf = _crVBoxHGSMIBufAlloc(pClient, len); + + if (!pBuf) + { + /* fallback */ + crVBoxHGCMWriteReadExact(conn, buf, len, CR_VBOXHGCM_USERALLOCATED); + return; + } + + CRASSERT(!offBuffer); + + offBuffer = 0; + fFlags.Value = 0; + fFlags.s.fDiscard = 1; + fFlags.s.fWriteOnly = 1; + rc = pBuf->pfnLock(pBuf, 0, len, fFlags, &pvBuf); + if (RT_SUCCESS(rc)) + { + memcpy(pvBuf, buf, len); + rc = pBuf->pfnUnlock(pBuf); + CRASSERT(RT_SUCCESS(rc)); + } + else + { + crWarning("_crVBoxHGSMIWriteReadExact: pfnUnlock failed rc %d", rc); + _crVBoxHGSMIBufFree(pClient, pBuf); + /* fallback */ + crVBoxHGCMWriteReadExact(conn, buf, len, CR_VBOXHGCM_USERALLOCATED); + return; + } + } + else + { + pBuf = (PVBOXUHGSMI_BUFFER)buf; + } + + do + { + PVBOXUHGSMI_BUFFER pRecvBuffer = _crVBoxHGSMIRecvBufGet(pClient); + CRASSERT(pRecvBuffer); + if (!pRecvBuffer) + { + break; + } + + _crVBoxHGSMIFillCmd(&aSubmit[0], pClient, sizeof (*parms)); + + aSubmit[1].pBuf = pBuf; + aSubmit[1].offData = offBuffer; + aSubmit[1].cbData = len; + aSubmit[1].fFlags.Value = 0; + aSubmit[1].fFlags.s.fHostReadOnly = 1; + + aSubmit[2].pBuf = pRecvBuffer; + aSubmit[2].offData = 0; + aSubmit[2].cbData = pRecvBuffer->cbBuffer; + aSubmit[2].fFlags.Value = 0; + + rc = pClient->pHgsmi->pfnBufferSubmit(pClient->pHgsmi, aSubmit, 3); + if (RT_FAILURE(rc)) + { + crError("pfnBufferSubmit failed with %d \n", rc); + break; + } + + parms = (CRVBOXHGSMIWRITEREAD *)_crVBoxHGSMICmdBufferLockRo(pClient, sizeof (*parms)); + CRASSERT(parms); + if (parms) + { + uint32_t cbWriteback = parms->cbWriteback; + rc = parms->hdr.result; +#ifdef DEBUG_misha + /* catch it here to test the buffer */ + Assert(RT_SUCCESS(parms->hdr.Hdr.rc) || parms->hdr.Hdr.rc == VERR_BUFFER_OVERFLOW); +#endif + _crVBoxHGSMICmdBufferUnlock(pClient); +#ifdef DEBUG + parms = NULL; +#endif + if (RT_SUCCESS(rc)) + { + if (cbWriteback) + { + void *pvData = _crVBoxHGSMIRecvBufData(pClient, cbWriteback); + CRASSERT(pvData); + if (pvData) + { + conn->pBuffer = pvData; + conn->cbBuffer = cbWriteback; + _crVBoxHGCMReceiveMessage(conn); + } + } + } + else if (VERR_BUFFER_OVERFLOW == rc) + { + VBOXUHGSMI_BUFFER_TYPE_FLAGS Flags = {0}; + PVBOXUHGSMI_BUFFER pNewBuf; + CRASSERT(!pClient->pvHGBuffer); + CRASSERT(cbWriteback>pClient->pHGBuffer->cbBuffer); + crDebug("Reallocating host buffer from %d to %d bytes", conn->cbHostBufferAllocated, cbWriteback); + + rc = pClient->pHgsmi->pfnBufferCreate(pClient->pHgsmi, CRVBOXHGSMI_PAGE_ALIGN(cbWriteback), Flags, &pNewBuf); + if (RT_SUCCESS(rc)) + { + rc = pClient->pHGBuffer->pfnDestroy(pClient->pHGBuffer); + CRASSERT(RT_SUCCESS(rc)); + + pClient->pHGBuffer = pNewBuf; + + _crVBoxHGSMIReadExact(conn, pClient/*, cbWriteback*/); + } + else + { + crWarning("_crVBoxHGSMIWriteReadExact: pfnBufferCreate(%d) failed!", CRVBOXHGSMI_PAGE_ALIGN(cbWriteback)); + if (conn->cbHostBufferAllocated < cbWriteback) + { + crFree(conn->pHostBuffer); + conn->cbHostBufferAllocated = cbWriteback; + conn->pHostBuffer = crAlloc(conn->cbHostBufferAllocated); + } + crVBoxHGCMReadExact(conn, NULL, cbWriteback); + } + } + else + { + crWarning("SHCRGL_GUEST_FN_WRITE_READ (%i) failed with %x \n", len, rc); + } + } + else + { + crWarning("_crVBoxHGSMICmdBufferLockRo failed\n"); + break; + } + } while (0); + + if (!bIsBuffer) + _crVBoxHGSMIBufFree(pClient, pBuf); + + return; +} + +static void _crVBoxHGSMIWriteExact(CRConnection *conn, PCRVBOXHGSMI_CLIENT pClient, PVBOXUHGSMI_BUFFER pBuf, uint32_t offStart, unsigned int len) +{ + int rc; + int32_t callRes = VINF_SUCCESS; /* Shut up MSC. */ + VBOXUHGSMI_BUFFER_SUBMIT aSubmit[2]; + +#ifdef IN_GUEST + if (conn->u32InjectClientID) + { + CRVBOXHGSMIINJECT *parms = (CRVBOXHGSMIINJECT *)_crVBoxHGSMICmdBufferLock(pClient, sizeof (*parms)); + CRASSERT(parms); + if (!parms) + { + return; + } + + parms->hdr.result = VERR_WRONG_ORDER; + parms->hdr.u32ClientID = conn->u32ClientID; + parms->hdr.u32Function = SHCRGL_GUEST_FN_INJECT; +/* parms->hdr.u32Reserved = 0;*/ + + parms->u32ClientID = conn->u32InjectClientID; + + parms->iBuffer = 1; + _crVBoxHGSMICmdBufferUnlock(pClient); + + _crVBoxHGSMIFillCmd(&aSubmit[0], pClient, sizeof (*parms)); + + aSubmit[1].pBuf = pBuf; + aSubmit[1].offData = offStart; + aSubmit[1].cbData = len; + aSubmit[1].fFlags.Value = 0; + aSubmit[1].fFlags.s.fHostReadOnly = 1; + + rc = pClient->pHgsmi->pfnBufferSubmit(pClient->pHgsmi, aSubmit, 2); + if (RT_SUCCESS(rc)) + { + callRes = _crVBoxHGSMICmdBufferGetRc(pClient); + } + else + { + /* we can not recover at this point, report error & exit */ + crError("pfnBufferSubmit failed with %d \n", rc); + } + } + else +#endif + { + CRVBOXHGSMIWRITE * parms = (CRVBOXHGSMIWRITE *)_crVBoxHGSMICmdBufferLock(pClient, sizeof (*parms));; + + parms->hdr.result = VERR_WRONG_ORDER; + parms->hdr.u32ClientID = conn->u32ClientID; + parms->hdr.u32Function = SHCRGL_GUEST_FN_WRITE; +/* parms->hdr.u32Reserved = 0; */ + + parms->iBuffer = 1; + _crVBoxHGSMICmdBufferUnlock(pClient); + + _crVBoxHGSMIFillCmd(&aSubmit[0], pClient, sizeof (*parms)); + + aSubmit[1].pBuf = pBuf; + aSubmit[1].offData = offStart; + aSubmit[1].cbData = len; + aSubmit[1].fFlags.Value = 0; + aSubmit[1].fFlags.s.fHostReadOnly = 1; + + rc = pClient->pHgsmi->pfnBufferSubmit(pClient->pHgsmi, aSubmit, 2); + if (RT_SUCCESS(rc)) + { + callRes = _crVBoxHGSMICmdBufferGetRc(pClient); + } + else + { + /* we can not recover at this point, report error & exit */ + crError("Failed to submit CrHhgsmi buffer"); + } + } + + if (RT_FAILURE(rc) || RT_FAILURE(callRes)) + { + crWarning("SHCRGL_GUEST_FN_WRITE failed with %x %x\n", rc, callRes); + } +} + +static void crVBoxHGSMISend(CRConnection *conn, void **bufp, + const void *start, unsigned int len) +{ + PCRVBOXHGSMI_CLIENT pClient; + PVBOXUHGSMI_BUFFER pBuf; + CRVBOXHGCMBUFFER *hgcm_buffer; + + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + if (!bufp) /* We're sending a user-allocated buffer. */ + { + pClient = _crVBoxHGSMIClientGet(conn); + if (pClient) + { +#ifndef IN_GUEST + /** @todo remove temp buffer allocation in unpacker */ + /* we're at the host side, so just store data until guest polls us */ + _crVBoxHGCMWriteBytes(conn, start, len); +#else + CRASSERT(!conn->u32InjectClientID); + crDebug("SHCRGL: sending userbuf with %d bytes\n", len); + _crVBoxHGSMIWriteReadExact(conn, pClient, (void*)start, 0, len, false); +#endif +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return; + } + + /* fallback */ + crVBoxHGCMSend(conn, bufp, start, len); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return; + } + + hgcm_buffer = (CRVBOXHGCMBUFFER *) *bufp - 1; + CRASSERT(hgcm_buffer->magic == CR_VBOXHGCM_BUFFER_MAGIC); + if (hgcm_buffer->magic != CR_VBOXHGCM_BUFFER_MAGIC) + { + crError("HGCM buffer magic mismatch"); + } + + + if (hgcm_buffer->kind != CR_VBOXHGCM_UHGSMI_BUFFER) + { + /* fallback */ + crVBoxHGCMSend(conn, bufp, start, len); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return; + } + + /* The region [start .. start + len + 1] lies within a buffer that + * was allocated with crVBoxHGCMAlloc() and can be put into the free + * buffer pool when we're done sending it. + */ + + pBuf = _crVBoxHGSMIBufFromHdr(hgcm_buffer); + CRASSERT(pBuf); + if (!pBuf) + { + crVBoxHGCMSend(conn, bufp, start, len); +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return; + } + + pClient = (PCRVBOXHGSMI_CLIENT)pBuf->pvUserData; + if (pClient != &conn->HgsmiClient) + { + crError("HGSMI client mismatch"); + } + + /* Length would be passed as part of HGCM pointer description + * No need to prepend it to the buffer + */ +#ifdef IN_GUEST + if (conn->u32InjectClientID) + { + _crVBoxHGSMIWriteExact(conn, pClient, pBuf, CRVBOXHGSMI_BUF_OFFSET(start, *bufp) + CRVBOXHGSMI_BUF_HDR_SIZE(), len); + } + else +#endif + { + _crVBoxHGSMIWriteReadExact(conn, pClient, pBuf, CRVBOXHGSMI_BUF_OFFSET(start, *bufp) + CRVBOXHGSMI_BUF_HDR_SIZE(), len, true); + } + + /* Reclaim this pointer for reuse */ + _crVBoxHGSMIBufFree(pClient, pBuf); + /* Since the buffer's now in the 'free' buffer pool, the caller can't + * use it any more. Setting bufp to NULL will make sure the caller + * doesn't try to re-use the buffer. + */ + *bufp = NULL; + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void crVBoxHGSMIWriteExact(CRConnection *conn, const void *buf, unsigned int len) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + + CRASSERT(0); + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void crVBoxHGSMISingleRecv(CRConnection *conn, void *buf, unsigned int len) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + + CRASSERT(0); + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void crVBoxHGSMIReceiveMessage(CRConnection *conn) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + CRASSERT(0); + + _crVBoxHGCMReceiveMessage(conn); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +/* + * Called on host side only, to "accept" client connection + */ +static void crVBoxHGSMIAccept( CRConnection *conn, const char *hostname, unsigned short port ) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + CRASSERT(0); + + CRASSERT(conn && conn->pHostBuffer); +#ifdef IN_GUEST + CRASSERT(FALSE); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static int crVBoxHGSMIDoConnect( CRConnection *conn ) +{ + PCRVBOXHGSMI_CLIENT pClient; + int rc = VINF_SUCCESS; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + + pClient = _crVBoxHGSMIClientGet(conn); + if (pClient) + { + rc = VBoxCrHgsmiCtlConGetClientID(pClient->pHgsmi, &conn->u32ClientID); + if (RT_FAILURE(rc)) + { + WARN(("VBoxCrHgsmiCtlConGetClientID failed %d", rc)); + } + if (!g_crvboxhgcm.fHostCapsInitialized) + { + rc = VBoxCrHgsmiCtlConGetHostCaps(pClient->pHgsmi, &g_crvboxhgcm.u32HostCaps); + if (RT_SUCCESS(rc)) + { + g_crvboxhgcm.fHostCapsInitialized = true; + } + else + { + WARN(("VBoxCrHgsmiCtlConGetHostCaps failed %d", rc)); + g_crvboxhgcm.u32HostCaps = 0; + } + } + } + else + { + WARN(("_crVBoxHGSMIClientGet failed %d", rc)); + rc = VERR_GENERAL_FAILURE; + } + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + return RT_SUCCESS(rc); +} + +static void crVBoxHGSMIDoDisconnect( CRConnection *conn ) +{ + bool fHasActiveCons = false; + + if (!g_crvboxhgcm.initialized) return; + + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + fHasActiveCons = _crVBoxCommonDoDisconnectLocked(conn); + +#ifndef VBOX_CRHGSMI_WITH_D3DDEV + if (conn->HgsmiClient.pHgsmi) + { + PVBOXUHGSMI pHgsmi; + _crVBoxHGSMIClientTerm(&conn->HgsmiClient, &pHgsmi); + CRASSERT(pHgsmi); + if (!conn->pExternalHgsmi) + VBoxCrHgsmiDestroy(pHgsmi); + } +#else +# error "port me!" +#endif + + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif +} + +static void crVBoxHGSMIInstantReclaim(CRConnection *conn, CRMessage *mess) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + CRASSERT(0); + + _crVBoxHGSMIFree(conn, mess); + +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} + +static void crVBoxHGSMIHandleNewMessage( CRConnection *conn, CRMessage *msg, unsigned int len ) +{ + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + CRASSERT(0); + + CRASSERT(FALSE); + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); +} +#endif + +void crVBoxHGCMInit(CRNetReceiveFuncList *rfl, CRNetCloseFuncList *cfl, unsigned int mtu) +{ + (void) mtu; + + g_crvboxhgcm.recv_list = rfl; + g_crvboxhgcm.close_list = cfl; + if (g_crvboxhgcm.initialized) + { + return; + } + + VBOXCRHGSMIPROFILE_INIT(); + + g_crvboxhgcm.initialized = 1; + +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + g_crvboxhgcm.bHgsmiOn = _crVBoxHGSMIInit(); +#endif + + g_crvboxhgcm.num_conns = 0; + g_crvboxhgcm.conns = NULL; + + /* Can't open VBox guest driver here, because it gets called for host side as well */ + /** @todo as we have 2 dll versions, can do it now.*/ + +#ifdef RT_OS_WINDOWS + g_crvboxhgcm.pDirectDraw = NULL; +#endif + +#ifdef CHROMIUM_THREADSAFE + crInitMutex(&g_crvboxhgcm.mutex); + crInitMutex(&g_crvboxhgcm.recvmutex); +#endif + g_crvboxhgcm.bufpool = crBufferPoolInit(16); + +#ifdef IN_GUEST + g_crvboxhgcm.fHostCapsInitialized = false; + g_crvboxhgcm.u32HostCaps = 0; +#endif +} + +/* Callback function used to free buffer pool entries */ +static void crVBoxHGCMBufferFree(void *data) +{ + CRVBOXHGCMBUFFER *hgcm_buffer = (CRVBOXHGCMBUFFER *) data; + + CRASSERT(hgcm_buffer->magic == CR_VBOXHGCM_BUFFER_MAGIC); + + switch (hgcm_buffer->kind) + { + case CR_VBOXHGCM_MEMORY: + crDebug("crVBoxHGCMBufferFree: CR_VBOXHGCM_MEMORY: %p", hgcm_buffer); + crFree( hgcm_buffer ); + break; + case CR_VBOXHGCM_MEMORY_BIG: + crDebug("crVBoxHGCMBufferFree: CR_VBOXHGCM_MEMORY_BIG: %p", hgcm_buffer); + crFree( hgcm_buffer ); + break; + + default: + crError( "Weird buffer kind trying to free in crVBoxHGCMBufferFree: %d", hgcm_buffer->kind ); + } +} + +void crVBoxHGCMTearDown(void) +{ + int32_t i, cCons; + + if (!g_crvboxhgcm.initialized) return; + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + + /* Connection count would be changed in calls to crNetDisconnect, so we have to store original value. + * Walking array backwards is not a good idea as it could cause some issues if we'd disconnect clients not in the + * order of their connection. + */ + cCons = g_crvboxhgcm.num_conns; + for (i=0; itype = CR_VBOXHGCM; + conn->Alloc = crVBoxHGSMIAlloc; + conn->Send = crVBoxHGSMISend; + conn->SendExact = crVBoxHGSMIWriteExact; + conn->Recv = crVBoxHGSMISingleRecv; + conn->RecvMsg = crVBoxHGSMIReceiveMessage; + conn->Free = crVBoxHGSMIFree; + conn->Accept = crVBoxHGSMIAccept; + conn->Connect = crVBoxHGSMIDoConnect; + conn->Disconnect = crVBoxHGSMIDoDisconnect; + conn->InstantReclaim = crVBoxHGSMIInstantReclaim; + conn->HandleNewMessage = crVBoxHGSMIHandleNewMessage; + conn->pExternalHgsmi = pHgsmi; + } + else +#endif + { + conn->type = CR_VBOXHGCM; + conn->Alloc = crVBoxHGCMAlloc; + conn->Send = crVBoxHGCMSend; + conn->SendExact = crVBoxHGCMWriteExact; + conn->Recv = crVBoxHGCMSingleRecv; + conn->RecvMsg = crVBoxHGCMReceiveMessage; + conn->Free = crVBoxHGCMFree; + conn->Accept = crVBoxHGCMAccept; + conn->Connect = crVBoxHGCMDoConnect; + conn->Disconnect = crVBoxHGCMDoDisconnect; + conn->InstantReclaim = crVBoxHGCMInstantReclaim; + conn->HandleNewMessage = crVBoxHGCMHandleNewMessage; + } + conn->sizeof_buffer_header = sizeof(CRVBOXHGCMBUFFER); + conn->actual_network = 1; + + conn->krecv_buf_size = 0; + + conn->pBuffer = NULL; + conn->cbBuffer = 0; + conn->allow_redir_ptr = 1; + + /** @todo remove this crap at all later */ + conn->cbHostBufferAllocated = 2*1024; + conn->pHostBuffer = (uint8_t*) crAlloc(conn->cbHostBufferAllocated); + CRASSERT(conn->pHostBuffer); + conn->cbHostBuffer = 0; + +#if !defined(IN_GUEST) + RTListInit(&conn->PendingMsgList); +#endif + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + /* Find a free slot */ + for (i = 0; i < g_crvboxhgcm.num_conns; i++) { + if (g_crvboxhgcm.conns[i] == NULL) { + conn->index = i; + g_crvboxhgcm.conns[i] = conn; + found = 1; + break; + } + } + + /* Realloc connection stack if we couldn't find a free slot */ + if (found == 0) { + n_bytes = ( g_crvboxhgcm.num_conns + 1 ) * sizeof(*g_crvboxhgcm.conns); + crRealloc( (void **) &g_crvboxhgcm.conns, n_bytes ); + conn->index = g_crvboxhgcm.num_conns; + g_crvboxhgcm.conns[g_crvboxhgcm.num_conns++] = conn; + } +#ifdef CHROMIUM_THREADSAFE + crUnlockMutex(&g_crvboxhgcm.mutex); +#endif +} + +#if defined(IN_GUEST) +static void _crVBoxHGCMPerformPollHost(CRConnection *conn) +{ + if (conn->type == CR_NO_CONNECTION ) + return; + + if (!conn->pBuffer) + { +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + PCRVBOXHGSMI_CLIENT pClient; + if (g_crvboxhgcm.bHgsmiOn && !!(pClient = _crVBoxHGSMIClientGet(conn))) + { + _crVBoxHGSMIPollHost(conn, pClient); + } + else +#endif + { + crVBoxHGCMPollHost(conn); + } + } +} +#endif + +static void _crVBoxHGCMPerformReceiveMessage(CRConnection *conn) +{ + if ( conn->type == CR_NO_CONNECTION ) + return; + + if (conn->cbBuffer>0) + { + _crVBoxHGCMReceiveMessage(conn); + } +} + +#ifdef IN_GUEST +uint32_t crVBoxHGCMHostCapsGet(void) +{ + Assert(g_crvboxhgcm.fHostCapsInitialized); + return g_crvboxhgcm.u32HostCaps; +} +#endif + +int crVBoxHGCMRecv( +#if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + CRConnection *conn +#else + void +#endif + ) +{ + int32_t i; + + VBOXCRHGSMIPROFILE_FUNC_PROLOGUE(); + +#ifdef CHROMIUM_THREADSAFE + crLockMutex(&g_crvboxhgcm.mutex); +#endif + +#ifdef IN_GUEST +# if defined(VBOX_WITH_CRHGSMI) && defined(IN_GUEST) + if (conn && g_crvboxhgcm.bHgsmiOn) + { + _crVBoxHGCMPerformPollHost(conn); + _crVBoxHGCMPerformReceiveMessage(conn); + VBOXCRHGSMIPROFILE_FUNC_EPILOGUE(); + return 0; + } +# endif + /* we're on guest side, poll host if it got something for us */ + for (i=0; i +# include +#endif + +#include +#include +#include + +#ifdef DEBUG_misha +# define VBOXVDBG_VR_LAL_DISABLE +#endif + +#ifndef IN_RING0 +# include +# ifndef VBOXVDBG_VR_LAL_DISABLE +static RTMEMCACHE g_VBoxVrLookasideList; +# define vboxVrRegLaAlloc(_c) RTMemCacheAlloc((_c)) +# define vboxVrRegLaFree(_c, _e) RTMemCacheFree((_c), (_e)) + +DECLINLINE(int) vboxVrLaCreate(PRTMEMCACHE phCache, size_t cbElement) +{ + int rc = RTMemCacheCreate(phCache, + cbElement, + 0 /* cbAlignment */, + UINT32_MAX /* cMaxObjects */, + NULL /* pfnCtor*/, + NULL /* pfnDtor*/, + NULL /* pvUser*/, + 0 /* fFlags*/); + if (!RT_SUCCESS(rc)) + { + WARN(("RTMemCacheCreate failed rc %d", rc)); + return rc; + } + return VINF_SUCCESS; +} +# define vboxVrLaDestroy(_c) RTMemCacheDestroy((_c)) +# endif /* !VBOXVDBG_VR_LAL_DISABLE */ + +#else /* IN_RING0 */ +# ifdef RT_OS_WINDOWS +# undef PAGE_SIZE +# undef PAGE_SHIFT +# include +# ifndef VBOXVDBG_VR_LAL_DISABLE +static LOOKASIDE_LIST_EX g_VBoxVrLookasideList; +# define vboxVrRegLaAlloc(_c) ExAllocateFromLookasideListEx(&(_c)) +# define vboxVrRegLaFree(_c, _e) ExFreeToLookasideListEx(&(_c), (_e)) +# define VBOXWDDMVR_MEMTAG 'vDBV' +DECLINLINE(int) vboxVrLaCreate(LOOKASIDE_LIST_EX *pCache, size_t cbElement) +{ + NTSTATUS Status = ExInitializeLookasideListEx(pCache, + NULL, /* PALLOCATE_FUNCTION_EX Allocate */ + NULL, /* PFREE_FUNCTION_EX Free */ + NonPagedPool, + 0, /* ULONG Flags */ + cbElement, + VBOXWDDMVR_MEMTAG, + 0 /* USHORT Depth - reserved, must be null */ + ); + if (!NT_SUCCESS(Status)) + { + WARN(("ExInitializeLookasideListEx failed, Status (0x%x)", Status)); + return VERR_GENERAL_FAILURE; + } + + return VINF_SUCCESS; +} +# define vboxVrLaDestroy(_c) ExDeleteLookasideListEx(&(_c)) +# endif +# else /* !RT_OS_WINDOWS */ +# error "port me!" +# endif /* !RT_OS_WINDOWS */ +#endif /* IN_RING0 */ + + +/********************************************************************************************************************************* +* Defined Constants And Macros * +*********************************************************************************************************************************/ +#define VBOXVR_INVALID_COORD (~0U) + + +/********************************************************************************************************************************* +* Global Variables * +*********************************************************************************************************************************/ +static volatile int32_t g_cVBoxVrInits = 0; + + +static PVBOXVR_REG vboxVrRegCreate(void) +{ +#ifndef VBOXVDBG_VR_LAL_DISABLE + PVBOXVR_REG pReg = (PVBOXVR_REG)vboxVrRegLaAlloc(g_VBoxVrLookasideList); + if (!pReg) + { + WARN(("ExAllocateFromLookasideListEx failed!")); + } + return pReg; +#else + return (PVBOXVR_REG)RTMemAlloc(sizeof(VBOXVR_REG)); +#endif +} + +static void vboxVrRegTerm(PVBOXVR_REG pReg) +{ +#ifndef VBOXVDBG_VR_LAL_DISABLE + vboxVrRegLaFree(g_VBoxVrLookasideList, pReg); +#else + RTMemFree(pReg); +#endif +} + +VBOXVREGDECL(void) VBoxVrListClear(PVBOXVR_LIST pList) +{ + PVBOXVR_REG pReg, pRegNext; + RTListForEachSafe(&pList->ListHead, pReg, pRegNext, VBOXVR_REG, ListEntry) + { + vboxVrRegTerm(pReg); + } + VBoxVrListInit(pList); +} + +/* moves list data to pDstList and empties the pList */ +VBOXVREGDECL(void) VBoxVrListMoveTo(PVBOXVR_LIST pList, PVBOXVR_LIST pDstList) +{ + *pDstList = *pList; + pDstList->ListHead.pNext->pPrev = &pDstList->ListHead; + pDstList->ListHead.pPrev->pNext = &pDstList->ListHead; + VBoxVrListInit(pList); +} + +VBOXVREGDECL(int) VBoxVrInit(void) +{ + int32_t cNewRefs = ASMAtomicIncS32(&g_cVBoxVrInits); + Assert(cNewRefs >= 1); + Assert(cNewRefs == 1); /* <- debugging */ + if (cNewRefs > 1) + return VINF_SUCCESS; + +#ifndef VBOXVDBG_VR_LAL_DISABLE + int rc = vboxVrLaCreate(&g_VBoxVrLookasideList, sizeof(VBOXVR_REG)); + if (!RT_SUCCESS(rc)) + { + WARN(("ExInitializeLookasideListEx failed, rc (%d)", rc)); + return rc; + } +#endif + + return VINF_SUCCESS; +} + +VBOXVREGDECL(void) VBoxVrTerm(void) +{ + int32_t cNewRefs = ASMAtomicDecS32(&g_cVBoxVrInits); + Assert(cNewRefs >= 0); + if (cNewRefs > 0) + return; + +#ifndef VBOXVDBG_VR_LAL_DISABLE + vboxVrLaDestroy(g_VBoxVrLookasideList); +#endif +} + +typedef DECLCALLBACK(int) FNVBOXVR_CB_COMPARATOR(PCVBOXVR_REG pReg1, PCVBOXVR_REG pReg2); +typedef FNVBOXVR_CB_COMPARATOR *PFNVBOXVR_CB_COMPARATOR; + +static DECLCALLBACK(int) vboxVrRegNonintersectedComparator(PCRTRECT pRect1, PCRTRECT pRect2) +{ + Assert(!VBoxRectIsIntersect(pRect1, pRect2)); + if (pRect1->yTop != pRect2->yTop) + return pRect1->yTop - pRect2->yTop; + return pRect1->xLeft - pRect2->xLeft; +} + +#ifdef DEBUG_misha +static void vboxVrDbgListDoVerify(PVBOXVR_LIST pList) +{ + PVBOXVR_REG pReg1, pReg2; + RTListForEach(&pList->ListHead, pReg1, VBOXVR_REG, ListEntry) + { + Assert(!VBoxRectIsZero(&pReg1->Rect)); + for (RTLISTNODE *pEntry2 = pReg1->ListEntry.pNext; pEntry2 != &pList->ListHead; pEntry2 = pEntry2->pNext) + { + pReg2 = PVBOXVR_REG_FROM_ENTRY(pEntry2); + Assert(vboxVrRegNonintersectedComparator(&pReg1->Rect, &pReg2->Rect) < 0); + } + } +} +# define vboxVrDbgListVerify(_p) vboxVrDbgListDoVerify(_p) +#else +# define vboxVrDbgListVerify(_p) do {} while (0) +#endif + + +DECLINLINE(void) vboxVrListRegAdd(PVBOXVR_LIST pList, PVBOXVR_REG pReg, PRTLISTNODE pPlace, bool fAfter) +{ + if (fAfter) + RTListPrepend(pPlace, &pReg->ListEntry); + else + RTListAppend(pPlace, &pReg->ListEntry); + ++pList->cEntries; + vboxVrDbgListVerify(pList); +} + +DECLINLINE(void) vboxVrListRegRemove(PVBOXVR_LIST pList, PVBOXVR_REG pReg) +{ + RTListNodeRemove(&pReg->ListEntry); + --pList->cEntries; + vboxVrDbgListVerify(pList); +} + +static void vboxVrListRegAddOrder(PVBOXVR_LIST pList, PRTLISTNODE pMemberEntry, PVBOXVR_REG pReg) +{ + for (;;) + { + if (pMemberEntry != &pList->ListHead) + { + PVBOXVR_REG pMemberReg = PVBOXVR_REG_FROM_ENTRY(pMemberEntry); + if (vboxVrRegNonintersectedComparator(&pMemberReg->Rect, &pReg->Rect) < 0) + { + pMemberEntry = pMemberEntry->pNext; + continue; + } + } + vboxVrListRegAdd(pList, pReg, pMemberEntry, false); + break; + } +} + +static void vboxVrListAddNonintersected(PVBOXVR_LIST pList1, PVBOXVR_LIST pList2) +{ + PRTLISTNODE pEntry1 = pList1->ListHead.pNext; + + for (PRTLISTNODE pEntry2 = pList2->ListHead.pNext; pEntry2 != &pList2->ListHead; pEntry2 = pList2->ListHead.pNext) + { + PVBOXVR_REG pReg2 = PVBOXVR_REG_FROM_ENTRY(pEntry2); + for (;;) + { + if (pEntry1 != &pList1->ListHead) + { + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + if (vboxVrRegNonintersectedComparator(&pReg1->Rect, &pReg2->Rect) < 0) + { + pEntry1 = pEntry1->pNext; + continue; + } + } + vboxVrListRegRemove(pList2, pReg2); + vboxVrListRegAdd(pList1, pReg2, pEntry1, false); + break; + } + } + + Assert(VBoxVrListIsEmpty(pList2)); +} + +static int vboxVrListRegIntersectSubstNoJoin(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, PCRTRECT pRect2) +{ + uint32_t topLim = VBOXVR_INVALID_COORD; + uint32_t bottomLim = VBOXVR_INVALID_COORD; + RTLISTNODE List; + PVBOXVR_REG pBottomReg = NULL; +#ifdef DEBUG_misha + RTRECT tmpRect = pReg1->Rect; + vboxVrDbgListVerify(pList1); +#endif + Assert(!VBoxRectIsZero(pRect2)); + + RTListInit(&List); + + Assert(VBoxRectIsIntersect(&pReg1->Rect, pRect2)); + + if (pReg1->Rect.yTop < pRect2->yTop) + { + Assert(pRect2->yTop < pReg1->Rect.yBottom); + PVBOXVR_REG pRegResult = vboxVrRegCreate(); + pRegResult->Rect.yTop = pReg1->Rect.yTop; + pRegResult->Rect.xLeft = pReg1->Rect.xLeft; + pRegResult->Rect.yBottom = pRect2->yTop; + pRegResult->Rect.xRight = pReg1->Rect.xRight; + topLim = pRect2->yTop; + RTListAppend(&List, &pRegResult->ListEntry); + } + + if (pReg1->Rect.yBottom > pRect2->yBottom) + { + Assert(pRect2->yBottom > pReg1->Rect.yTop); + PVBOXVR_REG pRegResult = vboxVrRegCreate(); + pRegResult->Rect.yTop = pRect2->yBottom; + pRegResult->Rect.xLeft = pReg1->Rect.xLeft; + pRegResult->Rect.yBottom = pReg1->Rect.yBottom; + pRegResult->Rect.xRight = pReg1->Rect.xRight; + bottomLim = pRect2->yBottom; + pBottomReg = pRegResult; + } + + if (pReg1->Rect.xLeft < pRect2->xLeft) + { + Assert(pRect2->xLeft < pReg1->Rect.xRight); + PVBOXVR_REG pRegResult = vboxVrRegCreate(); + pRegResult->Rect.yTop = topLim == VBOXVR_INVALID_COORD ? pReg1->Rect.yTop : topLim; + pRegResult->Rect.xLeft = pReg1->Rect.xLeft; + pRegResult->Rect.yBottom = bottomLim == VBOXVR_INVALID_COORD ? pReg1->Rect.yBottom : bottomLim; + pRegResult->Rect.xRight = pRect2->xLeft; + RTListAppend(&List, &pRegResult->ListEntry); + } + + if (pReg1->Rect.xRight > pRect2->xRight) + { + Assert(pRect2->xRight > pReg1->Rect.xLeft); + PVBOXVR_REG pRegResult = vboxVrRegCreate(); + pRegResult->Rect.yTop = topLim == VBOXVR_INVALID_COORD ? pReg1->Rect.yTop : topLim; + pRegResult->Rect.xLeft = pRect2->xRight; + pRegResult->Rect.yBottom = bottomLim == VBOXVR_INVALID_COORD ? pReg1->Rect.yBottom : bottomLim; + pRegResult->Rect.xRight = pReg1->Rect.xRight; + RTListAppend(&List, &pRegResult->ListEntry); + } + + if (pBottomReg) + RTListAppend(&List, &pBottomReg->ListEntry); + + PRTLISTNODE pMemberEntry = pReg1->ListEntry.pNext; + vboxVrListRegRemove(pList1, pReg1); + vboxVrRegTerm(pReg1); + + if (RTListIsEmpty(&List)) + return VINF_SUCCESS; /* the region is covered by the pRect2 */ + + PRTLISTNODE pNext; + PRTLISTNODE pEntry = List.pNext; + for (; pEntry != &List; pEntry = pNext) + { + pNext = pEntry->pNext; + PVBOXVR_REG pReg = PVBOXVR_REG_FROM_ENTRY(pEntry); + + vboxVrListRegAddOrder(pList1, pMemberEntry, pReg); + pMemberEntry = pEntry->pNext; /* the following elements should go after the given pEntry since they are ordered already */ + } + return VINF_SUCCESS; +} + +/** + * @returns Entry to be used for continuing the rectangles iterations being made currently on the callback call. + * ListHead is returned to break the current iteration + * @param ppNext specifies next reg entry to be used for iteration. the default is pReg1->ListEntry.pNext */ +typedef DECLCALLBACK(PRTLISTNODE) FNVBOXVR_CB_INTERSECTED_VISITOR(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, + PCRTRECT pRect2, void *pvContext, PRTLISTNODE *ppNext); +typedef FNVBOXVR_CB_INTERSECTED_VISITOR *PFNVBOXVR_CB_INTERSECTED_VISITOR; + +static void vboxVrListVisitIntersected(PVBOXVR_LIST pList1, uint32_t cRects, PCRTRECT aRects, + PFNVBOXVR_CB_INTERSECTED_VISITOR pfnVisitor, void* pvVisitor) +{ + PRTLISTNODE pEntry1 = pList1->ListHead.pNext; + PRTLISTNODE pNext1; + uint32_t iFirst2 = 0; + + for (; pEntry1 != &pList1->ListHead; pEntry1 = pNext1) + { + pNext1 = pEntry1->pNext; + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + for (uint32_t i = iFirst2; i < cRects; ++i) + { + PCRTRECT pRect2 = &aRects[i]; + if (VBoxRectIsZero(pRect2)) + continue; + + if (!VBoxRectIsIntersect(&pReg1->Rect, pRect2)) + continue; + + /* the visitor can modify the list 1, apply necessary adjustments after it */ + pEntry1 = pfnVisitor (pList1, pReg1, pRect2, pvVisitor, &pNext1); + if (pEntry1 == &pList1->ListHead) + break; + pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + } + } +} + +#if 0 /* unused */ +/** + * @returns Entry to be iterated next. ListHead is returned to break the + * iteration + */ +typedef DECLCALLBACK(PRTLISTNODE) FNVBOXVR_CB_NONINTERSECTED_VISITOR(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, void *pvContext); +typedef FNVBOXVR_CB_NONINTERSECTED_VISITOR *PFNVBOXVR_CB_NONINTERSECTED_VISITOR; + +static void vboxVrListVisitNonintersected(PVBOXVR_LIST pList1, uint32_t cRects, PCRTRECT aRects, + PFNVBOXVR_CB_NONINTERSECTED_VISITOR pfnVisitor, void* pvVisitor) +{ + PRTLISTNODE pEntry1 = pList1->ListHead.pNext; + PRTLISTNODE pNext1; + uint32_t iFirst2 = 0; + + for (; pEntry1 != &pList1->ListHead; pEntry1 = pNext1) + { + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + uint32_t i = iFirst2; + for (; i < cRects; ++i) + { + PCRTRECT pRect2 = &aRects[i]; + if (VBoxRectIsZero(pRect2)) + continue; + + if (VBoxRectIsIntersect(&pReg1->Rect, pRect2)) + break; + } + + if (i == cRects) + pNext1 = pfnVisitor(pList1, pReg1, pvVisitor); + else + pNext1 = pEntry1->pNext; + } +} +#endif /* unused */ + +static void vboxVrListJoinRectsHV(PVBOXVR_LIST pList, bool fHorizontal) +{ + PRTLISTNODE pNext1, pNext2; + + for (PRTLISTNODE pEntry1 = pList->ListHead.pNext; pEntry1 != &pList->ListHead; pEntry1 = pNext1) + { + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + pNext1 = pEntry1->pNext; + for (PRTLISTNODE pEntry2 = pEntry1->pNext; pEntry2 != &pList->ListHead; pEntry2 = pNext2) + { + PVBOXVR_REG pReg2 = PVBOXVR_REG_FROM_ENTRY(pEntry2); + pNext2 = pEntry2->pNext; + if (fHorizontal) + { + if (pReg1->Rect.yTop == pReg2->Rect.yTop) + { + if (pReg1->Rect.xRight == pReg2->Rect.xLeft) + { + /* join rectangles */ + vboxVrListRegRemove(pList, pReg2); + if (pReg1->Rect.yBottom > pReg2->Rect.yBottom) + { + int32_t oldRight1 = pReg1->Rect.xRight; + int32_t oldBottom1 = pReg1->Rect.yBottom; + pReg1->Rect.xRight = pReg2->Rect.xRight; + pReg1->Rect.yBottom = pReg2->Rect.yBottom; + + vboxVrDbgListVerify(pList); + + pReg2->Rect.xLeft = pReg1->Rect.xLeft; + pReg2->Rect.yTop = pReg1->Rect.yBottom; + pReg2->Rect.xRight = oldRight1; + pReg2->Rect.yBottom = oldBottom1; + vboxVrListRegAddOrder(pList, pReg1->ListEntry.pNext, pReg2); + /* restart the pNext1 & pNext2 since regs are splitted into smaller ones in y dimension + * and thus can match one of the previous rects */ + pNext1 = pList->ListHead.pNext; + break; + } + + if (pReg1->Rect.yBottom < pReg2->Rect.yBottom) + { + pReg1->Rect.xRight = pReg2->Rect.xRight; + vboxVrDbgListVerify(pList); + pReg2->Rect.yTop = pReg1->Rect.yBottom; + vboxVrListRegAddOrder(pList, pReg1->ListEntry.pNext, pReg2); + /* restart the pNext1 & pNext2 since regs are splitted into smaller ones in y dimension + * and thus can match one of the previous rects */ + pNext1 = pList->ListHead.pNext; + break; + } + + pReg1->Rect.xRight = pReg2->Rect.xRight; + vboxVrDbgListVerify(pList); + /* reset the pNext1 since it could be the pReg2 being destroyed */ + pNext1 = pEntry1->pNext; + /* pNext2 stays the same since it is pReg2->ListEntry.pNext, which is kept intact */ + vboxVrRegTerm(pReg2); + } + continue; + } + else if (pReg1->Rect.yBottom == pReg2->Rect.yBottom) + { + Assert(pReg1->Rect.yTop < pReg2->Rect.yTop); /* <- since pReg1 > pReg2 && pReg1->Rect.yTop != pReg2->Rect.yTop*/ + if (pReg1->Rect.xRight == pReg2->Rect.xLeft) + { + /* join rectangles */ + vboxVrListRegRemove(pList, pReg2); + + pReg1->Rect.yBottom = pReg2->Rect.yTop; + vboxVrDbgListVerify(pList); + pReg2->Rect.xLeft = pReg1->Rect.xLeft; + + vboxVrListRegAddOrder(pList, pNext2, pReg2); + + /* restart the pNext1 & pNext2 since regs are splitted into smaller ones in y dimension + * and thus can match one of the previous rects */ + pNext1 = pList->ListHead.pNext; + break; + } + + if (pReg1->Rect.xLeft == pReg2->Rect.xRight) + { + /* join rectangles */ + vboxVrListRegRemove(pList, pReg2); + + pReg1->Rect.yBottom = pReg2->Rect.yTop; + vboxVrDbgListVerify(pList); + pReg2->Rect.xRight = pReg1->Rect.xRight; + + vboxVrListRegAddOrder(pList, pNext2, pReg2); + + /* restart the pNext1 & pNext2 since regs are splitted into smaller ones in y dimension + * and thus can match one of the previous rects */ + pNext1 = pList->ListHead.pNext; + break; + } + continue; + } + } + else + { + if (pReg1->Rect.yBottom == pReg2->Rect.yTop) + { + if (pReg1->Rect.xLeft == pReg2->Rect.xLeft) + { + if (pReg1->Rect.xRight == pReg2->Rect.xRight) + { + /* join rects */ + vboxVrListRegRemove(pList, pReg2); + + pReg1->Rect.yBottom = pReg2->Rect.yBottom; + vboxVrDbgListVerify(pList); + + /* reset the pNext1 since it could be the pReg2 being destroyed */ + pNext1 = pEntry1->pNext; + /* pNext2 stays the same since it is pReg2->ListEntry.pNext, which is kept intact */ + vboxVrRegTerm(pReg2); + continue; + } + /* no more to be done for for pReg1 */ + break; + } + + if (pReg1->Rect.xRight > pReg2->Rect.xLeft) + { + /* no more to be done for for pReg1 */ + break; + } + + continue; + } + + if (pReg1->Rect.yBottom < pReg2->Rect.yTop) + { + /* no more to be done for for pReg1 */ + break; + } + } + } + } +} + +static void vboxVrListJoinRects(PVBOXVR_LIST pList) +{ + vboxVrListJoinRectsHV(pList, true); + vboxVrListJoinRectsHV(pList, false); +} + +typedef struct VBOXVR_CBDATA_SUBST +{ + int rc; + bool fChanged; +} VBOXVR_CBDATA_SUBST; +typedef VBOXVR_CBDATA_SUBST *PVBOXVR_CBDATA_SUBST; + +static DECLCALLBACK(PRTLISTNODE) vboxVrListSubstNoJoinCb(PVBOXVR_LIST pList, PVBOXVR_REG pReg1, PCRTRECT pRect2, + void *pvContext, PRTLISTNODE *ppNext) +{ + PVBOXVR_CBDATA_SUBST pData = (PVBOXVR_CBDATA_SUBST)pvContext; + /* store the prev to get the new pNext out of it*/ + PRTLISTNODE pPrev = pReg1->ListEntry.pPrev; + pData->fChanged = true; + + Assert(VBoxRectIsIntersect(&pReg1->Rect, pRect2)); + + /* NOTE: the pReg1 will be invalid after the vboxVrListRegIntersectSubstNoJoin call!!! */ + int rc = vboxVrListRegIntersectSubstNoJoin(pList, pReg1, pRect2); + if (RT_SUCCESS(rc)) + { + *ppNext = pPrev->pNext; + return &pList->ListHead; + } + WARN(("vboxVrListRegIntersectSubstNoJoin failed!")); + Assert(!RT_SUCCESS(rc)); + pData->rc = rc; + *ppNext = &pList->ListHead; + return &pList->ListHead; +} + +static int vboxVrListSubstNoJoin(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) +{ + if (pfChanged) + *pfChanged = false; + + if (VBoxVrListIsEmpty(pList)) + return VINF_SUCCESS; + + VBOXVR_CBDATA_SUBST Data; + Data.rc = VINF_SUCCESS; + Data.fChanged = false; + + vboxVrListVisitIntersected(pList, cRects, aRects, vboxVrListSubstNoJoinCb, &Data); + if (!RT_SUCCESS(Data.rc)) + { + WARN(("vboxVrListVisitIntersected failed!")); + return Data.rc; + } + + if (pfChanged) + *pfChanged = Data.fChanged; + + return VINF_SUCCESS; +} + +#if 0 +static PCRTRECT vboxVrRectsOrder(uint32_t cRects, PCRTRECT aRects) +{ +#ifdef VBOX_STRICT + for (uint32_t i = 0; i < cRects; ++i) + { + PRTRECT pRectI = &aRects[i]; + for (uint32_t j = i + 1; j < cRects; ++j) + { + PRTRECT pRectJ = &aRects[j]; + Assert(!VBoxRectIsIntersect(pRectI, pRectJ)); + } + } +#endif + + PRTRECT pRects = (PRTRECT)aRects; + /* check if rects are ordered already */ + for (uint32_t i = 0; i < cRects - 1; ++i) + { + PRTRECT pRect1 = &pRects[i]; + PRTRECT pRect2 = &pRects[i+1]; + if (vboxVrRegNonintersectedComparator(pRect1, pRect2) < 0) + continue; + + WARN(("rects are unoreded!")); + + if (pRects == aRects) + { + pRects = (PRTRECT)RTMemAlloc(sizeof(RTRECT) * cRects); + if (!pRects) + { + WARN(("RTMemAlloc failed!")); + return NULL; + } + + memcpy(pRects, aRects, sizeof(RTRECT) * cRects); + } + + Assert(pRects != aRects); + + int j = (int)i - 1; + for (;;) + { + RTRECT Tmp = *pRect1; + *pRect1 = *pRect2; + *pRect2 = Tmp; + + if (j < 0) + break; + + if (vboxVrRegNonintersectedComparator(pRect1, pRect1-1) > 0) + break; + + pRect2 = pRect1--; + --j; + } + } + + return pRects; +} +#endif + +VBOXVREGDECL(void) VBoxVrListTranslate(PVBOXVR_LIST pList, int32_t x, int32_t y) +{ + for (PRTLISTNODE pEntry1 = pList->ListHead.pNext; pEntry1 != &pList->ListHead; pEntry1 = pEntry1->pNext) + { + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + VBoxRectTranslate(&pReg1->Rect, x, y); + } +} + +#if 0 /* unused */ + +static DECLCALLBACK(PRTLISTNODE) vboxVrListIntersectNoJoinNonintersectedCb(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, void *pvContext) +{ + VBOXVR_CBDATA_SUBST *pData = (VBOXVR_CBDATA_SUBST*)pvContext; + + PRTLISTNODE pNext = pReg1->ListEntry.pNext; + + vboxVrDbgListVerify(pList1); + + vboxVrListRegRemove(pList1, pReg1); + vboxVrRegTerm(pReg1); + + vboxVrDbgListVerify(pList1); + + pData->fChanged = true; + + return pNext; +} + +static DECLCALLBACK(PRTLISTNODE) vboxVrListIntersectNoJoinIntersectedCb(PVBOXVR_LIST pList1, PVBOXVR_REG pReg1, PCRTRECT pRect2, + void *pvContext, PPRTLISTNODE ppNext) +{ + RT_NOREF1(ppNext); + PVBOXVR_CBDATA_SUBST pData = (PVBOXVR_CBDATA_SUBST)pvContext; + pData->fChanged = true; + + vboxVrDbgListVerify(pList1); + + PRTLISTNODE pMemberEntry = pReg1->ListEntry.pNext; + + Assert(VBoxRectIsIntersect(&pReg1->Rect, pRect2)); + Assert(!VBoxRectIsZero(pRect2)); + + vboxVrListRegRemove(pList1, pReg1); + VBoxRectIntersect(&pReg1->Rect, pRect2); + Assert(!VBoxRectIsZero(&pReg1->Rect)); + + vboxVrListRegAddOrder(pList1, pMemberEntry, pReg1); + + vboxVrDbgListVerify(pList1); + + return &pReg1->ListEntry; +} + +#endif /* unused */ + +static int vboxVrListIntersectNoJoin(PVBOXVR_LIST pList, PCVBOXVR_LIST pList2, bool *pfChanged) +{ + bool fChanged = false; + if (pfChanged) + *pfChanged = false; + + if (VBoxVrListIsEmpty(pList)) + return VINF_SUCCESS; + + if (VBoxVrListIsEmpty(pList2)) + { + if (pfChanged) + *pfChanged = true; + + VBoxVrListClear(pList); + return VINF_SUCCESS; + } + + PRTLISTNODE pNext1; + + for (PRTLISTNODE pEntry1 = pList->ListHead.pNext; pEntry1 != &pList->ListHead; pEntry1 = pNext1) + { + pNext1 = pEntry1->pNext; + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + RTRECT RegRect1 = pReg1->Rect; + PRTLISTNODE pMemberEntry = pReg1->ListEntry.pNext; + + for (const RTLISTNODE *pEntry2 = pList2->ListHead.pNext; pEntry2 != &pList2->ListHead; pEntry2 = pEntry2->pNext) + { + PCVBOXVR_REG pReg2 = PVBOXVR_REG_FROM_ENTRY(pEntry2); + PCRTRECT pRect2 = &pReg2->Rect; + + if (!VBoxRectIsIntersect(&RegRect1, pRect2)) + continue; + + if (pReg1) + { + if (VBoxRectCovers(pRect2, &RegRect1)) + { + /* no change */ + + /* zero up the pReg1 to mark it as intersected (see the code after this inner loop) */ + pReg1 = NULL; + + if (!VBoxRectCmp(pRect2, &RegRect1)) + break; /* and we can break the iteration here */ + } + else + { + /*just to ensure the VBoxRectCovers is true for equal rects */ + Assert(VBoxRectCmp(pRect2, &RegRect1)); + + /** @todo this can have false-alarming sometimes if the separated rects will then be joind into the original rect, + * so far this should not be a problem for VReg clients, so keep it this way for now */ + fChanged = true; + + /* re-use the reg entry */ + vboxVrListRegRemove(pList, pReg1); + VBoxRectIntersect(&pReg1->Rect, pRect2); + Assert(!VBoxRectIsZero(&pReg1->Rect)); + + vboxVrListRegAddOrder(pList, pMemberEntry, pReg1); + pReg1 = NULL; + } + } + else + { + Assert(fChanged); /* <- should be set by the if branch above */ + PVBOXVR_REG pReg = vboxVrRegCreate(); + if (!pReg) + { + WARN(("vboxVrRegCreate failed!")); + return VERR_NO_MEMORY; + } + VBoxRectIntersected(&RegRect1, pRect2, &pReg->Rect); + Assert(!VBoxRectIsZero(&pReg->Rect)); + vboxVrListRegAddOrder(pList, pList->ListHead.pNext, pReg); + } + } + + if (pReg1) + { + /* the region has no intersections, remove it */ + vboxVrListRegRemove(pList, pReg1); + vboxVrRegTerm(pReg1); + fChanged = true; + } + } + + *pfChanged = fChanged; + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) VBoxVrListIntersect(PVBOXVR_LIST pList, PCVBOXVR_LIST pList2, bool *pfChanged) +{ + bool fChanged = false; + + int rc = vboxVrListIntersectNoJoin(pList, pList2, &fChanged); + if (pfChanged) + *pfChanged = fChanged; + + if (!RT_SUCCESS(rc)) + { + WARN(("vboxVrListSubstNoJoin failed!")); + return rc; + } + + if (fChanged) + { + vboxVrListJoinRects(pList); + } + + return rc; +} + +VBOXVREGDECL(int) VBoxVrListRectsIntersect(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) +{ + if (pfChanged) + *pfChanged = false; + + if (VBoxVrListIsEmpty(pList)) + return VINF_SUCCESS; + + if (!cRects) + { + if (pfChanged) + *pfChanged = true; + + VBoxVrListClear(pList); + return VINF_SUCCESS; + } + + /* we perform intersection using lists because the algorythm axpects the rects to be non-intersected, + * which list guaranties to us */ + + VBOXVR_LIST TmpList; + VBoxVrListInit(&TmpList); + + int rc = VBoxVrListRectsAdd(&TmpList, cRects, aRects, NULL); + if (RT_SUCCESS(rc)) + { + rc = VBoxVrListIntersect(pList, &TmpList, pfChanged); + if (!RT_SUCCESS(rc)) + { + WARN(("VBoxVrListIntersect failed! rc %d", rc)); + } + } + else + { + WARN(("VBoxVrListRectsAdd failed, rc %d", rc)); + } + VBoxVrListClear(&TmpList); + + return rc; +} + +VBOXVREGDECL(int) VBoxVrListRectsSubst(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) +{ +#if 0 + PCRTRECT pRects = vboxVrRectsOrder(cRects, aRects); + if (!pRects) + { + WARN(("vboxVrRectsOrder failed!")); + return VERR_NO_MEMORY; + } +#endif + + bool fChanged = false; + + int rc = vboxVrListSubstNoJoin(pList, cRects, aRects, &fChanged); + if (!RT_SUCCESS(rc)) + { + WARN(("vboxVrListSubstNoJoin failed!")); + goto done; + } + + if (fChanged) + goto done; + + vboxVrListJoinRects(pList); + +done: +#if 0 + if (pRects != aRects) + RTMemFree(pRects); +#endif + + if (pfChanged) + *pfChanged = fChanged; + + return rc; +} + +VBOXVREGDECL(int) VBoxVrListRectsSet(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) +{ + if (pfChanged) + *pfChanged = false; + + if (!cRects && VBoxVrListIsEmpty(pList)) + return VINF_SUCCESS; + + /** @todo fChanged will have false alarming here, fix if needed */ + VBoxVrListClear(pList); + + int rc = VBoxVrListRectsAdd(pList, cRects, aRects, NULL); + if (!RT_SUCCESS(rc)) + { + WARN(("VBoxVrListRectsSet failed rc %d", rc)); + return rc; + } + + if (pfChanged) + *pfChanged = true; + + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) VBoxVrListRectsAdd(PVBOXVR_LIST pList, uint32_t cRects, PCRTRECT aRects, bool *pfChanged) +{ + uint32_t cCovered = 0; + + if (pfChanged) + *pfChanged = false; + +#if 0 +#ifdef VBOX_STRICT + for (uint32_t i = 0; i < cRects; ++i) + { + PRTRECT pRectI = &aRects[i]; + for (uint32_t j = i + 1; j < cRects; ++j) + { + PRTRECT pRectJ = &aRects[j]; + Assert(!VBoxRectIsIntersect(pRectI, pRectJ)); + } + } +#endif +#endif + + /* early sort out the case when there are no new rects */ + for (uint32_t i = 0; i < cRects; ++i) + { + if (VBoxRectIsZero(&aRects[i])) + { + cCovered++; + continue; + } + + for (PRTLISTNODE pEntry1 = pList->ListHead.pNext; pEntry1 != &pList->ListHead; pEntry1 = pEntry1->pNext) + { + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + + if (VBoxRectCovers(&pReg1->Rect, &aRects[i])) + { + cCovered++; + break; + } + } + } + + if (cCovered == cRects) + return VINF_SUCCESS; + + /* rects are not covered, need to go the slow way */ + + VBOXVR_LIST DiffList; + VBoxVrListInit(&DiffList); + PRTRECT pListRects = NULL; + uint32_t cAllocatedRects = 0; + bool fNeedRectreate = true; + bool fChanged = false; + int rc = VINF_SUCCESS; + + for (uint32_t i = 0; i < cRects; ++i) + { + if (VBoxRectIsZero(&aRects[i])) + continue; + + PVBOXVR_REG pReg = vboxVrRegCreate(); + if (!pReg) + { + WARN(("vboxVrRegCreate failed!")); + rc = VERR_NO_MEMORY; + break; + } + pReg->Rect = aRects[i]; + + uint32_t cListRects = VBoxVrListRectsCount(pList); + if (!cListRects) + { + vboxVrListRegAdd(pList, pReg, &pList->ListHead, false); + fChanged = true; + continue; + } + Assert(VBoxVrListIsEmpty(&DiffList)); + vboxVrListRegAdd(&DiffList, pReg, &DiffList.ListHead, false); + + if (cAllocatedRects < cListRects) + { + cAllocatedRects = cListRects + cRects; + Assert(fNeedRectreate); + if (pListRects) + RTMemFree(pListRects); + pListRects = (RTRECT *)RTMemAlloc(sizeof(RTRECT) * cAllocatedRects); + if (!pListRects) + { + WARN(("RTMemAlloc failed!")); + rc = VERR_NO_MEMORY; + break; + } + } + + + if (fNeedRectreate) + { + rc = VBoxVrListRectsGet(pList, cListRects, pListRects); + Assert(rc == VINF_SUCCESS); + fNeedRectreate = false; + } + + bool fDummyChanged = false; + rc = vboxVrListSubstNoJoin(&DiffList, cListRects, pListRects, &fDummyChanged); + if (!RT_SUCCESS(rc)) + { + WARN(("vboxVrListSubstNoJoin failed!")); + rc = VERR_NO_MEMORY; + break; + } + + if (!VBoxVrListIsEmpty(&DiffList)) + { + vboxVrListAddNonintersected(pList, &DiffList); + fNeedRectreate = true; + fChanged = true; + } + + Assert(VBoxVrListIsEmpty(&DiffList)); + } + + if (pListRects) + RTMemFree(pListRects); + + Assert(VBoxVrListIsEmpty(&DiffList) || rc != VINF_SUCCESS); + VBoxVrListClear(&DiffList); + + if (fChanged) + vboxVrListJoinRects(pList); + + if (pfChanged) + *pfChanged = fChanged; + + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) VBoxVrListRectsGet(PVBOXVR_LIST pList, uint32_t cRects, RTRECT * aRects) +{ + if (cRects < VBoxVrListRectsCount(pList)) + return VERR_BUFFER_OVERFLOW; + + uint32_t i = 0; + for (PRTLISTNODE pEntry1 = pList->ListHead.pNext; pEntry1 != &pList->ListHead; pEntry1 = pEntry1->pNext, ++i) + { + PVBOXVR_REG pReg1 = PVBOXVR_REG_FROM_ENTRY(pEntry1); + aRects[i] = pReg1->Rect; + } + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) VBoxVrListCmp(const VBOXVR_LIST *pList1, const VBOXVR_LIST *pList2) +{ + int cTmp = pList1->cEntries - pList2->cEntries; + if (cTmp) + return cTmp; + + PVBOXVR_REG pReg1, pReg2; + + for (pReg1 = RTListNodeGetNext(&pList1->ListHead, VBOXVR_REG, ListEntry), + pReg2 = RTListNodeGetNext(&pList2->ListHead, VBOXVR_REG, ListEntry); + + !RTListNodeIsDummy(&pList1->ListHead, pReg1, VBOXVR_REG, ListEntry); + + pReg1 = RT_FROM_MEMBER(pReg1->ListEntry.pNext, VBOXVR_REG, ListEntry), + pReg2 = RT_FROM_MEMBER(pReg2->ListEntry.pNext, VBOXVR_REG, ListEntry) ) + { + Assert(!RTListNodeIsDummy(&pList2->ListHead, pReg2, VBOXVR_REG, ListEntry)); + cTmp = VBoxRectCmp(&pReg1->Rect, &pReg2->Rect); + if (cTmp) + return cTmp; + } + Assert(RTListNodeIsDummy(&pList2->ListHead, pReg2, VBOXVR_REG, ListEntry)); + return 0; +} + +VBOXVREGDECL(int) VBoxVrListClone(PCVBOXVR_LIST pList, PVBOXVR_LIST pDstList) +{ + VBoxVrListInit(pDstList); + PCVBOXVR_REG pReg; + RTListForEach(&pList->ListHead, pReg, const VBOXVR_REG, ListEntry) + { + PVBOXVR_REG pDstReg = vboxVrRegCreate(); + if (!pDstReg) + { + WARN(("vboxVrRegLaAlloc failed")); + VBoxVrListClear(pDstList); + return VERR_NO_MEMORY; + } + pDstReg->Rect = pReg->Rect; + vboxVrListRegAdd(pDstList, pDstReg, &pDstList->ListHead, true /*bool fAfter*/); + } + + Assert(pDstList->cEntries == pList->cEntries); + + return VINF_SUCCESS; +} + +VBOXVREGDECL(void) VBoxVrCompositorInit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_ENTRY_RELEASED pfnEntryReleased) +{ + RTListInit(&pCompositor->List); + pCompositor->pfnEntryReleased = pfnEntryReleased; +} + +VBOXVREGDECL(void) VBoxVrCompositorRegionsClear(PVBOXVR_COMPOSITOR pCompositor, bool *pfChanged) +{ + bool fChanged = false; + PVBOXVR_COMPOSITOR_ENTRY pEntry, pEntryNext; + RTListForEachSafe(&pCompositor->List, pEntry, pEntryNext, VBOXVR_COMPOSITOR_ENTRY, Node) + { + VBoxVrCompositorEntryRemove(pCompositor, pEntry); + fChanged = true; + } + + if (pfChanged) + *pfChanged = fChanged; +} + +VBOXVREGDECL(void) VBoxVrCompositorClear(PVBOXVR_COMPOSITOR pCompositor) +{ + VBoxVrCompositorRegionsClear(pCompositor, NULL); +} + +DECLINLINE(void) vboxVrCompositorEntryRelease(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) +{ + if (--pEntry->cRefs) + { + Assert(pEntry->cRefs < UINT32_MAX/2); + return; + } + + Assert(!VBoxVrCompositorEntryIsInList(pEntry)); + + if (pCompositor->pfnEntryReleased) + pCompositor->pfnEntryReleased(pCompositor, pEntry, pReplacingEntry); +} + +DECLINLINE(void) vboxVrCompositorEntryAddRef(PVBOXVR_COMPOSITOR_ENTRY pEntry) +{ + ++pEntry->cRefs; +} + +DECLINLINE(void) vboxVrCompositorEntryAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry) +{ + RTListPrepend(&pCompositor->List, &pEntry->Node); + vboxVrCompositorEntryAddRef(pEntry); +} + +DECLINLINE(void) vboxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) +{ + RTListNodeRemove(&pEntry->Node); + vboxVrCompositorEntryRelease(pCompositor, pEntry, pReplacingEntry); +} + +static void vboxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_COMPOSITOR_ENTRY pReplacingEntry) +{ + VBoxVrListMoveTo(&pEntry->Vr, &pReplacingEntry->Vr); + + pReplacingEntry->Node = pEntry->Node; + pReplacingEntry->Node.pNext->pPrev = &pReplacingEntry->Node; + pReplacingEntry->Node.pPrev->pNext = &pReplacingEntry->Node; + pEntry->Node.pNext = NULL; + pEntry->Node.pPrev = NULL; + + vboxVrCompositorEntryAddRef(pReplacingEntry); + vboxVrCompositorEntryRelease(pCompositor, pEntry, pReplacingEntry); +} + + + +VBOXVREGDECL(void) VBoxVrCompositorEntryInit(PVBOXVR_COMPOSITOR_ENTRY pEntry) +{ + VBoxVrListInit(&pEntry->Vr); + pEntry->cRefs = 0; +} + +VBOXVREGDECL(bool) VBoxVrCompositorEntryRemove(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry) +{ + if (!VBoxVrCompositorEntryIsInList(pEntry)) + return false; + + vboxVrCompositorEntryAddRef(pEntry); + + VBoxVrListClear(&pEntry->Vr); + vboxVrCompositorEntryRemove(pCompositor, pEntry, NULL); + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + return true; +} + +VBOXVREGDECL(bool) VBoxVrCompositorEntryReplace(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + PVBOXVR_COMPOSITOR_ENTRY pNewEntry) +{ + if (!VBoxVrCompositorEntryIsInList(pEntry)) + return false; + + vboxVrCompositorEntryReplace(pCompositor, pEntry, pNewEntry); + + return true; +} + +static int vboxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRects, PCRTRECT paRects, bool *pfChanged) +{ + bool fChanged; + vboxVrCompositorEntryAddRef(pEntry); + + int rc = VBoxVrListRectsSubst(&pEntry->Vr, cRects, paRects, &fChanged); + if (RT_SUCCESS(rc)) + { + if (VBoxVrListIsEmpty(&pEntry->Vr)) + { + Assert(fChanged); + vboxVrCompositorEntryRemove(pCompositor, pEntry, NULL); + } + if (pfChanged) + *pfChanged = false; + } + else + WARN(("VBoxVrListRectsSubst failed, rc %d", rc)); + + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + return rc; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsAdd(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRects, PCRTRECT paRects, PVBOXVR_COMPOSITOR_ENTRY *ppReplacedEntry, + uint32_t *pfChangeFlags) +{ + bool fOthersChanged = false; + bool fCurChanged = false; + bool fEntryChanged = false; + bool fEntryWasInList = false; + PVBOXVR_COMPOSITOR_ENTRY pCur; + PVBOXVR_COMPOSITOR_ENTRY pNext; + PVBOXVR_COMPOSITOR_ENTRY pReplacedEntry = NULL; + int rc = VINF_SUCCESS; + + if (pEntry) + vboxVrCompositorEntryAddRef(pEntry); + + if (!cRects) + { + if (pfChangeFlags) + *pfChangeFlags = 0; + if (pEntry) + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + return VINF_SUCCESS; + } + + if (pEntry) + { + fEntryWasInList = VBoxVrCompositorEntryIsInList(pEntry); + rc = VBoxVrListRectsAdd(&pEntry->Vr, cRects, paRects, &fEntryChanged); + if (RT_SUCCESS(rc)) + { + if (VBoxVrListIsEmpty(&pEntry->Vr)) + { +// WARN(("Empty rectangles passed in, is it expected?")); + if (pfChangeFlags) + *pfChangeFlags = 0; + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + return VINF_SUCCESS; + } + } + else + { + WARN(("VBoxVrListRectsAdd failed, rc %d", rc)); + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + return rc; + } + + Assert(!VBoxVrListIsEmpty(&pEntry->Vr)); + } + else + { + fEntryChanged = true; + } + + RTListForEachSafe(&pCompositor->List, pCur, pNext, VBOXVR_COMPOSITOR_ENTRY, Node) + { + Assert(!VBoxVrListIsEmpty(&pCur->Vr)); + if (pCur != pEntry) + { + if (pEntry && !VBoxVrListCmp(&pCur->Vr, &pEntry->Vr)) + { + VBoxVrListClear(&pCur->Vr); + pReplacedEntry = pCur; + vboxVrCompositorEntryAddRef(pReplacedEntry); + vboxVrCompositorEntryRemove(pCompositor, pCur, pEntry); + if (ppReplacedEntry) + *ppReplacedEntry = pReplacedEntry; + break; + } + + rc = vboxVrCompositorEntryRegionsSubst(pCompositor, pCur, cRects, paRects, &fCurChanged); + if (RT_SUCCESS(rc)) + fOthersChanged |= fCurChanged; + else + { + WARN(("vboxVrCompositorEntryRegionsSubst failed, rc %d", rc)); + return rc; + } + } + } + + AssertRC(rc); + + if (pEntry) + { + if (!fEntryWasInList) + { + Assert(!VBoxVrListIsEmpty(&pEntry->Vr)); + vboxVrCompositorEntryAdd(pCompositor, pEntry); + } + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + } + + uint32_t fFlags = 0; + if (fOthersChanged) + { + Assert(!pReplacedEntry); + fFlags = VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED + | VBOXVR_COMPOSITOR_CF_OTHER_ENTRIES_REGIONS_CHANGED; + } + else if (pReplacedEntry) + { + vboxVrCompositorEntryRelease(pCompositor, pReplacedEntry, pEntry); + Assert(fEntryChanged); + fFlags = VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_ENTRY_REPLACED; + } + else if (fEntryChanged) + { + Assert(!pReplacedEntry); + fFlags = VBOXVR_COMPOSITOR_CF_ENTRY_REGIONS_CHANGED | VBOXVR_COMPOSITOR_CF_REGIONS_CHANGED; + } + else + { + Assert(!pReplacedEntry); + } + + if (!fEntryWasInList) + Assert(fEntryChanged); + + if (pfChangeFlags) + *pfChangeFlags = fFlags; + + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSubst(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRects, PCRTRECT paRects, bool *pfChanged) +{ + if (!pEntry) + { + WARN(("VBoxVrCompositorEntryRegionsSubst called with zero entry, unsupported!")); + if (pfChanged) + *pfChanged = false; + return VERR_INVALID_PARAMETER; + } + + vboxVrCompositorEntryAddRef(pEntry); + + if (VBoxVrListIsEmpty(&pEntry->Vr)) + { + if (pfChanged) + *pfChanged = false; + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + return VINF_SUCCESS; + } + + int rc = vboxVrCompositorEntryRegionsSubst(pCompositor, pEntry, cRects, paRects, pfChanged); + if (!RT_SUCCESS(rc)) + WARN(("pfChanged failed, rc %d", rc)); + + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + + return rc; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsSet(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRects, PCRTRECT paRects, bool *pfChanged) +{ + if (!pEntry) + { + WARN(("VBoxVrCompositorEntryRegionsSet called with zero entry, unsupported!")); + if (pfChanged) + *pfChanged = false; + return VERR_INVALID_PARAMETER; + } + + vboxVrCompositorEntryAddRef(pEntry); + + bool fChanged = false, fCurChanged = false; + uint32_t fChangeFlags = 0; + int rc; + fCurChanged = VBoxVrCompositorEntryRemove(pCompositor, pEntry); + fChanged |= fCurChanged; + + rc = VBoxVrCompositorEntryRegionsAdd(pCompositor, pEntry, cRects, paRects, NULL, &fChangeFlags); + if (RT_SUCCESS(rc)) + { + fChanged |= !!fChangeFlags; + if (pfChanged) + *pfChanged = fChanged; + } + else + WARN(("VBoxVrCompositorEntryRegionsAdd failed, rc %d", rc)); + + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + + return VINF_SUCCESS; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + PCVBOXVR_LIST pList2, bool *pfChanged) +{ + int rc = VINF_SUCCESS; + bool fChanged = false; + + vboxVrCompositorEntryAddRef(pEntry); + + if (VBoxVrCompositorEntryIsInList(pEntry)) + { + rc = VBoxVrListIntersect(&pEntry->Vr, pList2, &fChanged); + if (RT_SUCCESS(rc)) + { + if (VBoxVrListIsEmpty(&pEntry->Vr)) + { + Assert(fChanged); + vboxVrCompositorEntryRemove(pCompositor, pEntry, NULL); + } + } + else + { + WARN(("VBoxVrListRectsIntersect failed, rc %d", rc)); + } + } + + if (pfChanged) + *pfChanged = fChanged; + + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + + return rc; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersect(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + uint32_t cRects, PCRTRECT paRects, bool *pfChanged) +{ + int rc = VINF_SUCCESS; + bool fChanged = false; + + vboxVrCompositorEntryAddRef(pEntry); + + if (VBoxVrCompositorEntryIsInList(pEntry)) + { + rc = VBoxVrListRectsIntersect(&pEntry->Vr, cRects, paRects, &fChanged); + if (RT_SUCCESS(rc)) + { + if (VBoxVrListIsEmpty(&pEntry->Vr)) + { + Assert(fChanged); + vboxVrCompositorEntryRemove(pCompositor, pEntry, NULL); + } + } + else + { + WARN(("VBoxVrListRectsIntersect failed, rc %d", rc)); + } + } + + if (pfChanged) + *pfChanged = fChanged; + + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + + return rc; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryListIntersectAll(PVBOXVR_COMPOSITOR pCompositor, PCVBOXVR_LIST pList2, bool *pfChanged) +{ + VBOXVR_COMPOSITOR_ITERATOR Iter; + VBoxVrCompositorIterInit(pCompositor, &Iter); + PVBOXVR_COMPOSITOR_ENTRY pEntry; + int rc = VINF_SUCCESS; + bool fChanged = false; + + while ((pEntry = VBoxVrCompositorIterNext(&Iter)) != NULL) + { + bool fTmpChanged = false; + int tmpRc = VBoxVrCompositorEntryListIntersect(pCompositor, pEntry, pList2, &fTmpChanged); + if (RT_SUCCESS(tmpRc)) + fChanged |= fTmpChanged; + else + { + WARN(("VBoxVrCompositorEntryRegionsIntersect failed, rc %d", tmpRc)); + rc = tmpRc; + } + } + + if (pfChanged) + *pfChanged = fChanged; + + return rc; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsIntersectAll(PVBOXVR_COMPOSITOR pCompositor, uint32_t cRegions, PCRTRECT paRegions, + bool *pfChanged) +{ + VBOXVR_COMPOSITOR_ITERATOR Iter; + VBoxVrCompositorIterInit(pCompositor, &Iter); + PVBOXVR_COMPOSITOR_ENTRY pEntry; + int rc = VINF_SUCCESS; + bool fChanged = false; + + while ((pEntry = VBoxVrCompositorIterNext(&Iter)) != NULL) + { + bool fTmpChanged = false; + int tmpRc = VBoxVrCompositorEntryRegionsIntersect(pCompositor, pEntry, cRegions, paRegions, &fTmpChanged); + if (RT_SUCCESS(tmpRc)) + fChanged |= fTmpChanged; + else + { + WARN(("VBoxVrCompositorEntryRegionsIntersect failed, rc %d", tmpRc)); + rc = tmpRc; + } + } + + if (pfChanged) + *pfChanged = fChanged; + + return rc; +} + +VBOXVREGDECL(int) VBoxVrCompositorEntryRegionsTranslate(PVBOXVR_COMPOSITOR pCompositor, PVBOXVR_COMPOSITOR_ENTRY pEntry, + int32_t x, int32_t y, bool *pfChanged) +{ + if (!pEntry) + { + WARN(("VBoxVrCompositorEntryRegionsTranslate called with zero entry, unsupported!")); + if (pfChanged) + *pfChanged = false; + return VERR_INVALID_PARAMETER; + } + + vboxVrCompositorEntryAddRef(pEntry); + + if ( (!x && !y) + || !VBoxVrCompositorEntryIsInList(pEntry)) + { + if (pfChanged) + *pfChanged = false; + + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + return VINF_SUCCESS; + } + + VBoxVrListTranslate(&pEntry->Vr, x, y); + + Assert(!VBoxVrListIsEmpty(&pEntry->Vr)); + + PVBOXVR_COMPOSITOR_ENTRY pCur; + uint32_t cRects = 0; + PRTRECT paRects = NULL; + int rc = VINF_SUCCESS; + RTListForEach(&pCompositor->List, pCur, VBOXVR_COMPOSITOR_ENTRY, Node) + { + Assert(!VBoxVrListIsEmpty(&pCur->Vr)); + + if (pCur == pEntry) + continue; + + if (!paRects) + { + cRects = VBoxVrListRectsCount(&pEntry->Vr); + Assert(cRects); + paRects = (RTRECT*)RTMemAlloc(cRects * sizeof(RTRECT)); + if (!paRects) + { + WARN(("RTMemAlloc failed!")); + rc = VERR_NO_MEMORY; + break; + } + + rc = VBoxVrListRectsGet(&pEntry->Vr, cRects, paRects); + if (!RT_SUCCESS(rc)) + { + WARN(("VBoxVrListRectsGet failed! rc %d", rc)); + break; + } + } + + rc = vboxVrCompositorEntryRegionsSubst(pCompositor, pCur, cRects, paRects, NULL); + if (!RT_SUCCESS(rc)) + { + WARN(("vboxVrCompositorEntryRegionsSubst failed! rc %d", rc)); + break; + } + } + + if (pfChanged) + *pfChanged = true; + + if (paRects) + RTMemFree(paRects); + + vboxVrCompositorEntryRelease(pCompositor, pEntry, NULL); + + return rc; +} + +VBOXVREGDECL(void) VBoxVrCompositorVisit(PVBOXVR_COMPOSITOR pCompositor, PFNVBOXVRCOMPOSITOR_VISITOR pfnVisitor, void *pvVisitor) +{ + PVBOXVR_COMPOSITOR_ENTRY pEntry, pEntryNext; + RTListForEachSafe(&pCompositor->List, pEntry, pEntryNext, VBOXVR_COMPOSITOR_ENTRY, Node) + { + if (!pfnVisitor(pCompositor, pEntry, pvVisitor)) + return; + } +} + diff --git a/src/VBox/GuestHost/OpenGL/util/warp.c b/src/VBox/GuestHost/OpenGL/util/warp.c new file mode 100644 index 00000000..0e008db9 --- /dev/null +++ b/src/VBox/GuestHost/OpenGL/util/warp.c @@ -0,0 +1,24 @@ +/* Copyright (c) 2001, Stanford University + * All rights reserved + * + * See the file LICENSE.txt for information on redistributing this software. + */ + +#include "cr_error.h" +#include "cr_warp.h" + +void +crWarpPoint(const float *align, const float *point, float *result) +{ + float w, x, y; + + x = align[0] * point[0] + align[1] * point[1] + align[2]; + y = align[3] * point[0] + align[4] * point[1] + align[5]; + w = align[6] * point[0] + align[7] * point[1] + align[8]; + + if (w == 0) + crError("Crud in alignment matrix --> w == 0. bleh!"); + + result[0] = x / w; + result[1] = y / w; +} -- cgit v1.2.3