Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.06 KB | None | 0 0
  1. #ifdef ps_main17
  2. PS_OUTPUT ps_main17(PS_INPUT input)
  3. {
  4.     PS_OUTPUT output;
  5.  
  6.     // Potential speed optimization. There is a high probability that
  7.     // game only want to extract a single channel (blue). It will allow
  8.     // to remove most of the conditional operation and yield a +2/3 fps
  9.     // boost on MGS3
  10.     //
  11.     // Hypothesis wrong in Prince of Persia ... Seriously WTF !
  12.     //#define ONLY_BLUE;
  13.  
  14.     // Convert a RGBA texture into a 8 bits packed texture
  15.     // Input column: 8x2 RGBA pixels
  16.     // 0: 8 RGBA
  17.     // 1: 8 RGBA
  18.     // Output column: 16x4 Index pixels
  19.     // 0: 8 R | 8 B
  20.     // 1: 8 R | 8 B
  21.     // 2: 8 G | 8 A
  22.     // 3: 8 G | 8 A
  23.     float c;
  24.  
  25.     uint2 sel = uint2(input.p.xy) % uint2(16u, 16u);
  26.     int2  tb  = ((int2(input.p.xy) & ~int2(15, 3)) >> 1);
  27.  
  28.     int ty   = tb.y | (int(input.p.y) & 1);
  29.     int txN  = tb.x | (int(input.p.x) & 7);
  30.     int txH  = tb.x | ((int(input.p.x) + 4) & 7);
  31.  
  32.     txN *= ScalingFactor.x;
  33.     txH *= ScalingFactor.x;
  34.     ty  *= ScalingFactor.y;
  35.  
  36.     // TODO investigate texture gather
  37.     float4 cN = Texture.Sample(TextureSampler, int2(txN, ty), 0);
  38.     float4 cH = Texture.Sample(TextureSampler, int2(txH, ty), 0);
  39.  
  40.  
  41.     if ((sel.y & 4u) == 0u) {
  42.         // Column 0 and 2
  43. #ifdef ONLY_BLUE
  44.         c = cN.b;
  45. #else
  46.         if ((sel.y & 3u) < 2u) {
  47.             // first 2 lines of the col
  48.             if (sel.x < 8u)
  49.                 c = cN.r;
  50.             else
  51.                 c = cN.b;
  52.         } else {
  53.             if (sel.x < 8u)
  54.                 c = cH.g;
  55.             else
  56.                 c = cH.a;
  57.         }
  58. #endif
  59.     } else {
  60. #ifdef ONLY_BLUE
  61.         c = cH.b;
  62. #else
  63.         // Column 1 and 3
  64.         if ((sel.y & 3u) < 2u) {
  65.             // first 2 lines of the col
  66.             if (sel.x < 8u)
  67.                 c = cH.r;
  68.             else
  69.                 c = cH.b;
  70.         } else {
  71.             if (sel.x < 8u)
  72.                 c = cN.g;
  73.             else
  74.                 c = cN.a;
  75.         }
  76. #endif
  77.     }
  78.  
  79.     output.c = (float4)(c); // divide by something here?
  80. }
  81. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement