Commit 8ffeadb6 by Sean Risser

Make Vk::Stringify return std::string

We want Vk::Stringify to return the numeric value passed to it when it's in release mode or when it fails to find the matching string. However, we can't do that if we return a char* because the char* will be a pointer to a point on the stack. Bug: b/139528538 Change-Id: I1bab741e7e7aceea44c6179b2159f8a55497d3e0 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38868Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarSean Risser <srisser@google.com> Presubmit-Ready: Sean Risser <srisser@google.com>
parent b64fbfec
...@@ -387,7 +387,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn ...@@ -387,7 +387,7 @@ GraphicsPipeline::GraphicsPipeline(const VkGraphicsPipelineCreateInfo* pCreateIn
} }
break; break;
default: default:
WARN("pCreateInfo->pRasterizationState->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType)); WARN("pCreateInfo->pRasterizationState->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
break; break;
} }
......
...@@ -77,7 +77,7 @@ RenderPass::RenderPass(const VkRenderPassCreateInfo* pCreateInfo, void* mem) : ...@@ -77,7 +77,7 @@ RenderPass::RenderPass(const VkRenderPassCreateInfo* pCreateInfo, void* mem) :
break; break;
} }
default: default:
WARN("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType)); WARN("pCreateInfo->pNext sType = %s", vk::Stringify(extensionCreateInfo->sType).c_str());
break; break;
} }
...@@ -221,4 +221,4 @@ void RenderPass::MarkFirstUse(int attachment, int subpass) ...@@ -221,4 +221,4 @@ void RenderPass::MarkFirstUse(int attachment, int subpass)
attachmentViewMasks[attachment] |= viewMasks[subpass]; attachmentViewMasks[attachment] |= viewMasks[subpass];
} }
} // namespace vk } // namespace vk
\ No newline at end of file
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace vk { namespace vk {
const char *Stringify(VkStructureType value) std::string Stringify(VkStructureType value)
{ {
#ifndef NDEBUG #ifndef NDEBUG
// Since C++ hasn't given us introspection on enums, we can't just "get" an // Since C++ hasn't given us introspection on enums, we can't just "get" an
...@@ -459,15 +459,15 @@ const char *Stringify(VkStructureType value) ...@@ -459,15 +459,15 @@ const char *Stringify(VkStructureType value)
auto it = strings.find(value); auto it = strings.find(value);
if (it != strings.end()) if (it != strings.end())
{ {
return it->second; return std::string(it->second);
} }
else else
{ {
WARN("Stringify(VkStructureType v) is out of date. Please update it to match vulkan/vulkan_core.h"); WARN("Stringify(VkStructureType v) is out of date. Please update it to match vulkan/vulkan_core.h");
return ""; return std::to_string(value);
} }
#else // if not debug: #else // if not debug:
return ""; return std::to_string(value);
#endif #endif
} }
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
namespace vk { namespace vk {
const char *Stringify(VkStructureType value); std::string Stringify(VkStructureType value);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment