DXGL r597 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r596‎ | r597 | r598 >
Date:19:09, 22 February 2015
Author:admin
Status:new
Tags:
Comment:
Fix some D3D queue opcodes.
Modified paths:
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

Index: ddraw/glRenderer.cpp
@@ -161,14 +161,23 @@
162162 {
163163 argsize = va_arg(params, int);
164164 argptr = va_arg(params, void*);
165 - if (!argsize) continue;
 165+ if (!argsize)
 166+ {
 167+ This->queue[This->queue_write++] = argsize;
 168+ size -= 1;
 169+ continue;
 170+ }
166171 if ((NextMultipleOf4(argsize) / 4) > size) break;
167172 This->queue[This->queue_write++] = argsize;
168173 if (argptr) memcpy(This->queue + This->queue_write, argptr, argsize);
169174 This->queue_write += (NextMultipleOf4(argsize) / 4);
170 - size -= (NextMultipleOf4(argsize) / 4);
 175+ size -= 1 + (NextMultipleOf4(argsize) / 4);
171176 }
172177 va_end(params);
 178+ if (size != 0)
 179+ {
 180+ FIXME("Opcode size mismatch!\n")
 181+ }
173182 This->queuelength++;
174183 if (!This->running) SetEvent(This->start);
175184 LeaveCriticalSection(&This->queuecs);
@@ -742,9 +751,9 @@
743752 DWORD vertsize = 0;
744753 DWORD indexsize = 0;
745754 if (!indices) indexcount = 0;
746 - vertsize = (stride * count) / 4;
747 - indexsize = NextMultipleOf2(indexcount) / 2;
748 - glRenderer_AddQueue(This, OP_DRAWPRIMITIVES, 0, 16 + vertsize + indexsize, 8, 4, &device,
 755+ vertsize = stride * count;
 756+ indexsize = NextMultipleOf4(indexcount * 2);
 757+ glRenderer_AddQueue(This, OP_DRAWPRIMITIVES, 0, 16 + ((vertsize + indexsize)/4), 8, 4, &device,
749758 4, &mode, 4, &stride, 4, &dwVertexTypeDesc, 4, &count, 4, &indexcount,
750759 vertsize, vertices, indexsize, indices);
751760 if (flags & D3DDP_WAIT) glRenderer_Sync(This, 0);
@@ -876,7 +885,7 @@
877886 {
878887 EnterCriticalSection(&This->commandcs);
879888 if (!This->running) memcpy(&This->transform[dtstTransformStateType], lpD3DMatrix, sizeof(D3DMATRIX));
880 - else glRenderer_AddQueue(This, OP_SETTRANSFORM, 0, 4 + (sizeof(D3DMATRIX) / 4), 2,
 889+ else glRenderer_AddQueue(This, OP_SETTRANSFORM, 0, 5 + (sizeof(D3DMATRIX) / 4), 2,
881890 4, &dtstTransformStateType, sizeof(D3DMATRIX), lpD3DMatrix);
882891 LeaveCriticalSection(&This->commandcs);
883892 }
@@ -892,8 +901,8 @@
893902 {
894903 EnterCriticalSection(&This->commandcs);
895904 if (!This->running) memcpy(&This->material, lpMaterial, sizeof(D3DMATERIAL7));
896 - glRenderer_AddQueue(This, OP_SETMATERIAL, 0, 2 + (sizeof(D3DMATERIAL7) / 4), 1,
897 - sizeof(D3DMATERIAL), lpMaterial);
 905+ glRenderer_AddQueue(This, OP_SETMATERIAL, 0, 3 + (sizeof(D3DMATERIAL7) / 4), 1,
 906+ sizeof(D3DMATERIAL7), lpMaterial);
898907 LeaveCriticalSection(&This->commandcs);
899908 }
900909
@@ -917,7 +926,7 @@
918927 DWORD _remove = remove;
919928 if (light) light7 = light;
920929 else light7 = &null_light;
921 - glRenderer_AddQueue(This, OP_SETLIGHT, 0, 6 + (sizeof(D3DLIGHT7) / 4), 3, 4, &index,
 930+ glRenderer_AddQueue(This, OP_SETLIGHT, 0, 7 + (sizeof(D3DLIGHT7) / 4), 3, 4, &index,
922931 4, &_remove, sizeof(D3DLIGHT7), light7);
923932 LeaveCriticalSection(&This->commandcs);
924933 }
@@ -932,7 +941,7 @@
933942 void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
934943 {
935944 EnterCriticalSection(&This->commandcs);
936 - glRenderer_AddQueue(This, OP_SETVIEWPORT, 0, 2 + (sizeof(D3DVIEWPORT7) / 4), 1,
 945+ glRenderer_AddQueue(This, OP_SETVIEWPORT, 0, 3 + (sizeof(D3DVIEWPORT7) / 4), 1,
937946 sizeof(D3DVIEWPORT7), lpViewport);
938947 LeaveCriticalSection(&This->commandcs);
939948 }
@@ -1111,21 +1120,21 @@
11121121 (D3DTEXTURESTAGESTATETYPE)This->queue[This->queue_read + 5], (DWORD)This->queue[This->queue_read + 7]);
11131122 break;
11141123 case OP_SETTRANSFORM:
1115 - if (This->queue[This->queue_read + 1] != (4 + (sizeof(D3DMATRIX) / 4))) break;
 1124+ if (This->queue[This->queue_read + 1] != (5 + (sizeof(D3DMATRIX) / 4))) break;
11161125 glRenderer__SetTransform(This, (D3DTRANSFORMSTATETYPE)This->queue[This->queue_read + 3],
11171126 (LPD3DMATRIX)&This->queue[This->queue_read + 5]);
11181127 break;
11191128 case OP_SETMATERIAL:
1120 - if (This->queue[This->queue_read + 1] != (2 + (sizeof(D3DMATERIAL7) / 4))) break;
 1129+ if (This->queue[This->queue_read + 1] != (3 + (sizeof(D3DMATERIAL7) / 4))) break;
11211130 glRenderer__SetMaterial(This, (LPD3DMATERIAL7)&This->queue[This->queue_read + 3]);
11221131 break;
11231132 case OP_SETLIGHT:
1124 - if (This->queue[This->queue_read + 1] != (6 + (sizeof(D3DLIGHT7) / 4))) break;
 1133+ if (This->queue[This->queue_read + 1] != (7 + (sizeof(D3DLIGHT7) / 4))) break;
11251134 glRenderer__SetLight(This, (DWORD)This->queue[This->queue_read + 3], (LPD3DLIGHT7)&This->queue[This->queue_read + 7],
11261135 (BOOL)This->queue[This->queue_read + 5]);
11271136 break;
11281137 case OP_SETVIEWPORT:
1129 - if (This->queue[This->queue_read + 1] != (2 + (sizeof(D3DVIEWPORT7) / 4))) break;
 1138+ if (This->queue[This->queue_read + 1] != (3 + (sizeof(D3DVIEWPORT7) / 4))) break;
11301139 glRenderer__SetViewport(This, (LPD3DVIEWPORT7)&This->queue[This->queue_read + 3]);
11311140 break;
11321141 case OP_RESETQUEUE: