mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-31 05:52:11 +01:00
[dxbc] Figuring out how to best generate SPIR-V module code
This commit is contained in:
parent
aebe359509
commit
0a57a4ddf5
@ -2,8 +2,9 @@
|
|||||||
|
|
||||||
namespace dxvk {
|
namespace dxvk {
|
||||||
|
|
||||||
DxbcCompiler::DxbcCompiler(DxbcProgramVersion version) {
|
DxbcCompiler::DxbcCompiler(DxbcProgramVersion version)
|
||||||
|
: m_version(version) {
|
||||||
|
this->enableCapability(spv::CapabilityShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -19,8 +20,36 @@ namespace dxvk {
|
|||||||
|
|
||||||
|
|
||||||
Rc<DxvkShader> DxbcCompiler::finalize() {
|
Rc<DxvkShader> DxbcCompiler::finalize() {
|
||||||
return new DxvkShader(VK_SHADER_STAGE_COMPUTE_BIT,
|
DxvkSpirvCodeBuffer codeBuffer;
|
||||||
DxvkSpirvCodeBuffer(), 0, nullptr);
|
codeBuffer.putHeader(m_counter.numIds());
|
||||||
|
codeBuffer.append(m_spirvCapabilities);
|
||||||
|
codeBuffer.append(m_spirvProgramCode);
|
||||||
|
|
||||||
|
return new DxvkShader(this->shaderStage(),
|
||||||
|
std::move(codeBuffer), 0, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VkShaderStageFlagBits DxbcCompiler::shaderStage() const {
|
||||||
|
switch (m_version.type()) {
|
||||||
|
case DxbcProgramType::PixelShader : return VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||||
|
case DxbcProgramType::VertexShader : return VK_SHADER_STAGE_VERTEX_BIT;
|
||||||
|
case DxbcProgramType::GeometryShader : return VK_SHADER_STAGE_GEOMETRY_BIT;
|
||||||
|
case DxbcProgramType::HullShader : return VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
|
||||||
|
case DxbcProgramType::DomainShader : return VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
|
||||||
|
case DxbcProgramType::ComputeShader : return VK_SHADER_STAGE_COMPUTE_BIT;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw DxvkError("DxbcCompiler::shaderStage: Unknown program type");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DxbcCompiler::enableCapability(spv::Capability cap) {
|
||||||
|
if (m_capabilities.find(cap) == m_capabilities.end()) {
|
||||||
|
m_spirvCapabilities.putIns (spv::OpCapability, 2);
|
||||||
|
m_spirvCapabilities.putWord(cap);
|
||||||
|
m_capabilities.insert(cap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <unordered_set>
|
||||||
|
|
||||||
#include "../dxvk/dxvk_shader.h"
|
#include "../dxvk/dxvk_shader.h"
|
||||||
|
|
||||||
#include "dxbc_chunk_shex.h"
|
#include "dxbc_chunk_shex.h"
|
||||||
@ -34,6 +36,18 @@ namespace dxvk {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
DxbcProgramVersion m_version;
|
||||||
|
DxvkSpirvIdCounter m_counter;
|
||||||
|
|
||||||
|
std::unordered_set<spv::Capability> m_capabilities;
|
||||||
|
|
||||||
|
DxvkSpirvCodeBuffer m_spirvCapabilities;
|
||||||
|
DxvkSpirvCodeBuffer m_spirvProgramCode;
|
||||||
|
|
||||||
|
VkShaderStageFlagBits shaderStage() const;
|
||||||
|
|
||||||
|
void enableCapability(spv::Capability cap);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user