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

trimming broken for some traces #901

Closed
zmike opened this issue Oct 5, 2023 · 7 comments
Closed

trimming broken for some traces #901

zmike opened this issue Oct 5, 2023 · 7 comments
Assignees

Comments

@zmike
Copy link
Contributor

zmike commented Oct 5, 2023

Looking at the trace from #900, if I try to trim a gameplay trace (e.g., gltrim -k -f3470), the trim operation completes but then replay crashes immediately like

#0  0x0000000000584eed in retrace_memcpy (call=...) at /home/zmike/src/apitrace/retrace/retrace_stdc.cpp:64
#1  0x0000000000558242 in retrace::Retracer::retrace (this=0x83e0a0 <retracer>, call=...) at /home/zmike/src/apitrace/retrace/retrace.cpp:159
#2  0x000000000055be4c in retrace::retraceCall (call=0x13642b0) at /home/zmike/src/apitrace/retrace/retrace_main.cpp:406
#3  0x000000000055c0dd in retrace::RelayRunner::runLeg (this=0x127d7d0, call=0x13642b0) at /home/zmike/src/apitrace/retrace/retrace_main.cpp:562
#4  0x000000000055c047 in retrace::RelayRunner::runRace (this=0x127d7d0) at /home/zmike/src/apitrace/retrace/retrace_main.cpp:540
#5  0x000000000055c2be in retrace::RelayRunner::runnerThread (_this=0x127d7d0) at /home/zmike/src/apitrace/retrace/retrace_main.cpp:621
#6  0x0000000000584be4 in std::__invoke_impl<void, void (*)(retrace::RelayRunner*), retrace::RelayRunner*> (
    __f=@0xc67b00: 0x55c2a6 <retrace::RelayRunner::runnerThread(retrace::RelayRunner*)>) at /usr/include/c++/13/bits/invoke.h:61
#7  0x0000000000584a9a in std::__invoke<void (*)(retrace::RelayRunner*), retrace::RelayRunner*> (
    __fn=@0xc67b00: 0x55c2a6 <retrace::RelayRunner::runnerThread(retrace::RelayRunner*)>) at /usr/include/c++/13/bits/invoke.h:96
#8  0x000000000058496d in std::thread::_Invoker<std::tuple<void (*)(retrace::RelayRunner*), retrace::RelayRunner*> >::_M_invoke<0ul, 1ul> (this=0xc67af8)
    at /usr/include/c++/13/bits/std_thread.h:292
#9  0x00000000005848b6 in std::thread::_Invoker<std::tuple<void (*)(retrace::RelayRunner*), retrace::RelayRunner*> >::operator() (this=0xc67af8)
    at /usr/include/c++/13/bits/std_thread.h:299
#10 0x0000000000584844 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(retrace::RelayRunner*), retrace::RelayRunner*> > >::_M_run (
    this=0xc67af0) at /usr/include/c++/13/bits/std_thread.h:244
#11 0x00007ffff7ae31f3 in execute_native_thread_routine () from /lib64/libstdc++.so.6
#12 0x00007ffff78ae947 in start_thread () from /lib64/libc.so.6
#13 0x00007ffff7934870 in clone3 () from /lib64/libc.so.6

I've noticed this behavior is consistent in traces from a number of AAA titles.

@gerddie
Copy link
Contributor

gerddie commented Oct 6, 2023

Unfortunately the trace is no longer available.

@zmike
Copy link
Contributor Author

zmike commented Oct 6, 2023

Oh whoops, forgot I replaced it with a working trace. Link

@gerddie
Copy link
Contributor

gerddie commented Oct 10, 2023

I've found the root of the problem: gltrim is not yet capable to deal with multi-threaded traces, i.e. in this case a texture is set up in one thread, and other texture bindings happen in another thread, since the code ignores the thread, the texture setup calls are not attributed to the right objects, and we get an illegal call sequence. In this case calls to glCompressedTextureSubImage2DEXT happen on textures that are no longer correctly set up, because the setup calls to glCompressedTexImage2D that are needed for this setup must use the binding points that are clobbered by the trimmer.

@gerddie gerddie self-assigned this Oct 10, 2023
gerddie added a commit to gerddie/apitrace that referenced this issue Oct 16, 2023
This includes
* tracking which context is bound in which thread
* switch context when the thread is changed
* track bindings on a per-context base

Closes: apitrace#901

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
@gerddie
Copy link
Contributor

gerddie commented Oct 16, 2023

With this PR #902 trimming results in a trace that can be replayed.

@zmike
Copy link
Contributor Author

zmike commented Oct 16, 2023

Awesome!

@gerddie
Copy link
Contributor

gerddie commented Oct 16, 2023

Well, the output is broken, I'm not yet sure whether it is the usual "one has to use try-and -error" to get it right, or whether it is a "normal" bug ( at first sight it looks like the latter)

@gerddie
Copy link
Contributor

gerddie commented Oct 16, 2023

After some testing I was able to get correct rendering with

gltrim -k -s 3362-3372 -f 3470-3500 wolf.trace -o wolf-k+s3362-3372+f3470-3500-check.trace

i.e. one has to add some setup frames to get it right, so it is the "try-an-error" problem. (Frames 3362-3372 seem to setup the scene)

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

No branches or pull requests

2 participants