450 likes | 745 Views
Innovations in high p erformance 2D graphics with DirectX. Dan McLachlan Principal Program Manager Lead Microsoft Corporation 3-191. Agenda. DirectX performance improvements N ew capabilities in Windows 8.1 Text Geometry Imaging. DirectX technologies are c ore to Windows.
E N D
Innovations in high performance 2D graphics with DirectX Dan McLachlan Principal Program Manager Lead Microsoft Corporation 3-191
Agenda • DirectX performance improvements • New capabilities in Windows 8.1 • Text • Geometry • Imaging
Agenda • DirectX performance improvements • New capabilities in Windows 8.1 • Text • Geometry • Imaging
Existing industry approaches • App does text analysis and replaces code points with bitmaps • Font foundries provide multiple fonts that are aligned, and app draws same text in multiple fonts to get layering • Fonts with embedded bitmaps
Multi-color fonts in Windows 8.1 • Supported through new multi-layer glyphs • Extended the Windows OpenType implementation • Still text, so everything else just works. • New system font: Segoe UI Emoji • Supports the most commonly used emoji code points
Enabling color – DrawTextLayout • d2dContext->DrawTextLayout( • D2D1::Point2F(x, y), • m_layout.Get(), • D2D1_DRAW_TEXT_OPTIONS_CLIP • ); | D2D1_DRAW_TEXT_OPTIONS_ENABLE_COLOR_FONT
Enabling color - DrawGlyphRun • d2dContext->DrawGlyphRun(…, glyphRun, … color, …);
Enabling color - DrawGlyphRun • colorlayers = dWrite->TranslateColorGlyphRun(…, glyphRun, …); • Foreachlayer in colorLayers { • d2dContext->DrawGlyphRun(…, layer.GlyphRun, … layer.color, …); • }
Agenda • DirectX performance improvements • New capabilities in Windows 8.1 • Text • Geometry • Imaging
2D geometry rendering performance • Complex geometry rendering CPU bound • Existing optimization techniques have limitations • Creating bitmaps • Not fully robust to rotations and scales • Bitmaps consume significant resources • Geometry meshes • Only aliased rendering is available
Geometry Rendering Solutions • DirectX 11.1 hardware utilization • Geometry needs to be specified with D2D1_FILL_MODE_ALTERNATE • Geometry Realizations
Geometry realizations • New Direct2D Geometry class • Enables amortizing generation costs over multiple frames • Creates device-dependent representation • Drawing uses minimal CPU resources • Tuned for optimal GPU resource usage
Draw or fill geometryOnce per frame Geometry CPU Work GPU Work Rendered on GPU
Create geometry realizationOnce per primitive Geometry CPU Work Geometry Realization Object
Draw geometry realizationOnce per frame GPU Work Geometry Realization Rendered on GPU
Will geometry realization work for you? • Is your geometry static? • Are the applied transformations only translations, rotations and uniform scales? • How you generate realizations will depend on your range of scale factors.
Agenda • DirectX performance improvements • New capabilities in Windows 8.1 • Text • Geometry • Imaging
Improving image effects performance • Defer rasterization as much as possible • Avoid using a RenderTarget bitmap only once • CommandLists can be helpful when different sections of code generate intermediates • Minimize redundant rasterization • Use RenderTarget bitmaps when you need the same image as input to multiple effects • CommandLists are a tool here too
Agenda • DirectX performance improvements • New capabilities in Windows 8.1 • Text • Geometry • Imaging • Image Compression
Image considerations in apps • Large part of memory utilization and start up time • Quality versus space trade-offs • Direct2D supports two new compressed image formats
Analysis of memory usage • Comparison of image data for some common Windows 8 apps.
Block compression formats • Native graphics hardware support • BC1 – BC3 DirectX 9+ hardware • BC4 – BC5 DirectX 10+ hardware • BC6 – BC7 DirectX 11+ hardware • 4-8 bits per pixel • Can be up to 87.5 % smaller in memory than RGBA • Lossy image compression • MUST be a multiple of 4 in all dimensions
Block compression 00 00 01 02 01 02 01 01 03 03 01 00 02 02 01 00 4x4 block Encoding Color1 Color2 16 – 2bit encoded colors
Block compression • Choosing your Block compression format
Cut The Rope image comparison Startbg.jpg (Background image) Original BGRA format (7.91MB decoded)
Cut The Rope image comparison Startbg.jpg (Background image) BC1 compression (0.99MB decoded)
Jpeg to BC-1 Jpeg version1 BC-1 version 1Decoding does not include YCBCR optimizations
Using block compressed images • Use current authoring pipeline • Block compressed images are a runtime format • Generate them as part of your app build/packaging
Using image compression • Jpeg YCBCR compression • User assets • No conversion necessary • 25% - 63% working set savings over RGBA data • Smaller disk footprint compared to DDS • Block compression (DDS) • App-local assets • Build time conversion • Better with natural images than synthetic ones • 75% - 87.5% working set savings over RGBA data
Summary • DirectX performance improvements • New capabilities in Windows 8.1 • Text • Geometry • Imaging
Leverage new Windows 8.1 features to make your apps fast and fluid
Call to action • Use new color fonts for emoticons AND scalable UI elements • Take advantage of Geometry Realizations to improve geometry rendering performance • Use compressed image formats and maintain compression on GPU for faster load times and better resource utilization
Resources • Color Fonts Sample • Geometry Realization Sample • D2D1_FILL_MODE enumeration • Block Compressed Images Sample • JPEG YCBCR Optimizations Sample • Block Compression (MSDN).
Required Slide *delete this box when your slide is finalized Your MS Tag will be inserted here during the final scrub. Evaluate this session • Scan this QR codeto evaluate this session and be automatically entered in a drawing to win a prize!