Summary: | getUniform should support SAMPLER_2D or SAMPLER_CUBE | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Ben Vanik <ben.vanik> | ||||
Component: | WebGL | Assignee: | Zhenyao Mo <zmo> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | cmarrin, enne, kbr, zmo | ||||
Priority: | P2 | ||||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | All | ||||||
OS: | All | ||||||
Bug Depends on: | |||||||
Bug Blocks: | 53542 | ||||||
Attachments: |
|
Description
Ben Vanik
2011-01-10 19:22:45 PST
Here's the current workaround I'm using until this is fixed, in case anyone else needs it - just call installUniformHack after getting the gl context. function installUniformHack(gl) { var uniqueUniformId = 0; var original_getUniformLocation = gl.getUniformLocation; gl.getUniformLocation = function (program, name) { var result = original_getUniformLocation.apply(this, arguments); if (result) { if (!result.hasOwnProperty("__uniqueId")) { result.__uniqueId = String(uniqueUniformId++); } } return result; }; var original_uniform1i = gl.uniform1i; gl.uniform1i = function (loc, value) { var program = this.getParameter(this.CURRENT_PROGRAM); var lookaside = program.__uniformLookaside; if (!lookaside) { lookaside = program.__uniformLookaside = {}; } lookaside[loc.__uniqueId] = value; original_uniform1i.apply(this, arguments); }; var original_uniform1iv = gl.uniform1iv; gl.uniform1iv = function (loc, value) { var program = this.getParameter(this.CURRENT_PROGRAM); var lookaside = program.__uniformLookaside; if (!lookaside) { lookaside = program.__uniformLookaside = {}; } lookaside[loc.__uniqueId] = value[0]; original_uniform1iv.apply(this, arguments); }; var original_getUniform = gl.getUniform; gl.getUniform = function (program, loc) { var lookaside = program.__uniformLookaside; if (lookaside) { if (lookaside.hasOwnProperty(loc.__uniqueId)) { return lookaside[loc.__uniqueId]; } } return original_getUniform.apply(this, arguments); }; }; I'll incorporate Ben's patch and add some test cases. Created attachment 80779 [details]
Patch
Will update the khronos side test once this is reviewed. Comment on attachment 80779 [details]
Patch
Looks good. Thanks for cleaning this up.
Committed r77311: <http://trac.webkit.org/changeset/77311> |