2017-10-16 17:50:09 +02:00
|
|
|
#pragma once
|
|
|
|
|
2017-11-13 00:22:52 +01:00
|
|
|
#include "./gen/dxbc_gen_common.h"
|
2017-10-16 17:50:09 +02:00
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
|
|
|
/**
|
2017-11-13 00:22:52 +01:00
|
|
|
* \brief DXBC compiler
|
|
|
|
*
|
|
|
|
* Interprets DXBC instructions and generates
|
|
|
|
* SPIR-V code for the appropriate shader type.
|
2017-10-16 17:50:09 +02:00
|
|
|
*/
|
|
|
|
class DxbcCompiler {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
DxbcCompiler(
|
2017-12-07 16:29:34 +01:00
|
|
|
const DxbcProgramVersion& version,
|
|
|
|
const Rc<DxbcIsgn>& isgn,
|
|
|
|
const Rc<DxbcIsgn>& osgn);
|
2017-10-16 17:50:09 +02:00
|
|
|
~DxbcCompiler();
|
|
|
|
|
2017-11-01 00:01:40 +01:00
|
|
|
void processInstruction(
|
2017-12-07 16:29:34 +01:00
|
|
|
const DxbcInstruction& ins);
|
2017-11-13 00:22:52 +01:00
|
|
|
|
2017-12-08 18:14:05 +01:00
|
|
|
Rc<DxvkShader> finalize();
|
2017-10-16 17:50:09 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2017-11-13 00:22:52 +01:00
|
|
|
Rc<DxbcCodeGen> m_gen;
|
|
|
|
|
|
|
|
void dclGlobalFlags(
|
2017-11-16 01:30:17 +01:00
|
|
|
const DxbcInstruction& ins);
|
2017-11-13 00:22:52 +01:00
|
|
|
|
2017-12-08 17:08:26 +01:00
|
|
|
void dclConstantBuffer(
|
|
|
|
const DxbcInstruction& ins);
|
|
|
|
|
2017-11-13 02:07:13 +01:00
|
|
|
void dclInterfaceVar(
|
2017-11-16 01:30:17 +01:00
|
|
|
const DxbcInstruction& ins);
|
2017-11-13 00:22:52 +01:00
|
|
|
|
|
|
|
void dclTemps(
|
2017-11-16 01:30:17 +01:00
|
|
|
const DxbcInstruction& ins);
|
|
|
|
|
2017-11-17 11:41:56 +01:00
|
|
|
void opAdd(
|
|
|
|
const DxbcInstruction& ins);
|
|
|
|
|
2017-12-09 01:49:30 +01:00
|
|
|
void opMul(
|
|
|
|
const DxbcInstruction& ins);
|
|
|
|
|
2017-12-08 17:08:26 +01:00
|
|
|
void opDpx(
|
|
|
|
const DxbcInstruction& ins,
|
|
|
|
uint32_t n);
|
|
|
|
|
2017-11-16 01:30:17 +01:00
|
|
|
void opMov(
|
|
|
|
const DxbcInstruction& ins);
|
|
|
|
|
|
|
|
void opRet(
|
|
|
|
const DxbcInstruction& ins);
|
|
|
|
|
2017-12-08 17:08:26 +01:00
|
|
|
DxbcValue getDynamicIndexValue(
|
|
|
|
const DxbcOperandIndex& index);
|
|
|
|
|
2017-11-16 01:30:17 +01:00
|
|
|
DxbcComponentMask getDstOperandMask(
|
|
|
|
const DxbcOperand& operand);
|
|
|
|
|
|
|
|
DxbcPointer getTempOperandPtr(
|
|
|
|
const DxbcOperand& operand);
|
|
|
|
|
|
|
|
DxbcPointer getInterfaceOperandPtr(
|
|
|
|
const DxbcOperand& operand);
|
|
|
|
|
2017-12-08 17:08:26 +01:00
|
|
|
DxbcPointer getConstantBufferPtr(
|
|
|
|
const DxbcOperand& operand);
|
|
|
|
|
2017-11-16 01:30:17 +01:00
|
|
|
DxbcPointer getOperandPtr(
|
|
|
|
const DxbcOperand& operand);
|
|
|
|
|
|
|
|
DxbcValue selectOperandComponents(
|
|
|
|
const DxbcOperandToken& opToken,
|
|
|
|
const DxbcValue& opValue,
|
|
|
|
DxbcComponentMask dstMask);
|
|
|
|
|
|
|
|
DxbcValue applyOperandModifiers(
|
|
|
|
DxbcValue value,
|
|
|
|
DxbcOperandModifiers modifiers);
|
|
|
|
|
2017-11-17 11:41:56 +01:00
|
|
|
DxbcValue applyResultModifiers(
|
|
|
|
DxbcValue value,
|
|
|
|
DxbcOpcodeControl control);
|
|
|
|
|
2017-11-16 01:30:17 +01:00
|
|
|
DxbcValue loadOperand(
|
|
|
|
const DxbcOperand& operand,
|
|
|
|
DxbcComponentMask dstMask,
|
|
|
|
DxbcScalarType dstType);
|
|
|
|
|
|
|
|
void storeOperand(
|
|
|
|
const DxbcOperand& operand,
|
|
|
|
DxbcValue value,
|
|
|
|
DxbcComponentMask mask);
|
2017-10-16 19:53:17 +02:00
|
|
|
|
2017-10-16 17:50:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|