LeviLamina
Loading...
Searching...
No Matches
TextureGroup.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/client/model/models/AsyncCachedTextureLoader.h"
7#include "mc/client/renderer/ImageBufferResourceManager.h"
8#include "mc/client/renderer/ImageCacheMode.h"
9#include "mc/client/renderer/TextureLoadMode.h"
10#include "mc/deps/core/resource/ResourceLocation.h"
11#include "mc/deps/core/threading/Async.h"
12#include "mc/deps/core/threading/CountTracker.h"
13#include "mc/deps/core/threading/SharedAsync.h"
14#include "mc/deps/core/utility/EnableNonOwnerReferences.h"
15#include "mc/deps/core/utility/NonOwnerPointer.h"
16#include "mc/deps/core_graphics/ImageBuffer.h"
17#include "mc/deps/core_graphics/TextureSetLayerType.h"
18#include "mc/deps/minecraft_renderer/renderer/TextureGroupBase.h"
19#include "mc/resources/ResourceLoadType.h"
20#include "mc/util/texture_set_helpers/TextureSetDefinitionLoader.h"
21
22// auto generated forward declare list
23// clang-format off
24class BedrockTexture;
28namespace cg { class TextureSetDefinition; }
29namespace mce { class ImageResourceLoader; }
30namespace mce { class LRUCache; }
31namespace mce { class TextureContainer; }
32namespace mce { class TexturePtr; }
33namespace mce { struct TextureDescription; }
34namespace mce { struct TextureResourceService; }
35// clang-format on
36
37namespace mce {
38
39class TextureGroup : public ::Bedrock::EnableNonOwnerReferences, public ::mce::TextureGroupBase {
40public:
41 // TextureGroup inner types define
42 using LoadResult = ::Bedrock::Threading::Async<void>;
43
44 using TextureMap = ::std::map<::ResourceLocation, ::BedrockTexture>;
45
46 using TextureLoadKey = ::std::pair<::ResourceLocation, ::TextureLoadMode>;
47
48public:
49 // member variables
50 // NOLINTBEGIN
51 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IAdvancedGraphicsOptions>> mAdvancedGraphicsOptions;
52 ::ll::TypedStorage<8, 352, ::AsyncCachedTextureLoader> mAsyncTextureLoader;
53 ::ll::TypedStorage<8, 16, ::std::map<::ResourceLocation, ::BedrockTexture>> mLoadedTextures;
54 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::ResourceLoadManager>> mResourceLoadManager;
55 ::ll::TypedStorage<8, 8, ::mce::TextureResourceService&> mResourceService;
56 ::ll::TypedStorage<8, 48, ::cg::ImageBuffer const> mMissingTexture;
57 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::mce::ImageResourceLoader>> mImageResourceLoader;
58 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TextureSetHelpers::TextureSetDefinitionLoader::ResourceHelper>>
59 mTextureSetResourceHelper;
60 ::ll::TypedStorage<8, 16, ::std::map<::ResourceLocation, ::std::optional<uint>>> mTouchedTextures;
61 ::ll::TypedStorage<8, 16, ::ImageBufferResourceManager> mImageBufferCache;
62 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::mce::LRUCache>> mLRUCache;
63 ::ll::TypedStorage<
64 8,
65 16,
66 ::std::map<::std::pair<::ResourceLocation, ::TextureLoadMode>, ::Bedrock::Threading::SharedAsync<void>>>
67 mLoadQueueResults;
68 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::Async<void>> mQueueLoadResultCoroutine;
69 ::ll::TypedStorage<8, 16, ::Bedrock::Threading::CountTracker> mPendingLoadTaskCounter;
70 ::ll::TypedStorage<8, 8, ::std::atomic<uint64>> mOutstandingTaskMemory;
71 ::ll::TypedStorage<8, 8, ::std::atomic<uint64>> mOutstandingTaskCount;
72 // NOLINTEND
73
74public:
75 // prevent constructor by default
76 TextureGroup& operator=(TextureGroup const&);
77 TextureGroup(TextureGroup const&);
78 TextureGroup();
79
80public:
81 // virtual functions
82 // NOLINTBEGIN
83 virtual ~TextureGroup() /*override*/;
84
85 virtual ::mce::TexturePtr getTexture(
86 ::ResourceLocation const& resourceLocation,
87 bool const forceReload,
88 ::std::optional<uint> optLoadOrder,
89 ::cg::TextureSetLayerType const textureType
90 ) /*override*/;
91 // NOLINTEND
92
93public:
94 // member functions
95 // NOLINTBEGIN
96 MCAPI TextureGroup(
97 ::Bedrock::NotNullNonOwnerPtr<::IAdvancedGraphicsOptions> advancedGraphicsOptions,
98 ::Bedrock::NotNullNonOwnerPtr<::ResourceLoadManager> resourceLoadManager,
99 ::mce::TextureResourceService& textureResourceService
100 );
101
102 MCAPI TextureGroup(
103 ::Bedrock::NotNullNonOwnerPtr<::IAdvancedGraphicsOptions> advancedGraphicsOptions,
104 ::Bedrock::NotNullNonOwnerPtr<::ResourceLoadManager> resourceLoadManager,
105 ::mce::TextureResourceService& textureResourceService,
106 ::std::shared_ptr<::mce::ImageResourceLoader> imageResourceLoader
107 );
108
109 MCAPI void _loadTextureAsyncUrgentlyIfTouched(
110 ::std::pair<::ResourceLocation, ::TextureLoadMode> const& textureLoadKey,
111 ::std::optional<::ResourceLoadType> const optionalLoadType
112 );
113
114 MCAPI void _loadTexturesAsync(
115 ::gsl::span<::ResourceLocationPair> const locationPairs,
116 ::std::optional<::ResourceLoadType> const resourceLoadType
117 );
118
119 MCAPI void addEmptyTexture(::ResourceLocation const& resourceLocation, int width, int height);
120
121 MCAPI void enableLRUCache(uint64 cacheSize);
122
123 MCAPI uint64 estimateMemoryUsage() const;
124
125 MCAPI ::cg::ImageBuffer* getCachedImageOrLoadAsync(::ResourceLocation const& imageToLoad);
126
127 MCAPI ::cg::ImageBuffer* getCachedImageOrLoadSync(::ResourceLocation const& resourceLocation, bool forceReload);
128
129 MCAPI ::cg::ImageBuffer*
130 insertImageIntoCache(::ResourceLocation const& resourceLocation, ::cg::ImageBuffer&& imageBuffer);
131
132 MCAPI bool isLoaded(
133 ::ResourceLocation const& resourceLocation,
134 bool ignoreCreation,
135 ::cg::TextureSetLayerType textureType
136 ) const;
137
138 MCAPI ::nonstd::expected<void, ::std::error_condition>
139 loadImageSyncAndInsertIntoCache(::ResourceLocation const& resourceLocation, bool splitAsArray);
140
141 MCAPI ::Bedrock::Threading::Async<void> loadTextureAsync(
142 ::ResourceLocation const& resourceLocation,
143 ::TextureLoadMode textureLoadMode,
144 ::std::optional<::ResourceLoadType> resourceLoadType,
145 ::std::optional<uint> optLoadOrder
146 );
147
148 MCAPI void
149 loadTexturesAsync(::gsl::span<::ResourceLocation> locations, ::std::optional<::ResourceLoadType> resourceLoadType);
150
151 MCAPI void reloadAllTextures();
152
153 MCAPI void reloadImages(
154 ::gsl::span<::ResourceLocationPair> imagesToLoadAsync,
155 ::gsl::span<::ResourceLocation> imagesToImmediatelyLoad,
156 ::std::vector<::ResourceLocation> texturesToKeep,
157 ::ImageCacheMode
158 );
159
160 MCAPI void
161 setTextureMetadata(::ResourceLocation const& resourceLocation, ::mce::TextureDescription const& textureDescription);
162
163 MCAPI void setTextureMetadata(
164 ::ResourceLocation const& resourceLocation,
165 ::gsl::not_null<::std::shared_ptr<::cg::TextureSetDefinition>> textureSetDefinition
166 );
167
168 MCAPI bool shouldLoadPBRResources() const;
169
170 MCAPI void unloadAllTextures();
171
172 MCAPI bool unloadTexture(::ResourceLocation const& resourceLocation, bool assertOnFailure);
173
174 MCAPI bool updateTextureInPlace(::ResourceLocation const& resourceLocation, ::cg::ImageBuffer imageBuffer);
175
176 MCAPI ::BedrockTexture& uploadTexture(::ResourceLocation const& resourceLocation, ::cg::ImageBuffer imageBuffer);
177
178 MCAPI ::BedrockTexture& uploadTexture(
179 ::ResourceLocation const& resourceLocation,
180 ::gsl::not_null<::std::shared_ptr<::cg::TextureSetDefinition>> textureSetDefinition
181 );
182
183 MCAPI ::BedrockTexture& uploadTexture(
184 ::ResourceLocation const& resourceLocation,
185 ::mce::TextureContainer&& textureContainer,
186 ::std::string_view optionalIdentifier
187 );
188 // NOLINTEND
189
190public:
191 // constructor thunks
192 // NOLINTBEGIN
193 MCAPI void* $ctor(
194 ::Bedrock::NotNullNonOwnerPtr<::IAdvancedGraphicsOptions> advancedGraphicsOptions,
195 ::Bedrock::NotNullNonOwnerPtr<::ResourceLoadManager> resourceLoadManager,
196 ::mce::TextureResourceService& textureResourceService
197 );
198
199 MCAPI void* $ctor(
200 ::Bedrock::NotNullNonOwnerPtr<::IAdvancedGraphicsOptions> advancedGraphicsOptions,
201 ::Bedrock::NotNullNonOwnerPtr<::ResourceLoadManager> resourceLoadManager,
202 ::mce::TextureResourceService& textureResourceService,
203 ::std::shared_ptr<::mce::ImageResourceLoader> imageResourceLoader
204 );
205 // NOLINTEND
206
207public:
208 // destructor thunk
209 // NOLINTBEGIN
210 MCAPI void $dtor();
211 // NOLINTEND
212
213public:
214 // virtual function thunks
215 // NOLINTBEGIN
216 MCAPI ::mce::TexturePtr $getTexture(
217 ::ResourceLocation const& resourceLocation,
218 bool const forceReload,
219 ::std::optional<uint> optLoadOrder,
220 ::cg::TextureSetLayerType const textureType
221 );
222 // NOLINTEND
223};
224
225} // namespace mce
Definition BedrockTexture.h:5
Definition IAdvancedGraphicsOptions.h:10
Definition ResourceLoadManager.h:18
Definition ResourceLocationPair.h:9
Definition TextureSetDefinition.h:19
Definition ImageResourceLoader.h:19
Definition LRUCache.h:7
Definition TextureContainer.h:7
Definition TextureGroup.h:7
Definition TexturePtr.h:7
Definition TextureDescription.h:7
Definition TextureResourceService.h:7