| 69 | |
| 70 | template<typename T> |
| 71 | void floodFill(Param out, const Param image, const Param seedsx, |
| 72 | const Param seedsy, const T newValue, const T lowValue, |
| 73 | const T highValue, const af::connectivity nlookup) { |
| 74 | constexpr int RADIUS = 1; |
| 75 | |
| 76 | UNUSED(nlookup); |
| 77 | std::array<std::string, 11> options = { |
| 78 | DefineKeyValue(T, dtype_traits<T>::getName()), |
| 79 | DefineValue(RADIUS), |
| 80 | DefineValue(VALID), |
| 81 | DefineValue(INVALID), |
| 82 | DefineValue(ZERO), |
| 83 | DefineKey(FLOOD_FILL_STEP), |
| 84 | DefineKeyValue(LMEM_WIDTH, (THREADS_X + 2 * RADIUS)), |
| 85 | DefineKeyValue(LMEM_HEIGHT, (THREADS_Y + 2 * RADIUS)), |
| 86 | DefineKeyValue(GROUP_SIZE, (THREADS_Y * THREADS_X)), |
| 87 | getTypeBuildDefinition<T>()}; |
| 88 | |
| 89 | auto floodStep = |
| 90 | common::getKernel("flood_step", {{flood_fill_cl_src}}, |
| 91 | TemplateArgs(TemplateTypename<T>()), options); |
| 92 | cl::NDRange local(kernel::THREADS_X, kernel::THREADS_Y, 1); |
| 93 | cl::NDRange global(divup(out.info.dims[0], local[0]) * local[0], |
| 94 | divup(out.info.dims[1], local[1]) * local[1], 1); |
| 95 | |
| 96 | initSeeds<T>(out, seedsx, seedsy); |
| 97 | |
| 98 | int notFinished = 1; |
| 99 | cl::Buffer* dContinue = bufferAlloc(sizeof(int)); |
| 100 | |
| 101 | while (notFinished) { |
| 102 | notFinished = 0; |
| 103 | floodStep.setFlag(dContinue, ¬Finished); |
| 104 | floodStep(cl::EnqueueArgs(getQueue(), global, local), *out.data, |
| 105 | out.info, *image.data, image.info, lowValue, highValue, |
| 106 | *dContinue); |
| 107 | CL_DEBUG_FINISH(getQueue()); |
| 108 | notFinished = floodStep.getFlag(dContinue); |
| 109 | } |
| 110 | bufferFree(dContinue); |
| 111 | finalizeOutput<T>(out, newValue); |
| 112 | } |
| 113 | |
| 114 | } // namespace kernel |
| 115 | } // namespace opencl |
nothing calls this directly
no test coverage detected