diff --git a/renderdoc/driver/metal/metal_serialise.cpp b/renderdoc/driver/metal/metal_serialise.cpp index c85130e5f..db6e61e3c 100644 --- a/renderdoc/driver/metal/metal_serialise.cpp +++ b/renderdoc/driver/metal/metal_serialise.cpp @@ -226,6 +226,14 @@ void DoSerialise(SerialiserType &ser, RDMTL::VertexDescriptor &el) SERIALISE_MEMBER(attributes); } +template +void DoSerialise(SerialiserType &ser, RDMTL::AttributeDescriptor &el) +{ + SERIALISE_MEMBER(bufferIndex); + SERIALISE_MEMBER(offset); + SERIALISE_MEMBER(format); +} + template void DoSerialise(SerialiserType &ser, RDMTL::FunctionGroup &el) { @@ -368,6 +376,7 @@ INSTANTIATE_SERIALISE_TYPE(RDMTL::PipelineBufferDescriptor); INSTANTIATE_SERIALISE_TYPE(RDMTL::VertexAttributeDescriptor); INSTANTIATE_SERIALISE_TYPE(RDMTL::VertexBufferLayoutDescriptor); INSTANTIATE_SERIALISE_TYPE(RDMTL::VertexDescriptor); +INSTANTIATE_SERIALISE_TYPE(RDMTL::AttributeDescriptor); INSTANTIATE_SERIALISE_TYPE(RDMTL::FunctionGroup); INSTANTIATE_SERIALISE_TYPE(RDMTL::LinkedFunctions); INSTANTIATE_SERIALISE_TYPE(RDMTL::RenderPipelineDescriptor); diff --git a/renderdoc/driver/metal/metal_stringise.cpp b/renderdoc/driver/metal/metal_stringise.cpp index fd1f90033..93ce9a5f0 100644 --- a/renderdoc/driver/metal/metal_stringise.cpp +++ b/renderdoc/driver/metal/metal_stringise.cpp @@ -1136,6 +1136,70 @@ rdcstr DoStringise(const MTL::IndexType &el) END_ENUM_STRINGISE() } +template <> +rdcstr DoStringise(const MTL::AttributeFormat &el) +{ + BEGIN_ENUM_STRINGISE(MTL::AttributeFormat) + { + MTL_STRINGISE_ENUM(AttributeFormatInvalid); + MTL_STRINGISE_ENUM(AttributeFormatUChar2); + MTL_STRINGISE_ENUM(AttributeFormatUChar3); + MTL_STRINGISE_ENUM(AttributeFormatUChar4); + MTL_STRINGISE_ENUM(AttributeFormatChar2); + MTL_STRINGISE_ENUM(AttributeFormatChar3); + MTL_STRINGISE_ENUM(AttributeFormatChar4); + MTL_STRINGISE_ENUM(AttributeFormatUChar2Normalized); + MTL_STRINGISE_ENUM(AttributeFormatUChar3Normalized); + MTL_STRINGISE_ENUM(AttributeFormatUChar4Normalized); + MTL_STRINGISE_ENUM(AttributeFormatChar2Normalized); + MTL_STRINGISE_ENUM(AttributeFormatChar3Normalized); + MTL_STRINGISE_ENUM(AttributeFormatChar4Normalized); + MTL_STRINGISE_ENUM(AttributeFormatUShort2); + MTL_STRINGISE_ENUM(AttributeFormatUShort3); + MTL_STRINGISE_ENUM(AttributeFormatUShort4); + MTL_STRINGISE_ENUM(AttributeFormatShort2); + MTL_STRINGISE_ENUM(AttributeFormatShort3); + MTL_STRINGISE_ENUM(AttributeFormatShort4); + MTL_STRINGISE_ENUM(AttributeFormatUShort2Normalized); + MTL_STRINGISE_ENUM(AttributeFormatUShort3Normalized); + MTL_STRINGISE_ENUM(AttributeFormatUShort4Normalized); + MTL_STRINGISE_ENUM(AttributeFormatShort2Normalized); + MTL_STRINGISE_ENUM(AttributeFormatShort3Normalized); + MTL_STRINGISE_ENUM(AttributeFormatShort4Normalized); + MTL_STRINGISE_ENUM(AttributeFormatHalf2); + MTL_STRINGISE_ENUM(AttributeFormatHalf3); + MTL_STRINGISE_ENUM(AttributeFormatHalf4); + MTL_STRINGISE_ENUM(AttributeFormatFloat); + MTL_STRINGISE_ENUM(AttributeFormatFloat2); + MTL_STRINGISE_ENUM(AttributeFormatFloat3); + MTL_STRINGISE_ENUM(AttributeFormatFloat4); + MTL_STRINGISE_ENUM(AttributeFormatInt); + MTL_STRINGISE_ENUM(AttributeFormatInt2); + MTL_STRINGISE_ENUM(AttributeFormatInt3); + MTL_STRINGISE_ENUM(AttributeFormatInt4); + MTL_STRINGISE_ENUM(AttributeFormatUInt); + MTL_STRINGISE_ENUM(AttributeFormatUInt2); + MTL_STRINGISE_ENUM(AttributeFormatUInt3); + MTL_STRINGISE_ENUM(AttributeFormatUInt4); + MTL_STRINGISE_ENUM(AttributeFormatInt1010102Normalized); + MTL_STRINGISE_ENUM(AttributeFormatUInt1010102Normalized); + MTL_STRINGISE_ENUM(AttributeFormatUChar4Normalized_BGRA); + MTL_STRINGISE_ENUM(AttributeFormatUChar); + MTL_STRINGISE_ENUM(AttributeFormatChar); + MTL_STRINGISE_ENUM(AttributeFormatUCharNormalized); + MTL_STRINGISE_ENUM(AttributeFormatCharNormalized); + MTL_STRINGISE_ENUM(AttributeFormatUShort); + MTL_STRINGISE_ENUM(AttributeFormatShort); + MTL_STRINGISE_ENUM(AttributeFormatUShortNormalized); + MTL_STRINGISE_ENUM(AttributeFormatShortNormalized); + MTL_STRINGISE_ENUM(AttributeFormatHalf); + // TODO: When metal-cpp is updated to SDK 14.x + // MTL_STRINGISE_ENUM(AttributeFormatFloatRG11B10); + // MTL_STRINGISE_ENUM(AttributeFormatFloatRGB9E5); + } + END_ENUM_STRINGISE() +} + template <> rdcstr DoStringise(const MetalResourceType &el) { diff --git a/renderdoc/driver/metal/metal_types.cpp b/renderdoc/driver/metal/metal_types.cpp index f7e3240df..6f81fad31 100644 --- a/renderdoc/driver/metal/metal_types.cpp +++ b/renderdoc/driver/metal/metal_types.cpp @@ -322,6 +322,18 @@ void VertexDescriptor::CopyTo(MTL::VertexDescriptor *objc) COPYTOOBJCARRAY(VertexAttributeDescriptor, attributes); } +AttributeDescriptor::AttributeDescriptor(MTL::AttributeDescriptor *objc) + : bufferIndex(objc->bufferIndex()), offset(objc->offset()), format(objc->format()) +{ +} + +void AttributeDescriptor::CopyTo(MTL::AttributeDescriptor *objc) +{ + objc->setBufferIndex(bufferIndex); + objc->setOffset(offset); + objc->setFormat(format); +} + LinkedFunctions::LinkedFunctions(MTL::LinkedFunctions *objc) { GETWRAPPEDNSARRAY(Function, functions); diff --git a/renderdoc/driver/metal/metal_types.h b/renderdoc/driver/metal/metal_types.h index 1685e54ee..e14720c03 100644 --- a/renderdoc/driver/metal/metal_types.h +++ b/renderdoc/driver/metal/metal_types.h @@ -163,6 +163,7 @@ MTL_DECLARE_REFLECTION_TYPE(DepthClipMode); MTL_DECLARE_REFLECTION_TYPE(TriangleFillMode); MTL_DECLARE_REFLECTION_TYPE(CullMode); MTL_DECLARE_REFLECTION_TYPE(IndexType); +MTL_DECLARE_REFLECTION_TYPE(AttributeFormat); template <> inline rdcliteral TypeName() @@ -262,6 +263,18 @@ struct VertexDescriptor rdcarray attributes; }; +// MTLAttributeDescriptor : based on the interface defined in +// Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk/System/Library/Frameworks/Metal.framework/Headers/MTLStageInputOutputDescriptor.h +struct AttributeDescriptor +{ + AttributeDescriptor() = default; + AttributeDescriptor(MTL::AttributeDescriptor *objc); + void CopyTo(MTL::AttributeDescriptor *objc); + NS::UInteger bufferIndex = 0; + NS::UInteger offset = 0; + MTL::AttributeFormat format = MTL::AttributeFormatInvalid; +}; + // Helper struct for holding MTLLinkedFunctions::groups data // NSDictionary>*> *groups; struct FunctionGroup @@ -459,6 +472,7 @@ RDMTL_DECLARE_REFLECTION_STRUCT(PipelineBufferDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(VertexAttributeDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(VertexBufferLayoutDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(VertexDescriptor); +RDMTL_DECLARE_REFLECTION_STRUCT(AttributeDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(FunctionGroup); RDMTL_DECLARE_REFLECTION_STRUCT(LinkedFunctions); RDMTL_DECLARE_REFLECTION_STRUCT(RenderPipelineDescriptor);