1Name 2 3 NV_context_priority_realtime 4 5Name Strings 6 7 EGL_NV_context_priority_realtime 8 9Contributors 10 11 Sandeep Shinde 12 Kirill Artamonov 13 Sami Kiminki 14 Donghan Ryu 15 Daniel Koch 16 Mark Kilgard 17 18Contacts 19 20 Sandeep Shinde, NVIDIA (sashinde 'at' nvidia 'dot' com) 21 22Status 23 24 Complete 25 26Version 27 28 Version 4 - November 21, 2017 29 30Number 31 32 EGL Extension #124 33 34Dependencies 35 36 Requires EGL 1.0. 37 38 Requires EGL_IMG_context_priority 39 40 This extension is written against the wording of the EGL 1.5 41 Specification - August 27, 2014 (but may be implemented against earlier 42 versions). 43 44Overview 45 46 This extension allows an EGLContext to be created with one extra 47 priority level in addition to three priority levels that are part of 48 EGL_IMG_context_priority extension. 49 50 This new level has extra privileges that are not available to other three 51 levels. Some of the privileges may include: 52 - Allow realtime priority to only few contexts 53 - Allow realtime priority only to trusted applications 54 - Make sure realtime priority contexts are executed immediately 55 - Preempt any current context running on GPU on submission of 56 commands for realtime context 57 58 The mechanism for determining which EGL context is allowed to use this 59 priority level is platform dependent. 60 61New Types 62 63 None 64 65New Procedures and Functions 66 67 None 68 69New Tokens 70 71 New attribute value accepted for the EGL_CONTEXT_PRIORITY_LEVEL_IMG 72 attribute in the <attrib_list> argument of eglCreateContext: 73 74 EGL_CONTEXT_PRIORITY_REALTIME_NV 0x3357 75 76Additions to Chapter 3 of the EGL 1.5 Specification (EGL Functions and Errors) 77 78 Add a NEW section "3.7.1.7 Context Priority" to specify the context 79 priority attribute for EGL_IMG_context_priority and values: 80 81 "3.7.1.7 Context Priority 82 83 The attribute EGL_CONTEXT_PRIORITY_LEVEL_IMG specifies a context 84 priority hint for a context supporting context priority. This 85 attribute's value may be one of EGL_CONTEXT_PRIORITY_HIGH_IMG, 86 EGL_CONTEXT_PRIORITY_MEDIUM_IMG, EGL_CONTEXT_PRIORITY_LOW_IMG, 87 or EGL_CONTEXT_PRIORITY_REALTIME_NV. The default value for 88 EGL_CONTEXT_PRIORITY_LEVEL_IMG is EGL_CONTEXT_PRIORITY_MEDIUM_IMG. 89 90 This attribute is a hint, as an implementation may not support 91 multiple contexts at some priority levels and system policy may limit 92 access to high priority contexts to appropriate system privilege 93 level. 94 95 The value EGL_CONTEXT_PRIORITY_REALTIME_NV requests the created 96 context run at the highest possible priority and be capable of 97 preempting the current executing context when commands are flushed 98 by such a realtime context. 99 100 This attribute is supported only for OpenGL and OpenGL ES contexts." 101 102 Within section 3.7.4 "Context Queries" amend the eglQueryContext 103 discussion as follows: 104 105 Change the sentence describing the attribute parameter to include 106 EGL_CONTEXT_PRIORITY_LEVEL_IMG so it reads: 107 108 "attribute must be set to EGL_CONFIG_ID, EGL_CONTEXT_CLIENT_TYPE, 109 EGL_CONTEXT_CLIENT_VERSION, EGL_RENDER_BUFFER, or 110 EGL_CONTEXT_PRIORITY_LEVEL_IMG." 111 112 After the discussion of "Querying EGL_RENDER_BUFFER", add: 113 114 "Querying EGL_CONTEXT_PRIORITY_LEVEL_IMG returns the priority this 115 context was actually created with. Note: this may not be the same 116 as specified at context creation time, due to implementation limits 117 on the number of contexts that can be created at a specific priority 118 level in the system." 119 120Issues 121 122 1) The EGL_IMG_context_priority extension is written to amend the EGL 123 1.4 specification. Should this extension amend EGL 1.5 or 1.4? 124 125 RESOLVED: EGL 1.5 because it is newer and better organized to 126 extend context attributes. 127 128 EGL 1.5 rewrites 3.7.1 "Creating Rendering Contexts" to have subsections 129 for different context attributes. This extension adds a new such section 130 that includes the EGL_IMG_context_priority attribute and values too. 131 132 2) Is context priority hint supported for both OpenGL and OpenGL ES contexts? 133 134 RESOLVED: Yes. 135 136 3) What is the intended application of the realtime priority level? 137 138 RESOLVED: One anticipated application is the system compositor 139 for a Head Mounted Display (HMD) requires realtime recomposition 140 for time-warping. 141 142 4) What action causes a context with realtime priority to preempt 143 other contexts? 144 145 RESOLVED: Preemption by a context with realtime priority should 146 occur when there are pending rendering commands and an implicit or 147 explicit flush (i.e. glFlush or glFinish) occurs. 148 149 5) What does "trusted" or "appropriate system privilege level" 150 mean in practice for a Linux-based operating system such as Android? 151 152 RESOLVED: Trusted means an application that has higher privileges 153 than other apps such as having CAP_SYS_NICE capability. On Android 154 such applications have to be registered in advance with the OS; 155 unpriviledged third party app cannot acquire this capability. 156 157 This restriction exists so arbitrary applications do not starve or 158 otherwise compromise the interactivity of the system overall. 159 160 6) In practice how many realtime priority contexts can exist in a system to 161 get best performance? 162 163 RESOLVED: Only one realtime priority context should be active at a given 164 moment to get best performance. 165 166 7) Can a context created with a realtime priority hint that is 167 in fact given a realtime priority, subsequently find that realtime 168 priority revoked and, if revoked, can it be restored? 169 170 RESOLVED: No, once a context is created with specific priority level, the 171 priority will not change for lifetime of the context. This means there will 172 not be revoking or restoring of realtime priority to already created context. 173 174 8) The attrib_list for eglCreateContext could list the attribute 175 EGL_CONTEXT_PRIORITY_LEVEL_IMG multiple times with different valid values. 176 What happens in this case? 177 178 RESOLVED: Behavior is undefined in this case. 179 180 NVIDIA's EGL implementation handles such case by using the last (valid) attribute 181 value listed in the attrib_list array as the effective attribute value for 182 creating the context. 183 184 The EGL specification is unfortunately silent on this issue. 185 186 187Revision History 188 Version 1, 2016/11/23 (Sandeep Shinde) 189 - Initial version 190 Version 2, 2017/10/13 (Mark Kilgard) 191 - Complete and convert to NV extension 192 Version 3, 2017/10/31 (Sandeep Shinde) 193 - Few minor corrections. Issue 6 resolved. 194 Version 4, 2017/11/21 (Sandeep Shinde) 195 - Update enum value and add extension number 196