mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Use RDCMTL descriptor structs C++ wrapped APIs
Create the RDCMTL descriptor struct in the ObjC hook and pass it to the C++ wrapped APIs ie. WrappedMTLDevice::newTextureWithDescriptor takes a RDMTL::TextureDescriptor & WrappedMTLDevice::newRenderPipelineStateWithDescriptor takes a RDMTL::RenderPipelineDescriptor & This means the wrapping and unwrapping of resources in the descriptor structs is handled by the conversion methods for the structs
This commit is contained in:
committed by
Baldur Karlsson
parent
3baa24407a
commit
cb98a133bf
@@ -256,25 +256,9 @@ bool WrappedMTLDevice::Serialise_newRenderPipelineStateWithDescriptor(
|
||||
}
|
||||
|
||||
WrappedMTLRenderPipelineState *WrappedMTLDevice::newRenderPipelineStateWithDescriptor(
|
||||
MTL::RenderPipelineDescriptor *descriptor, NS::Error **error)
|
||||
RDMTL::RenderPipelineDescriptor &descriptor, NS::Error **error)
|
||||
{
|
||||
MTL::RenderPipelineDescriptor *realDescriptor = descriptor->copy();
|
||||
|
||||
// realDescriptor needs the real resources
|
||||
// TODO: need to unwrap more resources see
|
||||
// RenderPipelineDescriptor::operator MTL::RenderPipelineDescriptor *()
|
||||
WrappedMTLFunction *wrappedVertexFunction = GetWrapped(descriptor->vertexFunction());
|
||||
if(wrappedVertexFunction != NULL)
|
||||
{
|
||||
realDescriptor->setVertexFunction(Unwrap(wrappedVertexFunction));
|
||||
}
|
||||
|
||||
WrappedMTLFunction *wrappedFragmentFunction = GetWrapped(descriptor->fragmentFunction());
|
||||
if(wrappedFragmentFunction != NULL)
|
||||
{
|
||||
realDescriptor->setFragmentFunction(Unwrap(wrappedFragmentFunction));
|
||||
}
|
||||
|
||||
MTL::RenderPipelineDescriptor *realDescriptor(descriptor);
|
||||
MTL::RenderPipelineState *realMTLRenderPipelineState;
|
||||
SERIALISE_TIME_CALL(realMTLRenderPipelineState =
|
||||
Unwrap(this)->newRenderPipelineState(realDescriptor, error));
|
||||
@@ -289,22 +273,21 @@ WrappedMTLRenderPipelineState *WrappedMTLDevice::newRenderPipelineStateWithDescr
|
||||
{
|
||||
CACHE_THREAD_SERIALISER();
|
||||
SCOPED_SERIALISE_CHUNK(MetalChunk::MTLDevice_newRenderPipelineStateWithDescriptor);
|
||||
RDMTL::RenderPipelineDescriptor rdDescriptor(descriptor);
|
||||
Serialise_newRenderPipelineStateWithDescriptor(ser, wrappedMTLRenderPipelineState,
|
||||
rdDescriptor, error);
|
||||
Serialise_newRenderPipelineStateWithDescriptor(ser, wrappedMTLRenderPipelineState, descriptor,
|
||||
error);
|
||||
chunk = scope.Get();
|
||||
}
|
||||
|
||||
MetalResourceRecord *record =
|
||||
GetResourceManager()->AddResourceRecord(wrappedMTLRenderPipelineState);
|
||||
record->AddChunk(chunk);
|
||||
if(wrappedVertexFunction)
|
||||
if(descriptor.vertexFunction)
|
||||
{
|
||||
record->AddParent(GetRecord(wrappedVertexFunction));
|
||||
record->AddParent(GetRecord(descriptor.vertexFunction));
|
||||
}
|
||||
if(wrappedFragmentFunction)
|
||||
if(descriptor.fragmentFunction)
|
||||
{
|
||||
record->AddParent(GetRecord(wrappedFragmentFunction));
|
||||
record->AddParent(GetRecord(descriptor.fragmentFunction));
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -331,13 +314,13 @@ bool WrappedMTLDevice::Serialise_newTextureWithDescriptor(SerialiserType &ser,
|
||||
return true;
|
||||
}
|
||||
|
||||
WrappedMTLTexture *WrappedMTLDevice::newTextureWithDescriptor(MTL::TextureDescriptor *descriptor)
|
||||
WrappedMTLTexture *WrappedMTLDevice::newTextureWithDescriptor(RDMTL::TextureDescriptor &descriptor)
|
||||
{
|
||||
return Common_NewTexture(descriptor, MetalChunk::MTLDevice_newTextureWithDescriptor, false, NULL,
|
||||
0);
|
||||
}
|
||||
|
||||
WrappedMTLTexture *WrappedMTLDevice::newTextureWithDescriptor(MTL::TextureDescriptor *descriptor,
|
||||
WrappedMTLTexture *WrappedMTLDevice::newTextureWithDescriptor(RDMTL::TextureDescriptor &descriptor,
|
||||
IOSurfaceRef iosurface,
|
||||
NS::UInteger plane)
|
||||
{
|
||||
@@ -479,14 +462,16 @@ bool WrappedMTLDevice::supportsPrimitiveMotionBlur()
|
||||
|
||||
// End of MTLDevice APIs
|
||||
|
||||
WrappedMTLTexture *WrappedMTLDevice::Common_NewTexture(MTL::TextureDescriptor *descriptor,
|
||||
WrappedMTLTexture *WrappedMTLDevice::Common_NewTexture(RDMTL::TextureDescriptor &descriptor,
|
||||
MetalChunk chunkType, bool ioSurfaceTexture,
|
||||
IOSurfaceRef iosurface, NS::UInteger plane)
|
||||
{
|
||||
MTL::Texture *realMTLTexture;
|
||||
SERIALISE_TIME_CALL(realMTLTexture = !ioSurfaceTexture
|
||||
? Unwrap(this)->newTexture(descriptor)
|
||||
: Unwrap(this)->newTexture(descriptor, iosurface, plane));
|
||||
MTL::TextureDescriptor *realDescriptor(descriptor);
|
||||
SERIALISE_TIME_CALL(realMTLTexture = !ioSurfaceTexture ? Unwrap(this)->newTexture(realDescriptor)
|
||||
: Unwrap(this)->newTexture(
|
||||
realDescriptor, iosurface, plane));
|
||||
realDescriptor->release();
|
||||
WrappedMTLTexture *wrappedMTLTexture;
|
||||
ResourceId id = GetResourceManager()->WrapResource(realMTLTexture, wrappedMTLTexture);
|
||||
if(IsCaptureMode(m_State))
|
||||
|
||||
@@ -42,18 +42,13 @@ public:
|
||||
DECLARE_FUNCTION_WITH_RETURN_SERIALISED(WrappedMTLLibrary *, newLibraryWithSource,
|
||||
NS::String *source, MTL::CompileOptions *options,
|
||||
NS::Error **error);
|
||||
WrappedMTLRenderPipelineState *newRenderPipelineStateWithDescriptor(
|
||||
MTL::RenderPipelineDescriptor *descriptor, NS::Error **error);
|
||||
template <typename SerialiserType>
|
||||
bool Serialise_newRenderPipelineStateWithDescriptor(SerialiserType &ser,
|
||||
WrappedMTLRenderPipelineState *,
|
||||
RDMTL::RenderPipelineDescriptor &descriptor,
|
||||
NS::Error **error);
|
||||
WrappedMTLTexture *newTextureWithDescriptor(MTL::TextureDescriptor *descriptor,
|
||||
DECLARE_FUNCTION_WITH_RETURN_SERIALISED(WrappedMTLRenderPipelineState *,
|
||||
newRenderPipelineStateWithDescriptor,
|
||||
RDMTL::RenderPipelineDescriptor &descriptor,
|
||||
NS::Error **error);
|
||||
WrappedMTLTexture *newTextureWithDescriptor(RDMTL::TextureDescriptor &descriptor,
|
||||
IOSurfaceRef iosurface, NS::UInteger plane);
|
||||
WrappedMTLTexture *newTextureWithDescriptor(MTL::TextureDescriptor *descriptor);
|
||||
template <typename SerialiserType>
|
||||
bool Serialise_newTextureWithDescriptor(SerialiserType &ser, WrappedMTLTexture *,
|
||||
DECLARE_FUNCTION_WITH_RETURN_SERIALISED(WrappedMTLTexture *, newTextureWithDescriptor,
|
||||
RDMTL::TextureDescriptor &descriptor);
|
||||
|
||||
// Non-Serialised MTLDevice APIs
|
||||
@@ -108,7 +103,7 @@ private:
|
||||
void Create_InitialState(ResourceId id, WrappedMTLObject *live, bool hasData);
|
||||
void Apply_InitialState(WrappedMTLObject *live, const MetalInitialContents &initial);
|
||||
|
||||
WrappedMTLTexture *Common_NewTexture(MTL::TextureDescriptor *descriptor, MetalChunk chunkType,
|
||||
WrappedMTLTexture *Common_NewTexture(RDMTL::TextureDescriptor &descriptor, MetalChunk chunkType,
|
||||
bool ioSurfaceTexture, IOSurfaceRef iosurface,
|
||||
NS::UInteger plane);
|
||||
|
||||
|
||||
@@ -257,8 +257,8 @@
|
||||
|
||||
- (nullable id<MTLTexture>)newTextureWithDescriptor:(MTLTextureDescriptor *)descriptor
|
||||
{
|
||||
return id<MTLTexture>(
|
||||
GetWrapped(self)->newTextureWithDescriptor((MTL::TextureDescriptor *)descriptor));
|
||||
RDMTL::TextureDescriptor rdDescriptor((MTL::TextureDescriptor *)descriptor);
|
||||
return id<MTLTexture>(GetWrapped(self)->newTextureWithDescriptor(rdDescriptor));
|
||||
}
|
||||
|
||||
- (nullable id<MTLTexture>)newTextureWithDescriptor:(MTLTextureDescriptor *)descriptor
|
||||
@@ -266,8 +266,8 @@
|
||||
plane:(NSUInteger)plane
|
||||
API_AVAILABLE(macos(10.11), ios(11.0))
|
||||
{
|
||||
return id<MTLTexture>(GetWrapped(self)->newTextureWithDescriptor(
|
||||
(MTL::TextureDescriptor *)descriptor, iosurface, plane));
|
||||
RDMTL::TextureDescriptor rdDescriptor((MTL::TextureDescriptor *)descriptor);
|
||||
return id<MTLTexture>(GetWrapped(self)->newTextureWithDescriptor(rdDescriptor, iosurface, plane));
|
||||
}
|
||||
|
||||
- (nullable id<MTLTexture>)newSharedTextureWithDescriptor:(MTLTextureDescriptor *)descriptor
|
||||
@@ -366,8 +366,9 @@
|
||||
newRenderPipelineStateWithDescriptor:(MTLRenderPipelineDescriptor *)descriptor
|
||||
error:(__autoreleasing NSError **)error
|
||||
{
|
||||
return id<MTLRenderPipelineState>(GetWrapped(self)->newRenderPipelineStateWithDescriptor(
|
||||
(MTL::RenderPipelineDescriptor *)descriptor, (NS::Error **)error));
|
||||
RDMTL::RenderPipelineDescriptor rdDescriptor((MTL::RenderPipelineDescriptor *)descriptor);
|
||||
return id<MTLRenderPipelineState>(
|
||||
GetWrapped(self)->newRenderPipelineStateWithDescriptor(rdDescriptor, (NS::Error **)error));
|
||||
}
|
||||
|
||||
- (nullable id<MTLRenderPipelineState>)
|
||||
|
||||
Reference in New Issue
Block a user