Plasma Engine  2.0
Loading...
Searching...
No Matches
Texture2DResource.h
1#pragma once
2
3#include <RendererCore/RendererCoreDLL.h>
4
5#include <Core/ResourceManager/Resource.h>
6#include <Core/ResourceManager/ResourceTypeLoader.h>
7#include <Foundation/IO/MemoryStream.h>
8#include <RendererCore/Pipeline/Declarations.h>
9#include <RendererCore/RenderContext/Implementation/RenderContextStructs.h>
10#include <RendererFoundation/Descriptors/Descriptors.h>
11#include <RendererFoundation/RendererFoundationDLL.h>
12
13class plImage;
14
16
18struct PL_RENDERERCORE_DLL plTexture2DResourceDescriptor
19{
23
25 plUInt8 m_uiQualityLevelsDiscardable = 0;
26
28 plUInt8 m_uiQualityLevelsLoadable = 0;
29
33};
34
35class PL_RENDERERCORE_DLL plTexture2DResource : public plResource
36{
37 PL_ADD_DYNAMIC_REFLECTION(plTexture2DResource, plResource);
38
39 PL_RESOURCE_DECLARE_COMMON_CODE(plTexture2DResource);
40 PL_RESOURCE_DECLARE_CREATEABLE(plTexture2DResource, plTexture2DResourceDescriptor);
41
42public:
44
45 PL_ALWAYS_INLINE plGALResourceFormat::Enum GetFormat() const { return m_Format; }
46 PL_ALWAYS_INLINE plUInt32 GetWidth() const { return m_uiWidth; }
47 PL_ALWAYS_INLINE plUInt32 GetHeight() const { return m_uiHeight; }
48 PL_ALWAYS_INLINE plGALTextureType::Enum GetType() const { return m_Type; }
49
50 static void FillOutDescriptor(plTexture2DResourceDescriptor& ref_td, const plImage* pImage, bool bSRGB, plUInt32 uiNumMipLevels,
51 plUInt32& out_uiMemoryUsed, plHybridArray<plGALSystemMemoryDescription, 32>& ref_initData);
52
53 const plGALTextureHandle& GetGALTexture() const { return m_hGALTexture[m_uiLoadedTextures - 1]; }
54 const plGALSamplerStateHandle& GetGALSamplerState() const { return m_hSamplerState; }
55
56protected:
57 virtual plResourceLoadDesc UnloadData(Unload WhatToUnload) override;
58 virtual plResourceLoadDesc UpdateContent(plStreamReader* Stream) override;
59 virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override;
60
61 plTexture2DResource(DoUpdate ResourceUpdateThread);
62
63 plUInt8 m_uiLoadedTextures = 0;
64 plGALTextureHandle m_hGALTexture[2];
65 plUInt32 m_uiMemoryGPU[2] = {0, 0};
66
67 plGALTextureType::Enum m_Type = plGALTextureType::Invalid;
68 plGALResourceFormat::Enum m_Format = plGALResourceFormat::Invalid;
69 plUInt32 m_uiWidth = 0;
70 plUInt32 m_uiHeight = 0;
71
72 plGALSamplerStateHandle m_hSamplerState;
73};
74
76
78
79struct PL_RENDERERCORE_DLL plRenderToTexture2DResourceDescriptor
80{
81 plUInt32 m_uiWidth = 0;
82 plUInt32 m_uiHeight = 0;
83 plEnum<plGALMSAASampleCount> m_SampleCount;
87};
88
89class PL_RENDERERCORE_DLL plRenderToTexture2DResource : public plTexture2DResource
90{
91 PL_ADD_DYNAMIC_REFLECTION(plRenderToTexture2DResource, plTexture2DResource);
92
93 PL_RESOURCE_DECLARE_COMMON_CODE(plRenderToTexture2DResource);
95
96public:
97 plGALRenderTargetViewHandle GetRenderTargetView() const;
98 void AddRenderView(plViewHandle hView);
99 void RemoveRenderView(plViewHandle hView);
100 const plDynamicArray<plViewHandle>& GetAllRenderViews() const;
101
102private:
103 virtual plResourceLoadDesc UnloadData(Unload WhatToUnload) override;
104 virtual plResourceLoadDesc UpdateContent(plStreamReader* Stream) override;
105 virtual void UpdateMemoryUsage(MemoryUsage& out_NewMemoryUsage) override;
106
107protected:
108 // other views that use this texture as their target
109 plDynamicArray<plViewHandle> m_RenderViews;
110};
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition DynamicArray.h:81
Definition RendererFoundationDLL.h:453
Definition RendererFoundationDLL.h:481
Definition RendererFoundationDLL.h:411
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
A class containing image data and associated meta data.
Definition Image.h:103
Definition Texture2DResource.h:90
The base class for all resources.
Definition Resource.h:10
Interface for binary in (read) streams.
Definition Stream.h:22
Definition Texture2DResource.h:36
Definition Declarations.h:64
A custom enum implementation that allows to define the underlying storage type to control its memory ...
Definition Enum.h:37
Definition Descriptors.h:118
Definition Descriptors.h:177
Definition Texture2DResource.h:80
Definition Resource.h:34
Describes in which loading state a resource currently is, and how many different quality levels there...
Definition Declarations.h:102
Use this descriptor in calls to plResourceManager::CreateResource<plTexture2DResource> to create text...
Definition Texture2DResource.h:19
plArrayPtr< plGALSystemMemoryDescription > m_InitialContent
Definition Texture2DResource.h:32
plGALTextureCreationDescription m_DescGAL
Describes the texture format, etc.
Definition Texture2DResource.h:21