整理目录
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
#include "include/convert_base.hlsl"
|
||||
|
||||
#define LEFT_SUBSAMPLING
|
||||
|
||||
#include "include/convert_yuv420_packed_uv_ps_base.hlsl"
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "include/convert_linear_base.hlsl"
|
||||
|
||||
#define LEFT_SUBSAMPLING
|
||||
|
||||
#include "include/convert_yuv420_packed_uv_ps_base.hlsl"
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "include/convert_perceptual_quantizer_base.hlsl"
|
||||
|
||||
#define LEFT_SUBSAMPLING
|
||||
|
||||
#include "include/convert_yuv420_packed_uv_ps_base.hlsl"
|
||||
@@ -0,0 +1,15 @@
|
||||
cbuffer subsample_offset_cbuffer : register(b0) {
|
||||
float2 subsample_offset;
|
||||
};
|
||||
|
||||
cbuffer rotate_texture_steps_cbuffer : register(b1) {
|
||||
int rotate_texture_steps;
|
||||
};
|
||||
|
||||
#define LEFT_SUBSAMPLING
|
||||
#include "include/base_vs.hlsl"
|
||||
|
||||
vertex_t main_vs(uint vertex_id : SV_VertexID)
|
||||
{
|
||||
return generate_fullscreen_triangle_vertex(vertex_id, subsample_offset, rotate_texture_steps);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "include/convert_base.hlsl"
|
||||
|
||||
#define LEFT_SUBSAMPLING_SCALE
|
||||
|
||||
#include "include/convert_yuv420_packed_uv_ps_base.hlsl"
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "include/convert_linear_base.hlsl"
|
||||
|
||||
#define LEFT_SUBSAMPLING_SCALE
|
||||
|
||||
#include "include/convert_yuv420_packed_uv_ps_base.hlsl"
|
||||
@@ -0,0 +1,5 @@
|
||||
#include "include/convert_perceptual_quantizer_base.hlsl"
|
||||
|
||||
#define LEFT_SUBSAMPLING_SCALE
|
||||
|
||||
#include "include/convert_yuv420_packed_uv_ps_base.hlsl"
|
||||
@@ -0,0 +1,15 @@
|
||||
cbuffer subsample_offset_cbuffer : register(b0) {
|
||||
float2 subsample_offset;
|
||||
};
|
||||
|
||||
cbuffer rotate_texture_steps_cbuffer : register(b1) {
|
||||
int rotate_texture_steps;
|
||||
};
|
||||
|
||||
#define LEFT_SUBSAMPLING_SCALE
|
||||
#include "include/base_vs.hlsl"
|
||||
|
||||
vertex_t main_vs(uint vertex_id : SV_VertexID)
|
||||
{
|
||||
return generate_fullscreen_triangle_vertex(vertex_id, subsample_offset, rotate_texture_steps);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "include/convert_base.hlsl"
|
||||
|
||||
#include "include/convert_yuv420_planar_y_ps_base.hlsl"
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "include/convert_linear_base.hlsl"
|
||||
|
||||
#include "include/convert_yuv420_planar_y_ps_base.hlsl"
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "include/convert_perceptual_quantizer_base.hlsl"
|
||||
|
||||
#include "include/convert_yuv420_planar_y_ps_base.hlsl"
|
||||
@@ -0,0 +1,10 @@
|
||||
cbuffer rotate_texture_steps_cbuffer : register(b1) {
|
||||
int rotate_texture_steps;
|
||||
};
|
||||
|
||||
#include "include/base_vs.hlsl"
|
||||
|
||||
vertex_t main_vs(uint vertex_id : SV_VertexID)
|
||||
{
|
||||
return generate_fullscreen_triangle_vertex(vertex_id, float2(0, 0), rotate_texture_steps);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "include/convert_base.hlsl"
|
||||
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "include/convert_linear_base.hlsl"
|
||||
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,10 @@
|
||||
cbuffer rotate_texture_steps_cbuffer : register(b1) {
|
||||
int rotate_texture_steps;
|
||||
};
|
||||
|
||||
#include "include/base_vs.hlsl"
|
||||
|
||||
vertex_t main_vs(uint vertex_id : SV_VertexID)
|
||||
{
|
||||
return generate_fullscreen_triangle_vertex(vertex_id, float2(0, 0), rotate_texture_steps);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "include/convert_base.hlsl"
|
||||
|
||||
#define Y410
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "include/convert_linear_base.hlsl"
|
||||
|
||||
#define Y410
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "include/convert_perceptual_quantizer_base.hlsl"
|
||||
|
||||
#define Y410
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "include/convert_base.hlsl"
|
||||
|
||||
#define PLANAR_VIEWPORTS
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "include/convert_linear_base.hlsl"
|
||||
|
||||
#define PLANAR_VIEWPORTS
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,4 @@
|
||||
#include "include/convert_perceptual_quantizer_base.hlsl"
|
||||
|
||||
#define PLANAR_VIEWPORTS
|
||||
#include "include/convert_yuv444_ps_base.hlsl"
|
||||
@@ -0,0 +1,33 @@
|
||||
cbuffer rotate_texture_steps_cbuffer : register(b1) {
|
||||
int rotate_texture_steps;
|
||||
};
|
||||
|
||||
cbuffer color_matrix_cbuffer : register(b3) {
|
||||
float4 color_vec_y;
|
||||
float4 color_vec_u;
|
||||
float4 color_vec_v;
|
||||
float2 range_y;
|
||||
float2 range_uv;
|
||||
};
|
||||
|
||||
#define PLANAR_VIEWPORTS
|
||||
#include "include/base_vs.hlsl"
|
||||
|
||||
vertex_t main_vs(uint vertex_id : SV_VertexID)
|
||||
{
|
||||
vertex_t output = generate_fullscreen_triangle_vertex(vertex_id % 3, float2(0, 0), rotate_texture_steps);
|
||||
|
||||
output.viewport = vertex_id / 3;
|
||||
|
||||
if (output.viewport == 0) {
|
||||
output.color_vec = color_vec_y;
|
||||
}
|
||||
else if (output.viewport == 1) {
|
||||
output.color_vec = color_vec_u;
|
||||
}
|
||||
else {
|
||||
output.color_vec = color_vec_v;
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
9
win-x64/phserver/assets/shaders/directx/cursor_ps.hlsl
Normal file
9
win-x64/phserver/assets/shaders/directx/cursor_ps.hlsl
Normal file
@@ -0,0 +1,9 @@
|
||||
Texture2D cursor : register(t0);
|
||||
SamplerState def_sampler : register(s0);
|
||||
|
||||
#include "include/base_vs_types.hlsl"
|
||||
|
||||
float4 main_ps(vertex_t input) : SV_Target
|
||||
{
|
||||
return cursor.Sample(def_sampler, input.tex_coord, 0);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
Texture2D cursor : register(t0);
|
||||
SamplerState def_sampler : register(s0);
|
||||
|
||||
cbuffer normalize_white_cbuffer : register(b1) {
|
||||
float white_multiplier;
|
||||
};
|
||||
|
||||
#include "include/base_vs_types.hlsl"
|
||||
|
||||
float4 main_ps(vertex_t input) : SV_Target
|
||||
{
|
||||
float4 output = cursor.Sample(def_sampler, input.tex_coord, 0);
|
||||
|
||||
output.rgb = output.rgb * white_multiplier;
|
||||
|
||||
return output;
|
||||
}
|
||||
10
win-x64/phserver/assets/shaders/directx/cursor_vs.hlsl
Normal file
10
win-x64/phserver/assets/shaders/directx/cursor_vs.hlsl
Normal file
@@ -0,0 +1,10 @@
|
||||
cbuffer rotate_texture_steps_cbuffer : register(b2) {
|
||||
int rotate_texture_steps;
|
||||
};
|
||||
|
||||
#include "include/base_vs.hlsl"
|
||||
|
||||
vertex_t main_vs(uint vertex_id : SV_VertexID)
|
||||
{
|
||||
return generate_fullscreen_triangle_vertex(vertex_id, float2(0, 0), rotate_texture_steps);
|
||||
}
|
||||
53
win-x64/phserver/assets/shaders/directx/include/base_vs.hlsl
Normal file
53
win-x64/phserver/assets/shaders/directx/include/base_vs.hlsl
Normal file
@@ -0,0 +1,53 @@
|
||||
#include "include/base_vs_types.hlsl"
|
||||
|
||||
vertex_t generate_fullscreen_triangle_vertex(uint vertex_id, float2 subsample_offset, int rotate_texture_steps)
|
||||
{
|
||||
vertex_t output;
|
||||
float2 tex_coord;
|
||||
|
||||
if (vertex_id == 0) {
|
||||
output.viewpoint_pos = float4(-1, -1, 0, 1);
|
||||
tex_coord = float2(0, 1);
|
||||
}
|
||||
else if (vertex_id == 1) {
|
||||
output.viewpoint_pos = float4(-1, 3, 0, 1);
|
||||
tex_coord = float2(0, -1);
|
||||
}
|
||||
else {
|
||||
output.viewpoint_pos = float4(3, -1, 0, 1);
|
||||
tex_coord = float2(2, 1);
|
||||
}
|
||||
|
||||
if (rotate_texture_steps != 0) {
|
||||
float rotation_radians = radians(90 * rotate_texture_steps);
|
||||
float2x2 rotation_matrix = { cos(rotation_radians), -sin(rotation_radians),
|
||||
sin(rotation_radians), cos(rotation_radians) };
|
||||
float2 rotation_center = { 0.5, 0.5 };
|
||||
tex_coord = round(rotation_center + mul(rotation_matrix, tex_coord - rotation_center));
|
||||
|
||||
// Swap the xy offset coordinates if the texture is rotated an odd number of times.
|
||||
if (rotate_texture_steps & 1) {
|
||||
subsample_offset.xy = subsample_offset.yx;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(LEFT_SUBSAMPLING)
|
||||
output.tex_right_left_center = float3(tex_coord.x, tex_coord.x - subsample_offset.x, tex_coord.y);
|
||||
#elif defined(LEFT_SUBSAMPLING_SCALE)
|
||||
float2 halfsample_offset = subsample_offset / 2;
|
||||
float3 right_center_left = float3(tex_coord.x + halfsample_offset.x,
|
||||
tex_coord.x - halfsample_offset.x,
|
||||
tex_coord.x - 3 * halfsample_offset.x);
|
||||
float2 top_bottom = float2(tex_coord.y - halfsample_offset.y,
|
||||
tex_coord.y + halfsample_offset.y);
|
||||
output.tex_right_center_left_top = float4(right_center_left, top_bottom.x);
|
||||
output.tex_right_center_left_bottom = float4(right_center_left, top_bottom.y);
|
||||
#elif defined(TOPLEFT_SUBSAMPLING)
|
||||
output.tex_right_left_top = float3(tex_coord.x, tex_coord.x - subsample_offset.x, tex_coord.y - subsample_offset.y);
|
||||
output.tex_right_left_bottom = float3(tex_coord.x, tex_coord.x - subsample_offset.x, tex_coord.y);
|
||||
#else
|
||||
output.tex_coord = tex_coord;
|
||||
#endif
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
struct vertex_t
|
||||
{
|
||||
float4 viewpoint_pos : SV_Position;
|
||||
#if defined(LEFT_SUBSAMPLING)
|
||||
float3 tex_right_left_center : TEXCOORD;
|
||||
#elif defined(LEFT_SUBSAMPLING_SCALE)
|
||||
float4 tex_right_center_left_top : TEXCOORD0;
|
||||
float4 tex_right_center_left_bottom : TEXCOORD1;
|
||||
#elif defined(TOPLEFT_SUBSAMPLING)
|
||||
float3 tex_right_left_top : TEXCOORD0;
|
||||
float3 tex_right_left_bottom : TEXCOORD1;
|
||||
#else
|
||||
float2 tex_coord : TEXCOORD;
|
||||
#endif
|
||||
#ifdef PLANAR_VIEWPORTS
|
||||
uint viewport : SV_ViewportArrayIndex;
|
||||
nointerpolation float4 color_vec : COLOR0;
|
||||
#endif
|
||||
};
|
||||
41
win-x64/phserver/assets/shaders/directx/include/common.hlsl
Normal file
41
win-x64/phserver/assets/shaders/directx/include/common.hlsl
Normal file
@@ -0,0 +1,41 @@
|
||||
// This is a fast sRGB approximation from Microsoft's ColorSpaceUtility.hlsli
|
||||
float3 ApplySRGBCurve(float3 x)
|
||||
{
|
||||
return x < 0.0031308 ? 12.92 * x : 1.13005 * sqrt(x - 0.00228) - 0.13448 * x + 0.005719;
|
||||
}
|
||||
|
||||
float3 NitsToPQ(float3 L)
|
||||
{
|
||||
// Constants from SMPTE 2084 PQ
|
||||
static const float m1 = 2610.0 / 4096.0 / 4;
|
||||
static const float m2 = 2523.0 / 4096.0 * 128;
|
||||
static const float c1 = 3424.0 / 4096.0;
|
||||
static const float c2 = 2413.0 / 4096.0 * 32;
|
||||
static const float c3 = 2392.0 / 4096.0 * 32;
|
||||
|
||||
float3 Lp = pow(saturate(L / 10000.0), m1);
|
||||
return pow((c1 + c2 * Lp) / (1 + c3 * Lp), m2);
|
||||
}
|
||||
|
||||
float3 Rec709toRec2020(float3 rec709)
|
||||
{
|
||||
static const float3x3 ConvMat =
|
||||
{
|
||||
0.627402, 0.329292, 0.043306,
|
||||
0.069095, 0.919544, 0.011360,
|
||||
0.016394, 0.088028, 0.895578
|
||||
};
|
||||
return mul(ConvMat, rec709);
|
||||
}
|
||||
|
||||
float3 scRGBTo2100PQ(float3 rgb)
|
||||
{
|
||||
// Convert from Rec 709 primaries (used by scRGB) to Rec 2020 primaries (used by Rec 2100)
|
||||
rgb = Rec709toRec2020(rgb);
|
||||
|
||||
// 1.0f is defined as 80 nits in the scRGB colorspace
|
||||
rgb *= 80;
|
||||
|
||||
// Apply the PQ transfer function on the raw color values in nits
|
||||
return NitsToPQ(rgb);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
#define CONVERT_FUNCTION saturate
|
||||
@@ -0,0 +1,6 @@
|
||||
#include "include/common.hlsl"
|
||||
|
||||
float3 CONVERT_FUNCTION(float3 input)
|
||||
{
|
||||
return ApplySRGBCurve(saturate(input));
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "include/common.hlsl"
|
||||
|
||||
#define CONVERT_FUNCTION scRGBTo2100PQ
|
||||
@@ -0,0 +1,44 @@
|
||||
Texture2D image : register(t0);
|
||||
SamplerState def_sampler : register(s0);
|
||||
|
||||
cbuffer color_matrix_cbuffer : register(b0) {
|
||||
float4 color_vec_y;
|
||||
float4 color_vec_u;
|
||||
float4 color_vec_v;
|
||||
float2 range_y;
|
||||
float2 range_uv;
|
||||
};
|
||||
|
||||
#include "include/base_vs_types.hlsl"
|
||||
|
||||
float2 main_ps(vertex_t input) : SV_Target
|
||||
{
|
||||
#if defined(LEFT_SUBSAMPLING)
|
||||
float3 rgb_left = image.Sample(def_sampler, input.tex_right_left_center.xz).rgb;
|
||||
float3 rgb_right = image.Sample(def_sampler, input.tex_right_left_center.yz).rgb;
|
||||
float3 rgb = CONVERT_FUNCTION((rgb_left + rgb_right) * 0.5);
|
||||
#elif defined(LEFT_SUBSAMPLING_SCALE)
|
||||
float3 rgb = image.Sample(def_sampler, input.tex_right_center_left_top.yw).rgb; // top-center
|
||||
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.yw).rgb; // bottom-center
|
||||
rgb *= 2;
|
||||
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.xw).rgb; // top-right
|
||||
rgb += image.Sample(def_sampler, input.tex_right_center_left_top.zw).rgb; // top-left
|
||||
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.xw).rgb; // bottom-right
|
||||
rgb += image.Sample(def_sampler, input.tex_right_center_left_bottom.zw).rgb; // bottom-left
|
||||
rgb = CONVERT_FUNCTION(rgb * (1./8));
|
||||
#elif defined(TOPLEFT_SUBSAMPLING)
|
||||
float3 rgb_top_left = image.Sample(def_sampler, input.tex_right_left_top.xz).rgb;
|
||||
float3 rgb_top_right = image.Sample(def_sampler, input.tex_right_left_top.yz).rgb;
|
||||
float3 rgb_bottom_left = image.Sample(def_sampler, input.tex_right_left_bottom.xz).rgb;
|
||||
float3 rgb_bottom_right = image.Sample(def_sampler, input.tex_right_left_bottom.yz).rgb;
|
||||
float3 rgb = CONVERT_FUNCTION((rgb_top_left + rgb_top_right + rgb_bottom_left + rgb_bottom_right) * 0.25);
|
||||
#endif
|
||||
|
||||
float u = dot(color_vec_u.xyz, rgb) + color_vec_u.w;
|
||||
float v = dot(color_vec_v.xyz, rgb) + color_vec_v.w;
|
||||
|
||||
u = u * range_uv.x + range_uv.y;
|
||||
v = v * range_uv.x + range_uv.y;
|
||||
|
||||
return float2(u, v);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
Texture2D image : register(t0);
|
||||
SamplerState def_sampler : register(s0);
|
||||
|
||||
cbuffer color_matrix_cbuffer : register(b0) {
|
||||
float4 color_vec_y;
|
||||
float4 color_vec_u;
|
||||
float4 color_vec_v;
|
||||
float2 range_y;
|
||||
float2 range_uv;
|
||||
};
|
||||
|
||||
#include "include/base_vs_types.hlsl"
|
||||
|
||||
float main_ps(vertex_t input) : SV_Target
|
||||
{
|
||||
float3 rgb = CONVERT_FUNCTION(image.Sample(def_sampler, input.tex_coord, 0).rgb);
|
||||
|
||||
float y = dot(color_vec_y.xyz, rgb) + color_vec_y.w;
|
||||
|
||||
return y * range_y.x + range_y.y;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
Texture2D image : register(t0);
|
||||
SamplerState def_sampler : register(s0);
|
||||
|
||||
#ifndef PLANAR_VIEWPORTS
|
||||
cbuffer color_matrix_cbuffer : register(b0) {
|
||||
float4 color_vec_y;
|
||||
float4 color_vec_u;
|
||||
float4 color_vec_v;
|
||||
float2 range_y;
|
||||
float2 range_uv;
|
||||
};
|
||||
#endif
|
||||
|
||||
#include "include/base_vs_types.hlsl"
|
||||
|
||||
#ifdef PLANAR_VIEWPORTS
|
||||
uint main_ps(vertex_t input) : SV_Target
|
||||
#else
|
||||
uint4 main_ps(vertex_t input) : SV_Target
|
||||
#endif
|
||||
{
|
||||
float3 rgb = CONVERT_FUNCTION(image.Sample(def_sampler, input.tex_coord, 0).rgb);
|
||||
|
||||
#ifdef PLANAR_VIEWPORTS
|
||||
// Planar R16, 10 most significant bits store the value
|
||||
return uint(dot(input.color_vec.xyz, rgb) + input.color_vec.w) << 6;
|
||||
#else
|
||||
float y = dot(color_vec_y.xyz, rgb) + color_vec_y.w;
|
||||
float u = dot(color_vec_u.xyz, rgb) + color_vec_u.w;
|
||||
float v = dot(color_vec_v.xyz, rgb) + color_vec_v.w;
|
||||
|
||||
#ifdef Y410
|
||||
return uint4(u, y, v, 0);
|
||||
#else
|
||||
// AYUV
|
||||
return uint4(v, u, y, 0);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user