Discards fragments as early as possible.

This commit moves the `discard` instruction in the fragment shader to an earlier position to avoid performing calculations whose results are unused.
This commit is contained in:
Olli Wang 2017-07-02 01:10:38 +08:00
parent c75fc0bfcf
commit 7e11b11177

View File

@ -626,6 +626,7 @@ static int glnvg__renderCreate(void* uptr)
" float scissor = scissorMask(fpos);\n"
"#ifdef EDGE_AA\n"
" float strokeAlpha = strokeMask();\n"
" if (strokeAlpha < strokeThr) discard;\n"
"#else\n"
" float strokeAlpha = 1.0;\n"
"#endif\n"
@ -665,9 +666,6 @@ static int glnvg__renderCreate(void* uptr)
" color *= scissor;\n"
" result = color * innerCol;\n"
" }\n"
"#ifdef EDGE_AA\n"
" if (strokeAlpha < strokeThr) discard;\n"
"#endif\n"
"#ifdef NANOVG_GL3\n"
" outColor = result;\n"
"#else\n"