further fixes for removing global set
This commit is contained in:
parent
f596f78479
commit
23753dcc45
@ -35,12 +35,7 @@ alias DescSetLayout = VkDescriptorSetLayout;
|
|||||||
alias PipelineLayout = VkPipelineLayout;
|
alias PipelineLayout = VkPipelineLayout;
|
||||||
alias DescLayoutBinding = VkDescriptorSetLayoutBinding;
|
alias DescLayoutBinding = VkDescriptorSetLayoutBinding;
|
||||||
alias DescWrite = VkWriteDescriptorSet;
|
alias DescWrite = VkWriteDescriptorSet;
|
||||||
|
alias DescSet = VkDescriptorSet;
|
||||||
struct DescSet
|
|
||||||
{
|
|
||||||
VkDescriptorSet handle;
|
|
||||||
u32 dynamic_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool g_VLAYER_SUPPORT = false;
|
bool g_VLAYER_SUPPORT = false;
|
||||||
|
|
||||||
@ -521,8 +516,6 @@ struct Vulkan
|
|||||||
PipelineHandles[] pipeline_handles;
|
PipelineHandles[] pipeline_handles;
|
||||||
u32 pipeline_count;
|
u32 pipeline_count;
|
||||||
VkPipeline[FRAME_OVERLAP] last_pipelines;
|
VkPipeline[FRAME_OVERLAP] last_pipelines;
|
||||||
DescSetLayout global_set_layout;
|
|
||||||
DescSet global_set;
|
|
||||||
|
|
||||||
MappedBuffer!(u8) transfer_buf;
|
MappedBuffer!(u8) transfer_buf;
|
||||||
|
|
||||||
@ -606,7 +599,7 @@ CreateDescSetLayout(DescLayoutBinding[] bindings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DescSet
|
DescSet
|
||||||
AllocDescSet(DescSetLayout layout, u32 dynamic_count = 0)
|
AllocDescSet(DescSetLayout layout)
|
||||||
{
|
{
|
||||||
VkDescriptorSetAllocateInfo alloc_info = {
|
VkDescriptorSetAllocateInfo alloc_info = {
|
||||||
sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
sType: VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO,
|
||||||
@ -615,15 +608,15 @@ AllocDescSet(DescSetLayout layout, u32 dynamic_count = 0)
|
|||||||
descriptorPool: g_vk.active_pool,
|
descriptorPool: g_vk.active_pool,
|
||||||
};
|
};
|
||||||
|
|
||||||
DescSet set = { dynamic_count: dynamic_count };
|
DescSet set;
|
||||||
VkResult result = vkAllocateDescriptorSets(g_vk.device, &alloc_info, &set.handle);
|
VkResult result = vkAllocateDescriptorSets(g_vk.device, &alloc_info, &set);
|
||||||
if(result == VK_ERROR_OUT_OF_POOL_MEMORY || result == VK_ERROR_FRAGMENTED_POOL)
|
if(result == VK_ERROR_OUT_OF_POOL_MEMORY || result == VK_ERROR_FRAGMENTED_POOL)
|
||||||
{
|
{
|
||||||
PushDescriptorPool();
|
PushDescriptorPool();
|
||||||
|
|
||||||
alloc_info.descriptorPool = g_vk.active_pool;
|
alloc_info.descriptorPool = g_vk.active_pool;
|
||||||
|
|
||||||
result = vkAllocateDescriptorSets(g_vk.device, &alloc_info, &set.handle);
|
result = vkAllocateDescriptorSets(g_vk.device, &alloc_info, &set);
|
||||||
VkCheckA("vkAllocateDescriptorSets failure", result);
|
VkCheckA("vkAllocateDescriptorSets failure", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1515,45 +1508,16 @@ Bind(Pipeline pipeline_handle, DescSet[] sets, bool compute = false)
|
|||||||
BindPipeline(cmd, pipeline);
|
BindPipeline(cmd, pipeline);
|
||||||
|
|
||||||
u32[] offsets;
|
u32[] offsets;
|
||||||
if(g_vk.global_set.dynamic_count > 0)
|
|
||||||
{
|
|
||||||
offsets = Alloc!(u32)(g_vk.frame_arena, g_vk.global_set.dynamic_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
cmd,
|
cmd,
|
||||||
pipeline.type,
|
pipeline.type,
|
||||||
pipeline.layout,
|
pipeline.layout,
|
||||||
0,
|
0,
|
||||||
1,
|
cast(u32)sets.length,
|
||||||
&g_vk.global_set.handle,
|
sets.ptr,
|
||||||
cast(u32)offsets.length,
|
0,
|
||||||
offsets.ptr
|
null
|
||||||
);
|
|
||||||
|
|
||||||
u32 offset_count;
|
|
||||||
VkDescriptorSet[] handles = Alloc!(VkDescriptorSet)(g_vk.frame_arena, sets.length);
|
|
||||||
|
|
||||||
foreach(i, set; sets)
|
|
||||||
{
|
|
||||||
handles[i] = set.handle;
|
|
||||||
offset_count += set.dynamic_count;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(offset_count > 0)
|
|
||||||
{
|
|
||||||
offsets = Alloc!(u32)(g_vk.frame_arena, offset_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
|
||||||
cmd,
|
|
||||||
pipeline.type,
|
|
||||||
pipeline.layout,
|
|
||||||
1,
|
|
||||||
cast(u32)handles.length,
|
|
||||||
handles.ptr,
|
|
||||||
cast(u32)offsets.length,
|
|
||||||
offsets.ptr
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1576,37 +1540,15 @@ Bind(Pipeline pipeline_handle, DescSet set, bool compute = false)
|
|||||||
PipelineHandles* pipeline = g_vk.pipeline_handles.ptr + pipeline_handle;
|
PipelineHandles* pipeline = g_vk.pipeline_handles.ptr + pipeline_handle;
|
||||||
BindPipeline(cmd, pipeline);
|
BindPipeline(cmd, pipeline);
|
||||||
|
|
||||||
u32[] offsets;
|
|
||||||
if(g_vk.global_set.dynamic_count > 0)
|
|
||||||
{
|
|
||||||
offsets = Alloc!(u32)(g_vk.frame_arena, g_vk.global_set.dynamic_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
vkCmdBindDescriptorSets(
|
||||||
cmd,
|
cmd,
|
||||||
pipeline.type,
|
pipeline.type,
|
||||||
pipeline.layout,
|
pipeline.layout,
|
||||||
0,
|
0,
|
||||||
1,
|
1,
|
||||||
&g_vk.global_set.handle,
|
&set,
|
||||||
cast(u32)offsets.length,
|
0,
|
||||||
offsets.ptr
|
null
|
||||||
);
|
|
||||||
|
|
||||||
if(set.dynamic_count > 0)
|
|
||||||
{
|
|
||||||
offsets = Alloc!(u32)(g_vk.frame_arena, set.dynamic_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
vkCmdBindDescriptorSets(
|
|
||||||
cmd,
|
|
||||||
pipeline.type,
|
|
||||||
pipeline.layout,
|
|
||||||
1,
|
|
||||||
1,
|
|
||||||
&set.handle,
|
|
||||||
cast(u32)offsets.length,
|
|
||||||
offsets.ptr
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2089,7 +2031,7 @@ PrepareWrite(VkWriteDescriptorSet* write, DescSet set, Descriptor* desc)
|
|||||||
|
|
||||||
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
write.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
||||||
write.descriptorType = desc.type;
|
write.descriptorType = desc.type;
|
||||||
write.dstSet = set.handle;
|
write.dstSet = set;
|
||||||
write.dstBinding = desc.binding;
|
write.dstBinding = desc.binding;
|
||||||
write.descriptorCount = 1;
|
write.descriptorCount = 1;
|
||||||
write.dstArrayElement = desc.index;
|
write.dstArrayElement = desc.index;
|
||||||
@ -2163,7 +2105,7 @@ WriteConvDescriptor(Buffer* buf)
|
|||||||
|
|
||||||
VkWriteDescriptorSet write = {
|
VkWriteDescriptorSet write = {
|
||||||
sType: VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
sType: VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
dstSet: g_vk.conv_desc_set.handle,
|
dstSet: g_vk.conv_desc_set,
|
||||||
dstBinding: 1,
|
dstBinding: 1,
|
||||||
descriptorCount: 1,
|
descriptorCount: 1,
|
||||||
descriptorType: VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
descriptorType: VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
|
||||||
@ -2183,7 +2125,7 @@ WriteConvDescriptor(ImageView* view)
|
|||||||
|
|
||||||
VkWriteDescriptorSet write = {
|
VkWriteDescriptorSet write = {
|
||||||
sType: VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
sType: VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||||
dstSet: g_vk.conv_desc_set.handle,
|
dstSet: g_vk.conv_desc_set,
|
||||||
dstBinding: 0,
|
dstBinding: 0,
|
||||||
descriptorCount: 1,
|
descriptorCount: 1,
|
||||||
descriptorType: VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
descriptorType: VK_DESCRIPTOR_TYPE_STORAGE_IMAGE,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user