Add proper support for immutable samplers. Refs #260

This commit is contained in:
baldurk
2016-06-01 16:39:18 +02:00
parent a9d7ff60e2
commit 6c39971374
7 changed files with 30 additions and 4 deletions
+3 -1
View File
@@ -46,7 +46,8 @@ struct VulkanPipelineState
struct BindingElement
{
BindingElement()
: customSamplerName(false),
: immutableSampler(false),
customSamplerName(false),
baseMip(0),
baseLayer(0),
offset(0),
@@ -64,6 +65,7 @@ struct VulkanPipelineState
ResourceId view; // bufferview, imageview, attachmentview
ResourceId res; // buffer, image, attachment
ResourceId sampler;
bool32 immutableSampler;
rdctype::str SamplerName;
bool32 customSamplerName;
+2 -1
View File
@@ -732,6 +732,7 @@ void Serialiser::Serialise(
Serialise("", el.view);
Serialise("", el.res);
Serialise("", el.sampler);
Serialise("", el.immutableSampler);
Serialise("", el.SamplerName);
Serialise("", el.customSamplerName);
@@ -758,7 +759,7 @@ void Serialiser::Serialise(
Serialise("", el.border);
Serialise("", el.unnormalized);
SIZE_CHECK(VulkanPipelineState::Pipeline::DescriptorSet::DescriptorBinding::BindingElement, 240);
SIZE_CHECK(VulkanPipelineState::Pipeline::DescriptorSet::DescriptorBinding::BindingElement, 248);
};
template <>
+3 -1
View File
@@ -1443,7 +1443,9 @@ bool WrappedVulkan::Serialise_InitialState(ResourceId resid, WrappedVkRes *)
for(uint32_t d = 0; d < writes[i].descriptorCount; d++)
{
dstImage[d] = src[d].imageInfo;
valid &= (src[d].imageInfo.sampler != VK_NULL_HANDLE);
valid &= (src[d].imageInfo.sampler != VK_NULL_HANDLE) ||
(layout.bindings[j].immutableSampler &&
layout.bindings[j].immutableSampler[d] != ResourceId());
valid &= (src[d].imageInfo.imageView != VK_NULL_HANDLE);
}
writes[i].pImageInfo = dstImage;
+5
View File
@@ -3415,10 +3415,15 @@ void VulkanReplay::SavePipelineState()
layoutBind.descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)
{
if(layoutBind.immutableSampler)
{
dst.bindings[b].binds[a].sampler = layoutBind.immutableSampler[a];
dst.bindings[b].binds[a].immutableSampler = true;
}
else if(info[a].imageInfo.sampler != VK_NULL_HANDLE)
{
dst.bindings[b].binds[a].sampler =
rm->GetNonDispWrapper(info[a].imageInfo.sampler)->id;
}
if(dst.bindings[b].binds[a].sampler != ResourceId())
{
@@ -199,6 +199,19 @@ VkResult WrappedVulkan::vkCreateDescriptorSetLayout(VkDevice device,
record->descInfo = new DescriptorSetData();
record->descInfo->layout = new DescSetLayout();
record->descInfo->layout->Init(GetResourceManager(), m_CreationInfo, pCreateInfo);
for(uint32_t i = 0; i < pCreateInfo->bindingCount; i++)
{
bool usesSampler =
pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER ||
pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
if(usesSampler && pCreateInfo->pBindings[i].pImmutableSamplers != NULL)
{
for(uint32_t d = 0; d < pCreateInfo->pBindings[i].descriptorCount; d++)
record->AddParent(GetRecord(pCreateInfo->pBindings[i].pImmutableSamplers[d]));
}
}
}
else
{
@@ -55,6 +55,7 @@ namespace renderdoc
public ResourceId view;
public ResourceId res;
public ResourceId sampler;
public bool immutableSampler;
[CustomMarshalAs(CustomUnmanagedType.UTF8TemplatedString)]
public string SamplerName;
@@ -308,7 +308,9 @@ namespace renderdocui.Windows.PipelineState
lod += String.Format(" Bias {0}", descriptor.mipBias);
return new object[] {
"", bindset, slotname, "Sampler", descriptor.SamplerName,
"", bindset, slotname,
descriptor.immutableSampler ? "Immutable Sampler" : "Sampler",
descriptor.SamplerName,
addressing,
filter,
lod