[dxvk] Support creating shader stage infos with module identifiers

This commit is contained in:
Philip Rebohle 2022-07-08 17:51:31 +02:00
parent 52cc0a366e
commit df1908f7bf
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 49 additions and 2 deletions

View File

@ -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();

View File

@ -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;