コード例 #1
0
void FNullDynamicRHI::Init()
{
#if PLATFORM_WINDOWS
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::ES2] = SP_PCD3D_ES2;
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::ES3_1] = SP_PCD3D_ES3_1;
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::SM4] = SP_PCD3D_SM4;
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::SM5] = SP_PCD3D_SM5;
#else
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::ES2] = SP_OPENGL_PCES2;
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::ES3_1] = SP_NumPlatforms;
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::SM4] = SP_OPENGL_SM4;
	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::SM5] = SP_OPENGL_SM5;
#endif
	
	check(!GIsRHIInitialized);

	// Notify all initialized FRenderResources that there's a valid RHI device to create their RHI resources for now.
	for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
	{
		ResourceIt->InitRHI();
	}
	// Dynamic resources can have dependencies on static resources (with uniform buffers) and must initialized last!
	for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
	{
		ResourceIt->InitDynamicRHI();
	}

	GIsRHIInitialized = true;
}
コード例 #2
0
/**
* Iterate over the global list of resources that need to
* be updated and call UpdateResource on each one.
*/
void FDeferredUpdateResource::UpdateResources()
{
	if( bNeedsUpdate )
	{
		TLinkedList<FDeferredUpdateResource*>*& UpdateList = FDeferredUpdateResource::GetUpdateList();
		for( TLinkedList<FDeferredUpdateResource*>::TIterator ResourceIt(UpdateList);ResourceIt; )
		{
			FDeferredUpdateResource* RTResource = *ResourceIt;
			// iterate to next resource before removing an entry
			ResourceIt.Next();
			if( RTResource )
			{
				// update each resource
				RTResource->UpdateResource();
				if( RTResource->bOnlyUpdateOnce )
				{
					// remove from list if only a single update was requested
					RTResource->RemoveFromDeferredUpdateList();
				}
			}
		}
		// since the updates should only occur once globally
		// then we need to reset this before rendering any viewports
		bNeedsUpdate = false;
	}
}
コード例 #3
0
void FD3D11DynamicRHI::CleanupD3DDevice()
{
	if(GIsRHIInitialized)
	{
		check(Direct3DDevice);
		check(Direct3DDeviceIMContext);

		// Reset the RHI initialized flag.
		GIsRHIInitialized = false;

		check(!GIsCriticalError);

		// Ask all initialized FRenderResources to release their RHI resources.
		for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
		{
			FRenderResource* Resource = *ResourceIt;
			check(Resource->IsInitialized());
			Resource->ReleaseRHI();
		}

		for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
		{
			ResourceIt->ReleaseDynamicRHI();
		}

		extern void EmptyD3DSamplerStateCache();
		EmptyD3DSamplerStateCache();

		// release our dynamic VB and IB buffers
		DynamicVB = NULL;
		DynamicIB = NULL;

		ReleasePooledUniformBuffers();
		ReleasePooledTextures();

		// Release the device and its IC
		StateCache.SetContext(nullptr);
		Direct3DDeviceIMContext = NULL;

		Direct3DDevice = NULL;
	}
}
コード例 #4
0
/**
* Add this resource to deferred update list
* @param OnlyUpdateOnce - flag this resource for a single update if true
*/
void FDeferredUpdateResource::AddToDeferredUpdateList( bool OnlyUpdateOnce )
{
	bool bExists=false;
	TLinkedList<FDeferredUpdateResource*>*& UpdateList = FDeferredUpdateResource::GetUpdateList();
	for( TLinkedList<FDeferredUpdateResource*>::TIterator ResourceIt(UpdateList);ResourceIt;ResourceIt.Next() )
	{
		if( (*ResourceIt) == this )
		{
			bExists=true;
			break;
		}
	}
	if( !bExists )
	{
		UpdateListLink = TLinkedList<FDeferredUpdateResource*>(this);
		UpdateListLink.Link(UpdateList);
		bNeedsUpdate = true;
	}
	bOnlyUpdateOnce=OnlyUpdateOnce;
}
コード例 #5
0
ファイル: D3D11Device.cpp プロジェクト: xiangyuan/Unreal4
void FD3D11DynamicRHI::CleanupD3DDevice()
{
	if(GIsRHIInitialized)
	{
		check(Direct3DDevice);
		check(Direct3DDeviceIMContext);

		// Reset the RHI initialized flag.
		GIsRHIInitialized = false;

		check(!GIsCriticalError);

		// Ask all initialized FRenderResources to release their RHI resources.
		for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
		{
			FRenderResource* Resource = *ResourceIt;
			check(Resource->IsInitialized());
			Resource->ReleaseRHI();
		}

		for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
		{
			ResourceIt->ReleaseDynamicRHI();
		}

		extern void EmptyD3DSamplerStateCache();
		EmptyD3DSamplerStateCache();

		// release our dynamic VB and IB buffers
		DynamicVB = NULL;
		DynamicIB = NULL;

		// Release references to bound uniform buffers.
		for (int32 Frequency = 0; Frequency < SF_NumFrequencies; ++Frequency)
		{
			for (int32 BindIndex = 0; BindIndex < MAX_UNIFORM_BUFFERS_PER_SHADER_STAGE; ++BindIndex)
			{
				BoundUniformBuffers[Frequency][BindIndex].SafeRelease();
			}
		}

		// Release the device and its IC
		StateCache.SetContext(nullptr);

		// Flush all pending deletes before destroying the device.
		FRHIResource::FlushPendingDeletes();

		ReleasePooledUniformBuffers();
		ReleasePooledTextures();

		// When running with D3D debug, clear state and flush the device to get rid of spurious live objects in D3D11's report.
		if (D3D11RHI_ShouldCreateWithD3DDebug())
		{
			Direct3DDeviceIMContext->ClearState();
			Direct3DDeviceIMContext->Flush();
		}

		Direct3DDeviceIMContext = NULL;

		Direct3DDevice = NULL;
	}
}
コード例 #6
0
FEmptyDynamicRHI::FEmptyDynamicRHI()
{
	// This should be called once at the start 
	check( IsInGameThread() );
	check( !GIsThreadedRendering );

	// Initialize the RHI capabilities.

//	GRHIAdapterName = 
//	GRHIVendorId = 
// 	GSupportsRenderTargetFormat_PF_G8 = false;
// 	GSupportsQuads = true;
// 	GRHISupportsTextureStreaming = true;
// 	GMaxShadowDepthBufferSizeX = 4096;
// 	GMaxShadowDepthBufferSizeY = 4096;
// 
// 	GMaxTextureDimensions = 16384;
// 	GMaxTextureMipCount = FPlatformMath::CeilLogTwo( GMaxTextureDimensions ) + 1;
// 	GMaxTextureMipCount = FPlatformMath::Min<int32>( MAX_TEXTURE_MIP_COUNT, GMaxTextureMipCount );
// 	GMaxCubeTextureDimensions = 16384;
// 	GMaxTextureArrayLayers = 8192;

//	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::ES2] = SP_NumPlatforms;
//	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::ES3_1] = SP_NumPlatforms;
//	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::SM4] = SP_NumPlatforms;
//	GShaderPlatformForFeatureLevel[ERHIFeatureLevel::SM5] = ;

// 	GDrawUPVertexCheckCount = MAX_uint16;

	// Initialize the platform pixel format map.
// 	GPixelFormats[PF_Unknown			].PlatformFormat	= 
// 	GPixelFormats[PF_A32B32G32R32F		].PlatformFormat	= 
// 	GPixelFormats[PF_B8G8R8A8			].PlatformFormat	= 
// 	GPixelFormats[PF_G8					].PlatformFormat	= 
// 	GPixelFormats[PF_G16				].PlatformFormat	= 
// 	GPixelFormats[PF_DXT1				].PlatformFormat	= 
// 	GPixelFormats[PF_DXT3				].PlatformFormat	= 
// 	GPixelFormats[PF_DXT5				].PlatformFormat	= 
// 	GPixelFormats[PF_UYVY				].PlatformFormat	= 
// 	GPixelFormats[PF_FloatRGB			].PlatformFormat	= 
// 	GPixelFormats[PF_FloatRGB			].BlockBytes		= 4;
// 	GPixelFormats[PF_FloatRGBA			].PlatformFormat	= 
// 	GPixelFormats[PF_FloatRGBA			].BlockBytes		= 8;
// 	GPixelFormats[PF_DepthStencil		].PlatformFormat	= 
// 	GPixelFormats[PF_DepthStencil		].BlockBytes		= 4;
// 	GPixelFormats[PF_X24_G8				].PlatformFormat	= 
// 	GPixelFormats[PF_X24_G8				].BlockBytes		= 1;
// 	GPixelFormats[PF_ShadowDepth		].PlatformFormat	= 
// 	GPixelFormats[PF_R32_FLOAT			].PlatformFormat	= 
// 	GPixelFormats[PF_G16R16				].PlatformFormat	= 
// 	GPixelFormats[PF_G16R16F			].PlatformFormat	= 
// 	GPixelFormats[PF_G16R16F_FILTER		].PlatformFormat	= 
// 	GPixelFormats[PF_G32R32F			].PlatformFormat	= 
// 	GPixelFormats[PF_A2B10G10R10		].PlatformFormat    = 
// 	GPixelFormats[PF_A16B16G16R16		].PlatformFormat    = 
// 	GPixelFormats[PF_D24				].PlatformFormat	= 
// 	GPixelFormats[PF_R16F				].PlatformFormat	= 
// 	GPixelFormats[PF_R16F_FILTER		].PlatformFormat	= 
// 	GPixelFormats[PF_BC5				].PlatformFormat	= 
// 	GPixelFormats[PF_V8U8				].PlatformFormat	= 
// 	GPixelFormats[PF_A1					].PlatformFormat	= 
// 	GPixelFormats[PF_FloatR11G11B10		].PlatformFormat	= 
// 	GPixelFormats[PF_FloatR11G11B10		].BlockBytes		= 4;
// 	GPixelFormats[PF_A8					].PlatformFormat	= 
// 	GPixelFormats[PF_R32_UINT			].PlatformFormat	= 
// 	GPixelFormats[PF_R32_SINT			].PlatformFormat	= 
// 	GPixelFormats[PF_R16G16B16A16_UINT	].PlatformFormat	= 
// 	GPixelFormats[PF_R16G16B16A16_SINT	].PlatformFormat	= 
// 	GPixelFormats[PF_R5G6B5_UNORM		].PlatformFormat	= 
// 	GPixelFormats[PF_R8G8B8A8			].PlatformFormat	= 
// 	GPixelFormats[PF_R8G8				].PlatformFormat	= 

	GDynamicRHI = this;

	// Notify all initialized FRenderResources that there's a valid RHI device to create their RHI resources for now.
	for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
	{
		ResourceIt->InitRHI();
	}
	// Dynamic resources can have dependencies on static resources (with uniform buffers) and must initialized last!
	for(TLinkedList<FRenderResource*>::TIterator ResourceIt(FRenderResource::GetResourceList());ResourceIt;ResourceIt.Next())
	{
		ResourceIt->InitDynamicRHI();
	}

	GIsRHIInitialized = true;
}