{"id":62,"date":"2014-08-11T18:24:05","date_gmt":"2014-08-11T18:24:05","guid":{"rendered":"https:\/\/blogs.scummvm.org\/subr3v\/?p=62"},"modified":"2022-05-23T18:26:30","modified_gmt":"2022-05-23T18:26:30","slug":"dirty-rectangles-system-performance-considerations","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/subr3v\/2014\/08\/11\/dirty-rectangles-system-performance-considerations\/","title":{"rendered":"Dirty Rectangles system performance considerations"},"content":{"rendered":"<p>As I&#8217;ve spent the last week fixing some minor bugs and documenting code, I wanted to analyse better the effects of this system on the current games.<br \/>\nI&#8217;ve done some profiling by measuring fps in two modes: analysis and release;<br \/>\nAnalysis build is a build with less optimizations enabled and debug symbols whilst release mode is the classic o3 build with every possible optimization enabled.<br \/>\nThe scenes used for these tests are the following:<br \/>\nEMI &#8211; ship scene, lucre island and act 1 beginning.<br \/>\nGrim demo: first scenes of the demo.<\/p>\n<p>Here are some screenshots for clarity.<\/p>\n<div id='gallery-1' class='gallery galleryid-62 gallery-columns-1 gallery-size-full'><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/1.png'><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"518\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/1.png\" class=\"attachment-full size-full\" alt=\"\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/1.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/1-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/2.png'><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"518\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/2.png\" class=\"attachment-full size-full\" alt=\"\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/2.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/2-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/3.png'><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"518\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/3.png\" class=\"attachment-full size-full\" alt=\"\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/3.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/3-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/4.png'><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"518\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/4.png\" class=\"attachment-full size-full\" alt=\"\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/4.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/4-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/5.png'><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"518\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/5.png\" class=\"attachment-full size-full\" alt=\"\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/5.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/5-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/6.png'><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"518\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/6.png\" class=\"attachment-full size-full\" alt=\"\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/6.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/6-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>\n\t\t\t<\/div><\/figure><figure class='gallery-item'>\n\t\t\t<div class='gallery-icon landscape'>\n\t\t\t\t<a href='https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/7.png'><img loading=\"lazy\" decoding=\"async\" width=\"656\" height=\"518\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/7.png\" class=\"attachment-full size-full\" alt=\"\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/7.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/08\/7-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>\n\t\t\t<\/div><\/figure>\n\t\t<\/div>\n\n<p>And here are some results.<\/p>\n<pre>Before dirty rectangle system (analysis \/ release):\r\nShip scene: 13.50 \/ 57 fps\r\nLucre Island: 9 \/ 47 fps\r\nAct 1 Beginning: 25 \/ 135 fps\r\nGrim scene 1: 50 \/ 160 fps\r\nGrim scene 2: 62 \/ 220 fps\r\nGrim scene 3: 57 \/ 243 fps\r\nGrim scene 4: 60 \/ 205 fps<\/pre>\n<pre>After dirty rectangle system (analysis \/ release):\r\nShip scene: 12 \/ 55 fps\r\nLucre Island: 9 \/ 45 fps\r\nAct 1 Beginning: 24 \/ 133 fps\r\nGrim scene 1: 23 \/ 136 fps\r\nGrim scene 2: 62 \/ 500 fps\r\nGrim scene 3: 27 \/ 180 fps\r\nGrim scene 4: 42 \/ 250 fps<\/pre>\n<p>As we can see dirty rects introduces an heavy overhead, especially with analysis build; but release build is somewhat balanced: the fps is pretty much the same for crowded scenes whereas it goes up by quite a bit if the scene has only a few animated objects (like grim scene 2 or scene 4, where animated objects are small and dirty rects yield some performance advantage).<\/p>\n<p>In my personal opinion dirty rects should only be employed on some specific scenarios, as its overhead generally slows down the code and it only shines in some cases.<br \/>\nDirty rects is a system that is probably better off being used in 2D games where screen changes are more controllable and there is no need to perform more calculation to know which region of the screen is going to be affected.<\/p>\n<p>Developing this system was quite challenging and it took a lot of time but I think that the overall task was beneficial because it gave us an insight on how this could have affected performance: I think that implementing this system on an higher level of abstraction might result in being more effective but more research would be required for doing so (such system would not be applicable for this project though as the engine has to support a vast variety of games).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As I&#8217;ve spent the last week fixing some minor bugs and documenting code, I wanted to analyse better the effects of this system on the current games. I&#8217;ve done some profiling by measuring fps in two modes: analysis and release; Analysis build is a build with less optimizations enabled and debug symbols whilst release mode [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":3,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":72,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/posts\/62\/revisions\/72"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}