Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-04-05 Thread Nanley Chery
On Thu, Apr 05, 2018 at 10:51:21AM -0700, Jason Ekstrand wrote:
> ping?
> 

I haven't yet gotten around to seeing how the users of the modifier API
would use the newly-exposed CCS surface, but all the changes within anv
look good to me. 

This patch is
Acked-by: Nanley Chery 



> On Wed, Feb 21, 2018 at 11:17 AM, Jason Ekstrand 
> wrote:
> 
> > v2 (Jason Ekstrand):
> >  - Return the correct enum values from anv_layout_to_fast_clear_type
> >
> > v3 (Jason Ekstrand):
> >  - Always return ANV_FAST_CLEAR_NONE and leave doing the right thing for
> >the patch which adds a modifier which supports fast-clears.
> > ---
> >  src/intel/vulkan/anv_formats.c |  9 
> >  src/intel/vulkan/anv_image.c   | 50 ++
> > 
> >  2 files changed, 40 insertions(+), 19 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_
> > formats.c
> > index 9c52ad5..3c17366 100644
> > --- a/src/intel/vulkan/anv_formats.c
> > +++ b/src/intel/vulkan/anv_formats.c
> > @@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const struct
> > anv_physical_device *physic
> >DRM_FORMAT_MOD_LINEAR,
> >I915_FORMAT_MOD_X_TILED,
> >I915_FORMAT_MOD_Y_TILED,
> > +  I915_FORMAT_MOD_Y_TILED_CCS,
> > };
> >
> > for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
> > +  const struct isl_drm_modifier_info *mod_info =
> > + isl_drm_modifier_get_info(modifiers[i]);
> > +
> > +  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
> > +  !isl_format_supports_ccs_e(_device->info,
> > + anv_format->planes[0].isl_format))
> > + continue;
> > +
> >vk_outarray_append(, mod_props) {
> >   mod_props->modifier = modifiers[i];
> >   if (isl_drm_modifier_has_aux(modifiers[i]))
> > diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> > index a2bae7b..9897e58 100644
> > --- a/src/intel/vulkan/anv_image.c
> > +++ b/src/intel/vulkan/anv_image.c
> > @@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
> > case DRM_FORMAT_MOD_LINEAR: return 1;
> > case I915_FORMAT_MOD_X_TILED: return 2;
> > case I915_FORMAT_MOD_Y_TILED: return 3;
> > +   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
> > default: unreachable("bad DRM format modifier");
> > }
> >  }
> > @@ -746,8 +747,14 @@ void anv_GetImageSubresourceLayout(
> >  VkSubresourceLayout*layout)
> >  {
> > ANV_FROM_HANDLE(anv_image, image, _image);
> > -   const struct anv_surface *surface =
> > -  get_surface(image, subresource->aspectMask);
> > +
> > +   const struct anv_surface *surface;
> > +   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
> > +   image->drm_format_mod != DRM_FORMAT_MOD_INVALID &&
> > +   isl_drm_modifier_has_aux(image->drm_format_mod))
> > +  surface = >planes[0].aux_surface;
> > +   else
> > +  surface = get_surface(image, subresource->aspectMask);
> >
> > assert(__builtin_popcount(subresource->aspectMask) == 1);
> >
> > @@ -862,25 +869,20 @@ anv_layout_to_aux_usage(const struct gen_device_info
> > * const devinfo,
> >}
> >
> >
> > -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
> >assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> >
> > -  /* On SKL+, the render buffer can be decompressed by the
> > presentation
> > -   * engine. Support for this feature has not yet landed in the wider
> > -   * ecosystem. TODO: Update this code when support lands.
> > -   *
> > -   * From the BDW PRM, Vol 7, Render Target Resolve:
> > -   *
> > -   *If the MCS is enabled on a non-multisampled render target, the
> > -   *render target must be resolved before being used for other
> > -   *purposes (display, texture, CPU lock) The clear value from
> > -   *SURFACE_STATE is written into pixels in the render target
> > -   *indicated as clear in the MCS.
> > -   *
> > -   * Pre-SKL, the render buffer must be resolved before being used for
> > -   * presentation. We can infer that the auxiliary buffer is not used.
> > +  /* When handing the image off to the presentation engine, we need to
> > +   * ensure that things are properly resolved.  For images with no
> > +   * modifier, we assume that they follow the old rules and always
> > need
> > +   * a full resolve because the PE doesn't understand any form of
> > +   * compression.  For images with modifiers, we use the aux usage
> > from
> > +   * the modifier.
> > */
> > -  return ISL_AUX_USAGE_NONE;
> > +  const struct isl_drm_modifier_info *mod_info =
> > + isl_drm_modifier_get_info(image->drm_format_mod);
> > +  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
> > +   }
> >
> >
> > /* Rendering 

Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-04-05 Thread Daniel Stone
On 21 February 2018 at 19:17, Jason Ekstrand  wrote:
> v2 (Jason Ekstrand):
>  - Return the correct enum values from anv_layout_to_fast_clear_type
>
> v3 (Jason Ekstrand):
>  - Always return ANV_FAST_CLEAR_NONE and leave doing the right thing for
>the patch which adds a modifier which supports fast-clears.

I've been running this for a while and haven't seen any issues with it
so far, so:
Reviewed-by: Daniel Stone 
Tested-by: Daniel Stone 
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-04-05 Thread Jason Ekstrand
ping?

On Wed, Feb 21, 2018 at 11:17 AM, Jason Ekstrand 
wrote:

> v2 (Jason Ekstrand):
>  - Return the correct enum values from anv_layout_to_fast_clear_type
>
> v3 (Jason Ekstrand):
>  - Always return ANV_FAST_CLEAR_NONE and leave doing the right thing for
>the patch which adds a modifier which supports fast-clears.
> ---
>  src/intel/vulkan/anv_formats.c |  9 
>  src/intel/vulkan/anv_image.c   | 50 ++
> 
>  2 files changed, 40 insertions(+), 19 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_
> formats.c
> index 9c52ad5..3c17366 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const struct
> anv_physical_device *physic
>DRM_FORMAT_MOD_LINEAR,
>I915_FORMAT_MOD_X_TILED,
>I915_FORMAT_MOD_Y_TILED,
> +  I915_FORMAT_MOD_Y_TILED_CCS,
> };
>
> for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
> +  const struct isl_drm_modifier_info *mod_info =
> + isl_drm_modifier_get_info(modifiers[i]);
> +
> +  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
> +  !isl_format_supports_ccs_e(_device->info,
> + anv_format->planes[0].isl_format))
> + continue;
> +
>vk_outarray_append(, mod_props) {
>   mod_props->modifier = modifiers[i];
>   if (isl_drm_modifier_has_aux(modifiers[i]))
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index a2bae7b..9897e58 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
> case DRM_FORMAT_MOD_LINEAR: return 1;
> case I915_FORMAT_MOD_X_TILED: return 2;
> case I915_FORMAT_MOD_Y_TILED: return 3;
> +   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
> default: unreachable("bad DRM format modifier");
> }
>  }
> @@ -746,8 +747,14 @@ void anv_GetImageSubresourceLayout(
>  VkSubresourceLayout*layout)
>  {
> ANV_FROM_HANDLE(anv_image, image, _image);
> -   const struct anv_surface *surface =
> -  get_surface(image, subresource->aspectMask);
> +
> +   const struct anv_surface *surface;
> +   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
> +   image->drm_format_mod != DRM_FORMAT_MOD_INVALID &&
> +   isl_drm_modifier_has_aux(image->drm_format_mod))
> +  surface = >planes[0].aux_surface;
> +   else
> +  surface = get_surface(image, subresource->aspectMask);
>
> assert(__builtin_popcount(subresource->aspectMask) == 1);
>
> @@ -862,25 +869,20 @@ anv_layout_to_aux_usage(const struct gen_device_info
> * const devinfo,
>}
>
>
> -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
>assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
>
> -  /* On SKL+, the render buffer can be decompressed by the
> presentation
> -   * engine. Support for this feature has not yet landed in the wider
> -   * ecosystem. TODO: Update this code when support lands.
> -   *
> -   * From the BDW PRM, Vol 7, Render Target Resolve:
> -   *
> -   *If the MCS is enabled on a non-multisampled render target, the
> -   *render target must be resolved before being used for other
> -   *purposes (display, texture, CPU lock) The clear value from
> -   *SURFACE_STATE is written into pixels in the render target
> -   *indicated as clear in the MCS.
> -   *
> -   * Pre-SKL, the render buffer must be resolved before being used for
> -   * presentation. We can infer that the auxiliary buffer is not used.
> +  /* When handing the image off to the presentation engine, we need to
> +   * ensure that things are properly resolved.  For images with no
> +   * modifier, we assume that they follow the old rules and always
> need
> +   * a full resolve because the PE doesn't understand any form of
> +   * compression.  For images with modifiers, we use the aux usage
> from
> +   * the modifier.
> */
> -  return ISL_AUX_USAGE_NONE;
> +  const struct isl_drm_modifier_info *mod_info =
> + isl_drm_modifier_get_info(image->drm_format_mod);
> +  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
> +   }
>
>
> /* Rendering Layouts */
> @@ -960,8 +962,18 @@ anv_layout_to_fast_clear_type(const struct
> gen_device_info * const devinfo,
> case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
>return ANV_FAST_CLEAR_ANY;
>
> -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
> +  assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> +#ifndef NDEBUG
> +  /* We do not yet support any modifiers which support clear color so
> we
> +   * just always return NONE.  One day, this will change.

[Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-21 Thread Jason Ekstrand
v2 (Jason Ekstrand):
 - Return the correct enum values from anv_layout_to_fast_clear_type

v3 (Jason Ekstrand):
 - Always return ANV_FAST_CLEAR_NONE and leave doing the right thing for
   the patch which adds a modifier which supports fast-clears.
---
 src/intel/vulkan/anv_formats.c |  9 
 src/intel/vulkan/anv_image.c   | 50 ++
 2 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 9c52ad5..3c17366 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const struct 
anv_physical_device *physic
   DRM_FORMAT_MOD_LINEAR,
   I915_FORMAT_MOD_X_TILED,
   I915_FORMAT_MOD_Y_TILED,
+  I915_FORMAT_MOD_Y_TILED_CCS,
};
 
for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(modifiers[i]);
+
+  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
+  !isl_format_supports_ccs_e(_device->info,
+ anv_format->planes[0].isl_format))
+ continue;
+
   vk_outarray_append(, mod_props) {
  mod_props->modifier = modifiers[i];
  if (isl_drm_modifier_has_aux(modifiers[i]))
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index a2bae7b..9897e58 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
case DRM_FORMAT_MOD_LINEAR: return 1;
case I915_FORMAT_MOD_X_TILED: return 2;
case I915_FORMAT_MOD_Y_TILED: return 3;
+   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
default: unreachable("bad DRM format modifier");
}
 }
@@ -746,8 +747,14 @@ void anv_GetImageSubresourceLayout(
 VkSubresourceLayout*layout)
 {
ANV_FROM_HANDLE(anv_image, image, _image);
-   const struct anv_surface *surface =
-  get_surface(image, subresource->aspectMask);
+
+   const struct anv_surface *surface;
+   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
+   image->drm_format_mod != DRM_FORMAT_MOD_INVALID &&
+   isl_drm_modifier_has_aux(image->drm_format_mod))
+  surface = >planes[0].aux_surface;
+   else
+  surface = get_surface(image, subresource->aspectMask);
 
assert(__builtin_popcount(subresource->aspectMask) == 1);
 
@@ -862,25 +869,20 @@ anv_layout_to_aux_usage(const struct gen_device_info * 
const devinfo,
   }
 
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
 
-  /* On SKL+, the render buffer can be decompressed by the presentation
-   * engine. Support for this feature has not yet landed in the wider
-   * ecosystem. TODO: Update this code when support lands.
-   *
-   * From the BDW PRM, Vol 7, Render Target Resolve:
-   *
-   *If the MCS is enabled on a non-multisampled render target, the
-   *render target must be resolved before being used for other
-   *purposes (display, texture, CPU lock) The clear value from
-   *SURFACE_STATE is written into pixels in the render target
-   *indicated as clear in the MCS.
-   *
-   * Pre-SKL, the render buffer must be resolved before being used for
-   * presentation. We can infer that the auxiliary buffer is not used.
+  /* When handing the image off to the presentation engine, we need to
+   * ensure that things are properly resolved.  For images with no
+   * modifier, we assume that they follow the old rules and always need
+   * a full resolve because the PE doesn't understand any form of
+   * compression.  For images with modifiers, we use the aux usage from
+   * the modifier.
*/
-  return ISL_AUX_USAGE_NONE;
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
+   }
 
 
/* Rendering Layouts */
@@ -960,8 +962,18 @@ anv_layout_to_fast_clear_type(const struct gen_device_info 
* const devinfo,
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
   return ANV_FAST_CLEAR_ANY;
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
+  assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+#ifndef NDEBUG
+  /* We do not yet support any modifiers which support clear color so we
+   * just always return NONE.  One day, this will change.
+   */
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  assert(!mod_info || !mod_info->supports_clear_color);
+#endif
   return ANV_FAST_CLEAR_NONE;
+   }
 
default:
   /* If the image has CCS_E enabled all the time 

[Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-20 Thread Jason Ekstrand
v2 (Jason Ekstrand):
 - Return the correct enum values from anv_layout_to_fast_clear_type

v3 (Jason Ekstrand):
 - Always return ANV_FAST_CLEAR_NONE and leave doing the right thing for
   the patch which adds a modifier which supports fast-clears.
---
 src/intel/vulkan/anv_formats.c |  9 
 src/intel/vulkan/anv_image.c   | 49 ++
 2 files changed, 39 insertions(+), 19 deletions(-)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 9c52ad5..3c17366 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const struct 
anv_physical_device *physic
   DRM_FORMAT_MOD_LINEAR,
   I915_FORMAT_MOD_X_TILED,
   I915_FORMAT_MOD_Y_TILED,
+  I915_FORMAT_MOD_Y_TILED_CCS,
};
 
for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(modifiers[i]);
+
+  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
+  !isl_format_supports_ccs_e(_device->info,
+ anv_format->planes[0].isl_format))
+ continue;
+
   vk_outarray_append(, mod_props) {
  mod_props->modifier = modifiers[i];
  if (isl_drm_modifier_has_aux(modifiers[i]))
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index a2bae7b..f536459 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
case DRM_FORMAT_MOD_LINEAR: return 1;
case I915_FORMAT_MOD_X_TILED: return 2;
case I915_FORMAT_MOD_Y_TILED: return 3;
+   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
default: unreachable("bad DRM format modifier");
}
 }
@@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
 VkSubresourceLayout*layout)
 {
ANV_FROM_HANDLE(anv_image, image, _image);
-   const struct anv_surface *surface =
-  get_surface(image, subresource->aspectMask);
+
+   const struct anv_surface *surface;
+   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
+   isl_drm_modifier_has_aux(image->drm_format_mod))
+  surface = >planes[0].aux_surface;
+   else
+  surface = get_surface(image, subresource->aspectMask);
 
assert(__builtin_popcount(subresource->aspectMask) == 1);
 
@@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct gen_device_info * 
const devinfo,
   }
 
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
 
-  /* On SKL+, the render buffer can be decompressed by the presentation
-   * engine. Support for this feature has not yet landed in the wider
-   * ecosystem. TODO: Update this code when support lands.
-   *
-   * From the BDW PRM, Vol 7, Render Target Resolve:
-   *
-   *If the MCS is enabled on a non-multisampled render target, the
-   *render target must be resolved before being used for other
-   *purposes (display, texture, CPU lock) The clear value from
-   *SURFACE_STATE is written into pixels in the render target
-   *indicated as clear in the MCS.
-   *
-   * Pre-SKL, the render buffer must be resolved before being used for
-   * presentation. We can infer that the auxiliary buffer is not used.
+  /* When handing the image off to the presentation engine, we need to
+   * ensure that things are properly resolved.  For images with no
+   * modifier, we assume that they follow the old rules and always need
+   * a full resolve because the PE doesn't understand any form of
+   * compression.  For images with modifiers, we use the aux usage from
+   * the modifier.
*/
-  return ISL_AUX_USAGE_NONE;
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
+   }
 
 
/* Rendering Layouts */
@@ -960,8 +961,18 @@ anv_layout_to_fast_clear_type(const struct gen_device_info 
* const devinfo,
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
   return ANV_FAST_CLEAR_ANY;
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
+  assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+#ifndef NDEBUG
+  /* We do not yet support any modifiers which support clear color so we
+   * just always return NONE.  One day, this will change.
+   */
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  assert(!mod_info || !mod_info->supports_clear_color);
+#endif
   return ANV_FAST_CLEAR_NONE;
+   }
 
default:
   /* If the image has CCS_E enabled all the time then we can use
-- 
2.5.0.400.gff86faf


Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-20 Thread Jason Ekstrand
On Tue, Feb 20, 2018 at 1:57 PM, Nanley Chery  wrote:

> On Tue, Feb 20, 2018 at 11:31:08AM -0800, Jason Ekstrand wrote:
> > On Tue, Feb 20, 2018 at 11:26 AM, Jason Ekstrand 
> > wrote:
> >
> > > On Tue, Feb 20, 2018 at 11:25 AM, Nanley Chery 
> > > wrote:
> > >
> > >> On Fri, Feb 16, 2018 at 09:28:43AM -0800, Jason Ekstrand wrote:
> > >> > ---
> > >> >  src/intel/vulkan/anv_formats.c |  9 +++
> > >> >  src/intel/vulkan/anv_image.c   | 53 ++
> > >> 
> > >> >  2 files changed, 42 insertions(+), 20 deletions(-)
> > >> >
> > >> > diff --git a/src/intel/vulkan/anv_formats.c
> > >> b/src/intel/vulkan/anv_formats.c
> > >> > index 9c52ad5..3c17366 100644
> > >> > --- a/src/intel/vulkan/anv_formats.c
> > >> > +++ b/src/intel/vulkan/anv_formats.c
> > >> > @@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const
> > >> struct anv_physical_device *physic
> > >> >DRM_FORMAT_MOD_LINEAR,
> > >> >I915_FORMAT_MOD_X_TILED,
> > >> >I915_FORMAT_MOD_Y_TILED,
> > >> > +  I915_FORMAT_MOD_Y_TILED_CCS,
> > >> > };
> > >> >
> > >> > for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
> > >> > +  const struct isl_drm_modifier_info *mod_info =
> > >> > + isl_drm_modifier_get_info(modifiers[i]);
> > >> > +
> > >> > +  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
> > >> > +  !isl_format_supports_ccs_e(_device->info,
> > >> > + anv_format->planes[0].isl_for
> > >> mat))
> > >> > + continue;
> > >> > +
> > >> >vk_outarray_append(, mod_props) {
> > >> >   mod_props->modifier = modifiers[i];
> > >> >   if (isl_drm_modifier_has_aux(modifiers[i]))
> > >> > diff --git a/src/intel/vulkan/anv_image.c
> b/src/intel/vulkan/anv_image.c
> > >> > index a2bae7b..d7c2e55 100644
> > >> > --- a/src/intel/vulkan/anv_image.c
> > >> > +++ b/src/intel/vulkan/anv_image.c
> > >> > @@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
> > >> > case DRM_FORMAT_MOD_LINEAR: return 1;
> > >> > case I915_FORMAT_MOD_X_TILED: return 2;
> > >> > case I915_FORMAT_MOD_Y_TILED: return 3;
> > >> > +   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
> > >> > default: unreachable("bad DRM format modifier");
> > >> > }
> > >> >  }
> > >> > @@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
> > >> >  VkSubresourceLayout*layout)
> > >> >  {
> > >> > ANV_FROM_HANDLE(anv_image, image, _image);
> > >> > -   const struct anv_surface *surface =
> > >> > -  get_surface(image, subresource->aspectMask);
> > >> > +
> > >> > +   const struct anv_surface *surface;
> > >> > +   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR
> &&
> > >> > +   isl_drm_modifier_has_aux(image->drm_format_mod))
> > >> > +  surface = >planes[0].aux_surface;
> > >> > +   else
> > >> > +  surface = get_surface(image, subresource->aspectMask);
> > >> >
> > >> > assert(__builtin_popcount(subresource->aspectMask) == 1);
> > >> >
> > >> > @@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct
> > >> gen_device_info * const devinfo,
> > >> >}
> > >> >
> > >> >
> > >> > -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> > >> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
> > >> >assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > >> >
> > >> > -  /* On SKL+, the render buffer can be decompressed by the
> > >> presentation
> > >> > -   * engine. Support for this feature has not yet landed in the
> > >> wider
> > >> > -   * ecosystem. TODO: Update this code when support lands.
> > >> > -   *
> > >> > -   * From the BDW PRM, Vol 7, Render Target Resolve:
> > >> > -   *
> > >> > -   *If the MCS is enabled on a non-multisampled render
> target,
> > >> the
> > >> > -   *render target must be resolved before being used for
> other
> > >> > -   *purposes (display, texture, CPU lock) The clear value
> from
> > >> > -   *SURFACE_STATE is written into pixels in the render
> target
> > >> > -   *indicated as clear in the MCS.
> > >> > -   *
> > >> > -   * Pre-SKL, the render buffer must be resolved before being
> used
> > >> for
> > >> > -   * presentation. We can infer that the auxiliary buffer is
> not
> > >> used.
> > >> > +  /* When handing the image off to the presentation engine, we
> > >> need to
> > >> > +   * ensure that things are properly resolved.  For images
> with no
> > >> > +   * modifier, we assume that they follow the old rules and
> always
> > >> need
> > >> > +   * a full resolve because the PE doesn't understand any form
> of
> > >> > +   * compression.  For images with modifiers, we use the aux
> usage
> > >> from
> > >> > +   * the modifier.
> > >> > */
> > >> > -  return ISL_AUX_USAGE_NONE;
> > >> > +  const struct 

Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-20 Thread Nanley Chery
On Tue, Feb 20, 2018 at 11:31:08AM -0800, Jason Ekstrand wrote:
> On Tue, Feb 20, 2018 at 11:26 AM, Jason Ekstrand 
> wrote:
> 
> > On Tue, Feb 20, 2018 at 11:25 AM, Nanley Chery 
> > wrote:
> >
> >> On Fri, Feb 16, 2018 at 09:28:43AM -0800, Jason Ekstrand wrote:
> >> > ---
> >> >  src/intel/vulkan/anv_formats.c |  9 +++
> >> >  src/intel/vulkan/anv_image.c   | 53 ++
> >> 
> >> >  2 files changed, 42 insertions(+), 20 deletions(-)
> >> >
> >> > diff --git a/src/intel/vulkan/anv_formats.c
> >> b/src/intel/vulkan/anv_formats.c
> >> > index 9c52ad5..3c17366 100644
> >> > --- a/src/intel/vulkan/anv_formats.c
> >> > +++ b/src/intel/vulkan/anv_formats.c
> >> > @@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const
> >> struct anv_physical_device *physic
> >> >DRM_FORMAT_MOD_LINEAR,
> >> >I915_FORMAT_MOD_X_TILED,
> >> >I915_FORMAT_MOD_Y_TILED,
> >> > +  I915_FORMAT_MOD_Y_TILED_CCS,
> >> > };
> >> >
> >> > for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
> >> > +  const struct isl_drm_modifier_info *mod_info =
> >> > + isl_drm_modifier_get_info(modifiers[i]);
> >> > +
> >> > +  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
> >> > +  !isl_format_supports_ccs_e(_device->info,
> >> > + anv_format->planes[0].isl_for
> >> mat))
> >> > + continue;
> >> > +
> >> >vk_outarray_append(, mod_props) {
> >> >   mod_props->modifier = modifiers[i];
> >> >   if (isl_drm_modifier_has_aux(modifiers[i]))
> >> > diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> >> > index a2bae7b..d7c2e55 100644
> >> > --- a/src/intel/vulkan/anv_image.c
> >> > +++ b/src/intel/vulkan/anv_image.c
> >> > @@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
> >> > case DRM_FORMAT_MOD_LINEAR: return 1;
> >> > case I915_FORMAT_MOD_X_TILED: return 2;
> >> > case I915_FORMAT_MOD_Y_TILED: return 3;
> >> > +   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
> >> > default: unreachable("bad DRM format modifier");
> >> > }
> >> >  }
> >> > @@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
> >> >  VkSubresourceLayout*layout)
> >> >  {
> >> > ANV_FROM_HANDLE(anv_image, image, _image);
> >> > -   const struct anv_surface *surface =
> >> > -  get_surface(image, subresource->aspectMask);
> >> > +
> >> > +   const struct anv_surface *surface;
> >> > +   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
> >> > +   isl_drm_modifier_has_aux(image->drm_format_mod))
> >> > +  surface = >planes[0].aux_surface;
> >> > +   else
> >> > +  surface = get_surface(image, subresource->aspectMask);
> >> >
> >> > assert(__builtin_popcount(subresource->aspectMask) == 1);
> >> >
> >> > @@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct
> >> gen_device_info * const devinfo,
> >> >}
> >> >
> >> >
> >> > -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> >> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
> >> >assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> >> >
> >> > -  /* On SKL+, the render buffer can be decompressed by the
> >> presentation
> >> > -   * engine. Support for this feature has not yet landed in the
> >> wider
> >> > -   * ecosystem. TODO: Update this code when support lands.
> >> > -   *
> >> > -   * From the BDW PRM, Vol 7, Render Target Resolve:
> >> > -   *
> >> > -   *If the MCS is enabled on a non-multisampled render target,
> >> the
> >> > -   *render target must be resolved before being used for other
> >> > -   *purposes (display, texture, CPU lock) The clear value from
> >> > -   *SURFACE_STATE is written into pixels in the render target
> >> > -   *indicated as clear in the MCS.
> >> > -   *
> >> > -   * Pre-SKL, the render buffer must be resolved before being used
> >> for
> >> > -   * presentation. We can infer that the auxiliary buffer is not
> >> used.
> >> > +  /* When handing the image off to the presentation engine, we
> >> need to
> >> > +   * ensure that things are properly resolved.  For images with no
> >> > +   * modifier, we assume that they follow the old rules and always
> >> need
> >> > +   * a full resolve because the PE doesn't understand any form of
> >> > +   * compression.  For images with modifiers, we use the aux usage
> >> from
> >> > +   * the modifier.
> >> > */
> >> > -  return ISL_AUX_USAGE_NONE;
> >> > +  const struct isl_drm_modifier_info *mod_info =
> >> > + isl_drm_modifier_get_info(image->drm_format_mod);
> >> > +  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
> >> > +   }
> >> >
> >> >
> >> > /* Rendering Layouts */
> >> > @@ -960,8 +961,20 @@ anv_layout_to_fast_clear_type(const struct
> >> gen_device_info 

Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-20 Thread Jason Ekstrand
On Tue, Feb 20, 2018 at 11:26 AM, Jason Ekstrand 
wrote:

> On Tue, Feb 20, 2018 at 11:25 AM, Nanley Chery 
> wrote:
>
>> On Fri, Feb 16, 2018 at 09:28:43AM -0800, Jason Ekstrand wrote:
>> > ---
>> >  src/intel/vulkan/anv_formats.c |  9 +++
>> >  src/intel/vulkan/anv_image.c   | 53 ++
>> 
>> >  2 files changed, 42 insertions(+), 20 deletions(-)
>> >
>> > diff --git a/src/intel/vulkan/anv_formats.c
>> b/src/intel/vulkan/anv_formats.c
>> > index 9c52ad5..3c17366 100644
>> > --- a/src/intel/vulkan/anv_formats.c
>> > +++ b/src/intel/vulkan/anv_formats.c
>> > @@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const
>> struct anv_physical_device *physic
>> >DRM_FORMAT_MOD_LINEAR,
>> >I915_FORMAT_MOD_X_TILED,
>> >I915_FORMAT_MOD_Y_TILED,
>> > +  I915_FORMAT_MOD_Y_TILED_CCS,
>> > };
>> >
>> > for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
>> > +  const struct isl_drm_modifier_info *mod_info =
>> > + isl_drm_modifier_get_info(modifiers[i]);
>> > +
>> > +  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
>> > +  !isl_format_supports_ccs_e(_device->info,
>> > + anv_format->planes[0].isl_for
>> mat))
>> > + continue;
>> > +
>> >vk_outarray_append(, mod_props) {
>> >   mod_props->modifier = modifiers[i];
>> >   if (isl_drm_modifier_has_aux(modifiers[i]))
>> > diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
>> > index a2bae7b..d7c2e55 100644
>> > --- a/src/intel/vulkan/anv_image.c
>> > +++ b/src/intel/vulkan/anv_image.c
>> > @@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
>> > case DRM_FORMAT_MOD_LINEAR: return 1;
>> > case I915_FORMAT_MOD_X_TILED: return 2;
>> > case I915_FORMAT_MOD_Y_TILED: return 3;
>> > +   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
>> > default: unreachable("bad DRM format modifier");
>> > }
>> >  }
>> > @@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
>> >  VkSubresourceLayout*layout)
>> >  {
>> > ANV_FROM_HANDLE(anv_image, image, _image);
>> > -   const struct anv_surface *surface =
>> > -  get_surface(image, subresource->aspectMask);
>> > +
>> > +   const struct anv_surface *surface;
>> > +   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
>> > +   isl_drm_modifier_has_aux(image->drm_format_mod))
>> > +  surface = >planes[0].aux_surface;
>> > +   else
>> > +  surface = get_surface(image, subresource->aspectMask);
>> >
>> > assert(__builtin_popcount(subresource->aspectMask) == 1);
>> >
>> > @@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct
>> gen_device_info * const devinfo,
>> >}
>> >
>> >
>> > -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
>> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
>> >assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
>> >
>> > -  /* On SKL+, the render buffer can be decompressed by the
>> presentation
>> > -   * engine. Support for this feature has not yet landed in the
>> wider
>> > -   * ecosystem. TODO: Update this code when support lands.
>> > -   *
>> > -   * From the BDW PRM, Vol 7, Render Target Resolve:
>> > -   *
>> > -   *If the MCS is enabled on a non-multisampled render target,
>> the
>> > -   *render target must be resolved before being used for other
>> > -   *purposes (display, texture, CPU lock) The clear value from
>> > -   *SURFACE_STATE is written into pixels in the render target
>> > -   *indicated as clear in the MCS.
>> > -   *
>> > -   * Pre-SKL, the render buffer must be resolved before being used
>> for
>> > -   * presentation. We can infer that the auxiliary buffer is not
>> used.
>> > +  /* When handing the image off to the presentation engine, we
>> need to
>> > +   * ensure that things are properly resolved.  For images with no
>> > +   * modifier, we assume that they follow the old rules and always
>> need
>> > +   * a full resolve because the PE doesn't understand any form of
>> > +   * compression.  For images with modifiers, we use the aux usage
>> from
>> > +   * the modifier.
>> > */
>> > -  return ISL_AUX_USAGE_NONE;
>> > +  const struct isl_drm_modifier_info *mod_info =
>> > + isl_drm_modifier_get_info(image->drm_format_mod);
>> > +  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
>> > +   }
>> >
>> >
>> > /* Rendering Layouts */
>> > @@ -960,8 +961,20 @@ anv_layout_to_fast_clear_type(const struct
>> gen_device_info * const devinfo,
>> > case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
>> >return ANV_FAST_CLEAR_ANY;
>> >
>> > -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
>> > -  return ANV_FAST_CLEAR_NONE;
>> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
>> > +  assert(image->aspects == 

[Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-20 Thread Jason Ekstrand
v2 (Jason Ekstrand):
 - Return the correct enum values from anv_layout_to_fast_clear_type
---
 src/intel/vulkan/anv_formats.c |  9 +++
 src/intel/vulkan/anv_image.c   | 56 +++---
 2 files changed, 45 insertions(+), 20 deletions(-)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 9c52ad5..3c17366 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const struct 
anv_physical_device *physic
   DRM_FORMAT_MOD_LINEAR,
   I915_FORMAT_MOD_X_TILED,
   I915_FORMAT_MOD_Y_TILED,
+  I915_FORMAT_MOD_Y_TILED_CCS,
};
 
for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(modifiers[i]);
+
+  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
+  !isl_format_supports_ccs_e(_device->info,
+ anv_format->planes[0].isl_format))
+ continue;
+
   vk_outarray_append(, mod_props) {
  mod_props->modifier = modifiers[i];
  if (isl_drm_modifier_has_aux(modifiers[i]))
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index a2bae7b..54c975a 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
case DRM_FORMAT_MOD_LINEAR: return 1;
case I915_FORMAT_MOD_X_TILED: return 2;
case I915_FORMAT_MOD_Y_TILED: return 3;
+   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
default: unreachable("bad DRM format modifier");
}
 }
@@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
 VkSubresourceLayout*layout)
 {
ANV_FROM_HANDLE(anv_image, image, _image);
-   const struct anv_surface *surface =
-  get_surface(image, subresource->aspectMask);
+
+   const struct anv_surface *surface;
+   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
+   isl_drm_modifier_has_aux(image->drm_format_mod))
+  surface = >planes[0].aux_surface;
+   else
+  surface = get_surface(image, subresource->aspectMask);
 
assert(__builtin_popcount(subresource->aspectMask) == 1);
 
@@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct gen_device_info * 
const devinfo,
   }
 
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
 
-  /* On SKL+, the render buffer can be decompressed by the presentation
-   * engine. Support for this feature has not yet landed in the wider
-   * ecosystem. TODO: Update this code when support lands.
-   *
-   * From the BDW PRM, Vol 7, Render Target Resolve:
-   *
-   *If the MCS is enabled on a non-multisampled render target, the
-   *render target must be resolved before being used for other
-   *purposes (display, texture, CPU lock) The clear value from
-   *SURFACE_STATE is written into pixels in the render target
-   *indicated as clear in the MCS.
-   *
-   * Pre-SKL, the render buffer must be resolved before being used for
-   * presentation. We can infer that the auxiliary buffer is not used.
+  /* When handing the image off to the presentation engine, we need to
+   * ensure that things are properly resolved.  For images with no
+   * modifier, we assume that they follow the old rules and always need
+   * a full resolve because the PE doesn't understand any form of
+   * compression.  For images with modifiers, we use the aux usage from
+   * the modifier.
*/
-  return ISL_AUX_USAGE_NONE;
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
+   }
 
 
/* Rendering Layouts */
@@ -960,8 +961,23 @@ anv_layout_to_fast_clear_type(const struct gen_device_info 
* const devinfo,
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
   return ANV_FAST_CLEAR_ANY;
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
-  return ANV_FAST_CLEAR_NONE;
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
+  assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+
+  /* When handing the image off to the presentation engine, we need to
+   * ensure that things are properly resolved.  For images with no
+   * modifier, we assume that they follow the old rules and always need
+   * a full resolve because the PE doesn't understand any form of
+   * compression.  For images with modifiers, we use the value from the
+   * modifier.
+   */
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  if (mod_info && mod_info->supports_clear_color)
+ return ANV_FAST_CLEAR_ANY;
+  else
+ return 

Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-20 Thread Jason Ekstrand
On Tue, Feb 20, 2018 at 11:25 AM, Nanley Chery 
wrote:

> On Fri, Feb 16, 2018 at 09:28:43AM -0800, Jason Ekstrand wrote:
> > ---
> >  src/intel/vulkan/anv_formats.c |  9 +++
> >  src/intel/vulkan/anv_image.c   | 53 ++
> 
> >  2 files changed, 42 insertions(+), 20 deletions(-)
> >
> > diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_
> formats.c
> > index 9c52ad5..3c17366 100644
> > --- a/src/intel/vulkan/anv_formats.c
> > +++ b/src/intel/vulkan/anv_formats.c
> > @@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const
> struct anv_physical_device *physic
> >DRM_FORMAT_MOD_LINEAR,
> >I915_FORMAT_MOD_X_TILED,
> >I915_FORMAT_MOD_Y_TILED,
> > +  I915_FORMAT_MOD_Y_TILED_CCS,
> > };
> >
> > for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
> > +  const struct isl_drm_modifier_info *mod_info =
> > + isl_drm_modifier_get_info(modifiers[i]);
> > +
> > +  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
> > +  !isl_format_supports_ccs_e(_device->info,
> > + anv_format->planes[0].isl_format))
> > + continue;
> > +
> >vk_outarray_append(, mod_props) {
> >   mod_props->modifier = modifiers[i];
> >   if (isl_drm_modifier_has_aux(modifiers[i]))
> > diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> > index a2bae7b..d7c2e55 100644
> > --- a/src/intel/vulkan/anv_image.c
> > +++ b/src/intel/vulkan/anv_image.c
> > @@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
> > case DRM_FORMAT_MOD_LINEAR: return 1;
> > case I915_FORMAT_MOD_X_TILED: return 2;
> > case I915_FORMAT_MOD_Y_TILED: return 3;
> > +   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
> > default: unreachable("bad DRM format modifier");
> > }
> >  }
> > @@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
> >  VkSubresourceLayout*layout)
> >  {
> > ANV_FROM_HANDLE(anv_image, image, _image);
> > -   const struct anv_surface *surface =
> > -  get_surface(image, subresource->aspectMask);
> > +
> > +   const struct anv_surface *surface;
> > +   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
> > +   isl_drm_modifier_has_aux(image->drm_format_mod))
> > +  surface = >planes[0].aux_surface;
> > +   else
> > +  surface = get_surface(image, subresource->aspectMask);
> >
> > assert(__builtin_popcount(subresource->aspectMask) == 1);
> >
> > @@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct
> gen_device_info * const devinfo,
> >}
> >
> >
> > -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
> >assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> >
> > -  /* On SKL+, the render buffer can be decompressed by the
> presentation
> > -   * engine. Support for this feature has not yet landed in the
> wider
> > -   * ecosystem. TODO: Update this code when support lands.
> > -   *
> > -   * From the BDW PRM, Vol 7, Render Target Resolve:
> > -   *
> > -   *If the MCS is enabled on a non-multisampled render target,
> the
> > -   *render target must be resolved before being used for other
> > -   *purposes (display, texture, CPU lock) The clear value from
> > -   *SURFACE_STATE is written into pixels in the render target
> > -   *indicated as clear in the MCS.
> > -   *
> > -   * Pre-SKL, the render buffer must be resolved before being used
> for
> > -   * presentation. We can infer that the auxiliary buffer is not
> used.
> > +  /* When handing the image off to the presentation engine, we need
> to
> > +   * ensure that things are properly resolved.  For images with no
> > +   * modifier, we assume that they follow the old rules and always
> need
> > +   * a full resolve because the PE doesn't understand any form of
> > +   * compression.  For images with modifiers, we use the aux usage
> from
> > +   * the modifier.
> > */
> > -  return ISL_AUX_USAGE_NONE;
> > +  const struct isl_drm_modifier_info *mod_info =
> > + isl_drm_modifier_get_info(image->drm_format_mod);
> > +  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
> > +   }
> >
> >
> > /* Rendering Layouts */
> > @@ -960,8 +961,20 @@ anv_layout_to_fast_clear_type(const struct
> gen_device_info * const devinfo,
> > case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
> >return ANV_FAST_CLEAR_ANY;
> >
> > -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> > -  return ANV_FAST_CLEAR_NONE;
> > +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
> > +  assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> > +
> > +  /* When handing the image off to the presentation engine, we need
> to
> > +   * ensure that things are properly resolved.  For images with no
> > +   * 

Re: [Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-20 Thread Nanley Chery
On Fri, Feb 16, 2018 at 09:28:43AM -0800, Jason Ekstrand wrote:
> ---
>  src/intel/vulkan/anv_formats.c |  9 +++
>  src/intel/vulkan/anv_image.c   | 53 
> ++
>  2 files changed, 42 insertions(+), 20 deletions(-)
> 
> diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
> index 9c52ad5..3c17366 100644
> --- a/src/intel/vulkan/anv_formats.c
> +++ b/src/intel/vulkan/anv_formats.c
> @@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const struct 
> anv_physical_device *physic
>DRM_FORMAT_MOD_LINEAR,
>I915_FORMAT_MOD_X_TILED,
>I915_FORMAT_MOD_Y_TILED,
> +  I915_FORMAT_MOD_Y_TILED_CCS,
> };
>  
> for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
> +  const struct isl_drm_modifier_info *mod_info =
> + isl_drm_modifier_get_info(modifiers[i]);
> +
> +  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
> +  !isl_format_supports_ccs_e(_device->info,
> + anv_format->planes[0].isl_format))
> + continue;
> +
>vk_outarray_append(, mod_props) {
>   mod_props->modifier = modifiers[i];
>   if (isl_drm_modifier_has_aux(modifiers[i]))
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index a2bae7b..d7c2e55 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
> case DRM_FORMAT_MOD_LINEAR: return 1;
> case I915_FORMAT_MOD_X_TILED: return 2;
> case I915_FORMAT_MOD_Y_TILED: return 3;
> +   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
> default: unreachable("bad DRM format modifier");
> }
>  }
> @@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
>  VkSubresourceLayout*layout)
>  {
> ANV_FROM_HANDLE(anv_image, image, _image);
> -   const struct anv_surface *surface =
> -  get_surface(image, subresource->aspectMask);
> +
> +   const struct anv_surface *surface;
> +   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
> +   isl_drm_modifier_has_aux(image->drm_format_mod))
> +  surface = >planes[0].aux_surface;
> +   else
> +  surface = get_surface(image, subresource->aspectMask);
>  
> assert(__builtin_popcount(subresource->aspectMask) == 1);
>  
> @@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct gen_device_info * 
> const devinfo,
>}
>  
>  
> -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
>assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
>  
> -  /* On SKL+, the render buffer can be decompressed by the presentation
> -   * engine. Support for this feature has not yet landed in the wider
> -   * ecosystem. TODO: Update this code when support lands.
> -   *
> -   * From the BDW PRM, Vol 7, Render Target Resolve:
> -   *
> -   *If the MCS is enabled on a non-multisampled render target, the
> -   *render target must be resolved before being used for other
> -   *purposes (display, texture, CPU lock) The clear value from
> -   *SURFACE_STATE is written into pixels in the render target
> -   *indicated as clear in the MCS.
> -   *
> -   * Pre-SKL, the render buffer must be resolved before being used for
> -   * presentation. We can infer that the auxiliary buffer is not used.
> +  /* When handing the image off to the presentation engine, we need to
> +   * ensure that things are properly resolved.  For images with no
> +   * modifier, we assume that they follow the old rules and always need
> +   * a full resolve because the PE doesn't understand any form of
> +   * compression.  For images with modifiers, we use the aux usage from
> +   * the modifier.
> */
> -  return ISL_AUX_USAGE_NONE;
> +  const struct isl_drm_modifier_info *mod_info =
> + isl_drm_modifier_get_info(image->drm_format_mod);
> +  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
> +   }
>  
>  
> /* Rendering Layouts */
> @@ -960,8 +961,20 @@ anv_layout_to_fast_clear_type(const struct 
> gen_device_info * const devinfo,
> case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
>return ANV_FAST_CLEAR_ANY;
>  
> -   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
> -  return ANV_FAST_CLEAR_NONE;
> +   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
> +  assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
> +
> +  /* When handing the image off to the presentation engine, we need to
> +   * ensure that things are properly resolved.  For images with no
> +   * modifier, we assume that they follow the old rules and always need
> +   * a full resolve because the PE doesn't understand any form of
> +   * compression.  For images with modifiers, we use the value from the
> +   * modifier.
> +   */
> +  const struct 

[Mesa-dev] [PATCH] anv: Add WSI support for the I915_FORMAT_MOD_Y_TILED_CCS

2018-02-16 Thread Jason Ekstrand
---
 src/intel/vulkan/anv_formats.c |  9 +++
 src/intel/vulkan/anv_image.c   | 53 ++
 2 files changed, 42 insertions(+), 20 deletions(-)

diff --git a/src/intel/vulkan/anv_formats.c b/src/intel/vulkan/anv_formats.c
index 9c52ad5..3c17366 100644
--- a/src/intel/vulkan/anv_formats.c
+++ b/src/intel/vulkan/anv_formats.c
@@ -671,9 +671,18 @@ get_wsi_format_modifier_properties_list(const struct 
anv_physical_device *physic
   DRM_FORMAT_MOD_LINEAR,
   I915_FORMAT_MOD_X_TILED,
   I915_FORMAT_MOD_Y_TILED,
+  I915_FORMAT_MOD_Y_TILED_CCS,
};
 
for (uint32_t i = 0; i < ARRAY_SIZE(modifiers); i++) {
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(modifiers[i]);
+
+  if (mod_info->aux_usage == ISL_AUX_USAGE_CCS_E &&
+  !isl_format_supports_ccs_e(_device->info,
+ anv_format->planes[0].isl_format))
+ continue;
+
   vk_outarray_append(, mod_props) {
  mod_props->modifier = modifiers[i];
  if (isl_drm_modifier_has_aux(modifiers[i]))
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index a2bae7b..d7c2e55 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -515,6 +515,7 @@ score_drm_format_mod(uint64_t modifier)
case DRM_FORMAT_MOD_LINEAR: return 1;
case I915_FORMAT_MOD_X_TILED: return 2;
case I915_FORMAT_MOD_Y_TILED: return 3;
+   case I915_FORMAT_MOD_Y_TILED_CCS: return 4;
default: unreachable("bad DRM format modifier");
}
 }
@@ -746,8 +747,13 @@ void anv_GetImageSubresourceLayout(
 VkSubresourceLayout*layout)
 {
ANV_FROM_HANDLE(anv_image, image, _image);
-   const struct anv_surface *surface =
-  get_surface(image, subresource->aspectMask);
+
+   const struct anv_surface *surface;
+   if (subresource->aspectMask == VK_IMAGE_ASPECT_PLANE_1_BIT_KHR &&
+   isl_drm_modifier_has_aux(image->drm_format_mod))
+  surface = >planes[0].aux_surface;
+   else
+  surface = get_surface(image, subresource->aspectMask);
 
assert(__builtin_popcount(subresource->aspectMask) == 1);
 
@@ -862,25 +868,20 @@ anv_layout_to_aux_usage(const struct gen_device_info * 
const devinfo,
   }
 
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
 
-  /* On SKL+, the render buffer can be decompressed by the presentation
-   * engine. Support for this feature has not yet landed in the wider
-   * ecosystem. TODO: Update this code when support lands.
-   *
-   * From the BDW PRM, Vol 7, Render Target Resolve:
-   *
-   *If the MCS is enabled on a non-multisampled render target, the
-   *render target must be resolved before being used for other
-   *purposes (display, texture, CPU lock) The clear value from
-   *SURFACE_STATE is written into pixels in the render target
-   *indicated as clear in the MCS.
-   *
-   * Pre-SKL, the render buffer must be resolved before being used for
-   * presentation. We can infer that the auxiliary buffer is not used.
+  /* When handing the image off to the presentation engine, we need to
+   * ensure that things are properly resolved.  For images with no
+   * modifier, we assume that they follow the old rules and always need
+   * a full resolve because the PE doesn't understand any form of
+   * compression.  For images with modifiers, we use the aux usage from
+   * the modifier.
*/
-  return ISL_AUX_USAGE_NONE;
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  return mod_info ? mod_info->aux_usage : ISL_AUX_USAGE_NONE;
+   }
 
 
/* Rendering Layouts */
@@ -960,8 +961,20 @@ anv_layout_to_fast_clear_type(const struct gen_device_info 
* const devinfo,
case VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL:
   return ANV_FAST_CLEAR_ANY;
 
-   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR:
-  return ANV_FAST_CLEAR_NONE;
+   case VK_IMAGE_LAYOUT_PRESENT_SRC_KHR: {
+  assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+
+  /* When handing the image off to the presentation engine, we need to
+   * ensure that things are properly resolved.  For images with no
+   * modifier, we assume that they follow the old rules and always need
+   * a full resolve because the PE doesn't understand any form of
+   * compression.  For images with modifiers, we use the value from the
+   * modifier.
+   */
+  const struct isl_drm_modifier_info *mod_info =
+ isl_drm_modifier_get_info(image->drm_format_mod);
+  return mod_info && mod_info->supports_clear_color;
+   }
 
default:
   /* If the image has CCS_E enabled all the time then we can use
-- 
2.5.0.400.gff86faf