diff options
author | Younes Manton <[email protected]> | 2010-04-30 20:42:30 -0400 |
---|---|---|
committer | Younes Manton <[email protected]> | 2010-04-30 20:42:30 -0400 |
commit | a8ea1dacc63ac567498049e5756c247b9fec6cd9 (patch) | |
tree | 4031e2e2b6166bd926b43fa4bbb3aab773a30ee5 /src/gallium/include | |
parent | 404fb63b4649f58fce443615e49337d42b8ddece (diff) | |
parent | 35d960cc744c374ccaad48c3d80559b59c74e28a (diff) |
Merge branch 'master' of ssh://git.freedesktop.org/git/mesa/mesa into pipe-video
Conflicts:
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/auxiliary/util/u_format.csv
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/auxiliary/vl/vl_compositor.h
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.c
src/gallium/auxiliary/vl/vl_mpeg12_mc_renderer.h
src/gallium/drivers/identity/id_objects.c
src/gallium/drivers/identity/id_objects.h
src/gallium/drivers/identity/id_screen.c
src/gallium/drivers/nv40/Makefile
src/gallium/drivers/nv40/nv40_screen.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_texture.h
src/gallium/drivers/softpipe/sp_video_context.c
src/gallium/drivers/softpipe/sp_video_context.h
src/gallium/include/pipe/p_format.h
src/gallium/include/pipe/p_screen.h
src/gallium/include/pipe/p_video_context.h
src/gallium/include/pipe/p_video_state.h
src/gallium/include/state_tracker/dri1_api.h
src/gallium/include/state_tracker/drm_api.h
src/gallium/state_trackers/dri/common/dri_context.c
src/gallium/state_trackers/xorg/xvmc/attributes.c
src/gallium/state_trackers/xorg/xvmc/block.c
src/gallium/state_trackers/xorg/xvmc/context.c
src/gallium/state_trackers/xorg/xvmc/subpicture.c
src/gallium/state_trackers/xorg/xvmc/surface.c
src/gallium/state_trackers/xorg/xvmc/tests/.gitignore
src/gallium/state_trackers/xorg/xvmc/tests/Makefile
src/gallium/state_trackers/xorg/xvmc/xvmc_private.h
src/gallium/winsys/drm/radeon/core/radeon_drm.c
src/gallium/winsys/g3dvl/vl_winsys.h
src/gallium/winsys/g3dvl/xlib/xsp_winsys.c
src/gallium/winsys/sw/Makefile
Diffstat (limited to 'src/gallium/include')
-rw-r--r-- | src/gallium/include/pipe/p_compiler.h | 46 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_context.h | 100 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_defines.h | 213 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_format.h | 264 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_screen.h | 162 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_shader_tokens.h | 6 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_state.h | 104 | ||||
-rw-r--r-- | src/gallium/include/state_tracker/dri1_api.h | 6 | ||||
-rw-r--r-- | src/gallium/include/state_tracker/drisw_api.h | 23 | ||||
-rw-r--r-- | src/gallium/include/state_tracker/drm_api.h | 59 | ||||
-rw-r--r-- | src/gallium/include/state_tracker/graw.h | 36 | ||||
-rw-r--r-- | src/gallium/include/state_tracker/st_api.h | 396 | ||||
-rw-r--r-- | src/gallium/include/state_tracker/sw_winsys.h | 145 | ||||
-rw-r--r-- | src/gallium/include/state_tracker/xlib_sw_winsys.h | 29 |
14 files changed, 1149 insertions, 440 deletions
diff --git a/src/gallium/include/pipe/p_compiler.h b/src/gallium/include/pipe/p_compiler.h index b93b38310ac..9b31555f1b1 100644 --- a/src/gallium/include/pipe/p_compiler.h +++ b/src/gallium/include/pipe/p_compiler.h @@ -31,13 +31,8 @@ #include "p_config.h" -#ifndef XFree86Server #include <stdlib.h> #include <string.h> -#else -#include "xf86_ansic.h" -#include "xf86_libc.h" -#endif #include <stddef.h> #include <stdarg.h> @@ -79,7 +74,6 @@ typedef unsigned char boolean; #define FALSE false #endif - /* Function inlining */ #ifndef INLINE # ifdef __cplusplus @@ -188,6 +182,44 @@ typedef unsigned char boolean; #endif - +/* You should use these macros to mark if blocks where the if condition + * is either likely to be true, or unlikely to be true. + * + * This will inform human readers of this fact, and will also inform + * the compiler, who will in turn inform the CPU. + * + * CPUs often start executing code inside the if or the else blocks + * without knowing whether the condition is true or not, and will have + * to throw the work away if they find out later they executed the + * wrong part of the if. + * + * If these macros are used, the CPU is more likely to correctly predict + * the right path, and will avoid speculatively executing the wrong branch, + * thus not throwing away work, resulting in better performance. + * + * In light of this, it is also a good idea to mark as "likely" a path + * which is not necessarily always more likely, but that will benefit much + * more from performance improvements since it is already much faster than + * the other path, or viceversa with "unlikely". + * + * Example usage: + * if(unlikely(do_we_need_a_software_fallback())) + * do_software_fallback(); + * else + * render_with_gpu(); + * + * The macros follow the Linux kernel convention, and more examples can + * be found there. + * + * Note that profile guided optimization can offer better results, but + * needs an appropriate coverage suite and does not inform human readers. + */ +#ifdef __GNUC__ +#define likely(x) __builtin_expect(!!(x), 1) +#define unlikely(x) __builtin_expect(!!(x), 0) +#else +#define likely(x) !!(x) +#define unlikely(x) !!(x) +#endif #endif /* P_COMPILER_H */ diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h index f82b77903e9..6f47845f3b8 100644 --- a/src/gallium/include/pipe/p_context.h +++ b/src/gallium/include/pipe/p_context.h @@ -58,15 +58,16 @@ struct pipe_context { void (*destroy)( struct pipe_context * ); /** - * VBO drawing (return false on fallbacks (temporary??)) + * VBO drawing */ /*@{*/ void (*draw_arrays)( struct pipe_context *pipe, unsigned mode, unsigned start, unsigned count); void (*draw_elements)( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, + struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned mode, unsigned start, unsigned count); void (*draw_arrays_instanced)(struct pipe_context *pipe, @@ -77,8 +78,9 @@ struct pipe_context { unsigned instanceCount); void (*draw_elements_instanced)(struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, + struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned mode, unsigned start, unsigned count, @@ -91,8 +93,9 @@ struct pipe_context { * module. */ void (*draw_range_elements)( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, + struct pipe_resource *indexBuffer, unsigned indexSize, + int indexBias, unsigned minIndex, unsigned maxIndex, unsigned mode, @@ -177,6 +180,12 @@ struct pipe_context { void (*bind_gs_state)(struct pipe_context *, void *); void (*delete_gs_state)(struct pipe_context *, void *); + void * (*create_vertex_elements_state)(struct pipe_context *, + unsigned num_elements, + const struct pipe_vertex_element *); + void (*bind_vertex_elements_state)(struct pipe_context *, void *); + void (*delete_vertex_elements_state)(struct pipe_context *, void *); + /*@}*/ /** @@ -194,7 +203,7 @@ struct pipe_context { void (*set_constant_buffer)( struct pipe_context *, uint shader, uint index, - struct pipe_buffer *buf ); + struct pipe_resource *buf ); void (*set_framebuffer_state)( struct pipe_context *, const struct pipe_framebuffer_state * ); @@ -208,21 +217,18 @@ struct pipe_context { void (*set_viewport_state)( struct pipe_context *, const struct pipe_viewport_state * ); - void (*set_fragment_sampler_textures)(struct pipe_context *, - unsigned num_textures, - struct pipe_texture **); + void (*set_fragment_sampler_views)(struct pipe_context *, + unsigned num_views, + struct pipe_sampler_view **); - void (*set_vertex_sampler_textures)(struct pipe_context *, - unsigned num_textures, - struct pipe_texture **); + void (*set_vertex_sampler_views)(struct pipe_context *, + unsigned num_views, + struct pipe_sampler_view **); void (*set_vertex_buffers)( struct pipe_context *, unsigned num_buffers, const struct pipe_vertex_buffer * ); - void (*set_vertex_elements)( struct pipe_context *, - unsigned num_elements, - const struct pipe_vertex_element * ); /*@}*/ @@ -288,21 +294,63 @@ struct pipe_context { * \param level mipmap level. * \return mask of PIPE_REFERENCED_FOR_READ/WRITE or PIPE_UNREFERENCED */ - unsigned int (*is_texture_referenced)(struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level); + unsigned int (*is_resource_referenced)(struct pipe_context *pipe, + struct pipe_resource *texture, + unsigned face, unsigned level); /** - * Check whether a buffer is referenced by an unflushed hw command. - * The state-tracker uses this function to avoid unnecessary flushes. - * It is safe (but wasteful) to always return - * PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE. - * \param pipe context whose unflushed hw commands will be checked. - * \param buf buffer to check. - * \return mask of PIPE_REFERENCED_FOR_READ/WRITE or PIPE_UNREFERENCED + * Create a view on a texture to be used by a shader stage. + */ + struct pipe_sampler_view * (*create_sampler_view)(struct pipe_context *ctx, + struct pipe_resource *texture, + const struct pipe_sampler_view *templat); + + void (*sampler_view_destroy)(struct pipe_context *ctx, + struct pipe_sampler_view *view); + + + /** + * Get a transfer object for transferring data to/from a texture. + * + * Transfers are (by default) context-private and allow uploads to be + * interleaved with + */ + struct pipe_transfer *(*get_transfer)(struct pipe_context *, + struct pipe_resource *resource, + struct pipe_subresource, + unsigned usage, /* a combination of PIPE_TRANSFER_x */ + const struct pipe_box *); + + void (*transfer_destroy)(struct pipe_context *, + struct pipe_transfer *); + + void *(*transfer_map)( struct pipe_context *, + struct pipe_transfer *transfer ); + + /* If transfer was created with WRITE|FLUSH_EXPLICIT, only the + * regions specified with this call are guaranteed to be written to + * the resource. */ - unsigned int (*is_buffer_referenced)(struct pipe_context *pipe, - struct pipe_buffer *buf); + void (*transfer_flush_region)( struct pipe_context *, + struct pipe_transfer *transfer, + const struct pipe_box *); + + void (*transfer_unmap)( struct pipe_context *, + struct pipe_transfer *transfer ); + + + /* One-shot transfer operation with data supplied in a user + * pointer. XXX: strides?? + */ + void (*transfer_inline_write)( struct pipe_context *, + struct pipe_resource *, + struct pipe_subresource, + unsigned usage, /* a combination of PIPE_TRANSFER_x */ + const struct pipe_box *, + const void *data, + unsigned stride, + unsigned slice_stride); + }; diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h index 5cebd43ace2..28318183183 100644 --- a/src/gallium/include/pipe/p_defines.h +++ b/src/gallium/include/pipe/p_defines.h @@ -137,10 +137,11 @@ enum pipe_error { /** Texture types */ enum pipe_texture_target { - PIPE_TEXTURE_1D = 0, - PIPE_TEXTURE_2D = 1, - PIPE_TEXTURE_3D = 2, - PIPE_TEXTURE_CUBE = 3, + PIPE_BUFFER = 0, + PIPE_TEXTURE_1D = 1, + PIPE_TEXTURE_2D = 2, + PIPE_TEXTURE_3D = 3, + PIPE_TEXTURE_CUBE = 4, PIPE_MAX_TEXTURE_TYPES }; @@ -175,21 +176,10 @@ enum pipe_texture_target { #define PIPE_TEX_COMPARE_NONE 0 #define PIPE_TEX_COMPARE_R_TO_TEXTURE 1 -#define PIPE_TEXTURE_USAGE_RENDER_TARGET 0x1 -#define PIPE_TEXTURE_USAGE_DISPLAY_TARGET 0x2 /* ie a backbuffer */ -#define PIPE_TEXTURE_USAGE_PRIMARY 0x4 /* ie a frontbuffer */ -#define PIPE_TEXTURE_USAGE_DEPTH_STENCIL 0x8 -#define PIPE_TEXTURE_USAGE_SAMPLER 0x10 -#define PIPE_TEXTURE_USAGE_DYNAMIC 0x20 -/** Pipe driver custom usage flags should be greater or equal to this value */ -#define PIPE_TEXTURE_USAGE_CUSTOM (1 << 16) - -#define PIPE_TEXTURE_GEOM_NON_SQUARE 0x1 -#define PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO 0x2 - /** - * Surface layout + * Surface layout -- a hint? Or some driver-internal poking out into + * the interface? */ #define PIPE_SURFACE_LAYOUT_LINEAR 0 @@ -207,10 +197,23 @@ enum pipe_texture_target { * Transfer object usage flags */ enum pipe_transfer_usage { + /** + * Resource contents read back (or accessed directly) at transfer + * create time. + */ PIPE_TRANSFER_READ = (1 << 0), + + /** + * Resource contents will be written back at transfer_destroy + * time (or modified as a result of being accessed directly). + */ PIPE_TRANSFER_WRITE = (1 << 1), - /** Read/modify/write */ + + /** + * Read/modify/write + */ PIPE_TRANSFER_READ_WRITE = PIPE_TRANSFER_READ | PIPE_TRANSFER_WRITE, + /** * The transfer should map the texture storage directly. The driver may * return NULL if that isn't possible, and the state tracker needs to cope @@ -220,89 +223,116 @@ enum pipe_transfer_usage { * does read/modify/write cycles on them directly, and a more complicated * path which uses minimal read and write transfers. */ - PIPE_TRANSFER_MAP_DIRECTLY = (1 << 2) -}; + PIPE_TRANSFER_MAP_DIRECTLY = (1 << 2), + /** + * Discards the memory within the mapped region. + * + * It should not be used with PIPE_TRANSFER_CPU_READ. + * + * See also: + * - OpenGL's ARB_map_buffer_range extension, MAP_INVALIDATE_RANGE_BIT flag. + * - Direct3D's D3DLOCK_DISCARD flag. + */ + PIPE_TRANSFER_DISCARD = (1 << 8), -/* - * Buffer usage flags - */ + /** + * Fail if the resource cannot be mapped immediately. + * + * See also: + * - Direct3D's D3DLOCK_DONOTWAIT flag. + * - Mesa3D's MESA_MAP_NOWAIT_BIT flag. + * - WDDM's D3DDDICB_LOCKFLAGS.DonotWait flag. + */ + PIPE_TRANSFER_DONTBLOCK = (1 << 9), + + /** + * Do not attempt to synchronize pending operations on the resource when mapping. + * + * It should not be used with PIPE_TRANSFER_CPU_READ. + * + * See also: + * - OpenGL's ARB_map_buffer_range extension, MAP_UNSYNCHRONIZED_BIT flag. + * - Direct3D's D3DLOCK_NOOVERWRITE flag. + * - WDDM's D3DDDICB_LOCKFLAGS.IgnoreSync flag. + */ + PIPE_TRANSFER_UNSYNCHRONIZED = (1 << 10), + PIPE_TRANSFER_NOOVERWRITE = (1 << 10), /* are these really the same?? */ + + /** + * Written ranges will be notified later with + * pipe_context::transfer_flush_region. + * + * It should not be used with PIPE_TRANSFER_CPU_READ. + * + * See also: + * - pipe_context::transfer_flush_region + * - OpenGL's ARB_map_buffer_range extension, MAP_FLUSH_EXPLICIT_BIT flag. + */ + PIPE_TRANSFER_FLUSH_EXPLICIT = (1 << 11) + +}; -#define PIPE_BUFFER_USAGE_CPU_READ (1 << 0) -#define PIPE_BUFFER_USAGE_CPU_WRITE (1 << 1) -#define PIPE_BUFFER_USAGE_GPU_READ (1 << 2) -#define PIPE_BUFFER_USAGE_GPU_WRITE (1 << 3) -#define PIPE_BUFFER_USAGE_PIXEL (1 << 4) -#define PIPE_BUFFER_USAGE_VERTEX (1 << 5) -#define PIPE_BUFFER_USAGE_INDEX (1 << 6) -#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7) /* - * CPU access flags. - * - * These flags should only be used for texture transfers or when mapping - * buffers. - * - * Note that the PIPE_BUFFER_USAGE_CPU_xxx flags above are also used for - * mapping. Either PIPE_BUFFER_USAGE_CPU_READ or PIPE_BUFFER_USAGE_CPU_WRITE - * must be set. + * Resource binding flags -- state tracker must specify in advance all + * the ways a resource might be used. */ - -/** - * Discards the memory within the mapped region. +#define PIPE_BIND_DEPTH_STENCIL (1 << 0) /* get_tex_surface */ +#define PIPE_BIND_RENDER_TARGET (1 << 1) /* get_tex_surface */ +#define PIPE_BIND_SAMPLER_VIEW (1 << 2) /* get_sampler_view */ +#define PIPE_BIND_VERTEX_BUFFER (1 << 3) /* set_vertex_buffers */ +#define PIPE_BIND_INDEX_BUFFER (1 << 4) /* draw_elements */ +#define PIPE_BIND_CONSTANT_BUFFER (1 << 5) /* set_constant_buffer */ +#define PIPE_BIND_BLIT_SOURCE (1 << 6) /* surface_copy */ +#define PIPE_BIND_BLIT_DESTINATION (1 << 7) /* surface_copy, fill */ +#define PIPE_BIND_DISPLAY_TARGET (1 << 8) /* flush_front_buffer */ +#define PIPE_BIND_TRANSFER_WRITE (1 << 9) /* get_transfer */ +#define PIPE_BIND_TRANSFER_READ (1 << 10) /* get_transfer */ +#define PIPE_BIND_CUSTOM (1 << 16) /* state-tracker/winsys usages */ + +/* The first two flags above were previously part of the amorphous + * TEXTURE_USAGE, most of which are now descriptions of the ways a + * particular texture can be bound to the gallium pipeline. The two flags + * below do not fit within that and probably need to be migrated to some + * other place. * - * It should not be used with PIPE_BUFFER_USAGE_CPU_READ. + * It seems like scanout is used by the Xorg state tracker to ask for + * a texture suitable for actual scanout (hence the name), which + * implies extra layout constraints on some hardware. It may also + * have some special meaning regarding mouse cursor images. * - * See also: - * - OpenGL's ARB_map_buffer_range extension, MAP_INVALIDATE_RANGE_BIT flag. - * - Direct3D's D3DLOCK_DISCARD flag. + * The shared flag is quite underspecified, but certainly isn't a + * binding flag - it seems more like a message to the winsys to create + * a shareable allocation. */ -#define PIPE_BUFFER_USAGE_DISCARD (1 << 8) +#define PIPE_BIND_SCANOUT (1 << 14) /* */ +#define PIPE_BIND_SHARED (1 << 15) /* get_texture_handle ??? */ -/** - * Fail if the resource cannot be mapped immediately. - * - * See also: - * - Direct3D's D3DLOCK_DONOTWAIT flag. - * - Mesa3D's MESA_MAP_NOWAIT_BIT flag. - * - WDDM's D3DDDICB_LOCKFLAGS.DonotWait flag. - */ -#define PIPE_BUFFER_USAGE_DONTBLOCK (1 << 9) -/** - * Do not attempt to synchronize pending operations on the resource when mapping. - * - * It should not be used with PIPE_BUFFER_USAGE_CPU_READ. - * - * See also: - * - OpenGL's ARB_map_buffer_range extension, MAP_UNSYNCHRONIZED_BIT flag. - * - Direct3D's D3DLOCK_NOOVERWRITE flag. - * - WDDM's D3DDDICB_LOCKFLAGS.IgnoreSync flag. +/* Flags for the driver about resource behaviour: */ -#define PIPE_BUFFER_USAGE_UNSYNCHRONIZED (1 << 10) +#define PIPE_RESOURCE_FLAG_GEN_MIPS (1 << 0) /* Driver performs autogen mips */ +#define PIPE_RESOURCE_FLAG_DRV_PRIV (1 << 16) /* driver/winsys private */ +#define PIPE_RESOURCE_FLAG_ST_PRIV (1 << 24) /* state-tracker/winsys private */ -/** - * Written ranges will be notified later with - * pipe_screen::buffer_flush_mapped_range. - * - * It should not be used with PIPE_BUFFER_USAGE_CPU_READ. - * - * See also: - * - pipe_screen::buffer_flush_mapped_range - * - OpenGL's ARB_map_buffer_range extension, MAP_FLUSH_EXPLICIT_BIT flag. +/* Hint about the expected lifecycle of a resource. */ -#define PIPE_BUFFER_USAGE_FLUSH_EXPLICIT (1 << 11) +#define PIPE_USAGE_DEFAULT 0 /* many uploads, draws intermixed */ +#define PIPE_USAGE_DYNAMIC 1 /* many uploads, draws intermixed */ +#define PIPE_USAGE_STATIC 2 /* same as immutable?? */ +#define PIPE_USAGE_IMMUTABLE 3 /* no change after first upload */ +#define PIPE_USAGE_STREAM 4 /* upload, draw, upload, draw */ -/** Pipe driver custom usage flags should be greater or equal to this value */ -#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16) -/* Convenient shortcuts */ -#define PIPE_BUFFER_USAGE_CPU_READ_WRITE \ - ( PIPE_BUFFER_USAGE_CPU_READ | PIPE_BUFFER_USAGE_CPU_WRITE ) -#define PIPE_BUFFER_USAGE_GPU_READ_WRITE \ - ( PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE ) -#define PIPE_BUFFER_USAGE_WRITE \ - ( PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_GPU_WRITE ) +/* These are intended to be used in calls to is_format_supported, but + * no driver actually uses these flags, and only the glx/xlib state + * tracker issues them. + * + * Deprecate? + */ +#define PIPE_TEXTURE_GEOM_NON_SQUARE 0x1 +#define PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO 0x2 /** @@ -369,6 +399,17 @@ enum pipe_transfer_usage { /** + * Texture swizzles + */ +#define PIPE_SWIZZLE_RED 0 +#define PIPE_SWIZZLE_GREEN 1 +#define PIPE_SWIZZLE_BLUE 2 +#define PIPE_SWIZZLE_ALPHA 3 +#define PIPE_SWIZZLE_ZERO 4 +#define PIPE_SWIZZLE_ONE 5 + + +/** * Implementation capabilities/limits which are queried through * pipe_screen::get_param() and pipe_screen::get_paramf(). */ @@ -422,7 +463,6 @@ enum pipe_transfer_usage { #define PIPE_REFERENCED_FOR_READ (1 << 0) #define PIPE_REFERENCED_FOR_WRITE (1 << 1) - enum pipe_video_codec { PIPE_VIDEO_CODEC_UNKNOWN = 0, @@ -447,6 +487,7 @@ enum pipe_video_profile PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH }; + #ifdef __cplusplus } #endif diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h index f3534685b5a..70a768c4e16 100644 --- a/src/gallium/include/pipe/p_format.h +++ b/src/gallium/include/pipe/p_format.h @@ -44,141 +44,169 @@ extern "C" { */ enum pipe_format { - PIPE_FORMAT_NONE = 0, - PIPE_FORMAT_B8G8R8A8_UNORM = 1, - PIPE_FORMAT_B8G8R8X8_UNORM = 2, - PIPE_FORMAT_A8R8G8B8_UNORM = 3, - PIPE_FORMAT_X8R8G8B8_UNORM = 4, - PIPE_FORMAT_B5G5R5A1_UNORM = 5, - PIPE_FORMAT_B4G4R4A4_UNORM = 6, - PIPE_FORMAT_B5G6R5_UNORM = 7, - PIPE_FORMAT_R10G10B10A2_UNORM = 8, - PIPE_FORMAT_L8_UNORM = 9, /**< ubyte luminance */ - PIPE_FORMAT_A8_UNORM = 10, /**< ubyte alpha */ - PIPE_FORMAT_I8_UNORM = 11, /**< ubyte intensity */ - PIPE_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */ - PIPE_FORMAT_L16_UNORM = 13, /**< ushort luminance */ - PIPE_FORMAT_UYVY = 14, /**< aka Y422, UYNV, HDYC */ - PIPE_FORMAT_YUYV = 15, /**< aka YUY2, YUNV, V422 */ - PIPE_FORMAT_Z16_UNORM = 16, - PIPE_FORMAT_Z32_UNORM = 17, - PIPE_FORMAT_Z32_FLOAT = 18, - PIPE_FORMAT_Z24S8_UNORM = 19, - PIPE_FORMAT_S8Z24_UNORM = 20, - PIPE_FORMAT_Z24X8_UNORM = 21, - PIPE_FORMAT_X8Z24_UNORM = 22, - PIPE_FORMAT_S8_UNORM = 23, /**< ubyte stencil */ - PIPE_FORMAT_R64_FLOAT = 24, - PIPE_FORMAT_R64G64_FLOAT = 25, - PIPE_FORMAT_R64G64B64_FLOAT = 26, - PIPE_FORMAT_R64G64B64A64_FLOAT = 27, - PIPE_FORMAT_R32_FLOAT = 28, - PIPE_FORMAT_R32G32_FLOAT = 29, - PIPE_FORMAT_R32G32B32_FLOAT = 30, - PIPE_FORMAT_R32G32B32A32_FLOAT = 31, - PIPE_FORMAT_R32_UNORM = 32, - PIPE_FORMAT_R32G32_UNORM = 33, - PIPE_FORMAT_R32G32B32_UNORM = 34, - PIPE_FORMAT_R32G32B32A32_UNORM = 35, - PIPE_FORMAT_R32_USCALED = 36, - PIPE_FORMAT_R32G32_USCALED = 37, - PIPE_FORMAT_R32G32B32_USCALED = 38, - PIPE_FORMAT_R32G32B32A32_USCALED = 39, - PIPE_FORMAT_R32_SNORM = 40, - PIPE_FORMAT_R32G32_SNORM = 41, - PIPE_FORMAT_R32G32B32_SNORM = 42, - PIPE_FORMAT_R32G32B32A32_SNORM = 43, - PIPE_FORMAT_R32_SSCALED = 44, - PIPE_FORMAT_R32G32_SSCALED = 45, - PIPE_FORMAT_R32G32B32_SSCALED = 46, - PIPE_FORMAT_R32G32B32A32_SSCALED = 47, - PIPE_FORMAT_R16_UNORM = 48, - PIPE_FORMAT_R16G16_UNORM = 49, - PIPE_FORMAT_R16G16B16_UNORM = 50, - PIPE_FORMAT_R16G16B16A16_UNORM = 51, - PIPE_FORMAT_R16_USCALED = 52, - PIPE_FORMAT_R16G16_USCALED = 53, - PIPE_FORMAT_R16G16B16_USCALED = 54, - PIPE_FORMAT_R16G16B16A16_USCALED = 55, - PIPE_FORMAT_R16_SNORM = 56, - PIPE_FORMAT_R16G16_SNORM = 57, - PIPE_FORMAT_R16G16B16_SNORM = 58, - PIPE_FORMAT_R16G16B16A16_SNORM = 59, - PIPE_FORMAT_R16_SSCALED = 60, - PIPE_FORMAT_R16G16_SSCALED = 61, - PIPE_FORMAT_R16G16B16_SSCALED = 62, - PIPE_FORMAT_R16G16B16A16_SSCALED = 63, - PIPE_FORMAT_R8_UNORM = 64, - PIPE_FORMAT_R8G8_UNORM = 65, - PIPE_FORMAT_R8G8B8_UNORM = 66, - PIPE_FORMAT_R8G8B8A8_UNORM = 67, - PIPE_FORMAT_X8B8G8R8_UNORM = 68, - PIPE_FORMAT_R8_USCALED = 69, - PIPE_FORMAT_R8G8_USCALED = 70, - PIPE_FORMAT_R8G8B8_USCALED = 71, - PIPE_FORMAT_R8G8B8A8_USCALED = 72, - PIPE_FORMAT_R8_SNORM = 74, - PIPE_FORMAT_R8G8_SNORM = 75, - PIPE_FORMAT_R8G8B8_SNORM = 76, - PIPE_FORMAT_R8G8B8A8_SNORM = 77, - PIPE_FORMAT_R8_SSCALED = 82, - PIPE_FORMAT_R8G8_SSCALED = 83, - PIPE_FORMAT_R8G8B8_SSCALED = 84, - PIPE_FORMAT_R8G8B8A8_SSCALED = 85, - PIPE_FORMAT_R32_FIXED = 87, - PIPE_FORMAT_R32G32_FIXED = 88, - PIPE_FORMAT_R32G32B32_FIXED = 89, - PIPE_FORMAT_R32G32B32A32_FIXED = 90, - /* sRGB formats */ - PIPE_FORMAT_L8_SRGB = 91, - PIPE_FORMAT_L8A8_SRGB = 92, - PIPE_FORMAT_R8G8B8_SRGB = 93, - PIPE_FORMAT_A8B8G8R8_SRGB = 94, - PIPE_FORMAT_X8B8G8R8_SRGB = 95, - PIPE_FORMAT_B8G8R8A8_SRGB = 96, - PIPE_FORMAT_B8G8R8X8_SRGB = 97, - PIPE_FORMAT_A8R8G8B8_SRGB = 98, - PIPE_FORMAT_X8R8G8B8_SRGB = 99, + PIPE_FORMAT_NONE = 0, + PIPE_FORMAT_B8G8R8A8_UNORM = 1, + PIPE_FORMAT_B8G8R8X8_UNORM = 2, + PIPE_FORMAT_A8R8G8B8_UNORM = 3, + PIPE_FORMAT_X8R8G8B8_UNORM = 4, + PIPE_FORMAT_B5G5R5A1_UNORM = 5, + PIPE_FORMAT_B4G4R4A4_UNORM = 6, + PIPE_FORMAT_B5G6R5_UNORM = 7, + PIPE_FORMAT_R10G10B10A2_UNORM = 8, + PIPE_FORMAT_L8_UNORM = 9, /**< ubyte luminance */ + PIPE_FORMAT_A8_UNORM = 10, /**< ubyte alpha */ + PIPE_FORMAT_I8_UNORM = 11, /**< ubyte intensity */ + PIPE_FORMAT_L8A8_UNORM = 12, /**< ubyte alpha, luminance */ + PIPE_FORMAT_L16_UNORM = 13, /**< ushort luminance */ + PIPE_FORMAT_UYVY = 14, + PIPE_FORMAT_YUYV = 15, + PIPE_FORMAT_Z16_UNORM = 16, + PIPE_FORMAT_Z32_UNORM = 17, + PIPE_FORMAT_Z32_FLOAT = 18, + PIPE_FORMAT_Z24_UNORM_S8_USCALED = 19, + PIPE_FORMAT_S8_USCALED_Z24_UNORM = 20, + PIPE_FORMAT_Z24X8_UNORM = 21, + PIPE_FORMAT_X8Z24_UNORM = 22, + PIPE_FORMAT_S8_USCALED = 23, /**< ubyte stencil */ + PIPE_FORMAT_R64_FLOAT = 24, + PIPE_FORMAT_R64G64_FLOAT = 25, + PIPE_FORMAT_R64G64B64_FLOAT = 26, + PIPE_FORMAT_R64G64B64A64_FLOAT = 27, + PIPE_FORMAT_R32_FLOAT = 28, + PIPE_FORMAT_R32G32_FLOAT = 29, + PIPE_FORMAT_R32G32B32_FLOAT = 30, + PIPE_FORMAT_R32G32B32A32_FLOAT = 31, + PIPE_FORMAT_R32_UNORM = 32, + PIPE_FORMAT_R32G32_UNORM = 33, + PIPE_FORMAT_R32G32B32_UNORM = 34, + PIPE_FORMAT_R32G32B32A32_UNORM = 35, + PIPE_FORMAT_R32_USCALED = 36, + PIPE_FORMAT_R32G32_USCALED = 37, + PIPE_FORMAT_R32G32B32_USCALED = 38, + PIPE_FORMAT_R32G32B32A32_USCALED = 39, + PIPE_FORMAT_R32_SNORM = 40, + PIPE_FORMAT_R32G32_SNORM = 41, + PIPE_FORMAT_R32G32B32_SNORM = 42, + PIPE_FORMAT_R32G32B32A32_SNORM = 43, + PIPE_FORMAT_R32_SSCALED = 44, + PIPE_FORMAT_R32G32_SSCALED = 45, + PIPE_FORMAT_R32G32B32_SSCALED = 46, + PIPE_FORMAT_R32G32B32A32_SSCALED = 47, + PIPE_FORMAT_R16_UNORM = 48, + PIPE_FORMAT_R16G16_UNORM = 49, + PIPE_FORMAT_R16G16B16_UNORM = 50, + PIPE_FORMAT_R16G16B16A16_UNORM = 51, + PIPE_FORMAT_R16_USCALED = 52, + PIPE_FORMAT_R16G16_USCALED = 53, + PIPE_FORMAT_R16G16B16_USCALED = 54, + PIPE_FORMAT_R16G16B16A16_USCALED = 55, + PIPE_FORMAT_R16_SNORM = 56, + PIPE_FORMAT_R16G16_SNORM = 57, + PIPE_FORMAT_R16G16B16_SNORM = 58, + PIPE_FORMAT_R16G16B16A16_SNORM = 59, + PIPE_FORMAT_R16_SSCALED = 60, + PIPE_FORMAT_R16G16_SSCALED = 61, + PIPE_FORMAT_R16G16B16_SSCALED = 62, + PIPE_FORMAT_R16G16B16A16_SSCALED = 63, + PIPE_FORMAT_R8_UNORM = 64, + PIPE_FORMAT_R8G8_UNORM = 65, + PIPE_FORMAT_R8G8B8_UNORM = 66, + PIPE_FORMAT_R8G8B8A8_UNORM = 67, + PIPE_FORMAT_X8B8G8R8_UNORM = 68, + PIPE_FORMAT_R8_USCALED = 69, + PIPE_FORMAT_R8G8_USCALED = 70, + PIPE_FORMAT_R8G8B8_USCALED = 71, + PIPE_FORMAT_R8G8B8A8_USCALED = 72, + PIPE_FORMAT_R8_SNORM = 74, + PIPE_FORMAT_R8G8_SNORM = 75, + PIPE_FORMAT_R8G8B8_SNORM = 76, + PIPE_FORMAT_R8G8B8A8_SNORM = 77, + PIPE_FORMAT_R8_SSCALED = 82, + PIPE_FORMAT_R8G8_SSCALED = 83, + PIPE_FORMAT_R8G8B8_SSCALED = 84, + PIPE_FORMAT_R8G8B8A8_SSCALED = 85, + PIPE_FORMAT_R32_FIXED = 87, + PIPE_FORMAT_R32G32_FIXED = 88, + PIPE_FORMAT_R32G32B32_FIXED = 89, + PIPE_FORMAT_R32G32B32A32_FIXED = 90, + PIPE_FORMAT_R16_FLOAT = 91, + PIPE_FORMAT_R16G16_FLOAT = 92, + PIPE_FORMAT_R16G16B16_FLOAT = 93, + PIPE_FORMAT_R16G16B16A16_FLOAT = 94, - /* mixed formats */ - PIPE_FORMAT_R8SG8SB8UX8U_NORM = 100, - PIPE_FORMAT_R5SG5SB6U_NORM = 101, + /* sRGB formats */ + PIPE_FORMAT_L8_SRGB = 95, + PIPE_FORMAT_L8A8_SRGB = 96, + PIPE_FORMAT_R8G8B8_SRGB = 97, + PIPE_FORMAT_A8B8G8R8_SRGB = 98, + PIPE_FORMAT_X8B8G8R8_SRGB = 99, + PIPE_FORMAT_B8G8R8A8_SRGB = 100, + PIPE_FORMAT_B8G8R8X8_SRGB = 101, + PIPE_FORMAT_A8R8G8B8_SRGB = 102, + PIPE_FORMAT_X8R8G8B8_SRGB = 103, + PIPE_FORMAT_R8G8B8A8_SRGB = 104, /* compressed formats */ - PIPE_FORMAT_DXT1_RGB = 102, - PIPE_FORMAT_DXT1_RGBA = 103, - PIPE_FORMAT_DXT3_RGBA = 104, - PIPE_FORMAT_DXT5_RGBA = 105, + PIPE_FORMAT_DXT1_RGB = 105, + PIPE_FORMAT_DXT1_RGBA = 106, + PIPE_FORMAT_DXT3_RGBA = 107, + PIPE_FORMAT_DXT5_RGBA = 108, /* sRGB, compressed */ - PIPE_FORMAT_DXT1_SRGB = 106, - PIPE_FORMAT_DXT1_SRGBA = 107, - PIPE_FORMAT_DXT3_SRGBA = 108, - PIPE_FORMAT_DXT5_SRGBA = 109, - - PIPE_FORMAT_A8B8G8R8_UNORM = 110, - - PIPE_FORMAT_YV12 = 111, - PIPE_FORMAT_YV16 = 112, - PIPE_FORMAT_IYUV = 113, /**< aka I420 */ - PIPE_FORMAT_NV12 = 114, - PIPE_FORMAT_NV21 = 115, + PIPE_FORMAT_DXT1_SRGB = 109, + PIPE_FORMAT_DXT1_SRGBA = 110, + PIPE_FORMAT_DXT3_SRGBA = 111, + PIPE_FORMAT_DXT5_SRGBA = 112, + + /* rgtc compressed */ + PIPE_FORMAT_RGTC1_UNORM = 113, + PIPE_FORMAT_RGTC1_SNORM = 114, + PIPE_FORMAT_RGTC2_UNORM = 115, + PIPE_FORMAT_RGTC2_SNORM = 116, + + PIPE_FORMAT_R8G8_B8G8_UNORM = 117, + PIPE_FORMAT_G8R8_G8B8_UNORM = 118, + + /* mixed formats */ + PIPE_FORMAT_R8SG8SB8UX8U_NORM = 119, + PIPE_FORMAT_R5SG5SB6U_NORM = 120, + + /* TODO: re-order these */ + PIPE_FORMAT_A8B8G8R8_UNORM = 121, + PIPE_FORMAT_B5G5R5X1_UNORM = 122, + PIPE_FORMAT_R10G10B10A2_USCALED = 123, + PIPE_FORMAT_R11G11B10_FLOAT = 124, + PIPE_FORMAT_R9G9B9E5_FLOAT = 125, + PIPE_FORMAT_Z32_FLOAT_S8X24_USCALED = 126, + PIPE_FORMAT_R1_UNORM = 127, + PIPE_FORMAT_R10G10B10X2_USCALED = 128, + PIPE_FORMAT_R10G10B10X2_SNORM = 129, + PIPE_FORMAT_L4A4_UNORM = 130, + PIPE_FORMAT_B10G10R10A2_UNORM = 131, + PIPE_FORMAT_R10SG10SB10SA2U_NORM = 132, + PIPE_FORMAT_R8G8Bx_SNORM = 133, + PIPE_FORMAT_R8G8B8X8_UNORM = 134, + PIPE_FORMAT_B4G4R4X4_UNORM = 135, + + PIPE_FORMAT_YV12 = 136, + PIPE_FORMAT_YV16 = 137, + PIPE_FORMAT_IYUV = 138, /**< aka I420 */ + PIPE_FORMAT_NV12 = 139, + PIPE_FORMAT_NV21 = 140, PIPE_FORMAT_AYUV = PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_VUYA = PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_IA44 = 116, - PIPE_FORMAT_AI44 = 117, + PIPE_FORMAT_IA44 = 141, + PIPE_FORMAT_AI44 = 142, PIPE_FORMAT_COUNT }; - enum pipe_video_chroma_format { PIPE_VIDEO_CHROMA_FORMAT_420, PIPE_VIDEO_CHROMA_FORMAT_422, PIPE_VIDEO_CHROMA_FORMAT_444 }; - #ifdef __cplusplus } #endif diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index cf6a9c5e2f0..919d1628d05 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -50,10 +50,12 @@ extern "C" { /** Opaque type */ +struct winsys_handle; +/** Opaque type */ struct pipe_fence_handle; struct pipe_winsys; -struct pipe_buffer; struct pipe_texture; +struct pipe_resource; struct pipe_surface; struct pipe_transfer; @@ -96,40 +98,48 @@ struct pipe_screen { /** * Check if the given pipe_format is supported as a texture or * drawing surface. - * \param tex_usage bitmask of PIPE_TEXTURE_USAGE_* + * \param bindings bitmask of PIPE_BIND_* * \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 bindings, 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); + struct pipe_resource * (*resource_create)(struct pipe_screen *, + const struct pipe_resource *templat); /** - * Create a new texture object, using the given template info, but on top of - * existing memory. - * - * It is assumed that the buffer data is layed out according to the expected - * by the hardware. NULL will be returned if any inconsistency is found. + * 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_blanket)(struct pipe_screen *, - const struct pipe_texture *templat, - const unsigned *stride, - struct pipe_buffer *buffer); + struct pipe_resource * (*resource_from_handle)(struct pipe_screen *, + const struct pipe_resource *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 (*resource_get_handle)(struct pipe_screen *, + struct pipe_resource *tex, + struct winsys_handle *handle); + - void (*texture_destroy)(struct pipe_texture *pt); + void (*resource_destroy)(struct pipe_screen *, + struct pipe_resource *pt); /** Get a 2D surface which is a "view" into a texture - * \param usage bitmaks of PIPE_BUFFER_USAGE_* read/write flags + * \param usage bitmaks of PIPE_BIND_* flags */ struct pipe_surface *(*get_tex_surface)(struct pipe_screen *, - struct pipe_texture *texture, + struct pipe_resource *resource, unsigned face, unsigned level, unsigned zslice, unsigned usage ); @@ -137,34 +147,6 @@ struct pipe_screen { void (*tex_surface_destroy)(struct pipe_surface *); - /** Get a transfer object for transferring data to/from a texture */ - struct pipe_transfer *(*get_tex_transfer)(struct pipe_screen *, - struct pipe_texture *texture, - unsigned face, unsigned level, - unsigned zslice, - enum pipe_transfer_usage usage, - unsigned x, unsigned y, - unsigned w, unsigned h); - - void (*tex_transfer_destroy)(struct pipe_transfer *); - - void *(*transfer_map)( struct pipe_screen *, - struct pipe_transfer *transfer ); - - void (*transfer_unmap)( struct pipe_screen *, - struct pipe_transfer *transfer ); - - - /** - * 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. @@ -187,96 +169,20 @@ struct pipe_screen { * 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); - - /** - * Allocate storage for a display target surface. - * - * 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_screenwhen creating a texture marked - * with the PIPE_TEXTURE_USAGE_DISPLAY_TARGET flag to get the underlying - * buffer storage. - */ - struct pipe_buffer *(*surface_buffer_create)(struct pipe_screen *screen, - unsigned width, unsigned height, - enum pipe_format format, - unsigned usage, - unsigned tex_usage, - unsigned *stride); - - - /** - * 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 ); - - /** - * Do any special operations to ensure buffer size is correct - */ - void (*update_buffer)( struct pipe_screen *ws, - void *context_private ); + struct pipe_resource *(*user_buffer_create)(struct pipe_screen *screen, + void *ptr, + unsigned bytes, + unsigned bind_flags); /** * 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 *context_private ); + void *winsys_drawable_handle ); diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h index c5c480f1f0e..e21aaacc18a 100644 --- a/src/gallium/include/pipe/p_shader_tokens.h +++ b/src/gallium/include/pipe/p_shader_tokens.h @@ -276,12 +276,10 @@ struct tgsi_property_data { #define TGSI_OPCODE_TXL 72 #define TGSI_OPCODE_BRK 73 #define TGSI_OPCODE_IF 74 -#define TGSI_OPCODE_BGNFOR 75 -#define TGSI_OPCODE_REP 76 + /* gap */ #define TGSI_OPCODE_ELSE 77 #define TGSI_OPCODE_ENDIF 78 -#define TGSI_OPCODE_ENDFOR 79 -#define TGSI_OPCODE_ENDREP 80 + /* gap */ #define TGSI_OPCODE_PUSHA 81 #define TGSI_OPCODE_POPA 82 #define TGSI_OPCODE_CEIL 83 diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index 02558520bfe..a504757c472 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -71,19 +71,6 @@ struct pipe_reference }; -/** - * The driver will certainly subclass this to include actual memory - * management information. - */ -struct pipe_buffer -{ - struct pipe_reference reference; - unsigned size; - struct pipe_screen *screen; - unsigned alignment; - unsigned usage; -}; - /** * Primitive (point/line/tri) rasterization info @@ -249,7 +236,7 @@ struct pipe_framebuffer_state { unsigned width, height; - /** multiple colorbuffers for multiple render targets */ + /** multiple color buffers for multiple render targets */ unsigned nr_cbufs; struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS]; @@ -285,46 +272,61 @@ struct pipe_sampler_state struct pipe_surface { struct pipe_reference reference; - enum pipe_format format; /**< PIPE_FORMAT_x */ + struct pipe_resource *texture; /**< resource into which this is a view */ + enum pipe_format format; + unsigned width; /**< logical width in pixels */ unsigned height; /**< logical height in pixels */ + unsigned layout; /**< PIPE_SURFACE_LAYOUT_x */ unsigned offset; /**< offset from start of buffer, in bytes */ - unsigned usage; /**< PIPE_BUFFER_USAGE_* */ + unsigned usage; /**< bitmask of PIPE_BIND_x */ unsigned zslice; - struct pipe_texture *texture; /**< texture into which this is a view */ unsigned face; unsigned level; }; /** - * Transfer object. For data transfer to/from a texture. + * A view into a texture that can be bound to a shader stage. */ -struct pipe_transfer +struct pipe_sampler_view { - unsigned x; /**< x offset from start of texture image */ - unsigned y; /**< y offset from start of texture image */ - unsigned width; /**< logical width in pixels */ - unsigned height; /**< logical height in pixels */ - unsigned stride; /**< stride in bytes between rows of blocks */ - enum pipe_transfer_usage usage; /**< PIPE_TRANSFER_* */ + struct pipe_reference reference; + enum pipe_format format; /**< typed PIPE_FORMAT_x */ + struct pipe_resource *texture; /**< texture into which this is a view */ + struct pipe_context *context; /**< context this view belongs to */ + unsigned first_level:8; /**< first mipmap level */ + unsigned last_level:8; /**< last mipmap level */ + unsigned swizzle_r:3; /**< PIPE_SWIZZLE_x for red component */ + unsigned swizzle_g:3; /**< PIPE_SWIZZLE_x for green component */ + unsigned swizzle_b:3; /**< PIPE_SWIZZLE_x for blue component */ + unsigned swizzle_a:3; /**< PIPE_SWIZZLE_x for alpha component */ +}; - struct pipe_texture *texture; /**< texture to transfer to/from */ - unsigned face; - unsigned level; - unsigned zslice; + +/** + * Subregion of 1D/2D/3D image resource. + */ +struct pipe_box +{ + unsigned x; + unsigned y; + unsigned z; + unsigned width; + unsigned height; + unsigned depth; }; /** - * Texture object. + * A memory object/resource such as a vertex buffer or texture. */ -struct pipe_texture -{ +struct pipe_resource +{ struct pipe_reference reference; - + struct pipe_screen *screen; /**< screen that this texture belongs to */ enum pipe_texture_target target; /**< PIPE_TEXTURE_x */ enum pipe_format format; /**< PIPE_FORMAT_x */ @@ -333,16 +335,41 @@ struct pipe_texture unsigned depth0; unsigned last_level:8; /**< Index of last mipmap level present/defined */ - unsigned nr_samples:8; /**< for multisampled surfaces, nr of samples */ + unsigned usage:8; /**< PIPE_USAGE_x (not a bitmask) */ - unsigned tex_usage; /* PIPE_TEXTURE_USAGE_* */ + unsigned bind; /**< bitmask of PIPE_BIND_x */ + unsigned flags; /**< bitmask of PIPE_RESOURCE_FLAG_x */ +}; - struct pipe_screen *screen; /**< screen that this texture belongs to */ + +/** + * Extra indexing info for (cube) texture resources. + */ +struct pipe_subresource +{ + unsigned face:16; + unsigned level:16; }; /** + * Transfer object. For data transfer to/from a resource. + */ +struct pipe_transfer +{ + struct pipe_resource *resource; /**< resource to transfer to/from */ + struct pipe_subresource sr; + enum pipe_transfer_usage usage; + struct pipe_box box; + unsigned stride; + unsigned slice_stride; + void *data; +}; + + + +/** * A vertex buffer. Typically, all the vertex data/attributes for * drawing something will be in one buffer. But it's also possible, for * example, to put colors in one buffer and texcoords in another. @@ -352,7 +379,7 @@ struct pipe_vertex_buffer unsigned stride; /**< stride to same attrib in next vertex, in bytes */ unsigned max_index; /**< number of vertices in this buffer */ unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ - struct pipe_buffer *buffer; /**< the actual buffer */ + struct pipe_resource *buffer; /**< the actual buffer */ }; @@ -373,9 +400,8 @@ struct pipe_vertex_element * this attribute live in? */ unsigned vertex_buffer_index:8; - unsigned nr_components:8; - enum pipe_format src_format; /**< PIPE_FORMAT_* */ + enum pipe_format src_format; }; diff --git a/src/gallium/include/state_tracker/dri1_api.h b/src/gallium/include/state_tracker/dri1_api.h index 603f5d8af83..41a5713a776 100644 --- a/src/gallium/include/state_tracker/dri1_api.h +++ b/src/gallium/include/state_tracker/dri1_api.h @@ -7,13 +7,13 @@ #include "state_tracker/drm_api.h" -#include <drm.h> - struct pipe_screen; struct pipe_winsys; struct pipe_buffer; struct pipe_context; -struct pipe_texture; +struct pipe_resource; + +struct drm_clip_rect; struct dri1_api_version { diff --git a/src/gallium/include/state_tracker/drisw_api.h b/src/gallium/include/state_tracker/drisw_api.h new file mode 100644 index 00000000000..944a649257e --- /dev/null +++ b/src/gallium/include/state_tracker/drisw_api.h @@ -0,0 +1,23 @@ +#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); +}; + +/** + * Implemented by the drisw target. + */ +struct pipe_screen * drisw_create_screen(struct drisw_loader_funcs *lf); + +#endif diff --git a/src/gallium/include/state_tracker/drm_api.h b/src/gallium/include/state_tracker/drm_api.h index 883a4d2b40c..75131307aad 100644 --- a/src/gallium/include/state_tracker/drm_api.h +++ b/src/gallium/include/state_tracker/drm_api.h @@ -9,7 +9,7 @@ struct pipe_winsys; struct pipe_buffer; struct pipe_context; struct pipe_video_context; -struct pipe_texture; +struct pipe_resource; enum drm_create_screen_mode { DRM_CREATE_NORMAL = 0, @@ -18,6 +18,32 @@ enum drm_create_screen_mode { DRM_CREATE_MAX }; +#define DRM_API_HANDLE_TYPE_SHARED 0 +#define DRM_API_HANDLE_TYPE_KMS 1 + +/** + * For use with pipe_screen::{texture_from_handle|texture_get_handle}. + */ +struct winsys_handle +{ + /** + * Unused for texture_from_handle, always + * DRM_API_HANDLE_TYPE_SHARED. Input to texture_get_handle, + * use TEXTURE_USAGE to select handle for kms or ipc. + */ + 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; +}; + /** * Modes other than DRM_CREATE_NORMAL derive from this struct. */ @@ -29,6 +55,8 @@ struct drm_create_screen_arg { struct drm_api { + void (*destroy)(struct drm_api *api); + const char *name; /** @@ -37,37 +65,10 @@ struct drm_api const char *driver_name; /** - * Special buffer functions + * Create a pipe srcreen. */ - /*@{*/ struct pipe_screen* (*create_screen)(struct drm_api *api, int drm_fd, struct drm_create_screen_arg *arg); - /*@}*/ - - /** - * Special buffer functions - */ - /*@{*/ - struct pipe_texture* - (*texture_from_shared_handle)(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *templ, - const char *name, - unsigned stride, - unsigned handle); - boolean (*shared_handle_from_texture)(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle); - boolean (*local_handle_from_texture)(struct drm_api *api, - struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned *stride, - unsigned *handle); - /*@}*/ - - void (*destroy)(struct drm_api *api); }; extern struct drm_api * drm_api_create(void); diff --git a/src/gallium/include/state_tracker/graw.h b/src/gallium/include/state_tracker/graw.h new file mode 100644 index 00000000000..a58e18e4739 --- /dev/null +++ b/src/gallium/include/state_tracker/graw.h @@ -0,0 +1,36 @@ +#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_format.h" + +struct pipe_screen; + +struct pipe_screen *graw_init( void ); + +/* Returns a handle to be used with flush_frontbuffer()/present(). + * + * Query format support with screen::is_format_supported and usage + * XXX. + */ +void *graw_create_window( int x, + int y, + unsigned width, + unsigned height, + enum pipe_format format ); + +void graw_destroy_window( void *handle ); + +#endif diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h new file mode 100644 index 00000000000..002d1c6b840 --- /dev/null +++ b/src/gallium/include/state_tracker/st_api.h @@ -0,0 +1,396 @@ +/********************************************************** + * 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_OPENGL_ES1, + ST_API_OPENGL_ES2, + ST_API_OPENVG, + + ST_API_COUNT +}; + +/** + * 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, +}; + +/** + * 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; +}; + +/** + * Used in st_manager_iface->get_egl_image. + */ +struct st_egl_image +{ + /* these fields are filled by the caller */ + struct st_context_iface *stctxi; + void *egl_image; + + /* this is owned by the caller */ + struct pipe_resource *texture; + + unsigned face; + unsigned level; + unsigned zslice; +}; + +/** + * 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; +}; + +/** + * 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 + * 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 + * atomic flag used for notification of framebuffer dirty status. + * + * The thread syncronisation is put inside the framebuffer + * and only called once the framebuffer has become dirty. + */ +struct st_framebuffer_iface +{ + /** + * 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_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_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; + + /** + * Destroy the context. + */ + void (*destroy)(struct st_context_iface *stctxi); + + /** + * 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. + */ + void (*notify_invalid_framebuffer)(struct st_context_iface *stctxi, + struct st_framebuffer_iface *stfbi); + + /** + * 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); + + /** + * 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 function is optional. + */ + boolean (*get_egl_image)(struct st_manager *smapi, + struct st_egl_image *stimg); +}; + +/** + * Represent a rendering API such as OpenGL or OpenVG. + * + * Implemented by the state tracker and used by the state tracker manager. + */ +struct st_api +{ + /** + * 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. + */ + st_proc_t (*get_proc_address)(struct st_api *stapi, const char *procname); + + /** + * Return true if the visual is supported by the state tracker. + */ + boolean (*is_visual_supported)(struct st_api *stapi, + const struct st_visual *visual); + + /** + * Create a rendering context. + */ + struct st_context_iface *(*create_context)(struct st_api *stapi, + struct st_manager *smapi, + const struct st_visual *visual, + struct st_context_iface *stsharei); + + /** + * Bind the context to the calling thread with draw and read as drawables. + * + * The framebuffers 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); +} + +/* 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_ */ diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h new file mode 100644 index 00000000000..d461dedb90e --- /dev/null +++ b/src/gallium/include/state_tracker/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 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. + * + **************************************************************************/ + +/** + * @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; + + +/** + * 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 *template, + 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 ); + + void + (*displaytarget_destroy)( struct sw_winsys *ws, + struct sw_displaytarget *dt ); +}; + + + +#ifdef __cplusplus +} +#endif + +#endif /* SW_WINSYS_H */ diff --git a/src/gallium/include/state_tracker/xlib_sw_winsys.h b/src/gallium/include/state_tracker/xlib_sw_winsys.h new file mode 100644 index 00000000000..f22c22bb620 --- /dev/null +++ b/src/gallium/include/state_tracker/xlib_sw_winsys.h @@ -0,0 +1,29 @@ +#ifndef XLIB_SW_WINSYS_H +#define XLIB_SW_WINSYS_H + +#include "state_tracker/sw_winsys.h" +#include <X11/Xlib.h> + + +struct pipe_screen; +struct pipe_surface; + +/* 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; +}; + + +/* This is the public interface to the ws/xlib module. Why isn't it + * being defined in that directory? + */ +struct sw_winsys *xlib_create_sw_winsys( Display *display ); + + +#endif |