On Tue, 15 Jul 2025 05:41:32 GMT, Ambarish Rapte <ara...@openjdk.org> wrote:

>> ### Description
>> This is the implementation of new graphics rendering pipeline for JavaFX 
>> using Metal APIs on MacOS.
>> We released two Early Access (EA) builds and have reached a stage where it 
>> is ready to be integrated.
>> Default rendering pipeline on macOS has not been changed by this PR. OpenGL 
>> still stays as the default rendering pipeline and Metal rendering pipeline 
>> is optional to choose (by providing  `-Dprism.order=mtl`)
>> The `-Dprism.verbose=true` option can be used to verify the rendering 
>> pipeline in use.
>> 
>> ### Details about the changes
>> 
>> **Shader changes**
>> - MSLBackend class: This is the primary class that parses (Prism and Decora) 
>> jsl shaders into Metal shaders(msl)
>> - There are a few additional Metal shader files added under directory : 
>> modules/javafx.graphics/src/main/native-prism-mtl/msl
>> 
>> **Build changes** - There are new tasks added to build.gradle for
>> - Generation/ Compilation/ linking of Metal shaders
>> - Compilation of Prism Java and Objective C files
>> 
>> **Prism** - Prism is the rendering engine of JavaFX.
>> - Added Metal specific Java classes and respective native implementation 
>> which use Metal APIs
>> - Java side changes:
>>   - New Metal specific classes: Classes prefixed with MTL, are added here : 
>> modules/javafx.graphics/src/main/java/com/sun/prism/mtl 
>>   - Modification to Prism common classes: A few limited changes were 
>> required in Prism common classes to support Metal classes. 
>> - Native side changes:
>>   - New Metal specific Objective C implementation is added here: 
>> modules/javafx.graphics/src/main/native-prism-mtl
>> 
>> **Glass** - Glass is the windowing toolkit of JavaFX
>> - Existing Glass classes are refactored to support both OpenGL and Metal 
>> pipelines
>> - Added Metal specific Glass implementation.
>> 
>> ### Testing
>> - Testing performed on different hardware and macOS versions.
>>   - HW - macBooks with Intel, Intel with discrete graphics card, Apple 
>> Silicon (M1, M2 and M4)
>>   - macOS versions - macOS 13, macOS 14 and macOS 15
>> - Functional Testing:
>>   - All headful tests pass with Metal pipeline.
>>   - Verified samples applications: Ensemble and toys
>> - Performance Testing:
>>   - Tested with RenderPerfTest: Almost all tests match/exceed es2 
>> performance except a few that fall a little short on different hardwares. 
>> These will be addressed separately (there are open bugs already filed)
>> 
>> ### Note to reviewers :
>> - Providing `-Dprism.order=mtl` option is a must for testing the Metal 
>> pipeline
>> - It woul...
>
> Ambarish Rapte has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   changes for running apps in eclipse

modules/javafx.graphics/src/main/native-glass/mac/GlassCGLOffscreen.h line 45:

> 43:     GLuint              _textureWidth;
> 44:     GLuint              _textureHeight;
> 45:     NSView* glassView;

minor: we probably should not try to align, but simply use a single space char, 
as in java code.

modules/javafx.graphics/src/main/native-glass/mac/GlassCGLOffscreen.m line 48:

> 46:             {
> 47:                 // TODO: implement PBuffer if needed
> 48:                 // self->_fbo = [[GlassPBuffer alloc] init];

commented out - is it going to crash of the value is `nil`?

modules/javafx.graphics/src/main/native-glass/mac/GlassCGLOffscreen.m line 143:

> 141:                                                                          
>    withObject:nil
> 142:                                                                          
> waitUntilDone:NO
> 143:                                                                          
>         modes:allModes];

minor: this indentation is hard to look at

modules/javafx.graphics/src/main/native-glass/mac/GlassMTLOffscreen.m line 68:

> 66:     [(NSObject*)self->_fbo release];
> 67:     self->_fbo = nil;
> 68:     [super dealloc];

here and elsewhere: should we protect against repeated calls to dealloc?  like 
`if(self->_fbo != nil)`

modules/javafx.graphics/src/main/native-prism-mtl/MetalPipelineManager.m line 
32:

> 30: // ---------------------------- Debug helper for Developers 
> -------------------------
> 31: //
> 32: // This implementation is to utilize "Metal Debuger" present in Xcode.

is the debugger available in production code?

modules/javafx.graphics/src/main/native-prism-mtl/MetalRingBuffer.m line 34:

> 32: static unsigned int currentBufferIndex;
> 33: 
> 34: - (MetalRingBuffer*) init:(MetalContext*)ctx

ring buffers are a frequent source of off-by-one bugs.
is it possible to have a unit test for it?

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1824#discussion_r2211378208
PR Review Comment: https://git.openjdk.org/jfx/pull/1824#discussion_r2211379651
PR Review Comment: https://git.openjdk.org/jfx/pull/1824#discussion_r2211381704
PR Review Comment: https://git.openjdk.org/jfx/pull/1824#discussion_r2211390403
PR Review Comment: https://git.openjdk.org/jfx/pull/1824#discussion_r2211415829
PR Review Comment: https://git.openjdk.org/jfx/pull/1824#discussion_r2211426199

Reply via email to