Forum

Doom 3 engine release and game code

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

Re: Doom 3 engine release and game code

Postby motorsep » Sat Sep 01, 2012 5:08 am

care to explain how can I add/fix that in dhewm3 ? :) Thanks!
motorsep
 
Posts: 231
Joined: Wed Aug 02, 2006 11:46 pm
Location: Texas, USA

Re: Doom 3 engine release and game code

Postby motorsep » Sat Sep 01, 2012 5:20 am

r00k wrote:Is there a wiki for the doom3 gamecode? I really havent even looked at the source, but would like to tinker with a quake1 mod in doom3-land.
id Tech3 is fueling QuakeLive, but if one was to make a doom3 mod worthy and popular I think Quake1 gameplay beats QuakeLive.
Kinda like making Quake1 backwards, by releasing the multiplayer 1st then work on singleplayer if acceptance is positive. Or if anything just to showcase a modded D3Engine.


There is modwiki, but it deals with scripts/defs (and is not complete reference anyway). Gamex86 (aka SDK, gamelib) is a black box, so to speak. If you know OOP, simply did the code.

Although it seems like a fun idea, there is no point in recreating Quake 1 gameplay in idTech 4. Simply play Quake ;) Or you can use DarkPplaces engine to make Quake look like Quake 2012 (still need to add ragdolls and whatnot) :D
motorsep
 
Posts: 231
Joined: Wed Aug 02, 2006 11:46 pm
Location: Texas, USA

Re: Doom 3 engine release and game code

Postby revelator » Sat Sep 01, 2012 1:05 pm

Would be very lenghty to explain but ill make you a Vertexcache.cpp for dhewm3. When i post it just replace the vertexcache.cpp in dhewm3\neo\render folder with it and recompile.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby revelator » Sat Sep 01, 2012 2:28 pm

http://code.google.com/p/realm/downloads/detail?name=VertexCache-dhewm3.7z&can=2&q=

unzip and drop these two files in dhewm3\neo\render folder and overwrite the existing ones then recompile.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby motorsep » Sat Sep 01, 2012 4:37 pm

Tried, doesn't work. Can't just replace files with dhewm3.
motorsep
 
Posts: 231
Joined: Wed Aug 02, 2006 11:46 pm
Location: Texas, USA

Re: Doom 3 engine release and game code

Postby revelator » Sat Sep 01, 2012 7:25 pm

eh i just recompiled it here can you post your build log ? maybe something changed in dhewm3 code.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby revelator » Sat Sep 01, 2012 7:52 pm

Something i cooked up for starting Doom3 with gfx mods.

Code for my wrapper executables ;)

Code: Select all
/***************************************************************

 Simple wrapper to start Win32 applications with command parameters
 without using batch files.

 (c) Ralph Engels, September 01, 2012
 
 Licensed under the GPL license.

 ***************************************************************/

#include <windows.h>
#include <stdio.h>

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
   /* Declarations for new process    */
   STARTUPINFO         si = {sizeof(si)};
   PROCESS_INFORMATION pi;
   int               ret;
   LPSTR            baseLine = "doom3.exe +set fs_game_base d3xp +set fs_game sikkmodd3xp";

   /* Needed for OS detection */
   OSVERSIONINFOEX      osvi;
   BOOL            bOsVersionInfoEx;

   /* Setup startup flags */
   si.dwFlags = STARTF_USESHOWWINDOW;

   /* Check the Operating System version */
   ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
   osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);

   if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)))
   {
      osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);

      if (! GetVersionEx ((OSVERSIONINFO *) &osvi))
      {
         exit(EXIT_FAILURE);
      }
   }

   /* If windows9x/ME then hide */
   if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
   {
      si.wShowWindow = SW_HIDE;
   }
   else
   {
      si.wShowWindow = SW_SHOW;
   }
    ret = CreateProcess (NULL, baseLine, NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi);

   if (ret == 0)
   {
      MessageBox(NULL, "ERROR: Could not launch your application!", baseLine, MB_OK | MB_ICONERROR);
      exit(EXIT_FAILURE);
   }
}


to set it for other games change this "doom3.exe +set fs_game_base <basefolder of game> +set fs_game <modfolder>"
Last edited by revelator on Sun Sep 02, 2012 12:57 am, edited 1 time in total.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby revelator » Sun Sep 02, 2012 12:55 am

AMD users still report its godawfully slow on there rigs 2 fps :shock:
im starting to think its not related to the VBO code at all cause i sent them a clean version with just that and it ran as it should.
Hm as far as i know the only change i done to the renderer was MH's shared ARB/GLSL backend and i removed an old hack for ati cards that shouldnt be nessesary anymore but maybe im wrong (btw this hack was also removed in dhewm3 i wonder if he had any reports on bad performance on AMD cards ?). Oh one other thing that changed, i used some code from a source mh sent me for the normal arrays (uses glVertexAttribARB instead) but i dunno if that breaks AMD cards hmm.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby mh » Sun Sep 02, 2012 2:34 am

I built most of that code on a machine with an AMD card so it shouldn't be an issue. Colour me puzzled.

Check the usual suspects I suppose - driver versions, settings forced in CCC, etc.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Doom 3 engine release and game code

Postby revelator » Sun Sep 02, 2012 2:51 am

aye was my thought also but doom 3 does not even run when the catalyst AI is on :( the users know that by now and normally resort to renaming the Doom3.exe to something else or turning the AI off.
Hmm if you got access to an AMD / ATI i uploaded a newer build which i hoped fixed it but atleast one user reports it to perform badly. Maybe you could give it a try ? and let me know if it also runs bad for you.

http://code.google.com/p/realm/downloads/detail?name=Doom3.7z&can=2&q= heres the executable.
http://code.google.com/p/realm/downloads/detail?name=Revelator.7z&can=2&q= and my sources.

edit: forgot to mention i managed to convert the doom3 sources back to msvc 2005 :)
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby tobis87 » Sun Sep 02, 2012 2:28 pm

reckless wrote:eh i just recompiled it here can you post your build log ? maybe something changed in dhewm3 code.

I also tried to compile dhewm3 with your changes, but it didn't work. I have made a cleaner patch (http://pastebin.com/raw.php?i=cGtRKMj1):
Code: Select all
diff -urN a/neo/renderer/VertexCache.cpp b/neo/renderer/VertexCache.cpp
--- a/neo/renderer/VertexCache.cpp   2012-09-01 23:45:39.000000000 +0200
+++ b/neo/renderer/VertexCache.cpp   2012-09-02 00:02:44.000000000 +0200
@@ -33,13 +33,38 @@
 #include "renderer/VertexCache.h"
 
 static const int   FRAME_MEMORY_BYTES = 0x200000;
-static const int   EXPAND_HEADERS = 1024;
+static const int   EXPAND_HEADERS = 32;
 
 idCVar idVertexCache::r_showVertexCache( "r_showVertexCache", "0", CVAR_INTEGER|CVAR_RENDERER, "" );
+idCVar idVertexCache::r_reuseVertexCacheSooner( "r_reuseVertexCacheSooner", "1", CVAR_BOOL|CVAR_RENDERER, "reuse vertex buffers as soon as possible after freeing" );
 idCVar idVertexCache::r_vertexBufferMegs( "r_vertexBufferMegs", "32", CVAR_INTEGER|CVAR_RENDERER, "" );
 
 idVertexCache      vertexCache;
 
+static GLuint gl_current_array_buffer = 0;
+static GLuint gl_current_index_buffer = 0;
+
+static void GL_BindBuffer (GLenum target, GLuint buffer)
+{
+   if ( target == GL_ARRAY_BUFFER ) {
+      if ( gl_current_array_buffer != buffer ) {
+         gl_current_array_buffer = buffer;
+      } else {
+         return;
+      }
+   } else if ( target == GL_ELEMENT_ARRAY_BUFFER ) {
+      if ( gl_current_index_buffer != buffer ) {
+         gl_current_index_buffer = buffer;
+      } else {
+         return;
+      }
+   } else {
+      common->Error ("GL_BindBuffer : invalid buffer target : %i\n", (int) target);
+      return;
+   }
+   qglBindBufferARB (target, buffer);
+}
+
 /*
 ==============
 R_ListVertexCache_f
@@ -67,16 +92,10 @@
 
    // temp blocks are in a shared space that won't be freed
    if ( block->tag != TAG_TEMP ) {
-      staticAllocTotal -= block->size;
-      staticCountTotal--;
+      this->staticAllocTotal -= block->size;
+      this->staticCountTotal--;
 
-      if ( block->vbo ) {
-#if 0      // this isn't really necessary, it will be reused soon enough
-         // filling with zero length data is the equivalent of freeing
-         qglBindBufferARB(GL_ARRAY_BUFFER_ARB, block->vbo);
-         qglBufferDataARB(GL_ARRAY_BUFFER_ARB, 0, 0, GL_DYNAMIC_DRAW_ARB);
-#endif
-      } else if ( block->virtMem ) {
+      if ( block->virtMem ) {
          Mem_Free( block->virtMem );
          block->virtMem = NULL;
       }
@@ -87,15 +106,15 @@
    block->next->prev = block->prev;
    block->prev->next = block->next;
 
-#if 1
-   // stick it on the front of the free list so it will be reused immediately
-   block->next = freeStaticHeaders.next;
-   block->prev = &freeStaticHeaders;
-#else
-   // stick it on the back of the free list so it won't be reused soon (just for debugging)
-   block->next = &freeStaticHeaders;
-   block->prev = freeStaticHeaders.prev;
-#endif
+   if ( r_reuseVertexCacheSooner.GetBool() ) {
+      // stick it on the front of the free list so it will be reused immediately
+      block->next = this->freeStaticHeaders.next;
+      block->prev = &this->freeStaticHeaders;
+   } else {
+      // stick it on the back of the free list so it won't be reused soon (just for debugging)
+      block->next = &this->freeStaticHeaders;
+      block->prev = this->freeStaticHeaders.prev;
+   }
 
    block->next->prev = block;
    block->prev->next = block;
@@ -121,25 +140,23 @@
    if ( buffer->vbo ) {
       if ( r_showVertexCache.GetInteger() == 2 ) {
          if ( buffer->tag == TAG_TEMP ) {
-            common->Printf( "GL_ARRAY_BUFFER_ARB = %i + %zd (%i bytes)\n", buffer->vbo, buffer->offset, buffer->size );
+            common->Printf( "GL_ARRAY_BUFFER = %i + %zd (%i bytes)\n", buffer->vbo, buffer->offset, buffer->size );
          } else {
-            common->Printf( "GL_ARRAY_BUFFER_ARB = %i (%i bytes)\n", buffer->vbo, buffer->size );
+            common->Printf( "GL_ARRAY_BUFFER = %i (%i bytes)\n", buffer->vbo, buffer->size );
          }
       }
-      if ( buffer->indexBuffer ) {
-         qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, buffer->vbo );
-      } else {
-         qglBindBufferARB( GL_ARRAY_BUFFER_ARB, buffer->vbo );
-      }
-      return (void *)buffer->offset;
-   }
 
-   // virtual memory is a real pointer
-   return (void *)((byte *)buffer->virtMem + buffer->offset);
+      GL_BindBuffer( (buffer->indexBuffer ? GL_ELEMENT_ARRAY_BUFFER : GL_ARRAY_BUFFER), buffer->vbo );
+
+      return (void *) buffer->offset;
+   } else {
+      // virtual memory is a real pointer
+      return (void *)((byte *)buffer->virtMem + buffer->offset);
+   }
 }
 
 void idVertexCache::UnbindIndex() {
-   qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
+   GL_BindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
 }
 
 
@@ -157,19 +174,17 @@
       r_vertexBufferMegs.SetInteger( 8 );
    }
 
-   virtualMemory = false;
-
    // use ARB_vertex_buffer_object unless explicitly disabled
-   if( r_useVertexBuffers.GetInteger() && glConfig.ARBVertexBufferObjectAvailable ) {
+   if( glConfig.ARBVertexBufferObjectAvailable ) {
+      virtualMemory = false;
       common->Printf( "using ARB_vertex_buffer_object memory\n" );
    } else {
       virtualMemory = true;
-      r_useIndexBuffers.SetBool( false );
       common->Printf( "WARNING: vertex array range in virtual memory (SLOW)\n" );
    }
 
    // initialize the cache memory blocks
-   freeStaticHeaders.next = freeStaticHeaders.prev = &freeStaticHeaders;
+   this->freeStaticHeaders.next = this->freeStaticHeaders.prev = &this->freeStaticHeaders;
    staticHeaders.next = staticHeaders.prev = &staticHeaders;
    freeDynamicHeaders.next = freeDynamicHeaders.prev = &freeDynamicHeaders;
    dynamicHeaders.next = dynamicHeaders.prev = &dynamicHeaders;
@@ -177,21 +192,22 @@
 
    // set up the dynamic frame memory
    frameBytes = FRAME_MEMORY_BYTES;
-   staticAllocTotal = 0;
+   this->staticAllocTotal = 0;
 
    byte   *junk = (byte *)Mem_Alloc( frameBytes );
    for ( int i = 0 ; i < NUM_VERTEX_FRAMES ; i++ ) {
-      allocatingTempBuffer = true;   // force the alloc to use GL_STREAM_DRAW_ARB
-      Alloc( junk, frameBytes, &tempBuffers[i] );
-      allocatingTempBuffer = false;
-      tempBuffers[i]->tag = TAG_FIXED;
+      this->allocatingTempBuffer = true;   // force the alloc to use GL_STREAM_DRAW
+      this->Alloc( junk, this->frameBytes, &this->tempBuffers[i] );
+      this->allocatingTempBuffer = false;
+      this->tempBuffers[i]->tag = TAG_FIXED;
+
       // unlink these from the static list, so they won't ever get purged
-      tempBuffers[i]->next->prev = tempBuffers[i]->prev;
-      tempBuffers[i]->prev->next = tempBuffers[i]->next;
+      this->tempBuffers[i]->next->prev = this->tempBuffers[i]->prev;
+      this->tempBuffers[i]->prev->next = this->tempBuffers[i]->next;
    }
    Mem_Free( junk );
 
-   EndFrame();
+   this->EndFrame ();
 }
 
 /*
@@ -225,7 +241,7 @@
 ===========
 */
 void idVertexCache::Alloc( void *data, int size, vertCache_t **buffer, bool indexBuffer ) {
-   vertCache_t   *block;
+   vertCache_t   *block = NULL;
 
    if ( size <= 0 ) {
       common->Error( "idVertexCache::Alloc: size = %i\n", size );
@@ -235,23 +251,55 @@
    *buffer = NULL;
 
    // if we don't have any remaining unused headers, allocate some more
-   if ( freeStaticHeaders.next == &freeStaticHeaders ) {
+   if ( this->freeStaticHeaders.next == &this->freeStaticHeaders )   {
 
       for ( int i = 0; i < EXPAND_HEADERS; i++ ) {
-         block = headerAllocator.Alloc();
-         block->next = freeStaticHeaders.next;
-         block->prev = &freeStaticHeaders;
-         block->next->prev = block;
-         block->prev->next = block;
+         block = headerAllocator.Alloc ();
 
          if( !virtualMemory ) {
-            qglGenBuffersARB( 1, & block->vbo );
+            qglGenBuffersARB( 1, &block->vbo );
+            block->size = 0;
          }
+
+         block->next = this->freeStaticHeaders.next;
+         block->prev = &this->freeStaticHeaders;
+         block->next->prev = block;
+         block->prev->next = block;
+      }
+   }
+
+   GLenum target = ( indexBuffer ? GL_ELEMENT_ARRAY_BUFFER : GL_ARRAY_BUFFER );
+   GLenum usage = ( allocatingTempBuffer ? GL_STREAM_DRAW : GL_STATIC_DRAW );
+
+   // try to find a matching block to replace so that we're not continually respecifying vbo data each frame
+   for ( vertCache_t *findblock = this->freeStaticHeaders.next; ; findblock = findblock->next ) {
+      if ( findblock == &this->freeStaticHeaders ) {
+         block = this->freeStaticHeaders.next;
+         break;
       }
+
+      if ( findblock->target != target ) continue;
+      if ( findblock->usage != usage ) continue;
+      if ( findblock->size != size ) continue;
+
+      block = findblock;
+      break;
    }
 
    // move it from the freeStaticHeaders list to the staticHeaders list
-   block = freeStaticHeaders.next;
+   block->target = target;
+   block->usage = usage;
+
+   if ( block->vbo ) {
+      // orphan the buffer in case it needs respecifying (it usually will)
+      GL_BindBuffer (target, block->vbo);
+      qglBufferDataARB( target, (GLsizeiptr) size, NULL, usage );
+      qglBufferDataARB( target, (GLsizeiptr) size, data, usage );
+   } else {
+      block->virtMem = Mem_Alloc( size );
+      memcpy( block->virtMem, data, size );
+   }
+
    block->next->prev = block->prev;
    block->prev->next = block->next;
    block->next = staticHeaders.next;
@@ -264,10 +312,10 @@
    block->tag = TAG_USED;
 
    // save data for debugging
-   staticAllocThisFrame += block->size;
-   staticCountThisFrame++;
-   staticCountTotal++;
-   staticAllocTotal += block->size;
+   this->staticAllocThisFrame += block->size;
+   this->staticCountThisFrame++;
+   this->staticCountTotal++;
+   this->staticAllocTotal += block->size;
 
    // this will be set to zero when it is purged
    block->user = buffer;
@@ -277,26 +325,7 @@
    // load time lots of things may be created, but they aren't
    // referenced by the GPU yet, and can be purged if needed.
    block->frameUsed = currentFrame - NUM_VERTEX_FRAMES;
-
    block->indexBuffer = indexBuffer;
-
-   // copy the data
-   if ( block->vbo ) {
-      if ( indexBuffer ) {
-         qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, block->vbo );
-         qglBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, (GLsizeiptrARB)size, data, GL_STATIC_DRAW_ARB );
-      } else {
-         qglBindBufferARB( GL_ARRAY_BUFFER_ARB, block->vbo );
-         if ( allocatingTempBuffer ) {
-            qglBufferDataARB( GL_ARRAY_BUFFER_ARB, (GLsizeiptrARB)size, data, GL_STREAM_DRAW_ARB );
-         } else {
-            qglBufferDataARB( GL_ARRAY_BUFFER_ARB, (GLsizeiptrARB)size, data, GL_STATIC_DRAW_ARB );
-         }
-      }
-   } else {
-      block->virtMem = Mem_Alloc( size );
-      SIMDProcessor->Memcpy( block->virtMem, data, size );
-   }
 }
 
 /*
@@ -377,9 +406,9 @@
    if ( dynamicAllocThisFrame + size > frameBytes ) {
       // if we don't have enough room in the temp block, allocate a static block,
       // but immediately free it so it will get freed at the next frame
-      tempOverflow = true;
-      Alloc( data, size, &block );
-      Free( block);
+      this->tempOverflow = true;
+      this->Alloc( data, size, &block );
+      this->Free( block);
       return block;
    }
 
@@ -417,13 +446,32 @@
 
    // copy the data
    block->virtMem = tempBuffers[listNum]->virtMem;
-   block->vbo = tempBuffers[listNum]->vbo;
 
-   if ( block->vbo ) {
-      qglBindBufferARB( GL_ARRAY_BUFFER_ARB, block->vbo );
-      qglBufferSubDataARB( GL_ARRAY_BUFFER_ARB, block->offset, (GLsizeiptrARB)size, data );
+   if ( (block->vbo = tempBuffers[listNum]->vbo) != 0 ) {
+      GL_BindBuffer( GL_ARRAY_BUFFER, block->vbo );
+
+      // try to get an unsynchronized map if at all possible
+      if ( R_CheckExtension("GL_ARB_map_buffer_range") ) {
+         void *dst = NULL;
+         GLbitfield access = GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|GL_MAP_INVALIDATE_RANGE_BIT;
+
+         // if the buffer has wrapped then we orphan it
+         if ( block->offset == 0 ) {
+            access = GL_MAP_WRITE_BIT|GL_MAP_INVALIDATE_BUFFER_BIT;
+         } else {
+            access = GL_MAP_WRITE_BIT|GL_MAP_UNSYNCHRONIZED_BIT|GL_MAP_INVALIDATE_RANGE_BIT;
+         }
+         if ( (dst = qglMapBufferRange(GL_ARRAY_BUFFER, block->offset, (GLsizeiptr) size, access)) != NULL ) {
+            memcpy( dst, data, size );
+            qglUnmapBufferARB( GL_ARRAY_BUFFER );
+         } else {
+            qglBufferSubDataARB( GL_ARRAY_BUFFER, block->offset, (GLsizeiptr) size, data );
+         }
+      } else {
+         qglBufferSubDataARB( GL_ARRAY_BUFFER, block->offset, (GLsizeiptr) size, data );
+      }
    } else {
-      SIMDProcessor->Memcpy( (byte *)block->virtMem + block->offset, data, size );
+      memcpy( (byte *) block->virtMem + block->offset, data, size );
    }
 
    return block;
@@ -451,31 +499,21 @@
 
       common->Printf( "vertex dynamic:%i=%ik%s, static alloc:%i=%ik used:%i=%ik total:%i=%ik\n",
          dynamicCountThisFrame, dynamicAllocThisFrame/1024, frameOverflow,
-         staticCountThisFrame, staticAllocThisFrame/1024,
+         this->staticCountThisFrame, this->staticAllocThisFrame/1024,
          staticUseCount, staticUseSize/1024,
-         staticCountTotal, staticAllocTotal/1024 );
-   }
-
-#if 0
-   // if our total static count is above our working memory limit, start purging things
-   while ( staticAllocTotal > r_vertexBufferMegs.GetInteger() * 1024 * 1024 ) {
-      // free the least recently used
-
+         this->staticCountTotal, this->staticAllocTotal/1024 );
    }
-#endif
 
-   if( !virtualMemory ) {
-      // unbind vertex buffers so normal virtual memory will be used in case
-      // r_useVertexBuffers / r_useIndexBuffers
-      qglBindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
-      qglBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
+   if ( !virtualMemory ) {
+      // unbind vertex buffers so normal virtual memory will be used
+      GL_BindBuffer( GL_ARRAY_BUFFER, 0 );
+      GL_BindBuffer( GL_ELEMENT_ARRAY_BUFFER, 0 );
    }
 
-
    currentFrame = tr.frameCount;
    listNum = currentFrame % NUM_VERTEX_FRAMES;
-   staticAllocThisFrame = 0;
-   staticCountThisFrame = 0;
+   this->staticAllocThisFrame = 0;
+   this->staticCountThisFrame = 0;
    dynamicAllocThisFrame = 0;
    dynamicCountThisFrame = 0;
    tempOverflow = false;
@@ -518,7 +556,8 @@
    }
 
    int   numFreeStaticHeaders = 0;
-   for ( block = freeStaticHeaders.next ; block != &freeStaticHeaders ; block = block->next ) {
+
+   for ( block = this->freeStaticHeaders.next ; block != &this->freeStaticHeaders ; block = block->next ) {
       numFreeStaticHeaders++;
    }
 
@@ -539,11 +578,7 @@
       common->Printf( "Vertex cache is in virtual memory (SLOW)\n" );
    }
 
-   if ( r_useIndexBuffers.GetBool() ) {
-      common->Printf( "Index buffers are accelerated.\n" );
-   } else {
-      common->Printf( "Index buffers are not used.\n" );
-   }
+   common->Printf( "Index buffers are accelerated.\n" );
 }
 
 /*
diff -urN a/neo/renderer/VertexCache.h b/neo/renderer/VertexCache.h
--- a/neo/renderer/VertexCache.h   2012-09-01 23:45:39.000000000 +0200
+++ b/neo/renderer/VertexCache.h   2012-09-01 23:37:29.000000000 +0200
@@ -42,6 +42,8 @@
 
 typedef struct vertCache_s {
    GLuint         vbo;
+   GLenum         target;
+   GLenum         usage;
    void         *virtMem;         // only one of vbo / virtMem will be set
    bool         indexBuffer;      // holds indexes instead of vertexes
 
@@ -78,7 +80,7 @@
    // but it will be an int offset cast to a pointer of ARB_vertex_buffer_object
    void *         Position( vertCache_t *buffer );
 
-   // if r_useIndexBuffers is enabled, but you need to draw something without
+   // if you need to draw something without
    // an indexCache, this must be called to reset GL_ELEMENT_ARRAY_BUFFER_ARB
    void         UnbindIndex();
 
@@ -112,6 +114,8 @@
 
    static idCVar   r_showVertexCache;
    static idCVar   r_vertexBufferMegs;
+   static idCVar   r_useArbBufferRange;
+   static idCVar   r_reuseVertexCacheSooner;
 
    int            staticCountTotal;
    int            staticAllocTotal;      // for end of frame purging

Building fails with these errors:
    /tmp/dhewm3/neo/renderer/VertexCache.cpp: In member function ‘vertCache_t* idVertexCache::AllocFrameTemp(void*, int)’:
    /tmp/dhewm3/neo/renderer/VertexCache.cpp:457: error: ‘GL_MAP_WRITE_BIT’ was not declared in this scope
    /tmp/dhewm3/neo/renderer/VertexCache.cpp:457: error: ‘GL_MAP_UNSYNCHRONIZED_BIT’ was not declared in this scope
    /tmp/dhewm3/neo/renderer/VertexCache.cpp:457: error: ‘GL_MAP_INVALIDATE_RANGE_BIT’ was not declared in this scope
    /tmp/dhewm3/neo/renderer/VertexCache.cpp:461: error: ‘GL_MAP_INVALIDATE_BUFFER_BIT’ was not declared in this scope
    /tmp/dhewm3/neo/renderer/VertexCache.cpp:465: error: ‘qglMapBufferRange’ was not declared in this scope

As far as I know dhewm3 uses SDL which only supports OpenGL 3 functions from 1.3 onwards.
Could this VertexCache optimisation be done with functions which are supported in SDL 1.2 only? Many Linux distros still ship with SDL 1.2.
tobis87
 
Posts: 8
Joined: Sat Sep 01, 2012 9:44 pm

Re: Doom 3 engine release and game code

Postby Spike » Sun Sep 02, 2012 3:37 pm

'qglMapBufferRange' is always invalid, regardless of what your system headers/libraries provide.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: Doom 3 engine release and game code

Postby revelator » Sun Sep 02, 2012 4:12 pm

Should have been glMapBufferRange i have several copies of the source file but obviously forgot to rename it in the posted codepiece damn quake2 references :(

If youre missing GL_MAP_WRITE_BIT etc then your SDL is to old it was added lately from glext.h and is in my version.

Edit You can also use glext.h together with SDL if you dont feel experimental :) the SDL version with it included is the 1.3 branch on mercurial.
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby revelator » Sun Sep 02, 2012 4:27 pm

Hope it helps else ill upload my dhewm3 build somewhere but not now :) been bughunting ATI crap for 32 hours and my eyes are falling out of there sockets !!! :twisted:
Productivity is a state of mind.
User avatar
revelator
 
Posts: 2567
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: Doom 3 engine release and game code

Postby tobis87 » Mon Sep 03, 2012 5:17 am

reckless wrote:Should have been glMapBufferRange i have several copies of the source file but obviously forgot to rename it in the posted codepiece damn quake2 references :(

If youre missing GL_MAP_WRITE_BIT etc then your SDL is to old it was added lately from glext.h and is in my version.

Edit You can also use glext.h together with SDL if you dont feel experimental :) the SDL version with it included is the 1.3 branch on mercurial.

glMapBufferRange is also missing.

I put these lines at the beginning of VertexCache.cpp:
Code: Select all
#define GL_MAP_WRITE_BIT                  0x0002
#define GL_MAP_INVALIDATE_RANGE_BIT       0x0004
#define GL_MAP_INVALIDATE_BUFFER_BIT      0x0008
#define GL_MAP_UNSYNCHRONIZED_BIT         0x0020
GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);


It compiles, but does not link yet:
    CMakeFiles/dhewm3.dir/renderer/VertexCache.cpp.o: In function `idVertexCache::AllocFrameTemp(void*, int)':
    /tmp/dhewm3/neo/renderer/VertexCache.cpp:470: undefined reference to `glMapBufferRange(unsigned int, long, long, unsigned int)'

What do I need to link against and how do I change CMakeLists.txt?
tobis87
 
Posts: 8
Joined: Sat Sep 01, 2012 9:44 pm

PreviousNext

Return to General Programming

Who is online

Users browsing this forum: No registered users and 1 guest