aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2013-05-06 10:37:04 -0700
committerPaul Berry <[email protected]>2013-06-12 11:10:07 -0700
commit418aecea7d626d57da8987c062aeb3d046c6dd9a (patch)
tree99a4b539c9e8763f3fa86203c930e372c5daf98f /src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
parentfac32c0bd31601c37f3aa01d69b655e0f75bbdef (diff)
i965/blorp: Write blorp code to do render target resolves.
This patch implements the "render target resolve" blorp operation. This will be needed when a buffer that has experienced a fast color clear is later used for a purpose other than as a render target (texturing, glReadPixels, or swapped to the screen). It resolves any remaining deferred clear operation that was not taken care of during normal rendering. Fortunately not much work is necessary; all we need to do is scale down the size of the rectangle primitive being emitted, run the fragment shader with the "Render Target Resolve Enable" bit set, and ensure that the fragment shader writes to the render target using the "replicated color" message. We already have a fragment shader that does that (the shader that we use for fast color clears), so for simplicity we re-use it. Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_blorp_clear.cpp')
-rw-r--r--src/mesa/drivers/dri/i965/brw_blorp_clear.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index 8df493e0d18..1e2205ea15c 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -68,6 +68,20 @@ public:
bool partial_clear);
};
+
+/**
+ * Parameters for a blorp operation that performs a "render target resolve".
+ * This is used to resolve pending fast clear pixels before a color buffer is
+ * used for texturing, ReadPixels, or scanout.
+ */
+class brw_blorp_rt_resolve_params : public brw_blorp_const_color_params
+{
+public:
+ brw_blorp_rt_resolve_params(struct brw_context *brw,
+ struct intel_mipmap_tree *mt);
+};
+
+
class brw_blorp_const_color_program
{
public:
@@ -266,6 +280,43 @@ brw_blorp_clear_params::brw_blorp_clear_params(struct brw_context *brw,
}
}
+
+brw_blorp_rt_resolve_params::brw_blorp_rt_resolve_params(
+ struct brw_context *brw,
+ struct intel_mipmap_tree *mt)
+{
+ dst.set(brw, mt, 0 /* level */, 0 /* layer */);
+
+ /* From the Ivy Bridge PRM, Vol2 Part1 11.9 "Render Target Resolve":
+ *
+ * A rectangle primitive must be scaled down by the following factors
+ * with respect to render target being resolved.
+ *
+ * The scaledown factors in the table that follows are related to the
+ * alignment size returned by intel_get_non_msrt_mcs_alignment(), but with
+ * X and Y alignment each divided by 2.
+ */
+ unsigned x_align, y_align;
+ intel_get_non_msrt_mcs_alignment(&brw->intel, mt, &x_align, &y_align);
+ unsigned x_scaledown = x_align / 2;
+ unsigned y_scaledown = y_align / 2;
+ x0 = y0 = 0;
+ x1 = ALIGN(mt->logical_width0, x_scaledown) / x_scaledown;
+ y1 = ALIGN(mt->logical_height0, y_scaledown) / y_scaledown;
+
+ fast_clear_op = GEN7_FAST_CLEAR_OP_RESOLVE;
+
+ /* Note: there is no need to initialize push constants because it doesn't
+ * matter what data gets dispatched to the render target. However, we must
+ * ensure that the fragment shader delivers the data using the "replicated
+ * color" message.
+ */
+ use_wm_prog = true;
+ memset(&wm_prog_key, 0, sizeof(wm_prog_key));
+ wm_prog_key.use_simd16_replicated_data = true;
+}
+
+
uint32_t
brw_blorp_const_color_params::get_wm_prog(struct brw_context *brw,
brw_blorp_prog_data **prog_data)
@@ -452,4 +503,13 @@ brw_blorp_clear_color(struct intel_context *intel, struct gl_framebuffer *fb,
return true;
}
+void
+brw_blorp_resolve_color(struct intel_context *intel, struct intel_mipmap_tree *mt)
+{
+ struct brw_context *brw = brw_context(&intel->ctx);
+ brw_blorp_rt_resolve_params params(brw, mt);
+ brw_blorp_exec(intel, &params);
+ mt->mcs_state = INTEL_MCS_STATE_RESOLVED;
+}
+
} /* extern "C" */