Blender V5.3
gpu_shader_update_mipmaps.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2021 NVIDIA Corporation
2 * SPDX-FileCopyrightText: 2026 Blender Foundation
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Adapted code from NVIDIA Corporation. */
7
8#pragma once
9
10#include "GPU_shader_shared.hh"
11
13
14/* Conversion functions. */
15template<typename DstType, typename SrcType>
16void convert(DstType & /*dst_value*/, const SrcType /*src_value*/)
17{
18}
19
20template<> void convert<float4, float>(float4 &dst_value, const float src_value)
21{
22 dst_value.x = src_value;
23 dst_value.y = 0.0;
24 dst_value.z = 0.0;
25 dst_value.w = 0.0;
26}
27template<> void convert<float, float4>(float &dst_value, const float4 src_value)
28{
29 dst_value = src_value.x;
30}
31template<> void convert<float4, float4>(float4 &dst_value, const float4 src_value)
32{
33 dst_value = src_value;
34}
35
36/* Color transfer functions */
37/* TODO: should be moved to a library */
38float srgb_to_linearrgb(float c)
39{
40 if (c < 0.04045f) {
41 return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f);
42 }
43
44 return pow((c + 0.055f) * (1.0f / 1.055f), 2.4f);
45}
46
47float linearrgb_to_srgb(float c)
48{
49 if (c < 0.0031308f) {
50 return (c < 0.0f) ? 0.0f : c * 12.92f;
51 }
52
53 return 1.055f * pow(c, 1.0f / 2.4f) - 0.055f;
54}
55
65#define LOCAL_SIZE_X 128
66static constexpr int TILE_SIZE = MIPMAP_UPDATE_TILE_SIZE;
67static constexpr int MAX_SHARED_SAMPLES = (TILE_SIZE + TILE_SIZE + 1);
68static constexpr int INPUT_LEVEL = 0;
69
71template<typename T> struct Shared {
77
78 void store_sample(int2 dst_coord, T color)
79 {
80 intermediate_level[dst_coord.y][dst_coord.x] = color;
81 }
82
83 T load_sample(int2 src_coord)
84 {
85 return intermediate_level[src_coord.y][src_coord.x];
86 }
87};
88
96
97 void store_sample(int2 dst_coord, float color)
98 {
99 intermediate_level[dst_coord.y][dst_coord.x] = color;
100 }
101
102 float load_sample(int2 src_coord)
103 {
104 return intermediate_level[src_coord.y][src_coord.x];
105 }
106};
107
115
116 void store_sample(int2 dst_coord, float4 color)
117 {
118 float4 srgba;
119 srgba.r = linearrgb_to_srgb(color.r);
120 srgba.g = linearrgb_to_srgb(color.g);
121 srgba.b = linearrgb_to_srgb(color.b);
122 srgba.a = color.a;
123 uint srgb_packed = packUnorm4x8(srgba);
124 intermediate_level[dst_coord.y][dst_coord.x] = srgb_packed;
125 }
126
128 {
129 uint srgb_packed = intermediate_level[src_coord.y][src_coord.x];
130 float4 srgba = unpackUnorm4x8(srgb_packed);
131 float4 linear_color;
132 linear_color.r = srgb_to_linearrgb(srgba.r);
133 linear_color.g = srgb_to_linearrgb(srgba.g);
134 linear_color.b = srgb_to_linearrgb(srgba.b);
135 linear_color.a = srgba.a;
136 return linear_color;
137 }
138};
139
141{
142 return int2(input_size.x == 1 ? 1 : (2 | (input_size.x & 1)),
143 input_size.y == 1 ? 1 : (2 | (input_size.y & 1)));
144}
145
150
166template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
167struct Resources {
172 /* Note: using int2 margin on Metal fails for unknown reasons. */
173 [[push_constant]] const int margin_x;
174 [[push_constant]] const int margin_y;
176 [[storage(0, read)]] const MipmapChunkCoord (&chunk_list)[];
177 [[image(0, read, format), condition(!is_layered)]] image2D mip_in;
178 [[image(1, write, format), condition(!is_layered)]] image2D mip_out1;
179 [[image(2, write, format), condition(!is_layered)]] image2D mip_out2;
180 [[image(0, read, format), condition(is_layered)]] image2DArray mip_array_in;
181 [[image(1, write, format), condition(is_layered)]] image2DArray mip_array_out1;
182 [[image(2, write, format), condition(is_layered)]] image2DArray mip_array_out2;
184
186 void store_sample(int2 dst_coord, int dst_level, InnerType color)
187 {
188 float4 color_out;
189 convert<float4, InnerType>(color_out, color);
191 color_out.r = linearrgb_to_srgb(color_out.r);
192 color_out.g = linearrgb_to_srgb(color_out.g);
193 color_out.b = linearrgb_to_srgb(color_out.b);
194 }
196 if (dst_level == 1) {
197 imageStore(mip_out1, dst_coord, color_out);
198 }
199 else if (dst_level == 2) {
200 imageStore(mip_out2, dst_coord, color_out);
201 }
202 }
204 if (dst_level == 1) {
205 imageStore(mip_array_out1, int3(dst_coord, dst_layer), color_out);
206 }
207 else if (dst_level == 2) {
208 imageStore(mip_array_out2, int3(dst_coord, dst_layer), color_out);
209 }
210 }
211 }
212
213 void store_shared_sample(int2 dst_coord, InnerType color)
214 {
215 shared_storage.store_sample(dst_coord, color);
216 }
217
218 InnerType load_sample(int2 src_coord, bool load_from_shared)
219 {
220 InnerType color;
221 if (load_from_shared) {
222 color = shared_storage.load_sample(src_coord);
223 }
224 else {
225 float4 loaded_color;
227 loaded_color = imageLoad(mip_in, src_coord);
228 }
230 loaded_color = imageLoad(mip_array_in, int3(src_coord, dst_layer));
231 }
233 loaded_color.r = srgb_to_linearrgb(loaded_color.r);
234 loaded_color.g = srgb_to_linearrgb(loaded_color.g);
235 loaded_color.b = srgb_to_linearrgb(loaded_color.b);
236 }
237 convert<InnerType, float4>(color, loaded_color);
238 }
239 return color;
240 }
241
242 int2 level_size(int level)
243 {
244 int2 mip_in_size;
246 mip_in_size = imageSize(mip_in);
247 }
249 mip_in_size = imageSize(mip_array_in).xy;
250 }
251 int2 mip_size = max((mip_in_size >> level), int2(1));
252 return mip_size;
253 }
254
256 float a0, InnerType v0, float a1, InnerType v1, float a2, InnerType v2)
257 {
258 return a0 * v0 + a1 * v1 + a2 * v2;
259 }
260
261 InnerType pyramid_reduce_2(InnerType v0, InnerType v1)
262 {
263 return 0.5 * (v0 + v1);
264 }
265
277 template<bool load_from_shared>
278 InnerType reduce_store_sample(int2 src_coord,
279 int /*src_level*/,
280 int2 kernel_size,
281 int2 dst_image_size,
282 int2 dst_coord,
283 int dst_level)
284 {
285 float num_dst_pixels = dst_image_size.y;
286 float rcp = 1.0f / (2 * num_dst_pixels + 1);
287 float w0 = rcp * (num_dst_pixels - dst_coord.y);
288 float w1 = rcp * num_dst_pixels;
289 float w2 = 1.0f - w0 - w1;
290
291 InnerType v0, v1, v2, h0, h1, h2, out_pixel;
292
293 /* Reduce vertically up to 3 times (depending on kernel horizontal size) */
294 switch (kernel_size.x) {
295 case 3:
296 switch (kernel_size.y) {
297 case 3:
298 v2 = load_sample(src_coord + int2(2, 2), load_from_shared);
299 [[fallthrough]];
300 case 2:
301 v1 = load_sample(src_coord + int2(2, 1), load_from_shared);
302 [[fallthrough]];
303 case 1:
304 v0 = load_sample(src_coord + int2(2, 0), load_from_shared);
305 break;
306 }
307 switch (kernel_size.y) {
308 case 3:
309 h2 = pyramid_reduce_3(w0, v0, w1, v1, w2, v2);
310 break;
311 case 2:
312 h2 = pyramid_reduce_2(v0, v1);
313 break;
314 case 1:
315 h2 = v0;
316 break;
317 }
318 [[fallthrough]];
319 case 2:
320 switch (kernel_size.y) {
321 case 3:
322 v2 = load_sample(src_coord + int2(1, 2), load_from_shared);
323 [[fallthrough]];
324 case 2:
325 v1 = load_sample(src_coord + int2(1, 1), load_from_shared);
326 [[fallthrough]];
327 case 1:
328 v0 = load_sample(src_coord + int2(1, 0), load_from_shared);
329 break;
330 }
331 switch (kernel_size.y) {
332 case 3:
333 h1 = pyramid_reduce_3(w0, v0, w1, v1, w2, v2);
334 break;
335 case 2:
336 h1 = pyramid_reduce_2(v0, v1);
337 break;
338 case 1:
339 h1 = v0;
340 break;
341 }
342 [[fallthrough]];
343 case 1:
344 switch (kernel_size.y) {
345 case 3:
346 v2 = load_sample(src_coord + int2(0, 2), load_from_shared);
347 [[fallthrough]];
348 case 2:
349 v1 = load_sample(src_coord + int2(0, 1), load_from_shared);
350 [[fallthrough]];
351 case 1:
352 v0 = load_sample(src_coord + int2(0, 0), load_from_shared);
353 break;
354 }
355 switch (kernel_size.y) {
356 case 3:
357 h0 = pyramid_reduce_3(w0, v0, w1, v1, w2, v2);
358 break;
359 case 2:
360 h0 = pyramid_reduce_2(v0, v1);
361 break;
362 case 1:
363 h0 = v0;
364 break;
365 }
366 }
367
368 /* Reduce up to 3 samples horizontally. */
369 switch (kernel_size.x) {
370 case 3:
371 num_dst_pixels = dst_image_size.x;
372 rcp = 1.0f / (2 * num_dst_pixels + 1);
373 w0 = rcp * (num_dst_pixels - dst_coord.x);
374 w1 = rcp * num_dst_pixels;
375 w2 = 1.0f - w0 - w1;
376 out_pixel = pyramid_reduce_3(w0, h0, w1, h1, w2, h2);
377 break;
378 case 2:
379 out_pixel = pyramid_reduce_2(h0, h1);
380 break;
381 case 1:
382 out_pixel = h0;
383 }
384
385 /* Write out sample. */
386 store_sample(dst_coord, dst_level, out_pixel);
387 return out_pixel;
388 }
389
402 void intermediate_level_loop(int2 init_dst_coord,
403 int2 init_shared_coord,
404 int2 step,
405 int iterations,
406 bool use_bounds_check)
407 {
408 int2 dst_coord = init_dst_coord;
409 int2 shared_coord = init_shared_coord;
410 int src_level = INPUT_LEVEL;
411 int dst_level = src_level + 1;
412 int2 src_image_size = level_size(src_level);
413 int2 dst_image_size = level_size(dst_level);
414 int2 kernel_size = kernel_size_from_input_size(src_image_size);
415
416 for (int i_ = 0; i_ < iterations; ++i_) {
417 int2 src_coord = dst_coord * 2;
418
419 if (use_bounds_check) {
420 if (uint(dst_coord.x) >= uint(dst_image_size.x)) {
421 continue;
422 }
423 if (uint(dst_coord.y) >= uint(dst_image_size.y)) {
424 continue;
425 }
426 }
427
428 InnerType result = reduce_store_sample<false>(
429 src_coord, src_level, kernel_size, dst_image_size, dst_coord, dst_level);
430
431 /* `reduce_store_sample` handles writing to the actual output; manually
432 * cache into shared memory here. */
433 store_shared_sample(shared_coord, result);
434 dst_coord += step;
435 shared_coord += step;
436 }
437 }
438
449 void fill_intermediate_tile(uint local_index, int2 dst_tile_coord, bool use_bounds_check)
450 {
451 int2 init_thread_offset;
452 int2 step;
453 int iterations;
454
455 int2 dst_image_size = level_size(INPUT_LEVEL + 1);
456 int2 future_kernel_size = kernel_size_from_input_size(dst_image_size);
457
458 if (future_kernel_size.x == 3) {
459 if (future_kernel_size.y == 3) {
460 /* Fill in 2 17x7 steps and 1 17x3 step (9 idle threads) */
461 init_thread_offset = int2(local_index % 17u, local_index / 17u);
462 step = int2(0, 7);
463 iterations = local_index >= 7 * 17 ? 0 : local_index < 3 * 17 ? 3 : 2;
464 }
465 else {
466 /* Future 3x[2,1] kernel
467 * Fill in 2 8x16 steps and 1 1x16 step */
468 init_thread_offset = int2(local_index / 16u, local_index % 16u);
469 step = int2(8, 0);
470 iterations = local_index < 1 * 16 ? 3 : 2;
471 }
472 }
473 else {
474 if (future_kernel_size.y == 3) {
475 /* Fill in 2 16x8 steps and 1 16x1 step */
476 init_thread_offset = int2(local_index % 16u, local_index / 16u);
477 step = int2(0, 8);
478 iterations = local_index < 1 * 16 ? 3 : 2;
479 }
480 else {
481 /* Fill in 2 16x8 steps */
482 init_thread_offset = int2(local_index % 16u, local_index / 16u);
483 step = int2(0, 8);
484 iterations = 2;
485 }
486 }
487
488 intermediate_level_loop(dst_tile_coord + init_thread_offset,
489 init_thread_offset,
490 step,
491 iterations,
492 use_bounds_check);
493 }
494
503 void fill_last_tile(uint local_index, int2 dst_tile_coord, bool use_bounds_check)
504 {
505
506 if (local_index < 8 * 8) {
507 int2 thread_offset = int2(local_index % 8u, local_index / 8u);
508 int src_level = INPUT_LEVEL + 1;
509 int dst_level = INPUT_LEVEL + 2;
510 int2 src_image_size = level_size(src_level);
511 int2 dst_image_size = level_size(dst_level);
512
513 int2 src_shared_coord = thread_offset * 2;
514 int2 kernel_size = kernel_size_from_input_size(src_image_size);
515 int2 dst_coord = thread_offset + dst_tile_coord;
516
517 bool within_bounds = true;
518 if (use_bounds_check) {
519 within_bounds = (uint(dst_coord.x) < uint(dst_image_size.x)) &&
520 (uint(dst_coord.y) < uint(dst_image_size.y));
521 }
522 if (within_bounds) {
524 src_shared_coord, 0, kernel_size, dst_image_size, dst_coord, dst_level);
525 }
526 }
527 }
528};
529
530template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
533 [[work_group_id]] const uint3 group_id,
534 [[local_invocation_id]] const uint3 local_index,
536{
537 if (srt.num_levels == 1) {
538 uint sample_index = global_id.x + uint(srt.group_offset) * uint(LOCAL_SIZE_X);
539 int2 kernel_size = kernel_size_from_input_size(srt.level_size(INPUT_LEVEL));
540 int2 dst_image_size = srt.level_size(INPUT_LEVEL + 1);
541 int2 dst_coord = int2(int(sample_index) % dst_image_size.x,
542 int(sample_index) / dst_image_size.x);
543 int2 src_coord = dst_coord * 2;
544
545 if (dst_coord.y < dst_image_size.y) {
546 srt.template reduce_store_sample<false>(
547 src_coord, INPUT_LEVEL, kernel_size, dst_image_size, dst_coord, INPUT_LEVEL + 1);
548 }
549 }
550 else {
551 /* Handling two levels.
552 * Assign a 8x8 tile of mip level inputLevel_ + 2 to this workgroup. */
553 int level2 = INPUT_LEVEL + 2;
554 int2 level2_size = srt.level_size(level2);
555 int2 tile_count;
556 tile_count.x = int(uint(level2_size.x + 7) / 8u);
557 tile_count.y = int(uint(level2_size.y + 7) / 8u);
558
559 int2 tile_index = int2(group_id.xy);
560
561 if (srt.partial_dst_level >= 0) {
562 /* Partial update. Dispatch z selects the chunk, and xy selects tile within the chunk. */
563 int2 chunk = srt.chunk_list[group_id.z].coord;
564 int2 margin = int2(srt.margin_x, srt.margin_y);
565 int dst_level = srt.partial_dst_level;
566
567 /* Inclusive chunk bounds at the current level, expanded by margin. */
568 int2 chunk_min = ((chunk * MIPMAP_UPDATE_CHUNK_SIZE) >> dst_level) - margin;
569 int2 chunk_max = (((chunk + 1) * MIPMAP_UPDATE_CHUNK_SIZE - 1) >> dst_level) + 1 + margin;
570 chunk_min = max(chunk_min, int2(0));
571 chunk_max = min(chunk_max, level2_size);
572
573 /* Offset tile index to chunk. */
574 tile_index += chunk_min / TILE_SIZE;
575
576 /* Skip grid cells past the rect. */
577 if (tile_index.x * TILE_SIZE >= chunk_max.x || tile_index.y * TILE_SIZE >= chunk_max.y) {
578 return;
579 }
580 }
581
582 /* Determine if bounds checking is needed; this is only the case
583 * for tiles at the right or bottom fringe that might be cut off
584 * by the image border. Note that later, I use if statements rather
585 * than passing use_bounds_check directly to convince the compiler
586 * to inline everything. */
587 bool use_bounds_check = tile_index.x >= tile_count.x - 1 || tile_index.y >= tile_count.y - 1;
588
589 if (use_bounds_check) {
590 /* Compute the tile in level inputLevel_ + 1 that's needed to
591 * compute the above 8x8 tile. */
592 srt.fill_intermediate_tile(local_index.x, tile_index * 2 * int2(8, 8), true);
593 barrier();
594
595 /* Compute the inputLevel_ + 2 tile of size 8x8, loading
596 * inputs from shared memory. */
597 srt.fill_last_tile(local_index.x, tile_index * int2(8, 8), true);
598 }
599 else {
600 /* Same but without bounds checking. */
601 srt.fill_intermediate_tile(local_index.x, tile_index * 2 * int2(8, 8), false);
602 barrier();
603 srt.fill_last_tile(local_index.x, tile_index * int2(8, 8), false);
604 }
605 }
606}
607
608template struct Shared<float>;
609template struct Shared<float4>;
610
611template struct Resources<UNORM_8, SharedUnorm, float>;
612template struct Resources<UNORM_8_8_8_8, SharedSRGB, float4>;
613template struct Resources<SFLOAT_16, Shared<float>, float>;
614template struct Resources<SFLOAT_16_16_16_16, Shared<float4>, float4>;
615template struct Resources<SFLOAT_32, Shared<float>, float>;
616template struct Resources<SFLOAT_32_32_32_32, Shared<float4>, float4>;
617
619 int2 src_coord,
620 int src_level,
621 int2 kernel_size,
622 int2 dst_image_size,
623 int2 dst_coord,
624 int dst_level);
626 int2 src_coord,
627 int src_level,
628 int2 kernel_size,
629 int2 dst_image_size,
630 int2 dst_coord,
631 int dst_level);
633 int2 src_coord,
634 int src_level,
635 int2 kernel_size,
636 int2 dst_image_size,
637 int2 dst_coord,
638 int dst_level);
640 int2 src_coord,
641 int src_level,
642 int2 kernel_size,
643 int2 dst_image_size,
644 int2 dst_coord,
645 int dst_level);
646template float Resources<SFLOAT_16, Shared<float>, float>::reduce_store_sample<true>(
647 int2 src_coord,
648 int src_level,
649 int2 kernel_size,
650 int2 dst_image_size,
651 int2 dst_coord,
652 int dst_level);
653template float Resources<SFLOAT_16, Shared<float>, float>::reduce_store_sample<false>(
654 int2 src_coord,
655 int src_level,
656 int2 kernel_size,
657 int2 dst_image_size,
658 int2 dst_coord,
659 int dst_level);
660template float4 Resources<SFLOAT_16_16_16_16, Shared<float4>, float4>::reduce_store_sample<true>(
661 int2 src_coord,
662 int src_level,
663 int2 kernel_size,
664 int2 dst_image_size,
665 int2 dst_coord,
666 int dst_level);
667template float4 Resources<SFLOAT_16_16_16_16, Shared<float4>, float4>::reduce_store_sample<false>(
668 int2 src_coord,
669 int src_level,
670 int2 kernel_size,
671 int2 dst_image_size,
672 int2 dst_coord,
673 int dst_level);
674template float Resources<SFLOAT_32, Shared<float>, float>::reduce_store_sample<true>(
675 int2 src_coord,
676 int src_level,
677 int2 kernel_size,
678 int2 dst_image_size,
679 int2 dst_coord,
680 int dst_level);
681template float Resources<SFLOAT_32, Shared<float>, float>::reduce_store_sample<false>(
682 int2 src_coord,
683 int src_level,
684 int2 kernel_size,
685 int2 dst_image_size,
686 int2 dst_coord,
687 int dst_level);
688template float4 Resources<SFLOAT_32_32_32_32, Shared<float4>, float4>::reduce_store_sample<true>(
689 int2 src_coord,
690 int src_level,
691 int2 kernel_size,
692 int2 dst_image_size,
693 int2 dst_coord,
694 int dst_level);
695template float4 Resources<SFLOAT_32_32_32_32, Shared<float4>, float4>::reduce_store_sample<false>(
696 int2 src_coord,
697 int src_level,
698 int2 kernel_size,
699 int2 dst_image_size,
700 int2 dst_coord,
701 int dst_level);
702
704 const uint3 global_id,
705 const uint3 group_id,
706 const uint3 local_index,
709 const uint3 global_id,
710 const uint3 group_id,
711 const uint3 local_index,
714 const uint3 global_id,
715 const uint3 group_id,
716 const uint3 local_index,
719 const uint3 global_id,
720 const uint3 group_id,
721 const uint3 local_index,
724 const uint3 global_id,
725 const uint3 group_id,
726 const uint3 local_index,
729 const uint3 global_id,
730 const uint3 group_id,
731 const uint3 local_index,
733
734} // namespace builtin::mipmaps
735
738 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = false});
741 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = true});
744 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = false});
747 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = true});
750 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = false});
753 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = true});
756 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = false});
759 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = true});
762 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = false});
765 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = true});
768 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = false});
771 builtin::mipmaps::Constants{.is_srgb_texture = false, .is_layered = true});
774 builtin::mipmaps::Constants{.is_srgb_texture = true, .is_layered = false});
777 builtin::mipmaps::Constants{.is_srgb_texture = true, .is_layered = true});
btScalar max
@ SFLOAT_16_16_16_16
@ SFLOAT_32_32_32_32
#define shared
#define storage(slot, qualifiers)
#define work_group_id
#define push_constant
#define compilation_constant
#define resource_table
#define static_branch
#define global_invocation_id
#define local_invocation_id
#define compute
#define condition(cond)
#define local_size(...)
#define pow
float4 unpackUnorm4x8(uint) RET
uint packUnorm4x8(float4) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void barrier()
IMG_TEMPLATE DataVec imageLoad(const T &, IntCoord) RET
ImageBase< float, 2, true > image2DArray
ImageBase< float, 2 > image2D
IMG_TEMPLATE SizeVec imageSize(const T &) RET
IMG_TEMPLATE void imageStore(T &, IntCoord, DataVec)
PipelineCompute gpu_shader_2D_update_mipmaps_unorm_8_8_8_8_layered(builtin::mipmaps::update_mipmaps< UNORM_8_8_8_8, builtin::mipmaps::SharedSRGB, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=true})
PipelineCompute gpu_shader_2D_update_mipmaps_unorm_8_layered(builtin::mipmaps::update_mipmaps< UNORM_8, builtin::mipmaps::SharedUnorm, float >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=true})
PipelineCompute gpu_shader_2D_update_mipmaps_srgba_8_8_8_8_layered(builtin::mipmaps::update_mipmaps< UNORM_8_8_8_8, builtin::mipmaps::SharedSRGB, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=true,.is_layered=true})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_16_16_16_16_layered(builtin::mipmaps::update_mipmaps< SFLOAT_16_16_16_16, builtin::mipmaps::Shared< float4 >, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=true})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_32(builtin::mipmaps::update_mipmaps< SFLOAT_32, builtin::mipmaps::Shared< float >, float >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=false})
PipelineCompute gpu_shader_2D_update_mipmaps_unorm_8(builtin::mipmaps::update_mipmaps< UNORM_8, builtin::mipmaps::SharedUnorm, float >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=false})
PipelineCompute gpu_shader_2D_update_mipmaps_unorm_8_8_8_8(builtin::mipmaps::update_mipmaps< UNORM_8_8_8_8, builtin::mipmaps::SharedSRGB, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=false})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_16(builtin::mipmaps::update_mipmaps< SFLOAT_16, builtin::mipmaps::Shared< float >, float >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=false})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_16_layered(builtin::mipmaps::update_mipmaps< SFLOAT_16, builtin::mipmaps::Shared< float >, float >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=true})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_32_32_32_32_layered(builtin::mipmaps::update_mipmaps< SFLOAT_32_32_32_32, builtin::mipmaps::Shared< float4 >, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=true})
PipelineCompute gpu_shader_2D_update_mipmaps_srgba_8_8_8_8(builtin::mipmaps::update_mipmaps< UNORM_8_8_8_8, builtin::mipmaps::SharedSRGB, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=true,.is_layered=false})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_16_16_16_16(builtin::mipmaps::update_mipmaps< SFLOAT_16_16_16_16, builtin::mipmaps::Shared< float4 >, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=false})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_32_layered(builtin::mipmaps::update_mipmaps< SFLOAT_32, builtin::mipmaps::Shared< float >, float >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=true})
PipelineCompute gpu_shader_2D_update_mipmaps_sfloat_32_32_32_32(builtin::mipmaps::update_mipmaps< SFLOAT_32_32_32_32, builtin::mipmaps::Shared< float4 >, float4 >, builtin::mipmaps::Constants{.is_srgb_texture=false,.is_layered=false})
const int tile_index
#define T
static constexpr int INPUT_LEVEL
static constexpr int MAX_SHARED_SAMPLES
void update_mipmaps(const uint3 global_id, const uint3 group_id, const uint3 local_index, Resources< format, SharedStorage, InnerType > &srt)
void convert(DstType &, const SrcType)
int2 kernel_size_from_input_size(int2 input_size)
#define min(a, b)
Definition sort.cc:38
Templated struct for bindings and performing the mipmap generation.
InnerType pyramid_reduce_2(InnerType v0, InnerType v1)
InnerType load_sample(int2 src_coord, bool load_from_shared)
void store_shared_sample(int2 dst_coord, InnerType color)
InnerType pyramid_reduce_3(float a0, InnerType v0, float a1, InnerType v1, float a2, InnerType v2)
void intermediate_level_loop(int2 init_dst_coord, int2 init_shared_coord, int2 step, int iterations, bool use_bounds_check)
void fill_last_tile(uint local_index, int2 dst_tile_coord, bool use_bounds_check)
void store_sample(int2 dst_coord, int dst_level, InnerType color)
void fill_intermediate_tile(uint local_index, int2 dst_tile_coord, bool use_bounds_check)
InnerType reduce_store_sample(int2 src_coord, int, int2 kernel_size, int2 dst_image_size, int2 dst_coord, int dst_level)
uint intermediate_level[MAX_SHARED_SAMPLES][MAX_SHARED_SAMPLES]
void store_sample(int2 dst_coord, float4 color)
void store_sample(int2 dst_coord, float color)
float intermediate_level[MAX_SHARED_SAMPLES][MAX_SHARED_SAMPLES]
T intermediate_level[MAX_SHARED_SAMPLES][MAX_SHARED_SAMPLES]
void store_sample(int2 dst_coord, T color)
float y
Definition sky_math.h:225
float z
Definition sky_math.h:225
float x
Definition sky_math.h:225
float w
Definition sky_math.h:225