aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/include/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/include/state_tracker')
-rw-r--r--mesalib/src/gallium/include/state_tracker/drisw_api.h25
-rw-r--r--mesalib/src/gallium/include/state_tracker/drm_driver.h126
-rw-r--r--mesalib/src/gallium/include/state_tracker/graw.h96
-rw-r--r--mesalib/src/gallium/include/state_tracker/st_api.h541
-rw-r--r--mesalib/src/gallium/include/state_tracker/sw_winsys.h146
-rw-r--r--mesalib/src/gallium/include/state_tracker/vdpau_interop.h49
-rw-r--r--mesalib/src/gallium/include/state_tracker/xlibsw_api.h19
7 files changed, 1002 insertions, 0 deletions
diff --git a/mesalib/src/gallium/include/state_tracker/drisw_api.h b/mesalib/src/gallium/include/state_tracker/drisw_api.h
new file mode 100644
index 000000000..328440cf5
--- /dev/null
+++ b/mesalib/src/gallium/include/state_tracker/drisw_api.h
@@ -0,0 +1,25 @@
+#ifndef _DRISW_API_H_
+#define _DRISW_API_H_
+
+#include "pipe/p_compiler.h"
+
+struct pipe_screen;
+struct dri_drawable;
+
+/**
+ * This callback struct is intended for the winsys to call the loader.
+ */
+struct drisw_loader_funcs
+{
+ void (*put_image) (struct dri_drawable *dri_drawable,
+ void *data, unsigned width, unsigned height);
+ void (*put_image2) (struct dri_drawable *dri_drawable,
+ void *data, int x, int y, unsigned width, unsigned height, unsigned stride);
+};
+
+/**
+ * Implemented by the drisw target.
+ */
+struct pipe_screen * drisw_create_screen(struct drisw_loader_funcs *lf);
+
+#endif
diff --git a/mesalib/src/gallium/include/state_tracker/drm_driver.h b/mesalib/src/gallium/include/state_tracker/drm_driver.h
new file mode 100644
index 000000000..740c4bbe1
--- /dev/null
+++ b/mesalib/src/gallium/include/state_tracker/drm_driver.h
@@ -0,0 +1,126 @@
+
+#ifndef _DRM_DRIVER_H_
+#define _DRM_DRIVER_H_
+
+#include "pipe/p_compiler.h"
+
+struct pipe_screen;
+struct pipe_context;
+struct pipe_resource;
+
+#define DRM_API_HANDLE_TYPE_SHARED 0
+#define DRM_API_HANDLE_TYPE_KMS 1
+#define DRM_API_HANDLE_TYPE_FD 2
+
+
+/**
+ * For use with pipe_screen::{texture_from_handle|texture_get_handle}.
+ */
+struct winsys_handle
+{
+ /**
+ * Input for texture_from_handle, valid values are
+ * DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD.
+ * Input to texture_get_handle,
+ * to select handle for kms, flink, or prime.
+ */
+ unsigned type;
+ /**
+ * Input to texture_from_handle.
+ * Output for texture_get_handle.
+ */
+ unsigned handle;
+ /**
+ * Input to texture_from_handle.
+ * Output for texture_get_handle.
+ */
+ unsigned stride;
+};
+
+
+
+/**
+ * Configuration queries.
+ */
+enum drm_conf {
+ /* How many frames to allow before throttling. Or -1 to indicate any number */
+ DRM_CONF_THROTTLE, /* DRM_CONF_INT. */
+ /* Can this driver, running on this kernel, import and export dma-buf fds? */
+ DRM_CONF_SHARE_FD, /* DRM_CONF_BOOL. */
+ DRM_CONF_MAX
+};
+
+/**
+ * Type of configuration answer
+ */
+enum drm_conf_type {
+ DRM_CONF_INT,
+ DRM_CONF_BOOL,
+ DRM_CONF_FLOAT,
+ DRM_CONF_POINTER
+};
+
+/**
+ * Return value from the configuration function.
+ */
+struct drm_conf_ret {
+ enum drm_conf_type type;
+ union {
+ int val_int;
+ bool val_bool;
+ float val_float;
+ void *val_pointer;
+ } val;
+};
+
+struct drm_driver_descriptor
+{
+ /**
+ * Identifying sufix/prefix of the binary, used by egl.
+ */
+ const char *name;
+
+ /**
+ * Kernel driver name, as accepted by drmOpenByName.
+ */
+ const char *driver_name;
+
+ /**
+ * Create a pipe srcreen.
+ *
+ * This function does any wrapping of the screen.
+ * For example wrapping trace or rbug debugging drivers around it.
+ */
+ struct pipe_screen* (*create_screen)(int drm_fd);
+
+
+ /**
+ * Return a configuration value.
+ *
+ * If this function is NULL, or if it returns NULL
+ * the state tracker- or state
+ * tracker manager should provide a reasonable default value.
+ */
+ const struct drm_conf_ret *(*configuration) (enum drm_conf conf);
+};
+
+extern struct drm_driver_descriptor driver_descriptor;
+
+/**
+ * Instantiate a drm_driver_descriptor struct.
+ */
+#define DRM_DRIVER_DESCRIPTOR(name_str, driver_name_str, func, conf) \
+struct drm_driver_descriptor driver_descriptor = { \
+ .name = name_str, \
+ .driver_name = driver_name_str, \
+ .create_screen = func, \
+ .configuration = (conf), \
+};
+
+extern struct pipe_screen *dd_create_screen(int fd);
+
+extern const char *dd_driver_name(void);
+
+extern const struct drm_conf_ret *dd_configuration(enum drm_conf conf);
+
+#endif
diff --git a/mesalib/src/gallium/include/state_tracker/graw.h b/mesalib/src/gallium/include/state_tracker/graw.h
new file mode 100644
index 000000000..217fa31ba
--- /dev/null
+++ b/mesalib/src/gallium/include/state_tracker/graw.h
@@ -0,0 +1,96 @@
+/**************************************************************************
+ *
+ * Copyright 2010 VMware, Inc.
+ * 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 VMWARE 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.
+ *
+ **************************************************************************/
+
+#ifndef GALLIUM_RAW_H
+#define GALLIUM_RAW_H
+
+/* This is an API for exercising gallium functionality in a
+ * platform-neutral fashion. Whatever platform integration is
+ * necessary to implement this interface is orchestrated by the
+ * individual target building this entity.
+ *
+ * For instance, the graw-xlib target includes code to implent these
+ * interfaces on top of the X window system.
+ *
+ * Programs using this interface may additionally benefit from some of
+ * the utilities currently in the libgallium.a library, especially
+ * those for parsing text representations of TGSI shaders.
+ */
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+
+struct pipe_context;
+struct pipe_screen;
+struct pipe_surface;
+
+/* Returns a handle to be used with flush_frontbuffer()/present().
+ *
+ * Query format support with screen::is_format_supported and usage
+ * XXX.
+ */
+PUBLIC struct pipe_screen *graw_create_window_and_screen( int x,
+ int y,
+ unsigned width,
+ unsigned height,
+ enum pipe_format format,
+ void **handle);
+
+PUBLIC void graw_set_display_func( void (*func)( void ) );
+PUBLIC void graw_main_loop( void );
+
+PUBLIC void *graw_parse_geometry_shader( struct pipe_context *pipe,
+ const char *text );
+
+PUBLIC void *graw_parse_vertex_shader( struct pipe_context *pipe,
+ const char *text );
+
+PUBLIC void *graw_parse_fragment_shader( struct pipe_context *pipe,
+ const char *text );
+
+/* Parse a single command-line option, if any. Options include:
+ *
+ * -o <filename>
+ *
+ * If an option has been successfully parsed, argi is updated
+ * to point just after the option and return TRUE.
+ */
+PUBLIC boolean graw_parse_args(int *argi, int argc, char *argv[]);
+
+/* Saves surface contents to a file.
+ *
+ * If filename is NULL, the filename provided with the `-o' option
+ * is used. If the option has not been specified, the surface
+ * will not be saved.
+ *
+ * Returns TRUE if the surface has been saved.
+ */
+PUBLIC boolean graw_save_surface_to_file(struct pipe_context *pipe,
+ struct pipe_surface *surface,
+ const char *filename);
+
+#endif
diff --git a/mesalib/src/gallium/include/state_tracker/st_api.h b/mesalib/src/gallium/include/state_tracker/st_api.h
new file mode 100644
index 000000000..86fdc6988
--- /dev/null
+++ b/mesalib/src/gallium/include/state_tracker/st_api.h
@@ -0,0 +1,541 @@
+/**********************************************************
+ * Copyright 2010 VMware, Inc. 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, sublicense, 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 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
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * 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.
+ *
+ **********************************************************/
+
+
+#ifndef _ST_API_H_
+#define _ST_API_H_
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_format.h"
+
+/**
+ * \file API for communication between state trackers and state tracker
+ * managers.
+ *
+ * While both are state tackers, we use the term state tracker for rendering
+ * APIs such as OpenGL or OpenVG, and state tracker manager for window system
+ * APIs such as EGL or GLX in this file.
+ *
+ * This file defines an API to be implemented by both state trackers and state
+ * tracker managers.
+ */
+
+/**
+ * The supported rendering API of a state tracker.
+ */
+enum st_api_type {
+ ST_API_OPENGL,
+ ST_API_OPENVG,
+
+ ST_API_COUNT
+};
+
+/**
+ * The profile of a context.
+ */
+enum st_profile_type
+{
+ ST_PROFILE_DEFAULT, /**< OpenGL compatibility profile */
+ ST_PROFILE_OPENGL_CORE, /**< OpenGL 3.2+ core profile */
+ ST_PROFILE_OPENGL_ES1, /**< OpenGL ES 1.x */
+ ST_PROFILE_OPENGL_ES2 /**< OpenGL ES 2.0 */
+};
+
+/* for profile_mask in st_api */
+#define ST_PROFILE_DEFAULT_MASK (1 << ST_PROFILE_DEFAULT)
+#define ST_PROFILE_OPENGL_CORE_MASK (1 << ST_PROFILE_OPENGL_CORE)
+#define ST_PROFILE_OPENGL_ES1_MASK (1 << ST_PROFILE_OPENGL_ES1)
+#define ST_PROFILE_OPENGL_ES2_MASK (1 << ST_PROFILE_OPENGL_ES2)
+
+/**
+ * Optional API/state tracker features.
+ */
+enum st_api_feature
+{
+ ST_API_FEATURE_MS_VISUALS /**< support for multisample visuals */
+};
+
+/* for feature_mask in st_api */
+#define ST_API_FEATURE_MS_VISUALS_MASK (1 << ST_API_FEATURE_MS_VISUALS)
+
+/**
+ * New context flags for GL 3.0 and beyond.
+ *
+ * Profile information (core vs. compatibilty for OpenGL 3.2+) is communicated
+ * through the \c st_profile_type, not through flags.
+ */
+#define ST_CONTEXT_FLAG_DEBUG (1 << 0)
+#define ST_CONTEXT_FLAG_FORWARD_COMPATIBLE (1 << 1)
+#define ST_CONTEXT_FLAG_ROBUST_ACCESS (1 << 2)
+
+/**
+ * Reasons that context creation might fail.
+ */
+enum st_context_error {
+ ST_CONTEXT_SUCCESS = 0,
+ ST_CONTEXT_ERROR_NO_MEMORY,
+ ST_CONTEXT_ERROR_BAD_API,
+ ST_CONTEXT_ERROR_BAD_VERSION,
+ ST_CONTEXT_ERROR_BAD_FLAG,
+ ST_CONTEXT_ERROR_UNKNOWN_ATTRIBUTE,
+ ST_CONTEXT_ERROR_UNKNOWN_FLAG
+};
+
+/**
+ * Used in st_context_iface->teximage.
+ */
+enum st_texture_type {
+ ST_TEXTURE_1D,
+ ST_TEXTURE_2D,
+ ST_TEXTURE_3D,
+ ST_TEXTURE_RECT
+};
+
+/**
+ * Available attachments of framebuffer.
+ */
+enum st_attachment_type {
+ ST_ATTACHMENT_FRONT_LEFT,
+ ST_ATTACHMENT_BACK_LEFT,
+ ST_ATTACHMENT_FRONT_RIGHT,
+ ST_ATTACHMENT_BACK_RIGHT,
+ ST_ATTACHMENT_DEPTH_STENCIL,
+ ST_ATTACHMENT_ACCUM,
+ ST_ATTACHMENT_SAMPLE,
+
+ ST_ATTACHMENT_COUNT,
+ ST_ATTACHMENT_INVALID = -1
+};
+
+/* for buffer_mask in st_visual */
+#define ST_ATTACHMENT_FRONT_LEFT_MASK (1 << ST_ATTACHMENT_FRONT_LEFT)
+#define ST_ATTACHMENT_BACK_LEFT_MASK (1 << ST_ATTACHMENT_BACK_LEFT)
+#define ST_ATTACHMENT_FRONT_RIGHT_MASK (1 << ST_ATTACHMENT_FRONT_RIGHT)
+#define ST_ATTACHMENT_BACK_RIGHT_MASK (1 << ST_ATTACHMENT_BACK_RIGHT)
+#define ST_ATTACHMENT_DEPTH_STENCIL_MASK (1 << ST_ATTACHMENT_DEPTH_STENCIL)
+#define ST_ATTACHMENT_ACCUM_MASK (1 << ST_ATTACHMENT_ACCUM)
+#define ST_ATTACHMENT_SAMPLE_MASK (1 << ST_ATTACHMENT_SAMPLE)
+
+/**
+ * Enumerations of state tracker context resources.
+ */
+enum st_context_resource_type {
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_2D,
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_3D,
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_X,
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_X,
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Y,
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_POSITIVE_Z,
+ ST_CONTEXT_RESOURCE_OPENGL_TEXTURE_CUBE_MAP_NEGATIVE_Z,
+ ST_CONTEXT_RESOURCE_OPENGL_RENDERBUFFER,
+ ST_CONTEXT_RESOURCE_OPENVG_PARENT_IMAGE
+};
+
+/**
+ * Flush flags.
+ */
+#define ST_FLUSH_FRONT (1 << 0)
+#define ST_FLUSH_END_OF_FRAME (1 << 1)
+
+/**
+ * Value to st_manager->get_param function.
+ */
+enum st_manager_param {
+ /**
+ * The dri state tracker on old libGL's doesn't do the right thing
+ * with regards to invalidating the framebuffers.
+ *
+ * For the mesa state tracker that means that it needs to invalidate
+ * the framebuffer in glViewport itself.
+ */
+ ST_MANAGER_BROKEN_INVALIDATE
+};
+
+/**
+ * The return type of st_api->get_proc_address.
+ */
+typedef void (*st_proc_t)(void);
+
+struct pipe_context;
+struct pipe_resource;
+struct pipe_fence_handle;
+
+/**
+ * Used in st_context_iface->get_resource_for_egl_image.
+ */
+struct st_context_resource
+{
+ /* these fields are filled in by the caller */
+ enum st_context_resource_type type;
+ void *resource;
+
+ /* this is owned by the caller */
+ struct pipe_resource *texture;
+};
+
+/**
+ * Used in st_manager_iface->get_egl_image.
+ */
+struct st_egl_image
+{
+ /* this is owned by the caller */
+ struct pipe_resource *texture;
+
+ unsigned level;
+ unsigned layer;
+};
+
+/**
+ * Represent the visual of a framebuffer.
+ */
+struct st_visual
+{
+ /**
+ * Available buffers. Tested with ST_FRAMEBUFFER_*_MASK.
+ */
+ unsigned buffer_mask;
+
+ /**
+ * Buffer formats. The formats are always set even when the buffer is
+ * not available.
+ */
+ enum pipe_format color_format;
+ enum pipe_format depth_stencil_format;
+ enum pipe_format accum_format;
+ int samples;
+
+ /**
+ * Desired render buffer.
+ */
+ enum st_attachment_type render_buffer;
+};
+
+
+/**
+ * Configuration options from driconf
+ */
+struct st_config_options
+{
+ boolean disable_blend_func_extended;
+ boolean disable_glsl_line_continuations;
+ boolean disable_shader_bit_encoding;
+ boolean force_glsl_extensions_warn;
+ unsigned force_glsl_version;
+ boolean force_s3tc_enable;
+ boolean allow_glsl_extension_directive_midshader;
+};
+
+/**
+ * Represent the attributes of a context.
+ */
+struct st_context_attribs
+{
+ /**
+ * The profile and minimal version to support.
+ *
+ * The valid profiles and versions are rendering API dependent. The latest
+ * version satisfying the request should be returned.
+ */
+ enum st_profile_type profile;
+ int major, minor;
+
+ /** Mask of ST_CONTEXT_FLAG_x bits */
+ unsigned flags;
+
+ /**
+ * The visual of the framebuffers the context will be bound to.
+ */
+ struct st_visual visual;
+
+ /**
+ * Configuration options.
+ */
+ struct st_config_options options;
+};
+
+struct st_context_iface;
+
+/**
+ * Represent a windowing system drawable.
+ *
+ * The framebuffer is implemented by the state tracker manager and
+ * used by the state trackers.
+ *
+ * Instead of the winsys poking into the API context to figure
+ * out what buffers that might be needed in the future by the API
+ * context, it calls into the framebuffer to get the textures.
+ *
+ * This structure along with the notify_invalid_framebuffer
+ * allows framebuffers to be shared between different threads
+ * but at the same make the API context free from thread
+ * synchronization primitves, with the exception of a small
+ * atomic flag used for notification of framebuffer dirty status.
+ *
+ * The thread synchronization is put inside the framebuffer
+ * and only called once the framebuffer has become dirty.
+ */
+struct st_framebuffer_iface
+{
+ /**
+ * Atomic stamp which changes when framebuffers need to be updated.
+ */
+ int32_t stamp;
+
+ /**
+ * Available for the state tracker manager to use.
+ */
+ void *st_manager_private;
+
+ /**
+ * The visual of a framebuffer.
+ */
+ const struct st_visual *visual;
+
+ /**
+ * Flush the front buffer.
+ *
+ * On some window systems, changes to the front buffers are not immediately
+ * visible. They need to be flushed.
+ *
+ * @att is one of the front buffer attachments.
+ */
+ boolean (*flush_front)(struct st_context_iface *stctx,
+ struct st_framebuffer_iface *stfbi,
+ enum st_attachment_type statt);
+
+ /**
+ * The state tracker asks for the textures it needs.
+ *
+ * It should try to only ask for attachments that it currently renders
+ * to, thus allowing the winsys to delay the allocation of textures not
+ * needed. For example front buffer attachments are not needed if you
+ * only do back buffer rendering.
+ *
+ * The implementor of this function needs to also ensure
+ * thread safty as this call might be done from multiple threads.
+ *
+ * The returned textures are owned by the caller. They should be
+ * unreferenced when no longer used. If this function is called multiple
+ * times with different sets of attachments, those buffers not included in
+ * the last call might be destroyed. This behavior might change in the
+ * future.
+ */
+ boolean (*validate)(struct st_context_iface *stctx,
+ struct st_framebuffer_iface *stfbi,
+ const enum st_attachment_type *statts,
+ unsigned count,
+ struct pipe_resource **out);
+};
+
+/**
+ * Represent a rendering context.
+ *
+ * This entity is created from st_api and used by the state tracker manager.
+ */
+struct st_context_iface
+{
+ /**
+ * Available for the state tracker and the manager to use.
+ */
+ void *st_context_private;
+ void *st_manager_private;
+
+ /**
+ * The CSO context associated with this context in case we need to draw
+ * something before swap buffers.
+ */
+ struct cso_context *cso_context;
+
+ /**
+ * The gallium context.
+ */
+ struct pipe_context *pipe;
+
+ /**
+ * Destroy the context.
+ */
+ void (*destroy)(struct st_context_iface *stctxi);
+
+ /**
+ * Flush all drawing from context to the pipe also flushes the pipe.
+ */
+ void (*flush)(struct st_context_iface *stctxi, unsigned flags,
+ struct pipe_fence_handle **fence);
+
+ /**
+ * Replace the texture image of a texture object at the specified level.
+ *
+ * This function is optional.
+ */
+ boolean (*teximage)(struct st_context_iface *stctxi,
+ enum st_texture_type target,
+ int level, enum pipe_format internal_format,
+ struct pipe_resource *tex, boolean mipmap);
+
+ /**
+ * Used to implement glXCopyContext.
+ */
+ void (*copy)(struct st_context_iface *stctxi,
+ struct st_context_iface *stsrci, unsigned mask);
+
+ /**
+ * Used to implement wglShareLists.
+ */
+ boolean (*share)(struct st_context_iface *stctxi,
+ struct st_context_iface *stsrci);
+
+ /**
+ * Look up and return the info of a resource for EGLImage.
+ *
+ * This function is optional.
+ */
+ boolean (*get_resource_for_egl_image)(struct st_context_iface *stctxi,
+ struct st_context_resource *stres);
+};
+
+
+/**
+ * Represent a state tracker manager.
+ *
+ * This interface is implemented by the state tracker manager. It corresponds
+ * to a "display" in the window system.
+ */
+struct st_manager
+{
+ struct pipe_screen *screen;
+
+ /**
+ * Look up and return the info of an EGLImage.
+ *
+ * This is used to implement for example EGLImageTargetTexture2DOES.
+ * The GLeglImageOES agrument of that call is passed directly to this
+ * function call and the information needed to access this is returned
+ * in the given struct out.
+ *
+ * @smapi: manager owning the caller context
+ * @stctx: caller context
+ * @egl_image: EGLImage that caller recived
+ * @out: return struct filled out with access information.
+ *
+ * This function is optional.
+ */
+ boolean (*get_egl_image)(struct st_manager *smapi,
+ void *egl_image,
+ struct st_egl_image *out);
+
+ /**
+ * Query an manager param.
+ */
+ int (*get_param)(struct st_manager *smapi,
+ enum st_manager_param param);
+};
+
+/**
+ * Represent a rendering API such as OpenGL or OpenVG.
+ *
+ * Implemented by the state tracker and used by the state tracker manager.
+ */
+struct st_api
+{
+ /**
+ * The name of the rendering API. This is informative.
+ */
+ const char *name;
+
+ /**
+ * The supported rendering API.
+ */
+ enum st_api_type api;
+
+ /**
+ * The supported profiles. Tested with ST_PROFILE_*_MASK.
+ */
+ unsigned profile_mask;
+
+ /**
+ * The supported optional features. Tested with ST_FEATURE_*_MASK.
+ */
+ unsigned feature_mask;
+
+ /**
+ * Destroy the API.
+ */
+ void (*destroy)(struct st_api *stapi);
+
+ /**
+ * Query supported OpenGL versions. (if applicable)
+ * The format is (major*10+minor).
+ */
+ void (*query_versions)(struct st_api *stapi, struct st_manager *sm,
+ struct st_config_options *options,
+ int *gl_core_version,
+ int *gl_compat_version,
+ int *gl_es1_version,
+ int *gl_es2_version);
+
+ /**
+ * Return an API entry point.
+ *
+ * For GL this is the same as _glapi_get_proc_address.
+ */
+ st_proc_t (*get_proc_address)(struct st_api *stapi, const char *procname);
+
+ /**
+ * Create a rendering context.
+ */
+ struct st_context_iface *(*create_context)(struct st_api *stapi,
+ struct st_manager *smapi,
+ const struct st_context_attribs *attribs,
+ enum st_context_error *error,
+ struct st_context_iface *stsharei);
+
+ /**
+ * Bind the context to the calling thread with draw and read as drawables.
+ *
+ * The framebuffers might be NULL, or might have different visuals than the
+ * context does.
+ */
+ boolean (*make_current)(struct st_api *stapi,
+ struct st_context_iface *stctxi,
+ struct st_framebuffer_iface *stdrawi,
+ struct st_framebuffer_iface *streadi);
+
+ /**
+ * Get the currently bound context in the calling thread.
+ */
+ struct st_context_iface *(*get_current)(struct st_api *stapi);
+};
+
+/**
+ * Return true if the visual has the specified buffers.
+ */
+static INLINE boolean
+st_visual_have_buffers(const struct st_visual *visual, unsigned mask)
+{
+ return ((visual->buffer_mask & mask) == mask);
+}
+
+#endif /* _ST_API_H_ */
diff --git a/mesalib/src/gallium/include/state_tracker/sw_winsys.h b/mesalib/src/gallium/include/state_tracker/sw_winsys.h
new file mode 100644
index 000000000..a3479eb0b
--- /dev/null
+++ b/mesalib/src/gallium/include/state_tracker/sw_winsys.h
@@ -0,0 +1,146 @@
+/**************************************************************************
+ *
+ * Copyright 2007-2009 VMware, Inc.
+ * 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 VMWARE 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.
+ *
+ **************************************************************************/
+
+/**
+ * @file
+ * Software rasterizer winsys.
+ */
+
+
+#ifndef SW_WINSYS_H
+#define SW_WINSYS_H
+
+
+#include "pipe/p_compiler.h" /* for boolean */
+#include "pipe/p_format.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct winsys_handle;
+struct pipe_screen;
+struct pipe_context;
+struct pipe_resource;
+struct pipe_box;
+
+/**
+ * Opaque pointer.
+ */
+struct sw_displaytarget;
+
+
+/**
+ * This is the interface that sw expects any window system
+ * hosting it to implement.
+ *
+ * sw is for the most part a self sufficient driver. The only thing it
+ * does not know is how to display a surface.
+ */
+struct sw_winsys
+{
+ void
+ (*destroy)( struct sw_winsys *ws );
+
+ boolean
+ (*is_displaytarget_format_supported)( struct sw_winsys *ws,
+ unsigned tex_usage,
+ enum pipe_format format );
+
+ /**
+ * Allocate storage for a render target.
+ *
+ * Often surfaces which are meant to be blitted to the front screen (i.e.,
+ * display targets) must be allocated with special characteristics, memory
+ * pools, or obtained directly from the windowing system.
+ *
+ * This callback is invoked by the pipe_screen when creating a texture marked
+ * with the PIPE_BIND_DISPLAY_TARGET flag to get the underlying
+ * storage.
+ */
+ struct sw_displaytarget *
+ (*displaytarget_create)( struct sw_winsys *ws,
+ unsigned tex_usage,
+ enum pipe_format format,
+ unsigned width, unsigned height,
+ unsigned alignment,
+ unsigned *stride );
+
+ /**
+ * Used to implement texture_from_handle.
+ */
+ struct sw_displaytarget *
+ (*displaytarget_from_handle)( struct sw_winsys *ws,
+ const struct pipe_resource *templat,
+ struct winsys_handle *whandle,
+ unsigned *stride );
+
+ /**
+ * Used to implement texture_get_handle.
+ */
+ boolean
+ (*displaytarget_get_handle)( struct sw_winsys *ws,
+ struct sw_displaytarget *dt,
+ struct winsys_handle *whandle );
+
+ /**
+ * \param flags bitmask of PIPE_TRANSFER_x flags
+ */
+ void *
+ (*displaytarget_map)( struct sw_winsys *ws,
+ struct sw_displaytarget *dt,
+ unsigned flags );
+
+ void
+ (*displaytarget_unmap)( struct sw_winsys *ws,
+ struct sw_displaytarget *dt );
+
+ /**
+ * @sa pipe_screen:flush_frontbuffer.
+ *
+ * This call will likely become asynchronous eventually.
+ */
+ void
+ (*displaytarget_display)( struct sw_winsys *ws,
+ struct sw_displaytarget *dt,
+ void *context_private,
+ struct pipe_box *box );
+
+ void
+ (*displaytarget_destroy)( struct sw_winsys *ws,
+ struct sw_displaytarget *dt );
+};
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* SW_WINSYS_H */
diff --git a/mesalib/src/gallium/include/state_tracker/vdpau_interop.h b/mesalib/src/gallium/include/state_tracker/vdpau_interop.h
new file mode 100644
index 000000000..3ca7c9d4a
--- /dev/null
+++ b/mesalib/src/gallium/include/state_tracker/vdpau_interop.h
@@ -0,0 +1,49 @@
+/**************************************************************************
+ *
+ * Copyright 2013 Advanced Micro Devices, Inc.
+ * 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 THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ **************************************************************************/
+
+/*
+ * Authors:
+ * Christian König <christian.koenig@amd.com>
+ *
+ */
+
+#ifndef _VDPAU_INTEROP_H_
+#define _VDPAU_INTEROP_H_
+
+/* driver specific functions for NV_vdpau_interop */
+
+#define VDP_FUNC_ID_BASE_DRIVER 0x2000
+#define VDP_FUNC_ID_VIDEO_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 0)
+#define VDP_FUNC_ID_OUTPUT_SURFACE_GALLIUM (VDP_FUNC_ID_BASE_DRIVER + 1)
+
+struct pipe_resource;
+struct pipe_video_buffer;
+
+typedef struct pipe_video_buffer *VdpVideoSurfaceGallium(uint32_t surface);
+typedef struct pipe_resource *VdpOutputSurfaceGallium(uint32_t surface);
+
+#endif /* _VDPAU_INTEROP_H_ */
diff --git a/mesalib/src/gallium/include/state_tracker/xlibsw_api.h b/mesalib/src/gallium/include/state_tracker/xlibsw_api.h
new file mode 100644
index 000000000..930127981
--- /dev/null
+++ b/mesalib/src/gallium/include/state_tracker/xlibsw_api.h
@@ -0,0 +1,19 @@
+#ifndef XLIB_SW_WINSYS_H
+#define XLIB_SW_WINSYS_H
+
+#include "state_tracker/sw_winsys.h"
+#include <X11/Xlib.h>
+
+
+/* This is what the xlib software winsys expects to find in the
+ * "private" field of flush_frontbuffers().
+ *
+ * Xlib-based state trackers somehow need to know this.
+ */
+struct xlib_drawable {
+ Visual *visual;
+ int depth;
+ Drawable drawable;
+};
+
+#endif