diff options
author | Marek Olšák <[email protected]> | 2019-12-03 18:01:31 -0500 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2020-05-13 13:46:53 -0400 |
commit | d6287a94b697ffe12a4e576a38943cdf4e90cdb0 (patch) | |
tree | bb84357d98dc74412e983693e09875bb355b467e /src/gallium/include/frontend | |
parent | b408734e5e2fe1e1ef08080c4425ad8a7ed33579 (diff) |
gallium: rename 'state tracker' to 'frontend'
Acked-by: Eric Anholt <[email protected]>
Acked-by: Alyssa Rosenzweig <[email protected]>
Acked-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4902>
Diffstat (limited to 'src/gallium/include/frontend')
-rw-r--r-- | src/gallium/include/frontend/api.h | 575 | ||||
-rw-r--r-- | src/gallium/include/frontend/drisw_api.h | 27 | ||||
-rw-r--r-- | src/gallium/include/frontend/drm_driver.h | 49 | ||||
-rw-r--r-- | src/gallium/include/frontend/graw.h | 96 | ||||
-rw-r--r-- | src/gallium/include/frontend/opencl_interop.h | 40 | ||||
-rw-r--r-- | src/gallium/include/frontend/sw_driver.h | 21 | ||||
-rw-r--r-- | src/gallium/include/frontend/sw_winsys.h | 145 | ||||
-rw-r--r-- | src/gallium/include/frontend/vdpau_dmabuf.h | 94 | ||||
-rw-r--r-- | src/gallium/include/frontend/vdpau_funcs.h | 65 | ||||
-rw-r--r-- | src/gallium/include/frontend/vdpau_interop.h | 54 | ||||
-rw-r--r-- | src/gallium/include/frontend/winsys_handle.h | 69 | ||||
-rw-r--r-- | src/gallium/include/frontend/xlibsw_api.h | 19 |
12 files changed, 1254 insertions, 0 deletions
diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h new file mode 100644 index 00000000000..5bcb8d9fea6 --- /dev/null +++ b/src/gallium/include/frontend/api.h @@ -0,0 +1,575 @@ +/********************************************************** + * 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 _API_H_ +#define _API_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) +#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. + */ +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) + +/** + * Flush flags. + */ +#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. + */ +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 +}; + +struct pipe_context; +struct pipe_resource; +struct pipe_fence_handle; +struct util_queue_monitoring; + +/** + * Used in st_manager_iface->get_egl_image. + */ +struct st_egl_image +{ + /* this is owned by the caller */ + struct pipe_resource *texture; + + /* format only differs from texture->format for multi-planar (YUV): */ + enum pipe_format format; + + unsigned level; + unsigned layer; + /* GL internal format. */ + unsigned internalformat; +}; + +/** + * Represent the visual of a framebuffer. + */ +struct st_visual +{ + bool no_config; + + /** + * Available buffers. Bitfield of ST_ATTACHMENT_*_MASK bits. + */ + 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; + 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; + bool allow_draw_out_of_order; + bool force_integer_tex_nearest; + char *force_gl_vendor; + unsigned char config_options_sha1[20]; +}; + +/** + * 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; +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 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; + + /** + * 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. + */ + 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. + */ + 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. + * + * 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. + */ + 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); +}; + +/** + * 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 state tracker manager that manages this object. + */ + struct st_manager *state_manager; + + /** + * 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, + void (*notify_before_flush_cb) (void*), + void* notify_before_flush_cb_args); + + /** + * Replace the texture image of a texture object at the specified level. + * + * This function is optional. + */ + 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. + */ + void (*copy)(struct st_context_iface *stctxi, + struct st_context_iface *stsrci, unsigned mask); + + /** + * 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. + */ + void (*thread_finish)(struct st_context_iface *stctxi); +}; + + +/** + * 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. + */ + 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; +}; + +/** + * 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); + + /** + * 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. + */ + 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 bool +st_visual_have_buffers(const struct st_visual *visual, unsigned mask) +{ + return ((visual->buffer_mask & mask) == mask); +} + +#endif /* _API_H_ */ diff --git a/src/gallium/include/frontend/drisw_api.h b/src/gallium/include/frontend/drisw_api.h new file mode 100644 index 00000000000..4b5d36c1797 --- /dev/null +++ b/src/gallium/include/frontend/drisw_api.h @@ -0,0 +1,27 @@ +#ifndef _DRISW_API_H_ +#define _DRISW_API_H_ + +#include "pipe/p_compiler.h" +#include "sw_winsys.h" + +struct pipe_screen; +struct dri_drawable; + +/** + * This callback struct is intended for the winsys to call the loader. + */ +struct drisw_loader_funcs +{ + void (*get_image) (struct dri_drawable *dri_drawable, + int x, int y, unsigned width, unsigned height, unsigned stride, + void *data); + 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); + void (*put_image_shm) (struct dri_drawable *dri_drawable, + int shmid, char *shmaddr, unsigned offset, unsigned offset_x, + int x, int y, unsigned width, unsigned height, unsigned stride); +}; + +#endif diff --git a/src/gallium/include/frontend/drm_driver.h b/src/gallium/include/frontend/drm_driver.h new file mode 100644 index 00000000000..f8d77a79721 --- /dev/null +++ b/src/gallium/include/frontend/drm_driver.h @@ -0,0 +1,49 @@ + +#ifndef _DRM_DRIVER_H_ +#define _DRM_DRIVER_H_ + +#include "pipe/p_compiler.h" + +#include "winsys_handle.h" + +struct pipe_screen; +struct pipe_screen_config; +struct pipe_context; +struct pipe_resource; + +struct drm_driver_descriptor +{ + /** + * Identifying prefix/suffix of the binary, used by the pipe-loader. + */ + const char *driver_name; + + /** + * Pointer to the XML string describing driver-specific driconf options. + * Use DRI_CONF_* macros to create the string. + */ + const char **driconf_xml; + + /** + * 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, + const struct pipe_screen_config *config); +}; + +extern const struct drm_driver_descriptor driver_descriptor; + +/** + * Instantiate a drm_driver_descriptor struct. + */ +#define DRM_DRIVER_DESCRIPTOR(driver_name_str, driconf, func) \ +const struct drm_driver_descriptor driver_descriptor = { \ + .driver_name = driver_name_str, \ + .driconf_xml = driconf, \ + .create_screen = func, \ +}; + +#endif diff --git a/src/gallium/include/frontend/graw.h b/src/gallium/include/frontend/graw.h new file mode 100644 index 00000000000..af81cc8871b --- /dev/null +++ b/src/gallium/include/frontend/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 implement 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 bool 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 bool graw_save_surface_to_file(struct pipe_context *pipe, + struct pipe_surface *surface, + const char *filename); + +#endif diff --git a/src/gallium/include/frontend/opencl_interop.h b/src/gallium/include/frontend/opencl_interop.h new file mode 100644 index 00000000000..498364472b6 --- /dev/null +++ b/src/gallium/include/frontend/opencl_interop.h @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2015 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. + * + **************************************************************************/ + +#ifndef OPENCL_INTEROP_H +#define OPENCL_INTEROP_H + +/* dlsym these without the "_t" suffix. You should get the correct symbols + * if the OpenCL driver is loaded. + */ + +typedef bool (*opencl_dri_event_add_ref_t)(void *cl_event); +typedef bool (*opencl_dri_event_release_t)(void *cl_event); +typedef bool (*opencl_dri_event_wait_t)(void *cl_event, uint64_t timeout); +typedef struct pipe_fence_handle *(*opencl_dri_event_get_fence_t)(void *cl_event); + +#endif /* OPENCL_INTEROP_H */ diff --git a/src/gallium/include/frontend/sw_driver.h b/src/gallium/include/frontend/sw_driver.h new file mode 100644 index 00000000000..1d59bd5fe56 --- /dev/null +++ b/src/gallium/include/frontend/sw_driver.h @@ -0,0 +1,21 @@ + +#ifndef _SW_DRIVER_H_ +#define _SW_DRIVER_H_ + +#include "pipe/p_compiler.h" + +struct pipe_screen; +struct sw_winsys; + +struct sw_driver_descriptor +{ + struct pipe_screen *(*create_screen)(struct sw_winsys *ws); + struct { + const char * const name; + struct sw_winsys *(*create_winsys)(); + } winsys[]; +}; + +extern const struct sw_driver_descriptor swrast_driver_descriptor; + +#endif diff --git a/src/gallium/include/frontend/sw_winsys.h b/src/gallium/include/frontend/sw_winsys.h new file mode 100644 index 00000000000..86eca9defca --- /dev/null +++ b/src/gallium/include/frontend/sw_winsys.h @@ -0,0 +1,145 @@ +/************************************************************************** + * + * 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_format.h" +#include "frontend/winsys_handle.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +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 ); + + bool + (*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, + const void *front_private, + 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. + */ + bool + (*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/src/gallium/include/frontend/vdpau_dmabuf.h b/src/gallium/include/frontend/vdpau_dmabuf.h new file mode 100644 index 00000000000..f838c925f30 --- /dev/null +++ b/src/gallium/include/frontend/vdpau_dmabuf.h @@ -0,0 +1,94 @@ +/************************************************************************** + * + * Copyright 2016 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 <[email protected]> + * + */ + +#ifndef _VDPAU_DMABUF_H_ +#define _VDPAU_DMABUF_H_ + +#include <vdpau/vdpau.h> + +/* driver specific functions for NV_vdpau_interop */ +#ifndef VDP_FUNC_ID_BASE_DRIVER +#define VDP_FUNC_ID_BASE_DRIVER 0x2000 +#endif + +/* New DMA-buf based implementation */ +#define VDP_FUNC_ID_VIDEO_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 2) +#define VDP_FUNC_ID_OUTPUT_SURFACE_DMA_BUF (VDP_FUNC_ID_BASE_DRIVER + 3) + +/* Define some more internal RGBA formats for more + * robust handling of Video Surfaces + */ +#define VDP_RGBA_FORMAT_R8 (-1) +#define VDP_RGBA_FORMAT_R8G8 (-2) + +struct VdpSurfaceDMABufDesc { + /* DMA-buf file descriptor */ + uint32_t handle; + /* Width in pixel */ + uint32_t width; + /* Height in pixel */ + uint32_t height; + /* Offset in bytes */ + uint32_t offset; + /* Stride in bytes */ + uint32_t stride; + /* VDP_RGBA_FORMAT_* as defined in the VDPAU spec and above. */ + uint32_t format; +}; + +/** + * \brief Video surface planes + */ +typedef uint32_t VdpVideoSurfacePlane; + +/** \hideinitializer \brief Luma top field */ +#define VDP_VIDEO_SURFACE_PLANE_LUMA_TOP ((VdpVideoSurfacePlane)0) +/** \hideinitializer \brief Luma bottom field */ +#define VDP_VIDEO_SURFACE_PLANE_LUMA_BOTTOM ((VdpVideoSurfacePlane)1) +/** \hideinitializer \brief Chroma top field */ +#define VDP_VIDEO_SURFACE_PLANE_CHROMA_TOP ((VdpVideoSurfacePlane)2) +/** \hideinitializer \brief Chroma bottom field */ +#define VDP_VIDEO_SURFACE_PLANE_CHROMA_BOTTOM ((VdpVideoSurfacePlane)3) + +typedef VdpStatus VdpVideoSurfaceDMABuf( + VdpVideoSurface surface, + VdpVideoSurfacePlane plane, + struct VdpSurfaceDMABufDesc * result +); + +typedef VdpStatus VdpOutputSurfaceDMABuf( + VdpOutputSurface surface, + struct VdpSurfaceDMABufDesc * result +); + +#endif /* _VDPAU_DMABUF_H_ */ diff --git a/src/gallium/include/frontend/vdpau_funcs.h b/src/gallium/include/frontend/vdpau_funcs.h new file mode 100644 index 00000000000..66e3c23ede4 --- /dev/null +++ b/src/gallium/include/frontend/vdpau_funcs.h @@ -0,0 +1,65 @@ +/************************************************************************** + * + * Copyright 2016 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 <[email protected]> + * + */ + +#ifndef _VDPAU_FUNCS_H_ +#define _VDPAU_FUNCS_H_ + +#include "vdpau_dmabuf.h" + +/* Used for implementing NV_vdpau_interop */ +static inline enum pipe_format +VdpFormatRGBAToPipe(uint32_t vdpau_format) +{ + switch (vdpau_format) { + case VDP_RGBA_FORMAT_R8: + return PIPE_FORMAT_R8_UNORM; + case VDP_RGBA_FORMAT_R8G8: + return PIPE_FORMAT_R8G8_UNORM; + case VDP_RGBA_FORMAT_A8: + return PIPE_FORMAT_A8_UNORM; + case VDP_RGBA_FORMAT_B10G10R10A2: + return PIPE_FORMAT_B10G10R10A2_UNORM; + case VDP_RGBA_FORMAT_B8G8R8A8: + return PIPE_FORMAT_B8G8R8A8_UNORM; + case VDP_RGBA_FORMAT_R10G10B10A2: + return PIPE_FORMAT_R10G10B10A2_UNORM; + case VDP_RGBA_FORMAT_R8G8B8A8: + return PIPE_FORMAT_R8G8B8A8_UNORM; + default: + assert(0); + } + + return PIPE_FORMAT_NONE; +} + +#endif /* _VDPAU_FUNCS_H_ */ diff --git a/src/gallium/include/frontend/vdpau_interop.h b/src/gallium/include/frontend/vdpau_interop.h new file mode 100644 index 00000000000..04d455a370a --- /dev/null +++ b/src/gallium/include/frontend/vdpau_interop.h @@ -0,0 +1,54 @@ +/************************************************************************** + * + * 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 <[email protected]> + * + */ + +#ifndef _VDPAU_INTEROP_H_ +#define _VDPAU_INTEROP_H_ + +/* driver specific functions for NV_vdpau_interop */ +#ifndef VDP_FUNC_ID_BASE_DRIVER +#define VDP_FUNC_ID_BASE_DRIVER 0x2000 +#endif + +/* Older implementation relying on passing pipe_video_buffer and + * pipe_resources around. Deprecated and shouldn't be used for new things. + */ +#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/src/gallium/include/frontend/winsys_handle.h b/src/gallium/include/frontend/winsys_handle.h new file mode 100644 index 00000000000..78f5f4b36f2 --- /dev/null +++ b/src/gallium/include/frontend/winsys_handle.h @@ -0,0 +1,69 @@ + +#ifndef _WINSYS_HANDLE_H_ +#define _WINSYS_HANDLE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define WINSYS_HANDLE_TYPE_SHARED 0 +#define WINSYS_HANDLE_TYPE_KMS 1 +#define WINSYS_HANDLE_TYPE_FD 2 +#define WINSYS_HANDLE_TYPE_SHMID 3 + +/** + * For use with pipe_screen::{texture_from_handle|texture_get_handle}. + */ +struct winsys_handle +{ + /** + * Input for texture_from_handle, valid values are + * WINSYS_HANDLE_TYPE_SHARED or WINSYS_HANDLE_TYPE_FD. + * Input to texture_get_handle, + * to select handle for kms, flink, or prime. + */ + unsigned type; + /** + * Input for texture_get_handle, allows to export the offset + * of a specific layer of an array texture. + */ + unsigned layer; + /** + * Input for texture_get_handle, allows to export of a specific plane of a + * texture. + */ + unsigned plane; + /** + * Input to texture_from_handle. + * Output for texture_get_handle. + */ + unsigned handle; + /** + * Input to texture_from_handle. + * Output for texture_get_handle. + */ + unsigned stride; + /** + * Input to texture_from_handle. + * Output for texture_get_handle. + */ + unsigned offset; + + /** + * Input to resource_from_handle. + * Output from resource_get_handle. + */ + uint64_t format; + + /** + * Input to resource_from_handle. + * Output from resource_get_handle. + */ + uint64_t modifier; +}; + +#ifdef __cplusplus +} +#endif + +#endif /* _WINSYS_HANDLE_H_ */ diff --git a/src/gallium/include/frontend/xlibsw_api.h b/src/gallium/include/frontend/xlibsw_api.h new file mode 100644 index 00000000000..49ffa5df13f --- /dev/null +++ b/src/gallium/include/frontend/xlibsw_api.h @@ -0,0 +1,19 @@ +#ifndef XLIB_SW_WINSYS_H +#define XLIB_SW_WINSYS_H + +#include "frontend/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 |