/** * Clear the given surface to the specified value. * No masking, no scissor (clear entire buffer). */ static void brw_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, double depth, unsigned stencil) { struct brw_context *brw = brw_context( pipe ); int i; if (buffers & PIPE_CLEAR_COLOR) { for (i = 0; i < brw->curr.fb.nr_cbufs; i++) { color_clear( brw, brw_surface(brw->curr.fb.cbufs[i]), rgba ); } } if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { if (brw->curr.fb.zsbuf) { zstencil_clear( brw, brw_surface(brw->curr.fb.zsbuf), buffers & PIPE_CLEAR_DEPTHSTENCIL, depth, stencil ); } } }
static int prepare_depthbuffer(struct brw_context *brw) { struct pipe_surface *zsbuf = brw->curr.fb.zsbuf; if (zsbuf) brw_add_validated_bo(brw, brw_surface(zsbuf)->bo); return 0; }
/* XXX should respect region */ static void brw_clear_render_target(struct pipe_context *pipe, struct pipe_surface *dst, const float *rgba, unsigned dstx, unsigned dsty, unsigned width, unsigned height) { struct brw_context *brw = brw_context( pipe ); color_clear( brw, brw_surface(dst), rgba ); }
/* XXX should respect region */ static void brw_clear_depth_stencil(struct pipe_context *pipe, struct pipe_surface *dst, unsigned clear_flags, double depth, unsigned stencil, unsigned dstx, unsigned dsty, unsigned width, unsigned height) { struct brw_context *brw = brw_context( pipe ); zstencil_clear( brw, brw_surface(dst), clear_flags, depth, stencil ); }
static int emit_depthbuffer(struct brw_context *brw) { struct pipe_surface *surface = brw->curr.fb.zsbuf; unsigned int len = (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) ? 6 : 5; if (surface == NULL) { BEGIN_BATCH(len, IGNORE_CLIPRECTS); OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2)); OUT_BATCH((BRW_DEPTHFORMAT_D32_FLOAT << 18) | (BRW_SURFACE_NULL << 29)); OUT_BATCH(0); OUT_BATCH(0); OUT_BATCH(0); if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) OUT_BATCH(0); ADVANCE_BATCH(); } else { struct brw_winsys_buffer *bo; unsigned int format; unsigned int pitch; unsigned int cpp; switch (surface->format) { case PIPE_FORMAT_Z16_UNORM: format = BRW_DEPTHFORMAT_D16_UNORM; cpp = 2; break; case PIPE_FORMAT_Z24X8_UNORM: case PIPE_FORMAT_Z24S8_UNORM: format = BRW_DEPTHFORMAT_D24_UNORM_S8_UINT; cpp = 4; break; case PIPE_FORMAT_Z32_FLOAT: format = BRW_DEPTHFORMAT_D32_FLOAT; cpp = 4; break; default: assert(0); return PIPE_ERROR_BAD_INPUT; } bo = brw_surface(surface)->bo; pitch = brw_surface(surface)->pitch; BEGIN_BATCH(len, IGNORE_CLIPRECTS); OUT_BATCH(CMD_DEPTH_BUFFER << 16 | (len - 2)); OUT_BATCH(((pitch * cpp) - 1) | (format << 18) | (BRW_TILEWALK_YMAJOR << 26) | ((surface->layout != PIPE_SURFACE_LAYOUT_LINEAR) << 27) | (BRW_SURFACE_2D << 29)); OUT_RELOC(bo, BRW_USAGE_DEPTH_BUFFER, surface->offset); OUT_BATCH((BRW_SURFACE_MIPMAPLAYOUT_BELOW << 1) | ((pitch - 1) << 6) | ((surface->height - 1) << 19)); OUT_BATCH(0); if (BRW_IS_G4X(brw) || BRW_IS_IGDNG(brw)) OUT_BATCH(0); ADVANCE_BATCH(); } return 0; }