mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-09-11 15:13:37 +02:00
D3D9: Support AUTO mip bias and approximate CONST.
This commit is contained in:
@@ -313,6 +313,8 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
|
||||
dxstate.texMagFilter.set(D3DTEXF_POINT);
|
||||
dxstate.texMinFilter.set(D3DTEXF_POINT);
|
||||
}
|
||||
dxstate.texMipLodBias.set(0.0f);
|
||||
dxstate.texMaxMipLevel.set(0);
|
||||
device_->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
|
||||
HRESULT hr = device_->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coord, 5 * sizeof(float));
|
||||
if (FAILED(hr)) {
|
||||
|
||||
@@ -160,17 +160,26 @@ void TextureCacheDX9::UpdateSamplingParams(TexCacheEntry &entry, bool force) {
|
||||
GETexLevelMode mode = gstate.getTexLevelMode();
|
||||
switch (mode) {
|
||||
case GE_TEXLEVEL_MODE_AUTO:
|
||||
// TODO
|
||||
dxstate.texMaxMipLevel.set(0);
|
||||
dxstate.texMipLodBias.set(lodBias);
|
||||
break;
|
||||
case GE_TEXLEVEL_MODE_CONST:
|
||||
dxstate.texMipLodBias.set(lodBias);
|
||||
// TODO
|
||||
// TODO: This is just an approximation - texMaxMipLevel sets the lowest numbered mip to use.
|
||||
// Unfortunately, this doesn't support a const 1.5 or etc.
|
||||
dxstate.texMaxMipLevel.set((int)lodBias);
|
||||
dxstate.texMipLodBias.set(-1000.0f);
|
||||
break;
|
||||
case GE_TEXLEVEL_MODE_SLOPE:
|
||||
// TODO
|
||||
WARN_LOG_REPORT_ONCE(texSlope, G3D, "Unsupported texture lod slope: %f + %f", gstate.getTextureLodSlope(), lodBias);
|
||||
// TODO: This behavior isn't correct.
|
||||
dxstate.texMaxMipLevel.set(0);
|
||||
dxstate.texMipLodBias.set(lodBias);
|
||||
break;
|
||||
}
|
||||
entry.lodBias = lodBias;
|
||||
} else {
|
||||
dxstate.texMaxMipLevel.set(0);
|
||||
dxstate.texMipLodBias.set(0.0f);
|
||||
}
|
||||
|
||||
D3DTEXTUREFILTERTYPE minf = (D3DTEXTUREFILTERTYPE)MinFilt[minFilt];
|
||||
@@ -199,6 +208,8 @@ void TextureCacheDX9::SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHe
|
||||
dxstate.texMinFilter.set(MinFilt[minFilt]);
|
||||
dxstate.texMipFilter.set(MipFilt[minFilt]);
|
||||
dxstate.texMagFilter.set(MagFilt[magFilt]);
|
||||
dxstate.texMipLodBias.set(0.0f);
|
||||
dxstate.texMaxMipLevel.set(0.0f);
|
||||
|
||||
// Often the framebuffer will not match the texture size. We'll wrap/clamp in the shader in that case.
|
||||
// This happens whether we have OES_texture_npot or not.
|
||||
@@ -437,6 +448,8 @@ void TextureCacheDX9::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFrame
|
||||
device_->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||
device_->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
||||
device_->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
|
||||
device_->SetSamplerState(0, D3DSAMP_MIPMAPLODBIAS, 0);
|
||||
device_->SetSamplerState(0, D3DSAMP_MAXMIPLEVEL, 0);
|
||||
|
||||
shaderApply.Shade();
|
||||
|
||||
|
||||
@@ -304,6 +304,7 @@ struct GPUgstate {
|
||||
bool isTextureSwizzled() const { return texmode & 1; }
|
||||
bool isClutSharedForMipmaps() const { return (texmode & 0x100) == 0; }
|
||||
int getTextureMaxLevel() const { return (texmode >> 16) & 0x7; }
|
||||
float getTextureLodSlope() const { return getFloat24(texlodslope); }
|
||||
|
||||
// Lighting
|
||||
bool isLightingEnabled() const { return lightingEnable & 1; }
|
||||
|
||||
@@ -59,6 +59,7 @@ void DirectXState::Restore() {
|
||||
texMagFilter.restore(); count++;
|
||||
texMipFilter.restore(); count++;
|
||||
texMipLodBias.restore(); count++;
|
||||
texMaxMipLevel.restore(); count++;
|
||||
texAddressU.restore(); count++;
|
||||
texAddressV.restore(); count++;
|
||||
}
|
||||
@@ -76,4 +77,4 @@ void DirectXState::SetVSyncInterval(int interval) {
|
||||
|
||||
} // namespace DX9
|
||||
|
||||
#endif // _MSC_VER
|
||||
#endif // _MSC_VER
|
||||
|
||||
@@ -480,6 +480,7 @@ public:
|
||||
DxSampler0State1<D3DSAMP_MAGFILTER, D3DTEXF_POINT> texMagFilter;
|
||||
DxSampler0State1<D3DSAMP_MIPFILTER, D3DTEXF_NONE> texMipFilter;
|
||||
DxSampler0State1Float<D3DSAMP_MIPMAPLODBIAS, 0> texMipLodBias;
|
||||
DxSampler0State1<D3DSAMP_MAXMIPLEVEL, 0> texMaxMipLevel;
|
||||
DxSampler0State1<D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP> texAddressU;
|
||||
DxSampler0State1<D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP> texAddressV;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user