• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1include::meta/VK_AMD_shader_fragment_mask.txt[]
2
3*Last Modified Date*::
4    2017-08-16
5*IP Status*::
6    No known IP claims.
7*Dependencies*::
8  - Requires the
9    https://www.khronos.org/registry/spir-v/extensions/AMD/SPV_AMD_shader_fragment_mask.html[+SPV_AMD_shader_fragment_mask+]
10    SPIR-V extension.
11*Contributors*::
12  - Aaron Hagan, AMD
13  - Daniel Rakos, AMD
14  - Timothy Lottes, AMD
15
16This extension provides efficient read access to the fragment mask in
17compressed multisampled color surfaces.
18The fragment mask is a lookup table that associates color samples with color
19fragment values.
20
21From a shader, the fragment mask can be fetched with a call to
22code:fragmentMaskFetchAMD, which returns a single code:uint where each
23subsequent four bits specify the color fragment index corresponding to the
24color sample, starting from the least significant bit.
25For example, when eight color samples are used, the color fragment index for
26color sample 0 will be in bits 0-3 of the fragment mask, for color sample 7
27the index will be in bits 28-31.
28
29The color fragment for a particular color sample may then be fetched with
30the corresponding fragment mask value using the code:fragmentFetchAMD shader
31function.
32
33=== New Object Types
34
35None.
36
37=== New Enum Constants
38
39None.
40
41=== New Enums
42
43None.
44
45=== New SPIR-V Capabilities
46
47  * <<spirvenv-capabilities-table-fragmentmaskamd, code:FragmentMaskAMD>>
48
49=== New Structures
50
51None.
52
53=== New Functions
54
55None.
56
57=== Examples
58
59This example shows a shader that queries the fragment mask from a
60multisampled compressed surface and uses it to query fragment values.
61
62[source,c++]
63----------------------------------------
64#version 450 core
65
66#extension GL_AMD_shader_fragment_mask: enable
67
68layout(binding = 0) uniform sampler2DMS       s2DMS;
69layout(binding = 1) uniform isampler2DMSArray is2DMSArray;
70
71layout(binding = 2, input_attachment_index = 0) uniform usubpassInputMS usubpassMS;
72
73layout(location = 0) out vec4 fragColor;
74
75void main()
76{
77    vec4 fragOne = vec4(0.0);
78
79    uint fragMask = fragmentMaskFetchAMD(s2DMS, ivec2(2, 3));
80    uint fragIndex = (fragMask & 0xF0) >> 4;
81    fragOne += fragmentFetchAMD(s2DMS, ivec2(2, 3), 1);
82
83    fragMask = fragmentMaskFetchAMD(is2DMSArray, ivec3(2, 3, 1));
84    fragIndex = (fragMask & 0xF0) >> 4;
85    fragOne += fragmentFetchAMD(is2DMSArray, ivec3(2, 3, 1), fragIndex);
86
87    fragMask = fragmentMaskFetchAMD(usubpassMS);
88    fragIndex = (fragMask & 0xF0) >> 4;
89    fragOne += fragmentFetchAMD(usubpassMS, fragIndex);
90
91    fragColor = fragOne;
92}
93----------------------------------------
94
95=== Version History
96
97  * Revision 1, 2017-08-16 (Aaron Hagan)
98    - Initial draft
99