Changeset 127452 in webkit


Ignore:
Timestamp:
Sep 4, 2012 2:37:41 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Web Inspector: [WebGL] Save gl.getError() status before taking a WebGL state snapshot and restore it afterwards
https://bugs.webkit.org/show_bug.cgi?id=95443

Patch by Andrey Adaikin <aandrey@chromium.org> on 2012-09-04
Reviewed by Vsevolod Vlasov.

Source/WebCore:

Save gl.getError() status before taking the GL snapshot and restore it afterwards.

  • inspector/InjectedScriptWebGLModuleSource.js:

(.):

LayoutTests:

Adds a test to check that we properly save the WebGL getError() status while doing the instrumentation.

  • inspector/profiler/webgl/webgl-profiler-get-error-expected.txt: Added.
  • inspector/profiler/webgl/webgl-profiler-get-error.html: Added.
  • inspector/profiler/webgl/webgl-profiler-test.js: Added.

(initialize_WebGLProfilerTest.InspectorTest.enableWebGLAgent):
(initialize_WebGLProfilerTest):
(createWebGLContext):

Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r127449 r127452  
     12012-09-04  Andrey Adaikin  <aandrey@chromium.org>
     2
     3        Web Inspector: [WebGL] Save gl.getError() status before taking a WebGL state snapshot and restore it afterwards
     4        https://bugs.webkit.org/show_bug.cgi?id=95443
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        Adds a test to check that we properly save the WebGL getError() status while doing the instrumentation.
     9
     10        * inspector/profiler/webgl/webgl-profiler-get-error-expected.txt: Added.
     11        * inspector/profiler/webgl/webgl-profiler-get-error.html: Added.
     12        * inspector/profiler/webgl/webgl-profiler-test.js: Added.
     13        (initialize_WebGLProfilerTest.InspectorTest.enableWebGLAgent):
     14        (initialize_WebGLProfilerTest):
     15        (createWebGLContext):
     16
    1172012-09-04  Alexander Pavlov  <apavlov@chromium.org>
    218
  • trunk/Source/WebCore/ChangeLog

    r127449 r127452  
     12012-09-04  Andrey Adaikin  <aandrey@chromium.org>
     2
     3        Web Inspector: [WebGL] Save gl.getError() status before taking a WebGL state snapshot and restore it afterwards
     4        https://bugs.webkit.org/show_bug.cgi?id=95443
     5
     6        Reviewed by Vsevolod Vlasov.
     7
     8        Save gl.getError() status before taking the GL snapshot and restore it afterwards.
     9
     10        * inspector/InjectedScriptWebGLModuleSource.js:
     11        (.):
     12
    1132012-09-04  Alexander Pavlov  <apavlov@chromium.org>
    214
  • trunk/Source/WebCore/inspector/InjectedScriptWebGLModuleSource.js

    r127426 r127452  
    340340    },
    341341
     342    /**
     343     * @param {*} result
     344     */
     345    setResult: function(result)
     346    {
     347        this._result = result;
     348    },
     349
    342350    freeze: function()
    343351    {
     
    895903        var gl = glResource.wrappedObject();
    896904        var program = this.wrappedObject();
     905
     906        var originalErrors = glResource.getAllErrors();
    897907
    898908        var uniforms = [];
     
    913923        }
    914924        data.uniforms = uniforms;
     925
     926        glResource.restoreErrors(originalErrors);
    915927    },
    916928
     
    12161228
    12171229    /**
     1230     * @return {Array.<number>}
     1231     */
     1232    getAllErrors: function()
     1233    {
     1234        var errors = [];
     1235        var gl = this.wrappedObject();
     1236        if (gl) {
     1237            while (true) {
     1238                var error = gl.getError();
     1239                if (error === gl.NO_ERROR)
     1240                    break;
     1241                this.clearError(error);
     1242                errors.push(error);
     1243            }
     1244        }
     1245        if (this._customErrors) {
     1246            for (var key in this._customErrors) {
     1247                var error = Number(key);
     1248                errors.push(error);
     1249            }
     1250            delete this._customErrors;
     1251        }
     1252        return errors;
     1253    },
     1254
     1255    /**
     1256     * @param {Array.<number>} errors
     1257     */
     1258    restoreErrors: function(errors)
     1259    {
     1260        var gl = this.wrappedObject();
     1261        if (gl) {
     1262            var wasError = false;
     1263            while (gl.getError() !== gl.NO_ERROR)
     1264                wasError = true;
     1265            console.assert(!wasError, "Error(s) while capturing current WebGL state.");
     1266        }
     1267        if (!errors.length)
     1268            delete this._customErrors;
     1269        else {
     1270            this._customErrors = {};
     1271            for (var i = 0, n = errors.length; i < n; ++i)
     1272                this._customErrors[errors[i]] = true;
     1273        }
     1274    },
     1275
     1276    /**
     1277     * @param {number} error
     1278     */
     1279    clearError: function(error)
     1280    {
     1281        if (this._customErrors)
     1282            delete this._customErrors[error];
     1283    },
     1284
     1285    /**
     1286     * @return {number}
     1287     */
     1288    nextError: function()
     1289    {
     1290        if (this._customErrors) {
     1291            for (var key in this._customErrors) {
     1292                var error = Number(key);
     1293                delete this._customErrors[error];
     1294                return error;
     1295            }
     1296        }
     1297        delete this._customErrors;
     1298        var gl = this.wrappedObject();
     1299        return gl ? gl.NO_ERROR : 0;
     1300    },
     1301
     1302    /**
    12181303     * @override
    12191304     * @param {Object} data
     
    12251310        data.replayContextCallback = this._replayContextCallback;
    12261311
    1227         // FIXME: Save the getError() status and restore it after taking the GL state snapshot.
     1312        var originalErrors = this.getAllErrors();
    12281313
    12291314        // Take a full GL state snapshot.
     
    12341319        WebGLRenderingContextResource.StateParameters.forEach(function(parameter) {
    12351320            glState[parameter] = Resource.toReplayable(gl.getParameter(gl[parameter]), cache);
    1236             // FIXME: Call while(gl.getError() != gl.NO_ERROR) {...} to check if a particular parameter is supported.
    12371321        });
    12381322
     
    12671351
    12681352        data.glState = glState;
     1353
     1354        this.restoreErrors(originalErrors);
    12691355    },
    12701356
     
    15471633            this._call = new Call(this._glResource, this._functionName, this._args, this.result());
    15481634        return this._call;
     1635    },
     1636
     1637    /**
     1638     * @param {*} result
     1639     */
     1640    _overrideResult: function(result)
     1641    {
     1642        var call = this.call();
     1643        call.setResult(result);
     1644        this._result = result;
    15491645    }
    15501646}
     
    16271723        customWrapFunction("framebufferTexture2D");
    16281724        customWrapFunction("renderbufferStorage");
     1725
     1726        /** @this WebGLRenderingContextResource.WrapFunction */
     1727        wrapFunctions["getError"] = function()
     1728        {
     1729            var gl = this._originalObject;
     1730            var error = this.result();
     1731            if (error !== gl.NO_ERROR)
     1732                this._glResource.clearError(error);
     1733            else {
     1734                error = this._glResource.nextError();
     1735                if (error !== gl.NO_ERROR)
     1736                    this._overrideResult(error);
     1737            }
     1738        }
    16291739
    16301740        WebGLRenderingContextResource._wrapFunctions = wrapFunctions;
Note: See TracChangeset for help on using the changeset viewer.