[vlc-commits] d3d11: make sure for colorspace primary conversion

Steve Lhomme git at videolan.org
Wed Oct 17 16:07:47 CEST 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 12 14:52:06 2018 +0200| [c10b969de27878799e986f57bc392deeda141cde] | committer: Steve Lhomme

d3d11: make sure for colorspace primary conversion

(cherry picked from commit 1dcc1f448e429689976c90a63aaed442d1c16772)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=c10b969de27878799e986f57bc392deeda141cde
---

 modules/video_output/win32/d3d11_shaders.c | 12 ++++++++++--
 modules/video_output/win32/d3d11_shaders.h |  2 ++
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c
index 35405811e3..ccb52352c9 100644
--- a/modules/video_output/win32/d3d11_shaders.c
+++ b/modules/video_output/win32/d3d11_shaders.c
@@ -63,6 +63,7 @@ static const char* globPixelShaderDefault = "\
   {\n\
     float4x4 WhitePoint;\n\
     float4x4 Colorspace;\n\
+    float3x3 Primaries;\n\
   };\n\
   Texture2D%s shaderTexture[" STRINGIZE(D3D11_MAX_SHADER_VIEW) "];\n\
   SamplerState SamplerStates[2];\n\
@@ -100,6 +101,10 @@ static const char* globPixelShaderDefault = "\
       %s;\n\
   }\n\
   \n\
+  inline float3 transformPrimaries(float3 rgb) {\n\
+      %s;\n\
+  }\n\
+  \n\
   inline float3 toneMapping(float3 rgb) {\n\
       %s;\n\
   }\n\
@@ -126,6 +131,7 @@ static const char* globPixelShaderDefault = "\
     float opacity = rgba.a * Opacity;\n\
     float3 rgb = (float3)rgba;\n\
     rgb = sourceToLinear(rgb);\n\
+    rgb = transformPrimaries(rgb);\n\
     rgb = toneMapping(rgb);\n\
     rgb = linearToDisplay(rgb);\n\
     rgb = adjustRange(rgb);\n\
@@ -206,6 +212,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
     const char *psz_sampler;
     const char *psz_src_transform     = DEFAULT_NOOP;
     const char *psz_display_transform = DEFAULT_NOOP;
+    const char *psz_primaries_transform = DEFAULT_NOOP;
     const char *psz_tone_mapping      = DEFAULT_NOOP;
     const char *psz_adjust_range      = DEFAULT_NOOP;
     char *psz_range = NULL;
@@ -421,7 +428,7 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
     }
 
     char *shader = malloc(strlen(globPixelShaderDefault) + 32 + strlen(psz_sampler) +
-                          strlen(psz_src_transform) + strlen(psz_display_transform) +
+                          strlen(psz_src_transform) + strlen(psz_primaries_transform) + strlen(psz_display_transform) +
                           strlen(psz_tone_mapping) + strlen(psz_adjust_range));
     if (!shader)
     {
@@ -430,10 +437,11 @@ HRESULT D3D11_CompilePixelShader(vlc_object_t *o, d3d11_handle_t *hd3d, bool leg
         return E_OUTOFMEMORY;
     }
     sprintf(shader, globPixelShaderDefault, legacy_shader ? "" : "Array", psz_src_transform,
-            psz_display_transform, psz_tone_mapping, psz_adjust_range, psz_sampler);
+            psz_display_transform, psz_primaries_transform, psz_tone_mapping, psz_adjust_range, psz_sampler);
 #ifndef NDEBUG
     if (!IsRGBShader(format)) {
         msg_Dbg(o,"psz_src_transform %s", psz_src_transform);
+        msg_Dbg(o,"psz_primaries_transform %s", psz_primaries_transform);
         msg_Dbg(o,"psz_tone_mapping %s", psz_tone_mapping);
         msg_Dbg(o,"psz_display_transform %s", psz_display_transform);
         msg_Dbg(o,"psz_adjust_range %s", psz_adjust_range);
diff --git a/modules/video_output/win32/d3d11_shaders.h b/modules/video_output/win32/d3d11_shaders.h
index 8049ec945c..d22a516b93 100644
--- a/modules/video_output/win32/d3d11_shaders.h
+++ b/modules/video_output/win32/d3d11_shaders.h
@@ -61,6 +61,8 @@ typedef struct {
 typedef struct {
     FLOAT WhitePoint[4*4];
     FLOAT Colorspace[4*4];
+    FLOAT Primaries[3*3];
+    FLOAT padding[16 - 3*3];
 } PS_COLOR_TRANSFORM;
 
 typedef struct {



More information about the vlc-commits mailing list