Serialisation for MTLLibary::newFunctionWithName

This commit is contained in:
Jake Turner
2022-03-22 05:09:19 +00:00
committed by Baldur Karlsson
parent 0d58ae8c2e
commit 7de4345426
3 changed files with 55 additions and 2 deletions
+50
View File
@@ -32,3 +32,53 @@ WrappedMTLLibrary::WrappedMTLLibrary(MTL::Library *realMTLLibrary, ResourceId ob
{
objcBridge = AllocateObjCBridge(this);
}
template <typename SerialiserType>
bool WrappedMTLLibrary::Serialise_newFunctionWithName(SerialiserType &ser,
WrappedMTLFunction *function,
NS::String *FunctionName)
{
SERIALISE_ELEMENT_LOCAL(Library, this);
SERIALISE_ELEMENT_LOCAL(Function, GetResID(function)).TypedAs("MTLFunction"_lit);
SERIALISE_ELEMENT(FunctionName).Important();
SERIALISE_CHECK_READ_ERRORS();
// TODO: implement RD MTL replay
if(IsReplayingAndReading())
{
}
return true;
}
WrappedMTLFunction *WrappedMTLLibrary::newFunctionWithName(NS::String *functionName)
{
MTL::Function *realMTLFunction;
SERIALISE_TIME_CALL(realMTLFunction = Unwrap(this)->newFunction(functionName));
WrappedMTLFunction *wrappedMTLFunction;
ResourceId id = GetResourceManager()->WrapResource(realMTLFunction, wrappedMTLFunction);
if(IsCaptureMode(m_State))
{
Chunk *chunk = NULL;
{
CACHE_THREAD_SERIALISER();
SCOPED_SERIALISE_CHUNK(MetalChunk::MTLLibrary_newFunctionWithName);
Serialise_newFunctionWithName(ser, wrappedMTLFunction, functionName);
chunk = scope.Get();
}
MetalResourceRecord *record = GetResourceManager()->AddResourceRecord(wrappedMTLFunction);
record->AddChunk(chunk);
GetResourceManager()->MarkResourceFrameReferenced(id, eFrameRef_Read);
record->AddParent(GetRecord(this));
}
else
{
// TODO: implement RD MTL replay
}
return wrappedMTLFunction;
}
INSTANTIATE_FUNCTION_WITH_RETURN_SERIALISED(WrappedMTLLibrary, WrappedMTLFunction *function,
newFunctionWithName, NS::String *functionName);
+3
View File
@@ -32,6 +32,9 @@ public:
WrappedMTLLibrary(MTL::Library *realMTLLibrary, ResourceId objId,
WrappedMTLDevice *wrappedMTLDevice);
DECLARE_FUNCTION_WITH_RETURN_SERIALISED(WrappedMTLFunction *, newFunctionWithName,
NS::String *functionName);
enum
{
TypeEnum = eResLibrary
@@ -78,8 +78,8 @@
- (nullable id<MTLFunction>)newFunctionWithName:(NSString *)functionName
{
METAL_NOT_HOOKED();
return [self.real newFunctionWithName:functionName];
return id<MTLFunction>(
GetObjCBridge(self.wrappedCPP->newFunctionWithName((NS::String *)functionName)));
}
- (nullable id<MTLFunction>)newFunctionWithName:(NSString *)name