<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 20, 2016 at 3:53 PM, Chad Versace <span dir="ltr"><<a href="mailto:chad.versace@intel.com" target="_blank">chad.versace@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Sat 11 Jun 2016, Jason Ekstrand wrote:<br>
> ---<br>
> src/intel/isl/Makefile.am | 12 ++++++++<br>
> src/intel/isl/Makefile.sources | 13 +++++++--<br>
> src/intel/isl/isl.c | 28 +++++++++++++++++++<br>
> src/intel/isl/isl_priv.h | 24 ++++++++++++++++<br>
> src/intel/isl/isl_surface_state.c | 58 ++++++++++++++++++++++++++++++++++++---<br>
> 5 files changed, 129 insertions(+), 6 deletions(-)<br>
><br>
> diff --git a/src/intel/isl/Makefile.am b/src/intel/isl/Makefile.am<br>
> index 74f863a..ae367a9 100644<br>
> --- a/src/intel/isl/Makefile.am<br>
> +++ b/src/intel/isl/Makefile.am<br>
> @@ -22,6 +22,9 @@<br>
> include Makefile.sources<br>
><br>
> ISL_GEN_LIBS = \<br>
> + <a href="http://libisl-gen4.la" rel="noreferrer" target="_blank">libisl-gen4.la</a> \<br>
> + <a href="http://libisl-gen5.la" rel="noreferrer" target="_blank">libisl-gen5.la</a> \<br>
> + <a href="http://libisl-gen6.la" rel="noreferrer" target="_blank">libisl-gen6.la</a> \<br>
> <a href="http://libisl-gen7.la" rel="noreferrer" target="_blank">libisl-gen7.la</a> \<br>
> <a href="http://libisl-gen75.la" rel="noreferrer" target="_blank">libisl-gen75.la</a> \<br>
> <a href="http://libisl-gen8.la" rel="noreferrer" target="_blank">libisl-gen8.la</a> \<br>
> @@ -52,6 +55,15 @@ libisl_la_LIBADD = $(ISL_GEN_LIBS)<br>
><br>
> libisl_la_SOURCES = $(ISL_FILES) $(ISL_GENERATED_FILES)<br>
><br>
> +libisl_gen4_la_SOURCES = $(ISL_GEN4_FILES)<br>
> +libisl_gen4_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=40<br>
> +<br>
> +libisl_gen5_la_SOURCES = $(ISL_GEN5_FILES)<br>
> +libisl_gen5_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=50<br>
> +<br>
> +libisl_gen6_la_SOURCES = $(ISL_GEN6_FILES)<br>
> +libisl_gen6_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=60<br>
> +<br>
> libisl_gen7_la_SOURCES = $(ISL_GEN7_FILES)<br>
> libisl_gen7_la_CFLAGS = $(libisl_la_CFLAGS) -DGEN_VERSIONx10=70<br>
><br>
> diff --git a/src/intel/isl/Makefile.sources b/src/intel/isl/Makefile.sources<br>
> index 89b1418..aa20ed4 100644<br>
> --- a/src/intel/isl/Makefile.sources<br>
> +++ b/src/intel/isl/Makefile.sources<br>
> @@ -2,12 +2,21 @@ ISL_FILES = \<br>
> isl.c \<br>
> isl.h \<br>
> isl_format.c \<br>
> + isl_priv.h \<br>
> + isl_storage_image.c<br>
> +<br>
> +ISL_GEN4_FILES = \<br>
> isl_gen4.c \<br>
> isl_gen4.h \<br>
> + isl_surface_state.c<br>
> +<br>
> +ISL_GEN5_FILES = \<br>
> + isl_surface_state.c<br>
> +<br>
> +ISL_GEN6_FILES = \<br>
> isl_gen6.c \<br>
> isl_gen6.h \<br>
> - isl_priv.h \<br>
> - isl_storage_image.c<br>
> + isl_surface_state.c<br>
><br>
> ISL_GEN7_FILES = \<br>
> isl_gen7.c \<br>
> diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c<br>
> index 77b570d..7343a55 100644<br>
> --- a/src/intel/isl/isl.c<br>
> +++ b/src/intel/isl/isl.c<br>
> @@ -1191,6 +1191,20 @@ isl_surf_fill_state_s(const struct isl_device *dev, void *state,<br>
> }<br>
><br>
> switch (ISL_DEV_GEN(dev)) {<br>
> + case 4:<br>
> + if (ISL_DEV_IS_G4X(dev)) {<br>
> + isl_gen4_surf_fill_state_s(dev, state, info);<br>
> + } else {<br>
> + /* G45 surface state is the same as gen5 */<br>
> + isl_gen5_surf_fill_state_s(dev, state, info);<br>
> + }<br>
> + break;<br>
<br>
</div></div>The above can't be correct, because...<br>
<br>
#define GEN_IS_G4X ((GEN_VERSIONx10) == 45)<br>
<br>
I think you meant this:<br>
<br>
if (ISL_DEV_IS_G4X(dev)) {<br>
<span class=""> /* G45 surface state is the same as gen5 */<br>
</span> isl_gen5_surf_fill_state_s(dev, state, info);<br>
} else {<br>
isl_gen4_surf_fill_state_s(dev, state, info);<br>
<span class=""> }<br></span></blockquote><div><br></div><div>You are correct. The reason it didn't trigger a bug is that the only difference bertween gen4 and 4.5 is that x/y offsets are introduced in 4.5. Since we never use ISL for filling out surfaces with x/y offsets on gen4.5 with this series, I never caught it. Thanks!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
<br>
<br>
<br>
> + case 5:<br>
> + isl_gen5_surf_fill_state_s(dev, state, info);<br>
> + break;<br>
> + case 6:<br>
> + isl_gen6_surf_fill_state_s(dev, state, info);<br>
> + break;<br>
> case 7:<br>
> if (ISL_DEV_IS_HASWELL(dev)) {<br>
> isl_gen75_surf_fill_state_s(dev, state, info);<br>
> @@ -1214,6 +1228,20 @@ isl_buffer_fill_state_s(const struct isl_device *dev, void *state,<br>
> const struct isl_buffer_fill_state_info *restrict info)<br>
> {<br>
> switch (ISL_DEV_GEN(dev)) {<br>
> + case 4:<br>
> + if (ISL_DEV_IS_G4X(dev)) {<br>
> + isl_gen4_buffer_fill_state_s(state, info);<br>
> + } else {<br>
> + /* G45 surface state is the same as gen5 */<br>
> + isl_gen5_buffer_fill_state_s(state, info);<br>
> + }<br>
> + break;<br>
<br>
</span>Same as above.<br></blockquote><div><br></div><div>My local fix just changes buffers to use the gen5 version for 4, 4.5, and 5<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
> + case 5:<br>
> + isl_gen5_buffer_fill_state_s(state, info);<br>
> + break;<br>
> + case 6:<br>
> + isl_gen6_buffer_fill_state_s(state, info);<br>
> + break;<br>
> case 7:<br>
> if (ISL_DEV_IS_HASWELL(dev)) {<br>
> isl_gen75_buffer_fill_state_s(state, info);<br>
> diff --git a/src/intel/isl/isl_priv.h b/src/intel/isl/isl_priv.h<br>
> index d98e707..3a7af1a 100644<br>
> --- a/src/intel/isl/isl_priv.h<br>
> +++ b/src/intel/isl/isl_priv.h<br>
> @@ -136,6 +136,18 @@ isl_extent3d_el_to_sa(enum isl_format fmt, struct isl_extent3d extent_el)<br>
> }<br>
><br>
> void<br>
> +isl_gen4_surf_fill_state_s(const struct isl_device *dev, void *state,<br>
> + const struct isl_surf_fill_state_info *restrict info);<br>
> +<br>
> +void<br>
> +isl_gen5_surf_fill_state_s(const struct isl_device *dev, void *state,<br>
> + const struct isl_surf_fill_state_info *restrict info);<br>
> +<br>
> +void<br>
> +isl_gen6_surf_fill_state_s(const struct isl_device *dev, void *state,<br>
> + const struct isl_surf_fill_state_info *restrict info);<br>
> +<br>
> +void<br>
> isl_gen7_surf_fill_state_s(const struct isl_device *dev, void *state,<br>
> const struct isl_surf_fill_state_info *restrict info);<br>
><br>
> @@ -150,6 +162,18 @@ isl_gen9_surf_fill_state_s(const struct isl_device *dev, void *state,<br>
> const struct isl_surf_fill_state_info *restrict info);<br>
><br>
> void<br>
> +isl_gen4_buffer_fill_state_s(void *state,<br>
> + const struct isl_buffer_fill_state_info *restrict info);<br>
> +<br>
> +void<br>
> +isl_gen5_buffer_fill_state_s(void *state,<br>
> + const struct isl_buffer_fill_state_info *restrict info);<br>
> +<br>
> +void<br>
> +isl_gen6_buffer_fill_state_s(void *state,<br>
> + const struct isl_buffer_fill_state_info *restrict info);<br>
> +<br>
> +void<br>
> isl_gen7_buffer_fill_state_s(void *state,<br>
> const struct isl_buffer_fill_state_info *restrict info);<br>
><br>
> diff --git a/src/intel/isl/isl_surface_state.c b/src/intel/isl/isl_surface_state.c<br>
> index fb3fd99..53ff56f 100644<br>
> --- a/src/intel/isl/isl_surface_state.c<br>
> +++ b/src/intel/isl/isl_surface_state.c<br>
> @@ -78,11 +78,13 @@ static const uint8_t isl_to_gen_tiling[] = {<br>
> };<br>
> #endif<br>
><br>
> +#if GEN_GEN >= 7<br>
> static const uint32_t isl_to_gen_multisample_layout[] = {<br>
> [ISL_MSAA_LAYOUT_NONE] = MSFMT_MSS,<br>
> [ISL_MSAA_LAYOUT_INTERLEAVED] = MSFMT_DEPTH_STENCIL,<br>
> [ISL_MSAA_LAYOUT_ARRAY] = MSFMT_MSS,<br>
> };<br>
> +#endif<br>
<br>
</div></div>Wow. The hardware enum names are awful. WTF is MSFMT_MSS?<br>
<div><div class="h5"><br>
> static uint8_t<br>
> get_surftype(enum isl_surf_dim dim, isl_surf_usage_flags_t usage)<br>
> @@ -112,7 +114,7 @@ get_surftype(enum isl_surf_dim dim, isl_surf_usage_flags_t usage)<br>
> * Get the values to pack into RENDER_SUFFACE_STATE.SurfaceHorizontalAlignment<br>
> * and SurfaceVerticalAlignment.<br>
> */<br>
> -static struct isl_extent3d<br>
> +static inline struct isl_extent3d<br>
> get_image_alignment(const struct isl_surf *surf)<br>
> {<br>
> if (GEN_GEN >= 9) {<br>
> @@ -199,6 +201,23 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,<br>
> s.Width = info->surf->logical_level0_px.width - 1;<br>
> s.Height = info->surf->logical_level0_px.height - 1;<br>
><br>
> + /* In the gen6 PRM Volume 1 Part 1: Graphics Core, Section 7.18.3.7.1<br>
> + * (Surface Arrays For all surfaces other than separate stencil buffer):<br>
> + *<br>
> + * "[DevSNB] Errata: Sampler MSAA Qpitch will be 4 greater than the value<br>
> + * calculated in the equation above , for every other odd Surface Height<br>
> + * starting from 1 i.e. 1,5,9,13"<br>
> + *<br>
> + * Since this Qpitch errata only impacts the sampler, we have to adjust the<br>
> + * input for the rendering surface to achieve the same qpitch. For the<br>
> + * affected heights, we increment the height by 1 for the rendering<br>
> + * surface.<br>
> + */<br>
> + if (GEN_GEN == 6 && (info->view->usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) &&<br>
> + info->surf->samples > 1 &&<br>
> + (info->surf->logical_level0_px.height % 4) == 1)<br>
> + s.Height++;<br>
> +<br>
<br>
</div></div>Ouch, that's a surprising workaround.<br></blockquote><div><br></div><div>Yes, yes it is. We'll have to add a similar hack to isl's gen6 layout code.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
> switch (s.SurfaceType) {<br>
> case SURFTYPE_1D:<br>
> case SURFTYPE_2D:<br>
> @@ -251,7 +270,9 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,<br>
> unreachable("bad SurfaceType");<br>
> }<br>
><br>
> +#if GEN_GEN >= 7<br>
> s.SurfaceArray = info->surf->dim != ISL_SURF_DIM_3D;<br>
> +#endif<br>
><br>
> if (info->view->usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) {<br>
> /* For render target surfaces, the hardware interprets field<br>
> @@ -279,9 +300,13 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,<br>
> s.MipTailStartLOD = 15;<br>
> #endif<br>
><br>
> +#if GEN_GEN >= 6<br>
> const struct isl_extent3d image_align = get_image_alignment(info->surf);<br>
> s.SurfaceVerticalAlignment = isl_to_gen_valign[image_align.height];<br>
> +#if GEN_GEN >= 7<br>
> s.SurfaceHorizontalAlignment = isl_to_gen_halign[image_align.width];<br>
> +#endif<br>
> +#endif<br>
><br>
> if (info->surf->tiling == ISL_TILING_W) {<br>
> /* From the Broadwell PRM documentation for this field:<br>
> @@ -333,9 +358,13 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,<br>
> #endif<br>
> }<br>
><br>
> +#if GEN_GEN >= 6<br>
> + s.NumberofMultisamples = ffs(info->surf->samples) - 1;<br>
> +#if GEN_GEN >= 7<br>
> s.MultisampledSurfaceStorageFormat =<br>
> isl_to_gen_multisample_layout[info->surf->msaa_layout];<br>
> - s.NumberofMultisamples = ffs(info->surf->samples) - 1;<br>
> +#endif<br>
> +#endif<br>
><br>
> #if (GEN_GEN >= 8 || GEN_IS_HASWELL)<br>
> s.ShaderChannelSelectRed = info->view->channel_select[0];<br>
> @@ -345,11 +374,14 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,<br>
> #endif<br>
><br>
> s.SurfaceBaseAddress = info->address;<br>
> +<br>
> +#if GEN_GEN >= 6<br>
> s.MOCS = info->mocs;<br>
> +#endif<br>
><br>
> #if GEN_GEN >= 8<br>
> s.AuxiliarySurfaceMode = AUX_NONE;<br>
> -#else<br>
> +#elif GEN_GEN >= 7<br>
> s.MCSEnable = false;<br>
> #endif<br>
><br>
> @@ -424,15 +456,31 @@ isl_genX(buffer_fill_state_s)(void *state,<br>
> struct GENX(RENDER_SURFACE_STATE) s = { 0 };<br>
><br>
> s.SurfaceType = SURFTYPE_BUFFER,<br>
> - s.SurfaceArray = false,<br>
> s.SurfaceFormat = info->format,<br>
> +<br>
> +#if GEN_GEN >= 6<br>
> s.SurfaceVerticalAlignment = isl_to_gen_valign[4],<br>
> +#if GEN_GEN >= 7<br>
> s.SurfaceHorizontalAlignment = isl_to_gen_halign[4],<br>
> + s.SurfaceArray = false,<br>
> +#endif<br>
> +#endif<br>
> +<br>
> +#if GEN_GEN >= 7<br>
> s.Height = ((num_elements - 1) >> 7) & 0x3fff,<br>
> s.Width = (num_elements - 1) & 0x7f,<br>
> s.Depth = ((num_elements - 1) >> 21) & 0x3ff,<br>
> +#else<br>
> + s.Height = ((num_elements - 1) >> 7) & 0x1fff,<br>
> + s.Width = (num_elements - 1) & 0x7f,<br>
> + s.Depth = ((num_elements - 1) >> 20) & 0x7f,<br>
> +#endif<br>
> +<br>
> s.SurfacePitch = info->stride - 1,<br>
> +<br>
> +#if GEN_GEN >= 6<br>
> s.NumberofMultisamples = MULTISAMPLECOUNT_1,<br>
> +#endif<br>
><br>
> #if (GEN_GEN >= 8)<br>
> s.TileMode = LINEAR,<br>
> @@ -447,7 +495,9 @@ isl_genX(buffer_fill_state_s)(void *state,<br>
> #endif<br>
><br>
> s.SurfaceBaseAddress = info->address,<br>
> +#if GEN_GEN >= 6<br>
> s.MOCS = info->mocs,<br>
> +#endif<br>
><br>
> #if (GEN_GEN >= 8 || GEN_IS_HASWELL)<br>
> s.ShaderChannelSelectRed = SCS_RED,<br>
<br>
</div></div>I'm really pleased with how this function looks after adding support for<br>
all gens. You've been able to populate non-buffer surface state in<br>
a single function for all gens, and it's very readable. It's much more<br>
readable than having various functions per gen, like i965. Before I began<br>
reviewing this series, I didn't expect this would be possible.<br>
<br>
Waiting to hear your reply on the G4X comment.<br>
</blockquote></div><br></div></div>