mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-13 13:15:59 +00:00
video: Import new shader recompiler + display a triangle (#142)
This commit is contained in:
parent
8cf64a33b2
commit
8730968385
103 changed files with 17793 additions and 729 deletions
97
src/shader_recompiler/frontend/decode.h
Normal file
97
src/shader_recompiler/frontend/decode.h
Normal file
|
@ -0,0 +1,97 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "shader_recompiler/frontend/instruction.h"
|
||||
|
||||
namespace Shader::Gcn {
|
||||
|
||||
struct InstFormat {
|
||||
InstClass inst_class = InstClass::Undefined;
|
||||
InstCategory inst_category = InstCategory::Undefined;
|
||||
u32 src_count = 0;
|
||||
u32 dst_count = 0;
|
||||
ScalarType src_type = ScalarType::Undefined;
|
||||
ScalarType dst_type = ScalarType::Undefined;
|
||||
};
|
||||
|
||||
InstEncoding GetInstructionEncoding(u32 token);
|
||||
|
||||
u32 GetEncodingLength(InstEncoding encoding);
|
||||
|
||||
InstFormat InstructionFormat(InstEncoding encoding, u32 opcode);
|
||||
|
||||
Opcode DecodeOpcode(u32 token);
|
||||
|
||||
class GcnCodeSlice {
|
||||
public:
|
||||
GcnCodeSlice(const u32* ptr, const u32* end) : m_ptr(ptr), m_end(end) {}
|
||||
GcnCodeSlice(const GcnCodeSlice& other) = default;
|
||||
~GcnCodeSlice() = default;
|
||||
|
||||
u32 at(u32 id) const {
|
||||
return m_ptr[id];
|
||||
}
|
||||
|
||||
u32 readu32() {
|
||||
return *(m_ptr++);
|
||||
}
|
||||
|
||||
u64 readu64() {
|
||||
const u64 value = *(u64*)m_ptr;
|
||||
m_ptr += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
bool atEnd() const {
|
||||
return m_ptr == m_end;
|
||||
}
|
||||
|
||||
private:
|
||||
const u32* m_ptr{};
|
||||
const u32* m_end{};
|
||||
};
|
||||
|
||||
class GcnDecodeContext {
|
||||
public:
|
||||
GcnInst decodeInstruction(GcnCodeSlice& code);
|
||||
|
||||
private:
|
||||
uint32_t getEncodingLength(InstEncoding encoding);
|
||||
uint32_t getOpMapOffset(InstEncoding encoding);
|
||||
uint32_t mapEncodingOp(InstEncoding encoding, Opcode opcode);
|
||||
void updateInstructionMeta(InstEncoding encoding);
|
||||
uint32_t getMimgModifier(Opcode opcode);
|
||||
void repairOperandType();
|
||||
|
||||
OperandField getOperandField(uint32_t code);
|
||||
|
||||
void decodeInstruction32(InstEncoding encoding, GcnCodeSlice& code);
|
||||
void decodeInstruction64(InstEncoding encoding, GcnCodeSlice& code);
|
||||
void decodeLiteralConstant(InstEncoding encoding, GcnCodeSlice& code);
|
||||
|
||||
// 32 bits encodings
|
||||
void decodeInstructionSOP1(uint32_t hexInstruction);
|
||||
void decodeInstructionSOPP(uint32_t hexInstruction);
|
||||
void decodeInstructionSOPC(uint32_t hexInstruction);
|
||||
void decodeInstructionSOPK(uint32_t hexInstruction);
|
||||
void decodeInstructionSOP2(uint32_t hexInstruction);
|
||||
void decodeInstructionVOP1(uint32_t hexInstruction);
|
||||
void decodeInstructionVOPC(uint32_t hexInstruction);
|
||||
void decodeInstructionVOP2(uint32_t hexInstruction);
|
||||
void decodeInstructionSMRD(uint32_t hexInstruction);
|
||||
void decodeInstructionVINTRP(uint32_t hexInstruction);
|
||||
// 64 bits encodings
|
||||
void decodeInstructionVOP3(uint64_t hexInstruction);
|
||||
void decodeInstructionMUBUF(uint64_t hexInstruction);
|
||||
void decodeInstructionMTBUF(uint64_t hexInstruction);
|
||||
void decodeInstructionMIMG(uint64_t hexInstruction);
|
||||
void decodeInstructionDS(uint64_t hexInstruction);
|
||||
void decodeInstructionEXP(uint64_t hexInstruction);
|
||||
|
||||
private:
|
||||
GcnInst m_instruction;
|
||||
};
|
||||
|
||||
} // namespace Shader::Gcn
|
Loading…
Add table
Add a link
Reference in a new issue