SRGB implementation

The SRGB conversion code was already available, but wasn't used
specifically for the SRGB type framebuffers. Also, the SRGB
conversion should always be applied after blending.

According to the GLES 3.0 spec, section 4.1.8 - sRGB Conversion:
"the R, G, and B values after blending are converted
 into the non-linear sRGB color space by computing."

All related dEQP tests pass.

Change-Id: I9342d2f74aa650f28835a951bdfa8bd371bc6924
Reviewed-on: https://swiftshader-review.googlesource.com/5189
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Shader/SamplerCore.cpp b/src/Shader/SamplerCore.cpp
index 1dc78bf..956f526 100644
--- a/src/Shader/SamplerCore.cpp
+++ b/src/Shader/SamplerCore.cpp
@@ -222,6 +222,8 @@
 				case FORMAT_X8B8G8R8:
 				case FORMAT_A8R8G8B8:
 				case FORMAT_A8B8G8R8:
+				case FORMAT_SRGB8_X8:
+				case FORMAT_SRGB8_A8:
 				case FORMAT_V8U8:
 				case FORMAT_Q8W8V8U8:
 				case FORMAT_X8L8V8U8:
@@ -480,6 +482,8 @@
 				case FORMAT_X8B8G8R8:
 				case FORMAT_A8R8G8B8:
 				case FORMAT_A8B8G8R8:
+				case FORMAT_SRGB8_X8:
+				case FORMAT_SRGB8_A8:
 				case FORMAT_V8U8:
 				case FORMAT_Q8W8V8U8:
 				case FORMAT_X8L8V8U8:
@@ -1738,6 +1742,7 @@
 					case FORMAT_A8B8G8R8UI:
 					case FORMAT_A8B8G8R8I_SNORM:
 					case FORMAT_Q8W8V8U8:
+					case FORMAT_SRGB8_A8:
 						c.z = c.x;
 						c.x = As<Short4>(UnpackLow(c.x, c.y));
 						c.z = As<Short4>(UnpackHigh(c.z, c.y));
@@ -1778,6 +1783,7 @@
 					case FORMAT_X8B8G8R8I:
 					case FORMAT_X8B8G8R8:
 					case FORMAT_X8L8V8U8:
+					case FORMAT_SRGB8_X8:
 						c.z = c.x;
 						c.x = As<Short4>(UnpackLow(c.x, c.y));
 						c.z = As<Short4>(UnpackHigh(c.z, c.y));
@@ -2213,6 +2219,8 @@
 		case FORMAT_X8B8G8R8:
 		case FORMAT_A8R8G8B8:
 		case FORMAT_A8B8G8R8:
+		case FORMAT_SRGB8_X8:
+		case FORMAT_SRGB8_A8:
 		case FORMAT_V8U8:
 		case FORMAT_Q8W8V8U8:
 		case FORMAT_X8L8V8U8:
@@ -2262,6 +2270,8 @@
 		case FORMAT_X8B8G8R8:
 		case FORMAT_A8R8G8B8:
 		case FORMAT_A8B8G8R8:
+		case FORMAT_SRGB8_X8:
+		case FORMAT_SRGB8_A8:
 		case FORMAT_V8U8:
 		case FORMAT_Q8W8V8U8:
 		case FORMAT_X8L8V8U8:
@@ -2354,6 +2364,8 @@
 		case FORMAT_X8B8G8R8:
 		case FORMAT_A8R8G8B8:
 		case FORMAT_A8B8G8R8:
+		case FORMAT_SRGB8_X8:
+		case FORMAT_SRGB8_A8:
 		case FORMAT_V8U8:
 		case FORMAT_Q8W8V8U8:
 		case FORMAT_X8L8V8U8:
@@ -2429,6 +2441,8 @@
 		case FORMAT_X8B8G8R8:
 		case FORMAT_A8R8G8B8:
 		case FORMAT_A8B8G8R8:
+		case FORMAT_SRGB8_X8:
+		case FORMAT_SRGB8_A8:
 		case FORMAT_V8U8:
 		case FORMAT_Q8W8V8U8:
 		case FORMAT_X8L8V8U8:
@@ -2496,6 +2510,8 @@
 		case FORMAT_X8B8G8R8:       return component < 3;
 		case FORMAT_A8R8G8B8:       return component < 3;
 		case FORMAT_A8B8G8R8:       return component < 3;
+		case FORMAT_SRGB8_X8:       return component < 3;
+		case FORMAT_SRGB8_A8:       return component < 3;
 		case FORMAT_V8U8:           return false;
 		case FORMAT_Q8W8V8U8:       return false;
 		case FORMAT_X8L8V8U8:       return false;