1 /**************************************************************************
3 * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
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:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
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.
26 **************************************************************************/
31 #include "pipe/p_state.h"
32 #include "pipe/p_screen.h"
35 #include "brw_structs.h"
37 struct brw_winsys_screen;
41 * Subclass of pipe_screen
45 struct pipe_screen base;
46 struct brw_chipset chipset;
47 struct brw_winsys_screen *sws;
52 * Subclass of pipe_transfer
56 struct pipe_transfer base;
63 struct pipe_buffer base;
65 /* One of either bo or user_buffer will be non-null, depending on
66 * whether this is a hardware or user buffer.
68 struct brw_winsys_buffer *bo;
77 union brw_surface_id {
89 struct pipe_surface base;
91 union brw_surface_id id;
97 struct brw_surface_state ss;
98 struct brw_winsys_buffer *bo;
99 struct brw_surface *next, *prev;
103 #define BRW_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */
104 #define BRW_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */
109 struct pipe_texture base;
110 struct brw_winsys_buffer *bo;
111 struct brw_surface_state ss;
113 unsigned *image_offset[BRW_MAX_TEXTURE_2D_LEVELS];
114 unsigned nr_images[BRW_MAX_TEXTURE_2D_LEVELS];
115 unsigned level_offset[BRW_MAX_TEXTURE_2D_LEVELS];
122 unsigned total_height;
124 struct brw_surface views[2];
132 static INLINE struct brw_screen *
133 brw_screen(struct pipe_screen *pscreen)
135 return (struct brw_screen *) pscreen;
138 static INLINE struct brw_transfer *
139 brw_transfer(struct pipe_transfer *transfer)
141 return (struct brw_transfer *)transfer;
144 static INLINE struct brw_surface *
145 brw_surface(struct pipe_surface *surface)
147 return (struct brw_surface *)surface;
150 static INLINE struct brw_buffer *
151 brw_buffer(struct pipe_buffer *buffer)
153 return (struct brw_buffer *)buffer;
156 static INLINE struct brw_texture *
157 brw_texture(struct pipe_texture *texture)
159 return (struct brw_texture *)texture;
163 /* Pipe buffer helpers
165 static INLINE boolean
166 brw_buffer_is_user_buffer( const struct pipe_buffer *buf )
168 return ((const struct brw_buffer *)buf)->user_buffer != NULL;
172 brw_surface_pitch( const struct pipe_surface *surface );
174 /***********************************************************************
177 GLboolean brw_texture_layout(struct brw_screen *brw_screen,
178 struct brw_texture *tex );
180 void brw_update_texture( struct brw_screen *brw_screen,
181 struct brw_texture *tex );
184 /* brw_screen_texture.h
187 void brw_tex_init( struct brw_context *brw );
188 void brw_screen_tex_init( struct brw_screen *brw_screen );
189 void brw_screen_tex_surface_init( struct brw_screen *brw_screen );
191 void brw_screen_buffer_init(struct brw_screen *brw_screen);
194 boolean brw_is_texture_referenced_by_bo( struct brw_screen *brw_screen,
195 struct pipe_texture *texture,
198 struct brw_winsys_buffer *bo );
200 boolean brw_is_buffer_referenced_by_bo( struct brw_screen *brw_screen,
201 struct pipe_buffer *buffer,
202 struct brw_winsys_buffer *bo );
206 #endif /* BRW_SCREEN_H */