#ifndef _ST_API_H_
#define _ST_API_H_
-#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
/**
*/
enum st_api_type {
ST_API_OPENGL,
- ST_API_OPENGL_ES1,
- ST_API_OPENGL_ES2,
ST_API_OPENVG,
ST_API_COUNT
*/
enum st_profile_type
{
- ST_PROFILE_DEFAULT,
- ST_PROFILE_OPENGL_CORE,
- ST_PROFILE_OPENGL_ES1,
- ST_PROFILE_OPENGL_ES2
+ 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_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)
+#define ST_CONTEXT_FLAG_RESET_NOTIFICATION_ENABLED (1 << 3)
+#define ST_CONTEXT_FLAG_NO_ERROR (1 << 4)
+#define ST_CONTEXT_FLAG_RELEASE_NONE (1 << 5)
+#define ST_CONTEXT_FLAG_HIGH_PRIORITY (1 << 6)
+#define ST_CONTEXT_FLAG_LOW_PRIORITY (1 << 7)
+
+/**
+ * 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.
*/
#define ST_ATTACHMENT_SAMPLE_MASK (1 << ST_ATTACHMENT_SAMPLE)
/**
- * Enumerations of state tracker context resources.
+ * Flush flags.
*/
-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
-};
+#define ST_FLUSH_FRONT (1 << 0)
+#define ST_FLUSH_END_OF_FRAME (1 << 1)
+#define ST_FLUSH_WAIT (1 << 2)
+#define ST_FLUSH_FENCE_FD (1 << 3)
/**
* Value to st_manager->get_param function.
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 by the caller */
- enum st_context_resource_type type;
- void *resource;
-
- /* this is owned by the caller */
- struct pipe_resource *texture;
-};
+struct util_queue_monitoring;
/**
* Used in st_manager_iface->get_egl_image.
/* this is owned by the caller */
struct pipe_resource *texture;
- unsigned face;
+ /* format only differs from texture->format for multi-planar (YUV): */
+ enum pipe_format format;
+
unsigned level;
- unsigned zslice;
+ unsigned layer;
+ /* GL internal format. */
+ unsigned internalformat;
};
/**
*/
struct st_visual
{
+ bool no_config;
+
/**
- * Available buffers. Tested with ST_FRAMEBUFFER_*_MASK.
+ * Available buffers. Bitfield of ST_ATTACHMENT_*_MASK bits.
*/
unsigned buffer_mask;
enum pipe_format color_format;
enum pipe_format depth_stencil_format;
enum pipe_format accum_format;
- int samples;
+ unsigned samples;
/**
* Desired render buffer.
enum st_attachment_type render_buffer;
};
+
+/**
+ * Configuration options from driconf
+ */
+struct st_config_options
+{
+ bool disable_blend_func_extended;
+ bool disable_glsl_line_continuations;
+ bool disable_arb_gpu_shader5;
+ bool force_glsl_extensions_warn;
+ unsigned force_glsl_version;
+ bool allow_glsl_extension_directive_midshader;
+ bool allow_glsl_builtin_const_expression;
+ bool allow_glsl_relaxed_es;
+ bool allow_glsl_builtin_variable_redeclaration;
+ bool allow_higher_compat_version;
+ bool glsl_zero_init;
+ bool vs_position_always_invariant;
+ bool force_glsl_abs_sqrt;
+ bool allow_glsl_cross_stage_interpolation_mismatch;
+ bool allow_glsl_layout_qualifier_on_function_parameters;
+ char *force_gl_vendor;
+ unsigned char config_options_sha1[20];
+};
+
/**
* Represent the attributes of a context.
*/
* 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, unless
- * forward_compatiible is true.
+ * version satisfying the request should be returned.
*/
enum st_profile_type profile;
int major, minor;
- /**
- * Enable debugging.
- */
- boolean debug;
+ /** Mask of ST_CONTEXT_FLAG_x bits */
+ unsigned flags;
/**
- * Return the exact version and disallow the use of deprecated features.
+ * The visual of the framebuffers the context will be bound to.
*/
- boolean forward_compatible;
+ struct st_visual visual;
/**
- * The visual of the framebuffers the context will be bound to.
+ * Configuration options.
*/
- struct st_visual visual;
+ struct st_config_options options;
};
+struct st_context_iface;
+struct st_manager;
+
/**
* Represent a windowing system drawable.
*
* The framebuffer is implemented by the state tracker manager and
* used by the state trackers.
*
- * Instead of the winsys pokeing into the API context to figure
+ * 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
- * syncronisation primitves, with the exception of a small
+ * synchronization primitves, with the exception of a small
* atomic flag used for notification of framebuffer dirty status.
*
- * The thread syncronisation is put inside the framebuffer
+ * 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;
+
+ /**
+ * Identifier that uniquely identifies the framebuffer interface object.
+ */
+ uint32_t ID;
+
+ /**
+ * The state tracker manager that manages this object.
+ */
+ struct st_manager *state_manager;
+
/**
* Available for the state tracker manager to use.
*/
*
* @att is one of the front buffer attachments.
*/
- boolean (*flush_front)(struct st_framebuffer_iface *stfbi,
- enum st_attachment_type statt);
+ bool (*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.
* the last call might be destroyed. This behavior might change in the
* future.
*/
- boolean (*validate)(struct st_framebuffer_iface *stfbi,
- const enum st_attachment_type *statts,
- unsigned count,
- struct pipe_resource **out);
+ bool (*validate)(struct st_context_iface *stctx,
+ struct st_framebuffer_iface *stfbi,
+ const enum st_attachment_type *statts,
+ unsigned count,
+ struct pipe_resource **out);
+ bool (*flush_swapbuffers) (struct st_context_iface *stctx,
+ struct st_framebuffer_iface *stfbi);
};
/**
void *st_manager_private;
/**
- * Destroy the context.
+ * The state tracker manager that manages this object.
*/
- void (*destroy)(struct st_context_iface *stctxi);
+ struct st_manager *state_manager;
/**
- * Invalidate the current textures that was taken from a framebuffer.
- *
- * The state tracker manager calls this function to let the rendering
- * context know that it should update the textures it got from
- * st_framebuffer_iface::validate. It should do so at the latest time possible.
- * Possible right before sending triangles to the pipe context.
- *
- * For certain platforms this function might be called from a thread other
- * than the thread that the context is currently bound in, and must
- * therefore be thread safe. But it is the state tracker manager's
- * responsibility to make sure that the framebuffer is bound to the context
- * and the API context is current for the duration of this call.
- *
- * Thus reducing the sync primitive needed to a single atomic flag.
+ * The CSO context associated with this context in case we need to draw
+ * something before swap buffers.
*/
- void (*notify_invalid_framebuffer)(struct st_context_iface *stctxi,
- struct st_framebuffer_iface *stfbi);
+ 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);
+ struct pipe_fence_handle **fence,
+ void (*notify_before_flush_cb) (void*),
+ void* notify_before_flush_cb_args);
+
+ /**
+ * Flush all enqueued vertices (e.g. vbo module) and call
+ * pipe_context::flush_resource.
+ */
+ void (*flush_resource)(struct st_context_iface *stctxi,
+ struct pipe_resource *resource);
/**
* 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);
+ bool (*teximage)(struct st_context_iface *stctxi,
+ enum st_texture_type target,
+ int level, enum pipe_format internal_format,
+ struct pipe_resource *tex, bool mipmap);
/**
* Used to implement glXCopyContext.
struct st_context_iface *stsrci, unsigned mask);
/**
- * Look up and return the info of a resource for EGLImage.
- *
- * This function is optional.
+ * Used to implement wglShareLists.
+ */
+ bool (*share)(struct st_context_iface *stctxi,
+ struct st_context_iface *stsrci);
+
+ /**
+ * Start the thread if the API has a worker thread.
+ * Called after the context has been created and fully initialized on both
+ * sides (e.g. st/mesa and st/dri).
+ */
+ void (*start_thread)(struct st_context_iface *stctxi);
+
+ /**
+ * If the API is multithreaded, wait for all queued commands to complete.
+ * Called from the main thread.
*/
- boolean (*get_resource_for_egl_image)(struct st_context_iface *stctxi,
- struct st_context_resource *stres);
+ void (*thread_finish)(struct st_context_iface *stctxi);
};
*
* This function is optional.
*/
- boolean (*get_egl_image)(struct st_manager *smapi,
- struct st_context_iface *stctx,
- void *egl_image,
- struct st_egl_image *out);
+ bool (*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);
+
+ /**
+ * Call the loader function setBackgroundContext. Called from the worker
+ * thread.
+ */
+ void (*set_background_context)(struct st_context_iface *stctxi,
+ struct util_queue_monitoring *queue_info);
+
+ /**
+ * Destroy any private data used by the state tracker manager.
+ */
+ void (*destroy)(struct st_manager *smapi);
+
+ /**
+ * Available for the state tracker manager to use.
+ */
+ void *st_manager_private;
};
/**
*/
struct st_api
{
+ /**
+ * The name of the rendering API. This is informative.
+ */
+ const char *name;
+
/**
* The supported rendering API.
*/
*/
unsigned profile_mask;
+ /**
+ * The supported optional features. Tested with ST_FEATURE_*_MASK.
+ */
+ unsigned feature_mask;
+
/**
* Destroy the API.
*/
void (*destroy)(struct st_api *stapi);
/**
- * Return an API entry point.
- *
- * For GL this is the same as _glapi_get_proc_address.
+ * Query supported OpenGL versions. (if applicable)
+ * The format is (major*10+minor).
*/
- st_proc_t (*get_proc_address)(struct st_api *stapi, const char *procname);
+ 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);
/**
* 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);
/**
* 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);
+ bool (*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);
+
+ /**
+ * Notify the st manager the framebuffer interface object
+ * is no longer valid.
+ */
+ void (*destroy_drawable)(struct st_api *stapi,
+ struct st_framebuffer_iface *stfbi);
};
/**
* Return true if the visual has the specified buffers.
*/
-static INLINE boolean
+static inline bool
st_visual_have_buffers(const struct st_visual *visual, unsigned mask)
{
return ((visual->buffer_mask & mask) == mask);
}
-/* these symbols may need to be dynamically lookup up */
-extern PUBLIC struct st_api * st_api_create_OpenGL(void);
-extern PUBLIC struct st_api * st_api_create_OpenGL_ES1(void);
-extern PUBLIC struct st_api * st_api_create_OpenGL_ES2(void);
-extern PUBLIC struct st_api * st_api_create_OpenVG(void);
-
-/**
- * The entry points of the state trackers.
- */
-#define ST_CREATE_OPENGL_SYMBOL "st_api_create_OpenGL"
-#define ST_CREATE_OPENGL_ES1_SYMBOL "st_api_create_OpenGL_ES1"
-#define ST_CREATE_OPENGL_ES2_SYMBOL "st_api_create_OpenGL_ES2"
-#define ST_CREATE_OPENVG_SYMBOL "st_api_create_OpenVG"
-
#endif /* _ST_API_H_ */