Mesa (master): svga: add function svga_linear_to_srgb()

Brian Paul brianp at kemper.freedesktop.org
Sat Apr 29 03:07:38 UTC 2017


Module: Mesa
Branch: master
Commit: 1b415a5b2833c1642176601653021d4bbe895b35
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1b415a5b2833c1642176601653021d4bbe895b35

Author: Neha Bhende <bhenden at vmware.com>
Date:   Thu Apr 27 10:37:02 2017 -0700

svga: add function svga_linear_to_srgb()

This function will return compatible svga srgb format for corresponding
linear format

Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Charmaine Lee <charmainel at vmware.com>

---

 src/gallium/drivers/svga/svga_format.c | 26 ++++++++++++++++++++++++++
 src/gallium/drivers/svga/svga_format.h |  3 +++
 2 files changed, 29 insertions(+)

diff --git a/src/gallium/drivers/svga/svga_format.c b/src/gallium/drivers/svga/svga_format.c
index d8ccfbd947..3a2f7df242 100644
--- a/src/gallium/drivers/svga/svga_format.c
+++ b/src/gallium/drivers/svga/svga_format.c
@@ -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;
+   }
+}
diff --git a/src/gallium/drivers/svga/svga_format.h b/src/gallium/drivers/svga/svga_format.h
index 63be8f1ad7..55d89ed2b4 100644
--- a/src/gallium/drivers/svga/svga_format.h
+++ b/src/gallium/drivers/svga/svga_format.h
@@ -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_ */




More information about the mesa-commit mailing list