NullGfx.cpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright 2015 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "VideoBackends/Null/NullGfx.h"
  4. #include "VideoBackends/Null/NullBoundingBox.h"
  5. #include "VideoBackends/Null/NullTexture.h"
  6. #include "VideoCommon/AbstractPipeline.h"
  7. #include "VideoCommon/AbstractShader.h"
  8. #include "VideoCommon/NativeVertexFormat.h"
  9. #include "VideoCommon/VideoConfig.h"
  10. namespace Null
  11. {
  12. // Init functions
  13. NullGfx::NullGfx()
  14. {
  15. UpdateActiveConfig();
  16. }
  17. NullGfx::~NullGfx()
  18. {
  19. UpdateActiveConfig();
  20. }
  21. bool NullGfx::IsHeadless() const
  22. {
  23. return true;
  24. }
  25. bool NullGfx::SupportsUtilityDrawing() const
  26. {
  27. return false;
  28. }
  29. std::unique_ptr<AbstractTexture> NullGfx::CreateTexture(const TextureConfig& config,
  30. [[maybe_unused]] std::string_view name)
  31. {
  32. return std::make_unique<NullTexture>(config);
  33. }
  34. std::unique_ptr<AbstractStagingTexture> NullGfx::CreateStagingTexture(StagingTextureType type,
  35. const TextureConfig& config)
  36. {
  37. return std::make_unique<NullStagingTexture>(type, config);
  38. }
  39. class NullShader final : public AbstractShader
  40. {
  41. public:
  42. explicit NullShader(ShaderStage stage) : AbstractShader(stage) {}
  43. };
  44. std::unique_ptr<AbstractShader>
  45. NullGfx::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source,
  46. [[maybe_unused]] std::string_view name)
  47. {
  48. return std::make_unique<NullShader>(stage);
  49. }
  50. std::unique_ptr<AbstractShader>
  51. NullGfx::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length,
  52. [[maybe_unused]] std::string_view name)
  53. {
  54. return std::make_unique<NullShader>(stage);
  55. }
  56. class NullPipeline final : public AbstractPipeline
  57. {
  58. };
  59. std::unique_ptr<AbstractPipeline> NullGfx::CreatePipeline(const AbstractPipelineConfig& config,
  60. const void* cache_data,
  61. size_t cache_data_length)
  62. {
  63. return std::make_unique<NullPipeline>();
  64. }
  65. std::unique_ptr<AbstractFramebuffer>
  66. NullGfx::CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment,
  67. std::vector<AbstractTexture*> additional_color_attachments)
  68. {
  69. return NullFramebuffer::Create(static_cast<NullTexture*>(color_attachment),
  70. static_cast<NullTexture*>(depth_attachment),
  71. std::move(additional_color_attachments));
  72. }
  73. std::unique_ptr<NativeVertexFormat>
  74. NullGfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
  75. {
  76. return std::make_unique<NativeVertexFormat>(vtx_decl);
  77. }
  78. NullRenderer::~NullRenderer() = default;
  79. } // namespace Null