MCPcopy Create free account
hub / github.com/3DAnimals/3DAnimals / getLaunchBlockSize

Function getLaunchBlockSize

model/render/renderutils/c_src/common.cpp:18–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16// Block and grid size calculators for kernel launches.
17
18dim3 getLaunchBlockSize(int maxWidth, int maxHeight, dim3 dims)
19{
20 int maxThreads = maxWidth * maxHeight;
21 if (maxThreads <= 1 || (dims.x * dims.y) <= 1)
22 return dim3(1, 1, 1); // Degenerate.
23
24 // Start from max size.
25 int bw = maxWidth;
26 int bh = maxHeight;
27
28 // Optimizations for weirdly sized buffers.
29 if (dims.x < bw)
30 {
31 // Decrease block width to smallest power of two that covers the buffer width.
32 while ((bw >> 1) >= dims.x)
33 bw >>= 1;
34
35 // Maximize height.
36 bh = maxThreads / bw;
37 if (bh > dims.y)
38 bh = dims.y;
39 }
40 else if (dims.y < bh)
41 {
42 // Halve height and double width until fits completely inside buffer vertically.
43 while (bh > dims.y)
44 {
45 bh >>= 1;
46 if (bw < dims.x)
47 bw <<= 1;
48 }
49 }
50
51 // Done.
52 return dim3(bw, bh, 1);
53}
54
55// returns the size of a block that can be reduced using horizontal SIMD operations (e.g. __shfl_xor_sync)
56dim3 getWarpSize(dim3 blockSize)

Callers 15

lambert_fwdFunction · 0.85
lambert_bwdFunction · 0.85
frostbite_fwdFunction · 0.85
frostbite_bwdFunction · 0.85
fresnel_shlick_fwdFunction · 0.85
fresnel_shlick_bwdFunction · 0.85
ndf_ggx_fwdFunction · 0.85
ndf_ggx_bwdFunction · 0.85
lambda_ggx_fwdFunction · 0.85
lambda_ggx_bwdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected