Pica: Set program code / swizzle data limit to 4096

One of the later commits will enable writing to GS regs.
It turns out that on startup, most games will write 4096 GS program words.

The current limit of 1024 would hence result in 3072 (4096 - 1024) error messages:
```
HW.GPU <Error> video_core/shader/shader.cpp:WriteProgramCode:229: Invalid GS program offset 1024
```

New constants have been introduced to represent these limits.
The swizzle data size has also been raised. This matches the given field sizes of [GPUREG_SH_OPDESCS_INDEX](https://3dbrew.org/wiki/GPU/Internal_Registers#GPUREG_SH_OPDESCS_INDEX) and [GPUREG_SH_CODETRANSFER_INDEX](https://www.3dbrew.org/wiki/GPU/Internal_Registers#GPUREG_SH_CODETRANSFER_INDEX) (12 bit = [0; 4095]).
merge-requests/60/head
Jannik Vogel 2017-05-08 23:37:38 +07:00
parent e33558c6ce
commit 925724c990
5 changed files with 16 additions and 13 deletions

@ -24,6 +24,9 @@ namespace Pica {
namespace Shader { namespace Shader {
constexpr unsigned MAX_PROGRAM_CODE_LENGTH = 4096;
constexpr unsigned MAX_SWIZZLE_DATA_LENGTH = 4096;
struct AttributeBuffer { struct AttributeBuffer {
alignas(16) Math::Vec4<float24> attr[16]; alignas(16) Math::Vec4<float24> attr[16];
}; };
@ -144,8 +147,8 @@ struct ShaderSetup {
return offsetof(ShaderSetup, uniforms.i) + index * sizeof(Math::Vec4<u8>); return offsetof(ShaderSetup, uniforms.i) + index * sizeof(Math::Vec4<u8>);
} }
std::array<u32, 1024> program_code; std::array<u32, MAX_PROGRAM_CODE_LENGTH> program_code;
std::array<u32, 1024> swizzle_data; std::array<u32, MAX_SWIZZLE_DATA_LENGTH> swizzle_data;
/// Data private to ShaderEngines /// Data private to ShaderEngines
struct EngineData { struct EngineData {

@ -653,7 +653,7 @@ static void RunInterpreter(const ShaderSetup& setup, UnitState& state, DebugData
} }
void InterpreterEngine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { void InterpreterEngine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) {
ASSERT(entry_point < 1024); ASSERT(entry_point < MAX_PROGRAM_CODE_LENGTH);
setup.engine_data.entry_point = entry_point; setup.engine_data.entry_point = entry_point;
} }

@ -15,7 +15,7 @@ JitX64Engine::JitX64Engine() = default;
JitX64Engine::~JitX64Engine() = default; JitX64Engine::~JitX64Engine() = default;
void JitX64Engine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) { void JitX64Engine::SetupBatch(ShaderSetup& setup, unsigned int entry_point) {
ASSERT(entry_point < 1024); ASSERT(entry_point < MAX_PROGRAM_CODE_LENGTH);
setup.engine_data.entry_point = entry_point; setup.engine_data.entry_point = entry_point;
u64 code_hash = Common::ComputeHash64(&setup.program_code, sizeof(setup.program_code)); u64 code_hash = Common::ComputeHash64(&setup.program_code, sizeof(setup.program_code));

@ -834,8 +834,8 @@ void JitShader::FindReturnOffsets() {
std::sort(return_offsets.begin(), return_offsets.end()); std::sort(return_offsets.begin(), return_offsets.end());
} }
void JitShader::Compile(const std::array<u32, 1024>* program_code_, void JitShader::Compile(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>* program_code_,
const std::array<u32, 1024>* swizzle_data_) { const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>* swizzle_data_) {
program_code = program_code_; program_code = program_code_;
swizzle_data = swizzle_data_; swizzle_data = swizzle_data_;

@ -22,8 +22,8 @@ namespace Pica {
namespace Shader { namespace Shader {
/// Memory allocated for each compiled shader (64Kb) /// Memory allocated for each compiled shader
constexpr size_t MAX_SHADER_SIZE = 1024 * 64; constexpr size_t MAX_SHADER_SIZE = MAX_PROGRAM_CODE_LENGTH * 64;
/** /**
* This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64 * This class implements the shader JIT compiler. It recompiles a Pica shader program into x86_64
@ -37,8 +37,8 @@ public:
program(&setup, &state, instruction_labels[offset].getAddress()); program(&setup, &state, instruction_labels[offset].getAddress());
} }
void Compile(const std::array<u32, 1024>* program_code, void Compile(const std::array<u32, MAX_PROGRAM_CODE_LENGTH>* program_code,
const std::array<u32, 1024>* swizzle_data); const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>* swizzle_data);
void Compile_ADD(Instruction instr); void Compile_ADD(Instruction instr);
void Compile_DP3(Instruction instr); void Compile_DP3(Instruction instr);
@ -104,11 +104,11 @@ private:
*/ */
void FindReturnOffsets(); void FindReturnOffsets();
const std::array<u32, 1024>* program_code = nullptr; const std::array<u32, MAX_PROGRAM_CODE_LENGTH>* program_code = nullptr;
const std::array<u32, 1024>* swizzle_data = nullptr; const std::array<u32, MAX_SWIZZLE_DATA_LENGTH>* swizzle_data = nullptr;
/// Mapping of Pica VS instructions to pointers in the emitted code /// Mapping of Pica VS instructions to pointers in the emitted code
std::array<Xbyak::Label, 1024> instruction_labels; std::array<Xbyak::Label, MAX_PROGRAM_CODE_LENGTH> instruction_labels;
/// Offsets in code where a return needs to be inserted /// Offsets in code where a return needs to be inserted
std::vector<unsigned> return_offsets; std::vector<unsigned> return_offsets;