void FSlateRHIRenderingPolicy::ReleaseResources() { for( int32 BufferIndex = 0; BufferIndex < 2; ++BufferIndex ) { BeginReleaseResource(&VertexBuffers[BufferIndex]); BeginReleaseResource(&IndexBuffers[BufferIndex]); } }
/** Invalidates the light's cached lighting with the option to recreate the light Guids. */ void ULightComponent::InvalidateLightingCacheInner(bool bRecreateLightGuids) { // Save the light state for transactions. Modify(); // Detach the component from the scene for the duration of this function. FComponentReregisterContext ReregisterContext(this); // Block until the RT processes the unregister before modifying variables that it may need to access FlushRenderingCommands(); StaticShadowDepthMap.Empty(); BeginReleaseResource(&StaticShadowDepthMap); bPrecomputedLightingIsValid = false; if (bRecreateLightGuids) { // Create new guids for light. UpdateLightGUIDs(); } else { ValidateLightGUIDs(); ShadowMapChannel = INDEX_NONE; } // Send to render thread MarkRenderStateDirty(); }
bool UTexture::IsReadyForFinishDestroy() { bool bReadyForFinishDestroy = false; // Check whether super class is ready and whether we have any pending streaming requests in flight. if( Super::IsReadyForFinishDestroy() && !UpdateStreamingStatus() ) { // Kick off async resource release if we haven't already. if( !bAsyncResourceReleaseHasBeenStarted && (Resource || TextureReference.IsInitialized_GameThread()) ) { // Send the rendering thread a release message for the texture's resource. if (Resource) { BeginReleaseResource(Resource); } if (TextureReference.IsInitialized_GameThread()) { TextureReference.BeginRelease_GameThread(); } ReleaseFence.BeginFence(); // Keep track that we already kicked off the async release. bAsyncResourceReleaseHasBeenStarted = true; } // Only allow FinishDestroy to be called once the texture resource has finished its rendering thread cleanup. if( !bAsyncResourceReleaseHasBeenStarted || ReleaseFence.IsFenceComplete() ) { bReadyForFinishDestroy = true; } } return bReadyForFinishDestroy; }
FTileItemThumbnail::~FTileItemThumbnail() { BeginReleaseResource(ThumbnailTexture); // Wait for all resources to be released FlushRenderingCommands(); delete ThumbnailTexture; ThumbnailTexture = NULL; }
void ULightComponent::BeginDestroy() { Super::BeginDestroy(); BeginReleaseResource(&StaticShadowDepthMap); StaticShadowDepthMap.Empty(); // Use a fence to keep track of when the rendering thread executes the release command DestroyFence.BeginFence(); }
FShotThumbnail::~FShotThumbnail() { BeginReleaseResource( Texture ); FlushRenderingCommands(); if (Texture) { delete Texture; } }
void UTexture::BeginDestroy() { Super::BeginDestroy(); if( !UpdateStreamingStatus() && Resource ) { // Send the rendering thread a release message for the texture's resource. BeginReleaseResource(Resource); Resource->ReleaseFence.BeginFence(); // Keep track that we alrady kicked off the async release. bAsyncResourceReleaseHasBeenStarted = true; } }
void FDynamicResourceMap::ReleaseResources() { for (TMap<FName, TSharedPtr<FSlateDynamicTextureResource> >::TIterator It(NativeTextureMap); It; ++It) { BeginReleaseResource(It.Value()->RHIRefTexture); } for ( TextureResourceMap::TIterator It(TextureMap); It; ++It ) { It.Value()->UpdateRenderResource(nullptr); } }
void FShaderResource::Release() { check(NumRefs != 0); if(--NumRefs == 0) { ShaderResourceIdMap.Remove(GetId()); // Send a release message to the rendering thread when the shader loses its last reference. BeginReleaseResource(this); BeginCleanup(this); } }
void FSceneViewport::UpdateViewportRHI(bool bDestroyed, uint32 NewSizeX, uint32 NewSizeY, EWindowMode::Type NewWindowMode) { { SCOPED_SUSPEND_RENDERING_THREAD(true); // Update the viewport attributes. // This is done AFTER the command flush done by UpdateViewportRHI, to avoid disrupting rendering thread accesses to the old viewport size. SizeX = NewSizeX; SizeY = NewSizeY; WindowMode = NewWindowMode; // Release the viewport's resources. BeginReleaseResource(this); if( !bDestroyed ) { BeginInitResource(this); if( !bUseSeparateRenderTarget ) { // Get the viewport for this window from the renderer so we can render directly to the backbuffer TSharedPtr<FSlateRenderer> Renderer = FSlateApplication::Get().GetRenderer(); FWidgetPath WidgetPath; void* ViewportResource = Renderer->GetViewportResource( *FSlateApplication::Get().FindWidgetWindow( ViewportWidget.Pin().ToSharedRef(), WidgetPath ) ); if( ViewportResource ) { ViewportRHI = *((FViewportRHIRef*)ViewportResource); } } ViewportResizedEvent.Broadcast(this, 0); } else { // Enqueue a render command to delete the handle. It must be deleted on the render thread after the resource is released ENQUEUE_UNIQUE_RENDER_COMMAND_TWOPARAMETER(DeleteSlateRenderTarget, TArray<FSlateRenderTargetRHI*>&, BufferedSlateHandles, BufferedSlateHandles, FSlateRenderTargetRHI*&, RenderThreadSlateTexture, RenderThreadSlateTexture, { for (int32 i = 0; i < BufferedSlateHandles.Num(); ++i) { delete BufferedSlateHandles[i]; BufferedSlateHandles[i] = nullptr; delete RenderThreadSlateTexture; RenderThreadSlateTexture = nullptr; } }); } }
void FSceneViewState::Destroy() { if ( IsInGameThread() ) { // Release the occlusion query data. BeginReleaseResource(this); // Defer deletion of the view state until the rendering thread is done with it. BeginCleanup(this); } else { ReleaseResource(); FinishCleanup(); } }
void FShaderResource::Release() { // We need to lock the resource map so that no resource gets acquired by // FindShaderResourceById while we (potentially) remove this resource FScopeLock ShaderResourceIdMapLock(&ShaderResourceIdMapCritical); check(NumRefs != 0); if(--NumRefs == 0) { ShaderResourceIdMap.Remove(GetId()); // Send a release message to the rendering thread when the shader loses its last reference. BeginReleaseResource(this); Canary = FShader::ShaderMagic_CleaningUp; BeginCleanup(this); } }
void UVaQuoleUIComponent::DestroyUITexture() { if (Texture) { Texture->RemoveFromRoot(); if (Texture->Resource) { BeginReleaseResource(Texture->Resource); FlushRenderingCommands(); } Texture->MarkPendingKill(); Texture = nullptr; } }
void FSceneViewport::UpdateViewportRHI(bool bDestroyed, uint32 NewSizeX, uint32 NewSizeY, EWindowMode::Type NewWindowMode) { // Make sure we're not in the middle of streaming textures. (*GFlushStreamingFunc)(); { SCOPED_SUSPEND_RENDERING_THREAD(true); // Update the viewport attributes. // This is done AFTER the command flush done by UpdateViewportRHI, to avoid disrupting rendering thread accesses to the old viewport size. SizeX = NewSizeX; SizeY = NewSizeY; WindowMode = NewWindowMode; // Release the viewport's resources. BeginReleaseResource(this); if( !bDestroyed ) { BeginInitResource(this); if( !bUseSeparateRenderTarget ) { // Get the viewport for this window from the renderer so we can render directly to the backbuffer TSharedPtr<FSlateRenderer> Renderer = FSlateApplication::Get().GetRenderer(); FWidgetPath WidgetPath; void* ViewportResource = Renderer->GetViewportResource( *FSlateApplication::Get().FindWidgetWindow( ViewportWidget.Pin().ToSharedRef(), WidgetPath ) ); if( ViewportResource ) { ViewportRHI = *((FViewportRHIRef*)ViewportResource); } } ViewportResizedEvent.Broadcast(this, 0); } else { // Enqueue a render command to delete the handle. It must be deleted on the render thread after the resource is released ENQUEUE_UNIQUE_RENDER_COMMAND_ONEPARAMETER(DeleteSlateRenderTarget, FSlateRenderTargetRHI*&, SlateRenderTargetHandle, SlateRenderTargetHandle, { delete SlateRenderTargetHandle; SlateRenderTargetHandle = NULL; }); } }
void UTexture::BeginDestroy() { Super::BeginDestroy(); if( !UpdateStreamingStatus() && (Resource || TextureReference.IsInitialized_GameThread()) ) { // Send the rendering thread a release message for the texture's resource. if (Resource) { BeginReleaseResource(Resource); } if (TextureReference.IsInitialized_GameThread()) { TextureReference.BeginRelease_GameThread(); } ReleaseFence.BeginFence(); // Keep track that we already kicked off the async release. bAsyncResourceReleaseHasBeenStarted = true; } }
void FSlateElementIndexBuffer::Destroy() { BeginReleaseResource(this); }
~FPreviewMaterial() { BeginReleaseResource(this); FlushRenderingCommands(); }