/ src / video_core / rasterizer_cache / texture_cube.h
texture_cube.h
 1  // Copyright 2023 Citra Emulator Project
 2  // Licensed under GPLv2 or any later version
 3  // Refer to the license.txt file included.
 4  
 5  #pragma once
 6  
 7  #include "common/hash.h"
 8  #include "video_core/pica/regs_texturing.h"
 9  #include "video_core/rasterizer_cache/slot_id.h"
10  
11  namespace VideoCore {
12  
13  struct TextureCube {
14      SurfaceId surface_id;
15      std::array<SurfaceId, 6> face_ids;
16      std::array<u64, 6> ticks;
17  };
18  
19  struct TextureCubeConfig {
20      PAddr px;
21      PAddr nx;
22      PAddr py;
23      PAddr ny;
24      PAddr pz;
25      PAddr nz;
26      u32 width;
27      u32 levels;
28      Pica::TexturingRegs::TextureFormat format;
29  
30      bool operator==(const TextureCubeConfig& rhs) const {
31          return std::memcmp(this, &rhs, sizeof(TextureCubeConfig)) == 0;
32      }
33  
34      bool operator!=(const TextureCubeConfig& rhs) const {
35          return std::memcmp(this, &rhs, sizeof(TextureCubeConfig)) != 0;
36      }
37  
38      const u64 Hash() const {
39          return Common::ComputeHash64(this, sizeof(TextureCubeConfig));
40      }
41  };
42  
43  } // namespace VideoCore
44  
45  namespace std {
46  template <>
47  struct hash<VideoCore::TextureCubeConfig> {
48      std::size_t operator()(const VideoCore::TextureCubeConfig& config) const noexcept {
49          return config.Hash();
50      }
51  };
52  } // namespace std