i965: Drop trailing whitespace from the rest of the driver.
[mesa.git] / src / mesa / drivers / dri / i965 / intel_buffer_objects.h
1 /**************************************************************************
2 *
3 * Copyright 2005 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28 #ifndef INTEL_BUFFEROBJ_H
29 #define INTEL_BUFFEROBJ_H
30
31 #include "main/mtypes.h"
32
33 struct brw_context;
34 struct gl_buffer_object;
35
36
37 /**
38 * Intel vertex/pixel buffer object, derived from Mesa's gl_buffer_object.
39 */
40 struct intel_buffer_object
41 {
42 struct gl_buffer_object Base;
43 drm_intel_bo *buffer; /* the low-level buffer manager's buffer handle */
44
45 drm_intel_bo *range_map_bo;
46 void *range_map_buffer;
47 unsigned int range_map_offset;
48
49 /** @{
50 * Tracking for what range of the BO may currently be in use by the GPU.
51 *
52 * Users often want to either glBufferSubData() or glMapBufferRange() a
53 * buffer object where some subset of it is busy on the GPU, without either
54 * stalling or doing an extra blit (since our blits are extra expensive,
55 * given that we have to reupload most of the 3D state when switching
56 * rings). We wish they'd just use glMapBufferRange() with the
57 * UNSYNC|INVALIDATE_RANGE flag or the INVALIDATE_BUFFER flag, but lots
58 * don't.
59 *
60 * To work around apps, we track what range of the BO we might have used on
61 * the GPU as vertex data, tranform feedback output, buffer textures, etc.,
62 * and just do glBufferSubData() with an unsynchronized map when they're
63 * outside of that range.
64 *
65 * If gpu_active_start > gpu_active_end, then the GPU is not currently
66 * accessing the BO (and we can map it without synchronization).
67 */
68 uint32_t gpu_active_start;
69 uint32_t gpu_active_end;
70
71 /**
72 * If we've avoided stalls/blits using the active tracking, flag the buffer
73 * for (occasional) stalling in the future to avoid getting stuck in a
74 * cycle of blitting on buffer wraparound.
75 */
76 bool prefer_stall_to_blit;
77 /** @} */
78 };
79
80
81 /* Get the bm buffer associated with a GL bufferobject:
82 */
83 drm_intel_bo *intel_bufferobj_buffer(struct brw_context *brw,
84 struct intel_buffer_object *obj,
85 uint32_t offset,
86 uint32_t size);
87
88 void intel_upload_data(struct brw_context *brw,
89 const void *ptr, GLuint size, GLuint align,
90 drm_intel_bo **return_bo,
91 GLuint *return_offset);
92
93 void *intel_upload_map(struct brw_context *brw,
94 GLuint size, GLuint align);
95 void intel_upload_unmap(struct brw_context *brw,
96 const void *ptr, GLuint size, GLuint align,
97 drm_intel_bo **return_bo,
98 GLuint *return_offset);
99
100 void intel_upload_finish(struct brw_context *brw);
101
102 /* Hook the bufferobject implementation into mesa:
103 */
104 void intelInitBufferObjectFuncs(struct dd_function_table *functions);
105
106 static inline struct intel_buffer_object *
107 intel_buffer_object(struct gl_buffer_object *obj)
108 {
109 return (struct intel_buffer_object *) obj;
110 }
111
112 #endif