vlc | branch: master | Steve Lhomme <[email protected]> | Wed Feb 17 16:51:25 2021 +0100| [e11f0233510d954a397bf3ba6bad4961053850a1] | committer: Steve Lhomme
d3d_dynamic_shader: premultiply the Colorspace and Primaries matrices No need to multiply it for each pixel > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e11f0233510d954a397bf3ba6bad4961053850a1 --- modules/video_output/win32/d3d11_shaders.c | 6 ++-- modules/video_output/win32/d3d11_shaders.h | 8 ++--- modules/video_output/win32/d3d_dynamic_shader.c | 39 ++----------------------- modules/video_output/win32/d3d_dynamic_shader.h | 2 +- modules/video_output/win32/d3d_shaders.c | 5 ++-- modules/video_output/win32/d3d_shaders.h | 3 +- modules/video_output/win32/direct3d11.c | 4 +-- 7 files changed, 16 insertions(+), 51 deletions(-) diff --git a/modules/video_output/win32/d3d11_shaders.c b/modules/video_output/win32/d3d11_shaders.c index be41c60923..3c5ab832c8 100644 --- a/modules/video_output/win32/d3d11_shaders.c +++ b/modules/video_output/win32/d3d11_shaders.c @@ -43,11 +43,11 @@ HRESULT (D3D11_CompilePixelShaderBlob)(vlc_object_t *o, const d3d_shader_compile d3d11_device_t *d3d_dev, const display_info_t *display, video_transfer_func_t transfer, - video_color_primaries_t primaries, bool src_full_range, - d3d11_quad_t *quad, d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET]) + bool src_full_range, + const d3d11_quad_t *quad, d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET]) { return D3D_CompilePixelShader(o, compiler, d3d_dev->feature_level, - display, transfer, primaries, + display, transfer, src_full_range, quad->generic.textureFormat, pPSBlob); } diff --git a/modules/video_output/win32/d3d11_shaders.h b/modules/video_output/win32/d3d11_shaders.h index 57984a7215..d3605e4c60 100644 --- a/modules/video_output/win32/d3d11_shaders.h +++ b/modules/video_output/win32/d3d11_shaders.h @@ -55,11 +55,11 @@ typedef struct HRESULT D3D11_CompilePixelShaderBlob(vlc_object_t *, const d3d_shader_compiler_t *, d3d11_device_t *, const display_info_t *, - video_transfer_func_t, video_color_primaries_t, + video_transfer_func_t, bool src_full_range, - d3d11_quad_t *, d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET]); -#define D3D11_CompilePixelShaderBlob(a,b,c,d,e,f,g,h,i) \ - D3D11_CompilePixelShaderBlob(VLC_OBJECT(a),b,c,d,e,f,g,h,i) + const d3d11_quad_t *, d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET]); +#define D3D11_CompilePixelShaderBlob(a,b,c,d,e,f,g,h) \ + D3D11_CompilePixelShaderBlob(VLC_OBJECT(a),b,c,d,e,f,g,h) HRESULT D3D11_SetQuadPixelShader(vlc_object_t *, d3d11_device_t *, bool sharp, d3d11_quad_t *quad, d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET]); diff --git a/modules/video_output/win32/d3d_dynamic_shader.c b/modules/video_output/win32/d3d_dynamic_shader.c index 5cde7130c1..dd991fd83c 100644 --- a/modules/video_output/win32/d3d_dynamic_shader.c +++ b/modules/video_output/win32/d3d_dynamic_shader.c @@ -39,7 +39,6 @@ static const char globPixelShaderDefault[] = "\ cbuffer PS_CONSTANT_BUFFER : register(b0)\n\ {\n\ float4x3 Colorspace;\n\ - float4x3 Primaries;\n\ float Opacity;\n\ float LuminanceScale;\n\ float2 Boundary;\n\ @@ -65,8 +64,6 @@ struct PS_INPUT\n\ #define DST_TRANSFER_SRGB 1\n\ #define DST_TRANSFER_PQ 2\n\ \n\ -#define TRANSFORM_PRIMARIES 1\n\ -\n\ #define FULL_RANGE 1\n\ #define STUDIO_RANGE 2\n\ \n\ @@ -157,14 +154,6 @@ inline float3 linearToDisplay(float3 rgb) {\n\ #endif\n\ }\n\ \n\ -inline float3 transformPrimaries(float4 rgb) {\n\ -#if (PRIMARIES_MODE==TRANSFORM_PRIMARIES)\n\ - return max(mul(rgb, Primaries), 0);\n\ -#else\n\ - return rgb.rgb;\n\ -#endif\n\ -}\n\ -\n\ inline float3 toneMapping(float3 rgb) {\n\ rgb = rgb * LuminanceScale;\n\ #if (TONE_MAPPING==TONE_MAP_HABLE)\n\ @@ -266,8 +255,7 @@ float4 main( PS_INPUT In ) : SV_TARGET\n\ sample = sampleTexture( borderSampler, In.uv );\n\ else\n\ sample = sampleTexture( normalSampler, In.uv );\n\ - float3 rgb1 = max(mul(sample, Colorspace),0);\n\ - float3 rgb = transformPrimaries(float4(rgb1, 0));\n\ + float3 rgb = max(mul(sample, Colorspace),0);\n\ rgb = sourceToLinear(rgb);\n\ rgb = toneMapping(rgb);\n\ rgb = linearToDisplay(rgb);\n\ @@ -389,7 +377,6 @@ static HRESULT CompilePixelShaderBlob(vlc_object_t *o, const d3d_shader_compiler D3D_FEATURE_LEVEL feature_level, const char *psz_sampler, const char *psz_src_to_linear, - const char *psz_primaries_transform, const char *psz_linear_to_display, const char *psz_tone_mapping, const char *psz_src_range, const char *psz_dst_range, @@ -406,7 +393,6 @@ static HRESULT CompilePixelShaderBlob(vlc_object_t *o, const d3d_shader_compiler { "TONE_MAPPING", psz_tone_mapping }, { "SRC_TO_LINEAR", psz_src_to_linear }, { "LINEAR_TO_DST", psz_linear_to_display }, - { "PRIMARIES_MODE", psz_primaries_transform }, { "SAMPLE_TEXTURES", psz_sampler }, { "SRC_RANGE", psz_src_range }, { "DST_RANGE", psz_dst_range }, @@ -433,7 +419,7 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c D3D_FEATURE_LEVEL feature_level, const display_info_t *display, video_transfer_func_t transfer, - video_color_primaries_t primaries, bool src_full_range, + bool src_full_range, const d3d_format_t *dxgi_fmt, d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET]) { @@ -441,7 +427,6 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c const char *psz_sampler[DXGI_MAX_RENDER_TARGET] = {NULL, NULL}; const char *psz_src_to_linear = DEFAULT_NOOP; const char *psz_linear_to_display = DEFAULT_NOOP; - const char *psz_primaries_transform = DEFAULT_NOOP; const char *psz_tone_mapping = DEFAULT_NOOP; const char *psz_src_range, *psz_dst_range; @@ -602,24 +587,6 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c } } - if (display->primaries != primaries) - { - switch (primaries) - { - case COLOR_PRIMARIES_BT601_525: - case COLOR_PRIMARIES_BT601_625: - case COLOR_PRIMARIES_BT709: - case COLOR_PRIMARIES_BT2020: - case COLOR_PRIMARIES_DCI_P3: - case COLOR_PRIMARIES_FCC1953: - psz_primaries_transform = "TRANSFORM_PRIMARIES"; - break; - default: - /* see STANDARD_PRIMARIES */ - msg_Warn(o, "unhandled color primaries %d", primaries); - } - } - bool dst_full_range = display->b_full_range; if (!DxgiIsRGBFormat(dxgi_fmt) && DxgiIsRGBFormat(display->pixelFormat)) { @@ -705,7 +672,6 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c hr = CompilePixelShaderBlob(o, compiler, feature_level, psz_sampler[0], psz_src_to_linear, - psz_primaries_transform, psz_linear_to_display, psz_tone_mapping, psz_src_range, psz_dst_range, @@ -716,7 +682,6 @@ HRESULT (D3D_CompilePixelShader)(vlc_object_t *o, const d3d_shader_compiler_t *c hr = CompilePixelShaderBlob(o, compiler, feature_level, psz_sampler[1], psz_src_to_linear, - psz_primaries_transform, psz_linear_to_display, psz_tone_mapping, psz_src_range, psz_dst_range, diff --git a/modules/video_output/win32/d3d_dynamic_shader.h b/modules/video_output/win32/d3d_dynamic_shader.h index 57606b4d42..2863371d47 100644 --- a/modules/video_output/win32/d3d_dynamic_shader.h +++ b/modules/video_output/win32/d3d_dynamic_shader.h @@ -36,7 +36,7 @@ HRESULT D3D_CompilePixelShader(vlc_object_t *, const d3d_shader_compiler_t *, D3D_FEATURE_LEVEL, const display_info_t *, video_transfer_func_t, - video_color_primaries_t, bool src_full_range, + bool src_full_range, const d3d_format_t *dxgi_fmt, d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET]); diff --git a/modules/video_output/win32/d3d_shaders.c b/modules/video_output/win32/d3d_shaders.c index cb64d3305e..ca2c349e81 100644 --- a/modules/video_output/win32/d3d_shaders.c +++ b/modules/video_output/win32/d3d_shaders.c @@ -450,8 +450,9 @@ void D3D_SetupQuad(vlc_object_t *o, const video_format_t *fmt, d3d_quad_t *quad, if (fmt->primaries != displayFormat->primaries) { - GetPrimariesTransform(quad->shaderConstants->Primaries, fmt->primaries, - displayFormat->primaries); + FLOAT Primaries[4*3]; + GetPrimariesTransform(Primaries, fmt->primaries, displayFormat->primaries); + MultMat43(quad->shaderConstants->Colorspace, Primaries, quad->shaderConstants->Colorspace); } } diff --git a/modules/video_output/win32/d3d_shaders.h b/modules/video_output/win32/d3d_shaders.h index 2077642742..d99ef4ca2f 100644 --- a/modules/video_output/win32/d3d_shaders.h +++ b/modules/video_output/win32/d3d_shaders.h @@ -46,12 +46,11 @@ typedef struct { /* structures passed to the pixel shader */ typedef struct { FLOAT Colorspace[4*3]; - FLOAT Primaries[4*3]; FLOAT Opacity; FLOAT LuminanceScale; FLOAT BoundaryX; FLOAT BoundaryY; - FLOAT padding[36]; // 256 bytes alignment + FLOAT padding[48]; // 256 bytes alignment } PS_CONSTANT_BUFFER; typedef struct { diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c index f7dbf765f7..3fc2fd1c9d 100644 --- a/modules/video_output/win32/direct3d11.c +++ b/modules/video_output/win32/direct3d11.c @@ -1037,7 +1037,7 @@ static int Direct3D11CreateFormatResources(vout_display_t *vd, const video_forma d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET] = { 0 }; hr = D3D11_CompilePixelShaderBlob(vd, &sys->shaders, sys->d3d_dev, - &sys->display, fmt->transfer, fmt->primaries, + &sys->display, fmt->transfer, fmt->color_range == COLOR_RANGE_FULL, &sys->picQuad, pPSBlob); if (FAILED(hr)) @@ -1186,7 +1186,7 @@ static int Direct3D11CreateGenericResources(vout_display_t *vd) { d3d_shader_blob pPSBlob[DXGI_MAX_RENDER_TARGET] = { 0 }; hr = D3D11_CompilePixelShaderBlob(vd, &sys->shaders, sys->d3d_dev, - &sys->display, TRANSFER_FUNC_SRGB, COLOR_PRIMARIES_SRGB, true, + &sys->display, TRANSFER_FUNC_SRGB, true, &sys->regionQuad, pPSBlob); if (FAILED(hr)) { _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
