author | jdv |
Fri, 21 Jun 2019 12:08:37 +0530 | |
branch | metal-prototype-branch |
changeset 57416 | e153174dba06 |
permissions | -rw-r--r-- |
57416
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
1 |
/* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
4 |
* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
10 |
* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
15 |
* accompanied this code). |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
16 |
* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
20 |
* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
23 |
* questions. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
24 |
*/ |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
25 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
26 |
#ifndef MTLGraphicsConfig_h_Included |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
27 |
#define MTLGraphicsConfig_h_Included |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
28 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
29 |
#import "jni.h" |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
30 |
#import "MTLSurfaceDataBase.h" |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
31 |
#import "MTLContext.h" |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
32 |
#import <Cocoa/Cocoa.h> |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
33 |
#import <Metal/Metal.h> |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
34 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
35 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
36 |
@interface MTLGraphicsConfigUtil : NSObject {} |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
37 |
+ (void) _getMTLConfigInfo: (NSMutableArray *)argValue; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
38 |
@end |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
39 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
40 |
// REMIND: Using an NSOpenGLPixelBuffer as the scratch surface has been |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
41 |
// problematic thus far (seeing garbage and flickering when switching |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
42 |
// between an NSView and the scratch surface), so the following enables |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
43 |
// an alternate codepath that uses a hidden NSWindow/NSView as the scratch |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
44 |
// surface, for the purposes of making a context current in certain |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
45 |
// situations. It appears that calling [NSOpenGLContext setView] too |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
46 |
// frequently contributes to the bad behavior, so we should try to avoid |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
47 |
// switching to the scratch surface whenever possible. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
48 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
49 |
/* Do we need this if we are using all off-screen drawing ? */ |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
50 |
#define USE_NSVIEW_FOR_SCRATCH 1 |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
51 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
52 |
/* Uncomment to have an additional CAOGLLayer instance tied to |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
53 |
* each instance, which can be used to test remoting the layer |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
54 |
* to an out of process window. The additional layer is needed |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
55 |
* because a layer can only be attached to one context (view/window). |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
56 |
* This is only for testing purposes and can be removed if/when no |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
57 |
* longer needed. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
58 |
*/ |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
59 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
60 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
61 |
/** |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
62 |
* The MTLGraphicsConfigInfo structure contains information specific to a |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
63 |
* given CGLGraphicsConfig (pixel format). |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
64 |
* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
65 |
* jint screen; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
66 |
* The screen and PixelFormat for the associated CGLGraphicsConfig. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
67 |
* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
68 |
* NSOpenGLPixelFormat *pixfmt; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
69 |
* The pixel format of the native NSOpenGL context. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
70 |
* |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
71 |
* MTLContext *context; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
72 |
* The context associated with this CGLGraphicsConfig. |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
73 |
*/ |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
74 |
typedef struct _MTLGraphicsConfigInfo { |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
75 |
jint screen; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
76 |
NSOpenGLPixelFormat *pixfmt; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
77 |
MTLContext *context; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
78 |
} MTLGraphicsConfigInfo; |
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
79 |
|
e153174dba06
Merge JDK-8220154 initial metal implementation patch to the jdk sandbox branch
jdv
parents:
diff
changeset
|
80 |
#endif /* MTLGraphicsConfig_h_Included */ |