MCPcopy Create free account
hub / github.com/defold/defold / init

Method init

engine/dlib/src/basis/encoder/basisu_frontend.cpp:51–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49 }
50
51 bool basisu_frontend::init(const params &p)
52 {
53 debug_printf("basisu_frontend::init: Multithreaded: %u, Job pool total threads: %u, NumEndpointClusters: %u, NumSelectorClusters: %u, Perceptual: %u, CompressionLevel: %u\n",
54 p.m_multithreaded, p.m_pJob_pool ? p.m_pJob_pool->get_total_threads() : 0,
55 p.m_max_endpoint_clusters, p.m_max_selector_clusters, p.m_perceptual, p.m_compression_level);
56
57 if ((p.m_max_endpoint_clusters < 1) || (p.m_max_endpoint_clusters > cMaxEndpointClusters))
58 return false;
59 if ((p.m_max_selector_clusters < 1) || (p.m_max_selector_clusters > cMaxSelectorClusters))
60 return false;
61
62 m_source_blocks.resize(0);
63 append_vector(m_source_blocks, p.m_pSource_blocks, p.m_num_source_blocks);
64
65 m_params = p;
66
67 if (m_params.m_pOpenCL_context)
68 {
69 BASISU_ASSUME(sizeof(cl_pixel_block) == sizeof(pixel_block));
70
71 // Upload the RGBA pixel blocks a single time.
72 if (!opencl_set_pixel_blocks(m_params.m_pOpenCL_context, m_source_blocks.size(), (cl_pixel_block*)m_source_blocks.data()))
73 {
74 // This is not fatal, we just won't use OpenCL.
75 error_printf("basisu_frontend::init: opencl_set_pixel_blocks() failed\n");
76 m_params.m_pOpenCL_context = nullptr;
77 m_opencl_failed = true;
78 }
79 }
80
81 m_encoded_blocks.resize(m_params.m_num_source_blocks);
82 memset(&m_encoded_blocks[0], 0, m_encoded_blocks.size() * sizeof(m_encoded_blocks[0]));
83
84 m_num_endpoint_codebook_iterations = 1;
85 m_num_selector_codebook_iterations = 1;
86
87 switch (p.m_compression_level)
88 {
89 case 0:
90 {
91 m_endpoint_refinement = false;
92 m_use_hierarchical_endpoint_codebooks = true;
93 m_use_hierarchical_selector_codebooks = true;
94 break;
95 }
96 case 1:
97 {
98 m_endpoint_refinement = true;
99 m_use_hierarchical_endpoint_codebooks = true;
100 m_use_hierarchical_selector_codebooks = true;
101
102 break;
103 }
104 case 2:
105 {
106 m_endpoint_refinement = true;
107 m_use_hierarchical_endpoint_codebooks = true;
108 m_use_hierarchical_selector_codebooks = true;

Callers

nothing calls this directly

Calls 8

debug_printfFunction · 0.85
append_vectorFunction · 0.85
opencl_set_pixel_blocksFunction · 0.85
error_printfFunction · 0.85
get_total_threadsMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected