cmpto_j2k: param to disable GPU conversions

for debugging + eventualy if there were problems as a workaround
This commit is contained in:
Martin Pulec
2024-09-03 11:56:20 +02:00
parent 7b91ebb5d4
commit 94afd6c5b4
2 changed files with 22 additions and 5 deletions

View File

@@ -188,12 +188,22 @@ static struct {
{R12L, CMPTO_444_U12_MSB16LE_P012, RG48, r12l_to_rg48_cuda},
};
#define CPU_CONV_PARAM "j2k-enc-cpu-conv"
ADD_TO_PARAM(
CPU_CONV_PARAM,
"* " CPU_CONV_PARAM "\n"
" Enforce CPU conversion instead of CUDA (applicable to R12L now)\n");
static void
set_pool(struct state_video_compress_j2k *s, struct video_desc desc)
{
const bool force_cpu_conv =
get_commandline_param(CPU_CONV_PARAM) != nullptr;
s->pool_in_device_memory = false;
#ifdef HAVE_CUDA
if (cuda_devices_count == 1) {
if (cuda_devices_count > 1) {
MSG(WARNING, "More than 1 CUDA device will use CPU buffers and "
"conversion...\n");
} else if (!force_cpu_conv || s->cuda_convert_func == nullptr) {
cuda_wrapper_set_device((int) cuda_devices[0]);
if (s->cuda_convert_func != nullptr) {
@@ -211,8 +221,7 @@ set_pool(struct state_video_compress_j2k *s, struct video_desc desc)
cuda_wrapper_malloc, cuda_wrapper_free>());
return;
}
MSG(WARNING, "More than 1 CUDA device will use CPU buffers and "
"conversion...\n");
s->cuda_convert_func = nullptr; // either was 0 or force_cpu_conv
s->pool = video_frame_pool(
s->max_in_frames,
cmpto_j2k_enc_cuda_buffer_data_allocator<cuda_wrapper_malloc_host,

View File

@@ -289,12 +289,19 @@ static const struct conv_props {
r12l_postprocessor_get_sz, r12l_postprocess_cuda },
};
#define CPU_CONV_PARAM "j2k-dec-cpu-conv"
ADD_TO_PARAM(
CPU_CONV_PARAM,
"* " CPU_CONV_PARAM "\n"
" Enforce CPU conversion instead of CUDA (applicable to R12L now)\n");
static bool
set_postprocess_convert(struct state_decompress_j2k *s,
struct cmpto_j2k_dec_ctx_cfg *ctx_cfg,
const struct conv_props *codec)
{
if (codec->run_callback != nullptr) {
const bool force_cpu_conv =
get_commandline_param(CPU_CONV_PARAM) != nullptr;
if (codec->run_callback != nullptr && !force_cpu_conv) {
if (cuda_devices_count == 1) {
CHECK_OK(cmpto_j2k_dec_ctx_cfg_set_postprocessor_cuda(
ctx_cfg, nullptr, nullptr,
@@ -306,7 +313,8 @@ set_postprocess_convert(struct state_decompress_j2k *s,
"More than 1 CUDA device set, will use CPU conversion...\n");
}
s->convert = codec->convert;
if (s->convert != nullptr && codec->run_callback == nullptr) {
if (s->convert != nullptr && codec->run_callback == nullptr &&
!force_cpu_conv) {
MSG(WARNING, "Compiled without CUDA, pixfmt conv will "
"be processed on CPU...\n");
}