Changeset 250874 in webkit


Ignore:
Timestamp:
Oct 8, 2019 4:15:59 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: Canvas: modifications to shader modules can be shared between vertex/fragment shaders
https://bugs.webkit.org/show_bug.cgi?id=202031

Reviewed by Dean Jackson.

Source/JavaScriptCore:

  • inspector/protocol/Canvas.json:

Create a distinct ShaderProgram type so that additional data can be bundled and sent to
the frontend as part of the programCreated event without having to worry about having too
many arguments.

Source/WebCore:

Test: inspector/canvas/updateShader-webgpu-sharedVertexFragment.html

  • Modules/webgpu/WebGPUPipeline.h:
  • Modules/webgpu/WebGPUComputePipeline.cpp:

(WebCore::WebGPUComputePipeline::cloneShaderModules): Added.
(WebCore::WebGPUComputePipeline::recompile):

  • Modules/webgpu/WebGPURenderPipeline.cpp:

(WebCore::WebGPURenderPipeline::cloneShaderModules): Added.
(WebCore::WebGPURenderPipeline::recompile):
Recreate the vertex/fragment/compute shader module(s) when recompiling so that modifications
to it via this pipeline don't affect other pipelines that also use the same shader module.

  • inspector/InspectorShaderProgram.h:
  • inspector/InspectorShaderProgram.cpp:

(WebCore::InspectorShaderProgram::updateShader):
(WebCore::InspectorShaderProgram::buildObjectForShaderProgram): Added.

  • inspector/agents/InspectorCanvasAgent.cpp:

(WebCore::InspectorCanvasAgent::didCreateWebGLProgram):
(WebCore::InspectorCanvasAgent::didCreateWebGPUPipeline):
Include as part of the Canvas.event.programCreated payload a flag indicating whether the
vertex shader module and fragment shader module are the same for WebGPURenderPipelines.

Source/WebInspectorUI:

If the vertex and fragment shaders share the same source module for a WebGPU shader pipeline,
only display a single editable content view for that shader pipeline in the Canvas Tab.

  • UserInterface/Models/ShaderProgram.js:

(WI.ShaderProgram):
(WI.ShaderProgram.prototype.get sharesVertexFragmentShader): Added.

  • UserInterface/Controllers/CanvasManager.js:

(WI.CanvasManager.prototype.programCreated):

  • UserInterface/Protocol/CanvasObserver.js:

(WI.CanvasObserver.prototype.programCreated):

  • UserInterface/Views/ShaderProgramContentView.js:

(WI.ShaderProgramContentView):
(WI.ShaderProgramContentView.prototype.shown):
(WI.ShaderProgramContentView.prototype.hidden):
(WI.ShaderProgramContentView.prototype._refreshContent):

  • UserInterface/Views/ShaderProgramContentView.css:

(.content-view.shader-program > .shader.compute, .content-view.shader-program > .shader.vertex.shares-vertex-fragment-shader): Added.
(body[dir=ltr] .content-view.shader-program > .shader.vertex:not(.shares-vertex-fragment-shader), body[dir=rtl] .content-view.shader-program > .shader.fragment): Added.
(body[dir=ltr] .content-view.shader-program > .shader.fragment, body[dir=rtl] .content-view.shader-program > .shader.vertex:not(.shares-vertex-fragment-shader)): Added.
(.content-view.shader-program > .shader.compute): Deleted.
(body[dir=ltr] .content-view.shader-program > .shader.vertex, body[dir=rtl] .content-view.shader-program > .shader.fragment): Deleted.
(body[dir=ltr] .content-view.shader-program > .shader.fragment, body[dir=rtl] .content-view.shader-program > .shader.vertex): Deleted.

  • UserInterface/Views/CodeMirrorAdditions.js:

Replace the vertex/fragment specific MIME types with a more general "render" MIME type.

  • Localizations/en.lproj/localizedStrings.js:

LayoutTests:

  • inspector/canvas/updateShader-webgpu-sharedVertexFragment.html: Added.
  • inspector/canvas/updateShader-webgpu-sharedVertexFragment-expected.txt: Added.
  • platform/gtk/TestExpectations:
  • platform/ios/TestExpectations:
  • platform/mac-wk1/TestExpectations:
  • platform/mac/TestExpectations:
  • platform/win/TestExpectations:
  • platform/wincairo/TestExpectations:
  • platform/wpe/TestExpectations:
Location:
trunk
Files:
2 added
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r250872 r250874  
     12019-10-08  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Canvas: modifications to shader modules can be shared between vertex/fragment shaders
     4        https://bugs.webkit.org/show_bug.cgi?id=202031
     5
     6        Reviewed by Dean Jackson.
     7
     8        * inspector/canvas/updateShader-webgpu-sharedVertexFragment.html: Added.
     9        * inspector/canvas/updateShader-webgpu-sharedVertexFragment-expected.txt: Added.
     10
     11        * platform/gtk/TestExpectations:
     12        * platform/ios/TestExpectations:
     13        * platform/mac-wk1/TestExpectations:
     14        * platform/mac/TestExpectations:
     15        * platform/win/TestExpectations:
     16        * platform/wincairo/TestExpectations:
     17        * platform/wpe/TestExpectations:
     18
    1192019-10-08  Yury Semikhatsky  <yurys@chromium.org>
    220
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r250714 r250874  
    11541154webkit.org/b/191005 inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    11551155webkit.org/b/191005 inspector/canvas/updateShader-webgpu.html [ Skip ]
     1156webkit.org/b/191005 inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    11561157
    11571158# No support for resource load statistics yet
  • trunk/LayoutTests/platform/ios/TestExpectations

    r250714 r250874  
    5050inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    5151inspector/canvas/updateShader-webgpu.html [ Skip ]
     52inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    5253
    5354# Encrypted Media Extensions are not enabled
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r250824 r250874  
    5555inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    5656inspector/canvas/updateShader-webgpu.html [ Skip ]
     57inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    5758
    5859# Media Stream API testing is not supported for WK1 yet.
  • trunk/LayoutTests/platform/mac/TestExpectations

    r250781 r250874  
    17841784webkit.org/b/199275 [ HighSierra ] inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    17851785webkit.org/b/199275 [ HighSierra ] inspector/canvas/updateShader-webgpu.html [ Skip ]
     1786webkit.org/b/199275 [ HighSierra ] inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    17861787
    17871788webkit.org/b/189680 platform/mac/media/audio-session-category-video-paused.html [ Pass Timeout ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r250786 r250874  
    42694269inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    42704270inspector/canvas/updateShader-webgpu.html [ Skip ]
     4271inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    42714272
    42724273webkit.org/b/191194 fast/block/basic/inline-content-with-floating-image.html [ Failure ]
  • trunk/LayoutTests/platform/wincairo/TestExpectations

    r250413 r250874  
    301301inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    302302inspector/canvas/updateShader-webgpu.html [ Skip ]
     303inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    303304
    304305# WIRELESS_PLAYBACK_TARGET is disabled
  • trunk/LayoutTests/platform/wpe/TestExpectations

    r250714 r250874  
    307307inspector/canvas/shaderProgram-add-remove-webgpu.html [ Skip ]
    308308inspector/canvas/updateShader-webgpu.html [ Skip ]
     309inspector/canvas/updateShader-webgpu-sharedVertexFragment.html [ Skip ]
    309310
    310311# Skipped due to untestable DRM key system. ClearKey counterparts are tested instead.
  • trunk/Source/JavaScriptCore/ChangeLog

    r250860 r250874  
     12019-10-08  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Canvas: modifications to shader modules can be shared between vertex/fragment shaders
     4        https://bugs.webkit.org/show_bug.cgi?id=202031
     5
     6        Reviewed by Dean Jackson.
     7
     8        * inspector/protocol/Canvas.json:
     9        Create a distinct `ShaderProgram` type so that additional data can be bundled and sent to
     10        the frontend as part of the `programCreated` event without having to worry about having too
     11        many arguments.
     12
    1132019-10-08  Alexey Shvayka  <shvaikalesh@gmail.com>
    214
  • trunk/Source/JavaScriptCore/inspector/protocol/Canvas.json

    r250258 r250874  
    5858                { "name": "backtrace", "type": "array", "items": { "$ref": "Console.CallFrame" }, "optional": true, "description": "Backtrace that was captured when this canvas context was created." }
    5959            ]
     60        },
     61        {
     62            "id": "ShaderProgram",
     63            "type": "object",
     64            "description": "Information about a WebGL/WebGL2 shader program or WebGPU shader pipeline.",
     65            "properties": [
     66                { "name": "programId", "$ref": "ProgramId" },
     67                { "name": "programType", "$ref": "ProgramType" },
     68                { "name": "canvasId", "$ref": "CanvasId"} ,
     69                { "name": "sharesVertexFragmentShader", "type": "boolean", "optional": true, "description": "Indicates whether the vertex and fragment shader modules are the same object for a render shader pipleine for a WebGPU device." }
     70            ]
    6071        }
    6172    ],
     
    228239            "name": "programCreated",
    229240            "parameters": [
    230                 { "name": "canvasId", "$ref": "CanvasId"} ,
    231                 { "name": "programId", "$ref": "ProgramId" },
    232                 { "name": "programType", "$ref": "ProgramType" }
     241                { "name": "shaderProgram", "$ref": "ShaderProgram" }
    233242            ]
    234243        },
  • trunk/Source/WebCore/ChangeLog

    r250863 r250874  
     12019-10-08  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Canvas: modifications to shader modules can be shared between vertex/fragment shaders
     4        https://bugs.webkit.org/show_bug.cgi?id=202031
     5
     6        Reviewed by Dean Jackson.
     7
     8        Test: inspector/canvas/updateShader-webgpu-sharedVertexFragment.html
     9
     10        * Modules/webgpu/WebGPUPipeline.h:
     11        * Modules/webgpu/WebGPUComputePipeline.cpp:
     12        (WebCore::WebGPUComputePipeline::cloneShaderModules): Added.
     13        (WebCore::WebGPUComputePipeline::recompile):
     14        * Modules/webgpu/WebGPURenderPipeline.cpp:
     15        (WebCore::WebGPURenderPipeline::cloneShaderModules): Added.
     16        (WebCore::WebGPURenderPipeline::recompile):
     17        Recreate the vertex/fragment/compute shader module(s) when recompiling so that modifications
     18        to it via this pipeline don't affect other pipelines that also use the same shader module.
     19
     20        * inspector/InspectorShaderProgram.h:
     21        * inspector/InspectorShaderProgram.cpp:
     22        (WebCore::InspectorShaderProgram::updateShader):
     23        (WebCore::InspectorShaderProgram::buildObjectForShaderProgram): Added.
     24        * inspector/agents/InspectorCanvasAgent.cpp:
     25        (WebCore::InspectorCanvasAgent::didCreateWebGLProgram):
     26        (WebCore::InspectorCanvasAgent::didCreateWebGPUPipeline):
     27        Include as part of the `Canvas.event.programCreated` payload a flag indicating whether the
     28        vertex shader module and fragment shader module are the same for `WebGPURenderPipeline`s.
     29
    1302019-10-08  Timothy Hatcher  <timothy@apple.com>
    231
  • trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.cpp

    r250258 r250874  
    3333#include "GPUPipeline.h"
    3434#include "GPUProgrammableStageDescriptor.h"
     35#include "GPUShaderModule.h"
     36#include "GPUShaderModuleDescriptor.h"
    3537#include "WebGPUDevice.h"
     38#include "WebGPUShaderModule.h"
    3639#include <wtf/Optional.h>
    3740#include <wtf/Ref.h>
     
    5356WebGPUComputePipeline::~WebGPUComputePipeline() = default;
    5457
     58bool WebGPUComputePipeline::cloneShaderModules(const WebGPUDevice& device)
     59{
     60    if (m_computeShader) {
     61        if (auto& webGPUComputeShaderModule = m_computeShader.value().module) {
     62            const auto& computeSource = webGPUComputeShaderModule->source();
     63            webGPUComputeShaderModule = WebGPUShaderModule::create(GPUShaderModule::tryCreate(device.device(), { computeSource }), computeSource);
     64            return true;
     65        }
     66    }
     67    return false;
     68}
     69
    5570bool WebGPUComputePipeline::recompile(const WebGPUDevice& device)
    5671{
    5772    if (m_computePipeline && m_computeShader) {
    5873        if (auto& webGPUComputeShaderModule = m_computeShader.value().module) {
     74            // Recreate the shader module so that modifications to it via this pipeline don't affect
     75            // other pipelines that also use the same shader module.
     76
    5977            if (auto* gpuComputeShaderModule = webGPUComputeShaderModule->module()) {
    6078                GPUProgrammableStageDescriptor computeStage(makeRef(*gpuComputeShaderModule), { m_computeShader.value().entryPoint });
  • trunk/Source/WebCore/Modules/webgpu/WebGPUComputePipeline.h

    r250258 r250874  
    5050    Optional<WebGPUPipeline::ShaderData> computeShader() const { return m_computeShader; }
    5151
     52    bool cloneShaderModules(const WebGPUDevice&);
    5253    bool recompile(const WebGPUDevice&);
    5354
  • trunk/Source/WebCore/Modules/webgpu/WebGPUPipeline.h

    r250824 r250874  
    5757    };
    5858
     59    virtual bool cloneShaderModules(const WebGPUDevice&) = 0;
    5960    virtual bool recompile(const WebGPUDevice&) = 0;
    6061
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.cpp

    r250258 r250874  
    3333#include "GPUProgrammableStageDescriptor.h"
    3434#include "GPURenderPipeline.h"
     35#include "GPUShaderModule.h"
     36#include "GPUShaderModuleDescriptor.h"
    3537#include "WebGPUDevice.h"
     38#include "WebGPUShaderModule.h"
    3639#include <wtf/Optional.h>
    3740#include <wtf/Ref.h>
     
    5356
    5457WebGPURenderPipeline::~WebGPURenderPipeline() = default;
     58
     59bool WebGPURenderPipeline::cloneShaderModules(const WebGPUDevice& device)
     60{
     61    if (m_vertexShader) {
     62        if (auto& webGPUVertexShaderModule = m_vertexShader.value().module) {
     63            bool sharesVertexFragmentShaderModule = m_fragmentShader && m_fragmentShader.value().module == webGPUVertexShaderModule;
     64
     65            const auto& vertexSource = webGPUVertexShaderModule->source();
     66            webGPUVertexShaderModule = WebGPUShaderModule::create(GPUShaderModule::tryCreate(device.device(), { vertexSource }), vertexSource);
     67
     68            if (!m_fragmentShader)
     69                return true;
     70
     71            if (auto& webGPUFragmentShaderModule = m_fragmentShader.value().module) {
     72                if (sharesVertexFragmentShaderModule)
     73                    webGPUFragmentShaderModule = webGPUVertexShaderModule;
     74                else {
     75                    const auto& fragmentSource = webGPUFragmentShaderModule->source();
     76                    webGPUFragmentShaderModule = WebGPUShaderModule::create(GPUShaderModule::tryCreate(device.device(), { fragmentSource }), fragmentSource);
     77                }
     78                return true;
     79            }
     80        }
     81    }
     82    return false;
     83}
    5584
    5685bool WebGPURenderPipeline::recompile(const WebGPUDevice& device)
  • trunk/Source/WebCore/Modules/webgpu/WebGPURenderPipeline.h

    r250258 r250874  
    5151    Optional<WebGPUPipeline::ShaderData> fragmentShader() const { return m_fragmentShader; }
    5252
     53    bool cloneShaderModules(const WebGPUDevice&);
    5354    bool recompile(const WebGPUDevice&);
    5455
  • trunk/Source/WebCore/inspector/InspectorShaderProgram.cpp

    r250258 r250874  
    216216            auto& pipeline = pipelineWrapper.get();
    217217            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;
     218                if (pipeline.cloneShaderModules(*device)) {
     219                    if (auto shaderData = shaderForType(pipeline, shaderType)) {
     220                        if (auto module = shaderData.value().module) {
     221                            module->update(*device, source);
     222                            if (pipeline.recompile(*device))
     223                                return true;
     224                        }
    223225                    }
    224226                }
     
    236238}
    237239
     240Ref<Inspector::Protocol::Canvas::ShaderProgram> InspectorShaderProgram::buildObjectForShaderProgram()
     241{
     242    bool sharesVertexFragmentShader = false;
     243
     244    using ProgramTypeType = Optional<Inspector::Protocol::Canvas::ProgramType>;
     245    auto programType = WTF::switchOn(m_program,
     246#if ENABLE(WEBGL)
     247        [&] (std::reference_wrapper<WebGLProgram>) -> ProgramTypeType {
     248            return Inspector::Protocol::Canvas::ProgramType::Render;
     249        },
     250#endif
     251#if ENABLE(WEBGPU)
     252        [&] (std::reference_wrapper<WebGPUPipeline> pipelineWrapper) -> ProgramTypeType {
     253            auto& pipeline = pipelineWrapper.get();
     254            if (is<WebGPUComputePipeline>(pipeline))
     255                return Inspector::Protocol::Canvas::ProgramType::Compute;
     256            if (is<WebGPURenderPipeline>(pipeline)) {
     257                auto& renderPipeline = downcast<WebGPURenderPipeline>(pipeline);
     258                auto vertexShader = renderPipeline.vertexShader();
     259                auto fragmentShader = renderPipeline.fragmentShader();
     260                if (vertexShader && fragmentShader && vertexShader.value().module == fragmentShader.value().module)
     261                    sharesVertexFragmentShader = true;
     262                return Inspector::Protocol::Canvas::ProgramType::Render;
     263            }
     264            return WTF::nullopt;
     265        },
     266#endif
     267        [&] (Monostate) -> ProgramTypeType {
     268#if ENABLE(WEBGL) || ENABLE(WEBGPU)
     269            ASSERT_NOT_REACHED();
     270#endif
     271            return WTF::nullopt;
     272        }
     273    );
     274    if (!programType) {
     275        ASSERT_NOT_REACHED();
     276        programType = Inspector::Protocol::Canvas::ProgramType::Render;
     277    }
     278
     279    auto payload = Inspector::Protocol::Canvas::ShaderProgram::create()
     280        .setProgramId(m_identifier)
     281        .setProgramType(programType.value())
     282        .setCanvasId(m_canvas.identifier())
     283        .release();
     284    if (sharesVertexFragmentShader)
     285        payload->setSharesVertexFragmentShader(true);
     286    return payload;
     287}
     288
    238289} // namespace WebCore
  • trunk/Source/WebCore/inspector/InspectorShaderProgram.h

    r250463 r250874  
    7272    void setHighlighted(bool value) { m_highlighted = value; }
    7373
     74    Ref<Inspector::Protocol::Canvas::ShaderProgram> buildObjectForShaderProgram();
     75
    7476private:
    7577#if ENABLE(WEBGL)
  • trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp

    r250839 r250874  
    569569        return;
    570570
    571     auto inspectorProgram = InspectorShaderProgram::create(program, *inspectorCanvas);
    572     String programIdentifier = inspectorProgram->identifier();
    573     m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram));
    574     m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier, Inspector::Protocol::Canvas::ProgramType::Render);
     571    auto inspectorProgramRef = InspectorShaderProgram::create(program, *inspectorCanvas);
     572    auto& inspectorProgram = inspectorProgramRef.get();
     573    m_identifierToInspectorProgram.set(inspectorProgram.identifier(), WTFMove(inspectorProgramRef));
     574    m_frontendDispatcher->programCreated(inspectorProgram.buildObjectForShaderProgram());
    575575}
    576576
     
    652652    ASSERT(pipeline.isValid());
    653653
    654     auto inspectorProgram = InspectorShaderProgram::create(pipeline, *inspectorCanvas);
    655     String programIdentifier = inspectorProgram->identifier();
    656     m_identifierToInspectorProgram.set(programIdentifier, WTFMove(inspectorProgram));
    657 
    658     Optional<Inspector::Protocol::Canvas::ProgramType> programType;
    659     if (is<WebGPUComputePipeline>(pipeline))
    660         programType = Inspector::Protocol::Canvas::ProgramType::Compute;
    661     else if (is<WebGPURenderPipeline>(pipeline))
    662         programType = Inspector::Protocol::Canvas::ProgramType::Render;
    663     ASSERT(programType);
    664 
    665     m_frontendDispatcher->programCreated(inspectorCanvas->identifier(), programIdentifier, programType.value());
     654    auto inspectorProgramRef = InspectorShaderProgram::create(pipeline, *inspectorCanvas);
     655    auto& inspectorProgram = inspectorProgramRef.get();
     656    m_identifierToInspectorProgram.set(inspectorProgram.identifier(), WTFMove(inspectorProgramRef));
     657    m_frontendDispatcher->programCreated(inspectorProgram.buildObjectForShaderProgram());
    666658}
    667659
  • trunk/Source/WebInspectorUI/ChangeLog

    r250859 r250874  
     12019-10-08  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Canvas: modifications to shader modules can be shared between vertex/fragment shaders
     4        https://bugs.webkit.org/show_bug.cgi?id=202031
     5
     6        Reviewed by Dean Jackson.
     7
     8        If the vertex and fragment shaders share the same source module for a WebGPU shader pipeline,
     9        only display a single editable content view for that shader pipeline in the Canvas Tab.
     10
     11        * UserInterface/Models/ShaderProgram.js:
     12        (WI.ShaderProgram):
     13        (WI.ShaderProgram.prototype.get sharesVertexFragmentShader): Added.
     14        * UserInterface/Controllers/CanvasManager.js:
     15        (WI.CanvasManager.prototype.programCreated):
     16        * UserInterface/Protocol/CanvasObserver.js:
     17        (WI.CanvasObserver.prototype.programCreated):
     18
     19        * UserInterface/Views/ShaderProgramContentView.js:
     20        (WI.ShaderProgramContentView):
     21        (WI.ShaderProgramContentView.prototype.shown):
     22        (WI.ShaderProgramContentView.prototype.hidden):
     23        (WI.ShaderProgramContentView.prototype._refreshContent):
     24        * UserInterface/Views/ShaderProgramContentView.css:
     25        (.content-view.shader-program > .shader.compute, .content-view.shader-program > .shader.vertex.shares-vertex-fragment-shader): Added.
     26        (body[dir=ltr] .content-view.shader-program > .shader.vertex:not(.shares-vertex-fragment-shader), body[dir=rtl] .content-view.shader-program > .shader.fragment): Added.
     27        (body[dir=ltr] .content-view.shader-program > .shader.fragment, body[dir=rtl] .content-view.shader-program > .shader.vertex:not(.shares-vertex-fragment-shader)): Added.
     28        (.content-view.shader-program > .shader.compute): Deleted.
     29        (body[dir=ltr] .content-view.shader-program > .shader.vertex, body[dir=rtl] .content-view.shader-program > .shader.fragment): Deleted.
     30        (body[dir=ltr] .content-view.shader-program > .shader.fragment, body[dir=rtl] .content-view.shader-program > .shader.vertex): Deleted.
     31
     32        * UserInterface/Views/CodeMirrorAdditions.js:
     33        Replace the vertex/fragment specific MIME types with a more general "render" MIME type.
     34
     35        * Localizations/en.lproj/localizedStrings.js:
     36
    1372019-10-08  Devin Rousso  <drousso@apple.com>
    238
  • trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js

    r250814 r250874  
    12321232localizedStrings["Vertex"] = "Vertex";
    12331233localizedStrings["Vertex Shader"] = "Vertex Shader";
     1234localizedStrings["Vertex/Fragment Shader"] = "Vertex/Fragment Shader";
    12341235localizedStrings["Very High"] = "Very High";
    12351236localizedStrings["View Image"] = "View Image";
  • trunk/Source/WebInspectorUI/UserInterface/Controllers/CanvasManager.js

    r250258 r250874  
    235235    }
    236236
    237     programCreated(canvasIdentifier, programIdentifier, programType)
    238     {
    239         let canvas = this._canvasIdentifierMap.get(canvasIdentifier);
    240         console.assert(canvas);
    241         if (!canvas)
    242             return;
    243 
    244         console.assert(!this._shaderProgramIdentifierMap.has(programIdentifier), `ShaderProgram already exists with id ${programIdentifier}.`);
    245 
    246         // COMPATIBILITY (iOS 13): `programType` did not exist yet.
     237    programCreated(shaderProgramPayload)
     238    {
     239        let canvas = this._canvasIdentifierMap.get(shaderProgramPayload.canvasId);
     240        console.assert(canvas);
     241        if (!canvas)
     242            return;
     243
     244        let programId = shaderProgramPayload.programId;
     245        console.assert(!this._shaderProgramIdentifierMap.has(programId), `ShaderProgram already exists with id ${programId}.`);
     246
     247        // COMPATIBILITY (iOS 13.0): `Canvas.ShaderProgram.programType` did not exist yet.
     248        let programType = shaderProgramPayload.programType;
    247249        if (!programType)
    248250            programType = WI.ShaderProgram.ProgramType.Render;
    249251
    250         let program = new WI.ShaderProgram(programIdentifier, programType, canvas);
     252        let options = {};
     253
     254        // COMPATIBILITY (iOS 13.0): `Canvas.ShaderProgram.sharesVertexFragmentShader` did not exist yet.
     255        if (shaderProgramPayload.sharesVertexFragmentShader)
     256            options.sharesVertexFragmentShader = true;
     257
     258        let program = new WI.ShaderProgram(programId, programType, canvas, options);
    251259        this._shaderProgramIdentifierMap.set(program.identifier, program);
    252260
  • trunk/Source/WebInspectorUI/UserInterface/Models/ShaderProgram.js

    r250258 r250874  
    2626WI.ShaderProgram = class ShaderProgram extends WI.Object
    2727{
    28     constructor(identifier, programType, canvas)
     28    constructor(identifier, programType, canvas, {sharesVertexFragmentShader} = {})
    2929    {
    3030        console.assert(identifier);
     
    3838        this._programType = programType;
    3939        this._canvas = canvas;
     40
     41        this._sharesVertexFragmentShader = !!sharesVertexFragmentShader;
     42        console.assert(!this._sharesVertexFragmentShader || (this._canvas.contextType === WI.Canvas.ContextType.WebGPU && this._programType === ShaderProgram.ProgramType.Render));
     43
    4044        this._disabled = false;
    4145    }
     
    7983    get programType() { return this._programType; }
    8084    get canvas() { return this._canvas; }
     85    get sharesVertexFragmentShader() { return this._sharesVertexFragmentShader; }
    8186
    8287    get displayName()
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/CanvasObserver.js

    r250258 r250874  
    6868    }
    6969
    70     programCreated(canvasId, programId, programType)
     70    programCreated(shaderProgram)
    7171    {
    72         WI.canvasManager.programCreated(canvasId, programId, programType);
     72        // COMPATIBILITY (iOS 13.0): `shaderProgram` replaced `canvasId` and `programId`.
     73        if (arguments.length === 2) {
     74            shaderProgram = {
     75                canvasId: arguments[0],
     76                programId: arguments[1],
     77            };
     78        }
     79        WI.canvasManager.programCreated(shaderProgram);
    7380    }
    7481
  • trunk/Source/WebInspectorUI/UserInterface/Views/CodeMirrorAdditions.js

    r250277 r250874  
    686686    // FIXME: Add WHLSL specific modes.
    687687    CodeMirror.defineMIME("x-pipeline/x-compute", CodeMirror.resolveMode("x-shader/x-vertex"));
    688     CodeMirror.defineMIME("x-pipeline/x-fragment", CodeMirror.resolveMode("x-shader/x-fragment"));
    689     CodeMirror.defineMIME("x-pipeline/x-vertex", CodeMirror.resolveMode("x-shader/x-vertex"));
     688    CodeMirror.defineMIME("x-pipeline/x-render", CodeMirror.resolveMode("x-shader/x-vertex"));
    690689})();
    691690
  • trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.css

    r250533 r250874  
    3232}
    3333
    34 .content-view.shader-program > .shader.compute {
     34.content-view.shader-program > .shader.compute,
     35.content-view.shader-program > .shader.vertex.shares-vertex-fragment-shader {
    3536    right: 0;
    3637    left: 0;
    3738}
    3839
    39 body[dir=ltr] .content-view.shader-program > .shader.vertex,
     40body[dir=ltr] .content-view.shader-program > .shader.vertex:not(.shares-vertex-fragment-shader),
    4041body[dir=rtl] .content-view.shader-program > .shader.fragment {
    4142    width: calc(50% - 1px);
     
    4445
    4546body[dir=ltr] .content-view.shader-program > .shader.fragment,
    46 body[dir=rtl] .content-view.shader-program > .shader.vertex {
     47body[dir=rtl] .content-view.shader-program > .shader.vertex:not(.shares-vertex-fragment-shader) {
    4748    width: calc(50% + 1px);
    4849    right: 0;
  • trunk/Source/WebInspectorUI/UserInterface/Views/ShaderProgramContentView.js

    r250277 r250874  
    3333
    3434        let isWebGPU = this.representedObject.canvas.contextType === WI.Canvas.ContextType.WebGPU;
     35        let sharesVertexFragmentShader = isWebGPU && this.representedObject.sharesVertexFragmentShader;
    3536
    3637        this._refreshButtonNavigationItem = new WI.ButtonNavigationItem("refresh", WI.UIString("Refresh"), "Images/ReloadFull.svg", 13, 13);
     
    6869            case WI.ShaderProgram.ShaderType.Fragment:
    6970                shaderTypeContainer.textContent = WI.UIString("Fragment Shader");
    70                 textEditor.mimeType = isWebGPU ? "x-pipeline/x-fragment" : "x-shader/x-fragment";
     71                textEditor.mimeType = isWebGPU ? "x-pipeline/x-render" : "x-shader/x-fragment";
    7172                break;
    7273
    7374            case WI.ShaderProgram.ShaderType.Vertex:
    74                 shaderTypeContainer.textContent = WI.UIString("Vertex Shader");
    75                 textEditor.mimeType = isWebGPU ? "x-pipeline/x-vertex" : "x-shader/x-vertex";
     75                if (sharesVertexFragmentShader)
     76                    shaderTypeContainer.textContent = WI.UIString("Vertex/Fragment Shader");
     77                else
     78                    shaderTypeContainer.textContent = WI.UIString("Vertex Shader");
     79                textEditor.mimeType = isWebGPU ? "x-pipeline/x-render" : "x-shader/x-vertex";
    7680                break;
    7781            }
     
    8084            container.appendChild(textEditor.element);
    8185            container.classList.add("shader", shaderType);
     86            container.classList.toggle("shares-vertex-fragment-shader", sharesVertexFragmentShader);
    8287
    8388            return {container, textEditor};
     
    99104            this._vertexEditor = vertexEditor.textEditor;
    100105
    101             let fragmentEditor = createEditor(WI.ShaderProgram.ShaderType.Fragment);
    102             this._fragmentContainer = fragmentEditor.container;
    103             this._fragmentEditor = fragmentEditor.textEditor;
     106            if (!sharesVertexFragmentShader) {
     107                let fragmentEditor = createEditor(WI.ShaderProgram.ShaderType.Fragment);
     108                this._fragmentContainer = fragmentEditor.container;
     109                this._fragmentEditor = fragmentEditor.textEditor;
     110            }
    104111
    105112            this._lastActiveEditor = this._vertexEditor;
     
    129136        case WI.ShaderProgram.ProgramType.Render:
    130137            this._vertexEditor.shown();
    131             this._fragmentEditor.shown();
     138            if (!this.representedObject.sharesVertexFragmentShader)
     139                this._fragmentEditor.shown();
    132140            break;
    133141        }
     
    145153        case WI.ShaderProgram.ProgramType.Render:
    146154            this._vertexEditor.hidden();
    147             this._fragmentEditor.hidden();
     155            if (!this.representedObject.sharesVertexFragmentShader)
     156                this._fragmentEditor.hidden();
    148157            break;
    149158        }
     
    277286        case WI.ShaderProgram.ProgramType.Render:
    278287            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));
     288            if (!this.representedObject.sharesVertexFragmentShader)
     289                this.representedObject.requestShaderSource(WI.ShaderProgram.ShaderType.Fragment, createCallback(this._fragmentContainer, this._fragmentEditor));
    280290            return;
    281291        }
Note: See TracChangeset for help on using the changeset viewer.