1
0
mirror of https://github.com/blawar/GLideN64.git synced 2024-07-07 03:13:49 +00:00

Write macros for reading a vector or matrix without hurting performance. Cleanup blender code.

This commit is contained in:
S2S 2019-11-10 18:48:43 +01:00 committed by Sergey Lipskiy
parent b79f7fa9d6
commit a42e34f1b8

View File

@ -509,26 +509,17 @@ public:
{ {
#if 1 #if 1
m_part = m_part =
" muxPM[0] = clampedColor; \n" " #define STVEC(pos) step(float(pos) - 0.5, vec4(0.0,1.0,2.0,3.0)) - step(float(pos) + 0.5, vec4(0.0,1.0,2.0,3.0)) \n" // Return the vector of the standard basis of R^4 with a 1 at position <pos> and 0 otherwise.
" lowp vec4 vprobe = vec4(0.0, 1.0, 2.0, 3.0); \n" " #define MUXA(pos) dot(muxA, STVEC(pos)) \n"
" if (uForceBlendCycle1 != 0) { \n" " #define MUXB(pos) dot(muxB, STVEC(pos)) \n"
" muxA[0] = clampedColor.a; \n" " #define MUXPM(pos) muxPM*(STVEC(pos)) \n"
" lowp float muxa = dot(muxA, vec4(equal(vec4(uBlendMux1[1]), vprobe))); \n" " muxPM[0] = clampedColor; \n"
" muxB[0] = 1.0 - muxa; \n" " if (uForceBlendCycle1 != 0) { \n"
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux1[0]), vprobe)); \n" " muxA[0] = clampedColor.a; \n"
" lowp vec4 muxpm2 = muxPM * vec4(equal(vec4(uBlendMux1[2]), vprobe)); \n" " muxB[0] = 1.0 - MUXA(uBlendMux1[1]); \n"
" lowp float muxb = dot(muxB, vec4(equal(vec4(uBlendMux1[3]), vprobe))); \n" " lowp vec4 blend1 = MUXPM(uBlendMux1[0]) * MUXA(uBlendMux1[1]) + MUXPM(uBlendMux1[2]) * MUXB(uBlendMux1[3]); \n"
" lowp vec4 blend1 = (muxpm0 * muxa) + (muxpm2 * muxb); \n" " clampedColor.rgb = clamp(blend1.rgb, 0.0, 1.0); \n"
" clampedColor.rgb = clamp(blend1.rgb, 0.0, 1.0); \n" " } else clampedColor.rgb = (MUXPM(uBlendMux1[0])).rgb; \n"
" } else { \n"
// Workaround for Intel drivers for Mac, issue #1601
#if defined(OS_MAC_OS_X)
" clampedColor.rgb = muxPM[uBlendMux1[0]].rgb; \n"
#else
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux1[0]), vprobe)); \n"
" clampedColor.rgb = muxpm0.rgb; \n"
#endif
" } \n"
; ;
#else #else
// Keep old code for reference // Keep old code for reference
@ -551,28 +542,16 @@ public:
ShaderBlender2() ShaderBlender2()
{ {
#if 1 #if 1
m_part = m_part =
" muxPM[0] = clampedColor; \n" " muxPM[0] = clampedColor; \n"
" muxPM[1] = vec4(0.0); \n" " muxPM[1] = vec4(0.0); \n"
" if (uForceBlendCycle2 != 0) { \n" " if (uForceBlendCycle2 != 0) { \n"
" muxA[0] = clampedColor.a; \n" " muxA[0] = clampedColor.a; \n"
" lowp float muxa = dot(muxA, vec4(equal(vec4(uBlendMux2[1]), vprobe))); \n" " muxB[0] = 1.0 - MUXA(uBlendMux2[1]); \n"
" muxB[0] = 1.0 - muxa; \n" " lowp vec4 blend2 = MUXPM(uBlendMux2[0]) * MUXA(uBlendMux2[1]) + MUXPM(uBlendMux2[2]) * MUXB(uBlendMux2[3]); \n"
" lowp vec4 muxpm0 = muxPM*vec4(equal(vec4(uBlendMux2[0]), vprobe)); \n" " clampedColor.rgb = clamp(blend2.rgb, 0.0, 1.0); \n"
" lowp vec4 muxpm2 = muxPM*vec4(equal(vec4(uBlendMux2[2]), vprobe)); \n" " } else clampedColor.rgb = (MUXPM(uBlendMux2[0])).rgb; \n"
" lowp float muxb = dot(muxB,vec4(equal(vec4(uBlendMux2[3]), vprobe))); \n" ;
" lowp vec4 blend2 = muxpm0 * muxa + muxpm2 * muxb; \n"
" clampedColor.rgb = clamp(blend2.rgb, 0.0, 1.0); \n"
" } else { \n"
// Workaround for Intel drivers for Mac, issue #1601
#if defined(OS_MAC_OS_X)
" clampedColor.rgb = muxPM[uBlendMux2[0]].rgb; \n"
#else
" lowp vec4 muxpm0 = muxPM * vec4(equal(vec4(uBlendMux2[0]), vprobe)); \n"
" clampedColor.rgb = muxpm0.rgb; \n"
#endif
" } \n"
;
#else #else
// Keep old code for reference // Keep old code for reference
m_part = m_part =