[Mesa-dev] [PATCH 12/15] i965: Refactor check for separate stencil
Topi Pohjolainen
topi.pohjolainen at gmail.com
Tue Jun 13 19:11:03 UTC 2017
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 29 ++++++++++++++++++++-------
src/mesa/drivers/dri/i965/intel_mipmap_tree.h | 4 ++--
2 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
index c513a69a5c..b58e9454d1 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
@@ -306,6 +306,25 @@ unwind:
return false;
}
+static bool
+needs_stencil(const struct brw_context *brw,
+ struct intel_mipmap_tree *mt,
+ mesa_format format, uint32_t layout_flags)
+{
+
+ if (layout_flags & MIPTREE_LAYOUT_FOR_BO)
+ return false;
+
+ if (_mesa_get_format_base_format(format) != GL_DEPTH_STENCIL)
+ return false;
+
+ if (brw->must_use_separate_stencil)
+ return true;
+
+ return brw->has_separate_stencil &&
+ intel_miptree_wants_hiz_buffer(brw, mt);
+}
+
/**
* @param for_bo Indicates that the caller is
* intel_miptree_create_for_bo(). If true, then do not create
@@ -482,11 +501,7 @@ intel_miptree_create_layout(struct brw_context *brw,
mt->physical_height0 = height0;
mt->physical_depth0 = depth0;
- if (!(layout_flags & MIPTREE_LAYOUT_FOR_BO) &&
- _mesa_get_format_base_format(format) == GL_DEPTH_STENCIL &&
- (brw->must_use_separate_stencil ||
- (brw->has_separate_stencil &&
- intel_miptree_wants_hiz_buffer(brw, mt)))) {
+ if (needs_stencil(brw, mt, format, layout_flags)) {
uint32_t stencil_flags = MIPTREE_LAYOUT_ACCELERATED_UPLOAD;
if (brw->gen == 6) {
stencil_flags |= MIPTREE_LAYOUT_GEN6_HIZ_STENCIL |
@@ -1812,8 +1827,8 @@ intel_miptree_level_enable_hiz(struct brw_context *brw,
}
bool
-intel_miptree_wants_hiz_buffer(struct brw_context *brw,
- struct intel_mipmap_tree *mt)
+intel_miptree_wants_hiz_buffer(const struct brw_context *brw,
+ const struct intel_mipmap_tree *mt)
{
if (!brw->has_hiz)
return false;
diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
index 5a18d72c2e..2e08a5bcc0 100644
--- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.h
@@ -829,8 +829,8 @@ intel_miptree_copy_teximage(struct brw_context *brw,
*/
bool
-intel_miptree_wants_hiz_buffer(struct brw_context *brw,
- struct intel_mipmap_tree *mt);
+intel_miptree_wants_hiz_buffer(const struct brw_context *brw,
+ const struct intel_mipmap_tree *mt);
bool
intel_miptree_wants_r8_stencil(const struct brw_context *brw);
--
2.11.0
More information about the mesa-dev
mailing list