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

Add override for getCustomAttribute in MetalTextureGpu #237

Merged

Conversation

srmainwaring
Copy link
Contributor

@srmainwaring srmainwaring commented Oct 19, 2021

This PR implements an override for the function getCustomAttribute in the class MetalTextureGpu.

This function is may be used to access some of the render systems underlying objects. For Metal we are interested in getting the object id for a texture. The two named attributes that may be accessed are msFinalTextureBuffer and msMsaaTextureBuffer, for example:

void *mtlTexturePtr = nullptr;
texture->getCustomAttribute( "msFinalTextureBuffer", &mtlTexturePtr );
id<MTLTexture> mtlTexture = CFBridgingRelease( mtlTexturePtr );

@darksylinc
Copy link
Member

Hi!

That is not the best way to transfer ptrs around in ARC.

Please do what MetalWindow::getCustomAttribute does which uses CFBridgingRetain:

*static_cast<void**>(pData) = (void*)CFBridgingRetain( mMetalView );

and is obtained via:

void *uiViewPtr = 0;
renderWindow->getCustomAttribute( "UIView", &uiViewPtr );
UIView *uiView = CFBridgingRelease( uiViewPtr );

Which is also used by MetalRenderSystem::_hlmsComputePipelineStateObjectCreated and _hlmsSamplerblockCreated

- Implement method getCustomAttribute for MetalTextureGpu
- The caller takes ownership of the object via CFBridgingRetain.

Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
@srmainwaring srmainwaring force-pushed the feature/metal-custom-attributes branch from 193be43 to 3b11873 Compare October 20, 2021 09:06
@srmainwaring
Copy link
Contributor Author

@darksylinc thanks for the feedback - I've modified the PR and force pushed the change.

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

Successfully merging this pull request may close these issues.

2 participants