Exemplo n.º 1
0
void FSlateRHIRenderingPolicy::ReleaseResources()
{
	for( int32 BufferIndex = 0; BufferIndex < 2; ++BufferIndex )
	{
		BeginReleaseResource(&VertexBuffers[BufferIndex]);
		BeginReleaseResource(&IndexBuffers[BufferIndex]);
	}
}
Exemplo n.º 2
0
/** 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();
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
FTileItemThumbnail::~FTileItemThumbnail()
{
	BeginReleaseResource(ThumbnailTexture);
	
	// Wait for all resources to be released
	FlushRenderingCommands();
	delete ThumbnailTexture;
	ThumbnailTexture = NULL;
}
Exemplo n.º 5
0
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;
	}
}
Exemplo n.º 7
0
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);
	}
}
Exemplo n.º 9
0
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);
	}
}
Exemplo n.º 10
0
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;
				}						
			});

		}
	}
Exemplo n.º 11
0
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();
	}
}
Exemplo n.º 12
0
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);
	}
}
Exemplo n.º 13
0
void UVaQuoleUIComponent::DestroyUITexture()
{
	if (Texture)
	{
		Texture->RemoveFromRoot();

		if (Texture->Resource)
		{
			BeginReleaseResource(Texture->Resource);

			FlushRenderingCommands();
		}

		Texture->MarkPendingKill();
		Texture = nullptr;
	}
}
Exemplo n.º 14
0
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;
			});

		}
	}
Exemplo n.º 15
0
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);
}
Exemplo n.º 17
0
	~FPreviewMaterial()
	{
		BeginReleaseResource(this);
		FlushRenderingCommands();
	}