Bug 220137 - Failures of attribute location conformance tests with Metal backend
Summary: Failures of attribute location conformance tests with Metal backend
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Major
Assignee: Kyle Piddington
URL:
Keywords: InRadar
Depends on: 219759
Blocks: anglemetal
  Show dependency treegraph
 
Reported: 2020-12-23 23:42 PST by Kenneth Russell
Modified: 2021-01-08 16:10 PST (History)
10 users (show)

See Also:


Attachments
Patch (5.30 KB, patch)
2021-01-06 13:25 PST, Kyle Piddington
no flags Details | Formatted Diff | Diff
Patch (11.07 KB, patch)
2021-01-08 15:26 PST, Kyle Piddington
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Kenneth Russell 2020-12-23 23:42:28 PST
Per Bug 220076, the following three WebGL 1.0.3 conformance tests are failing with the Metal backend:

webgl/1.0.3/conformance/attribs/gl-disabled-vertex-attrib.html
webgl/1.0.3/conformance/attribs/gl-vertex-attrib-render.html
webgl/1.0.3/conformance/attribs/gl-vertex-attrib-zero-issues.html

This is basic functionality; the Metal backend must not be enabled by default before these bugs are tracked down and fixed.
Comment 1 Radar WebKit Bug Importer 2020-12-30 23:43:23 PST
<rdar://problem/72750062>
Comment 2 Kyle Piddington 2021-01-06 13:25:01 PST
Created attachment 417121 [details]
Patch
Comment 3 EWS Watchlist 2021-01-06 13:25:46 PST
Note that there are important steps to take when updating ANGLE. See https://trac.webkit.org/wiki/UpdatingANGLE
Comment 4 Kenneth Russell 2021-01-06 15:04:15 PST
Comment on attachment 417121 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417121&action=review

Great work handling this! A few questions, but assuming this passes tests, r+.

> Source/ThirdParty/ANGLE/src/compiler/translator/TranslatorMetalDirect/EmitMetal.cpp:1229
> +     mOut << " __unassigned_attribute__ ";

Is the indentaion off here?

> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_glslang_mtl_utils.mm:151
> +    //Build string to attrib map.

Nit: space after //.

> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_glslang_mtl_utils.mm:152
> +    const std::vector<sh::ShaderVariable> programAttributes = programState.getProgramInputs();

How about "const auto&"? I think this will perform a copy as written.

> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_glslang_mtl_utils.mm:163
> +                stream << attribute.name << "_" << std::to_string(i) << " __unassigned_attribute__";

How about a variable for the constant string " __unassigned_attribute__"?

> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_glslang_mtl_utils.mm:177
> +    for(std::unordered_map<std::string, uint32_t>::iterator it = attributeBindings.begin(); it!=attributeBindings.end(); ++it)

Is "for (auto it = attributeBindings::begin(); ..." workable here?

> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_glslang_mtl_utils.mm:186
> +    }

What happens if a given attribute wasn't assigned a location via glBindAttribLocation? Would the " __unassigned_attribute__" strings cause MSL compilation failures?
Comment 5 Kyle Piddington 2021-01-06 15:11:51 PST
> What happens if a given attribute wasn't assigned a location via glBindAttribLocation? Would the " __unassigned_attribute__" strings cause MSL compilation failures?

Any active attribute should get a location, even if they aren't specifically bound. This is handled in the linkAttributes() (See Program.cpp) step in the Angle frontend.

Any non-active attributes should be optimized out, but if something went wrong, we would have a compilation failure.
Comment 6 Kenneth Russell 2021-01-06 15:51:06 PST
(In reply to Kyle Piddington from comment #5)
> > What happens if a given attribute wasn't assigned a location via glBindAttribLocation? Would the " __unassigned_attribute__" strings cause MSL compilation failures?
> 
> Any active attribute should get a location, even if they aren't specifically
> bound. This is handled in the linkAttributes() (See Program.cpp) step in the
> Angle frontend.
> 
> Any non-active attributes should be optimized out, but if something went
> wrong, we would have a compilation failure.

Thanks for your confirmation. Sounds fine.
Comment 7 Kyle Piddington 2021-01-08 15:26:08 PST
Created attachment 417308 [details]
Patch
Comment 8 Dean Jackson 2021-01-08 15:35:35 PST
Comment on attachment 417308 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417308&action=review

Looks good if the unrelated changes are removed.

> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_common.h:-126
> -
> -// NOTE(hqle): support variable max number of vertex attributes
> -constexpr uint32_t kMaxVertexAttribs = gl::MAX_VERTEX_ATTRIBS;
> -// NOTE(hqle): support variable max number of render targets
> -constexpr uint32_t kMaxRenderTargets = 4;
> -

I don't think you meant to include the changes in this file.

> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_constants.h:35
> +constexpr uint32_t kMaxShaderXFBs = gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS;
> +
> +// The max size of a buffer that will be allocated in shared memory.
> +// NOTE(hqle): This is just a hint. There is no official document on what is the max allowed size
> +// for shared memory.
> +constexpr size_t kSharedMemBufferMaxBufSizeHint = 128 * 1024;

I think this is from another patch.
Comment 9 Dean Jackson 2021-01-08 15:36:18 PST
Comment on attachment 417308 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=417308&action=review

>> Source/ThirdParty/ANGLE/src/libANGLE/renderer/metal/mtl_common.h:-126
>> -
> 
> I don't think you meant to include the changes in this file.

Kyle explained that this was intentional. Lots of these were defined twice.
Comment 10 EWS 2021-01-08 16:10:29 PST
Committed r271334: <https://trac.webkit.org/changeset/271334>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 417308 [details].