Enable initial sRGB support

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
This commit is contained in:
Vladislav Sytchenko
2020-03-23 14:11:25 -04:00
bovenliggende faf3b83594
commit 8ddeeb4551
3 gewijzigde bestanden met toevoegingen van 12 en 12 verwijderingen
+5 -2
Bestand weergeven
@@ -76,14 +76,17 @@ cl_channel_type getCLChannelType(const hipArray_Format hipFormat,
}
inline
cl_channel_order getCLChannelOrder(const unsigned int hipNumChannels) {
cl_channel_order getCLChannelOrder(const unsigned int hipNumChannels,
const int sRGB) {
switch (hipNumChannels) {
case 1:
return CL_R;
case 2:
return CL_RG;
case 4:
return CL_RGBA;
return (sRGB == 1) ? CL_sRGBA : CL_RGBA;
default:
break;
}
ShouldNotReachHere();
+1 -1
Bestand weergeven
@@ -545,7 +545,7 @@ hipError_t ihipArrayCreate(hipArray** array,
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_mem_object_type imageType = hip::getCLMemObjectType(pAllocateArray->Width,
pAllocateArray->Height,
+6 -9
Bestand weergeven
@@ -130,10 +130,6 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
if (pTexDesc->addressMode[0] == hipAddressModeBorder) {
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.
if (pTexDesc->maxAnisotropy != 0) {
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,
// due to already having the image created with a different format.
if ((pResViewDesc != nullptr) ||
(readMode == hipReadModeNormalizedFloat)) {
(readMode == hipReadModeNormalizedFloat) ||
(pTexDesc->sRGB == 1)) {
// 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)) :
hip::getCLChannelOrder(pResDesc->res.array.array->NumChannels);
const cl_channel_order channelOrder = (pResViewDesc != nullptr) ? hip::getCLChannelOrder(hip::getNumChannels(pResViewDesc->format), pTexDesc->sRGB) :
hip::getCLChannelOrder(pResDesc->res.array.array->NumChannels, pTexDesc->sRGB);
const cl_channel_type channelType = (pResViewDesc != nullptr) ? hip::getCLChannelType(hip::getArrayFormat(pResViewDesc->format), readMode) :
hip::getCLChannelType(pResDesc->res.array.array->Format, readMode);
const amd::Image::Format imageFormat(cl_image_format{channelOrder, channelType});
@@ -244,7 +241,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
break;
}
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 amd::Image::Format imageFormat({channelOrder, channelType});
const cl_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType);
@@ -268,7 +265,7 @@ hipError_t ihipCreateTextureObject(hipTextureObject_t* pTexObject,
break;
}
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_mem_object_type imageType = hip::getCLMemObjectType(pResDesc->resType);
size_t offset = 0;