8 #include "surfacedescriptor.h"
9 #include "renderutils.h"
12 #include <nap/resource.h>
13 #include <glm/glm.hpp>
14 #include <nap/numeric.h>
15 #include <rtti/factory.h>
16 #include <nap/signalslot.h>
52 virtual uint getLayerCount()
const = 0;
57 virtual uint getMipLevels()
const = 0;
62 virtual const ImageData& getHandle()
const = 0;
67 virtual VkImageLayout
getTargetLayout()
const {
return VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; };
92 virtual void onDestroy()
override { textureDestroyed(); }
108 virtual void clear(VkCommandBuffer commandBuffer);
117 VkFormat mFormat = VK_FORMAT_UNDEFINED;
118 VkClearColorValue mClearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
175 const glm::vec2
getSize()
const {
return { getWidth(), getHeight() }; }
180 int getWidth()
const {
return mDescriptor.mWidth; }
196 void update(
const void* data,
int width,
int height,
int pitch,
ESurfaceChannels channels);
226 void asyncGetData(
Bitmap& bitmap);
233 void asyncGetData(std::function<
void(
const void*,
size_t)> copyFunction);
235 EUsage mUsage = EUsage::Static;
257 void upload(VkCommandBuffer commandBuffer);
262 void download(VkCommandBuffer commandBuffer);
267 void notifyDownloadReady(
int frameIndex);
272 void clearDownloads();
278 int mCurrentStagingBufferIndex = -1;
279 size_t mImageSizeInBytes = -1;
304 static constexpr
const uint layerCount = 6;
324 const glm::vec2
getSize()
const {
return { getWidth(), getHeight() }; }
329 int getWidth()
const {
return mDescriptor.mWidth; }
362 const EUsage mUsage = EUsage::Static;
369 VkImageUsageFlags mImageUsageFlags = 0;
unsigned int uint
Definition: numeric.h:23
virtual bool init(utility::ErrorState &errorState)
Definition: object.h:46
virtual ImageData & getHandle() override
Definition: texture.h:241
virtual ~Texture()
Definition: texture.h:47
virtual uint getLayerCount() const override
Definition: texture.h:209
std::vector< BufferData > mStagingBuffers
All vulkan staging buffers, 1 when static or using dynamic read, no. of frames in flight when dynamic...
Definition: texture.h:277
Definition: texture.h:298
@ Static
Buffer data is uploaded only once from the CPU to the GPU.
@ DynamicRead
Buffer data is uploaded only once from the CPU to the GPU, and frequently read from GPU to CPU.
ImageData mImageData
2D Texture vulkan image buffers
Definition: texture.h:276
ESurfaceChannels
Definition: surfacedescriptor.h:26
const glm::vec2 getSize() const
Definition: texture.h:324
std::vector< int > mDownloadStagingBufferIndices
Staging buffer indices associated with a frameindex.
Definition: texture.h:281
const SurfaceDescriptor & getDescriptor() const
Definition: texture.h:77
virtual const ImageData & getHandle() const override
Definition: texture.h:354
EUsage
Definition: texture.h:36
RenderService & getRenderService()
Definition: texture.h:82
Definition: errorstate.h:19
nap::Signal textureDestroyed
Signal that is triggered before texture is destroyed.
Definition: texture.h:94
uint32_t uint32
Definition: numeric.h:20
Definition: texture.h:128
Definition: imagedata.h:23
Definition: signalslot.h:28
virtual VkImageLayout getTargetLayout() const
Definition: texture.h:67
Definition: surfacedescriptor.h:46
Definition: renderservice.h:275
VkFormat getFormat() const
Definition: texture.h:72
@ DynamicWrite
Buffer data is updated more than once from the CPU to the GPU.
std::function< void(void *data, size_t sizeInBytes)> TextureReadCallback
Definition: texture.h:274
VkImageUsageFlags getImageUsageFlags() const
Definition: texture.h:339
virtual void onDestroy() override
Definition: texture.h:92
virtual uint getMipLevels() const override
Definition: texture.h:214
RenderService & mRenderService
Reference to the render service.
Definition: texture.h:115
int getWidth() const
Definition: texture.h:180
int getWidth() const
Definition: texture.h:329
Definition: templateapp.h:17
const RenderService & getRenderService() const
Definition: texture.h:87
std::vector< TextureReadCallback > mReadCallbacks
Number of callbacks based on number of frames in flight.
Definition: texture.h:280
static constexpr const uint layerCount
Definition: texture.h:304
Definition: resource.h:19
virtual const ImageData & getHandle() const override
Definition: texture.h:219
virtual uint getMipLevels() const override
Definition: texture.h:349
int getHeight() const
Definition: texture.h:334
int getHeight() const
Definition: texture.h:185
const glm::vec2 getSize() const
Definition: texture.h:175
virtual ImageData & getHandle() override
Definition: texture.h:360
SurfaceDescriptor mDescriptor
Texture description.
Definition: texture.h:116
virtual uint getLayerCount() const override
Definition: texture.h:344