-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
rsx: Fix index vertex array range with modulo calculation #14505
Conversation
rpcs3/Emu/RSX/RSXThread.cpp
Outdated
{ | ||
if (std::find(std::begin(frequencies), std::begin(frequencies) + freq_count, attrib.frequency) == std::begin(frequencies) + freq_count) | ||
{ | ||
frequencies[freq_count++] = attrib.frequency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how is ensured that freq_count is not >= 16 ?
027f866
to
d2cb038
Compare
rpcs3/Emu/RSX/RSXThread.cpp
Outdated
|
||
if (index_size == 4) | ||
{ | ||
re_evaluate(u32{}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weird right?
I stumbled upon the same issue lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just pass vm::get_super_ptr<u32>(address)
here and use auto in the lambda.
Then there would be no such useless param.
8ce204d
to
35e10d1
Compare
// Force aligned indices as realhw | ||
const u32 address = (0 - index_size) & get_address(rsx::method_registers.index_array_address(), rsx::method_registers.index_array_location()); | ||
|
||
auto re_evaluate = [&](auto ptr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surpised that this works without the template.
Are you sure it's not implicitly casting to another type for one of the calls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Recursively iterating over the IB is way too slow for this to be a real fix.
A better solution is to simply handle this whole function as a line intersection problem. Every attribute is simply a 1D vector and usually only a handful will be in use anyway. I may have to think about it a bit more, it may require some more work elsewhere.
This function exists solely to accelerate vertex uploads over going one attr at a time, which this solution is actually slower than.
I added a debug message for when this fallback is hit named "This sucks" in red error message, please test many games and upload logs if you see it spammed frequently or even logged at all. |
588b225
to
7dd90e9
Compare
I've tested most of the games and haven't noticed a single error named "This sucks". |
No other game except specifically the DW series spits out "This Sucks" |
GT6 have broken graphic in this PR |
In #9055, modulo op with frequency was used on vertex indices wiuth some values already surpoassing frequency divider value. We incorrectly assumed that this means that the upper bound of vertex data memory data is the frequency divider in this case, but actually we still need to check for each element max_index = max(index % frequency, max_index). This is also true for min_index.
This re-iteration over all indices can be quite expensive for this exceptionally rare case, so do it if an access violation is guarenteed due to unallocated memory access. I think this can be optimized in the future for single frequency across the entire vertex arrays but I won't do it in this pr.
Fixes #9055