[Mesa-dev] [PATCH 09/15] i965: Add function intel_miptree_downsample

Chad Versace chad.versace at linux.intel.com
Sat Jul 21 17:36:48 PDT 2012


This function does a downsample from mt to mt->singlesample_mt.

Conceptually, this function belongs in intel_mipmap_tree.c. However, it
needs to interact with blorp, which is C++. So I created a new file,
brw_blorp_orphands.cpp, for this and other functions that fall into the
same category.

CC: Eric Anholt <eric at anholt.net>
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 | 66 +++++++++++++++++++++++++
 src/mesa/drivers/dri/intel/intel_mipmap_tree.h  | 10 ++++
 3 files changed, 77 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..0b16438
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/brw_blorp_orphans.cpp
@@ -0,0 +1,66 @@
+/*
+ * 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 which  whose definitions conceptually belong
+ * in other C files but need to interact closely with blorp.
+ */
+
+#include "intel_mipmap_tree.h"
+
+#include "brw_blorp.h"
+
+extern "C" {
+
+/**
+ * \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)
+{
+   if (!mt->need_downsample)
+      return;
+
+   int src_x0 = 0;
+   int src_y0 = 0;
+   int dst_x0 = 0;
+   int dst_y0 = 0;
+
+   brw_blorp_blit_params params(brw_context(&intel->ctx),
+                                mt, mt->singlesample_mt,
+                                src_x0, src_y0,
+                                dst_x0, dst_y0,
+                                mt->singlesample_mt->width0,
+                                mt->singlesample_mt->height0,
+                                false, false);
+   brw_blorp_exec(intel, &params);
+
+   mt->need_downsample = false;
+}
+
+} /* 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 bb3fa50..0b76fad 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -540,6 +540,9 @@ intel_miptree_unmap(struct intel_context *intel,
 		    unsigned int slice);
 
 #ifdef I915
+
+void intel_miptree_downsample();
+
 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)
@@ -548,7 +551,14 @@ 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_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.2



More information about the mesa-dev mailing list