diff --git a/include/SDL3/SDL_render.h b/include/SDL3/SDL_render.h index 60c3962b35..195e580290 100644 --- a/include/SDL3/SDL_render.h +++ b/include/SDL3/SDL_render.h @@ -1234,7 +1234,6 @@ extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, S * The default texture scale mode is SDL_SCALEMODE_LINEAR. * * If the scale mode is not supported, the closest supported mode is chosen. - * Palettized textures will always use SDL_SCALEMODE_NEAREST. * * \param texture the texture to update. * \param scaleMode the SDL_ScaleMode to use for texture scaling. diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 0753e5c719..44f293c05d 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -1525,11 +1525,7 @@ SDL_Texture *SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_Propert texture->color.b = 1.0f; texture->color.a = 1.0f; texture->blendMode = SDL_ISPIXELFORMAT_ALPHA(format) ? SDL_BLENDMODE_BLEND : SDL_BLENDMODE_NONE; - if (SDL_ISPIXELFORMAT_INDEXED(format)) { - texture->scaleMode = SDL_SCALEMODE_NEAREST; - } else { - texture->scaleMode = renderer->scale_mode; - } + texture->scaleMode = renderer->scale_mode; texture->view.pixel_w = w; texture->view.pixel_h = h; texture->view.viewport.w = -1; @@ -2162,12 +2158,8 @@ bool SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode) switch (scaleMode) { case SDL_SCALEMODE_NEAREST: - break; case SDL_SCALEMODE_PIXELART: case SDL_SCALEMODE_LINEAR: - if (SDL_ISPIXELFORMAT_INDEXED(texture->format)) { - scaleMode = SDL_SCALEMODE_NEAREST; - } break; default: return SDL_InvalidParamError("scaleMode"); diff --git a/src/render/direct3d/D3D9_PixelShader_Palette.h b/src/render/direct3d/D3D9_PixelShader_Palette.h index 9bc727ee50..201c337c0a 100644 --- a/src/render/direct3d/D3D9_PixelShader_Palette.h +++ b/src/render/direct3d/D3D9_PixelShader_Palette.h @@ -6,83 +6,263 @@ // // 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 c0, 0.99609375, 0.001953125, 0, 0 - dcl t0.xy + 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 - texld r0, t0, s0 - mad r0.xy, r0.x, c0.x, c0.y - texld r0, r0, 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 5 instruction slots used (2 texture, 3 arithmetic) +// approximately 45 instruction slots used (10 texture, 35 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, + 67, 0, 67, 84, 65, 66, + 28, 0, 0, 0, 223, 0, 0, 0, 0, 2, 255, 255, - 2, 0, 0, 0, 28, 0, + 4, 0, 0, 0, 28, 0, 0, 0, 0, 1, 0, 0, - 116, 0, 0, 0, 68, 0, + 216, 0, 0, 0, 108, 0, 0, 0, 3, 0, 0, 0, - 1, 0, 0, 0, 76, 0, + 1, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, - 92, 0, 0, 0, 3, 0, + 132, 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, 63, 0, 0, 0, 59, + 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, - 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, - 3, 128, 0, 0, 0, 128, - 0, 0, 0, 160, 0, 0, - 85, 160, 66, 0, 0, 3, - 0, 0, 15, 128, 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, diff --git a/src/render/direct3d/D3D9_PixelShader_Palette.hlsl b/src/render/direct3d/D3D9_PixelShader_Palette.hlsl deleted file mode 100644 index 99dd4798d0..0000000000 --- a/src/render/direct3d/D3D9_PixelShader_Palette.hlsl +++ /dev/null @@ -1,19 +0,0 @@ - -uniform sampler2D image; -uniform sampler1D palette; - -struct PixelShaderInput -{ - float4 pos : SV_POSITION; - float2 tex : TEXCOORD0; - float4 color : COLOR0; -}; - -float4 main(PixelShaderInput input) : SV_TARGET -{ - float4 Output; - float index; - index = tex2D(image, input.tex).r; - Output = tex1D(palette, index * (255. / 256) + (0.5 / 256)); - return Output * input.color; -} diff --git a/src/render/direct3d/D3D9_PixelShader_Palette.hlsli b/src/render/direct3d/D3D9_PixelShader_Palette.hlsli new file mode 100644 index 0000000000..5bd5a58e66 --- /dev/null +++ b/src/render/direct3d/D3D9_PixelShader_Palette.hlsli @@ -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); +} + diff --git a/src/render/direct3d/D3D9_PixelShader_Palette_Linear.h b/src/render/direct3d/D3D9_PixelShader_Palette_Linear.h new file mode 100755 index 0000000000..da73f860e9 --- /dev/null +++ b/src/render/direct3d/D3D9_PixelShader_Palette_Linear.h @@ -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 +}; diff --git a/src/render/direct3d/D3D9_PixelShader_Palette_Linear.hlsl b/src/render/direct3d/D3D9_PixelShader_Palette_Linear.hlsl new file mode 100644 index 0000000000..63aeaa002d --- /dev/null +++ b/src/render/direct3d/D3D9_PixelShader_Palette_Linear.hlsl @@ -0,0 +1,7 @@ + +#include "D3D9_PixelShader_Palette.hlsli" + +float4 main(PixelShaderInput input) : SV_TARGET +{ + return SamplePaletteLinear(input.tex) * input.color; +} diff --git a/src/render/direct3d/D3D9_PixelShader_Palette_Nearest.h b/src/render/direct3d/D3D9_PixelShader_Palette_Nearest.h new file mode 100755 index 0000000000..6a36bb75e6 --- /dev/null +++ b/src/render/direct3d/D3D9_PixelShader_Palette_Nearest.h @@ -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 +}; diff --git a/src/render/direct3d/D3D9_PixelShader_Palette_Nearest.hlsl b/src/render/direct3d/D3D9_PixelShader_Palette_Nearest.hlsl new file mode 100644 index 0000000000..6131f7bf61 --- /dev/null +++ b/src/render/direct3d/D3D9_PixelShader_Palette_Nearest.hlsl @@ -0,0 +1,7 @@ + +#include "D3D9_PixelShader_Palette.hlsli" + +float4 main(PixelShaderInput input) : SV_TARGET +{ + return SamplePaletteNearest(input.tex) * input.color; +} diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index e72c49e34e..a368a61e4d 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -86,9 +86,7 @@ typedef struct IDirect3DSurface9 *defaultRenderTarget; IDirect3DSurface9 *currentRenderTarget; void *d3dxDLL; -#ifdef SDL_HAVE_YUV LPDIRECT3DPIXELSHADER9 shaders[NUM_SHADERS]; -#endif LPDIRECT3DVERTEXBUFFER9 vertexBuffers[8]; size_t vertexBufferSize[8]; int currentVertexBuffer; @@ -100,8 +98,9 @@ typedef struct typedef struct { D3D_TextureRep texture; - D3D9_Shader shader; + UINT shader_params_length; const float *shader_params; + float palette_shader_params[4]; #ifdef SDL_HAVE_YUV // YV12 texture support @@ -657,7 +656,12 @@ static bool D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ return false; } if (texture->format == SDL_PIXELFORMAT_INDEX8) { - texturedata->shader = SHADER_PALETTE; + texturedata->shader_params_length = 1; // The palette shader takes 1 float4 parameters + texturedata->shader_params = texturedata->palette_shader_params; + texturedata->palette_shader_params[0] = 1.0f / texture->w; + texturedata->palette_shader_params[1] = 1.0f / texture->h; + texturedata->palette_shader_params[2] = texture->w; + texturedata->palette_shader_params[3] = texture->h; } #ifdef SDL_HAVE_YUV if (texture->format == SDL_PIXELFORMAT_YV12 || @@ -672,7 +676,7 @@ static bool D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture, SDL_ return false; } - texturedata->shader = SHADER_YUV; + texturedata->shader_params_length = 4; // The YUV shader takes 4 float4 parameters texturedata->shader_params = SDL_GetYCbCRtoRGBConversionMatrix(texture->colorspace, texture->w, texture->h, 8); if (texturedata->shader_params == NULL) { return SDL_SetError("Unsupported YUV colorspace"); @@ -1041,7 +1045,7 @@ static void UpdateTextureAddressMode(D3D_RenderData *data, SDL_TextureAddressMod } } -static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, D3D9_Shader *shader, const float **shader_params) +static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, SDL_ScaleMode scale_mode, D3D9_Shader *shader, const float **shader_params) { D3D_TextureData *texturedata = (D3D_TextureData *)texture->internal; @@ -1049,7 +1053,15 @@ static bool SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, D3D9_S return SDL_SetError("Texture is not currently available"); } - *shader = texturedata->shader; + if (texture->format == SDL_PIXELFORMAT_INDEX8) { + if (scale_mode == SDL_SCALEMODE_LINEAR) { + *shader = SHADER_PALETTE_LINEAR; + } else { + *shader = SHADER_PALETTE_NEAREST; + } + } else if (texturedata->yuv) { + *shader = SHADER_YUV; + } *shader_params = texturedata->shader_params; if (!BindTextureRep(data->device, &texturedata->texture, 0)) { @@ -1099,11 +1111,10 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) IDirect3DDevice9_SetTexture(data->device, 2, NULL); } #endif - if (texture && !SetupTextureState(data, texture, &shader, &shader_params)) { + if (texture && !SetupTextureState(data, texture, cmd->data.draw.texture_scale_mode, &shader, &shader_params)) { return false; } -#ifdef SDL_HAVE_YUV if (shader != data->drawstate.shader) { const HRESULT result = IDirect3DDevice9_SetPixelShader(data->device, data->shaders[shader]); if (FAILED(result)) { @@ -1122,7 +1133,6 @@ static bool SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) } data->drawstate.shader_params = shader_params; } -#endif // SDL_HAVE_YUV data->drawstate.texture = texture; } else if (texture) { @@ -1877,7 +1887,9 @@ static bool D3D_CreateRenderer(SDL_Renderer *renderer, SDL_Window *window, SDL_P D3D_SetError("CreatePixelShader()", result); } } - if (caps.MaxSimultaneousTextures >= 2 && data->shaders[SHADER_PALETTE]) { + if (caps.MaxSimultaneousTextures >= 2 && + data->shaders[SHADER_PALETTE_NEAREST] && + data->shaders[SHADER_PALETTE_LINEAR]) { SDL_AddSupportedTextureFormat(renderer, SDL_PIXELFORMAT_INDEX8); } #ifdef SDL_HAVE_YUV diff --git a/src/render/direct3d/SDL_shaders_d3d.c b/src/render/direct3d/SDL_shaders_d3d.c index ffbf4df915..d9b1a27f25 100644 --- a/src/render/direct3d/SDL_shaders_d3d.c +++ b/src/render/direct3d/SDL_shaders_d3d.c @@ -30,8 +30,12 @@ // The shaders here were compiled with compile_shaders.bat -#define g_ps20_main D3D9_PixelShader_Palette -#include "D3D9_PixelShader_Palette.h" +#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 @@ -40,7 +44,8 @@ static const BYTE *D3D9_shaders[] = { NULL, - D3D9_PixelShader_Palette, + D3D9_PixelShader_Palette_Nearest, + D3D9_PixelShader_Palette_Linear, D3D9_PixelShader_YUV }; SDL_COMPILE_TIME_ASSERT(D3D9_shaders, SDL_arraysize(D3D9_shaders) == NUM_SHADERS); diff --git a/src/render/direct3d/SDL_shaders_d3d.h b/src/render/direct3d/SDL_shaders_d3d.h index 491b24a5d1..a0b32a964b 100644 --- a/src/render/direct3d/SDL_shaders_d3d.h +++ b/src/render/direct3d/SDL_shaders_d3d.h @@ -25,7 +25,8 @@ typedef enum { SHADER_NONE, - SHADER_PALETTE, + SHADER_PALETTE_NEAREST, + SHADER_PALETTE_LINEAR, SHADER_YUV, NUM_SHADERS } D3D9_Shader; diff --git a/src/render/direct3d/compile_shaders.bat b/src/render/direct3d/compile_shaders.bat index c8b8e183a3..fb37536753 100644 --- a/src/render/direct3d/compile_shaders.bat +++ b/src/render/direct3d/compile_shaders.bat @@ -1,2 +1,3 @@ -fxc /T ps_2_0 /Fh D3D9_PixelShader_Palette.h D3D9_PixelShader_Palette.hlsl +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 diff --git a/src/render/direct3d11/D3D11_PixelShader_Advanced.h b/src/render/direct3d11/D3D11_PixelShader_Advanced.h index 1c9fb3ed73..1697e57d6e 100644 --- a/src/render/direct3d11/D3D11_PixelShader_Advanced.h +++ b/src/render/direct3d11/D3D11_PixelShader_Advanced.h @@ -64,7 +64,7 @@ dcl_resource_texture2d (float,float,float,float) t2 dcl_input_ps linear v1.xy dcl_input_ps linear v2.xyzw dcl_output o0.xyzw -dcl_temps 7 +dcl_temps 8 eq r0.xyzw, cb0[0].yzzz, l(0.000000, 3.000000, 2.000000, 1.000000) if_nz r0.x mov r1.xyzw, l(1.000000,1.000000,1.000000,1.000000) @@ -107,37 +107,123 @@ else else eq r0.x, cb0[0].y, l(4.000000) if_nz r0.x - sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.yz, v1.xyxx, t1.zxyw, s0 - add r2.xyz, r2.xyzx, cb0[3].xyzx - dp3 r1.x, r2.xyzx, cb0[4].xyzx - dp3 r1.y, r2.xyzx, cb0[5].xyzx - dp3 r1.z, r2.xyzx, cb0[6].xyzx + mad r2.xy, v1.xyxx, cb0[1].zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r3.xyzw, r2.xyxy + add r3.xyzw, r3.xyzw, l(-0.500000, -0.500000, 0.500000, 0.500000) + mul r3.xyzw, r3.xyzw, cb0[1].xyxy + frc r2.xy, r2.xyxx + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.xyxx, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r4.x, r0.x, l(0.003906) + mov r4.yw, l(0,0.500000,0,0.500000) + sample_indexable(texture2d)(float,float,float,float) r5.xyzw, r4.xyxx, t1.xyzw, s1 + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.xwxx, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r4.z, r0.x, l(0.003906) + sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r4.zwzz, t1.xyzw, s1 + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.zyzz, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r6.x, r0.x, l(0.003906) + mov r6.yw, l(0,0.500000,0,0.500000) + sample_indexable(texture2d)(float,float,float,float) r7.xyzw, r6.xyxx, t1.xyzw, s1 + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.zwzz, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r6.z, r0.x, l(0.003906) + sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r6.zwzz, t1.xyzw, s1 + add r4.xyzw, -r5.xyzw, r4.xyzw + mad r4.xyzw, r2.yyyy, r4.xyzw, r5.xyzw + add r3.xyzw, -r7.xyzw, r3.xyzw + mad r3.xyzw, r2.yyyy, r3.xyzw, r7.xyzw + add r3.xyzw, -r4.xyzw, r3.xyzw + mad r1.xyzw, r2.xxxx, r3.xyzw, r4.xyzw else eq r0.x, cb0[0].y, l(5.000000) if_nz r0.x - sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.yz, v1.xyxx, t1.zyxw, s0 - add r2.xyz, r2.xyzx, cb0[3].xyzx - dp3 r1.x, r2.xyzx, cb0[4].xyzx - dp3 r1.y, r2.xyzx, cb0[5].xyzx - dp3 r1.z, r2.xyzx, cb0[6].xyzx + deriv_rtx_coarse r2.xy, v1.xyxx + deriv_rty_coarse r2.zw, v1.xxxy + add r2.xy, |r2.zwzz|, |r2.xyxx| + mul r2.xy, r2.xyxx, cb0[1].zwzz + max r2.xy, r2.xyxx, l(0.000010, 0.000010, 0.000000, 0.000000) + min r2.xy, r2.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000) + mul r2.zw, r2.xxxy, l(0.000000, 0.000000, 0.500000, 0.500000) + mad r2.zw, v1.xxxy, cb0[1].zzzw, -r2.zzzw + add r2.xy, -r2.xyxx, l(1.000000, 1.000000, 0.000000, 0.000000) + frc r3.xy, r2.zwzz + add r3.zw, -r2.xxxy, l(0.000000, 0.000000, 1.000000, 1.000000) + add r2.xy, -r2.xyxx, r3.xyxx + div r3.xy, l(1.000000, 1.000000, 1.000000, 1.000000), r3.zwzz + mul_sat r2.xy, r2.xyxx, r3.xyxx + mad r3.xy, r2.xyxx, l(-2.000000, -2.000000, 0.000000, 0.000000), l(3.000000, 3.000000, 0.000000, 0.000000) + mul r2.xy, r2.xyxx, r2.xyxx + round_ni r2.zw, r2.zzzw + mad r2.xy, r3.xyxx, r2.xyxx, r2.zwzz + add r2.xy, r2.xyxx, l(0.500000, 0.500000, 0.000000, 0.000000) + mul r2.xy, r2.xyxx, cb0[1].xyxx + mad r2.xy, r2.xyxx, cb0[1].zwzz, l(0.500000, 0.500000, 0.000000, 0.000000) + round_ni r3.xyzw, r2.xyxy + add r3.xyzw, r3.xyzw, l(-0.500000, -0.500000, 0.500000, 0.500000) + mul r3.xyzw, r3.xyzw, cb0[1].xyxy + frc r2.xy, r2.xyxx + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.xyxx, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r4.x, r0.x, l(0.003906) + mov r4.yw, l(0,0.500000,0,0.500000) + sample_indexable(texture2d)(float,float,float,float) r5.xyzw, r4.xyxx, t1.xyzw, s1 + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.xwxx, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r4.z, r0.x, l(0.003906) + sample_indexable(texture2d)(float,float,float,float) r4.xyzw, r4.zwzz, t1.xyzw, s1 + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.zyzz, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r6.x, r0.x, l(0.003906) + mov r6.yw, l(0,0.500000,0,0.500000) + sample_indexable(texture2d)(float,float,float,float) r7.xyzw, r6.xyxx, t1.xyzw, s1 + sample_indexable(texture2d)(float,float,float,float) r0.x, r3.zwzz, t0.xyzw, s0 + mad r0.x, r0.x, l(255.000000), l(0.500000) + mul r6.z, r0.x, l(0.003906) + sample_indexable(texture2d)(float,float,float,float) r3.xyzw, r6.zwzz, t1.xyzw, s1 + add r4.xyzw, -r5.xyzw, r4.xyzw + mad r4.xyzw, r2.yyyy, r4.xyzw, r5.xyzw + add r3.xyzw, -r7.xyzw, r3.xyzw + mad r3.xyzw, r2.yyyy, r3.xyzw, r7.xyzw + add r3.xyzw, -r4.xyzw, r3.xyzw + mad r1.xyzw, r2.xxxx, r3.xyzw, r4.xyzw else eq r0.x, cb0[0].y, l(6.000000) if_nz r0.x sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.y, v1.xyxx, t1.yxzw, s0 - sample_indexable(texture2d)(float,float,float,float) r2.z, v1.xyxx, t2.yzxw, s0 + sample_indexable(texture2d)(float,float,float,float) r2.yz, v1.xyxx, t1.zxyw, s0 add r2.xyz, r2.xyzx, cb0[3].xyzx dp3 r1.x, r2.xyzx, cb0[4].xyzx dp3 r1.y, r2.xyzx, cb0[5].xyzx dp3 r1.z, r2.xyzx, cb0[6].xyzx else - mov r1.xyz, l(1.000000,0,0,0) + eq r0.x, cb0[0].y, l(7.000000) + if_nz r0.x + sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 + sample_indexable(texture2d)(float,float,float,float) r2.yz, v1.xyxx, t1.zyxw, s0 + add r2.xyz, r2.xyzx, cb0[3].xyzx + dp3 r1.x, r2.xyzx, cb0[4].xyzx + dp3 r1.y, r2.xyzx, cb0[5].xyzx + dp3 r1.z, r2.xyzx, cb0[6].xyzx + else + eq r0.x, cb0[0].y, l(8.000000) + if_nz r0.x + sample_indexable(texture2d)(float,float,float,float) r2.x, v1.xyxx, t0.xyzw, s0 + sample_indexable(texture2d)(float,float,float,float) r2.y, v1.xyxx, t1.yxzw, s0 + sample_indexable(texture2d)(float,float,float,float) r2.z, v1.xyxx, t2.yzxw, s0 + add r2.xyz, r2.xyzx, cb0[3].xyzx + dp3 r1.x, r2.xyzx, cb0[4].xyzx + dp3 r1.y, r2.xyzx, cb0[5].xyzx + dp3 r1.z, r2.xyzx, cb0[6].xyzx + else + mov r1.xyz, l(1.000000,0,1.000000,0) + endif + endif endif + mov r1.w, l(1.000000) endif endif - mov r1.w, l(1.000000) endif endif endif @@ -225,20 +311,20 @@ else endif mul o0.xyzw, r1.xyzw, v2.xyzw ret -// Approximately 160 instruction slots used +// Approximately 246 instruction slots used #endif const BYTE g_main[] = { - 68, 88, 66, 67, 189, 249, - 3, 160, 168, 14, 177, 240, - 224, 229, 45, 241, 216, 176, - 187, 190, 1, 0, 0, 0, - 172, 24, 0, 0, 5, 0, + 68, 88, 66, 67, 218, 34, + 85, 97, 34, 23, 186, 108, + 107, 10, 84, 63, 204, 132, + 47, 109, 1, 0, 0, 0, + 236, 35, 0, 0, 5, 0, 0, 0, 52, 0, 0, 0, 168, 4, 0, 0, 28, 5, 0, 0, 80, 5, 0, 0, - 16, 24, 0, 0, 82, 68, + 80, 35, 0, 0, 82, 68, 69, 70, 108, 4, 0, 0, 1, 0, 0, 0, 52, 1, 0, 0, 6, 0, 0, 0, @@ -457,8 +543,8 @@ const BYTE g_main[] = 15, 0, 0, 0, 83, 86, 95, 84, 65, 82, 71, 69, 84, 0, 171, 171, 83, 72, - 69, 88, 184, 18, 0, 0, - 80, 0, 0, 0, 174, 4, + 69, 88, 248, 29, 0, 0, + 80, 0, 0, 0, 126, 7, 0, 0, 106, 8, 0, 1, 89, 0, 0, 4, 70, 142, 32, 0, 0, 0, 0, 0, @@ -481,7 +567,7 @@ const BYTE g_main[] = 2, 0, 0, 0, 101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0, 0, 104, 0, - 0, 2, 7, 0, 0, 0, + 0, 2, 8, 0, 0, 0, 24, 0, 0, 11, 242, 0, 16, 0, 0, 0, 0, 0, 150, 138, 32, 0, 0, 0, @@ -690,150 +776,630 @@ const BYTE g_main[] = 0, 0, 1, 64, 0, 0, 0, 0, 128, 64, 31, 0, 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 69, 0, - 0, 139, 194, 0, 0, 128, - 67, 85, 21, 0, 18, 0, - 16, 0, 2, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 98, 0, 16, 0, 2, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 38, 125, - 16, 0, 1, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 16, 0, - 0, 8, 18, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 16, 0, 0, 8, 34, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 16, 0, 0, 8, - 66, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 18, 0, - 0, 1, 24, 0, 0, 8, - 18, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 160, 64, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 69, 0, - 0, 139, 194, 0, 0, 128, - 67, 85, 21, 0, 18, 0, - 16, 0, 2, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 98, 0, 16, 0, 2, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 102, 124, - 16, 0, 1, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 0, 0, 0, 8, - 114, 0, 16, 0, 2, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 16, 0, - 0, 8, 18, 0, 16, 0, - 1, 0, 0, 0, 70, 2, - 16, 0, 2, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 4, 0, 0, 0, - 16, 0, 0, 8, 34, 0, - 16, 0, 1, 0, 0, 0, - 70, 2, 16, 0, 2, 0, - 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 5, 0, - 0, 0, 16, 0, 0, 8, - 66, 0, 16, 0, 1, 0, - 0, 0, 70, 2, 16, 0, - 2, 0, 0, 0, 70, 130, - 32, 0, 0, 0, 0, 0, - 6, 0, 0, 0, 18, 0, - 0, 1, 24, 0, 0, 8, - 18, 0, 16, 0, 0, 0, - 0, 0, 26, 128, 32, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 1, 64, 0, 0, - 0, 0, 192, 64, 31, 0, - 4, 3, 10, 0, 16, 0, - 0, 0, 0, 0, 69, 0, - 0, 139, 194, 0, 0, 128, - 67, 85, 21, 0, 18, 0, - 16, 0, 2, 0, 0, 0, - 70, 16, 16, 0, 1, 0, - 0, 0, 70, 126, 16, 0, - 0, 0, 0, 0, 0, 96, - 16, 0, 0, 0, 0, 0, - 69, 0, 0, 139, 194, 0, - 0, 128, 67, 85, 21, 0, - 34, 0, 16, 0, 2, 0, - 0, 0, 70, 16, 16, 0, - 1, 0, 0, 0, 22, 126, - 16, 0, 1, 0, 0, 0, - 0, 96, 16, 0, 0, 0, - 0, 0, 69, 0, 0, 139, - 194, 0, 0, 128, 67, 85, - 21, 0, 66, 0, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 13, 50, 0, 16, 0, 2, 0, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, - 150, 124, 16, 0, 2, 0, - 0, 0, 0, 96, 16, 0, + 230, 138, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, 0, 0, 0, 0, 0, 0, - 0, 8, 114, 0, 16, 0, - 2, 0, 0, 0, 70, 2, + 0, 0, 65, 0, 0, 5, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 4, 16, 0, + 2, 0, 0, 0, 0, 0, + 0, 10, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 191, 0, 0, 0, 191, + 0, 0, 0, 63, 0, 0, + 0, 63, 56, 0, 0, 8, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 70, 132, + 32, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 26, 0, + 0, 5, 50, 0, 16, 0, + 2, 0, 0, 0, 70, 0, 16, 0, 2, 0, 0, 0, - 70, 130, 32, 0, 0, 0, - 0, 0, 3, 0, 0, 0, - 16, 0, 0, 8, 18, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 0, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 127, 67, + 1, 64, 0, 0, 0, 0, + 0, 63, 56, 0, 0, 7, + 18, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 59, + 54, 0, 0, 8, 162, 0, + 16, 0, 4, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 63, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 242, 0, 16, 0, + 5, 0, 0, 0, 70, 0, + 16, 0, 4, 0, 0, 0, + 70, 126, 16, 0, 1, 0, + 0, 0, 0, 96, 16, 0, + 1, 0, 0, 0, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 0, 0, 0, 0, + 198, 0, 16, 0, 3, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 127, 67, 1, 64, + 0, 0, 0, 0, 0, 63, + 56, 0, 0, 7, 66, 0, + 16, 0, 4, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 59, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 242, 0, + 16, 0, 4, 0, 0, 0, + 230, 10, 16, 0, 4, 0, + 0, 0, 70, 126, 16, 0, + 1, 0, 0, 0, 0, 96, 16, 0, 1, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 0, 0, + 0, 0, 102, 10, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 127, 67, + 1, 64, 0, 0, 0, 0, + 0, 63, 56, 0, 0, 7, + 18, 0, 16, 0, 6, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 59, + 54, 0, 0, 8, 162, 0, + 16, 0, 6, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 63, + 0, 0, 0, 0, 0, 0, + 0, 63, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 242, 0, 16, 0, + 7, 0, 0, 0, 70, 0, + 16, 0, 6, 0, 0, 0, + 70, 126, 16, 0, 1, 0, + 0, 0, 0, 96, 16, 0, + 1, 0, 0, 0, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 18, 0, + 16, 0, 0, 0, 0, 0, + 230, 10, 16, 0, 3, 0, + 0, 0, 70, 126, 16, 0, + 0, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 50, 0, 0, 9, 18, 0, + 16, 0, 0, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 127, 67, 1, 64, + 0, 0, 0, 0, 0, 63, + 56, 0, 0, 7, 66, 0, + 16, 0, 6, 0, 0, 0, + 10, 0, 16, 0, 0, 0, + 0, 0, 1, 64, 0, 0, + 0, 0, 128, 59, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 242, 0, + 16, 0, 3, 0, 0, 0, + 230, 10, 16, 0, 6, 0, + 0, 0, 70, 126, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 0, 0, 0, 8, 242, 0, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 128, 65, 0, + 0, 0, 5, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 50, 0, 0, 9, + 242, 0, 16, 0, 4, 0, + 0, 0, 86, 5, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 5, 0, + 0, 0, 0, 0, 0, 8, + 242, 0, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 128, + 65, 0, 0, 0, 7, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 50, 0, + 0, 9, 242, 0, 16, 0, + 3, 0, 0, 0, 86, 5, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 70, 14, 16, 0, + 7, 0, 0, 0, 0, 0, + 0, 8, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 128, 65, 0, 0, 0, + 4, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 9, 242, 0, + 16, 0, 1, 0, 0, 0, + 6, 0, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 4, 0, 0, 0, + 18, 0, 0, 1, 24, 0, + 0, 8, 18, 0, 16, 0, + 0, 0, 0, 0, 26, 128, + 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 160, 64, + 31, 0, 4, 3, 10, 0, + 16, 0, 0, 0, 0, 0, + 122, 0, 0, 5, 50, 0, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 124, 0, 0, 5, + 194, 0, 16, 0, 2, 0, + 0, 0, 6, 20, 16, 0, + 1, 0, 0, 0, 0, 0, + 0, 9, 50, 0, 16, 0, + 2, 0, 0, 0, 230, 10, + 16, 128, 129, 0, 0, 0, + 2, 0, 0, 0, 70, 0, + 16, 128, 129, 0, 0, 0, + 2, 0, 0, 0, 56, 0, + 0, 8, 50, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 2, 0, 0, 0, + 230, 138, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 52, 0, 0, 10, 50, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 172, 197, 39, 55, 172, 197, + 39, 55, 0, 0, 0, 0, + 0, 0, 0, 0, 51, 0, + 0, 10, 50, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 128, 63, 0, 0, 128, 63, + 0, 0, 0, 0, 0, 0, + 0, 0, 56, 0, 0, 10, + 194, 0, 16, 0, 2, 0, + 0, 0, 6, 4, 16, 0, + 2, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 63, + 50, 0, 0, 11, 194, 0, + 16, 0, 2, 0, 0, 0, + 6, 20, 16, 0, 1, 0, + 0, 0, 166, 142, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 166, 14, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 0, 0, 0, 11, + 50, 0, 16, 0, 2, 0, + 0, 0, 70, 0, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 26, 0, + 0, 5, 50, 0, 16, 0, + 3, 0, 0, 0, 230, 10, + 16, 0, 2, 0, 0, 0, + 0, 0, 0, 11, 194, 0, + 16, 0, 3, 0, 0, 0, + 6, 4, 16, 128, 65, 0, + 0, 0, 2, 0, 0, 0, + 2, 64, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 0, 8, + 50, 0, 16, 0, 2, 0, + 0, 0, 70, 0, 16, 128, + 65, 0, 0, 0, 2, 0, + 0, 0, 70, 0, 16, 0, + 3, 0, 0, 0, 14, 0, + 0, 10, 50, 0, 16, 0, + 3, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 128, 63, + 0, 0, 128, 63, 0, 0, + 128, 63, 0, 0, 128, 63, + 230, 10, 16, 0, 3, 0, + 0, 0, 56, 32, 0, 7, + 50, 0, 16, 0, 2, 0, + 0, 0, 70, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 15, 50, 0, + 16, 0, 3, 0, 0, 0, + 70, 0, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 192, 0, 0, + 0, 192, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 64, + 0, 0, 0, 0, 64, 64, + 0, 0, 64, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 56, 0, 0, 7, 50, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 2, 0, + 0, 0, 70, 0, 16, 0, + 2, 0, 0, 0, 65, 0, + 0, 5, 194, 0, 16, 0, + 2, 0, 0, 0, 166, 14, + 16, 0, 2, 0, 0, 0, + 50, 0, 0, 9, 50, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 3, 0, + 0, 0, 70, 0, 16, 0, + 2, 0, 0, 0, 230, 10, + 16, 0, 2, 0, 0, 0, + 0, 0, 0, 10, 50, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 2, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 56, 0, + 0, 8, 50, 0, 16, 0, + 2, 0, 0, 0, 70, 0, + 16, 0, 2, 0, 0, 0, + 70, 128, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 50, 0, 0, 13, 50, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 2, 0, + 0, 0, 230, 138, 32, 0, + 0, 0, 0, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 63, 0, 0, + 0, 63, 0, 0, 0, 0, + 0, 0, 0, 0, 65, 0, + 0, 5, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 4, + 16, 0, 2, 0, 0, 0, + 0, 0, 0, 10, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 191, 0, 0, + 0, 191, 0, 0, 0, 63, + 0, 0, 0, 63, 56, 0, + 0, 8, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 70, 132, 32, 0, 0, 0, + 0, 0, 1, 0, 0, 0, + 26, 0, 0, 5, 50, 0, + 16, 0, 2, 0, 0, 0, + 70, 0, 16, 0, 2, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 0, 0, 0, 0, 70, 0, + 16, 0, 3, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 127, 67, 1, 64, 0, 0, + 0, 0, 0, 63, 56, 0, + 0, 7, 18, 0, 16, 0, + 4, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 59, 54, 0, 0, 8, + 162, 0, 16, 0, 4, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 0, + 0, 0, 0, 63, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 242, 0, + 16, 0, 5, 0, 0, 0, + 70, 0, 16, 0, 4, 0, + 0, 0, 70, 126, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 0, 0, + 0, 0, 198, 0, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 127, 67, + 1, 64, 0, 0, 0, 0, + 0, 63, 56, 0, 0, 7, + 66, 0, 16, 0, 4, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 59, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 242, 0, 16, 0, 4, 0, + 0, 0, 230, 10, 16, 0, + 4, 0, 0, 0, 70, 126, + 16, 0, 1, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 0, 0, 0, 0, 102, 10, + 16, 0, 3, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 50, 0, + 0, 9, 18, 0, 16, 0, + 0, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 127, 67, 1, 64, 0, 0, + 0, 0, 0, 63, 56, 0, + 0, 7, 18, 0, 16, 0, + 6, 0, 0, 0, 10, 0, + 16, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 128, 59, 54, 0, 0, 8, + 162, 0, 16, 0, 6, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 63, 0, 0, 0, 0, + 0, 0, 0, 63, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 242, 0, + 16, 0, 7, 0, 0, 0, + 70, 0, 16, 0, 6, 0, + 0, 0, 70, 126, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 1, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 18, 0, 16, 0, 0, 0, + 0, 0, 230, 10, 16, 0, + 3, 0, 0, 0, 70, 126, + 16, 0, 0, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 50, 0, 0, 9, + 18, 0, 16, 0, 0, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 127, 67, + 1, 64, 0, 0, 0, 0, + 0, 63, 56, 0, 0, 7, + 66, 0, 16, 0, 6, 0, + 0, 0, 10, 0, 16, 0, + 0, 0, 0, 0, 1, 64, + 0, 0, 0, 0, 128, 59, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 242, 0, 16, 0, 3, 0, + 0, 0, 230, 10, 16, 0, + 6, 0, 0, 0, 70, 126, + 16, 0, 1, 0, 0, 0, + 0, 96, 16, 0, 1, 0, + 0, 0, 0, 0, 0, 8, + 242, 0, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 128, + 65, 0, 0, 0, 5, 0, + 0, 0, 70, 14, 16, 0, + 4, 0, 0, 0, 50, 0, + 0, 9, 242, 0, 16, 0, + 4, 0, 0, 0, 86, 5, + 16, 0, 2, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 70, 14, 16, 0, + 5, 0, 0, 0, 0, 0, + 0, 8, 242, 0, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 128, 65, 0, 0, 0, + 7, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 50, 0, 0, 9, 242, 0, + 16, 0, 3, 0, 0, 0, + 86, 5, 16, 0, 2, 0, + 0, 0, 70, 14, 16, 0, + 3, 0, 0, 0, 70, 14, + 16, 0, 7, 0, 0, 0, + 0, 0, 0, 8, 242, 0, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 128, 65, 0, + 0, 0, 4, 0, 0, 0, + 70, 14, 16, 0, 3, 0, + 0, 0, 50, 0, 0, 9, + 242, 0, 16, 0, 1, 0, + 0, 0, 6, 0, 16, 0, + 2, 0, 0, 0, 70, 14, + 16, 0, 3, 0, 0, 0, + 70, 14, 16, 0, 4, 0, + 0, 0, 18, 0, 0, 1, + 24, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 192, 64, 31, 0, 4, 3, + 10, 0, 16, 0, 0, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 98, 0, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 38, 125, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 114, 0, + 16, 0, 2, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0, 70, 130, 32, 0, - 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 3, 0, 0, 0, 16, 0, 0, 8, - 34, 0, 16, 0, 1, 0, + 18, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0, 70, 130, 32, 0, 0, 0, 0, 0, - 5, 0, 0, 0, 16, 0, - 0, 8, 66, 0, 16, 0, + 4, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, 1, 0, 0, 0, 70, 2, 16, 0, 2, 0, 0, 0, 70, 130, 32, 0, 0, 0, - 0, 0, 6, 0, 0, 0, - 18, 0, 0, 1, 54, 0, - 0, 8, 114, 0, 16, 0, - 1, 0, 0, 0, 2, 64, + 0, 0, 5, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 18, 0, 0, 1, + 24, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 224, 64, 31, 0, 4, 3, + 10, 0, 16, 0, 0, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 98, 0, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 102, 124, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 0, 0, 0, 8, 114, 0, + 16, 0, 2, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 3, 0, + 0, 0, 16, 0, 0, 8, + 18, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 4, 0, 0, 0, 16, 0, + 0, 8, 34, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 5, 0, 0, 0, + 16, 0, 0, 8, 66, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 6, 0, + 0, 0, 18, 0, 0, 1, + 24, 0, 0, 8, 18, 0, + 16, 0, 0, 0, 0, 0, + 26, 128, 32, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 64, 0, 0, 0, 0, + 0, 65, 31, 0, 4, 3, + 10, 0, 16, 0, 0, 0, + 0, 0, 69, 0, 0, 139, + 194, 0, 0, 128, 67, 85, + 21, 0, 18, 0, 16, 0, + 2, 0, 0, 0, 70, 16, + 16, 0, 1, 0, 0, 0, + 70, 126, 16, 0, 0, 0, + 0, 0, 0, 96, 16, 0, + 0, 0, 0, 0, 69, 0, + 0, 139, 194, 0, 0, 128, + 67, 85, 21, 0, 34, 0, + 16, 0, 2, 0, 0, 0, + 70, 16, 16, 0, 1, 0, + 0, 0, 22, 126, 16, 0, + 1, 0, 0, 0, 0, 96, + 16, 0, 0, 0, 0, 0, + 69, 0, 0, 139, 194, 0, + 0, 128, 67, 85, 21, 0, + 66, 0, 16, 0, 2, 0, + 0, 0, 70, 16, 16, 0, + 1, 0, 0, 0, 150, 124, + 16, 0, 2, 0, 0, 0, + 0, 96, 16, 0, 0, 0, + 0, 0, 0, 0, 0, 8, + 114, 0, 16, 0, 2, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 3, 0, 0, 0, 16, 0, + 0, 8, 18, 0, 16, 0, + 1, 0, 0, 0, 70, 2, + 16, 0, 2, 0, 0, 0, + 70, 130, 32, 0, 0, 0, + 0, 0, 4, 0, 0, 0, + 16, 0, 0, 8, 34, 0, + 16, 0, 1, 0, 0, 0, + 70, 2, 16, 0, 2, 0, + 0, 0, 70, 130, 32, 0, + 0, 0, 0, 0, 5, 0, + 0, 0, 16, 0, 0, 8, + 66, 0, 16, 0, 1, 0, + 0, 0, 70, 2, 16, 0, + 2, 0, 0, 0, 70, 130, + 32, 0, 0, 0, 0, 0, + 6, 0, 0, 0, 18, 0, + 0, 1, 54, 0, 0, 8, + 114, 0, 16, 0, 1, 0, + 0, 0, 2, 64, 0, 0, + 0, 0, 128, 63, 0, 0, + 0, 0, 0, 0, 128, 63, + 0, 0, 0, 0, 21, 0, + 0, 1, 21, 0, 0, 1, + 21, 0, 0, 1, 54, 0, + 0, 5, 130, 0, 16, 0, + 1, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 21, 0, 0, 1, 21, 0, 0, 1, 21, 0, 0, 1, - 54, 0, 0, 5, 130, 0, - 16, 0, 1, 0, 0, 0, - 1, 64, 0, 0, 0, 0, - 128, 63, 21, 0, 0, 1, 21, 0, 0, 1, 21, 0, 0, 1, 21, 0, 0, 1, 47, 0, 0, 6, 114, 0, @@ -1258,21 +1824,21 @@ const BYTE g_main[] = 16, 0, 2, 0, 0, 0, 62, 0, 0, 1, 83, 84, 65, 84, 148, 0, 0, 0, - 160, 0, 0, 0, 7, 0, + 246, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, - 3, 0, 0, 0, 95, 0, + 3, 0, 0, 0, 155, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 11, 0, - 0, 0, 13, 0, 0, 0, + 0, 0, 0, 0, 13, 0, + 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 26, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, + 1, 0, 0, 0, 8, 0, 0, 0, 10, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, - 1, 0, 0, 0, 4, 0, - 0, 0, 10, 0, 0, 0, - 5, 0, 0, 0, 0, 0, + 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, diff --git a/src/render/direct3d11/D3D11_PixelShader_Common.hlsli b/src/render/direct3d11/D3D11_PixelShader_Common.hlsli index c176005a15..4a4cedd06b 100644 --- a/src/render/direct3d11/D3D11_PixelShader_Common.hlsli +++ b/src/render/direct3d11/D3D11_PixelShader_Common.hlsli @@ -20,10 +20,12 @@ static const float TONEMAP_CHROME = 2; static const float TEXTURETYPE_NONE = 0; static const float TEXTURETYPE_RGB = 1; static const float TEXTURETYPE_RGB_PIXELART = 2; -static const float TEXTURETYPE_PALETTE = 3; -static const float TEXTURETYPE_NV12 = 4; -static const float TEXTURETYPE_NV21 = 5; -static const float TEXTURETYPE_YUV = 6; +static const float TEXTURETYPE_PALETTE_NEAREST = 3; +static const float TEXTURETYPE_PALETTE_LINEAR = 4; +static const float TEXTURETYPE_PALETTE_PIXELART = 5; +static const float TEXTURETYPE_NV12 = 6; +static const float TEXTURETYPE_NV21 = 7; +static const float TEXTURETYPE_YUV = 8; static const float INPUTTYPE_UNSPECIFIED = 0; static const float INPUTTYPE_SRGB = 1; @@ -118,21 +120,48 @@ float3 ApplyTonemap(float3 v) return v; } -float2 GetPixelArtUV(PixelShaderInput input) +float4 SamplePaletteNearest(float2 uv) +{ + float index = texture0.Sample(sampler0, uv).r * 255; + return texture1.Sample(sampler1, float2((index + 0.5) / 256, 0.5)); +} + +// 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); +} + +float2 GetPixelArtUV(float2 uv) { // box filter size in texel units - float2 boxSize = clamp(fwidth(input.tex) * texel_size.zw, 1e-5, 1); + float2 boxSize = clamp(fwidth(uv) * texel_size.zw, 1e-5, 1); // scale uv by texture size to get texel coordinate - float2 tx = input.tex * texel_size.zw - 0.5 * boxSize; + float2 tx = uv * texel_size.zw - 0.5 * boxSize; // compute offset for pixel-sized box filter float2 txOffset = smoothstep(1 - boxSize, 1, frac(tx)); // compute bilinear sample uv coordinates - float2 uv = (floor(tx) + 0.5 + txOffset) * texel_size.xy; - - return uv; + return (floor(tx) + 0.5 + txOffset) * texel_size.xy; } float4 GetInputColor(PixelShaderInput input) @@ -144,11 +173,15 @@ float4 GetInputColor(PixelShaderInput input) } else if (texture_type == TEXTURETYPE_RGB) { rgba = texture0.Sample(sampler0, input.tex); } else if (texture_type == TEXTURETYPE_RGB_PIXELART) { - float2 uv = GetPixelArtUV(input); + float2 uv = GetPixelArtUV(input.tex); rgba = texture0.SampleGrad(sampler0, uv, ddx(input.tex), ddy(input.tex)); - } else if (texture_type == TEXTURETYPE_PALETTE) { - float index = texture0.Sample(sampler0, input.tex).r * 255; - rgba = texture1.Sample(sampler1, float2((index + 0.5) / 256, 0.5)); + } else if (texture_type == TEXTURETYPE_PALETTE_NEAREST) { + rgba = SamplePaletteNearest(input.tex); + } else if (texture_type == TEXTURETYPE_PALETTE_LINEAR) { + rgba = SamplePaletteLinear(input.tex); + } else if (texture_type == TEXTURETYPE_PALETTE_PIXELART) { + float2 uv = GetPixelArtUV(input.tex); + rgba = SamplePaletteLinear(uv); } else if (texture_type == TEXTURETYPE_NV12) { float3 yuv; yuv.x = texture0.Sample(sampler0, input.tex).r; @@ -184,7 +217,7 @@ float4 GetInputColor(PixelShaderInput input) // Error! rgba.r = 1.0; rgba.g = 0.0; - rgba.b = 0.0; + rgba.b = 1.0; rgba.a = 1.0; } return rgba; diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index 2fe7cd8658..83c4746c62 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -69,10 +69,12 @@ static const float TONEMAP_CHROME = 2; //static const float TEXTURETYPE_NONE = 0; static const float TEXTURETYPE_RGB = 1; static const float TEXTURETYPE_RGB_PIXELART = 2; -static const float TEXTURETYPE_PALETTE = 3; -static const float TEXTURETYPE_NV12 = 4; -static const float TEXTURETYPE_NV21 = 5; -static const float TEXTURETYPE_YUV = 6; +static const float TEXTURETYPE_PALETTE_NEAREST = 3; +static const float TEXTURETYPE_PALETTE_LINEAR = 4; +static const float TEXTURETYPE_PALETTE_PIXELART = 5; +static const float TEXTURETYPE_NV12 = 6; +static const float TEXTURETYPE_NV21 = 7; +static const float TEXTURETYPE_YUV = 8; static const float INPUTTYPE_UNSPECIFIED = 0; static const float INPUTTYPE_SRGB = 1; @@ -2189,8 +2191,20 @@ static void D3D11_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderC switch (texture->format) { case SDL_PIXELFORMAT_INDEX8: - constants->texture_type = TEXTURETYPE_PALETTE; - constants->input_type = INPUTTYPE_UNSPECIFIED; + switch (cmd->data.draw.texture_scale_mode) { + case SDL_SCALEMODE_NEAREST: + constants->texture_type = TEXTURETYPE_PALETTE_NEAREST; + break; + case SDL_SCALEMODE_LINEAR: + constants->texture_type = TEXTURETYPE_PALETTE_LINEAR; + break; + case SDL_SCALEMODE_PIXELART: + constants->texture_type = TEXTURETYPE_PALETTE_PIXELART; + break; + default: + SDL_assert(!"Unknown scale mode"); + break; + } break; case SDL_PIXELFORMAT_YV12: case SDL_PIXELFORMAT_IYUV: @@ -2212,10 +2226,6 @@ static void D3D11_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderC default: if (cmd->data.draw.texture_scale_mode == SDL_SCALEMODE_PIXELART) { constants->texture_type = TEXTURETYPE_RGB_PIXELART; - constants->texture_width = texture->w; - constants->texture_height = texture->h; - constants->texel_width = 1.0f / constants->texture_width; - constants->texel_height = 1.0f / constants->texture_height; } else { constants->texture_type = TEXTURETYPE_RGB; } @@ -2230,6 +2240,15 @@ static void D3D11_SetupShaderConstants(SDL_Renderer *renderer, const SDL_RenderC break; } + if (constants->texture_type == TEXTURETYPE_PALETTE_LINEAR || + constants->texture_type == TEXTURETYPE_PALETTE_PIXELART || + constants->texture_type == TEXTURETYPE_RGB_PIXELART) { + constants->texture_width = texture->w; + constants->texture_height = texture->h; + constants->texel_width = 1.0f / constants->texture_width; + constants->texel_height = 1.0f / constants->texture_height; + } + constants->sdr_white_point = texture->SDR_white_point; if (renderer->target) { @@ -2429,7 +2448,7 @@ static bool D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand * return true; } -static ID3D11SamplerState *D3D11_GetSamplerState(D3D11_RenderData *data, SDL_ScaleMode scale_mode, SDL_TextureAddressMode address_u, SDL_TextureAddressMode address_v) +static ID3D11SamplerState *D3D11_GetSamplerState(D3D11_RenderData *data, SDL_PixelFormat format, SDL_ScaleMode scale_mode, SDL_TextureAddressMode address_u, SDL_TextureAddressMode address_v) { Uint32 key = RENDER_SAMPLER_HASHKEY(scale_mode, address_u, address_v); SDL_assert(key < SDL_arraysize(data->samplers)); @@ -2448,7 +2467,12 @@ static ID3D11SamplerState *D3D11_GetSamplerState(D3D11_RenderData *data, SDL_Sca break; case SDL_SCALEMODE_PIXELART: // Uses linear sampling case SDL_SCALEMODE_LINEAR: - samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + if (format == SDL_PIXELFORMAT_INDEX8) { + // We'll do linear sampling in the shader + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT; + } else { + samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; + } break; default: SDL_SetError("Unknown scale mode: %d", scale_mode); @@ -2506,7 +2530,7 @@ static bool D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand * shaderResources[numShaderResources++] = textureData->mainTextureResourceView; - shaderSamplers[numShaderSamplers] = D3D11_GetSamplerState(rendererData, cmd->data.draw.texture_scale_mode, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v); + shaderSamplers[numShaderSamplers] = D3D11_GetSamplerState(rendererData, texture->format, cmd->data.draw.texture_scale_mode, cmd->data.draw.texture_address_mode_u, cmd->data.draw.texture_address_mode_v); if (!shaderSamplers[numShaderSamplers]) { return false; } @@ -2517,7 +2541,7 @@ static bool D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand * shaderResources[numShaderResources++] = palette->resourceView; - shaderSamplers[numShaderSamplers] = D3D11_GetSamplerState(rendererData, SDL_SCALEMODE_NEAREST, SDL_TEXTURE_ADDRESS_CLAMP, SDL_TEXTURE_ADDRESS_CLAMP); + shaderSamplers[numShaderSamplers] = D3D11_GetSamplerState(rendererData, SDL_PIXELFORMAT_UNKNOWN, SDL_SCALEMODE_NEAREST, SDL_TEXTURE_ADDRESS_CLAMP, SDL_TEXTURE_ADDRESS_CLAMP); if (!shaderSamplers[numShaderSamplers]) { return false; } diff --git a/src/render/direct3d12/D3D12_PixelShader_Advanced.h b/src/render/direct3d12/D3D12_PixelShader_Advanced.h index d164762f6c..812a3a5d65 100644 --- a/src/render/direct3d12/D3D12_PixelShader_Advanced.h +++ b/src/render/direct3d12/D3D12_PixelShader_Advanced.h @@ -15,7 +15,7 @@ ; -------------------- ----- ------ -------- -------- ------- ------ ; SV_Target 0 xyzw 0 TARGET float xyzw ; -; shader hash: 81f4ac5bde7e0dc4ae064cb53cb6b6f1 +; shader hash: f246f76536638c165bb49487d071f8f4 ; ; Pipeline Runtime Information: ; @@ -114,7 +114,7 @@ define void @main() { %13 = call %dx.types.CBufRet.f32 @dx.op.cbufferLoadLegacy.f32(i32 59, %dx.types.Handle %6, i32 0) ; CBufferLoadLegacy(handle,regIndex) %14 = extractvalue %dx.types.CBufRet.f32 %13, 1 %15 = fcmp fast oeq float %14, 0.000000e+00 - br i1 %15, label %188, label %16 + br i1 %15, label %428, label %16 ;