Permalink
Browse files

Trivial shader simplification, improves float accuracy a little.

  • Loading branch information...
gimhael committed Mar 27, 2016
1 parent 6f5069b commit 2e0e9f6544fd4b493842678f790c1c4700d8852f
Showing with 74 additions and 78 deletions.
  1. +70 −74 daemon/src/engine/renderer/shaders.cpp
  2. +4 −4 main/glsl/depthtile1_fp.glsl
@@ -2276,84 +2276,80 @@ const char depthtile1_fp[] = {
0x68, 0x54, 0x6f, 0x5a, 0x28, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x33,
0x5d, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x20, 0x6d, 0x69, 0x6e, 0x44, 0x65, 0x70, 0x74, 0x68, 0x20,
0x3d, 0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x20, 0x2d, 0x20,
0x6d, 0x61, 0x78, 0x31, 0x36, 0x28, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b,
0x30, 0x5d, 0x20, 0x2a, 0x20, 0x28, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e,
0x30, 0x20, 0x2d, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x30, 0x5d,
0x29, 0x2c, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x31, 0x5d, 0x20, 0x2a, 0x20, 0x28,
0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x64, 0x65,
0x70, 0x74, 0x68, 0x5b, 0x31, 0x5d, 0x29, 0x2c, 0x0a, 0x09, 0x09, 0x09,
0x3d, 0x20, 0x2d, 0x20, 0x6d, 0x61, 0x78, 0x31, 0x36, 0x28, 0x20, 0x6d,
0x61, 0x73, 0x6b, 0x5b, 0x30, 0x5d, 0x20, 0x2a, 0x20, 0x28, 0x2d, 0x64,
0x65, 0x70, 0x74, 0x68, 0x5b, 0x30, 0x5d, 0x29, 0x2c, 0x0a, 0x09, 0x09,
0x09, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b,
0x32, 0x5d, 0x20, 0x2a, 0x20, 0x28, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e,
0x30, 0x20, 0x2d, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x32, 0x5d,
0x29, 0x2c, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x20, 0x20, 0x20, 0x20, 0x20,
0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x33, 0x5d, 0x20, 0x2a, 0x20, 0x28,
0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x20, 0x2d, 0x20, 0x64, 0x65,
0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d, 0x29, 0x20, 0x29, 0x3b, 0x0a, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x30, 0x5d,
0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x30, 0x5d, 0x3b,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x31,
0x5d, 0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x31, 0x5d,
0x31, 0x5d, 0x20, 0x2a, 0x20, 0x28, 0x2d, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x31, 0x5d, 0x29, 0x2c, 0x0a, 0x09, 0x09, 0x09, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x32, 0x5d, 0x20, 0x2a,
0x20, 0x28, 0x2d, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x32, 0x5d, 0x29,
0x2c, 0x0a, 0x09, 0x09, 0x09, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x6d,
0x61, 0x73, 0x6b, 0x5b, 0x33, 0x5d, 0x20, 0x2a, 0x20, 0x28, 0x2d, 0x64,
0x65, 0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d, 0x29, 0x20, 0x29, 0x3b, 0x0a,
0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x30,
0x5d, 0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x30, 0x5d,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x32, 0x5d, 0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x32,
0x31, 0x5d, 0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x31,
0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x33, 0x5d, 0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b,
0x33, 0x5d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x20, 0x6d, 0x61, 0x78, 0x44, 0x65, 0x70, 0x74, 0x68, 0x20,
0x3d, 0x20, 0x6d, 0x61, 0x78, 0x31, 0x36, 0x28, 0x20, 0x64, 0x65, 0x70,
0x74, 0x68, 0x5b, 0x30, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x31, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x32,
0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d, 0x20,
0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65, 0x70, 0x74, 0x68, 0x20, 0x3d,
0x5b, 0x32, 0x5d, 0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b,
0x32, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74,
0x68, 0x5b, 0x33, 0x5d, 0x20, 0x2a, 0x3d, 0x20, 0x6d, 0x61, 0x73, 0x6b,
0x5b, 0x33, 0x5d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c,
0x6f, 0x61, 0x74, 0x20, 0x6d, 0x61, 0x78, 0x44, 0x65, 0x70, 0x74, 0x68,
0x20, 0x3d, 0x20, 0x6d, 0x61, 0x78, 0x31, 0x36, 0x28, 0x20, 0x64, 0x65,
0x70, 0x74, 0x68, 0x5b, 0x30, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74,
0x68, 0x5b, 0x31, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x32, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d,
0x20, 0x29, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f,
0x61, 0x74, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65, 0x70, 0x74, 0x68, 0x20,
0x3d, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x30, 0x5d, 0x20, 0x2b, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x31, 0x5d, 0x20, 0x2b, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x32,
0x5d, 0x20, 0x2b, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d,
0x2c, 0x0a, 0x09, 0x09, 0x09, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28,
0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x20, 0x29, 0x20, 0x29,
0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x30, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65,
0x70, 0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x30,
0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x31, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65,
0x70, 0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x31,
0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x32, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65,
0x70, 0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x32,
0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x33, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65,
0x70, 0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x33,
0x5d, 0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61,
0x74, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x3d,
0x20, 0x64, 0x6f, 0x74, 0x28, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x30, 0x5d, 0x20, 0x2b, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x31,
0x5d, 0x20, 0x2b, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x32, 0x5d,
0x20, 0x2b, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d, 0x2c,
0x0a, 0x09, 0x09, 0x09, 0x20, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x20,
0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x20, 0x29, 0x20, 0x29, 0x3b,
0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x30, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65, 0x70,
0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x30, 0x5d,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x31, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65, 0x70,
0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x31, 0x5d,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x32, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65, 0x70,
0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x32, 0x5d,
0x3b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x33, 0x5d, 0x20, 0x2d, 0x3d, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65, 0x70,
0x74, 0x68, 0x20, 0x2a, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x5b, 0x33, 0x5d,
0x3b, 0x0a, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74,
0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x3d, 0x20,
0x64, 0x6f, 0x74, 0x28, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x30,
0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x30, 0x5d, 0x20,
0x29, 0x20, 0x2b, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x20, 0x64, 0x65, 0x70,
0x74, 0x68, 0x5b, 0x31, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x31, 0x5d, 0x20, 0x29, 0x20, 0x2b, 0x0a, 0x20, 0x20, 0x20, 0x20,
0x20, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68,
0x5b, 0x32, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x32,
0x5d, 0x20, 0x29, 0x20, 0x2b, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x20, 0x64,
0x65, 0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70,
0x74, 0x68, 0x5b, 0x33, 0x5d, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x2a, 0x3d,
0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f,
0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x20, 0x6d, 0x61,
0x78, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2c, 0x20, 0x6d, 0x69, 0x6e, 0x44,
0x65, 0x70, 0x74, 0x68, 0x2c, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65, 0x70,
0x74, 0x68, 0x2c, 0x20, 0x73, 0x71, 0x72, 0x74, 0x28, 0x20, 0x76, 0x61,
0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x29, 0x20, 0x29, 0x3b, 0x0a,
0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64, 0x20,
0x6a, 0x75, 0x73, 0x74, 0x20, 0x73, 0x6b, 0x79, 0x20, 0x70, 0x69, 0x78,
0x65, 0x6c, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x70,
0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65,
0x63, 0x34, 0x28, 0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x2c,
0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x2c, 0x20, 0x39, 0x39,
0x39, 0x39, 0x39, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x20, 0x29,
0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a, 0x00
0x30, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x30, 0x5d,
0x20, 0x29, 0x20, 0x2b, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x20, 0x64, 0x65,
0x70, 0x74, 0x68, 0x5b, 0x31, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74,
0x68, 0x5b, 0x31, 0x5d, 0x20, 0x29, 0x20, 0x2b, 0x0a, 0x20, 0x20, 0x20,
0x20, 0x20, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x20, 0x64, 0x65, 0x70, 0x74,
0x68, 0x5b, 0x32, 0x5d, 0x2c, 0x20, 0x64, 0x65, 0x70, 0x74, 0x68, 0x5b,
0x32, 0x5d, 0x20, 0x29, 0x20, 0x2b, 0x20, 0x64, 0x6f, 0x74, 0x28, 0x20,
0x64, 0x65, 0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d, 0x2c, 0x20, 0x64, 0x65,
0x70, 0x74, 0x68, 0x5b, 0x33, 0x5d, 0x20, 0x29, 0x3b, 0x0a, 0x20, 0x20,
0x20, 0x20, 0x76, 0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x2a,
0x3d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x3b, 0x0a, 0x20,
0x20, 0x20, 0x20, 0x6f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c,
0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x34, 0x28, 0x20, 0x6d,
0x61, 0x78, 0x44, 0x65, 0x70, 0x74, 0x68, 0x2c, 0x20, 0x6d, 0x69, 0x6e,
0x44, 0x65, 0x70, 0x74, 0x68, 0x2c, 0x20, 0x61, 0x76, 0x67, 0x44, 0x65,
0x70, 0x74, 0x68, 0x2c, 0x20, 0x73, 0x71, 0x72, 0x74, 0x28, 0x20, 0x76,
0x61, 0x72, 0x69, 0x61, 0x6e, 0x63, 0x65, 0x20, 0x29, 0x20, 0x29, 0x3b,
0x0a, 0x20, 0x20, 0x7d, 0x20, 0x65, 0x6c, 0x73, 0x65, 0x20, 0x7b, 0x0a,
0x20, 0x20, 0x20, 0x20, 0x2f, 0x2f, 0x20, 0x66, 0x6f, 0x75, 0x6e, 0x64,
0x20, 0x6a, 0x75, 0x73, 0x74, 0x20, 0x73, 0x6b, 0x79, 0x20, 0x70, 0x69,
0x78, 0x65, 0x6c, 0x73, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x6f, 0x75, 0x74,
0x70, 0x75, 0x74, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x76,
0x65, 0x63, 0x34, 0x28, 0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30,
0x2c, 0x20, 0x39, 0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x2c, 0x20, 0x39,
0x39, 0x39, 0x39, 0x39, 0x2e, 0x30, 0x2c, 0x20, 0x30, 0x2e, 0x30, 0x20,
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x7d, 0x0a, 0x7d, 0x0a, 0x00
};
const char depthtile1_vp[] = {
0x2f, 0x2a, 0x0a, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d, 0x3d,
@@ -89,10 +89,10 @@ void main()
depth[2] = depthToZ(depth[2]);
depth[3] = depthToZ(depth[3]);
float minDepth = 99999.0 - max16( mask[0] * (99999.0 - depth[0]),
mask[1] * (99999.0 - depth[1]),
mask[2] * (99999.0 - depth[2]),
mask[3] * (99999.0 - depth[3]) );
float minDepth = - max16( mask[0] * (-depth[0]),
mask[1] * (-depth[1]),
mask[2] * (-depth[2]),
mask[3] * (-depth[3]) );
depth[0] *= mask[0];
depth[1] *= mask[1];

0 comments on commit 2e0e9f6

Please sign in to comment.