MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / Share

Method Share

GTE/Graphics/DX11/DX11Engine.cpp:149–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

147}
148
149DX11GraphicsObject* DX11Engine::Share(std::shared_ptr<Texture2> const& texture, DX11Engine* engine)
150{
151 LogAssert(texture != nullptr && engine != nullptr, "Invalid input.");
152 LogAssert(texture->IsShared(), "The texture must allow sharing.");
153
154 DX11GraphicsObject* dxTexture = static_cast<DX11GraphicsObject*>(Get(texture));
155 if (dxTexture)
156 {
157 // The texture is already shared by 'this', so nothing to do.
158 return dxTexture;
159 }
160
161 dxTexture = static_cast<DX11GraphicsObject*>(engine->Get(texture));
162 if (dxTexture)
163 {
164 std::shared_ptr<DX11GraphicsObject> dxShared;
165 if (texture->GetType() == GT_TEXTURE2)
166 {
167 dxShared = std::make_shared<DX11Texture2>(mDevice, static_cast<DX11Texture2 const*>(dxTexture));
168 }
169 else if (texture->GetType() == GT_TEXTURE_RT)
170 {
171 dxShared = std::make_shared<DX11TextureRT>(mDevice, static_cast<DX11TextureRT const*>(dxTexture));
172 }
173 else // texture->GetType() == GT_TEXTURE_DS
174 {
175 dxShared = std::make_shared<DX11TextureDS>(mDevice, static_cast<DX11TextureDS const*>(dxTexture));
176 }
177 mGOMapMutex.lock();
178 mGOMap.insert(std::make_pair(texture.get(), dxShared));
179 mGOMapMutex.unlock();
180 return dxShared.get();
181 }
182
183 // The texture is not bound to 'engine'; create a new binding for 'this'.
184 return static_cast<DX11GraphicsObject*>(Bind(texture));
185}
186
187D3D11_MAPPED_SUBRESOURCE DX11Engine::MapForWrite(std::shared_ptr<Resource> const& resource, uint32_t sri)
188{

Callers

nothing calls this directly

Calls 3

IsSharedMethod · 0.80
GetMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected