Ejemplo n.º 1
0
void FSlateOpenGLTexture::UpdateTextureRaw(const void* Buffer, const FIntRect& Dirty)
{
	// Ensure texturing is enabled before setting texture properties
#if USE_DEPRECATED_OPENGL_FUNCTIONALITY
	glEnable(GL_TEXTURE_2D);
#endif // USE_DEPRECATED_OPENGL_FUNCTIONALITY
	glBindTexture(GL_TEXTURE_2D, ShaderResource);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
#if USE_DEPRECATED_OPENGL_FUNCTIONALITY
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
#endif // USE_DEPRECATED_OPENGL_FUNCTIONALITY
	
	// Upload the texture data
#if !PLATFORM_USES_ES2

	if (bHasPendingResize || Dirty.Area() == 0)
	{
		glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, SizeX, SizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, Buffer);
		bHasPendingResize = false;
	}
	else
	{
		glPixelStorei(GL_UNPACK_ROW_LENGTH, SizeX);
		glTexSubImage2D(GL_TEXTURE_2D, 0, Dirty.Min.X, Dirty.Min.Y, Dirty.Width(), Dirty.Height(), GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, (uint8*)Buffer + Dirty.Min.Y * SizeX * 4 + Dirty.Min.X * 4);
		glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
	}
#else
	glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8_EXT, SizeX, SizeY, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, Buffer);
#endif
	CHECK_GL_ERRORS;
}
Ejemplo n.º 2
0
/**
 * Display the currently queued subtitles and cleanup after they have finished rendering
 *
 * @param  Canvas - where to render the subtitles
 * @param  CurrentTime - current world time
 */
void FSubtitleManager::DisplaySubtitles( FCanvas* InCanvas, FIntRect& InSubtitleRegion, float InAudioTimeSeconds )
{
	check( GEngine );
	check( InCanvas );

	if( !GEngine->GetSubtitleFont() )
	{
		UE_LOG(LogSubtitle, Warning, TEXT( "NULL GEngine->GetSubtitleFont() - subtitles not rendering!" ) );
		return;
	}
	
	if (InSubtitleRegion.Area() > 0)
	{
		// Work out the safe zones
		TrimRegionToSafeZone( InCanvas, InSubtitleRegion );

		// If the lines have not already been split, split them to the safe zone now
		SplitLinesToSafeZone( InCanvas, InSubtitleRegion );

		// Find the subtitle to display
		PTRINT HighestPriorityID = FindHighestPrioritySubtitle( InAudioTimeSeconds );

		// Display the highest priority subtitle
		if( HighestPriorityID )
		{
			FActiveSubtitle* Subtitle = ActiveSubtitles.Find( HighestPriorityID );
			DisplaySubtitle( InCanvas, Subtitle, InSubtitleRegion, FLinearColor::White );
		}
		else
		{
			CurrentSubtitleHeight = 0.0f;
		}
	}
}
Ejemplo n.º 3
0
void FSlateD3DTexture::UpdateTextureRaw(const void* Buffer, const FIntRect& Dirty)
{
	bool bUseStagingTexture = StagingTexture.IsValid();
	ID3D11Texture2D* TextureToUpdate = bUseStagingTexture ? StagingTexture : D3DTexture;

	D3D11_BOX Region;
	Region.front = 0;
	Region.back = 1;
	if (bUseStagingTexture && Dirty.Area() > 0)
	{
		Region.left = Dirty.Min.X;
		Region.top = Dirty.Min.Y;
		Region.right = Dirty.Max.X;
		Region.bottom = Dirty.Max.Y;
	}
	else
	{
		Region.left = 0;
		Region.right = SizeX;
		Region.top = 0;
		Region.bottom = SizeY;
	}

	D3D11_MAPPED_SUBRESOURCE Resource;
	HRESULT Hr = GD3DDeviceContext->Map(TextureToUpdate, 0, bUseStagingTexture?D3D11_MAP_READ_WRITE:D3D11_MAP_WRITE_DISCARD, 0, &Resource);
	uint32 SourcePitch = SizeX * BytesPerPixel;
	uint32 CopyRowBytes = (Region.right - Region.left) * BytesPerPixel;
	uint8* Destination = (uint8*)Resource.pData + Region.left * BytesPerPixel + Region.top * Resource.RowPitch;
	uint8* Source = (uint8*)Buffer + Region.left * BytesPerPixel + Region.top * SourcePitch;
	for (uint32 Row = Region.top; Row < Region.bottom; ++Row, Destination += Resource.RowPitch, Source += SourcePitch)
	{
		FMemory::Memcpy(Destination, Source, CopyRowBytes);
	}
	GD3DDeviceContext->Unmap(TextureToUpdate, 0);
	if (bUseStagingTexture)
	{
		GD3DDeviceContext->CopySubresourceRegion(D3DTexture, 0, Region.left, Region.top, Region.front, StagingTexture, 0, &Region);
	}
}
void FVulkanCommandListContext::InternalClearMRT(FVulkanCmdBuffer* CmdBuffer, bool bClearColor, int32 NumClearColors, const FLinearColor* ClearColorArray, bool bClearDepth, float Depth, bool bClearStencil, uint32 Stencil, FIntRect ExcludeRect)
{
#if VULKAN_USE_NEW_RENDERPASSES
	const VkExtent2D& Extents = RenderPassState.CurrentRenderPass->GetLayout().GetExtent2D();
	if (ExcludeRect.Min.X == 0 && ExcludeRect.Width() == Extents.width && ExcludeRect.Min.Y == 0 && Extents.height)
	{
		//if (ForceFullScreen == EForceFullScreenClear::EDoNotForce)
		{
			return;
		}
		//else
		{
			//ensureMsgf(false, TEXT("Forced Full Screen Clear ignoring Exclude Rect Restriction"));
		}
	}

	ensure(ExcludeRect.Area() == 0);

	if (RenderPassState.CurrentRenderPass)
	{
		VkClearRect Rect;
		FMemory::Memzero(Rect);
		Rect.rect.offset.x = 0;
		Rect.rect.offset.y = 0;
		Rect.rect.extent = Extents;

		VkClearAttachment Attachments[MaxSimultaneousRenderTargets + 1];
		FMemory::Memzero(Attachments);

		uint32 NumAttachments = NumClearColors;
		if (bClearColor)
		{
			for (int32 i = 0; i < NumClearColors; ++i)
			{
				Attachments[i].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
				Attachments[i].colorAttachment = i;
				Attachments[i].clearValue.color.float32[0] = ClearColorArray[i].R;
				Attachments[i].clearValue.color.float32[1] = ClearColorArray[i].G;
				Attachments[i].clearValue.color.float32[2] = ClearColorArray[i].B;
				Attachments[i].clearValue.color.float32[3] = ClearColorArray[i].A;
			}
		}

		if (bClearDepth || bClearStencil)
		{
			Attachments[NumClearColors].aspectMask = bClearDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : 0;
			Attachments[NumClearColors].aspectMask |= bClearStencil ? VK_IMAGE_ASPECT_STENCIL_BIT : 0;
			Attachments[NumClearColors].colorAttachment = 0;
			Attachments[NumClearColors].clearValue.depthStencil.depth = Depth;
			Attachments[NumClearColors].clearValue.depthStencil.stencil = Stencil;
			++NumAttachments;
		}

		VulkanRHI::vkCmdClearAttachments(CmdBuffer->GetHandle(), NumAttachments, Attachments, 1, &Rect);
	}
	else
	{
		ensure(0);
		//VulkanRHI::vkCmdClearColorImage(CmdBuffer->GetHandle(), )
	}
#else
#if VULKAN_ALLOW_MIDPASS_CLEAR
	const VkExtent2D& Extents = PendingState->GetRenderPass().GetLayout().GetExtent2D();
	if (ExcludeRect.Min.X == 0 && ExcludeRect.Width() == Extents.width && ExcludeRect.Min.Y == 0 && Extents.height)
	{
		//if (ForceFullScreen == EForceFullScreenClear::EDoNotForce)
		{
			return;
		}
		//else
		{
			//ensureMsgf(false, TEXT("Forced Full Screen Clear ignoring Exclude Rect Restriction"));
		}
	}

	ensure(ExcludeRect.Area() == 0);

	VkClearRect Rect;
	FMemory::Memzero(Rect);
	Rect.rect.offset.x = 0;
	Rect.rect.offset.y = 0;
	Rect.rect.extent = PendingState->GetRenderPass().GetLayout().GetExtent2D();

	VkClearAttachment Attachments[MaxSimultaneousRenderTargets + 1];
	FMemory::Memzero(Attachments);

	uint32 NumAttachments = NumClearColors;
	if (bClearColor)
	{
		for (int32 i = 0; i < NumClearColors; ++i)
		{
			Attachments[i].aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
			Attachments[i].colorAttachment = i;
			Attachments[i].clearValue.color.float32[0] = ClearColorArray[i].R;
			Attachments[i].clearValue.color.float32[1] = ClearColorArray[i].G;
			Attachments[i].clearValue.color.float32[2] = ClearColorArray[i].B;
			Attachments[i].clearValue.color.float32[3] = ClearColorArray[i].A;
		}
	}

	if(bClearDepth || bClearStencil)
	{
		Attachments[NumClearColors].aspectMask = bClearDepth ? VK_IMAGE_ASPECT_DEPTH_BIT : 0;
		Attachments[NumClearColors].aspectMask |= bClearStencil ? VK_IMAGE_ASPECT_STENCIL_BIT : 0;
		Attachments[NumClearColors].colorAttachment = 0;
		Attachments[NumClearColors].clearValue.depthStencil.depth = Depth;
		Attachments[NumClearColors].clearValue.depthStencil.stencil = Stencil;
		++NumAttachments;
	}

	VulkanRHI::vkCmdClearAttachments(CmdBuffer->GetHandle(), NumAttachments, Attachments, 1, &Rect);
#endif
#endif
}