2017-04-23 04:44:34 +00:00
|
|
|
// 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"
|
2017-06-12 17:37:28 +00:00
|
|
|
|
|
|
|
enum class AbstractTextureFormat : u32
|
|
|
|
{
|
|
|
|
RGBA8,
|
2017-09-09 05:24:41 +00:00
|
|
|
BGRA8,
|
2017-06-12 17:37:28 +00:00
|
|
|
DXT1,
|
|
|
|
DXT3,
|
2017-07-27 12:00:04 +00:00
|
|
|
DXT5,
|
2017-09-09 05:24:41 +00:00
|
|
|
BPTC,
|
|
|
|
Undefined
|
2017-06-12 17:37:28 +00:00
|
|
|
};
|
2017-04-23 04:44:34 +00:00
|
|
|
|
2017-10-21 14:49:40 +00:00
|
|
|
enum class StagingTextureType
|
|
|
|
{
|
|
|
|
Readback, // Optimize for CPU reads, GPU writes, no CPU writes
|
|
|
|
Upload, // Optimize for CPU writes, GPU reads, no CPU reads
|
|
|
|
Mutable // Optimize for CPU reads, GPU writes, allow slow CPU reads
|
|
|
|
};
|
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
struct TextureConfig
|
|
|
|
{
|
|
|
|
constexpr TextureConfig() = default;
|
2017-09-30 06:25:36 +00:00
|
|
|
constexpr TextureConfig(u32 width_, u32 height_, u32 levels_, u32 layers_,
|
|
|
|
AbstractTextureFormat format_, bool rendertarget_)
|
|
|
|
: width(width_), height(height_), levels(levels_), layers(layers_), format(format_),
|
|
|
|
rendertarget(rendertarget_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
bool operator==(const TextureConfig& o) const;
|
2017-10-21 14:49:40 +00:00
|
|
|
bool operator!=(const TextureConfig& o) const;
|
2017-04-23 04:44:34 +00:00
|
|
|
MathUtil::Rectangle<int> GetRect() const;
|
2017-10-21 14:49:40 +00:00
|
|
|
MathUtil::Rectangle<int> GetMipRect(u32 level) const;
|
|
|
|
size_t GetStride() const;
|
|
|
|
size_t GetMipStride(u32 level) const;
|
2017-04-23 04:44:34 +00:00
|
|
|
|
|
|
|
u32 width = 0;
|
|
|
|
u32 height = 0;
|
|
|
|
u32 levels = 1;
|
|
|
|
u32 layers = 1;
|
2017-06-12 17:37:28 +00:00
|
|
|
AbstractTextureFormat format = AbstractTextureFormat::RGBA8;
|
2017-04-23 04:44:34 +00:00
|
|
|
bool rendertarget = false;
|
2017-10-09 00:15:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
template <>
|
|
|
|
struct hash<TextureConfig>
|
|
|
|
{
|
|
|
|
using argument_type = TextureConfig;
|
|
|
|
using result_type = size_t;
|
2017-04-23 04:44:34 +00:00
|
|
|
|
2017-10-09 00:15:34 +00:00
|
|
|
result_type operator()(const argument_type& c) const noexcept
|
2017-04-23 04:44:34 +00:00
|
|
|
{
|
2017-10-09 00:15:34 +00:00
|
|
|
const u64 id = static_cast<u64>(c.rendertarget) << 63 | static_cast<u64>(c.format) << 50 |
|
|
|
|
static_cast<u64>(c.layers) << 48 | static_cast<u64>(c.levels) << 32 |
|
|
|
|
static_cast<u64>(c.height) << 16 | static_cast<u64>(c.width);
|
|
|
|
return std::hash<u64>{}(id);
|
|
|
|
}
|
2017-04-23 04:44:34 +00:00
|
|
|
};
|
2017-10-09 00:15:34 +00:00
|
|
|
} // namespace std
|