15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_draw_vulkan_image 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_draw_vulkan_image 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Jeff Bolz, NVIDIA Corporation 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContact 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Piers Daniell, NVIDIA Corporation (pdaniell 'at' nvidia.com) 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ciStatus 185bd8deadSopenharmony_ci 195bd8deadSopenharmony_ci Complete 205bd8deadSopenharmony_ci 215bd8deadSopenharmony_ciVersion 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ci Last Modified Date: 2/22/2017 245bd8deadSopenharmony_ci NVIDIA Revision: 2 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ciNumber 275bd8deadSopenharmony_ci 285bd8deadSopenharmony_ci OpenGL Extension #501 295bd8deadSopenharmony_ci OpenGL ES Extension #274 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ciDependencies 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ci This extension is written against the OpenGL 4.5 Specification 345bd8deadSopenharmony_ci (Compatibility Profile). 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ci This extension can also be used with OpenGL ES 3.2 or later. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci This extension interacts with Vulkan 1.0 and requires the OpenGL 395bd8deadSopenharmony_ci implementation to expose an implementation of Vulkan 1.0. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciOverview 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci This extension provides a new function, DrawVkImageNV(), allowing 445bd8deadSopenharmony_ci applications to draw a screen-aligned rectangle displaying some or all of 455bd8deadSopenharmony_ci the contents of a two-dimensional Vulkan VkImage. Callers specify a 465bd8deadSopenharmony_ci Vulkan VkImage handle, an optional OpenGL sampler object, window 475bd8deadSopenharmony_ci coordinates of the rectangle to draw, and texture coordinates corresponding 485bd8deadSopenharmony_ci to the corners of the rectangle. For each fragment produced by the 495bd8deadSopenharmony_ci rectangle, DrawVkImageNV interpolates the texture coordinates, performs 505bd8deadSopenharmony_ci a texture lookup, and uses the texture result as the fragment color. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci No shaders are used by DrawVkImageNV; the results of the texture lookup 535bd8deadSopenharmony_ci are used in lieu of a fragment shader output. The fragments generated are 545bd8deadSopenharmony_ci processed by all per-fragment operations. In particular, 555bd8deadSopenharmony_ci DrawVkImageNV() fully supports blending and multisampling. 565bd8deadSopenharmony_ci 575bd8deadSopenharmony_ci In order to synchronize between Vulkan and OpenGL there are three other 585bd8deadSopenharmony_ci functions provided; WaitVkSemaphoreNV(), SignalVkSemaphoreNV() and 595bd8deadSopenharmony_ci SignalVkFenceNV(). These allow OpenGL to wait for Vulkan to complete work 605bd8deadSopenharmony_ci and also Vulkan to wait for OpenGL to complete work. Together OpenGL 615bd8deadSopenharmony_ci and Vulkan can synchronize on the server without application 625bd8deadSopenharmony_ci interation. 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci Finally the function GetVkProcAddrNV() is provided to allow the OpenGL 655bd8deadSopenharmony_ci context to query the Vulkan entry points directly and avoid having to 665bd8deadSopenharmony_ci load them through the typical Vulkan loader. 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ciNew Procedures and Functions 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci void DrawVkImageNV(GLuint64 vkImage, GLuint sampler, 715bd8deadSopenharmony_ci GLfloat x0, GLfloat y0, 725bd8deadSopenharmony_ci GLfloat x1, GLfloat y1, 735bd8deadSopenharmony_ci GLfloat z, 745bd8deadSopenharmony_ci GLfloat s0, GLfloat t0, 755bd8deadSopenharmony_ci GLfloat s1, GLfloat t1); 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci VULKANPROCNV GetVkProcAddrNV(const GLchar *name); 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ci void WaitVkSemaphoreNV (GLuint64 vkSemaphore); 805bd8deadSopenharmony_ci 815bd8deadSopenharmony_ci void SignalVkSemaphoreNV (GLuint64 vkSemaphore); 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci void SignalVkFenceNV (GLuint64 vkFence); 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ciNew Types 865bd8deadSopenharmony_ci 875bd8deadSopenharmony_ci The Vulkan base entry point type from which all Vulkan functions pointers 885bd8deadSopenharmony_ci can be cast is: 895bd8deadSopenharmony_ci 905bd8deadSopenharmony_ci typedef void (APIENTRY *VULKANPROCNV)(void); 915bd8deadSopenharmony_ci 925bd8deadSopenharmony_ci Note that this function pointer is defined as having the 935bd8deadSopenharmony_ci same calling convention as the GL functions. 945bd8deadSopenharmony_ci 955bd8deadSopenharmony_ciNew Tokens 965bd8deadSopenharmony_ci 975bd8deadSopenharmony_ci None. 985bd8deadSopenharmony_ci 995bd8deadSopenharmony_ciAdditions to Chapter 1 of the OpenGL 4.5 Specification (Introduction) 1005bd8deadSopenharmony_ci 1015bd8deadSopenharmony_ci (Insert a new section after Section 1.3.6, OpenCL p. 7) 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci 1.3.X Vulkan 1045bd8deadSopenharmony_ci 1055bd8deadSopenharmony_ci Vulkan is a royalty-free, cross-platform explicit API for full-function 1065bd8deadSopenharmony_ci 3D graphics and compute. Designed for a complete range of platforms from 1075bd8deadSopenharmony_ci low-power mobile to high-performance desktop. 1085bd8deadSopenharmony_ci 1095bd8deadSopenharmony_ci OpenGL can interoperate directly with Vulkan to take advantage of Vulkan's 1105bd8deadSopenharmony_ci explicit low-level access to the GPU for the power and performance 1115bd8deadSopenharmony_ci efficiencies it can offet. 1125bd8deadSopenharmony_ci 1135bd8deadSopenharmony_ci An OpenGL application can use the following function to query the Vulkan 1145bd8deadSopenharmony_ci function entry points from within an OpenGL context: 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci VULKANPROCNV GetVkProcAddrNV(const GLchar *name); 1175bd8deadSopenharmony_ci 1185bd8deadSopenharmony_ci <name> is the name of the Vulkan function, for example "vkCreateInstance" 1195bd8deadSopenharmony_ci and the return is a point to the Vulkan function address. This allows 1205bd8deadSopenharmony_ci OpenGL applications that need to interoperate with Vulkan to query the 1215bd8deadSopenharmony_ci entry points directly and bypass the typical Vulkan loader. The OpenGL 1225bd8deadSopenharmony_ci implementation provides access to the Vulkan implementation through this 1235bd8deadSopenharmony_ci mechanism. 1245bd8deadSopenharmony_ci 1255bd8deadSopenharmony_ci The specification and more information about Vulkan can be found at 1265bd8deadSopenharmony_ci https://www.khronos.org/vulkan/ 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci 1295bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 4.5 Specification (Event Model) 1305bd8deadSopenharmony_ci 1315bd8deadSopenharmony_ci (Insert a new section after Section 4.1.3, Sync Object Queries p. 42) 1325bd8deadSopenharmony_ci 1335bd8deadSopenharmony_ci 4.1.X Synchronization between OpenGL and Vulkan 1345bd8deadSopenharmony_ci 1355bd8deadSopenharmony_ci The command: 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ci void WaitVkSemaphoreNV (GLuint64 vkSemaphore); 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci causes the GL server to block until the Vulkan VkSemaphore <vkSemaphore> 1405bd8deadSopenharmony_ci is signalled. No GL commands after this command are executed by the server 1415bd8deadSopenharmony_ci until the semaphore is signaled. <vkSemaphore> must be a valid Vulkan 1425bd8deadSopenharmony_ci VkSemaphore non-dispatchable handle otherwise the operation is undefined. 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci The command: 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci void SignalVkSemaphoreNV (GLuint64 vkSemaphore); 1475bd8deadSopenharmony_ci 1485bd8deadSopenharmony_ci causes the GL server to signal the Vulkan VkSemaphore <vkSemaphore> when 1495bd8deadSopenharmony_ci it executes this command. The semaphore is not signalled by GL until all 1505bd8deadSopenharmony_ci commands issued before this have completed execution on the GL server. 1515bd8deadSopenharmony_ci <vkSemaphore> must be a valid Vulkan VkSemaphore non-dispatchable handle 1525bd8deadSopenharmony_ci otherwise the operation is undefined. 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci The command: 1555bd8deadSopenharmony_ci 1565bd8deadSopenharmony_ci void SignalVkFenceNV (GLuint64 vkFence); 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ci causes the GL server to signal the Vulkan VkFence <vkFence> object when 1595bd8deadSopenharmony_ci it executes this command. The fence is not signalled by the GL until all 1605bd8deadSopenharmony_ci commands issued before this have completed execution on the GL server. 1615bd8deadSopenharmony_ci <vkFence> must be a valid Vulkan VkFence non-dispatcable handle otherwise 1625bd8deadSopenharmony_ci the operation is undefined. 1635bd8deadSopenharmony_ci 1645bd8deadSopenharmony_ciAdditions to Chapter 10 of the OpenGL 4.5 Specification (Vertex Specification 1655bd8deadSopenharmony_ciand Drawing Commands) 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci Modify Section 10.9, Conditional Rendering, p. 420 1685bd8deadSopenharmony_ci 1695bd8deadSopenharmony_ci (modify first paragraph to specify that DrawVkImageNV is affected by 1705bd8deadSopenharmony_ci conditional rendering) ... is false, all rendering commands between 1715bd8deadSopenharmony_ci BeginConditionalRender and the corresponding EndConditionalRender are 1725bd8deadSopenharmony_ci discarded. In this case, Begin, End, ...and DrawVkImageNV (section 18.4.X) 1735bd8deadSopenharmony_ci have no effect. 1745bd8deadSopenharmony_ci 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ciAdditions to Chapter 14 of the OpenGL 4.5 Specification (Fixed-Function 1775bd8deadSopenharmony_ciPrimitive Assembly and Rasterization) 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci Modify Section 14.1, Discarding Primitives Before Rasterization, p. 527 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci (modify the end of the second paragraph) When enabled, RASTERIZER_DISCARD 1825bd8deadSopenharmony_ci also causes the [[compatibility profile only: Accum, Bitmap, CopyPixels, 1835bd8deadSopenharmony_ci DrawPixels,]] Clear, ClearBuffer*, and DrawVkImageNV commands to be 1845bd8deadSopenharmony_ci ignored. 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ciAdditions to Chapter 18 of the OpenGL 4.5 Specification (Drawing, Reading, 1875bd8deadSopenharmony_ciand Copying Pixels) 1885bd8deadSopenharmony_ci 1895bd8deadSopenharmony_ci (Insert new section after Section 18.4.1, Writing to the Stencil or 1905bd8deadSopenharmony_ci Depth/Stencil Buffers, p. 621) 1915bd8deadSopenharmony_ci 1925bd8deadSopenharmony_ci Section 18.4.X, Drawing Textures 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci The command: 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci void DrawVkImageNV(GLuint64 vkImage, GLuint sampler, 1975bd8deadSopenharmony_ci GLfloat x0, GLfloat y0, 1985bd8deadSopenharmony_ci GLfloat x1, GLfloat y1, 1995bd8deadSopenharmony_ci GLfloat z, 2005bd8deadSopenharmony_ci GLfloat s0, GLfloat t0, 2015bd8deadSopenharmony_ci GLfloat s1, GLfloat t1); 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci is used to draw a screen-aligned rectangle displaying a portion of the 2045bd8deadSopenharmony_ci contents of the Vulkan image <vkImage>. The four corners of this 2055bd8deadSopenharmony_ci screen-aligned rectangle have the floating-point window coordinates 2065bd8deadSopenharmony_ci (<x0>,<y0>), (<x0>,<y1>), (<x1>,<y1>), and (<x1>,<y0>). A fragment will 2075bd8deadSopenharmony_ci be generated for each pixel covered by the rectangle. Coverage along the 2085bd8deadSopenharmony_ci edges of the rectangle will be determined according to polygon 2095bd8deadSopenharmony_ci rasterization rules. If the framebuffer does not have a multisample 2105bd8deadSopenharmony_ci buffer, or if MULTISAMPLE is disabled, fragments will be generated 2115bd8deadSopenharmony_ci according to the polygon rasterization algorithm described in section 2125bd8deadSopenharmony_ci 3.6.1. Otherwise, fragments will be generated for the rectangle using the 2135bd8deadSopenharmony_ci multisample polygon rasterization algorithm described in section 3.6.6. 2145bd8deadSopenharmony_ci In either case, the set of fragments generated is not affected by other 2155bd8deadSopenharmony_ci state affecting polygon rasterization -- in particular, the CULL_FACE, 2165bd8deadSopenharmony_ci POLYGON_SMOOTH, and POLYGON_OFFSET_FILL enables and PolygonMode state have 2175bd8deadSopenharmony_ci no effect. All fragments generated for the rectangle will have a Z window 2185bd8deadSopenharmony_ci coordinate of <z>. 2195bd8deadSopenharmony_ci 2205bd8deadSopenharmony_ci The color associated with each fragment produced will be obtained by using 2215bd8deadSopenharmony_ci an interpolated source coordinate (s,t) to perform a lookup into <vkImage> 2225bd8deadSopenharmony_ci The (s,t) source coordinate for each fragment is interpolated over the 2235bd8deadSopenharmony_ci rectangle in the manner described in section 3.6.1, where the (s,t) 2245bd8deadSopenharmony_ci coordinates associated with the four corners of the rectangle are: 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci (<s0>, <t0>) for the corner at (<x0>, <y0>), 2275bd8deadSopenharmony_ci (<s1>, <t0>) for the corner at (<x1>, <y0>), 2285bd8deadSopenharmony_ci (<s1>, <t1>) for the corner at (<x1>, <y1>), and 2295bd8deadSopenharmony_ci (<s0>, <t1>) for the corner at (<x0>, <y1>). 2305bd8deadSopenharmony_ci 2315bd8deadSopenharmony_ci The interpolated texture coordinate (s,t) is used to obtain a texture 2325bd8deadSopenharmony_ci color (Rs,Gs,Bs,As) from the <vkImage> using the process described in 2335bd8deadSopenharmony_ci section 3.9. The sampler state used for the texture access will be taken 2345bd8deadSopenharmony_ci from the texture object <vkImage> if <sampler> is zero, or from the 2355bd8deadSopenharmony_ci sampler object given by <sampler> otherwise. The filtered texel <tau> is 2365bd8deadSopenharmony_ci converted to an (Rb,Gb,Bb,Ab) vector according to table 3.25 and swizzled 2375bd8deadSopenharmony_ci as described in Section 3.9.16. [[Core Profile Only: The section 2385bd8deadSopenharmony_ci referenced here is present only in the compatibility profile; this 2395bd8deadSopenharmony_ci language should be changed to reference the relevant language in the core 2405bd8deadSopenharmony_ci profile.]] 2415bd8deadSopenharmony_ci 2425bd8deadSopenharmony_ci The fragments produced by the rectangle are not processed by fragment 2435bd8deadSopenharmony_ci shaders [[Compatibility Profile: or fixed-function texture, color sum, or 2445bd8deadSopenharmony_ci fog operations]]. These fragments are processed by all of the 2455bd8deadSopenharmony_ci per-fragment operations in section 4.1. For the purposes of the scissor 2465bd8deadSopenharmony_ci test (section 4.1.2), the enable and scissor rectangle for the first 2475bd8deadSopenharmony_ci element in the array of scissor test enables and rectangles are used. 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci The error INVALID_VALUE is generated by DrawVkImageNV if <sampler> is 2505bd8deadSopenharmony_ci neither zero nor the name of a sampler object. The error 2515bd8deadSopenharmony_ci INVALID_OPERATION is generated if the image type of <vkImage> is not 2525bd8deadSopenharmony_ci VK_IMAGE_TYPE_2D. 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci 2555bd8deadSopenharmony_ciAdditions to the AGL/GLX/WGL Specifications 2565bd8deadSopenharmony_ci 2575bd8deadSopenharmony_ci None. 2585bd8deadSopenharmony_ci 2595bd8deadSopenharmony_ciGLX Protocol 2605bd8deadSopenharmony_ci 2615bd8deadSopenharmony_ci TBD 2625bd8deadSopenharmony_ci 2635bd8deadSopenharmony_ciErrors 2645bd8deadSopenharmony_ci 2655bd8deadSopenharmony_ci INVALID_VALUE is generated by DrawVkImageNV if <sampler> is neither 2665bd8deadSopenharmony_ci zero nor the name of a sampler object. 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ci INVALID_OPERATION is generated by DrawVkImageNV if the target of <vkImage> 2695bd8deadSopenharmony_ci is not VK_IMAGE_TYPE_2D. 2705bd8deadSopenharmony_ci 2715bd8deadSopenharmony_ciNew State 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci None. 2745bd8deadSopenharmony_ci 2755bd8deadSopenharmony_ci 2765bd8deadSopenharmony_ciNew Implementation Dependent State 2775bd8deadSopenharmony_ci 2785bd8deadSopenharmony_ci None. 2795bd8deadSopenharmony_ci 2805bd8deadSopenharmony_ci 2815bd8deadSopenharmony_ciIssues 2825bd8deadSopenharmony_ci 2835bd8deadSopenharmony_ci 1) Can Vulkan entry points obtained through the typical Vulkan loader 2845bd8deadSopenharmony_ci be used to interoperate with OpenGL. 2855bd8deadSopenharmony_ci 2865bd8deadSopenharmony_ci UNRESOLVED: Vulkan entry points obtained through the Vulkan loader may 2875bd8deadSopenharmony_ci introduce layers between the application and the Vulkan driver. These 2885bd8deadSopenharmony_ci layers may modify the Vulkan non-dispatchable handles returned by the 2895bd8deadSopenharmony_ci Vulkan driver. In that case, these handles will not functions correctly 2905bd8deadSopenharmony_ci when used with OpenGL interop. It is therefore advised the Vulkan layers 2915bd8deadSopenharmony_ci are bypassed when doing OpenGL interop by getting them directly from 2925bd8deadSopenharmony_ci GetVkProcAddrNV(). 2935bd8deadSopenharmony_ci 2945bd8deadSopenharmony_ciRevision History 2955bd8deadSopenharmony_ci 2965bd8deadSopenharmony_ci Rev. Date Author Changes 2975bd8deadSopenharmony_ci ---- -------- -------- ----------------------------------------- 2985bd8deadSopenharmony_ci 1 20160214 pdaniell Initial draft 2995bd8deadSopenharmony_ci 2 20170222 pdaniell Registered extension 300