Files
UnrealEngineUWP/Engine/Source/Runtime/SlateRHIRenderer/Private/SlateMaterialResource.h
nick darnell fdd0e1a254 Slate - Adding more debugging and an alternative path for getting the material proxy on the render thread. In rare cases seeing materials being GCed, adding additiona debugging to try and trace that down.
#ROBOMERGE-SOURCE: CL 12341733 via CL 12341750 via CL 12342073 via CL 12342088
#ROBOMERGE-BOT: (v671-12333473)

[CL 12342141 by nick darnell in Main branch]
2020-03-20 14:03:45 -04:00

68 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Textures/SlateShaderResource.h"
#include "Materials/MaterialInterface.h"
class FMaterialRenderProxy;
/**
* A resource for rendering a UMaterial in Slate
*/
class FSlateMaterialResource : public FSlateShaderResource
{
public:
FSlateMaterialResource(const UMaterialInterface& InMaterialResource, const FVector2D& InImageSize, FSlateShaderResource* InTextureMask = nullptr );
~FSlateMaterialResource();
virtual uint32 GetWidth() const override { return Width; }
virtual uint32 GetHeight() const override { return Height; }
virtual ESlateShaderResource::Type GetType() const override { return ESlateShaderResource::Material; }
void UpdateMaterial(const UMaterialInterface& InMaterialResource, const FVector2D& InImageSize, FSlateShaderResource* InTextureMask );
void ResetMaterial();
/** @return The material render proxy */
FMaterialRenderProxy* GetRenderProxy() const { return MaterialProxy; }
/** @return the material object */
const UMaterialInterface* GetMaterialObject() const
{
return MaterialObject;
}
/** Slate proxy used for batching the material */
FSlateShaderResourceProxy* GetResourceProxy() const { return SlateProxy; }
FSlateShaderResource* GetTextureMaskResource() const { return TextureMaskResource; }
#if SLATE_CHECK_UOBJECT_RENDER_RESOURCES
virtual void CheckForStaleResources() const override;
#endif
private:
const class UMaterialInterface* MaterialObject;
class FMaterialRenderProxy* MaterialProxy;
#if SLATE_CHECK_UOBJECT_RENDER_RESOURCES
// Used to guard against crashes when the material object is deleted. This is expensive so we do not do it in shipping
TWeakObjectPtr<const UMaterialInterface> MaterialObjectWeakPtr;
FName DebugName;
#endif
/** Slate proxy used for batching the material */
FSlateShaderResourceProxy* SlateProxy;
FSlateShaderResource* TextureMaskResource;
uint32 Width;
uint32 Height;
private:
#if SLATE_CHECK_UOBJECT_RENDER_RESOURCES
void UpdateMaterialName();
#endif
};