Commit 8aafc03b authored by José Fonseca's avatar José Fonseca

gallium: Finer grained is_format_supported.

parent ff26c501
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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. */
......
......@@ -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;
}
}
......
......@@ -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
/**
......
......@@ -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.
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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()
......
......@@ -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,
......
......@@ -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 {
......
......@@ -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);
}
}
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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;