Re-org of st_create_framebuffer() and renderbuffer format selection.

st_create_framebuffer() now takes pipe_formats for the color, depth, stencil
buffers.
This avoids a round-about chain of calls to pipe->is_format_supported() for
window renderbuffers (their format never changes).
Renderbuffer format selection code in st_format.c is simpler now too.
This commit is contained in:
Brian
2007-12-12 14:55:57 -07:00
parent a51d0e419a
commit 20eae595fa
9 changed files with 173 additions and 139 deletions

View File

@@ -274,11 +274,34 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
return GL_FALSE; /* not implemented */ return GL_FALSE; /* not implemented */
} }
else { else {
enum pipe_format colorFormat, depthFormat, stencilFormat;
struct intel_framebuffer *intelfb = CALLOC_STRUCT(intel_framebuffer); struct intel_framebuffer *intelfb = CALLOC_STRUCT(intel_framebuffer);
if (!intelfb) if (!intelfb)
return GL_FALSE; return GL_FALSE;
intelfb->stfb = st_create_framebuffer(visual, GL_TRUE, (void*) intelfb); if (visual->redBits == 5)
colorFormat = PIPE_FORMAT_R5G6B5_UNORM;
else
colorFormat = PIPE_FORMAT_A8R8G8B8_UNORM;
if (visual->depthBits == 16)
depthFormat = PIPE_FORMAT_Z16_UNORM;
else if (visual->depthBits == 24)
depthFormat = PIPE_FORMAT_S8Z24_UNORM;
else
depthFormat = PIPE_FORMAT_NONE;
if (visual->stencilBits == 8)
stencilFormat = PIPE_FORMAT_S8Z24_UNORM;
else
stencilFormat = PIPE_FORMAT_NONE;
intelfb->stfb = st_create_framebuffer(visual, GL_TRUE,
colorFormat,
depthFormat,
stencilFormat,
(void*) intelfb);
if (!intelfb->stfb) { if (!intelfb->stfb) {
free(intelfb); free(intelfb);
return GL_FALSE; return GL_FALSE;

View File

@@ -783,6 +783,11 @@ softpipe_put_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_A1R5G5B5_UNORM: case PIPE_FORMAT_A1R5G5B5_UNORM:
/*a1r5g5b5_put_tile(ps, x, y, w, h, p);*/ /*a1r5g5b5_put_tile(ps, x, y, w, h, p);*/
break; break;
case PIPE_FORMAT_R5G6B5_UNORM:
case PIPE_FORMAT_R8G8B8A8_UNORM:
/* XXX need these */
fprintf(stderr, "unsup pipe format in softpipe_put_tile_rgba()\n");
break;
case PIPE_FORMAT_U_L8: case PIPE_FORMAT_U_L8:
/*l8_put_tile(ps, x, y, w, h, p);*/ /*l8_put_tile(ps, x, y, w, h, p);*/
break; break;

View File

@@ -251,6 +251,52 @@ xmesa_get_window_size(XMesaDisplay *dpy, XMesaBuffer b,
} }
/**
* Choose the pixel format for the given visual.
* This will tell the gallium driver how to pack pixel data into
* drawing surfaces.
*/
static GLuint
choose_pixel_format(XMesaVisual v)
{
if ( GET_REDMASK(v) == 0x0000ff
&& GET_GREENMASK(v) == 0x00ff00
&& GET_BLUEMASK(v) == 0xff0000
&& v->BitsPerPixel == 32) {
if (CHECK_BYTE_ORDER(v)) {
/* no byteswapping needed */
return 0 /* PIXEL_FORMAT_U_A8_B8_G8_R8 */;
}
else {
return PIPE_FORMAT_R8G8B8A8_UNORM;
}
}
else if ( GET_REDMASK(v) == 0xff0000
&& GET_GREENMASK(v) == 0x00ff00
&& GET_BLUEMASK(v) == 0x0000ff
&& v->BitsPerPixel == 32) {
if (CHECK_BYTE_ORDER(v)) {
/* no byteswapping needed */
return PIPE_FORMAT_A8R8G8B8_UNORM;
}
else {
return PIPE_FORMAT_B8G8R8A8_UNORM;
}
}
else if ( GET_REDMASK(v) == 0xf800
&& GET_GREENMASK(v) == 0x07e0
&& GET_BLUEMASK(v) == 0x001f
&& CHECK_BYTE_ORDER(v)
&& v->BitsPerPixel == 16) {
/* 5-6-5 RGB */
return PIPE_FORMAT_R5G6B5_UNORM;
}
assert(0);
return 0;
}
/**********************************************************************/ /**********************************************************************/
/***** Linked list of XMesaBuffers *****/ /***** Linked list of XMesaBuffers *****/
@@ -276,6 +322,7 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
{ {
XMesaBuffer b; XMesaBuffer b;
GLframebuffer *fb; GLframebuffer *fb;
enum pipe_format colorFormat, depthFormat, stencilFormat;
ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER); ASSERT(type == WINDOW || type == PIXMAP || type == PBUFFER);
@@ -289,10 +336,35 @@ create_xmesa_buffer(XMesaDrawable d, BufferType type,
b->type = type; b->type = type;
b->cmap = cmap; b->cmap = cmap;
/* determine PIPE_FORMATs for buffers */
colorFormat = choose_pixel_format(vis);
if (vis->mesa_visual.depthBits == 0)
depthFormat = PIPE_FORMAT_NONE;
else if (vis->mesa_visual.depthBits <= 16)
depthFormat = PIPE_FORMAT_Z16_UNORM;
else if (vis->mesa_visual.depthBits <= 24)
depthFormat = PIPE_FORMAT_S8Z24_UNORM;
else
depthFormat = PIPE_FORMAT_Z32_UNORM;
if (vis->mesa_visual.stencilBits == 8) {
if (depthFormat == PIPE_FORMAT_S8Z24_UNORM)
stencilFormat = depthFormat;
else
stencilFormat = PIPE_FORMAT_S8_UNORM;
}
else {
stencilFormat = PIPE_FORMAT_NONE;
}
/* /*
* Create framebuffer, but we'll plug in our own renderbuffers below. * Create framebuffer, but we'll plug in our own renderbuffers below.
*/ */
b->stfb = st_create_framebuffer(&vis->mesa_visual, GL_TRUE, (void *) b); b->stfb = st_create_framebuffer(&vis->mesa_visual, GL_TRUE,
colorFormat, depthFormat, stencilFormat,
(void *) b);
fb = &b->stfb->Base; fb = &b->stfb->Base;
/* /*
@@ -387,52 +459,6 @@ xmesa_free_buffer(XMesaBuffer buffer)
/**********************************************************************/ /**********************************************************************/
/**
* Choose the pixel format for the given visual.
* This will tell the gallium driver how to pack pixel data into
* drawing surfaces.
*/
static GLuint
choose_pixel_format(XMesaVisual v)
{
if ( GET_REDMASK(v) == 0x0000ff
&& GET_GREENMASK(v) == 0x00ff00
&& GET_BLUEMASK(v) == 0xff0000
&& v->BitsPerPixel == 32) {
if (CHECK_BYTE_ORDER(v)) {
/* no byteswapping needed */
return 0 /* PIXEL_FORMAT_U_A8_B8_G8_R8 */;
}
else {
return PIPE_FORMAT_R8G8B8A8_UNORM;
}
}
else if ( GET_REDMASK(v) == 0xff0000
&& GET_GREENMASK(v) == 0x00ff00
&& GET_BLUEMASK(v) == 0x0000ff
&& v->BitsPerPixel == 32) {
if (CHECK_BYTE_ORDER(v)) {
/* no byteswapping needed */
return PIPE_FORMAT_A8R8G8B8_UNORM;
}
else {
return PIPE_FORMAT_B8G8R8A8_UNORM;
}
}
else if ( GET_REDMASK(v) == 0xf800
&& GET_GREENMASK(v) == 0x07e0
&& GET_BLUEMASK(v) == 0x001f
&& CHECK_BYTE_ORDER(v)
&& v->BitsPerPixel == 16) {
/* 5-6-5 RGB */
return PIPE_FORMAT_R5G6B5_UNORM;
}
assert(0);
return 0;
}
/** /**
* When a context is bound for the first time, we can finally finish * When a context is bound for the first time, we can finally finish
* initializing the context's visual and buffer information. * initializing the context's visual and buffer information.

View File

@@ -87,9 +87,7 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
{ {
struct pipe_context *pipe = ctx->st->pipe; struct pipe_context *pipe = ctx->st->pipe;
struct st_renderbuffer *strb = st_renderbuffer(rb); struct st_renderbuffer *strb = st_renderbuffer(rb);
uint type = strb->screenSurface ? PIPE_SCREEN_SURFACE : PIPE_SURFACE; enum pipe_format pipeFormat;
const enum pipe_format pipeFormat
= st_choose_pipe_format(pipe, internalFormat, GL_NONE, GL_NONE, type);
GLbitfield flags = 0x0; /* XXX needed? */ GLbitfield flags = 0x0; /* XXX needed? */
if (!strb->surface) { if (!strb->surface) {
@@ -106,6 +104,18 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer, pipe->winsys->buffer_reference(pipe->winsys, &strb->surface->buffer,
NULL); NULL);
/* Determine surface format here */
if (strb->format != PIPE_FORMAT_NONE) {
assert(strb->format != 0);
/* we'll hit this for front/back color bufs */
pipeFormat = strb->format;
}
else {
pipeFormat = st_choose_renderbuffer_format(pipe, internalFormat);
}
init_renderbuffer_bits(strb, pipeFormat);
pipe->winsys->surface_alloc_storage(pipe->winsys, pipe->winsys->surface_alloc_storage(pipe->winsys,
strb->surface, strb->surface,
width, width,
@@ -185,6 +195,7 @@ st_new_renderbuffer(GLcontext *ctx, GLuint name)
strb->Base.Delete = st_renderbuffer_delete; strb->Base.Delete = st_renderbuffer_delete;
strb->Base.AllocStorage = st_renderbuffer_alloc_storage; strb->Base.AllocStorage = st_renderbuffer_alloc_storage;
strb->Base.GetPointer = null_get_pointer; strb->Base.GetPointer = null_get_pointer;
strb->format = PIPE_FORMAT_NONE;
return &strb->Base; return &strb->Base;
} }
return NULL; return NULL;
@@ -193,12 +204,10 @@ st_new_renderbuffer(GLcontext *ctx, GLuint name)
/** /**
* Allocate a renderbuffer for a an on-screen window (not a user-created * Allocate a renderbuffer for a an on-screen window (not a user-created
* renderbuffer). The window system code determines the internal format. * renderbuffer). The window system code determines the format.
* \param screenSurface indicates if the renderbuffer is a front/back color
* buffer that'll be displayed/copied to the screen
*/ */
struct gl_renderbuffer * struct gl_renderbuffer *
st_new_renderbuffer_fb(GLenum intFormat, GLboolean screenSurface) st_new_renderbuffer_fb(enum pipe_format format)
{ {
struct st_renderbuffer *strb; struct st_renderbuffer *strb;
@@ -210,28 +219,37 @@ st_new_renderbuffer_fb(GLenum intFormat, GLboolean screenSurface)
_mesa_init_renderbuffer(&strb->Base, 0); _mesa_init_renderbuffer(&strb->Base, 0);
strb->Base.ClassID = 0x4242; /* just a unique value */ strb->Base.ClassID = 0x4242; /* just a unique value */
strb->Base.InternalFormat = intFormat; strb->format = format;
strb->screenSurface = screenSurface;
switch (intFormat) { switch (format) {
case GL_RGB5: case PIPE_FORMAT_A8R8G8B8_UNORM:
case GL_RGBA8: case PIPE_FORMAT_B8G8R8A8_UNORM:
case GL_RGBA16: case PIPE_FORMAT_A1R5G5B5_UNORM:
case PIPE_FORMAT_A4R4G4B4_UNORM:
case PIPE_FORMAT_R5G6B5_UNORM:
strb->Base.InternalFormat = GL_RGBA;
strb->Base._BaseFormat = GL_RGBA; strb->Base._BaseFormat = GL_RGBA;
break; break;
case GL_DEPTH_COMPONENT16: case PIPE_FORMAT_Z16_UNORM:
case GL_DEPTH_COMPONENT32: strb->Base.InternalFormat = GL_DEPTH_COMPONENT16;
strb->Base._BaseFormat = GL_DEPTH_COMPONENT; strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
break; break;
case GL_DEPTH24_STENCIL8_EXT: case PIPE_FORMAT_Z32_UNORM:
strb->Base.InternalFormat = GL_DEPTH_COMPONENT32;
strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_Z24S8_UNORM:
strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT;
strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT; strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
break; break;
case GL_STENCIL_INDEX8_EXT: case PIPE_FORMAT_R16G16B16A16_SNORM:
strb->Base._BaseFormat = GL_STENCIL_INDEX; strb->Base.InternalFormat = GL_RGBA16;
strb->Base._BaseFormat = GL_RGBA;
break; break;
default: default:
_mesa_problem(NULL, _mesa_problem(NULL,
"Unexpected intFormat in st_new_renderbuffer"); "Unexpected format in st_new_renderbuffer_fb");
return NULL; return NULL;
} }
@@ -248,6 +266,7 @@ st_new_renderbuffer_fb(GLenum intFormat, GLboolean screenSurface)
/** /**
* Called via ctx->Driver.BindFramebufferEXT(). * Called via ctx->Driver.BindFramebufferEXT().
*/ */

View File

@@ -39,7 +39,7 @@ struct st_renderbuffer
{ {
struct gl_renderbuffer Base; struct gl_renderbuffer Base;
struct pipe_surface *surface; struct pipe_surface *surface;
GLboolean screenSurface; /**< A front/back colorbuffer? */ enum pipe_format format; /** preferred format, or PIPE_FORMAT_NONE */
}; };
@@ -51,8 +51,7 @@ st_renderbuffer(struct gl_renderbuffer *rb)
extern struct gl_renderbuffer * extern struct gl_renderbuffer *
st_new_renderbuffer_fb(GLenum intFormat, GLboolean screen_surface); st_new_renderbuffer_fb(enum pipe_format format);
extern void extern void
st_init_fbo_functions(struct dd_function_table *functions); st_init_fbo_functions(struct dd_function_table *functions);

View File

@@ -283,9 +283,9 @@ static GLuint
default_rgba_format(struct pipe_context *pipe, uint type) default_rgba_format(struct pipe_context *pipe, uint type)
{ {
static const enum pipe_format colorFormats[] = { static const enum pipe_format colorFormats[] = {
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_B8G8R8A8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM,
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM PIPE_FORMAT_R5G6B5_UNORM
}; };
uint i; uint i;
@@ -334,56 +334,22 @@ default_depth_format(struct pipe_context *pipe, uint type)
/** /**
* Choose the PIPE_FORMAT_ to use for storing a texture image based * Choose the PIPE_FORMAT_ to use for user-created renderbuffers.
* on the user's internalFormat, format and type parameters.
* We query the pipe device for a list of formats which it supports
* and choose from them.
* If we find a device that needs a more intricate selection mechanism,
* this function _could_ get pushed down into the pipe device.
*
* Note: also used for glRenderbufferStorageEXT()
*
* Note: format and type may be GL_NONE (see renderbuffers)
* *
* \return PIPE_FORMAT_NONE if error/problem. * \return PIPE_FORMAT_NONE if error/problem.
*/ */
GLuint enum pipe_format
st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat)
GLenum format, GLenum type, uint surfType)
{ {
assert(surfType == PIPE_TEXTURE || uint surfType = PIPE_SURFACE;
surfType == PIPE_SURFACE ||
surfType == PIPE_SCREEN_SURFACE);
switch (internalFormat) { switch (internalFormat) {
case 4: case 4:
case GL_RGBA: case GL_RGBA:
case GL_COMPRESSED_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, 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, 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, surfType ))
return PIPE_FORMAT_A1R5G5B5_UNORM;
}
}
return default_rgba_format( pipe, surfType );
case 3: case 3:
case GL_RGB: case GL_RGB:
case GL_COMPRESSED_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, surfType ))
return PIPE_FORMAT_R5G6B5_UNORM;
}
return default_rgba_format( pipe, surfType );
case GL_RGBA8: case GL_RGBA8:
case GL_RGB10_A2: case GL_RGB10_A2:
case GL_RGBA12: case GL_RGBA12:
@@ -434,7 +400,7 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
case GL_LUMINANCE12: case GL_LUMINANCE12:
case GL_LUMINANCE16: case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE: case GL_COMPRESSED_LUMINANCE:
if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_A8, surfType )) if (pipe->is_format_supported( pipe, PIPE_FORMAT_U_L8, surfType ))
return PIPE_FORMAT_U_A8; return PIPE_FORMAT_U_A8;
return default_rgba_format( pipe, surfType ); return default_rgba_format( pipe, surfType );
@@ -461,18 +427,10 @@ st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat,
return PIPE_FORMAT_U_I8; return PIPE_FORMAT_U_I8;
return default_rgba_format( pipe, surfType ); 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, surfType ))
return PIPE_FORMAT_YCBCR;
}
else {
if (pipe->is_format_supported( pipe, PIPE_FORMAT_YCBCR_REV, surfType ))
return PIPE_FORMAT_YCBCR_REV;
}
return PIPE_FORMAT_NONE;
#if 0 #if 0
/* not supported for renderbuffers */
case GL_YCBCR_MESA:
return PIPE_FORMAT_NONE;
case GL_COMPRESSED_RGB_FXT1_3DFX: case GL_COMPRESSED_RGB_FXT1_3DFX:
return &_mesa_texformat_rgb_fxt1; return &_mesa_texformat_rgb_fxt1;
case GL_COMPRESSED_RGBA_FXT1_3DFX: case GL_COMPRESSED_RGBA_FXT1_3DFX:

View File

@@ -63,9 +63,8 @@ extern enum pipe_format
st_mesa_format_to_pipe_format(GLuint mesaFormat); st_mesa_format_to_pipe_format(GLuint mesaFormat);
extern GLuint extern enum pipe_format
st_choose_pipe_format(struct pipe_context *pipe, GLint internalFormat, st_choose_renderbuffer_format(struct pipe_context *pipe, GLint internalFormat);
GLenum format, GLenum type, uint surfType);
extern const struct gl_texture_format * extern const struct gl_texture_format *

View File

@@ -35,15 +35,16 @@
#include "st_cb_fbo.h" #include "st_cb_fbo.h"
struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual, struct st_framebuffer *
boolean createRenderbuffers, st_create_framebuffer( const __GLcontextModes *visual,
void *private) boolean createRenderbuffers, /* XXX remove? */
enum pipe_format colorFormat,
enum pipe_format depthFormat,
enum pipe_format stencilFormat,
void *private)
{ {
struct st_framebuffer *stfb struct st_framebuffer *stfb = CALLOC_STRUCT(st_framebuffer);
= CALLOC_STRUCT(st_framebuffer);
if (stfb) { if (stfb) {
GLenum rgbFormat = (visual->redBits == 5 ? GL_RGB5 : GL_RGBA8);
_mesa_initialize_framebuffer(&stfb->Base, visual); _mesa_initialize_framebuffer(&stfb->Base, visual);
if (createRenderbuffers) { if (createRenderbuffers) {
@@ -52,20 +53,20 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
/* XXX allocation should only happen in the unusual case /* XXX allocation should only happen in the unusual case
it's actually needed */ it's actually needed */
struct gl_renderbuffer *rb struct gl_renderbuffer *rb
= st_new_renderbuffer_fb(rgbFormat, GL_TRUE); = st_new_renderbuffer_fb(colorFormat);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_FRONT_LEFT, rb);
} }
if (visual->doubleBufferMode) { if (visual->doubleBufferMode) {
struct gl_renderbuffer *rb struct gl_renderbuffer *rb
= st_new_renderbuffer_fb(rgbFormat, GL_TRUE); = st_new_renderbuffer_fb(colorFormat);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_BACK_LEFT, rb);
} }
if (visual->depthBits == 24 && visual->stencilBits == 8) { if (visual->depthBits == 24 && visual->stencilBits == 8) {
/* combined depth/stencil buffer */ /* combined depth/stencil buffer */
struct gl_renderbuffer *depthStencilRb struct gl_renderbuffer *depthStencilRb
= st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT, GL_FALSE); = st_new_renderbuffer_fb(depthFormat);
/* note: bind RB to two attachment points */ /* note: bind RB to two attachment points */
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthStencilRb);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, depthStencilRb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, depthStencilRb);
@@ -76,26 +77,26 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
if (visual->depthBits == 32) { if (visual->depthBits == 32) {
/* 32-bit depth buffer */ /* 32-bit depth buffer */
struct gl_renderbuffer *depthRb struct gl_renderbuffer *depthRb
= st_new_renderbuffer_fb(GL_DEPTH_COMPONENT32, GL_FALSE); = st_new_renderbuffer_fb(depthFormat);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
} }
else if (visual->depthBits == 24) { else if (visual->depthBits == 24) {
/* 24-bit depth buffer, ignore stencil bits */ /* 24-bit depth buffer, ignore stencil bits */
struct gl_renderbuffer *depthRb struct gl_renderbuffer *depthRb
= st_new_renderbuffer_fb(GL_DEPTH24_STENCIL8_EXT, GL_FALSE); = st_new_renderbuffer_fb(depthFormat);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
} }
else if (visual->depthBits > 0) { else if (visual->depthBits > 0) {
/* 16-bit depth buffer */ /* 16-bit depth buffer */
struct gl_renderbuffer *depthRb struct gl_renderbuffer *depthRb
= st_new_renderbuffer_fb(GL_DEPTH_COMPONENT16, GL_FALSE); = st_new_renderbuffer_fb(depthFormat);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, depthRb);
} }
if (visual->stencilBits > 0) { if (visual->stencilBits > 0) {
/* 8-bit stencil */ /* 8-bit stencil */
struct gl_renderbuffer *stencilRb struct gl_renderbuffer *stencilRb
= st_new_renderbuffer_fb(GL_STENCIL_INDEX8_EXT, GL_FALSE); = st_new_renderbuffer_fb(stencilFormat);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, stencilRb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, stencilRb);
} }
} }
@@ -103,7 +104,7 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
if (visual->accumRedBits > 0) { if (visual->accumRedBits > 0) {
/* 16-bit/channel accum */ /* 16-bit/channel accum */
struct gl_renderbuffer *accumRb struct gl_renderbuffer *accumRb
= st_new_renderbuffer_fb(GL_RGBA16, GL_FALSE); = st_new_renderbuffer_fb(PIPE_FORMAT_R16G16B16A16_SNORM);
_mesa_add_renderbuffer(&stfb->Base, BUFFER_ACCUM, accumRb); _mesa_add_renderbuffer(&stfb->Base, BUFFER_ACCUM, accumRb);
} }
} }

View File

@@ -29,6 +29,7 @@
#define ST_PUBLIC_H #define ST_PUBLIC_H
#include "pipe/p_compiler.h" #include "pipe/p_compiler.h"
#include "pipe/p_format.h"
#define ST_SURFACE_FRONT_LEFT 0 #define ST_SURFACE_FRONT_LEFT 0
@@ -55,6 +56,9 @@ void st_copy_context_state(struct st_context *dst, struct st_context *src,
struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual, struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
boolean createRenderbuffers, boolean createRenderbuffers,
enum pipe_format colorFormat,
enum pipe_format depthFormat,
enum pipe_format stencilFormat,
void *privateData); void *privateData);
void st_resize_framebuffer( struct st_framebuffer *stfb, void st_resize_framebuffer( struct st_framebuffer *stfb,