/ appendices / VK_AMD_shader_fragment_mask.txt
VK_AMD_shader_fragment_mask.txt
1 include::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 16 This extension provides efficient read access to the fragment mask in 17 compressed multisampled color surfaces. 18 The fragment mask is a lookup table that associates color samples with color 19 fragment values. 20 21 From a shader, the fragment mask can be fetched with a call to 22 code:fragmentMaskFetchAMD, which returns a single code:uint where each 23 subsequent four bits specify the color fragment index corresponding to the 24 color sample, starting from the least significant bit. 25 For example, when eight color samples are used, the color fragment index for 26 color sample 0 will be in bits 0-3 of the fragment mask, for color sample 7 27 the index will be in bits 28-31. 28 29 The color fragment for a particular color sample may then be fetched with 30 the corresponding fragment mask value using the code:fragmentFetchAMD shader 31 function. 32 33 === New Object Types 34 35 None. 36 37 === New Enum Constants 38 39 None. 40 41 === New Enums 42 43 None. 44 45 === New SPIR-V Capabilities 46 47 * <<spirvenv-capabilities-table-fragmentmaskamd, code:FragmentMaskAMD>> 48 49 === New Structures 50 51 None. 52 53 === New Functions 54 55 None. 56 57 === Examples 58 59 This example shows a shader that queries the fragment mask from a 60 multisampled 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 68 layout(binding = 0) uniform sampler2DMS s2DMS; 69 layout(binding = 1) uniform isampler2DMSArray is2DMSArray; 70 71 layout(binding = 2, input_attachment_index = 0) uniform usubpassInputMS usubpassMS; 72 73 layout(location = 0) out vec4 fragColor; 74 75 void 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