| 1 | // Copyright 2017 Dolphin Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #include "VideoBackends/Null/NullTexture.h" |
| 5 | |
| 6 | namespace Null |
| 7 | { |
| 8 | NullTexture::NullTexture(const TextureConfig& tex_config) : AbstractTexture(tex_config) |
| 9 | { |
| 10 | } |
| 11 | |
| 12 | void NullTexture::CopyRectangleFromTexture(const AbstractTexture* src, |
| 13 | const MathUtil::Rectangle<int>& src_rect, u32 src_layer, |
| 14 | u32 src_level, const MathUtil::Rectangle<int>& dst_rect, |
| 15 | u32 dst_layer, u32 dst_level) |
| 16 | { |
| 17 | } |
| 18 | void NullTexture::ResolveFromTexture(const AbstractTexture* src, |
| 19 | const MathUtil::Rectangle<int>& rect, u32 layer, u32 level) |
| 20 | { |
| 21 | } |
| 22 | |
| 23 | void NullTexture::Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer, |
| 24 | size_t buffer_size, u32 layer) |
| 25 | { |
| 26 | } |
| 27 | |
| 28 | NullStagingTexture::NullStagingTexture(StagingTextureType type, const TextureConfig& config) |
| 29 | : AbstractStagingTexture(type, config) |
| 30 | { |
| 31 | m_texture_buf.resize(m_texel_size * config.width * config.height); |
| 32 | m_map_pointer = reinterpret_cast<char*>(m_texture_buf.data()); |
| 33 | m_map_stride = m_texel_size * config.width; |
| 34 | } |
| 35 | |
| 36 | NullStagingTexture::~NullStagingTexture() = default; |
| 37 | |
| 38 | void NullStagingTexture::CopyFromTexture(const AbstractTexture* src, |
| 39 | const MathUtil::Rectangle<int>& src_rect, u32 src_layer, |
| 40 | u32 src_level, const MathUtil::Rectangle<int>& dst_rect) |
| 41 | { |
| 42 | m_needs_flush = true; |
| 43 | } |
| 44 | |
| 45 | void NullStagingTexture::CopyToTexture(const MathUtil::Rectangle<int>& src_rect, |
| 46 | AbstractTexture* dst, |
| 47 | const MathUtil::Rectangle<int>& dst_rect, u32 dst_layer, |
| 48 | u32 dst_level) |
| 49 | { |
| 50 | m_needs_flush = true; |
| 51 | } |
| 52 | |
| 53 | bool NullStagingTexture::Map() |
| 54 | { |
| 55 | return true; |
| 56 | } |
| 57 | |
| 58 | void NullStagingTexture::Unmap() |
| 59 | { |
| 60 | } |
| 61 | |
| 62 | void NullStagingTexture::Flush() |
| 63 | { |
| 64 | m_needs_flush = false; |
| 65 | } |
| 66 | |
| 67 | NullFramebuffer::NullFramebuffer(AbstractTexture* color_attachment, |
| 68 | AbstractTexture* depth_attachment, |
| 69 | std::vector<AbstractTexture*> additional_color_attachments, |
| 70 | AbstractTextureFormat color_format, |
| 71 | AbstractTextureFormat depth_format, u32 width, u32 height, |
| 72 | u32 layers, u32 samples) |
| 73 | : AbstractFramebuffer(color_attachment, depth_attachment, |
| 74 | std::move(additional_color_attachments), color_format, depth_format, |
| 75 | width, height, layers, samples) |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | std::unique_ptr<NullFramebuffer> |
| 80 | NullFramebuffer::Create(NullTexture* color_attachment, NullTexture* depth_attachment, |
| 81 | std::vector<AbstractTexture*> additional_color_attachments) |
| 82 | { |
| 83 | if (!ValidateConfig(color_attachment, depth_attachment, additional_color_attachments)) |
| 84 | return nullptr; |
| 85 | |
| 86 | const AbstractTextureFormat color_format = |
| 87 | color_attachment ? color_attachment->GetFormat() : AbstractTextureFormat::Undefined; |
| 88 | const AbstractTextureFormat depth_format = |
| 89 | depth_attachment ? depth_attachment->GetFormat() : AbstractTextureFormat::Undefined; |
| 90 | const NullTexture* either_attachment = color_attachment ? color_attachment : depth_attachment; |
| 91 | const u32 width = either_attachment->GetWidth(); |
| 92 | const u32 height = either_attachment->GetHeight(); |
| 93 | const u32 layers = either_attachment->GetLayers(); |
| 94 | const u32 samples = either_attachment->GetSamples(); |
| 95 | |
| 96 | return std::make_unique<NullFramebuffer>(color_attachment, depth_attachment, |
| 97 | std::move(additional_color_attachments), color_format, |
| 98 | depth_format, width, height, layers, samples); |
| 99 | } |
| 100 | |
| 101 | } // namespace Null |