mesa: Changes to 'upstream-experimental'
Makefile | 13
bin/mklib | 22
configs/autoconf.in | 4
configs/darwin | 49
configs/darwin-static | 28
configs/darwin-static-x86ppc | 30
configs/default | 7
configs/linux-dri-xcb | 2
configure.ac | 49
docs/MESA_packed_depth_stencil.spec | 231
docs/MESA_program_debug.spec | 357
docs/MESA_sprite_point.spec | 191
docs/MESA_trace.spec | 360
docs/OLD/MESA_packed_depth_stencil.spec | 231
docs/OLD/MESA_program_debug.spec | 357
docs/OLD/MESA_sprite_point.spec | 191
docs/OLD/MESA_trace.spec | 360
docs/download.html | 2
docs/news.html | 7
docs/relnotes-7.0.4.html | 80
docs/relnotes-7.1.html | 2
docs/relnotes.html | 1
docs/shading.html | 76
include/GL/glext.h | 390
include/GL/glxext.h | 42
include/GL/internal/dri_interface.h | 7
progs/demos/Makefile | 13
progs/demos/fbo_firecube.c | 1041 ++
progs/demos/gearbox.c | 16
progs/fp/Makefile | 6
progs/glsl/CH06-brick.frag | 36
progs/glsl/CH06-brick.frag.txt | 36
progs/glsl/CH06-brick.vert | 41
progs/glsl/CH06-brick.vert.txt | 41
progs/glsl/CH11-bumpmap.frag | 41
progs/glsl/CH11-bumpmap.frag.txt | 41
progs/glsl/CH11-bumpmap.vert | 38
progs/glsl/CH11-bumpmap.vert.txt | 38
progs/glsl/CH11-toyball.frag | 75
progs/glsl/CH11-toyball.frag.txt | 75
progs/glsl/CH11-toyball.vert | 24
progs/glsl/CH11-toyball.vert.txt | 24
progs/glsl/CH18-mandel.frag | 55
progs/glsl/CH18-mandel.frag.txt | 55
progs/glsl/CH18-mandel.vert | 35
progs/glsl/CH18-mandel.vert.txt | 35
progs/glsl/Makefile | 16
progs/glsl/brick.c | 4
progs/glsl/bump.c | 4
progs/glsl/convolution.frag | 21
progs/glsl/convolution.vert | 5
progs/glsl/convolutions.c | 469
progs/glsl/cubemap.frag | 18
progs/glsl/cubemap.frag.txt | 18
progs/glsl/mandelbrot.c | 4
progs/glsl/multitex.c | 4
progs/glsl/multitex.frag | 15
progs/glsl/multitex.frag.txt | 15
progs/glsl/multitex.vert | 10
progs/glsl/multitex.vert.txt | 10
progs/glsl/pointcoord.c | 205
progs/glsl/reflect.vert | 19
progs/glsl/reflect.vert.txt | 19
progs/glsl/shadowtex.frag | 21
progs/glsl/shadowtex.frag.txt | 21
progs/glsl/simple.vert | 9
progs/glsl/simple.vert.txt | 9
progs/glsl/texdemo1.c | 8
progs/glsl/toyball.c | 4
progs/glsl/trirast.c | 2
progs/glsl/twoside.c | 52
progs/slang/Makefile | 14
progs/tools/trace/gltrace_support.cc | 4
progs/trivial/Makefile | 4
progs/util/shaderutil.c | 15
progs/xdemos/Makefile | 8
progs/xdemos/glxinfo.c | 7
src/glu/Makefile | 2
src/glu/sgi/Makefile | 1
src/glu/sgi/glu.exports | 59
src/glu/sgi/glu.exports.darwin | 59
src/glut/glx/Makefile | 3
src/glw/Makefile | 5
src/glx/x11/Makefile | 3
src/glx/x11/dri_glx.c | 1
src/glx/x11/glxclient.h | 7
src/glx/x11/glxcmds.c | 18
src/glx/x11/glxcurrent.c | 8
src/glx/x11/glxext.c | 14
src/glx/x11/glxextensions.h | 2
src/glx/x11/glxhash.c | 6
src/glx/x11/indirect.c | 80
src/glx/x11/indirect_vertex_array.c | 39
src/glx/x11/singlepix.c | 6
src/mesa/Makefile | 4
src/mesa/drivers/dri/common/depthtmp.h | 9
src/mesa/drivers/dri/common/dri_util.c | 4
src/mesa/drivers/dri/common/utils.c | 4
src/mesa/drivers/dri/gamma/gamma_span.c | 6
src/mesa/drivers/dri/i810/i810span.c | 2
src/mesa/drivers/dri/i915/i830_context.c | 8
src/mesa/drivers/dri/i915/i915_context.c | 1
src/mesa/drivers/dri/i965/brw_clip.h | 5
src/mesa/drivers/dri/i965/brw_clip_tri.c | 10
src/mesa/drivers/dri/i965/brw_clip_unfilled.c | 24
src/mesa/drivers/dri/i965/brw_clip_util.c | 5
src/mesa/drivers/dri/i965/brw_draw_upload.c | 51
src/mesa/drivers/dri/i965/brw_fallback.c | 5
src/mesa/drivers/dri/i965/brw_vs_emit.c | 30
src/mesa/drivers/dri/i965/brw_wm.c | 9
src/mesa/drivers/dri/i965/brw_wm_emit.c | 15
src/mesa/drivers/dri/i965/brw_wm_fp.c | 16
src/mesa/drivers/dri/i965/brw_wm_glsl.c | 14
src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 64
src/mesa/drivers/dri/intel/intel_buffers.c | 50
src/mesa/drivers/dri/intel/intel_context.c | 8
src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 11
src/mesa/drivers/dri/intel/intel_regions.c | 15
src/mesa/drivers/dri/intel/intel_screen.c | 2
src/mesa/drivers/dri/intel/intel_span.c | 5
src/mesa/drivers/dri/intel/intel_tex.c | 9
src/mesa/drivers/dri/intel/intel_tex.h | 8
src/mesa/drivers/dri/intel/intel_tex_image.c | 5
src/mesa/drivers/dri/intel/intel_tex_validate.c | 85
src/mesa/drivers/dri/mach64/mach64_span.c | 2
src/mesa/drivers/dri/mga/mgaspan.c | 6
src/mesa/drivers/dri/nouveau/Makefile | 54
src/mesa/drivers/dri/nouveau/nouveau_bufferobj.c | 627 -
src/mesa/drivers/dri/nouveau/nouveau_bufferobj.h | 77
src/mesa/drivers/dri/nouveau/nouveau_card.c | 17
src/mesa/drivers/dri/nouveau/nouveau_card.h | 49
src/mesa/drivers/dri/nouveau/nouveau_card_list.h | 226
src/mesa/drivers/dri/nouveau/nouveau_context.c | 422
src/mesa/drivers/dri/nouveau/nouveau_context.h | 241
src/mesa/drivers/dri/nouveau/nouveau_ctrlreg.h | 44
src/mesa/drivers/dri/nouveau/nouveau_dri.h | 28
src/mesa/drivers/dri/nouveau/nouveau_driver.c | 218
src/mesa/drivers/dri/nouveau/nouveau_driver.h | 42
src/mesa/drivers/dri/nouveau/nouveau_fbo.c | 289
src/mesa/drivers/dri/nouveau/nouveau_fbo.h | 30
src/mesa/drivers/dri/nouveau/nouveau_fifo.c | 153
src/mesa/drivers/dri/nouveau/nouveau_fifo.h | 222
src/mesa/drivers/dri/nouveau/nouveau_lock.c | 81
src/mesa/drivers/dri/nouveau/nouveau_lock.h | 69
src/mesa/drivers/dri/nouveau/nouveau_mem.c | 144
src/mesa/drivers/dri/nouveau/nouveau_mem.h | 23
src/mesa/drivers/dri/nouveau/nouveau_msg.h | 67
src/mesa/drivers/dri/nouveau/nouveau_object.c | 98
src/mesa/drivers/dri/nouveau/nouveau_object.h | 39
src/mesa/drivers/dri/nouveau/nouveau_query.c | 200
src/mesa/drivers/dri/nouveau/nouveau_query.h | 38
src/mesa/drivers/dri/nouveau/nouveau_reg.h | 4998 ----------
src/mesa/drivers/dri/nouveau/nouveau_screen.c | 325
src/mesa/drivers/dri/nouveau/nouveau_screen.h | 61
src/mesa/drivers/dri/nouveau/nouveau_shader.c | 833 -
src/mesa/drivers/dri/nouveau/nouveau_shader.h | 454
src/mesa/drivers/dri/nouveau/nouveau_shader_0.c | 1050 --
src/mesa/drivers/dri/nouveau/nouveau_shader_1.c | 16
src/mesa/drivers/dri/nouveau/nouveau_shader_2.c | 264
src/mesa/drivers/dri/nouveau/nouveau_span.c | 123
src/mesa/drivers/dri/nouveau/nouveau_span.h | 39
src/mesa/drivers/dri/nouveau/nouveau_state.c | 368
src/mesa/drivers/dri/nouveau/nouveau_state.h | 50
src/mesa/drivers/dri/nouveau/nouveau_state_cache.c | 69
src/mesa/drivers/dri/nouveau/nouveau_state_cache.h | 29
src/mesa/drivers/dri/nouveau/nouveau_swtcl.c | 127
src/mesa/drivers/dri/nouveau/nouveau_swtcl.h | 55
src/mesa/drivers/dri/nouveau/nouveau_sync.c | 198
src/mesa/drivers/dri/nouveau/nouveau_sync.h | 69
src/mesa/drivers/dri/nouveau/nouveau_tex.c | 49
src/mesa/drivers/dri/nouveau/nouveau_tex.h | 38
src/mesa/drivers/dri/nouveau/nv04_state.c | 540 -
src/mesa/drivers/dri/nouveau/nv04_swtcl.c | 619 -
src/mesa/drivers/dri/nouveau/nv04_swtcl.h | 12
src/mesa/drivers/dri/nouveau/nv10_state.c | 1009 --
src/mesa/drivers/dri/nouveau/nv10_swtcl.c | 714 -
src/mesa/drivers/dri/nouveau/nv10_swtcl.h | 40
src/mesa/drivers/dri/nouveau/nv20_shader.h | 121
src/mesa/drivers/dri/nouveau/nv20_state.c | 824 -
src/mesa/drivers/dri/nouveau/nv20_vertprog.c | 447
src/mesa/drivers/dri/nouveau/nv30_fragprog.c | 742 -
src/mesa/drivers/dri/nouveau/nv30_shader.h | 379
src/mesa/drivers/dri/nouveau/nv30_state.c | 1002 --
src/mesa/drivers/dri/nouveau/nv30_vertprog.c | 367
src/mesa/drivers/dri/nouveau/nv40_fragprog.c | 224
src/mesa/drivers/dri/nouveau/nv40_shader.h | 467
src/mesa/drivers/dri/nouveau/nv40_vertprog.c | 778 -
src/mesa/drivers/dri/nouveau/nv50_state.c | 641 -
src/mesa/drivers/dri/r128/r128_span.c | 3
src/mesa/drivers/dri/r200/r200_span.c | 2
src/mesa/drivers/dri/r200/r200_tex.c | 64
src/mesa/drivers/dri/r300/r300_cmdbuf.c | 2
src/mesa/drivers/dri/r300/r300_context.c | 1
src/mesa/drivers/dri/r300/r300_context.h | 1
src/mesa/drivers/dri/r300/r300_fragprog.c | 37
src/mesa/drivers/dri/r300/r300_reg.h | 8
src/mesa/drivers/dri/r300/r300_render.c | 15
src/mesa/drivers/dri/r300/r300_state.c | 60
src/mesa/drivers/dri/r300/r300_tex.c | 2
src/mesa/drivers/dri/r300/r300_texstate.c | 7
src/mesa/drivers/dri/r300/r500_fragprog.c | 148
src/mesa/drivers/dri/r300/r500_fragprog_emit.c | 4
src/mesa/drivers/dri/r300/radeon_nqssadce.c | 2
src/mesa/drivers/dri/r300/radeon_program_alu.c | 27
src/mesa/drivers/dri/r300/radeon_program_alu.h | 5
src/mesa/drivers/dri/r300/radeon_program_pair.c | 28
src/mesa/drivers/dri/r300/radeon_span.c | 4
src/mesa/drivers/dri/r300/radeon_state.c | 4
src/mesa/drivers/dri/radeon/radeon_context.h | 2
src/mesa/drivers/dri/radeon/radeon_screen.c | 12
src/mesa/drivers/dri/radeon/radeon_span.c | 4
src/mesa/drivers/dri/radeon/radeon_tex.h | 4
src/mesa/drivers/dri/radeon/radeon_texmem.c | 2
src/mesa/drivers/dri/radeon/radeon_texstate.c | 83
src/mesa/drivers/dri/s3v/s3v_span.c | 6
src/mesa/drivers/dri/savage/savagespan.c | 8
src/mesa/drivers/dri/sis/sis_span.c | 6
src/mesa/drivers/dri/unichrome/via_span.c | 5
src/mesa/drivers/glide/fxddspan.c | 4
src/mesa/drivers/osmesa/Makefile | 2
src/mesa/drivers/x11/Makefile | 1
src/mesa/drivers/x11/xm_tri.c | 192
src/mesa/main/config.h | 1
src/mesa/main/context.c | 3
src/mesa/main/enable.c | 4
src/mesa/main/execmem.c | 2
src/mesa/main/extensions.c | 4
src/mesa/main/fbobject.c | 14
src/mesa/main/get.c | 63
src/mesa/main/get_gen.py | 9
src/mesa/main/getstring.c | 150
src/mesa/main/glheader.h | 6
src/mesa/main/mtypes.h | 4
src/mesa/main/stencil.c | 96
src/mesa/main/texobj.c | 105
src/mesa/main/texstate.c | 1
src/mesa/main/texstore.c | 126
src/mesa/main/varray.c | 5
src/mesa/main/version.h | 2
src/mesa/shader/arbprogram.c | 202
src/mesa/shader/arbprogram.h | 10
src/mesa/shader/prog_execute.c | 2
src/mesa/shader/prog_parameter.c | 32
src/mesa/shader/prog_parameter.h | 2
src/mesa/shader/prog_print.c | 2
src/mesa/shader/prog_statevars.c | 38
src/mesa/shader/prog_statevars.h | 5
src/mesa/shader/program.c | 209
src/mesa/shader/program.h | 18
src/mesa/shader/programopt.c | 12
src/mesa/shader/shader_api.c | 257
src/mesa/shader/slang/library/slang_120_core.gc | 50
src/mesa/shader/slang/library/slang_120_core_gc.h | 1354 +-
src/mesa/shader/slang/library/slang_builtin_120_common_gc.h | 188
src/mesa/shader/slang/library/slang_builtin_120_fragment_gc.h | 2
src/mesa/shader/slang/library/slang_common_builtin.gc | 210
src/mesa/shader/slang/library/slang_common_builtin_gc.h | 1580 +--
src/mesa/shader/slang/library/slang_core.gc | 334
src/mesa/shader/slang/library/slang_core_gc.h | 1589 +--
src/mesa/shader/slang/library/slang_fragment_builtin_gc.h | 190
src/mesa/shader/slang/library/slang_pp_version.syn | 11
src/mesa/shader/slang/library/slang_pp_version_syn.h | 10
src/mesa/shader/slang/library/slang_shader.syn | 94
src/mesa/shader/slang/library/slang_shader_syn.h | 47
src/mesa/shader/slang/library/slang_vertex_builtin_gc.h | 175
src/mesa/shader/slang/slang_builtin.c | 4
src/mesa/shader/slang/slang_codegen.c | 1154 +-
src/mesa/shader/slang/slang_codegen.h | 2
src/mesa/shader/slang/slang_compile.c | 326
src/mesa/shader/slang/slang_compile.h | 4
src/mesa/shader/slang/slang_compile_function.c | 2
src/mesa/shader/slang/slang_compile_operation.c | 33
src/mesa/shader/slang/slang_compile_operation.h | 5
src/mesa/shader/slang/slang_compile_struct.c | 3
src/mesa/shader/slang/slang_compile_struct.h | 13
src/mesa/shader/slang/slang_compile_variable.c | 24
src/mesa/shader/slang/slang_compile_variable.h | 11
src/mesa/shader/slang/slang_emit.c | 561 -
src/mesa/shader/slang/slang_emit.h | 8
src/mesa/shader/slang/slang_ir.c | 94
src/mesa/shader/slang/slang_ir.h | 32
src/mesa/shader/slang/slang_library_noise.c | 2
src/mesa/shader/slang/slang_link.c | 149
src/mesa/shader/slang/slang_log.c | 2
src/mesa/shader/slang/slang_mem.c | 4
src/mesa/shader/slang/slang_mem.h | 2
src/mesa/shader/slang/slang_preprocess.c | 33
src/mesa/shader/slang/slang_print.c | 27
src/mesa/shader/slang/slang_simplify.c | 301
src/mesa/shader/slang/slang_simplify.h | 28
src/mesa/shader/slang/slang_storage.c | 2
src/mesa/shader/slang/slang_typeinfo.c | 130
src/mesa/shader/slang/slang_typeinfo.h | 10
src/mesa/shader/slang/slang_utility.c | 2
src/mesa/shader/slang/slang_vartable.c | 69
src/mesa/swrast/s_blend.c | 7
src/mesa/swrast/s_context.c | 10
src/mesa/swrast/s_fragprog.c | 1
src/mesa/x86/assyntax.h | 3
src/mesa/x86/common_x86.c | 26
300 files changed, 11267 insertions(+), 28123 deletions(-)
New commits:
commit 7c81124d7c4a4d1da9f48cbf7e82ab1a3a970a7a
Author: Dave Airlie <airlied@linux.ie>
Date: Sun Aug 24 17:52:40 2008 +1000
Revert "Merge branch 'drm-gem'"
This reverts commit 53675e5c05c0598b7ea206d5c27dbcae786a2c03.
Conflicts:
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template
index 072d16c..95eeecc 100644
--- a/src/mesa/drivers/dri/Makefile.template
+++ b/src/mesa/drivers/dri/Makefile.template
@@ -10,6 +10,11 @@ COMMON_SOURCES = \
../common/xmlconfig.c \
../common/drirenderbuffer.c
+COMMON_BM_SOURCES = \
+ ../common/dri_bufmgr.c \
+ ../common/dri_bufmgr_fake.c
+
+
ifeq ($(WINDOW_SYSTEM),dri)
WINOBJ=
WINLIB=
diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.c b/src/mesa/drivers/dri/common/dri_bufmgr.c
new file mode 100644
index 0000000..8b5cb76
--- /dev/null
+++ b/src/mesa/drivers/dri/common/dri_bufmgr.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright © 2007 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "mtypes.h"
+#include "dri_bufmgr.h"
+
+/** @file dri_bufmgr.c
+ *
+ * Convenience functions for buffer management methods.
+ */
+
+dri_bo *
+dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
+ unsigned int alignment, uint64_t location_mask)
+{
+ return bufmgr->bo_alloc(bufmgr, name, size, alignment, location_mask);
+}
+
+dri_bo *
+dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name, unsigned long offset,
+ unsigned long size, void *virtual,
+ uint64_t location_mask)
+{
+ return bufmgr->bo_alloc_static(bufmgr, name, offset, size, virtual,
+ location_mask);
+}
+
+void
+dri_bo_reference(dri_bo *bo)
+{
+ bo->bufmgr->bo_reference(bo);
+}
+
+void
+dri_bo_unreference(dri_bo *bo)
+{
+ if (bo == NULL)
+ return;
+
+ bo->bufmgr->bo_unreference(bo);
+}
+
+int
+dri_bo_map(dri_bo *buf, GLboolean write_enable)
+{
+ return buf->bufmgr->bo_map(buf, write_enable);
+}
+
+int
+dri_bo_unmap(dri_bo *buf)
+{
+ return buf->bufmgr->bo_unmap(buf);
+}
+
+void
+dri_fence_wait(dri_fence *fence)
+{
+ fence->bufmgr->fence_wait(fence);
+}
+
+void
+dri_fence_reference(dri_fence *fence)
+{
+ fence->bufmgr->fence_reference(fence);
+}
+
+void
+dri_fence_unreference(dri_fence *fence)
+{
+ if (fence == NULL)
+ return;
+
+ fence->bufmgr->fence_unreference(fence);
+}
+
+void
+dri_bo_subdata(dri_bo *bo, unsigned long offset,
+ unsigned long size, const void *data)
+{
+ if (size == 0 || data == NULL)
+ return;
+
+ dri_bo_map(bo, GL_TRUE);
+ memcpy((unsigned char *)bo->virtual + offset, data, size);
+ dri_bo_unmap(bo);
+}
+
+void
+dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
+ unsigned long size, void *data)
+{
+ if (size == 0 || data == NULL)
+ return;
+
+ dri_bo_map(bo, GL_FALSE);
+ memcpy(data, (unsigned char *)bo->virtual + offset, size);
+ dri_bo_unmap(bo);
+}
+
+void
+dri_bufmgr_destroy(dri_bufmgr *bufmgr)
+{
+ bufmgr->destroy(bufmgr);
+}
+
+
+int dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
+ GLuint offset, dri_bo *target_buf)
+{
+ return reloc_buf->bufmgr->emit_reloc(reloc_buf, flags, delta, offset, target_buf);
+}
+
+void *dri_process_relocs(dri_bo *batch_buf, GLuint *count)
+{
+ return batch_buf->bufmgr->process_relocs(batch_buf, count);
+}
+
+void dri_post_submit(dri_bo *batch_buf, dri_fence **last_fence)
+{
+ batch_buf->bufmgr->post_submit(batch_buf, last_fence);
+}
+
+void
+dri_bufmgr_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug)
+{
+ bufmgr->debug = enable_debug;
+}
+
+int
+dri_bufmgr_check_aperture_space(dri_bo *bo)
+{
+ return bo->bufmgr->check_aperture_space(bo);
+}
diff --git a/src/mesa/drivers/dri/common/dri_bufmgr.h b/src/mesa/drivers/dri/common/dri_bufmgr.h
new file mode 100644
index 0000000..0a726dc
--- /dev/null
+++ b/src/mesa/drivers/dri/common/dri_bufmgr.h
@@ -0,0 +1,260 @@
+/**************************************************************************
+ *
+ * Copyright � 2007 Intel Corporation
+ * Copyright 2006 Tungsten Graphics, 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
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * THE 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
+ * 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.
+ *
+ *
+ **************************************************************************/
+/*
+ * Authors: Thomas Hellstr�thomas-at-tungstengraphics-dot-com>
+ * Keith Whitwell <keithw-at-tungstengraphics-dot-com>
+ * Eric Anholt <eric@anholt.net>
+ */
+
+#ifndef _DRI_BUFMGR_H_
+#define _DRI_BUFMGR_H_
+#include <xf86drm.h>
+
+typedef struct _dri_bufmgr dri_bufmgr;
+typedef struct _dri_bo dri_bo;
+typedef struct _dri_fence dri_fence;
+
+struct _dri_bo {
+ /** Size in bytes of the buffer object. */
+ unsigned long size;
+ /**
+ * Card virtual address (offset from the beginning of the aperture) for the
+ * object. Only valid while validated.
+ */
+ unsigned long offset;
+ /**
+ * Virtual address for accessing the buffer data. Only valid while mapped.
+ */
+ void *virtual;
+ /** Buffer manager context associated with this buffer object */
+ dri_bufmgr *bufmgr;
+};
+
+struct _dri_fence {
+ /**
+ * This is an ORed mask of DRM_BO_FLAG_READ, DRM_BO_FLAG_WRITE, and
+ * DRM_FLAG_EXE indicating the operations associated with this fence.
+ *
+ * It is constant for the life of the fence object.
+ */
+ unsigned int type;
+ /** Buffer manager context associated with this fence */
+ dri_bufmgr *bufmgr;
+};
+
+/**
+ * Context for a buffer manager instance.
+ *
+ * Contains public methods followed by private storage for the buffer manager.
+ */
+struct _dri_bufmgr {
+ /**
+ * Allocate a buffer object.
+ *
+ * Buffer objects are not necessarily initially mapped into CPU virtual
+ * address space or graphics device aperture. They must be mapped using
+ * bo_map() to be used by the CPU, and validated for use using bo_validate()
+ * to be used from the graphics device.
+ */
+ dri_bo *(*bo_alloc)(dri_bufmgr *bufmgr_ctx, const char *name,
+ unsigned long size, unsigned int alignment,
+ uint64_t location_mask);
+
+ /**
+ * Allocates a buffer object for a static allocation.
+ *
+ * Static allocations are ones such as the front buffer that are offered by
+ * the X Server, which are never evicted and never moved.
+ */
+ dri_bo *(*bo_alloc_static)(dri_bufmgr *bufmgr_ctx, const char *name,
+ unsigned long offset, unsigned long size,
+ void *virtual, uint64_t location_mask);
+
+ /** Takes a reference on a buffer object */
+ void (*bo_reference)(dri_bo *bo);
+
+ /**
+ * Releases a reference on a buffer object, freeing the data if
+ * rerefences remain.
+ */
+ void (*bo_unreference)(dri_bo *bo);
+
+ /**
+ * Maps the buffer into userspace.
+ *
+ * This function will block waiting for any existing fence on the buffer to
+ * clear, first. The resulting mapping is available at buf->virtual.
+\ */
+ int (*bo_map)(dri_bo *buf, GLboolean write_enable);
+
+ /** Reduces the refcount on the userspace mapping of the buffer object. */
+ int (*bo_unmap)(dri_bo *buf);
+
+ /** Takes a reference on a fence object */
+ void (*fence_reference)(dri_fence *fence);
+
+ /**
+ * Releases a reference on a fence object, freeing the data if
+ * rerefences remain.
+ */
+ void (*fence_unreference)(dri_fence *fence);
+
+ /**
+ * Blocks until the given fence is signaled.
+ */
+ void (*fence_wait)(dri_fence *fence);
+
+ /**
+ * Tears down the buffer manager instance.
+ */
+ void (*destroy)(dri_bufmgr *bufmgr);
+
+ /**
+ * Add relocation entry in reloc_buf, which will be updated with the
+ * target buffer's real offset on on command submission.
+ *
+ * Relocations remain in place for the lifetime of the buffer object.
+ *
+ * \param reloc_buf Buffer to write the relocation into.
+ * \param flags BO flags to be used in validating the target buffer.
+ * Applicable flags include:
+ * - DRM_BO_FLAG_READ: The buffer will be read in the process of
+ * command execution.
+ * - DRM_BO_FLAG_WRITE: The buffer will be written in the process of
+ * command execution.
+ * - DRM_BO_FLAG_MEM_TT: The buffer should be validated in TT memory.
+ * - DRM_BO_FLAG_MEM_VRAM: The buffer should be validated in video
+ * memory.
+ * \param delta Constant value to be added to the relocation target's offset.
+ * \param offset Byte offset within batch_buf of the relocated pointer.
+ * \param target Buffer whose offset should be written into the relocation
+ * entry.
+ */
+ int (*emit_reloc)(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
+ GLuint offset, dri_bo *target);
+
+ /**
+ * Processes the relocations, either in userland or by converting the list
+ * for use in batchbuffer submission.
+ *
+ * Kernel-based implementations will return a pointer to the arguments
+ * to be handed with batchbuffer submission to the kernel. The userland
+ * implementation performs the buffer validation and emits relocations
+ * into them the appopriate order.
+ *
+ * \param batch_buf buffer at the root of the tree of relocations
+ * \param count returns the number of buffers validated.
+ * \return relocation record for use in command submission.
+ * */
+ void *(*process_relocs)(dri_bo *batch_buf, GLuint *count);
+
+ void (*post_submit)(dri_bo *batch_buf, dri_fence **fence);
+
+ int (*check_aperture_space)(dri_bo *bo);
+ GLboolean debug; /**< Enables verbose debugging printouts */
+};
+
+dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
+ unsigned int alignment, uint64_t location_mask);
+dri_bo *dri_bo_alloc_static(dri_bufmgr *bufmgr, const char *name,
+ unsigned long offset, unsigned long size,
+ void *virtual, uint64_t location_mask);
+void dri_bo_reference(dri_bo *bo);
+void dri_bo_unreference(dri_bo *bo);
+int dri_bo_map(dri_bo *buf, GLboolean write_enable);
+int dri_bo_unmap(dri_bo *buf);
+void dri_fence_wait(dri_fence *fence);
+void dri_fence_reference(dri_fence *fence);
+void dri_fence_unreference(dri_fence *fence);
+
+void dri_bo_subdata(dri_bo *bo, unsigned long offset,
+ unsigned long size, const void *data);
+void dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
+ unsigned long size, void *data);
+
+void dri_bufmgr_fake_contended_lock_take(dri_bufmgr *bufmgr);
+dri_bufmgr *dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
+ unsigned long size,
+ unsigned int (*fence_emit)(void *private),
+ int (*fence_wait)(void *private,
+ unsigned int cookie),
+ void *driver_priv);
+void dri_bufmgr_set_debug(dri_bufmgr *bufmgr, GLboolean enable_debug);
+void dri_bo_fake_disable_backing_store(dri_bo *bo,
+ void (*invalidate_cb)(dri_bo *bo,
+ void *ptr),
+ void *ptr);
+void dri_bufmgr_destroy(dri_bufmgr *bufmgr);
+
+int dri_emit_reloc(dri_bo *reloc_buf, uint64_t flags, GLuint delta,
+ GLuint offset, dri_bo *target_buf);
+void *dri_process_relocs(dri_bo *batch_buf, uint32_t *count);
+void dri_post_process_relocs(dri_bo *batch_buf);
+void dri_post_submit(dri_bo *batch_buf, dri_fence **last_fence);
+int dri_bufmgr_check_aperture_space(dri_bo *bo);
+
+#ifndef TTM_API
+/* reuse some TTM API */
+
+#define DRM_BO_MEM_LOCAL 0
+#define DRM_BO_MEM_TT 1
+#define DRM_BO_MEM_VRAM 2
+#define DRM_BO_MEM_PRIV0 3
+#define DRM_BO_MEM_PRIV1 4
+#define DRM_BO_MEM_PRIV2 5
+#define DRM_BO_MEM_PRIV3 6
+#define DRM_BO_MEM_PRIV4 7
+
+#define DRM_BO_FLAG_READ (1ULL << 0)
+#define DRM_BO_FLAG_WRITE (1ULL << 1)
+#define DRM_BO_FLAG_EXE (1ULL << 2)
+#define DRM_BO_MASK_ACCESS (DRM_BO_FLAG_READ | DRM_BO_FLAG_WRITE | DRM_BO_FLAG_EXE)
+#define DRM_BO_FLAG_NO_EVICT (1ULL << 4)
+
+#define DRM_BO_FLAG_MAPPABLE (1ULL << 5)
+#define DRM_BO_FLAG_SHAREABLE (1ULL << 6)
+
+#define DRM_BO_FLAG_CACHED (1ULL << 7)
+
+#define DRM_BO_FLAG_NO_MOVE (1ULL << 8)
+#define DRM_BO_FLAG_CACHED_MAPPED (1ULL << 19)
+#define DRM_BO_FLAG_FORCE_CACHING (1ULL << 13)
+#define DRM_BO_FLAG_FORCE_MAPPABLE (1ULL << 14)
+#define DRM_BO_FLAG_TILE (1ULL << 15)
+
+#define DRM_BO_FLAG_MEM_LOCAL (1ULL << 24)
+#define DRM_BO_FLAG_MEM_TT (1ULL << 25)
+#define DRM_BO_FLAG_MEM_VRAM (1ULL << 26)
+
+#define DRM_BO_MASK_MEM 0x00000000FF000000ULL
+
+#define DRM_FENCE_TYPE_EXE 0x00000001
+#endif
+
+#endif
diff --git a/src/mesa/drivers/dri/common/dri_bufmgr_fake.c b/src/mesa/drivers/dri/common/dri_bufmgr_fake.c
new file mode 100644
index 0000000..9bf3f34
--- /dev/null
+++ b/src/mesa/drivers/dri/common/dri_bufmgr_fake.c
@@ -0,0 +1,1245 @@
+/**************************************************************************
+ *
+ * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+/* Originally a fake version of the buffer manager so that we can
+ * prototype the changes in a driver fairly quickly, has been fleshed
+ * out to a fully functional interim solution.
+ *
+ * Basically wraps the old style memory management in the new
+ * programming interface, but is more expressive and avoids many of
+ * the bugs in the old texture manager.
+ */
+#include "mtypes.h"
+#include "dri_bufmgr.h"
+#include "drm.h"
+
+#include "simple_list.h"
+#include "mm.h"
+#include "imports.h"
+
+#define DBG(...) do { \
+ if (bufmgr_fake->bufmgr.debug) \
+ _mesa_printf(__VA_ARGS__); \
+} while (0)
+
+/* Internal flags:
+ */
+#define BM_NO_BACKING_STORE 0x00000001
+#define BM_NO_FENCE_SUBDATA 0x00000002
+#define BM_PINNED 0x00000004
+
+/* Wrapper around mm.c's mem_block, which understands that you must
+ * wait for fences to expire before memory can be freed. This is
+ * specific to our use of memcpy for uploads - an upload that was
+ * processed through the command queue wouldn't need to care about
+ * fences.
+ */
+#define MAX_RELOCS 4096
+
+struct fake_buffer_reloc
+{
+ /** Buffer object that the relocation points at. */
+ dri_bo *target_buf;
+ /** Offset of the relocation entry within reloc_buf. */
+ GLuint offset;
+ /** Cached value of the offset when we last performed this relocation. */
+ GLuint last_target_offset;
+ /** Value added to target_buf's offset to get the relocation entry. */
+ GLuint delta;
+ /** Flags to validate the target buffer under. */
+ uint64_t validate_flags;
+};
+
+struct block {
+ struct block *next, *prev;
+ struct mem_block *mem; /* BM_MEM_AGP */
+
+ /**
+ * Marks that the block is currently in the aperture and has yet to be
+ * fenced.
+ */
+ unsigned on_hardware:1;
+ /**
+ * Marks that the block is currently fenced (being used by rendering) and
+ * can't be freed until @fence is passed.
+ */
+ unsigned fenced:1;
+
+ /** Fence cookie for the block. */
+ unsigned fence; /* Split to read_fence, write_fence */
+
+ dri_bo *bo;
+ void *virtual;
+};
+
+typedef struct _bufmgr_fake {
+ dri_bufmgr bufmgr;
+
+ unsigned long low_offset;
+ unsigned long size;
+ void *virtual;
+
+ struct mem_block *heap;
+ struct block lru; /* only allocated, non-fence-pending blocks here */
+
+ unsigned buf_nr; /* for generating ids */
+
+ struct block on_hardware; /* after bmValidateBuffers */
+ struct block fenced; /* after bmFenceBuffers (mi_flush, emit irq, write dword) */
+ /* then to bufmgr->lru or free() */
+
+ unsigned int last_fence;
+
+ unsigned fail:1;
+ unsigned need_fence:1;
+ GLboolean thrashing;
+
+ /**
+ * Driver callback to emit a fence, returning the cookie.
+ *
+ * Currently, this also requires that a write flush be emitted before
+ * emitting the fence, but this should change.
+ */
+ unsigned int (*fence_emit)(void *private);
+ /** Driver callback to wait for a fence cookie to have passed. */
+ int (*fence_wait)(void *private, unsigned int fence_cookie);
+ /** Driver-supplied argument to driver callbacks */
+ void *driver_priv;
+
+ GLboolean debug;
+
+ GLboolean performed_rendering;
+
+ /* keep track of the current total size of objects we have relocs for */
+ unsigned long current_total_size;
+} dri_bufmgr_fake;
+
+typedef struct _dri_bo_fake {
+ dri_bo bo;
+
+ unsigned id; /* debug only */
+ const char *name;
+
+ unsigned dirty:1;
+ unsigned size_accounted:1; /*this buffers size has been accounted against the aperture */
+ unsigned card_dirty:1; /* has the card written to this buffer - we make need to copy it back */
+ unsigned int refcount;
+ /* Flags may consist of any of the DRM_BO flags, plus
+ * DRM_BO_NO_BACKING_STORE and BM_NO_FENCE_SUBDATA, which are the first two
+ * driver private flags.
+ */
+ uint64_t flags;
+ unsigned int alignment;
+ GLboolean is_static, validated;
+ unsigned int map_count;
+
+ /* Flags for the buffer to be validated with in command submission */
+ uint64_t validate_flags;
+
+ /** relocation list */
+ struct fake_buffer_reloc *relocs;
+ GLuint nr_relocs;
+
+ struct block *block;
+ void *backing_store;
+ void (*invalidate_cb)(dri_bo *bo, void *ptr);
+ void *invalidate_ptr;
+} dri_bo_fake;
+
+typedef struct _dri_fence_fake {
+ dri_fence fence;
+
+ const char *name;
+ unsigned int refcount;
+ unsigned int fence_cookie;
+ GLboolean flushed;
+} dri_fence_fake;
+
+static int clear_fenced(dri_bufmgr_fake *bufmgr_fake,
+ unsigned int fence_cookie);
+
+static int dri_fake_check_aperture_space(dri_bo *bo);
+
+#define MAXFENCE 0x7fffffff
+
+static GLboolean FENCE_LTE( unsigned a, unsigned b )
+{
+ if (a == b)
+ return GL_TRUE;
+
+ if (a < b && b - a < (1<<24))
+ return GL_TRUE;
+
+ if (a > b && MAXFENCE - a + b < (1<<24))
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+static unsigned int
+_fence_emit_internal(dri_bufmgr_fake *bufmgr_fake)
+{
+ bufmgr_fake->last_fence = bufmgr_fake->fence_emit(bufmgr_fake->driver_priv);
+ return bufmgr_fake->last_fence;
+}
+
+static void
+_fence_wait_internal(dri_bufmgr_fake *bufmgr_fake, unsigned int cookie)
+{
+ int ret;
+
+ ret = bufmgr_fake->fence_wait(bufmgr_fake->driver_priv, cookie);
+ if (ret != 0) {
+ _mesa_printf("%s:%d: Error %d waiting for fence.\n",
+ __FILE__, __LINE__);
+ abort();
+ }
+ clear_fenced(bufmgr_fake, cookie);
+}
+
+static GLboolean
+_fence_test(dri_bufmgr_fake *bufmgr_fake, unsigned fence)
+{
+ /* Slight problem with wrap-around:
+ */
+ return fence == 0 || FENCE_LTE(fence, bufmgr_fake->last_fence);
+}
+
Reply to: