Search Unity

Compute Shader Thread Number Restriction

Discussion in 'Shaders' started by BLUE_CHIP, Oct 18, 2018.

  1. BLUE_CHIP

    BLUE_CHIP

    Joined:
    Sep 24, 2018
    Posts:
    2
    The situation is the following:

    I have a kernel:

    Code (CSharp):
    1. #pragma kernel diffga
    2. [numthreads(16, 8, 1)]
    3. void diffga(uint3 id : SV_DispatchThreadID) {
    4.    /* code here */
    5. }
    I dispatch this kernel with the following:
    Code (CSharp):
    1. _shader.Dispatch(kidiffga, 8, 16, 1)
    If I capture the values of id.x and id.y, id.y ranges from 0:31 as expected. However id.x only ranges from 0:7. If I change numthreads and dispatch such that the expected range is less than 8 then it functions fine. However any configuration of numthreads and dispatch which requires a range of greater than 8 is capped.

    Any insight as to why this is the case would be much appreciated.
     
  2. BLUE_CHIP

    BLUE_CHIP

    Joined:
    Sep 24, 2018
    Posts:
    2
    I've managed to locate the problem. It arose from an incorrect value for the stride parameter when istantiating the ComputeBuffer for the kernel.