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