|
2 | 2 | package com.nativelibs4java.opencl; |
3 | 3 | import static com.nativelibs4java.opencl.CLException.error; |
4 | 4 | import static com.nativelibs4java.opencl.JavaCL.CL; |
| 5 | +import static com.nativelibs4java.opencl.JavaCL.check; |
5 | 6 | import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_FALSE; |
6 | 7 | import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_ELEMENT_SIZE; |
7 | 8 | import static com.nativelibs4java.opencl.library.IOpenCLLibrary.CL_IMAGE_FORMAT; |
@@ -37,7 +38,7 @@ public abstract class CLImage extends CLMem { |
37 | 38 | this.format = format; |
38 | 39 | } |
39 | 40 |
|
40 | | - |
| 41 | + protected abstract long[] getDimensions(); |
41 | 42 |
|
42 | 43 | /** |
43 | 44 | * Return image format descriptor specified when image is created with CLContext.create{Input|Output|InputOutput}{2D|3D}. |
@@ -124,6 +125,65 @@ public void run() { |
124 | 125 | return evt; |
125 | 126 | } |
126 | 127 |
|
| 128 | + /** |
| 129 | +#documentCallsFunction("clEnqueueFillImage") |
| 130 | + * @param queue |
| 131 | + * @param queue Queue on which to enqueue this fill buffer command. |
| 132 | + * @param color Color components to fill the buffer with. |
| 133 | + * @param origin Origin point. |
| 134 | + * @param region Size of the region to fill. |
| 135 | +#documentEventsToWaitForAndReturn() |
| 136 | + */ |
| 137 | + public CLEvent fillImage(CLQueue queue, Object color, CLEvent... eventsToWaitFor) { |
| 138 | + long[] region = getDimensions(); |
| 139 | + long[] origin = new long[region.length]; |
| 140 | + return fillImage(queue, color, origin, region, eventsToWaitFor); |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | +#documentCallsFunction("clEnqueueFillImage") |
| 145 | + * @param queue |
| 146 | + * @param queue Queue on which to enqueue this fill buffer command. |
| 147 | + * @param color Color components to fill the buffer with. |
| 148 | + * @param origin Origin point. |
| 149 | + * @param region Size of the region to fill. |
| 150 | +#documentEventsToWaitForAndReturn() |
| 151 | + */ |
| 152 | + public CLEvent fillImage(CLQueue queue, Object color, long[] origin, long[] region, CLEvent... eventsToWaitFor) { |
| 153 | + context.getPlatform().requireMinVersionValue("clEnqueueFillImage", 1.2); |
| 154 | + Pointer<?> pColor; |
| 155 | + if (color instanceof int[]) { |
| 156 | + pColor = pointerToInts((int[]) color); |
| 157 | + } else if (color instanceof float[]) { |
| 158 | + pColor = pointerToFloats((float[]) color); |
| 159 | + } else { |
| 160 | + throw new IllegalArgumentException("Color should be an int[] or a float[] with 4 elements."); |
| 161 | + } |
| 162 | + check(pColor.getValidElements() == 4, "Color should have 4 elements."); |
| 163 | + |
| 164 | + #declareReusablePtrsAndEventsInOut() |
| 165 | + Pointer<SizeT> pOrigin = ptrs.sizeT3_1.pointerToSizeTs(origin); |
| 166 | + Pointer<SizeT> pRegion = ptrs.sizeT3_2.pointerToSizeTs(region); |
| 167 | + error(CL.clEnqueueFillImage( |
| 168 | + queue.getEntity(), |
| 169 | + getEntity(), |
| 170 | + getPeer(pColor), |
| 171 | + getPeer(pOrigin), |
| 172 | + getPeer(pRegion), |
| 173 | + #eventsInOutArgsRaw() |
| 174 | + )); |
| 175 | + #returnEventOut("queue") |
| 176 | + } |
| 177 | + |
| 178 | + // clEnqueueFillImage ( cl_command_queue command_queue, |
| 179 | + // cl_mem image, |
| 180 | + // const void *fill_color, |
| 181 | + // const size_t *origin, |
| 182 | + // const size_t *region, |
| 183 | + // cl_uint num_events_in_wait_list, |
| 184 | + // const cl_event *event_wait_list, |
| 185 | + // cl_event *event) |
| 186 | + |
127 | 187 | protected Pair<ByteBuffer, CLEvent> map(CLQueue queue, MapFlags flags, |
128 | 188 | Pointer<SizeT> offset3, Pointer<SizeT> length3, |
129 | 189 | Long imageRowPitch, |
|
0 commit comments