2017-10-16 17:50:09 +02:00
|
|
|
#include "dxbc_compiler.h"
|
|
|
|
|
|
|
|
namespace dxvk {
|
|
|
|
|
2017-10-16 19:53:17 +02:00
|
|
|
DxbcCompiler::DxbcCompiler(DxbcProgramVersion version)
|
|
|
|
: m_version(version) {
|
2017-10-21 17:58:58 +02:00
|
|
|
m_entryPointId = m_counter.nextId();
|
|
|
|
|
2017-10-18 09:50:30 +02:00
|
|
|
this->declareCapabilities();
|
|
|
|
this->declareMemoryModel();
|
2017-10-16 17:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DxbcCompiler::~DxbcCompiler() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-21 17:58:58 +02:00
|
|
|
bool DxbcCompiler::processInstruction(DxbcInstruction ins) {
|
|
|
|
return false;
|
2017-10-16 17:50:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Rc<DxvkShader> DxbcCompiler::finalize() {
|
2017-10-18 10:36:47 +02:00
|
|
|
SpirvCodeBuffer codeBuffer;
|
2017-10-16 19:53:17 +02:00
|
|
|
codeBuffer.putHeader(m_counter.numIds());
|
2017-10-17 13:02:57 +02:00
|
|
|
codeBuffer.append(m_spvCapabilities.code());
|
|
|
|
codeBuffer.append(m_spvEntryPoints.code());
|
|
|
|
codeBuffer.append(m_spvTypeInfo.code());
|
|
|
|
codeBuffer.append(m_spvCode);
|
2017-10-16 19:53:17 +02:00
|
|
|
|
2017-10-17 13:02:57 +02:00
|
|
|
return new DxvkShader(m_version.shaderStage(),
|
2017-10-16 19:53:17 +02:00
|
|
|
std::move(codeBuffer), 0, nullptr);
|
|
|
|
}
|
|
|
|
|
2017-10-18 09:50:30 +02:00
|
|
|
|
|
|
|
void DxbcCompiler::declareCapabilities() {
|
|
|
|
m_spvCapabilities.enable(spv::CapabilityShader);
|
|
|
|
|
|
|
|
switch (m_version.type()) {
|
|
|
|
case DxbcProgramType::GeometryShader:
|
|
|
|
m_spvCapabilities.enable(spv::CapabilityGeometry);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DxbcProgramType::HullShader:
|
|
|
|
case DxbcProgramType::DomainShader:
|
|
|
|
m_spvCapabilities.enable(spv::CapabilityTessellation);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DxbcCompiler::declareMemoryModel() {
|
|
|
|
m_spvEntryPoints.setMemoryModel(
|
|
|
|
spv::AddressingModelLogical,
|
|
|
|
spv::MemoryModelGLSL450);
|
|
|
|
}
|
|
|
|
|
2017-10-16 17:50:09 +02:00
|
|
|
}
|