mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-23 06:56:40 +00:00
Display swizzles on image views in vulkan pipeline view
This commit is contained in:
@@ -60,6 +60,10 @@ struct VulkanPipelineState
|
||||
borderEnable(false),
|
||||
unnormalized(false)
|
||||
{
|
||||
swizzle[0] = eSwizzle_Red;
|
||||
swizzle[1] = eSwizzle_Green;
|
||||
swizzle[2] = eSwizzle_Blue;
|
||||
swizzle[3] = eSwizzle_Alpha;
|
||||
}
|
||||
|
||||
ResourceId view; // bufferview, imageview, attachmentview
|
||||
@@ -72,6 +76,7 @@ struct VulkanPipelineState
|
||||
|
||||
// image views
|
||||
ResourceFormat viewfmt;
|
||||
TextureSwizzle swizzle[4];
|
||||
uint32_t baseMip;
|
||||
uint32_t baseLayer;
|
||||
|
||||
@@ -313,10 +318,18 @@ struct VulkanPipelineState
|
||||
|
||||
struct Attachment
|
||||
{
|
||||
Attachment() : baseMip(0), baseLayer(0)
|
||||
{
|
||||
swizzle[0] = eSwizzle_Red;
|
||||
swizzle[1] = eSwizzle_Green;
|
||||
swizzle[2] = eSwizzle_Blue;
|
||||
swizzle[3] = eSwizzle_Alpha;
|
||||
}
|
||||
ResourceId view;
|
||||
ResourceId img;
|
||||
|
||||
ResourceFormat viewfmt;
|
||||
TextureSwizzle swizzle[4];
|
||||
uint32_t baseMip;
|
||||
uint32_t baseLayer;
|
||||
};
|
||||
|
||||
@@ -739,6 +739,8 @@ void Serialiser::Serialise(
|
||||
Serialise("", el.SamplerName);
|
||||
Serialise("", el.customSamplerName);
|
||||
|
||||
Serialise("", el.viewfmt);
|
||||
SerialisePODArray<4>("", el.swizzle);
|
||||
Serialise("", el.baseMip);
|
||||
Serialise("", el.baseLayer);
|
||||
|
||||
@@ -761,7 +763,7 @@ void Serialiser::Serialise(
|
||||
Serialise("", el.border);
|
||||
Serialise("", el.unnormalized);
|
||||
|
||||
SIZE_CHECK(VulkanPipelineState::Pipeline::DescriptorSet::DescriptorBinding::BindingElement, 248);
|
||||
SIZE_CHECK(VulkanPipelineState::Pipeline::DescriptorSet::DescriptorBinding::BindingElement, 320);
|
||||
};
|
||||
|
||||
template <>
|
||||
@@ -1382,6 +1384,11 @@ string ToStrHelper<false, FormatComponentType>::Get(const FormatComponentType &e
|
||||
return "<...>";
|
||||
}
|
||||
template <>
|
||||
string ToStrHelper<false, TextureSwizzle>::Get(const TextureSwizzle &el)
|
||||
{
|
||||
return "<...>";
|
||||
}
|
||||
template <>
|
||||
string ToStrHelper<false, CounterUnits>::Get(const CounterUnits &el)
|
||||
{
|
||||
return "<...>";
|
||||
|
||||
@@ -519,12 +519,34 @@ void VulkanCreationInfo::Sampler::Init(VulkanResourceManager *resourceMan, Vulka
|
||||
unnormalizedCoordinates = pCreateInfo->unnormalizedCoordinates != 0;
|
||||
}
|
||||
|
||||
static TextureSwizzle Convert(VkComponentSwizzle s, int i)
|
||||
{
|
||||
switch(s)
|
||||
{
|
||||
default: RDCWARN("Unexpected component swizzle value %d", (int)s);
|
||||
case VK_COMPONENT_SWIZZLE_IDENTITY: break;
|
||||
case VK_COMPONENT_SWIZZLE_ZERO: return eSwizzle_Zero;
|
||||
case VK_COMPONENT_SWIZZLE_ONE: return eSwizzle_One;
|
||||
case VK_COMPONENT_SWIZZLE_R: return eSwizzle_Red;
|
||||
case VK_COMPONENT_SWIZZLE_G: return eSwizzle_Green;
|
||||
case VK_COMPONENT_SWIZZLE_B: return eSwizzle_Blue;
|
||||
case VK_COMPONENT_SWIZZLE_A: return eSwizzle_Alpha;
|
||||
}
|
||||
|
||||
return TextureSwizzle(eSwizzle_Red + i);
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::ImageView::Init(VulkanResourceManager *resourceMan, VulkanCreationInfo &info,
|
||||
const VkImageViewCreateInfo *pCreateInfo)
|
||||
{
|
||||
image = resourceMan->GetNonDispWrapper(pCreateInfo->image)->id;
|
||||
format = pCreateInfo->format;
|
||||
range = pCreateInfo->subresourceRange;
|
||||
|
||||
swizzle[0] = Convert(pCreateInfo->components.r, 0);
|
||||
swizzle[1] = Convert(pCreateInfo->components.g, 1);
|
||||
swizzle[2] = Convert(pCreateInfo->components.b, 2);
|
||||
swizzle[3] = Convert(pCreateInfo->components.a, 3);
|
||||
}
|
||||
|
||||
void VulkanCreationInfo::ShaderModule::Init(VulkanResourceManager *resourceMan,
|
||||
|
||||
@@ -313,6 +313,7 @@ struct VulkanCreationInfo
|
||||
ResourceId image;
|
||||
VkFormat format;
|
||||
VkImageSubresourceRange range;
|
||||
TextureSwizzle swizzle[4];
|
||||
};
|
||||
map<ResourceId, ImageView> m_ImageView;
|
||||
|
||||
|
||||
@@ -3396,6 +3396,9 @@ void VulkanReplay::SavePipelineState()
|
||||
c.m_ImageView[viewid].range.baseMipLevel;
|
||||
m_VulkanPipelineState.Pass.framebuffer.attachments[i].baseLayer =
|
||||
c.m_ImageView[viewid].range.baseArrayLayer;
|
||||
|
||||
memcpy(m_VulkanPipelineState.Pass.framebuffer.attachments[i].swizzle,
|
||||
c.m_ImageView[viewid].swizzle, sizeof(TextureSwizzle) * 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3567,6 +3570,9 @@ void VulkanReplay::SavePipelineState()
|
||||
dst.bindings[b].binds[a].view = rm->GetOriginalID(viewid);
|
||||
dst.bindings[b].binds[a].res = rm->GetOriginalID(c.m_ImageView[viewid].image);
|
||||
dst.bindings[b].binds[a].viewfmt = MakeResourceFormat(c.m_ImageView[viewid].format);
|
||||
|
||||
memcpy(dst.bindings[b].binds[a].swizzle, c.m_ImageView[viewid].swizzle,
|
||||
sizeof(TextureSwizzle) * 4);
|
||||
dst.bindings[b].binds[a].baseMip = c.m_ImageView[viewid].range.baseMipLevel;
|
||||
dst.bindings[b].binds[a].baseLayer = c.m_ImageView[viewid].range.baseArrayLayer;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,9 @@ namespace renderdoc
|
||||
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
|
||||
public ResourceFormat viewfmt;
|
||||
|
||||
[CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)]
|
||||
public TextureSwizzle[] swizzle;
|
||||
|
||||
public UInt32 baseMip;
|
||||
public UInt32 baseLayer;
|
||||
|
||||
@@ -376,6 +379,9 @@ namespace renderdoc
|
||||
[CustomMarshalAs(CustomUnmanagedType.CustomClass)]
|
||||
public ResourceFormat viewfmt;
|
||||
|
||||
[CustomMarshalAs(CustomUnmanagedType.FixedArray, FixedLength = 4)]
|
||||
public TextureSwizzle[] swizzle;
|
||||
|
||||
public UInt32 baseMip;
|
||||
public UInt32 baseArray;
|
||||
};
|
||||
|
||||
@@ -464,6 +464,8 @@ namespace renderdocui.Windows.PipelineState
|
||||
{
|
||||
name = "Object " + descriptorBind.res.ToString();
|
||||
|
||||
format = descriptorBind.viewfmt.ToString();
|
||||
|
||||
// check to see if it's a texture
|
||||
for (int t = 0; t < texs.Length; t++)
|
||||
{
|
||||
@@ -473,7 +475,6 @@ namespace renderdocui.Windows.PipelineState
|
||||
h = texs[t].height;
|
||||
d = texs[t].depth;
|
||||
a = texs[t].arraysize;
|
||||
format = texs[t].format.ToString();
|
||||
name = texs[t].name;
|
||||
restype = texs[t].resType;
|
||||
samples = texs[t].msSamp;
|
||||
@@ -492,7 +493,6 @@ namespace renderdocui.Windows.PipelineState
|
||||
h = 0;
|
||||
d = 0;
|
||||
a = 0;
|
||||
format = "";
|
||||
name = bufs[t].name;
|
||||
restype = ShaderResourceType.Buffer;
|
||||
|
||||
@@ -606,13 +606,29 @@ namespace renderdocui.Windows.PipelineState
|
||||
else
|
||||
dim = String.Format("{0}x{1}", w, h);
|
||||
|
||||
string arraydim = "-";
|
||||
string arraydim = "";
|
||||
|
||||
if (descriptorBind.swizzle[0] != TextureSwizzle.Red ||
|
||||
descriptorBind.swizzle[1] != TextureSwizzle.Green ||
|
||||
descriptorBind.swizzle[2] != TextureSwizzle.Blue ||
|
||||
descriptorBind.swizzle[3] != TextureSwizzle.Alpha)
|
||||
{
|
||||
arraydim = String.Format("swizzle[{0}{1}{2}{3}]",
|
||||
descriptorBind.swizzle[0].Str(),
|
||||
descriptorBind.swizzle[1].Str(),
|
||||
descriptorBind.swizzle[2].Str(),
|
||||
descriptorBind.swizzle[3].Str());
|
||||
}
|
||||
|
||||
if (restype == ShaderResourceType.Texture1DArray ||
|
||||
restype == ShaderResourceType.Texture2DArray ||
|
||||
restype == ShaderResourceType.Texture2DMSArray ||
|
||||
restype == ShaderResourceType.TextureCubeArray)
|
||||
{
|
||||
if (arraydim != "")
|
||||
arraydim += " ";
|
||||
arraydim = String.Format("{0}[{1}]", restype.Str(), a);
|
||||
}
|
||||
|
||||
if (restype == ShaderResourceType.Texture2DMS || restype == ShaderResourceType.Texture2DMSArray)
|
||||
dim += String.Format(", {0}x MSAA", samples);
|
||||
@@ -620,7 +636,7 @@ namespace renderdocui.Windows.PipelineState
|
||||
node = parentNodes.Add(new object[] {
|
||||
"", bindset, slotname, typename, name,
|
||||
dim,
|
||||
descriptorBind.viewfmt.ToString(),
|
||||
format,
|
||||
arraydim,
|
||||
});
|
||||
|
||||
@@ -1491,6 +1507,18 @@ namespace renderdocui.Windows.PipelineState
|
||||
}
|
||||
}
|
||||
|
||||
if (p.swizzle[0] != TextureSwizzle.Red ||
|
||||
p.swizzle[1] != TextureSwizzle.Green ||
|
||||
p.swizzle[2] != TextureSwizzle.Blue ||
|
||||
p.swizzle[3] != TextureSwizzle.Alpha)
|
||||
{
|
||||
format += String.Format(" swizzle[{0}{1}{2}{3}]",
|
||||
p.swizzle[0].Str(),
|
||||
p.swizzle[1].Str(),
|
||||
p.swizzle[2].Str(),
|
||||
p.swizzle[3].Str());
|
||||
}
|
||||
|
||||
var node = targetOutputs.Nodes.Add(new object[] { i, name, typename, w, h, d, a, format });
|
||||
|
||||
node.Image = global::renderdocui.Properties.Resources.action;
|
||||
|
||||
Reference in New Issue
Block a user