p_screen.h revision d9d82dcd006c124e6569789c90390c43c1360c06
1/************************************************************************** 2 * 3 * Copyright 2007 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/** 29 * @file 30 * 31 * Screen, Adapter or GPU 32 * 33 * These are driver functions/facilities that are context independent. 34 */ 35 36 37#ifndef P_SCREEN_H 38#define P_SCREEN_H 39 40 41#include "pipe/p_compiler.h" 42#include "pipe/p_format.h" 43#include "pipe/p_defines.h" 44#include "pipe/p_video_enums.h" 45 46 47 48#ifdef __cplusplus 49extern "C" { 50#endif 51 52 53/** Opaque type */ 54struct winsys_handle; 55/** Opaque type */ 56struct pipe_fence_handle; 57struct pipe_resource; 58struct pipe_surface; 59struct pipe_transfer; 60 61 62/** 63 * Gallium screen/adapter context. Basically everything 64 * hardware-specific that doesn't actually require a rendering 65 * context. 66 */ 67struct pipe_screen { 68 void (*destroy)( struct pipe_screen * ); 69 70 71 const char *(*get_name)( struct pipe_screen * ); 72 73 const char *(*get_vendor)( struct pipe_screen * ); 74 75 /** 76 * Query an integer-valued capability/parameter/limit 77 * \param param one of PIPE_CAP_x 78 */ 79 int (*get_param)( struct pipe_screen *, enum pipe_cap param ); 80 81 /** 82 * Query a float-valued capability/parameter/limit 83 * \param param one of PIPE_CAP_x 84 */ 85 float (*get_paramf)( struct pipe_screen *, enum pipe_capf param ); 86 87 /** 88 * Query a per-shader-stage integer-valued capability/parameter/limit 89 * \param param one of PIPE_CAP_x 90 */ 91 int (*get_shader_param)( struct pipe_screen *, unsigned shader, enum pipe_shader_cap param ); 92 93 /** 94 * Query an integer-valued capability/parameter/limit for a codec/profile 95 * \param param one of PIPE_VIDEO_CAP_x 96 */ 97 int (*get_video_param)( struct pipe_screen *, 98 enum pipe_video_profile profile, 99 enum pipe_video_cap param ); 100 101 /** 102 * Query a compute-specific capability/parameter/limit. 103 * \param param one of PIPE_COMPUTE_CAP_x 104 * \param ret pointer to a preallocated buffer that will be 105 * initialized to the parameter value, or NULL. 106 * \return size in bytes of the parameter value that would be 107 * returned. 108 */ 109 int (*get_compute_param)(struct pipe_screen *, 110 enum pipe_compute_cap param, 111 void *ret); 112 113 struct pipe_context * (*context_create)( struct pipe_screen *, 114 void *priv ); 115 116 /** 117 * Check if the given pipe_format is supported as a texture or 118 * drawing surface. 119 * \param bindings bitmask of PIPE_BIND_* 120 */ 121 boolean (*is_format_supported)( struct pipe_screen *, 122 enum pipe_format format, 123 enum pipe_texture_target target, 124 unsigned sample_count, 125 unsigned bindings ); 126 127 /** 128 * Check if the given pipe_format is supported as output for this codec/profile. 129 * \param profile profile to check, may also be PIPE_VIDEO_PROFILE_UNKNOWN 130 */ 131 boolean (*is_video_format_supported)( struct pipe_screen *, 132 enum pipe_format format, 133 enum pipe_video_profile profile ); 134 135 /** 136 * Create a new texture object, using the given template info. 137 */ 138 struct pipe_resource * (*resource_create)(struct pipe_screen *, 139 const struct pipe_resource *templat); 140 141 /** 142 * Create a texture from a winsys_handle. The handle is often created in 143 * another process by first creating a pipe texture and then calling 144 * resource_get_handle. 145 */ 146 struct pipe_resource * (*resource_from_handle)(struct pipe_screen *, 147 const struct pipe_resource *templat, 148 struct winsys_handle *handle); 149 150 /** 151 * Get a winsys_handle from a texture. Some platforms/winsys requires 152 * that the texture is created with a special usage flag like 153 * DISPLAYTARGET or PRIMARY. 154 */ 155 boolean (*resource_get_handle)(struct pipe_screen *, 156 struct pipe_resource *tex, 157 struct winsys_handle *handle); 158 159 160 void (*resource_destroy)(struct pipe_screen *, 161 struct pipe_resource *pt); 162 163 164 /** 165 * Create a buffer that wraps user-space data. 166 * 167 * Effectively this schedules a delayed call to buffer_create 168 * followed by an upload of the data at *some point in the future*, 169 * or perhaps never. Basically the allocate/upload is delayed 170 * until the buffer is actually passed to hardware. 171 * 172 * The intention is to provide a quick way to turn regular data 173 * into a buffer, and secondly to avoid a copy operation if that 174 * data subsequently turns out to be only accessed by the CPU. 175 * 176 * Common example is OpenGL vertex buffers that are subsequently 177 * processed either by software TNL in the driver or by passing to 178 * hardware. 179 * 180 * XXX: What happens if the delayed call to buffer_create() fails? 181 * 182 * Note that ptr may be accessed at any time upto the time when the 183 * buffer is destroyed, so the data must not be freed before then. 184 */ 185 struct pipe_resource *(*user_buffer_create)(struct pipe_screen *screen, 186 void *ptr, 187 unsigned bytes, 188 unsigned bind_flags); 189 190 /** 191 * Do any special operations to ensure frontbuffer contents are 192 * displayed, eg copy fake frontbuffer. 193 * \param winsys_drawable_handle an opaque handle that the calling context 194 * gets out-of-band 195 */ 196 void (*flush_frontbuffer)( struct pipe_screen *screen, 197 struct pipe_resource *resource, 198 unsigned level, unsigned layer, 199 void *winsys_drawable_handle ); 200 201 202 203 /** Set ptr = fence, with reference counting */ 204 void (*fence_reference)( struct pipe_screen *screen, 205 struct pipe_fence_handle **ptr, 206 struct pipe_fence_handle *fence ); 207 208 /** 209 * Checks whether the fence has been signalled. 210 */ 211 boolean (*fence_signalled)( struct pipe_screen *screen, 212 struct pipe_fence_handle *fence ); 213 214 /** 215 * Wait for the fence to finish. 216 * \param timeout in nanoseconds 217 */ 218 boolean (*fence_finish)( struct pipe_screen *screen, 219 struct pipe_fence_handle *fence, 220 uint64_t timeout ); 221 222}; 223 224 225#ifdef __cplusplus 226} 227#endif 228 229#endif /* P_SCREEN_H */ 230