Giter VIP home page Giter VIP logo

Comments (28)

pchome avatar pchome commented on August 21, 2024 1

Ok, I'll try to do my best.

from d9vk.

pchome avatar pchome commented on August 21, 2024 1

key.MipmapLodBias = bit::cast<float>(state[D3DSAMP_MIPMAPLODBIAS]);

Looks like this produces different values every time.
Changing value to key.MipmapLodBias = 0; "fixes" problem.

P.S. I was able to create apitrace, but it's too huge (I was very accurate in data collecting :) ).
I should learn how to crop it, to preserve only valuable data. Maybe separate frame states, or so.

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

It is truly incredible that the game requires this many samplers.

The way I am doing lookups now is not the best.

May be worth offloading that sampler lookup into CS somehow, would need a d3d9-only backend change. I might have a go at implementing some dynamic sampler system and seeing if that makes a difference.

I could perhaps compress the sampler data with the bitfield struct thing (:) and probably get it down to 128 bits maybe? Wouldn't affect hashing it now due to how its being done though.

from d9vk.

doitsujin avatar doitsujin commented on August 21, 2024

would need a d3d9-only backend change

You can run your own code on the CS too, this doesn't (and shouldn't) be part of the backend.

Might also be worth checking if the game passes random/undefined data as sampler states, and normalize the key (e.g. set border colors to 0 if the sampler doesn't use border address mode). Usually there's no reason to have more than a few dozen samplers in total.

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

would need a d3d9-only backend change

You can run your own code on the CS too, this doesn't (and shouldn't) be part of the backend.

Might also be worth checking if the game passes random/undefined data as sampler states, and normalize the key (e.g. set border colors to 0 if the sampler doesn't use border address mode). Usually there's no reason to have more than a few dozen samplers in total.

Good idea. Will start with normalizing first, and then see if offloading helps

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

@pchome

I've pushed a couple of commits to help rectify this issue:
d9df0f9
and
b5f6e4d

Can you try at each of them and tell me at which commit you get better performance with BL2?

Cheers :)

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

To clarify for testing:

  1. Just using d9df0f9
  2. Using d9df0f9 and b5f6e4d (at head of sampler-offloading branch)

from d9vk.

pchome avatar pchome commented on August 21, 2024

To clarify for testing:

  1. Just using d9df0f9
  2. Using d9df0f9 and b5f6e4d (at head of sampler-offloading branch)

No noticeable difference between 0, 1 and 2.

Performance still degrading, but faster (degrading) with 2 (probably ... :) ).

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

Can you produce an apitrace so I can attempt another fix locally?

from d9vk.

pchome avatar pchome commented on August 21, 2024

Can you produce an apitrace so I can attempt another fix locally?

I have no luck to do this on linux/steam/proton yet, maybe someone can help and do this on windows ?

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

A guide is located here:

https://tracehub.froggi.es/

from d9vk.

mrdeathjr28 avatar mrdeathjr28 commented on August 21, 2024

d9vk/src/d3d9/d3d9_device.cpp

Line 3837 in 0595a6a

key.MipmapLodBias = bit::cast(state[D3DSAMP_MIPMAPLODBIAS]);
Looks like this produces different values every time.
Changing value to key.MipmapLodBias = 0; "fixes" problem.

P.S. I was able to create apitrace, but it's too huge (I was very accurate in data collecting :) ). I should learn how to crop it, to preserve only valuable data. Maybe separate frame states, or so.

Hi
If you have precompiled binary can test

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

d9vk/src/d3d9/d3d9_device.cpp

Line 3837 in 0595a6a
key.MipmapLodBias = bit::cast(state[D3DSAMP_MIPMAPLODBIAS]);

Looks like this produces different values every time.
Changing value to key.MipmapLodBias = 0; "fixes" problem.

P.S. I was able to create apitrace, but it's too huge (I was very accurate in data collecting :) ). I should learn how to crop it, to preserve only valuable data. Maybe separate frame states, or so.

Can you see if 55c86fa corrects your issue?

from d9vk.

pchome avatar pchome commented on August 21, 2024

Can you see if 55c86fa corrects your issue?

Still there.

Here is the alert("") debugger output:

$ cat Borderlands2_d3d9.log | sort | uniq -c | grep new

      9 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : 1
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : 3.08894e-09
  14484 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : -nan
      2 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 1 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 1 : 1.97692e-07
      2 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 1
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 2
      2 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 3.08894e-09
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 4 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 4 : 1
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 5 : 3.08894e-09
      2 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 6 : 3.08894e-09

Logger::warn(str::format("Direct3DDevice9Ex::CreateSampler: new sampler: ", Sampler, " : ", key.MipmapLodBias));

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

I imagine its failing to make with a -NAN MipmapLodBias perhaps?

from d9vk.

pchome avatar pchome commented on August 21, 2024

yep

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

Cool, I'll work on a fix for that

from d9vk.

pchome avatar pchome commented on August 21, 2024

Just for the record:

`$ cat Borderlands2_d3d9.log | sort | uniq -c | grep reused`
 163457 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 0
     16 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 1
   7213 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 3.08894e-09
  41351 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 0
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 10 : 0
     16 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 1
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 11 : 0
  10820 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 1.97692e-07
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 12 : 0
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 13 : 0
   7214 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 3.08894e-09
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 14 : 0
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 15 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 16 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 17 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 18 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 19 : 0
  59913 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 20 : 0
     82 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 1
     19 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 2
   3605 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 3.08894e-09
  28491 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 3 : 0
     31 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 3 : 1
   3607 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 3 : 3.08894e-09
  39281 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 4 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 4 : 1
   3607 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 4 : 3.08894e-09
  17026 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 5 : 0
   3606 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 5 : 3.08894e-09
  10798 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 6 : 0
   3605 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 6 : 3.08894e-09
   7796 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 7 : 0
   3607 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 7 : 3.08894e-09
   3509 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 8 : 0
   3507 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 8 : 3.08894e-09
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 9 : 0

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

Does bd8264e rectify the issue?

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

(I added a another commit to ensure the MipmapLodBias is 0 with NANs)

from d9vk.

pchome avatar pchome commented on August 21, 2024

Current master looks ok.

`$ cat Borderlands2_d3d9.log | sort | uniq -c | grep new`
     10 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : 1
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : 3
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 0 : 3.08894e-09
      3 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 1 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 1 : 1.97692e-07
      3 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 1
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 2
      2 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 2 : 3.08894e-09
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 3 : 0
      3 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 4 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 4 : 1
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 5 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 5 : 3.08894e-09
      2 warn:  Direct3DDevice9Ex::CreateSampler: new sampler: 6 : 3.08894e-09
`$ cat Borderlands2_d3d9.log | sort | uniq -c | grep reused`
 913276 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 0
     49 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 1
      8 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 2
      7 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 3
  25715 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 0 : 3.08894e-09
 210570 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 0
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 10 : 0
     34 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 1
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 11 : 0
  38573 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 1.97692e-07
      8 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 2
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 12 : 0
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 13 : 0
  25716 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 1 : 3.08894e-09
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 14 : 0
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 15 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 16 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 17 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 18 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 19 : 0
 223036 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 20 : 0
    183 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 1
     19 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 2
  12856 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 2 : 3.08894e-09
 130386 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 3 : 0
     63 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 3 : 1
  12858 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 3 : 3.08894e-09
 125760 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 4 : 0
      1 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 4 : 1
  12858 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 4 : 3.08894e-09
  92525 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 5 : 0
  12680 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 5 : 3.08894e-09
  59734 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 6 : 0
  12679 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 6 : 3.08894e-09
  32812 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 7 : 0
  12626 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 7 : 3.08894e-09
   7914 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 8 : 0
   7912 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 8 : 3.08894e-09
      3 warn:  Direct3DDevice9Ex::CreateSampler: reused sampler: 9 : 0

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

@pchome Issue can be closed? :)

from d9vk.

pchome avatar pchome commented on August 21, 2024

Issue can be closed? :)

Sure.
You could keep it opened, to track remaining problems in Borderlands 2.

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

Issue can be closed? :)

Sure.
You could keep it opened, to track remaining problems in Borderlands 2.

A separate issue with more detailed information on each issue would be better.

from d9vk.

pchome avatar pchome commented on August 21, 2024

upd:
Other problems (FYI):

  • high and constantly growing VRAM usage
    Can't reproduce with recent build (~ e9af5d8), VRAM usage near 1000 (~200-300 usually used by system itself).
  • rotated Ammo/Weapon/Damage hints
    See attached image.
  • red texture borders (black is red)
    While bug still there, can be overridden in WillowEngine.ini:
    • partially: DefaultPostProcessName=WillowEngineMaterials.RyanScenePostProcess
    • completely: DefaultPostProcessName=WillowEngineMaterials.CinematicScenePostProcess
    • default: DefaultPostProcessName=WillowEngineMaterials.WillowScenePostProcess

d9vk-borderlands-2-bug-21ab453

from d9vk.

Joshua-Ashton avatar Joshua-Ashton commented on August 21, 2024

Issue is probably my shader io mapping (masks and multiple semantics to one register)

I will try and fix this over the next couple of days

from d9vk.

mrdeathjr28 avatar mrdeathjr28 commented on August 21, 2024

upd:
Other problems (FYI):

  • high and constantly growing VRAM usage
    Can't reproduce with recent build (~ e9af5d8), VRAM usage near 1000 (~200-300 usually used by system itself).

  • rotated Ammo/Weapon/Damage hints
    See attached image.

  • red texture borders (black is red)
    While bug still there, can be overridden in WillowEngine.ini:

    • partially: DefaultPostProcessName=WillowEngineMaterials.RyanScenePostProcess
    • completely: DefaultPostProcessName=WillowEngineMaterials.CinematicScenePostProcess
    • default: DefaultPostProcessName=WillowEngineMaterials.WillowScenePostProcess

d9vk-borderlands-2-bug-21ab453

Confimed in my case for now in x-men wolverine vram dont pass 500mb

from d9vk.

K0bin avatar K0bin commented on August 21, 2024

FYI the red lighting issue is fixed with 54a50c3

from d9vk.

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.