added GS alpha test emulation
This commit is contained in:
parent
5ffbde3890
commit
d8d13d4429
@ -23,7 +23,7 @@ void defaultRenderCB_Shader(Atomic *atomic, InstanceDataHeader *header) {}
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
void
|
void
|
||||||
drawInst(d3d9::InstanceDataHeader *header, d3d9::InstanceData *inst)
|
drawInst_simple(d3d9::InstanceDataHeader *header, d3d9::InstanceData *inst)
|
||||||
{
|
{
|
||||||
d3d::flushCache();
|
d3d::flushCache();
|
||||||
d3ddevice->DrawIndexedPrimitive((D3DPRIMITIVETYPE)header->primType, inst->baseIndex,
|
d3ddevice->DrawIndexedPrimitive((D3DPRIMITIVETYPE)header->primType, inst->baseIndex,
|
||||||
@ -36,27 +36,41 @@ void
|
|||||||
drawInst_GSemu(d3d9::InstanceDataHeader *header, InstanceData *inst)
|
drawInst_GSemu(d3d9::InstanceDataHeader *header, InstanceData *inst)
|
||||||
{
|
{
|
||||||
uint32 hasAlpha;
|
uint32 hasAlpha;
|
||||||
int alphafunc;
|
int alphafunc, alpharef, gsalpharef;
|
||||||
int zwrite;
|
int zwrite;
|
||||||
d3d::getRenderState(D3DRS_ALPHABLENDENABLE, &hasAlpha);
|
d3d::getRenderState(D3DRS_ALPHABLENDENABLE, &hasAlpha);
|
||||||
if(hasAlpha){
|
if(hasAlpha){
|
||||||
zwrite = rw::GetRenderState(rw::ZWRITEENABLE);
|
zwrite = rw::GetRenderState(rw::ZWRITEENABLE);
|
||||||
alphafunc = rw::GetRenderState(rw::ALPHATESTFUNC);
|
alphafunc = rw::GetRenderState(rw::ALPHATESTFUNC);
|
||||||
if(zwrite){
|
if(zwrite){
|
||||||
|
alpharef = rw::GetRenderState(rw::ALPHATESTREF);
|
||||||
|
gsalpharef = rw::GetRenderState(rw::GSALPHATESTREF);
|
||||||
|
|
||||||
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL);
|
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAGREATEREQUAL);
|
||||||
drawInst(header, inst);
|
SetRenderState(rw::ALPHATESTREF, gsalpharef);
|
||||||
|
drawInst_simple(header, inst);
|
||||||
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHALESS);
|
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHALESS);
|
||||||
SetRenderState(rw::ZWRITEENABLE, 0);
|
SetRenderState(rw::ZWRITEENABLE, 0);
|
||||||
drawInst(header, inst);
|
drawInst_simple(header, inst);
|
||||||
SetRenderState(rw::ZWRITEENABLE, 1);
|
SetRenderState(rw::ZWRITEENABLE, 1);
|
||||||
SetRenderState(rw::ALPHATESTFUNC, alphafunc);
|
SetRenderState(rw::ALPHATESTFUNC, alphafunc);
|
||||||
|
SetRenderState(rw::ALPHATESTREF, alpharef);
|
||||||
}else{
|
}else{
|
||||||
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAALWAYS);
|
SetRenderState(rw::ALPHATESTFUNC, rw::ALPHAALWAYS);
|
||||||
drawInst(header, inst);
|
drawInst_simple(header, inst);
|
||||||
SetRenderState(rw::ALPHATESTFUNC, alphafunc);
|
SetRenderState(rw::ALPHATESTFUNC, alphafunc);
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
drawInst(header, inst);
|
drawInst_simple(header, inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
drawInst(d3d9::InstanceDataHeader *header, d3d9::InstanceData *inst)
|
||||||
|
{
|
||||||
|
if(rw::GetRenderState(rw::GSALPHATEST))
|
||||||
|
drawInst_GSemu(header, inst);
|
||||||
|
else
|
||||||
|
drawInst_simple(header, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -79,6 +79,11 @@ struct RwStateCache {
|
|||||||
uint32 cullmode;
|
uint32 cullmode;
|
||||||
uint32 alphafunc;
|
uint32 alphafunc;
|
||||||
uint32 alpharef;
|
uint32 alpharef;
|
||||||
|
|
||||||
|
// emulation of PS2 GS
|
||||||
|
bool32 gsalpha;
|
||||||
|
uint32 gsalpharef;
|
||||||
|
|
||||||
RwRasterStateCache texstage[MAXNUMSTAGES];
|
RwRasterStateCache texstage[MAXNUMSTAGES];
|
||||||
};
|
};
|
||||||
static RwStateCache rwStateCache;
|
static RwStateCache rwStateCache;
|
||||||
@ -548,6 +553,12 @@ setRwRenderState(int32 state, void *pvalue)
|
|||||||
setRenderState(D3DRS_ALPHAREF, rwStateCache.alpharef);
|
setRenderState(D3DRS_ALPHAREF, rwStateCache.alpharef);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case GSALPHATEST:
|
||||||
|
rwStateCache.gsalpha = value;
|
||||||
|
break;
|
||||||
|
case GSALPHATESTREF:
|
||||||
|
rwStateCache.gsalpharef = value;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -605,6 +616,12 @@ getRwRenderState(int32 state)
|
|||||||
case ALPHATESTREF:
|
case ALPHATESTREF:
|
||||||
val = rwStateCache.alpharef;
|
val = rwStateCache.alpharef;
|
||||||
break;
|
break;
|
||||||
|
case GSALPHATEST:
|
||||||
|
val = rwStateCache.gsalpha;
|
||||||
|
break;
|
||||||
|
case GSALPHATESTREF:
|
||||||
|
val = rwStateCache.gsalpharef;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
val = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
@ -1326,6 +1343,9 @@ initD3D(void)
|
|||||||
d3ddevice->SetRenderState(D3DRS_ALPHAREF, 10);
|
d3ddevice->SetRenderState(D3DRS_ALPHAREF, 10);
|
||||||
rwStateCache.alpharef = 10;
|
rwStateCache.alpharef = 10;
|
||||||
|
|
||||||
|
rwStateCache.gsalpha = 0;
|
||||||
|
rwStateCache.gsalpharef = 128;
|
||||||
|
|
||||||
d3ddevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
|
d3ddevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
|
||||||
rwStateCache.fogenable = 0;
|
rwStateCache.fogenable = 0;
|
||||||
d3ddevice->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
|
d3ddevice->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);
|
||||||
|
@ -24,7 +24,12 @@ enum RenderState
|
|||||||
|
|
||||||
// platform specific or opaque?
|
// platform specific or opaque?
|
||||||
ALPHATESTFUNC,
|
ALPHATESTFUNC,
|
||||||
ALPHATESTREF
|
ALPHATESTREF,
|
||||||
|
|
||||||
|
// emulation of PS2 GS alpha test
|
||||||
|
// in the mode where it still writes color but nor depth
|
||||||
|
GSALPHATEST,
|
||||||
|
GSALPHATESTREF
|
||||||
};
|
};
|
||||||
|
|
||||||
enum AlphaTestFunc
|
enum AlphaTestFunc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user