#include "brw_context.h"
#include "brw_blorp_blit_eu.h"
#include "brw_state.h"
+#include "brw_meta_util.h"
#define FILE_DEBUG_FLAG DEBUG_BLORP
-/**
- * Helper function for handling mirror image blits.
- *
- * If coord0 > coord1, swap them and invert the "mirror" boolean.
- */
-static inline void
-fixup_mirroring(bool &mirror, GLfloat &coord0, GLfloat &coord1)
-{
- if (coord0 > coord1) {
- mirror = !mirror;
- GLfloat tmp = coord0;
- coord0 = coord1;
- coord1 = tmp;
- }
-}
-
-
-/**
- * Adjust {src,dst}_x{0,1} to account for clipping and scissoring of
- * destination coordinates.
- *
- * Return true if there is still blitting to do, false if all pixels got
- * rejected by the clip and/or scissor.
- *
- * For clarity, the nomenclature of this function assumes we are clipping and
- * scissoring the X coordinate; the exact same logic applies for Y
- * coordinates.
- *
- * Note: this function may also be used to account for clipping of source
- * coordinates, by swapping the roles of src and dst.
- */
-static inline bool
-clip_or_scissor(bool mirror, GLfloat &src_x0, GLfloat &src_x1, GLfloat &dst_x0,
- GLfloat &dst_x1, GLfloat fb_xmin, GLfloat fb_xmax)
-{
- float scale = (float) (src_x1 - src_x0) / (dst_x1 - dst_x0);
- /* If we are going to scissor everything away, stop. */
- if (!(fb_xmin < fb_xmax &&
- dst_x0 < fb_xmax &&
- fb_xmin < dst_x1 &&
- dst_x0 < dst_x1)) {
- return false;
- }
-
- /* Clip the destination rectangle, and keep track of how many pixels we
- * clipped off of the left and right sides of it.
- */
- GLint pixels_clipped_left = 0;
- GLint pixels_clipped_right = 0;
- if (dst_x0 < fb_xmin) {
- pixels_clipped_left = fb_xmin - dst_x0;
- dst_x0 = fb_xmin;
- }
- if (fb_xmax < dst_x1) {
- pixels_clipped_right = dst_x1 - fb_xmax;
- dst_x1 = fb_xmax;
- }
-
- /* If we are mirrored, then before applying pixels_clipped_{left,right} to
- * the source coordinates, we need to flip them to account for the
- * mirroring.
- */
- if (mirror) {
- GLint tmp = pixels_clipped_left;
- pixels_clipped_left = pixels_clipped_right;
- pixels_clipped_right = tmp;
- }
-
- /* Adjust the source rectangle to remove the pixels corresponding to those
- * that were clipped/scissored out of the destination rectangle.
- */
- src_x0 += pixels_clipped_left * scale;
- src_x1 -= pixels_clipped_right * scale;
-
- return true;
-}
-
-
static struct intel_mipmap_tree *
find_miptree(GLbitfield buffer_bit, struct intel_renderbuffer *irb)
{
intel_miptree_slice_resolve_depth(brw, src_mt, src_level, src_layer);
intel_miptree_slice_resolve_depth(brw, dst_mt, dst_level, dst_layer);
- DBG("%s from %s mt %p %d %d (%f,%f) (%f,%f)"
- "to %s mt %p %d %d (%f,%f) (%f,%f) (flip %d,%d)\n",
+ DBG("%s from %dx %s mt %p %d %d (%f,%f) (%f,%f)"
+ "to %dx %s mt %p %d %d (%f,%f) (%f,%f) (flip %d,%d)\n",
__FUNCTION__,
- _mesa_get_format_name(src_mt->format), src_mt,
+ src_mt->num_samples, _mesa_get_format_name(src_mt->format), src_mt,
src_level, src_layer, src_x0, src_y0, src_x1, src_y1,
- _mesa_get_format_name(dst_mt->format), dst_mt,
+ dst_mt->num_samples, _mesa_get_format_name(dst_mt->format), dst_mt,
dst_level, dst_layer, dst_x0, dst_y0, dst_x1, dst_y1,
mirror_x, mirror_y);
const struct gl_framebuffer *read_fb = ctx->ReadBuffer;
const struct gl_framebuffer *draw_fb = ctx->DrawBuffer;
- /* Detect if the blit needs to be mirrored */
- bool mirror_x = false, mirror_y = false;
- fixup_mirroring(mirror_x, srcX0, srcX1);
- fixup_mirroring(mirror_x, dstX0, dstX1);
- fixup_mirroring(mirror_y, srcY0, srcY1);
- fixup_mirroring(mirror_y, dstY0, dstY1);
-
- /* If the destination rectangle needs to be clipped or scissored, do so.
- */
- if (!(clip_or_scissor(mirror_x, srcX0, srcX1, dstX0, dstX1,
- draw_fb->_Xmin, draw_fb->_Xmax) &&
- clip_or_scissor(mirror_y, srcY0, srcY1, dstY0, dstY1,
- draw_fb->_Ymin, draw_fb->_Ymax))) {
- /* Everything got clipped/scissored away, so the blit was successful. */
+ bool mirror_x, mirror_y;
+ if (brw_meta_mirror_clip_and_scissor(ctx,
+ &srcX0, &srcY0, &srcX1, &srcY1,
+ &dstX0, &dstY0, &dstX1, &dstY1,
+ &mirror_x, &mirror_y))
return true;
- }
-
- /* If the source rectangle needs to be clipped or scissored, do so. */
- if (!(clip_or_scissor(mirror_x, dstX0, dstX1, srcX0, srcX1,
- 0, read_fb->Width) &&
- clip_or_scissor(mirror_y, dstY0, dstY1, srcY0, srcY1,
- 0, read_fb->Height))) {
- /* Everything got clipped/scissored away, so the blit was successful. */
- return true;
- }
-
- /* Account for the fact that in the system framebuffer, the origin is at
- * the lower left.
- */
- if (_mesa_is_winsys_fbo(read_fb)) {
- GLint tmp = read_fb->Height - srcY0;
- srcY0 = read_fb->Height - srcY1;
- srcY1 = tmp;
- mirror_y = !mirror_y;
- }
- if (_mesa_is_winsys_fbo(draw_fb)) {
- GLint tmp = draw_fb->Height - dstY0;
- dstY0 = draw_fb->Height - dstY1;
- dstY1 = tmp;
- mirror_y = !mirror_y;
- }
/* Find buffers */
struct intel_renderbuffer *src_irb;
mirror_y = true;
}
+ /* Account for face selection and texture view MinLayer */
+ int dst_slice = slice + dst_image->TexObject->MinLayer + dst_image->Face;
+ int dst_level = dst_image->Level + dst_image->TexObject->MinLevel;
+
brw_blorp_blit_miptrees(brw,
src_mt, src_irb->mt_level, src_irb->mt_layer,
- dst_mt, dst_image->Level, dst_image->Face + slice,
+ dst_mt, dst_level, dst_slice,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
GL_NEAREST, false, mirror_y);
if (src_mt != dst_mt) {
brw_blorp_blit_miptrees(brw,
src_mt, src_irb->mt_level, src_irb->mt_layer,
- dst_mt, dst_image->Level,
- dst_image->Face + slice,
+ dst_mt, dst_level, dst_slice,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
GL_NEAREST, false, mirror_y);
{
public:
brw_blorp_blit_program(struct brw_context *brw,
- const brw_blorp_blit_prog_key *key);
+ const brw_blorp_blit_prog_key *key, bool debug_flag);
- const GLuint *compile(struct brw_context *brw, GLuint *program_size,
- FILE *dump_file = stderr);
+ const GLuint *compile(struct brw_context *brw, GLuint *program_size);
brw_blorp_prog_data prog_data;
brw_blorp_blit_program::brw_blorp_blit_program(
struct brw_context *brw,
- const brw_blorp_blit_prog_key *key)
- : brw_blorp_eu_emitter(brw),
+ const brw_blorp_blit_prog_key *key,
+ bool debug_flag)
+ : brw_blorp_eu_emitter(brw, debug_flag),
brw(brw),
key(key)
{
const GLuint *
brw_blorp_blit_program::compile(struct brw_context *brw,
- GLuint *program_size,
- FILE *dump_file)
+ GLuint *program_size)
{
/* Sanity checks */
if (key->dst_tiled_w && key->rt_samples > 0) {
*/
render_target_write();
- return get_program(program_size, dump_file);
+ return get_program(program_size);
}
void
GLenum filter,
bool mirror_x, bool mirror_y)
{
- struct gl_context *ctx = &brw->ctx;
-
src.set(brw, src_mt, src_level, src_layer, false);
dst.set(brw, dst_mt, dst_level, dst_layer, true);
if (!brw_search_cache(&brw->cache, BRW_BLORP_BLIT_PROG,
&this->wm_prog_key, sizeof(this->wm_prog_key),
&prog_offset, prog_data)) {
- brw_blorp_blit_program prog(brw, &this->wm_prog_key);
+ brw_blorp_blit_program prog(brw, &this->wm_prog_key,
+ INTEL_DEBUG & DEBUG_BLORP);
GLuint program_size;
- const GLuint *program = prog.compile(brw, &program_size, stderr);
+ const GLuint *program = prog.compile(brw, &program_size);
brw_upload_cache(&brw->cache, BRW_BLORP_BLIT_PROG,
&this->wm_prog_key, sizeof(this->wm_prog_key),
program, program_size,
}
return prog_offset;
}
-
-void
-brw_blorp_blit_test_compile(struct brw_context *brw,
- const brw_blorp_blit_prog_key *key,
- FILE *out)
-{
- GLuint program_size;
- brw_blorp_blit_program prog(brw, key);
- INTEL_DEBUG |= DEBUG_BLORP;
- prog.compile(brw, &program_size, out);
-}