fixes to d3d cache

This commit is contained in:
aap 2020-10-27 12:41:10 +01:00
parent 5e5a624681
commit 4e8396af26
2 changed files with 17 additions and 4 deletions

View File

@ -325,6 +325,16 @@ restoreD3d9Device(void)
d3ddevice->SetIndices(deviceCache.indices); d3ddevice->SetIndices(deviceCache.indices);
for(i = 0; i < MAXNUMSTREAMS; i++) for(i = 0; i < MAXNUMSTREAMS; i++)
d3ddevice->SetStreamSource(i, deviceCache.vertexStreams[i].buffer, deviceCache.vertexStreams[i].offset, deviceCache.vertexStreams[i].stride); d3ddevice->SetStreamSource(i, deviceCache.vertexStreams[i].buffer, deviceCache.vertexStreams[i].offset, deviceCache.vertexStreams[i].stride);
// shader constants are zero now
d3dShaderState.fogDirty = true;
d3dShaderState.matColor.red = 0;
d3dShaderState.matColor.green = 0;
d3dShaderState.matColor.blue = 0;
d3dShaderState.matColor.alpha = 0;
d3dShaderState.surfProps.ambient = 0.0f;
d3dShaderState.surfProps.specular = 0.0f;
d3dShaderState.surfProps.diffuse = 0.0f;
} }
void void
@ -517,7 +527,7 @@ setMaterial_fix(const RGBA &color, const SurfaceProperties &surfProps)
void void
setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops) setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp)
{ {
if(!equal(d3dShaderState.matColor, color)){ if(!equal(d3dShaderState.matColor, color)){
rw::RGBAf col; rw::RGBAf col;
@ -528,14 +538,16 @@ setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops)
if(d3dShaderState.surfProps.ambient != surfaceprops.ambient || if(d3dShaderState.surfProps.ambient != surfaceprops.ambient ||
d3dShaderState.surfProps.specular != surfaceprops.specular || d3dShaderState.surfProps.specular != surfaceprops.specular ||
d3dShaderState.surfProps.diffuse != surfaceprops.diffuse){ d3dShaderState.surfProps.diffuse != surfaceprops.diffuse ||
d3dShaderState.extraSurfProp != extraSurfProp){
float surfProps[4]; float surfProps[4];
surfProps[0] = surfaceprops.ambient; surfProps[0] = surfaceprops.ambient;
surfProps[1] = surfaceprops.specular; surfProps[1] = surfaceprops.specular;
surfProps[2] = surfaceprops.diffuse; surfProps[2] = surfaceprops.diffuse;
surfProps[3] = 0.0f; surfProps[3] = extraSurfProp;
d3ddevice->SetVertexShaderConstantF(VSLOC_surfProps, surfProps, 1); d3ddevice->SetVertexShaderConstantF(VSLOC_surfProps, surfProps, 1);
d3dShaderState.surfProps = surfaceprops; d3dShaderState.surfProps = surfaceprops;
d3dShaderState.extraSurfProp = extraSurfProp;
} }
} }

View File

@ -187,7 +187,7 @@ void getSamplerState(uint32 stage, uint32 type, uint32 *value);
void flushCache(void); void flushCache(void);
void setTexture(uint32 stage, Texture *tex); void setTexture(uint32 stage, Texture *tex);
void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops); void setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp = 0.0f);
void setVertexShader(void *vs); void setVertexShader(void *vs);
void setPixelShader(void *ps); void setPixelShader(void *ps);
@ -226,6 +226,7 @@ struct D3dShaderState
} fogData, fogDisable; } fogData, fogDisable;
RGBA matColor; RGBA matColor;
SurfaceProperties surfProps; SurfaceProperties surfProps;
float extraSurfProp;
float lightOffset[3]; float lightOffset[3];
int32 numDir, numPoint, numSpot; int32 numDir, numPoint, numSpot;
RGBAf ambient; RGBAf ambient;