mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-12-06 07:12:28 +01:00
rsx: Fix bugs in fragment program constants stream maagement
- Fix misplaced semicolon in GL fragment program compiler - Add a simple lookup to avoid silly reverse-indexing issues in FP::AddConst
This commit is contained in:
parent
e860cc9fad
commit
cd3e4fc8f1
|
|
@ -186,9 +186,9 @@ void GLFragmentDecompilerThread::insertConstants(std::stringstream & OS)
|
||||||
" sampler_info texture_parameters[16];\n"
|
" sampler_info texture_parameters[16];\n"
|
||||||
"};\n\n"
|
"};\n\n"
|
||||||
|
|
||||||
"layout(std140, binding = " << GL_RASTERIZER_STATE_BIND_SLOT << ") uniform RasterizerHeap\n";
|
"layout(std140, binding = " << GL_RASTERIZER_STATE_BIND_SLOT << ") uniform RasterizerHeap\n"
|
||||||
"{\n";
|
"{\n"
|
||||||
" uvec4 stipple_pattern[8];\n";
|
" uvec4 stipple_pattern[8];\n"
|
||||||
"};\n\n";
|
"};\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#pragma optimize("", off)
|
||||||
#include "FragmentProgramDecompiler.h"
|
#include "FragmentProgramDecompiler.h"
|
||||||
|
#include "ProgramStateCache.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
@ -233,22 +236,18 @@ std::string FragmentProgramDecompiler::AddCond()
|
||||||
std::string FragmentProgramDecompiler::AddConst()
|
std::string FragmentProgramDecompiler::AddConst()
|
||||||
{
|
{
|
||||||
const u32 constant_id = m_size + (4 * sizeof(u32));
|
const u32 constant_id = m_size + (4 * sizeof(u32));
|
||||||
int index = -1, ctr = 0;
|
u32 index = umax;
|
||||||
|
|
||||||
// Have we seen this constant before?
|
if (auto found = m_constant_offsets.find(constant_id);
|
||||||
for (auto it = properties.constant_offsets.rbegin(); it != properties.constant_offsets.rend(); ++it, ++ctr)
|
found != m_constant_offsets.end())
|
||||||
{
|
{
|
||||||
if (*it == constant_id)
|
index = found->second;
|
||||||
{
|
|
||||||
index = ctr;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
if (index == -1)
|
|
||||||
{
|
{
|
||||||
index = static_cast<int>(properties.constant_offsets.size());
|
index =::size32(properties.constant_offsets);
|
||||||
properties.constant_offsets.push_back(constant_id);
|
properties.constant_offsets.push_back(constant_id);
|
||||||
|
m_constant_offsets[constant_id] = index;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip next instruction, its just a literal
|
// Skip next instruction, its just a literal
|
||||||
|
|
@ -1305,6 +1304,7 @@ std::string FragmentProgramDecompiler::Decompile()
|
||||||
m_loop_count = 0;
|
m_loop_count = 0;
|
||||||
m_code_level = 1;
|
m_code_level = 1;
|
||||||
m_is_valid_ucode = true;
|
m_is_valid_ucode = true;
|
||||||
|
m_constant_offsets.clear();
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
#include "RSXFragmentProgram.h"
|
#include "RSXFragmentProgram.h"
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to translate RSX Fragment program to GLSL/HLSL code
|
* This class is used to translate RSX Fragment program to GLSL/HLSL code
|
||||||
|
|
@ -43,13 +44,13 @@ class FragmentProgramDecompiler
|
||||||
u32 m_const_index = 0;
|
u32 m_const_index = 0;
|
||||||
u32 m_offset;
|
u32 m_offset;
|
||||||
u32 m_location = 0;
|
u32 m_location = 0;
|
||||||
|
bool m_is_valid_ucode = true;
|
||||||
|
|
||||||
u32 m_loop_count;
|
u32 m_loop_count;
|
||||||
int m_code_level;
|
int m_code_level;
|
||||||
std::vector<u32> m_end_offsets;
|
std::vector<u32> m_end_offsets;
|
||||||
std::vector<u32> m_else_offsets;
|
std::vector<u32> m_else_offsets;
|
||||||
|
std::unordered_map<u32, u32> m_constant_offsets;
|
||||||
bool m_is_valid_ucode = true;
|
|
||||||
|
|
||||||
std::array<rsx::MixedPrecisionRegister, 64> temp_registers;
|
std::array<rsx::MixedPrecisionRegister, 64> temp_registers;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue