2017-04-22 22:44:34 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-06-18 21:28:28 -06:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
|
2017-04-22 22:44:34 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "Common/MathUtil.h"
|
|
|
|
#include "VideoCommon/TextureConfig.h"
|
|
|
|
|
|
|
|
class AbstractTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AbstractTexture(const TextureConfig& c);
|
2018-01-26 01:32:33 -07:00
|
|
|
virtual ~AbstractTexture() = default;
|
2017-10-30 06:00:15 -06:00
|
|
|
|
2017-10-30 05:51:42 -06:00
|
|
|
virtual void CopyRectangleFromTexture(const AbstractTexture* src,
|
|
|
|
const MathUtil::Rectangle<int>& src_rect, u32 src_layer,
|
|
|
|
u32 src_level, const MathUtil::Rectangle<int>& dst_rect,
|
|
|
|
u32 dst_layer, u32 dst_level) = 0;
|
2018-01-20 22:03:06 -07:00
|
|
|
virtual void ResolveFromTexture(const AbstractTexture* src, const MathUtil::Rectangle<int>& rect,
|
|
|
|
u32 layer, u32 level) = 0;
|
2017-04-22 22:44:34 -06:00
|
|
|
virtual void Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer,
|
|
|
|
size_t buffer_size) = 0;
|
|
|
|
|
2019-02-14 18:59:50 -07:00
|
|
|
// Hints to the backend that we have finished rendering to this texture, and it will be used
|
|
|
|
// as a shader resource and sampled. For Vulkan, this transitions the image layout.
|
|
|
|
virtual void FinishedRendering();
|
|
|
|
|
2018-01-21 07:28:34 -07:00
|
|
|
u32 GetWidth() const { return m_config.width; }
|
|
|
|
u32 GetHeight() const { return m_config.height; }
|
|
|
|
u32 GetLevels() const { return m_config.levels; }
|
|
|
|
u32 GetLayers() const { return m_config.layers; }
|
|
|
|
u32 GetSamples() const { return m_config.samples; }
|
|
|
|
AbstractTextureFormat GetFormat() const { return m_config.format; }
|
2019-02-14 18:59:50 -07:00
|
|
|
MathUtil::Rectangle<int> GetRect() const { return m_config.GetRect(); }
|
|
|
|
MathUtil::Rectangle<int> GetMipRect(u32 level) const { return m_config.GetMipRect(level); }
|
2018-01-21 07:28:34 -07:00
|
|
|
bool IsMultisampled() const { return m_config.IsMultisampled(); }
|
2017-10-30 06:00:15 -06:00
|
|
|
bool Save(const std::string& filename, unsigned int level);
|
|
|
|
|
2017-10-21 08:49:40 -06:00
|
|
|
static bool IsCompressedFormat(AbstractTextureFormat format);
|
2018-01-21 06:59:19 -07:00
|
|
|
static bool IsDepthFormat(AbstractTextureFormat format);
|
2018-01-21 03:22:45 -07:00
|
|
|
static bool IsStencilFormat(AbstractTextureFormat format);
|
2019-02-14 18:59:50 -07:00
|
|
|
static AbstractTextureFormat GetColorFormatForDepthFormat(AbstractTextureFormat format);
|
|
|
|
static u32 CalculateStrideForFormat(AbstractTextureFormat format, u32 row_length);
|
|
|
|
static u32 GetTexelSizeForFormat(AbstractTextureFormat format);
|
|
|
|
static u32 GetBlockSizeForFormat(AbstractTextureFormat format);
|
2017-04-22 22:44:34 -06:00
|
|
|
|
2017-06-18 21:33:15 -06:00
|
|
|
const TextureConfig& GetConfig() const;
|
2017-04-22 22:44:34 -06:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const TextureConfig m_config;
|
|
|
|
};
|