Fix Sobol sampler and D65 illuminant for Metal GPU backend#38
Open
jkrumbiegel wants to merge 3 commits intoJuliaGraphics:masterfrom
Open
Fix Sobol sampler and D65 illuminant for Metal GPU backend#38jkrumbiegel wants to merge 3 commits intoJuliaGraphics:masterfrom
jkrumbiegel wants to merge 3 commits intoJuliaGraphics:masterfrom
Conversation
Two issues fixed: 1. Runtime NTuple indexing returns 0 on Metal. Replace PERMUTATIONS_4WAY (nested NTuples indexed at runtime) with PACKED_PERMUTATIONS_4WAY (bit-packed UInt32 values appended to the Sobol matrices GPU array). lookup_permutation now takes the matrices array and uses bit shifts. 2. @nexprs unrolled loops cause Metal compiler crashes or miscompilation when the loop body references non-constant kernel arguments. Replace with regular for loops in sobol_sample. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The D65 illuminant spectrum was stored as NTuple{107, Float32} and indexed
at runtime, which returns 0 on Metal (same root cause as the Sobol fix).
Add d65_values field to RGBToSpectrumTable as a GPU array, and add
GPU-compatible sample_d65/sample_d65_spectral overloads that read from
the array instead of the NTuple constant.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
486d1af to
1f22f31
Compare
Collaborator
|
great!
would you mind sharing the code for all these? It would be nice to test and show the output across all backends, so starting with a set of references as in Makie make sense. |
Author
|
The 20 materials test scene is in RayMakie in |
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
PERMUTATIONS_4WAY(nested NTuples) with bit-packedUInt32values appended to the Sobol matrices GPU array. Also replace@nexprsunrolled loops with regularforloops (the unrolled form causes Metal compiler crashes or miscompilation with non-constant kernel arguments).NTuple{107, Float32}indexed at runtime. Addd65_valuesfield toRGBToSpectrumTableas a GPU array, with GPU-compatiblesample_d65overloads.How these changes were tested
Created with the help of Claude Code