video_core: Reduce nihstro includes in headers. (#6626)

This commit is contained in:
Steveice10 2023-06-19 15:49:22 -07:00 committed by GitHub
parent 3faddd5e03
commit 03dbdfc12f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 37 deletions

View File

@ -16,6 +16,7 @@
namespace OpenGL::ShaderDecompiler { namespace OpenGL::ShaderDecompiler {
using nihstro::DestRegister;
using nihstro::Instruction; using nihstro::Instruction;
using nihstro::OpCode; using nihstro::OpCode;
using nihstro::RegisterType; using nihstro::RegisterType;

View File

@ -12,7 +12,6 @@
#include <boost/serialization/access.hpp> #include <boost/serialization/access.hpp>
#include <boost/serialization/array.hpp> #include <boost/serialization/array.hpp>
#include <boost/serialization/base_object.hpp> #include <boost/serialization/base_object.hpp>
#include <nihstro/shader_bytecode.h>
#include "common/assert.h" #include "common/assert.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -22,10 +21,6 @@
#include "video_core/regs_rasterizer.h" #include "video_core/regs_rasterizer.h"
#include "video_core/regs_shader.h" #include "video_core/regs_shader.h"
using nihstro::DestRegister;
using nihstro::RegisterType;
using nihstro::SourceRegister;
namespace Pica::Shader { namespace Pica::Shader {
constexpr unsigned MAX_PROGRAM_CODE_LENGTH = 4096; constexpr unsigned MAX_PROGRAM_CODE_LENGTH = 4096;
@ -164,36 +159,19 @@ struct UnitState {
GSEmitter* emitter_ptr; GSEmitter* emitter_ptr;
static std::size_t InputOffset(const SourceRegister& reg) { static std::size_t InputOffset(int register_index) {
switch (reg.GetRegisterType()) {
case RegisterType::Input:
return offsetof(UnitState, registers.input) + return offsetof(UnitState, registers.input) +
reg.GetIndex() * sizeof(Common::Vec4<float24>); register_index * sizeof(Common::Vec4<float24>);
case RegisterType::Temporary:
return offsetof(UnitState, registers.temporary) +
reg.GetIndex() * sizeof(Common::Vec4<float24>);
default:
UNREACHABLE();
return 0;
}
} }
static std::size_t OutputOffset(const DestRegister& reg) { static std::size_t OutputOffset(int register_index) {
switch (reg.GetRegisterType()) {
case RegisterType::Output:
return offsetof(UnitState, registers.output) + return offsetof(UnitState, registers.output) +
reg.GetIndex() * sizeof(Common::Vec4<float24>); register_index * sizeof(Common::Vec4<float24>);
case RegisterType::Temporary:
return offsetof(UnitState, registers.temporary) +
reg.GetIndex() * sizeof(Common::Vec4<float24>);
default:
UNREACHABLE();
return 0;
} }
static std::size_t TemporaryOffset(int register_index) {
return offsetof(UnitState, registers.temporary) +
register_index * sizeof(Common::Vec4<float24>);
} }
/** /**

View File

@ -29,6 +29,9 @@ using Xbyak::Reg32;
using Xbyak::Reg64; using Xbyak::Reg64;
using Xbyak::Xmm; using Xbyak::Xmm;
using nihstro::DestRegister;
using nihstro::RegisterType;
namespace Pica::Shader { namespace Pica::Shader {
typedef void (JitShader::*JitFunction)(Instruction instr); typedef void (JitShader::*JitFunction)(Instruction instr);
@ -185,13 +188,22 @@ void JitShader::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRe
Xmm dest) { Xmm dest) {
Reg64 src_ptr; Reg64 src_ptr;
std::size_t src_offset; std::size_t src_offset;
switch (src_reg.GetRegisterType()) {
if (src_reg.GetRegisterType() == RegisterType::FloatUniform) { case RegisterType::FloatUniform:
src_ptr = UNIFORMS; src_ptr = UNIFORMS;
src_offset = Uniforms::GetFloatUniformOffset(src_reg.GetIndex()); src_offset = Uniforms::GetFloatUniformOffset(src_reg.GetIndex());
} else { break;
case RegisterType::Input:
src_ptr = STATE; src_ptr = STATE;
src_offset = UnitState::InputOffset(src_reg); src_offset = UnitState::InputOffset(src_reg.GetIndex());
break;
case RegisterType::Temporary:
src_ptr = STATE;
src_offset = UnitState::TemporaryOffset(src_reg.GetIndex());
break;
default:
UNREACHABLE_MSG("Encountered unknown source register type: {}", src_reg.GetRegisterType());
break;
} }
int src_offset_disp = (int)src_offset; int src_offset_disp = (int)src_offset;
@ -270,7 +282,19 @@ void JitShader::Compile_DestEnable(Instruction instr, Xmm src) {
SwizzlePattern swiz = {(*swizzle_data)[operand_desc_id]}; SwizzlePattern swiz = {(*swizzle_data)[operand_desc_id]};
std::size_t dest_offset_disp = UnitState::OutputOffset(dest); std::size_t dest_offset_disp;
switch (dest.GetRegisterType()) {
case RegisterType::Output:
dest_offset_disp = UnitState::OutputOffset(dest.GetIndex());
break;
case RegisterType::Temporary:
dest_offset_disp = UnitState::TemporaryOffset(dest.GetIndex());
break;
default:
UNREACHABLE_MSG("Encountered unknown destination register type: {}",
dest.GetRegisterType());
break;
}
// If all components are enabled, write the result to the destination register // If all components are enabled, write the result to the destination register
if (swiz.dest_mask == NO_DEST_REG_MASK) { if (swiz.dest_mask == NO_DEST_REG_MASK) {

View File

@ -20,6 +20,7 @@
using nihstro::Instruction; using nihstro::Instruction;
using nihstro::OpCode; using nihstro::OpCode;
using nihstro::SourceRegister;
using nihstro::SwizzlePattern; using nihstro::SwizzlePattern;
namespace Pica::Shader { namespace Pica::Shader {