{"id":3301,"date":"2009-05-07T08:00:06","date_gmt":"2009-05-07T12:00:06","guid":{"rendered":"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=3301"},"modified":"2010-10-24T08:05:56","modified_gmt":"2010-10-24T13:05:56","slug":"procedural-city-part-14-feedback-and-assessment","status":"publish","type":"post","link":"https:\/\/www.shamusyoung.com\/twentysidedtale\/?p=3301","title":{"rendered":"Procedural City, Part 14: Feedback and Assessment"},"content":{"rendered":"<p><strong>Short version:<\/strong>  <\/p>\n<p>Thanks for all the feedback on Pixel City.  Stating your version of windows and graphics chipset along with problem reports is invaluable.  The current release version has a rather embarrassing memory leak in it, so prolonged use will make the system thrash for a while when you exit it.  For those of you compiling along at home, this is already fixed in the codebase and you should integrate <a href=\"http:\/\/code.google.com\/p\/pixelcity\/source\/list\">revisions #11 and #12<\/a>, regardless of what else you&#8217;re doing with your own forked version.  <\/p>\n<p>For this reason, I&#8217;ll be issuing at least one more build of Pixel City that fixes this problem.   I&#8217;d like to kill a few other issues in that same release if I can gather the data needed to do so.<\/p>\n<p><strong>Long version:<\/strong>  <\/p>\n<p>I want to start with <a href=\"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=3237\">this comment<\/a> from Brandon:<\/p>\n<div class=\"quote\">I&#39;m using an ancient machine (think 2003 or 2004). Barely 1GB of DDR RAM across three sticks, I don&#39;t even want to know what my processor is like, and the best thing in here is a 512mb AGP graphics card. But the screensaver runs relatively smoothly, provided I have absolutely nothing else running on my computer. With about four other applications open I average 15-20fps and managed to get up to 50fps when the camera swooped low and followed a street<\/div>\n<p>This is very much what I expected: Just barely useful on a five year old machine.  That fits with the my impressions on what we should be seeing, which is why I was very taken aback by reports from people with two or three year old machines that said the thing took ten minutes to start and ran at 2 frames per second.  This was very alarming and had me worried that I&#8217;d somehow grossly misjudged what I was asking of the graphics hardware and the CPU.  Brandon&#8217;s comment hints that I was probably right in the first place, and that these extreme slowdowns are coming from somewhere else.  <\/p>\n<p>Also interesting are reports from people claiming that <a href=\"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=3237#comment-121763\">it doesn&#8217;t work with multi-monitor setups<\/a>, and other comments saying that <a href=\"http:\/\/www.shamusyoung.com\/twentysidedtale\/?p=3237#comment-121764\">it does<\/a>.<\/p>\n<p>The screensaver functionality was added late in the project, and was thrown together more or less at the last minute.  I was slightly dubious about taking a system I&#8217;d built carefully (but not adequately tested) and setting it atop a system I&#8217;d built in great haste and hadn&#8217;t tested at all. <\/p>\n<p>For the record, the program makes no special effort to support or not support multi-monitor setups.  How Windows screensavers work is that your program is invoked and instead of manually creating a window yourself like you do in most programs, you are simply given a pre-existing window to use.  This can be a bit strange when you&#8217;ve got a 1920&#215;1200 monitor in front of you and (say) a 1024&#215;768 monitor to one side and Windows is creating a single frame to encompass them both.  One obvious problem is that windows must be rectangular.   Assuming the small window occupies the same vertical space as the larger one (which is by no means certain) then your program is going to have a 2944&#215;1200 region to fill.  Even worse, within that render-hungry expanse is going to be a 1024&#215;432 rectangle that&#8217;s being rendered and then discarded. <\/p>\n<p>(EDIT: And just to be clear, the program doesn&#8217;t really have any idea that it IS on a multi-monitor setup.  It&#8217;s just handed a window.  I&#8217;m sure it&#8217;s POSSIBLE to query the setup and the monitor sizes and their geometic relationship, but I&#8217;m sure that would be a lot of work, and I&#8217;m not even sure what benefit it would be.  The program still has just one window and one render context.)<\/p>\n<p>How that window behaves and what monitors is spans is very much open to how multi-monitor support has been implemented.  I know some graphics cards have their own multi-monitor setups that exist outside of the same functionality as provided by windows.  Couple this with the fact that different versions of windows probably have different ideas about how window regions are stitched together and you have a recipe for something that will take a lot of time and experimentation with different monitor setups to understand.  Keep in mind that I was never really that interested in wrangling with the Windows screensaver functionality.  My real goal was the procedural city stuff, and the rest of the project was just scaffolding to support that idea. <\/p>\n<p>The extreme slowdowns are a little more perplexing, and right now my instinct is to again blame the unknown behavior of the Windows screensaver functionality. <\/p>\n<p>The directions I&#8217;d read online indicated that Windows would provide your program with a pre-existing window, and would then call WM_PAINT as fast as possible.  I was a bit surprised at this, as this is a break from the behavior we see elsewhere in the operating system.  Normally a window only gets a WM_PAINT when its contents need to be redrawn.  If you move a window around the screen, resize it, or bring it out from behind other windows, it gets a WM_PAINT message letting it know that it needs to redraw.  But here we have a situation where WM_PAINT is supposedly being called indiscriminately, and at an unknown (or undocumented) interval.  <\/p>\n<p>I&#8217;m strongly suspecting that WM_PAINT isn&#8217;t getting called very often on some systems.  In screensaver mode, <em>everything<\/em>  is bound to that one WM_PAINT message, which is putting a lot of trust in a feature that I don&#8217;t know much about and didn&#8217;t make sense to me in the first place.  If Windows only calls WM_PAINT twice a second, then the program will take ~512 seconds to build the world and will run at two frames a second no matter what hardware you have.  This seems to meet with observations.  <\/p>\n<p>One solution is to set up a WM_TIMER and see if that solves the problem.  This would let me direct windows to call me every (say) 17ms or so, which would give me the desired 60fps framerate.  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Short version: Thanks for all the feedback on Pixel City. Stating your version of windows and graphics chipset along with problem reports is invaluable. The current release version has a rather embarrassing memory leak in it, so prolonged use will make the system thrash for a while when you exit it. For those of you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66,10],"tags":[],"class_list":["post-3301","post","type-post","status-publish","format-standard","hentry","category-programming","category-projects"],"_links":{"self":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/3301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3301"}],"version-history":[{"count":0,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=\/wp\/v2\/posts\/3301\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shamusyoung.com\/twentysidedtale\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}