It appears that when a class like the following:
" class RoomCaptureViewController: UIViewController,
RoomCaptureViewDelegate,ARSCNViewDelegate,
MTKViewDelegate, ARSessionDelegate, RoomCaptureSessionDelegate. "
has multiple delegates, the ordering of the priority of each message is delivered to a delegate by a priority sensitive order based algorithm and that one message can be processed by only one delegate and not passed off to other delegates if they don't have the proper entry points. Specifically I noted that changing the order seems to result in a delegate not getting a message that it should be seeing. Is there a "handoff" call that can be made after a delegate has seen a message but needs to pass it off to another delegate for processing? This is a protocol typically utilized in Interrupt handlers for PCIe and other messaging protocols and I have not been able to find a similar capability In the voluminous documentation available for IOS and Mac systems. I would also like to know how a message is dispatched by a class to the particular delegate for which the message was intended. Is there a detailed document that explains how the messaging protocol works that is not so fragmented as to require having multiple monitors open in order to form a coherent picture of the messaging interface for Delegates belonging to a class?
MetalKit
RSS for tagRender graphics in a standard Metal view, load textures from many sources, and work efficiently with models provided by Model I/O using MetalKit.
Posts under MetalKit tag
47 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I'm brand new to Metal. I've googled, but can't get the right answer to come up. (Thanks, unhelpful ChatGPT generated answers polluting everything, but I digress...)
Ultimately, I'm trying to figure out how to use Metal to render 3D DICOM data on iOS specifically. If you're not familiar with DICOM, let's just say I've got a whole stack of CT image slices. Or to get really simple, I've got a cube of voxel values with differing values at each voxel coordinate.
Where do I even start in Metal to render something like this?
(I was trying to get the VTK toolkit compiled for iOS, which uses OpenGL, but that appears to be a dead end. And besides, Metal is supposed to be so much better.)
Thanks for any tips/leads/suggestions/general pointers.
I'm trying to follow the metal-cpp tutorials I've found at https://developer.apple.com/metal/sample-code/?q=learn
The program seems to be launching correctly (I can see the menu bar and interact with it), but nothing is rendered inside the window. I suppose the culprit is somewhere in the following function (I see it binds the device, the view and the window with the object in charge of drawing stuff in the view)
void core::Application::applicationDidFinishLaunching(NS::Notification *pNotification)
{
CGRect frame = (CGRect){{100.0, 100.0}, {512.0, 512.0}};
m_Window->init(frame, NS::WindowStyleMaskClosable | NS::WindowStyleMaskTitled, NS::BackingStoreBuffered, false);
m_Device = MTL::CreateSystemDefaultDevice();
m_View = MTK::View::alloc()->init(frame, m_Device);
m_View->setColorPixelFormat(MTL::PixelFormat::PixelFormatBGRA8Unorm);
m_View->setClearColor(MTL::ClearColor::Make(1.0, 0.0, 0.0, 1.0));
m_ViewDelegate = new graphics::ViewDelegate(m_Device);
m_View->setDelegate(m_ViewDelegate);
m_Window->setContentView(m_View);
m_Window->setTitle(NS::String::string("Template 1", NS::StringEncoding::UTF8StringEncoding));
m_Window->makeKeyAndOrderFront(nullptr);
NS::Application* nsApp = reinterpret_cast<NS::Application*>(pNotification->object());
nsApp->activateIgnoringOtherApps(true);
}
but, as you can infer from the fact that I'm failing at the very first tutorial of the bunch, I'm quite lost. I've tried debugging the app with the Xcode debugger and I saw that it never enters in this function.
void ViewDelegate::drawInMTKView(MTK::View *pView)
{
m_Renderer->Draw(pView);
}
Can it be a symptom of some call missing from my code?
Thank you in advance for your help
I have provided a test UIKit app which displays three different images, side by side, each inside a separate MTKView. Each image is tagged with a different color profile:
Display P3
uRGB
Test RGB (from an image supplied in Apple's ImageApp sample).
I set up default values for all color spaces and formats. I then check if the image is tagged and, if so, I override those values with state from the tagged color space.
The variables I am setting:
“workingColorSpace” in the Metal CIContext, default = sRGB
“workingFormat” in the Metal CIContext, default = RGBAf
“outputColorSpace” in the Metal CIContext, default = displayP3
“colorPixelFormat” in the MTKView, default = bgra8Unorm
“colorSpace” in a CIRenderDestination that I use in the MTKView delegate draw method
The “colorSpace” default value = CGColorSpaceCreateDeviceRGB()
I also set “pixelFormat” in CIRenderDestination with the MTKView.colorPixelFormat.
If the image is tagged, I override the following values with the tagged colorSpace:
CIContext.workingColorSpace
CIContext.outputColorSpace
CIRenderDestination.colorSpace
If the tagged colorSpace.isWideGamutRGB = true, then I set the CIRenderDestination.colorSpace to extendedSRGB, ignoring the color space in the tagged wide gamut color space, as well as set the colorPixelFormat = bgr10_xr
Results:
The above scenario will properly render the DisplayP3 image, and the uRGB image. The “Test RGB” image fails:
If I do not override the CIRenderDestination.colorSpace with a value from the tagged image, then the “Test RGB” image succeeds, but the “uRGB” image fails to render properly:
Question: Do I have everything hooked up correctly and, if so, why does one image fail, and the other succeed?
Link to sample project:
https://www.dropbox.com/scl/fi/57u2fcrgdvys7jtzykzxt/ColorSpaceTest.zip?rlkey=unjeeiu7mi0wx9wfpylt78nwd&dl=0
I am working on an application where we are planning to use Metal for directly rendering custom content. When user looks at something on the rendered image, I want to get the position or ray of cursor (the point where the user is currently looking at) to render something else like a crosshair. Is it possible to get the cursor position information on VisionOS to accomplish this? How can I know if something is being hovered on by the eyes?
I wanna draw a pixel buffer directly on the screen with the Metal API.
in OpenGL I can use glDrawPixels
how to do it in Metal?
Is MTKView intentionally unavailable on visionOS or is this an issue with the current beta?