[vlc-devel] [PATCH 15/29] direct3d11: pass the whitepoint and colorspace matrices to the RGB pixel shader
Steve Lhomme
robux4 at videolabs.io
Thu Jan 19 11:10:50 CET 2017
Now all pixel shaders are given the same constant buffers
--
replaces https://patches.videolan.org/patch/15375/
* base the RGB detection on the quad config, not the main config
---
modules/video_output/win32/direct3d11.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 37d2d0e..b1f2c80 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -235,6 +235,14 @@ static const char* globPixelShaderDefault = "\
float Opacity;\
float opacityPadding[3];\
};\
+ cbuffer PS_COLOR_TRANSFORM : register(b1)\
+ {\
+ float WhitePointX;\
+ float WhitePointY;\
+ float WhitePointZ;\
+ float whitePadding;\
+ float4x4 Colorspace;\
+ };\
Texture2D shaderTexture;\
SamplerState SampleType;\
\
@@ -249,8 +257,11 @@ static const char* globPixelShaderDefault = "\
float4 rgba; \
\
rgba = shaderTexture.Sample(SampleType, In.Texture);\
+ rgba.x += WhitePointX;\
+ rgba.y += WhitePointY;\
+ rgba.z += WhitePointZ;\
rgba.a = rgba.a * Opacity;\
- return rgba; \
+ return saturate(mul(rgba, Colorspace));\
}\
";
@@ -1888,6 +1899,9 @@ static int AllocQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
D3D11_MAPPED_SUBRESOURCE mappedResource;
HRESULT hr;
static const FLOAT FULL_TO_STUDIO_SHIFT = 16.f / 256.f;
+ const bool RGB_shader = cfg->resourceFormatYRGB != DXGI_FORMAT_R8_UNORM &&
+ cfg->resourceFormatYRGB != DXGI_FORMAT_R16_UNORM &&
+ fmt->i_chroma != VLC_CODEC_YUYV;
/* pixel shader constant buffer */
PS_CONSTANT_BUFFER defaultConstants = {
@@ -1908,7 +1922,15 @@ static int AllocQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
}
FLOAT WHITE_POINT_D65_TO_FULL[4] = { -FULL_TO_STUDIO_SHIFT, -0.5f, -0.5f, 1.f };
+ if (RGB_shader)
+ WHITE_POINT_D65_TO_FULL[0] = WHITE_POINT_D65_TO_FULL[1] = WHITE_POINT_D65_TO_FULL[2] = 0.f;
+ FLOAT COLORSPACE_RGB_FULL[4 * 4] = {
+ 1.f, 0.f, 0.f, 0.f,
+ 0.f, 1.f, 0.f, 0.f,
+ 0.f, 0.f, 1.f, 0.f,
+ 0.f, 0.f, 0.f, 1.f,
+ };
FLOAT COLORSPACE_BT601_TO_FULL[4*4] = {
1.164383561643836f, 0.f, 1.596026785714286f, 0.f,
1.164383561643836f, -0.391762290094914f, -0.812967647237771f, 0.f,
@@ -1931,6 +1953,9 @@ static int AllocQuad(vout_display_t *vd, const video_format_t *fmt, d3d_quad_t *
PS_COLOR_TRANSFORM colorspace;
FLOAT *ppColorspace;
+ if (RGB_shader)
+ ppColorspace = COLORSPACE_RGB_FULL;
+ else
switch (fmt->space){
case COLOR_SPACE_BT709:
ppColorspace = COLORSPACE_BT709_TO_FULL;
--
2.10.2
More information about the vlc-devel
mailing list