MCPcopy Create free account
hub / github.com/ROCm/clr / hipGraphicsSubResourceGetMappedArray

Function hipGraphicsSubResourceGetMappedArray

hipamd/src/hip_gl.cpp:182–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182hipError_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
228hipError_t hipGraphicsGLRegisterImage(hipGraphicsResource** resource, GLuint image, GLenum target,
229 unsigned int flags) {

Callers

nothing calls this directly

Calls 12

getCurrentDeviceFunction · 0.85
getCLMemObjectTypeFunction · 0.85
getCL2hipArrayFormatFunction · 0.85
getChannelFormatDescFunction · 0.85
getNumChannelsFunction · 0.85
asContextMethod · 0.80
getNumChannelsMethod · 0.80
asImageMethod · 0.45
createViewMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
getDepthMethod · 0.45

Tested by

no test coverage detected