{"id":53,"date":"2014-07-28T18:20:48","date_gmt":"2014-07-28T18:20:48","guid":{"rendered":"https:\/\/blogs.scummvm.org\/subr3v\/?p=53"},"modified":"2022-05-23T18:22:46","modified_gmt":"2022-05-23T18:22:46","slug":"dirty-rectangle-system-pt-3","status":"publish","type":"post","link":"https:\/\/blogs.scummvm.org\/subr3v\/2014\/07\/28\/dirty-rectangle-system-pt-3\/","title":{"rendered":"Dirty Rectangle System Pt 3"},"content":{"rendered":"<p>In the past days I&#8217;ve been working on dirty rectangle system and I wanted to share some results I have achieved in this blog post:<\/p>\n<p>First of all, I had to introduce a new type of draw call that turned out to be needed: Clear Buffer; this type of draw call just clears either the color or the z buffer (or both, if needed) and it always has a full rectangle screen as dirty region.<\/p>\n<p>When I had all the draw call types implemented I just had to make them work in deferred mode: in order to make this possible I had to track down all the state that was needed by TinyGL to perform that specific draw call and then store it so that I could apply this state before performing the actual drawing logic.<br \/>\nHaving done this, sub task 1 proved to be easily implemented as I just had to store all the draw calls in a queue and then perform them sequentially when the frame was marked as &#8220;done&#8221;.<\/p>\n<p>With sub task 1 done I then proceeded with the calculation of which portion of the screen a draw call was going to affect: calculating this was rather easy for blit draw calls but it turns out that calculating what a rasterization draw call is going to affect isn&#8217;t very complex either: I just had to calculate a bounding rectangle that contained all the vertices (after those were transformed to screen space).<\/p>\n<p>Since I had all the information about the dirty regions of the screen I wanted to display this information on the screen so that I could see which part was affected by which type of draw call so here&#8217;s some screenshots (red rectangles are blitting draw calls while green rectangles are rasterization draw calls):<\/p>\n<p><a href=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/yTM9KlB.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-55\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/yTM9KlB.png\" alt=\"\" width=\"656\" height=\"518\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/yTM9KlB.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/yTM9KlB-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a><a href=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/S5NPhQh.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-56\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/S5NPhQh.png\" alt=\"\" width=\"656\" height=\"518\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/S5NPhQh.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/S5NPhQh-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a><a href=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/apF1Ee8.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-57\" src=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/apF1Ee8.png\" alt=\"\" width=\"656\" height=\"518\" srcset=\"https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/apF1Ee8.png 656w, https:\/\/blogs.scummvm.org\/subr3v\/wp-content\/uploads\/sites\/41\/2014\/07\/apF1Ee8-300x237.png 300w\" sizes=\"auto, (max-width: 656px) 100vw, 656px\" \/><\/a>Now I only need to work on the last two sub tasks:<\/p>\n<ol>\n<li>Implement the logic behind draw calls that allows the caller to specify a clipping rectangle for that specific instance.<\/li>\n<li>Implement the logic that detects the difference between draw calls and performs clipping on them.<\/li>\n<\/ol>\n<p>But I&#8217;ll write more about these as the work progresses, as for now&#8230; stay tuned!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the past days I&#8217;ve been working on dirty rectangle system and I wanted to share some results I have achieved in this blog post: First of all, I had to introduce a new type of draw call that turned out to be needed: Clear Buffer; this type of draw call just clears either the [&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-53","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/posts\/53","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=53"}],"version-history":[{"count":2,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/posts\/53\/revisions"}],"predecessor-version":[{"id":58,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/posts\/53\/revisions\/58"}],"wp:attachment":[{"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/media?parent=53"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/categories?post=53"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.scummvm.org\/subr3v\/wp-json\/wp\/v2\/tags?post=53"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}