Allow for optional support for 3D and cubemaps with depth format

* These are not required to be supported and some drivers may not handle them,
  but on implementations where they are supported we need to support debugging
  them.
This commit is contained in:
baldurk
2023-01-12 18:00:00 +00:00
parent 5d801636ab
commit 8a6ee78c40
3 changed files with 64 additions and 25 deletions
+35 -7
View File
@@ -3330,10 +3330,6 @@ void VulkanReplay::TextureRendering::Init(WrappedVulkan *driver, VkDescriptorPoo
{
for(size_t type = 0; type < ARRAY_COUNT(types); type++)
{
// don't create 3D depth
if(formats[fmt] == VK_FORMAT_D16_UNORM && types[type] == VK_IMAGE_TYPE_3D)
continue;
// create 1x1 image of the right size
VkImageCreateInfo imInfo = {
VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
@@ -3354,12 +3350,40 @@ void VulkanReplay::TextureRendering::Init(WrappedVulkan *driver, VkDescriptorPoo
};
// make the 2D image cube-compatible for non-depth
if(type == 1 && formats[fmt] != VK_FORMAT_D16_UNORM)
if(type == 1)
{
imInfo.arrayLayers = 6;
imInfo.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
}
// some depth images might not be supported
if(formats[fmt] == VK_FORMAT_D16_UNORM)
{
VkImageFormatProperties props = {};
vkr = driver->vkGetPhysicalDeviceImageFormatProperties(
driver->GetPhysDev(), imInfo.format, imInfo.imageType, imInfo.tiling, imInfo.usage,
imInfo.flags, &props);
if(vkr != VK_SUCCESS)
{
if(type == 1)
{
// create non-cube compatible
imInfo.arrayLayers = 1;
imInfo.flags = 0;
DepthCubesSupported = false;
}
else
{
RDCLOG("Couldn't create image with format %s type %s and sample count %s",
ToStr(formats[fmt]).c_str(), ToStr(types[type]).c_str(),
ToStr(sampleCounts[type]).c_str());
continue;
}
}
}
vkr = driver->vkCreateImage(driver->GetDev(), &imInfo, NULL, &DummyImages[fmt][type]);
driver->CheckVkResult(vkr);
@@ -3462,8 +3486,12 @@ void VulkanReplay::TextureRendering::Init(WrappedVulkan *driver, VkDescriptorPoo
cube = true;
}
// don't create 3D depth or cubes
if(formats[fmt] == VK_FORMAT_D16_UNORM && (viewtypes[type] == VK_IMAGE_VIEW_TYPE_3D || cube))
// don't make cube views if cubes weren't supported for depth
if(formats[fmt] == VK_FORMAT_D16_UNORM && cube && !DepthCubesSupported)
continue;
// don't create views when we failed to make the images
if(DummyImages[fmt][imType] == VK_NULL_HANDLE)
continue;
VkImageViewCreateInfo viewInfo = {
+3
View File
@@ -448,6 +448,8 @@ public:
void CopyPixelForPixelHistory(VkCommandBuffer cmd, VkOffset2D offset, uint32_t sample,
uint32_t bufferOffset, VkFormat format, VkDescriptorSet descSet);
bool Depth3DSupported() { return m_TexRender.DummyImages[3][2] != VK_NULL_HANDLE; }
bool DepthCubeSupported() { return m_TexRender.DepthCubesSupported; }
private:
bool FetchShaderFeedback(uint32_t eventId);
void ClearFeedbackCache();
@@ -605,6 +607,7 @@ private:
VkSampler DummySampler = VK_NULL_HANDLE;
VkBuffer DummyBuffer = VK_NULL_HANDLE;
VkBufferView DummyBufferView[4] = {};
bool DepthCubesSupported = true;
std::map<ResourceId, TextureDisplayViews> TextureViews;
+26 -18
View File
@@ -1247,16 +1247,14 @@ public:
// reset descriptor sets to dummy state
if(depthTex)
{
// for depth not all descriptors are valid, in particular we skip 3D and cube
uint32_t resetIndex = 3;
rdcarray<VkWriteDescriptorSet> writes;
for(size_t i = 0; i < ARRAY_COUNT(m_DebugData.DummyWrites[resetIndex]); i++)
{
if(m_DebugData.DummyWrites[resetIndex][i].dstBinding != (uint32_t)ShaderDebugBind::Tex3D &&
m_DebugData.DummyWrites[resetIndex][i].dstBinding != (uint32_t)ShaderDebugBind::TexCube &&
m_DebugData.DummyWrites[resetIndex][i].dstBinding != (uint32_t)ShaderDebugBind::Buffer)
// not all textures may be supported for depth, so only update those that are valid
if(m_DebugData.DummyWrites[resetIndex][i].descriptorCount != 0)
writes.push_back(m_DebugData.DummyWrites[resetIndex][i]);
}
@@ -2374,8 +2372,13 @@ private:
{
rdcspv::StorageClass storageClass = rdcspv::StorageClass::UniformConstant;
if(depthTex && (i == (size_t)ShaderDebugBind::Tex3D || i == (size_t)ShaderDebugBind::TexCube))
continue;
if(depthTex)
{
if(i == (size_t)ShaderDebugBind::Tex3D && !m_pDriver->GetReplay()->Depth3DSupported())
continue;
else if(i == (size_t)ShaderDebugBind::TexCube && !m_pDriver->GetReplay()->DepthCubeSupported())
continue;
}
if(i == (size_t)ShaderDebugBind::Constants)
storageClass = rdcspv::StorageClass::Uniform;
@@ -2392,10 +2395,10 @@ private:
editor.SetName(bindVars[(size_t)ShaderDebugBind::Tex1D], "Tex1D");
editor.SetName(bindVars[(size_t)ShaderDebugBind::Tex2D], "Tex2D");
if(!depthTex)
if(bindVars[(size_t)ShaderDebugBind::Tex3D] != rdcspv::Id())
editor.SetName(bindVars[(size_t)ShaderDebugBind::Tex3D], "Tex3D");
editor.SetName(bindVars[(size_t)ShaderDebugBind::Tex2DMS], "Tex2DMS");
if(!depthTex)
if(bindVars[(size_t)ShaderDebugBind::TexCube] != rdcspv::Id())
editor.SetName(bindVars[(size_t)ShaderDebugBind::TexCube], "TexCube");
editor.SetName(bindVars[(size_t)ShaderDebugBind::Buffer], "Buffer");
editor.SetName(bindVars[(size_t)ShaderDebugBind::Sampler], "Sampler");
@@ -2575,7 +2578,7 @@ private:
if(i == sampIdx || i == (uint32_t)ShaderDebugBind::Constants)
continue;
if(depthTex && (i == (size_t)ShaderDebugBind::Tex3D || i == (size_t)ShaderDebugBind::TexCube))
if(bindVars[i] == rdcspv::Id())
continue;
rdcspv::ImageOperandsAndParamDatas imageOperandsWithOffsets;
@@ -2706,8 +2709,7 @@ private:
// VUID-StandaloneSpirv-OpImage-04777
// OpImage*Dref must not consume an image whose Dim is 3D
// also skip cube
if(i == (uint32_t)ShaderDebugBind::Tex3D || i == (uint32_t)ShaderDebugBind::TexCube)
if(i == (uint32_t)ShaderDebugBind::Tex3D)
depthTex = false;
// don't emit dref's for uint/sint textures
@@ -4834,6 +4836,9 @@ rdcarray<ShaderDebugState> VulkanReplay::ContinueDebug(ShaderDebugger *debugger)
{
for(size_t dim = 0; dim < ARRAY_COUNT(m_TexRender.DummyImageViews[0]); dim++)
{
if(m_TexRender.DummyImageViews[fmt][dim] == VK_NULL_HANDLE)
continue;
m_ShaderDebugData.DummyImageInfos[fmt][dim].imageLayout =
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
m_ShaderDebugData.DummyImageInfos[fmt][dim].imageView =
@@ -4857,13 +4862,16 @@ rdcarray<ShaderDebugState> VulkanReplay::ContinueDebug(ShaderDebugger *debugger)
m_ShaderDebugData.DummyWrites[fmt][5].dstSet = Unwrap(m_ShaderDebugData.DescSet);
m_ShaderDebugData.DummyWrites[fmt][5].pImageInfo = &m_ShaderDebugData.DummyImageInfos[fmt][5];
m_ShaderDebugData.DummyWrites[fmt][6].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
m_ShaderDebugData.DummyWrites[fmt][6].descriptorCount = 1;
m_ShaderDebugData.DummyWrites[fmt][6].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
m_ShaderDebugData.DummyWrites[fmt][6].dstBinding = (uint32_t)ShaderDebugBind::Buffer;
m_ShaderDebugData.DummyWrites[fmt][6].dstSet = Unwrap(m_ShaderDebugData.DescSet);
m_ShaderDebugData.DummyWrites[fmt][6].pTexelBufferView =
UnwrapPtr(m_TexRender.DummyBufferView[fmt]);
if(m_TexRender.DummyBufferView[fmt] != VK_NULL_HANDLE)
{
m_ShaderDebugData.DummyWrites[fmt][6].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
m_ShaderDebugData.DummyWrites[fmt][6].descriptorCount = 1;
m_ShaderDebugData.DummyWrites[fmt][6].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER;
m_ShaderDebugData.DummyWrites[fmt][6].dstBinding = (uint32_t)ShaderDebugBind::Buffer;
m_ShaderDebugData.DummyWrites[fmt][6].dstSet = Unwrap(m_ShaderDebugData.DescSet);
m_ShaderDebugData.DummyWrites[fmt][6].pTexelBufferView =
UnwrapPtr(m_TexRender.DummyBufferView[fmt]);
}
}
rdcarray<ShaderDebugState> ret = spvDebugger->ContinueDebug();