svga: add function svga_linear_to_srgb()
authorNeha Bhende <bhenden@vmware.com>
Thu, 27 Apr 2017 17:37:02 +0000 (10:37 -0700)
committerBrian Paul <brianp@vmware.com>
Sat, 29 Apr 2017 03:03:06 +0000 (21:03 -0600)
This function will return compatible svga srgb format for corresponding
linear format

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/drivers/svga/svga_format.c
src/gallium/drivers/svga/svga_format.h

index d8ccfbd947a8d1aebf1084e0feb1e32355ff829a..3a2f7df24277930e2bbbae81109f12c51270839b 100644 (file)
@@ -2337,3 +2337,29 @@ svga_format_is_shareable(const struct svga_screen *ss,
 
    return false;
 }
+
+
+/**
+  * Return the sRGB format which corresponds to the given (linear) format.
+  * If there's no such sRGB format, return the format as-is.
+  */
+SVGA3dSurfaceFormat
+svga_linear_to_srgb(SVGA3dSurfaceFormat format)
+{
+   switch (format) {
+   case SVGA3D_R8G8B8A8_UNORM:
+      return SVGA3D_R8G8B8A8_UNORM_SRGB;
+   case SVGA3D_BC1_UNORM:
+      return SVGA3D_BC1_UNORM_SRGB;
+   case SVGA3D_BC2_UNORM:
+      return SVGA3D_BC2_UNORM_SRGB;
+   case SVGA3D_BC3_UNORM:
+      return SVGA3D_BC3_UNORM_SRGB;
+   case SVGA3D_B8G8R8A8_UNORM:
+      return SVGA3D_B8G8R8A8_UNORM_SRGB;
+   case SVGA3D_B8G8R8X8_UNORM:
+      return SVGA3D_B8G8R8X8_UNORM_SRGB;
+   default:
+      return format;
+   }
+}
index 63be8f1ad79a0c0aa3bdb5b6fcc78cecef306b36..55d89ed2b484fd095d349c77ca177aebbbb40dc4 100644 (file)
@@ -117,4 +117,7 @@ svga_format_is_shareable(const struct svga_screen *ss,
                          SVGA3dSurfaceFormat sformat,
                          unsigned bind,
                          bool verbose);
+
+SVGA3dSurfaceFormat
+svga_linear_to_srgb(SVGA3dSurfaceFormat format);
 #endif /* SVGA_FORMAT_H_ */