Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup Direct3D State #1624

Closed
wants to merge 10 commits into from
Closed

Cleanup Direct3D State #1624

wants to merge 10 commits into from

Conversation

RobertBColton
Copy link
Contributor

@RobertBColton RobertBColton commented Mar 17, 2019

This pull request cleans up so much garbage I hardly know where to begin. The first thing I was looking at was the Direct3D9 and Direct3D11 light handling. For some reason, I copied over the garbage from the OpenGL1 system when adding lights to D3D. Since GM's lighting was originally based on Direct3D's, there was no need for any of this. The GL1 system was concerned with reapplying the lights when the projection matrix is changed due to lighting being computed in eyespace. I believe the origin of the GL1 stuff I copied was polygonz. Regardless, I started by dumping it from D3D9 and D3D11.

We were also missing a cache of the device lighting material that I added in #1530. So the bug was still occurring with the managed device since Project Mario resizing a window provokes a device reset. While I was in here, I decided to clean up a bunch of the cache code too and use simpler repetitions for restoring the cached device state.

@RobertBColton RobertBColton added the Graphics Game visuals including render state, geometry pipeline, rasterization, and related assets. label Mar 17, 2019
map< DWORD, map< D3DSAMPLERSTATETYPE, DWORD > > cacheSamplerStates; /// cached sampler states
map< DWORD, D3DLIGHT9 > cacheLightStates; /// cached light states
map< DWORD, BOOL > cacheLightEnable; /// cached light enable states
D3DMATERIAL9 cacheMaterial; /// cached lighting material
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We forgot to cache the lighting material for the managed D3D9 device before.

// ***** LIGHTS BEGIN *****
#include <map>
#include <list>
#include "Universal_System/fileio.h"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this garbage wasn't even being used!

@codecov
Copy link

codecov bot commented Mar 17, 2019

Codecov Report

Merging #1624 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1624   +/-   ##
=======================================
  Coverage   18.73%   18.73%           
=======================================
  Files         171      171           
  Lines       17018    17018           
=======================================
  Hits         3188     3188           
  Misses      13830    13830

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe02cb2...ed1bd34. Read the comment docs.

@RobertBColton
Copy link
Contributor Author

Closing in favor of #1636 which solves these exact same problems in a better way.

@RobertBColton RobertBColton deleted the cleanup-direct3d-state branch April 23, 2019 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Graphics Game visuals including render state, geometry pipeline, rasterization, and related assets.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant