Instead of using the sampler field force_degamma to perform sRGB->linear conversion during pixel sampling, we use an appropriate image format instead. The overhead of this is having to create an image view when creating a texture object from an array.

Change-Id: I1ca368c312c1fd4b6f784a3a1b35b5eeb28070ff


[ROCm/clr commit: 23211f05d6]
Этот коммит содержится в:
Vladislav Sytchenko
2020-03-23 14:11:25 -04:00
родитель 21587cb0fa
Коммит e9eababfdd
3 изменённых файлов: 12 добавлений и 12 удалений
+5 -2
Просмотреть файл
@@ -76,14 +76,17 @@ cl_channel_type getCLChannelType(const hipArray_Format hipFormat,
} }
inline inline
cl_channel_order getCLChannelOrder(const unsigned int hipNumChannels) { cl_channel_order getCLChannelOrder(const unsigned int hipNumChannels,
const int sRGB) {
switch (hipNumChannels) { switch (hipNumChannels) {
case 1: case 1:
return CL_R; return CL_R;
case 2: case 2:
return CL_RG; return CL_RG;
case 4: case 4:
return CL_RGBA; return (sRGB == 1) ? CL_sRGBA : CL_RGBA;
default:
break;
} }
ShouldNotReachHere(); ShouldNotReachHere();
+1 -1
Просмотреть файл
@@ -545,7 +545,7 @@ hipError_t ihipArrayCreate(hipArray** array,
return hipErrorNotSupported; return hipErrorNotSupported;
} }
const cl_channel_order channelOrder = hip::getCLChannelOrder(pAllocateArray->NumChannels); const cl_channel_order channelOrder = hip::getCLChannelOrder(pAllocateArray->NumChannels, 0);
const cl_channel_type channelType = hip::getCLChannelType(pAllocateArray->Format, hipReadModeElementType); const cl_channel_type channelType = hip::getCLChannelType(pAllocateArray->Format, hipReadModeElementType);
const cl_mem_object_type imageType = hip::getCLMemObjectType(pAllocateArray->Width, const cl_mem_object_type imageType = hip::getCLMemObjectType(pAllocateArray->Width,
pAllocateArray->Height, pAllocateArray->Height,
+6 -9
Просмотреть файл
@@ -130,10 +130,6 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
if (pTexDesc->addressMode[0] == hipAddressModeBorder) { if (pTexDesc->addressMode[0] == hipAddressModeBorder) {
return hipErrorNotSupported; return hipErrorNotSupported;
} }
// We don't program the force_degamma/skip_degamma fields in the HW sampler SRD.
if (pTexDesc->sRGB == 1) {
return hipErrorNotSupported;
}
// We don't program the max_ansio_ratio field in the the HW sampler SRD. // We don't program the max_ansio_ratio field in the the HW sampler SRD.
if (pTexDesc->maxAnisotropy != 0) { if (pTexDesc->maxAnisotropy != 0) {
return hipErrorNotSupported; return hipErrorNotSupported;
@@ -221,10 +217,11 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
// We need to create an image view if the user requested to use normalized pixel values, // We need to create an image view if the user requested to use normalized pixel values,
// due to already having the image created with a different format. // due to already having the image created with a different format.
if ((pResViewDesc != nullptr) || if ((pResViewDesc != nullptr) ||
(readMode == hipReadModeNormalizedFloat)) { (readMode == hipReadModeNormalizedFloat) ||
(pTexDesc->sRGB == 1)) {
// TODO VDI currently right now can only change the format of the image. // TODO VDI currently right now can only change the format of the image.
const cl_channel_order channelOrder = (pResViewDesc != nullptr) ? hip::getCLChannelOrder(hip::getNumChannels(pResViewDesc->format)) : const cl_channel_order channelOrder = (pResViewDesc != nullptr) ? hip::getCLChannelOrder(hip::getNumChannels(pResViewDesc->format), pTexDesc->sRGB) :
hip::getCLChannelOrder(pResDesc->res.array.array->NumChannels); hip::getCLChannelOrder(pResDesc->res.array.array->NumChannels, pTexDesc->sRGB);
const cl_channel_type channelType = (pResViewDesc != nullptr) ? hip::getCLChannelType(hip::getArrayFormat(pResViewDesc->format), readMode) : const cl_channel_type channelType = (pResViewDesc != nullptr) ? hip::getCLChannelType(hip::getArrayFormat(pResViewDesc->format), readMode) :
hip::getCLChannelType(pResDesc->res.array.array->Format, readMode); hip::getCLChannelType(pResDesc->res.array.array->Format, readMode);
const amd::Image::Format imageFormat(cl_image_format{channelOrder, channelType}); const amd::Image::Format imageFormat(cl_image_format{channelOrder, channelType});
@@ -244,7 +241,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
break; break;
} }
case hipResourceTypeLinear: { case hipResourceTypeLinear: {
const cl_channel_order channelOrder = hip::getCLChannelOrder(hip::getNumChannels(pResDesc->res.linear.desc)); const cl_channel_order channelOrder = hip::getCLChannelOrder(hip::getNumChannels(pResDesc->res.linear.desc), pTexDesc->sRGB);
const cl_channel_type channelType = hip::getCLChannelType(hip::getArrayFormat(pResDesc->res.linear.desc), pTexDesc->readMode); const cl_channel_type channelType = hip::getCLChannelType(hip::getArrayFormat(pResDesc->res.linear.desc), pTexDesc->readMode);
const amd::Image::Format imageFormat({channelOrder, channelType}); const amd::Image::Format imageFormat({channelOrder, channelType});
const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType); const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType);
@@ -268,7 +265,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
break; break;
} }
case hipResourceTypePitch2D: { case hipResourceTypePitch2D: {
const cl_channel_order channelOrder = hip::getCLChannelOrder(hip::getNumChannels(pResDesc->res.pitch2D.desc)); const cl_channel_order channelOrder = hip::getCLChannelOrder(hip::getNumChannels(pResDesc->res.pitch2D.desc), pTexDesc->sRGB);
const cl_channel_type channelType = hip::getCLChannelType(hip::getArrayFormat(pResDesc->res.pitch2D.desc), pTexDesc->readMode); const cl_channel_type channelType = hip::getCLChannelType(hip::getArrayFormat(pResDesc->res.pitch2D.desc), pTexDesc->readMode);
const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType); const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType);
size_t offset = 0; size_t offset = 0;