⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 245759 in webkit


Ignore:
Timestamp:
May 24, 2019, 4:38:18 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

[WHLSL] Allow vertex attributes to have arbitrary names in the shader
https://bugs.webkit.org/show_bug.cgi?id=198235

Reviewed by Dean Jackson and Justin Fan.

Source/WebCore:

Metal doesn't allow arbitrary vertex attribute IDs. If you try to create a vertex attribute > 16,
the Metal validation layer will assert. So, we need to have a mapping from whatever the WebGPU
API says the vertex attribute IDs should be to the internally-used vertex attribute IDs.

Test: webgpu/whlsl-arbitrary-vertex-attribute-locations.html

  • Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp:

(WebCore::WHLSL::Metal::VertexEntryPointScaffolding::VertexEntryPointScaffolding):

  • Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h:
  • Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp:

(WebCore::WHLSL::matchVertexAttributes):

  • platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:

(WebCore::convertRenderPipelineDescriptor):
(WebCore::trySetInputStateForPipelineDescriptor):

LayoutTests:

  • webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html: Added.
  • webgpu/whlsl-arbitrary-vertex-attribute-locations.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r245751 r245759  
     12019-05-24  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [WHLSL] Allow vertex attributes to have arbitrary names in the shader
     4        https://bugs.webkit.org/show_bug.cgi?id=198235
     5
     6        Reviewed by Dean Jackson and Justin Fan.
     7
     8        * webgpu/whlsl-arbitrary-vertex-attribute-locations-expected.html: Added.
     9        * webgpu/whlsl-arbitrary-vertex-attribute-locations.html: Added.
     10
    1112019-05-24  Shawn Roberts  <sroberts@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r245753 r245759  
     12019-05-24  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        [WHLSL] Allow vertex attributes to have arbitrary names in the shader
     4        https://bugs.webkit.org/show_bug.cgi?id=198235
     5
     6        Reviewed by Dean Jackson and Justin Fan.
     7
     8        Metal doesn't allow arbitrary vertex attribute IDs. If you try to create a vertex attribute > 16,
     9        the Metal validation layer will assert. So, we need to have a mapping from whatever the WebGPU
     10        API says the vertex attribute IDs should be to the internally-used vertex attribute IDs.
     11
     12        Test: webgpu/whlsl-arbitrary-vertex-attribute-locations.html
     13
     14        * Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp:
     15        (WebCore::WHLSL::Metal::VertexEntryPointScaffolding::VertexEntryPointScaffolding):
     16        * Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h:
     17        * Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp:
     18        (WebCore::WHLSL::matchVertexAttributes):
     19        * platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm:
     20        (WebCore::convertRenderPipelineDescriptor):
     21        (WebCore::trySetInputStateForPipelineDescriptor):
     22
    1232019-05-24  Timothy Hatcher  <timothy@apple.com>
    224
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLEntryPointScaffolding.cpp

    r245680 r245759  
    284284        namedStageIn.indexInEntryPointItems = keyValuePair.value;
    285285        namedStageIn.elementName = m_typeNamer.generateNextStructureElementName();
    286         namedStageIn.attributeIndex = keyValuePair.key->name;
     286        namedStageIn.attributeIndex = keyValuePair.key->metalLocation;
    287287        m_namedStageIns.uncheckedAppend(WTFMove(namedStageIn));
    288288    }
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLPipelineDescriptor.h

    r245680 r245759  
    4545struct VertexAttribute {
    4646    VertexFormat vertexFormat;
    47     unsigned name;
     47    unsigned shaderLocation;
     48    unsigned metalLocation;
    4849};
    4950
  • trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLSemanticMatcher.cpp

    r243091 r245759  
    165165                continue;
    166166            auto& stageInOutSemantic = WTF::get<AST::StageInOutSemantic>(semantic);
    167             if (stageInOutSemantic.index() != vertexAttribute.name)
     167            if (stageInOutSemantic.index() != vertexAttribute.shaderLocation)
    168168                continue;
    169169            if (!isAcceptableFormat(vertexAttribute.vertexFormat, *item.unnamedType, intrinsics))
  • trunk/Source/WebCore/platform/graphics/gpu/cocoa/GPURenderPipelineMetal.mm

    r245680 r245759  
    182182
    183183    for (size_t i = 0; i < descriptor.inputState.attributes.size(); ++i)
    184         whlslDescriptor.vertexAttributes.append({ convertVertexFormat(descriptor.inputState.attributes[i].format), static_cast<unsigned>(i) });
     184        whlslDescriptor.vertexAttributes.append({ convertVertexFormat(descriptor.inputState.attributes[i].format), descriptor.inputState.attributes[i].shaderLocation, static_cast<unsigned>(i) });
    185185
    186186    for (size_t i = 0; i < descriptor.colorStates.size(); ++i) {
     
    338338
    339339    for (size_t i = 0; i < attributes.size(); ++i) {
    340         auto location = attributes[i].shaderLocation;
     340        auto location = static_cast<unsigned>(i);
    341341        // Maximum number of vertex attributes to be supported by Web GPU.
    342342        if (location >= 16) {
Note: See TracChangeset for help on using the changeset viewer.