Index: ddraw/glDirect3D.cpp |
— | — | @@ -25,18 +25,22 @@ |
26 | 26 | D3DDEVICEDESC7 d3ddesc =
|
27 | 27 | {
|
28 | 28 | D3DDEVCAPS_CANBLTSYSTONONLOCAL | D3DDEVCAPS_CANRENDERAFTERFLIP | D3DDEVCAPS_DRAWPRIMTLVERTEX |
|
29 | | - D3DDEVCAPS_FLOATTLVERTEX, // dwDevCaps
|
| 29 | + D3DDEVCAPS_FLOATTLVERTEX | D3DDEVCAPS_TEXTURENONLOCALVIDMEM | D3DDEVCAPS_TEXTURESYSTEMMEMORY |
|
| 30 | + D3DDEVCAPS_TEXTUREVIDEOMEMORY | D3DDEVCAPS_TLVERTEXSYSTEMMEMORY | D3DDEVCAPS_TLVERTEXVIDEOMEMORY, // dwDevCaps
|
30 | 31 | { //dpcLineCaps
|
31 | 32 | sizeof(D3DPRIMCAPS),
|
32 | 33 | 0, // dwMiscCaps
|
33 | 34 | D3DPRASTERCAPS_SUBPIXEL | D3DPRASTERCAPS_ZTEST, //dwRasterCaps
|
34 | 35 | D3DPCMPCAPS_LESSEQUAL, //dwZCmpCaps
|
35 | | - DDBD_16|DDBD_24|DDBD_32, //dwSrcBlendCaps
|
36 | | - DDBD_16|DDBD_24|DDBD_32, //dwDestBlendCaps
|
| 36 | + 0, //dwSrcBlendCaps
|
| 37 | + 0, //dwDestBlendCaps
|
37 | 38 | 0, //dwAlphaCmpCaps
|
38 | | - 0, //dwShadeCaps
|
39 | | - 0, //dwTextureCaps
|
40 | | - 0, //dwTextureFilterCaps
|
| 39 | + D3DPSHADECAPS_COLORGOURAUDRGB, //dwShadeCaps
|
| 40 | + D3DPTEXTURECAPS_PERSPECTIVE, //dwTextureCaps
|
| 41 | + D3DPTFILTERCAPS_NEAREST | D3DPTFILTERCAPS_LINEAR | D3DPTFILTERCAPS_MIPNEAREST |
|
| 42 | + D3DPTFILTERCAPS_MIPLINEAR | D3DPTFILTERCAPS_LINEARMIPNEAREST | D3DPTFILTERCAPS_LINEARMIPLINEAR |
|
| 43 | + D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MINFLINEAR |
|
| 44 | + D3DPTFILTERCAPS_MINFPOINT, //dwTextureFilterCaps
|
41 | 45 | 0, //dwTextureBlendCaps
|
42 | 46 | 0, //dwTextureAddressCaps
|
43 | 47 | 0, //dwStippleWidth
|
— | — | @@ -50,9 +54,12 @@ |
51 | 55 | 0, //dwSrcBlendCaps
|
52 | 56 | 0, //dwDestBlendCaps
|
53 | 57 | 0, //dwAlphaCmpCaps
|
54 | | - 0, //dwShadeCaps
|
55 | | - 0, //dwTextureCaps
|
56 | | - 0, //dwTextureFilterCaps
|
| 58 | + D3DPSHADECAPS_COLORGOURAUDRGB, //dwShadeCaps
|
| 59 | + D3DPTEXTURECAPS_PERSPECTIVE, //dwTextureCaps
|
| 60 | + D3DPTFILTERCAPS_NEAREST | D3DPTFILTERCAPS_LINEAR | D3DPTFILTERCAPS_MIPNEAREST |
|
| 61 | + D3DPTFILTERCAPS_MIPLINEAR | D3DPTFILTERCAPS_LINEARMIPNEAREST | D3DPTFILTERCAPS_LINEARMIPLINEAR |
|
| 62 | + D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MINFLINEAR |
|
| 63 | + D3DPTFILTERCAPS_MINFPOINT, //dwTextureFilterCaps
|
57 | 64 | 0, //dwTextureBlendCaps
|
58 | 65 | 0, //dwTextureAddressCaps
|
59 | 66 | 0, //dwStippleWidth
|
— | — | @@ -60,8 +67,8 @@ |
61 | 68 | },
|
62 | 69 | DDBD_16|DDBD_24|DDBD_32, //dwDeviceRenderBitDepth
|
63 | 70 | DDBD_16|DDBD_24|DDBD_32, //dwDeviceZBufferBitDepth
|
64 | | - 0, //dwMinTextureWidth
|
65 | | - 0, //dwMinTextureHeight
|
| 71 | + 1, //dwMinTextureWidth
|
| 72 | + 1, //dwMinTextureHeight
|
66 | 73 | 0, //dwMaxTextureWidth
|
67 | 74 | 0, //dwMaxTextureHeight
|
68 | 75 | 0, //dwMaxTextureRepeat
|
— | — | @@ -74,9 +81,10 @@ |
75 | 82 | 0.0f, //dvExtentsAdjust
|
76 | 83 | 0, //dwStencilCaps
|
77 | 84 | 8, //dwFVFCaps
|
78 | | - 0, //dwTextureOpCaps
|
79 | | - 0, //wMaxTextureBlendStages
|
80 | | - 0, //wMaxSimultaneousTextures
|
| 85 | + D3DTEXOPCAPS_SELECTARG1 | D3DTEXOPCAPS_SELECTARG2 | D3DTOP_MODULATE |
|
| 86 | + D3DTOP_MODULATE2X | D3DTOP_MODULATE4X | D3DTOP_ADD, //dwTextureOpCaps
|
| 87 | + 8, //wMaxTextureBlendStages
|
| 88 | + 8, //wMaxSimultaneousTextures
|
81 | 89 | 8, //dwMaxActiveLights
|
82 | 90 | 0.0f, //dvMaxVertexW
|
83 | 91 | IID_IDirect3DHALDevice, //deviceGUID
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -28,6 +28,8 @@ |
29 | 29 | #include "glutil.h"
|
30 | 30 | #include "matrix.h"
|
31 | 31 |
|
| 32 | +extern D3DDEVICEDESC7 d3ddesc;
|
| 33 | +
|
32 | 34 | const DWORD renderstate_default[153] = {0, // 0
|
33 | 35 | NULL, //texturehandle
|
34 | 36 | D3DANTIALIAS_NONE, //antialias
|
— | — | @@ -173,8 +175,10 @@ |
174 | 176 | 0,
|
175 | 177 | D3DTTFF_DISABLE,
|
176 | 178 | NULL,
|
| 179 | + false,
|
177 | 180 | 0,
|
178 | | - 0
|
| 181 | + GL_NEAREST,
|
| 182 | + GL_NEAREST
|
179 | 183 | };
|
180 | 184 |
|
181 | 185 | int setdrawmode(D3DPRIMITIVETYPE d3dptPrimitiveType)
|
— | — | @@ -228,6 +232,8 @@ |
229 | 233 | ZeroMemory(lights,16*sizeof(glDirect3DLight*));
|
230 | 234 | memset(gllights,0xff,8*sizeof(int));
|
231 | 235 | memset(gltextures,0,8*sizeof(GLuint));
|
| 236 | + d3ddesc.dwMaxTextureWidth = d3ddesc.dwMaxTextureHeight =
|
| 237 | + d3ddesc.dwMaxTextureRepeat = d3ddesc.dwMaxTextureAspectRatio = glD3D7->glDD7->renderer->gl_caps.TextureMax;
|
232 | 238 | glD3D7->glDD7->renderer->InitD3D(zbuffer);
|
233 | 239 | }
|
234 | 240 | glDirect3DDevice7::~glDirect3DDevice7()
|
— | — | @@ -371,7 +377,7 @@ |
372 | 378 | shader |= ((renderstate[D3DRENDERSTATE_AMBIENTMATERIALSOURCE] & 3) << 27);
|
373 | 379 | shader |= ((renderstate[D3DRENDERSTATE_EMISSIVEMATERIALSOURCE] & 3) << 29);
|
374 | 380 | int numtextures = 0;
|
375 | | - for(int i = 0; i < 8; i++)
|
| 381 | + for(i = 0; i < 8; i++)
|
376 | 382 | if(VertexType[i+10].data) numtextures++;
|
377 | 383 | shader |= (__int64)numtextures << 31;
|
378 | 384 | if(VertexType[8].data) shader |= (1i64<<35);
|
— | — | @@ -416,10 +422,10 @@ |
417 | 423 | texstages[i].shaderid |= (__int64)(((texstages[i].textransform & 7) - 1)& 3) << 51;
|
418 | 424 | }
|
419 | 425 | if(texstages[i].textransform & D3DTTFF_PROJECTED) texstages[i].shaderid |= 1i64 << 53;
|
| 426 | + texstages[i].shaderid |= (__int64)(texstages[i].texcoordindex&7) << 54;
|
| 427 | + texstages[i].shaderid |= (__int64)((texstages[i].texcoordindex>>16)&3) << 57;
|
| 428 | + if(texstages[i].texture) texstages[i].shaderid |= 1i64 << 59;
|
420 | 429 | }
|
421 | | - texstages[i].shaderid |= (__int64)(texstages[i].texcoordindex&7) << 54;
|
422 | | - texstages[i].shaderid |= (__int64)((texstages[i].texcoordindex>>16)&3) << 57;
|
423 | | - if(texstages[i].texture) texstages[i].shaderid |= 1i64 << 59;
|
424 | 430 | return shader;
|
425 | 431 | }
|
426 | 432 |
|
— | — | @@ -1154,8 +1160,24 @@ |
1155 | 1161 | HRESULT WINAPI glDirect3DDevice7::ValidateDevice(LPDWORD lpdwPasses)
|
1156 | 1162 | {
|
1157 | 1163 | if(!this) return DDERR_INVALIDPARAMS;
|
1158 | | - FIXME("glDirect3DDevice7::ValidateDevice: stub");
|
1159 | | - ERR(DDERR_GENERIC);
|
| 1164 | + for(int i = 0; i < 8; i++)
|
| 1165 | + {
|
| 1166 | + switch(texstages[i].colorop)
|
| 1167 | + {
|
| 1168 | + case D3DTOP_DISABLE:
|
| 1169 | + case D3DTOP_SELECTARG1:
|
| 1170 | + case D3DTOP_SELECTARG2:
|
| 1171 | + case D3DTOP_MODULATE:
|
| 1172 | + case D3DTOP_MODULATE2X:
|
| 1173 | + case D3DTOP_MODULATE4X:
|
| 1174 | + case D3DTOP_ADD:
|
| 1175 | + break;
|
| 1176 | + default:
|
| 1177 | + return D3DERR_UNSUPPORTEDCOLOROPERATION;
|
| 1178 | + }
|
| 1179 | + }
|
| 1180 | + if(lpdwPasses) *lpdwPasses = 1;
|
| 1181 | + return D3D_OK;
|
1160 | 1182 | }
|
1161 | 1183 |
|
1162 | 1184 | void glDirect3DDevice7::UpdateNormalMatrix()
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -541,6 +541,7 @@ |
542 | 542 | gl_caps.ShaderVer = (GLfloat)atof((char*)glver);
|
543 | 543 | }
|
544 | 544 | else gl_caps.ShaderVer = 0;
|
| 545 | + glGetIntegerv(GL_MAX_TEXTURE_SIZE,&gl_caps.TextureMax);
|
545 | 546 | CompileShaders();
|
546 | 547 | InitFBO();
|
547 | 548 | glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
— | — | @@ -1070,20 +1071,32 @@ |
1071 | 1072 | case -1: // Null
|
1072 | 1073 | break;
|
1073 | 1074 | case 0: // st
|
1074 | | - glEnableVertexAttribArray(prog.attribs[i+18]);
|
1075 | | - glVertexAttribPointer(prog.attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1075 | + if(prog.attribs[i+18] != -1)
|
| 1076 | + {
|
| 1077 | + glEnableVertexAttribArray(prog.attribs[i+18]);
|
| 1078 | + glVertexAttribPointer(prog.attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1079 | + }
|
1076 | 1080 | break;
|
1077 | 1081 | case 1: // str
|
1078 | | - glEnableVertexAttribArray(prog.attribs[i+26]);
|
1079 | | - glVertexAttribPointer(prog.attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1082 | + if(prog.attribs[i+26] != -1)
|
| 1083 | + {
|
| 1084 | + glEnableVertexAttribArray(prog.attribs[i+26]);
|
| 1085 | + glVertexAttribPointer(prog.attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1086 | + }
|
1080 | 1087 | break;
|
1081 | 1088 | case 2: // strq
|
1082 | | - glEnableVertexAttribArray(prog.attribs[i+34]);
|
1083 | | - glVertexAttribPointer(prog.attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1089 | + if(prog.attribs[i+34] != -1)
|
| 1090 | + {
|
| 1091 | + glEnableVertexAttribArray(prog.attribs[i+34]);
|
| 1092 | + glVertexAttribPointer(prog.attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1093 | + }
|
1084 | 1094 | break;
|
1085 | 1095 | case 3: // s
|
1086 | | - glEnableVertexAttribArray(prog.attribs[i+10]);
|
1087 | | - glVertexAttribPointer(prog.attribs[i+10],1,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1096 | + if(prog.attribs[i+10] != -1)
|
| 1097 | + {
|
| 1098 | + glEnableVertexAttribArray(prog.attribs[i+10]);
|
| 1099 | + glVertexAttribPointer(prog.attribs[i+10],1,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
| 1100 | + }
|
1088 | 1101 | break;
|
1089 | 1102 | }
|
1090 | 1103 |
|
Index: ddraw/glRenderer.h |
— | — | @@ -22,12 +22,7 @@ |
23 | 23 | {
|
24 | 24 | float Version;
|
25 | 25 | float ShaderVer;
|
26 | | - int TextureMaxX;
|
27 | | - int TextureMaxY;
|
28 | | - bool NonPowerOfTwo;
|
29 | | - int RenderToTexture; // 0 - no support, 1 -
|
30 | | - int MultiTextureExt;
|
31 | | - int PalettedTextures;
|
| 26 | + GLint TextureMax;
|
32 | 27 | } GLCAPS;
|
33 | 28 | typedef struct
|
34 | 29 | {
|
— | — | @@ -98,6 +93,7 @@ |
99 | 94 | DWORD indexcount, DWORD flags);
|
100 | 95 | HGLRC hRC;
|
101 | 96 | LRESULT WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
|
| 97 | + GLCAPS gl_caps;
|
102 | 98 | private:
|
103 | 99 | // In-thread APIs
|
104 | 100 | DWORD _Entry();
|
— | — | @@ -124,7 +120,6 @@ |
125 | 121 | HWND hWnd;
|
126 | 122 | HWND hRenderWnd;
|
127 | 123 | bool hasHWnd;
|
128 | | - GLCAPS gl_caps;
|
129 | 124 | DIB dib;
|
130 | 125 | GLuint PBO;
|
131 | 126 | CRITICAL_SECTION cs;
|
Index: ddraw/shadergen.cpp |
— | — | @@ -197,6 +197,7 @@ |
198 | 198 | static const char attr_xyz[] = "attribute vec3 xyz;\n";
|
199 | 199 | static const char attr_rhw[] = "attribute float rhw;\n";
|
200 | 200 | static const char attr_nxyz[] = "attribute vec3 nxyz;\n";
|
| 201 | +static const char const_nxyz[] = "const vec3 nxyz = vec3(0,0,0);\n";
|
201 | 202 | static const char attr_blend[] = "attribute float blendX;\n";
|
202 | 203 | static const char attr_rgba[] = "attribute vec4 rgbaX;\n";
|
203 | 204 | static const char attr_s[] = "attribute float sX;\n";
|
— | — | @@ -333,6 +334,7 @@ |
334 | 335 | vsrc->append(tmp);
|
335 | 336 | }
|
336 | 337 | if((id>>37)&1) vsrc->append(attr_nxyz);
|
| 338 | + else vsrc->append(const_nxyz);
|
337 | 339 | count = (id>>46)&7;
|
338 | 340 | if(count)
|
339 | 341 | {
|
— | — | @@ -531,6 +533,7 @@ |
532 | 534 | fsrc->append(op_colorfragin);
|
533 | 535 | string arg1,arg2;
|
534 | 536 | int args[4];
|
| 537 | + bool texfail;
|
535 | 538 | const string blendargs[] = {"color","gl_Color","texture2DProj(texX,gl_TexCoord[Y]).rgb",
|
536 | 539 | "texture2DProj(texX,gl_TexCoord[Y]).a","texfactor","gl_SecondaryColor","vec3(1,1,1)","1"};
|
537 | 540 | for(i = 0; i < 8; i++)
|
— | — | @@ -537,6 +540,7 @@ |
538 | 541 | {
|
539 | 542 | if((texstate[i].shaderid & 31) == D3DTOP_DISABLE)break;
|
540 | 543 | // Color stage
|
| 544 | + texfail = false;
|
541 | 545 | args[0] = (texstate[i].shaderid>>5)&63;
|
542 | 546 | switch(args[0]&7) //arg1
|
543 | 547 | {
|
— | — | @@ -548,9 +552,13 @@ |
549 | 553 | arg1 = blendargs[1];
|
550 | 554 | break;
|
551 | 555 | case D3DTA_TEXTURE:
|
552 | | - arg1 = blendargs[2];
|
553 | | - arg1.replace(17,1,_itoa(i,idstring,10));
|
554 | | - arg1.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 556 | + if((texstate[i].shaderid >> 59)&1)
|
| 557 | + {
|
| 558 | + arg1 = blendargs[2];
|
| 559 | + arg1.replace(17,1,_itoa(i,idstring,10));
|
| 560 | + arg1.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 561 | + }
|
| 562 | + else texfail = true;
|
555 | 563 | break;
|
556 | 564 | case D3DTA_TFACTOR:
|
557 | 565 | FIXME("Support texture factor value");
|
— | — | @@ -571,9 +579,13 @@ |
572 | 580 | arg2 = blendargs[1];
|
573 | 581 | break;
|
574 | 582 | case D3DTA_TEXTURE:
|
575 | | - arg2 = blendargs[3];
|
576 | | - arg2.replace(17,1,_itoa(i,idstring,10));
|
577 | | - arg2.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 583 | + if((texstate[i].shaderid >> 59)&1)
|
| 584 | + {
|
| 585 | + arg2 = blendargs[3];
|
| 586 | + arg2.replace(17,1,_itoa(i,idstring,10));
|
| 587 | + arg2.replace(31,1,_itoa((texstate[i].shaderid>>54)&7,idstring,10));
|
| 588 | + }
|
| 589 | + else texfail = true;
|
578 | 590 | break;
|
579 | 591 | case D3DTA_TFACTOR:
|
580 | 592 | FIXME("Support texture factor value");
|
— | — | @@ -583,7 +595,7 @@ |
584 | 596 | arg2 = blendargs[5];
|
585 | 597 | break;
|
586 | 598 | }
|
587 | | - switch(texstate[i].shaderid & 31)
|
| 599 | + if(!texfail) switch(texstate[i].shaderid & 31)
|
588 | 600 | {
|
589 | 601 | case D3DTOP_DISABLE:
|
590 | 602 | default:
|