Skip to content

Instantly share code, notes, and snippets.

@fuqunaga
Last active January 11, 2019 13:41
Show Gist options
  • Save fuqunaga/3bd590dbb7b3c560d5acef69e3b3cc6a to your computer and use it in GitHub Desktop.
Save fuqunaga/3bd590dbb7b3c560d5acef69e3b3cc6a to your computer and use it in GitHub Desktop.
DispatchThreadNum
public static class ComputerShaderExtension
{
public static void DispatchThreadNum(this ComputeShader cs, int kernel, int threadNumX, int threadNumY, int threadNumZ)
{
uint x, y, z;
cs.GetKernelThreadGroupSizes(kernel, out x, out y, out z);
cs.Dispatch(kernel, Mathf.CeilToInt((float)threadNumX / x), Mathf.CeilToInt((float)threadNumY / y), Mathf.CeilToInt((float)threadNumZ / z));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment