| 928 | } |
| 929 | |
| 930 | bool opencl_encode_etc1s_blocks(opencl_context_ptr pContext, etc_block* pOutput_blocks, bool perceptual, uint32_t total_perms) |
| 931 | { |
| 932 | if (!opencl_is_available()) |
| 933 | return false; |
| 934 | |
| 935 | interval_timer tm; |
| 936 | tm.start(); |
| 937 | |
| 938 | assert(pContext->m_ocl_pixel_blocks); |
| 939 | if (!pContext->m_ocl_pixel_blocks) |
| 940 | return false; |
| 941 | |
| 942 | cl_encode_etc1s_param_struct ps; |
| 943 | ps.m_total_blocks = pContext->m_ocl_total_pixel_blocks; |
| 944 | ps.m_perceptual = perceptual; |
| 945 | ps.m_total_perms = total_perms; |
| 946 | |
| 947 | bool status = false; |
| 948 | |
| 949 | cl_mem vars = g_ocl.alloc_and_init_read_buffer(pContext->m_command_queue , &ps, sizeof(ps)); |
| 950 | cl_mem block_buf = g_ocl.alloc_write_buffer(sizeof(etc_block) * pContext->m_ocl_total_pixel_blocks); |
| 951 | |
| 952 | if (!vars || !block_buf) |
| 953 | goto exit; |
| 954 | |
| 955 | if (!g_ocl.set_kernel_args(pContext->m_ocl_encode_etc1s_blocks_kernel, vars, pContext->m_ocl_pixel_blocks, block_buf)) |
| 956 | goto exit; |
| 957 | |
| 958 | if (!g_ocl.run_2D(pContext->m_command_queue, pContext->m_ocl_encode_etc1s_blocks_kernel, pContext->m_ocl_total_pixel_blocks, 1)) |
| 959 | goto exit; |
| 960 | |
| 961 | if (!g_ocl.read_from_buffer(pContext->m_command_queue, block_buf, pOutput_blocks, pContext->m_ocl_total_pixel_blocks * sizeof(etc_block))) |
| 962 | goto exit; |
| 963 | |
| 964 | status = true; |
| 965 | |
| 966 | debug_printf("opencl_encode_etc1s_blocks: Elapsed time: %3.3f secs\n", tm.get_elapsed_secs()); |
| 967 | |
| 968 | exit: |
| 969 | g_ocl.destroy_buffer(block_buf); |
| 970 | g_ocl.destroy_buffer(vars); |
| 971 | |
| 972 | return status; |
| 973 | } |
| 974 | |
| 975 | bool opencl_encode_etc1s_pixel_clusters( |
| 976 | opencl_context_ptr pContext, |
no test coverage detected