Device texture functions should not normalize the sampled pixel (#1826)

* Device texture functions should not normalize the sampled pixel. This is already done by HW.
* Add support to use h/w capability for normalized float data convertion for driver API's

Co-authored-by: ansurya <50609411+ansurya@users.noreply.github.com>


[ROCm/hip commit: ef514eef71]
이 커밋은 다음에 포함됨:
vsytch그리고ansurya 작성하고 GitHub가 2020-02-05 20:56:17 +05:30를 커밋함
1 부모 9d723d9c21
커밋 e5243c1834
5 파일이 변경됨
+49 -35

검색과 일치하는 파일 없음

+19 -3
파일 보기
@@ -27,8 +27,24 @@ THE SOFTWARE.
*/
#include "test_common.h"
#define SIZE 10
static float getNormalizedValue(const float value,
const enum hipArray_Format texFormat) {
switch (texFormat) {
case HIP_AD_FORMAT_SIGNED_INT8:
return (value / SCHAR_MAX);
case HIP_AD_FORMAT_UNSIGNED_INT8:
return (value / UCHAR_MAX);
case HIP_AD_FORMAT_SIGNED_INT16:
return (value / SHRT_MAX);
case HIP_AD_FORMAT_UNSIGNED_INT16:
return (value / USHRT_MAX);
default:
return value;
}
}
texture<float, hipTextureType1D, hipReadModeElementType> textureNormalizedVal_1D;
__global__ void normalizedValTextureTest(unsigned int numElements, float* pDst)
@@ -47,7 +63,6 @@ bool textureTest(enum hipArray_Format texFormat)
T *dData = NULL;
HIPCHECK(hipMalloc((void **) &dData, sizeof(T)*SIZE));
HIPCHECK(hipMemcpyHtoD((hipDeviceptr_t)dData, hData, sizeof(T)*SIZE));
textureReference* texRef = &textureNormalizedVal_1D;
HIPCHECK(hipTexRefSetAddressMode(texRef, 0, hipAddressModeClamp));
HIPCHECK(hipTexRefSetAddressMode(texRef, 1, hipAddressModeClamp));
@@ -73,7 +88,8 @@ bool textureTest(enum hipArray_Format texFormat)
for(int i = 0; i < SIZE; i++)
{
if((float)hData[i]/texFormatToSize[texFormat] != hOutputData[i])
float expected = getNormalizedValue(float(hData[i]), texFormat);
if(expected != hOutputData[i])
{
printf("mismatch at index:%d for texType:%d output:%f\n",i,texFormat,hOutputData[i]);
testResult = false;