diff options
author | Michal Krol <[email protected]> | 2007-10-28 17:19:39 +0000 |
---|---|---|
committer | Michal Krol <[email protected]> | 2007-10-28 17:34:39 +0000 |
commit | 3c8121967224f91bfcd5431b4069d66eecbc5952 (patch) | |
tree | 0f02118d163e144074dc4e5cafd21fdfbcb2f7ee | |
parent | b85cd7b70096cf7c922aed56ae8255fb4b8f0709 (diff) |
Replace supported_formats with is_format_supported interface.
The old supported_formats interface returned a list of formats
supported by a pipe/winsys implementation. This was reasonable
when gallium had a fixed list of predefined format.
Now things has changed and the definition of PIPE_FORMAT is
more flexible.
The new shiny is_format_supported interface gets PIPE_FORMAT
as an argument and returns a boolean whether this particular
format is supported.
-rw-r--r-- | src/mesa/drivers/x11/xm_api.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xm_surface.c | 18 | ||||
-rw-r--r-- | src/mesa/drivers/x11/xmesaP.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/failover/fo_context.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_context.c | 24 | ||||
-rw-r--r-- | src/mesa/pipe/p_context.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 12 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_winsys.h | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 33 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 70 |
10 files changed, 75 insertions, 98 deletions
diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index 1d2b93d100b..4b31447bbd5 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -1616,7 +1616,7 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list ) #if 0 mesaCtx->st->pipe->surface_alloc = xmesa_surface_alloc; #endif - mesaCtx->st->pipe->supported_formats = xmesa_supported_formats; + mesaCtx->st->pipe->is_format_supported = xmesa_is_format_supported; mesaCtx->st->pipe->get_tile_rgba = xmesa_get_tile_rgba; mesaCtx->st->pipe->put_tile_rgba = xmesa_put_tile_rgba; diff --git a/src/mesa/drivers/x11/xm_surface.c b/src/mesa/drivers/x11/xm_surface.c index dbbf26e33ff..5533158ece0 100644 --- a/src/mesa/drivers/x11/xm_surface.c +++ b/src/mesa/drivers/x11/xm_surface.c @@ -195,18 +195,16 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint pipeFormat) } -const GLuint * -xmesa_supported_formats(struct pipe_context *pipe, GLuint *numFormats) +boolean +xmesa_is_format_supported(struct pipe_context *pipe, uint format) { - static const GLuint formats[] = { - PIPE_FORMAT_U_A8_R8_G8_B8, - PIPE_FORMAT_S_R16_G16_B16_A16, - PIPE_FORMAT_S8_Z24 + switch( format ) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + case PIPE_FORMAT_S_R16_G16_B16_A16: + case PIPE_FORMAT_S8_Z24: + return TRUE; }; - - *numFormats = sizeof(formats) / sizeof(formats[0]); - - return formats; + return FALSE; } diff --git a/src/mesa/drivers/x11/xmesaP.h b/src/mesa/drivers/x11/xmesaP.h index 8af95504fb6..4709d633942 100644 --- a/src/mesa/drivers/x11/xmesaP.h +++ b/src/mesa/drivers/x11/xmesaP.h @@ -618,8 +618,8 @@ xmesa_surface_alloc(struct pipe_context *pipe, GLuint format); extern struct pipe_surface * xmesa_new_color_surface(struct pipe_context *pipe, GLuint format); -extern const uint * -xmesa_supported_formats(struct pipe_context *pipe, uint *numFormats); +extern boolean +xmesa_is_format_supported(struct pipe_context *pipe, uint format); extern void xmesa_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *ps, diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c index 7e02b751bb3..aa5d0885e6a 100644 --- a/src/mesa/pipe/failover/fo_context.c +++ b/src/mesa/pipe/failover/fo_context.c @@ -116,7 +116,7 @@ struct pipe_context *failover_create( struct pipe_context *hw, failover->pipe.winsys = hw->winsys; failover->pipe.destroy = failover_destroy; - failover->pipe.supported_formats = hw->supported_formats; + failover->pipe.is_format_supported = hw->is_format_supported; failover->pipe.max_texture_size = hw->max_texture_size; failover->pipe.get_name = hw->get_name; failover->pipe.get_vendor = hw->get_vendor; diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c index 161f8ce6972..6541f0e8484 100644 --- a/src/mesa/pipe/i915simple/i915_context.c +++ b/src/mesa/pipe/i915simple/i915_context.c @@ -40,16 +40,16 @@ /** - * Return list of supported surface/texture formats. + * Query format support. * If we find texture and drawable support differs, add a selector * parameter or another function. */ -static const unsigned * -i915_supported_formats(struct pipe_context *pipe, -// unsigned type, - unsigned *numFormats) +static boolean +i915_is_format_supported( struct pipe_context *pipe, + uint format ) { #if 0 + /* XXX: This is broken -- rewrite if still needed. */ static const unsigned tex_supported[] = { PIPE_FORMAT_U_R8_G8_B8_A8, PIPE_FORMAT_U_A8_R8_G8_B8, @@ -97,13 +97,13 @@ i915_supported_formats(struct pipe_context *pipe, return NULL; } #else - static const unsigned render_supported[] = { - PIPE_FORMAT_U_A8_R8_G8_B8, - PIPE_FORMAT_U_R5_G6_B5, - PIPE_FORMAT_S8_Z24, + switch( format ) { + case PIPE_FORMAT_U_A8_R8_G8_B8: + case PIPE_FORMAT_U_R5_G6_B5: + case PIPE_FORMAT_S8_Z24: + return TRUE; }; - *numFormats = 3; - return render_supported; + return FALSE; #endif } @@ -303,7 +303,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys, i915->pipe.winsys = pipe_winsys; i915->pipe.destroy = i915_destroy; - i915->pipe.supported_formats = i915_supported_formats; + i915->pipe.is_format_supported = i915_is_format_supported; i915->pipe.max_texture_size = i915_max_texture_size; i915->pipe.get_param = i915_get_param; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index dbbf48c5760..a1441a7e430 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -44,8 +44,8 @@ struct pipe_context { /* * Queries */ - const unsigned *(*supported_formats)(struct pipe_context *pipe, - unsigned *numFormats); + boolean (*is_format_supported)( struct pipe_context *pipe, + uint format ); void (*max_texture_size)(struct pipe_context *pipe, unsigned textureType, /* PIPE_TEXTURE_x */ diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c index 3a1861cb62f..f67588783be 100644 --- a/src/mesa/pipe/softpipe/sp_context.c +++ b/src/mesa/pipe/softpipe/sp_context.c @@ -46,14 +46,16 @@ /** - * Return list of supported surface/texture formats. + * Query format support. * If we find texture and drawable support differs, add a selector * parameter or another function. */ -static const unsigned * -softpipe_supported_formats(struct pipe_context *pipe, unsigned *numFormats) +static boolean +softpipe_is_format_supported( struct pipe_context *pipe, + uint format ) { #if 0 + /* XXX: This is broken -- rewrite if still needed. */ static const unsigned supported[] = { PIPE_FORMAT_U_R8_G8_B8_A8, PIPE_FORMAT_U_A8_R8_G8_B8, @@ -76,7 +78,7 @@ softpipe_supported_formats(struct pipe_context *pipe, unsigned *numFormats) return supported; #else struct softpipe_context *softpipe = softpipe_context( pipe ); - return softpipe->winsys->supported_formats( softpipe->winsys, numFormats ); + return softpipe->winsys->is_format_supported( softpipe->winsys, format ); #endif } @@ -298,7 +300,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys, softpipe->pipe.destroy = softpipe_destroy; /* queries */ - softpipe->pipe.supported_formats = softpipe_supported_formats; + softpipe->pipe.is_format_supported = softpipe_is_format_supported; softpipe->pipe.max_texture_size = softpipe_max_texture_size; softpipe->pipe.get_param = softpipe_get_param; diff --git a/src/mesa/pipe/softpipe/sp_winsys.h b/src/mesa/pipe/softpipe/sp_winsys.h index 726e4c8bb6b..d8ae9711884 100644 --- a/src/mesa/pipe/softpipe/sp_winsys.h +++ b/src/mesa/pipe/softpipe/sp_winsys.h @@ -35,8 +35,8 @@ */ struct softpipe_winsys { - const unsigned *(*supported_formats)(struct softpipe_winsys *sws, - unsigned *numFormats); + boolean (*is_format_supported)( struct softpipe_winsys *sws, + uint format ); }; diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 896ba2b905e..99e1e3ed25d 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -937,31 +937,26 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height, { struct pipe_context *pipe = ctx->st->pipe; const uint flags = PIPE_SURFACE_FLAG_TEXTURE; - uint numFormats, i, format = 0, cpp, comp, pitch; - const uint *formats = ctx->st->pipe->supported_formats(pipe, &numFormats); + uint format = 0, cpp, comp, pitch; ubyte *dest; struct pipe_mipmap_tree *mt; int row, col; /* find a texture format we know */ - for (i = 0; i < numFormats; i++) { - switch (formats[i]) { - case PIPE_FORMAT_U_I8: - format = formats[i]; - cpp = 1; - comp = 0; - break; - case PIPE_FORMAT_U_A8_R8_G8_B8: - format = formats[i]; - cpp = 4; - comp = 3; /* alpha channel */ /*XXX little-endian dependency */ - break; - default: - /* XXX support more formats */ - ; - } + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8 )) { + format = PIPE_FORMAT_U_I8; + cpp = 1; + comp = 0; + } + else if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) { + format = PIPE_FORMAT_U_A8_R8_G8_B8; + cpp = 4; + comp = 3; /* alpha channel */ /*XXX little-endian dependency */ + } + else { + /* XXX support more formats */ + assert( 0 ); } - assert(format); /** * Create a mipmap tree. diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 5a50d2d63a4..c0e1a79bad0 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -342,24 +342,6 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat) } } -/* XXX: This function should be implemented by pipe object. */ -static GLboolean -allow_format( - struct pipe_context *pipe, - unsigned format ) -{ - const GLuint *supported; - GLuint i, n; - - supported = pipe->supported_formats( pipe, &n ); - for (i = 0; i < n; i++) { - if (supported[i] == format) { - return GL_TRUE; - } - } - return GL_FALSE; -} - /** * Search list of formats for first RGBA format. */ @@ -367,13 +349,13 @@ static GLuint default_rgba_format( struct pipe_context *pipe ) { - if (allow_format( pipe, PIPE_FORMAT_U_R8_G8_B8_A8 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R8_G8_B8_A8 )) { return PIPE_FORMAT_U_R8_G8_B8_A8; } - if (allow_format( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) { return PIPE_FORMAT_U_A8_R8_G8_B8; } - if (allow_format( pipe, PIPE_FORMAT_U_R5_G6_B5 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R5_G6_B5 )) { return PIPE_FORMAT_U_R5_G6_B5; } return PIPE_FORMAT_NONE; @@ -387,7 +369,7 @@ static GLuint default_deep_rgba_format( struct pipe_context *pipe ) { - if (allow_format( pipe, PIPE_FORMAT_S_R16_G16_B16_A16 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S_R16_G16_B16_A16 )) { return PIPE_FORMAT_S_R16_G16_B16_A16; } return PIPE_FORMAT_NONE; @@ -401,13 +383,13 @@ static GLuint default_depth_format( struct pipe_context *pipe ) { - if (allow_format( pipe, PIPE_FORMAT_U_Z16 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z16 )) { return PIPE_FORMAT_U_Z16; } - if (allow_format( pipe, PIPE_FORMAT_U_Z32 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 )) { return PIPE_FORMAT_U_Z32; } - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) { + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) { return PIPE_FORMAT_S8_Z24; } return PIPE_FORMAT_NONE; @@ -437,15 +419,15 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_COMPRESSED_RGBA: if (format == GL_BGRA) { if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) { - if (allow_format( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_R8_G8_B8 )) return PIPE_FORMAT_U_A8_R8_G8_B8; } else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) { - if (allow_format( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) return PIPE_FORMAT_U_A4_R4_G4_B4; } else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) { - if (allow_format( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) return PIPE_FORMAT_U_A1_R5_G5_B5; } } @@ -455,7 +437,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_RGB: case GL_COMPRESSED_RGB: if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { - if (allow_format( pipe, PIPE_FORMAT_U_R5_G6_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_R5_G6_B5 )) return PIPE_FORMAT_U_R5_G6_B5; } return default_rgba_format( pipe ); @@ -469,12 +451,12 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_RGBA4: case GL_RGBA2: - if (allow_format( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A4_R4_G4_B4 )) return PIPE_FORMAT_U_A4_R4_G4_B4; return default_rgba_format( pipe ); case GL_RGB5_A1: - if (allow_format( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) return PIPE_FORMAT_U_A1_R5_G5_B5; return default_rgba_format( pipe ); @@ -487,7 +469,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_RGB5: case GL_RGB4: case GL_R3_G3_B2: - if (allow_format( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A1_R5_G5_B5 )) return PIPE_FORMAT_U_A1_R5_G5_B5; return default_rgba_format( pipe ); @@ -497,7 +479,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_ALPHA12: case GL_ALPHA16: case GL_COMPRESSED_ALPHA: - if (allow_format( pipe, PIPE_FORMAT_U_A8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 )) return PIPE_FORMAT_U_A8; return default_rgba_format( pipe ); @@ -508,7 +490,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_LUMINANCE12: case GL_LUMINANCE16: case GL_COMPRESSED_LUMINANCE: - if (allow_format( pipe, PIPE_FORMAT_U_A8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 )) return PIPE_FORMAT_U_A8; return default_rgba_format( pipe ); @@ -521,7 +503,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: - if (allow_format( pipe, PIPE_FORMAT_U_A8_L8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_L8 )) return PIPE_FORMAT_U_A8_L8; return default_rgba_format( pipe ); @@ -531,17 +513,17 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_INTENSITY12: case GL_INTENSITY16: case GL_COMPRESSED_INTENSITY: - if (allow_format( pipe, PIPE_FORMAT_U_I8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8 )) return PIPE_FORMAT_U_I8; return default_rgba_format( pipe ); case GL_YCBCR_MESA: if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE) { - if (allow_format( pipe, PIPE_FORMAT_YCBCR )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR )) return PIPE_FORMAT_YCBCR; } else { - if (allow_format( pipe, PIPE_FORMAT_YCBCR_REV )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR_REV )) return PIPE_FORMAT_YCBCR_REV; } return PIPE_FORMAT_NONE; @@ -570,15 +552,15 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, #endif case GL_DEPTH_COMPONENT16: - if (allow_format( pipe, PIPE_FORMAT_U_Z16 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z16 )) return PIPE_FORMAT_U_Z16; /* fall-through */ case GL_DEPTH_COMPONENT24: - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; /* fall-through */ case GL_DEPTH_COMPONENT32: - if (allow_format( pipe, PIPE_FORMAT_U_Z32 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_Z32 )) return PIPE_FORMAT_U_Z32; /* fall-through */ case GL_DEPTH_COMPONENT: @@ -589,15 +571,15 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, case GL_STENCIL_INDEX4_EXT: case GL_STENCIL_INDEX8_EXT: case GL_STENCIL_INDEX16_EXT: - if (allow_format( pipe, PIPE_FORMAT_U_S8 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_S8 )) return PIPE_FORMAT_U_S8; - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; return PIPE_FORMAT_NONE; case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - if (allow_format( pipe, PIPE_FORMAT_S8_Z24 )) + if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8_Z24 )) return PIPE_FORMAT_S8_Z24; return PIPE_FORMAT_NONE; |