---
src/intel/isl/isl_surface_state.c | 154 ++
1 file changed, 74 insertions(+), 80 deletions(-)
diff --git a/src/intel/isl/isl_surface_state.c
b/src/intel/isl/isl_surface_state.c
index 0f21e34..0ada3e4 100644
--- a/src/intel/isl/isl_surface_state.c
+++ b/src/intel/isl/isl_surface_state.c
@@ -213,7 +213,81 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev,
void *state,
s.SurfaceFormat = info->view->format;
}
+ s.Width = info->surf->logical_level0_px.width - 1;
+ s.Height = info->surf->logical_level0_px.height - 1;
+
+ switch (s.SurfaceType) {
+ case SURFTYPE_1D:
+ case SURFTYPE_2D:
+ s.MinimumArrayElement = info->view->base_array_layer;
+
+ /* From the Broadwell PRM >> RENDER_SURFACE_STATE::Depth:
+ *
+ *For SURFTYPE_1D, 2D, and CUBE: The range of this field is reduced
+ *by one for each increase from zero of Minimum Array Element. For
+ *example, if Minimum Array Element is set to 1024 on a 2D surface,
+ *the range of this field is reduced to [0,1023].
+ *
+ * In other words, 'Depth' is the number of array layers.
+ */
+ s.Depth = info->view->array_len - 1;
+
+ /* From the Broadwell PRM >>
RENDER_SURFACE_STATE::RenderTargetViewExtent:
+ *
+ *For Render Target and Typed Dataport 1D and 2D Surfaces:
+ *This field must be set to the same value as the Depth field.
+ */
+ s.RenderTargetViewExtent = s.Depth;
+ break;
+ case SURFTYPE_CUBE:
+ s.MinimumArrayElement = info->view->base_array_layer;
+ /* Same as SURFTYPE_2D, but divided by 6 */
+ s.Depth = info->view->array_len / 6 - 1;
+ s.RenderTargetViewExtent = s.Depth;
+ break;
+ case SURFTYPE_3D:
+ s.MinimumArrayElement = info->view->base_array_layer;
+
+ /* From the Broadwell PRM >> RENDER_SURFACE_STATE::Depth:
+ *
+ *If the volume texture is MIP-mapped, this field specifies the
+ *depth of the base MIP level.
+ */
+ s.Depth = info->surf->logical_level0_px.depth - 1;
+
+ /* From the Broadwell PRM >>
RENDER_SURFACE_STATE::RenderTargetViewExtent:
+ *
+ *For Render Target and Typed Dataport 3D Surfaces: This field
+ *indicates the extent of the accessible 'R' coordinates minus 1 on
+ *the LOD currently being rendered to.
+ */
+ s.RenderTargetViewExtent =
isl_minify(info->surf->logical_level0_px.depth,
+info->view->base_level) - 1;
+ break;
+ default:
+ unreachable("bad SurfaceType");
+ }
+
s.SurfaceArray = info->surf->phys_level0_sa.array_len > 1;
+
+ if (info->view->usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) {
+ /* For render target surfaces, the hardware interprets field
+ * MIPCount/LOD as LOD. The Broadwell PRM says:
+ *
+ *MIPCountLOD defines the LOD that will be rendered into.
+ *SurfaceMinLOD is ignored.
+ */
+ s.MIPCountLOD = info->view->base_level;
+ s.SurfaceMinLOD = 0;
+ } else {
+ /* For non render target surfaces, the hardware interprets field
+ * MIPCount/LOD as MIPCount. The range of levels accessible by the
+ * sampler engine is [SurfaceMinLOD, SurfaceMinLOD + MIPCountLOD].
+ */
+ s.SurfaceMinLOD = info->view->base_level;
+ s.MIPCountLOD = MAX(info->view->levels, 1) - 1;
+ }
+
s.SurfaceVerticalAlignment = valign;
s.SurfaceHorizontalAlignment = halign;
@@ -255,20 +329,10 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev,
void *state,
s.SurfaceQPitch = get_qpitch(info->surf) >> 2;
#endif
- s.Width = info->surf->logical_level0_px.width - 1;
- s.Height = info->surf->logical_level0_px.height - 1;
- s.Depth = 0; /* TEMPLATE */
-
- s.RenderTargetViewExtent = 0; /* TEMPLATE */
- s.MinimumArrayElement = 0; /* TEMPLATE */
-
s.MultisampledSurfaceStorageFormat =
isl_to_gen_multisample_layout[info->surf->msaa_layout];
s.NumberofMultisamples = ffs(info->surf->samples) - 1;
- s.MIPCountLOD = 0; /* TEMPLATE */
- s.SurfaceMinLOD = 0; /* TEMPLATE */
-
#if (GEN_GEN >= 8 || GEN_IS_HASWELL)
s.ShaderChannelSelectRed = info->view->channel_select[0];
s.ShaderChannelSelectGreen = info->view->channel_select[1];
@@ -298,76 +362,6 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev,
void *state,
s.SurfacePitch = info->surf->row_pitch - 1;
}
- switch (s.SurfaceType) {
- case SURFTYPE_1D:
- case SURFTYPE_2D:
- s.MinimumArrayElement = info->view->base_array_layer;
-
- /* From the Broadwell PRM >> RENDER_SURFACE_STATE::Depth:
- *
- *For SURFTYPE_1D, 2D, and CUBE: The range of this field is reduced
- *by one for each increase from zero of Minimum Array Element. For
- *example, if Minimum Array Element is set to 1024 on a 2D surface,
- *the range of this f