ããªã«ã»ãããã¬ã³ã³ïŒã€ã³ããã¯ã¹ïŒ
ã¿ãªããããã«ã¡ã¯ïŒ ç§ã®ååã¯ããªã«ã»ãããã¬ã³ã³ã§ãããã®4ã5幎éãç§ã¯Yandexã§ããã³ããšã³ãéçºè ãšããŠåããŠããŸããã ãããŠãã®éãã£ãšãç§ã¯ããã©ãã«æ©ãŸãããŠããŸããã å ¥ç€Ÿæã«ããã©ãã®å éšãµãŒãã¹ãè¡ã£ãåŸã倧èŠæš¡ãªYandexãããã§ããã©ãã¿ã¹ã¯ã解決ããæè¿Canvas 2DãHTMLãWebGLã§ããã©ãWebãã¬ãŒã€ãŒãäœæããŸããã ä»æ¥ã¯ãWebGLã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã«ã€ããŠã話ããããšæããŸãã
ãŸããWebGLãšã¯äœãã確èªããWebGLã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã枬å®ããæ¹æ³ã«ã€ããŠèª¬æããæåŸã«WebGLã¢ããªã±ãŒã·ã§ã³ã®ããã€ãã®æé©åãšãããããããã©ããã¬ãŒã€ãŒã«é©çšããæ¹æ³ã«ã€ããŠèª¬æããŸãã
ããã§ã¯ãWebGLãšã¯äœã§ããïŒ WebGLã¯ãã°ã©ãã£ãã¯ã¹ã«ãŒãã®ãªãœãŒã¹ãžã®Webãã©ãããã©ãŒã ã¢ã¯ã»ã¹ãæäŸããAPIã§ãã JavascriptããçŽæ¥ããã©ãŠã¶å ã§3次å ãå«ãããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã°ã©ãã£ãã¯ã¹ãæç»ã§ããŸãã
WebGLã¢ããªã±ãŒã·ã§ã³ã®æ§é ã¯ãå ç¥ãå®å®ãèŠãæ¹æ³ãšæ¯èŒããããšãã§ããŸãã ãŸããå°ãªããšããããã®ããžã§ã³ã®1ã€ã§ã
ã€ãŸã ããã¯ã象ã«äŸåããäžçš®ã®äžçã§ããã象ã¯å€§ããªäºã®äžã«ç«ã¡ãŸãã ãããŠããã®å³ã§ã¯ããã¹ãŠã®ããžãã¯ããã¹ãŠã®æå³ããã¹ãŠãèµ·ããäžçãã¢ããªã±ãŒã·ã§ã³ã«ãªããŸãã ãŸããWebGLã¢ããªã±ãŒã·ã§ã³ã¯ã3ã€ã®äž»èŠãªãªãœãŒã¹ã«äŸåããŸãã
- ãããã¡ãŒã¯ããžãªã¡ããªãé 眮ããéåžžã«å€§ããªãã€ããããã¯ã§ããããŠãŒã¶ãŒã«ã¢ãã«ã衚瀺ããããã®ã§ãã
- ãã¯ã¹ãã£ã¯ãããçŸãããããèªç¶ã«èŠããçŸå®äžçã®ãªããžã§ã¯ãã®ããã«èŠããããã«ãã¢ãã«ã«ãªãŒããŒã¬ã€ããç»åã§ãã
- ã·ã§ãŒããŒã¯ãGPUäžã§çŽæ¥å®è¡ãããå°ããªããã°ã©ã ã§ãGPUã«ãžãªã¡ããªã®è¡šç€ºæ¹æ³ããã¯ã¹ãã£ã®ãªãŒããŒã¬ã€æ¹æ³ãªã©ãGPUã«äŒããŸãã
ãããŠããããã®ãªãœãŒã¹ã¯ãã¹ãŠãWebGLã³ã³ããã¹ãã®ãã¬ãŒã ã¯ãŒã¯å ã§åç¶ããçãŸããæ»ã«ãŸãã WebGLã³ã³ããã¹ãã¯ããã®å³ã§ã¯éåžžã«å€§ããªã¿ãŒãã«ã§ãããããéããŠããã¹ãŠã®ãªãœãŒã¹ã«ã¢ã¯ã»ã¹ããããããäœæããããã«ããããã®ãªãœãŒã¹ãçžäºã«æ¥ç¶ããæ¹æ³ããããã®ãããã¡ãŒãã·ã§ãŒããŒããã¯ã¹ãã£ãããã³ã·ã§ãŒããŒã®èšç®çµæã®äœ¿çšæ¹æ³ããŸãšããŸãã ã€ãŸã ã¬ã³ããªã³ã°ã«åœ±é¿ããçŽ æŽãããç¶æ ã ãã¡ãããã¢ããªã±ãŒã·ã§ã³ãããé«éã«åäœããã®ã§ããã°ã¯ãŒã«ã§ãã
ããããæé©åã«ã€ããŠè©±ãåã«ããŸã枬å®æ¹æ³ãåŠã¶å¿ èŠããããŸãã 枬å®ã§ããªããã®ãæ¹åããããšã¯äžå¯èœã§ãã ãããå¯èœã«ããæãç°¡åãªããŒã«ã¯ããã¬ãŒã /ç§ã«ãŠã³ã¿ãŒã§ãã
Chromã§äœ¿çšã§ããŸããèªåã§å®è¡ããããšã¯é£ãããããŸãããäžè¬çã«ããã¹ãŠãæ確ã§ãã 1ç§ãããã®ãã¬ãŒã æ°ãå€ãå Žåãããã¯è¯å¥œã§ããããã¬ãŒã æ°ã¯å°ãªã-æªãã ãã ããã¢ããªã±ãŒã·ã§ã³ã®FPSã¯ãŠãŒã¶ãŒã®ç»é¢ã®ãªãã¬ãã·ã¥ã¬ãŒãã«ãã£ãŠå¶éããããšãã埮åŠãªç¹ã1ã€èŠããŠããå¿ èŠããããŸãã éçã®ã»ãšãã©ã®ãŠãŒã¶ãŒã®å Žåãããã¯60 Hzã§ãã 1ç§ããã60ãã¬ãŒã ã§ãããããã£ãŠã5ããªç§ã10ããªç§ã§ãã¬ãŒã ãçæãããã©ããã¯é¢ä¿ãããŸãã...åžžã«60ãã¬ãŒã ãååšããŸãã 1ç§ãããã®ãã¬ãŒã ã¬ãŒãã¯ãããçšåºŠã®æçå¿ãæã£ãŠæ±ãå¿ èŠããããŸãã ããã§ãã1ç§ãããæ°ãã¬ãŒã ããããšãã¢ããªã±ãŒã·ã§ã³ã®é床ãäœäžããããã«ããã¯ãæ¢ãå§ããŸãã æé©åãè©Šã¿å§ããŠããŸãã
ç§ã¯éåžžããã®ãããªå Žåãããªãã®ããã«æã-ç§ã¯ãããã¡ã€ã©ãŒããªã³ã«ããŠãã¢ããªã±ãŒã·ã§ã³ã®ãããã¡ã€ãªã³ã°ãéå§ããç§ã®JavaScriptãæãå€ãã®æéãè²»ãããŠããæ©èœã確èªãããããã®æ©èœãé¡åŸ®é¡ã§èª¿ã¹ãŠããããã䜿ã£ãŠäœããããããšããŸãã
ãã ããOpenGLã¢ããªã±ãŒã·ã§ã³ã®å Žåããããã¡ã€ã©ãŒã¯åé¡ã«çŽé¢ããŠããŸãã
å®éã«ã¯ãWebGL APIã¯éšåçã«éåæã§ããã€ãŸãã ãã¹ãŠã®æç»åŒã³åºãã¯éåæã§ãããä»ã®ããã€ãã®åŒã³åºããéåæã§ãã ããã¯ãããšãã°æç»åŒã³åºãã§ã©ãããæå³ã§ããïŒ åŒã³åºããå¶åŸ¡ãJSã«è¿ãããšãããã®æç¹ãŸã§ã«æç»ãçµäºããŠããªãã£ãå Žåããã°ããããŠçµäºããŸãã ããã«ãçµå¶é£ãç§ãã¡ã«æ»ã£ãŠããåŸã§ãéå§ã§ããŸãã ã€ãŸã drawã³ãŒã«ãè¡ããã¹ãŠ-äœããã®ã³ãã³ããçæããããããããã¡ã«è¿œå ããŠãç§ãã¡ã«æ»ãããGoïŒ æ¬¡ïŒã ãããã£ãŠããããã¡ã€ã©ãŒã§ã¯ããã®ãããªåŒã³åºãã¯çºçãããã¬ã³ããªã³ã°ãé ãå Žåãããã¯è¡šç€ºãããŸããã
ãããããã¹ãŠãããã»ã©æªãããã§ã¯ãªããäžéšã®åŒã³åºãã¯ãŸã åæçã§ãããäžéšã®åŒã³åºãã¯åæçã§ããã ãã§ãªããã³ã³ããã¹ãå šäœãæªæãæã£ãŠåæããŸãã ã€ãŸã 圌ãã¯åæããŠå²ãåœãŠãäœæ¥ãè¡ãã ãã§ãªããåæã«ã¢ããªã±ãŒã·ã§ã³ããããã¯ãããã®åã«ã³ã³ããã¹ãã«å²ãåœãŠããã¹ãŠã®ã¿ã¹ã¯ã®çµäºãŸã§åŸ æ©ããŸãã ãã¹ãŠã®ã¬ã³ããªã³ã°ãäœããã®äœããã®ç¶æ ã®å€åãªã©ã ãããã¡ã€ã©ãŒã¯ããã®ãããªåé¡ãèŠã€ããã®ã«åœ¹ç«ã¡ãŸãã
ã¬ã³ããªã³ã°ã§ã¯ãEXT_disjoint_timer_queryãšåŒã°ããå¥ã®ããŒã«ã圹ç«ã¡ãŸãã
ããã¯WebGLã®æ¡åŒµæ©èœã§ãããéåžžã«å®éšçãªãã®ã§ãã ããã¯ãŸã ãã©ããæ¡åŒµæ©èœã§ãã GPUã§ã®ã³ãã³ãã®å®è¡æéã枬å®ã§ããŸãã åæã«ãããã¯éåžžã«ã¯ãŒã«ã§ãããéåæã§å®è¡ãããŸãã ã€ãŸã äžèŠãªæ¹æ³ã§ã³ã³ããã¹ããåæããããå€ãã®å®è¡æãªãŒããŒããããè¿œå ãããããŸããã ã¢ããªã±ãŒã·ã§ã³ã®ããã©ãŒãã³ã¹ã枬å®ããããã«èšè¿°ãããã¹ãŠã®ã³ãŒãã¯ãå®çšŒåç°å¢ã«çŽæ¥ããŠãŒã¶ãŒã«çŽæ¥åºè·ã§ããŸãã ãŸããããšãã°ãçµ±èšãåéããŸãã ãŸãã¯ãããã«è¯ãããšã«ããããã®ããŒã¿ã«åºã¥ããŠããããã®æž¬å®ã«åºã¥ããŠããŠãŒã¶ãŒã®æ©åšã«åãããŠç»åã®å質ã調æŽããŸãã ã¹ããŒããã©ã³ã§ã¯1æã®åçããã¿ãã¬ããã§ã¯-ããè¯ãå質ã§ãéåžžã¯ãã匷åãªéãããã®ã§ããã¹ã¯ãããã§ã¯éåžžã«åŒ·åãªéãããã®ã§ãã¯ãŒã«ãªå¹æã§æãã¯ãŒã«ãªç»åã衚瀺ããŸãã ãããåæã«ãããã«ã€ããŠããã€ãã®ã³ãŒããæžãå¿ èŠããããŸã-ããã¯å°ããªãã€ãã¹ã§ãã
EXT_disjoint_timer_queryã䜿çšãããšãGPUã«å¯ŸããçŽæ¥ã®æåãŸãã¯è€æ°ã®åŒã³åºãã®å®è¡æéã枬å®ã§ããŸãã ãŸããã³ã³ãã¢ã§æ£ç¢ºãªæé枬å®ãèšå®ããããšãã§ããŸãã ã€ãŸã ããšãã°ãGLããŒã ãJSããGPUã«ç§»åããæéã枬å®ã§ããŸãã ãã€ãã©ã€ã³ã®é 延ã¯äœã§ããã
EXT_disjoint_timer_queryã¯åæAPIã§ããããWebGLã®å®è£ ã®ããã«ãã©ã€ããŒçšã®ã¯ãšãªãªããžã§ã¯ããäœæã§ããã¯ãšãªãªããžã§ã¯ãã§äœæ¥ãè¡ãããŸãã ã¯ãšãªãªããžã§ã¯ããäœæããããããããã®ãªããžã§ã¯ãã«æ£ç¢ºãªã¿ã€ã ã¹ã¿ã³ããä»ããããããã䜿çšããŠã³ãã³ãã°ã«ãŒãã®å®è¡æéã枬å®ããŸãããšèšããŸãã ãã®åŸããã¬ãŒã ãšéåžžã¯æ¬¡ã®ãã¬ãŒã ã®æ§ç¯ãå®äºããŸãããããããåŸã§ãããç§åäœã®æž¬å®çµæãå©çšå¯èœã«ãªããŸããããã¯åæã«ããªãæ£ç¢ºã§ãã ãããŠããããã®æž¬å®å€ã䜿çšã§ããŸãã
枬å®ã«é¢ããçµè«ãèŠçŽããŸãã
ã¢ããªã±ãŒã·ã§ã³ã®è³ªçãªç¹æ§ãšããŠã1ç§ãããã®ãã¬ãŒã ã«ãŠã³ã¿ãŒããããŸããããã«ãããé床ãäœäžããŠãããã©ããã確èªã§ããŸãã ãããŠãé床ãèœãšããšãJSãããã¡ã€ã©ãŒã¯ãJSã®CPUã®ããã«ããã¯ããããçš®ã®æ°åŠã§ãããçš®ã®ãµããŒãã³ãŒãã§èŠã€ããã®ã«åœ¹ç«ã¡ãŸãã EXT_disjoint_timer_queryã¯ãGPUã®ããã«ããã¯ãèŠã€ããã®ã«åœ¹ç«ã¡ãŸãã
ããŠãããã©ãŒãã³ã¹ã®æž¬å®æ¹æ³ãåŠã³ãããã«ããã¯ãæ¢ãæ¹æ³ãåŠã³ãŸããã次ã«ã次ã«äœããã¹ãããç解ããå¿ èŠããããŸãã ããã§ã¯ãããã€ãã®æé©åã«ã€ããŠã®ã¿èª¬æããŸãã ã³ã³ãã¥ãŒã¿ã°ã©ãã£ãã¯ã¹ã¯ããããã³ã°ã欺ceptionãå¥åŠãªæé©åã®éåžžã«å€§ããªé åã§ãã ããã€ãã®äžè¬çãªæé©åã®ã¿ãããã©ããã¬ãŒã€ãŒã§ããããã©ã®ããã«é©çšãããã«ã€ããŠèª¬æããŸãã
ãããŠãé«éGLã¢ããªã±ãŒã·ã§ã³ãžã®éã§æ¡çšãããå¿ èŠãããæåã®ã«ãŒã«ã¯ãWebGLç¶æ ã§æ éã«åãããšã§ãã åé ã§è¿°ã¹ãããã«ãWebGLã³ã³ããã¹ãã«ã¯ã¬ã³ããªã³ã°ã«åœ±é¿ããç¶æ ã®å€§ããªéšåããããæ éã«äœæ¥ããå¿ èŠããããŸãã ç¹ã«ãget *ããã³read *åŒã³åºããè¡ãå¿ èŠã¯ãããŸããã ã³ã³ããã¹ãã®çŸåšã®ç¶æ ãèŠæ±ããåŒã³åºãããŸãã¯ãããªã«ãŒãããããŒã¿ãèªã¿åãåŒã³åºãã æ¬åœã«å¿ èŠãªå Žåã ãªãã§ïŒ ãããã®åŒã³åºãã¯åæã§ããã ãã§ãªããã³ã³ããã¹ãå šäœã®åæãåŒãèµ·ããå¯èœæ§ããããããã¢ããªã±ãŒã·ã§ã³ã®é床ãäœäžããŸãã ç¹ã«ãgetErrorïŒïŒã¡ãœããã¯ãWebGLã³ã³ããã¹ãã®æäœã§ãšã©ãŒããããã©ããã確èªããŸãã éçºæã«ã®ã¿åŒã³åºãå¿ èŠããããéçºæã«ã¯åŒã³åºããªãã§ãã ããã ãŸããç¶æ ã®åãæ¿ãã¯ãé »ç¹ã«è¡ããªãããã«æå°éã«æããå¿ èŠããããŸããããã¯ãååãæ¿ããäœããã®äŸ¡å€ãããããã§ãã
ã³ãŒãã§ã©ã®ããã«èŠããã®ã§ããããïŒ
ç¹ã«ãããã¯æ¬¡ã®ããã«ãªããŸãã ãµã€ã¯ã«ã¯çžäºã«ãã¹ããããå€éšãµã€ã¯ã«ã§ã¯ããé«äŸ¡ãªç¶æ ãåãæ¿ããé »ç¹ã«åãæ¿ããããšã¯ãªãããã¹ãããããµã€ã¯ã«ã§ã¯ããå®äŸ¡ãªç¶æ ãåãæ¿ããŸãã ç¹ã«ããã¬ãŒã ãããã¡ãŒã®æ¥ç¶ãã·ã§ãŒããŒããã°ã©ã ã®åãæ¿ãã¯éåžžã«é«äŸ¡ãªåãæ¿ãã§ãããåæãçºçããããšã¯ã»ãŒä¿èšŒãããŠãããäžè¬çã«ã¯ããªãæéãããããŸãã ãŸãããã¯ã¹ãã£ãšã·ã§ãŒããŒãã©ã¡ãŒã¿ã®åãæ¿ãã¯ããé«éã§ãããé »ç¹ã«è¡ãããšãã§ããŸãã
ãããããã®çŽ æŽããããã¶ã€ã³ã§ããããã«æé©åã§ããŸãã
æç»åŒã³åºããå°ãªãããããããã«å¯ŸããŠããå€ãã®äœæ¥ãå®è¡ã§ããŸãã åæç»åŒã³åºãã¯ãç¶æ æ€èšŒã«äœããã®ãªãŒããŒããããè¿œå ããŠããã®ããŒã¿ããããªã«ãŒãã«éä¿¡ããŸãã ãããŠããã®ãªãŒããŒãããã䟵é£ããããšã¯çŽ æŽãããããšã§ãã ãããŠããããã®åŒã³åºããå°ãããããªãŒããŒããããæžãããŠãååŒã³åºãã«ããå€ãã®äœæ¥ãè¡ãããšã§ã1ã€ã®æ¹æ³ã§ã®ã¿ãŒããããããããšãã§ããŸãã å ·äœçã«ã¯ãè€æ°ã®ãªããžã§ã¯ããæç»ããè€æ°ã®ã¢ãã«ããããŒã¿ãå«ã1ã€ã®ãããã¡ãŒã«ã¹ã¿ãã¯ã§ããŸãã ãŸãããã¯ã¹ãã£ã䜿çšããå Žåã¯ããããã®ãã¯ã¹ãã£ããã¹ãŠ1ã€ã®å€§ããªç»åã«é 眮ããŸããããã¯éåžžããã¯ã¹ãã£ã¢ãã©ã¹ãšåŒã°ããŸãã ãããã£ãŠãè€æ°ã®ãªããžã§ã¯ããã¬ã³ããªã³ã°ã«åãç¶æ ãå¿ èŠãšãããã€ã³ãã«æã£ãŠããããããã1åã®åŒã³åºãã§æç»ã§ããŸãã
ã€ã³ã¹ã¿ã³ã¹åãšåŒã°ãããã®ãããªåªããææ³ã䜿çšãããšãåããªããžã§ã¯ãã®è€æ°ã®ã³ããŒãç°ãªããã©ã¡ãŒã¿ãŒã§1åã®åŒã³åºãã§æç»ã§ããŸãã ã€ã³ã¹ã¿ã³ã¹åæé©åã®ã¢ããªã±ãŒã·ã§ã³ã®è¯ãäŸã¯ãããŒãã£ã¯ã«ã·ã¹ãã ã§ãã ããŒãã£ã¯ã«ã·ã¹ãã ã䜿çšããŠæãããçŽ æŽãããäŒè°ã®ããŽãèŠãããã£ãã®ã§ãã ãããã¯å°ããªãªããžã§ã¯ãã§ãããå°ããªã¢ãã«ã§ããããã®äžã«ã¯5äžåããããŸããæåã®ã±ãŒã¹ã§ã¯ãçŽ æŽãªã¢ãããŒãã§ãããããåå¥ã«ãã€ã³ãããŸããã 2çªç®ã®ã±ãŒã¹ã§ã¯ãç¹å¥ãªæ¡åŒµæ©èœã䜿çšããŸããã
äžè¬ã«ãæ¡åŒµæ©èœã䜿çšããã®ã¯è¯ãç¿æ £ã§ãããæ¡åŒµæ©èœã«ã¯å€ãã®å Žåéåžžã«åªããæ©èœãå«ãŸããŠããŸãã ããã©ãããããããã¯æ éã«äœ¿çšããå¿ èŠããããŸãã æ¡åŒµæ©èœãªãã§åäœããã³ãŒãã«åžžã«ãµã€ãã£ã³ã°ãæ®ãå¿ èŠããããŸãã
ããã§ANGLE_instanced_arraysã䜿çšããŸãããããã¯ãWebGLã®ã€ã³ã¹ã¿ã³ã¹åãå®è£ ããŠããŸãã ãªããžã§ã¯ãã®ãã¹ãŠã®ã³ããŒã®ãã¹ãŠã®ãã©ã¡ãŒã¿ãŒã倧ããªãããã¡ãŒã«å ¥ããWebGLã«ãããã³ããŒãã©ã¡ãŒã¿ãŒãæã€ãããã¡ãŒã§ããããšãäŒãããããŠ-ãããïŒ åœŒã¯æããã ãããŠã10ã60 FPSã§ãã¹ãŠãããã«äžãããšããçŸããå¹æããããŸããã
ãã®å Žåãããã©ãã§äœããããŸãããïŒ
ããã©ãã§ã¯ãã³ã³ããã¹ãåãæ¿ãã®æå°åãäºå®äžç¡æã«ãªããŸããã ãªããããèµ·ãã£ãã®ã§ããïŒ ç§ãã¡ã®ä»äºã¯ããã ã£ãã®ã§ãã€ãŸã ãã¬ãŒã€ãŒã«ãŸãããã©ããæç»ãã次ã«ãªããžã§ã¯ãã®çœ²åãæç»ãã次ã«ã³ã³ãããŒã«ãé·ç§»ç¢å°ãã¯ã€ãã¯é·ç§»ã¯ãã·ã£ãŒãæç»ããŸãã ãã®èšèé£ããããåããªããžã§ã¯ããã³ãŒãå ã§äžŠã¹ãŠæç»ããããšã«ãªããŸãã ãã®å ŽåãããŒã«ãŒã«ã€ã³ã¹ã¿ã³ã¹åãé©çšããŸããã ãã¹ãŠã®ããŒã«ãŒããã¹ãŠã®ãªããžã§ã¯ãã©ãã«ã1åã®æç»åŒã³åºãã§æç»ããŸãã ããã§ãã衚瀺ãããŠããªãããã©ãã»ã¯ã¿ãŒã®æç»åŒã³åºãã¯çæããŸããã ãŸã ç»é¢ã«è¡šç€ºãããªããã®ã®åŒã³åºããçæããã®ã¯ãªãã§ããïŒ ã€ãŸã äžè¬ã«ãã¥ãŒããŒãã«ãªã³ã°ãŸãã¯éå°ã«ãªã³ã°ãšåŒã°ããææ³ã
ãããŠããã®å Žæã§ã¯ãYandexã«çç¶ã®ããã©ãããããšèšãããšãéèŠã§ãã ããã¯ãçã«éããããããçš®ã®åçã§ãã ãã¬ãŒã€ãŒãéããšããã®åçã®äžå€®ã«ãç«ã¡ããå€ãèŠãããšãã§ããŸãã ããã¯ãå åŽããã§ã¯ãªããçäœã®å€åŽãèŠããšã©ã®ããã«èŠãããã§ãã
ããã¯ãããã©ãæ§é ããµãŒããŒããã®ããã©ãåçãã€ãŸã çããé·æ¹åœ¢ã®æ圱ã§ãããä¿æããŸãã
ãŸããWebGLã§äœæ¥ããããããããã«ãå°ããªã»ã¯ã¿ãŒã«åå²ããŸããã
WebGLã¯éåžžã«å€§ããªãã¯ã¹ãã£ãäœæã§ããŸããã
ãããŠããã®ãããªã»ã¯ã¿ãŒããšã«ãç»é¢ã«è¡šç€ºããããã©ãããèšç®ã§ããŸãã 該åœããªãå Žåã¯ãã¬ã³ããªã³ã°ã®ããã«ãªã¹ãããé€å€ããã ãã§ãªããå æããŠãããªãœãŒã¹ãåé€ããŸãã ã¡ã¢ãªãç¯çŽããŸãã åã³è¡šç€ºããããšããã«ã空ã®ãã¯ã¹ãã£ãéžæãããã©ãŠã¶ãã£ãã·ã¥ãããã®ç»åããªããŒãããŸãã
ãã®ãããªãã®ã¯å¹ŸäœåŠçã«èŠãããããªãã¡ ãã¯ã¹ãã£ã®åã»ã¯ã¿ãŒã¯çäœã®ãžãªã¡ããªã®ã»ã¯ã¿ãŒã«å¯Ÿå¿ãããããããã¯ãã¹ãŠæç»ãããŸãã
WebGLã¢ããªã±ãŒã·ã§ã³ã§ã®ãã1ã€ã®å€§ããªæããã眪ã¯ããªãŒããŒãããŒã§ãã
ãªãŒããŒãããŒãšã¯äœã§ããïŒ ããã¯ããã¯ã»ã«ãæ°åæ°ãããšãã§ãã ããšãã°ãã¹ã©ã€ãã«ç€ºãããŠããå³ã®ããã«ã æåã«é·æ¹åœ¢ãã次ã«åãã次ã«äžè§åœ¢ãæããšãé·æ¹åœ¢ã®äžéšãèæ ®ããåã®ãã®éšåã®åŸã«ã¯ç¡é§ã«ãªã£ãããšãããããŸãã ç§ãã¡ã¯ãŸã ããããèŠãããªãœãŒã¹ã¯ãããã«è²»ãããŸããã ãããé¿ããã®ãããã§ãããã ããã«ã¯ããŸããŸãªææ³ããããŸãã
1ã€ç®ã¯ããã¯ã¹ãã£ã»ã¯ã¿ãäžå¯èŠãªããžã§ã¯ããã€ãŸã JSã®CPUäžã§ä»ã®ãªããžã§ã¯ãã«ãã£ãŠéããããããããæç»ããªããªããžã§ã¯ãã¯ããããã®æç»åŒã³åºããçæããŸããã ãã®ææ³ã¯ããªã¯ã«ãŒãžã§ã³ã«ãªã³ã°ãšåŒã°ããŸãã JSã§ãããè¡ãã®ã¯å¿ ãããç°¡åã§ã¯ãããŸãããJSã¯æ°åŠã§ã¯ããã»ã©é«éã§ã¯ãããŸããã
ããåçŽãªææ³ãé©çšã§ããŸããããšãã°ããªããžã§ã¯ããæ·±ãã§ãœãŒãããŸãã è¿ãããé ããŸã§ããããæç»ãããšããããªã«ãŒãèªäœããã®èšç®ããé€å€ãããŸãããããã®ãã¯ã»ã«ã¯ãç»é¢ã«è¡šç€ºãããªãããšããã¬ãŒã ã«æ¢ã«ãããã¯ã»ã«ãããé ãã«ããããšã確å®ã«ããããŸãã
ãããŠããããå°é£ãªå Žåãããšãã°ããªããžã§ã¯ãã延é·ãããŠããããå·§åŠã«äº€å·®ããŠããããã«ãDepth pre-passãã€ãŸã éåžžã«åçŽãªã·ã§ãŒããŒã䜿çšããŠã深床ãããã¡ãŒãåããããšã«ããããããªã«ãŒãã«ç»é¢ããã®åãã¯ã»ã«ã®è·é¢ãªã©ãäŒãããããªã«ãŒãã¯åã®ã±ãŒã¹ãšãŸã£ããåãæé©åãé©çšã§ããŸãã
ããã©ãã§ã¯ãå¥ã®åé¡ã解決ããããã«ãç§ãã¡ã¯ã²ã£ããããŸããã ããã©ãç»åã¯ããµãŒããŒäžã§è€æ°ã®ãµã€ãºãè€æ°ã®è§£å床ã§åæãããŠããå¿ èŠãããããã¬ãŒã€ãŒã®çŸåšã®ãºãŒã ãŸãã¯ããã©ãã®çŸåšã®ãºãŒã ã«æé©ãªç»åã®ãµã€ãºããŠãŒã¶ãŒã«è¡šç€ºããå¿ èŠããããŸãã ãã ããåæã«ãç§ãã¡ãæ¢ã«æã£ãŠããæé«ã®å質ã瀺ããããšæããŸããããã¯åžžã«æé©ãšã¯éããŸããããå質ãäœãå ŽåããããŸãã ã©ã®ããã«èŠããŸããïŒ
æåã«ãæãéããæããŒãããŠãæãç³é¹žã®å€ãç»è³ªã§æç»ããŸãã ãã®åŸããã®äžã«ãããè¯ãå質ãããããšããã¹ãŠæããŸãã
ãããŠãããã§ã¯ãç»åã®ãã¹ãŠã®ã»ã¯ã·ã§ã³ãããããã§ã¯ãªããäžéšãæ¬ èœããŠãããéæã§ãããããããéããŠããäœãå質ãèŠããããšã¯æããã§ãã
ãããŠãã®åŸãåçã®çŽ°éšããŸã å±ããŠããªããããéšåçã«éæã§ããå¯èœæ§ã®ããæé«ã®å質ãåŒãåºããŸãã
ç¹°ãè¿ããŸãããåã®ã¬ã€ã€ãŒãèŠããééããããŸãã
ãããã£ãŠã4ã€ã®ãã¹ã§ããŠãŒã¶ãŒã®ç»é¢ã«ããã©ãç»åãçæããŸãã ãªããããèµ·ãã£ãã®ã§ããïŒ ãªããªãããŸãããã¯ã¹ãã£ã®äžéšãéæã«ãªãå¯èœæ§ããããäžè¬çã«èšãã°ãã©ã®éšåãéæã§ããã¯ã¹ãã£ã®ã©ã®äœå質éšåãé«å質ã®éšåã§èŠãããŠããããèšç®ããã®ã¯ããã»ã©ç°¡åã§ã¯ãªãã£ãããã§ã ãããã£ãŠãç§ã¯ããèŠããå¿ èŠããããŸããã Retinaã¹ã¯ãªãŒã³ã§ã¯ããã¯ã»ã«æ°ãå€ãããéåžžã«é ããã¢ãã€ã«ã§ã¯ããŸãæ©èœããŸããã§ããã
ã©ããã£ãŠãããåé¿ããŸãããïŒ å ã»ã©ç€ºãããã®å³ãããèŠããšãäžè¬çã«èšãã°ããã®æäœã¯äžåºŠã«å®è¡ã§ãããšæ³å®ã§ããŸãã ã€ãŸã ãããã®ã¬ã€ã€ãŒã1ã€ã®äžéãããã¡ãŒã«æããããã åŸãããããã£ãã·ã¥ãšåŒã³ããã¬ãŒã å ã«ã®ã¿æç»ã§ããŸãã ããã¯ãŸãã«ç§ãã¡ããã£ãããšã§ãã
ããšãã°ã質ã®æªãããŒã¿ãã€ãŸã å³åŽã«ã¯ããŒã¿ããããå·ŠåŽã«ã¯ãã¯ã¹ãã£ããããŸãããã¯ã¹ãã£ã¯ãã®äžéšã§ãã è¯è³ªã®ããŒã¿ãå°çããŸãã-ãã¯ã¹ãã£ãæç»ããŸããã ããè¯ãããŒã¿ãå°çããŸãã-æªãããŒã¿ã®äžã«ãã¯ã¹ãã£ãã¬ã³ããªã³ã°ããŸããã éåžžã«è¯ãããŒã¿ãå°çããŸãã-ãããŠãç§ãã¡ãããããäžã«æããŸããã å°çããããŒã¿ãããªãã©ã€ã³ã§åéãããç»åãåžžã«1ã€ãããŸãã
ãã¡ããããã¹ãŠãåžžã«è¯å¥œã§ãããšã¯éããããããã¯ãŒã¯ã¯äºæž¬äžèœã§ãããããŒã¿ã¯ééã£ãé åºã§å°çããå¯èœæ§ããããŸãã ããããç§ãã¡ã¯åé¡ãéåžžã«ç°¡åã«è§£æ±ºããŸãã
åã³ãæªãçµµãç§ãã¡ã«ãã£ãŠæ¥ãŠãããããæé«ã®çµµãå±ãããããäžçªäžã«æããŸãã ãããŠãäœå質ã®åçãå±ããŸãããã¡ãããç§ãã¡ã¯ããã衚瀺ããŸããã ãã§ã«ããæé«ã®å質ãæ®ããŠããŸãã T.O. è€æ°ã®ããã©ãã¬ã³ããªã³ã°ãã¹ã1ã€ã«åæžããŸãããããã«ãããRetinaããã€ã¹ãå«ãããŸããŸãªããã€ã¹ã§ã®åŠçãå éãããŸããã
å€ãã®å ŽåãWebGLã§èšè¿°ãããã¬ã³ããªã³ã°ã³ãŒãã¯éåžžã«é«éã«åäœããã¹ããŒããã©ã³ãã¿ãã¬ããããã¹ã¯ãããã³ã³ãã¥ãŒã¿ãŒã§60 fpsãé ä¿¡ã§ããŸãã ãããããããåãå·»ãã³ãŒãã¯ãWebã¢ããªã±ãŒã·ã§ã³ã«å¿ ãååšããŸããDOMãæŽæ°ããã³ãŒãããªãœãŒã¹ãããŒãããã³ãŒãããŠãŒã¶ãŒã€ãã³ããåŠçããã³ãŒããUIã€ãã³ãã å¶åŸ¡ã«é·æéããããã¢ãã¡ãŒã·ã§ã³ã®é 延ãã¬ã³ããªã³ã°ã®é 延ãåŒãèµ·ãããã¢ããªã±ãŒã·ã§ã³ã®é床ãäœäžãããŸãã
ãã®ã³ãŒãã§ã¯ãå°ããªéšåã«åå²ãã以å€ã¯äœãã§ããªãããã§ãã 100æã®åçãããŒããããŠããå ŽåãäžåºŠã«100æãããŒãããå¿ èŠã¯ãããŸããã10ããŒã¹ãããã±ã«ãããŒãããå¿ èŠããããŸãã ãããŠãã¢ãã¡ãŒã·ã§ã³ã®é床ãäœäžããªããšãã«ãæ¬åœã«æéããããšãã«ã®ã¿ãã®ã³ãŒããå®è¡ããã¹ã±ãžã¥ãŒã©ãäœæããŸãã
ããã©ãã®ç§ãã¡ã«ãšã£ãŠããã®ãããªã³ãŒãã¯ã¿ã€ã«ãããŒãããããã©ãã®ç®ã«èŠããªãéšåãæŒãåºããŠããŸãããããã«ã€ããŠã¯æåã«è©±ããŸããã ããã©ããåããŠããéã¯çµ¶å¯Ÿã«ãããè¡ããŸãããéæ¢ç»åãããå Žåãã©ã®fpsã衚瀺ãããã1ç§ãããã®ãã¬ãŒã æ°ã衚瀺ãããã1ã60ã衚瀺ãããã¯é¢ä¿ãªãããã§ããéãã«æ³šæããŠãã ãããç»åã¯ç§»åãããç»é¢äžã§äœãå€ãããŸããã ãã®ãããã¢ãã¡ãŒã·ã§ã³ãçµäºãããŸã§åŸ æ©ãã衚瀺ãããŠããã¿ã€ã«ãåã«ãŠã³ããã衚瀺ãããŠããã»ã¯ã¿ãŒããã¯ã¹ãã£ãåã«ãŠã³ãããŸãã ãªã¯ãšã¹ããäœæãããªãœãŒã¹ã管çããŸãã
ããã«ããã¬ãŒã€ãŒã®ãœãããŠã§ã¢ã€ã³ã¿ãŒãã§ãŒã¹ã®ã€ãã³ããåé¡ã®åå ã«ãªããŸããã ãã¬ãŒã€ãŒã¯å€§ããªãããã«åã蟌ãŸãããŠã£ãžã§ããã§ããã倧ããªãããã¯ããã€ãã®å€éšã€ãã³ãã䜿çšããŠãè¿œå ã®ã€ã³ã¿ãŒãã§ãŒã¹èŠçŽ ã®äžéšã衚瀺ããŸãã
APIã€ãã³ãã䜿çšãããšãéåžžã«ç°¡åã«ãªããŸããã ãŸããããããæå¶ããŸããã ããšãã°ããŠãŒã¶ãŒã®èŠç·ã®æ¹åãå€åããŠããéãããã©ãã§èŠç·ã®æ¹åãå€åããŠããéã«ãåžžã«çæãããã€ãã³ãã¯ããããã®ã€ãã³ãã調æŽããŸããã çæé »åºŠãå€§å¹ ã«åæžããŸããã ããããããã¯ååã§ã¯ãããŸããã§ãããããšãã°ããã®å Žæã§ã®ç§ãã¡ã«ãšã£ãŠã®å€ãã®åé¡ããã©ãŠã¶APIã®æŽå²ãäœãäžããŸããã èŠåã®å€åã€ãã³ãããšã«ã¢ãã¬ã¹ããŒã®ãªã³ã¯ãæŽæ°ããããšããŸãããããã¹ãŠãéåžžã«é ããªããŸããã , , . , , API . , - .
.
â , , . , , get error . .
, .. overhead, .
overdraw , , .
, .. , , , .
» dmikis@yandex-team.ru
» Github
» Facebook
â HighLoad++ .
, , « ».
HighLoad++ YouTube, :(
- Frontend Conf WebGL:
é¢çœãïŒ ! .
, :). Frontend Conf, .