summaryrefslogtreecommitdiff
path: root/Source/Core/VideoBackends/OGL/TextureCache.cpp
diff options
context:
space:
mode:
authorMarkus Wick <markus+github@selfnet.de>2015-05-05 17:21:20 +0200
committerMarkus Wick <markus+github@selfnet.de>2015-05-05 17:21:20 +0200
commit430e8b7adeb5b3adb12ef50ce7961562463b0fa0 (patch)
tree286107b1594d1b96d5922e25f01aa02e32a19782 /Source/Core/VideoBackends/OGL/TextureCache.cpp
parent1d351ba20e5645beca5ccbfdd55aa98f454438a0 (diff)
parent7a1252f7e51edcfd1f3505129d1f9aa68c5852c8 (diff)
Merge pull request #2365 from Armada651/int-depth
VideoBackends: Implement depth copy shaders with integer math.
Diffstat (limited to 'Source/Core/VideoBackends/OGL/TextureCache.cpp')
-rw-r--r--Source/Core/VideoBackends/OGL/TextureCache.cpp28
1 files changed, 10 insertions, 18 deletions
diff --git a/Source/Core/VideoBackends/OGL/TextureCache.cpp b/Source/Core/VideoBackends/OGL/TextureCache.cpp
index 1054e75594..abc1a73ba9 100644
--- a/Source/Core/VideoBackends/OGL/TextureCache.cpp
+++ b/Source/Core/VideoBackends/OGL/TextureCache.cpp
@@ -294,27 +294,19 @@ void TextureCache::CompileShaders()
"\n"
"void main(){\n"
" vec4 texcol = texture(samp9, vec3(f_uv0.xy, %s));\n"
+ " int depth = int(round(texcol.x * float(0xFFFFFF)));\n"
- // 255.99998474121 = 16777215/16777216*256
- " float workspace = texcol.x * 255.99998474121;\n"
+ // Convert to Z24 format
+ " ivec4 workspace;\n"
+ " workspace.r = (depth >> 16) & 255;\n"
+ " workspace.g = (depth >> 8) & 255;\n"
+ " workspace.b = depth & 255;\n"
- " texcol.x = floor(workspace);\n" // x component
+ // Convert to Z4 format
+ " workspace.a = (depth >> 16) & 0xF0;\n"
- " workspace = workspace - texcol.x;\n" // subtract x component out
- " workspace = workspace * 256.0;\n" // shift left 8 bits
- " texcol.y = floor(workspace);\n" // y component
-
- " workspace = workspace - texcol.y;\n" // subtract y component out
- " workspace = workspace * 256.0;\n" // shift left 8 bits
- " texcol.z = floor(workspace);\n" // z component
-
- " texcol.w = texcol.x;\n" // duplicate x into w
-
- " texcol = texcol / 255.0;\n" // normalize components to [0.0..1.0]
-
- " texcol.w = texcol.w * 15.0;\n"
- " texcol.w = floor(texcol.w);\n"
- " texcol.w = texcol.w / 15.0;\n" // w component
+ // Normalize components to [0.0..1.0]
+ " texcol = vec4(workspace) / 255.0;\n"
" ocol0 = texcol * mat4(colmat[0], colmat[1], colmat[2], colmat[3]) + colmat[4];\n"
"}\n";