Skip to content

Commit

Permalink
fixes to d3d cache
Browse files Browse the repository at this point in the history
  • Loading branch information
aap committed Oct 27, 2020
1 parent 5e5a624 commit 4e8396a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/d3d/d3ddevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,16 @@ restoreD3d9Device(void)
d3ddevice->SetIndices(deviceCache.indices);
for(i = 0; i < MAXNUMSTREAMS; i++)
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
Expand Down Expand Up @@ -517,7 +527,7 @@ setMaterial_fix(const RGBA &color, const SurfaceProperties &surfProps)


void
setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops)
setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops, float extraSurfProp)
{
if(!equal(d3dShaderState.matColor, color)){
rw::RGBAf col;
Expand All @@ -528,14 +538,16 @@ setMaterial(const RGBA &color, const SurfaceProperties &surfaceprops)

if(d3dShaderState.surfProps.ambient != surfaceprops.ambient ||
d3dShaderState.surfProps.specular != surfaceprops.specular ||
d3dShaderState.surfProps.diffuse != surfaceprops.diffuse){
d3dShaderState.surfProps.diffuse != surfaceprops.diffuse ||
d3dShaderState.extraSurfProp != extraSurfProp){
float surfProps[4];
surfProps[0] = surfaceprops.ambient;
surfProps[1] = surfaceprops.specular;
surfProps[2] = surfaceprops.diffuse;
surfProps[3] = 0.0f;
surfProps[3] = extraSurfProp;
d3ddevice->SetVertexShaderConstantF(VSLOC_surfProps, surfProps, 1);
d3dShaderState.surfProps = surfaceprops;
d3dShaderState.extraSurfProp = extraSurfProp;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/d3d/rwd3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void getSamplerState(uint32 stage, uint32 type, uint32 *value);
void flushCache(void);

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 setPixelShader(void *ps);
Expand Down Expand Up @@ -226,6 +226,7 @@ struct D3dShaderState
} fogData, fogDisable;
RGBA matColor;
SurfaceProperties surfProps;
float extraSurfProp;
float lightOffset[3];
int32 numDir, numPoint, numSpot;
RGBAf ambient;
Expand Down

0 comments on commit 4e8396a

Please sign in to comment.