summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_cb_fbo.c
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-04-07 14:53:49 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-04-07 14:53:49 -0600
commit0dd596fbc7f88b88467529a7f176aca70d70f731 (patch)
treedf063e03f96e0315974c0f1707a677b7cf8dea9d /src/mesa/state_tracker/st_cb_fbo.c
parent29b65a709cae779debc4bcdbfaa66cfe72f7074f (diff)
gallium: accum buffer fixes
If the driver can't create a PIPE_FORMAT_R16G16B16A16_SNORM surface, create an accum surface using a shallower format and taller height. Since only the accum buffer code accesses the surface the actual format doesn't really matter, just that there's enough memory.
Diffstat (limited to 'src/mesa/state_tracker/st_cb_fbo.c')
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index e55281a430..b1a56f3ca6 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -127,14 +127,37 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
pipeFormat,
flags);
if (ret || !strb->surface->buffer) {
- return GL_FALSE; /* out of memory, try s/w buffer? */
+ if (pipeFormat == DEFAULT_ACCUM_PIPE_FORMAT) {
+ /* Accum buffer. Try a different surface format. Since accum
+ * buffers are s/w only for now, the surface pixel format doesn't
+ * really matter, only that the buffer is large enough.
+ */
+ int sz, mult;
+ enum pipe_format accum_format;
+
+ /* allocate a buffer of (typically) double height to get 64bpp */
+ accum_format = st_choose_renderbuffer_format(pipe, GL_RGBA);
+ sz = pf_get_size(accum_format);
+ mult = pf_get_size(DEFAULT_ACCUM_PIPE_FORMAT) / sz;
+
+ ret = pipe->winsys->surface_alloc_storage(pipe->winsys,
+ strb->surface,
+ width, height * mult,
+ accum_format, flags);
+ if (ret)
+ return GL_FALSE; /* we've _really_ failed */
+
+ }
+ else {
+ return GL_FALSE; /* out of memory, try s/w buffer? */
+ }
}
ASSERT(strb->surface->buffer);
ASSERT(strb->surface->format);
ASSERT(strb->surface->cpp);
ASSERT(strb->surface->width == width);
- ASSERT(strb->surface->height == height);
+ /*ASSERT(strb->surface->height == height);*/
ASSERT(strb->surface->pitch);
strb->Base.Width = width;
@@ -252,7 +275,7 @@ st_new_renderbuffer_fb(enum pipe_format format)
strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT;
strb->Base._BaseFormat = GL_STENCIL_INDEX;
break;
- case PIPE_FORMAT_R16G16B16A16_SNORM:
+ case DEFAULT_ACCUM_PIPE_FORMAT: /*PIPE_FORMAT_R16G16B16A16_SNORM*/
strb->Base.InternalFormat = GL_RGBA16;
strb->Base._BaseFormat = GL_RGBA;
break;