<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Mon, Sep 10, 2018 at 10:21 AM Danylo Piliaiev <<a href="mailto:danylo.piliaiev@gmail.com">danylo.piliaiev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Handle all cases in calculation of layers count for isl_view<br>
taking into account texture view and image unit.<br>
st_convert_image was taken as a reference.<br>
<br>
When u->Layered is true the whole level is taken with respect to<br>
image view. In other case only one layer is taken.<br>
<br>
v3: (Józef Kucia and Ilia Mirkin)<br>
- Rewrote patch by taking st_convert_image as a reference<br>
- Removed now unused get_image_num_layers function<br>
- Changed commit message<br>
<br>
Fixes: 5a8c8903<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=107856" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=107856</a><br>
<br>
Signed-off-by: Danylo Piliaiev <<a href="mailto:danylo.piliaiev@globallogic.com" target="_blank">danylo.piliaiev@globallogic.com</a>><br>
---<br>
.../drivers/dri/i965/brw_wm_surface_state.c | 32 ++++++++++---------<br>
1 file changed, 17 insertions(+), 15 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
index 944762ec46..9bfe6e2037 100644<br>
--- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c<br>
@@ -1499,18 +1499,6 @@ update_buffer_image_param(struct brw_context *brw,<br>
param->stride[0] = _mesa_get_format_bytes(u->_ActualFormat);<br>
}<br>
<br>
-static unsigned<br>
-get_image_num_layers(const struct intel_mipmap_tree *mt, GLenum target,<br>
- unsigned level)<br>
-{<br>
- if (target == GL_TEXTURE_CUBE_MAP)<br>
- return 6;<br>
-<br>
- return target == GL_TEXTURE_3D ?<br>
- minify(mt->surf.logical_level0_px.depth, level) :<br>
- mt->surf.logical_level0_px.array_len;<br>
-}<br>
-<br>
static void<br>
update_image_surface(struct brw_context *brw,<br>
struct gl_image_unit *u,<br>
@@ -1541,14 +1529,28 @@ update_image_surface(struct brw_context *brw,<br>
} else {<br>
struct intel_texture_object *intel_obj = intel_texture_object(obj);<br>
struct intel_mipmap_tree *mt = intel_obj->mt;<br>
- const unsigned num_layers = u->Layered ?<br>
- get_image_num_layers(mt, obj->Target, u->Level) : 1;<br>
+<br>
+ unsigned base_layer, num_layers;<br>
+ if (u->Layered) {<br>
+ if (obj->Target == GL_TEXTURE_3D) {<br>
+ base_layer = 0;<br>
+ num_layers = minify(mt->surf.logical_level0_px.depth, u->Level);<br>
+ } else {<br>
+ base_layer = obj->MinLayer;<br>
+ num_layers = obj->Immutable ?<br>
+ obj->NumLayers :<br>
+ mt->surf.logical_level0_px.array_len;<br></blockquote><div><br></div><div>Doesn't this need to be array_len - base_layer? I'm not sure on the others without digging.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+ } else {<br>
+ base_layer = obj->MinLayer + u->_Layer;<br>
+ num_layers = 1;<br>
+ }<br>
<br>
struct isl_view view = {<br>
.format = format,<br>
.base_level = obj->MinLevel + u->Level,<br>
.levels = 1,<br>
- .base_array_layer = obj->MinLayer + u->_Layer,<br>
+ .base_array_layer = base_layer,<br>
.array_len = num_layers,<br>
.swizzle = ISL_SWIZZLE_IDENTITY,<br>
.usage = ISL_SURF_USAGE_STORAGE_BIT,<br>
-- <br>
2.18.0<br>
<br>
</blockquote></div></div>