DXGL r256 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r255‎ | r256 | r257 >
Date:22:15, 4 September 2012
Author:admin
Status:new
Tags:
Comment:
Add D3DTBLEND_MODULATE.
Add DX5 texture blend caps.
Add texture size caps for legacy D3D.
Modified paths:
  • /ddraw/glDirect3D.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)

Diff [purge]

Index: ddraw/glDirect3D.cpp
@@ -52,8 +52,10 @@
5353 D3DPTFILTERCAPS_MIPLINEAR | D3DPTFILTERCAPS_LINEARMIPNEAREST | D3DPTFILTERCAPS_LINEARMIPLINEAR |
5454 D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MINFLINEAR |
5555 D3DPTFILTERCAPS_MINFPOINT, //dwTextureFilterCaps
56 - 0, //dwTextureBlendCaps
57 - 0, //dwTextureAddressCaps
 56+ D3DPTBLENDCAPS_ADD | D3DPTBLENDCAPS_COPY | D3DPTBLENDCAPS_DECAL | D3DPTBLENDCAPS_DECALALPHA |
 57+ D3DPTBLENDCAPS_MODULATE | D3DPTBLENDCAPS_MODULATEALPHA, //dwTextureBlendCaps
 58+ D3DPTADDRESSCAPS_CLAMP | D3DPTADDRESSCAPS_INDEPENDENTUV |D3DPTADDRESSCAPS_MIRROR |
 59+ D3DPTADDRESSCAPS_WRAP, //dwTextureAddressCaps
5860 0, //dwStippleWidth
5961 0 //dwStippleHeight
6062 },
@@ -77,8 +79,10 @@
7880 D3DPTFILTERCAPS_MIPLINEAR | D3DPTFILTERCAPS_LINEARMIPNEAREST | D3DPTFILTERCAPS_LINEARMIPLINEAR |
7981 D3DPTFILTERCAPS_MAGFLINEAR | D3DPTFILTERCAPS_MAGFPOINT | D3DPTFILTERCAPS_MINFLINEAR |
8082 D3DPTFILTERCAPS_MINFPOINT, //dwTextureFilterCaps
81 - 0, //dwTextureBlendCaps
82 - 0, //dwTextureAddressCaps
 83+ D3DPTBLENDCAPS_ADD | D3DPTBLENDCAPS_COPY | D3DPTBLENDCAPS_DECAL | D3DPTBLENDCAPS_DECALALPHA |
 84+ D3DPTBLENDCAPS_MODULATE | D3DPTBLENDCAPS_MODULATEALPHA, //dwTextureBlendCaps
 85+ D3DPTADDRESSCAPS_CLAMP | D3DPTADDRESSCAPS_INDEPENDENTUV |D3DPTADDRESSCAPS_MIRROR |
 86+ D3DPTADDRESSCAPS_WRAP, //dwTextureAddressCaps
8387 0, //dwStippleWidth
8488 0 //dwStippleHeight
8589 },
Index: ddraw/glDirect3DDevice.cpp
@@ -256,6 +256,8 @@
257257 memset(gltextures,0,8*sizeof(GLuint));
258258 d3ddesc.dwMaxTextureWidth = d3ddesc.dwMaxTextureHeight =
259259 d3ddesc.dwMaxTextureRepeat = d3ddesc.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
 260+ d3ddesc3.dwMaxTextureWidth = d3ddesc3.dwMaxTextureHeight =
 261+ d3ddesc3.dwMaxTextureRepeat = d3ddesc3.dwMaxTextureAspectRatio = renderer->gl_caps.TextureMax;
260262 renderer->InitD3D(zbuffer);
261263 }
262264 glDirect3DDevice7::~glDirect3DDevice7()
@@ -486,7 +488,16 @@
487489 shader |= (__int64)blendweights << 46;
488490 if(renderstate[D3DRENDERSTATE_NORMALIZENORMALS]) shader |= (1i64 << 49);
489491 if(VertexType[1].data) shader |= (1i64 << 50);
490 - //TODO: Implement texture stages.
 492+ if(renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] == D3DTBLEND_MODULATE)
 493+ {
 494+ bool noalpha = false;;
 495+ if(!texstages[0].texture) noalpha = true;
 496+ if(texstages[0].texture)
 497+ if(!(texstages[0].texture->ddsd.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS))
 498+ noalpha = true;
 499+ if(noalpha) texstages[0].alphaop = D3DTOP_SELECTARG2;
 500+ else texstages[0].alphaop = D3DTOP_MODULATE;
 501+ }
491502 for(i = 0; i < 8; i++)
492503 {
493504 if(!texstages[i].dirty) continue;
@@ -1039,8 +1050,12 @@
10401051 SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);
10411052 break;
10421053 case D3DTBLEND_MODULATE:
1043 - FIXME("DX5 modulate not yet supported.");
1044 - ERR(DDERR_GENERIC);
 1054+ SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
 1055+ SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_CURRENT);
 1056+ SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
 1057+ SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_CURRENT);
 1058+ SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
 1059+ break; // Automatically selected based on texture
10451060 case D3DTBLEND_DECALALPHA:
10461061 SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
10471062 SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_CURRENT);
@@ -1113,6 +1128,7 @@
11141129 {
11151130 case D3DTSS_COLOROP:
11161131 if(!dwValue || (dwValue > 24)) return DDERR_INVALIDPARAMS;
 1132+ if(dwStage == 0)renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] = 0;
11171133 texstages[dwStage].colorop = (D3DTEXTUREOP)dwValue;
11181134 texstages[dwStage].dirty = true;
11191135 return D3D_OK;
@@ -1130,6 +1146,7 @@
11311147 return D3D_OK;
11321148 case D3DTSS_ALPHAOP:
11331149 if(!dwValue || (dwValue > 24)) return DDERR_INVALIDPARAMS;
 1150+ if(dwStage == 0)renderstate[D3DRENDERSTATE_TEXTUREMAPBLEND] = 0;
11341151 texstages[dwStage].alphaop = (D3DTEXTUREOP )dwValue;
11351152 texstages[dwStage].dirty = true;
11361153 return D3D_OK;