2
0

P4 to Git Change 1058007 by rili@rili_opencl_stg_01 on 2014/07/22 17:28:41

EPR #399808 - Fixed wrong conversion of sRGBA when using host copy instead of blit kernel transfer

Affected files ...

... //depot/stg/opencl/drivers/opencl/api/opencl/amdocl/cl_memobj.cpp#68 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/blit.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/blit.hpp#2 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpublit.cpp#107 edit
Este cometimento está contido em:
foreman
2014-07-22 17:42:44 -04:00
ascendente d2b905f18e
cometimento 1681dd142f
3 ficheiros modificados com 54 adições e 4 eliminações
+39 -1
Ver ficheiro
@@ -683,6 +683,20 @@ HostBlitManager::fillImage(
// rowPitch and slicePitch in bytes
size_t devRowPitch;
size_t devSlicePitch;
void *newpattern = const_cast<void *>(pattern);
cl_float4 fFillColor;
// Converting a linear RGB floating-point color value to a normalized 8-bit unsigned integer sRGB value so that the cpu path can treat sRGB as RGB for host transfer.
if (memory.owner()->asImage()->getImageFormat().image_channel_order == CL_sRGBA) {
float *fColor = static_cast<float *>(newpattern);
fFillColor.s[0] = sRGBmap(fColor[0]) / 255.0f;
fFillColor.s[1] = sRGBmap(fColor[1]) / 255.0f;
fFillColor.s[2] = sRGBmap(fColor[2]) / 255.0f;
fFillColor.s[3] = fColor[3];
newpattern = static_cast<void *>(&fFillColor);
}
// Map memory
void* fillMem = memory.cpuMap(vDev_, (entire) ? Memory::CpuWriteOnly : 0,
startLayer, numLayers, &devRowPitch, &devSlicePitch);
@@ -693,7 +707,7 @@ HostBlitManager::fillImage(
float fillValue[4];
memset(fillValue, 0, sizeof(fillValue));
memory.owner()->asImage()->getImageFormat().formatColor(pattern, fillValue);
memory.owner()->asImage()->getImageFormat().formatColor(newpattern, fillValue);
size_t elementSize = memory.owner()->asImage()->getImageFormat().getElementSize();
size_t offset = origin[0] * elementSize;
@@ -734,4 +748,28 @@ HostBlitManager::fillImage(
return true;
}
cl_uint
HostBlitManager::sRGBmap(float fc) const
{
double c = (double)fc;
#ifdef ATI_OS_LINUX
if (isnan(c))
c = 0.0;
#else
if (_isnan(c))
c = 0.0;
#endif
if (c > 1.0)
c = 1.0;
else if (c < 0.0)
c = 0.0;
else if (c < 0.0031308)
c = 12.92 * c;
else
c = (1055.0/1000.0) * pow(c, 5.0/12.0) - (55.0/1000.0);
return (cl_uint)(c * 255.0 + 0.5);
}
} // namespace gpu
+2
Ver ficheiro
@@ -352,6 +352,8 @@ public:
bool entire = false //!< Entire buffer will be updated
) const;
cl_uint sRGBmap(float fc) const;
protected:
VirtualDevice& vDev_; //!< Virtual device object
const amd::Device& dev_; //!< Physical device
+13 -3
Ver ficheiro
@@ -2583,6 +2583,9 @@ KernelBlitManager::fillImage(
fillType = FillImage;
dim = 3;
void *newpattern = const_cast<void *>(pattern);
cl_uint4 iFillColor;
bool rejected = false;
bool releaseView = false;
// For depth, we need to create a view
@@ -2605,6 +2608,13 @@ KernelBlitManager::fillImage(
}
if (gpuMem(memory).cal()->format_ == CM_SURF_FMT_RGBA8_SRGB) {
// Converting a linear RGB floating-point color value to a 8-bit unsigned integer sRGB value because hw is not support write_imagef for sRGB.
float *fColor = static_cast<float *>(newpattern);
iFillColor.s[0] = sRGBmap(fColor[0]);
iFillColor.s[1] = sRGBmap(fColor[1]);
iFillColor.s[2] = sRGBmap(fColor[2]);
iFillColor.s[3] = (cl_uint)(fColor[3]*255.0f);
newpattern = static_cast<void*>(&iFillColor);
for (uint i = 0; i < RejectedFormatChannelTotal; ++i) {
if (RejectedOrder[i].clOldType_ == newFormat.image_channel_order) {
newFormat.image_channel_order = RejectedOrder[i].clNewType_;
@@ -2657,9 +2667,9 @@ KernelBlitManager::fillImage(
// Program kernels arguments for the blit operation
Memory* mem = memView;
setArgument(kernels_[fillType], 0, sizeof(cl_mem), &mem);
setArgument(kernels_[fillType], 1, sizeof(cl_float4), pattern);
setArgument(kernels_[fillType], 2, sizeof(cl_int4), pattern);
setArgument(kernels_[fillType], 3, sizeof(cl_uint4), pattern);
setArgument(kernels_[fillType], 1, sizeof(cl_float4), newpattern);
setArgument(kernels_[fillType], 2, sizeof(cl_int4), newpattern);
setArgument(kernels_[fillType], 3, sizeof(cl_uint4), newpattern);
cl_int fillOrigin[4] = { (cl_int)origin[0],
(cl_int)origin[1],