1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +01:00
OpenDX/src/dxbc/dxbc_compiler.h

123 lines
2.7 KiB
C
Raw Normal View History

#pragma once
#include "dxbc_chunk_isgn.h"
#include "dxbc_chunk_shex.h"
#include "dxbc_names.h"
#include "dxbc_type.h"
#include "../spirv/spirv_module.h"
namespace dxvk {
/**
* \brief DXBC to SPIR-V compiler
*/
class DxbcCompiler {
public:
DxbcCompiler(
DxbcProgramVersion version,
const Rc<DxbcIsgn>& inputSig,
const Rc<DxbcIsgn>& outputSig);
~DxbcCompiler();
DxbcCompiler (DxbcCompiler&&) = delete;
DxbcCompiler& operator = (DxbcCompiler&&) = delete;
/**
* \brief Processes a single instruction
*
* \param [in] ins The instruction
* \returns \c true on success
*/
void processInstruction(
2017-10-25 13:49:13 +02:00
const DxbcInstruction& ins);
/**
* \brief Creates actual shader object
*
* Combines all information gatherd during the
* shader compilation into one shader object.
*/
Rc<DxvkShader> finalize();
private:
DxbcProgramVersion m_version;
SpirvModule m_module;
Rc<DxbcIsgn> m_inputSig;
Rc<DxbcIsgn> m_outputSig;
std::vector<uint32_t> m_interfaces;
std::vector<DxbcPointer> m_rRegs; // Temps
2017-11-01 16:43:04 +01:00
DxbcPointer m_svPosition;
std::vector<DxbcPointer> m_svClipDistance;
std::vector<DxbcPointer> m_svCullDistance;
uint32_t m_entryPointId = 0;
uint32_t m_typeVoid = 0;
uint32_t m_typeFunction = 0;
bool m_useRestrictedMath = false;
2017-11-01 16:43:04 +01:00
void declareCapabilities();
void declareMemoryModel();
2017-11-01 16:43:04 +01:00
void dclGlobalFlags(
const DxbcInstruction& ins);
void dclInput(
const DxbcInstruction& ins);
void dclOutputSiv(
const DxbcInstruction& ins);
void dclTemps(
const DxbcInstruction& ins);
void dclThreadGroup(
const DxbcInstruction& ins);
void opMov(
const DxbcInstruction& ins);
void opRet(
const DxbcInstruction& ins);
uint32_t getScalarTypeId(
const DxbcScalarType& type);
2017-11-01 16:43:04 +01:00
uint32_t getValueTypeId(
const DxbcValueType& type);
uint32_t getPointerTypeId(
const DxbcPointerType& type);
DxbcValue loadPointer(
const DxbcPointer& pointer);
DxbcValue loadOperand(
const DxbcOperand& operand,
const DxbcValueType& type);
2017-11-01 16:43:04 +01:00
void storePointer(
const DxbcPointer& pointer,
const DxbcValue& value);
void storeOperand(
const DxbcOperand& operand,
const DxbcValueType& srcType,
uint32_t srcValue);
};
}