GrVkTextureRenderTarget.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright 2015 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #ifndef GrVkTextureRenderTarget_DEFINED
  8. #define GrVkTextureRenderTarget_DEFINED
  9. #include "include/gpu/vk/GrVkTypes.h"
  10. #include "src/gpu/vk/GrVkRenderTarget.h"
  11. #include "src/gpu/vk/GrVkTexture.h"
  12. class GrVkGpu;
  13. #ifdef SK_BUILD_FOR_WIN
  14. // Windows gives bogus warnings about inheriting asTexture/asRenderTarget via dominance.
  15. #pragma warning(push)
  16. #pragma warning(disable: 4250)
  17. #endif
  18. class GrVkImageView;
  19. struct GrVkImageInfo;
  20. class GrVkTextureRenderTarget: public GrVkTexture, public GrVkRenderTarget {
  21. public:
  22. static sk_sp<GrVkTextureRenderTarget> MakeNewTextureRenderTarget(GrVkGpu*, SkBudgeted,
  23. const GrSurfaceDesc&,
  24. int sampleCnt,
  25. const GrVkImage::ImageDesc&,
  26. GrMipMapsStatus);
  27. static sk_sp<GrVkTextureRenderTarget> MakeWrappedTextureRenderTarget(GrVkGpu*,
  28. const GrSurfaceDesc&,
  29. int sampleCnt,
  30. GrWrapOwnership,
  31. GrWrapCacheable,
  32. const GrVkImageInfo&,
  33. sk_sp<GrVkImageLayout>);
  34. GrBackendFormat backendFormat() const override { return this->getBackendFormat(); }
  35. protected:
  36. void onAbandon() override {
  37. // In order to correctly handle calling texture idle procs, GrVkTexture must go first.
  38. GrVkTexture::onAbandon();
  39. GrVkRenderTarget::onAbandon();
  40. }
  41. void onRelease() override {
  42. // In order to correctly handle calling texture idle procs, GrVkTexture must go first.
  43. GrVkTexture::onRelease();
  44. GrVkRenderTarget::onRelease();
  45. }
  46. private:
  47. // MSAA, not-wrapped
  48. GrVkTextureRenderTarget(GrVkGpu* gpu,
  49. SkBudgeted budgeted,
  50. const GrSurfaceDesc& desc,
  51. int sampleCnt,
  52. const GrVkImageInfo& info,
  53. sk_sp<GrVkImageLayout> layout,
  54. const GrVkImageView* texView,
  55. const GrVkImageInfo& msaaInfo,
  56. sk_sp<GrVkImageLayout> msaaLayout,
  57. const GrVkImageView* colorAttachmentView,
  58. const GrVkImageView* resolveAttachmentView,
  59. GrMipMapsStatus);
  60. // non-MSAA, not-wrapped
  61. GrVkTextureRenderTarget(GrVkGpu* gpu,
  62. SkBudgeted budgeted,
  63. const GrSurfaceDesc& desc,
  64. const GrVkImageInfo& info,
  65. sk_sp<GrVkImageLayout> layout,
  66. const GrVkImageView* texView,
  67. const GrVkImageView* colorAttachmentView,
  68. GrMipMapsStatus);
  69. // MSAA, wrapped
  70. GrVkTextureRenderTarget(GrVkGpu* gpu,
  71. const GrSurfaceDesc& desc,
  72. int sampleCnt,
  73. const GrVkImageInfo& info,
  74. sk_sp<GrVkImageLayout> layout,
  75. const GrVkImageView* texView,
  76. const GrVkImageInfo& msaaInfo,
  77. sk_sp<GrVkImageLayout> msaaLayout,
  78. const GrVkImageView* colorAttachmentView,
  79. const GrVkImageView* resolveAttachmentView,
  80. GrMipMapsStatus,
  81. GrBackendObjectOwnership,
  82. GrWrapCacheable);
  83. // non-MSAA, wrapped
  84. GrVkTextureRenderTarget(GrVkGpu* gpu,
  85. const GrSurfaceDesc& desc,
  86. const GrVkImageInfo& info,
  87. sk_sp<GrVkImageLayout> layout,
  88. const GrVkImageView* texView,
  89. const GrVkImageView* colorAttachmentView,
  90. GrMipMapsStatus,
  91. GrBackendObjectOwnership,
  92. GrWrapCacheable);
  93. // GrGLRenderTarget accounts for the texture's memory and any MSAA renderbuffer's memory.
  94. size_t onGpuMemorySize() const override;
  95. // In Vulkan we call the release proc after we are finished with the underlying
  96. // GrVkImage::Resource object (which occurs after the GPU has finished all work on it).
  97. void onSetRelease(sk_sp<GrRefCntedCallback> releaseHelper) override {
  98. // Forward the release proc on to GrVkImage
  99. this->setResourceRelease(std::move(releaseHelper));
  100. }
  101. };
  102. #endif