From daf8977c1254c3767600a01352afb933ffdb6276 Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 16 Oct 2019 12:03:49 -0400 Subject: [PATCH] P4 to Git Change 2014458 by jujiang@JJ-HIP on 2019/10/16 11:52:39 SWDEV-205925 - Update HIP texture APIs for issue in hipTexRefSetAddress in HIP/PAL on Windows - Remove the nullptr possibility http://ocltc.amd.com/reviews/r/18121/ Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_texture.cpp#23 edit --- hipamd/api/hip/hip_texture.cpp | 35 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/hipamd/api/hip/hip_texture.cpp b/hipamd/api/hip/hip_texture.cpp index b7e6293b95..5d4e964686 100644 --- a/hipamd/api/hip/hip_texture.cpp +++ b/hipamd/api/hip/hip_texture.cpp @@ -394,21 +394,15 @@ hipError_t hipGetTextureObjectTextureDesc(hipTextureDesc* pTexDesc, hipError_t ihipBindTexture(cl_mem_object_type type, size_t* offset, textureReference* tex, const void* devPtr, - const hipChannelFormatDesc* desc, size_t width, size_t height, + const hipChannelFormatDesc& desc, size_t width, size_t height, size_t pitch) { if (tex == nullptr) { return hipErrorInvalidImage; } if (hip::getCurrentContext()) { cl_image_format image_format; - - if (nullptr == desc) { - getDrvChannelOrderAndType(tex->format, tex->numChannels, + getChannelOrderAndType(desc, hipReadModeElementType, &image_format.image_channel_order, &image_format.image_channel_data_type); - } else { - getChannelOrderAndType(*desc, hipReadModeElementType, - &image_format.image_channel_order, &image_format.image_channel_data_type); - } const amd::Image::Format imageFormat(image_format); amd::Memory* memory = getMemoryObject(devPtr, *offset); amd::Image* image = new (*hip::getCurrentContext()) amd::Image(*memory->asBuffer(), @@ -431,17 +425,13 @@ hipError_t ihipBindTexture(cl_mem_object_type type, case CL_MEM_OBJECT_IMAGE1D: resDesc.resType = hipResourceTypeLinear; resDesc.res.linear.devPtr = const_cast(devPtr); - if (nullptr != desc) { - resDesc.res.linear.desc = *desc; - } + resDesc.res.linear.desc = desc; resDesc.res.linear.sizeInBytes = image->getSize(); break; case CL_MEM_OBJECT_IMAGE2D: resDesc.resType = hipResourceTypePitch2D; resDesc.res.pitch2D.devPtr = const_cast(devPtr); - if (nullptr != desc) { - resDesc.res.pitch2D.desc = *desc; - } + resDesc.res.pitch2D.desc = desc; resDesc.res.pitch2D.width = width; resDesc.res.pitch2D.height = height; resDesc.res.pitch2D.pitchInBytes = pitch; @@ -471,7 +461,7 @@ hipError_t hipBindTexture(size_t* offset, textureReference* tex, const void* dev &image_format.image_channel_order, &image_format.image_channel_data_type); const amd::Image::Format imageFormat(image_format); - HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE1D, offset, tex, devPtr, desc, size / imageFormat.getElementSize(), 1, size)); + HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE1D, offset, tex, devPtr, *desc, size / imageFormat.getElementSize(), 1, size)); } hipError_t hipBindTexture2D(size_t* offset, textureReference* tex, const void* devPtr, @@ -479,7 +469,7 @@ hipError_t hipBindTexture2D(size_t* offset, textureReference* tex, const void* d size_t pitch) { HIP_INIT_API(NONE, offset, tex, devPtr, desc, width, height, pitch); - HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE2D, offset, tex, devPtr, desc, width, height, pitch)); + HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE2D, offset, tex, devPtr, *desc, width, height, pitch)); } hipError_t hipBindTextureToArray(textureReference* tex, hipArray_const_t array, @@ -498,7 +488,7 @@ hipError_t ihipBindTextureImpl(TlsData* tls, int dim, enum hipTextureReadMode re assert(1 == dim); - HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE1D, offset, tex, devPtr, desc, size, 1, 0)); + HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE1D, offset, tex, devPtr, *desc, size, 1, 0)); } hipError_t ihipBindTextureToArrayImpl(TlsData* tls, int dim, enum hipTextureReadMode readMode, @@ -521,7 +511,7 @@ hipError_t ihipBindTextureToArrayImpl(TlsData* tls, int dim, enum hipTextureRead HIP_RETURN(hipErrorInvalidValue); } - HIP_RETURN(ihipBindTexture(clType, &offset, tex, array->data, &desc, array->width, + HIP_RETURN(ihipBindTexture(clType, &offset, tex, array->data, desc, array->width, array->height, array->depth)); } @@ -666,7 +656,7 @@ hipError_t hipTexRefSetArray(textureReference* tex, hipArray_const_t array, unsi HIP_RETURN(hipErrorInvalidImage); } - HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE2D, &offset, tex, array->data, &array->desc, array->width, + HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE2D, &offset, tex, array->data, array->desc, array->width, array->height, 0)); } @@ -703,8 +693,8 @@ hipError_t hipTexRefSetAddress(size_t* offset, textureReference* tex, hipDevicep getDrvChannelOrderAndType(tex->format, tex->numChannels, &image_format.image_channel_order, &image_format.image_channel_data_type); const amd::Image::Format imageFormat(image_format); - - HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE1D, offset, tex, devPtr, nullptr, size / imageFormat.getElementSize(), 1, size)); + hipChannelFormatDesc channelDesc = hipCreateChannelDesc(); + HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE1D, offset, tex, devPtr, channelDesc, size / imageFormat.getElementSize(), 1, size)); } hipError_t hipTexRefSetAddress2D(textureReference* tex, const HIP_ARRAY_DESCRIPTOR* desc, @@ -716,5 +706,6 @@ hipError_t hipTexRefSetAddress2D(textureReference* tex, const HIP_ARRAY_DESCRIPT } size_t offset; - HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE2D, &offset, tex, devPtr, nullptr, desc->Width, desc->Height, pitch)); + hipChannelFormatDesc channelDesc = hipCreateChannelDesc(); + HIP_RETURN(ihipBindTexture(CL_MEM_OBJECT_IMAGE2D, &offset, tex, devPtr, channelDesc, desc->Width, desc->Height, pitch)); }