Closed CookiePLMonster closed 7 years ago
Looks good. But could you please remove the spaces between braces and arguments in the function calls to stay true to the rest of the code? =)
Sure, will do. I noticed the initial issue I was trying to fix by this is still happening at times though :(
"Reference count for 'IDirect3DDevice8' object 1AAFEA88 (2) is inconsistent."
That's not necessarily an issue. It can happen if the game does not release its objects in the reverse order it created them, which is quite common. I don't think a lot of D3D8 games do multi-threading actually (though the API seems to support it partially). Still these changes can't hurt.
These interlocked ops are literally compiled to a single locked assembly instruction so they are not any slower than regular operations (the perf difference doesn't really make a difference in the context of d3d rendering) so it's a win-win.
I have updated the PR with a fix for device refcounts. See the comments in the code for an explaination on what happened.
Ah. Nice catch.
It could solve issues with inconsistent device refcounters in games which expect d3d8 to be thread safe.