| Index: ddraw/glDirect3DDevice.cpp |
| — | — | @@ -246,6 +246,30 @@ |
| 247 | 247 | }
|
| 248 | 248 | }
|
| 249 | 249 |
|
| | 250 | +void AddStats(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwCount, D3DSTATS *stats)
|
| | 251 | +{
|
| | 252 | + switch(d3dptPrimitiveType)
|
| | 253 | + {
|
| | 254 | + case D3DPT_POINTLIST:
|
| | 255 | + stats->dwPointsDrawn += dwCount;
|
| | 256 | + break;
|
| | 257 | + case D3DPT_LINELIST:
|
| | 258 | + stats->dwLinesDrawn += dwCount / 2;
|
| | 259 | + break;
|
| | 260 | + case D3DPT_LINESTRIP:
|
| | 261 | + if(dwCount > 1) stats->dwLinesDrawn += dwCount - 1;
|
| | 262 | + break;
|
| | 263 | + case D3DPT_TRIANGLELIST:
|
| | 264 | + stats->dwTrianglesDrawn += dwCount / 3;
|
| | 265 | + break;
|
| | 266 | + case D3DPT_TRIANGLESTRIP:
|
| | 267 | + case D3DPT_TRIANGLEFAN:
|
| | 268 | + if(dwCount > 2) stats->dwTrianglesDrawn += dwCount - 2;
|
| | 269 | + break;
|
| | 270 | + default:
|
| | 271 | + break;
|
| | 272 | + }
|
| | 273 | +}
|
| 250 | 274 |
|
| 251 | 275 | glDirect3DDevice7::glDirect3DDevice7(REFCLSID rclsid, glDirect3D7 *glD3D7, glDirectDrawSurface7 *glDDS7)
|
| 252 | 276 | {
|
| — | — | @@ -326,6 +350,8 @@ |
| 327 | 351 | ZeroMemory(lights,16*sizeof(glDirect3DLight*));
|
| 328 | 352 | memset(gllights,0xff,8*sizeof(int));
|
| 329 | 353 | memset(gltextures,0,8*sizeof(GLuint));
|
| | 354 | + ZeroMemory(&stats,sizeof(D3DSTATS));
|
| | 355 | + stats.dwSize = sizeof(D3DSTATS);
|
| 330 | 356 | d3ddesc.dwMaxTextureWidth = d3ddesc.dwMaxTextureHeight =
|
| 331 | 357 | d3ddesc.dwMaxTextureRepeat = d3ddesc.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
|
| 332 | 358 | d3ddesc3.dwMaxTextureWidth = d3ddesc3.dwMaxTextureHeight =
|
| — | — | @@ -708,6 +734,8 @@ |
| 709 | 735 | if(!this) return DDERR_INVALIDOBJECT;
|
| 710 | 736 | if(!inscene) return D3DERR_SCENE_NOT_IN_SCENE;
|
| 711 | 737 | HRESULT err = fvftoglvertex(dwVertexTypeDesc,(LPDWORD)lpvVertices);
|
| | 738 | + if(lpwIndices) AddStats(d3dptPrimitiveType,dwIndexCount,&stats);
|
| | 739 | + else AddStats(d3dptPrimitiveType,dwVertexCount,&stats);
|
| 712 | 740 | if(err != D3D_OK) return err;
|
| 713 | 741 | return renderer->DrawPrimitives(this,setdrawmode(d3dptPrimitiveType),vertdata,texformats,
|
| 714 | 742 | dwVertexCount,lpwIndices,dwIndexCount,dwFlags);
|
| — | — | @@ -1814,8 +1842,9 @@ |
| 1815 | 1843 | {
|
| 1816 | 1844 | if(!this) return DDERR_INVALIDOBJECT;
|
| 1817 | 1845 | if(!lpD3DStats) return DDERR_INVALIDPARAMS;
|
| 1818 | | - FIXME("glDirect3DDevice7::GetStats: stub");
|
| 1819 | | - return DDERR_GENERIC;
|
| | 1846 | + if(lpD3DStats->dwSize < sizeof(D3DSTATS)) return DDERR_INVALIDPARAMS;
|
| | 1847 | + memcpy(lpD3DStats,&stats,sizeof(D3DSTATS));
|
| | 1848 | + return D3D_OK;
|
| 1820 | 1849 | }
|
| 1821 | 1850 |
|
| 1822 | 1851 | HRESULT glDirect3DDevice7::SwapTextureHandles(LPDIRECT3DTEXTURE2 lpD3DTex1, LPDIRECT3DTEXTURE2 lpD3DTex2)
|
| — | — | @@ -2282,6 +2311,7 @@ |
| 2283 | 2312 | default:
|
| 2284 | 2313 | break;
|
| 2285 | 2314 | }
|
| | 2315 | + stats.dwVerticesProcessed += ((D3DPROCESSVERTICES*)opptr)->dwCount;
|
| 2286 | 2316 | opptr += instruction->bSize;
|
| 2287 | 2317 | }
|
| 2288 | 2318 | break;
|
| — | — | @@ -2301,8 +2331,20 @@ |
| 2302 | 2332 | FIXME("D3DOP_SPAN: stub");
|
| 2303 | 2333 | break;
|
| 2304 | 2334 | case D3DOP_SETSTATUS:
|
| 2305 | | - opptr += sizeof(D3DINSTRUCTION)+(instruction->bSize*instruction->wCount);
|
| 2306 | | - FIXME("D3DOP_SETSTATUS: stub");
|
| | 2335 | + opptr += sizeof(D3DINSTRUCTION);
|
| | 2336 | + if(instruction->bSize < sizeof(D3DSTATUS))
|
| | 2337 | + {
|
| | 2338 | + opptr += (instruction->bSize*instruction->wCount);
|
| | 2339 | + break;
|
| | 2340 | + }
|
| | 2341 | + for(i = 0; i < instruction->wCount; i++)
|
| | 2342 | + {
|
| | 2343 | + if(((D3DSTATUS*)opptr)->dwFlags & D3DSETSTATUS_STATUS)
|
| | 2344 | + data.dsStatus.dwStatus = ((D3DSTATUS*)opptr)->dwStatus;
|
| | 2345 | + if(((D3DSTATUS*)opptr)->dwFlags & D3DSETSTATUS_EXTENTS)
|
| | 2346 | + data.dsStatus.drExtent = ((D3DSTATUS*)opptr)->drExtent;
|
| | 2347 | + opptr += instruction->bSize;
|
| | 2348 | + }
|
| 2307 | 2349 | break;
|
| 2308 | 2350 | default:
|
| 2309 | 2351 | opptr += sizeof(D3DINSTRUCTION)+(instruction->bSize*instruction->wCount);
|
| Index: ddraw/glDirect3DDevice.h |
| — | — | @@ -191,6 +191,7 @@ |
| 192 | 192 | int texturecount;
|
| 193 | 193 | bool modelview_dirty;
|
| 194 | 194 | bool projection_dirty;
|
| | 195 | + D3DSTATS stats;
|
| 195 | 196 | glDirect3DDevice3 *glD3DDev3;
|
| 196 | 197 | glDirect3DDevice2 *glD3DDev2;
|
| 197 | 198 | glDirect3DDevice1 *glD3DDev1;
|
| Index: ddraw/shadergen.cpp |
| — | — | @@ -476,6 +476,7 @@ |
| 477 | 477 | if((id>>50)&1) vsrc->append(unif_size);
|
| 478 | 478 | if((id>>59)&1) numlights = (id>>18)&7;
|
| 479 | 479 | else numlights = 0;
|
| | 480 | + if((id>>50)&1) numlights = 0;
|
| 480 | 481 | if(numlights) // Lighting
|
| 481 | 482 | {
|
| 482 | 483 | vsrc->append(lightstruct);
|