mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxvk] Moved descriptor set updates into DxvkContext
This commit is contained in:
parent
30eb43a284
commit
a875e045c5
@ -88,52 +88,6 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkCommandList::bindResourceDescriptors(
|
|
||||||
VkPipelineBindPoint pipeline,
|
|
||||||
VkPipelineLayout pipelineLayout,
|
|
||||||
VkDescriptorSetLayout descriptorLayout,
|
|
||||||
uint32_t descriptorCount,
|
|
||||||
const DxvkDescriptorSlot* descriptorSlots,
|
|
||||||
const DxvkDescriptorInfo* descriptorInfos,
|
|
||||||
const DxvkBindingState& bindingState) {
|
|
||||||
|
|
||||||
// Allocate a new descriptor set
|
|
||||||
VkDescriptorSet dset = m_descAlloc.alloc(descriptorLayout);
|
|
||||||
|
|
||||||
// Write data to the descriptor set
|
|
||||||
std::array<VkWriteDescriptorSet, MaxNumResourceSlots> descriptorWrites;
|
|
||||||
uint32_t writeId = 0;
|
|
||||||
|
|
||||||
for (uint32_t i = 0; i < descriptorCount; i++) {
|
|
||||||
if (bindingState.isBound(i)) {
|
|
||||||
auto& curr = descriptorWrites[writeId++];
|
|
||||||
auto& binding = descriptorSlots[i];
|
|
||||||
|
|
||||||
curr.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
|
||||||
curr.pNext = nullptr;
|
|
||||||
curr.dstSet = dset;
|
|
||||||
curr.dstBinding = i;
|
|
||||||
curr.dstArrayElement = 0;
|
|
||||||
curr.descriptorCount = 1;
|
|
||||||
curr.descriptorType = binding.type;
|
|
||||||
curr.pImageInfo = &descriptorInfos[i].image;
|
|
||||||
curr.pBufferInfo = &descriptorInfos[i].buffer;
|
|
||||||
curr.pTexelBufferView = &descriptorInfos[i].texelBuffer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_vkd->vkUpdateDescriptorSets(
|
|
||||||
m_vkd->device(), writeId,
|
|
||||||
descriptorWrites.data(),
|
|
||||||
0, nullptr);
|
|
||||||
|
|
||||||
// Bind descriptor set to the pipeline
|
|
||||||
m_vkd->vkCmdBindDescriptorSets(m_buffer,
|
|
||||||
pipeline, pipelineLayout, 0, 1,
|
|
||||||
&dset, 0, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DxvkStagingBufferSlice DxvkCommandList::stagedAlloc(VkDeviceSize size) {
|
DxvkStagingBufferSlice DxvkCommandList::stagedAlloc(VkDeviceSize size) {
|
||||||
return m_stagingAlloc.alloc(size);
|
return m_stagingAlloc.alloc(size);
|
||||||
}
|
}
|
||||||
|
@ -82,14 +82,19 @@ namespace dxvk {
|
|||||||
*/
|
*/
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void bindResourceDescriptors(
|
VkDescriptorSet allocateDescriptorSet(
|
||||||
VkPipelineBindPoint pipeline,
|
VkDescriptorSetLayout descriptorLayout) {
|
||||||
VkPipelineLayout pipelineLayout,
|
return m_descAlloc.alloc(descriptorLayout);
|
||||||
VkDescriptorSetLayout descriptorLayout,
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void updateDescriptorSet(
|
||||||
uint32_t descriptorCount,
|
uint32_t descriptorCount,
|
||||||
const DxvkDescriptorSlot* descriptorSlots,
|
const VkWriteDescriptorSet* descriptorWrites) {
|
||||||
const DxvkDescriptorInfo* descriptorInfos,
|
m_vkd->vkUpdateDescriptorSets(m_vkd->device(),
|
||||||
const DxvkBindingState& bindingState);
|
descriptorCount, descriptorWrites, 0, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmdBeginRenderPass(
|
void cmdBeginRenderPass(
|
||||||
const VkRenderPassBeginInfo* pRenderPassBegin,
|
const VkRenderPassBeginInfo* pRenderPassBegin,
|
||||||
@ -99,6 +104,16 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void cmdBindDescriptorSet(
|
||||||
|
VkPipelineBindPoint pipeline,
|
||||||
|
VkPipelineLayout pipelineLayout,
|
||||||
|
VkDescriptorSet descriptorSet) {
|
||||||
|
m_vkd->vkCmdBindDescriptorSets(m_buffer,
|
||||||
|
pipeline, pipelineLayout, 0, 1,
|
||||||
|
&descriptorSet, 0, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmdBindIndexBuffer(
|
void cmdBindIndexBuffer(
|
||||||
VkBuffer buffer,
|
VkBuffer buffer,
|
||||||
VkDeviceSize offset,
|
VkDeviceSize offset,
|
||||||
|
@ -1130,14 +1130,33 @@ namespace dxvk {
|
|||||||
VkPipelineBindPoint bindPoint,
|
VkPipelineBindPoint bindPoint,
|
||||||
const DxvkBindingState& bindingState,
|
const DxvkBindingState& bindingState,
|
||||||
const Rc<DxvkBindingLayout>& layout) {
|
const Rc<DxvkBindingLayout>& layout) {
|
||||||
m_cmd->bindResourceDescriptors(
|
std::array<VkWriteDescriptorSet, MaxNumResourceSlots> writes;
|
||||||
bindPoint,
|
|
||||||
layout->pipelineLayout(),
|
const VkDescriptorSet dset =
|
||||||
layout->descriptorSetLayout(),
|
m_cmd->allocateDescriptorSet(
|
||||||
layout->bindingCount(),
|
layout->descriptorSetLayout());
|
||||||
layout->bindings(),
|
|
||||||
m_descriptors.data(),
|
size_t writeId = 0;
|
||||||
bindingState);
|
|
||||||
|
for (uint32_t i = 0; i < layout->bindingCount(); i++) {
|
||||||
|
if (bindingState.isBound(i)) {
|
||||||
|
writes[writeId].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
|
writes[writeId].pNext = nullptr;
|
||||||
|
writes[writeId].dstSet = dset;
|
||||||
|
writes[writeId].dstBinding = i;
|
||||||
|
writes[writeId].dstArrayElement = 0;
|
||||||
|
writes[writeId].descriptorCount = 1;
|
||||||
|
writes[writeId].descriptorType = layout->binding(i).type;
|
||||||
|
writes[writeId].pImageInfo = &m_descriptors[i].image;
|
||||||
|
writes[writeId].pBufferInfo = &m_descriptors[i].buffer;
|
||||||
|
writes[writeId].pTexelBufferView = &m_descriptors[i].texelBuffer;
|
||||||
|
writeId++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_cmd->updateDescriptorSet(writeId, writes.data());
|
||||||
|
m_cmd->cmdBindDescriptorSet(bindPoint,
|
||||||
|
layout->pipelineLayout(), dset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user