GLboolean invertTex = GL_FALSE;
GLint readX, readY, readW, readH;
struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
+ GLboolean write_stencil = GL_FALSE;
+ GLboolean write_depth = GL_FALSE;
_mesa_update_draw_buffer_bounds(ctx, ctx->DrawBuffer);
return;
}
- if (type == GL_STENCIL) {
- /* can't use texturing to do stencil */
- copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty);
- return;
- }
-
/*
* The subsequent code implements glCopyPixels by copying the source
* pixels into a temporary texture that's then applied to a textured quad.
* into the constant buffer, we need to update them
*/
st_upload_constants(st, &st->fp->Base);
- }
- else {
- assert(type == GL_DEPTH);
+ } else if (type == GL_DEPTH) {
rbRead = st_renderbuffer(ctx->ReadBuffer->
Attachment[BUFFER_DEPTH].Renderbuffer);
-
driver_fp = get_drawpix_z_stencil_program(st, GL_TRUE, GL_FALSE);
+ } else {
+ assert(type == GL_STENCIL);
+ rbRead = st_renderbuffer(ctx->ReadBuffer->
+ Attachment[BUFFER_STENCIL].Renderbuffer);
+ driver_fp = get_drawpix_z_stencil_program(st, GL_FALSE, GL_TRUE);
}
/* Choose the format for the temporary texture. */
GL_NONE, st->internal_target, 0, 0,
srcBind, false, false);
}
+ else if (type == GL_STENCIL) {
+ /* can't use texturing, fallback to copy */
+ copy_stencil_pixels(ctx, srcx, srcy, width, height, dstx, dsty);
+ return;
+ }
else {
assert(type == GL_COLOR);
return;
}
+ /* Create a second sampler view to read stencil */
+ if (type == GL_STENCIL) {
+ write_stencil = GL_TRUE;
+ enum pipe_format stencil_format =
+ util_format_stencil_only(pt->format);
+ /* we should not be doing pixel map/transfer (see above) */
+ assert(num_sampler_view == 1);
+ sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
+ stencil_format);
+ if (!sv[1]) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
+ pipe_resource_reference(&pt, NULL);
+ pipe_sampler_view_reference(&sv[0], NULL);
+ return;
+ }
+ num_sampler_view++;
+ }
/* Copy the src region to the temporary texture. */
{
struct pipe_blit_info blit;
blit.dst.box.width = readW;
blit.dst.box.height = readH;
blit.dst.box.depth = 1;
- blit.mask = util_format_get_mask(pt->format) & ~PIPE_MASK_S;
+ if (type != GL_STENCIL)
+ blit.mask = util_format_get_mask(pt->format) & ~PIPE_MASK_S;
+ else
+ blit.mask = util_format_get_mask(pt->format) & ~PIPE_MASK_Z;
blit.filter = PIPE_TEX_FILTER_NEAREST;
pipe->blit(pipe, &blit);
st->passthrough_vs,
driver_fp, fpv,
ctx->Current.Attrib[VERT_ATTRIB_COLOR0],
- invertTex, GL_FALSE, GL_FALSE);
+ invertTex, write_depth, write_stencil);
pipe_resource_reference(&pt, NULL);
pipe_sampler_view_reference(&sv[0], NULL);