当前位置: 首页>>代码示例>>C++>>正文


C++ TRefCountPtr::GetReference方法代码示例

本文整理汇总了C++中TRefCountPtr::GetReference方法的典型用法代码示例。如果您正苦于以下问题:C++ TRefCountPtr::GetReference方法的具体用法?C++ TRefCountPtr::GetReference怎么用?C++ TRefCountPtr::GetReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TRefCountPtr的用法示例。


在下文中一共展示了TRefCountPtr::GetReference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsViewportFullscreen

void FSlateD3DRenderer::Private_CreateViewport( TSharedRef<SWindow> InWindow, const FVector2D &WindowSize )
{
	TSharedRef< FGenericWindow > NativeWindow = InWindow->GetNativeWindow().ToSharedRef();

	bool bFullscreen = IsViewportFullscreen( *InWindow );
	bool bWindowed = true;//@todo implement fullscreen: !bFullscreen;

	DXGI_SWAP_CHAIN_DESC SwapChainDesc;
	FMemory::Memzero(&SwapChainDesc, sizeof(SwapChainDesc) );
	SwapChainDesc.BufferCount = 1;
	SwapChainDesc.BufferDesc.Width = FMath::TruncToInt(WindowSize.X);
	SwapChainDesc.BufferDesc.Height = FMath::TruncToInt(WindowSize.Y);
	SwapChainDesc.BufferDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
	SwapChainDesc.BufferDesc.RefreshRate.Numerator = 0;
	SwapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
	SwapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	SwapChainDesc.OutputWindow = (HWND)NativeWindow->GetOSWindowHandle();
	SwapChainDesc.SampleDesc.Count = 1;
	SwapChainDesc.SampleDesc.Quality = 0;
	SwapChainDesc.Windowed = bWindowed;
	SwapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
	SwapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

	TRefCountPtr<IDXGIDevice> DXGIDevice;
	HRESULT Hr = GD3DDevice->QueryInterface( __uuidof(IDXGIDevice), (void**)DXGIDevice.GetInitReference() );
	check( SUCCEEDED(Hr) );

	TRefCountPtr<IDXGIAdapter> DXGIAdapter;
	Hr = DXGIDevice->GetParent(__uuidof(IDXGIAdapter), (void **)DXGIAdapter.GetInitReference() );
	check( SUCCEEDED(Hr) );

	TRefCountPtr<IDXGIFactory> DXGIFactory;
	DXGIAdapter->GetParent(__uuidof(IDXGIFactory), (void **)DXGIFactory.GetInitReference() );
	check( SUCCEEDED(Hr) );

	FSlateD3DViewport Viewport;

	Hr = DXGIFactory->CreateSwapChain(DXGIDevice.GetReference(), &SwapChainDesc, Viewport.D3DSwapChain.GetInitReference() );
	check( SUCCEEDED(Hr) );

	Hr = DXGIFactory->MakeWindowAssociation((HWND)NativeWindow->GetOSWindowHandle(),DXGI_MWA_NO_ALT_ENTER);
	check(SUCCEEDED(Hr));

	uint32 Width = FMath::TruncToInt(WindowSize.X);
	uint32 Height = FMath::TruncToInt(WindowSize.Y);

	Viewport.ViewportInfo.MaxDepth = 1.0f;
	Viewport.ViewportInfo.MinDepth = 0.0f;
	Viewport.ViewportInfo.Width = Width;
	Viewport.ViewportInfo.Height = Height;
	Viewport.ViewportInfo.TopLeftX = 0;
	Viewport.ViewportInfo.TopLeftY = 0;
	
	CreateBackBufferResources( Viewport.D3DSwapChain, Viewport.BackBufferTexture, Viewport.RenderTargetView );

	Viewport.ProjectionMatrix = CreateProjectionMatrixD3D( Width, Height );

	WindowToViewportMap.Add( &InWindow.Get(), Viewport );

}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:60,代码来源:SlateD3DRenderer.cpp

示例2: RHICreateIndexBuffer

FIndexBufferRHIRef FOpenGLDynamicRHI::RHICreateIndexBuffer(uint32 Stride,uint32 Size, uint32 InUsage, FRHIResourceCreateInfo& CreateInfo)
{
	VERIFY_GL_SCOPE();

	const void *Data = NULL;

	// If a resource array was provided for the resource, create the resource pre-populated
	if(CreateInfo.ResourceArray)
	{
		check(Size == CreateInfo.ResourceArray->GetResourceDataSize());
		Data = CreateInfo.ResourceArray->GetResourceData();
	}

	TRefCountPtr<FOpenGLIndexBuffer> IndexBuffer = new FOpenGLIndexBuffer(Stride, Size, InUsage, Data);
	return IndexBuffer.GetReference();
}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:16,代码来源:OpenGLIndexBuffer.cpp

示例3: CompileShader

static void CompileShader( const FString& Filename, const FString& EntryPoint, const FString& ShaderModel, TRefCountPtr<ID3DBlob>& OutBlob )
{
	uint32 ShaderFlags = D3DCOMPILE_ENABLE_STRICTNESS;
#if UE_BUILD_DEBUG
	ShaderFlags |= D3D10_SHADER_DEBUG;
#else
	ShaderFlags |= D3DCOMPILE_OPTIMIZATION_LEVEL3;
#endif

	TRefCountPtr<ID3DBlob> ErrorBlob;
	HRESULT Hr = D3DX11CompileFromFile( *Filename, NULL, NULL, TCHAR_TO_ANSI(*EntryPoint), TCHAR_TO_ANSI(*ShaderModel), ShaderFlags, 0, NULL, OutBlob.GetInitReference(), ErrorBlob.GetInitReference(), NULL );
	if( FAILED(Hr) )
	{
		if( ErrorBlob.GetReference() )
		{
			checkf(0, ANSI_TO_TCHAR(ErrorBlob->GetBufferPointer()));
		}
	}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:19,代码来源:SlateD3DShaders.cpp

示例4: Lock

FSamplerStateRHIRef FD3D11DynamicRHI::RHICreateSamplerState(const FSamplerStateInitializerRHI& Initializer)
{
	D3D11_SAMPLER_DESC SamplerDesc;
	FMemory::Memzero(&SamplerDesc,sizeof(D3D11_SAMPLER_DESC));

	int32 MaxAnisotropyCVar = GetCachedScalabilityCVars().MaxAnisotropy;

	SamplerDesc.AddressU = TranslateAddressMode(Initializer.AddressU);
	SamplerDesc.AddressV = TranslateAddressMode(Initializer.AddressV);
	SamplerDesc.AddressW = TranslateAddressMode(Initializer.AddressW);
	SamplerDesc.MipLODBias = Initializer.MipBias;
	SamplerDesc.MaxAnisotropy = FMath::Clamp(Initializer.MaxAnisotropy > 0 ? Initializer.MaxAnisotropy : MaxAnisotropyCVar,1,16);
	SamplerDesc.MinLOD = Initializer.MinMipLevel;
	SamplerDesc.MaxLOD = Initializer.MaxMipLevel;

	// Determine whether we should use one of the comparison modes
	const bool bComparisonEnabled = Initializer.SamplerComparisonFunction != SCF_Never;
	switch(Initializer.Filter)
	{
	case SF_AnisotropicLinear:
	case SF_AnisotropicPoint:
		if (SamplerDesc.MaxAnisotropy == 1)
		{
			SamplerDesc.Filter = bComparisonEnabled ? D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_LINEAR;
		}
		else
		{
			// D3D11 doesn't allow using point filtering for mip filter when using anisotropic filtering
			SamplerDesc.Filter = bComparisonEnabled ? D3D11_FILTER_COMPARISON_ANISOTROPIC : D3D11_FILTER_ANISOTROPIC;
		}
		
		break;
	case SF_Trilinear:
        SamplerDesc.Filter = bComparisonEnabled ? D3D11_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR : D3D11_FILTER_MIN_MAG_MIP_LINEAR;
		break;
	case SF_Bilinear:
		SamplerDesc.Filter = bComparisonEnabled ? D3D11_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT : D3D11_FILTER_MIN_MAG_LINEAR_MIP_POINT;
		break;
	case SF_Point:
		SamplerDesc.Filter = bComparisonEnabled ? D3D11_FILTER_COMPARISON_MIN_MAG_MIP_POINT : D3D11_FILTER_MIN_MAG_MIP_POINT;
		break;
	}
	const FLinearColor LinearBorderColor = FColor(Initializer.BorderColor);
	SamplerDesc.BorderColor[0] = LinearBorderColor.R;
	SamplerDesc.BorderColor[1] = LinearBorderColor.G;
	SamplerDesc.BorderColor[2] = LinearBorderColor.B;
	SamplerDesc.BorderColor[3] = LinearBorderColor.A;
	SamplerDesc.ComparisonFunc = TranslateSamplerCompareFunction(Initializer.SamplerComparisonFunction);

#if LOCK_GSamplerStateCache
	QUICK_SCOPE_CYCLE_COUNTER(FD3D11DynamicRHI_RHICreateSamplerState_LockAndCreate);
	FScopeLock Lock(&GSamplerStateCacheLock);
#endif

	// D3D11 will return the same pointer if the particular state description was already created
	TRefCountPtr<ID3D11SamplerState> SamplerStateHandle;
	VERIFYD3D11RESULT(Direct3DDevice->CreateSamplerState(&SamplerDesc, SamplerStateHandle.GetInitReference()));

	FD3D11SamplerState** Found = GSamplerStateCache.Find(SamplerStateHandle);
	if (Found)
	{
		return *Found;
	}

	FD3D11SamplerState* SamplerState = new FD3D11SamplerState;
	SamplerState->Resource = SamplerStateHandle;
	// Manually add reference as we control the creation/destructions
	SamplerState->AddRef();
	GSamplerStateCache.Add(SamplerStateHandle.GetReference(), SamplerState);
	return SamplerState;
}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:71,代码来源:D3D11State.cpp

示例5: sizeof

void FD3D11StateCacheBase::VerifyCacheState()
{
	if (!Direct3DDeviceIMContext)
	{
		return;
	}

	// Verify Shader States
	{
		TRefCountPtr<ID3D11VertexShader> VertexShader;
		TRefCountPtr<ID3D11HullShader> HullShader;
		TRefCountPtr<ID3D11DomainShader> DomainShader;
		TRefCountPtr<ID3D11GeometryShader> GeometryShader;
		TRefCountPtr<ID3D11PixelShader> PixelShader;
		TRefCountPtr<ID3D11ComputeShader> ComputeShader;

		Direct3DDeviceIMContext->VSGetShader(VertexShader.GetInitReference(), nullptr, nullptr);
		Direct3DDeviceIMContext->HSGetShader(HullShader.GetInitReference(), nullptr, nullptr);
		Direct3DDeviceIMContext->DSGetShader(DomainShader.GetInitReference(), nullptr, nullptr);
		Direct3DDeviceIMContext->GSGetShader(GeometryShader.GetInitReference(), nullptr, nullptr);
		Direct3DDeviceIMContext->PSGetShader(PixelShader.GetInitReference(), nullptr, nullptr);
		Direct3DDeviceIMContext->CSGetShader(ComputeShader.GetInitReference(), nullptr, nullptr);

		check(VertexShader.GetReference() == CurrentVertexShader);
		check(HullShader.GetReference() == CurrentHullShader);
		check(DomainShader.GetReference() == CurrentDomainShader);
		check(GeometryShader.GetReference() == CurrentGeometryShader);
		check(PixelShader.GetReference() == CurrentPixelShader);
		check(ComputeShader.GetReference() == CurrentComputeShader);
	}

	// Verify Depth Stencil State
	{
		TRefCountPtr<ID3D11DepthStencilState> DepthStencilState;
		uint32 StencilRef;

		Direct3DDeviceIMContext->OMGetDepthStencilState(DepthStencilState.GetInitReference(), &StencilRef);

		check(DepthStencilState.GetReference() == CurrentDepthStencilState);
		check(StencilRef == CurrentReferenceStencil);
	}

	// Verify Rasterizer State
	{
		TRefCountPtr<ID3D11RasterizerState> RasterizerState;

		Direct3DDeviceIMContext->RSGetState(RasterizerState.GetInitReference());

		check(RasterizerState.GetReference() == CurrentRasterizerState);
	}

	// Verify Blend State
	{
		TRefCountPtr<ID3D11BlendState> BlendState;
		float BlendFactor[4];
		uint32 SampleMask;

		Direct3DDeviceIMContext->OMGetBlendState(BlendState.GetInitReference(), BlendFactor, &SampleMask);

		check(BlendState.GetReference() == CurrentBlendState);
		check(FMemory::Memcmp(BlendFactor, CurrentBlendFactor, sizeof(CurrentBlendFactor)) == 0);
		check(SampleMask == CurrentBlendSampleMask);
	}

	// Verify Viewport state
	{
		D3D11_VIEWPORT vp[D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
		uint32 numVP = CurrentNumberOfViewports;
		Direct3DDeviceIMContext->RSGetViewports(&numVP,&vp[0]);
		check(numVP == CurrentNumberOfViewports);
		check( FMemory::Memcmp( &vp, &CurrentViewport[0],sizeof(D3D11_VIEWPORT) * CurrentNumberOfViewports) ==0);
	}
	
	// Verify Input Layout
	{
		TRefCountPtr<ID3D11InputLayout> InputLayout;
		Direct3DDeviceIMContext->IAGetInputLayout(InputLayout.GetInitReference());
		check(InputLayout.GetReference() == CurrentInputLayout);
	}

	// Verify Sampler States
	{
		VerifySamplerStates<SF_Vertex>();
		VerifySamplerStates<SF_Hull>();
		VerifySamplerStates<SF_Domain>();
		VerifySamplerStates<SF_Geometry>();
		VerifySamplerStates<SF_Pixel>();
		VerifySamplerStates<SF_Compute>();
	}

	// Verify Vertex Buffers
	{
		ID3D11Buffer* VertexBuffers[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
		uint32 Strides[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
		uint32 Offsets[D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];

		Direct3DDeviceIMContext->IAGetVertexBuffers(0, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, VertexBuffers, Strides, Offsets);

		for (uint32 Index = 0; Index < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; Index++)
		{
//.........这里部分代码省略.........
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:101,代码来源:D3D11StateCache.cpp


注:本文中的TRefCountPtr::GetReference方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。