| 2164 | } |
| 2165 | |
| 2166 | bool basis_parallel_compress( |
| 2167 | uint32_t total_threads, |
| 2168 | const basisu::vector<basis_compressor_params>& params_vec, |
| 2169 | basisu::vector< parallel_results >& results_vec) |
| 2170 | { |
| 2171 | assert(g_library_initialized); |
| 2172 | if (!g_library_initialized) |
| 2173 | { |
| 2174 | error_printf("basis_parallel_compress: basisu_encoder_init() MUST be called before using any encoder functionality!\n"); |
| 2175 | return false; |
| 2176 | } |
| 2177 | |
| 2178 | assert(total_threads >= 1); |
| 2179 | total_threads = basisu::maximum<uint32_t>(total_threads, 1); |
| 2180 | |
| 2181 | job_pool jpool(total_threads); |
| 2182 | |
| 2183 | results_vec.resize(0); |
| 2184 | results_vec.resize(params_vec.size()); |
| 2185 | |
| 2186 | std::atomic<bool> result; |
| 2187 | result = true; |
| 2188 | |
| 2189 | std::atomic<bool> opencl_failed; |
| 2190 | opencl_failed = false; |
| 2191 | |
| 2192 | for (uint32_t pindex = 0; pindex < params_vec.size(); pindex++) |
| 2193 | { |
| 2194 | jpool.add_job([pindex, ¶ms_vec, &results_vec, &result, &opencl_failed] { |
| 2195 | |
| 2196 | basis_compressor_params params = params_vec[pindex]; |
| 2197 | parallel_results& results = results_vec[pindex]; |
| 2198 | |
| 2199 | interval_timer tm; |
| 2200 | tm.start(); |
| 2201 | |
| 2202 | basis_compressor c; |
| 2203 | |
| 2204 | // Dummy job pool |
| 2205 | job_pool task_jpool(1); |
| 2206 | params.m_pJob_pool = &task_jpool; |
| 2207 | // TODO: Remove this flag entirely |
| 2208 | params.m_multithreading = true; |
| 2209 | |
| 2210 | // Stop using OpenCL if a failure ever occurs. |
| 2211 | if (opencl_failed) |
| 2212 | params.m_use_opencl = false; |
| 2213 | |
| 2214 | bool status = c.init(params); |
| 2215 | |
| 2216 | if (c.get_opencl_failed()) |
| 2217 | opencl_failed = true; |
| 2218 | |
| 2219 | if (status) |
| 2220 | { |
| 2221 | basis_compressor::error_code ec = c.process(); |
| 2222 | |
| 2223 | if (c.get_opencl_failed()) |
nothing calls this directly
no test coverage detected