Blender V5.3
builtin::mipmaps::Resources< format, SharedStorage, InnerType > Struct Template Reference

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

Detailed Description

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
struct builtin::mipmaps::Resources< format, SharedStorage, InnerType >

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.

Template Parameters
formatis the texture format of the mipmap images.
SharedStorageis the storage class to store intermediate levels. Depending on the texture format an optimal storage class can be selected.
InnerTypethe 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.

Member Function Documentation

◆ fill_intermediate_tile()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
void builtin::mipmaps::Resources< format, SharedStorage, InnerType >::fill_intermediate_tile ( uint local_index,
int2 dst_tile_coord,
bool use_bounds_check )
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.

◆ fill_last_tile()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
void builtin::mipmaps::Resources< format, SharedStorage, InnerType >::fill_last_tile ( uint local_index,
int2 dst_tile_coord,
bool use_bounds_check )
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.

◆ intermediate_level_loop()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
void builtin::mipmaps::Resources< format, SharedStorage, InnerType >::intermediate_level_loop ( int2 init_dst_coord,
int2 init_shared_coord,
int2 step,
int iterations,
bool use_bounds_check )
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().

◆ level_size()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
int2 builtin::mipmaps::Resources< format, SharedStorage, InnerType >::level_size ( int level)
inline

◆ load_sample()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
InnerType builtin::mipmaps::Resources< format, SharedStorage, InnerType >::load_sample ( int2 src_coord,
bool load_from_shared )
inline

◆ pyramid_reduce_2()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
InnerType builtin::mipmaps::Resources< format, SharedStorage, InnerType >::pyramid_reduce_2 ( InnerType v0,
InnerType v1 )
inline

Definition at line 261 of file gpu_shader_update_mipmaps.bsl.hh.

Referenced by reduce_store_sample().

◆ pyramid_reduce_3()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
InnerType builtin::mipmaps::Resources< format, SharedStorage, InnerType >::pyramid_reduce_3 ( float a0,
InnerType v0,
float a1,
InnerType v1,
float a2,
InnerType v2 )
inline

Definition at line 255 of file gpu_shader_update_mipmaps.bsl.hh.

Referenced by reduce_store_sample().

◆ reduce_store_sample()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
template<bool load_from_shared>
template float4 builtin::mipmaps::Resources< format, SharedStorage, InnerType >::reduce_store_sample< false > ( int2 src_coord,
int ,
int2 kernel_size,
int2 dst_image_size,
int2 dst_coord,
int dst_level )
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().

◆ store_sample()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
void builtin::mipmaps::Resources< format, SharedStorage, InnerType >::store_sample ( int2 dst_coord,
int dst_level,
InnerType color )
inline

◆ store_shared_sample()

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
void builtin::mipmaps::Resources< format, SharedStorage, InnerType >::store_shared_sample ( int2 dst_coord,
InnerType color )
inline

Definition at line 213 of file gpu_shader_update_mipmaps.bsl.hh.

References shared_storage.

Referenced by intermediate_level_loop().

Member Data Documentation

◆ chunk_list

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
const MipmapChunkCoord(& builtin::mipmaps::Resources< format, SharedStorage, InnerType >::chunk_list)[]

Definition at line 176 of file gpu_shader_update_mipmaps.bsl.hh.

◆ consts

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ dst_layer

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ group_offset

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::group_offset

Definition at line 170 of file gpu_shader_update_mipmaps.bsl.hh.

◆ margin_x

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::margin_x

Definition at line 173 of file gpu_shader_update_mipmaps.bsl.hh.

◆ margin_y

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::margin_y

Definition at line 174 of file gpu_shader_update_mipmaps.bsl.hh.

◆ mip_array_in

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ mip_array_out1

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ mip_array_out2

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ mip_in

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ mip_out1

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ mip_out2

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().

◆ num_levels

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::num_levels

Definition at line 169 of file gpu_shader_update_mipmaps.bsl.hh.

◆ partial_dst_level

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
const int builtin::mipmaps::Resources< format, SharedStorage, InnerType >::partial_dst_level

Definition at line 171 of file gpu_shader_update_mipmaps.bsl.hh.

◆ shared_storage

template<enum TextureWriteFormat format, typename SharedStorage, typename InnerType>
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().


The documentation for this struct was generated from the following file: