diff options
author | Brian Paul <[email protected]> | 2008-02-28 11:31:56 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2008-02-28 11:36:54 -0700 |
commit | 70126588cf78b8a835dfced2b7ca7f1e05afeb67 (patch) | |
tree | d4e979527deb66327d11ee25aaecddcd9033108c /src/mesa | |
parent | 01e53be2b80d5bcb48102f7f1be507b6a5a5832a (diff) |
gallium: fix surface/texture format conversion in st_CopyPixels
If the src buffer's format isn't supported as a texture format, find a different
texture format.
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_cb_drawpixels.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index e0dc657b457..6c0d75cc550 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -1216,7 +1216,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, struct pipe_surface *psTex; struct pipe_texture *pt; GLfloat *color; - enum pipe_format format; + enum pipe_format srcFormat, texFormat; /* make sure rendering has completed */ pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE); @@ -1236,6 +1236,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, stvp = st_make_passthrough_vertex_shader(ctx->st, GL_FALSE); } else { + assert(type == GL_DEPTH); rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer); color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0]; stfp = make_fragment_shader_z(ctx->st); @@ -1243,10 +1244,39 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, } psRead = rbRead->surface; - format = psRead->format; + srcFormat = psRead->format; - pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0, width, height, - 1, 0); + if (screen->is_format_supported(screen, srcFormat, PIPE_TEXTURE)) { + texFormat = srcFormat; + } + else { + /* srcFormat can't be used as a texture format */ + if (type == GL_DEPTH) { + static const enum pipe_format zFormats[] = { + PIPE_FORMAT_Z16_UNORM, + PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_Z24S8_UNORM + }; + uint i; + texFormat = 0; + for (i = 0; i < Elements(zFormats); i++) { + if (screen->is_format_supported(screen, zFormats[i], + PIPE_TEXTURE)) { + texFormat = zFormats[i]; + break; + } + } + assert(texFormat); /* XXX no depth texture formats??? */ + } + else { + /* todo */ + assert(0); + } + } + + pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, texFormat, 0, + width, height, 1, 0); if (!pt) return; @@ -1260,7 +1290,7 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, * front/back color buffers as surfaces (they're XImages and Pixmaps). * So, this var tells us if we can use surface_copy here... */ - if (st->haveFramebufferSurfaces) { + if (st->haveFramebufferSurfaces && srcFormat == texFormat) { /* copy source framebuffer surface into mipmap/texture */ pipe->surface_copy(pipe, FALSE, |