Changeset 250139 in webkit
- Timestamp:
- Sep 20, 2019 12:39:42 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 15 deleted
- 66 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r250127 r250139 1 2019-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 1 13 2019-09-20 Rob Buis <rbuis@igalia.com> 2 14 -
trunk/LayoutTests/inspector/canvas/console-record-webgl.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/console-record-webgl2.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/recording-webgl-frameCount.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/recording-webgl-full.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/recording-webgl-memoryLimit.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/recording-webgl-snapshots.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec3 position; -
trunk/LayoutTests/inspector/canvas/recording-webgl2-frameCount.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/recording-webgl2-full.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/recording-webgl2-memoryLimit.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec4 test; -
trunk/LayoutTests/inspector/canvas/recording-webgl2-snapshots.html
r250114 r250139 4 4 <script src="../../http/tests/inspector/resources/inspector-test.js"></script> 5 5 <script src="resources/recording-utilities.js"></script> 6 <script src="resources/shaderProgram-utilities -webgl.js"></script>6 <script src="resources/shaderProgram-utilities.js"></script> 7 7 <script id="vertex-shader" type="x-shader/x-vertex"> 8 8 attribute vec3 position; -
trunk/LayoutTests/inspector/canvas/requestShaderSource-expected.txt
r250114 r250139 1 Common tests for Canvas.requestShaderSource command.1 Test compilation of shaders after being attached to a program, with and without syntax errors. 2 2 3 3 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 6 22 PASS: Should produce an error. 7 23 Error: Missing program for given programId 8 24 25 -- Running test case: Canvas.requestShaderSource.invalidShaderType 26 PASS: Should produce an error. 27 Error: Missing shader for given shaderType 28 -
trunk/LayoutTests/inspector/canvas/requestShaderSource.html
r250114 r250139 3 3 <head> 4 4 <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> 5 18 <script> 19 function load() { 20 createProgram("webgl"); 21 linkProgram("vertex-shader", "fragment-shader"); 22 23 runTest(); 24 } 25 6 26 function test() { 7 let suite = InspectorTest.createAsyncSuite("Canvas. requestShaderSource");27 let suite = InspectorTest.createAsyncSuite("Canvas.getShaderSource"); 8 28 9 29 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", 11 63 description: "Invalid program identifiers should cause an error.", 12 64 test(resolve, reject) { … … 21 73 }); 22 74 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 23 94 suite.runTestCasesAndFinish(); 24 95 } 25 96 </script> 26 97 </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> 29 100 </body> 30 101 </html> -
trunk/LayoutTests/inspector/canvas/setShaderProgramDisabled.html
r250114 r250139 3 3 <head> 4 4 <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> 6 6 <script id="vertex-shader" type="x-shader/x-vertex"> 7 7 attribute vec3 position; -
trunk/LayoutTests/inspector/canvas/setShaderProgramHighlighted.html
r250114 r250139 3 3 <head> 4 4 <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> 6 6 <script id="vertex-shader" type="x-shader/x-vertex"> 7 7 attribute vec3 position; -
trunk/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl.html
r250114 r250139 3 3 <head> 4 4 <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> 6 6 <script> 7 7 function test() { -
trunk/LayoutTests/inspector/canvas/shaderProgram-add-remove-webgl2.html
r250114 r250139 3 3 <head> 4 4 <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> 6 6 <script> 7 7 if (window.internals) -
trunk/LayoutTests/inspector/canvas/updateShader-expected.txt
r250114 r250139 1 Common tests for Canvas.updateShader command. 1 CONSOLE MESSAGE: WebGL: ERROR: 0:1: 'INVALID' : syntax error 2 CONSOLE MESSAGE: WebGL: ERROR: 0:1: 'INVALID' : syntax error 3 Test compilation of shaders after being attached to a program, with and without syntax errors. 2 4 3 5 4 6 == 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 6 24 PASS: Should produce an error. 7 25 Error: Missing program for given programId 8 26 27 -- Running test case: Canvas.updateShader.invalidShaderType 28 PASS: Should produce an error. 29 Error: Missing shader for given shaderType 30 31 -- Running test case: Canvas.updateShader.invalidVertexShaderSource 32 PASS: Should produce error. 33 Error: Failed to update shader 34 35 -- Running test case: Canvas.updateShader.invalidFragmentShaderSource 36 PASS: Should produce error. 37 Error: Failed to update shader 38 -
trunk/LayoutTests/inspector/canvas/updateShader.html
r250114 r250139 3 3 <head> 4 4 <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> 5 18 <script> 19 function load() { 20 createProgram("webgl"); 21 linkProgram("vertex-shader", "fragment-shader"); 22 23 runTest(); 24 } 25 6 26 function test() { 7 27 let suite = InspectorTest.createAsyncSuite("Canvas.updateShader"); 8 28 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 9 71 suite.addTestCase({ 10 name: "Canvas.updateShader. ProgramId.Invalid",72 name: "Canvas.updateShader.invalidProgramId", 11 73 description: "Invalid program identifiers should cause an error.", 12 74 test(resolve, reject) { … … 22 84 }); 23 85 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 24 137 suite.runTestCasesAndFinish(); 25 138 } 26 139 </script> 27 140 </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> 30 143 </body> 31 144 </html> -
trunk/LayoutTests/platform/gtk/TestExpectations
r250114 r250139 1151 1151 webkit.org/b/191005 inspector/canvas/create-context-webgpu.html [ Skip ] 1152 1152 webkit.org/b/191005 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 1153 webkit.org/b/191005 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]1154 1153 webkit.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 ]1157 1154 1158 1155 # No support for resource load statistics yet -
trunk/LayoutTests/platform/ios/TestExpectations
r250114 r250139 46 46 inspector/canvas/create-context-webgpu.html [ Skip ] 47 47 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 48 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]49 48 inspector/canvas/resolveContext-webgpu.html [ Skip ] 50 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]51 inspector/canvas/updateShader-webgpu.html [ Skip ]52 49 53 50 # Encrypted Media Extensions are not enabled -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r250114 r250139 48 48 inspector/canvas/create-context-webgpu.html [ Skip ] 49 49 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 50 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]51 50 inspector/canvas/resolveContext-webgpu.html [ Skip ] 52 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]53 inspector/canvas/updateShader-webgpu.html [ Skip ]54 51 55 52 # Media Stream API testing is not supported for WK1 yet. -
trunk/LayoutTests/platform/mac/TestExpectations
r250127 r250139 1782 1782 webkit.org/b/199275 [ HighSierra ] inspector/canvas/create-context-webgpu.html [ Skip ] 1783 1783 webkit.org/b/199275 [ HighSierra ] inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 1784 webkit.org/b/199275 [ HighSierra ] inspector/canvas/requestShaderSource-webgpu.html [ Skip ]1785 1784 webkit.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 ]1788 1785 1789 1786 webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ] -
trunk/LayoutTests/platform/win/TestExpectations
r250114 r250139 2002 2002 inspector/canvas/requestContent-webgl.html [ Skip ] 2003 2003 inspector/canvas/requestContent-webgl2.html [ Skip ] 2004 inspector/canvas/requestShaderSource -webgl.html [ Skip ]2004 inspector/canvas/requestShaderSource.html [ Skip ] 2005 2005 inspector/canvas/resolveContext-webgl.html [ Skip ] 2006 2006 inspector/canvas/resolveContext-webgl2.html [ Skip ] 2007 2007 inspector/canvas/shaderProgram-add-remove-webgl.html [ Skip ] 2008 2008 inspector/canvas/shaderProgram-add-remove-webgl2.html [ Skip ] 2009 inspector/canvas/updateShader-webgl.html [ Skip ] 2010 2009 inspector/canvas/updateShader.html [ Skip ] 2011 2010 ################################################################################ 2012 2011 ################# End WebGL Issues ####################### … … 4248 4247 inspector/canvas/create-context-webgpu.html [ Skip ] 4249 4248 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 4250 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]4251 4249 inspector/canvas/resolveContext-webgpu.html [ Skip ] 4252 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]4253 inspector/canvas/updateShader-webgpu.html [ Skip ]4254 4250 4255 4251 webkit.org/b/191194 fast/block/basic/inline-content-with-floating-image.html [ Failure ] -
trunk/LayoutTests/platform/wincairo/TestExpectations
r250114 r250139 299 299 inspector/canvas/create-context-webgpu.html [ Skip ] 300 300 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 301 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]302 301 inspector/canvas/resolveContext-webgpu.html [ Skip ] 303 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]304 inspector/canvas/updateShader-webgpu.html [ Skip ]305 302 306 303 # WIRELESS_PLAYBACK_TARGET is disabled -
trunk/LayoutTests/platform/wpe/TestExpectations
r250114 r250139 303 303 inspector/canvas/create-context-webgpu.html [ Skip ] 304 304 inspector/canvas/requestClientNodes-webgpu.html [ Skip ] 305 inspector/canvas/requestShaderSource-webgpu.html [ Skip ]306 305 inspector/canvas/resolveContext-webgpu.html [ Skip ] 307 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]308 inspector/canvas/updateShader-webgpu.html [ Skip ]309 306 310 307 # Skipped due to untestable DRM key system. ClearKey counterparts are tested instead. -
trunk/Source/JavaScriptCore/ChangeLog
r250129 r250139 1 2019-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 1 13 2019-09-20 Paulo Matos <pmatos@igalia.com> 2 14 -
trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json
r250114 r250139 21 21 }, 22 22 { 23 "id": "ProgramType",24 "type": "string",25 "enum": ["compute", "render"]26 },27 {28 23 "id": "ShaderType", 29 24 "type": "string", 30 "enum": ["compute", "fragment", "vertex"] 25 "enum": ["fragment", "vertex"], 26 "description": "Shader type. WebGL supports vertex and fragment shaders." 31 27 }, 32 28 { … … 141 137 ], 142 138 "returns": [ 143 { "name": " source", "type": "string" }139 { "name": "content", "type": "string" } 144 140 ] 145 141 }, … … 228 224 "name": "programCreated", 229 225 "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." } 233 228 ] 234 229 }, … … 236 231 "name": "programDeleted", 237 232 "parameters": [ 238 { "name": "programId", "$ref": "ProgramId" }233 { "name": "programId", "$ref": "ProgramId", "description": "Program identifier." } 239 234 ] 240 235 } -
trunk/Source/WebCore/ChangeLog
r250132 r250139 1 2019-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 1 13 2019-09-20 Antti Koivisto <antti@apple.com> 2 14 -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp
r250114 r250139 29 29 #if ENABLE(WEBGPU) 30 30 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 39 31 namespace WebCore { 40 32 41 Ref<WebGPUComputePipeline> WebGPUComputePipeline::create( WebGPUDevice& device, RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes, Optional<WebGPUPipeline::ShaderData> computeShader)33 Ref<WebGPUComputePipeline> WebGPUComputePipeline::create(RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes) 42 34 { 43 return adoptRef(*new WebGPUComputePipeline( device, WTFMove(pipeline), errorScopes, computeShader));35 return adoptRef(*new WebGPUComputePipeline(WTFMove(pipeline), errorScopes)); 44 36 } 45 37 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) 38 WebGPUComputePipeline::WebGPUComputePipeline(RefPtr<GPUComputePipeline>&& pipeline, GPUErrorScopes& errorScopes) 39 : GPUObjectBase(makeRef(errorScopes)) 40 , m_computePipeline { WTFMove(pipeline) } 50 41 { 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;66 42 } 67 43 -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h
r250114 r250139 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WebGPUPipeline.h" 31 #include <wtf/Forward.h> 30 #include "GPUComputePipeline.h" 31 #include "GPUObjectBase.h" 32 #include <wtf/RefPtr.h> 32 33 33 34 namespace WebCore { 34 35 35 class GPUComputePipeline; 36 class GPUPipeline; 37 class GPUErrorScopes; 38 class WebGPUDevice; 36 class WebGPUComputePipeline : public GPUObjectBase { 37 public: 38 static Ref<WebGPUComputePipeline> create(RefPtr<GPUComputePipeline>&&, GPUErrorScopes&); 39 39 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(); }49 40 const GPUComputePipeline* computePipeline() const { return m_computePipeline.get(); } 50 Optional<WebGPUPipeline::ShaderData> computeShader() const { return m_computeShader; }51 52 bool recompile(const WebGPUDevice&);53 41 54 42 private: 55 WebGPUComputePipeline( WebGPUDevice&, RefPtr<GPUComputePipeline>&&, GPUErrorScopes&, Optional<WebGPUPipeline::ShaderData> computeShader);43 WebGPUComputePipeline(RefPtr<GPUComputePipeline>&&, GPUErrorScopes&); 56 44 57 45 RefPtr<GPUComputePipeline> m_computePipeline; 58 59 // Preserved for Web Inspector recompilation.60 Optional<WebGPUPipeline::ShaderData> m_computeShader;61 46 }; 62 47 63 48 } // namespace WebCore 64 49 65 SPECIALIZE_TYPE_TRAITS_WEBGPUPIPELINE(WebCore::WebGPUComputePipeline, isComputePipeline())66 67 50 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.idl
r250114 r250139 28 28 Conditional=WEBGPU, 29 29 EnabledAtRuntime=WebGPU, 30 ImplementationLacksVTable, 30 31 InterfaceName=GPUComputePipeline 31 32 ] interface WebGPUComputePipeline { -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.cpp
r250114 r250139 40 40 #include "GPUBufferDescriptor.h" 41 41 #include "GPUCommandBuffer.h" 42 #include "GPUComputePipeline.h"43 42 #include "GPUComputePipelineDescriptor.h" 44 43 #include "GPUProgrammableStageDescriptor.h" 45 #include "GPURenderPipeline.h"46 44 #include "GPURenderPipelineDescriptor.h" 47 45 #include "GPUSampler.h" … … 208 206 // FIXME: What can be validated here? 209 207 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 211 Ref<WebGPURenderPipeline> WebGPUDevice::createRenderPipeline(const WebGPURenderPipelineDescriptor& descriptor) const 214 212 { 215 213 m_errorScopes->setErrorPrefix("GPUDevice.createRenderPipeline(): "); … … 217 215 auto gpuDescriptor = descriptor.tryCreateGPURenderPipelineDescriptor(m_errorScopes); 218 216 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 223 Ref<WebGPUComputePipeline> WebGPUDevice::createComputePipeline(const WebGPUComputePipelineDescriptor& descriptor) const 236 224 { 237 225 m_errorScopes->setErrorPrefix("GPUDevice.createComputePipeline(): "); … … 239 227 auto gpuDescriptor = descriptor.tryCreateGPUComputePipelineDescriptor(m_errorScopes); 240 228 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); 251 233 } 252 234 -
trunk/Source/WebCore/Modules/webgpu/WebGPUDevice.h
r250114 r250139 100 100 101 101 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; 104 104 105 105 Ref<WebGPUCommandEncoder> createCommandEncoder() const; -
trunk/Source/WebCore/Modules/webgpu/WebGPUProgrammableStageDescriptor.h
r250114 r250139 38 38 Optional<GPUProgrammableStageDescriptor> tryCreateGPUProgrammableStageDescriptor() const; 39 39 40 RefPtr< WebGPUShaderModule> module;40 RefPtr<const WebGPUShaderModule> module; 41 41 }; 42 42 -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp
r250114 r250139 29 29 #if ENABLE(WEBGPU) 30 30 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 39 31 namespace WebCore { 40 32 41 Ref<WebGPURenderPipeline> WebGPURenderPipeline::create( WebGPUDevice& device, RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes, Optional<WebGPUPipeline::ShaderData> vertexShader, Optional<WebGPUPipeline::ShaderData> fragmentShader)33 Ref<WebGPURenderPipeline> WebGPURenderPipeline::create(RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes) 42 34 { 43 return adoptRef(*new WebGPURenderPipeline( device, WTFMove(pipeline), errorScopes, vertexShader, fragmentShader));35 return adoptRef(*new WebGPURenderPipeline(WTFMove(pipeline), errorScopes)); 44 36 } 45 37 46 WebGPURenderPipeline::WebGPURenderPipeline( WebGPUDevice& device, RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes, Optional<WebGPUPipeline::ShaderData> vertexShader, Optional<WebGPUPipeline::ShaderData> fragmentShader)47 : WebGPUPipeline(device, errorScopes)38 WebGPURenderPipeline::WebGPURenderPipeline(RefPtr<GPURenderPipeline>&& pipeline, GPUErrorScopes& errorScopes) 39 : GPUObjectBase(makeRef(errorScopes)) 48 40 , m_renderPipeline(WTFMove(pipeline)) 49 , m_vertexShader(vertexShader)50 , m_fragmentShader(fragmentShader)51 41 { 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;74 42 } 75 43 -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h
r250114 r250139 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "WebGPUPipeline.h" 31 #include <wtf/Forward.h> 30 #include "GPUObjectBase.h" 31 #include "GPURenderPipeline.h" 32 #include <wtf/RefPtr.h> 32 33 33 34 namespace WebCore { 34 35 35 class GPUPipeline; 36 class GPURenderPipeline; 37 class GPUErrorScopes; 38 class WebGPUDevice; 36 class WebGPURenderPipeline : public GPUObjectBase { 37 public: 38 static Ref<WebGPURenderPipeline> create(RefPtr<GPURenderPipeline>&&, GPUErrorScopes&); 39 39 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(); }49 40 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&);54 41 55 42 private: 56 WebGPURenderPipeline( WebGPUDevice&, RefPtr<GPURenderPipeline>&&, GPUErrorScopes&, Optional<WebGPUPipeline::ShaderData> vertexShader, Optional<WebGPUPipeline::ShaderData> fragmentShader);43 WebGPURenderPipeline(RefPtr<GPURenderPipeline>&&, GPUErrorScopes&); 57 44 58 45 RefPtr<GPURenderPipeline> m_renderPipeline; 59 60 // Preserved for Web Inspector recompilation.61 Optional<WebGPUPipeline::ShaderData> m_vertexShader;62 Optional<WebGPUPipeline::ShaderData> m_fragmentShader;63 46 }; 64 47 65 48 } // namespace WebCore 66 49 67 SPECIALIZE_TYPE_TRAITS_WEBGPUPIPELINE(WebCore::WebGPURenderPipeline, isRenderPipeline())68 69 50 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.idl
r250114 r250139 28 28 Conditional=WEBGPU, 29 29 EnabledAtRuntime=WebGPU, 30 ImplementationLacksVTable, 30 31 InterfaceName=GPURenderPipeline 31 32 ] interface WebGPURenderPipeline { -
trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.cpp
r250114 r250139 29 29 #if ENABLE(WEBGPU) 30 30 31 #include "GPUShaderModuleDescriptor.h"32 #include "WebGPUDevice.h"33 #include <wtf/RefPtr.h>34 35 31 namespace WebCore { 36 32 37 Ref<WebGPUShaderModule> WebGPUShaderModule::create(RefPtr<GPUShaderModule>&& module , const String& source)33 Ref<WebGPUShaderModule> WebGPUShaderModule::create(RefPtr<GPUShaderModule>&& module) 38 34 { 39 return adoptRef(*new WebGPUShaderModule(WTFMove(module) , source));35 return adoptRef(*new WebGPUShaderModule(WTFMove(module))); 40 36 } 41 37 42 WebGPUShaderModule::WebGPUShaderModule(RefPtr<GPUShaderModule>&& module , const String& source)38 WebGPUShaderModule::WebGPUShaderModule(RefPtr<GPUShaderModule>&& module) 43 39 : m_module(WTFMove(module)) 44 , m_source(source)45 40 { 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 });52 41 } 53 42 -
trunk/Source/WebCore/Modules/webgpu/WebGPUShaderModule.h
r250114 r250139 29 29 30 30 #include "GPUShaderModule.h" 31 #include <wtf/Forward.h> 31 32 32 #include <wtf/RefCounted.h> 33 #include <wtf/RefPtr.h> 33 34 34 35 namespace WebCore { 35 36 36 class WebGPUDevice;37 38 37 class WebGPUShaderModule : public RefCounted<WebGPUShaderModule> { 39 38 public: 40 static Ref<WebGPUShaderModule> create(RefPtr<GPUShaderModule>&& , const String& source);39 static Ref<WebGPUShaderModule> create(RefPtr<GPUShaderModule>&&); 41 40 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(); } 46 42 47 43 private: 48 WebGPUShaderModule(RefPtr<GPUShaderModule>&& , const String& source);44 WebGPUShaderModule(RefPtr<GPUShaderModule>&&); 49 45 50 46 RefPtr<GPUShaderModule> m_module; 51 52 // Preserved for Web Inspector recompilation.53 String m_source;54 47 }; 55 48 -
trunk/Source/WebCore/Sources.txt
r250128 r250139 374 374 Modules/webgpu/WebGPUDeviceErrorScopes.cpp 375 375 Modules/webgpu/WebGPUQueue.cpp 376 Modules/webgpu/WebGPUPipeline.cpp377 376 Modules/webgpu/WebGPUPipelineLayout.cpp 378 377 Modules/webgpu/WebGPUPipelineLayoutDescriptor.cpp … … 1900 1899 platform/graphics/gpu/GPUErrorScopes.cpp 1901 1900 platform/graphics/gpu/GPUValidationError.cpp 1902 platform/graphics/gpu/GPUPipeline.cpp1903 1901 platform/graphics/gpu/GPUPipelineLayout.cpp 1904 1902 platform/graphics/gpu/GPUProgrammablePassEncoder.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r250128 r250139 10405 10405 9175CE5A21E281ED00DF2C27 /* InspectorAuditAccessibilityObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorAuditAccessibilityObject.h; sourceTree = "<group>"; }; 10406 10406 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>"; };10411 10407 91B8F0B321953D65000C2B00 /* CertificateInfoBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CertificateInfoBase.h; sourceTree = "<group>"; }; 10412 10408 91B952221F58A58000931DC2 /* RecordingSwizzleTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RecordingSwizzleTypes.h; sourceTree = "<group>"; }; … … 18389 18385 D09AFB3722D7D5C600C4538C /* GPUObjectBase.h */, 18390 18386 D09AFB1922D6698A00C4538C /* GPUOutOfMemoryError.h */, 18391 9186F3BA2329FE6800AFF857 /* GPUPipeline.cpp */,18392 9186F3B32329FB0500AFF857 /* GPUPipeline.h */,18393 18387 312FF8C421A4C2F400EB199D /* GPUPipelineDescriptorBase.h */, 18394 18388 D003288721C9A4E500622AA6 /* GPUPipelineLayout.cpp */, … … 26126 26120 D09AC00A231735BE00187762 /* WebGPUDeviceEventHandler.h */, 26127 26121 D09AC00B231735BE00187762 /* WebGPUDeviceEventHandler.idl */, 26128 9186F3B62329FB4E00AFF857 /* WebGPUPipeline.cpp */,26129 9186F3B72329FB4F00AFF857 /* WebGPUPipeline.h */,26130 26122 D0C419F02183EB31009EC1DE /* WebGPUPipelineDescriptorBase.h */, 26131 26123 D0C419F12183EB31009EC1DE /* WebGPUPipelineDescriptorBase.idl */, -
trunk/Source/WebCore/html/canvas/WebGLProgram.cpp
r250114 r250139 29 29 #if ENABLE(WEBGL) 30 30 31 #include "InspectorInstrumentation.h"32 #include "ScriptExecutionContext.h"33 31 #include "WebGLContextGroup.h" 34 32 #include "WebGLRenderingContextBase.h" … … 63 61 WebGLProgram::WebGLProgram(WebGLRenderingContextBase& ctx) 64 62 : WebGLSharedObject(ctx) 65 , m_scriptExecutionContext(ctx.scriptExecutionContext())66 63 { 67 64 { … … 75 72 WebGLProgram::~WebGLProgram() 76 73 { 77 InspectorInstrumentation::willDestroyWebGLProgram(*this);78 79 74 deleteObject(0); 80 75 -
trunk/Source/WebCore/html/canvas/WebGLProgram.h
r250114 r250139 33 33 namespace WebCore { 34 34 35 class ScriptExecutionContext;36 class WebGLRenderingContextBase;37 35 class WebGLShader; 38 36 … … 44 42 static HashMap<WebGLProgram*, WebGLRenderingContextBase*>& instances(const LockHolder&); 45 43 static Lock& instancesMutex(); 46 47 ScriptExecutionContext* scriptExecutionContext() const { return m_scriptExecutionContext; }48 44 49 45 unsigned numActiveAttribLocations(); … … 76 72 void cacheInfoIfNeeded(); 77 73 78 ScriptExecutionContext* m_scriptExecutionContext;79 80 74 Vector<GC3Dint> m_activeAttribLocations; 81 75 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r250114 r250139 412 412 void showHightlight() 413 413 { 414 if (!m_program || LIKELY(!InspectorInstrumentation::is WebGLProgramHighlighted(m_context, *m_program)))414 if (!m_program || LIKELY(!InspectorInstrumentation::isShaderProgramHighlighted(m_context, *m_program))) 415 415 return; 416 416 … … 1755 1755 addSharedObject(program.get()); 1756 1756 1757 InspectorInstrumentation::didCreate WebGLProgram(*this, program.get());1757 InspectorInstrumentation::didCreateProgram(*this, program.get()); 1758 1758 1759 1759 return program; … … 1841 1841 { 1842 1842 if (program) 1843 InspectorInstrumentation::willDe stroyWebGLProgram(*program);1843 InspectorInstrumentation::willDeleteProgram(*this, *program); 1844 1844 1845 1845 deleteObject(program); … … 2256 2256 return; 2257 2257 2258 if (m_currentProgram && InspectorInstrumentation::is WebGLProgramDisabled(*this, *m_currentProgram))2258 if (m_currentProgram && InspectorInstrumentation::isShaderProgramDisabled(*this, *m_currentProgram)) 2259 2259 return; 2260 2260 … … 2310 2310 return; 2311 2311 2312 if (m_currentProgram && InspectorInstrumentation::is WebGLProgramDisabled(*this, *m_currentProgram))2312 if (m_currentProgram && InspectorInstrumentation::isShaderProgramDisabled(*this, *m_currentProgram)) 2313 2313 return; 2314 2314 -
trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp
r250114 r250139 1080 1080 } 1081 1081 1082 void InspectorInstrumentation::didCreate WebGLProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)1082 void InspectorInstrumentation::didCreateProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program) 1083 1083 { 1084 1084 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1085 canvasAgent->didCreate WebGLProgram(contextWebGLBase, program);1086 } 1087 1088 void InspectorInstrumentation::willDe stroyWebGLProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)1085 canvasAgent->didCreateProgram(contextWebGLBase, program); 1086 } 1087 1088 void InspectorInstrumentation::willDeleteProgramImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program) 1089 1089 { 1090 1090 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1091 canvasAgent->willDe stroyWebGLProgram(program);1092 } 1093 1094 bool InspectorInstrumentation::is WebGLProgramDisabledImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)1091 canvasAgent->willDeleteProgram(program); 1092 } 1093 1094 bool InspectorInstrumentation::isShaderProgramDisabledImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program) 1095 1095 { 1096 1096 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1097 return canvasAgent->is WebGLProgramDisabled(program);1097 return canvasAgent->isShaderProgramDisabled(program); 1098 1098 return false; 1099 1099 } 1100 1100 1101 bool InspectorInstrumentation::is WebGLProgramHighlightedImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program)1101 bool InspectorInstrumentation::isShaderProgramHighlightedImpl(InstrumentingAgents& instrumentingAgents, WebGLProgram& program) 1102 1102 { 1103 1103 if (InspectorCanvasAgent* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1104 return canvasAgent->is WebGLProgramHighlighted(program);1104 return canvasAgent->isShaderProgramHighlighted(program); 1105 1105 return false; 1106 1106 } … … 1124 1124 if (auto* canvasAgent = instrumentingAgents.inspectorCanvasAgent()) 1125 1125 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);1138 1126 } 1139 1127 #endif -
trunk/Source/WebCore/inspector/InspectorInstrumentation.h
r250114 r250139 64 64 #include "GPUCanvasContext.h" 65 65 #include "WebGPUDevice.h" 66 #include "WebGPUPipeline.h"67 66 #endif 68 67 … … 291 290 #if ENABLE(WEBGL) 292 291 static void didEnableExtension(WebGLRenderingContextBase&, const String&); 293 static void didCreate WebGLProgram(WebGLRenderingContextBase&, WebGLProgram&);294 static void willDe stroyWebGLProgram(WebGLProgram&);295 static bool is WebGLProgramDisabled(WebGLRenderingContextBase&, WebGLProgram&);296 static bool is WebGLProgramHighlighted(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&); 297 296 #endif 298 297 #if ENABLE(WEBGPU) … … 300 299 static void willDestroyWebGPUDevice(WebGPUDevice&); 301 300 static void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&); 302 static void didCreateWebGPUPipeline(WebGPUDevice&, WebGPUPipeline&);303 static void willDestroyWebGPUPipeline(WebGPUPipeline&);304 301 #endif 305 302 … … 485 482 #if ENABLE(WEBGL) 486 483 static void didEnableExtensionImpl(InstrumentingAgents&, WebGLRenderingContextBase&, const String&); 487 static void didCreate WebGLProgramImpl(InstrumentingAgents&, WebGLRenderingContextBase&, WebGLProgram&);488 static void willDe stroyWebGLProgramImpl(InstrumentingAgents&, WebGLProgram&);489 static bool is WebGLProgramDisabledImpl(InstrumentingAgents&, WebGLProgram&);490 static bool is WebGLProgramHighlightedImpl(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&); 491 488 #endif 492 489 #if ENABLE(WEBGPU) … … 494 491 static void willDestroyWebGPUDeviceImpl(InstrumentingAgents&, WebGPUDevice&); 495 492 static void willConfigureSwapChainImpl(InstrumentingAgents&, GPUCanvasContext&, WebGPUSwapChain&); 496 static void didCreateWebGPUPipelineImpl(InstrumentingAgents&, WebGPUDevice&, WebGPUPipeline&);497 static void willDestroyWebGPUPipelineImpl(InstrumentingAgents&, WebGPUPipeline&);498 493 #endif 499 494 … … 1390 1385 } 1391 1386 1392 inline void InspectorInstrumentation::didCreate WebGLProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)1387 inline void InspectorInstrumentation::didCreateProgram(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program) 1393 1388 { 1394 1389 FAST_RETURN_IF_NO_FRONTENDS(void()); 1395 1390 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext())) 1396 didCreate WebGLProgramImpl(*instrumentingAgents, contextWebGLBase, program);1397 } 1398 1399 inline void InspectorInstrumentation::willDe stroyWebGLProgram(WebGLProgram& program)1400 { 1401 FAST_RETURN_IF_NO_FRONTENDS(void()); 1402 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext( program.scriptExecutionContext()))1403 willDe stroyWebGLProgramImpl(*instrumentingAgents, program);1404 } 1405 1406 inline bool InspectorInstrumentation::is WebGLProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)1391 didCreateProgramImpl(*instrumentingAgents, contextWebGLBase, program); 1392 } 1393 1394 inline 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 1401 inline bool InspectorInstrumentation::isShaderProgramDisabled(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program) 1407 1402 { 1408 1403 FAST_RETURN_IF_NO_FRONTENDS(false); 1409 1404 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext())) 1410 return is WebGLProgramDisabledImpl(*instrumentingAgents, program);1405 return isShaderProgramDisabledImpl(*instrumentingAgents, program); 1411 1406 return false; 1412 1407 } 1413 1408 1414 inline bool InspectorInstrumentation::is WebGLProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program)1409 inline bool InspectorInstrumentation::isShaderProgramHighlighted(WebGLRenderingContextBase& contextWebGLBase, WebGLProgram& program) 1415 1410 { 1416 1411 FAST_RETURN_IF_NO_FRONTENDS(false); 1417 1412 if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(contextWebGLBase.canvasBase().scriptExecutionContext())) 1418 return is WebGLProgramHighlightedImpl(*instrumentingAgents, program);1413 return isShaderProgramHighlightedImpl(*instrumentingAgents, program); 1419 1414 return false; 1420 1415 } … … 1441 1436 if (auto* instrumentingAgents = instrumentingAgentsForContext(contextGPU.canvasBase().scriptExecutionContext())) 1442 1437 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);1457 1438 } 1458 1439 #endif -
trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp
r250114 r250139 27 27 #include "InspectorShaderProgram.h" 28 28 29 #if ENABLE(WEBGL) 30 31 #include "GraphicsContext3D.h" 32 #include "GraphicsTypes3D.h" 33 #include "HTMLCanvasElement.h" 29 34 #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"38 35 #include "WebGLProgram.h" 39 36 #include "WebGLRenderingContextBase.h" 40 37 #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> 51 39 52 40 namespace WebCore { … … 54 42 using namespace Inspector; 55 43 56 #if ENABLE(WEBGL)57 44 Ref<InspectorShaderProgram> InspectorShaderProgram::create(WebGLProgram& program, InspectorCanvas& inspectorCanvas) 58 45 { 59 46 return adoptRef(*new InspectorShaderProgram(program, inspectorCanvas)); 60 47 } 61 #endif62 48 63 #if ENABLE(WEBGPU)64 Ref<InspectorShaderProgram> InspectorShaderProgram::create(WebGPUPipeline& pipeline, InspectorCanvas& inspectorCanvas)65 {66 return adoptRef(*new InspectorShaderProgram(pipeline, inspectorCanvas));67 }68 #endif69 70 #if ENABLE(WEBGL)71 49 InspectorShaderProgram::InspectorShaderProgram(WebGLProgram& program, InspectorCanvas& inspectorCanvas) 72 50 : m_identifier("program:" + IdentifiersFactory::createIdentifier()) 51 , m_program(program) 73 52 , m_canvas(inspectorCanvas) 74 , m_program(program)75 53 { 76 ASSERT(is<WebGLRenderingContextBase>(m_canvas.canvasContext()));77 }78 #endif79 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 #endif89 90 #if ENABLE(WEBGL)91 WebGLProgram* InspectorShaderProgram::program() const92 {93 if (auto* programWrapper = WTF::get_if<std::reference_wrapper<WebGLProgram>>(m_program))94 return &programWrapper->get();95 return nullptr;96 }97 #endif98 99 #if ENABLE(WEBGPU)100 WebGPUPipeline* InspectorShaderProgram::pipeline() const101 {102 if (auto* pipelineWrapper = WTF::get_if<std::reference_wrapper<WebGPUPipeline>>(m_program))103 return &pipelineWrapper->get();104 return nullptr;105 }106 #endif107 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 #endif127 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 #endif152 153 String InspectorShaderProgram::requestShaderSource(Inspector::Protocol::Canvas::ShaderType shaderType)154 {155 #if !ENABLE(WEBGL) && !ENABLE(WEBGPU)156 UNUSED_PARAM(shaderType);157 #endif158 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 #endif168 #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 #endif178 [&] (Monostate) {179 #if ENABLE(WEBGL) || ENABLE(WEBGPU)180 ASSERT_NOT_REACHED();181 #endif182 return String();183 }184 );185 54 } 186 55 187 bool InspectorShaderProgram::updateShader(Inspector::Protocol::Canvas::ShaderType shaderType, const String& source) 56 WebGLRenderingContextBase& InspectorShaderProgram::context() const 188 57 { 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 } 193 62 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 ); 63 WebGLShader* 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); 236 74 } 237 75 238 76 } // namespace WebCore 77 78 #endif // ENABLE(WEBGL) -
trunk/Source/WebCore/inspector/InspectorShaderProgram.h
r250114 r250139 27 27 28 28 #include <JavaScriptCore/InspectorProtocolObjects.h> 29 #include <wtf/Forward.h>30 #include <wtf/RefCounted.h>31 29 32 30 namespace WebCore { 33 31 34 32 class InspectorCanvas; 35 36 #if ENABLE(WEBGL)37 33 class WebGLProgram; 38 34 class WebGLRenderingContextBase; 39 #endif 35 class WebGLShader; 40 36 41 #if ENABLE(WEBGPU) 42 class WebGPUPipeline; 43 #endif 37 typedef String ErrorString; 44 38 45 39 class InspectorShaderProgram final : public RefCounted<InspectorShaderProgram> { 46 40 public: 47 #if ENABLE(WEBGL)48 41 static Ref<InspectorShaderProgram> create(WebGLProgram&, InspectorCanvas&); 49 #endif50 #if ENABLE(WEBGPU)51 static Ref<InspectorShaderProgram> create(WebGPUPipeline&, InspectorCanvas&);52 #endif53 42 54 43 const String& identifier() const { return m_identifier; } 55 44 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&); 66 48 67 49 bool disabled() const { return m_disabled; } … … 71 53 void setHighlighted(bool value) { m_highlighted = value; } 72 54 55 ~InspectorShaderProgram() = default; 56 73 57 private: 74 #if ENABLE(WEBGL)75 58 InspectorShaderProgram(WebGLProgram&, InspectorCanvas&); 76 #endif77 #if ENABLE(WEBGPU)78 InspectorShaderProgram(WebGPUPipeline&, InspectorCanvas&);79 #endif80 59 81 60 String m_identifier; 61 WebGLProgram& m_program; 82 62 InspectorCanvas& m_canvas; 83 84 Variant<85 #if ENABLE(WEBGL)86 std::reference_wrapper<WebGLProgram>,87 #endif88 #if ENABLE(WEBGPU)89 std::reference_wrapper<WebGPUPipeline>,90 #endif91 Monostate92 > m_program;93 63 94 64 bool m_disabled { false }; -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
r250114 r250139 36 36 #include "ImageBitmapRenderingContext.h" 37 37 #include "InspectorDOMAgent.h" 38 #include "InspectorShaderProgram.h"39 38 #include "InstrumentingAgents.h" 40 39 #include "JSExecState.h" … … 48 47 #include <JavaScriptCore/InspectorProtocolObjects.h> 49 48 #include <JavaScriptCore/JSCInlines.h> 50 #include <wtf/HashMap.h>51 49 #include <wtf/HashSet.h> 52 50 #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>57 51 58 52 #if ENABLE(WEBGL) … … 60 54 #include "WebGLRenderingContext.h" 61 55 #include "WebGLRenderingContextBase.h" 56 #include "WebGLShader.h" 62 57 #endif 63 58 … … 68 63 #if ENABLE(WEBGPU) 69 64 #include "GPUCanvasContext.h" 70 #include "WebGPUComputePipeline.h"71 65 #include "WebGPUDevice.h" 72 #include "WebGPUPipeline.h"73 #include "WebGPURenderPipeline.h"74 #include "WebGPUSwapChain.h"75 66 #endif 76 67 … … 86 77 , m_inspectedPage(context.inspectedPage) 87 78 , m_canvasDestroyedTimer(*this, &InspectorCanvasAgent::canvasDestroyedTimerFired) 88 , m_programDestroyedTimer(*this, &InspectorCanvasAgent::programDestroyedTimerFired)89 79 { 90 80 } … … 104 94 void InspectorCanvasAgent::discardAgent() 105 95 { 106 reset();96 clearCanvasData(); 107 97 } 108 98 … … 152 142 for (auto& [program, contextWebGLBase] : WebGLProgram::instances(lock)) { 153 143 if (contextWebGLBase && existsInCurrentPage(contextWebGLBase->canvasBase().scriptExecutionContext())) 154 didCreate WebGLProgram(*contextWebGLBase, *program);144 didCreateProgram(*contextWebGLBase, *program); 155 145 } 156 146 } 157 147 #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 #endif168 148 } 169 149 … … 172 152 m_instrumentingAgents.setInspectorCanvasAgent(nullptr); 173 153 174 reset();154 clearCanvasData(); 175 155 176 156 m_recordingAutoCaptureFrameCount = WTF::nullopt; … … 301 281 } 302 282 303 void InspectorCanvasAgent::requestShaderSource(ErrorString& errorString, const String& programId, const String& shaderTypeString, String* outSource) 304 { 283 void InspectorCanvasAgent::requestShaderSource(ErrorString& errorString, const String& programId, const String& shaderType, String* content) 284 { 285 #if ENABLE(WEBGL) 305 286 auto inspectorProgram = assertInspectorProgram(errorString, programId); 306 287 if (!inspectorProgram) 307 288 return; 308 289 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 305 void InspectorCanvasAgent::updateShader(ErrorString& errorString, const String& programId, const String& shaderType, const String& source) 306 { 307 #if ENABLE(WEBGL) 326 308 auto inspectorProgram = assertInspectorProgram(errorString, programId); 327 309 if (!inspectorProgram) 328 310 return; 329 311 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 338 334 } 339 335 340 336 void InspectorCanvasAgent::setShaderProgramDisabled(ErrorString& errorString, const String& programId, bool disabled) 341 337 { 338 #if ENABLE(WEBGL) 342 339 auto inspectorProgram = assertInspectorProgram(errorString, programId); 343 340 if (!inspectorProgram) … … 345 342 346 343 inspectorProgram->setDisabled(disabled); 344 #else 345 UNUSED_PARAM(programId); 346 UNUSED_PARAM(disabled); 347 errorString = "Not supported"_s; 348 #endif 347 349 } 348 350 349 351 void InspectorCanvasAgent::setShaderProgramHighlighted(ErrorString& errorString, const String& programId, bool highlighted) 350 352 { 353 #if ENABLE(WEBGL) 351 354 auto inspectorProgram = assertInspectorProgram(errorString, programId); 352 355 if (!inspectorProgram) … … 354 357 355 358 inspectorProgram->setHighlighted(highlighted); 359 #else 360 UNUSED_PARAM(programId); 361 UNUSED_PARAM(highlighted); 362 errorString = "Not supported"_s; 363 #endif 356 364 } 357 365 … … 359 367 { 360 368 if (frame.isMainFrame()) { 361 reset();369 clearCanvasData(); 362 370 return; 363 371 } … … 561 569 } 562 570 563 void InspectorCanvasAgent::didCreate WebGLProgram(WebGLRenderingContextBase& context, WebGLProgram& program)571 void InspectorCanvasAgent::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program) 564 572 { 565 573 auto inspectorCanvas = findInspectorCanvas(context); … … 571 579 String programIdentifier = inspectorProgram->identifier(); 572 580 m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram)); 573 m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier , Inspector::Protocol::Canvas::ProgramType::Render);574 } 575 576 void InspectorCanvasAgent::willDe stroyWebGLProgram(WebGLProgram& program)581 m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier); 582 } 583 584 void InspectorCanvasAgent::willDeleteProgram(WebGLProgram& program) 577 585 { 578 586 auto inspectorProgram = findInspectorProgram(program); … … 580 588 return; 581 589 582 unbindProgram(*inspectorProgram); 583 } 584 585 bool InspectorCanvasAgent::isWebGLProgramDisabled(WebGLProgram& program) 590 String identifier = unbindProgram(*inspectorProgram); 591 m_frontendDispatcher->programDeleted(identifier); 592 } 593 594 bool InspectorCanvasAgent::isShaderProgramDisabled(WebGLProgram& program) 586 595 { 587 596 auto inspectorProgram = findInspectorProgram(program); … … 593 602 } 594 603 595 bool InspectorCanvasAgent::is WebGLProgramHighlighted(WebGLProgram& program)604 bool InspectorCanvasAgent::isShaderProgramHighlighted(WebGLProgram& program) 596 605 { 597 606 auto inspectorProgram = findInspectorProgram(program); … … 641 650 notifyDeviceForSwapChain(newSwapChain); 642 651 } 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 }675 652 #endif 676 653 … … 718 695 } 719 696 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() 697 void InspectorCanvasAgent::clearCanvasData() 732 698 { 733 699 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { … … 737 703 738 704 m_identifierToInspectorCanvas.clear(); 705 #if ENABLE(WEBGL) 706 m_identifierToInspectorProgram.clear(); 739 707 m_removedCanvasIdentifiers.clear(); 708 #endif 709 740 710 if (m_canvasDestroyedTimer.isActive()) 741 711 m_canvasDestroyedTimer.stop(); 742 743 m_identifierToInspectorProgram.clear();744 m_removedProgramIdentifiers.clear();745 if (m_programDestroyedTimer.isActive())746 m_programDestroyedTimer.stop();747 712 } 748 713 … … 841 806 #endif 842 807 843 void InspectorCanvasAgent::unbindProgram(InspectorShaderProgram& inspectorProgram) 808 #if ENABLE(WEBGL) 809 String InspectorCanvasAgent::unbindProgram(InspectorShaderProgram& inspectorProgram) 844 810 { 845 811 String identifier = inspectorProgram.identifier(); 846 812 m_identifierToInspectorProgram.remove(identifier); 847 813 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; 855 815 } 856 816 … … 865 825 } 866 826 867 #if ENABLE(WEBGL)868 827 RefPtr<InspectorShaderProgram> InspectorCanvasAgent::findInspectorProgram(WebGLProgram& program) 869 828 { 870 829 for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) { 871 if ( inspectorProgram->program() == &program)830 if (&inspectorProgram->program() == &program) 872 831 return inspectorProgram; 873 832 } … … 876 835 #endif 877 836 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 #endif888 889 837 } // namespace WebCore -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h
r250114 r250139 34 34 #include <JavaScriptCore/InspectorFrontendDispatchers.h> 35 35 #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 37 44 38 45 namespace Inspector { … … 43 50 44 51 class CanvasRenderingContext; 45 class InspectorShaderProgram;46 52 #if ENABLE(WEBGL) 47 53 class WebGLProgram; … … 51 57 class GPUCanvasContext; 52 58 class WebGPUDevice; 53 class WebGPUPipeline;54 59 class WebGPUSwapChain; 55 60 #endif … … 79 84 void startRecording(ErrorString&, const String& canvasId, const int* frameCount, const int* memoryLimit); 80 85 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*); 82 87 void updateShader(ErrorString&, const String& programId, const String& shaderType, const String& source); 83 88 void setShaderProgramDisabled(ErrorString&, const String& programId, bool disabled); … … 99 104 #if ENABLE(WEBGL) 100 105 void didEnableExtension(WebGLRenderingContextBase&, const String&); 101 void didCreate WebGLProgram(WebGLRenderingContextBase&, WebGLProgram&);102 void willDe stroyWebGLProgram(WebGLProgram&);103 bool is WebGLProgramDisabled(WebGLProgram&);104 bool is WebGLProgramHighlighted(WebGLProgram&);106 void didCreateProgram(WebGLRenderingContextBase&, WebGLProgram&); 107 void willDeleteProgram(WebGLProgram&); 108 bool isShaderProgramDisabled(WebGLProgram&); 109 bool isShaderProgramHighlighted(WebGLProgram&); 105 110 #endif 106 111 #if ENABLE(WEBGPU) … … 108 113 void willDestroyWebGPUDevice(WebGPUDevice&); 109 114 void willConfigureSwapChain(GPUCanvasContext&, WebGPUSwapChain&); 110 void didCreateWebGPUPipeline(WebGPUDevice&, WebGPUPipeline&);111 void willDestroyWebGPUPipeline(WebGPUPipeline&);112 115 #endif 113 116 … … 121 124 122 125 void canvasDestroyedTimerFired(); 123 void programDestroyedTimerFired(); 124 void reset(); 125 126 void clearCanvasData(); 126 127 InspectorCanvas& bindCanvas(CanvasRenderingContext&, bool captureBacktrace); 127 128 #if ENABLE(WEBGPU) … … 135 136 #endif 136 137 137 void unbindProgram(InspectorShaderProgram&); 138 #if ENABLE(WEBGL) 139 String unbindProgram(InspectorShaderProgram&); 138 140 RefPtr<InspectorShaderProgram> assertInspectorProgram(ErrorString&, const String& programId); 139 #if ENABLE(WEBGL)140 141 RefPtr<InspectorShaderProgram> findInspectorProgram(WebGLProgram&); 141 #endif142 #if ENABLE(WEBGPU)143 RefPtr<InspectorShaderProgram> findInspectorProgram(WebGPUPipeline&);144 142 #endif 145 143 … … 151 149 152 150 HashMap<String, RefPtr<InspectorCanvas>> m_identifierToInspectorCanvas; 151 #if ENABLE(WEBGL) 152 HashMap<String, RefPtr<InspectorShaderProgram>> m_identifierToInspectorProgram; 153 #endif 153 154 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;159 155 160 156 Optional<size_t> m_recordingAutoCaptureFrameCount; 157 158 Timer m_canvasDestroyedTimer; 161 159 }; 162 160 -
trunk/Source/WebCore/platform/graphics/gpu/GPUComputePipeline.h
r250114 r250139 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUPipeline.h"31 #include "GPUProgrammableStageDescriptor.h"32 30 #include "WHLSLPrepare.h" 33 31 #include <wtf/RefCounted.h> … … 41 39 class GPUDevice; 42 40 class GPUErrorScopes; 43 class GPUPipelineLayout;44 41 45 42 struct GPUComputePipelineDescriptor; … … 48 45 using PlatformComputePipelineSmartPtr = RetainPtr<MTLComputePipelineState>; 49 46 50 class GPUComputePipeline final : public GPUPipeline{47 class GPUComputePipeline : public RefCounted<GPUComputePipeline> { 51 48 public: 52 virtual ~GPUComputePipeline();53 54 49 static RefPtr<GPUComputePipeline> tryCreate(const GPUDevice&, const GPUComputePipelineDescriptor&, GPUErrorScopes&); 55 56 bool isComputePipeline() const { return true; }57 58 bool recompile(const GPUDevice&, GPUProgrammableStageDescriptor&& computeStage);59 50 60 51 const PlatformComputePipeline* platformComputePipeline() const { return m_platformComputePipeline.get(); } … … 63 54 64 55 private: 65 GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions , GPUPipelineLayout&);56 GPUComputePipeline(PlatformComputePipelineSmartPtr&&, WHLSL::ComputeDimensions); 66 57 67 58 PlatformComputePipelineSmartPtr m_platformComputePipeline; 68 59 WHLSL::ComputeDimensions m_computeDimensions { 0, 0, 0 }; 69 70 // Preserved for Web Inspector recompilation.71 RefPtr<GPUPipelineLayout> m_layout;72 60 }; 73 61 74 62 } // namespace WebCore 75 63 76 SPECIALIZE_TYPE_TRAITS_GPUPIPELINE(WebCore::GPUComputePipeline, isComputePipeline())77 78 64 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/platform/graphics/gpu/GPUProgrammableStageDescriptor.h
r250114 r250139 39 39 40 40 struct GPUProgrammableStageDescriptor : GPUProgrammableStageDescriptorBase { 41 GPUProgrammableStageDescriptor(Ref< GPUShaderModule>&& module, const GPUProgrammableStageDescriptorBase& base)41 GPUProgrammableStageDescriptor(Ref<const GPUShaderModule>&& module, const GPUProgrammableStageDescriptorBase& base) 42 42 : GPUProgrammableStageDescriptorBase(base) 43 43 , module { WTFMove(module) } … … 45 45 } 46 46 47 Ref< GPUShaderModule> module;47 Ref<const GPUShaderModule> module; 48 48 }; 49 49 -
trunk/Source/WebCore/platform/graphics/gpu/GPURenderPipeline.h
r250114 r250139 28 28 #if ENABLE(WEBGPU) 29 29 30 #include "GPUPipeline.h"31 #include "GPUProgrammableStageDescriptor.h"32 30 #include "GPURenderPipelineDescriptor.h" 33 31 #include <wtf/Optional.h> … … 49 47 using PlatformRenderPipelineSmartPtr = RetainPtr<MTLRenderPipelineState>; 50 48 51 class GPURenderPipeline final : public GPUPipeline{49 class GPURenderPipeline : public RefCounted<GPURenderPipeline> { 52 50 public: 53 virtual ~GPURenderPipeline();54 55 51 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);60 52 61 53 #if USE(METAL) … … 68 60 private: 69 61 #if USE(METAL) 70 GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPUPrimitiveTopology, Optional<GPUIndexFormat> , GPUPipelineLayout&, const GPURenderPipelineDescriptorBase&);62 GPURenderPipeline(RetainPtr<MTLDepthStencilState>&&, PlatformRenderPipelineSmartPtr&&, GPUPrimitiveTopology, Optional<GPUIndexFormat>); 71 63 72 64 RetainPtr<MTLDepthStencilState> m_depthStencilState; … … 75 67 GPUPrimitiveTopology m_primitiveTopology; 76 68 Optional<GPUIndexFormat> m_indexFormat; 77 78 // Preserved for Web Inspector recompilation.79 RefPtr<GPUPipelineLayout> m_layout;80 GPURenderPipelineDescriptorBase m_renderDescriptorBase;81 69 }; 82 70 83 71 } // namespace WebCore 84 72 85 SPECIALIZE_TYPE_TRAITS_GPUPIPELINE(WebCore::GPURenderPipeline, isRenderPipeline())86 87 73 #endif // ENABLE(WEBGPU) -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPUComputePipelineMetal.mm
r250114 r250139 32 32 #import "GPUDevice.h" 33 33 #import "GPUErrorScopes.h" 34 #import "GPUPipelineLayout.h"35 34 #import "GPUPipelineMetalConvertLayout.h" 36 35 #import "WHLSLPrepare.h" … … 196 195 return nullptr; 197 196 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 200 GPUComputePipeline::GPUComputePipeline(RetainPtr<MTLComputePipelineState>&& pipeline, WHLSL::ComputeDimensions computeDimensions) 201 : m_platformComputePipeline(WTFMove(pipeline)) 205 202 , 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 { 225 204 } 226 205 -
trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm
r250114 r250139 33 33 #import "GPULimits.h" 34 34 #import "GPUPipelineMetalConvertLayout.h" 35 #import "GPURenderPipelineDescriptor.h"36 35 #import "GPUUtils.h" 37 36 #import "WHLSLPrepare.h" … … 485 484 } 486 485 487 static RetainPtr<MTLRenderPipelineState> tryCreateMtlRenderPipelineState(const GPU Device& device, const GPURenderPipelineDescriptor& descriptor, GPUErrorScopes& errorScopes)486 static RetainPtr<MTLRenderPipelineState> tryCreateMtlRenderPipelineState(const GPURenderPipelineDescriptor& descriptor, const GPUDevice& device, GPUErrorScopes& errorScopes) 488 487 { 489 488 if (!device.platformDevice()) { … … 524 523 // FIXME: https://bugs.webkit.org/show_bug.cgi?id=198387 depthStencilAttachmentDescriptor isn't implemented yet for WHLSL compiler. 525 524 526 auto pipeline = tryCreateMtlRenderPipelineState(de vice, descriptor, errorScopes);525 auto pipeline = tryCreateMtlRenderPipelineState(descriptor, device, errorScopes); 527 526 if (!pipeline) 528 527 return nullptr; 529 528 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 532 GPURenderPipeline::GPURenderPipeline(RetainPtr<MTLDepthStencilState>&& depthStencil, RetainPtr<MTLRenderPipelineState>&& pipeline, GPUPrimitiveTopology topology, Optional<GPUIndexFormat> format) 533 : m_depthStencilState(WTFMove(depthStencil)) 537 534 , m_platformRenderPipeline(WTFMove(pipeline)) 538 535 , m_primitiveTopology(topology) 539 536 , 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 { 559 538 } 560 539 -
trunk/Source/WebInspectorUI/ChangeLog
r250118 r250139 1 2019-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 1 13 2019-09-19 Joseph Pecoraro <pecoraro@apple.com> 2 14 -
trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
r250114 r250139 267 267 localizedStrings["Compression"] = "Compression"; 268 268 localizedStrings["Compression:"] = "Compression:"; 269 localizedStrings["Compute"] = "Compute";270 localizedStrings["Compute Pipeline %d"] = "Compute Pipeline %d";271 localizedStrings["Compute Shader"] = "Compute Shader";272 269 localizedStrings["Computed"] = "Computed"; 273 270 localizedStrings["Condition"] = "Condition"; … … 467 464 localizedStrings["Entered Full-Screen Mode"] = "Entered Full-Screen Mode"; 468 465 localizedStrings["Entire Recording"] = "Entire Recording"; 469 localizedStrings["Entry point: "] = "Entry point: ";470 466 localizedStrings["Error"] = "Error"; 471 467 localizedStrings["Error: "] = "Error: "; … … 886 882 localizedStrings["Remove this breakpoint action"] = "Remove this breakpoint action"; 887 883 localizedStrings["Removed descendant "] = "Removed descendant "; 888 localizedStrings["Render Pipeline %d"] = "Render Pipeline %d";889 884 localizedStrings["Rendering Frames"] = "Rendering Frames"; 890 885 localizedStrings["Repeating Linear Gradient"] = "Repeating Linear Gradient"; … … 1003 998 localizedStrings["Setter"] = "Setter"; 1004 999 localizedStrings["Settings"] = "Settings"; 1000 localizedStrings["Shader"] = "Shader"; 1005 1001 localizedStrings["Shader Programs"] = "Shader Programs"; 1006 1002 localizedStrings["Shadow Content"] = "Shadow Content"; -
trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js
r250114 r250139 235 235 } 236 236 237 programCreated(canvasIdentifier, programIdentifier , programType)237 programCreated(canvasIdentifier, programIdentifier) 238 238 { 239 239 let canvas = this._canvasIdentifierMap.get(canvasIdentifier); … … 244 244 console.assert(!this._shaderProgramIdentifierMap.has(programIdentifier), `ShaderProgram already exists with id ${programIdentifier}.`); 245 245 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); 251 247 this._shaderProgramIdentifierMap.set(program.identifier, program); 252 248 -
trunk/Source/WebInspectorUI/UserInterface/Models/Canvas.js
r250114 r250139 46 46 this._recordingCollection = new WI.RecordingCollection; 47 47 48 this._nextShaderProgramDisplayNumber = null;48 this._nextShaderProgramDisplayNumber = 1; 49 49 50 50 this._requestNodePromise = null; … … 410 410 } 411 411 412 nextShaderProgramDisplayNumber ForProgramType(programType)412 nextShaderProgramDisplayNumber() 413 413 { 414 414 // Called from WI.ShaderProgram. 415 415 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++; 421 417 } 422 418 }; -
trunk/Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js
r250114 r250139 26 26 WI.ShaderProgram = class ShaderProgram extends WI.Object 27 27 { 28 constructor(identifier, programType,canvas)28 constructor(identifier, canvas) 29 29 { 30 30 console.assert(identifier); 31 console.assert(Object.values(ShaderProgram.ProgramType).includes(programType));32 31 console.assert(canvas instanceof WI.Canvas); 33 console.assert(ShaderProgram.contextTypeSupportsProgramType(canvas.contextType, programType));34 32 35 33 super(); 36 34 37 35 this._identifier = identifier; 38 this._programType = programType;39 36 this._canvas = canvas; 37 this._uniqueDisplayNumber = canvas.nextShaderProgramDisplayNumber(); 40 38 this._disabled = false; 41 }42 43 // Static44 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.Compute54 || 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.Fragment69 || shaderType === ShaderProgram.ShaderType.Vertex;70 }71 72 console.assert();73 return false;74 39 } 75 40 … … 77 42 78 43 get identifier() { return this._identifier; } 79 get programType() { return this._programType; }80 44 get canvas() { return this._canvas; } 81 45 82 46 get displayName() 83 47 { 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); 105 49 } 106 50 … … 112 56 set disabled(disabled) 113 57 { 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 120 58 if (this._disabled === disabled) 121 59 return; … … 128 66 } 129 67 130 request ShaderSource(shaderType,callback)68 requestVertexShaderSource(callback) 131 69 { 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); 145 71 } 146 72 147 updateShader(shaderType, source)73 requestFragmentShaderSource(callback) 148 74 { 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 } 151 77 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); 153 86 } 154 87 155 88 showHighlight() 156 89 { 157 cons ole.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 }); 161 94 } 162 95 163 96 hideHighlight() 164 97 { 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 } 167 103 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 }); 169 123 } 170 124 }; 171 125 172 WI.ShaderProgram.ProgramType = {173 Compute: "compute",174 Render: "render",175 };176 177 126 WI.ShaderProgram.ShaderType = { 178 Compute: "compute", 179 Fragment: "fragment", 180 Vertex: "vertex", 127 Fragment: "shader-type-fragment", 128 Vertex: "shader-type-vertex", 181 129 }; 182 130 -
trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js
r250114 r250139 68 68 } 69 69 70 programCreated(canvasId, programId , programType)70 programCreated(canvasId, programId) 71 71 { 72 WI.canvasManager.programCreated(canvasId, programId , programType);72 WI.canvasManager.programCreated(canvasId, programId); 73 73 } 74 74 -
trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js
r250114 r250139 683 683 CodeMirror.defineMIME(type, {name: "javascript", json: true}); 684 684 }); 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");690 685 })(); 691 686 -
trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.css
r250114 r250139 24 24 */ 25 25 26 .content-view.shader-program > .shader { 27 display: flex; 28 flex-direction: column; 26 .content-view.shader-program > .text-editor.shader { 29 27 position: absolute; 30 28 top: 0; 31 29 bottom: 0; 30 31 --border-start-style: 1px solid lightgrey; 32 32 } 33 33 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 { 34 body[dir=ltr] .content-view.shader-program > .text-editor.shader.vertex, 35 body[dir=rtl] .content-view.shader-program > .text-editor.shader.fragment { 41 36 width: calc(50% - 1px); 42 37 left: 0; 43 38 } 44 39 45 body[dir=ltr] .content-view.shader-program > . shader.fragment,46 body[dir=rtl] .content-view.shader-program > . shader.vertex {40 body[dir=ltr] .content-view.shader-program > .text-editor.shader.fragment, 41 body[dir=rtl] .content-view.shader-program > .text-editor.shader.vertex { 47 42 width: calc(50% + 1px); 48 43 right: 0; 49 44 } 50 45 51 .content-view.shader-program > .shader +.shader {52 border-left: 1px solid var(--border-color);46 body[dir=ltr] .content-view.shader-program > .text-editor.shader + .text-editor.shader { 47 border-left: var(--border-start-style); 53 48 } 54 49 55 .content-view.shader-program > .shader > header > * { 50 body[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 { 56 55 padding: 2px 4px; 56 background-color: hsl(0, 0%, 95%); 57 57 border-bottom: 1px solid lightgrey; 58 58 } 59 59 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; 62 62 } 63 63 64 64 @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 { 66 70 background-color: var(--background-color); 67 71 border-bottom-color: var(--text-color-quaternary); -
trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.js
r250114 r250139 32 32 super(shaderProgram); 33 33 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 40 34 let contentDidChangeDebouncer = new Debouncer((event) => { 41 35 this._contentDidChange(event); 42 36 }); 43 37 44 this.element.classList.add("shader-program" , this.representedObject.programType);38 this.element.classList.add("shader-program"); 45 39 46 40 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 54 41 let textEditor = new WI.TextEditor; 55 42 textEditor.readOnly = false; … … 59 46 contentDidChangeDebouncer.delayForTime(250, event); 60 47 }, this); 48 textEditor.element.classList.add("shader"); 49 50 let shaderTypeContainer = textEditor.element.insertAdjacentElement("afterbegin", document.createElement("div")); 51 shaderTypeContainer.classList.add("type-title"); 61 52 62 53 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"); 66 58 break; 67 59 68 60 case WI.ShaderProgram.ShaderType.Fragment: 69 61 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"); 76 64 break; 77 65 } 78 66 79 67 this.addSubview(textEditor); 80 container.appendChild(textEditor.element); 81 container.classList.add("shader", shaderType); 82 83 return {container, textEditor}; 68 return textEditor; 84 69 }; 85 70 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; 116 74 } 117 75 … … 122 80 super.shown(); 123 81 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 }); 136 92 } 137 93 138 94 hidden() 139 95 { 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(); 150 98 151 99 super.hidden(); … … 159 107 get saveData() 160 108 { 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) 167 113 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);186 114 187 115 return { 188 url: WI.FileUtilities.inspectorURLForFilename(filename + extension),116 url: WI.FileUtilities.inspectorURLForFilename(filename + ".glsl"), 189 117 content: this._lastActiveEditor.string, 190 118 forceSaveAs: true, … … 244 172 // Private 245 173 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 305 174 _editorFocused(event) 306 175 { … … 329 198 _contentDidChange(event) 330 199 { 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); 346 204 } 347 205 }; -
trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramTreeElement.js
r250114 r250139 33 33 super("shader-program", shaderProgram.displayName, subtitle, shaderProgram); 34 34 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; 43 39 } 44 40 … … 49 45 super.onattach(); 50 46 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); 55 48 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)); 59 51 } 60 52 61 53 ondetach() 62 54 { 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); 67 56 68 57 super.ondetach(); … … 71 60 canSelectOnMouseDown(event) 72 61 { 73 if (this._disabledImageElement && this._disabledImageElement.contains(event.target))62 if (this._disabledImageElement.contains(event.target)) 74 63 return false; 75 64 return super.canSelectOnMouseDown(event); … … 78 67 populateContextMenu(contextMenu, event) 79 68 { 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 }); 87 73 88 contextMenu.appendSeparator(); 89 } 74 contextMenu.appendSeparator(); 90 75 91 76 super.populateContextMenu(contextMenu, event);
Note: See TracChangeset
for help on using the changeset viewer.