aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--X11/extensions/randrproto.txt8
-rw-r--r--fontconfig/doc/fontconfig-devel.sgml2
-rw-r--r--fontconfig/doc/fontconfig-user.sgml2
-rw-r--r--fontconfig/fc-query/fc-query.c28
-rw-r--r--fontconfig/fc-query/fc-query.sgml12
-rw-r--r--fontconfig/fc-scan/fc-scan.c28
-rw-r--r--fontconfig/fc-scan/fc-scan.sgml14
-rw-r--r--fontconfig/fontconfig/fontconfig.h2
-rw-r--r--libfontenc/configure.ac2
-rw-r--r--libxcb/man/xcb-requests.man6
-rw-r--r--libxcb/src/xcb.h20
-rw-r--r--libxcb/src/xcb_in.c45
-rw-r--r--libxcb/src/xcb_out.c8
-rw-r--r--libxcb/src/xcbext.h54
-rw-r--r--mesalib/docs/GL3.txt22
-rw-r--r--mesalib/docs/egl.html8
-rw-r--r--mesalib/docs/envvars.html1
-rw-r--r--mesalib/docs/index.html6
-rw-r--r--mesalib/docs/relnotes.html1
-rw-r--r--mesalib/docs/relnotes/10.5.5.html95
-rw-r--r--mesalib/docs/relnotes/10.6.0.html9
-rw-r--r--mesalib/docs/specs/MESA_image_dma_buf_export.txt25
-rw-r--r--mesalib/include/EGL/eglmesaext.h66
-rw-r--r--mesalib/src/gallium/auxiliary/Makefile.sources1
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_driver_query.c5
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_private.h2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c1
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_flush.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_debug_memory.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_dirty_surfaces.h2
-rw-r--r--mesalib/src/glsl/Makefile.sources1
-rw-r--r--mesalib/src/glsl/ast_to_hir.cpp40
-rw-r--r--mesalib/src/glsl/ast_type.cpp10
-rw-r--r--mesalib/src/glsl/builtin_functions.cpp130
-rw-r--r--mesalib/src/glsl/builtin_types.cpp2
-rw-r--r--mesalib/src/glsl/builtin_variables.cpp37
-rw-r--r--mesalib/src/glsl/glcpp/glcpp-parse.y3
-rw-r--r--mesalib/src/glsl/glsl_lexer.ll2
-rw-r--r--mesalib/src/glsl/glsl_parser.yy36
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp24
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h42
-rw-r--r--mesalib/src/glsl/ir_set_program_inouts.cpp16
-rw-r--r--mesalib/src/glsl/link_uniform_blocks.cpp8
-rw-r--r--mesalib/src/glsl/link_uniforms.cpp6
-rw-r--r--mesalib/src/glsl/linker.cpp50
-rw-r--r--mesalib/src/glsl/nir/glsl_to_nir.cpp136
-rw-r--r--mesalib/src/glsl/nir/nir.c226
-rw-r--r--mesalib/src/glsl/nir/nir.h58
-rw-r--r--mesalib/src/glsl/nir/nir_builder.h6
-rw-r--r--mesalib/src/glsl/nir/nir_from_ssa.c150
-rw-r--r--mesalib/src/glsl/nir/nir_intrinsics.h34
-rw-r--r--mesalib/src/glsl/nir/nir_lower_atomics.c3
-rw-r--r--mesalib/src/glsl/nir/nir_lower_locals_to_regs.c14
-rw-r--r--mesalib/src/glsl/nir/nir_lower_samplers.cpp61
-rw-r--r--mesalib/src/glsl/nir/nir_lower_tex_projector.c12
-rw-r--r--mesalib/src/glsl/nir/nir_lower_to_source_mods.c20
-rw-r--r--mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c3
-rw-r--r--mesalib/src/glsl/nir/nir_opcodes.py2
-rw-r--r--mesalib/src/glsl/nir/nir_opt_algebraic.py27
-rw-r--r--mesalib/src/glsl/nir/nir_opt_copy_propagate.c71
-rw-r--r--mesalib/src/glsl/nir/nir_opt_gcm.c14
-rw-r--r--mesalib/src/glsl/nir/nir_opt_global_to_local.c13
-rw-r--r--mesalib/src/glsl/nir/nir_opt_peephole_ffma.c9
-rw-r--r--mesalib/src/glsl/nir/nir_opt_peephole_select.c10
-rw-r--r--mesalib/src/glsl/nir/nir_search.c31
-rw-r--r--mesalib/src/glsl/nir/nir_to_ssa.c19
-rw-r--r--mesalib/src/glsl/nir/nir_validate.c160
-rw-r--r--mesalib/src/glsl/opt_dead_builtin_varyings.cpp10
-rw-r--r--mesalib/src/hgl/GLDispatcher.cpp5
-rw-r--r--mesalib/src/hgl/GLDispatcher.h4
-rw-r--r--mesalib/src/hgl/SConscript1
-rw-r--r--mesalib/src/loader/loader.h9
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml225
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml2
-rw-r--r--mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml70
-rw-r--r--mesalib/src/mapi/glapi/gen/Makefile.am1
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_API.xml4
-rw-r--r--mesalib/src/mapi/glapi/gen/gl_genexec.py4
-rw-r--r--mesalib/src/mapi/glapi/glapi_priv.h8
-rw-r--r--mesalib/src/mesa/Makefile.sources2
-rw-r--r--mesalib/src/mesa/drivers/common/driverfuncs.c2
-rw-r--r--mesalib/src/mesa/drivers/common/meta.c3
-rw-r--r--mesalib/src/mesa/drivers/dri/swrast/swrast.c17
-rw-r--r--mesalib/src/mesa/main/api_arrayelt.c79
-rw-r--r--mesalib/src/mesa/main/api_loopback.c60
-rw-r--r--mesalib/src/mesa/main/api_loopback.h16
-rw-r--r--mesalib/src/mesa/main/arrayobj.c192
-rw-r--r--mesalib/src/mesa/main/arrayobj.h9
-rw-r--r--mesalib/src/mesa/main/blend.c37
-rw-r--r--mesalib/src/mesa/main/blend.h16
-rw-r--r--mesalib/src/mesa/main/blit.c219
-rw-r--r--mesalib/src/mesa/main/blit.h13
-rw-r--r--mesalib/src/mesa/main/bufferobj.c105
-rw-r--r--mesalib/src/mesa/main/buffers.c261
-rw-r--r--mesalib/src/mesa/main/buffers.h29
-rw-r--r--mesalib/src/mesa/main/clear.c106
-rw-r--r--mesalib/src/mesa/main/clear.h16
-rw-r--r--mesalib/src/mesa/main/compute.c20
-rw-r--r--mesalib/src/mesa/main/context.c7
-rw-r--r--mesalib/src/mesa/main/context.h20
-rw-r--r--mesalib/src/mesa/main/dd.h20
-rw-r--r--mesalib/src/mesa/main/extensions.c3
-rw-r--r--mesalib/src/mesa/main/fbobject.c1308
-rw-r--r--mesalib/src/mesa/main/fbobject.h81
-rw-r--r--mesalib/src/mesa/main/ffvertex_prog.c2
-rw-r--r--mesalib/src/mesa/main/framebuffer.c23
-rw-r--r--mesalib/src/mesa/main/framebuffer.h7
-rw-r--r--mesalib/src/mesa/main/genmipmap.c7
-rw-r--r--mesalib/src/mesa/main/get.c9
-rw-r--r--mesalib/src/mesa/main/mtypes.h17
-rw-r--r--mesalib/src/mesa/main/pipelineobj.c6
-rw-r--r--mesalib/src/mesa/main/queryobj.c19
-rw-r--r--mesalib/src/mesa/main/readpix.c4
-rw-r--r--mesalib/src/mesa/main/samplerobj.c7
-rw-r--r--mesalib/src/mesa/main/shader_query.cpp24
-rw-r--r--mesalib/src/mesa/main/shaderimage.c130
-rw-r--r--mesalib/src/mesa/main/shaderimage.h21
-rw-r--r--mesalib/src/mesa/main/state.c25
-rw-r--r--mesalib/src/mesa/main/texenv.c2
-rw-r--r--mesalib/src/mesa/main/texgetimage.c14
-rw-r--r--mesalib/src/mesa/main/teximage.c74
-rw-r--r--mesalib/src/mesa/main/texobj.c14
-rw-r--r--mesalib/src/mesa/main/texparam.c86
-rw-r--r--mesalib/src/mesa/main/texstorage.c7
-rw-r--r--mesalib/src/mesa/main/transformfeedback.c42
-rw-r--r--mesalib/src/mesa/main/uniform_query.cpp4
-rw-r--r--mesalib/src/mesa/main/varray.c857
-rw-r--r--mesalib/src/mesa/main/varray.h55
-rw-r--r--mesalib/src/mesa/main/version.c332
-rw-r--r--mesalib/src/mesa/main/vtxfmt.c12
-rw-r--r--mesalib/src/mesa/program/prog_statevars.c4
-rw-r--r--mesalib/src/mesa/program/prog_to_nir.c2
-rw-r--r--mesalib/src/mesa/program/program.c3
-rw-r--r--mesalib/src/mesa/program/program.h22
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_array.c172
-rw-r--r--mesalib/src/mesa/state_tracker/st_atom_framebuffer.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_flush.c35
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_flush.h3
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_perfmon.c425
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_perfmon.h64
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c16
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.h3
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_format.c2
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp30
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c4
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.h1
-rw-r--r--mesalib/src/mesa/swrast/s_drawpix.c29
-rw-r--r--mesalib/src/mesa/swrast/s_texrender.c2
-rw-r--r--mesalib/src/mesa/vbo/vbo_attrib_tmp.h119
-rw-r--r--mesalib/src/mesa/vbo/vbo_context.h17
-rw-r--r--mesalib/src/mesa/vbo/vbo_exec_api.c83
-rw-r--r--mesalib/src/mesa/vbo/vbo_save_api.c14
-rw-r--r--mesalib/src/mesa/vbo/vbo_split_copy.c1
-rw-r--r--mesalib/src/util/Makefile.sources1
-rw-r--r--mesalib/src/util/list.h (renamed from mesalib/src/gallium/auxiliary/util/u_double_list.h)93
-rw-r--r--pixman/.gitignore45
-rw-r--r--pixman/pixman/pixman-mips-dspr2-asm.h2
-rw-r--r--pixman/test/Makefile.sources1
-rw-r--r--pixman/test/solid-test.c350
-rw-r--r--xorg-server/Xext/hashtable.c4
-rw-r--r--xorg-server/Xext/panoramiX.c10
-rw-r--r--xorg-server/Xext/panoramiXprocs.c21
-rw-r--r--xorg-server/Xext/saver.c2
-rw-r--r--xorg-server/Xext/shape.c2
-rw-r--r--xorg-server/Xext/shm.c10
-rw-r--r--xorg-server/Xext/sync.c4
-rw-r--r--xorg-server/Xext/xcmisc.c2
-rw-r--r--xorg-server/Xext/xf86bigfont.c4
-rw-r--r--xorg-server/Xext/xres.c2
-rw-r--r--xorg-server/Xext/xselinux_label.c2
-rw-r--r--xorg-server/Xext/xvmain.c2
-rw-r--r--xorg-server/Xi/exevents.c6
-rw-r--r--xorg-server/Xi/getprop.c2
-rw-r--r--xorg-server/Xi/xiproperty.c8
-rw-r--r--xorg-server/Xi/xiquerypointer.c4
-rw-r--r--xorg-server/composite/compinit.c8
-rw-r--r--xorg-server/config/config.c3
-rw-r--r--xorg-server/configure.ac29
-rw-r--r--xorg-server/dbe/dbe.c14
-rw-r--r--xorg-server/dbe/midbe.c2
-rw-r--r--xorg-server/dix/atom.c4
-rw-r--r--xorg-server/dix/colormap.c71
-rw-r--r--xorg-server/dix/devices.c7
-rw-r--r--xorg-server/dix/dispatch.c10
-rw-r--r--xorg-server/dix/dixfonts.c18
-rw-r--r--xorg-server/dix/enterleave.c2
-rw-r--r--xorg-server/dix/events.c5
-rw-r--r--xorg-server/dix/extension.c6
-rw-r--r--xorg-server/dix/glyphcurs.c4
-rw-r--r--xorg-server/dix/grabs.c8
-rw-r--r--xorg-server/dix/property.c10
-rw-r--r--xorg-server/dix/region.c2
-rw-r--r--xorg-server/dix/resource.c6
-rw-r--r--xorg-server/dix/touch.c8
-rw-r--r--xorg-server/doc/Xserver-spec.xml9
-rw-r--r--xorg-server/exa/exa_accel.c8
-rw-r--r--xorg-server/exa/exa_glyphs.c4
-rw-r--r--xorg-server/exa/exa_migration_mixed.c4
-rw-r--r--xorg-server/fb/fbcopy.c2
-rw-r--r--xorg-server/fb/fbpict.c2
-rw-r--r--xorg-server/glamor/Makefile.am2
-rw-r--r--xorg-server/glamor/glamor.c71
-rw-r--r--xorg-server/glamor/glamor.h2
-rw-r--r--xorg-server/glamor/glamor_composite_glyphs.c551
-rw-r--r--xorg-server/glamor/glamor_compositerects.c2
-rw-r--r--xorg-server/glamor/glamor_copy.c15
-rw-r--r--xorg-server/glamor/glamor_core.c2
-rw-r--r--xorg-server/glamor/glamor_dash.c2
-rw-r--r--xorg-server/glamor/glamor_egl.c6
-rw-r--r--xorg-server/glamor/glamor_glyphs.c1769
-rw-r--r--xorg-server/glamor/glamor_gradient.c8
-rw-r--r--xorg-server/glamor/glamor_image.c4
-rw-r--r--xorg-server/glamor/glamor_pixmap.c8
-rw-r--r--xorg-server/glamor/glamor_points.c3
-rw-r--r--xorg-server/glamor/glamor_prepare.c4
-rw-r--r--xorg-server/glamor/glamor_priv.h88
-rw-r--r--xorg-server/glamor/glamor_program.c281
-rw-r--r--xorg-server/glamor/glamor_program.h63
-rw-r--r--xorg-server/glamor/glamor_render.c136
-rw-r--r--xorg-server/glamor/glamor_spans.c2
-rw-r--r--xorg-server/glamor/glamor_text.c4
-rw-r--r--xorg-server/glamor/glamor_transform.c34
-rw-r--r--xorg-server/glamor/glamor_transform.h6
-rw-r--r--xorg-server/glamor/glamor_utils.c2
-rw-r--r--xorg-server/glx/single2.c9
-rw-r--r--xorg-server/glx/single2swap.c9
-rw-r--r--xorg-server/hw/dmx/config/dmxconfig.c10
-rw-r--r--xorg-server/hw/dmx/dmx.c10
-rw-r--r--xorg-server/hw/dmx/dmxcmap.c2
-rw-r--r--xorg-server/hw/dmx/dmxcursor.c2
-rw-r--r--xorg-server/hw/dmx/dmxextension.c4
-rw-r--r--xorg-server/hw/dmx/dmxfont.c6
-rw-r--r--xorg-server/hw/dmx/dmxgc.c2
-rw-r--r--xorg-server/hw/dmx/dmxinit.c4
-rw-r--r--xorg-server/hw/dmx/dmxpict.c10
-rw-r--r--xorg-server/hw/dmx/dmxprop.c2
-rw-r--r--xorg-server/hw/dmx/dmxwindow.c4
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxcmds.c34
-rw-r--r--xorg-server/hw/dmx/glxProxy/glxscreens.c9
-rw-r--r--xorg-server/hw/dmx/input/dmxarg.c2
-rw-r--r--xorg-server/hw/dmx/input/dmxinputinit.c4
-rw-r--r--xorg-server/hw/dmx/input/dmxmotion.c5
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrdriext.c4
-rw-r--r--xorg-server/hw/kdrive/ephyr/ephyrinit.c11
-rw-r--r--xorg-server/hw/kdrive/ephyr/hostx.c30
-rw-r--r--xorg-server/hw/kdrive/fake/Makefile.am1
-rw-r--r--xorg-server/hw/kdrive/fake/fake.c2
-rw-r--r--xorg-server/hw/kdrive/fbdev/Makefile.am1
-rw-r--r--xorg-server/hw/kdrive/fbdev/fbdev.c2
-rw-r--r--xorg-server/hw/kdrive/src/kshadow.c2
-rw-r--r--xorg-server/hw/kdrive/src/kxv.c4
-rw-r--r--xorg-server/hw/vfb/InitOutput.c8
-rw-r--r--xorg-server/hw/xfree86/common/xf86AutoConfig.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86Bus.c23
-rw-r--r--xorg-server/hw/xfree86/common/xf86Config.c82
-rw-r--r--xorg-server/hw/xfree86/common/xf86Configure.c6
-rw-r--r--xorg-server/hw/xfree86/common/xf86DGA.c2
-rw-r--r--xorg-server/hw/xfree86/common/xf86Helper.c45
-rw-r--r--xorg-server/hw/xfree86/common/xf86Xinput.c5
-rw-r--r--xorg-server/hw/xfree86/common/xf86cmap.c6
-rw-r--r--xorg-server/hw/xfree86/common/xf86fbman.c11
-rw-r--r--xorg-server/hw/xfree86/common/xf86pciBus.c10
-rw-r--r--xorg-server/hw/xfree86/common/xf86platformBus.c6
-rw-r--r--xorg-server/hw/xfree86/common/xf86sbusBus.c10
-rw-r--r--xorg-server/hw/xfree86/common/xf86str.h10
-rw-r--r--xorg-server/hw/xfree86/common/xf86vmode.c8
-rw-r--r--xorg-server/hw/xfree86/common/xf86xv.c10
-rw-r--r--xorg-server/hw/xfree86/common/xf86xvmc.c2
-rw-r--r--xorg-server/hw/xfree86/ddc/ddc.c2
-rw-r--r--xorg-server/hw/xfree86/dri/xf86dri.c2
-rw-r--r--xorg-server/hw/xfree86/dri2/dri2.c4
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/driver.c2
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c291
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h2
-rw-r--r--xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c4
-rw-r--r--xorg-server/hw/xfree86/i2c/xf86i2c.c2
-rw-r--r--xorg-server/hw/xfree86/loader/loadmod.c10
-rw-r--r--xorg-server/hw/xfree86/man/xorg.conf.man13
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.c158
-rw-r--r--xorg-server/hw/xfree86/modes/xf86Crtc.h2
-rw-r--r--xorg-server/hw/xfree86/modes/xf86DiDGA.c2
-rw-r--r--xorg-server/hw/xfree86/modes/xf86RandR12.c86
-rw-r--r--xorg-server/hw/xfree86/os-support/bus/Sbus.c2
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/Makefile.am3
-rw-r--r--xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar806
-rw-r--r--xorg-server/hw/xfree86/parser/Configint.h2
-rw-r--r--xorg-server/hw/xfree86/parser/Screen.c22
-rw-r--r--xorg-server/hw/xfree86/parser/xf86Parser.h5
-rw-r--r--xorg-server/hw/xfree86/parser/xf86tokens.h1
-rw-r--r--xorg-server/hw/xfree86/utils/cvt/cvt.c4
-rw-r--r--xorg-server/hw/xfree86/vbe/vbe.c4
-rw-r--r--xorg-server/hw/xnest/Color.c17
-rw-r--r--xorg-server/hw/xnest/Display.c4
-rw-r--r--xorg-server/hw/xnest/GC.c5
-rw-r--r--xorg-server/hw/xnest/Keyboard.c6
-rw-r--r--xorg-server/hw/xnest/Screen.c4
-rw-r--r--xorg-server/hw/xwayland/xwayland-glamor.c4
-rw-r--r--xorg-server/hw/xwayland/xwayland-input.c55
-rw-r--r--xorg-server/hw/xwayland/xwayland-output.c4
-rw-r--r--xorg-server/hw/xwayland/xwayland.h4
-rw-r--r--xorg-server/hw/xwin/winclipboard/Makefile.am2
-rw-r--r--xorg-server/include/dix-config.h.in12
-rw-r--r--xorg-server/include/os.h31
-rw-r--r--xorg-server/include/servermd.h2
-rw-r--r--xorg-server/include/xorg-server.h.in3
-rw-r--r--xorg-server/m4/xorg-tls.m455
-rw-r--r--xorg-server/mi/miarc.c25
-rw-r--r--xorg-server/mi/mibitblt.c16
-rw-r--r--xorg-server/mi/micmap.c8
-rw-r--r--xorg-server/mi/micopy.c4
-rw-r--r--xorg-server/mi/miexpose.c2
-rw-r--r--xorg-server/mi/mifillrct.c4
-rw-r--r--xorg-server/mi/miglblt.c2
-rw-r--r--xorg-server/mi/miinitext.c4
-rw-r--r--xorg-server/mi/mipoly.c4
-rw-r--r--xorg-server/mi/mipolypnt.c2
-rw-r--r--xorg-server/mi/mipolyrect.c2
-rw-r--r--xorg-server/mi/miwideline.c42
-rw-r--r--xorg-server/mi/miwindow.c6
-rw-r--r--xorg-server/mi/mizerarc.c4
-rw-r--r--xorg-server/mi/mizerline.c4
-rw-r--r--xorg-server/miext/damage/damage.c2
-rw-r--r--xorg-server/miext/rootless/rootlessWindow.c4
-rw-r--r--xorg-server/miext/shadow/shalloc.c2
-rw-r--r--xorg-server/os/connection.c13
-rw-r--r--xorg-server/os/reallocarray.c43
-rw-r--r--xorg-server/os/utils.c28
-rw-r--r--xorg-server/os/xdmcp.c4
-rw-r--r--xorg-server/pseudoramiX/pseudoramiX.c6
-rw-r--r--xorg-server/randr/randrstr.h9
-rw-r--r--xorg-server/randr/rrcrtc.c56
-rw-r--r--xorg-server/randr/rrinfo.c10
-rw-r--r--xorg-server/randr/rrmode.c4
-rw-r--r--xorg-server/randr/rrmonitor.c11
-rw-r--r--xorg-server/randr/rroutput.c14
-rw-r--r--xorg-server/randr/rrproperty.c12
-rw-r--r--xorg-server/randr/rrproviderproperty.c6
-rw-r--r--xorg-server/randr/rrscreen.c7
-rw-r--r--xorg-server/randr/rrtransform.c2
-rw-r--r--xorg-server/record/record.c35
-rw-r--r--xorg-server/record/set.c4
-rw-r--r--xorg-server/render/filter.c12
-rw-r--r--xorg-server/render/miindex.c2
-rw-r--r--xorg-server/render/mipict.c4
-rw-r--r--xorg-server/render/picture.c2
-rw-r--r--xorg-server/render/render.c6
-rw-r--r--xorg-server/xfixes/region.c2
-rw-r--r--xorg-server/xkb/XKBAlloc.c14
-rw-r--r--xorg-server/xkb/XKBGAlloc.c2
-rw-r--r--xorg-server/xkb/XKBMAlloc.c47
-rw-r--r--xorg-server/xkb/maprules.c12
-rw-r--r--xorg-server/xkb/xkb.c32
-rw-r--r--xorg-server/xkb/xkbActions.c4
-rw-r--r--xorg-server/xkb/xkbUtils.c76
-rw-r--r--xorg-server/xkb/xkmread.c2
-rw-r--r--xorg-server/xkeyboard-config/rules/base.xml.in7
-rw-r--r--xorg-server/xkeyboard-config/symbols/eu1
-rw-r--r--xorg-server/xkeyboard-config/symbols/lk94
361 files changed, 8933 insertions, 5565 deletions
diff --git a/X11/extensions/randrproto.txt b/X11/extensions/randrproto.txt
index 74b7c366d..416f0017e 100644
--- a/X11/extensions/randrproto.txt
+++ b/X11/extensions/randrproto.txt
@@ -186,6 +186,14 @@ consider as single viewable areas.
Xinerama's information now comes from the Monitors instead of directly
from the CRTCs. The Monitor marked as Primary will be listed first.
+1.5.2. Clarification of Output lifetimes
+
+With dynamic connectors being a possibility with the introduction of
+DisplayPort multistream (MST), a lot of RandR clients can't handle the
+XID BadMatch when a RandR output disappears. This is to clarify that
+going forward the X server will not remove outputs dynamically,
+just mark them as disconnected.
+
1.99 Acknowledgments
Our thanks to the contributors to the design found on the xpert mailing
diff --git a/fontconfig/doc/fontconfig-devel.sgml b/fontconfig/doc/fontconfig-devel.sgml
index 0fa4605b5..17402c7bc 100644
--- a/fontconfig/doc/fontconfig-devel.sgml
+++ b/fontconfig/doc/fontconfig-devel.sgml
@@ -176,7 +176,7 @@ convenience for the application's rendering mechanism.
outline FC_OUTLINE Bool Whether the glyphs are outlines
scalable FC_SCALABLE Bool Whether glyphs can be scaled
scale FC_SCALE Double Scale factor for point->pixel
- conversions
+ conversions (deprecated)
color FC_COLOR Bool Whether any glyphs have color
dpi FC_DPI Double Target dots per inch
rgba FC_RGBA Int unknown, rgb, bgr, vrgb,
diff --git a/fontconfig/doc/fontconfig-user.sgml b/fontconfig/doc/fontconfig-user.sgml
index 5803929f7..e7cdb2e77 100644
--- a/fontconfig/doc/fontconfig-user.sgml
+++ b/fontconfig/doc/fontconfig-user.sgml
@@ -120,7 +120,7 @@ convenience for the applications' rendering mechanism.
outline Bool Whether the glyphs are outlines
scalable Bool Whether glyphs can be scaled
color Bool Whether any glyphs have color
- scale Double Scale factor for point->pixel conversions
+ scale Double Scale factor for point->pixel conversions (deprecated)
dpi Double Target dots per inch
rgba Int unknown, rgb, bgr, vrgb, vbgr,
none - subpixel geometry
diff --git a/fontconfig/fc-query/fc-query.c b/fontconfig/fc-query/fc-query.c
index 2983e0f19..9bd398059 100644
--- a/fontconfig/fc-query/fc-query.c
+++ b/fontconfig/fc-query/fc-query.c
@@ -52,6 +52,7 @@
#define _GNU_SOURCE
#include <getopt.h>
static const struct option longopts[] = {
+ {"ignore-blanks", 0, 0, 'b'},
{"index", 1, 0, 'i'},
{"format", 1, 0, 'f'},
{"version", 0, 0, 'V'},
@@ -70,24 +71,26 @@ usage (char *program, int error)
{
FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (file, "usage: %s [-Vh] [-i index] [-f FORMAT] [--index index] [--format FORMAT] [--version] [--help] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-i index] [-f FORMAT] [--ignore-blanks] [--index index] [--format FORMAT] [--version] [--help] font-file...\n",
program);
#else
- fprintf (file, "usage: %s [-Vh] [-i index] [-f FORMAT] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-i index] [-f FORMAT] font-file...\n",
program);
#endif
fprintf (file, "Query font files and print resulting pattern(s)\n");
fprintf (file, "\n");
#if HAVE_GETOPT_LONG
+ fprintf (file, " -b, --ignore-blanks ignore blanks to compute langauges\n");
fprintf (file, " -i, --index INDEX display the INDEX face of each font file only\n");
fprintf (file, " -f, --format=FORMAT use the given output format\n");
fprintf (file, " -V, --version display font config version and exit\n");
fprintf (file, " -h, --help display this help and exit\n");
#else
- fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n");
- fprintf (file, " -f FORMAT (format) use the given output format\n");
- fprintf (file, " -V (version) display font config version and exit\n");
- fprintf (file, " -h (help) display this help and exit\n");
+ fprintf (file, " -b (ignore-blanks) ignore blanks to compute languages\n");
+ fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n");
+ fprintf (file, " -f FORMAT (format) use the given output format\n");
+ fprintf (file, " -V (version) display font config version and exit\n");
+ fprintf (file, " -h (help) display this help and exit\n");
#endif
exit (error);
}
@@ -97,19 +100,24 @@ main (int argc, char **argv)
{
int index_set = 0;
int set_index = 0;
+ int ignore_blanks = 0;
FcChar8 *format = NULL;
+ FcBlanks *blanks = NULL;
int err = 0;
int i;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "i:f:Vh", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "bi:f:Vh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "i:f:Vh")) != -1)
+ while ((c = getopt (argc, argv, "bi:f:Vh")) != -1)
#endif
{
switch (c) {
+ case 'b':
+ ignore_blanks = 1;
+ break;
case 'i':
index_set = 1;
set_index = atoi (optarg);
@@ -135,6 +143,8 @@ main (int argc, char **argv)
if (i == argc)
usage (argv[0], 1);
+ if (!ignore_blanks)
+ blanks = FcConfigGetBlanks (NULL);
for (; i < argc; i++)
{
int index;
@@ -145,7 +155,7 @@ main (int argc, char **argv)
do {
FcPattern *pat;
- pat = FcFreeTypeQuery ((FcChar8 *) argv[i], index, NULL, &count);
+ pat = FcFreeTypeQuery ((FcChar8 *) argv[i], index, blanks, &count);
if (pat)
{
if (format)
diff --git a/fontconfig/fc-query/fc-query.sgml b/fontconfig/fc-query/fc-query.sgml
index 5351d1e4d..fd51d2171 100644
--- a/fontconfig/fc-query/fc-query.sgml
+++ b/fontconfig/fc-query/fc-query.sgml
@@ -65,6 +65,10 @@ manpage.1: manpage.sgml
<arg><option>-Vh</option></arg>
<sbr>
<group>
+ <arg><option>-b</option></arg>
+ <arg><option>--ignore-blanks</option></arg>
+ </group>
+ <group>
<arg><option>-i</option> <option><replaceable>index</replaceable></option></arg>
<arg><option>--index</option> <option><replaceable>index</replaceable></option></arg>
</group>
@@ -97,6 +101,14 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
+ <term><option>-b</option>
+ <option>--ignore-blanks</option>
+ </term>
+ <listitem>
+ <para>Ignore blanks to compute languages</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-i</option>
<option>--index</option>
<option><replaceable>index</replaceable></option>
diff --git a/fontconfig/fc-scan/fc-scan.c b/fontconfig/fc-scan/fc-scan.c
index 5638b51cf..4d0b1db44 100644
--- a/fontconfig/fc-scan/fc-scan.c
+++ b/fontconfig/fc-scan/fc-scan.c
@@ -52,6 +52,7 @@
#define _GNU_SOURCE
#include <getopt.h>
static const struct option longopts[] = {
+ {"ignore-blanks", 0, 0, 'b'},
{"format", 1, 0, 'f'},
{"version", 0, 0, 'V'},
{"help", 0, 0, 'h'},
@@ -69,22 +70,24 @@ usage (char *program, int error)
{
FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (file, "usage: %s [-Vh] [-f FORMAT] [--format FORMAT] [--version] [--help] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-f FORMAT] [--ignore-blanks] [--format FORMAT] [--version] [--help] font-file...\n",
program);
#else
- fprintf (file, "usage: %s [-Vh] [-f FORMAT] font-file...\n",
+ fprintf (file, "usage: %s [-Vbh] [-f FORMAT] font-file...\n",
program);
#endif
fprintf (file, "Scan font files and directories, and print resulting pattern(s)\n");
fprintf (file, "\n");
#if HAVE_GETOPT_LONG
+ fprintf (file, " -b, --ignore-blanks ignore blanks to compute languages\n");
fprintf (file, " -f, --format=FORMAT use the given output format\n");
fprintf (file, " -V, --version display font config version and exit\n");
fprintf (file, " -h, --help display this help and exit\n");
#else
- fprintf (file, " -f FORMAT (format) use the given output format\n");
- fprintf (file, " -V (version) display font config version and exit\n");
- fprintf (file, " -h (help) display this help and exit\n");
+ fprintf (file, " -b (ignore-blanks) ignore blanks to compute languages\n");
+ fprintf (file, " -f FORMAT (format) use the given output format\n");
+ fprintf (file, " -V (version) display font config version and exit\n");
+ fprintf (file, " -h (help) display this help and exit\n");
#endif
exit (error);
}
@@ -94,17 +97,22 @@ main (int argc, char **argv)
{
FcChar8 *format = NULL;
int i;
+ int ignore_blanks = 0;
FcFontSet *fs;
+ FcBlanks *blanks = NULL;
#if HAVE_GETOPT_LONG || HAVE_GETOPT
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "f:Vh", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "bf:Vh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "f:Vh")) != -1)
+ while ((c = getopt (argc, argv, "bf:Vh")) != -1)
#endif
{
switch (c) {
+ case 'b':
+ ignore_blanks = 1;
+ break;
case 'f':
format = (FcChar8 *) strdup (optarg);
break;
@@ -127,20 +135,22 @@ main (int argc, char **argv)
usage (argv[0], 1);
fs = FcFontSetCreate ();
+ if (!ignore_blanks)
+ blanks = FcConfigGetBlanks (NULL);
for (; i < argc; i++)
{
const FcChar8 *file = (FcChar8*) argv[i];
if (!FcFileIsDir (file))
- FcFileScan (fs, NULL, NULL, NULL, file, FcTrue);
+ FcFileScan (fs, NULL, NULL, blanks, file, FcTrue);
else
{
FcStrSet *dirs = FcStrSetCreate ();
FcStrList *strlist = FcStrListCreate (dirs);
do
{
- FcDirScan (fs, dirs, NULL, NULL, file, FcTrue);
+ FcDirScan (fs, dirs, NULL, blanks, file, FcTrue);
}
while ((file = FcStrListNext (strlist)));
FcStrListDone (strlist);
diff --git a/fontconfig/fc-scan/fc-scan.sgml b/fontconfig/fc-scan/fc-scan.sgml
index 9af403c1f..65a66c4f3 100644
--- a/fontconfig/fc-scan/fc-scan.sgml
+++ b/fontconfig/fc-scan/fc-scan.sgml
@@ -62,9 +62,13 @@ manpage.1: manpage.sgml
<cmdsynopsis>
<command>&dhpackage;</command>
- <arg><option>-Vh</option></arg>
+ <arg><option>-Vbh</option></arg>
<sbr>
<group>
+ <arg><option>-b</option></arg>
+ <arg><option>--ignore-blanks</option></arg>
+ </group>
+ <group>
<arg><option>-f</option> <option><replaceable>format</replaceable></option></arg>
<arg><option>--format</option> <option><replaceable>format</replaceable></option></arg>
</group>
@@ -91,6 +95,14 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
+ <term><option>-b</option>
+ <option>--ignore-blanks</option>
+ </term>
+ <listitem>
+ <para>Ignore blanks to compute languages</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>-f</option>
<option>--format</option>
<option><replaceable>format</replaceable></option>
diff --git a/fontconfig/fontconfig/fontconfig.h b/fontconfig/fontconfig/fontconfig.h
index b14c9616c..58b6b5137 100644
--- a/fontconfig/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig/fontconfig.h
@@ -95,7 +95,7 @@ typedef int FcBool;
#define FC_OUTLINE "outline" /* Bool */
#define FC_SCALABLE "scalable" /* Bool */
#define FC_COLOR "color" /* Bool */
-#define FC_SCALE "scale" /* double */
+#define FC_SCALE "scale" /* double (deprecated) */
#define FC_DPI "dpi" /* double */
#define FC_RGBA "rgba" /* Int */
#define FC_MINSPACE "minspace" /* Bool use minimum line spacing */
diff --git a/libfontenc/configure.ac b/libfontenc/configure.ac
index 62a959304..c2a23b758 100644
--- a/libfontenc/configure.ac
+++ b/libfontenc/configure.ac
@@ -21,7 +21,7 @@
# Initialize Autoconf
AC_PREREQ([2.60])
-AC_INIT([libfontenc], [1.1.2],
+AC_INIT([libfontenc], [1.1.3],
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [libfontenc])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
diff --git a/libxcb/man/xcb-requests.man b/libxcb/man/xcb-requests.man
index 8d4a1dc5f..6b11883e6 100644
--- a/libxcb/man/xcb-requests.man
+++ b/libxcb/man/xcb-requests.man
@@ -36,7 +36,7 @@ void my_example(xcb_connection *conn) {
cookie = xcb_intern_atom(conn, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
/* ... do other work here if possible ... */
if ((reply = xcb_intern_atom_reply(conn, cookie, NULL))) {
- printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
+ printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
}
free(reply);
}
@@ -118,7 +118,7 @@ void my_example(xcb_connection *conn, xcb_window_t window) {
cookie = xcb_intern_atom(c, 0, strlen("_NET_WM_NAME"), "_NET_WM_NAME");
/* ... do other work here if possible ... */
if ((reply = xcb_intern_atom_reply(c, cookie, &error))) {
- printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
+ printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
free(reply);
} else {
fprintf(stderr, "X11 Error %d\\n", error->error_code);
@@ -138,7 +138,7 @@ void my_example(xcb_connection *conn, xcb_window_t window) {
"_NET_WM_NAME");
/* ... do other work here if possible ... */
if ((reply = xcb_intern_atom_reply(c, cookie, NULL))) {
- printf("The _NET_WM_NAME atom has ID %u\n", reply->atom);
+ printf("The _NET_WM_NAME atom has ID %u\\n", reply->atom);
free(reply);
}
diff --git a/libxcb/src/xcb.h b/libxcb/src/xcb.h
index 23fe74e9f..86eb1bcee 100644
--- a/libxcb/src/xcb.h
+++ b/libxcb/src/xcb.h
@@ -378,6 +378,26 @@ xcb_generic_error_t *xcb_request_check(xcb_connection_t *c, xcb_void_cookie_t co
*/
void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence);
+/**
+ * @brief Discards the reply for a request, given by a 64bit sequence number
+ * @param c: The connection to the X server.
+ * @param sequence: 64-bit sequence number as returned by xcb_send_request64().
+ *
+ * Discards the reply for a request. Additionally, any error generated
+ * by the request is also discarded (unless it was an _unchecked request
+ * and the error has already arrived).
+ *
+ * This function will not block even if the reply is not yet available.
+ *
+ * Note that the sequence really does have to come from xcb_send_request64();
+ * the cookie sequence number is defined as "unsigned" int and therefore
+ * not 64-bit on all platforms.
+ * This function is not designed to operate on socket-handoff replies.
+ *
+ * Unlike its xcb_discard_reply() counterpart, the given sequence number is not
+ * automatically "widened" to 64-bit.
+ */
+void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence);
/* xcb_ext.c */
diff --git a/libxcb/src/xcb_in.c b/libxcb/src/xcb_in.c
index ad870c174..623a0a803 100644
--- a/libxcb/src/xcb_in.c
+++ b/libxcb/src/xcb_in.c
@@ -523,6 +523,20 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
return ret;
}
+void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e)
+{
+ void *ret;
+ if(e)
+ *e = 0;
+ if(c->has_error)
+ return 0;
+
+ pthread_mutex_lock(&c->iolock);
+ ret = wait_for_reply(c, request, e);
+ pthread_mutex_unlock(&c->iolock);
+ return ret;
+}
+
int *xcb_get_reply_fds(xcb_connection_t *c, void *reply, size_t reply_size)
{
return (int *) (&((char *) reply)[reply_size]);
@@ -595,6 +609,20 @@ void xcb_discard_reply(xcb_connection_t *c, unsigned int sequence)
pthread_mutex_unlock(&c->iolock);
}
+void xcb_discard_reply64(xcb_connection_t *c, uint64_t sequence)
+{
+ if(c->has_error)
+ return;
+
+ /* If an error occurred when issuing the request, fail immediately. */
+ if(!sequence)
+ return;
+
+ pthread_mutex_lock(&c->iolock);
+ discard_reply(c, sequence);
+ pthread_mutex_unlock(&c->iolock);
+}
+
int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error)
{
int ret;
@@ -612,6 +640,23 @@ int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply,
return ret;
}
+int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error)
+{
+ int ret;
+ if(c->has_error)
+ {
+ *reply = 0;
+ if(error)
+ *error = 0;
+ return 1; /* would not block */
+ }
+ assert(reply != 0);
+ pthread_mutex_lock(&c->iolock);
+ ret = poll_for_reply(c, request, reply, error);
+ pthread_mutex_unlock(&c->iolock);
+ return ret;
+}
+
xcb_generic_event_t *xcb_wait_for_event(xcb_connection_t *c)
{
xcb_generic_event_t *ret;
diff --git a/libxcb/src/xcb_out.c b/libxcb/src/xcb_out.c
index dc4295467..8cc5be868 100644
--- a/libxcb/src/xcb_out.c
+++ b/libxcb/src/xcb_out.c
@@ -177,7 +177,7 @@ uint32_t xcb_get_maximum_request_length(xcb_connection_t *c)
return c->out.maximum_request_length.value;
}
-unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
+uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
{
uint64_t request;
uint32_t prefix[2];
@@ -286,6 +286,12 @@ unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vect
return request;
}
+/* request number are actually uint64_t internally but keep API compat with unsigned int */
+unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *req)
+{
+ return xcb_send_request64(c, flags, vector, req);
+}
+
void
xcb_send_fd(xcb_connection_t *c, int fd)
{
diff --git a/libxcb/src/xcbext.h b/libxcb/src/xcbext.h
index 7587513d7..b2575f7e3 100644
--- a/libxcb/src/xcbext.h
+++ b/libxcb/src/xcbext.h
@@ -83,6 +83,30 @@ enum xcb_send_request_flags_t {
unsigned int xcb_send_request(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
/**
+ * @brief Send a request to the server, with 64-bit sequence number returned.
+ * @param c: The connection to the X server.
+ * @param flags: A combination of flags from the xcb_send_request_flags_t enumeration.
+ * @param vector: Data to send; must have two iovecs before start for internal use.
+ * @param request: Information about the request to be sent.
+ * @return The request's sequence number on success, 0 otherwise.
+ *
+ * This function sends a new request to the X server. The data of the request is
+ * given as an array of @c iovecs in the @p vector argument. The length of that
+ * array and the neccessary management information are given in the @p request
+ * argument.
+ *
+ * When this function returns, the request might or might not be sent already.
+ * Use xcb_flush() to make sure that it really was sent.
+ *
+ * Please note that this function is not the prefered way for sending requests.
+ * It's better to use the generated wrapper functions.
+ *
+ * Please note that xcb might use index -1 and -2 of the @p vector array internally,
+ * so they must be valid!
+ */
+uint64_t xcb_send_request64(xcb_connection_t *c, int flags, struct iovec *vector, const xcb_protocol_request_t *request);
+
+/**
* @brief Send a file descriptor to the server in the next call to xcb_send_request.
* @param c: The connection to the X server.
* @param fd: The file descriptor to send.
@@ -162,6 +186,21 @@ int xcb_writev(xcb_connection_t *c, struct iovec *vector, int count, uint64_t re
void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_error_t **e);
/**
+ * @brief Wait for the reply of a given request, with 64-bit sequence number
+ * @param c: The connection to the X server.
+ * @param request: 64-bit sequence number of the request as returned by xcb_send_request64().
+ * @param e: Location to store errors in, or NULL. Ignored for unchecked requests.
+ *
+ * Returns the reply to the given request or returns null in the event of
+ * errors. Blocks until the reply or error for the request arrives, or an I/O
+ * error occurs.
+ *
+ * Unlike its xcb_wait_for_reply() counterpart, the given sequence number is not
+ * automatically "widened" to 64-bit.
+ */
+void *xcb_wait_for_reply64(xcb_connection_t *c, uint64_t request, xcb_generic_error_t **e);
+
+/**
* @brief Poll for the reply of a given request.
* @param c: The connection to the X server.
* @param request: Sequence number of the request as returned by xcb_send_request().
@@ -174,6 +213,21 @@ void *xcb_wait_for_reply(xcb_connection_t *c, unsigned int request, xcb_generic_
int xcb_poll_for_reply(xcb_connection_t *c, unsigned int request, void **reply, xcb_generic_error_t **error);
/**
+ * @brief Poll for the reply of a given request, with 64-bit sequence number.
+ * @param c: The connection to the X server.
+ * @param request: 64-bit sequence number of the request as returned by xcb_send_request().
+ * @param reply: Location to store the reply in, must not be NULL.
+ * @param e: Location to store errors in, or NULL. Ignored for unchecked requests.
+ * @return 1 when the reply to the request was returned, else 0.
+ *
+ * Checks if the reply to the given request already received. Does not block.
+ *
+ * Unlike its xcb_poll_for_reply() counterpart, the given sequence number is not
+ * automatically "widened" to 64-bit.
+ */
+int xcb_poll_for_reply64(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error);
+
+/**
* @brief Don't use this, only needed by the generated code.
* @param c: The connection to the X server.
* @param reply: A reply that was received from the server
diff --git a/mesalib/docs/GL3.txt b/mesalib/docs/GL3.txt
index 617ff3447..c7009308a 100644
--- a/mesalib/docs/GL3.txt
+++ b/mesalib/docs/GL3.txt
@@ -117,8 +117,8 @@ GL 4.0, GLSL 4.00:
GL_ARB_texture_cube_map_array DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
GL_ARB_texture_gather DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe)
GL_ARB_texture_query_lod DONE (i965, nv50, nvc0, r600, radeonsi)
- GL_ARB_transform_feedback2 DONE (i965, nv50, nvc0, r600, radeonsi)
- GL_ARB_transform_feedback3 DONE (i965, nv50, nvc0, r600, radeonsi)
+ GL_ARB_transform_feedback2 DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
+ GL_ARB_transform_feedback3 DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
GL 4.1, GLSL 4.10:
@@ -127,7 +127,7 @@ GL 4.1, GLSL 4.10:
GL_ARB_get_program_binary DONE (0 binary formats)
GL_ARB_separate_shader_objects DONE (all drivers)
GL_ARB_shader_precision started (Micah)
- GL_ARB_vertex_attrib_64bit started (Dave)
+ GL_ARB_vertex_attrib_64bit DONE (nvc0, softpipe)
GL_ARB_viewport_array DONE (i965, nv50, nvc0, r600, llvmpipe)
@@ -137,7 +137,7 @@ GL 4.2, GLSL 4.20:
GL_ARB_compressed_texture_pixel_storage DONE (all drivers)
GL_ARB_shader_atomic_counters DONE (i965)
GL_ARB_texture_storage DONE (all drivers)
- GL_ARB_transform_feedback_instanced DONE (i965, nv50, nvc0, r600, radeonsi)
+ GL_ARB_transform_feedback_instanced DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
GL_ARB_base_instance DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
GL_ARB_shader_image_load_store in progress (curro)
GL_ARB_conservative_depth DONE (all drivers that support GLSL 1.30)
@@ -169,7 +169,7 @@ GL 4.3, GLSL 4.30:
GL_ARB_texture_buffer_range DONE (nv50, nvc0, i965, r600, radeonsi, llvmpipe)
GL_ARB_texture_query_levels DONE (all drivers that support GLSL 1.30)
GL_ARB_texture_storage_multisample DONE (all drivers that support GL_ARB_texture_multisample)
- GL_ARB_texture_view DONE (i965, nv50, nvc0)
+ GL_ARB_texture_view DONE (i965, nv50, nvc0, llvmpipe, softpipe)
GL_ARB_vertex_attrib_binding DONE (all drivers)
@@ -192,13 +192,13 @@ GL 4.5, GLSL 4.50:
GL_ARB_conditional_render_inverted DONE (i965, nv50, nvc0, llvmpipe, softpipe)
GL_ARB_cull_distance not started
GL_ARB_derivative_control DONE (i965, nv50, nvc0, r600)
- GL_ARB_direct_state_access started
+ GL_ARB_direct_state_access DONE (all drivers)
- Transform Feedback object DONE
- Buffer object DONE
- - Framebuffer object started (Laura Ekstrand)
+ - Framebuffer object DONE
- Renderbuffer object DONE
- Texture object DONE
- - Vertex array object started (Fredrik Höglund)
+ - Vertex array object DONE
- Sampler object DONE
- Program Pipeline object DONE
- Query object DONE (will require changes when GL_ARB_query_buffer_object lands)
@@ -225,11 +225,17 @@ GLES3.1, GLSL ES 3.1
GL_ARB_shading_language_packing DONE (all drivers)
GL_ARB_separate_shader_objects DONE (all drivers)
GL_ARB_stencil_texturing DONE (i965/gen8+, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
+ Multisample textures (GL_ARB_texture_multisample) DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe)
+ GL_ARB_texture_storage_multisample DONE (all drivers that support GL_ARB_texture_multisample)
GL_ARB_vertex_attrib_binding DONE (all drivers)
GS5 Enhanced textureGather DONE (i965, nvc0, r600, radeonsi)
GS5 Packing/bitfield/conversion functions DONE (i965, nvc0, r600, radeonsi)
GL_EXT_shader_integer_mix DONE (all drivers that support GLSL)
+ Additional functions not covered above:
+ glMemoryBarrierByRegion
+ glGetTexLevelParameter[fi]v - needs updates to restrict to GLES enums
+ glGetBooleani_v - needs updates to restrict to GLES enums
More info about these features and the work involved can be found at
http://dri.freedesktop.org/wiki/MissingFunctionality
diff --git a/mesalib/docs/egl.html b/mesalib/docs/egl.html
index d946bb0ae..3ab1a6018 100644
--- a/mesalib/docs/egl.html
+++ b/mesalib/docs/egl.html
@@ -184,14 +184,6 @@ values are: <code>debug</code>, <code>info</code>, <code>warning</code>, and
<code>fatal</code>.</p>
</dd>
-
-<dt><code>EGL_SOFTWARE</code></dt>
-<dd>
-
-<p>For drivers that support both hardware and software rendering, setting this
-variable to true forces the use of software rendering.</p>
-
-</dd>
</dl>
<h2>EGL Drivers</h2>
diff --git a/mesalib/docs/envvars.html b/mesalib/docs/envvars.html
index 31d14a45a..c0d5a51b4 100644
--- a/mesalib/docs/envvars.html
+++ b/mesalib/docs/envvars.html
@@ -34,6 +34,7 @@ sometimes be useful for debugging end-user issues.
<li>LIBGL_NO_DRAWARRAYS - if set do not use DrawArrays GLX protocol (for debugging)
<li>LIBGL_SHOW_FPS - print framerate to stdout based on the number of glXSwapBuffers
calls per second.
+<li>LIBGL_DRI3_DISABLE - disable DRI3 if set (the value does not matter)
</ul>
diff --git a/mesalib/docs/index.html b/mesalib/docs/index.html
index e01790cd7..325e554df 100644
--- a/mesalib/docs/index.html
+++ b/mesalib/docs/index.html
@@ -16,6 +16,12 @@
<h1>News</h1>
+<h2>May 11, 2015</h2>
+<p>
+<a href="relnotes/10.5.5.html">Mesa 10.5.5</a> is released.
+This is a bug-fix release.
+</p>
+
<h2>April 24, 2015</h2>
<p>
<a href="relnotes/10.5.4.html">Mesa 10.5.4</a> is released.
diff --git a/mesalib/docs/relnotes.html b/mesalib/docs/relnotes.html
index 7f2e1d851..6ba9e5904 100644
--- a/mesalib/docs/relnotes.html
+++ b/mesalib/docs/relnotes.html
@@ -21,6 +21,7 @@ The release notes summarize what's new or changed in each Mesa release.
</p>
<ul>
+<li><a href="relnotes/10.5.5.html">10.5.5 release notes</a>
<li><a href="relnotes/10.5.4.html">10.5.4 release notes</a>
<li><a href="relnotes/10.5.3.html">10.5.3 release notes</a>
<li><a href="relnotes/10.5.2.html">10.5.2 release notes</a>
diff --git a/mesalib/docs/relnotes/10.5.5.html b/mesalib/docs/relnotes/10.5.5.html
new file mode 100644
index 000000000..fc8247c00
--- /dev/null
+++ b/mesalib/docs/relnotes/10.5.5.html
@@ -0,0 +1,95 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <title>Mesa Release Notes</title>
+ <link rel="stylesheet" type="text/css" href="../mesa.css">
+</head>
+<body>
+
+<div class="header">
+ <h1>The Mesa 3D Graphics Library</h1>
+</div>
+
+<iframe src="../contents.html"></iframe>
+<div class="content">
+
+<h1>Mesa 10.5.5 Release Notes / May 11, 2015</h1>
+
+<p>
+Mesa 10.5.5 is a bug fix release which fixes bugs found since the 10.5.4 release.
+</p>
+<p>
+Mesa 10.5.5 implements the OpenGL 3.3 API, but the version reported by
+glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) /
+glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used.
+Some drivers don't support all the features required in OpenGL 3.3. OpenGL
+3.3 is <strong>only</strong> available if requested at context creation
+because compatibility contexts are not supported.
+</p>
+
+
+<h2>SHA256 checksums</h2>
+<pre>
+c10f00fd792b8290dd51ebcc48a9016c4cafab19ec205423c6fcadfd7f3a59f2 mesa-10.5.5.tar.gz
+4ac4e4ea3414f1cadb1467f2f173f9e56170d31e8674f7953a46f0549d319f28 mesa-10.5.5.tar.xz
+</pre>
+
+
+<h2>New features</h2>
+<p>None</p>
+
+<h2>Bug fixes</h2>
+
+<p>This list is likely incomplete.</p>
+
+<ul>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=88521">Bug 88521</a> - GLBenchmark 2.7 TRex renders with artifacts on Gen8 with !UXA</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=89455">Bug 89455</a> - [NVC0/Gallium] Unigine Heaven black and white boxes</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=89689">Bug 89689</a> - [Regression] Weston on DRM backend won't start with new version of mesa</li>
+
+<li><a href="https://bugs.freedesktop.org/show_bug.cgi?id=90130">Bug 90130</a> - gl_PrimitiveId seems to reset at 340</li>
+
+</ul>
+
+
+<h2>Changes</h2>
+
+<p>Boyan Ding (1):</p>
+<ul>
+ <li>i965: Add XRGB8888 format to intel_screen_make_configs</li>
+</ul>
+
+<p>Emil Velikov (3):</p>
+<ul>
+ <li>docs: Add sha256 sums for the 10.5.4 release</li>
+ <li>r300: do not link against libdrm_intel</li>
+ <li>Update version to 10.5.5</li>
+</ul>
+
+<p>Ilia Mirkin (4):</p>
+<ul>
+ <li>nvc0/ir: flush denorms to zero in non-compute shaders</li>
+ <li>gk110/ir: fix set with a register dest to not auto-set the abs flag</li>
+ <li>nvc0/ir: fix predicated PFETCH emission</li>
+ <li>nv50/ir: fix asFlow() const helper for OP_JOIN</li>
+</ul>
+
+<p>Kenneth Graunke (2):</p>
+<ul>
+ <li>i965: Make intel_emit_linear_blit handle Gen8+ alignment restrictions.</li>
+ <li>i965: Disallow linear blits that are not cacheline aligned.</li>
+</ul>
+
+<p>Roland Scheidegger (1):</p>
+<ul>
+ <li>draw: fix prim ids when there's no gs</li>
+</ul>
+
+
+</div>
+</body>
+</html>
diff --git a/mesalib/docs/relnotes/10.6.0.html b/mesalib/docs/relnotes/10.6.0.html
index fbc4d5be9..474a2c71f 100644
--- a/mesalib/docs/relnotes/10.6.0.html
+++ b/mesalib/docs/relnotes/10.6.0.html
@@ -48,6 +48,7 @@ Note: some of the new features are only available with certain drivers.
<li>GL_ARB_clip_control on i965</li>
<li>GL_ARB_depth_buffer_float on freedreno</li>
<li>GL_ARB_depth_clamp on freedreno</li>
+<li>GL_ARB_direct_state_access on all drivers that support GL 2.0+</li>
<li>GL_ARB_draw_indirect, GL_ARB_multi_draw_indirect on r600</li>
<li>GL_ARB_draw_instanced on freedreno</li>
<li>GL_ARB_gpu_shader_fp64 on nvc0, softpipe</li>
@@ -56,12 +57,16 @@ Note: some of the new features are only available with certain drivers.
<li>GL_ARB_pipeline_statistics_query on i965, nv50, nvc0, r600, radeonsi, softpipe</li>
<li>GL_ARB_program_interface_query (all drivers)</li>
<li>GL_ARB_texture_stencil8 on nv50, nvc0, r600, radeonsi, softpipe</li>
+<li>GL_ARB_texture_view on llvmpipe, softpipe</li>
<li>GL_ARB_uniform_buffer_object on freedreno</li>
+<li>GL_ARB_vertex_attrib_64bit on nvc0, softpipe</li>
+<li>GL_ARB_viewport_array, GL_AMD_vertex_shader_viewport_index on i965/gen6</li>
<li>GL_EXT_draw_buffers2 on freedreno</li>
<li>GL_OES_EGL_sync on all drivers</li>
-<li>EGL_KHR_fence_sync on freedreno, nv50, nvc0, r600, radeonsi</li>
-<li>EGL_KHR_wait_sync on freedreno, nv50, nvc0, r600, radeonsi</li>
+<li>EGL_KHR_fence_sync on i965, freedreno, nv50, nvc0, r600, radeonsi</li>
+<li>EGL_KHR_wait_sync on i965, freedreno, nv50, nvc0, r600, radeonsi</li>
<li>EGL_KHR_cl_event2 on freedreno, nv50, nvc0, r600, radeonsi</li>
+<li>GL_AMD_performance_monitor on nvc0</li>
</ul>
<h2>Bug fixes</h2>
diff --git a/mesalib/docs/specs/MESA_image_dma_buf_export.txt b/mesalib/docs/specs/MESA_image_dma_buf_export.txt
index c3794ee36..cc9497e43 100644
--- a/mesalib/docs/specs/MESA_image_dma_buf_export.txt
+++ b/mesalib/docs/specs/MESA_image_dma_buf_export.txt
@@ -16,19 +16,19 @@ Contact
Status
- Proposal
+ Complete, shipping.
Version
- Version 2, Mar 30, 2015
+ Version 3, May 5, 2015
Number
- EGL Extension #not assigned
+ EGL Extension #87
Dependencies
- Reguires EGL 1.4 or later. This extension is written against the
+ Requires EGL 1.4 or later. This extension is written against the
wording of the EGL 1.4 specification.
EGL_KHR_base_image is required.
@@ -43,7 +43,8 @@ Overview
file descriptor or multiple file descriptors, in the case of multi-plane
YUV image, from an EGLImage.
- It is designed to provide the complementary functionality to EGL_EXT_image_dma_buf_import.
+ It is designed to provide the complementary functionality to
+ EGL_EXT_image_dma_buf_import.
IP Status
@@ -51,10 +52,12 @@ IP Status
New Types
- This is a 64 bit unsigned integer.
-
- typedef khronos_uint64_t EGLuint64MESA;
+ This extension uses the 64-bit unsigned integer type EGLuint64KHR
+ first introduced by the EGL_KHR_stream extension, but does not
+ depend on that extension. The typedef may be reproduced separately
+ for this extension, if not already present in eglext.h.
+ typedef khronos_uint64_t EGLuint64KHR;
New Procedures and Functions
@@ -62,7 +65,7 @@ New Procedures and Functions
EGLImageKHR image,
int *fourcc,
int *num_planes,
- EGLuint64MESA *modifiers);
+ EGLuint64KHR *modifiers);
EGLBoolean eglExportDMABUFImageMESA(EGLDisplay dpy,
EGLImageKHR image,
@@ -89,7 +92,7 @@ Additions to the EGL 1.4 Specification:
EGLImageKHR image,
int *fourcc,
int *num_planes,
- EGLuint64MESA *modifiers);
+ EGLuint64KHR *modifiers);
is used to retrieve the pixel format of the buffer, as specified by
drm_fourcc.h, the number of planes in the image and the Linux
@@ -135,6 +138,8 @@ to dup the fd extra times to make the interface sane.
Revision History
+ Version 3, May, 2015
+ Just use the KHR 64-bit type.
Version 2, March, 2015
Add a query interface (Dave Airlie)
Version 1, June 3, 2014
diff --git a/mesalib/include/EGL/eglmesaext.h b/mesalib/include/EGL/eglmesaext.h
index 595babd54..87748cadb 100644
--- a/mesalib/include/EGL/eglmesaext.h
+++ b/mesalib/include/EGL/eglmesaext.h
@@ -34,63 +34,6 @@ extern "C" {
#include <EGL/eglplatform.h>
-/* EGL_MESA_screen extension >>> PRELIMINARY <<< */
-#ifndef EGL_MESA_screen_surface
-#define EGL_MESA_screen_surface 1
-
-#define EGL_BAD_SCREEN_MESA 0x4000
-#define EGL_BAD_MODE_MESA 0x4001
-#define EGL_SCREEN_COUNT_MESA 0x4002
-#define EGL_SCREEN_POSITION_MESA 0x4003
-#define EGL_SCREEN_POSITION_GRANULARITY_MESA 0x4004
-#define EGL_MODE_ID_MESA 0x4005
-#define EGL_REFRESH_RATE_MESA 0x4006
-#define EGL_OPTIMAL_MESA 0x4007
-#define EGL_INTERLACED_MESA 0x4008
-#define EGL_SCREEN_BIT_MESA 0x08
-
-typedef khronos_uint32_t EGLScreenMESA;
-typedef khronos_uint32_t EGLModeMESA;
-
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
-EGLAPI EGLBoolean EGLAPIENTRY eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
-EGLAPI EGLSurface EGLAPIENTRY eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
-EGLAPI EGLBoolean EGLAPIENTRY eglShowScreenSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
-EGLAPI EGLBoolean EGLAPIENTRY eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
-EGLAPI EGLBoolean EGLAPIENTRY eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
-EGLAPI const char * EGLAPIENTRY eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSEMODEMESA) (EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMODESMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGetModeATTRIBMESA) (EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSCRREENSMESA) (EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
-typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESCREENSURFACEMESA) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLSHOWSCREENSURFACEMESA) (EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLSCREENPOSIITONMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENSURFACEMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSCREENMODEMESA) (EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
-typedef const char * (EGLAPIENTRYP PFNEGLQUERYMODESTRINGMESA) (EGLDisplay dpy, EGLModeMESA mode);
-
-#endif /* EGL_MESA_screen_surface */
-
-#ifndef EGL_MESA_copy_context
-#define EGL_MESA_copy_context 1
-
-#ifdef EGL_EGLEXT_PROTOTYPES
-EGLAPI EGLBoolean EGLAPIENTRY eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
-#endif /* EGL_EGLEXT_PROTOTYPES */
-
-typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYCONTEXTMESA) (EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
-
-#endif /* EGL_MESA_copy_context */
-
#ifndef EGL_MESA_drm_display
#define EGL_MESA_drm_display 1
@@ -173,11 +116,16 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOK) (EGLDisplay dpy, EG
#if KHRONOS_SUPPORT_INT64
#ifndef EGL_MESA_image_dma_buf_export
#define EGL_MESA_image_dma_buf_export 1
-typedef khronos_uint64_t EGLuint64MESA;
-EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *fourcc, EGLint *nplanes, EGLuint64MESA *modifiers);
+#ifdef EGL_EGLEXT_PROTOTYPES
+EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *fourcc, EGLint *nplanes, EGLuint64KHR *modifiers);
EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets);
#endif
#endif
+
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESA) (EGLDisplay dpy, EGLImageKHR image, EGLint *fourcc, EGLint *nplanes, EGLuint64KHR *modifiers);
+typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESA) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets);
+
+#endif
#ifdef __cplusplus
}
#endif
diff --git a/mesalib/src/gallium/auxiliary/Makefile.sources b/mesalib/src/gallium/auxiliary/Makefile.sources
index ec7547cad..62e6b94ca 100644
--- a/mesalib/src/gallium/auxiliary/Makefile.sources
+++ b/mesalib/src/gallium/auxiliary/Makefile.sources
@@ -197,7 +197,6 @@ C_SOURCES := \
util/u_dirty_surfaces.h \
util/u_dl.c \
util/u_dl.h \
- util/u_double_list.h \
util/u_draw.c \
util/u_draw.h \
util/u_draw_quad.c \
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_driver_query.c b/mesalib/src/gallium/auxiliary/hud/hud_driver_query.c
index 53771fcae..603aba7e8 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -187,6 +187,7 @@ hud_driver_query_install(struct hud_pane *pane, struct pipe_context *pipe,
struct pipe_screen *screen = pipe->screen;
struct pipe_driver_query_info query;
unsigned num_queries, i;
+ boolean uses_byte_units;
boolean found = FALSE;
if (!screen->get_driver_query_info)
@@ -205,7 +206,9 @@ hud_driver_query_install(struct hud_pane *pane, struct pipe_context *pipe,
if (!found)
return FALSE;
+ uses_byte_units = query.type == PIPE_DRIVER_QUERY_TYPE_BYTES;
hud_pipe_query_install(pane, pipe, query.name, query.query_type, 0,
- query.max_value, query.uses_byte_units);
+ query.max_value.u64, uses_byte_units);
+
return TRUE;
}
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_private.h b/mesalib/src/gallium/auxiliary/hud/hud_private.h
index 230f02664..632926b87 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_private.h
+++ b/mesalib/src/gallium/auxiliary/hud/hud_private.h
@@ -29,7 +29,7 @@
#define HUD_PRIVATE_H
#include "pipe/p_context.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
struct hud_graph {
/* initialized by common code */
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index 9d087fe8a..24a5b93e1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -1306,6 +1306,7 @@ void util_blitter_default_src_texture(struct pipe_sampler_view *src_templ,
unsigned srclevel)
{
memset(src_templ, 0, sizeof(*src_templ));
+ src_templ->target = src->target;
src_templ->format = util_format_linear(src->format);
src_templ->u.tex.first_level = srclevel;
src_templ->u.tex.last_level = srclevel;
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_flush.c b/mesalib/src/gallium/auxiliary/util/u_debug_flush.c
index cdefca2fb..52e72cd6d 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_flush.c
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_flush.c
@@ -44,7 +44,7 @@
#include "util/u_memory.h"
#include "util/u_debug_flush.h"
#include "util/u_hash_table.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
#include "util/u_inlines.h"
#include "util/u_string.h"
#include "os/os_thread.h"
diff --git a/mesalib/src/gallium/auxiliary/util/u_debug_memory.c b/mesalib/src/gallium/auxiliary/util/u_debug_memory.c
index 1ad0e7220..747837cd1 100644
--- a/mesalib/src/gallium/auxiliary/util/u_debug_memory.c
+++ b/mesalib/src/gallium/auxiliary/util/u_debug_memory.c
@@ -42,7 +42,7 @@
#include "util/u_debug.h"
#include "util/u_debug_stack.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
#define DEBUG_MEMORY_MAGIC 0x6e34090aU
diff --git a/mesalib/src/gallium/auxiliary/util/u_dirty_surfaces.h b/mesalib/src/gallium/auxiliary/util/u_dirty_surfaces.h
index f3618d9be..d31f8b917 100644
--- a/mesalib/src/gallium/auxiliary/util/u_dirty_surfaces.h
+++ b/mesalib/src/gallium/auxiliary/util/u_dirty_surfaces.h
@@ -29,7 +29,7 @@
#include "pipe/p_state.h"
-#include "util/u_double_list.h"
+#include "util/list.h"
#include "util/u_math.h"
struct pipe_context;
diff --git a/mesalib/src/glsl/Makefile.sources b/mesalib/src/glsl/Makefile.sources
index c471eca23..d784a8107 100644
--- a/mesalib/src/glsl/Makefile.sources
+++ b/mesalib/src/glsl/Makefile.sources
@@ -22,6 +22,7 @@ NIR_FILES = \
nir/glsl_to_nir.h \
nir/nir.c \
nir/nir.h \
+ nir/nir_array.h \
nir/nir_builder.h \
nir/nir_constant_expressions.h \
nir/nir_dominance.c \
diff --git a/mesalib/src/glsl/ast_to_hir.cpp b/mesalib/src/glsl/ast_to_hir.cpp
index 18b82e3be..14e630905 100644
--- a/mesalib/src/glsl/ast_to_hir.cpp
+++ b/mesalib/src/glsl/ast_to_hir.cpp
@@ -1558,6 +1558,18 @@ ast_expression::do_hir(exec_list *instructions,
error_emitted = true;
}
+ /* From section 4.1.7 of the GLSL 4.50 spec (Opaque Types):
+ *
+ * "Except for array indexing, structure member selection, and
+ * parentheses, opaque variables are not allowed to be operands in
+ * expressions; such use results in a compile-time error."
+ */
+ if (type->contains_opaque()) {
+ _mesa_glsl_error(&loc, state, "opaque variables cannot be operands "
+ "of the ?: operator");
+ error_emitted = true;
+ }
+
ir_constant *cond_val = op[0]->constant_expression_value();
if (then_instructions.is_empty()
@@ -2357,6 +2369,14 @@ apply_image_qualifier_to_variable(const struct ast_type_qualifier *qual,
var->data.image_format = GL_NONE;
}
+ } else if (qual->flags.q.read_only ||
+ qual->flags.q.write_only ||
+ qual->flags.q.coherent ||
+ qual->flags.q._volatile ||
+ qual->flags.q.restrict_flag ||
+ qual->flags.q.explicit_image_format) {
+ _mesa_glsl_error(loc, state, "memory qualifiers may only be applied to "
+ "images");
}
}
@@ -2781,8 +2801,21 @@ apply_type_qualifier_to_variable(const struct ast_type_qualifier *qual,
validate_matrix_layout_for_type(state, loc, var->type, var);
}
- if (var->type->contains_image())
- apply_image_qualifier_to_variable(qual, var, state, loc);
+ apply_image_qualifier_to_variable(qual, var, state, loc);
+
+ /* From section 4.4.1.3 of the GLSL 4.50 specification (Fragment Shader
+ * Inputs):
+ *
+ * "Fragment shaders also allow the following layout qualifier on in only
+ * (not with variable declarations)
+ * layout-qualifier-id
+ * early_fragment_tests
+ * [...]"
+ */
+ if (qual->flags.q.early_fragment_tests) {
+ _mesa_glsl_error(loc, state, "early_fragment_tests layout qualifier only "
+ "valid in fragment shader input layout declaration.");
+ }
}
/**
@@ -3541,6 +3574,9 @@ ast_declarator_list::hir(exec_list *instructions,
case GLSL_TYPE_INT:
if (state->is_version(120, 300))
break;
+ case GLSL_TYPE_DOUBLE:
+ if (check_type->base_type == GLSL_TYPE_DOUBLE && (state->is_version(410, 0) || state->ARB_vertex_attrib_64bit_enable))
+ break;
/* FALLTHROUGH */
default:
_mesa_glsl_error(& loc, state,
diff --git a/mesalib/src/glsl/ast_type.cpp b/mesalib/src/glsl/ast_type.cpp
index b596cd59e..1bcf6a2e8 100644
--- a/mesalib/src/glsl/ast_type.cpp
+++ b/mesalib/src/glsl/ast_type.cpp
@@ -293,11 +293,7 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
valid_in_mask.flags.q.invocations = 1;
break;
case MESA_SHADER_FRAGMENT:
- if (q.flags.q.early_fragment_tests) {
- state->early_fragment_tests = true;
- } else {
- _mesa_glsl_error(loc, state, "invalid input layout qualifier");
- }
+ valid_in_mask.flags.q.early_fragment_tests = 1;
break;
case MESA_SHADER_COMPUTE:
create_cs_ast |=
@@ -345,6 +341,10 @@ ast_type_qualifier::merge_in_qualifier(YYLTYPE *loc,
this->invocations = q.invocations;
}
+ if (q.flags.q.early_fragment_tests) {
+ state->fs_early_fragment_tests = true;
+ }
+
if (create_gs_ast) {
node = new(mem_ctx) ast_gs_input_layout(*loc, q.prim_type);
} else if (create_cs_ast) {
diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp
index 524b8d6e8..97055d85d 100644
--- a/mesalib/src/glsl/builtin_functions.cpp
+++ b/mesalib/src/glsl/builtin_functions.cpp
@@ -136,6 +136,12 @@ v140(const _mesa_glsl_parse_state *state)
}
static bool
+es31(const _mesa_glsl_parse_state *state)
+{
+ return state->is_version(0, 310);
+}
+
+static bool
texture_rectangle(const _mesa_glsl_parse_state *state)
{
return state->ARB_texture_rectangle_enable;
@@ -194,7 +200,8 @@ shader_bit_encoding(const _mesa_glsl_parse_state *state)
static bool
shader_integer_mix(const _mesa_glsl_parse_state *state)
{
- return v130(state) && state->EXT_shader_integer_mix_enable;
+ return state->is_version(450, 310) ||
+ (v130(state) && state->EXT_shader_integer_mix_enable);
}
static bool
@@ -219,10 +226,17 @@ gpu_shader5(const _mesa_glsl_parse_state *state)
}
static bool
-shader_packing_or_gpu_shader5(const _mesa_glsl_parse_state *state)
+gpu_shader5_or_es31(const _mesa_glsl_parse_state *state)
+{
+ return state->is_version(400, 310) || state->ARB_gpu_shader5_enable;
+}
+
+static bool
+shader_packing_or_es31_or_gpu_shader5(const _mesa_glsl_parse_state *state)
{
return state->ARB_shading_language_packing_enable ||
- gpu_shader5(state);
+ state->ARB_gpu_shader5_enable ||
+ state->is_version(400, 310);
}
static bool
@@ -297,15 +311,24 @@ texture_gather(const _mesa_glsl_parse_state *state)
state->ARB_gpu_shader5_enable;
}
+static bool
+texture_gather_or_es31(const _mesa_glsl_parse_state *state)
+{
+ return state->is_version(400, 310) ||
+ state->ARB_texture_gather_enable ||
+ state->ARB_gpu_shader5_enable;
+}
+
/* Only ARB_texture_gather but not GLSL 4.0 or ARB_gpu_shader5.
* used for relaxation of const offset requirements.
*/
static bool
-texture_gather_only(const _mesa_glsl_parse_state *state)
+texture_gather_only_or_es31(const _mesa_glsl_parse_state *state)
{
return !state->is_version(400, 0) &&
!state->ARB_gpu_shader5_enable &&
- state->ARB_texture_gather_enable;
+ (state->ARB_texture_gather_enable ||
+ state->is_version(0, 310));
}
/* Desktop GL or OES_standard_derivatives + fragment shader only */
@@ -359,7 +382,7 @@ tex3d_lod(const _mesa_glsl_parse_state *state)
static bool
shader_atomic_counters(const _mesa_glsl_parse_state *state)
{
- return state->ARB_shader_atomic_counters_enable;
+ return state->has_atomic_counters();
}
static bool
@@ -1161,12 +1184,12 @@ builtin_builder::create_builtins()
add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);
add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3), NULL);
- add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_gpu_shader5), NULL);
- add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_gpu_shader5), NULL);
+ add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
+ add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);
add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3), NULL);
- add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_gpu_shader5), NULL);
- add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_gpu_shader5), NULL);
+ add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
+ add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_es31_or_gpu_shader5), NULL);
add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3), NULL);
add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3), NULL);
add_function("packDouble2x32", _packDouble2x32(fp64), NULL);
@@ -2202,61 +2225,69 @@ builtin_builder::create_builtins()
NULL);
add_function("textureGather",
- _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
- _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
- _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type),
_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type),
_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type),
- _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
- _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
- _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type),
- _texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
- _texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
- _texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type),
+ _texture(ir_tg4, texture_gather_or_es31, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type),
_texture(ir_tg4, texture_gather, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type),
_texture(ir_tg4, texture_gather, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type),
_texture(ir_tg4, texture_gather, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type),
- _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_COMPONENT),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),
_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),
_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DRect_type, glsl_type::vec2_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::samplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::ivec4_type, glsl_type::isamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::uvec4_type, glsl_type::usamplerCube_type, glsl_type::vec3_type, TEX_COMPONENT),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::samplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),
_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isamplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),
_texture(ir_tg4, gpu_shader5, glsl_type::uvec4_type, glsl_type::usamplerCubeArray_type, glsl_type::vec4_type, TEX_COMPONENT),
- _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),
- _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type),
- _texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type),
+ _texture(ir_tg4, gpu_shader5_or_es31, glsl_type::vec4_type, glsl_type::samplerCubeShadow_type, glsl_type::vec3_type),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::samplerCubeArrayShadow_type, glsl_type::vec4_type),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type),
NULL);
add_function("textureGatherOffset",
- _texture(ir_tg4, texture_gather_only, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
- _texture(ir_tg4, texture_gather_only, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
- _texture(ir_tg4, texture_gather_only, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
+ _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
+ _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
+ _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET),
+
+ _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
+ _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
+ _texture(ir_tg4, texture_gather_only_or_es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
- _texture(ir_tg4, texture_gather_only, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
- _texture(ir_tg4, texture_gather_only, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
- _texture(ir_tg4, texture_gather_only, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET),
+ _texture(ir_tg4, es31, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),
+ _texture(ir_tg4, es31, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),
+ _texture(ir_tg4, es31, glsl_type::uvec4_type, glsl_type::usampler2D_type, glsl_type::vec2_type, TEX_OFFSET | TEX_COMPONENT),
+
+ _texture(ir_tg4, es31, glsl_type::vec4_type, glsl_type::sampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),
+ _texture(ir_tg4, es31, glsl_type::ivec4_type, glsl_type::isampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),
+ _texture(ir_tg4, es31, glsl_type::uvec4_type, glsl_type::usampler2DArray_type, glsl_type::vec3_type, TEX_OFFSET | TEX_COMPONENT),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
_texture(ir_tg4, gpu_shader5, glsl_type::ivec4_type, glsl_type::isampler2D_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
@@ -2285,6 +2316,9 @@ builtin_builder::create_builtins()
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET_NONCONST),
_texture(ir_tg4, gpu_shader5, glsl_type::vec4_type, glsl_type::sampler2DRectShadow_type, glsl_type::vec2_type, TEX_OFFSET_NONCONST),
+
+ _texture(ir_tg4, es31, glsl_type::vec4_type, glsl_type::sampler2DShadow_type, glsl_type::vec2_type, TEX_OFFSET),
+ _texture(ir_tg4, es31, glsl_type::vec4_type, glsl_type::sampler2DArrayShadow_type, glsl_type::vec3_type, TEX_OFFSET),
NULL);
add_function("textureGatherOffsets",
@@ -4445,7 +4479,7 @@ builtin_builder::_bitfieldExtract(const glsl_type *type)
ir_variable *value = in_var(type, "value");
ir_variable *offset = in_var(glsl_type::int_type, "offset");
ir_variable *bits = in_var(glsl_type::int_type, "bits");
- MAKE_SIG(type, gpu_shader5, 3, value, offset, bits);
+ MAKE_SIG(type, gpu_shader5_or_es31, 3, value, offset, bits);
body.emit(ret(expr(ir_triop_bitfield_extract, value, offset, bits)));
@@ -4459,33 +4493,33 @@ builtin_builder::_bitfieldInsert(const glsl_type *type)
ir_variable *insert = in_var(type, "insert");
ir_variable *offset = in_var(glsl_type::int_type, "offset");
ir_variable *bits = in_var(glsl_type::int_type, "bits");
- MAKE_SIG(type, gpu_shader5, 4, base, insert, offset, bits);
+ MAKE_SIG(type, gpu_shader5_or_es31, 4, base, insert, offset, bits);
body.emit(ret(bitfield_insert(base, insert, offset, bits)));
return sig;
}
-UNOP(bitfieldReverse, ir_unop_bitfield_reverse, gpu_shader5)
+UNOP(bitfieldReverse, ir_unop_bitfield_reverse, gpu_shader5_or_es31)
ir_function_signature *
builtin_builder::_bitCount(const glsl_type *type)
{
- return unop(gpu_shader5, ir_unop_bit_count,
+ return unop(gpu_shader5_or_es31, ir_unop_bit_count,
glsl_type::ivec(type->vector_elements), type);
}
ir_function_signature *
builtin_builder::_findLSB(const glsl_type *type)
{
- return unop(gpu_shader5, ir_unop_find_lsb,
+ return unop(gpu_shader5_or_es31, ir_unop_find_lsb,
glsl_type::ivec(type->vector_elements), type);
}
ir_function_signature *
builtin_builder::_findMSB(const glsl_type *type)
{
- return unop(gpu_shader5, ir_unop_find_msb,
+ return unop(gpu_shader5_or_es31, ir_unop_find_msb,
glsl_type::ivec(type->vector_elements), type);
}
@@ -4505,7 +4539,7 @@ builtin_builder::_fma(builtin_available_predicate avail, const glsl_type *type)
ir_function_signature *
builtin_builder::_ldexp(const glsl_type *x_type, const glsl_type *exp_type)
{
- return binop(ir_binop_ldexp, x_type->base_type == GLSL_TYPE_DOUBLE ? fp64 : gpu_shader5, x_type, x_type, exp_type);
+ return binop(ir_binop_ldexp, x_type->base_type == GLSL_TYPE_DOUBLE ? fp64 : gpu_shader5_or_es31, x_type, x_type, exp_type);
}
ir_function_signature *
@@ -4526,7 +4560,7 @@ builtin_builder::_frexp(const glsl_type *x_type, const glsl_type *exp_type)
{
ir_variable *x = in_var(x_type, "x");
ir_variable *exponent = out_var(exp_type, "exp");
- MAKE_SIG(x_type, gpu_shader5, 2, x, exponent);
+ MAKE_SIG(x_type, gpu_shader5_or_es31, 2, x, exponent);
const unsigned vec_elem = x_type->vector_elements;
const glsl_type *bvec = glsl_type::get_instance(GLSL_TYPE_BOOL, vec_elem, 1);
@@ -4575,7 +4609,7 @@ builtin_builder::_uaddCarry(const glsl_type *type)
ir_variable *x = in_var(type, "x");
ir_variable *y = in_var(type, "y");
ir_variable *carry = out_var(type, "carry");
- MAKE_SIG(type, gpu_shader5, 3, x, y, carry);
+ MAKE_SIG(type, gpu_shader5_or_es31, 3, x, y, carry);
body.emit(assign(carry, ir_builder::carry(x, y)));
body.emit(ret(add(x, y)));
@@ -4589,7 +4623,7 @@ builtin_builder::_usubBorrow(const glsl_type *type)
ir_variable *x = in_var(type, "x");
ir_variable *y = in_var(type, "y");
ir_variable *borrow = out_var(type, "borrow");
- MAKE_SIG(type, gpu_shader5, 3, x, y, borrow);
+ MAKE_SIG(type, gpu_shader5_or_es31, 3, x, y, borrow);
body.emit(assign(borrow, ir_builder::borrow(x, y)));
body.emit(ret(sub(x, y)));
@@ -4607,7 +4641,7 @@ builtin_builder::_mulExtended(const glsl_type *type)
ir_variable *y = in_var(type, "y");
ir_variable *msb = out_var(type, "msb");
ir_variable *lsb = out_var(type, "lsb");
- MAKE_SIG(glsl_type::void_type, gpu_shader5, 4, x, y, msb, lsb);
+ MAKE_SIG(glsl_type::void_type, gpu_shader5_or_es31, 4, x, y, msb, lsb);
body.emit(assign(msb, imul_high(x, y)));
body.emit(assign(lsb, mul(x, y)));
diff --git a/mesalib/src/glsl/builtin_types.cpp b/mesalib/src/glsl/builtin_types.cpp
index fef86df28..d92e2eb30 100644
--- a/mesalib/src/glsl/builtin_types.cpp
+++ b/mesalib/src/glsl/builtin_types.cpp
@@ -372,7 +372,7 @@ _mesa_glsl_initialize_types(struct _mesa_glsl_parse_state *state)
add_type(symbols, glsl_type::uimage2DMSArray_type);
}
- if (state->ARB_shader_atomic_counters_enable) {
+ if (state->has_atomic_counters()) {
add_type(symbols, glsl_type::atomic_uint_type);
}
diff --git a/mesalib/src/glsl/builtin_variables.cpp b/mesalib/src/glsl/builtin_variables.cpp
index 21e7331c7..6806aa1f9 100644
--- a/mesalib/src/glsl/builtin_variables.cpp
+++ b/mesalib/src/glsl/builtin_variables.cpp
@@ -653,19 +653,46 @@ builtin_variable_generator::generate_constants()
add_const("gl_MaxTextureCoords", state->Const.MaxTextureCoords);
}
- if (state->ARB_shader_atomic_counters_enable) {
+ if (state->has_atomic_counters()) {
add_const("gl_MaxVertexAtomicCounters",
state->Const.MaxVertexAtomicCounters);
- add_const("gl_MaxGeometryAtomicCounters",
- state->Const.MaxGeometryAtomicCounters);
add_const("gl_MaxFragmentAtomicCounters",
state->Const.MaxFragmentAtomicCounters);
add_const("gl_MaxCombinedAtomicCounters",
state->Const.MaxCombinedAtomicCounters);
add_const("gl_MaxAtomicCounterBindings",
state->Const.MaxAtomicBufferBindings);
- add_const("gl_MaxTessControlAtomicCounters", 0);
- add_const("gl_MaxTessEvaluationAtomicCounters", 0);
+
+ /* When Mesa adds support for GL_OES_geometry_shader and
+ * GL_OES_tessellation_shader, this will need to change.
+ */
+ if (!state->es_shader) {
+ add_const("gl_MaxGeometryAtomicCounters",
+ state->Const.MaxGeometryAtomicCounters);
+ add_const("gl_MaxTessControlAtomicCounters", 0);
+ add_const("gl_MaxTessEvaluationAtomicCounters", 0);
+ }
+ }
+
+ if (state->is_version(420, 310)) {
+ add_const("gl_MaxVertexAtomicCounterBuffers",
+ state->Const.MaxVertexAtomicCounterBuffers);
+ add_const("gl_MaxFragmentAtomicCounterBuffers",
+ state->Const.MaxFragmentAtomicCounterBuffers);
+ add_const("gl_MaxCombinedAtomicCounterBuffers",
+ state->Const.MaxCombinedAtomicCounterBuffers);
+ add_const("gl_MaxAtomicCounterBufferSize",
+ state->Const.MaxAtomicCounterBufferSize);
+
+ /* When Mesa adds support for GL_OES_geometry_shader and
+ * GL_OES_tessellation_shader, this will need to change.
+ */
+ if (!state->es_shader) {
+ add_const("gl_MaxGeometryAtomicCounterBuffers",
+ state->Const.MaxGeometryAtomicCounterBuffers);
+ add_const("gl_MaxTessControlAtomicCounterBuffers", 0);
+ add_const("gl_MaxTessEvaluationAtomicCounterBuffers", 0);
+ }
}
if (state->is_version(430, 0) || state->ARB_compute_shader_enable) {
diff --git a/mesalib/src/glsl/glcpp/glcpp-parse.y b/mesalib/src/glsl/glcpp/glcpp-parse.y
index cfceca66b..a11b6b2c7 100644
--- a/mesalib/src/glsl/glcpp/glcpp-parse.y
+++ b/mesalib/src/glsl/glcpp/glcpp-parse.y
@@ -2448,6 +2448,9 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
if (extensions->ARB_gpu_shader_fp64)
add_builtin_define(parser, "GL_ARB_gpu_shader_fp64", 1);
+ if (extensions->ARB_vertex_attrib_64bit)
+ add_builtin_define(parser, "GL_ARB_vertex_attrib_64bit", 1);
+
if (extensions->AMD_vertex_shader_layer)
add_builtin_define(parser, "GL_AMD_vertex_shader_layer", 1);
diff --git a/mesalib/src/glsl/glsl_lexer.ll b/mesalib/src/glsl/glsl_lexer.ll
index 2785ed168..10db5b8b6 100644
--- a/mesalib/src/glsl/glsl_lexer.ll
+++ b/mesalib/src/glsl/glsl_lexer.ll
@@ -409,7 +409,7 @@ restrict KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store
readonly KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, READONLY);
writeonly KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_image_load_store_enable, WRITEONLY);
-atomic_uint KEYWORD_WITH_ALT(420, 300, 420, 0, yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT);
+atomic_uint KEYWORD_WITH_ALT(420, 300, 420, 310, yyextra->ARB_shader_atomic_counters_enable, ATOMIC_UINT);
struct return STRUCT;
void return VOID_TOK;
diff --git a/mesalib/src/glsl/glsl_parser.yy b/mesalib/src/glsl/glsl_parser.yy
index aceb3b916..3ce9e103f 100644
--- a/mesalib/src/glsl/glsl_parser.yy
+++ b/mesalib/src/glsl/glsl_parser.yy
@@ -214,6 +214,7 @@ static bool match_layout_qualifier(const char *s1, const char *s2,
%type <type_qualifier> layout_qualifier
%type <type_qualifier> layout_qualifier_id_list layout_qualifier_id
%type <type_qualifier> interface_block_layout_qualifier
+%type <type_qualifier> memory_qualifier
%type <type_qualifier> interface_qualifier
%type <type_specifier> type_specifier
%type <type_specifier> type_specifier_nonarray
@@ -1000,6 +1001,11 @@ parameter_qualifier:
$$ = $2;
$$.precision = $1;
}
+ | memory_qualifier parameter_qualifier
+ {
+ $$ = $1;
+ $$.merge_qualifier(&@1, state, $2);
+ }
parameter_direction_qualifier:
IN_TOK
@@ -1360,6 +1366,21 @@ layout_qualifier_id:
if (!$$.flags.i &&
match_layout_qualifier($1, "early_fragment_tests", state) == 0) {
+ /* From section 4.4.1.3 of the GLSL 4.50 specification
+ * (Fragment Shader Inputs):
+ *
+ * "Fragment shaders also allow the following layout
+ * qualifier on in only (not with variable declarations)
+ * layout-qualifier-id
+ * early_fragment_tests
+ * [...]"
+ */
+ if (state->stage != MESA_SHADER_FRAGMENT) {
+ _mesa_glsl_error(& @1, state,
+ "early_fragment_tests layout qualifier only "
+ "valid in fragment shaders");
+ }
+
$$.flags.q.early_fragment_tests = 1;
}
}
@@ -1404,13 +1425,13 @@ layout_qualifier_id:
}
if ((state->ARB_shading_language_420pack_enable ||
- state->ARB_shader_atomic_counters_enable) &&
+ state->has_atomic_counters()) &&
match_layout_qualifier("binding", $1, state) == 0) {
$$.flags.q.explicit_binding = 1;
$$.binding = $3;
}
- if (state->ARB_shader_atomic_counters_enable &&
+ if (state->has_atomic_counters() &&
match_layout_qualifier("offset", $1, state) == 0) {
$$.flags.q.explicit_offset = 1;
$$.offset = $3;
@@ -1581,6 +1602,7 @@ type_qualifier:
| storage_qualifier
| interpolation_qualifier
| layout_qualifier
+ | memory_qualifier
| precision_qualifier
{
memset(&$$, 0, sizeof($$));
@@ -1718,6 +1740,11 @@ type_qualifier:
$$ = $2;
$$.precision = $1;
}
+ | memory_qualifier type_qualifier
+ {
+ $$ = $1;
+ $$.merge_qualifier(&@1, state, $2);
+ }
;
auxiliary_storage_qualifier:
@@ -1778,7 +1805,10 @@ storage_qualifier:
memset(& $$, 0, sizeof($$));
$$.flags.q.uniform = 1;
}
- | COHERENT
+ ;
+
+memory_qualifier:
+ COHERENT
{
memset(& $$, 0, sizeof($$));
$$.flags.q.coherent = 1;
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index 0aa3c54fc..be6713c46 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -117,6 +117,16 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->Const.MaxFragmentAtomicCounters = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters;
this->Const.MaxCombinedAtomicCounters = ctx->Const.MaxCombinedAtomicCounters;
this->Const.MaxAtomicBufferBindings = ctx->Const.MaxAtomicBufferBindings;
+ this->Const.MaxVertexAtomicCounterBuffers =
+ ctx->Const.Program[MESA_SHADER_VERTEX].MaxAtomicBuffers;
+ this->Const.MaxGeometryAtomicCounterBuffers =
+ ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers;
+ this->Const.MaxFragmentAtomicCounterBuffers =
+ ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers;
+ this->Const.MaxCombinedAtomicCounterBuffers =
+ ctx->Const.MaxCombinedAtomicBuffers;
+ this->Const.MaxAtomicCounterBufferSize =
+ ctx->Const.MaxAtomicBufferSize;
/* Compute shader constants */
for (unsigned i = 0; i < ARRAY_SIZE(this->Const.MaxComputeWorkGroupCount); i++)
@@ -143,9 +153,9 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->num_user_structures = 0;
/* supported_versions should be large enough to support the known desktop
- * GLSL versions plus 2 GLES versions (ES2 & ES3)
+ * GLSL versions plus 3 GLES versions (ES 1.00, ES 3.00, and ES 3.10))
*/
- STATIC_ASSERT((ARRAY_SIZE(known_desktop_glsl_versions) + 2) ==
+ STATIC_ASSERT((ARRAY_SIZE(known_desktop_glsl_versions) + 3) ==
ARRAY_SIZE(this->supported_versions));
/* Populate the list of supported GLSL versions */
@@ -175,6 +185,11 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->supported_versions[this->num_supported_versions].es = true;
this->num_supported_versions++;
}
+ if (_mesa_is_gles31(ctx)) {
+ this->supported_versions[this->num_supported_versions].ver = 310;
+ this->supported_versions[this->num_supported_versions].es = true;
+ this->num_supported_versions++;
+ }
/* Create a string for use in error messages to tell the user which GLSL
* versions are supported.
@@ -212,7 +227,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
this->gs_input_size = 0;
this->in_qualifier = new(this) ast_type_qualifier();
this->out_qualifier = new(this) ast_type_qualifier();
- this->early_fragment_tests = false;
+ this->fs_early_fragment_tests = false;
memset(this->atomic_counter_offsets, 0,
sizeof(this->atomic_counter_offsets));
this->allow_extension_directive_midshader =
@@ -565,6 +580,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
EXT(ARB_texture_query_lod, true, false, ARB_texture_query_lod),
EXT(ARB_texture_rectangle, true, false, dummy_true),
EXT(ARB_uniform_buffer_object, true, false, ARB_uniform_buffer_object),
+ EXT(ARB_vertex_attrib_64bit, true, false, ARB_vertex_attrib_64bit),
EXT(ARB_viewport_array, true, false, ARB_viewport_array),
/* KHR extensions go here, sorted alphabetically.
@@ -1418,6 +1434,7 @@ set_shader_inout_layout(struct gl_shader *shader,
assert(!state->fs_redeclares_gl_fragcoord);
assert(!state->fs_pixel_center_integer);
assert(!state->fs_origin_upper_left);
+ assert(!state->fs_early_fragment_tests);
}
switch (shader->Stage) {
@@ -1460,6 +1477,7 @@ set_shader_inout_layout(struct gl_shader *shader,
shader->origin_upper_left = state->fs_origin_upper_left;
shader->ARB_fragment_coord_conventions_enable =
state->ARB_fragment_coord_conventions_enable;
+ shader->EarlyFragmentTests = state->fs_early_fragment_tests;
break;
default:
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index dae7864fd..9a0c24e67 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -160,7 +160,7 @@ struct _mesa_glsl_parse_state {
{
if (!this->has_separate_shader_objects()) {
const char *const requirement = this->es_shader
- ? "GL_EXT_separate_shader_objects extension"
+ ? "GL_EXT_separate_shader_objects extension or GLSL ES 310"
: "GL_ARB_separate_shader_objects extension or GLSL 420";
_mesa_glsl_error(locp, this, "%s explicit location requires %s",
@@ -175,17 +175,26 @@ struct _mesa_glsl_parse_state {
const ir_variable *)
{
if (!this->has_explicit_attrib_location() ||
- !this->ARB_explicit_uniform_location_enable) {
+ !this->has_explicit_uniform_location()) {
+ const char *const requirement = this->es_shader
+ ? "GLSL ES 310"
+ : "GL_ARB_explicit_uniform_location and either "
+ "GL_ARB_explicit_attrib_location or GLSL 330.";
+
_mesa_glsl_error(locp, this,
- "uniform explicit location requires "
- "GL_ARB_explicit_uniform_location and either "
- "GL_ARB_explicit_attrib_location or GLSL 330.");
+ "uniform explicit location requires %s",
+ requirement);
return false;
}
return true;
}
+ bool has_atomic_counters() const
+ {
+ return ARB_shader_atomic_counters_enable || is_version(420, 310);
+ }
+
bool has_explicit_attrib_stream() const
{
return ARB_gpu_shader5_enable || is_version(400, 0);
@@ -196,6 +205,11 @@ struct _mesa_glsl_parse_state {
return ARB_explicit_attrib_location_enable || is_version(330, 300);
}
+ bool has_explicit_uniform_location() const
+ {
+ return ARB_explicit_uniform_location_enable || is_version(430, 310);
+ }
+
bool has_uniform_buffer_objects() const
{
return ARB_uniform_buffer_object_enable || is_version(140, 300);
@@ -203,7 +217,7 @@ struct _mesa_glsl_parse_state {
bool has_separate_shader_objects() const
{
- return ARB_separate_shader_objects_enable || is_version(410, 0)
+ return ARB_separate_shader_objects_enable || is_version(410, 310)
|| EXT_separate_shader_objects_enable;
}
@@ -224,7 +238,7 @@ struct _mesa_glsl_parse_state {
struct {
unsigned ver;
bool es;
- } supported_versions[14];
+ } supported_versions[15];
bool es_shader;
unsigned language_version;
@@ -339,6 +353,16 @@ struct _mesa_glsl_parse_state {
unsigned MaxCombinedAtomicCounters;
unsigned MaxAtomicBufferBindings;
+ /* These are also atomic counter related, but they weren't added to
+ * until atomic counters were added to core in GLSL 4.20 and GLSL ES
+ * 3.10.
+ */
+ unsigned MaxVertexAtomicCounterBuffers;
+ unsigned MaxGeometryAtomicCounterBuffers;
+ unsigned MaxFragmentAtomicCounterBuffers;
+ unsigned MaxCombinedAtomicCounterBuffers;
+ unsigned MaxAtomicCounterBufferSize;
+
/* ARB_compute_shader */
unsigned MaxComputeWorkGroupCount[3];
unsigned MaxComputeWorkGroupSize[3];
@@ -458,6 +482,8 @@ struct _mesa_glsl_parse_state {
bool ARB_texture_rectangle_warn;
bool ARB_uniform_buffer_object_enable;
bool ARB_uniform_buffer_object_warn;
+ bool ARB_vertex_attrib_64bit_enable;
+ bool ARB_vertex_attrib_64bit_warn;
bool ARB_viewport_array_enable;
bool ARB_viewport_array_warn;
@@ -510,7 +536,7 @@ struct _mesa_glsl_parse_state {
*/
unsigned gs_input_size;
- bool early_fragment_tests;
+ bool fs_early_fragment_tests;
/** Atomic counter offsets by binding */
unsigned atomic_counter_offsets[MAX_COMBINED_ATOMIC_BUFFERS];
diff --git a/mesalib/src/glsl/ir_set_program_inouts.cpp b/mesalib/src/glsl/ir_set_program_inouts.cpp
index e877a2019..b968a1efd 100644
--- a/mesalib/src/glsl/ir_set_program_inouts.cpp
+++ b/mesalib/src/glsl/ir_set_program_inouts.cpp
@@ -105,13 +105,10 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
int idx = var->data.location + var->data.index + offset + i;
GLbitfield64 bitfield = BITFIELD64_BIT(idx);
- /* dvec3 and dvec4 take up 2 slots */
- if (dual_slot) {
- idx += i;
- bitfield |= bitfield << 1;
- }
if (var->data.mode == ir_var_shader_in) {
- prog->InputsRead |= bitfield;
+ prog->InputsRead |= bitfield;
+ if (dual_slot)
+ prog->DoubleInputsRead |= bitfield;
if (is_fragment_shader) {
gl_fragment_program *fprog = (gl_fragment_program *) prog;
fprog->InterpQualifier[idx] =
@@ -120,13 +117,6 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
fprog->IsCentroid |= bitfield;
if (var->data.sample)
fprog->IsSample |= bitfield;
-
- /* Set the InterpQualifier of the next slot to the same as the
- * current one, since dvec3 and dvec4 spans 2 slots.
- */
- if (dual_slot)
- fprog->InterpQualifier[idx + 1] =
- (glsl_interp_qualifier) var->data.interpolation;
}
} else if (var->data.mode == ir_var_system_value) {
prog->SystemValuesRead |= bitfield;
diff --git a/mesalib/src/glsl/link_uniform_blocks.cpp b/mesalib/src/glsl/link_uniform_blocks.cpp
index 6ca41107e..898544bea 100644
--- a/mesalib/src/glsl/link_uniform_blocks.cpp
+++ b/mesalib/src/glsl/link_uniform_blocks.cpp
@@ -67,14 +67,14 @@ private:
assert(!"Should not get here.");
}
- virtual void enter_record(const glsl_type *type, const char *name,
+ virtual void enter_record(const glsl_type *type, const char *,
bool row_major) {
assert(type->is_record());
this->offset = glsl_align(
this->offset, type->std140_base_alignment(row_major));
}
- virtual void leave_record(const glsl_type *type, const char *name,
+ virtual void leave_record(const glsl_type *type, const char *,
bool row_major) {
assert(type->is_record());
@@ -90,8 +90,8 @@ private:
}
virtual void visit_field(const glsl_type *type, const char *name,
- bool row_major, const glsl_type *record_type,
- bool last_field)
+ bool row_major, const glsl_type *,
+ bool /* last_field */)
{
assert(this->index < this->num_variables);
diff --git a/mesalib/src/glsl/link_uniforms.cpp b/mesalib/src/glsl/link_uniforms.cpp
index d5ca23a38..2c928e144 100644
--- a/mesalib/src/glsl/link_uniforms.cpp
+++ b/mesalib/src/glsl/link_uniforms.cpp
@@ -544,7 +544,7 @@ private:
assert(!"Should not get here.");
}
- virtual void enter_record(const glsl_type *type, const char *name,
+ virtual void enter_record(const glsl_type *type, const char *,
bool row_major) {
assert(type->is_record());
if (this->ubo_block_index == -1)
@@ -553,7 +553,7 @@ private:
this->ubo_byte_offset, type->std140_base_alignment(row_major));
}
- virtual void leave_record(const glsl_type *type, const char *name,
+ virtual void leave_record(const glsl_type *type, const char *,
bool row_major) {
assert(type->is_record());
if (this->ubo_block_index == -1)
@@ -564,7 +564,7 @@ private:
virtual void visit_field(const glsl_type *type, const char *name,
bool row_major, const glsl_type *record_type,
- bool last_field)
+ bool /* last_field */)
{
assert(!type->without_array()->is_record());
assert(!type->without_array()->is_interface());
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index 21fde9444..ea73c6f9d 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -1413,6 +1413,8 @@ link_fs_input_layout_qualifiers(struct gl_shader_program *prog,
linked_shader->origin_upper_left = shader->origin_upper_left;
linked_shader->pixel_center_integer = shader->pixel_center_integer;
}
+
+ linked_shader->EarlyFragmentTests |= shader->EarlyFragmentTests;
}
}
@@ -1975,6 +1977,7 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
} to_assign[16];
unsigned num_attr = 0;
+ unsigned total_attribs_size = 0;
foreach_in_list(ir_instruction, node, sh->ir) {
ir_variable *const var = node->as_variable();
@@ -2016,12 +2019,41 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
}
}
+ const unsigned slots = var->type->count_attribute_slots();
+
+ /* From GL4.5 core spec, section 11.1.1 (Vertex Attributes):
+ *
+ * "A program with more than the value of MAX_VERTEX_ATTRIBS active
+ * attribute variables may fail to link, unless device-dependent
+ * optimizations are able to make the program fit within available
+ * hardware resources. For the purposes of this test, attribute variables
+ * of the type dvec3, dvec4, dmat2x3, dmat2x4, dmat3, dmat3x4, dmat4x3,
+ * and dmat4 may count as consuming twice as many attributes as equivalent
+ * single-precision types. While these types use the same number of
+ * generic attributes as their single-precision equivalents,
+ * implementations are permitted to consume two single-precision vectors
+ * of internal storage for each three- or four-component double-precision
+ * vector."
+ * Until someone has a good reason in Mesa, enforce that now.
+ */
+ if (target_index == MESA_SHADER_VERTEX) {
+ total_attribs_size += slots;
+ if (var->type->without_array() == glsl_type::dvec3_type ||
+ var->type->without_array() == glsl_type::dvec4_type ||
+ var->type->without_array() == glsl_type::dmat2x3_type ||
+ var->type->without_array() == glsl_type::dmat2x4_type ||
+ var->type->without_array() == glsl_type::dmat3_type ||
+ var->type->without_array() == glsl_type::dmat3x4_type ||
+ var->type->without_array() == glsl_type::dmat4x3_type ||
+ var->type->without_array() == glsl_type::dmat4_type)
+ total_attribs_size += slots;
+ }
+
/* If the variable is not a built-in and has a location statically
* assigned in the shader (presumably via a layout qualifier), make sure
* that it doesn't collide with other assigned locations. Otherwise,
* add it to the list of variables that need linker-assigned locations.
*/
- const unsigned slots = var->type->count_attribute_slots();
if (var->data.location != -1) {
if (var->data.location >= generic_base && var->data.index < 1) {
/* From page 61 of the OpenGL 4.0 spec:
@@ -2141,6 +2173,15 @@ assign_attribute_or_color_locations(gl_shader_program *prog,
num_attr++;
}
+ if (target_index == MESA_SHADER_VERTEX) {
+ if (total_attribs_size > max_index) {
+ linker_error(prog,
+ "attempt to use %d vertex attribute slots only %d available ",
+ total_attribs_size, max_index);
+ return false;
+ }
+ }
+
/* If all of the attributes were assigned locations by the application (or
* are built-in attributes with fixed locations), return early. This should
* be the common case.
@@ -2556,6 +2597,7 @@ add_interface_variables(struct gl_shader_program *shProg,
{
foreach_in_list(ir_instruction, node, sh->ir) {
ir_variable *var = node->as_variable();
+ uint8_t mask = 0;
if (!var)
continue;
@@ -2571,6 +2613,10 @@ add_interface_variables(struct gl_shader_program *shProg,
var->data.location != SYSTEM_VALUE_VERTEX_ID_ZERO_BASE &&
var->data.location != SYSTEM_VALUE_INSTANCE_ID)
continue;
+ /* Mark special built-in inputs referenced by the vertex stage so
+ * that they are considered active by the shader queries.
+ */
+ mask = (1 << (MESA_SHADER_VERTEX));
/* FALLTHROUGH */
case ir_var_shader_in:
if (programInterface != GL_PROGRAM_INPUT)
@@ -2585,7 +2631,7 @@ add_interface_variables(struct gl_shader_program *shProg,
};
if (!add_program_resource(shProg, programInterface, var,
- build_stageref(shProg, var->name)))
+ build_stageref(shProg, var->name) | mask))
return false;
}
return true;
diff --git a/mesalib/src/glsl/nir/glsl_to_nir.cpp b/mesalib/src/glsl/nir/glsl_to_nir.cpp
index f6b8331d4..af758ceb0 100644
--- a/mesalib/src/glsl/nir/glsl_to_nir.cpp
+++ b/mesalib/src/glsl/nir/glsl_to_nir.cpp
@@ -614,27 +614,135 @@ nir_visitor::visit(ir_call *ir)
op = nir_intrinsic_atomic_counter_inc_var;
} else if (strcmp(ir->callee_name(), "__intrinsic_atomic_predecrement") == 0) {
op = nir_intrinsic_atomic_counter_dec_var;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_load") == 0) {
+ op = nir_intrinsic_image_load;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_store") == 0) {
+ op = nir_intrinsic_image_store;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_add") == 0) {
+ op = nir_intrinsic_image_atomic_add;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_min") == 0) {
+ op = nir_intrinsic_image_atomic_min;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_max") == 0) {
+ op = nir_intrinsic_image_atomic_max;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_and") == 0) {
+ op = nir_intrinsic_image_atomic_and;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_or") == 0) {
+ op = nir_intrinsic_image_atomic_or;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_xor") == 0) {
+ op = nir_intrinsic_image_atomic_xor;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_exchange") == 0) {
+ op = nir_intrinsic_image_atomic_exchange;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_image_atomic_comp_swap") == 0) {
+ op = nir_intrinsic_image_atomic_comp_swap;
+ } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier") == 0) {
+ op = nir_intrinsic_memory_barrier;
} else {
unreachable("not reached");
}
nir_intrinsic_instr *instr = nir_intrinsic_instr_create(shader, op);
- ir_dereference *param =
- (ir_dereference *) ir->actual_parameters.get_head();
- instr->variables[0] = evaluate_deref(&instr->instr, param);
- nir_ssa_dest_init(&instr->instr, &instr->dest, 1, NULL);
+
+ switch (op) {
+ case nir_intrinsic_atomic_counter_read_var:
+ case nir_intrinsic_atomic_counter_inc_var:
+ case nir_intrinsic_atomic_counter_dec_var: {
+ ir_dereference *param =
+ (ir_dereference *) ir->actual_parameters.get_head();
+ instr->variables[0] = evaluate_deref(&instr->instr, param);
+ nir_ssa_dest_init(&instr->instr, &instr->dest, 1, NULL);
+ break;
+ }
+ case nir_intrinsic_image_load:
+ case nir_intrinsic_image_store:
+ case nir_intrinsic_image_atomic_add:
+ case nir_intrinsic_image_atomic_min:
+ case nir_intrinsic_image_atomic_max:
+ case nir_intrinsic_image_atomic_and:
+ case nir_intrinsic_image_atomic_or:
+ case nir_intrinsic_image_atomic_xor:
+ case nir_intrinsic_image_atomic_exchange:
+ case nir_intrinsic_image_atomic_comp_swap: {
+ nir_ssa_undef_instr *instr_undef =
+ nir_ssa_undef_instr_create(shader, 1);
+ nir_instr_insert_after_cf_list(this->cf_node_list,
+ &instr_undef->instr);
+
+ /* Set the image variable dereference. */
+ exec_node *param = ir->actual_parameters.get_head();
+ ir_dereference *image = (ir_dereference *)param;
+ const glsl_type *type =
+ image->variable_referenced()->type->without_array();
+
+ instr->variables[0] = evaluate_deref(&instr->instr, image);
+ param = param->get_next();
+
+ /* Set the address argument, extending the coordinate vector to four
+ * components.
+ */
+ const nir_src src_addr = evaluate_rvalue((ir_dereference *)param);
+ nir_alu_instr *instr_addr = nir_alu_instr_create(shader, nir_op_vec4);
+ nir_ssa_dest_init(&instr_addr->instr, &instr_addr->dest.dest, 4, NULL);
+
+ for (int i = 0; i < 4; i++) {
+ if (i < type->coordinate_components()) {
+ instr_addr->src[i].src = src_addr;
+ instr_addr->src[i].swizzle[0] = i;
+ } else {
+ instr_addr->src[i].src = nir_src_for_ssa(&instr_undef->def);
+ }
+ }
+
+ nir_instr_insert_after_cf_list(cf_node_list, &instr_addr->instr);
+ instr->src[0] = nir_src_for_ssa(&instr_addr->dest.dest.ssa);
+ param = param->get_next();
+
+ /* Set the sample argument, which is undefined for single-sample
+ * images.
+ */
+ if (type->sampler_dimensionality == GLSL_SAMPLER_DIM_MS) {
+ instr->src[1] = evaluate_rvalue((ir_dereference *)param);
+ param = param->get_next();
+ } else {
+ instr->src[1] = nir_src_for_ssa(&instr_undef->def);
+ }
+
+ /* Set the intrinsic parameters. */
+ if (!param->is_tail_sentinel()) {
+ instr->src[2] = evaluate_rvalue((ir_dereference *)param);
+ param = param->get_next();
+ }
+
+ if (!param->is_tail_sentinel()) {
+ instr->src[3] = evaluate_rvalue((ir_dereference *)param);
+ param = param->get_next();
+ }
+
+ /* Set the intrinsic destination. */
+ if (ir->return_deref)
+ nir_ssa_dest_init(&instr->instr, &instr->dest,
+ ir->return_deref->type->vector_elements, NULL);
+ break;
+ }
+ case nir_intrinsic_memory_barrier:
+ break;
+ default:
+ unreachable("not reached");
+ }
nir_instr_insert_after_cf_list(this->cf_node_list, &instr->instr);
- nir_intrinsic_instr *store_instr =
- nir_intrinsic_instr_create(shader, nir_intrinsic_store_var);
- store_instr->num_components = 1;
+ if (ir->return_deref) {
+ nir_intrinsic_instr *store_instr =
+ nir_intrinsic_instr_create(shader, nir_intrinsic_store_var);
+ store_instr->num_components = ir->return_deref->type->vector_elements;
- store_instr->variables[0] = evaluate_deref(&store_instr->instr, ir->return_deref);
- store_instr->src[0].is_ssa = true;
- store_instr->src[0].ssa = &instr->dest.ssa;
+ store_instr->variables[0] =
+ evaluate_deref(&store_instr->instr, ir->return_deref);
+ store_instr->src[0] = nir_src_for_ssa(&instr->dest.ssa);
- nir_instr_insert_after_cf_list(this->cf_node_list, &store_instr->instr);
+ nir_instr_insert_after_cf_list(this->cf_node_list,
+ &store_instr->instr);
+ }
return;
}
@@ -824,7 +932,7 @@ nir_visitor::evaluate_rvalue(ir_rvalue* ir)
nir_dest *dest = get_instr_dest(this->result);
assert(dest->is_ssa);
- nir_src src;
+ nir_src src = NIR_SRC_INIT;
src.is_ssa = true;
src.ssa = &dest->ssa;
@@ -1038,8 +1146,8 @@ nir_visitor::visit(ir_expression *ir)
case ir_unop_rcp: emit(nir_op_frcp, dest_size, srcs); break;
case ir_unop_rsq: emit(nir_op_frsq, dest_size, srcs); break;
case ir_unop_sqrt: emit(nir_op_fsqrt, dest_size, srcs); break;
- case ir_unop_exp: emit(nir_op_fexp, dest_size, srcs); break;
- case ir_unop_log: emit(nir_op_flog, dest_size, srcs); break;
+ case ir_unop_exp: unreachable("ir_unop_exp should have been lowered");
+ case ir_unop_log: unreachable("ir_unop_log should have been lowered");
case ir_unop_exp2: emit(nir_op_fexp2, dest_size, srcs); break;
case ir_unop_log2: emit(nir_op_flog2, dest_size, srcs); break;
case ir_unop_i2f:
diff --git a/mesalib/src/glsl/nir/nir.c b/mesalib/src/glsl/nir/nir.c
index 4cc074b80..f03e80a4e 100644
--- a/mesalib/src/glsl/nir/nir.c
+++ b/mesalib/src/glsl/nir/nir.c
@@ -58,12 +58,9 @@ reg_create(void *mem_ctx, struct exec_list *list)
nir_register *reg = ralloc(mem_ctx, nir_register);
reg->parent_instr = NULL;
- reg->uses = _mesa_set_create(reg, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
- reg->defs = _mesa_set_create(reg, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
- reg->if_uses = _mesa_set_create(reg, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
+ list_inithead(&reg->uses);
+ list_inithead(&reg->defs);
+ list_inithead(&reg->if_uses);
reg->num_components = 0;
reg->num_array_elems = 0;
@@ -1070,11 +1067,14 @@ update_if_uses(nir_cf_node *node)
nir_if *if_stmt = nir_cf_node_as_if(node);
- struct set *if_uses_set = if_stmt->condition.is_ssa ?
- if_stmt->condition.ssa->if_uses :
- if_stmt->condition.reg.reg->uses;
-
- _mesa_set_add(if_uses_set, if_stmt);
+ if_stmt->condition.parent_if = if_stmt;
+ if (if_stmt->condition.is_ssa) {
+ list_addtail(&if_stmt->condition.use_link,
+ &if_stmt->condition.ssa->if_uses);
+ } else {
+ list_addtail(&if_stmt->condition.use_link,
+ &if_stmt->condition.reg.reg->if_uses);
+ }
}
void
@@ -1227,16 +1227,7 @@ cleanup_cf_node(nir_cf_node *node)
foreach_list_typed(nir_cf_node, child, node, &if_stmt->else_list)
cleanup_cf_node(child);
- struct set *if_uses;
- if (if_stmt->condition.is_ssa) {
- if_uses = if_stmt->condition.ssa->if_uses;
- } else {
- if_uses = if_stmt->condition.reg.reg->if_uses;
- }
-
- struct set_entry *entry = _mesa_set_search(if_uses, if_stmt);
- assert(entry);
- _mesa_set_remove(if_uses, entry);
+ list_del(&if_stmt->condition.use_link);
break;
}
@@ -1293,9 +1284,9 @@ add_use_cb(nir_src *src, void *state)
{
nir_instr *instr = state;
- struct set *uses_set = src->is_ssa ? src->ssa->uses : src->reg.reg->uses;
-
- _mesa_set_add(uses_set, instr);
+ src->parent_instr = instr;
+ list_addtail(&src->use_link,
+ src->is_ssa ? &src->ssa->uses : &src->reg.reg->uses);
return true;
}
@@ -1320,8 +1311,10 @@ add_reg_def_cb(nir_dest *dest, void *state)
{
nir_instr *instr = state;
- if (!dest->is_ssa)
- _mesa_set_add(dest->reg.reg->defs, instr);
+ if (!dest->is_ssa) {
+ dest->reg.parent_instr = instr;
+ list_addtail(&dest->reg.def_link, &dest->reg.reg->defs);
+ }
return true;
}
@@ -1436,13 +1429,7 @@ nir_instr_insert_after_cf_list(struct exec_list *list, nir_instr *after)
static bool
remove_use_cb(nir_src *src, void *state)
{
- nir_instr *instr = state;
-
- struct set *uses_set = src->is_ssa ? src->ssa->uses : src->reg.reg->uses;
-
- struct set_entry *entry = _mesa_set_search(uses_set, instr);
- if (entry)
- _mesa_set_remove(uses_set, entry);
+ list_del(&src->use_link);
return true;
}
@@ -1450,16 +1437,8 @@ remove_use_cb(nir_src *src, void *state)
static bool
remove_def_cb(nir_dest *dest, void *state)
{
- nir_instr *instr = state;
-
- if (dest->is_ssa)
- return true;
-
- nir_register *reg = dest->reg.reg;
-
- struct set_entry *entry = _mesa_set_search(reg->defs, instr);
- if (entry)
- _mesa_set_remove(reg->defs, entry);
+ if (!dest->is_ssa)
+ list_del(&dest->reg.def_link);
return true;
}
@@ -1834,64 +1813,77 @@ nir_srcs_equal(nir_src src1, nir_src src2)
}
static bool
-src_does_not_use_def(nir_src *src, void *void_def)
+src_is_valid(const nir_src *src)
{
- nir_ssa_def *def = void_def;
-
- if (src->is_ssa) {
- return src->ssa != def;
- } else {
- return true;
- }
+ return src->is_ssa ? (src->ssa != NULL) : (src->reg.reg != NULL);
}
-static bool
-src_does_not_use_reg(nir_src *src, void *void_reg)
+static void
+src_remove_all_uses(nir_src *src)
{
- nir_register *reg = void_reg;
+ for (; src; src = src->is_ssa ? NULL : src->reg.indirect) {
+ if (!src_is_valid(src))
+ continue;
- if (src->is_ssa) {
- return true;
- } else {
- return src->reg.reg != reg;
+ list_del(&src->use_link);
+ }
+}
+
+static void
+src_add_all_uses(nir_src *src, nir_instr *parent_instr, nir_if *parent_if)
+{
+ for (; src; src = src->is_ssa ? NULL : src->reg.indirect) {
+ if (!src_is_valid(src))
+ continue;
+
+ if (parent_instr) {
+ src->parent_instr = parent_instr;
+ if (src->is_ssa)
+ list_addtail(&src->use_link, &src->ssa->uses);
+ else
+ list_addtail(&src->use_link, &src->reg.reg->uses);
+ } else {
+ assert(parent_if);
+ src->parent_if = parent_if;
+ if (src->is_ssa)
+ list_addtail(&src->use_link, &src->ssa->if_uses);
+ else
+ list_addtail(&src->use_link, &src->reg.reg->if_uses);
+ }
}
}
void
nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src)
{
- nir_src old_src = *src;
+ assert(!src_is_valid(src) || src->parent_instr == instr);
+
+ src_remove_all_uses(src);
*src = new_src;
+ src_add_all_uses(src, instr, NULL);
+}
- for (nir_src *iter_src = &old_src; iter_src;
- iter_src = iter_src->is_ssa ? NULL : iter_src->reg.indirect) {
- if (iter_src->is_ssa) {
- nir_ssa_def *ssa = iter_src->ssa;
- if (ssa && nir_foreach_src(instr, src_does_not_use_def, ssa)) {
- struct set_entry *entry = _mesa_set_search(ssa->uses, instr);
- assert(entry);
- _mesa_set_remove(ssa->uses, entry);
- }
- } else {
- nir_register *reg = iter_src->reg.reg;
- if (reg && nir_foreach_src(instr, src_does_not_use_reg, reg)) {
- struct set_entry *entry = _mesa_set_search(reg->uses, instr);
- assert(entry);
- _mesa_set_remove(reg->uses, entry);
- }
- }
- }
+void
+nir_instr_move_src(nir_instr *dest_instr, nir_src *dest, nir_src *src)
+{
+ assert(!src_is_valid(dest) || dest->parent_instr == dest_instr);
- for (nir_src *iter_src = &new_src; iter_src;
- iter_src = iter_src->is_ssa ? NULL : iter_src->reg.indirect) {
- if (iter_src->is_ssa) {
- if (iter_src->ssa)
- _mesa_set_add(iter_src->ssa->uses, instr);
- } else {
- if (iter_src->reg.reg)
- _mesa_set_add(iter_src->reg.reg->uses, instr);
- }
- }
+ src_remove_all_uses(dest);
+ src_remove_all_uses(src);
+ *dest = *src;
+ *src = NIR_SRC_INIT;
+ src_add_all_uses(dest, dest_instr, NULL);
+}
+
+void
+nir_if_rewrite_condition(nir_if *if_stmt, nir_src new_src)
+{
+ nir_src *src = &if_stmt->condition;
+ assert(!src_is_valid(src) || src->parent_if == if_stmt);
+
+ src_remove_all_uses(src);
+ *src = new_src;
+ src_add_all_uses(src, NULL, if_stmt);
}
void
@@ -1900,10 +1892,8 @@ nir_ssa_def_init(nir_instr *instr, nir_ssa_def *def,
{
def->name = name;
def->parent_instr = instr;
- def->uses = _mesa_set_create(instr, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
- def->if_uses = _mesa_set_create(instr, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
+ list_inithead(&def->uses);
+ list_inithead(&def->if_uses);
def->num_components = num_components;
if (instr->block) {
@@ -1924,57 +1914,23 @@ nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
nir_ssa_def_init(instr, &dest->ssa, num_components, name);
}
-struct ssa_def_rewrite_state {
- void *mem_ctx;
- nir_ssa_def *old;
- nir_src new_src;
-};
-
-static bool
-ssa_def_rewrite_uses_src(nir_src *src, void *void_state)
-{
- struct ssa_def_rewrite_state *state = void_state;
-
- if (src->is_ssa && src->ssa == state->old)
- nir_src_copy(src, &state->new_src, state->mem_ctx);
-
- return true;
-}
-
void
nir_ssa_def_rewrite_uses(nir_ssa_def *def, nir_src new_src, void *mem_ctx)
{
- struct ssa_def_rewrite_state state;
- state.mem_ctx = mem_ctx;
- state.old = def;
- state.new_src = new_src;
-
assert(!new_src.is_ssa || def != new_src.ssa);
- struct set *new_uses, *new_if_uses;
- if (new_src.is_ssa) {
- new_uses = new_src.ssa->uses;
- new_if_uses = new_src.ssa->if_uses;
- } else {
- new_uses = new_src.reg.reg->uses;
- new_if_uses = new_src.reg.reg->if_uses;
- }
-
- struct set_entry *entry;
- set_foreach(def->uses, entry) {
- nir_instr *instr = (nir_instr *)entry->key;
-
- _mesa_set_remove(def->uses, entry);
- nir_foreach_src(instr, ssa_def_rewrite_uses_src, &state);
- _mesa_set_add(new_uses, instr);
+ nir_foreach_use_safe(def, use_src) {
+ nir_instr *src_parent_instr = use_src->parent_instr;
+ list_del(&use_src->use_link);
+ nir_src_copy(use_src, &new_src, mem_ctx);
+ src_add_all_uses(use_src, src_parent_instr, NULL);
}
- set_foreach(def->if_uses, entry) {
- nir_if *if_use = (nir_if *)entry->key;
-
- _mesa_set_remove(def->if_uses, entry);
- nir_src_copy(&if_use->condition, &new_src, mem_ctx);
- _mesa_set_add(new_if_uses, if_use);
+ nir_foreach_if_use_safe(def, use_src) {
+ nir_if *src_parent_if = use_src->parent_if;
+ list_del(&use_src->use_link);
+ nir_src_copy(use_src, &new_src, mem_ctx);
+ src_add_all_uses(use_src, NULL, src_parent_if);
}
}
diff --git a/mesalib/src/glsl/nir/nir.h b/mesalib/src/glsl/nir/nir.h
index 98b0ec328..697d37e95 100644
--- a/mesalib/src/glsl/nir/nir.h
+++ b/mesalib/src/glsl/nir/nir.h
@@ -30,6 +30,7 @@
#include "util/hash_table.h"
#include "../list.h"
#include "GL/gl.h" /* GLenum */
+#include "util/list.h"
#include "util/ralloc.h"
#include "util/set.h"
#include "util/bitset.h"
@@ -397,13 +398,13 @@ typedef struct {
struct nir_instr *parent_instr;
/** set of nir_instr's where this register is used (read from) */
- struct set *uses;
+ struct list_head uses;
/** set of nir_instr's where this register is defined (written to) */
- struct set *defs;
+ struct list_head defs;
/** set of nir_if's where this register is used as a condition */
- struct set *if_uses;
+ struct list_head if_uses;
} nir_register;
typedef enum {
@@ -462,10 +463,10 @@ typedef struct {
nir_instr *parent_instr;
/** set of nir_instr's where this register is used (read from) */
- struct set *uses;
+ struct list_head uses;
/** set of nir_if's where this register is used as a condition */
- struct set *if_uses;
+ struct list_head if_uses;
uint8_t num_components;
} nir_ssa_def;
@@ -481,6 +482,9 @@ typedef struct {
} nir_reg_src;
typedef struct {
+ nir_instr *parent_instr;
+ struct list_head def_link;
+
nir_register *reg;
struct nir_src *indirect; /** < NULL for no indirect offset */
unsigned base_offset;
@@ -488,8 +492,17 @@ typedef struct {
/* TODO def-use chain goes here */
} nir_reg_dest;
+struct nir_if;
+
typedef struct nir_src {
union {
+ nir_instr *parent_instr;
+ struct nir_if *parent_if;
+ };
+
+ struct list_head use_link;
+
+ union {
nir_reg_src reg;
nir_ssa_def *ssa;
};
@@ -497,6 +510,20 @@ typedef struct nir_src {
bool is_ssa;
} nir_src;
+#define NIR_SRC_INIT (nir_src) { { NULL } }
+
+#define nir_foreach_use(reg_or_ssa_def, src) \
+ list_for_each_entry(nir_src, src, &(reg_or_ssa_def)->uses, use_link)
+
+#define nir_foreach_use_safe(reg_or_ssa_def, src) \
+ list_for_each_entry_safe(nir_src, src, &(reg_or_ssa_def)->uses, use_link)
+
+#define nir_foreach_if_use(reg_or_ssa_def, src) \
+ list_for_each_entry(nir_src, src, &(reg_or_ssa_def)->if_uses, use_link)
+
+#define nir_foreach_if_use_safe(reg_or_ssa_def, src) \
+ list_for_each_entry_safe(nir_src, src, &(reg_or_ssa_def)->if_uses, use_link)
+
typedef struct {
union {
nir_reg_dest reg;
@@ -506,10 +533,18 @@ typedef struct {
bool is_ssa;
} nir_dest;
+#define NIR_DEST_INIT (nir_dest) { { { NULL } } }
+
+#define nir_foreach_def(reg, dest) \
+ list_for_each_entry(nir_dest, dest, &(reg)->defs, reg.def_link)
+
+#define nir_foreach_def_safe(reg, dest) \
+ list_for_each_entry_safe(nir_dest, dest, &(reg)->defs, reg.def_link)
+
static inline nir_src
nir_src_for_ssa(nir_ssa_def *def)
{
- nir_src src;
+ nir_src src = NIR_SRC_INIT;
src.is_ssa = true;
src.ssa = def;
@@ -520,7 +555,7 @@ nir_src_for_ssa(nir_ssa_def *def)
static inline nir_src
nir_src_for_reg(nir_register *reg)
{
- nir_src src;
+ nir_src src = NIR_SRC_INIT;
src.is_ssa = false;
src.reg.reg = reg;
@@ -543,12 +578,9 @@ nir_src_get_parent_instr(const nir_src *src)
static inline nir_dest
nir_dest_for_reg(nir_register *reg)
{
- nir_dest dest;
+ nir_dest dest = NIR_DEST_INIT;
- dest.is_ssa = false;
dest.reg.reg = reg;
- dest.reg.indirect = NULL;
- dest.reg.base_offset = 0;
return dest;
}
@@ -1207,7 +1239,7 @@ nir_block_last_instr(nir_block *block)
#define nir_foreach_instr_safe(block, instr) \
foreach_list_typed_safe(nir_instr, instr, node, &(block)->instr_list)
-typedef struct {
+typedef struct nir_if {
nir_cf_node cf_node;
nir_src condition;
@@ -1548,6 +1580,8 @@ bool nir_foreach_src(nir_instr *instr, nir_foreach_src_cb cb, void *state);
nir_const_value *nir_src_as_const_value(nir_src src);
bool nir_srcs_equal(nir_src src1, nir_src src2);
void nir_instr_rewrite_src(nir_instr *instr, nir_src *src, nir_src new_src);
+void nir_instr_move_src(nir_instr *dest_instr, nir_src *dest, nir_src *src);
+void nir_if_rewrite_condition(nir_if *if_stmt, nir_src new_src);
void nir_ssa_dest_init(nir_instr *instr, nir_dest *dest,
unsigned num_components, const char *name);
diff --git a/mesalib/src/glsl/nir/nir_builder.h b/mesalib/src/glsl/nir/nir_builder.h
index d1419ee21..9223e8380 100644
--- a/mesalib/src/glsl/nir/nir_builder.h
+++ b/mesalib/src/glsl/nir/nir_builder.h
@@ -231,8 +231,7 @@ static inline nir_ssa_def *
nir_swizzle(nir_builder *build, nir_ssa_def *src, unsigned swiz[4],
unsigned num_components, bool use_fmov)
{
- nir_alu_src alu_src;
- memset(&alu_src, 0, sizeof(alu_src));
+ nir_alu_src alu_src = { NIR_SRC_INIT };
alu_src.src = nir_src_for_ssa(src);
for (int i = 0; i < 4; i++)
alu_src.swizzle[i] = swiz[i];
@@ -251,8 +250,7 @@ nir_ssa_for_src(nir_builder *build, nir_src src, int num_components)
if (src.is_ssa && src.ssa->num_components == num_components)
return src.ssa;
- nir_alu_src alu;
- memset(&alu, 0, sizeof(alu));
+ nir_alu_src alu = { NIR_SRC_INIT };
alu.src = src;
for (int j = 0; j < 4; j++)
alu.swizzle[j] = j;
diff --git a/mesalib/src/glsl/nir/nir_from_ssa.c b/mesalib/src/glsl/nir/nir_from_ssa.c
index 6a3b141bd..67733e6da 100644
--- a/mesalib/src/glsl/nir/nir_from_ssa.c
+++ b/mesalib/src/glsl/nir/nir_from_ssa.c
@@ -37,7 +37,6 @@
struct from_ssa_state {
void *mem_ctx;
void *dead_ctx;
- struct hash_table *ssa_table;
struct hash_table *merge_node_table;
nir_instr *instr;
nir_function_impl *impl;
@@ -344,45 +343,31 @@ isolate_phi_nodes_block(nir_block *block, void *void_state)
get_parallel_copy_at_end_of_block(src->pred);
assert(pcopy);
- nir_parallel_copy_entry *entry = ralloc(state->dead_ctx,
- nir_parallel_copy_entry);
- exec_list_push_tail(&pcopy->entries, &entry->node);
-
- nir_src_copy(&entry->src, &src->src, state->dead_ctx);
- _mesa_set_add(src->src.ssa->uses, &pcopy->instr);
-
+ nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx,
+ nir_parallel_copy_entry);
nir_ssa_dest_init(&pcopy->instr, &entry->dest,
phi->dest.ssa.num_components, src->src.ssa->name);
+ exec_list_push_tail(&pcopy->entries, &entry->node);
- struct set_entry *use_entry =
- _mesa_set_search(src->src.ssa->uses, instr);
- if (use_entry)
- /* It is possible that a phi node can use the same source twice
- * but for different basic blocks. If that happens, entry will
- * be NULL because we already deleted it. This is safe
- * because, by the time the loop is done, we will have deleted
- * all of the sources of the phi from their respective use sets
- * and moved them to the parallel copy definitions.
- */
- _mesa_set_remove(src->src.ssa->uses, use_entry);
+ assert(src->src.is_ssa);
+ nir_instr_rewrite_src(&pcopy->instr, &entry->src, src->src);
- src->src.ssa = &entry->dest.ssa;
- _mesa_set_add(entry->dest.ssa.uses, instr);
+ nir_instr_rewrite_src(&phi->instr, &src->src,
+ nir_src_for_ssa(&entry->dest.ssa));
}
- nir_parallel_copy_entry *entry = ralloc(state->dead_ctx,
- nir_parallel_copy_entry);
- exec_list_push_tail(&block_pcopy->entries, &entry->node);
-
+ nir_parallel_copy_entry *entry = rzalloc(state->dead_ctx,
+ nir_parallel_copy_entry);
nir_ssa_dest_init(&block_pcopy->instr, &entry->dest,
phi->dest.ssa.num_components, phi->dest.ssa.name);
+ exec_list_push_tail(&block_pcopy->entries, &entry->node);
+
nir_ssa_def_rewrite_uses(&phi->dest.ssa,
nir_src_for_ssa(&entry->dest.ssa),
state->mem_ctx);
- entry->src.is_ssa = true;
- entry->src.ssa = &phi->dest.ssa;
- _mesa_set_add(phi->dest.ssa.uses, &block_pcopy->instr);
+ nir_instr_rewrite_src(&block_pcopy->instr, &entry->src,
+ nir_src_for_ssa(&phi->dest.ssa));
}
return true;
@@ -415,7 +400,7 @@ coalesce_phi_nodes_block(nir_block *block, void *void_state)
}
static void
-agressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
+aggressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
struct from_ssa_state *state)
{
nir_foreach_parallel_copy_entry(pcopy, entry) {
@@ -444,7 +429,7 @@ agressive_coalesce_parallel_copy(nir_parallel_copy_instr *pcopy,
}
static bool
-agressive_coalesce_block(nir_block *block, void *void_state)
+aggressive_coalesce_block(nir_block *block, void *void_state)
{
struct from_ssa_state *state = void_state;
@@ -457,7 +442,7 @@ agressive_coalesce_block(nir_block *block, void *void_state)
start_pcopy = nir_instr_as_parallel_copy(instr);
- agressive_coalesce_parallel_copy(start_pcopy, state);
+ aggressive_coalesce_parallel_copy(start_pcopy, state);
break;
}
@@ -467,17 +452,21 @@ agressive_coalesce_block(nir_block *block, void *void_state)
get_parallel_copy_at_end_of_block(block);
if (end_pcopy && end_pcopy != start_pcopy)
- agressive_coalesce_parallel_copy(end_pcopy, state);
+ aggressive_coalesce_parallel_copy(end_pcopy, state);
return true;
}
-static nir_register *
-get_register_for_ssa_def(nir_ssa_def *def, struct from_ssa_state *state)
+static bool
+rewrite_ssa_def(nir_ssa_def *def, void *void_state)
{
+ struct from_ssa_state *state = void_state;
+ nir_register *reg;
+
struct hash_entry *entry =
_mesa_hash_table_search(state->merge_node_table, def);
if (entry) {
+ /* In this case, we're part of a phi web. Use the web's register. */
merge_node *node = (merge_node *)entry->data;
/* If it doesn't have a register yet, create one. Note that all of
@@ -491,20 +480,15 @@ get_register_for_ssa_def(nir_ssa_def *def, struct from_ssa_state *state)
node->set->reg->num_array_elems = 0;
}
- return node->set->reg;
- }
-
- entry = _mesa_hash_table_search(state->ssa_table, def);
- if (entry) {
- return (nir_register *)entry->data;
+ reg = node->set->reg;
} else {
/* We leave load_const SSA values alone. They act as immediates to
* the backend. If it got coalesced into a phi, that's ok.
*/
if (def->parent_instr->type == nir_instr_type_load_const)
- return NULL;
+ return true;
- nir_register *reg = nir_local_reg_create(state->impl);
+ reg = nir_local_reg_create(state->impl);
reg->name = def->name;
reg->num_components = def->num_components;
reg->num_array_elems = 0;
@@ -516,57 +500,24 @@ get_register_for_ssa_def(nir_ssa_def *def, struct from_ssa_state *state)
*/
if (def->parent_instr->type != nir_instr_type_ssa_undef)
reg->parent_instr = def->parent_instr;
-
- _mesa_hash_table_insert(state->ssa_table, def, reg);
- return reg;
}
-}
-
-static bool
-rewrite_ssa_src(nir_src *src, void *void_state)
-{
- struct from_ssa_state *state = void_state;
- if (src->is_ssa) {
- nir_register *reg = get_register_for_ssa_def(src->ssa, state);
+ nir_ssa_def_rewrite_uses(def, nir_src_for_reg(reg), state->mem_ctx);
+ assert(list_empty(&def->uses) && list_empty(&def->if_uses));
- if (reg == NULL) {
- assert(src->ssa->parent_instr->type == nir_instr_type_load_const);
- return true;
- }
-
- memset(src, 0, sizeof *src);
- src->reg.reg = reg;
-
- /* We don't need to remove it from the uses set because that is going
- * away. We just need to add it to the one for the register. */
- _mesa_set_add(reg->uses, state->instr);
- }
-
- return true;
-}
-
-static bool
-rewrite_ssa_dest(nir_dest *dest, void *void_state)
-{
- struct from_ssa_state *state = void_state;
-
- if (dest->is_ssa) {
- nir_register *reg = get_register_for_ssa_def(&dest->ssa, state);
-
- if (reg == NULL) {
- assert(dest->ssa.parent_instr->type == nir_instr_type_load_const);
- return true;
- }
+ if (def->parent_instr->type == nir_instr_type_ssa_undef)
+ return true;
- _mesa_set_destroy(dest->ssa.uses, NULL);
- _mesa_set_destroy(dest->ssa.if_uses, NULL);
+ assert(def->parent_instr->type != nir_instr_type_load_const);
- memset(dest, 0, sizeof *dest);
- dest->reg.reg = reg;
+ /* At this point we know a priori that this SSA def is part of a
+ * nir_dest. We can use exec_node_data to get the dest pointer.
+ */
+ nir_dest *dest = exec_node_data(nir_dest, def, ssa);
- _mesa_set_add(reg->defs, state->instr);
- }
+ *dest = nir_dest_for_reg(reg);
+ dest->reg.parent_instr = state->instr;
+ list_addtail(&dest->reg.def_link, &reg->defs);
return true;
}
@@ -581,8 +532,7 @@ resolve_registers_block(nir_block *block, void *void_state)
nir_foreach_instr_safe(block, instr) {
state->instr = instr;
- nir_foreach_src(instr, rewrite_ssa_src, state);
- nir_foreach_dest(instr, rewrite_ssa_dest, state);
+ nir_foreach_ssa_def(instr, rewrite_ssa_def, state);
if (instr->type == nir_instr_type_ssa_undef ||
instr->type == nir_instr_type_phi) {
@@ -592,23 +542,6 @@ resolve_registers_block(nir_block *block, void *void_state)
}
state->instr = NULL;
- nir_if *following_if = nir_block_get_following_if(block);
- if (following_if && following_if->condition.is_ssa) {
- nir_register *reg = get_register_for_ssa_def(following_if->condition.ssa,
- state);
- if (reg) {
- memset(&following_if->condition, 0, sizeof following_if->condition);
- following_if->condition.reg.reg = reg;
-
- _mesa_set_add(reg->if_uses, following_if);
- } else {
- /* FIXME: We really shouldn't hit this. We should be doing
- * constant control flow propagation.
- */
- assert(following_if->condition.ssa->parent_instr->type == nir_instr_type_load_const);
- }
- }
-
return true;
}
@@ -853,10 +786,8 @@ nir_convert_from_ssa_impl(nir_function_impl *impl)
nir_metadata_dominance);
nir_foreach_block(impl, coalesce_phi_nodes_block, &state);
- nir_foreach_block(impl, agressive_coalesce_block, &state);
+ nir_foreach_block(impl, aggressive_coalesce_block, &state);
- state.ssa_table = _mesa_hash_table_create(NULL, _mesa_hash_pointer,
- _mesa_key_pointer_equal);
nir_foreach_block(impl, resolve_registers_block, &state);
nir_foreach_block(impl, resolve_parallel_copies_block, &state);
@@ -865,7 +796,6 @@ nir_convert_from_ssa_impl(nir_function_impl *impl)
nir_metadata_dominance);
/* Clean up dead instructions and the hash tables */
- _mesa_hash_table_destroy(state.ssa_table, NULL);
_mesa_hash_table_destroy(state.merge_node_table, NULL);
ralloc_free(state.dead_ctx);
}
diff --git a/mesalib/src/glsl/nir/nir_intrinsics.h b/mesalib/src/glsl/nir/nir_intrinsics.h
index 8e28765c1..10192c531 100644
--- a/mesalib/src/glsl/nir/nir_intrinsics.h
+++ b/mesalib/src/glsl/nir/nir_intrinsics.h
@@ -68,6 +68,13 @@ INTRINSIC(interp_var_at_offset, 1, ARR(2), true, 0, 1, 0,
#define BARRIER(name) INTRINSIC(name, 0, ARR(), false, 0, 0, 0, 0)
BARRIER(discard)
+
+/*
+ * Memory barrier with semantics analogous to the memoryBarrier() GLSL
+ * intrinsic.
+ */
+BARRIER(memory_barrier)
+
/** A conditional discard, with a single boolean source. */
INTRINSIC(discard_if, 1, ARR(1), false, 0, 0, 0, 0)
@@ -89,6 +96,33 @@ ATOMIC(inc, 0)
ATOMIC(dec, 0)
ATOMIC(read, NIR_INTRINSIC_CAN_ELIMINATE)
+/*
+ * Image load, store and atomic intrinsics.
+ *
+ * All image intrinsics take an image target passed as a nir_variable. Image
+ * variables contain a number of memory and layout qualifiers that influence
+ * the semantics of the intrinsic.
+ *
+ * All image intrinsics take a four-coordinate vector and a sample index as
+ * first two sources, determining the location within the image that will be
+ * accessed by the intrinsic. Components not applicable to the image target
+ * in use are undefined. Image store takes an additional four-component
+ * argument with the value to be written, and image atomic operations take
+ * either one or two additional scalar arguments with the same meaning as in
+ * the ARB_shader_image_load_store specification.
+ */
+INTRINSIC(image_load, 2, ARR(4, 1), true, 4, 1, 0,
+ NIR_INTRINSIC_CAN_ELIMINATE)
+INTRINSIC(image_store, 3, ARR(4, 1, 4), false, 0, 1, 0, 0)
+INTRINSIC(image_atomic_add, 3, ARR(4, 1, 1), true, 1, 1, 0, 0)
+INTRINSIC(image_atomic_min, 3, ARR(4, 1, 1), true, 1, 1, 0, 0)
+INTRINSIC(image_atomic_max, 3, ARR(4, 1, 1), true, 1, 1, 0, 0)
+INTRINSIC(image_atomic_and, 3, ARR(4, 1, 1), true, 1, 1, 0, 0)
+INTRINSIC(image_atomic_or, 3, ARR(4, 1, 1), true, 1, 1, 0, 0)
+INTRINSIC(image_atomic_xor, 3, ARR(4, 1, 1), true, 1, 1, 0, 0)
+INTRINSIC(image_atomic_exchange, 3, ARR(4, 1, 1), true, 1, 1, 0, 0)
+INTRINSIC(image_atomic_comp_swap, 4, ARR(4, 1, 1, 1), true, 1, 1, 0, 0)
+
#define SYSTEM_VALUE(name, components) \
INTRINSIC(load_##name, 0, ARR(), true, components, 0, 0, \
NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER)
diff --git a/mesalib/src/glsl/nir/nir_lower_atomics.c b/mesalib/src/glsl/nir/nir_lower_atomics.c
index e82df0169..f6f89020f 100644
--- a/mesalib/src/glsl/nir/nir_lower_atomics.c
+++ b/mesalib/src/glsl/nir/nir_lower_atomics.c
@@ -78,7 +78,8 @@ lower_instr(nir_intrinsic_instr *instr, nir_function_impl *impl)
nir_deref_as_array(instr->variables[0]->deref.child);
assert(deref_array->deref.child == NULL);
- offset_const->value.u[0] += deref_array->base_offset;
+ offset_const->value.u[0] +=
+ deref_array->base_offset * ATOMIC_COUNTER_SIZE;
if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
nir_load_const_instr *atomic_counter_size =
diff --git a/mesalib/src/glsl/nir/nir_lower_locals_to_regs.c b/mesalib/src/glsl/nir/nir_lower_locals_to_regs.c
index bc6a3d320..28fdec50e 100644
--- a/mesalib/src/glsl/nir/nir_lower_locals_to_regs.c
+++ b/mesalib/src/glsl/nir/nir_lower_locals_to_regs.c
@@ -269,18 +269,16 @@ lower_locals_to_regs_block(nir_block *block, void *void_state)
static nir_block *
compute_reg_usedef_lca(nir_register *reg)
{
- struct set_entry *entry;
nir_block *lca = NULL;
- set_foreach(reg->defs, entry)
- lca = nir_dominance_lca(lca, ((nir_instr *)entry->key)->block);
+ list_for_each_entry(nir_dest, def_dest, &reg->defs, reg.def_link)
+ lca = nir_dominance_lca(lca, def_dest->reg.parent_instr->block);
- set_foreach(reg->uses, entry)
- lca = nir_dominance_lca(lca, ((nir_instr *)entry->key)->block);
+ list_for_each_entry(nir_src, use_src, &reg->uses, use_link)
+ lca = nir_dominance_lca(lca, use_src->parent_instr->block);
- set_foreach(reg->if_uses, entry) {
- nir_if *if_stmt = (nir_if *)entry->key;
- nir_cf_node *prev_node = nir_cf_node_prev(&if_stmt->cf_node);
+ list_for_each_entry(nir_src, use_src, &reg->if_uses, use_link) {
+ nir_cf_node *prev_node = nir_cf_node_prev(&use_src->parent_if->cf_node);
assert(prev_node->type == nir_cf_node_block);
lca = nir_dominance_lca(lca, nir_cf_node_as_block(prev_node));
}
diff --git a/mesalib/src/glsl/nir/nir_lower_samplers.cpp b/mesalib/src/glsl/nir/nir_lower_samplers.cpp
index cf8ab8325..7a0b0a09f 100644
--- a/mesalib/src/glsl/nir/nir_lower_samplers.cpp
+++ b/mesalib/src/glsl/nir/nir_lower_samplers.cpp
@@ -70,44 +70,45 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr
case nir_deref_type_array: {
nir_deref_array *deref_array = nir_deref_as_array(deref->child);
+ assert(deref_array->deref_array_type != nir_deref_array_type_wildcard);
+
+ if (deref_array->deref.child) {
+ ralloc_asprintf_append(&name, "[%u]",
+ deref_array->deref_array_type == nir_deref_array_type_direct ?
+ deref_array->base_offset : 0);
+ } else {
+ assert(deref->child->type->base_type == GLSL_TYPE_SAMPLER);
+ instr->sampler_index = deref_array->base_offset;
+ }
+
/* XXX: We're assuming here that the indirect is the last array
* thing we have. This should be ok for now as we don't support
* arrays_of_arrays yet.
*/
-
- instr->sampler_index *= glsl_get_length(deref->type);
- switch (deref_array->deref_array_type) {
- case nir_deref_array_type_direct:
- instr->sampler_index += deref_array->base_offset;
- if (deref_array->deref.child)
- ralloc_asprintf_append(&name, "[%u]", deref_array->base_offset);
- break;
- case nir_deref_array_type_indirect: {
- instr->src = reralloc(instr, instr->src, nir_tex_src,
- instr->num_srcs + 1);
- memset(&instr->src[instr->num_srcs], 0, sizeof *instr->src);
+ if (deref_array->deref_array_type == nir_deref_array_type_indirect) {
+ /* First, we have to resize the array of texture sources */
+ nir_tex_src *new_srcs = rzalloc_array(instr, nir_tex_src,
+ instr->num_srcs + 1);
+
+ for (unsigned i = 0; i < instr->num_srcs; i++) {
+ new_srcs[i].src_type = instr->src[i].src_type;
+ nir_instr_move_src(&instr->instr, &new_srcs[i].src,
+ &instr->src[i].src);
+ }
+
+ ralloc_free(instr->src);
+ instr->src = new_srcs;
+
+ /* Now we can go ahead and move the source over to being a
+ * first-class texture source.
+ */
instr->src[instr->num_srcs].src_type = nir_tex_src_sampler_offset;
instr->num_srcs++;
-
- nir_instr_rewrite_src(&instr->instr,
- &instr->src[instr->num_srcs - 1].src,
- deref_array->indirect);
+ nir_instr_move_src(&instr->instr,
+ &instr->src[instr->num_srcs - 1].src,
+ &deref_array->indirect);
instr->sampler_array_size = glsl_get_length(deref->type);
-
- nir_src empty;
- memset(&empty, 0, sizeof empty);
- nir_instr_rewrite_src(&instr->instr, &deref_array->indirect, empty);
-
- if (deref_array->deref.child)
- ralloc_strcat(&name, "[0]");
- break;
- }
-
- case nir_deref_array_type_wildcard:
- unreachable("Cannot copy samplers");
- default:
- unreachable("Invalid deref array type");
}
break;
}
diff --git a/mesalib/src/glsl/nir/nir_lower_tex_projector.c b/mesalib/src/glsl/nir/nir_lower_tex_projector.c
index 6b0e9c340..357131cd7 100644
--- a/mesalib/src/glsl/nir/nir_lower_tex_projector.c
+++ b/mesalib/src/glsl/nir/nir_lower_tex_projector.c
@@ -109,12 +109,12 @@ nir_lower_tex_projector_block(nir_block *block, void *void_state)
/* Now move the later tex sources down the array so that the projector
* disappears.
*/
- nir_src dead;
- memset(&dead, 0, sizeof dead);
- nir_instr_rewrite_src(&tex->instr, &tex->src[proj_index].src, dead);
- memmove(&tex->src[proj_index],
- &tex->src[proj_index + 1],
- (tex->num_srcs - proj_index) * sizeof(*tex->src));
+ nir_instr_rewrite_src(&tex->instr, &tex->src[proj_index].src,
+ NIR_SRC_INIT);
+ for (int i = proj_index + 1; i < tex->num_srcs; i++) {
+ tex->src[i-1].src_type = tex->src[i].src_type;
+ nir_instr_move_src(&tex->instr, &tex->src[i-1].src, &tex->src[i].src);
+ }
tex->num_srcs--;
}
diff --git a/mesalib/src/glsl/nir/nir_lower_to_source_mods.c b/mesalib/src/glsl/nir/nir_lower_to_source_mods.c
index 7b4a0f657..94c7e36d4 100644
--- a/mesalib/src/glsl/nir/nir_lower_to_source_mods.c
+++ b/mesalib/src/glsl/nir/nir_lower_to_source_mods.c
@@ -88,8 +88,8 @@ nir_lower_to_source_mods_block(nir_block *block, void *state)
alu->src[i].swizzle[j] = parent->src[0].swizzle[alu->src[i].swizzle[j]];
}
- if (parent->dest.dest.ssa.uses->entries == 0 &&
- parent->dest.dest.ssa.if_uses->entries == 0)
+ if (list_empty(&parent->dest.dest.ssa.uses) &&
+ list_empty(&parent->dest.dest.ssa.if_uses))
nir_instr_remove(&parent->instr);
}
@@ -131,13 +131,13 @@ nir_lower_to_source_mods_block(nir_block *block, void *state)
if (nir_op_infos[alu->op].output_type != nir_type_float)
continue;
- if (alu->dest.dest.ssa.if_uses->entries != 0)
+ if (!list_empty(&alu->dest.dest.ssa.if_uses))
continue;
bool all_children_are_sat = true;
- struct set_entry *entry;
- set_foreach(alu->dest.dest.ssa.uses, entry) {
- const nir_instr *child = entry->key;
+ nir_foreach_use(&alu->dest.dest.ssa, child_src) {
+ assert(child_src->is_ssa);
+ nir_instr *child = child_src->parent_instr;
if (child->type != nir_instr_type_alu) {
all_children_are_sat = false;
continue;
@@ -161,8 +161,12 @@ nir_lower_to_source_mods_block(nir_block *block, void *state)
alu->dest.saturate = true;
- set_foreach(alu->dest.dest.ssa.uses, entry) {
- nir_alu_instr *child_alu = nir_instr_as_alu((nir_instr *)entry->key);
+ nir_foreach_use(&alu->dest.dest.ssa, child_src) {
+ assert(child_src->is_ssa);
+ nir_instr *child = child_src->parent_instr;
+ assert(child->type == nir_instr_type_alu);
+ nir_alu_instr *child_alu = nir_instr_as_alu(child);
+
child_alu->op = nir_op_fmov;
child_alu->dest.saturate = false;
/* We could propagate the dest of our instruction to the
diff --git a/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c b/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c
index bb60f4601..ccb8f99df 100644
--- a/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c
+++ b/mesalib/src/glsl/nir/nir_lower_vars_to_ssa.c
@@ -567,10 +567,11 @@ add_phi_sources(nir_block *block, nir_block *pred,
nir_phi_src *src = ralloc(phi, nir_phi_src);
src->pred = pred;
+ src->src.parent_instr = &phi->instr;
src->src.is_ssa = true;
src->src.ssa = get_ssa_def_for_block(node, pred, state);
- _mesa_set_add(src->src.ssa->uses, instr);
+ list_addtail(&src->src.use_link, &src->src.ssa->uses);
exec_list_push_tail(&phi->srcs, &src->node);
}
diff --git a/mesalib/src/glsl/nir/nir_opcodes.py b/mesalib/src/glsl/nir/nir_opcodes.py
index 264806f5d..56e96d912 100644
--- a/mesalib/src/glsl/nir/nir_opcodes.py
+++ b/mesalib/src/glsl/nir/nir_opcodes.py
@@ -153,8 +153,6 @@ unop("fsat", tfloat, "(src0 > 1.0f) ? 1.0f : ((src0 <= 0.0f) ? 0.0f : src0)")
unop("frcp", tfloat, "1.0f / src0")
unop("frsq", tfloat, "1.0f / sqrtf(src0)")
unop("fsqrt", tfloat, "sqrtf(src0)")
-unop("fexp", tfloat, "expf(src0)") # < e^x
-unop("flog", tfloat, "logf(src0)") # log base e
unop("fexp2", tfloat, "exp2f(src0)")
unop("flog2", tfloat, "log2f(src0)")
unop_convert("f2i", tfloat, tint, "src0") # Float-to-integer conversion.
diff --git a/mesalib/src/glsl/nir/nir_opt_algebraic.py b/mesalib/src/glsl/nir/nir_opt_algebraic.py
index 2a2b9561e..fa039222f 100644
--- a/mesalib/src/glsl/nir/nir_opt_algebraic.py
+++ b/mesalib/src/glsl/nir/nir_opt_algebraic.py
@@ -83,24 +83,37 @@ optimizations = [
# Comparison simplifications
(('inot', ('flt', a, b)), ('fge', a, b)),
(('inot', ('fge', a, b)), ('flt', a, b)),
+ (('inot', ('feq', a, b)), ('fne', a, b)),
+ (('inot', ('fne', a, b)), ('feq', a, b)),
(('inot', ('ilt', a, b)), ('ige', a, b)),
(('inot', ('ige', a, b)), ('ilt', a, b)),
+ (('inot', ('ieq', a, b)), ('ine', a, b)),
+ (('inot', ('ine', a, b)), ('ieq', a, b)),
(('fge', ('fneg', ('fabs', a)), 0.0), ('feq', a, 0.0)),
(('bcsel', ('flt', a, b), a, b), ('fmin', a, b)),
(('bcsel', ('flt', a, b), b, a), ('fmax', a, b)),
(('bcsel', ('inot', 'a@bool'), b, c), ('bcsel', a, c, b)),
(('bcsel', a, ('bcsel', a, b, c), d), ('bcsel', a, b, d)),
+ (('fmin', a, a), a),
+ (('fmax', a, a), a),
+ (('imin', a, a), a),
+ (('imax', a, a), a),
+ (('umin', a, a), a),
+ (('umax', a, a), a),
(('fmin', ('fmax', a, 0.0), 1.0), ('fsat', a), '!options->lower_fsat'),
(('fsat', a), ('fmin', ('fmax', a, 0.0), 1.0), 'options->lower_fsat'),
(('fsat', ('fsat', a)), ('fsat', a)),
(('fmin', ('fmax', ('fmin', ('fmax', a, 0.0), 1.0), 0.0), 1.0), ('fmin', ('fmax', a, 0.0), 1.0)),
(('ior', ('flt', a, b), ('flt', a, c)), ('flt', a, ('fmax', b, c))),
+ (('ior', ('flt', a, c), ('flt', b, c)), ('flt', ('fmin', a, b), c)),
(('ior', ('fge', a, b), ('fge', a, c)), ('fge', a, ('fmin', b, c))),
+ (('ior', ('fge', a, c), ('fge', b, c)), ('fge', ('fmax', a, b), c)),
(('slt', a, b), ('b2f', ('flt', a, b)), 'options->lower_scmp'),
(('sge', a, b), ('b2f', ('fge', a, b)), 'options->lower_scmp'),
(('seq', a, b), ('b2f', ('feq', a, b)), 'options->lower_scmp'),
(('sne', a, b), ('b2f', ('fne', a, b)), 'options->lower_scmp'),
# Emulating booleans
+ (('imul', ('b2i', a), ('b2i', b)), ('b2i', ('iand', a, b))),
(('fmul', ('b2f', a), ('b2f', b)), ('b2f', ('iand', a, b))),
(('fsat', ('fadd', ('b2f', a), ('b2f', b))), ('b2f', ('ior', a, b))),
(('iand', 'a@bool', 1.0), ('b2f', a)),
@@ -136,36 +149,23 @@ optimizations = [
(('ushr', a, 0), a),
# Exponential/logarithmic identities
(('fexp2', ('flog2', a)), a), # 2^lg2(a) = a
- (('fexp', ('flog', a)), a), # e^ln(a) = a
(('flog2', ('fexp2', a)), a), # lg2(2^a) = a
- (('flog', ('fexp', a)), a), # ln(e^a) = a
(('fpow', a, b), ('fexp2', ('fmul', ('flog2', a), b)), 'options->lower_fpow'), # a^b = 2^(lg2(a)*b)
(('fexp2', ('fmul', ('flog2', a), b)), ('fpow', a, b), '!options->lower_fpow'), # 2^(lg2(a)*b) = a^b
- (('fexp', ('fmul', ('flog', a), b)), ('fpow', a, b), '!options->lower_fpow'), # e^(ln(a)*b) = a^b
(('fpow', a, 1.0), a),
(('fpow', a, 2.0), ('fmul', a, a)),
(('fpow', a, 4.0), ('fmul', ('fmul', a, a), ('fmul', a, a))),
(('fpow', 2.0, a), ('fexp2', a)),
(('fsqrt', ('fexp2', a)), ('fexp2', ('fmul', 0.5, a))),
- (('fsqrt', ('fexp', a)), ('fexp', ('fmul', 0.5, a))),
(('frcp', ('fexp2', a)), ('fexp2', ('fneg', a))),
- (('frcp', ('fexp', a)), ('fexp', ('fneg', a))),
(('frsq', ('fexp2', a)), ('fexp2', ('fmul', -0.5, a))),
- (('frsq', ('fexp', a)), ('fexp', ('fmul', -0.5, a))),
(('flog2', ('fsqrt', a)), ('fmul', 0.5, ('flog2', a))),
- (('flog', ('fsqrt', a)), ('fmul', 0.5, ('flog', a))),
(('flog2', ('frcp', a)), ('fneg', ('flog2', a))),
- (('flog', ('frcp', a)), ('fneg', ('flog', a))),
(('flog2', ('frsq', a)), ('fmul', -0.5, ('flog2', a))),
- (('flog', ('frsq', a)), ('fmul', -0.5, ('flog', a))),
(('flog2', ('fpow', a, b)), ('fmul', b, ('flog2', a))),
- (('flog', ('fpow', a, b)), ('fmul', b, ('flog', a))),
(('fadd', ('flog2', a), ('flog2', b)), ('flog2', ('fmul', a, b))),
- (('fadd', ('flog', a), ('flog', b)), ('flog', ('fmul', a, b))),
(('fadd', ('flog2', a), ('fneg', ('flog2', b))), ('flog2', ('fdiv', a, b))),
- (('fadd', ('flog', a), ('fneg', ('flog', b))), ('flog', ('fdiv', a, b))),
(('fmul', ('fexp2', a), ('fexp2', b)), ('fexp2', ('fadd', a, b))),
- (('fmul', ('fexp', a), ('fexp', b)), ('fexp', ('fadd', a, b))),
# Division and reciprocal
(('fdiv', 1.0, a), ('frcp', a)),
(('frcp', ('frcp', a)), a),
@@ -187,6 +187,7 @@ optimizations = [
(('fcsel', a, b, b), b),
# Conversions
+ (('i2b', ('b2i', a)), a),
(('f2i', ('ftrunc', a)), ('f2i', a)),
(('f2u', ('ftrunc', a)), ('f2u', a)),
diff --git a/mesalib/src/glsl/nir/nir_opt_copy_propagate.c b/mesalib/src/glsl/nir/nir_opt_copy_propagate.c
index ee78e5aa0..71367d001 100644
--- a/mesalib/src/glsl/nir/nir_opt_copy_propagate.c
+++ b/mesalib/src/glsl/nir/nir_opt_copy_propagate.c
@@ -93,62 +93,6 @@ is_swizzleless_move(nir_alu_instr *instr)
}
}
-typedef struct {
- nir_ssa_def *def;
- bool found;
-} search_def_state;
-
-static bool
-search_def(nir_src *src, void *_state)
-{
- search_def_state *state = (search_def_state *) _state;
-
- if (src->is_ssa && src->ssa == state->def)
- state->found = true;
-
- return true;
-}
-
-static void
-rewrite_src_instr(nir_src *src, nir_ssa_def *new_def, nir_instr *parent_instr)
-{
- nir_ssa_def *old_def = src->ssa;
-
- src->ssa = new_def;
-
- /*
- * The instruction could still use the old definition in one of its other
- * sources, so only remove the instruction from the uses if there are no
- * more uses left.
- */
-
- search_def_state search_state;
- search_state.def = old_def;
- search_state.found = false;
- nir_foreach_src(parent_instr, search_def, &search_state);
- if (!search_state.found) {
- struct set_entry *entry = _mesa_set_search(old_def->uses, parent_instr);
- assert(entry);
- _mesa_set_remove(old_def->uses, entry);
- }
-
- _mesa_set_add(new_def->uses, parent_instr);
-}
-
-static void
-rewrite_src_if(nir_if *if_stmt, nir_ssa_def *new_def)
-{
- nir_ssa_def *old_def = if_stmt->condition.ssa;
-
- if_stmt->condition.ssa = new_def;
-
- struct set_entry *entry = _mesa_set_search(old_def->if_uses, if_stmt);
- assert(entry);
- _mesa_set_remove(old_def->if_uses, entry);
-
- _mesa_set_add(new_def->if_uses, if_stmt);
-}
-
static bool
copy_prop_src(nir_src *src, nir_instr *parent_instr, nir_if *parent_if)
{
@@ -178,10 +122,14 @@ copy_prop_src(nir_src *src, nir_instr *parent_instr, nir_if *parent_if)
return false;
}
- if (parent_instr)
- rewrite_src_instr(src, alu_instr->src[0].src.ssa, parent_instr);
- else
- rewrite_src_if(parent_if, alu_instr->src[0].src.ssa);
+ if (parent_instr) {
+ nir_instr_rewrite_src(parent_instr, src,
+ nir_src_for_ssa(alu_instr->src[0].src.ssa));
+ } else {
+ assert(src == &parent_if->condition);
+ nir_if_rewrite_condition(parent_if,
+ nir_src_for_ssa(alu_instr->src[0].src.ssa));
+ }
return true;
}
@@ -234,7 +182,8 @@ copy_prop_alu_src(nir_alu_instr *parent_alu_instr, unsigned index)
for (unsigned i = 0; i < 4; i++)
src->swizzle[i] = new_swizzle[i];
- rewrite_src_instr(&src->src, def, &parent_alu_instr->instr);
+ nir_instr_rewrite_src(&parent_alu_instr->instr, &src->src,
+ nir_src_for_ssa(def));
return true;
}
diff --git a/mesalib/src/glsl/nir/nir_opt_gcm.c b/mesalib/src/glsl/nir/nir_opt_gcm.c
index b4f5fd3d5..44068bf37 100644
--- a/mesalib/src/glsl/nir/nir_opt_gcm.c
+++ b/mesalib/src/glsl/nir/nir_opt_gcm.c
@@ -279,9 +279,8 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
nir_block *lca = NULL;
- struct set_entry *entry;
- set_foreach(def->uses, entry) {
- nir_instr *use_instr = (nir_instr *)entry->key;
+ nir_foreach_use(def, use_src) {
+ nir_instr *use_instr = use_src->parent_instr;
gcm_schedule_late_instr(use_instr, state);
@@ -304,8 +303,8 @@ gcm_schedule_late_def(nir_ssa_def *def, void *void_state)
}
}
- set_foreach(def->if_uses, entry) {
- nir_if *if_stmt = (nir_if *)entry->key;
+ nir_foreach_if_use(def, use_src) {
+ nir_if *if_stmt = use_src->parent_if;
/* For if statements, we consider the block to be the one immediately
* preceding the if CF node.
@@ -377,9 +376,8 @@ gcm_place_instr(nir_instr *instr, struct gcm_state *state);
static bool
gcm_place_instr_def(nir_ssa_def *def, void *state)
{
- struct set_entry *entry;
- set_foreach(def->uses, entry)
- gcm_place_instr((nir_instr *)entry->key, state);
+ nir_foreach_use(def, use_src)
+ gcm_place_instr(use_src->parent_instr, state);
return false;
}
diff --git a/mesalib/src/glsl/nir/nir_opt_global_to_local.c b/mesalib/src/glsl/nir/nir_opt_global_to_local.c
index 00db37ba7..bccb45b62 100644
--- a/mesalib/src/glsl/nir/nir_opt_global_to_local.c
+++ b/mesalib/src/glsl/nir/nir_opt_global_to_local.c
@@ -34,9 +34,8 @@ global_to_local(nir_register *reg)
assert(reg->is_global);
- struct set_entry *entry;
- set_foreach(reg->defs, entry) {
- nir_instr *instr = (nir_instr *) entry->key;
+ nir_foreach_def(reg, def_dest) {
+ nir_instr *instr = def_dest->reg.parent_instr;
nir_function_impl *instr_impl =
nir_cf_node_get_function(&instr->block->cf_node);
if (impl != NULL) {
@@ -47,8 +46,8 @@ global_to_local(nir_register *reg)
}
}
- set_foreach(reg->uses, entry) {
- nir_instr *instr = (nir_instr *) entry->key;
+ nir_foreach_use(reg, use_src) {
+ nir_instr *instr = use_src->parent_instr;
nir_function_impl *instr_impl =
nir_cf_node_get_function(&instr->block->cf_node);
if (impl != NULL) {
@@ -59,8 +58,8 @@ global_to_local(nir_register *reg)
}
}
- set_foreach(reg->if_uses, entry) {
- nir_if *if_stmt = (nir_if *) entry->key;
+ nir_foreach_if_use(reg, use_src) {
+ nir_if *if_stmt = use_src->parent_if;
nir_function_impl *if_impl = nir_cf_node_get_function(&if_stmt->cf_node);
if (impl != NULL) {
if (impl != if_impl)
diff --git a/mesalib/src/glsl/nir/nir_opt_peephole_ffma.c b/mesalib/src/glsl/nir/nir_opt_peephole_ffma.c
index 9d5646fe6..b430eac8e 100644
--- a/mesalib/src/glsl/nir/nir_opt_peephole_ffma.c
+++ b/mesalib/src/glsl/nir/nir_opt_peephole_ffma.c
@@ -41,12 +41,11 @@ struct peephole_ffma_state {
static inline bool
are_all_uses_fadd(nir_ssa_def *def)
{
- if (def->if_uses->entries > 0)
+ if (!list_empty(&def->if_uses))
return false;
- struct set_entry *use_iter;
- set_foreach(def->uses, use_iter) {
- nir_instr *use_instr = (nir_instr *)use_iter->key;
+ nir_foreach_use(def, use_src) {
+ nir_instr *use_instr = use_src->parent_instr;
if (use_instr->type != nir_instr_type_alu)
return false;
@@ -220,7 +219,7 @@ nir_opt_peephole_ffma_block(nir_block *block, void *void_state)
state->mem_ctx);
nir_instr_insert_before(&add->instr, &ffma->instr);
- assert(add->dest.dest.ssa.uses->entries == 0);
+ assert(list_empty(&add->dest.dest.ssa.uses));
nir_instr_remove(&add->instr);
state->progress = true;
diff --git a/mesalib/src/glsl/nir/nir_opt_peephole_select.c b/mesalib/src/glsl/nir/nir_opt_peephole_select.c
index f400cfd66..82c65bb44 100644
--- a/mesalib/src/glsl/nir/nir_opt_peephole_select.c
+++ b/mesalib/src/glsl/nir/nir_opt_peephole_select.c
@@ -98,15 +98,13 @@ block_check_for_allowed_instrs(nir_block *block)
return false;
/* It cannot have any if-uses */
- if (mov->dest.dest.ssa.if_uses->entries != 0)
+ if (!list_empty(&mov->dest.dest.ssa.if_uses))
return false;
/* The only uses of this definition must be phi's in the successor */
- struct set_entry *entry;
- set_foreach(mov->dest.dest.ssa.uses, entry) {
- const nir_instr *dest_instr = entry->key;
- if (dest_instr->type != nir_instr_type_phi ||
- dest_instr->block != block->successors[0])
+ nir_foreach_use(&mov->dest.dest.ssa, use) {
+ if (use->parent_instr->type != nir_instr_type_phi ||
+ use->parent_instr->block != block->successors[0])
return false;
}
break;
diff --git a/mesalib/src/glsl/nir/nir_search.c b/mesalib/src/glsl/nir/nir_search.c
index 5ba016085..0c4e48ce9 100644
--- a/mesalib/src/glsl/nir/nir_search.c
+++ b/mesalib/src/glsl/nir/nir_search.c
@@ -73,6 +73,14 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
{
uint8_t new_swizzle[4];
+ /* If the source is an explicitly sized source, then we need to reset
+ * both the number of components and the swizzle.
+ */
+ if (nir_op_infos[instr->op].input_sizes[src] != 0) {
+ num_components = nir_op_infos[instr->op].input_sizes[src];
+ swizzle = identity_swizzle;
+ }
+
for (int i = 0; i < num_components; ++i)
new_swizzle[i] = instr->src[src].swizzle[swizzle[i]];
@@ -90,6 +98,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src,
case nir_search_value_variable: {
nir_search_variable *var = nir_search_value_as_variable(value);
+ assert(var->variable < NIR_SEARCH_MAX_VARIABLES);
if (state->variables_seen & (1 << var->variable)) {
if (!nir_srcs_equal(state->variables[var->variable].src,
@@ -198,16 +207,13 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
}
}
+ /* Stash off the current variables_seen bitmask. This way we can
+ * restore it prior to matching in the commutative case below.
+ */
+ unsigned variables_seen_stash = state->variables_seen;
+
bool matched = true;
for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
- /* If the source is an explicitly sized source, then we need to reset
- * both the number of components and the swizzle.
- */
- if (nir_op_infos[instr->op].input_sizes[i] != 0) {
- num_components = nir_op_infos[instr->op].input_sizes[i];
- swizzle = identity_swizzle;
- }
-
if (!match_value(expr->srcs[i], instr, i, num_components,
swizzle, state)) {
matched = false;
@@ -220,6 +226,13 @@ match_expression(const nir_search_expression *expr, nir_alu_instr *instr,
if (nir_op_infos[instr->op].algebraic_properties & NIR_OP_IS_COMMUTATIVE) {
assert(nir_op_infos[instr->op].num_inputs == 2);
+
+ /* Restore the variables_seen bitmask. If we don't do this, then we
+ * could end up with an erroneous failure due to variables found in the
+ * first match attempt above not matching those in the second.
+ */
+ state->variables_seen = variables_seen_stash;
+
if (!match_value(expr->srcs[0], instr, 1, num_components,
swizzle, state))
return false;
@@ -276,7 +289,7 @@ construct_value(const nir_search_value *value, nir_alu_type type,
const nir_search_variable *var = nir_search_value_as_variable(value);
assert(state->variables_seen & (1 << var->variable));
- nir_alu_src val;
+ nir_alu_src val = { NIR_SRC_INIT };
nir_alu_src_copy(&val, &state->variables[var->variable], mem_ctx);
assert(!var->is_constant);
diff --git a/mesalib/src/glsl/nir/nir_to_ssa.c b/mesalib/src/glsl/nir/nir_to_ssa.c
index 53ff54766..a3c35fa04 100644
--- a/mesalib/src/glsl/nir/nir_to_ssa.c
+++ b/mesalib/src/glsl/nir/nir_to_ssa.c
@@ -89,9 +89,8 @@ insert_phi_nodes(nir_function_impl *impl)
w_start = w_end = 0;
iter_count++;
- struct set_entry *entry;
- set_foreach(reg->defs, entry) {
- nir_instr *def = (nir_instr *) entry->key;
+ nir_foreach_def(reg, dest) {
+ nir_instr *def = dest->reg.parent_instr;
if (work[def->block->index] < iter_count)
W[w_end++] = def->block;
work[def->block->index] = iter_count;
@@ -99,6 +98,7 @@ insert_phi_nodes(nir_function_impl *impl)
while (w_start != w_end) {
nir_block *cur = W[w_start++];
+ struct set_entry *entry;
set_foreach(cur->dom_frontier, entry) {
nir_block *next = (nir_block *) entry->key;
@@ -190,13 +190,12 @@ rewrite_use(nir_src *src, void *_state)
if (state->states[index].stack == NULL)
return true;
- src->is_ssa = true;
- src->ssa = get_ssa_src(src->reg.reg, state);
-
+ nir_ssa_def *def = get_ssa_src(src->reg.reg, state);
if (state->parent_instr)
- _mesa_set_add(src->ssa->uses, state->parent_instr);
+ nir_instr_rewrite_src(state->parent_instr, src, nir_src_for_ssa(def));
else
- _mesa_set_add(src->ssa->if_uses, state->parent_if);
+ nir_if_rewrite_condition(state->parent_if, nir_src_for_ssa(def));
+
return true;
}
@@ -219,6 +218,7 @@ rewrite_def_forwards(nir_dest *dest, void *_state)
name = ralloc_asprintf(state->mem_ctx, "%s_%u", dest->reg.reg->name,
state->states[index].num_defs);
+ list_del(&dest->reg.def_link);
nir_ssa_dest_init(state->parent_instr, dest, reg->num_components, name);
/* push our SSA destination on the stack */
@@ -270,6 +270,7 @@ rewrite_alu_instr_forward(nir_alu_instr *instr, rewrite_state *state)
reg->name, state->states[index].num_defs);
instr->dest.write_mask = (1 << num_components) - 1;
+ list_del(&instr->dest.dest.reg.def_link);
nir_ssa_dest_init(&instr->instr, &instr->dest.dest, num_components, name);
if (nir_op_infos[instr->op].output_size == 0) {
@@ -484,7 +485,7 @@ init_rewrite_state(nir_function_impl *impl, rewrite_state *state)
* called after phi nodes are inserted so we can count phi node
* definitions too.
*/
- unsigned stack_size = reg->defs->entries;
+ unsigned stack_size = list_length(&reg->defs);
state->states[reg->index].stack = ralloc_array(state->states,
nir_ssa_def *,
diff --git a/mesalib/src/glsl/nir/nir_validate.c b/mesalib/src/glsl/nir/nir_validate.c
index a7aa79837..da92ed904 100644
--- a/mesalib/src/glsl/nir/nir_validate.c
+++ b/mesalib/src/glsl/nir/nir_validate.c
@@ -97,50 +97,47 @@ typedef struct {
static void validate_src(nir_src *src, validate_state *state);
static void
-validate_reg_src(nir_reg_src *src, validate_state *state)
+validate_reg_src(nir_src *src, validate_state *state)
{
- assert(src->reg != NULL);
+ assert(src->reg.reg != NULL);
struct hash_entry *entry;
- entry = _mesa_hash_table_search(state->regs, src->reg);
+ entry = _mesa_hash_table_search(state->regs, src->reg.reg);
assert(entry);
reg_validate_state *reg_state = (reg_validate_state *) entry->data;
if (state->instr) {
- _mesa_set_add(reg_state->uses, state->instr);
-
- assert(_mesa_set_search(src->reg->uses, state->instr));
+ _mesa_set_add(reg_state->uses, src);
} else {
assert(state->if_stmt);
- _mesa_set_add(reg_state->if_uses, state->if_stmt);
-
- assert(_mesa_set_search(src->reg->if_uses, state->if_stmt));
+ _mesa_set_add(reg_state->if_uses, src);
}
- if (!src->reg->is_global) {
+ if (!src->reg.reg->is_global) {
assert(reg_state->where_defined == state->impl &&
"using a register declared in a different function");
}
- assert((src->reg->num_array_elems == 0 ||
- src->base_offset < src->reg->num_array_elems) &&
+ assert((src->reg.reg->num_array_elems == 0 ||
+ src->reg.base_offset < src->reg.reg->num_array_elems) &&
"definitely out-of-bounds array access");
- if (src->indirect) {
- assert(src->reg->num_array_elems != 0);
- assert((src->indirect->is_ssa || src->indirect->reg.indirect == NULL) &&
+ if (src->reg.indirect) {
+ assert(src->reg.reg->num_array_elems != 0);
+ assert((src->reg.indirect->is_ssa ||
+ src->reg.indirect->reg.indirect == NULL) &&
"only one level of indirection allowed");
- validate_src(src->indirect, state);
+ validate_src(src->reg.indirect, state);
}
}
static void
-validate_ssa_src(nir_ssa_def *def, validate_state *state)
+validate_ssa_src(nir_src *src, validate_state *state)
{
- assert(def != NULL);
+ assert(src->ssa != NULL);
- struct hash_entry *entry = _mesa_hash_table_search(state->ssa_defs, def);
+ struct hash_entry *entry = _mesa_hash_table_search(state->ssa_defs, src->ssa);
assert(entry);
@@ -150,14 +147,10 @@ validate_ssa_src(nir_ssa_def *def, validate_state *state)
"using an SSA value defined in a different function");
if (state->instr) {
- _mesa_set_add(def_state->uses, state->instr);
-
- assert(_mesa_set_search(def->uses, state->instr));
+ _mesa_set_add(def_state->uses, src);
} else {
assert(state->if_stmt);
- _mesa_set_add(def_state->if_uses, state->if_stmt);
-
- assert(_mesa_set_search(def->if_uses, state->if_stmt));
+ _mesa_set_add(def_state->if_uses, src);
}
/* TODO validate that the use is dominated by the definition */
@@ -166,10 +159,15 @@ validate_ssa_src(nir_ssa_def *def, validate_state *state)
static void
validate_src(nir_src *src, validate_state *state)
{
+ if (state->instr)
+ assert(src->parent_instr == state->instr);
+ else
+ assert(src->parent_if == state->if_stmt);
+
if (src->is_ssa)
- validate_ssa_src(src->ssa, state);
+ validate_ssa_src(src, state);
else
- validate_reg_src(&src->reg, state);
+ validate_reg_src(src, state);
}
static void
@@ -201,8 +199,7 @@ validate_reg_dest(nir_reg_dest *dest, validate_state *state)
{
assert(dest->reg != NULL);
- struct set_entry *entry = _mesa_set_search(dest->reg->defs, state->instr);
- assert(entry && "definition not in nir_register.defs");
+ assert(dest->parent_instr == state->instr);
struct hash_entry *entry2;
entry2 = _mesa_hash_table_search(state->regs, dest->reg);
@@ -210,7 +207,7 @@ validate_reg_dest(nir_reg_dest *dest, validate_state *state)
assert(entry2);
reg_validate_state *reg_state = (reg_validate_state *) entry2->data;
- _mesa_set_add(reg_state->defs, state->instr);
+ _mesa_set_add(reg_state->defs, dest);
if (!dest->reg->is_global) {
assert(reg_state->where_defined == state->impl &&
@@ -236,8 +233,13 @@ validate_ssa_def(nir_ssa_def *def, validate_state *state)
assert(!BITSET_TEST(state->ssa_defs_found, def->index));
BITSET_SET(state->ssa_defs_found, def->index);
+ assert(def->parent_instr == state->instr);
+
assert(def->num_components <= 4);
+ list_validate(&def->uses);
+ list_validate(&def->if_uses);
+
ssa_def_validate_state *def_state = ralloc(state->ssa_defs,
ssa_def_validate_state);
def_state->where_defined = state->impl;
@@ -699,6 +701,10 @@ prevalidate_reg_decl(nir_register *reg, bool is_global, validate_state *state)
assert(!BITSET_TEST(state->regs_found, reg->index));
BITSET_SET(state->regs_found, reg->index);
+ list_validate(&reg->uses);
+ list_validate(&reg->defs);
+ list_validate(&reg->if_uses);
+
reg_validate_state *reg_state = ralloc(state->regs, reg_validate_state);
reg_state->uses = _mesa_set_create(reg_state, _mesa_hash_pointer,
_mesa_key_pointer_equal);
@@ -719,47 +725,47 @@ postvalidate_reg_decl(nir_register *reg, validate_state *state)
reg_validate_state *reg_state = (reg_validate_state *) entry->data;
- if (reg_state->uses->entries != reg->uses->entries) {
+ nir_foreach_use(reg, src) {
+ struct set_entry *entry = _mesa_set_search(reg_state->uses, src);
+ assert(entry);
+ _mesa_set_remove(reg_state->uses, entry);
+ }
+
+ if (reg_state->uses->entries != 0) {
printf("extra entries in register uses:\n");
struct set_entry *entry;
- set_foreach(reg->uses, entry) {
- struct set_entry *entry2 =
- _mesa_set_search(reg_state->uses, entry->key);
-
- if (entry2 == NULL) {
- printf("%p\n", entry->key);
- }
- }
+ set_foreach(reg_state->uses, entry)
+ printf("%p\n", entry->key);
abort();
}
- if (reg_state->if_uses->entries != reg->if_uses->entries) {
+ nir_foreach_if_use(reg, src) {
+ struct set_entry *entry = _mesa_set_search(reg_state->if_uses, src);
+ assert(entry);
+ _mesa_set_remove(reg_state->if_uses, entry);
+ }
+
+ if (reg_state->if_uses->entries != 0) {
printf("extra entries in register if_uses:\n");
struct set_entry *entry;
- set_foreach(reg->if_uses, entry) {
- struct set_entry *entry2 =
- _mesa_set_search(reg_state->if_uses, entry->key);
-
- if (entry2 == NULL) {
- printf("%p\n", entry->key);
- }
- }
+ set_foreach(reg_state->if_uses, entry)
+ printf("%p\n", entry->key);
abort();
}
- if (reg_state->defs->entries != reg->defs->entries) {
+ nir_foreach_def(reg, src) {
+ struct set_entry *entry = _mesa_set_search(reg_state->defs, src);
+ assert(entry);
+ _mesa_set_remove(reg_state->defs, entry);
+ }
+
+ if (reg_state->defs->entries != 0) {
printf("extra entries in register defs:\n");
struct set_entry *entry;
- set_foreach(reg->defs, entry) {
- struct set_entry *entry2 =
- _mesa_set_search(reg_state->defs, entry->key);
-
- if (entry2 == NULL) {
- printf("%p\n", entry->key);
- }
- }
+ set_foreach(reg_state->defs, entry)
+ printf("%p\n", entry->key);
abort();
}
@@ -788,32 +794,32 @@ postvalidate_ssa_def(nir_ssa_def *def, void *void_state)
struct hash_entry *entry = _mesa_hash_table_search(state->ssa_defs, def);
ssa_def_validate_state *def_state = (ssa_def_validate_state *)entry->data;
- if (def_state->uses->entries != def->uses->entries) {
- printf("extra entries in SSA def uses:\n");
- struct set_entry *entry;
- set_foreach(def->uses, entry) {
- struct set_entry *entry2 =
- _mesa_set_search(def_state->uses, entry->key);
+ nir_foreach_use(def, src) {
+ struct set_entry *entry = _mesa_set_search(def_state->uses, src);
+ assert(entry);
+ _mesa_set_remove(def_state->uses, entry);
+ }
- if (entry2 == NULL) {
- printf("%p\n", entry->key);
- }
- }
+ if (def_state->uses->entries != 0) {
+ printf("extra entries in register uses:\n");
+ struct set_entry *entry;
+ set_foreach(def_state->uses, entry)
+ printf("%p\n", entry->key);
abort();
}
- if (def_state->if_uses->entries != def->if_uses->entries) {
- printf("extra entries in SSA def uses:\n");
- struct set_entry *entry;
- set_foreach(def->if_uses, entry) {
- struct set_entry *entry2 =
- _mesa_set_search(def_state->if_uses, entry->key);
+ nir_foreach_if_use(def, src) {
+ struct set_entry *entry = _mesa_set_search(def_state->if_uses, src);
+ assert(entry);
+ _mesa_set_remove(def_state->if_uses, entry);
+ }
- if (entry2 == NULL) {
- printf("%p\n", entry->key);
- }
- }
+ if (def_state->if_uses->entries != 0) {
+ printf("extra entries in register uses:\n");
+ struct set_entry *entry;
+ set_foreach(def_state->if_uses, entry)
+ printf("%p\n", entry->key);
abort();
}
diff --git a/mesalib/src/glsl/opt_dead_builtin_varyings.cpp b/mesalib/src/glsl/opt_dead_builtin_varyings.cpp
index 92f20c71d..31719d20c 100644
--- a/mesalib/src/glsl/opt_dead_builtin_varyings.cpp
+++ b/mesalib/src/glsl/opt_dead_builtin_varyings.cpp
@@ -99,6 +99,16 @@ public:
}
else {
this->fragdata_usage |= 1 << index->get_uint_component(0);
+ /* Don't lower fragdata array if the output variable
+ * is not a float variable (or float vector) because it will
+ * generate wrong register assignments because of different
+ * data types.
+ */
+ if (var->type->gl_type != GL_FLOAT &&
+ var->type->gl_type != GL_FLOAT_VEC2 &&
+ var->type->gl_type != GL_FLOAT_VEC3 &&
+ var->type->gl_type != GL_FLOAT_VEC4)
+ this->lower_fragdata_array = false;
}
/* Don't visit the leaves of ir_dereference_array. */
diff --git a/mesalib/src/hgl/GLDispatcher.cpp b/mesalib/src/hgl/GLDispatcher.cpp
index 46b91d57c..a1e905361 100644
--- a/mesalib/src/hgl/GLDispatcher.cpp
+++ b/mesalib/src/hgl/GLDispatcher.cpp
@@ -1,6 +1,6 @@
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000-2012 Haiku, Inc. All Rights Reserved.
+ * Copyright 2000-2015 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -10,10 +10,11 @@
*/
-extern "C" {
#include "glapi/glapi.h"
#include "glapi/glapi_priv.h"
+
+extern "C" {
/*
* NOTE: this file portion implements C-based dispatch of the OpenGL entrypoints
* (glAccum, glBegin, etc).
diff --git a/mesalib/src/hgl/GLDispatcher.h b/mesalib/src/hgl/GLDispatcher.h
index 44bca8ce5..7ee095d91 100644
--- a/mesalib/src/hgl/GLDispatcher.h
+++ b/mesalib/src/hgl/GLDispatcher.h
@@ -1,6 +1,6 @@
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000-2012 Haiku, Inc. All Rights Reserved.
+ * Copyright 2000-2015 Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -17,9 +17,7 @@
#include "glheader.h"
-extern "C" {
#include "glapi/glapi.h"
-}
class BGLDispatcher
diff --git a/mesalib/src/hgl/SConscript b/mesalib/src/hgl/SConscript
index 70db1494d..71881f504 100644
--- a/mesalib/src/hgl/SConscript
+++ b/mesalib/src/hgl/SConscript
@@ -6,6 +6,7 @@ Import('*')
env = env.Clone()
env.Append(CPPPATH = [
+ '#/src',
'#/src/mapi',
'#/src/mesa',
'#/src/mesa/main',
diff --git a/mesalib/src/loader/loader.h b/mesalib/src/loader/loader.h
index 810e7da7f..60c58f2f8 100644
--- a/mesalib/src/loader/loader.h
+++ b/mesalib/src/loader/loader.h
@@ -27,6 +27,10 @@
#ifndef LOADER_H
#define LOADER_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* Helpers to figure out driver and device name, eg. from pci-id, etc. */
#define _LOADER_DRI (1 << 0)
@@ -61,4 +65,9 @@ loader_get_user_preferred_fd(int default_fd, int *different_device);
void
loader_set_logger(void (*logger)(int level, const char *fmt, ...));
+
+#ifdef __cplusplus
+}
+#endif
+
#endif /* LOADER_H */
diff --git a/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml b/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml
index 8a092d697..bb9baf5a3 100644
--- a/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml
+++ b/mesalib/src/mapi/glapi/gen/ARB_direct_state_access.xml
@@ -152,6 +152,135 @@
<param name="data" type="GLvoid *" />
</function>
+ <!-- Framebuffer object functions -->
+
+ <function name="CreateFramebuffers" offset="assign">
+ <param name="n" type="GLsizei" />
+ <param name="framebuffers" type="GLuint *" />
+ </function>
+
+ <function name="NamedFramebufferRenderbuffer" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="attachment" type="GLenum" />
+ <param name="renderbuffertarget" type="GLenum" />
+ <param name="renderbuffer" type="GLuint" />
+ </function>
+
+ <function name="NamedFramebufferParameteri" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="pname" type="GLenum" />
+ <param name="param" type="GLint" />
+ </function>
+
+ <function name="NamedFramebufferTexture" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="attachment" type="GLenum" />
+ <param name="texture" type="GLuint" />
+ <param name="level" type="GLint" />
+ </function>
+
+ <function name="NamedFramebufferTextureLayer" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="attachment" type="GLenum" />
+ <param name="texture" type="GLuint" />
+ <param name="level" type="GLint" />
+ <param name="layer" type="GLint" />
+ </function>
+
+ <function name="NamedFramebufferDrawBuffer" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="buf" type="GLenum" />
+ </function>
+
+ <function name="NamedFramebufferDrawBuffers" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="n" type="GLsizei" />
+ <param name="bufs" type="const GLenum *" />
+ </function>
+
+ <function name="NamedFramebufferReadBuffer" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="buf" type="GLenum" />
+ </function>
+
+ <function name="InvalidateNamedFramebufferData" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="numAttachments" type="GLsizei" />
+ <param name="attachments" type="const GLenum *" />
+ </function>
+
+ <function name="InvalidateNamedFramebufferSubData" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="numAttachments" type="GLsizei" />
+ <param name="attachments" type="const GLenum *" />
+ <param name="x" type="GLint" />
+ <param name="y" type="GLint" />
+ <param name="width" type="GLsizei" />
+ <param name="height" type="GLsizei" />
+ </function>
+
+ <function name="ClearNamedFramebufferiv" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="buffer" type="GLenum" />
+ <param name="drawbuffer" type="GLint" />
+ <param name="value" type="const GLint *" />
+ </function>
+
+ <function name="ClearNamedFramebufferuiv" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="buffer" type="GLenum" />
+ <param name="drawbuffer" type="GLint" />
+ <param name="value" type="const GLuint *" />
+ </function>
+
+ <function name="ClearNamedFramebufferfv" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="buffer" type="GLenum" />
+ <param name="drawbuffer" type="GLint" />
+ <param name="value" type="const GLfloat *" />
+ </function>
+
+ <function name="ClearNamedFramebufferfi" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="buffer" type="GLenum" />
+ <param name="depth" type="GLfloat" />
+ <param name="stencil" type="GLint" />
+ </function>
+
+ <function name="BlitNamedFramebuffer" offset="assign">
+ <param name="readFramebuffer" type="GLuint" />
+ <param name="drawFramebuffer" type="GLuint" />
+ <param name="srcX0" type="GLint" />
+ <param name="srcY0" type="GLint" />
+ <param name="srcX1" type="GLint" />
+ <param name="srcY1" type="GLint" />
+ <param name="dstX0" type="GLint" />
+ <param name="dstY0" type="GLint" />
+ <param name="dstX1" type="GLint" />
+ <param name="dstY1" type="GLint" />
+ <param name="mask" type="GLbitfield" />
+ <param name="filter" type="GLenum" />
+ </function>
+
+ <function name="CheckNamedFramebufferStatus" offset="assign">
+ <return type="GLenum" />
+ <param name="framebuffer" type="GLuint" />
+ <param name="target" type="GLenum" />
+ </function>
+
+ <function name="GetNamedFramebufferParameteriv" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="pname" type="GLenum" />
+ <param name="param" type="GLint *" />
+ </function>
+
+ <function name="GetNamedFramebufferAttachmentParameteriv" offset="assign">
+ <param name="framebuffer" type="GLuint" />
+ <param name="attachment" type="GLenum" />
+ <param name="pname" type="GLenum" />
+ <param name="params" type="GLint *" />
+ </function>
+
<!-- Renderbuffer object functions -->
<function name="CreateRenderbuffers" offset="assign">
@@ -448,6 +577,102 @@
<param name="params" type="GLint *" />
</function>
+ <!-- Vertex Array object functions -->
+
+ <function name="CreateVertexArrays" offset="assign">
+ <param name="n" type="GLsizei" />
+ <param name="arrays" type="GLuint *" />
+ </function>
+
+ <function name="DisableVertexArrayAttrib" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="index" type="GLuint" />
+ </function>
+
+ <function name="EnableVertexArrayAttrib" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="index" type="GLuint" />
+ </function>
+
+ <function name="VertexArrayElementBuffer" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="buffer" type="GLuint" />
+ </function>
+
+ <function name="VertexArrayVertexBuffer" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="bindingindex" type="GLuint" />
+ <param name="buffer" type="GLuint" />
+ <param name="offset" type="GLintptr" />
+ <param name="stride" type="GLsizei" />
+ </function>
+
+ <function name="VertexArrayVertexBuffers" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="first" type="GLuint" />
+ <param name="count" type="GLsizei" />
+ <param name="buffers" type="const GLuint *" />
+ <param name="offsets" type="const GLintptr *" />
+ <param name="strides" type="const GLsizei *" />
+ </function>
+
+ <function name="VertexArrayAttribFormat" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="attribindex" type="GLuint" />
+ <param name="size" type="GLint" />
+ <param name="type" type="GLenum" />
+ <param name="normalized" type="GLboolean" />
+ <param name="relativeoffset" type="GLuint" />
+ </function>
+
+ <function name="VertexArrayAttribIFormat" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="attribindex" type="GLuint" />
+ <param name="size" type="GLint" />
+ <param name="type" type="GLenum" />
+ <param name="relativeoffset" type="GLuint" />
+ </function>
+
+ <function name="VertexArrayAttribLFormat" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="attribindex" type="GLuint" />
+ <param name="size" type="GLint" />
+ <param name="type" type="GLenum" />
+ <param name="relativeoffset" type="GLuint" />
+ </function>
+
+ <function name="VertexArrayAttribBinding" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="attribindex" type="GLuint" />
+ <param name="bindingindex" type="GLuint" />
+ </function>
+
+ <function name="VertexArrayBindingDivisor" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="bindingindex" type="GLuint" />
+ <param name="divisor" type="GLuint" />
+ </function>
+
+ <function name="GetVertexArrayiv" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="pname" type="GLenum" />
+ <param name="param" type="GLint *" />
+ </function>
+
+ <function name="GetVertexArrayIndexediv" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="index" type="GLuint" />
+ <param name="pname" type="GLenum" />
+ <param name="param" type="GLint *" />
+ </function>
+
+ <function name="GetVertexArrayIndexed64iv" offset="assign">
+ <param name="vaobj" type="GLuint" />
+ <param name="index" type="GLuint" />
+ <param name="pname" type="GLenum" />
+ <param name="param" type="GLint64 *" />
+ </function>
+
<!-- Sampler object functions -->
<function name="CreateSamplers" offset="assign">
diff --git a/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml b/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml
index 7c547c167..999a8ef13 100644
--- a/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml
+++ b/mesalib/src/mapi/glapi/gen/ARB_framebuffer_object.xml
@@ -247,7 +247,7 @@
<param name="textarget" type="GLenum"/>
<param name="texture" type="GLuint"/>
<param name="level" type="GLint"/>
- <param name="zoffset" type="GLint"/>
+ <param name="layer" type="GLint"/>
<glx rop="4323"/>
</function>
diff --git a/mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml b/mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml
new file mode 100644
index 000000000..fc49f84b5
--- /dev/null
+++ b/mesalib/src/mapi/glapi/gen/ARB_vertex_attrib_64bit.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<category name="GL_ARB_vertex_attrib_64bit" number="99">
+
+ <function name="VertexAttribL1d" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttribL2d" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttribL3d" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttribL4d" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttribL1dv" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="VertexAttribL2dv" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="VertexAttribL3dv" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="VertexAttribL4dv" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="VertexAttribLPointer" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ </function>
+
+ <function name="GetVertexAttribLdv" offset="assign">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLdouble *"/>
+ </function>
+</category>
+
+</OpenGLAPI>
+
diff --git a/mesalib/src/mapi/glapi/gen/Makefile.am b/mesalib/src/mapi/glapi/gen/Makefile.am
index 1c4b86aab..c8d417468 100644
--- a/mesalib/src/mapi/glapi/gen/Makefile.am
+++ b/mesalib/src/mapi/glapi/gen/Makefile.am
@@ -163,6 +163,7 @@ API_XML = \
ARB_texture_view.xml \
ARB_uniform_buffer_object.xml \
ARB_vertex_array_object.xml \
+ ARB_vertex_attrib_64bit.xml \
ARB_vertex_attrib_binding.xml \
ARB_viewport_array.xml \
AMD_draw_buffers_blend.xml \
diff --git a/mesalib/src/mapi/glapi/gen/gl_API.xml b/mesalib/src/mapi/glapi/gen/gl_API.xml
index a8a6db683..d1565989c 100644
--- a/mesalib/src/mapi/glapi/gen/gl_API.xml
+++ b/mesalib/src/mapi/glapi/gen/gl_API.xml
@@ -8253,7 +8253,9 @@
<!-- No new functions, types, enums. -->
</category>
-<!-- ARB extensions #99...#108 -->
+<xi:include href="ARB_vertex_attrib_64bit.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
+<!-- ARB extensions #100...#108 -->
<xi:include href="ARB_ES2_compatibility.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
diff --git a/mesalib/src/mapi/glapi/gen/gl_genexec.py b/mesalib/src/mapi/glapi/gen/gl_genexec.py
index 7151f0de1..4e76fe3c2 100644
--- a/mesalib/src/mapi/glapi/gen/gl_genexec.py
+++ b/mesalib/src/mapi/glapi/gen/gl_genexec.py
@@ -183,8 +183,8 @@ class PrintCode(gl_XML.gl_print_base):
if 'es1' in f.api_map:
condition_parts.append('ctx->API == API_OPENGLES')
if 'es2' in f.api_map:
- if f.api_map['es2'] == 3:
- condition_parts.append('_mesa_is_gles3(ctx)')
+ if f.api_map['es2'] > 2.0:
+ condition_parts.append('(ctx->API == API_OPENGLES2 && ctx->Version >= {0})'.format(int(f.api_map['es2'] * 10)))
else:
condition_parts.append('ctx->API == API_OPENGLES2')
if not condition_parts:
diff --git a/mesalib/src/mapi/glapi/glapi_priv.h b/mesalib/src/mapi/glapi/glapi_priv.h
index 50f710edc..337913acc 100644
--- a/mesalib/src/mapi/glapi/glapi_priv.h
+++ b/mesalib/src/mapi/glapi/glapi_priv.h
@@ -49,6 +49,10 @@ typedef void *GLeglImageOES;
#include "glapi/glapi.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* getproc */
extern void
@@ -106,4 +110,8 @@ get_entrypoint_address(unsigned int functionOffset);
#define MAX_EXTENSION_FUNCS 256
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/mesalib/src/mesa/Makefile.sources b/mesalib/src/mesa/Makefile.sources
index 1293d4135..83f500fbf 100644
--- a/mesalib/src/mesa/Makefile.sources
+++ b/mesalib/src/mesa/Makefile.sources
@@ -434,6 +434,8 @@ STATETRACKER_FILES = \
state_tracker/st_cb_flush.h \
state_tracker/st_cb_msaa.c \
state_tracker/st_cb_msaa.h \
+ state_tracker/st_cb_perfmon.c \
+ state_tracker/st_cb_perfmon.h \
state_tracker/st_cb_program.c \
state_tracker/st_cb_program.h \
state_tracker/st_cb_queryobj.c \
diff --git a/mesalib/src/mesa/drivers/common/driverfuncs.c b/mesalib/src/mesa/drivers/common/driverfuncs.c
index 0d094ddf4..71c1a7639 100644
--- a/mesalib/src/mesa/drivers/common/driverfuncs.c
+++ b/mesalib/src/mesa/drivers/common/driverfuncs.c
@@ -172,7 +172,7 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
driver->UnmapRenderbuffer = _swrast_unmap_soft_renderbuffer;
driver->RenderTexture = _swrast_render_texture;
driver->FinishRenderTexture = _swrast_finish_render_texture;
- driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
+ driver->FramebufferRenderbuffer = _mesa_FramebufferRenderbuffer_sw;
driver->ValidateFramebuffer = _mesa_validate_framebuffer;
driver->BlitFramebuffer = _swrast_BlitFramebuffer;
diff --git a/mesalib/src/mesa/drivers/common/meta.c b/mesalib/src/mesa/drivers/common/meta.c
index d2ab7b8de..214a68a91 100644
--- a/mesalib/src/mesa/drivers/common/meta.c
+++ b/mesalib/src/mesa/drivers/common/meta.c
@@ -1211,7 +1211,8 @@ _mesa_meta_end(struct gl_context *ctx)
_mesa_BindRenderbuffer(GL_RENDERBUFFER, save->RenderbufferName);
if (state & MESA_META_DRAW_BUFFERS) {
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers, save->ColorDrawBuffers, NULL);
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, ctx->Const.MaxDrawBuffers,
+ save->ColorDrawBuffers, NULL);
}
ctx->Meta->SaveStackDepth--;
diff --git a/mesalib/src/mesa/drivers/dri/swrast/swrast.c b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
index d1bb72139..cbc946c3f 100644
--- a/mesalib/src/mesa/drivers/dri/swrast/swrast.c
+++ b/mesalib/src/mesa/drivers/dri/swrast/swrast.c
@@ -61,6 +61,9 @@
#include "swrast_priv.h"
#include "swrast/s_context.h"
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
const __DRIextension **__driDriverGetExtensions_swrast(void);
const char * const swrast_vendor_string = "Mesa Project";
@@ -137,6 +140,16 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param,
value[0] = 0;
return 0;
case __DRI2_RENDERER_VIDEO_MEMORY: {
+ /* This should probably share code with os_get_total_physical_memory()
+ * from src/gallium/auxiliary/os/os_misc.c
+ */
+#if defined(CTL_HW) && defined(HW_MEMSIZE)
+ int mib[2] = { CTL_HW, HW_MEMSIZE };
+ unsigned long system_memory_bytes;
+ size_t len = sizeof(system_memory_bytes);
+ if (sysctl(mib, 2, &system_memory_bytes, &len, NULL, 0) != 0)
+ return -1;
+#elif defined(_SC_PHYS_PAGES) && defined(_SC_PAGE_SIZE)
/* XXX: Do we want to return the full amount of system memory ? */
const long system_memory_pages = sysconf(_SC_PHYS_PAGES);
const long system_page_size = sysconf(_SC_PAGE_SIZE);
@@ -146,6 +159,9 @@ swrast_query_renderer_integer(__DRIscreen *psp, int param,
const uint64_t system_memory_bytes = (uint64_t) system_memory_pages
* (uint64_t) system_page_size;
+#else
+#error "Unsupported platform"
+#endif
const unsigned system_memory_megabytes =
(unsigned) (system_memory_bytes / (1024 * 1024));
@@ -942,6 +958,7 @@ static const __DRIextension *swrast_driver_extensions[] = {
&driCoreExtension.base,
&driSWRastExtension.base,
&driCopySubBufferExtension.base,
+ &dri2ConfigQueryExtension.base,
&swrast_vtable.base,
NULL
};
diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c
index ea015fd65..92d8238f4 100644
--- a/mesalib/src/mesa/main/api_arrayelt.c
+++ b/mesalib/src/mesa/main/api_arrayelt.c
@@ -1258,12 +1258,37 @@ VertexAttribI4uiv(GLuint index, const GLuint *v)
CALL_VertexAttribI4uivEXT(GET_DISPATCH(), (index, v));
}
+/* GL_DOUBLE unconverted attributes */
+
+static void GLAPIENTRY
+VertexAttribL1dv(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttribL1dv(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY
+VertexAttribL2dv(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttribL2dv(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY
+VertexAttribL3dv(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttribL3dv(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY
+VertexAttribL4dv(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttribL4dv(GET_DISPATCH(), (index, v));
+}
/*
* Array [unnormalized/normalized/integer][size][type] of VertexAttrib
* functions
*/
-static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = {
+static attrib_func AttribFuncsARB[4][4][NUM_TYPES] = {
{
/* non-normalized */
{
@@ -1405,7 +1430,55 @@ static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = {
NULL, /* GL_FLOAT */
NULL /* GL_DOUBLE */
}
+ },
+ {
+ /* double-valued */
+ {
+ /* size 1 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (attrib_func) VertexAttribL1dv,
+ },
+ {
+ /* size 2 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (attrib_func) VertexAttribL2dv,
+ },
+ {
+ /* size 3 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (attrib_func) VertexAttribL3dv,
+ },
+ {
+ /* size 4 */
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ (attrib_func) VertexAttribL4dv,
+ }
}
+
};
@@ -1571,7 +1644,9 @@ _ae_update_state(struct gl_context *ctx)
* change from one execution of _ae_ArrayElement() to
* the next. Doing so caused UT to break.
*/
- if (at->array->Integer)
+ if (at->array->Doubles)
+ intOrNorm = 3;
+ else if (at->array->Integer)
intOrNorm = 2;
else if (at->array->Normalized)
intOrNorm = 1;
diff --git a/mesalib/src/mesa/main/api_loopback.c b/mesalib/src/mesa/main/api_loopback.c
index d10ae15ea..9932a8373 100644
--- a/mesalib/src/mesa/main/api_loopback.c
+++ b/mesalib/src/mesa/main/api_loopback.c
@@ -84,6 +84,10 @@
#define ATTRIBI_4UI(index,x,y,z,w) CALL_VertexAttribI4uiEXT(GET_DISPATCH(), (index,x,y,z,w))
+#define ATTRIB1_D(index,x) CALL_VertexAttribL1d(GET_DISPATCH(), (index,x))
+#define ATTRIB2_D(index,x,y) CALL_VertexAttribL2d(GET_DISPATCH(), (index,x,y))
+#define ATTRIB3_D(index,x,y,z) CALL_VertexAttribL3d(GET_DISPATCH(), (index,x,y,z))
+#define ATTRIB4_D(index,x,y,z,w) CALL_VertexAttribL4d(GET_DISPATCH(), (index,x,y,z,w))
void GLAPIENTRY
_mesa_Color3b( GLbyte red, GLbyte green, GLbyte blue )
@@ -1490,8 +1494,53 @@ _mesa_VertexAttribI4usv(GLuint index, const GLushort *v)
ATTRIBI_4UI(index, v[0], v[1], v[2], v[3]);
}
+void GLAPIENTRY
+_mesa_VertexAttribL1d(GLuint index, GLdouble x)
+{
+ ATTRIB1_D(index, x);
+}
+
+void GLAPIENTRY
+_mesa_VertexAttribL2d(GLuint index, GLdouble x, GLdouble y)
+{
+ ATTRIB2_D(index, x, y);
+}
+void GLAPIENTRY
+_mesa_VertexAttribL3d(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ ATTRIB3_D(index, x, y, z);
+}
+void GLAPIENTRY
+_mesa_VertexAttribL4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ ATTRIB4_D(index, x, y, z, w);
+}
+
+void GLAPIENTRY
+_mesa_VertexAttribL1dv(GLuint index, const GLdouble *v)
+{
+ ATTRIB1_D(index, v[0]);
+}
+
+void GLAPIENTRY
+_mesa_VertexAttribL2dv(GLuint index, const GLdouble *v)
+{
+ ATTRIB2_D(index, v[0], v[1]);
+}
+
+void GLAPIENTRY
+_mesa_VertexAttribL3dv(GLuint index, const GLdouble *v)
+{
+ ATTRIB3_D(index, v[0], v[1], v[2]);
+}
+
+void GLAPIENTRY
+_mesa_VertexAttribL4dv(GLuint index, const GLdouble *v)
+{
+ ATTRIB4_D(index, v[0], v[1], v[2], v[3]);
+}
/*
* This code never registers handlers for any of the entry points
@@ -1723,5 +1772,16 @@ _mesa_loopback_init_api_table(const struct gl_context *ctx,
SET_VertexAttribI4sv(dest, _mesa_VertexAttribI4sv);
SET_VertexAttribI4ubv(dest, _mesa_VertexAttribI4ubv);
SET_VertexAttribI4usv(dest, _mesa_VertexAttribI4usv);
+
+ /* GL 4.1 / GL_ARB_vertex_attrib_64bit */
+ SET_VertexAttribL1d(dest, _mesa_VertexAttribL1d);
+ SET_VertexAttribL2d(dest, _mesa_VertexAttribL2d);
+ SET_VertexAttribL3d(dest, _mesa_VertexAttribL3d);
+ SET_VertexAttribL4d(dest, _mesa_VertexAttribL4d);
+
+ SET_VertexAttribL1dv(dest, _mesa_VertexAttribL1dv);
+ SET_VertexAttribL2dv(dest, _mesa_VertexAttribL2dv);
+ SET_VertexAttribL3dv(dest, _mesa_VertexAttribL3dv);
+ SET_VertexAttribL4dv(dest, _mesa_VertexAttribL4dv);
}
}
diff --git a/mesalib/src/mesa/main/api_loopback.h b/mesalib/src/mesa/main/api_loopback.h
index 44514405b..026bfd68e 100644
--- a/mesalib/src/mesa/main/api_loopback.h
+++ b/mesalib/src/mesa/main/api_loopback.h
@@ -464,5 +464,21 @@ _mesa_VertexAttribI4ubv(GLuint index, const GLubyte *v);
void GLAPIENTRY
_mesa_VertexAttribI4usv(GLuint index, const GLushort *v);
+void GLAPIENTRY
+_mesa_VertexAttribL1d(GLuint index, GLdouble x);
+void GLAPIENTRY
+_mesa_VertexAttribL2d(GLuint index, GLdouble x, GLdouble y);
+void GLAPIENTRY
+_mesa_VertexAttribL3d(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+void GLAPIENTRY
+_mesa_VertexAttribL4d(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+void GLAPIENTRY
+_mesa_VertexAttribL1dv(GLuint index, const GLdouble *v);
+void GLAPIENTRY
+_mesa_VertexAttribL2dv(GLuint index, const GLdouble *v);
+void GLAPIENTRY
+_mesa_VertexAttribL3dv(GLuint index, const GLdouble *v);
+void GLAPIENTRY
+_mesa_VertexAttribL4dv(GLuint index, const GLdouble *v);
#endif /* API_LOOPBACK_H */
diff --git a/mesalib/src/mesa/main/arrayobj.c b/mesalib/src/mesa/main/arrayobj.c
index 3c8ffb5a4..320f435ea 100644
--- a/mesalib/src/mesa/main/arrayobj.c
+++ b/mesalib/src/mesa/main/arrayobj.c
@@ -75,6 +75,61 @@ _mesa_lookup_vao(struct gl_context *ctx, GLuint id)
/**
+ * Looks up the array object for the given ID.
+ *
+ * Unlike _mesa_lookup_vao, this function generates a GL_INVALID_OPERATION
+ * error if the array object does not exist. It also returns the default
+ * array object when ctx is a compatibility profile context and id is zero.
+ */
+struct gl_vertex_array_object *
+_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char *caller)
+{
+ /* The ARB_direct_state_access specification says:
+ *
+ * "<vaobj> is [compatibility profile:
+ * zero, indicating the default vertex array object, or]
+ * the name of the vertex array object."
+ */
+ if (id == 0) {
+ if (ctx->API == API_OPENGL_CORE) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(zero is not valid vaobj name in a core profile "
+ "context)", caller);
+ return NULL;
+ }
+
+ return ctx->Array.DefaultVAO;
+ } else {
+ struct gl_vertex_array_object *vao;
+
+ if (ctx->Array.LastLookedUpVAO &&
+ ctx->Array.LastLookedUpVAO->Name == id) {
+ vao = ctx->Array.LastLookedUpVAO;
+ } else {
+ vao = (struct gl_vertex_array_object *)
+ _mesa_HashLookup(ctx->Array.Objects, id);
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated if <vaobj> is not
+ * [compatibility profile: zero or] the name of an existing
+ * vertex array object."
+ */
+ if (!vao || !vao->EverBound) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(non-existent vaobj=%u)", caller, id);
+ return NULL;
+ }
+
+ _mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, vao);
+ }
+
+ return vao;
+ }
+}
+
+
+/**
* For all the vertex binding points in the array object, unbind any pointers
* to any buffer objects (VBOs).
* This is done just prior to array object destruction.
@@ -200,6 +255,7 @@ init_array(struct gl_context *ctx,
array->Enabled = GL_FALSE;
array->Normalized = GL_FALSE;
array->Integer = GL_FALSE;
+ array->Doubles = GL_FALSE;
array->_ElementSize = size * _mesa_sizeof_type(type);
array->VertexBinding = index;
@@ -469,6 +525,9 @@ _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids)
/* The ID is immediately freed for re-use */
remove_array_object(ctx, obj);
+ if (ctx->Array.LastLookedUpVAO == obj)
+ _mesa_reference_vao(ctx, &ctx->Array.LastLookedUpVAO, NULL);
+
/* Unreference the array object.
* If refcount hits zero, the object will be deleted.
*/
@@ -480,19 +539,23 @@ _mesa_DeleteVertexArrays(GLsizei n, const GLuint *ids)
/**
* Generate a set of unique array object IDs and store them in \c arrays.
- * Helper for _mesa_GenVertexArrays[APPLE]() functions below.
+ * Helper for _mesa_GenVertexArrays[APPLE]() and _mesa_CreateVertexArrays()
+ * below.
+ *
* \param n Number of IDs to generate.
* \param arrays Array of \c n locations to store the IDs.
- * \param vboOnly Will arrays have to reside in VBOs?
+ * \param create Indicates that the objects should also be created.
+ * \param func The name of the GL entry point.
*/
static void
-gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays)
+gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays,
+ bool create, const char *func)
{
GLuint first;
GLint i;
if (n < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGenVertexArrays");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
return;
}
@@ -502,16 +565,20 @@ gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays)
first = _mesa_HashFindFreeKeyBlock(ctx->Array.Objects, n);
- /* Allocate new, empty array objects and return identifiers */
+ /* For the sake of simplicity we create the array objects in both
+ * the Gen* and Create* cases. The only difference is the value of
+ * EverBound, which is set to true in the Create* case.
+ */
for (i = 0; i < n; i++) {
struct gl_vertex_array_object *obj;
GLuint name = first + i;
obj = (*ctx->Driver.NewArrayObject)( ctx, name );
if (!obj) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArrays");
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
return;
}
+ obj->EverBound = create;
save_array_object(ctx, obj);
arrays[i] = first + i;
}
@@ -526,7 +593,7 @@ void GLAPIENTRY
_mesa_GenVertexArrays(GLsizei n, GLuint *arrays)
{
GET_CURRENT_CONTEXT(ctx);
- gen_vertex_arrays(ctx, n, arrays);
+ gen_vertex_arrays(ctx, n, arrays, false, "glGenVertexArrays");
}
@@ -538,7 +605,27 @@ void GLAPIENTRY
_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
{
GET_CURRENT_CONTEXT(ctx);
- gen_vertex_arrays(ctx, n, arrays);
+ gen_vertex_arrays(ctx, n, arrays, false, "glGenVertexArraysAPPLE");
+}
+
+
+/**
+ * ARB_direct_state_access
+ * Generates ID's and creates the array objects.
+ */
+void GLAPIENTRY
+_mesa_CreateVertexArrays(GLsizei n, GLuint *arrays)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateVertexArrays(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ gen_vertex_arrays(ctx, n, arrays, true, "glCreateVertexArrays");
}
@@ -565,3 +652,92 @@ _mesa_IsVertexArray( GLuint id )
return obj->EverBound;
}
+
+
+/**
+ * Sets the element array buffer binding of a vertex array object.
+ *
+ * This is the ARB_direct_state_access equivalent of
+ * glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buffer).
+ */
+void GLAPIENTRY
+_mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+ struct gl_buffer_object *bufObj;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayElementBuffer(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ /* The GL_ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by VertexArrayElementBuffer
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
+ */
+ vao =_mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayElementBuffer");
+ if (!vao)
+ return;
+
+ /* The GL_ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated if <buffer> is not zero or
+ * the name of an existing buffer object."
+ */
+ if (buffer != 0)
+ bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
+ "glVertexArrayElementBuffer");
+ else
+ bufObj = ctx->Shared->NullBufferObj;
+
+ if (bufObj)
+ _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, bufObj);
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexArrayiv(GLuint vaobj, GLenum pname, GLint *param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexArrayiv(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ /* The GL_ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated if <vaobj> is not
+ * [compatibility profile: zero or] the name of an existing
+ * vertex array object."
+ */
+ vao =_mesa_lookup_vao_err(ctx, vaobj, "glGetVertexArrayiv");
+ if (!vao)
+ return;
+
+ /* The GL_ARB_direct_state_access specification says:
+ *
+ * "An INVALID_ENUM error is generated if <pname> is not
+ * ELEMENT_ARRAY_BUFFER_BINDING."
+ */
+ if (pname != GL_ELEMENT_ARRAY_BUFFER_BINDING) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetVertexArrayiv(pname != "
+ "GL_ELEMENT_ARRAY_BUFFER_BINDING)");
+ return;
+ }
+
+ param[0] = vao->IndexBufferObj->Name;
+}
diff --git a/mesalib/src/mesa/main/arrayobj.h b/mesalib/src/mesa/main/arrayobj.h
index 3c1f91835..6a4247f4a 100644
--- a/mesalib/src/mesa/main/arrayobj.h
+++ b/mesalib/src/mesa/main/arrayobj.h
@@ -49,6 +49,9 @@ extern struct gl_vertex_array_object *
_mesa_lookup_vao(struct gl_context *ctx, GLuint id);
extern struct gl_vertex_array_object *
+_mesa_lookup_vao_err(struct gl_context *ctx, GLuint id, const char *caller);
+
+extern struct gl_vertex_array_object *
_mesa_new_vao(struct gl_context *ctx, GLuint name);
extern void
@@ -93,6 +96,12 @@ void GLAPIENTRY _mesa_GenVertexArrays(GLsizei n, GLuint *arrays);
void GLAPIENTRY _mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *buffer);
+void GLAPIENTRY _mesa_CreateVertexArrays(GLsizei n, GLuint *arrays);
+
GLboolean GLAPIENTRY _mesa_IsVertexArray( GLuint id );
+void GLAPIENTRY _mesa_VertexArrayElementBuffer(GLuint vaobj, GLuint buffer);
+
+void GLAPIENTRY _mesa_GetVertexArrayiv(GLuint vaobj, GLenum pname, GLint *param);
+
#endif /* ARRAYOBJ_H */
diff --git a/mesalib/src/mesa/main/blend.c b/mesalib/src/mesa/main/blend.c
index 774fc888e..d869fa2aa 100644
--- a/mesalib/src/mesa/main/blend.c
+++ b/mesalib/src/mesa/main/blend.c
@@ -769,7 +769,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
}
FLUSH_VERTICES(ctx, _NEW_LIGHT);
ctx->Light.ClampVertexColor = clamp;
- _mesa_update_clamp_vertex_color(ctx);
+ _mesa_update_clamp_vertex_color(ctx, ctx->DrawBuffer);
break;
case GL_CLAMP_FRAGMENT_COLOR_ARB:
if (ctx->API == API_OPENGL_CORE &&
@@ -778,7 +778,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp)
}
FLUSH_VERTICES(ctx, _NEW_FRAG_CLAMP);
ctx->Color.ClampFragmentColor = clamp;
- _mesa_update_clamp_fragment_color(ctx);
+ _mesa_update_clamp_fragment_color(ctx, ctx->DrawBuffer);
break;
case GL_CLAMP_READ_COLOR_ARB:
ctx->Color.ClampReadColor = clamp;
@@ -807,50 +807,55 @@ get_clamp_color(const struct gl_framebuffer *fb, GLenum clamp)
}
GLboolean
-_mesa_get_clamp_fragment_color(const struct gl_context *ctx)
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- return get_clamp_color(ctx->DrawBuffer,
- ctx->Color.ClampFragmentColor);
+ return get_clamp_color(drawFb, ctx->Color.ClampFragmentColor);
}
GLboolean
-_mesa_get_clamp_vertex_color(const struct gl_context *ctx)
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- return get_clamp_color(ctx->DrawBuffer, ctx->Light.ClampVertexColor);
+ return get_clamp_color(drawFb, ctx->Light.ClampVertexColor);
}
GLboolean
-_mesa_get_clamp_read_color(const struct gl_context *ctx)
+_mesa_get_clamp_read_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *readFb)
{
- return get_clamp_color(ctx->ReadBuffer, ctx->Color.ClampReadColor);
+ return get_clamp_color(readFb, ctx->Color.ClampReadColor);
}
/**
* Update the ctx->Color._ClampFragmentColor field
*/
void
-_mesa_update_clamp_fragment_color(struct gl_context *ctx)
+_mesa_update_clamp_fragment_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- struct gl_framebuffer *fb = ctx->DrawBuffer;
-
/* Don't clamp if:
* - there is no colorbuffer
* - all colorbuffers are unsigned normalized, so clamping has no effect
* - there is an integer colorbuffer
*/
- if (!fb || !fb->_HasSNormOrFloatColorBuffer || fb->_IntegerColor)
+ if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
+ drawFb->_IntegerColor)
ctx->Color._ClampFragmentColor = GL_FALSE;
else
- ctx->Color._ClampFragmentColor = _mesa_get_clamp_fragment_color(ctx);
+ ctx->Color._ClampFragmentColor =
+ _mesa_get_clamp_fragment_color(ctx, drawFb);
}
/**
* Update the ctx->Color._ClampVertexColor field
*/
void
-_mesa_update_clamp_vertex_color(struct gl_context *ctx)
+_mesa_update_clamp_vertex_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb)
{
- ctx->Light._ClampVertexColor = _mesa_get_clamp_vertex_color(ctx);
+ ctx->Light._ClampVertexColor =
+ _mesa_get_clamp_vertex_color(ctx, drawFb);
}
/**
diff --git a/mesalib/src/mesa/main/blend.h b/mesalib/src/mesa/main/blend.h
index fe31a7440..8ab9e02fc 100644
--- a/mesalib/src/mesa/main/blend.h
+++ b/mesalib/src/mesa/main/blend.h
@@ -37,6 +37,7 @@
#include "formats.h"
struct gl_context;
+struct gl_framebuffer;
extern void GLAPIENTRY
@@ -101,19 +102,24 @@ extern void GLAPIENTRY
_mesa_ClampColor(GLenum target, GLenum clamp);
extern GLboolean
-_mesa_get_clamp_fragment_color(const struct gl_context *ctx);
+_mesa_get_clamp_fragment_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern GLboolean
-_mesa_get_clamp_vertex_color(const struct gl_context *ctx);
+_mesa_get_clamp_vertex_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern GLboolean
-_mesa_get_clamp_read_color(const struct gl_context *ctx);
+_mesa_get_clamp_read_color(const struct gl_context *ctx,
+ const struct gl_framebuffer *readFb);
extern void
-_mesa_update_clamp_fragment_color(struct gl_context *ctx);
+_mesa_update_clamp_fragment_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern void
-_mesa_update_clamp_vertex_color(struct gl_context *ctx);
+_mesa_update_clamp_vertex_color(struct gl_context *ctx,
+ const struct gl_framebuffer *drawFb);
extern mesa_format
_mesa_get_render_format(const struct gl_context *ctx, mesa_format format);
diff --git a/mesalib/src/mesa/main/blit.c b/mesalib/src/mesa/main/blit.c
index 0694466eb..fac972450 100644
--- a/mesalib/src/mesa/main/blit.c
+++ b/mesalib/src/mesa/main/blit.c
@@ -34,6 +34,7 @@
#include "enums.h"
#include "blit.h"
#include "fbobject.h"
+#include "framebuffer.h"
#include "glformats.h"
#include "mtypes.h"
#include "state.h"
@@ -148,38 +149,25 @@ is_valid_blit_filter(const struct gl_context *ctx, GLenum filter)
}
-/**
- * Blit rectangular region, optionally from one framebuffer to another.
- *
- * Note, if the src buffer is multisampled and the dest is not, this is
- * when the samples must be resolved to a single color.
- */
-void GLAPIENTRY
-_mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
- GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
- GLbitfield mask, GLenum filter)
+void
+_mesa_blit_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter, const char *func)
{
const GLbitfield legalMaskBits = (GL_COLOR_BUFFER_BIT |
GL_DEPTH_BUFFER_BIT |
GL_STENCIL_BUFFER_BIT);
- const struct gl_framebuffer *readFb, *drawFb;
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx,
- "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)\n",
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1,
- mask, _mesa_lookup_enum_by_nr(filter));
-
- if (ctx->NewState) {
- _mesa_update_state(ctx);
- }
+ /* Update completeness status of readFb and drawFb. */
+ _mesa_update_framebuffer(ctx, readFb, drawFb);
- readFb = ctx->ReadBuffer;
- drawFb = ctx->DrawBuffer;
+ /* Make sure drawFb has an initialized bounding box. */
+ _mesa_update_draw_buffer_bounds(ctx, drawFb);
if (!readFb || !drawFb) {
/* This will normally never happen but someday we may want to
@@ -192,12 +180,12 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if (drawFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT ||
readFb->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
_mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
- "glBlitFramebufferEXT(incomplete draw/read buffers)");
+ "%s(incomplete draw/read buffers)", func);
return;
}
if (!is_valid_blit_filter(ctx, filter)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glBlitFramebufferEXT(%s)",
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid filter %s)", func,
_mesa_lookup_enum_by_nr(filter));
return;
}
@@ -205,13 +193,13 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if ((filter == GL_SCALED_RESOLVE_FASTEST_EXT ||
filter == GL_SCALED_RESOLVE_NICEST_EXT) &&
(readFb->Visual.samples == 0 || drawFb->Visual.samples > 0)) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebufferEXT(%s)",
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(%s: invalid samples)", func,
_mesa_lookup_enum_by_nr(filter));
return;
}
if (mask & ~legalMaskBits) {
- _mesa_error( ctx, GL_INVALID_VALUE, "glBlitFramebufferEXT(mask)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(invalid mask bits set)", func);
return;
}
@@ -219,13 +207,13 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if ((mask & (GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT))
&& filter != GL_NEAREST) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)");
+ "%s(depth/stencil requires GL_NEAREST filter)", func);
return;
}
/* get color read/draw renderbuffers */
if (mask & GL_COLOR_BUFFER_BIT) {
- const GLuint numColorDrawBuffers = ctx->DrawBuffer->_NumColorDrawBuffers;
+ const GLuint numColorDrawBuffers = drawFb->_NumColorDrawBuffers;
const struct gl_renderbuffer *colorReadRb = readFb->_ColorReadBuffer;
const struct gl_renderbuffer *colorDrawRb = NULL;
GLuint i;
@@ -241,7 +229,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
}
else {
for (i = 0; i < numColorDrawBuffers; i++) {
- colorDrawRb = ctx->DrawBuffer->_ColorDrawBuffers[i];
+ colorDrawRb = drawFb->_ColorDrawBuffers[i];
if (!colorDrawRb)
continue;
@@ -257,15 +245,15 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
*/
if (_mesa_is_gles3(ctx) && (colorDrawRb == colorReadRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(source and destination color "
- "buffer cannot be the same)");
+ "%s(source and destination color "
+ "buffer cannot be the same)", func);
return;
}
if (!compatible_color_datatypes(colorReadRb->Format,
colorDrawRb->Format)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(color buffer datatypes mismatch)");
+ "%s(color buffer datatypes mismatch)", func);
return;
}
/* extra checks for multisample copies... */
@@ -273,7 +261,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
/* color formats must match */
if (!compatible_resolve_formats(colorReadRb, colorDrawRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(bad src/dst multisample pixel formats)");
+ "%s(bad src/dst multisample pixel formats)", func);
return;
}
}
@@ -286,7 +274,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLenum type = _mesa_get_format_datatype(colorReadRb->Format);
if (type == GL_INT || type == GL_UNSIGNED_INT) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(integer color type)");
+ "%s(integer color type)", func);
return;
}
}
@@ -306,15 +294,15 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* ignored."
*/
if ((readRb == NULL) || (drawRb == NULL)) {
- mask &= ~GL_STENCIL_BUFFER_BIT;
+ mask &= ~GL_STENCIL_BUFFER_BIT;
}
else {
int read_z_bits, draw_z_bits;
if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(source and destination stencil "
- "buffer cannot be the same)");
+ "%s(source and destination stencil "
+ "buffer cannot be the same)", func);
return;
}
@@ -324,7 +312,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* there is only one: GL_UNSIGNED_INT.
*/
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(stencil attachment format mismatch)");
+ "%s(stencil attachment format mismatch)", func);
return;
}
@@ -340,8 +328,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
_mesa_get_format_datatype(readRb->Format) !=
_mesa_get_format_datatype(drawRb->Format))) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebuffer"
- "(stencil attachment depth format mismatch)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(stencil attachment depth format mismatch)", func);
return;
}
}
@@ -360,15 +348,15 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* ignored."
*/
if ((readRb == NULL) || (drawRb == NULL)) {
- mask &= ~GL_DEPTH_BUFFER_BIT;
+ mask &= ~GL_DEPTH_BUFFER_BIT;
}
else {
int read_s_bit, draw_s_bit;
if (_mesa_is_gles3(ctx) && (drawRb == readRb)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(source and destination depth "
- "buffer cannot be the same)");
+ "%s(source and destination depth "
+ "buffer cannot be the same)", func);
return;
}
@@ -377,7 +365,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
(_mesa_get_format_datatype(readRb->Format) !=
_mesa_get_format_datatype(drawRb->Format))) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(depth attachment format mismatch)");
+ "%s(depth attachment format mismatch)", func);
return;
}
@@ -389,8 +377,8 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
* we should ignore the stencil format check.
*/
if (read_s_bit > 0 && draw_s_bit > 0 && read_s_bit != draw_s_bit) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glBlitFramebuffer"
- "(depth attachment stencil bits mismatch)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(depth attachment stencil bits mismatch)", func);
return;
}
}
@@ -406,7 +394,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
*/
if (drawFb->Visual.samples > 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(destination samples must be 0)");
+ "%s(destination samples must be 0)", func);
return;
}
@@ -426,7 +414,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
&& (srcX0 != dstX0 || srcY0 != dstY0
|| srcX1 != dstX1 || srcY1 != dstY1)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebuffer(bad src/dst multisample region)");
+ "%s(bad src/dst multisample region)", func);
return;
}
} else {
@@ -434,7 +422,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
drawFb->Visual.samples > 0 &&
readFb->Visual.samples != drawFb->Visual.samples) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(mismatched samples)");
+ "%s(mismatched samples)", func);
return;
}
@@ -445,7 +433,7 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
if (abs(srcX1 - srcX0) != abs(dstX1 - dstX0) ||
abs(srcY1 - srcY0) != abs(dstY1 - dstY0)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBlitFramebufferEXT(bad src/dst multisample region sizes)");
+ "%s(bad src/dst multisample region sizes)", func);
return;
}
}
@@ -457,43 +445,44 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
const struct gl_renderbuffer *colorDrawRb = NULL;
GLuint i = 0;
- printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d,"
- " 0x%x, 0x%x)\n",
- srcX0, srcY0, srcX1, srcY1,
- dstX0, dstY0, dstX1, dstY1,
- mask, filter);
+ printf("%s(%d, %d, %d, %d, %d, %d, %d, %d,"
+ " 0x%x, 0x%x)\n", func,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter);
+
if (colorReadRb) {
const struct gl_renderbuffer_attachment *att;
att = find_attachment(readFb, colorReadRb);
printf(" Src FBO %u RB %u (%dx%d) ",
- readFb->Name, colorReadRb->Name,
- colorReadRb->Width, colorReadRb->Height);
+ readFb->Name, colorReadRb->Name,
+ colorReadRb->Width, colorReadRb->Height);
if (att && att->Texture) {
printf("Tex %u tgt 0x%x level %u face %u",
- att->Texture->Name,
- att->Texture->Target,
- att->TextureLevel,
- att->CubeMapFace);
+ att->Texture->Name,
+ att->Texture->Target,
+ att->TextureLevel,
+ att->CubeMapFace);
}
printf("\n");
/* Print all active color render buffers */
- for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; i++) {
- colorDrawRb = ctx->DrawBuffer->_ColorDrawBuffers[i];
+ for (i = 0; i < drawFb->_NumColorDrawBuffers; i++) {
+ colorDrawRb = drawFb->_ColorDrawBuffers[i];
if (!colorDrawRb)
continue;
att = find_attachment(drawFb, colorDrawRb);
printf(" Dst FBO %u RB %u (%dx%d) ",
- drawFb->Name, colorDrawRb->Name,
- colorDrawRb->Width, colorDrawRb->Height);
+ drawFb->Name, colorDrawRb->Name,
+ colorDrawRb->Width, colorDrawRb->Height);
if (att && att->Texture) {
printf("Tex %u tgt 0x%x level %u face %u",
- att->Texture->Name,
- att->Texture->Target,
- att->TextureLevel,
- att->CubeMapFace);
+ att->Texture->Name,
+ att->Texture->Target,
+ att->TextureLevel,
+ att->CubeMapFace);
}
printf("\n");
}
@@ -507,8 +496,94 @@ _mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
}
assert(ctx->Driver.BlitFramebuffer);
- ctx->Driver.BlitFramebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
+ ctx->Driver.BlitFramebuffer(ctx, readFb, drawFb,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
mask, filter);
}
+
+
+/**
+ * Blit rectangular region, optionally from one framebuffer to another.
+ *
+ * Note, if the src buffer is multisampled and the dest is not, this is
+ * when the samples must be resolved to a single color.
+ */
+void GLAPIENTRY
+_mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx,
+ "glBlitFramebuffer(%d, %d, %d, %d, "
+ " %d, %d, %d, %d, 0x%x, %s)\n",
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, _mesa_lookup_enum_by_nr(filter));
+
+ _mesa_blit_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter, "glBlitFramebuffer");
+}
+
+
+void GLAPIENTRY
+_mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *readFb, *drawFb;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBlitNamedFramebuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx,
+ "glBlitNamedFramebuffer(%u %u %d, %d, %d, %d, "
+ " %d, %d, %d, %d, 0x%x, %s)\n",
+ readFramebuffer, drawFramebuffer,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, _mesa_lookup_enum_by_nr(filter));
+
+ /*
+ * According to PDF page 533 of the OpenGL 4.5 core spec (30.10.2014,
+ * Section 18.3 Copying Pixels):
+ * "... if readFramebuffer or drawFramebuffer is zero (for
+ * BlitNamedFramebuffer), then the default read or draw framebuffer is
+ * used as the corresponding source or destination framebuffer,
+ * respectively."
+ */
+ if (readFramebuffer) {
+ readFb = _mesa_lookup_framebuffer_err(ctx, readFramebuffer,
+ "glBlitNamedFramebuffer");
+ if (!readFb)
+ return;
+ }
+ else
+ readFb = ctx->WinSysReadBuffer;
+
+ if (drawFramebuffer) {
+ drawFb = _mesa_lookup_framebuffer_err(ctx, drawFramebuffer,
+ "glBlitNamedFramebuffer");
+ if (!drawFb)
+ return;
+ }
+ else
+ drawFb = ctx->WinSysDrawBuffer;
+
+ _mesa_blit_framebuffer(ctx, readFb, drawFb,
+ srcX0, srcY0, srcX1, srcY1,
+ dstX0, dstY0, dstX1, dstY1,
+ mask, filter, "glBlitNamedFramebuffer");
+}
diff --git a/mesalib/src/mesa/main/blit.h b/mesalib/src/mesa/main/blit.h
index 01a958af5..54b946e31 100644
--- a/mesalib/src/mesa/main/blit.h
+++ b/mesalib/src/mesa/main/blit.h
@@ -28,11 +28,24 @@
#include "glheader.h"
+extern void
+_mesa_blit_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter, const char *func);
extern void GLAPIENTRY
_mesa_BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter);
+extern void GLAPIENTRY
+_mesa_BlitNamedFramebuffer(GLuint readFramebuffer, GLuint drawFramebuffer,
+ GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
+ GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
+ GLbitfield mask, GLenum filter);
+
#endif /* BLIT_H */
diff --git a/mesalib/src/mesa/main/bufferobj.c b/mesalib/src/mesa/main/bufferobj.c
index 66dee6802..660bc9489 100644
--- a/mesalib/src/mesa/main/bufferobj.c
+++ b/mesalib/src/mesa/main/bufferobj.c
@@ -1303,6 +1303,12 @@ create_buffers(GLsizei n, GLuint *buffers, bool dsa)
const char *func = dsa ? "glCreateBuffers" : "glGenBuffers";
+ if (dsa && !ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
+
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "%s(%d)\n", func, n);
@@ -1477,6 +1483,13 @@ _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedBufferStorage(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferStorage");
if (!bufObj)
return;
@@ -1603,6 +1616,13 @@ _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedBufferData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData");
if (!bufObj)
return;
@@ -1673,6 +1693,13 @@ _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferSubData");
if (!bufObj)
return;
@@ -1710,6 +1737,13 @@ _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferSubData");
if (!bufObj)
@@ -1805,6 +1839,13 @@ _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedBufferData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glClearNamedBufferData");
if (!bufObj)
return;
@@ -1842,6 +1883,13 @@ _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glClearNamedBufferSubData");
if (!bufObj)
@@ -1930,6 +1978,13 @@ _mesa_UnmapNamedBuffer(GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glUnmapNamedBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return GL_FALSE;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glUnmapNamedBuffer");
if (!bufObj)
return GL_FALSE;
@@ -2039,6 +2094,13 @@ _mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params)
struct gl_buffer_object *bufObj;
GLint64 parameter;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferParameteriv");
if (!bufObj)
@@ -2059,6 +2121,13 @@ _mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
struct gl_buffer_object *bufObj;
GLint64 parameter;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferParameteri64v(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glGetNamedBufferParameteri64v");
if (!bufObj)
@@ -2098,6 +2167,13 @@ _mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params)
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedBufferPointerv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (pname != GL_BUFFER_MAP_POINTER) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetNamedBufferPointerv(pname != "
"GL_BUFFER_MAP_POINTER)");
@@ -2212,6 +2288,13 @@ _mesa_CopyNamedBufferSubData(GLuint readBuffer, GLuint writeBuffer,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *src, *dst;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyNamedBufferSubData(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
src = _mesa_lookup_bufferobj_err(ctx, readBuffer,
"glCopyNamedBufferSubData");
if (!src)
@@ -2430,6 +2513,13 @@ _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glMapNamedBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return NULL;
+ }
+
if (!ctx->Extensions.ARB_map_buffer_range) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glMapNamedBufferRange("
@@ -2497,6 +2587,13 @@ _mesa_MapNamedBuffer(GLuint buffer, GLenum access)
struct gl_buffer_object *bufObj;
GLbitfield accessFlags;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glMapNamedBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return NULL;
+ }
+
if (!get_map_buffer_access_flags(ctx, access, &accessFlags)) {
_mesa_error(ctx, GL_INVALID_ENUM, "glMapNamedBuffer(invalid access)");
return NULL;
@@ -2587,6 +2684,14 @@ _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glFlushMappedNamedBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glFlushMappedNamedBufferRange");
if (!bufObj)
diff --git a/mesalib/src/mesa/main/buffers.c b/mesalib/src/mesa/main/buffers.c
index 37a979092..c83459add 100644
--- a/mesalib/src/mesa/main/buffers.c
+++ b/mesalib/src/mesa/main/buffers.c
@@ -242,16 +242,16 @@ read_buffer_enum_to_index(GLenum buffer)
*
* See the GL_EXT_framebuffer_object spec for more info.
*/
-void GLAPIENTRY
-_mesa_DrawBuffer(GLenum buffer)
+void
+_mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller)
{
GLbitfield destMask;
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API) {
- _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+ _mesa_debug(ctx, "%s %s\n", caller, _mesa_lookup_enum_by_nr(buffer));
}
if (buffer == GL_NONE) {
@@ -259,33 +259,67 @@ _mesa_DrawBuffer(GLenum buffer)
}
else {
const GLbitfield supportedMask
- = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
+ = supported_buffer_bitmask(ctx, fb);
destMask = draw_buffer_enum_to_bitmask(ctx, buffer);
if (destMask == BAD_MASK) {
/* totally bogus buffer */
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glDrawBuffer(buffer=0x%x)", buffer);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
return;
}
destMask &= supportedMask;
if (destMask == 0x0) {
/* none of the named color buffers exist! */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffer(buffer=0x%x)", buffer);
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffer));
return;
}
}
/* if we get here, there's no error so set new state */
- _mesa_drawbuffers(ctx, 1, &buffer, &destMask);
+ _mesa_drawbuffers(ctx, fb, 1, &buffer, &destMask);
+
+ /* Call device driver function only if fb is the bound draw buffer */
+ if (fb == ctx->DrawBuffer) {
+ if (ctx->Driver.DrawBuffers)
+ ctx->Driver.DrawBuffers(ctx, 1, &buffer);
+ else if (ctx->Driver.DrawBuffer)
+ ctx->Driver.DrawBuffer(ctx, buffer);
+ }
+}
- /*
- * Call device driver function.
- */
- if (ctx->Driver.DrawBuffers)
- ctx->Driver.DrawBuffers(ctx, 1, &buffer);
- else if (ctx->Driver.DrawBuffer)
- ctx->Driver.DrawBuffer(ctx, buffer);
+
+void GLAPIENTRY
+_mesa_DrawBuffer(GLenum buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_draw_buffer(ctx, ctx->DrawBuffer, buffer, "glDrawBuffer");
+}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferDrawBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferDrawBuffer");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ _mesa_draw_buffer(ctx, fb, buf, "glNamedFramebufferDrawBuffer");
}
@@ -298,13 +332,13 @@ _mesa_DrawBuffer(GLenum buffer)
* names cannot specify more than one buffer. For example,
* GL_FRONT_AND_BACK is illegal.
*/
-void GLAPIENTRY
-_mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
+void
+_mesa_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLsizei n, const GLenum *buffers, const char *caller)
{
GLuint output;
GLbitfield usedBufferMask, supportedMask;
GLbitfield destMask[MAX_DRAW_BUFFERS];
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
@@ -315,12 +349,18 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* "An INVALID_VALUE error is generated if n is greater than
* MAX_DRAW_BUFFERS."
*/
- if (n < 0 || n > (GLsizei) ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)");
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", caller);
+ return;
+ }
+
+ if (n > (GLsizei) ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(n > maximum number of draw buffers)", caller);
return;
}
- supportedMask = supported_buffer_bitmask(ctx, ctx->DrawBuffer);
+ supportedMask = supported_buffer_bitmask(ctx, fb);
usedBufferMask = 0x0;
/* From the ES 3.0 specification, page 180:
@@ -328,9 +368,9 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* and the constant must be BACK or NONE."
* (same restriction applies with GL_EXT_draw_buffers specification)
*/
- if (ctx->API == API_OPENGLES2 && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
+ if (ctx->API == API_OPENGLES2 && _mesa_is_winsys_fbo(fb) &&
(n != 1 || (buffers[0] != GL_NONE && buffers[0] != GL_BACK))) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(invalid buffers)", caller);
return;
}
@@ -362,9 +402,11 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* or equal to the value of MAX_COLOR_ATTACHMENTS, then the error
* INVALID_OPERATION results."
*/
- if (_mesa_is_user_fbo(ctx->DrawBuffer) && buffers[output] >=
+ if (_mesa_is_user_fbo(fb) && buffers[output] >=
GL_COLOR_ATTACHMENT0 + ctx->Const.MaxDrawBuffers) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffersARB(buffer)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(buffers[%d] >= maximum number of draw buffers)",
+ caller, output);
return;
}
@@ -375,9 +417,10 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* 4.5 or 4.6. Otherwise, an INVALID_ENUM error is generated.
*/
if (destMask[output] == BAD_MASK) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
- }
+ }
/* From the OpenGL 4.0 specification, page 256:
* "For both the default framebuffer and framebuffer objects, the
@@ -390,7 +433,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* but the Khronos conformance tests expect INVALID_ENUM.
*/
if (_mesa_bitcount(destMask[output]) > 1) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -407,7 +451,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
destMask[output] &= supportedMask;
if (destMask[output] == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffersARB(unsupported buffer)");
+ "%s(unsupported buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -416,10 +461,12 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* in bufs must be COLOR_ATTACHMENTi or NONE. [...] INVALID_OPERATION."
* (same restriction applies with GL_EXT_draw_buffers specification)
*/
- if (ctx->API == API_OPENGLES2 && _mesa_is_user_fbo(ctx->DrawBuffer) &&
+ if (ctx->API == API_OPENGLES2 && _mesa_is_user_fbo(fb) &&
buffers[output] != GL_NONE &&
buffers[output] != GL_COLOR_ATTACHMENT0 + output) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(unsupported buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -430,7 +477,8 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
*/
if (destMask[output] & usedBufferMask) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glDrawBuffersARB(duplicated buffer)");
+ "%s(duplicated buffer %s)",
+ caller, _mesa_lookup_enum_by_nr(buffers[output]));
return;
}
@@ -440,17 +488,55 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
}
/* OK, if we get here, there were no errors so set the new state */
- _mesa_drawbuffers(ctx, n, buffers, destMask);
+ _mesa_drawbuffers(ctx, fb, n, buffers, destMask);
/*
- * Call device driver function. Note that n can be equal to 0,
+ * Call device driver function if fb is the bound draw buffer.
+ * Note that n can be equal to 0,
* in which case we don't want to reference buffers[0], which
* may not be valid.
*/
- if (ctx->Driver.DrawBuffers)
- ctx->Driver.DrawBuffers(ctx, n, buffers);
- else if (ctx->Driver.DrawBuffer)
- ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE);
+ if (fb == ctx->DrawBuffer) {
+ if (ctx->Driver.DrawBuffers)
+ ctx->Driver.DrawBuffers(ctx, n, buffers);
+ else if (ctx->Driver.DrawBuffer)
+ ctx->Driver.DrawBuffer(ctx, n > 0 ? buffers[0] : GL_NONE);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_draw_buffers(ctx, ctx->DrawBuffer, n, buffers, "glDrawBuffers");
+}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
+ const GLenum *bufs)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferDrawBuffers(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferDrawBuffers");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ _mesa_draw_buffers(ctx, fb, n, bufs, "glNamedFramebufferDrawBuffers");
}
@@ -459,13 +545,11 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
* actual change.
*/
static void
-updated_drawbuffers(struct gl_context *ctx)
+updated_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb)
{
FLUSH_VERTICES(ctx, _NEW_BUFFERS);
if (ctx->API == API_OPENGL_COMPAT && !ctx->Extensions.ARB_ES2_compatibility) {
- struct gl_framebuffer *fb = ctx->DrawBuffer;
-
/* Flag the FBO as requiring validation. */
if (_mesa_is_user_fbo(fb)) {
fb->_Status = 0;
@@ -482,6 +566,7 @@ updated_drawbuffers(struct gl_context *ctx)
* so nothing should go wrong at this point.
*
* \param ctx current context
+ * \param fb the desired draw buffer
* \param n number of color outputs to set
* \param buffers array[n] of colorbuffer names, like GL_LEFT.
* \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the
@@ -489,10 +574,9 @@ updated_drawbuffers(struct gl_context *ctx)
* BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
*/
void
-_mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
- const GLbitfield *destMask)
+_mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint n, const GLenum *buffers, const GLbitfield *destMask)
{
- struct gl_framebuffer *fb = ctx->DrawBuffer;
GLbitfield mask[MAX_DRAW_BUFFERS];
GLuint buf;
@@ -518,7 +602,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
while (destMask0) {
GLint bufIndex = ffs(destMask0) - 1;
if (fb->_ColorDrawBufferIndexes[count] != bufIndex) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[count] = bufIndex;
}
count++;
@@ -535,14 +619,14 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
/* only one bit should be set in the destMask[buf] field */
assert(_mesa_bitcount(destMask[buf]) == 1);
if (fb->_ColorDrawBufferIndexes[buf] != bufIndex) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = bufIndex;
}
count = buf + 1;
}
else {
if (fb->_ColorDrawBufferIndexes[buf] != -1) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = -1;
}
}
@@ -554,7 +638,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
/* set remaining outputs to -1 (GL_NONE) */
for (buf = fb->_NumColorDrawBuffers; buf < ctx->Const.MaxDrawBuffers; buf++) {
if (fb->_ColorDrawBufferIndexes[buf] != -1) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
fb->_ColorDrawBufferIndexes[buf] = -1;
}
}
@@ -566,7 +650,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
/* also set context drawbuffer state */
for (buf = 0; buf < ctx->Const.MaxDrawBuffers; buf++) {
if (ctx->Color.DrawBuffer[buf] != fb->ColorDrawBuffer[buf]) {
- updated_drawbuffers(ctx);
+ updated_drawbuffers(ctx, fb);
ctx->Color.DrawBuffer[buf] = fb->ColorDrawBuffer[buf];
}
}
@@ -585,7 +669,7 @@ _mesa_update_draw_buffers(struct gl_context *ctx)
/* should be a window system FBO */
assert(_mesa_is_winsys_fbo(ctx->DrawBuffer));
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, ctx->Const.MaxDrawBuffers,
ctx->Color.DrawBuffer, NULL);
}
@@ -598,11 +682,10 @@ _mesa_update_draw_buffers(struct gl_context *ctx)
* \param bufferIndex the numerical index corresponding to 'buffer'
*/
void
-_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex)
+_mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, GLint bufferIndex)
{
- struct gl_framebuffer *fb = ctx->ReadBuffer;
-
- if (_mesa_is_winsys_fbo(fb)) {
+ if ((fb == ctx->ReadBuffer) && _mesa_is_winsys_fbo(fb)) {
/* Only update the per-context READ_BUFFER state if we're bound to
* a window-system framebuffer.
*/
@@ -621,23 +704,17 @@ _mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex)
* Called by glReadBuffer to set the source renderbuffer for reading pixels.
* \param mode color buffer such as GL_FRONT, GL_BACK, etc.
*/
-void GLAPIENTRY
-_mesa_ReadBuffer(GLenum buffer)
+void
+_mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller)
{
- struct gl_framebuffer *fb;
GLbitfield supportedMask;
GLint srcBuffer;
- GET_CURRENT_CONTEXT(ctx);
FLUSH_VERTICES(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
-
- fb = ctx->ReadBuffer;
-
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+ _mesa_debug(ctx, "%s %s\n", caller, _mesa_lookup_enum_by_nr(buffer));
if (buffer == GL_NONE) {
/* This is legal--it means that no buffer should be bound for reading. */
@@ -648,24 +725,60 @@ _mesa_ReadBuffer(GLenum buffer)
srcBuffer = read_buffer_enum_to_index(buffer);
if (srcBuffer == -1) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glReadBuffer(buffer=0x%x)", buffer);
+ "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
return;
}
supportedMask = supported_buffer_bitmask(ctx, fb);
if (((1 << srcBuffer) & supportedMask) == 0) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glReadBuffer(buffer=0x%x)", buffer);
+ "%s(invalid buffer %s)", caller,
+ _mesa_lookup_enum_by_nr(buffer));
return;
}
}
/* OK, all error checking has been completed now */
- _mesa_readbuffer(ctx, buffer, srcBuffer);
+ _mesa_readbuffer(ctx, fb, buffer, srcBuffer);
- /*
- * Call device driver function.
- */
- if (ctx->Driver.ReadBuffer)
- (*ctx->Driver.ReadBuffer)(ctx, buffer);
+ /* Call the device driver function only if fb is the bound read buffer */
+ if (fb == ctx->ReadBuffer) {
+ if (ctx->Driver.ReadBuffer)
+ (*ctx->Driver.ReadBuffer)(ctx, buffer);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_ReadBuffer(GLenum buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_read_buffer(ctx, ctx->ReadBuffer, buffer, "glReadBuffer");
+}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferReadBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferReadBuffer");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysReadBuffer;
+
+ _mesa_read_buffer(ctx, fb, src, "glNamedFramebufferReadBuffer");
}
diff --git a/mesalib/src/mesa/main/buffers.h b/mesalib/src/mesa/main/buffers.h
index ebcfa1c1e..5aa79fda5 100644
--- a/mesalib/src/mesa/main/buffers.h
+++ b/mesalib/src/mesa/main/buffers.h
@@ -36,26 +36,51 @@
#include "glheader.h"
struct gl_context;
+struct gl_framebuffer;
+
+extern void
+_mesa_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller);
extern void GLAPIENTRY
_mesa_DrawBuffer( GLenum mode );
extern void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffer(GLuint framebuffer, GLenum buf);
+
+extern void
+_mesa_draw_buffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLsizei n, const GLenum *buffers, const char *caller);
+
+extern void GLAPIENTRY
_mesa_DrawBuffers(GLsizei n, const GLenum *buffers);
+extern void GLAPIENTRY
+_mesa_NamedFramebufferDrawBuffers(GLuint framebuffer, GLsizei n,
+ const GLenum *bufs);
+
extern void
-_mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
+_mesa_drawbuffers(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLuint n, const GLenum *buffers,
const GLbitfield *destMask);
extern void
-_mesa_readbuffer(struct gl_context *ctx, GLenum buffer, GLint bufferIndex);
+_mesa_readbuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, GLint bufferIndex);
extern void
_mesa_update_draw_buffers(struct gl_context *ctx);
+extern void
+_mesa_read_buffer(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum buffer, const char *caller);
+
extern void GLAPIENTRY
_mesa_ReadBuffer( GLenum mode );
+extern void GLAPIENTRY
+_mesa_NamedFramebufferReadBuffer(GLuint framebuffer, GLenum src);
+
#endif
diff --git a/mesalib/src/mesa/main/clear.c b/mesalib/src/mesa/main/clear.c
index 8d707bc34..c6999f7fd 100644
--- a/mesalib/src/mesa/main/clear.c
+++ b/mesalib/src/mesa/main/clear.c
@@ -34,6 +34,8 @@
#include "clear.h"
#include "context.h"
#include "enums.h"
+#include "fbobject.h"
+#include "get.h"
#include "macros.h"
#include "mtypes.h"
#include "state.h"
@@ -400,6 +402,32 @@ _mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value)
/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLint *value)
+{
+ GLint oldfb;
+
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferiv(buffer, drawbuffer, value);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
+
+/**
* New in GL 3.0
* Clear unsigned integer color buffer (not depth, not stencil).
*/
@@ -472,6 +500,32 @@ _mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value)
/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLuint *value)
+{
+ GLint oldfb;
+
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferuiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferuiv(buffer, drawbuffer, value);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
+
+/**
* New in GL 3.0
* Clear fixed-pt or float color buffer or depth buffer (not stencil).
*/
@@ -565,6 +619,32 @@ _mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value)
/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLfloat *value)
+{
+ GLint oldfb;
+
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferfv(buffer, drawbuffer, value);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
+
+
+/**
* New in GL 3.0
* Clear depth/stencil buffer only.
*/
@@ -626,3 +706,29 @@ _mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
ctx->Stencil.Clear = clearStencilSave;
}
}
+
+
+/**
+ * The ClearBuffer framework is so complicated and so riddled with the
+ * assumption that the framebuffer is bound that, for now, we will just fake
+ * direct state access clearing for the user.
+ */
+void GLAPIENTRY
+_mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
+ GLfloat depth, GLint stencil)
+{
+ GLint oldfb;
+
+ GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glClearNamedFramebufferfi(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ _mesa_GetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldfb);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer);
+ _mesa_ClearBufferfi(buffer, 0, depth, stencil);
+ _mesa_BindFramebuffer(GL_DRAW_FRAMEBUFFER, (GLuint) oldfb);
+}
diff --git a/mesalib/src/mesa/main/clear.h b/mesalib/src/mesa/main/clear.h
index 96ce47b92..c29850676 100644
--- a/mesalib/src/mesa/main/clear.h
+++ b/mesalib/src/mesa/main/clear.h
@@ -52,13 +52,29 @@ extern void GLAPIENTRY
_mesa_ClearBufferiv(GLenum buffer, GLint drawbuffer, const GLint *value);
extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLint *value);
+
+extern void GLAPIENTRY
_mesa_ClearBufferuiv(GLenum buffer, GLint drawbuffer, const GLuint *value);
extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferuiv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLuint *value);
+
+extern void GLAPIENTRY
_mesa_ClearBufferfv(GLenum buffer, GLint drawbuffer, const GLfloat *value);
extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferfv(GLuint framebuffer, GLenum buffer,
+ GLint drawbuffer, const GLfloat *value);
+
+extern void GLAPIENTRY
_mesa_ClearBufferfi(GLenum buffer, GLint drawbuffer,
GLfloat depth, GLint stencil);
+extern void GLAPIENTRY
+_mesa_ClearNamedFramebufferfi(GLuint framebuffer, GLenum buffer,
+ GLfloat depth, GLint stencil);
+
#endif
diff --git a/mesalib/src/mesa/main/compute.c b/mesalib/src/mesa/main/compute.c
index 5756666b6..37a4ba70e 100644
--- a/mesalib/src/mesa/main/compute.c
+++ b/mesalib/src/mesa/main/compute.c
@@ -31,9 +31,27 @@ _mesa_DispatchCompute(GLuint num_groups_x,
GLuint num_groups_z)
{
GET_CURRENT_CONTEXT(ctx);
+ int i;
+ struct gl_shader_program *prog;
+ const GLuint num_groups[3] = { num_groups_x, num_groups_y, num_groups_z };
if (ctx->Extensions.ARB_compute_shader) {
- assert(!"TODO");
+ for (i = 0; i < 3; i++) {
+ if (num_groups[i] > ctx->Const.MaxComputeWorkGroupCount[i]) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glDispatchCompute(num_groups_%c)", 'x' + i);
+ return;
+ }
+ }
+ if (!_mesa_valid_to_render(ctx, "glDispatchCompute"))
+ return;
+ prog = ctx->Shader.CurrentProgram[MESA_SHADER_COMPUTE];
+ if (prog == NULL || prog->_LinkedShaders[MESA_SHADER_COMPUTE] == NULL) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDispatchCompute(no active compute shader)");
+ return;
+ }
+ ctx->Driver.DispatchCompute(ctx, num_groups);
} else {
_mesa_error(ctx, GL_INVALID_OPERATION,
"unsupported function (glDispatchCompute) called");
diff --git a/mesalib/src/mesa/main/context.c b/mesalib/src/mesa/main/context.c
index 4aaf8b1af..544cc142f 100644
--- a/mesalib/src/mesa/main/context.c
+++ b/mesalib/src/mesa/main/context.c
@@ -118,6 +118,7 @@
#include "scissor.h"
#include "shared.h"
#include "shaderobj.h"
+#include "shaderimage.h"
#include "util/simple_list.h"
#include "state.h"
#include "stencil.h"
@@ -821,6 +822,7 @@ init_attrib_groups(struct gl_context *ctx)
_mesa_init_feedback( ctx );
_mesa_init_fog( ctx );
_mesa_init_hint( ctx );
+ _mesa_init_image_units( ctx );
_mesa_init_line( ctx );
_mesa_init_lighting( ctx );
_mesa_init_matrix( ctx );
@@ -1563,7 +1565,8 @@ handle_first_current(struct gl_context *ctx)
else
buffer = GL_FRONT;
- _mesa_drawbuffers(ctx, 1, &buffer, NULL /* destMask */);
+ _mesa_drawbuffers(ctx, ctx->DrawBuffer, 1, &buffer,
+ NULL /* destMask */);
}
if (ctx->ReadBuffer != _mesa_get_incomplete_framebuffer()) {
@@ -1576,7 +1579,7 @@ handle_first_current(struct gl_context *ctx)
bufferIndex = BUFFER_FRONT_LEFT;
}
- _mesa_readbuffer(ctx, buffer, bufferIndex);
+ _mesa_readbuffer(ctx, ctx->ReadBuffer, buffer, bufferIndex);
}
}
diff --git a/mesalib/src/mesa/main/context.h b/mesalib/src/mesa/main/context.h
index 1cd89a84a..6f3c94101 100644
--- a/mesalib/src/mesa/main/context.h
+++ b/mesalib/src/mesa/main/context.h
@@ -285,7 +285,7 @@ do { \
/**
* Checks if the context is for Desktop GL (Compatibility or Core)
*/
-static inline GLboolean
+static inline bool
_mesa_is_desktop_gl(const struct gl_context *ctx)
{
return ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGL_CORE;
@@ -295,7 +295,7 @@ _mesa_is_desktop_gl(const struct gl_context *ctx)
/**
* Checks if the context is for any GLES version
*/
-static inline GLboolean
+static inline bool
_mesa_is_gles(const struct gl_context *ctx)
{
return ctx->API == API_OPENGLES || ctx->API == API_OPENGLES2;
@@ -303,9 +303,9 @@ _mesa_is_gles(const struct gl_context *ctx)
/**
- * Checks if the context is for GLES 3.x
+ * Checks if the context is for GLES 3.0 or later
*/
-static inline GLboolean
+static inline bool
_mesa_is_gles3(const struct gl_context *ctx)
{
return ctx->API == API_OPENGLES2 && ctx->Version >= 30;
@@ -313,9 +313,19 @@ _mesa_is_gles3(const struct gl_context *ctx)
/**
+ * Checks if the context is for GLES 3.1 or later
+ */
+static inline bool
+_mesa_is_gles31(const struct gl_context *ctx)
+{
+ return ctx->API == API_OPENGLES2 && ctx->Version >= 31;
+}
+
+
+/**
* Checks if the context supports geometry shaders.
*/
-static inline GLboolean
+static inline bool
_mesa_has_geometry_shaders(const struct gl_context *ctx)
{
return _mesa_is_desktop_gl(ctx) &&
diff --git a/mesalib/src/mesa/main/dd.h b/mesalib/src/mesa/main/dd.h
index 0c1a13fa4..d783e3422 100644
--- a/mesalib/src/mesa/main/dd.h
+++ b/mesalib/src/mesa/main/dd.h
@@ -1005,6 +1005,13 @@ struct dd_function_table {
void (*MemoryBarrier)(struct gl_context *ctx, GLbitfield barriers);
/** @} */
+
+ /**
+ * \name GL_ARB_compute_shader interface
+ */
+ /*@{*/
+ void (*DispatchCompute)(struct gl_context *ctx, const GLuint *num_groups);
+ /*@}*/
};
@@ -1167,6 +1174,19 @@ typedef struct {
void (GLAPIENTRYP VertexAttribP4uiv)( GLuint index, GLenum type,
GLboolean normalized,
const GLuint *value);
+
+ /* GL_ARB_vertex_attrib_64bit / GL 4.1 */
+ void (GLAPIENTRYP VertexAttribL1d)( GLuint index, GLdouble x);
+ void (GLAPIENTRYP VertexAttribL2d)( GLuint index, GLdouble x, GLdouble y);
+ void (GLAPIENTRYP VertexAttribL3d)( GLuint index, GLdouble x, GLdouble y, GLdouble z);
+ void (GLAPIENTRYP VertexAttribL4d)( GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+
+
+ void (GLAPIENTRYP VertexAttribL1dv)( GLuint index, const GLdouble *v);
+ void (GLAPIENTRYP VertexAttribL2dv)( GLuint index, const GLdouble *v);
+ void (GLAPIENTRYP VertexAttribL3dv)( GLuint index, const GLdouble *v);
+ void (GLAPIENTRYP VertexAttribL4dv)( GLuint index, const GLdouble *v);
+
} GLvertexformat;
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index 9be8993b0..c82416aa0 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -104,7 +104,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_depth_clamp", o(ARB_depth_clamp), GL, 2003 },
{ "GL_ARB_depth_texture", o(ARB_depth_texture), GLL, 2001 },
{ "GL_ARB_derivative_control", o(ARB_derivative_control), GL, 2014 },
- { "GL_ARB_direct_state_access", o(dummy_false), GL, 2014 },
+ { "GL_ARB_direct_state_access", o(ARB_direct_state_access), GL, 2014 },
{ "GL_ARB_draw_buffers", o(dummy_true), GL, 2002 },
{ "GL_ARB_draw_buffers_blend", o(ARB_draw_buffers_blend), GL, 2009 },
{ "GL_ARB_draw_elements_base_vertex", o(ARB_draw_elements_base_vertex), GL, 2009 },
@@ -203,6 +203,7 @@ static const struct extension extension_table[] = {
{ "GL_ARB_vertex_buffer_object", o(dummy_true), GLL, 2003 },
{ "GL_ARB_vertex_program", o(ARB_vertex_program), GLL, 2002 },
{ "GL_ARB_vertex_shader", o(ARB_vertex_shader), GL, 2002 },
+ { "GL_ARB_vertex_attrib_64bit", o(ARB_vertex_attrib_64bit), GLC, 2010 },
{ "GL_ARB_vertex_type_10f_11f_11f_rev", o(ARB_vertex_type_10f_11f_11f_rev), GL, 2013 },
{ "GL_ARB_vertex_type_2_10_10_10_rev", o(ARB_vertex_type_2_10_10_10_rev), GL, 2009 },
{ "GL_ARB_viewport_array", o(ARB_viewport_array), GLC, 2010 },
diff --git a/mesalib/src/mesa/main/fbobject.c b/mesalib/src/mesa/main/fbobject.c
index 27cf97f17..8db651ca2 100644
--- a/mesalib/src/mesa/main/fbobject.c
+++ b/mesalib/src/mesa/main/fbobject.c
@@ -121,6 +121,27 @@ _mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id)
/**
+ * A convenience function for direct state access that throws
+ * GL_INVALID_OPERATION if the renderbuffer doesn't exist.
+ */
+struct gl_renderbuffer *
+_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func)
+{
+ struct gl_renderbuffer *rb;
+
+ rb = _mesa_lookup_renderbuffer(ctx, id);
+ if (!rb || rb == &DummyRenderbuffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(non-existent renderbuffer %u)", func, id);
+ return NULL;
+ }
+
+ return rb;
+}
+
+
+/**
* Helper routine for getting a gl_framebuffer.
*/
struct gl_framebuffer *
@@ -138,6 +159,27 @@ _mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id)
/**
+ * A convenience function for direct state access that throws
+ * GL_INVALID_OPERATION if the framebuffer doesn't exist.
+ */
+struct gl_framebuffer *
+_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func)
+{
+ struct gl_framebuffer *fb;
+
+ fb = _mesa_lookup_framebuffer(ctx, id);
+ if (!fb || fb == &DummyFramebuffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(non-existent framebuffer %u)", func, id);
+ return NULL;
+ }
+
+ return fb;
+}
+
+
+/**
* Mark the given framebuffer as invalid. This will force the
* test for framebuffer completeness to be done before the framebuffer
* is used.
@@ -423,7 +465,7 @@ set_texture_attachment(struct gl_context *ctx,
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att,
struct gl_texture_object *texObj,
- GLenum texTarget, GLuint level, GLuint zoffset,
+ GLenum texTarget, GLuint level, GLuint layer,
GLboolean layered)
{
struct gl_renderbuffer *rb = att->Renderbuffer;
@@ -447,7 +489,7 @@ set_texture_attachment(struct gl_context *ctx,
/* always update these fields */
att->TextureLevel = level;
att->CubeMapFace = _mesa_tex_target_to_face(texTarget);
- att->Zoffset = zoffset;
+ att->Zoffset = layer;
att->Layered = layered;
att->Complete = GL_FALSE;
@@ -479,9 +521,10 @@ set_renderbuffer_attachment(struct gl_context *ctx,
* Attach a renderbuffer object to a framebuffer object.
*/
void
-_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
- struct gl_framebuffer *fb,
- GLenum attachment, struct gl_renderbuffer *rb)
+_mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb)
{
struct gl_renderbuffer_attachment *att;
@@ -1446,6 +1489,14 @@ void GLAPIENTRY
_mesa_CreateRenderbuffers(GLsizei n, GLuint *renderbuffers)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateRenderbuffers(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
create_render_buffers(ctx, n, renderbuffers, true);
}
@@ -1886,6 +1937,12 @@ renderbuffer_storage_named(GLuint renderbuffer, GLenum internalFormat,
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
+
if (MESA_VERBOSE & VERBOSE_API) {
if (samples == NO_SAMPLES)
_mesa_debug(ctx, "%s(%u, %s, %d, %d)\n",
@@ -2140,6 +2197,13 @@ _mesa_GetNamedRenderbufferParameteriv(GLuint renderbuffer, GLenum pname,
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedRenderbufferParameteriv("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
struct gl_renderbuffer *rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
if (!rb || rb == &DummyRenderbuffer) {
/* ID was reserved, but no real renderbuffer object made yet */
@@ -2396,15 +2460,29 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers)
}
-void GLAPIENTRY
-_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
+/**
+ * This is the implementation for glGenFramebuffers and glCreateFramebuffers.
+ * It is not exposed to the rest of Mesa to encourage the use of
+ * nameless buffers in driver internals.
+ */
+static void
+create_framebuffers(GLsizei n, GLuint *framebuffers, bool dsa)
{
GET_CURRENT_CONTEXT(ctx);
GLuint first;
GLint i;
+ struct gl_framebuffer *fb;
+
+ const char *func = dsa ? "glCreateFramebuffers" : "glGenFramebuffers";
+
+ if (dsa && !ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
+ return;
+ }
if (n < 0) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(n < 0)", func);
return;
}
@@ -2416,31 +2494,43 @@ _mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
for (i = 0; i < n; i++) {
GLuint name = first + i;
framebuffers[i] = name;
- /* insert dummy placeholder into hash table */
+
+ if (dsa) {
+ fb = ctx->Driver.NewFramebuffer(ctx, framebuffers[i]);
+ if (!fb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s", func);
+ return;
+ }
+ }
+ else
+ fb = &DummyFramebuffer;
+
mtx_lock(&ctx->Shared->Mutex);
- _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer);
+ _mesa_HashInsert(ctx->Shared->FrameBuffers, name, fb);
mtx_unlock(&ctx->Shared->Mutex);
}
}
-GLenum GLAPIENTRY
-_mesa_CheckFramebufferStatus(GLenum target)
+void GLAPIENTRY
+_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers)
{
- struct gl_framebuffer *buffer;
- GET_CURRENT_CONTEXT(ctx);
+ create_framebuffers(n, framebuffers, false);
+}
- ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
- if (MESA_VERBOSE & VERBOSE_API)
- _mesa_debug(ctx, "glCheckFramebufferStatus(%s)\n",
- _mesa_lookup_enum_by_nr(target));
+void GLAPIENTRY
+_mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers)
+{
+ create_framebuffers(n, framebuffers, true);
+}
- buffer = get_framebuffer_target(ctx, target);
- if (!buffer) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)");
- return 0;
- }
+
+GLenum
+_mesa_check_framebuffer_status(struct gl_context *ctx,
+ struct gl_framebuffer *buffer)
+{
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
if (_mesa_is_winsys_fbo(buffer)) {
/* EGL_KHR_surfaceless_context allows the winsys FBO to be incomplete. */
@@ -2461,6 +2551,74 @@ _mesa_CheckFramebufferStatus(GLenum target)
}
+GLenum GLAPIENTRY
+_mesa_CheckFramebufferStatus(GLenum target)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCheckFramebufferStatus(%s)\n",
+ _mesa_lookup_enum_by_nr(target));
+
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCheckFramebufferStatus(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return 0;
+ }
+
+ return _mesa_check_framebuffer_status(ctx, fb);
+}
+
+
+GLenum GLAPIENTRY
+_mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCheckNamedFramebufferStatus(GL_ARB_direct_state_access "
+ "is not supported)");
+ return 0;
+ }
+
+ /* Validate the target (for conformance's sake) and grab a reference to the
+ * default framebuffer in case framebuffer = 0.
+ * Section 9.4 Framebuffer Completeness of the OpenGL 4.5 core spec
+ * (30.10.2014, PDF page 336) says:
+ * "If framebuffer is zero, then the status of the default read or
+ * draw framebuffer (as determined by target) is returned."
+ */
+ switch (target) {
+ case GL_DRAW_FRAMEBUFFER:
+ case GL_FRAMEBUFFER:
+ fb = ctx->WinSysDrawBuffer;
+ break;
+ case GL_READ_FRAMEBUFFER:
+ fb = ctx->WinSysReadBuffer;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCheckNamedFramebufferStatus(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return 0;
+ }
+
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glCheckNamedFramebufferStatus");
+ if (!fb)
+ return 0;
+ }
+
+ return _mesa_check_framebuffer_status(ctx, fb);
+}
+
+
/**
* Replicate the src attachment point. Used by framebuffer_texture() when
* the same texture is attached at GL_DEPTH_ATTACHMENT and
@@ -2487,144 +2645,301 @@ reuse_framebuffer_texture_attachment(struct gl_framebuffer *fb,
/**
- * Common code called by glFramebufferTexture1D/2D/3D() and
- * glFramebufferTextureLayer().
+ * Common code called by gl*FramebufferTexture*() to retrieve the correct
+ * texture object pointer.
*
- * \param textarget is the textarget that was passed to the
- * glFramebufferTexture...() function, or 0 if the corresponding function
- * doesn't have a textarget parameter.
+ * \param texObj where the pointer to the texture object is returned. Note
+ * that a successful call may return texObj = NULL.
*
- * \param layered is true if this function was called from
- * glFramebufferTexture(), false otherwise.
+ * \return true if no errors, false if errors
*/
-static void
-framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
- GLenum attachment, GLenum textarget, GLuint texture,
- GLint level, GLuint zoffset, GLboolean layered)
+static bool
+get_texture_for_framebuffer(struct gl_context *ctx, GLuint texture,
+ bool layered, const char *caller,
+ struct gl_texture_object **texObj)
{
- struct gl_renderbuffer_attachment *att;
- struct gl_texture_object *texObj = NULL;
- struct gl_framebuffer *fb;
- GLenum maxLevelsTarget;
+ *texObj = NULL; /* This will get returned if texture = 0. */
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferTexture%s(target=0x%x)", caller, target);
- return;
+ if (!texture)
+ return true;
+
+ *texObj = _mesa_lookup_texture(ctx, texture);
+ if (*texObj == NULL || (*texObj)->Target == 0) {
+ /* Can't render to a non-existent texture object.
+ *
+ * The OpenGL 4.5 core spec (02.02.2015) in Section 9.2 Binding and
+ * Managing Framebuffer Objects specifies a different error
+ * depending upon the calling function (PDF pages 325-328).
+ * *FramebufferTexture (where layered = GL_TRUE) throws invalid
+ * value, while the other commands throw invalid operation (where
+ * layered = GL_FALSE).
+ */
+ const GLenum error = layered ? GL_INVALID_VALUE :
+ GL_INVALID_OPERATION;
+ _mesa_error(ctx, error,
+ "%s(non-existent texture %u)", caller, texture);
+ return false;
}
- /* check framebuffer binding */
- if (_mesa_is_winsys_fbo(fb)) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture%s", caller);
- return;
+ return true;
+}
+
+
+/**
+ * Common code called by gl*FramebufferTexture() to verify the texture target
+ * and decide whether or not the attachment should truly be considered
+ * layered.
+ *
+ * \param layered true if attachment should be considered layered, false if
+ * not
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_layered_texture_target(struct gl_context *ctx, GLenum target,
+ const char *caller, GLboolean *layered)
+{
+ *layered = GL_TRUE;
+
+ switch (target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_1D_ARRAY_EXT:
+ case GL_TEXTURE_2D_ARRAY_EXT:
+ case GL_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return true;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_RECTANGLE:
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ /* These texture types are valid to pass to
+ * glFramebufferTexture(), but since they aren't layered, it
+ * is equivalent to calling glFramebufferTexture{1D,2D}().
+ */
+ *layered = GL_FALSE;
+ return true;
}
- /* The textarget, level, and zoffset parameters are only validated if
- * texture is non-zero.
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid texture target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
+ return false;
+}
+
+
+/**
+ * Common code called by gl*FramebufferTextureLayer() to verify the texture
+ * target.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_texture_target(struct gl_context *ctx, GLenum target,
+ const char *caller)
+{
+ /* We're being called by glFramebufferTextureLayer().
+ * The only legal texture types for that function are 3D,
+ * cube-map, and 1D/2D/cube-map array textures.
*/
- if (texture) {
- GLboolean err = GL_TRUE;
-
- texObj = _mesa_lookup_texture(ctx, texture);
- if (texObj != NULL) {
- if (textarget == 0) {
- if (layered) {
- /* We're being called by glFramebufferTexture() and textarget
- * is not used.
- */
- switch (texObj->Target) {
- case GL_TEXTURE_3D:
- case GL_TEXTURE_1D_ARRAY_EXT:
- case GL_TEXTURE_2D_ARRAY_EXT:
- case GL_TEXTURE_CUBE_MAP:
- case GL_TEXTURE_CUBE_MAP_ARRAY:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- err = false;
- break;
- case GL_TEXTURE_1D:
- case GL_TEXTURE_2D:
- case GL_TEXTURE_RECTANGLE:
- case GL_TEXTURE_2D_MULTISAMPLE:
- /* These texture types are valid to pass to
- * glFramebufferTexture(), but since they aren't layered, it
- * is equivalent to calling glFramebufferTexture{1D,2D}().
- */
- err = false;
- layered = false;
- textarget = texObj->Target;
- break;
- default:
- err = true;
- break;
- }
- } else {
- /* We're being called by glFramebufferTextureLayer() and
- * textarget is not used. The only legal texture types for
- * that function are 3D and 1D/2D arrays textures.
- */
- err = (texObj->Target != GL_TEXTURE_3D) &&
- (texObj->Target != GL_TEXTURE_1D_ARRAY_EXT) &&
- (texObj->Target != GL_TEXTURE_2D_ARRAY_EXT) &&
- (texObj->Target != GL_TEXTURE_CUBE_MAP_ARRAY) &&
- (texObj->Target != GL_TEXTURE_2D_MULTISAMPLE_ARRAY);
- }
- }
- else {
- /* Make sure textarget is consistent with the texture's type */
- err = (texObj->Target == GL_TEXTURE_CUBE_MAP)
- ? !_mesa_is_cube_face(textarget)
- : (texObj->Target != textarget);
- }
+ switch (target) {
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_1D_ARRAY:
+ case GL_TEXTURE_2D_ARRAY:
+ case GL_TEXTURE_CUBE_MAP_ARRAY:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ return true;
+ case GL_TEXTURE_CUBE_MAP:
+ /* This target is valid in TextureLayer when ARB_direct_state_access
+ * or OpenGL 4.5 is supported.
+ */
+ return ctx->Extensions.ARB_direct_state_access;
+ }
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid texture target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
+ return false;
+}
+
+
+/**
+ * Common code called by glFramebufferTexture*D() to verify the texture
+ * target.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_textarget(struct gl_context *ctx, int dims, GLenum target,
+ GLenum textarget, const char *caller)
+{
+ bool err = false;
+
+ switch (dims) {
+ case 1:
+ switch (textarget) {
+ case GL_TEXTURE_1D:
+ break;
+ case GL_TEXTURE_1D_ARRAY:
+ err = !ctx->Extensions.EXT_texture_array;
+ break;
+ default:
+ err = true;
}
- else {
- /* can't render to a non-existant texture */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture%s(non existant texture)",
- caller);
- return;
+ break;
+ case 2:
+ switch (textarget) {
+ case GL_TEXTURE_2D:
+ break;
+ case GL_TEXTURE_RECTANGLE:
+ err = _mesa_is_gles(ctx)
+ || !ctx->Extensions.NV_texture_rectangle;
+ break;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ err = !ctx->Extensions.ARB_texture_cube_map;
+ break;
+ case GL_TEXTURE_2D_ARRAY:
+ err = (_mesa_is_gles(ctx) && ctx->Version < 30)
+ || !ctx->Extensions.EXT_texture_array;
+ break;
+ case GL_TEXTURE_2D_MULTISAMPLE:
+ case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ err = _mesa_is_gles(ctx)
+ || !ctx->Extensions.ARB_texture_multisample;
+ break;
+ default:
+ err = true;
}
+ break;
+ case 3:
+ if (textarget != GL_TEXTURE_3D)
+ err = true;
+ break;
+ default:
+ err = true;
+ }
- if (err) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture%s(texture target mismatch)",
- caller);
- return;
- }
+ if (err) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(invalid textarget %s)",
+ caller, _mesa_lookup_enum_by_nr(textarget));
+ return false;
+ }
- if (texObj->Target == GL_TEXTURE_3D) {
- const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
- if (zoffset >= maxSize) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glFramebufferTexture%s(zoffset)", caller);
- return;
- }
+ /* Make sure textarget is consistent with the texture's type */
+ err = (target == GL_TEXTURE_CUBE_MAP) ?
+ !_mesa_is_cube_face(textarget): (target != textarget);
+
+ if (err) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(mismatched texture target)", caller);
+ return false;
+ }
+
+ return true;
+}
+
+
+/**
+ * Common code called by gl*FramebufferTextureLayer() and
+ * glFramebufferTexture3D() to validate the layer.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_layer(struct gl_context *ctx, GLenum target, GLint layer,
+ const char *caller)
+{
+ /* Page 306 (page 328 of the PDF) of the OpenGL 4.5 (Core Profile)
+ * spec says:
+ *
+ * "An INVALID_VALUE error is generated if texture is non-zero
+ * and layer is negative."
+ */
+ if (layer < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(layer %u < 0)", caller, layer);
+ return false;
+ }
+
+ if (target == GL_TEXTURE_3D) {
+ const GLuint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
+ if (layer >= maxSize) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(invalid layer %u)", caller, layer);
+ return false;
}
- else if ((texObj->Target == GL_TEXTURE_1D_ARRAY_EXT) ||
- (texObj->Target == GL_TEXTURE_2D_ARRAY_EXT) ||
- (texObj->Target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
- (texObj->Target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
- if (zoffset >= ctx->Const.MaxArrayTextureLayers) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glFramebufferTexture%s(layer)", caller);
- return;
- }
+ }
+ else if ((target == GL_TEXTURE_1D_ARRAY) ||
+ (target == GL_TEXTURE_2D_ARRAY) ||
+ (target == GL_TEXTURE_CUBE_MAP_ARRAY) ||
+ (target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)) {
+ if (layer >= ctx->Const.MaxArrayTextureLayers) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(layer %u >= GL_MAX_ARRAY_TEXTURE_LAYERS)",
+ caller, layer);
+ return false;
}
-
- maxLevelsTarget = textarget ? textarget : texObj->Target;
- if ((level < 0) ||
- (level >= _mesa_max_texture_levels(ctx, maxLevelsTarget))) {
+ }
+ else if (target == GL_TEXTURE_CUBE_MAP) {
+ if (layer >= 6) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glFramebufferTexture%s(level)", caller);
- return;
+ "%s(layer %u >= 6)", caller, layer);
+ return false;
}
}
+ return true;
+}
+
+
+/**
+ * Common code called by all gl*FramebufferTexture*() entry points to verify
+ * the level.
+ *
+ * \return true if no errors, false if errors
+ */
+static bool
+check_level(struct gl_context *ctx, GLenum target, GLint level,
+ const char *caller)
+{
+ if ((level < 0) ||
+ (level >= _mesa_max_texture_levels(ctx, target))) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(invalid level %d)", caller, level);
+ return false;
+ }
+
+ return true;
+}
+
+
+void
+_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_texture_object *texObj, GLenum textarget,
+ GLint level, GLuint layer, GLboolean layered,
+ const char *caller)
+{
+ struct gl_renderbuffer_attachment *att;
+
+ /* The window-system framebuffer object is immutable */
+ if (_mesa_is_winsys_fbo(fb)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s(window-system framebuffer)",
+ caller);
+ return;
+ }
+
+ /* Not a hash lookup, so we can afford to get the attachment here. */
att = get_attachment(ctx, fb, attachment);
if (att == NULL) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferTexture%s(attachment)", caller);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
+ _mesa_lookup_enum_by_nr(attachment));
return;
}
@@ -2637,7 +2952,7 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
level == fb->Attachment[BUFFER_STENCIL].TextureLevel &&
_mesa_tex_target_to_face(textarget) ==
fb->Attachment[BUFFER_STENCIL].CubeMapFace &&
- zoffset == fb->Attachment[BUFFER_STENCIL].Zoffset) {
+ layer == fb->Attachment[BUFFER_STENCIL].Zoffset) {
/* The texture object is already attached to the stencil attachment
* point. Don't create a new renderbuffer; just reuse the stencil
* attachment's. This is required to prevent a GL error in
@@ -2650,13 +2965,14 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
level == fb->Attachment[BUFFER_DEPTH].TextureLevel &&
_mesa_tex_target_to_face(textarget) ==
fb->Attachment[BUFFER_DEPTH].CubeMapFace &&
- zoffset == fb->Attachment[BUFFER_DEPTH].Zoffset) {
+ layer == fb->Attachment[BUFFER_DEPTH].Zoffset) {
/* As above, but with depth and stencil transposed. */
reuse_framebuffer_texture_attachment(fb, BUFFER_STENCIL,
BUFFER_DEPTH);
} else {
set_texture_attachment(ctx, fb, att, texObj, textarget,
- level, zoffset, layered);
+ level, layer, layered);
+
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
/* Above we created a new renderbuffer and attached it to the
* depth attachment point. Now attach it to the stencil attachment
@@ -2692,36 +3008,50 @@ framebuffer_texture(struct gl_context *ctx, const char *caller, GLenum target,
}
-void GLAPIENTRY
-_mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture, GLint level)
+static void
+framebuffer_texture_with_dims(int dims, GLenum target,
+ GLenum attachment, GLenum textarget,
+ GLuint texture, GLint level, GLint layer,
+ const char *caller)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
- if (texture != 0) {
- GLboolean error;
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid target %s)", caller,
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
- switch (textarget) {
- case GL_TEXTURE_1D:
- error = GL_FALSE;
- break;
- case GL_TEXTURE_1D_ARRAY:
- error = !ctx->Extensions.EXT_texture_array;
- break;
- default:
- error = GL_TRUE;
- }
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, false, caller, &texObj))
+ return;
- if (error) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture1D(textarget=%s)",
- _mesa_lookup_enum_by_nr(textarget));
+ if (texObj) {
+ if (!check_textarget(ctx, dims, texObj->Target, textarget, caller))
+ return;
+
+ if ((dims == 3) && !check_layer(ctx, texObj->Target, layer, caller))
return;
- }
}
- framebuffer_texture(ctx, "1D", target, attachment, textarget, texture,
- level, 0, GL_FALSE);
+ if (!check_level(ctx, textarget, level, caller))
+ return;
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
+ layer, GL_FALSE, caller);
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture, GLint level)
+{
+ framebuffer_texture_with_dims(1, target, attachment, textarget, texture,
+ level, 0, "glFramebufferTexture1D");
}
@@ -2729,79 +3059,112 @@ void GLAPIENTRY
_mesa_FramebufferTexture2D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level)
{
+ framebuffer_texture_with_dims(2, target, attachment, textarget, texture,
+ level, 0, "glFramebufferTexture2D");
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferTexture3D(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture,
+ GLint level, GLint layer)
+{
+ framebuffer_texture_with_dims(3, target, attachment, textarget, texture,
+ level, layer, "glFramebufferTexture3D");
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
+ GLuint texture, GLint level, GLint layer)
+{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLenum textarget = 0;
- if (texture != 0) {
- GLboolean error;
+ const char *func = "glFramebufferTextureLayer";
- switch (textarget) {
- case GL_TEXTURE_2D:
- error = GL_FALSE;
- break;
- case GL_TEXTURE_RECTANGLE:
- error = _mesa_is_gles(ctx)
- || !ctx->Extensions.NV_texture_rectangle;
- break;
- case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
- case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
- case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
- error = !ctx->Extensions.ARB_texture_cube_map;
- break;
- case GL_TEXTURE_2D_ARRAY:
- error = (_mesa_is_gles(ctx) && ctx->Version < 30)
- || !ctx->Extensions.EXT_texture_array;
- break;
- case GL_TEXTURE_2D_MULTISAMPLE:
- case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- error = _mesa_is_gles(ctx)
- || !ctx->Extensions.ARB_texture_multisample;
- break;
- default:
- error = GL_TRUE;
- }
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTextureLayer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
- if (error) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture2D(textarget=%s)",
- _mesa_lookup_enum_by_nr(textarget));
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, false, func, &texObj))
+ return;
+
+ if (texObj) {
+ if (!check_texture_target(ctx, texObj->Target, func))
+ return;
+
+ if (!check_layer(ctx, texObj->Target, layer, func))
return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
+
+ if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
+ assert(layer >= 0 && layer < 6);
+ textarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
+ layer = 0;
}
}
- framebuffer_texture(ctx, "2D", target, attachment, textarget, texture,
- level, 0, GL_FALSE);
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
+ layer, GL_FALSE, func);
}
void GLAPIENTRY
-_mesa_FramebufferTexture3D(GLenum target, GLenum attachment,
- GLenum textarget, GLuint texture,
- GLint level, GLint zoffset)
+_mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level, GLint layer)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLenum textarget = 0;
+
+ const char *func = "glNamedFramebufferTextureLayer";
- if ((texture != 0) && (textarget != GL_TEXTURE_3D)) {
+ if (!ctx->Extensions.ARB_direct_state_access) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferTexture3D(textarget)");
+ "%s(GL_ARB_direct_state_access is not supported)", func);
return;
}
- framebuffer_texture(ctx, "3D", target, attachment, textarget, texture,
- level, zoffset, GL_FALSE);
-}
+ /* Get the framebuffer object */
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
+ if (!fb)
+ return;
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, false, func, &texObj))
+ return;
-void GLAPIENTRY
-_mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
- GLuint texture, GLint level, GLint layer)
-{
- GET_CURRENT_CONTEXT(ctx);
+ if (texObj) {
+ if (!check_texture_target(ctx, texObj->Target, func))
+ return;
+
+ if (!check_layer(ctx, texObj->Target, layer, func))
+ return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
- framebuffer_texture(ctx, "Layer", target, attachment, 0, texture,
- level, layer, GL_FALSE);
+ if (texObj->Target == GL_TEXTURE_CUBE_MAP) {
+ assert(layer >= 0 && layer < 6);
+ textarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + layer;
+ layer = 0;
+ }
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, textarget, level,
+ layer, GL_FALSE, func);
}
@@ -2810,82 +3173,121 @@ _mesa_FramebufferTexture(GLenum target, GLenum attachment,
GLuint texture, GLint level)
{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered;
+
+ const char *func = "FramebufferTexture";
- if (_mesa_has_geometry_shaders(ctx)) {
- framebuffer_texture(ctx, "", target, attachment, 0, texture,
- level, 0, GL_TRUE);
- } else {
+ if (!_mesa_has_geometry_shaders(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"unsupported function (glFramebufferTexture) called");
+ return;
+ }
+
+ /* Get the framebuffer object */
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
}
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, true, func, &texObj))
+ return;
+
+ if (texObj) {
+ if (!check_layered_texture_target(ctx, texObj->Target, func, &layered))
+ return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ 0, layered, func);
}
void GLAPIENTRY
-_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
- GLenum renderbufferTarget,
- GLuint renderbuffer)
+_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level)
{
- struct gl_renderbuffer_attachment *att;
- struct gl_framebuffer *fb;
- struct gl_renderbuffer *rb;
GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *fb;
+ struct gl_texture_object *texObj;
+ GLboolean layered;
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbuffer(target)");
+ const char *func = "glNamedFramebufferTexture";
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", func);
return;
}
- if (renderbufferTarget != GL_RENDERBUFFER_EXT) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbuffer(renderbufferTarget)");
+ if (!_mesa_has_geometry_shaders(ctx)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "unsupported function (glNamedFramebufferTexture) called");
return;
}
+ /* Get the framebuffer object */
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer, func);
+ if (!fb)
+ return;
+
+ /* Get the texture object */
+ if (!get_texture_for_framebuffer(ctx, texture, true, func, &texObj))
+ return;
+
+ if (texObj) {
+ if (!check_layered_texture_target(ctx, texObj->Target, func,
+ &layered))
+ return;
+
+ if (!check_level(ctx, texObj->Target, level, func))
+ return;
+ }
+
+ _mesa_framebuffer_texture(ctx, fb, attachment, texObj, 0, level,
+ 0, layered, func);
+}
+
+
+void
+_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb,
+ const char *func)
+{
+ struct gl_renderbuffer_attachment *att;
+
if (_mesa_is_winsys_fbo(fb)) {
/* Can't attach new renderbuffers to a window system framebuffer */
- _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbuffer");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(window-system framebuffer)", func);
return;
}
att = get_attachment(ctx, fb, attachment);
if (att == NULL) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glFramebufferRenderbuffer(invalid attachment %s)",
+ "%s(invalid attachment %s)", func,
_mesa_lookup_enum_by_nr(attachment));
return;
}
- if (renderbuffer) {
- rb = _mesa_lookup_renderbuffer(ctx, renderbuffer);
- if (!rb) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferRenderbuffer(non-existant"
- " renderbuffer %u)", renderbuffer);
- return;
- }
- else if (rb == &DummyRenderbuffer) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferRenderbuffer(renderbuffer %u)",
- renderbuffer);
- return;
- }
- }
- else {
- /* remove renderbuffer attachment */
- rb = NULL;
- }
-
if (attachment == GL_DEPTH_STENCIL_ATTACHMENT &&
rb && rb->Format != MESA_FORMAT_NONE) {
/* make sure the renderbuffer is a depth/stencil format */
const GLenum baseFormat = _mesa_get_format_base_format(rb->Format);
if (baseFormat != GL_DEPTH_STENCIL) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glFramebufferRenderbuffer(renderbuffer"
- " is not DEPTH_STENCIL format)");
+ "%s(renderbuffer is not DEPTH_STENCIL format)", func);
return;
}
}
@@ -2903,24 +3305,99 @@ _mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
void GLAPIENTRY
-_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
- GLenum pname, GLint *params)
+_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer)
{
- const struct gl_renderbuffer_attachment *att;
- struct gl_framebuffer *buffer;
- GLenum err;
+ struct gl_framebuffer *fb;
+ struct gl_renderbuffer *rb;
GET_CURRENT_CONTEXT(ctx);
- /* The error differs in GL and GLES. */
- err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbuffer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
- buffer = get_framebuffer_target(ctx, target);
- if (!buffer) {
+ if (renderbuffertarget != GL_RENDERBUFFER) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(target)");
+ "glFramebufferRenderbuffer(renderbuffertarget is not "
+ "GL_RENDERBUFFER)");
return;
}
+ if (renderbuffer) {
+ rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer,
+ "glFramebufferRenderbuffer");
+ if (!rb)
+ return;
+ }
+ else {
+ /* remove renderbuffer attachment */
+ rb = NULL;
+ }
+
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
+ "glFramebufferRenderbuffer");
+}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer)
+{
+ struct gl_framebuffer *fb;
+ struct gl_renderbuffer *rb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferRenderbuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glNamedFramebufferRenderbuffer");
+
+ if (renderbuffertarget != GL_RENDERBUFFER) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glNamedFramebufferRenderbuffer(renderbuffertarget is not "
+ "GL_RENDERBUFFER)");
+ return;
+ }
+
+ if (renderbuffer) {
+ rb = _mesa_lookup_renderbuffer_err(ctx, renderbuffer,
+ "glNamedFramebufferRenderbuffer");
+ if (!rb)
+ return;
+ }
+ else {
+ /* remove renderbuffer attachment */
+ rb = NULL;
+ }
+
+ _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb,
+ "glNamedFramebufferRenderbuffer");
+}
+
+
+void
+_mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
+ struct gl_framebuffer *buffer,
+ GLenum attachment, GLenum pname,
+ GLint *params, const char *caller)
+{
+ const struct gl_renderbuffer_attachment *att;
+ GLenum err;
+
+ /* The error differs in GL and GLES. */
+ err = _mesa_is_desktop_gl(ctx) ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+
if (_mesa_is_winsys_fbo(buffer)) {
/* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec
* says:
@@ -2936,14 +3413,15 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
!ctx->Extensions.ARB_framebuffer_object)
&& !_mesa_is_gles3(ctx)) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv(bound FBO = 0)");
+ "%s(window-system framebuffer)", caller);
return;
}
if (_mesa_is_gles3(ctx) && attachment != GL_BACK &&
attachment != GL_DEPTH && attachment != GL_STENCIL) {
_mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(attachment)");
+ "%s(invalid attachment %s)", caller,
+ _mesa_lookup_enum_by_nr(attachment));
return;
}
/* the default / window-system FBO */
@@ -2955,8 +3433,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
}
if (att == NULL) {
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(attachment)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", caller,
+ _mesa_lookup_enum_by_nr(attachment));
return;
}
@@ -2970,9 +3448,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
* attachment, since it does not have a single format."
*/
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv("
- "GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
- " is invalid for depth+stencil attachment)");
+ "%s(GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE"
+ " is invalid for depth+stencil attachment)", caller);
return;
}
/* the depth and stencil attachments must point to the same buffer */
@@ -2980,8 +3457,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
stencilAtt = get_attachment(ctx, buffer, GL_STENCIL_ATTACHMENT);
if (depthAtt->Renderbuffer != stencilAtt->Renderbuffer) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv(DEPTH/STENCIL"
- " attachments differ)");
+ "%s(DEPTH/STENCIL attachments differ)", caller);
return;
}
}
@@ -3014,8 +3490,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
*params = att->TextureLevel;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
goto invalid_pname_enum;
@@ -3031,8 +3507,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
}
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
goto invalid_pname_enum;
@@ -3042,8 +3518,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
if (ctx->API == API_OPENGLES) {
goto invalid_pname_enum;
} else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
} else if (att->Type == GL_TEXTURE) {
if (att->Texture && (att->Texture->Target == GL_TEXTURE_3D ||
att->Texture->Target == GL_TEXTURE_2D_ARRAY)) {
@@ -3064,8 +3540,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
goto invalid_pname_enum;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
if (ctx->Extensions.EXT_framebuffer_sRGB) {
@@ -3087,8 +3563,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
goto invalid_pname_enum;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else {
mesa_format format = att->Renderbuffer->Format;
@@ -3103,9 +3579,9 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
if (_mesa_is_gles3(ctx) &&
attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glGetFramebufferAttachmentParameteriv(cannot query "
+ "%s(cannot query "
"GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE of "
- "GL_DEPTH_STENCIL_ATTACHMENT");
+ "GL_DEPTH_STENCIL_ATTACHMENT)", caller);
return;
}
@@ -3139,8 +3615,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
goto invalid_pname_enum;
}
else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
}
else if (att->Texture) {
const struct gl_texture_image *texImage =
@@ -3159,8 +3635,7 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
att->Renderbuffer->Format);
}
else {
- _mesa_problem(ctx, "glGetFramebufferAttachmentParameterivEXT:"
- " invalid FBO attachment structure");
+ _mesa_problem(ctx, "%s: invalid FBO attachment structure", caller);
}
return;
case GL_FRAMEBUFFER_ATTACHMENT_LAYERED:
@@ -3169,8 +3644,8 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
} else if (att->Type == GL_TEXTURE) {
*params = att->Layered;
} else if (att->Type == GL_NONE) {
- _mesa_error(ctx, err,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, err, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
} else {
goto invalid_pname_enum;
}
@@ -3182,30 +3657,145 @@ _mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
return;
invalid_pname_enum:
- _mesa_error(ctx, GL_INVALID_ENUM,
- "glGetFramebufferAttachmentParameteriv(pname)");
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid pname %s)", caller,
+ _mesa_lookup_enum_by_nr(pname));
return;
}
+void GLAPIENTRY
+_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
+ GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *buffer;
+
+ buffer = get_framebuffer_target(ctx, target);
+ if (!buffer) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameteriv(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ _mesa_get_framebuffer_attachment_parameter(ctx, buffer, attachment, pname,
+ params,
+ "glGetFramebufferAttachmentParameteriv");
+}
+
+
+void GLAPIENTRY
+_mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
+ GLenum attachment,
+ GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_framebuffer *buffer;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedFramebufferAttachmentParameteriv("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
+ if (framebuffer) {
+ buffer = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glGetNamedFramebufferAttachmentParameteriv");
+ if (!buffer)
+ return;
+ }
+ else {
+ /*
+ * Section 9.2 Binding and Managing Framebuffer Objects of the OpenGL
+ * 4.5 core spec (30.10.2014, PDF page 314):
+ * "If framebuffer is zero, then the default draw framebuffer is
+ * queried."
+ */
+ buffer = ctx->WinSysDrawBuffer;
+ }
+
+ _mesa_get_framebuffer_attachment_parameter(ctx, buffer, attachment, pname,
+ params,
+ "glGetNamedFramebufferAttachmentParameteriv");
+}
+
+
+void GLAPIENTRY
+_mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
+ GLint param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ (void) framebuffer;
+ (void) pname;
+ (void) param;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferParameteri("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferParameteri not supported "
+ "(ARB_framebuffer_no_attachments not implemented)");
+}
+
+
+void GLAPIENTRY
+_mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
+ GLint *param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ (void) framebuffer;
+ (void) pname;
+ (void) param;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glNamedFramebufferParameteriv("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetNamedFramebufferParameteriv not supported "
+ "(ARB_framebuffer_no_attachments not implemented)");
+}
+
+
static void
-invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
+invalidate_framebuffer_storage(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height, const char *name)
{
int i;
- struct gl_framebuffer *fb;
- GET_CURRENT_CONTEXT(ctx);
- fb = get_framebuffer_target(ctx, target);
- if (!fb) {
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(target)", name);
+ /* Section 17.4 Whole Framebuffer Operations of the OpenGL 4.5 Core
+ * Spec (2.2.2015, PDF page 522) says:
+ * "An INVALID_VALUE error is generated if numAttachments, width, or
+ * height is negative."
+ */
+ if (numAttachments < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(numAttachments < 0)", name);
return;
}
- if (numAttachments < 0) {
+ if (width < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "%s(numAttachments < 0)", name);
+ "%s(width < 0)", name);
+ return;
+ }
+
+ if (height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(height < 0)", name);
return;
}
@@ -3301,7 +3891,8 @@ invalidate_framebuffer_storage(GLenum target, GLsizei numAttachments,
return;
invalid_enum:
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(attachment)", name);
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(invalid attachment %s)", name,
+ _mesa_lookup_enum_by_nr(attachments[i]));
return;
}
@@ -3311,16 +3902,74 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments, GLint x, GLint y,
GLsizei width, GLsizei height)
{
- invalidate_framebuffer_storage(target, numAttachments, attachments,
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glInvalidateSubFramebuffer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
x, y, width, height,
"glInvalidateSubFramebuffer");
}
void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferSubData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glInvalidateNamedFramebufferSubData("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
+ /* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
+ * Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
+ * default draw framebuffer is affected."
+ */
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glInvalidateNamedFramebufferSubData");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
+ x, y, width, height,
+ "glInvalidateNamedFramebufferSubData");
+}
+
+
+void GLAPIENTRY
_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments)
{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ fb = get_framebuffer_target(ctx, target);
+ if (!fb) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glInvalidateFramebuffer(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
/* The GL_ARB_invalidate_subdata spec says:
*
* "The command
@@ -3333,7 +3982,7 @@ _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
* <width>, <height> equal to 0, 0, <MAX_VIEWPORT_DIMS[0]>,
* <MAX_VIEWPORT_DIMS[1]> respectively."
*/
- invalidate_framebuffer_storage(target, numAttachments, attachments,
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
0, 0,
MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT,
"glInvalidateFramebuffer");
@@ -3341,6 +3990,53 @@ _mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments)
+{
+ struct gl_framebuffer *fb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glInvalidateNamedFramebufferData("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
+ /* The OpenGL 4.5 core spec (02.02.2015) says (in Section 17.4 Whole
+ * Framebuffer Operations, PDF page 522): "If framebuffer is zero, the
+ * default draw framebuffer is affected."
+ */
+ if (framebuffer) {
+ fb = _mesa_lookup_framebuffer_err(ctx, framebuffer,
+ "glInvalidateNamedFramebufferData");
+ if (!fb)
+ return;
+ }
+ else
+ fb = ctx->WinSysDrawBuffer;
+
+ /* The GL_ARB_invalidate_subdata spec says:
+ *
+ * "The command
+ *
+ * void InvalidateFramebuffer(enum target,
+ * sizei numAttachments,
+ * const enum *attachments);
+ *
+ * is equivalent to the command InvalidateSubFramebuffer with <x>, <y>,
+ * <width>, <height> equal to 0, 0, <MAX_VIEWPORT_DIMS[0]>,
+ * <MAX_VIEWPORT_DIMS[1]> respectively."
+ */
+ invalidate_framebuffer_storage(ctx, fb, numAttachments, attachments,
+ 0, 0,
+ MAX_VIEWPORT_WIDTH, MAX_VIEWPORT_HEIGHT,
+ "glInvalidateNamedFramebufferData");
+}
+
+
+void GLAPIENTRY
_mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
const GLenum *attachments)
{
diff --git a/mesalib/src/mesa/main/fbobject.h b/mesalib/src/mesa/main/fbobject.h
index 61aa1f503..9f570db3a 100644
--- a/mesalib/src/mesa/main/fbobject.h
+++ b/mesalib/src/mesa/main/fbobject.h
@@ -64,9 +64,17 @@ _mesa_get_incomplete_framebuffer(void);
extern struct gl_renderbuffer *
_mesa_lookup_renderbuffer(struct gl_context *ctx, GLuint id);
+extern struct gl_renderbuffer *
+_mesa_lookup_renderbuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func);
+
extern struct gl_framebuffer *
_mesa_lookup_framebuffer(struct gl_context *ctx, GLuint id);
+extern struct gl_framebuffer *
+_mesa_lookup_framebuffer_err(struct gl_context *ctx, GLuint id,
+ const char *func);
+
void
_mesa_update_texture_renderbuffer(struct gl_context *ctx,
@@ -74,9 +82,17 @@ _mesa_update_texture_renderbuffer(struct gl_context *ctx,
struct gl_renderbuffer_attachment *att);
extern void
+_mesa_FramebufferRenderbuffer_sw(struct gl_context *ctx,
+ struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_renderbuffer *rb);
+
+extern void
_mesa_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
- GLenum attachment, struct gl_renderbuffer *rb);
+ GLenum attachment,
+ struct gl_renderbuffer *rb,
+ const char *func);
extern void
_mesa_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb);
@@ -99,6 +115,24 @@ _mesa_detach_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
const void *att);
+extern void
+_mesa_framebuffer_texture(struct gl_context *ctx, struct gl_framebuffer *fb,
+ GLenum attachment,
+ struct gl_texture_object *texObj, GLenum textarget,
+ GLint level, GLuint layer, GLboolean layered,
+ const char *caller);
+
+extern GLenum
+_mesa_check_framebuffer_status(struct gl_context *ctx,
+ struct gl_framebuffer *fb);
+
+extern void
+_mesa_get_framebuffer_attachment_parameter(struct gl_context *ctx,
+ struct gl_framebuffer *buffer,
+ GLenum attachment, GLenum pname,
+ GLint *params, const char *caller);
+
+
extern GLboolean GLAPIENTRY
_mesa_IsRenderbuffer(GLuint renderbuffer);
@@ -165,9 +199,15 @@ _mesa_DeleteFramebuffers(GLsizei n, const GLuint *framebuffers);
extern void GLAPIENTRY
_mesa_GenFramebuffers(GLsizei n, GLuint *framebuffers);
+extern void GLAPIENTRY
+_mesa_CreateFramebuffers(GLsizei n, GLuint *framebuffers);
+
extern GLenum GLAPIENTRY
_mesa_CheckFramebufferStatus(GLenum target);
+extern GLenum GLAPIENTRY
+_mesa_CheckNamedFramebufferStatus(GLuint framebuffer, GLenum target);
+
extern void GLAPIENTRY
_mesa_FramebufferTexture1D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
@@ -179,24 +219,49 @@ _mesa_FramebufferTexture2D(GLenum target, GLenum attachment,
extern void GLAPIENTRY
_mesa_FramebufferTexture3D(GLenum target, GLenum attachment,
GLenum textarget, GLuint texture,
- GLint level, GLint zoffset);
+ GLint level, GLint layer);
extern void GLAPIENTRY
_mesa_FramebufferTextureLayer(GLenum target, GLenum attachment,
GLuint texture, GLint level, GLint layer);
extern void GLAPIENTRY
+_mesa_NamedFramebufferTextureLayer(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level, GLint layer);
+
+extern void GLAPIENTRY
_mesa_FramebufferTexture(GLenum target, GLenum attachment,
GLuint texture, GLint level);
extern void GLAPIENTRY
+_mesa_NamedFramebufferTexture(GLuint framebuffer, GLenum attachment,
+ GLuint texture, GLint level);
+
+extern void GLAPIENTRY
_mesa_FramebufferRenderbuffer(GLenum target, GLenum attachment,
GLenum renderbuffertarget,
GLuint renderbuffer);
extern void GLAPIENTRY
+_mesa_NamedFramebufferRenderbuffer(GLuint framebuffer, GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer);
+
+extern void GLAPIENTRY
_mesa_GetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment,
GLenum pname, GLint *params);
+extern void GLAPIENTRY
+_mesa_GetNamedFramebufferAttachmentParameteriv(GLuint framebuffer,
+ GLenum attachment,
+ GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_NamedFramebufferParameteri(GLuint framebuffer, GLenum pname,
+ GLint param);
+
+extern void GLAPIENTRY
+_mesa_GetNamedFramebufferParameteriv(GLuint framebuffer, GLenum pname,
+ GLint *param);
extern void GLAPIENTRY
_mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
@@ -204,10 +269,22 @@ _mesa_InvalidateSubFramebuffer(GLenum target, GLsizei numAttachments,
GLsizei width, GLsizei height);
extern void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferSubData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height);
+
+extern void GLAPIENTRY
_mesa_InvalidateFramebuffer(GLenum target, GLsizei numAttachments,
const GLenum *attachments);
extern void GLAPIENTRY
+_mesa_InvalidateNamedFramebufferData(GLuint framebuffer,
+ GLsizei numAttachments,
+ const GLenum *attachments);
+
+extern void GLAPIENTRY
_mesa_DiscardFramebufferEXT(GLenum target, GLsizei numAttachments,
const GLenum *attachments);
diff --git a/mesalib/src/mesa/main/ffvertex_prog.c b/mesalib/src/mesa/main/ffvertex_prog.c
index 7fdd9bab6..70adaf885 100644
--- a/mesalib/src/mesa/main/ffvertex_prog.c
+++ b/mesalib/src/mesa/main/ffvertex_prog.c
@@ -135,7 +135,7 @@ static GLboolean check_active_shininess( struct gl_context *ctx,
(key->light_color_material_mask & (1 << attr)))
return GL_TRUE;
- if (key->varying_vp_inputs & VERT_ATTRIB_GENERIC(attr))
+ if (key->varying_vp_inputs & VERT_BIT_GENERIC(attr))
return GL_TRUE;
if (ctx->Light.Material.Attrib[attr][0] != 0.0F)
diff --git a/mesalib/src/mesa/main/framebuffer.c b/mesalib/src/mesa/main/framebuffer.c
index 4f7736a64..665a5ba14 100644
--- a/mesalib/src/mesa/main/framebuffer.c
+++ b/mesalib/src/mesa/main/framebuffer.c
@@ -312,7 +312,7 @@ _mesa_resize_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
if (ctx) {
/* update scissor / window bounds */
- _mesa_update_draw_buffer_bounds(ctx);
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
/* Signal new buffer state so that swrast will update its clipping
* info (the CLIP_BIT flag).
*/
@@ -413,9 +413,9 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
* \param ctx the GL context.
*/
void
-_mesa_update_draw_buffer_bounds(struct gl_context *ctx)
+_mesa_update_draw_buffer_bounds(struct gl_context *ctx,
+ struct gl_framebuffer *buffer)
{
- struct gl_framebuffer *buffer = ctx->DrawBuffer;
int bbox[4];
if (!buffer)
@@ -652,7 +652,7 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
* context state (GL_READ_BUFFER too).
*/
if (fb->ColorDrawBuffer[0] != ctx->Color.DrawBuffer[0]) {
- _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ _mesa_drawbuffers(ctx, fb, ctx->Const.MaxDrawBuffers,
ctx->Color.DrawBuffer, NULL);
}
}
@@ -678,24 +678,21 @@ update_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
/**
- * Update state related to the current draw/read framebuffers.
+ * Update state related to the draw/read framebuffers.
*/
void
-_mesa_update_framebuffer(struct gl_context *ctx)
+_mesa_update_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb)
{
- struct gl_framebuffer *drawFb;
- struct gl_framebuffer *readFb;
-
assert(ctx);
- drawFb = ctx->DrawBuffer;
- readFb = ctx->ReadBuffer;
update_framebuffer(ctx, drawFb);
if (readFb != drawFb)
update_framebuffer(ctx, readFb);
- _mesa_update_clamp_vertex_color(ctx);
- _mesa_update_clamp_fragment_color(ctx);
+ _mesa_update_clamp_vertex_color(ctx, drawFb);
+ _mesa_update_clamp_fragment_color(ctx, drawFb);
}
diff --git a/mesalib/src/mesa/main/framebuffer.h b/mesalib/src/mesa/main/framebuffer.h
index a4274216e..d02b86f20 100644
--- a/mesalib/src/mesa/main/framebuffer.h
+++ b/mesalib/src/mesa/main/framebuffer.h
@@ -77,14 +77,17 @@ _mesa_scissor_bounding_box(const struct gl_context *ctx,
unsigned idx, int *bbox);
extern void
-_mesa_update_draw_buffer_bounds(struct gl_context *ctx);
+_mesa_update_draw_buffer_bounds(struct gl_context *ctx,
+ struct gl_framebuffer *drawFb);
extern void
_mesa_update_framebuffer_visual(struct gl_context *ctx,
struct gl_framebuffer *fb);
extern void
-_mesa_update_framebuffer(struct gl_context *ctx);
+_mesa_update_framebuffer(struct gl_context *ctx,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb);
extern GLboolean
_mesa_source_buffer_exists(struct gl_context *ctx, GLenum format);
diff --git a/mesalib/src/mesa/main/genmipmap.c b/mesalib/src/mesa/main/genmipmap.c
index 9aef09019..32b9460ad 100644
--- a/mesalib/src/mesa/main/genmipmap.c
+++ b/mesalib/src/mesa/main/genmipmap.c
@@ -158,6 +158,13 @@ _mesa_GenerateTextureMipmap(GLuint texture)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGenerateTextureMipmap(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, "glGenerateTextureMipmap");
if (!texObj)
return;
diff --git a/mesalib/src/mesa/main/get.c b/mesalib/src/mesa/main/get.c
index a881bc589..8a6c81aff 100644
--- a/mesalib/src/mesa/main/get.c
+++ b/mesalib/src/mesa/main/get.c
@@ -909,13 +909,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
break;
case GL_FOG_COLOR:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4FV(v->value_float_4, ctx->Fog.Color);
else
COPY_4FV(v->value_float_4, ctx->Fog.ColorUnclamped);
break;
case GL_COLOR_CLEAR_VALUE:
- if (_mesa_get_clamp_fragment_color(ctx)) {
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
v->value_float_4[0] = CLAMP(ctx->Color.ClearColor.f[0], 0.0F, 1.0F);
v->value_float_4[1] = CLAMP(ctx->Color.ClearColor.f[1], 0.0F, 1.0F);
v->value_float_4[2] = CLAMP(ctx->Color.ClearColor.f[2], 0.0F, 1.0F);
@@ -924,13 +924,13 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
COPY_4FV(v->value_float_4, ctx->Color.ClearColor.f);
break;
case GL_BLEND_COLOR_EXT:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4FV(v->value_float_4, ctx->Color.BlendColor);
else
COPY_4FV(v->value_float_4, ctx->Color.BlendColorUnclamped);
break;
case GL_ALPHA_TEST_REF:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
v->value_float = ctx->Color.AlphaRef;
else
v->value_float = ctx->Color.AlphaRefUnclamped;
@@ -1911,6 +1911,7 @@ find_value_indexed(const char *func, GLenum pname, GLuint index, union value *v)
if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs)
goto invalid_value;
v->value_int = ctx->Array.VAO->VertexBinding[VERT_ATTRIB_GENERIC(index)].Stride;
+ return TYPE_INT;
/* ARB_shader_image_load_store */
case GL_IMAGE_BINDING_NAME: {
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index fb4143086..83425176a 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -695,7 +695,8 @@ struct gl_current_attrib
* \note Index and Edgeflag current values are stored as floats in the
* SIX and SEVEN attribute slots.
*/
- GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Position, color, texcoords, etc */
+ /* we need double storage for this for vertex attrib 64bit */
+ GLfloat Attrib[VERT_ATTRIB_MAX][4*2]; /**< Position, color, texcoords, etc */
/**
* \name Current raster position attributes (always valid).
@@ -1523,6 +1524,7 @@ struct gl_client_array
GLboolean Enabled; /**< Enabled flag is a boolean */
GLboolean Normalized; /**< GL_ARB_vertex_program */
GLboolean Integer; /**< Integer-valued? */
+ GLboolean Doubles; /**< double precision values are not converted to floats */
GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
struct gl_buffer_object *BufferObj;/**< GL_ARB_vertex_buffer_object */
@@ -1553,6 +1555,7 @@ struct gl_vertex_attrib_array
GLboolean Enabled; /**< Whether the array is enabled */
GLboolean Normalized; /**< Fixed-point values are normalized when converted to floats */
GLboolean Integer; /**< Fixed-point values are not converted to floats */
+ GLboolean Doubles; /**< double precision values are not converted to floats */
GLuint _ElementSize; /**< Size of each element in bytes */
GLuint VertexBinding; /**< Vertex buffer binding */
};
@@ -1671,6 +1674,9 @@ struct gl_array_attrib
/** The default vertex array object */
struct gl_vertex_array_object *DefaultVAO;
+ /** The last VAO accessed by a DSA function */
+ struct gl_vertex_array_object *LastLookedUpVAO;
+
/** Array objects (GL_ARB/APPLE_vertex_array_object) */
struct _mesa_HashTable *Objects;
@@ -2090,6 +2096,7 @@ struct gl_program
struct nir_shader *nir;
GLbitfield64 InputsRead; /**< Bitmask of which input regs are read */
+ GLbitfield64 DoubleInputsRead; /**< Bitmask of which input regs are read and are doubles */
GLbitfield64 OutputsWritten; /**< Bitmask of which output regs are written */
GLbitfield SystemValuesRead; /**< Bitmask of SYSTEM_VALUE_x inputs used */
GLbitfield InputFlags[MAX_PROGRAM_INPUTS]; /**< PROG_PARAM_BIT_x flags */
@@ -2499,6 +2506,12 @@ struct gl_shader
GLuint NumImages;
/**
+ * Whether early fragment tests are enabled as defined by
+ * ARB_shader_image_load_store.
+ */
+ bool EarlyFragmentTests;
+
+ /**
* Compute shader state from ARB_compute_shader layout qualifiers.
*/
struct {
@@ -3608,6 +3621,7 @@ struct gl_extensions
GLboolean ARB_depth_clamp;
GLboolean ARB_depth_texture;
GLboolean ARB_derivative_control;
+ GLboolean ARB_direct_state_access;
GLboolean ARB_draw_buffers_blend;
GLboolean ARB_draw_elements_base_vertex;
GLboolean ARB_draw_indirect;
@@ -3672,6 +3686,7 @@ struct gl_extensions
GLboolean ARB_transform_feedback3;
GLboolean ARB_transform_feedback_instanced;
GLboolean ARB_uniform_buffer_object;
+ GLboolean ARB_vertex_attrib_64bit;
GLboolean ARB_vertex_program;
GLboolean ARB_vertex_shader;
GLboolean ARB_vertex_type_10f_11f_11f_rev;
diff --git a/mesalib/src/mesa/main/pipelineobj.c b/mesalib/src/mesa/main/pipelineobj.c
index 0fefa7d56..a33cdd139 100644
--- a/mesalib/src/mesa/main/pipelineobj.c
+++ b/mesalib/src/mesa/main/pipelineobj.c
@@ -553,6 +553,12 @@ _mesa_CreateProgramPipelines(GLsizei n, GLuint *pipelines)
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glCreateProgramPipelines("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
create_program_pipelines(ctx, n, pipelines, true);
}
diff --git a/mesalib/src/mesa/main/queryobj.c b/mesalib/src/mesa/main/queryobj.c
index fbccf3fe6..2784b4c05 100644
--- a/mesalib/src/mesa/main/queryobj.c
+++ b/mesalib/src/mesa/main/queryobj.c
@@ -284,6 +284,13 @@ _mesa_CreateQueries(GLenum target, GLsizei n, GLuint *ids)
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateQueries(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
switch (target) {
case GL_SAMPLES_PASSED:
case GL_ANY_SAMPLES_PASSED:
@@ -776,6 +783,9 @@ _mesa_GetQueryObjectiv(GLuint id, GLenum pname, GLint *params)
ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
+ case GL_QUERY_TARGET:
+ *params = q->Target;
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)");
return;
@@ -827,6 +837,9 @@ _mesa_GetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
+ case GL_QUERY_TARGET:
+ *params = q->Target;
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)");
return;
@@ -867,6 +880,9 @@ _mesa_GetQueryObjecti64v(GLuint id, GLenum pname, GLint64EXT *params)
ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
+ case GL_QUERY_TARGET:
+ *params = q->Target;
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjecti64vARB(pname)");
return;
@@ -907,6 +923,9 @@ _mesa_GetQueryObjectui64v(GLuint id, GLenum pname, GLuint64EXT *params)
ctx->Driver.CheckQuery( ctx, q );
*params = q->Ready;
break;
+ case GL_QUERY_TARGET:
+ *params = q->Target;
+ break;
default:
_mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectui64vARB(pname)");
return;
diff --git a/mesalib/src/mesa/main/readpix.c b/mesalib/src/mesa/main/readpix.c
index ed0104c9e..df46f8361 100644
--- a/mesalib/src/mesa/main/readpix.c
+++ b/mesalib/src/mesa/main/readpix.c
@@ -83,7 +83,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, mesa_format texFormat,
if (uses_blit) {
/* For blit-based ReadPixels packing, the clamping is done automatically
* unless the type is float. */
- if (_mesa_get_clamp_read_color(ctx) &&
+ if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) &&
(type == GL_FLOAT || type == GL_HALF_FLOAT)) {
transferOps |= IMAGE_CLAMP_BIT;
}
@@ -91,7 +91,7 @@ get_readpixels_transfer_ops(const struct gl_context *ctx, mesa_format texFormat,
else {
/* For CPU-based ReadPixels packing, the clamping must always be done
* for non-float types, */
- if (_mesa_get_clamp_read_color(ctx) ||
+ if (_mesa_get_clamp_read_color(ctx, ctx->ReadBuffer) ||
(type != GL_FLOAT && type != GL_HALF_FLOAT)) {
transferOps |= IMAGE_CLAMP_BIT;
}
diff --git a/mesalib/src/mesa/main/samplerobj.c b/mesalib/src/mesa/main/samplerobj.c
index a3aacc66a..60711a5b5 100644
--- a/mesalib/src/mesa/main/samplerobj.c
+++ b/mesalib/src/mesa/main/samplerobj.c
@@ -221,6 +221,13 @@ void GLAPIENTRY
_mesa_CreateSamplers(GLsizei count, GLuint *samplers)
{
GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glCreateSamplers("
+ "GL_ARB_direct_state_access is not supported)");
+ return;
+ }
+
create_samplers(ctx, count, samplers, "glCreateSamplers");
}
diff --git a/mesalib/src/mesa/main/shader_query.cpp b/mesalib/src/mesa/main/shader_query.cpp
index d2ca49b43..3445f89a3 100644
--- a/mesalib/src/mesa/main/shader_query.cpp
+++ b/mesalib/src/mesa/main/shader_query.cpp
@@ -28,6 +28,7 @@
* \author Ian Romanick <ian.d.romanick@intel.com>
*/
+#include "main/context.h"
#include "main/core.h"
#include "glsl_symbol_table.h"
#include "ir.h"
@@ -809,6 +810,8 @@ stage_from_enum(GLenum ref)
return MESA_SHADER_GEOMETRY;
case GL_REFERENCED_BY_FRAGMENT_SHADER:
return MESA_SHADER_FRAGMENT;
+ case GL_REFERENCED_BY_COMPUTE_SHADER:
+ return MESA_SHADER_COMPUTE;
default:
assert(!"shader stage not supported");
return MESA_SHADER_STAGES;
@@ -824,6 +827,10 @@ is_resource_referenced(struct gl_shader_program *shProg,
struct gl_program_resource *res,
GLuint index, uint8_t stage)
{
+ /* First, check if we even have such a stage active. */
+ if (!shProg->_LinkedShaders[stage])
+ return false;
+
if (res->Type == GL_ATOMIC_COUNTER_BUFFER)
return RESOURCE_ATC(res)->StageReferences[stage];
@@ -979,6 +986,10 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
case GL_NUM_ACTIVE_VARIABLES:
case GL_ACTIVE_VARIABLES:
return get_buffer_property(shProg, res, prop, val, caller);
+ case GL_REFERENCED_BY_COMPUTE_SHADER:
+ if (!_mesa_has_compute_shaders(ctx))
+ goto invalid_enum;
+ /* fallthrough */
case GL_REFERENCED_BY_VERTEX_SHADER:
case GL_REFERENCED_BY_GEOMETRY_SHADER:
case GL_REFERENCED_BY_FRAGMENT_SHADER:
@@ -1015,17 +1026,18 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
case GL_IS_PER_PATCH:
case GL_REFERENCED_BY_TESS_CONTROL_SHADER:
case GL_REFERENCED_BY_TESS_EVALUATION_SHADER:
- /* GL_ARB_compute_shader */
- case GL_REFERENCED_BY_COMPUTE_SHADER:
default:
- _mesa_error(ctx, GL_INVALID_ENUM, "%s(%s prop %s)", caller,
- _mesa_lookup_enum_by_nr(res->Type),
- _mesa_lookup_enum_by_nr(prop));
- return 0;
+ goto invalid_enum;
}
#undef VALIDATE_TYPE
+invalid_enum:
+ _mesa_error(ctx, GL_INVALID_ENUM, "%s(%s prop %s)", caller,
+ _mesa_lookup_enum_by_nr(res->Type),
+ _mesa_lookup_enum_by_nr(prop));
+ return 0;
+
invalid_operation:
_mesa_error(ctx, GL_INVALID_OPERATION, "%s(%s prop %s)", caller,
_mesa_lookup_enum_by_nr(res->Type),
diff --git a/mesalib/src/mesa/main/shaderimage.c b/mesalib/src/mesa/main/shaderimage.c
index dcbcca623..80b77275f 100644
--- a/mesalib/src/mesa/main/shaderimage.c
+++ b/mesalib/src/mesa/main/shaderimage.c
@@ -58,8 +58,8 @@
# define MESA_FORMAT_SIGNED_RG_8 MESA_FORMAT_R8G8_SNORM
#endif
-static mesa_format
-get_image_format(GLenum format)
+mesa_format
+_mesa_get_shader_image_format(GLenum format)
{
switch (format) {
case GL_RGBA32F:
@@ -331,19 +331,33 @@ get_image_format_class(mesa_format format)
}
}
+void
+_mesa_init_image_units(struct gl_context *ctx)
+{
+ unsigned i;
+
+ for (i = 0; i < ARRAY_SIZE(ctx->ImageUnits); ++i) {
+ struct gl_image_unit *u = &ctx->ImageUnits[i];
+ u->Access = GL_READ_ONLY;
+ u->Format = GL_R8;
+ u->_ActualFormat = _mesa_get_shader_image_format(u->Format);
+ }
+}
+
static GLboolean
validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u)
{
struct gl_texture_object *t = u->TexObj;
- struct gl_texture_image *img;
+ mesa_format tex_format;
- if (!t || u->Level < t->BaseLevel ||
- u->Level > t->_MaxLevel)
+ if (!t)
return GL_FALSE;
_mesa_test_texobj_completeness(ctx, t);
- if ((u->Level == t->BaseLevel && !t->_BaseComplete) ||
+ if (u->Level < t->BaseLevel ||
+ u->Level > t->_MaxLevel ||
+ (u->Level == t->BaseLevel && !t->_BaseComplete) ||
(u->Level != t->BaseLevel && !t->_MipmapComplete))
return GL_FALSE;
@@ -351,25 +365,32 @@ validate_image_unit(struct gl_context *ctx, struct gl_image_unit *u)
u->Layer >= _mesa_get_texture_layers(t, u->Level))
return GL_FALSE;
- if (t->Target == GL_TEXTURE_CUBE_MAP)
- img = t->Image[u->Layer][u->Level];
- else
- img = t->Image[0][u->Level];
+ if (t->Target == GL_TEXTURE_BUFFER) {
+ tex_format = _mesa_get_shader_image_format(t->BufferObjectFormat);
+
+ } else {
+ struct gl_texture_image *img = (t->Target == GL_TEXTURE_CUBE_MAP ?
+ t->Image[u->Layer][u->Level] :
+ t->Image[0][u->Level]);
- if (!img || img->Border ||
- get_image_format_class(img->TexFormat) == IMAGE_FORMAT_CLASS_NONE ||
- img->NumSamples > ctx->Const.MaxImageSamples)
+ if (!img || img->Border || img->NumSamples > ctx->Const.MaxImageSamples)
+ return GL_FALSE;
+
+ tex_format = _mesa_get_shader_image_format(img->InternalFormat);
+ }
+
+ if (!tex_format)
return GL_FALSE;
switch (t->ImageFormatCompatibilityType) {
case GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE:
- if (_mesa_get_format_bytes(img->TexFormat) !=
+ if (_mesa_get_format_bytes(tex_format) !=
_mesa_get_format_bytes(u->_ActualFormat))
return GL_FALSE;
break;
case GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS:
- if (get_image_format_class(img->TexFormat) !=
+ if (get_image_format_class(tex_format) !=
get_image_format_class(u->_ActualFormat))
return GL_FALSE;
break;
@@ -421,7 +442,7 @@ validate_bind_image_texture(struct gl_context *ctx, GLuint unit,
return GL_FALSE;
}
- if (!get_image_format(format)) {
+ if (!_mesa_get_shader_image_format(format)) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(format)");
return GL_FALSE;
}
@@ -435,7 +456,6 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
GLenum format)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_texture_object *t = NULL;
struct gl_image_unit *u;
if (!validate_bind_image_texture(ctx, unit, texture, level,
@@ -448,34 +468,34 @@ _mesa_BindImageTexture(GLuint unit, GLuint texture, GLint level,
ctx->NewDriverState |= ctx->DriverFlags.NewImageUnits;
if (texture) {
- t = _mesa_lookup_texture(ctx, texture);
+ struct gl_texture_object *t = _mesa_lookup_texture(ctx, texture);
+
if (!t) {
_mesa_error(ctx, GL_INVALID_VALUE, "glBindImageTexture(texture)");
return;
}
_mesa_reference_texobj(&u->TexObj, t);
- u->Level = level;
- u->Access = access;
- u->Format = format;
- u->_ActualFormat = get_image_format(format);
-
- if (_mesa_tex_target_is_layered(t->Target)) {
- u->Layered = layered;
- u->Layer = (layered ? 0 : layer);
- } else {
- u->Layered = GL_FALSE;
- u->Layer = 0;
- }
-
} else {
_mesa_reference_texobj(&u->TexObj, NULL);
}
+ u->Level = level;
+ u->Access = access;
+ u->Format = format;
+ u->_ActualFormat = _mesa_get_shader_image_format(format);
u->_Valid = validate_image_unit(ctx, u);
+ if (u->TexObj && _mesa_tex_target_is_layered(u->TexObj->Target)) {
+ u->Layered = layered;
+ u->Layer = (layered ? 0 : layer);
+ } else {
+ u->Layered = GL_FALSE;
+ u->Layer = 0;
+ }
+
if (ctx->Driver.BindImageTexture)
- ctx->Driver.BindImageTexture(ctx, u, t, level, layered,
+ ctx->Driver.BindImageTexture(ctx, u, u->TexObj, level, layered,
layer, access, format);
}
@@ -535,8 +555,7 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
if (texture != 0) {
struct gl_texture_object *texObj;
- struct gl_texture_image *image;
- mesa_format actualFormat;
+ GLenum tex_format;
if (!u->TexObj || u->TexObj->Name != texture) {
texObj = _mesa_lookup_texture_locked(ctx, texture);
@@ -557,25 +576,30 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
texObj = u->TexObj;
}
- image = texObj->Image[0][0];
+ if (texObj->Target == GL_TEXTURE_BUFFER) {
+ tex_format = texObj->BufferObjectFormat;
+ } else {
+ struct gl_texture_image *image = texObj->Image[0][0];
- if (!image || image->Width == 0 || image->Height == 0 || image->Depth == 0) {
- /* The ARB_multi_bind spec says:
- *
- * "An INVALID_OPERATION error is generated if the width,
- * height, or depth of the level zero texture image of
- * any texture in <textures> is zero (per binding)."
- */
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBindImageTextures(the width, height or depth "
- "of the level zero texture image of "
- "textures[%d]=%u is zero)", i, texture);
- continue;
- }
+ if (!image || image->Width == 0 || image->Height == 0 ||
+ image->Depth == 0) {
+ /* The ARB_multi_bind spec says:
+ *
+ * "An INVALID_OPERATION error is generated if the width,
+ * height, or depth of the level zero texture image of
+ * any texture in <textures> is zero (per binding)."
+ */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindImageTextures(the width, height or depth "
+ "of the level zero texture image of "
+ "textures[%d]=%u is zero)", i, texture);
+ continue;
+ }
- actualFormat = get_image_format(image->InternalFormat);
+ tex_format = image->InternalFormat;
+ }
- if (actualFormat == MESA_FORMAT_NONE) {
+ if (_mesa_get_shader_image_format(tex_format) == MESA_FORMAT_NONE) {
/* The ARB_multi_bind spec says:
*
* "An INVALID_OPERATION error is generated if the internal
@@ -586,7 +610,7 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
"glBindImageTextures(the internal format %s of "
"the level zero texture image of textures[%d]=%u "
"is not supported)",
- _mesa_lookup_enum_by_nr(image->InternalFormat),
+ _mesa_lookup_enum_by_nr(tex_format),
i, texture);
continue;
}
@@ -597,8 +621,8 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures)
u->Layered = _mesa_tex_target_is_layered(texObj->Target);
u->Layer = 0;
u->Access = GL_READ_WRITE;
- u->Format = image->InternalFormat;
- u->_ActualFormat = actualFormat;
+ u->Format = tex_format;
+ u->_ActualFormat = _mesa_get_shader_image_format(tex_format);
u->_Valid = validate_image_unit(ctx, u);
} else {
/* Unbind the texture from the unit */
diff --git a/mesalib/src/mesa/main/shaderimage.h b/mesalib/src/mesa/main/shaderimage.h
index 733ac7747..33d8a1eff 100644
--- a/mesalib/src/mesa/main/shaderimage.h
+++ b/mesalib/src/mesa/main/shaderimage.h
@@ -28,10 +28,27 @@
#define SHADERIMAGE_H
#include "glheader.h"
+#include "formats.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
struct gl_context;
/**
+ * Get the matching mesa_format for a shader image format GL enum.
+ */
+mesa_format
+_mesa_get_shader_image_format(GLenum format);
+
+/**
+ * Initialize a context's shader image units to the default state.
+ */
+void
+_mesa_init_image_units(struct gl_context *ctx);
+
+/**
* Recalculate the \c _Valid flag of a context's shader image units.
*
* To be called when the state of any texture bound to an image unit
@@ -51,4 +68,8 @@ _mesa_BindImageTextures(GLuint first, GLsizei count, const GLuint *textures);
void GLAPIENTRY
_mesa_MemoryBarrier(GLbitfield barriers);
+#ifdef __cplusplus
+}
+#endif
+
#endif
diff --git a/mesalib/src/mesa/main/state.c b/mesalib/src/mesa/main/state.c
index cc84c6148..2657c532f 100644
--- a/mesalib/src/mesa/main/state.c
+++ b/mesalib/src/mesa/main/state.c
@@ -101,9 +101,12 @@ update_program(struct gl_context *ctx)
ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY];
struct gl_shader_program *fsProg =
ctx->_Shader->CurrentProgram[MESA_SHADER_FRAGMENT];
+ const struct gl_shader_program *csProg =
+ ctx->_Shader->CurrentProgram[MESA_SHADER_COMPUTE];
const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current;
const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current;
const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current;
+ const struct gl_compute_program *prevCP = ctx->ComputeProgram._Current;
GLbitfield new_state = 0x0;
/*
@@ -199,6 +202,16 @@ update_program(struct gl_context *ctx)
_mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
}
+ if (csProg && csProg->LinkStatus
+ && csProg->_LinkedShaders[MESA_SHADER_COMPUTE]) {
+ /* Use GLSL compute shader */
+ _mesa_reference_compprog(ctx, &ctx->ComputeProgram._Current,
+ gl_compute_program(csProg->_LinkedShaders[MESA_SHADER_COMPUTE]->Program));
+ } else {
+ /* no compute program */
+ _mesa_reference_compprog(ctx, &ctx->ComputeProgram._Current, NULL);
+ }
+
/* Let the driver know what's happening:
*/
if (ctx->FragmentProgram._Current != prevFP) {
@@ -225,6 +238,14 @@ update_program(struct gl_context *ctx)
}
}
+ if (ctx->ComputeProgram._Current != prevCP) {
+ new_state |= _NEW_PROGRAM;
+ if (ctx->Driver.BindProgram) {
+ ctx->Driver.BindProgram(ctx, GL_COMPUTE_PROGRAM_NV,
+ (struct gl_program *) ctx->ComputeProgram._Current);
+ }
+ }
+
return new_state;
}
@@ -368,10 +389,10 @@ _mesa_update_state_locked( struct gl_context *ctx )
update_frontbit( ctx );
if (new_state & _NEW_BUFFERS)
- _mesa_update_framebuffer(ctx);
+ _mesa_update_framebuffer(ctx, ctx->ReadBuffer, ctx->DrawBuffer);
if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
- _mesa_update_draw_buffer_bounds( ctx );
+ _mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
if (new_state & _NEW_LIGHT)
_mesa_update_lighting( ctx );
diff --git a/mesalib/src/mesa/main/texenv.c b/mesalib/src/mesa/main/texenv.c
index ec521e6c6..3edafc0f7 100644
--- a/mesalib/src/mesa/main/texenv.c
+++ b/mesalib/src/mesa/main/texenv.c
@@ -646,7 +646,7 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
if (pname == GL_TEXTURE_ENV_COLOR) {
if(ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
_mesa_update_state(ctx);
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4FV( params, texUnit->EnvColor );
else
COPY_4FV( params, texUnit->EnvColorUnclamped );
diff --git a/mesalib/src/mesa/main/texgetimage.c b/mesalib/src/mesa/main/texgetimage.c
index 92b4d6795..f582a7f78 100644
--- a/mesalib/src/mesa/main/texgetimage.c
+++ b/mesalib/src/mesa/main/texgetimage.c
@@ -1108,6 +1108,13 @@ _mesa_GetTextureImage(GLuint texture, GLint level, GLenum format,
GLenum err;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureImage(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/*
* This has been moved here because a format/type mismatch can cause a NULL
* texImage object, which in turn causes the mismatch error to be
@@ -1344,6 +1351,13 @@ _mesa_GetCompressedTextureImage(GLuint texture, GLint level,
GLint image_stride;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetCompressedTextureImage(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetCompressedTextureImage");
if (!texObj)
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 7bc1da7f8..7616fd7ce 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -3624,6 +3624,13 @@ texturesubimage(struct gl_context *ctx, GLuint dims,
_mesa_lookup_enum_by_nr(format),
_mesa_lookup_enum_by_nr(type), pixels);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureSubImage%uD(GL_ARB_direct_state_access "
+ "is not supported)", dims);
+ return;
+ }
+
/* Get the texture object by Name. */
texObj = _mesa_lookup_texture(ctx, texture);
if (!texObj) {
@@ -4183,6 +4190,12 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage1D";
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", self);
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4207,6 +4220,12 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage2D";
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", self);
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4234,6 +4253,12 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
const char *self = "glCopyTextureSubImage3D";
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported)", self);
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture, self);
if (!texObj)
return;
@@ -4829,6 +4854,13 @@ _mesa_CompressedTextureSubImage1D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTextureSubImage1D(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage1D");
if (!texObj)
@@ -4907,6 +4939,13 @@ _mesa_CompressedTextureSubImage2D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTextureSubImage2D(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage2D");
if (!texObj)
@@ -4985,6 +5024,13 @@ _mesa_CompressedTextureSubImage3D(GLuint texture, GLint level, GLint xoffset,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTextureSubImage3D(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glCompressedTextureSubImage3D");
if (!texObj)
@@ -5469,6 +5515,13 @@ _mesa_TextureBuffer(GLuint texture, GLenum internalFormat, GLuint buffer)
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureBuffer(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glTextureBuffer");
if (!bufObj)
@@ -5497,6 +5550,13 @@ _mesa_TextureBufferRange(GLuint texture, GLenum internalFormat, GLuint buffer,
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
if (buffer) {
bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
"glTextureBufferRange");
@@ -5801,6 +5861,13 @@ _mesa_TextureStorage2DMultisample(GLuint texture, GLsizei samples,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage2DMultisample(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glTextureStorage2DMultisample");
if (!texObj)
@@ -5821,6 +5888,13 @@ _mesa_TextureStorage3DMultisample(GLuint texture, GLsizei samples,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage3DMultisample(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/* Get the texture object by Name. */
texObj = _mesa_lookup_texture_err(ctx, texture,
"glTextureStorage3DMultisample");
diff --git a/mesalib/src/mesa/main/texobj.c b/mesalib/src/mesa/main/texobj.c
index c563f1e74..d51e6954b 100644
--- a/mesalib/src/mesa/main/texobj.c
+++ b/mesalib/src/mesa/main/texobj.c
@@ -1317,6 +1317,13 @@ _mesa_CreateTextures(GLenum target, GLsizei n, GLuint *textures)
GLint targetIndex;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateTextures(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/*
* The 4.5 core profile spec (30.10.2014) doesn't specify what
* glCreateTextures should do with invalid targets, which was probably an
@@ -1808,6 +1815,13 @@ _mesa_BindTextureUnit(GLuint unit, GLuint texture)
_mesa_debug(ctx, "glBindTextureUnit %s %d\n",
_mesa_lookup_enum_by_nr(GL_TEXTURE0+unit), (GLint) texture);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindTextureUnit(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
/* Section 8.1 (Texture Objects) of the OpenGL 4.5 core profile spec
* (20141030) says:
* "When texture is zero, each of the targets enumerated at the
diff --git a/mesalib/src/mesa/main/texparam.c b/mesalib/src/mesa/main/texparam.c
index b5d42d304..1fa583002 100644
--- a/mesalib/src/mesa/main/texparam.c
+++ b/mesalib/src/mesa/main/texparam.c
@@ -1108,6 +1108,13 @@ _mesa_TextureParameterfv(GLuint texture, GLenum pname, const GLfloat *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1124,6 +1131,13 @@ _mesa_TextureParameterf(GLuint texture, GLenum pname, GLfloat param)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterf(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1140,6 +1154,13 @@ _mesa_TextureParameteri(GLuint texture, GLenum pname, GLint param)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameteri(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1157,6 +1178,13 @@ _mesa_TextureParameteriv(GLuint texture, GLenum pname,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1174,6 +1202,13 @@ _mesa_TextureParameterIiv(GLuint texture, GLenum pname, const GLint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1191,6 +1226,13 @@ _mesa_TextureParameterIuiv(GLuint texture, GLenum pname, const GLuint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureParameterIuiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_FALSE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -1650,6 +1692,13 @@ _mesa_GetTextureLevelParameterfv(GLuint texture, GLint level,
GLint iparam;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureLevelParameterfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetTextureLevelParameterfv");
if (!texObj)
@@ -1668,6 +1717,13 @@ _mesa_GetTextureLevelParameteriv(GLuint texture, GLint level,
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureLevelParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = _mesa_lookup_texture_err(ctx, texture,
"glGetTextureLevelParameteriv");
if (!texObj)
@@ -1709,7 +1765,7 @@ get_tex_parameterfv(struct gl_context *ctx,
if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
_mesa_update_state_locked(ctx);
- if (_mesa_get_clamp_fragment_color(ctx)) {
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) {
params[0] = CLAMP(obj->Sampler.BorderColor.f[0], 0.0F, 1.0F);
params[1] = CLAMP(obj->Sampler.BorderColor.f[1], 0.0F, 1.0F);
params[2] = CLAMP(obj->Sampler.BorderColor.f[2], 0.0F, 1.0F);
@@ -2227,6 +2283,13 @@ _mesa_GetTextureParameterfv(GLuint texture, GLenum pname, GLfloat *params)
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterfv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!obj) {
/* User passed a non-generated name. */
@@ -2244,6 +2307,13 @@ _mesa_GetTextureParameteriv(GLuint texture, GLenum pname, GLint *params)
struct gl_texture_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameteriv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!obj) {
/* User passed a non-generated name. */
@@ -2261,6 +2331,13 @@ _mesa_GetTextureParameterIiv(GLuint texture, GLenum pname, GLint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterIiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!texObj) {
/* User passed a non-generated name. */
@@ -2279,6 +2356,13 @@ _mesa_GetTextureParameterIuiv(GLuint texture, GLenum pname, GLuint *params)
struct gl_texture_object *texObj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTextureParameterIuiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
texObj = get_texobj_by_name(ctx, texture, GL_TRUE);
if (!texObj) {
/* User passed a non-generated name. */
diff --git a/mesalib/src/mesa/main/texstorage.c b/mesalib/src/mesa/main/texstorage.c
index 53cb2c091..dee74a825 100644
--- a/mesalib/src/mesa/main/texstorage.c
+++ b/mesalib/src/mesa/main/texstorage.c
@@ -507,6 +507,13 @@ texturestorage(GLuint dims, GLuint texture, GLsizei levels,
_mesa_lookup_enum_by_nr(internalformat),
width, height, depth);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTextureStorage%uD(GL_ARB_direct_state_access "
+ "is not supported)", dims);
+ return;
+ }
+
/* Check the format to make sure it is sized. */
if (!_mesa_is_legal_tex_storage_format(ctx, internalformat)) {
_mesa_error(ctx, GL_INVALID_ENUM,
diff --git a/mesalib/src/mesa/main/transformfeedback.c b/mesalib/src/mesa/main/transformfeedback.c
index 103011ce5..642fa9647 100644
--- a/mesalib/src/mesa/main/transformfeedback.c
+++ b/mesalib/src/mesa/main/transformfeedback.c
@@ -706,6 +706,13 @@ _mesa_TransformFeedbackBufferBase(GLuint xfb, GLuint index, GLuint buffer)
struct gl_transform_feedback_object *obj;
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTransformFeedbackBufferBase(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glTransformFeedbackBufferBase");
if(!obj) {
@@ -729,6 +736,13 @@ _mesa_TransformFeedbackBufferRange(GLuint xfb, GLuint index, GLuint buffer,
struct gl_transform_feedback_object *obj;
struct gl_buffer_object *bufObj;
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTransformFeedbackBufferRange(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glTransformFeedbackBufferRange");
if(!obj) {
@@ -1045,6 +1059,13 @@ _mesa_CreateTransformFeedbacks(GLsizei n, GLuint *names)
{
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCreateTransformFeedbacks(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
create_transform_feedbacks(ctx, n, names, true);
}
@@ -1215,6 +1236,13 @@ _mesa_GetTransformFeedbackiv(GLuint xfb, GLenum pname, GLint *param)
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTransformFeedbackiv(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbackiv");
if(!obj) {
@@ -1241,6 +1269,13 @@ _mesa_GetTransformFeedbacki_v(GLuint xfb, GLenum pname, GLuint index,
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTransformFeedbacki_v(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbacki_v");
if(!obj) {
@@ -1270,6 +1305,13 @@ _mesa_GetTransformFeedbacki64_v(GLuint xfb, GLenum pname, GLuint index,
struct gl_transform_feedback_object *obj;
GET_CURRENT_CONTEXT(ctx);
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTransformFeedbacki64_v(GL_ARB_direct_state_access "
+ "is not supported)");
+ return;
+ }
+
obj = lookup_transform_feedback_object_err(ctx, xfb,
"glGetTransformFeedbacki64_v");
if(!obj) {
diff --git a/mesalib/src/mesa/main/uniform_query.cpp b/mesalib/src/mesa/main/uniform_query.cpp
index 3e857ed10..728bd1bac 100644
--- a/mesalib/src/mesa/main/uniform_query.cpp
+++ b/mesalib/src/mesa/main/uniform_query.cpp
@@ -347,7 +347,8 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
&&
(uni->type->base_type == GLSL_TYPE_INT
|| uni->type->base_type == GLSL_TYPE_UINT
- || uni->type->base_type == GLSL_TYPE_SAMPLER))) {
+ || uni->type->base_type == GLSL_TYPE_SAMPLER
+ || uni->type->base_type == GLSL_TYPE_IMAGE))) {
memcpy(paramsOut, src, bytes);
} else {
union gl_constant_value *const dst =
@@ -366,6 +367,7 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
break;
case GLSL_TYPE_INT:
case GLSL_TYPE_SAMPLER:
+ case GLSL_TYPE_IMAGE:
dst[i].f = (float) src[i].i;
break;
case GLSL_TYPE_BOOL:
diff --git a/mesalib/src/mesa/main/varray.c b/mesalib/src/mesa/main/varray.c
index 42e7f89b2..da6bbce52 100644
--- a/mesalib/src/mesa/main/varray.c
+++ b/mesalib/src/mesa/main/varray.c
@@ -66,6 +66,21 @@
#define UNSIGNED_INT_10F_11F_11F_REV_BIT (1 << 14)
#define ALL_TYPE_BITS ((1 << 15) - 1)
+#define ATTRIB_FORMAT_TYPES_MASK (BYTE_BIT | UNSIGNED_BYTE_BIT | \
+ SHORT_BIT | UNSIGNED_SHORT_BIT | \
+ INT_BIT | UNSIGNED_INT_BIT | \
+ HALF_BIT | FLOAT_BIT | DOUBLE_BIT | \
+ FIXED_GL_BIT | \
+ UNSIGNED_INT_2_10_10_10_REV_BIT | \
+ INT_2_10_10_10_REV_BIT | \
+ UNSIGNED_INT_10F_11F_11F_REV_BIT)
+
+#define ATTRIB_IFORMAT_TYPES_MASK (BYTE_BIT | UNSIGNED_BYTE_BIT | \
+ SHORT_BIT | UNSIGNED_SHORT_BIT | \
+ INT_BIT | UNSIGNED_INT_BIT)
+
+#define ATTRIB_LFORMAT_TYPES_MASK DOUBLE_BIT
+
/** Convert GL datatype enum into a <type>_BIT value seen above */
static GLbitfield
@@ -113,10 +128,11 @@ type_to_bit(const struct gl_context *ctx, GLenum type)
* Sets the VertexBinding field in the vertex attribute given by attribIndex.
*/
static void
-vertex_attrib_binding(struct gl_context *ctx, GLuint attribIndex,
+vertex_attrib_binding(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint attribIndex,
GLuint bindingIndex)
{
- struct gl_vertex_array_object *vao = ctx->Array.VAO;
struct gl_vertex_attrib_array *array = &vao->VertexAttrib[attribIndex];
if (array->VertexBinding != bindingIndex) {
@@ -139,11 +155,12 @@ vertex_attrib_binding(struct gl_context *ctx, GLuint attribIndex,
* and sets the Offset and Stride fields.
*/
static void
-bind_vertex_buffer(struct gl_context *ctx, GLuint index,
+bind_vertex_buffer(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint index,
struct gl_buffer_object *vbo,
GLintptr offset, GLsizei stride)
{
- struct gl_vertex_array_object *vao = ctx->Array.VAO;
struct gl_vertex_buffer_binding *binding = &vao->VertexBinding[index];
if (binding->BufferObj != vbo ||
@@ -167,10 +184,11 @@ bind_vertex_buffer(struct gl_context *ctx, GLuint index,
* given by bindingIndex.
*/
static void
-vertex_binding_divisor(struct gl_context *ctx, GLuint bindingIndex,
+vertex_binding_divisor(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint bindingIndex,
GLuint divisor)
{
- struct gl_vertex_array_object *vao = ctx->Array.VAO;
struct gl_vertex_buffer_binding *binding =
&vao->VertexBinding[bindingIndex];
@@ -243,15 +261,17 @@ get_legal_types_mask(const struct gl_context *ctx)
* \param type Datatype of each component (GL_FLOAT, GL_INT, etc)
* \param normalized Whether integer types are converted to floats in [-1, 1]
* \param integer Integer-valued values (will not be normalized to [-1, 1])
+ * \param doubles Double values not reduced to floats
* \param relativeOffset Offset of the first element relative to the binding offset.
*/
static bool
update_array_format(struct gl_context *ctx,
const char *func,
+ struct gl_vertex_array_object *vao,
GLuint attrib, GLbitfield legalTypesMask,
GLint sizeMin, GLint sizeMax,
GLint size, GLenum type,
- GLboolean normalized, GLboolean integer,
+ GLboolean normalized, GLboolean integer, GLboolean doubles,
GLuint relativeOffset)
{
struct gl_vertex_attrib_array *array;
@@ -362,16 +382,17 @@ update_array_format(struct gl_context *ctx,
elementSize = _mesa_bytes_per_vertex_attrib(size, type);
assert(elementSize != -1);
- array = &ctx->Array.VAO->VertexAttrib[attrib];
+ array = &vao->VertexAttrib[attrib];
array->Size = size;
array->Type = type;
array->Format = format;
array->Normalized = normalized;
array->Integer = integer;
+ array->Doubles = doubles;
array->RelativeOffset = relativeOffset;
array->_ElementSize = elementSize;
- ctx->Array.VAO->NewArrays |= VERT_BIT(attrib);
+ vao->NewArrays |= VERT_BIT(attrib);
ctx->NewState |= _NEW_ARRAY;
return true;
@@ -392,6 +413,7 @@ update_array_format(struct gl_context *ctx,
* \param stride stride between elements, in elements
* \param normalized are integer types converted to floats in [-1, 1]?
* \param integer integer-valued values (will not be normalized to [-1,1])
+ * \param doubles Double values not reduced to floats
* \param ptr the address (or offset inside VBO) of the array data
*/
static void
@@ -400,7 +422,7 @@ update_array(struct gl_context *ctx,
GLuint attrib, GLbitfield legalTypesMask,
GLint sizeMin, GLint sizeMax,
GLint size, GLenum type, GLsizei stride,
- GLboolean normalized, GLboolean integer,
+ GLboolean normalized, GLboolean integer, GLboolean doubles,
const GLvoid *ptr)
{
struct gl_vertex_attrib_array *array;
@@ -453,13 +475,14 @@ update_array(struct gl_context *ctx,
return;
}
- if (!update_array_format(ctx, func, attrib, legalTypesMask, sizeMin,
- sizeMax, size, type, normalized, integer, 0)) {
+ if (!update_array_format(ctx, func, ctx->Array.VAO, attrib,
+ legalTypesMask, sizeMin, sizeMax,
+ size, type, normalized, integer, doubles, 0)) {
return;
}
/* Reset the vertex attrib binding */
- vertex_attrib_binding(ctx, attrib, attrib);
+ vertex_attrib_binding(ctx, ctx->Array.VAO, attrib, attrib);
/* The Stride and Ptr fields are not set by update_array_format() */
array = &ctx->Array.VAO->VertexAttrib[attrib];
@@ -468,7 +491,7 @@ update_array(struct gl_context *ctx,
/* Update the vertex buffer binding */
effectiveStride = stride != 0 ? stride : array->_ElementSize;
- bind_vertex_buffer(ctx, attrib, ctx->Array.ArrayBufferObj,
+ bind_vertex_buffer(ctx, ctx->Array.VAO, attrib, ctx->Array.ArrayBufferObj,
(GLintptr) ptr, effectiveStride);
}
@@ -488,7 +511,7 @@ _mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
update_array(ctx, "glVertexPointer", VERT_ATTRIB_POS,
legalTypes, 2, 4,
- size, type, stride, GL_FALSE, GL_FALSE, ptr);
+ size, type, stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
@@ -507,7 +530,7 @@ _mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
update_array(ctx, "glNormalPointer", VERT_ATTRIB_NORMAL,
legalTypes, 3, 3,
- 3, type, stride, GL_TRUE, GL_FALSE, ptr);
+ 3, type, stride, GL_TRUE, GL_FALSE, GL_FALSE, ptr);
}
@@ -529,7 +552,7 @@ _mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
update_array(ctx, "glColorPointer", VERT_ATTRIB_COLOR0,
legalTypes, sizeMin, BGRA_OR_4,
- size, type, stride, GL_TRUE, GL_FALSE, ptr);
+ size, type, stride, GL_TRUE, GL_FALSE, GL_FALSE, ptr);
}
@@ -543,7 +566,7 @@ _mesa_FogCoordPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
update_array(ctx, "glFogCoordPointer", VERT_ATTRIB_FOG,
legalTypes, 1, 1,
- 1, type, stride, GL_FALSE, GL_FALSE, ptr);
+ 1, type, stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
@@ -558,7 +581,7 @@ _mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
update_array(ctx, "glIndexPointer", VERT_ATTRIB_COLOR_INDEX,
legalTypes, 1, 1,
- 1, type, stride, GL_FALSE, GL_FALSE, ptr);
+ 1, type, stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
@@ -578,7 +601,7 @@ _mesa_SecondaryColorPointer(GLint size, GLenum type,
update_array(ctx, "glSecondaryColorPointer", VERT_ATTRIB_COLOR1,
legalTypes, 3, BGRA_OR_4,
- size, type, stride, GL_TRUE, GL_FALSE, ptr);
+ size, type, stride, GL_TRUE, GL_FALSE, GL_FALSE, ptr);
}
@@ -600,7 +623,7 @@ _mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
update_array(ctx, "glTexCoordPointer", VERT_ATTRIB_TEX(unit),
legalTypes, sizeMin, 4,
- size, type, stride, GL_FALSE, GL_FALSE,
+ size, type, stride, GL_FALSE, GL_FALSE, GL_FALSE,
ptr);
}
@@ -617,7 +640,7 @@ _mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
update_array(ctx, "glEdgeFlagPointer", VERT_ATTRIB_EDGEFLAG,
legalTypes, 1, 1,
- 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, integer, ptr);
+ 1, GL_UNSIGNED_BYTE, stride, GL_FALSE, integer, GL_FALSE, ptr);
}
@@ -637,7 +660,7 @@ _mesa_PointSizePointerOES(GLenum type, GLsizei stride, const GLvoid *ptr)
update_array(ctx, "glPointSizePointer", VERT_ATTRIB_POINT_SIZE,
legalTypes, 1, 1,
- 1, type, stride, GL_FALSE, GL_FALSE, ptr);
+ 1, type, stride, GL_FALSE, GL_FALSE, GL_FALSE, ptr);
}
@@ -668,7 +691,7 @@ _mesa_VertexAttribPointer(GLuint index, GLint size, GLenum type,
update_array(ctx, "glVertexAttribPointer", VERT_ATTRIB_GENERIC(index),
legalTypes, 1, BGRA_OR_4,
- size, type, stride, normalized, GL_FALSE, ptr);
+ size, type, stride, normalized, GL_FALSE, GL_FALSE, ptr);
}
@@ -696,24 +719,36 @@ _mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
update_array(ctx, "glVertexAttribIPointer", VERT_ATTRIB_GENERIC(index),
legalTypes, 1, 4,
- size, type, stride, normalized, integer, ptr);
+ size, type, stride, normalized, integer, GL_FALSE, ptr);
}
-
-
void GLAPIENTRY
-_mesa_EnableVertexAttribArray(GLuint index)
+_mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr)
{
- struct gl_vertex_array_object *vao;
GET_CURRENT_CONTEXT(ctx);
-
+ const GLbitfield legalTypes = (DOUBLE_BIT);
if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glEnableVertexAttribArrayARB(index)");
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribLPointer(index)");
return;
}
- vao = ctx->Array.VAO;
+ update_array(ctx, "glVertexAttribLPointer", VERT_ATTRIB_GENERIC(index),
+ legalTypes, 1, 4,
+ size, type, stride, GL_TRUE, GL_FALSE, GL_TRUE, ptr);
+}
+
+
+static void
+enable_vertex_array_attrib(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint index,
+ const char *func)
+{
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+ return;
+ }
assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
@@ -728,18 +763,52 @@ _mesa_EnableVertexAttribArray(GLuint index)
void GLAPIENTRY
-_mesa_DisableVertexAttribArray(GLuint index)
+_mesa_EnableVertexAttribArray(GLuint index)
{
- struct gl_vertex_array_object *vao;
GET_CURRENT_CONTEXT(ctx);
+ enable_vertex_array_attrib(ctx, ctx->Array.VAO, index,
+ "glEnableVertexAttribArray");
+}
- if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glDisableVertexAttribArrayARB(index)");
+
+void GLAPIENTRY
+_mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glEnableVertexArrayAttrib(GL_ARB_direct_state_access "
+ "is not supported");
return;
}
- vao = ctx->Array.VAO;
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
+ * and DisableVertexArrayAttrib if <vaobj> is not
+ * [compatibility profile: zero or] the name of an existing vertex
+ * array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glEnableVertexArrayAttrib");
+ if (!vao)
+ return;
+
+ enable_vertex_array_attrib(ctx, vao, index, "glEnableVertexArrayAttrib");
+}
+
+
+static void
+disable_vertex_array_attrib(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint index,
+ const char *func)
+{
+ if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(index)", func);
+ return;
+ }
assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
@@ -753,16 +822,54 @@ _mesa_DisableVertexAttribArray(GLuint index)
}
+void GLAPIENTRY
+_mesa_DisableVertexAttribArray(GLuint index)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ disable_vertex_array_attrib(ctx, ctx->Array.VAO, index,
+ "glDisableVertexAttribArray");
+}
+
+
+void GLAPIENTRY
+_mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDisableVertexArrayAttrib(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by EnableVertexArrayAttrib
+ * and DisableVertexArrayAttrib if <vaobj> is not
+ * [compatibility profile: zero or] the name of an existing vertex
+ * array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glDisableVertexArrayAttrib");
+ if (!vao)
+ return;
+
+ disable_vertex_array_attrib(ctx, vao, index, "glDisableVertexArrayAttrib");
+}
+
+
/**
* Return info for a vertex attribute array (no alias with legacy
* vertex attributes (pos, normal, color, etc)). This function does
* not handle the 4-element GL_CURRENT_VERTEX_ATTRIB_ARB query.
*/
static GLuint
-get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
- const char *caller)
+get_vertex_array_attrib(struct gl_context *ctx,
+ const struct gl_vertex_array_object *vao,
+ GLuint index, GLenum pname,
+ const char *caller)
{
- const struct gl_vertex_array_object *vao = ctx->Array.VAO;
const struct gl_vertex_attrib_array *array;
if (index >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
@@ -794,6 +901,11 @@ get_vertex_array_attrib(struct gl_context *ctx, GLuint index, GLenum pname,
return array->Integer;
}
goto error;
+ case GL_VERTEX_ATTRIB_ARRAY_LONG:
+ if (_mesa_is_desktop_gl(ctx)) {
+ return array->Doubles;
+ }
+ goto error;
case GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ARB:
if ((_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_instanced_arrays)
|| _mesa_is_gles3(ctx)) {
@@ -853,7 +965,8 @@ _mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params)
}
}
else {
- params[0] = (GLfloat) get_vertex_array_attrib(ctx, index, pname,
+ params[0] = (GLfloat) get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
"glGetVertexAttribfv");
}
}
@@ -874,11 +987,32 @@ _mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params)
}
}
else {
- params[0] = (GLdouble) get_vertex_array_attrib(ctx, index, pname,
+ params[0] = (GLdouble) get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
"glGetVertexAttribdv");
}
}
+void GLAPIENTRY
+_mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ const GLdouble *v = (const GLdouble *)get_current_attrib(ctx, index, "glGetVertexAttribLdv");
+ if (v != NULL) {
+ params[0] = v[0];
+ params[1] = v[1];
+ params[2] = v[2];
+ params[3] = v[3];
+ }
+ }
+ else {
+ params[0] = (GLdouble) get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
+ "glGetVertexAttribLdv");
+ }
+}
void GLAPIENTRY
_mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
@@ -896,7 +1030,8 @@ _mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params)
}
}
else {
- params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname,
+ params[0] = (GLint) get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
"glGetVertexAttribiv");
}
}
@@ -916,7 +1051,8 @@ _mesa_GetVertexAttribIiv(GLuint index, GLenum pname, GLint *params)
}
}
else {
- params[0] = (GLint) get_vertex_array_attrib(ctx, index, pname,
+ params[0] = (GLint) get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
"glGetVertexAttribIiv");
}
}
@@ -936,7 +1072,8 @@ _mesa_GetVertexAttribIuiv(GLuint index, GLenum pname, GLuint *params)
}
}
else {
- params[0] = get_vertex_array_attrib(ctx, index, pname,
+ params[0] = get_vertex_array_attrib(ctx, ctx->Array.VAO,
+ index, pname,
"glGetVertexAttribIuiv");
}
}
@@ -963,6 +1100,138 @@ _mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer)
}
+/** ARB_direct_state_access */
+void GLAPIENTRY
+_mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index,
+ GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexArrayIndexediv(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated if <vaobj> is not
+ * [compatibility profile: zero or] the name of an existing
+ * vertex array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glGetVertexArrayIndexediv");
+ if (!vao)
+ return;
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "For GetVertexArrayIndexediv, <pname> must be one of
+ * VERTEX_ATTRIB_ARRAY_ENABLED, VERTEX_ATTRIB_ARRAY_SIZE,
+ * VERTEX_ATTRIB_ARRAY_STRIDE, VERTEX_ATTRIB_ARRAY_TYPE,
+ * VERTEX_ATTRIB_ARRAY_NORMALIZED, VERTEX_ATTRIB_ARRAY_INTEGER,
+ * VERTEX_ATTRIB_ARRAY_LONG, VERTEX_ATTRIB_ARRAY_DIVISOR, or
+ * VERTEX_ATTRIB_RELATIVE_OFFSET."
+ *
+ * and:
+ *
+ * "Add GetVertexArrayIndexediv in 'Get Command' for
+ * VERTEX_ATTRIB_ARRAY_BUFFER_BINDING
+ * VERTEX_ATTRIB_BINDING,
+ * VERTEX_ATTRIB_RELATIVE_OFFSET,
+ * VERTEX_BINDING_OFFSET, and
+ * VERTEX_BINDING_STRIDE states"
+ *
+ * The only parameter name common to both lists is
+ * VERTEX_ATTRIB_RELATIVE_OFFSET. Also note that VERTEX_BINDING_BUFFER
+ * and VERTEX_BINDING_DIVISOR are missing from both lists. It seems
+ * pretty clear however that the intent is that it should be possible
+ * to query all vertex attrib and binding states that can be set with
+ * a DSA function.
+ */
+ switch (pname) {
+ case GL_VERTEX_BINDING_OFFSET:
+ params[0] = vao->VertexBinding[VERT_ATTRIB_GENERIC(index)].Offset;
+ break;
+ case GL_VERTEX_BINDING_STRIDE:
+ params[0] = vao->VertexBinding[VERT_ATTRIB_GENERIC(index)].Stride;
+ break;
+ case GL_VERTEX_BINDING_DIVISOR:
+ params[0] = vao->VertexBinding[VERT_ATTRIB_GENERIC(index)].InstanceDivisor;
+ break;
+ case GL_VERTEX_BINDING_BUFFER:
+ params[0] = vao->VertexBinding[VERT_ATTRIB_GENERIC(index)].BufferObj->Name;
+ break;
+ default:
+ params[0] = get_vertex_array_attrib(ctx, vao, index, pname,
+ "glGetVertexArrayIndexediv");
+ break;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index,
+ GLenum pname, GLint64 *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetVertexArrayIndexed64iv(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated if <vaobj> is not
+ * [compatibility profile: zero or] the name of an existing
+ * vertex array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glGetVertexArrayIndexed64iv");
+ if (!vao)
+ return;
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "For GetVertexArrayIndexed64iv, <pname> must be
+ * VERTEX_BINDING_OFFSET."
+ *
+ * and:
+ *
+ * "An INVALID_ENUM error is generated if <pname> is not one of
+ * the valid values listed above for the corresponding command."
+ */
+ if (pname != GL_VERTEX_BINDING_OFFSET) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexArrayIndexed64iv("
+ "pname != GL_VERTEX_BINDING_OFFSET)");
+ return;
+ }
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_VALUE error is generated if <index> is greater than
+ * or equal to the value of MAX_VERTEX_ATTRIBS."
+ *
+ * Since the index refers to a buffer binding in this case, the intended
+ * limit must be MAX_VERTEX_ATTRIB_BINDINGS. Both limits are currently
+ * required to be the same, so in practice this doesn't matter.
+ */
+ if (index >= ctx->Const.MaxVertexAttribBindings) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexArrayIndexed64iv("
+ "index %d >= the value of GL_MAX_VERTEX_ATTRIB_BINDINGS (%d))",
+ index, ctx->Const.MaxVertexAttribBindings);
+ return;
+ }
+
+ params[0] = vao->VertexBinding[VERT_ATTRIB_GENERIC(index)].Offset;
+}
+
+
void GLAPIENTRY
_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
GLsizei count, const GLvoid *ptr)
@@ -1337,6 +1606,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
GET_CURRENT_CONTEXT(ctx);
const GLuint genericIndex = VERT_ATTRIB_GENERIC(index);
+ struct gl_vertex_array_object * const vao = ctx->Array.VAO;
if (!ctx->Extensions.ARB_instanced_arrays) {
_mesa_error(ctx, GL_INVALID_OPERATION, "glVertexAttribDivisor()");
@@ -1349,7 +1619,7 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
return;
}
- assert(genericIndex < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
+ assert(genericIndex < ARRAY_SIZE(vao->VertexAttrib));
/* The ARB_vertex_attrib_binding spec says:
*
@@ -1362,8 +1632,8 @@ _mesa_VertexAttribDivisor(GLuint index, GLuint divisor)
* VertexAttribBinding(index, index);
* VertexBindingDivisor(index, divisor);"
*/
- vertex_attrib_binding(ctx, genericIndex, genericIndex);
- vertex_binding_divisor(ctx, genericIndex, divisor);
+ vertex_attrib_binding(ctx, vao, genericIndex, genericIndex);
+ vertex_binding_divisor(ctx, vao, genericIndex, divisor);
}
@@ -1395,38 +1665,25 @@ _mesa_primitive_restart_index(const struct gl_context *ctx, GLenum ib_type)
/**
* GL_ARB_vertex_attrib_binding
*/
-void GLAPIENTRY
-_mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
- GLsizei stride)
+static void
+vertex_array_vertex_buffer(struct gl_context *ctx, struct gl_vertex_array_object *vao,
+ GLuint bindingIndex, GLuint buffer, GLintptr offset,
+ GLsizei stride, const char *func)
{
- GET_CURRENT_CONTEXT(ctx);
- const struct gl_vertex_array_object *vao = ctx->Array.VAO;
struct gl_buffer_object *vbo;
ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The ARB_vertex_attrib_binding spec says:
*
- * "An INVALID_OPERATION error is generated if no vertex array object
- * is bound."
- */
- if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.VAO == ctx->Array.DefaultVAO) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glBindVertexBuffer(No array object bound)");
- return;
- }
-
- /* The ARB_vertex_attrib_binding spec says:
- *
* "An INVALID_VALUE error is generated if <bindingindex> is greater than
* the value of MAX_VERTEX_ATTRIB_BINDINGS."
*/
if (bindingIndex >= ctx->Const.MaxVertexAttribBindings) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffer(bindingindex=%u > "
+ "%s(bindingindex=%u > "
"GL_MAX_VERTEX_ATTRIB_BINDINGS)",
- bindingIndex);
+ func, bindingIndex);
return;
}
@@ -1437,21 +1694,21 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
*/
if (offset < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffer(offset=%" PRId64 " < 0)",
- (int64_t) offset);
+ "%s(offset=%" PRId64 " < 0)",
+ func, (int64_t) offset);
return;
}
if (stride < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffer(stride=%d < 0)", stride);
+ "%s(stride=%d < 0)", func, stride);
return;
}
if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
stride > ctx->Const.MaxVertexAttribStride) {
- _mesa_error(ctx, GL_INVALID_VALUE, "glBindVertexBuffer(stride=%d > "
- "GL_MAX_VERTEX_ATTRIB_STRIDE)", stride);
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(stride=%d > "
+ "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, stride);
return;
}
@@ -1471,7 +1728,7 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
* object references (automatically gen it).
*/
if (!_mesa_handle_bind_buffer_gen(ctx, GL_ARRAY_BUFFER, buffer,
- &vbo, "glBindVertexBuffer"))
+ &vbo, func))
return;
} else {
/* The ARB_vertex_attrib_binding spec says:
@@ -1482,33 +1739,75 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
vbo = ctx->Shared->NullBufferObj;
}
- bind_vertex_buffer(ctx, VERT_ATTRIB_GENERIC(bindingIndex),
+ bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(bindingIndex),
vbo, offset, stride);
}
void GLAPIENTRY
-_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
- const GLintptr *offsets, const GLsizei *strides)
+_mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
+ GLsizei stride)
{
GET_CURRENT_CONTEXT(ctx);
- struct gl_vertex_array_object * const vao = ctx->Array.VAO;
- GLuint i;
-
- ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The ARB_vertex_attrib_binding spec says:
*
- * "An INVALID_OPERATION error is generated if no
- * vertex array object is bound."
+ * "An INVALID_OPERATION error is generated if no vertex array object
+ * is bound."
*/
if (ctx->API == API_OPENGL_CORE &&
ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBindVertexBuffers(No array object bound)");
+ "glBindVertexBuffer(No array object bound)");
return;
}
+ vertex_array_vertex_buffer(ctx, ctx->Array.VAO, bindingIndex,
+ buffer, offset, stride, "glBindVertexBuffer");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
+ GLintptr offset, GLsizei stride)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayVertexBuffer(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayVertexBuffer");
+ if (!vao)
+ return;
+
+ vertex_array_vertex_buffer(ctx, vao, bindingIndex,
+ buffer, offset, stride,
+ "glVertexArrayVertexBuffer");
+}
+
+
+static void
+vertex_array_vertex_buffers(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint first, GLsizei count, const GLuint *buffers,
+ const GLintptr *offsets, const GLsizei *strides,
+ const char *func)
+{
+ GLuint i;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
/* The ARB_multi_bind spec says:
*
* "An INVALID_OPERATION error is generated if <first> + <count>
@@ -1516,9 +1815,9 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
*/
if (first + count > ctx->Const.MaxVertexAttribBindings) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glBindVertexBuffers(first=%u + count=%d > the value of "
+ "%s(first=%u + count=%d > the value of "
"GL_MAX_VERTEX_ATTRIB_BINDINGS=%u)",
- first, count, ctx->Const.MaxVertexAttribBindings);
+ func, first, count, ctx->Const.MaxVertexAttribBindings);
return;
}
@@ -1535,7 +1834,8 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
struct gl_buffer_object *vbo = ctx->Shared->NullBufferObj;
for (i = 0; i < count; i++)
- bind_vertex_buffer(ctx, VERT_ATTRIB_GENERIC(first + i), vbo, 0, 16);
+ bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i),
+ vbo, 0, 16);
return;
}
@@ -1571,23 +1871,23 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
*/
if (offsets[i] < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffers(offsets[%u]=%" PRId64 " < 0)",
- i, (int64_t) offsets[i]);
+ "%s(offsets[%u]=%" PRId64 " < 0)",
+ func, i, (int64_t) offsets[i]);
continue;
}
if (strides[i] < 0) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffers(strides[%u]=%d < 0)",
- i, strides[i]);
+ "%s(strides[%u]=%d < 0)",
+ func, i, strides[i]);
continue;
}
if (ctx->API == API_OPENGL_CORE && ctx->Version >= 44 &&
strides[i] > ctx->Const.MaxVertexAttribStride) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glBindVertexBuffers(strides[%u]=%d > "
- "GL_MAX_VERTEX_ATTRIB_STRIDE)", i, strides[i]);
+ "%s(strides[%u]=%d > "
+ "GL_MAX_VERTEX_ATTRIB_STRIDE)", func, i, strides[i]);
continue;
}
@@ -1598,8 +1898,7 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
if (buffers[i] == binding->BufferObj->Name)
vbo = binding->BufferObj;
else
- vbo = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, i,
- "glBindVertexBuffers");
+ vbo = _mesa_multi_bind_lookup_bufferobj(ctx, buffers, i, func);
if (!vbo)
continue;
@@ -1607,8 +1906,8 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
vbo = ctx->Shared->NullBufferObj;
}
- bind_vertex_buffer(ctx, VERT_ATTRIB_GENERIC(first + i), vbo,
- offsets[i], strides[i]);
+ bind_vertex_buffer(ctx, vao, VERT_ATTRIB_GENERIC(first + i),
+ vbo, offsets[i], strides[i]);
}
_mesa_end_bufferobj_lookups(ctx);
@@ -1616,65 +1915,68 @@ _mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
void GLAPIENTRY
-_mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
- GLboolean normalized, GLuint relativeOffset)
+_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
+ const GLintptr *offsets, const GLsizei *strides)
{
- const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT |
- SHORT_BIT | UNSIGNED_SHORT_BIT |
- INT_BIT | UNSIGNED_INT_BIT |
- HALF_BIT | FLOAT_BIT | DOUBLE_BIT |
- FIXED_GL_BIT |
- UNSIGNED_INT_2_10_10_10_REV_BIT |
- INT_2_10_10_10_REV_BIT |
- UNSIGNED_INT_10F_11F_11F_REV_BIT);
-
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The ARB_vertex_attrib_binding spec says:
*
- * "An INVALID_OPERATION error is generated under any of the following
- * conditions:
- * - if no vertex array object is currently bound (see section 2.10);
- * - ..."
+ * "An INVALID_OPERATION error is generated if no
+ * vertex array object is bound."
*/
if (ctx->API == API_OPENGL_CORE &&
ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexAttribFormat(No array object bound)");
+ "glBindVertexBuffers(No array object bound)");
return;
}
- /* The ARB_vertex_attrib_binding spec says:
- *
- * "The error INVALID_VALUE is generated if index is greater than or equal
- * to the value of MAX_VERTEX_ATTRIBS."
- */
- if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
- _mesa_error(ctx, GL_INVALID_VALUE,
- "glVertexAttribFormat(attribindex=%u > "
- "GL_MAX_VERTEX_ATTRIBS)",
- attribIndex);
+ vertex_array_vertex_buffers(ctx, ctx->Array.VAO, first, count,
+ buffers, offsets, strides,
+ "glBindVertexBuffers");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
+ const GLuint *buffers,
+ const GLintptr *offsets, const GLsizei *strides)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayVertexBuffers(GL_ARB_direct_state_access "
+ "is not supported");
return;
}
- FLUSH_VERTICES(ctx, 0);
- update_array_format(ctx, "glVertexAttribFormat",
- VERT_ATTRIB_GENERIC(attribIndex),
- legalTypes, 1, BGRA_OR_4, size, type, normalized,
- GL_FALSE, relativeOffset);
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by VertexArrayVertexBuffer
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayVertexBuffers");
+ if (!vao)
+ return;
+
+ vertex_array_vertex_buffers(ctx, vao, first, count,
+ buffers, offsets, strides,
+ "glVertexArrayVertexBuffers");
}
-void GLAPIENTRY
-_mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
- GLuint relativeOffset)
+static void
+vertex_attrib_format(GLuint attribIndex, GLint size, GLenum type,
+ GLboolean normalized, GLboolean integer,
+ GLboolean doubles, GLbitfield legalTypes,
+ GLsizei maxSize, GLuint relativeOffset,
+ const char *func)
{
- const GLbitfield legalTypes = (BYTE_BIT | UNSIGNED_BYTE_BIT |
- SHORT_BIT | UNSIGNED_SHORT_BIT |
- INT_BIT | UNSIGNED_INT_BIT);
-
GET_CURRENT_CONTEXT(ctx);
ASSERT_OUTSIDE_BEGIN_END(ctx);
@@ -1684,33 +1986,59 @@ _mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
* conditions:
* - if no vertex array object is currently bound (see section 2.10);
* - ..."
+ *
+ * This error condition only applies to VertexAttribFormat and
+ * VertexAttribIFormat in the extension spec, but we assume that this
+ * is an oversight. In the OpenGL 4.3 (Core Profile) spec, it applies
+ * to all three functions.
*/
if (ctx->API == API_OPENGL_CORE &&
ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexAttribIFormat(No array object bound)");
+ "%s(No array object bound)", func);
return;
}
/* The ARB_vertex_attrib_binding spec says:
*
- * "The error INVALID_VALUE is generated if index is greater than
- * or equal to the value of MAX_VERTEX_ATTRIBS."
+ * "The error INVALID_VALUE is generated if index is greater than or equal
+ * to the value of MAX_VERTEX_ATTRIBS."
*/
if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glVertexAttribIFormat(attribindex=%u > "
+ "%s(attribindex=%u > "
"GL_MAX_VERTEX_ATTRIBS)",
- attribIndex);
+ func, attribIndex);
return;
}
FLUSH_VERTICES(ctx, 0);
- update_array_format(ctx, "glVertexAttribIFormat",
+ update_array_format(ctx, func, ctx->Array.VAO,
VERT_ATTRIB_GENERIC(attribIndex),
- legalTypes, 1, 4, size, type, GL_FALSE, GL_TRUE,
- relativeOffset);
+ legalTypes, 1, maxSize, size, type,
+ normalized, integer, doubles, relativeOffset);
+}
+
+
+void GLAPIENTRY
+_mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
+ GLboolean normalized, GLuint relativeOffset)
+{
+ vertex_attrib_format(attribIndex, size, type, normalized,
+ GL_FALSE, GL_FALSE, ATTRIB_FORMAT_TYPES_MASK,
+ BGRA_OR_4, relativeOffset,
+ "glVertexAttribFormat");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
+ GLuint relativeOffset)
+{
+ vertex_attrib_format(attribIndex, size, type, GL_FALSE,
+ GL_TRUE, GL_FALSE, ATTRIB_IFORMAT_TYPES_MASK, 4,
+ relativeOffset, "glVertexAttribIFormat");
}
@@ -1718,67 +2046,104 @@ void GLAPIENTRY
_mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
GLuint relativeOffset)
{
- const GLbitfield legalTypes = DOUBLE_BIT;
+ vertex_attrib_format(attribIndex, size, type, GL_FALSE, GL_FALSE,
+ GL_TRUE, ATTRIB_LFORMAT_TYPES_MASK, 4,
+ relativeOffset, "glVertexAttribLFormat");
+}
+
+static void
+vertex_array_attrib_format(GLuint vaobj, GLuint attribIndex, GLint size,
+ GLenum type, GLboolean normalized,
+ GLboolean integer, GLboolean doubles,
+ GLbitfield legalTypes, GLsizei maxSize,
+ GLuint relativeOffset, const char *func)
+{
GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "%s(GL_ARB_direct_state_access is not supported", func);
+ return;
+ }
+
ASSERT_OUTSIDE_BEGIN_END(ctx);
- /* Page 298 of the PDF of the OpenGL 4.3 (Core Profile) spec says:
- *
- * "An INVALID_OPERATION error is generated under any of the following
- * conditions:
- * • if no vertex array object is currently bound (see section 10.4);
- * • ..."
+ /* The ARB_direct_state_access spec says:
*
- * This language is missing from the extension spec, but we assume
- * that this is an oversight.
+ * "An INVALID_OPERATION error is generated by VertexArrayAttrib*Format
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
*/
- if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.VAO == ctx->Array.DefaultVAO) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexAttribLFormat(No array object bound)");
+ vao = _mesa_lookup_vao_err(ctx, vaobj, func);
+ if (!vao)
return;
- }
/* The ARB_vertex_attrib_binding spec says:
*
- * "The error INVALID_VALUE is generated if <attribindex> is greater than
- * or equal to the value of MAX_VERTEX_ATTRIBS."
+ * "The error INVALID_VALUE is generated if index is greater than or equal
+ * to the value of MAX_VERTEX_ATTRIBS."
*/
if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glVertexAttribLFormat(attribindex=%u > "
- "GL_MAX_VERTEX_ATTRIBS)",
- attribIndex);
+ "%s(attribindex=%u > GL_MAX_VERTEX_ATTRIBS)",
+ func, attribIndex);
return;
}
FLUSH_VERTICES(ctx, 0);
- update_array_format(ctx, "glVertexAttribLFormat",
+ update_array_format(ctx, func, vao,
VERT_ATTRIB_GENERIC(attribIndex),
- legalTypes, 1, 4, size, type, GL_FALSE, GL_FALSE,
- relativeOffset);
+ legalTypes, 1, maxSize, size, type, normalized,
+ integer, doubles, relativeOffset);
}
void GLAPIENTRY
-_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
+_mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size,
+ GLenum type, GLboolean normalized,
+ GLuint relativeOffset)
{
- GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
+ vertex_array_attrib_format(vaobj, attribIndex, size, type, normalized,
+ GL_FALSE, GL_FALSE, ATTRIB_FORMAT_TYPES_MASK,
+ BGRA_OR_4, relativeOffset,
+ "glVertexArrayAttribFormat");
+}
- /* The ARB_vertex_attrib_binding spec says:
- *
- * "An INVALID_OPERATION error is generated if no vertex array object
- * is bound."
- */
- if (ctx->API == API_OPENGL_CORE &&
- ctx->Array.VAO == ctx->Array.DefaultVAO) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexAttribBinding(No array object bound)");
- return;
- }
+
+void GLAPIENTRY
+_mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex,
+ GLint size, GLenum type,
+ GLuint relativeOffset)
+{
+ vertex_array_attrib_format(vaobj, attribIndex, size, type, GL_FALSE,
+ GL_TRUE, GL_FALSE, ATTRIB_IFORMAT_TYPES_MASK,
+ 4, relativeOffset,
+ "glVertexArrayAttribIFormat");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
+ GLint size, GLenum type,
+ GLuint relativeOffset)
+{
+ vertex_array_attrib_format(vaobj, attribIndex, size, type, GL_FALSE,
+ GL_FALSE, GL_TRUE, ATTRIB_LFORMAT_TYPES_MASK,
+ 4, relativeOffset,
+ "glVertexArrayAttribLFormat");
+}
+
+
+static void
+vertex_array_attrib_binding(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint attribIndex, GLuint bindingIndex,
+ const char *func)
+{
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
/* The ARB_vertex_attrib_binding spec says:
*
@@ -1789,38 +2154,32 @@ _mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
*/
if (attribIndex >= ctx->Const.Program[MESA_SHADER_VERTEX].MaxAttribs) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glVertexAttribBinding(attribindex=%u >= "
+ "%s(attribindex=%u >= "
"GL_MAX_VERTEX_ATTRIBS)",
- attribIndex);
+ func, attribIndex);
return;
}
if (bindingIndex >= ctx->Const.MaxVertexAttribBindings) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glVertexAttribBinding(bindingindex=%u >= "
+ "%s(bindingindex=%u >= "
"GL_MAX_VERTEX_ATTRIB_BINDINGS)",
- bindingIndex);
+ func, bindingIndex);
return;
}
- assert(VERT_ATTRIB_GENERIC(attribIndex) <
- ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(attribIndex) < ARRAY_SIZE(vao->VertexAttrib));
- vertex_attrib_binding(ctx, VERT_ATTRIB_GENERIC(attribIndex),
+ vertex_attrib_binding(ctx, vao,
+ VERT_ATTRIB_GENERIC(attribIndex),
VERT_ATTRIB_GENERIC(bindingIndex));
}
void GLAPIENTRY
-_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
+_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex)
{
GET_CURRENT_CONTEXT(ctx);
- ASSERT_OUTSIDE_BEGIN_END(ctx);
-
- if (!ctx->Extensions.ARB_instanced_arrays) {
- _mesa_error(ctx, GL_INVALID_OPERATION, "glVertexBindingDivisor()");
- return;
- }
/* The ARB_vertex_attrib_binding spec says:
*
@@ -1830,7 +2189,54 @@ _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
if (ctx->API == API_OPENGL_CORE &&
ctx->Array.VAO == ctx->Array.DefaultVAO) {
_mesa_error(ctx, GL_INVALID_OPERATION,
- "glVertexBindingDivisor(No array object bound)");
+ "glVertexAttribBinding(No array object bound)");
+ return;
+ }
+
+ vertex_array_attrib_binding(ctx, ctx->Array.VAO,
+ attribIndex, bindingIndex,
+ "glVertexAttribBinding");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex, GLuint bindingIndex)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_vertex_array_object *vao;
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayAttribBinding(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by VertexArrayAttribBinding
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayAttribBinding");
+ if (!vao)
+ return;
+
+ vertex_array_attrib_binding(ctx, vao, attribIndex, bindingIndex,
+ "glVertexArrayAttribBinding");
+}
+
+
+static void
+vertex_array_binding_divisor(struct gl_context *ctx,
+ struct gl_vertex_array_object *vao,
+ GLuint bindingIndex, GLuint divisor,
+ const char *func)
+{
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->Extensions.ARB_instanced_arrays) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s()", func);
return;
}
@@ -1841,13 +2247,64 @@ _mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
*/
if (bindingIndex >= ctx->Const.MaxVertexAttribBindings) {
_mesa_error(ctx, GL_INVALID_VALUE,
- "glVertexBindingDivisor(bindingindex=%u > "
+ "%s(bindingindex=%u > "
"GL_MAX_VERTEX_ATTRIB_BINDINGS)",
- bindingIndex);
+ func, bindingIndex);
return;
}
- vertex_binding_divisor(ctx, VERT_ATTRIB_GENERIC(bindingIndex), divisor);
+ vertex_binding_divisor(ctx, vao, VERT_ATTRIB_GENERIC(bindingIndex), divisor);
+}
+
+
+void GLAPIENTRY
+_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* The ARB_vertex_attrib_binding spec says:
+ *
+ * "An INVALID_OPERATION error is generated if no vertex array object
+ * is bound."
+ */
+ if (ctx->API == API_OPENGL_CORE &&
+ ctx->Array.VAO == ctx->Array.DefaultVAO) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexBindingDivisor(No array object bound)");
+ return;
+ }
+
+ vertex_array_binding_divisor(ctx, ctx->Array.VAO,
+ bindingIndex, divisor,
+ "glVertexBindingDivisor");
+}
+
+
+void GLAPIENTRY
+_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor)
+{
+ struct gl_vertex_array_object *vao;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_direct_state_access) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glVertexArrayBindingDivisor(GL_ARB_direct_state_access "
+ "is not supported");
+ return;
+ }
+
+ /* The ARB_direct_state_access specification says:
+ *
+ * "An INVALID_OPERATION error is generated by VertexArrayBindingDivisor
+ * if <vaobj> is not [compatibility profile: zero or] the name of an
+ * existing vertex array object."
+ */
+ vao = _mesa_lookup_vao_err(ctx, vaobj, "glVertexArrayBindingDivisor");
+ if (!vao)
+ return;
+
+ vertex_array_binding_divisor(ctx, vao, bindingIndex, divisor,
+ "glVertexArrayBindingDivisor");
}
@@ -1868,6 +2325,7 @@ _mesa_copy_client_array(struct gl_context *ctx,
dst->Enabled = src->Enabled;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
+ dst->Doubles = src->Doubles;
dst->InstanceDivisor = src->InstanceDivisor;
dst->_ElementSize = src->_ElementSize;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
@@ -1885,6 +2343,7 @@ _mesa_copy_vertex_attrib_array(struct gl_context *ctx,
dst->RelativeOffset = src->RelativeOffset;
dst->Format = src->Format;
dst->Integer = src->Integer;
+ dst->Doubles = src->Doubles;
dst->Normalized = src->Normalized;
dst->Ptr = src->Ptr;
dst->Enabled = src->Enabled;
diff --git a/mesalib/src/mesa/main/varray.h b/mesalib/src/mesa/main/varray.h
index 4e4bd5f80..5583ed5a1 100644
--- a/mesalib/src/mesa/main/varray.h
+++ b/mesalib/src/mesa/main/varray.h
@@ -68,6 +68,7 @@ _mesa_update_client_array(struct gl_context *ctx,
dst->Enabled = src->Enabled;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
+ dst->Doubles = src->Doubles;
dst->InstanceDivisor = binding->InstanceDivisor;
dst->_ElementSize = src->_ElementSize;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
@@ -166,22 +167,34 @@ void GLAPIENTRY
_mesa_VertexAttribIPointer(GLuint index, GLint size, GLenum type,
GLsizei stride, const GLvoid *ptr);
+extern void GLAPIENTRY
+_mesa_VertexAttribLPointer(GLuint index, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *pointer);
extern void GLAPIENTRY
_mesa_EnableVertexAttribArray(GLuint index);
extern void GLAPIENTRY
+_mesa_EnableVertexArrayAttrib(GLuint vaobj, GLuint index);
+
+
+extern void GLAPIENTRY
_mesa_DisableVertexAttribArray(GLuint index);
extern void GLAPIENTRY
-_mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);
+_mesa_DisableVertexArrayAttrib(GLuint vaobj, GLuint index);
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribdv(GLuint index, GLenum pname, GLdouble *params);
extern void GLAPIENTRY
_mesa_GetVertexAttribfv(GLuint index, GLenum pname, GLfloat *params);
+extern void GLAPIENTRY
+_mesa_GetVertexAttribLdv(GLuint index, GLenum pname, GLdouble *params);
extern void GLAPIENTRY
_mesa_GetVertexAttribiv(GLuint index, GLenum pname, GLint *params);
@@ -199,6 +212,16 @@ extern void GLAPIENTRY
_mesa_GetVertexAttribPointerv(GLuint index, GLenum pname, GLvoid **pointer);
+void GLAPIENTRY
+_mesa_GetVertexArrayIndexediv(GLuint vaobj, GLuint index,
+ GLenum pname, GLint *param);
+
+
+void GLAPIENTRY
+_mesa_GetVertexArrayIndexed64iv(GLuint vaobj, GLuint index,
+ GLenum pname, GLint64 *param);
+
+
extern void GLAPIENTRY
_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
@@ -278,27 +301,57 @@ _mesa_BindVertexBuffer(GLuint bindingIndex, GLuint buffer, GLintptr offset,
GLsizei stride);
extern void GLAPIENTRY
+_mesa_VertexArrayVertexBuffer(GLuint vaobj, GLuint bindingIndex, GLuint buffer,
+ GLintptr offset, GLsizei stride);
+
+extern void GLAPIENTRY
_mesa_BindVertexBuffers(GLuint first, GLsizei count, const GLuint *buffers,
const GLintptr *offsets, const GLsizei *strides);
extern void GLAPIENTRY
+_mesa_VertexArrayVertexBuffers(GLuint vaobj, GLuint first, GLsizei count,
+ const GLuint *buffers,
+ const GLintptr *offsets, const GLsizei *strides);
+
+extern void GLAPIENTRY
_mesa_VertexAttribFormat(GLuint attribIndex, GLint size, GLenum type,
GLboolean normalized, GLuint relativeOffset);
extern void GLAPIENTRY
+_mesa_VertexArrayAttribFormat(GLuint vaobj, GLuint attribIndex, GLint size,
+ GLenum type, GLboolean normalized,
+ GLuint relativeOffset);
+
+extern void GLAPIENTRY
_mesa_VertexAttribIFormat(GLuint attribIndex, GLint size, GLenum type,
GLuint relativeOffset);
extern void GLAPIENTRY
+_mesa_VertexArrayAttribIFormat(GLuint vaobj, GLuint attribIndex,
+ GLint size, GLenum type,
+ GLuint relativeOffset);
+
+extern void GLAPIENTRY
_mesa_VertexAttribLFormat(GLuint attribIndex, GLint size, GLenum type,
GLuint relativeOffset);
extern void GLAPIENTRY
+_mesa_VertexArrayAttribLFormat(GLuint vaobj, GLuint attribIndex,
+ GLint size, GLenum type,
+ GLuint relativeOffset);
+
+extern void GLAPIENTRY
_mesa_VertexAttribBinding(GLuint attribIndex, GLuint bindingIndex);
extern void GLAPIENTRY
+_mesa_VertexArrayAttribBinding(GLuint vaobj, GLuint attribIndex,
+ GLuint bindingIndex);
+
+extern void GLAPIENTRY
_mesa_VertexBindingDivisor(GLuint bindingIndex, GLuint divisor);
+extern void GLAPIENTRY
+_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex, GLuint divisor);
extern void
_mesa_copy_client_array(struct gl_context *ctx,
diff --git a/mesalib/src/mesa/main/version.c b/mesalib/src/mesa/main/version.c
index 5b8ac0a5c..699a0de46 100644
--- a/mesalib/src/mesa/main/version.c
+++ b/mesalib/src/mesa/main/version.c
@@ -32,23 +32,16 @@
/**
* Scans 'string' to see if it ends with 'ending'.
*/
-static GLboolean
+static bool
check_for_ending(const char *string, const char *ending)
{
- int len1, len2;
+ const size_t len1 = strlen(string);
+ const size_t len2 = strlen(ending);
- len1 = strlen(string);
- len2 = strlen(ending);
+ if (len2 > len1)
+ return false;
- if (len2 > len1) {
- return GL_FALSE;
- }
-
- if (strcmp(string + (len1 - len2), ending) == 0) {
- return GL_TRUE;
- } else {
- return GL_FALSE;
- }
+ return strcmp(string + (len1 - len2), ending) == 0;
}
/**
@@ -58,15 +51,14 @@ check_for_ending(const char *string, const char *ending)
* fwd_context is only valid if version > 0
*/
static void
-get_gl_override(int *version, GLboolean *fwd_context,
- GLboolean *compat_context)
+get_gl_override(int *version, bool *fwd_context, bool *compat_context)
{
const char *env_var = "MESA_GL_VERSION_OVERRIDE";
const char *version_str;
int major, minor, n;
static int override_version = -1;
- static GLboolean fc_suffix = GL_FALSE;
- static GLboolean compat_suffix = GL_FALSE;
+ static bool fc_suffix = false;
+ static bool compat_suffix = false;
if (override_version < 0) {
override_version = 0;
@@ -78,12 +70,14 @@ get_gl_override(int *version, GLboolean *fwd_context,
n = sscanf(version_str, "%u.%u", &major, &minor);
if (n != 2) {
- fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version_str);
+ fprintf(stderr, "error: invalid value for %s: %s\n",
+ env_var, version_str);
override_version = 0;
} else {
override_version = major * 10 + minor;
if (override_version < 30 && fc_suffix) {
- fprintf(stderr, "error: invalid value for %s: %s\n", env_var, version_str);
+ fprintf(stderr, "error: invalid value for %s: %s\n",
+ env_var, version_str);
}
}
}
@@ -134,7 +128,7 @@ _mesa_override_gl_version_contextless(struct gl_constants *consts,
gl_api *apiOut, GLuint *versionOut)
{
int version;
- GLboolean fwd_context, compat_context;
+ bool fwd_context, compat_context;
get_gl_override(&version, &fwd_context, &compat_context);
@@ -148,9 +142,9 @@ _mesa_override_gl_version_contextless(struct gl_constants *consts,
} else {
*apiOut = API_OPENGL_COMPAT;
}
- return GL_TRUE;
+ return true;
}
- return GL_FALSE;
+ return false;
}
void
@@ -171,7 +165,7 @@ int
_mesa_get_gl_version_override(void)
{
int version;
- GLboolean fwd_context, compat_context;
+ bool fwd_context, compat_context;
get_gl_override(&version, &fwd_context, &compat_context);
@@ -211,121 +205,121 @@ compute_version(const struct gl_extensions *extensions,
{
GLuint major, minor, version;
- const GLboolean ver_1_3 = (extensions->ARB_texture_border_clamp &&
- extensions->ARB_texture_cube_map &&
- extensions->ARB_texture_env_combine &&
- extensions->ARB_texture_env_dot3);
- const GLboolean ver_1_4 = (ver_1_3 &&
- extensions->ARB_depth_texture &&
- extensions->ARB_shadow &&
- extensions->ARB_texture_env_crossbar &&
- extensions->EXT_blend_color &&
- extensions->EXT_blend_func_separate &&
- extensions->EXT_blend_minmax &&
- extensions->EXT_point_parameters);
- const GLboolean ver_1_5 = (ver_1_4 &&
- extensions->ARB_occlusion_query);
- const GLboolean ver_2_0 = (ver_1_5 &&
- extensions->ARB_point_sprite &&
- extensions->ARB_vertex_shader &&
- extensions->ARB_fragment_shader &&
- extensions->ARB_texture_non_power_of_two &&
- extensions->EXT_blend_equation_separate &&
-
- /* Technically, 2.0 requires the functionality
- * of the EXT version. Enable 2.0 if either
- * extension is available, and assume that a
- * driver that only exposes the ATI extension
- * will fallback to software when necessary.
- */
- (extensions->EXT_stencil_two_side
- || extensions->ATI_separate_stencil));
- const GLboolean ver_2_1 = (ver_2_0 &&
- extensions->EXT_pixel_buffer_object &&
- extensions->EXT_texture_sRGB);
- const GLboolean ver_3_0 = (ver_2_1 &&
- consts->GLSLVersion >= 130 &&
- (consts->MaxSamples >= 4 || consts->FakeSWMSAA) &&
- (api == API_OPENGL_CORE ||
- extensions->ARB_color_buffer_float) &&
- extensions->ARB_depth_buffer_float &&
- extensions->ARB_half_float_vertex &&
- extensions->ARB_map_buffer_range &&
- extensions->ARB_shader_texture_lod &&
- extensions->ARB_texture_float &&
- extensions->ARB_texture_rg &&
- extensions->ARB_texture_compression_rgtc &&
- extensions->EXT_draw_buffers2 &&
- extensions->ARB_framebuffer_object &&
- extensions->EXT_framebuffer_sRGB &&
- extensions->EXT_packed_float &&
- extensions->EXT_texture_array &&
- extensions->EXT_texture_shared_exponent &&
- extensions->EXT_transform_feedback &&
- extensions->NV_conditional_render);
- const GLboolean ver_3_1 = (ver_3_0 &&
- consts->GLSLVersion >= 140 &&
- extensions->ARB_draw_instanced &&
- extensions->ARB_texture_buffer_object &&
- extensions->ARB_uniform_buffer_object &&
- extensions->EXT_texture_snorm &&
- extensions->NV_primitive_restart &&
- extensions->NV_texture_rectangle &&
- consts->Program[MESA_SHADER_VERTEX].MaxTextureImageUnits >= 16);
- const GLboolean ver_3_2 = (ver_3_1 &&
- consts->GLSLVersion >= 150 &&
- extensions->ARB_depth_clamp &&
- extensions->ARB_draw_elements_base_vertex &&
- extensions->ARB_fragment_coord_conventions &&
- extensions->EXT_provoking_vertex &&
- extensions->ARB_seamless_cube_map &&
- extensions->ARB_sync &&
- extensions->ARB_texture_multisample &&
- extensions->EXT_vertex_array_bgra);
- const GLboolean ver_3_3 = (ver_3_2 &&
- consts->GLSLVersion >= 330 &&
- extensions->ARB_blend_func_extended &&
- extensions->ARB_explicit_attrib_location &&
- extensions->ARB_instanced_arrays &&
- extensions->ARB_occlusion_query2 &&
- extensions->ARB_shader_bit_encoding &&
- extensions->ARB_texture_rgb10_a2ui &&
- extensions->ARB_timer_query &&
- extensions->ARB_vertex_type_2_10_10_10_rev &&
- extensions->EXT_texture_swizzle);
- /* ARB_sampler_objects is always enabled in mesa */
-
- const GLboolean ver_4_0 = (ver_3_3 &&
- consts->GLSLVersion >= 400 &&
- extensions->ARB_draw_buffers_blend &&
- extensions->ARB_draw_indirect &&
- extensions->ARB_gpu_shader5 &&
- extensions->ARB_gpu_shader_fp64 &&
- extensions->ARB_sample_shading &&
- 0/*extensions->ARB_shader_subroutine*/ &&
- extensions->ARB_tessellation_shader &&
- extensions->ARB_texture_buffer_object_rgb32 &&
- extensions->ARB_texture_cube_map_array &&
- extensions->ARB_texture_query_lod &&
- extensions->ARB_transform_feedback2 &&
- extensions->ARB_transform_feedback3);
- const GLboolean ver_4_1 = (ver_4_0 &&
- consts->GLSLVersion >= 410 &&
- extensions->ARB_ES2_compatibility &&
- extensions->ARB_shader_precision &&
- 0/*extensions->ARB_vertex_attrib_64bit*/ &&
- extensions->ARB_viewport_array);
- const GLboolean ver_4_2 = (ver_4_1 &&
- consts->GLSLVersion >= 420 &&
- extensions->ARB_base_instance &&
- extensions->ARB_conservative_depth &&
- extensions->ARB_internalformat_query &&
- extensions->ARB_shader_atomic_counters &&
- extensions->ARB_shader_image_load_store &&
- extensions->ARB_shading_language_420pack &&
- extensions->ARB_shading_language_packing &&
- extensions->ARB_texture_compression_bptc &&
- extensions->ARB_transform_feedback_instanced);
+ const bool ver_1_3 = (extensions->ARB_texture_border_clamp &&
+ extensions->ARB_texture_cube_map &&
+ extensions->ARB_texture_env_combine &&
+ extensions->ARB_texture_env_dot3);
+ const bool ver_1_4 = (ver_1_3 &&
+ extensions->ARB_depth_texture &&
+ extensions->ARB_shadow &&
+ extensions->ARB_texture_env_crossbar &&
+ extensions->EXT_blend_color &&
+ extensions->EXT_blend_func_separate &&
+ extensions->EXT_blend_minmax &&
+ extensions->EXT_point_parameters);
+ const bool ver_1_5 = (ver_1_4 &&
+ extensions->ARB_occlusion_query);
+ const bool ver_2_0 = (ver_1_5 &&
+ extensions->ARB_point_sprite &&
+ extensions->ARB_vertex_shader &&
+ extensions->ARB_fragment_shader &&
+ extensions->ARB_texture_non_power_of_two &&
+ extensions->EXT_blend_equation_separate &&
+
+ /* Technically, 2.0 requires the functionality of the
+ * EXT version. Enable 2.0 if either extension is
+ * available, and assume that a driver that only
+ * exposes the ATI extension will fallback to
+ * software when necessary.
+ */
+ (extensions->EXT_stencil_two_side
+ || extensions->ATI_separate_stencil));
+ const bool ver_2_1 = (ver_2_0 &&
+ extensions->EXT_pixel_buffer_object &&
+ extensions->EXT_texture_sRGB);
+ const bool ver_3_0 = (ver_2_1 &&
+ consts->GLSLVersion >= 130 &&
+ (consts->MaxSamples >= 4 || consts->FakeSWMSAA) &&
+ (api == API_OPENGL_CORE ||
+ extensions->ARB_color_buffer_float) &&
+ extensions->ARB_depth_buffer_float &&
+ extensions->ARB_half_float_vertex &&
+ extensions->ARB_map_buffer_range &&
+ extensions->ARB_shader_texture_lod &&
+ extensions->ARB_texture_float &&
+ extensions->ARB_texture_rg &&
+ extensions->ARB_texture_compression_rgtc &&
+ extensions->EXT_draw_buffers2 &&
+ extensions->ARB_framebuffer_object &&
+ extensions->EXT_framebuffer_sRGB &&
+ extensions->EXT_packed_float &&
+ extensions->EXT_texture_array &&
+ extensions->EXT_texture_shared_exponent &&
+ extensions->EXT_transform_feedback &&
+ extensions->NV_conditional_render);
+ const bool ver_3_1 = (ver_3_0 &&
+ consts->GLSLVersion >= 140 &&
+ extensions->ARB_draw_instanced &&
+ extensions->ARB_texture_buffer_object &&
+ extensions->ARB_uniform_buffer_object &&
+ extensions->EXT_texture_snorm &&
+ extensions->NV_primitive_restart &&
+ extensions->NV_texture_rectangle &&
+ consts->Program[MESA_SHADER_VERTEX].MaxTextureImageUnits >= 16);
+ const bool ver_3_2 = (ver_3_1 &&
+ consts->GLSLVersion >= 150 &&
+ extensions->ARB_depth_clamp &&
+ extensions->ARB_draw_elements_base_vertex &&
+ extensions->ARB_fragment_coord_conventions &&
+ extensions->EXT_provoking_vertex &&
+ extensions->ARB_seamless_cube_map &&
+ extensions->ARB_sync &&
+ extensions->ARB_texture_multisample &&
+ extensions->EXT_vertex_array_bgra);
+ const bool ver_3_3 = (ver_3_2 &&
+ consts->GLSLVersion >= 330 &&
+ extensions->ARB_blend_func_extended &&
+ extensions->ARB_explicit_attrib_location &&
+ extensions->ARB_instanced_arrays &&
+ extensions->ARB_occlusion_query2 &&
+ extensions->ARB_shader_bit_encoding &&
+ extensions->ARB_texture_rgb10_a2ui &&
+ extensions->ARB_timer_query &&
+ extensions->ARB_vertex_type_2_10_10_10_rev &&
+ extensions->EXT_texture_swizzle);
+ /* ARB_sampler_objects is always enabled in mesa */
+
+ const bool ver_4_0 = (ver_3_3 &&
+ consts->GLSLVersion >= 400 &&
+ extensions->ARB_draw_buffers_blend &&
+ extensions->ARB_draw_indirect &&
+ extensions->ARB_gpu_shader5 &&
+ extensions->ARB_gpu_shader_fp64 &&
+ extensions->ARB_sample_shading &&
+ false /*extensions->ARB_shader_subroutine*/ &&
+ extensions->ARB_tessellation_shader &&
+ extensions->ARB_texture_buffer_object_rgb32 &&
+ extensions->ARB_texture_cube_map_array &&
+ extensions->ARB_texture_query_lod &&
+ extensions->ARB_transform_feedback2 &&
+ extensions->ARB_transform_feedback3);
+ const bool ver_4_1 = (ver_4_0 &&
+ consts->GLSLVersion >= 410 &&
+ extensions->ARB_ES2_compatibility &&
+ extensions->ARB_shader_precision &&
+ extensions->ARB_vertex_attrib_64bit &&
+ extensions->ARB_viewport_array);
+ const bool ver_4_2 = (ver_4_1 &&
+ consts->GLSLVersion >= 420 &&
+ extensions->ARB_base_instance &&
+ extensions->ARB_conservative_depth &&
+ extensions->ARB_internalformat_query &&
+ extensions->ARB_shader_atomic_counters &&
+ extensions->ARB_shader_image_load_store &&
+ extensions->ARB_shading_language_420pack &&
+ extensions->ARB_shading_language_packing &&
+ extensions->ARB_texture_compression_bptc &&
+ extensions->ARB_transform_feedback_instanced);
if (ver_4_2) {
major = 4;
@@ -392,11 +386,11 @@ static GLuint
compute_version_es1(const struct gl_extensions *extensions)
{
/* OpenGL ES 1.0 is derived from OpenGL 1.3 */
- const GLboolean ver_1_0 = (extensions->ARB_texture_env_combine &&
- extensions->ARB_texture_env_dot3);
+ const bool ver_1_0 = (extensions->ARB_texture_env_combine &&
+ extensions->ARB_texture_env_dot3);
/* OpenGL ES 1.1 is derived from OpenGL 1.5 */
- const GLboolean ver_1_1 = (ver_1_0 &&
- extensions->EXT_point_parameters);
+ const bool ver_1_1 = (ver_1_0 &&
+ extensions->EXT_point_parameters);
if (ver_1_1) {
return 11;
@@ -411,34 +405,34 @@ static GLuint
compute_version_es2(const struct gl_extensions *extensions)
{
/* OpenGL ES 2.0 is derived from OpenGL 2.0 */
- const GLboolean ver_2_0 = (extensions->ARB_texture_cube_map &&
- extensions->EXT_blend_color &&
- extensions->EXT_blend_func_separate &&
- extensions->EXT_blend_minmax &&
- extensions->ARB_vertex_shader &&
- extensions->ARB_fragment_shader &&
- extensions->ARB_texture_non_power_of_two &&
- extensions->EXT_blend_equation_separate);
+ const bool ver_2_0 = (extensions->ARB_texture_cube_map &&
+ extensions->EXT_blend_color &&
+ extensions->EXT_blend_func_separate &&
+ extensions->EXT_blend_minmax &&
+ extensions->ARB_vertex_shader &&
+ extensions->ARB_fragment_shader &&
+ extensions->ARB_texture_non_power_of_two &&
+ extensions->EXT_blend_equation_separate);
/* FINISHME: This list isn't quite right. */
- const GLboolean ver_3_0 = (extensions->ARB_half_float_vertex &&
- extensions->ARB_internalformat_query &&
- extensions->ARB_map_buffer_range &&
- extensions->ARB_shader_texture_lod &&
- extensions->ARB_texture_float &&
- extensions->ARB_texture_rg &&
- extensions->ARB_depth_buffer_float &&
- extensions->EXT_draw_buffers2 &&
- /* extensions->ARB_framebuffer_object && */
- extensions->EXT_framebuffer_sRGB &&
- extensions->EXT_packed_float &&
- extensions->EXT_texture_array &&
- extensions->EXT_texture_shared_exponent &&
- extensions->EXT_transform_feedback &&
- extensions->ARB_draw_instanced &&
- extensions->ARB_uniform_buffer_object &&
- extensions->EXT_texture_snorm &&
- extensions->NV_primitive_restart &&
- extensions->OES_depth_texture_cube_map);
+ const bool ver_3_0 = (extensions->ARB_half_float_vertex &&
+ extensions->ARB_internalformat_query &&
+ extensions->ARB_map_buffer_range &&
+ extensions->ARB_shader_texture_lod &&
+ extensions->ARB_texture_float &&
+ extensions->ARB_texture_rg &&
+ extensions->ARB_depth_buffer_float &&
+ extensions->EXT_draw_buffers2 &&
+ /* extensions->ARB_framebuffer_object && */
+ extensions->EXT_framebuffer_sRGB &&
+ extensions->EXT_packed_float &&
+ extensions->EXT_texture_array &&
+ extensions->EXT_texture_shared_exponent &&
+ extensions->EXT_transform_feedback &&
+ extensions->ARB_draw_instanced &&
+ extensions->ARB_uniform_buffer_object &&
+ extensions->EXT_texture_snorm &&
+ extensions->NV_primitive_restart &&
+ extensions->OES_depth_texture_cube_map);
if (ver_3_0) {
return 30;
} else if (ver_2_0) {
diff --git a/mesalib/src/mesa/main/vtxfmt.c b/mesalib/src/mesa/main/vtxfmt.c
index fc0a01edf..d7ef7e278 100644
--- a/mesalib/src/mesa/main/vtxfmt.c
+++ b/mesalib/src/mesa/main/vtxfmt.c
@@ -206,6 +206,18 @@ install_vtxfmt(struct gl_context *ctx, struct _glapi_table *tab,
SET_VertexAttribP3uiv(tab, vfmt->VertexAttribP3uiv);
SET_VertexAttribP4uiv(tab, vfmt->VertexAttribP4uiv);
}
+
+ if (_mesa_is_desktop_gl(ctx)) {
+ SET_VertexAttribL1d(tab, vfmt->VertexAttribL1d);
+ SET_VertexAttribL2d(tab, vfmt->VertexAttribL2d);
+ SET_VertexAttribL3d(tab, vfmt->VertexAttribL3d);
+ SET_VertexAttribL4d(tab, vfmt->VertexAttribL4d);
+
+ SET_VertexAttribL1dv(tab, vfmt->VertexAttribL1dv);
+ SET_VertexAttribL2dv(tab, vfmt->VertexAttribL2dv);
+ SET_VertexAttribL3dv(tab, vfmt->VertexAttribL3dv);
+ SET_VertexAttribL4dv(tab, vfmt->VertexAttribL4dv);
+ }
}
diff --git a/mesalib/src/mesa/program/prog_statevars.c b/mesalib/src/mesa/program/prog_statevars.c
index 0c0c87faa..bdb335e4b 100644
--- a/mesalib/src/mesa/program/prog_statevars.c
+++ b/mesalib/src/mesa/program/prog_statevars.c
@@ -244,14 +244,14 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[],
{
/* state[1] is the texture unit */
const GLuint unit = (GLuint) state[1];
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
else
COPY_4V(value, ctx->Texture.Unit[unit].EnvColorUnclamped);
}
return;
case STATE_FOG_COLOR:
- if (_mesa_get_clamp_fragment_color(ctx))
+ if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer))
COPY_4V(value, ctx->Fog.Color);
else
COPY_4V(value, ctx->Fog.ColorUnclamped);
diff --git a/mesalib/src/mesa/program/prog_to_nir.c b/mesalib/src/mesa/program/prog_to_nir.c
index ff3d9f3be..6c5fa51ec 100644
--- a/mesalib/src/mesa/program/prog_to_nir.c
+++ b/mesalib/src/mesa/program/prog_to_nir.c
@@ -710,7 +710,7 @@ static const nir_op op_trans[MAX_OPCODE] = {
[OPCODE_DST] = 0,
[OPCODE_END] = 0,
[OPCODE_EX2] = nir_op_fexp2,
- [OPCODE_EXP] = nir_op_fexp,
+ [OPCODE_EXP] = 0,
[OPCODE_FLR] = nir_op_ffloor,
[OPCODE_FRC] = nir_op_ffract,
[OPCODE_LG2] = nir_op_flog2,
diff --git a/mesalib/src/mesa/program/program.c b/mesalib/src/mesa/program/program.c
index 4f28e2a3b..fb61f4d36 100644
--- a/mesalib/src/mesa/program/program.c
+++ b/mesalib/src/mesa/program/program.c
@@ -102,6 +102,8 @@ _mesa_init_program(struct gl_context *ctx)
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current,
NULL);
+ _mesa_reference_compprog(ctx, &ctx->ComputeProgram.Current, NULL);
+
/* XXX probably move this stuff */
ctx->ATIFragmentShader.Enabled = GL_FALSE;
ctx->ATIFragmentShader.Current = ctx->Shared->DefaultFragmentShader;
@@ -121,6 +123,7 @@ _mesa_free_program_data(struct gl_context *ctx)
_mesa_reference_fragprog(ctx, &ctx->FragmentProgram.Current, NULL);
_mesa_delete_shader_cache(ctx, ctx->FragmentProgram.Cache);
_mesa_reference_geomprog(ctx, &ctx->GeometryProgram.Current, NULL);
+ _mesa_reference_compprog(ctx, &ctx->ComputeProgram.Current, NULL);
/* XXX probably move this stuff */
if (ctx->ATIFragmentShader.Current) {
diff --git a/mesalib/src/mesa/program/program.h b/mesalib/src/mesa/program/program.h
index 0b0d1ac6f..2d92ab2f1 100644
--- a/mesalib/src/mesa/program/program.h
+++ b/mesalib/src/mesa/program/program.h
@@ -138,6 +138,15 @@ _mesa_reference_geomprog(struct gl_context *ctx,
(struct gl_program *) prog);
}
+static inline void
+_mesa_reference_compprog(struct gl_context *ctx,
+ struct gl_compute_program **ptr,
+ struct gl_compute_program *prog)
+{
+ _mesa_reference_program(ctx, (struct gl_program **) ptr,
+ (struct gl_program *) prog);
+}
+
extern struct gl_program *
_mesa_clone_program(struct gl_context *ctx, const struct gl_program *prog);
@@ -276,6 +285,19 @@ gl_geometry_program_const(const struct gl_program *prog)
}
+static inline struct gl_compute_program *
+gl_compute_program(struct gl_program *prog)
+{
+ return (struct gl_compute_program *) prog;
+}
+
+static inline const struct gl_compute_program *
+gl_compute_program_const(const struct gl_program *prog)
+{
+ return (const struct gl_compute_program *) prog;
+}
+
+
#ifdef __cplusplus
} /* extern "C" */
#endif
diff --git a/mesalib/src/mesa/state_tracker/st_atom_array.c b/mesalib/src/mesa/state_tracker/st_atom_array.c
index d4fb8b862..56b8019a3 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_array.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_array.c
@@ -44,7 +44,6 @@
#include "cso_cache/cso_context.h"
#include "util/u_math.h"
-
#include "main/bufferobj.h"
#include "main/glformats.h"
@@ -311,6 +310,18 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format,
return PIPE_FORMAT_NONE; /* silence compiler warning */
}
+static const struct gl_client_array *
+get_client_array(const struct st_vertex_program *vp,
+ const struct gl_client_array **arrays,
+ int attr)
+{
+ const GLuint mesaAttr = vp->index_to_input[attr];
+ /* st_program uses 0xffffffff to denote a double placeholder attribute */
+ if (mesaAttr == ST_DOUBLE_ATTRIB_PLACEHOLDER)
+ return NULL;
+ return arrays[mesaAttr];
+}
+
/**
* Examine the active arrays to determine if we have interleaved
* vertex arrays all living in one VBO, or all living in user space.
@@ -327,11 +338,16 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
GLboolean userSpaceBuffer = GL_FALSE;
for (attr = 0; attr < vpv->num_inputs; attr++) {
- const GLuint mesaAttr = vp->index_to_input[attr];
- const struct gl_client_array *array = arrays[mesaAttr];
- const struct gl_buffer_object *bufObj = array->BufferObj;
- const GLsizei stride = array->StrideB; /* in bytes */
+ const struct gl_client_array *array;
+ const struct gl_buffer_object *bufObj;
+ GLsizei stride;
+
+ array = get_client_array(vp, arrays, attr);
+ if (!array)
+ continue;
+ stride = array->StrideB; /* in bytes */
+ bufObj = array->BufferObj;
if (attr == 0) {
/* save info about the first array */
firstStride = stride;
@@ -358,6 +374,55 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
return GL_TRUE;
}
+static void init_velement(struct pipe_vertex_element *velement,
+ int src_offset, int format,
+ int instance_divisor, int vbo_index)
+{
+ velement->src_offset = src_offset;
+ velement->src_format = format;
+ velement->instance_divisor = instance_divisor;
+ velement->vertex_buffer_index = vbo_index;
+ assert(velement->src_format);
+}
+
+static void init_velement_lowered(struct st_context *st,
+ struct pipe_vertex_element *velements,
+ int src_offset, int format,
+ int instance_divisor, int vbo_index,
+ int nr_components, GLboolean doubles,
+ GLuint *attr_idx)
+{
+ int idx = *attr_idx;
+ if (doubles) {
+ int lower_format;
+
+ if (nr_components == 1)
+ lower_format = PIPE_FORMAT_R32G32_UINT;
+ else if (nr_components >= 2)
+ lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
+
+ init_velement(&velements[idx], src_offset,
+ lower_format, instance_divisor, vbo_index);
+ idx++;
+
+ if (nr_components > 2) {
+ if (nr_components == 3)
+ lower_format = PIPE_FORMAT_R32G32_UINT;
+ else if (nr_components >= 4)
+ lower_format = PIPE_FORMAT_R32G32B32A32_UINT;
+
+ init_velement(&velements[idx], src_offset + 4 * sizeof(float),
+ lower_format, instance_divisor, vbo_index);
+ idx++;
+ }
+ } else {
+ init_velement(&velements[idx], src_offset,
+ format, instance_divisor, vbo_index);
+ idx++;
+ }
+ *attr_idx = idx;
+}
+
/**
* Set up for drawing interleaved arrays that all live in one VBO
* or all live in user space.
@@ -365,13 +430,15 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
* \param velements returns vertex element info
*/
static boolean
-setup_interleaved_attribs(const struct st_vertex_program *vp,
+setup_interleaved_attribs(struct st_context *st,
+ const struct st_vertex_program *vp,
const struct st_vp_variant *vpv,
const struct gl_client_array **arrays,
struct pipe_vertex_buffer *vbuffer,
- struct pipe_vertex_element velements[])
+ struct pipe_vertex_element velements[],
+ unsigned *num_velements)
{
- GLuint attr;
+ GLuint attr, attr_idx;
const GLubyte *low_addr = NULL;
GLboolean usingVBO; /* all arrays in a VBO? */
struct gl_buffer_object *bufobj;
@@ -381,8 +448,10 @@ setup_interleaved_attribs(const struct st_vertex_program *vp,
* Init bufobj and stride.
*/
if (vpv->num_inputs) {
- const GLuint mesaAttr0 = vp->index_to_input[0];
- const struct gl_client_array *array = arrays[mesaAttr0];
+ const struct gl_client_array *array;
+
+ array = get_client_array(vp, arrays, 0);
+ assert(array);
/* Since we're doing interleaved arrays, we know there'll be at most
* one buffer object and the stride will be the same for all arrays.
@@ -394,7 +463,11 @@ setup_interleaved_attribs(const struct st_vertex_program *vp,
low_addr = arrays[vp->index_to_input[0]]->Ptr;
for (attr = 1; attr < vpv->num_inputs; attr++) {
- const GLubyte *start = arrays[vp->index_to_input[attr]]->Ptr;
+ const GLubyte *start;
+ array = get_client_array(vp, arrays, attr);
+ if (!array)
+ continue;
+ start = array->Ptr;
low_addr = MIN2(low_addr, start);
}
}
@@ -408,25 +481,33 @@ setup_interleaved_attribs(const struct st_vertex_program *vp,
/* are the arrays in user space? */
usingVBO = _mesa_is_bufferobj(bufobj);
+ attr_idx = 0;
for (attr = 0; attr < vpv->num_inputs; attr++) {
- const GLuint mesaAttr = vp->index_to_input[attr];
- const struct gl_client_array *array = arrays[mesaAttr];
- unsigned src_offset = (unsigned) (array->Ptr - low_addr);
+ const struct gl_client_array *array;
+ unsigned src_offset;
+ unsigned src_format;
+
+ array = get_client_array(vp, arrays, attr);
+ if (!array)
+ continue;
+ src_offset = (unsigned) (array->Ptr - low_addr);
assert(array->_ElementSize ==
_mesa_bytes_per_vertex_attrib(array->Size, array->Type));
- velements[attr].src_offset = src_offset;
- velements[attr].instance_divisor = array->InstanceDivisor;
- velements[attr].vertex_buffer_index = 0;
- velements[attr].src_format = st_pipe_vertex_format(array->Type,
- array->Size,
- array->Format,
- array->Normalized,
- array->Integer);
- assert(velements[attr].src_format);
+ src_format = st_pipe_vertex_format(array->Type,
+ array->Size,
+ array->Format,
+ array->Normalized,
+ array->Integer);
+
+ init_velement_lowered(st, velements, src_offset, src_format,
+ array->InstanceDivisor, 0,
+ array->Size, array->Doubles, &attr_idx);
}
+ *num_velements = attr_idx;
+
/*
* Return the vbuffer info and setup user-space attrib info, if needed.
*/
@@ -472,17 +553,25 @@ setup_non_interleaved_attribs(struct st_context *st,
const struct st_vp_variant *vpv,
const struct gl_client_array **arrays,
struct pipe_vertex_buffer vbuffer[],
- struct pipe_vertex_element velements[])
+ struct pipe_vertex_element velements[],
+ unsigned *num_velements)
{
struct gl_context *ctx = st->ctx;
- GLuint attr;
+ GLuint attr, attr_idx = 0;
for (attr = 0; attr < vpv->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
- const struct gl_client_array *array = arrays[mesaAttr];
- struct gl_buffer_object *bufobj = array->BufferObj;
- GLsizei stride = array->StrideB;
+ const struct gl_client_array *array;
+ struct gl_buffer_object *bufobj;
+ GLsizei stride;
+ unsigned src_format;
+ array = get_client_array(vp, arrays, attr);
+ if (!array)
+ continue;
+
+ stride = array->StrideB;
+ bufobj = array->BufferObj;
assert(array->_ElementSize ==
_mesa_bytes_per_vertex_attrib(array->Size, array->Type));
@@ -524,16 +613,19 @@ setup_non_interleaved_attribs(struct st_context *st,
/* common-case setup */
vbuffer[attr].stride = stride; /* in bytes */
- velements[attr].src_offset = 0;
- velements[attr].instance_divisor = array->InstanceDivisor;
- velements[attr].vertex_buffer_index = attr;
- velements[attr].src_format = st_pipe_vertex_format(array->Type,
- array->Size,
- array->Format,
- array->Normalized,
- array->Integer);
- assert(velements[attr].src_format);
+ src_format = st_pipe_vertex_format(array->Type,
+ array->Size,
+ array->Format,
+ array->Normalized,
+ array->Integer);
+
+ init_velement_lowered(st, velements, 0, src_format,
+ array->InstanceDivisor, attr,
+ array->Size, array->Doubles, &attr_idx);
+
}
+
+ *num_velements = attr_idx;
return TRUE;
}
@@ -563,25 +655,23 @@ static void update_array(struct st_context *st)
* Setup the vbuffer[] and velements[] arrays.
*/
if (is_interleaved_arrays(vp, vpv, arrays)) {
- if (!setup_interleaved_attribs(vp, vpv, arrays, vbuffer, velements)) {
+ if (!setup_interleaved_attribs(st, vp, vpv, arrays, vbuffer, velements, &num_velements)) {
st->vertex_array_out_of_memory = TRUE;
return;
}
num_vbuffers = 1;
- num_velements = vpv->num_inputs;
if (num_velements == 0)
num_vbuffers = 0;
}
else {
if (!setup_non_interleaved_attribs(st, vp, vpv, arrays, vbuffer,
- velements)) {
+ velements, &num_velements)) {
st->vertex_array_out_of_memory = TRUE;
return;
}
num_vbuffers = vpv->num_inputs;
- num_velements = vpv->num_inputs;
}
cso_set_vertex_buffers(st->cso_context, 0, num_vbuffers, vbuffer);
diff --git a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
index b195c55b3..ae883a253 100644
--- a/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/mesalib/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -134,7 +134,10 @@ update_framebuffer_state( struct st_context *st )
else {
strb = st_renderbuffer(fb->Attachment[BUFFER_STENCIL].Renderbuffer);
if (strb) {
- assert(strb->surface);
+ if (strb->is_rtt) {
+ /* rendering to a GL texture, may have to update surface */
+ st_update_renderbuffer_surface(st, strb);
+ }
pipe_surface_reference(&framebuffer->zsbuf, strb->surface);
update_framebuffer_size(framebuffer, strb->surface);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 296ea1e0d..0399eef72 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -842,7 +842,7 @@ void st_init_fbo_functions(struct dd_function_table *functions)
functions->NewFramebuffer = st_new_framebuffer;
functions->NewRenderbuffer = st_new_renderbuffer;
functions->BindFramebuffer = st_bind_framebuffer;
- functions->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
+ functions->FramebufferRenderbuffer = _mesa_FramebufferRenderbuffer_sw;
functions->RenderTexture = st_render_texture;
functions->FinishRenderTexture = st_finish_render_texture;
functions->ValidateFramebuffer = st_validate_framebuffer;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.c b/mesalib/src/mesa/state_tracker/st_cb_flush.c
index ca51eeee3..82affd2de 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_flush.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_flush.c
@@ -141,11 +141,44 @@ static void st_glFinish(struct gl_context *ctx)
}
-void st_init_flush_functions(struct dd_function_table *functions)
+/**
+ * Query information about GPU resets observed by this context
+ *
+ * Called via \c dd_function_table::GetGraphicsResetStatus.
+ */
+static GLenum
+st_get_graphics_reset_status(struct gl_context *ctx)
+{
+ struct st_context *st = st_context(ctx);
+ enum pipe_reset_status status;
+
+ status = st->pipe->get_device_reset_status(st->pipe);
+
+ switch (status) {
+ case PIPE_NO_RESET:
+ return GL_NO_ERROR;
+ case PIPE_GUILTY_CONTEXT_RESET:
+ return GL_GUILTY_CONTEXT_RESET_ARB;
+ case PIPE_INNOCENT_CONTEXT_RESET:
+ return GL_INNOCENT_CONTEXT_RESET_ARB;
+ case PIPE_UNKNOWN_CONTEXT_RESET:
+ return GL_UNKNOWN_CONTEXT_RESET_ARB;
+ default:
+ assert(0);
+ return GL_NO_ERROR;
+ }
+}
+
+
+void st_init_flush_functions(struct pipe_screen *screen,
+ struct dd_function_table *functions)
{
functions->Flush = st_glFlush;
functions->Finish = st_glFinish;
+ if (screen->get_param(screen, PIPE_CAP_DEVICE_RESET_STATUS_QUERY))
+ functions->GetGraphicsResetStatus = st_get_graphics_reset_status;
+
/* Windows opengl32.dll calls glFinish prior to every swapbuffers.
* This is unnecessary and degrades performance. Luckily we have some
* scope to work around this, as the externally-visible behaviour of
diff --git a/mesalib/src/mesa/state_tracker/st_cb_flush.h b/mesalib/src/mesa/state_tracker/st_cb_flush.h
index 84ffc63ae..f92dcd56b 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_flush.h
+++ b/mesalib/src/mesa/state_tracker/st_cb_flush.h
@@ -37,7 +37,8 @@ struct pipe_fence_handle;
struct st_context;
extern void
-st_init_flush_functions(struct dd_function_table *functions);
+st_init_flush_functions(struct pipe_screen *screen,
+ struct dd_function_table *functions);
extern void
st_flush(struct st_context *st,
diff --git a/mesalib/src/mesa/state_tracker/st_cb_perfmon.c b/mesalib/src/mesa/state_tracker/st_cb_perfmon.c
new file mode 100644
index 000000000..1bb5be397
--- /dev/null
+++ b/mesalib/src/mesa/state_tracker/st_cb_perfmon.c
@@ -0,0 +1,425 @@
+/*
+ * Copyright (C) 2013 Christoph Bumiller
+ * Copyright (C) 2015 Samuel Pitoiset
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * Performance monitoring counters interface to gallium.
+ */
+
+#include "st_debug.h"
+#include "st_context.h"
+#include "st_cb_bitmap.h"
+#include "st_cb_perfmon.h"
+
+#include "util/bitset.h"
+
+#include "pipe/p_context.h"
+#include "pipe/p_screen.h"
+#include "util/u_memory.h"
+
+/**
+ * Return a PIPE_QUERY_x type >= PIPE_QUERY_DRIVER_SPECIFIC, or -1 if
+ * the driver-specific query doesn't exist.
+ */
+static int
+find_query_type(struct pipe_screen *screen, const char *name)
+{
+ int num_queries;
+ int type = -1;
+ int i;
+
+ num_queries = screen->get_driver_query_info(screen, 0, NULL);
+ if (!num_queries)
+ return type;
+
+ for (i = 0; i < num_queries; i++) {
+ struct pipe_driver_query_info info;
+
+ if (!screen->get_driver_query_info(screen, i, &info))
+ continue;
+
+ if (!strncmp(info.name, name, strlen(name))) {
+ type = info.query_type;
+ break;
+ }
+ }
+ return type;
+}
+
+/**
+ * Return TRUE if the underlying driver expose GPU counters.
+ */
+static bool
+has_gpu_counters(struct pipe_screen *screen)
+{
+ int num_groups, gid;
+
+ num_groups = screen->get_driver_query_group_info(screen, 0, NULL);
+ for (gid = 0; gid < num_groups; gid++) {
+ struct pipe_driver_query_group_info group_info;
+
+ if (!screen->get_driver_query_group_info(screen, gid, &group_info))
+ continue;
+
+ if (group_info.type == PIPE_DRIVER_QUERY_GROUP_TYPE_GPU)
+ return true;
+ }
+ return false;
+}
+
+static bool
+init_perf_monitor(struct gl_context *ctx, struct gl_perf_monitor_object *m)
+{
+ struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
+ struct pipe_screen *screen = st_context(ctx)->pipe->screen;
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ int gid, cid;
+
+ st_flush_bitmap_cache(st_context(ctx));
+
+ /* Create a query for each active counter. */
+ for (gid = 0; gid < ctx->PerfMonitor.NumGroups; gid++) {
+ const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[gid];
+
+ if (m->ActiveGroups[gid] > g->MaxActiveCounters) {
+ /* Maximum number of counters reached. Cannot start the session. */
+ if (ST_DEBUG & DEBUG_MESA) {
+ debug_printf("Maximum number of counters reached. "
+ "Cannot start the session!\n");
+ }
+ return false;
+ }
+
+ for (cid = 0; cid < g->NumCounters; cid++) {
+ const struct gl_perf_monitor_counter *c = &g->Counters[cid];
+ struct st_perf_counter_object *cntr;
+ int query_type;
+
+ if (!BITSET_TEST(m->ActiveCounters[gid], cid))
+ continue;
+
+ query_type = find_query_type(screen, c->Name);
+ assert(query_type != -1);
+
+ cntr = CALLOC_STRUCT(st_perf_counter_object);
+ if (!cntr)
+ return false;
+
+ cntr->query = pipe->create_query(pipe, query_type, 0);
+ cntr->id = cid;
+ cntr->group_id = gid;
+
+ list_addtail(&cntr->list, &stm->active_counters);
+ }
+ }
+ return true;
+}
+
+static void
+reset_perf_monitor(struct st_perf_monitor_object *stm,
+ struct pipe_context *pipe)
+{
+ struct st_perf_counter_object *cntr, *tmp;
+
+ LIST_FOR_EACH_ENTRY_SAFE(cntr, tmp, &stm->active_counters, list) {
+ if (cntr->query)
+ pipe->destroy_query(pipe, cntr->query);
+ list_del(&cntr->list);
+ free(cntr);
+ }
+}
+
+static struct gl_perf_monitor_object *
+st_NewPerfMonitor(struct gl_context *ctx)
+{
+ struct st_perf_monitor_object *stq = ST_CALLOC_STRUCT(st_perf_monitor_object);
+ if (stq) {
+ list_inithead(&stq->active_counters);
+ return &stq->base;
+ }
+ return NULL;
+}
+
+static void
+st_DeletePerfMonitor(struct gl_context *ctx, struct gl_perf_monitor_object *m)
+{
+ struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+
+ reset_perf_monitor(stm, pipe);
+ FREE(stm);
+}
+
+static GLboolean
+st_BeginPerfMonitor(struct gl_context *ctx, struct gl_perf_monitor_object *m)
+{
+ struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_perf_counter_object *cntr;
+
+ if (LIST_IS_EMPTY(&stm->active_counters)) {
+ /* Create a query for each active counter before starting
+ * a new monitoring session. */
+ if (!init_perf_monitor(ctx, m))
+ goto fail;
+ }
+
+ /* Start the query for each active counter. */
+ LIST_FOR_EACH_ENTRY(cntr, &stm->active_counters, list) {
+ if (!pipe->begin_query(pipe, cntr->query))
+ goto fail;
+ }
+ return true;
+
+fail:
+ /* Failed to start the monitoring session. */
+ reset_perf_monitor(stm, pipe);
+ return false;
+}
+
+static void
+st_EndPerfMonitor(struct gl_context *ctx, struct gl_perf_monitor_object *m)
+{
+ struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_perf_counter_object *cntr;
+
+ /* Stop the query for each active counter. */
+ LIST_FOR_EACH_ENTRY(cntr, &stm->active_counters, list)
+ pipe->end_query(pipe, cntr->query);
+}
+
+static void
+st_ResetPerfMonitor(struct gl_context *ctx, struct gl_perf_monitor_object *m)
+{
+ struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+
+ if (!m->Ended)
+ st_EndPerfMonitor(ctx, m);
+
+ reset_perf_monitor(stm, pipe);
+
+ if (m->Active)
+ st_BeginPerfMonitor(ctx, m);
+}
+
+static GLboolean
+st_IsPerfMonitorResultAvailable(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m)
+{
+ struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_perf_counter_object *cntr;
+
+ if (LIST_IS_EMPTY(&stm->active_counters))
+ return false;
+
+ /* The result of a monitoring session is only available if the query of
+ * each active counter is idle. */
+ LIST_FOR_EACH_ENTRY(cntr, &stm->active_counters, list) {
+ union pipe_query_result result;
+ if (!pipe->get_query_result(pipe, cntr->query, FALSE, &result)) {
+ /* The query is busy. */
+ return false;
+ }
+ }
+ return true;
+}
+
+static void
+st_GetPerfMonitorResult(struct gl_context *ctx,
+ struct gl_perf_monitor_object *m,
+ GLsizei dataSize,
+ GLuint *data,
+ GLint *bytesWritten)
+{
+ struct st_perf_monitor_object *stm = st_perf_monitor_object(m);
+ struct pipe_context *pipe = st_context(ctx)->pipe;
+ struct st_perf_counter_object *cntr;
+
+ /* Copy data to the supplied array (data).
+ *
+ * The output data format is: <group ID, counter ID, value> for each
+ * active counter. The API allows counters to appear in any order.
+ */
+ GLsizei offset = 0;
+
+ /* Read query results for each active counter. */
+ LIST_FOR_EACH_ENTRY(cntr, &stm->active_counters, list) {
+ union pipe_query_result result = { 0 };
+ int gid, cid;
+ GLenum type;
+
+ cid = cntr->id;
+ gid = cntr->group_id;
+ type = ctx->PerfMonitor.Groups[gid].Counters[cid].Type;
+
+ if (!pipe->get_query_result(pipe, cntr->query, TRUE, &result))
+ continue;
+
+ data[offset++] = gid;
+ data[offset++] = cid;
+ switch (type) {
+ case GL_UNSIGNED_INT64_AMD:
+ *(uint64_t *)&data[offset] = result.u64;
+ offset += sizeof(uint64_t) / sizeof(GLuint);
+ break;
+ case GL_UNSIGNED_INT:
+ *(uint32_t *)&data[offset] = result.u32;
+ offset += sizeof(uint32_t) / sizeof(GLuint);
+ break;
+ case GL_FLOAT:
+ case GL_PERCENTAGE_AMD:
+ *(GLfloat *)&data[offset] = result.f;
+ offset += sizeof(GLfloat) / sizeof(GLuint);
+ break;
+ }
+ }
+
+ if (bytesWritten)
+ *bytesWritten = offset * sizeof(GLuint);
+}
+
+
+bool
+st_init_perfmon(struct st_context *st)
+{
+ struct gl_perf_monitor_state *perfmon = &st->ctx->PerfMonitor;
+ struct pipe_screen *screen = st->pipe->screen;
+ struct gl_perf_monitor_group *groups = NULL;
+ int num_counters, num_groups;
+ int gid, cid;
+
+ if (!screen->get_driver_query_info || !screen->get_driver_query_group_info)
+ return false;
+
+ if (!has_gpu_counters(screen)) {
+ /* According to the spec, GL_AMD_performance_monitor must only
+ * expose GPU counters. */
+ return false;
+ }
+
+ /* Get the number of available queries. */
+ num_counters = screen->get_driver_query_info(screen, 0, NULL);
+ if (!num_counters)
+ return false;
+
+ /* Get the number of available groups. */
+ num_groups = screen->get_driver_query_group_info(screen, 0, NULL);
+ if (num_groups)
+ groups = CALLOC(num_groups, sizeof(*groups));
+ if (!groups)
+ return false;
+
+ for (gid = 0; gid < num_groups; gid++) {
+ struct gl_perf_monitor_group *g = &groups[perfmon->NumGroups];
+ struct pipe_driver_query_group_info group_info;
+ struct gl_perf_monitor_counter *counters = NULL;
+
+ if (!screen->get_driver_query_group_info(screen, gid, &group_info))
+ continue;
+
+ if (group_info.type != PIPE_DRIVER_QUERY_GROUP_TYPE_GPU)
+ continue;
+
+ g->Name = group_info.name;
+ g->MaxActiveCounters = group_info.max_active_queries;
+ g->NumCounters = 0;
+ g->Counters = NULL;
+
+ if (group_info.num_queries)
+ counters = CALLOC(group_info.num_queries, sizeof(*counters));
+ if (!counters)
+ goto fail;
+
+ for (cid = 0; cid < num_counters; cid++) {
+ struct gl_perf_monitor_counter *c = &counters[g->NumCounters];
+ struct pipe_driver_query_info info;
+
+ if (!screen->get_driver_query_info(screen, cid, &info))
+ continue;
+ if (info.group_id != gid)
+ continue;
+
+ c->Name = info.name;
+ switch (info.type) {
+ case PIPE_DRIVER_QUERY_TYPE_UINT64:
+ c->Minimum.u64 = 0;
+ c->Maximum.u64 = info.max_value.u64 ? info.max_value.u64 : -1;
+ c->Type = GL_UNSIGNED_INT64_AMD;
+ break;
+ case PIPE_DRIVER_QUERY_TYPE_UINT:
+ c->Minimum.u32 = 0;
+ c->Maximum.u32 = info.max_value.u32 ? info.max_value.u32 : -1;
+ c->Type = GL_UNSIGNED_INT;
+ break;
+ case PIPE_DRIVER_QUERY_TYPE_FLOAT:
+ c->Minimum.f = 0.0;
+ c->Maximum.f = info.max_value.f ? info.max_value.f : -1;
+ c->Type = GL_FLOAT;
+ break;
+ case PIPE_DRIVER_QUERY_TYPE_PERCENTAGE:
+ c->Minimum.f = 0.0f;
+ c->Maximum.f = 100.0f;
+ c->Type = GL_PERCENTAGE_AMD;
+ break;
+ default:
+ unreachable("Invalid driver query type!");
+ }
+ g->NumCounters++;
+ }
+ g->Counters = counters;
+ perfmon->NumGroups++;
+ }
+ perfmon->Groups = groups;
+
+ return true;
+
+fail:
+ for (gid = 0; gid < num_groups; gid++)
+ FREE((void *)groups[gid].Counters);
+ FREE(groups);
+ return false;
+}
+
+void
+st_destroy_perfmon(struct st_context *st)
+{
+ struct gl_perf_monitor_state *perfmon = &st->ctx->PerfMonitor;
+ int gid;
+
+ for (gid = 0; gid < perfmon->NumGroups; gid++)
+ FREE((void *)perfmon->Groups[gid].Counters);
+ FREE((void *)perfmon->Groups);
+}
+
+void st_init_perfmon_functions(struct dd_function_table *functions)
+{
+ functions->NewPerfMonitor = st_NewPerfMonitor;
+ functions->DeletePerfMonitor = st_DeletePerfMonitor;
+ functions->BeginPerfMonitor = st_BeginPerfMonitor;
+ functions->EndPerfMonitor = st_EndPerfMonitor;
+ functions->ResetPerfMonitor = st_ResetPerfMonitor;
+ functions->IsPerfMonitorResultAvailable = st_IsPerfMonitorResultAvailable;
+ functions->GetPerfMonitorResult = st_GetPerfMonitorResult;
+}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_perfmon.h b/mesalib/src/mesa/state_tracker/st_cb_perfmon.h
new file mode 100644
index 000000000..13d3627de
--- /dev/null
+++ b/mesalib/src/mesa/state_tracker/st_cb_perfmon.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2013 Christoph Bumiller
+ * Copyright (C) 2015 Samuel Pitoiset
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef ST_CB_PERFMON_H
+#define ST_CB_PERFMON_H
+
+#include "util/list.h"
+
+/**
+ * Subclass of gl_perf_monitor_object
+ */
+struct st_perf_monitor_object
+{
+ struct gl_perf_monitor_object base;
+ struct list_head active_counters;
+};
+
+struct st_perf_counter_object
+{
+ struct list_head list;
+ struct pipe_query *query;
+ int id;
+ int group_id;
+};
+
+/**
+ * Cast wrapper
+ */
+static INLINE struct st_perf_monitor_object *
+st_perf_monitor_object(struct gl_perf_monitor_object *q)
+{
+ return (struct st_perf_monitor_object *)q;
+}
+
+bool
+st_init_perfmon(struct st_context *st);
+
+void
+st_destroy_perfmon(struct st_context *st);
+
+extern void
+st_init_perfmon_functions(struct dd_function_table *functions);
+
+#endif
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index 5fe132ac2..69e0f929d 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -51,6 +51,7 @@
#include "st_cb_fbo.h"
#include "st_cb_feedback.h"
#include "st_cb_msaa.h"
+#include "st_cb_perfmon.h"
#include "st_cb_program.h"
#include "st_cb_queryobj.h"
#include "st_cb_readpixels.h"
@@ -116,6 +117,7 @@ st_destroy_context_priv(struct st_context *st)
st_destroy_bitmap(st);
st_destroy_drawpix(st);
st_destroy_drawtex(st);
+ st_destroy_perfmon(st);
for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) {
for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) {
@@ -250,6 +252,12 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
st_init_extensions(st->pipe->screen, &ctx->Const,
&ctx->Extensions, &st->options, ctx->Mesa_DXTn);
+ if (st_init_perfmon(st)) {
+ /* GL_AMD_performance_monitor is only enabled when the underlying
+ * driver expose GPU hardware performance counters. */
+ ctx->Extensions.AMD_performance_monitor = GL_TRUE;
+ }
+
/* Enable shader-based fallbacks for ARB_color_buffer_float if needed. */
if (screen->get_param(screen, PIPE_CAP_VERTEX_COLOR_UNCLAMPED)) {
if (!screen->get_param(screen, PIPE_CAP_VERTEX_COLOR_CLAMPED)) {
@@ -313,7 +321,7 @@ struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
struct st_context *st;
memset(&funcs, 0, sizeof(funcs));
- st_init_driver_functions(&funcs);
+ st_init_driver_functions(pipe->screen, &funcs);
ctx = _mesa_create_context(api, visual, shareCtx, &funcs);
if (!ctx) {
@@ -393,7 +401,8 @@ void st_destroy_context( struct st_context *st )
}
-void st_init_driver_functions(struct dd_function_table *functions)
+void st_init_driver_functions(struct pipe_screen *screen,
+ struct dd_function_table *functions)
{
_mesa_init_shader_object_functions(functions);
_mesa_init_sampler_object_functions(functions);
@@ -414,13 +423,14 @@ void st_init_driver_functions(struct dd_function_table *functions)
st_init_fbo_functions(functions);
st_init_feedback_functions(functions);
st_init_msaa_functions(functions);
+ st_init_perfmon_functions(functions);
st_init_program_functions(functions);
st_init_query_functions(functions);
st_init_cond_render_functions(functions);
st_init_readpixels_functions(functions);
st_init_texture_functions(functions);
st_init_texture_barrier_functions(functions);
- st_init_flush_functions(functions);
+ st_init_flush_functions(screen, functions);
st_init_string_functions(functions);
st_init_viewport_functions(functions);
diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h
index 8a9504bb7..dac5a4b90 100644
--- a/mesalib/src/mesa/state_tracker/st_context.h
+++ b/mesalib/src/mesa/state_tracker/st_context.h
@@ -237,7 +237,8 @@ struct st_framebuffer
};
-extern void st_init_driver_functions(struct dd_function_table *functions);
+extern void st_init_driver_functions(struct pipe_screen *screen,
+ struct dd_function_table *functions);
void st_invalidate_state(struct gl_context * ctx, GLuint new_state);
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 82e4a3009..23a45883d 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -650,6 +650,12 @@ void st_init_extensions(struct pipe_screen *screen,
ARRAY_SIZE(vertex_mapping), PIPE_BUFFER,
PIPE_BIND_VERTEX_BUFFER);
+ /* ARB_direct_state_access requires OpenGL 2.0. Assume that all drivers
+ * that support NPOT textures are able to support GL 2.0.
+ */
+ if (extensions->ARB_texture_non_power_of_two)
+ extensions->ARB_direct_state_access = GL_TRUE;
+
if (extensions->ARB_stencil_texturing)
extensions->ARB_texture_stencil8 = GL_TRUE;
@@ -909,6 +915,8 @@ void st_init_extensions(struct pipe_screen *screen,
if (screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
PIPE_SHADER_CAP_DOUBLES) &&
screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
- PIPE_SHADER_CAP_DOUBLES))
+ PIPE_SHADER_CAP_DOUBLES)) {
extensions->ARB_gpu_shader_fp64 = GL_TRUE;
+ extensions->ARB_vertex_attrib_64bit = GL_TRUE;
+ }
}
diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c
index 181465dd8..db7b5b71d 100644
--- a/mesalib/src/mesa/state_tracker/st_format.c
+++ b/mesalib/src/mesa/state_tracker/st_format.c
@@ -991,7 +991,7 @@ static const struct format_mapping format_map[] = {
{
{ GL_RGB10, 0 },
{ PIPE_FORMAT_B10G10R10X2_UNORM, PIPE_FORMAT_B10G10R10A2_UNORM,
- DEFAULT_RGB_FORMATS }
+ PIPE_FORMAT_R10G10B10A2_UNORM, DEFAULT_RGB_FORMATS }
},
{
{ GL_RGB10_A2, 0 },
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 93671ba9c..f0f2a77d0 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -88,6 +88,7 @@ public:
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
+ this->double_reg2 = false;
}
st_src_reg(gl_register_file file, int index, int type)
@@ -101,6 +102,7 @@ public:
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
+ this->double_reg2 = false;
}
st_src_reg(gl_register_file file, int index, int type, int index2D)
@@ -114,6 +116,7 @@ public:
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
+ this->double_reg2 = false;
}
st_src_reg()
@@ -127,6 +130,7 @@ public:
this->reladdr = NULL;
this->reladdr2 = NULL;
this->has_index2 = false;
+ this->double_reg2 = false;
}
explicit st_src_reg(st_dst_reg reg);
@@ -141,6 +145,11 @@ public:
st_src_reg *reladdr;
st_src_reg *reladdr2;
bool has_index2;
+ /*
+ * Is this the second half of a double register pair?
+ * currently used for input mapping only.
+ */
+ bool double_reg2;
};
class st_dst_reg {
@@ -197,6 +206,7 @@ st_src_reg::st_src_reg(st_dst_reg reg)
this->index2D = 0;
this->reladdr2 = NULL;
this->has_index2 = false;
+ this->double_reg2 = false;
}
st_dst_reg::st_dst_reg(st_src_reg reg)
@@ -677,8 +687,10 @@ glsl_to_tgsi_visitor::emit(ir_instruction *ir, unsigned op,
if (dinst->src[j].type == GLSL_TYPE_DOUBLE) {
dinst->src[j].index = initial_src_idx[j];
- if (swz > 1)
+ if (swz > 1) {
+ dinst->src[j].double_reg2 = true;
dinst->src[j].index++;
+ }
if (swz & 1)
dinst->src[j].swizzle = MAKE_SWIZZLE4(SWIZZLE_Z, SWIZZLE_W, SWIZZLE_Z, SWIZZLE_W);
@@ -1941,7 +1953,7 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir)
break;
case ir_unop_i2b:
if (native_integers)
- emit(ir, TGSI_OPCODE_INEG, result_dst, op[0]);
+ emit(ir, TGSI_OPCODE_USNE, result_dst, op[0], st_src_reg_for_int(0));
else
emit(ir, TGSI_OPCODE_SNE, result_dst, op[0], st_src_reg_for_float(0.0));
break;
@@ -2611,6 +2623,7 @@ glsl_to_tgsi_visitor::visit(ir_assignment *ir)
assert(!ir->lhs->type->is_scalar() && !ir->lhs->type->is_vector());
l.writemask = WRITEMASK_XYZW;
} else if (ir->lhs->type->is_scalar() &&
+ !ir->lhs->type->is_double() &&
ir->lhs->variable_referenced()->data.mode == ir_var_shader_out) {
/* FINISHME: This hack makes writing to gl_FragDepth, which lives in the
* FINISHME: W component of fragment shader output zero, work correctly.
@@ -3704,6 +3717,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
} else {
if (first->src[0].file != copy_chan->src[0].file ||
first->src[0].index != copy_chan->src[0].index ||
+ first->src[0].double_reg2 != copy_chan->src[0].double_reg2 ||
first->src[0].index2D != copy_chan->src[0].index2D) {
good = false;
break;
@@ -3719,6 +3733,7 @@ glsl_to_tgsi_visitor::copy_propagate(void)
inst->src[r].index = first->src[0].index;
inst->src[r].index2D = first->src[0].index2D;
inst->src[r].has_index2 = first->src[0].has_index2;
+ inst->src[r].double_reg2 = first->src[0].double_reg2;
int swizzle = 0;
for (int i = 0; i < 4; i++) {
@@ -4551,6 +4566,9 @@ dst_register(struct st_translate *t,
static struct ureg_src
src_register(struct st_translate *t, const st_src_reg *reg)
{
+ int index = reg->index;
+ int double_reg2 = reg->double_reg2 ? 1 : 0;
+
switch(reg->file) {
case PROGRAM_UNDEFINED:
return ureg_imm4f(t->ureg, 0, 0, 0, 0);
@@ -4576,8 +4594,12 @@ src_register(struct st_translate *t, const st_src_reg *reg)
return t->immediates[reg->index];
case PROGRAM_INPUT:
- assert(t->inputMapping[reg->index] < ARRAY_SIZE(t->inputs));
- return t->inputs[t->inputMapping[reg->index]];
+ /* GLSL inputs are 64-bit containers, so we have to
+ * map back to the original index and add the offset after
+ * mapping. */
+ index -= double_reg2;
+ assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs));
+ return t->inputs[t->inputMapping[index] + double_reg2];
case PROGRAM_OUTPUT:
assert(t->outputMapping[reg->index] < ARRAY_SIZE(t->outputs));
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index 840f76a13..0376954f7 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -680,6 +680,10 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
if (attribs->flags & ST_CONTEXT_FLAG_FORWARD_COMPATIBLE)
st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT;
+ if (attribs->flags & ST_CONTEXT_FLAG_ROBUST_ACCESS)
+ st->ctx->Const.ContextFlags |= GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB;
+ if (attribs->flags & ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED)
+ st->ctx->Const.ResetStrategy = GL_LOSE_CONTEXT_ON_RESET_ARB;
/* need to perform version check */
if (attribs->major > 1 || attribs->minor > 0) {
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index d93b3c7bc..a9110d3c6 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -194,6 +194,11 @@ st_prepare_vertex_program(struct gl_context *ctx,
stvp->input_to_index[attr] = stvp->num_inputs;
stvp->index_to_input[stvp->num_inputs] = attr;
stvp->num_inputs++;
+ if ((stvp->Base.Base.DoubleInputsRead & BITFIELD64_BIT(attr)) != 0) {
+ /* add placeholder for second part of a double attribute */
+ stvp->index_to_input[stvp->num_inputs] = ST_DOUBLE_ATTRIB_PLACEHOLDER;
+ stvp->num_inputs++;
+ }
}
}
/* bit of a hack, presetup potentially unused edgeflag input */
diff --git a/mesalib/src/mesa/state_tracker/st_program.h b/mesalib/src/mesa/state_tracker/st_program.h
index b2c86faec..a2c56062d 100644
--- a/mesalib/src/mesa/state_tracker/st_program.h
+++ b/mesalib/src/mesa/state_tracker/st_program.h
@@ -45,6 +45,7 @@
extern "C" {
#endif
+#define ST_DOUBLE_ATTRIB_PLACEHOLDER 0xffffffff
/** Fragment program variant key */
struct st_fp_variant_key
diff --git a/mesalib/src/mesa/swrast/s_drawpix.c b/mesalib/src/mesa/swrast/s_drawpix.c
index bf427266c..fb677ee1b 100644
--- a/mesalib/src/mesa/swrast/s_drawpix.c
+++ b/mesalib/src/mesa/swrast/s_drawpix.c
@@ -448,14 +448,34 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
{
const GLbitfield interpMask = span.interpMask;
const GLbitfield arrayMask = span.arrayMask;
- const GLint srcStride
- = _mesa_image_row_stride(unpack, width, format, type);
GLint skipPixels = 0;
/* use span array for temp color storage */
GLfloat *rgba = (GLfloat *) span.array->attribs[VARYING_SLOT_COL0];
void *tempImage = NULL;
- if (unpack->SwapBytes) {
+ /* We have to deal with GL_COLOR_INDEX manually because
+ * _mesa_format_convert does not handle this format. So what we do here is
+ * convert it to RGBA ubyte first and then convert from that to dst as
+ * usual.
+ */
+ if (format == GL_COLOR_INDEX) {
+ /* This will handle byte swapping and transferops if needed */
+ tempImage =
+ _mesa_unpack_color_index_to_rgba_ubyte(ctx, 2,
+ pixels, format, type,
+ width, height, 1,
+ unpack,
+ transferOps);
+ if (!tempImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
+ return;
+ }
+
+ transferOps = 0;
+ pixels = tempImage;
+ format = GL_RGBA;
+ type = GL_UNSIGNED_BYTE;
+ } else if (unpack->SwapBytes) {
/* We have to handle byte-swapping scenarios before calling
* _mesa_format_convert
*/
@@ -476,6 +496,9 @@ draw_rgba_pixels( struct gl_context *ctx, GLint x, GLint y,
}
}
+ const GLint srcStride
+ = _mesa_image_row_stride(unpack, width, format, type);
+
/* if the span is wider than SWRAST_MAX_WIDTH we have to do it in chunks */
while (skipPixels < width) {
const GLint spanWidth = MIN2(width - skipPixels, SWRAST_MAX_WIDTH);
diff --git a/mesalib/src/mesa/swrast/s_texrender.c b/mesalib/src/mesa/swrast/s_texrender.c
index fa853c919..4e41b3b72 100644
--- a/mesalib/src/mesa/swrast/s_texrender.c
+++ b/mesalib/src/mesa/swrast/s_texrender.c
@@ -72,7 +72,7 @@ update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
* \param fb the framebuffer object the texture is being bound to
* \param att the fb attachment point of the texture
*
- * \sa _mesa_framebuffer_renderbuffer
+ * \sa _mesa_FramebufferRenderbuffer_sw
*/
void
_swrast_render_texture(struct gl_context *ctx,
diff --git a/mesalib/src/mesa/vbo/vbo_attrib_tmp.h b/mesalib/src/mesa/vbo/vbo_attrib_tmp.h
index 17e057836..e73b8fb5f 100644
--- a/mesalib/src/mesa/vbo/vbo_attrib_tmp.h
+++ b/mesalib/src/mesa/vbo/vbo_attrib_tmp.h
@@ -31,14 +31,16 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* ATTR */
#define ATTRI( A, N, V0, V1, V2, V3 ) \
- ATTR_UNION(A, N, GL_INT, INT_AS_UNION(V0), INT_AS_UNION(V1), \
+ ATTR_UNION(A, N, GL_INT, fi_type, INT_AS_UNION(V0), INT_AS_UNION(V1), \
INT_AS_UNION(V2), INT_AS_UNION(V3))
#define ATTRUI( A, N, V0, V1, V2, V3 ) \
- ATTR_UNION(A, N, GL_UNSIGNED_INT, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \
+ ATTR_UNION(A, N, GL_UNSIGNED_INT, fi_type, UINT_AS_UNION(V0), UINT_AS_UNION(V1), \
UINT_AS_UNION(V2), UINT_AS_UNION(V3))
#define ATTRF( A, N, V0, V1, V2, V3 ) \
- ATTR_UNION(A, N, GL_FLOAT, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\
+ ATTR_UNION(A, N, GL_FLOAT, fi_type, FLOAT_AS_UNION(V0), FLOAT_AS_UNION(V1),\
FLOAT_AS_UNION(V2), FLOAT_AS_UNION(V3))
+#define ATTRD( A, N, V0, V1, V2, V3 ) \
+ ATTR_UNION(A, N, GL_DOUBLE, double, V0, V1, V2, V3)
/* float */
@@ -232,6 +234,19 @@ static inline float conv_i2_to_norm_float(const struct gl_context *ctx, int i2)
ERROR(GL_INVALID_VALUE); \
} while(0)
+
+/* Doubles */
+#define ATTR1DV( A, V ) ATTRD( A, 1, (V)[0], 0, 0, 1 )
+#define ATTR2DV( A, V ) ATTRD( A, 2, (V)[0], (V)[1], 0, 1 )
+#define ATTR3DV( A, V ) ATTRD( A, 3, (V)[0], (V)[1], (V)[2], 1 )
+#define ATTR4DV( A, V ) ATTRD( A, 4, (V)[0], (V)[1], (V)[2], (V)[3] )
+
+#define ATTR1D( A, X ) ATTRD( A, 1, X, 0, 0, 1 )
+#define ATTR2D( A, X, Y ) ATTRD( A, 2, X, Y, 0, 1 )
+#define ATTR3D( A, X, Y, Z ) ATTRD( A, 3, X, Y, Z, 1 )
+#define ATTR4D( A, X, Y, Z, W ) ATTRD( A, 4, X, Y, Z, W )
+
+
static void GLAPIENTRY
TAG(Vertex2f)(GLfloat x, GLfloat y)
{
@@ -1190,6 +1205,104 @@ TAG(VertexAttribP4uiv)(GLuint index, GLenum type, GLboolean normalized,
}
+
+static void GLAPIENTRY
+TAG(VertexAttribL1d)(GLuint index, GLdouble x)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR1D(0, x);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR1D(VBO_ATTRIB_GENERIC0 + index, x);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+static void GLAPIENTRY
+TAG(VertexAttribL1dv)(GLuint index, const GLdouble * v)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR1DV(0, v);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR1DV(VBO_ATTRIB_GENERIC0 + index, v);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+static void GLAPIENTRY
+TAG(VertexAttribL2d)(GLuint index, GLdouble x, GLdouble y)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR2D(0, x, y);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR2D(VBO_ATTRIB_GENERIC0 + index, x, y);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+static void GLAPIENTRY
+TAG(VertexAttribL2dv)(GLuint index, const GLdouble * v)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR2DV(0, v);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR2DV(VBO_ATTRIB_GENERIC0 + index, v);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+static void GLAPIENTRY
+TAG(VertexAttribL3d)(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR3D(0, x, y, z);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR3D(VBO_ATTRIB_GENERIC0 + index, x, y, z);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+static void GLAPIENTRY
+TAG(VertexAttribL3dv)(GLuint index, const GLdouble * v)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR3DV(0, v);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR3DV(VBO_ATTRIB_GENERIC0 + index, v);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+static void GLAPIENTRY
+TAG(VertexAttribL4d)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR4D(0, x, y, z, w);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR4D(VBO_ATTRIB_GENERIC0 + index, x, y, z, w);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+static void GLAPIENTRY
+TAG(VertexAttribL4dv)(GLuint index, const GLdouble * v)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index == 0 && _mesa_attr_zero_aliases_vertex(ctx))
+ ATTR4DV(0, v);
+ else if (index < MAX_VERTEX_GENERIC_ATTRIBS)
+ ATTR4DV(VBO_ATTRIB_GENERIC0 + index, v);
+ else
+ ERROR(GL_INVALID_VALUE);
+}
+
+
#undef ATTR1FV
#undef ATTR2FV
#undef ATTR3FV
diff --git a/mesalib/src/mesa/vbo/vbo_context.h b/mesalib/src/mesa/vbo/vbo_context.h
index 6099b56e6..a376efe34 100644
--- a/mesalib/src/mesa/vbo/vbo_context.h
+++ b/mesalib/src/mesa/vbo/vbo_context.h
@@ -146,6 +146,7 @@ vbo_attrtype_to_integer_flag(GLenum format)
{
switch (format) {
case GL_FLOAT:
+ case GL_DOUBLE:
return GL_FALSE;
case GL_INT:
case GL_UNSIGNED_INT:
@@ -156,6 +157,22 @@ vbo_attrtype_to_integer_flag(GLenum format)
}
}
+static inline GLboolean
+vbo_attrtype_to_double_flag(GLenum format)
+{
+ switch (format) {
+ case GL_FLOAT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return GL_FALSE;
+ case GL_DOUBLE:
+ return GL_TRUE;
+ default:
+ assert(0);
+ return GL_FALSE;
+ }
+}
+
/**
* Return default component values for the given format.
* The return type is an array of fi_types, because that's how we declare
diff --git a/mesalib/src/mesa/vbo/vbo_exec_api.c b/mesalib/src/mesa/vbo/vbo_exec_api.c
index 48680ec88..138cd6051 100644
--- a/mesalib/src/mesa/vbo/vbo_exec_api.c
+++ b/mesalib/src/mesa/vbo/vbo_exec_api.c
@@ -159,27 +159,36 @@ static void vbo_exec_copy_to_current( struct vbo_exec_context *exec )
* ctx->Current.Attrib and ctx->Light.Material.Attrib arrays.
*/
GLfloat *current = (GLfloat *)vbo->currval[i].Ptr;
- fi_type tmp[4];
+ fi_type tmp[8]; /* space for doubles */
+ int dmul = exec->vtx.attrtype[i] == GL_DOUBLE ? 2 : 1;
+
+ if (exec->vtx.attrtype[i] == GL_DOUBLE) {
+ memset(tmp, 0, sizeof(tmp));
+ memcpy(tmp, exec->vtx.attrptr[i], exec->vtx.attrsz[i] * sizeof(GLfloat));
+ } else {
+ COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
+ exec->vtx.attrsz[i],
+ exec->vtx.attrptr[i],
+ exec->vtx.attrtype[i]);
+ }
- COPY_CLEAN_4V_TYPE_AS_UNION(tmp,
- exec->vtx.attrsz[i],
- exec->vtx.attrptr[i],
- exec->vtx.attrtype[i]);
-
if (exec->vtx.attrtype[i] != vbo->currval[i].Type ||
- memcmp(current, tmp, sizeof(tmp)) != 0) {
- memcpy(current, tmp, sizeof(tmp));
+ memcmp(current, tmp, 4 * sizeof(GLfloat) * dmul) != 0) {
+ memcpy(current, tmp, 4 * sizeof(GLfloat) * dmul);
/* Given that we explicitly state size here, there is no need
* for the COPY_CLEAN above, could just copy 16 bytes and be
* done. The only problem is when Mesa accesses ctx->Current
* directly.
*/
- vbo->currval[i].Size = exec->vtx.attrsz[i];
- vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat);
+ /* Size here is in components - not bytes */
+ vbo->currval[i].Size = exec->vtx.attrsz[i] / dmul;
+ vbo->currval[i]._ElementSize = vbo->currval[i].Size * sizeof(GLfloat) * dmul;
vbo->currval[i].Type = exec->vtx.attrtype[i];
vbo->currval[i].Integer =
vbo_attrtype_to_integer_flag(exec->vtx.attrtype[i]);
+ vbo->currval[i].Doubles =
+ vbo_attrtype_to_double_flag(exec->vtx.attrtype[i]);
/* This triggers rather too much recalculation of Mesa state
* that doesn't get used (eg light positions).
@@ -214,13 +223,17 @@ vbo_exec_copy_from_current(struct vbo_exec_context *exec)
GLint i;
for (i = VBO_ATTRIB_POS + 1; i < VBO_ATTRIB_MAX; i++) {
- const fi_type *current = (fi_type *) vbo->currval[i].Ptr;
- switch (exec->vtx.attrsz[i]) {
- case 4: exec->vtx.attrptr[i][3] = current[3];
- case 3: exec->vtx.attrptr[i][2] = current[2];
- case 2: exec->vtx.attrptr[i][1] = current[1];
- case 1: exec->vtx.attrptr[i][0] = current[0];
- break;
+ if (exec->vtx.attrtype[i] == GL_DOUBLE) {
+ memcpy(exec->vtx.attrptr[i], vbo->currval[i].Ptr, exec->vtx.attrsz[i] * sizeof(GLfloat));
+ } else {
+ const fi_type *current = (fi_type *) vbo->currval[i].Ptr;
+ switch (exec->vtx.attrsz[i]) {
+ case 4: exec->vtx.attrptr[i][3] = current[3];
+ case 3: exec->vtx.attrptr[i][2] = current[2];
+ case 2: exec->vtx.attrptr[i][1] = current[1];
+ case 1: exec->vtx.attrptr[i][0] = current[0];
+ break;
+ }
}
}
}
@@ -364,11 +377,11 @@ vbo_exec_wrap_upgrade_vertex(struct vbo_exec_context *exec,
* glTexCoord4f() call. We promote the array from size=2 to size=4.
*/
static void
-vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize)
+vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize, GLenum newType)
{
struct vbo_exec_context *exec = &vbo_context(ctx)->exec;
- if (newSize > exec->vtx.attrsz[attr]) {
+ if (newSize > exec->vtx.attrsz[attr] || newType != exec->vtx.attrtype[attr]) {
/* New size is larger. Need to flush existing vertices and get
* an enlarged vertex format.
*/
@@ -401,18 +414,19 @@ vbo_exec_fixup_vertex(struct gl_context *ctx, GLuint attr, GLuint newSize)
* This macro is used to implement all the glVertex, glColor, glTexCoord,
* glVertexAttrib, etc functions.
*/
-#define ATTR_UNION( A, N, T, V0, V1, V2, V3 ) \
+#define ATTR_UNION( A, N, T, C, V0, V1, V2, V3 ) \
do { \
struct vbo_exec_context *exec = &vbo_context(ctx)->exec; \
- \
+ int sz = (sizeof(C) / sizeof(GLfloat)); \
if (unlikely(!(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT))) \
ctx->Driver.BeginVertices( ctx ); \
- \
- if (unlikely(exec->vtx.active_sz[A] != N)) \
- vbo_exec_fixup_vertex(ctx, A, N); \
- \
+ \
+ if (unlikely(exec->vtx.active_sz[A] != N * sz) || \
+ unlikely(exec->vtx.attrtype[A] != T)) \
+ vbo_exec_fixup_vertex(ctx, A, N * sz, T); \
+ \
{ \
- fi_type *dest = exec->vtx.attrptr[A]; \
+ C *dest = (C *)exec->vtx.attrptr[A]; \
if (N>0) dest[0] = V0; \
if (N>1) dest[1] = V1; \
if (N>2) dest[2] = V2; \
@@ -438,7 +452,6 @@ do { \
} \
} while (0)
-
#define ERROR(err) _mesa_error( ctx, err, __func__ )
#define TAG(x) vbo_##x
@@ -575,7 +588,7 @@ static void GLAPIENTRY vbo_exec_EvalCoord1f( GLfloat u )
for (i = 0; i <= VBO_ATTRIB_TEX7; i++) {
if (exec->eval.map1[i].map)
if (exec->vtx.active_sz[i] != exec->eval.map1[i].sz)
- vbo_exec_fixup_vertex( ctx, i, exec->eval.map1[i].sz );
+ vbo_exec_fixup_vertex( ctx, i, exec->eval.map1[i].sz, GL_FLOAT );
}
}
@@ -602,12 +615,12 @@ static void GLAPIENTRY vbo_exec_EvalCoord2f( GLfloat u, GLfloat v )
for (i = 0; i <= VBO_ATTRIB_TEX7; i++) {
if (exec->eval.map2[i].map)
if (exec->vtx.active_sz[i] != exec->eval.map2[i].sz)
- vbo_exec_fixup_vertex( ctx, i, exec->eval.map2[i].sz );
+ vbo_exec_fixup_vertex( ctx, i, exec->eval.map2[i].sz, GL_FLOAT );
}
if (ctx->Eval.AutoNormal)
if (exec->vtx.active_sz[VBO_ATTRIB_NORMAL] != 3)
- vbo_exec_fixup_vertex( ctx, VBO_ATTRIB_NORMAL, 3 );
+ vbo_exec_fixup_vertex( ctx, VBO_ATTRIB_NORMAL, 3, GL_FLOAT );
}
memcpy( exec->vtx.copied.buffer, exec->vtx.vertex,
@@ -968,6 +981,16 @@ static void vbo_exec_vtxfmt_init( struct vbo_exec_context *exec )
vfmt->VertexAttribP3uiv = vbo_VertexAttribP3uiv;
vfmt->VertexAttribP4ui = vbo_VertexAttribP4ui;
vfmt->VertexAttribP4uiv = vbo_VertexAttribP4uiv;
+
+ vfmt->VertexAttribL1d = vbo_VertexAttribL1d;
+ vfmt->VertexAttribL2d = vbo_VertexAttribL2d;
+ vfmt->VertexAttribL3d = vbo_VertexAttribL3d;
+ vfmt->VertexAttribL4d = vbo_VertexAttribL4d;
+
+ vfmt->VertexAttribL1dv = vbo_VertexAttribL1dv;
+ vfmt->VertexAttribL2dv = vbo_VertexAttribL2dv;
+ vfmt->VertexAttribL3dv = vbo_VertexAttribL3dv;
+ vfmt->VertexAttribL4dv = vbo_VertexAttribL4dv;
}
diff --git a/mesalib/src/mesa/vbo/vbo_save_api.c b/mesalib/src/mesa/vbo/vbo_save_api.c
index 5927beeb3..29de3d38a 100644
--- a/mesalib/src/mesa/vbo/vbo_save_api.c
+++ b/mesalib/src/mesa/vbo/vbo_save_api.c
@@ -772,7 +772,7 @@ _save_reset_vertex(struct gl_context *ctx)
* 3f version won't otherwise set color[3] to 1.0 -- this is the job
* of the chooser function when switching between Color4f and Color3f.
*/
-#define ATTR_UNION(A, N, T, V0, V1, V2, V3) \
+#define ATTR_UNION(A, N, T, C, V0, V1, V2, V3) \
do { \
struct vbo_save_context *save = &vbo_context(ctx)->save; \
\
@@ -780,7 +780,7 @@ do { \
save_fixup_vertex(ctx, A, N); \
\
{ \
- fi_type *dest = save->attrptr[A]; \
+ C *dest = (C *)save->attrptr[A]; \
if (N>0) dest[0] = V0; \
if (N>1) dest[1] = V1; \
if (N>2) dest[2] = V2; \
@@ -1372,6 +1372,16 @@ _save_vtxfmt_init(struct gl_context *ctx)
vfmt->VertexAttribP3uiv = _save_VertexAttribP3uiv;
vfmt->VertexAttribP4uiv = _save_VertexAttribP4uiv;
+ vfmt->VertexAttribL1d = _save_VertexAttribL1d;
+ vfmt->VertexAttribL2d = _save_VertexAttribL2d;
+ vfmt->VertexAttribL3d = _save_VertexAttribL3d;
+ vfmt->VertexAttribL4d = _save_VertexAttribL4d;
+
+ vfmt->VertexAttribL1dv = _save_VertexAttribL1dv;
+ vfmt->VertexAttribL2dv = _save_VertexAttribL2dv;
+ vfmt->VertexAttribL3dv = _save_VertexAttribL3dv;
+ vfmt->VertexAttribL4dv = _save_VertexAttribL4dv;
+
/* This will all require us to fallback to saving the list as opcodes:
*/
vfmt->CallList = _save_CallList;
diff --git a/mesalib/src/mesa/vbo/vbo_split_copy.c b/mesalib/src/mesa/vbo/vbo_split_copy.c
index d1107dd84..7b1e20b18 100644
--- a/mesalib/src/mesa/vbo/vbo_split_copy.c
+++ b/mesalib/src/mesa/vbo/vbo_split_copy.c
@@ -533,6 +533,7 @@ replay_init( struct copy_context *copy )
dst->Enabled = GL_TRUE;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
+ dst->Doubles = src->Doubles;
dst->BufferObj = ctx->Shared->NullBufferObj;
dst->_ElementSize = src->_ElementSize;
diff --git a/mesalib/src/util/Makefile.sources b/mesalib/src/util/Makefile.sources
index 3e0d02bad..dc5593918 100644
--- a/mesalib/src/util/Makefile.sources
+++ b/mesalib/src/util/Makefile.sources
@@ -7,6 +7,7 @@ MESA_UTIL_FILES := \
format_srgb.h \
hash_table.c \
hash_table.h \
+ list.h \
macros.h \
ralloc.c \
ralloc.h \
diff --git a/mesalib/src/gallium/auxiliary/util/u_double_list.h b/mesalib/src/util/list.h
index 247f0f282..946034710 100644
--- a/mesalib/src/gallium/auxiliary/util/u_double_list.h
+++ b/mesalib/src/util/list.h
@@ -1,8 +1,8 @@
/**************************************************************************
- *
+ *
* Copyright 2006 VMware, Inc., Bismarck, ND. USA.
* All Rights Reserved.
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -10,36 +10,37 @@
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
- * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
* USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
- *
+ *
**************************************************************************/
/**
* \file
* List macros heavily inspired by the Linux kernel
* list handling. No list looping yet.
- *
+ *
* Is not threadsafe, so common operations need to
* be protected using an external mutex.
*/
-#ifndef _U_DOUBLE_LIST_H_
-#define _U_DOUBLE_LIST_H_
+#ifndef _UTIL_LIST_H_
+#define _UTIL_LIST_H_
+#include <stdbool.h>
#include <stddef.h>
-#include "pipe/p_compiler.h"
+#include <assert.h>
struct list_head
@@ -48,13 +49,13 @@ struct list_head
struct list_head *next;
};
-static INLINE void list_inithead(struct list_head *item)
+static inline void list_inithead(struct list_head *item)
{
item->prev = item;
item->next = item;
}
-static INLINE void list_add(struct list_head *item, struct list_head *list)
+static inline void list_add(struct list_head *item, struct list_head *list)
{
item->prev = list;
item->next = list->next;
@@ -62,7 +63,7 @@ static INLINE void list_add(struct list_head *item, struct list_head *list)
list->next = item;
}
-static INLINE void list_addtail(struct list_head *item, struct list_head *list)
+static inline void list_addtail(struct list_head *item, struct list_head *list)
{
item->next = list;
item->prev = list->prev;
@@ -70,7 +71,7 @@ static INLINE void list_addtail(struct list_head *item, struct list_head *list)
list->prev = item;
}
-static INLINE void list_replace(struct list_head *from, struct list_head *to)
+static inline void list_replace(struct list_head *from, struct list_head *to)
{
to->prev = from->prev;
to->next = from->next;
@@ -78,14 +79,14 @@ static INLINE void list_replace(struct list_head *from, struct list_head *to)
from->prev->next = to;
}
-static INLINE void list_del(struct list_head *item)
+static inline void list_del(struct list_head *item)
{
item->prev->next = item->next;
item->next->prev = item->prev;
item->prev = item->next = NULL;
}
-static INLINE void list_delinit(struct list_head *item)
+static inline void list_delinit(struct list_head *item)
{
item->prev->next = item->next;
item->next->prev = item->prev;
@@ -93,6 +94,28 @@ static INLINE void list_delinit(struct list_head *item)
item->prev = item;
}
+static inline bool list_empty(struct list_head *list)
+{
+ return list->next == list;
+}
+
+static inline unsigned list_length(struct list_head *list)
+{
+ struct list_head *node;
+ unsigned length = 0;
+ for (node = list->next; node != list; node = node->next)
+ length++;
+ return length;
+}
+
+static inline void list_validate(struct list_head *list)
+{
+ struct list_head *node;
+ assert(list->next->prev == list && list->prev->next == list);
+ for (node = list->next; node != list; node = node->next)
+ assert(node->next->prev == node && node->prev->next == node);
+}
+
#define LIST_INITHEAD(__item) list_inithead(__item)
#define LIST_ADD(__item, __list) list_add(__item, __list)
#define LIST_ADDTAIL(__item, __list) list_addtail(__item, __list)
@@ -144,4 +167,38 @@ static INLINE void list_delinit(struct list_head *item)
&pos->member != (head); \
pos = container_of(pos->member.prev, pos, member))
-#endif /*_U_DOUBLE_LIST_H_*/
+#define list_for_each_entry(type, pos, head, member) \
+ for (type *pos = LIST_ENTRY(type, (head)->next, member); \
+ &pos->member != (head); \
+ pos = LIST_ENTRY(type, pos->member.next, member))
+
+#define list_for_each_entry_safe(type, pos, head, member) \
+ for (type *pos = LIST_ENTRY(type, (head)->next, member), \
+ *__next = LIST_ENTRY(type, pos->member.next, member); \
+ &pos->member != (head); \
+ pos = __next, \
+ __next = LIST_ENTRY(type, __next->member.next, member))
+
+#define list_for_each_entry_rev(type, pos, head, member) \
+ for (type *pos = LIST_ENTRY(type, (head)->prev, member); \
+ &pos->member != (head); \
+ pos = LIST_ENTRY(type, pos->member.prev, member))
+
+#define list_for_each_entry_safe_rev(type, pos, head, member) \
+ for (type *pos = LIST_ENTRY(type, (head)->prev, member), \
+ *__prev = LIST_ENTRY(type, pos->member.prev, member); \
+ &pos->member != (head); \
+ pos = __prev, \
+ __prev = LIST_ENTRY(type, __prev->member.prev, member))
+
+#define list_for_each_entry_from(type, pos, start, head, member) \
+ for (type *pos = LIST_ENTRY(type, (start), member); \
+ &pos->member != (head); \
+ pos = LIST_ENTRY(type, pos->member.next, member))
+
+#define list_for_each_entry_from_rev(type, pos, start, head, member) \
+ for (type *pos = LIST_ENTRY(type, (start), member); \
+ &pos->member != (head); \
+ pos = LIST_ENTRY(type, pos->member.prev, member))
+
+#endif /*_UTIL_LIST_H_*/
diff --git a/pixman/.gitignore b/pixman/.gitignore
index 7da6b6f79..a245b69f0 100644
--- a/pixman/.gitignore
+++ b/pixman/.gitignore
@@ -26,62 +26,27 @@ stamp-h?
config.h
config.h.in
.*.swp
-demos/alpha-test
+demos/*-test
demos/checkerboard
demos/clip-in
-demos/clip-test
-demos/composite-test
-demos/conical-test
-demos/convolution-test
-demos/gradient-test
demos/linear-gradient
demos/quad2quad
-demos/radial-test
demos/scale
-demos/screen-test
-demos/srgb-test
-demos/srgb-trap-test
-demos/trap-test
-demos/tri-test
pixman/pixman-srgb.c
pixman/pixman-version.h
-test/a1-trap-test
+test/*-test
test/affine-bench
-test/affine-test
test/alpha-loop
test/alphamap
-test/alpha-test
-test/blitters-test
+test/check-formats
test/clip-in
-test/clip-test
-test/combiner-test
test/composite
-test/composite-test
-test/composite-traps-test
-test/convolution-test
-test/fetch-test
-test/glyph-test
-test/gradient-crash-test
-test/gradient-test
test/infinite-loop
test/lowlevel-blt-bench
-test/oob-test
-test/pdf-op-test
-test/prng-test
-test/radial-perf-test
-test/region-contains-test
-test/region-test
+test/radial-invalid
test/region-translate
-test/region-translate-test
-test/rotate-test
-test/scaling-crash-test
-test/scaling-helpers-test
-test/scaling-test
-test/screen-test
-test/stress-test
+test/scaling-bench
test/trap-crasher
-test/trap-test
-test/window-test
*.pdb
*.dll
*.lib
diff --git a/pixman/pixman/pixman-mips-dspr2-asm.h b/pixman/pixman/pixman-mips-dspr2-asm.h
index 11849bd66..e44edd695 100644
--- a/pixman/pixman/pixman-mips-dspr2-asm.h
+++ b/pixman/pixman/pixman-mips-dspr2-asm.h
@@ -72,10 +72,8 @@
#define LEAF_MIPS32R2(symbol) \
.globl symbol; \
.align 2; \
-#ifdef __ELF__
.hidden symbol; \
.type symbol, @function; \
-#endif
.ent symbol, 0; \
symbol: .frame sp, 0, ra; \
.set push; \
diff --git a/pixman/test/Makefile.sources b/pixman/test/Makefile.sources
index 8b0e855e2..d0d79287c 100644
--- a/pixman/test/Makefile.sources
+++ b/pixman/test/Makefile.sources
@@ -23,6 +23,7 @@ TESTPROGRAMS = \
composite-traps-test \
region-contains-test \
glyph-test \
+ solid-test \
stress-test \
blitters-test \
affine-test \
diff --git a/pixman/test/solid-test.c b/pixman/test/solid-test.c
new file mode 100644
index 000000000..7be546678
--- /dev/null
+++ b/pixman/test/solid-test.c
@@ -0,0 +1,350 @@
+/*
+ * Copyright © 2015 RISC OS Open Ltd
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the copyright holders not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The copyright holders make no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ *
+ * Author: Ben Avison (bavison@riscosopen.org)
+ *
+ */
+
+#include "utils.h"
+#include <stdlib.h>
+#include <stdio.h>
+
+#define WIDTH 32
+#define HEIGHT 32
+
+static const pixman_op_t op_list[] = {
+ PIXMAN_OP_SRC,
+ PIXMAN_OP_OVER,
+ PIXMAN_OP_ADD,
+ PIXMAN_OP_CLEAR,
+ PIXMAN_OP_SRC,
+ PIXMAN_OP_DST,
+ PIXMAN_OP_OVER,
+ PIXMAN_OP_OVER_REVERSE,
+ PIXMAN_OP_IN,
+ PIXMAN_OP_IN_REVERSE,
+ PIXMAN_OP_OUT,
+ PIXMAN_OP_OUT_REVERSE,
+ PIXMAN_OP_ATOP,
+ PIXMAN_OP_ATOP_REVERSE,
+ PIXMAN_OP_XOR,
+ PIXMAN_OP_ADD,
+ PIXMAN_OP_MULTIPLY,
+ PIXMAN_OP_SCREEN,
+ PIXMAN_OP_OVERLAY,
+ PIXMAN_OP_DARKEN,
+ PIXMAN_OP_LIGHTEN,
+ PIXMAN_OP_HARD_LIGHT,
+ PIXMAN_OP_DIFFERENCE,
+ PIXMAN_OP_EXCLUSION,
+#if 0 /* these use floating point math and are not always bitexact on different platforms */
+ PIXMAN_OP_SATURATE,
+ PIXMAN_OP_DISJOINT_CLEAR,
+ PIXMAN_OP_DISJOINT_SRC,
+ PIXMAN_OP_DISJOINT_DST,
+ PIXMAN_OP_DISJOINT_OVER,
+ PIXMAN_OP_DISJOINT_OVER_REVERSE,
+ PIXMAN_OP_DISJOINT_IN,
+ PIXMAN_OP_DISJOINT_IN_REVERSE,
+ PIXMAN_OP_DISJOINT_OUT,
+ PIXMAN_OP_DISJOINT_OUT_REVERSE,
+ PIXMAN_OP_DISJOINT_ATOP,
+ PIXMAN_OP_DISJOINT_ATOP_REVERSE,
+ PIXMAN_OP_DISJOINT_XOR,
+ PIXMAN_OP_CONJOINT_CLEAR,
+ PIXMAN_OP_CONJOINT_SRC,
+ PIXMAN_OP_CONJOINT_DST,
+ PIXMAN_OP_CONJOINT_OVER,
+ PIXMAN_OP_CONJOINT_OVER_REVERSE,
+ PIXMAN_OP_CONJOINT_IN,
+ PIXMAN_OP_CONJOINT_IN_REVERSE,
+ PIXMAN_OP_CONJOINT_OUT,
+ PIXMAN_OP_CONJOINT_OUT_REVERSE,
+ PIXMAN_OP_CONJOINT_ATOP,
+ PIXMAN_OP_CONJOINT_ATOP_REVERSE,
+ PIXMAN_OP_CONJOINT_XOR,
+ PIXMAN_OP_COLOR_DODGE,
+ PIXMAN_OP_COLOR_BURN,
+ PIXMAN_OP_SOFT_LIGHT,
+ PIXMAN_OP_HSL_HUE,
+ PIXMAN_OP_HSL_SATURATION,
+ PIXMAN_OP_HSL_COLOR,
+ PIXMAN_OP_HSL_LUMINOSITY,
+#endif
+};
+
+/* The first eight format in the list are by far the most widely
+ * used formats, so we test those more than the others
+ */
+#define N_MOST_LIKELY_FORMATS 8
+
+static const pixman_format_code_t img_fmt_list[] = {
+ PIXMAN_a8r8g8b8,
+ PIXMAN_a8b8g8r8,
+ PIXMAN_x8r8g8b8,
+ PIXMAN_x8b8g8r8,
+ PIXMAN_r5g6b5,
+ PIXMAN_b5g6r5,
+ PIXMAN_a8,
+ PIXMAN_a1,
+ PIXMAN_r3g3b2,
+ PIXMAN_b8g8r8a8,
+ PIXMAN_b8g8r8x8,
+ PIXMAN_r8g8b8a8,
+ PIXMAN_r8g8b8x8,
+ PIXMAN_x14r6g6b6,
+ PIXMAN_r8g8b8,
+ PIXMAN_b8g8r8,
+#if 0 /* These are going to use floating point in the near future */
+ PIXMAN_x2r10g10b10,
+ PIXMAN_a2r10g10b10,
+ PIXMAN_x2b10g10r10,
+ PIXMAN_a2b10g10r10,
+#endif
+ PIXMAN_a1r5g5b5,
+ PIXMAN_x1r5g5b5,
+ PIXMAN_a1b5g5r5,
+ PIXMAN_x1b5g5r5,
+ PIXMAN_a4r4g4b4,
+ PIXMAN_x4r4g4b4,
+ PIXMAN_a4b4g4r4,
+ PIXMAN_x4b4g4r4,
+ PIXMAN_r3g3b2,
+ PIXMAN_b2g3r3,
+ PIXMAN_a2r2g2b2,
+ PIXMAN_a2b2g2r2,
+ PIXMAN_c8,
+ PIXMAN_g8,
+ PIXMAN_x4c4,
+ PIXMAN_x4g4,
+ PIXMAN_c4,
+ PIXMAN_g4,
+ PIXMAN_g1,
+ PIXMAN_x4a4,
+ PIXMAN_a4,
+ PIXMAN_r1g2b1,
+ PIXMAN_b1g2r1,
+ PIXMAN_a1r1g1b1,
+ PIXMAN_a1b1g1r1,
+ PIXMAN_null
+};
+
+static const pixman_format_code_t mask_fmt_list[] = {
+ PIXMAN_a8r8g8b8,
+ PIXMAN_a8,
+ PIXMAN_a4,
+ PIXMAN_a1,
+ PIXMAN_null
+};
+
+static pixman_indexed_t rgb_palette[9];
+static pixman_indexed_t y_palette[9];
+
+static pixman_format_code_t
+random_format (const pixman_format_code_t *allowed_formats)
+{
+ int n = 0;
+
+ while (allowed_formats[n] != PIXMAN_null)
+ n++;
+
+ if (n > N_MOST_LIKELY_FORMATS && prng_rand_n (4) != 0)
+ n = N_MOST_LIKELY_FORMATS;
+
+ return allowed_formats[prng_rand_n (n)];
+}
+
+static pixman_image_t *
+create_multi_pixel_image (const pixman_format_code_t *allowed_formats,
+ uint32_t *buffer,
+ pixman_format_code_t *used_fmt)
+{
+ pixman_format_code_t fmt;
+ pixman_image_t *img;
+ int stride;
+
+ fmt = random_format (allowed_formats);
+ stride = (WIDTH * PIXMAN_FORMAT_BPP (fmt) + 31) / 32 * 4;
+ img = pixman_image_create_bits (fmt, WIDTH, HEIGHT, buffer, stride);
+
+ if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR)
+ pixman_image_set_indexed (img, &(rgb_palette[PIXMAN_FORMAT_BPP (fmt)]));
+ else if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_GRAY)
+ pixman_image_set_indexed (img, &(y_palette[PIXMAN_FORMAT_BPP (fmt)]));
+
+ prng_randmemset (buffer, WIDTH * HEIGHT * 4, 0);
+ image_endian_swap (img);
+
+ if (used_fmt)
+ *used_fmt = fmt;
+
+ return img;
+}
+
+static pixman_image_t *
+create_solid_image (const pixman_format_code_t *allowed_formats,
+ uint32_t *buffer,
+ pixman_format_code_t *used_fmt)
+{
+ if (prng_rand_n (2))
+ {
+ /* Use a repeating 1x1 bitmap image for solid */
+ pixman_format_code_t fmt;
+ pixman_image_t *img, *dummy_img;
+ uint32_t bpp, dummy_buf;
+
+ fmt = random_format (allowed_formats);
+ bpp = PIXMAN_FORMAT_BPP (fmt);
+ img = pixman_image_create_bits (fmt, 1, 1, buffer, 4);
+ pixman_image_set_repeat (img, PIXMAN_REPEAT_NORMAL);
+
+ if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_COLOR)
+ pixman_image_set_indexed (img, &(rgb_palette[bpp]));
+ else if (PIXMAN_FORMAT_TYPE (fmt) == PIXMAN_TYPE_GRAY)
+ pixman_image_set_indexed (img, &(y_palette[bpp]));
+
+ /* Force the flags to be calculated for image with initial
+ * bitmap contents of 0 or 2^bpp-1 by plotting from it into a
+ * separate throwaway image. It is simplest to write all 0s
+ * or all 1s to the first word irrespective of the colour
+ * depth even though we actually only care about the first
+ * pixel since the stride has to be a whole number of words.
+ */
+ *buffer = prng_rand_n (2) ? 0xFFFFFFFFu : 0;
+ dummy_img = pixman_image_create_bits (PIXMAN_a8r8g8b8, 1, 1,
+ &dummy_buf, 4);
+ pixman_image_composite (PIXMAN_OP_SRC, img, NULL, dummy_img,
+ 0, 0, 0, 0, 0, 0, 1, 1);
+ pixman_image_unref (dummy_img);
+
+ /* Now set the bitmap contents to a random value */
+ *buffer = prng_rand ();
+ image_endian_swap (img);
+
+ if (used_fmt)
+ *used_fmt = fmt;
+
+ return img;
+ }
+ else
+ {
+ /* Use a native solid image */
+ pixman_color_t color;
+ pixman_image_t *img;
+
+ prng_randmemset (&color, sizeof color, 0);
+ img = pixman_image_create_solid_fill (&color);
+
+ if (used_fmt)
+ *used_fmt = PIXMAN_solid;
+
+ return img;
+ }
+}
+
+static uint32_t
+test_solid (int testnum, int verbose)
+{
+ pixman_op_t op;
+ uint32_t src_buf[WIDTH * HEIGHT];
+ uint32_t dst_buf[WIDTH * HEIGHT];
+ uint32_t mask_buf[WIDTH * HEIGHT];
+ pixman_image_t *src_img;
+ pixman_image_t *dst_img;
+ pixman_image_t *mask_img = NULL;
+ pixman_format_code_t src_fmt, dst_fmt, mask_fmt = PIXMAN_null;
+ pixman_bool_t ca = 0;
+ uint32_t crc32;
+
+ prng_srand (testnum);
+
+ op = op_list[prng_rand_n (ARRAY_LENGTH (op_list))];
+
+ dst_img = create_multi_pixel_image (img_fmt_list, dst_buf, &dst_fmt);
+ switch (prng_rand_n (3))
+ {
+ case 0: /* Solid source, no mask */
+ src_img = create_solid_image (img_fmt_list, src_buf, &src_fmt);
+ break;
+ case 1: /* Solid source, bitmap mask */
+ src_img = create_solid_image (img_fmt_list, src_buf, &src_fmt);
+ mask_img = create_multi_pixel_image (mask_fmt_list, mask_buf, &mask_fmt);
+ break;
+ case 2: /* Bitmap image, solid mask */
+ src_img = create_multi_pixel_image (img_fmt_list, src_buf, &src_fmt);
+ mask_img = create_solid_image (mask_fmt_list, mask_buf, &mask_fmt);
+ break;
+ default:
+ abort ();
+ }
+
+ if (mask_img)
+ {
+ ca = prng_rand_n (2);
+ pixman_image_set_component_alpha (mask_img, ca);
+ }
+
+ if (verbose)
+ {
+ printf ("op=%s\n", operator_name (op));
+ printf ("src_fmt=%s, dst_fmt=%s, mask_fmt=%s\n",
+ format_name (src_fmt), format_name (dst_fmt),
+ format_name (mask_fmt));
+ printf ("src_size=%u, mask_size=%u, component_alpha=%u\n",
+ src_fmt == PIXMAN_solid ? 1 : src_img->bits.width,
+ !mask_img || mask_fmt == PIXMAN_solid ? 1 : mask_img->bits.width,
+ ca);
+ }
+
+ pixman_image_composite (op, src_img, mask_img, dst_img,
+ 0, 0, 0, 0, 0, 0, WIDTH, HEIGHT);
+
+ if (verbose)
+ print_image (dst_img);
+
+ crc32 = compute_crc32_for_image (0, dst_img);
+
+ pixman_image_unref (src_img);
+ pixman_image_unref (dst_img);
+ if (mask_img)
+ pixman_image_unref (mask_img);
+
+ return crc32;
+}
+
+int
+main (int argc, const char *argv[])
+{
+ int i;
+
+ prng_srand (0);
+
+ for (i = 1; i <= 8; i++)
+ {
+ initialize_palette (&(rgb_palette[i]), i, TRUE);
+ initialize_palette (&(y_palette[i]), i, FALSE);
+ }
+
+ return fuzzer_test_main ("solid", 500000,
+ 0x1B6DFF8D,
+ test_solid, argc, argv);
+}
diff --git a/xorg-server/Xext/hashtable.c b/xorg-server/Xext/hashtable.c
index 471ecca1c..41b2e0013 100644
--- a/xorg-server/Xext/hashtable.c
+++ b/xorg-server/Xext/hashtable.c
@@ -54,7 +54,7 @@ ht_create(int keySize,
ht->elements = 0;
ht->bucketBits = INITHASHSIZE;
numBuckets = 1 << ht->bucketBits;
- ht->buckets = malloc(numBuckets * sizeof(*ht->buckets));
+ ht->buckets = xallocarray(numBuckets, sizeof(*ht->buckets));
ht->cdata = cdata;
if (ht->buckets) {
@@ -92,7 +92,7 @@ double_size(HashTable ht)
int newNumBuckets = 1 << newBucketBits;
int c;
- newBuckets = malloc(newNumBuckets * sizeof(*ht->buckets));
+ newBuckets = xallocarray(newNumBuckets, sizeof(*ht->buckets));
if (newBuckets) {
for (c = 0; c < newNumBuckets; ++c) {
xorg_list_init(&newBuckets[c]);
diff --git a/xorg-server/Xext/panoramiX.c b/xorg-server/Xext/panoramiX.c
index 2bbae2f5e..209df292c 100644
--- a/xorg-server/Xext/panoramiX.c
+++ b/xorg-server/Xext/panoramiX.c
@@ -747,13 +747,13 @@ PanoramiXMaybeAddDepth(DepthPtr pDepth)
j = PanoramiXNumDepths;
PanoramiXNumDepths++;
- PanoramiXDepths = realloc(PanoramiXDepths,
- PanoramiXNumDepths * sizeof(DepthRec));
+ PanoramiXDepths = reallocarray(PanoramiXDepths,
+ PanoramiXNumDepths, sizeof(DepthRec));
PanoramiXDepths[j].depth = pDepth->depth;
PanoramiXDepths[j].numVids = 0;
/* XXX suboptimal, should grow these dynamically */
if (pDepth->numVids)
- PanoramiXDepths[j].vids = malloc(sizeof(VisualID) * pDepth->numVids);
+ PanoramiXDepths[j].vids = xallocarray(pDepth->numVids, sizeof(VisualID));
else
PanoramiXDepths[j].vids = NULL;
}
@@ -789,8 +789,8 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
/* found a matching visual on all screens, add it to the subset list */
j = PanoramiXNumVisuals;
PanoramiXNumVisuals++;
- PanoramiXVisuals = realloc(PanoramiXVisuals,
- PanoramiXNumVisuals * sizeof(VisualRec));
+ PanoramiXVisuals = reallocarray(PanoramiXVisuals,
+ PanoramiXNumVisuals, sizeof(VisualRec));
memcpy(&PanoramiXVisuals[j], pVisual, sizeof(VisualRec));
diff --git a/xorg-server/Xext/panoramiXprocs.c b/xorg-server/Xext/panoramiXprocs.c
index 413a66afb..9eb29bd74 100644
--- a/xorg-server/Xext/panoramiXprocs.c
+++ b/xorg-server/Xext/panoramiXprocs.c
@@ -1106,7 +1106,7 @@ PanoramiXCopyArea(ClientPtr client)
}
pitch = PixmapBytePad(stuff->width, drawables[0]->depth);
- if (!(data = calloc(1, stuff->height * pitch)))
+ if (!(data = calloc(stuff->height, pitch)))
return BadAlloc;
XineramaGetImageData(drawables, srcx, srcy,
@@ -1341,7 +1341,7 @@ PanoramiXPolyPoint(ClientPtr client)
isRoot = (draw->type == XRT_WINDOW) && draw->u.win.root;
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyPointReq));
if (npoint > 0) {
- origPts = malloc(npoint * sizeof(xPoint));
+ origPts = xallocarray(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1406,7 +1406,7 @@ PanoramiXPolyLine(ClientPtr client)
isRoot = IS_ROOT_DRAWABLE(draw);
npoint = bytes_to_int32((client->req_len << 2) - sizeof(xPolyLineReq));
if (npoint > 0) {
- origPts = malloc(npoint * sizeof(xPoint));
+ origPts = xallocarray(npoint, sizeof(xPoint));
memcpy((char *) origPts, (char *) &stuff[1], npoint * sizeof(xPoint));
FOR_NSCREENS_FORWARD(j) {
@@ -1475,7 +1475,7 @@ PanoramiXPolySegment(ClientPtr client)
return BadLength;
nsegs >>= 3;
if (nsegs > 0) {
- origSegs = malloc(nsegs * sizeof(xSegment));
+ origSegs = xallocarray(nsegs, sizeof(xSegment));
memcpy((char *) origSegs, (char *) &stuff[1], nsegs * sizeof(xSegment));
FOR_NSCREENS_FORWARD(j) {
@@ -1543,7 +1543,7 @@ PanoramiXPolyRectangle(ClientPtr client)
return BadLength;
nrects >>= 3;
if (nrects > 0) {
- origRecs = malloc(nrects * sizeof(xRectangle));
+ origRecs = xallocarray(nrects, sizeof(xRectangle));
memcpy((char *) origRecs, (char *) &stuff[1],
nrects * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1610,7 +1610,7 @@ PanoramiXPolyArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
- origArcs = malloc(narcs * sizeof(xArc));
+ origArcs = xallocarray(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -1672,7 +1672,7 @@ PanoramiXFillPoly(ClientPtr client)
count = bytes_to_int32((client->req_len << 2) - sizeof(xFillPolyReq));
if (count > 0) {
- locPts = malloc(count * sizeof(DDXPointRec));
+ locPts = xallocarray(count, sizeof(DDXPointRec));
memcpy((char *) locPts, (char *) &stuff[1],
count * sizeof(DDXPointRec));
FOR_NSCREENS_FORWARD(j) {
@@ -1741,7 +1741,7 @@ PanoramiXPolyFillRectangle(ClientPtr client)
return BadLength;
things >>= 3;
if (things > 0) {
- origRects = malloc(things * sizeof(xRectangle));
+ origRects = xallocarray(things, sizeof(xRectangle));
memcpy((char *) origRects, (char *) &stuff[1],
things * sizeof(xRectangle));
FOR_NSCREENS_FORWARD(j) {
@@ -1808,7 +1808,7 @@ PanoramiXPolyFillArc(ClientPtr client)
return BadLength;
narcs /= sizeof(xArc);
if (narcs > 0) {
- origArcs = malloc(narcs * sizeof(xArc));
+ origArcs = xallocarray(narcs, sizeof(xArc));
memcpy((char *) origArcs, (char *) &stuff[1], narcs * sizeof(xArc));
FOR_NSCREENS_FORWARD(j) {
@@ -1988,8 +1988,7 @@ PanoramiXGetImage(ClientPtr client)
if (linesPerBuf > h)
linesPerBuf = h;
}
- length = linesPerBuf * widthBytesLine;
- if (!(pBuf = malloc(length)))
+ if (!(pBuf = xallocarray(linesPerBuf, widthBytesLine)))
return BadAlloc;
WriteReplyToClient(client, sizeof(xGetImageReply), &xgi);
diff --git a/xorg-server/Xext/saver.c b/xorg-server/Xext/saver.c
index 2c14ea00e..0e20467c9 100644
--- a/xorg-server/Xext/saver.c
+++ b/xorg-server/Xext/saver.c
@@ -853,7 +853,7 @@ ScreenSaverSetAttributes(ClientPtr client)
goto bail;
}
/* over allocate for override redirect */
- pAttr->values = values = malloc((len + 1) * sizeof(unsigned long));
+ pAttr->values = values = xallocarray(len + 1, sizeof(unsigned long));
if (!values) {
ret = BadAlloc;
goto bail;
diff --git a/xorg-server/Xext/shape.c b/xorg-server/Xext/shape.c
index bb479b159..2fc789ec1 100644
--- a/xorg-server/Xext/shape.c
+++ b/xorg-server/Xext/shape.c
@@ -996,7 +996,7 @@ ProcShapeGetRectangles(ClientPtr client)
nrects = RegionNumRects(region);
box = RegionRects(region);
- rects = malloc(nrects * sizeof(xRectangle));
+ rects = xallocarray(nrects, sizeof(xRectangle));
if (!rects && nrects)
return BadAlloc;
for (i = 0; i < nrects; i++, box++) {
diff --git a/xorg-server/Xext/shm.c b/xorg-server/Xext/shm.c
index db9d47450..b359a9035 100644
--- a/xorg-server/Xext/shm.c
+++ b/xorg-server/Xext/shm.c
@@ -260,7 +260,7 @@ ShmDestroyPixmap(PixmapPtr pPixmap)
pScreen->DestroyPixmap = ShmDestroyPixmap;
if (shmdesc)
- ShmDetachSegment(shmdesc, pPixmap->drawable.id);
+ ShmDetachSegment(shmdesc, 0);
return ret;
}
@@ -427,7 +427,7 @@ ProcShmAttach(ClientPtr client)
/*ARGSUSED*/ static int
ShmDetachSegment(void *value, /* must conform to DeleteType */
- XID shmseg)
+ XID unused)
{
ShmDescPtr shmdesc = (ShmDescPtr) value;
ShmDescPtr *prev;
@@ -971,6 +971,12 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client)
stuff->offset);
if (pMap) {
+ result = XaceHook(XACE_RESOURCE_ACCESS, client, stuff->pid,
+ RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess);
+ if (result != Success) {
+ pDraw->pScreen->DestroyPixmap(pMap);
+ return result;
+ }
dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc);
shmdesc->refcnt++;
pMap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
diff --git a/xorg-server/Xext/sync.c b/xorg-server/Xext/sync.c
index ba08cd1bb..41405619c 100644
--- a/xorg-server/Xext/sync.c
+++ b/xorg-server/Xext/sync.c
@@ -620,7 +620,7 @@ SyncAwaitTriggerFired(SyncTrigger * pTrigger)
pAwaitUnion = (SyncAwaitUnion *) pAwait->pHeader;
numwaits = pAwaitUnion->header.num_waitconditions;
- ppAwait = malloc(numwaits * sizeof(SyncAwait *));
+ ppAwait = xallocarray(numwaits, sizeof(SyncAwait *));
if (!ppAwait)
goto bail;
@@ -1514,7 +1514,7 @@ SyncAwaitPrologue(ClientPtr client, int items)
/* all the memory for the entire await list is allocated
* here in one chunk
*/
- pAwaitUnion = malloc((items + 1) * sizeof(SyncAwaitUnion));
+ pAwaitUnion = xallocarray(items + 1, sizeof(SyncAwaitUnion));
if (!pAwaitUnion)
return NULL;
diff --git a/xorg-server/Xext/xcmisc.c b/xorg-server/Xext/xcmisc.c
index 1e9101059..ed25650cd 100644
--- a/xorg-server/Xext/xcmisc.c
+++ b/xorg-server/Xext/xcmisc.c
@@ -101,7 +101,7 @@ ProcXCMiscGetXIDList(ClientPtr client)
if (stuff->count > UINT32_MAX / sizeof(XID))
return BadAlloc;
- pids = (XID *) malloc(stuff->count * sizeof(XID));
+ pids = xallocarray(stuff->count, sizeof(XID));
if (!pids) {
return BadAlloc;
}
diff --git a/xorg-server/Xext/xf86bigfont.c b/xorg-server/Xext/xf86bigfont.c
index 46b3242d1..95b537170 100644
--- a/xorg-server/Xext/xf86bigfont.c
+++ b/xorg-server/Xext/xf86bigfont.c
@@ -401,7 +401,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
}
else {
#endif
- pCI = malloc(nCharInfos * sizeof(xCharInfo));
+ pCI = xallocarray(nCharInfos, sizeof(xCharInfo));
if (!pCI)
return BadAlloc;
#ifdef HAS_SHM
@@ -463,7 +463,7 @@ ProcXF86BigfontQueryFont(ClientPtr client)
if (hashModulus > nCharInfos + 1)
hashModulus = nCharInfos + 1;
- tmp = malloc((4 * nCharInfos + 1) * sizeof(CARD16));
+ tmp = xallocarray(4 * nCharInfos + 1, sizeof(CARD16));
if (!tmp) {
if (!pDesc)
free(pCI);
diff --git a/xorg-server/Xext/xres.c b/xorg-server/Xext/xres.c
index 273793806..6b87c3ddc 100644
--- a/xorg-server/Xext/xres.c
+++ b/xorg-server/Xext/xres.c
@@ -223,7 +223,7 @@ ProcXResQueryClients(ClientPtr client)
REQUEST_SIZE_MATCH(xXResQueryClientsReq);
- current_clients = malloc(currentMaxClients * sizeof(int));
+ current_clients = xallocarray(currentMaxClients, sizeof(int));
num_clients = 0;
for (i = 0; i < currentMaxClients; i++) {
diff --git a/xorg-server/Xext/xselinux_label.c b/xorg-server/Xext/xselinux_label.c
index 2c33d1cbf..8559385b9 100644
--- a/xorg-server/Xext/xselinux_label.c
+++ b/xorg-server/Xext/xselinux_label.c
@@ -64,7 +64,7 @@ SELinuxArraySet(SELinuxArrayRec * rec, unsigned key, void *val)
{
if (key >= rec->size) {
/* Need to increase size of array */
- rec->array = realloc(rec->array, (key + 1) * sizeof(val));
+ rec->array = reallocarray(rec->array, key + 1, sizeof(val));
if (!rec->array)
return FALSE;
memset(rec->array + rec->size, 0, (key - rec->size + 1) * sizeof(val));
diff --git a/xorg-server/Xext/xvmain.c b/xorg-server/Xext/xvmain.c
index 0abf190dc..93e5f0cd3 100644
--- a/xorg-server/Xext/xvmain.c
+++ b/xorg-server/Xext/xvmain.c
@@ -1102,7 +1102,7 @@ XvFillColorKey(DrawablePtr pDraw, CARD32 key, RegionPtr region)
(void) ChangeGC(NullClient, gc, GCForeground | GCSubwindowMode, pval);
ValidateGC(pDraw, gc);
- rects = malloc(nbox * sizeof(xRectangle));
+ rects = xallocarray(nbox, sizeof(xRectangle));
if (rects) {
for (i = 0; i < nbox; i++, pbox++) {
rects[i].x = pbox->x1 - pDraw->x;
diff --git a/xorg-server/Xi/exevents.c b/xorg-server/Xi/exevents.c
index 0857bcee6..1c586d051 100644
--- a/xorg-server/Xi/exevents.c
+++ b/xorg-server/Xi/exevents.c
@@ -471,9 +471,9 @@ DeepCopyKeyboardClasses(DeviceIntPtr from, DeviceIntPtr to)
oldTrace = to->focus->trace;
memcpy(to->focus, from->focus, sizeof(FocusClassRec));
- to->focus->trace = realloc(oldTrace,
- to->focus->traceSize *
- sizeof(WindowPtr));
+ to->focus->trace = reallocarray(oldTrace,
+ to->focus->traceSize,
+ sizeof(WindowPtr));
if (!to->focus->trace && to->focus->traceSize)
FatalError("[Xi] no memory for trace.\n");
memcpy(to->focus->trace, from->focus->trace,
diff --git a/xorg-server/Xi/getprop.c b/xorg-server/Xi/getprop.c
index 4d6ce6338..19f18af21 100644
--- a/xorg-server/Xi/getprop.c
+++ b/xorg-server/Xi/getprop.c
@@ -118,7 +118,7 @@ ProcXGetDeviceDontPropagateList(ClientPtr client)
ClassFromMask(NULL, others->dontPropagateMask[i], i, &count, COUNT);
if (count) {
rep.count = count;
- buf = (XEventClass *) malloc(rep.count * sizeof(XEventClass));
+ buf = xallocarray(rep.count, sizeof(XEventClass));
rep.length = bytes_to_int32(rep.count * sizeof(XEventClass));
tbuf = buf;
diff --git a/xorg-server/Xi/xiproperty.c b/xorg-server/Xi/xiproperty.c
index 8e8e4b061..e3b8f5abe 100644
--- a/xorg-server/Xi/xiproperty.c
+++ b/xorg-server/Xi/xiproperty.c
@@ -221,7 +221,7 @@ list_atoms(DeviceIntPtr dev, int *natoms, Atom **atoms_return)
if (nprops) {
Atom *a;
- atoms = malloc(nprops * sizeof(Atom));
+ atoms = xallocarray(nprops, sizeof(Atom));
if (!atoms)
return BadAlloc;
a = atoms;
@@ -687,7 +687,6 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
{
XIPropertyPtr prop;
int size_in_bytes;
- int total_size;
unsigned long total_len;
XIPropertyValuePtr prop_value;
XIPropertyValueRec new_value;
@@ -725,9 +724,8 @@ XIChangeDeviceProperty(DeviceIntPtr dev, Atom property, Atom type,
if (mode == PropModeReplace || len > 0) {
void *new_data = NULL, *old_data = NULL;
- total_size = total_len * size_in_bytes;
- new_value.data = (void *) malloc(total_size);
- if (!new_value.data && total_size) {
+ new_value.data = xallocarray(total_len, size_in_bytes);
+ if (!new_value.data && total_len && size_in_bytes) {
if (add)
XIDestroyDeviceProperty(prop);
return BadAlloc;
diff --git a/xorg-server/Xi/xiquerypointer.c b/xorg-server/Xi/xiquerypointer.c
index 7ec0c851d..b9e295815 100644
--- a/xorg-server/Xi/xiquerypointer.c
+++ b/xorg-server/Xi/xiquerypointer.c
@@ -152,10 +152,10 @@ ProcXIQueryPointer(ClientPtr client)
rep.buttons_len =
bytes_to_int32(bits_to_bytes(pDev->button->numButtons));
rep.length += rep.buttons_len;
- buttons_size = rep.buttons_len * 4;
- buttons = calloc(1, buttons_size);
+ buttons = calloc(rep.buttons_len, 4);
if (!buttons)
return BadAlloc;
+ buttons_size = rep.buttons_len * 4;
for (i = 1; i < pDev->button->numButtons; i++)
if (BitIsOn(pDev->button->down, i))
diff --git a/xorg-server/composite/compinit.c b/xorg-server/composite/compinit.c
index 3ac075a46..cf61f2a57 100644
--- a/xorg-server/composite/compinit.c
+++ b/xorg-server/composite/compinit.c
@@ -223,8 +223,8 @@ compRegisterAlternateVisuals(CompScreenPtr cs, VisualID * vids, int nVisuals)
{
VisualID *p;
- p = realloc(cs->alternateVisuals,
- sizeof(VisualID) * (cs->numAlternateVisuals + nVisuals));
+ p = reallocarray(cs->alternateVisuals,
+ cs->numAlternateVisuals + nVisuals, sizeof(VisualID));
if (p == NULL)
return FALSE;
@@ -253,8 +253,8 @@ CompositeRegisterImplicitRedirectionException(ScreenPtr pScreen,
CompScreenPtr cs = GetCompScreen(pScreen);
CompImplicitRedirectException *p;
- p = realloc(cs->implicitRedirectExceptions,
- sizeof(p[0]) * (cs->numImplicitRedirectExceptions + 1));
+ p = reallocarray(cs->implicitRedirectExceptions,
+ cs->numImplicitRedirectExceptions + 1, sizeof(p[0]));
if (p == NULL)
return FALSE;
diff --git a/xorg-server/config/config.c b/xorg-server/config/config.c
index b5d634b87..de45cc350 100644
--- a/xorg-server/config/config.c
+++ b/xorg-server/config/config.c
@@ -130,7 +130,8 @@ device_is_duplicate(const char *config_info)
struct OdevAttributes *
config_odev_allocate_attributes(void)
{
- struct OdevAttributes *attribs = XNFcalloc(sizeof (struct OdevAttributes));
+ struct OdevAttributes *attribs =
+ xnfcalloc(1, sizeof (struct OdevAttributes));
attribs->fd = -1;
return attribs;
}
diff --git a/xorg-server/configure.ac b/xorg-server/configure.ac
index 606298bdc..f760730c3 100644
--- a/xorg-server/configure.ac
+++ b/xorg-server/configure.ac
@@ -219,7 +219,7 @@ dnl Checks for library functions.
AC_CHECK_FUNCS([backtrace ffs geteuid getuid issetugid getresuid \
getdtablesize getifaddrs getpeereid getpeerucred getprogname getzoneid \
mmap seteuid shmctl64 strncasecmp vasprintf vsnprintf walkcontext])
-AC_REPLACE_FUNCS([strcasecmp strcasestr strlcat strlcpy strndup])
+AC_REPLACE_FUNCS([reallocarray strcasecmp strcasestr strlcat strlcpy strndup])
AC_CHECK_DECLS([program_invocation_short_name], [], [], [[#include <errno.h>]])
@@ -560,17 +560,7 @@ dnl GLX build options
AC_ARG_ENABLE(aiglx, AS_HELP_STRING([--enable-aiglx], [Build accelerated indirect GLX (default: enabled)]),
[AIGLX=$enableval],
[AIGLX=yes])
-XORG_TLS
-AC_ARG_ENABLE(glx-tls, AS_HELP_STRING([--enable-glx-tls], [Build GLX with TLS support (default: auto)]),
- [GLX_USE_TLS=$enableval
- if test "x$GLX_USE_TLS" = "xyes" && test "${ac_cv_tls}" = "none" ; then
- AC_MSG_ERROR([GLX with TLS support requested, but the compiler does not support it.])
- fi],
- [GLX_USE_TLS=no
- if test "${ac_cv_tls}" != "none" ; then
- GLX_USE_TLS=yes
- fi])
-AC_SUBST(GLX_TLS, ${GLX_USE_TLS})
+
AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Path to Khronos OpenGL registry database files (default: auto)]),
[KHRONOS_SPEC_DIR="${withval}"],
[KHRONOS_SPEC_DIR=auto])
@@ -1324,10 +1314,6 @@ if test "x$AIGLX" = xyes -a \( "x$DRI2" = xyes \); then
fi
AM_CONDITIONAL(AIGLX_DRI_LOADER, { test "x$DRI2" = xyes; } && test "x$AIGLX" = xyes)
-if test "x$GLX_USE_TLS" = xyes ; then
- GLX_DEFINES="-DGLX_USE_TLS -DPTHREADS"
- GLX_SYS_LIBS="$GLX_SYS_LIBS -lpthread"
-fi
AC_SUBST([GLX_DEFINES])
AC_SUBST([GLX_SYS_LIBS])
@@ -1976,7 +1962,7 @@ if test "x$XORG" = xyes; then
sparc*)
SOLARIS_INOUT_ARCH="sparcv8plus"
;;
- i*86)
+ i*86|x86_64*)
if test x$SOLARIS_64 = xyes ; then
SOLARIS_INOUT_ARCH="amd64"
else
@@ -2006,11 +1992,6 @@ if test "x$XORG" = xyes; then
;;
esac
- case $host_cpu in
- i*86)
- ;;
- esac
-
if test "x$DGA" = xauto; then
PKG_CHECK_MODULES(DGA, $DGAPROTO, [DGA=yes], [DGA=no])
fi
@@ -2423,7 +2404,8 @@ if test "$KDRIVE" = yes; then
fi
;;
esac
- KDRIVE_LOCAL_LIBS="$MAIN_LIB $DIX_LIB $KDRIVE_LIB"
+ KDRIVE_MAIN_LIB="$MAIN_LIB"
+ KDRIVE_LOCAL_LIBS="$DIX_LIB $KDRIVE_LIB"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $FB_LIB $MI_LIB $KDRIVE_PURE_LIBS"
KDRIVE_LOCAL_LIBS="$KDRIVE_LOCAL_LIBS $KDRIVE_OS_LIB"
KDRIVE_LIBS="$KDRIVE_LOCAL_LIBS $XSERVER_SYS_LIBS $GLX_SYS_LIBS $DLOPEN_LIBS $TSLIB_LIBS"
@@ -2435,6 +2417,7 @@ AC_SUBST([KDRIVE_INCS])
AC_SUBST([KDRIVE_PURE_INCS])
AC_SUBST([KDRIVE_CFLAGS])
AC_SUBST([KDRIVE_PURE_LIBS])
+AC_SUBST([KDRIVE_MAIN_LIB])
AC_SUBST([KDRIVE_LOCAL_LIBS])
AC_SUBST([KDRIVE_LIBS])
AM_CONDITIONAL(KDRIVELINUX, [test "x$KDRIVELINUX" = xyes])
diff --git a/xorg-server/dbe/dbe.c b/xorg-server/dbe/dbe.c
index e5d928d7b..23f7e164d 100644
--- a/xorg-server/dbe/dbe.c
+++ b/xorg-server/dbe/dbe.c
@@ -287,11 +287,10 @@ ProcDbeAllocateBackBufferName(ClientPtr client)
}
/* malloc/realloc a new array and initialize all elements to 0. */
- pDbeWindowPriv->IDs = (XID *) realloc(pIDs,
- (pDbeWindowPriv->
- maxAvailableIDs +
- DBE_INCR_MAX_IDS) *
- sizeof(XID));
+ pDbeWindowPriv->IDs =
+ reallocarray(pIDs,
+ pDbeWindowPriv->maxAvailableIDs + DBE_INCR_MAX_IDS,
+ sizeof(XID));
if (!pDbeWindowPriv->IDs) {
return BadAlloc;
}
@@ -470,7 +469,7 @@ ProcDbeSwapBuffers(ClientPtr client)
dbeSwapInfo = (xDbeSwapInfo *) &stuff[1];
/* Allocate array to record swap information. */
- swapInfo = (DbeSwapInfoPtr) malloc(nStuff * sizeof(DbeSwapInfoRec));
+ swapInfo = xallocarray(nStuff, sizeof(DbeSwapInfoRec));
if (swapInfo == NULL) {
return BadAlloc;
}
@@ -580,8 +579,7 @@ ProcDbeGetVisualInfo(ClientPtr client)
return BadAlloc;
/* Make sure any specified drawables are valid. */
if (stuff->n != 0) {
- if (!(pDrawables = (DrawablePtr *) malloc(stuff->n *
- sizeof(DrawablePtr)))) {
+ if (!(pDrawables = xallocarray(stuff->n, sizeof(DrawablePtr)))) {
return BadAlloc;
}
diff --git a/xorg-server/dbe/midbe.c b/xorg-server/dbe/midbe.c
index 8f759107a..9684d45bd 100644
--- a/xorg-server/dbe/midbe.c
+++ b/xorg-server/dbe/midbe.c
@@ -87,7 +87,7 @@ miDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo * pScrVisInfo)
}
/* Allocate an array of XdbeVisualInfo items. */
- if (!(visInfo = (XdbeVisualInfo *) malloc(count * sizeof(XdbeVisualInfo)))) {
+ if (!(visInfo = xallocarray(count, sizeof(XdbeVisualInfo)))) {
return FALSE; /* memory alloc failure */
}
diff --git a/xorg-server/dix/atom.c b/xorg-server/dix/atom.c
index 22cd0dc0e..7de7fb05e 100644
--- a/xorg-server/dix/atom.c
+++ b/xorg-server/dix/atom.c
@@ -119,7 +119,7 @@ MakeAtom(const char *string, unsigned len, Bool makeit)
if ((lastAtom + 1) >= tableLength) {
NodePtr *table;
- table = realloc(nodeTable, tableLength * (2 * sizeof(NodePtr)));
+ table = reallocarray(nodeTable, tableLength, 2 * sizeof(NodePtr));
if (!table) {
if (nd->string != string) {
/* nd->string has been strdup'ed */
@@ -200,7 +200,7 @@ InitAtoms(void)
{
FreeAllAtoms();
tableLength = InitialTableSize;
- nodeTable = malloc(InitialTableSize * sizeof(NodePtr));
+ nodeTable = xallocarray(InitialTableSize, sizeof(NodePtr));
if (!nodeTable)
AtomError();
nodeTable[None] = NULL;
diff --git a/xorg-server/dix/colormap.c b/xorg-server/dix/colormap.c
index 4d408d5d2..a3e5a2c09 100644
--- a/xorg-server/dix/colormap.c
+++ b/xorg-server/dix/colormap.c
@@ -296,7 +296,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
for (pent = &pmap->red[size - 1]; pent >= pmap->red; pent--)
pent->refcnt = AllocPrivate;
pmap->freeRed = 0;
- ppix = malloc(size * sizeof(Pixel));
+ ppix = xallocarray(size, sizeof(Pixel));
if (!ppix) {
free(pmap);
return BadAlloc;
@@ -337,7 +337,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
for (pent = &pmap->green[size - 1]; pent >= pmap->green; pent--)
pent->refcnt = AllocPrivate;
pmap->freeGreen = 0;
- ppix = malloc(size * sizeof(Pixel));
+ ppix = xallocarray(size, sizeof(Pixel));
if (!ppix) {
free(pmap->clientPixelsRed[client]);
free(pmap);
@@ -352,7 +352,7 @@ CreateColormap(Colormap mid, ScreenPtr pScreen, VisualPtr pVisual,
for (pent = &pmap->blue[size - 1]; pent >= pmap->blue; pent--)
pent->refcnt = AllocPrivate;
pmap->freeBlue = 0;
- ppix = malloc(size * sizeof(Pixel));
+ ppix = xallocarray(size, sizeof(Pixel));
if (!ppix) {
free(pmap->clientPixelsGreen[client]);
free(pmap->clientPixelsRed[client]);
@@ -702,7 +702,7 @@ UpdateColors(ColormapPtr pmap)
pVisual = pmap->pVisual;
size = pVisual->ColormapEntries;
- defs = malloc(size * sizeof(xColorItem));
+ defs = xallocarray(size, sizeof(xColorItem));
if (!defs)
return;
n = 0;
@@ -792,8 +792,8 @@ AllocColor(ColormapPtr pmap,
*pgreen = pmap->red[pixR].co.local.green;
*pblue = pmap->red[pixR].co.local.blue;
npix = pmap->numPixelsRed[client];
- ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
- (npix + 1) * sizeof(Pixel));
+ ppix = reallocarray(pmap->clientPixelsRed[client],
+ npix + 1, sizeof(Pixel));
if (!ppix)
return BadAlloc;
ppix[npix] = pixR;
@@ -814,22 +814,22 @@ AllocColor(ColormapPtr pmap,
*pgreen = pmap->green[pixG].co.local.green;
*pblue = pmap->blue[pixB].co.local.blue;
npix = pmap->numPixelsRed[client];
- ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
- (npix + 1) * sizeof(Pixel));
+ ppix = reallocarray(pmap->clientPixelsRed[client],
+ npix + 1, sizeof(Pixel));
if (!ppix)
return BadAlloc;
ppix[npix] = pixR;
pmap->clientPixelsRed[client] = ppix;
npix = pmap->numPixelsGreen[client];
- ppix = (Pixel *) realloc(pmap->clientPixelsGreen[client],
- (npix + 1) * sizeof(Pixel));
+ ppix = reallocarray(pmap->clientPixelsGreen[client],
+ npix + 1, sizeof(Pixel));
if (!ppix)
return BadAlloc;
ppix[npix] = pixG;
pmap->clientPixelsGreen[client] = ppix;
npix = pmap->numPixelsBlue[client];
- ppix = (Pixel *) realloc(pmap->clientPixelsBlue[client],
- (npix + 1) * sizeof(Pixel));
+ ppix = reallocarray(pmap->clientPixelsBlue[client],
+ npix + 1, sizeof(Pixel));
if (!ppix)
return BadAlloc;
ppix[npix] = pixB;
@@ -1279,7 +1279,7 @@ FindColor(ColormapPtr pmap, EntryPtr pentFirst, int size, xrgb * prgb,
break;
}
npix = nump[client];
- ppix = (Pixel *) realloc(pixp[client], (npix + 1) * sizeof(Pixel));
+ ppix = reallocarray(pixp[client], npix + 1, sizeof(Pixel));
if (!ppix) {
pent->refcnt--;
if (!pent->fShared)
@@ -1647,9 +1647,9 @@ AllocDirect(int client, ColormapPtr pmap, int c, int r, int g, int b,
for (p = pixels; p < pixels + c; p++)
*p = 0;
- ppixRed = malloc(npixR * sizeof(Pixel));
- ppixGreen = malloc(npixG * sizeof(Pixel));
- ppixBlue = malloc(npixB * sizeof(Pixel));
+ ppixRed = xallocarray(npixR, sizeof(Pixel));
+ ppixGreen = xallocarray(npixG, sizeof(Pixel));
+ ppixBlue = xallocarray(npixB, sizeof(Pixel));
if (!ppixRed || !ppixGreen || !ppixBlue) {
free(ppixBlue);
free(ppixGreen);
@@ -1662,19 +1662,19 @@ AllocDirect(int client, ColormapPtr pmap, int c, int r, int g, int b,
okB = AllocCP(pmap, pmap->blue, c, b, contig, ppixBlue, pbmask);
if (okR && okG && okB) {
- rpix = (Pixel *) realloc(pmap->clientPixelsRed[client],
- (pmap->numPixelsRed[client] + (c << r)) *
- sizeof(Pixel));
+ rpix = reallocarray(pmap->clientPixelsRed[client],
+ pmap->numPixelsRed[client] + (c << r),
+ sizeof(Pixel));
if (rpix)
pmap->clientPixelsRed[client] = rpix;
- gpix = (Pixel *) realloc(pmap->clientPixelsGreen[client],
- (pmap->numPixelsGreen[client] + (c << g)) *
- sizeof(Pixel));
+ gpix = reallocarray(pmap->clientPixelsGreen[client],
+ pmap->numPixelsGreen[client] + (c << g),
+ sizeof(Pixel));
if (gpix)
pmap->clientPixelsGreen[client] = gpix;
- bpix = (Pixel *) realloc(pmap->clientPixelsBlue[client],
- (pmap->numPixelsBlue[client] + (c << b)) *
- sizeof(Pixel));
+ bpix = reallocarray(pmap->clientPixelsBlue[client],
+ pmap->numPixelsBlue[client] + (c << b),
+ sizeof(Pixel));
if (bpix)
pmap->clientPixelsBlue[client] = bpix;
}
@@ -1747,7 +1747,7 @@ AllocPseudo(int client, ColormapPtr pmap, int c, int r, Bool contig,
npix = c << r;
if ((r >= 32) || (npix > pmap->freeRed) || (npix < c))
return BadAlloc;
- if (!(ppixTemp = malloc(npix * sizeof(Pixel))))
+ if (!(ppixTemp = xallocarray(npix, sizeof(Pixel))))
return BadAlloc;
ok = AllocCP(pmap, pmap->red, c, r, contig, ppixTemp, pmask);
@@ -1755,9 +1755,8 @@ AllocPseudo(int client, ColormapPtr pmap, int c, int r, Bool contig,
/* all the allocated pixels are added to the client pixel list,
* but only the unique ones are returned to the client */
- ppix = (Pixel *) realloc(pmap->clientPixelsRed[client],
- (pmap->numPixelsRed[client] +
- npix) * sizeof(Pixel));
+ ppix = reallocarray(pmap->clientPixelsRed[client],
+ pmap->numPixelsRed[client] + npix, sizeof(Pixel));
if (!ppix) {
for (p = ppixTemp; p < ppixTemp + npix; p++)
pmap->red[*p].refcnt = 0;
@@ -1960,7 +1959,7 @@ AllocShared(ColormapPtr pmap, Pixel * ppix, int c, int r, int g, int b,
npixClientNew = c << (r + g + b);
npixShared = (c << r) + (c << g) + (c << b);
- psharedList = malloc(npixShared * sizeof(SHAREDCOLOR *));
+ psharedList = xallocarray(npixShared, sizeof(SHAREDCOLOR *));
if (!psharedList)
return FALSE;
ppshared = psharedList;
@@ -2204,7 +2203,7 @@ FreeCo(ColormapPtr pmap, int client, int color, int npixIn, Pixel * ppixIn,
npix++;
}
}
- pptr = (Pixel *) realloc(ppixClient, npixNew * sizeof(Pixel));
+ pptr = reallocarray(ppixClient, npixNew, sizeof(Pixel));
if (pptr)
ppixClient = pptr;
npixClient = npixNew;
@@ -2469,8 +2468,8 @@ IsMapInstalled(Colormap map, WindowPtr pWin)
Colormap *pmaps;
int imap, nummaps, found;
- pmaps =
- malloc(pWin->drawable.pScreen->maxInstalledCmaps * sizeof(Colormap));
+ pmaps = xallocarray(pWin->drawable.pScreen->maxInstalledCmaps,
+ sizeof(Colormap));
if (!pmaps)
return FALSE;
nummaps = (*pWin->drawable.pScreen->ListInstalledColormaps)
@@ -2521,8 +2520,8 @@ ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, DepthPtr depth)
first_new_vid = depth->numVids;
first_new_visual = pScreen->numVisuals;
- vids =
- realloc(depth->vids, (depth->numVids + new_visual_count) * sizeof(XID));
+ vids = reallocarray(depth->vids, depth->numVids + new_visual_count,
+ sizeof(XID));
if (!vids)
return FALSE;
@@ -2530,7 +2529,7 @@ ResizeVisualArray(ScreenPtr pScreen, int new_visual_count, DepthPtr depth)
depth->vids = vids;
numVisuals = pScreen->numVisuals + new_visual_count;
- visuals = realloc(pScreen->visuals, numVisuals * sizeof(VisualRec));
+ visuals = reallocarray(pScreen->visuals, numVisuals, sizeof(VisualRec));
if (!visuals) {
return FALSE;
}
diff --git a/xorg-server/dix/devices.c b/xorg-server/dix/devices.c
index d8e7f9c40..1f8dabddd 100644
--- a/xorg-server/dix/devices.c
+++ b/xorg-server/dix/devices.c
@@ -177,6 +177,9 @@ DeviceSetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
if (!isfinite(f[i]))
return BadValue;
+ if (!dev->valuator)
+ return BadMatch;
+
if (!checkonly)
DeviceSetTransform(dev, f);
}
@@ -1469,8 +1472,8 @@ InitStringFeedbackClassDeviceStruct(DeviceIntPtr dev,
feedc->ctrl.num_symbols_displayed = 0;
feedc->ctrl.max_symbols = max_symbols;
feedc->ctrl.symbols_supported =
- malloc(sizeof(KeySym) * num_symbols_supported);
- feedc->ctrl.symbols_displayed = malloc(sizeof(KeySym) * max_symbols);
+ xallocarray(num_symbols_supported, sizeof(KeySym));
+ feedc->ctrl.symbols_displayed = xallocarray(max_symbols, sizeof(KeySym));
if (!feedc->ctrl.symbols_supported || !feedc->ctrl.symbols_displayed) {
free(feedc->ctrl.symbols_supported);
free(feedc->ctrl.symbols_displayed);
diff --git a/xorg-server/dix/dispatch.c b/xorg-server/dix/dispatch.c
index 17fa75e19..9208582a6 100644
--- a/xorg-server/dix/dispatch.c
+++ b/xorg-server/dix/dispatch.c
@@ -344,7 +344,7 @@ Dispatch(void)
nextFreeClientID = 1;
nClients = 0;
- clientReady = malloc(sizeof(int) * MaxClients);
+ clientReady = xallocarray(MaxClients, sizeof(int));
if (!clientReady)
return;
@@ -963,7 +963,7 @@ ProcQueryTree(ClientPtr client)
if (numChildren) {
int curChild = 0;
- childIDs = malloc(numChildren * sizeof(Window));
+ childIDs = xallocarray(numChildren, sizeof(Window));
if (!childIDs)
return BadAlloc;
for (pChild = pWin->lastChild; pChild != pHead;
@@ -2786,7 +2786,7 @@ ProcQueryColors(ClientPtr client)
count =
bytes_to_int32((client->req_len << 2) - sizeof(xQueryColorsReq));
- prgbs = calloc(1, count * sizeof(xrgb));
+ prgbs = calloc(count, sizeof(xrgb));
if (!prgbs && count)
return BadAlloc;
if ((rc =
@@ -2908,10 +2908,10 @@ ProcCreateCursor(ClientPtr client)
if (stuff->x > width || stuff->y > height)
return BadMatch;
- n = BitmapBytePad(width) * height;
- srcbits = calloc(1, n);
+ srcbits = calloc(BitmapBytePad(width), height);
if (!srcbits)
return BadAlloc;
+ n = BitmapBytePad(width) * height;
mskbits = malloc(n);
if (!mskbits) {
free(srcbits);
diff --git a/xorg-server/dix/dixfonts.c b/xorg-server/dix/dixfonts.c
index bc2732fb9..be389e82f 100644
--- a/xorg-server/dix/dixfonts.c
+++ b/xorg-server/dix/dixfonts.c
@@ -168,9 +168,8 @@ QueueFontWakeup(FontPathElementPtr fpe)
}
}
if (num_slept_fpes == size_slept_fpes) {
- new = (FontPathElementPtr *)
- realloc(slept_fpes,
- sizeof(FontPathElementPtr) * (size_slept_fpes + 4));
+ new = reallocarray(slept_fpes, size_slept_fpes + 4,
+ sizeof(FontPathElementPtr));
if (!new)
return;
slept_fpes = new;
@@ -424,7 +423,7 @@ OpenFont(ClientPtr client, XID fid, Mask flags, unsigned lenfname,
* copy the current FPE list, so that if it gets changed by another client
* while we're blocking, the request still appears atomic
*/
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
if (!c->fpe_list) {
free((void *) c->fontname);
free(c);
@@ -821,7 +820,7 @@ ListFonts(ClientPtr client, unsigned char *pattern, unsigned length,
if (!(c = malloc(sizeof *c)))
return BadAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
if (!c->fpe_list) {
free(c);
return BadAlloc;
@@ -1072,7 +1071,7 @@ StartListFontsWithInfo(ClientPtr client, int length, unsigned char *pattern,
if (!(c = malloc(sizeof *c)))
goto badAlloc;
- c->fpe_list = malloc(sizeof(FontPathElementPtr) * num_fpes);
+ c->fpe_list = xallocarray(num_fpes, sizeof(FontPathElementPtr));
if (!c->fpe_list) {
free(c);
goto badAlloc;
@@ -1441,7 +1440,7 @@ doImageText(ClientPtr client, ITclosurePtr c)
*new_closure = *c;
c = new_closure;
- data = malloc(c->nChars * itemSize);
+ data = xallocarray(c->nChars, itemSize);
if (!data) {
free(c);
c = old_closure;
@@ -1597,7 +1596,7 @@ SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
unsigned char *cp = paths;
FontPathElementPtr fpe = NULL, *fplist;
- fplist = malloc(sizeof(FontPathElementPtr) * npaths);
+ fplist = xallocarray(npaths, sizeof(FontPathElementPtr));
if (!fplist) {
*bad = 0;
return BadAlloc;
@@ -1894,8 +1893,7 @@ RegisterFPEFunctions(NameCheckFunc name_func,
FPEFunctions *new;
/* grow the list */
- new = (FPEFunctions *) realloc(fpe_functions,
- (num_fpe_types + 1) * sizeof(FPEFunctions));
+ new = reallocarray(fpe_functions, num_fpe_types + 1, sizeof(FPEFunctions));
if (!new)
return -1;
fpe_functions = new;
diff --git a/xorg-server/dix/enterleave.c b/xorg-server/dix/enterleave.c
index 54f4b8554..7f1f94165 100644
--- a/xorg-server/dix/enterleave.c
+++ b/xorg-server/dix/enterleave.c
@@ -714,7 +714,7 @@ DeliverStateNotifyEvent(DeviceIntPtr dev, WindowPtr win)
}
}
- sev = ev = (deviceStateNotify *) malloc(evcount * sizeof(xEvent));
+ sev = ev = xallocarray(evcount, sizeof(xEvent));
FixDeviceStateNotify(dev, ev, NULL, NULL, NULL, first);
if (b != NULL) {
diff --git a/xorg-server/dix/events.c b/xorg-server/dix/events.c
index c232ebadc..efaf91d2b 100644
--- a/xorg-server/dix/events.c
+++ b/xorg-server/dix/events.c
@@ -1057,6 +1057,7 @@ MonthChangedOrBadTime(CARD32 *ms)
void
NoticeTime(const DeviceIntPtr dev, TimeStamp time)
{
+ currentTime = time;
lastDeviceEventTime[XIAllDevices].time = currentTime;
lastDeviceEventTime[dev->id].time = currentTime;
@@ -4785,8 +4786,8 @@ SetInputFocus(ClientPtr client,
depth++;
if (depth > focus->traceSize) {
focus->traceSize = depth + 1;
- focus->trace = realloc(focus->trace,
- focus->traceSize * sizeof(WindowPtr));
+ focus->trace = reallocarray(focus->trace, focus->traceSize,
+ sizeof(WindowPtr));
}
focus->traceGood = depth;
for (pWin = focusWin, depth--; pWin; pWin = pWin->parent, depth--)
diff --git a/xorg-server/dix/extension.c b/xorg-server/dix/extension.c
index 56e3abc14..e81f673b2 100644
--- a/xorg-server/dix/extension.c
+++ b/xorg-server/dix/extension.c
@@ -103,8 +103,7 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
return ((ExtensionEntry *) NULL);
}
i = NumExtensions;
- newexts = (ExtensionEntry **) realloc(extensions,
- (i + 1) * sizeof(ExtensionEntry *));
+ newexts = reallocarray(extensions, i + 1, sizeof(ExtensionEntry *));
if (!newexts) {
free((void *) ext->name);
dixFreePrivates(ext->devPrivates, PRIVATE_EXTENSION);
@@ -153,8 +152,7 @@ AddExtensionAlias(const char *alias, ExtensionEntry * ext)
if (!ext)
return FALSE;
- aliases = realloc(ext->aliases,
- (ext->num_aliases + 1) * sizeof(char *));
+ aliases = reallocarray(ext->aliases, ext->num_aliases + 1, sizeof(char *));
if (!aliases)
return FALSE;
ext->aliases = aliases;
diff --git a/xorg-server/dix/glyphcurs.c b/xorg-server/dix/glyphcurs.c
index eca6a4cb8..3ff6ae83e 100644
--- a/xorg-server/dix/glyphcurs.c
+++ b/xorg-server/dix/glyphcurs.c
@@ -78,7 +78,6 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm,
GCPtr pGC;
xRectangle rect;
PixmapPtr ppix;
- long nby;
char *pbits;
ChangeGCVal gcval[3];
unsigned char char2b[2];
@@ -88,8 +87,7 @@ ServerBitsFromGlyph(FontPtr pfont, unsigned ch, CursorMetricPtr cm,
char2b[1] = (unsigned char) (ch & 0xff);
pScreen = screenInfo.screens[0];
- nby = BitmapBytePad(cm->width) * (long) cm->height;
- pbits = calloc(1, nby);
+ pbits = calloc(BitmapBytePad(cm->width), cm->height);
if (!pbits)
return BadAlloc;
diff --git a/xorg-server/dix/grabs.c b/xorg-server/dix/grabs.c
index b92f1e7ce..2a307a2b9 100644
--- a/xorg-server/dix/grabs.c
+++ b/xorg-server/dix/grabs.c
@@ -594,10 +594,10 @@ DeletePassiveGrabFromList(GrabPtr pMinuendGrab)
i++;
if (!i)
return TRUE;
- deletes = malloc(i * sizeof(GrabPtr));
- adds = malloc(i * sizeof(GrabPtr));
- updates = malloc(i * sizeof(Mask **));
- details = malloc(i * sizeof(Mask *));
+ deletes = xallocarray(i, sizeof(GrabPtr));
+ adds = xallocarray(i, sizeof(GrabPtr));
+ updates = xallocarray(i, sizeof(Mask **));
+ details = xallocarray(i, sizeof(Mask *));
if (!deletes || !adds || !updates || !details) {
free(details);
free(updates);
diff --git a/xorg-server/dix/property.c b/xorg-server/dix/property.c
index ff7f31aa9..99608af72 100644
--- a/xorg-server/dix/property.c
+++ b/xorg-server/dix/property.c
@@ -136,8 +136,8 @@ ProcRotateProperties(ClientPtr client)
return rc;
atoms = (Atom *) &stuff[1];
- props = malloc(stuff->nAtoms * sizeof(PropertyPtr));
- saved = malloc(stuff->nAtoms * sizeof(PropertyRec));
+ props = xallocarray(stuff->nAtoms, sizeof(PropertyPtr));
+ saved = xallocarray(stuff->nAtoms, sizeof(PropertyRec));
if (!props || !saved) {
rc = BadAlloc;
goto out;
@@ -313,7 +313,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
/* do nothing */
}
else if (mode == PropModeAppend) {
- data = malloc((pProp->size + len) * sizeInBytes);
+ data = xallocarray(pProp->size + len, sizeInBytes);
if (!data)
return BadAlloc;
memcpy(data, pProp->data, pProp->size * sizeInBytes);
@@ -322,7 +322,7 @@ dixChangeWindowProperty(ClientPtr pClient, WindowPtr pWin, Atom property,
pProp->size += len;
}
else if (mode == PropModePrepend) {
- data = malloc(sizeInBytes * (len + pProp->size));
+ data = xallocarray(len + pProp->size, sizeInBytes);
if (!data)
return BadAlloc;
memcpy(data + totalSize, pProp->data, pProp->size * sizeInBytes);
@@ -581,7 +581,7 @@ ProcListProperties(ClientPtr client)
for (pProp = wUserProps(pWin); pProp; pProp = pProp->next)
numProps++;
- if (numProps && !(pAtoms = malloc(numProps * sizeof(Atom))))
+ if (numProps && !(pAtoms = xallocarray(numProps, sizeof(Atom))))
return BadAlloc;
numProps = 0;
diff --git a/xorg-server/dix/region.c b/xorg-server/dix/region.c
index 04e590170..fd7313990 100644
--- a/xorg-server/dix/region.c
+++ b/xorg-server/dix/region.c
@@ -1247,7 +1247,7 @@ RegionValidate(RegionPtr badreg, Bool *pOverlap)
if (sizeRI == numRI) {
/* Oops, allocate space for new region information */
sizeRI <<= 1;
- rit = (RegionInfo *) realloc(ri, sizeRI * sizeof(RegionInfo));
+ rit = (RegionInfo *) reallocarray(ri, sizeRI, sizeof(RegionInfo));
if (!rit)
goto bail;
ri = rit;
diff --git a/xorg-server/dix/resource.c b/xorg-server/dix/resource.c
index 964f0b306..af8e162bb 100644
--- a/xorg-server/dix/resource.c
+++ b/xorg-server/dix/resource.c
@@ -510,7 +510,7 @@ CreateNewResourceType(DeleteType deleteFunc, const char *name)
if (next & lastResourceClass)
return 0;
- types = realloc(resourceTypes, (next + 1) * sizeof(*resourceTypes));
+ types = reallocarray(resourceTypes, next + 1, sizeof(*resourceTypes));
if (!types)
return 0;
@@ -834,10 +834,10 @@ RebuildTable(int client)
*/
j = 2 * clientTable[client].buckets;
- tails = malloc(j * sizeof(ResourcePtr *));
+ tails = xallocarray(j, sizeof(ResourcePtr *));
if (!tails)
return;
- resources = malloc(j * sizeof(ResourcePtr));
+ resources = xallocarray(j, sizeof(ResourcePtr));
if (!resources) {
free(tails);
return;
diff --git a/xorg-server/dix/touch.c b/xorg-server/dix/touch.c
index 1eeed78bd..49d16ab37 100644
--- a/xorg-server/dix/touch.c
+++ b/xorg-server/dix/touch.c
@@ -101,7 +101,7 @@ TouchResizeQueue(ClientPtr client, void *closure)
* don't need to do it often */
size = dev->last.num_touches + dev->last.num_touches / 2 + 1;
- tmp = realloc(dev->last.touches, size * sizeof(*dev->last.touches));
+ tmp = reallocarray(dev->last.touches, size, sizeof(*dev->last.touches));
if (tmp) {
int j;
@@ -350,7 +350,7 @@ TouchBeginTouch(DeviceIntPtr dev, int sourceid, uint32_t touchid,
/* If we get here, then we've run out of touches: enlarge dev->touch and
* try again. */
- tmp = realloc(t->touches, (t->num_touches + 1) * sizeof(*ti));
+ tmp = reallocarray(t->touches, t->num_touches + 1, sizeof(*ti));
if (tmp) {
t->touches = tmp;
t->num_touches++;
@@ -547,8 +547,8 @@ TouchBuildDependentSpriteTrace(DeviceIntPtr dev, SpritePtr sprite)
return FALSE;
if (srcsprite->spriteTraceGood > sprite->spriteTraceSize) {
- trace = realloc(sprite->spriteTrace,
- srcsprite->spriteTraceSize * sizeof(*trace));
+ trace = reallocarray(sprite->spriteTrace,
+ srcsprite->spriteTraceSize, sizeof(*trace));
if (!trace) {
sprite->spriteTraceGood = 0;
return FALSE;
diff --git a/xorg-server/doc/Xserver-spec.xml b/xorg-server/doc/Xserver-spec.xml
index 4c344194d..72a544b55 100644
--- a/xorg-server/doc/Xserver-spec.xml
+++ b/xorg-server/doc/Xserver-spec.xml
@@ -1992,7 +1992,7 @@ regions, these blocks may need to be reallocated by your region
software. For instance, in the sample server, a RegionRec has some
header information and a pointer to a dynamically allocated rectangle
list. Periodically, the rectangle list needs to be expanded with
-Xrealloc(), whereupon the new pointer is remembered in the RegionRec.</para>
+realloc(), whereupon the new pointer is remembered in the RegionRec.</para>
<para>
Most of the region operations come in two forms: a function pointer in
the Screen structure, and a macro. The server can be compiled so that
@@ -2598,7 +2598,7 @@ VisualRec data structure along with other display characteristics like the
depth and other numbers.</para>
<para>
The allowable DepthRec's and VisualRec's are pointed to by fields in the ScreenRec.
-These are set up when InitOutput() is called; you should Xalloc() appropriate blocks
+These are set up when InitOutput() is called; you should malloc() appropriate blocks
or use static variables initialized to the correct values.</para>
</section>
<section>
@@ -3897,7 +3897,7 @@ for CT_NONE, etc. are in Xserver/include/gc.h.) This routine is
responsible for incrementing any necessary reference counts (e.g. for
a pixmap clip mask) for the new clipmask and freeing anything that
used to be in the GC's clipMask field. The lists of rectangles passed
-in can be freed with Xfree(), the regions can be destroyed with the
+in can be freed with free(), the regions can be destroyed with the
RegionDestroy field in the screen, and pixmaps can be destroyed by
calling the screen's DestroyPixmap function. DIX and MI code expect
what they pass in to this to be freed or otherwise inaccessible, and
@@ -5104,9 +5104,6 @@ mi and fb implementations.</para>
<row><entry><function>WaitForSomething</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
<row><entry><function>WindowExposures</function></entry><entry><literal>mi</literal></entry><entry><para>Window</para></entry></row>
<row><entry><function>WriteToClient</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>Xalloc</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>Xfree</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
-<row><entry><function>Xrealloc</function></entry><entry><literal>os</literal></entry><entry><para></para></entry></row>
</tbody>
</tgroup>
</table>
diff --git a/xorg-server/exa/exa_accel.c b/xorg-server/exa/exa_accel.c
index 5aa7d1078..b26d5c804 100644
--- a/xorg-server/exa/exa_accel.c
+++ b/xorg-server/exa/exa_accel.c
@@ -386,7 +386,7 @@ exaHWCopyNtoN(DrawablePtr pSrcDrawable,
exaGetDrawableDeltas(pSrcDrawable, pSrcPixmap, &src_off_x, &src_off_y);
exaGetDrawableDeltas(pDstDrawable, pDstPixmap, &dst_off_x, &dst_off_y);
- rects = malloc(nbox * sizeof(xRectangle));
+ rects = xallocarray(nbox, sizeof(xRectangle));
if (rects) {
int i;
@@ -626,7 +626,7 @@ exaPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
return;
}
- prect = malloc(sizeof(xRectangle) * npt);
+ prect = xallocarray(npt, sizeof(xRectangle));
for (i = 0; i < npt; i++) {
prect[i].x = ppt[i].x;
prect[i].y = ppt[i].y;
@@ -667,7 +667,7 @@ exaPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
return;
}
- prect = malloc(sizeof(xRectangle) * (npt - 1));
+ prect = xallocarray(npt - 1, sizeof(xRectangle));
x1 = ppt[0].x;
y1 = ppt[0].y;
/* If we have any non-horizontal/vertical, fall back. */
@@ -738,7 +738,7 @@ exaPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment * pSeg)
}
}
- prect = malloc(sizeof(xRectangle) * nseg);
+ prect = xallocarray(nseg, sizeof(xRectangle));
for (i = 0; i < nseg; i++) {
if (pSeg[i].x1 < pSeg[i].x2) {
prect[i].x = pSeg[i].x1;
diff --git a/xorg-server/exa/exa_glyphs.c b/xorg-server/exa/exa_glyphs.c
index 41f3694f2..cf21ea914 100644
--- a/xorg-server/exa/exa_glyphs.c
+++ b/xorg-server/exa/exa_glyphs.c
@@ -211,8 +211,8 @@ exaRealizeGlyphCaches(ScreenPtr pScreen, unsigned int format)
cache->picture = pPicture;
cache->picture->refcnt++;
- cache->hashEntries = malloc(sizeof(int) * cache->hashSize);
- cache->glyphs = malloc(sizeof(ExaCachedGlyphRec) * cache->size);
+ cache->hashEntries = xallocarray(cache->hashSize, sizeof(int));
+ cache->glyphs = xallocarray(cache->size, sizeof(ExaCachedGlyphRec));
cache->glyphCount = 0;
if (!cache->hashEntries || !cache->glyphs)
diff --git a/xorg-server/exa/exa_migration_mixed.c b/xorg-server/exa/exa_migration_mixed.c
index cf66327b3..7d3fca7c0 100644
--- a/xorg-server/exa/exa_migration_mixed.c
+++ b/xorg-server/exa/exa_migration_mixed.c
@@ -205,8 +205,8 @@ exaPrepareAccessReg_mixed(PixmapPtr pPixmap, int index, RegionPtr pReg)
/* Do we need to allocate our system buffer? */
if (!pExaPixmap->sys_ptr) {
- pExaPixmap->sys_ptr = malloc(pExaPixmap->sys_pitch *
- pPixmap->drawable.height);
+ pExaPixmap->sys_ptr = xallocarray(pExaPixmap->sys_pitch,
+ pPixmap->drawable.height);
if (!pExaPixmap->sys_ptr)
FatalError("EXA: malloc failed for size %d bytes\n",
pExaPixmap->sys_pitch * pPixmap->drawable.height);
diff --git a/xorg-server/fb/fbcopy.c b/xorg-server/fb/fbcopy.c
index 5bbabc39f..6af10ccf7 100644
--- a/xorg-server/fb/fbcopy.c
+++ b/xorg-server/fb/fbcopy.c
@@ -194,7 +194,7 @@ fbCopyNto1(DrawablePtr pSrcDrawable,
height = pbox->y2 - pbox->y1;
tmpStride = ((width + FB_STIP_MASK) >> FB_STIP_SHIFT);
- tmp = malloc(tmpStride * height * sizeof(FbStip));
+ tmp = xallocarray(tmpStride * height, sizeof(FbStip));
if (!tmp)
return;
diff --git a/xorg-server/fb/fbpict.c b/xorg-server/fb/fbpict.c
index c8378ad90..021f17883 100644
--- a/xorg-server/fb/fbpict.c
+++ b/xorg-server/fb/fbpict.c
@@ -124,7 +124,7 @@ fbGlyphs(CARD8 op,
pixman_glyph_cache_freeze (glyphCache);
if (n_glyphs > N_STACK_GLYPHS) {
- if (!(pglyphs = malloc (n_glyphs * sizeof (pixman_glyph_t))))
+ if (!(pglyphs = xallocarray(n_glyphs, sizeof(pixman_glyph_t))))
goto out;
}
diff --git a/xorg-server/glamor/Makefile.am b/xorg-server/glamor/Makefile.am
index db72cb11c..c48802999 100644
--- a/xorg-server/glamor/Makefile.am
+++ b/xorg-server/glamor/Makefile.am
@@ -14,7 +14,7 @@ libglamor_la_SOURCES = \
glamor_font.c \
glamor_font.h \
glamor_glx.c \
- glamor_glyphs.c \
+ glamor_composite_glyphs.c \
glamor_image.c \
glamor_lines.c \
glamor_segs.c \
diff --git a/xorg-server/glamor/glamor.c b/xorg-server/glamor/glamor.c
index 6f4f30927..807f28ebd 100644
--- a/xorg-server/glamor/glamor.c
+++ b/xorg-server/glamor/glamor.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2008 Intel Corporation
+ * Copyright © 2008,2011 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -23,7 +23,7 @@
* Authors:
* Eric Anholt <eric@anholt.net>
* Zhigang Gong <zhigang.gong@linux.intel.com>
- *
+ * Chad Versace <chad.versace@linux.intel.com>
*/
/** @file glamor.c
@@ -288,16 +288,6 @@ glamor_create_screen_resources(ScreenPtr screen)
ret = screen->CreateScreenResources(screen);
screen->CreateScreenResources = glamor_create_screen_resources;
- if (!glamor_glyphs_init(screen)) {
- ErrorF("Failed to initialize glyphs\n");
- ret = FALSE;
- }
-
- if (!glamor_realize_glyph_caches(screen)) {
- ErrorF("Failed to initialize glyph cache\n");
- ret = FALSE;
- }
-
return ret;
}
@@ -336,7 +326,11 @@ glamor_init(ScreenPtr screen, unsigned int flags)
{
glamor_screen_private *glamor_priv;
int gl_version;
+ int glsl_major, glsl_minor;
int max_viewport_size[2];
+ const char *shading_version_string;
+ int shading_version_offset;
+
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
if (flags & ~GLAMOR_VALID_FLAGS) {
@@ -380,14 +374,40 @@ glamor_init(ScreenPtr screen, unsigned int flags)
gl_version = epoxy_gl_version();
- /* Would be nice to have a cleaner test for GLSL 1.30 support,
- * but for now this should suffice
- */
- if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30)
- glamor_priv->glsl_version = 130;
- else
- glamor_priv->glsl_version = 120;
+ shading_version_string = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION);
+
+ if (!shading_version_string) {
+ LogMessage(X_WARNING,
+ "glamor%d: Failed to get GLSL version\n",
+ screen->myNum);
+ goto fail;
+ }
+
+ shading_version_offset = 0;
+ if (strncmp("OpenGL ES GLSL ES ", shading_version_string, 18) == 0)
+ shading_version_offset = 18;
+ if (sscanf(shading_version_string + shading_version_offset,
+ "%i.%i",
+ &glsl_major,
+ &glsl_minor) != 2) {
+ LogMessage(X_WARNING,
+ "glamor%d: Failed to parse GLSL version string %s\n",
+ screen->myNum, shading_version_string);
+ goto fail;
+ }
+ glamor_priv->glsl_version = glsl_major * 100 + glsl_minor;
+
+ if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
+ /* Force us back to the base version of our programs on an ES
+ * context, anyway. Basically glamor only uses desktop 1.20
+ * or 1.30 currently. 1.30's new features are also present in
+ * ES 3.0, but our glamor_program.c constructions use a lot of
+ * compatibility features (to reduce the diff between 1.20 and
+ * 1.30 programs).
+ */
+ glamor_priv->glsl_version = 120;
+ }
/* We'd like to require GL_ARB_map_buffer_range or
* GL_OES_map_buffer_range, since it offers more information to
@@ -479,6 +499,11 @@ glamor_init(ScreenPtr screen, unsigned int flags)
glamor_priv->saved_procs.block_handler = screen->BlockHandler;
screen->BlockHandler = _glamor_block_handler;
+ if (!glamor_composite_glyphs_init(screen)) {
+ ErrorF("Failed to initialize composite masks\n");
+ goto fail;
+ }
+
glamor_priv->saved_procs.create_gc = screen->CreateGC;
screen->CreateGC = glamor_create_gc;
@@ -520,10 +545,7 @@ glamor_init(ScreenPtr screen, unsigned int flags)
ps->CompositeRects = miCompositeRects;
glamor_priv->saved_procs.glyphs = ps->Glyphs;
- ps->Glyphs = glamor_glyphs;
-
- glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
- ps->UnrealizeGlyph = glamor_glyph_unrealize;
+ ps->Glyphs = glamor_composite_glyphs;
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
ps->CreatePicture = glamor_create_picture;
@@ -604,7 +626,7 @@ glamor_close_screen(ScreenPtr screen)
glamor_priv = glamor_get_screen_private(screen);
glamor_sync_close(screen);
- glamor_glyphs_fini(screen);
+ glamor_composite_glyphs_fini(screen);
screen->CloseScreen = glamor_priv->saved_procs.close_screen;
screen->CreateScreenResources =
glamor_priv->saved_procs.create_screen_resources;
@@ -625,7 +647,6 @@ glamor_close_screen(ScreenPtr screen)
ps->CreatePicture = glamor_priv->saved_procs.create_picture;
ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
ps->Glyphs = glamor_priv->saved_procs.glyphs;
- ps->UnrealizeGlyph = glamor_priv->saved_procs.unrealize_glyph;
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
screen_pixmap = screen->GetScreenPixmap(screen);
diff --git a/xorg-server/glamor/glamor.h b/xorg-server/glamor/glamor.h
index d07182d9e..0d57fff88 100644
--- a/xorg-server/glamor/glamor.h
+++ b/xorg-server/glamor/glamor.h
@@ -105,8 +105,6 @@ extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
extern _X_EXPORT uint32_t glamor_get_pixmap_texture(PixmapPtr pixmap);
-extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
-
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
unsigned int tex);
diff --git a/xorg-server/glamor/glamor_composite_glyphs.c b/xorg-server/glamor/glamor_composite_glyphs.c
new file mode 100644
index 000000000..39ed854bc
--- /dev/null
+++ b/xorg-server/glamor/glamor_composite_glyphs.c
@@ -0,0 +1,551 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. The copyright holders make no representations
+ * about the suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+#include <stdlib.h>
+#include "Xprintf.h"
+
+#include "glamor_priv.h"
+#include "glamor_transform.h"
+#include "glamor_transfer.h"
+
+#include <mipict.h>
+
+#define DEFAULT_ATLAS_DIM 1024
+
+static DevPrivateKeyRec glamor_glyph_private_key;
+
+struct glamor_glyph_private {
+ int16_t x;
+ int16_t y;
+ uint32_t serial;
+};
+
+struct glamor_glyph_atlas {
+ PixmapPtr atlas;
+ PictFormatPtr format;
+ int x, y;
+ int row_height;
+ int nglyph;
+ uint32_t serial;
+};
+
+static inline struct glamor_glyph_private *glamor_get_glyph_private(PixmapPtr pixmap) {
+ return dixLookupPrivate(&pixmap->devPrivates, &glamor_glyph_private_key);
+}
+
+static inline void
+glamor_copy_glyph(PixmapPtr glyph_pixmap,
+ DrawablePtr atlas_draw,
+ int16_t x,
+ int16_t y)
+{
+ DrawablePtr glyph_draw = &glyph_pixmap->drawable;
+ BoxRec box = {
+ .x1 = 0,
+ .y1 = 0,
+ .x2 = glyph_draw->width,
+ .y2 = glyph_draw->height,
+ };
+
+ if (glyph_pixmap->drawable.bitsPerPixel == atlas_draw->bitsPerPixel) {
+ glamor_upload_boxes((PixmapPtr) atlas_draw,
+ &box, 1,
+ 0, 0,
+ x, y,
+ glyph_pixmap->devPrivate.ptr,
+ glyph_pixmap->devKind);
+ } else {
+ GCPtr scratch_gc = GetScratchGC(atlas_draw->depth, atlas_draw->pScreen);
+ ChangeGCVal changes[2];
+ if (!scratch_gc)
+ return;
+
+ /* If we're dealing with 1-bit glyphs, we upload them to
+ * the cache as normal 8-bit alpha, since that's what GL
+ * can handle.
+ */
+ assert(glyph_draw->depth == 1);
+ assert(atlas_draw->depth == 8);
+
+ changes[0].val = 0xff;
+ changes[1].val = 0x00;
+ if (ChangeGC(NullClient, scratch_gc,
+ GCForeground|GCBackground, changes) != Success)
+ goto bail_gc;
+ ValidateGC(atlas_draw, scratch_gc);
+
+ (*scratch_gc->ops->CopyPlane)(glyph_draw,
+ atlas_draw,
+ scratch_gc,
+ 0, 0,
+ glyph_draw->width,
+ glyph_draw->height,
+ x, y, 0x1);
+
+ bail_gc:
+ FreeScratchGC(scratch_gc);
+ }
+}
+
+static Bool
+glamor_glyph_atlas_init(ScreenPtr screen, struct glamor_glyph_atlas *atlas)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ PictFormatPtr format = atlas->format;
+
+ atlas->atlas = glamor_create_pixmap(screen, glamor_priv->glyph_atlas_dim,
+ glamor_priv->glyph_atlas_dim, format->depth, 0);
+ atlas->x = 0;
+ atlas->y = 0;
+ atlas->row_height = 0;
+ atlas->serial++;
+ atlas->nglyph = 0;
+ return TRUE;
+}
+
+static Bool
+glamor_glyph_can_add(struct glamor_glyph_atlas *atlas, int dim, DrawablePtr glyph_draw)
+{
+ /* Step down */
+ if (atlas->x + glyph_draw->width > dim) {
+ atlas->x = 0;
+ atlas->y += atlas->row_height;
+ atlas->row_height = 0;
+ }
+
+ /* Check for overfull */
+ if (atlas->y + glyph_draw->height > dim)
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+glamor_glyph_add(struct glamor_glyph_atlas *atlas, DrawablePtr glyph_draw)
+{
+ PixmapPtr glyph_pixmap = (PixmapPtr) glyph_draw;
+ struct glamor_glyph_private *glyph_priv = glamor_get_glyph_private(glyph_pixmap);
+
+ glamor_copy_glyph(glyph_pixmap, &atlas->atlas->drawable, atlas->x, atlas->y);
+
+ glyph_priv->x = atlas->x;
+ glyph_priv->y = atlas->y;
+ glyph_priv->serial = atlas->serial;
+
+ atlas->x += glyph_draw->width;
+ if (atlas->row_height < glyph_draw->height)
+ atlas->row_height = glyph_draw->height;
+
+ atlas->nglyph++;
+
+ return TRUE;
+}
+
+static const glamor_facet glamor_facet_composite_glyphs_130 = {
+ .name = "composite_glyphs",
+ .version = 130,
+ .vs_vars = ("attribute vec4 primitive;\n"
+ "attribute vec2 source;\n"
+ "varying vec2 glyph_pos;\n"),
+ .vs_exec = (" vec2 pos = primitive.zw * vec2(gl_VertexID&1, (gl_VertexID&2)>>1);\n"
+ GLAMOR_POS(gl_Position, (primitive.xy + pos))
+ " glyph_pos = (source + pos) * ATLAS_DIM_INV;\n"),
+ .fs_vars = ("varying vec2 glyph_pos;\n"),
+ .fs_exec = (" vec4 mask = texture2D(atlas, glyph_pos);\n"),
+ .source_name = "source",
+ .locations = glamor_program_location_atlas,
+};
+
+static const glamor_facet glamor_facet_composite_glyphs_120 = {
+ .name = "composite_glyphs",
+ .vs_vars = ("attribute vec2 primitive;\n"
+ "attribute vec2 source;\n"
+ "varying vec2 glyph_pos;\n"),
+ .vs_exec = (GLAMOR_POS(gl_Position, primitive)
+ " glyph_pos = source.xy * ATLAS_DIM_INV;\n"),
+ .fs_vars = ("varying vec2 glyph_pos;\n"),
+ .fs_exec = (" vec4 mask = texture2D(atlas, glyph_pos);\n"),
+ .source_name = "source",
+ .locations = glamor_program_location_atlas,
+};
+
+static inline Bool
+glamor_glyph_use_130(glamor_screen_private *glamor_priv) {
+ return glamor_priv->glsl_version >= 130;
+}
+
+static Bool
+glamor_glyphs_init_facet(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ return asprintf(&glamor_priv->glyph_defines, "#define ATLAS_DIM_INV %20.18f\n", 1.0/glamor_priv->glyph_atlas_dim) > 0;
+}
+
+static void
+glamor_glyphs_fini_facet(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ free(glamor_priv->glyph_defines);
+}
+
+static void
+glamor_glyphs_flush(CARD8 op, PicturePtr src, PicturePtr dst,
+ glamor_program *prog,
+ struct glamor_glyph_atlas *atlas, int nglyph)
+{
+ DrawablePtr drawable = dst->pDrawable;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen);
+ PixmapPtr atlas_pixmap = atlas->atlas;
+ glamor_pixmap_private *atlas_priv = glamor_get_pixmap_private(atlas_pixmap);
+ glamor_pixmap_fbo *atlas_fbo = glamor_pixmap_fbo_at(atlas_priv, 0, 0);
+ PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
+ glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
+ int box_x, box_y;
+ int off_x, off_y;
+
+ glamor_put_vbo_space(drawable->pScreen);
+
+ glEnable(GL_SCISSOR_TEST);
+ glActiveTexture(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, atlas_fbo->tex);
+
+ for (;;) {
+ if (!glamor_use_program_render(prog, op, src, dst))
+ break;
+
+ glUniform1i(prog->atlas_uniform, 1);
+
+ glamor_pixmap_loop(pixmap_priv, box_x, box_y) {
+ BoxPtr box = RegionRects(dst->pCompositeClip);
+ int nbox = RegionNumRects(dst->pCompositeClip);
+
+ glamor_set_destination_drawable(drawable, box_x, box_y, TRUE, FALSE, prog->matrix_uniform, &off_x, &off_y);
+
+ /* Run over the clip list, drawing the glyphs
+ * in each box
+ */
+
+ while (nbox--) {
+ glScissor(box->x1 + off_x,
+ box->y1 + off_y,
+ box->x2 - box->x1,
+ box->y2 - box->y1);
+ box++;
+
+ if (glamor_glyph_use_130(glamor_priv))
+ glDrawArraysInstanced(GL_TRIANGLE_STRIP, 0, 4, nglyph);
+ else
+ glamor_glDrawArrays_GL_QUADS(glamor_priv, nglyph * 4);
+ }
+ }
+ if (prog->alpha != glamor_program_alpha_ca_first)
+ break;
+ prog++;
+ }
+
+ glDisable(GL_SCISSOR_TEST);
+
+ glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 0);
+ glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glDisable(GL_BLEND);
+}
+
+static GLshort *
+glamor_glyph_start(ScreenPtr screen, int count)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ GLshort *v;
+ char *vbo_offset;
+
+ /* Set up the vertex buffers for the font and destination */
+
+ if (glamor_glyph_use_130(glamor_priv)) {
+ v = glamor_get_vbo_space(screen, count * (6 * sizeof (GLshort)), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribDivisor(GLAMOR_VERTEX_POS, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 4, GL_SHORT, GL_FALSE,
+ 6 * sizeof (GLshort), vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ glVertexAttribDivisor(GLAMOR_VERTEX_SOURCE, 1);
+ glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_SHORT, GL_FALSE,
+ 6 * sizeof (GLshort), vbo_offset + 4 * sizeof (GLshort));
+ } else {
+ v = glamor_get_vbo_space(screen, count * (16 * sizeof (GLshort)), &vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
+ glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_SHORT, GL_FALSE,
+ 4 * sizeof (GLshort), vbo_offset);
+
+ glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
+ glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_SHORT, GL_FALSE,
+ 4 * sizeof (GLshort), vbo_offset + 2 * sizeof (GLshort));
+ }
+ return v;
+}
+
+static inline struct glamor_glyph_atlas *
+glamor_atlas_for_glyph(glamor_screen_private *glamor_priv, DrawablePtr drawable)
+{
+ if (drawable->depth == 32)
+ return glamor_priv->glyph_atlas_argb;
+ else
+ return glamor_priv->glyph_atlas_a;
+}
+
+void
+glamor_composite_glyphs(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr glyph_format,
+ INT16 x_src,
+ INT16 y_src, int nlist, GlyphListPtr list,
+ GlyphPtr *glyphs)
+{
+ int glyphs_queued;
+ GLshort *v = NULL;
+ DrawablePtr drawable = dst->pDrawable;
+ ScreenPtr screen = drawable->pScreen;
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+ glamor_program *prog = NULL;
+ PicturePtr glyph_pict = NULL;
+ DrawablePtr glyph_draw;
+ glamor_program_render *glyphs_program = &glamor_priv->glyphs_program;
+ struct glamor_glyph_atlas *glyph_atlas = NULL;
+ int x = 0, y = 0;
+ int n;
+ int glyph_atlas_dim = glamor_priv->glyph_atlas_dim;
+ int glyph_max_dim = glamor_priv->glyph_max_dim;
+ int nglyph = 0;
+ int screen_num = screen->myNum;
+
+ for (n = 0; n < nlist; n++)
+ nglyph += list[n].len;
+
+ glamor_make_current(glamor_priv);
+
+ glyphs_queued = 0;
+
+ while (nlist--) {
+ x += list->xOff;
+ y += list->yOff;
+ n = list->len;
+ list++;
+ while (n--) {
+ GlyphPtr glyph = *glyphs++;
+
+ /* Glyph not empty?
+ */
+ if (glyph->info.width && glyph->info.height) {
+ glamor_pixmap_private *glyph_pix_priv;
+
+ glyph_pict = GlyphPicture(glyph)[screen_num];
+ glyph_draw = glyph_pict->pDrawable;
+ glyph_pix_priv = glamor_get_pixmap_private((PixmapPtr) glyph_draw);
+
+ /* Need to draw with slow path?
+ */
+ if (_X_UNLIKELY(glyph_draw->width > glyph_max_dim ||
+ glyph_draw->height > glyph_max_dim ||
+ (glyph_pix_priv != 0 && glyph_pix_priv->type != GLAMOR_MEMORY)))
+ {
+ if (glyphs_queued) {
+ glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+ glyphs_queued = 0;
+ }
+ bail_one:
+ glamor_composite(op, src, glyph_pict, dst,
+ x_src + (x - glyph->info.x), (y - glyph->info.y),
+ 0, 0,
+ x - glyph->info.x, y - glyph->info.y,
+ glyph_draw->width, glyph_draw->height);
+ } else {
+ struct glamor_glyph_private *glyph_priv = glamor_get_glyph_private((PixmapPtr)(glyph_draw));
+ struct glamor_glyph_atlas *next_atlas = glamor_atlas_for_glyph(glamor_priv, glyph_draw);
+
+ /* Switching source glyph format?
+ */
+ if (_X_UNLIKELY(next_atlas != glyph_atlas)) {
+ if (glyphs_queued) {
+ glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+ glyphs_queued = 0;
+ }
+ glyph_atlas = next_atlas;
+ }
+
+ /* Glyph not cached in current atlas?
+ */
+ if (_X_UNLIKELY(glyph_priv->serial != glyph_atlas->serial)) {
+ if (!glamor_glyph_can_add(glyph_atlas, glyph_atlas_dim, glyph_draw)) {
+ if (glyphs_queued) {
+ glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+ glyphs_queued = 0;
+ }
+ if (glyph_atlas->atlas) {
+ (*screen->DestroyPixmap)(glyph_atlas->atlas);
+ glyph_atlas->atlas = NULL;
+ }
+ }
+ if (!glyph_atlas->atlas)
+ glamor_glyph_atlas_init(screen, glyph_atlas);
+ glamor_glyph_add(glyph_atlas, glyph_draw);
+ }
+
+ /* First glyph in the current atlas?
+ */
+ if (_X_UNLIKELY(glyphs_queued == 0)) {
+ if (glamor_glyph_use_130(glamor_priv))
+ prog = glamor_setup_program_render(op, src, glyph_pict, dst,
+ glyphs_program,
+ &glamor_facet_composite_glyphs_130,
+ glamor_priv->glyph_defines);
+ else
+ prog = glamor_setup_program_render(op, src, glyph_pict, dst,
+ glyphs_program,
+ &glamor_facet_composite_glyphs_120,
+ glamor_priv->glyph_defines);
+ if (!prog)
+ goto bail_one;
+ v = glamor_glyph_start(screen, nglyph);
+ }
+
+ /* Add the glyph
+ */
+
+ glyphs_queued++;
+ if (_X_LIKELY(glamor_glyph_use_130(glamor_priv))) {
+ v[0] = x - glyph->info.x;
+ v[1] = y - glyph->info.y;
+ v[2] = glyph_draw->width;
+ v[3] = glyph_draw->height;
+ v[4] = glyph_priv->x;
+ v[5] = glyph_priv->y;
+ v += 6;
+ } else {
+ v[0] = x - glyph->info.x;
+ v[1] = y - glyph->info.y;
+ v[2] = glyph_priv->x;
+ v[3] = glyph_priv->y;
+ v += 4;
+
+ v[0] = x - glyph->info.x + glyph_draw->width;
+ v[1] = y - glyph->info.y;
+ v[2] = glyph_priv->x + glyph_draw->width;
+ v[3] = glyph_priv->y;
+ v += 4;
+
+ v[0] = x - glyph->info.x + glyph_draw->width;
+ v[1] = y - glyph->info.y + glyph_draw->height;
+ v[2] = glyph_priv->x + glyph_draw->width;
+ v[3] = glyph_priv->y + glyph_draw->height;
+ v += 4;
+
+ v[0] = x - glyph->info.x;
+ v[1] = y - glyph->info.y + glyph_draw->height;
+ v[2] = glyph_priv->x;
+ v[3] = glyph_priv->y + glyph_draw->height;
+ v += 4;
+ }
+ }
+ }
+ x += glyph->info.xOff;
+ y += glyph->info.yOff;
+ nglyph--;
+ }
+ }
+
+ if (glyphs_queued)
+ glamor_glyphs_flush(op, src, dst, prog, glyph_atlas, glyphs_queued);
+
+ return;
+}
+
+static struct glamor_glyph_atlas *
+glamor_alloc_glyph_atlas(ScreenPtr screen, int depth, CARD32 f)
+{
+ PictFormatPtr format;
+ struct glamor_glyph_atlas *glyph_atlas;
+
+ format = PictureMatchFormat(screen, depth, f);
+ if (!format)
+ return NULL;
+ glyph_atlas = calloc (1, sizeof (struct glamor_glyph_atlas));
+ if (!glyph_atlas)
+ return NULL;
+ glyph_atlas->format = format;
+ glyph_atlas->serial = 1;
+
+ return glyph_atlas;
+}
+
+Bool
+glamor_composite_glyphs_init(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ if (!dixRegisterPrivateKey(&glamor_glyph_private_key, PRIVATE_PIXMAP, sizeof (struct glamor_glyph_private)))
+ return FALSE;
+
+ /* Make glyph atlases of a reasonable size, but no larger than the maximum
+ * supported by the hardware
+ */
+ glamor_priv->glyph_atlas_dim = MIN(DEFAULT_ATLAS_DIM, glamor_priv->max_fbo_size);
+
+ /* Don't stick huge glyphs in the atlases */
+ glamor_priv->glyph_max_dim = glamor_priv->glyph_atlas_dim / 8;
+
+ glamor_priv->glyph_atlas_a = glamor_alloc_glyph_atlas(screen, 8, PICT_a8);
+ if (!glamor_priv->glyph_atlas_a)
+ return FALSE;
+ glamor_priv->glyph_atlas_argb = glamor_alloc_glyph_atlas(screen, 32, PICT_a8r8g8b8);
+ if (!glamor_priv->glyph_atlas_argb) {
+ free (glamor_priv->glyph_atlas_a);
+ return FALSE;
+ }
+ if (!glamor_glyphs_init_facet(screen))
+ return FALSE;
+ return TRUE;
+}
+
+static void
+glamor_free_glyph_atlas(struct glamor_glyph_atlas *atlas)
+{
+ if (!atlas)
+ return;
+ if (atlas->atlas)
+ FreePicture(atlas->atlas, 0);
+ free (atlas);
+}
+
+void
+glamor_composite_glyphs_fini(ScreenPtr screen)
+{
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
+
+ glamor_glyphs_fini_facet(screen);
+ glamor_free_glyph_atlas(glamor_priv->glyph_atlas_a);
+ glamor_free_glyph_atlas(glamor_priv->glyph_atlas_argb);
+}
diff --git a/xorg-server/glamor/glamor_compositerects.c b/xorg-server/glamor/glamor_compositerects.c
index e188d8a3f..885a6c065 100644
--- a/xorg-server/glamor/glamor_compositerects.c
+++ b/xorg-server/glamor/glamor_compositerects.c
@@ -57,7 +57,7 @@ _pixman_region_init_clipped_rectangles(pixman_region16_t * region,
unsigned int i, j;
if (num_rects > ARRAY_SIZE(stack_boxes)) {
- boxes = malloc(sizeof(pixman_box16_t) * num_rects);
+ boxes = xallocarray(num_rects, sizeof(pixman_box16_t));
if (boxes == NULL)
return FALSE;
}
diff --git a/xorg-server/glamor/glamor_copy.c b/xorg-server/glamor/glamor_copy.c
index 75fe8a700..028acf239 100644
--- a/xorg-server/glamor/glamor_copy.c
+++ b/xorg-server/glamor/glamor_copy.c
@@ -53,7 +53,7 @@ static const glamor_facet glamor_facet_copyarea = {
.vs_exec = (GLAMOR_POS(gl_Position, primitive.xy)
" fill_pos = (fill_offset + primitive.xy) * fill_size_inv;\n"),
.fs_exec = " gl_FragColor = texture2D(sampler, fill_pos);\n",
- .locations = glamor_program_location_fill,
+ .locations = glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_copyarea,
};
@@ -140,7 +140,7 @@ static const glamor_facet glamor_facet_copyplane = {
" gl_FragColor = fg;\n"
" else\n"
" gl_FragColor = bg;\n"),
- .locations = glamor_program_location_fill|glamor_program_location_fg|glamor_program_location_bg|glamor_program_location_bitplane,
+ .locations = glamor_program_location_fillsamp|glamor_program_location_fillpos|glamor_program_location_fg|glamor_program_location_bg|glamor_program_location_bitplane,
.use = use_copyplane,
};
@@ -212,7 +212,7 @@ glamor_copy_cpu_fbo(DrawablePtr src,
if (gc && gc->alu != GXcopy)
goto bail;
- if (gc && !glamor_pm_is_solid(dst, gc->planemask))
+ if (gc && !glamor_pm_is_solid(gc->depth, gc->planemask))
goto bail;
glamor_make_current(glamor_priv);
@@ -262,7 +262,7 @@ glamor_copy_fbo_cpu(DrawablePtr src,
if (gc && gc->alu != GXcopy)
goto bail;
- if (gc && !glamor_pm_is_solid(dst, gc->planemask))
+ if (gc && !glamor_pm_is_solid(gc->depth, gc->planemask))
goto bail;
glamor_make_current(glamor_priv);
@@ -319,7 +319,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
glamor_make_current(glamor_priv);
- if (gc && !glamor_set_planemask(dst_pixmap, gc->planemask))
+ if (gc && !glamor_set_planemask(gc->depth, gc->planemask))
goto bail_ctx;
if (!glamor_set_alu(screen, gc ? gc->alu : GXcopy))
@@ -338,7 +338,7 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src,
if (!prog->prog) {
if (!glamor_build_program(screen, prog,
- copy_facet, NULL))
+ copy_facet, NULL, NULL, NULL))
goto bail_ctx;
}
@@ -419,7 +419,6 @@ glamor_copy_fbo_fbo_temp(DrawablePtr src,
{
ScreenPtr screen = dst->pScreen;
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
- PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
PixmapPtr tmp_pixmap;
BoxRec bounds;
int n;
@@ -434,7 +433,7 @@ glamor_copy_fbo_fbo_temp(DrawablePtr src,
*/
glamor_make_current(glamor_priv);
- if (gc && !glamor_set_planemask(dst_pixmap, gc->planemask))
+ if (gc && !glamor_set_planemask(gc->depth, gc->planemask))
goto bail_ctx;
if (!glamor_set_alu(screen, gc ? gc->alu : GXcopy))
diff --git a/xorg-server/glamor/glamor_core.c b/xorg-server/glamor/glamor_core.c
index 55174541f..965024e68 100644
--- a/xorg-server/glamor/glamor_core.c
+++ b/xorg-server/glamor/glamor_core.c
@@ -35,7 +35,7 @@
#include "glamor_priv.h"
-const Bool
+Bool
glamor_get_drawable_location(const DrawablePtr drawable)
{
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
diff --git a/xorg-server/glamor/glamor_dash.c b/xorg-server/glamor/glamor_dash.c
index 4281ff0a8..101228e40 100644
--- a/xorg-server/glamor/glamor_dash.c
+++ b/xorg-server/glamor/glamor_dash.c
@@ -170,7 +170,7 @@ glamor_dash_setup(DrawablePtr drawable, GCPtr gc)
if (!prog->prog) {
if (!glamor_build_program(screen, prog,
&glamor_facet_double_dash_lines,
- NULL))
+ NULL, NULL, NULL))
goto bail;
}
diff --git a/xorg-server/glamor/glamor_egl.c b/xorg-server/glamor/glamor_egl.c
index 6033780f8..dc5456118 100644
--- a/xorg-server/glamor/glamor_egl.c
+++ b/xorg-server/glamor/glamor_egl.c
@@ -595,6 +595,7 @@ glamor_egl_close_screen(ScreenPtr screen)
return screen->CloseScreen(screen);
}
+#ifdef DRI3
static int
glamor_dri3_open_client(ClientPtr client,
ScreenPtr screen,
@@ -651,12 +652,12 @@ static dri3_screen_info_rec glamor_dri3_info = {
.pixmap_from_fd = glamor_pixmap_from_fd,
.fd_from_pixmap = glamor_fd_from_pixmap,
};
+#endif /* DRI3 */
void
glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
- glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
struct glamor_egl_screen_private *glamor_egl =
glamor_egl_get_screen_private(scrn);
@@ -668,7 +669,9 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
glamor_ctx->make_current = glamor_egl_make_current;
+#ifdef DRI3
if (glamor_egl->dri3_capable) {
+ glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
/* Tell the core that we have the interfaces for import/export
* of pixmaps.
*/
@@ -691,6 +694,7 @@ glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
}
}
}
+#endif
}
static void
diff --git a/xorg-server/glamor/glamor_glyphs.c b/xorg-server/glamor/glamor_glyphs.c
deleted file mode 100644
index 2cf0c7d16..000000000
--- a/xorg-server/glamor/glamor_glyphs.c
+++ /dev/null
@@ -1,1769 +0,0 @@
-/*
- * Copyright © 2008 Red Hat, Inc.
- * Partly based on code Copyright © 2000 SuSE, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of Red Hat not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. Red Hat makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * Red Hat DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Red Hat
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Permission to use, copy, modify, distribute, and sell this software and its
- * documentation for any purpose is hereby granted without fee, provided that
- * the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of SuSE not be used in advertising or
- * publicity pertaining to distribution of the software without specific,
- * written prior permission. SuSE makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
- * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
- * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: Owen Taylor <otaylor@fishsoup.net>
- * Based on code by: Keith Packard
- */
-
-#include <stdlib.h>
-
-#include "glamor_priv.h"
-
-#include <mipict.h>
-
-#if DEBUG_GLYPH_CACHE
-#define DBG_GLYPH_CACHE(a) ErrorF a
-#else
-#define DBG_GLYPH_CACHE(a)
-#endif
-
-/* Width of the pixmaps we use for the caches; this should be less than
- * max texture size of the driver; this may need to actually come from
- * the driver.
- */
-
-/* Maximum number of glyphs we buffer on the stack before flushing
- * rendering to the mask or destination surface.
- */
-#define GLYPH_BUFFER_SIZE 1024
-
-typedef struct {
- PicturePtr source;
- glamor_composite_rect_t rects[GLYPH_BUFFER_SIZE + 4];
- int count;
-} glamor_glyph_buffer_t;
-
-struct glamor_glyph {
- glamor_glyph_cache_t *cache;
- uint16_t x, y;
- uint16_t size, pos;
- unsigned long long left_x1_map, left_x2_map;
- unsigned long long right_x1_map, right_x2_map; /* Use to check real intersect or not. */
- Bool has_edge_map;
- Bool cached;
-};
-
-typedef enum {
- GLAMOR_GLYPH_SUCCESS, /* Glyph added to render buffer */
- GLAMOR_GLYPH_FAIL, /* out of memory, etc */
- GLAMOR_GLYPH_NEED_FLUSH, /* would evict a glyph already in the buffer */
-} glamor_glyph_cache_result_t;
-
-#define NeedsComponent(f) (PICT_FORMAT_A(f) != 0 && PICT_FORMAT_RGB(f) != 0)
-static DevPrivateKeyRec glamor_glyph_key;
-
-static inline struct glamor_glyph *
-glamor_glyph_get_private(ScreenPtr screen, GlyphPtr glyph)
-{
- struct glamor_glyph *privates = (struct glamor_glyph*)glyph->devPrivates;
-
- return &privates[screen->myNum];
-}
-
-/*
- * Mask cache is located at the corresponding cache picture's last row.
- * and is deadicated for the mask picture when do the glyphs_via_mask.
- *
- * As we split the glyphs list according to its overlapped or non-overlapped,
- * we can reduce the length of glyphs to do the glyphs_via_mask to 2 or 3
- * glyphs one time for most cases. Thus it give us a case to allocate a
- * small portion of the corresponding cache directly as the mask picture.
- * Then we can rendering the glyphs to this mask picture, and latter we
- * can accumulate the second steps, composite the mask to the dest with
- * the other non-overlapped glyphs's rendering process.
- * Another major benefit is we now only need to clear a relatively small mask
- * region then before. It also make us implement a bunch mask picture clearing
- * algorithm to avoid too frequently small region clearing.
- *
- * If there is no any overlapping, this method will not get performance gain.
- * If there is some overlapping, then this algorithm can get about 15% performance
- * gain.
- */
-
-static void
-clear_mask_cache_bitmap(glamor_glyph_mask_cache_t *maskcache,
- unsigned int clear_mask_bits)
-{
- unsigned int i = 0;
- BoxRec box[MASK_CACHE_WIDTH];
- int box_cnt = 0;
-
- assert((clear_mask_bits & ~MASK_CACHE_MASK) == 0);
- for (i = 0; i < MASK_CACHE_WIDTH; i++) {
- if (clear_mask_bits & (1 << i)) {
- box[box_cnt].x1 = maskcache->mcache[i].x;
- box[box_cnt].x2 = maskcache->mcache[i].x + MASK_CACHE_MAX_SIZE;
- box[box_cnt].y1 = maskcache->mcache[i].y;
- box[box_cnt].y2 = maskcache->mcache[i].y + MASK_CACHE_MAX_SIZE;
- box_cnt++;
- }
- }
- glamor_solid_boxes(maskcache->pixmap, box, box_cnt, 0);
- maskcache->cleared_bitmap |= clear_mask_bits;
-}
-
-static void
-clear_mask_cache(glamor_glyph_mask_cache_t *maskcache)
-{
- int x = 0;
- int cnt = MASK_CACHE_WIDTH;
- unsigned int i = 0;
- struct glamor_glyph_mask_cache_entry *mce;
-
- glamor_solid(maskcache->pixmap, 0, CACHE_PICTURE_SIZE, CACHE_PICTURE_SIZE,
- MASK_CACHE_MAX_SIZE, 0);
- mce = &maskcache->mcache[0];
- while (cnt--) {
- mce->width = 0;
- mce->height = 0;
- mce->x = x;
- mce->y = CACHE_PICTURE_SIZE;
- mce->idx = i++;
- x += MASK_CACHE_MAX_SIZE;
- mce++;
- }
- maskcache->free_bitmap = MASK_CACHE_MASK;
- maskcache->cleared_bitmap = MASK_CACHE_MASK;
-}
-
-static int
-find_continuous_bits(unsigned int bits, int bits_cnt, unsigned int *pbits_mask)
-{
- int idx = 0;
- unsigned int bits_mask;
-
- bits_mask = ((1LL << bits_cnt) - 1);
-
- if (_X_UNLIKELY(bits_cnt > 56)) {
- while (bits) {
- if ((bits & bits_mask) == bits_mask) {
- *pbits_mask = bits_mask << idx;
- return idx;
- }
- bits >>= 1;
- idx++;
- }
- }
- else {
- idx = __fls(bits);
- while (bits) {
- unsigned int temp_bits;
-
- temp_bits = bits_mask << (idx - bits_cnt + 1);
- if ((bits & temp_bits) == temp_bits) {
- *pbits_mask = temp_bits;
- return (idx - bits_cnt + 1);
- }
- /* Find first zero. And clear the tested bit. */
- bits &= ~(1LL << idx);
- idx = __fls(~bits);
- bits &= ~((1LL << idx) - 1);
- idx--;
- }
- }
- return -1;
-}
-
-static struct glamor_glyph_mask_cache_entry *
-get_mask_cache(glamor_glyph_mask_cache_t *maskcache, int blocks)
-{
- int free_cleared_bit, idx = -1;
- int retry_cnt = 0;
- unsigned int bits_mask = 0;
-
- if (maskcache->free_bitmap == 0)
- return NULL;
- retry:
- free_cleared_bit = maskcache->free_bitmap & maskcache->cleared_bitmap;
- if (free_cleared_bit && blocks == 1) {
- idx = __fls(free_cleared_bit);
- bits_mask = 1 << idx;
- }
- else if (free_cleared_bit && blocks > 1) {
- idx = find_continuous_bits(free_cleared_bit, blocks, &bits_mask);
- }
-
- if (idx < 0) {
- clear_mask_cache_bitmap(maskcache, maskcache->free_bitmap);
- if (retry_cnt++ > 2)
- return NULL;
- goto retry;
- }
-
- maskcache->cleared_bitmap &= ~bits_mask;
- maskcache->free_bitmap &= ~bits_mask;
- DEBUGF("get idx %d free %x clear %x \n",
- idx, maskcache->free_bitmap, maskcache->cleared_bitmap);
- return &maskcache->mcache[idx];
-}
-
-static void
-put_mask_cache_bitmap(glamor_glyph_mask_cache_t *maskcache,
- unsigned int bitmap)
-{
- maskcache->free_bitmap |= bitmap;
- DEBUGF("put bitmap %x free %x clear %x \n",
- bitmap, maskcache->free_bitmap, maskcache->cleared_bitmap);
-}
-
-static void
-glamor_unrealize_glyph_caches(ScreenPtr pScreen)
-{
- glamor_screen_private *glamor = glamor_get_screen_private(pScreen);
- int i;
-
- if (!glamor->glyph_caches_realized)
- return;
-
- for (i = 0; i < GLAMOR_NUM_GLYPH_CACHE_FORMATS; i++) {
- glamor_glyph_cache_t *cache = &glamor->glyphCaches[i];
-
- if (cache->picture)
- FreePicture(cache->picture, 0);
-
- if (cache->glyphs)
- free(cache->glyphs);
-
- if (glamor->mask_cache[i])
- free(glamor->mask_cache[i]);
- }
- glamor->glyph_caches_realized = FALSE;
-}
-
-void
-glamor_glyphs_fini(ScreenPtr pScreen)
-{
- glamor_unrealize_glyph_caches(pScreen);
-}
-
-/* All caches for a single format share a single pixmap for glyph storage,
- * allowing mixing glyphs of different sizes without paying a penalty
- * for switching between source pixmaps. (Note that for a size of font
- * right at the border between two sizes, we might be switching for almost
- * every glyph.)
- *
- * This function allocates the storage pixmap, and then fills in the
- * rest of the allocated structures for all caches with the given format.
- */
-
-Bool
-glamor_realize_glyph_caches(ScreenPtr pScreen)
-{
- glamor_screen_private *glamor = glamor_get_screen_private(pScreen);
-
- unsigned int formats[] = {
- PIXMAN_a8,
- PIXMAN_a8r8g8b8,
- };
- int i;
-
- if (glamor->glyph_caches_realized)
- return TRUE;
-
- memset(glamor->glyphCaches, 0, sizeof(glamor->glyphCaches));
-
- for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
- glamor_glyph_cache_t *cache = &glamor->glyphCaches[i];
- PixmapPtr pixmap;
- PicturePtr picture;
- XID component_alpha;
- int depth = PIXMAN_FORMAT_DEPTH(formats[i]);
- int error;
- PictFormatPtr pPictFormat =
- PictureMatchFormat(pScreen, depth, formats[i]);
- if (!pPictFormat)
- goto bail;
-
- /* Now allocate the pixmap and picture */
- pixmap = pScreen->CreatePixmap(pScreen,
- CACHE_PICTURE_SIZE,
- CACHE_PICTURE_SIZE + MASK_CACHE_MAX_SIZE,
- depth, GLAMOR_CREATE_NO_LARGE);
- if (!pixmap)
- goto bail;
-
- component_alpha = NeedsComponent(pPictFormat->format);
- picture = CreatePicture(0, &pixmap->drawable, pPictFormat,
- CPComponentAlpha, &component_alpha,
- serverClient, &error);
-
- pScreen->DestroyPixmap(pixmap);
- if (!picture)
- goto bail;
-
- ValidatePicture(picture);
-
- cache->picture = picture;
- cache->glyphs = calloc(sizeof(GlyphPtr), GLYPH_CACHE_SIZE);
- if (!cache->glyphs)
- goto bail;
-
- cache->evict = rand() % GLYPH_CACHE_SIZE;
- glamor->mask_cache[i] = calloc(1, sizeof(*glamor->mask_cache[i]));
- glamor->mask_cache[i]->pixmap = pixmap;
- clear_mask_cache(glamor->mask_cache[i]);
- }
- assert(i == GLAMOR_NUM_GLYPH_CACHE_FORMATS);
-
- glamor->glyph_caches_realized = TRUE;
- return TRUE;
-
- bail:
- glamor_unrealize_glyph_caches(pScreen);
- return FALSE;
-}
-
-/**
- * Called by glamor_create_screen_resources() to set up the glyph cache.
- *
- * This was previously required to be called by the drivers, but not
- * as of the xserver 1.16 ABI.
- */
-Bool
-glamor_glyphs_init(ScreenPtr pScreen)
-{
- if (!dixRegisterPrivateKey(&glamor_glyph_key,
- PRIVATE_GLYPH,
- screenInfo.numScreens * sizeof(struct glamor_glyph)))
- return FALSE;
-
- return TRUE;
-}
-
-/* The most efficient thing to way to upload the glyph to the screen
- * is to use CopyArea; glamor pixmaps are always offscreen.
- */
-static void
-glamor_glyph_cache_upload_glyph(ScreenPtr screen,
- glamor_glyph_cache_t *cache,
- GlyphPtr glyph, int x, int y)
-{
- PicturePtr pGlyphPicture = GlyphPicture(glyph)[screen->myNum];
- PixmapPtr pGlyphPixmap = (PixmapPtr) pGlyphPicture->pDrawable;
- PixmapPtr pCachePixmap = (PixmapPtr) cache->picture->pDrawable;
- PixmapPtr scratch;
- BoxRec box;
- GCPtr gc;
-
- gc = GetScratchGC(pCachePixmap->drawable.depth, screen);
- if (!gc)
- return;
-
- ValidateGC(&pCachePixmap->drawable, gc);
-
- scratch = pGlyphPixmap;
- if (pGlyphPixmap->drawable.depth != pCachePixmap->drawable.depth) {
-
- scratch = glamor_create_pixmap(screen,
- glyph->info.width,
- glyph->info.height,
- pCachePixmap->drawable.depth, 0);
- if (scratch) {
- PicturePtr picture;
- int error;
-
- picture =
- CreatePicture(0,
- &scratch->drawable,
- PictureMatchFormat
- (screen,
- pCachePixmap->drawable.depth,
- cache->picture->format),
- 0, NULL, serverClient, &error);
- if (picture) {
- ValidatePicture(picture);
- glamor_composite(PictOpSrc,
- pGlyphPicture,
- NULL, picture,
- 0, 0, 0, 0, 0,
- 0, glyph->info.width, glyph->info.height);
- FreePicture(picture, 0);
- }
- }
- else {
- scratch = pGlyphPixmap;
- }
- }
-
- box.x1 = x;
- box.y1 = y;
- box.x2 = x + glyph->info.width;
- box.y2 = y + glyph->info.height;
- glamor_copy(&scratch->drawable,
- &pCachePixmap->drawable, NULL,
- &box, 1, -x, -y, FALSE, FALSE, 0, NULL);
- if (scratch != pGlyphPixmap)
- screen->DestroyPixmap(scratch);
-
- FreeScratchGC(gc);
-}
-
-void
-glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph)
-{
- struct glamor_glyph *priv;
-
- /* Use Lookup in case we have not attached to this glyph. */
- priv = glamor_glyph_get_private(screen, glyph);
-
- if (priv->cached)
- priv->cache->glyphs[priv->pos] = NULL;
-}
-
-/* Cut and paste from render/glyph.c - probably should export it instead */
-static void
-glamor_glyph_extents(int nlist,
- GlyphListPtr list, GlyphPtr *glyphs, BoxPtr extents)
-{
- int x1, x2, y1, y2;
- int x, y, n;
-
- x1 = y1 = MAXSHORT;
- x2 = y2 = MINSHORT;
- x = y = 0;
- while (nlist--) {
- x += list->xOff;
- y += list->yOff;
- n = list->len;
- list++;
- while (n--) {
- GlyphPtr glyph = *glyphs++;
- int v;
-
- v = x - glyph->info.x;
- if (v < x1)
- x1 = v;
- v += glyph->info.width;
- if (v > x2)
- x2 = v;
-
- v = y - glyph->info.y;
- if (v < y1)
- y1 = v;
- v += glyph->info.height;
- if (v > y2)
- y2 = v;
-
- x += glyph->info.xOff;
- y += glyph->info.yOff;
- }
- }
-
- extents->x1 = x1 < MINSHORT ? MINSHORT : x1;
- extents->x2 = x2 > MAXSHORT ? MAXSHORT : x2;
- extents->y1 = y1 < MINSHORT ? MINSHORT : y1;
- extents->y2 = y2 > MAXSHORT ? MAXSHORT : y2;
-}
-
-static void
-glamor_glyph_priv_get_edge_map(GlyphPtr glyph, struct glamor_glyph *priv,
- PicturePtr glyph_picture)
-{
- PixmapPtr glyph_pixmap = (PixmapPtr) glyph_picture->pDrawable;
- int j;
- unsigned long long left_x1_map = 0, left_x2_map = 0;
- unsigned long long right_x1_map = 0, right_x2_map = 0;
- int bitsPerPixel;
- int stride;
- void *bits;
- int width;
- unsigned int left_x1_data = 0, left_x2_data = 0;
- unsigned int right_x1_data = 0, right_x2_data = 0;
-
- bitsPerPixel = glyph_pixmap->drawable.bitsPerPixel;
- stride = glyph_pixmap->devKind;
- bits = glyph_pixmap->devPrivate.ptr;
- width = glyph->info.width;
-
- if (glyph_pixmap->drawable.width < 2
- || !(glyph_pixmap->drawable.depth == 8
- || glyph_pixmap->drawable.depth == 1
- || glyph_pixmap->drawable.depth == 32)) {
- priv->has_edge_map = FALSE;
- return;
- }
-
- left_x1_map = left_x2_map = 0;
- right_x1_map = right_x2_map = 0;
-
- for (j = 0; j < glyph_pixmap->drawable.height; j++) {
- if (bitsPerPixel == 8) {
- unsigned char *data;
-
- data = (unsigned char *) ((unsigned char *) bits + stride * j);
- left_x1_data = *data++;
- left_x2_data = *data;
- data =
- (unsigned char *) ((unsigned char *) bits + stride * j + width -
- 2);
- right_x1_data = *data++;
- right_x2_data = *data;
- }
- else if (bitsPerPixel == 32) {
- left_x1_data = *((unsigned int *) bits + stride / 4 * j);
- left_x2_data = *((unsigned int *) bits + stride / 4 * j + 1);
- right_x1_data =
- *((unsigned int *) bits + stride / 4 * j + width - 2);
- right_x2_data =
- *((unsigned int *) bits + stride / 4 * j + width - 1);
- }
- else if (bitsPerPixel == 1) {
- unsigned char temp;
-
- temp = *((unsigned char *) glyph_pixmap->devPrivate.ptr
- + glyph_pixmap->devKind * j) & 0x3;
- left_x1_data = temp & 0x1;
- left_x2_data = temp & 0x2;
-
- temp = *((unsigned char *) glyph_pixmap->devPrivate.ptr
- + glyph_pixmap->devKind * j
- + (glyph_pixmap->drawable.width - 2) / 8);
- right_x1_data = temp
- & (1 << ((glyph_pixmap->drawable.width - 2) % 8));
- temp = *((unsigned char *) glyph_pixmap->devPrivate.ptr
- + glyph_pixmap->devKind * j
- + (glyph_pixmap->drawable.width - 1) / 8);
- right_x2_data = temp
- & (1 << ((glyph_pixmap->drawable.width - 1) % 8));
- }
- left_x1_map |= (left_x1_data != 0) << j;
- left_x2_map |= (left_x2_data != 0) << j;
- right_x1_map |= (right_x1_data != 0) << j;
- right_x2_map |= (right_x2_data != 0) << j;
- }
-
- priv->left_x1_map = left_x1_map;
- priv->left_x2_map = left_x2_map;
- priv->right_x1_map = right_x1_map;
- priv->right_x2_map = right_x2_map;
- priv->has_edge_map = TRUE;
- return;
-}
-
-/**
- * Returns TRUE if the glyphs in the lists intersect. Only checks based on
- * bounding box, which appears to be good enough to catch most cases at least.
- */
-
-#define INTERSECTED_TYPE_MASK 1
-#define NON_INTERSECTED 0
-#define INTERSECTED 1
-
-struct glamor_glyph_list {
- int nlist;
- GlyphListPtr list;
- GlyphPtr *glyphs;
- int type;
-};
-
-static Bool
-glyph_new_fixed_list(struct glamor_glyph_list *fixed_list,
- GlyphPtr *cur_glyphs,
- GlyphPtr ** head_glyphs,
- GlyphListPtr cur_list,
- int cur_pos, int cur_x, int cur_y,
- int x1, int y1, int x2, int y2,
- GlyphListPtr *head_list,
- int *head_pos,
- int *head_x,
- int *head_y, int *fixed_cnt, int type, BoxPtr prev_extents)
-{
- int x_off = 0;
- int y_off = 0;
- int n_off = 0;
- int list_cnt;
-
- if (type == NON_INTERSECTED) {
- if (x1 < prev_extents->x2 && x2 > prev_extents->x1
- && y1 < prev_extents->y2 && y2 > prev_extents->y1)
- return FALSE;
- x_off = (*(cur_glyphs - 1))->info.xOff;
- y_off = (*(cur_glyphs - 1))->info.yOff;
- n_off = 1;
- }
-
- list_cnt = cur_list - *head_list + 1;
- if (cur_pos <= n_off) {
- DEBUGF("break at %d n_off %d\n", cur_pos, n_off);
- list_cnt--;
- if (cur_pos < n_off) {
- /* we overlap with previous list's last glyph. */
- x_off += cur_list->xOff;
- y_off += cur_list->yOff;
- cur_list--;
- cur_pos = cur_list->len;
- if (cur_pos <= n_off) {
- list_cnt--;
- }
- }
- }
- DEBUGF("got %d lists\n", list_cnt);
- if (list_cnt != 0) {
- fixed_list->list = malloc(list_cnt * sizeof(*cur_list));
- memcpy(fixed_list->list, *head_list, list_cnt * sizeof(*cur_list));
- fixed_list->list[0].xOff = *head_x;
- fixed_list->list[0].yOff = *head_y;
- fixed_list->glyphs = *head_glyphs;
- fixed_list->type = type & INTERSECTED_TYPE_MASK;
- fixed_list->nlist = list_cnt;
- if (cur_list != *head_list) {
- fixed_list->list[0].len = (*head_list)->len - *head_pos;
- if (cur_pos != n_off)
- fixed_list->list[list_cnt - 1].len = cur_pos - n_off;
- }
- else
- fixed_list->list[0].len = cur_pos - *head_pos - n_off;
- (*fixed_cnt)++;
- }
-
- if (type <= INTERSECTED) {
- *head_list = cur_list;
- *head_pos = cur_pos - n_off;
- *head_x = cur_x - x_off;
- *head_y = cur_y - y_off;
- *head_glyphs = cur_glyphs - n_off;
- }
- return TRUE;
-}
-
-/*
- * This function detects glyph lists's overlapping.
- *
- * If check_fake_overlap is set, then it will check the glyph's left
- * and right small boxes's real overlapping pixels. And if there is
- * no real pixel overlapping, then it will not be treated as overlapped
- * case. And we also can configured it to ignore less than 2 pixels
- * overlappig.
- *
- * This function analyzes all the lists and split the list to multiple
- * lists which are pure overlapped glyph lists or pure non-overlapped
- * list if the overlapping only ocurr on the two adjacent glyphs.
- * Otherwise, it return -1.
- *
- **/
-
-static int
-glamor_glyphs_intersect(int nlist, GlyphListPtr list, GlyphPtr *glyphs,
- PictFormatShort mask_format,
- ScreenPtr screen, Bool check_fake_overlap,
- struct glamor_glyph_list *fixed_list, int fixed_size)
-{
- int x1, x2, y1, y2;
- int n;
- int x, y;
- BoxPtr extents;
- BoxRec prev_extents;
- Bool first = TRUE, first_list = TRUE;
- Bool need_free_list_region = FALSE;
- Bool need_free_fixed_list = FALSE;
- struct glamor_glyph *priv = NULL;
- Bool in_non_intersected_list = -1;
- GlyphListPtr head_list;
- int head_x, head_y, head_pos;
- int fixed_cnt = 0;
- GlyphPtr *head_glyphs;
- GlyphListPtr cur_list = list;
- RegionRec list_region;
- RegionRec current_region;
- BoxRec current_box;
-
- if (nlist > 1) {
- pixman_region_init(&list_region);
- need_free_list_region = TRUE;
- }
-
- pixman_region_init(&current_region);
-
- extents = pixman_region_extents(&current_region);
-
- x = 0;
- y = 0;
- x1 = x2 = y1 = y2 = 0;
- n = 0;
- extents->x1 = 0;
- extents->y1 = 0;
- extents->x2 = 0;
- extents->y2 = 0;
-
- head_list = list;
- DEBUGF("has %d lists.\n", nlist);
- while (nlist--) {
- BoxRec left_box, right_box = { 0 };
- Bool has_left_edge_box = FALSE, has_right_edge_box = FALSE;
- Bool left_to_right;
- struct glamor_glyph *left_priv = NULL, *right_priv = NULL;
-
- x += list->xOff;
- y += list->yOff;
- n = list->len;
- left_to_right = TRUE;
- cur_list = list++;
-
- if (_X_UNLIKELY(!first_list)) {
- pixman_region_init_with_extents(&current_region, extents);
- pixman_region_union(&list_region, &list_region, &current_region);
- first = TRUE;
- }
- else {
- head_list = cur_list;
- head_pos = cur_list->len - n;
- head_x = x;
- head_y = y;
- head_glyphs = glyphs;
- }
-
- DEBUGF("current list %p has %d glyphs\n", cur_list, n);
- while (n--) {
- GlyphPtr glyph = *glyphs++;
-
- DEBUGF("the %dth glyph\n", cur_list->len - n - 1);
- if (glyph->info.width == 0 || glyph->info.height == 0) {
- x += glyph->info.xOff;
- y += glyph->info.yOff;
- continue;
- }
- if (mask_format
- && mask_format != GlyphPicture(glyph)[screen->myNum]->format) {
- need_free_fixed_list = TRUE;
- goto done;
- }
-
- x1 = x - glyph->info.x;
- if (x1 < MINSHORT)
- x1 = MINSHORT;
- y1 = y - glyph->info.y;
- if (y1 < MINSHORT)
- y1 = MINSHORT;
- if (check_fake_overlap)
- priv = glamor_glyph_get_private(screen, glyph);
-
- x2 = x1 + glyph->info.width;
- y2 = y1 + glyph->info.height;
-
- if (x2 > MAXSHORT)
- x2 = MAXSHORT;
- if (y2 > MAXSHORT)
- y2 = MAXSHORT;
-
- if (first) {
- extents->x1 = x1;
- extents->y1 = y1;
- extents->x2 = x2;
- extents->y2 = y2;
-
- prev_extents = *extents;
-
- first = FALSE;
- if (check_fake_overlap && priv
- && priv->has_edge_map && glyph->info.yOff == 0) {
- left_box.x1 = x1;
- left_box.x2 = x1 + 1;
- left_box.y1 = y1;
-
- right_box.x1 = x2 - 2;
- right_box.x2 = x2 - 1;
- right_box.y1 = y1;
- left_priv = right_priv = priv;
- has_left_edge_box = TRUE;
- has_right_edge_box = TRUE;
- }
- }
- else {
- if (_X_UNLIKELY(!first_list)) {
- current_box.x1 = x1;
- current_box.y1 = y1;
- current_box.x2 = x2;
- current_box.y2 = y2;
- if (pixman_region_contains_rectangle
- (&list_region, &current_box) != PIXMAN_REGION_OUT) {
- need_free_fixed_list = TRUE;
- goto done;
- }
- }
-
- if (x1 < extents->x2 && x2 > extents->x1
- && y1 < extents->y2 && y2 > extents->y1) {
-
- if (check_fake_overlap &&
- (has_left_edge_box || has_right_edge_box)
- && priv->has_edge_map && glyph->info.yOff == 0) {
- int left_dx, right_dx;
- unsigned long long intersected;
-
- left_dx = has_left_edge_box ? 1 : 0;
- right_dx = has_right_edge_box ? 1 : 0;
- if (x1 + 1 < extents->x2 - right_dx &&
- x2 - 1 > extents->x1 + left_dx)
- goto real_intersected;
-
- if (left_to_right && has_right_edge_box) {
- if (x1 == right_box.x1) {
- intersected =
- ((priv->left_x1_map & right_priv->
- right_x1_map)
- | (priv->left_x2_map & right_priv->
- right_x2_map));
- if (intersected)
- goto real_intersected;
- }
- else if (x1 == right_box.x2) {
- intersected =
- (priv->left_x1_map & right_priv->
- right_x2_map);
- if (intersected) {
-#ifdef GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
- /* tolerate with two pixels overlap. */
- intersected &= ~(1 << __fls(intersected));
- if ((intersected & (intersected - 1)))
-#endif
- goto real_intersected;
- }
- }
- }
- else if (!left_to_right && has_left_edge_box) {
- if (x2 - 1 == left_box.x1) {
- intersected =
- (priv->right_x2_map & left_priv->
- left_x1_map);
- if (intersected) {
-#ifdef GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
- /* tolerate with two pixels overlap. */
- intersected &= ~(1 << __fls(intersected));
- if ((intersected & (intersected - 1)))
-#endif
- goto real_intersected;
- }
- }
- else if (x2 - 1 == right_box.x2) {
- if ((priv->right_x1_map & left_priv->
- left_x1_map)
- || (priv->right_x2_map & left_priv->
- left_x2_map))
- goto real_intersected;
- }
- }
- else {
- if (x1 < extents->x2 && x1 + 2 > extents->x1)
- goto real_intersected;
- }
- goto non_intersected;
- }
- else {
- real_intersected:
- DEBUGF("overlap with previous glyph.\n");
- if (in_non_intersected_list == 1) {
- if (fixed_cnt >= fixed_size) {
- need_free_fixed_list = TRUE;
- goto done;
- }
- if (!glyph_new_fixed_list(&fixed_list[fixed_cnt],
- glyphs - 1,
- &head_glyphs,
- cur_list,
- cur_list->len - (n + 1),
- x, y, x1, y1, x2, y2,
- &head_list, &head_pos,
- &head_x, &head_y,
- &fixed_cnt,
- NON_INTERSECTED,
- &prev_extents)) {
- need_free_fixed_list = TRUE;
- goto done;
- }
- }
-
- in_non_intersected_list = 0;
-
- }
- }
- else {
- non_intersected:
- DEBUGF("doesn't overlap with previous glyph.\n");
- if (in_non_intersected_list == 0) {
- if (fixed_cnt >= fixed_size) {
- need_free_fixed_list = TRUE;
- goto done;
- }
- if (!glyph_new_fixed_list(&fixed_list[fixed_cnt],
- glyphs - 1,
- &head_glyphs,
- cur_list,
- cur_list->len - (n + 1), x, y,
- x1, y1, x2, y2,
- &head_list,
- &head_pos,
- &head_x,
- &head_y, &fixed_cnt,
- INTERSECTED, &prev_extents)) {
- need_free_fixed_list = TRUE;
- goto done;
- }
- }
- in_non_intersected_list = 1;
- }
- prev_extents = *extents;
- }
-
- if (check_fake_overlap && priv
- && priv->has_edge_map && glyph->info.yOff == 0) {
- if (!has_left_edge_box || x1 < extents->x1) {
- left_box.x1 = x1;
- left_box.x2 = x1 + 1;
- left_box.y1 = y1;
- has_left_edge_box = TRUE;
- left_priv = priv;
- }
-
- if (!has_right_edge_box || x2 > extents->x2) {
- right_box.x1 = x2 - 2;
- right_box.x2 = x2 - 1;
- right_box.y1 = y1;
- has_right_edge_box = TRUE;
- right_priv = priv;
- }
- }
-
- if (x1 < extents->x1)
- extents->x1 = x1;
- if (x2 > extents->x2)
- extents->x2 = x2;
-
- if (y1 < extents->y1)
- extents->y1 = y1;
- if (y2 > extents->y2)
- extents->y2 = y2;
-
- x += glyph->info.xOff;
- y += glyph->info.yOff;
- }
- first_list = FALSE;
- }
-
- if (in_non_intersected_list == 0 && fixed_cnt == 0) {
- fixed_cnt = -1;
- goto done;
- }
-
- if ((in_non_intersected_list != -1 || head_pos != n) && (fixed_cnt > 0)) {
- if (fixed_cnt >= fixed_size) {
- need_free_fixed_list = TRUE;
- goto done;
- }
- if (!glyph_new_fixed_list(&fixed_list[fixed_cnt],
- glyphs - 1,
- &head_glyphs,
- cur_list,
- cur_list->len - (n + 1), x, y,
- x1, y1, x2, y2,
- &head_list,
- &head_pos,
- &head_x,
- &head_y, &fixed_cnt,
- (!in_non_intersected_list) | 0x80,
- &prev_extents)) {
- need_free_fixed_list = TRUE;
- goto done;
- }
- }
-
- done:
- if (need_free_list_region)
- pixman_region_fini(&list_region);
- pixman_region_fini(&current_region);
-
- if (need_free_fixed_list && fixed_cnt >= 0) {
- while (fixed_cnt--) {
- free(fixed_list[fixed_cnt].list);
- }
- }
-
- DEBUGF("Got %d fixed list \n", fixed_cnt);
- return fixed_cnt;
-}
-
-static inline unsigned int
-glamor_glyph_size_to_count(int size)
-{
- size /= GLYPH_MIN_SIZE;
- return size * size;
-}
-
-static inline unsigned int
-glamor_glyph_count_to_mask(int count)
-{
- return ~(count - 1);
-}
-
-static inline unsigned int
-glamor_glyph_size_to_mask(int size)
-{
- return glamor_glyph_count_to_mask(glamor_glyph_size_to_count(size));
-}
-
-static PicturePtr
-glamor_glyph_cache(glamor_screen_private *glamor, GlyphPtr glyph, int *out_x,
- int *out_y)
-{
- ScreenPtr screen = glamor->screen;
- PicturePtr glyph_picture = GlyphPicture(glyph)[screen->myNum];
- glamor_glyph_cache_t *cache =
- &glamor->glyphCaches[PICT_FORMAT_RGB(glyph_picture->format) != 0];
- struct glamor_glyph *priv = NULL, *evicted_priv = NULL;
- int size, mask, pos, s;
-
- if (glyph->info.width > GLYPH_MAX_SIZE
- || glyph->info.height > GLYPH_MAX_SIZE)
- return NULL;
-
- for (size = GLYPH_MIN_SIZE; size <= GLYPH_MAX_SIZE; size *= 2)
- if (glyph->info.width <= size && glyph->info.height <= size)
- break;
-
- s = glamor_glyph_size_to_count(size);
- mask = glamor_glyph_count_to_mask(s);
- pos = (cache->count + s - 1) & mask;
-
- priv = glamor_glyph_get_private(screen, glyph);
- if (pos < GLYPH_CACHE_SIZE) {
- cache->count = pos + s;
- }
- else {
- for (s = size; s <= GLYPH_MAX_SIZE; s *= 2) {
- int i = cache->evict & glamor_glyph_size_to_mask(s);
- GlyphPtr evicted = cache->glyphs[i];
-
- if (evicted == NULL)
- continue;
-
- evicted_priv = glamor_glyph_get_private(screen, evicted);
- assert(evicted_priv->pos == i);
- if (evicted_priv->size >= s) {
- cache->glyphs[i] = NULL;
- evicted_priv->cached = FALSE;
- pos = cache->evict & glamor_glyph_size_to_mask(size);
- }
- else
- evicted_priv = NULL;
- break;
- }
- if (evicted_priv == NULL) {
- int count = glamor_glyph_size_to_count(size);
-
- mask = glamor_glyph_count_to_mask(count);
- pos = cache->evict & mask;
- for (s = 0; s < count; s++) {
- GlyphPtr evicted = cache->glyphs[pos + s];
-
- if (evicted != NULL) {
-
- evicted_priv = glamor_glyph_get_private(screen, evicted);
-
- assert(evicted_priv->pos == pos + s);
- evicted_priv->cached = FALSE;
- cache->glyphs[pos + s] = NULL;
- }
- }
-
- }
- /* And pick a new eviction position */
- cache->evict = rand() % GLYPH_CACHE_SIZE;
- }
-
- cache->glyphs[pos] = glyph;
-
- priv->cache = cache;
- priv->size = size;
- priv->pos = pos;
- s = pos / ((GLYPH_MAX_SIZE / GLYPH_MIN_SIZE) *
- (GLYPH_MAX_SIZE / GLYPH_MIN_SIZE));
- priv->x = s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
- priv->y = (s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
- for (s = GLYPH_MIN_SIZE; s < GLYPH_MAX_SIZE; s *= 2) {
- if (pos & 1)
- priv->x += s;
- if (pos & 2)
- priv->y += s;
- pos >>= 2;
- }
-
- glamor_glyph_cache_upload_glyph(screen, cache, glyph, priv->x, priv->y);
-#ifndef GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
- if (priv->has_edge_map == FALSE && glyph->info.width >= 2)
- glamor_glyph_priv_get_edge_map(glyph, priv, glyph_picture);
-#endif
- priv->cached = TRUE;
-
- *out_x = priv->x;
- *out_y = priv->y;
- return cache->picture;
-}
-
-typedef void (*glyphs_flush_func) (void *arg);
-struct glyphs_flush_dst_arg {
- CARD8 op;
- PicturePtr src;
- PicturePtr dst;
- glamor_glyph_buffer_t *buffer;
- int x_src, y_src;
- int x_dst, y_dst;
-};
-
-static struct glyphs_flush_dst_arg dst_arg;
-static struct glyphs_flush_mask_arg mask_arg;
-static glamor_glyph_buffer_t dst_buffer;
-static glamor_glyph_buffer_t mask_buffer;
-unsigned long long mask_glyphs_cnt = 0;
-unsigned long long dst_glyphs_cnt = 0;
-
-#define GLYPHS_DST_MODE_VIA_MASK 0
-#define GLYPHS_DST_MODE_VIA_MASK_CACHE 1
-#define GLYPHS_DST_MODE_TO_DST 2
-#define GLYPHS_DST_MODE_MASK_TO_DST 3
-
-struct glyphs_flush_mask_arg {
- PicturePtr mask;
- glamor_glyph_buffer_t *buffer;
- glamor_glyph_mask_cache_t *maskcache;
- unsigned int used_bitmap;
-};
-
-static void
-glamor_glyphs_flush_mask(struct glyphs_flush_mask_arg *arg)
-{
- if (arg->buffer->count > 0) {
- glamor_composite_glyph_rects(PictOpAdd, arg->buffer->source,
- NULL, arg->mask,
- arg->buffer->count, arg->buffer->rects);
- }
- arg->buffer->count = 0;
- arg->buffer->source = NULL;
-
-}
-
-static void
-glamor_glyphs_flush_dst(struct glyphs_flush_dst_arg *arg)
-{
- if (!arg->buffer)
- return;
-
- if (mask_buffer.count > 0) {
- glamor_glyphs_flush_mask(&mask_arg);
- }
- if (mask_arg.used_bitmap) {
- put_mask_cache_bitmap(mask_arg.maskcache, mask_arg.used_bitmap);
- mask_arg.used_bitmap = 0;
- }
-
- if (arg->buffer->count > 0) {
- glamor_composite_glyph_rects(arg->op, arg->src,
- arg->buffer->source, arg->dst,
- arg->buffer->count,
- &arg->buffer->rects[0]);
- arg->buffer->count = 0;
- arg->buffer->source = NULL;
- }
-}
-
-static glamor_glyph_cache_result_t
-glamor_buffer_glyph(glamor_screen_private *glamor_priv,
- glamor_glyph_buffer_t *buffer,
- PictFormatShort format,
- GlyphPtr glyph, struct glamor_glyph *priv,
- int x_glyph, int y_glyph,
- int dx, int dy, int w, int h,
- int glyphs_dst_mode,
- glyphs_flush_func glyphs_flush, void *flush_arg)
-{
- ScreenPtr screen = glamor_priv->screen;
- glamor_composite_rect_t *rect;
- PicturePtr source;
- int x, y;
- glamor_glyph_cache_t *cache;
-
- if (glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST)
- priv = glamor_glyph_get_private(screen, glyph);
-
- if (PICT_FORMAT_BPP(format) == 1)
- format = PICT_a8;
-
- cache = &glamor_priv->glyphCaches[PICT_FORMAT_RGB(format) != 0];
-
- if (buffer->source && buffer->source != cache->picture && glyphs_flush) {
- (*glyphs_flush) (flush_arg);
- glyphs_flush = NULL;
- }
-
- if (buffer->count == GLYPH_BUFFER_SIZE && glyphs_flush) {
- (*glyphs_flush) (flush_arg);
- glyphs_flush = NULL;
- }
-
- if (priv && priv->cached) {
- rect = &buffer->rects[buffer->count++];
- rect->x_src = priv->x + dx;
- rect->y_src = priv->y + dy;
- if (buffer->source == NULL)
- buffer->source = priv->cache->picture;
- if (glyphs_dst_mode <= GLYPHS_DST_MODE_VIA_MASK_CACHE)
- assert(priv->cache->glyphs[priv->pos] == glyph);
- }
- else {
- assert(glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST);
- if (glyphs_flush)
- (*glyphs_flush) (flush_arg);
- source = glamor_glyph_cache(glamor_priv, glyph, &x, &y);
-
- if (source != NULL) {
- rect = &buffer->rects[buffer->count++];
- rect->x_src = x + dx;
- rect->y_src = y + dy;
- if (buffer->source == NULL)
- buffer->source = source;
- if (glyphs_dst_mode == GLYPHS_DST_MODE_VIA_MASK_CACHE) {
- /* mode 1 means we are using global mask cache,
- * thus we have to composite from the cache picture
- * to the cache picture, we need a flush here to make
- * sure latter we get the corret glyphs data.*/
- glamor_make_current(glamor_priv);
- glFlush();
- }
- }
- else {
- /* Couldn't find the glyph in the cache, use the glyph picture directly */
- source = GlyphPicture(glyph)[screen->myNum];
- if (buffer->source && buffer->source != source && glyphs_flush)
- (*glyphs_flush) (flush_arg);
- buffer->source = source;
-
- rect = &buffer->rects[buffer->count++];
- rect->x_src = 0 + dx;
- rect->y_src = 0 + dy;
- }
- priv = glamor_glyph_get_private(screen, glyph);
- }
-
- rect->x_dst = x_glyph;
- rect->y_dst = y_glyph;
- if (glyphs_dst_mode != GLYPHS_DST_MODE_MASK_TO_DST) {
- rect->x_dst -= glyph->info.x;
- rect->y_dst -= glyph->info.y;
- }
- rect->width = w;
- rect->height = h;
- if (glyphs_dst_mode > GLYPHS_DST_MODE_VIA_MASK_CACHE) {
- rect->x_mask = rect->x_src;
- rect->y_mask = rect->y_src;
- rect->x_src = dst_arg.x_src + rect->x_dst - dst_arg.x_dst;
- rect->y_src = dst_arg.y_src + rect->y_dst - dst_arg.y_dst;
- }
-
- return GLAMOR_GLYPH_SUCCESS;
-}
-
-static void
-glamor_buffer_glyph_clip(glamor_screen_private *glamor_priv,
- BoxPtr rects,
- int nrect, PictFormatShort format,
- GlyphPtr glyph, struct glamor_glyph *priv,
- int glyph_x, int glyph_y,
- int glyph_dx, int glyph_dy,
- int width, int height,
- int glyphs_mode,
- glyphs_flush_func flush_func, void *arg)
-{
- int i;
-
- for (i = 0; i < nrect; i++) {
- int dst_x, dst_y;
- int dx, dy;
- int x2, y2;
-
- dst_x = glyph_x - glyph_dx;
- dst_y = glyph_y - glyph_dy;
- x2 = dst_x + width;
- y2 = dst_y + height;
- dx = dy = 0;
- if (rects[i].y1 >= y2)
- break;
-
- if (dst_x < rects[i].x1)
- dx = rects[i].x1 - dst_x, dst_x = rects[i].x1;
- if (x2 > rects[i].x2)
- x2 = rects[i].x2;
- if (dst_y < rects[i].y1)
- dy = rects[i].y1 - dst_y, dst_y = rects[i].y1;
- if (y2 > rects[i].y2)
- y2 = rects[i].y2;
- if (dst_x < x2 && dst_y < y2) {
-
- glamor_buffer_glyph(glamor_priv,
- &dst_buffer,
- format,
- glyph, priv,
- dst_x + glyph_dx,
- dst_y + glyph_dy,
- dx, dy,
- x2 - dst_x, y2 - dst_y,
- glyphs_mode, flush_func, arg);
- }
- }
-}
-
-static void
-glamor_glyphs_via_mask(CARD8 op,
- PicturePtr src,
- PicturePtr dst,
- PictFormatPtr mask_format,
- INT16 x_src,
- INT16 y_src,
- int nlist, GlyphListPtr list, GlyphPtr *glyphs,
- Bool use_mask_cache)
-{
- PixmapPtr mask_pixmap = 0;
- PicturePtr mask;
- ScreenPtr screen = dst->pDrawable->pScreen;
- int width = 0, height = 0;
- int x, y;
- int x_dst = list->xOff, y_dst = list->yOff;
- int n;
- GlyphPtr glyph;
- int error;
- BoxRec extents = { 0, 0, 0, 0 };
- XID component_alpha;
- glamor_screen_private *glamor_priv;
- int need_free_mask = FALSE;
- glamor_glyph_buffer_t buffer;
- struct glyphs_flush_mask_arg arg;
- glamor_glyph_buffer_t *pmask_buffer;
- struct glyphs_flush_mask_arg *pmask_arg;
- struct glamor_glyph_mask_cache_entry *mce = NULL;
- glamor_glyph_mask_cache_t *maskcache;
- glamor_glyph_cache_t *cache;
- int glyphs_dst_mode;
-
- glamor_glyph_extents(nlist, list, glyphs, &extents);
-
- if (extents.x2 <= extents.x1 || extents.y2 <= extents.y1)
- return;
- glamor_priv = glamor_get_screen_private(screen);
- width = extents.x2 - extents.x1;
- height = extents.y2 - extents.y1;
-
- if (mask_format->depth == 1) {
- PictFormatPtr a8Format = PictureMatchFormat(screen, 8, PICT_a8);
-
- if (a8Format)
- mask_format = a8Format;
- }
-
- cache = &glamor_priv->glyphCaches
- [PICT_FORMAT_RGB(mask_format->format) != 0];
- maskcache = glamor_priv->mask_cache[PICT_FORMAT_RGB(mask_format->format) != 0];
-
- x = -extents.x1;
- y = -extents.y1;
- if (!use_mask_cache || width > (CACHE_PICTURE_SIZE / 4)
- || height > MASK_CACHE_MAX_SIZE) {
- new_mask_pixmap:
- mask_pixmap = glamor_create_pixmap(screen, width, height,
- mask_format->depth,
- CREATE_PIXMAP_USAGE_SCRATCH);
- if (!mask_pixmap) {
- glamor_destroy_pixmap(mask_pixmap);
- return;
- }
- glamor_solid(mask_pixmap, 0, 0, width, height, 0);
- component_alpha = NeedsComponent(mask_format->format);
- mask = CreatePicture(0, &mask_pixmap->drawable,
- mask_format, CPComponentAlpha,
- &component_alpha, serverClient, &error);
- if (!mask)
- return;
- need_free_mask = TRUE;
- pmask_arg = &arg;
- pmask_buffer = &buffer;
- pmask_buffer->count = 0;
- pmask_buffer->source = NULL;
- pmask_arg->used_bitmap = 0;
- glyphs_dst_mode = GLYPHS_DST_MODE_VIA_MASK;
- }
- else {
- int retry_cnt = 0;
-
- retry:
- mce = get_mask_cache(maskcache,
- (width + MASK_CACHE_MAX_SIZE -
- 1) / MASK_CACHE_MAX_SIZE);
-
- if (mce == NULL) {
- glamor_glyphs_flush_dst(&dst_arg);
- retry_cnt++;
- if (retry_cnt > 2) {
- assert(0);
- goto new_mask_pixmap;
- }
- goto retry;
- }
-
- mask = cache->picture;
- x += mce->x;
- y += mce->y;
- mce->width = (width + MASK_CACHE_MAX_SIZE - 1) / MASK_CACHE_MAX_SIZE;
- mce->height = 1;
- if (mask_arg.mask && mask_arg.mask != mask && mask_buffer.count != 0)
- glamor_glyphs_flush_dst(&dst_arg);
- pmask_arg = &mask_arg;
- pmask_buffer = &mask_buffer;
- pmask_arg->maskcache = maskcache;
- glyphs_dst_mode = GLYPHS_DST_MODE_VIA_MASK_CACHE;
- }
- pmask_arg->mask = mask;
- pmask_arg->buffer = pmask_buffer;
- while (nlist--) {
- x += list->xOff;
- y += list->yOff;
- n = list->len;
- mask_glyphs_cnt += n;
- while (n--) {
- glyph = *glyphs++;
- if (glyph->info.width > 0 && glyph->info.height > 0) {
- glyphs_flush_func flush_func;
- void *temp_arg;
-
- if (need_free_mask) {
- if (pmask_buffer->count)
- flush_func =
- (glyphs_flush_func) glamor_glyphs_flush_mask;
- else
- flush_func = NULL;
- temp_arg = pmask_arg;
- }
- else {
- /* If we are using global mask cache, then we need to
- * flush dst instead of mask. As some dst depends on the
- * previous mask result. Just flush mask can't get all previous's
- * overlapped glyphs.*/
- if (dst_buffer.count || mask_buffer.count)
- flush_func =
- (glyphs_flush_func) glamor_glyphs_flush_dst;
- else
- flush_func = NULL;
- temp_arg = &dst_arg;
- }
- glamor_buffer_glyph(glamor_priv, pmask_buffer,
- mask_format->format,
- glyph, NULL, x, y,
- 0, 0,
- glyph->info.width, glyph->info.height,
- glyphs_dst_mode,
- flush_func, (void *) temp_arg);
- }
- x += glyph->info.xOff;
- y += glyph->info.yOff;
- }
- list++;
- }
-
- x = extents.x1;
- y = extents.y1;
- if (need_free_mask) {
- glamor_glyphs_flush_mask(pmask_arg);
- CompositePicture(op,
- src,
- mask,
- dst,
- x_src + x - x_dst,
- y_src + y - y_dst, 0, 0, x, y, width, height);
- FreePicture(mask, 0);
- glamor_destroy_pixmap(mask_pixmap);
- }
- else {
- struct glamor_glyph priv;
- glyphs_flush_func flush_func;
- BoxPtr rects;
- int nrect;
-
- priv.cache = cache;
- priv.x = mce->x;
- priv.y = mce->y;
- priv.cached = TRUE;
- rects = REGION_RECTS(dst->pCompositeClip);
- nrect = REGION_NUM_RECTS(dst->pCompositeClip);
-
- pmask_arg->used_bitmap |= ((1 << mce->width) - 1) << mce->idx;
- dst_arg.op = op;
- dst_arg.src = src;
- dst_arg.dst = dst;
- dst_arg.buffer = &dst_buffer;
- dst_arg.x_src = x_src;
- dst_arg.y_src = y_src;
- dst_arg.x_dst = x_dst;
- dst_arg.y_dst = y_dst;
-
- if (dst_buffer.source == NULL) {
- dst_buffer.source = cache->picture;
- }
- else if (dst_buffer.source != cache->picture) {
- glamor_glyphs_flush_dst(&dst_arg);
- dst_buffer.source = cache->picture;
- }
-
- x += dst->pDrawable->x;
- y += dst->pDrawable->y;
-
- if (dst_buffer.count || mask_buffer.count)
- flush_func = (glyphs_flush_func) glamor_glyphs_flush_dst;
- else
- flush_func = NULL;
-
- glamor_buffer_glyph_clip(glamor_priv,
- rects, nrect,
- mask_format->format,
- NULL, &priv,
- x, y,
- 0, 0,
- width, height,
- GLYPHS_DST_MODE_MASK_TO_DST,
- flush_func, (void *) &dst_arg);
- }
-}
-
-static void
-glamor_glyphs_to_dst(CARD8 op,
- PicturePtr src,
- PicturePtr dst,
- INT16 x_src,
- INT16 y_src,
- int nlist, GlyphListPtr list, GlyphPtr *glyphs)
-{
- ScreenPtr screen = dst->pDrawable->pScreen;
- int x = 0, y = 0;
- int x_dst = list->xOff, y_dst = list->yOff;
- int n;
- GlyphPtr glyph;
- BoxPtr rects;
- int nrect;
- glamor_screen_private *glamor_priv;
-
- rects = REGION_RECTS(dst->pCompositeClip);
- nrect = REGION_NUM_RECTS(dst->pCompositeClip);
-
- glamor_priv = glamor_get_screen_private(screen);
-
- dst_arg.op = op;
- dst_arg.src = src;
- dst_arg.dst = dst;
- dst_arg.buffer = &dst_buffer;
- dst_arg.x_src = x_src;
- dst_arg.y_src = y_src;
- dst_arg.x_dst = x_dst;
- dst_arg.y_dst = y_dst;
-
- x = dst->pDrawable->x;
- y = dst->pDrawable->y;
-
- while (nlist--) {
- x += list->xOff;
- y += list->yOff;
- n = list->len;
- dst_glyphs_cnt += n;
- while (n--) {
- glyph = *glyphs++;
-
- if (glyph->info.width > 0 && glyph->info.height > 0) {
- glyphs_flush_func flush_func;
-
- if (dst_buffer.count || mask_buffer.count)
- flush_func = (glyphs_flush_func) glamor_glyphs_flush_dst;
- else
- flush_func = NULL;
- glamor_buffer_glyph_clip(glamor_priv,
- rects, nrect,
- (GlyphPicture(glyph)[screen->myNum])->
- format, glyph, NULL, x, y,
- glyph->info.x, glyph->info.y,
- glyph->info.width, glyph->info.height,
- GLYPHS_DST_MODE_TO_DST, flush_func,
- (void *) &dst_arg);
- }
-
- x += glyph->info.xOff;
- y += glyph->info.yOff;
- }
- list++;
- }
-}
-
-#define MAX_FIXED_SIZE
-static void
-glamor_glyphs_reset_buffer(glamor_glyph_buffer_t *buffer)
-{
- buffer->count = 0;
- buffer->source = NULL;
-}
-
-static Bool
-_glamor_glyphs(CARD8 op,
- PicturePtr src,
- PicturePtr dst,
- PictFormatPtr mask_format,
- INT16 x_src,
- INT16 y_src, int nlist, GlyphListPtr list,
- GlyphPtr *glyphs, Bool fallback)
-{
- PictFormatShort format;
- int fixed_size, fixed_cnt = 0;
- struct glamor_glyph_list *fixed_list = NULL;
- Bool need_free_list = FALSE;
-
-#ifndef GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
- Bool check_fake_overlap = TRUE;
-
- if (!(op == PictOpOver || op == PictOpAdd || op == PictOpXor)) {
- /* C = (0,0,0,0) D = glyphs , SRC = A, DEST = B (faked overlapped glyphs, overlapped with (0,0,0,0)).
- * For those op, (A IN (C ADD D)) OP B != (A IN D) OP ((A IN C) OP B)
- * or (A IN (D ADD C)) OP B != (A IN C) OP ((A IN D) OP B)
- * We need to split the faked regions to three or two, and composite the disoverlapped small
- * boxes one by one. For other Ops, it's safe to composite the whole box. */
- check_fake_overlap = FALSE;
- }
-#else
- Bool check_fake_overlap = FALSE;
-#endif
- if (mask_format)
- format = mask_format->depth << 24 | mask_format->format;
- else
- format = 0;
-
- fixed_size = 32;
- glamor_glyphs_reset_buffer(&dst_buffer);
-
- if (!mask_format || (((nlist == 1 && list->len == 1) || op == PictOpAdd)
- && (dst->format ==
- ((mask_format->depth << 24) | mask_format->
- format)))) {
- glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist, list, glyphs);
- goto last_flush;
- }
-
- glamor_glyphs_reset_buffer(&mask_buffer);
-
- /* We have mask_format. Need to check the real overlap or not. */
- format = mask_format->depth << 24 | mask_format->format;
-
- fixed_list = calloc(fixed_size, sizeof(*fixed_list));
- if (_X_UNLIKELY(fixed_list == NULL))
- fixed_size = 0;
- fixed_cnt = glamor_glyphs_intersect(nlist, list, glyphs,
- format, dst->pDrawable->pScreen,
- check_fake_overlap,
- fixed_list, fixed_size);
- if (fixed_cnt == 0)
- mask_format = NULL;
- need_free_list = TRUE;
-
- if (fixed_cnt <= 0) {
- if (mask_format == NULL) {
- glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
- list, glyphs);
- goto last_flush;
- }
- else {
- glamor_glyphs_via_mask(op, src, dst, mask_format,
- x_src, y_src, nlist, list, glyphs, FALSE);
- goto free_fixed_list;
- }
- }
- else {
-
- /* We have splitted the original list to serval list, some are overlapped
- * and some are non-overlapped. For the non-overlapped, we render it to
- * dst directly. For the overlapped, we render it to mask picture firstly,
- * then render the mask to dst. If we can use mask cache which is in the
- * glyphs cache's last row, we can accumulate the rendering of mask to dst
- * with the other dst_buffer's rendering operations thus can reduce the call
- * of glDrawElements.
- *
- * */
- struct glamor_glyph_list *saved_list;
-
- saved_list = fixed_list;
- mask_arg.used_bitmap = 0;
- while (fixed_cnt--) {
- if (fixed_list->type == NON_INTERSECTED) {
- glamor_glyphs_to_dst(op, src, dst,
- x_src, y_src,
- fixed_list->nlist,
- fixed_list->list, fixed_list->glyphs);
- }
- else
- glamor_glyphs_via_mask(op, src, dst,
- mask_format, x_src, y_src,
- fixed_list->nlist,
- fixed_list->list,
- fixed_list->glyphs, TRUE);
-
- free(fixed_list->list);
- fixed_list++;
- }
- free(saved_list);
- need_free_list = FALSE;
- }
-
- last_flush:
- if (dst_buffer.count || mask_buffer.count)
- glamor_glyphs_flush_dst(&dst_arg);
- free_fixed_list:
- if (need_free_list) {
- assert(fixed_cnt <= 0);
- free(fixed_list);
- }
- return TRUE;
-}
-
-void
-glamor_glyphs(CARD8 op,
- PicturePtr src,
- PicturePtr dst,
- PictFormatPtr mask_format,
- INT16 x_src,
- INT16 y_src, int nlist, GlyphListPtr list, GlyphPtr *glyphs)
-{
- _glamor_glyphs(op, src, dst, mask_format, x_src,
- y_src, nlist, list, glyphs, TRUE);
-}
diff --git a/xorg-server/glamor/glamor_gradient.c b/xorg-server/glamor/glamor_gradient.c
index 8ea645efc..d34131d35 100644
--- a/xorg-server/glamor/glamor_gradient.c
+++ b/xorg-server/glamor/glamor_gradient.c
@@ -997,13 +997,13 @@ glamor_generate_radial_gradient_picture(ScreenPtr screen,
/* Set all the stops and colors to shader. */
if (stops_count > RADIAL_SMALL_STOPS) {
- stop_colors = malloc(4 * stops_count * sizeof(float));
+ stop_colors = xallocarray(stops_count, 4 * sizeof(float));
if (stop_colors == NULL) {
ErrorF("Failed to allocate stop_colors memory.\n");
goto GRADIENT_FAIL;
}
- n_stops = malloc(stops_count * sizeof(float));
+ n_stops = xallocarray(stops_count, sizeof(float));
if (n_stops == NULL) {
ErrorF("Failed to allocate n_stops memory.\n");
goto GRADIENT_FAIL;
@@ -1338,13 +1338,13 @@ glamor_generate_linear_gradient_picture(ScreenPtr screen,
/* Set all the stops and colors to shader. */
if (stops_count > LINEAR_SMALL_STOPS) {
- stop_colors = malloc(4 * stops_count * sizeof(float));
+ stop_colors = xallocarray(stops_count, 4 * sizeof(float));
if (stop_colors == NULL) {
ErrorF("Failed to allocate stop_colors memory.\n");
goto GRADIENT_FAIL;
}
- n_stops = malloc(stops_count * sizeof(float));
+ n_stops = xallocarray(stops_count, sizeof(float));
if (n_stops == NULL) {
ErrorF("Failed to allocate n_stops memory.\n");
goto GRADIENT_FAIL;
diff --git a/xorg-server/glamor/glamor_image.c b/xorg-server/glamor/glamor_image.c
index 5633da647..a272d5eaf 100644
--- a/xorg-server/glamor/glamor_image.c
+++ b/xorg-server/glamor/glamor_image.c
@@ -49,7 +49,7 @@ glamor_put_image_gl(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
if (gc->alu != GXcopy)
goto bail;
- if (!glamor_pm_is_solid(&pixmap->drawable, gc->planemask))
+ if (!glamor_pm_is_solid(gc->depth, gc->planemask))
goto bail;
if (format == XYPixmap && drawable->depth == 1 && leftPad == 0)
@@ -116,7 +116,7 @@ glamor_get_image_gl(DrawablePtr drawable, int x, int y, int w, int h,
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
goto bail;
- if (format != ZPixmap || !glamor_pm_is_solid(drawable, plane_mask))
+ if (format != ZPixmap || !glamor_pm_is_solid(drawable->depth, plane_mask))
goto bail;
glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
diff --git a/xorg-server/glamor/glamor_pixmap.c b/xorg-server/glamor/glamor_pixmap.c
index 89b4c366b..4e8737172 100644
--- a/xorg-server/glamor/glamor_pixmap.c
+++ b/xorg-server/glamor/glamor_pixmap.c
@@ -109,9 +109,9 @@ glamor_set_destination_pixmap(PixmapPtr pixmap)
}
Bool
-glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
+glamor_set_planemask(int depth, unsigned long planemask)
{
- if (glamor_pm_is_solid(&pixmap->drawable, planemask)) {
+ if (glamor_pm_is_solid(depth, planemask)) {
return GL_TRUE;
}
@@ -775,7 +775,7 @@ _glamor_upload_bits_to_pixmap_texture(PixmapPtr pixmap, GLenum format,
if (pixmap->drawable.depth == 1)
stride = (((w * 8 + 7) / 8) + 3) & ~3;
- converted_bits = malloc(h * stride);
+ converted_bits = xallocarray(h, stride);
if (converted_bits == NULL)
return FALSE;
@@ -966,7 +966,7 @@ glamor_upload_sub_pixmap_to_texture(PixmapPtr pixmap, int x, int y, int w,
void *sub_bits;
int i, j;
- sub_bits = malloc(h * stride);
+ sub_bits = xallocarray(h, stride);
if (sub_bits == NULL)
return FALSE;
box.x1 = x;
diff --git a/xorg-server/glamor/glamor_points.c b/xorg-server/glamor/glamor_points.c
index df7e5a23f..3ba4a6927 100644
--- a/xorg-server/glamor/glamor_points.c
+++ b/xorg-server/glamor/glamor_points.c
@@ -60,7 +60,8 @@ glamor_poly_point_gl(DrawablePtr drawable, GCPtr gc, int mode, int npt, DDXPoint
if (!prog->prog) {
if (!glamor_build_program(screen, prog,
&glamor_facet_point,
- &glamor_fill_solid))
+ &glamor_fill_solid,
+ NULL, NULL))
goto bail;
}
diff --git a/xorg-server/glamor/glamor_prepare.c b/xorg-server/glamor/glamor_prepare.c
index 83ba7f16f..9bfc557e1 100644
--- a/xorg-server/glamor/glamor_prepare.c
+++ b/xorg-server/glamor/glamor_prepare.c
@@ -91,8 +91,8 @@ glamor_prep_pixmap_box(PixmapPtr pixmap, glamor_access_t access, BoxPtr box)
pixmap->devKind * pixmap->drawable.height, NULL,
gl_usage);
} else {
- pixmap->devPrivate.ptr = malloc(pixmap->devKind *
- pixmap->drawable.height);
+ pixmap->devPrivate.ptr = xallocarray(pixmap->devKind,
+ pixmap->drawable.height);
if (!pixmap->devPrivate.ptr)
return FALSE;
}
diff --git a/xorg-server/glamor/glamor_priv.h b/xorg-server/glamor/glamor_priv.h
index 898a9348a..480d13bfe 100644
--- a/xorg-server/glamor/glamor_priv.h
+++ b/xorg-server/glamor/glamor_priv.h
@@ -154,41 +154,8 @@ enum glamor_gl_flavor {
GLAMOR_GL_ES2 // OPENGL ES2.0 API
};
-#define GLAMOR_NUM_GLYPH_CACHE_FORMATS 2
-
#define GLAMOR_COMPOSITE_VBO_VERT_CNT (64*1024)
-typedef struct {
- PicturePtr picture; /* Where the glyphs of the cache are stored */
- GlyphPtr *glyphs;
- uint16_t count;
- uint16_t evict;
-} glamor_glyph_cache_t;
-
-#define CACHE_PICTURE_SIZE 1024
-#define GLYPH_MIN_SIZE 8
-#define GLYPH_MAX_SIZE 64
-#define GLYPH_CACHE_SIZE ((CACHE_PICTURE_SIZE) * CACHE_PICTURE_SIZE / (GLYPH_MIN_SIZE * GLYPH_MIN_SIZE))
-
-#define MASK_CACHE_MAX_SIZE 32
-#define MASK_CACHE_WIDTH (CACHE_PICTURE_SIZE / MASK_CACHE_MAX_SIZE)
-#define MASK_CACHE_MASK ((1LL << (MASK_CACHE_WIDTH)) - 1)
-
-struct glamor_glyph_mask_cache_entry {
- int idx;
- int width;
- int height;
- int x;
- int y;
-};
-
-typedef struct {
- PixmapPtr pixmap;
- struct glamor_glyph_mask_cache_entry mcache[MASK_CACHE_WIDTH];
- unsigned int free_bitmap;
- unsigned int cleared_bitmap;
-} glamor_glyph_mask_cache_t;
-
struct glamor_saved_procs {
CloseScreenProcPtr close_screen;
CreateScreenResourcesProcPtr create_screen_resources;
@@ -208,7 +175,6 @@ struct glamor_saved_procs {
AddTrapsProcPtr addtraps;
CreatePictureProcPtr create_picture;
DestroyPictureProcPtr destroy_picture;
- UnrealizeGlyphProcPtr unrealize_glyph;
SetWindowPixmapProcPtr set_window_pixmap;
#if XSYNC
SyncScreenFuncsRec sync_screen_funcs;
@@ -274,6 +240,14 @@ typedef struct glamor_screen_private {
glamor_program_fill on_off_dash_line_progs;
glamor_program double_dash_line_prog;
+ /* glamor composite_glyphs shaders */
+ glamor_program_render glyphs_program;
+ struct glamor_glyph_atlas *glyph_atlas_a;
+ struct glamor_glyph_atlas *glyph_atlas_argb;
+ int glyph_atlas_dim;
+ int glyph_max_dim;
+ char *glyph_defines;
+
/* vertext/elment_index buffer object for render */
GLuint vbo, ebo;
/** Next offset within the VBO that glamor_get_vbo_space() will use. */
@@ -292,9 +266,6 @@ typedef struct glamor_screen_private {
glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
[SHADER_MASK_COUNT]
[SHADER_IN_COUNT];
- glamor_glyph_cache_t glyphCaches[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
- glamor_glyph_mask_cache_t *mask_cache[GLAMOR_NUM_GLYPH_CACHE_FORMATS];
- Bool glyph_caches_realized;
/* shaders to restore a texture to another texture. */
GLint finish_access_prog[2];
@@ -638,10 +609,10 @@ glamor_get_gc_private(GCPtr gc)
* pixel values for pDrawable.
*/
static inline Bool
-glamor_pm_is_solid(DrawablePtr drawable, unsigned long planemask)
+glamor_pm_is_solid(int depth, unsigned long planemask)
{
- return (planemask & FbFullMask(drawable->depth)) ==
- FbFullMask(drawable->depth);
+ return (planemask & FbFullMask(depth)) ==
+ FbFullMask(depth);
}
extern int glamor_debug_level;
@@ -676,7 +647,7 @@ glamor_pixmap_fbo *glamor_create_fbo_array(glamor_screen_private *glamor_priv,
void glamor_init_finish_access_shaders(ScreenPtr screen);
void glamor_fini_finish_access_shaders(ScreenPtr screen);
-const Bool glamor_get_drawable_location(const DrawablePtr drawable);
+Bool glamor_get_drawable_location(const DrawablePtr drawable);
void glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
int *x, int *y);
GLint glamor_compile_glsl_prog(GLenum type, const char *source);
@@ -701,23 +672,12 @@ glamor_pixmap_fbo *glamor_es2_pixmap_read_prepare(PixmapPtr source, int x,
int swap_rb);
Bool glamor_set_alu(ScreenPtr screen, unsigned char alu);
-Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
+Bool glamor_set_planemask(int depth, unsigned long planemask);
RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
void
glamor_track_stipple(GCPtr gc);
-/* glamor_glyphs.c */
-Bool glamor_realize_glyph_caches(ScreenPtr screen);
-void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
-void glamor_glyphs_fini(ScreenPtr screen);
-void glamor_glyphs(CARD8 op,
- PicturePtr pSrc,
- PicturePtr pDst,
- PictFormatPtr maskFormat,
- INT16 xSrc,
- INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr *glyphs);
-
/* glamor_render.c */
Bool glamor_composite_clipped_region(CARD8 op,
PicturePtr source,
@@ -744,10 +704,6 @@ void glamor_composite(CARD8 op,
void glamor_init_composite_shaders(ScreenPtr screen);
void glamor_fini_composite_shaders(ScreenPtr screen);
-void glamor_composite_glyph_rects(CARD8 op,
- PicturePtr src, PicturePtr mask,
- PicturePtr dst, int nrect,
- glamor_composite_rect_t *rects);
void glamor_composite_rects(CARD8 op,
PicturePtr pDst,
xRenderColor *color, int nRect, xRectangle *rects);
@@ -994,6 +950,22 @@ void glamor_composite_rectangles(CARD8 op,
xRenderColor *color,
int num_rects, xRectangle *rects);
+/* glamor_composite_glyphs.c */
+Bool
+glamor_composite_glyphs_init(ScreenPtr pScreen);
+
+void
+glamor_composite_glyphs_fini(ScreenPtr pScreen);
+
+void
+glamor_composite_glyphs(CARD8 op,
+ PicturePtr src,
+ PicturePtr dst,
+ PictFormatPtr mask_format,
+ INT16 x_src,
+ INT16 y_src, int nlist,
+ GlyphListPtr list, GlyphPtr *glyphs);
+
/* glamor_sync.c */
Bool
glamor_sync_init(ScreenPtr screen);
@@ -1077,8 +1049,6 @@ void glamor_xv_render(glamor_port_private *port_priv);
#if 0
#define MAX_FBO_SIZE 32 /* For test purpose only. */
#endif
-//#define GLYPHS_NO_EDEGEMAP_OVERLAP_CHECK
-#define GLYPHS_EDEGE_OVERLAP_LOOSE_CHECK
#include "glamor_font.h"
diff --git a/xorg-server/glamor/glamor_program.c b/xorg-server/glamor/glamor_program.c
index 8aab53f4f..1dc5f1983 100644
--- a/xorg-server/glamor/glamor_program.c
+++ b/xorg-server/glamor/glamor_program.c
@@ -47,7 +47,7 @@ static const glamor_facet glamor_fill_tile = {
.name = "tile",
.vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;\n",
.fs_exec = " gl_FragColor = texture2D(sampler, fill_pos);\n",
- .locations = glamor_program_location_fill,
+ .locations = glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_tile,
};
@@ -66,7 +66,7 @@ static const glamor_facet glamor_fill_stipple = {
" if (a == 0.0)\n"
" discard;\n"
" gl_FragColor = fg;\n"),
- .locations = glamor_program_location_fg | glamor_program_location_fill,
+ .locations = glamor_program_location_fg | glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_stipple,
};
@@ -87,7 +87,7 @@ static const glamor_facet glamor_fill_opaque_stipple = {
" gl_FragColor = bg;\n"
" else\n"
" gl_FragColor = fg;\n"),
- .locations = glamor_program_location_fg | glamor_program_location_bg | glamor_program_location_fill,
+ .locations = glamor_program_location_fg | glamor_program_location_bg | glamor_program_location_fillsamp | glamor_program_location_fillpos,
.use = use_opaque_stipple
};
@@ -114,12 +114,15 @@ static glamor_location_var location_vars[] = {
.fs_vars = "uniform vec4 bg;\n"
},
{
- .location = glamor_program_location_fill,
+ .location = glamor_program_location_fillsamp,
+ .fs_vars = "uniform sampler2D sampler;\n"
+ },
+ {
+ .location = glamor_program_location_fillpos,
.vs_vars = ("uniform vec2 fill_offset;\n"
"uniform vec2 fill_size_inv;\n"
"varying vec2 fill_pos;\n"),
- .fs_vars = ("uniform sampler2D sampler;\n"
- "uniform vec2 fill_size_inv;\n"
+ .fs_vars = ("uniform vec2 fill_size_inv;\n"
"varying vec2 fill_pos;\n")
},
{
@@ -136,6 +139,10 @@ static glamor_location_var location_vars[] = {
.vs_vars = "uniform float dash_length;\n",
.fs_vars = "uniform sampler2D dash;\n",
},
+ {
+ .location = glamor_program_location_atlas,
+ .fs_vars = "uniform sampler2D atlas;\n",
+ },
};
#define NUM_LOCATION_VARS (sizeof location_vars / sizeof location_vars[0])
@@ -183,6 +190,7 @@ fs_location_vars(glamor_program_location locations)
static const char vs_template[] =
"%s" /* version */
+ "%s" /* defines */
"%s" /* prim vs_vars */
"%s" /* fill vs_vars */
"%s" /* location vs_vars */
@@ -195,12 +203,14 @@ static const char vs_template[] =
static const char fs_template[] =
"%s" /* version */
GLAMOR_DEFAULT_PRECISION
+ "%s" /* defines */
"%s" /* prim fs_vars */
"%s" /* fill fs_vars */
"%s" /* location fs_vars */
"void main() {\n"
"%s" /* prim fs_exec */
"%s" /* fill fs_exec */
+ "%s" /* combine */
"}\n";
static const char *
@@ -236,7 +246,9 @@ Bool
glamor_build_program(ScreenPtr screen,
glamor_program *prog,
const glamor_facet *prim,
- const glamor_facet *fill)
+ const glamor_facet *fill,
+ const char *combine,
+ const char *defines)
{
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
@@ -282,6 +294,7 @@ glamor_build_program(ScreenPtr screen,
if (asprintf(&vs_prog_string,
vs_template,
str(version_string),
+ str(defines),
str(prim->vs_vars),
str(fill->vs_vars),
vs_vars,
@@ -292,26 +305,30 @@ glamor_build_program(ScreenPtr screen,
if (asprintf(&fs_prog_string,
fs_template,
str(version_string),
+ str(defines),
str(prim->fs_vars),
str(fill->fs_vars),
fs_vars,
str(prim->fs_exec),
- str(fill->fs_exec)) < 0)
+ str(fill->fs_exec),
+ str(combine)) < 0)
fs_prog_string = NULL;
if (!vs_prog_string || !fs_prog_string)
goto fail;
+ prog->prog = glCreateProgram();
#if DBG
- ErrorF("\nPrograms for %s %s\nVertex shader:\n\n%s\n\nFragment Shader:\n\n%s",
- prim->name, fill->name, vs_prog_string, fs_prog_string);
+ ErrorF("\n\tProgram %d for %s %s\n\tVertex shader:\n\n\t================\n%s\n\n\tFragment Shader:\n\n%s\t================\n",
+ prog->prog, prim->name, fill->name, vs_prog_string, fs_prog_string);
#endif
- prog->prog = glCreateProgram();
prog->flags = flags;
prog->locations = locations;
prog->prim_use = prim->use;
+ prog->prim_use_render = prim->use_render;
prog->fill_use = fill->use;
+ prog->fill_use_render = fill->use_render;
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, vs_prog_string);
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, fs_prog_string);
@@ -335,13 +352,14 @@ glamor_build_program(ScreenPtr screen,
prog->matrix_uniform = glamor_get_uniform(prog, glamor_program_location_none, "v_matrix");
prog->fg_uniform = glamor_get_uniform(prog, glamor_program_location_fg, "fg");
prog->bg_uniform = glamor_get_uniform(prog, glamor_program_location_bg, "bg");
- prog->fill_offset_uniform = glamor_get_uniform(prog, glamor_program_location_fill, "fill_offset");
- prog->fill_size_inv_uniform = glamor_get_uniform(prog, glamor_program_location_fill, "fill_size_inv");
+ prog->fill_offset_uniform = glamor_get_uniform(prog, glamor_program_location_fillpos, "fill_offset");
+ prog->fill_size_inv_uniform = glamor_get_uniform(prog, glamor_program_location_fillpos, "fill_size_inv");
prog->font_uniform = glamor_get_uniform(prog, glamor_program_location_font, "font");
prog->bitplane_uniform = glamor_get_uniform(prog, glamor_program_location_bitplane, "bitplane");
prog->bitmul_uniform = glamor_get_uniform(prog, glamor_program_location_bitplane, "bitmul");
prog->dash_uniform = glamor_get_uniform(prog, glamor_program_location_dash, "dash");
prog->dash_length_uniform = glamor_get_uniform(prog, glamor_program_location_dash, "dash_length");
+ prog->atlas_uniform = glamor_get_uniform(prog, glamor_program_location_atlas, "atlas");
free(version_string);
free(fs_vars);
@@ -396,7 +414,7 @@ glamor_use_program_fill(PixmapPtr pixmap,
if (!fill)
return NULL;
- if (!glamor_build_program(screen, prog, prim, fill))
+ if (!glamor_build_program(screen, prog, prim, fill, NULL, NULL))
return NULL;
}
@@ -405,3 +423,238 @@ glamor_use_program_fill(PixmapPtr pixmap,
return prog;
}
+
+static struct blendinfo composite_op_info[] = {
+ [PictOpClear] = {0, 0, GL_ZERO, GL_ZERO},
+ [PictOpSrc] = {0, 0, GL_ONE, GL_ZERO},
+ [PictOpDst] = {0, 0, GL_ZERO, GL_ONE},
+ [PictOpOver] = {0, 1, GL_ONE, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpOverReverse] = {1, 0, GL_ONE_MINUS_DST_ALPHA, GL_ONE},
+ [PictOpIn] = {1, 0, GL_DST_ALPHA, GL_ZERO},
+ [PictOpInReverse] = {0, 1, GL_ZERO, GL_SRC_ALPHA},
+ [PictOpOut] = {1, 0, GL_ONE_MINUS_DST_ALPHA, GL_ZERO},
+ [PictOpOutReverse] = {0, 1, GL_ZERO, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpAtop] = {1, 1, GL_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpAtopReverse] = {1, 1, GL_ONE_MINUS_DST_ALPHA, GL_SRC_ALPHA},
+ [PictOpXor] = {1, 1, GL_ONE_MINUS_DST_ALPHA, GL_ONE_MINUS_SRC_ALPHA},
+ [PictOpAdd] = {0, 0, GL_ONE, GL_ONE},
+};
+
+static void
+glamor_set_blend(CARD8 op, glamor_program_alpha alpha, PicturePtr dst)
+{
+ GLenum src_blend, dst_blend;
+ struct blendinfo *op_info;
+
+ switch (alpha) {
+ case glamor_program_alpha_ca_first:
+ op = PictOpOutReverse;
+ break;
+ case glamor_program_alpha_ca_second:
+ op = PictOpAdd;
+ break;
+ default:
+ break;
+ }
+
+ if (op == PictOpSrc)
+ return;
+
+ op_info = &composite_op_info[op];
+
+ src_blend = op_info->source_blend;
+ dst_blend = op_info->dest_blend;
+
+ /* If there's no dst alpha channel, adjust the blend op so that we'll treat
+ * it as always 1.
+ */
+ if (PICT_FORMAT_A(dst->format) == 0 && op_info->dest_alpha) {
+ if (src_blend == GL_DST_ALPHA)
+ src_blend = GL_ONE;
+ else if (src_blend == GL_ONE_MINUS_DST_ALPHA)
+ src_blend = GL_ZERO;
+ }
+
+ /* Set up the source alpha value for blending in component alpha mode. */
+ if (alpha != glamor_program_alpha_normal && op_info->source_alpha) {
+ if (dst_blend == GL_SRC_ALPHA)
+ dst_blend = GL_SRC_COLOR;
+ else if (dst_blend == GL_ONE_MINUS_SRC_ALPHA)
+ dst_blend = GL_ONE_MINUS_SRC_COLOR;
+ }
+
+ glEnable(GL_BLEND);
+ glBlendFunc(src_blend, dst_blend);
+}
+
+static Bool
+use_source_solid(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
+{
+
+ glamor_set_blend(op, prog->alpha, dst);
+
+ glamor_set_color(glamor_get_drawable_pixmap(dst->pDrawable),
+ src->pSourcePict->solidFill.color,
+ prog->fg_uniform);
+ return TRUE;
+}
+
+const glamor_facet glamor_source_solid = {
+ .name = "render_solid",
+ .fs_exec = " vec4 source = fg;\n",
+ .locations = glamor_program_location_fg,
+ .use_render = use_source_solid,
+};
+
+static Bool
+use_source_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
+{
+ glamor_set_blend(op, prog->alpha, dst);
+
+ return glamor_set_texture((PixmapPtr) src->pDrawable,
+ 0, 0,
+ prog->fill_offset_uniform,
+ prog->fill_size_inv_uniform);
+}
+
+const glamor_facet glamor_source_picture = {
+ .name = "render_picture",
+ .vs_exec = " fill_pos = (fill_offset + primitive.xy + pos) * fill_size_inv;\n",
+ .fs_exec = " vec4 source = texture2D(sampler, fill_pos);\n",
+ .locations = glamor_program_location_fillsamp | glamor_program_location_fillpos,
+ .use_render = use_source_picture,
+};
+
+static Bool
+use_source_1x1_picture(CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog)
+{
+ glamor_set_blend(op, prog->alpha, dst);
+
+ return glamor_set_texture_pixmap((PixmapPtr) src->pDrawable);
+}
+
+const glamor_facet glamor_source_1x1_picture = {
+ .name = "render_picture",
+ .fs_exec = " vec4 source = texture2D(sampler, vec2(0.5));\n",
+ .locations = glamor_program_location_fillsamp,
+ .use_render = use_source_1x1_picture,
+};
+
+const glamor_facet *glamor_facet_source[glamor_program_source_count] = {
+ [glamor_program_source_solid] = &glamor_source_solid,
+ [glamor_program_source_picture] = &glamor_source_picture,
+ [glamor_program_source_1x1_picture] = &glamor_source_1x1_picture,
+};
+
+static const char *glamor_combine[] = {
+ [glamor_program_alpha_normal] = " gl_FragColor = source * mask.a;\n",
+ [glamor_program_alpha_ca_first] = " gl_FragColor = source.a * mask;\n",
+ [glamor_program_alpha_ca_second] = " gl_FragColor = source * mask;\n"
+};
+
+static Bool
+glamor_setup_one_program_render(ScreenPtr screen,
+ glamor_program *prog,
+ glamor_program_source source_type,
+ glamor_program_alpha alpha,
+ const glamor_facet *prim,
+ const char *defines)
+{
+ if (prog->failed)
+ return FALSE;
+
+ if (!prog->prog) {
+ const glamor_facet *fill = glamor_facet_source[source_type];
+
+ if (!fill)
+ return FALSE;
+
+ if (!glamor_build_program(screen, prog, prim, fill, glamor_combine[alpha], defines))
+ return FALSE;
+ prog->alpha = alpha;
+ }
+
+ return TRUE;
+}
+
+glamor_program *
+glamor_setup_program_render(CARD8 op,
+ PicturePtr src,
+ PicturePtr mask,
+ PicturePtr dst,
+ glamor_program_render *program_render,
+ const glamor_facet *prim,
+ const char *defines)
+{
+ ScreenPtr screen = dst->pDrawable->pScreen;
+ glamor_program_alpha alpha;
+ glamor_program_source source_type;
+ glamor_program *prog;
+
+ if (op > ARRAY_SIZE(composite_op_info))
+ return NULL;
+
+ if (glamor_is_component_alpha(mask)) {
+ /* This only works for PictOpOver */
+ if (op != PictOpOver)
+ return NULL;
+ alpha = glamor_program_alpha_ca_first;
+ } else
+ alpha = glamor_program_alpha_normal;
+
+ if (src->pDrawable) {
+
+ /* Can't do transforms, alphamaps or sourcing from non-pixmaps yet */
+ if (src->transform || src->alphaMap || src->pDrawable->type != DRAWABLE_PIXMAP)
+ return NULL;
+
+ if (src->pDrawable->width == 1 && src->pDrawable->height == 1 && src->repeat)
+ source_type = glamor_program_source_1x1_picture;
+ else
+ source_type = glamor_program_source_picture;
+ } else {
+ SourcePictPtr sp = src->pSourcePict;
+ if (!sp)
+ return NULL;
+ switch (sp->type) {
+ case SourcePictTypeSolidFill:
+ source_type = glamor_program_source_solid;
+ break;
+ default:
+ return NULL;
+ }
+ }
+
+ prog = &program_render->progs[source_type][alpha];
+ if (!glamor_setup_one_program_render(screen, prog, source_type, alpha, prim, defines))
+ return NULL;
+
+ if (alpha == glamor_program_alpha_ca_first) {
+
+ /* Make sure we can also build the second program before
+ * deciding to use this path.
+ */
+ if (!glamor_setup_one_program_render(screen,
+ &program_render->progs[source_type][glamor_program_alpha_ca_second],
+ source_type, glamor_program_alpha_ca_second, prim,
+ defines))
+ return NULL;
+ }
+ return prog;
+}
+
+Bool
+glamor_use_program_render(glamor_program *prog,
+ CARD8 op,
+ PicturePtr src,
+ PicturePtr dst)
+{
+ glUseProgram(prog->prog);
+
+ if (prog->prim_use_render && !prog->prim_use_render(op, src, dst, prog))
+ return FALSE;
+
+ if (prog->fill_use_render && !prog->fill_use_render(op, src, dst, prog))
+ return FALSE;
+ return TRUE;
+}
diff --git a/xorg-server/glamor/glamor_program.h b/xorg-server/glamor/glamor_program.h
index fa3877c5d..9e561cd92 100644
--- a/xorg-server/glamor/glamor_program.h
+++ b/xorg-server/glamor/glamor_program.h
@@ -27,23 +27,36 @@ typedef enum {
glamor_program_location_none = 0,
glamor_program_location_fg = 1,
glamor_program_location_bg = 2,
- glamor_program_location_fill = 4,
- glamor_program_location_font = 8,
- glamor_program_location_bitplane = 16,
- glamor_program_location_dash = 32,
+ glamor_program_location_fillsamp = 4,
+ glamor_program_location_fillpos = 8,
+ glamor_program_location_font = 16,
+ glamor_program_location_bitplane = 32,
+ glamor_program_location_dash = 64,
+ glamor_program_location_atlas = 128,
} glamor_program_location;
typedef enum {
glamor_program_flag_none = 0,
} glamor_program_flag;
+typedef enum {
+ glamor_program_alpha_normal,
+ glamor_program_alpha_ca_first,
+ glamor_program_alpha_ca_second,
+ glamor_program_alpha_count
+} glamor_program_alpha;
+
typedef struct _glamor_program glamor_program;
typedef Bool (*glamor_use) (PixmapPtr pixmap, GCPtr gc, glamor_program *prog, void *arg);
+typedef Bool (*glamor_use_render) (CARD8 op, PicturePtr src, PicturePtr dst, glamor_program *prog);
+
typedef struct {
const char *name;
const int version;
+ char *vs_defines;
+ char *fs_defines;
const char *vs_vars;
const char *vs_exec;
const char *fs_vars;
@@ -52,6 +65,7 @@ typedef struct {
const glamor_program_flag flags;
const char *source_name;
glamor_use use;
+ glamor_use_render use_render;
} glamor_facet;
struct _glamor_program {
@@ -67,10 +81,14 @@ struct _glamor_program {
GLint bitmul_uniform;
GLint dash_uniform;
GLint dash_length_uniform;
+ GLint atlas_uniform;
glamor_program_location locations;
glamor_program_flag flags;
glamor_use prim_use;
glamor_use fill_use;
+ glamor_program_alpha alpha;
+ glamor_use_render prim_use_render;
+ glamor_use_render fill_use_render;
};
typedef struct {
@@ -83,7 +101,9 @@ Bool
glamor_build_program(ScreenPtr screen,
glamor_program *prog,
const glamor_facet *prim,
- const glamor_facet *fill);
+ const glamor_facet *fill,
+ const char *combine,
+ const char *defines);
Bool
glamor_use_program(PixmapPtr pixmap,
@@ -97,4 +117,37 @@ glamor_use_program_fill(PixmapPtr pixmap,
glamor_program_fill *program_fill,
const glamor_facet *prim);
+typedef enum {
+ glamor_program_source_solid,
+ glamor_program_source_picture,
+ glamor_program_source_1x1_picture,
+ glamor_program_source_count,
+} glamor_program_source;
+
+typedef struct {
+ glamor_program progs[glamor_program_source_count][glamor_program_alpha_count];
+} glamor_program_render;
+
+static inline Bool
+glamor_is_component_alpha(PicturePtr mask) {
+ if (mask && mask->componentAlpha && PICT_FORMAT_RGB(mask->format))
+ return TRUE;
+ return FALSE;
+}
+
+glamor_program *
+glamor_setup_program_render(CARD8 op,
+ PicturePtr src,
+ PicturePtr mask,
+ PicturePtr dst,
+ glamor_program_render *program_render,
+ const glamor_facet *prim,
+ const char *defines);
+
+Bool
+glamor_use_program_render(glamor_program *prog,
+ CARD8 op,
+ PicturePtr src,
+ PicturePtr dst);
+
#endif /* _GLAMOR_PROGRAM_H_ */
diff --git a/xorg-server/glamor/glamor_render.c b/xorg-server/glamor/glamor_render.c
index 27c09fd48..efca36744 100644
--- a/xorg-server/glamor/glamor_render.c
+++ b/xorg-server/glamor/glamor_render.c
@@ -1701,139 +1701,3 @@ glamor_composite(CARD8 op,
glamor_finish_access_picture(source);
glamor_finish_access_picture(dest);
}
-
-static void
-glamor_get_src_rect_extent(int nrect,
- glamor_composite_rect_t *rects, BoxPtr extent)
-{
- extent->x1 = MAXSHORT;
- extent->y1 = MAXSHORT;
- extent->x2 = MINSHORT;
- extent->y2 = MINSHORT;
-
- while (nrect--) {
- if (extent->x1 > rects->x_src)
- extent->x1 = rects->x_src;
- if (extent->y1 > rects->y_src)
- extent->y1 = rects->y_src;
- if (extent->x2 < rects->x_src + rects->width)
- extent->x2 = rects->x_src + rects->width;
- if (extent->y2 < rects->y_src + rects->height)
- extent->y2 = rects->y_src + rects->height;
- rects++;
- }
-}
-
-static void
-glamor_composite_src_rect_translate(int nrect,
- glamor_composite_rect_t *rects,
- int x, int y)
-{
- while (nrect--) {
- rects->x_src += x;
- rects->y_src += y;
- rects++;
- }
-}
-
-void
-glamor_composite_glyph_rects(CARD8 op,
- PicturePtr src, PicturePtr mask, PicturePtr dst,
- int nrect, glamor_composite_rect_t *rects)
-{
- int n;
- PicturePtr temp_src = NULL;
- glamor_composite_rect_t *r;
-
- ValidatePicture(src);
- ValidatePicture(dst);
- if (!(glamor_is_large_picture(src)
- || (mask && glamor_is_large_picture(mask))
- || glamor_is_large_picture(dst))) {
- PixmapPtr src_pixmap = NULL;
- PixmapPtr mask_pixmap = NULL;
- PixmapPtr dst_pixmap = NULL;
- PixmapPtr temp_src_pixmap = NULL;
- glamor_pixmap_private *src_pixmap_priv = NULL;
- glamor_pixmap_private *mask_pixmap_priv = NULL;
- glamor_pixmap_private *dst_pixmap_priv;
- glamor_pixmap_private *temp_src_priv = NULL;
- BoxRec src_extent;
-
- dst_pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
- dst_pixmap_priv = glamor_get_pixmap_private(dst_pixmap);
-
- if (mask && mask->pDrawable) {
- mask_pixmap = glamor_get_drawable_pixmap(mask->pDrawable);
- mask_pixmap_priv = glamor_get_pixmap_private(mask_pixmap);
- }
- if (src->pDrawable) {
- src_pixmap = glamor_get_drawable_pixmap(src->pDrawable);
- src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
- }
-
- if (!src->pDrawable
- && (src->pSourcePict->type != SourcePictTypeSolidFill)) {
- glamor_get_src_rect_extent(nrect, rects, &src_extent);
- temp_src = glamor_convert_gradient_picture(dst->pDrawable->pScreen,
- src,
- src_extent.x1,
- src_extent.y1,
- src_extent.x2 -
- src_extent.x1,
- src_extent.y2 -
- src_extent.y1);
- if (!temp_src)
- goto fallback;
-
- temp_src_pixmap = (PixmapPtr) (temp_src->pDrawable);
- temp_src_priv = glamor_get_pixmap_private(temp_src_pixmap);
- glamor_composite_src_rect_translate(nrect, rects,
- -src_extent.x1, -src_extent.y1);
- }
- else {
- temp_src = src;
- temp_src_pixmap = src_pixmap;
- temp_src_priv = src_pixmap_priv;
- }
-
- if (mask && mask->componentAlpha) {
- if (op == PictOpOver) {
- if (glamor_composite_with_shader(PictOpOutReverse,
- temp_src, mask, dst,
- temp_src_pixmap, mask_pixmap, dst_pixmap,
- temp_src_priv,
- mask_pixmap_priv,
- dst_pixmap_priv, nrect, rects,
- TRUE))
- goto done;
- }
- }
- else {
- if (glamor_composite_with_shader
- (op, temp_src, mask, dst,
- temp_src_pixmap, mask_pixmap, dst_pixmap,
- temp_src_priv, mask_pixmap_priv,
- dst_pixmap_priv, nrect, rects, FALSE))
- goto done;
- }
- }
- fallback:
- n = nrect;
- r = rects;
-
- while (n--) {
- CompositePicture(op,
- temp_src ? temp_src : src,
- mask,
- dst,
- r->x_src, r->y_src,
- r->x_mask, r->y_mask,
- r->x_dst, r->y_dst, r->width, r->height);
- r++;
- }
-
- done:
- if (temp_src && temp_src != src)
- FreePicture(temp_src, 0);
-}
diff --git a/xorg-server/glamor/glamor_spans.c b/xorg-server/glamor/glamor_spans.c
index b358c60bd..58da3edf7 100644
--- a/xorg-server/glamor/glamor_spans.c
+++ b/xorg-server/glamor/glamor_spans.c
@@ -279,7 +279,7 @@ glamor_set_spans_gl(DrawablePtr drawable, GCPtr gc, char *src,
if (gc->alu != GXcopy)
goto bail;
- if (!glamor_pm_is_solid(&pixmap->drawable, gc->planemask))
+ if (!glamor_pm_is_solid(gc->depth, gc->planemask))
goto bail;
glamor_get_drawable_deltas(drawable, pixmap, &off_x, &off_y);
diff --git a/xorg-server/glamor/glamor_text.c b/xorg-server/glamor/glamor_text.c
index c7c1ab738..81a22a5af 100644
--- a/xorg-server/glamor/glamor_text.c
+++ b/xorg-server/glamor/glamor_text.c
@@ -417,7 +417,7 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
fill_facet = &glamor_facet_image_fill;
}
- if (!glamor_build_program(screen, prog, prim_facet, fill_facet))
+ if (!glamor_build_program(screen, prog, prim_facet, fill_facet, NULL, NULL))
goto bail;
}
@@ -431,7 +431,7 @@ glamor_image_text(DrawablePtr drawable, GCPtr gc,
/* Check planemask before drawing background to
* bail early if it's not OK
*/
- if (!glamor_set_planemask(pixmap, gc->planemask))
+ if (!glamor_set_planemask(gc->depth, gc->planemask))
goto bail;
for (c = 0; c < count; c++)
if (charinfo[c])
diff --git a/xorg-server/glamor/glamor_transform.c b/xorg-server/glamor/glamor_transform.c
index 6d29e9eb6..f476a99b7 100644
--- a/xorg-server/glamor/glamor_transform.c
+++ b/xorg-server/glamor/glamor_transform.c
@@ -129,7 +129,7 @@ glamor_set_solid(PixmapPtr pixmap,
CARD32 pixel;
int alu = use_alu ? gc->alu : GXcopy;
- if (!glamor_set_planemask(pixmap, gc->planemask))
+ if (!glamor_set_planemask(gc->depth, gc->planemask))
return FALSE;
pixel = gc->fgPixel;
@@ -155,12 +155,7 @@ glamor_set_solid(PixmapPtr pixmap,
}
Bool
-glamor_set_texture(PixmapPtr pixmap,
- PixmapPtr texture,
- int off_x,
- int off_y,
- GLint offset_uniform,
- GLint size_inv_uniform)
+glamor_set_texture_pixmap(PixmapPtr texture)
{
glamor_pixmap_private *texture_priv;
@@ -175,6 +170,23 @@ glamor_set_texture(PixmapPtr pixmap,
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture_priv->fbo->tex);
+ /* we're not setting the sampler uniform here as we always use
+ * GL_TEXTURE0, and the default value for uniforms is zero. So,
+ * save a bit of CPU time by taking advantage of that.
+ */
+ return TRUE;
+}
+
+Bool
+glamor_set_texture(PixmapPtr texture,
+ int off_x,
+ int off_y,
+ GLint offset_uniform,
+ GLint size_inv_uniform)
+{
+ if (!glamor_set_texture_pixmap(texture))
+ return FALSE;
+
glUniform2f(offset_uniform, off_x, off_y);
glUniform2f(size_inv_uniform, 1.0f/texture->drawable.width, 1.0f/texture->drawable.height);
return TRUE;
@@ -189,11 +201,10 @@ glamor_set_tiled(PixmapPtr pixmap,
if (!glamor_set_alu(pixmap->drawable.pScreen, gc->alu))
return FALSE;
- if (!glamor_set_planemask(pixmap, gc->planemask))
+ if (!glamor_set_planemask(gc->depth, gc->planemask))
return FALSE;
- return glamor_set_texture(pixmap,
- gc->tile.pixmap,
+ return glamor_set_texture(gc->tile.pixmap,
-gc->patOrg.x,
-gc->patOrg.y,
offset_uniform,
@@ -274,8 +285,7 @@ glamor_set_stippled(PixmapPtr pixmap,
if (!glamor_set_solid(pixmap, gc, TRUE, fg_uniform))
return FALSE;
- return glamor_set_texture(pixmap,
- stipple,
+ return glamor_set_texture(stipple,
-gc->patOrg.x,
-gc->patOrg.y,
offset_uniform,
diff --git a/xorg-server/glamor/glamor_transform.h b/xorg-server/glamor/glamor_transform.h
index 36b789af8..dca6a26ab 100644
--- a/xorg-server/glamor/glamor_transform.h
+++ b/xorg-server/glamor/glamor_transform.h
@@ -39,8 +39,10 @@ glamor_set_color(PixmapPtr pixmap,
GLint uniform);
Bool
-glamor_set_texture(PixmapPtr pixmap,
- PixmapPtr texture,
+glamor_set_texture_pixmap(PixmapPtr texture);
+
+Bool
+glamor_set_texture(PixmapPtr texture,
int off_x,
int off_y,
GLint offset_uniform,
diff --git a/xorg-server/glamor/glamor_utils.c b/xorg-server/glamor/glamor_utils.c
index f06896096..d3e6fd3ff 100644
--- a/xorg-server/glamor/glamor_utils.c
+++ b/xorg-server/glamor/glamor_utils.c
@@ -31,7 +31,7 @@ glamor_solid_boxes(PixmapPtr pixmap,
xRectangle *rect;
int n;
- rect = malloc(nbox * sizeof (xRectangle));
+ rect = xallocarray(nbox, sizeof(xRectangle));
if (!rect)
return;
for (n = 0; n < nbox; n++) {
diff --git a/xorg-server/glx/single2.c b/xorg-server/glx/single2.c
index a6ea614fd..acc66ac07 100644
--- a/xorg-server/glx/single2.c
+++ b/xorg-server/glx/single2.c
@@ -62,9 +62,8 @@ __glXDisp_FeedbackBuffer(__GLXclientState * cl, GLbyte * pc)
size = *(GLsizei *) (pc + 0);
type = *(GLenum *) (pc + 4);
if (cx->feedbackBufSize < size) {
- cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf,
- (size_t) size
- * __GLX_SIZE_FLOAT32);
+ cx->feedbackBuf = reallocarray(cx->feedbackBuf,
+ (size_t) size, __GLX_SIZE_FLOAT32);
if (!cx->feedbackBuf) {
cl->client->errorValue = size;
return BadAlloc;
@@ -94,8 +93,8 @@ __glXDisp_SelectBuffer(__GLXclientState * cl, GLbyte * pc)
pc += __GLX_SINGLE_HDR_SIZE;
size = *(GLsizei *) (pc + 0);
if (cx->selectBufSize < size) {
- cx->selectBuf = (GLuint *) realloc(cx->selectBuf,
- (size_t) size * __GLX_SIZE_CARD32);
+ cx->selectBuf = reallocarray(cx->selectBuf,
+ (size_t) size, __GLX_SIZE_CARD32);
if (!cx->selectBuf) {
cl->client->errorValue = size;
return BadAlloc;
diff --git a/xorg-server/glx/single2swap.c b/xorg-server/glx/single2swap.c
index 53490694b..d5bb1c03c 100644
--- a/xorg-server/glx/single2swap.c
+++ b/xorg-server/glx/single2swap.c
@@ -63,9 +63,8 @@ __glXDispSwap_FeedbackBuffer(__GLXclientState * cl, GLbyte * pc)
size = *(GLsizei *) (pc + 0);
type = *(GLenum *) (pc + 4);
if (cx->feedbackBufSize < size) {
- cx->feedbackBuf = (GLfloat *) realloc(cx->feedbackBuf,
- (size_t) size
- * __GLX_SIZE_FLOAT32);
+ cx->feedbackBuf = reallocarray(cx->feedbackBuf,
+ (size_t) size, __GLX_SIZE_FLOAT32);
if (!cx->feedbackBuf) {
cl->client->errorValue = size;
return BadAlloc;
@@ -99,8 +98,8 @@ __glXDispSwap_SelectBuffer(__GLXclientState * cl, GLbyte * pc)
__GLX_SWAP_INT(pc + 0);
size = *(GLsizei *) (pc + 0);
if (cx->selectBufSize < size) {
- cx->selectBuf = (GLuint *) realloc(cx->selectBuf,
- (size_t) size * __GLX_SIZE_CARD32);
+ cx->selectBuf = reallocarray(cx->selectBuf,
+ (size_t) size, __GLX_SIZE_CARD32);
if (!cx->selectBuf) {
cl->client->errorValue = size;
return BadAlloc;
diff --git a/xorg-server/hw/dmx/config/dmxconfig.c b/xorg-server/hw/dmx/config/dmxconfig.c
index 2cc9ab396..1d10ec018 100644
--- a/xorg-server/hw/dmx/config/dmxconfig.c
+++ b/xorg-server/hw/dmx/config/dmxconfig.c
@@ -204,8 +204,8 @@ dmxConfigAddDisplay(const char *name,
{
DMXScreenInfo *dmxScreen;
- if (!(dmxScreens = realloc(dmxScreens,
- (dmxNumScreens + 1) * sizeof(*dmxScreens))))
+ if (!(dmxScreens = reallocarray(dmxScreens, dmxNumScreens + 1,
+ sizeof(*dmxScreens))))
dmxLog(dmxFatal,
"dmxConfigAddDisplay: realloc failed for screen %d (%s)\n",
dmxNumScreens, name);
@@ -234,8 +234,8 @@ dmxConfigAddInput(const char *name, int core)
{
DMXInputInfo *dmxInput;
- if (!(dmxInputs = realloc(dmxInputs,
- (dmxNumInputs + 1) * sizeof(*dmxInputs))))
+ if (!(dmxInputs = reallocarray(dmxInputs, dmxNumInputs + 1,
+ sizeof(*dmxInputs))))
dmxLog(dmxFatal,
"dmxConfigAddInput: realloc failed for input %d (%s)\n",
dmxNumInputs, name);
@@ -341,7 +341,7 @@ dmxConfigCopyFromOption(DMXConfigOptionPtr o)
for (pt = o->option; pt; pt = pt->next) {
if (pt->string) {
++argc;
- argv = realloc(argv, (argc + 1) * sizeof(*argv));
+ argv = reallocarray(argv, argc + 1, sizeof(*argv));
argv[argc] = (char *) pt->string;
}
}
diff --git a/xorg-server/hw/dmx/dmx.c b/xorg-server/hw/dmx/dmx.c
index 2988df33a..9729963da 100644
--- a/xorg-server/hw/dmx/dmx.c
+++ b/xorg-server/hw/dmx/dmx.c
@@ -427,7 +427,7 @@ ProcDMXChangeScreensAttributes(ClientPtr client)
if (!_DMXXineramaActive())
goto noxinerama;
- if (!(attribs = malloc(stuff->screenCount * sizeof(*attribs))))
+ if (!(attribs = xallocarray(stuff->screenCount, sizeof(*attribs))))
return BadAlloc;
for (i = 0; i < stuff->screenCount; i++) {
@@ -624,18 +624,18 @@ ProcDMXGetWindowAttributes(ClientPtr client)
REQUEST_SIZE_MATCH(xDMXGetWindowAttributesReq);
- if (!(screens = malloc(count * sizeof(*screens))))
+ if (!(screens = xallocarray(count, sizeof(*screens))))
return BadAlloc;
- if (!(windows = malloc(count * sizeof(*windows)))) {
+ if (!(windows = xallocarray(count, sizeof(*windows)))) {
free(screens);
return BadAlloc;
}
- if (!(pos = malloc(count * sizeof(*pos)))) {
+ if (!(pos = xallocarray(count, sizeof(*pos)))) {
free(windows);
free(screens);
return BadAlloc;
}
- if (!(vis = malloc(count * sizeof(*vis)))) {
+ if (!(vis = xallocarray(count, sizeof(*vis)))) {
free(pos);
free(windows);
free(screens);
diff --git a/xorg-server/hw/dmx/dmxcmap.c b/xorg-server/hw/dmx/dmxcmap.c
index 450627b40..7a87a9864 100644
--- a/xorg-server/hw/dmx/dmxcmap.c
+++ b/xorg-server/hw/dmx/dmxcmap.c
@@ -177,7 +177,7 @@ dmxStoreColors(ColormapPtr pColormap, int ndef, xColorItem * pdef)
dmxColormapPrivPtr pCmapPriv = DMX_GET_COLORMAP_PRIV(pColormap);
if (dmxScreen->beDisplay && (pColormap->pVisual->class & DynamicClass)) {
- XColor *color = malloc(sizeof(*color) * ndef);
+ XColor *color = xallocarray(ndef, sizeof(*color));
int i;
if (color) {
diff --git a/xorg-server/hw/dmx/dmxcursor.c b/xorg-server/hw/dmx/dmxcursor.c
index 70f2bc4b4..0ef800e39 100644
--- a/xorg-server/hw/dmx/dmxcursor.c
+++ b/xorg-server/hw/dmx/dmxcursor.c
@@ -203,7 +203,7 @@ miPointerScreenFuncRec dmxPointerCursorFuncs = {
static int *
dmxSLCreate(void)
{
- int *list = malloc(dmxNumScreens * sizeof(*list));
+ int *list = xallocarray(dmxNumScreens, sizeof(*list));
int i;
for (i = 0; i < dmxNumScreens; i++)
diff --git a/xorg-server/hw/dmx/dmxextension.c b/xorg-server/hw/dmx/dmxextension.c
index fcc97e3df..75d7166f3 100644
--- a/xorg-server/hw/dmx/dmxextension.c
+++ b/xorg-server/hw/dmx/dmxextension.c
@@ -1188,8 +1188,8 @@ dmxBERestoreRenderGlyph(void *value, XID id, void *n)
/* Now allocate the memory we need */
images = calloc(len_images, sizeof(char));
- gids = malloc(glyphSet->hash.tableEntries * sizeof(Glyph));
- glyphs = malloc(glyphSet->hash.tableEntries * sizeof(XGlyphInfo));
+ gids = xallocarray(glyphSet->hash.tableEntries, sizeof(Glyph));
+ glyphs = xallocarray(glyphSet->hash.tableEntries, sizeof(XGlyphInfo));
pos = images;
ctr = 0;
diff --git a/xorg-server/hw/dmx/dmxfont.c b/xorg-server/hw/dmx/dmxfont.c
index 115422d41..25a04a6f0 100644
--- a/xorg-server/hw/dmx/dmxfont.c
+++ b/xorg-server/hw/dmx/dmxfont.c
@@ -72,7 +72,7 @@ dmxGetFontPath(int *npaths)
newfp = malloc(*npaths + len);
c = (unsigned char *) newfp;
- fp = malloc(*npaths * sizeof(*fp));
+ fp = xallocarray(*npaths, sizeof(*fp));
memmove(newfp, paths + 1, *npaths + len - 1);
l = *paths;
@@ -306,7 +306,7 @@ dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
if (!dmxFontPath)
dmxLog(dmxWarning, "No default font path is set.\n");
- goodfps = malloc(npaths * sizeof(*goodfps));
+ goodfps = xallocarray(npaths, sizeof(*goodfps));
dmxLog(dmxError,
"The DMX server failed to set the following font paths on "
@@ -354,7 +354,7 @@ dmxBELoadFont(ScreenPtr pScreen, FontPtr pFont)
return FALSE;
}
- newfp = malloc(len * sizeof(*newfp));
+ newfp = xallocarray(len, sizeof(*newfp));
for (i = 0; i < npaths; i++) {
if (goodfps[i]) {
int n = strlen(fp[i]);
diff --git a/xorg-server/hw/dmx/dmxgc.c b/xorg-server/hw/dmx/dmxgc.c
index ec15d27aa..c4789a607 100644
--- a/xorg-server/hw/dmx/dmxgc.c
+++ b/xorg-server/hw/dmx/dmxgc.c
@@ -397,7 +397,7 @@ dmxChangeClip(GCPtr pGC, int type, void *pvalue, int nrects)
} else {
if (dmxScreen->beDisplay) {
nRects = RegionNumRects((RegionPtr) pGC->clientClip);
- pRects = malloc(nRects * sizeof(*pRects));
+ pRects = xallocarray(nRects, sizeof(*pRects));
pBox = RegionRects((RegionPtr) pGC->clientClip);
for (i = 0; i < nRects; i++) {
diff --git a/xorg-server/hw/dmx/dmxinit.c b/xorg-server/hw/dmx/dmxinit.c
index 025dc8637..3d394c52b 100644
--- a/xorg-server/hw/dmx/dmxinit.c
+++ b/xorg-server/hw/dmx/dmxinit.c
@@ -438,7 +438,7 @@ dmxGetColormaps(DMXScreenInfo * dmxScreen)
int i;
dmxScreen->beNumDefColormaps = dmxScreen->beNumVisuals;
- dmxScreen->beDefColormaps = malloc(dmxScreen->beNumDefColormaps *
+ dmxScreen->beDefColormaps = xallocarray(dmxScreen->beNumDefColormaps,
sizeof(*dmxScreen->beDefColormaps));
for (i = 0; i < dmxScreen->beNumDefColormaps; i++)
@@ -793,7 +793,7 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char *argv[])
nconfigs = dmxScreen->numGlxVisuals;
}
- configprivs = malloc(nconfigs * sizeof(dmxGlxVisualPrivate *));
+ configprivs = xallocarray(nconfigs, sizeof(dmxGlxVisualPrivate *));
if (configs != NULL && configprivs != NULL) {
int j;
diff --git a/xorg-server/hw/dmx/dmxpict.c b/xorg-server/hw/dmx/dmxpict.c
index aaca178b9..1f1022ee6 100644
--- a/xorg-server/hw/dmx/dmxpict.c
+++ b/xorg-server/hw/dmx/dmxpict.c
@@ -390,7 +390,7 @@ dmxProcRenderAddGlyphs(ClientPtr client)
sizeof(xRenderAddGlyphsReq) -
(sizeof(CARD32) + sizeof(xGlyphInfo)) * nglyphs);
- gidsCopy = malloc(sizeof(*gidsCopy) * nglyphs);
+ gidsCopy = xallocarray(nglyphs, sizeof(*gidsCopy));
for (i = 0; i < nglyphs; i++)
gidsCopy[i] = gids[i];
@@ -434,7 +434,7 @@ dmxProcRenderFreeGlyphs(ClientPtr client)
nglyphs = ((client->req_len << 2) - sizeof(xRenderFreeGlyphsReq)) >> 2;
if (nglyphs) {
- gids = malloc(sizeof(*gids) * nglyphs);
+ gids = xallocarray(nglyphs, sizeof(*gids));
for (i = 0; i < nglyphs; i++)
gids[i] = ((CARD32 *) (stuff + 1))[i];
@@ -569,11 +569,11 @@ dmxProcRenderCompositeGlyphs(ClientPtr client)
/* The following only works for Render version > 0.2 */
/* All of the XGlyphElt* structure sizes are identical */
- elts = malloc(nelt * sizeof(XGlyphElt8));
+ elts = xallocarray(nelt, sizeof(XGlyphElt8));
if (!elts)
return BadAlloc;
- glyphs = malloc(nglyph * size);
+ glyphs = xallocarray(nglyph, size);
if (!glyphs) {
free(elts);
return BadAlloc;
@@ -925,7 +925,7 @@ dmxChangePictureClip(PicturePtr pPicture, int clipType, void *value, int n)
int nRects;
nRects = nBox;
- pRects = pRect = malloc(nRects * sizeof(*pRect));
+ pRects = pRect = xallocarray(nRects, sizeof(*pRect));
while (nBox--) {
pRect->x = pBox->x1;
diff --git a/xorg-server/hw/dmx/dmxprop.c b/xorg-server/hw/dmx/dmxprop.c
index 5e306d286..4c85268b7 100644
--- a/xorg-server/hw/dmx/dmxprop.c
+++ b/xorg-server/hw/dmx/dmxprop.c
@@ -171,7 +171,7 @@ dmxPropertyCheckOtherServers(DMXScreenInfo * dmxScreen, Atom atom)
dmxLogOutputWarning(dmxScreen,
"%s also running on %s\n",
tp.value, dmxScreen->name);
- list = realloc(list, ++count * sizeof(*list));
+ list = reallocarray(list, ++count, sizeof(*list));
list[count - 1] = malloc(tp.nitems + 2);
strncpy(list[count - 1], (char *) tp.value, tp.nitems + 1);
}
diff --git a/xorg-server/hw/dmx/dmxwindow.c b/xorg-server/hw/dmx/dmxwindow.c
index c157e1099..dcdb9ac60 100644
--- a/xorg-server/hw/dmx/dmxwindow.c
+++ b/xorg-server/hw/dmx/dmxwindow.c
@@ -969,7 +969,7 @@ dmxDoSetShape(WindowPtr pWindow)
if (wBoundingShape(pWindow)) {
pBox = RegionRects(wBoundingShape(pWindow));
nRect = nBox = RegionNumRects(wBoundingShape(pWindow));
- pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
+ pRectFirst = pRect = xallocarray(nRect, sizeof(*pRect));
while (nBox--) {
pRect->x = pBox->x1;
pRect->y = pBox->y1;
@@ -992,7 +992,7 @@ dmxDoSetShape(WindowPtr pWindow)
if (wClipShape(pWindow)) {
pBox = RegionRects(wClipShape(pWindow));
nRect = nBox = RegionNumRects(wClipShape(pWindow));
- pRectFirst = pRect = malloc(nRect * sizeof(*pRect));
+ pRectFirst = pRect = xallocarray(nRect, sizeof(*pRect));
while (nBox--) {
pRect->x = pBox->x1;
pRect->y = pBox->y1;
diff --git a/xorg-server/hw/dmx/glxProxy/glxcmds.c b/xorg-server/hw/dmx/glxProxy/glxcmds.c
index 4c500c93d..ddcb98135 100644
--- a/xorg-server/hw/dmx/glxProxy/glxcmds.c
+++ b/xorg-server/hw/dmx/glxProxy/glxcmds.c
@@ -284,11 +284,11 @@ CreateContext(__GLXclientState * cl,
* allocate memory for back-end servers info
*/
num_be_screens = to_screen - from_screen + 1;
- glxc->real_ids = (XID *) malloc(sizeof(XID) * num_be_screens);
+ glxc->real_ids = xallocarray(num_be_screens, sizeof(XID));
if (!glxc->real_ids) {
return BadAlloc;
}
- glxc->real_vids = (XID *) malloc(sizeof(XID) * num_be_screens);
+ glxc->real_vids = xallocarray(num_be_screens, sizeof(XID));
if (!glxc->real_vids) {
return BadAlloc;
}
@@ -685,22 +685,16 @@ AddCurrentContext(__GLXclientState * cl, __GLXcontext * glxc, DrawablePtr pDraw)
if (!num) {
table = (__GLXcontext **) malloc(sizeof(__GLXcontext *));
cl->currentDrawables = (DrawablePtr *) malloc(sizeof(DrawablePtr));
- cl->be_currentCTag =
- (GLXContextTag *) malloc(screenInfo.numScreens *
- sizeof(GLXContextTag));
+ cl->be_currentCTag = xallocarray(screenInfo.numScreens,
+ sizeof(GLXContextTag));
}
else {
- table = (__GLXcontext **) realloc(table,
- (num + 1) * sizeof(__GLXcontext *));
- cl->currentDrawables = (DrawablePtr *) realloc(cl->currentDrawables,
- (num +
- 1) *
- sizeof(DrawablePtr));
- cl->be_currentCTag =
- (GLXContextTag *) realloc(cl->be_currentCTag,
- (num +
- 1) * screenInfo.numScreens *
- sizeof(GLXContextTag));
+ table = reallocarray(table, num + 1, sizeof(__GLXcontext *));
+ cl->currentDrawables = reallocarray(cl->currentDrawables, num + 1,
+ sizeof(DrawablePtr));
+ cl->be_currentCTag = reallocarray(cl->be_currentCTag,
+ (num + 1) * screenInfo.numScreens,
+ sizeof(GLXContextTag));
}
table[num] = glxc;
cl->currentDrawables[num] = pDraw;
@@ -1896,7 +1890,7 @@ CreateGLXPixmap(__GLXclientState * cl,
if (!pGlxPixmap) {
return BadAlloc;
}
- pGlxPixmap->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
+ pGlxPixmap->be_xids = xallocarray(screenInfo.numScreens, sizeof(XID));
if (!pGlxPixmap->be_xids) {
free(pGlxPixmap);
return BadAlloc;
@@ -3356,7 +3350,7 @@ __glXCreatePbuffer(__GLXclientState * cl, GLbyte * pc)
return BadAlloc;
}
- pGlxPbuffer->be_xids = (XID *) malloc(sizeof(XID) * screenInfo.numScreens);
+ pGlxPbuffer->be_xids = xallocarray(screenInfo.numScreens, sizeof(XID));
if (!pGlxPbuffer->be_xids) {
free(pGlxPbuffer);
return BadAlloc;
@@ -3617,13 +3611,13 @@ __glXGetDrawableAttributes(__GLXclientState * cl, GLbyte * pc)
}
if (reply.numAttribs) {
- attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
- attribs = (CARD32 *) malloc(attribs_size);
+ attribs = xallocarray(reply.numAttribs, 2 * __GLX_SIZE_CARD32);
if (attribs == NULL) {
UnlockDisplay(dpy);
SyncHandle();
return BadAlloc;
}
+ attribs_size = 2 * reply.numAttribs * __GLX_SIZE_CARD32;
_XRead(dpy, (char *) attribs, attribs_size);
}
diff --git a/xorg-server/hw/dmx/glxProxy/glxscreens.c b/xorg-server/hw/dmx/glxProxy/glxscreens.c
index 15bb1e862..508e67ed4 100644
--- a/xorg-server/hw/dmx/glxProxy/glxscreens.c
+++ b/xorg-server/hw/dmx/glxProxy/glxscreens.c
@@ -129,7 +129,7 @@ CalcServerVersionAndExtensions(void)
/*
* read extensions strings of all back-end servers
*/
- be_extensions = (char **) malloc(__glXNumActiveScreens * sizeof(char *));
+ be_extensions = xallocarray(__glXNumActiveScreens, sizeof(char *));
if (!be_extensions)
return;
@@ -237,10 +237,9 @@ __glXScreenInit(GLint numscreens)
// find the set of FBConfigs that are present on all back-end
// servers - only those configs will be supported
*/
- __glXFBConfigs = (__GLXFBConfig **) malloc(dmxScreen0->numFBConfigs *
- (numscreens +
- 1) *
- sizeof(__GLXFBConfig *));
+ __glXFBConfigs =
+ xallocarray(dmxScreen0->numFBConfigs * (numscreens + 1),
+ sizeof(__GLXFBConfig *));
__glXNumFBConfigs = 0;
for (c = 0; c < dmxScreen0->numFBConfigs; c++) {
diff --git a/xorg-server/hw/dmx/input/dmxarg.c b/xorg-server/hw/dmx/input/dmxarg.c
index 4a74b4c9e..6c21ae959 100644
--- a/xorg-server/hw/dmx/input/dmxarg.c
+++ b/xorg-server/hw/dmx/input/dmxarg.c
@@ -86,7 +86,7 @@ void
dmxArgAdd(dmxArg a, const char *string)
{
if (a->argm <= a->argc + 2)
- a->argv = realloc(a->argv, sizeof(*a->argv) * (a->argm *= 2));
+ a->argv = reallocarray(a->argv, (a->argm *= 2), sizeof(*a->argv));
a->argv[a->argc++] = strdup(string);
a->argv[a->argc] = NULL;
}
diff --git a/xorg-server/hw/dmx/input/dmxinputinit.c b/xorg-server/hw/dmx/input/dmxinputinit.c
index 56a39df8c..cdefd9ae0 100644
--- a/xorg-server/hw/dmx/input/dmxinputinit.c
+++ b/xorg-server/hw/dmx/input/dmxinputinit.c
@@ -814,8 +814,8 @@ dmxInputCopyLocal(DMXInputInfo * dmxInput, DMXLocalInputInfoPtr s)
dmxLocal->deviceId = -1;
++dmxInput->numDevs;
- dmxInput->devs = realloc(dmxInput->devs,
- dmxInput->numDevs * sizeof(*dmxInput->devs));
+ dmxInput->devs = reallocarray(dmxInput->devs,
+ dmxInput->numDevs, sizeof(*dmxInput->devs));
dmxInput->devs[dmxInput->numDevs - 1] = dmxLocal;
return dmxLocal;
diff --git a/xorg-server/hw/dmx/input/dmxmotion.c b/xorg-server/hw/dmx/input/dmxmotion.c
index 1642894a2..7f2cb8ed9 100644
--- a/xorg-server/hw/dmx/input/dmxmotion.c
+++ b/xorg-server/hw/dmx/input/dmxmotion.c
@@ -113,9 +113,8 @@ dmxPointerPutMotionEvent(DeviceIntPtr pDevice,
int i;
if (!dmxLocal->history) {
- dmxLocal->history = malloc(sizeof(*dmxLocal->history)
- * (numAxes + 1)
- * DMX_MOTION_SIZE);
+ dmxLocal->history = xallocarray(numAxes + 1,
+ sizeof(*dmxLocal->history) * DMX_MOTION_SIZE);
dmxLocal->head = 0;
dmxLocal->tail = 0;
dmxLocal->valuators = calloc(sizeof(*dmxLocal->valuators), numAxes);
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
index 3d5cf7721..748b608c2 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrdriext.c
@@ -431,8 +431,8 @@ EphyrDuplicateVisual(unsigned int a_screen,
* extend the list of visual IDs in that entry,
* so to add a_new_id in there.
*/
- vids = realloc(cur_depth->vids,
- (cur_depth->numVids + 1) * sizeof(VisualID));
+ vids = reallocarray(cur_depth->vids,
+ cur_depth->numVids + 1, sizeof(VisualID));
if (!vids) {
EPHYR_LOG_ERROR("failed to realloc numids\n");
goto out;
diff --git a/xorg-server/hw/kdrive/ephyr/ephyrinit.c b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
index 897aa1955..8fbaf1d44 100644
--- a/xorg-server/hw/kdrive/ephyr/ephyrinit.c
+++ b/xorg-server/hw/kdrive/ephyr/ephyrinit.c
@@ -52,6 +52,13 @@ void processScreenOrOutputArg(const char *screen_size, const char *output, char
void processOutputArg(const char *output, char *parent_id);
void processScreenArg(const char *screen_size, char *parent_id);
+int
+main(int argc, char *argv[], char *envp[])
+{
+ hostx_use_resname(basename(argv[0]), 0);
+ return dix_main(argc, argv, envp);
+}
+
void
InitCard(char *name)
{
@@ -209,10 +216,6 @@ ddxProcessArgument(int argc, char **argv, int i)
EPHYR_DBG("mark argv[%d]='%s'", i, argv[i]);
- if (i == 1) {
- hostx_use_resname(basename(argv[0]), 0);
- }
-
if (!strcmp(argv[i], "-parent")) {
if (i + 1 < argc) {
int j;
diff --git a/xorg-server/hw/kdrive/ephyr/hostx.c b/xorg-server/hw/kdrive/ephyr/hostx.c
index c67ff60d3..dc265d545 100644
--- a/xorg-server/hw/kdrive/ephyr/hostx.c
+++ b/xorg-server/hw/kdrive/ephyr/hostx.c
@@ -129,8 +129,8 @@ hostx_add_screen(KdScreenInfo *screen, unsigned long win_id, int screen_num, Boo
int index = HostX.n_screens;
HostX.n_screens += 1;
- HostX.screens = realloc(HostX.screens,
- HostX.n_screens * sizeof(HostX.screens[0]));
+ HostX.screens = reallocarray(HostX.screens,
+ HostX.n_screens, sizeof(HostX.screens[0]));
HostX.screens[index] = screen;
scrpriv->screen = screen;
@@ -177,7 +177,7 @@ hostx_set_win_title(KdScreenInfo *screen, const char *extra_text)
memset(buf, 0, BUF_LEN + 1);
snprintf(buf, BUF_LEN, "Xephyr on %s.%d %s",
- HostX.server_dpy_name,
+ HostX.server_dpy_name ? HostX.server_dpy_name : ":0",
scrpriv->mynum, (extra_text != NULL) ? extra_text : "");
xcb_icccm_set_wm_name(HostX.conn,
@@ -798,7 +798,7 @@ hostx_screen_init(KdScreenInfo *screen,
}
EPHYR_DBG("host_screen=%p x=%d, y=%d, wxh=%dx%d, buffer_height=%d",
- host_screen, x, y, width, height, buffer_height);
+ screen, x, y, width, height, buffer_height);
if (scrpriv->ximg != NULL) {
/* Free up the image data if previously used
@@ -866,8 +866,13 @@ hostx_screen_init(KdScreenInfo *screen,
~0,
NULL);
+ /* Match server byte order so that the image can be converted to
+ * the native byte order by xcb_image_put() before drawing */
+ if (host_depth_matches_server(scrpriv))
+ scrpriv->ximg->byte_order = IMAGE_BYTE_ORDER;
+
scrpriv->ximg->data =
- malloc(scrpriv->ximg->stride * buffer_height);
+ xallocarray(scrpriv->ximg->stride, buffer_height);
}
{
@@ -933,7 +938,7 @@ hostx_screen_init(KdScreenInfo *screen,
*bits_per_pixel = scrpriv->server_depth;
EPHYR_DBG("server bpp %i", bytes_per_pixel);
- scrpriv->fb_data = malloc (stride * buffer_height);
+ scrpriv->fb_data = xallocarray (stride, buffer_height);
return scrpriv->fb_data;
}
}
@@ -1034,8 +1039,11 @@ hostx_paint_rect(KdScreenInfo *screen,
sx, sy, dx, dy, width, height, FALSE);
}
else {
- xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, scrpriv->ximg,
- dx, dy, 0);
+ /* This is slow and could be done better */
+ xcb_image_t *img = xcb_image_native (HostX.conn, scrpriv->ximg, 1);
+ xcb_image_put(HostX.conn, scrpriv->win, HostX.gc, img, 0, 0, 0);
+ if (scrpriv->ximg != img)
+ xcb_image_destroy(img);
}
xcb_aux_sync(HostX.conn);
@@ -1148,9 +1156,9 @@ hostx_get_visuals_info(EphyrHostVisualInfo ** a_visuals, int *a_num_entries)
for (; depths.rem; xcb_depth_next(&depths)) {
xcb_visualtype_t *visuals = xcb_depth_visuals(depths.data);
EphyrHostVisualInfo *tmp_visuals =
- realloc(host_visuals,
- (nb_items + depths.data->visuals_len)
- * sizeof(EphyrHostVisualInfo));
+ reallocarray(host_visuals,
+ nb_items + depths.data->visuals_len,
+ sizeof(EphyrHostVisualInfo));
if (!tmp_visuals) {
goto out;
}
diff --git a/xorg-server/hw/kdrive/fake/Makefile.am b/xorg-server/hw/kdrive/fake/Makefile.am
index 14c99c3cc..d28bd2752 100644
--- a/xorg-server/hw/kdrive/fake/Makefile.am
+++ b/xorg-server/hw/kdrive/fake/Makefile.am
@@ -18,6 +18,7 @@ Xfake_SOURCES = \
Xfake_LDADD = \
libfake.la \
+ @KDRIVE_MAIN_LIB@ \
@KDRIVE_LIBS@
Xfake_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
diff --git a/xorg-server/hw/kdrive/fake/fake.c b/xorg-server/hw/kdrive/fake/fake.c
index 90e3ec9a6..04a727897 100644
--- a/xorg-server/hw/kdrive/fake/fake.c
+++ b/xorg-server/hw/kdrive/fake/fake.c
@@ -158,7 +158,7 @@ fakeMapFramebuffer(KdScreenInfo * screen)
priv->bytes_per_line =
((screen->width * screen->fb.bitsPerPixel + 31) >> 5) << 2;
free(priv->base);
- priv->base = malloc(priv->bytes_per_line * screen->height);
+ priv->base = xallocarray(priv->bytes_per_line, screen->height);
if (scrpriv->shadow) {
if (!KdShadowFbAlloc
diff --git a/xorg-server/hw/kdrive/fbdev/Makefile.am b/xorg-server/hw/kdrive/fbdev/Makefile.am
index 7e8ba024c..d550c1391 100644
--- a/xorg-server/hw/kdrive/fbdev/Makefile.am
+++ b/xorg-server/hw/kdrive/fbdev/Makefile.am
@@ -16,6 +16,7 @@ Xfbdev_SOURCES = \
Xfbdev_LDADD = \
libfbdev.la \
+ @KDRIVE_MAIN_LIB@ \
@KDRIVE_LIBS@
Xfbdev_DEPENDENCIES = \
diff --git a/xorg-server/hw/kdrive/fbdev/fbdev.c b/xorg-server/hw/kdrive/fbdev/fbdev.c
index 95f64cbef..23f750924 100644
--- a/xorg-server/hw/kdrive/fbdev/fbdev.c
+++ b/xorg-server/hw/kdrive/fbdev/fbdev.c
@@ -677,7 +677,7 @@ fbdevCreateColormap(ColormapPtr pmap)
case FB_VISUAL_STATIC_PSEUDOCOLOR:
pVisual = pmap->pVisual;
nent = pVisual->ColormapEntries;
- pdefs = malloc(nent * sizeof(xColorItem));
+ pdefs = xallocarray(nent, sizeof(xColorItem));
if (!pdefs)
return FALSE;
for (i = 0; i < nent; i++)
diff --git a/xorg-server/hw/kdrive/src/kshadow.c b/xorg-server/hw/kdrive/src/kshadow.c
index 828ea19a6..7f1e2ee19 100644
--- a/xorg-server/hw/kdrive/src/kshadow.c
+++ b/xorg-server/hw/kdrive/src/kshadow.c
@@ -36,7 +36,7 @@ KdShadowFbAlloc(KdScreenInfo * screen, Bool rotate)
/* use fb computation for width */
paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof(FbBits);
- buf = malloc(paddedWidth * height);
+ buf = xallocarray(paddedWidth, height);
if (!buf)
return FALSE;
if (screen->fb.shadow)
diff --git a/xorg-server/hw/kdrive/src/kxv.c b/xorg-server/hw/kdrive/src/kxv.c
index 369db3332..844deca0d 100644
--- a/xorg-server/hw/kdrive/src/kxv.c
+++ b/xorg-server/hw/kdrive/src/kxv.c
@@ -327,8 +327,8 @@ KdXVInitAdaptors(ScreenPtr pScreen, KdVideoAdaptorPtr infoPtr, int number)
void *moreSpace;
totFormat *= 2;
- moreSpace = realloc(pFormat,
- totFormat * sizeof(XvFormatRec));
+ moreSpace = reallocarray(pFormat, totFormat,
+ sizeof(XvFormatRec));
if (!moreSpace)
break;
pFormat = moreSpace;
diff --git a/xorg-server/hw/vfb/InitOutput.c b/xorg-server/hw/vfb/InitOutput.c
index bcaaa85e4..8b867e3b9 100644
--- a/xorg-server/hw/vfb/InitOutput.c
+++ b/xorg-server/hw/vfb/InitOutput.c
@@ -292,7 +292,7 @@ ddxProcessArgument(int argc, char *argv[], int i)
if (vfbNumScreens <= screenNum) {
vfbScreens =
- realloc(vfbScreens, sizeof(*vfbScreens) * (screenNum + 1));
+ reallocarray(vfbScreens, screenNum + 1, sizeof(*vfbScreens));
if (!vfbScreens)
FatalError("Not enough memory for screen %d\n", screenNum);
for (; vfbNumScreens <= screenNum; ++vfbNumScreens)
@@ -407,9 +407,9 @@ vfbInstallColormap(ColormapPtr pmap)
swapcopy32(pXWDHeader->bits_per_rgb, pVisual->bitsPerRGBValue);
swapcopy32(pXWDHeader->colormap_entries, pVisual->ColormapEntries);
- ppix = (Pixel *) malloc(entries * sizeof(Pixel));
- prgb = (xrgb *) malloc(entries * sizeof(xrgb));
- defs = (xColorItem *) malloc(entries * sizeof(xColorItem));
+ ppix = xallocarray(entries, sizeof(Pixel));
+ prgb = xallocarray(entries, sizeof(xrgb));
+ defs = xallocarray(entries, sizeof(xColorItem));
for (i = 0; i < entries; i++)
ppix[i] = i;
diff --git a/xorg-server/hw/xfree86/common/xf86AutoConfig.c b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
index 1450afbfc..6b8d0eb89 100644
--- a/xorg-server/hw/xfree86/common/xf86AutoConfig.c
+++ b/xorg-server/hw/xfree86/common/xf86AutoConfig.c
@@ -105,7 +105,7 @@ AppendToList(const char *s, const char ***list, int *lines)
str = xnfstrdup(s);
for (p = strtok(str, "\n"); p; p = strtok(NULL, "\n")) {
(*lines)++;
- *list = xnfrealloc(*list, (*lines + 1) * sizeof(**list));
+ *list = xnfreallocarray(*list, *lines + 1, sizeof(**list));
newstr = xnfalloc(strlen(p) + 2);
strcpy(newstr, p);
strcat(newstr, "\n");
diff --git a/xorg-server/hw/xfree86/common/xf86Bus.c b/xorg-server/hw/xfree86/common/xf86Bus.c
index 889294fe7..bd36fc5ab 100644
--- a/xorg-server/hw/xfree86/common/xf86Bus.c
+++ b/xorg-server/hw/xfree86/common/xf86Bus.c
@@ -256,11 +256,11 @@ int
xf86AllocateEntity(void)
{
xf86NumEntities++;
- xf86Entities = xnfrealloc(xf86Entities,
- sizeof(EntityPtr) * xf86NumEntities);
+ xf86Entities = xnfreallocarray(xf86Entities,
+ xf86NumEntities, sizeof(EntityPtr));
xf86Entities[xf86NumEntities - 1] = xnfcalloc(1, sizeof(EntityRec));
xf86Entities[xf86NumEntities - 1]->entityPrivates =
- xnfcalloc(sizeof(DevUnion) * xf86EntityPrivateCount, 1);
+ xnfcalloc(xf86EntityPrivateCount, sizeof(DevUnion));
return xf86NumEntities - 1;
}
@@ -326,12 +326,13 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
}
pScrn->numEntities++;
- pScrn->entityList = xnfrealloc(pScrn->entityList,
- pScrn->numEntities * sizeof(int));
+ pScrn->entityList = xnfreallocarray(pScrn->entityList,
+ pScrn->numEntities, sizeof(int));
pScrn->entityList[pScrn->numEntities - 1] = entityIndex;
xf86Entities[entityIndex]->inUse = TRUE;
- pScrn->entityInstanceList = xnfrealloc(pScrn->entityInstanceList,
- pScrn->numEntities * sizeof(int));
+ pScrn->entityInstanceList = xnfreallocarray(pScrn->entityInstanceList,
+ pScrn->numEntities,
+ sizeof(int));
pScrn->entityInstanceList[pScrn->numEntities - 1] = 0;
}
@@ -427,8 +428,8 @@ xf86AddDevToEntity(int entityIndex, GDevPtr dev)
pEnt = xf86Entities[entityIndex];
pEnt->numInstances++;
- pEnt->devices = xnfrealloc(pEnt->devices,
- pEnt->numInstances * sizeof(GDevPtr));
+ pEnt->devices = xnfreallocarray(pEnt->devices,
+ pEnt->numInstances, sizeof(GDevPtr));
pEnt->devices[pEnt->numInstances - 1] = dev;
dev->claimed = TRUE;
}
@@ -670,8 +671,8 @@ xf86AllocateEntityPrivateIndex(void)
idx = xf86EntityPrivateCount++;
for (i = 0; i < xf86NumEntities; i++) {
pEnt = xf86Entities[i];
- nprivs = xnfrealloc(pEnt->entityPrivates,
- xf86EntityPrivateCount * sizeof(DevUnion));
+ nprivs = xnfreallocarray(pEnt->entityPrivates,
+ xf86EntityPrivateCount, sizeof(DevUnion));
/* Zero the new private */
memset(&nprivs[idx], 0, sizeof(DevUnion));
pEnt->entityPrivates = nprivs;
diff --git a/xorg-server/hw/xfree86/common/xf86Config.c b/xorg-server/hw/xfree86/common/xf86Config.c
index d42572f38..b8ec8a0ef 100644
--- a/xorg-server/hw/xfree86/common/xf86Config.c
+++ b/xorg-server/hw/xfree86/common/xf86Config.c
@@ -126,7 +126,7 @@ static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
int scrnum, MessageType from);
static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
- Bool active);
+ Bool active, Bool gpu);
static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
MessageType from);
static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
@@ -363,8 +363,8 @@ xf86ModulelistFromConfig(void ***optlist)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char *));
- optarray = xnfalloc((count + 1) * sizeof(void *));
+ modulearray = xnfallocarray(count + 1, sizeof(char *));
+ optarray = xnfallocarray(count + 1, sizeof(void *));
count = 0;
if (xf86configptr->conf_modules) {
modp = xf86configptr->conf_modules->mod_load_lst;
@@ -390,7 +390,7 @@ const char **
xf86DriverlistFromConfig(void)
{
int count = 0;
- int j;
+ int j, k;
const char **modulearray;
screenLayoutPtr slp;
@@ -411,8 +411,10 @@ xf86DriverlistFromConfig(void)
*/
if (xf86ConfigLayout.screens) {
slp = xf86ConfigLayout.screens;
- while ((slp++)->screen) {
+ while (slp->screen) {
count++;
+ count += slp->screen->num_gpu_devices;
+ slp++;
}
}
@@ -429,12 +431,16 @@ xf86DriverlistFromConfig(void)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char *));
+ modulearray = xnfallocarray(count + 1, sizeof(char *));
count = 0;
slp = xf86ConfigLayout.screens;
while (slp->screen) {
modulearray[count] = slp->screen->device->driver;
count++;
+ for (k = 0; k < slp->screen->num_gpu_devices; k++) {
+ modulearray[count] = slp->screen->gpu_devices[k]->driver;
+ count++;
+ }
slp++;
}
@@ -493,7 +499,7 @@ xf86InputDriverlistFromConfig(void)
/*
* allocate the memory and walk the list again to fill in the pointers
*/
- modulearray = xnfalloc((count + 1) * sizeof(char *));
+ modulearray = xnfallocarray(count + 1, sizeof(char *));
count = 0;
idp = xf86ConfigLayout.inputs;
while (idp && *idp) {
@@ -1086,7 +1092,7 @@ addDevice(InputInfoPtr * list, InputInfoPtr pInfo)
for (devs = list; devs && *devs; devs++)
count++;
- list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr));
+ list = xnfreallocarray(list, count + 1, sizeof(InputInfoPtr));
list[count] = NULL;
list[count - 1] = pInfo;
@@ -1502,7 +1508,7 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
if (!count) /* alloc enough storage even if no screen is specified */
count = 1;
- slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
+ slp = xnfcalloc((count + 1), sizeof(screenLayoutRec));
slp[count].screen = NULL;
/*
* now that we have storage, loop over the list again and fill in our
@@ -1626,12 +1632,12 @@ configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
}
DebugF("Found %d inactive devices in the layout section %s\n",
count, conf_layout->lay_identifier);
- gdp = xnfalloc((count + 1) * sizeof(GDevRec));
+ gdp = xnfallocarray(count + 1, sizeof(GDevRec));
gdp[count].identifier = NULL;
idp = conf_layout->lay_inactive_lst;
count = 0;
while (idp) {
- if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
+ if (!configDevice(&gdp[count], idp->inactive_device, FALSE, FALSE))
goto bail;
count++;
idp = (XF86ConfInactivePtr) idp->list.next;
@@ -1746,7 +1752,7 @@ configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
count++;
conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
}
- adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
+ adaptor->ports = xnfallocarray(count, sizeof(confXvPortRec));
adaptor->numports = count;
count = 0;
conf_port = conf_adaptor->va_port_lst;
@@ -1769,6 +1775,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
XF86ConfAdaptorLinkPtr conf_adaptor;
Bool defaultMonitor = FALSE;
XF86ConfScreenRec local_conf_screen;
+ int i;
if (!conf_screen) {
memset(&local_conf_screen, 0, sizeof(local_conf_screen));
@@ -1811,12 +1818,41 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
"\tUsing the first device section listed.\n", screenp->id);
}
- if (configDevice(screenp->device, conf_screen->scrn_device, TRUE)) {
+ if (configDevice(screenp->device, conf_screen->scrn_device, TRUE, FALSE)) {
screenp->device->myScreenSection = screenp;
}
else {
screenp->device = NULL;
}
+
+ if (conf_screen->num_gpu_devices == 0 && xf86configptr->conf_device_lst) {
+ XF86ConfDevicePtr sdevice = xf86configptr->conf_device_lst->list.next;
+
+ for (i = 0; i < MAX_GPUDEVICES; i++) {
+ if (!sdevice)
+ break;
+
+ FIND_SUITABLE (XF86ConfDevicePtr, sdevice, conf_screen->scrn_gpu_devices[i]);
+ if (!conf_screen->scrn_gpu_devices[i])
+ break;
+ screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec));
+ if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) {
+ screenp->gpu_devices[i]->myScreenSection = screenp;
+ }
+ sdevice = conf_screen->scrn_gpu_devices[i]->list.next;
+ }
+ screenp->num_gpu_devices = i;
+
+ } else {
+ for (i = 0; i < conf_screen->num_gpu_devices; i++) {
+ screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec));
+ if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE, TRUE)) {
+ screenp->gpu_devices[i]->myScreenSection = screenp;
+ }
+ }
+ screenp->num_gpu_devices = conf_screen->num_gpu_devices;
+ }
+
screenp->options = conf_screen->scrn_option_lst;
/*
@@ -1827,7 +1863,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
count++;
dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
}
- screenp->displays = xnfalloc((count) * sizeof(DispRec));
+ screenp->displays = xnfallocarray(count, sizeof(DispRec));
screenp->numdisplays = count;
/* Fill in the default Virtual size, if any */
@@ -1857,7 +1893,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
count++;
conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
}
- screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
+ screenp->xvadaptors = xnfallocarray(count, sizeof(confXvAdaptorRec));
screenp->numxvadaptors = 0;
conf_adaptor = conf_screen->scrn_adaptor_lst;
while (conf_adaptor) {
@@ -2096,7 +2132,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
count++;
modep = (XF86ModePtr) modep->list.next;
}
- displayp->modes = xnfalloc((count + 1) * sizeof(char *));
+ displayp->modes = xnfallocarray(count + 1, sizeof(char *));
modep = conf_display->disp_mode_lst;
count = 0;
while (modep) {
@@ -2110,7 +2146,7 @@ configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
}
static Bool
-configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
+configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active, Bool gpu)
{
int i;
@@ -2118,10 +2154,14 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
return FALSE;
}
- if (active)
- xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
- conf_device->dev_identifier);
- else
+ if (active) {
+ if (gpu)
+ xf86Msg(X_CONFIG, "| |-->GPUDevice \"%s\"\n",
+ conf_device->dev_identifier);
+ else
+ xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
+ conf_device->dev_identifier);
+ } else
xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
conf_device->dev_identifier);
diff --git a/xorg-server/hw/xfree86/common/xf86Configure.c b/xorg-server/hw/xfree86/common/xf86Configure.c
index cc7ff1bb5..1271010fa 100644
--- a/xorg-server/hw/xfree86/common/xf86Configure.c
+++ b/xorg-server/hw/xfree86/common/xf86Configure.c
@@ -109,7 +109,7 @@ xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData,
/* Allocate new structure occurrence */
i = nDevToConfig++;
DevToConfig =
- xnfrealloc(DevToConfig, nDevToConfig * sizeof(DevToConfigRec));
+ xnfreallocarray(DevToConfig, nDevToConfig, sizeof(DevToConfigRec));
memset(DevToConfig + i, 0, sizeof(DevToConfigRec));
DevToConfig[i].GDev.chipID =
@@ -645,10 +645,10 @@ DoConfigure(void)
xf86DoConfigurePass1 = FALSE;
- dev2screen = xnfcalloc(1, xf86NumDrivers * sizeof(int));
+ dev2screen = xnfcalloc(xf86NumDrivers, sizeof(int));
{
- Bool *driverProbed = xnfcalloc(1, xf86NumDrivers * sizeof(Bool));
+ Bool *driverProbed = xnfcalloc(xf86NumDrivers, sizeof(Bool));
for (screennum = 0; screennum < nDevToConfig; screennum++) {
int k, l, n, oldNumScreens;
diff --git a/xorg-server/hw/xfree86/common/xf86DGA.c b/xorg-server/hw/xfree86/common/xf86DGA.c
index b9e1e3f88..9533e1c52 100644
--- a/xorg-server/hw/xfree86/common/xf86DGA.c
+++ b/xorg-server/hw/xfree86/common/xf86DGA.c
@@ -1349,7 +1349,7 @@ ProcXDGAQueryModes(ClientPtr client)
return Success;
}
- if (!(mode = (XDGAModePtr) malloc(num * sizeof(XDGAModeRec))))
+ if (!(mode = xallocarray(num, sizeof(XDGAModeRec))))
return BadAlloc;
for (i = 0; i < num; i++)
diff --git a/xorg-server/hw/xfree86/common/xf86Helper.c b/xorg-server/hw/xfree86/common/xf86Helper.c
index e2b32a074..359bac762 100644
--- a/xorg-server/hw/xfree86/common/xf86Helper.c
+++ b/xorg-server/hw/xfree86/common/xf86Helper.c
@@ -77,8 +77,8 @@ xf86AddDriver(DriverPtr driver, void *module, int flags)
xf86NumDrivers = 0;
xf86NumDrivers++;
- xf86DriverList = xnfrealloc(xf86DriverList,
- xf86NumDrivers * sizeof(DriverPtr));
+ xf86DriverList = xnfreallocarray(xf86DriverList,
+ xf86NumDrivers, sizeof(DriverPtr));
xf86DriverList[xf86NumDrivers - 1] = xnfalloc(sizeof(DriverRec));
if (flags & HaveDriverFuncs)
*xf86DriverList[xf86NumDrivers - 1] = *driver;
@@ -117,9 +117,9 @@ xf86AddInputDriver(InputDriverPtr driver, void *module, int flags)
xf86NumInputDrivers = 0;
xf86NumInputDrivers++;
- xf86InputDriverList = xnfrealloc(xf86InputDriverList,
- xf86NumInputDrivers *
- sizeof(InputDriverPtr));
+ xf86InputDriverList = xnfreallocarray(xf86InputDriverList,
+ xf86NumInputDrivers,
+ sizeof(InputDriverPtr));
xf86InputDriverList[xf86NumInputDrivers - 1] =
xnfalloc(sizeof(InputDriverRec));
*xf86InputDriverList[xf86NumInputDrivers - 1] = *driver;
@@ -173,7 +173,8 @@ xf86AllocateScreen(DriverPtr drv, int flags)
if (xf86GPUScreens == NULL)
xf86NumGPUScreens = 0;
i = xf86NumGPUScreens++;
- xf86GPUScreens = xnfrealloc(xf86GPUScreens, xf86NumGPUScreens * sizeof(ScrnInfoPtr));
+ xf86GPUScreens = xnfreallocarray(xf86GPUScreens, xf86NumGPUScreens,
+ sizeof(ScrnInfoPtr));
xf86GPUScreens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
pScrn = xf86GPUScreens[i];
pScrn->scrnIndex = i + GPU_SCREEN_OFFSET; /* Changes when a screen is removed */
@@ -183,7 +184,8 @@ xf86AllocateScreen(DriverPtr drv, int flags)
xf86NumScreens = 0;
i = xf86NumScreens++;
- xf86Screens = xnfrealloc(xf86Screens, xf86NumScreens * sizeof(ScrnInfoPtr));
+ xf86Screens = xnfreallocarray(xf86Screens, xf86NumScreens,
+ sizeof(ScrnInfoPtr));
xf86Screens[i] = xnfcalloc(sizeof(ScrnInfoRec), 1);
pScrn = xf86Screens[i];
@@ -293,16 +295,16 @@ xf86AllocateScrnInfoPrivateIndex(void)
idx = xf86ScrnInfoPrivateCount++;
for (i = 0; i < xf86NumScreens; i++) {
pScr = xf86Screens[i];
- nprivs = xnfrealloc(pScr->privates,
- xf86ScrnInfoPrivateCount * sizeof(DevUnion));
+ nprivs = xnfreallocarray(pScr->privates,
+ xf86ScrnInfoPrivateCount, sizeof(DevUnion));
/* Zero the new private */
memset(&nprivs[idx], 0, sizeof(DevUnion));
pScr->privates = nprivs;
}
for (i = 0; i < xf86NumGPUScreens; i++) {
pScr = xf86GPUScreens[i];
- nprivs = xnfrealloc(pScr->privates,
- xf86ScrnInfoPrivateCount * sizeof(DevUnion));
+ nprivs = xnfreallocarray(pScr->privates,
+ xf86ScrnInfoPrivateCount, sizeof(DevUnion));
/* Zero the new private */
memset(&nprivs[idx], 0, sizeof(DevUnion));
pScr->privates = nprivs;
@@ -636,8 +638,8 @@ xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int dummy, int fbbpp,
if (i == scrp->confScreen->numdisplays) {
scrp->confScreen->numdisplays++;
scrp->confScreen->displays =
- xnfrealloc(scrp->confScreen->displays,
- scrp->confScreen->numdisplays * sizeof(DispRec));
+ xnfreallocarray(scrp->confScreen->displays,
+ scrp->confScreen->numdisplays, sizeof(DispRec));
xf86DrvMsg(scrp->scrnIndex, X_INFO,
"Creating default Display subsection in Screen section\n"
"\t\"%s\" for depth/fbbpp %d/%d\n",
@@ -1367,7 +1369,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
{
GDevPtr gdp, *pgdp = NULL;
confScreenPtr screensecptr;
- int i, j;
+ int i, j, k;
if (sectlist)
*sectlist = NULL;
@@ -1408,9 +1410,20 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
/*
* we have a matching driver that wasn't claimed, yet
*/
- pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr));
pgdp[i++] = screensecptr->device;
}
+ for (k = 0; k < screensecptr->num_gpu_devices; k++) {
+ if ((screensecptr->gpu_devices[k]->driver != NULL)
+ && (xf86NameCmp(screensecptr->gpu_devices[k]->driver, drivername) == 0)
+ && (!screensecptr->gpu_devices[k]->claimed)) {
+ /*
+ * we have a matching driver that wasn't claimed, yet
+ */
+ pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp[i++] = screensecptr->gpu_devices[k];
+ }
+ }
}
/* Then handle the inactive devices */
@@ -1420,7 +1433,7 @@ xf86MatchDevice(const char *drivername, GDevPtr ** sectlist)
if (gdp->driver && !gdp->claimed &&
!xf86NameCmp(gdp->driver, drivername)) {
/* we have a matching driver that wasn't claimed yet */
- pgdp = xnfrealloc(pgdp, (i + 2) * sizeof(GDevPtr));
+ pgdp = xnfreallocarray(pgdp, i + 2, sizeof(GDevPtr));
pgdp[i++] = gdp;
}
j++;
diff --git a/xorg-server/hw/xfree86/common/xf86Xinput.c b/xorg-server/hw/xfree86/common/xf86Xinput.c
index 9fa3dc43c..55bf2bbe4 100644
--- a/xorg-server/hw/xfree86/common/xf86Xinput.c
+++ b/xorg-server/hw/xfree86/common/xf86Xinput.c
@@ -867,8 +867,9 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable)
if (fd != -1) {
if (paused) {
/* Put on new_input_devices list for delayed probe */
- new_input_devices = xnfrealloc(new_input_devices,
- sizeof(pInfo) * (new_input_devices_count + 1));
+ new_input_devices = xnfreallocarray(new_input_devices,
+ new_input_devices_count + 1,
+ sizeof(pInfo));
new_input_devices[new_input_devices_count] = pInfo;
new_input_devices_count++;
systemd_logind_release_fd(pInfo->major, pInfo->minor, fd);
diff --git a/xorg-server/hw/xfree86/common/xf86cmap.c b/xorg-server/hw/xfree86/common/xf86cmap.c
index ab51f9603..704e35358 100644
--- a/xorg-server/hw/xfree86/common/xf86cmap.c
+++ b/xorg-server/hw/xfree86/common/xf86cmap.c
@@ -166,10 +166,10 @@ xf86HandleColormaps(ScreenPtr pScreen,
elements = 1 << sigRGBbits;
- if (!(gamma = malloc(elements * sizeof(LOCO))))
+ if (!(gamma = xallocarray(elements, sizeof(LOCO))))
return FALSE;
- if (!(indices = malloc(maxColors * sizeof(int)))) {
+ if (!(indices = xallocarray(maxColors, sizeof(int)))) {
free(gamma);
return FALSE;
}
@@ -270,7 +270,7 @@ CMapAllocateColormapPrivate(ColormapPtr pmap)
else
numColors = 1 << pmap->pVisual->nplanes;
- if (!(colors = malloc(numColors * sizeof(LOCO))))
+ if (!(colors = xallocarray(numColors, sizeof(LOCO))))
return FALSE;
if (!(pColPriv = malloc(sizeof(CMapColormapRec)))) {
diff --git a/xorg-server/hw/xfree86/common/xf86fbman.c b/xorg-server/hw/xfree86/common/xf86fbman.c
index 1b2cb5704..91ddedc29 100644
--- a/xorg-server/hw/xfree86/common/xf86fbman.c
+++ b/xorg-server/hw/xfree86/common/xf86fbman.c
@@ -317,16 +317,17 @@ localRegisterFreeBoxCallback(ScreenPtr pScreen,
offman = (FBManagerPtr) dixLookupPrivate(&pScreen->devPrivates,
xf86FBScreenKey);
- newCallbacks = realloc(offman->FreeBoxesUpdateCallback,
- sizeof(FreeBoxCallbackProcPtr) *
- (offman->NumCallbacks + 1));
+ newCallbacks = reallocarray(offman->FreeBoxesUpdateCallback,
+ offman->NumCallbacks + 1,
+ sizeof(FreeBoxCallbackProcPtr));
if (!newCallbacks)
return FALSE;
else
offman->FreeBoxesUpdateCallback = newCallbacks;
- newPrivates = realloc(offman->devPrivates,
- sizeof(DevUnion) * (offman->NumCallbacks + 1));
+ newPrivates = reallocarray(offman->devPrivates,
+ offman->NumCallbacks + 1,
+ sizeof(DevUnion));
if (!newPrivates)
return FALSE;
else
diff --git a/xorg-server/hw/xfree86/common/xf86pciBus.c b/xorg-server/hw/xfree86/common/xf86pciBus.c
index e86ecb9d4..8158c2b62 100644
--- a/xorg-server/hw/xfree86/common/xf86pciBus.c
+++ b/xorg-server/hw/xfree86/common/xf86pciBus.c
@@ -103,9 +103,9 @@ xf86PciProbe(void)
while ((info = pci_device_next(iter)) != NULL) {
if (PCIINFOCLASSES(info->device_class)) {
num++;
- xf86PciVideoInfo = xnfrealloc(xf86PciVideoInfo,
- (sizeof(struct pci_device *)
- * (num + 1)));
+ xf86PciVideoInfo = xnfreallocarray(xf86PciVideoInfo,
+ num + 1,
+ sizeof(struct pci_device *));
xf86PciVideoInfo[num] = NULL;
xf86PciVideoInfo[num - 1] = info;
@@ -679,7 +679,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
}
pci_iterator_destroy(iter);
- instances = xnfalloc(max_entries * sizeof(struct Inst));
+ instances = xnfallocarray(max_entries, sizeof(struct Inst));
}
iter = pci_slot_match_iterator_create(NULL);
@@ -976,7 +976,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
/* Allocate an entry in the lists to be returned */
numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities = xnfreallocarray(retEntities, numFound, sizeof(int));
retEntities[numFound - 1] = xf86ClaimPciSlot(pPci, drvp,
instances[i].chip,
instances[i].dev,
diff --git a/xorg-server/hw/xfree86/common/xf86platformBus.c b/xorg-server/hw/xfree86/common/xf86platformBus.c
index c1aaba41a..f1e942378 100644
--- a/xorg-server/hw/xfree86/common/xf86platformBus.c
+++ b/xorg-server/hw/xfree86/common/xf86platformBus.c
@@ -59,9 +59,9 @@ struct xf86_platform_device *xf86_platform_devices;
int
xf86_add_platform_device(struct OdevAttributes *attribs, Bool unowned)
{
- xf86_platform_devices = xnfrealloc(xf86_platform_devices,
- (sizeof(struct xf86_platform_device)
- * (xf86_num_platform_devices + 1)));
+ xf86_platform_devices = xnfreallocarray(xf86_platform_devices,
+ xf86_num_platform_devices + 1,
+ sizeof(struct xf86_platform_device));
xf86_platform_devices[xf86_num_platform_devices].attribs = attribs;
xf86_platform_devices[xf86_num_platform_devices].pdev = NULL;
diff --git a/xorg-server/hw/xfree86/common/xf86sbusBus.c b/xorg-server/hw/xfree86/common/xf86sbusBus.c
index 07eb71ed8..119211dc5 100644
--- a/xorg-server/hw/xfree86/common/xf86sbusBus.c
+++ b/xorg-server/hw/xfree86/common/xf86sbusBus.c
@@ -68,7 +68,7 @@ CheckSbusDevice(const char *device, int fbNum)
if (!sbusDeviceTable[i].devId)
return;
xf86SbusInfo =
- xnfrealloc(xf86SbusInfo, sizeof(psdp) * (++xf86nSbusInfo + 1));
+ xnfreallocarray(xf86SbusInfo, ++xf86nSbusInfo + 1, sizeof(psdp));
xf86SbusInfo[xf86nSbusInfo] = NULL;
xf86SbusInfo[xf86nSbusInfo - 1] = psdp = xnfcalloc(sizeof(sbusDevice), 1);
psdp->devId = sbusDeviceTable[i].devId;
@@ -406,8 +406,8 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
if (psdp->fd == -2)
continue;
++allocatedInstances;
- instances = xnfrealloc(instances,
- allocatedInstances * sizeof(struct Inst));
+ instances = xnfreallocarray(instances,
+ allocatedInstances, sizeof(struct Inst));
instances[allocatedInstances - 1].sbus = psdp;
instances[allocatedInstances - 1].dev = NULL;
instances[allocatedInstances - 1].claimed = FALSE;
@@ -532,7 +532,7 @@ xf86MatchSbusInstances(const char *driverName, int sbusDevId,
/* Allocate an entry in the lists to be returned */
numFound++;
- retEntities = xnfrealloc(retEntities, numFound * sizeof(int));
+ retEntities = xnfreallocarray(retEntities, numFound, sizeof(int));
retEntities[numFound - 1]
= xf86ClaimSbusSlot(psdp, drvp, instances[i].dev,
instances[i].dev->active ? TRUE : FALSE);
@@ -648,7 +648,7 @@ xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
return;
fbcmap.count = 0;
fbcmap.index = indices[0];
- fbcmap.red = data = malloc(numColors * 3);
+ fbcmap.red = data = xallocarray(numColors, 3);
if (!data)
return;
fbcmap.green = data + numColors;
diff --git a/xorg-server/hw/xfree86/common/xf86str.h b/xorg-server/hw/xfree86/common/xf86str.h
index 643a65db1..a58fafebd 100644
--- a/xorg-server/hw/xfree86/common/xf86str.h
+++ b/xorg-server/hw/xfree86/common/xf86str.h
@@ -440,6 +440,7 @@ typedef struct _confxvadaptrec {
void *options;
} confXvAdaptorRec, *confXvAdaptorPtr;
+#define MAX_GPUDEVICES 4
typedef struct _confscreenrec {
const char *id;
int screennum;
@@ -453,6 +454,9 @@ typedef struct _confscreenrec {
int numxvadaptors;
confXvAdaptorPtr xvadaptors;
void *options;
+
+ int num_gpu_devices;
+ GDevPtr gpu_devices[MAX_GPUDEVICES];
} confScreenRec, *confScreenPtr;
typedef enum {
@@ -512,6 +516,9 @@ typedef struct _confdrirec {
#define NUM_RESERVED_POINTERS 14
#define NUM_RESERVED_FUNCS 10
+/* let clients know they can use this */
+#define XF86_SCRN_HAS_PREFER_CLONE 1
+
typedef void *(*funcPointer) (void);
/* flags for depth 24 pixmap options */
@@ -768,6 +775,9 @@ typedef struct _ScrnInfoRec {
ClockRangePtr clockRanges;
int adjustFlags;
+ /* initial rightof support disable */
+ int preferClone;
+
/*
* These can be used when the minor ABI version is incremented.
* The NUM_* parameters must be reduced appropriately to keep the
diff --git a/xorg-server/hw/xfree86/common/xf86vmode.c b/xorg-server/hw/xfree86/common/xf86vmode.c
index 0ce58e365..818e7dc45 100644
--- a/xorg-server/hw/xfree86/common/xf86vmode.c
+++ b/xorg-server/hw/xfree86/common/xf86vmode.c
@@ -1240,11 +1240,11 @@ ProcXF86VidModeGetMonitor(ClientPtr client)
pad_to_int32(rep.modelLength));
rep.nhsync = nHsync;
rep.nvsync = nVrefresh;
- hsyncdata = malloc(nHsync * sizeof(CARD32));
+ hsyncdata = xallocarray(nHsync, sizeof(CARD32));
if (!hsyncdata) {
return BadAlloc;
}
- vsyncdata = malloc(nVrefresh * sizeof(CARD32));
+ vsyncdata = xallocarray(nVrefresh, sizeof(CARD32));
if (!vsyncdata) {
free(hsyncdata);
@@ -1512,9 +1512,9 @@ ProcXF86VidModeGetGammaRamp(ClientPtr client)
length = (stuff->size + 1) & ~1;
if (stuff->size) {
- ramplen = length * 3 * sizeof(CARD16);
- if (!(ramp = malloc(ramplen)))
+ if (!(ramp = xallocarray(length, 3 * sizeof(CARD16))))
return BadAlloc;
+ ramplen = length * 3 * sizeof(CARD16);
if (!VidModeGetGammaRamp(stuff->screen, stuff->size,
ramp, ramp + length, ramp + (length * 2))) {
diff --git a/xorg-server/hw/xfree86/common/xf86xv.c b/xorg-server/hw/xfree86/common/xf86xv.c
index b974cd212..d613d712c 100644
--- a/xorg-server/hw/xfree86/common/xf86xv.c
+++ b/xorg-server/hw/xfree86/common/xf86xv.c
@@ -131,8 +131,8 @@ xf86XVRegisterGenericAdaptorDriver(xf86XVInitGenericAdaptorPtr InitFunc)
{
xf86XVInitGenericAdaptorPtr *newdrivers;
- newdrivers = realloc(GenDrivers, sizeof(xf86XVInitGenericAdaptorPtr) *
- (1 + NumGenDrivers));
+ newdrivers = reallocarray(GenDrivers, 1 + NumGenDrivers,
+ sizeof(xf86XVInitGenericAdaptorPtr));
if (!newdrivers)
return 0;
GenDrivers = newdrivers;
@@ -159,7 +159,7 @@ xf86XVListGenericAdaptors(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr ** adaptors)
n = (*GenDrivers[i]) (pScrn, &DrivAdap);
if (0 == n)
continue;
- new = realloc(*adaptors, sizeof(XF86VideoAdaptorPtr) * (num + n));
+ new = reallocarray(*adaptors, num + n, sizeof(XF86VideoAdaptorPtr));
if (NULL == new)
continue;
*adaptors = new;
@@ -436,8 +436,8 @@ xf86XVInitAdaptors(ScreenPtr pScreen, XF86VideoAdaptorPtr * infoPtr, int number)
void *moreSpace;
totFormat *= 2;
- moreSpace = realloc(pFormat,
- totFormat * sizeof(XvFormatRec));
+ moreSpace = reallocarray(pFormat, totFormat,
+ sizeof(XvFormatRec));
if (!moreSpace)
break;
pFormat = moreSpace;
diff --git a/xorg-server/hw/xfree86/common/xf86xvmc.c b/xorg-server/hw/xfree86/common/xf86xvmc.c
index 3169c054c..a0a94c74b 100644
--- a/xorg-server/hw/xfree86/common/xf86xvmc.c
+++ b/xorg-server/hw/xfree86/common/xf86xvmc.c
@@ -155,7 +155,7 @@ xf86XvMCScreenInit(ScreenPtr pScreen,
if (noXvExtension)
return FALSE;
- if (!(pAdapt = malloc(sizeof(XvMCAdaptorRec) * num_adaptors)))
+ if (!(pAdapt = xallocarray(num_adaptors, sizeof(XvMCAdaptorRec))))
return FALSE;
if (!dixRegisterPrivateKey(&XF86XvMCScreenKeyRec, PRIVATE_SCREEN, 0)) {
diff --git a/xorg-server/hw/xfree86/ddc/ddc.c b/xorg-server/hw/xfree86/ddc/ddc.c
index 29185ad8b..ee533db1c 100644
--- a/xorg-server/hw/xfree86/ddc/ddc.c
+++ b/xorg-server/hw/xfree86/ddc/ddc.c
@@ -437,7 +437,7 @@ xf86DoEEDID(ScrnInfoPtr pScrn, I2CBusPtr pBus, Bool complete)
int i, n = EDID_block[0x7e];
if (complete && n) {
- EDID_block = realloc(EDID_block, EDID1_LEN * (1 + n));
+ EDID_block = reallocarray(EDID_block, 1 + n, EDID1_LEN);
for (i = 0; i < n; i++)
DDC2Read(dev, i + 1, EDID_block + (EDID1_LEN * (1 + i)));
diff --git a/xorg-server/hw/xfree86/dri/xf86dri.c b/xorg-server/hw/xfree86/dri/xf86dri.c
index 086e833ed..68f8b7e72 100644
--- a/xorg-server/hw/xfree86/dri/xf86dri.c
+++ b/xorg-server/hw/xfree86/dri/xf86dri.c
@@ -422,7 +422,7 @@ ProcXF86DRIGetDrawableInfo(register ClientPtr client)
if (rep.numClipRects) {
/* Clip cliprects to screen dimensions (redirected windows) */
- pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t));
+ pClippedRects = xallocarray(rep.numClipRects, sizeof(drm_clip_rect_t));
if (pClippedRects) {
ScreenPtr pScreen = screenInfo.screens[stuff->screen];
diff --git a/xorg-server/hw/xfree86/dri2/dri2.c b/xorg-server/hw/xfree86/dri2/dri2.c
index 0c038b3d1..60ea6dd93 100644
--- a/xorg-server/hw/xfree86/dri2/dri2.c
+++ b/xorg-server/hw/xfree86/dri2/dri2.c
@@ -1577,7 +1577,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
if (info->version == 3 || info->numDrivers == 0) {
/* Driver too old: use the old-style driverName field */
ds->numDrivers = info->driverName ? 1 : 2;
- ds->driverNames = malloc(ds->numDrivers * sizeof(*ds->driverNames));
+ ds->driverNames = xallocarray(ds->numDrivers, sizeof(*ds->driverNames));
if (!ds->driverNames)
goto err_out;
@@ -1591,7 +1591,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
}
else {
ds->numDrivers = info->numDrivers;
- ds->driverNames = malloc(info->numDrivers * sizeof(*ds->driverNames));
+ ds->driverNames = xallocarray(info->numDrivers, sizeof(*ds->driverNames));
if (!ds->driverNames)
goto err_out;
memcpy(ds->driverNames, info->driverNames,
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/driver.c b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
index e2f3846ca..e90e4b842 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/driver.c
+++ b/xorg-server/hw/xfree86/drivers/modesetting/driver.c
@@ -451,7 +451,7 @@ dispatch_dirty_region(ScrnInfoPtr scrn,
int ret = 0;
if (num_cliprects) {
- drmModeClip *clip = malloc(num_cliprects * sizeof(drmModeClip));
+ drmModeClip *clip = xallocarray(num_cliprects, sizeof(drmModeClip));
BoxPtr rect = REGION_RECTS(dirty);
int i;
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
index 1ea799b3a..f3c9909ef 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -326,6 +326,8 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
continue;
drmmode_output = output->driver_private;
+ if (drmmode_output->output_id == -1)
+ continue;
output_ids[output_count] =
drmmode_output->mode_output->connector_id;
output_count++;
@@ -366,10 +368,14 @@ drmmode_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
/* go through all the outputs and force DPMS them back on? */
for (i = 0; i < xf86_config->num_output; i++) {
xf86OutputPtr output = xf86_config->output[i];
+ drmmode_output_private_ptr drmmode_output;
if (output->crtc != crtc)
continue;
+ drmmode_output = output->driver_private;
+ if (drmmode_output->output_id == -1)
+ continue;
output->funcs->dpms(output, DPMSModeOn);
}
}
@@ -427,10 +433,10 @@ drmmode_set_cursor(xf86CrtcPtr crtc)
drmModeSetCursor2(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id,
handle, ms->cursor_width, ms->cursor_height,
cursor->bits->xhot, cursor->bits->yhot);
+ if (!ret)
+ return;
if (ret == -EINVAL)
use_set_cursor2 = FALSE;
- else
- return;
}
ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle,
@@ -687,7 +693,7 @@ drmmode_crtc_vblank_pipe(int crtc_id)
}
static void
-drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
+drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num)
{
xf86CrtcPtr crtc;
drmmode_crtc_private_ptr drmmode_crtc;
@@ -698,7 +704,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
drmmode_crtc->mode_crtc =
- drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]);
+ drmModeGetCrtc(drmmode->fd, mode_res->crtcs[num]);
drmmode_crtc->drmmode = drmmode;
drmmode_crtc->vblank_pipe = drmmode_crtc_vblank_pipe(num);
crtc->driver_private = drmmode_crtc;
@@ -712,6 +718,9 @@ drmmode_output_detect(xf86OutputPtr output)
drmmode_ptr drmmode = drmmode_output->drmmode;
xf86OutputStatus status;
+ if (drmmode_output->output_id == -1)
+ return XF86OutputStatusDisconnected;
+
drmModeFreeConnector(drmmode_output->mode_output);
drmmode_output->mode_output =
@@ -740,6 +749,46 @@ drmmode_output_mode_valid(xf86OutputPtr output, DisplayModePtr pModes)
return MODE_OK;
}
+static void
+drmmode_output_attach_tile(xf86OutputPtr output)
+{
+ drmmode_output_private_ptr drmmode_output = output->driver_private;
+ drmModeConnectorPtr koutput = drmmode_output->mode_output;
+ drmmode_ptr drmmode = drmmode_output->drmmode;
+ int i;
+ struct xf86CrtcTileInfo tile_info, *set = NULL;
+
+ if (!koutput) {
+ xf86OutputSetTile(output, NULL);
+ return;
+ }
+
+ /* look for a TILE property */
+ for (i = 0; i < koutput->count_props; i++) {
+ drmModePropertyPtr props;
+ props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+ if (!props)
+ continue;
+
+ if (!(props->flags & DRM_MODE_PROP_BLOB)) {
+ drmModeFreeProperty(props);
+ continue;
+ }
+
+ if (!strcmp(props->name, "TILE")) {
+ drmModeFreePropertyBlob(drmmode_output->tile_blob);
+ drmmode_output->tile_blob =
+ drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]);
+ }
+ drmModeFreeProperty(props);
+ }
+ if (drmmode_output->tile_blob) {
+ if (xf86OutputParseKMSTile(drmmode_output->tile_blob->data, drmmode_output->tile_blob->length, &tile_info) == TRUE)
+ set = &tile_info;
+ }
+ xf86OutputSetTile(output, set);
+}
+
static Bool
has_panel_fitter(xf86OutputPtr output)
{
@@ -848,6 +897,8 @@ drmmode_output_get_modes(xf86OutputPtr output)
}
xf86OutputSetEDID(output, mon);
+ drmmode_output_attach_tile(output);
+
/* modes should already be available */
for (i = 0; i < koutput->count_modes; i++) {
Mode = xnfalloc(sizeof(DisplayModeRec));
@@ -873,11 +924,13 @@ drmmode_output_destroy(xf86OutputPtr output)
free(drmmode_output->props[i].atoms);
}
free(drmmode_output->props);
- for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) {
- drmModeFreeEncoder(drmmode_output->mode_encoders[i]);
+ if (drmmode_output->mode_output) {
+ for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) {
+ drmModeFreeEncoder(drmmode_output->mode_encoders[i]);
+ }
+ drmModeFreeConnector(drmmode_output->mode_output);
}
free(drmmode_output->mode_encoders);
- drmModeFreeConnector(drmmode_output->mode_output);
free(drmmode_output);
output->driver_private = NULL;
}
@@ -1111,22 +1164,134 @@ static const char *const output_names[] = {
"DSI",
};
+static xf86OutputPtr find_output(ScrnInfoPtr pScrn, int id)
+{
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int i;
+ for (i = 0; i < xf86_config->num_output; i++) {
+ xf86OutputPtr output = xf86_config->output[i];
+ drmmode_output_private_ptr drmmode_output;
+
+ drmmode_output = output->driver_private;
+ if (drmmode_output->output_id == id)
+ return output;
+ }
+ return NULL;
+}
+
+static int parse_path_blob(drmModePropertyBlobPtr path_blob, int *conn_base_id, char **path)
+{
+ char *conn;
+ char conn_id[5];
+ int id, len;
+ char *blob_data;
+
+ if (!path_blob)
+ return -1;
+
+ blob_data = path_blob->data;
+ /* we only handle MST paths for now */
+ if (strncmp(blob_data, "mst:", 4))
+ return -1;
+
+ conn = strchr(blob_data + 4, '-');
+ if (!conn)
+ return -1;
+ len = conn - (blob_data + 4);
+ if (len + 1> 5)
+ return -1;
+ memcpy(conn_id, blob_data + 4, len);
+ conn_id[len + 1] = '\0';
+ id = strtoul(conn_id, NULL, 10);
+
+ *conn_base_id = id;
+
+ *path = conn + 1;
+ return 0;
+}
+
+static void
+drmmode_create_name(ScrnInfoPtr pScrn, drmModeConnectorPtr koutput, char *name,
+ drmModePropertyBlobPtr path_blob)
+{
+ int ret;
+ char *extra_path;
+ int conn_id;
+ xf86OutputPtr output;
+
+ ret = parse_path_blob(path_blob, &conn_id, &extra_path);
+ if (ret == -1)
+ goto fallback;
+
+ output = find_output(pScrn, conn_id);
+ if (!output)
+ goto fallback;
+
+ snprintf(name, 32, "%s-%s", output->name, extra_path);
+ return;
+
+ fallback:
+ if (koutput->connector_type >= MS_ARRAY_SIZE(output_names))
+ snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1);
+#ifdef MODESETTING_OUTPUT_SLAVE_SUPPORT
+ else if (pScrn->is_gpu)
+ snprintf(name, 32, "%s-%d-%d", output_names[koutput->connector_type], pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1, koutput->connector_type_id - 1);
+#endif
+ else
+ snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], koutput->connector_type_id - 1);
+}
+
static void
-drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
+drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num, Bool dynamic)
{
xf86OutputPtr output;
+ xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
drmModeConnectorPtr koutput;
drmModeEncoderPtr *kencoders = NULL;
drmmode_output_private_ptr drmmode_output;
drmModePropertyPtr props;
char name[32];
int i;
+ drmModePropertyBlobPtr path_blob = NULL;
koutput =
- drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]);
+ drmModeGetConnector(drmmode->fd, mode_res->connectors[num]);
if (!koutput)
return;
+ for (i = 0; i < koutput->count_props; i++) {
+ props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+ if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
+ if (!strcmp(props->name, "PATH")) {
+ path_blob = drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]);
+ drmModeFreeProperty(props);
+ break;
+ }
+ drmModeFreeProperty(props);
+ }
+ }
+
+ drmmode_create_name(pScrn, koutput, name, path_blob);
+
+ if (path_blob)
+ drmModeFreePropertyBlob(path_blob);
+
+ if (path_blob && dynamic) {
+ /* see if we have an output with this name already
+ and hook stuff up */
+ for (i = 0; i < xf86_config->num_output; i++) {
+ output = xf86_config->output[i];
+
+ if (strncmp(output->name, name, 32))
+ continue;
+
+ drmmode_output = output->driver_private;
+ drmmode_output->output_id = mode_res->connectors[num];
+ drmmode_output->mode_output = koutput;
+ return;
+ }
+ }
+
kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
if (!kencoders) {
goto out_free_encoders;
@@ -1139,17 +1304,6 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
}
}
- /* need to do smart conversion here for compat with non-kms ATI driver */
- if (koutput->connector_type >= MS_ARRAY_SIZE(output_names))
- snprintf(name, 32, "Unknown-%d", koutput->connector_type_id - 1);
- else if (pScrn->is_gpu)
- snprintf(name, 32, "%s-%d-%d", output_names[koutput->connector_type],
- pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1,
- koutput->connector_type_id - 1);
- else
- snprintf(name, 32, "%s-%d", output_names[koutput->connector_type],
- koutput->connector_type_id - 1);
-
output = xf86OutputCreate(pScrn, &drmmode_output_funcs, name);
if (!output) {
goto out_free_encoders;
@@ -1161,7 +1315,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
goto out_free_encoders;
}
- drmmode_output->output_id = drmmode->mode_res->connectors[num];
+ drmmode_output->output_id = mode_res->connectors[num];
drmmode_output->mode_output = koutput;
drmmode_output->mode_encoders = kencoders;
drmmode_output->drmmode = drmmode;
@@ -1192,6 +1346,8 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
}
}
+ if (dynamic)
+ output->randr_output = RROutputCreate(xf86ScrnToScreen(pScrn), output->name, strlen(output->name), output);
return;
out_free_encoders:
if (kencoders) {
@@ -1231,7 +1387,7 @@ find_clones(ScrnInfoPtr scrn, xf86OutputPtr output)
}
static void
-drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode, drmModeResPtr mode_res)
{
int i, j;
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1246,8 +1402,8 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
for (j = 0; j < drmmode_output->mode_output->count_encoders; j++) {
int k;
- for (k = 0; k < drmmode->mode_res->count_encoders; k++) {
- if (drmmode->mode_res->encoders[k] ==
+ for (k = 0; k < mode_res->count_encoders; k++) {
+ if (mode_res->encoders[k] ==
drmmode_output->mode_encoders[j]->encoder_id)
drmmode_output->enc_mask |= (1 << k);
}
@@ -1425,6 +1581,7 @@ drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
int i;
int ret;
uint64_t value = 0;
+ drmModeResPtr mode_res;
/* check for dumb capability */
ret = drmGetCap(drmmode->fd, DRM_CAP_DUMB_BUFFER, &value);
@@ -1438,23 +1595,24 @@ drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
drmmode->scrn = pScrn;
drmmode->cpp = cpp;
- drmmode->mode_res = drmModeGetResources(drmmode->fd);
- if (!drmmode->mode_res)
+ mode_res = drmModeGetResources(drmmode->fd);
+ if (!mode_res)
return FALSE;
- xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width,
- drmmode->mode_res->max_height);
- for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
+ xf86CrtcSetSizeRange(pScrn, 320, 200, mode_res->max_width,
+ mode_res->max_height);
+ for (i = 0; i < mode_res->count_crtcs; i++)
if (!xf86IsEntityShared(pScrn->entityList[0]) ||
pScrn->confScreen->device->screen == i)
- drmmode_crtc_init(pScrn, drmmode, i);
+ drmmode_crtc_init(pScrn, drmmode, mode_res, i);
- for (i = 0; i < drmmode->mode_res->count_connectors; i++)
- drmmode_output_init(pScrn, drmmode, i);
+ for (i = 0; i < mode_res->count_connectors; i++)
+ drmmode_output_init(pScrn, drmmode, mode_res, i, FALSE);
/* workout clones */
- drmmode_clones_init(pScrn, drmmode);
+ drmmode_clones_init(pScrn, drmmode, mode_res);
+ drmModeFreeResources(mode_res);
#if XF86_CRTC_VERSION >= 5
xf86ProviderSetup(pScrn, NULL, "modesetting");
#endif
@@ -1618,11 +1776,78 @@ drmmode_handle_uevents(int fd, void *closure)
drmmode_ptr drmmode = closure;
ScrnInfoPtr scrn = drmmode->scrn;
struct udev_device *dev;
+ drmModeResPtr mode_res;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+ int i, j;
+ Bool found;
+ Bool changed = FALSE;
dev = udev_monitor_receive_device(drmmode->uevent_monitor);
if (!dev)
return;
+ mode_res = drmModeGetResources(drmmode->fd);
+ if (!mode_res)
+ goto out;
+
+ if (mode_res->count_crtcs != config->num_crtc) {
+ ErrorF("number of CRTCs changed - failed to handle, %d vs %d\n", mode_res->count_crtcs, config->num_crtc);
+ goto out_free_res;
+ }
+
+ /* figure out if we have gotten rid of any connectors
+ traverse old output list looking for outputs */
+ for (i = 0; i < config->num_output; i++) {
+ xf86OutputPtr output = config->output[i];
+ drmmode_output_private_ptr drmmode_output;
+
+ drmmode_output = output->driver_private;
+ found = FALSE;
+ for (j = 0; j < mode_res->count_connectors; j++) {
+ if (mode_res->connectors[j] == drmmode_output->output_id) {
+ found = TRUE;
+ break;
+ }
+ }
+ if (found)
+ continue;
+
+ drmModeFreeConnector(drmmode_output->mode_output);
+ drmmode_output->mode_output = NULL;
+ drmmode_output->output_id = -1;
+
+ changed = TRUE;
+ }
+
+ /* find new output ids we don't have outputs for */
+ for (i = 0; i < mode_res->count_connectors; i++) {
+ found = FALSE;
+
+ for (j = 0; j < config->num_output; j++) {
+ xf86OutputPtr output = config->output[j];
+ drmmode_output_private_ptr drmmode_output;
+
+ drmmode_output = output->driver_private;
+ if (mode_res->connectors[i] == drmmode_output->output_id) {
+ found = TRUE;
+ break;
+ }
+ }
+ if (found)
+ continue;
+
+ changed = TRUE;
+ drmmode_output_init(scrn, drmmode, mode_res, i, 1);
+ }
+
+ if (changed) {
+ RRSetChanged(xf86ScrnToScreen(scrn));
+ RRTellChanged(xf86ScrnToScreen(scrn));
+ }
+
+out_free_res:
+ drmModeFreeResources(mode_res);
+out:
RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
udev_device_unref(dev);
}
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
index 3a8959ac3..b0e45b6e0 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/xorg-server/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -47,7 +47,6 @@ typedef struct {
int fd;
unsigned fb_id;
unsigned old_fb_id;
- drmModeResPtr mode_res;
drmModeFBPtr mode_fb;
int cpp;
ScrnInfoPtr scrn;
@@ -121,6 +120,7 @@ typedef struct {
drmModeConnectorPtr mode_output;
drmModeEncoderPtr *mode_encoders;
drmModePropertyBlobPtr edid_blob;
+ drmModePropertyBlobPtr tile_blob;
int dpms_enum_id;
int num_props;
drmmode_prop_ptr props;
diff --git a/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c b/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c
index 58d420e07..cf13f0a9c 100644
--- a/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c
+++ b/xorg-server/hw/xfree86/drivers/modesetting/dumb_bo.c
@@ -25,6 +25,10 @@
*
*/
+#ifdef HAVE_DIX_CONFIG_H
+#include "dix-config.h"
+#endif
+
#include "dumb_bo.h"
#include <errno.h>
diff --git a/xorg-server/hw/xfree86/i2c/xf86i2c.c b/xorg-server/hw/xfree86/i2c/xf86i2c.c
index cf2cd0971..2a8b8df22 100644
--- a/xorg-server/hw/xfree86/i2c/xf86i2c.c
+++ b/xorg-server/hw/xfree86/i2c/xf86i2c.c
@@ -872,7 +872,7 @@ xf86I2CGetScreenBuses(int scrnIndex, I2CBusPtr ** pppI2CBus)
if (!pppI2CBus)
continue;
- *pppI2CBus = xnfrealloc(*pppI2CBus, n * sizeof(I2CBusPtr));
+ *pppI2CBus = xnfreallocarray(*pppI2CBus, n, sizeof(I2CBusPtr));
(*pppI2CBus)[n - 1] = pI2CBus;
}
diff --git a/xorg-server/hw/xfree86/loader/loadmod.c b/xorg-server/hw/xfree86/loader/loadmod.c
index fdf5bd8c9..73dc1b8dc 100644
--- a/xorg-server/hw/xfree86/loader/loadmod.c
+++ b/xorg-server/hw/xfree86/loader/loadmod.c
@@ -142,7 +142,7 @@ InitPathList(const char *path)
if (addslash)
len++;
save = list;
- list = realloc(list, (n + 2) * sizeof(char *));
+ list = reallocarray(list, n + 2, sizeof(char *));
if (!list) {
if (save) {
save[n] = NULL;
@@ -244,7 +244,7 @@ InitPatterns(const char **patternlist)
for (i = 0, s = patternlist; *s; i++, s++)
if (*s == DEFAULT_LIST)
i += sizeof(stdPatterns) / sizeof(stdPatterns[0]) - 1 - 1;
- patterns = malloc((i + 1) * sizeof(PatternRec));
+ patterns = xallocarray(i + 1, sizeof(PatternRec));
if (!patterns) {
return NULL;
}
@@ -323,7 +323,7 @@ InitSubdirs(const char **subdirlist)
}
}
}
- subdirs = malloc((i * 2 + 1) * sizeof(char *));
+ subdirs = xallocarray(i * 2 + 1, sizeof(char *));
if (!subdirs) {
free(tmp_subdirlist);
return NULL;
@@ -530,8 +530,8 @@ LoaderListDirs(const char **subdirlist, const char **patternlist)
match[1].rm_so != -1) {
len = match[1].rm_eo - match[1].rm_so;
save = listing;
- listing = realloc(listing,
- (n + 2) * sizeof(char *));
+ listing = reallocarray(listing, n + 2,
+ sizeof(char *));
if (!listing) {
if (save) {
save[n] = NULL;
diff --git a/xorg-server/hw/xfree86/man/xorg.conf.man b/xorg-server/hw/xfree86/man/xorg.conf.man
index d26c3cc4d..e9b6d9990 100644
--- a/xorg-server/hw/xfree86/man/xorg.conf.man
+++ b/xorg-server/hw/xfree86/man/xorg.conf.man
@@ -1906,6 +1906,7 @@ sections have the following format:
.B "Section \*qScreen\*q"
.BI " Identifier \*q" name \*q
.BI " Device \*q" devid \*q
+.BI " GPUDevice \*q" devid \*q
.BI " Monitor \*q" monid \*q
.I " entries"
.I " ..."
@@ -1949,6 +1950,18 @@ of a
.B Device
section in the config file.
.TP 7
+.BI "GPUDevice \*q" device\-id \*q
+This entry specifies the
+.B Device
+section to be used as a secondary GPU device for this screen. When multiple graphics cards are
+present, this is what ties a specific secondary card to a screen. The
+.I device\-id
+must match the
+.B Identifier
+of a
+.B Device
+section in the config file. This can be specified up to 4 times for a single screen.
+.TP 7
.BI "Monitor \*q" monitor\-id \*q
specifies which monitor description is to be used for this screen.
If a
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.c b/xorg-server/hw/xfree86/modes/xf86Crtc.c
index a1947241b..38bc58cbc 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.c
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.c
@@ -118,7 +118,7 @@ xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs)
/* Preallocate gamma at a sensible size. */
crtc->gamma_size = 256;
- crtc->gamma_red = malloc(3 * crtc->gamma_size * sizeof(CARD16));
+ crtc->gamma_red = xallocarray(crtc->gamma_size, 3 * sizeof(CARD16));
if (!crtc->gamma_red) {
free(crtc);
return NULL;
@@ -127,10 +127,10 @@ xf86CrtcCreate(ScrnInfoPtr scrn, const xf86CrtcFuncsRec * funcs)
crtc->gamma_blue = crtc->gamma_green + crtc->gamma_size;
if (xf86_config->crtc)
- crtcs = realloc(xf86_config->crtc,
- (xf86_config->num_crtc + 1) * sizeof(xf86CrtcPtr));
+ crtcs = reallocarray(xf86_config->crtc,
+ xf86_config->num_crtc + 1, sizeof(xf86CrtcPtr));
else
- crtcs = malloc((xf86_config->num_crtc + 1) * sizeof(xf86CrtcPtr));
+ crtcs = xallocarray(xf86_config->num_crtc + 1, sizeof(xf86CrtcPtr));
if (!crtcs) {
free(crtc->gamma_red);
free(crtc);
@@ -620,11 +620,12 @@ xf86OutputCreate(ScrnInfoPtr scrn,
}
if (xf86_config->output)
- outputs = realloc(xf86_config->output,
- (xf86_config->num_output +
- 1) * sizeof(xf86OutputPtr));
+ outputs = reallocarray(xf86_config->output,
+ xf86_config->num_output + 1,
+ sizeof(xf86OutputPtr));
else
- outputs = malloc((xf86_config->num_output + 1) * sizeof(xf86OutputPtr));
+ outputs = xallocarray(xf86_config->num_output + 1,
+ sizeof(xf86OutputPtr));
if (!outputs) {
free(output);
return NULL;
@@ -942,7 +943,7 @@ xf86PickCrtcs(ScrnInfoPtr scrn,
if (modes[n] == NULL)
return best_score;
- crtcs = malloc(config->num_output * sizeof(xf86CrtcPtr));
+ crtcs = xallocarray(config->num_output, sizeof(xf86CrtcPtr));
if (!crtcs)
return best_score;
@@ -1123,6 +1124,15 @@ xf86InitialOutputPositions(ScrnInfoPtr scrn, DisplayModePtr * modes)
int o;
int min_x, min_y;
+ /* check for initial right-of heuristic */
+ for (o = 0; o < config->num_output; o++)
+ {
+ xf86OutputPtr output = config->output[o];
+
+ if (output->initial_x || output->initial_y)
+ return TRUE;
+ }
+
for (o = 0; o < config->num_output; o++) {
xf86OutputPtr output = config->output[o];
@@ -2102,6 +2112,118 @@ bestModeForAspect(xf86CrtcConfigPtr config, Bool *enabled, float aspect)
return match;
}
+static int
+numEnabledOutputs(xf86CrtcConfigPtr config, Bool *enabled)
+{
+ int i = 0, p;
+
+ for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++) ;
+
+ return i;
+}
+
+static Bool
+xf86TargetRightOf(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
+ DisplayModePtr *modes, Bool *enabled,
+ int width, int height)
+{
+ int o;
+ int w = 0;
+ Bool has_tile = FALSE;
+ uint32_t configured_outputs;
+
+ if (scrn->preferClone)
+ return FALSE;
+
+ if (numEnabledOutputs(config, enabled) < 2)
+ return FALSE;
+
+ for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
+ DisplayModePtr mode =
+ xf86OutputHasPreferredMode(config->output[o], width, height);
+
+ if (!mode)
+ return FALSE;
+
+ w += mode->HDisplay;
+ }
+
+ if (w > width)
+ return FALSE;
+
+ w = 0;
+ configured_outputs = 0;
+
+ for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
+ DisplayModePtr mode =
+ xf86OutputHasPreferredMode(config->output[o], width, height);
+
+ if (configured_outputs & (1 << o))
+ continue;
+
+ if (config->output[o]->tile_info.group_id) {
+ has_tile = TRUE;
+ continue;
+ }
+
+ config->output[o]->initial_x = w;
+ w += mode->HDisplay;
+
+ configured_outputs |= (1 << o);
+ modes[o] = mode;
+ }
+
+ if (has_tile) {
+ for (o = -1; nextEnabledOutput(config, enabled, &o); ) {
+ int ht, vt, ot;
+ int add_x, cur_x = w;
+ struct xf86CrtcTileInfo *tile_info = &config->output[o]->tile_info, *this_tile;
+ if (configured_outputs & (1 << o))
+ continue;
+ if (!tile_info->group_id)
+ continue;
+
+ if (tile_info->tile_h_loc != 0 && tile_info->tile_v_loc != 0)
+ continue;
+
+ for (ht = 0; ht < tile_info->num_h_tile; ht++) {
+ int cur_y = 0;
+ add_x = 0;
+ for (vt = 0; vt < tile_info->num_v_tile; vt++) {
+
+ for (ot = -1; nextEnabledOutput(config, enabled, &ot); ) {
+
+ DisplayModePtr mode =
+ xf86OutputHasPreferredMode(config->output[ot], width, height);
+ if (!config->output[ot]->tile_info.group_id)
+ continue;
+
+ this_tile = &config->output[ot]->tile_info;
+ if (this_tile->group_id != tile_info->group_id)
+ continue;
+
+ if (this_tile->tile_h_loc != ht ||
+ this_tile->tile_v_loc != vt)
+ continue;
+
+ config->output[ot]->initial_x = cur_x;
+ config->output[ot]->initial_y = cur_y;
+
+ if (vt == 0)
+ add_x = this_tile->tile_h_size;
+ cur_y += this_tile->tile_v_size;
+ configured_outputs |= (1 << ot);
+ modes[ot] = mode;
+ }
+ }
+ cur_x += add_x;
+ }
+ w = cur_x;
+ }
+ }
+ return TRUE;
+}
+
static Bool
xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
DisplayModePtr * modes, Bool *enabled,
@@ -2178,14 +2300,10 @@ xf86TargetPreferred(ScrnInfoPtr scrn, xf86CrtcConfigPtr config,
*/
if (!ret)
do {
- int i = 0;
float aspect = 0.0;
DisplayModePtr a = NULL, b = NULL;
- /* count the number of enabled outputs */
- for (i = 0, p = -1; nextEnabledOutput(config, enabled, &p); i++);
-
- if (i != 1)
+ if (numEnabledOutputs(config, enabled) != 1)
break;
p = -1;
@@ -2334,7 +2452,7 @@ xf86CrtcSetInitialGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green,
int i, size = 256;
CARD16 *red, *green, *blue;
- red = malloc(3 * size * sizeof(CARD16));
+ red = xallocarray(size, 3 * sizeof(CARD16));
green = red + size;
blue = green + size;
@@ -2491,6 +2609,8 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
else {
if (xf86TargetUserpref(scrn, config, modes, enabled, width, height))
xf86DrvMsg(i, X_INFO, "Using user preference for initial modes\n");
+ else if (xf86TargetRightOf(scrn, config, modes, enabled, width, height))
+ xf86DrvMsg(i, X_INFO, "Using spanning desktop for initial modes\n");
else if (xf86TargetPreferred
(scrn, config, modes, enabled, width, height))
xf86DrvMsg(i, X_INFO, "Using exact sizes for initial modes\n");
@@ -2510,9 +2630,11 @@ xf86InitialConfiguration(ScrnInfoPtr scrn, Bool canGrow)
"Output %s enabled but has no modes\n",
config->output[o]->name);
else
- xf86DrvMsg(scrn->scrnIndex, X_INFO,
- "Output %s using initial mode %s\n",
- config->output[o]->name, modes[o]->name);
+ xf86DrvMsg (scrn->scrnIndex, X_INFO,
+ "Output %s using initial mode %s +%d+%d\n",
+ config->output[o]->name, modes[o]->name,
+ config->output[o]->initial_x,
+ config->output[o]->initial_y);
}
/*
diff --git a/xorg-server/hw/xfree86/modes/xf86Crtc.h b/xorg-server/hw/xfree86/modes/xf86Crtc.h
index 3c5bbcfd5..8b0160845 100644
--- a/xorg-server/hw/xfree86/modes/xf86Crtc.h
+++ b/xorg-server/hw/xfree86/modes/xf86Crtc.h
@@ -745,6 +745,8 @@ xf86CompatOutput(ScrnInfoPtr pScrn)
{
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ if (config->compat_output < 0)
+ return NULL;
return config->output[config->compat_output];
}
diff --git a/xorg-server/hw/xfree86/modes/xf86DiDGA.c b/xorg-server/hw/xfree86/modes/xf86DiDGA.c
index 3f1a3309f..645727441 100644
--- a/xorg-server/hw/xfree86/modes/xf86DiDGA.c
+++ b/xorg-server/hw/xfree86/modes/xf86DiDGA.c
@@ -60,7 +60,7 @@ xf86_dga_get_modes(ScreenPtr pScreen)
if (!num)
return FALSE;
- modes = malloc(num * sizeof(DGAModeRec));
+ modes = xallocarray(num, sizeof(DGAModeRec));
if (!modes)
return FALSE;
diff --git a/xorg-server/hw/xfree86/modes/xf86RandR12.c b/xorg-server/hw/xfree86/modes/xf86RandR12.c
index b1c306a88..0d446da64 100644
--- a/xorg-server/hw/xfree86/modes/xf86RandR12.c
+++ b/xorg-server/hw/xfree86/modes/xf86RandR12.c
@@ -1058,7 +1058,7 @@ xf86RandR12CrtcNotify(RRCrtcPtr randr_crtc)
DisplayModePtr mode = &crtc->mode;
Bool ret;
- randr_outputs = malloc(config->num_output * sizeof(RROutputPtr));
+ randr_outputs = xallocarray(config->num_output, sizeof(RROutputPtr));
if (!randr_outputs)
return FALSE;
x = crtc->x;
@@ -1150,7 +1150,7 @@ xf86RandR12CrtcSet(ScreenPtr pScreen,
if (!crtc->scrn->vtSema)
return FALSE;
- save_crtcs = malloc(config->num_output * sizeof(xf86CrtcPtr));
+ save_crtcs = xallocarray(config->num_output, sizeof(xf86CrtcPtr));
if ((randr_mode != NULL) != crtc->enabled)
changed = TRUE;
else if (randr_mode && !xf86RandRModeMatches(randr_mode, &crtc->mode))
@@ -1255,9 +1255,8 @@ xf86RandR12CrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc)
if (randr_crtc->gammaSize != crtc->gamma_size) {
CARD16 *tmp_ptr;
- tmp_ptr =
- realloc(crtc->gamma_red,
- 3 * randr_crtc->gammaSize * sizeof(CARD16));
+ tmp_ptr = reallocarray(crtc->gamma_red,
+ randr_crtc->gammaSize, 3 * sizeof(CARD16));
if (!tmp_ptr)
return FALSE;
crtc->gamma_red = tmp_ptr;
@@ -1298,9 +1297,8 @@ xf86RandR12CrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc)
if (randr_crtc->gammaSize != crtc->gamma_size) {
CARD16 *tmp_ptr;
- tmp_ptr =
- realloc(randr_crtc->gammaRed,
- 3 * crtc->gamma_size * sizeof(CARD16));
+ tmp_ptr = reallocarray(randr_crtc->gammaRed,
+ crtc->gamma_size, 3 * sizeof(CARD16));
if (!tmp_ptr)
return FALSE;
randr_crtc->gammaRed = tmp_ptr;
@@ -1394,7 +1392,7 @@ xf86RROutputSetModes(RROutputPtr randr_output, DisplayModePtr modes)
nmode++;
if (nmode) {
- rrmodes = malloc(nmode * sizeof(RRModePtr));
+ rrmodes = xallocarray(nmode, sizeof(RRModePtr));
if (!rrmodes)
return FALSE;
@@ -1449,8 +1447,8 @@ xf86RandR12SetInfo12(ScreenPtr pScreen)
int o, c, l;
int nclone;
- clones = malloc(config->num_output * sizeof(RROutputPtr));
- crtcs = malloc(config->num_crtc * sizeof(RRCrtcPtr));
+ clones = xallocarray(config->num_output, sizeof(RROutputPtr));
+ crtcs = xallocarray(config->num_crtc, sizeof(RRCrtcPtr));
for (o = 0; o < config->num_output; o++) {
xf86OutputPtr output = config->output[o];
@@ -1564,6 +1562,70 @@ xf86RandR12CreateObjects12(ScreenPtr pScreen)
return TRUE;
}
+static void
+xf86RandR12CreateMonitors(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
+ int o, ot;
+ int ht, vt;
+ int ret;
+ char buf[25];
+
+ for (o = 0; o < config->num_output; o++) {
+ xf86OutputPtr output = config->output[o];
+ struct xf86CrtcTileInfo *tile_info = &output->tile_info, *this_tile;
+ RRMonitorPtr monitor;
+ int output_num, num_outputs;
+ if (!tile_info->group_id)
+ continue;
+
+ if (tile_info->tile_h_loc ||
+ tile_info->tile_v_loc)
+ continue;
+
+ num_outputs = tile_info->num_h_tile * tile_info->num_v_tile;
+
+ monitor = RRMonitorAlloc(num_outputs);
+ if (!monitor)
+ return;
+ monitor->pScreen = pScreen;
+ snprintf(buf, 25, "Auto-Monitor-%d", tile_info->group_id);
+ monitor->name = MakeAtom(buf, strlen(buf), TRUE);
+ monitor->primary = 0;
+ monitor->automatic = TRUE;
+ memset(&monitor->geometry.box, 0, sizeof(monitor->geometry.box));
+
+ output_num = 0;
+ for (ht = 0; ht < tile_info->num_h_tile; ht++) {
+ for (vt = 0; vt < tile_info->num_v_tile; vt++) {
+
+ for (ot = 0; ot < config->num_output; ot++) {
+ this_tile = &config->output[ot]->tile_info;
+
+ if (this_tile->group_id != tile_info->group_id)
+ continue;
+
+ if (this_tile->tile_h_loc != ht ||
+ this_tile->tile_v_loc != vt)
+ continue;
+
+ monitor->outputs[output_num] = config->output[ot]->randr_output->id;
+ output_num++;
+
+ }
+
+ }
+ }
+
+ ret = RRMonitorAdd(serverClient, pScreen, monitor);
+ if (ret) {
+ RRMonitorFree(monitor);
+ return;
+ }
+ }
+}
+
static Bool
xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
{
@@ -1579,6 +1641,8 @@ xf86RandR12CreateScreenResources12(ScreenPtr pScreen)
RRScreenSetSizeRange(pScreen, config->minWidth, config->minHeight,
config->maxWidth, config->maxHeight);
+
+ xf86RandR12CreateMonitors(pScreen);
return TRUE;
}
diff --git a/xorg-server/hw/xfree86/os-support/bus/Sbus.c b/xorg-server/hw/xfree86/os-support/bus/Sbus.c
index 16ce5b58a..86b4d685a 100644
--- a/xorg-server/hw/xfree86/os-support/bus/Sbus.c
+++ b/xorg-server/hw/xfree86/os-support/bus/Sbus.c
@@ -440,7 +440,7 @@ sparcPromAssignNodes(void)
for (i = 0, j = 0; i < 32; i++)
if (devicePtrs[i] && devicePtrs[i]->fbNum == -1)
j++;
- xf86SbusInfo = xnfrealloc(xf86SbusInfo, sizeof(psdp) * (n + j + 1));
+ xf86SbusInfo = xnfreallocarray(xf86SbusInfo, n + j + 1, sizeof(psdp));
for (i = 0, psdpp = xf86SbusInfo; i < 32; i++)
if (devicePtrs[i]) {
if (devicePtrs[i]->fbNum == -1) {
diff --git a/xorg-server/hw/xfree86/os-support/solaris/Makefile.am b/xorg-server/hw/xfree86/os-support/solaris/Makefile.am
index 6cda4b361..e534bc8dc 100644
--- a/xorg-server/hw/xfree86/os-support/solaris/Makefile.am
+++ b/xorg-server/hw/xfree86/os-support/solaris/Makefile.am
@@ -33,5 +33,4 @@ AM_CFLAGS = -DUSESTDRES -DHAVE_SYSV_IPC $(XORG_CFLAGS) $(DIX_CFLAGS)
AM_CPPFLAGS = $(XORG_INCS)
-EXTRA_DIST = solaris-amd64.S solaris-ia32.S solaris-sparcv8plus.S \
- apSolaris.shar sun_inout.s
+EXTRA_DIST = solaris-amd64.S solaris-ia32.S solaris-sparcv8plus.S sun_inout.s
diff --git a/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar b/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar
deleted file mode 100644
index a3548f7b4..000000000
--- a/xorg-server/hw/xfree86/os-support/solaris/apSolaris.shar
+++ /dev/null
@@ -1,806 +0,0 @@
-#!/bin/sh
-#
-# This is a shell archive. Save it in a file, remove anything before
-# this line, and then unpack it by entering "sh file". Note, it may
-# create directories; files and directories will be owned by you and
-# have default permissions.
-# Made on Sun Jun 25 20:24:59 CEST 2006 by Martin Bochnig at martux.org
-#
-# This archive contains:
-#
-# ./aperture
-#
-# ./aperture/Makefile
-# ./aperture/Makefile.amd64
-# ./aperture/Makefile.sparcv9
-# ./aperture/README
-# ./aperture/aperture.c
-# ./aperture/aperture.conf
-# ./aperture/devlink.tab
-#
-echo c - ./aperture
-mkdir -p ./aperture > /dev/null 2>&1
-#
-echo x - ./aperture/Makefile
-sed 's/^X//' >./aperture/Makefile << 'END-of-./aperture/Makefile'
-X#
-X# File: makefile for aperture Framebuffer Driver
-X# Author: Doug Anson (danson@lgc.com)
-X# Date: 2/15/94
-X# Modified: David Holland (davidh@use.com)
-X# Date: 2/23/94
-X# - Changed name, and debugging structure
-X# Modified: Marc Aurele La France (tsi@xfree86.org)
-X# Date: 2001.06.08
-X# - SPARC support, cleanup and turf aptest.
-X#
-X# >>NOTE<< Have a look at Makefile.sparcv9 for specifics.
-X#
-X# Modified: Martin Bochnig (martin@martux.org)
-X# Date: 2006.06.24
-X# - Slightly modified to also build on Solaris 10 and 11.
-X# - amd64 64 bit kernel support
-X# - cosmetical changes to also support sun4v, not only sun4u
-X#
-X# >>NOTE<< Have a look at Makefile.amd64 for amd64 specifics.
-X#
-X# GNU gcc compiler
-XCC=gcc
-XCFLGS=-fno-builtin -Wall -O3
-X
-X#
-X# SUNWspro compiler
-X#CC=/opt/SUNWspro/bin/cc
-X#CFLGS=-Xa -xnolib -xO3
-X
-X#
-X# Debug error reporting
-X#DEBUG_FLG=
-X#DEBUG_FLG=-DAPERTURE_DEBUG
-X
-X#
-X# Files and object declarations
-XKERNEL_FLGS=-D_KERNEL -DSUNDDI
-XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG)
-XCFILES= aperture.c
-XOBJS= aperture.o
-XDRIVER= aperture
-X
-X#
-X# Make rules
-Xall: $(DRIVER)
-X
-X$(DRIVER): $(OBJS)
-X @if [ -f "Makefile.`isainfo -k`" ]; then \
-X make -f Makefile.`isainfo -k` $(DRIVER); \
-X else \
-X rm -f $(DRIVER); \
-X ld -r -o $(DRIVER) $(OBJS); \
-X fi
-X
-Xinstall: $(DRIVER)
-X @if [ -f "Makefile.`isainfo -k`" ]; then \
-X make -f Makefile.`isainfo -k` install; \
-X else \
-X cp aperture.conf /kernel/drv; \
-X cp $(DRIVER) /kernel/drv; \
-X fi
-X
-Xadd_drv:
-X @if [ -f "Makefile.`isainfo -k`" ]; then \
-X make -f Makefile.`isainfo -k` add_drv; \
-X else \
-X add_drv aperture; \
-X fi
-X
-Xclean:
-X rm -f *% *.BAK $(OBJS) $(DRIVER) core
-X
-X.SUFFIXES: .i
-X
-X.c.i:
-X $(CC) -E $(CFLAGS) $*.c > $@
-X
-X.c.o:
-X @if [ -f "Makefile.`isainfo -k`" ]; then \
-X make -f Makefile.`isainfo -k` $@; \
-X else \
-X rm -f $@; \
-X $(CC) -c $(CFLAGS) $*.c -o $@; \
-X fi
-END-of-./aperture/Makefile
-echo x - ./aperture/Makefile.amd64
-sed 's/^X//' >./aperture/Makefile.amd64 << 'END-of-./aperture/Makefile.amd64'
-X#
-X# File: Makefile for aperture Framebuffer Driver
-X# Author: Doug Anson (danson@lgc.com)
-X# Date: 2/15/94
-X# Modified: David Holland (davidh@use.com)
-X# Date: 2/23/94
-X# - Changed name, and debugging structure
-X# Modified: Marc Aurele La France (tsi@xfree86.org)
-X# Date: 2001.06.08
-X# - SPARC support, cleanup and turf aptest.
-X# Modified: Martin Bochnig (martin@martux.org)
-X# - amd64 64 bit kernel support, cosmetics and also
-X# supporting sun4v (and arbitrary sparcv9) platforms
-X# as well as SunOS 5.10 or higher now
-X# - Changed name
-X#
-X
-X#
-X# GNU gcc compiler, version 3.2 or later
-X#
-XCC=gcc
-XCFLGS=-fno-builtin -Wall -O3 -m64 -mcmodel=kernel
-X
-X#
-X# SUNWspro compiler (untested, might not properly work for amd64 here)
-X#CC=/opt/SUNWspro/bin/cc
-X#CFLGS=-Xa -xarch=v9 -xnolib -xO3
-X
-X#
-X# Debug error reporting
-X#DEBUG_FLG=
-X#DEBUG_FLG=-DAPERTURE_DEBUG
-X
-X#
-X# Files and object declarations
-XKERNEL_FLGS=-D_KERNEL -DSUNDDI
-XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG)
-XCFILES= aperture.c
-XOBJS= aperture.o
-XDRIVER= aperture
-X
-X#
-X# Make rules
-Xall: $(DRIVER)
-X
-X$(DRIVER): $(OBJS)
-X rm -f $(DRIVER)
-X ld -r -o $(DRIVER) $(OBJS)
-X
-Xinstall: $(DRIVER)
-X cp aperture.conf /kernel/drv
-X cp $(DRIVER) /kernel/drv/amd64
-X
-Xadd_drv:
-X add_drv aperture
-X
-Xclean:
-X rm -f *% *.BAK $(OBJS) $(DRIVER) core
-X
-X.SUFFIXES: .i
-X
-X.c.i:
-X $(CC) -E $(CFLAGS) $*.c > $@
-END-of-./aperture/Makefile.amd64
-echo x - ./aperture/Makefile.sparcv9
-sed 's/^X//' >./aperture/Makefile.sparcv9 << 'END-of-./aperture/Makefile.sparcv9'
-X#
-X# File: makefile for aperture Framebuffer Driver
-X# Author: Doug Anson (danson@lgc.com)
-X# Date: 2/15/94
-X# Modified: David Holland (davidh@use.com)
-X# Date: 2/23/94
-X# - Changed name, and debugging structure
-X# Modified: Marc Aurele La France (tsi@xfree86.org)
-X# Date: 2001.06.08
-X# - SPARC support, cleanup and turf aptest.
-X# Modified: Martin Bochnig (martin@martux.org)
-X# Date: 2006.06.24
-X# - Changed name for generic sparcv9 support
-X# - updated to better work with Solaris 10 and 11
-X#
-X
-X#
-X# GNU gcc compiler, version 3.2 or later
-X#
-XCC=gcc
-XCFLGS=-fno-builtin -Wall -O3 -m64
-X
-X#
-X# SUNWspro compiler
-X#CC=/opt/SUNWspro/bin/cc
-X#CFLGS=-Xa -xarch=v9 -xnolib -xO3
-X
-X#
-X# Debug error reporting
-X#DEBUG_FLG=
-X#DEBUG_FLG=-DAPERTURE_DEBUG
-X
-X#
-X# Files and object declarations
-XKERNEL_FLGS=-D_KERNEL -DSUNDDI
-XCFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG)
-XCFILES= aperture.c
-XOBJS= aperture.o
-XDRIVER= aperture
-X
-X#
-X# Make rules
-Xall: $(DRIVER)
-X
-X$(DRIVER): $(OBJS)
-X rm -f $(DRIVER)
-X ld -r -o $(DRIVER) $(OBJS)
-X
-Xinstall: $(DRIVER)
-X cp aperture.conf /kernel/drv
-X cp $(DRIVER) /kernel/drv/sparcv9
-X
-Xadd_drv:
-X add_drv aperture
-X
-Xclean:
-X rm -f *% *.BAK $(OBJS) $(DRIVER) core
-X
-X.SUFFIXES: .i
-X
-X.c.i:
-X $(CC) -E $(CFLAGS) $*.c > $@
-END-of-./aperture/Makefile.sparcv9
-echo x - ./aperture/README
-sed 's/^X//' >./aperture/README << 'END-of-./aperture/README'
-XFramebuffer aperture driver.
-X
-XThis driver was written to provide a device that, unlike /dev/mem, allows
-Xmmap()'ing of ranges beyond installed memory.
-X
-XThe original x86-based version of this driver was the collaborative work of
-XDoug Anson (danson@lgc.com), and David Holland (davidh@use.com). It has since
-Xbeen rewritten to also work on sparc machines and - later on - also on sparcv9
-Xand recently amd64 64 bit kernels.
-XIt flawlessly compiles and installs on Solaris 10 and 11 now.
-X
-X
-XInstallation instructions:
-X
-X1) Check the Makefile, for appropriate CC, and CFLAGS definitions. Compiling
-X with APERTURE_DEBUG defined means the driver will generate reams of
-X debugging output. You'll probably want to leave this off...
-X
-X2) Type 'make' (or 'gmake'). Both the driver and test program should compile
-X without any problems. No warning messages should be generated.
-X
-X3) Become 'root'.
-X
-X4) Type 'make install' and 'make add_drv'. The screen should look something
-X like this:
-X
-X # make install
-X cp aperture aperture.conf /kernel/drv
-X # make add_drv
-X add_drv aperture
-X
-X On a sparcv9 machine this will mention the /kernel/drv/sparcv9 directory
-X instead of /kernel/drv. Similarily /kernel/drv/amd64 should be used on amd64.
-X
-X This installs the driver to the system.
-X
-X5) While as root modify the file /etc/devlink.tab, adding these lines:
-X
-X# The following entry is for the framebuffer driver
-Xtype=ddi_pseudo;name=aperture fbs/\M0
-X
-X Add that line exactly as shown. You may also simply add the
-X contents of the devlink.tab file supplied to /etc/devlink.tab.
-X It contains the lines as well. (Yes, that is a tab between
-X aperture and fbs, not spaces - very important)
-X
-X6) Perform a reconfiguration boot of the system.
-X
-X # touch /reconfigure
-X # init 6
-X
-XBug reports, questions, suggestions, etc can be sent to xfree86@xfree86.org.
-END-of-./aperture/README
-echo x - ./aperture/aperture.c
-sed 's/^X//' >./aperture/aperture.c << 'END-of-./aperture/aperture.c'
-X/*
-X * Copyright (C) 2001 The XFree86 Project, Inc. All Rights Reserved.
-X *
-X * Permission is hereby granted, free of charge, to any person obtaining a copy
-X * of this software and associated documentation files (the "Software"), to
-X * deal in the Software without restriction, including without limitation the
-X * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-X * sell copies of the Software, and to permit persons to whom the Software is
-X * furnished to do so, subject to the following conditions:
-X *
-X * The above copyright notice and this permission notice shall be included in
-X * all copies or substantial portions of the Software.
-X *
-X * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-X * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-X * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-X * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-X * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-X * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-X *
-X * Except as contained in this notice, the name of the XFree86 Project shall
-X * not be used in advertising or otherwise to promote the sale, use or other
-X * dealings in this Software without prior written authorization from the
-X * XFree86 Project.
-X */
-X
-X/*
-X * Aperture driver for Solaris.
-X */
-X
-X/*
-X * Modified: Martin Bochnig (martin@martux.org)
-X * Log: Commented out obsolete kernel interfaces DDI_IDENTIFIED and DDI_NOT_IDENTIFIED
-X * not supported by SunOS 5.10 or higher anymore,
-X * see http://docs.sun.com/app/docs/doc/819-2255/6n4ibnffr?a=view
-X */
-X
-X#include <sys/conf.h>
-X#include <sys/ddi.h>
-X#include <sys/modctl.h>
-X#include <sys/open.h>
-X#include <sys/stat.h>
-X#include <sys/sunddi.h>
-X
-X#define DEV_IDENT "aperture"
-X#define DEV_BANNER "XFree86 aperture driver"
-X
-X#ifndef D_64BIT
-X#define D_64BIT 0
-X#endif
-X
-X#ifndef NULL
-X#define NULL ((void *)0)
-X#endif
-X
-X/*
-X * open(9E)
-X */
-X/*ARGSUSED*/
-Xstatic int
-Xaperture_open
-X(
-X#ifdef __STDC__
-X dev_t *devp,
-X int flag,
-X int typ,
-X struct cred *cred
-X#endif
-X)
-X#ifndef __STDC__
-X dev_t *devp;
-X int flag;
-X int typ;
-X struct cred *cred;
-X#endif
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering open()\n");
-X
-X#endif
-X
-X if ((typ != OTYP_CHR) || (getminor(*devp)))
-X error = EINVAL;
-X else
-X error = 0;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving open() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-X/*
-X * mmap(9E)
-X */
-X/*ARGSUSED*/
-Xstatic int
-Xaperture_mmap
-X(
-X#ifdef __STDC__
-X dev_t dev,
-X off_t off,
-X int prot
-X#endif
-X)
-X#ifndef __STDC__
-X dev_t dev;
-X off_t off;
-X int prot;
-X#endif
-X{
-X pfn_t pf;
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering mmap(0x%016lx)\n", off);
-X
-X#endif
-X
-X pf = btop((unsigned long)off);
-X
-X /* Deal with mmap(9E) interface limits */
-X error = (int)pf;
-X if ((error < 0) || (pf != (pfn_t)error))
-X error = -1;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving mmap() = 0x%08lx", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-Xstatic struct cb_ops aperture_cb_ops =
-X{
-X aperture_open, /* open */
-X nulldev, /* close */
-X nodev, /* strategy */
-X nodev, /* print */
-X nodev, /* dump */
-X nodev, /* read */
-X nodev, /* write */
-X nodev, /* ioctl */
-X nodev, /* devmap */
-X aperture_mmap, /* mmap */
-X ddi_segmap, /* segmap */
-X nochpoll, /* poll */
-X ddi_prop_op, /* cb_prop_op */
-X 0, /* streamtab */
-X D_NEW | D_MP | D_64BIT /* Driver compatibility flag */
-X};
-X
-X
-Xstatic dev_info_t *aperture_dip; /* private copy of devinfo pointer */
-X
-X/*
-X * getinfo(9E)
-X */
-X/*ARGSUSED*/
-Xstatic int
-Xaperture_getinfo
-X(
-X#ifdef __STDC__
-X dev_info_t *dip,
-X ddi_info_cmd_t infocmd,
-X void *arg,
-X void **result
-X#endif
-X)
-X#ifndef __STDC__
-X dev_info_t *dip;
-X ddi_info_cmd_t infocmd;
-X void *arg;
-X void **result;
-X#endif
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering getinfo()\n");
-X
-X#endif
-X
-X switch (infocmd) {
-X case DDI_INFO_DEVT2DEVINFO:
-X *result = aperture_dip;
-X error = DDI_SUCCESS;
-X break;
-X case DDI_INFO_DEVT2INSTANCE:
-X *result = NULL;
-X error = DDI_SUCCESS;
-X break;
-X default:
-X error = DDI_FAILURE;
-X }
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving getinfo() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-X/*
-X * identify(9E)
-X */
-X/*ARGSUSED*/
-Xstatic int
-Xaperture_identify
-X(
-X#ifdef __STDC__
-X dev_info_t *dip
-X#endif
-X)
-X#ifndef __STDC__
-X dev_info_t *dip;
-X#endif
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering identify()\n");
-X
-X#endif
-X
-X if (strcmp(ddi_get_name(dip), DEV_IDENT))
-X error = 1 /* DDI_NOT_IDENTIFIED obsolete since SunOS 5.10 */ ;
-X else
-X error = 2 /* DDI_IDENTIFIED obsolete since SunOS 5.10 */ ;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving identify() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-X/*
-X * attach(9E)
-X */
-X/*ARGSUSED*/
-Xstatic int
-Xaperture_attach
-X(
-X#ifdef __STDC__
-X dev_info_t *dip,
-X ddi_attach_cmd_t cmd
-X#endif
-X)
-X#ifndef __STDC__
-X dev_info_t *dip;
-X ddi_attach_cmd_t cmd;
-X#endif
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering attach()\n");
-X
-X#endif
-X
-X if (cmd != DDI_ATTACH)
-X {
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": not attach(, DDI_ATTACH)\n");
-X
-X#endif
-X
-X error = DDI_FAILURE;
-X }
-X else
-X {
-X error = ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR,
-X (minor_t)ddi_get_instance(dip),
-X NULL, 0 /* NODESPECIFIC_DEV obsolete since SunOS 5.10 */ );
-X
-X if (error == DDI_SUCCESS)
-X {
-X aperture_dip = dip;
-X ddi_report_dev(dip);
-X }
-X }
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving attach() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-X/*
-X * detach(9E)
-X */
-Xstatic int
-Xaperture_detach
-X(
-X#ifdef __STDC__
-X dev_info_t *dip,
-X ddi_detach_cmd_t cmd
-X#endif
-X)
-X#ifndef __STDC__
-X dev_info_t *dip;
-X ddi_detach_cmd_t cmd;
-X#endif
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering detach()\n");
-X
-X#endif
-X
-X if (cmd != DDI_DETACH)
-X {
-X error = DDI_FAILURE;
-X }
-X else
-X {
-X ddi_remove_minor_node(dip, NULL);
-X aperture_dip = NULL;
-X error = DDI_SUCCESS;
-X }
-X
-X#if APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving detach() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-X
-Xstatic struct dev_ops aperture_ops =
-X{
-X DEVO_REV, /* revision */
-X 0, /* refcnt */
-X aperture_getinfo, /* getinfo */
-X aperture_identify, /* identify */
-X nulldev, /* probe */
-X aperture_attach, /* attach */
-X aperture_detach, /* detach */
-X nodev, /* reset */
-X &aperture_cb_ops, /* driver operations */
-X NULL /* bus operations */
-X};
-X
-X
-Xstatic struct modldrv modldrv =
-X{
-X &mod_driverops, /* mod_ops structure pointer */
-X DEV_BANNER, /* driver banner string */
-X &aperture_ops, /* dev_ops structure pointer */
-X};
-X
-X
-Xstatic struct modlinkage modlinkage =
-X{
-X MODREV_1, /* module API revision */
-X {
-X &modldrv, /* module driver structure pointer */
-X NULL /* list termination */
-X }
-X};
-X
-X
-X/*
-X * _init(9E)
-X */
-Xint
-X_init
-X(
-X#ifdef __STDC__
-X void
-X#endif
-X)
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering _init()\n");
-X
-X#endif
-X
-X error = mod_install(&modlinkage);
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving _init() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-X/*
-X * _info(9E)
-X */
-Xint
-X_info
-X(
-X#ifdef __STDC__
-X struct modinfo *modinfop
-X#endif
-X)
-X#ifndef __STDC__
-X struct modinfo *modinfop;
-X#endif
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering _info()\n");
-X
-X#endif
-X
-X error = mod_info(&modlinkage, modinfop);
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving _info() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-X
-X/*
-X * _fini(9E)
-X */
-Xint
-X_fini
-X(
-X#ifdef __STDC__
-X void
-X#endif
-X)
-X{
-X int error;
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": entering _fini()\n");
-X
-X#endif
-X
-X error = mod_remove(&modlinkage);
-X
-X#ifdef APERTURE_DEBUG
-X
-X cmn_err(CE_CONT, DEV_IDENT ": leaving _fini() = %d\n", error);
-X
-X#endif
-X
-X return error;
-X}
-END-of-./aperture/aperture.c
-echo x - ./aperture/aperture.conf
-sed 's/^X//' >./aperture/aperture.conf << 'END-of-./aperture/aperture.conf'
-X#
-X# Copyright 1994 Doug Anson, danson@lgc.com & David Holland, davidh@use.com
-X#
-X# File: aperture.conf
-X# Author: Doug Anson (danson@lgc.com)
-X#
-X# Modified: David Holland (davidh@use.com)
-X# Log: Change comments 02/23/94
-X# Change defaults/comments 09/25/94
-X#
-X# Modified: Marc Aurele La France (tsi@xfree86.org)
-X# Log: SPARC changes 2001.09
-X#
-X# Purpose: This conf file is used by the aperture driver.
-X#
-Xname="aperture" parent="pseudo";
-END-of-./aperture/aperture.conf
-echo x - ./aperture/devlink.tab
-sed 's/^X//' >./aperture/devlink.tab << 'END-of-./aperture/devlink.tab'
-X# The following entry is for the aperture driver
-Xtype=ddi_pseudo;name=aperture fbs/\M0
-END-of-./aperture/devlink.tab
-exit
-
diff --git a/xorg-server/hw/xfree86/parser/Configint.h b/xorg-server/hw/xfree86/parser/Configint.h
index 31035ae2d..e5fa6cec2 100644
--- a/xorg-server/hw/xfree86/parser/Configint.h
+++ b/xorg-server/hw/xfree86/parser/Configint.h
@@ -204,6 +204,8 @@ else\
"Multiple \"%s\" lines."
#define MUST_BE_OCTAL_MSG \
"The number \"%d\" given in this section must be in octal (0xxx) format."
+#define GPU_DEVICE_TOO_MANY \
+"More than %d GPU devices defined."
/* Warning messages */
#define OBSOLETE_MSG \
diff --git a/xorg-server/hw/xfree86/parser/Screen.c b/xorg-server/hw/xfree86/parser/Screen.c
index 9d8eda277..b5b454ff4 100644
--- a/xorg-server/hw/xfree86/parser/Screen.c
+++ b/xorg-server/hw/xfree86/parser/Screen.c
@@ -211,6 +211,7 @@ static xf86ConfigSymTabRec ScreenTab[] = {
{DEFAULTFBBPP, "defaultfbbpp"},
{VIRTUAL, "virtual"},
{OPTION, "option"},
+ {GDEVICE, "gpudevice"},
{-1, ""},
};
@@ -270,6 +271,13 @@ xf86parseScreenSection(void)
Error(QUOTE_MSG, "Device");
ptr->scrn_device_str = xf86_lex_val.str;
break;
+ case GDEVICE:
+ if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
+ Error(QUOTE_MSG, "GPUDevice");
+ if (ptr->num_gpu_devices == CONF_MAXGPUDEVICES)
+ Error(GPU_DEVICE_TOO_MANY, CONF_MAXGPUDEVICES);
+ ptr->scrn_gpu_device_str[ptr->num_gpu_devices++] = xf86_lex_val.str;
+ break;
case MONITOR:
if (xf86getSubToken(&(ptr->scrn_comment)) != STRING)
Error(QUOTE_MSG, "Monitor");
@@ -342,7 +350,7 @@ xf86printScreenSection(FILE * cf, XF86ConfScreenPtr ptr)
XF86ConfAdaptorLinkPtr aptr;
XF86ConfDisplayPtr dptr;
XF86ModePtr mptr;
-
+ int i;
while (ptr) {
fprintf(cf, "Section \"Screen\"\n");
if (ptr->scrn_comment)
@@ -353,6 +361,9 @@ xf86printScreenSection(FILE * cf, XF86ConfScreenPtr ptr)
fprintf(cf, "\tDriver \"%s\"\n", ptr->scrn_obso_driver);
if (ptr->scrn_device_str)
fprintf(cf, "\tDevice \"%s\"\n", ptr->scrn_device_str);
+ for (i = 0; i < ptr->num_gpu_devices; i++)
+ if (ptr->scrn_gpu_device_str[i])
+ fprintf(cf, "\tGPUDevice \"%s\"\n", ptr->scrn_gpu_device_str[i]);
if (ptr->scrn_monitor_str)
fprintf(cf, "\tMonitor \"%s\"\n", ptr->scrn_monitor_str);
if (ptr->scrn_defaultdepth)
@@ -426,11 +437,13 @@ void
xf86freeScreenList(XF86ConfScreenPtr ptr)
{
XF86ConfScreenPtr prev;
-
+ int i;
while (ptr) {
TestFree(ptr->scrn_identifier);
TestFree(ptr->scrn_monitor_str);
TestFree(ptr->scrn_device_str);
+ for (i = 0; i < ptr->num_gpu_devices; i++)
+ TestFree(ptr->scrn_gpu_device_str[i]);
TestFree(ptr->scrn_comment);
xf86optionListFree(ptr->scrn_option_lst);
xf86freeAdaptorLinkList(ptr->scrn_adaptor_lst);
@@ -487,6 +500,7 @@ xf86validateScreen(XF86ConfigPtr p)
XF86ConfScreenPtr screen = p->conf_screen_lst;
XF86ConfMonitorPtr monitor;
XF86ConfAdaptorLinkPtr adaptor;
+ int i;
while (screen) {
if (screen->scrn_obso_driver && !screen->scrn_identifier)
@@ -505,6 +519,10 @@ xf86validateScreen(XF86ConfigPtr p)
screen->scrn_device =
xf86findDevice(screen->scrn_device_str, p->conf_device_lst);
+ for (i = 0; i < screen->num_gpu_devices; i++) {
+ screen->scrn_gpu_devices[i] =
+ xf86findDevice(screen->scrn_gpu_device_str[i], p->conf_device_lst);
+ }
adaptor = screen->scrn_adaptor_lst;
while (adaptor) {
adaptor->al_adaptor =
diff --git a/xorg-server/hw/xfree86/parser/xf86Parser.h b/xorg-server/hw/xfree86/parser/xf86Parser.h
index 43e17550c..b3a50e52f 100644
--- a/xorg-server/hw/xfree86/parser/xf86Parser.h
+++ b/xorg-server/hw/xfree86/parser/xf86Parser.h
@@ -259,6 +259,7 @@ typedef struct {
XF86ConfVideoAdaptorPtr al_adaptor;
} XF86ConfAdaptorLinkRec, *XF86ConfAdaptorLinkPtr;
+#define CONF_MAXGPUDEVICES 4
typedef struct {
GenericListRec list;
const char *scrn_identifier;
@@ -276,6 +277,10 @@ typedef struct {
char *scrn_comment;
int scrn_virtualX, scrn_virtualY;
char *match_seat;
+
+ int num_gpu_devices;
+ const char *scrn_gpu_device_str[CONF_MAXGPUDEVICES];
+ XF86ConfDevicePtr scrn_gpu_devices[CONF_MAXGPUDEVICES];
} XF86ConfScreenRec, *XF86ConfScreenPtr;
typedef struct {
diff --git a/xorg-server/hw/xfree86/parser/xf86tokens.h b/xorg-server/hw/xfree86/parser/xf86tokens.h
index 9c44970ea..bbd6b90d1 100644
--- a/xorg-server/hw/xfree86/parser/xf86tokens.h
+++ b/xorg-server/hw/xfree86/parser/xf86tokens.h
@@ -143,6 +143,7 @@ typedef enum {
/* Screen tokens */
OBSDRIVER,
MDEVICE,
+ GDEVICE,
MONITOR,
SCREENNO,
DEFAULTDEPTH,
diff --git a/xorg-server/hw/xfree86/utils/cvt/cvt.c b/xorg-server/hw/xfree86/utils/cvt/cvt.c
index d5df17fd9..9413c20fa 100644
--- a/xorg-server/hw/xfree86/utils/cvt/cvt.c
+++ b/xorg-server/hw/xfree86/utils/cvt/cvt.c
@@ -54,11 +54,11 @@ XNFalloc(unsigned long n)
/* xnfcalloc implementation used by the server code we built in */
void *
-XNFcalloc(unsigned long n)
+XNFcallocarray(size_t nmemb, size_t size)
{
void *r;
- r = calloc(1, n);
+ r = calloc(nmemb, size);
if (!r) {
perror("calloc failed");
exit(1);
diff --git a/xorg-server/hw/xfree86/vbe/vbe.c b/xorg-server/hw/xfree86/vbe/vbe.c
index 5ea019733..ef12cb805 100644
--- a/xorg-server/hw/xfree86/vbe/vbe.c
+++ b/xorg-server/hw/xfree86/vbe/vbe.c
@@ -397,7 +397,7 @@ VBEGetVBEInfo(vbeInfoPtr pVbe)
i = 0;
while (modes[i] != 0xffff)
i++;
- block->VideoModePtr = malloc(sizeof(CARD16) * (i + 1));
+ block->VideoModePtr = xallocarray(i + 1, sizeof(CARD16));
memcpy(block->VideoModePtr, modes, sizeof(CARD16) * i);
block->VideoModePtr[i] = 0xffff;
@@ -825,7 +825,7 @@ VBESetGetPaletteData(vbeInfoPtr pVbe, Bool set, int first, int num,
if (set)
return data;
- data = malloc(num * sizeof(CARD32));
+ data = xallocarray(num, sizeof(CARD32));
memcpy(data, pVbe->memory, num * sizeof(CARD32));
return data;
diff --git a/xorg-server/hw/xnest/Color.c b/xorg-server/hw/xnest/Color.c
index 8d9d35621..3a9e42203 100644
--- a/xorg-server/hw/xnest/Color.c
+++ b/xorg-server/hw/xnest/Color.c
@@ -62,7 +62,7 @@ xnestCreateColormap(ColormapPtr pCmap)
switch (pVisual->class) {
case StaticGray: /* read only */
- colors = (XColor *) malloc(ncolors * sizeof(XColor));
+ colors = xallocarray(ncolors, sizeof(XColor));
for (i = 0; i < ncolors; i++)
colors[i].pixel = i;
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
@@ -75,7 +75,7 @@ xnestCreateColormap(ColormapPtr pCmap)
break;
case StaticColor: /* read only */
- colors = (XColor *) malloc(ncolors * sizeof(XColor));
+ colors = xallocarray(ncolors, sizeof(XColor));
for (i = 0; i < ncolors; i++)
colors[i].pixel = i;
XQueryColors(xnestDisplay, xnestColormap(pCmap), colors, ncolors);
@@ -88,7 +88,7 @@ xnestCreateColormap(ColormapPtr pCmap)
break;
case TrueColor: /* read only */
- colors = (XColor *) malloc(ncolors * sizeof(XColor));
+ colors = xallocarray(ncolors, sizeof(XColor));
red = green = blue = 0L;
redInc = lowbit(pVisual->redMask);
greenInc = lowbit(pVisual->greenMask);
@@ -194,14 +194,12 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
xnestInstalledColormapWindows icws;
int numWindows;
- icws.cmapIDs = (Colormap *) malloc(pScreen->maxInstalledCmaps *
- sizeof(Colormap));
+ icws.cmapIDs = xallocarray(pScreen->maxInstalledCmaps, sizeof(Colormap));
icws.numCmapIDs = xnestListInstalledColormaps(pScreen, icws.cmapIDs);
icws.numWindows = 0;
WalkTree(pScreen, xnestCountInstalledColormapWindows, (void *) &icws);
if (icws.numWindows) {
- icws.windows =
- (Window *) malloc((icws.numWindows + 1) * sizeof(Window));
+ icws.windows = xallocarray(icws.numWindows + 1, sizeof(Window));
icws.index = 0;
WalkTree(pScreen, xnestGetInstalledColormapWindows, (void *) &icws);
icws.windows[icws.numWindows] = xnestDefaultWindows[pScreen->myNum];
@@ -220,8 +218,7 @@ xnestSetInstalledColormapWindows(ScreenPtr pScreen)
#ifdef _XSERVER64
{
int i;
- Window64 *windows =
- (Window64 *) malloc(numWindows * sizeof(Window64));
+ Window64 *windows = xallocarray(numWindows, sizeof(Window64));
for (i = 0; i < numWindows; ++i)
windows[i] = icws.windows[i];
@@ -393,7 +390,7 @@ xnestStoreColors(ColormapPtr pCmap, int nColors, xColorItem * pColors)
#ifdef _XSERVER64
{
int i;
- XColor *pColors64 = (XColor *) malloc(nColors * sizeof(XColor));
+ XColor *pColors64 = xallocarray(nColors, sizeof(XColor));
for (i = 0; i < nColors; ++i) {
pColors64[i].pixel = pColors[i].pixel;
diff --git a/xorg-server/hw/xnest/Display.c b/xorg-server/hw/xnest/Display.c
index a2f8acbaa..e6d07dfd1 100644
--- a/xorg-server/hw/xnest/Display.c
+++ b/xorg-server/hw/xnest/Display.c
@@ -121,8 +121,8 @@ xnestOpenDisplay(int argc, char *argv[])
}
xnestNumDefaultColormaps = xnestNumVisuals;
- xnestDefaultColormaps = (Colormap *) malloc(xnestNumDefaultColormaps *
- sizeof(Colormap));
+ xnestDefaultColormaps = xallocarray(xnestNumDefaultColormaps,
+ sizeof(Colormap));
for (i = 0; i < xnestNumDefaultColormaps; i++)
xnestDefaultColormaps[i] = XCreateColormap(xnestDisplay,
DefaultRootWindow
diff --git a/xorg-server/hw/xnest/GC.c b/xorg-server/hw/xnest/GC.c
index 96af6eb91..ecfa61e39 100644
--- a/xorg-server/hw/xnest/GC.c
+++ b/xorg-server/hw/xnest/GC.c
@@ -190,7 +190,7 @@ xnestDestroyGC(GCPtr pGC)
void
xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
{
- int i, size;
+ int i;
BoxPtr pBox;
XRectangle *pRects;
@@ -204,8 +204,7 @@ xnestChangeClip(GCPtr pGC, int type, void *pValue, int nRects)
case CT_REGION:
nRects = RegionNumRects((RegionPtr) pValue);
- size = nRects * sizeof(*pRects);
- pRects = (XRectangle *) malloc(size);
+ pRects = xallocarray(nRects, sizeof(*pRects));
pBox = RegionRects((RegionPtr) pValue);
for (i = nRects; i-- > 0;) {
pRects[i].x = pBox[i].x1;
diff --git a/xorg-server/hw/xnest/Keyboard.c b/xorg-server/hw/xnest/Keyboard.c
index ee3f68e3f..7ee7a7c3c 100644
--- a/xorg-server/hw/xnest/Keyboard.c
+++ b/xorg-server/hw/xnest/Keyboard.c
@@ -16,6 +16,10 @@ is" without express or implied warranty.
#include <xnest-config.h>
#endif
+#ifdef WIN32
+#include <X11/Xwindows.h>
+#endif
+
#include <X11/X.h>
#include <X11/Xproto.h>
#include <xcb/xcb_keysyms.h>
@@ -134,7 +138,7 @@ xnestKeyboardProc(DeviceIntPtr pDev, int onoff)
max_keycode - min_keycode + 1,
&mapWidth);
len = (max_keycode - min_keycode + 1) * mapWidth;
- keymap = (KeySym *) malloc(len * sizeof(KeySym));
+ keymap = xallocarray(len, sizeof(KeySym));
for (i = 0; i < len; ++i)
keymap[i] = keymap64[i];
XFree(keymap64);
diff --git a/xorg-server/hw/xnest/Screen.c b/xorg-server/hw/xnest/Screen.c
index abb4d372d..214b55015 100644
--- a/xorg-server/hw/xnest/Screen.c
+++ b/xorg-server/hw/xnest/Screen.c
@@ -158,7 +158,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
if (!dixRegisterPrivateKey(&xnestCursorScreenKeyRec, PRIVATE_SCREEN, 0))
return FALSE;
- visuals = (VisualPtr) malloc(xnestNumVisuals * sizeof(VisualRec));
+ visuals = xallocarray(xnestNumVisuals, sizeof(VisualRec));
numVisuals = 0;
depths = (DepthPtr) malloc(MAXDEPTH * sizeof(DepthRec));
@@ -224,7 +224,7 @@ xnestOpenScreen(ScreenPtr pScreen, int argc, char *argv[])
numVisuals++;
}
- visuals = (VisualPtr) realloc(visuals, numVisuals * sizeof(VisualRec));
+ visuals = reallocarray(visuals, numVisuals, sizeof(VisualRec));
defaultVisual = visuals[xnestDefaultVisualIndex].vid;
rootDepth = visuals[xnestDefaultVisualIndex].nplanes;
diff --git a/xorg-server/hw/xwayland/xwayland-glamor.c b/xorg-server/hw/xwayland/xwayland-glamor.c
index d06006c70..6b6e59756 100644
--- a/xorg-server/hw/xwayland/xwayland-glamor.c
+++ b/xorg-server/hw/xwayland/xwayland-glamor.c
@@ -310,7 +310,7 @@ xwl_drm_init_egl(struct xwl_screen *xwl_screen)
}
if (!epoxy_has_gl_extension("GL_OES_EGL_image")) {
- ErrorF("GL_OES_EGL_image no available");
+ ErrorF("GL_OES_EGL_image not available\n");
return;
}
@@ -329,7 +329,7 @@ xwl_drm_handle_device(void *data, struct wl_drm *drm, const char *device)
xwl_screen->drm_fd = open(xwl_screen->device_name, O_RDWR | O_CLOEXEC);
if (xwl_screen->drm_fd == -1) {
- ErrorF("wayland-egl: could not open %s (%s)",
+ ErrorF("wayland-egl: could not open %s (%s)\n",
xwl_screen->device_name, strerror(errno));
return;
}
diff --git a/xorg-server/hw/xwayland/xwayland-input.c b/xorg-server/hw/xwayland/xwayland-input.c
index cc3bc53c8..78d9702ac 100644
--- a/xorg-server/hw/xwayland/xwayland-input.c
+++ b/xorg-server/hw/xwayland/xwayland-input.c
@@ -43,7 +43,7 @@ static int
xwl_pointer_proc(DeviceIntPtr device, int what)
{
#define NBUTTONS 10
-#define NAXES 2
+#define NAXES 4
BYTE map[NBUTTONS + 1];
int i = 0;
Atom btn_labels[NBUTTONS] = { 0 };
@@ -67,8 +67,10 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
+ axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HWHEEL);
+ axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_WHEEL);
- if (!InitValuatorClassDeviceStruct(device, 2, btn_labels,
+ if (!InitValuatorClassDeviceStruct(device, NAXES, btn_labels,
GetMotionHistorySize(), Absolute))
return BadValue;
@@ -77,6 +79,13 @@ xwl_pointer_proc(DeviceIntPtr device, int what)
0, 0xFFFF, 10000, 0, 10000, Absolute);
InitValuatorAxisStruct(device, 1, axes_labels[1],
0, 0xFFFF, 10000, 0, 10000, Absolute);
+ InitValuatorAxisStruct(device, 2, axes_labels[2],
+ NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
+ InitValuatorAxisStruct(device, 3, axes_labels[3],
+ NO_AXIS_LIMITS, NO_AXIS_LIMITS, 0, 0, 0, Relative);
+
+ SetScrollValuator(device, 2, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE);
+ SetScrollValuator(device, 3, SCROLL_TYPE_VERTICAL, 1.0, SCROLL_FLAG_PREFERRED);
if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control))
return BadValue;
@@ -259,54 +268,24 @@ pointer_handle_axis(void *data, struct wl_pointer *pointer,
uint32_t time, uint32_t axis, wl_fixed_t value)
{
struct xwl_seat *xwl_seat = data;
- int index, count;
- int i, val;
+ int index;
const int divisor = 10;
ValuatorMask mask;
- if (time - xwl_seat->scroll_time > 2000) {
- xwl_seat->vertical_scroll = 0;
- xwl_seat->horizontal_scroll = 0;
- }
- xwl_seat->scroll_time = time;
-
- /* FIXME: Need to do proper smooth scrolling here! */
switch (axis) {
case WL_POINTER_AXIS_VERTICAL_SCROLL:
- xwl_seat->vertical_scroll += value / divisor;
- val = wl_fixed_to_int(xwl_seat->vertical_scroll);
- xwl_seat->vertical_scroll -= wl_fixed_from_int(val);
-
- if (val <= -1)
- index = 4;
- else if (val >= 1)
- index = 5;
- else
- return;
+ index = 3;
break;
case WL_POINTER_AXIS_HORIZONTAL_SCROLL:
- xwl_seat->horizontal_scroll += value / divisor;
- val = wl_fixed_to_int(xwl_seat->horizontal_scroll);
- xwl_seat->horizontal_scroll -= wl_fixed_from_int(val);
-
- if (val <= -1)
- index = 6;
- else if (val >= 1)
- index = 7;
- else
- return;
+ index = 2;
break;
default:
return;
}
valuator_mask_zero(&mask);
-
- count = abs(val);
- for (i = 0; i < count; i++) {
- QueuePointerEvents(xwl_seat->pointer, ButtonPress, index, 0, &mask);
- QueuePointerEvents(xwl_seat->pointer, ButtonRelease, index, 0, &mask);
- }
+ valuator_mask_set_double(&mask, index, wl_fixed_to_double(value) / divisor);
+ QueuePointerEvents(xwl_seat->pointer, MotionNotify, 0, POINTER_RELATIVE, &mask);
}
static const struct wl_pointer_listener pointer_listener = {
@@ -561,7 +540,7 @@ create_input_device(struct xwl_screen *xwl_screen, uint32_t id)
xwl_seat = calloc(sizeof *xwl_seat, 1);
if (xwl_seat == NULL) {
- ErrorF("create_input ENOMEM");
+ ErrorF("create_input ENOMEM\n");
return;
}
diff --git a/xorg-server/hw/xwayland/xwayland-output.c b/xorg-server/hw/xwayland/xwayland-output.c
index 778914c61..155cbc109 100644
--- a/xorg-server/hw/xwayland/xwayland-output.c
+++ b/xorg-server/hw/xwayland/xwayland-output.c
@@ -159,7 +159,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
xwl_output = calloc(sizeof *xwl_output, 1);
if (xwl_output == NULL) {
- ErrorF("create_output ENOMEM");
+ ErrorF("create_output ENOMEM\n");
return NULL;
}
@@ -168,7 +168,7 @@ xwl_output_create(struct xwl_screen *xwl_screen, uint32_t id)
wl_output_add_listener(xwl_output->output, &output_listener, xwl_output);
if (snprintf(name, sizeof name, "XWAYLAND%d", serial++) < 0) {
- ErrorF("create_output ENOMEM");
+ ErrorF("create_output ENOMEM\n");
free(xwl_output);
return NULL;
}
diff --git a/xorg-server/hw/xwayland/xwayland.h b/xorg-server/hw/xwayland/xwayland.h
index bfffa712f..cfb343d36 100644
--- a/xorg-server/hw/xwayland/xwayland.h
+++ b/xorg-server/hw/xwayland/xwayland.h
@@ -122,10 +122,6 @@ struct xwl_seat {
struct xorg_list link;
CursorPtr x_cursor;
- wl_fixed_t horizontal_scroll;
- wl_fixed_t vertical_scroll;
- uint32_t scroll_time;
-
size_t keymap_size;
char *keymap;
struct wl_surface *keyboard_focus;
diff --git a/xorg-server/hw/xwin/winclipboard/Makefile.am b/xorg-server/hw/xwin/winclipboard/Makefile.am
index b1c95f4ef..a1079aec6 100644
--- a/xorg-server/hw/xwin/winclipboard/Makefile.am
+++ b/xorg-server/hw/xwin/winclipboard/Makefile.am
@@ -19,7 +19,7 @@ xwinclip_SOURCES = xwinclip.c debug.c
xwinclip_CFLAGS = $(XWINMODULES_CFLAGS)
-xwinclip_LDADD = libXWinclipboard.la $(XWINMODULES_LIBS) -lgdi32
+xwinclip_LDADD = libXWinclipboard.la $(XWINMODULES_LIBS) -lgdi32 -lpthread
include $(top_srcdir)/manpages.am
appman_PRE = xwinclip.man
diff --git a/xorg-server/include/dix-config.h.in b/xorg-server/include/dix-config.h.in
index 1aa77a5eb..76f45f535 100644
--- a/xorg-server/include/dix-config.h.in
+++ b/xorg-server/include/dix-config.h.in
@@ -149,6 +149,9 @@
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H
+/* Define to 1 if you have the `reallocarray' function. */
+#undef HAVE_REALLOCARRAY
+
/* Define to 1 if you have the <rpcsvc/dbm.h> header file. */
#undef HAVE_RPCSVC_DBM_H
@@ -388,9 +391,15 @@
/* Vendor name */
#undef XVENDORNAME
+/* Number of bits in a file offset, on hosts where this is settable. */
+#undef _FILE_OFFSET_BITS
+
/* Enable GNU and other extensions to the C environment for GLIBC */
#undef _GNU_SOURCE
+/* Define for large files, on AIX-style hosts. */
+#undef _LARGE_FILES
+
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
@@ -454,9 +463,6 @@
/* Define to __typeof__ if your compiler spells it that way. */
#undef typeof
-/* The compiler supported TLS storage class, prefering initial-exec if tls_model is supported */
-#undef TLS
-
/* Correctly set _XSERVER64 for OSX fat binaries */
#ifdef __APPLE__
#include "dix-config-apple-verbatim.h"
diff --git a/xorg-server/include/os.h b/xorg-server/include/os.h
index 3e68c4933..6638c8443 100644
--- a/xorg-server/include/os.h
+++ b/xorg-server/include/os.h
@@ -69,11 +69,15 @@ typedef struct _NewClientRec *NewClientPtr;
#ifndef xnfalloc
#define xnfalloc(size) XNFalloc((unsigned long)(size))
-#define xnfcalloc(_num, _size) XNFcalloc((unsigned long)(_num)*(unsigned long)(_size))
+#define xnfcalloc(_num, _size) XNFcallocarray((_num), (_size))
#define xnfrealloc(ptr, size) XNFrealloc((void *)(ptr), (unsigned long)(size))
#define xstrdup(s) Xstrdup(s)
#define xnfstrdup(s) XNFstrdup(s)
+
+#define xallocarray(num, size) reallocarray(NULL, (num), (size))
+#define xnfallocarray(num, size) XNFreallocarray(NULL, (num), (size))
+#define xnfreallocarray(ptr, num, size) XNFreallocarray((ptr), (num), (size))
#endif
#include <stdio.h>
@@ -222,7 +226,14 @@ XNFalloc(unsigned long /*amount */ );
* enough memory.
*/
extern _X_EXPORT void *
-XNFcalloc(unsigned long /*amount */ );
+XNFcalloc(unsigned long /*amount */ ) _X_DEPRECATED;
+
+/*
+ * This function calloc(3)s buffer, terminating the server if there is not
+ * enough memory or the arguments overflow when multiplied
+ */
+extern _X_EXPORT void *
+XNFcallocarray(size_t nmemb, size_t size);
/*
* This function realloc(3)s passed buffer, terminating the server if there is
@@ -232,6 +243,13 @@ extern _X_EXPORT void *
XNFrealloc(void * /*ptr */ , unsigned long /*amount */ );
/*
+ * This function reallocarray(3)s passed buffer, terminating the server if
+ * there is not enough memory or the arguments overflow when multiplied.
+ */
+extern _X_EXPORT void *
+XNFreallocarray(void *ptr, size_t nmemb, size_t size);
+
+/*
* This function strdup(3)s passed string. The only difference from the library
* function that it is safe to pass NULL, as NULL will be returned.
*/
@@ -510,7 +528,14 @@ ddxGiveUp(enum ExitCode error);
extern _X_EXPORT int
TimeSinceLastInputEvent(void);
-/* strcasecmp.c */
+/* Function fallbacks provided by AC_REPLACE_FUNCS in configure.ac */
+
+#ifndef HAVE_REALLOCARRAY
+#define reallocarray xreallocarray
+extern _X_EXPORT void *
+reallocarray(void *optr, size_t nmemb, size_t size);
+#endif
+
#ifndef HAVE_STRCASECMP
#define strcasecmp xstrcasecmp
extern _X_EXPORT int
diff --git a/xorg-server/include/servermd.h b/xorg-server/include/servermd.h
index a3b5c3af3..087826f48 100644
--- a/xorg-server/include/servermd.h
+++ b/xorg-server/include/servermd.h
@@ -52,6 +52,8 @@ SOFTWARE.
#error xserver code must include dix-config.h before any other headers
#endif
+#include <X11/Xarch.h> /* for X_LITTLE_ENDIAN/X_BIG_ENDIAN */
+
#if X_BYTE_ORDER == X_LITTLE_ENDIAN
#define IMAGE_BYTE_ORDER LSBFirst
#define BITMAP_BIT_ORDER LSBFirst
diff --git a/xorg-server/include/xorg-server.h.in b/xorg-server/include/xorg-server.h.in
index 4cb94875c..3152dbd68 100644
--- a/xorg-server/include/xorg-server.h.in
+++ b/xorg-server/include/xorg-server.h.in
@@ -47,6 +47,9 @@
/* Define to 1 if you have the `ffs' function. */
#undef HAVE_FFS
+/* Define to 1 if you have the `reallocarray' function. */
+#undef HAVE_REALLOCARRAY
+
/* Define to 1 if you have the `strcasecmp' function. */
#undef HAVE_STRCASECMP
diff --git a/xorg-server/m4/xorg-tls.m4 b/xorg-server/m4/xorg-tls.m4
deleted file mode 100644
index 57687758f..000000000
--- a/xorg-server/m4/xorg-tls.m4
+++ /dev/null
@@ -1,55 +0,0 @@
-dnl Copyright © 2011 Apple Inc.
-dnl
-dnl Permission is hereby granted, free of charge, to any person obtaining a
-dnl copy of this software and associated documentation files (the "Software"),
-dnl to deal in the Software without restriction, including without limitation
-dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
-dnl and/or sell copies of the Software, and to permit persons to whom the
-dnl Software is furnished to do so, subject to the following conditions:
-dnl
-dnl The above copyright notice and this permission notice (including the next
-dnl paragraph) shall be included in all copies or substantial portions of the
-dnl Software.
-dnl
-dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-dnl DEALINGS IN THE SOFTWARE.
-dnl
-dnl Authors: Jeremy Huddleston <jeremyhu@apple.com>
-
-AC_DEFUN([XORG_TLS], [
- AC_REQUIRE([XORG_STRICT_OPTION])
- AC_MSG_CHECKING(for thread local storage (TLS) support)
- AC_CACHE_VAL(ac_cv_tls, [
- ac_cv_tls=none
- keywords="__thread __declspec(thread)"
- for kw in $keywords ; do
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int $kw test;]], [])], ac_cv_tls=$kw ; break ;)
- done
- ])
- AC_MSG_RESULT($ac_cv_tls)
-
- if test "$ac_cv_tls" != "none"; then
- AC_MSG_CHECKING(for tls_model attribute support)
- AC_CACHE_VAL(ac_cv_tls_model, [
- save_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $STRICT_CFLAGS"
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[int $ac_cv_tls __attribute__((tls_model("initial-exec"))) test;]], [])],
- ac_cv_tls_model=yes, ac_cv_tls_model=no)
- CFLAGS="$save_CFLAGS"
- ])
- AC_MSG_RESULT($ac_cv_tls_model)
-
- if test "x$ac_cv_tls_model" = "xyes" ; then
- xorg_tls=$ac_cv_tls' __attribute__((tls_model("initial-exec")))'
- else
- xorg_tls=$ac_cv_tls
- fi
-
- AC_DEFINE_UNQUOTED([TLS], $xorg_tls, [The compiler supported TLS storage class, prefering initial-exec if tls_model is supported])
- fi
-])
diff --git a/xorg-server/mi/miarc.c b/xorg-server/mi/miarc.c
index e8bc87e3e..5e854b329 100644
--- a/xorg-server/mi/miarc.c
+++ b/xorg-server/mi/miarc.c
@@ -1187,9 +1187,9 @@ miFillSppPoly(DrawablePtr dst, GCPtr pgc, int count, /* number of points */
y = ymax - ymin + 1;
if ((count < 3) || (y <= 0))
return;
- ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * y);
- width = FirstWidth = malloc(sizeof(int) * y);
- Marked = malloc(sizeof(int) * count);
+ ptsOut = FirstPoint = xallocarray(y, sizeof(DDXPointRec));
+ width = FirstWidth = xallocarray(y, sizeof(int));
+ Marked = xallocarray(count, sizeof(int));
if (!ptsOut || !width || !Marked) {
free(Marked);
@@ -1679,8 +1679,7 @@ miGetArcPts(SppArcPtr parc, /* points to an arc */
count++;
cdt = 2 * miDcos(dt);
- if (!(poly = (SppPointPtr) realloc((void *) *ppPts,
- (cpt + count) * sizeof(SppPointRec))))
+ if (!(poly = reallocarray(*ppPts, cpt + count, sizeof(SppPointRec))))
return 0;
*ppPts = poly;
@@ -1737,7 +1736,7 @@ addCap(miArcCapPtr * capsp, int *ncapsp, int *sizep, int end, int arcIndex)
if (*ncapsp == *sizep) {
newsize = *sizep + ADD_REALLOC_STEP;
- cap = (miArcCapPtr) realloc(*capsp, newsize * sizeof(**capsp));
+ cap = reallocarray(*capsp, newsize, sizeof(**capsp));
if (!cap)
return;
*sizep = newsize;
@@ -1760,7 +1759,7 @@ addJoin(miArcJoinPtr * joinsp,
if (*njoinsp == *sizep) {
newsize = *sizep + ADD_REALLOC_STEP;
- join = (miArcJoinPtr) realloc(*joinsp, newsize * sizeof(**joinsp));
+ join = reallocarray(*joinsp, newsize, sizeof(**joinsp));
if (!join)
return;
*sizep = newsize;
@@ -1784,7 +1783,7 @@ addArc(miArcDataPtr * arcsp, int *narcsp, int *sizep, xArc * xarc)
if (*narcsp == *sizep) {
newsize = *sizep + ADD_REALLOC_STEP;
- arc = (miArcDataPtr) realloc(*arcsp, newsize * sizeof(**arcsp));
+ arc = reallocarray(*arcsp, newsize, sizeof(**arcsp));
if (!arc)
return NULL;
*sizep = newsize;
@@ -1890,10 +1889,10 @@ miComputeArcs(xArc * parcs, int narcs, GCPtr pGC)
isDoubleDash = (pGC->lineStyle == LineDoubleDash);
dashOffset = pGC->dashOffset;
- data = malloc(narcs * sizeof(struct arcData));
+ data = xallocarray(narcs, sizeof(struct arcData));
if (!data)
return NULL;
- arcs = malloc(sizeof(*arcs) * (isDoubleDash ? 2 : 1));
+ arcs = xallocarray(isDoubleDash ? 2 : 1, sizeof(*arcs));
if (!arcs) {
free(data);
return NULL;
@@ -3081,8 +3080,8 @@ fillSpans(DrawablePtr pDrawable, GCPtr pGC)
if (nspans == 0)
return;
- xSpan = xSpans = malloc(nspans * sizeof(DDXPointRec));
- xWidth = xWidths = malloc(nspans * sizeof(int));
+ xSpan = xSpans = xallocarray(nspans, sizeof(DDXPointRec));
+ xWidth = xWidths = xallocarray(nspans, sizeof(int));
if (xSpans && xWidths) {
i = 0;
f = finalSpans;
@@ -3136,7 +3135,7 @@ realFindSpan(int y)
else
change = SPAN_REALLOC;
newSize = finalSize + change;
- newSpans = malloc(newSize * sizeof(struct finalSpan *));
+ newSpans = xallocarray(newSize, sizeof(struct finalSpan *));
if (!newSpans)
return NULL;
newMiny = finalMiny;
diff --git a/xorg-server/mi/mibitblt.c b/xorg-server/mi/mibitblt.c
index 724396333..28296a449 100644
--- a/xorg-server/mi/mibitblt.c
+++ b/xorg-server/mi/mibitblt.c
@@ -136,11 +136,11 @@ miCopyArea(DrawablePtr pSrcDrawable,
dsty += pDstDrawable->y;
}
- pptFirst = ppt = malloc(heightSrc * sizeof(DDXPointRec));
- pwidthFirst = pwidth = malloc(heightSrc * sizeof(unsigned int));
+ pptFirst = ppt = xallocarray(heightSrc, sizeof(DDXPointRec));
+ pwidthFirst = pwidth = xallocarray(heightSrc, sizeof(unsigned int));
numRects = RegionNumRects(prgnSrcClip);
boxes = RegionRects(prgnSrcClip);
- ordering = malloc(numRects * sizeof(unsigned int));
+ ordering = xallocarray(numRects, sizeof(unsigned int));
if (!pptFirst || !pwidthFirst || !ordering) {
free(ordering);
free(pwidthFirst);
@@ -221,7 +221,7 @@ miCopyArea(DrawablePtr pSrcDrawable,
ppt++->y = y++;
*pwidth++ = width;
}
- pbits = malloc(height * PixmapBytePad(width, pSrcDrawable->depth));
+ pbits = xallocarray(height, PixmapBytePad(width, pSrcDrawable->depth));
if (pbits) {
(*pSrcDrawable->pScreen->GetSpans) (pSrcDrawable, width, pptFirst,
(int *) pwidthFirst, height,
@@ -398,8 +398,8 @@ miOpqStipDrawable(DrawablePtr pDraw, GCPtr pGC, RegionPtr prgnSrc,
ChangeGC(NullClient, pGCT, GCBackground, gcv);
ValidateGC((DrawablePtr) pPixmap, pGCT);
miClearDrawable((DrawablePtr) pPixmap, pGCT);
- ppt = pptFirst = malloc(h * sizeof(DDXPointRec));
- pwidth = pwidthFirst = malloc(h * sizeof(int));
+ ppt = pptFirst = xallocarray(h, sizeof(DDXPointRec));
+ pwidth = pwidthFirst = xallocarray(h, sizeof(int));
if (!pptFirst || !pwidthFirst) {
free(pwidthFirst);
free(pptFirst);
@@ -746,8 +746,8 @@ miPutImage(DrawablePtr pDraw, GCPtr pGC, int depth,
break;
case ZPixmap:
- ppt = pptFirst = malloc(h * sizeof(DDXPointRec));
- pwidth = pwidthFirst = malloc(h * sizeof(int));
+ ppt = pptFirst = xallocarray(h, sizeof(DDXPointRec));
+ pwidth = pwidthFirst = xallocarray(h, sizeof(int));
if (!pptFirst || !pwidthFirst) {
free(pwidthFirst);
free(pptFirst);
diff --git a/xorg-server/mi/micmap.c b/xorg-server/mi/micmap.c
index 1aeb359ba..5743adb19 100644
--- a/xorg-server/mi/micmap.c
+++ b/xorg-server/mi/micmap.c
@@ -458,9 +458,9 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
ndepth++;
nvisual += visuals->count;
}
- depth = malloc(ndepth * sizeof(DepthRec));
- visual = malloc(nvisual * sizeof(VisualRec));
- preferredCVCs = malloc(ndepth * sizeof(int));
+ depth = xallocarray(ndepth, sizeof(DepthRec));
+ visual = xallocarray(nvisual, sizeof(VisualRec));
+ preferredCVCs = xallocarray(ndepth, sizeof(int));
if (!depth || !visual || !preferredCVCs) {
free(depth);
free(visual);
@@ -481,7 +481,7 @@ miInitVisuals(VisualPtr * visualp, DepthPtr * depthp, int *nvisualp,
prefp++;
vid = NULL;
if (nvtype) {
- vid = malloc(nvtype * sizeof(VisualID));
+ vid = xallocarray(nvtype, sizeof(VisualID));
if (!vid) {
free(depth);
free(visual);
diff --git a/xorg-server/mi/micopy.c b/xorg-server/mi/micopy.c
index 2409c7880..12cdad4ad 100644
--- a/xorg-server/mi/micopy.c
+++ b/xorg-server/mi/micopy.c
@@ -62,7 +62,7 @@ miCopyRegion(DrawablePtr pSrcDrawable,
if (nbox > 1) {
/* keep ordering in each band, reverse order of bands */
- pboxNew1 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
+ pboxNew1 = xallocarray(nbox, sizeof(BoxRec));
if (!pboxNew1)
return;
pboxBase = pboxNext = pbox + nbox - 1;
@@ -93,7 +93,7 @@ miCopyRegion(DrawablePtr pSrcDrawable,
if (nbox > 1) {
/* reverse order of rects in each band */
- pboxNew2 = (BoxPtr) malloc(sizeof(BoxRec) * nbox);
+ pboxNew2 = xallocarray(nbox, sizeof(BoxRec));
if (!pboxNew2) {
free(pboxNew1);
return;
diff --git a/xorg-server/mi/miexpose.c b/xorg-server/mi/miexpose.c
index fc4dbc071..c4118f16a 100644
--- a/xorg-server/mi/miexpose.c
+++ b/xorg-server/mi/miexpose.c
@@ -535,7 +535,7 @@ miPaintWindow(WindowPtr pWin, RegionPtr prgn, int what)
gcmask |= GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin;
}
- prect = malloc(RegionNumRects(prgn) * sizeof(xRectangle));
+ prect = xallocarray(RegionNumRects(prgn), sizeof(xRectangle));
if (!prect)
return;
diff --git a/xorg-server/mi/mifillrct.c b/xorg-server/mi/mifillrct.c
index 28f2322e6..eb98a779e 100644
--- a/xorg-server/mi/mifillrct.c
+++ b/xorg-server/mi/mifillrct.c
@@ -100,8 +100,8 @@ miPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, /* number of rec
maxheight = max(maxheight, prect->height);
}
- pptFirst = malloc(maxheight * sizeof(DDXPointRec));
- pwFirst = malloc(maxheight * sizeof(int));
+ pptFirst = xallocarray(maxheight, sizeof(DDXPointRec));
+ pwFirst = xallocarray(maxheight, sizeof(int));
if (!pptFirst || !pwFirst) {
free(pwFirst);
free(pptFirst);
diff --git a/xorg-server/mi/miglblt.c b/xorg-server/mi/miglblt.c
index 0183e998b..e9d3a1af0 100644
--- a/xorg-server/mi/miglblt.c
+++ b/xorg-server/mi/miglblt.c
@@ -131,7 +131,7 @@ miPolyGlyphBlt(DrawablePtr pDrawable, GC * pGC, int x, int y, unsigned int nglyp
gcvals);
nbyLine = BitmapBytePad(width);
- pbits = malloc(height * nbyLine);
+ pbits = xallocarray(height, nbyLine);
if (!pbits) {
(*pDrawable->pScreen->DestroyPixmap) (pPixmap);
FreeScratchGC(pGCtmp);
diff --git a/xorg-server/mi/miinitext.c b/xorg-server/mi/miinitext.c
index 086d2c3fb..5fc44e3f4 100644
--- a/xorg-server/mi/miinitext.c
+++ b/xorg-server/mi/miinitext.c
@@ -352,8 +352,8 @@ NewExtensionModuleList(int size)
numExtensionModules = 0;
n = numExtensionModules + size;
- ExtensionModuleList = realloc(ExtensionModuleList,
- n * sizeof(ExtensionModule));
+ ExtensionModuleList = reallocarray(ExtensionModuleList, n,
+ sizeof(ExtensionModule));
if (ExtensionModuleList == NULL) {
ExtensionModuleList = save;
return NULL;
diff --git a/xorg-server/mi/mipoly.c b/xorg-server/mi/mipoly.c
index a332376d1..a97e2bb64 100644
--- a/xorg-server/mi/mipoly.c
+++ b/xorg-server/mi/mipoly.c
@@ -412,8 +412,8 @@ miFillConvexPoly(DrawablePtr dst, GCPtr pgc, int count, DDXPointPtr ptsIn)
dy = ymax - ymin + 1;
if ((count < 3) || (dy < 0))
return TRUE;
- ptsOut = FirstPoint = malloc(sizeof(DDXPointRec) * dy);
- width = FirstWidth = malloc(sizeof(int) * dy);
+ ptsOut = FirstPoint = xallocarray(dy, sizeof(DDXPointRec));
+ width = FirstWidth = xallocarray(dy, sizeof(int));
if (!FirstPoint || !FirstWidth) {
free(FirstWidth);
free(FirstPoint);
diff --git a/xorg-server/mi/mipolypnt.c b/xorg-server/mi/mipolypnt.c
index 4fa521d07..1c4150dfb 100644
--- a/xorg-server/mi/mipolypnt.c
+++ b/xorg-server/mi/mipolypnt.c
@@ -67,7 +67,7 @@ miPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, /* Origin or Previous */
int i;
xPoint *ppt;
- if (!(pwidthInit = malloc(npt * sizeof(int))))
+ if (!(pwidthInit = xallocarray(npt, sizeof(int))))
return;
/* make pointlist origin relative */
diff --git a/xorg-server/mi/mipolyrect.c b/xorg-server/mi/mipolyrect.c
index 830822513..7ebf9db8d 100644
--- a/xorg-server/mi/mipolyrect.c
+++ b/xorg-server/mi/mipolyrect.c
@@ -88,7 +88,7 @@ miPolyRectangle(DrawablePtr pDraw, GCPtr pGC, int nrects, xRectangle *pRects)
offset2 = pGC->lineWidth;
offset1 = offset2 >> 1;
offset3 = offset2 - offset1;
- tmp = malloc(ntmp * sizeof(xRectangle));
+ tmp = xallocarray(ntmp, sizeof(xRectangle));
if (!tmp)
return;
t = tmp;
diff --git a/xorg-server/mi/miwideline.c b/xorg-server/mi/miwideline.c
index 452d74fc1..3baa99bfb 100644
--- a/xorg-server/mi/miwideline.c
+++ b/xorg-server/mi/miwideline.c
@@ -189,19 +189,16 @@ miSubtractSpans(SpanGroup * spanGroup, Spans * sub)
int *newwid;
#define EXTRA 8
- newPt =
- (DDXPointPtr) realloc(spans->points,
- (spans->count +
- EXTRA) *
- sizeof(DDXPointRec));
+ newPt = reallocarray(spans->points,
+ spans->count + EXTRA,
+ sizeof(DDXPointRec));
if (!newPt)
break;
spansPt = newPt + (spansPt - spans->points);
spans->points = newPt;
- newwid =
- (int *) realloc(spans->widths,
- (spans->count +
- EXTRA) * sizeof(int));
+ newwid = reallocarray(spans->widths,
+ spans->count + EXTRA,
+ sizeof(int));
if (!newwid)
break;
spansWid = newwid + (spansWid - spans->widths);
@@ -240,8 +237,8 @@ miAppendSpans(SpanGroup * spanGroup, SpanGroup * otherGroup, Spans * spans)
if (spansCount > 0) {
if (spanGroup->size == spanGroup->count) {
spanGroup->size = (spanGroup->size + 8) * 2;
- spanGroup->group = (Spans *)
- realloc(spanGroup->group, sizeof(Spans) * spanGroup->size);
+ spanGroup->group =
+ reallocarray(spanGroup->group, sizeof(Spans), spanGroup->size);
}
spanGroup->group[spanGroup->count] = *spans;
@@ -456,8 +453,8 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
ylength = spanGroup->ymax - ymin + 1;
/* Allocate Spans for y buckets */
- yspans = malloc(ylength * sizeof(Spans));
- ysizes = malloc(ylength * sizeof(int));
+ yspans = xallocarray(ylength, sizeof(Spans));
+ ysizes = xallocarray(ylength, sizeof(int));
if (!yspans || !ysizes) {
free(yspans);
@@ -491,12 +488,11 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
int *newwidths;
ysizes[index] = (ysizes[index] + 8) * 2;
- newpoints = (DDXPointPtr) realloc(newspans->points,
- ysizes[index] *
- sizeof(DDXPointRec));
- newwidths =
- (int *) realloc(newspans->widths,
- ysizes[index] * sizeof(int));
+ newpoints = reallocarray(newspans->points,
+ ysizes[index],
+ sizeof(DDXPointRec));
+ newwidths = reallocarray(newspans->widths,
+ ysizes[index], sizeof(int));
if (!newpoints || !newwidths) {
for (i = 0; i < ylength; i++) {
free(yspans[i].points);
@@ -525,8 +521,8 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
} /* for i thorough Spans */
/* Now sort by x and uniquify each bucket into the final array */
- points = malloc(count * sizeof(DDXPointRec));
- widths = malloc(count * sizeof(int));
+ points = xallocarray(count, sizeof(DDXPointRec));
+ widths = xallocarray(count, sizeof(int));
if (!points || !widths) {
for (i = 0; i < ylength; i++) {
free(yspans[i].points);
@@ -573,10 +569,10 @@ miFillUniqueSpanGroup(DrawablePtr pDraw, GCPtr pGC, SpanGroup * spanGroup)
static Bool
InitSpans(Spans * spans, size_t nspans)
{
- spans->points = malloc(nspans * sizeof(*spans->points));
+ spans->points = xallocarray(nspans, sizeof(*spans->points));
if (!spans->points)
return FALSE;
- spans->widths = malloc(nspans * sizeof(*spans->widths));
+ spans->widths = xallocarray(nspans, sizeof(*spans->widths));
if (!spans->widths) {
free(spans->points);
return FALSE;
diff --git a/xorg-server/mi/miwindow.c b/xorg-server/mi/miwindow.c
index a1af3a770..7574239f5 100644
--- a/xorg-server/mi/miwindow.c
+++ b/xorg-server/mi/miwindow.c
@@ -777,9 +777,9 @@ miSpriteTrace(SpritePtr pSprite, int x, int y)
) {
if (pSprite->spriteTraceGood >= pSprite->spriteTraceSize) {
pSprite->spriteTraceSize += 10;
- pSprite->spriteTrace = realloc(pSprite->spriteTrace,
- pSprite->spriteTraceSize *
- sizeof(WindowPtr));
+ pSprite->spriteTrace = reallocarray(pSprite->spriteTrace,
+ pSprite->spriteTraceSize,
+ sizeof(WindowPtr));
}
pSprite->spriteTrace[pSprite->spriteTraceGood++] = pWin;
pWin = pWin->firstChild;
diff --git a/xorg-server/mi/mizerarc.c b/xorg-server/mi/mizerarc.c
index b216cf43d..e1b5f0c18 100644
--- a/xorg-server/mi/mizerarc.c
+++ b/xorg-server/mi/mizerarc.c
@@ -671,7 +671,7 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
numPts = maxPts << 2;
dospans = (pGC->fillStyle != FillSolid);
if (dospans) {
- widths = malloc(sizeof(int) * numPts);
+ widths = xallocarray(numPts, sizeof(int));
if (!widths)
return;
maxw = 0;
@@ -687,7 +687,7 @@ miZeroPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc * parcs)
(unsigned char *) pGC->dash, (int) pGC->numInDashList,
&dinfo.dashOffsetInit);
}
- points = malloc(sizeof(DDXPointRec) * numPts);
+ points = xallocarray(numPts, sizeof(DDXPointRec));
if (!points) {
if (dospans) {
free(widths);
diff --git a/xorg-server/mi/mizerline.c b/xorg-server/mi/mizerline.c
index 5a2447014..2f22d2309 100644
--- a/xorg-server/mi/mizerline.c
+++ b/xorg-server/mi/mizerline.c
@@ -150,8 +150,8 @@ miZeroLine(DrawablePtr pDraw, GCPtr pGC, int mode, /* Origin or Previous */
width = xright - xleft + 1;
height = ybottom - ytop + 1;
list_len = (height >= width) ? height : width;
- pspanInit = malloc(list_len * sizeof(DDXPointRec));
- pwidthInit = malloc(list_len * sizeof(int));
+ pspanInit = xallocarray(list_len, sizeof(DDXPointRec));
+ pwidthInit = xallocarray(list_len, sizeof(int));
if (!pspanInit || !pwidthInit) {
free(pspanInit);
free(pwidthInit);
diff --git a/xorg-server/miext/damage/damage.c b/xorg-server/miext/damage/damage.c
index 6ef7f9dfc..ce20169d4 100644
--- a/xorg-server/miext/damage/damage.c
+++ b/xorg-server/miext/damage/damage.c
@@ -1293,7 +1293,7 @@ damageText(DrawablePtr pDrawable,
if (!checkGCDamage(pDrawable, pGC))
return;
- charinfo = malloc(count * sizeof(CharInfoPtr));
+ charinfo = xallocarray(count, sizeof(CharInfoPtr));
if (!charinfo)
return;
diff --git a/xorg-server/miext/rootless/rootlessWindow.c b/xorg-server/miext/rootless/rootlessWindow.c
index a8f296a39..1f78e3f6c 100644
--- a/xorg-server/miext/rootless/rootlessWindow.c
+++ b/xorg-server/miext/rootless/rootlessWindow.c
@@ -949,7 +949,7 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
copy_rect_width = copy_rect.x2 - copy_rect.x1;
copy_rect_height = copy_rect.y2 - copy_rect.y1;
copy_rowbytes = ((copy_rect_width * Bpp) + 31) & ~31;
- gResizeDeathBits = malloc(copy_rowbytes * copy_rect_height);
+ gResizeDeathBits = xallocarray(copy_rowbytes, copy_rect_height);
if (copy_rect_width * copy_rect_height >
rootless_CopyBytes_threshold &&
@@ -998,7 +998,7 @@ StartFrameResize(WindowPtr pWin, Bool gravity,
RootlessStartDrawing(pWin);
- gResizeDeathBits = malloc(winRec->bytesPerRow * winRec->height);
+ gResizeDeathBits = xallocarray(winRec->bytesPerRow, winRec->height);
memcpy(gResizeDeathBits, winRec->pixelData,
winRec->bytesPerRow * winRec->height);
diff --git a/xorg-server/miext/shadow/shalloc.c b/xorg-server/miext/shadow/shalloc.c
index e555135b9..6a79085c4 100644
--- a/xorg-server/miext/shadow/shalloc.c
+++ b/xorg-server/miext/shadow/shalloc.c
@@ -44,6 +44,6 @@ shadowAlloc(int width, int height, int bpp)
/* Cant use PixmapBytePad -- the structure is probably not initialized yet */
stride = BitmapBytePad(width * bpp);
- fb = malloc(stride * height);
+ fb = xallocarray(stride, height);
return fb;
}
diff --git a/xorg-server/os/connection.c b/xorg-server/os/connection.c
index 7ff44e175..c36b125fe 100644
--- a/xorg-server/os/connection.c
+++ b/xorg-server/os/connection.c
@@ -309,7 +309,7 @@ InitConnectionLimits(void)
#if !defined(WIN32)
if (!ConnectionTranslation)
- ConnectionTranslation = (int *) xnfalloc(sizeof(int) * (lastfdesc + 1));
+ ConnectionTranslation = xnfallocarray(lastfdesc + 1, sizeof(int));
#else
InitConnectionTranslation();
#endif
@@ -429,7 +429,9 @@ CreateWellKnownSockets(void)
display = dynamic_display;
}
- ListenTransFds = malloc(ListenTransCount * sizeof (int));
+ ListenTransFds = xallocarray(ListenTransCount, sizeof (int));
+ if (ListenTransFds == NULL)
+ FatalError ("Failed to create listening socket array");
for (i = 0; i < ListenTransCount; i++) {
int fd = _XSERVTransGetConnectionNumber(ListenTransConns[i]);
@@ -1291,11 +1293,10 @@ ListenOnOpenFD(int fd, int noxauth)
/* Allocate space to store it */
ListenTransFds =
- (int *) realloc(ListenTransFds, (ListenTransCount + 1) * sizeof(int));
+ xnfreallocarray(ListenTransFds, ListenTransCount + 1, sizeof(int));
ListenTransConns =
- (XtransConnInfo *) realloc(ListenTransConns,
- (ListenTransCount +
- 1) * sizeof(XtransConnInfo));
+ xnfreallocarray(ListenTransConns, ListenTransCount + 1,
+ sizeof(XtransConnInfo));
/* Store it */
ListenTransConns[ListenTransCount] = ciptr;
diff --git a/xorg-server/os/reallocarray.c b/xorg-server/os/reallocarray.c
new file mode 100644
index 000000000..c415e09af
--- /dev/null
+++ b/xorg-server/os/reallocarray.c
@@ -0,0 +1,43 @@
+/* $OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $ */
+/*
+ * Copyright (c) 2008 Otto Moerbeek <otto@drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <sys/types.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "os.h"
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4))
+
+void *
+reallocarray(void *optr, size_t nmemb, size_t size)
+{
+ if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+ nmemb > 0 && SIZE_MAX / nmemb < size) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc(optr, size * nmemb);
+}
diff --git a/xorg-server/os/utils.c b/xorg-server/os/utils.c
index 75769f17c..7fd395b2a 100644
--- a/xorg-server/os/utils.c
+++ b/xorg-server/os/utils.c
@@ -1128,10 +1128,20 @@ XNFalloc(unsigned long amount)
return ptr;
}
+/* The original XNFcalloc was used with the xnfcalloc macro which multiplied
+ * the arguments at the call site without allowing calloc to check for overflow.
+ * XNFcallocarray was added to fix that without breaking ABI.
+ */
void *
XNFcalloc(unsigned long amount)
{
- void *ret = calloc(1, amount);
+ return XNFcallocarray(1, amount);
+}
+
+void *
+XNFcallocarray(size_t nmemb, size_t size)
+{
+ void *ret = calloc(nmemb, size);
if (!ret)
FatalError("XNFcalloc: Out of memory");
@@ -1148,6 +1158,16 @@ XNFrealloc(void *ptr, unsigned long amount)
return ret;
}
+void *
+XNFreallocarray(void *ptr, size_t nmemb, size_t size)
+{
+ void *ret = reallocarray(ptr, nmemb, size);
+
+ if (!ret)
+ FatalError("XNFreallocarray: Out of memory");
+ return ret;
+}
+
char *
Xstrdup(const char *s)
{
@@ -1640,7 +1660,7 @@ Fclose(void *iop)
#include <X11/Xwindows.h>
const char *
-Win32TempDir()
+Win32TempDir(void)
{
static char buffer[PATH_MAX];
@@ -1981,7 +2001,7 @@ xstrtokenize(const char *str, const char *separators)
if (!tmp)
goto error;
for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
- nlist = realloc(list, (num + 2) * sizeof(*list));
+ nlist = reallocarray(list, num + 2, sizeof(*list));
if (!nlist)
goto error;
list = nlist;
@@ -2091,6 +2111,7 @@ FormatUInt64Hex(uint64_t num, char *string)
string[len] = '\0';
}
+#if !defined(WIN32) || defined(__CYGWIN__)
/* Move a file descriptor out of the way of our select mask; this
* is useful for file descriptors which will never appear in the
* select mask to avoid reducing the number of clients that can
@@ -2114,3 +2135,4 @@ os_move_fd(int fd)
close(fd);
return newfd;
}
+#endif
diff --git a/xorg-server/os/xdmcp.c b/xorg-server/os/xdmcp.c
index bc5a70706..b265db338 100644
--- a/xorg-server/os/xdmcp.c
+++ b/xorg-server/os/xdmcp.c
@@ -19,6 +19,10 @@
#ifdef WIN32
#include <X11/Xwinsock.h>
+#define XSERV_t
+#define TRANS_SERVER
+#define TRANS_REOPEN
+#include <X11/Xtrans/Xtrans.h>
#endif
#include <X11/Xos.h>
diff --git a/xorg-server/pseudoramiX/pseudoramiX.c b/xorg-server/pseudoramiX/pseudoramiX.c
index e59ca1312..d8b259341 100644
--- a/xorg-server/pseudoramiX/pseudoramiX.c
+++ b/xorg-server/pseudoramiX/pseudoramiX.c
@@ -140,9 +140,9 @@ PseudoramiXAddScreen(int x, int y, int w, int h)
if (pseudoramiXNumScreens == pseudoramiXScreensAllocated) {
pseudoramiXScreensAllocated += pseudoramiXScreensAllocated + 1;
- pseudoramiXScreens = realloc(pseudoramiXScreens,
- pseudoramiXScreensAllocated *
- sizeof(PseudoramiXScreenRec));
+ pseudoramiXScreens = reallocarray(pseudoramiXScreens,
+ pseudoramiXScreensAllocated,
+ sizeof(PseudoramiXScreenRec));
}
DEBUG_LOG("x: %d, y: %d, w: %d, h: %d\n", x, y, w, h);
diff --git a/xorg-server/randr/randrstr.h b/xorg-server/randr/randrstr.h
index 438a52aeb..03974fd4f 100644
--- a/xorg-server/randr/randrstr.h
+++ b/xorg-server/randr/randrstr.h
@@ -1016,6 +1016,15 @@ RRMonitorFreeList(RRMonitorPtr monitors, int nmon);
void
RRMonitorClose(ScreenPtr screen);
+RRMonitorPtr
+RRMonitorAlloc(int noutput);
+
+int
+RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor);
+
+void
+RRMonitorFree(RRMonitorPtr monitor);
+
int
ProcRRGetMonitors(ClientPtr client);
diff --git a/xorg-server/randr/rrcrtc.c b/xorg-server/randr/rrcrtc.c
index 69b3ecf0f..e95b049df 100644
--- a/xorg-server/randr/rrcrtc.c
+++ b/xorg-server/randr/rrcrtc.c
@@ -65,8 +65,8 @@ RRCrtcCreate(ScreenPtr pScreen, void *devPrivate)
/* make space for the crtc pointer */
if (pScrPriv->numCrtcs)
- crtcs = realloc(pScrPriv->crtcs,
- (pScrPriv->numCrtcs + 1) * sizeof(RRCrtcPtr));
+ crtcs = reallocarray(pScrPriv->crtcs,
+ pScrPriv->numCrtcs + 1, sizeof(RRCrtcPtr));
else
crtcs = malloc(sizeof(RRCrtcPtr));
if (!crtcs)
@@ -176,10 +176,10 @@ RRCrtcNotify(RRCrtcPtr crtc,
if (numOutputs) {
if (crtc->numOutputs)
- newoutputs = realloc(crtc->outputs,
- numOutputs * sizeof(RROutputPtr));
+ newoutputs = reallocarray(crtc->outputs,
+ numOutputs, sizeof(RROutputPtr));
else
- newoutputs = malloc(numOutputs * sizeof(RROutputPtr));
+ newoutputs = xallocarray(numOutputs, sizeof(RROutputPtr));
if (!newoutputs)
return FALSE;
}
@@ -394,7 +394,7 @@ rrCreateSharedPixmap(RRCrtcPtr crtc, int width, int height,
Bool ret;
int depth;
PixmapPtr mscreenpix;
- PixmapPtr protopix = crtc->pScreen->current_master->GetScreenPixmap(crtc->pScreen->current_master);
+ PixmapPtr protopix = master->GetScreenPixmap(master);
rrScrPriv(crtc->pScreen);
/* create a pixmap on the master screen,
@@ -428,7 +428,7 @@ rrCreateSharedPixmap(RRCrtcPtr crtc, int width, int height,
ret = pScrPriv->rrCrtcSetScanoutPixmap(crtc, spix);
if (ret == FALSE) {
- ErrorF("failed to set shadow slave pixmap\n");
+ ErrorF("randr: failed to set shadow slave pixmap\n");
return FALSE;
}
@@ -457,18 +457,20 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
/* have to iterate all the crtcs of the attached gpu masters
and all their output slaves */
for (c = 0; c < pScrPriv->numCrtcs; c++) {
- if (pScrPriv->crtcs[c] == rr_crtc) {
+ RRCrtcPtr crtc = pScrPriv->crtcs[c];
+
+ if (crtc == rr_crtc) {
newbox.x1 = x;
newbox.x2 = x + w;
newbox.y1 = y;
newbox.y2 = y + h;
} else {
- if (!pScrPriv->crtcs[c]->mode)
+ if (!crtc->mode)
continue;
- newbox.x1 = pScrPriv->crtcs[c]->x;
- newbox.x2 = pScrPriv->crtcs[c]->x + pScrPriv->crtcs[c]->mode->mode.width;
- newbox.y1 = pScrPriv->crtcs[c]->y;
- newbox.y2 = pScrPriv->crtcs[c]->y + pScrPriv->crtcs[c]->mode->mode.height;
+ newbox.x1 = crtc->x;
+ newbox.x2 = crtc->x + crtc->mode->mode.width;
+ newbox.y1 = crtc->y;
+ newbox.y2 = crtc->y + crtc->mode->mode.height;
}
RegionInit(&new_crtc_region, &newbox, 1);
RegionUnion(&total_region, &total_region, &new_crtc_region);
@@ -477,19 +479,21 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) {
rrScrPrivPtr slave_priv = rrGetScrPriv(slave);
for (c = 0; c < slave_priv->numCrtcs; c++) {
- if (slave_priv->crtcs[c] == rr_crtc) {
+ RRCrtcPtr slave_crtc = slave_priv->crtcs[c];
+
+ if (slave_crtc == rr_crtc) {
newbox.x1 = x;
newbox.x2 = x + w;
newbox.y1 = y;
newbox.y2 = y + h;
}
else {
- if (!slave_priv->crtcs[c]->mode)
+ if (!slave_crtc->mode)
continue;
- newbox.x1 = slave_priv->crtcs[c]->x;
- newbox.x2 = slave_priv->crtcs[c]->x + slave_priv->crtcs[c]->mode->mode.width;
- newbox.y1 = slave_priv->crtcs[c]->y;
- newbox.y2 = slave_priv->crtcs[c]->y + slave_priv->crtcs[c]->mode->mode.height;
+ newbox.x1 = slave_crtc->x;
+ newbox.x2 = slave_crtc->x + slave_crtc->mode->mode.width;
+ newbox.y1 = slave_crtc->y;
+ newbox.y2 = slave_crtc->y + slave_crtc->mode->mode.height;
}
RegionInit(&new_crtc_region, &newbox, 1);
RegionUnion(&total_region, &total_region, &new_crtc_region);
@@ -502,7 +506,6 @@ rrCheckPixmapBounding(ScreenPtr pScreen,
if (new_width == screen_pixmap->drawable.width &&
new_height == screen_pixmap->drawable.height) {
- ErrorF("adjust shatters %d %d\n", newsize->x1, newsize->x2);
} else {
pScrPriv->rrScreenSetSize(pScreen, new_width, new_height, 0, 0);
}
@@ -557,7 +560,6 @@ RRCrtcSet(RRCrtcPtr crtc,
width = mode->mode.width;
height = mode->mode.height;
}
- ErrorF("have a master to look out for\n");
ret = rrCheckPixmapBounding(master, crtc,
x, y, width, height);
if (!ret)
@@ -565,8 +567,6 @@ RRCrtcSet(RRCrtcPtr crtc,
if (pScreen->current_master) {
ret = rrCreateSharedPixmap(crtc, width, height, x, y);
- ErrorF("need to create shared pixmap %d", ret);
-
}
}
#if RANDR_12_INTERFACE
@@ -798,7 +798,7 @@ RRCrtcGammaSetSize(RRCrtcPtr crtc, int size)
if (size == crtc->gammaSize)
return TRUE;
if (size) {
- gamma = malloc(size * 3 * sizeof(CARD16));
+ gamma = xallocarray(size, 3 * sizeof(CARD16));
if (!gamma)
return FALSE;
}
@@ -1027,7 +1027,7 @@ ProcRRSetCrtcConfig(ClientPtr client)
return BadMatch;
}
if (numOutputs) {
- outputs = malloc(numOutputs * sizeof(RROutputPtr));
+ outputs = xallocarray(numOutputs, sizeof(RROutputPtr));
if (!outputs)
return BadAlloc;
}
@@ -1575,7 +1575,8 @@ ProcRRGetCrtcTransform(ClientPtr client)
return Success;
}
-static Bool check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y)
+static Bool
+check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y)
{
rrScrPriv(pScreen);
int i;
@@ -1595,7 +1596,8 @@ static Bool check_all_screen_crtcs(ScreenPtr pScreen, int *x, int *y)
return FALSE;
}
-static Bool constrain_all_screen_crtcs(DeviceIntPtr pDev, ScreenPtr pScreen, int *x, int *y)
+static Bool
+constrain_all_screen_crtcs(DeviceIntPtr pDev, ScreenPtr pScreen, int *x, int *y)
{
rrScrPriv(pScreen);
int i;
diff --git a/xorg-server/randr/rrinfo.c b/xorg-server/randr/rrinfo.c
index fc57bd408..24245b7b6 100644
--- a/xorg-server/randr/rrinfo.c
+++ b/xorg-server/randr/rrinfo.c
@@ -55,8 +55,8 @@ RROldModeAdd(RROutputPtr output, RRScreenSizePtr size, int refresh)
}
if (output->numModes)
- modes = realloc(output->modes,
- (output->numModes + 1) * sizeof(RRModePtr));
+ modes = reallocarray(output->modes,
+ output->numModes + 1, sizeof(RRModePtr));
else
modes = malloc(sizeof(RRModePtr));
if (!modes) {
@@ -266,8 +266,8 @@ RRRegisterSize(ScreenPtr pScreen,
for (i = 0; i < pScrPriv->nSizes; i++)
if (RRScreenSizeMatches(&tmp, &pScrPriv->pSizes[i]))
return &pScrPriv->pSizes[i];
- pNew = realloc(pScrPriv->pSizes,
- (pScrPriv->nSizes + 1) * sizeof(RRScreenSize));
+ pNew = reallocarray(pScrPriv->pSizes,
+ pScrPriv->nSizes + 1, sizeof(RRScreenSize));
if (!pNew)
return 0;
pNew[pScrPriv->nSizes++] = tmp;
@@ -289,7 +289,7 @@ RRRegisterRate(ScreenPtr pScreen, RRScreenSizePtr pSize, int rate)
if (pSize->pRates[i].rate == rate)
return TRUE;
- pNew = realloc(pSize->pRates, (pSize->nRates + 1) * sizeof(RRScreenRate));
+ pNew = reallocarray(pSize->pRates, pSize->nRates + 1, sizeof(RRScreenRate));
if (!pNew)
return FALSE;
pRate = &pNew[pSize->nRates++];
diff --git a/xorg-server/randr/rrmode.c b/xorg-server/randr/rrmode.c
index befac4741..a7aa43320 100644
--- a/xorg-server/randr/rrmode.c
+++ b/xorg-server/randr/rrmode.c
@@ -79,7 +79,7 @@ RRModeCreate(xRRModeInfo * modeInfo, const char *name, ScreenPtr userScreen)
mode->userScreen = userScreen;
if (num_modes)
- newModes = realloc(modes, (num_modes + 1) * sizeof(RRModePtr));
+ newModes = reallocarray(modes, num_modes + 1, sizeof(RRModePtr));
else
newModes = malloc(sizeof(RRModePtr));
@@ -166,7 +166,7 @@ RRModesForScreen(ScreenPtr pScreen, int *num_ret)
RRModePtr *screen_modes;
int num_screen_modes = 0;
- screen_modes = malloc((num_modes ? num_modes : 1) * sizeof(RRModePtr));
+ screen_modes = xallocarray((num_modes ? num_modes : 1), sizeof(RRModePtr));
if (!screen_modes)
return NULL;
diff --git a/xorg-server/randr/rrmonitor.c b/xorg-server/randr/rrmonitor.c
index fbdd352f6..05285ddfd 100644
--- a/xorg-server/randr/rrmonitor.c
+++ b/xorg-server/randr/rrmonitor.c
@@ -389,13 +389,13 @@ RRMonitorCountList(ScreenPtr screen)
return nmon;
}
-static void
+void
RRMonitorFree(RRMonitorPtr monitor)
{
free(monitor);
}
-static RRMonitorPtr
+RRMonitorPtr
RRMonitorAlloc(int noutput)
{
RRMonitorPtr monitor;
@@ -451,7 +451,7 @@ RRMonitorMatchesOutputName(ScreenPtr screen, Atom name)
return FALSE;
}
-static int
+int
RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor)
{
rrScrPrivPtr pScrPriv = rrGetScrPriv(screen);
@@ -494,8 +494,9 @@ RRMonitorAdd(ClientPtr client, ScreenPtr screen, RRMonitorPtr monitor)
* needs to not have any side-effects on failure
*/
if (pScrPriv->numMonitors)
- monitors = realloc(pScrPriv->monitors,
- (pScrPriv->numMonitors + 1) * sizeof (RRMonitorPtr));
+ monitors = reallocarray(pScrPriv->monitors,
+ pScrPriv->numMonitors + 1,
+ sizeof (RRMonitorPtr));
else
monitors = malloc(sizeof (RRMonitorPtr));
diff --git a/xorg-server/randr/rroutput.c b/xorg-server/randr/rroutput.c
index 548e07d1d..10df4da95 100644
--- a/xorg-server/randr/rroutput.c
+++ b/xorg-server/randr/rroutput.c
@@ -60,8 +60,8 @@ RROutputCreate(ScreenPtr pScreen,
pScrPriv = rrGetScrPriv(pScreen);
if (pScrPriv->numOutputs)
- outputs = realloc(pScrPriv->outputs,
- (pScrPriv->numOutputs + 1) * sizeof(RROutputPtr));
+ outputs = reallocarray(pScrPriv->outputs,
+ pScrPriv->numOutputs + 1, sizeof(RROutputPtr));
else
outputs = malloc(sizeof(RROutputPtr));
if (!outputs)
@@ -124,7 +124,7 @@ RROutputSetClones(RROutputPtr output, RROutputPtr * clones, int numClones)
return TRUE;
}
if (numClones) {
- newClones = malloc(numClones * sizeof(RROutputPtr));
+ newClones = xallocarray(numClones, sizeof(RROutputPtr));
if (!newClones)
return FALSE;
}
@@ -157,7 +157,7 @@ RROutputSetModes(RROutputPtr output,
}
if (numModes) {
- newModes = malloc(numModes * sizeof(RRModePtr));
+ newModes = xallocarray(numModes, sizeof(RRModePtr));
if (!newModes)
return FALSE;
}
@@ -200,8 +200,8 @@ RROutputAddUserMode(RROutputPtr output, RRModePtr mode)
return BadMatch;
if (output->userModes)
- newModes = realloc(output->userModes,
- (output->numUserModes + 1) * sizeof(RRModePtr));
+ newModes = reallocarray(output->userModes,
+ output->numUserModes + 1, sizeof(RRModePtr));
else
newModes = malloc(sizeof(RRModePtr));
if (!newModes)
@@ -256,7 +256,7 @@ RROutputSetCrtcs(RROutputPtr output, RRCrtcPtr * crtcs, int numCrtcs)
return TRUE;
}
if (numCrtcs) {
- newCrtcs = malloc(numCrtcs * sizeof(RRCrtcPtr));
+ newCrtcs = xallocarray(numCrtcs, sizeof(RRCrtcPtr));
if (!newCrtcs)
return FALSE;
}
diff --git a/xorg-server/randr/rrproperty.c b/xorg-server/randr/rrproperty.c
index e385e15ab..e56626cd2 100644
--- a/xorg-server/randr/rrproperty.c
+++ b/xorg-server/randr/rrproperty.c
@@ -140,7 +140,6 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
RRPropertyPtr prop;
rrScrPrivPtr pScrPriv = rrGetScrPriv(output->pScreen);
int size_in_bytes;
- int total_size;
unsigned long total_len;
RRPropertyValuePtr prop_value;
RRPropertyValueRec new_value;
@@ -180,9 +179,8 @@ RRChangeOutputProperty(RROutputPtr output, Atom property, Atom type,
if (mode == PropModeReplace || len > 0) {
void *new_data = NULL, *old_data = NULL;
- total_size = total_len * size_in_bytes;
- new_value.data = (void *) malloc(total_size);
- if (!new_value.data && total_size) {
+ new_value.data = xallocarray(total_len, size_in_bytes);
+ if (!new_value.data && total_len && size_in_bytes) {
if (add)
RRDestroyOutputProperty(prop);
return BadAlloc;
@@ -350,7 +348,7 @@ RRConfigureOutputProperty(RROutputPtr output, Atom property,
return BadMatch;
}
- new_values = malloc(num_values * sizeof(INT32));
+ new_values = xallocarray(num_values, sizeof(INT32));
if (!new_values && num_values) {
if (add)
RRDestroyOutputProperty(prop);
@@ -400,7 +398,7 @@ ProcRRListOutputProperties(ClientPtr client)
for (prop = output->properties; prop; prop = prop->next)
numProps++;
if (numProps)
- if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom))))
+ if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
return BadAlloc;
rep = (xRRListOutputPropertiesReply) {
@@ -447,7 +445,7 @@ ProcRRQueryOutputProperty(ClientPtr client)
return BadName;
if (prop->num_valid) {
- extra = malloc(prop->num_valid * sizeof(INT32));
+ extra = xallocarray(prop->num_valid, sizeof(INT32));
if (!extra)
return BadAlloc;
}
diff --git a/xorg-server/randr/rrproviderproperty.c b/xorg-server/randr/rrproviderproperty.c
index ff2c614d0..b79c17f9b 100644
--- a/xorg-server/randr/rrproviderproperty.c
+++ b/xorg-server/randr/rrproviderproperty.c
@@ -350,7 +350,7 @@ RRConfigureProviderProperty(RRProviderPtr provider, Atom property,
return BadMatch;
}
- new_values = malloc(num_values * sizeof(INT32));
+ new_values = xallocarray(num_values, sizeof(INT32));
if (!new_values && num_values) {
if (add)
RRDestroyProviderProperty(prop);
@@ -400,7 +400,7 @@ ProcRRListProviderProperties(ClientPtr client)
for (prop = provider->properties; prop; prop = prop->next)
numProps++;
if (numProps)
- if (!(pAtoms = (Atom *) malloc(numProps * sizeof(Atom))))
+ if (!(pAtoms = xallocarray(numProps, sizeof(Atom))))
return BadAlloc;
rep = (xRRListProviderPropertiesReply) {
@@ -445,7 +445,7 @@ ProcRRQueryProviderProperty(ClientPtr client)
return BadName;
if (prop->num_valid) {
- extra = malloc(prop->num_valid * sizeof(INT32));
+ extra = xallocarray(prop->num_valid, sizeof(INT32));
if (!extra)
return BadAlloc;
}
diff --git a/xorg-server/randr/rrscreen.c b/xorg-server/randr/rrscreen.c
index e7ea49ddf..d0ca91e0e 100644
--- a/xorg-server/randr/rrscreen.c
+++ b/xorg-server/randr/rrscreen.c
@@ -400,8 +400,6 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen)
update_totals(iter, pScrPriv);
}
- ErrorF("reporting %d %d %d %d\n", total_crtcs, total_outputs, total_modes, total_name_len);
-
pScrPriv = rrGetScrPriv(pScreen);
rep = (xRRGetScreenResourcesReply) {
.type = X_Reply,
@@ -415,8 +413,9 @@ rrGetMultiScreenResources(ClientPtr client, Bool query, ScreenPtr pScreen)
.nbytesNames = total_name_len
};
- rep.length = (total_crtcs + total_outputs + total_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
- bytes_to_int32(rep.nbytesNames));
+ rep.length = (total_crtcs + total_outputs +
+ total_modes * bytes_to_int32(SIZEOF(xRRModeInfo)) +
+ bytes_to_int32(total_name_len));
extraLen = rep.length << 2;
if (extraLen) {
diff --git a/xorg-server/randr/rrtransform.c b/xorg-server/randr/rrtransform.c
index c8a27498f..6137f8587 100644
--- a/xorg-server/randr/rrtransform.c
+++ b/xorg-server/randr/rrtransform.c
@@ -70,7 +70,7 @@ RRTransformSetFilter(RRTransformPtr dst,
xFixed *new_params;
if (nparams) {
- new_params = malloc(nparams * sizeof(xFixed));
+ new_params = xallocarray(nparams, sizeof(xFixed));
if (!new_params)
return FALSE;
memcpy(new_params, params, nparams * sizeof(xFixed));
diff --git a/xorg-server/record/record.c b/xorg-server/record/record.c
index 0a466e279..1caf3f1db 100644
--- a/xorg-server/record/record.c
+++ b/xorg-server/record/record.c
@@ -1074,19 +1074,19 @@ RecordAddClientToRCAP(RecordClientsAndProtocolPtr pRCAP, XID clientspec)
{
if (pRCAP->numClients == pRCAP->sizeClients) {
if (pRCAP->clientIDsSeparatelyAllocated) {
- XID *pNewIDs = (XID *) realloc(pRCAP->pClientIDs,
- (pRCAP->sizeClients +
- CLIENT_ARRAY_GROWTH_INCREMENT) *
- sizeof(XID));
+ XID *pNewIDs =
+ reallocarray(pRCAP->pClientIDs,
+ pRCAP->sizeClients + CLIENT_ARRAY_GROWTH_INCREMENT,
+ sizeof(XID));
if (!pNewIDs)
return;
pRCAP->pClientIDs = pNewIDs;
pRCAP->sizeClients += CLIENT_ARRAY_GROWTH_INCREMENT;
}
else {
- XID *pNewIDs = (XID *) malloc((pRCAP->sizeClients +
- CLIENT_ARRAY_GROWTH_INCREMENT) *
- sizeof(XID));
+ XID *pNewIDs =
+ xallocarray(pRCAP->sizeClients + CLIENT_ARRAY_GROWTH_INCREMENT,
+ sizeof(XID));
if (!pNewIDs)
return;
memcpy(pNewIDs, pRCAP->pClientIDs, pRCAP->numClients * sizeof(XID));
@@ -1217,7 +1217,7 @@ RecordCanonicalizeClientSpecifiers(XID *pClientspecs, int *pNumClientspecs,
for (i = 0; i < numClients; i++) {
if (pClientspecs[i] == XRecordAllClients || pClientspecs[i] == XRecordCurrentClients) { /* expand All/Current */
int j, nc;
- XID *pCanon = (XID *) malloc(sizeof(XID) * (currentMaxClients + 1));
+ XID *pCanon = xallocarray(currentMaxClients + 1, sizeof(XID));
if (!pCanon)
return NULL;
@@ -1421,8 +1421,7 @@ static int
RecordAllocIntervals(SetInfoPtr psi, int nIntervals)
{
assert(!psi->intervals);
- psi->intervals = (RecordSetInterval *)
- malloc(nIntervals * sizeof(RecordSetInterval));
+ psi->intervals = xallocarray(nIntervals, sizeof(RecordSetInterval));
if (!psi->intervals)
return BadAlloc;
memset(psi->intervals, 0, nIntervals * sizeof(RecordSetInterval));
@@ -1584,7 +1583,7 @@ RecordRegisterClients(RecordContextPtr pContext, ClientPtr client,
* range for extension replies.
*/
maxSets = PREDEFSETS + 2 * stuff->nRanges;
- si = (SetInfoPtr) malloc(sizeof(SetInfoRec) * maxSets);
+ si = xallocarray(maxSets, sizeof(SetInfoRec));
if (!si) {
err = BadAlloc;
goto bailout;
@@ -1853,8 +1852,8 @@ ProcRecordCreateContext(ClientPtr client)
/* make sure there is room in ppAllContexts to store the new context */
- ppNewAllContexts = (RecordContextPtr *)
- realloc(ppAllContexts, sizeof(RecordContextPtr) * (numContexts + 1));
+ ppNewAllContexts =
+ reallocarray(ppAllContexts, numContexts + 1, sizeof(RecordContextPtr));
if (!ppNewAllContexts)
goto bailout;
ppAllContexts = ppNewAllContexts;
@@ -1971,8 +1970,7 @@ RecordAllocRanges(GetContextRangeInfoPtr pri, int nRanges)
#define SZINCR 8
newsize = max(pri->size + SZINCR, nRanges);
- pNewRange = (xRecordRange *) realloc(pri->pRanges,
- newsize * sizeof(xRecordRange));
+ pNewRange = reallocarray(pri->pRanges, newsize, sizeof(xRecordRange));
if (!pNewRange)
return BadAlloc;
@@ -2150,9 +2148,7 @@ ProcRecordGetContext(ClientPtr client)
/* allocate and initialize space for record range info */
- pRangeInfo =
- (GetContextRangeInfoPtr) malloc(nRCAPs *
- sizeof(GetContextRangeInfoRec));
+ pRangeInfo = xallocarray(nRCAPs, sizeof(GetContextRangeInfoRec));
if (!pRangeInfo && nRCAPs > 0)
return BadAlloc;
for (i = 0; i < nRCAPs; i++) {
@@ -2733,7 +2729,8 @@ RecordAClientStateChange(CallbackListPtr *pcbl, void *nulldata,
/* RecordDisableContext modifies contents of ppAllContexts. */
numContextsCopy = numContexts;
- ppAllContextsCopy = malloc(numContextsCopy * sizeof(RecordContextPtr));
+ ppAllContextsCopy = xallocarray(numContextsCopy,
+ sizeof(RecordContextPtr));
assert(ppAllContextsCopy);
memcpy(ppAllContextsCopy, ppAllContexts,
numContextsCopy * sizeof(RecordContextPtr));
diff --git a/xorg-server/record/set.c b/xorg-server/record/set.c
index 34faa617e..e0db385b9 100644
--- a/xorg-server/record/set.c
+++ b/xorg-server/record/set.c
@@ -303,9 +303,7 @@ IntervalListCreateSet(RecordSetInterval * pIntervals, int nIntervals,
CARD16 first;
if (nIntervals > 0) {
- stackIntervals =
- (RecordSetInterval *) malloc(sizeof(RecordSetInterval) *
- nIntervals);
+ stackIntervals = xallocarray(nIntervals, sizeof(RecordSetInterval));
if (!stackIntervals)
return NULL;
diff --git a/xorg-server/render/filter.c b/xorg-server/render/filter.c
index 019ea7f94..2741f406c 100644
--- a/xorg-server/render/filter.c
+++ b/xorg-server/render/filter.c
@@ -67,7 +67,7 @@ PictureGetFilterId(const char *filter, int len, Bool makeit)
memcpy(name, filter, len);
name[len] = '\0';
if (filterNames)
- names = realloc(filterNames, (nfilterNames + 1) * sizeof(char *));
+ names = reallocarray(filterNames, nfilterNames + 1, sizeof(char *));
else
names = malloc(sizeof(char *));
if (!names) {
@@ -145,7 +145,7 @@ PictureAddFilter(ScreenPtr pScreen,
return -1;
if (ps->filters)
filters =
- realloc(ps->filters, (ps->nfilters + 1) * sizeof(PictFilterRec));
+ reallocarray(ps->filters, ps->nfilters + 1, sizeof(PictFilterRec));
else
filters = malloc(sizeof(PictFilterRec));
if (!filters)
@@ -177,9 +177,9 @@ PictureSetFilterAlias(ScreenPtr pScreen, const char *filter, const char *alias)
PictFilterAliasPtr aliases;
if (ps->filterAliases)
- aliases = realloc(ps->filterAliases,
- (ps->nfilterAliases + 1) *
- sizeof(PictFilterAliasRec));
+ aliases = reallocarray(ps->filterAliases,
+ ps->nfilterAliases + 1,
+ sizeof(PictFilterAliasRec));
else
aliases = malloc(sizeof(PictFilterAliasRec));
if (!aliases)
@@ -336,7 +336,7 @@ SetPicturePictFilter(PicturePtr pPicture, PictFilterPtr pFilter,
return BadMatch;
if (nparams != pPicture->filter_nparams) {
- xFixed *new_params = malloc(nparams * sizeof(xFixed));
+ xFixed *new_params = xallocarray(nparams, sizeof(xFixed));
if (!new_params && nparams)
return BadAlloc;
diff --git a/xorg-server/render/miindex.c b/xorg-server/render/miindex.c
index 0375e8f88..4119eef66 100644
--- a/xorg-server/render/miindex.c
+++ b/xorg-server/render/miindex.c
@@ -254,7 +254,7 @@ miInitIndexed(ScreenPtr pScreen, PictFormatPtr pFormat)
return FALSE;
pFormat->index.nvalues = num;
- pFormat->index.pValues = malloc(num * sizeof(xIndexValue));
+ pFormat->index.pValues = xallocarray(num, sizeof(xIndexValue));
if (!pFormat->index.pValues) {
free(pIndexed);
return FALSE;
diff --git a/xorg-server/render/mipict.c b/xorg-server/render/mipict.c
index a72510480..2571fda17 100644
--- a/xorg-server/render/mipict.c
+++ b/xorg-server/render/mipict.c
@@ -510,7 +510,7 @@ miTriStrip(CARD8 op,
int ntri;
ntri = npoints - 2;
- tris = malloc(ntri * sizeof(xTriangle));
+ tris = xallocarray(ntri, sizeof(xTriangle));
if (!tris)
return;
@@ -535,7 +535,7 @@ miTriFan(CARD8 op,
int ntri;
ntri = npoints - 2;
- tris = malloc(ntri * sizeof(xTriangle));
+ tris = xallocarray(ntri, sizeof(xTriangle));
if (!tris)
return;
diff --git a/xorg-server/render/picture.c b/xorg-server/render/picture.c
index 6ff31ba02..60517a4ee 100644
--- a/xorg-server/render/picture.c
+++ b/xorg-server/render/picture.c
@@ -837,7 +837,7 @@ initGradient(SourcePictPtr pGradient, int stopCount,
dpos = stopPoints[i];
}
- pGradient->gradient.stops = malloc(stopCount * sizeof(PictGradientStop));
+ pGradient->gradient.stops = xallocarray(stopCount, sizeof(PictGradientStop));
if (!pGradient->gradient.stops) {
*error = BadAlloc;
return;
diff --git a/xorg-server/render/render.c b/xorg-server/render/render.c
index 723f380c2..88d8a2669 100644
--- a/xorg-server/render/render.c
+++ b/xorg-server/render/render.c
@@ -1318,14 +1318,14 @@ ProcRenderCompositeGlyphs(ClientPtr client)
if (nglyph <= NLOCALGLYPH)
glyphsBase = glyphsLocal;
else {
- glyphsBase = (GlyphPtr *) malloc(nglyph * sizeof(GlyphPtr));
+ glyphsBase = xallocarray(nglyph, sizeof(GlyphPtr));
if (!glyphsBase)
return BadAlloc;
}
if (nlist <= NLOCALDELTA)
listsBase = listsLocal;
else {
- listsBase = (GlyphListPtr) malloc(nlist * sizeof(GlyphListRec));
+ listsBase = xallocarray(nlist, sizeof(GlyphListRec));
if (!listsBase) {
rc = BadAlloc;
goto bail;
@@ -1793,7 +1793,7 @@ ProcRenderCreateAnimCursor(ClientPtr client)
ncursor =
(client->req_len -
(bytes_to_int32(sizeof(xRenderCreateAnimCursorReq)))) >> 1;
- cursors = malloc(ncursor * (sizeof(CursorPtr) + sizeof(CARD32)));
+ cursors = xallocarray(ncursor, sizeof(CursorPtr) + sizeof(CARD32));
if (!cursors)
return BadAlloc;
deltas = (CARD32 *) (cursors + ncursor);
diff --git a/xorg-server/xfixes/region.c b/xorg-server/xfixes/region.c
index 4492f1267..dd74d7f7e 100644
--- a/xorg-server/xfixes/region.c
+++ b/xorg-server/xfixes/region.c
@@ -777,7 +777,7 @@ ProcXFixesExpandRegion(ClientPtr client)
nBoxes = RegionNumRects(pSource);
pSrc = RegionRects(pSource);
if (nBoxes) {
- pTmp = malloc(nBoxes * sizeof(BoxRec));
+ pTmp = xallocarray(nBoxes, sizeof(BoxRec));
if (!pTmp)
return BadAlloc;
for (i = 0; i < nBoxes; i++) {
diff --git a/xorg-server/xkb/XKBAlloc.c b/xorg-server/xkb/XKBAlloc.c
index 78c98371d..18557b804 100644
--- a/xorg-server/xkb/XKBAlloc.c
+++ b/xorg-server/xkb/XKBAlloc.c
@@ -56,8 +56,8 @@ XkbAllocCompatMap(XkbDescPtr xkb, unsigned which, unsigned nSI)
if (compat->sym_interpret == NULL)
compat->num_si = 0;
prev_interpret = compat->sym_interpret;
- compat->sym_interpret = realloc(compat->sym_interpret,
- nSI * sizeof(XkbSymInterpretRec));
+ compat->sym_interpret = reallocarray(compat->sym_interpret,
+ nSI, sizeof(XkbSymInterpretRec));
if (compat->sym_interpret == NULL) {
free(prev_interpret);
compat->size_si = compat->num_si = 0;
@@ -159,9 +159,9 @@ XkbAllocNames(XkbDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases)
else if (nTotalAliases > names->num_key_aliases) {
XkbKeyAliasRec *prev_aliases = names->key_aliases;
- names->key_aliases = realloc(names->key_aliases,
- nTotalAliases *
- sizeof(XkbKeyAliasRec));
+ names->key_aliases = reallocarray(names->key_aliases,
+ nTotalAliases,
+ sizeof(XkbKeyAliasRec));
if (names->key_aliases != NULL) {
memset(&names->key_aliases[names->num_key_aliases], 0,
(nTotalAliases -
@@ -184,8 +184,8 @@ XkbAllocNames(XkbDescPtr xkb, unsigned which, int nTotalRG, int nTotalAliases)
else if (nTotalRG > names->num_rg) {
Atom *prev_radio_groups = names->radio_groups;
- names->radio_groups = realloc(names->radio_groups,
- nTotalRG * sizeof(Atom));
+ names->radio_groups = reallocarray(names->radio_groups,
+ nTotalRG, sizeof(Atom));
if (names->radio_groups != NULL) {
memset(&names->radio_groups[names->num_rg], 0,
(nTotalRG - names->num_rg) * sizeof(Atom));
diff --git a/xorg-server/xkb/XKBGAlloc.c b/xorg-server/xkb/XKBGAlloc.c
index 25917d304..e9f55fa43 100644
--- a/xorg-server/xkb/XKBGAlloc.c
+++ b/xorg-server/xkb/XKBGAlloc.c
@@ -409,7 +409,7 @@ XkbGeomRealloc(void **buffer, int szItems, int nrItems,
return FALSE;
/* Check if there is need to resize. */
if (nrItems != szItems)
- if (!(items = realloc(items, nrItems * itemSize)))
+ if (!(items = reallocarray(items, nrItems, itemSize)))
return FALSE;
/* Clear specified items to zero. */
switch (clearance) {
diff --git a/xorg-server/xkb/XKBMAlloc.c b/xorg-server/xkb/XKBMAlloc.c
index 37ed1a725..dbc1389e6 100644
--- a/xorg-server/xkb/XKBMAlloc.c
+++ b/xorg-server/xkb/XKBMAlloc.c
@@ -80,7 +80,7 @@ XkbAllocClientMap(XkbDescPtr xkb, unsigned which, unsigned nTotalTypes)
XkbKeyTypeRec *prev_types = map->types;
map->types =
- realloc(map->types, nTotalTypes * sizeof(XkbKeyTypeRec));
+ reallocarray(map->types, nTotalTypes, sizeof(XkbKeyTypeRec));
if (map->types == NULL) {
free(prev_types);
map->num_types = map->size_types = 0;
@@ -177,7 +177,7 @@ XkbAllocServerMap(XkbDescPtr xkb, unsigned which, unsigned nNewActions)
XkbAction *prev_acts = map->acts;
need = map->num_acts + nNewActions;
- map->acts = realloc(map->acts, need * sizeof(XkbAction));
+ map->acts = reallocarray(map->acts, need, sizeof(XkbAction));
if (map->acts == NULL) {
free(prev_acts);
map->num_acts = map->size_acts = 0;
@@ -309,7 +309,7 @@ XkbResizeKeyType(XkbDescPtr xkb,
if ((map_count > type->map_count) || (type->map == NULL))
type->map =
- realloc(type->map, map_count * sizeof(XkbKTMapEntryRec));
+ reallocarray(type->map, map_count, sizeof(XkbKTMapEntryRec));
if (!type->map) {
free(prev_map);
return BadAlloc;
@@ -318,8 +318,8 @@ XkbResizeKeyType(XkbDescPtr xkb,
XkbModsRec *prev_preserve = type->preserve;
if ((map_count > type->map_count) || (type->preserve == NULL)) {
- type->preserve = realloc(type->preserve,
- map_count * sizeof(XkbModsRec));
+ type->preserve = reallocarray(type->preserve,
+ map_count, sizeof(XkbModsRec));
}
if (!type->preserve) {
free(prev_preserve);
@@ -336,8 +336,8 @@ XkbResizeKeyType(XkbDescPtr xkb,
if ((new_num_lvls > type->num_levels) || (type->level_names == NULL)) {
Atom *prev_level_names = type->level_names;
- type->level_names = realloc(type->level_names,
- new_num_lvls * sizeof(Atom));
+ type->level_names = reallocarray(type->level_names,
+ new_num_lvls, sizeof(Atom));
if (!type->level_names) {
free(prev_level_names);
return BadAlloc;
@@ -659,9 +659,9 @@ XkbChangeKeycodeRange(XkbDescPtr xkb,
if (xkb->map->key_sym_map) {
XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
- xkb->map->key_sym_map = realloc(xkb->map->key_sym_map,
- (maxKC +
- 1) * sizeof(XkbSymMapRec));
+ xkb->map->key_sym_map = reallocarray(xkb->map->key_sym_map,
+ maxKC + 1,
+ sizeof(XkbSymMapRec));
if (!xkb->map->key_sym_map) {
free(prev_key_sym_map);
return BadAlloc;
@@ -680,8 +680,9 @@ XkbChangeKeycodeRange(XkbDescPtr xkb,
if (xkb->map->modmap) {
unsigned char *prev_modmap = xkb->map->modmap;
- xkb->map->modmap = realloc(xkb->map->modmap,
- (maxKC + 1) * sizeof(unsigned char));
+ xkb->map->modmap = reallocarray(xkb->map->modmap,
+ maxKC + 1,
+ sizeof(unsigned char));
if (!xkb->map->modmap) {
free(prev_modmap);
return BadAlloc;
@@ -702,9 +703,9 @@ XkbChangeKeycodeRange(XkbDescPtr xkb,
if (xkb->server->behaviors) {
XkbBehavior *prev_behaviors = xkb->server->behaviors;
- xkb->server->behaviors = realloc(xkb->server->behaviors,
- (maxKC +
- 1) * sizeof(XkbBehavior));
+ xkb->server->behaviors = reallocarray(xkb->server->behaviors,
+ maxKC + 1,
+ sizeof(XkbBehavior));
if (!xkb->server->behaviors) {
free(prev_behaviors);
return BadAlloc;
@@ -724,9 +725,9 @@ XkbChangeKeycodeRange(XkbDescPtr xkb,
if (xkb->server->key_acts) {
unsigned short *prev_key_acts = xkb->server->key_acts;
- xkb->server->key_acts = realloc(xkb->server->key_acts,
- (maxKC +
- 1) * sizeof(unsigned short));
+ xkb->server->key_acts = reallocarray(xkb->server->key_acts,
+ maxKC + 1,
+ sizeof(unsigned short));
if (!xkb->server->key_acts) {
free(prev_key_acts);
return BadAlloc;
@@ -746,9 +747,9 @@ XkbChangeKeycodeRange(XkbDescPtr xkb,
if (xkb->server->vmodmap) {
unsigned short *prev_vmodmap = xkb->server->vmodmap;
- xkb->server->vmodmap = realloc(xkb->server->vmodmap,
- (maxKC +
- 1) * sizeof(unsigned short));
+ xkb->server->vmodmap = reallocarray(xkb->server->vmodmap,
+ maxKC + 1,
+ sizeof(unsigned short));
if (!xkb->server->vmodmap) {
free(prev_vmodmap);
return BadAlloc;
@@ -769,8 +770,8 @@ XkbChangeKeycodeRange(XkbDescPtr xkb,
if ((xkb->names) && (xkb->names->keys)) {
XkbKeyNameRec *prev_keys = xkb->names->keys;
- xkb->names->keys = realloc(xkb->names->keys,
- (maxKC + 1) * sizeof(XkbKeyNameRec));
+ xkb->names->keys = reallocarray(xkb->names->keys,
+ maxKC + 1, sizeof(XkbKeyNameRec));
if (!xkb->names->keys) {
free(prev_keys);
return BadAlloc;
diff --git a/xorg-server/xkb/maprules.c b/xorg-server/xkb/maprules.c
index 28148d9a5..8e2277969 100644
--- a/xorg-server/xkb/maprules.c
+++ b/xorg-server/xkb/maprules.c
@@ -89,11 +89,11 @@ InputLineAddChar(InputLine * line, int ch)
{
if (line->num_line >= line->sz_line) {
if (line->line == line->buf) {
- line->line = malloc(line->sz_line * 2);
+ line->line = xallocarray(line->sz_line, 2);
memcpy(line->line, line->buf, line->sz_line);
}
else {
- line->line = realloc((char *) line->line, line->sz_line * 2);
+ line->line = reallocarray(line->line, line->sz_line, 2);
}
line->sz_line *= 2;
}
@@ -897,8 +897,8 @@ XkbRF_AddRule(XkbRF_RulesPtr rules)
}
else if (rules->num_rules >= rules->sz_rules) {
rules->sz_rules *= 2;
- rules->rules = realloc(rules->rules,
- rules->sz_rules * sizeof(XkbRF_RuleRec));
+ rules->rules = reallocarray(rules->rules,
+ rules->sz_rules, sizeof(XkbRF_RuleRec));
}
if (!rules->rules) {
rules->sz_rules = rules->num_rules = 0;
@@ -919,8 +919,8 @@ XkbRF_AddGroup(XkbRF_RulesPtr rules)
}
else if (rules->num_groups >= rules->sz_groups) {
rules->sz_groups *= 2;
- rules->groups = realloc(rules->groups,
- rules->sz_groups * sizeof(XkbRF_GroupRec));
+ rules->groups = reallocarray(rules->groups,
+ rules->sz_groups, sizeof(XkbRF_GroupRec));
}
if (!rules->groups) {
rules->sz_groups = rules->num_groups = 0;
diff --git a/xorg-server/xkb/xkb.c b/xorg-server/xkb/xkb.c
index f3988f9a7..294cdf8a3 100644
--- a/xorg-server/xkb/xkb.c
+++ b/xorg-server/xkb/xkb.c
@@ -2216,12 +2216,11 @@ SetKeyBehaviors(XkbSrvInfoPtr xkbi,
}
if (maxRG > (int) xkbi->nRadioGroups) {
- int sz = maxRG * sizeof(XkbRadioGroupRec);
-
if (xkbi->radioGroups)
- xkbi->radioGroups = realloc(xkbi->radioGroups, sz);
+ xkbi->radioGroups = reallocarray(xkbi->radioGroups, maxRG,
+ sizeof(XkbRadioGroupRec));
else
- xkbi->radioGroups = calloc(1, sz);
+ xkbi->radioGroups = calloc(maxRG, sizeof(XkbRadioGroupRec));
if (xkbi->radioGroups) {
if (xkbi->nRadioGroups)
memset(&xkbi->radioGroups[xkbi->nRadioGroups], 0,
@@ -2700,15 +2699,16 @@ XkbSendCompatMap(ClientPtr client,
char *data;
int size;
- size = rep->length * 4;
- if (size > 0) {
- data = malloc(size);
+ if (rep->length > 0) {
+ data = xallocarray(rep->length, 4);
if (data) {
register unsigned i, bit;
xkbModsWireDesc *grp;
XkbSymInterpretPtr sym = &compat->sym_interpret[rep->firstSI];
xkbSymInterpretWireDesc *wire = (xkbSymInterpretWireDesc *) data;
+ size = rep->length * 4;
+
for (i = 0; i < rep->nSI; i++, sym++, wire++) {
wire->sym = sym->sym;
wire->mods = sym->mods;
@@ -2856,9 +2856,9 @@ _XkbSetCompatMap(ClientPtr client, DeviceIntPtr dev,
if ((unsigned) (req->firstSI + req->nSI) > compat->num_si) {
compat->num_si = req->firstSI + req->nSI;
- compat->sym_interpret = realloc(compat->sym_interpret,
- compat->num_si *
- sizeof(XkbSymInterpretRec));
+ compat->sym_interpret = reallocarray(compat->sym_interpret,
+ compat->num_si,
+ sizeof(XkbSymInterpretRec));
if (!compat->sym_interpret) {
compat->num_si = 0;
return BadAlloc;
@@ -3086,14 +3086,15 @@ XkbSendIndicatorMap(ClientPtr client,
register int i;
register unsigned bit;
- length = rep->length * 4;
- if (length > 0) {
+ if (rep->length > 0) {
CARD8 *to;
- to = map = malloc(length);
+ to = map = xallocarray(rep->length, 4);
if (map) {
xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *) to;
+ length = rep->length * 4;
+
for (i = 0, bit = 1; i < XkbNumIndicators; i++, bit <<= 1) {
if (rep->which & bit) {
wire->flags = indicators->maps[i].flags;
@@ -4863,7 +4864,6 @@ XkbComputeGetGeometryReplySize(XkbGeometryPtr geom,
}
return Success;
}
-
static int
XkbSendGeometry(ClientPtr client,
XkbGeometryPtr geom, xkbGetGeometryReply * rep, Bool freeGeom)
@@ -4872,10 +4872,10 @@ XkbSendGeometry(ClientPtr client,
int len;
if (geom != NULL) {
- len = rep->length * 4;
- start = desc = malloc(len);
+ start = desc = xallocarray(rep->length, 4);
if (!start)
return BadAlloc;
+ len = rep->length * 4;
desc = XkbWriteCountedString(desc, geom->label_font, client->swapped);
if (rep->nProperties > 0)
desc = XkbWriteGeomProperties(desc, geom, client->swapped);
diff --git a/xorg-server/xkb/xkbActions.c b/xorg-server/xkb/xkbActions.c
index 2a196f151..9dd1cbd3b 100644
--- a/xorg-server/xkb/xkbActions.c
+++ b/xorg-server/xkb/xkbActions.c
@@ -1103,8 +1103,8 @@ _XkbNextFreeFilter(XkbSrvInfoPtr xkbi)
}
}
xkbi->szFilters *= 2;
- xkbi->filters = realloc(xkbi->filters,
- xkbi->szFilters * sizeof(XkbFilterRec));
+ xkbi->filters = reallocarray(xkbi->filters,
+ xkbi->szFilters, sizeof(XkbFilterRec));
/* 6/21/93 (ef) -- XXX! deal with allocation failure */
memset(&xkbi->filters[xkbi->szFilters / 2], 0,
(xkbi->szFilters / 2) * sizeof(XkbFilterRec));
diff --git a/xorg-server/xkb/xkbUtils.c b/xorg-server/xkb/xkbUtils.c
index 6019f0f31..25b5a364e 100644
--- a/xorg-server/xkb/xkbUtils.c
+++ b/xorg-server/xkb/xkbUtils.c
@@ -946,8 +946,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (src->map->syms) {
if (src->map->size_syms != dst->map->size_syms) {
- tmp = realloc(dst->map->syms,
- src->map->size_syms * sizeof(KeySym));
+ tmp = reallocarray(dst->map->syms,
+ src->map->size_syms, sizeof(KeySym));
if (!tmp)
return FALSE;
dst->map->syms = tmp;
@@ -965,8 +965,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (src->map->key_sym_map) {
if (src->max_key_code != dst->max_key_code) {
- tmp = realloc(dst->map->key_sym_map,
- (src->max_key_code + 1) * sizeof(XkbSymMapRec));
+ tmp = reallocarray(dst->map->key_sym_map,
+ src->max_key_code + 1, sizeof(XkbSymMapRec));
if (!tmp)
return FALSE;
dst->map->key_sym_map = tmp;
@@ -983,8 +983,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (src->map->num_types > dst->map->size_types ||
!dst->map->types || !dst->map->size_types) {
if (dst->map->types && dst->map->size_types) {
- tmp = realloc(dst->map->types,
- src->map->num_types * sizeof(XkbKeyTypeRec));
+ tmp = reallocarray(dst->map->types, src->map->num_types,
+ sizeof(XkbKeyTypeRec));
if (!tmp)
return FALSE;
dst->map->types = tmp;
@@ -1020,8 +1020,8 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (stype->num_levels != dtype->num_levels &&
dtype->num_levels && dtype->level_names &&
i < dst->map->num_types) {
- tmp = realloc(dtype->level_names,
- stype->num_levels * sizeof(Atom));
+ tmp = reallocarray(dtype->level_names,
+ stype->num_levels, sizeof(Atom));
if (!tmp)
continue;
dtype->level_names = tmp;
@@ -1053,17 +1053,17 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (stype->map_count != dtype->map_count &&
dtype->map_count && dtype->map &&
i < dst->map->num_types) {
- tmp = realloc(dtype->map,
- stype->map_count *
- sizeof(XkbKTMapEntryRec));
+ tmp = reallocarray(dtype->map,
+ stype->map_count,
+ sizeof(XkbKTMapEntryRec));
if (!tmp)
return FALSE;
dtype->map = tmp;
}
else if (!dtype->map_count || !dtype->map ||
i >= dst->map->num_types) {
- tmp = malloc(stype->map_count *
- sizeof(XkbKTMapEntryRec));
+ tmp = xallocarray(stype->map_count,
+ sizeof(XkbKTMapEntryRec));
if (!tmp)
return FALSE;
dtype->map = tmp;
@@ -1082,16 +1082,17 @@ _XkbCopyClientMap(XkbDescPtr src, XkbDescPtr dst)
if (stype->map_count != dtype->map_count &&
dtype->map_count && dtype->preserve &&
i < dst->map->num_types) {
- tmp = realloc(dtype->preserve,
- stype->map_count *
- sizeof(XkbModsRec));
+ tmp = reallocarray(dtype->preserve,
+ stype->map_count,
+ sizeof(XkbModsRec));
if (!tmp)
return FALSE;
dtype->preserve = tmp;
}
else if (!dtype->preserve || !dtype->map_count ||
i >= dst->map->num_types) {
- tmp = malloc(stype->map_count * sizeof(XkbModsRec));
+ tmp = xallocarray(stype->map_count,
+ sizeof(XkbModsRec));
if (!tmp)
return FALSE;
dtype->preserve = tmp;
@@ -1192,8 +1193,8 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
if (src->server->acts) {
if (src->server->size_acts != dst->server->size_acts) {
- tmp = realloc(dst->server->acts,
- src->server->size_acts * sizeof(XkbAction));
+ tmp = reallocarray(dst->server->acts,
+ src->server->size_acts, sizeof(XkbAction));
if (!tmp)
return FALSE;
dst->server->acts = tmp;
@@ -1210,8 +1211,8 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
if (src->server->key_acts) {
if (src->max_key_code != dst->max_key_code) {
- tmp = realloc(dst->server->key_acts,
- (src->max_key_code + 1) * sizeof(unsigned short));
+ tmp = reallocarray(dst->server->key_acts,
+ src->max_key_code + 1, sizeof(unsigned short));
if (!tmp)
return FALSE;
dst->server->key_acts = tmp;
@@ -1226,8 +1227,8 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
if (src->server->behaviors) {
if (src->max_key_code != dst->max_key_code) {
- tmp = realloc(dst->server->behaviors,
- (src->max_key_code + 1) * sizeof(XkbBehavior));
+ tmp = reallocarray(dst->server->behaviors,
+ src->max_key_code + 1, sizeof(XkbBehavior));
if (!tmp)
return FALSE;
dst->server->behaviors = tmp;
@@ -1244,8 +1245,8 @@ _XkbCopyServerMap(XkbDescPtr src, XkbDescPtr dst)
if (src->server->vmodmap) {
if (src->max_key_code != dst->max_key_code) {
- tmp = realloc(dst->server->vmodmap,
- (src->max_key_code + 1) * sizeof(unsigned short));
+ tmp = reallocarray(dst->server->vmodmap,
+ src->max_key_code + 1, sizeof(unsigned short));
if (!tmp)
return FALSE;
dst->server->vmodmap = tmp;
@@ -1281,8 +1282,8 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
if (src->names->keys) {
if (src->max_key_code != dst->max_key_code) {
- tmp = realloc(dst->names->keys,
- (src->max_key_code + 1) * sizeof(XkbKeyNameRec));
+ tmp = reallocarray(dst->names->keys, src->max_key_code + 1,
+ sizeof(XkbKeyNameRec));
if (!tmp)
return FALSE;
dst->names->keys = tmp;
@@ -1297,9 +1298,9 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
if (src->names->num_key_aliases) {
if (src->names->num_key_aliases != dst->names->num_key_aliases) {
- tmp = realloc(dst->names->key_aliases,
- src->names->num_key_aliases *
- sizeof(XkbKeyAliasRec));
+ tmp = reallocarray(dst->names->key_aliases,
+ src->names->num_key_aliases,
+ sizeof(XkbKeyAliasRec));
if (!tmp)
return FALSE;
dst->names->key_aliases = tmp;
@@ -1315,8 +1316,8 @@ _XkbCopyNames(XkbDescPtr src, XkbDescPtr dst)
if (src->names->num_rg) {
if (src->names->num_rg != dst->names->num_rg) {
- tmp = realloc(dst->names->radio_groups,
- src->names->num_rg * sizeof(Atom));
+ tmp = reallocarray(dst->names->radio_groups,
+ src->names->num_rg, sizeof(Atom));
if (!tmp)
return FALSE;
dst->names->radio_groups = tmp;
@@ -1366,8 +1367,9 @@ _XkbCopyCompat(XkbDescPtr src, XkbDescPtr dst)
if (src->compat->sym_interpret && src->compat->num_si) {
if (src->compat->num_si != dst->compat->size_si) {
- tmp = realloc(dst->compat->sym_interpret,
- src->compat->num_si * sizeof(XkbSymInterpretRec));
+ tmp = reallocarray(dst->compat->sym_interpret,
+ src->compat->num_si,
+ sizeof(XkbSymInterpretRec));
if (!tmp)
return FALSE;
dst->compat->sym_interpret = tmp;
@@ -1582,8 +1584,8 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
j < sshape->num_outlines;
j++, soutline++, doutline++) {
if (soutline->num_points) {
- tmp = malloc(soutline->num_points *
- sizeof(XkbPointRec));
+ tmp = xallocarray(soutline->num_points,
+ sizeof(XkbPointRec));
if (!tmp)
return FALSE;
doutline->points = tmp;
@@ -1710,7 +1712,7 @@ _XkbCopyGeom(XkbDescPtr src, XkbDescPtr dst)
for (j = 0, srow = ssection->rows, drow = dsection->rows;
j < ssection->num_rows; j++, srow++, drow++) {
if (srow->num_keys) {
- tmp = malloc(srow->num_keys * sizeof(XkbKeyRec));
+ tmp = xallocarray(srow->num_keys, sizeof(XkbKeyRec));
if (!tmp)
return FALSE;
drow->keys = tmp;
diff --git a/xorg-server/xkb/xkmread.c b/xorg-server/xkb/xkmread.c
index 0b9f0ef6d..1666e3216 100644
--- a/xorg-server/xkb/xkmread.c
+++ b/xorg-server/xkb/xkmread.c
@@ -64,7 +64,7 @@ XkmInsureSize(void *oldPtr, int oldCount, int *newCountRtrn, int elemSize)
oldPtr = calloc(newCount, elemSize);
}
else if (oldCount < newCount) {
- oldPtr = realloc(oldPtr, newCount * elemSize);
+ oldPtr = reallocarray(oldPtr, newCount, elemSize);
if (oldPtr != NULL) {
char *tmp = (char *) oldPtr;
diff --git a/xorg-server/xkeyboard-config/rules/base.xml.in b/xorg-server/xkeyboard-config/rules/base.xml.in
index a75f02942..c700972d2 100644
--- a/xorg-server/xkeyboard-config/rules/base.xml.in
+++ b/xorg-server/xkeyboard-config/rules/base.xml.in
@@ -4938,6 +4938,13 @@
</languageList>
</configItem>
</variant>
+ <variant>
+ <configItem>
+ <name>us</name>
+ <shortDescription>us</shortDescription>
+ <_description>Singhala (US keyboard with Singhala letters)</_description>
+ </configItem>
+ </variant>
</variantList>
</layout>
<layout>
diff --git a/xorg-server/xkeyboard-config/symbols/eu b/xorg-server/xkeyboard-config/symbols/eu
index 0a4d31a21..5b767f1da 100644
--- a/xorg-server/xkeyboard-config/symbols/eu
+++ b/xorg-server/xkeyboard-config/symbols/eu
@@ -1,6 +1,5 @@
// Based on <http://eurkey.steffen.bruentjen.eu/>
// Copyright: Copyright 2012 Steffen Bruentjen (eurkey (at) steffen dot bruentjen dot de)
-// License: GPLv3 <http://www.gnu.org/licenses/gpl-3.0.html>
// modified by Christoph Roeper <spam (at) roeper dot biz> (use firstName to mail)
default partial alphanumeric_keys modifier_keys
diff --git a/xorg-server/xkeyboard-config/symbols/lk b/xorg-server/xkeyboard-config/symbols/lk
index 9f3b7c7b7..017029dfb 100644
--- a/xorg-server/xkeyboard-config/symbols/lk
+++ b/xorg-server/xkeyboard-config/symbols/lk
@@ -88,3 +88,97 @@ xkb_symbols "tam_TAB" {
name[Group1]= "Tamil (Sri Lanka, TAB Typewriter)";
};
+// SINGHALA - US, SUBSTITUTES SOME AND ADDS SOME
+// =============================================
+//
+// This started as an upgrade to the first romanized version of
+// Singhala called PTS Pali created in the 1860s. PTS requires
+// dots and bars on letters that are rare in fonts, and impossible
+// to type. Its singular purpose was to print Tripitaka, the
+// collection of Buddhist discourses.
+//
+// This version covers the entire newer Singhala phoneme chart
+// (Hodiya) that became standard just before the end of the 19th
+// century. All the phonemes map to the SBCS. It is easy and
+// faster than English to type. It overcomes the setback of
+// Unicode Sinhala that it is not compatible with Pali and
+// Sanskrit because it encodes two ligatures as base letters and
+// the SLS1134 specification matching shape and morpheme sets
+// violating Sanskrit orthography.
+//
+// Most importantly, this romanized version of Singhala has a
+// companion orthographic font that displays the text in the
+// native script and a JavaScript converts it to Unicode Sinhala
+// and back dramatically increasing Singhala seen on the web due
+// to its ease of use
+//
+// Dedication:
+// Thomas William Rhys Davids, Ven. Udagama Sumangala
+// Rev. Fr. A. M. Gunasekara, Rev. Fr. Theodore G. Perera
+// Ven. Mettavihari
+//
+// Maintainer:
+// JC Ahangama - sing@ahangama.com
+//
+partial alphanumeric_keys modifier_keys
+xkb_symbols "us" {
+ include "us(basic)"
+ name[Group1]= "Singhala (US keyboard with Singhala letters)";
+//
+// UNSHIFTED, SHIFT, ALT
+// --------------------------------------------
+//
+ key <AB01> { [ z, VoidSymbol, VoidSymbol ] };
+ key <AB02> { [ x, VoidSymbol, VoidSymbol ] };
+ key <AB03> { [ c, ccedilla, VoidSymbol ] };
+ key <AB04> { [ v, VoidSymbol, VoidSymbol ] };
+ key <AB05> { [ b, B, VoidSymbol ] };
+ key <AB06> { [ n, N, ntilde ] };
+ key <AB07> { [ m, VoidSymbol, VoidSymbol ] };
+ key <AB08> { [ comma, less, UAB ] };
+ key <AB09> { [ period, greater, UBB ] };
+ key <AB10> { [ slash, question, U200C ] };
+
+ key <AC01> { [ a, aacute, adiaeresis ] };
+ key <AC02> { [ s, VoidSymbol, VoidSymbol ] };
+ key <AC03> { [ d, D, VoidSymbol ] };
+ key <AC04> { [ thorn, f, VoidSymbol ] };
+ key <AC05> { [ g, G, VoidSymbol ] };
+ key <AC06> { [ h, VoidSymbol, VoidSymbol ] };
+ key <AC07> { [ j, ccedilla, VoidSymbol ] };
+ key <AC08> { [ k, VoidSymbol, VoidSymbol ] };
+ key <AC09> { [ l, L, ocircumflex ] };
+ key <AC10> { [ semicolon, colon, VoidSymbol ] };
+ key <AC11> { [ apostrophe, quotedbl, VoidSymbol ] };
+
+ key <AD01> { [ eth, ETH, q ] };
+ key <AD02> { [ ae, acute, VoidSymbol ] };
+ key <AD03> { [ e, eacute, ediaeresis ] };
+ key <AD04> { [ r, ucircumflex, VoidSymbol ] };
+ key <AD05> { [ t, VoidSymbol, VoidSymbol ] };
+ key <AD06> { [ y, VoidSymbol, VoidSymbol ] };
+ key <AD07> { [ u, uacute, udiaeresis ] };
+ key <AD08> { [ i, iacute, idiaeresis ] };
+ key <AD09> { [ o, oacute, odiaeresis ] };
+ key <AD10> { [ p, VoidSymbol, VoidSymbol ] };
+ key <AD11> { [ bracketleft, braceleft, VoidSymbol ] };
+ key <AD12> { [ bracketright, braceright, VoidSymbol ] };
+
+ key <AE01> { [ one, exclam, dead_macron ] };
+ key <AE02> { [ two, at, dead_belowdot ] };
+ key <AE03> { [ three, numbersign, dead_abovedot ] };
+ key <AE04> { [ four, dollar, currency ] };
+ key <AE05> { [ five, percent, UB0 ] };
+ key <AE06> { [ six, asciicircum, onequarter ] };
+ key <AE07> { [ seven, ampersand, onehalf ] };
+ key <AE08> { [ eight, asterisk, threequarters ] };
+ key <AE09> { [ nine, parenleft, VoidSymbol ] };
+ key <AE10> { [ zero, parenright, VoidSymbol ] };
+ key <AE11> { [ minus, underscore, U2014 ] };
+ key <AE12> { [ equal, plus, VoidSymbol ] };
+
+ key <BKSL> { [ backslash, bar, VoidSymbol ] };
+ key <SPCE> { [ space, nobreakspace, VoidSymbol ] };
+ key <TLDE> { [ grave, asciitilde, VoidSymbol ] };
+ include "level3(alt_switch)"
+};