1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[dxvk] Remove old pipeline layout implementation

This commit is contained in:
Philip Rebohle 2022-06-23 17:41:19 +02:00
parent c67481b904
commit db07861518
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
14 changed files with 0 additions and 735 deletions

View File

@ -336,13 +336,6 @@ namespace dxvk {
{ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, 3, VK_IMAGE_VIEW_TYPE_2D, 0, VK_ACCESS_SHADER_READ_BIT },
}};
const std::array<DxvkResourceSlot, 4> fsResourceSlots = {{
{ 0, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC },
{ 1, VK_DESCRIPTOR_TYPE_SAMPLER },
{ 2, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_IMAGE_VIEW_TYPE_2D },
{ 3, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_IMAGE_VIEW_TYPE_2D },
}};
DxvkShaderCreateInfo vsInfo;
vsInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vsInfo.outputMask = 0x1;
@ -352,8 +345,6 @@ namespace dxvk {
fsInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fsInfo.bindingCount = fsBindings.size();
fsInfo.bindings = fsBindings.data();
fsInfo.resourceSlotCount = fsResourceSlots.size();
fsInfo.resourceSlots = fsResourceSlots.data();
fsInfo.inputMask = 0x1;
fsInfo.outputMask = 0x1;
m_fs = new DxvkShader(fsInfo, std::move(fsCode));

View File

@ -602,8 +602,6 @@ namespace dxvk {
std::string m_filename;
SpirvModule m_module;
std::vector
<DxvkResourceSlot> m_resourceSlots;
std::vector
<DxvkBindingInfo> m_bindings;
std::vector<uint32_t> m_entryPointInterfaces;
@ -717,8 +715,6 @@ namespace dxvk {
info.stage = isVS() ? VK_SHADER_STAGE_VERTEX_BIT : VK_SHADER_STAGE_FRAGMENT_BIT;
info.bindingCount = m_bindings.size();
info.bindings = m_bindings.data();
info.resourceSlotCount = m_resourceSlots.size();
info.resourceSlots = m_resourceSlots.data();
info.inputMask = m_inputMask;
info.outputMask = m_outputMask;
info.pushConstOffset = m_pushConstOffset;
@ -1390,13 +1386,6 @@ namespace dxvk {
m_module.decorateDescriptorSet(m_vs.constantBuffer, 0);
m_module.decorateBinding(m_vs.constantBuffer, bindingId);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
@ -1436,13 +1425,6 @@ namespace dxvk {
m_module.decorate(m_vs.vertexBlendData, spv::DecorationNonWritable);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_SHADER_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
@ -2049,13 +2031,6 @@ namespace dxvk {
m_module.decorateDescriptorSet(m_ps.constantBuffer, 0);
m_module.decorateBinding(m_ps.constantBuffer, bindingId);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
@ -2127,13 +2102,6 @@ namespace dxvk {
m_module.decorateBinding(sampler.varId, bindingId);
// Store descriptor info for the shader interface
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
resource.view = viewType;
resource.access = VK_ACCESS_SHADER_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER };
binding.resourceBinding = bindingId;
binding.viewType = viewType;
@ -2155,13 +2123,6 @@ namespace dxvk {
m_module.decorateDescriptorSet(m_ps.sharedState, 0);
m_module.decorateBinding(m_ps.sharedState, bindingId);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
@ -2201,13 +2162,6 @@ namespace dxvk {
m_module.decorateDescriptorSet(clipPlaneBlock, 0);
m_module.decorateBinding (clipPlaneBlock, bindingId);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;

View File

@ -130,17 +130,10 @@ namespace dxvk {
{ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, BindingIds::Buffer, VK_IMAGE_VIEW_TYPE_1D, 0, VK_ACCESS_SHADER_READ_BIT },
} };
const std::array<DxvkResourceSlot, 2> resourceSlots = { {
{ BindingIds::Image, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, VK_IMAGE_VIEW_TYPE_2D },
{ BindingIds::Buffer, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, VK_IMAGE_VIEW_TYPE_1D },
} };
DxvkShaderCreateInfo info;
info.stage = VK_SHADER_STAGE_COMPUTE_BIT;
info.bindingCount = bindings.size();
info.bindings = bindings.data();
info.resourceSlotCount = resourceSlots.size();
info.resourceSlots = resourceSlots.data();
info.pushConstOffset = 0;
info.pushConstSize = sizeof(VkExtent2D);

View File

@ -136,11 +136,6 @@ namespace dxvk {
m_bufferBinding.access = VK_ACCESS_SHADER_WRITE_BIT;
m_bufferBinding.stages = 0;
m_bufferResource.slot = bufferSlot;
m_bufferResource.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
m_bufferResource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
m_bufferResource.access = VK_ACCESS_SHADER_WRITE_BIT;
// Load our builtins
uint32_t primitiveIdPtr = m_module.newVar(m_module.defPointerType(uint_t, spv::StorageClassInput), spv::StorageClassInput);
m_module.decorateBuiltIn(primitiveIdPtr, spv::BuiltInPrimitiveId);
@ -291,8 +286,6 @@ namespace dxvk {
info.stage = VK_SHADER_STAGE_GEOMETRY_BIT;
info.bindingCount = 1;
info.bindings = &m_bufferBinding;
info.resourceSlotCount = 1;
info.resourceSlots = &m_bufferResource;
info.inputMask = m_inputMask;
return new DxvkShader(info, m_module.compile());
@ -306,7 +299,6 @@ namespace dxvk {
uint32_t m_entryPointId = 0;
uint32_t m_inputMask = 0u;
DxvkBindingInfo m_bufferBinding;
DxvkResourceSlot m_bufferResource;
};

View File

@ -251,8 +251,6 @@ namespace dxvk {
// Create the shader object
DxvkShaderCreateInfo info;
info.stage = m_programInfo.shaderStage();
info.resourceSlotCount = m_resourceSlots.size();
info.resourceSlots = m_resourceSlots.data();
info.bindingCount = m_bindings.size();
info.bindings = m_bindings.data();
info.inputMask = m_inputMask;
@ -840,13 +838,6 @@ namespace dxvk {
? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
: VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = descriptorType;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { descriptorType };
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
binding.access = VK_ACCESS_UNIFORM_READ_BIT;
@ -883,13 +874,6 @@ namespace dxvk {
m_module.decorateBinding(varId, bindingId);
// Store descriptor info for the shader interface
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_SAMPLER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = 0;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_SAMPLER };
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
binding.resourceBinding = bindingId;
@ -1070,24 +1054,6 @@ namespace dxvk {
}
// Store descriptor info for the shader interface
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.view = typeInfo.vtype;
if (isUav) {
resource.type = resourceType == DxbcResourceDim::Buffer
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
: VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
resource.access = m_analysis->uavInfos[registerId].accessFlags;
} else {
resource.type = resourceType == DxbcResourceDim::Buffer
? VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
: VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
resource.access = VK_ACCESS_SHADER_READ_BIT;
}
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { };
binding.viewType = typeInfo.vtype;
binding.resourceBinding = bindingId;
@ -1235,20 +1201,6 @@ namespace dxvk {
}
// Store descriptor info for the shader interface
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = useRawSsbo
? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
: (isUav
? VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
: VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER);
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = isUav
? m_analysis->uavInfos[registerId].accessFlags
: VK_ACCESS_SHADER_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { };
binding.descriptorType = useRawSsbo
? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
@ -1498,14 +1450,6 @@ namespace dxvk {
m_module.decorateBinding(varId, bindingId);
// Declare the storage buffer binding
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_SHADER_READ_BIT
| VK_ACCESS_SHADER_WRITE_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_STORAGE_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;

View File

@ -424,7 +424,6 @@ namespace dxvk {
///////////////////////////////////////////////////////
// Resource slot description for the shader. This will
// be used to map D3D11 bindings to DXVK bindings.
std::vector<DxvkResourceSlot> m_resourceSlots;
std::vector<DxvkBindingInfo> m_bindings;
////////////////////////////////////////////////

View File

@ -250,8 +250,6 @@ namespace dxvk {
info.stage = m_programInfo.shaderStage();
info.bindingCount = m_bindings.size();
info.bindings = m_bindings.data();
info.resourceSlotCount = m_resourceSlots.size();
info.resourceSlots = m_resourceSlots.data();
info.inputMask = m_inputMask;
info.outputMask = m_outputMask;
info.pushConstOffset = m_pushConstOffset;
@ -332,13 +330,6 @@ namespace dxvk {
m_module.decorateDescriptorSet(m_cBuffer, 0);
m_module.decorateBinding(m_cBuffer, bindingId);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
@ -432,15 +423,6 @@ namespace dxvk {
if (asSsbo)
m_module.decorate(constantBufferId, spv::DecorationNonWritable);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = asSsbo
? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
: VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = asSsbo ? VK_ACCESS_MEMORY_READ_BIT : VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { };
binding.descriptorType = asSsbo
? VK_DESCRIPTOR_TYPE_STORAGE_BUFFER
@ -529,13 +511,6 @@ namespace dxvk {
m_module.decorateDescriptorSet(m_ps.sharedState, 0);
m_module.decorateBinding(m_ps.sharedState, bindingId);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
@ -877,13 +852,6 @@ namespace dxvk {
str::format("s", idx, "_bound").c_str());
// Store descriptor info for the shader interface
DxvkResourceSlot resource;
resource.slot = binding;
resource.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
resource.view = implicit ? VK_IMAGE_VIEW_TYPE_MAX_ENUM : viewType;
resource.access = VK_ACCESS_SHADER_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo bindingInfo = { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER };
bindingInfo.resourceBinding = binding;
bindingInfo.viewType = implicit ? VK_IMAGE_VIEW_TYPE_MAX_ENUM : viewType;
@ -3683,13 +3651,6 @@ void DxsoCompiler::emitControlFlowGenericLoop(
m_module.decorateDescriptorSet(clipPlaneBlock, 0);
m_module.decorateBinding (clipPlaneBlock, bindingId);
DxvkResourceSlot resource;
resource.slot = bindingId;
resource.type = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
resource.view = VK_IMAGE_VIEW_TYPE_MAX_ENUM;
resource.access = VK_ACCESS_UNIFORM_READ_BIT;
m_resourceSlots.push_back(resource);
DxvkBindingInfo binding = { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER };
binding.resourceBinding = bindingId;
binding.viewType = VK_IMAGE_VIEW_TYPE_MAX_ENUM;

View File

@ -277,7 +277,6 @@ namespace dxvk {
///////////////////////////////////////////////////////
// Resource slot description for the shader. This will
// be used to map D3D9 bindings to DXVK bindings.
std::vector<DxvkResourceSlot> m_resourceSlots;
std::vector<DxvkBindingInfo> m_bindings;
////////////////////////////////////////////////

View File

@ -338,193 +338,4 @@ namespace dxvk {
return flags;
}
DxvkDescriptorSlotMapping:: DxvkDescriptorSlotMapping() { }
DxvkDescriptorSlotMapping::~DxvkDescriptorSlotMapping() { }
void DxvkDescriptorSlotMapping::defineSlot(
VkShaderStageFlagBits stage,
const DxvkResourceSlot& desc) {
uint32_t bindingId = this->getBindingId(desc.slot);
if (bindingId != InvalidBinding) {
m_descriptorSlots[bindingId].stages |= stage;
m_descriptorSlots[bindingId].access |= desc.access;
} else {
DxvkDescriptorSlot slotInfo;
slotInfo.slot = desc.slot;
slotInfo.type = desc.type;
slotInfo.view = desc.view;
slotInfo.stages = stage;
slotInfo.access = desc.access;
m_descriptorSlots.push_back(slotInfo);
}
}
void DxvkDescriptorSlotMapping::definePushConstRange(
VkShaderStageFlagBits stage,
uint32_t offset,
uint32_t size) {
m_pushConstRange.stageFlags |= stage;
m_pushConstRange.size = std::max(
m_pushConstRange.size, offset + size);
}
uint32_t DxvkDescriptorSlotMapping::getBindingId(uint32_t slot) const {
// This won't win a performance competition, but the number
// of bindings used by a shader is usually much smaller than
// the number of resource slots available to the system.
for (uint32_t i = 0; i < m_descriptorSlots.size(); i++) {
if (m_descriptorSlots[i].slot == slot)
return i;
}
return InvalidBinding;
}
void DxvkDescriptorSlotMapping::makeDescriptorsDynamic(
uint32_t uniformBuffers,
uint32_t storageBuffers) {
if (this->countDescriptors(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) <= uniformBuffers)
this->replaceDescriptors(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC);
}
uint32_t DxvkDescriptorSlotMapping::countDescriptors(
VkDescriptorType type) const {
uint32_t count = 0;
for (const auto& slot : m_descriptorSlots)
count += slot.type == type ? 1 : 0;
return count;
}
void DxvkDescriptorSlotMapping::replaceDescriptors(
VkDescriptorType oldType,
VkDescriptorType newType) {
for (auto& slot : m_descriptorSlots) {
if (slot.type == oldType)
slot.type = newType;
}
}
DxvkPipelineLayout::DxvkPipelineLayout(
const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& slotMapping,
VkPipelineBindPoint pipelineBindPoint)
: m_vkd (vkd),
m_pushConstRange(slotMapping.pushConstRange()),
m_bindingSlots (slotMapping.bindingCount()) {
auto bindingCount = slotMapping.bindingCount();
auto bindingInfos = slotMapping.bindingInfos();
if (bindingCount > MaxNumActiveBindings)
throw DxvkError(str::format("Too many active bindings in pipeline layout (", bindingCount, ")"));
for (uint32_t i = 0; i < bindingCount; i++)
m_bindingSlots[i] = bindingInfos[i];
std::vector<VkDescriptorSetLayoutBinding> bindings(bindingCount);
std::vector<VkDescriptorUpdateTemplateEntry> tEntries(bindingCount);
for (uint32_t i = 0; i < bindingCount; i++) {
bindings[i].binding = i;
bindings[i].descriptorType = bindingInfos[i].type;
bindings[i].descriptorCount = 1;
bindings[i].stageFlags = bindingInfos[i].stages;
bindings[i].pImmutableSamplers = nullptr;
tEntries[i].dstBinding = i;
tEntries[i].dstArrayElement = 0;
tEntries[i].descriptorCount = 1;
tEntries[i].descriptorType = bindingInfos[i].type;
tEntries[i].offset = sizeof(DxvkDescriptorInfo) * i;
tEntries[i].stride = 0;
if (bindingInfos[i].type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)
m_dynamicSlots.push_back(i);
m_descriptorTypes.set(bindingInfos[i].type);
}
// Create descriptor set layout. We do not need to
// create one if there are no active resource bindings.
if (bindingCount > 0) {
VkDescriptorSetLayoutCreateInfo dsetInfo;
dsetInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
dsetInfo.pNext = nullptr;
dsetInfo.flags = 0;
dsetInfo.bindingCount = bindings.size();
dsetInfo.pBindings = bindings.data();
if (m_vkd->vkCreateDescriptorSetLayout(m_vkd->device(),
&dsetInfo, nullptr, &m_descriptorSetLayout) != VK_SUCCESS)
throw DxvkError("DxvkPipelineLayout: Failed to create descriptor set layout");
}
// Create pipeline layout with the given descriptor set layout
VkPipelineLayoutCreateInfo pipeInfo;
pipeInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
pipeInfo.pNext = nullptr;
pipeInfo.flags = 0;
pipeInfo.setLayoutCount = bindingCount > 0 ? 1 : 0;
pipeInfo.pSetLayouts = &m_descriptorSetLayout;
pipeInfo.pushConstantRangeCount = 0;
pipeInfo.pPushConstantRanges = nullptr;
if (m_pushConstRange.size) {
pipeInfo.pushConstantRangeCount = 1;
pipeInfo.pPushConstantRanges = &m_pushConstRange;
}
if (m_vkd->vkCreatePipelineLayout(m_vkd->device(),
&pipeInfo, nullptr, &m_pipelineLayout) != VK_SUCCESS) {
m_vkd->vkDestroyDescriptorSetLayout(m_vkd->device(), m_descriptorSetLayout, nullptr);
throw DxvkError("DxvkPipelineLayout: Failed to create pipeline layout");
}
// Create descriptor update template. If there are no active
// resource bindings, there won't be any descriptors to update.
if (bindingCount > 0) {
VkDescriptorUpdateTemplateCreateInfo templateInfo;
templateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO;
templateInfo.pNext = nullptr;
templateInfo.flags = 0;
templateInfo.descriptorUpdateEntryCount = tEntries.size();
templateInfo.pDescriptorUpdateEntries = tEntries.data();
templateInfo.templateType = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET;
templateInfo.descriptorSetLayout = m_descriptorSetLayout;
templateInfo.pipelineBindPoint = pipelineBindPoint;
templateInfo.pipelineLayout = m_pipelineLayout;
templateInfo.set = 0;
if (m_vkd->vkCreateDescriptorUpdateTemplate(
m_vkd->device(), &templateInfo, nullptr, &m_descriptorTemplate) != VK_SUCCESS) {
m_vkd->vkDestroyDescriptorSetLayout(m_vkd->device(), m_descriptorSetLayout, nullptr);
m_vkd->vkDestroyPipelineLayout(m_vkd->device(), m_pipelineLayout, nullptr);
throw DxvkError("DxvkPipelineLayout: Failed to create descriptor update template");
}
}
}
DxvkPipelineLayout::~DxvkPipelineLayout() {
m_vkd->vkDestroyDescriptorUpdateTemplate(
m_vkd->device(), m_descriptorTemplate, nullptr);
m_vkd->vkDestroyPipelineLayout(
m_vkd->device(), m_pipelineLayout, nullptr);
m_vkd->vkDestroyDescriptorSetLayout(
m_vkd->device(), m_descriptorSetLayout, nullptr);
}
}

View File

@ -546,278 +546,5 @@ namespace dxvk {
std::array<VkDescriptorSet, 2 * DxvkDescriptorSets::SetCount> m_sets;
};
/**
* \brief Resource slot
*
* Describes the type of a single resource
* binding that a shader can access.
*/
struct DxvkResourceSlot {
uint32_t slot;
VkDescriptorType type;
VkImageViewType view;
VkAccessFlags access;
};
/**
* \brief Shader interface binding
*
* Corresponds to a single descriptor binding in
* Vulkan. DXVK does not use descriptor arrays.
* Instead, each binding stores one descriptor.
*/
struct DxvkDescriptorSlot {
uint32_t slot; ///< Resource slot index for the context
VkDescriptorType type; ///< Descriptor type (aka resource type)
VkImageViewType view; ///< Compatible image view type
VkShaderStageFlags stages; ///< Stages that can use the resource
VkAccessFlags access; ///< Access flags
};
/**
* \brief Descriptor slot mapping
*
* Convenience class that generates descriptor slot
* index to binding index mappings. This is required
* when generating Vulkan pipeline and descriptor set
* layouts.
*/
class DxvkDescriptorSlotMapping {
constexpr static uint32_t InvalidBinding = 0xFFFFFFFFu;
public:
DxvkDescriptorSlotMapping();
~DxvkDescriptorSlotMapping();
/**
* \brief Number of descriptor bindings
* \returns Descriptor binding count
*/
uint32_t bindingCount() const {
return m_descriptorSlots.size();
}
/**
* \brief Descriptor binding infos
* \returns Descriptor binding infos
*/
const DxvkDescriptorSlot* bindingInfos() const {
return m_descriptorSlots.data();
}
/**
* \brief Push constant range
* \returns Push constant range
*/
VkPushConstantRange pushConstRange() const {
return m_pushConstRange;
}
/**
* \brief Defines a new slot
*
* Adds a slot to the mapping. If the slot is already
* defined by another shader stage, this will extend
* the stage mask by the given stage. Otherwise, an
* entirely new binding is added.
* \param [in] stage Shader stage
* \param [in] desc Slot description
*/
void defineSlot(
VkShaderStageFlagBits stage,
const DxvkResourceSlot& desc);
/**
* \brief Defines new push constant range
*
* \param [in] stage Shader stage
* \param [in] offset Range offset
* \param [in] size Range size
*/
void definePushConstRange(
VkShaderStageFlagBits stage,
uint32_t offset,
uint32_t size);
/**
* \brief Gets binding ID for a slot
*
* \param [in] slot Resource slot
* \returns Binding index, or \c InvalidBinding
*/
uint32_t getBindingId(
uint32_t slot) const;
/**
* \brief Makes static descriptors dynamic
*
* Replaces static uniform and storage buffer bindings by
* their dynamic equivalent if the number of bindings of
* the respective type lies within supported device limits.
* Using dynamic descriptor types may improve performance.
* \param [in] uniformBuffers Max number of uniform buffers
* \param [in] storageBuffers Max number of storage buffers
*/
void makeDescriptorsDynamic(
uint32_t uniformBuffers,
uint32_t storageBuffers);
private:
std::vector<DxvkDescriptorSlot> m_descriptorSlots;
VkPushConstantRange m_pushConstRange = { };
uint32_t countDescriptors(
VkDescriptorType type) const;
void replaceDescriptors(
VkDescriptorType oldType,
VkDescriptorType newType);
};
/**
* \brief Shader interface
*
* Describes shader resource bindings
* for a graphics or compute pipeline.
*/
class DxvkPipelineLayout : public RcObject {
public:
DxvkPipelineLayout(
const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& slotMapping,
VkPipelineBindPoint pipelineBindPoint);
~DxvkPipelineLayout();
/**
* \brief Number of resource bindings
* \returns Resource binding count
*/
uint32_t bindingCount() const {
return m_bindingSlots.size();
}
/**
* \brief Resource binding info
*
* \param [in] id Binding index
* \returns Resource binding info
*/
const DxvkDescriptorSlot& binding(uint32_t id) const {
return m_bindingSlots[id];
}
/**
* \brief Resource binding info
* \returns Resource binding info
*/
const DxvkDescriptorSlot* bindings() const {
return m_bindingSlots.data();
}
/**
* \brief Push constant range
* \returns Push constant range
*/
const VkPushConstantRange& pushConstRange() const {
return m_pushConstRange;
}
/**
* \brief Descriptor set layout handle
* \returns Descriptor set layout handle
*/
VkDescriptorSetLayout descriptorSetLayout() const {
return m_descriptorSetLayout;
}
/**
* \brief Pipeline layout handle
* \returns Pipeline layout handle
*/
VkPipelineLayout pipelineLayout() const {
return m_pipelineLayout;
}
/**
* \brief Descriptor update template
* \returns Descriptor update template
*/
VkDescriptorUpdateTemplateKHR descriptorTemplate() const {
return m_descriptorTemplate;
}
/**
* \brief Number of dynamic bindings
* \returns Dynamic binding count
*/
uint32_t dynamicBindingCount() const {
return m_dynamicSlots.size();
}
/**
* \brief Returns a dynamic binding
*
* \param [in] id Dynamic binding ID
* \returns Reference to that binding
*/
const DxvkDescriptorSlot& dynamicBinding(uint32_t id) const {
return this->binding(m_dynamicSlots[id]);
}
/**
* \brief Checks for static buffer bindings
*
* Returns \c true if there is at least one
* descriptor of the static uniform buffer
* type.
*/
bool hasStaticBufferBindings() const {
return m_descriptorTypes.test(
VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
}
/**
* \brief Checks whether buffers or images are written to
*
* It is assumed that storage images and buffers
* will be written to if they are present. Used
* for synchronization purposes.
* \param [in] stages Shader stages to check
*/
VkShaderStageFlags getStorageDescriptorStages() const {
VkShaderStageFlags stages = 0;
for (const auto& slot : m_bindingSlots) {
if (slot.access & VK_ACCESS_SHADER_WRITE_BIT)
stages |= slot.stages;
}
return stages;
}
private:
Rc<vk::DeviceFn> m_vkd;
VkPushConstantRange m_pushConstRange = { };
VkDescriptorSetLayout m_descriptorSetLayout = VK_NULL_HANDLE;
VkPipelineLayout m_pipelineLayout = VK_NULL_HANDLE;
VkDescriptorUpdateTemplateKHR m_descriptorTemplate = VK_NULL_HANDLE;
std::vector<DxvkDescriptorSlot> m_bindingSlots;
std::vector<uint32_t> m_dynamicSlots;
Flags<VkDescriptorType> m_descriptorTypes;
};
}

View File

@ -64,18 +64,10 @@ namespace dxvk {
const DxvkShaderCreateInfo& info,
SpirvCodeBuffer&& spirv)
: m_info(info), m_code(spirv) {
m_info.resourceSlots = nullptr;
m_info.uniformData = nullptr;
m_info.bindings = nullptr;
// Copy resource binding slot infos
if (info.resourceSlotCount) {
m_slots.resize(info.resourceSlotCount);
for (uint32_t i = 0; i < info.resourceSlotCount; i++)
m_slots[i] = info.resourceSlots[i];
m_info.resourceSlots = m_slots.data();
}
for (uint32_t i = 0; i < info.bindingCount; i++) {
DxvkBindingInfo binding = info.bindings[i];
binding.stages = info.stage;
@ -178,51 +170,6 @@ namespace dxvk {
}
void DxvkShader::defineResourceSlots(
DxvkDescriptorSlotMapping& mapping) const {
for (const auto& slot : m_slots)
mapping.defineSlot(m_info.stage, slot);
if (m_info.pushConstSize) {
mapping.definePushConstRange(m_info.stage,
m_info.pushConstOffset,
m_info.pushConstSize);
}
}
DxvkShaderModule DxvkShader::createShaderModule(
const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& mapping,
const DxvkShaderModuleCreateInfo& info) {
SpirvCodeBuffer spirvCode = m_code.decompress();
uint32_t* code = spirvCode.data();
// Remap resource binding IDs
for (const auto& info : m_bindingOffsets) {
uint32_t mappedBinding = mapping.getBindingId(info.bindingId);
code[info.bindingOffset] = mappedBinding;
if (info.constIdOffset)
code[info.constIdOffset] = mappedBinding;
if (code[info.setOffset])
code[info.setOffset] = 0;
}
// For dual-source blending we need to re-map
// location 1, index 0 to location 0, index 1
if (info.fsDualSrcBlend && m_o1IdxOffset && m_o1LocOffset)
std::swap(code[m_o1IdxOffset], code[m_o1LocOffset]);
// Replace undefined input variables with zero
for (uint32_t u : bit::BitMask(info.undefinedInputs))
eliminateInput(spirvCode, u);
return DxvkShaderModule(vkd, this, spirvCode);
}
DxvkShaderModule DxvkShader::createShaderModule(
const Rc<vk::DeviceFn>& vkd,
const DxvkBindingLayoutObjects* layout,

View File

@ -56,8 +56,6 @@ namespace dxvk {
/// Shader stage
VkShaderStageFlagBits stage;
/// Descriptor info
uint32_t resourceSlotCount = 0;
const DxvkResourceSlot* resourceSlots = nullptr;
uint32_t bindingCount = 0;
const DxvkBindingInfo* bindings = nullptr;
/// Input and output register mask
@ -127,30 +125,6 @@ namespace dxvk {
return m_bindings;
}
/**
* \brief Adds resource slots definitions to a mapping
*
* Used to generate the exact descriptor set layout when
* compiling a graphics or compute pipeline. Slot indices
* have to be mapped to actual binding numbers.
*/
void defineResourceSlots(
DxvkDescriptorSlotMapping& mapping) const;
/**
* \brief Creates a shader module
*
* Maps the binding slot numbers
* \param [in] vkd Vulkan device functions
* \param [in] mapping Resource slot mapping
* \param [in] info Module create info
* \returns The shader module
*/
DxvkShaderModule createShaderModule(
const Rc<vk::DeviceFn>& vkd,
const DxvkDescriptorSlotMapping& mapping,
const DxvkShaderModuleCreateInfo& info);
/**
* \brief Creates a shader module
*
@ -247,7 +221,6 @@ namespace dxvk {
size_t m_o1IdxOffset = 0;
size_t m_o1LocOffset = 0;
std::vector<DxvkResourceSlot> m_slots;
std::vector<char> m_uniformData;
std::vector<BindingOffsets> m_bindingOffsets;

View File

@ -323,11 +323,6 @@ namespace dxvk {
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, BindingIds::Gamma, VK_IMAGE_VIEW_TYPE_2D, 0, VK_ACCESS_SHADER_READ_BIT },
}};
const std::array<DxvkResourceSlot, 2> fsResourceSlots = {{
{ BindingIds::Image, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_IMAGE_VIEW_TYPE_2D },
{ BindingIds::Gamma, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_IMAGE_VIEW_TYPE_1D },
}};
DxvkShaderCreateInfo vsInfo;
vsInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vsInfo.outputMask = 0x1;
@ -337,8 +332,6 @@ namespace dxvk {
fsInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fsInfo.bindingCount = fsBindings.size();
fsInfo.bindings = fsBindings.data();
fsInfo.resourceSlotCount = fsResourceSlots.size();
fsInfo.resourceSlots = fsResourceSlots.data();
fsInfo.pushConstSize = sizeof(PresenterArgs);
fsInfo.inputMask = 0x1;
fsInfo.outputMask = 0x1;

View File

@ -168,21 +168,10 @@ namespace dxvk::hud {
{ VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 2, VK_IMAGE_VIEW_TYPE_MAX_ENUM, 0, VK_ACCESS_SHADER_READ_BIT },
}};
const std::array<DxvkResourceSlot, 2> vsResources = {{
{ 0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
{ 1, VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
}};
const std::array<DxvkResourceSlot, 1> fsResources = {{
{ 2, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_IMAGE_VIEW_TYPE_2D },
}};
DxvkShaderCreateInfo vsInfo;
vsInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vsInfo.bindingCount = vsBindings.size();
vsInfo.bindings = vsBindings.data();
vsInfo.resourceSlotCount = vsResources.size();
vsInfo.resourceSlots = vsResources.data();
vsInfo.outputMask = 0x3;
vsInfo.pushConstSize = sizeof(HudTextPushConstants);
result.vert = new DxvkShader(vsInfo, std::move(vsCode));
@ -191,8 +180,6 @@ namespace dxvk::hud {
fsInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fsInfo.bindingCount = fsBindings.size();
fsInfo.bindings = fsBindings.data();
fsInfo.resourceSlotCount = fsResources.size();
fsInfo.resourceSlots = fsResources.data();
fsInfo.inputMask = 0x3;
fsInfo.outputMask = 0x1;
result.frag = new DxvkShader(fsInfo, std::move(fsCode));
@ -211,10 +198,6 @@ namespace dxvk::hud {
{ VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 0, VK_IMAGE_VIEW_TYPE_MAX_ENUM, 0, VK_ACCESS_SHADER_READ_BIT },
}};
const std::array<DxvkResourceSlot, 1> fsResources = {{
{ 0, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, VK_IMAGE_VIEW_TYPE_MAX_ENUM },
}};
DxvkShaderCreateInfo vsInfo;
vsInfo.stage = VK_SHADER_STAGE_VERTEX_BIT;
vsInfo.outputMask = 0x1;
@ -225,8 +208,6 @@ namespace dxvk::hud {
fsInfo.stage = VK_SHADER_STAGE_FRAGMENT_BIT;
fsInfo.bindingCount = fsBindings.size();
fsInfo.bindings = fsBindings.data();
fsInfo.resourceSlotCount = fsResources.size();
fsInfo.resourceSlots = fsResources.data();
fsInfo.inputMask = 0x1;
fsInfo.outputMask = 0x1;
fsInfo.pushConstSize = sizeof(HudGraphPushConstants);