mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-19 05:52:11 +01:00
[dxvk] Add push constant range info to shaders and pipeline layout
This commit is contained in:
parent
d5b2c2fd23
commit
8931013234
@ -32,6 +32,16 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
@ -81,7 +91,9 @@ namespace dxvk {
|
||||
const Rc<vk::DeviceFn>& vkd,
|
||||
const DxvkDescriptorSlotMapping& slotMapping,
|
||||
VkPipelineBindPoint pipelineBindPoint)
|
||||
: m_vkd(vkd), m_bindingSlots(slotMapping.bindingCount()) {
|
||||
: m_vkd (vkd),
|
||||
m_pushConstRange(slotMapping.pushConstRange()),
|
||||
m_bindingSlots (slotMapping.bindingCount()) {
|
||||
|
||||
auto bindingCount = slotMapping.bindingCount();
|
||||
auto bindingInfos = slotMapping.bindingInfos();
|
||||
@ -138,6 +150,11 @@ namespace dxvk {
|
||||
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);
|
||||
|
@ -66,6 +66,14 @@ namespace dxvk {
|
||||
return m_descriptorSlots.data();
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Push constant range
|
||||
* \returns Push constant range
|
||||
*/
|
||||
VkPushConstantRange pushConstRange() const {
|
||||
return m_pushConstRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Defines a new slot
|
||||
*
|
||||
@ -86,6 +94,18 @@ namespace dxvk {
|
||||
VkShaderStageFlagBits stage,
|
||||
VkAccessFlags access);
|
||||
|
||||
/**
|
||||
* \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
|
||||
*
|
||||
@ -112,6 +132,7 @@ namespace dxvk {
|
||||
private:
|
||||
|
||||
std::vector<DxvkDescriptorSlot> m_descriptorSlots;
|
||||
VkPushConstantRange m_pushConstRange = { };
|
||||
|
||||
uint32_t countDescriptors(
|
||||
VkDescriptorType type) const;
|
||||
@ -166,6 +187,14 @@ namespace dxvk {
|
||||
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
|
||||
@ -244,6 +273,7 @@ namespace dxvk {
|
||||
|
||||
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;
|
||||
|
@ -151,6 +151,12 @@ namespace dxvk {
|
||||
DxvkDescriptorSlotMapping& mapping) const {
|
||||
for (const auto& slot : m_slots)
|
||||
mapping.defineSlot(slot.slot, slot.type, slot.view, m_stage, slot.access);
|
||||
|
||||
if (m_interface.pushConstSize) {
|
||||
mapping.definePushConstRange(m_stage,
|
||||
m_interface.pushConstOffset,
|
||||
m_interface.pushConstSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -43,8 +43,10 @@ namespace dxvk {
|
||||
* purely for validation purposes.
|
||||
*/
|
||||
struct DxvkInterfaceSlots {
|
||||
uint32_t inputSlots = 0;
|
||||
uint32_t outputSlots = 0;
|
||||
uint32_t inputSlots = 0;
|
||||
uint32_t outputSlots = 0;
|
||||
uint32_t pushConstOffset = 0;
|
||||
uint32_t pushConstSize = 0;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user