2017-04-23 04:44:34 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-04-23 04:44:34 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-06-19 03:28:28 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
|
2017-04-23 04:44:34 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
#include "Common/MathUtil.h"
|
|
|
|
#include "VideoCommon/TextureConfig.h"
|
|
|
|
|
|
|
|
class AbstractTexture
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit AbstractTexture(const TextureConfig& c);
|
2018-01-26 08:32:33 +00:00
|
|
|
virtual ~AbstractTexture() = default;
|
2017-10-30 12:00:15 +00:00
|
|
|
|
2017-10-30 11:51:42 +00: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-21 05:03:06 +00:00
|
|
|
virtual void ResolveFromTexture(const AbstractTexture* src, const MathUtil::Rectangle<int>& rect,
|
|
|
|
u32 layer, u32 level) = 0;
|
2017-04-23 04:44:34 +00:00
|
|
|
virtual void Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer,
|
2023-01-28 00:46:53 +00:00
|
|
|
size_t buffer_size, u32 layer = 0) = 0;
|
2017-04-23 04:44:34 +00:00
|
|
|
|
2019-02-15 01:59:50 +00: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 14:28:34 +00: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-15 01:59:50 +00: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 14:28:34 +00:00
|
|
|
bool IsMultisampled() const { return m_config.IsMultisampled(); }
|
2023-11-16 07:23:59 +00:00
|
|
|
bool Save(const std::string& filename, unsigned int level, int compression = 6) const;
|
2017-10-30 12:00:15 +00:00
|
|
|
|
2017-10-21 14:49:40 +00:00
|
|
|
static bool IsCompressedFormat(AbstractTextureFormat format);
|
2018-01-21 13:59:19 +00:00
|
|
|
static bool IsDepthFormat(AbstractTextureFormat format);
|
2018-01-21 10:22:45 +00:00
|
|
|
static bool IsStencilFormat(AbstractTextureFormat format);
|
2019-07-31 05:33:27 +00:00
|
|
|
static bool IsCompatibleDepthAndColorFormats(AbstractTextureFormat depth_format,
|
|
|
|
AbstractTextureFormat color_format);
|
2019-02-15 01:59:50 +00:00
|
|
|
static u32 CalculateStrideForFormat(AbstractTextureFormat format, u32 row_length);
|
|
|
|
static u32 GetTexelSizeForFormat(AbstractTextureFormat format);
|
|
|
|
static u32 GetBlockSizeForFormat(AbstractTextureFormat format);
|
2017-04-23 04:44:34 +00:00
|
|
|
|
2017-06-19 03:33:15 +00:00
|
|
|
const TextureConfig& GetConfig() const;
|
2017-04-23 04:44:34 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
const TextureConfig m_config;
|
|
|
|
};
|