aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_cb_drawpixels.c')
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_drawpixels.c57
1 files changed, 9 insertions, 48 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
index 386eed290..de4c189a8 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -33,6 +33,7 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/bufferobj.h"
+#include "main/format_pack.h"
#include "main/macros.h"
#include "main/mfeatures.h"
#include "main/mtypes.h"
@@ -842,12 +843,14 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
y = ctx->DrawBuffer->Height - y - height;
}
- if(format != GL_DEPTH_STENCIL &&
- util_format_get_component_bits(strb->format,
- UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
+ if (format == GL_STENCIL_INDEX &&
+ _mesa_is_format_packed_depth_stencil(strb->Base.Format)) {
+ /* writing stencil to a combined depth+stencil buffer */
usage = PIPE_TRANSFER_READ_WRITE;
- else
+ }
+ else {
usage = PIPE_TRANSFER_WRITE;
+ }
pt = pipe_get_transfer(pipe, strb->texture,
strb->rtt_level, strb->rtt_face + strb->rtt_slice,
@@ -1209,8 +1212,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
}
}
- if (util_format_get_component_bits(rbDraw->format,
- UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
+ if (_mesa_is_format_packed_depth_stencil(rbDraw->Base.Format))
usage = PIPE_TRANSFER_READ_WRITE;
else
usage = PIPE_TRANSFER_WRITE;
@@ -1248,48 +1250,7 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
dst = drawMap + y * ptDraw->stride;
src = buffer + i * width;
- switch (ptDraw->resource->format) {
- case PIPE_FORMAT_Z24_UNORM_S8_UINT:
- {
- uint *dst4 = (uint *) dst;
- int j;
- assert(usage == PIPE_TRANSFER_READ_WRITE);
- for (j = 0; j < width; j++) {
- *dst4 = (*dst4 & 0xffffff) | (src[j] << 24);
- dst4++;
- }
- }
- break;
- case PIPE_FORMAT_S8_UINT_Z24_UNORM:
- {
- uint *dst4 = (uint *) dst;
- int j;
- assert(usage == PIPE_TRANSFER_READ_WRITE);
- for (j = 0; j < width; j++) {
- *dst4 = (*dst4 & 0xffffff00) | (src[j] & 0xff);
- dst4++;
- }
- }
- break;
- case PIPE_FORMAT_S8_UINT:
- assert(usage == PIPE_TRANSFER_WRITE);
- memcpy(dst, src, width);
- break;
- case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT:
- {
- uint *dst4 = (uint *) dst;
- int j;
- dst4++;
- assert(usage == PIPE_TRANSFER_READ_WRITE);
- for (j = 0; j < width; j++) {
- *dst4 = src[j] & 0xff;
- dst4 += 2;
- }
- }
- break;
- default:
- assert(0);
- }
+ _mesa_pack_ubyte_stencil_row(rbDraw->Base.Format, width, src, dst);
}
free(buffer);