[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Explicit unboxing for object identifiers



On Thu, Apr 26, 2012 at 7:03 PM, Kenneth Russell <kbr@google.com> wrote:
> On Mon, Jan 9, 2012 at 9:37 AM, Gregg Tavares (wrk) <gman@google.com> wrote:
>>
>>
>> On Sun, Jan 8, 2012 at 5:59 PM, Vladimir Vukicevic <vladimir@pobox.com>
>> wrote:
>>>
>>>
>>>
>>> On Sun, Jan 8, 2012 at 11:37 AM, Benoit Jacob <bjacob@mozilla.com> wrote:
>>>>
>>>>
>>>> In Firefox <= 10, equal uniform locations give the same
>>>> WebGLUniformLocation object, so the location1 === location2 test just works.
>>>>
>>>> We just changed this for Firefox 11 as (per a mailing list discussion)
>>>> there was agreement that this wasn't needed, and so the extra code in Gecko
>>>> needed to make that work was seen as unneeded complexity.
>>>>
>>>> What is you use case for comparing uniform locations? Why can't you
>>>> implement it on your side, maybe with a shim/wrapper around
>>>> webgl.getUniformLocation?
>>>
>>>
>>> Hrrm, does this mean that:
>>>
>>>   gl.getUniformLocation(prog, "foo") != gl.getUniformLocation(prog, "foo")
>>
>>
>> I think
>>
>>     gl.getUniformLocation(prog, "foo") == gl.getUniformLocation(prog, "foo")
>>
>> should be true but
>>
>>     gl.getUniformLocation(prog, "foo") === gl.getUniformLocation(prog,
>> "foo")
>>
>> can be false
>>
>> although honestly it's not hard to guarantee the second be true as well.
>
> Resurrecting this old thread. Meant to test this some time ago.
>
> At least in current Firefox and Chrome,
>
>    gl.getUniformLocation(prog, "foo") == gl.getUniformLocation(prog, "foo")
>
> is false.
>
> I don't know what would be required to try to make the "==" operator
> work in this case. Web IDL says nothing about equality comparisons
> between different host objects. I tried simply defining operator== on
> the C++ WebGLUniformLocation class in WebKit, but that had no effect;
> it isn't called by the JavaScript engine.
>
> If anyone wants to pursue this issue, public-script-coord@w3.org is
> probably the best forum.

For archival purposes, here are the diffs to
sdk/tests/conformance/uniforms/uniform-location.html I tested with.

-Ken


> -Ken
>
>
>
>>>
>>>
>>> ?  That seems really unexpected and very likely to cause hard to untable
>>> confusion and bugs.  Hashtable (object property) storage especially using
>>> uniform locations as keys doesn't seem that unexpected, for example to store
>>> the current value or somesuch for optimization purpose.
>>>
>>> A developer or a library can't just wrap getUniformLocation -- they'd have
>>> to track all shaders attached to 'prog', track compilation and linking,
>>> etc., because any of those could cause the return value to actually -need-
>>> to change.  It seems very tricky to get right in a wrapper, and I don't see
>>> any reason to dump this complexity on wrappers when a simple hashtable would
>>> do it on the implementation side.
>>>
>>>     - Vlad
>>>
>>>
>>
>>
Index: uniform-location.html
===================================================================
--- uniform-location.html	(revision 17628)
+++ uniform-location.html	(working copy)
@@ -34,6 +34,30 @@
 <div id="description"></div>
 <div id="console"></div>
 
+<script id="testVertex" type="x-shader/x-vertex">
+attribute vec4 a_vertex;
+attribute vec3 a_normal;
+
+uniform mediump mat4 u_modelViewMatrix;
+uniform mediump mat4 u_projMatrix;
+
+varying vec3 v_normal;
+
+void main()
+{
+    v_normal = a_normal;
+    gl_Position =  u_projMatrix * u_modelViewMatrix * a_vertex;
+}
+</script>
+<script id="testFragment" type="x-shader/x-fragment">
+varying mediump vec3 v_normal;
+
+void main()
+{
+    gl_FragColor = vec4(v_normal/2.0+vec3(0.5), 1);
+}
+</script>
+
 <script>
 description("Tests the WebGLUniformLocation API");
 
@@ -99,6 +123,30 @@
 locationSx2.foo = {};
 shouldBeFalse("locationSx.foo === locationSx2.foo");
 
+
+var testProg = loadProgram(contextA, "testVertex", "testFragment", false);
+shouldBeNonNull("testProg");
+var loc1 = contextA.getUniformLocation(testProg, "u_modelViewMatrix");
+var loc2 = contextA.getUniformLocation(testProg, "u_projMatrix");
+shouldBeFalse("loc1 === loc2");
+var loc3 = contextA.getUniformLocation(testProg, "u_modelViewMatrix");
+var loc4 = contextA.getUniformLocation(testProg, "u_projMatrix");
+shouldBeFalse("loc3 === loc4");
+shouldBeFalse("loc1 === loc3");
+shouldBeFalse("loc2 === loc4");
+shouldBeTrue("loc1 === loc1");
+shouldBeTrue("loc2 === loc2");
+shouldBeTrue("loc3 === loc3");
+shouldBeTrue("loc4 === loc4");
+shouldBeTrue("loc1 == loc1");
+shouldBeTrue("loc2 == loc2");
+shouldBeTrue("loc3 == loc3");
+shouldBeTrue("loc4 == loc4");
+shouldBeTrue("loc1 == loc3");
+shouldBeTrue("loc2 == loc4");
+
+
+
 successfullyParsed = true;
 </script>