summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/TextureConfig.h
blob: 27a0c935a1389b3b398765e305b86f6e6918aa45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright 2017 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.

#pragma once

#include <cstddef>
#include <functional>

#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"

enum class AbstractTextureFormat : u32
{
  RGBA8,
  DXT1,
  DXT3,
  DXT5
};

struct TextureConfig
{
  constexpr TextureConfig() = default;
  bool operator==(const TextureConfig& o) const;
  MathUtil::Rectangle<int> GetRect() const;

  u32 width = 0;
  u32 height = 0;
  u32 levels = 1;
  u32 layers = 1;
  AbstractTextureFormat format = AbstractTextureFormat::RGBA8;
  bool rendertarget = false;

  struct Hasher : std::hash<u64>
  {
    size_t operator()(const TextureConfig& c) const
    {
      u64 id = (u64)c.rendertarget << 63 | (u64)c.format << 50 | (u64)c.layers << 48 |
               (u64)c.levels << 32 | (u64)c.height << 16 | (u64)c.width;
      return std::hash<u64>::operator()(id);
    }
  };
};