|
Blender V5.3
|
Templated struct for bindings and performing the mipmap generation. More...
#include <gpu_shader_update_mipmaps.bsl.hh>
Public Member Functions | |
| void | store_sample (int2 dst_coord, int dst_level, InnerType color) |
| void | store_shared_sample (int2 dst_coord, InnerType color) |
| InnerType | load_sample (int2 src_coord, bool load_from_shared) |
| int2 | level_size (int level) |
| InnerType | pyramid_reduce_3 (float a0, InnerType v0, float a1, InnerType v1, float a2, InnerType v2) |
| InnerType | pyramid_reduce_2 (InnerType v0, InnerType v1) |
| template<bool load_from_shared> | |
| InnerType | reduce_store_sample (int2 src_coord, int, int2 kernel_size, int2 dst_image_size, int2 dst_coord, int dst_level) |
| void | intermediate_level_loop (int2 init_dst_coord, int2 init_shared_coord, int2 step, int iterations, bool use_bounds_check) |
| void | fill_intermediate_tile (uint local_index, int2 dst_tile_coord, bool use_bounds_check) |
| void | fill_last_tile (uint local_index, int2 dst_tile_coord, bool use_bounds_check) |
Public Attributes | |
| Constants | consts |
| const int | num_levels |
| const int | group_offset |
| const int | partial_dst_level |
| const int | margin_x |
| const int | margin_y |
| const int | dst_layer |
| const MipmapChunkCoord(& | chunk_list )[] |
| image2D | mip_in |
| image2D | mip_out1 |
| image2D | mip_out2 |
| image2DArray | mip_array_in |
| image2DArray | mip_array_out1 |
| image2DArray | mip_array_out2 |
| SharedStorage | shared_storage |
Templated struct for bindings and performing the mipmap generation.
The mipmap generation is based on the general algorithm of https://github.com/nvpro-samples/vk_compute_mipmaps/tree/main/nvpro_pyramid It can generate 2 mipmap levels per dispatch.
| format | is the texture format of the mipmap images. |
| SharedStorage | is the storage class to store intermediate levels. Depending on the texture format an optimal storage class can be selected. |
| InnerType | the type to use for computation. Depending on the number of samples that a texture format has a more memory efficient type can be used. |
Definition at line 167 of file gpu_shader_update_mipmaps.bsl.hh.
|
inline |
Function for the workgroup that handles filling the intermediate level (caching it in shared memory as well).
We need somewhere from 16x16 to 17x17 samples, depending on what the kernel size for the 2nd mip level generation will be.
dst_tile_coord : upper left coordinate of the tile to generate. use_bounds_check : whether to skip samples that are out-of-bounds.
Definition at line 449 of file gpu_shader_update_mipmaps.bsl.hh.
References builtin::mipmaps::INPUT_LEVEL, intermediate_level_loop(), builtin::mipmaps::kernel_size_from_input_size(), level_size(), step, int2::x, and int2::y.
|
inline |
Function for the workgroup that handles filling the last level tile (2nd level after the original input level), using as input the tile in shared memory.
dst_tile_coord : upper left coordinate of the tile to generate. use_bounds_check : whether to skip samples that are out-of-bounds.
Definition at line 503 of file gpu_shader_update_mipmaps.bsl.hh.
References builtin::mipmaps::INPUT_LEVEL, builtin::mipmaps::kernel_size_from_input_size(), level_size(), reduce_store_sample(), int2::x, and int2::y.
|
inline |
Compute and write out (to the 1st mip level generated) the samples at coordinates init_dst_coord, init_dst_coord + step, ... init_dst_coord + (iterations-1) * step and cache them at in the sharedLevel_ tile at coordinates init_shared_coord, init_shared_coord + step, ... init_shared_coord + (iterations-1) * step If use_bounds_check is true, skip coordinates that are out of bounds.
Definition at line 402 of file gpu_shader_update_mipmaps.bsl.hh.
References builtin::mipmaps::INPUT_LEVEL, builtin::mipmaps::kernel_size_from_input_size(), level_size(), reduce_store_sample(), step, store_shared_sample(), int2::x, and int2::y.
Referenced by fill_intermediate_tile().
|
inline |
Definition at line 242 of file gpu_shader_update_mipmaps.bsl.hh.
References consts, imageSize(), builtin::mipmaps::Constants::is_layered, max, mip_array_in, mip_in, and static_branch.
Referenced by fill_intermediate_tile(), fill_last_tile(), and intermediate_level_loop().
|
inline |
Definition at line 218 of file gpu_shader_update_mipmaps.bsl.hh.
References consts, builtin::mipmaps::convert(), dst_layer, imageLoad(), builtin::mipmaps::Constants::is_layered, builtin::mipmaps::Constants::is_srgb_texture, mip_array_in, mip_in, shared_storage, builtin::mipmaps::srgb_to_linearrgb(), and static_branch.
Referenced by reduce_store_sample().
|
inline |
Definition at line 261 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by reduce_store_sample().
|
inline |
Definition at line 255 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by reduce_store_sample().
|
inline |
Handle loading and reducing a rectangle of size kernel_size with the given upper-left coordinate src_coord. Samples read from mip level src_level if !loadFromShared_, sharedLevel_ otherwise.
kernel_size must range from 1x1 to 3x3.
Once computed, the sample is written to the given coordinate of the specified destination mip level, and returned. The destination image size is needed to compute the kernel weights.
Definition at line 278 of file gpu_shader_update_mipmaps.bsl.hh.
References load_sample(), pyramid_reduce_2(), pyramid_reduce_3(), store_sample(), int2::x, and int2::y.
Referenced by fill_last_tile(), and intermediate_level_loop().
|
inline |
Store sample result into an output mip image.
Definition at line 186 of file gpu_shader_update_mipmaps.bsl.hh.
References consts, builtin::mipmaps::convert(), dst_layer, imageStore(), builtin::mipmaps::Constants::is_layered, builtin::mipmaps::Constants::is_srgb_texture, builtin::mipmaps::linearrgb_to_srgb(), mip_array_out1, mip_array_out2, mip_out1, mip_out2, and static_branch.
Referenced by reduce_store_sample().
|
inline |
Definition at line 213 of file gpu_shader_update_mipmaps.bsl.hh.
References shared_storage.
Referenced by intermediate_level_loop().
| const MipmapChunkCoord(& builtin::mipmaps::Resources< format, SharedStorage, InnerType >::chunk_list)[] |
Definition at line 176 of file gpu_shader_update_mipmaps.bsl.hh.
| Constants builtin::mipmaps::Resources< format, SharedStorage, InnerType >::consts |
Definition at line 168 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by level_size(), load_sample(), and store_sample().
| const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::dst_layer |
Definition at line 175 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by load_sample(), and store_sample().
| const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::group_offset |
Definition at line 170 of file gpu_shader_update_mipmaps.bsl.hh.
| const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::margin_x |
Definition at line 173 of file gpu_shader_update_mipmaps.bsl.hh.
| const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::margin_y |
Definition at line 174 of file gpu_shader_update_mipmaps.bsl.hh.
| image2DArray builtin::mipmaps::Resources< format, SharedStorage, InnerType >::mip_array_in |
Definition at line 180 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by level_size(), and load_sample().
| image2DArray builtin::mipmaps::Resources< format, SharedStorage, InnerType >::mip_array_out1 |
Definition at line 181 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by store_sample().
| image2DArray builtin::mipmaps::Resources< format, SharedStorage, InnerType >::mip_array_out2 |
Definition at line 182 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by store_sample().
| image2D builtin::mipmaps::Resources< format, SharedStorage, InnerType >::mip_in |
Definition at line 177 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by level_size(), and load_sample().
| image2D builtin::mipmaps::Resources< format, SharedStorage, InnerType >::mip_out1 |
Definition at line 178 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by store_sample().
| image2D builtin::mipmaps::Resources< format, SharedStorage, InnerType >::mip_out2 |
Definition at line 179 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by store_sample().
| const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::num_levels |
Definition at line 169 of file gpu_shader_update_mipmaps.bsl.hh.
| const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::partial_dst_level |
Definition at line 171 of file gpu_shader_update_mipmaps.bsl.hh.
| SharedStorage builtin::mipmaps::Resources< format, SharedStorage, InnerType >::shared_storage |
Definition at line 183 of file gpu_shader_update_mipmaps.bsl.hh.
Referenced by load_sample(), and store_shared_sample().