-
Notifications
You must be signed in to change notification settings - Fork 27
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.
b2f4953
to
56f38db
Compare
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! |
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]>
Signed-off-by: Michael Pollind <[email protected]>
b727121
to
b027a75
Compare
Signed-off-by: Michael Pollind <[email protected]>
Thanks for the progress. Very appreciated. |
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]>
so i guess you encode the data to an argument buffer. I guess to reproduce descriptor sets the pool would allocate an argument buffer for n number of descriptor sets?
|
To be honest I don't follow. Please, explain the problem and a solution. Is the question about indirect drawing or something else? |
Correct. Metal requires to fill argument buffers even for non-indirect draw calls, so you need to store descriptors in it. |
any clue how these properties line up with DescriptorRangeDesc?
|
Signed-off-by: Michael Pollind <[email protected]>
An obvious suggestion: you can look at
(looking at MTL docs...) |
I've been looking at the MoltenVK source, thanks for the suggestion. umm, ill have to do a bit of research i don't want to have to extend |
Why do you need to potentially extend case DescriptorType::TEXTURE:
argDescriptor.dataType = MTLDataTypeTexture;
argDescriptor.textureType = MTLTextureType2D; // descriptor type does not have this
break; ? |
https://developer.apple.com/documentation/metal/mtltexturetype defines 1D/1DArray/2D/2dArray/Cube/CubeArray etc ... ill have to see NRISamples when I get there. just something to note later on. Ummm, I still need to finish metal cmd buffers. |
You can do the same trick as here - NRI/Source/D3D11/DescriptorD3D11.hpp Line 55 in 205cf05
|
in what way? |
AFAIK, MTLTextureDescriptor is a direct analogue of NriDescriptor, so it shouldn't be hard to identify the texture type when creating the descriptor. If I'm right, you can use TextureViewType to identify the MTLTextureType. |
The problem is that there are no |
https://github.com/KhronosGroup/MoltenVK/blob/1d2ec638532268d076a550262df2e5e5e4fd2c9e/MoltenVK/MoltenVK/GPUObjects/MVKDescriptorSet.mm#L1146C43-L1146C67 |
No description provided.