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