aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_blorp.cpp
diff options
context:
space:
mode:
authorPaul Berry <[email protected]>2012-04-29 22:00:46 -0700
committerPaul Berry <[email protected]>2012-05-15 15:09:22 -0700
commit2c5510b71b6348b686e76ecc2c34195080d566f4 (patch)
treebd5f1af55ac012d6b2f67db975e53aab53efdf7a /src/mesa/drivers/dri/i965/brw_blorp.cpp
parent610910a66d1a97ca51ad8a003bdeadfe9563d721 (diff)
i965: Parameterize HiZ code to prepare for adding blitting.
This patch groups together the parameters used by the HiZ functions into a new data structure, brw_hiz_resolve_params, rather than passing each parameter individually between the HiZ functions. This data structure is a subclass of brw_blorp_params, which represents the parameters of a general-purpose blit or resolve operation. A future patch will add another subclass for blits. In addition, this patch generalizes the (width, height) parameters to a full rect (x0, y0, x1, y1), since blitting operations will need to be able to operate on arbitrary rectangles. Also, it renames several of the HiZ functions to reflect the expanded role they will serve. v2: Rename brw_hiz_resolve_params to brw_hiz_op_params. Move gen{6,7}_blorp_exec() functions back into gen{6,7}_blorp.h. Reviewed-by: Chad Versace <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_blorp.cpp')
-rw-r--r--src/mesa/drivers/dri/i965/brw_blorp.cpp108
1 files changed, 108 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_blorp.cpp b/src/mesa/drivers/dri/i965/brw_blorp.cpp
new file mode 100644
index 00000000000..95f039f63db
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_blorp.cpp
@@ -0,0 +1,108 @@
+/*
+ * Copyright © 2012 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "intel_fbo.h"
+
+#include "brw_blorp.h"
+#include "brw_defines.h"
+#include "gen6_blorp.h"
+#include "gen7_blorp.h"
+
+brw_blorp_mip_info::brw_blorp_mip_info()
+ : mt(NULL),
+ level(0),
+ layer(0)
+{
+}
+
+void
+brw_blorp_mip_info::set(struct intel_mipmap_tree *mt,
+ unsigned int level, unsigned int layer)
+{
+ intel_miptree_check_level_layer(mt, level, layer);
+
+ this->mt = mt;
+ this->level = level;
+ this->layer = layer;
+}
+
+void
+brw_blorp_mip_info::get_draw_offsets(uint32_t *draw_x, uint32_t *draw_y) const
+{
+ /* Construct a dummy renderbuffer just to extract tile offsets. */
+ struct intel_renderbuffer rb;
+ rb.mt = mt;
+ rb.mt_level = level;
+ rb.mt_layer = layer;
+ intel_renderbuffer_set_draw_offset(&rb);
+ *draw_x = rb.draw_x;
+ *draw_y = rb.draw_y;
+}
+
+brw_blorp_params::brw_blorp_params()
+ : x0(0),
+ y0(0),
+ x1(0),
+ y1(0),
+ depth_format(0),
+ hiz_op(GEN6_HIZ_OP_NONE)
+{
+}
+
+void
+brw_blorp_params::exec(struct intel_context *intel) const
+{
+ switch (intel->gen) {
+ case 6:
+ gen6_blorp_exec(intel, this);
+ break;
+ case 7:
+ gen7_blorp_exec(intel, this);
+ break;
+ default:
+ /* BLORP is not supported before Gen6. */
+ assert(false);
+ break;
+ }
+}
+
+brw_hiz_op_params::brw_hiz_op_params(struct intel_mipmap_tree *mt,
+ unsigned int level,
+ unsigned int layer,
+ gen6_hiz_op op)
+{
+ assert(op != GEN6_HIZ_OP_DEPTH_CLEAR); /* Not implemented yet. */
+ this->hiz_op = op;
+
+ depth.set(mt, level, layer);
+ depth.get_miplevel_dims(&x1, &y1);
+
+ assert(mt->hiz_mt != NULL);
+
+ switch (mt->format) {
+ case MESA_FORMAT_Z16: depth_format = BRW_DEPTHFORMAT_D16_UNORM; break;
+ case MESA_FORMAT_Z32_FLOAT: depth_format = BRW_DEPTHFORMAT_D32_FLOAT; break;
+ case MESA_FORMAT_X8_Z24: depth_format = BRW_DEPTHFORMAT_D24_UNORM_X8_UINT; break;
+ default: assert(0); break;
+ }
+}