fn workgroup_size(
    x: u64,
    max_threads: u32,
    max_workgroup_size: u32,
) -> Result<(u32, u32), CompileError> {
    let max_x = max_threads as u64;

    Ok(if x > max_x {
        let workgroup_size = ceil(x, max_x) as _;
        let threads = ceil(x, workgroup_size as u64) as _;
        log::info!(
            "number of items ({}) exceeds maximum number of threads ({}); adjusting workgroup size={} and threads={} (this will compute {} items)",
            x,
            max_x,
            workgroup_size,
            threads,
            workgroup_size * threads
        );

        if threads > max_threads {
            return Err(CompileError::ComputeLimitExceeded(
                String::from("threads"),
                threads,
                max_threads,
            ));
        }

        if workgroup_size > max_workgroup_size {
            return Err(CompileError::ComputeLimitExceeded(
                String::from("workgroup size"),
                workgroup_size,
                max_workgroup_size,
            ));
        }

        (threads, workgroup_size)
    } else {
        (x as u32, 1)
    })
}
/// Determines the appropriate number of threads and workgroup size given a number of times the entry point of the shader should be run
Determines the appropriate number of threads and workgroup size given a number of times the entry point of the shader should be run
Determines the appropriate number of threads and workgroup size given a number of times the entry point of the shader should be run
fn workgroup_size(
    x: u64,
    max_threads: u32,
    max_workgroup_size: u32,
) -> Result<(u32, u32), CompileError> {
    let max_x = max_threads as u64;
    Ok(if x > max_x {
        let workgroup_size = ceil(x, max_x) as _;
        let threads = ceil(x, workgroup_size as u64) as _;
        log::info!(
            "number of items ({}) exceeds maximum number of threads ({}); adjusting workgroup size={} and threads={} (this will compute {} items)",
            x,
            max_x,
            workgroup_size,
            threads,
            workgroup_size * threads
        );
        if threads > max_threads {
            return Err(CompileError::ComputeLimitExceeded(
                String::from("threads"),
                threads,
                max_threads,
            ));
        }
        if workgroup_size > max_workgroup_size {
            return Err(CompileError::ComputeLimitExceeded(
                String::from("workgroup size"),
                workgroup_size,
                max_workgroup_size,
            ));
        }
        (threads, workgroup_size)
    } else {
        (x as u32, 1)
    })
}
fn workgroup_size ( x : u64 , max_threads : u32 , max_workgroup_size : u32 , ) -> Result < ( u32 , u32 ) , CompileError > { let max_x = max_threads as u64 ; Ok ( if x > max_x { let workgroup_size = ceil ( x , max_x ) as _ ; let threads = ceil ( x , workgroup_size as u64 ) as _ ; log :: info ! ( " " x max_x workgroup_size threads workgroup_size threads ) ; if threads > max_threads { return Err ( CompileError :: ComputeLimitExceeded ( String :: from ( " " ) , threads , max_threads , ) ) ; } if workgroup_size > max_workgroup_size { return Err ( CompileError :: ComputeLimitExceeded ( String :: from ( " " ) , workgroup_size , max_workgroup_size , ) ) ; } ( threads , workgroup_size ) } else { ( x as u32 , 1 ) } ) }
Determines the appropriate number of threads and workgroup size given a number of times the entry point of the shader should be run
Determines the appropriate number of threads and workgroup size given a number of times the entry point of the shader should be run
x
u64
max_threads
u32
max_workgroup_size
u32
x
u64
max_threads
u32
max_workgroup_size
u32