From 5a48bc2168dcf3713acb9b3a2abf3b9ff35a93da Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Mon, 1 Oct 2018 15:28:34 +0530 Subject: [PATCH 1/2] Fixed image width for linear resource type texture [ROCm/hip commit: 0b8fc1d66a26054f0c7d9d4e4b559a60b31cb96e] --- projects/hip/src/hip_texture.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/hip/src/hip_texture.cpp b/projects/hip/src/hip_texture.cpp index 82bc5b5d8a..85fb006d43 100644 --- a/projects/hip/src/hip_texture.cpp +++ b/projects/hip/src/hip_texture.cpp @@ -198,6 +198,7 @@ bool getHipTextureObject(hipTextureObject_t* pTexObject, hsa_ext_image_t& image, return true; } +size_t channelFormatKindSize[] = {sizeof(unsigned),sizeof(signed),sizeof(float),sizeof(unsigned)}; // Texture Object APIs hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResourceDesc* pResDesc, const hipTextureDesc* pTexDesc, @@ -263,7 +264,7 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResou break; case hipResourceTypeLinear: devPtr = pResDesc->res.linear.devPtr; - imageDescriptor.width = pResDesc->res.linear.sizeInBytes; + imageDescriptor.width = pResDesc->res.linear.sizeInBytes/channelFormatKindSize[pResDesc->res.linear.desc.f]; imageDescriptor.height = 1; imageDescriptor.depth = 0; imageDescriptor.array_size = 0; From 8401146cd6db5d72e34300e61750a505c4836d4e Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Wed, 3 Oct 2018 12:07:38 +0530 Subject: [PATCH 2/2] Corrected the width calculation logic to accomodate multi channels [ROCm/hip commit: 5a3d89e99c3006f08a7eb631e9da6912daf52330] --- projects/hip/src/hip_texture.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/projects/hip/src/hip_texture.cpp b/projects/hip/src/hip_texture.cpp index 85fb006d43..521e0e24de 100644 --- a/projects/hip/src/hip_texture.cpp +++ b/projects/hip/src/hip_texture.cpp @@ -198,7 +198,6 @@ bool getHipTextureObject(hipTextureObject_t* pTexObject, hsa_ext_image_t& image, return true; } -size_t channelFormatKindSize[] = {sizeof(unsigned),sizeof(signed),sizeof(float),sizeof(unsigned)}; // Texture Object APIs hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResourceDesc* pResDesc, const hipTextureDesc* pTexDesc, @@ -264,7 +263,7 @@ hipError_t hipCreateTextureObject(hipTextureObject_t* pTexObject, const hipResou break; case hipResourceTypeLinear: devPtr = pResDesc->res.linear.devPtr; - imageDescriptor.width = pResDesc->res.linear.sizeInBytes/channelFormatKindSize[pResDesc->res.linear.desc.f]; + imageDescriptor.width = pResDesc->res.linear.sizeInBytes/((pResDesc->res.linear.desc.x + pResDesc->res.linear.desc.y + pResDesc->res.linear.desc.z + pResDesc->res.linear.desc.w)/8); imageDescriptor.height = 1; imageDescriptor.depth = 0; imageDescriptor.array_size = 0;