diff --git a/app/resources.qrc b/app/resources.qrc index a56a6fa0..0427b0dd 100644 --- a/app/resources.qrc +++ b/app/resources.qrc @@ -61,7 +61,7 @@ shaders/egl_overlay.vert shaders/d3d11_vertex.fxc shaders/d3d11_overlay_pixel.fxc - shaders/d3d11_video_pixel.fxc + shaders/d3d11_genyuv_pixel.fxc shaders/d3d11_bt601lim_pixel.fxc shaders/d3d11_bt2020lim_pixel.fxc diff --git a/app/shaders/build_hlsl.bat b/app/shaders/build_hlsl.bat index bf915204..4a8389ab 100644 --- a/app/shaders/build_hlsl.bat +++ b/app/shaders/build_hlsl.bat @@ -1,6 +1,6 @@ fxc /T vs_4_0_level_9_3 /Fo d3d11_vertex.fxc d3d11_vertex.hlsl fxc /T ps_4_0_level_9_3 /Fo d3d11_overlay_pixel.fxc d3d11_overlay_pixel.hlsl -fxc /T ps_4_0_level_9_3 /Fo d3d11_video_pixel.fxc d3d11_video_pixel.hlsl +fxc /T ps_4_0_level_9_3 /Fo d3d11_genyuv_pixel.fxc d3d11_genyuv_pixel.hlsl fxc /T ps_4_0_level_9_3 /Fo d3d11_bt601lim_pixel.fxc d3d11_bt601lim_pixel.hlsl fxc /T ps_4_0_level_9_3 /Fo d3d11_bt2020lim_pixel.fxc d3d11_bt2020lim_pixel.hlsl \ No newline at end of file diff --git a/app/shaders/d3d11_bt2020lim_pixel.hlsl b/app/shaders/d3d11_bt2020lim_pixel.hlsl index 0e335f93..e4e7bc40 100644 --- a/app/shaders/d3d11_bt2020lim_pixel.hlsl +++ b/app/shaders/d3d11_bt2020lim_pixel.hlsl @@ -1,6 +1,4 @@ -Texture2D luminancePlane : register(t0); -Texture2D chrominancePlane : register(t1); -SamplerState theSampler : register(s0); +#include "d3d11_video_pixel_start.hlsli" static const min16float3x3 cscMatrix = { @@ -14,22 +12,4 @@ static const min16float3 offsets = 16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0 }; -struct ShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; -}; - -min16float4 main(ShaderInput input) : SV_TARGET -{ - min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex), - chrominancePlane.Sample(theSampler, input.tex)); - - // Subtract the YUV offset for limited vs full range - yuv -= offsets; - - // Multiply by the conversion matrix for this colorspace - yuv = mul(yuv, cscMatrix); - - return min16float4(yuv, 1.0); -} \ No newline at end of file +#include "d3d11_video_pixel_end.hlsli" \ No newline at end of file diff --git a/app/shaders/d3d11_bt601lim_pixel.hlsl b/app/shaders/d3d11_bt601lim_pixel.hlsl index 9a795fd3..ef184cd7 100644 --- a/app/shaders/d3d11_bt601lim_pixel.hlsl +++ b/app/shaders/d3d11_bt601lim_pixel.hlsl @@ -1,6 +1,4 @@ -Texture2D luminancePlane : register(t0); -Texture2D chrominancePlane : register(t1); -SamplerState theSampler : register(s0); +#include "d3d11_video_pixel_start.hlsli" static const min16float3x3 cscMatrix = { @@ -14,22 +12,4 @@ static const min16float3 offsets = 16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0 }; -struct ShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; -}; - -min16float4 main(ShaderInput input) : SV_TARGET -{ - min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex), - chrominancePlane.Sample(theSampler, input.tex)); - - // Subtract the YUV offset for limited vs full range - yuv -= offsets; - - // Multiply by the conversion matrix for this colorspace - yuv = mul(yuv, cscMatrix); - - return min16float4(yuv, 1.0); -} \ No newline at end of file +#include "d3d11_video_pixel_end.hlsli" \ No newline at end of file diff --git a/app/shaders/d3d11_video_pixel.fxc b/app/shaders/d3d11_genyuv_pixel.fxc similarity index 100% rename from app/shaders/d3d11_video_pixel.fxc rename to app/shaders/d3d11_genyuv_pixel.fxc diff --git a/app/shaders/d3d11_genyuv_pixel.hlsl b/app/shaders/d3d11_genyuv_pixel.hlsl new file mode 100644 index 00000000..b2f8a150 --- /dev/null +++ b/app/shaders/d3d11_genyuv_pixel.hlsl @@ -0,0 +1,9 @@ +#include "d3d11_video_pixel_start.hlsli" + +cbuffer CSC_CONST_BUF : register(b0) +{ + min16float3x3 cscMatrix; + min16float3 offsets; +}; + +#include "d3d11_video_pixel_end.hlsli" \ No newline at end of file diff --git a/app/shaders/d3d11_video_pixel.hlsl b/app/shaders/d3d11_video_pixel_end.hlsli similarity index 56% rename from app/shaders/d3d11_video_pixel.hlsl rename to app/shaders/d3d11_video_pixel_end.hlsli index f1df0702..db62c66a 100644 --- a/app/shaders/d3d11_video_pixel.hlsl +++ b/app/shaders/d3d11_video_pixel_end.hlsli @@ -1,19 +1,3 @@ -Texture2D luminancePlane : register(t0); -Texture2D chrominancePlane : register(t1); -SamplerState theSampler : register(s0); - -cbuffer CSC_CONST_BUF : register(b0) -{ - min16float3x3 cscMatrix; - min16float3 offsets; -}; - -struct ShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; -}; - min16float4 main(ShaderInput input) : SV_TARGET { min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex), diff --git a/app/shaders/d3d11_video_pixel_start.hlsli b/app/shaders/d3d11_video_pixel_start.hlsli new file mode 100644 index 00000000..863d9d43 --- /dev/null +++ b/app/shaders/d3d11_video_pixel_start.hlsli @@ -0,0 +1,9 @@ +Texture2D luminancePlane : register(t0); +Texture2D chrominancePlane : register(t1); +SamplerState theSampler : register(s0); + +struct ShaderInput +{ + float4 pos : SV_POSITION; + float2 tex : TEXCOORD0; +}; \ No newline at end of file diff --git a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp index 3b546e71..8aed102e 100644 --- a/app/streaming/video/ffmpeg-renderers/d3d11va.cpp +++ b/app/streaming/video/ffmpeg-renderers/d3d11va.cpp @@ -1158,7 +1158,7 @@ bool D3D11VARenderer::setupRenderingResources() } { - QByteArray videoPixelShaderBytecode = Path::readDataFile("d3d11_video_pixel.fxc"); + QByteArray videoPixelShaderBytecode = Path::readDataFile("d3d11_genyuv_pixel.fxc"); hr = m_Device->CreatePixelShader(videoPixelShaderBytecode.constData(), videoPixelShaderBytecode.length(), nullptr, &m_VideoGenericPixelShader); if (FAILED(hr)) {