DXGL r594 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r593‎ | r594 | r595 >
Date:21:35, 8 February 2015
Author:admin
Status:new
Tags:
Comment:
More attempts at fixing the queue.
Fix crash when setting a light with a NULL pointer.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)
  • /ddraw/opqueue.c (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -395,7 +395,6 @@
396396 uploadop->texture = texture;
397397 memcpy(opbuffer, outbuffer, outy*outpitch);
398398 opqueue_putunlock(&This->queue, uploadopsize);
399 - glRenderer_Sync(This);
400399 }
401400
402401 /**
@@ -932,7 +931,7 @@
933932 lightop->opcode.size = sizeof(SETLIGHTOP);
934933 lightop->index = index;
935934 lightop->remove = remove;
936 - memcpy(&lightop->light, light, sizeof(D3DLIGHT7));
 935+ if(light) memcpy(&lightop->light, light, sizeof(D3DLIGHT7));
937936 opqueue_putunlock(&This->queue, sizeof(SETLIGHTOP));
938937 }
939938
@@ -1156,6 +1155,10 @@
11571156 glRenderer__SetViewport(This, &setviewportop->viewport);
11581157 opqueue_getunlock(&This->queue, setviewportop->opcode.size);
11591158 break;
 1159+ default:
 1160+ FIXME("Invalid opcode detected");
 1161+ opqueue_getunlock(&This->queue, opcode->opcode.size);
 1162+ break;
11601163 }
11611164 }
11621165 return 0;
Index: ddraw/opqueue.c
@@ -98,7 +98,7 @@
9999 queue->waitfull = TRUE;
100100 _exitspinlock(&queue->readlock);
101101 _enterspinlock(&queue->writelock);
102 - WaitForSingleObject(queue->waitevent, 10);
 102+ Sleep(0);
103103 }
104104 if (waitfull) ResetEvent(queue->waitevent);
105105 queue->waitfull = FALSE;
@@ -121,18 +121,20 @@
122122
123123 BYTE *opqueue_getlock(OPQUEUE *queue)
124124 {
 125+ BOOL exit = TRUE;
125126 _enterspinlock(&queue->readlock);
126127 _enterspinlock(&queue->writelock);
127128 if (queue->readptr == queue->writeptr)
128129 {
129 - _exitspinlock(&queue->readlock);
130130 queue->waitempty = TRUE;
131131 ResetEvent(queue->waitevent);
 132+ _exitspinlock(&queue->readlock);
132133 _exitspinlock(&queue->writelock);
133134 WaitForSingleObject(queue->waitevent, INFINITE);
134135 _enterspinlock(&queue->readlock);
 136+ exit = FALSE;
135137 }
136 - _exitspinlock(&queue->writelock);
 138+ if(exit) _exitspinlock(&queue->writelock);
137139 return queue->data + queue->readptr;
138140 }
139141 void opqueue_getunlock(OPQUEUE *queue, DWORD size)