Opengl 4.6 (Core Profile)
Total Page:16
File Type:pdf, Size:1020Kb
The OpenGL R Graphics System: A Specification (Version 4.6 (Core Profile) - October 22, 2019) Mark Segal Kurt Akeley Editor (version 1.1): Chris Frazier Editor (versions 1.2-4.6 ): Jon Leech Editor (version 2.0): Pat Brown Copyright c 2006-2019 The Khronos Group Inc. All Rights Reserved. This specification is protected by copyright laws and contains material proprietary to Khronos. Except as described by these terms, it or any components may not be reproduced, republished, distributed, transmitted, displayed, broadcast or otherwise exploited in any manner without the express prior written permission of Khronos. This specification has been created under the Khronos Intellectual Property Rights Policy, which is Attachment A of the Khronos Group Membership Agreement available at www.khronos.org/files/member agreement.pdf. Khronos grants a con- ditional copyright license to use and reproduce the unmodified specification for any purpose, without fee or royalty, EXCEPT no licenses to any patent, trade- mark or other intellectual property rights are granted under these terms. Parties desiring to implement the specification and make use of Khronos trademarks in relation to that implementation, and receive reciprocal patent license protection under the Khronos IP Policy must become Adopters and confirm the implementa- tion as conformant under the process defined by Khronos for this specification; see https://www.khronos.org/adopters. Khronos makes no, and expressly disclaims any, representations or warranties, ex- press or implied, regarding this specification, including, without limitation: mer- chantability, fitness for a particular purpose, non-infringement of any intellectual property, correctness, accuracy, completeness, timeliness, and reliability. Under no circumstances will Khronos, or any of its Promoters, Contributors or Members, or their respective partners, officers, directors, employees, agents or representatives be liable for any damages, whether direct, indirect, special or consequential damages for lost revenues, lost profits, or otherwise, arising from or in connection with these materials. Vulkan and Khronos are registered trademarks, and WebGL and EGL are trade- marks of The Khronos Group Inc. ASTC is a trademark of ARM Holdings PLC; OpenCL is a trademark of Apple Inc.; and OpenGL is a registered trademark, and the OpenGL ES and OpenGL SC logos are trademarks of Hewlett Packard Enter- prise, all used under license by Khronos. All other product names, trademarks, and/or company names are used solely for identification and belong to their respec- tive owners. Contents 1 Introduction1 1.1 Formatting of the OpenGL Specification . .1 1.1.1 . .1 1.1.2 . .1 1.2 What is the OpenGL Graphics System? . .2 1.2.1 Programmer’s View of OpenGL . .2 1.2.2 Implementor’s View of OpenGL . .2 1.2.3 Our View . .3 1.2.4 Fixed-function Hardware and the Compatibility Profile . .3 1.2.5 The Deprecation Model . .3 1.3 Related APIs . .4 1.3.1 OpenGL Shading Language . .4 1.3.2 OpenGL ES . .4 1.3.3 OpenGL ES Shading Language . .5 1.3.4 SPIR-V . .5 1.3.5 WebGL . .6 1.3.6 Window System Bindings . .6 1.3.7 OpenCL . .7 1.4 Filing Bug Reports . .7 2 OpenGL Fundamentals8 2.1 Execution Model . .8 2.2 Command Syntax . 10 2.2.1 Data Conversion For State-Setting Commands . 12 2.2.2 Data Conversions For State Query Commands . 14 2.3 Command Execution . 15 2.3.1 Errors . 16 2.3.2 Graphics Reset Recovery . 19 2.3.3 Flush and Finish . 20 i CONTENTS ii 2.3.4 Numeric Representation and Computation . 21 2.3.5 Fixed-Point Data Conversions . 24 2.4 Rendering Commands . 26 2.5 Context State . 27 2.5.1 Generic Context State Queries . 27 2.6 Objects and the Object Model . 27 2.6.1 Object Management . 28 2.6.2 Buffer Objects . 29 2.6.3 Shader Objects . 29 2.6.4 Program Objects . 29 2.6.5 Program Pipeline Objects . 30 2.6.6 Texture Objects . 30 2.6.7 Sampler Objects . 30 2.6.8 Renderbuffer Objects . 31 2.6.9 Framebuffer Objects . 31 2.6.10 Vertex Array Objects . 31 2.6.11 Transform Feedback Objects . 31 2.6.12 Query Objects . 32 2.6.13 Sync Objects . 32 2.6.14 . 32 3 Dataflow Model 33 4 Event Model 36 4.1 Sync Objects and Fences . 36 4.1.1 Waiting for Sync Objects . 38 4.1.2 Signaling . 40 4.1.3 Sync Object Queries . 41 4.2 Query Objects and Asynchronous Queries . 42 4.2.1 Query Object Types and Targets . 42 4.2.2 Query Object Creation and Activation . 43 4.2.3 Query Object Queries . 47 4.3 Time Queries . 51 5 Shared Objects and Multiple Contexts 53 5.1 Object Deletion Behavior . 54 5.1.1 Side Effects of Shared Context Destruction . 54 5.1.2 Automatic Unbinding of Deleted Objects . 54 5.1.3 Deleted Object and Object Name Lifetimes . 54 5.2 Sync Objects and Multiple Contexts . 55 OpenGL 4.6 (Core Profile) - October 22, 2019 CONTENTS iii 5.3 Propagating Changes to Objects . 55 5.3.1 Determining Completion of Changes to an object . 56 5.3.2 Definitions . 57 5.3.3 Rules . 57 6 Buffer Objects 59 6.1 Creating and Binding Buffer Objects . 60 6.1.1 Binding Buffer Objects to Indexed Targets . 62 6.2 Creating and Modifying Buffer Object Data Stores . 65 6.2.1 Clearing Buffer Object Data Stores . 71 6.3 Mapping and Unmapping Buffer Data . 73 6.3.1 Unmapping Buffers . 78 6.3.2 Effects of Mapping Buffers on Other GL Commands . 79 6.4 Effects of Accessing Outside Buffer Bounds . 79 6.5 Invalidating Buffer Data . 80 6.6 Copying Between Buffers . 80 6.7 Buffer Object Queries . 81 6.7.1 Indexed Buffer Object Limits and Binding Queries . 83 6.8 Buffer Object State . 84 7 Programs and Shaders 87 7.1 Shader Objects . 88 7.2 Shader Binaries . 91 7.2.1 Shader Specialization . 93 7.3 Program Objects . 94 7.3.1 Program Interfaces . 102 7.4 Program Pipeline Objects . 121 7.4.1 Shader Interface Matching . 125 7.4.2 SPIR-V Shader Interface Matching . 128 7.4.3 Program Pipeline Object State . 129 7.5 Program Binaries . 130 7.6 Uniform Variables . 132 7.6.1 Loading Uniform Variables In The Default Uniform Block 141 7.6.2 Uniform Blocks . 144 7.6.3 Uniform Buffer Object Bindings . 149 7.7 Atomic Counter Buffers . 150 7.7.1 Atomic Counter Buffer Object Storage . 150 7.7.2 Atomic Counter Buffer Bindings . 150 7.8 Shader Buffer Variables and Shader Storage Blocks . 151 7.9 Invocation Groups . 153 OpenGL 4.6 (Core Profile) - October 22, 2019 CONTENTS iv 7.10 Subroutine Uniform Variables . 154 7.11 Samplers . 157 7.12 Images . 158 7.13 Shader Memory Access . 159 7.13.1 Shader Memory Access Ordering . 159 7.13.2 Shader Memory Access Synchronization . 161 7.14 Shader, Program, and Program Pipeline Queries . 166 7.15 Required State . 175 8 Textures and Samplers 178 8.1 Texture Objects . 179 8.2 Sampler Objects . 183 8.3 Sampler Object Queries . 188 8.4 Pixel Rectangles . 188 8.4.1 Pixel Storage Modes and Pixel Buffer Objects . 189 8.4.2 . 190 8.4.3 . 190 8.4.4 Transfer of Pixel Rectangles . 190 8.4.5 . 203 8.5 Texture Image Specification . 203 8.5.1 Required Texture Formats . 206 8.5.2 Encoding of Special Internal Formats . 207 8.5.3 Texture Image Structure . 211 8.6 Alternate Texture Image Specification Commands . 218 8.6.1 Texture Copying Feedback Loops . 225 8.7 Compressed Texture Images . 225 8.8 Multisample Textures . 233 8.9 Buffer Textures . 234 8.10 Texture Parameters . 238 8.11 Texture Queries . 242 8.11.1 Active Texture . 242 8.11.2 Texture Parameter Queries . 242 8.11.3 Texture Level Parameter Queries . 243 8.11.4 Texture Image Queries . 246 8.12 Depth Component Textures . 252 8.13 Cube Map Texture Selection . 253 8.13.1 Seamless Cube.