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

Function ihipMipmapArrayCreate

hipamd/src/hip_memory.cpp:4159–4226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4157}
4158
4159hipError_t ihipMipmapArrayCreate(hipMipmappedArray_t* mipmapped_array_pptr,
4160 HIP_ARRAY3D_DESCRIPTOR* mipmapped_array_desc_ptr,
4161 unsigned int num_mipmap_levels, size_t offset = 0,
4162 amd::Memory* buffer = nullptr) {
4163 bool mipMapSupport = true;
4164 amd::Context& context = *hip::getCurrentDevice()->asContext();
4165 const std::vector<amd::Device*>& devices = context.devices();
4166 for (auto& dev : devices) {
4167 if (!dev->settings().checkExtension(ClKhrMipMapImage)) {
4168 mipMapSupport = false;
4169 }
4170 }
4171 if (mipMapSupport == false) {
4172 LogPrintfError("Mipmap not supported on one of the devices, Mip Level: %d", num_mipmap_levels);
4173 return hipErrorNotSupported;
4174 }
4175 if (!mipmapped_array_pptr || !mipmapped_array_desc_ptr) {
4176 return hipErrorInvalidValue;
4177 }
4178 unsigned int flags = hipArrayDefault | hipArrayLayered | hipArraySurfaceLoadStore |
4179 hipArrayTextureGather; // hipArrayCubemap isn't supported
4180 if (mipmapped_array_desc_ptr->Flags & (~flags)) {
4181 return hipErrorInvalidValue;
4182 }
4183 if (mipmapped_array_desc_ptr->Flags & hipArrayTextureGather) {
4184 // hipArrayTextureGather only works for 2D
4185 if (mipmapped_array_desc_ptr->Width == 0 || mipmapped_array_desc_ptr->Height == 0 ||
4186 mipmapped_array_desc_ptr->Depth > 0)
4187 return hipErrorInvalidValue;
4188 }
4189
4190 const cl_channel_order channel_order =
4191 hip::getCLChannelOrder(mipmapped_array_desc_ptr->NumChannels, 0);
4192 const cl_channel_type channel_type =
4193 hip::getCLChannelType(mipmapped_array_desc_ptr->Format, hipReadModeElementType);
4194 const cl_mem_object_type image_type =
4195 hip::getCLMemObjectType(mipmapped_array_desc_ptr->Width, mipmapped_array_desc_ptr->Height,
4196 mipmapped_array_desc_ptr->Depth, mipmapped_array_desc_ptr->Flags);
4197 hipError_t status = hipSuccess;
4198 // Create a new amd::Image with mipmap
4199 amd::Image* image =
4200 ihipImageCreate(channel_order, channel_type, image_type, mipmapped_array_desc_ptr->Width,
4201 mipmapped_array_desc_ptr->Height, mipmapped_array_desc_ptr->Depth,
4202 mipmapped_array_desc_ptr->Depth, 0 /* row pitch */, 0 /* slice pitch */,
4203 num_mipmap_levels, offset, buffer, status);
4204
4205 if (image == nullptr) {
4206 return status;
4207 }
4208
4209 cl_mem cl_mem_obj = as_cl<amd::Memory>(image);
4210 *mipmapped_array_pptr = new hipMipmappedArray();
4211 (*mipmapped_array_pptr)->data = reinterpret_cast<void*>(cl_mem_obj);
4212
4213 (*mipmapped_array_pptr)->desc = hip::getChannelFormatDesc(mipmapped_array_desc_ptr->NumChannels,
4214 mipmapped_array_desc_ptr->Format);
4215 (*mipmapped_array_pptr)->type = image_type;
4216 (*mipmapped_array_pptr)->width = mipmapped_array_desc_ptr->Width;

Calls 8

getCurrentDeviceFunction · 0.85
getCLChannelOrderFunction · 0.85
getCLChannelTypeFunction · 0.85
getCLMemObjectTypeFunction · 0.85
ihipImageCreateFunction · 0.85
getChannelFormatDescFunction · 0.85
asContextMethod · 0.80
checkExtensionMethod · 0.80

Tested by

no test coverage detected