summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-12-10 13:48:09 -0700
committerBrian <brian.paul@tungstengraphics.com>2007-12-10 13:48:09 -0700
commit4f58d9af9addb1506a1b2abc7dd8012147772b78 (patch)
treead223bf21560a3690d367e1cfedceb9fd2791f7e /src/mesa/pipe
parentf26936b35253b697f1ccb5c2898a8607564bdcfe (diff)
Add 'type' parameter to is_format_supported() to specify texture vs. drawing surface, etc.
Additional types may be added in the future.
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c77
-rw-r--r--src/mesa/pipe/p_context.h3
-rw-r--r--src/mesa/pipe/p_defines.h7
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c24
-rw-r--r--src/mesa/pipe/softpipe/sp_winsys.h16
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c26
6 files changed, 70 insertions, 83 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index b915a67790..f505ff6ae6 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -39,72 +39,61 @@
/**
- * Query format support.
- * If we find texture and drawable support differs, add a selector
- * parameter or another function.
+ * Query format support for creating a texture, drawing surface, etc.
+ * \param format the format to test
+ * \param type one of PIPE_TEXTURE, PIPE_SURFACE, PIPE_SCREEN_SURFACE
*/
static boolean
i915_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format )
+ enum pipe_format format, uint type )
{
-#if 0
- /* XXX: This is broken -- rewrite if still needed. */
- static const unsigned tex_supported[] = {
+ static const enum pipe_format tex_supported[] = {
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM,
PIPE_FORMAT_U_L8,
PIPE_FORMAT_U_A8,
PIPE_FORMAT_U_I8,
- PIPE_FORMAT_U_L8_A8,
+ PIPE_FORMAT_U_A8_L8,
PIPE_FORMAT_YCBCR,
PIPE_FORMAT_YCBCR_REV,
PIPE_FORMAT_S8Z24_UNORM,
+ PIPE_FORMAT_NONE /* list terminator */
};
-
-
- /* Actually a lot more than this - add later:
- */
- static const unsigned render_supported[] = {
+ static const enum pipe_format surface_supported[] = {
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM,
- };
-
- /*
- */
- static const unsigned z_stencil_supported[] = {
- PIPE_FORMAT_Z16_UNORM,
- PIPE_FORMAT_Z32_UNORM,
PIPE_FORMAT_S8Z24_UNORM,
+ PIPE_FORMAT_R16G16B16A16_SNORM,
+ PIPE_FORMAT_NONE /* list terminator */
+ };
+ static const enum pipe_format screen_surface_supported[] = {
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ PIPE_FORMAT_NONE /* list terminator */
};
+ const enum pipe_format *list;
+ uint i;
switch (type) {
- case PIPE_RENDER_FORMAT:
- *numFormats = Elements(render_supported);
- return render_supported;
-
- case PIPE_TEX_FORMAT:
- *numFormats = Elements(tex_supported);
- return render_supported;
-
- case PIPE_Z_STENCIL_FORMAT:
- *numFormats = Elements(render_supported);
- return render_supported;
-
+ case PIPE_TEXTURE:
+ list = tex_supported;
+ break;
+ case PIPE_SURFACE:
+ list = surface_supported;
+ break;
+ case PIPE_SCREEN_SURFACE:
+ list = screen_surface_supported;
+ break;
default:
- *numFormats = 0;
- return NULL;
+ assert(0);
}
-#else
- switch( format ) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- return TRUE;
- default:
- return FALSE;
- };
-#endif
+
+ for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
+ if (list[i] == format)
+ return TRUE;
+ }
+
+ return FALSE;
}
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index b3a2122ade..00379fbacf 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -50,8 +50,9 @@ struct pipe_context {
/*
* Queries
*/
+ /** type is one of PIPE_SURFACE, PIPE_TEXTURE, etc. */
boolean (*is_format_supported)( struct pipe_context *pipe,
- enum pipe_format format );
+ enum pipe_format format, uint type );
const char *(*get_name)( struct pipe_context *pipe );
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index 8dce3aba90..d3afef95b4 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -161,10 +161,11 @@
#define PIPE_TEX_FACE_MAX 6
/**
- * Surface flags
+ * Surfaces, textures, etc. (others may be added)
*/
-#define PIPE_SURFACE_FLAG_TEXTURE 0x1
-#define PIPE_SURFACE_FLAG_RENDER 0x2
+#define PIPE_TEXTURE 1
+#define PIPE_SURFACE 2 /**< user-created surfaces */
+#define PIPE_SCREEN_SURFACE 3 /**< On-screen front/back colorbuffer */
/**
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 809b165f45..8b8e04c2f9 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -46,17 +46,29 @@
/**
- * Query format support.
- * If we find texture and drawable support differs, add a selector
- * parameter or another function.
+ * Query format support for creating a texture, drawing surface, etc.
+ * \param format the format to test
+ * \param type one of PIPE_TEXTURE, PIPE_SURFACE, PIPE_SCREEN_SURFACE
*/
static boolean
softpipe_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format )
+ enum pipe_format format, uint type )
{
struct softpipe_context *softpipe = softpipe_context( pipe );
- /* ask winsys if the format is supported */
- return softpipe->winsys->is_format_supported( softpipe->winsys, format );
+
+ switch (type) {
+ case PIPE_TEXTURE:
+ /* softpipe supports all texture formats */
+ return TRUE;
+ case PIPE_SURFACE:
+ /* softpipe supports all (off-screen) surface formats */
+ return TRUE;
+ case PIPE_SCREEN_SURFACE:
+ return softpipe->winsys->is_format_supported( softpipe->winsys, format );
+ default:
+ assert(0);
+ return FALSE;
+ }
}
diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h
index 1912e59b9f..cbf64ebb85 100644
--- a/src/mesa/pipe/softpipe/sp_winsys.h
+++ b/src/mesa/pipe/softpipe/sp_winsys.h
@@ -25,21 +25,23 @@
*
**************************************************************************/
+/* This is the interface that softpipe requires any window system
+ * hosting it to implement. This is the only include file in softpipe
+ * which is public.
+ */
+
+
#ifndef SP_WINSYS_H
#define SP_WINSYS_H
-#include "pipe/p_compiler.h" // for boolean
+#include "pipe/p_compiler.h" /* for boolean */
-/* This is the interface that softpipe requires any window system
- * hosting it to implement. This is the only include file in softpipe
- * which is public.
- */
-
struct softpipe_winsys {
+ /** test if the given format is supported for front/back color bufs */
boolean (*is_format_supported)( struct softpipe_winsys *sws,
- uint format );
+ enum pipe_format format );
};
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
index c347d1c2a3..68f9c39116 100644
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ b/src/mesa/pipe/xlib/xm_winsys.c
@@ -71,7 +71,7 @@ struct xmesa_surface
struct xmesa_softpipe_winsys
{
struct softpipe_winsys spws;
- uint pixelformat;
+ enum pipe_format pixelformat;
};
@@ -377,35 +377,17 @@ xmesa_get_pipe_winsys(void)
/**
+ * Called via softpipe_winsys->is_format_supported().
+ * This function is only called to test formats for front/back color surfaces.
* The winsys being queried will have been created at glXCreateContext
* time, with a pixel format corresponding to the context's visual.
- *
- * XXX we should pass a flag indicating if the format is going to be
- * use for a drawing surface vs. a texture. In the later case, we
- * can support any format.
*/
static boolean
xmesa_is_format_supported(struct softpipe_winsys *sws,
enum pipe_format format)
{
struct xmesa_softpipe_winsys *xmws = xmesa_softpipe_winsys(sws);
-
- if (format == xmws->pixelformat) {
- return TRUE;
- }
- else {
- /* non-color / window surface format */
- switch (format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- case PIPE_FORMAT_U_S8:
- case PIPE_FORMAT_Z16_UNORM:
- case PIPE_FORMAT_Z32_UNORM:
- return TRUE;
- default:
- return FALSE;
- }
- }
+ return (format == xmws->pixelformat);
}