1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Generate mip levels for DynamicTextMaps

This changeset introduced a new plBitmap flag `kAutoGenMipmap`, which
trickles through the pipeline and becomes `D3DUSAGE_AUTOGENMIPMAP` in
standard DirectX texture creation. This flag is applied to all
DyanmicTextMaps. The end result is that DynamicTextMaps become fuzzy at a
distance, rather than choppy.
This commit is contained in:
2013-01-30 22:10:52 -05:00
parent 33d26ce29f
commit 2b06708915
5 changed files with 28 additions and 30 deletions

View File

@ -209,17 +209,9 @@ plDXTextureRef& plDXTextureRef::Set( D3DFORMAT ft, uint32_t ml, uint32_t mw, uin
//// Constructor & Destructor /////////////////////////////////////////////////
plDXTextureRef::plDXTextureRef( D3DFORMAT ft, uint32_t ml, uint32_t mw, uint32_t mh, uint32_t np,
uint32_t sz, uint32_t manSize, uint32_t* lSz, void* pd, bool ed, bool renderTarget )
uint32_t sz, uint32_t manSize, uint32_t* lSz, void* pd, bool ed, bool renderTarget )
: fD3DTexture(nullptr), fLevelSizes(nullptr), fOwner(nullptr)
{
fLevelSizes = nil;
fOwner = nil;
fD3DTexture = nil;
fDataSize = 0;
fFlags = 0;
fFormatType = D3DFMT_UNKNOWN;
fMMLvs = 0;
fMaxWidth = 0;
fMaxHeight = 0;
Set( ft, ml, mw, mh, np, sz, manSize, lSz, pd, ed, renderTarget );
}

View File

@ -8292,6 +8292,14 @@ void plDXPipeline::IReloadTexture( plDXTextureRef *ref )
}
}
static uint32_t IGetD3DTextureUsage(const plDXTextureRef* ref)
{
uint32_t usage = 0;
if (ref->GetFlags() & plDXTextureRef::kAutoGenMipmap)
usage |= D3DUSAGE_AUTOGENMIPMAP;
return usage;
}
//// IMakeD3DTexture //////////////////////////////////////////////////////////
// Makes a DX Texture object based on the ref given.
@ -8302,7 +8310,7 @@ IDirect3DTexture9 *plDXPipeline::IMakeD3DTexture( plDXTextureRef *ref, D3DFORM
fManagedAlloced = true;
if( FAILED( fSettings.fDXError = fD3DDevice->CreateTexture( ref->fMaxWidth, ref->fMaxHeight,
ref->fMMLvs,
0,
IGetD3DTextureUsage(ref),
formatType,
poolType,
&texPtr, NULL ) ) )
@ -8474,6 +8482,11 @@ hsGDeviceRef *plDXPipeline::MakeTextureRef( plLayerInterface* layer, plMipmap
ref->Link( &fTextureRefList );
}
// NOTE: This is just a hint, so setting it on a device with no support for it
// or mipmaps in general won't do any damage.
if (original->GetFlags() & plMipmap::kAutoGenMipmap)
ref->SetFlags(ref->GetFlags() | plDXTextureRef::kAutoGenMipmap);
/// Copy the data into the ref
IReloadTexture( ref );

View File

@ -76,7 +76,8 @@ class plDXTextureRef : public plDXDeviceRef
kProjection = kPerspProjection | kOrthoProjection,
kOffscreenRT = 0x00000040, // Offscreen renderTarget. Never used as an actual texture,
// but handy to still have it as a textureRef
kUVWNormal = 0x00000080 // Use the normal as the UVW src
kUVWNormal = 0x00000080, // Use the normal as the UVW src
kAutoGenMipmap = 0x00000100 // DirectX should generate mip levels for us
};
IDirect3DBaseTexture9 *fD3DTexture;
@ -94,7 +95,7 @@ class plDXTextureRef : public plDXDeviceRef
void* fData; // for reloading
uint32_t GetFlags( void ) { return fFlags; }
uint32_t GetFlags() const { return fFlags; }
void SetFlags( uint32_t flag ) { fFlags = flag; }
plDXTextureRef& Set( D3DFORMAT tp, uint32_t ml, uint32_t mw, uint32_t mh, uint32_t np, uint32_t sz, uint32_t manSize, uint32_t* lSz, void* pd, bool ed=false, bool renderTarget = false );