本文整理汇总了C++中FTextureRHIRef函数的典型用法代码示例。如果您正苦于以下问题:C++ FTextureRHIRef函数的具体用法?C++ FTextureRHIRef怎么用?C++ FTextureRHIRef使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FTextureRHIRef函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: RHIUnlockTexture2D
void FMediaTextureResource::UpdateDeferredResource(FRHICommandListImmediate& RHICmdList, bool bClearRenderTarget/*=true*/)
{
FTimespan CurrentFrameTime = VideoBuffer->GetCurrentSampleTime();
TSharedPtr<TArray<uint8>, ESPMode::ThreadSafe> CurrentFrame = VideoBuffer->GetCurrentSample();
if (CurrentFrame.IsValid())
{
// draw the latest video frame
if (CurrentFrameTime != LastFrameTime)
{
uint32 Stride = 0;
FRHITexture2D* Texture2D = TextureRHI->GetTexture2D();
uint8* TextureBuffer = (uint8*)RHILockTexture2D(Texture2D, 0, RLM_WriteOnly, Stride, false);
FMemory::Memcpy(TextureBuffer, CurrentFrame->GetData(), CurrentFrame->Num());
RHIUnlockTexture2D(Texture2D, 0, false);
LastFrameTime = CurrentFrameTime;
Cleared = false;
}
}
else if (!Cleared || (LastClearColor != Owner->ClearColor))
{
// clear texture if video track selected
FRHICommandListImmediate& CommandList = FRHICommandListExecutor::GetImmediateCommandList();
SetRenderTarget(CommandList, RenderTargetTextureRHI, FTextureRHIRef());
CommandList.SetViewport(0, 0, 0.0f, Owner->GetSurfaceWidth(), Owner->GetSurfaceHeight(), 1.0f);
CommandList.Clear(true, Owner->ClearColor, false, 0.f, false, 0, FIntRect());
CommandList.CopyToResolveTarget(Texture2DRHI, TextureRHI, true, FResolveParams());
LastClearColor = Owner->ClearColor;
Cleared = true;
}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:35,代码来源:MediaTextureResource.cpp
示例2: check
void FSteamVRHMD::RenderTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FTexture2DRHIParamRef BackBuffer, FTexture2DRHIParamRef SrcTexture) const
{
check(IsInRenderingThread());
if (WindowMirrorMode == 0)
{
return;
}
const uint32 ViewportWidth = BackBuffer->GetSizeX();
const uint32 ViewportHeight = BackBuffer->GetSizeY();
SetRenderTarget(RHICmdList, BackBuffer, FTextureRHIRef());
RHICmdList.SetViewport(0, 0, 0, ViewportWidth, ViewportHeight, 1.0f);
RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
const auto FeatureLevel = GMaxRHIFeatureLevel;
auto ShaderMap = GetGlobalShaderMap(FeatureLevel);
TShaderMapRef<FScreenVS> VertexShader(ShaderMap);
TShaderMapRef<FScreenPS> PixelShader(ShaderMap);
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(RHICmdList, FeatureLevel, BoundShaderState, RendererModule->GetFilterVertexDeclaration().VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(RHICmdList, TStaticSamplerState<SF_Bilinear>::GetRHI(), SrcTexture);
if (WindowMirrorMode == 1)
{
// need to clear when rendering only one eye since the borders won't be touched by the DrawRect below
RHICmdList.Clear(true, FLinearColor::Black, false, 0, false, 0, FIntRect());
RendererModule->DrawRectangle(
RHICmdList,
ViewportWidth / 4, 0,
ViewportWidth / 2, ViewportHeight,
0.1f, 0.2f,
0.3f, 0.6f,
FIntPoint(ViewportWidth, ViewportHeight),
FIntPoint(1, 1),
*VertexShader,
EDRF_Default);
}
else if (WindowMirrorMode == 2)
{
RendererModule->DrawRectangle(
RHICmdList,
0, 0,
ViewportWidth, ViewportHeight,
0.0f, 0.0f,
1.0f, 1.0f,
FIntPoint(ViewportWidth, ViewportHeight),
FIntPoint(1, 1),
*VertexShader,
EDRF_Default);
}
}
开发者ID:JustDo1989,项目名称:UnrealEngine4.11-HairWorks,代码行数:60,代码来源:SteamVRRender.cpp
示例3: SCOPED_DRAW_EVENT
void FRCPassPostProcessAA::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessAA);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.ViewRect;
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestSize.X, DestSize.Y, 1.0f );
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
switch(Quality)
{
case 1: SetShaderTemplAA<1>(Context); break;
case 2: SetShaderTemplAA<2>(Context); break;
case 3: SetShaderTemplAA<3>(Context); break;
case 4: SetShaderTemplAA<4>(Context); break;
case 5: SetShaderTemplAA<5>(Context); break;
default: SetShaderTemplAA<6>(Context); break;
}
// Draw a quad mapping scene color to the view's render target
TShaderMapRef<FFXAAVS> VertexShader(Context.GetShaderMap());
DrawRectangle(
Context.RHICmdList,
DestRect.Min.X, DestRect.Min.Y,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestSize,
SrcSize,
*VertexShader,
EDRF_Default);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:59,代码来源:PostProcessAA.cpp
示例4: SCOPED_DRAW_EVENT
void FRCPassPostProcessLensBlur::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PassPostProcessLensBlur);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
FIntPoint TexSize = InputDesc->Extent;
// usually 1, 2, 4 or 8
uint32 ScaleToFullRes = GSceneRenderTargets.GetBufferSizeXY().X / TexSize.X;
FIntRect ViewRect = FIntRect::DivideAndRoundUp(View.ViewRect, ScaleToFullRes);
FIntPoint ViewSize = ViewRect.Size();
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef(), ESimpleRenderTargetMode::EClearColorToBlack);
Context.SetViewportAndCallRHI(ViewRect);
// set the state (additive blending)
Context.RHICmdList.SetBlendState(TStaticBlendState<CW_RGB, BO_Add, BF_One, BF_One>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessLensBlurVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessLensBlurPS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GEmptyVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
uint32 TileSize = 1;
FIntPoint TileCount = ViewSize / TileSize;
float PixelKernelSize = PercentKernelSize / 100.0f * ViewSize.X;
VertexShader->SetParameters(Context, TileCount, TileSize, PixelKernelSize, Threshold);
PixelShader->SetParameters(Context, PixelKernelSize);
Context.RHICmdList.SetStreamSource(0, NULL, 0, 0);
// needs to be the same on shader side (faster on NVIDIA and AMD)
int32 QuadsPerInstance = 4;
Context.RHICmdList.DrawPrimitive(PT_TriangleList, 0, 2, FMath::DivideAndRoundUp(TileCount.X * TileCount.Y, QuadsPerInstance));
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:johndpope,项目名称:UE4,代码行数:59,代码来源:PostProcessLensBlur.cpp
示例5: SCOPED_DRAW_EVENT
void FRCPassPostProcessMorpheus::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessMorpheus);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.UnscaledViewRect;
FIntPoint SrcSize = InputDesc->Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(DestRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessMorpheusVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessMorpheusPS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
FMatrix QuadTexTransform;
FMatrix QuadPosTransform = FMatrix::Identity;
PixelShader->SetPS(Context, SrcRect, SrcSize, View.StereoPass, QuadTexTransform);
// Draw a quad mapping scene color to the view's render target
DrawTransformedRectangle(
Context.RHICmdList,
0, 0,
DestRect.Width(), DestRect.Height(),
QuadPosTransform,
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
QuadTexTransform,
DestRect.Size(),
SrcSize
);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:58,代码来源:PostProcessMorpheus.cpp
示例6: SCOPED_DRAW_EVENT
void FRCPassPostProcessVisualizeBloomOverlay::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, VisualizeBloomOverlay);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
check(InputDesc && "Input is not hooked up correctly");
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
// e.g. 4 means the input texture is 4x smaller than the buffer size
uint32 ScaleFactor = GSceneRenderTargets.GetBufferSizeXY().X / SrcSize.X;
FIntRect SrcRect = View.ViewRect / ScaleFactor;
FIntRect DestRect = SrcRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
// is optimized away if possible (RT size=view size, )
Context.RHICmdList.Clear(true, FLinearColor(0, 0, 0, 0), false, 1.0f, false, 0, DestRect);
Context.SetViewportAndCallRHI(0, 0, 0.0f, DestRect.Width(), DestRect.Height(), 1.0f );
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessVisualizeBloomOverlayPS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context);
VertexShader->SetParameters(Context);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
DestRect.Min.X, DestRect.Min.Y,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
SrcSize,
*VertexShader,
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:johndpope,项目名称:UE4,代码行数:58,代码来源:PostProcessBloomSetup.cpp
示例7: SCOPED_DRAW_EVENT
void FRCPassPostProcessVisualizeLPV::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, VisualizeLPV);
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
// const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
const TRefCountPtr<IPooledRenderTarget> RenderTarget = GetInput(ePId_Input0)->GetOutput()->PooledRenderTarget;
const FSceneRenderTargetItem& DestRenderTarget = RenderTarget->GetRenderTargetItem();
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
{
FRenderTargetTemp TempRenderTarget(View, (const FTexture2DRHIRef&)DestRenderTarget.TargetableTexture);
FCanvas Canvas(&TempRenderTarget, NULL, ViewFamily.CurrentRealTime, ViewFamily.CurrentWorldTime, ViewFamily.DeltaWorldTime, View.GetFeatureLevel());
float X = 30;
float Y = 28;
const float YStep = 14;
const float ColumnWidth = 250;
Canvas.DrawShadowedString( X, Y += YStep, TEXT("VisualizeLightPropagationVolume"), GetStatsFont(), FLinearColor(0.2f, 0.2f, 1));
Y += YStep;
const FLightPropagationVolumeSettings& Dest = View.FinalPostProcessSettings.BlendableManager.GetSingleFinalDataConst<FLightPropagationVolumeSettings>();
#define ENTRY(name)\
Canvas.DrawShadowedString( X, Y += YStep, TEXT(#name) TEXT(":"), GetStatsFont(), FLinearColor(1, 1, 1));\
Canvas.DrawShadowedString( X + ColumnWidth, Y, *FString::Printf(TEXT("%g"), Dest.name), GetStatsFont(), FLinearColor(1, 1, 1));
ENTRY(LPVIntensity)
ENTRY(LPVVplInjectionBias)
ENTRY(LPVSize)
ENTRY(LPVSecondaryOcclusionIntensity)
ENTRY(LPVSecondaryBounceIntensity)
ENTRY(LPVGeometryVolumeBias)
ENTRY(LPVEmissiveInjectionIntensity)
ENTRY(LPVDirectionalOcclusionIntensity)
ENTRY(LPVDirectionalOcclusionRadius)
ENTRY(LPVDiffuseOcclusionExponent)
ENTRY(LPVSpecularOcclusionExponent)
ENTRY(LPVDiffuseOcclusionIntensity)
ENTRY(LPVSpecularOcclusionIntensity)
#undef ENTRY
Canvas.Flush_RenderThread(Context.RHICmdList);
}
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
// to satify following passws
FRenderingCompositeOutput* Output = GetOutput(ePId_Output0);
Output->PooledRenderTarget = RenderTarget;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:58,代码来源:PostProcessLpvIndirect.cpp
示例8: SCOPED_DRAW_EVENT
void FRCPassPostProcessHistogramReduce::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessHistogramReduce);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessHistogramReducePS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
// we currently assume the input is half res, one full res pixel less to avoid getting bilinear filtered input
FIntPoint GatherExtent = (View.ViewRect.Size() - FIntPoint(1, 1)) / 2;
uint32 LoopSizeValue = ComputeLoopSize(GatherExtent);
PixelShader->SetPS(Context, LoopSizeValue);
DrawPostProcessPass(
Context.RHICmdList,
0, 0,
DestSize.X, DestSize.Y,
0, 0,
SrcSize.X, 0,
DestSize,
SrcSize,
*VertexShader,
View.StereoPass,
Context.HasHmdMesh(),
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:frobro98,项目名称:UnrealSource,代码行数:57,代码来源:PostProcessHistogramReduce.cpp
示例9: SCOPED_DRAW_EVENT
void FRCPassPostProcessVisualizeMotionBlur::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(VisualizeMotionBlur, DEC_SCENE_ITEMS);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
FIntPoint TexSize = InputDesc->Extent;
// we assume the input and output is full resolution
FIntPoint SrcSize = InputDesc->Extent;
FIntPoint DestSize = PassOutputs[0].RenderTargetDesc.Extent;
// e.g. 4 means the input texture is 4x smaller than the buffer size
uint32 ScaleFactor = GSceneRenderTargets.GetBufferSizeXY().X / SrcSize.X;
FIntRect SrcRect = FIntRect::DivideAndRoundUp(View.ViewRect, ScaleFactor);
FIntRect DestRect = SrcRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
RHISetRenderTarget(DestRenderTarget.TargetableTexture, FTextureRHIRef());
// is optimized away if possible (RT size=view size, )
RHIClear(true, FLinearColor::Black, false, 1.0f, false, 0, SrcRect);
Context.SetViewportAndCallRHI(SrcRect);
// set the state
RHISetBlendState(TStaticBlendState<>::GetRHI());
RHISetRasterizerState(TStaticRasterizerState<>::GetRHI());
RHISetDepthStencilState(TStaticDepthStencilState<false,CF_Always>::GetRHI());
// Quality 0: visualize
SetMotionBlurShaderTempl<0>(Context);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
0, 0,
SrcRect.Width(), SrcRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
SrcRect.Size(),
SrcSize,
EDRF_UseTriangleOptimization);
RHICopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:57,代码来源:PostProcessMotionBlur.cpp
示例10: SCOPED_DRAW_EVENT
void FRCPassPostProcessHistogram::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(PostProcessHistogram, DEC_SCENE_ITEMS);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntRect DestRect = View.ViewRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
TShaderMapRef<FPostProcessHistogramCS> ComputeShader(GetGlobalShaderMap());
RHISetComputeShader(ComputeShader->GetComputeShader());
RHISetRenderTarget(FTextureRHIRef(), FTextureRHIRef());
// set destination
check(DestRenderTarget.UAV);
RHISetUAVParameter(ComputeShader->GetComputeShader(), ComputeShader->HistogramRWTexture.GetBaseIndex(), DestRenderTarget.UAV);
// we currently assume the input is half res, one full res pixel less to avoid getting bilinear filtered input
FIntPoint GatherExtent = (DestRect.Size() - FIntPoint(1, 1)) / 2;
FIntPoint ThreadGroupCountValue = ComputeThreadGroupCount(GatherExtent);
ComputeShader->SetCS(Context, ThreadGroupCountValue, (DestRect.Min + FIntPoint(1, 1)) / 2, GatherExtent);
DispatchComputeShader(*ComputeShader, ThreadGroupCountValue.X, ThreadGroupCountValue.Y, 1);
// un-set destination
RHISetUAVParameter(ComputeShader->GetComputeShader(), ComputeShader->HistogramRWTexture.GetBaseIndex(), NULL);
RHICopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:44,代码来源:PostProcessHistogram.cpp
示例11: SCOPED_DRAW_EVENT
void FRCPassPostProcessHistogram::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessHistogram);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntPoint SrcSize = InputDesc->Extent;
FIntRect DestRect = View.ViewRect;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
TShaderMapRef<FPostProcessHistogramCS> ComputeShader(Context.GetShaderMap());
SetRenderTarget(Context.RHICmdList, FTextureRHIRef(), FTextureRHIRef());
Context.RHICmdList.SetComputeShader(ComputeShader->GetComputeShader());
// set destination
check(DestRenderTarget.UAV);
Context.RHICmdList.TransitionResource(EResourceTransitionAccess::ERWBarrier, EResourceTransitionPipeline::EGfxToCompute, DestRenderTarget.UAV);
Context.RHICmdList.SetUAVParameter(ComputeShader->GetComputeShader(), ComputeShader->HistogramRWTexture.GetBaseIndex(), DestRenderTarget.UAV);
FIntPoint GatherExtent = ComputeGatherExtent(View);
FIntPoint ThreadGroupCountValue = ComputeThreadGroupCount(GatherExtent);
ComputeShader->SetCS(Context.RHICmdList, Context, ThreadGroupCountValue, (DestRect.Min + FIntPoint(1, 1)) / 2, GatherExtent);
DispatchComputeShader(Context.RHICmdList, *ComputeShader, ThreadGroupCountValue.X, ThreadGroupCountValue.Y, 1);
// un-set destination
Context.RHICmdList.SetUAVParameter(ComputeShader->GetComputeShader(), ComputeShader->HistogramRWTexture.GetBaseIndex(), NULL);
Context.RHICmdList.TransitionResource(EResourceTransitionAccess::EReadable, EResourceTransitionPipeline::EComputeToGfx, DestRenderTarget.UAV);
ensureMsgf(DestRenderTarget.TargetableTexture == DestRenderTarget.ShaderResourceTexture, TEXT("%s should be resolved to a separate SRV"), *DestRenderTarget.TargetableTexture->GetName().ToString());
}
开发者ID:WasPedro,项目名称:UnrealEngine4.11-HairWorks,代码行数:43,代码来源:PostProcessHistogram.cpp
示例12: SCOPED_DRAW_EVENT
void FRCPassPostProcessVelocityFlatten::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessVelocityFlatten);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
const FSceneRenderTargetItem& DestRenderTarget0 = PassOutputs[0].RequestSurface(Context);
const FSceneRenderTargetItem& DestRenderTarget1 = PassOutputs[1].RequestSurface(Context);
//const FSceneRenderTargetItem& DestRenderTarget2 = PassOutputs[2].RequestSurface(Context);
TShaderMapRef< FPostProcessVelocityFlattenCS > ComputeShader( Context.GetShaderMap() );
Context.RHICmdList.SetComputeShader(ComputeShader->GetComputeShader());
SetRenderTarget(Context.RHICmdList, FTextureRHIRef(), FTextureRHIRef());
// set destination
Context.RHICmdList.SetUAVParameter( ComputeShader->GetComputeShader(), ComputeShader->OutVelocityFlat.GetBaseIndex(), DestRenderTarget0.UAV );
//Context.RHICmdList.SetUAVParameter( ComputeShader->GetComputeShader(), ComputeShader->OutPackedVelocityDepth.GetBaseIndex(), DestRenderTarget1.UAV );
Context.RHICmdList.SetUAVParameter( ComputeShader->GetComputeShader(), ComputeShader->OutMaxTileVelocity.GetBaseIndex(), DestRenderTarget1.UAV );
ComputeShader->SetCS(Context.RHICmdList, Context, View );
FIntPoint ThreadGroupCountValue = ComputeThreadGroupCount( View.ViewRect.Size() );
DispatchComputeShader(Context.RHICmdList, *ComputeShader, ThreadGroupCountValue.X, ThreadGroupCountValue.Y, 1);
// un-set destination
Context.RHICmdList.SetUAVParameter( ComputeShader->GetComputeShader(), ComputeShader->OutVelocityFlat.GetBaseIndex(), NULL );
//Context.RHICmdList.SetUAVParameter( ComputeShader->GetComputeShader(), ComputeShader->OutPackedVelocityDepth.GetBaseIndex(), NULL );
Context.RHICmdList.SetUAVParameter( ComputeShader->GetComputeShader(), ComputeShader->OutMaxTileVelocity.GetBaseIndex(), NULL );
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget0.TargetableTexture, DestRenderTarget0.ShaderResourceTexture, false, FResolveParams());
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget1.TargetableTexture, DestRenderTarget1.ShaderResourceTexture, false, FResolveParams());
//Context.RHICmdList.CopyToResolveTarget(DestRenderTarget1.TargetableTexture, DestRenderTarget2.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:42,代码来源:PostProcessMotionBlur.cpp
示例13: SCOPED_DRAW_EVENT
void FRCPassPostProcessVisualizeComplexity::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessVisualizeComplexity);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
FIntRect SrcRect = View.ViewRect;
FIntRect DestRect = View.UnscaledViewRect;
FIntPoint SrcSize = InputDesc->Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(DestRect);
// turn off culling and blending
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<FM_Solid, CM_None>::GetRHI());
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
// turn off depth reads/writes
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
//reuse this generic vertex shader
TShaderMapRef<FShaderComplexityApplyVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FShaderComplexityApplyPS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState ShaderComplexityBoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), ShaderComplexityBoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context, Colors);
DrawRectangle(
Context.RHICmdList,
0, 0,
DestRect.Width(), DestRect.Height(),
SrcRect.Min.X, SrcRect.Min.Y,
SrcRect.Width(), SrcRect.Height(),
DestRect.Size(),
SrcSize,
*VertexShader,
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:xiangyuan,项目名称:Unreal4,代码行数:54,代码来源:ShaderComplexityRendering.cpp
示例14: check
void FOculusRiftHMD::CopyTexture_RenderThread(FRHICommandListImmediate& RHICmdList, FTexture2DRHIParamRef DstTexture, FTexture2DRHIParamRef SrcTexture,
FIntRect DstRect, FIntRect SrcRect) const
{
check(IsInRenderingThread());
if (DstRect.IsEmpty())
{
DstRect = FIntRect(0, 0, DstTexture->GetSizeX(), DstTexture->GetSizeY());
}
const uint32 ViewportWidth = DstRect.Width();
const uint32 ViewportHeight = DstRect.Height();
const FIntPoint TargetSize(ViewportWidth, ViewportHeight);
const float SrcTextureWidth = SrcTexture->GetSizeX();
const float SrcTextureHeight = SrcTexture->GetSizeY();
float U = 0.f, V = 0.f, USize = 1.f, VSize = 1.f;
if (!SrcRect.IsEmpty())
{
U = SrcRect.Min.X / SrcTextureWidth;
V = SrcRect.Min.Y / SrcTextureHeight;
USize = SrcRect.Width() / SrcTextureWidth;
VSize = SrcRect.Height() / SrcTextureHeight;
}
SetRenderTarget(RHICmdList, DstTexture, FTextureRHIRef());
RHICmdList.SetViewport(DstRect.Min.X, DstRect.Min.Y, 0, DstRect.Max.X, DstRect.Max.Y, 1.0f);
RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
const auto FeatureLevel = GMaxRHIFeatureLevel;
auto ShaderMap = GetGlobalShaderMap(FeatureLevel);
TShaderMapRef<FScreenVS> VertexShader(ShaderMap);
TShaderMapRef<FScreenPS> PixelShader(ShaderMap);
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(RHICmdList, FeatureLevel, BoundShaderState, RendererModule->GetFilterVertexDeclaration().VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(RHICmdList, TStaticSamplerState<SF_Bilinear>::GetRHI(), SrcTexture);
RendererModule->DrawRectangle(
RHICmdList,
0, 0,
ViewportWidth, ViewportHeight,
U, V,
USize, VSize,
TargetSize,
FIntPoint(1, 1),
*VertexShader,
EDRF_Default);
}
开发者ID:PickUpSU,项目名称:UnrealEngine4,代码行数:53,代码来源:OculusRiftRender.cpp
示例15: SCOPED_DRAW_EVENT
void FRCPassPostProcessSceneColorFringe::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, SceneColorFringe);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(View.ViewRect);
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
TShaderMapRef<FPostProcessSceneColorFringeVS> VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessSceneColorFringePS> PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GFilterVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
PixelShader->SetParameters(Context);
VertexShader->SetParameters(Context);
// Draw a quad mapping scene color to the view's render target
DrawRectangle(
Context.RHICmdList,
0, 0,
View.ViewRect.Width(), View.ViewRect.Height(),
View.ViewRect.Min.X, View.ViewRect.Min.Y,
View.ViewRect.Width(), View.ViewRect.Height(),
View.ViewRect.Size(),
FSceneRenderTargets::Get(Context.RHICmdList).GetBufferSizeXY(),
*VertexShader,
EDRF_UseTriangleOptimization);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:amyvmiwei,项目名称:UnrealEngine4,代码行数:51,代码来源:PostProcessSceneColorFringe.cpp
示例16: VERIFY_GL_SCOPE
void FOpenGLDynamicRHI::RHIBeginDrawingViewport(FViewportRHIParamRef ViewportRHI, FTextureRHIParamRef RenderTarget)
{
VERIFY_GL_SCOPE();
DYNAMIC_CAST_OPENGLRESOURCE(Viewport,Viewport);
SCOPE_CYCLE_COUNTER(STAT_OpenGLPresentTime);
check(!DrawingViewport);
DrawingViewport = Viewport;
bRevertToSharedContextAfterDrawingViewport = false;
EOpenGLCurrentContext CurrentContext = PlatformOpenGLCurrentContext( PlatformDevice );
if( CurrentContext != CONTEXT_Rendering )
{
check(CurrentContext == CONTEXT_Shared);
check(!bIsRenderingContextAcquired || !GUseThreadedRendering);
bRevertToSharedContextAfterDrawingViewport = true;
PlatformRenderingContextSetup(PlatformDevice);
}
if(!GPUProfilingData.FrameTiming.IsInitialized())
{
GPUProfilingData.FrameTiming.InitResource();
}
// Set the render target and viewport.
if( RenderTarget )
{
FRHIRenderTargetView RTV(RenderTarget);
RHISetRenderTargets(1, &RTV, FTextureRHIRef(), 0, NULL);
}
else
{
FRHIRenderTargetView RTV(DrawingViewport->GetBackBuffer());
RHISetRenderTargets(1, &RTV, FTextureRHIRef(), 0, NULL);
}
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:38,代码来源:OpenGLViewport.cpp
示例17: AllocateOrReuseLightShaftRenderTarget
void AllocateOrReuseLightShaftRenderTarget(FRHICommandListImmediate& RHICmdList, TRefCountPtr<IPooledRenderTarget>& Target, const TCHAR* Name)
{
if (!Target)
{
EPixelFormat LightShaftFilterBufferFormat = PF_FloatRGB;
const FIntPoint BufferSize = FSceneRenderTargets::Get(RHICmdList).GetBufferSizeXY();
FIntPoint LightShaftSize(FMath::Max<uint32>(BufferSize.X / GetLightShaftDownsampleFactor(), 1), FMath::Max<uint32>(BufferSize.Y / GetLightShaftDownsampleFactor(), 1));
FPooledRenderTargetDesc Desc(FPooledRenderTargetDesc::Create2DDesc(LightShaftSize, LightShaftFilterBufferFormat, FClearValueBinding::None, TexCreate_None, TexCreate_RenderTargetable, false));
GRenderTargetPool.FindFreeElement(Desc, Target, Name);
SetRenderTarget(RHICmdList, Target->GetRenderTargetItem().TargetableTexture, FTextureRHIRef());
RHICmdList.Clear(true, FLinearColor(0, 0, 0, 0), false, 1.0f, false, 0, FIntRect());
}
}
开发者ID:colwalder,项目名称:unrealengine,代码行数:14,代码来源:LightShaftRendering.cpp
示例18: SCOPED_DRAW_EVENT
void FRCPassPostProcessHMD::Process(FRenderingCompositePassContext& Context)
{
SCOPED_DRAW_EVENT(Context.RHICmdList, PostProcessHMD, DEC_SCENE_ITEMS);
const FPooledRenderTargetDesc* InputDesc = GetInputDesc(ePId_Input0);
if(!InputDesc)
{
// input is not hooked up correctly
return;
}
const FSceneView& View = Context.View;
const FSceneViewFamily& ViewFamily = *(View.Family);
const FIntRect SrcRect = View.ViewRect;
const FIntRect DestRect = View.UnscaledViewRect;
const FIntPoint SrcSize = InputDesc->Extent;
const FSceneRenderTargetItem& DestRenderTarget = PassOutputs[0].RequestSurface(Context);
// Set the view family's render target/viewport.
SetRenderTarget(Context.RHICmdList, DestRenderTarget.TargetableTexture, FTextureRHIRef());
Context.SetViewportAndCallRHI(DestRect);
Context.RHICmdList.Clear(true, FLinearColor::Black, false, 1.0f, false, 0, FIntRect());
// set the state
Context.RHICmdList.SetBlendState(TStaticBlendState<>::GetRHI());
Context.RHICmdList.SetRasterizerState(TStaticRasterizerState<>::GetRHI());
Context.RHICmdList.SetDepthStencilState(TStaticDepthStencilState<false, CF_Always>::GetRHI());
FMatrix QuadTexTransform = FMatrix::Identity;
FMatrix QuadPosTransform = FMatrix::Identity;
check(GEngine->HMDDevice.IsValid());
{
TShaderMapRef<FPostProcessHMDVS<false> > VertexShader(Context.GetShaderMap());
TShaderMapRef<FPostProcessHMDPS<false> > PixelShader(Context.GetShaderMap());
static FGlobalBoundShaderState BoundShaderState;
SetGlobalBoundShaderState(Context.RHICmdList, Context.GetFeatureLevel(), BoundShaderState, GDistortionVertexDeclaration.VertexDeclarationRHI, *VertexShader, *PixelShader);
VertexShader->SetVS(Context, View.StereoPass);
PixelShader->SetPS(Context, SrcRect, SrcSize, View.StereoPass, QuadTexTransform);
}
GEngine->HMDDevice->DrawDistortionMesh_RenderThread(Context, View, SrcSize);
Context.RHICmdList.CopyToResolveTarget(DestRenderTarget.TargetableTexture, DestRenderTarget.ShaderResourceTexture, false, FResolveParams());
}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:49,代码来源:PostProcessHMD.cpp
示例19: GetFrameRate
void UCodecMovieFallback::GetFrame( class FTextureMovieResource* InTextureMovieResource )
{
CurrentTime += 1.f / GetFrameRate();
if( CurrentTime > PlaybackDuration )
{
CurrentTime = 0.f;
}
if( InTextureMovieResource &&
InTextureMovieResource->IsInitialized() )
{
FLinearColor ClearColor(1.f,CurrentTime/PlaybackDuration,0.f,1.f);
RHISetRenderTarget(InTextureMovieResource->GetRenderTargetTexture(),FTextureRHIRef());
RHIClear(true,ClearColor,false,0.f,false,0, FIntRect());
RHICopyToResolveTarget(InTextureMovieResource->GetRenderTargetTexture(),InTextureMovieResource->TextureRHI,false,FResolveParams());
}
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:16,代码来源:MovieCodecs.cpp
示例20: RHICmdList
void FD3D11DynamicRHI::IssueLongGPUTask()
{
if (GMaxRHIFeatureLevel >= ERHIFeatureLevel::SM4)
{
int32 LargestViewportIndex = INDEX_NONE;
int32 LargestViewportPixels = 0;
for (int32 ViewportIndex = 0; ViewportIndex < Viewports.Num(); ViewportIndex++)
{
FD3D11Viewport* Viewport = Viewports[ViewportIndex];
if (Viewport->GetSizeXY().X * Viewport->GetSizeXY().Y > LargestViewportPixels)
{
LargestViewportPixels = Viewport->GetSizeXY().X * Viewport->GetSizeXY().Y;
LargestViewportIndex = ViewportIndex;
}
}
if (LargestViewportIndex >= 0)
{
FD3D11Viewport* Viewport = Viewp
|
请发表评论