summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-19 12:04:37 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-19 12:32:29 +0900
commit8aafc03b260ab8923f1b373f7effa75bcdb40a72 (patch)
tree0274cc6cad2d6993ba8ea3fdd34c49254c532d47 /src
parentff26c50153b3a348b35843262ceb27062ab37214 (diff)
gallium: Finer grained is_format_supported.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_blit.c12
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c3
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.c24
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c18
-rw-r--r--src/gallium/drivers/i965simple/brw_screen.c5
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c26
-rw-r--r--src/gallium/include/pipe/p_defines.h7
-rw-r--r--src/gallium/include/pipe/p_screen.h9
-rw-r--r--src/gallium/state_trackers/python/gallium.i15
-rw-r--r--src/gallium/state_trackers/python/samples/tri.py8
-rw-r--r--src/gallium/state_trackers/python/tests/texture.py13
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c3
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c9
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c8
-rw-r--r--src/mesa/state_tracker/st_extensions.c14
-rw-r--r--src/mesa/state_tracker/st_format.c101
-rw-r--r--src/mesa/state_tracker/st_format.h2
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c3
-rw-r--r--src/mesa/state_tracker/st_texture.c3
20 files changed, 158 insertions, 127 deletions
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 3dc9fdd11e..ae087df4cf 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -307,8 +307,10 @@ util_blit_pixels(struct blit_state *ctx,
dstY1 = tmp;
}
- assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE));
- assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE));
+ assert(screen->is_format_supported(screen, src->format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0));
+ assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0));
if(dst->format == src->format && (dstX1 - dstX0) == srcW && (dstY1 - dstY0) == srcH) {
/* FIXME: this will most surely fail for overlapping rectangles */
@@ -319,7 +321,8 @@ util_blit_pixels(struct blit_state *ctx,
return;
}
- assert(screen->is_format_supported(screen, dst->format, PIPE_SURFACE));
+ assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
/*
* XXX for now we're always creating a temporary texture.
@@ -449,7 +452,8 @@ util_blit_pixels_tex(struct blit_state *ctx,
t0 = srcY0 / (float)tex->height[0];
t1 = srcY1 / (float)tex->height[0];
- assert(screen->is_format_supported(screen, dst->format, PIPE_SURFACE));
+ assert(screen->is_format_supported(screen, dst->format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET, 0));
/* save state (restored below) */
cso_save_blend(ctx->cso);
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index 5313a8008a..4999822068 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -858,7 +858,8 @@ util_gen_mipmap(struct gen_mipmap_state *ctx,
uint zslice = 0;
/* check if we can render in the texture's format */
- if (!screen->is_format_supported(screen, pt->format, PIPE_SURFACE)) {
+ if (!screen->is_format_supported(screen, pt->format, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
fallback_gen_mipmap(ctx, pt, face, baseLevel, lastLevel);
return;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c
index 5198b51441..cf9b68b695 100644
--- a/src/gallium/drivers/cell/ppu/cell_screen.c
+++ b/src/gallium/drivers/cell/ppu/cell_screen.c
@@ -115,23 +115,17 @@ cell_get_paramf(struct pipe_screen *screen, int param)
static boolean
cell_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format, uint type )
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags )
{
- switch (type) {
- case PIPE_TEXTURE:
- /* cell supports most texture formats, XXX for now anyway */
- if (format == PIPE_FORMAT_DXT5_RGBA ||
- format == PIPE_FORMAT_R8G8B8A8_SRGB)
- return FALSE;
- else
- return TRUE;
- case PIPE_SURFACE:
- /* cell supports all (off-screen) surface formats, XXX for now */
- return TRUE;
- default:
- assert(0);
+ /* cell supports most formats, XXX for now anyway */
+ if (format == PIPE_FORMAT_DXT5_RGBA ||
+ format == PIPE_FORMAT_R8G8B8A8_SRGB)
return FALSE;
- }
+ else
+ return TRUE;
}
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index ba8f183bdf..4b1b8af7da 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -148,7 +148,10 @@ i915_get_paramf(struct pipe_screen *screen, int param)
static boolean
i915_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format, uint type )
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags )
{
static const enum pipe_format tex_supported[] = {
PIPE_FORMAT_R8G8B8A8_UNORM,
@@ -173,17 +176,10 @@ i915_is_format_supported( struct pipe_screen *screen,
const enum pipe_format *list;
uint i;
- switch (type) {
- case PIPE_TEXTURE:
- list = tex_supported;
- break;
- case PIPE_SURFACE:
+ if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
list = surface_supported;
- break;
- default:
- assert(0);
- return FALSE;
- }
+ else
+ list = tex_supported;
for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
if (list[i] == format)
diff --git a/src/gallium/drivers/i965simple/brw_screen.c b/src/gallium/drivers/i965simple/brw_screen.c
index b700f7e4f5..6d8f24d1c4 100644
--- a/src/gallium/drivers/i965simple/brw_screen.c
+++ b/src/gallium/drivers/i965simple/brw_screen.c
@@ -136,7 +136,10 @@ brw_get_paramf(struct pipe_screen *screen, int param)
static boolean
brw_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format, uint type )
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags )
{
#if 0
/* XXX: This is broken -- rewrite if still needed. */
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index f6193bfaf9..3f9d4b0ed3 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -115,23 +115,19 @@ softpipe_get_paramf(struct pipe_screen *screen, int param)
*/
static boolean
softpipe_is_format_supported( struct pipe_screen *screen,
- enum pipe_format format, uint type )
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags )
{
- switch (type) {
- case PIPE_TEXTURE:
- case PIPE_SURFACE:
- switch(format) {
- case PIPE_FORMAT_DXT1_RGB:
- case PIPE_FORMAT_DXT1_RGBA:
- case PIPE_FORMAT_DXT3_RGBA:
- case PIPE_FORMAT_DXT5_RGBA:
- return FALSE;
- default:
- return TRUE;
- }
- default:
- assert(0);
+ switch(format) {
+ case PIPE_FORMAT_DXT1_RGB:
+ case PIPE_FORMAT_DXT1_RGBA:
+ case PIPE_FORMAT_DXT3_RGBA:
+ case PIPE_FORMAT_DXT5_RGBA:
return FALSE;
+ default:
+ return TRUE;
}
}
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index bc4d7c845a..b1d100ef53 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -172,11 +172,8 @@ enum pipe_texture_target {
#define PIPE_TEXTURE_USAGE_DEPTH_STENCIL 0x8
#define PIPE_TEXTURE_USAGE_SAMPLER 0x10
-/**
- * Surfaces, textures, etc. (others may be added)
- */
-#define PIPE_TEXTURE 1
-#define PIPE_SURFACE 2 /**< user-created surfaces */
+#define PIPE_TEXTURE_GEOM_NON_SQUARE 0x1
+#define PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO 0x2
/**
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index cc8430dae1..b15affef7a 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -77,11 +77,14 @@ struct pipe_screen {
/**
* Check if the given pipe_format is supported as a texture or
* drawing surface.
- * \param type one of PIPE_TEXTURE, PIPE_SURFACE
+ * \param tex_usage bitmask of PIPE_TEXTURE_USAGE_*
+ * \param flags bitmask of PIPE_TEXTURE_GEOM_*
*/
boolean (*is_format_supported)( struct pipe_screen *,
- enum pipe_format format,
- uint type );
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags );
/**
* Create a new texture object, using the given template info.
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index c08ac87aca..8d8b762ea5 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -158,8 +158,15 @@ struct st_context {
* drawing surface.
* \param type one of PIPE_TEXTURE, PIPE_SURFACE
*/
- int is_format_supported( enum pipe_format format, unsigned type ) {
- return $self->screen->is_format_supported( $self->screen, format, type);
+ int is_format_supported( enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags ) {
+ return $self->screen->is_format_supported( $self->screen,
+ format,
+ target,
+ tex_usage,
+ geom_flags );
}
struct st_context *
@@ -175,7 +182,7 @@ struct st_context {
unsigned depth = 1,
unsigned last_level = 0,
enum pipe_texture_target target = PIPE_TEXTURE_2D,
- unsigned usage = 0
+ unsigned tex_usage = 0
) {
struct pipe_texture templat;
memset(&templat, 0, sizeof(templat));
@@ -186,7 +193,7 @@ struct st_context {
templat.depth[0] = depth;
templat.last_level = last_level;
templat.target = target;
- templat.tex_usage = usage;
+ templat.tex_usage = tex_usage;
return $self->screen->texture_create($self->screen, &templat);
}
diff --git a/src/gallium/state_trackers/python/samples/tri.py b/src/gallium/state_trackers/python/samples/tri.py
index 3665922929..1271c67627 100644
--- a/src/gallium/state_trackers/python/samples/tri.py
+++ b/src/gallium/state_trackers/python/samples/tri.py
@@ -140,9 +140,11 @@ def test(dev):
ctx.set_clip(clip)
# framebuffer
- cbuf = dev.texture_create(PIPE_FORMAT_X8R8G8B8_UNORM,
- width, height,
- usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET)
+ cbuf = dev.texture_create(
+ PIPE_FORMAT_X8R8G8B8_UNORM,
+ width, height,
+ tex_usage=PIPE_TEXTURE_USAGE_DISPLAY_TARGET,
+ )
_cbuf = cbuf.get_surface(usage = PIPE_BUFFER_USAGE_GPU_READ|PIPE_BUFFER_USAGE_GPU_WRITE)
fb = Framebuffer()
fb.width = width
diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py
index 16ad78c8aa..b2ca9f416f 100644
--- a/src/gallium/state_trackers/python/tests/texture.py
+++ b/src/gallium/state_trackers/python/tests/texture.py
@@ -136,7 +136,7 @@ class TextureTest(TestCase):
level = self.level
zslice = self.zslice
- if not dev.is_format_supported(format, PIPE_TEXTURE):
+ if not dev.is_format_supported(format, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0):
raise TestSkip
ctx = self.dev.context_create()
@@ -199,6 +199,7 @@ class TextureTest(TestCase):
height = height,
depth = depth,
last_level = last_level,
+ tex_usage = PIPE_TEXTURE_USAGE_SAMPLER,
)
expected_rgba = FloatArray(height*width*4)
@@ -212,10 +213,12 @@ class TextureTest(TestCase):
ctx.set_sampler_texture(0, texture)
# framebuffer
- cbuf_tex = dev.texture_create(PIPE_FORMAT_A8R8G8B8_UNORM,
- width,
- height,
- usage = PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ cbuf_tex = dev.texture_create(
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ width,
+ height,
+ tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ )
cbuf = cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_GPU_WRITE|PIPE_BUFFER_USAGE_GPU_READ)
fb = Framebuffer()
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index e4de875e8c..a357b71677 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -122,7 +122,7 @@ create_color_map_texture(GLcontext *ctx)
const uint texSize = 256; /* simple, and usually perfect */
/* find an RGBA texture format */
- format = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE);
+ format = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER);
/* create texture for color map/table */
pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0,
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index de86832342..d5696a909f 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -746,7 +746,8 @@ st_init_bitmap(struct st_context *st)
st->bitmap.rasterizer.bypass_vs = 1;
/* find a usable texture format */
- if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE)) {
+ if (screen->is_format_supported(screen, PIPE_FORMAT_I8_UNORM, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
st->bitmap.tex_format = PIPE_FORMAT_I8_UNORM;
}
else {
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 2ebfcaf82b..db0c9fbd09 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -995,18 +995,21 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
srcFormat = rbRead->texture->format;
- if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE)) {
+ if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
texFormat = srcFormat;
}
else {
/* srcFormat can't be used as a texture format */
if (type == GL_DEPTH) {
- texFormat = st_choose_format(pipe, GL_DEPTH_COMPONENT, PIPE_TEXTURE);
+ texFormat = st_choose_format(pipe, GL_DEPTH_COMPONENT, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_DEPTH_STENCIL);
assert(texFormat != PIPE_FORMAT_NONE); /* XXX no depth texture formats??? */
}
else {
/* default color format */
- texFormat = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE);
+ texFormat = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER);
assert(texFormat != PIPE_FORMAT_NONE);
}
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index de782e8232..1f94a0b9ef 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -1210,9 +1210,13 @@ do_copy_texsubimage(GLcontext *ctx,
use_fallback = GL_FALSE;
}
else if (screen->is_format_supported(screen, strb->surface->format,
- PIPE_TEXTURE) &&
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER,
+ 0) &&
screen->is_format_supported(screen, dest_surface->format,
- PIPE_SURFACE)) {
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET,
+ 0)) {
boolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
int srcY0, srcY1;
if (do_flip) {
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index d804d2b453..cacf972a1b 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -213,18 +213,24 @@ void st_init_extensions(struct st_context *st)
}
if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
- PIPE_TEXTURE)) {
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
}
#if 01
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
- PIPE_TEXTURE)) {
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE;
}
#endif
- if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, PIPE_TEXTURE) ||
- screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, PIPE_TEXTURE)) {
+ if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
+ screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
}
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 50a06868df..b6d97ef659 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -281,7 +281,10 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
* Find an RGBA format supported by the context/winsys.
*/
static enum pipe_format
-default_rgba_format(struct pipe_screen *screen, uint type)
+default_rgba_format(struct pipe_screen *screen,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags)
{
static const enum pipe_format colorFormats[] = {
PIPE_FORMAT_A8R8G8B8_UNORM,
@@ -291,7 +294,7 @@ default_rgba_format(struct pipe_screen *screen, uint type)
};
uint i;
for (i = 0; i < Elements(colorFormats); i++) {
- if (screen->is_format_supported( screen, colorFormats[i], type )) {
+ if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
return colorFormats[i];
}
}
@@ -303,13 +306,16 @@ default_rgba_format(struct pipe_screen *screen, uint type)
* Search list of formats for first RGBA format with >8 bits/channel.
*/
static enum pipe_format
-default_deep_rgba_format(struct pipe_screen *screen, uint type)
+default_deep_rgba_format(struct pipe_screen *screen,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags)
{
- if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, type)) {
+ if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SNORM, target, tex_usage, geom_flags)) {
return PIPE_FORMAT_R16G16B16A16_SNORM;
}
- if (type == PIPE_TEXTURE)
- return default_rgba_format(screen, type);
+ if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ return default_rgba_format(screen, target, tex_usage, geom_flags);
else
return PIPE_FORMAT_NONE;
}
@@ -319,7 +325,10 @@ default_deep_rgba_format(struct pipe_screen *screen, uint type)
* Find an Z format supported by the context/winsys.
*/
static enum pipe_format
-default_depth_format(struct pipe_screen *screen, uint type)
+default_depth_format(struct pipe_screen *screen,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags)
{
static const enum pipe_format zFormats[] = {
PIPE_FORMAT_Z16_UNORM,
@@ -329,7 +338,7 @@ default_depth_format(struct pipe_screen *screen, uint type)
};
uint i;
for (i = 0; i < Elements(zFormats); i++) {
- if (screen->is_format_supported( screen, zFormats[i], type )) {
+ if (screen->is_format_supported( screen, zFormats[i], target, tex_usage, geom_flags )) {
return zFormats[i];
}
}
@@ -343,12 +352,10 @@ default_depth_format(struct pipe_screen *screen, uint type)
*/
enum pipe_format
st_choose_format(struct pipe_context *pipe, GLint internalFormat,
- uint surfType)
+ enum pipe_texture_target target, unsigned tex_usage)
{
struct pipe_screen *screen = pipe->screen;
-
- assert(surfType == PIPE_SURFACE ||
- surfType == PIPE_TEXTURE);
+ unsigned geom_flags = 0;
switch (internalFormat) {
case 4:
@@ -360,38 +367,38 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_RGBA16:
- if (surfType == PIPE_SURFACE)
- return default_deep_rgba_format( screen, surfType );
+ if (tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET)
+ return default_deep_rgba_format( screen, target, tex_usage, geom_flags );
else
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_RGBA4:
case GL_RGBA2:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_A4R4G4B4_UNORM;
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_RGB5_A1:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_A1R5G5B5_UNORM;
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_A1R5G5B5_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_R5G6B5_UNORM;
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_ALPHA:
case GL_ALPHA4:
@@ -399,9 +406,9 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
case GL_ALPHA12:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_A8_UNORM;
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case 1:
case GL_LUMINANCE:
@@ -410,9 +417,9 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
case GL_LUMINANCE12:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
- if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_L8_UNORM;
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case 2:
case GL_LUMINANCE_ALPHA:
@@ -423,9 +430,9 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
- if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_A8L8_UNORM;
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_INTENSITY:
case GL_INTENSITY4:
@@ -433,17 +440,17 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
case GL_INTENSITY12:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
- if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_I8_UNORM;
- return default_rgba_format( screen, surfType );
+ return default_rgba_format( screen, target, tex_usage, geom_flags );
case GL_YCBCR_MESA:
if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR,
- PIPE_TEXTURE)) {
+ target, tex_usage, geom_flags)) {
return PIPE_FORMAT_YCBCR;
}
if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV,
- PIPE_TEXTURE)) {
+ target, tex_usage, geom_flags)) {
return PIPE_FORMAT_YCBCR_REV;
}
return PIPE_FORMAT_NONE;
@@ -472,40 +479,40 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
#endif
case GL_DEPTH_COMPONENT16:
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_Z16_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT24:
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_S8Z24_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_Z24S8_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT32:
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_Z32_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT:
- return default_depth_format( screen, surfType );
+ return default_depth_format( screen, target, tex_usage, geom_flags );
case GL_STENCIL_INDEX:
case GL_STENCIL_INDEX1_EXT:
case GL_STENCIL_INDEX4_EXT:
case GL_STENCIL_INDEX8_EXT:
case GL_STENCIL_INDEX16_EXT:
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_S8_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_S8Z24_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_Z24S8_UNORM;
return PIPE_FORMAT_NONE;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_S8Z24_UNORM;
- if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, surfType ))
+ if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags ))
return PIPE_FORMAT_Z24S8_UNORM;
return PIPE_FORMAT_NONE;
@@ -521,7 +528,8 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
enum pipe_format
st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
{
- return st_choose_format(pipe, internalFormat, PIPE_SURFACE);
+ return st_choose_format(pipe, internalFormat, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET);
}
@@ -587,7 +595,8 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
(void) format;
(void) type;
- pFormat = st_choose_format(ctx->st->pipe, internalFormat, PIPE_TEXTURE);
+ pFormat = st_choose_format(ctx->st->pipe, internalFormat, PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER);
if (pFormat == PIPE_FORMAT_NONE)
return NULL;
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index ff0fd042db..3f5ac3201b 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -65,7 +65,7 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat);
extern enum pipe_format
st_choose_format(struct pipe_context *pipe, GLint internalFormat,
- uint surfType);
+ enum pipe_texture_target target, unsigned tex_usage);
extern enum pipe_format
st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat);
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 2fc00df429..6db9bc0dd5 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -86,7 +86,8 @@ st_render_mipmap(struct st_context *st,
assert(target != GL_TEXTURE_3D); /* not done yet */
/* check if we can render in the texture's format */
- if (!screen->is_format_supported(screen, pt->format, PIPE_SURFACE)) {
+ if (!screen->is_format_supported(screen, pt->format, target,
+ PIPE_TEXTURE_USAGE_RENDER_TARGET, 0)) {
return FALSE;
}
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 8222826e7a..3e5054ecd2 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -88,7 +88,8 @@ st_texture_create(struct st_context *st,
_mesa_lookup_enum_by_nr(format), last_level);
assert(format);
- assert(screen->is_format_supported(screen, format, PIPE_TEXTURE));
+ assert(screen->is_format_supported(screen, format, target,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0));
memset(&pt, 0, sizeof(pt));
pt.target = target;