Vulkan/Debug: Add Reference value type.

`vk::dbg::Reference` is a `vk::dbg::Value` that reads and writes from a value stored in memory.

Used for displaying variables.

Bug: b/145351270
Change-Id: I64146cb11b13267bef15d727af82a2256a9f25ce
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39881
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Presubmit-Ready: Ben Clayton <bclayton@google.com>
diff --git a/src/Vulkan/Debug/Value.hpp b/src/Vulkan/Debug/Value.hpp
index 132f818..15105c2 100644
--- a/src/Vulkan/Debug/Value.hpp
+++ b/src/Vulkan/Debug/Value.hpp
@@ -89,11 +89,57 @@
 	return &value;
 }
 
+// Reference is reference to a value in memory.
+template<typename T>
+class Reference : public Value
+{
+public:
+	inline Reference(T &ptr);
+	inline std::shared_ptr<Type> type() const override;
+	inline const void *get() const override;
+	inline bool set(void *ptr) override;
+
+private:
+	T &ref;
+};
+
+template<typename T>
+Reference<T>::Reference(T &ref)
+    : ref(ref)
+{
+}
+
+template<typename T>
+std::shared_ptr<Type> Reference<T>::type() const
+{
+	return TypeOf<T>::get();
+}
+
+template<typename T>
+const void *Reference<T>::get() const
+{
+	return &ref;
+}
+
+template<typename T>
+bool Reference<T>::set(void *ptr)
+{
+	ref = *reinterpret_cast<const T *>(ptr);
+	return true;
+}
+
 // make_constant() returns a shared_ptr to a Constant with the given value.
 template<typename T>
 inline std::shared_ptr<Constant<T>> make_constant(const T &value)
 {
-	return std::shared_ptr<Constant<T>>(new vk::dbg::Constant<T>(value));
+	return std::make_shared<Constant<T>>(value);
+}
+
+// make_reference() returns a shared_ptr to a Reference with the given value.
+template<typename T>
+inline std::shared_ptr<Reference<T>> make_reference(T &value)
+{
+	return std::make_shared<Reference<T>>(value);
 }
 
 }  // namespace dbg