Overte C++ Documentation
Version.h
1 //
2 // Created by Bradley Austin Davis on 2018/10/29
3 //
4 // Copyright 2018 High Fidelity, Inc.
5 // Copyright 2024 Overte e.V.
6 //
7 // Distributed under the Apache License, Version 2.0.
8 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
9 //
10 // Contains parts of Vulkan Samples, Copyright (c) 2018, Sascha Willems, distributed on MIT License.
11 //
12 
13 #pragma once
14 
15 #include <cstdint>
16 #include <string>
17 #include <sstream>
18 
19 namespace vks {
20 
21  // Version information for Vulkan is stored in a single 32 bit integer
22  // with individual bits representing the major, minor and patch versions.
23  // The maximum possible major and minor version is 512 (look out nVidia)
24  // while the maximum possible patch version is 2048
25  struct Version {
26  Version() : vulkan_major(0), vulkan_minor(0), vulkan_patch(0) {
27  }
28  explicit Version(uint32_t version) : Version() {
29  *this = version;
30  }
31 
32  Version& operator =(uint32_t version) {
33  memcpy(this, &version, sizeof(uint32_t));
34  return *this;
35  }
36 
37  explicit operator uint32_t() const {
38  uint32_t result;
39  memcpy(&result, this, sizeof(uint32_t));
40  return result;
41  }
42 
43  std::string toString() const {
44  std::stringstream buffer;
45  buffer << vulkan_major << "." << vulkan_minor << "." << vulkan_patch;
46  return buffer.str();
47  }
48 
49  const uint32_t vulkan_major : 10;
50  const uint32_t vulkan_minor : 10;
51  const uint32_t vulkan_patch : 12;
52 
53  };
54 }