Skip to content

Screen goes black (with artifacts) upon declaration of large array. #375

@Makogan

Description

@Makogan

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions