fix(msl): vertex stage_in for struct args, metal::discard_fragment namespace#38
Merged
fix(msl): vertex stage_in for struct args, metal::discard_fragment namespace#38
Conversation
- msl/expressions_test.go: MSL expression generation tests - msl/statements_test.go: MSL statement generation tests - msl/types_test.go: MSL type mapping, entry point tests - glsl/expressions_test.go: GLSL type/expression/statement tests - ir/validate_expression_test.go: comprehensive expression/type validation - Removed old validate_test.go (superseded by new comprehensive tests)
…mespace - Remove fragment-only gate in writeEntryPointInputStruct, allowing vertex shaders with struct-typed inputs (e.g. fn vs_main(in: VertexInput)) to generate synthesized _Input struct with [[attribute(N)]] members - Use member binding-based attribute generation (locationInputAttribute, builtinInputAttribute) instead of hardcoded position/user attributes - Add metal:: namespace prefix to discard_fragment() call Fixes gogpu/ui#23
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Add fallback attribute generation for struct members without explicit bindings (fragment: [[position]]/[[user(locnN)]], vertex: [[attribute(N)]]) - Fix revive lint: globalIdBinding → globalIDBinding - Add cyclop nolint for writeEntryPointInputStruct
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix two MSL backend bugs that caused Metal shader compilation failures on Apple Silicon (reported in gogpu/ui#23):
[[stage_in]]for struct-typed arguments — vertex shaders with struct inputs (e.g.,fn vs_main(in: VertexInput)) now correctly generate a synthesized_Inputstruct with[[attribute(N)]]members and[[stage_in]]parameter; previously gated to fragment-onlymetal::discard_fragment()namespace — add requiredmetal::prefix; barediscard_fragment()was rejected by Metal compilerAlso includes test coverage improvements from previous sessions.
Changes
msl/functions.gomsl/statements.goNamespaceprefix todiscard_fragment()msl/statements_test.goTestMSL_Killexpected outputsnapshot/testdata/golden/msl/vertex_colors.mslvs_main_InputstructCHANGELOG.mdTest plan
go test ./...)go fmtcleanreviveissue in glsl test)