MCPcopy Create free account
hub / github.com/a2flo/floor / build_mip_map_minification_program

Method build_mip_map_minification_program

compute/compute_image.cpp:827–1245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

825#include <floor/compute/device/mip_map_minify.hpp>
826
827void compute_image::build_mip_map_minification_program() const {
828 // build mip-map minify kernels (do so in a separate thread so that we don't hold up anything)
829 task::spawn([this, ctx = dev.context]() {
830 auto prog = make_unique<minify_program>();
831 const llvm_toolchain::compile_options options {
832 // suppress any debug output for this, we only want to have console/log output if something goes wrong
833 .silence_debug_output = true
834 };
835
836 string base_path;
837 switch(ctx->get_compute_type()) {
838 case COMPUTE_TYPE::CUDA:
839 base_path = floor::get_cuda_base_path();
840 break;
841 case COMPUTE_TYPE::OPENCL:
842 base_path = floor::get_opencl_base_path();
843 break;
844 case COMPUTE_TYPE::VULKAN:
845 base_path = floor::get_vulkan_base_path();
846 break;
847 case COMPUTE_TYPE::HOST:
848 // doesn't matter
849 break;
850 default:
851 log_error("backend does not support (or need) mip-map minification kernels");
852 return;
853 }
854
855 prog->program = ctx->add_program_file(base_path + "floor/floor/compute/device/mip_map_minify.hpp", options);
856 if(prog->program == nullptr) {
857 log_error("failed to build minify kernels");
858 return;
859 }
860
861 // build/get all minification kernels
862 unordered_map<COMPUTE_IMAGE_TYPE, pair<string, shared_ptr<compute_kernel>>> minify_kernels {
863#define FLOOR_MINIFY_ENTRY(kernel_type, image_type, sample_type) \
864 { \
865 COMPUTE_IMAGE_TYPE::image_type | COMPUTE_IMAGE_TYPE::sample_type, \
866 { "libfloor_mip_map_minify_" #image_type "_" #sample_type , {} } \
867 },
868
869 FLOOR_MINIFY_IMAGE_TYPES(FLOOR_MINIFY_ENTRY)
870 };
871
872 // drop depth image kernel (handling) if there is no depth image support
873 if(!dev.image_depth_support ||
874 !dev.image_depth_write_support ||
875 // TODO: vulkan support
876 ctx->get_compute_type() == COMPUTE_TYPE::VULKAN) {
877 minify_kernels.erase(COMPUTE_IMAGE_TYPE::IMAGE_DEPTH | COMPUTE_IMAGE_TYPE::FLOAT);
878 minify_kernels.erase(COMPUTE_IMAGE_TYPE::IMAGE_DEPTH_ARRAY | COMPUTE_IMAGE_TYPE::FLOAT);
879 }
880
881 for(auto& entry : minify_kernels) {
882 entry.second.second = prog->program->get_kernel(entry.second.first);
883 if(entry.second.second == nullptr) {
884 log_error("failed to retrieve kernel \"$\" from minify program", entry.second.first);

Callers

nothing calls this directly

Calls 14

spawnFunction · 0.85
image_dim_countFunction · 0.85
lockMethod · 0.80
findMethod · 0.80
emplaceMethod · 0.80
unlockMethod · 0.80
get_compute_typeMethod · 0.45
add_program_fileMethod · 0.45
eraseMethod · 0.45
get_kernelMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected