Initialize the Compute library based on support types
| 250 | // Initialize the Compute library based on support types |
| 251 | // |
| 252 | CMP_ERROR CMP_API CMP_CreateComputeLibrary(MipSet* srcTexture, KernelOptions* kernel_options, void* CMips) |
| 253 | { |
| 254 | CMP_Compute_type CompType = kernel_options->encodeWith; |
| 255 | CMP_FORMAT cmp_format = kernel_options->format; |
| 256 | if ((CompType != ComputeType) || cmp_format != cmp_format_hold) |
| 257 | { |
| 258 | CMP_DestroyComputeLibrary(true); |
| 259 | } |
| 260 | |
| 261 | if (plugin_encoder_codec == NULL) |
| 262 | { |
| 263 | plugin_encoder_codec = reinterpret_cast<PluginInterface_Encoder*>(g_pluginManager.GetPlugin("ENCODER", GetFormatDesc(cmp_format))); |
| 264 | if (plugin_encoder_codec == NULL) |
| 265 | { |
| 266 | PrintInfo("Format [%s] for [%s] is not supported or failed to load\n", GetFormatDesc(cmp_format), GetEncodeWithDesc(CompType)); |
| 267 | return CMP_ERR_UNABLE_TO_INIT_COMPUTELIB; |
| 268 | } |
| 269 | cmp_format_hold = cmp_format; |
| 270 | } |
| 271 | |
| 272 | if (kernel_options->srcfile == NULL) |
| 273 | { |
| 274 | kernel_options->srcfile = plugin_encoder_codec->TC_ComputeSourceFile(kernel_options->encodeWith); |
| 275 | if (kernel_options->srcfile == NULL) |
| 276 | { |
| 277 | PrintInfo("Failed to load the encoders shader code\n"); |
| 278 | return CMP_ERR_NOSHADER_CODE_DEFINED; |
| 279 | } |
| 280 | } |
| 281 | |
| 282 | // Initialize the compression codec, pass kernel options |
| 283 | kernel_options->height = srcTexture->dwHeight; |
| 284 | kernel_options->width = srcTexture->dwWidth; |
| 285 | kernel_options->srcformat = srcTexture->m_format; |
| 286 | if (plugin_encoder_codec->TC_Init(kernel_options) != 0) |
| 287 | { |
| 288 | PrintInfo("Failed to init encoder\n"); |
| 289 | return CMP_ERR_UNABLE_TO_INIT_COMPUTELIB; |
| 290 | } |
| 291 | |
| 292 | if (plugin_encoder_codec->TC_PluginSetSharedIO(CMips) != 0) |
| 293 | { |
| 294 | PrintInfo("Warning unable to set print IO\n"); |
| 295 | } |
| 296 | |
| 297 | // Are we re-running the same codec type |
| 298 | if (g_ComputeBase && (ComputeType == CompType)) |
| 299 | { |
| 300 | return CMP_OK; |
| 301 | } |
| 302 | |
| 303 | switch (CompType) |
| 304 | { |
| 305 | default: |
| 306 | case CMP_HPC: |
| 307 | g_ComputeBase = reinterpret_cast<PluginInterface_Pipeline*>(g_pluginManager.GetPlugin("PIPELINE", "HPC")); |
| 308 | break; |
| 309 | case CMP_GPU_OCL: |