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);
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);
}
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;
* 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,