|
@@ -972,7 +972,7 @@ HRESULT ConvertDDSurftoPixBuf(PixelBuffer *pixbuf,LPDIRECTDRAWSURFACE7 pDDSurf)
|
|
|
// texture, and then copies the bitmap into the texture.
|
|
// texture, and then copies the bitmap into the texture.
|
|
|
//-----------------------------------------------------------------------------
|
|
//-----------------------------------------------------------------------------
|
|
|
LPDIRECTDRAWSURFACE7 DXTextureContext::
|
|
LPDIRECTDRAWSURFACE7 DXTextureContext::
|
|
|
-CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts) {
|
|
|
|
|
|
|
+CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT pTexPixFmts, LPD3DDEVICEDESC7 pD3DDevDesc) {
|
|
|
HRESULT hr;
|
|
HRESULT hr;
|
|
|
int i;
|
|
int i;
|
|
|
PixelBuffer *pbuf = _texture->_pbuffer;
|
|
PixelBuffer *pbuf = _texture->_pbuffer;
|
|
@@ -1006,19 +1006,10 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
|
|
DWORD dwOrigWidth = (DWORD)pbuf->get_xsize();
|
|
DWORD dwOrigWidth = (DWORD)pbuf->get_xsize();
|
|
|
DWORD dwOrigHeight = (DWORD)pbuf->get_ysize();
|
|
DWORD dwOrigHeight = (DWORD)pbuf->get_ysize();
|
|
|
|
|
|
|
|
- // Get the device caps so we can check if the device has any constraints
|
|
|
|
|
- // when using textures. Could we use the
|
|
|
|
|
- D3DDEVICEDESC7 devDesc;
|
|
|
|
|
- if(FAILED( pd3dDevice->GetCaps( &devDesc ) )) {
|
|
|
|
|
- goto error_exit;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // s3 virge drivers sometimes give crap values for these
|
|
|
|
|
- if(devDesc.dwMaxTextureWidth==0)
|
|
|
|
|
- devDesc.dwMaxTextureWidth=256;
|
|
|
|
|
|
|
+ // Use the device caps so we can check if the device has any constraints
|
|
|
|
|
+ // when using textures.
|
|
|
|
|
|
|
|
- if(devDesc.dwMaxTextureHeight==0)
|
|
|
|
|
- devDesc.dwMaxTextureHeight=256;
|
|
|
|
|
|
|
+ assert((pD3DDevDesc->dwMaxTextureWidth>0) && (pD3DDevDesc->dwMaxTextureHeight>0));
|
|
|
|
|
|
|
|
// Setup the new surface desc for the texture. Note how we are using the
|
|
// Setup the new surface desc for the texture. Note how we are using the
|
|
|
// texture manage attribute, so Direct3D does alot of dirty work for us
|
|
// texture manage attribute, so Direct3D does alot of dirty work for us
|
|
@@ -1073,21 +1064,21 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
|
|
bool bShrinkOriginal;
|
|
bool bShrinkOriginal;
|
|
|
bShrinkOriginal=false;
|
|
bShrinkOriginal=false;
|
|
|
|
|
|
|
|
- if((dwOrigWidth>devDesc.dwMaxTextureWidth)||(dwOrigHeight>devDesc.dwMaxTextureHeight)) {
|
|
|
|
|
|
|
+ if((dwOrigWidth>pD3DDevDesc->dwMaxTextureWidth)||(dwOrigHeight>pD3DDevDesc->dwMaxTextureHeight)) {
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
- dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << devDesc.dwMaxTextureWidth << "," << devDesc.dwMaxTextureHeight << ") !!\n"
|
|
|
|
|
- << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< devDesc.dwMaxTextureWidth << "," << devDesc.dwMaxTextureHeight << ") !\n";
|
|
|
|
|
|
|
+ dxgsg_cat.error() << "WARNING: " <<_tex->get_name() << ": Image size exceeds max texture dimensions of (" << pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !!\n"
|
|
|
|
|
+ << "Scaling "<< _tex->get_name() << " ("<< dwOrigWidth<<"," <<dwOrigHeight << ") => ("<< pD3DDevDesc->dwMaxTextureWidth << "," << pD3DDevDesc->dwMaxTextureHeight << ") !\n";
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
- if(dwOrigWidth>devDesc.dwMaxTextureWidth)
|
|
|
|
|
- ddsd.dwWidth=devDesc.dwMaxTextureWidth;
|
|
|
|
|
- if(dwOrigHeight>devDesc.dwMaxTextureHeight)
|
|
|
|
|
- ddsd.dwHeight=devDesc.dwMaxTextureHeight;
|
|
|
|
|
|
|
+ if(dwOrigWidth>pD3DDevDesc->dwMaxTextureWidth)
|
|
|
|
|
+ ddsd.dwWidth=pD3DDevDesc->dwMaxTextureWidth;
|
|
|
|
|
+ if(dwOrigHeight>pD3DDevDesc->dwMaxTextureHeight)
|
|
|
|
|
+ ddsd.dwHeight=pD3DDevDesc->dwMaxTextureHeight;
|
|
|
bShrinkOriginal=true;
|
|
bShrinkOriginal=true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// checks for SQUARE reqmt (nvidia riva128 needs this)
|
|
// checks for SQUARE reqmt (nvidia riva128 needs this)
|
|
|
- if((ddsd.dwWidth != ddsd.dwHeight) && (devDesc.dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )) {
|
|
|
|
|
|
|
+ if((ddsd.dwWidth != ddsd.dwHeight) && (pD3DDevDesc->dpcTriCaps.dwTextureCaps & D3DPTEXTURECAPS_SQUAREONLY )) {
|
|
|
|
|
|
|
|
// assume pow2 textures. sum exponents, divide by 2 rounding down to get sq size
|
|
// assume pow2 textures. sum exponents, divide by 2 rounding down to get sq size
|
|
|
int i,width_exp,height_exp;
|
|
int i,width_exp,height_exp;
|
|
@@ -1489,7 +1480,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
|
|
else ft=Texture::FT_linear;
|
|
else ft=Texture::FT_linear;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if((ft==Texture::FT_linear) && !(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
|
|
|
|
|
|
+ if((ft==Texture::FT_linear) && !(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
|
|
ft=Texture::FT_nearest;
|
|
ft=Texture::FT_nearest;
|
|
|
_tex->set_magfilter(ft);
|
|
_tex->set_magfilter(ft);
|
|
|
|
|
|
|
@@ -1522,26 +1513,26 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
|
|
ft=Texture::FT_linear;
|
|
ft=Texture::FT_linear;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- assert((devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_NEAREST)!=0);
|
|
|
|
|
|
|
+ assert((pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_NEAREST)!=0);
|
|
|
|
|
|
|
|
switch(ft) {
|
|
switch(ft) {
|
|
|
case Texture::FT_nearest_mipmap_linear:
|
|
case Texture::FT_nearest_mipmap_linear:
|
|
|
- if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPNEAREST))
|
|
|
|
|
|
|
+ if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPNEAREST))
|
|
|
ft=Texture::FT_nearest_mipmap_nearest;
|
|
ft=Texture::FT_nearest_mipmap_nearest;
|
|
|
break;
|
|
break;
|
|
|
case Texture::FT_linear_mipmap_nearest:
|
|
case Texture::FT_linear_mipmap_nearest:
|
|
|
- if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR))
|
|
|
|
|
|
|
+ if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR))
|
|
|
ft=Texture::FT_nearest_mipmap_nearest;
|
|
ft=Texture::FT_nearest_mipmap_nearest;
|
|
|
break;
|
|
break;
|
|
|
case Texture::FT_linear_mipmap_linear:
|
|
case Texture::FT_linear_mipmap_linear:
|
|
|
- if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPLINEAR)) {
|
|
|
|
|
- if(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR)
|
|
|
|
|
|
|
+ if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEARMIPLINEAR)) {
|
|
|
|
|
+ if(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_MIPLINEAR)
|
|
|
ft=Texture::FT_linear_mipmap_nearest;
|
|
ft=Texture::FT_linear_mipmap_nearest;
|
|
|
else ft=Texture::FT_nearest_mipmap_nearest; // if you cant do linear in a level, you probably cant do linear b/w levels, so just do nearest-all
|
|
else ft=Texture::FT_nearest_mipmap_nearest; // if you cant do linear in a level, you probably cant do linear b/w levels, so just do nearest-all
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
case Texture::FT_linear:
|
|
case Texture::FT_linear:
|
|
|
- if(!(devDesc.dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
|
|
|
|
|
|
+ if(!(pD3DDevDesc->dpcTriCaps.dwTextureFilterCaps & D3DPTFILTERCAPS_LINEAR))
|
|
|
ft=Texture::FT_nearest;
|
|
ft=Texture::FT_nearest;
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -1551,14 +1542,14 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
|
|
uint aniso_degree;
|
|
uint aniso_degree;
|
|
|
|
|
|
|
|
aniso_degree=1;
|
|
aniso_degree=1;
|
|
|
- if(devDesc.dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANISOTROPY) {
|
|
|
|
|
|
|
+ if(pD3DDevDesc->dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ANISOTROPY) {
|
|
|
aniso_degree=_tex->get_anisotropic_degree();
|
|
aniso_degree=_tex->get_anisotropic_degree();
|
|
|
- if((aniso_degree>devDesc.dwMaxAnisotropy)
|
|
|
|
|
|
|
+ if((aniso_degree>pD3DDevDesc->dwMaxAnisotropy)
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
|
|| dx_force_anisotropic_filtering
|
|
|| dx_force_anisotropic_filtering
|
|
|
#endif
|
|
#endif
|
|
|
)
|
|
)
|
|
|
- aniso_degree=devDesc.dwMaxAnisotropy;
|
|
|
|
|
|
|
+ aniso_degree=pD3DDevDesc->dwMaxAnisotropy;
|
|
|
}
|
|
}
|
|
|
_tex->set_anisotropic_degree(aniso_degree);
|
|
_tex->set_anisotropic_degree(aniso_degree);
|
|
|
#ifdef _DEBUG
|
|
#ifdef _DEBUG
|
|
@@ -1572,7 +1563,7 @@ CreateTexture(LPDIRECT3DDEVICE7 pd3dDevice, int cNumTexPixFmts, LPDDPIXELFORMAT
|
|
|
dxgsg_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
|
|
dxgsg_cat.debug() << "CreateTexture: generating mipmaps for "<< _tex->get_name() << endl;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if(devDesc.dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
|
|
|
|
|
|
|
+ if(pD3DDevDesc->dwDevCaps & D3DDEVCAPS_SEPARATETEXTUREMEMORIES) {
|
|
|
// must assign a texture to a specific stage
|
|
// must assign a texture to a specific stage
|
|
|
// for now I'm just going to use stage 0 for all
|
|
// for now I'm just going to use stage 0 for all
|
|
|
ddsd.dwTextureStage=0;
|
|
ddsd.dwTextureStage=0;
|