Comments (16)
Can you try with the following versions to see if they make any difference?
from d3d8to9.
Thanks for looking into this! Neither DLL acts any differently, unfortunately. In the log for both your DLL and the normal d3d8to9 is Reference count for 'IDirect3DDevice8' object 065BA288 (5) is inconsistent.
, which is written as the game is exited.
from d3d8to9.
I purchased the game on GOG and was able to see that some of the textures are missing, though it did not look exactly like your screenshots so I am not completely sure it is the same issue.
There is an issue with the reference count for 'IDirect3DDevice8', but I have not been able to figure that one out and I don't think it is the core issue (which is why I have not spent much time looking at it). There also appears to be an issue with the reference count of 'IDirect3DSurface8', which does seem to be the core issue. I tried a quick hack to fix the 'IDirect3DSurface8' reference count but that did not seem to help.
I could be wrong here (since I am not the original author), but it seems to be that when the game requests a surface (for example by calling GetSurfaceLevel or GetCubeMapSurface) that d3d8to9 creates a new Direct3DSurface8 surface rather then giving it the existing surface (which is what d3d9 returns). This is certainly leading to the 'IDirect3DSurface8' reference count issue because each time GetSurfaceLevel or GetCubeMapSurface is called d3d9 is increasing the reference count but the internal reference counter _ref
is not increased.
This problem in the code seems to be somewhat prevalent, as I see it in the following functions: GetBackBuffer, GetCubeMapSurface, GetSurfaceLevel, GetTexture, GetIndices, GetStreamSource and GetVolumeLevel.
from d3d8to9.
I purchased the game on GOG and was able to see that some of the textures are missing, though it did not look exactly like your screenshots so I am not completely sure it is the same issue.
The effects seem to be different each time a level is loaded. The image above is one of the more dramatic-looking versions of the bug that I've seen.
I don't know if this is useful information, but running the game through PIX for Windows seemed to correct most of the issue, despite it still using d3d8to9. There were still some graphical errors, such as some of the particle effects that appear when you grab health in the first level not appearing, and random orange flashes appearing when an object moves (both of these issues are strangely gone in PIX's frame capture).
from d3d8to9.
I don't know if this is useful information, but running the game through PIX for Windows seemed to correct most of the issue, despite it still using d3d8to9.
That sounds like an issue with Scarface: The World is Yours - in this case, the game starts showing terrible artifacts if running on more than one core (vertex buffer being populated from another thread without proper synchronization maybe? or issuing d3d calls from multiple threads?) and running the game from pix is said to help with said artifacts. Far fetched, but could be related.
from d3d8to9.
That sounds like an issue with Scarface: The World is Yours - in this case, the game starts showing terrible artifacts if running on more than one core
That sounds amazingly similar to this issue. When I used msconfig to boot the system with one core, the issues went away even when I was using d3d8to9. Running the game with the affinity set to use only one core did not fix the issue however. Strange how the game is only affected by this issue when d3d8to9 is used (at least on my computer, apparently on some Intel cards there are missing textures with just d3d8).
from d3d8to9.
Hi guys,
Can you post a nightly build with the latest commit (0c5e710) here? I do not have visual studio, therefore I am not able to compile it on my own.
Thanks.
from d3d8to9.
There you go, build with logging enabled.
from d3d8to9.
I tried with other D8 to D9 converters, like the one here and it has the same problem. This seems like a larger issue and is beyond my expertise.
from d3d8to9.
Wouldn't be surprised if this was a game issue exposed by d3d9? To me, this really looks like invalid reuse of vertex buffers (had similar stuff happen in production code only because of wrong vb locking flags - and would expose itself only under heavy CPU load).
from d3d8to9.
If I create the IDirect3D9 device where the Direct3D features are implemented in software using the D3DDEVTYPE_REF
device type then the missing textures can be seen. The textures only seem to be missing when using D3DDEVTYPE_HAL
.
from d3d8to9.
The issue with Raymond 3 not showing some textures has to do with where the vertex buffers are stored. Raymond 3 uses D3DUSAGE_DYNAMIC
vertex buffers. It seems that the way Direct3D8 and Direct3D9 handle dynamic buffers have changed. Disabling dynamic buffers solves this issue.
You can disable dynamic buffers by adding this line to the beginning of the Direct3DDevice8::CreateVertexBuffer
function in d3d8to9:
Usage &= (D3DUSAGE_DYNAMIC ^ 0xFFFF);
I have also attached a working version of the d3d8to9 dll you can download here. Let me know if this works for you.
from d3d8to9.
It seems that disabling D3DLOCK_DISCARD
in Direct3DVertexBuffer8::Lock
solved the problem also.
This can be done by adding this line to the beginning of the Direct3DVertexBuffer8::Lock
function:
Flags &= (D3DLOCK_DISCARD ^ 0xFFFF);
I am not really sure which change is better.
from d3d8to9.
I can confirm this is the issue. I've narrowed down the main texture issue to one of the vertex buffers created by the function located at 0x486A30 in Rayman3.exe, and a secondary issue (that caused missing/delayed/miscoloured effects on NVIDIA cards and a crash on WineD3D) to the function located at 0x472430 in Rayman3.exe. Perhaps these could be analysed by someone smarter than me to see exactly what the game is doing that isn't supported by Direct3D9?
from d3d8to9.
I think I figured out the issue here. The way D3DLOCK_DISCARD
works in Direct3D8 is very different from the way it works in Direct3D9.
Here is the D3DLOCK_DISCARD
documentation from Direct3D8:
The application overwrites the entire vertex buffer with a write-only operation. This enables Direct3D to return a pointer to a new memory area so that the dynamic memory access (DMA) and rendering from the old area do not stall.
Here is the D3DLOCK_DISCARD
documentation from Direct3D9:
The application discards all memory within the locked region. For vertex and index buffers, the entire buffer will be discarded. This option is only valid when the resource is created with dynamic usage.
Notice how in Direct3D9 the "entire buffer will be discarded" whereas in Direct3D8 this will "overwrites the entire vertex buffer with a write-only operation" and "return a pointer to a new memory area". The missing textures are happening because Direct3D9 discards the buffer rather than doing a "write-only" operation.
With Direct3D9 you need to use the D3DUSAGE_WRITEONLY
flag if you want the same functionality. And I think (though I cannot prove) that even with Direct3D8 you are suppose to use the D3DUSAGE_WRITEONLY
flag for this. In Raymond 3 a handful of vertex buffers call the Lock
function with D3DLOCK_DISCARD
enabled and D3DUSAGE_WRITEONLY
disabled and it is the exact same buffers that have this issue.
Therefore the right fix is to remove the D3DLOCK_DISCARD
flag from all lock operations if the D3DUSAGE_WRITEONLY
flag is not being used because this operation will certainly not do what the application expects.
This can be done by modifying this line in the Direct3DVertexBuffer8::Lock
function and adding || (desc.Usage & D3DUSAGE_WRITEONLY) == 0
so it looks like this:
if ((Flags & D3DLOCK_DISCARD) != 0)
{
D3DVERTEXBUFFER_DESC desc;
ProxyInterface->GetDesc(&desc);
if ((desc.Usage & D3DUSAGE_DYNAMIC) == 0 || (desc.Usage & D3DUSAGE_WRITEONLY) == 0)
{
Flags ^= D3DLOCK_DISCARD;
}
}
Also I recommend adding this code to the Direct3DIndexBuffer8::Lock
function, since the same problem can happen with index buffers:
if ((Flags & D3DLOCK_DISCARD) != 0)
{
D3DINDEXBUFFER_DESC desc;
ProxyInterface->GetDesc(&desc);
if ((desc.Usage & D3DUSAGE_DYNAMIC) == 0 || (desc.Usage & D3DUSAGE_WRITEONLY) == 0)
{
Flags ^= D3DLOCK_DISCARD;
}
}
from d3d8to9.
Note: there are still issues on NVIDIA cards with the vertex buffer created in function 0x472430 (specifically, the one with size 96000), where effects that use this buffer can be missing, or have artifacts such as lingering orange flashes, incorrect models, and more. (This can be seen with the particles from the health powerups in the very first level, where the 2nd-4th health will not show it's particles). This happens regardless of whether d3d8to9 is used, so I'm not reopening this, but I thought it worth documenting here.
from d3d8to9.
Related Issues (20)
- Mafia The City Lost Heaven HOT 2
- [Crash] Pro Evolution Soccer 3 HOT 2
- Max Payne - WS Fix not working HOT 3
- .
- Consider collaborating with the d8vk project? HOT 1
- Consider recommending D3DX from NuGet instead of an old DirectX SDK HOT 3
- Ballistics (2001) - Junk polygons in menus
- C:\Microsoft\Cpp\Default\props not found HOT 1
- Rome Total War - Campaign Map Texture Issue HOT 6
- D3D8.1 Pixel and Vertex Shader Lifetimes Seem To Be Incorrect HOT 1
- Problems with character models. Pangya
- Latest update crashes Silent Hill 2 in SetVertexShader() HOT 4
- v1.11.1 - Max Payne - Loading Screen Errors / Missing Sounds
- Fellowship of the Ring black screen on startup/uncapped frame rate HOT 1
- uhh
- NVCP multi sampling anti-aliasing doesn't work. I tried everything. Metin2 is the game. HOT 1
- [Suggestion] The Bard's Tale (2005) - Solve the slowness of some parts... HOT 1
- Fixing 3dwinxp screensaver working experience
- Generals Zero Hour - Many Issues and 1 Bug HOT 1
- Failed to Load d3dx9_43.dll HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3d8to9.