Changeset 250139 in webkit


Ignore:
Timestamp:
Sep 20, 2019 12:39:42 PM (5 years ago)
Author:
Truitt Savell
Message:

Unreviewed, rolling out r250114.

Broke ~16 webgpu/ tests on Mojave wk2

Reverted changeset:

"Web Inspector: Canvas: show WebGPU shader pipelines"
https://bugs.webkit.org/show_bug.cgi?id=201675
https://trac.webkit.org/changeset/250114

Location:
trunk
Files:
15 deleted
66 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r250127 r250139  
     12019-09-20  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r250114.
     4
     5        Broke ~16 webgpu/ tests on Mojave wk2
     6
     7        Reverted changeset:
     8
     9        "Web Inspector: Canvas: show WebGPU shader pipelines"
     10        https://bugs.webkit.org/show_bug.cgi?id=201675
     11        https://trac.webkit.org/changeset/250114
     12
    1132019-09-20  Rob Buis  <rbuis@igalia.com>
    214
  • trunk/LayoutTests/inspector/canvas/console-record-webgl.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/console-record-webgl2.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/recording-webgl-frameCount.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/recording-webgl-full.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/recording-webgl-memoryLimit.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec3 position;
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-frameCount.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-full.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-memoryLimit.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec4 test;
  • trunk/LayoutTests/inspector/canvas/recording-webgl2-snapshots.html

    r250114 r250139  
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    55<script src="resources/recording-utilities.js"></script>
    6 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     6<script src="resources/shaderProgram-utilities.js"></script>
    77<script id="vertex-shader" type="x-shader/x-vertex">
    88    attribute vec3 position;
  • trunk/LayoutTests/inspector/canvas/requestShaderSource-expected.txt

    r250114 r250139  
    1 Common tests for Canvas.requestShaderSource command.
     1Test compilation of shaders after being attached to a program, with and without syntax errors.
    22
    33
    4 == Running test suite: Canvas.requestShaderSource
    5 -- Running test case: Canvas.requestShaderSource.ProgramId.Invalid
     4== Running test suite: Canvas.getShaderSource
     5-- Running test case: Canvas.requestShaderSource.vertexShader
     6
     7    void main(void) {
     8        gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
     9    }
     10
     11
     12-- Running test case: Canvas.requestShaderSource.fragmentShader
     13
     14    precision mediump float;
     15
     16    void main(void) {
     17        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
     18    }
     19
     20
     21-- Running test case: Canvas.requestShaderSource.invalidProgramId
    622PASS: Should produce an error.
    723Error: Missing program for given programId
    824
     25-- Running test case: Canvas.requestShaderSource.invalidShaderType
     26PASS: Should produce an error.
     27Error: Missing shader for given shaderType
     28
  • trunk/LayoutTests/inspector/canvas/requestShaderSource.html

    r250114 r250139  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="resources/shaderProgram-utilities.js"></script>
     6<script id="vertex-shader" type="x-shader/x-vertex">
     7    void main(void) {
     8        gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
     9    }
     10</script>
     11<script id="fragment-shader" type="x-shader/x-fragment">
     12    precision mediump float;
     13
     14    void main(void) {
     15        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
     16    }
     17</script>
    518<script>
     19function load() {
     20    createProgram("webgl");
     21    linkProgram("vertex-shader", "fragment-shader");
     22
     23    runTest();
     24}
     25
    626function test() {
    7     let suite = InspectorTest.createAsyncSuite("Canvas.requestShaderSource");
     27    let suite = InspectorTest.createAsyncSuite("Canvas.getShaderSource");
    828
    929    suite.addTestCase({
    10         name: "Canvas.requestShaderSource.ProgramId.Invalid",
     30        name: "Canvas.requestShaderSource.vertexShader",
     31        description: "Tests requesting the source code of a program's vertex shader.",
     32        test(resolve, reject) {
     33            let shaderProgram = WI.canvasManager.shaderPrograms[0];
     34            if (!shaderProgram) {
     35                reject("Missing shader program")
     36                return;
     37            }
     38
     39            CanvasAgent.requestShaderSource(shaderProgram.identifier, CanvasAgent.ShaderType.Vertex)
     40            .then(({content}) => InspectorTest.log(content))
     41            .then(resolve, reject);
     42        }
     43    });
     44
     45    suite.addTestCase({
     46        name: "Canvas.requestShaderSource.fragmentShader",
     47        description: "Tests requesting the source code of a program's fragment shader.",
     48        test(resolve, reject) {
     49            let shaderProgram = WI.canvasManager.shaderPrograms[0];
     50            if (!shaderProgram) {
     51                reject("Missing shader program")
     52                return;
     53            }
     54
     55            CanvasAgent.requestShaderSource(shaderProgram.identifier, CanvasAgent.ShaderType.Fragment)
     56            .then(({content}) => InspectorTest.log(content))
     57            .then(resolve, reject);
     58        }
     59    });
     60
     61    suite.addTestCase({
     62        name: "Canvas.requestShaderSource.invalidProgramId",
    1163        description: "Invalid program identifiers should cause an error.",
    1264        test(resolve, reject) {
     
    2173    });
    2274
     75    suite.addTestCase({
     76        name: "Canvas.requestShaderSource.invalidShaderType",
     77        description: "Invalid shader types should cause an error.",
     78        test(resolve, reject) {
     79            let shaderProgram = WI.canvasManager.shaderPrograms[0];
     80            if (!shaderProgram) {
     81                reject("Missing shader program")
     82                return;
     83            }
     84
     85            const shaderType = "INVALID_SHADER_TYPE";
     86            CanvasAgent.requestShaderSource(shaderProgram.identifier, shaderType, (error) => {
     87                InspectorTest.expectThat(error, "Should produce an error.");
     88                InspectorTest.log("Error: " + error);
     89                resolve();
     90            });
     91        }
     92    });
     93
    2394    suite.runTestCasesAndFinish();
    2495}
    2596</script>
    2697</head>
    27 <body onload="runTest()">
    28 <p>Common tests for Canvas.requestShaderSource command.</p>
     98<body onload="load()">
     99    <p>Test compilation of shaders after being attached to a program, with and without syntax errors.</p>
    29100</body>
    30101</html>
  • trunk/LayoutTests/inspector/canvas/setShaderProgramDisabled.html

    r250114 r250139  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    5 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     5<script src="resources/shaderProgram-utilities.js"></script>
    66<script id="vertex-shader" type="x-shader/x-vertex">
    77    attribute vec3 position;
  • trunk/LayoutTests/inspector/canvas/setShaderProgramHighlighted.html

    r250114 r250139  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    5 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     5<script src="resources/shaderProgram-utilities.js"></script>
    66<script id="vertex-shader" type="x-shader/x-vertex">
    77    attribute vec3 position;
  • trunk/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl.html

    r250114 r250139  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    5 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     5<script src="resources/shaderProgram-utilities.js"></script>
    66<script>
    77function test() {
  • trunk/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2.html

    r250114 r250139  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
    5 <script src="resources/shaderProgram-utilities-webgl.js"></script>
     5<script src="resources/shaderProgram-utilities.js"></script>
    66<script>
    77if (window.internals)
  • trunk/LayoutTests/inspector/canvas/updateShader-expected.txt

    r250114 r250139  
    1 Common tests for Canvas.updateShader command.
     1CONSOLE MESSAGE: WebGL: ERROR: 0:1: 'INVALID' : syntax error
     2CONSOLE MESSAGE: WebGL: ERROR: 0:1: 'INVALID' : syntax error
     3Test compilation of shaders after being attached to a program, with and without syntax errors.
    24
    35
    46== Running test suite: Canvas.updateShader
    5 -- Running test case: Canvas.updateShader.ProgramId.Invalid
     7-- Running test case: Canvas.updateShader.vertexShaderValid
     8
     9    void main(void) {
     10        gl_Position = vec4(1, 2, 3, 4);
     11    }
     12
     13
     14-- Running test case: Canvas.updateShader.fragmentShaderValid
     15
     16    precision mediump float;
     17
     18    void main(void) {
     19        gl_FragColor = vec4(0.1, 0.2, 0.3, 0.4);
     20    }
     21
     22
     23-- Running test case: Canvas.updateShader.invalidProgramId
    624PASS: Should produce an error.
    725Error: Missing program for given programId
    826
     27-- Running test case: Canvas.updateShader.invalidShaderType
     28PASS: Should produce an error.
     29Error: Missing shader for given shaderType
     30
     31-- Running test case: Canvas.updateShader.invalidVertexShaderSource
     32PASS: Should produce error.
     33Error: Failed to update shader
     34
     35-- Running test case: Canvas.updateShader.invalidFragmentShaderSource
     36PASS: Should produce error.
     37Error: Failed to update shader
     38
  • trunk/LayoutTests/inspector/canvas/updateShader.html

    r250114 r250139  
    33<head>
    44<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
     5<script src="resources/shaderProgram-utilities.js"></script>
     6<script id="vertex-shader" type="x-shader/x-vertex">
     7    void main(void) {
     8        gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
     9    }
     10</script>
     11<script id="fragment-shader" type="x-shader/x-fragment">
     12    precision mediump float;
     13
     14    void main(void) {
     15        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);
     16    }
     17</script>
    518<script>
     19function load() {
     20    createProgram("webgl");
     21    linkProgram("vertex-shader", "fragment-shader");
     22
     23    runTest();
     24}
     25
    626function test() {
    727    let suite = InspectorTest.createAsyncSuite("Canvas.updateShader");
    828
     29    function validSourceTest({name, shaderType, source}) {
     30        suite.addTestCase({
     31            name,
     32            test(resolve, reject) {
     33                let shaderProgram = WI.canvasManager.shaderPrograms[0];
     34                if (!shaderProgram) {
     35                    reject("Missing shader program")
     36                    return;
     37                }
     38
     39                let programId = shaderProgram.identifier;
     40
     41                CanvasAgent.updateShader(programId, shaderType, source)
     42                .then(() => CanvasAgent.requestShaderSource(programId, shaderType))
     43                .then(({content}) => InspectorTest.log(content))
     44                .then(resolve, reject);
     45            }
     46        });
     47    }
     48
     49    validSourceTest({
     50        name: "Canvas.updateShader.vertexShaderValid",
     51        shaderType: CanvasAgent.ShaderType.Vertex,
     52        source: `
     53    void main(void) {
     54        gl_Position = vec4(1, 2, 3, 4);
     55    }
     56`,
     57    });
     58
     59    validSourceTest({
     60        name: "Canvas.updateShader.fragmentShaderValid",
     61        shaderType: CanvasAgent.ShaderType.Fragment,
     62        source: `
     63    precision mediump float;
     64
     65    void main(void) {
     66        gl_FragColor = vec4(0.1, 0.2, 0.3, 0.4);
     67    }
     68`,
     69    });
     70
    971    suite.addTestCase({
    10         name: "Canvas.updateShader.ProgramId.Invalid",
     72        name: "Canvas.updateShader.invalidProgramId",
    1173        description: "Invalid program identifiers should cause an error.",
    1274        test(resolve, reject) {
     
    2284    });
    2385
     86    suite.addTestCase({
     87        name: "Canvas.updateShader.invalidShaderType",
     88        description: "Invalid shader types should cause an error.",
     89        test(resolve, reject) {
     90            let shaderProgram = WI.canvasManager.shaderPrograms[0];
     91            if (!shaderProgram) {
     92                reject("Missing shader program")
     93                return;
     94            }
     95
     96            const shaderType = "INVALID_SHADER_TYPE";
     97            const source = "INVALID_SOURCE";
     98            CanvasAgent.updateShader(shaderProgram.identifier, shaderType, source, (error) => {
     99                InspectorTest.expectThat(error, "Should produce an error.");
     100                InspectorTest.log("Error: " + error);
     101                resolve();
     102            });
     103        }
     104    });
     105
     106    function invalidSourceTest({name, shaderType, source}) {
     107        suite.addTestCase({
     108            name,
     109            test(resolve, reject) {
     110                let shaderProgram = WI.canvasManager.shaderPrograms[0];
     111                if (!shaderProgram) {
     112                    reject("Missing shader program")
     113                    return;
     114                }
     115
     116                CanvasAgent.updateShader(shaderProgram.identifier, shaderType, source, (error) => {
     117                    InspectorTest.expectThat(error, "Should produce error.");
     118                    InspectorTest.log("Error: " + error);
     119                    resolve();
     120                });
     121            }
     122        });
     123    }
     124
     125    invalidSourceTest({
     126        name: "Canvas.updateShader.invalidVertexShaderSource",
     127        shaderType: CanvasAgent.ShaderType.Vertex,
     128        source: "INVALID",
     129    });
     130
     131    invalidSourceTest({
     132        name: "Canvas.updateShader.invalidFragmentShaderSource",
     133        shaderType: CanvasAgent.ShaderType.Fragment,
     134        source: "INVALID",
     135    });
     136
    24137    suite.runTestCasesAndFinish();
    25138}
    26139</script>
    27140</head>
    28 <body onload="runTest()">
    29 <p>Common tests for Canvas.updateShader command.</p>
     141<body onload="load()">
     142    <p>Test compilation of shaders after being attached to a program, with and without syntax errors.</p>
    30143</body>
    31144</html>
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r250114 r250139  
    11511151webkit.org/b/191005 inspector/canvas/create-context-webgpu.html [ Skip ]
    11521152webkit.org/b/191005 inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    1153 webkit.org/b/191005 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]
    11541153webkit.org/b/191005 inspector/canvas/resolveContext-webgpu.html [ Skip ]
    1155 webkit.org/b/191005 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    1156 webkit.org/b/191005 inspector/canvas/updateShader-webgpu.html [ Skip ]
    11571154
    11581155# No support for resource load statistics yet
  • trunk/LayoutTests/platform/ios/TestExpectations

    r250114 r250139  
    4646inspector/canvas/create-context-webgpu.html [ Skip ]
    4747inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    48 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]
    4948inspector/canvas/resolveContext-webgpu.html [ Skip ]
    50 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    51 inspector/canvas/updateShader-webgpu.html [ Skip ]
    5249
    5350# Encrypted Media Extensions are not enabled
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r250114 r250139  
    4848inspector/canvas/create-context-webgpu.html [ Skip ]
    4949inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    50 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]
    5150inspector/canvas/resolveContext-webgpu.html [ Skip ]
    52 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    53 inspector/canvas/updateShader-webgpu.html [ Skip ]
    5451
    5552# Media Stream API testing is not supported for WK1 yet.
  • trunk/LayoutTests/platform/mac/TestExpectations

    r250127 r250139  
    17821782webkit.org/b/199275 [ HighSierra ] inspector/canvas/create-context-webgpu.html [ Skip ]
    17831783webkit.org/b/199275 [ HighSierra ] inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    1784 webkit.org/b/199275 [ HighSierra ] inspector/canvas/requestShaderSource-webgpu.html [ Skip ]
    17851784webkit.org/b/199275 [ HighSierra ] inspector/canvas/resolveContext-webgpu.html [ Skip ]
    1786 webkit.org/b/199275 [ HighSierra ] inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    1787 webkit.org/b/199275 [ HighSierra ] inspector/canvas/updateShader-webgpu.html [ Skip ]
    17881785
    17891786webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r250114 r250139  
    20022002inspector/canvas/requestContent-webgl.html [ Skip ]
    20032003inspector/canvas/requestContent-webgl2.html [ Skip ]
    2004 inspector/canvas/requestShaderSource-webgl.html [ Skip ]
     2004inspector/canvas/requestShaderSource.html [ Skip ]
    20052005inspector/canvas/resolveContext-webgl.html [ Skip ]
    20062006inspector/canvas/resolveContext-webgl2.html [ Skip ]
    20072007inspector/canvas/shaderProgram-add-remove-webgl.html [ Skip ]
    20082008inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ]
    2009 inspector/canvas/updateShader-webgl.html [ Skip ]
    2010 
     2009inspector/canvas/updateShader.html [ Skip ]
    20112010################################################################################
    20122011#################          End WebGL Issues              #######################
     
    42484247inspector/canvas/create-context-webgpu.html [ Skip ]
    42494248inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    4250 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]
    42514249inspector/canvas/resolveContext-webgpu.html [ Skip ]
    4252 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    4253 inspector/canvas/updateShader-webgpu.html [ Skip ]
    42544250
    42554251webkit.org/b/191194 fast/block/basic/inline-content-with-floating-image.html [ Failure ]
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r250114 r250139  
    299299inspector/canvas/create-context-webgpu.html [ Skip ]
    300300inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    301 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]
    302301inspector/canvas/resolveContext-webgpu.html [ Skip ]
    303 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    304 inspector/canvas/updateShader-webgpu.html [ Skip ]
    305302
    306303# WIRELESS_PLAYBACK_TARGET is disabled
  • trunk/LayoutTests/platform/wpe/TestExpectations

    r250114 r250139  
    303303inspector/canvas/create-context-webgpu.html [ Skip ]
    304304inspector/canvas/requestClientNodes-webgpu.html [ Skip ]
    305 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]
    306305inspector/canvas/resolveContext-webgpu.html [ Skip ]
    307 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    308 inspector/canvas/updateShader-webgpu.html [ Skip ]
    309306
    310307# Skipped due to untestable DRM key system. ClearKey counterparts are tested instead.
  • trunk/Source/JavaScriptCore/ChangeLog

    r250129 r250139  
     12019-09-20  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r250114.
     4
     5        Broke ~16 webgpu/ tests on Mojave wk2
     6
     7        Reverted changeset:
     8
     9        "Web Inspector: Canvas: show WebGPU shader pipelines"
     10        https://bugs.webkit.org/show_bug.cgi?id=201675
     11        https://trac.webkit.org/changeset/250114
     12
    1132019-09-20  Paulo Matos  <pmatos@igalia.com>
    214
  • trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json

    r250114 r250139  
    2121        },
    2222        {
    23             "id": "ProgramType",
    24             "type": "string",
    25             "enum": ["compute", "render"]
    26         },
    27         {
    2823            "id": "ShaderType",
    2924            "type": "string",
    30             "enum": ["compute", "fragment", "vertex"]
     25            "enum": ["fragment", "vertex"],
     26            "description": "Shader type. WebGL supports vertex and fragment shaders."
    3127        },
    3228        {
     
    141137            ],
    142138            "returns": [
    143                 { "name": "source", "type": "string" }
     139                { "name": "content", "type": "string" }
    144140            ]
    145141        },
     
    228224            "name": "programCreated",
    229225            "parameters": [
    230                 { "name": "canvasId", "$ref": "CanvasId"} ,
    231                 { "name": "programId", "$ref": "ProgramId" },
    232                 { "name": "programType", "$ref": "ProgramType" }
     226                { "name": "canvasId", "$ref": "CanvasId", "description": "Canvas identifier." },
     227                { "name": "programId", "$ref": "ProgramId", "description": "Program identifier." }
    233228            ]
    234229        },
     
    236231            "name": "programDeleted",
    237232            "parameters": [
    238                 { "name": "programId", "$ref": "ProgramId" }
     233                { "name": "programId", "$ref": "ProgramId", "description": "Program identifier." }
    239234            ]
    240235        }
  • trunk/Source/WebCore/ChangeLog

    r250132 r250139  
     12019-09-20  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r250114.
     4
     5        Broke ~16 webgpu/ tests on Mojave wk2
     6
     7        Reverted changeset:
     8
     9        "Web Inspector: Canvas: show WebGPU shader pipelines"
     10        https://bugs.webkit.org/show_bug.cgi?id=201675
     11        https://trac.webkit.org/changeset/250114
     12
    1132019-09-20  Antti Koivisto  <antti@apple.com>
    214
  • trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp

    r250114 r250139  
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPUComputePipeline.h"
    32 #include "GPUErrorScopes.h"
    33 #include "GPUPipeline.h"
    34 #include "GPUProgrammableStageDescriptor.h"
    35 #include "WebGPUDevice.h"
    36 #include <wtf/Optional.h>
    37 #include <wtf/Ref.h>
    38 
    3931namespace WebCore {
    4032
    41 Ref<WebGPUComputePipeline> WebGPUComputePipeline::create(WebGPUDevice& device, RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes, Optional<WebGPUPipeline::ShaderData> computeShader)
     33Ref<WebGPUComputePipeline> WebGPUComputePipeline::create(RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes)
    4234{
    43     return adoptRef(*new WebGPUComputePipeline(device, WTFMove(pipeline), errorScopes, computeShader));
     35    return adoptRef(*new WebGPUComputePipeline(WTFMove(pipeline), errorScopes));
    4436}
    4537
    46 WebGPUComputePipeline::WebGPUComputePipeline(WebGPUDevice& device, RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes, Optional<WebGPUPipeline::ShaderData> computeShader)
    47     : WebGPUPipeline(device, errorScopes)
    48     , m_computePipeline(WTFMove(pipeline))
    49     , m_computeShader(computeShader)
     38WebGPUComputePipeline::WebGPUComputePipeline(RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes)
     39    : GPUObjectBase(makeRef(errorScopes))
     40    , m_computePipeline { WTFMove(pipeline) }
    5041{
    51 }
    52 
    53 WebGPUComputePipeline::~WebGPUComputePipeline() = default;
    54 
    55 bool WebGPUComputePipeline::recompile(const WebGPUDevice& device)
    56 {
    57     if (m_computePipeline && m_computeShader) {
    58         if (auto& webGPUComputeShaderModule = m_computeShader.value().module) {
    59             if (auto* gpuComputeShaderModule = webGPUComputeShaderModule->module()) {
    60                 GPUProgrammableStageDescriptor computeStage(makeRef(*gpuComputeShaderModule), { m_computeShader.value().entryPoint });
    61                 return m_computePipeline->recompile(device.device(), WTFMove(computeStage));
    62             }
    63         }
    64     }
    65     return false;
    6642}
    6743
  • trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h

    r250114 r250139  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "WebGPUPipeline.h"
    31 #include <wtf/Forward.h>
     30#include "GPUComputePipeline.h"
     31#include "GPUObjectBase.h"
     32#include <wtf/RefPtr.h>
    3233
    3334namespace WebCore {
    3435
    35 class GPUComputePipeline;
    36 class GPUPipeline;
    37 class GPUErrorScopes;
    38 class WebGPUDevice;
     36class WebGPUComputePipeline : public GPUObjectBase {
     37public:
     38    static Ref<WebGPUComputePipeline> create(RefPtr<GPUComputePipeline>&&, GPUErrorScopes&);
    3939
    40 class WebGPUComputePipeline final : public WebGPUPipeline {
    41 public:
    42     virtual ~WebGPUComputePipeline();
    43 
    44     static Ref<WebGPUComputePipeline> create(WebGPUDevice&, RefPtr<GPUComputePipeline>&&, GPUErrorScopes&, Optional<WebGPUPipeline::ShaderData> computeShader);
    45 
    46     bool isComputePipeline() const { return true; }
    47 
    48     bool isValid() const { return computePipeline(); }
    4940    const GPUComputePipeline* computePipeline() const { return m_computePipeline.get(); }
    50     Optional<WebGPUPipeline::ShaderData> computeShader() const { return m_computeShader; }
    51 
    52     bool recompile(const WebGPUDevice&);
    5341
    5442private:
    55     WebGPUComputePipeline(WebGPUDevice&, RefPtr<GPUComputePipeline>&&, GPUErrorScopes&, Optional<WebGPUPipeline::ShaderData> computeShader);
     43    WebGPUComputePipeline(RefPtr<GPUComputePipeline>&&, GPUErrorScopes&);
    5644
    5745    RefPtr<GPUComputePipeline> m_computePipeline;
    58 
    59     // Preserved for Web Inspector recompilation.
    60     Optional<WebGPUPipeline::ShaderData> m_computeShader;
    6146};
    6247
    6348} // namespace WebCore
    6449
    65 SPECIALIZE_TYPE_TRAITS_WEBGPUPIPELINE(WebCore::WebGPUComputePipeline, isComputePipeline())
    66 
    6750#endif // ENABLE(WEBGPU)
  • trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.idl

    r250114 r250139  
    2828    Conditional=WEBGPU,
    2929    EnabledAtRuntime=WebGPU,
     30    ImplementationLacksVTable,
    3031    InterfaceName=GPUComputePipeline
    3132] interface WebGPUComputePipeline {
  • trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp

    r250114 r250139  
    4040#include "GPUBufferDescriptor.h"
    4141#include "GPUCommandBuffer.h"
    42 #include "GPUComputePipeline.h"
    4342#include "GPUComputePipelineDescriptor.h"
    4443#include "GPUProgrammableStageDescriptor.h"
    45 #include "GPURenderPipeline.h"
    4644#include "GPURenderPipelineDescriptor.h"
    4745#include "GPUSampler.h"
     
    208206    // FIXME: What can be validated here?
    209207    auto module = m_device->tryCreateShaderModule(GPUShaderModuleDescriptor { descriptor.code });
    210     return WebGPUShaderModule::create(WTFMove(module), descriptor.code);
    211 }
    212 
    213 Ref<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(const WebGPURenderPipelineDescriptor& descriptor)
     208    return WebGPUShaderModule::create(WTFMove(module));
     209}
     210
     211Ref<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(const WebGPURenderPipelineDescriptor& descriptor) const
    214212{
    215213    m_errorScopes->setErrorPrefix("GPUDevice.createRenderPipeline(): ");
     
    217215    auto gpuDescriptor = descriptor.tryCreateGPURenderPipelineDescriptor(m_errorScopes);
    218216    if (!gpuDescriptor)
    219         return WebGPURenderPipeline::create(*this, nullptr, m_errorScopes, WTF::nullopt, WTF::nullopt);
    220 
    221     auto gpuPipeline = m_device->tryCreateRenderPipeline(*gpuDescriptor, m_errorScopes);
    222 
    223     WebGPUPipeline::ShaderData vertexShader = { descriptor.vertexStage.module, descriptor.vertexStage.entryPoint };
    224 
    225     Optional<WebGPUPipeline::ShaderData> fragmentShader;
    226     if (descriptor.fragmentStage)
    227         fragmentShader = { { descriptor.fragmentStage.value().module, descriptor.fragmentStage.value().entryPoint } };
    228 
    229     auto webGPUPipeline = WebGPURenderPipeline::create(*this, WTFMove(gpuPipeline), m_errorScopes, vertexShader, fragmentShader);
    230     if (webGPUPipeline->isValid())
    231         InspectorInstrumentation::didCreateWebGPUPipeline(*this, webGPUPipeline.get());
    232     return webGPUPipeline;
    233 }
    234 
    235 Ref<WebGPUComputePipeline> WebGPUDevice::createComputePipeline(const WebGPUComputePipelineDescriptor& descriptor)
     217        return WebGPURenderPipeline::create(nullptr, m_errorScopes);
     218
     219    auto pipeline = m_device->tryCreateRenderPipeline(*gpuDescriptor, m_errorScopes);
     220    return WebGPURenderPipeline::create(WTFMove(pipeline), m_errorScopes);
     221}
     222
     223Ref<WebGPUComputePipeline> WebGPUDevice::createComputePipeline(const WebGPUComputePipelineDescriptor& descriptor) const
    236224{
    237225    m_errorScopes->setErrorPrefix("GPUDevice.createComputePipeline(): ");
     
    239227    auto gpuDescriptor = descriptor.tryCreateGPUComputePipelineDescriptor(m_errorScopes);
    240228    if (!gpuDescriptor)
    241         return WebGPUComputePipeline::create(*this, nullptr, m_errorScopes, WTF::nullopt);
    242 
    243     auto gpuPipeline = m_device->tryCreateComputePipeline(*gpuDescriptor, m_errorScopes);
    244 
    245     WebGPUPipeline::ShaderData computeShader = { descriptor.computeStage.module, descriptor.computeStage.entryPoint };
    246 
    247     auto webGPUPipeline = WebGPUComputePipeline::create(*this, WTFMove(gpuPipeline), m_errorScopes, computeShader);
    248     if (webGPUPipeline->isValid())
    249         InspectorInstrumentation::didCreateWebGPUPipeline(*this, webGPUPipeline.get());
    250     return webGPUPipeline;
     229        return WebGPUComputePipeline::create(nullptr, m_errorScopes);
     230
     231    auto pipeline = m_device->tryCreateComputePipeline(*gpuDescriptor, m_errorScopes);
     232    return WebGPUComputePipeline::create(WTFMove(pipeline), m_errorScopes);
    251233}
    252234
  • trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h

    r250114 r250139  
    100100
    101101    Ref<WebGPUShaderModule> createShaderModule(const WebGPUShaderModuleDescriptor&) const;
    102     Ref<WebGPURenderPipeline> createRenderPipeline(const WebGPURenderPipelineDescriptor&);
    103     Ref<WebGPUComputePipeline> createComputePipeline(const WebGPUComputePipelineDescriptor&);
     102    Ref<WebGPURenderPipeline> createRenderPipeline(const WebGPURenderPipelineDescriptor&) const;
     103    Ref<WebGPUComputePipeline> createComputePipeline(const WebGPUComputePipelineDescriptor&) const;
    104104
    105105    Ref<WebGPUCommandEncoder> createCommandEncoder() const;
  • trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammableStageDescriptor.h

    r250114 r250139  
    3838    Optional<GPUProgrammableStageDescriptor> tryCreateGPUProgrammableStageDescriptor() const;
    3939
    40     RefPtr<WebGPUShaderModule> module;
     40    RefPtr<const WebGPUShaderModule> module;
    4141};
    4242
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp

    r250114 r250139  
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPUErrorScopes.h"
    32 #include "GPUPipeline.h"
    33 #include "GPUProgrammableStageDescriptor.h"
    34 #include "GPURenderPipeline.h"
    35 #include "WebGPUDevice.h"
    36 #include <wtf/Optional.h>
    37 #include <wtf/Ref.h>
    38 
    3931namespace WebCore {
    4032
    41 Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(WebGPUDevice& device, RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes, Optional<WebGPUPipeline::ShaderData> vertexShader, Optional<WebGPUPipeline::ShaderData> fragmentShader)
     33Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes)
    4234{
    43     return adoptRef(*new WebGPURenderPipeline(device, WTFMove(pipeline), errorScopes, vertexShader, fragmentShader));
     35    return adoptRef(*new WebGPURenderPipeline(WTFMove(pipeline), errorScopes));
    4436}
    4537
    46 WebGPURenderPipeline::WebGPURenderPipeline(WebGPUDevice& device, RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes, Optional<WebGPUPipeline::ShaderData> vertexShader, Optional<WebGPUPipeline::ShaderData> fragmentShader)
    47     : WebGPUPipeline(device, errorScopes)
     38WebGPURenderPipeline::WebGPURenderPipeline(RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes)
     39    : GPUObjectBase(makeRef(errorScopes))
    4840    , m_renderPipeline(WTFMove(pipeline))
    49     , m_vertexShader(vertexShader)
    50     , m_fragmentShader(fragmentShader)
    5141{
    52 }
    53 
    54 WebGPURenderPipeline::~WebGPURenderPipeline() = default;
    55 
    56 bool WebGPURenderPipeline::recompile(const WebGPUDevice& device)
    57 {
    58     if (m_renderPipeline && m_vertexShader) {
    59         if (auto& webGPUVertexShaderModule = m_vertexShader.value().module) {
    60             if (auto* gpuVertexShaderModule = webGPUVertexShaderModule->module()) {
    61                 GPUProgrammableStageDescriptor vertexStage(makeRef(*gpuVertexShaderModule), { m_vertexShader.value().entryPoint });
    62                 Optional<GPUProgrammableStageDescriptor> fragmentStage;
    63                 if (m_fragmentShader) {
    64                     if (auto& webGPUFragmentShaderModule = m_fragmentShader.value().module) {
    65                         if (auto* gpuFragmentShaderModule = webGPUFragmentShaderModule->module())
    66                             fragmentStage = GPUProgrammableStageDescriptor(makeRef(*gpuFragmentShaderModule), { m_fragmentShader.value().entryPoint });
    67                     }
    68                 }
    69                 return m_renderPipeline->recompile(device.device(), WTFMove(vertexStage), WTFMove(fragmentStage));
    70             }
    71         }
    72     }
    73     return false;
    7442}
    7543
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h

    r250114 r250139  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "WebGPUPipeline.h"
    31 #include <wtf/Forward.h>
     30#include "GPUObjectBase.h"
     31#include "GPURenderPipeline.h"
     32#include <wtf/RefPtr.h>
    3233
    3334namespace WebCore {
    3435
    35 class GPUPipeline;
    36 class GPURenderPipeline;
    37 class GPUErrorScopes;
    38 class WebGPUDevice;
     36class WebGPURenderPipeline : public GPUObjectBase {
     37public:
     38    static Ref<WebGPURenderPipeline> create(RefPtr<GPURenderPipeline>&&, GPUErrorScopes&);
    3939
    40 class WebGPURenderPipeline final : public WebGPUPipeline {
    41 public:
    42     virtual ~WebGPURenderPipeline();
    43 
    44     static Ref<WebGPURenderPipeline> create(WebGPUDevice&, RefPtr<GPURenderPipeline>&&, GPUErrorScopes&, Optional<WebGPUPipeline::ShaderData> vertexShader, Optional<WebGPUPipeline::ShaderData> fragmentShader);
    45 
    46     bool isRenderPipeline() const { return true; }
    47 
    48     bool isValid() const { return renderPipeline(); }
    4940    const GPURenderPipeline* renderPipeline() const { return m_renderPipeline.get(); }
    50     Optional<WebGPUPipeline::ShaderData> vertexShader() const { return m_vertexShader; }
    51     Optional<WebGPUPipeline::ShaderData> fragmentShader() const { return m_fragmentShader; }
    52 
    53     bool recompile(const WebGPUDevice&);
    5441
    5542private:
    56     WebGPURenderPipeline(WebGPUDevice&, RefPtr<GPURenderPipeline>&&, GPUErrorScopes&, Optional<WebGPUPipeline::ShaderData> vertexShader, Optional<WebGPUPipeline::ShaderData> fragmentShader);
     43    WebGPURenderPipeline(RefPtr<GPURenderPipeline>&&, GPUErrorScopes&);
    5744
    5845    RefPtr<GPURenderPipeline> m_renderPipeline;
    59 
    60     // Preserved for Web Inspector recompilation.
    61     Optional<WebGPUPipeline::ShaderData> m_vertexShader;
    62     Optional<WebGPUPipeline::ShaderData> m_fragmentShader;
    6346};
    6447
    6548} // namespace WebCore
    6649
    67 SPECIALIZE_TYPE_TRAITS_WEBGPUPIPELINE(WebCore::WebGPURenderPipeline, isRenderPipeline())
    68 
    6950#endif // ENABLE(WEBGPU)
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.idl

    r250114 r250139  
    2828    Conditional=WEBGPU,
    2929    EnabledAtRuntime=WebGPU,
     30    ImplementationLacksVTable,
    3031    InterfaceName=GPURenderPipeline
    3132] interface WebGPURenderPipeline {
  • trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.cpp

    r250114 r250139  
    2929#if ENABLE(WEBGPU)
    3030
    31 #include "GPUShaderModuleDescriptor.h"
    32 #include "WebGPUDevice.h"
    33 #include <wtf/RefPtr.h>
    34 
    3531namespace WebCore {
    3632
    37 Ref<WebGPUShaderModule> WebGPUShaderModule::create(RefPtr<GPUShaderModule>&& module, const String& source)
     33Ref<WebGPUShaderModule> WebGPUShaderModule::create(RefPtr<GPUShaderModule>&& module)
    3834{
    39     return adoptRef(*new WebGPUShaderModule(WTFMove(module), source));
     35    return adoptRef(*new WebGPUShaderModule(WTFMove(module)));
    4036}
    4137
    42 WebGPUShaderModule::WebGPUShaderModule(RefPtr<GPUShaderModule>&& module, const String& source)
     38WebGPUShaderModule::WebGPUShaderModule(RefPtr<GPUShaderModule>&& module)
    4339    : m_module(WTFMove(module))
    44     , m_source(source)
    4540{
    46 }
    47 
    48 void WebGPUShaderModule::update(const WebGPUDevice& device, const String& source)
    49 {
    50     m_source = source;
    51     m_module = GPUShaderModule::tryCreate(device.device(), { m_source });
    5241}
    5342
  • trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h

    r250114 r250139  
    2929
    3030#include "GPUShaderModule.h"
    31 #include <wtf/Forward.h>
     31
    3232#include <wtf/RefCounted.h>
     33#include <wtf/RefPtr.h>
    3334
    3435namespace WebCore {
    3536
    36 class WebGPUDevice;
    37 
    3837class WebGPUShaderModule : public RefCounted<WebGPUShaderModule> {
    3938public:
    40     static Ref<WebGPUShaderModule> create(RefPtr<GPUShaderModule>&&, const String& source);
     39    static Ref<WebGPUShaderModule> create(RefPtr<GPUShaderModule>&&);
    4140
    42     GPUShaderModule* module() const { return m_module.get(); }
    43     const String& source() const { return m_source; }
    44 
    45     void update(const WebGPUDevice&, const String& source);
     41    const GPUShaderModule* module() const { return m_module.get(); }
    4642
    4743private:
    48     WebGPUShaderModule(RefPtr<GPUShaderModule>&&, const String& source);
     44    WebGPUShaderModule(RefPtr<GPUShaderModule>&&);
    4945
    5046    RefPtr<GPUShaderModule> m_module;
    51 
    52     // Preserved for Web Inspector recompilation.
    53     String m_source;
    5447};
    5548
  • trunk/Source/WebCore/Sources.txt

    r250128 r250139  
    374374Modules/webgpu/WebGPUDeviceErrorScopes.cpp
    375375Modules/webgpu/WebGPUQueue.cpp
    376 Modules/webgpu/WebGPUPipeline.cpp
    377376Modules/webgpu/WebGPUPipelineLayout.cpp
    378377Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp
     
    19001899platform/graphics/gpu/GPUErrorScopes.cpp
    19011900platform/graphics/gpu/GPUValidationError.cpp
    1902 platform/graphics/gpu/GPUPipeline.cpp
    19031901platform/graphics/gpu/GPUPipelineLayout.cpp
    19041902platform/graphics/gpu/GPUProgrammablePassEncoder.cpp
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r250128 r250139  
    1040510405                9175CE5A21E281ED00DF2C27 /* InspectorAuditAccessibilityObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorAuditAccessibilityObject.h; sourceTree = "<group>"; };
    1040610406                9175CE5A21E281ED00DF2C28 /* JSInspectorAuditAccessibilityObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSInspectorAuditAccessibilityObject.h; sourceTree = "<group>"; };
    10407                 9186F3B32329FB0500AFF857 /* GPUPipeline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GPUPipeline.h; sourceTree = "<group>"; };
    10408                 9186F3B62329FB4E00AFF857 /* WebGPUPipeline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGPUPipeline.cpp; sourceTree = "<group>"; };
    10409                 9186F3B72329FB4F00AFF857 /* WebGPUPipeline.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGPUPipeline.h; sourceTree = "<group>"; };
    10410                 9186F3BA2329FE6800AFF857 /* GPUPipeline.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GPUPipeline.cpp; sourceTree = "<group>"; };
    1041110407                91B8F0B321953D65000C2B00 /* CertificateInfoBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CertificateInfoBase.h; sourceTree = "<group>"; };
    1041210408                91B952221F58A58000931DC2 /* RecordingSwizzleTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RecordingSwizzleTypes.h; sourceTree = "<group>"; };
     
    1838918385                                D09AFB3722D7D5C600C4538C /* GPUObjectBase.h */,
    1839018386                                D09AFB1922D6698A00C4538C /* GPUOutOfMemoryError.h */,
    18391                                 9186F3BA2329FE6800AFF857 /* GPUPipeline.cpp */,
    18392                                 9186F3B32329FB0500AFF857 /* GPUPipeline.h */,
    1839318387                                312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */,
    1839418388                                D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */,
     
    2612626120                                D09AC00A231735BE00187762 /* WebGPUDeviceEventHandler.h */,
    2612726121                                D09AC00B231735BE00187762 /* WebGPUDeviceEventHandler.idl */,
    26128                                 9186F3B62329FB4E00AFF857 /* WebGPUPipeline.cpp */,
    26129                                 9186F3B72329FB4F00AFF857 /* WebGPUPipeline.h */,
    2613026122                                D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */,
    2613126123                                D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */,
  • trunk/Source/WebCore/html/canvas/WebGLProgram.cpp

    r250114 r250139  
    2929#if ENABLE(WEBGL)
    3030
    31 #include "InspectorInstrumentation.h"
    32 #include "ScriptExecutionContext.h"
    3331#include "WebGLContextGroup.h"
    3432#include "WebGLRenderingContextBase.h"
     
    6361WebGLProgram::WebGLProgram(WebGLRenderingContextBase& ctx)
    6462    : WebGLSharedObject(ctx)
    65     , m_scriptExecutionContext(ctx.scriptExecutionContext())
    6663{
    6764    {
     
    7572WebGLProgram::~WebGLProgram()
    7673{
    77     InspectorInstrumentation::willDestroyWebGLProgram(*this);
    78 
    7974    deleteObject(0);
    8075
  • trunk/Source/WebCore/html/canvas/WebGLProgram.h

    r250114 r250139  
    3333namespace WebCore {
    3434
    35 class ScriptExecutionContext;
    36 class WebGLRenderingContextBase;
    3735class WebGLShader;
    3836
     
    4442    static HashMap<WebGLProgram*, WebGLRenderingContextBase*>& instances(const LockHolder&);
    4543    static Lock& instancesMutex();
    46 
    47     ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }
    4844
    4945    unsigned numActiveAttribLocations();
     
    7672    void cacheInfoIfNeeded();
    7773
    78     ScriptExecutionContext* m_scriptExecutionContext;
    79 
    8074    Vector<GC3Dint> m_activeAttribLocations;
    8175
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r250114 r250139  
    412412    void showHightlight()
    413413    {
    414         if (!m_program || LIKELY(!InspectorInstrumentation::isWebGLProgramHighlighted(m_context, *m_program)))
     414        if (!m_program || LIKELY(!InspectorInstrumentation::isShaderProgramHighlighted(m_context, *m_program)))
    415415            return;
    416416
     
    17551755    addSharedObject(program.get());
    17561756
    1757     InspectorInstrumentation::didCreateWebGLProgram(*this, program.get());
     1757    InspectorInstrumentation::didCreateProgram(*this, program.get());
    17581758
    17591759    return program;
     
    18411841{
    18421842    if (program)
    1843         InspectorInstrumentation::willDestroyWebGLProgram(*program);
     1843        InspectorInstrumentation::willDeleteProgram(*this, *program);
    18441844
    18451845    deleteObject(program);
     
    22562256        return;
    22572257
    2258     if (m_currentProgram && InspectorInstrumentation::isWebGLProgramDisabled(*this, *m_currentProgram))
     2258    if (m_currentProgram && InspectorInstrumentation::isShaderProgramDisabled(*this, *m_currentProgram))
    22592259        return;
    22602260
     
    23102310        return;
    23112311
    2312     if (m_currentProgram && InspectorInstrumentation::isWebGLProgramDisabled(*this, *m_currentProgram))
     2312    if (m_currentProgram && InspectorInstrumentation::isShaderProgramDisabled(*this, *m_currentProgram))
    23132313        return;
    23142314
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp

    r250114 r250139  
    10801080}
    10811081
    1082 void InspectorInstrumentation::didCreateWebGLProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
     1082void InspectorInstrumentation::didCreateProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
    10831083{
    10841084    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1085         canvasAgent->didCreateWebGLProgram(contextWebGLBase, program);
    1086 }
    1087 
    1088 void InspectorInstrumentation::willDestroyWebGLProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)
     1085        canvasAgent->didCreateProgram(contextWebGLBase, program);
     1086}
     1087
     1088void InspectorInstrumentation::willDeleteProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)
    10891089{
    10901090    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1091         canvasAgent->willDestroyWebGLProgram(program);
    1092 }
    1093 
    1094 bool InspectorInstrumentation::isWebGLProgramDisabledImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)
     1091        canvasAgent->willDeleteProgram(program);
     1092}
     1093
     1094bool InspectorInstrumentation::isShaderProgramDisabledImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)
    10951095{
    10961096    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1097         return canvasAgent->isWebGLProgramDisabled(program);
     1097        return canvasAgent->isShaderProgramDisabled(program);
    10981098    return false;
    10991099}
    11001100
    1101 bool InspectorInstrumentation::isWebGLProgramHighlightedImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)
     1101bool InspectorInstrumentation::isShaderProgramHighlightedImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)
    11021102{
    11031103    if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1104         return canvasAgent->isWebGLProgramHighlighted(program);
     1104        return canvasAgent->isShaderProgramHighlighted(program);
    11051105    return false;
    11061106}
     
    11241124    if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    11251125        canvasAgent->willConfigureSwapChain(contextGPU, newSwapChain);
    1126 }
    1127 
    1128 void InspectorInstrumentation::didCreateWebGPUPipelineImpl(InstrumentingAgents& instrumentingAgents, WebGPUDevice& device, WebGPUPipeline& pipeline)
    1129 {
    1130     if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1131         canvasAgent->didCreateWebGPUPipeline(device, pipeline);
    1132 }
    1133 
    1134 void InspectorInstrumentation::willDestroyWebGPUPipelineImpl(InstrumentingAgents& instrumentingAgents, WebGPUPipeline& pipeline)
    1135 {
    1136     if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent())
    1137         canvasAgent->willDestroyWebGPUPipeline(pipeline);
    11381126}
    11391127#endif
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r250114 r250139  
    6464#include "GPUCanvasContext.h"
    6565#include "WebGPUDevice.h"
    66 #include "WebGPUPipeline.h"
    6766#endif
    6867
     
    291290#if ENABLE(WEBGL)
    292291    static void didEnableExtension(WebGLRenderingContextBase&, const String&);
    293     static void didCreateWebGLProgram(WebGLRenderingContextBase&, WebGLProgram&);
    294     static void willDestroyWebGLProgram(WebGLProgram&);
    295     static bool isWebGLProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);
    296     static bool isWebGLProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
     292    static void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
     293    static void willDeleteProgram(WebGLRenderingContextBase&, WebGLProgram&);
     294    static bool isShaderProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);
     295    static bool isShaderProgramHighlighted(WebGLRenderingContextBase&, WebGLProgram&);
    297296#endif
    298297#if ENABLE(WEBGPU)
     
    300299    static void willDestroyWebGPUDevice(WebGPUDevice&);
    301300    static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);
    302     static void didCreateWebGPUPipeline(WebGPUDevice&, WebGPUPipeline&);
    303     static void willDestroyWebGPUPipeline(WebGPUPipeline&);
    304301#endif
    305302
     
    485482#if ENABLE(WEBGL)
    486483    static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&);
    487     static void didCreateWebGLProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
    488     static void willDestroyWebGLProgramImpl(InstrumentingAgents&, WebGLProgram&);
    489     static bool isWebGLProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);
    490     static bool isWebGLProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
     484    static void didCreateProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);
     485    static void willDeleteProgramImpl(InstrumentingAgents&, WebGLProgram&);
     486    static bool isShaderProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);
     487    static bool isShaderProgramHighlightedImpl(InstrumentingAgents&, WebGLProgram&);
    491488#endif
    492489#if ENABLE(WEBGPU)
     
    494491    static void willDestroyWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&);
    495492    static void willConfigureSwapChainImpl(InstrumentingAgents&, GPUCanvasContext&, WebGPUSwapChain&);
    496     static void didCreateWebGPUPipelineImpl(InstrumentingAgents&, WebGPUDevice&, WebGPUPipeline&);
    497     static void willDestroyWebGPUPipelineImpl(InstrumentingAgents&, WebGPUPipeline&);
    498493#endif
    499494
     
    13901385}
    13911386
    1392 inline void InspectorInstrumentation::didCreateWebGLProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
     1387inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
    13931388{
    13941389    FAST_RETURN_IF_NO_FRONTENDS(void());
    13951390    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
    1396         didCreateWebGLProgramImpl(*instrumentingAgents, contextWebGLBase, program);
    1397 }
    1398 
    1399 inline void InspectorInstrumentation::willDestroyWebGLProgram(WebGLProgram& program)
    1400 {
    1401     FAST_RETURN_IF_NO_FRONTENDS(void());
    1402     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(program.scriptExecutionContext()))
    1403         willDestroyWebGLProgramImpl(*instrumentingAgents, program);
    1404 }
    1405 
    1406 inline bool InspectorInstrumentation::isWebGLProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
     1391        didCreateProgramImpl(*instrumentingAgents, contextWebGLBase, program);
     1392}
     1393
     1394inline void InspectorInstrumentation::willDeleteProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
     1395{
     1396    FAST_RETURN_IF_NO_FRONTENDS(void());
     1397    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
     1398        willDeleteProgramImpl(*instrumentingAgents, program);
     1399}
     1400
     1401inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
    14071402{
    14081403    FAST_RETURN_IF_NO_FRONTENDS(false);
    14091404    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
    1410         return isWebGLProgramDisabledImpl(*instrumentingAgents, program);
     1405        return isShaderProgramDisabledImpl(*instrumentingAgents, program);
    14111406    return false;
    14121407}
    14131408
    1414 inline bool InspectorInstrumentation::isWebGLProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
     1409inline bool InspectorInstrumentation::isShaderProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)
    14151410{
    14161411    FAST_RETURN_IF_NO_FRONTENDS(false);
    14171412    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext()))
    1418         return isWebGLProgramHighlightedImpl(*instrumentingAgents, program);
     1413        return isShaderProgramHighlightedImpl(*instrumentingAgents, program);
    14191414    return false;
    14201415}
     
    14411436    if (auto* instrumentingAgents = instrumentingAgentsForContext(contextGPU.canvasBase().scriptExecutionContext()))
    14421437        willConfigureSwapChainImpl(*instrumentingAgents, contextGPU, newSwapChain);
    1443 }
    1444 
    1445 inline void InspectorInstrumentation::didCreateWebGPUPipeline(WebGPUDevice& device, WebGPUPipeline& pipeline)
    1446 {
    1447     FAST_RETURN_IF_NO_FRONTENDS(void());
    1448     if (auto* instrumentingAgents = instrumentingAgentsForContext(device.scriptExecutionContext()))
    1449         didCreateWebGPUPipelineImpl(*instrumentingAgents, device, pipeline);
    1450 }
    1451 
    1452 inline void InspectorInstrumentation::willDestroyWebGPUPipeline(WebGPUPipeline& pipeline)
    1453 {
    1454     FAST_RETURN_IF_NO_FRONTENDS(void());
    1455     if (auto* instrumentingAgents = instrumentingAgentsForContext(pipeline.scriptExecutionContext()))
    1456         willDestroyWebGPUPipelineImpl(*instrumentingAgents, pipeline);
    14571438}
    14581439#endif
  • trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp

    r250114 r250139  
    2727#include "InspectorShaderProgram.h"
    2828
     29#if ENABLE(WEBGL)
     30
     31#include "GraphicsContext3D.h"
     32#include "GraphicsTypes3D.h"
     33#include "HTMLCanvasElement.h"
    2934#include "InspectorCanvas.h"
    30 #include <JavaScriptCore/IdentifiersFactory.h>
    31 #include <wtf/Optional.h>
    32 #include <wtf/Ref.h>
    33 #include <wtf/Variant.h>
    34 #include <wtf/text/WTFString.h>
    35 
    36 #if ENABLE(WEBGL)
    37 #include "GraphicsContext3D.h"
    3835#include "WebGLProgram.h"
    3936#include "WebGLRenderingContextBase.h"
    4037#include "WebGLShader.h"
    41 #endif
    42 
    43 #if ENABLE(WEBGPU)
    44 #include "GPUShaderModule.h"
    45 #include "WHLSLPrepare.h"
    46 #include "WebGPUComputePipeline.h"
    47 #include "WebGPUPipeline.h"
    48 #include "WebGPURenderPipeline.h"
    49 #include "WebGPUShaderModule.h"
    50 #endif
     38#include <JavaScriptCore/IdentifiersFactory.h>
    5139
    5240namespace WebCore {
     
    5442using namespace Inspector;
    5543
    56 #if ENABLE(WEBGL)
    5744Ref<InspectorShaderProgram> InspectorShaderProgram::create(WebGLProgram& program, InspectorCanvas& inspectorCanvas)
    5845{
    5946    return adoptRef(*new InspectorShaderProgram(program, inspectorCanvas));
    6047}
    61 #endif
    6248
    63 #if ENABLE(WEBGPU)
    64 Ref<InspectorShaderProgram> InspectorShaderProgram::create(WebGPUPipeline& pipeline, InspectorCanvas& inspectorCanvas)
    65 {
    66     return adoptRef(*new InspectorShaderProgram(pipeline, inspectorCanvas));
    67 }
    68 #endif
    69 
    70 #if ENABLE(WEBGL)
    7149InspectorShaderProgram::InspectorShaderProgram(WebGLProgram& program, InspectorCanvas& inspectorCanvas)
    7250    : m_identifier("program:" + IdentifiersFactory::createIdentifier())
     51    , m_program(program)
    7352    , m_canvas(inspectorCanvas)
    74     , m_program(program)
    7553{
    76     ASSERT(is<WebGLRenderingContextBase>(m_canvas.canvasContext()));
    77 }
    78 #endif
    79 
    80 #if ENABLE(WEBGPU)
    81 InspectorShaderProgram::InspectorShaderProgram(WebGPUPipeline& pipeline, InspectorCanvas& inspectorCanvas)
    82     : m_identifier("pipeline:" + IdentifiersFactory::createIdentifier())
    83     , m_canvas(inspectorCanvas)
    84     , m_program(pipeline)
    85 {
    86     ASSERT(m_canvas.deviceContext());
    87 }
    88 #endif
    89 
    90 #if ENABLE(WEBGL)
    91 WebGLProgram* InspectorShaderProgram::program() const
    92 {
    93     if (auto* programWrapper = WTF::get_if<std::reference_wrapper<WebGLProgram>>(m_program))
    94         return &programWrapper->get();
    95     return nullptr;
    96 }
    97 #endif
    98 
    99 #if ENABLE(WEBGPU)
    100 WebGPUPipeline* InspectorShaderProgram::pipeline() const
    101 {
    102     if (auto* pipelineWrapper = WTF::get_if<std::reference_wrapper<WebGPUPipeline>>(m_program))
    103         return &pipelineWrapper->get();
    104     return nullptr;
    105 }
    106 #endif
    107 
    108 #if ENABLE(WEBGL)
    109 static WebGLShader* shaderForType(WebGLProgram& program, Inspector::Protocol::Canvas::ShaderType shaderType)
    110 {
    111     switch (shaderType) {
    112     case Inspector::Protocol::Canvas::ShaderType::Fragment:
    113         return program.getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER);
    114 
    115     case Inspector::Protocol::Canvas::ShaderType::Vertex:
    116         return program.getAttachedShader(GraphicsContext3D::VERTEX_SHADER);
    117 
    118     // Compute shaders are a WebGPU concept.
    119     case Inspector::Protocol::Canvas::ShaderType::Compute:
    120         return nullptr;
    121     }
    122 
    123     ASSERT_NOT_REACHED();
    124     return nullptr;
    125 }
    126 #endif
    127 
    128 #if ENABLE(WEBGPU)
    129 static Optional<WebGPUPipeline::ShaderData> shaderForType(WebGPUPipeline& pipeline, Inspector::Protocol::Canvas::ShaderType shaderType)
    130 {
    131     switch (shaderType) {
    132     case Inspector::Protocol::Canvas::ShaderType::Compute:
    133         if (is<WebGPUComputePipeline>(pipeline))
    134             return downcast<WebGPUComputePipeline>(pipeline).computeShader();
    135         break;
    136 
    137     case Inspector::Protocol::Canvas::ShaderType::Fragment:
    138         if (is<WebGPURenderPipeline>(pipeline))
    139             return downcast<WebGPURenderPipeline>(pipeline).fragmentShader();
    140         break;
    141 
    142     case Inspector::Protocol::Canvas::ShaderType::Vertex:
    143         if (is<WebGPURenderPipeline>(pipeline))
    144             return downcast<WebGPURenderPipeline>(pipeline).vertexShader();
    145         break;
    146     }
    147 
    148     ASSERT_NOT_REACHED();
    149     return WTF::nullopt;
    150 }
    151 #endif
    152 
    153 String InspectorShaderProgram::requestShaderSource(Inspector::Protocol::Canvas::ShaderType shaderType)
    154 {
    155 #if !ENABLE(WEBGL) && !ENABLE(WEBGPU)
    156     UNUSED_PARAM(shaderType);
    157 #endif
    158 
    159     return WTF::switchOn(m_program,
    160 #if ENABLE(WEBGL)
    161         [&] (std::reference_wrapper<WebGLProgram> programWrapper) {
    162             auto& program = programWrapper.get();
    163             if (auto* shader = shaderForType(program, shaderType))
    164                 return shader->getSource();
    165             return String();
    166         },
    167 #endif
    168 #if ENABLE(WEBGPU)
    169         [&] (std::reference_wrapper<WebGPUPipeline> pipelineWrapper) {
    170             auto& pipeline = pipelineWrapper.get();
    171             if (auto shaderData = shaderForType(pipeline, shaderType)) {
    172                 if (auto module = shaderData.value().module)
    173                     return module->source();
    174             }
    175             return String();
    176         },
    177 #endif
    178         [&] (Monostate) {
    179 #if ENABLE(WEBGL) || ENABLE(WEBGPU)
    180             ASSERT_NOT_REACHED();
    181 #endif
    182             return String();
    183         }
    184     );
    18554}
    18655
    187 bool InspectorShaderProgram::updateShader(Inspector::Protocol::Canvas::ShaderType shaderType, const String& source)
     56WebGLRenderingContextBase& InspectorShaderProgram::context() const
    18857{
    189 #if !ENABLE(WEBGL) && !ENABLE(WEBGPU)
    190     UNUSED_PARAM(shaderType);
    191     UNUSED_PARAM(source);
    192 #endif
     58    ASSERT(m_canvas.canvasContext());
     59    ASSERT(is<WebGLRenderingContextBase>(*m_canvas.canvasContext()));
     60    return downcast<WebGLRenderingContextBase>(*m_canvas.canvasContext());
     61}
    19362
    194     return WTF::switchOn(m_program,
    195 #if ENABLE(WEBGL)
    196         [&] (std::reference_wrapper<WebGLProgram> programWrapper) {
    197             auto& program = programWrapper.get();
    198             if (auto* shader = shaderForType(program, shaderType)) {
    199                 if (auto* context = m_canvas.canvasContext()) {
    200                     if (is<WebGLRenderingContextBase>(context)) {
    201                         auto& contextWebGLBase = downcast<WebGLRenderingContextBase>(*context);
    202                         contextWebGLBase.shaderSource(shader, source);
    203                         contextWebGLBase.compileShader(shader);
    204                         if (shader->isValid()) {
    205                             contextWebGLBase.linkProgramWithoutInvalidatingAttribLocations(&program);
    206                             return true;
    207                         }
    208                     }
    209                 }
    210             }
    211             return false;
    212         },
    213 #endif
    214 #if ENABLE(WEBGPU)
    215         [&] (std::reference_wrapper<WebGPUPipeline> pipelineWrapper) {
    216             auto& pipeline = pipelineWrapper.get();
    217             if (auto* device = m_canvas.deviceContext()) {
    218                 if (auto shaderData = shaderForType(pipeline, shaderType)) {
    219                     if (auto module = shaderData.value().module) {
    220                         module->update(*device, source);
    221                         if (pipeline.recompile(*device))
    222                             return true;
    223                     }
    224                 }
    225             }
    226             return false;
    227         },
    228 #endif
    229         [&] (Monostate) {
    230 #if ENABLE(WEBGL) || ENABLE(WEBGPU)
    231             ASSERT_NOT_REACHED();
    232 #endif
    233             return false;
    234         }
    235     );
     63WebGLShader* InspectorShaderProgram::shaderForType(const String& protocolType)
     64{
     65    GC3Denum shaderType;
     66    if (protocolType == "vertex")
     67        shaderType = GraphicsContext3D::VERTEX_SHADER;
     68    else if (protocolType == "fragment")
     69        shaderType = GraphicsContext3D::FRAGMENT_SHADER;
     70    else
     71        return nullptr;
     72
     73    return m_program.getAttachedShader(shaderType);
    23674}
    23775
    23876} // namespace WebCore
     77
     78#endif // ENABLE(WEBGL)
  • trunk/Source/WebCore/inspector/InspectorShaderProgram.h

    r250114 r250139  
    2727
    2828#include <JavaScriptCore/InspectorProtocolObjects.h>
    29 #include <wtf/Forward.h>
    30 #include <wtf/RefCounted.h>
    3129
    3230namespace WebCore {
    3331
    3432class InspectorCanvas;
    35 
    36 #if ENABLE(WEBGL)
    3733class WebGLProgram;
    3834class WebGLRenderingContextBase;
    39 #endif
     35class WebGLShader;
    4036
    41 #if ENABLE(WEBGPU)
    42 class WebGPUPipeline;
    43 #endif
     37typedef String ErrorString;
    4438
    4539class InspectorShaderProgram final : public RefCounted<InspectorShaderProgram> {
    4640public:
    47 #if ENABLE(WEBGL)
    4841    static Ref<InspectorShaderProgram> create(WebGLProgram&, InspectorCanvas&);
    49 #endif
    50 #if ENABLE(WEBGPU)
    51     static Ref<InspectorShaderProgram> create(WebGPUPipeline&, InspectorCanvas&);
    52 #endif
    5342
    5443    const String& identifier() const { return m_identifier; }
    5544    InspectorCanvas& canvas() const { return m_canvas; }
    56 
    57 #if ENABLE(WEBGL)
    58     WebGLProgram* program() const;
    59 #endif
    60 #if ENABLE(WEBGPU)
    61     WebGPUPipeline* pipeline() const;
    62 #endif
    63 
    64     String requestShaderSource(Inspector::Protocol::Canvas::ShaderType);
    65     bool updateShader(Inspector::Protocol::Canvas::ShaderType, const String& source);
     45    WebGLRenderingContextBase& context() const;
     46    WebGLProgram& program() const { return m_program; }
     47    WebGLShader* shaderForType(const String&);
    6648
    6749    bool disabled() const { return m_disabled; }
     
    7153    void setHighlighted(bool value) { m_highlighted = value; }
    7254
     55    ~InspectorShaderProgram() = default;
     56
    7357private:
    74 #if ENABLE(WEBGL)
    7558    InspectorShaderProgram(WebGLProgram&, InspectorCanvas&);
    76 #endif
    77 #if ENABLE(WEBGPU)
    78     InspectorShaderProgram(WebGPUPipeline&, InspectorCanvas&);
    79 #endif
    8059
    8160    String m_identifier;
     61    WebGLProgram& m_program;
    8262    InspectorCanvas& m_canvas;
    83 
    84     Variant<
    85 #if ENABLE(WEBGL)
    86         std::reference_wrapper<WebGLProgram>,
    87 #endif
    88 #if ENABLE(WEBGPU)
    89         std::reference_wrapper<WebGPUPipeline>,
    90 #endif
    91         Monostate
    92     > m_program;
    9363
    9464    bool m_disabled { false };
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp

    r250114 r250139  
    3636#include "ImageBitmapRenderingContext.h"
    3737#include "InspectorDOMAgent.h"
    38 #include "InspectorShaderProgram.h"
    3938#include "InstrumentingAgents.h"
    4039#include "JSExecState.h"
     
    4847#include <JavaScriptCore/InspectorProtocolObjects.h>
    4948#include <JavaScriptCore/JSCInlines.h>
    50 #include <wtf/HashMap.h>
    5149#include <wtf/HashSet.h>
    5250#include <wtf/Lock.h>
    53 #include <wtf/Optional.h>
    54 #include <wtf/RefPtr.h>
    55 #include <wtf/Vector.h>
    56 #include <wtf/text/WTFString.h>
    5751
    5852#if ENABLE(WEBGL)
     
    6054#include "WebGLRenderingContext.h"
    6155#include "WebGLRenderingContextBase.h"
     56#include "WebGLShader.h"
    6257#endif
    6358
     
    6863#if ENABLE(WEBGPU)
    6964#include "GPUCanvasContext.h"
    70 #include "WebGPUComputePipeline.h"
    7165#include "WebGPUDevice.h"
    72 #include "WebGPUPipeline.h"
    73 #include "WebGPURenderPipeline.h"
    74 #include "WebGPUSwapChain.h"
    7566#endif
    7667
     
    8677    , m_inspectedPage(context.inspectedPage)
    8778    , m_canvasDestroyedTimer(*this, &InspectorCanvasAgent::canvasDestroyedTimerFired)
    88     , m_programDestroyedTimer(*this, &InspectorCanvasAgent::programDestroyedTimerFired)
    8979{
    9080}
     
    10494void InspectorCanvasAgent::discardAgent()
    10595{
    106     reset();
     96    clearCanvasData();
    10797}
    10898
     
    152142        for (auto& [program, contextWebGLBase] : WebGLProgram::instances(lock)) {
    153143            if (contextWebGLBase && existsInCurrentPage(contextWebGLBase->canvasBase().scriptExecutionContext()))
    154                 didCreateWebGLProgram(*contextWebGLBase, *program);
     144                didCreateProgram(*contextWebGLBase, *program);
    155145        }
    156146    }
    157147#endif
    158 
    159 #if ENABLE(WEBGPU)
    160     {
    161         LockHolder lock(WebGPUPipeline::instancesMutex());
    162         for (auto& [pipeline, device] : WebGPUPipeline::instances(lock)) {
    163             if (device && existsInCurrentPage(device->scriptExecutionContext()) && pipeline->isValid())
    164                 didCreateWebGPUPipeline(*device, *pipeline);
    165         }
    166     }
    167 #endif
    168148}
    169149
     
    172152    m_instrumentingAgents.setInspectorCanvasAgent(nullptr);
    173153
    174     reset();
     154    clearCanvasData();
    175155
    176156    m_recordingAutoCaptureFrameCount = WTF::nullopt;
     
    301281}
    302282
    303 void InspectorCanvasAgent::requestShaderSource(ErrorString& errorString, const String& programId, const String& shaderTypeString, String* outSource)
    304 {
     283void InspectorCanvasAgent::requestShaderSource(ErrorString& errorString, const String& programId, const String& shaderType, String* content)
     284{
     285#if ENABLE(WEBGL)
    305286    auto inspectorProgram = assertInspectorProgram(errorString, programId);
    306287    if (!inspectorProgram)
    307288        return;
    308289
    309     auto shaderType = Inspector::Protocol::InspectorHelpers::parseEnumValueFromString<Inspector::Protocol::Canvas::ShaderType>(shaderTypeString);
    310     if (!shaderType) {
    311         errorString = makeString("Unknown shaderType: "_s, shaderTypeString);
    312         return;
    313     }
    314 
    315     auto source = inspectorProgram->requestShaderSource(shaderType.value());
    316     if (!source) {
    317         errorString = "Missing shader of given shaderType for given programId"_s;
    318         return;
    319     }
    320 
    321     *outSource = source;
    322 }
    323 
    324 void InspectorCanvasAgent::updateShader(ErrorString& errorString, const String& programId, const String& shaderTypeString, const String& source)
    325 {
     290    auto* shader = inspectorProgram->shaderForType(shaderType);
     291    if (!shader) {
     292        errorString = "Missing shader for given shaderType"_s;
     293        return;
     294    }
     295
     296    *content = shader->getSource();
     297#else
     298    UNUSED_PARAM(programId);
     299    UNUSED_PARAM(shaderType);
     300    UNUSED_PARAM(content);
     301    errorString = "Not supported"_s;
     302#endif
     303}
     304
     305void InspectorCanvasAgent::updateShader(ErrorString& errorString, const String& programId, const String& shaderType, const String& source)
     306{
     307#if ENABLE(WEBGL)
    326308    auto inspectorProgram = assertInspectorProgram(errorString, programId);
    327309    if (!inspectorProgram)
    328310        return;
    329311
    330     auto shaderType = Inspector::Protocol::InspectorHelpers::parseEnumValueFromString<Inspector::Protocol::Canvas::ShaderType>(shaderTypeString);
    331     if (!shaderType) {
    332         errorString = makeString("Unknown shaderType: "_s, shaderTypeString);
    333         return;
    334     }
    335 
    336     if (!inspectorProgram->updateShader(shaderType.value(), source))
    337         errorString = "Failed to update shader of given shaderType for given programId"_s;
     312    auto* shader = inspectorProgram->shaderForType(shaderType);
     313    if (!shader) {
     314        errorString = "Missing shader for given shaderType"_s;
     315        return;
     316    }
     317
     318    WebGLRenderingContextBase& contextWebGL = inspectorProgram->context();
     319    contextWebGL.shaderSource(shader, source);
     320    contextWebGL.compileShader(shader);
     321
     322    if (!shader->isValid()) {
     323        errorString = "Failed to update shader"_s;
     324        return;
     325    }
     326
     327    contextWebGL.linkProgramWithoutInvalidatingAttribLocations(&inspectorProgram->program());
     328#else
     329    UNUSED_PARAM(programId);
     330    UNUSED_PARAM(shaderType);
     331    UNUSED_PARAM(source);
     332    errorString = "Not supported"_s;
     333#endif
    338334}
    339335
    340336void InspectorCanvasAgent::setShaderProgramDisabled(ErrorString& errorString, const String& programId, bool disabled)
    341337{
     338#if ENABLE(WEBGL)
    342339    auto inspectorProgram = assertInspectorProgram(errorString, programId);
    343340    if (!inspectorProgram)
     
    345342
    346343    inspectorProgram->setDisabled(disabled);
     344#else
     345    UNUSED_PARAM(programId);
     346    UNUSED_PARAM(disabled);
     347    errorString = "Not supported"_s;
     348#endif
    347349}
    348350
    349351void InspectorCanvasAgent::setShaderProgramHighlighted(ErrorString& errorString, const String& programId, bool highlighted)
    350352{
     353#if ENABLE(WEBGL)
    351354    auto inspectorProgram = assertInspectorProgram(errorString, programId);
    352355    if (!inspectorProgram)
     
    354357
    355358    inspectorProgram->setHighlighted(highlighted);
     359#else
     360    UNUSED_PARAM(programId);
     361    UNUSED_PARAM(highlighted);
     362    errorString = "Not supported"_s;
     363#endif
    356364}
    357365
     
    359367{
    360368    if (frame.isMainFrame()) {
    361         reset();
     369        clearCanvasData();
    362370        return;
    363371    }
     
    561569}
    562570
    563 void InspectorCanvasAgent::didCreateWebGLProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
     571void InspectorCanvasAgent::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program)
    564572{
    565573    auto inspectorCanvas = findInspectorCanvas(context);
     
    571579    String programIdentifier = inspectorProgram->identifier();
    572580    m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram));
    573     m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier, Inspector::Protocol::Canvas::ProgramType::Render);
    574 }
    575 
    576 void InspectorCanvasAgent::willDestroyWebGLProgram(WebGLProgram& program)
     581    m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier);
     582}
     583
     584void InspectorCanvasAgent::willDeleteProgram(WebGLProgram& program)
    577585{
    578586    auto inspectorProgram = findInspectorProgram(program);
     
    580588        return;
    581589
    582     unbindProgram(*inspectorProgram);
    583 }
    584 
    585 bool InspectorCanvasAgent::isWebGLProgramDisabled(WebGLProgram& program)
     590    String identifier = unbindProgram(*inspectorProgram);
     591    m_frontendDispatcher->programDeleted(identifier);
     592}
     593
     594bool InspectorCanvasAgent::isShaderProgramDisabled(WebGLProgram& program)
    586595{
    587596    auto inspectorProgram = findInspectorProgram(program);
     
    593602}
    594603
    595 bool InspectorCanvasAgent::isWebGLProgramHighlighted(WebGLProgram& program)
     604bool InspectorCanvasAgent::isShaderProgramHighlighted(WebGLProgram& program)
    596605{
    597606    auto inspectorProgram = findInspectorProgram(program);
     
    641650    notifyDeviceForSwapChain(newSwapChain);
    642651}
    643 
    644 void InspectorCanvasAgent::didCreateWebGPUPipeline(WebGPUDevice& device, WebGPUPipeline& pipeline)
    645 {
    646     auto inspectorCanvas = findInspectorCanvas(device);
    647     ASSERT(inspectorCanvas);
    648     if (!inspectorCanvas)
    649         return;
    650 
    651     ASSERT(pipeline.isValid());
    652 
    653     auto inspectorProgram = InspectorShaderProgram::create(pipeline, *inspectorCanvas);
    654     String programIdentifier = inspectorProgram->identifier();
    655     m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram));
    656 
    657     Optional<Inspector::Protocol::Canvas::ProgramType> programType;
    658     if (is<WebGPUComputePipeline>(pipeline))
    659         programType = Inspector::Protocol::Canvas::ProgramType::Compute;
    660     else if (is<WebGPURenderPipeline>(pipeline))
    661         programType = Inspector::Protocol::Canvas::ProgramType::Render;
    662     ASSERT(programType);
    663 
    664     m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier, programType.value());
    665 }
    666 
    667 void InspectorCanvasAgent::willDestroyWebGPUPipeline(WebGPUPipeline& pipeline)
    668 {
    669     auto inspectorProgram = findInspectorProgram(pipeline);
    670     if (!inspectorProgram)
    671         return;
    672 
    673     unbindProgram(*inspectorProgram);
    674 }
    675652#endif
    676653
     
    718695}
    719696
    720 void InspectorCanvasAgent::programDestroyedTimerFired()
    721 {
    722     if (!m_removedProgramIdentifiers.size())
    723         return;
    724 
    725     for (auto& identifier : m_removedProgramIdentifiers)
    726         m_frontendDispatcher->programDeleted(identifier);
    727 
    728     m_removedProgramIdentifiers.clear();
    729 }
    730 
    731 void InspectorCanvasAgent::reset()
     697void InspectorCanvasAgent::clearCanvasData()
    732698{
    733699    for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) {
     
    737703
    738704    m_identifierToInspectorCanvas.clear();
     705#if ENABLE(WEBGL)
     706    m_identifierToInspectorProgram.clear();
    739707    m_removedCanvasIdentifiers.clear();
     708#endif
     709
    740710    if (m_canvasDestroyedTimer.isActive())
    741711        m_canvasDestroyedTimer.stop();
    742 
    743     m_identifierToInspectorProgram.clear();
    744     m_removedProgramIdentifiers.clear();
    745     if (m_programDestroyedTimer.isActive())
    746         m_programDestroyedTimer.stop();
    747712}
    748713
     
    841806#endif
    842807
    843 void InspectorCanvasAgent::unbindProgram(InspectorShaderProgram& inspectorProgram)
     808#if ENABLE(WEBGL)
     809String InspectorCanvasAgent::unbindProgram(InspectorShaderProgram& inspectorProgram)
    844810{
    845811    String identifier = inspectorProgram.identifier();
    846812    m_identifierToInspectorProgram.remove(identifier);
    847813
    848     // This can be called in response to GC. Due to the single-process model used in WebKit1, the
    849     // event must be dispatched from a timer to prevent the frontend from making JS allocations
    850     // while the GC is still active.
    851     m_removedProgramIdentifiers.append(identifier);
    852 
    853     if (!m_programDestroyedTimer.isActive())
    854         m_programDestroyedTimer.startOneShot(0_s);
     814    return identifier;
    855815}
    856816
     
    865825}
    866826
    867 #if ENABLE(WEBGL)
    868827RefPtr<InspectorShaderProgram> InspectorCanvasAgent::findInspectorProgram(WebGLProgram& program)
    869828{
    870829    for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) {
    871         if (inspectorProgram->program() == &program)
     830        if (&inspectorProgram->program() == &program)
    872831            return inspectorProgram;
    873832    }
     
    876835#endif
    877836
    878 #if ENABLE(WEBGPU)
    879 RefPtr<InspectorShaderProgram> InspectorCanvasAgent::findInspectorProgram(WebGPUPipeline& pipeline)
    880 {
    881     for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) {
    882         if (inspectorProgram->pipeline() == &pipeline)
    883             return inspectorProgram;
    884     }
    885     return nullptr;
    886 }
    887 #endif
    888 
    889837} // namespace WebCore
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h

    r250114 r250139  
    3434#include <JavaScriptCore/InspectorFrontendDispatchers.h>
    3535#include <initializer_list>
    36 #include <wtf/Forward.h>
     36#include <wtf/HashMap.h>
     37#include <wtf/RefPtr.h>
     38#include <wtf/Vector.h>
     39#include <wtf/text/WTFString.h>
     40
     41#if ENABLE(WEBGL)
     42#include "InspectorShaderProgram.h"
     43#endif
    3744
    3845namespace Inspector {
     
    4350
    4451class CanvasRenderingContext;
    45 class InspectorShaderProgram;
    4652#if ENABLE(WEBGL)
    4753class WebGLProgram;
     
    5157class GPUCanvasContext;
    5258class WebGPUDevice;
    53 class WebGPUPipeline;
    5459class WebGPUSwapChain;
    5560#endif
     
    7984    void startRecording(ErrorString&, const String& canvasId, const int* frameCount, const int* memoryLimit);
    8085    void stopRecording(ErrorString&, const String& canvasId);
    81     void requestShaderSource(ErrorString&, const String& programId, const String& shaderType, String* source);
     86    void requestShaderSource(ErrorString&, const String& programId, const String& shaderType, String*);
    8287    void updateShader(ErrorString&, const String& programId, const String& shaderType, const String& source);
    8388    void setShaderProgramDisabled(ErrorString&, const String& programId, bool disabled);
     
    99104#if ENABLE(WEBGL)
    100105    void didEnableExtension(WebGLRenderingContextBase&, const String&);
    101     void didCreateWebGLProgram(WebGLRenderingContextBase&, WebGLProgram&);
    102     void willDestroyWebGLProgram(WebGLProgram&);
    103     bool isWebGLProgramDisabled(WebGLProgram&);
    104     bool isWebGLProgramHighlighted(WebGLProgram&);
     106    void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&);
     107    void willDeleteProgram(WebGLProgram&);
     108    bool isShaderProgramDisabled(WebGLProgram&);
     109    bool isShaderProgramHighlighted(WebGLProgram&);
    105110#endif
    106111#if ENABLE(WEBGPU)
     
    108113    void willDestroyWebGPUDevice(WebGPUDevice&);
    109114    void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&);
    110     void didCreateWebGPUPipeline(WebGPUDevice&, WebGPUPipeline&);
    111     void willDestroyWebGPUPipeline(WebGPUPipeline&);
    112115#endif
    113116
     
    121124
    122125    void canvasDestroyedTimerFired();
    123     void programDestroyedTimerFired();
    124     void reset();
    125 
     126    void clearCanvasData();
    126127    InspectorCanvas& bindCanvas(CanvasRenderingContext&, bool captureBacktrace);
    127128#if ENABLE(WEBGPU)
     
    135136#endif
    136137
    137     void unbindProgram(InspectorShaderProgram&);
     138#if ENABLE(WEBGL)
     139    String unbindProgram(InspectorShaderProgram&);
    138140    RefPtr<InspectorShaderProgram> assertInspectorProgram(ErrorString&, const String& programId);
    139 #if ENABLE(WEBGL)
    140141    RefPtr<InspectorShaderProgram> findInspectorProgram(WebGLProgram&);
    141 #endif
    142 #if ENABLE(WEBGPU)
    143     RefPtr<InspectorShaderProgram> findInspectorProgram(WebGPUPipeline&);
    144142#endif
    145143
     
    151149
    152150    HashMap<String, RefPtr<InspectorCanvas>> m_identifierToInspectorCanvas;
     151#if ENABLE(WEBGL)
     152    HashMap<String, RefPtr<InspectorShaderProgram>> m_identifierToInspectorProgram;
     153#endif
    153154    Vector<String> m_removedCanvasIdentifiers;
    154     Timer m_canvasDestroyedTimer;
    155 
    156     HashMap<String, RefPtr<InspectorShaderProgram>> m_identifierToInspectorProgram;
    157     Vector<String> m_removedProgramIdentifiers;
    158     Timer m_programDestroyedTimer;
    159155
    160156    Optional<size_t> m_recordingAutoCaptureFrameCount;
     157
     158    Timer m_canvasDestroyedTimer;
    161159};
    162160
  • trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h

    r250114 r250139  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "GPUPipeline.h"
    31 #include "GPUProgrammableStageDescriptor.h"
    3230#include "WHLSLPrepare.h"
    3331#include <wtf/RefCounted.h>
     
    4139class GPUDevice;
    4240class GPUErrorScopes;
    43 class GPUPipelineLayout;
    4441
    4542struct GPUComputePipelineDescriptor;
     
    4845using PlatformComputePipelineSmartPtr = RetainPtr<MTLComputePipelineState>;
    4946
    50 class GPUComputePipeline final : public GPUPipeline {
     47class GPUComputePipeline : public RefCounted<GPUComputePipeline> {
    5148public:
    52     virtual ~GPUComputePipeline();
    53 
    5449    static RefPtr<GPUComputePipeline> tryCreate(const GPUDevice&, const GPUComputePipelineDescriptor&, GPUErrorScopes&);
    55 
    56     bool isComputePipeline() const { return true; }
    57 
    58     bool recompile(const GPUDevice&, GPUProgrammableStageDescriptor&& computeStage);
    5950
    6051    const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); }
     
    6354
    6455private:
    65     GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions, GPUPipelineLayout&);
     56    GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions);
    6657
    6758    PlatformComputePipelineSmartPtr m_platformComputePipeline;
    6859    WHLSL::ComputeDimensions m_computeDimensions { 0, 0, 0 };
    69 
    70     // Preserved for Web Inspector recompilation.
    71     RefPtr<GPUPipelineLayout> m_layout;
    7260};
    7361
    7462} // namespace WebCore
    7563
    76 SPECIALIZE_TYPE_TRAITS_GPUPIPELINE(WebCore::GPUComputePipeline, isComputePipeline())
    77 
    7864#endif // ENABLE(WEBGPU)
  • trunk/Source/WebCore/platform/graphics/gpu/GPUProgrammableStageDescriptor.h

    r250114 r250139  
    3939
    4040struct GPUProgrammableStageDescriptor : GPUProgrammableStageDescriptorBase {
    41     GPUProgrammableStageDescriptor(Ref<GPUShaderModule>&& module, const GPUProgrammableStageDescriptorBase& base)
     41    GPUProgrammableStageDescriptor(Ref<const GPUShaderModule>&& module, const GPUProgrammableStageDescriptorBase& base)
    4242        : GPUProgrammableStageDescriptorBase(base)
    4343        , module { WTFMove(module) }
     
    4545    }
    4646
    47     Ref<GPUShaderModule> module;
     47    Ref<const GPUShaderModule> module;
    4848};
    4949
  • trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h

    r250114 r250139  
    2828#if ENABLE(WEBGPU)
    2929
    30 #include "GPUPipeline.h"
    31 #include "GPUProgrammableStageDescriptor.h"
    3230#include "GPURenderPipelineDescriptor.h"
    3331#include <wtf/Optional.h>
     
    4947using PlatformRenderPipelineSmartPtr = RetainPtr<MTLRenderPipelineState>;
    5048
    51 class GPURenderPipeline final : public GPUPipeline {
     49class GPURenderPipeline : public RefCounted<GPURenderPipeline> {
    5250public:
    53     virtual ~GPURenderPipeline();
    54 
    5551    static RefPtr<GPURenderPipeline> tryCreate(const GPUDevice&, const GPURenderPipelineDescriptor&, GPUErrorScopes&);
    56 
    57     bool isRenderPipeline() const { return true; }
    58 
    59     bool recompile(const GPUDevice&, GPUProgrammableStageDescriptor&& vertexStage, Optional<GPUProgrammableStageDescriptor>&& fragmentStage);
    6052
    6153#if USE(METAL)
     
    6860private:
    6961#if USE(METAL)
    70     GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPUPrimitiveTopology, Optional<GPUIndexFormat>, GPUPipelineLayout&, const GPURenderPipelineDescriptorBase&);
     62    GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPUPrimitiveTopology, Optional<GPUIndexFormat>);
    7163
    7264    RetainPtr<MTLDepthStencilState> m_depthStencilState;
     
    7567    GPUPrimitiveTopology m_primitiveTopology;
    7668    Optional<GPUIndexFormat> m_indexFormat;
    77 
    78     // Preserved for Web Inspector recompilation.
    79     RefPtr<GPUPipelineLayout> m_layout;
    80     GPURenderPipelineDescriptorBase m_renderDescriptorBase;
    8169};
    8270
    8371} // namespace WebCore
    8472
    85 SPECIALIZE_TYPE_TRAITS_GPUPIPELINE(WebCore::GPURenderPipeline, isRenderPipeline())
    86 
    8773#endif // ENABLE(WEBGPU)
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm

    r250114 r250139  
    3232#import "GPUDevice.h"
    3333#import "GPUErrorScopes.h"
    34 #import "GPUPipelineLayout.h"
    3534#import "GPUPipelineMetalConvertLayout.h"
    3635#import "WHLSLPrepare.h"
     
    196195        return nullptr;
    197196
    198     ASSERT(descriptor.layout);
    199     return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions, *descriptor.layout));
    200 }
    201 
    202 GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions, GPUPipelineLayout& layout)
    203     : GPUPipeline()
    204     , m_platformComputePipeline(WTFMove(pipeline))
     197    return adoptRef(new GPUComputePipeline(WTFMove(createResult->pipelineState), createResult->computeDimensions));
     198}
     199
     200GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions)
     201    : m_platformComputePipeline(WTFMove(pipeline))
    205202    , m_computeDimensions(computeDimensions)
    206     , m_layout(makeRef(layout))
    207 {
    208 }
    209 
    210 GPUComputePipeline::~GPUComputePipeline() = default;
    211 
    212 bool GPUComputePipeline::recompile(const GPUDevice& device, GPUProgrammableStageDescriptor&& computeStage)
    213 {
    214     if (m_layout) {
    215         GPUComputePipelineDescriptor descriptor(makeRef(*m_layout), WTFMove(computeStage));
    216         auto errorScopes = GPUErrorScopes::create([] (GPUError&&) { });
    217         if (auto createResult = tryCreateMTLComputePipelineState(device, descriptor, errorScopes)) {
    218             m_platformComputePipeline = WTFMove(createResult->pipelineState);
    219             m_computeDimensions = createResult->computeDimensions;
    220             return true;
    221         }
    222     }
    223 
    224     return false;
     203{
    225204}
    226205
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm

    r250114 r250139  
    3333#import "GPULimits.h"
    3434#import "GPUPipelineMetalConvertLayout.h"
    35 #import "GPURenderPipelineDescriptor.h"
    3635#import "GPUUtils.h"
    3736#import "WHLSLPrepare.h"
     
    485484}
    486485
    487 static RetainPtr<MTLRenderPipelineState> tryCreateMtlRenderPipelineState(const GPUDevice& device, const GPURenderPipelineDescriptor& descriptor, GPUErrorScopes& errorScopes)
     486static RetainPtr<MTLRenderPipelineState> tryCreateMtlRenderPipelineState(const GPURenderPipelineDescriptor& descriptor, const GPUDevice& device, GPUErrorScopes& errorScopes)
    488487{
    489488    if (!device.platformDevice()) {
     
    524523    // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198387 depthStencilAttachmentDescriptor isn't implemented yet for WHLSL compiler.
    525524
    526     auto pipeline = tryCreateMtlRenderPipelineState(device, descriptor, errorScopes);
     525    auto pipeline = tryCreateMtlRenderPipelineState(descriptor, device, errorScopes);
    527526    if (!pipeline)
    528527        return nullptr;
    529528
    530     ASSERT(descriptor.layout);
    531     return adoptRef(new GPURenderPipeline(WTFMove(depthStencil), WTFMove(pipeline), descriptor.primitiveTopology, descriptor.vertexInput.indexFormat, *descriptor.layout, descriptor));
    532 }
    533 
    534 GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPUPrimitiveTopology topology, Optional<GPUIndexFormat> format, GPUPipelineLayout& layout, const GPURenderPipelineDescriptorBase& renderDescriptorBase)
    535     : GPUPipeline()
    536     , m_depthStencilState(WTFMove(depthStencil))
     529    return adoptRef(new GPURenderPipeline(WTFMove(depthStencil), WTFMove(pipeline), descriptor.primitiveTopology, descriptor.vertexInput.indexFormat));
     530}
     531
     532GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPUPrimitiveTopology topology, Optional<GPUIndexFormat> format)
     533    : m_depthStencilState(WTFMove(depthStencil))
    537534    , m_platformRenderPipeline(WTFMove(pipeline))
    538535    , m_primitiveTopology(topology)
    539536    , m_indexFormat(format)
    540     , m_layout(makeRef(layout))
    541     , m_renderDescriptorBase(renderDescriptorBase)
    542 {
    543 }
    544 
    545 GPURenderPipeline::~GPURenderPipeline() = default;
    546 
    547 bool GPURenderPipeline::recompile(const GPUDevice& device, GPUProgrammableStageDescriptor&& vertexStage, Optional<GPUProgrammableStageDescriptor>&& fragmentStage)
    548 {
    549     if (m_layout) {
    550         GPURenderPipelineDescriptor descriptor(makeRef(*m_layout), WTFMove(vertexStage), WTFMove(fragmentStage), m_renderDescriptorBase);
    551         auto errorScopes = GPUErrorScopes::create([] (GPUError&&) { });
    552         if (auto pipeline = tryCreateMtlRenderPipelineState(device, descriptor, errorScopes)) {
    553             m_platformRenderPipeline = WTFMove(pipeline);
    554             return true;
    555         }
    556     }
    557 
    558     return false;
     537{
    559538}
    560539
  • trunk/Source/WebInspectorUI/ChangeLog

    r250118 r250139  
     12019-09-20  Truitt Savell  <tsavell@apple.com>
     2
     3        Unreviewed, rolling out r250114.
     4
     5        Broke ~16 webgpu/ tests on Mojave wk2
     6
     7        Reverted changeset:
     8
     9        "Web Inspector: Canvas: show WebGPU shader pipelines"
     10        https://bugs.webkit.org/show_bug.cgi?id=201675
     11        https://trac.webkit.org/changeset/250114
     12
    1132019-09-19  Joseph Pecoraro  <pecoraro@apple.com>
    214
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r250114 r250139  
    267267localizedStrings["Compression"] = "Compression";
    268268localizedStrings["Compression:"] = "Compression:";
    269 localizedStrings["Compute"] = "Compute";
    270 localizedStrings["Compute Pipeline %d"] = "Compute Pipeline %d";
    271 localizedStrings["Compute Shader"] = "Compute Shader";
    272269localizedStrings["Computed"] = "Computed";
    273270localizedStrings["Condition"] = "Condition";
     
    467464localizedStrings["Entered Full-Screen Mode"] = "Entered Full-Screen Mode";
    468465localizedStrings["Entire Recording"] = "Entire Recording";
    469 localizedStrings["Entry point: "] = "Entry point: ";
    470466localizedStrings["Error"] = "Error";
    471467localizedStrings["Error: "] = "Error: ";
     
    886882localizedStrings["Remove this breakpoint action"] = "Remove this breakpoint action";
    887883localizedStrings["Removed descendant "] = "Removed descendant ";
    888 localizedStrings["Render Pipeline %d"] = "Render Pipeline %d";
    889884localizedStrings["Rendering Frames"] = "Rendering Frames";
    890885localizedStrings["Repeating Linear Gradient"] = "Repeating Linear Gradient";
     
    1003998localizedStrings["Setter"] = "Setter";
    1004999localizedStrings["Settings"] = "Settings";
     1000localizedStrings["Shader"] = "Shader";
    10051001localizedStrings["Shader Programs"] = "Shader Programs";
    10061002localizedStrings["Shadow Content"] = "Shadow Content";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js

    r250114 r250139  
    235235    }
    236236
    237     programCreated(canvasIdentifier, programIdentifier, programType)
     237    programCreated(canvasIdentifier, programIdentifier)
    238238    {
    239239        let canvas = this._canvasIdentifierMap.get(canvasIdentifier);
     
    244244        console.assert(!this._shaderProgramIdentifierMap.has(programIdentifier), `ShaderProgram already exists with id ${programIdentifier}.`);
    245245
    246         // COMPATIBILITY (iOS 13): `programType` did not exist yet.
    247         if (!programType)
    248             programType = WI.ShaderProgram.ProgramType.Render;
    249 
    250         let program = new WI.ShaderProgram(programIdentifier, programType, canvas);
     246        let program = new WI.ShaderProgram(programIdentifier, canvas);
    251247        this._shaderProgramIdentifierMap.set(program.identifier, program);
    252248
  • trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js

    r250114 r250139  
    4646        this._recordingCollection = new WI.RecordingCollection;
    4747
    48         this._nextShaderProgramDisplayNumber = null;
     48        this._nextShaderProgramDisplayNumber = 1;
    4949
    5050        this._requestNodePromise = null;
     
    410410    }
    411411
    412     nextShaderProgramDisplayNumberForProgramType(programType)
     412    nextShaderProgramDisplayNumber()
    413413    {
    414414        // Called from WI.ShaderProgram.
    415415
    416         if (!this._nextShaderProgramDisplayNumber)
    417             this._nextShaderProgramDisplayNumber = {};
    418 
    419         this._nextShaderProgramDisplayNumber[programType] = (this._nextShaderProgramDisplayNumber[programType] || 0) + 1;
    420         return this._nextShaderProgramDisplayNumber[programType];
     416        return this._nextShaderProgramDisplayNumber++;
    421417    }
    422418};
  • trunk/Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js

    r250114 r250139  
    2626WI.ShaderProgram = class ShaderProgram extends WI.Object
    2727{
    28     constructor(identifier, programType, canvas)
     28    constructor(identifier, canvas)
    2929    {
    3030        console.assert(identifier);
    31         console.assert(Object.values(ShaderProgram.ProgramType).includes(programType));
    3231        console.assert(canvas instanceof WI.Canvas);
    33         console.assert(ShaderProgram.contextTypeSupportsProgramType(canvas.contextType, programType));
    3432
    3533        super();
    3634
    3735        this._identifier = identifier;
    38         this._programType = programType;
    3936        this._canvas = canvas;
     37        this._uniqueDisplayNumber = canvas.nextShaderProgramDisplayNumber();
    4038        this._disabled = false;
    41     }
    42 
    43     // Static
    44 
    45     static contextTypeSupportsProgramType(contextType, programType)
    46     {
    47         switch (contextType) {
    48         case WI.Canvas.ContextType.WebGL:
    49         case WI.Canvas.ContextType.WebGL2:
    50             return programType === ShaderProgram.ProgramType.Render;
    51 
    52         case WI.Canvas.ContextType.WebGPU:
    53             return programType === ShaderProgram.ProgramType.Compute
    54                 || programType === ShaderProgram.ProgramType.Render;
    55         }
    56 
    57         console.assert();
    58         return false;
    59     }
    60 
    61     static programTypeSupportsShaderType(programType, shaderType)
    62     {
    63         switch (programType) {
    64         case ShaderProgram.ProgramType.Compute:
    65             return shaderType === ShaderProgram.ShaderType.Compute;
    66 
    67         case ShaderProgram.ProgramType.Render:
    68             return shaderType === ShaderProgram.ShaderType.Fragment
    69                 || shaderType === ShaderProgram.ShaderType.Vertex;
    70         }
    71 
    72         console.assert();
    73         return false;
    7439    }
    7540
     
    7742
    7843    get identifier() { return this._identifier; }
    79     get programType() { return this._programType; }
    8044    get canvas() { return this._canvas; }
    8145
    8246    get displayName()
    8347    {
    84         let format = null;
    85         switch (this._canvas.contextType) {
    86         case WI.Canvas.ContextType.WebGL:
    87         case WI.Canvas.ContextType.WebGL2:
    88             format = WI.UIString("Program %d");
    89             break;
    90         case WI.Canvas.ContextType.WebGPU:
    91             switch (this._programType) {
    92             case ShaderProgram.ProgramType.Compute:
    93                 format = WI.UIString("Compute Pipeline %d");
    94                 break;
    95             case ShaderProgram.ProgramType.Render:
    96                 format = WI.UIString("Render Pipeline %d");
    97                 break;
    98             }
    99             break;
    100         }
    101         console.assert(format);
    102         if (!this._uniqueDisplayNumber)
    103             this._uniqueDisplayNumber = this._canvas.nextShaderProgramDisplayNumberForProgramType(this._programType);
    104         return format.format(this._uniqueDisplayNumber);
     48        return WI.UIString("Program %d").format(this._uniqueDisplayNumber);
    10549    }
    10650
     
    11256    set disabled(disabled)
    11357    {
    114         console.assert(this._programType === ShaderProgram.ProgramType.Render);
    115         console.assert(this._canvas.contextType === WI.Canvas.ContextType.WebGL || this._canvas.contextType === WI.Canvas.ContextType.WebGL2);
    116 
    117         if (this._canvas.contextType === WI.Canvas.ContextType.WebGPU)
    118             return;
    119 
    12058        if (this._disabled === disabled)
    12159            return;
     
    12866    }
    12967
    130     requestShaderSource(shaderType, callback)
     68    requestVertexShaderSource(callback)
    13169    {
    132         console.assert(Object.values(ShaderProgram.ShaderType).includes(shaderType));
    133         console.assert(ShaderProgram.programTypeSupportsShaderType(this._programType, shaderType));
    134 
    135         // COMPATIBILITY (iOS 13): `content` was renamed to `source`.
    136         CanvasAgent.requestShaderSource(this._identifier, shaderType, (error, source) => {
    137             if (error) {
    138                 WI.reportInternalError(error);
    139                 callback(null, null);
    140                 return;
    141             }
    142 
    143             callback(source);
    144         });
     70        this._requestShaderSource(CanvasAgent.ShaderType.Vertex, callback);
    14571    }
    14672
    147     updateShader(shaderType, source)
     73    requestFragmentShaderSource(callback)
    14874    {
    149         console.assert(Object.values(ShaderProgram.ShaderType).includes(shaderType));
    150         console.assert(ShaderProgram.programTypeSupportsShaderType(this._programType, shaderType));
     75        this._requestShaderSource(CanvasAgent.ShaderType.Fragment, callback);
     76    }
    15177
    152         CanvasAgent.updateShader(this._identifier, shaderType, source);
     78    updateVertexShader(source)
     79    {
     80        this._updateShader(CanvasAgent.ShaderType.Vertex, source);
     81    }
     82
     83    updateFragmentShader(source)
     84    {
     85        this._updateShader(CanvasAgent.ShaderType.Fragment, source);
    15386    }
    15487
    15588    showHighlight()
    15689    {
    157         console.assert(this._programType === ShaderProgram.ProgramType.Render);
    158         console.assert(this._canvas.contextType === WI.Canvas.ContextType.WebGL || this._canvas.contextType === WI.Canvas.ContextType.WebGL2);
    159 
    160         CanvasAgent.setShaderProgramHighlighted(this._identifier, true);
     90        const highlighted = true;
     91        CanvasAgent.setShaderProgramHighlighted(this._identifier, highlighted, (error) => {
     92            console.assert(!error, error);
     93        });
    16194    }
    16295
    16396    hideHighlight()
    16497    {
    165         console.assert(this._programType === ShaderProgram.ProgramType.Render);
    166         console.assert(this._canvas.contextType === WI.Canvas.ContextType.WebGL || this._canvas.contextType === WI.Canvas.ContextType.WebGL2);
     98        const highlighted = false;
     99        CanvasAgent.setShaderProgramHighlighted(this._identifier, highlighted, (error) => {
     100            console.assert(!error, error);
     101        });
     102    }
    167103
    168         CanvasAgent.setShaderProgramHighlighted(this._identifier, false);
     104    // Private
     105
     106    _requestShaderSource(shaderType, callback)
     107    {
     108        CanvasAgent.requestShaderSource(this._identifier, shaderType, (error, content) => {
     109            if (error) {
     110                callback(null);
     111                return;
     112            }
     113
     114            callback(content);
     115        });
     116    }
     117
     118    _updateShader(shaderType, source)
     119    {
     120        CanvasAgent.updateShader(this._identifier, shaderType, source, (error) => {
     121            console.assert(!error, error);
     122        });
    169123    }
    170124};
    171125
    172 WI.ShaderProgram.ProgramType = {
    173     Compute: "compute",
    174     Render: "render",
    175 };
    176 
    177126WI.ShaderProgram.ShaderType = {
    178     Compute: "compute",
    179     Fragment: "fragment",
    180     Vertex: "vertex",
     127    Fragment: "shader-type-fragment",
     128    Vertex: "shader-type-vertex",
    181129};
    182130
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js

    r250114 r250139  
    6868    }
    6969
    70     programCreated(canvasId, programId, programType)
     70    programCreated(canvasId, programId)
    7171    {
    72         WI.canvasManager.programCreated(canvasId, programId, programType);
     72        WI.canvasManager.programCreated(canvasId, programId);
    7373    }
    7474
  • trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js

    r250114 r250139  
    683683        CodeMirror.defineMIME(type, {name: "javascript", json: true});
    684684    });
    685 
    686     // FIXME: Add WHLSL specific modes.
    687     CodeMirror.defineMIME("x-pipeline/x-compute", "x-shader/x-vertex");
    688     CodeMirror.defineMIME("x-pipeline/x-fragment", "x-shader/x-fragment");
    689     CodeMirror.defineMIME("x-pipeline/x-vertex", "x-shader/x-vertex");
    690685})();
    691686
  • trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.css

    r250114 r250139  
    2424 */
    2525
    26 .content-view.shader-program > .shader {
    27     display: flex;
    28     flex-direction: column;
     26.content-view.shader-program > .text-editor.shader {
    2927    position: absolute;
    3028    top: 0;
    3129    bottom: 0;
     30
     31    --border-start-style: 1px solid lightgrey;
    3232}
    3333
    34 .content-view.shader-program > .shader.compute {
    35     right: 0;
    36     left: 0;
    37 }
    38 
    39 body[dir=ltr] .content-view.shader-program > .shader.vertex,
    40 body[dir=rtl] .content-view.shader-program > .shader.fragment {
     34body[dir=ltr] .content-view.shader-program > .text-editor.shader.vertex,
     35body[dir=rtl] .content-view.shader-program > .text-editor.shader.fragment {
    4136    width: calc(50% - 1px);
    4237    left: 0;
    4338}
    4439
    45 body[dir=ltr] .content-view.shader-program > .shader.fragment,
    46 body[dir=rtl] .content-view.shader-program > .shader.vertex {
     40body[dir=ltr] .content-view.shader-program > .text-editor.shader.fragment,
     41body[dir=rtl] .content-view.shader-program > .text-editor.shader.vertex {
    4742    width: calc(50% + 1px);
    4843    right: 0;
    4944}
    5045
    51 .content-view.shader-program > .shader + .shader {
    52     border-left: 1px solid var(--border-color);
     46body[dir=ltr] .content-view.shader-program > .text-editor.shader + .text-editor.shader {
     47    border-left: var(--border-start-style);
    5348}
    5449
    55 .content-view.shader-program > .shader > header > * {
     50body[dir=rtl] .content-view.shader-program > .text-editor.shader + .text-editor.shader {
     51    border-right: var(--border-start-style);
     52}
     53
     54.content-view.shader-program > .text-editor.shader > .type-title {
    5655    padding: 2px 4px;
     56    background-color: hsl(0, 0%, 95%);
    5757    border-bottom: 1px solid lightgrey;
    5858}
    5959
    60 .content-view.shader-program > .shader > header > .shader-type {
    61     background-color: hsl(0, 0%, 95%);
     60.content-view.shader-program > .text-editor.shader > .CodeMirror {
     61    top: 18px;
    6262}
    6363
    6464@media (prefers-color-scheme: dark) {
    65     .content-view.shader-program > .shader > header {
     65    .content-view.shader-program > .text-editor.shader {
     66        --border-start-style: 1px solid var(--text-color-quaternary);
     67    }
     68
     69    .content-view.shader-program > .text-editor.shader > .type-title {
    6670        background-color: var(--background-color);
    6771        border-bottom-color: var(--text-color-quaternary);
  • trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.js

    r250114 r250139  
    3232        super(shaderProgram);
    3333
    34         let isWebGPU = this.representedObject.contextType === WI.Canvas.ContextType.WebGPU;
    35 
    36         this._refreshButtonNavigationItem = new WI.ButtonNavigationItem("refresh", WI.UIString("Refresh"), "Images/ReloadFull.svg", 13, 13);
    37         this._refreshButtonNavigationItem.visibilityPriority = WI.NavigationItem.VisibilityPriority.Low;
    38         this._refreshButtonNavigationItem.addEventListener(WI.ButtonNavigationItem.Event.Clicked, this._refreshContent, this);
    39 
    4034        let contentDidChangeDebouncer = new Debouncer((event) => {
    4135            this._contentDidChange(event);
    4236        });
    4337
    44         this.element.classList.add("shader-program", this.representedObject.programType);
     38        this.element.classList.add("shader-program");
    4539
    4640        let createEditor = (shaderType) => {
    47             let container = this.element.appendChild(document.createElement("div"));
    48 
    49             let header = container.appendChild(document.createElement("header"));
    50 
    51             let shaderTypeContainer = header.appendChild(document.createElement("div"));
    52             shaderTypeContainer.classList.add("shader-type");
    53 
    5441            let textEditor = new WI.TextEditor;
    5542            textEditor.readOnly = false;
     
    5946                contentDidChangeDebouncer.delayForTime(250, event);
    6047            }, this);
     48            textEditor.element.classList.add("shader");
     49
     50            let shaderTypeContainer = textEditor.element.insertAdjacentElement("afterbegin", document.createElement("div"));
     51            shaderTypeContainer.classList.add("type-title");
    6152
    6253            switch (shaderType) {
    63             case WI.ShaderProgram.ShaderType.Compute:
    64                 shaderTypeContainer.textContent = WI.UIString("Compute Shader");
    65                 textEditor.mimeType = isWebGPU ? "x-pipeline/x-compute" : "x-shader/x-compute";
     54            case WI.ShaderProgram.ShaderType.Vertex:
     55                shaderTypeContainer.textContent = WI.UIString("Vertex Shader");
     56                textEditor.mimeType = "x-shader/x-vertex";
     57                textEditor.element.classList.add("vertex");
    6658                break;
    6759
    6860            case WI.ShaderProgram.ShaderType.Fragment:
    6961                shaderTypeContainer.textContent = WI.UIString("Fragment Shader");
    70                 textEditor.mimeType = isWebGPU ? "x-pipeline/x-fragment" : "x-shader/x-fragment";
    71                 break;
    72 
    73             case WI.ShaderProgram.ShaderType.Vertex:
    74                 shaderTypeContainer.textContent = WI.UIString("Vertex Shader");
    75                 textEditor.mimeType = isWebGPU ? "x-pipeline/x-vertex" : "x-shader/x-vertex";
     62                textEditor.mimeType = "x-shader/x-fragment";
     63                textEditor.element.classList.add("fragment");
    7664                break;
    7765            }
    7866
    7967            this.addSubview(textEditor);
    80             container.appendChild(textEditor.element);
    81             container.classList.add("shader", shaderType);
    82 
    83             return {container, textEditor};
     68            return textEditor;
    8469        };
    8570
    86         switch (this.representedObject.programType) {
    87         case WI.ShaderProgram.ProgramType.Compute: {
    88             let computeEditor = createEditor(WI.ShaderProgram.ShaderType.Compute);
    89             this._computeContainer = computeEditor.container;
    90             this._computeEditor = computeEditor.textEditor;
    91 
    92             this._lastActiveEditor = this._computeEditor;
    93             break;
    94         }
    95 
    96         case WI.ShaderProgram.ProgramType.Render: {
    97             let vertexEditor = createEditor(WI.ShaderProgram.ShaderType.Vertex);
    98             this._vertexContainer = vertexEditor.container;
    99             this._vertexEditor = vertexEditor.textEditor;
    100 
    101             let fragmentEditor = createEditor(WI.ShaderProgram.ShaderType.Fragment);
    102             this._fragmentContainer = fragmentEditor.container;
    103             this._fragmentEditor = fragmentEditor.textEditor;
    104 
    105             this._lastActiveEditor = this._vertexEditor;
    106             break;
    107         }
    108         }
    109     }
    110 
    111     // Public
    112 
    113     get navigationItems()
    114     {
    115         return [this._refreshButtonNavigationItem];
     71        this._vertexEditor = createEditor(WI.ShaderProgram.ShaderType.Vertex);
     72        this._fragmentEditor = createEditor(WI.ShaderProgram.ShaderType.Fragment);
     73        this._lastActiveEditor = this._vertexEditor;
    11674    }
    11775
     
    12280        super.shown();
    12381
    124         switch (this.representedObject.programType) {
    125         case WI.ShaderProgram.ProgramType.Compute:
    126             this._computeEditor.shown();
    127             break;
    128 
    129         case WI.ShaderProgram.ProgramType.Render:
    130             this._vertexEditor.shown();
    131             this._fragmentEditor.shown();
    132             break;
    133         }
    134 
    135         this._refreshContent();
     82        this._vertexEditor.shown();
     83        this._fragmentEditor.shown();
     84
     85        this.representedObject.requestVertexShaderSource((content) => {
     86            this._vertexEditor.string = content || "";
     87        });
     88
     89        this.representedObject.requestFragmentShaderSource((content) => {
     90            this._fragmentEditor.string = content || "";
     91        });
    13692    }
    13793
    13894    hidden()
    13995    {
    140         switch (this.representedObject.programType) {
    141         case WI.ShaderProgram.ProgramType.Compute:
    142             this._computeEditor.hidden();
    143             break;
    144 
    145         case WI.ShaderProgram.ProgramType.Render:
    146             this._vertexEditor.hidden();
    147             this._fragmentEditor.hidden();
    148             break;
    149         }
     96        this._vertexEditor.hidden();
     97        this._fragmentEditor.hidden();
    15098
    15199        super.hidden();
     
    159107    get saveData()
    160108    {
    161         let filename = "";
    162         switch (this._lastActiveEditor) {
    163         case this._computeEditor:
    164             filename = WI.UIString("Compute");
    165             break;
    166         case this._fragmentEditor:
     109        let filename = WI.UIString("Shader");
     110        if (this._lastActiveEditor === this._vertexEditor)
     111            filename = WI.UIString("Vertex");
     112        else if (this._lastActiveEditor === this._fragmentEditor)
    167113            filename = WI.UIString("Fragment");
    168             break;
    169         case this._vertexEditor:
    170             filename = WI.UIString("Vertex");
    171             break;
    172         }
    173         console.assert(filename);
    174 
    175         let extension = "";
    176         switch (this.representedObject.canvas.contextType) {
    177         case WI.Canvas.ContextType.WebGL:
    178         case WI.Canvas.ContextType.WebGL2:
    179             extension = WI.unlocalizedString(".glsl");
    180             break;
    181         case WI.Canvas.ContextType.WebGPU:
    182             extension = WI.unlocalizedString(".wsl");
    183             break;
    184         }
    185         console.assert(extension);
    186114
    187115        return {
    188             url: WI.FileUtilities.inspectorURLForFilename(filename + extension),
     116            url: WI.FileUtilities.inspectorURLForFilename(filename + ".glsl"),
    189117            content: this._lastActiveEditor.string,
    190118            forceSaveAs: true,
     
    244172    // Private
    245173
    246     _refreshContent()
    247     {
    248         let createCallback = (container, textEditor) => {
    249             return (source, entryPoint) => {
    250                 if (source === null) {
    251                     container.remove();
    252                     return;
    253                 }
    254 
    255                 if (!container.parentNode) {
    256                     switch (container) {
    257                     case this._computeContainer:
    258                     case this._vertexContainer:
    259                         this.element.insertAdjacentElement("afterbegin", container);
    260                         break;
    261 
    262                     case this._fragmentContainer:
    263                         this.element.insertAdjacentElement("beforeend", container);
    264                         break;
    265                     }
    266                 }
    267 
    268                 textEditor.string = source || "";
    269             };
    270         };
    271 
    272         switch (this.representedObject.programType) {
    273         case WI.ShaderProgram.ProgramType.Compute:
    274             this.representedObject.requestShaderSource(WI.ShaderProgram.ShaderType.Compute, createCallback(this._computeContainer, this._computeEditor));
    275             return;
    276 
    277         case WI.ShaderProgram.ProgramType.Render:
    278             this.representedObject.requestShaderSource(WI.ShaderProgram.ShaderType.Vertex, createCallback(this._vertexContainer, this._vertexEditor));
    279             this.representedObject.requestShaderSource(WI.ShaderProgram.ShaderType.Fragment, createCallback(this._fragmentContainer, this._fragmentEditor));
    280             return;
    281         }
    282 
    283         console.assert();
    284     }
    285 
    286     _updateShader(shaderType)
    287     {
    288         switch (shaderType) {
    289         case WI.ShaderProgram.ShaderType.Compute:
    290             this.representedObject.updateShader(shaderType, this._computeEditor.string);
    291             return;
    292 
    293         case WI.ShaderProgram.ShaderType.Fragment:
    294             this.representedObject.updateShader(shaderType, this._fragmentEditor.string);
    295             return;
    296 
    297         case WI.ShaderProgram.ShaderType.Vertex:
    298             this.representedObject.updateShader(shaderType, this._vertexEditor.string);
    299             return;
    300         }
    301 
    302         console.assert();
    303     }
    304 
    305174    _editorFocused(event)
    306175    {
     
    329198    _contentDidChange(event)
    330199    {
    331         switch (event.target) {
    332         case this._computeEditor:
    333             this._updateShader(WI.ShaderProgram.ShaderType.Compute);
    334             return;
    335 
    336         case this._fragmentEditor:
    337             this._updateShader(WI.ShaderProgram.ShaderType.Fragment);
    338             return;
    339 
    340         case this._vertexEditor:
    341             this._updateShader(WI.ShaderProgram.ShaderType.Vertex);
    342             return;
    343         }
    344 
    345         console.assert();
     200        if (event.target === this._vertexEditor)
     201            this.representedObject.updateVertexShader(this._vertexEditor.string);
     202        else if (event.target === this._fragmentEditor)
     203            this.representedObject.updateFragmentShader(this._fragmentEditor.string);
    346204    }
    347205};
  • trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js

    r250114 r250139  
    3333        super("shader-program", shaderProgram.displayName, subtitle, shaderProgram);
    3434
    35         // FIXME: add support for disabling/highlighting WebGPU shader pipelines.
    36         let contextType = this.representedObject.canvas.contextType;
    37         if (contextType === WI.Canvas.ContextType.WebGL || contextType === WI.Canvas.ContextType.WebGL2) {
    38             this._disabledImageElement = document.createElement("img");
    39             this._disabledImageElement.title = WI.UIString("Disable Program");
    40             this._disabledImageElement.addEventListener("click", this._disabledImageElementClicked.bind(this));
    41             this.status = this._disabledImageElement;
    42         }
     35        this._disabledImageElement = document.createElement("img");
     36        this._disabledImageElement.title = WI.UIString("Disable Program");
     37        this._disabledImageElement.addEventListener("click", this._disabledImageElementClicked.bind(this));
     38        this.status = this._disabledImageElement;
    4339    }
    4440
     
    4945        super.onattach();
    5046
    51         // FIXME: add support for disabling/highlighting WebGPU shader pipelines.
    52         let contextType = this.representedObject.canvas.contextType;
    53         if (contextType === WI.Canvas.ContextType.WebGL || contextType === WI.Canvas.ContextType.WebGL2) {
    54             this.representedObject.addEventListener(WI.ShaderProgram.Event.DisabledChanged, this._handleShaderProgramDisabledChanged, this);
     47        this.representedObject.addEventListener(WI.ShaderProgram.Event.DisabledChanged, this._handleShaderProgramDisabledChanged, this);
    5548
    56             this.element.addEventListener("mouseover", this._handleMouseOver.bind(this));
    57             this.element.addEventListener("mouseout", this._handleMouseOut.bind(this));
    58         }
     49        this.element.addEventListener("mouseover", this._handleMouseOver.bind(this));
     50        this.element.addEventListener("mouseout", this._handleMouseOut.bind(this));
    5951    }
    6052
    6153    ondetach()
    6254    {
    63         // FIXME: add support for disabling/highlighting WebGPU shader pipelines.
    64         let contextType = this.representedObject.canvas.contextType;
    65         if (contextType === WI.Canvas.ContextType.WebGL || contextType === WI.Canvas.ContextType.WebGL2)
    66             this.representedObject.removeEventListener(WI.ShaderProgram.Event.DisabledChanged, this._handleShaderProgramDisabledChanged, this);
     55        this.representedObject.removeEventListener(WI.ShaderProgram.Event.DisabledChanged, this._handleShaderProgramDisabledChanged, this);
    6756
    6857        super.ondetach();
     
    7160    canSelectOnMouseDown(event)
    7261    {
    73         if (this._disabledImageElement && this._disabledImageElement.contains(event.target))
     62        if (this._disabledImageElement.contains(event.target))
    7463            return false;
    7564        return super.canSelectOnMouseDown(event);
     
    7867    populateContextMenu(contextMenu, event)
    7968    {
    80         // FIXME: add support for disabling/highlighting WebGPU shader pipelines.
    81         let contextType = this.representedObject.canvas.contextType;
    82         if (contextType === WI.Canvas.ContextType.WebGL || contextType === WI.Canvas.ContextType.WebGL2) {
    83             let disabled = this.representedObject.disabled;
    84             contextMenu.appendItem(disabled ? WI.UIString("Enable Program") : WI.UIString("Disable Program"), () => {
    85                 this.representedObject.disabled = !disabled;
    86             });
     69        let disabled = this.representedObject.disabled;
     70        contextMenu.appendItem(disabled ? WI.UIString("Enable Program") : WI.UIString("Disable Program"), () => {
     71            this.representedObject.disabled = !disabled;
     72        });
    8773
    88             contextMenu.appendSeparator();
    89         }
     74        contextMenu.appendSeparator();
    9075
    9176        super.populateContextMenu(contextMenu, event);
Note: See TracChangeset for help on using the changeset viewer.