{"id":925,"date":"2017-11-07T06:00:01","date_gmt":"2017-11-07T13:00:01","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/directx\/?p=925"},"modified":"2017-11-07T06:00:01","modified_gmt":"2017-11-07T13:00:01","slug":"announcing-new-directx-12-features","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/directx\/announcing-new-directx-12-features\/","title":{"rendered":"Announcing new DirectX 12 features"},"content":{"rendered":"<h2>Announcing new DirectX 12 features<\/h2>\n<p>We\u2019ve come a long way since we launched DirectX 12 with Windows 10 on July 29, 2015. Since then, we\u2019ve heard every bit of feedback and improved the API to enhance stability and offer more versatility. Today, developers using DirectX 12 can build games that have better graphics, run faster and that are more stable than ever before. Many games now run on the latest version of our groundbreaking API and we\u2019re confident that even more anticipated, high-end AAA titles will take advantage of DirectX 12.<\/p>\n<p>DirectX 12 is ideal for powering the games that run on PC and Xbox,\u00a0which as of <a href=\"https:\/\/news.microsoft.com\/2017\/11\/06\/worlds-most-powerful-console-xbox-one-x-launches-worldwide\/\">yesterday<\/a> is the most powerful console on the market. Simply put, our consoles work best with our software: DirectX 12 is perfectly suited for native 4K games on the Xbox One X.<\/p>\n<p>In the Fall Creator\u2019s Update, we\u2019ve added features that make it easier for developers to debug their code. In this article, we\u2019ll explore how these features work and offer a recap of what we added in Spring Creator\u2019s Update.<\/p>\n<p>But first, let\u2019s cover how debugging a game or a program utilizing the GPU is different from debugging other programs.<\/p>\n<p>As covered previously, DirectX 12 offers developers unprecedented low-level access to the GPU (check out Matt Sandy\u2019s detailed <a href=\"https:\/\/devblogs.microsoft.com\/directx\/directx-12\/\">post<\/a> for more info). But even though this enables developers to write code that\u2019s substantially faster and more efficient, this comes at a cost: the API is more complicated, which means that there are more opportunities for mistakes.<\/p>\n<p>Many of these mistakes happen GPU-side, which means they are a lot more difficult to fix. When the GPU crashes, it can be difficult to determine exactly what went wrong. After a crash, we\u2019re often left with little information besides a cryptic error message. The reason why these error messages can be vague is because of the inherent differences between CPUs and GPUs. Readers familiar with how GPUs work should feel free to skip the next section.<\/p>\n<h3>The CPU-GPU Divide<\/h3>\n<p>Most of the processing that happens in your machine happens in the CPU, as it\u2019s a component that\u2019s designed to resolve almost any computation it it\u2019s given. It does many things, and for some operations, foregoes efficiency for versatility. This is the entire reason that GPUs exist: to perform better than the CPU at the kinds of calculations that power the graphically intensive applications of today. Basically, rendering calculations (i.e. the math behind generating images from 2D or 3D objects) are small and many: performing them in parallel makes a lot more sense than doing them consecutively. The GPU excels at these kinds of calculations. This is why game logic, which often involves long, varied and complicated computations, happens on the CPU, while the rendering happens GPU-side.<\/p>\n<p>Even though applications run on the CPU, many modern-day applications require a lot of GPU support. These applications send instructions to the GPU, and then receive processed work back. For example, an application that uses 3D graphics will tell the GPU the positions of every object that needs to be drawn. The GPU will then move each object to its correct position in the 3D world, taking into account things like lighting conditions and the position of the camera, and then does the math to work out what all of this should look like from the perspective of the user. The GPU then sends back the image that should be displayed on system\u2019s monitor.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/Capture5.png\"><img decoding=\"async\" width=\"903\" height=\"264\" class=\"alignnone wp-image-956\" alt=\"\" src=\"http:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/Capture5.png\" srcset=\"https:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/Capture5.png 636w, https:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/Capture5-300x88.png 300w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/a><\/p>\n<p><i>To the left, we see a camera, three objects and a light source in Unity, a game development engine. <\/i><i>To the right, we see how the GPU renders these 3-dimensional objects onto a 2-dimensional screen, given the camera position and light source.\u00a0<\/i><\/p>\n<p><i><\/i>For high-end games with thousands of objects in every scene, this process of turning complicated 3-dimensional scenes into 2-dimensional images happens at least 60 times a second and would be impossible to do using the CPU alone!<\/p>\n<p>Because of hardware differences, the CPU can\u2019t talk to the GPU directly: when GPU work needs to be done, CPU-side orders need to be translated into native machine instructions that our system\u2019s GPU can understand. This work is done by hardwire drivers, but because each GPU model is different, this means that the instructions delivered by each driver is different! Don\u2019t worry though, here at Microsoft, we devote a substantial amount of time to make sure that GPU manufacturers (AMD, Nvidia and Intel) provide drivers that DirectX can communicate with across devices. This is one of the things that our API does; we can see DirectX as the software layer between the CPU and GPU hardware drivers.<\/p>\n<h3>Device Removed Errors<\/h3>\n<p>When games run error-free, DirectX simply sends orders (commands) from the CPU via hardware drivers to the GPU. The GPU then sends processed images back. After commands are translated and sent to the GPU, the CPU cannot track them anymore, which means that when the GPU crashes, it\u2019s really difficult to find out what happened. Finding out which command caused it to crash used to be almost impossible, but we\u2019re in the process of changing this, with two awesome new features that will help developers figure out what exactly happened when things go wrong in their programs.<\/p>\n<p>One kind of error happens when the GPU becomes temporarily unavailable to the application, known as device removed or device lost errors. Most of these errors happen when a driver update occurs in the middle of a game. But sometimes, these errors happen because of mistakes in the programming of the game itself. Once the device has been logically removed, communication between the GPU and the application is terminated and access to GPU data is lost.<\/p>\n<h3>Improved Debugging: Data<\/h3>\n<p>During the rendering process, the GPU writes to and reads from data structures called resources. Because it takes time to do translation work between the CPU and GPU, if we already know that the GPU is going to use the same data repeatedly, we might as well just put that data straight into the GPU. In a racing game, a developer will likely want to do this for all the cars, and the track that they\u2019re going to be racing on. All this data will then be put into resources. To draw just a single frame, the GPU will write to and read from many thousands of resources.<\/p>\n<p>Before the Fall Creator\u2019s Update, applications had no direct control over the underlying resource memory. However, there are rare but important cases where applications may need to access resource memory contents, such as right after device removed errors.<\/p>\n<p>We\u2019ve implemented a tool that does exactly this. Developers with access to the contents of resource memory now have substantially more useful information to help them determine exactly where an error occurred. Developers can now optimize time spent trying to determine the causes of errors, offering them more time to fix them across systems.<\/p>\n<p>For technical details, see the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/mt813612(v=vs.85).aspx\">OpenExistingHeapFromAddress\u00a0<\/a>documentation.<\/p>\n<h3>Improved Debugging: Commands<\/h3>\n<p>We\u2019ve implemented another tool to be used alongside the previous one. Essentially, it can be used to create markers that record which commands sent from the CPU have already been executed and which ones are in the process of executing. Right after a crash, even a device removed crash, this information remains behind, which means we can quickly figure out which commands might have caused it\u2014information that can significantly reduce the time needed for game development and bug fixing.<\/p>\n<p><span style=\"float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px\">For technical details, see the <\/span><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/mt844818(v=vs.85).aspx\">WriteBufferImmediate<\/a><span style=\"float: none;background-color: transparent;color: #333333;cursor: text;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif;font-size: 16px;font-style: normal;font-variant: normal;font-weight: 400;letter-spacing: normal;line-height: 24px;text-align: left;text-decoration: none;text-indent: 0px\"> documentation.<\/span><\/p>\n<p>What does this mean for gamers? Having these tools offers direct ways to detect and inform around the root causes of what\u2019s going on inside your machine. It&#8217;s like the difference between trying to figure out what\u2019s wrong with your pickup truck based on hot smoke coming from the front versus having your Tesla\u2019s internal computer system telling you exactly which part failed and needs to be replaced.<\/p>\n<p>Developers using these tools will have more time to build high-performance, reliable games instead of continuously searching for the root causes of a particular bug.<\/p>\n<h2><strong>Recap of Spring Creator\u2019s Update<\/strong><\/h2>\n<p>In the Spring Creator\u2019s Update, we introduced two new features: Depth Bounds Testing and Programmable MSAA. Where the features we rolled out for the Fall Creator\u2019s Update were mainly for making it easier for developers to fix crashes, Depth Bounds Testing and Programmable MSAA are focused on making it easier to program games that run faster with better visuals. These features can be seen as additional tools that have been added to a DirectX developer\u2019s already extensive tool belt.<\/p>\n<h3>Depth Bounds Testing<\/h3>\n<p>Assigning depth values to pixels is a technique with a variety of applications: once we know how far away pixels are from a camera, we can throw away the ones too close or too far away. The same can be done to figure out which pixels fall inside and outside a light\u2019s influence (in a 3D environment), which means that we can darken and lighten parts of the scene accordingly. We can also assign depth values to pixels to help us figure out where shadows are. These are only some of the applications of assigning depth values to pixels; it\u2019s a versatile technique!<\/p>\n<p>We now enable developers to specify a pixel\u2019s minimum and maximum depth value; pixels outside of this range get discarded. Because doing this is now an integral part of the API and because the API is closer to the hardware than any software written on top of it, discarding pixels that don\u2019t meet depth requirements is now something that can happen faster and more efficiently than before.<\/p>\n<p>Simply put, developers will now be able to make better use of depth values in their code and can free GPU resources to perform other tasks on pixels or parts of the image that aren\u2019t going to be thrown away.<\/p>\n<p>Now that developers have another tool at their disposal, for gamers, this means that games will be able to do more for every scene.<\/p>\n<p>For technical details, see the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/mt492658(v=vs.85).aspx\">OMSetDepthBounds<\/a> documentation.<\/p>\n<h3>Programmable MSAA<\/h3>\n<p>Before we explore this feature, let\u2019s first discuss anti-aliasing.<\/p>\n<p>Aliasing refers to the unwanted distortions that happen during the rendering of a scene in a game. There are two kinds of aliasing that happen in games: spatial and temporal.<\/p>\n<p>Spatial aliasing refers to the visual distortions that happen when an image is represented digitally. Because pixels in a monitor\/television screen are not infinitely small, there isn\u2019t a way of representing lines that aren\u2019t perfectly vertical or horizontal on a monitor. This means that most lines, instead of being straight lines on our screen, are not straight but rather approximations of straight lines. Sometimes the illusion of straight lines is broken: this may appear as stair-like rough edges, or \u2018jaggies\u2019, and spatial anti-aliasing refers to the techniques that programmers use to make these kinds edges smoother and less noticeable. The solution to these distortions is baked into the API, with hardware-accelerated MSAA (Multi-Sample Anti-Aliasing), an efficient anti-aliasing technique that combines quality with speed. Before the Spring Creator\u2019s Update, developers already had the tools to enable MSAA and specify its granularity (the amount of anti-aliasing done per scene) with DirectX.<\/p>\n<p><a href=\"http:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/sidebyside.png\"><img decoding=\"async\" width=\"1149\" height=\"502\" class=\"alignnone wp-image-926\" alt=\"\" src=\"http:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/sidebyside.png\" srcset=\"https:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/sidebyside.png 1314w, https:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/sidebyside-300x131.png 300w, https:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/sidebyside-768x335.png 768w, https:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/sidebyside-1024x447.png 1024w\" sizes=\"(max-width: 1149px) 100vw, 1149px\" \/><\/a><a href=\"http:\/\/devblogs.microsoft.com\/directx\/wp-content\/uploads\/sites\/42\/2017\/11\/sidebyside.png\"><\/a><\/p>\n<p><em>Side-by-side comparison of the same scene with spatial aliasing (left) and without (right). Notice in particular the jagged outlines of the building and sides of the road in the aliased image. This still was taken from <a href=\"https:\/\/www.forzamotorsport.net\/en-us\/news\/fm6_apex_announce\">Forza Motorsport 6: Apex<\/a>.<\/em><\/p>\n<p>But what about temporal aliasing? Temporal aliasing refers to the aliasing that happens over time and is caused by the sampling rate (or number of frames drawn a second) being slower than the movement that happens in scene. To the user, things in the scene jump around instead of moving smoothly. <a href=\"https:\/\/www.youtube.com\/watch?v=lzndRrMiuNA\">This<\/a> YouTube video does an excellent job showing what temporal aliasing looks like in a game.<\/p>\n<p>In the Spring Creator\u2019s Update, we offer developers more control of MSAA, by making it a lot more programmable. At each frame, developers can specify how MSAA works on a sub-pixel level. By alternating MSAA on each frame, the effects of temporal aliasing become significantly less noticeable.<\/p>\n<p>Programmable MSAA means that developers have a useful tool in their belt. Our API not only has native spatial anti-aliasing but now also has a feature that makes temporal anti-aliasing a lot easier. With DirectX 12 on Windows 10, PC gamers can expect upcoming games to look better than before.<\/p>\n<p>For technical details, see the <a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/windows\/desktop\/mt492660(v=vs.85).aspx\">SetSamplePositions<\/a> documentation.<\/p>\n<h3>Other Changes<\/h3>\n<p>Besides several bugfixes, we\u2019ve also updated our graphics debugging software, PIX, every month to help developers optimize their games. Check out the <a href=\"https:\/\/devblogs.microsoft.com\/pix\/introducing-pix-on-windows-beta\/\">PIX blog<\/a> for more details.<\/p>\n<p>Once again, we appreciate the feedback shared on DirectX 12 to date, and look forward to delivering even more tools, enhancements and support in the future.<\/p>\n<p>Happy developing and gaming!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Announcing new DirectX 12 features We\u2019ve come a long way since we launched DirectX 12 with Windows 10 on July 29, 2015. Since then, we\u2019ve heard every bit of feedback and improved the API to enhance stability and offer more versatility. Today, developers using DirectX 12 can build games that have better graphics, run faster [&hellip;]<\/p>\n","protected":false},"author":1746,"featured_media":12651,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[13,14,18,21,27,31],"class_list":["post-925","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-directx","tag-direct3d","tag-direct3d12","tag-directx-12","tag-directx12","tag-gaming","tag-graphics"],"acf":[],"blog_post_summary":"<p>Announcing new DirectX 12 features We\u2019ve come a long way since we launched DirectX 12 with Windows 10 on July 29, 2015. Since then, we\u2019ve heard every bit of feedback and improved the API to enhance stability and offer more versatility. Today, developers using DirectX 12 can build games that have better graphics, run faster [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/925","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/users\/1746"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/comments?post=925"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/posts\/925\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media\/12651"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/media?parent=925"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/categories?post=925"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/directx\/wp-json\/wp\/v2\/tags?post=925"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}