// Copyright 2022-2024 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

include::{generated}/meta/{refprefix}VK_EXT_shader_tile_image.adoc[]

=== Other Extension Metadata

*Last Modified Date*::
  2023-03-23
*IP Status*::
  No known IP claims.
*Interactions and External Dependencies*::
  - This extension provides API support for
    https://raw.githubusercontent.com/KhronosGroup/GLSL/master/extensions/ext/GLSL_EXT_shader_tile_image.txt[`GL_EXT_shader_tile_image`]
*Contributors*::
  - Sandeep Kakarlapudi, Arm
  - Jan-Harald Fredriksen, Arm
  - James Fitzpatrick, Imagination
  - Andrew Garrard, Imagination
  - Jeff Leger, Qualcomm
  - Huilong Wang, Huawei
  - Graeme Leese, Broadcom
  - Hans-Kristian Arntzen, Valve
  - Tobias Hector, AMD
  - Jeff Bolz, NVIDIA
  - Shahbaz Youssefi, Google

=== Description

This extension allows fragment shader invocations to read color, depth and
stencil values at their pixel location in rasterization order.
The functionality is only available when using dynamic render passes
introduced by VK_KHR_dynamic_rendering.
Example use cases are programmable blending and deferred shading.

See <<fragops-shader-tileimage-reads, fragment shader tile image reads>> for
more information.

include::{generated}/interfaces/VK_EXT_shader_tile_image.adoc[]

=== Issues

None.

=== Examples

Color read example.
[source,c]
----
layout( location = 0 /* aliased to color attachment 0 */ ) tileImageEXT highp attachmentEXT color0;
layout( location = 1 /* aliased to color attachment 1 */ ) tileImageEXT highp attachmentEXT color1;

layout( location = 0 ) out vec4 fragColor;

void main()
{
    vec4 value = colorAttachmentReadEXT(color0) + colorAttachmentReadEXT(color1);
    fragColor = value;
}
----

Depth & Stencil read example.
[source,c]
----
void main()
{
    // read sample 0: works for non-MSAA or MSAA targets
    highp float last_depth = depthAttachmentReadEXT();
    lowp uint last_stencil = stencilAttachmentReadEXT();

    //..
}
----

=== Version History

  * Revision 1, 2023-03-23 (Sandeep Kakarlapudi)
  ** Initial version
