15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_conditional_render 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_conditional_render 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Eric Werness, NVIDIA (ewerness 'at' nvidia.com) 125bd8deadSopenharmony_ci Pat Brown, NVIDIA (pbrown 'at' nvidia.com) 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContributors 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Daniel Koch, NVIDIA 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciStatus 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Shipping. 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ciVersion 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ci Last Modified Date: 05/26/2014 255bd8deadSopenharmony_ci NVIDIA Revision: 6 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciNumber 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci OpenGL Extension #346 305bd8deadSopenharmony_ci OpenGL ES Extension #198 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciDependencies 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci The extension is written against the OpenGL 2.0 Specification. 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci ARB_occlusion_query or OpenGL 1.5 is required in an OpenGL 375bd8deadSopenharmony_ci implementation. 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci This extension interacts with NVX_conditional_render. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ci This extension interacts with ARB_occlusion_query2. 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci This extension interacts with ARB_ES3_compatibility. 445bd8deadSopenharmony_ci 455bd8deadSopenharmony_ci This extension interacts trivially with the OpenGL compatibility profile. 465bd8deadSopenharmony_ci 475bd8deadSopenharmony_ci This extension interacts with OpenGL 3.0, 3.2, 3.3, and 4.3 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci EXT_occlusion_query_boolean or OpenGL ES 3.0 is required in an OpenGL ES 505bd8deadSopenharmony_ci implementation. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci This extension interacts with EXT_occlusion_query_boolean. 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci This extension interacts with NV_occlusion_query_samples. 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci This extension interacts with OpenGL ES 3.0. 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ciOverview 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci This extension provides support for conditional rendering based on the 615bd8deadSopenharmony_ci results of an occlusion query. This mechanism allows an application to 625bd8deadSopenharmony_ci potentially reduce the latency between the completion of an occlusion 635bd8deadSopenharmony_ci query and the rendering commands depending on its result. It additionally 645bd8deadSopenharmony_ci allows the decision of whether to render to be made without application 655bd8deadSopenharmony_ci intervention. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci This extension defines two new functions, BeginConditionalRenderNV and 685bd8deadSopenharmony_ci EndConditionalRenderNV, between which rendering commands may be discarded 695bd8deadSopenharmony_ci based on the results of an occlusion query. If the specified occlusion 705bd8deadSopenharmony_ci query returns a non-zero value, rendering commands between these calls are 715bd8deadSopenharmony_ci executed. If the occlusion query returns a value of zero, all rendering 725bd8deadSopenharmony_ci commands between the calls are discarded. 735bd8deadSopenharmony_ci 745bd8deadSopenharmony_ci If the occlusion query results are not available when 755bd8deadSopenharmony_ci BeginConditionalRenderNV is executed, the <mode> parameter specifies 765bd8deadSopenharmony_ci whether the GL should wait for the query to complete or should simply 775bd8deadSopenharmony_ci render the subsequent geometry unconditionally. 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ci Additionally, the extension provides a set of "by region" modes, allowing 805bd8deadSopenharmony_ci for implementations that divide rendering work by screen regions to 815bd8deadSopenharmony_ci perform the conditional query test on a region-by-region basis without 825bd8deadSopenharmony_ci checking the query results from other regions. Such a mode is useful for 835bd8deadSopenharmony_ci cases like split-frame SLI, where a frame is divided between multiple 845bd8deadSopenharmony_ci GPUs, each of which has its own occlusion query hardware. 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ciNew Procedures and Functions 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci void BeginConditionalRenderNV(uint id, enum mode); 905bd8deadSopenharmony_ci void EndConditionalRenderNV(void); 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ciNew Tokens 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ci Accepted by the <mode> parameter of BeginConditionalRenderNV: 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci QUERY_WAIT_NV 0x8E13 985bd8deadSopenharmony_ci QUERY_NO_WAIT_NV 0x8E14 995bd8deadSopenharmony_ci QUERY_BY_REGION_WAIT_NV 0x8E15 1005bd8deadSopenharmony_ci QUERY_BY_REGION_NO_WAIT_NV 0x8E16 1015bd8deadSopenharmony_ci 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 2.0 Specification (OpenGL Operation) 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci (Incorporate the spec edits from the EXT_transform_feedback specification 1065bd8deadSopenharmony_ci that move the "Occlusion Queries" Section 4.1.7 -- to between Section 2.11, 1075bd8deadSopenharmony_ci Coordinate Transforms and Section 2.12, Clipping, and rename it to 1085bd8deadSopenharmony_ci "Asynchronous Queries". Insert a new section immediately after the moved 1095bd8deadSopenharmony_ci "Asynchronous Queries" section. If EXT_transform_feedback is incorporated, 1105bd8deadSopenharmony_ci this section should be inserted prior the the "Transform Feedback" 1115bd8deadSopenharmony_ci section.) 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci (also modify the BeginQuery language to disallow BeginQuery while the 1145bd8deadSopenharmony_ci query object is being used for conditional rendering) 1155bd8deadSopenharmony_ci ... 1165bd8deadSopenharmony_ci BeginQuery sets the active query object name for the query type given by 1175bd8deadSopenharmony_ci <target> to <id>. If BeginQuery is called with an <id> of zero, if the 1185bd8deadSopenharmony_ci active query object name for <target> is non-zero, if <id> is the active 1195bd8deadSopenharmony_ci query object name for any query type, or if <id> is the active query 1205bd8deadSopenharmony_ci object for condtional rendering (Section 2.X), the error INVALID OPERATION 1215bd8deadSopenharmony_ci is generated. 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci 1245bd8deadSopenharmony_ci Section 2.X, Conditional Rendering 1255bd8deadSopenharmony_ci 1265bd8deadSopenharmony_ci Conditional rendering can be used to discard rendering commands based on 1275bd8deadSopenharmony_ci the result of an occlusion query. Conditional rendering is started and 1285bd8deadSopenharmony_ci stopped using the commands 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci void BeginConditionalRenderNV(uint id, enum mode); 1315bd8deadSopenharmony_ci void EndConditionalRenderNV(void); 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci <id> specifies the name of an occlusion query object whose results are 1345bd8deadSopenharmony_ci used to determine if the rendering commands are discarded. If the result 1355bd8deadSopenharmony_ci (SAMPLES_PASSED) of the query is zero, or if the result 1365bd8deadSopenharmony_ci (ANY_SAMPLES_PASSED or ANY_SAMPLES_PASSED_CONSERVATIVE) is false, all 1375bd8deadSopenharmony_ci rendering commands between BeginConditionalRenderNV and the corresponding 1385bd8deadSopenharmony_ci EndConditionalRenderNV are discarded. In this case, Begin, End, all 1395bd8deadSopenharmony_ci vertex array commands performing an implicit Begin and End, DrawPixels 1405bd8deadSopenharmony_ci (section 3.6), Bitmap (section 3.7), Clear (section 4.2.3), Accum 1415bd8deadSopenharmony_ci (section 4.2.4), CopyPixels (section 4.3.3), EvalMesh1 and EvalMesh2 1425bd8deadSopenharmony_ci (section 5.1), BlitFramebuffer, ClearBuffer*, and DispatchCompute* have 1435bd8deadSopenharmony_ci no effect. 1445bd8deadSopenharmony_ci 1455bd8deadSopenharmony_ci The effect of commands setting current vertex state (e.g., Color or 1465bd8deadSopenharmony_ci VertexAttrib) is undefined. If the result (SAMPLES_PASSED) of the 1475bd8deadSopenharmony_ci query is non-zero, or if the result (ANY_SAMPLES_PASSED or 1485bd8deadSopenharmony_ci ANY_SAMPLES_PASSED_CONSERVATIVE) is true, such commands are not discarded. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci <mode> specifies how BeginConditionalRenderNV interprets the results of 1515bd8deadSopenharmony_ci the occlusion query given by <id>. If <mode> is QUERY_WAIT_NV, the GL 1525bd8deadSopenharmony_ci waits for the results of the query to be available and then uses the 1535bd8deadSopenharmony_ci results to determine if subsequent rendering commands are discarded. If 1545bd8deadSopenharmony_ci <mode> is QUERY_NO_WAIT_NV, the GL may choose to unconditionally execute 1555bd8deadSopenharmony_ci the subsequent rendering commands without waiting for the query to 1565bd8deadSopenharmony_ci complete. 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci If <mode> is QUERY_BY_REGION_WAIT_NV, the GL will also wait for occlusion 1595bd8deadSopenharmony_ci query results and discard rendering commands if the result of the 1605bd8deadSopenharmony_ci occlusion query is zero. If the query result is non-zero, subsequent 1615bd8deadSopenharmony_ci rendering commands are executed, but the GL may discard the results of the 1625bd8deadSopenharmony_ci commands for any region of the framebuffer that did not contribute to the 1635bd8deadSopenharmony_ci sample count in the specified occlusion query. Any such discarding is 1645bd8deadSopenharmony_ci done in an implementation-dependent manner, but the rendering command 1655bd8deadSopenharmony_ci results may not be discarded for any samples that contributed to the 1665bd8deadSopenharmony_ci occlusion query sample count. If <mode> is QUERY_BY_REGION_NO_WAIT_NV, 1675bd8deadSopenharmony_ci the GL operates as in QUERY_BY_REGION_WAIT_NV, but may choose to 1685bd8deadSopenharmony_ci unconditionally execute the subsequent rendering commands without waiting 1695bd8deadSopenharmony_ci for the query to complete. 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci If BeginConditionalRenderNV is called while conditional rendering is in 1725bd8deadSopenharmony_ci progress, or if EndConditionalRenderNV is called while conditional 1735bd8deadSopenharmony_ci rendering is not in progress, the error INVALID_OPERATION is generated. 1745bd8deadSopenharmony_ci The error INVALID_VALUE is generated if <id> is not the name of an 1755bd8deadSopenharmony_ci existing query object query. The error INVALID_OPERATION is generated if 1765bd8deadSopenharmony_ci <id> is the name of a query object with a target other than 1775bd8deadSopenharmony_ci SAMPLES_PASSED, ANY_SAMPLES_PASSED, or ANY_SAMPLES_PASSED_CONSERVATIVE, or 1785bd8deadSopenharmony_ci if <id> is the name of a query currently in progress. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 2.0 Specification (Rasterization) 1825bd8deadSopenharmony_ci 1835bd8deadSopenharmony_ci None. 1845bd8deadSopenharmony_ci 1855bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 2.0 Specification (Per-Fragment 1865bd8deadSopenharmony_ciOperations and the Frame Buffer) 1875bd8deadSopenharmony_ci 1885bd8deadSopenharmony_ci None. 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 2.0 Specification (Special Functions) 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci None. 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 2.0 Specification (State and State 1955bd8deadSopenharmony_ciRequests) 1965bd8deadSopenharmony_ci 1975bd8deadSopenharmony_ci None. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ciAdditions to Appendix A of the OpenGL 2.0 Specification (Invariance) 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci None. 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 2045bd8deadSopenharmony_ci 2055bd8deadSopenharmony_ci None. 2065bd8deadSopenharmony_ci 2075bd8deadSopenharmony_ciGLX Protocol 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci The following rendering commands are sent to the server as part of 2105bd8deadSopenharmony_ci glXRender requests: 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci BeginConditionalRenderNV 2135bd8deadSopenharmony_ci 2 12 rendering command length 2145bd8deadSopenharmony_ci 2 348 rendering command opcode 2155bd8deadSopenharmony_ci 4 CARD32 id 2165bd8deadSopenharmony_ci 4 ENUM mode 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ci EndConditionalRenderNV 2195bd8deadSopenharmony_ci 2 4 rendering command length 2205bd8deadSopenharmony_ci 2 349 rendering command opcode 2215bd8deadSopenharmony_ci 2225bd8deadSopenharmony_ciDependencies on NVX_conditional_render 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci NVX_conditional_render was an early version of this extension. This 2255bd8deadSopenharmony_ci extension provides several conditional rendering modes (QUERY_WAIT_NV, 2265bd8deadSopenharmony_ci QUERY_NO_WAIT_NV, QUERY_BY_REGION_WAIT_NV, QUERY_BY_REGION_NO_WAIT_NV) not 2275bd8deadSopenharmony_ci present in the NVX extension. The NVX extension's commands: 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci glBeginConditionalRenderNVX(id); 2305bd8deadSopenharmony_ci glEndConditionalRenderNVX(); 2315bd8deadSopenharmony_ci 2325bd8deadSopenharmony_ci are equivalent to the following commands from this extension: 2335bd8deadSopenharmony_ci 2345bd8deadSopenharmony_ci glBeginConditionalRenderNV(id, QUERY_WAIT_NV); 2355bd8deadSopenharmony_ci glEndConditionalRenderNV(); 2365bd8deadSopenharmony_ci 2375bd8deadSopenharmony_ciDependencies on ARB_occlusion_query2 and OpenGL 3.3 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci If ARB_occlusion_query2 or OpenGL 3.3 is not supported in an OpenGL 2405bd8deadSopenharmony_ci implementation, ignore references to the ANY_SAMPLES_PASSED query type. 2415bd8deadSopenharmony_ci 2425bd8deadSopenharmony_ciDependencies on ARB_ES3_compatibility and OpenGL 4.3 2435bd8deadSopenharmony_ci 2445bd8deadSopenharmony_ci If ARB_ES3_compatibility or OpenGL 4.3 is not supported in an OpenGL 2455bd8deadSopenharmony_ci implementation, ignore references to the ANY_SAMPLES_PASSED_CONSERVATIVE 2465bd8deadSopenharmony_ci query type. 2475bd8deadSopenharmony_ci 2485bd8deadSopenharmony_ciDependencies on the OpenGL compatibility profile 2495bd8deadSopenharmony_ci 2505bd8deadSopenharmony_ci In contexts which support the core profile only (for GL) or OpenGL ES, 2515bd8deadSopenharmony_ci ignore references to the following commands: Begin, End, DrawPixels, 2525bd8deadSopenharmony_ci Bitmap, Accum, Color, CopyPixels, EvalMesh1 and EvalMesh2. 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ciDependencies on OpenGL 3.0 and OpenGL ES 3.0 2555bd8deadSopenharmony_ci 2565bd8deadSopenharmony_ci If OpenGL 3.0 or OpenGL ES 3.0 is not supported, ignore references to 2575bd8deadSopenharmony_ci the BlitFramebuffer and ClearBuffer* commands, unless provided by 2585bd8deadSopenharmony_ci other extensions. 2595bd8deadSopenharmony_ci 2605bd8deadSopenharmony_ciDependencies on OpenGL 4.3 and OpenGL ES 3.1 2615bd8deadSopenharmony_ci 2625bd8deadSopenharmony_ci If OpenGL 4.3 or OpenGL ES 3.1 is not supported, ignore references to 2635bd8deadSopenharmony_ci DispatchCompute* commands. 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ciDependencies on EXT_occlusion_query_boolean and OpenGL ES 3.0 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci In an OpenGL ES implementation, if OpenGL ES 3.0 is not supported 2685bd8deadSopenharmony_ci replace references to query functionality in OpenGL ES 3.0 with 2695bd8deadSopenharmony_ci the query functionality provided by EXT_occlusion_query_boolean. 2705bd8deadSopenharmony_ci 2715bd8deadSopenharmony_ciDependencies on NV_occlusion_query_samples 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci If NV_occlusion_query_samples is not supported in an OpenGL ES 2745bd8deadSopenharmony_ci implementation, ignore all references to SAMPLES_PASSED. 2755bd8deadSopenharmony_ci 2765bd8deadSopenharmony_ci If NV_occlusion_query_samples is supported, replaces references to 2775bd8deadSopenharmony_ci SAMPLES_PASSED with SAMPLES_PASSED_NV. 2785bd8deadSopenharmony_ci 2795bd8deadSopenharmony_ciErrors 2805bd8deadSopenharmony_ci 2815bd8deadSopenharmony_ci INVALID_OPERATION is generated by BeginConditionalRenderNV if a previous 2825bd8deadSopenharmony_ci BeginConditionalRenderNV command has been executed without a 2835bd8deadSopenharmony_ci corresponding EndConditionalRenderNV command. 2845bd8deadSopenharmony_ci 2855bd8deadSopenharmony_ci INVALID_OPERATION is generated by EndConditionalRenderNV if no 2865bd8deadSopenharmony_ci corresponding BeginConditionalRenderNV command has been executed. 2875bd8deadSopenharmony_ci 2885bd8deadSopenharmony_ci INVALID_VALUE is generated by BeginConditionalRenderNV if <id> is not the 2895bd8deadSopenharmony_ci name of an existing occlusion query object. 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci INVALID_OPERATION is generated by BeginConditionalRenderNV if <id> is the 2925bd8deadSopenharmony_ci name of a query object with a <target> other than SAMPLES_PASSED, 2935bd8deadSopenharmony_ci ANY_SAMPLES_PASSED, or ANY_SAMPLES_PASSED_CONSERVATIVE. 2945bd8deadSopenharmony_ci 2955bd8deadSopenharmony_ci INVALID_OPERATION is generated by BeginConditionalRenderNV if the query 2965bd8deadSopenharmony_ci identified by <id> is still in progress. 2975bd8deadSopenharmony_ci 2985bd8deadSopenharmony_ciIssues 2995bd8deadSopenharmony_ci 3005bd8deadSopenharmony_ci (1) How should rendering commands other than "normal" Begin/End-style 3015bd8deadSopenharmony_ci geometry be affected by conditional rendering? 3025bd8deadSopenharmony_ci 3035bd8deadSopenharmony_ci RESOLVED: All rendering commands (DrawPixels, Bitmap, Clear, Accum, 3045bd8deadSopenharmony_ci etc...) are performed conditionally. 3055bd8deadSopenharmony_ci 3065bd8deadSopenharmony_ci (2) What does NO_WAIT do, and why would anyone care? 3075bd8deadSopenharmony_ci 3085bd8deadSopenharmony_ci RESOLVED: Hardware OpenGL implementations are heavily pipelined. After 3095bd8deadSopenharmony_ci vertices are transformed, they are assembled into primitives and 3105bd8deadSopenharmony_ci rasterized. While a GPU is rasterizing a primitive, it may be 3115bd8deadSopenharmony_ci simultaneously transforming the vertices of the next primitive provided 3125bd8deadSopenharmony_ci to the GL. At the same time, the CPU may be preparing hardware commands 3135bd8deadSopenharmony_ci to process primitives following that one. 3145bd8deadSopenharmony_ci 3155bd8deadSopenharmony_ci Conditional rendering uses the results of rasterizing one primitive (an 3165bd8deadSopenharmony_ci occlusion query) to determine whether it will process subsequent ones. 3175bd8deadSopenharmony_ci In a pipelined implementation, the initial set of primitives may not be 3185bd8deadSopenharmony_ci finished drawing by the time the GL needs the occlusion query results. 3195bd8deadSopenharmony_ci Waiting for the query results will leave portions of the GPU temporarily 3205bd8deadSopenharmony_ci idle. It may be preferable to avoid the idle time by proceeding with a 3215bd8deadSopenharmony_ci conservative assumption that the primitives rendered during the 3225bd8deadSopenharmony_ci occlusion query will hit at least one sample. The NO_WAIT <mode> 3235bd8deadSopenharmony_ci parameter tells the driver move ahead in that case. 3245bd8deadSopenharmony_ci 3255bd8deadSopenharmony_ci For best performance, applications should attempt to insert some amount 3265bd8deadSopenharmony_ci of non-dependent rendering between an occlusion query and the 3275bd8deadSopenharmony_ci conditionally-rendered primitives that depend on the query result. 3285bd8deadSopenharmony_ci 3295bd8deadSopenharmony_ci (3) What does BY_REGION do, and why should anyone care? 3305bd8deadSopenharmony_ci 3315bd8deadSopenharmony_ci RESOLVED: Conditional rendering may be used for a variety of effects. 3325bd8deadSopenharmony_ci Some of these use conditional rendering only for performance. One 3335bd8deadSopenharmony_ci common use would be to draw a bounding box for a primitive 3345bd8deadSopenharmony_ci unconditionally with an occlusion query active, and then conditionally 3355bd8deadSopenharmony_ci execute a DrawElements call to draw the full (complex) primitive. If 3365bd8deadSopenharmony_ci the bounding box is not visible, any work needed to process the full 3375bd8deadSopenharmony_ci primitive can be skipped in the conditional rendering pass. 3385bd8deadSopenharmony_ci 3395bd8deadSopenharmony_ci In a split-screen SLI implementation, one GPU might draw the top half of 3405bd8deadSopenharmony_ci the scene while a second might draw the bottom half. The results of the 3415bd8deadSopenharmony_ci occlusion query would normally be obtained by combining individual 3425bd8deadSopenharmony_ci occlusion query results from each half of the screen. However, it is 3435bd8deadSopenharmony_ci not necessary to do this for the bounding box algorithm. We could skip 3445bd8deadSopenharmony_ci this synchronization point, and each region could instead use only its 3455bd8deadSopenharmony_ci local occlusion query results. If the bounding box hits only the bottom 3465bd8deadSopenharmony_ci half of the screen, the complex primitive need not be drawn on the top 3475bd8deadSopenharmony_ci half, because that portion is known not to be visible. The bottom half 3485bd8deadSopenharmony_ci would still be drawn, but the GPU used for the top half could skip it 3495bd8deadSopenharmony_ci and start drawing the next primitive specified. The 3505bd8deadSopenharmony_ci QUERY_BY_REGION_*_NV modes would be useful in that case. 3515bd8deadSopenharmony_ci 3525bd8deadSopenharmony_ci However, some algorithms may require conditional rendering for 3535bd8deadSopenharmony_ci correctness. For example, an application may want to render a 3545bd8deadSopenharmony_ci post-processing effect that should be drawn if and only if a point is 3555bd8deadSopenharmony_ci visible in the scene. Drawing only half of such an effect due to 3565bd8deadSopenharmony_ci BY_REGION tests would not be desirable. 3575bd8deadSopenharmony_ci 3585bd8deadSopenharmony_ci For QUERY_BY_REGION_NO_WAIT_NV, we expect that GL implementations using 3595bd8deadSopenharmony_ci region-based rendering will discard rendering commands in any region 3605bd8deadSopenharmony_ci where query results are available and the region's sample count is zero. 3615bd8deadSopenharmony_ci Rendering would proceed normally in all other regions. The spec 3625bd8deadSopenharmony_ci language doesn't require such behavior, however. 3635bd8deadSopenharmony_ci 3645bd8deadSopenharmony_ci (4) Should the <mode> parameter passed to BeginConditionalRenderNV be 3655bd8deadSopenharmony_ci specified as a hint instead? 3665bd8deadSopenharmony_ci 3675bd8deadSopenharmony_ci RESOLVED: The "wait" or "don't wait" portion of the <mode> parameter 3685bd8deadSopenharmony_ci could be a hint. But it doesn't fit nicely with the FASTEST or NICEST 3695bd8deadSopenharmony_ci values that are normally passed to Hint. Providing this functionality 3705bd8deadSopenharmony_ci via a <mode> parameter to BeginConditionalRenderNV seems to make the 3715bd8deadSopenharmony_ci most sense. Note that the <mode> parameter is specified such that 3725bd8deadSopenharmony_ci QUERY_NO_WAIT_NV can be implemented as though QUERY_WAIT_NV were 3735bd8deadSopenharmony_ci specified, which makes the "NO_WAIT" part of the mode a hint. 3745bd8deadSopenharmony_ci 3755bd8deadSopenharmony_ci The "BY_REGION" part is also effectively a hint. These modes may be 3765bd8deadSopenharmony_ci implemented as though the equivalent non-BY_REGION mode were provided. 3775bd8deadSopenharmony_ci Many OpenGL implementations will do all of their processing in a single 3785bd8deadSopenharmony_ci region. 3795bd8deadSopenharmony_ci 3805bd8deadSopenharmony_ci (5) What happens if BeginQuery is called while the specified occlusion 3815bd8deadSopenharmony_ci query is begin used for conditional rendering? 3825bd8deadSopenharmony_ci 3835bd8deadSopenharmony_ci RESOLVED: An INVALID_OPERATION error is generated. 3845bd8deadSopenharmony_ci 3855bd8deadSopenharmony_ci (6) Should conditional rendering work with any type of query other than 3865bd8deadSopenharmony_ci SAMPLES_PASSED (occlusion)? 3875bd8deadSopenharmony_ci 3885bd8deadSopenharmony_ci RESOLVED: Not in this extension. The spec currently requires that <id> 3895bd8deadSopenharmony_ci be the name of an occlusion query. There might be other query types 3905bd8deadSopenharmony_ci where such an operation would make sense, but there aren't any in the 3915bd8deadSopenharmony_ci current OpenGL spec. 3925bd8deadSopenharmony_ci 3935bd8deadSopenharmony_ci (7) What is the effect on current state for immediate mode attribute calls 3945bd8deadSopenharmony_ci (e.g., Color, VertexAttrib) made during conditional rendering if the 3955bd8deadSopenharmony_ci corresponding occlusion query failed? 3965bd8deadSopenharmony_ci 3975bd8deadSopenharmony_ci RESOLVED: The effect of these calls is undefined. If subsequent 3985bd8deadSopenharmony_ci primitives depend on a vertex attribute set inside a conditional 3995bd8deadSopenharmony_ci rendering block, and application should re-send the values after 4005bd8deadSopenharmony_ci EndConditionalRenderNV. 4015bd8deadSopenharmony_ci 4025bd8deadSopenharmony_ci (8) Should we provide any new query object types for conditional 4035bd8deadSopenharmony_ci rendering? 4045bd8deadSopenharmony_ci 4055bd8deadSopenharmony_ci RESOLVED: No. It may be useful to some GL implementations to provide 4065bd8deadSopenharmony_ci an occlusion query type that only returns "zero" or "non-zero", or to 4075bd8deadSopenharmony_ci provide a query type that is used only for conditional rendering but 4085bd8deadSopenharmony_ci doesn't have to maintain results that can be returned to the 4095bd8deadSopenharmony_ci application. However, performing conditional rendering using only the 4105bd8deadSopenharmony_ci occlusion query mechanisms already in core OpenGL is sufficient for 4115bd8deadSopenharmony_ci the platforms targeted by this extension. 4125bd8deadSopenharmony_ci 4135bd8deadSopenharmony_ci (9) What happens if QUERY_BY_REGION_* is used, and the application switches 4145bd8deadSopenharmony_ci between windows or FBOs between the occlusion query and conditional 4155bd8deadSopenharmony_ci rendering blocks? The "regions" used for the two operations may not be 4165bd8deadSopenharmony_ci identical. 4175bd8deadSopenharmony_ci 4185bd8deadSopenharmony_ci RESOLVED: The spec language doesn't specifically address this issue, and 4195bd8deadSopenharmony_ci implementations may choose to define regions arbitrarily in this case. 4205bd8deadSopenharmony_ci 4215bd8deadSopenharmony_ci We strongly recommend that applications using QUERY_BY_REGION_* should 4225bd8deadSopenharmony_ci not change windows or FBO configuration between the occlusion query and 4235bd8deadSopenharmony_ci the dependent rendering. 4245bd8deadSopenharmony_ci 4255bd8deadSopenharmony_ci 4265bd8deadSopenharmony_ciUsage Example 4275bd8deadSopenharmony_ci 4285bd8deadSopenharmony_ci GLuint queryID = 0x12345678; 4295bd8deadSopenharmony_ci 4305bd8deadSopenharmony_ci // Use an occlusion query while rendering the bounding box of the real 4315bd8deadSopenharmony_ci // object. 4325bd8deadSopenharmony_ci glBeginQuery(GL_SAMPLES_PASSED, queryID); 4335bd8deadSopenharmony_ci drawBoundingBox(); 4345bd8deadSopenharmony_ci glEndQuery(GL_SAMPLES_PASSED); 4355bd8deadSopenharmony_ci 4365bd8deadSopenharmony_ci // Do some unrelated rendering in hope that the query result will be 4375bd8deadSopenharmony_ci // available by the time we call glBeginConditionalRenderNV. 4385bd8deadSopenharmony_ci 4395bd8deadSopenharmony_ci // Now conditionally render the real object if any portion of its 4405bd8deadSopenharmony_ci // bounding box is visible. 4415bd8deadSopenharmony_ci glBeginConditionalRenderNV(queryID, GL_QUERY_WAIT_NV); 4425bd8deadSopenharmony_ci drawComplicatedObject(); 4435bd8deadSopenharmony_ci glEndConditionalRenderNV(); 4445bd8deadSopenharmony_ci 4455bd8deadSopenharmony_ci 4465bd8deadSopenharmony_ciRevision History 4475bd8deadSopenharmony_ci 4485bd8deadSopenharmony_ci Rev. Date Author Changes 4495bd8deadSopenharmony_ci ---- -------- -------- -------------------------------------------- 4505bd8deadSopenharmony_ci 6 05/26/14 dkoch Add interactions with later GL extensions and 4515bd8deadSopenharmony_ci core versions. 4525bd8deadSopenharmony_ci Add interactions with OpenGL ES extensions 4535bd8deadSopenharmony_ci and versions. 4545bd8deadSopenharmony_ci 4555bd8deadSopenharmony_ci 5 08/07/12 pbrown Fix minor typos; added interaction with the 4565bd8deadSopenharmony_ci older NVX_conditional_render extension. 4575bd8deadSopenharmony_ci 4585bd8deadSopenharmony_ci 4 09/22/10 srahman Added GLX protocol. 4595bd8deadSopenharmony_ci 4605bd8deadSopenharmony_ci 3 02/19/08 pbrown Document the INVALID_OPERATION error from 4615bd8deadSopenharmony_ci calling BeginQuery while the query is used 4625bd8deadSopenharmony_ci for conditional rendering in the spec body. 4635bd8deadSopenharmony_ci 4645bd8deadSopenharmony_ci 2 11/29/07 ewerness First public release 4655bd8deadSopenharmony_ci 4665bd8deadSopenharmony_ci 1 Internal revisions 467