diff options
author | Jason Ekstrand <[email protected]> | 2019-06-16 21:21:16 -0500 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2019-06-17 22:32:26 +0000 |
commit | f3ea0cf8289ebdbb45d7122095919fb6752eb433 (patch) | |
tree | e6bf480d13e2de840d910a4eceaba919f22775a1 /src/intel/vulkan/anv_image.c | |
parent | 4faa3145b16ed2160082ef70c8925c9fb0b1964c (diff) |
anv: Add stencil texturing support for gen7
Intel hardware didn't get support for sampling from W-tiled (required
for stencil) images until Broadwell so we can't directly sample from
stencil. Instead, if we want to support stencil texturing on gen7
hardware, we have to keep a texture-capable shadow copy around and use
BLORP to update when stencil changes. The one thing this commit does
not implement is self-dependencies with stencil input attachments.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=99493
Reviewed-by: Lionel Landwerlin <[email protected]>
Diffstat (limited to 'src/intel/vulkan/anv_image.c')
-rw-r--r-- | src/intel/vulkan/anv_image.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c index 038a01f8a39..f405aa8067f 100644 --- a/src/intel/vulkan/anv_image.c +++ b/src/intel/vulkan/anv_image.c @@ -336,6 +336,12 @@ make_surface(const struct anv_device *dev, needs_shadow = true; } + if (dev->info.gen <= 7 && + aspect == VK_IMAGE_ASPECT_STENCIL_BIT && + (image->usage & VK_IMAGE_USAGE_SAMPLED_BIT)) { + needs_shadow = true; + } + ok = isl_surf_init(&dev->isl_dev, &anv_surf->isl, .dim = vk_to_isl_surf_dim[image->type], .format = plane_format.isl_format, @@ -359,12 +365,11 @@ make_surface(const struct anv_device *dev, /* If an image is created as BLOCK_TEXEL_VIEW_COMPATIBLE, then we need to * create an identical tiled shadow surface for use while texturing so we - * don't get garbage performance. + * don't get garbage performance. If we're on gen7 and the image contains + * stencil, then we need to maintain a shadow because we can't texture from + * W-tiled images. */ if (needs_shadow) { - assert(aspect == VK_IMAGE_ASPECT_COLOR_BIT); - assert(tiling_flags == ISL_TILING_LINEAR_BIT); - ok = isl_surf_init(&dev->isl_dev, &image->planes[plane].shadow_surface.isl, .dim = vk_to_isl_surf_dim[image->type], .format = plane_format.isl_format, @@ -1275,6 +1280,16 @@ anv_image_fill_surface_state(struct anv_device *device, surface = &image->planes[plane].shadow_surface; } + /* For texturing from stencil on gen7, we have to sample from a shadow + * surface because we don't support W-tiling in the sampler. + */ + if (image->planes[plane].shadow_surface.isl.size_B > 0 && + aspect == VK_IMAGE_ASPECT_STENCIL_BIT) { + assert(device->info.gen == 7); + assert(view_usage & ISL_SURF_USAGE_TEXTURE_BIT); + surface = &image->planes[plane].shadow_surface; + } + if (view_usage == ISL_SURF_USAGE_RENDER_TARGET_BIT) view.swizzle = anv_swizzle_for_render(view.swizzle); |