2023-04-28 15:57:31 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "MuT/ASTOpReferenceResource.h"
|
|
|
|
|
|
2023-11-20 04:22:10 -05:00
|
|
|
#include "MuT/ASTOpConstantResource.h"
|
2023-04-28 15:57:31 -04:00
|
|
|
#include "Containers/Array.h"
|
|
|
|
|
#include "HAL/PlatformMath.h"
|
|
|
|
|
#include "Misc/AssertionMacros.h"
|
|
|
|
|
#include "MuR/Types.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace mu
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
void ASTOpReferenceResource::ForEachChild(const TFunctionRef<void(ASTChild&)>)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|
bool ASTOpReferenceResource::IsEqual(const ASTOp& otherUntyped) const
|
|
|
|
|
{
|
2024-01-18 03:27:38 -05:00
|
|
|
if (otherUntyped.GetOpType() == GetOpType())
|
2023-04-28 15:57:31 -04:00
|
|
|
{
|
2024-01-18 03:27:38 -05:00
|
|
|
const ASTOpReferenceResource* other = static_cast<const ASTOpReferenceResource*>(&otherUntyped);
|
2023-10-05 04:46:46 -04:00
|
|
|
return type == other->type && ID == other->ID && bForceLoad == other->bForceLoad && ImageDesc == other->ImageDesc;
|
2023-04-28 15:57:31 -04:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|
mu::Ptr<ASTOp> ASTOpReferenceResource::Clone(MapChildFuncRef) const
|
|
|
|
|
{
|
|
|
|
|
Ptr<ASTOpReferenceResource> n = new ASTOpReferenceResource();
|
|
|
|
|
n->type = type;
|
|
|
|
|
n->ID = ID;
|
2023-10-05 04:46:46 -04:00
|
|
|
n->bForceLoad = bForceLoad;
|
|
|
|
|
n->ImageDesc = ImageDesc;
|
2023-04-28 15:57:31 -04:00
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|
uint64 ASTOpReferenceResource::Hash() const
|
|
|
|
|
{
|
|
|
|
|
uint64 res = std::hash<uint64>()(uint64(type));
|
|
|
|
|
hash_combine(res, ID);
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
2023-07-28 04:00:17 -04:00
|
|
|
void ASTOpReferenceResource::Link(FProgram& program, FLinkerOptions* Options)
|
2023-04-28 15:57:31 -04:00
|
|
|
{
|
|
|
|
|
if (!linkedAddress)
|
2024-02-12 05:31:15 -05:00
|
|
|
{
|
2023-04-28 15:57:31 -04:00
|
|
|
OP::ResourceReferenceArgs Args;
|
|
|
|
|
FMemory::Memset(&Args, 0, sizeof(Args));
|
|
|
|
|
Args.ID = ID;
|
2024-02-12 05:31:15 -05:00
|
|
|
Args.ForceLoad = bForceLoad ? 1 : 0;
|
2023-10-05 04:46:46 -04:00
|
|
|
Args.ImageDesc = ImageDesc;
|
2023-04-28 15:57:31 -04:00
|
|
|
|
|
|
|
|
linkedAddress = (OP::ADDRESS)program.m_opAddress.Num();
|
|
|
|
|
program.m_opAddress.Add((uint32)program.m_byteCode.Num());
|
|
|
|
|
AppendCode(program.m_byteCode, type);
|
|
|
|
|
AppendCode(program.m_byteCode, Args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|
FImageDesc ASTOpReferenceResource::GetImageDesc(bool, class FGetImageDescContext*) const
|
|
|
|
|
{
|
2023-11-27 06:23:14 -05:00
|
|
|
return ImageDesc;
|
2023-04-28 15:57:31 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
2024-05-13 03:20:24 -04:00
|
|
|
void ASTOpReferenceResource::GetBlockLayoutSize(uint64 BlockId, int32* pBlockX, int32* pBlockY, FBlockLayoutSizeCache*)
|
2023-04-28 15:57:31 -04:00
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case OP_TYPE::IM_REFERENCE:
|
|
|
|
|
{
|
|
|
|
|
*pBlockX = 0;
|
|
|
|
|
*pBlockY = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
checkf(false, TEXT("Instruction not supported"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
2024-05-13 03:20:24 -04:00
|
|
|
void ASTOpReferenceResource::GetLayoutBlockSize(int32* pBlockX, int32* pBlockY)
|
2023-04-28 15:57:31 -04:00
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case OP_TYPE::IM_REFERENCE:
|
|
|
|
|
{
|
|
|
|
|
// We didn't find any layout.
|
|
|
|
|
*pBlockX = 0;
|
|
|
|
|
*pBlockY = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
checkf(false, TEXT("Instruction not supported"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------------------
|
|
|
|
|
bool ASTOpReferenceResource::GetNonBlackRect(FImageRect&) const
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mu::Ptr<ImageSizeExpression> ASTOpReferenceResource::GetImageSizeExpression() const
|
|
|
|
|
{
|
|
|
|
|
Ptr<ImageSizeExpression> pRes = new ImageSizeExpression;
|
|
|
|
|
pRes->type = ImageSizeExpression::ISET_UNKNOWN;
|
|
|
|
|
|
|
|
|
|
return pRes;
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-20 04:22:10 -05:00
|
|
|
|
2024-06-13 04:48:11 -04:00
|
|
|
FSourceDataDescriptor ASTOpReferenceResource::GetSourceDataDescriptor(FGetSourceDataDescriptorContext*) const
|
|
|
|
|
{
|
|
|
|
|
return SourceDataDescriptor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-04-28 15:57:31 -04:00
|
|
|
}
|