Screen goes black (with artifacts) upon declaration of large array.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.4k
- Forks
- 125
- PR merge metrics
- No merged PRs in 30d
Description
I have a fairly complex shader that's doing a lot of numerical analysis on the GPU. One function does this:
pub fn evaluate_function_vector(
&mut self,
x: [S; 3],
degree: usize,
#[cfg(not(feature = "std"))] coefficients: &[S; MAXIMUM_ARRAY_SIZE_NO_STD],
#[cfg(feature = "std")] coefficients: &[S],
) -> S
{
#[cfg(feature = "std")]
let basis_eval = self.eval(x, degree);
#[cfg(not(feature = "std"))]
let basis_eval = {
let mut basis_eval = [S::default(); MAXIMUM_ARRAY_SIZE_NO_STD]; // THIS LINE!!!!!!!!!!!!
self.eval(x, degree, &mut basis_eval);
basis_eval
};
let mut res = S::default();
for i in 0..basis_eval.len()
{
let v = basis_eval[i];
let coeff = coefficients[i];
res += v.clone() * coeff.clone();
}
res
}
I noticed that different sizes of let mut basis_eval = [S::default(); MAXIMUM_ARRAY_SIZE_NO_STD]; // THIS LINE!!!!!!!!!!!! Caused different behaviours. Small sizes would produce the expected image, sizes of about larger than 50 would create a black image with colour noise sprinkled in, as if rendering a corrupted buffer or uninitialized memory.
I am using the latest cargo gpu to compile my shaders afaik.
I am on Garuda Linux, Vulkan version 1.4.321.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the evaluate_function_vector function and the basis_eval array declaration shown in the report. Reproduce the shader on Vulkan with progressively larger MAXIMUM_ARRAY_SIZE_NO_STD values, comparing the rendered output and generated shader behavior. Done means the cause of the black image and artifacts is identified and the issue has a verified correction or documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100