1// Copyright (c) 2018-2020 NVIDIA Corporation 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5include::{generated}/meta/{refprefix}VK_NV_representative_fragment_test.adoc[] 6 7=== Other Extension Metadata 8 9*Last Modified Date*:: 10 2018-09-13 11*Contributors*:: 12 - Kedarnath Thangudu, NVIDIA 13 - Christoph Kubisch, NVIDIA 14 - Pierre Boudier, NVIDIA 15 - Pat Brown, NVIDIA 16 - Jeff Bolz, NVIDIA 17 - Eric Werness, NVIDIA 18 19=== Description 20 21This extension provides a new representative fragment test that allows 22implementations to reduce the amount of rasterization and fragment 23processing work performed for each point, line, or triangle primitive. 24For any primitive that produces one or more fragments that pass all other 25early fragment tests, the implementation is permitted to choose one or more 26"`representative`" fragments for processing and discard all other fragments. 27For draw calls rendering multiple points, lines, or triangles arranged in 28lists, strips, or fans, the representative fragment test is performed 29independently for each of those primitives. 30 31This extension is useful for applications that use an early render pass to 32determine the full set of primitives that would be visible in the final 33scene. 34In this render pass, such applications would set up a fragment shader that 35enables early fragment tests and writes to an image or shader storage buffer 36to record the ID of the primitive that generated the fragment. 37Without this extension, the shader would record the ID separately for each 38visible fragment of each primitive. 39With this extension, fewer stores will be performed, particularly for large 40primitives. 41 42The representative fragment test has no effect if early fragment tests are 43not enabled via the fragment shader. 44The set of fragments discarded by the representative fragment test is 45implementation-dependent and may vary from frame to frame. 46In some cases, the representative fragment test may not discard any 47fragments for a given primitive. 48 49include::{generated}/interfaces/VK_NV_representative_fragment_test.adoc[] 50 51=== Issues 52 53(1) Is the representative fragment test guaranteed to have any effect? 54 55*RESOLVED*: No. 56As specified, we only guarantee that each primitive with at least one 57fragment that passes prior tests will have one fragment passing the 58representative fragment tests. 59We do not guarantee that any particular fragment will fail the test. 60 61In the initial implementation of this extension, the representative fragment 62test is treated as an optimization that may be completely disabled for some 63pipeline states. 64This feature was designed for a use case where the fragment shader records 65information on individual primitives using shader storage buffers or storage 66images, with no writes to color or depth buffers. 67 68(2) Will the set of fragments that pass the representative fragment test be 69repeatable if you draw the same scene over and over again? 70 71*RESOLVED*: No. 72The set of fragments that pass the representative fragment test is 73implementation-dependent and may vary due to the timing of operations 74performed by the GPU. 75 76(3) What happens if you enable the representative fragment test with writes 77to color and/or depth render targets enabled? 78 79*RESOLVED*: If writes to the color or depth buffer are enabled, they will be 80performed for any fragments that survive the relevant tests. 81Any fragments that fail the representative fragment test will not update 82color buffers. 83For the use cases intended for this feature, we do not expect color or depth 84writes to be enabled. 85 86(4) How do derivatives and automatic texture level of detail computations 87work with the representative fragment test enabled? 88 89*RESOLVED*: If a fragment shader uses derivative functions or texture 90lookups using automatic level of detail computation, derivatives will be 91computed identically whether or not the representative fragment test is 92enabled. 93For the use cases intended for this feature, we do not expect the use of 94derivatives in the fragment shader. 95 96=== Version History 97 98 * Revision 2, 2018-09-13 (pbrown) 99 ** Add issues. 100 * Revision 1, 2018-08-22 (Kedarnath Thangudu) 101 ** Internal Revisions 102