1Name 2 3 NVX_conditional_render 4 5Name Strings 6 7 GL_NVX_conditional_render 8 9Contact 10 11 Eric Werness, NVIDIA (ewerness 'at' nvidia.com) 12 Pat Brown, NVIDIA (pbrown 'at' nvidia.com) 13 14Status 15 16 Shipping. 17 18Version 19 20 Last Modified Date: 08/07/2012 21 NVIDIA Revision: 4 22 23Number 24 25 425 26 27Dependencies 28 29 The extension is written against the OpenGL 2.0 Specification. 30 31 ARB_occlusion_query or OpenGL 1.5 is required. 32 33 This extension interacts with NV_conditional_render. 34 35Overview 36 37 This extension provides support for conditional rendering based on the 38 results of an occlusion query. This mechanism allows an application to 39 potentially reduce the latency between the completion of an occlusion 40 query and the rendering commands depending on its result. It additionally 41 allows the decision of whether to render to be made without application 42 intervention. 43 44 This extension defines two new functions, BeginConditionalRenderNVX and 45 EndConditionalRenderNVX, between which rendering commands may be discarded 46 based on the results of an occlusion query. If the specified occlusion 47 query returns a non-zero value, rendering commands between these calls are 48 executed. If the occlusion query returns a value of zero, all rendering 49 commands between the calls are discarded. 50 51New Procedures and Functions 52 53 void BeginConditionalRenderNVX(uint id); 54 void EndConditionalRenderNVX(void); 55 56 57New Tokens 58 59 None. 60 61 62Additions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation) 63 64 (Incorporate the spec edits from the NV_transform_feedback specification 65 that move the "Occlusion Queries" Section 4.1.7 -- to between Section 2.11, 66 Coordinate Transforms and Section 2.12, Clipping, and rename it to 67 "Asynchronous Queries". Insert a new section immediately after the moved 68 "Asynchronous Queries" section. If NV_transform_feedback is incorporated, 69 this section should be inserted prior the the "Transform Feedback" 70 section.) 71 72 (also modify the BeginQuery language to disallow BeginQuery while the 73 query object is being used for conditional rendering) 74 ... 75 BeginQuery sets the active query object name for the query type given by 76 <target> to <id>. If BeginQuery is called with an <id> of zero, if the 77 active query object name for <target> is non-zero, if <id> is the active 78 query object name for any query type, or if <id> is the active query 79 object for condtional rendering (Section 2.X), the error INVALID OPERATION 80 is generated. 81 82 83 Section 2.X, Conditional Rendering 84 85 Conditional rendering can be used to discard rendering commands based on 86 the result of an occlusion query. Conditional rendering is started and 87 stopped using the commands 88 89 void BeginConditionalRenderNVX(uint id); 90 void EndConditionalRenderNVX(void); 91 92 <id> specifies the name of an occlusion query object whose results are 93 used to determine if the rendering commands are discarded. If the result 94 (SAMPLES_PASSED) of the query is zero, all rendering commands between 95 BeginConditionalRenderNVX and the corresponding EndConditionalRenderNVX 96 are discarded. In this case, Begin, End, all vertex array commands 97 performing an implicit Begin and End, DrawPixels (section 3.6), Bitmap 98 (section 3.7), Clear (section 4.2.3), Accum (section 4.2.4), CopyPixels 99 (section 4.3.3), EvalMesh1, and EvalMesh2 (section 5.1) have no effect. 100 The effect of commands setting current vertex state (e.g., Color, 101 VertexAttrib) is undefined. If the result of the occlusion query is 102 non-zero, such commands are not discarded. The GL waits for the results 103 of the query to be available and then uses the results to determine if 104 subsequent rendering commands are discarded. 105 106 If BeginConditionalRenderNVX is called while conditional rendering is in 107 progress, or if EndConditionalRenderNVX is called while conditional 108 rendering is not in progress, the error INVALID_OPERATION is generated. 109 The error INVALID_VALUE is generated if <id> is not the name of an 110 existing query object query. The error INVALID_OPERATION is generated if 111 <id> is the name of a query object with a target other than 112 SAMPLES_PASSED, or <id> is the name of a query currently in progress. 113 114 115Additions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization) 116 117 None. 118 119Additions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment 120Operations and the Frame Buffer) 121 122 None. 123 124Additions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions) 125 126 None. 127 128Additions to Chapter 6 of the OpenGL 2.0 Specification (State and State 129Requests) 130 131 None. 132 133Additions to Appendix A of the OpenGL 2.0 Specification (Invariance) 134 135 None. 136 137Additions to the AGL/GLX/WGL Specifications 138 139 None. 140 141GLX Protocol 142 143 TBD. 144 145Dependencies on NV_conditional_render 146 147 This extension was an early version of the NV_conditional_render 148 extension, which provides several conditional rendering modes 149 (QUERY_WAIT_NV, QUERY_NO_WAIT_NV, QUERY_BY_REGION_WAIT_NV, 150 QUERY_BY_REGION_NO_WAIT_NV). This extension's commands: 151 152 glBeginConditionalRenderNVX(id); 153 glEndConditionalRenderNVX(); 154 155 are equivalent to the following NV_conditional_render commands: 156 157 glBeginConditionalRenderNV(id, QUERY_WAIT_NV); 158 glEndConditionalRenderNV(); 159 160Errors 161 162 INVALID_OPERATION is generated by BeginConditionalRenderNVX if a previous 163 BeginConditionalRenderNVX command has been executed without a 164 corresponding EndConditionalRenderNVX command. 165 166 INVALID_OPERATION is generated by EndConditionalRenderNVX if no 167 corresponding BeginConditionalRenderNVX command has been executed. 168 169 INVALID_VALUE is generated by BeginConditionalRenderNVX if <id> is not the 170 name of an existing occlusion query object. 171 172 INVALID_OPERATION is generated by BeginConditionalRenderNVX if <id> is the 173 name of a query object with a <target> other than SAMPLES_PASSED. 174 175 INVALID_OPERATION is generated by BeginConditionalRenderNVX if the query 176 identified by <id> is still in progress. 177 178Issues 179 180 (1) How should rendering commands other than "normal" Begin/End-style 181 geometry be affected by conditional rendering? 182 183 RESOLVED: All rendering commands (DrawPixels, Bitmap, Clear, Accum, 184 etc...) are performed conditionally. 185 186 (5) What happens if BeginQuery is called while the specified occlusion 187 query is begin used for conditional rendering? 188 189 RESOLVED: An INVALID_OPERATION error is generated. 190 191 (6) Should conditional rendering work with any type of query other than 192 SAMPLES_PASSED (occlusion)? 193 194 RESOLVED: Not in this extension. The spec currently requires that <id> 195 be the name of an occlusion query. There might be other query types 196 where such an operation would make sense, but there aren't any in the 197 current OpenGL spec. 198 199 (7) What is the effect on current state for immediate mode attribute calls 200 (e.g., Color, VertexAttrib) made during conditional rendering if the 201 corresponding occlusion query failed? 202 203 RESOLVED: The effect of these calls is undefined. If subsequent 204 primitives depend on a vertex attribute set inside a conditional 205 rendering block, and application should re-send the values after 206 EndConditionalRenderNV. 207 208 209Usage Example 210 211 GLuint queryID = 0x12345678; 212 213 // Use an occlusion query while rendering the bounding box of the real 214 // object. 215 glBeginQuery(GL_SAMPLES_PASSED, queryID); 216 drawBoundingBox(); 217 glEndQuery(GL_SAMPLES_PASSED); 218 219 // Do some unrelated rendering in hope that the query result will be 220 // available by the time we call glBeginConditionalRenderNV. 221 222 // Now conditionally render the real object if any portion of its 223 // bounding box is visible. 224 glBeginConditionalRenderNVX(queryID); 225 drawComplicatedObject(); 226 glEndConditionalRenderNVX(); 227 228 229Revision History 230 231 Rev. Date Author Changes 232 ---- -------- -------- -------------------------------------------- 233 4 08/07/12 pbrown Minor edits in preparation for publishing to 234 the Khronos registry. 235 236 3 02/19/08 pbrown Document the INVALID_OPERATION error from 237 calling BeginQuery while the query is used 238 for conditional rendering in the spec body. 239 240 2 11/29/07 ewerness First public release 241 242 1 Internal revisions 243