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 **************************************************************************/
28 #ifndef BRW_RESOURCE_H
29 #define BRW_RESOURCE_H
33 #include "util/u_transfer.h"
34 #include "util/u_debug.h"
36 #include "brw_screen.h" /* for brw_surface */
45 /* One of either bo or user_buffer will be non-null, depending on
46 * whether this is a hardware or user buffer.
48 struct brw_winsys_buffer
*bo
;
56 #define BRW_MAX_TEXTURE_2D_LEVELS 11 /* max 1024x1024 */
57 #define BRW_MAX_TEXTURE_3D_LEVELS 8 /* max 128x128x128 */
63 struct brw_winsys_buffer
*bo
;
64 struct brw_surface_state ss
;
66 unsigned *image_offset
[BRW_MAX_TEXTURE_2D_LEVELS
];
67 unsigned nr_images
[BRW_MAX_TEXTURE_2D_LEVELS
];
68 unsigned level_offset
[BRW_MAX_TEXTURE_2D_LEVELS
];
75 unsigned total_height
;
77 struct brw_surface views
[2];
81 void brw_init_screen_resource_functions(struct brw_screen
*is
);
82 void brw_init_resource_functions(struct brw_context
*brw
);
84 extern struct u_resource_vtbl brw_buffer_vtbl
;
85 extern struct u_resource_vtbl brw_texture_vtbl
;
87 static INLINE
struct brw_texture
*brw_texture( struct pipe_resource
*resource
)
89 struct brw_texture
*tex
= (struct brw_texture
*)resource
;
90 assert(tex
->b
.vtbl
== &brw_texture_vtbl
);
94 static INLINE
struct brw_buffer
*brw_buffer( struct pipe_resource
*resource
)
96 struct brw_buffer
*tex
= (struct brw_buffer
*)resource
;
97 assert(tex
->b
.vtbl
== &brw_buffer_vtbl
);
101 struct pipe_resource
*
102 brw_texture_create(struct pipe_screen
*screen
,
103 const struct pipe_resource
*template);
105 struct pipe_resource
*
106 brw_texture_from_handle(struct pipe_screen
* screen
,
107 const struct pipe_resource
*template,
108 struct winsys_handle
*whandle
);
111 struct pipe_resource
*
112 brw_user_buffer_create(struct pipe_screen
*screen
,
117 struct pipe_resource
*
118 brw_buffer_create(struct pipe_screen
*screen
,
119 const struct pipe_resource
*template);
124 brw_is_format_supported( struct pipe_screen *screen,
125 enum pipe_format format,
126 enum pipe_texture_target target,
127 unsigned sample_count,
129 unsigned geom_flags );
132 /* Pipe buffer helpers
134 static INLINE boolean
135 brw_buffer_is_user_buffer( const struct pipe_resource
*buf
)
137 return ((const struct brw_buffer
*)buf
)->user_buffer
!= NULL
;
141 /***********************************************************************
144 GLboolean
brw_texture_layout(struct brw_screen
*brw_screen
,
145 struct brw_texture
*tex
);
147 void brw_update_texture( struct brw_screen
*brw_screen
,
148 struct brw_texture
*tex
);
152 #endif /* BRW_RESOURCE_H */