Repository navigation
fix(spirv): lower thread pointers to function-local scalars - #5327
Open
iamcipherdev wants to merge 1 commit into
Open
iamcipherdev wants to merge 1 commit into
iamcipherdev wants to merge 1 commit into
Conversation
SPIR-V output lowers a helper's pointer parameter to inout when a call passes the address of a whole function-local scalar, as HLSL already does: the argument is copied into the parameter's own Function variable and copied back when the call returns. A dereference or subscript of the parameter in the callee body reads and writes that variable, so tsum(&mean, ...) and minmax(x, y, &lo, &hi) now translate instead of being refused with requires a storage buffer argument. Closes CrossGL#2283
Coverage change against mainAgainst the coverage published for Not measured in this run: CUDA output, CUDA input, HIP output, HIP input, Metal output, Metal input, Mojo output, Mojo input, Rust output, Rust input. Measured by this Coverage run. |
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.
Closes #2283
SPIR-V output lowers a helper's pointer parameter to
inoutwhen a call passes the address of a whole function-local scalar, as HLSL already does: the argument is copied into the parameter's ownFunctionvariable and copied back when the call returns. A dereference (*a) or subscript (x[i]) of the parameter in the callee body reads and writes that variable. This covers the issue's Metal reproducertsum(&mean, ...)and the OpenCL C / CUDA helpers from the 2 Dec note (minmax(x, y, &lo, &hi),swapf(&lo, &hi)). The lowering is fail-closed: only&identifierof aFunction-storage scalar whose type matches the declared pointee exactly, on a non-constparameter; anything else keeps the existing refusal. WGSL is out of scope here (follow-up).Verification
SpirvLoweringRefused): Metaltsum, OpenCLminmax/swapf, CUDAminmax— each asserts copy-in/copy-out of the caller's variable, noOpFunctionCall, noWARNING.tests/test_translator/test_codegen/: 8866 passed, 1469 skipped, 0 failed.tests/test_changelog.py: 12 passed.--select=E9,F63,F7,F82) pass; black--preview --target-version=py38clean.Not verified locally (disclosed): no native validators exist in this environment (no spirv-as/spirv-val, dxc, naga, or slangc), so
spirv-valvalidation of the new tests is CI-guarded — the new tests skip atassert_spirv_module_validateshere. Full 46k translator suite not run locally (VM is 1.5 CPU); the SPIR-V/codegen subsets above are green.