MCPcopy Create free account
hub / github.com/dborth/fceugx / MakeStereoTexture

Function MakeStereoTexture

source/gcvideo.cpp:1217–1403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1215}
1216
1217void MakeStereoTexture(const void *srcLeft, const void *srcRight, void *dst, s32 width, s32 height)
1218{
1219 const s32 borderwidth = (256 - width) / 2;
1220 const s32 borderheight = (240 - height) / 2;
1221
1222 const u8 *srcBufL = (const u8 *)srcLeft + (borderheight << 8) + borderwidth;
1223 const u8 *srcBufR = (const u8 *)srcRight + (borderheight << 8) + borderwidth;
1224 u8 *dstBuf = (u8 *)dst + (borderheight * 512) + (borderwidth * 8);
1225
1226 u32 r_src_row_L=0, r_src_row_R=0, r_dst_row=0;
1227 u32 tL0=0, tR0=0, tL1=0, tR1=0, w0=0;
1228
1229 __asm__ __volatile__ (
1230 "srwi %[width], %[width], 2\n"
1231 "srwi %[height], %[height], 2\n"
1232
1233 "2: mtctr %[width]\n"
1234 "mr %[r_src_row_L], %[srcL]\n"
1235 "mr %[r_src_row_R], %[srcR]\n"
1236 "mr %[r_dst_row], %[dst]\n"
1237
1238 "1: dcbz 0, %[dst]\n"
1239
1240 // ----------------------------------------------------
1241 // 8 sub-blocks to process 16 pixels. Example: Row 0 Left Half
1242 // Math trick: offset = ((L & 63) << 7) | ((R & 63) << 1)
1243 // ----------------------------------------------------
1244
1245 // Row 0, Left Half
1246 "lbz %[tL0], 0(%[srcL])\n"
1247 "lbz %[tR0], 0(%[srcR])\n"
1248 "lbz %[tL1], 1(%[srcL])\n"
1249 "lbz %[tR1], 1(%[srcR])\n"
1250 "rlwinm %[tL0], %[tL0], 7, 19, 24\n"
1251 "rlwinm %[tR0], %[tR0], 1, 25, 30\n"
1252 "rlwinm %[tL1], %[tL1], 7, 19, 24\n"
1253 "rlwinm %[tR1], %[tR1], 1, 25, 30\n"
1254 "or %[tL0], %[tL0], %[tR0]\n"
1255 "or %[tL1], %[tL1], %[tR1]\n"
1256 "lhzx %[tL0], %[pal], %[tL0]\n"
1257 "lhzx %[tL1], %[pal], %[tL1]\n"
1258 "slwi %[w0], %[tL0], 16\n"
1259 "or %[w0], %[w0], %[tL1]\n"
1260 "stw %[w0], 0(%[dst])\n"
1261
1262 // Row 0, Right Half
1263 "lbz %[tL0], 2(%[srcL])\n"
1264 "lbz %[tR0], 2(%[srcR])\n"
1265 "lbz %[tL1], 3(%[srcL])\n"
1266 "lbz %[tR1], 3(%[srcR])\n"
1267 "rlwinm %[tL0], %[tL0], 7, 19, 24\n"
1268 "rlwinm %[tR0], %[tR0], 1, 25, 30\n"
1269 "rlwinm %[tL1], %[tL1], 7, 19, 24\n"
1270 "rlwinm %[tR1], %[tR1], 1, 25, 30\n"
1271 "or %[tL0], %[tL0], %[tR0]\n"
1272 "or %[tL1], %[tL1], %[tR1]\n"
1273 "lhzx %[tL0], %[pal], %[tL0]\n"
1274 "lhzx %[tL1], %[pal], %[tL1]\n"

Callers 1

RenderStereoFramesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected