2
0

Texture.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef LOVE_GRAPHICS_VULKAN_TEXTURE_H
  2. #define LOVE_GRAPHICS_VULKAN_TEXTURE_H
  3. #include "graphics/Texture.h"
  4. #include "graphics/Volatile.h"
  5. #include "vk_mem_alloc.h"
  6. #include <iostream>
  7. namespace love {
  8. namespace graphics {
  9. namespace vulkan {
  10. class Texture : public graphics::Texture, public Volatile {
  11. public:
  12. Texture(love::graphics::Graphics* gfx, const Settings& settings, const Slices* data);
  13. ~Texture();
  14. virtual bool loadVolatile() override;
  15. virtual void unloadVolatile() override;
  16. void copyFromBuffer(graphics::Buffer* source, size_t sourceoffset, int sourcewidth, size_t size, int slice, int mipmap, const Rect& rect) override { std::cout << "Texture::copyFromBuffer "; };
  17. void copyToBuffer(graphics::Buffer* dest, int slice, int mipmap, const Rect& rect, size_t destoffset, int destwidth, size_t size) override { std::cout << "Texture::copyToBuffer "; };
  18. ptrdiff_t getRenderTargetHandle() const override { std::cout << "Texture::getRenderTargetHandle "; return (ptrdiff_t)0; };
  19. ptrdiff_t getSamplerHandle() const override { std::cout << "Texture::getSamplerHandle "; return (ptrdiff_t)0; };
  20. void uploadByteData(PixelFormat pixelformat, const void* data, size_t size, int level, int slice, const Rect& r) override;
  21. void generateMipmapsInternal() override { std::cout << "Texture::generateMipmapsInternal "; };
  22. int getMSAA() const override { std::cout << "Texture::getMSAA "; return 0; };
  23. ptrdiff_t getHandle() const override { std::cout << "Texture::getHandle "; return (ptrdiff_t)textureImage; }
  24. VkImageView getImageView() const { return textureImageView; }
  25. VkSampler getSampler() const { return textureSampler; }
  26. private:
  27. void transitionImageLayout(VkImage, VkImageLayout oldLayout, VkImageLayout newLayout);
  28. void copyBufferToImage(VkBuffer, VkImage, const Rect&);
  29. void createTextureImageView();
  30. void createTextureSampler();
  31. graphics::Graphics* gfx;
  32. VkDevice device;
  33. VmaAllocator allocator;
  34. VkImage textureImage = VK_NULL_HANDLE;
  35. VmaAllocation textureImageAllocation;
  36. VkImageView textureImageView;
  37. VkSampler textureSampler;
  38. const Slices* data;
  39. };
  40. }
  41. }
  42. }
  43. #endif