mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 23:35:55 +00:00
Refactor D3D11 shaders to reduce duplicated code
This commit is contained in:
parent
b1f980c216
commit
36db791516
@ -61,7 +61,7 @@
|
|||||||
<file alias="egl_overlay.vert">shaders/egl_overlay.vert</file>
|
<file alias="egl_overlay.vert">shaders/egl_overlay.vert</file>
|
||||||
<file alias="d3d11_vertex.fxc">shaders/d3d11_vertex.fxc</file>
|
<file alias="d3d11_vertex.fxc">shaders/d3d11_vertex.fxc</file>
|
||||||
<file alias="d3d11_overlay_pixel.fxc">shaders/d3d11_overlay_pixel.fxc</file>
|
<file alias="d3d11_overlay_pixel.fxc">shaders/d3d11_overlay_pixel.fxc</file>
|
||||||
<file alias="d3d11_video_pixel.fxc">shaders/d3d11_video_pixel.fxc</file>
|
<file alias="d3d11_genyuv_pixel.fxc">shaders/d3d11_genyuv_pixel.fxc</file>
|
||||||
<file alias="d3d11_bt601lim_pixel.fxc">shaders/d3d11_bt601lim_pixel.fxc</file>
|
<file alias="d3d11_bt601lim_pixel.fxc">shaders/d3d11_bt601lim_pixel.fxc</file>
|
||||||
<file alias="d3d11_bt2020lim_pixel.fxc">shaders/d3d11_bt2020lim_pixel.fxc</file>
|
<file alias="d3d11_bt2020lim_pixel.fxc">shaders/d3d11_bt2020lim_pixel.fxc</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
fxc /T vs_4_0_level_9_3 /Fo d3d11_vertex.fxc d3d11_vertex.hlsl
|
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_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_bt601lim_pixel.fxc d3d11_bt601lim_pixel.hlsl
|
||||||
fxc /T ps_4_0_level_9_3 /Fo d3d11_bt2020lim_pixel.fxc d3d11_bt2020lim_pixel.hlsl
|
fxc /T ps_4_0_level_9_3 /Fo d3d11_bt2020lim_pixel.fxc d3d11_bt2020lim_pixel.hlsl
|
@ -1,6 +1,4 @@
|
|||||||
Texture2D<min16float> luminancePlane : register(t0);
|
#include "d3d11_video_pixel_start.hlsli"
|
||||||
Texture2D<min16float2> chrominancePlane : register(t1);
|
|
||||||
SamplerState theSampler : register(s0);
|
|
||||||
|
|
||||||
static const min16float3x3 cscMatrix =
|
static const min16float3x3 cscMatrix =
|
||||||
{
|
{
|
||||||
@ -14,22 +12,4 @@ static const min16float3 offsets =
|
|||||||
16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0
|
16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShaderInput
|
#include "d3d11_video_pixel_end.hlsli"
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
@ -1,6 +1,4 @@
|
|||||||
Texture2D<min16float> luminancePlane : register(t0);
|
#include "d3d11_video_pixel_start.hlsli"
|
||||||
Texture2D<min16float2> chrominancePlane : register(t1);
|
|
||||||
SamplerState theSampler : register(s0);
|
|
||||||
|
|
||||||
static const min16float3x3 cscMatrix =
|
static const min16float3x3 cscMatrix =
|
||||||
{
|
{
|
||||||
@ -14,22 +12,4 @@ static const min16float3 offsets =
|
|||||||
16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0
|
16.0 / 255.0, 128.0 / 255.0, 128.0 / 255.0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ShaderInput
|
#include "d3d11_video_pixel_end.hlsli"
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
9
app/shaders/d3d11_genyuv_pixel.hlsl
Normal file
9
app/shaders/d3d11_genyuv_pixel.hlsl
Normal file
@ -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"
|
@ -1,19 +1,3 @@
|
|||||||
Texture2D<min16float> luminancePlane : register(t0);
|
|
||||||
Texture2D<min16float2> 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
|
min16float4 main(ShaderInput input) : SV_TARGET
|
||||||
{
|
{
|
||||||
min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex),
|
min16float3 yuv = min16float3(luminancePlane.Sample(theSampler, input.tex),
|
9
app/shaders/d3d11_video_pixel_start.hlsli
Normal file
9
app/shaders/d3d11_video_pixel_start.hlsli
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Texture2D<min16float> luminancePlane : register(t0);
|
||||||
|
Texture2D<min16float2> chrominancePlane : register(t1);
|
||||||
|
SamplerState theSampler : register(s0);
|
||||||
|
|
||||||
|
struct ShaderInput
|
||||||
|
{
|
||||||
|
float4 pos : SV_POSITION;
|
||||||
|
float2 tex : TEXCOORD0;
|
||||||
|
};
|
@ -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);
|
hr = m_Device->CreatePixelShader(videoPixelShaderBytecode.constData(), videoPixelShaderBytecode.length(), nullptr, &m_VideoGenericPixelShader);
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user