-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: apple support #89
base: main
Are you sure you want to change the base?
feat: apple support #89
Conversation
Source/Metal/DeviceMetal.mm
Outdated
if (strstr(m_Desc.adapterDesc.name, "Apple")) | ||
{ | ||
m_Desc.adapterDesc.vendor = nri::Vendor::APPLE; | ||
} else { | ||
const uint64_t regID = [m_Device registryID]; | ||
if (regID) | ||
{ | ||
io_registry_entry_t entry = IOServiceGetMatchingService(kIOMasterPortDefault, IORegistryEntryIDMatching(regID)); | ||
if (entry) | ||
{ | ||
// That returned the IOGraphicsAccelerator nub. Its parent, then, is the actual PCI device. | ||
io_registry_entry_t parent; | ||
if (IORegistryEntryGetParentEntry(entry, kIOServicePlane, &parent) == kIOReturnSuccess) | ||
{ | ||
m_Desc.adapterDesc.vendor = GetVendorFromID(GetEntryProperty(parent, CFSTR("vendor-id"))); | ||
m_Desc.adapterDesc.deviceId = GetEntryProperty(parent, CFSTR("device-id")); | ||
IOObjectRelease(parent); | ||
} | ||
IOObjectRelease(entry); | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something interesting, I guess apple doesn't report the device/vendor.
"Apple": {
"id": "0x106b",
"_comment": [
"Apple GPUs do not report a DeviceID via the Metal API, and as such the typical device",
"pattern matching does not work for them. The recommended approach is to find the highest",
"supported 'common' family supported and report it as the architecture.",
"Examples: 'common-1', 'common-3'",
"https://developer.apple.com/documentation/metal/gpu_devices_and_work_submission/detecting_gpu_features_and_metal_software_versions"
]
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a problem. Just do what Metal's layer says and just pass the single device.
20992dc
to
a5806a5
Compare
// defined in apple framework | ||
#undef INTEL | ||
#undef AMD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like these are #defined in apple framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't mind to add these undefs to the interface.
Source/Metal/ConversionMTL.h
Outdated
constexpr std::array<MTLDataType, (size_t)DescriptorType::MAX_NUM> DESCRIPTOR_TYPES = { | ||
MTLDataTypeSampler, // SAMPLER | ||
MTLDataTypeNone, // CONSTANT_BUFFER | ||
MTLDataTypeTexture, // TEXTURE | ||
MTLDataTypeNone, // STORAGE_TEXTURE | ||
MTLDataTypeStruct, // BUFFER | ||
MTLDataTypeStruct, // STORAGE_BUFFER | ||
MTLDataTypeArray, // STRUCTURED_BUFFER | ||
MTLDataTypeStruct, // STORAGE_STRUCTURED_BUFFER | ||
MTLDataTypePrimitiveAccelerationStructure // ACCELERATION_STRUCTURE | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how this will work in practice.
69abd41
to
51a6f96
Compare
@dzhdanNV just an observation you nearly have a pure C interface any reason for the C++ code to abstract across that. you can also just union a bunch of stuff together for dx12/dx11/vulkan/metal. You also have all this logic to build tables of functions etc ... avoid having to use a C++ so it should be easier to distribute. I guess you could just access that data based on the api.
|
Source/Metal/CommandBufferMTL.mm
Outdated
indexBufferOffset: m_CurrentIndexCmd.m_Offset]; | ||
} | ||
void CommandBufferMTL::DrawIndirect(const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {} | ||
void CommandBufferMTL::DrawIndexedIndirect(const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like there isn't a count buffer implement provided by the encoder. https://developer.apple.com/documentation/metal/mtlrendercommandencoder/render_pass_drawing_commands?language=objc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping me when you're done with the base implementation, I'll try to get samples to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, argument buffers can be used to emulate root constants/push constants. But yes, you can also use it for count buffers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, argument buffers can be used to emulate root constants/push constants. But yes, you can also use it for count buffers
feel free to jump in if you know what to do, you can drop me a PR and i can merge it. still looking around at the metal docs and trying to roughly get something together, will take quite a bit there is a lot here to cover.
Source/Metal/CommandBufferMTL.mm
Outdated
Result CommandBufferMTL::Begin(const DescriptorPool* descriptorPool) { | ||
|
||
} | ||
Result CommandBufferMTL::End() { | ||
|
||
} | ||
void CommandBufferMTL::SetPipeline(const Pipeline& pipeline) { | ||
if (m_CurrentPipeline == (PipelineMTL*)&pipeline) | ||
return; | ||
PipelineMTL& pipelineImpl = (PipelineMTL&)pipeline; | ||
m_CurrentPipeline = &pipelineImpl; | ||
|
||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure how these will fit together i only know about encoder once the pipeline is set. the attachment is know only with BeginRendering
https://developer.apple.com/documentation/metal/mtlcommandencoder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have something rough for this CommandBufferMTL. hopefully I can get something rough.
Source/Metal/CommandBufferMTL.mm
Outdated
indexBufferOffset: m_CurrentIndexCmd.m_Offset]; | ||
} | ||
void CommandBufferMTL::DrawIndirect(const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {} | ||
void CommandBufferMTL::DrawIndexedIndirect(const Buffer& buffer, uint64_t offset, uint32_t drawNum, uint32_t stride, const Buffer* countBuffer, uint64_t countBufferOffset) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, argument buffers can be used to emulate root constants/push constants. But yes, you can also use it for count buffers
feel free to jump in if you know what to do, you can drop me a PR and i can merge it. still looking around at the metal docs and trying to roughly get something together, will take quite a bit there is a lot here to cover.
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
Signed-off-by: Michael Pollind <[email protected]>
b2f4953
to
56f38db
Compare
Signed-off-by: Michael Pollind <[email protected]>
been busy with something else, I'll have to catch up to this once i finish up what i want to do with this game project im working on. |
Sure, no prob. And tons of thanks for working on native Apple support! |
No description provided.