From 70793c4f0a0ce184d4cc1d5e162849b49a9a08e6 Mon Sep 17 00:00:00 2001 From: Isaac Marovitz Date: Sun, 21 Jan 2024 13:03:00 -0500 Subject: [PATCH] MTLBufferLayoutDescriptor --- renderdoc/driver/metal/metal_serialise.cpp | 9 +++++++++ renderdoc/driver/metal/metal_stringise.cpp | 18 ++++++++++++++++++ renderdoc/driver/metal/metal_types.cpp | 12 ++++++++++++ renderdoc/driver/metal/metal_types.h | 14 ++++++++++++++ 4 files changed, 53 insertions(+) diff --git a/renderdoc/driver/metal/metal_serialise.cpp b/renderdoc/driver/metal/metal_serialise.cpp index db6e61e3c..d390ca459 100644 --- a/renderdoc/driver/metal/metal_serialise.cpp +++ b/renderdoc/driver/metal/metal_serialise.cpp @@ -234,6 +234,14 @@ void DoSerialise(SerialiserType &ser, RDMTL::AttributeDescriptor &el) SERIALISE_MEMBER(format); } +template +void DoSerialise(SerialiserType &ser, RDMTL::BufferLayoutDescriptor &el) +{ + SERIALISE_MEMBER(stride); + SERIALISE_MEMBER(stepFunction); + SERIALISE_MEMBER(stepRate); +} + template void DoSerialise(SerialiserType &ser, RDMTL::FunctionGroup &el) { @@ -377,6 +385,7 @@ INSTANTIATE_SERIALISE_TYPE(RDMTL::VertexAttributeDescriptor); INSTANTIATE_SERIALISE_TYPE(RDMTL::VertexBufferLayoutDescriptor); INSTANTIATE_SERIALISE_TYPE(RDMTL::VertexDescriptor); INSTANTIATE_SERIALISE_TYPE(RDMTL::AttributeDescriptor); +INSTANTIATE_SERIALISE_TYPE(RDMTL::BufferLayoutDescriptor); 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 93ce9a5f0..9fd6d3a78 100644 --- a/renderdoc/driver/metal/metal_stringise.cpp +++ b/renderdoc/driver/metal/metal_stringise.cpp @@ -1200,6 +1200,24 @@ rdcstr DoStringise(const MTL::AttributeFormat &el) END_ENUM_STRINGISE() } +template <> +rdcstr DoStringise(const MTL::StepFunction &el) +{ + BEGIN_ENUM_STRINGISE(MTL::StepFunction) + { + MTL_STRINGISE_ENUM(StepFunctionConstant); + MTL_STRINGISE_ENUM(StepFunctionPerVertex); + MTL_STRINGISE_ENUM(StepFunctionPerInstance); + MTL_STRINGISE_ENUM(StepFunctionPerPatch); + MTL_STRINGISE_ENUM(StepFunctionPerPatchControlPoint); + MTL_STRINGISE_ENUM(StepFunctionThreadPositionInGridX); + MTL_STRINGISE_ENUM(StepFunctionThreadPositionInGridY); + MTL_STRINGISE_ENUM(StepFunctionThreadPositionInGridXIndexed); + MTL_STRINGISE_ENUM(StepFunctionThreadPositionInGridYIndexed); + } + 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 6f81fad31..1fe279af1 100644 --- a/renderdoc/driver/metal/metal_types.cpp +++ b/renderdoc/driver/metal/metal_types.cpp @@ -334,6 +334,18 @@ void AttributeDescriptor::CopyTo(MTL::AttributeDescriptor *objc) objc->setFormat(format); } +BufferLayoutDescriptor::BufferLayoutDescriptor(MTL::BufferLayoutDescriptor *objc) + : stride(objc->stride()), stepFunction(objc->stepFunction()), stepRate(objc->stepRate()) +{ +} + +void BufferLayoutDescriptor::CopyTo(MTL::BufferLayoutDescriptor *objc) +{ + objc->setStride(stride); + objc->setStepFunction(stepFunction); + objc->setStepRate(stepRate); +} + 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 e14720c03..9680150ac 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(StepFunction); MTL_DECLARE_REFLECTION_TYPE(AttributeFormat); template <> @@ -275,6 +276,18 @@ struct AttributeDescriptor MTL::AttributeFormat format = MTL::AttributeFormatInvalid; }; +// MTLBufferLayoutDescriptor : 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 BufferLayoutDescriptor +{ + BufferLayoutDescriptor() = default; + BufferLayoutDescriptor(MTL::BufferLayoutDescriptor *objc); + void CopyTo(MTL::BufferLayoutDescriptor *objc); + NS::UInteger stride = 0; + MTL::StepFunction stepFunction = MTL::StepFunctionConstant; + NS::UInteger stepRate = 0; +}; + // Helper struct for holding MTLLinkedFunctions::groups data // NSDictionary>*> *groups; struct FunctionGroup @@ -473,6 +486,7 @@ RDMTL_DECLARE_REFLECTION_STRUCT(VertexAttributeDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(VertexBufferLayoutDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(VertexDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(AttributeDescriptor); +RDMTL_DECLARE_REFLECTION_STRUCT(BufferLayoutDescriptor); RDMTL_DECLARE_REFLECTION_STRUCT(FunctionGroup); RDMTL_DECLARE_REFLECTION_STRUCT(LinkedFunctions); RDMTL_DECLARE_REFLECTION_STRUCT(RenderPipelineDescriptor);