| 180 | } |
| 181 | |
| 182 | hipError_t hipGraphicsSubResourceGetMappedArray(hipArray_t* array, hipGraphicsResource_t resource, |
| 183 | unsigned int arrayIndex, unsigned int mipLevel) { |
| 184 | HIP_INIT_API(hipGraphicsSubResourceGetMappedArray, array, resource, arrayIndex, mipLevel); |
| 185 | |
| 186 | amd::Context& amdContext = *(hip::getCurrentDevice()->asContext()); |
| 187 | if (array == nullptr || resource == nullptr) { |
| 188 | LogError("invalid array/resource"); |
| 189 | HIP_RETURN(hipErrorInvalidValue); |
| 190 | } |
| 191 | |
| 192 | amd::Image* image = (reinterpret_cast<amd::Memory*>(resource))->asImage(); |
| 193 | if (image == nullptr) { |
| 194 | LogError("invalid resource/image"); |
| 195 | HIP_RETURN(hipErrorInvalidValue); |
| 196 | } |
| 197 | // arrayIndex higher than zero not implmented |
| 198 | if (arrayIndex > 0) { |
| 199 | return hipErrorInvalidValue; |
| 200 | } |
| 201 | amd::Image* view = image->createView(amdContext, image->getImageFormat(), nullptr, mipLevel, 0); |
| 202 | |
| 203 | hipArray* myarray = new hipArray(); |
| 204 | |
| 205 | myarray->data = as_cl<amd::Memory>(view); |
| 206 | |
| 207 | myarray->width = view->getWidth(); |
| 208 | myarray->height = view->getHeight(); |
| 209 | myarray->depth = view->getDepth(); |
| 210 | |
| 211 | const cl_mem_object_type image_type = |
| 212 | hip::getCLMemObjectType(myarray->width, myarray->height, myarray->depth, hipArrayDefault); |
| 213 | myarray->type = image_type; |
| 214 | amd::Image::Format f = image->getImageFormat(); |
| 215 | myarray->Format = hip::getCL2hipArrayFormat(f.image_channel_data_type); |
| 216 | myarray->desc = hip::getChannelFormatDesc(f.getNumChannels(), myarray->Format); |
| 217 | myarray->NumChannels = hip::getNumChannels(myarray->desc); |
| 218 | myarray->isDrv = 0; |
| 219 | myarray->textureType = 0; |
| 220 | *array = myarray; |
| 221 | { |
| 222 | amd::ScopedLock lock(hip::hipArraySetLock); |
| 223 | hip::hipArraySet.insert(*array); |
| 224 | } |
| 225 | HIP_RETURN(hipSuccess); |
| 226 | } |
| 227 | |
| 228 | hipError_t hipGraphicsGLRegisterImage(hipGraphicsResource** resource, GLuint image, GLenum target, |
| 229 | unsigned int flags) { |
nothing calls this directly
no test coverage detected