summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
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/state_tracker
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/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c4
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c11
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.h3
-rw-r--r--src/mesa/state_tracker/st_format.c95
-rw-r--r--src/mesa/state_tracker/st_format.h2
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c29
6 files changed, 71 insertions, 73 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index c0e41dbeec..0179000353 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -993,13 +993,13 @@ make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
int row, col;
/* find a texture format we know */
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8 )) {
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8, PIPE_TEXTURE )) {
format = PIPE_FORMAT_U_I8;
internal_format = GL_INTENSITY8;
cpp = 1;
comp = 0;
}
- else if (pipe->is_format_supported( pipe, PIPE_FORMAT_A8R8G8B8_UNORM )) {
+ else if (pipe->is_format_supported( pipe, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_TEXTURE )) {
format = PIPE_FORMAT_A8R8G8B8_UNORM;
internal_format = GL_RGBA8;
cpp = 4;
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 36d25a576d..6e9e7e3a24 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -87,12 +87,14 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
{
struct pipe_context *pipe = ctx->st->pipe;
struct st_renderbuffer *strb = st_renderbuffer(rb);
+ uint type = strb->screenSurface ? PIPE_SCREEN_SURFACE : PIPE_SURFACE;
const enum pipe_format pipeFormat
- = st_choose_pipe_format(pipe, internalFormat, GL_NONE, GL_NONE);
+ = st_choose_pipe_format(pipe, internalFormat, GL_NONE, GL_NONE, type);
GLuint cpp;
- GLbitfield flags = PIPE_SURFACE_FLAG_RENDER; /* want to render to surface */
+ GLbitfield flags = 0x0; /* XXX needed? */
cpp = init_renderbuffer_bits(strb, pipeFormat);
+ assert(cpp);
if (strb->surface && strb->surface->format != pipeFormat) {
/* need to change surface types, free this surface */
@@ -201,9 +203,11 @@ st_new_renderbuffer(GLcontext *ctx, GLuint name)
/**
* Allocate a renderbuffer for a an on-screen window (not a user-created
* renderbuffer). The window system code determines the internal format.
+ * \param screenSurface indicates if the renderbuffer is a front/back color
+ * buffer that'll be displayed/copied to the screen
*/
struct gl_renderbuffer *
-st_new_renderbuffer_fb(GLenum intFormat)
+st_new_renderbuffer_fb(GLenum intFormat, GLboolean screenSurface)
{
struct st_renderbuffer *strb;
@@ -216,6 +220,7 @@ st_new_renderbuffer_fb(GLenum intFormat)
_mesa_init_renderbuffer(&strb->Base, 0);
strb->Base.ClassID = 0x4242; /* just a unique value */
strb->Base.InternalFormat = intFormat;
+ strb->screenSurface = screenSurface;
switch (intFormat) {
case GL_RGB5:
diff --git a/src/mesa/state_tracker/st_cb_fbo.h b/src/mesa/state_tracker/st_cb_fbo.h
index 2280441db5..bd85bfc549 100644
--- a/src/mesa/state_tracker/st_cb_fbo.h
+++ b/src/mesa/state_tracker/st_cb_fbo.h
@@ -39,6 +39,7 @@ struct st_renderbuffer
{
struct gl_renderbuffer Base;
struct pipe_surface *surface;
+ GLboolean screenSurface; /**< A front/back colorbuffer? */
};
@@ -50,7 +51,7 @@ st_renderbuffer(struct gl_renderbuffer *rb)
extern struct gl_renderbuffer *
-st_new_renderbuffer_fb(GLenum intFormat);
+st_new_renderbuffer_fb(GLenum intFormat, GLboolean screen_surface);
extern void
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 8d39e1bec6..c292a975f3 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -276,10 +276,9 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
* Find an RGBA format supported by the context/winsys.
*/
static GLuint
-default_rgba_format(
- struct pipe_context *pipe )
+default_rgba_format(struct pipe_context *pipe, uint type)
{
- static const uint colorFormats[] = {
+ static const enum pipe_format colorFormats[] = {
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_B8G8R8A8_UNORM,
@@ -287,7 +286,7 @@ default_rgba_format(
};
uint i;
for (i = 0; i < Elements(colorFormats); i++) {
- if (pipe->is_format_supported( pipe, colorFormats[i] )) {
+ if (pipe->is_format_supported( pipe, colorFormats[i], type )) {
return colorFormats[i];
}
}
@@ -299,10 +298,9 @@ default_rgba_format(
* Search list of formats for first RGBA format with >8 bits/channel.
*/
static GLuint
-default_deep_rgba_format(
- struct pipe_context *pipe )
+default_deep_rgba_format(struct pipe_context *pipe, uint type)
{
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_R16G16B16A16_SNORM )) {
+ if (pipe->is_format_supported(pipe, PIPE_FORMAT_R16G16B16A16_SNORM, type)) {
return PIPE_FORMAT_R16G16B16A16_SNORM;
}
return PIPE_FORMAT_NONE;
@@ -313,10 +311,9 @@ default_deep_rgba_format(
* Find an Z format supported by the context/winsys.
*/
static GLuint
-default_depth_format(
- struct pipe_context *pipe )
+default_depth_format(struct pipe_context *pipe, uint type)
{
- static const uint zFormats[] = {
+ static const enum pipe_format zFormats[] = {
PIPE_FORMAT_Z16_UNORM,
PIPE_FORMAT_Z32_UNORM,
PIPE_FORMAT_S8Z24_UNORM,
@@ -324,7 +321,7 @@ default_depth_format(
};
uint i;
for (i = 0; i < Elements(zFormats); i++) {
- if (pipe->is_format_supported( pipe, zFormats[i] )) {
+ if (pipe->is_format_supported( pipe, zFormats[i], type )) {
return zFormats[i];
}
}
@@ -348,67 +345,71 @@ default_depth_format(
*/
GLuint
st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
- GLenum format, GLenum type)
+ GLenum format, GLenum type, uint surfType)
{
+ assert(surfType == PIPE_TEXTURE ||
+ surfType == PIPE_SURFACE ||
+ surfType == PIPE_SCREEN_SURFACE);
+
switch (internalFormat) {
case 4:
case GL_RGBA:
case GL_COMPRESSED_RGBA:
if (format == GL_BGRA) {
if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_A8R8G8B8_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_A8R8G8B8_UNORM, surfType ))
return PIPE_FORMAT_A8R8G8B8_UNORM;
}
else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_A4R4G4B4_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_A4R4G4B4_UNORM, surfType ))
return PIPE_FORMAT_A4R4G4B4_UNORM;
}
else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
return PIPE_FORMAT_A1R5G5B5_UNORM;
}
}
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case 3:
case GL_RGB:
case GL_COMPRESSED_RGB:
if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_R5G6B5_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_R5G6B5_UNORM, surfType ))
return PIPE_FORMAT_R5G6B5_UNORM;
}
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_RGBA16:
- return default_deep_rgba_format( pipe );
+ return default_deep_rgba_format( pipe, surfType );
case GL_RGBA4:
case GL_RGBA2:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_A4R4G4B4_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_A4R4G4B4_UNORM, surfType ))
return PIPE_FORMAT_A4R4G4B4_UNORM;
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_RGB5_A1:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
return PIPE_FORMAT_A1R5G5B5_UNORM;
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_A1R5G5B5_UNORM, surfType ))
return PIPE_FORMAT_A1R5G5B5_UNORM;
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_ALPHA:
case GL_ALPHA4:
@@ -416,9 +417,9 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
case GL_ALPHA12:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8, surfType ))
return PIPE_FORMAT_U_A8;
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case 1:
case GL_LUMINANCE:
@@ -427,9 +428,9 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
case GL_LUMINANCE12:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8 ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8, surfType ))
return PIPE_FORMAT_U_A8;
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case 2:
case GL_LUMINANCE_ALPHA:
@@ -440,9 +441,9 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
case GL_LUMINANCE12_ALPHA12:
case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_L8 ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8_L8, surfType ))
return PIPE_FORMAT_U_A8_L8;
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_INTENSITY:
case GL_INTENSITY4:
@@ -450,17 +451,17 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
case GL_INTENSITY12:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8 ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_I8, surfType ))
return PIPE_FORMAT_U_I8;
- return default_rgba_format( pipe );
+ return default_rgba_format( pipe, surfType );
case GL_YCBCR_MESA:
if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE) {
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR, surfType ))
return PIPE_FORMAT_YCBCR;
}
else {
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR_REV ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR_REV, surfType ))
return PIPE_FORMAT_YCBCR_REV;
}
return PIPE_FORMAT_NONE;
@@ -489,40 +490,40 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
#endif
case GL_DEPTH_COMPONENT16:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z16_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z16_UNORM, surfType ))
return PIPE_FORMAT_Z16_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT24:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM, surfType ))
return PIPE_FORMAT_S8Z24_UNORM;
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM, surfType ))
return PIPE_FORMAT_Z24S8_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT32:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z32_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z32_UNORM, surfType ))
return PIPE_FORMAT_Z32_UNORM;
/* fall-through */
case GL_DEPTH_COMPONENT:
- return default_depth_format( pipe );
+ return default_depth_format( pipe, surfType );
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 (pipe->is_format_supported( pipe, PIPE_FORMAT_U_S8 ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_S8, surfType ))
return PIPE_FORMAT_U_S8;
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM, surfType ))
return PIPE_FORMAT_S8Z24_UNORM;
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM, surfType ))
return PIPE_FORMAT_Z24S8_UNORM;
return PIPE_FORMAT_NONE;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_S8Z24_UNORM, surfType ))
return PIPE_FORMAT_S8Z24_UNORM;
- if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM ))
+ if (pipe->is_format_supported( pipe, PIPE_FORMAT_Z24S8_UNORM, surfType ))
return PIPE_FORMAT_Z24S8_UNORM;
return PIPE_FORMAT_NONE;
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 6ccf5536f9..ebff7c5b91 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 GLuint
st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
- GLenum format, GLenum type);
+ GLenum format, GLenum type, uint surfType);
extern const struct gl_texture_format *
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 8633f431b2..454306b874 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -51,19 +51,21 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
/* fake frontbuffer */
/* XXX allocation should only happen in the unusual case
it's actually needed */
- struct gl_renderbuffer *rb = st_new_renderbuffer_fb(rgbFormat);
+ struct gl_renderbuffer *rb
+ = st_new_renderbuffer_fb(rgbFormat, GL_TRUE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
}
if (visual->doubleBufferMode) {
- struct gl_renderbuffer *rb = st_new_renderbuffer_fb(rgbFormat);
+ struct gl_renderbuffer *rb
+ = st_new_renderbuffer_fb(rgbFormat, GL_TRUE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
}
if (visual->depthBits == 24 && visual->stencilBits == 8) {
/* combined depth/stencil buffer */
struct gl_renderbuffer *depthStencilRb
- = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
+ = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT, GL_FALSE);
/* note: bind RB to two attachment points */
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, depthStencilRb);
@@ -74,47 +76,36 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
if (visual->depthBits == 32) {
/* 32-bit depth buffer */
struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT32);
+ = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT32, GL_FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
}
else if (visual->depthBits == 24) {
/* 24-bit depth buffer, ignore stencil bits */
struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT);
+ = st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT, GL_FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
}
else if (visual->depthBits > 0) {
/* 16-bit depth buffer */
struct gl_renderbuffer *depthRb
- = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16);
+ = st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16, GL_FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
}
if (visual->stencilBits > 0) {
/* 8-bit stencil */
struct gl_renderbuffer *stencilRb
- = st_new_renderbuffer_fb(GL_STENCIL_INDEX8_EXT);
+ = st_new_renderbuffer_fb(GL_STENCIL_INDEX8_EXT, GL_FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, stencilRb);
}
}
-#if 0
if (visual->accumRedBits > 0) {
/* 16-bit/channel accum */
struct gl_renderbuffer *accumRb
- = st_new_renderbuffer_fb(GL_RGBA16);
+ = st_new_renderbuffer_fb(GL_RGBA16, GL_FALSE);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_ACCUM, accumRb);
}
-#endif
-
- /* now add any/all software-based renderbuffers we may need */
- _mesa_add_soft_renderbuffers(&stfb->Base,
- GL_FALSE, /* never sw color */
- GL_FALSE, /* never sw depth */
- GL_FALSE, /* stencil */
- visual->accumRedBits > 0,
- GL_FALSE, /* never sw alpha */
- GL_FALSE /* never sw aux */ );
}
stfb->Base.Initialized = GL_TRUE;