Files
UnrealEngineUWP/Engine/Source/Runtime/RenderCore/Public/GenerateMips.h
thomas engel bb744b5f4b Further fixup work for circular ref / leak when using FGenerateMips::Execute() - parameters are now regenerate each time unless an external cache for them is provided by the caller
#jira UE-86234
#rb job.cain


#ROBOMERGE-SOURCE: CL 10950878 via CL 10950882 via CL 10950884
#ROBOMERGE-BOT: (v632-10940481)

[CL 10950885 by thomas engel in Main branch]
2020-01-13 08:00:57 -05:00

47 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GlobalShader.h"
struct FGenerateMipsStruct;
/** Parameters for generating mip maps */
struct FGenerateMipsParams
{
ESamplerFilter Filter = SF_Bilinear;
ESamplerAddressMode AddressU = AM_Clamp;
ESamplerAddressMode AddressV = AM_Clamp;
ESamplerAddressMode AddressW = AM_Clamp;
};
class RENDERCORE_API FGenerateMips
{
public:
/**
* Public function for executing the generate mips compute shader
* @param RHICmdList RHI command list to use to schedule generation of mips
* @param InTexture Texture to generate mips for
* @param InParams Parameters influencing mips generation (Default sampler is always bilinear clamp)
* @param ExternalMipsStructCache Shared pointer to provide a location to cache internal parameters and resource needed to generate mips (provide if generation is triggered repeatedly)
* @param bAllowRenderBasedGeneration Set to true if generation via classic rendering is allowable (some platforms do not support compute based generation, but some use cases may disallow this)
*/
static void Execute(FRHICommandListImmediate& RHICmdList, FRHITexture* InTexture, TSharedPtr<FGenerateMipsStruct> & ExternalMipsStructCache, const FGenerateMipsParams& InParams = FGenerateMipsParams(), bool bAllowRenderBasedGeneration = false)
{
ExecuteInternal(RHICmdList, InTexture, InParams, &ExternalMipsStructCache, bAllowRenderBasedGeneration);
}
static void Execute(FRHICommandListImmediate& RHICmdList, FRHITexture* InTexture, const FGenerateMipsParams& InParams = FGenerateMipsParams(), bool bAllowRenderBasedGeneration = false)
{
ExecuteInternal(RHICmdList, InTexture, InParams, nullptr, bAllowRenderBasedGeneration);
}
static void Execute(class FRDGBuilder* GraphBuilder, class FRDGTexture* InGraphTexture, FRHISamplerState* InSampler);
private:
static void ExecuteInternal(FRHICommandListImmediate& RHICmdList, FRHITexture* InTexture, const FGenerateMipsParams& InParams, TSharedPtr<FGenerateMipsStruct> * ExternalMipsStructCache, bool bAllowRenderBasedGeneration);
static void Compute(FRHICommandListImmediate& RHIImmCmdList, FRHITexture* InTexture, TSharedPtr<FGenerateMipsStruct> GenMipsStruct);
static TSharedPtr<FGenerateMipsStruct> SetupTexture(FRHITexture* InTexture, const FGenerateMipsParams& InParams = FGenerateMipsParams());
static void RenderMips(FRHICommandListImmediate& RHICmdList, FRHITexture* InTexture, const FGenerateMipsParams& InParams, TSharedPtr<FGenerateMipsStruct> * ExternalMipsStructCache);
static void SetupRendering(FGenerateMipsStruct *GenMipsStruct, FRHITexture* InTexture, const FGenerateMipsParams& InParams);
};