Merge pull request #433 from jackohound/add_QCOM_texture_foveated2

add QCOM_texture_foveated2
diff --git a/extensions/QCOM/QCOM_texture_foveated2.txt b/extensions/QCOM/QCOM_texture_foveated2.txt
new file mode 100644
index 0000000..9985a42
--- /dev/null
+++ b/extensions/QCOM/QCOM_texture_foveated2.txt
@@ -0,0 +1,114 @@
+Name
+
+    QCOM_texture_foveated2
+
+Name Strings
+
+    GL_QCOM_texture_foveated2
+
+Contact
+
+    Jeff Leger - jleger 'at' qti.qualcomm.com
+
+Contributors
+
+    Sam Holmes
+    Jonathan Wicks
+    Arpit Agarwal
+
+Status
+
+    Complete
+
+Version
+
+    Last Modified Date:  October 12, 2020
+    Author Revision: 1.0
+
+Number
+
+     OpenGL ES Extension #331
+
+Dependencies
+
+    This extension requires QCOM_texture_foveated.
+
+    This extension interacts with QCOM_texture_foveated_subsampled_layout.
+
+Overview
+
+    This extension adds a new texture parameter that specifies a pixel density
+    below which rendering can be discarded during foveated rendering.
+
+New Tokens
+
+    Accepted as a value for <pname> for the TexParameter{if} and
+    TexParameter{if}v commands and for the <pname> parameter of
+    GetTexParameter{if}v:
+
+    TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM         0x96A0
+
+    Add new rows to Table 8.19 (Texture parameters and their values):
+
+        Name                               | Type | Legal Values
+    ------------------------------------------------------------
+    TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM | float | Any float between 0.0 and 1.0
+
+    Add new rows to Table 21.10 Textures (state per texture object)
+
+    Get value | Type | Get Command | Initial Value | Description | Sec
+    ------------------------------------------------------------------
+    TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM | R[0.0,1.0] | GetTexParameter{if}v | 0.0 | Pixel density threshold for rendering cutoff | 8.19
+
+    This parameter defines the cutoff pixel density for a given focal
+    point at the location (px,py) on a texture layer in NDC as:
+
+    cutoff_pixel_density=TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM;
+    for(int i=0;i<focalPointsPerLayer;++i){
+        focal_point_density = 1./max((focalX[i]-px)^2*gainX[i]^2+
+                            (focalY[i]-py)^2*gainY[i]^2-foveaArea[i],1.);
+        if(focal_point_density >= cutoff_pixel_density)
+            shade pixel;
+    }
+
+    The resulting contents of the buffer regions corresponding to the
+    discarded pixels will be undefined.
+
+New Procedures and Functions
+
+    None.
+
+Errors
+
+    INVALID_VALUE is generated by TexParameter{if} or TexParamter{if}v
+    if <pname> is TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM and <param> is a
+    float less than 0.0 or greater than 1.0.
+
+Issues
+
+    (1)  What are the texture contents in discarded regions?
+
+    RESOLVED: After a draw operation where the foveation density cutoff
+    is applied, the contents of the discarded regions of the texture become
+    undefined. It is the application's responsibility to only sample from
+    the regions of the texture that are above the cutoff pixel density, as
+    specified by the provided foveation parameters.
+
+    (2)  Are any other buffers impacted other than color buffer?
+
+    RESOLVED: Yes. Contents of the depth and stencil buffers will be
+    undefined for discarded regions.
+
+    (3)  What is the impact on primitive/geometric data for discarded regions?
+
+    RESOLVED: For the discarded regions, primitive data is also discarded so
+    the behavior of all shaders in the vertex processing stage is undefined
+    for these regions (such as UAV writes and transform feedback).
+
+
+Revision History
+
+      Rev.    Date    Author    Changes
+      ----  --------  --------  -----------------------------------------
+      1.0   10/12/20  jleger  Initial version.
+
diff --git a/extensions/esext.php b/extensions/esext.php
index 3ed2597..3d80fe4 100644
--- a/extensions/esext.php
+++ b/extensions/esext.php
@@ -687,4 +687,6 @@
 </li>
 <li value=330><a href="extensions/NV/NV_timeline_semaphore.txt">GL_NV_timeline_semaphore</a>
 </li>
+<li value=331><a href="extensions/QCOM/QCOM_texture_foveated2.txt">GL_QCOM_texture_foveated2</a>
+</li>
 </ol>
diff --git a/extensions/registry.py b/extensions/registry.py
index 41f8fda..86d395e 100644
--- a/extensions/registry.py
+++ b/extensions/registry.py
@@ -4558,6 +4558,11 @@
         'flags' : { 'public' },
         'url' : 'extensions/QCOM/QCOM_texture_foveated.txt',
     },
+    'GL_QCOM_texture_foveated2' : {
+        'esnumber' : 331,
+        'flags' : { 'public' },
+        'url' : 'extensions/QCOM/QCOM_texture_foveated2.txt',
+    },
     'GL_QCOM_texture_foveated_subsampled_layout' : {
         'esnumber' : 306,
         'flags' : { 'public' },
diff --git a/xml/gl.xml b/xml/gl.xml
index c7861a9..5288ba1 100644
--- a/xml/gl.xml
+++ b/xml/gl.xml
@@ -11620,7 +11620,8 @@
     </enums>
 
     <enums namespace="GL" start="0x96A0" end="0x96AF" vendor="Qualcomm" comment="contact Jeff Leger">
-            <unused start="0x96A0" end="0x96A1" vendor="Qualcomm"/>
+        <enum value="0x96A0" name="GL_TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM" group="TextureParameterName"/>
+            <unused start="0x96A1" end="0x96A1" vendor="Qualcomm"/>
         <enum value="0x96A2" name="GL_FRAMEBUFFER_FETCH_NONCOHERENT_QCOM" group="FramebufferFetchNoncoherent"/>
         <enum value="0x96A3" name="GL_VALIDATE_SHADER_BINARY_QCOM"/>
         <enum value="0x96A4" name="GL_SHADING_RATE_QCOM" group="GetPName"/>
@@ -51107,6 +51108,11 @@
                 <command name="glTextureFoveationParametersQCOM"/>
             </require>
         </extension>
+        <extension name="GL_QCOM_texture_foveated2" supported="gles2">
+            <require>
+                <enum name="GL_TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM"/>
+            </require>
+        </extension>
         <extension name="GL_QCOM_texture_foveated_subsampled_layout" supported="gles2">
             <require>
                 <enum name="GL_FOVEATION_SUBSAMPLED_LAYOUT_METHOD_BIT_QCOM"/>