Skip to content
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

No way to read pixels from an external texture for Apple textures #1385

Open
Allan121 opened this issue May 31, 2024 · 0 comments
Open

No way to read pixels from an external texture for Apple textures #1385

Allan121 opened this issue May 31, 2024 · 0 comments
Milestone

Comments

@Allan121
Copy link

Allan121 commented May 31, 2024

There is currently no way to wait for the underlying texture to synchronise and be ready for reading.

I've implemented a workaround that effectively allows us to wait for the internal command buffer to complete with the following:

deviceUpdate->Finish();
device->FinishRenderingCurrentFrame();
auto buffer = ((__bridge id<MTLCommandQueue>)device->GetPlatformInfo().CommandQueue).commandBuffer;
[buffer commit];
[buffer waitUntilCompleted];
device->StartRenderingCurrentFrame();
deviceUpdate->Start();

By creating and enqueueing another buffer, and waiting for it to complete, we can essentially ensure that all previous buffers have also completed, in turn ensuring that any textures that were involved in the rendered frame would also be ready to read from.

Ideally, we should have something similar exposed to allow safe reading of pixels from external textures.

Relevant docs for reading pixels from MTLTexture (note the reference of needing synchronise prior to reading):
https://developer.apple.com/documentation/metal/mtltexture/1516318-getbytes

@thomlucc thomlucc modified the milestone: 8.0 Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants