nvfx: expose GLSL
[mesa/mesa-lb.git] / src / gallium / drivers / i915 / intel_winsys.h
blob00fd0c1efea4a1135aa74dd941240a93068061ca
1 /**************************************************************************
3 * Copyright © 2009 Jakob Bornecrantz
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 **************************************************************************/
26 #ifndef INTEL_WINSYS_H
27 #define INTEL_WINSYS_H
29 #include "pipe/p_compiler.h"
31 struct intel_winsys;
32 struct intel_buffer;
33 struct intel_batchbuffer;
34 struct pipe_texture;
35 struct pipe_fence_handle;
36 struct winsys_handle;
38 enum intel_buffer_usage
40 /* use on textures */
41 INTEL_USAGE_RENDER = 0x01,
42 INTEL_USAGE_SAMPLER = 0x02,
43 INTEL_USAGE_2D_TARGET = 0x04,
44 INTEL_USAGE_2D_SOURCE = 0x08,
45 /* use on vertex */
46 INTEL_USAGE_VERTEX = 0x10
49 enum intel_buffer_type
51 INTEL_NEW_TEXTURE,
52 INTEL_NEW_SCANOUT, /**< a texture used for scanning out from */
53 INTEL_NEW_VERTEX
56 enum intel_buffer_tile
58 INTEL_TILE_NONE,
59 INTEL_TILE_X,
60 INTEL_TILE_Y
63 struct intel_batchbuffer {
65 struct intel_winsys *iws;
67 /**
68 * Values exported to speed up the writing the batchbuffer,
69 * instead of having to go trough a accesor function for
70 * each dword written.
72 /*{@*/
73 uint8_t *map;
74 uint8_t *ptr;
75 size_t size;
77 size_t relocs;
78 size_t max_relocs;
79 /*@}*/
82 struct intel_winsys {
84 /**
85 * Batchbuffer functions.
87 /*@{*/
88 /**
89 * Create a new batchbuffer.
91 struct intel_batchbuffer *(*batchbuffer_create)(struct intel_winsys *iws);
93 /**
94 * Emit a relocation to a buffer.
95 * Target position in batchbuffer is the same as ptr.
97 * @batch
98 * @reloc buffer address to be inserted into target.
99 * @usage how is the hardware going to use the buffer.
100 * @offset add this to the reloc buffers address
101 * @target buffer where to write the address, null for batchbuffer.
103 int (*batchbuffer_reloc)(struct intel_batchbuffer *batch,
104 struct intel_buffer *reloc,
105 enum intel_buffer_usage usage,
106 unsigned offset);
109 * Flush a bufferbatch.
111 void (*batchbuffer_flush)(struct intel_batchbuffer *batch,
112 struct pipe_fence_handle **fence);
115 * Destroy a batchbuffer.
117 void (*batchbuffer_destroy)(struct intel_batchbuffer *batch);
118 /*@}*/
122 * Buffer functions.
124 /*@{*/
126 * Create a buffer.
128 struct intel_buffer *(*buffer_create)(struct intel_winsys *iws,
129 unsigned size, unsigned alignment,
130 enum intel_buffer_type type);
133 * Creates a buffer from a handle.
134 * Used to implement pipe_screen::texture_from_handle.
135 * Also provides the stride information needed for the
136 * texture via the stride argument.
138 struct intel_buffer *(*buffer_from_handle)(struct intel_winsys *iws,
139 struct winsys_handle *whandle,
140 unsigned *stride);
143 * Used to implement pipe_screen::texture_get_handle.
144 * The winsys might need the stride information.
146 boolean (*buffer_get_handle)(struct intel_winsys *iws,
147 struct intel_buffer *buffer,
148 struct winsys_handle *whandle,
149 unsigned stride);
152 * Fence a buffer with a fence reg.
153 * Not to be confused with pipe_fence_handle.
155 int (*buffer_set_fence_reg)(struct intel_winsys *iws,
156 struct intel_buffer *buffer,
157 unsigned stride,
158 enum intel_buffer_tile tile);
161 * Map a buffer.
163 void *(*buffer_map)(struct intel_winsys *iws,
164 struct intel_buffer *buffer,
165 boolean write);
168 * Unmap a buffer.
170 void (*buffer_unmap)(struct intel_winsys *iws,
171 struct intel_buffer *buffer);
174 * Write to a buffer.
176 * Arguments follows pipe_buffer_write.
178 int (*buffer_write)(struct intel_winsys *iws,
179 struct intel_buffer *dst,
180 size_t offset,
181 size_t size,
182 const void *data);
184 void (*buffer_destroy)(struct intel_winsys *iws,
185 struct intel_buffer *buffer);
186 /*@}*/
190 * Fence functions.
192 /*@{*/
194 * Reference fence and set ptr to fence.
196 void (*fence_reference)(struct intel_winsys *iws,
197 struct pipe_fence_handle **ptr,
198 struct pipe_fence_handle *fence);
201 * Check if a fence has finished.
203 int (*fence_signalled)(struct intel_winsys *iws,
204 struct pipe_fence_handle *fence);
207 * Wait on a fence to finish.
209 int (*fence_finish)(struct intel_winsys *iws,
210 struct pipe_fence_handle *fence);
211 /*@}*/
215 * Destroy the winsys.
217 void (*destroy)(struct intel_winsys *iws);
222 * Create i915 pipe_screen.
224 struct pipe_screen *i915_create_screen(struct intel_winsys *iws, unsigned pci_id);
227 #endif