Initial Commit

This commit is contained in:
2026-02-12 11:46:06 +03:00
commit b044c8d1a5
3973 changed files with 1599881 additions and 0 deletions

View File

@@ -0,0 +1,272 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
// Parameters:
//
// sampler2D image;
// sampler1D palette;
// float4 texel_size;
// float texture_type;
//
//
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// texture_type c0 1
// texel_size c1 1
// image s0 1
// palette s1 1
//
ps_2_0
def c2, -1, 255, 0.5, 0.00390625
def c3, -2, 0, 0, 0
def c4, 1, 0, 0, 1
dcl v0
dcl t0.xy
dcl_2d s0
dcl_2d s1
mov r0.xz, c2
mad r1.x, t0.x, c1.z, r0.z
mad r1.y, t0.y, c1.w, r0.z
frc r0.yz, r1.zxyw
add r1.xy, -r0.yzxw, r1
add r1.zw, r1.wzyx, -c2.z
add r1.xy, r1, c2.z
mul r1.xy, r1, c1
mul r2.xy, r1.wzyx, c1
mov r3.x, r2.x
mov r3.y, r1.y
mov r4.y, r2.y
mov r4.x, r1.x
texld r3, r3, s0
texld r2, r2, s0
texld r1, r1, s0
texld r4, r4, s0
texld r5, t0, s0
mad r0.w, r3.x, c2.y, c2.z
mul r3.xy, r0.w, c2.w
mad r0.w, r2.x, c2.y, c2.z
mul r2.xy, r0.w, c2.w
mad r0.w, r1.x, c2.y, c2.z
mul r1.xy, r0.w, c2.w
mad r0.w, r4.x, c2.y, c2.z
mul r4.xy, r0.w, c2.w
mad r0.w, r5.x, c2.y, c2.z
mul r5.xy, r0.w, c2.w
texld r3, r3, s1
texld r2, r2, s1
texld r1, r1, s1
texld r4, r4, s1
texld r5, r5, s1
lrp r6, r0.z, r3, r2
lrp r2, r0.z, r1, r4
lrp r1, r0.y, r2, r6
mov r2.x, c0.x
add r0.y, r2.x, c3.x
mul r0.y, r0.y, r0.y
cmp r1, -r0.y, r1, c4
add r0.x, r0.x, c0.x
mul r0.x, r0.x, r0.x
cmp r0, -r0.x, r5, r1
mul r0, r0, v0
mov oC0, r0
// approximately 45 instruction slots used (10 texture, 35 arithmetic)
#endif
const BYTE g_ps20_main[] =
{
0, 2, 255, 255, 254, 255,
67, 0, 67, 84, 65, 66,
28, 0, 0, 0, 223, 0,
0, 0, 0, 2, 255, 255,
4, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
216, 0, 0, 0, 108, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 116, 0,
0, 0, 0, 0, 0, 0,
132, 0, 0, 0, 3, 0,
1, 0, 1, 0, 0, 0,
140, 0, 0, 0, 0, 0,
0, 0, 156, 0, 0, 0,
2, 0, 1, 0, 1, 0,
0, 0, 168, 0, 0, 0,
0, 0, 0, 0, 184, 0,
0, 0, 2, 0, 0, 0,
1, 0, 0, 0, 200, 0,
0, 0, 0, 0, 0, 0,
105, 109, 97, 103, 101, 0,
171, 171, 4, 0, 12, 0,
1, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0,
112, 97, 108, 101, 116, 116,
101, 0, 4, 0, 11, 0,
1, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0,
116, 101, 120, 101, 108, 95,
115, 105, 122, 101, 0, 171,
1, 0, 3, 0, 1, 0,
4, 0, 1, 0, 0, 0,
0, 0, 0, 0, 116, 101,
120, 116, 117, 114, 101, 95,
116, 121, 112, 101, 0, 171,
171, 171, 0, 0, 3, 0,
1, 0, 1, 0, 1, 0,
0, 0, 0, 0, 0, 0,
112, 115, 95, 50, 95, 48,
0, 77, 105, 99, 114, 111,
115, 111, 102, 116, 32, 40,
82, 41, 32, 72, 76, 83,
76, 32, 83, 104, 97, 100,
101, 114, 32, 67, 111, 109,
112, 105, 108, 101, 114, 32,
49, 48, 46, 49, 0, 171,
81, 0, 0, 5, 2, 0,
15, 160, 0, 0, 128, 191,
0, 0, 127, 67, 0, 0,
0, 63, 0, 0, 128, 59,
81, 0, 0, 5, 3, 0,
15, 160, 0, 0, 0, 192,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
81, 0, 0, 5, 4, 0,
15, 160, 0, 0, 128, 63,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 128, 63,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 15, 144,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 3, 176,
31, 0, 0, 2, 0, 0,
0, 144, 0, 8, 15, 160,
31, 0, 0, 2, 0, 0,
0, 144, 1, 8, 15, 160,
1, 0, 0, 2, 0, 0,
5, 128, 2, 0, 228, 160,
4, 0, 0, 4, 1, 0,
1, 128, 0, 0, 0, 176,
1, 0, 170, 160, 0, 0,
170, 128, 4, 0, 0, 4,
1, 0, 2, 128, 0, 0,
85, 176, 1, 0, 255, 160,
0, 0, 170, 128, 19, 0,
0, 2, 0, 0, 6, 128,
1, 0, 210, 128, 2, 0,
0, 3, 1, 0, 3, 128,
0, 0, 201, 129, 1, 0,
228, 128, 2, 0, 0, 3,
1, 0, 12, 128, 1, 0,
27, 128, 2, 0, 170, 161,
2, 0, 0, 3, 1, 0,
3, 128, 1, 0, 228, 128,
2, 0, 170, 160, 5, 0,
0, 3, 1, 0, 3, 128,
1, 0, 228, 128, 1, 0,
228, 160, 5, 0, 0, 3,
2, 0, 3, 128, 1, 0,
27, 128, 1, 0, 228, 160,
1, 0, 0, 2, 3, 0,
1, 128, 2, 0, 0, 128,
1, 0, 0, 2, 3, 0,
2, 128, 1, 0, 85, 128,
1, 0, 0, 2, 4, 0,
2, 128, 2, 0, 85, 128,
1, 0, 0, 2, 4, 0,
1, 128, 1, 0, 0, 128,
66, 0, 0, 3, 3, 0,
15, 128, 3, 0, 228, 128,
0, 8, 228, 160, 66, 0,
0, 3, 2, 0, 15, 128,
2, 0, 228, 128, 0, 8,
228, 160, 66, 0, 0, 3,
1, 0, 15, 128, 1, 0,
228, 128, 0, 8, 228, 160,
66, 0, 0, 3, 4, 0,
15, 128, 4, 0, 228, 128,
0, 8, 228, 160, 66, 0,
0, 3, 5, 0, 15, 128,
0, 0, 228, 176, 0, 8,
228, 160, 4, 0, 0, 4,
0, 0, 8, 128, 3, 0,
0, 128, 2, 0, 85, 160,
2, 0, 170, 160, 5, 0,
0, 3, 3, 0, 3, 128,
0, 0, 255, 128, 2, 0,
255, 160, 4, 0, 0, 4,
0, 0, 8, 128, 2, 0,
0, 128, 2, 0, 85, 160,
2, 0, 170, 160, 5, 0,
0, 3, 2, 0, 3, 128,
0, 0, 255, 128, 2, 0,
255, 160, 4, 0, 0, 4,
0, 0, 8, 128, 1, 0,
0, 128, 2, 0, 85, 160,
2, 0, 170, 160, 5, 0,
0, 3, 1, 0, 3, 128,
0, 0, 255, 128, 2, 0,
255, 160, 4, 0, 0, 4,
0, 0, 8, 128, 4, 0,
0, 128, 2, 0, 85, 160,
2, 0, 170, 160, 5, 0,
0, 3, 4, 0, 3, 128,
0, 0, 255, 128, 2, 0,
255, 160, 4, 0, 0, 4,
0, 0, 8, 128, 5, 0,
0, 128, 2, 0, 85, 160,
2, 0, 170, 160, 5, 0,
0, 3, 5, 0, 3, 128,
0, 0, 255, 128, 2, 0,
255, 160, 66, 0, 0, 3,
3, 0, 15, 128, 3, 0,
228, 128, 1, 8, 228, 160,
66, 0, 0, 3, 2, 0,
15, 128, 2, 0, 228, 128,
1, 8, 228, 160, 66, 0,
0, 3, 1, 0, 15, 128,
1, 0, 228, 128, 1, 8,
228, 160, 66, 0, 0, 3,
4, 0, 15, 128, 4, 0,
228, 128, 1, 8, 228, 160,
66, 0, 0, 3, 5, 0,
15, 128, 5, 0, 228, 128,
1, 8, 228, 160, 18, 0,
0, 4, 6, 0, 15, 128,
0, 0, 170, 128, 3, 0,
228, 128, 2, 0, 228, 128,
18, 0, 0, 4, 2, 0,
15, 128, 0, 0, 170, 128,
1, 0, 228, 128, 4, 0,
228, 128, 18, 0, 0, 4,
1, 0, 15, 128, 0, 0,
85, 128, 2, 0, 228, 128,
6, 0, 228, 128, 1, 0,
0, 2, 2, 0, 1, 128,
0, 0, 0, 160, 2, 0,
0, 3, 0, 0, 2, 128,
2, 0, 0, 128, 3, 0,
0, 160, 5, 0, 0, 3,
0, 0, 2, 128, 0, 0,
85, 128, 0, 0, 85, 128,
88, 0, 0, 4, 1, 0,
15, 128, 0, 0, 85, 129,
1, 0, 228, 128, 4, 0,
228, 160, 2, 0, 0, 3,
0, 0, 1, 128, 0, 0,
0, 128, 0, 0, 0, 160,
5, 0, 0, 3, 0, 0,
1, 128, 0, 0, 0, 128,
0, 0, 0, 128, 88, 0,
0, 4, 0, 0, 15, 128,
0, 0, 0, 129, 5, 0,
228, 128, 1, 0, 228, 128,
5, 0, 0, 3, 0, 0,
15, 128, 0, 0, 228, 128,
0, 0, 228, 144, 1, 0,
0, 2, 0, 8, 15, 128,
0, 0, 228, 128, 255, 255,
0, 0
};

View File

@@ -0,0 +1,49 @@
cbuffer Constants
{
float4 texel_size;
};
uniform sampler2D image;
uniform sampler1D palette;
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
static const float TEXTURETYPE_NONE = 0;
static const float TEXTURETYPE_PALETTE_NEAREST = 1;
static const float TEXTURETYPE_PALETTE_LINEAR = 2;
float4 SamplePaletteNearest(float2 uv)
{
float index = tex2D(image, uv).r * 255;
return tex1D(palette, (index + 0.5) / 256);
}
// Implementation with thanks from bgolus:
// https://discussions.unity.com/t/how-to-make-data-shader-support-bilinear-trilinear/598639/8
float4 SamplePaletteLinear(float2 uv)
{
// scale & offset uvs to integer values at texel centers
float2 uv_texels = uv * texel_size.zw + 0.5;
// get uvs for the center of the 4 surrounding texels by flooring
float4 uv_min_max = float4((floor(uv_texels) - 0.5) * texel_size.xy, (floor(uv_texels) + 0.5) * texel_size.xy);
// blend factor
float2 uv_frac = frac(uv_texels);
// sample all 4 texels
float4 texelA = SamplePaletteNearest(uv_min_max.xy);
float4 texelB = SamplePaletteNearest(uv_min_max.xw);
float4 texelC = SamplePaletteNearest(uv_min_max.zy);
float4 texelD = SamplePaletteNearest(uv_min_max.zw);
// bilinear interpolation
return lerp(lerp(texelA, texelB, uv_frac.y), lerp(texelC, texelD, uv_frac.y), uv_frac.x);
}

View File

@@ -0,0 +1,209 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
// Parameters:
//
// sampler2D image;
// sampler1D palette;
// float4 texel_size;
//
//
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// texel_size c0 1
// image s0 1
// palette s1 1
//
ps_2_0
def c1, 0.5, -0.5, 255, 0.00390625
dcl t0.xy
dcl v0
dcl_2d s0
dcl_2d s1
mov r0.w, c1.x
mad r0.x, t0.x, c0.z, r0.w
mad r0.y, t0.y, c0.w, r0.w
frc r0.zw, r0.wzyx
add r0.xy, -r0.wzyx, r0
add r1.xy, r0, c1.y
add r0.xy, r0, c1.x
mul r0.xy, r0, c0
mul r1.xy, r1, c0
mov r2.x, r1.x
mov r2.y, r0.y
mov r3.y, r1.y
mov r3.x, r0.x
texld r2, r2, s0
texld r1, r1, s0
texld r4, r0, s0
texld r3, r3, s0
mad r0.x, r2.x, c1.z, c1.x
mul r0.xy, r0.x, c1.w
mad r1.x, r1.x, c1.z, c1.x
mul r1.xy, r1.x, c1.w
mad r1.z, r4.x, c1.z, c1.x
mul r2.xy, r1.z, c1.w
mad r1.z, r3.x, c1.z, c1.x
mul r3.xy, r1.z, c1.w
texld r4, r0, s1
texld r1, r1, s1
texld r2, r2, s1
texld r3, r3, s1
lrp r5, r0.z, r4, r1
lrp r1, r0.z, r2, r3
lrp r2, r0.w, r1, r5
mul r0, r2, v0
mov oC0, r0
// approximately 34 instruction slots used (8 texture, 26 arithmetic)
#endif
const BYTE g_ps20_main[] =
{
0, 2, 255, 255, 254, 255,
54, 0, 67, 84, 65, 66,
28, 0, 0, 0, 171, 0,
0, 0, 0, 2, 255, 255,
3, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
164, 0, 0, 0, 88, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 96, 0,
0, 0, 0, 0, 0, 0,
112, 0, 0, 0, 3, 0,
1, 0, 1, 0, 0, 0,
120, 0, 0, 0, 0, 0,
0, 0, 136, 0, 0, 0,
2, 0, 0, 0, 1, 0,
0, 0, 148, 0, 0, 0,
0, 0, 0, 0, 105, 109,
97, 103, 101, 0, 171, 171,
4, 0, 12, 0, 1, 0,
1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 112, 97,
108, 101, 116, 116, 101, 0,
4, 0, 11, 0, 1, 0,
1, 0, 1, 0, 0, 0,
0, 0, 0, 0, 116, 101,
120, 101, 108, 95, 115, 105,
122, 101, 0, 171, 1, 0,
3, 0, 1, 0, 4, 0,
1, 0, 0, 0, 0, 0,
0, 0, 112, 115, 95, 50,
95, 48, 0, 77, 105, 99,
114, 111, 115, 111, 102, 116,
32, 40, 82, 41, 32, 72,
76, 83, 76, 32, 83, 104,
97, 100, 101, 114, 32, 67,
111, 109, 112, 105, 108, 101,
114, 32, 49, 48, 46, 49,
0, 171, 81, 0, 0, 5,
1, 0, 15, 160, 0, 0,
0, 63, 0, 0, 0, 191,
0, 0, 127, 67, 0, 0,
128, 59, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
3, 176, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
15, 144, 31, 0, 0, 2,
0, 0, 0, 144, 0, 8,
15, 160, 31, 0, 0, 2,
0, 0, 0, 144, 1, 8,
15, 160, 1, 0, 0, 2,
0, 0, 8, 128, 1, 0,
0, 160, 4, 0, 0, 4,
0, 0, 1, 128, 0, 0,
0, 176, 0, 0, 170, 160,
0, 0, 255, 128, 4, 0,
0, 4, 0, 0, 2, 128,
0, 0, 85, 176, 0, 0,
255, 160, 0, 0, 255, 128,
19, 0, 0, 2, 0, 0,
12, 128, 0, 0, 27, 128,
2, 0, 0, 3, 0, 0,
3, 128, 0, 0, 27, 129,
0, 0, 228, 128, 2, 0,
0, 3, 1, 0, 3, 128,
0, 0, 228, 128, 1, 0,
85, 160, 2, 0, 0, 3,
0, 0, 3, 128, 0, 0,
228, 128, 1, 0, 0, 160,
5, 0, 0, 3, 0, 0,
3, 128, 0, 0, 228, 128,
0, 0, 228, 160, 5, 0,
0, 3, 1, 0, 3, 128,
1, 0, 228, 128, 0, 0,
228, 160, 1, 0, 0, 2,
2, 0, 1, 128, 1, 0,
0, 128, 1, 0, 0, 2,
2, 0, 2, 128, 0, 0,
85, 128, 1, 0, 0, 2,
3, 0, 2, 128, 1, 0,
85, 128, 1, 0, 0, 2,
3, 0, 1, 128, 0, 0,
0, 128, 66, 0, 0, 3,
2, 0, 15, 128, 2, 0,
228, 128, 0, 8, 228, 160,
66, 0, 0, 3, 1, 0,
15, 128, 1, 0, 228, 128,
0, 8, 228, 160, 66, 0,
0, 3, 4, 0, 15, 128,
0, 0, 228, 128, 0, 8,
228, 160, 66, 0, 0, 3,
3, 0, 15, 128, 3, 0,
228, 128, 0, 8, 228, 160,
4, 0, 0, 4, 0, 0,
1, 128, 2, 0, 0, 128,
1, 0, 170, 160, 1, 0,
0, 160, 5, 0, 0, 3,
0, 0, 3, 128, 0, 0,
0, 128, 1, 0, 255, 160,
4, 0, 0, 4, 1, 0,
1, 128, 1, 0, 0, 128,
1, 0, 170, 160, 1, 0,
0, 160, 5, 0, 0, 3,
1, 0, 3, 128, 1, 0,
0, 128, 1, 0, 255, 160,
4, 0, 0, 4, 1, 0,
4, 128, 4, 0, 0, 128,
1, 0, 170, 160, 1, 0,
0, 160, 5, 0, 0, 3,
2, 0, 3, 128, 1, 0,
170, 128, 1, 0, 255, 160,
4, 0, 0, 4, 1, 0,
4, 128, 3, 0, 0, 128,
1, 0, 170, 160, 1, 0,
0, 160, 5, 0, 0, 3,
3, 0, 3, 128, 1, 0,
170, 128, 1, 0, 255, 160,
66, 0, 0, 3, 4, 0,
15, 128, 0, 0, 228, 128,
1, 8, 228, 160, 66, 0,
0, 3, 1, 0, 15, 128,
1, 0, 228, 128, 1, 8,
228, 160, 66, 0, 0, 3,
2, 0, 15, 128, 2, 0,
228, 128, 1, 8, 228, 160,
66, 0, 0, 3, 3, 0,
15, 128, 3, 0, 228, 128,
1, 8, 228, 160, 18, 0,
0, 4, 5, 0, 15, 128,
0, 0, 170, 128, 4, 0,
228, 128, 1, 0, 228, 128,
18, 0, 0, 4, 1, 0,
15, 128, 0, 0, 170, 128,
2, 0, 228, 128, 3, 0,
228, 128, 18, 0, 0, 4,
2, 0, 15, 128, 0, 0,
255, 128, 1, 0, 228, 128,
5, 0, 228, 128, 5, 0,
0, 3, 0, 0, 15, 128,
2, 0, 228, 128, 0, 0,
228, 144, 1, 0, 0, 2,
0, 8, 15, 128, 0, 0,
228, 128, 255, 255, 0, 0
};

View File

@@ -0,0 +1,7 @@
#include "D3D9_PixelShader_Palette.hlsli"
float4 main(PixelShaderInput input) : SV_TARGET
{
return SamplePaletteLinear(input.tex) * input.color;
}

View File

@@ -0,0 +1,95 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
// Parameters:
//
// sampler2D image;
// sampler1D palette;
//
//
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// image s0 1
// palette s1 1
//
ps_2_0
def c0, 255, 0.5, 0.00390625, 0
dcl t0.xy
dcl v0
dcl_2d s0
dcl_2d s1
texld r0, t0, s0
mad r0.x, r0.x, c0.x, c0.y
mul r0.xy, r0.x, c0.z
texld r0, r0, s1
mul r0, r0, v0
mov oC0, r0
// approximately 6 instruction slots used (2 texture, 4 arithmetic)
#endif
const BYTE g_ps20_main[] =
{
0, 2, 255, 255, 254, 255,
42, 0, 67, 84, 65, 66,
28, 0, 0, 0, 123, 0,
0, 0, 0, 2, 255, 255,
2, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
116, 0, 0, 0, 68, 0,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 76, 0,
0, 0, 0, 0, 0, 0,
92, 0, 0, 0, 3, 0,
1, 0, 1, 0, 0, 0,
100, 0, 0, 0, 0, 0,
0, 0, 105, 109, 97, 103,
101, 0, 171, 171, 4, 0,
12, 0, 1, 0, 1, 0,
1, 0, 0, 0, 0, 0,
0, 0, 112, 97, 108, 101,
116, 116, 101, 0, 4, 0,
11, 0, 1, 0, 1, 0,
1, 0, 0, 0, 0, 0,
0, 0, 112, 115, 95, 50,
95, 48, 0, 77, 105, 99,
114, 111, 115, 111, 102, 116,
32, 40, 82, 41, 32, 72,
76, 83, 76, 32, 83, 104,
97, 100, 101, 114, 32, 67,
111, 109, 112, 105, 108, 101,
114, 32, 49, 48, 46, 49,
0, 171, 81, 0, 0, 5,
0, 0, 15, 160, 0, 0,
127, 67, 0, 0, 0, 63,
0, 0, 128, 59, 0, 0,
0, 0, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
3, 176, 31, 0, 0, 2,
0, 0, 0, 128, 0, 0,
15, 144, 31, 0, 0, 2,
0, 0, 0, 144, 0, 8,
15, 160, 31, 0, 0, 2,
0, 0, 0, 144, 1, 8,
15, 160, 66, 0, 0, 3,
0, 0, 15, 128, 0, 0,
228, 176, 0, 8, 228, 160,
4, 0, 0, 4, 0, 0,
1, 128, 0, 0, 0, 128,
0, 0, 0, 160, 0, 0,
85, 160, 5, 0, 0, 3,
0, 0, 3, 128, 0, 0,
0, 128, 0, 0, 170, 160,
66, 0, 0, 3, 0, 0,
15, 128, 0, 0, 228, 128,
1, 8, 228, 160, 5, 0,
0, 3, 0, 0, 15, 128,
0, 0, 228, 128, 0, 0,
228, 144, 1, 0, 0, 2,
0, 8, 15, 128, 0, 0,
228, 128, 255, 255, 0, 0
};

View File

@@ -0,0 +1,7 @@
#include "D3D9_PixelShader_Palette.hlsli"
float4 main(PixelShaderInput input) : SV_TARGET
{
return SamplePaletteNearest(input.tex) * input.color;
}

View File

@@ -0,0 +1,164 @@
#if 0
//
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
//
// Parameters:
//
// float4 Bcoeff;
// float4 Gcoeff;
// float4 Rcoeff;
// float4 Yoffset;
// Texture2D theSampler+theTextureU;
// Texture2D theSampler+theTextureV;
// Texture2D theSampler+theTextureY;
//
//
// Registers:
//
// Name Reg Size
// ---------------------- ----- ----
// Yoffset c0 1
// Rcoeff c1 1
// Gcoeff c2 1
// Bcoeff c3 1
// theSampler+theTextureY s0 1
// theSampler+theTextureU s1 1
// theSampler+theTextureV s2 1
//
ps_2_0
def c4, 1, 0, 0, 0
dcl t0.xy
dcl v0
dcl_2d s0
dcl_2d s1
dcl_2d s2
texld r0, t0, s0
texld r1, t0, s1
texld r2, t0, s2
mov r0.y, r1.x
mov r0.z, r2.x
add r0.xyz, r0, c0
dp3 r1.x, r0, c1
dp3 r1.y, r0, c2
dp3 r1.z, r0, c3
mov r1.w, c4.x
mul r0, r1, v0
mov oC0, r0
// approximately 12 instruction slots used (3 texture, 9 arithmetic)
#endif
const BYTE g_ps20_main[] =
{
0, 2, 255, 255, 254, 255,
97, 0, 67, 84, 65, 66,
28, 0, 0, 0, 87, 1,
0, 0, 0, 2, 255, 255,
7, 0, 0, 0, 28, 0,
0, 0, 0, 1, 0, 0,
80, 1, 0, 0, 168, 0,
0, 0, 2, 0, 3, 0,
1, 0, 0, 0, 176, 0,
0, 0, 0, 0, 0, 0,
192, 0, 0, 0, 2, 0,
2, 0, 1, 0, 0, 0,
176, 0, 0, 0, 0, 0,
0, 0, 199, 0, 0, 0,
2, 0, 1, 0, 1, 0,
0, 0, 176, 0, 0, 0,
0, 0, 0, 0, 206, 0,
0, 0, 2, 0, 0, 0,
1, 0, 0, 0, 176, 0,
0, 0, 0, 0, 0, 0,
214, 0, 0, 0, 3, 0,
1, 0, 1, 0, 0, 0,
240, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0,
3, 0, 2, 0, 1, 0,
0, 0, 24, 1, 0, 0,
0, 0, 0, 0, 40, 1,
0, 0, 3, 0, 0, 0,
1, 0, 0, 0, 64, 1,
0, 0, 0, 0, 0, 0,
66, 99, 111, 101, 102, 102,
0, 171, 1, 0, 3, 0,
1, 0, 4, 0, 1, 0,
0, 0, 0, 0, 0, 0,
71, 99, 111, 101, 102, 102,
0, 82, 99, 111, 101, 102,
102, 0, 89, 111, 102, 102,
115, 101, 116, 0, 116, 104,
101, 83, 97, 109, 112, 108,
101, 114, 43, 116, 104, 101,
84, 101, 120, 116, 117, 114,
101, 85, 0, 171, 171, 171,
4, 0, 7, 0, 1, 0,
4, 0, 1, 0, 0, 0,
0, 0, 0, 0, 116, 104,
101, 83, 97, 109, 112, 108,
101, 114, 43, 116, 104, 101,
84, 101, 120, 116, 117, 114,
101, 86, 0, 171, 4, 0,
7, 0, 1, 0, 4, 0,
1, 0, 0, 0, 0, 0,
0, 0, 116, 104, 101, 83,
97, 109, 112, 108, 101, 114,
43, 116, 104, 101, 84, 101,
120, 116, 117, 114, 101, 89,
0, 171, 4, 0, 7, 0,
1, 0, 4, 0, 1, 0,
0, 0, 0, 0, 0, 0,
112, 115, 95, 50, 95, 48,
0, 77, 105, 99, 114, 111,
115, 111, 102, 116, 32, 40,
82, 41, 32, 72, 76, 83,
76, 32, 83, 104, 97, 100,
101, 114, 32, 67, 111, 109,
112, 105, 108, 101, 114, 32,
49, 48, 46, 49, 0, 171,
81, 0, 0, 5, 4, 0,
15, 160, 0, 0, 128, 63,
0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 3, 176,
31, 0, 0, 2, 0, 0,
0, 128, 0, 0, 15, 144,
31, 0, 0, 2, 0, 0,
0, 144, 0, 8, 15, 160,
31, 0, 0, 2, 0, 0,
0, 144, 1, 8, 15, 160,
31, 0, 0, 2, 0, 0,
0, 144, 2, 8, 15, 160,
66, 0, 0, 3, 0, 0,
15, 128, 0, 0, 228, 176,
0, 8, 228, 160, 66, 0,
0, 3, 1, 0, 15, 128,
0, 0, 228, 176, 1, 8,
228, 160, 66, 0, 0, 3,
2, 0, 15, 128, 0, 0,
228, 176, 2, 8, 228, 160,
1, 0, 0, 2, 0, 0,
2, 128, 1, 0, 0, 128,
1, 0, 0, 2, 0, 0,
4, 128, 2, 0, 0, 128,
2, 0, 0, 3, 0, 0,
7, 128, 0, 0, 228, 128,
0, 0, 228, 160, 8, 0,
0, 3, 1, 0, 1, 128,
0, 0, 228, 128, 1, 0,
228, 160, 8, 0, 0, 3,
1, 0, 2, 128, 0, 0,
228, 128, 2, 0, 228, 160,
8, 0, 0, 3, 1, 0,
4, 128, 0, 0, 228, 128,
3, 0, 228, 160, 1, 0,
0, 2, 1, 0, 8, 128,
4, 0, 0, 160, 5, 0,
0, 3, 0, 0, 15, 128,
1, 0, 228, 128, 0, 0,
228, 144, 1, 0, 0, 2,
0, 8, 15, 128, 0, 0,
228, 128, 255, 255, 0, 0
};

View File

@@ -0,0 +1,47 @@
Texture2D theTextureY : register(t0);
Texture2D theTextureU : register(t1);
Texture2D theTextureV : register(t2);
SamplerState theSampler = sampler_state
{
addressU = Clamp;
addressV = Clamp;
mipfilter = NONE;
minfilter = LINEAR;
magfilter = LINEAR;
};
struct PixelShaderInput
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float4 color : COLOR0;
};
cbuffer Constants : register(b0)
{
float4 Yoffset;
float4 Rcoeff;
float4 Gcoeff;
float4 Bcoeff;
};
float4 main(PixelShaderInput input) : SV_TARGET
{
float4 Output;
float3 yuv;
yuv.x = theTextureY.Sample(theSampler, input.tex).r;
yuv.y = theTextureU.Sample(theSampler, input.tex).r;
yuv.z = theTextureV.Sample(theSampler, input.tex).r;
yuv += Yoffset.xyz;
Output.r = dot(yuv, Rcoeff.xyz);
Output.g = dot(yuv, Gcoeff.xyz);
Output.b = dot(yuv, Bcoeff.xyz);
Output.a = 1.0f;
return Output * input.color;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
#ifdef SDL_VIDEO_RENDER_D3D
#include "../../core/windows/SDL_windows.h"
#include <d3d9.h>
#include "SDL_shaders_d3d.h"
// The shaders here were compiled with compile_shaders.bat
#define g_ps20_main D3D9_PixelShader_Palette_Nearest
#include "D3D9_PixelShader_Palette_Nearest.h"
#undef g_ps20_main
#define g_ps20_main D3D9_PixelShader_Palette_Linear
#include "D3D9_PixelShader_Palette_Linear.h"
#undef g_ps20_main
#define g_ps20_main D3D9_PixelShader_YUV
#include "D3D9_PixelShader_YUV.h"
#undef g_ps20_main
static const BYTE *D3D9_shaders[] = {
NULL,
D3D9_PixelShader_Palette_Nearest,
D3D9_PixelShader_Palette_Linear,
D3D9_PixelShader_YUV
};
SDL_COMPILE_TIME_ASSERT(D3D9_shaders, SDL_arraysize(D3D9_shaders) == NUM_SHADERS);
HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader)
{
return IDirect3DDevice9_CreatePixelShader(d3dDevice, (const DWORD *)D3D9_shaders[shader], pixelShader);
}
#endif // SDL_VIDEO_RENDER_D3D

View File

@@ -0,0 +1,34 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
// D3D9 shader implementation
typedef enum
{
SHADER_NONE,
SHADER_PALETTE_NEAREST,
SHADER_PALETTE_LINEAR,
SHADER_YUV,
NUM_SHADERS
} D3D9_Shader;
extern HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader);

View File

@@ -0,0 +1,3 @@
fxc /T ps_2_0 /Fh D3D9_PixelShader_Palette_Nearest.h D3D9_PixelShader_Palette_Nearest.hlsl
fxc /T ps_2_0 /Fh D3D9_PixelShader_Palette_Linear.h D3D9_PixelShader_Palette_Linear.hlsl
fxc /T ps_2_0 /Fh D3D9_PixelShader_YUV.h D3D9_PixelShader_YUV.hlsl