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

Most important fix of the year #7883

Merged
merged 2 commits into from Mar 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 16 additions & 16 deletions rpcs3/Emu/RSX/Common/ProgramStateCache.cpp
Expand Up @@ -47,20 +47,20 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert

std::function<void(u32, bool)> walk_function = [&](u32 start, bool fast_exit)
{
u32 current_instrution = start;
u32 current_instruction = start;
std::set<u32> conditional_targets;

while (true)
{
verify(HERE), current_instrution < 512;
verify(HERE), current_instruction < 512;

if (result.instruction_mask[current_instrution])
if (result.instruction_mask[current_instruction])
{
if (!fast_exit)
{
// This can be harmless if a dangling RET was encountered before
rsx_log.error("vp_analyser: Possible infinite loop detected");
current_instrution++;
current_instruction++;
continue;
}
else
Expand All @@ -70,14 +70,14 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert
}
}

const qword* instruction = reinterpret_cast<const qword*>(&data[current_instrution * 4]);
const qword* instruction = reinterpret_cast<const qword*>(&data[current_instruction * 4]);
d1.HEX = instruction->word[1];
d3.HEX = instruction->word[3];

// Touch current instruction
result.instruction_mask[current_instrution] = true;
instruction_range.first = std::min(current_instrution, instruction_range.first);
instruction_range.second = std::max(current_instrution, instruction_range.second);
result.instruction_mask[current_instruction] = true;
instruction_range.first = std::min(current_instruction, instruction_range.first);
instruction_range.second = std::max(current_instruction, instruction_range.second);

// Basic vec op analysis, must be done before flow analysis
switch (d1.vec_opcode)
Expand Down Expand Up @@ -111,22 +111,22 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert
case RSX_SCA_OPCODE_CLB:
{
// Need to patch the jump address to be consistent wherever the program is located
instructions_to_patch[current_instrution] = true;
instructions_to_patch[current_instruction] = true;
has_branch_instruction = true;

d2.HEX = instruction->word[2];
const u32 jump_address = ((d2.iaddrh << 3) | d3.iaddrl);

if (function_call)
{
call_stack.push(current_instrution + 1);
current_instrution = jump_address;
call_stack.push(current_instruction + 1);
current_instruction = jump_address;
continue;
}
else if (static_jump)
{
// NOTE: This will skip potential jump target blocks between current->target
current_instrution = jump_address;
current_instruction = jump_address;
continue;
}
else
Expand All @@ -146,7 +146,7 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert
}
else
{
current_instrution = call_stack.top();
current_instruction = call_stack.top();
call_stack.pop();
continue;
}
Expand All @@ -155,13 +155,13 @@ vertex_program_utils::vertex_program_metadata vertex_program_utils::analyse_vert
}
}

if ((d3.end && (fast_exit || current_instrution >= instruction_range.second)) ||
(current_instrution + 1) == 512)
if ((d3.end && (fast_exit || current_instruction >= instruction_range.second)) ||
(current_instruction + 1) == 512)
{
break;
}

current_instrution++;
current_instruction++;
}

for (const u32 target : conditional_targets)
Expand Down