mesa/src/gallium/include/pipe/p_screen.h

299 lines
10 KiB
C
Raw Normal View History

/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sub license, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
/**
2008-09-19 10:40:42 +09:00
* @file
*
* Screen, Adapter or GPU
*
* These are driver functions/facilities that are context independent.
*/
#ifndef P_SCREEN_H
#define P_SCREEN_H
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#include "pipe/p_defines.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Opaque type */
struct winsys_handle;
/** Opaque type */
struct pipe_fence_handle;
struct pipe_winsys;
struct pipe_buffer;
struct pipe_texture;
struct pipe_surface;
struct pipe_video_surface;
struct pipe_transfer;
/**
* Gallium screen/adapter context. Basically everything
* hardware-specific that doesn't actually require a rendering
* context.
*/
struct pipe_screen {
struct pipe_winsys *winsys;
void (*destroy)( struct pipe_screen * );
const char *(*get_name)( struct pipe_screen * );
const char *(*get_vendor)( struct pipe_screen * );
/**
* Query an integer-valued capability/parameter/limit
* \param param one of PIPE_CAP_x
*/
int (*get_param)( struct pipe_screen *, int param );
/**
* Query a float-valued capability/parameter/limit
* \param param one of PIPE_CAP_x
*/
float (*get_paramf)( struct pipe_screen *, int param );
gallium: squash-merge of gallium screen context Squashed commit of the following: commit 009598122adf5cad42bf9af067eccaf8e89e1233 Author: Christoph Bumiller <e0425955@student.tuwien.ac.at> Date: Mon Feb 8 11:03:26 2010 +0000 nouveau: fix gallium-screen-context branch fallout commit 7b2ffc2019d72e833afea7eebf3e80121187375d Merge: 51e190e c036d13 Author: Keith Whitwell <keithw@vmware.com> Date: Fri Feb 5 09:55:02 2010 +0000 Merge commit 'origin/master' into gallium-screen-context Conflicts: src/gallium/winsys/drm/nouveau/drm/nouveau_drm_api.c This branch has got a pretty tortured history now, I expect a squash merge will be appropriate when it is done. commit 51e190e95acf120f72768fafb29e9721e358df1b Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 17:58:02 2010 +0000 gallium: fix some build issues commit f524bdaa723fb181637ad30c6ad708aeedabe25b Merge: f906212 3aba0a2 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 17:51:32 2010 +0000 Merge commit 'origin/master' into gallium-screen-context commit f9062126883199eabf045714c717cd35f4b7b313 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 17:17:12 2010 +0000 gallium/docs: small description of screen::create_context commit efcb37bd3d5ed37f06c6105bd2d750b374ec0927 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:42:42 2010 +0000 drm/radeon: more dead create_context wrapper removal commit 6badc0dd9e06cf2ec936940bcf12b9ef5324b301 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:42:30 2010 +0000 drm/i965: more dead create_context wrapper removal commit cf04ebd5a54b18b2d894cfdab2b0f2fd55626ffc Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:42:05 2010 +0000 st/python: more dead create_context wrapper removal commit 444f114c3516abf71c430e6e9d0d2ae3b80679d3 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:37:58 2010 +0000 idenity: wrapped context creation commit 5a6d09cb9e468d1ee6c8d54b887618819d8d94f2 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:28:47 2010 +0000 ws/gdi: remove dead context_create wrapper commit 132b55f4bec39386ac625f09aaa11f609664024c Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:27:52 2010 +0000 ws/gdi: remove dead context_create wrapper commit 56d2d21a0cdcb197a364049d354c2f15a4fc026a Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:25:38 2010 +0000 st/xorg: use screen::context_create commit 838c5cfe56b2af6c644909bed3c5e7cdd64c336a Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:23:20 2010 +0000 glx/xlib: simplify creation of trace-wrapped contexts Trace screen knows how to properly wrap context creation in the wrapped screen, so nothing special to do here. commit c99404c03ebaec4175f08a2f363e43c9085f2635 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:18:24 2010 +0000 st/python: no need to special case context creation for trace commit 193a527a682b6877bb1faecd8092df4dfd055a18 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:15:30 2010 +0000 drm/radeon: remove dead create_context declaration commit bb984eecc25cf23bc77e1c818b81165ba1a07c9a Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:14:58 2010 +0000 nv/drm: remove dead create_context ref commit e809313a44287dc4e16c28e9e74ef3b2b5271aa1 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:12:51 2010 +0000 st/egl: remove a layer of wrappers around screen::create_context commit 39caa6672a04122f185c22e17aab86d1c40938bf Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:05:28 2010 +0000 r300g: fill in screen::context_create commit 407f12556d16ba0656774d8a1d9ebda22f82f473 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 16:04:04 2010 +0000 cell: adapt for screen::create_context, untested commit d02b0c6ce321a04c76fdabb09e0e4380ce1c1376 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:50:24 2010 +0000 drm/nv: adapt for screen::create_context All contexts now created directly through the screen, so remove equivalent code here. Remove apparently un-needed array of contexts in the winsys. commit 53eec5b1349aa1b6892a75a7bff7e7530957aeae Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:50:08 2010 +0000 stw: adapt for screen::create_context, untested commit c6a64de3eb381bc9a88e9fbdecbf87d77925aaf5 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:49:20 2010 +0000 trace: expose the wrapped context's priv data If we are going to keep this priv idea, really want an accessor function for it so that trace and other drivers can wrap that. commit 75d6104e11d86ec2b0749627ed58e35f856ee6eb Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:47:55 2010 +0000 nv30: adapt to screen::context_create commit 12f5deb6ed9723e9b5d34577052b8365813ca14e Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:44:47 2010 +0000 nv40: adapt to screen::context_create commit 14baccaa3b6bbb3b91056126f6521828e786dc62 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:35:27 2010 +0000 nv50: adapt to screen::create_context Not build tested. Need to figure out how to build nouveau. commit a0e94505ccd2d7f3e604465a2ac302f1286b73b6 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:22:27 2010 +0000 llvmpipe: update for screen::create_context, untested commit 0eae17107c950346030e4f7e0ec232f868d3893d Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 15:16:57 2010 +0000 xlib/llvmpipe: remove dead winsys context creation path commit 2f69f9ffaa7e2a01d2483277246ed13051ae4ca3 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 14:58:27 2010 +0000 gallium: convert most code to use screen::create_context I wish I could build all of gallium at once to find breakages. commit d7b57f4061b82322cbcae176125913d9f0dea6c1 Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 12:46:21 2010 +0000 glx: permit building with older protocol headers I'd like to be able to build mesa on current distro releases without having to upgrade from the standard dri2proto and glproto headers. With this change I'm able to build on ancient releases such as Ubuntu 9-10... In general, it would be nice to be able to build-test mesa to check for unintended breakages without having to follow the external dependencies of every group working on the codebase. commit 57adedd6fb06c98572ed8d4aef19203df4c4eea2 Merge: da71847 e1906ae Author: Keith Whitwell <keithw@vmware.com> Date: Thu Feb 4 11:38:15 2010 +0000 Merge commit 'origin/master' into gallium-screen-context Conflicts: src/gallium/drivers/softpipe/sp_video_context.h src/gallium/drivers/trace/tr_context.c src/gallium/state_trackers/wgl/shared/stw_context.c src/gallium/winsys/gdi/gdi_softpipe_winsys.c commit da71847ea6414d7e352c6094f8963bb4eda344dc Author: José Fonseca <jfonseca@vmware.com> Date: Sat May 2 08:57:39 2009 +0100 wgl: Use pipe_screen::context_create. commit 2595a188f93fd903600ef5d8517737ee0592035d Author: José Fonseca <jfonseca@vmware.com> Date: Sat May 2 08:56:47 2009 +0100 trace: Implement pipe_screen::context_create. commit f3640e4ae37a5260cbfba999d079f827de0a313a Author: José Fonseca <jfonseca@vmware.com> Date: Sat May 2 08:56:17 2009 +0100 softpipe: Implement pipe_screen::context_create. commit 347266bddc8bd39c711bacb2193793759d0f3696 Author: José Fonseca <jfonseca@vmware.com> Date: Sat May 2 08:55:31 2009 +0100 gallium: New pipe_screen::context_create callback.
2010-02-08 12:55:59 +00:00
struct pipe_context * (*context_create)( struct pipe_screen *,
void *priv );
/**
* Check if the given pipe_format is supported as a texture or
* drawing surface.
* \param tex_usage bitmask of PIPE_TEXTURE_USAGE_*
* \param geom_flags bitmask of PIPE_TEXTURE_GEOM_*
*/
boolean (*is_format_supported)( struct pipe_screen *,
enum pipe_format format,
enum pipe_texture_target target,
unsigned tex_usage,
unsigned geom_flags );
/**
* Create a new texture object, using the given template info.
*/
struct pipe_texture * (*texture_create)(struct pipe_screen *,
const struct pipe_texture *templat);
/**
* Create a texture from a winsys_handle. The handle is often created in
* another process by first creating a pipe texture and then calling
* texture_get_handle.
*/
struct pipe_texture * (*texture_from_handle)(struct pipe_screen *,
const struct pipe_texture *templat,
struct winsys_handle *handle);
/**
* Get a winsys_handle from a texture. Some platforms/winsys requires
* that the texture is created with a special usage flag like
* DISPLAYTARGET or PRIMARY.
*/
boolean (*texture_get_handle)(struct pipe_screen *,
struct pipe_texture *tex,
struct winsys_handle *handle);
void (*texture_destroy)(struct pipe_texture *pt);
2010-02-24 08:59:49 -07:00
/** Get a 2D surface which is a "view" into a texture
* \param usage bitmaks of PIPE_BUFFER_USAGE_* read/write flags
*/
struct pipe_surface *(*get_tex_surface)(struct pipe_screen *,
struct pipe_texture *texture,
unsigned face, unsigned level,
2008-05-01 11:07:21 +01:00
unsigned zslice,
unsigned usage );
void (*tex_surface_destroy)(struct pipe_surface *);
2008-05-01 11:07:21 +01:00
/**
* Create a new buffer.
* \param alignment buffer start address alignment in bytes
* \param usage bitmask of PIPE_BUFFER_USAGE_x
* \param size size in bytes
*/
struct pipe_buffer *(*buffer_create)( struct pipe_screen *screen,
unsigned alignment,
unsigned usage,
unsigned size );
/**
* Create a buffer that wraps user-space data.
*
* Effectively this schedules a delayed call to buffer_create
* followed by an upload of the data at *some point in the future*,
* or perhaps never. Basically the allocate/upload is delayed
* until the buffer is actually passed to hardware.
*
* The intention is to provide a quick way to turn regular data
* into a buffer, and secondly to avoid a copy operation if that
* data subsequently turns out to be only accessed by the CPU.
*
* Common example is OpenGL vertex buffers that are subsequently
* processed either by software TNL in the driver or by passing to
* hardware.
*
* XXX: What happens if the delayed call to buffer_create() fails?
*
* Note that ptr may be accessed at any time upto the time when the
* buffer is destroyed, so the data must not be freed before then.
*/
struct pipe_buffer *(*user_buffer_create)(struct pipe_screen *screen,
void *ptr,
unsigned bytes);
/**
* Map the entire data store of a buffer object into the client's address.
* flags is bitmask of PIPE_BUFFER_USAGE_CPU_READ/WRITE flags.
*/
void *(*buffer_map)( struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned usage );
/**
* Map a subrange of the buffer data store into the client's address space.
*
* The returned pointer is always relative to buffer start, regardless of
* the specified range. This is different from the ARB_map_buffer_range
* semantics because we don't forbid multiple mappings of the same buffer
* (yet).
*/
void *(*buffer_map_range)( struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned offset,
unsigned length,
unsigned usage);
/**
* Notify a range that was actually written into.
*
* Can only be used if the buffer was mapped with the
* PIPE_BUFFER_USAGE_CPU_WRITE and PIPE_BUFFER_USAGE_FLUSH_EXPLICIT flags
* set.
*
* The range is relative to the buffer start, regardless of the range
* specified to buffer_map_range. This is different from the
* ARB_map_buffer_range semantics because we don't forbid multiple mappings
* of the same buffer (yet).
*
*/
void (*buffer_flush_mapped_range)( struct pipe_screen *screen,
struct pipe_buffer *buf,
unsigned offset,
unsigned length);
/**
* Unmap buffer.
*
* If the buffer was mapped with PIPE_BUFFER_USAGE_CPU_WRITE flag but not
* PIPE_BUFFER_USAGE_FLUSH_EXPLICIT then the pipe driver will
* assume that the whole buffer was written. This is mostly for backward
* compatibility purposes and may affect performance -- the state tracker
* should always specify exactly what got written while the buffer was
* mapped.
*/
void (*buffer_unmap)( struct pipe_screen *screen,
struct pipe_buffer *buf );
void (*buffer_destroy)( struct pipe_buffer *buf );
/**
* Create a video surface suitable for use as a decoding target by the
* driver's pipe_video_context.
*/
struct pipe_video_surface*
(*video_surface_create)( struct pipe_screen *screen,
enum pipe_video_chroma_format chroma_format,
unsigned width, unsigned height );
void (*video_surface_destroy)( struct pipe_video_surface *vsfc );
/**
* Do any special operations to ensure buffer size is correct
* \param context_private the private data of the calling context
*/
void (*update_buffer)( struct pipe_screen *ws,
void *context_private );
/**
* Do any special operations to ensure frontbuffer contents are
* displayed, eg copy fake frontbuffer.
* \param winsys_drawable_handle an opaque handle that the calling context
* gets out-of-band
*/
void (*flush_frontbuffer)( struct pipe_screen *screen,
struct pipe_surface *surf,
void *winsys_drawable_handle );
/** Set ptr = fence, with reference counting */
void (*fence_reference)( struct pipe_screen *screen,
struct pipe_fence_handle **ptr,
struct pipe_fence_handle *fence );
/**
* Checks whether the fence has been signalled.
* \param flags driver-specific meaning
* \return zero on success.
*/
int (*fence_signalled)( struct pipe_screen *screen,
struct pipe_fence_handle *fence,
2009-04-09 21:26:15 +01:00
unsigned flags );
/**
* Wait for the fence to finish.
* \param flags driver-specific meaning
* \return zero on success.
*/
int (*fence_finish)( struct pipe_screen *screen,
struct pipe_fence_handle *fence,
2009-04-09 21:26:15 +01:00
unsigned flags );
};
#ifdef __cplusplus
}
#endif
#endif /* P_SCREEN_H */