[Mesa-dev] [PATCH 05/16] i965: Add functions up/downsampling on miptrees (v2)
Chad Versace
chad.versace at linux.intel.com
Thu Aug 2 18:39:48 PDT 2012
These functions do an up or downsample between mt and mt->singlesample_mt.
Conceptually, these functions belong in intel_mipmap_tree.c. However, they
needs to interact with blorp, which is C++. So I created a new file,
brw_blorp_orphans.cpp, for these and other functions that fall into the
same category.
v2:
- Add an upsample function.
- Also up/downsample the stencil miptree.
- Assert that the miptree is "flat".
CC: Paul Berry <stereotype441 at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
src/mesa/drivers/dri/i965/Makefile.sources | 1 +
src/mesa/drivers/dri/i965/brw_blorp_orphans.cpp | 144 ++++++++++++++++++++++++
src/mesa/drivers/dri/intel/intel_mipmap_tree.h | 14 +++
3 files changed, 159 insertions(+)
create mode 100644 src/mesa/drivers/dri/i965/brw_blorp_orphans.cpp
diff --git a/src/mesa/drivers/dri/i965/Makefile.sources b/src/mesa/drivers/dri/i965/Makefile.sources
index 334bfd9..4bbd905 100644
--- a/src/mesa/drivers/dri/i965/Makefile.sources
+++ b/src/mesa/drivers/dri/i965/Makefile.sources
@@ -113,6 +113,7 @@ i965_C_FILES = \
i965_CXX_FILES = \
brw_blorp.cpp \
brw_blorp_blit.cpp \
+ brw_blorp_orphans.cpp \
brw_cubemap_normalize.cpp \
brw_fs.cpp \
brw_fs_cfg.cpp \
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_orphans.cpp b/src/mesa/drivers/dri/i965/brw_blorp_orphans.cpp
new file mode 100644
index 0000000..044a38e
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_blorp_orphans.cpp
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+
+/**
+ * \file
+ *
+ * This file contains functions whose definitions conceptually belong
+ * in other C files but need to interact closely with blorp, which is a
+ * C++ module.
+ */
+
+#include "main/glheader.h"
+
+#include "intel_mipmap_tree.h"
+#include "brw_blorp.h"
+
+extern "C" {
+
+enum intel_updownsample {
+ INTEL_UPSAMPLE,
+ INTEL_DOWNSAMPLE,
+};
+
+static void
+intel_miptree_updownsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt,
+ enum intel_updownsample direction)
+{
+ struct intel_mipmap_tree *src;
+ struct intel_mipmap_tree *dst;
+
+ /* Only flat, renderbuffer-like miptrees are supported. */
+ assert(mt->target == GL_TEXTURE_2D);
+ assert(mt->first_level == 0);
+ assert(mt->last_level == 0);
+
+ switch (direction) {
+ case INTEL_DOWNSAMPLE: {
+ if (!mt->need_downsample)
+ return;
+ src = mt;
+ dst = mt->singlesample_mt;
+ break;
+ }
+ case INTEL_UPSAMPLE: {
+ assert(!mt->need_downsample);
+ src = mt->singlesample_mt;
+ dst = mt;
+ break;
+ }
+ default:
+ assert(0);
+ return;
+ }
+
+ int src_x0 = 0;
+ int src_y0 = 0;
+ int dst_x0 = 0;
+ int dst_y0 = 0;
+ int width = mt->singlesample_mt->width0;
+ int height = mt->singlesample_mt->height0;
+
+ intel_miptree_slice_resolve_depth(intel, src, 0, 0);
+ intel_miptree_slice_resolve_depth(intel, dst, 0, 0);
+
+ brw_blorp_blit_params params(brw_context(&intel->ctx),
+ src, dst,
+ src_x0, src_y0,
+ dst_x0, dst_y0,
+ width, height,
+ false, false);
+ brw_blorp_exec(intel, ¶ms);
+
+ if (src->stencil_mt) {
+ src = src->stencil_mt;
+ dst = dst->stencil_mt;
+
+ brw_blorp_blit_params params(brw_context(&intel->ctx),
+ src, dst,
+ src_x0, src_y0,
+ dst_x0, dst_y0,
+ width, height,
+ false, false);
+ brw_blorp_exec(intel, ¶ms);
+ }
+
+ if (direction == INTEL_UPSAMPLE) {
+ /* Strictly speaking, after a downsample on a depth miptree, a hiz
+ * resolve is needed on the singlesample miptree. However, since the
+ * singlesample miptree is never rendered to, the hiz resolve will never
+ * occur. Therefore we do not mark the needed hiz resolve on
+ * downsamples.
+ */
+ intel_miptree_slice_set_needs_hiz_resolve(mt, 0, 0);
+ }
+
+ mt->need_downsample = false;
+}
+
+/**
+ * \brief Downsample from mt to mt->singlesample_mt.
+ *
+ * If the miptree needs no downsample, then skip.
+ */
+void
+intel_miptree_downsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ intel_miptree_updownsample(intel, mt, INTEL_DOWNSAMPLE);
+}
+
+/**
+ * \brief Upsample from mt->singlesample_mt to mt.
+ *
+ * The upsample is done unconditionally.
+ */
+void
+intel_miptree_upsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt)
+{
+ intel_miptree_updownsample(intel, mt, INTEL_UPSAMPLE);
+}
+
+} /* end extern "C" */
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index 187e645..ca345bf 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -567,6 +567,10 @@ intel_miptree_unmap(struct intel_context *intel,
unsigned int slice);
#ifdef I915
+
+static inline void intel_miptree_downsample() {}
+static inline void intel_miptree_upsample() {}
+
static inline void
intel_hiz_exec(struct intel_context *intel, struct intel_mipmap_tree *mt,
unsigned int level, unsigned int layer, enum gen6_hiz_op op)
@@ -575,7 +579,17 @@ intel_hiz_exec(struct intel_context *intel, struct intel_mipmap_tree *mt,
* there.
*/
}
+
#else
+
+void
+intel_miptree_downsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt);
+
+void
+intel_miptree_upsample(struct intel_context *intel,
+ struct intel_mipmap_tree *mt);
+
void
intel_hiz_exec(struct intel_context *intel, struct intel_mipmap_tree *mt,
unsigned int level, unsigned int layer, enum gen6_hiz_op op);
--
1.7.11.4
More information about the mesa-dev
mailing list