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

Support cross-platform retrace for titles that query uniforms by index #649

Merged
merged 2 commits into from Jan 16, 2020

Conversation

janesma
Copy link

@janesma janesma commented Jan 6, 2020

These patches enable Linux/Windows retrace for GFXBench AztecRuins and Bioshock Infinite.

I'm happy to re-write if there is a better way to do the code generation.

Mark Janes added 2 commits January 6, 2020 14:23
During retrace, the driver may choose a different uniform location
than was recorded at trace time.  If the traced program looks up
uniforms by name with glGetUniformLocation or similar apis, Apitrace
correctly remaps locations at retrace time.

However, GL_ARB_program_interface_query allows programs to iterate
over program resources querying program names.  This reverse-lookup is
not supported by glretrace, and any change to uniform bindings will
result in a crash.

Programs looking up names for each index will:

 - iterate the resources attached to the program, calling
   glGetProgramResourceName to record the name at each index.

 - iterate the resources attached to the program, calling
   glGetProgramResourceiv to get the uniform location for each index.

This patch tracks the name at each program index, and then call into
GL to determined current bindings for the named resource whenever
glGetProgramResourceiv is encountered.

Fixes GFXBench Aztec Ruins traces, which crashed when retraced on
various drivers.  A trace made on Mesa would work on Intel and AMD
Linux platforms, but would crash on Windows
platforms (AMD/Intel/Nvidia).
Apitrace supports titles which query the index for a given uniform
block name.  Alternatively, titles may iterate active uniform block
indices and retrieve the name at each index.

To support this method of identifying uniform block bindings,
glGetActiveUniformBlockName must be checked against the return value
that was traced.

Enables retracing of Bioshock6, which queries names by index.  Without
this patch, a trace made on Linux will not retrace on Windows.
Copy link
Member

@jrfonseca jrfonseca left a comment

Choose a reason for hiding this comment

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

I haven't looked too closely at these extensions, but change looks good AFAICT.

I'll push as is for now. But you should double check that replaying traces on the same machine works well (didn't regress), and I think a follow up change with more error logging when things don't match would be nice.

return;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

It might be useful to log an error here to debug any issues on the future.

@jrfonseca jrfonseca merged commit ffb366c into apitrace:master Jan 16, 2020
@janesma
Copy link
Author

janesma commented Jan 16, 2020

I will add some error handling. I'm only handling uniform locations that are found via GL_ARB_program_interface_query, but there are other properties that may differ between drivers. I didn't have a trace that broke for any reason other than uniform locations.

I'm looking at Shadow of Mordor now, which fails to re-map shader storage block bindings. I'll add fix-up error handling in the pull request for that fix.

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.

None yet

2 participants