diff options
Diffstat (limited to 'src/video_core/shader')
-rw-r--r-- | src/video_core/shader/shader.cpp | 1 | ||||
-rw-r--r-- | src/video_core/shader/shader.h | 12 | ||||
-rw-r--r-- | src/video_core/shader/shader_interpreter.cpp | 5 | ||||
-rw-r--r-- | src/video_core/shader/shader_interpreter.h | 4 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit_x64.cpp | 27 | ||||
-rw-r--r-- | src/video_core/shader/shader_jit_x64.h | 3 |
6 files changed, 26 insertions, 26 deletions
diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index f89117521..59f54236b 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -146,7 +146,6 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, const Regs::ShaderConfig& config, const State::ShaderSetup& setup) { UnitState<true> state; - const auto& shader_memory = setup.program_code; state.program_counter = config.main_offset; state.debug.max_offset = 0; state.debug.max_opdesc_id = 0; diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index bac51ddd8..1c6fa592c 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -289,13 +289,13 @@ struct UnitState { DebugData<Debug> debug; - static int InputOffset(const SourceRegister& reg) { + static size_t InputOffset(const SourceRegister& reg) { switch (reg.GetRegisterType()) { case RegisterType::Input: - return (int)offsetof(UnitState::Registers, input) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, input) + reg.GetIndex()*sizeof(Math::Vec4<float24>); case RegisterType::Temporary: - return (int)offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); default: UNREACHABLE(); @@ -303,13 +303,13 @@ struct UnitState { } } - static int OutputOffset(const DestRegister& reg) { + static size_t OutputOffset(const DestRegister& reg) { switch (reg.GetRegisterType()) { case RegisterType::Output: - return (int)offsetof(UnitState::Registers, output) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, output) + reg.GetIndex()*sizeof(Math::Vec4<float24>); case RegisterType::Temporary: - return (int)offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); + return offsetof(UnitState::Registers, temporary) + reg.GetIndex()*sizeof(Math::Vec4<float24>); default: UNREACHABLE(); diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 69e4efa68..7b0c20b74 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -7,9 +7,8 @@ #include <nihstro/shader_bytecode.h> #include "video_core/pica.h" - -#include "shader.h" -#include "shader_interpreter.h" +#include "video_core/shader/shader.h" +#include "video_core/shader/shader_interpreter.h" using nihstro::OpCode; using nihstro::Instruction; diff --git a/src/video_core/shader/shader_interpreter.h b/src/video_core/shader/shader_interpreter.h index 71bcad5ac..294bca50e 100644 --- a/src/video_core/shader/shader_interpreter.h +++ b/src/video_core/shader/shader_interpreter.h @@ -4,9 +4,7 @@ #pragma once -#include "video_core/pica.h" - -#include "shader.h" +#include "video_core/shader/shader.h" namespace Pica { diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index b9a0b19e3..00415e402 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp @@ -144,7 +144,7 @@ static const u8 NO_DEST_REG_MASK = 0xf; */ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRegister src_reg, X64Reg dest) { X64Reg src_ptr; - int src_offset; + size_t src_offset; if (src_reg.GetRegisterType() == RegisterType::FloatUniform) { src_ptr = UNIFORMS; @@ -154,6 +154,9 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source src_offset = UnitState<false>::InputOffset(src_reg); } + int src_offset_disp = (int)src_offset; + ASSERT_MSG(src_offset == src_offset_disp, "Source register offset too large for int type"); + unsigned operand_desc_id; if (instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MAD || instr.opcode.Value().EffectiveOpCode() == OpCode::Id::MADI) { @@ -163,7 +166,7 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source operand_desc_id = instr.mad.operand_desc_id; // Load the source - MOVAPS(dest, MDisp(src_ptr, src_offset)); + MOVAPS(dest, MDisp(src_ptr, src_offset_disp)); } else { operand_desc_id = instr.common.operand_desc_id; @@ -173,13 +176,13 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source if (src_num == offset_src && instr.common.address_register_index != 0) { switch (instr.common.address_register_index) { case 1: // address offset 1 - MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_0, 1, src_offset)); + MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_0, SCALE_1, src_offset_disp)); break; case 2: // address offset 2 - MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_1, 1, src_offset)); + MOVAPS(dest, MComplex(src_ptr, ADDROFFS_REG_1, SCALE_1, src_offset_disp)); break; - case 3: // adddress offet 3 - MOVAPS(dest, MComplex(src_ptr, LOOPCOUNT_REG, 1, src_offset)); + case 3: // address offset 3 + MOVAPS(dest, MComplex(src_ptr, LOOPCOUNT_REG, SCALE_1, src_offset_disp)); break; default: UNREACHABLE(); @@ -187,7 +190,7 @@ void JitCompiler::Compile_SwizzleSrc(Instruction instr, unsigned src_num, Source } } else { // Load the source - MOVAPS(dest, MDisp(src_ptr, src_offset)); + MOVAPS(dest, MDisp(src_ptr, src_offset_disp)); } } @@ -224,14 +227,17 @@ void JitCompiler::Compile_DestEnable(Instruction instr,X64Reg src) { SwizzlePattern swiz = { g_state.vs.swizzle_data[operand_desc_id] }; + int dest_offset_disp = (int)UnitState<false>::OutputOffset(dest); + ASSERT_MSG(dest_offset_disp == UnitState<false>::OutputOffset(dest), "Destinaton offset too large for int type"); + // If all components are enabled, write the result to the destination register if (swiz.dest_mask == NO_DEST_REG_MASK) { // Store dest back to memory - MOVAPS(MDisp(REGISTERS, UnitState<false>::OutputOffset(dest)), src); + MOVAPS(MDisp(REGISTERS, dest_offset_disp), src); } else { // Not all components are enabled, so mask the result when storing to the destination register... - MOVAPS(SCRATCH, MDisp(REGISTERS, UnitState<false>::OutputOffset(dest))); + MOVAPS(SCRATCH, MDisp(REGISTERS, dest_offset_disp)); if (Common::GetCPUCaps().sse4_1) { u8 mask = ((swiz.dest_mask & 1) << 3) | ((swiz.dest_mask & 8) >> 3) | ((swiz.dest_mask & 2) << 1) | ((swiz.dest_mask & 4) >> 1); @@ -250,7 +256,7 @@ void JitCompiler::Compile_DestEnable(Instruction instr,X64Reg src) { } // Store dest back to memory - MOVAPS(MDisp(REGISTERS, UnitState<false>::OutputOffset(dest)), SCRATCH); + MOVAPS(MDisp(REGISTERS, dest_offset_disp), SCRATCH); } } @@ -743,7 +749,6 @@ void JitCompiler::Compile_NextInstr(unsigned* offset) { CompiledShader* JitCompiler::Compile() { const u8* start = GetCodePtr(); - const auto& code = g_state.vs.program_code; unsigned offset = g_state.regs.vs.main_offset; // The stack pointer is 8 modulo 16 at the entry of a procedure diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h index 8668cfff4..3afbceccf 100644 --- a/src/video_core/shader/shader_jit_x64.h +++ b/src/video_core/shader/shader_jit_x64.h @@ -9,8 +9,7 @@ #include "common/x64/emitter.h" #include "video_core/pica.h" - -#include "shader.h" +#include "video_core/shader/shader.h" using nihstro::Instruction; using nihstro::OpCode; |