Coder Social home page Coder Social logo

Comments (7)

crosire avatar crosire commented on May 29, 2024

According to both the D3D8 and D3D9 documentation, D3DLOCK_DISCARD may only be used on vertex buffers created with the D3DUSAGE_DYNAMIC flag. However it is too invalid to create a D3DPOOL_MANAGED buffer with that flag. It is valid only with D3DPOOL_DEFAULT (this too is true for both D3D8 and D3D9). I cannot remember which game it was that attempted to use the discard flag on a managed buffer, but it refused to launch unless the workaround was applied, which is why it was added. Probably because the call returned an error (which should be the case in native D3D8 as well, so I have no idea why it works there). The game did not pass D3DUSAGE_DYNAMIC either.

A better idea might be to remove the D3DLOCK_DISCARD flag from the lock call if the buffer usage does not match D3DPOOL_DEFAULT. That would invoke different behaviour, but at least should allow the call to succeed. And since it is the application's fault for using invalid flags, I'd expect undefined behaviour in native D3D8 here as well.

from d3d8to9.

crosire avatar crosire commented on May 29, 2024

I pushed a proposition to the fix_issue_1 branch. Please check if that works for you.

from d3d8to9.

michael-fadely avatar michael-fadely commented on May 29, 2024

6d95711 is causing the game in question (original 2004 Sonic Adventure DX PC) to crash sometime after creating IDirect3DDevice8, so I can't say. Somehow it's returning from a function call to some non-executable memory. It's calling IDirect3D8::GetDeviceCaps followed by IDirect3D8::CreateDevice. If the device is still null by this point, it tries again with different parameters.

from d3d8to9.

crosire avatar crosire commented on May 29, 2024

That commit changed exactly nothing, I only moved some code around ...

from d3d8to9.

michael-fadely avatar michael-fadely commented on May 29, 2024

That's what I figured, which made things all the more confusing. But alas, reverting to the revision right before that fixes it. I have no idea what's going on there...

from d3d8to9.

michael-fadely avatar michael-fadely commented on May 29, 2024

Found the problem here. This should be sizeof(output) not sizeof(input). The pointer the game passes in is to a structure on the stack, and this stomps all over it and messes up the return address.

(Edit: and yeah, the intended change did fix the vertex buffer issue)

from d3d8to9.

crosire avatar crosire commented on May 29, 2024

Ohhhhh .... So I did change one thing and of course had to mistake that one thing. Great. Anyway. Will fix that and merge it back into master then.

from d3d8to9.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.