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__,
+ __func__,
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,
dst_mt->num_samples, _mesa_get_format_name(dst_mt->format), dst_mt,
static bool
try_blorp_blit(struct brw_context *brw,
+ const struct gl_framebuffer *read_fb,
+ const struct gl_framebuffer *draw_fb,
GLfloat srcX0, GLfloat srcY0, GLfloat srcX1, GLfloat srcY1,
GLfloat dstX0, GLfloat dstY0, GLfloat dstX1, GLfloat dstY1,
GLenum filter, GLbitfield buffer_bit)
*/
intel_prepare_render(brw);
- const struct gl_framebuffer *read_fb = ctx->ReadBuffer;
- const struct gl_framebuffer *draw_fb = ctx->DrawBuffer;
-
bool mirror_x, mirror_y;
- if (brw_meta_mirror_clip_and_scissor(ctx,
+ if (brw_meta_mirror_clip_and_scissor(ctx, read_fb, draw_fb,
&srcX0, &srcY0, &srcX1, &srcY1,
&dstX0, &dstY0, &dstX1, &dstY1,
&mirror_x, &mirror_y))
switch (buffer_bit) {
case GL_COLOR_BUFFER_BIT:
src_irb = intel_renderbuffer(read_fb->_ColorReadBuffer);
- for (unsigned i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers; ++i) {
- dst_irb = intel_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[i]);
+ for (unsigned i = 0; i < draw_fb->_NumColorDrawBuffers; ++i) {
+ dst_irb = intel_renderbuffer(draw_fb->_ColorDrawBuffers[i]);
if (dst_irb)
do_blorp_blit(brw, buffer_bit,
src_irb, src_irb->Base.Base.Format,
struct intel_renderbuffer *src_irb = intel_renderbuffer(src_rb);
struct intel_texture_image *intel_image = intel_texture_image(dst_image);
+ /* No pixel transfer operations (zoom, bias, mapping), just a blit */
+ if (brw->ctx._ImageTransferState)
+ return false;
+
/* Sync up the state of window system buffers. We need to do this before
* we go looking at the src renderbuffer's miptree.
*/
struct intel_mipmap_tree *src_mt = src_irb->mt;
struct intel_mipmap_tree *dst_mt = intel_image->mt;
- /* BLORP is not supported before Gen6. */
- if (brw->gen < 6 || brw->gen >= 8)
+ /* BLORP is only supported for Gen6-7. */
+ if (brw->gen < 6 || brw->gen > 7)
return false;
if (_mesa_get_format_base_format(src_rb->Format) !=
GLbitfield
brw_blorp_framebuffer(struct brw_context *brw,
+ struct gl_framebuffer *readFb,
+ struct gl_framebuffer *drawFb,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
for (unsigned int i = 0; i < ARRAY_SIZE(buffer_bits); ++i) {
if ((mask & buffer_bits[i]) &&
- try_blorp_blit(brw,
+ try_blorp_blit(brw, readFb, drawFb,
srcX0, srcY0, srcX1, srcY1,
dstX0, dstY0, dstX1, dstY1,
filter, buffer_bits[i])) {
emit_mov(Xp_f, X);
emit_mov(Yp_f, Y);
/* Scale and offset */
- emit_mul(X_f, Xp_f, x_transform.multiplier);
- emit_mul(Y_f, Yp_f, y_transform.multiplier);
- emit_add(X_f, X_f, x_transform.offset);
- emit_add(Y_f, Y_f, y_transform.offset);
+ emit_mad(X_f, x_transform.offset, Xp_f, x_transform.multiplier);
+ emit_mad(Y_f, y_transform.offset, Yp_f, y_transform.multiplier);
if (key->blit_scaled && key->blend) {
/* Translate coordinates to lay out the samples in a rectangular grid
* roughly corresponding to sample locations.
/* Round the float coordinates down to nearest integer */
emit_rndd(Xp_f, X_f);
emit_rndd(Yp_f, Y_f);
- emit_mul(X_f, Xp_f, brw_imm_f(1 / key->x_scale));
- emit_mul(Y_f, Yp_f, brw_imm_f(1 / key->y_scale));
+ emit_mul(X_f, Xp_f, brw_imm_f(1.0f / key->x_scale));
+ emit_mul(Y_f, Yp_f, brw_imm_f(1.0f / key->y_scale));
SWAP_XY_AND_XPYP();
} else if (!key->bilinear_filter) {
/* Round the float coordinates down to nearest integer by moving to
struct brw_reg clampX1,
struct brw_reg clampY1)
{
- emit_cond_mov(regX, clampX0, BRW_CONDITIONAL_L, regX, clampX0);
- emit_cond_mov(regX, clampX1, BRW_CONDITIONAL_G, regX, clampX1);
- emit_cond_mov(regY, clampY0, BRW_CONDITIONAL_L, regY, clampY0);
- emit_cond_mov(regY, clampY1, BRW_CONDITIONAL_G, regY, clampY1);
+ emit_max(regX, regX, clampX0);
+ emit_max(regY, regY, clampY0);
+ emit_min(regX, regX, clampX1);
+ emit_min(regY, regY, clampY1);
}
/**
for (int j = 0; j < 4; ++j) {
emit_mul(offset(texture_data[0], 2*j),
offset(vec8(texture_data[0]), 2*j),
- brw_imm_f(1.0/num_samples));
+ brw_imm_f(1.0f / num_samples));
}
}
/* Compute pixel coordinates */
emit_add(vec16(x_sample_coords), Xp_f,
- brw_imm_f((float)(i & 0x1) * (1.0 / key->x_scale)));
+ brw_imm_f((float)(i & 0x1) * (1.0f / key->x_scale)));
emit_add(vec16(y_sample_coords), Yp_f,
- brw_imm_f((float)((i >> 1) & 0x1) * (1.0 / key->y_scale)));
+ brw_imm_f((float)((i >> 1) & 0x1) * (1.0f / key->y_scale)));
emit_mov(vec16(X), x_sample_coords);
emit_mov(vec16(Y), y_sample_coords);
* so 0.5 provides the necessary correction.
*/
multiplier = scale;
- offset = src0 + (-dst0 + 0.5) * scale;
+ offset = src0 + (-dst0 + 0.5f) * scale;
} else {
/* When mirroring X we need:
* src_x - src_x0 = dst_x1 - dst_x - 0.5
* src_x = src_x0 + (dst_x1 -dst_x - 0.5) * scale
*/
multiplier = -scale;
- offset = src0 + (dst1 - 0.5) * scale;
+ offset = src0 + (dst1 - 0.5f) * scale;
}
}
_mesa_get_format_color_encoding(dst_mt->format) == GL_SRGB &&
_mesa_get_srgb_format_linear(src_mt->format) ==
_mesa_get_srgb_format_linear(dst_mt->format)) {
- dst.brw_surfaceformat = brw_format_for_mesa_format(dst_mt->format);
- src.brw_surfaceformat = dst.brw_surfaceformat;
+ assert(brw->format_supported_as_render_target[dst_mt->format]);
+ dst.brw_surfaceformat = brw->render_target_format[dst_mt->format];
+ src.brw_surfaceformat = brw_format_for_mesa_format(dst_mt->format);
}
/* When doing a multisample resolve of a GL_LUMINANCE32F or GL_INTENSITY32F
/* Scaling factors used for bilinear filtering in multisample scaled
* blits.
*/
- wm_prog_key.x_scale = 2.0;
- wm_prog_key.y_scale = src_mt->num_samples / 2.0;
+ wm_prog_key.x_scale = 2.0f;
+ wm_prog_key.y_scale = src_mt->num_samples / 2.0f;
if (filter == GL_LINEAR && src.num_samples <= 1 && dst.num_samples <= 1)
wm_prog_key.bilinear_filter = true;
wm_prog_key.src_tiled_w = src.map_stencil_as_y_tiled;
wm_prog_key.dst_tiled_w = dst.map_stencil_as_y_tiled;
- x0 = wm_push_consts.dst_x0 = dst_x0;
- y0 = wm_push_consts.dst_y0 = dst_y0;
- x1 = wm_push_consts.dst_x1 = dst_x1;
- y1 = wm_push_consts.dst_y1 = dst_y1;
+ /* Round floating point values to nearest integer to avoid "off by one texel"
+ * kind of errors when blitting.
+ */
+ x0 = wm_push_consts.dst_x0 = roundf(dst_x0);
+ y0 = wm_push_consts.dst_y0 = roundf(dst_y0);
+ x1 = wm_push_consts.dst_x1 = roundf(dst_x1);
+ y1 = wm_push_consts.dst_y1 = roundf(dst_y1);
wm_push_consts.rect_grid_x1 = (minify(src_mt->logical_width0, src_level) *
- wm_prog_key.x_scale - 1.0);
+ wm_prog_key.x_scale - 1.0f);
wm_push_consts.rect_grid_y1 = (minify(src_mt->logical_height0, src_level) *
- wm_prog_key.y_scale - 1.0);
+ wm_prog_key.y_scale - 1.0f);
wm_push_consts.x_transform.setup(src_x0, src_x1, dst_x0, dst_x1, mirror_x);
wm_push_consts.y_transform.setup(src_y0, src_y1, dst_y0, dst_y1, mirror_y);
brw_blorp_prog_data **prog_data) const
{
uint32_t prog_offset = 0;
- if (!brw_search_cache(&brw->cache, BRW_BLORP_BLIT_PROG,
+ if (!brw_search_cache(&brw->cache, BRW_CACHE_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,
INTEL_DEBUG & DEBUG_BLORP);
GLuint program_size;
const GLuint *program = prog.compile(brw, &program_size);
- brw_upload_cache(&brw->cache, BRW_BLORP_BLIT_PROG,
+ brw_upload_cache(&brw->cache, BRW_CACHE_BLORP_BLIT_PROG,
&this->wm_prog_key, sizeof(this->wm_prog_key),
program, program_size,
&prog.prog_data, sizeof(prog.prog_data),