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

Experimental support for injection #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Experimental support for injection #1

wants to merge 4 commits into from

Conversation

JayFoxRox
Copy link
Owner

@JayFoxRox JayFoxRox commented Aug 1, 2018

Can be ran using reset && clear && XBOX=192.168.177.3 ./nv2a-trace.py clear.json and should give something like:

Example of clear.json injection

TODO:

  • Recover pgraph state
  • Cleanup
  • Wait for trace enhancements so this is useful
  • Add support for injecting RAM data (such as vertice or texture pixels)

abortNow = True

# Quit asap
#abortNow = True
Copy link
Owner Author

Choose a reason for hiding this comment

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

Doesn't work right now, because code won't run until we step through (so debug.html would not contain any results). We could set dma_put_addr to the original v_dma_get_addr to run this quickly and address this.

@@ -91,10 +94,11 @@ def recordPGRAPHMethod(xbox, method, data):
#FIXME: Mabye in PGRAPH: 0x00400828 ? [modified by command]
color_offset = data

if method == 0x17fc:
if method == 0x17fc or method == 0x1D94:
Copy link
Owner Author

@JayFoxRox JayFoxRox Aug 2, 2018

Choose a reason for hiding this comment

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

Separate change (more code follows)

@@ -1,4 +1,4 @@
#!/usr/bin/env python3 -u
#!/usr/bin/python3 -u
Copy link
Owner Author

Choose a reason for hiding this comment

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

Separate change. Not too happy about this tbh.


# Reconstruct the command word
word = int(command_log_entry['method'],16)
word |= int(command_log_entry['subchannel'],16) << 13
Copy link
Owner Author

@JayFoxRox JayFoxRox Aug 2, 2018

Choose a reason for hiding this comment

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

Should be able to use int(..., base=0) (or provide it implicitly)

"data": [
"0x000000F0"
]
},
Copy link
Owner Author

@JayFoxRox JayFoxRox Aug 2, 2018

Choose a reason for hiding this comment

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

  {
    "method": "CLEAR_BUFFERS", 
    "data": [{
      "COLOR_A": true,
      "COLOR_R": true,
      "COLOR_G": true,
      "COLOR_B": true
    }]
  }

"non_increasing": false,
"data": [
"0x00000000"
]
Copy link
Owner Author

@JayFoxRox JayFoxRox Aug 2, 2018

Choose a reason for hiding this comment

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

  {
    "method": "CLEAR_BUFFERS", 
    "data": [0]
  }

"data": [
"0x00FF00FF"
]
},
Copy link
Owner Author

@JayFoxRox JayFoxRox Aug 2, 2018

Choose a reason for hiding this comment

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

  {
    "method": "CLEAR_VALUE",
    "data": ["0x00FF00FF"]
  }

@JayFoxRox
Copy link
Owner Author

JayFoxRox commented Aug 2, 2018

For the record:

[fox@x230 rnn]$ RNN_PATH=`pwd`/../rnndb:`pwd`/../rnndb-generated/ ./lookup.py -d SUBCHAN -v obj-class NV20_3D 0x1d94 0xF0 2>/dev/null
CLEAR_BUFFERS => { COLOR_A | COLOR_B | COLOR_G | COLOR_R }

In https://github.com/envytools/envytools/tree/master/rnn


Integrating rnn looks kind of painful.

  • Distribution is not solved and I had trouble getting it to work properly as there's also a lack of documentation
  • For tracing it apppears mostly fine but it doesn't handle arrays well (which is odd).
  • For injecting I'd probably need to put in a lot of work. It doesn't seem to handle value parsing on its own.

I'll probably reach out to the envytools folks to improve distribution of rnn / rnndb (why no setuptools?); also the quality of rnndb for NV2A (and NV20_3D - NV25_3D) is not where it should be. Something I'd also attempt to address in hopes we adopt envytool names for all Xbox tools later.

@JayFoxRox
Copy link
Owner Author

JayFoxRox commented Aug 2, 2018

@file
@file+offset
@file+offset(count*size:stride)

Could be a useful format for binary data?

However, with interleaved vertex attributes, this would cause like 16x memory usage which will be a problem.
We"d need a clever mechanism to find all "good" overlap then.

For testing it might be safer to assume that all data is rather tightly packed (meaning we don"t need a full 64MB RAM dump).

We could also go more invasive and re-structure resources on a draw call. However, I"d like to avoid that if possible.


This must be handled kind of special:

{
  "load": {

    "file data": {
      "size": 16, # Implicit len(data); only really matters when stride isn't 0?
      "stride": 100, # Implicit 0

      # Load from file
      "data": "vertex_attrib_0.bin"
    },

    "direct data": {
      # Direct data
      "data": [
        ["0x00000000", 1.0, 2.0, 3.0],
        ["0x00000000", 4.0, 5.0, 6.0],
      ]
    }

  }
},
{
  "unload": [ "unique identifier" ]
}

@JayFoxRox
Copy link
Owner Author

We also have to solve the problem where the injection might start or stop in a bad state which might affect much more than pgraph.

Say stopping between BEGIN and END: we can detect this probably, but we probably can't change the state without injecting additional comments because the GPU probably has a lot of internal state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant