NullTexture.cpp 3.8 KB

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