Forum

No Render After vid_restart Using VS 2005 Express

Discuss programming topics for any language, any source base. If it is programming related but doesn't fit in one of the below categories, it goes here.

Moderator: InsideQC Admins

No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Sat Oct 05, 2013 1:54 am

So here's a crazy bug. I was testing some Paintball2 (Quake2-based engine) stuff on my laptop (Inspiron 700m with a crappy integrated video card), and noticed that, after a vid_restart, the world completely stopped rendering. HUD/text/menu/etc. still work, but the world is completely blank.

I bounced back and forth between different builds until I tracked down which version the issue started with: build 30. Looking at the code, I couldn't find anything suspect, but that was the version where I switched compilers. I didn't really think that would cause it, but I tested it, just for kicks. I grabbed the source from an old build that worked, built it with VS2005 express, and ran it on my laptop. Low and behold, vid_restart made the world stop rendering!

What in the world would cause this? It doesn't happen on other graphics cards that I'm aware of. I'm not sure if it's due to the graphics card or CPU instruction set... it's just really weird. Any ideas?
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: No Render After vid_restart Using VS 2005 Express

Postby Barnes » Sat Oct 05, 2013 5:01 am

jitspoe wrote:So here's a crazy bug. I was testing some Paintball2 (Quake2-based engine) stuff on my laptop (Inspiron 700m with a crappy integrated video card), and noticed that, after a vid_restart, the world completely stopped rendering. HUD/text/menu/etc. still work, but the world is completely blank.

I bounced back and forth between different builds until I tracked down which version the issue started with: build 30. Looking at the code, I couldn't find anything suspect, but that was the version where I switched compilers. I didn't really think that would cause it, but I tested it, just for kicks. I grabbed the source from an old build that worked, built it with VS2005 express, and ran it on my laptop. Low and behold, vid_restart made the world stop rendering!

What in the world would cause this? It doesn't happen on other graphics cards that I'm aware of. I'm not sure if it's due to the graphics card or CPU instruction set... it's just really weird. Any ideas?

:shock: have fun! For experiment try update visual studio to 2012
User avatar
Barnes
 
Posts: 224
Joined: Thu Dec 24, 2009 2:26 pm
Location: Russia, Moscow

Re: No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Sat Oct 05, 2013 7:06 pm

I'm afraid to update again -- seems every time I update, the binary gets more bloated, runs worse on old hardware, and apparently introduces weird bugs...
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: No Render After vid_restart Using VS 2005 Express

Postby revelator » Wed Oct 09, 2013 12:04 am

Been having the same probs :S seems the 2005 to 2008 compilers had some odd stuff going about for them. After upgrading to 2012 everything seems to Work ok Again though. But then Again you will get incompatibilities with earlier Windows like XP unless you explicitly set the build to XP compatibility in the project properties (and you need to update 2012 to the latest servicepack for that), it Works fine for XP builds after that though.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2544
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Wed Oct 09, 2013 1:06 am

It's really strange that the problem only exhibits itself after a vid_restart, though... I wonder what that would do to anything. What's even stranger is the rendering behavior:

HUD, text, and other 2D elements render fine.
World does not render at all (it's not that it's rendering black - it just doesn't render. If gl_clear is 0, 2D rendered elements will accumulate)
gl_showtris works.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Wed Oct 09, 2013 1:36 am

Interesting new discovery!

gl_ztrick 1 makes the rendering work again! Truly bizarre.

For reference, here's the relevant code:

Code: Select all
void R_Clear (void)
{
   if (fogenabled)
      qgl.ClearColor(fogcolor[0], fogcolor[1], fogcolor[2], 0.5); // jitfog

   if (gl_ztrick->value && !r_reflectivewater->value) // jitwater -- ztrick makes the screen flicker
   {
      static int trickframe;
      int clearbits = 0;

      if (gl_clear->value || fogenabled) // jitfog
         clearbits = GL_COLOR_BUFFER_BIT;

      if (have_stencil && gl_shadows->value == 2) // Stencil shadows - MrG
      {
         qgl.ClearStencil(0);
         clearbits |= GL_STENCIL_BUFFER_BIT;
      }

      qgl.Clear(clearbits);
      trickframe++;

      if (trickframe & 1)
      {
         gldepthmin = 0;
         gldepthmax = 0.49999;
         qgl.DepthFunc(GL_LEQUAL);
      }
      else
      {
         gldepthmin = 1;
         gldepthmax = 0.5;
         qgl.DepthFunc(GL_GEQUAL);
      }
   }
   else
   {
      int clearbits = GL_DEPTH_BUFFER_BIT;

      if (gl_clear->value || fogenabled) // jitfog
         clearbits |= GL_COLOR_BUFFER_BIT;

      if (have_stencil && gl_shadows->value == 2) // Stencil shadows - MrG
      {
         qgl.ClearStencil(0);
         clearbits |= GL_STENCIL_BUFFER_BIT;
      }

      qgl.Clear(clearbits);
      gldepthmin = 0;
      gldepthmax = 1;
      qgl.DepthFunc(GL_LEQUAL);
   }

   qgl.DepthRange(gldepthmin, gldepthmax);
}


Basically, ztrick is an optimization that alternates back and forth between using the upper and lower bits of the zbuffer at half precision to avoid clearing them. If I set gl_clear to 1, t does clear the color, but for some reason, it seems it's failing to clear the depth buffer after a vid_restart. I really don't see what would cause this. If the compiler was doing something that failed to set that bit, it seems like it would do it regardless of the computer, and regardless of whether or not you just started running or did a vid_restart. Beyond that, it would be at the library level. I know glClear is getting called because it works when clearing the color bits...

Now I'm really confused as to what could be causing this.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Wed Oct 09, 2013 2:04 am

So I've fixed the issue by adding a call to glClearDepth()...


Code: Select all
      qgl.ClearDepth(1.0);
      qgl.Clear(clearbits);


The clear depth should default to 1. I'm not sure what would cause it to change to something else after a vid restart, and why it only happens with VS2005express... should I be worried about some kind of buffer overflow? I wouldn't expect anything in the code would likely overwrite the memory space of OpenGL, and don't the libraries get completely unloaded and reloaded during a vid_restart, anyway?

Glad it's fixed, but I get an uneasy feeling about this.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Wed Oct 09, 2013 2:16 am

So... just to put my mind at ease, I removed that new line and added something to print out the depth value (wanted to see if it turned into some complete junk value, 0, or something else):

Code: Select all
         float test;
         qgl.GetFloatv(GL_DEPTH_CLEAR_VALUE, &test);
         ri.Con_Printf(PRINT_ALL, "depth clear: %g\n", test);


Guess what? It printed out 1, even after the vid_restart. I'm just going to write this one off as crappy OpenGL drivers and put the fix back in. Crazy. I still don't see what changing compilers would do to cause this.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: No Render After vid_restart Using VS 2005 Express

Postby revelator » Wed Oct 09, 2013 8:29 am

If you get that crystal ball working i would'nt mind a heads up :) been dealing with strange stuff like that for some time now, but newer found out what causes it.
The ztrick stuff is weird though i agree.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2544
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Wed Oct 09, 2013 3:10 pm

What video card do you have? This was happening on my Dell Insprion 700m (Intel Extreme Graphics 855 GM video card, I believe). You could try adding the glClearDepth(1.0); if you're experiencing the same issue.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am

Re: No Render After vid_restart Using VS 2005 Express

Postby r00k » Wed Oct 09, 2013 4:22 pm

hmm i thought it was always a good idea to use clearbits = GL_DEPTH_BUFFER_BIT; glClear (clearbits);
in r_clear anyways on modern gpus?
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Re: No Render After vid_restart Using VS 2005 Express

Postby Spike » Wed Oct 09, 2013 5:25 pm

r00k, glClearDepth specifies the value to write when clearing the buffer, but does not actually do the clear.
noone's using ztrick by default here (yes, ztrick is generally slower on modern gpus), they're only noticing that it still works when ztrick 0 does not.

make sure you're not scissoring during the clear or something? :s
you have glDepthMask(GL_TRUE) set I trust?

as you're q2-based, I assume your vid_restart is a full context destruction+recreation?
Spike
 
Posts: 2883
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: No Render After vid_restart Using VS 2005 Express

Postby jitspoe » Wed Oct 09, 2013 6:30 pm

I don't think ztrick is slower on modern GPU's, you just lose 50% of the precision (can result in more z-fighting), and the time it takes to clear the zbuffer on modern gpu's is almost negligible.

Spike wrote:make sure you're not scissoring during the clear or something? :s
you have glDepthMask(GL_TRUE) set I trust?

It wouldn't make sense that those would be the issue if simply setting the clear value to 1 makes everything work again. Of course, nothing about this really makes sense..

as you're q2-based, I assume your vid_restart is a full context destruction+recreation?

Yeah, as far as I know.
jitspoe
 
Posts: 217
Joined: Mon Jan 17, 2005 5:27 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest