| 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | <rejected href="rejected/WEBGL_subscribe_uniform/"> |
| 3 | <name>WEBGL_subscribe_uniform</name> |
| 4 | |
| 5 | <contact> <a href="https://www.khronos.org/webgl/public-mailing-list/">WebGL |
| 6 | working group</a> (public_webgl 'at' khronos.org) </contact> |
| 7 | |
| 8 | <contributors> |
| 9 | <contributor>Owen Glofcheski, Google</contributor> |
| 10 | <contributor>Members of the WebGL working group</contributor> |
| 11 | </contributors> |
| 12 | |
| 13 | <number>NN</number> |
| 14 | |
| 15 | <depends> |
| 16 | <api version="1.0"/> |
| 17 | </depends> |
| 18 | |
| 19 | |
| 20 | <overview id="overview"> |
| 21 | <p> This extension exposes the ability to subscribe to a set of uniform targets |
| 22 | which can be used to populate uniforms within shader programs. This extension |
| 23 | is generic, but currently only supports mouse position as a subscription target. |
| 24 | </p><p>Background: |
| 25 | </p><p>The depth of the web pipeline makes it difficult to support low latency |
| 26 | interaction as event information retrieved via javascript |
| 27 | is outdated by the time it's displayed to clients. By populating event |
| 28 | information later in the pipeline one can reduce perceived input latency. |
| 29 | </p><p>This extension creates a new buffer type <code>'Valuebuffer'</code> to |
| 30 | maintain the active state for predefined subscription targets. Since a |
| 31 | mechanism for buffering uniform information isn't available pre 2.0 (UBOs) |
| 32 | an additional data type was needed. See 'New Types' for additional |
| 33 | information.</p> |
| 34 | <p> When this extension is enabled: </p> |
| 35 | <ul> |
| 36 | <li>This extension provides a mechanism to store mouse positional information |
| 37 | in buffers and defer modification of uniform variables which use mouse |
| 38 | positional information until the WebGL commands are executed. |
| 39 | </li> |
| 40 | <li>This extension provides a mechanism to explicitly update mouse |
| 41 | positional information to maintain per frame consistency. |
| 42 | </li> |
| 43 | </ul> |
| 44 | </overview> |
| 45 | |
| 46 | <idl xml:space="preserve"> |
| 47 | [NoInterfaceObject] |
| 48 | interface WEBGL_subscribe_uniform { |
| 49 | const GLenum SUBSCRIBED_VALUES_BUFFER = 0x924B; |
| 50 | |
| 51 | // subscription targets |
| 52 | const GLenum MOUSE_POSITION = 0x924C; |
| 53 | |
| 54 | WebGLValuebuffer? createValuebuffer(); |
| 55 | void deleteValuebuffer(WebGLValuebuffer? buffer); |
| 56 | void isValuebuffer(WebGLValuebuffer? buffer); |
| 57 | void bindValuebuffer(GLenum target, WebGLValuebuffer? buffer); |
| 58 | |
| 59 | void subscribeValue(GLenum traget, GLenum subscription); |
| 60 | void populateSubscribedValues(GLenum target); |
| 61 | void uniformValuebuffer(WebGLUniformLocation? location, GLenum target, GLenum subscription); |
| 62 | }; // interface WEBGL_subscribe_uniform |
| 63 | </idl> |
| 64 | |
| 65 | <newfun> |
| 66 | <function name="createValuebuffer" type="WebGLValuebuffer"> |
| 67 | Creates and returns a <code>Valuebuffer</code> object.</function> |
| 68 | |
| 69 | <function name="deleteValuebuffer" type="void"><param |
| 70 | name="buffer" type="WebGLValuebuffer"/>Deletes a <code>Valuebuffer</code> |
| 71 | object.</function> |
| 72 | |
| 73 | <function name="isValuebuffer" type="bool"><param |
| 74 | name="buffer" type="WebGLValuebuffer"/>Returns whether an object is a |
| 75 | <code>Valuebuffer</code> object.</function> |
| 76 | |
| 77 | <function name="bindValuebuffer" type="void"><param |
| 78 | name="target" type="GLenum"/><param |
| 79 | name="buffer" type="WebGLValuebuffer"/>Lets you use a named |
| 80 | <code>Valuebuffer</code> object.</function> |
| 81 | |
| 82 | <function name="subscribeValuebuffer" type="void"><param |
| 83 | name="target" type="GLenum"/><param |
| 84 | name="subscription" type="GLenum"/>Subscribes the currently bound |
| 85 | <code>Valuebuffer</code> object to a subscription target.</function> |
| 86 | |
| 87 | <function name="populateSubscribedValues" type="void"><param |
| 88 | name="target" type="GLenum"/>Populates the currently bound |
| 89 | <code>Valuebuffer</code> object with the state of the subscriptions to |
| 90 | which it is subscribed.</function> |
| 91 | |
| 92 | <function name="uniformValuebuffer" type="void"><param |
| 93 | name="location" type="WebGLUniformLocation"/><param |
| 94 | name="target" type="GLenum"/><param |
| 95 | name="subscription" type="GLenum"/>Modifies the value of a uniform variable |
| 96 | or uniform variable array using the state of the subscription target in the |
| 97 | currently bound <code>Valuebuffer</code> object.</function> |
| 98 | </newfun> |
| 99 | |
| 100 | <newtypes> |
| 101 | <interface name="WebGLValuebuffer" noobject="true"> |
| 102 | <p>This interface is used to maintain a reference to internal |
| 103 | <code>Valuebuffer</code> subscription states.</p> |
| 104 | </interface> |
| 105 | <p>A <code>Valuebuffer</code> abstracts the mapping of subscription targets to internal |
| 106 | state and acts as a single storage object for subscription information (e.g. current |
| 107 | mouse position). Clients can then use the objects data to populate uniform variables.</p> |
| 108 | <p>Post WebGL API 2.0, this abstraction could exist as a layer ontop of UBOs |
| 109 | which managers the mapping of subscription targets to internal state and the mapping |
| 110 | of subscription targets to offsets within the buffer. The UBO would be used to store the |
| 111 | active buffer state as well as the uniform location mapping. Clients would be required to |
| 112 | state all their subscription targets at once to allocate the appropriate amount of memory. |
| 113 | Aside from this small change the implementation is essentially the same, with UBOs replacing |
| 114 | <code>Valuebuffers</code> and relevant create, delete, bind methods being replaced. |
| 115 | Additionally, the inclusion of UBOs would replace the need for |
| 116 | <code>uniformValueBuffer(...)</code>.</p> |
| 117 | </newtypes> |
| 118 | |
| 119 | <newtok> |
| 120 | <function name="bindValuebuffer" type="any"><param |
| 121 | name="target" type="GLenum"/><param |
| 122 | name="buffer" type="WebGLValuebuffer"/> |
| 123 | <p><code>SUBSCRIBED_VALUES_BUFFER</code> |
| 124 | is accepted as the target parameter to bindValuebuffer</p></function> |
| 125 | |
| 126 | <function name="subscribeValuebuffer" type="void"><param |
| 127 | name="target" type="GLenum"/><param |
| 128 | name="subscription" type="GLenum"/> |
| 129 | <p><code>SUBSCRIBED_VALUES_BUFFER</code> |
| 130 | is accepted as the target parameter to subscribeValuebuffer</p> |
| 131 | <p><code>MOUSE_POSITION</code> |
| 132 | is accepted as the subscription parameter to subscribeValuebuffer</p></function> |
| 133 | |
| 134 | <function name="populateSubscribedValues" type="void"><param |
| 135 | name="target" type="GLenum"/> |
| 136 | <p><code>SUBSCRIBED_VALUES_BUFFER</code> |
| 137 | is accepted as the target parameter to populateSubscribedValues</p></function> |
| 138 | |
| 139 | <function name="uniformValuebuffer" type="void"><param |
| 140 | name="location" type="WebGLUniformLocation"/><param |
| 141 | name="target" type="GLenum"/><param |
| 142 | name="subscription" type="GLenum"/> |
| 143 | <p><code>SUBSCRIBED_VALUES_BUFFER</code> |
| 144 | is accepted as the target parameter to uniformValuebuffer</p> |
| 145 | <p><code>MOUSE_POSITION</code> |
| 146 | is accepted as the subscription parameter to uniformValuebuffer</p></function> |
| 147 | </newtok> |
| 148 | |
| 149 | <samplecode><div class="example"><pre xml:space="preserve"> |
| 150 | <script id="vshader" type="x-shader/x-vertex"> |
| 151 | uniform ivec2 uMousePosition; |
| 152 | |
| 153 | void main() |
| 154 | { |
| 155 | gl_Position = vec4(uMousePosition, 0, 1); |
| 156 | } |
| 157 | </script> |
| 158 | |
| 159 | function init(gl) { |
| 160 | shader.uMousePosition = gl.getUniformLocation(shader, "uMousePosition"); |
| 161 | ... |
| 162 | |
| 163 | var ext = gl.getExtension('WEBGL_subscribe_uniform'); |
| 164 | |
| 165 | // Create the value buffer and subscribe. |
| 166 | var valuebuffer = ext.createValuebuffer(); |
| 167 | ext.bindValuebuffer(SUBSCRIBED_VALUES_BUFFER, valuebuffer); |
| 168 | ext.subscribeValue(MOUSE_POSITION); |
| 169 | ... |
| 170 | } |
| 171 | |
| 172 | function draw(gl) { |
| 173 | // Populate buffer and populate uniform |
| 174 | ext.bindValuebuffer(SUBSCRIBED_VALUES_BUFFER, valuebuffer); |
| 175 | ext.populateSubscribedValues(SUBSCRIBED_VALUES_BUFFER); |
| 176 | ext.uniformValuebuffer(shader.uMousePosition, |
| 177 | SUBSCRIBED_VALUES_BUFFER, |
| 178 | MOUSE_POSITION); |
| 179 | |
| 180 | gl.drawElements(...); |
| 181 | } |
| 182 | </pre></div></samplecode> |
| 183 | |
| 184 | <issues/> |
| 185 | |
| 186 | <history> |
| 187 | <revision date="2014/11/13"> |
| 188 | <change>Initial revision.</change> |
| 189 | </revision> |
| 190 | |
| 191 | <revision date="2016/04/14"> |
| 192 | <change>Moved to rejected state. Does not have a champion at this point. Was difficult to |
| 193 | reason about how to use the extension, given that the on-screen rendering would be farther |
| 194 | ahead than the application's state. Seems that the best solution is to focus on reducing the |
| 195 | depth, and therefore latency, of the browser's rendering pipeline.</change> |
| 196 | </revision> |
| 197 | </history> |
| 198 | </rejected> |