ãã¹ã¯ãããã®æé»é¢
å®éã«éå»ã® GDI ããã°ã©ãã³ã°ãããããã¨ãããæ¹ãï¼Windows XP 㨠WDDM ç°å¢ã® Windows Vista ã§å®é¨ããã°ï¼Device Dependent Bitmapï¼é称 DDB ã®æ¯ãèãã以åã¨å
¨ç¶éã£ã¦ãã¾ã£ã¦ãããã¨ã«æ°ä»ãã ããï¼
è¦ç¹ã ããè¨ãã°ï¼DDB ã®ããã©ã¼ãã³ã¹ç¹æ§ã DIB (Device Independent Bitmap) ã«ãã£ããã«ãªã£ãã¨ãããã¨ã ï¼
以ä¸ä½ã®å½¹ã«ãç«ããªãæé»éå¦
ï¼æ³¨ï¼ãããèªãã§ããVista ã® 2D æç»ã¯éããªãã¾ãããï¼ãï¼å°ãã ãä¸çã®çµ¡ç¹°ããåããããç¥ãã¾ããï¼åºæ¬çã«ã¯æã®äºæ ããã¾ãããç¥ããªãéçºè åãã«æ¸ãã¦ãã¾ãï¼ã£ã¦ç§ãæã®ãã¨ã¯å ¨ç¶ç¥ããªãã®ã§ããã©ï¼ã¾ãåããç¯å²ã§æ¸ãã¦ã¿ã¾ããï¼
DDB ã¯ï¼ãã©ã¤ãä¾åã®æ£ä½ä¸æãªããããããï¼ã¨ããã®ãå®ç¾©ã ãï¼ã¶ã£ã¡ããã¦è¨ãã° VRAM ä¸ã®ãµã¼ãã§ã¤ã¹ï¼ãã ãä½ããããã¨ã¡ã¤ã³ã¡ã¢ãªã«å¾
é¿ï¼ï¼ï¼ã¨ããã®ãå½æã®ã常èãã§ãã£ãï¼DDB éã® BitBlt ã CPU å¾éã«ãªã£ã¦ä½å¹´çµã£ã¦ããã ãããï¼æãã°å½æããæ¢ã« DDB éã® GDI BitBlt ï¼Blt 㯠Block Transfer ã®ç¥ï¼ããããç©å½¢è»¢éï¼ã¯çã£ã¦ããï¼ä¸æãªãã³ããã¼ã¯ãä½ã£ã¦ãã¾ãã¨ï¼Pixel Fill Rate ï¼1ç§éã«æç»ãããã¨ãã§ãããã¯ã»ã«æ°ï¼ã転éããç»åãµã¤ãºã«æ¯ä¾ããããã«è¦ããã®ã ï¼
ä½ã®ãã¨ã¯ãªãï¼ããè¦ã¦ã¿ã㨠16Ã16 ã ããã 128Ã128 ã ããã 512Ã512ã ãããï¼åä½æéã«å¼ã³åºãã¦ãã BitBlt åæ°ãåããã¨ã«æ°ä»ãï¼å¼ã³åºãåæ°ãåããªãï¼å½ç¶ã¹ã³ã¢ã¯ç»åé¢ç©ã®ã¿ã«æ¯ä¾ããã ããï¼
ã¤ã¾ãï¼GPU ã®ãã¤ãã太ããã¦ï¼CPU ã®ä»äºæå
¥é度ã追ãã¤ãã¦ããªããã¨ã«ãªãï¼ãã®æå
¥åæ°ã®ä¸éã¯åãã¿ã¤ãã® CPU ãªãæ¦ãã¯ããã¯ã«æ¯ä¾ããã®ã§ï¼21 ä¸ç´ã«è³ã£ã¦ãï¼ä¸é¨ã® 2D ãã³ããã¼ã¯ã¯ï¼CPU ã¯ããã¯ã«æ¯ä¾ããã¨ããå¤ãªç¾è±¡ãè¦ãããï¼
Direct3D ã§ãåæ§ã®ç¾è±¡ã¯æ¢ã«ãã¡ãã¡ã§èµ·ãã£ã¦ãããï¼å ã ãããå¦çã®æå ¥ãæèãã¦ãã API ã ãã«ç¶æ³ã¯ã¾ãã§ããï¼Microsoft ã GPU ãã³ãå社ã«ããï¼å°ããªããããããã«ç½ªæ·±ããã¨ã§ãããåèãã£ã³ãã¼ã³ãåãå¥ãã¦ããã®ãããããªãï¼Direct3D ã®ä¸çã«ã¯ãå°ããªãããï¼å¦çï¼ï¼ã«ãã³ã¯ã«ã¤ãã¿ãããªç¬ç¹ã®é°å²æ°ããã*1ï¼SQL Server ã§ã®ãã«ã¼ã½ã«ï¼ã«ãã³ã¯ã«ã¤ãã¿ãããªãã®ã ï¼
ä¸æ¹ã§ï¼GDI ã«ã¯ Device Independent Bitmapï¼ãããã DIB ã¨ãããã®ãããï¼DIB ã¯ï¼ãã·ã¹ãã ã¡ã¢ãªä¸ã®ãªãã¹ã¯ãªã¼ã³ãµã¼ãã§ã¤ã¹ãã¨ããæåããªããããã¨ãå¤ããï¼å®éã«ã»ã¨ãã©ã®å ´å㧠CPU å¦çããªããã¦ããã¨èãã¦è¯ãã ããï¼çµæï¼å¦çãããã¯ã»ã«æ°ã«æ¯ä¾ããã¹ã«ã¼ãããã示ããã¨ãå¤ãï¼CPU ã§æç»å½ä»¤ãçºè¡ãï¼CPU ã§å®éã«å¡ãã¤ã¶ãä¸ã§ï¼ã©ã¡ããããåè¶ãããã¨ããã°é常ã¯å¡ãã¤ã¶ãã®æ¹ã ããã ï¼
ãããï¼GPU ã«ããã¢ã¯ã»ã©ã¬ã¼ã·ã§ã³ãã»ã¨ãã©æå¾ ã§ããªãã«ããããããï¼DIB ã¯è¡°éããã©ãããå¾ã ã«å¢ååãåºãã¦ãã¦ããï¼DIB 使ãã®çé 㯠GDI+ï¼ãã㦠GDI+ ã使ç¨ããã¢ããªã±ã¼ã·ã§ã³ã¨ããã° Microsoft ã® Office ç³»ã¢ããªã±ã¼ã·ã§ã³ã¨ãªãï¼å æ¥ã® VSUG ã¤ãã³ãã§ç´¹ä»ããï¼Vista 風ã®ãã©ã¼ä»ãæåæç»ãï¼Theme API ã®åºåå ã¯ã¢ã«ãã¡å¤ãæã£ã DIB ãæå¾ ããã¦ãã*2ï¼åãããã¨ã«ä¸ã®ä¸ DIB ã°ã£ããã ï¼ãã®ä¸ç㯠Intel ãã©ã°ç«ã¡ã¾ãããããï¼
ãã ãæ´å²çã« Windows ã®ãã¹ã¯ãããç»é¢ã¯ DDB ã¨ãããã¨ã«ãªã£ã¦ããã®ã§ï¼ç¾è±¡è«çã«ã¯ï¼ããã¯ã¾ãã« DDB ã®å®ç¾©ã«è¿ãï¼ãã¹ã¯ãããã¨äºæããã®ã DDB ã ï¼ï¼æçµçã«ãã¹ã¯ãããã«è¡¨ç¤ºããã«ã¯ DIB ãã DDB ã¸ã®è»¢éãå¿ è¦ã¨ãªãï¼ããããæå³ã§ï¼DIB ã ã㧠Office ãä½ãããããã§ã¯ãªãï¼
ã¾ãï¼Photoshop ã®ãããªå°éååãã½ããï¼ã¨ã³ã§ã°ããã®ãã㪠2D ã²ã¼ã ã¯ï¼ãã®æ ¹å¹¹ã®å¦çã¯æåããç¬èªã®ã¡ã¢ãªãããã¡ã§è¡ã£ã¦ããï¼ãã ãï¼å社ç¬èªã¢ã«ã´ãªãºã ã«ããé«éåå¦çã§å·®å¥åãå³ã£ã¦ããï¼ç¹å®ç¨éåãã§ã¯ DIB ãããéãã«é«ãæ§è½ã示ãã ããï¼ãã¡ãããã®å ´åãï¼æå¾ã«ç»é¢ã«è¡¨ç¤ºããã«ã¯ DDB ã DirectDraw ã®åãåããã°ãªããªãï¼
ã¨ããããã§æåã«æ»ãï¼æ§æ ¼çå対ã®ååã«ä¹ ãã¶ãã«åä¼ãã¦ï¼å¦¹ã¨æã£ããå®ã¯å§ã®å¤ããæã¦ã姿ã§ããï¼ã¿ãããªã®ã WDDM ç°å¢ã§ã® DDBï¼ãã ã妹ã¯å¦¹ã®ã¾ã¾ãªã®ããããããï¼ãããæåã®æ®µè½ã§è¨ãããã£ããã¨ï¼
ãã¡ããï¼DDB ã常㫠DDB ãããã£ããã¨ããã¨ããã§ã¯ãªãï¼Virtual PC ã§ã¨ãã¥ã¬ã¼ãããã¦ããã¨ããï¼Remote Desktop çµç±ã®ã¨ãã¯ï¼å½ç¶ DDB ã®ããã©ã¼ãã³ã¹ã¯ããããããããªãã£ãã ããï¼WDDM ç°å¢ã§ã® DDB ã®è±¹å¤ãï¼æ´å²ãã²ãã¨ãã°ãããã¯ããã¦ã¨ããããã§ã¯ãªãï¼
ä¾ãã°éååæ°ã® NekoFlight ã«ã¯ï¼GDI ãã¼ã¹ã®ããªã´ã³æç»ã¢ã¼ããããï¼å人çã«ã¯ WinG ã¢ã¼ããããå³ããã£ã¦å¥½ãã ã£ãï¼ï¼ããã Virtual PC 2007 ã§åããã¨è¦ãã«å ªããªãæåã示ããï¼Remote Desktop çµç±ã§ã¯æ¯è¼çã¾ãã§ããï¼ã¡ããã©ä»æå 㧠Remote Desktop ã 2 段éçµç±ãã¦å®è¡ãã¦ããã¨ããã ãï¼ããã§ã 45 FPS åºã¦ããã®ã¯ç¢ºèªããï¼NekoFlight ã«ã¯ Wait è¨å®ããã£ã¦ï¼ããã©ã«ãè¨å®ã§ã¯ 70 FPS ãããã§ãµãããã¨ã«æ³¨æï¼ ï¼ã㦠Virtual PC 2007 ã§æ²æ¨ãªãï¼ã½ããã¦ã§ã¢å¦çãããã¨èãããã Vista ã§ã¯ã©ãã ãããï¼ çµæã¯æãã¦ããã»ã©æªããªãï¼æ¨ä»ã® CPU ã§ããã° NekoFlight ãã½ããã¦ã§ã¢ããªã´ã³ã§æç»ãã¦ãåå 60 FPS 確ä¿ã§ããã¨åãã£ãã ãã ã£ãï¼ãã®æå³ã¯ Virtual PC 2007 ããããæ®å¿µã¨ãããã¨ã«ãªãï¼
ä¸æ¹ã§ï¼å ã DIB ã¾ãã¯ç¬èªãããã¡ã§ CPU å¦çããã¦ããã±ã¼ã¹ã§ã¯ï¼ç°å¢ã®å¤åã«ããå·®ç°ãã»ã¨ãã©ã®å ´å CPU æ§è½ã«å¸°çµã§ããï¼ã©ãããé度ã§åããã CPU ï¼ã¨ããããã¡ã¤ã³ã¡ã¢ãªï¼ã®é度ã ãã§æ±ºã¾ãããï¼é常ã«æ§è½ãäºæ¸¬ããããã®ã ï¼ãã¨ã³ã§ã°ãããï¼ã¿ã¤ãã¼å¶å¾¡ã解é¤ããã°ï¼ Virtual PC 2007 ç°å¢ã§ã 90 FPS ã§åä½ãããã¨èãã¦ï¼é©ã人ã¯ã¾ã DIB ï¼ãã½ããã¦ã§ã¢æç»ï¼ã«ã¤ãã¦ç解ã足ããªãï¼å½æ主æµã ã£ã CPU ã§å¦çã§ããããã«ä½ããã¦ããã®ã ããï¼ä»ã® CPU ã§æããªããã¨ã¯ãªãã ããï¼ã¨å¹³ç¶ã¨è¨ã£ã¦ã®ãããããã§ãã*3ï¼
ãã¦ï¼ã¾ãã¾ã話ãè±ç·ããããåã«å ã«æ»ããï¼ä¹ ãã¶ãã«åä¼ãã DDB ã®æ§æ ¼ããã£ãã DIB ã«ãªã£ã¦ãã¾ã£ã¦ããï¼ ãã¼ããäºä»¶ã§ãï¼ ãªãã¼ã¹ã«ã¼ããªã¼ãã³ï¼ ã1 ç§éã«å¼ã¹ã BitBlt æ°ãä¸å®ãã1 ç§éã«è»¢éã§ãããã¯ã»ã«æ°ãä¸å®ã«ï¼ã ï¼ããã¾ã§ã¯ OK ã¨ããã*4ï¼åé¡ã¯ï¼ãã®çµæã©ããªããã ï¼å®ã¯ï¼ããã ãã§ãWindows Vista ã§ã¯ââ % ã 2D æ§è½æªåãã¨ããè¨äºãæ¸ãæ¾é¡ã¨ãã話ã«ãªãï¼ââ ã¯ã好ã¿ã§å¥½ããªæ°åãã©ããï¼ãã¤ã³ãã¯ãã³ããã¼ã¯ã¹ã³ã¢ã« Pixel Fill Rate ã使ãã¨ããã«ããï¼
ä¾ãã°ï¼ãã Windows XP ç°å¢ã§ã¯ï¼16Ã16ãã¯ã»ã«ã®ç»å転éã§ï¼DDB to DDB 㨠DIB to DIB ãæ®æããã¨ããï¼ãã£ã測ã£ãï¼ï¼ãã®å ´åï¼ãWindows XP ã§ã®ï¼512 à 512 ã®ç»å転éé度ãåºæºã«ãã¾ããã¨å®£è¨ããã°ããï¼GDI ã®ãã³ããã¼ã¯ãè¡ãã¨ã㯠DIB ã DDB ããæ示ããªãã¦è¯ãã¨ããå¤ãªæé»ã®äºè§£ããããããã®ã§ï¼ããã«å¾ããªãã®ã¯å人ãæ£ç´è ã§ããï¼ï¼ãã㯠XP ã§ã® DDB (512Ã512) to DDB ãåºæºã«ã¨ãã¨ãããï¼
ãããªããã§ãWindows Vista ã® 2D æç»ã¯ XP ã® 1000 åé ã!?ããæå¾ ãã¦ããããããªãã測ã£ãã¿ããï¼æ®å¿µï¼ãã£ãã® 100 åããå·®ãã¤ããªãã£ãï¼ã¾ããã¨ãã¨æ¡ã®è°è«ã ãï¼ããä¸å®ãã¯ãã¯ã»ã«æ°ãç¡é大ã«å¢å ããã¨ãã®æ¼¸è¿ç·ã®è°è«ã§ããï¼16Ã16ãã¯ã»ã«ãããã ã¨ããå°ããã©ã¡ã¼ã¿ãå¢ããå¿ è¦ãããã®ããç¥ããªãï¼èã£ã½ãè°è«ã ã 1 æ¡ãããã®ç³»çµ±èª¤å·®ã¯ãããããã®ã ããï¼100 åã§æºè¶³ãã¦ããããªããã°ï¼1024Ã1024 ã§ãï¼2048Ã2048 ã§ã好ããªã ãã¤ã³ãã¬ãèµ·ããã°ããã®ã ããï¼ï¼ããã§ããã¶ããã¯ã¨ãããªããããï¼ä»ã® GPU ã¯åãç©ã ï¼
例の記事ã«ã¤ãã¦æ£ç´ãªææ³ãè¨ãã°ï¼è¿å¹´ã® Office ã§ã¯ GDI çµç±ã®ãã¼ãã¦ã§ã¢ã®å©ç¨å¹çãããªãä¸ãã£ã¦ãã¦ãã¦ï¼ãããã½ããã¦ã§ã¢åãã¦ãã¾ã£ã¦ãï¼å®æ¸¬ã¹ã«ã¼ããã㯠1/5 ããè¦ãã1/3ã ç¨åº¦ã«ãªãã ãã§æ¸ãã§ããï¼ã®ããªï¼ ã¨ãã£ãã¨ããã ï¼åç´ã«ãã¼ãã¦ã§ã¢å¦çãã½ããã¦ã§ã¢å¦çã«ç½®ãæããã¤ã³ãã¯ãã«ãã¦ã¯ï¼1/5 1/3 ã¨ããã®ã¯ã©ããã¬ããããï¼ã½ããã¦ã§ã¢æç»ã®é¨åãããªããå ãã¦ãã¦ãããç·©è¡æã«ãªã£ã¦ãããï¼ããããããã«ãã¼ãã¦ã§ã¢ã®æ§è½ãå¼ãåºãã¦ããªãã£ããã©ã¡ããã ããï¼ãã¡ããï¼åãç°å¢ãæå
ã«ç¨æãã¦è©¦ãã¦ã¿ãªããã¨ã«ã¯æ£ç¢ºãªã¨ããã¯ä½ãè¨ããªãï¼ãããï¼2D CAD ãå
ã»ã©ã®ãããæ¾ã¾ãããã³ããã¼ã¯ã ã¨ï¼ãã£ã¨æ²æ¨ãªããã©ã¼ãã³ã¹ã»ãã¦ã³ã®æ°åãéç£ã§ããã ããã«ï¼ãã®æ°åã°ãããå¼ç¨ãããã®ã¯ã¡ãã£ã¨ãã£ãããªãæ°ãããï¼
ã¡ãªã¿ã« Office 㯠2007 ã«ãªã£ã¦ã¢ã«ãã¡ãã¬ã³ãã£ã³ã°ï¼å½ç¶ DIB çµç±ã® CPU å¦çã ããï¼ã®ä½¿ãã£ã·ãã«ããã«æè»ãããã£ã¦ããï¼ã¾ãã¾ã Intel ãã©ã°ãç«ã¡ã¾ããã§ããï¼
ã§ã¯ï¼WPF ã«ç§»è¡ããã°ä¸äº OK ãã¨ããã¨ï¼ããããããã©ã¼ãã³ã¹ç¹æ§ãå¾æ¥ã® GDI ã¨ã¯ç°ãªãã®ã§ï¼åç´ã«ç§»è¡ã¨ããããã«ããããªãã ããï¼åææ»ç¥ã¯é£ããï¼ããã«ï¼WPF èªä½ã¾ã ã¾ã ç¬éçã«èµ·åã¨ããé°å²æ°ã§ããªããï¼å®éã®ã¨ããï¼ãã©ã¦ã¶ä¸ã®ã½ããã¦ã§ã¢ã¬ã³ããªã³ã°ã§ååãªé åã¯é å½ã«ãã©ã¦ã¶ã«é£ããã¦ãããããªæ°ãããï¼ã¬ã¸ã§ããã«ãã¦ãï¼ããã°ã©ãã« WPF 触ãããããã¯ï¼æ¬è·ã®ãã¶ã¤ãããã« HTML æ¸ãã¦ãããæ¹ãè¦æ ãã®å¹³åå¤ã¯é«ããªãã ããï¼
ããããï¼æ£ç´ WPF ã¯ç¾ç©ãè¦ãã¾ã§ãã£ã¨é ·ãã¨æã£ã¦ããï¼ã ããã .NET ã¨ããã ãã§ï¼ãGC ã®ããã§ã»ã«ããããã¨ããã¤ã³ã©ã¤ã³å±éãã»ã«ããããã¨ãè¨ã人ãå¿ ãç¾ããã®ã«ï¼WPF ã RTM ãè¿ãã¦ã GC ã¨ããã®ãããã®ç¾ç¶ãä¼ããè¨äºãå ¨ç¶è¦ããããªãã¨ããã®ã¯ã©ããããã¨ãªã®ã ããï¼ è¦ããã«ï¼ã¿ããªæç« ãæ¸ãæã¯ãã£ã¦ããã³ããã¼ã¯ãã¨ã£ããèå¯ãããããæã¯ãªãã¨ãããã¨ãªãã ãããï¼
ãããWPF é ããï¼ããªæãã®ãã³ããã¼ã¯ãã¨ãããã¨ããæãªæ¹ãããã£ããããªãï¼WPF のパフォーマンスガイドã§æ¸ããã¦ãããã¨ã®å対ãé¸ã³ç¶ãããã¨ã§æ¯è¼ççæéã®ãã¡ã«å®ç¾ã§ããã¨æãï¼ããã¡ãã£ã¨ããã¢ãã¯ãªäººã¯ï¼ä¾ãã° WinHEC 2004 ã®ã¨ãã®ãããæå¥ï¼ãDirectX 10 ä¸ä»£ï¼ä»ã§è¨ãã¨ããã® Direct3D9 Ex ã«è©²å½ï¼ã® PixelShader 㧠1 M Glyphs/sec å®ç¾ããã(id:NyaRuRu:20060301#p2)ããï¼æ¬å½ã« WPF ã§å®ç¾ã§ãã¦ãããï¼ãªãã¦ã®ã¯é¢ç½ãæ¤è¨¼ãã¿ãããããªãï¼
ãã¨ï¼ä»æ´ã ãã© GDI ãã³ãæ¸ã人ã¯ï¼æ¸¬ã£ã¦ããã®ã DDB ã¸ã®å¦çãªã®ã DIB ã¸ã®å¦çãªã®ãï¼ã¯ãã¾ã DDB to DDBï¼DDB to DIBï¼DIB to DDBï¼DIB to DIB ãªã®ããããã¯ï¼æè¨ãã¦æ¬²ãããã®ã ã¨æã*5ï¼
ããããï¼ã»ã¨ãã©ç¢ºå®ã« CPU å¾éã«ãªã£ã¦ããã¹ã³ã¢ã«ã¤ãã¦ã¯ï¼å®éã« CPU å¾éãã©ããã測å®ãã¦ãããªãã¨ï¼èªè
ãå©ç¨è
ãããããªã«ã¼ããè²·ãæããã°ããã®ããªï¼ãã¨ãã£ãããã¬æããæ±ããããªãï¼ããã¯ããã¾ãã ã¨æãï¼
ãªããæå¾ã¯æç´ã°ã£ããã«ãªã£ã¡ãã£ããã©ï¼ã¾ãæé»éå¦ãªãã¦ãããªãã®ã¨ãããã¨ã§ï¼
å¢ãã§æ¸ãã¡ãã£ãã®ã§ï¼ä½ãäºå®èª¤èªããããã¾ãããï¼ãææã®ã»ã©ãããããé¡ããã¾ãï¼
*1:ããããã° Vista ã§ã¦ã¼ã¶ã¢ã¼ããã©ã¤ãå°å ¥ãããããããæå ¥ã³ã¹ãä¸ãããã¿ãããªè©±ãããã¾ãããï¼ã©ããªã£ããã§ãããããï¼
*2:[http://www.codeproject.com/vista/VGGlassIntro.asp:title= Vista Goodies in C++: Using Glass in Your UI]
*3:ã¨ã¯ããï¼å¤§æµãã®æã®çºè¨ã¯ã¡ããã¨åãã¦ããã®ã確èªãã¦ããå¾ä»ã§çç±è¿°ã¹ã¦ããã°ãããªã®ã§ï¼æªæ¥äºè¨è½åãæå¾ ãã¦ã¯ãããªãï¼Trick ã«åºã¦ããæªå¾³éè½åè ã¿ãããªãã®ã
*4:ã¨ã¯è¨ã£ã¦ãï¼å ã ã½ããã¦ã§ã¢å¦çããã¦ãããããé¨åã«ã¤ãã¦ã¯æ¯ãèãããããããï¼ã¡ã¾ãã® GDI ãã³ããã¼ã¯ã§ã¯ï¼DWM On ã®æ¹ã Off ã®ã¨ãããããã¹ãã¬ã³ããªã³ã°ç³»ã®ã¹ã³ã¢ã¯é«ãããã§ãã
*5:ãã®ç¹ id:LaMoo æ°ã®[http://lamoo.s53.xrea.com/develop/gdiplus/gdiplus_blt.html:title=ãã]ã¨ãããã