diff options
| author | donkopunchstania <donkopunchstania@gmail.com> | 2009-12-02 04:17:18 +0000 |
|---|---|---|
| committer | donkopunchstania <donkopunchstania@gmail.com> | 2009-12-02 04:17:18 +0000 |
| commit | e6d51e8ff41e5b3c0718a44f85d7c880a86e144f (patch) | |
| tree | 852e413eab05e5aae54eed0a5357c7d098b02166 /Source/Core/VideoCommon/Src/TextureConversionShader.cpp | |
| parent | 6e56ea80f7a3ea2cfe8d9a531542e3e05d2376b3 (diff) | |
Fixed 24 bit depth copies to RAM. 24 and 16 bit depth copies are now more accurate. Added an offset to DX copies to RAM and made half sized copies to a texture linearly filtered.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4635 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/VideoCommon/Src/TextureConversionShader.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Src/TextureConversionShader.cpp | 76 |
1 files changed, 60 insertions, 16 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index c38504c829..4db14bdeaa 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -611,19 +611,32 @@ void WriteZ16Encoder(char* p,bool HLSL) { WriteSwizzler(p, GX_TF_Z16,HLSL); - WRITE(p, " float depth;\n"); + WRITE(p, " float depth;\n"); + WRITE(p, " float3 expanded;\n"); // byte order is reversed WriteSampleColor(p, "b", "depth",HLSL); - WRITE(p, " ocol0.b = frac(depth * 256.0f);\n"); - WRITE(p, " ocol0.g = depth;\n"); + + WRITE(p, " depth *= 16777215.0f;\n"); + WRITE(p, " expanded.r = floor(depth / (256 * 256));\n"); + WRITE(p, " depth -= expanded.r * 256 * 256;\n"); + WRITE(p, " expanded.g = floor(depth / 256);\n"); + + WRITE(p, " ocol0.b = expanded.g / 255;\n"); + WRITE(p, " ocol0.g = expanded.r / 255;\n"); WriteIncrementSampleX(p,HLSL); WriteSampleColor(p, "b", "depth",HLSL); - WRITE(p, " ocol0.r = frac(depth * 256.0f);\n"); - WRITE(p, " ocol0.a = depth;\n"); + + WRITE(p, " depth *= 16777215.0f;\n"); + WRITE(p, " expanded.r = floor(depth / (256 * 256));\n"); + WRITE(p, " depth -= expanded.r * 256 * 256;\n"); + WRITE(p, " expanded.g = floor(depth / 256);\n"); + + WRITE(p, " ocol0.r = expanded.g / 255;\n"); + WRITE(p, " ocol0.a = expanded.r / 255;\n"); WriteEncoderEnd(p); } @@ -632,19 +645,36 @@ void WriteZ16LEncoder(char* p,bool HLSL) { WriteSwizzler(p, GX_CTF_Z16L,HLSL); - WRITE(p, " float depth;\n"); + WRITE(p, " float depth;\n"); + WRITE(p, " float3 expanded;\n"); // byte order is reversed WriteSampleColor(p, "b", "depth",HLSL); - WRITE(p, " ocol0.b = frac(depth * 65536.0f);\n"); - WRITE(p, " ocol0.g = frac(depth * 256.0f);\n"); + + WRITE(p, " depth *= 16777215.0f;\n"); + WRITE(p, " expanded.r = floor(depth / (256 * 256));\n"); + WRITE(p, " depth -= expanded.r * 256 * 256;\n"); + WRITE(p, " expanded.g = floor(depth / 256);\n"); + WRITE(p, " depth -= expanded.g * 256;\n"); + WRITE(p, " expanded.b = depth;\n"); + + WRITE(p, " ocol0.b = expanded.b / 255;\n"); + WRITE(p, " ocol0.g = expanded.g / 255;\n"); WriteIncrementSampleX(p,HLSL); WriteSampleColor(p, "b", "depth",HLSL); - WRITE(p, " ocol0.r = frac(depth * 65536.0f);\n"); - WRITE(p, " ocol0.a = frac(depth * 256.0f);\n"); + + WRITE(p, " depth *= 16777215.0f;\n"); + WRITE(p, " expanded.r = floor(depth / (256 * 256));\n"); + WRITE(p, " depth -= expanded.r * 256 * 256;\n"); + WRITE(p, " expanded.g = floor(depth / 256);\n"); + WRITE(p, " depth -= expanded.g * 256;\n"); + WRITE(p, " expanded.b = depth;\n"); + + WRITE(p, " ocol0.r = expanded.b;\n"); + WRITE(p, " ocol0.a = expanded.g;\n"); WriteEncoderEnd(p); } @@ -657,24 +687,38 @@ void WriteZ24Encoder(char* p, bool HLSL) WRITE(p, " float depth0;\n"); WRITE(p, " float depth1;\n"); + WRITE(p, " float3 expanded0;\n"); + WRITE(p, " float3 expanded1;\n"); WriteSampleColor(p, "b", "depth0",HLSL); WriteIncrementSampleX(p,HLSL); WriteSampleColor(p, "b", "depth1",HLSL); + for (int i = 0; i < 2; i++) + { + WRITE(p, " depth%i *= 16777215.0f;\n", i); + + WRITE(p, " expanded%i.r = floor(depth%i / (256 * 256));\n", i, i); + WRITE(p, " depth%i -= expanded%i.r * 256 * 256;\n", i, i); + WRITE(p, " expanded%i.g = floor(depth%i / 256);\n", i, i); + WRITE(p, " depth%i -= expanded%i.g * 256;\n", i, i); + WRITE(p, " expanded%i.b = depth%i;\n", i, i); + } + WRITE(p, " if(cl > 0.5f) {\n"); // upper 16 - WRITE(p, " ocol0.b = frac(depth0 * 256.0f);\n"); - WRITE(p, " ocol0.g = depth0;\n"); - WRITE(p, " ocol0.r = frac(depth1 * 256.0f);\n"); - WRITE(p, " ocol0.a = depth1;\n"); + WRITE(p, " ocol0.b = expanded0.g / 255;\n"); + WRITE(p, " ocol0.g = expanded0.b / 255;\n"); + WRITE(p, " ocol0.r = expanded1.g / 255;\n"); + WRITE(p, " ocol0.a = expanded1.b / 255;\n"); WRITE(p, " } else {\n"); // lower 8 WRITE(p, " ocol0.b = 1.0f;\n"); - WRITE(p, " ocol0.g = frac(depth0 * 65536.0f);\n"); + WRITE(p, " ocol0.g = expanded0.r / 255;\n"); WRITE(p, " ocol0.r = 1.0f;\n"); - WRITE(p, " ocol0.a = frac(depth0 * 65536.0f);\n"); + WRITE(p, " ocol0.a = expanded1.r / 255;\n"); WRITE(p, " }\n"); + WriteEncoderEnd(p); } |
