2017-10-16 17:50:09 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
#include "dxbc_chunk_isgn.h"
|
2017-10-16 17:50:09 +02:00
|
|
|
#include "dxbc_chunk_shex.h"
|
2017-10-29 02:35:16 +02:00
|
|
|
#include "dxbc_names.h"
|
2017-11-01 00:01:40 +01:00
|
|
|
#include "dxbc_type.h"
|
2017-10-18 10:36:47 +02:00
|
|
|
|
2017-10-26 15:40:39 +02:00
|
|
|
#include "../spirv/spirv_module.h"
|
2017-10-16 17:50:09 +02:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief DXBC to SPIR-V compiler
|
|
|
|
*/
|
|
|
|
class DxbcCompiler {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
DxbcCompiler(
|
|
|
|
DxbcProgramVersion version,
|
|
|
|
const Rc<DxbcIsgn>& inputSig,
|
|
|
|
const Rc<DxbcIsgn>& outputSig);
|
2017-10-16 17:50:09 +02:00
|
|
|
~DxbcCompiler();
|
|
|
|
|
2017-10-21 17:58:58 +02:00
|
|
|
DxbcCompiler (DxbcCompiler&&) = delete;
|
|
|
|
DxbcCompiler& operator = (DxbcCompiler&&) = delete;
|
|
|
|
|
2017-10-16 17:50:09 +02:00
|
|
|
/**
|
|
|
|
* \brief Processes a single instruction
|
2017-10-21 17:58:58 +02:00
|
|
|
*
|
2017-10-16 17:50:09 +02:00
|
|
|
* \param [in] ins The instruction
|
2017-10-21 17:58:58 +02:00
|
|
|
* \returns \c true on success
|
2017-10-16 17:50:09 +02:00
|
|
|
*/
|
2017-11-01 00:01:40 +01:00
|
|
|
void processInstruction(
|
2017-10-25 13:49:13 +02:00
|
|
|
const DxbcInstruction& ins);
|
2017-10-16 17:50:09 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Creates actual shader object
|
|
|
|
*
|
|
|
|
* Combines all information gatherd during the
|
|
|
|
* shader compilation into one shader object.
|
|
|
|
*/
|
|
|
|
Rc<DxvkShader> finalize();
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2017-10-16 19:53:17 +02:00
|
|
|
DxbcProgramVersion m_version;
|
2017-10-26 15:40:39 +02:00
|
|
|
SpirvModule m_module;
|
2017-10-16 19:53:17 +02:00
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
Rc<DxbcIsgn> m_inputSig;
|
|
|
|
Rc<DxbcIsgn> m_outputSig;
|
|
|
|
|
2017-10-29 02:35:16 +02:00
|
|
|
std::vector<uint32_t> m_interfaces;
|
2017-11-01 00:01:40 +01:00
|
|
|
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;
|
2017-10-26 16:32:10 +02:00
|
|
|
|
2017-10-21 17:58:58 +02:00
|
|
|
uint32_t m_entryPointId = 0;
|
|
|
|
|
2017-10-26 16:32:10 +02:00
|
|
|
uint32_t m_typeVoid = 0;
|
|
|
|
uint32_t m_typeFunction = 0;
|
|
|
|
|
2017-10-29 02:35:16 +02:00
|
|
|
bool m_useRestrictedMath = false;
|
|
|
|
|
2017-11-01 16:43:04 +01:00
|
|
|
|
|
|
|
|
2017-10-18 09:50:30 +02:00
|
|
|
void declareCapabilities();
|
|
|
|
void declareMemoryModel();
|
2017-10-16 19:53:17 +02:00
|
|
|
|
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 00:01:40 +01:00
|
|
|
|
2017-11-01 16:43:04 +01:00
|
|
|
uint32_t getValueTypeId(
|
|
|
|
const DxbcValueType& type);
|
|
|
|
|
|
|
|
uint32_t getPointerTypeId(
|
|
|
|
const DxbcPointerType& type);
|
2017-11-01 00:01:40 +01:00
|
|
|
|
|
|
|
|
|
|
|
DxbcValue loadPointer(
|
|
|
|
const DxbcPointer& pointer);
|
|
|
|
|
|
|
|
DxbcValue loadOperand(
|
|
|
|
const DxbcOperand& operand,
|
|
|
|
const DxbcValueType& type);
|
|
|
|
|
2017-11-01 16:43:04 +01:00
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
void storePointer(
|
|
|
|
const DxbcPointer& pointer,
|
|
|
|
const DxbcValue& value);
|
|
|
|
|
|
|
|
void storeOperand(
|
|
|
|
const DxbcOperand& operand,
|
|
|
|
const DxbcValueType& srcType,
|
|
|
|
uint32_t srcValue);
|
2017-10-26 16:32:10 +02:00
|
|
|
|
2017-10-16 17:50:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|