[Mesa-dev] [PATCH v4 23/34] i965/state: Add generic surface update functions based on ISL
Chad Versace
chad.versace at intel.com
Fri Jul 15 19:00:40 UTC 2016
On Wed 13 Jul 2016, Jason Ekstrand wrote:
> Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> ---
> src/mesa/drivers/dri/i965/brw_state.h | 9 ++
> src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 184 +++++++++++++++++++++++
> 2 files changed, 193 insertions(+)
> +void
> +brw_update_texture_surface(struct gl_context *ctx,
> + unsigned unit,
> + uint32_t *surf_offset,
> + bool for_gather,
> + uint32_t plane)
> +{
> + struct brw_context *brw = brw_context(ctx);
> + struct gl_texture_object *obj = ctx->Texture.Unit[unit]._Current;
> +
> + if (obj->Target == GL_TEXTURE_BUFFER) {
> + brw_update_buffer_texture_surface(ctx, unit, surf_offset);
> +
> + } else {
> + struct intel_texture_object *intel_obj = intel_texture_object(obj);
> + struct intel_mipmap_tree *mt = intel_obj->mt;
> + struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
> + /* If this is a view with restricted NumLayers, then our effective depth
> + * is not just the miptree depth.
> + */
> + const unsigned mt_num_layers =
> + mt->logical_depth0 * (_mesa_is_cube_map_texture(mt->target) ? 6 : 1);
> + const unsigned depth = (obj->Immutable && obj->Target != GL_TEXTURE_3D ?
> + obj->NumLayers : mt_num_layers);
Since 'depth' here is no longer depth, I would prefer that it be named
better. Below, the code does 'view.array_len = depth', so the name
'view_array_len' or 'view_num_layers' seems appropriate. Just
a suggestion.
...
> + struct isl_view view = {
> + .format = format,
> + .base_level = obj->MinLevel + obj->BaseLevel,
> + .levels = intel_obj->_MaxLevel - obj->BaseLevel + 1,
> + .base_array_layer = obj->MinLayer,
> + .array_len = depth,
> + .channel_select = {
> + swizzle_to_scs(GET_SWZ(swizzle, 0), need_green_to_blue),
> + swizzle_to_scs(GET_SWZ(swizzle, 1), need_green_to_blue),
> + swizzle_to_scs(GET_SWZ(swizzle, 2), need_green_to_blue),
> + swizzle_to_scs(GET_SWZ(swizzle, 3), need_green_to_blue),
> + },
> + .usage = ISL_SURF_USAGE_TEXTURE_BIT,
> + };
> +
> + if (obj->Target == GL_TEXTURE_CUBE_MAP ||
> + obj->Target == GL_TEXTURE_CUBE_MAP_ARRAY)
> + view.usage |= ISL_SURF_USAGE_CUBE_BIT;
> +
> + brw_emit_surface_state(brw, mt, &view,
> + surface_state_infos[brw->gen].tex_mocs, for_gather,
> + surf_offset, surf_index,
> + I915_GEM_DOMAIN_SAMPLER, 0);
> + }
Looks good.
Reviewed-by: Chad Versace <chad.versace at intel.com>
More information about the mesa-dev
mailing list