[quake3-commits] r1968 - in trunk/code: qcommon renderer

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Mon May 9 19:39:40 EDT 2011


Author: thilo
Date: 2011-05-09 19:39:40 -0400 (Mon, 09 May 2011)
New Revision: 1968

Modified:
   trunk/code/qcommon/q_shared.h
   trunk/code/renderer/tr_backend.c
   trunk/code/renderer/tr_cmds.c
   trunk/code/renderer/tr_init.c
   trunk/code/renderer/tr_shader.c
Log:
Choose better alignment for heavy-duty rendering structures, patch by Matt Turner (#4981)


Modified: trunk/code/qcommon/q_shared.h
===================================================================
--- trunk/code/qcommon/q_shared.h	2011-05-09 22:40:25 UTC (rev 1967)
+++ trunk/code/qcommon/q_shared.h	2011-05-09 23:39:40 UTC (rev 1968)
@@ -183,9 +183,11 @@
 typedef int		fileHandle_t;
 typedef int		clipHandle_t;
 
-#define PAD(x,y)	(((x)+(y)-1) & ~((y)-1))
-#define PADLEN(x,y)	(PAD((x), (y)) - (x))
+#define PAD(base, alignment)	(((base)+(alignment)-1) & ~((alignment)-1))
+#define PADLEN(base, alignment)	(PAD((base), (alignment)) - (base))
 
+#define PADP(base, alignment)	((void *) PAD((intptr_t) (base), (alignment)))
+
 #ifdef __GNUC__
 #define QALIGN(x) __attribute__((aligned(x)))
 #else

Modified: trunk/code/renderer/tr_backend.c
===================================================================
--- trunk/code/renderer/tr_backend.c	2011-05-09 22:40:25 UTC (rev 1967)
+++ trunk/code/renderer/tr_backend.c	2011-05-09 23:39:40 UTC (rev 1968)
@@ -1142,6 +1142,8 @@
 	}
 
 	while ( 1 ) {
+		data = PADP(data, sizeof(void *));
+
 		switch ( *(const int *)data ) {
 		case RC_SET_COLOR:
 			data = RB_SetColor( data );

Modified: trunk/code/renderer/tr_cmds.c
===================================================================
--- trunk/code/renderer/tr_cmds.c	2011-05-09 22:40:25 UTC (rev 1967)
+++ trunk/code/renderer/tr_cmds.c	2011-05-09 23:39:40 UTC (rev 1968)
@@ -195,6 +195,7 @@
 	renderCommandList_t	*cmdList;
 
 	cmdList = &backEndData[tr.smpFrame]->commands;
+	bytes = PAD(bytes, sizeof(void *));
 
 	// always leave room for the end of list command
 	if ( cmdList->used + bytes + 4 > MAX_RENDER_COMMANDS ) {

Modified: trunk/code/renderer/tr_init.c
===================================================================
--- trunk/code/renderer/tr_init.c	2011-05-09 22:40:25 UTC (rev 1967)
+++ trunk/code/renderer/tr_init.c	2011-05-09 23:39:40 UTC (rev 1968)
@@ -382,7 +382,7 @@
 	// Allocate a few more bytes so that we can choose an alignment we like
 	buffer = ri.Hunk_AllocateTempMemory(padwidth * height + *offset + packAlign - 1);
 	
-	bufstart = (byte *) PAD((intptr_t) buffer + *offset, packAlign);
+	bufstart = PADP((intptr_t) buffer + *offset, packAlign);
 	qglReadPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE, bufstart);
 	
 	*offset = bufstart - buffer;
@@ -780,7 +780,7 @@
 	avipadwidth = PAD(linelen, AVI_LINE_PADDING);
 	avipadlen = avipadwidth - linelen;
 
-	cBuf = (byte *) PAD((intptr_t) cmd->captureBuffer, packAlign);
+	cBuf = PADP(cmd->captureBuffer, packAlign);
 		
 	qglReadPixels(0, 0, cmd->width, cmd->height, GL_RGB,
 		GL_UNSIGNED_BYTE, cBuf);

Modified: trunk/code/renderer/tr_shader.c
===================================================================
--- trunk/code/renderer/tr_shader.c	2011-05-09 22:40:25 UTC (rev 1967)
+++ trunk/code/renderer/tr_shader.c	2011-05-09 23:39:40 UTC (rev 1968)
@@ -1878,6 +1878,8 @@
 		const void *curCmd = cmdList->cmds;
 
 		while ( 1 ) {
+			curCmd = PADP(curCmd, sizeof(void *));
+
 			switch ( *(const int *)curCmd ) {
 			case RC_SET_COLOR:
 				{



More information about the quake3-commits mailing list