mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-02-20 19:54:19 +01:00
[dxvk] Support creating shader stage infos with module identifiers
This commit is contained in:
parent
52cc0a366e
commit
df1908f7bf
@ -386,7 +386,7 @@ namespace dxvk {
|
||||
// enabled, we do not need to create a shader module object and can
|
||||
// instead chain the create info to the shader stage info struct.
|
||||
// For compute pipelines, this doesn't work and we still need a module.
|
||||
auto& moduleInfo = m_moduleInfos[m_stageCount];
|
||||
auto& moduleInfo = m_moduleInfos[m_stageCount].moduleInfo;
|
||||
moduleInfo = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO };
|
||||
moduleInfo.codeSize = codeBuffer.size();
|
||||
moduleInfo.pCode = codeBuffer.data();
|
||||
@ -415,6 +415,31 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxvkShaderStageInfo::addStage(
|
||||
VkShaderStageFlagBits stage,
|
||||
const VkShaderModuleIdentifierEXT& identifier,
|
||||
const VkSpecializationInfo* specInfo) {
|
||||
// Copy relevant bits of the module identifier
|
||||
uint32_t identifierSize = std::min(identifier.identifierSize, VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT);
|
||||
|
||||
auto& moduleId = m_moduleInfos[m_stageCount].moduleIdentifier;
|
||||
moduleId.createInfo = { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT };
|
||||
moduleId.createInfo.identifierSize = identifierSize;
|
||||
moduleId.createInfo.pIdentifier = moduleId.data.data();
|
||||
std::memcpy(moduleId.data.data(), identifier.identifier, identifierSize);
|
||||
|
||||
// Set up stage info using the module identifier
|
||||
auto& stageInfo = m_stageInfos[m_stageCount];
|
||||
stageInfo = { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO };
|
||||
stageInfo.pNext = &moduleId.createInfo;
|
||||
stageInfo.stage = stage;
|
||||
stageInfo.pName = "main";
|
||||
stageInfo.pSpecializationInfo = specInfo;
|
||||
|
||||
m_stageCount++;
|
||||
}
|
||||
|
||||
|
||||
DxvkShaderStageInfo::~DxvkShaderStageInfo() {
|
||||
auto vk = m_device->vkd();
|
||||
|
||||
|
@ -278,12 +278,34 @@ namespace dxvk {
|
||||
SpirvCodeBuffer&& code,
|
||||
const VkSpecializationInfo* specInfo);
|
||||
|
||||
/**
|
||||
* \brief Adds stage using a module identifier
|
||||
*
|
||||
* \param [in] stage Shader stage
|
||||
* \param [in] identifier Shader module identifier
|
||||
* \param [in] specinfo Specialization info
|
||||
*/
|
||||
void addStage(
|
||||
VkShaderStageFlagBits stage,
|
||||
const VkShaderModuleIdentifierEXT& identifier,
|
||||
const VkSpecializationInfo* specInfo);
|
||||
|
||||
private:
|
||||
|
||||
const DxvkDevice* m_device;
|
||||
|
||||
struct ShaderModuleIdentifier {
|
||||
VkPipelineShaderStageModuleIdentifierCreateInfoEXT createInfo;
|
||||
std::array<uint8_t, VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT> data;
|
||||
};
|
||||
|
||||
union ShaderModuleInfo {
|
||||
ShaderModuleIdentifier moduleIdentifier;
|
||||
VkShaderModuleCreateInfo moduleInfo;
|
||||
};
|
||||
|
||||
std::array<SpirvCodeBuffer, 5> m_codeBuffers;
|
||||
std::array<VkShaderModuleCreateInfo, 5> m_moduleInfos = { };
|
||||
std::array<ShaderModuleInfo, 5> m_moduleInfos = { };
|
||||
std::array<VkPipelineShaderStageCreateInfo, 5> m_stageInfos = { };
|
||||
uint32_t m_stageCount = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user