[llvm] [DX] Support pipeline state masks (PR #66425)

Chris B via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 07:59:22 PDT 2023


================
@@ -140,6 +159,22 @@ class PSVRuntimeInfo {
 
   const InfoStruct &getInfo() const { return BasicInfo; }
 
+  template <typename T> const T *getInfoAs() const {
+    if (const auto *P = std::get_if<dxbc::PSV::v2::RuntimeInfo>(&BasicInfo))
----------------
llvm-beanz wrote:

This is useful for cases where you want to read a field from the `v0` or `v1` data, but you don't actually care if the underlying data is a different version. You can see it in use in the `usesViewID()` method. That bit is part of the `v1` structure, so I want to return its value for `v1` or `v2` and return `false` for `v0`.

This helper allows me to not need to replicate the `std::get_if` blocks throughout the class, and since `std::is_same` will be compile-time resolved, the instantiations should be stripped down based on the statically resolvable structure versions.

https://github.com/llvm/llvm-project/pull/66425


More information about the llvm-commits mailing list